]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/places/placesitemmodel.h
Port to KStandardAction::DeleteFile
[dolphin.git] / src / panels / places / placesitemmodel.h
index b850f356fb74030c9202cddbaf05bba9251fc21d..aa8bb16fe51e8c09cbf7804af39088deff693911 100644 (file)
 #ifndef PLACESITEMMODEL_H
 #define PLACESITEMMODEL_H
 
-#include <config-nepomuk.h>
+#include <config-baloo.h>
 
 #include <kitemviews/kstandarditemmodel.h>
 
-#include <KUrl>
+#include <QUrl>
 #include <QHash>
 #include <QList>
 #include <QSet>
@@ -37,16 +37,6 @@ class PlacesItem;
 class QAction;
 class QTimer;
 
-#ifdef HAVE_NEPOMUK
-    namespace Nepomuk
-    {
-        namespace Query
-        {
-            class Term;
-        }
-    }
-#endif
-
 // #define PLACESITEMMODEL_DEBUG
 
 /**
@@ -68,8 +58,8 @@ public:
      *         attributes.
      */
     PlacesItem* createPlacesItem(const QString& text,
-                                 const KUrl& url,
-                                 const QString& iconName);
+                                 const QUrl& url,
+                                 const QString& iconName = QString());
 
     PlacesItem* placesItem(int index) const;
 
@@ -97,7 +87,16 @@ public:
      * range of the URL. -1 is returned if no closest item
      * could be found.
      */
-    int closestItem(const KUrl& url) const;
+    int closestItem(const QUrl& url) const;
+
+    /**
+     * Appends the item \a item as last element of the group
+     * the item belongs to. If no item with the same group is
+     * present, the item gets appended as last element of the
+     * model. PlacesItemModel takes the ownership
+     * of the item.
+     */
+    void appendItemToGroup(PlacesItem* item);
 
     QAction* ejectAction(int index) const;
     QAction* teardownAction(int index) const;
@@ -105,31 +104,46 @@ public:
     void requestEject(int index);
     void requestTeardown(int index);
 
-    /** @reimp */
-    virtual QMimeData* createMimeData(const QSet<int>& indexes) const;
+    bool storageSetupNeeded(int index) const;
+    void requestStorageSetup(int index);
+
+    virtual QMimeData* createMimeData(const KItemSet& indexes) const Q_DECL_OVERRIDE;
 
-    void dropMimeData(int index, const QMimeData* mimeData);
+    virtual bool supportsDropping(int index) const Q_DECL_OVERRIDE;
+
+    void dropMimeDataBefore(int index, const QMimeData* mimeData);
 
     /**
      * @return Converts the URL, which contains "virtual" URLs for system-items like
-     *         "search:/documents" into a Nepomuk-Query-URL that will be handled by
+     *         "search:/documents" into a Query-URL that will be handled by
      *         the corresponding IO-slave. Virtual URLs for bookmarks are used to
      *         be independent from internal format changes.
      */
-    static KUrl convertedUrl(const KUrl& url);
+    static QUrl convertedUrl(const QUrl& url);
+
+    virtual void clear() Q_DECL_OVERRIDE;
+
+    /**
+     * Saves the bookmarks and indicates to other applications that the
+     * state of the bookmarks has been changed. Is only called by the
+     * timeout of m_saveBookmarksTimer to prevent unnecessary savings.
+     */
+    void saveBookmarks();
 
 signals:
     void errorMessage(const QString& message);
+    void storageSetupDone(int index, bool success);
 
 protected:
-    virtual void onItemInserted(int index);
-    virtual void onItemRemoved(int index, KStandardItem* removedItem);
-    virtual void onItemChanged(int index, const QSet<QByteArray>& changedRoles);
+    virtual void onItemInserted(int index) Q_DECL_OVERRIDE;
+    virtual void onItemRemoved(int index, KStandardItem* removedItem) Q_DECL_OVERRIDE;
+    virtual void onItemChanged(int index, const QSet<QByteArray>& changedRoles) Q_DECL_OVERRIDE;
 
 private slots:
     void slotDeviceAdded(const QString& udi);
     void slotDeviceRemoved(const QString& udi);
     void slotStorageTeardownDone(Solid::ErrorType error, const QVariant& errorData);
