Hi Wolf-Michael,
I thought a bit more about where to get the mimetype definitions from, and I
can see three "backends":
1) the current "parse the big XML file" backend,
2) the current KDE solution of parsing the generated text files (globs2,
magic, aliases, etc.),
3) and the recommended-but-not-implemented-yet solution of parsing the
generated mime.cache files (in addition to per-mimetype xml files when one
asks for a mimetype's translated comment).
Solution 1 is slow, but has the advantage that it can be more easily deployed,
to Windows, without a dependency on shared-mime-info's "update-mime-database"
program.
As with any computing problem, it could be solved by another layer of
indirection :-)
class QMimeProviderBase
{
public:
QMimeProviderBase();
virtual void parseGlobs() = 0;
[and similar methods, parseMagic(), parseSubclasses(), parseAliases()]
// and virtual QString commentForMime(const QString &type) = 0;
};
class QMimeSystemProvider : public QMimeProviderBase
{
public:
QMimeSystemProvider();
// Parse the generated files (globs2, magic, subclasses) on demand
virtual void parseGlobs();
};
class QMimeXMLProvider : public QMimeProviderBase
{
public:
QMimeXMLProvider();
// Do XML parsing and store the results
virtual void parseGlobs();
};
class QMimeBinaryProvider : public QMimeProviderBase
{
QMimeXMLProvider();
// Parse mime.cache (possibly on demand, for its different areas?)
virtual void parseGlobs();
};
// In QMimeDatabase, we would do
// if system mime.cache found, new QMimeBinaryProvider
// else if system globs file found, new QMimeSystemProvider
// else {
// look for freedesktop.org.xml file in the system
// if not found, use Qt's own copy
// new QMimeXMLProvider
// }
How does this sound?
Useful or over-engineered?
Missing any use case?
This will remove the need for QMimeDatabaseBuilder (I'll just pass the
QMimeDatabasePrivate pointer to the provider), and hide the details of "where
the mimetype definitions come from", from the applications.
--
David Faure, [email protected], http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. Konqueror (http://www.konqueror.org).
_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback