┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2009-08-30 18:39:03 +0000
committerPeter Penz <[email protected]>2009-08-30 18:39:03 +0000
commit05762d42ea91ea034086c67099cf9208f86c00ff (patch)
treec7cd12caf603595821cd44f9be2266c82a5a9c0f
parent55704b419eb3ac864b2218cbeca2a8ae921ea1e1 (diff)
Move the VersionControlObserver from the DolphinView to the ViewExtensionsFactory. This automatically enables also the column view to be able handling version controlled files.
svn path=/trunk/KDE/kdebase/apps/; revision=1017482
-rw-r--r--src/dolphincontroller.cpp17
-rw-r--r--src/dolphincontroller.h24
-rw-r--r--src/dolphinview.cpp16
-rw-r--r--src/dolphinview.h5
-rw-r--r--src/viewextensionsfactory.cpp30
-rw-r--r--src/viewextensionsfactory.h5
6 files changed, 75 insertions, 22 deletions
diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp
index b3801bda8..a7c91def5 100644
--- a/src/dolphincontroller.cpp
+++ b/src/dolphincontroller.cpp
@@ -34,7 +34,8 @@ DolphinController::DolphinController(DolphinView* dolphinView) :
m_nameFilter(),
m_url(),
m_dolphinView(dolphinView),
- m_itemView(0)
+ m_itemView(0),
+ m_versionControlActions()
{
}
@@ -144,6 +145,20 @@ void DolphinController::setZoomLevel(int level)
}
}
+void DolphinController::setVersionControlActions(QList<QAction*> actions)
+{
+ m_versionControlActions = actions;
+}
+
+QList<QAction*> DolphinController::versionControlActions(const KFileItemList& items)
+{
+ emit requestVersionControlActions(items);
+ // All view implementations are connected with the signal requestVersionControlActions()
+ // (see ViewExtensionFactory) and will invoke DolphinController::setVersionControlActions(),
+ // so that the context dependent actions can be returned.
+ return m_versionControlActions;
+}
+
void DolphinController::handleKeyPressEvent(QKeyEvent* event)
{
Q_ASSERT(m_itemView != 0);
diff --git a/src/dolphincontroller.h b/src/dolphincontroller.h
index ccfef5306..355cff8cf 100644
--- a/src/dolphincontroller.h
+++ b/src/dolphincontroller.h
@@ -64,12 +64,14 @@ class QPoint;
* - emitViewportEntered()
* - replaceUrlByClipboard()
* - hideToolTip()
+ * - setVersionControlActions()
*
* The communication of the abstract view to the view implementations is done by:
* - setUrl()
* - indicateActivationChange()
* - setNameFilter()
* - setZoomLevel()
+ * - versionControlActions()
*/
class LIBDOLPHINPRIVATE_EXPORT DolphinController : public QObject
{
@@ -196,6 +198,20 @@ public:
int zoomLevel() const;
/**
+ * Sets the available version control actions. Is called by the view
+ * implementation as soon as the controller has send the signal
+ * requestVersionControlActions().
+ */
+ void setVersionControlActions(QList<QAction*> actions);
+
+ /**
+ * Returns the version control actions that are provided for the items \p items.
+ * Is called by the abstract Dolphin view to show the version control actions
+ * inside the context menu.
+ */
+ QList<QAction*> versionControlActions(const KFileItemList& items);
+
+ /**
* Sets the name filter to \a and emits the signal nameFilterChanged().
*/
void setNameFilter(const QString& nameFilter);
@@ -400,6 +416,13 @@ signals:
*/
void cancelPreviews();
+ /**
+ * Requests the view implementation to invoke DolphinController::setVersionControlActions(),
+ * so that they can be returned with DolphinController::versionControlActions() for
+ * the abstract Dolphin view.
+ */
+ void requestVersionControlActions(const KFileItemList& items);
+
private slots:
void updateMouseButtonState();
@@ -410,6 +433,7 @@ private:
KUrl m_url;
DolphinView* m_dolphinView;
QAbstractItemView* m_itemView;
+ QList<QAction*> m_versionControlActions;
};
inline const DolphinView* DolphinController::dolphinView() const
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index 09b4f3e16..2c3c6c38d 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <[email protected]> *
+ * Copyright (C) 2006-2009 by Peter Penz <[email protected]> *
* Copyright (C) 2006 by Gregor Kališnik <[email protected]> *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -63,7 +63,6 @@
#include "folderexpander.h"
#include "renamedialog.h"
#include "settings/dolphinsettings.h"
-#include "versioncontrolobserver.h"
#include "viewproperties.h"
#include "zoomlevelinfo.h"
@@ -94,7 +93,6 @@ DolphinView::DolphinView(QWidget* parent,
m_viewAccessor(proxyModel),
m_selectionModel(0),
m_selectionChangedTimer(0),
- m_versionControlObserver(0),
m_rootUrl(),
m_activeItemUrl(),
m_createdItemUrl(),
@@ -576,9 +574,7 @@ QString DolphinView::statusBarText() const
QList<QAction*> DolphinView::versionControlActions(const KFileItemList& items) const
{
- return items.isEmpty()
- ? m_versionControlObserver->contextMenuActions(url().path(KUrl::AddTrailingSlash))
- : m_versionControlObserver->contextMenuActions(items);
+ return m_controller->versionControlActions(items);
}
void DolphinView::setUrl(const KUrl& url)
@@ -1340,14 +1336,6 @@ void DolphinView::createView()
}
m_selectionModel->setParent(this);
- m_versionControlObserver = new VersionControlObserver(view);
- connect(m_versionControlObserver, SIGNAL(infoMessage(const QString&)),
- this, SIGNAL(infoMessage(const QString&)));
- connect(m_versionControlObserver, SIGNAL(errorMessage(const QString&)),
- this, SIGNAL(errorMessage(const QString&)));
- connect(m_versionControlObserver, SIGNAL(operationCompletedMessage(const QString&)),
- this, SIGNAL(operationCompletedMessage(const QString&)));
-
connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
this, SLOT(emitDelayedSelectionChangedSignal()));
connect(view->verticalScrollBar(), SIGNAL(valueChanged(int)),
diff --git a/src/dolphinview.h b/src/dolphinview.h
index b8c91333d..822eb52b0 100644
--- a/src/dolphinview.h
+++ b/src/dolphinview.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <[email protected]> *
+ * Copyright (C) 2006-2009 by Peter Penz <[email protected]> *
* Copyright (C) 2006 by Gregor Kališnik <[email protected]> *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -53,7 +53,6 @@ class KAction;
class KActionCollection;
class KDirLister;
class KUrl;
-class VersionControlObserver;
class ViewProperties;
/**
@@ -826,8 +825,6 @@ private:
QItemSelectionModel* m_selectionModel; // allow to switch views without losing the selection
QTimer* m_selectionChangedTimer;
- VersionControlObserver* m_versionControlObserver;
-
KUrl m_rootUrl;
KUrl m_activeItemUrl;
KUrl m_createdItemUrl; // URL for a new item that got created by the "Create New..." menu
diff --git a/src/viewextensionsfactory.cpp b/src/viewextensionsfactory.cpp
index 0f51489bc..0974e2126 100644
--- a/src/viewextensionsfactory.cpp
+++ b/src/viewextensionsfactory.cpp
@@ -27,6 +27,7 @@
#include "selectionmanager.h"
#include "settings/dolphinsettings.h"
#include "tooltips/tooltipmanager.h"
+#include "versioncontrolobserver.h"
#include "dolphin_generalsettings.h"
@@ -44,7 +45,8 @@ ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
m_previewGenerator(0),
m_selectionManager(0),
m_autoScroller(0),
- m_fileItemDelegate(0)
+ m_fileItemDelegate(0),
+ m_versionControlObserver(0)
{
view->setSelectionMode(QAbstractItemView::ExtendedSelection);
@@ -86,8 +88,19 @@ ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
m_fileItemDelegate->setShowToolTipWhenElided(false);
view->setItemDelegate(m_fileItemDelegate);
- // react on view property changes
+ // initialize version control observer
const DolphinView* dolphinView = controller->dolphinView();
+ m_versionControlObserver = new VersionControlObserver(view);
+ connect(m_versionControlObserver, SIGNAL(infoMessage(const QString&)),
+ dolphinView, SIGNAL(infoMessage(const QString&)));
+ connect(m_versionControlObserver, SIGNAL(errorMessage(const QString&)),
+ dolphinView, SIGNAL(errorMessage(const QString&)));
+ connect(m_versionControlObserver, SIGNAL(operationCompletedMessage(const QString&)),
+ dolphinView, SIGNAL(operationCompletedMessage(const QString&)));
+ connect(controller, SIGNAL(requestVersionControlActions(const KFileItemList&)),
+ this, SLOT(slotRequestVersionControlActions(const KFileItemList&)));
+
+ // react on view property changes
connect(dolphinView, SIGNAL(showHiddenFilesChanged()),
this, SLOT(slotShowHiddenFilesChanged()));
connect(dolphinView, SIGNAL(sortingChanged(DolphinView::Sorting)),
@@ -181,6 +194,19 @@ void ViewExtensionsFactory::slotNameFilterChanged(const QString& nameFilter)
proxyModel()->setFilterRegExp(nameFilter);
}
+void ViewExtensionsFactory::slotRequestVersionControlActions(const KFileItemList& items)
+{
+ QList<QAction*> actions;
+ if (items.isEmpty()) {
+ const KDirModel* dirModel = static_cast<const KDirModel*>(proxyModel()->sourceModel());
+ const KUrl url = dirModel->dirLister()->url();
+ actions = m_versionControlObserver->contextMenuActions(url.path(KUrl::AddTrailingSlash));
+ } else {
+ actions = m_versionControlObserver->contextMenuActions(items);
+ }
+ m_controller->setVersionControlActions(actions);
+}
+
void ViewExtensionsFactory::requestActivation()
{
m_controller->requestActivation();
diff --git a/src/viewextensionsfactory.h b/src/viewextensionsfactory.h
index 65549a55a..ddc1cf581 100644
--- a/src/viewextensionsfactory.h
+++ b/src/viewextensionsfactory.h
@@ -33,6 +33,7 @@ class QModelIndex;
class SelectionManager;
class ToolTipManager;
class QAbstractItemView;
+class VersionControlObserver;
/**
* @brief Responsible for creating extensions like tooltips and previews
@@ -73,6 +74,7 @@ private slots:
void slotSortOrderChanged(Qt::SortOrder order);
void slotSortFoldersFirstChanged(bool foldersFirst);
void slotNameFilterChanged(const QString& nameFilter);
+ void slotRequestVersionControlActions(const KFileItemList& items);
void requestActivation();
private:
@@ -85,7 +87,8 @@ private:
KFilePreviewGenerator* m_previewGenerator;
SelectionManager* m_selectionManager;
DolphinViewAutoScroller* m_autoScroller;
- DolphinFileItemDelegate* m_fileItemDelegate;
+ DolphinFileItemDelegate* m_fileItemDelegate;
+ VersionControlObserver* m_versionControlObserver;
};
#endif