]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Implemented the new KParts extension, KParts::ListingiNotificationExtension.
authorDawit Alemayehu <adawit@kde.org>
Wed, 5 Sep 2012 02:26:28 +0000 (22:26 -0400)
committerDawit Alemayehu <adawit@kde.org>
Fri, 7 Sep 2012 12:54:14 +0000 (08:54 -0400)
REVIEW: 106333
(cherry picked from commit acef4b1c287a315b42550c27fc18ac4b9f49746c)

src/dolphinpart.cpp
src/dolphinpart.h
src/kitemviews/kfileitemmodel.h
src/views/dolphinview.h

index bf3d2a54f9718c2a4e7e2c0c1a206c0167a62b26..a957fa665aed811ba5d88fe9821170bca1a6e096 100644 (file)
@@ -45,6 +45,8 @@
 #include "views/dolphinviewactionhandler.h"
 #include "views/dolphinnewfilemenuobserver.h"
 #include "views/dolphinremoteencoding.h"
+#include "kitemviews/kfileitemmodel.h"
+#include "kitemviews/private/kfileitemmodeldirlister.h"
 
 #include <QActionGroup>
 #include <QApplication>
@@ -120,6 +122,15 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
     new DolphinPartFileInfoExtension(this);
     new DolphinPartListingFilterExtension(this);
 
+    KDirLister* lister = m_view->m_model->m_dirLister;
+    if (lister) {
+        DolphinPartListingNotificationExtension* notifyExt = new DolphinPartListingNotificationExtension(this);
+        connect(lister, SIGNAL(newItems(KFileItemList)), notifyExt, SLOT(slotNewItems(KFileItemList)));
+        connect(lister, SIGNAL(itemsDeleted(KFileItemList)), notifyExt, SLOT(slotItemsDeleted(KFileItemList)));
+    } else {
+        kWarning() << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
+    }
+
     createActions();
     m_actionHandler->updateViewActions();
     slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions
@@ -128,7 +139,6 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
     // (sort of spacial navigation)
 
     loadPlugins(this, this, componentData());
-
 }
 
 DolphinPart::~DolphinPart()
@@ -706,4 +716,27 @@ void DolphinPartListingFilterExtension::setFilter (KParts::ListingFilterExtensio
     }
 }
 
+////
+
+DolphinPartListingNotificationExtension::DolphinPartListingNotificationExtension(DolphinPart* part)
+    :KParts::ListingNotificationExtension(part)
+{
+}
+
+KParts::ListingNotificationExtension::NotificationEventTypes DolphinPartListingNotificationExtension::supportedNotificationEventTypes() const
+{
+    return (KParts::ListingNotificationExtension::ItemsAdded |
+            KParts::ListingNotificationExtension::ItemsDeleted);
+}
+
+void DolphinPartListingNotificationExtension::slotNewItems(const KFileItemList& items)
+{
+    emit listingEvent(KParts::ListingNotificationExtension::ItemsAdded, items);
+}
+
+void DolphinPartListingNotificationExtension::slotItemsDeleted(const KFileItemList& items)
+{
+    emit listingEvent(KParts::ListingNotificationExtension::ItemsDeleted, items);
+}
+
 #include "dolphinpart.moc"
index f9c0bbf62a89047063195428f71fc50404447096..6cf9fe324345084732c003c12fdcf81a674f10a4 100644 (file)
@@ -297,4 +297,17 @@ private:
     DolphinPart* m_part;
 };
 
+class DolphinPartListingNotificationExtension : public KParts::ListingNotificationExtension
+{
+    Q_OBJECT
+
+public:
+    DolphinPartListingNotificationExtension(DolphinPart* part);
+    virtual NotificationEventTypes supportedNotificationEventTypes() const;
+
+public Q_SLOTS:
+   void slotNewItems(const KFileItemList&);
+   void slotItemsDeleted(const KFileItemList&);
+};
+
 #endif /* DOLPHINPART_H */
index 958fa104bb3ef91bd69c096ebb41fc1dd9bc9db4..5bcebce247b0830156670a9249478119b62a7124 100644 (file)
@@ -475,6 +475,7 @@ private:
     friend class KFileItemModelRolesUpdater;   // Accesses emitSortProgress() method
     friend class KFileItemModelTest;           // For unit testing
     friend class KFileItemListViewTest;        // For unit testing
+    friend class DolphinPart;                  // Accesses m_dirLister
 };
 
 inline bool KFileItemModel::isChildItem(int index) const
index 3f08c448007fa342ad0c1fdb8447915e27202f73..3f71fdc547aaf5e173dc90e6104c9637ca43c0c1 100644 (file)
@@ -764,6 +764,7 @@ private:
     // For unit tests
     friend class TestBase;
     friend class DolphinDetailsViewTest;
+    friend class DolphinPart;                   // Accesses m_model
 };
 
 /// Allow using DolphinView::Mode in QVariant