]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Step one for having DolphinParts for the icons and details view, which can be used...
authorPeter Penz <peter.penz19@gmail.com>
Wed, 14 Feb 2007 21:54:24 +0000 (21:54 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 14 Feb 2007 21:54:24 +0000 (21:54 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=633703

src/CMakeLists.txt
src/dolphincontroller.cpp [new file with mode: 0644]
src/dolphincontroller.h [new file with mode: 0644]
src/dolphindetailsview.cpp
src/dolphindetailsview.h
src/dolphiniconsview.cpp
src/dolphiniconsview.h
src/dolphinview.cpp
src/dolphinview.h

index ed7ca658242955b7ef89a696804159ec4fa22e3d..b2ea5561f3804731c0c1b810c6240c25656e80b6 100644 (file)
@@ -14,6 +14,7 @@ set(dolphin_SRCS
    bookmarkssidebarpage.cpp
    detailsviewsettingspage.cpp
    dolphinapplication.cpp
    bookmarkssidebarpage.cpp
    detailsviewsettingspage.cpp
    dolphinapplication.cpp
+   dolphincontroller.cpp
    dolphinmainwindow.cpp
    dolphinnewmenu.cpp
    dolphinview.cpp
    dolphinmainwindow.cpp
    dolphinnewmenu.cpp
    dolphinview.cpp
diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp
new file mode 100644 (file)
index 0000000..c397763
--- /dev/null
@@ -0,0 +1,63 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+#include "dolphincontroller.h"
+
+DolphinController::DolphinController(QObject* parent) :
+    QObject(parent)
+{
+}
+
+DolphinController::~DolphinController()
+{
+}
+
+void DolphinController::triggerContextMenuRequest(const QPoint& pos,
+                                                  const QPoint& globalPos)
+{
+    emit activated();
+    emit requestContextMenu(pos, globalPos);
+}
+
+void DolphinController::triggerActivation()
+{
+    emit activated();
+}
+
+void DolphinController::indicateSortingChange(DolphinView::Sorting sorting)
+{
+    emit sortingChanged(sorting);
+}
+
+void DolphinController::indicateSortOrderChange(Qt::SortOrder order)
+{
+    emit sortOrderChanged(order);
+}
+
+void DolphinController::triggerItem(const QModelIndex& index)
+{
+    emit itemTriggered(index);
+}
+
+void DolphinController::indicateSelectionChange()
+{
+    emit selectionChanged();
+}
+
+#include "dolphincontroller.moc"
diff --git a/src/dolphincontroller.h b/src/dolphincontroller.h
new file mode 100644 (file)
index 0000000..8229ade
--- /dev/null
@@ -0,0 +1,110 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+#ifndef DOLPHINCONTROLLER_H
+#define DOLPHINCONTROLLER_H
+
+#include <dolphinview.h>
+#include <kurl.h>
+#include <QObject>
+
+class KUrl;
+class QModelIndex;
+class QPoint;
+
+/**
+ * @brief Allows to control Dolphin views and to react on state changes.
+ *
+ * One instance of a DolphinController can be assigned to a variable number of
+ * Dolphin views (DolphinIconsView, DolphinDetailsView) by passing it in
+ * the constructor:
+ *
+ * \code
+ * DolphinController* controller = new DolphinController(parent);
+ * DolphinDetailsView* detailsView = new DolphinDetailsView(parent, controller);
+ * DolphinIconsView* iconsView = new DolphinIconsView(parent, controller);
+ * \endcode
+ *
+ * The Dolphin view assures that the controller gets informed about selection changes,
+ * when an item should be triggered and a lot more. The controller emits the corresponding signals
+ * so that the receiver may react on those changes.
+ */
+class DolphinController : public QObject
+{
+    Q_OBJECT
+
+public:
+    explicit DolphinController(QObject* parent);
+    virtual ~DolphinController();
+
+    void setUrl(const KUrl& url) { m_url = url; }
+    const KUrl& url() const { return m_url; }
+
+    void triggerContextMenuRequest(const QPoint& pos,
+                                   const QPoint& globalPos);
+
+    void triggerActivation();
+
+    void indicateSortingChange(DolphinView::Sorting sorting);
+
+    void indicateSortOrderChange(Qt::SortOrder order);
+
+public slots:
+    void triggerItem(const QModelIndex& index);
+    void indicateSelectionChange();
+
+signals:
+    /**
+     * Is emitted if a context menu should be opened.
+     * @param pos       Position relative to the view widget where the
+     *                  context menu should be opened. It is recommended
+     *                  to get the corresponding model index from
+     *                  this position.
+     * @param globalPos Global position where the context menu should
+     *                  be opened.
+     */
+    void requestContextMenu(const QPoint& pos,
+                            const QPoint& globalPos);
+
+    /**
+     * Is emitted if the view has been activated by e. g. a mouse click.
+     */
+    void activated();
+
+    /** Is emitted if the sorting has been changed to \a sorting. */
+    void sortingChanged(DolphinView::Sorting sorting);
+
+    /** Is emitted if the sort order has been changed to \a sort order. */
+    void sortOrderChanged(Qt::SortOrder order);
+
+    /**
+     * Is emitted if the item with the index \a index should be triggered.
+     * Usually triggering on a directory opens the directory, triggering
+     * on a file opens the corresponding application.
+     */
+    void itemTriggered(const QModelIndex& index);
+
+    /** Is emitted if the selection has been changed by the user. */
+    void selectionChanged();
+
+private:
+    KUrl m_url;
+};
+
+#endif
index 24692b5a83c20ca63c55858ec23cbb17b1e6051c..411a410d3a782c681b4f7dff29bb8251c5d3db9f 100644 (file)
 
 #include "dolphindetailsview.h"
 
 
 #include "dolphindetailsview.h"
 
-#include "dolphinmainwindow.h"
+#include "dolphincontroller.h"
 #include "dolphinsortfilterproxymodel.h"
 #include "dolphinsortfilterproxymodel.h"
-#include "dolphinview.h"
 #include "viewproperties.h"
 
 #include <assert.h>
 #include <kdirmodel.h>
 #include <QHeaderView>
 
 #include "viewproperties.h"
 
 #include <assert.h>
 #include <kdirmodel.h>
 #include <QHeaderView>
 
-DolphinDetailsView::DolphinDetailsView(DolphinView* parent) :
+DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* controller) :
     QTreeView(parent),
     QTreeView(parent),
-    m_dolphinView(parent)
+    m_controller(controller)
 {
 {
-    assert(parent != 0);
+    assert(controller != 0);
 
     setAcceptDrops(true);
     setRootIsDecorated(false);
     setSortingEnabled(true);
     setUniformRowHeights(true);
 
 
     setAcceptDrops(true);
     setRootIsDecorated(false);
     setSortingEnabled(true);
     setUniformRowHeights(true);
 
-    const ViewProperties props(parent->url());
+    const ViewProperties props(controller->url());
     setSortIndicatorSection(props.sorting());
     setSortIndicatorOrder(props.sortOrder());
 
     setSortIndicatorSection(props.sorting());
     setSortIndicatorOrder(props.sortOrder());
 
@@ -51,6 +50,9 @@ DolphinDetailsView::DolphinDetailsView(DolphinView* parent) :
             this, SLOT(setSortIndicatorSection(DolphinView::Sorting)));
     connect(parent, SIGNAL(sortOrderChanged(Qt::SortOrder)),
             this, SLOT(setSortIndicatorOrder(Qt::SortOrder)));
             this, SLOT(setSortIndicatorSection(DolphinView::Sorting)));
     connect(parent, SIGNAL(sortOrderChanged(Qt::SortOrder)),
             this, SLOT(setSortIndicatorOrder(Qt::SortOrder)));
+
+    connect(this, SIGNAL(clicked(const QModelIndex&)),
+            controller, SLOT(triggerItem(const QModelIndex&)));
 }
 
 DolphinDetailsView::~DolphinDetailsView()
 }
 
 DolphinDetailsView::~DolphinDetailsView()
