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 17:39:00 GMT 2018


pino added a comment.


  OK, second attempt (still untested!), resolving mimetypes on lookup:
  
    diff --git a/src/KDbDriverManager.cpp b/src/KDbDriverManager.cpp
    index 0d35729c..297910b4 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());
    @@ -162,7 +177,12 @@ QStringList DriverManagerInternal::driverIdsForMimeType(const QString &mimeType)
         if (!lookupDrivers()) {
             return QStringList();
         }
    -    const QList<KDbDriverMetaData*> metaDatas(m_metadata_by_mimetype.values(mimeType.toLower()));
    +    QMimeDatabase mimedb;
    +    const QMimeType mime = mimedb.mimeTypeForName(mimeType);
    +    if (!mime.isValid()) {
    +        return QStringList();
    +    }
    +    const QList<KDbDriverMetaData*> metaDatas(m_metadata_by_mimetype.values(mime.name()));
         QStringList result;
         foreach (const KDbDriverMetaData* metaData, metaDatas) {
             result.append(metaData->id());

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/a0e0987d/attachment.html>


More information about the Kexi-devel mailing list