]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Update previews when the preview-plugin settings have changed
authorPeter Penz <peter.penz19@gmail.com>
Wed, 21 Dec 2011 20:45:46 +0000 (21:45 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 21 Dec 2011 20:47:40 +0000 (21:47 +0100)
Thanks to Janardhan Reddy for the initial patch.

BUG: 288726
FIXED-IN: 4.8.0

src/kitemviews/kfileitemlistview.cpp
src/kitemviews/kfileitemlistview.h
src/kitemviews/kfileitemmodelrolesupdater.cpp
src/kitemviews/kfileitemmodelrolesupdater.h
src/views/dolphinitemlistcontainer.cpp

index e2bde3b12edc70b5f5cbf0915f7c5d9466c607ae..89fec9d0f8b28e1afbbb1193784df100951671da 100644 (file)
@@ -107,6 +107,18 @@ KFileItemListView::Layout KFileItemListView::itemLayout() const
     return m_itemLayout;
 }
 
+void KFileItemListView::setEnabledPlugins(const QStringList& list)
+{
+    if (m_modelRolesUpdater) {
+        m_modelRolesUpdater->setEnabledPlugins(list);
+    }
+}
+
+QStringList KFileItemListView::enabledPlugins() const
+{
+    return m_modelRolesUpdater ? m_modelRolesUpdater->enabledPlugins() : QStringList();
+}
+
 QSizeF KFileItemListView::itemSizeHint(int index) const
 {
     const QHash<QByteArray, QVariant> values = model()->data(index);
@@ -333,10 +345,7 @@ void KFileItemListView::onModelChanged(KItemModelBase* current, KItemModelBase*
     Q_UNUSED(previous);
     Q_ASSERT(qobject_cast<KFileItemModel*>(current));
 
-    if (m_modelRolesUpdater) {
-        delete m_modelRolesUpdater;
-    }
-
+    delete m_modelRolesUpdater;
     m_modelRolesUpdater = new KFileItemModelRolesUpdater(static_cast<KFileItemModel*>(current), this);
     const int size = styleOption().iconSize;
     m_modelRolesUpdater->setIconSize(QSize(size, size));
index a41d091b78b099bbdf9f89d1cffb2fb57021d883..203fb78c4d9bfcced079f7d3bad97acdc60486e8 100644 (file)
@@ -57,6 +57,23 @@ public:
     void setItemLayout(Layout layout);
     Layout itemLayout() const;
 
+    /**
+     * Sets the list of enabled thumbnail plugins that are used for previews.
+     * Per default all plugins enabled in the KConfigGroup "PreviewSettings"
+     * are used.
+     *
+     * For a list of available plugins, call KServiceTypeTrader::self()->query("ThumbCreator").
+     *
+     * @see enabledPlugins
+     */
+    void setEnabledPlugins(const QStringList& list);
+
+    /**
+     * Returns the list of enabled thumbnail plugins.
+     * @see setEnabledPlugins
+     */
+    QStringList enabledPlugins() const;
+
     /** @reimp */
     virtual QSizeF itemSizeHint(int index) const;
 
index 4fe45624c607ba651fb5179b35389d3988a30b7b..671352cacdaac9a1ae37ae3b11c6e817b1e492ce 100644 (file)
@@ -169,7 +169,18 @@ bool KFileItemModelRolesUpdater::isPreviewShown() const
 
 void KFileItemModelRolesUpdater::setEnabledPlugins(const QStringList& list)
 {
+    if (m_enabledPlugins == list) {
+        return;
+    }
+
     m_enabledPlugins = list;
+    if (m_previewShown) {
+        if (m_paused) {
+            m_previewChangedDuringPausing = true;
+        } else {
+            sortAndResolveAllRoles();
+        }
+    }
 }
 
 void KFileItemModelRolesUpdater::setPaused(bool paused)
index 993cc5244334ad1768f500831a1f2e4931a180ef..065f069c84184e05e51c01000520ba65830a5960 100644 (file)
@@ -82,13 +82,10 @@ public:
     QSet<QByteArray> roles() const;
 
     /**
-     * Sets the list of enabled thumbnail plugins.
+     * Sets the list of enabled thumbnail plugins that are used for previews.
      * Per default all plugins enabled in the KConfigGroup "PreviewSettings"
      * are used.
      *
-     * Note that this method doesn't cause already generated previews
-     * to be regenerated.
-     *
      * For a list of available plugins, call KServiceTypeTrader::self()->query("ThumbCreator").
      *
      * @see enabledPlugins
index 870043bc4cf556ef40a836d77dd494412600121f..9e7a15f742683da6b72cb702253419a9e553fc45 100644 (file)
@@ -176,6 +176,13 @@ void DolphinItemListContainer::refresh()
 
     updateFont();
     updateGridSize();
+
+    const KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings");
+    const QStringList plugins = globalConfig.readEntry("Plugins", QStringList()
+                                                       << "directorythumbnail"
+                                                       << "imagethumbnail"
+                                                       << "jpegthumbnail");
+    m_fileItemListView->setEnabledPlugins(plugins);
 }
 
 void DolphinItemListContainer::updateGridSize()