@@ -89,21 +91,14 @@ QStyleOptionViewItem DolphinDetailsView::viewOptions() const
 void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event)
 {
     QTreeView::contextMenuEvent(event);
 void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event)
 {
     QTreeView::contextMenuEvent(event);
-
-    KFileItem* item = 0;
-
-    const QModelIndex index = indexAt(event->pos());
-    if (index.isValid()) {
-        item = m_dolphinView->fileItem(index);
-    }
-
-    m_dolphinView->openContextMenu(item, event->globalPos());
+    m_controller->triggerContextMenuRequest(event->pos(),
+                                            event->globalPos());
 }
 
 void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event)
 {
     QTreeView::mouseReleaseEvent(event);
 }
 
 void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event)
 {
     QTreeView::mouseReleaseEvent(event);
-    m_dolphinView->declareViewActive();
+    m_controller->triggerActivation();
 }
 
 void DolphinDetailsView::dragEnterEvent(QDragEnterEvent* event)
 }
 
 void DolphinDetailsView::dragEnterEvent(QDragEnterEvent* event)
@@ -115,15 +110,18 @@ void DolphinDetailsView::dragEnterEvent(QDragEnterEvent* event)
 
 void DolphinDetailsView::dropEvent(QDropEvent* event)
 {
 
 void DolphinDetailsView::dropEvent(QDropEvent* event)
 {
-    const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
+    QTreeView::dropEvent(event);
+    // TODO: temporary deactivated until DolphinController will support this
+
+    /*const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
     if (!urls.isEmpty()) {
         event->acceptProposedAction();
 
         // TODO: handle dropping above a directory
 
     if (!urls.isEmpty()) {
         event->acceptProposedAction();
 
         // TODO: handle dropping above a directory
 
-        const KUrl& destination = m_dolphinView->url();
-        m_dolphinView->mainWindow()->dropUrls(urls, destination);
-    }
+        const KUrl& destination = m_controller->url();
+        m_controller->emitDropUrlsSignal(urls, destination);
+    }*/
 }
 
 void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting)
 }
 
 void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting)
