[Digikam-devel] extragear/graphics/digikam/utilities/cameragui

Gilles Caulier caulier.gilles at gmail.com
Tue May 12 10:08:52 BST 2009


SVN commit 966906 by cgilles:

more hack to try to get video thumbnails from cameragui.
code is synchronized with kdebase/runtime/kioslave/thumbnails.cpp
no plugin is found (but in album gui it work : mplayerthumbs installed)
Why ? Because cameragui use a separated thread to get thumbs ?
CCMAIL: digikam-devel at kde.org


 M  +24 -19    umscamera.cpp  


--- trunk/extragear/graphics/digikam/utilities/cameragui/umscamera.cpp #966905:966906
@@ -277,33 +277,27 @@
 {
     QString path     = folder + QString("/") + itemName;
     QString mimeType = KMimeType::findByUrl(path)->name();
-
     if (mimeType.isEmpty())
     {
         kDebug(50003) << "Mimetype not found" << endl;
         return false;
     }
 
-    QString mimeTypeAlt = mimeType.replace(QRegExp("/.*"), "/*");
-    QString plugin;
+    kDebug(50003) << "Mimetype : " << mimeType << endl;
 
-    if (!KServiceTypeTrader::self()) return false;
+    if (!KMimeTypeTrader::self())
+    {
+        kDebug(50003) << "No KMimeTypeTrader instance to get thumb from KDE" << endl;
+        return false;
+    }
 
-    KService::List plugins = KServiceTypeTrader::self()->query("ThumbCreator");
-    for (KService::List::ConstIterator it = plugins.constBegin(); it != plugins.constEnd(); ++it)
+    QString plugin;
+    KService::List offers = KMimeTypeTrader::self()->query(mimeType, QLatin1String("ThumbCreator"));
+    if (!offers.isEmpty())
     {
-        QStringList mimeTypes = (*it)->property("MimeTypes").toStringList();
-        for (QStringList::ConstIterator mt = mimeTypes.constBegin(); mt != mimeTypes.constEnd(); ++mt)
-        {
-            if  ((*mt) == mimeType || (*mt) == mimeTypeAlt)
-            {
-                plugin = (*it)->library();
-                break;
-            }
-        }
-
-        if (!plugin.isEmpty())
-            break;
+        KService::Ptr serv;
+        serv   = offers.first();
+        plugin = serv->library();
     }
 
     if (plugin.isEmpty())
@@ -312,6 +306,17 @@
         return false;
     }
 
+    kDebug(50003) << "plugin : " << plugin << endl;
+
+    // Don't use KLibFactory here, this is not a QObject and
+    // neither is ThumbCreator
+
+    if (!KMimeTypeTrader::self())
+    {
+        kDebug(50003) << "No KLibLoader instance to get thumb from KDE" << endl;
+        return false;
+    }
+
     KLibrary *library = KLibLoader::self()->library(QFile::encodeName(plugin));
     if (!library)
     {
@@ -343,7 +348,7 @@
 
 bool UMSCamera::getExif(const QString&, const QString&, char **, int&)
 {
-    // not necessary to implement this. read it directly from the file
+    // Not necessary to implement this. read data directly from the file
     // (done in camera controller)
     kWarning(50003) << "Exif implemented yet in camera controller" << endl;
     return false;



More information about the Digikam-devel mailing list