]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.h
Update e-mail address from peter.penz@gmx.at to peter.penz19@gmail.com
[dolphin.git] / src / views / dolphinview.h
index 5fcf1ab4de861606b120b254d874fc89e14885bb..1d1d316ea19f34ef50a2516b249d157328a77cde 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006-2009 by Peter Penz <peter.penz@gmx.at>             *
+ *   Copyright (C) 2006-2009 by Peter Penz <peter.penz19@gmail.com>        *
  *   Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net>          *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 #include "libdolphin_export.h"
 
 #include <kparts/part.h>
-#include <kfileitem.h>
-#include <kfileitemdelegate.h>
+#include <KFileItem>
+#include <KFileItemDelegate>
 #include <kio/fileundomanager.h>
-#include <kio/job.h>
+#include <KIO/Job>
 
 #include <QBoxLayout>
 #include <QKeyEvent>
@@ -119,15 +119,10 @@ public:
     };
 
     /**
-     * @param parent           Parent widget of the view.
      * @param url              Specifies the content which should be shown.
-     * @param proxyModel       Used proxy model which specifies the sorting. The
-     *                         model is not owned by the view and won't get
-     *                         deleted.
+     * @param parent           Parent widget of the view.
      */
-    DolphinView(QWidget* parent,
-                const KUrl& url,
-                DolphinSortFilterProxyModel* proxyModel);
+    DolphinView( const KUrl& url, QWidget* parent);
 
     virtual ~DolphinView();
 
@@ -181,6 +176,13 @@ public:
      */
     bool supportsCategorizedSorting() const;
 
+    /**
+     * Returns the root item which represents the current URL. Note that the returned
+     * item can be null (KFileItem::isNull() will return true) in case that the directory
+     * has not been loaded.
+     */
+    KFileItem rootItem() const;
+
     /**
      * Returns the items of the view.
      */
@@ -189,7 +191,6 @@ public:
     /**
      * Returns the selected items. The list is empty if no item has been
      * selected.
-     * @see DolphinView::selectedUrls()
      */
     KFileItemList selectedItems() const;
 
@@ -274,6 +275,7 @@ public:
      * which contain the given filter string will be shown.
      */
     void setNameFilter(const QString& nameFilter);
+    QString nameFilter() const;
 
     /**
      * Calculates the number of currently shown files into
@@ -435,6 +437,11 @@ signals:
      */
     void itemTriggered(const KFileItem& item);
 
+    /**
+     * Is emitted if items have been added or deleted.
+     */
+    void itemCountChanged();
+
     /**
      * Is emitted if a new tab should be opened for the URL \a url.
      */
@@ -523,12 +530,31 @@ signals:
      */
     void finishedPathLoading(const KUrl& url);
 
+    /**
+     * Is emitted after DolphinView::setUrl() has been invoked and provides
+     * the information how much percent of the current path have been loaded.
+     */
+    void pathLoadingProgress(int percent);
+
+    /**
+     * Is emitted if the DolphinView::setUrl() is invoked but the URL is not
+     * a directory.
+     */
+    void urlIsFileError(const KUrl& file);
+
     /**
      * Emitted when KDirLister emits redirection.
      * Testcase: fish://localhost
      */
     void redirection(const KUrl& oldUrl, const KUrl& newUrl);
 
+    /**
+     * Is emitted when the write state of the folder has been changed. The application
+     * should disable all actions like "Create New..." that depend on the write
+     * state.
+     */
+    void writeStateChanged(bool isFolderWritable);
+
 protected:
     /** @see QWidget::mouseReleaseEvent */
     virtual void mouseReleaseEvent(QMouseEvent* event);
@@ -623,6 +649,12 @@ private slots:
      */
     void slotDeleteFileFinished(KJob* job);
 
+    /**
+     * Invoked when the directory lister has been started the
+     * loading of \a url.
+     */
+    void slotDirListerStarted(const KUrl& url);
+
     /**
      * Invoked when the directory lister has completed the loading of
      * items. Assures that pasted items and renamed items get seleced.
@@ -666,6 +698,8 @@ private slots:
      */
     void restoreContentsPosition();
 
+    void slotUrlChangeRequested(const KUrl& url);
+
 private:
     void loadDirectory(const KUrl& url, bool reload = false);
 
@@ -723,6 +757,16 @@ private:
      */
     QItemSelection childrenMatchingPattern(const QModelIndex& parent, const QRegExp& pattern) const;
 
+    void connectViewAccessor();
+    void disconnectViewAccessor();
+
+    /**
+     * Updates m_isFolderWritable dependent on whether the folder represented by
+     * the current URL is writable. If the state has changed, the signal
+     * writeableStateChanged() will be emitted.
+     */
+    void updateWritableState();
+
 private:
     /**
      * Abstracts the access to the different view implementations
@@ -731,7 +775,7 @@ private:
     class ViewAccessor
     {
     public:
-        ViewAccessor(DolphinSortFilterProxyModel* proxyModel);
+        ViewAccessor();
         ~ViewAccessor();
 
         void createView(QWidget* parent,
@@ -756,6 +800,7 @@ private:
          */
         QWidget* layoutTarget() const;
 
+        void setRootUrl(const KUrl& rootUrl);
         KUrl rootUrl() const;
 
         bool supportsCategorizedSorting() const;
@@ -775,12 +820,17 @@ private:
         KDirLister* dirLister() const;
 
     private:
+        KUrl m_rootUrl;
         DolphinIconsView* m_iconsView;
         DolphinDetailsView* m_detailsView;
         DolphinColumnViewContainer* m_columnsContainer;
+        DolphinModel* m_dolphinModel;
         DolphinSortFilterProxyModel* m_proxyModel;
         QAbstractItemView* m_dragSource;
         QPointer<DolphinDetailsViewExpander> m_detailsViewExpander;
+
+        // For unit tests
+        friend class DolphinDetailsViewTest;
     };
 
     bool m_active : 1;
@@ -790,6 +840,7 @@ private:
     bool m_isContextMenuOpen : 1;   // TODO: workaround for Qt-issue 207192
     bool m_assureVisibleCurrentIndex : 1;
     bool m_expanderActive : 1;
+    bool m_isFolderWritable : 1;
 
     Mode m_mode;
 
@@ -801,7 +852,6 @@ private:
 
     QTimer* m_selectionChangedTimer;
 
-    KUrl m_rootUrl;
     KUrl m_activeItemUrl;
     QPoint m_restoredContentsPosition;
     KUrl m_createdItemUrl; // URL for a new item that got created by the "Create New..." menu
@@ -816,6 +866,7 @@ private:
 
     // For unit tests
     friend class TestBase;
+    friend class DolphinDetailsViewTest;
 };
 
 /// Allow using DolphinView::Mode in QVariant