@@ -141,23 +139,11 @@ void DolphinDetailsView::setSortIndicatorOrder(Qt::SortOrder sortOrder)
 void DolphinDetailsView::synchronizeSortingState(int column)
 {
     // The sorting has already been changed in QTreeView if this slot is
 void DolphinDetailsView::synchronizeSortingState(int column)
 {
     // The sorting has already been changed in QTreeView if this slot is
-    // invoked, but Dolphin was not informed about this. This is bypassed by changing
-    // the sorting and sort order to a temporary other value and readjust it again.
+    // invoked, but Dolphin is not informed about this.
     DolphinView::Sorting sorting = DolphinSortFilterProxyModel::sortingForColumn(column);
     const Qt::SortOrder sortOrder = header()->sortIndicatorOrder();
     DolphinView::Sorting sorting = DolphinSortFilterProxyModel::sortingForColumn(column);
     const Qt::SortOrder sortOrder = header()->sortIndicatorOrder();
-
-    // temporary adjust the sorting and sort order to different values...
-    const DolphinView::Sorting tempSorting = (sorting == DolphinView::SortByName) ?
-                                             DolphinView::SortBySize :
-                                             DolphinView::SortByName;
-    m_dolphinView->setSorting(tempSorting);
-    const Qt::SortOrder tempSortOrder = (sortOrder == Qt::Ascending) ?
-                                        Qt::Descending : Qt::Ascending;
-    m_dolphinView->setSortOrder(tempSortOrder);
-
-    // ... so that setting them again results in storing the new setting.
-    m_dolphinView->setSorting(sorting);
-    m_dolphinView->setSortOrder(sortOrder);
+    m_controller->indicateSortingChange(sorting);
+    m_controller->indicateSortOrderChange(sortOrder);
 }
 
 #include "dolphindetailsview.moc"
 }
 
 #include "dolphindetailsview.moc"
index 6197376a8137d4650c87ee7f0f1f81d88eeeec17..e66adf5738bc34a7283eec3e6bfed2e4b9b02927 100644 (file)
@@ -24,6 +24,8 @@
 #include <dolphinview.h>
 #include <QTreeView>
 
 #include <dolphinview.h>
 #include <QTreeView>
 
+class DolphinController;
+
 /**
  * @brief Represents the details view which shows the name, size,
  *        date, permissions, owner and group of an item.
 /**
  * @brief Represents the details view which shows the name, size,
  *        date, permissions, owner and group of an item.
@@ -37,7 +39,7 @@ class DolphinDetailsView : public QTreeView
     Q_OBJECT
 
 public:
     Q_OBJECT
 
 public:
-    explicit DolphinDetailsView(DolphinView* parent);
+    explicit DolphinDetailsView(QWidget* parent, DolphinController* controller);
     virtual ~DolphinDetailsView();
 
 protected:
     virtual ~DolphinDetailsView();
 
 protected:
@@ -69,7 +71,7 @@ private slots:
      void synchronizeSortingState(int column);
 
 private:
      void synchronizeSortingState(int column);
 
 private:
-    DolphinView* m_dolphinView;
+    DolphinController* m_controller;
 };
 
 #endif
 };
 
 #endif
index 840d7f5fb69ebcf99fd4582381fe32e7780aebe2..7c32715db8b6b19cb0c0395560e3ada6390f5f23 100644 (file)
@@ -1,6 +1,5 @@
 /***************************************************************************
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz                                      *
- *   peter.penz@gmx.at                                                     *
+ *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -19,8 +18,8 @@
  ***************************************************************************/
 
 #include "dolphiniconsview.h"
  ***************************************************************************/
 
 #include "dolphiniconsview.h"
