m_nameFilter(),
m_url(),
m_dolphinView(dolphinView),
- m_itemView(0)
+ m_itemView(0),
+ m_versionControlActions()
{
}
}
}
+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);
* - 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
{
void setZoomLevel(int level);
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 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();
KUrl m_url;
DolphinView* m_dolphinView;
QAbstractItemView* m_itemView;
+ QList<QAction*> m_versionControlActions;
};
inline const DolphinView* DolphinController::dolphinView() const
/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
+ * Copyright (C) 2006-2009 by Peter Penz <peter.penz@gmx.at> *
* Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net> *
* *
* This program is free software; you can redistribute it and/or modify *
#include "folderexpander.h"
#include "renamedialog.h"
#include "settings/dolphinsettings.h"
-#include "versioncontrolobserver.h"
#include "viewproperties.h"
#include "zoomlevelinfo.h"
m_viewAccessor(proxyModel),
m_selectionModel(0),
m_selectionChangedTimer(0),
- m_versionControlObserver(0),
m_rootUrl(),
m_activeItemUrl(),
m_createdItemUrl(),
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)
}
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)),
/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
+ * Copyright (C) 2006-2009 by Peter Penz <peter.penz@gmx.at> *
* Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net> *
* *
* This program is free software; you can redistribute it and/or modify *
class KActionCollection;
class KDirLister;
class KUrl;
-class VersionControlObserver;
class ViewProperties;
/**
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
#include "selectionmanager.h"
#include "settings/dolphinsettings.h"
#include "tooltips/tooltipmanager.h"
+#include "versioncontrolobserver.h"
#include "dolphin_generalsettings.h"
m_previewGenerator(0),
m_selectionManager(0),
m_autoScroller(0),
- m_fileItemDelegate(0)
+ m_fileItemDelegate(0),
+ m_versionControlObserver(0)
{
view->setSelectionMode(QAbstractItemView::ExtendedSelection);
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)),
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();
class SelectionManager;
class ToolTipManager;
class QAbstractItemView;
+class VersionControlObserver;
/**
* @brief Responsible for creating extensions like tooltips and previews
void slotSortOrderChanged(Qt::SortOrder order);
void slotSortFoldersFirstChanged(bool foldersFirst);
void slotNameFilterChanged(const QString& nameFilter);
+ void slotRequestVersionControlActions(const KFileItemList& items);
void requestActivation();
private:
KFilePreviewGenerator* m_previewGenerator;
SelectionManager* m_selectionManager;
DolphinViewAutoScroller* m_autoScroller;
- DolphinFileItemDelegate* m_fileItemDelegate;
+ DolphinFileItemDelegate* m_fileItemDelegate;
+ VersionControlObserver* m_versionControlObserver;
};
#endif