D17887: Fix detection of .kexi file types after recent change of mime database on Linux for SQLite type (2018-06-17)

Pino Toscano noreply at phabricator.kde.org
Mon Dec 31 16:47:38 GMT 2018


pino added a comment.


  Another option could be to resolve the mimetypes when loading the metadata of the plugins, in `DriverManagerInternal::lookupDriversInternal()`.
  
  An untested patch can be:
  
    diff --git a/src/KDbDriverManager.cpp b/src/KDbDriverManager.cpp
    index 0d35729c..1de8e9fe 100644
    --- a/src/KDbDriverManager.cpp
    +++ b/src/KDbDriverManager.cpp
    @@ -30,6 +30,9 @@
     #include <KPluginFactory>
     
     #include <QApplication>
    +#include <QMimeDatabase>
    +#include <QMimeType>
    +#include <QSet>
     #include <QTime>
     #include <QWidget>
     
    @@ -102,6 +105,7 @@ void DriverManagerInternal::lookupDriversInternal()
                 = KDbJsonTrader::self()->query(QLatin1String("KDb/Driver"));
         const QString expectedVersion = QString::fromLatin1("%1.%2")
                 .arg(KDB_STABLE_VERSION_MAJOR).arg(KDB_STABLE_VERSION_MINOR);
    +    QMimeDatabase mimedb;
         foreach(const QPluginLoader *loader, offers) {
             //QJsonObject json = loader->metaData();
             //drivermanagerDebug() << json;
    @@ -123,7 +127,18 @@ void DriverManagerInternal::lookupDriversInternal()
                 }
                 continue;
             }
    +        QSet<QString> resolvedMimeTypes;
             foreach (const QString& mimeType, metaData->mimeTypes()) {
    +            const QMimeType mime = mimedb.mimeTypeForName(mimeType);
    +            if (!mime.isValid()) {
    +                kdbWarning() << "Driver with ID" << metaData->id()
    +                             << "supports the unknown mimetype"
    +                             << mimeType << "-- skipping it";
    +                continue;
    +            }
    +            resolvedMimeTypes.insert(mime.name());
    +        }
    +        foreach (const QString& mimeType, resolvedMimeTypes) {
                 m_metadata_by_mimetype.insertMulti(mimeType, metaData.data());
             }
             m_driversMetaData.insert(metaData->id(), metaData.data());
  
  
  The QSet is used to avoid that the same metadats is registered twice in `m_metadata_by_mimetype` for the same mimetype, in case a plugin specifies two entries (mime name and one alias of it).

REPOSITORY
  R15 KDb

REVISION DETAIL
  https://phabricator.kde.org/D17887

To: staniek, piggz
Cc: pino, Kexi-Devel-list, barman, wicik, staniek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kexi-devel/attachments/20181231/cd0e04df/attachment-0001.html>


More information about the Kexi-devel mailing list