-#include "dolphinmainwindow.h"
-#include "dolphinview.h"
+
+#include "dolphincontroller.h"
 
 #include <assert.h>
 #include <kdirmodel.h>
 
 #include <assert.h>
 #include <kdirmodel.h>
 
 #include <QAbstractProxyModel>
 
 
 #include <QAbstractProxyModel>
 
-DolphinIconsView::DolphinIconsView(DolphinView* parent) :
+DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) :
     QListView(parent),
     QListView(parent),
-    m_dolphinView(parent)
+    m_controller(controller)
 {
 {
+    assert(controller != 0);
+
     setResizeMode(QListView::Adjust);
     setResizeMode(QListView::Adjust);
+
+    // TODO: read out settings
+    setViewMode(QListView::IconMode);
+    setSpacing(32);
+
+    connect(this, SIGNAL(clicked(const QModelIndex&)),
+            controller, SLOT(triggerItem(const QModelIndex&)));
 }
 
 DolphinIconsView::~DolphinIconsView()
 }
 
 DolphinIconsView::~DolphinIconsView()
@@ -57,21 +65,14 @@ QStyleOptionViewItem DolphinIconsView::viewOptions() const
 void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
 {
     QListView::contextMenuEvent(event);
 void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
 {
     QListView::contextMenuEvent(event);
-
-    KFileItem* item = 0;
-
-    const QModelIndex index = indexAt(event->pos());
-    if (index.isValid()) {
-        item = m_dolphinView->fileItem(index);
-    }
-
-    m_dolphinView->openContextMenu(item, event->globalPos());
+    m_controller->triggerContextMenuRequest(event->pos(),
+                                            event->globalPos());
 }
 
 void DolphinIconsView::mouseReleaseEvent(QMouseEvent* event)
 {
     QListView::mouseReleaseEvent(event);
 }
 
 void DolphinIconsView::mouseReleaseEvent(QMouseEvent* event)
 {
     QListView::mouseReleaseEvent(event);
-    m_dolphinView->declareViewActive();
+    m_controller->triggerActivation();
 }
 
 void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
 }
 
 void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
@@ -83,7 +84,10 @@ void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
 
 void DolphinIconsView::dropEvent(QDropEvent* event)
 {
 
 void DolphinIconsView::dropEvent(QDropEvent* event)
 {
-    KFileItem* directory = 0;
+    QListView::dropEvent(event);
+    // TODO: temporary deactivated until DolphinController will support this
+
+    /*    KFileItem* directory = 0;
     bool dropIntoDirectory = false;
     const QModelIndex index = indexAt(event->pos());
     if (index.isValid()) {
     bool dropIntoDirectory = false;
     const QModelIndex index = indexAt(event->pos());
     if (index.isValid()) {
@@ -104,7 +108,7 @@ void DolphinIconsView::dropEvent(QDropEvent* event)
         const KUrl& destination = (directory == 0) ? m_dolphinView->url() :
                                                      directory->url();
         m_dolphinView->mainWindow()->dropUrls(urls, destination);
         const KUrl& destination = (directory == 0) ? m_dolphinView->url() :
                                                      directory->url();
         m_dolphinView->mainWindow()->dropUrls(urls, destination);
-    }
+    }*/
 }
 
 #include "dolphiniconsview.moc"
 }
 
 #include "dolphiniconsview.moc"
