########### next target ###############
set(dolphinprivate_LIB_SRCS
- dolphincontroller.cpp
dolphindetailsview.cpp
dolphiniconsview.cpp
dolphincolumnview.cpp
dolphinview.cpp
dolphinviewactionhandler.cpp
dolphinviewautoscroller.cpp
+ dolphinviewcontroller.cpp
dolphinremoteencoding.cpp
dolphindetailsviewexpander.cpp
draganddrophelper.cpp
versioncontrol/updateitemstatesthread.cpp
versioncontrol/versioncontrolobserver.cpp
viewextensionsfactory.cpp
+ viewmodecontroller.cpp
viewproperties.cpp
zoomlevelinfo.cpp
)
#include "dolphinmodel.h"
#include "dolphincolumnviewcontainer.h"
-#include "dolphincontroller.h"
+#include "dolphinviewcontroller.h"
#include "dolphindirlister.h"
#include "dolphinsortfilterproxymodel.h"
#include "settings/dolphinsettings.h"
#include "folderexpander.h"
#include "tooltips/tooltipmanager.h"
#include "viewextensionsfactory.h"
+#include "viewmodecontroller.h"
#include "zoomlevelinfo.h"
#include <kcolorscheme.h>
}
connect(this, SIGNAL(viewportEntered()),
- m_container->m_controller, SLOT(emitViewportEntered()));
+ m_container->m_dolphinViewController, SLOT(emitViewportEntered()));
connect(this, SIGNAL(entered(const QModelIndex&)),
this, SLOT(slotEntered(const QModelIndex&)));
- const DolphinView* dolphinView = m_container->m_controller->dolphinView();
+ const DolphinView* dolphinView = m_container->m_dolphinViewController->view();
connect(dolphinView, SIGNAL(showPreviewChanged()),
this, SLOT(slotShowPreviewChanged()));
m_dirLister->setAutoUpdate(true);
m_dirLister->setMainWindow(window());
m_dirLister->setDelayedMimeTypes(true);
- const bool showHiddenFiles = m_container->m_controller->dolphinView()->showHiddenFiles();
+ const bool showHiddenFiles = m_container->m_dolphinViewController->view()->showHiddenFiles();
m_dirLister->setShowingDotFiles(showHiddenFiles);
m_dolphinModel = new DolphinModel(this);
connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
this, SLOT(updateFont()));
- DolphinController* controller = m_container->m_controller;
- connect(controller, SIGNAL(zoomLevelChanged(int)),
+ DolphinViewController* dolphinViewController = m_container->m_dolphinViewController;
+ connect(dolphinViewController, SIGNAL(zoomLevelChanged(int)),
this, SLOT(setZoomLevel(int)));
- const QString nameFilter = controller->nameFilter();
+ const ViewModeController* viewModeController = m_container->m_viewModeController;
+ const QString nameFilter = viewModeController->nameFilter();
if (!nameFilter.isEmpty()) {
m_proxyModel->setFilterFixedString(nameFilter);
}
updateDecorationSize(dolphinView->showPreview());
updateBackground();
- m_extensionsFactory = new ViewExtensionsFactory(this, controller);
+ m_extensionsFactory = new ViewExtensionsFactory(this, dolphinViewController, viewModeController);
m_dirLister->openUrl(url, KDirLister::NoFlags);
}
void DolphinColumnView::startDrag(Qt::DropActions supportedActions)
{
- DragAndDropHelper::instance().startDrag(this, supportedActions, m_container->m_controller);
+ DragAndDropHelper::instance().startDrag(this, supportedActions, m_container->m_dolphinViewController);
}
void DolphinColumnView::dragEnterEvent(QDragEnterEvent* event)
m_dropRect.setSize(QSize()); // set as invalid
if (index.isValid()) {
- m_container->m_controller->setItemView(this);
- const KFileItem item = m_container->m_controller->itemForIndex(index);
+ m_container->m_dolphinViewController->setItemView(this);
+ const KFileItem item = m_container->m_dolphinViewController->itemForIndex(index);
if (!item.isNull() && item.isDir()) {
m_dropRect = visualRect(index);
}
void DolphinColumnView::dropEvent(QDropEvent* event)
{
const QModelIndex index = indexAt(event->pos());
- m_container->m_controller->setItemView(this);
- const KFileItem item = m_container->m_controller->itemForIndex(index);
- m_container->m_controller->indicateDroppedUrls(item, url(), event);
+ m_container->m_dolphinViewController->setItemView(this);
+ const KFileItem item = m_container->m_dolphinViewController->itemForIndex(index);
+ m_container->m_dolphinViewController->indicateDroppedUrls(item, url(), event);
QListView::dropEvent(event);
}
requestActivation();
if (!indexAt(event->pos()).isValid()) {
if (QApplication::mouseButtons() & Qt::MidButton) {
- m_container->m_controller->replaceUrlByClipboard();
+ m_container->m_dolphinViewController->replaceUrlByClipboard();
}
} else if (event->button() == Qt::LeftButton) {
// TODO: see comment in DolphinIconsView::mousePressEvent()
QListView::keyPressEvent(event);
requestActivation();
- DolphinController* controller = m_container->m_controller;
+ DolphinViewController* controller = m_container->m_dolphinViewController;
controller->handleKeyPressEvent(event);
switch (event->key()) {
case Qt::Key_Right: {
{
requestActivation();
QListView::contextMenuEvent(event);
- m_container->m_controller->triggerContextMenuRequest(event->pos());
+ m_container->m_dolphinViewController->triggerContextMenuRequest(event->pos());
}
void DolphinColumnView::wheelEvent(QWheelEvent* event)
// if the mouse is above an item and moved very fast outside the widget,
// no viewportEntered() signal might be emitted although the mouse has been moved
// above the viewport
- m_container->m_controller->emitViewportEntered();
+ m_container->m_dolphinViewController->emitViewportEntered();
}
void DolphinColumnView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
const int size = ZoomLevelInfo::iconSizeForZoomLevel(level);
ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
- const bool showPreview = m_container->m_controller->dolphinView()->showPreview();
+ const bool showPreview = m_container->m_dolphinViewController->view()->showPreview();
if (showPreview) {
settings->setPreviewSize(size);
} else {
void DolphinColumnView::slotEntered(const QModelIndex& index)
{
- m_container->m_controller->setItemView(this);
- m_container->m_controller->emitItemEntered(index);
+ m_container->m_dolphinViewController->setItemView(this);
+ m_container->m_dolphinViewController->emitItemEntered(index);
}
void DolphinColumnView::requestActivation()
{
- m_container->m_controller->requestActivation();
+ m_container->m_dolphinViewController->requestActivation();
if (!m_active) {
m_container->requestActivation(this);
selectionModel()->clear();
void DolphinColumnView::slotShowPreviewChanged()
{
- const DolphinView* view = m_container->m_controller->dolphinView();
+ const DolphinView* view = m_container->m_dolphinViewController->view();
updateDecorationSize(view->showPreview());
}
if (KGlobalSettings::singleClick()) {
connect(this, SIGNAL(clicked(const QModelIndex&)),
- m_container->m_controller, SLOT(triggerItem(const QModelIndex&)));
+ m_container->m_dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
} else {
connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
- m_container->m_controller, SLOT(triggerItem(const QModelIndex&)));
+ m_container->m_dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
}
if (selectionModel() && selectionModel()->currentIndex().isValid()) {
clearFocus();
if (KGlobalSettings::singleClick()) {
disconnect(this, SIGNAL(clicked(const QModelIndex&)),
- m_container->m_controller, SLOT(triggerItem(const QModelIndex&)));
+ m_container->m_dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
} else {
disconnect(this, SIGNAL(doubleClicked(const QModelIndex&)),
- m_container->m_controller, SLOT(triggerItem(const QModelIndex&)));
+ m_container->m_dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
}
const QModelIndex current = selectionModel()->currentIndex();
#include "dolphincolumnviewcontainer.h"
+#include "dolphin_columnmodesettings.h"
+
#include "dolphincolumnview.h"
-#include "dolphincontroller.h"
+#include "dolphinviewcontroller.h"
#include "dolphinsortfilterproxymodel.h"
#include "draganddrophelper.h"
#include "settings/dolphinsettings.h"
-
-#include "dolphin_columnmodesettings.h"
+#include "viewmodecontroller.h"
#include <QPoint>
#include <QScrollBar>
#include <QTimer>
DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
- DolphinController* controller) :
+ DolphinViewController* dolphinViewController,
+ const ViewModeController* viewModeController) :
QScrollArea(parent),
- m_controller(controller),
+ m_dolphinViewController(dolphinViewController),
+ m_viewModeController(viewModeController),
m_active(false),
m_index(-1),
m_contentX(0),
m_dragSource(0),
m_activeUrlTimer(0)
{
- Q_ASSERT(controller != 0);
+ Q_ASSERT(dolphinViewController != 0);
+ Q_ASSERT(viewModeController != 0);
setAcceptDrops(true);
setFocusPolicy(Qt::NoFocus);
setFrameShape(QFrame::NoFrame);
setLayoutDirection(Qt::LeftToRight);
- connect(controller, SIGNAL(activationChanged(bool)),
+ connect(viewModeController, SIGNAL(activationChanged(bool)),
this, SLOT(updateColumnsBackground(bool)));
connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
connect(m_activeUrlTimer, SIGNAL(timeout()),
this, SLOT(updateActiveUrl()));
- DolphinColumnView* column = new DolphinColumnView(viewport(), this, m_controller->url());
+ DolphinColumnView* column = new DolphinColumnView(viewport(), this, viewModeController->url());
m_columns.append(column);
setActiveColumnIndex(0);
void DolphinColumnViewContainer::mousePressEvent(QMouseEvent* event)
{
- m_controller->requestActivation();
+ m_dolphinViewController->requestActivation();
QScrollArea::mousePressEvent(event);
}
void DolphinColumnViewContainer::updateActiveUrl()
{
const KUrl activeUrl = m_columns[m_index]->url();
- m_controller->setUrl(activeUrl);
+ m_dolphinViewController->requestUrlChange(activeUrl);
}
void DolphinColumnViewContainer::setActiveColumnIndex(int index)
void DolphinColumnViewContainer::requestActivation(DolphinColumnView* column)
{
- m_controller->setItemView(column);
+ m_dolphinViewController->setItemView(column);
if (column->isActive()) {
assureVisibleActiveColumn();
} else {
return;
}
- if (m_controller->itemView() == column) {
- m_controller->setItemView(0);
+ if (m_dolphinViewController->itemView() == column) {
+ m_dolphinViewController->setItemView(0);
}
// deleteWhenNotDragSource(column) does not necessarily delete column,
// and we want its preview generator destroyed immediately.
#include <QString>
class DolphinColumnView;
-class DolphinController;
+class DolphinViewController;
class QFrame;
class QTimeLine;
class QTimer;
Q_OBJECT
public:
+ /**
+ * @param parent Parent widget.
+ * @param dolphinViewController Allows the DolphinColumnView to control the
+ * DolphinView in a limited way.
+ * @param viewModeController Controller that is used by the DolphinView
+ * to control the DolphinColumnView. The DolphinColumnView
+ * only has read access to the controller.
+ * @param model Directory that is shown.
+ */
explicit DolphinColumnViewContainer(QWidget* parent,
- DolphinController* controller);
+ DolphinViewController* dolphinViewController,
+ const ViewModeController* viewModeController);
virtual ~DolphinColumnViewContainer();
KUrl rootUrl() const;
void deleteColumn(DolphinColumnView* column);
private:
- DolphinController* m_controller;
+ DolphinViewController* m_dolphinViewController;
+ const ViewModeController* m_viewModeController;
bool m_active;
int m_index;
int m_contentX;
#include "dolphindetailsview.h"
#include "dolphinmodel.h"
-#include "dolphincontroller.h"
+#include "dolphinviewcontroller.h"
#include "dolphinfileitemdelegate.h"
#include "settings/dolphinsettings.h"
#include "dolphinsortfilterproxymodel.h"
#include "dolphinviewautoscroller.h"
#include "draganddrophelper.h"
#include "viewextensionsfactory.h"
+#include "viewmodecontroller.h"
#include "viewproperties.h"
#include "zoomlevelinfo.h"
#include <QScrollBar>
DolphinDetailsView::DolphinDetailsView(QWidget* parent,
- DolphinController* controller,
+ DolphinViewController* dolphinViewController,
+ const ViewModeController* viewModeController,
DolphinSortFilterProxyModel* proxyModel) :
QTreeView(parent),
m_autoResize(true),
m_keyPressed(false),
m_useDefaultIndexAt(true),
m_ignoreScrollTo(false),
- m_controller(controller),
+ m_dolphinViewController(dolphinViewController),
+ m_viewModeController(viewModeController),
m_extensionsFactory(0),
m_expandableFoldersAction(0),
m_expandedUrls(),
{
const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
Q_ASSERT(settings != 0);
- Q_ASSERT(controller != 0);
+ Q_ASSERT(dolphinViewController != 0);
+ Q_ASSERT(viewModeController != 0);
setLayoutDirection(Qt::LeftToRight);
setAcceptDrops(true);
setMouseTracking(true);
- const ViewProperties props(controller->url());
+ const ViewProperties props(viewModeController->url());
setSortIndicatorSection(props.sorting());
setSortIndicatorOrder(props.sortOrder());
this, SLOT(setSortIndicatorOrder(Qt::SortOrder)));
connect(this, SIGNAL(clicked(const QModelIndex&)),
- controller, SLOT(requestTab(const QModelIndex&)));
+ dolphinViewController, SLOT(requestTab(const QModelIndex&)));
if (KGlobalSettings::singleClick()) {
connect(this, SIGNAL(clicked(const QModelIndex&)),
- controller, SLOT(triggerItem(const QModelIndex&)));
+ dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
} else {
connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
- controller, SLOT(triggerItem(const QModelIndex&)));
+ dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
}
connect(this, SIGNAL(entered(const QModelIndex&)),
this, SLOT(slotEntered(const QModelIndex&)));
connect(this, SIGNAL(viewportEntered()),
- controller, SLOT(emitViewportEntered()));
- connect(controller, SIGNAL(zoomLevelChanged(int)),
+ dolphinViewController, SLOT(emitViewportEntered()));
+ connect(viewModeController, SIGNAL(zoomLevelChanged(int)),
this, SLOT(setZoomLevel(int)));
- connect(controller->dolphinView(), SIGNAL(additionalInfoChanged()),
+ connect(dolphinViewController->view(), SIGNAL(additionalInfoChanged()),
this, SLOT(updateColumnVisibility()));
- connect(controller, SIGNAL(activationChanged(bool)),
+ connect(viewModeController, SIGNAL(activationChanged(bool)),
this, SLOT(slotActivationChanged(bool)));
if (settings->useSystemFont()) {
setVerticalScrollMode(QTreeView::ScrollPerPixel);
setHorizontalScrollMode(QTreeView::ScrollPerPixel);
- const DolphinView* view = controller->dolphinView();
+ const DolphinView* view = dolphinViewController->view();
connect(view, SIGNAL(showPreviewChanged()),
this, SLOT(slotShowPreviewChanged()));
updateDecorationSize(view->showPreview());
- m_extensionsFactory = new ViewExtensionsFactory(this, controller);
+ m_extensionsFactory = new ViewExtensionsFactory(this, dolphinViewController, viewModeController);
m_extensionsFactory->fileItemDelegate()->setMinimizedNameColumn(true);
m_extensionsFactory->setAutoFolderExpandingEnabled(settings->expandableFolders());
}
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
m_expandableFoldersAction->setChecked(settings->expandableFolders());
- m_controller->triggerContextMenuRequest(event->pos(),
+ m_dolphinViewController->triggerContextMenuRequest(event->pos(),
QList<QAction*>() << m_expandableFoldersAction);
}
void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
{
- m_controller->requestActivation();
+ m_dolphinViewController->requestActivation();
const QModelIndex current = currentIndex();
QTreeView::mousePressEvent(event);
if (!index.isValid() || (index.column() != DolphinModel::Name)) {
// the mouse press is done somewhere outside the filename column
if (QApplication::mouseButtons() & Qt::MidButton) {
- m_controller->replaceUrlByClipboard();
+ m_dolphinViewController->replaceUrlByClipboard();
}
const Qt::KeyboardModifiers mod = QApplication::keyboardModifiers();
void DolphinDetailsView::startDrag(Qt::DropActions supportedActions)
{
- DragAndDropHelper::instance().startDrag(this, supportedActions, m_controller);
+ DragAndDropHelper::instance().startDrag(this, supportedActions, m_dolphinViewController);
m_band.show = false;
}
setDirtyRegion(m_dropRect);
const QModelIndex index = indexAt(event->pos());
if (index.isValid() && (index.column() == DolphinModel::Name)) {
- const KFileItem item = m_controller->itemForIndex(index);
+ const KFileItem item = m_dolphinViewController->itemForIndex(index);
if (!item.isNull() && item.isDir()) {
m_dropRect = visualRect(index);
} else {
const QModelIndex index = indexAt(event->pos());
KFileItem item;
if (index.isValid() && (index.column() == DolphinModel::Name)) {
- item = m_controller->itemForIndex(index);
+ item = m_dolphinViewController->itemForIndex(index);
}
- m_controller->indicateDroppedUrls(item, m_controller->url(), event);
+ m_dolphinViewController->indicateDroppedUrls(item, m_viewModeController->url(), event);
QTreeView::dropEvent(event);
}
m_keyPressed = !(event->modifiers() & Qt::ControlModifier);
QTreeView::keyPressEvent(event);
- m_controller->handleKeyPressEvent(event);
+ m_dolphinViewController->handleKeyPressEvent(event);
}
void DolphinDetailsView::keyReleaseEvent(QKeyEvent* event)
// if the mouse is above an item and moved very fast outside the widget,
// no viewportEntered() signal might be emitted although the mouse has been moved
// above the viewport
- m_controller->emitViewportEntered();
+ m_dolphinViewController->emitViewportEntered();
}
return QTreeView::eventFilter(watched, event);
QRect DolphinDetailsView::visualRect(const QModelIndex& index) const
{
QRect rect = QTreeView::visualRect(index);
- const KFileItem item = m_controller->itemForIndex(index);
+ const KFileItem item = m_dolphinViewController->itemForIndex(index);
if (!item.isNull()) {
const int width = DolphinFileItemDelegate::nameColumnWidth(item.text(), viewOptions());
rect.setWidth(width);
// invoked, but Dolphin is not informed about this.
DolphinView::Sorting sorting = DolphinSortFilterProxyModel::sortingForColumn(column);
const Qt::SortOrder sortOrder = header()->sortIndicatorOrder();
- m_controller->indicateSortingChange(sorting);
- m_controller->indicateSortOrderChange(sortOrder);
+ m_dolphinViewController->indicateSortingChange(sorting);
+ m_dolphinViewController->indicateSortOrderChange(sortOrder);
}
void DolphinDetailsView::slotEntered(const QModelIndex& index)
{
if (index.column() == DolphinModel::Name) {
- m_controller->emitItemEntered(index);
+ m_dolphinViewController->emitItemEntered(index);
} else {
- m_controller->emitViewportEntered();
+ m_dolphinViewController->emitViewportEntered();
}
}
const int size = ZoomLevelInfo::iconSizeForZoomLevel(level);
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
- const bool showPreview = m_controller->dolphinView()->showPreview();
+ const bool showPreview = m_dolphinViewController->view()->showPreview();
if (showPreview) {
settings->setPreviewSize(size);
} else {
void DolphinDetailsView::slotShowPreviewChanged()
{
- const DolphinView* view = m_controller->dolphinView();
+ const DolphinView* view = m_dolphinViewController->view();
updateDecorationSize(view->showPreview());
}
const bool show = activatedAction->isChecked();
const int columnIndex = activatedAction->data().toInt();
- KFileItemDelegate::InformationList list = m_controller->dolphinView()->additionalInfo();
+ KFileItemDelegate::InformationList list = m_dolphinViewController->view()->additionalInfo();
const KFileItemDelegate::Information info = infoForColumn(columnIndex);
if (show) {
Q_ASSERT(!list.contains(info));
list.removeAt(index);
}
- m_controller->indicateAdditionalInfoChange(list);
+ m_dolphinViewController->indicateAdditionalInfoChange(list);
setColumnHidden(columnIndex, !show);
resizeColumns();
}
const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
const QList<int> columnPositions = settings->columnPositions();
- const KFileItemDelegate::InformationList list = m_controller->dolphinView()->additionalInfo();
+ const KFileItemDelegate::InformationList list = m_dolphinViewController->view()->additionalInfo();
for (int i = DolphinModel::Name; i <= DolphinModel::Version; ++i) {
const KFileItemDelegate::Information info = infoForColumn(i);
const bool hide = !list.contains(info) && (i != DolphinModel::Name);
void DolphinDetailsView::requestActivation()
{
- m_controller->requestActivation();
+ m_dolphinViewController->requestActivation();
}
void DolphinDetailsView::slotGlobalSettingsChanged(int category)
m_font = KGlobalSettings::generalFont();
}
//Disconnect then reconnect, since the settings have been changed, the connection requirements may have also.
- disconnect(this, SIGNAL(clicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
- disconnect(this, SIGNAL(doubleClicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
+ disconnect(this, SIGNAL(clicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
+ disconnect(this, SIGNAL(doubleClicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
if (KGlobalSettings::singleClick()) {
- connect(this, SIGNAL(clicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
+ connect(this, SIGNAL(clicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
} else {
- connect(this, SIGNAL(doubleClicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
+ connect(this, SIGNAL(doubleClicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
}
}
void DolphinDetailsView::slotExpanded(const QModelIndex& index)
{
- KFileItem item = m_controller->itemForIndex(index);
+ KFileItem item = m_dolphinViewController->itemForIndex(index);
if (!item.isNull()) {
m_expandedUrls.insert(item.url());
}
void DolphinDetailsView::slotCollapsed(const QModelIndex& index)
{
- KFileItem item = m_controller->itemForIndex(index);
+ KFileItem item = m_dolphinViewController->itemForIndex(index);
if (!item.isNull()) {
m_expandedUrls.remove(item.url());
}
#include <QTreeView>
#include <libdolphin_export.h>
-class DolphinController;
+class DolphinViewController;
class DolphinSortFilterProxyModel;
class ViewExtensionsFactory;
Q_OBJECT
public:
+ /**
+ * @param parent Parent widget.
+ * @param dolphinViewController Allows the DolphinDetailsView to control the
+ * DolphinView in a limited way.
+ * @param viewModeController Controller that is used by the DolphinView
+ * to control the DolphinDetailsView. The DolphinDetailsView
+ * only has read access to the controller.
+ * @param model Directory that is shown.
+ */
explicit DolphinDetailsView(QWidget* parent,
- DolphinController* controller,
+ DolphinViewController* dolphinViewController,
+ const ViewModeController* viewModeController,
DolphinSortFilterProxyModel* model);
virtual ~DolphinDetailsView();
bool m_useDefaultIndexAt : 1; // true, if QTreeView::indexAt() should be used
bool m_ignoreScrollTo : 1; // true if calls to scrollTo(...) should do nothing.
- DolphinController* m_controller;
+ DolphinViewController* m_dolphinViewController;
+ const ViewModeController* m_viewModeController;
ViewExtensionsFactory* m_extensionsFactory;
QAction* m_expandableFoldersAction;
#include "dolphiniconsview.h"
#include "dolphincategorydrawer.h"
-#include "dolphincontroller.h"
+#include "dolphinviewcontroller.h"
#include "settings/dolphinsettings.h"
#include "dolphinsortfilterproxymodel.h"
#include "dolphin_iconsmodesettings.h"
#include "draganddrophelper.h"
#include "selectionmanager.h"
#include "viewextensionsfactory.h"
+#include "viewmodecontroller.h"
#include "zoomlevelinfo.h"
#include <kcategorizedsortfilterproxymodel.h>
#include <QScrollBar>
DolphinIconsView::DolphinIconsView(QWidget* parent,
- DolphinController* controller,
+ DolphinViewController* dolphinViewController,
+ const ViewModeController* viewModeController,
DolphinSortFilterProxyModel* proxyModel) :
KCategorizedView(parent),
- m_controller(controller),
+ m_dolphinViewController(dolphinViewController),
+ m_viewModeController(viewModeController),
m_categoryDrawer(new DolphinCategoryDrawer(this)),
m_extensionsFactory(0),
m_font(),
m_itemSize(),
m_dropRect()
{
- Q_ASSERT(controller != 0);
+ Q_ASSERT(dolphinViewController != 0);
+ Q_ASSERT(viewModeController != 0);
+
setModel(proxyModel);
setLayoutDirection(Qt::LeftToRight);
setViewMode(QListView::IconMode);
setMouseTracking(true);
connect(this, SIGNAL(clicked(const QModelIndex&)),
- controller, SLOT(requestTab(const QModelIndex&)));
+ dolphinViewController, SLOT(requestTab(const QModelIndex&)));
if (KGlobalSettings::singleClick()) {
connect(this, SIGNAL(clicked(const QModelIndex&)),
- controller, SLOT(triggerItem(const QModelIndex&)));
+ dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
} else {
connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
- controller, SLOT(triggerItem(const QModelIndex&)));
+ dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
}
connect(this, SIGNAL(entered(const QModelIndex&)),
- controller, SLOT(emitItemEntered(const QModelIndex&)));
+ dolphinViewController, SLOT(emitItemEntered(const QModelIndex&)));
connect(this, SIGNAL(viewportEntered()),
- controller, SLOT(emitViewportEntered()));
- connect(controller, SIGNAL(zoomLevelChanged(int)),
+ dolphinViewController, SLOT(emitViewportEntered()));
+ connect(viewModeController, SIGNAL(zoomLevelChanged(int)),
this, SLOT(setZoomLevel(int)));
- const DolphinView* view = controller->dolphinView();
+ const DolphinView* view = dolphinViewController->view();
connect(view, SIGNAL(showPreviewChanged()),
this, SLOT(slotShowPreviewChanged()));
connect(view, SIGNAL(additionalInfoChanged()),
this, SLOT(slotGlobalSettingsChanged(int)));
updateGridSize(view->showPreview(), 0);
- m_extensionsFactory = new ViewExtensionsFactory(this, controller);
+ m_extensionsFactory = new ViewExtensionsFactory(this, dolphinViewController, viewModeController);
}
DolphinIconsView::~DolphinIconsView()
void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
{
KCategorizedView::contextMenuEvent(event);
- m_controller->triggerContextMenuRequest(event->pos());
+ m_dolphinViewController->triggerContextMenuRequest(event->pos());
}
void DolphinIconsView::mousePressEvent(QMouseEvent* event)
{
- m_controller->requestActivation();
+ m_dolphinViewController->requestActivation();
const QModelIndex index = indexAt(event->pos());
if (index.isValid() && (event->button() == Qt::LeftButton)) {
// TODO: It should not be necessary to manually set the dragging state, but I could
}
if (!index.isValid() && (QApplication::mouseButtons() & Qt::MidButton)) {
- m_controller->replaceUrlByClipboard();
+ m_dolphinViewController->replaceUrlByClipboard();
}
KCategorizedView::mousePressEvent(event);
void DolphinIconsView::startDrag(Qt::DropActions supportedActions)
{
- DragAndDropHelper::instance().startDrag(this, supportedActions, m_controller);
+ DragAndDropHelper::instance().startDrag(this, supportedActions, m_dolphinViewController);
}
void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
m_dropRect.setSize(QSize()); // set as invalid
if (index.isValid()) {
- const KFileItem item = m_controller->itemForIndex(index);
+ const KFileItem item = m_dolphinViewController->itemForIndex(index);
if (!item.isNull() && item.isDir()) {
m_dropRect = visualRect(index);
} else {
void DolphinIconsView::dropEvent(QDropEvent* event)
{
const QModelIndex index = indexAt(event->pos());
- const KFileItem item = m_controller->itemForIndex(index);
- m_controller->indicateDroppedUrls(item, m_controller->url(), event);
+ const KFileItem item = m_dolphinViewController->itemForIndex(index);
+ m_dolphinViewController->indicateDroppedUrls(item, m_viewModeController->url(), event);
// don't call KCategorizedView::dropEvent(event), as it moves
// the items which is not wanted
}
void DolphinIconsView::keyPressEvent(QKeyEvent* event)
{
KCategorizedView::keyPressEvent(event);
- m_controller->handleKeyPressEvent(event);
+ m_dolphinViewController->handleKeyPressEvent(event);
}
void DolphinIconsView::wheelEvent(QWheelEvent* event)
// if the mouse is above an item and moved very fast outside the widget,
// no viewportEntered() signal might be emitted although the mouse has been moved
// above the viewport
- m_controller->emitViewportEntered();
+ m_dolphinViewController->emitViewportEntered();
}
void DolphinIconsView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
void DolphinIconsView::resizeEvent(QResizeEvent* event)
{
KCategorizedView::resizeEvent(event);
- const DolphinView* view = m_controller->dolphinView();
+ const DolphinView* view = m_dolphinViewController->view();
updateGridSize(view->showPreview(), view->additionalInfo().count());
}
void DolphinIconsView::slotShowPreviewChanged()
{
- const DolphinView* view = m_controller->dolphinView();
+ const DolphinView* view = m_dolphinViewController->view();
updateGridSize(view->showPreview(), additionalInfoCount());
}
void DolphinIconsView::slotAdditionalInfoChanged()
{
- const DolphinView* view = m_controller->dolphinView();
+ const DolphinView* view = m_dolphinViewController->view();
const bool showPreview = view->showPreview();
updateGridSize(showPreview, view->additionalInfo().count());
}
const int oldIconSize = settings->iconSize();
int newIconSize = oldIconSize;
- const bool showPreview = m_controller->dolphinView()->showPreview();
+ const bool showPreview = m_dolphinViewController->view()->showPreview();
if (showPreview) {
const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(level);
settings->setPreviewSize(previewSize);
void DolphinIconsView::requestActivation()
{
- m_controller->requestActivation();
+ m_dolphinViewController->requestActivation();
}
void DolphinIconsView::slotGlobalSettingsChanged(int category)
m_font = KGlobalSettings::generalFont();
}
- disconnect(this, SIGNAL(clicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
- disconnect(this, SIGNAL(doubleClicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
+ disconnect(this, SIGNAL(clicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
+ disconnect(this, SIGNAL(doubleClicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
if (KGlobalSettings::singleClick()) {
- connect(this, SIGNAL(clicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
+ connect(this, SIGNAL(clicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
} else {
- connect(this, SIGNAL(doubleClicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
+ connect(this, SIGNAL(doubleClicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
}
}
int DolphinIconsView::additionalInfoCount() const
{
- const DolphinView* view = m_controller->dolphinView();
+ const DolphinView* view = m_dolphinViewController->view();
return view->additionalInfo().count();
}
#include <libdolphin_export.h>
-class DolphinController;
+class DolphinViewController;
class DolphinCategoryDrawer;
class DolphinSortFilterProxyModel;
class ViewExtensionsFactory;
+class ViewModeController;
/**
* @brief Represents the view, where each item is shown as an icon.
Q_OBJECT
public:
+ /**
+ * @param parent Parent widget.
+ * @param dolphinViewController Allows the DolphinIconsView to control the
+ * DolphinView in a limited way.
+ * @param viewModeController Controller that is used by the DolphinView
+ * to control the DolphinIconsView. The DolphinIconsView
+ * only has read access to the controller.
+ * @param model Directory that is shown.
+ */
explicit DolphinIconsView(QWidget* parent,
- DolphinController* controller,
+ DolphinViewController* dolphinViewController,
+ const ViewModeController* viewModeController,
DolphinSortFilterProxyModel* proxyModel);
virtual ~DolphinIconsView();
int additionalInfoCount() const;
private:
- DolphinController* m_controller;
+ DolphinViewController* m_dolphinViewController;
+ const ViewModeController* m_viewModeController;
DolphinCategoryDrawer* m_categoryDrawer;
ViewExtensionsFactory* m_extensionsFactory;
#include "dolphinmodel.h"
#include "dolphincolumnviewcontainer.h"
-#include "dolphincontroller.h"
+#include "dolphinviewcontroller.h"
#include "dolphindetailsview.h"
#include "dolphinfileitemdelegate.h"
#include "dolphinnewmenuobserver.h"
#include "draganddrophelper.h"
#include "renamedialog.h"
#include "settings/dolphinsettings.h"
+#include "viewmodecontroller.h"
#include "viewproperties.h"
#include "zoomlevelinfo.h"
#include "dolphindetailsviewexpander.h"
m_assureVisibleCurrentIndex(false),
m_mode(DolphinView::IconsView),
m_topLayout(0),
- m_controller(0),
+ m_dolphinViewController(0),
+ m_viewModeController(0),
m_viewAccessor(proxyModel),
m_selectionModel(0),
m_selectionChangedTimer(0),
m_topLayout->setSpacing(0);
m_topLayout->setMargin(0);
- m_controller = new DolphinController(this);
- m_controller->setUrl(url);
+ m_dolphinViewController = new DolphinViewController(this);
- connect(m_controller, SIGNAL(urlChanged(const KUrl&)),
+ m_viewModeController = new ViewModeController(this);
+ m_viewModeController->setUrl(url);
+
+ connect(m_viewModeController, SIGNAL(urlChanged(const KUrl&)),
this, SIGNAL(urlChanged(const KUrl&)));
- connect(m_controller, SIGNAL(requestContextMenu(const QPoint&, const QList<QAction*>&)),
+ connect(m_dolphinViewController, SIGNAL(requestContextMenu(const QPoint&, const QList<QAction*>&)),
this, SLOT(openContextMenu(const QPoint&, const QList<QAction*>&)));
- connect(m_controller, SIGNAL(urlsDropped(const KFileItem&, const KUrl&, QDropEvent*)),
+ connect(m_dolphinViewController, SIGNAL(urlsDropped(const KFileItem&, const KUrl&, QDropEvent*)),
this, SLOT(dropUrls(const KFileItem&, const KUrl&, QDropEvent*)));
- connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
+ connect(m_dolphinViewController, SIGNAL(sortingChanged(DolphinView::Sorting)),
this, SLOT(updateSorting(DolphinView::Sorting)));
- connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
+ connect(m_dolphinViewController, SIGNAL(sortOrderChanged(Qt::SortOrder)),
this, SLOT(updateSortOrder(Qt::SortOrder)));
- connect(m_controller, SIGNAL(sortFoldersFirstChanged(bool)),
+ connect(m_dolphinViewController, SIGNAL(sortFoldersFirstChanged(bool)),
this, SLOT(updateSortFoldersFirst(bool)));
- connect(m_controller, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)),
+ connect(m_dolphinViewController, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)),
this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList&)));
- connect(m_controller, SIGNAL(itemTriggered(const KFileItem&)),
+ connect(m_dolphinViewController, SIGNAL(itemTriggered(const KFileItem&)),
this, SLOT(triggerItem(const KFileItem&)));
- connect(m_controller, SIGNAL(tabRequested(const KUrl&)),
+ connect(m_dolphinViewController, SIGNAL(tabRequested(const KUrl&)),
this, SIGNAL(tabRequested(const KUrl&)));
- connect(m_controller, SIGNAL(activated()),
+ connect(m_dolphinViewController, SIGNAL(activated()),
this, SLOT(activate()));
- connect(m_controller, SIGNAL(itemEntered(const KFileItem&)),
+ connect(m_dolphinViewController, SIGNAL(itemEntered(const KFileItem&)),
this, SLOT(showHoverInformation(const KFileItem&)));
- connect(m_controller, SIGNAL(viewportEntered()),
+ connect(m_dolphinViewController, SIGNAL(viewportEntered()),
this, SLOT(clearHoverInformation()));
+ connect(m_dolphinViewController, SIGNAL(urlChangeRequested(KUrl)),
+ m_viewModeController, SLOT(setUrl(KUrl)));
KDirLister* dirLister = m_viewAccessor.dirLister();
connect(dirLister, SIGNAL(redirection(KUrl,KUrl)),
{
}
-const KUrl& DolphinView::url() const
+KUrl DolphinView::url() const
{
- return m_controller->url();
+ return m_viewModeController->url();
}
KUrl DolphinView::rootUrl() const
emit activated();
}
- m_controller->indicateActivationChange(active);
+ m_viewModeController->indicateActivationChange(active);
}
bool DolphinView::isActive() const
return; // the wished mode is already set
}
- const int oldZoomLevel = m_controller->zoomLevel();
+ const int oldZoomLevel = m_viewModeController->zoomLevel();
m_mode = mode;
// remember the currently selected items, so that they will
}
if (level != zoomLevel()) {
- m_controller->setZoomLevel(level);
+ m_viewModeController->setZoomLevel(level);
emit zoomLevelChanged(level);
}
}
int DolphinView::zoomLevel() const
{
- return m_controller->zoomLevel();
+ return m_viewModeController->zoomLevel();
}
void DolphinView::setSorting(Sorting sorting)
m_ignoreViewProperties = false;
const bool oldActivationState = m_active;
- const int oldZoomLevel = m_controller->zoomLevel();
+ const int oldZoomLevel = m_viewModeController->zoomLevel();
m_active = true;
createView();
void DolphinView::setNameFilter(const QString& nameFilter)
{
- m_controller->setNameFilter(nameFilter);
+ m_viewModeController->setNameFilter(nameFilter);
}
void DolphinView::calculateItemCount(int& fileCount,
QList<QAction*> DolphinView::versionControlActions(const KFileItemList& items) const
{
- return m_controller->versionControlActions(items);
+ return m_dolphinViewController->versionControlActions(items);
}
void DolphinView::setUrl(const KUrl& url)
{
- if (m_controller->url() != url) {
+ if (m_viewModeController->url() != url) {
m_newFileNames.clear();
- m_controller->setUrl(url); // emits urlChanged, which we forward
+ m_viewModeController->setUrl(url); // emits urlChanged, which we forward
m_viewAccessor.prepareUrlChange(url);
applyViewProperties();
loadDirectory(url);
props.setShowPreview(show);
m_showPreview = show;
- const int oldZoomLevel = m_controller->zoomLevel();
+ const int oldZoomLevel = m_viewModeController->zoomLevel();
emit showPreviewChanged();
// Enabling or disabling the preview might change the icon size of the view.
switch (event->type()) {
case QEvent::FocusIn:
if (watched == m_viewAccessor.itemView()) {
- m_controller->requestActivation();
+ m_dolphinViewController->requestActivation();
}
break;
const Mode mode = props.viewMode();
if (m_mode != mode) {
- const int oldZoomLevel = m_controller->zoomLevel();
+ const int oldZoomLevel = m_viewModeController->zoomLevel();
m_mode = mode;
createView();
const bool showPreview = props.showPreview();
if (showPreview != m_showPreview) {
m_showPreview = showPreview;
- const int oldZoomLevel = m_controller->zoomLevel();
+ const int oldZoomLevel = m_viewModeController->zoomLevel();
emit showPreviewChanged();
// Enabling or disabling the preview might change the icon size of the view.
deleteView();
Q_ASSERT(m_viewAccessor.itemView() == 0);
- m_viewAccessor.createView(this, m_controller, m_mode);
+ m_viewAccessor.createView(this, m_dolphinViewController, m_viewModeController, m_mode);
QAbstractItemView* view = m_viewAccessor.itemView();
Q_ASSERT(view != 0);
view->installEventFilter(this);
view->viewport()->installEventFilter(this);
- m_controller->setItemView(view);
+ m_dolphinViewController->setItemView(view);
// When changing the view mode, the selection is lost due to reinstantiating
// a new item view with a custom selection model. Pass the ownership of the
// disconnect all signal/slots
disconnect(view);
- m_controller->disconnect(view);
+ m_viewModeController->disconnect(view);
view->disconnect();
m_viewAccessor.deleteView();
{
const int newZoomLevel = ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor.itemView()->iconSize());
if (oldZoomLevel != newZoomLevel) {
- m_controller->setZoomLevel(newZoomLevel);
+ m_viewModeController->setZoomLevel(newZoomLevel);
emit zoomLevelChanged(newZoomLevel);
}
}
}
void DolphinView::ViewAccessor::createView(QWidget* parent,
- DolphinController* controller,
+ DolphinViewController* dolphinViewController,
+ const ViewModeController* viewModeController,
Mode mode)
{
Q_ASSERT(itemView() == 0);
switch (mode) {
case IconsView:
- m_iconsView = new DolphinIconsView(parent, controller, m_proxyModel);
+ m_iconsView = new DolphinIconsView(parent,
+ dolphinViewController,
+ viewModeController,
+ m_proxyModel);
break;
case DetailsView:
- m_detailsView = new DolphinDetailsView(parent, controller, m_proxyModel);
+ m_detailsView = new DolphinDetailsView(parent,
+ dolphinViewController,
+ viewModeController,
+ m_proxyModel);
break;
case ColumnView:
- m_columnsContainer = new DolphinColumnViewContainer(parent, controller);
+ m_columnsContainer = new DolphinColumnViewContainer(parent,
+ dolphinViewController,
+ viewModeController);
break;
default:
void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
{
emit redirection(oldUrl, newUrl);
- m_controller->redirectToUrl(newUrl); // #186947
+ m_viewModeController->redirectToUrl(newUrl); // #186947
}
void DolphinView::restoreContentsPosition()
typedef KIO::FileUndoManager::CommandType CommandType;
-class DolphinController;
class DolphinColumnViewContainer;
class DolphinDetailsView;
class DolphinIconsView;
class DolphinModel;
class DolphinSortFilterProxyModel;
+class DolphinViewController;
class KFilePreviewGenerator;
class KAction;
class KActionCollection;
class KDirLister;
class KUrl;
+class ViewModeController;
class ViewProperties;
class DolphinDetailsViewExpander;
* Returns the current active URL, where all actions are applied.
* The URL navigator is synchronized with this URL.
*/
- const KUrl& url() const;
+ KUrl url() const;
/**
* Returns the root URL of the view, which is defined as the first
ViewAccessor(DolphinSortFilterProxyModel* proxyModel);
~ViewAccessor();
- void createView(QWidget* parent, DolphinController* controller, Mode mode);
+ void createView(QWidget* parent,
+ DolphinViewController* dolphinViewController,
+ const ViewModeController* viewModeController,
+ Mode mode);
void deleteView();
/**
QVBoxLayout* m_topLayout;
- DolphinController* m_controller;
+ DolphinViewController* m_dolphinViewController;
+ ViewModeController* m_viewModeController;
ViewAccessor m_viewAccessor;
QItemSelectionModel* m_selectionModel; // allow to switch views without losing the selection
#include <kurlnavigator.h>
#include <krun.h>
+#include "dolphin_generalsettings.h"
#include "dolphinmodel.h"
#include "dolphincolumnview.h"
-#include "dolphincontroller.h"
+#include "dolphinviewcontroller.h"
#include "dolphinmainwindow.h"
#include "dolphindirlister.h"
#include "dolphinsortfilterproxymodel.h"
#include "dolphiniconsview.h"
#include "draganddrophelper.h"
#include "filterbar.h"
+#include "settings/dolphinsettings.h"
#include "statusbar/dolphinstatusbar.h"
+#include "viewmodecontroller.h"
#include "viewproperties.h"
-#include "settings/dolphinsettings.h"
-#include "dolphin_generalsettings.h"
DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
QWidget(parent),
/***************************************************************************
- * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) *
+ * Copyright (C) 2010 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 *
* 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 *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include "dolphincontroller.h"
+#include "dolphinviewcontroller.h"
#include "zoomlevelinfo.h"
#include <kdirmodel.h>
#include <QClipboard>
#include <QDir>
-Qt::MouseButtons DolphinController::m_mouseButtons = Qt::NoButton;
+Qt::MouseButtons DolphinViewController::m_mouseButtons = Qt::NoButton;
-DolphinController::DolphinController(DolphinView* dolphinView) :
+DolphinViewController::DolphinViewController(DolphinView* dolphinView) :
QObject(dolphinView),
- m_zoomLevel(0),
- m_nameFilter(),
- m_url(),
m_dolphinView(dolphinView),
m_itemView(0),
m_versionControlActions()
{
}
-DolphinController::~DolphinController()
+DolphinViewController::~DolphinViewController()
{
}
-void DolphinController::setUrl(const KUrl& url)
+const DolphinView* DolphinViewController::view() const
{
- if (m_url != url) {
- m_url = url;
- emit cancelPreviews();
- emit urlChanged(url);
- }
+ return m_dolphinView;
}
-void DolphinController::redirectToUrl(const KUrl& url)
+void DolphinViewController::requestUrlChange(const KUrl& url)
{
- m_url = url;
+ emit urlChangeRequested(url);
}
-void DolphinController::setItemView(QAbstractItemView* view)
+void DolphinViewController::setItemView(QAbstractItemView* view)
{
if (m_itemView != 0) {
disconnect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
m_itemView = view;
if (m_itemView != 0) {
- m_zoomLevel = ZoomLevelInfo::zoomLevelForIconSize(m_itemView->iconSize());
-
// TODO: this is a workaround until Qt-issue 176832 has been fixed
connect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
this, SLOT(updateMouseButtonState()));
}
}
-void DolphinController::triggerContextMenuRequest(const QPoint& pos,
+QAbstractItemView* DolphinViewController::itemView() const
+{
+ return m_itemView;
+}
+
+void DolphinViewController::triggerContextMenuRequest(const QPoint& pos,
const QList<QAction*>& customActions)
{
emit activated();
emit requestContextMenu(pos, customActions);
}
-void DolphinController::requestActivation()
+void DolphinViewController::requestActivation()
{
emit activated();
}
-void DolphinController::indicateDroppedUrls(const KFileItem& destItem,
+void DolphinViewController::indicateDroppedUrls(const KFileItem& destItem,
const KUrl& destPath,
QDropEvent* event)
{
}
-void DolphinController::indicateSortingChange(DolphinView::Sorting sorting)
+void DolphinViewController::indicateSortingChange(DolphinView::Sorting sorting)
{
emit sortingChanged(sorting);
}
-void DolphinController::indicateSortOrderChange(Qt::SortOrder order)
+void DolphinViewController::indicateSortOrderChange(Qt::SortOrder order)
{
emit sortOrderChanged(order);
}
-void DolphinController::indicateSortFoldersFirstChange(bool foldersFirst)
+void DolphinViewController::indicateSortFoldersFirstChange(bool foldersFirst)
{
emit sortFoldersFirstChanged(foldersFirst);
}
-void DolphinController::indicateAdditionalInfoChange(const KFileItemDelegate::InformationList& info)
+void DolphinViewController::indicateAdditionalInfoChange(const KFileItemDelegate::InformationList& info)
{
emit additionalInfoChanged(info);
}
-void DolphinController::indicateActivationChange(bool active)
-{
- emit activationChanged(active);
-}
-
-void DolphinController::setNameFilter(const QString& nameFilter)
-{
- if (nameFilter != m_nameFilter) {
- m_nameFilter = nameFilter;
- emit nameFilterChanged(nameFilter);
- }
-}
-
-QString DolphinController::nameFilter() const
-{
- return m_nameFilter;
-}
-
-void DolphinController::setZoomLevel(int level)
-{
- Q_ASSERT(level >= ZoomLevelInfo::minimumLevel());
- Q_ASSERT(level <= ZoomLevelInfo::maximumLevel());
- if (level != m_zoomLevel) {
- m_zoomLevel = level;
- emit zoomLevelChanged(m_zoomLevel);
- }
-}
-
-void DolphinController::setVersionControlActions(QList<QAction*> actions)
+void DolphinViewController::setVersionControlActions(QList<QAction*> actions)
{
m_versionControlActions = actions;
}
-QList<QAction*> DolphinController::versionControlActions(const KFileItemList& items)
+QList<QAction*> DolphinViewController::versionControlActions(const KFileItemList& items)
{
emit requestVersionControlActions(items);
// All view implementations are connected with the signal requestVersionControlActions()
- // (see ViewExtensionFactory) and will invoke DolphinController::setVersionControlActions(),
+ // (see ViewExtensionFactory) and will invoke DolphinViewController::setVersionControlActions(),
// so that the context dependent actions can be returned.
return m_versionControlActions;
}
-void DolphinController::handleKeyPressEvent(QKeyEvent* event)
+void DolphinViewController::handleKeyPressEvent(QKeyEvent* event)
{
Q_ASSERT(m_itemView != 0);
}
}
-void DolphinController::replaceUrlByClipboard()
+void DolphinViewController::replaceUrlByClipboard()
{
const QClipboard* clipboard = QApplication::clipboard();
QString text;
}
}
-void DolphinController::emitHideToolTip()
+void DolphinViewController::requestToolTipHiding()
{
emit hideToolTip();
}
-void DolphinController::emitItemTriggered(const KFileItem& item)
+void DolphinViewController::emitItemTriggered(const KFileItem& item)
{
emit itemTriggered(item);
}
-KFileItem DolphinController::itemForIndex(const QModelIndex& index) const
+KFileItem DolphinViewController::itemForIndex(const QModelIndex& index) const
{
Q_ASSERT(m_itemView != 0);
return dirModel->itemForIndex(dirIndex);
}
-void DolphinController::triggerItem(const QModelIndex& index)
+void DolphinViewController::triggerItem(const QModelIndex& index)
{
if (m_mouseButtons & Qt::LeftButton) {
const KFileItem item = itemForIndex(index);
}
}
-void DolphinController::requestTab(const QModelIndex& index)
+void DolphinViewController::requestTab(const QModelIndex& index)
{
if (m_mouseButtons & Qt::MidButton) {
const KFileItem item = itemForIndex(index);
}
}
-void DolphinController::emitItemEntered(const QModelIndex& index)
+void DolphinViewController::emitItemEntered(const QModelIndex& index)
{
KFileItem item = itemForIndex(index);
if (!item.isNull()) {
}
}
-void DolphinController::emitViewportEntered()
+void DolphinViewController::emitViewportEntered()
{
emit viewportEntered();
}
-void DolphinController::updateMouseButtonState()
+void DolphinViewController::updateMouseButtonState()
{
m_mouseButtons = QApplication::mouseButtons();
}
-#include "dolphincontroller.moc"
+#include "dolphinviewcontroller.moc"
/***************************************************************************
- * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) *
+ * Copyright (C) 2010 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 *
* 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 *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#ifndef DOLPHINCONTROLLER_H
-#define DOLPHINCONTROLLER_H
+#ifndef DOLPHINVIEWCONTROLLER_H
+#define DOLPHINVIEWCONTROLLER_H
#include <dolphinview.h>
#include <kurl.h>
class QPoint;
/**
- * @brief Acts as mediator between the abstract Dolphin view and the view
- * implementations.
+ * @brief Allows the view mode implementations (DolphinIconsView, DolphinDetailsView, DolphinColumnView)
+ * to do a limited control of the DolphinView.
*
- * The abstract Dolphin view (see DolphinView) represents the parent of the controller.
- * The lifetime of the controller is equal to the lifetime of the Dolphin view.
- * The controller is passed to the current view implementation
- * (see DolphinIconsView, DolphinDetailsView and DolphinColumnView)
- * by passing it in the constructor and informing the controller about the change
- * of the view implementation:
- *
- * \code
- * QAbstractItemView* view = new DolphinIconsView(parent, controller);
- * controller->setItemView(view);
- * \endcode
- *
- * The communication of the view implementations to the abstract view is done by:
- * - triggerContextMenuRequest()
- * - requestActivation()
- * - indicateDroppedUrls()
- * - indicateSortingChange()
- * - indicateSortOrderChanged()
- * - indicateSortFoldersFirstChanged()
- * - triggerItem()
- * - requestTab()
- * - handleKeyPressEvent()
- * - emitItemEntered()
- * - emitViewportEntered()
- * - replaceUrlByClipboard()
- * - hideToolTip()
- * - setVersionControlActions()
- *
- * The communication of the abstract view to the view implementations is done by:
- * - setUrl()
- * - indicateActivationChange()
- * - setNameFilter()
- * - setZoomLevel()
- * - versionControlActions()
+ * The DolphinView connects to the signals of DolphinViewController to react on changes
+ * that have been triggered by the view mode implementations. The view mode implementations
+ * have read access to the whole DolphinView by DolphinViewController::view(). Limited control of the
+ * DolphinView by the view mode implementations are defined by the public DolphinController methods.
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinController : public QObject
+class LIBDOLPHINPRIVATE_EXPORT DolphinViewController : public QObject
{
Q_OBJECT
public:
- explicit DolphinController(DolphinView* dolphinView);
- virtual ~DolphinController();
-
- /**
- * Allows read access for the view implementation to the abstract
- * Dolphin view.
- */
- const DolphinView* dolphinView() const;
+ explicit DolphinViewController(DolphinView* dolphinView);
+ virtual ~DolphinViewController();
/**
- * Sets the URL to \a url and emits the signal urlChanged() if
- * \a url is different for the current URL. This method should
- * be invoked by the abstract Dolphin view whenever the current
- * URL has been changed.
+ * Allows read access for the view mode implementation
+ * to the DolphinView.
*/
- void setUrl(const KUrl& url);
- const KUrl& url() const;
+ const DolphinView* view() const;
/**
- * Sets the URL to \a url and does nothing else. Called when
- * a redirection happens.
+ * Requests the DolphinView to change the URL to \p url. The signal
+ * urlChangeRequested will be emitted.
*/
- void redirectToUrl(const KUrl& url);
+ void requestUrlChange(const KUrl& url);
/**
- * Changes the current item view where the controller is working. This
- * is only necessary for views like the tree view, where internally
+ * Changes the current view mode implementation where the controller is working.
+ * This is only necessary for views like the tree view, where internally
* several QAbstractItemView instances are used.
*/
void setItemView(QAbstractItemView* view);
-
QAbstractItemView* itemView() const;
/**
- * Requests a context menu for the position \a pos. This method
- * should be invoked by the view implementation when a context
- * menu should be opened. The abstract Dolphin view itself
+ * Requests a context menu for the position \a pos. DolphinView
* takes care itself to get the selected items depending from
* \a pos. It is possible to define a custom list of actions for
* the context menu by \a customActions.
const QList<QAction*>& customActions = QList<QAction*>());
/**
- * Requests an activation of the view and emits the signal
- * activated(). This method should be invoked by the view implementation
+ * Requests an activation of the DolphinView and emits the signal
+ * activated(). This method should be invoked by the view mode implementation
* if e. g. a mouse click on the view has been done.
- * After the activation has been changed, the view implementation
- * might listen to the activationChanged() signal.
*/
void requestActivation();
/**
- * Indicates that URLs are dropped above a destination. This method
- * should be invoked by the view implementation. The abstract Dolphin view
+ * Indicates that URLs are dropped above a destination. The DolphinView
* will start the corresponding action (copy, move, link).
* @param destItem Item of the destination (can be null, see KFileItem::isNull()).
* @param destPath Path of the destination.
QDropEvent* event);
/**
- * Informs the abstract Dolphin view about a sorting change done inside
- * the view implementation. This method should be invoked by the view
- * implementation (e. g. the details view uses this method in combination
- * with the details header).
+ * Informs the DolphinView about a sorting change done inside
+ * the view mode implementation.
*/
void indicateSortingChange(DolphinView::Sorting sorting);
/**
- * Informs the abstract Dolphin view about a sort order change done inside
- * the view implementation. This method should be invoked by the view
- * implementation (e. g. the details view uses this method in combination
- * with the details header).
+ * Informs the DolphinView about a sort order change done inside
+ * the view mode implementation.
*/
void indicateSortOrderChange(Qt::SortOrder order);
/**
- * Informs the abstract Dolphin view about a change between separate sorting
+ * Informs the DolphinView about a change between separate sorting
* (with folders first) and mixed sorting of files and folders done inside
- * the view implementation. This method should be invoked by the view
- * implementation (e. g. the details view uses this method in combination
- * with the details header).
+ * the view mode implementation.
*/
void indicateSortFoldersFirstChange(bool foldersFirst);
/**
- * Informs the abstract Dolphin view about an additional information change
- * done inside the view implementation. This method should be invoked by the
- * view implementation (e. g. the details view uses this method in combination
- * with the details header).
+ * Informs the DolphinView about an additional information change
+ * done inside the view mode implementation.
*/
void indicateAdditionalInfoChange(const KFileItemDelegate::InformationList& info);
- /**
- * Informs the view implementation about a change of the activation
- * state and is invoked by the abstract Dolphin view. The signal
- * activationChanged() is emitted.
- */
- void indicateActivationChange(bool active);
-
- /**
- * Sets the zoom level to \a level and emits the signal zoomLevelChanged().
- * It must be assured that the used level is inside the range
- * DolphinController::zoomLevelMinimum() and
- * DolphinController::zoomLevelMaximum().
- * Is invoked by the abstract Dolphin view.
- */
- 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
+ * mode implementation as soon as the DolphinView has requested them by 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.
+ * Emits the signal requestVersionControlActions(). The view mode implementation
+ * listens to the signal and will invoke a DolphinViewController::setVersionControlActions()
+ * and the result will be returned.
*/
QList<QAction*> versionControlActions(const KFileItemList& items);
/**
- * Sets the name filter to \a and emits the signal nameFilterChanged().
- */
- void setNameFilter(const QString& nameFilter);
- QString nameFilter() const;
-
- /**
- * Tells the view implementation to zoom out by emitting the signal zoomOut()
- * and is invoked by the abstract Dolphin view.
- */
- void triggerZoomOut();
-
- /**
- * Should be invoked in each view implementation whenever a key has been
+ * Must be be invoked in each view mode implementation whenever a key has been
* pressed. If the selection model of \a view is not empty and
* the return key has been pressed, the selected items will get triggered.
*/
void handleKeyPressEvent(QKeyEvent* event);
/**
- * Replaces the URL of the abstract Dolphin view with the content
+ * Replaces the URL of the DolphinView with the content
* of the clipboard as URL. If the clipboard contains no text,
* nothing will be done.
*/
void replaceUrlByClipboard();
- /** Emits the signal hideToolTip(). */
- void emitHideToolTip();
+ /**
+ * Requests the view mode implementation to hide tooltips.
+ */
+ void requestToolTipHiding();
/**
* Emits the signal itemTriggered() for the item \a item.
- * The method can be used by the view implementations to
+ * The method can be used by the view mode implementations to
* trigger an item directly without mouse interaction.
* If the item triggering is done by the mouse, it is recommended
- * to use QAbstractItemView::triggerItem(), as this will check
+ * to use DolphinViewController::triggerItem(), as this will check
* the used mouse buttons to execute the correct action.
*/
void emitItemTriggered(const KFileItem& item);
/**
- * Returns the file item for the proxy index \a index of the view \a view.
+ * Returns the file item for the proxy index \a index of the DolphinView.
*/
KFileItem itemForIndex(const QModelIndex& index) const;
* Emits the signal itemTriggered() if the file item for the index \a index
* is not null and the left mouse button has been pressed. If the item is
* null, the signal itemEntered() is emitted.
- * The method should be invoked by the view implementations whenever the
+ * The method should be invoked by the view mode implementations whenever the
* user has triggered an item with the mouse (see
* QAbstractItemView::clicked() or QAbstractItemView::doubleClicked()).
*/
/**
* Emits the signal tabRequested(), if the file item for the index \a index
* represents a directory and when the middle mouse button has been pressed.
- * The method should be invoked by the view implementation.
*/
void requestTab(const QModelIndex& index);
/**
* Emits the signal itemEntered() if the file item for the index \a index
- * is not null. The method should be invoked by the view implementation
+ * is not null. The method should be invoked by the view mode implementation
* whenever the mouse cursor is above an item.
*/
void emitItemEntered(const QModelIndex& index);
/**
* Emits the signal viewportEntered(). The method should be invoked by
- * the view implementation whenever the mouse cursor is above the viewport.
+ * the view mode implementation whenever the mouse cursor is above the viewport.
*/
void emitViewportEntered();
signals:
- /**
- * Is emitted if the URL for the Dolphin controller has been changed
- * to \a url.
- */
- void urlChanged(const KUrl& url);
+ void urlChangeRequested(const KUrl& url);
/**
* Is emitted if a context menu should be opened (see triggerContextMenuRequest()).
- * The abstract Dolphin view connects to this signal and will open the context menu.
* @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
/**
* Is emitted if the view has been activated by e. g. a mouse click.
- * The abstract Dolphin view connects to this signal to know the
- * destination view for the menu actions.
*/
void activated();
/**
* Is emitted if the sorting has been changed to \a sorting by
- * the view implementation (see indicateSortingChanged().
- * The abstract Dolphin view connects to
+ * the view mode implementation (see indicateSortingChanged().
+ * The DolphinView connects to
* this signal to update its menu action.
*/
void sortingChanged(DolphinView::Sorting sorting);
/**
* Is emitted if the sort order has been changed to \a order
- * by the view implementation (see indicateSortOrderChanged().
- * The abstract Dolphin view connects
+ * by the view mode implementation (see indicateSortOrderChanged().
+ * The DolphinView connects
* to this signal to update its menu actions.
*/
void sortOrderChanged(Qt::SortOrder order);
/**
* Is emitted if 'sort folders first' has been changed to \a foldersFirst
- * by the view implementation (see indicateSortOrderChanged().
- * The abstract Dolphin view connects
+ * by the view mode implementation (see indicateSortOrderChanged().
+ * The DolphinView connects
* to this signal to update its menu actions.
*/
void sortFoldersFirstChanged(bool foldersFirst);
/**
* Is emitted if the additional info has been changed to \a info
- * by the view implementation. The abstract Dolphin view connects
+ * by the view mode implementation. The DolphinView connects
* to this signal to update its menu actions.
*/
void additionalInfoChanged(const KFileItemDelegate::InformationList& info);
- /**
- * Is emitted if the activation state has been changed to \a active
- * by the abstract Dolphin view.
- * The view implementation might connect to this signal if custom
- * updates are required in this case.
- */
- void activationChanged(bool active);
-
/**
* Is emitted if the item \a item should be triggered. The abstract
* Dolphin view connects to this signal. If the item represents a directory,
/**
* Is emitted if the mouse cursor has entered the item
* given by \a index (see emitItemEntered()).
- * The abstract Dolphin view connects to this signal.
*/
void itemEntered(const KFileItem& item);
/**
* Is emitted if the mouse cursor has entered
* the viewport (see emitViewportEntered()).
- * The abstract Dolphin view connects to this signal.
*/
void viewportEntered();
/**
- * Is emitted if the view should respect the name filter \a nameFilter. The view
- * implementation must connect to this signal if it supports name filters.
- */
- void nameFilterChanged(const QString& nameFilter);
-
- /**
- * Is emitted if the view should change the zoom to \a level. The view implementation
- * must connect to this signal if it supports zooming.
- */
- void zoomLevelChanged(int level);
-
- /**
- * Is emitted if the abstract view should hide an open tooltip.
+ * Is emitted, if DolphinViewController::requestToolTipHiding() is invoked
+ * and requests to hide all tooltips.
*/
void hideToolTip();
void cancelPreviews();
/**
- * Requests the view implementation to invoke DolphinController::setVersionControlActions(),
- * so that they can be returned with DolphinController::versionControlActions() for
- * the abstract Dolphin view.
+ * Requests the view mode implementation to invoke DolphinViewController::setVersionControlActions(),
+ * so that they can be returned with DolphinViewController::versionControlActions() for
+ * the DolphinView.
*/
void requestVersionControlActions(const KFileItemList& items);
void updateMouseButtonState();
private:
- int m_zoomLevel;
- QString m_nameFilter;
static Qt::MouseButtons m_mouseButtons; // TODO: this is a workaround until Qt-issue 176832 has been fixed
- KUrl m_url;
+
DolphinView* m_dolphinView;
QAbstractItemView* m_itemView;
QList<QAction*> m_versionControlActions;
};
-inline const DolphinView* DolphinController::dolphinView() const
-{
- return m_dolphinView;
-}
-
-inline const KUrl& DolphinController::url() const
-{
- return m_url;
-}
-
-inline QAbstractItemView* DolphinController::itemView() const
-{
- return m_itemView;
-}
-
-inline int DolphinController::zoomLevel() const
-{
- return m_zoomLevel;
-}
-
#endif
#include "draganddrophelper.h"
#include "dolphiniconsview.h"
-#include "dolphincontroller.h"
+#include "dolphinviewcontroller.h"
#include <kdirmodel.h>
#include <kfileitem.h>
void DragAndDropHelper::startDrag(QAbstractItemView* itemView,
Qt::DropActions supportedActions,
- DolphinController* controller)
+ DolphinViewController* dolphinViewController)
{
// Do not start a new drag until the previous one has been finished.
// This is a (possibly temporary) fix for bug #187884.
return;
}
- if (controller != 0) {
- controller->emitHideToolTip();
+ if (dolphinViewController != 0) {
+ dolphinViewController->requestToolTipHiding();
}
QDrag* drag = new QDrag(itemView);
#include "libdolphin_export.h"
#include <QObject>
-class DolphinController;
+class DolphinViewController;
class KFileItem;
class KUrl;
class QDropEvent;
*/
void startDrag(QAbstractItemView* itemView,
Qt::DropActions supportedActions,
- DolphinController* controller = 0);
+ DolphinViewController* dolphinViewController = 0);
/**
* Returns true if and only if the view \a itemView was the last view to
#include "paneltreeview.h"
-#include "dolphincontroller.h"
+#include "dolphinviewcontroller.h"
#include "dolphinmodel.h"
#include "draganddrophelper.h"
+#include "viewmodecontroller.h"
#include <kfileitemdelegate.h>
#include <QKeyEvent>
#include "viewextensionsfactory.h"
-#include "dolphincontroller.h"
#include "dolphinfileitemdelegate.h"
#include "dolphinsortfilterproxymodel.h"
#include "dolphinview.h"
+#include "dolphinviewcontroller.h"
#include "dolphinviewautoscroller.h"
#include "folderexpander.h"
#include "selectionmanager.h"
#include "settings/dolphinsettings.h"
#include "tooltips/tooltipmanager.h"
#include "versioncontrol/versioncontrolobserver.h"
+#include "viewmodecontroller.h"
#include "dolphin_generalsettings.h"
#include <QAbstractItemView>
ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
- DolphinController* controller) :
+ DolphinViewController* dolphinViewController,
+ const ViewModeController* viewModeController) :
QObject(view),
m_view(view),
- m_controller(controller),
+ m_dolphinViewController(dolphinViewController),
m_toolTipManager(0),
m_previewGenerator(0),
m_selectionManager(0),
DolphinSortFilterProxyModel* proxyModel = static_cast<DolphinSortFilterProxyModel*>(view->model());
m_toolTipManager = new ToolTipManager(view, proxyModel);
- connect(controller, SIGNAL(hideToolTip()),
+ connect(viewModeController, SIGNAL(hideToolTip()),
m_toolTipManager, SLOT(hideTip()));
}
// initialize preview generator
Q_ASSERT(view->iconSize().isValid());
m_previewGenerator = new KFilePreviewGenerator(view);
- m_previewGenerator->setPreviewShown(controller->dolphinView()->showPreview());
- connect(controller, SIGNAL(zoomLevelChanged(int)),
+ m_previewGenerator->setPreviewShown(dolphinViewController->view()->showPreview());
+ connect(viewModeController, SIGNAL(zoomLevelChanged(int)),
this, SLOT(slotZoomLevelChanged()));
- connect(controller, SIGNAL(cancelPreviews()),
+ connect(viewModeController, SIGNAL(cancelPreviews()),
this, SLOT(cancelPreviews()));
- connect(controller->dolphinView(), SIGNAL(showPreviewChanged()),
+ connect(dolphinViewController->view(), SIGNAL(showPreviewChanged()),
this, SLOT(slotShowPreviewChanged()));
// initialize selection manager
m_selectionManager = new SelectionManager(view);
connect(m_selectionManager, SIGNAL(selectionChanged()),
this, SLOT(requestActivation()));
- connect(controller, SIGNAL(urlChanged(const KUrl&)),
+ connect(viewModeController, SIGNAL(urlChanged(const KUrl&)),
m_selectionManager, SLOT(reset()));
}
view->setItemDelegate(m_fileItemDelegate);
// initialize version control observer
- const DolphinView* dolphinView = controller->dolphinView();
+ const DolphinView* dolphinView = dolphinViewController->view();
m_versionControlObserver = new VersionControlObserver(view);
connect(m_versionControlObserver, SIGNAL(infoMessage(const QString&)),
dolphinView, SIGNAL(infoMessage(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&)),
+ connect(dolphinViewController, SIGNAL(requestVersionControlActions(const KFileItemList&)),
this, SLOT(slotRequestVersionControlActions(const KFileItemList&)));
// react on view property changes
m_folderExpander = new FolderExpander(view, proxyModel());
m_folderExpander->setEnabled(settings->autoExpandFolders());
connect(m_folderExpander, SIGNAL(enterDir(const QModelIndex&)),
- controller, SLOT(triggerItem(const QModelIndex&)));
+ dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
// react on namefilter changes
- connect(controller, SIGNAL(nameFilterChanged(const QString&)),
+ connect(viewModeController, SIGNAL(nameFilterChanged(const QString&)),
this, SLOT(slotNameFilterChanged(const QString&)));
view->viewport()->installEventFilter(this);
void ViewExtensionsFactory::slotShowPreviewChanged()
{
- const bool show = m_controller->dolphinView()->showPreview();
+ const bool show = m_dolphinViewController->view()->showPreview();
m_previewGenerator->setPreviewShown(show);
}
dirLister->stop();
- const bool show = m_controller->dolphinView()->showHiddenFiles();
+ const bool show = m_dolphinViewController->view()->showHiddenFiles();
dirLister->setShowingDotFiles(show);
const KUrl url = dirLister->url();
} else {
actions = m_versionControlObserver->contextMenuActions(items);
}
- m_controller->setVersionControlActions(actions);
+ m_dolphinViewController->setVersionControlActions(actions);
}
void ViewExtensionsFactory::requestActivation()
{
- m_controller->requestActivation();
+ m_dolphinViewController->requestActivation();
}
DolphinSortFilterProxyModel* ViewExtensionsFactory::proxyModel() const
#include "dolphinview.h"
-class DolphinController;
class DolphinFileItemDelegate;
class DolphinSortFilterProxyModel;
class DolphinViewAutoScroller;
class ToolTipManager;
class QAbstractItemView;
class VersionControlObserver;
+class ViewModeController;
/**
* @brief Responsible for creating extensions like tooltips and previews
public:
explicit ViewExtensionsFactory(QAbstractItemView* view,
- DolphinController* controller);
+ DolphinViewController* dolphinViewController,
+ const ViewModeController* viewModeController);
virtual ~ViewExtensionsFactory();
/**
private:
QAbstractItemView* m_view;
- DolphinController* m_controller;
+ DolphinViewController* m_dolphinViewController;
ToolTipManager* m_toolTipManager;
KFilePreviewGenerator* m_previewGenerator;
SelectionManager* m_selectionManager;
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2010 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 "viewmodecontroller.h"
+
+#include "zoomlevelinfo.h"
+
+ViewModeController::ViewModeController(QObject* parent) :
+ QObject(parent),
+ m_zoomLevel(0),
+ m_nameFilter(),
+ m_url()
+{
+}
+
+ViewModeController::~ViewModeController()
+{
+}
+
+KUrl ViewModeController::url() const
+{
+ return m_url;
+}
+
+void ViewModeController::redirectToUrl(const KUrl& url)
+{
+ m_url = url;
+}
+
+void ViewModeController::indicateActivationChange(bool active)
+{
+ emit activationChanged(active);
+}
+
+void ViewModeController::setNameFilter(const QString& nameFilter)
+{
+ if (nameFilter != m_nameFilter) {
+ m_nameFilter = nameFilter;
+ emit nameFilterChanged(nameFilter);
+ }
+}
+
+QString ViewModeController::nameFilter() const
+{
+ return m_nameFilter;
+}
+
+void ViewModeController::setZoomLevel(int level)
+{
+ Q_ASSERT(level >= ZoomLevelInfo::minimumLevel());
+ Q_ASSERT(level <= ZoomLevelInfo::maximumLevel());
+ if (level != m_zoomLevel) {
+ m_zoomLevel = level;
+ emit zoomLevelChanged(m_zoomLevel);
+ }
+}
+
+int ViewModeController::zoomLevel() const
+{
+ return m_zoomLevel;
+}
+
+void ViewModeController::setUrl(const KUrl& url)
+{
+ if (m_url != url) {
+ m_url = url;
+ emit cancelPreviews();
+ emit urlChanged(url);
+ }
+}
+
+#include "viewmodecontroller.moc"
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2010 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 VIEWMODECONTROLLER_H
+#define VIEWMODECONTROLLER_H
+
+#include <dolphinview.h>
+#include <kurl.h>
+#include <QObject>
+#include <libdolphin_export.h>
+
+/**
+ * @brief Allows the DolphinView to control the view implementations for the
+ * different view modes.
+ *
+ * The view implementations (DolphinIconsView, DolphinDetailsView, DolphinColumnView)
+ * connect to signals of the ViewModeController to react on changes. The view
+ * implementations get only read-access to the ViewModeController.
+ */
+class LIBDOLPHINPRIVATE_EXPORT ViewModeController : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit ViewModeController(QObject* parent = 0);
+ virtual ~ViewModeController();
+
+ /**
+ * @return URL that is shown by the view mode implementation.
+ */
+ KUrl url() const;
+
+ /**
+ * Sets the URL to \a url and does nothing else. Called when
+ * a redirection happens. See ViewModeController::setUrl()
+ */
+ void redirectToUrl(const KUrl& url);
+
+ /**
+ * Informs the view mode implementation about a change of the activation
+ * state by emitting the signal activationChanged().
+ */
+ void indicateActivationChange(bool active);
+
+ /**
+ * Sets the zoom level to \a level and emits the signal zoomLevelChanged().
+ * It must be assured that the used level is inside the range
+ * ViewModeController::zoomLevelMinimum() and
+ * ViewModeController::zoomLevelMaximum().
+ */
+ void setZoomLevel(int level);
+ int zoomLevel() const;
+
+ /**
+ * Sets the name filter to \a and emits the signal nameFilterChanged().
+ */
+ void setNameFilter(const QString& nameFilter);
+ QString nameFilter() const;
+
+ /**
+ * Requests the view mode implementation to hide tooltips.
+ */
+ void requestToolTipHiding();
+
+public slots:
+ /**
+ * Sets the URL to \a url and emits the signals cancelPreviews() and
+ * urlChanged() if \a url is different for the current URL.
+ */
+ void setUrl(const KUrl& url);
+
+signals:
+ /**
+ * Is emitted if the URL has been changed by ViewModeController::setUrl().
+ */
+ void urlChanged(const KUrl& url);
+
+ /**
+ * Is emitted, if ViewModeController::indicateActivationChange() has been
+ * invoked. The view mode implementation may update its visual state
+ * to represent the activation state.
+ */
+ void activationChanged(bool active);
+
+ /**
+ * Is emitted if the name filter has been changed by
+ * ViewModeController::setNameFilter().
+ */
+ void nameFilterChanged(const QString& nameFilter);
+
+ /**
+ * Is emitted if the zoom level has been changed by
+ * ViewModeController::setZoomLevel().
+ */
+ void zoomLevelChanged(int level);
+
+ /**
+ * Is emitted if pending previews should be canceled (e. g. because of an URL change).
+ */
+ void cancelPreviews();
+
+private:
+ int m_zoomLevel;
+ QString m_nameFilter;
+ KUrl m_url;
+};
+
+#endif