+    void slotStorageSetupDone(Solid::ErrorType error, const QVariant& errorData, const QString& udi);
     void hideItem();
 
     /**
@@ -139,13 +153,6 @@ private slots:
      */
     void updateBookmarks();
 
-    /**
-     * Saves the bookmarks and indicates to other applications that the
-     * state of the bookmarks has been changed. Is only called by the
-     * timeout of m_saveBookmarksTimer to prevent unnecessary savings.
-     */
-    void saveBookmarks();
-
 private:
     struct SystemBookmarkData;
 
@@ -160,7 +167,8 @@ private:
      *         current application (e.g. bookmarks from other applications
      *         will be ignored).
      */
-    bool acceptBookmark(const KBookmark& bookmark) const;
+    bool acceptBookmark(const KBookmark& bookmark,
+                        const QSet<QString>& availableDevices) const;
 
     /**
      * Creates a PlacesItem for a system-bookmark:
@@ -191,12 +199,6 @@ private:
      */
     void hideItem(int index);
 
-    /**
-     * Triggers a delayed saving of bookmarks by starting
-     * m_saveBookmarksTimer.
-     */
-    void triggerBookmarksSaving();
-
     QString internalMimeType() const;
 
     /**
@@ -215,7 +217,7 @@ private:
     /**
      * @return URL using the timeline-protocol for searching (see convertedUrl()).
      */
-    static KUrl createTimelineUrl(const KUrl& url);
+    static QUrl createTimelineUrl(const QUrl& url);
 
     /**
      * Helper method for createTimelineUrl().
@@ -229,15 +231,15 @@ private:
      *         for a given term. The URL \a url represents a places-internal
      *         URL like e.g. "search:/documents" (see convertedUrl()).
      */
-    static KUrl createSearchUrl(const KUrl& url);
+    static QUrl createSearchUrl(const QUrl& url);
 
-#ifdef HAVE_NEPOMUK
+#ifdef HAVE_BALOO
     /**
-     * Helper method for createSearchUrl().
+     * Helper method for createSearchUrl()
      * @return URL that can be listed by KIO and results in searching
-     *         for the given term.
+     *         for the given type
      */
-    static KUrl searchUrlForTerm(const Nepomuk::Query::Term& term);
+    static QUrl searchUrlForType(const QString& type);
 #endif
 
 #ifdef PLACESITEMMODEL_DEBUG
@@ -245,7 +247,7 @@ private:
 #endif
 
 private:
-    bool m_nepomukRunning;
+    bool m_fileIndexingEnabled;
     bool m_hiddenItemsShown;
 
     QSet<QString> m_availableDevices;
@@ -254,17 +256,17 @@ private:
 
     struct SystemBookmarkData
     {
-        SystemBookmarkData(const KUrl& url,
+        SystemBookmarkData(const QUrl& url,
                            const QString& icon,
                            const QString& text) :
             url(url), icon(icon), text(text) {}
-        KUrl url;
+        QUrl url;
         QString icon;
         QString text;
     };
 
     QList<SystemBookmarkData> m_systemBookmarks;
-    QHash<KUrl, int> m_systemBookmarksIndexes;
+    QHash<QUrl, int> m_systemBookmarksIndexes;
 
     // Contains hidden and unhidden items that are stored as
     // bookmark (the model itself only contains items that
@@ -279,8 +281,9 @@ private:
     // removing an item is not allowed.
     int m_hiddenItemToRemove;
 
-    QTimer* m_saveBookmarksTimer;
     QTimer* m_updateBookmarksTimer;
+
+    QHash<QObject*, int> m_storageSetupInProgress;
 };
 
 #endif