index 99ca126887f07477e3c4891dec2940049b902016..68efbbd9119c6adff42d542adf30e62a393be514 100644 (file)
@@ -1,6 +1,5 @@
 /***************************************************************************
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz                                      *
- *   peter.penz@gmx.at                                                     *
+ *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -23,6 +22,7 @@
 
 #include <QListView>
 
 
 #include <QListView>
 
+class DolphinController;
 class DolphinView;
 
 /**
 class DolphinView;
 
 /**
@@ -30,15 +30,13 @@ class DolphinView;
  *
  * It is also possible that instead of the icon a preview of the item
  * content is shown.
  *
  * It is also possible that instead of the icon a preview of the item
  * content is shown.
- *
- * @author Peter Penz
  */
 class DolphinIconsView : public QListView
 {
     Q_OBJECT
 
 public:
  */
 class DolphinIconsView : public QListView
 {
     Q_OBJECT
 
 public:
-    explicit DolphinIconsView(DolphinView* parent);
+    explicit DolphinIconsView(QWidget* parent, DolphinController* controller);
     virtual ~DolphinIconsView();
 
 protected:
     virtual ~DolphinIconsView();
 
 protected:
@@ -49,7 +47,7 @@ protected:
     virtual void dropEvent(QDropEvent* event);
 
 private:
     virtual void dropEvent(QDropEvent* event);
 
 private:
-    DolphinView* m_dolphinView;
+    DolphinController* m_controller;
 };
 
 #endif
 };
 
 #endif
index a9f677244206b3bf2d75abe4cf1b02a0f53661a1..d1416c40a39c05c7677e2e9bcb9eb7420e2ffc87 100644 (file)
@@ -37,6 +37,7 @@
 #include <konq_operations.h>
 #include <kurl.h>
 
 #include <konq_operations.h>
 #include <kurl.h>
 
+#include "dolphincontroller.h"
 #include "dolphinstatusbar.h"
 #include "dolphinmainwindow.h"
 #include "dolphindirlister.h"
 #include "dolphinstatusbar.h"
 #include "dolphinmainwindow.h"
 #include "dolphindirlister.h"
@@ -63,6 +64,7 @@ DolphinView::DolphinView(DolphinMainWindow* mainWindow,
     m_mainWindow(mainWindow),
     m_topLayout(0),
     m_urlNavigator(0),
     m_mainWindow(mainWindow),
     m_topLayout(0),
     m_urlNavigator(0),
+    m_controller(0),
     m_iconsView(0),
     m_detailsView(0),
     m_filterBar(0),
     m_iconsView(0),
     m_detailsView(0),
     m_filterBar(0),
@@ -109,6 +111,20 @@ DolphinView::DolphinView(DolphinMainWindow* mainWindow,
     m_proxyModel = new DolphinSortFilterProxyModel(this);
     m_proxyModel->setSourceModel(m_dirModel);
 
     m_proxyModel = new DolphinSortFilterProxyModel(this);
     m_proxyModel->setSourceModel(m_dirModel);
 
+    m_controller = new DolphinController(this);
+    connect(m_controller, SIGNAL(requestContextMenu(const QPoint&, const QPoint&)),
+            this, SLOT(openContextMenu(const QPoint&, const QPoint&)));
+    connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
+            this, SLOT(updateSorting(DolphinView::Sorting)));
+    connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
+            this, SLOT(updateSortOrder(Qt::SortOrder)));
+    connect(m_controller, SIGNAL(itemTriggered(const QModelIndex&)),
+            this, SLOT(triggerItem(const QModelIndex&)));
+    connect(m_controller, SIGNAL(selectionChanged()),
+            this, SLOT(emitSelectionChangedSignal()));
+    connect(m_controller, SIGNAL(activated()),
+            this, SLOT(requestActivation()));
+
     createView();
 
     m_iconSize = K3Icon::SizeMedium;
     createView();
 
     m_iconSize = K3Icon::SizeMedium;
@@ -137,6 +153,7 @@ DolphinView::~DolphinView()
 void DolphinView::setUrl(const KUrl& url)
 {
     m_urlNavigator->setUrl(url);
 void DolphinView::setUrl(const KUrl& url)
 {
     m_urlNavigator->setUrl(url);
+    m_controller->setUrl(url);
 }
 
 const KUrl& DolphinView::url() const
 }
 
 const KUrl& DolphinView::url() const
@@ -144,11 +161,6 @@ const KUrl& DolphinView::url() const
     return m_urlNavigator->url();
 }
 
     return m_urlNavigator->url();
 }
 
