]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/versioncontrol/versioncontrolobserver.h
[versioncontrolobserver] Do not use static plugin objects
[dolphin.git] / src / views / versioncontrol / versioncontrolobserver.h
index 88c764baf7d7feca89b42a2cd2b5b83e304e900b..a42bbea6346a1e9d5e802288d50cdbd11adc7302 100644 (file)
 #ifndef VERSIONCONTROLOBSERVER_H
 #define VERSIONCONTROLOBSERVER_H
 
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
+
+#include "kversioncontrolplugin.h"
 
 #include <KFileItem>
-#include <kversioncontrolplugin.h>
+
 #include <QList>
-#include <QMutex>
 #include <QObject>
 #include <QString>
+#include <QUrl>
 
 class KFileItemList;
 class KFileItemModel;
@@ -43,19 +45,18 @@ class UpdateItemStatesThread;
  *
  * @see VersionControlPlugin
  */
-class LIBDOLPHINPRIVATE_EXPORT VersionControlObserver : public QObject
+class DOLPHIN_EXPORT VersionControlObserver : public QObject
 {
     Q_OBJECT
 
 public:
-    explicit VersionControlObserver(QObject* parent = 0);
-    virtual ~VersionControlObserver();
+    explicit VersionControlObserver(QObject* parent = nullptr);
+    ~VersionControlObserver() override;
 
     void setModel(KFileItemModel* model);
     KFileItemModel* model() const;
 
-    QList<QAction*> contextMenuActions(const KFileItemList& items) const;
-    QList<QAction*> contextMenuActions(const QString& directory) const;
+    QList<QAction*> actions(const KFileItemList& items) const;
 
 signals:
     /**
@@ -101,26 +102,31 @@ private slots:
     void slotThreadFinished();
 
 private:
-    struct ItemState
-    {
-        int index;
-        KFileItem item;
-        KVersionControlPlugin::VersionState version;
-    };
+    typedef QPair<KFileItem, KVersionControlPlugin::ItemVersion> ItemState;
 
     void updateItemStates();
 
     /**
-     * Adds recursively all items from the directory \p parentIndex into
-     * the list \p itemStates.
+     * It creates a item state list for every expanded directory and stores
+     * this list together with the directory url in the \a itemStates map.
+     *
+     * @itemStates      A map of item state lists for every expanded directory
+     *                  and its items, where the "key" is the directory url and
+     *                  the "value" is a list of ItemStates for every item
+     *                  within this directory.
+     * @firstIndex      The index to start the processing from, this is needed
+     *                  because this function is recursively called.
+     *
+     * @return          The number of (recursive) processed items.
      */
-    //void addDirectory(const QModelIndex& parentIndex, QList<ItemState>& itemStates);
+    int createItemStatesList(QMap<QString, QVector<ItemState> >& itemStates,
+                             const int firstIndex = 0);
 
     /**
      * Returns a matching plugin for the given directory.
      * 0 is returned, if no matching plugin has been found.
      */
-    KVersionControlPlugin* searchPlugin(const KUrl& directory) const;
+    KVersionControlPlugin* searchPlugin(const QUrl& directory);
 
     /**
      * Returns true, if the directory contains a version control information.
@@ -137,7 +143,9 @@ private:
 
     QTimer* m_dirVerificationTimer;
 
+    bool m_pluginsInitialized;
     KVersionControlPlugin* m_plugin;
+    QList<KVersionControlPlugin*> m_plugins;
     UpdateItemStatesThread* m_updateItemStatesThread;
 
     friend class UpdateItemStatesThread;