-void DolphinView::requestActivation()
-{
-    mainWindow()->setActiveView(this);
-}
-
 bool DolphinView::isActive() const
 {
     return (mainWindow()->activeView() == this);
 bool DolphinView::isActive() const
 {
     return (mainWindow()->activeView() == this);
@@ -371,12 +383,7 @@ bool DolphinView::isZoomOutPossible() const
 void DolphinView::setSorting(Sorting sorting)
 {
     if (sorting != this->sorting()) {
 void DolphinView::setSorting(Sorting sorting)
 {
     if (sorting != this->sorting()) {
-        ViewProperties props(url());
-        props.setSorting(sorting);
-
-        m_proxyModel->setSorting(sorting);
-
-        emit sortingChanged(sorting);
+        updateSorting(sorting);
     }
 }
 
     }
 }
 
@@ -388,12 +395,7 @@ DolphinView::Sorting DolphinView::sorting() const
 void DolphinView::setSortOrder(Qt::SortOrder order)
 {
     if (sortOrder() != order) {
 void DolphinView::setSortOrder(Qt::SortOrder order)
 {
     if (sortOrder() != order) {
-        ViewProperties props(url());
-        props.setSortOrder(order);
-
-        m_proxyModel->setSortOrder(order);
-
-        emit sortOrderChanged(order);
+        updateSortOrder(order);
     }
 }
 
     }
 }
 
@@ -484,12 +486,6 @@ KFileItem* DolphinView::fileItem(const QModelIndex index) const
     return m_dirModel->itemForIndex(dirModelIndex);
 }
 
     return m_dirModel->itemForIndex(dirModelIndex);
 }
 
-void DolphinView::openContextMenu(KFileItem* fileInfo, const QPoint& pos)
-{
-    DolphinContextMenu contextMenu(this, fileInfo, pos);
-    contextMenu.open();
-}
-
 void DolphinView::rename(const KUrl& source, const QString& newName)
 {
     bool ok = false;
 void DolphinView::rename(const KUrl& source, const QString& newName)
 {
     bool ok = false;
@@ -829,6 +825,11 @@ void DolphinView::updateStatusBar()
     }
 }
 
     }
 }
 
+void DolphinView::requestActivation()
+{
+    m_mainWindow->setActiveView(this);
+}
+
 void DolphinView::changeNameFilter(const QString& nameFilter)
 {
     // The name filter of KDirLister does a 'hard' filtering, which
 void DolphinView::changeNameFilter(const QString& nameFilter)
 {
     // The name filter of KDirLister does a 'hard' filtering, which
@@ -854,6 +855,39 @@ void DolphinView::changeNameFilter(const QString& nameFilter)
 #endif
 }
 
 #endif
 }
 
+void DolphinView::openContextMenu(const QPoint& pos, const QPoint& globalPos)
+{
+    KFileItem* item = 0;
+
+    const QModelIndex index = itemView()->indexAt(pos);
+    if (index.isValid()) {
+        item = fileItem(index);
+    }
+
+    DolphinContextMenu contextMenu(this, item, globalPos);
+    contextMenu.open();
+}
+
+void DolphinView::updateSorting(DolphinView::Sorting sorting)
+{
+    ViewProperties props(url());
+    props.setSorting(sorting);
+
+    m_proxyModel->setSorting(sorting);
+
+    emit sortingChanged(sorting);
+}
+
+void DolphinView::updateSortOrder(Qt::SortOrder order)
+{
+    ViewProperties props(url());
+    props.setSortOrder(order);
+
+    m_proxyModel->setSortOrder(order);
+
+    emit sortOrderChanged(order);
+}
+
 void DolphinView::createView()
 {
     // delete current view
 void DolphinView::createView()
 {
     // delete current view
@@ -872,22 +906,17 @@ void DolphinView::createView()
     // ... and recreate it representing the current mode
     switch (m_mode) {
         case IconsView:
     // ... and recreate it representing the current mode
     switch (m_mode) {
         case IconsView:
-            m_iconsView = new DolphinIconsView(this);
-            m_iconsView->setViewMode(QListView::IconMode);
-            m_iconsView->setSpacing(32);
+            m_iconsView = new DolphinIconsView(this, m_controller);
             view = m_iconsView;
             view = m_iconsView;
-            // TODO: read out view settings
             break;
 
         case DetailsView:
             break;
 
         case DetailsView:
-            m_detailsView = new DolphinDetailsView(this);
+            m_detailsView = new DolphinDetailsView(this, m_controller);
             view = m_detailsView;
             view = m_detailsView;
-            // TODO: read out view settings
             break;
     }
 
     view->setModel(m_proxyModel);
             break;
     }
 
     view->setModel(m_proxyModel);
-
     view->setSelectionMode(QAbstractItemView::ExtendedSelection);
 
     KFileItemDelegate* delegate = new KFileItemDelegate(this);
     view->setSelectionMode(QAbstractItemView::ExtendedSelection);
 
     KFileItemDelegate* delegate = new KFileItemDelegate(this);
@@ -895,13 +924,10 @@ void DolphinView::createView()
     view->setItemDelegate(delegate);
 
     new KMimeTypeResolver(view, m_dirModel);
     view->setItemDelegate(delegate);
 
     new KMimeTypeResolver(view, m_dirModel);
+    m_topLayout->insertWidget(1, view);
 
 
-    connect(view, SIGNAL(clicked(const QModelIndex&)),
-            this, SLOT(triggerItem(const QModelIndex&)));
     connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
     connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
-            this, SLOT(emitSelectionChangedSignal()));
-
-    m_topLayout->insertWidget(1, view);
+            m_controller, SLOT(indicateSelectionChange()));
 }
 
 int DolphinView::columnIndex(Sorting sorting) const
 }
 
 int DolphinView::columnIndex(Sorting sorting) const
index 4b740e655725b94a16003f212125f1a551a6902e..5a9d4eb248c380a4696617224d5b72a886a02ef7 100644 (file)
@@ -36,6 +36,7 @@
 #include <QVBoxLayout>
 #include <QWidget>
 
 #include <QVBoxLayout>
 #include <QWidget>
 
+class DolphinController;
 class FilterBar;
 class KUrl;
 class KDirModel;
 class FilterBar;
 class KUrl;
 class KDirModel;
@@ -120,7 +121,10 @@ public:
     /** Returns the current active URL. */
     const KUrl& url() const;
 
     /** Returns the current active URL. */
     const KUrl& url() const;
 
-    void requestActivation();
+    /**
+     * Returns true if the view is active and hence all actions are
+     * applied to this view.
+     */
     bool isActive() const;
 
     /**
     bool isActive() const;
 
     /**
@@ -237,13 +241,6 @@ public:
      */
     KFileItem* fileItem(const QModelIndex index) const;
 
      */
     KFileItem* fileItem(const QModelIndex index) const;
 
-    /**
-     * Opens the context menu for the item indicated by \a fileInfo
-     * on the position \a pos. If 0 is passed for the file info, a context
-     * menu for the viewport is opened.
-     */
-    void openContextMenu(KFileItem* fileInfo, const QPoint& pos);
-
     /**
      * Renames the filename of the source URL by the new file name.
      * If the new file name already exists, a dialog is opened which
     /**
      * Renames the filename of the source URL by the new file name.
      * If the new file name already exists, a dialog is opened which
@@ -348,6 +345,12 @@ public slots:
      */
     void updateStatusBar();
 
      */
     void updateStatusBar();
 
+    /**
+     * Requests the main window to set this view as active view, which
+     * means that all actions are applied to this view.
+     */
+    void requestActivation();
+
 signals:
     /** Is emitted if URL of the view has been changed to \a url. */
     void urlChanged(const KUrl& url);
 signals:
     /** Is emitted if URL of the view has been changed to \a url. */
     void urlChanged(const KUrl& url);
@@ -427,6 +430,20 @@ private slots:
      */
     void changeNameFilter(const QString& nameFilter);
 
      */
     void changeNameFilter(const QString& nameFilter);
 
+    void openContextMenu(const QPoint& pos, const QPoint& globalPos);
+
+    /**
+     * Updates the view properties of the current URL to the
+     * sorting given by \a sorting.
+     */
+    void updateSorting(DolphinView::Sorting sorting);
+
+    /**
+     * Updates the view properties of the current URL to the
+     * sort order given by \a order.
+     */
+    void updateSortOrder(Qt::SortOrder order);
+
 private:
     void startDirLister(const KUrl& url, bool reload = false);
 
 private:
     void startDirLister(const KUrl& url, bool reload = false);
 
@@ -477,6 +494,7 @@ private:
     QVBoxLayout* m_topLayout;
     UrlNavigator* m_urlNavigator;
 
     QVBoxLayout* m_topLayout;
     UrlNavigator* m_urlNavigator;
 
+    DolphinController* m_controller;
     DolphinIconsView* m_iconsView;
     DolphinDetailsView* m_detailsView;
 
     DolphinIconsView* m_iconsView;
     DolphinDetailsView* m_detailsView;