mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Split the class DolphinController into the two classes DolphinViewController and ViewModeController.
The ViewModeController offers a defined interface to control view mode implementations like icons view, details view and column view. The DolphinViewController allows those view mode implementations to control the parent DolphinView in a limited way. svn path=/trunk/KDE/kdebase/apps/; revision=1109228
This commit is contained in:
parent
25ffe18e65
commit
47d3113922
20 changed files with 583 additions and 459 deletions
|
@ -16,7 +16,6 @@ endif (Nepomuk_FOUND)
|
||||||
########### next target ###############
|
########### next target ###############
|
||||||
|
|
||||||
set(dolphinprivate_LIB_SRCS
|
set(dolphinprivate_LIB_SRCS
|
||||||
dolphincontroller.cpp
|
|
||||||
dolphindetailsview.cpp
|
dolphindetailsview.cpp
|
||||||
dolphiniconsview.cpp
|
dolphiniconsview.cpp
|
||||||
dolphincolumnview.cpp
|
dolphincolumnview.cpp
|
||||||
|
@ -30,6 +29,7 @@ set(dolphinprivate_LIB_SRCS
|
||||||
dolphinview.cpp
|
dolphinview.cpp
|
||||||
dolphinviewactionhandler.cpp
|
dolphinviewactionhandler.cpp
|
||||||
dolphinviewautoscroller.cpp
|
dolphinviewautoscroller.cpp
|
||||||
|
dolphinviewcontroller.cpp
|
||||||
dolphinremoteencoding.cpp
|
dolphinremoteencoding.cpp
|
||||||
dolphindetailsviewexpander.cpp
|
dolphindetailsviewexpander.cpp
|
||||||
draganddrophelper.cpp
|
draganddrophelper.cpp
|
||||||
|
@ -49,6 +49,7 @@ set(dolphinprivate_LIB_SRCS
|
||||||
versioncontrol/updateitemstatesthread.cpp
|
versioncontrol/updateitemstatesthread.cpp
|
||||||
versioncontrol/versioncontrolobserver.cpp
|
versioncontrol/versioncontrolobserver.cpp
|
||||||
viewextensionsfactory.cpp
|
viewextensionsfactory.cpp
|
||||||
|
viewmodecontroller.cpp
|
||||||
viewproperties.cpp
|
viewproperties.cpp
|
||||||
zoomlevelinfo.cpp
|
zoomlevelinfo.cpp
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include "dolphinmodel.h"
|
#include "dolphinmodel.h"
|
||||||
#include "dolphincolumnviewcontainer.h"
|
#include "dolphincolumnviewcontainer.h"
|
||||||
#include "dolphincontroller.h"
|
#include "dolphinviewcontroller.h"
|
||||||
#include "dolphindirlister.h"
|
#include "dolphindirlister.h"
|
||||||
#include "dolphinsortfilterproxymodel.h"
|
#include "dolphinsortfilterproxymodel.h"
|
||||||
#include "settings/dolphinsettings.h"
|
#include "settings/dolphinsettings.h"
|
||||||
|
@ -32,6 +32,7 @@
|
||||||
#include "folderexpander.h"
|
#include "folderexpander.h"
|
||||||
#include "tooltips/tooltipmanager.h"
|
#include "tooltips/tooltipmanager.h"
|
||||||
#include "viewextensionsfactory.h"
|
#include "viewextensionsfactory.h"
|
||||||
|
#include "viewmodecontroller.h"
|
||||||
#include "zoomlevelinfo.h"
|
#include "zoomlevelinfo.h"
|
||||||
|
|
||||||
#include <kcolorscheme.h>
|
#include <kcolorscheme.h>
|
||||||
|
@ -92,11 +93,11 @@ DolphinColumnView::DolphinColumnView(QWidget* parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(this, SIGNAL(viewportEntered()),
|
connect(this, SIGNAL(viewportEntered()),
|
||||||
m_container->m_controller, SLOT(emitViewportEntered()));
|
m_container->m_dolphinViewController, SLOT(emitViewportEntered()));
|
||||||
connect(this, SIGNAL(entered(const QModelIndex&)),
|
connect(this, SIGNAL(entered(const QModelIndex&)),
|
||||||
this, SLOT(slotEntered(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()),
|
connect(dolphinView, SIGNAL(showPreviewChanged()),
|
||||||
this, SLOT(slotShowPreviewChanged()));
|
this, SLOT(slotShowPreviewChanged()));
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ DolphinColumnView::DolphinColumnView(QWidget* parent,
|
||||||
m_dirLister->setAutoUpdate(true);
|
m_dirLister->setAutoUpdate(true);
|
||||||
m_dirLister->setMainWindow(window());
|
m_dirLister->setMainWindow(window());
|
||||||
m_dirLister->setDelayedMimeTypes(true);
|
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_dirLister->setShowingDotFiles(showHiddenFiles);
|
||||||
|
|
||||||
m_dolphinModel = new DolphinModel(this);
|
m_dolphinModel = new DolphinModel(this);
|
||||||
|
@ -124,18 +125,19 @@ DolphinColumnView::DolphinColumnView(QWidget* parent,
|
||||||
connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
|
connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
|
||||||
this, SLOT(updateFont()));
|
this, SLOT(updateFont()));
|
||||||
|
|
||||||
DolphinController* controller = m_container->m_controller;
|
DolphinViewController* dolphinViewController = m_container->m_dolphinViewController;
|
||||||
connect(controller, SIGNAL(zoomLevelChanged(int)),
|
connect(dolphinViewController, SIGNAL(zoomLevelChanged(int)),
|
||||||
this, SLOT(setZoomLevel(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()) {
|
if (!nameFilter.isEmpty()) {
|
||||||
m_proxyModel->setFilterFixedString(nameFilter);
|
m_proxyModel->setFilterFixedString(nameFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDecorationSize(dolphinView->showPreview());
|
updateDecorationSize(dolphinView->showPreview());
|
||||||
updateBackground();
|
updateBackground();
|
||||||
m_extensionsFactory = new ViewExtensionsFactory(this, controller);
|
m_extensionsFactory = new ViewExtensionsFactory(this, dolphinViewController, viewModeController);
|
||||||
|
|
||||||
m_dirLister->openUrl(url, KDirLister::NoFlags);
|
m_dirLister->openUrl(url, KDirLister::NoFlags);
|
||||||
}
|
}
|
||||||
|
@ -222,7 +224,7 @@ QStyleOptionViewItem DolphinColumnView::viewOptions() const
|
||||||
|
|
||||||
void DolphinColumnView::startDrag(Qt::DropActions supportedActions)
|
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)
|
void DolphinColumnView::dragEnterEvent(QDragEnterEvent* event)
|
||||||
|
@ -249,8 +251,8 @@ void DolphinColumnView::dragMoveEvent(QDragMoveEvent* event)
|
||||||
|
|
||||||
m_dropRect.setSize(QSize()); // set as invalid
|
m_dropRect.setSize(QSize()); // set as invalid
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
m_container->m_controller->setItemView(this);
|
m_container->m_dolphinViewController->setItemView(this);
|
||||||
const KFileItem item = m_container->m_controller->itemForIndex(index);
|
const KFileItem item = m_container->m_dolphinViewController->itemForIndex(index);
|
||||||
if (!item.isNull() && item.isDir()) {
|
if (!item.isNull() && item.isDir()) {
|
||||||
m_dropRect = visualRect(index);
|
m_dropRect = visualRect(index);
|
||||||
}
|
}
|
||||||
|
@ -266,9 +268,9 @@ void DolphinColumnView::dragMoveEvent(QDragMoveEvent* event)
|
||||||
void DolphinColumnView::dropEvent(QDropEvent* event)
|
void DolphinColumnView::dropEvent(QDropEvent* event)
|
||||||
{
|
{
|
||||||
const QModelIndex index = indexAt(event->pos());
|
const QModelIndex index = indexAt(event->pos());
|
||||||
m_container->m_controller->setItemView(this);
|
m_container->m_dolphinViewController->setItemView(this);
|
||||||
const KFileItem item = m_container->m_controller->itemForIndex(index);
|
const KFileItem item = m_container->m_dolphinViewController->itemForIndex(index);
|
||||||
m_container->m_controller->indicateDroppedUrls(item, url(), event);
|
m_container->m_dolphinViewController->indicateDroppedUrls(item, url(), event);
|
||||||
QListView::dropEvent(event);
|
QListView::dropEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +299,7 @@ void DolphinColumnView::mousePressEvent(QMouseEvent* event)
|
||||||
requestActivation();
|
requestActivation();
|
||||||
if (!indexAt(event->pos()).isValid()) {
|
if (!indexAt(event->pos()).isValid()) {
|
||||||
if (QApplication::mouseButtons() & Qt::MidButton) {
|
if (QApplication::mouseButtons() & Qt::MidButton) {
|
||||||
m_container->m_controller->replaceUrlByClipboard();
|
m_container->m_dolphinViewController->replaceUrlByClipboard();
|
||||||
}
|
}
|
||||||
} else if (event->button() == Qt::LeftButton) {
|
} else if (event->button() == Qt::LeftButton) {
|
||||||
// TODO: see comment in DolphinIconsView::mousePressEvent()
|
// TODO: see comment in DolphinIconsView::mousePressEvent()
|
||||||
|
@ -311,7 +313,7 @@ void DolphinColumnView::keyPressEvent(QKeyEvent* event)
|
||||||
QListView::keyPressEvent(event);
|
QListView::keyPressEvent(event);
|
||||||
requestActivation();
|
requestActivation();
|
||||||
|
|
||||||
DolphinController* controller = m_container->m_controller;
|
DolphinViewController* controller = m_container->m_dolphinViewController;
|
||||||
controller->handleKeyPressEvent(event);
|
controller->handleKeyPressEvent(event);
|
||||||
switch (event->key()) {
|
switch (event->key()) {
|
||||||
case Qt::Key_Right: {
|
case Qt::Key_Right: {
|
||||||
|
@ -340,7 +342,7 @@ void DolphinColumnView::contextMenuEvent(QContextMenuEvent* event)
|
||||||
{
|
{
|
||||||
requestActivation();
|
requestActivation();
|
||||||
QListView::contextMenuEvent(event);
|
QListView::contextMenuEvent(event);
|
||||||
m_container->m_controller->triggerContextMenuRequest(event->pos());
|
m_container->m_dolphinViewController->triggerContextMenuRequest(event->pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinColumnView::wheelEvent(QWheelEvent* event)
|
void DolphinColumnView::wheelEvent(QWheelEvent* event)
|
||||||
|
@ -356,7 +358,7 @@ void DolphinColumnView::leaveEvent(QEvent* event)
|
||||||
// if the mouse is above an item and moved very fast outside the widget,
|
// 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
|
// no viewportEntered() signal might be emitted although the mouse has been moved
|
||||||
// above the viewport
|
// above the viewport
|
||||||
m_container->m_controller->emitViewportEntered();
|
m_container->m_dolphinViewController->emitViewportEntered();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinColumnView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
|
void DolphinColumnView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||||
|
@ -370,7 +372,7 @@ void DolphinColumnView::setZoomLevel(int level)
|
||||||
const int size = ZoomLevelInfo::iconSizeForZoomLevel(level);
|
const int size = ZoomLevelInfo::iconSizeForZoomLevel(level);
|
||||||
ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
|
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) {
|
if (showPreview) {
|
||||||
settings->setPreviewSize(size);
|
settings->setPreviewSize(size);
|
||||||
} else {
|
} else {
|
||||||
|
@ -382,13 +384,13 @@ void DolphinColumnView::setZoomLevel(int level)
|
||||||
|
|
||||||
void DolphinColumnView::slotEntered(const QModelIndex& index)
|
void DolphinColumnView::slotEntered(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
m_container->m_controller->setItemView(this);
|
m_container->m_dolphinViewController->setItemView(this);
|
||||||
m_container->m_controller->emitItemEntered(index);
|
m_container->m_dolphinViewController->emitItemEntered(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinColumnView::requestActivation()
|
void DolphinColumnView::requestActivation()
|
||||||
{
|
{
|
||||||
m_container->m_controller->requestActivation();
|
m_container->m_dolphinViewController->requestActivation();
|
||||||
if (!m_active) {
|
if (!m_active) {
|
||||||
m_container->requestActivation(this);
|
m_container->requestActivation(this);
|
||||||
selectionModel()->clear();
|
selectionModel()->clear();
|
||||||
|
@ -407,7 +409,7 @@ void DolphinColumnView::updateFont()
|
||||||
|
|
||||||
void DolphinColumnView::slotShowPreviewChanged()
|
void DolphinColumnView::slotShowPreviewChanged()
|
||||||
{
|
{
|
||||||
const DolphinView* view = m_container->m_controller->dolphinView();
|
const DolphinView* view = m_container->m_dolphinViewController->view();
|
||||||
updateDecorationSize(view->showPreview());
|
updateDecorationSize(view->showPreview());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,10 +419,10 @@ void DolphinColumnView::activate()
|
||||||
|
|
||||||
if (KGlobalSettings::singleClick()) {
|
if (KGlobalSettings::singleClick()) {
|
||||||
connect(this, SIGNAL(clicked(const QModelIndex&)),
|
connect(this, SIGNAL(clicked(const QModelIndex&)),
|
||||||
m_container->m_controller, SLOT(triggerItem(const QModelIndex&)));
|
m_container->m_dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
|
||||||
} else {
|
} else {
|
||||||
connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
|
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()) {
|
if (selectionModel() && selectionModel()->currentIndex().isValid()) {
|
||||||
|
@ -435,10 +437,10 @@ void DolphinColumnView::deactivate()
|
||||||
clearFocus();
|
clearFocus();
|
||||||
if (KGlobalSettings::singleClick()) {
|
if (KGlobalSettings::singleClick()) {
|
||||||
disconnect(this, SIGNAL(clicked(const QModelIndex&)),
|
disconnect(this, SIGNAL(clicked(const QModelIndex&)),
|
||||||
m_container->m_controller, SLOT(triggerItem(const QModelIndex&)));
|
m_container->m_dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
|
||||||
} else {
|
} else {
|
||||||
disconnect(this, SIGNAL(doubleClicked(const QModelIndex&)),
|
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();
|
const QModelIndex current = selectionModel()->currentIndex();
|
||||||
|
|
|
@ -19,13 +19,14 @@
|
||||||
|
|
||||||
#include "dolphincolumnviewcontainer.h"
|
#include "dolphincolumnviewcontainer.h"
|
||||||
|
|
||||||
|
#include "dolphin_columnmodesettings.h"
|
||||||
|
|
||||||
#include "dolphincolumnview.h"
|
#include "dolphincolumnview.h"
|
||||||
#include "dolphincontroller.h"
|
#include "dolphinviewcontroller.h"
|
||||||
#include "dolphinsortfilterproxymodel.h"
|
#include "dolphinsortfilterproxymodel.h"
|
||||||
#include "draganddrophelper.h"
|
#include "draganddrophelper.h"
|
||||||
#include "settings/dolphinsettings.h"
|
#include "settings/dolphinsettings.h"
|
||||||
|
#include "viewmodecontroller.h"
|
||||||
#include "dolphin_columnmodesettings.h"
|
|
||||||
|
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
@ -33,9 +34,11 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
|
DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
|
||||||
DolphinController* controller) :
|
DolphinViewController* dolphinViewController,
|
||||||
|
const ViewModeController* viewModeController) :
|
||||||
QScrollArea(parent),
|
QScrollArea(parent),
|
||||||
m_controller(controller),
|
m_dolphinViewController(dolphinViewController),
|
||||||
|
m_viewModeController(viewModeController),
|
||||||
m_active(false),
|
m_active(false),
|
||||||
m_index(-1),
|
m_index(-1),
|
||||||
m_contentX(0),
|
m_contentX(0),
|
||||||
|
@ -45,14 +48,15 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
|
||||||
m_dragSource(0),
|
m_dragSource(0),
|
||||||
m_activeUrlTimer(0)
|
m_activeUrlTimer(0)
|
||||||
{
|
{
|
||||||
Q_ASSERT(controller != 0);
|
Q_ASSERT(dolphinViewController != 0);
|
||||||
|
Q_ASSERT(viewModeController != 0);
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
setFrameShape(QFrame::NoFrame);
|
setFrameShape(QFrame::NoFrame);
|
||||||
setLayoutDirection(Qt::LeftToRight);
|
setLayoutDirection(Qt::LeftToRight);
|
||||||
|
|
||||||
connect(controller, SIGNAL(activationChanged(bool)),
|
connect(viewModeController, SIGNAL(activationChanged(bool)),
|
||||||
this, SLOT(updateColumnsBackground(bool)));
|
this, SLOT(updateColumnsBackground(bool)));
|
||||||
|
|
||||||
connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
|
connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
|
||||||
|
@ -67,7 +71,7 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
|
||||||
connect(m_activeUrlTimer, SIGNAL(timeout()),
|
connect(m_activeUrlTimer, SIGNAL(timeout()),
|
||||||
this, SLOT(updateActiveUrl()));
|
this, SLOT(updateActiveUrl()));
|
||||||
|
|
||||||
DolphinColumnView* column = new DolphinColumnView(viewport(), this, m_controller->url());
|
DolphinColumnView* column = new DolphinColumnView(viewport(), this, viewModeController->url());
|
||||||
m_columns.append(column);
|
m_columns.append(column);
|
||||||
setActiveColumnIndex(0);
|
setActiveColumnIndex(0);
|
||||||
|
|
||||||
|
@ -181,7 +185,7 @@ void DolphinColumnViewContainer::showColumn(const KUrl& url)
|
||||||
|
|
||||||
void DolphinColumnViewContainer::mousePressEvent(QMouseEvent* event)
|
void DolphinColumnViewContainer::mousePressEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
m_controller->requestActivation();
|
m_dolphinViewController->requestActivation();
|
||||||
QScrollArea::mousePressEvent(event);
|
QScrollArea::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +247,7 @@ void DolphinColumnViewContainer::updateColumnsBackground(bool active)
|
||||||
void DolphinColumnViewContainer::updateActiveUrl()
|
void DolphinColumnViewContainer::updateActiveUrl()
|
||||||
{
|
{
|
||||||
const KUrl activeUrl = m_columns[m_index]->url();
|
const KUrl activeUrl = m_columns[m_index]->url();
|
||||||
m_controller->setUrl(activeUrl);
|
m_dolphinViewController->requestUrlChange(activeUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinColumnViewContainer::setActiveColumnIndex(int index)
|
void DolphinColumnViewContainer::setActiveColumnIndex(int index)
|
||||||
|
@ -338,7 +342,7 @@ void DolphinColumnViewContainer::assureVisibleActiveColumn()
|
||||||
|
|
||||||
void DolphinColumnViewContainer::requestActivation(DolphinColumnView* column)
|
void DolphinColumnViewContainer::requestActivation(DolphinColumnView* column)
|
||||||
{
|
{
|
||||||
m_controller->setItemView(column);
|
m_dolphinViewController->setItemView(column);
|
||||||
if (column->isActive()) {
|
if (column->isActive()) {
|
||||||
assureVisibleActiveColumn();
|
assureVisibleActiveColumn();
|
||||||
} else {
|
} else {
|
||||||
|
@ -378,8 +382,8 @@ void DolphinColumnViewContainer::deleteColumn(DolphinColumnView* column)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_controller->itemView() == column) {
|
if (m_dolphinViewController->itemView() == column) {
|
||||||
m_controller->setItemView(0);
|
m_dolphinViewController->setItemView(0);
|
||||||
}
|
}
|
||||||
// deleteWhenNotDragSource(column) does not necessarily delete column,
|
// deleteWhenNotDragSource(column) does not necessarily delete column,
|
||||||
// and we want its preview generator destroyed immediately.
|
// and we want its preview generator destroyed immediately.
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class DolphinColumnView;
|
class DolphinColumnView;
|
||||||
class DolphinController;
|
class DolphinViewController;
|
||||||
class QFrame;
|
class QFrame;
|
||||||
class QTimeLine;
|
class QTimeLine;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
@ -45,8 +45,18 @@ class DolphinColumnViewContainer : public QScrollArea
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
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,
|
explicit DolphinColumnViewContainer(QWidget* parent,
|
||||||
DolphinController* controller);
|
DolphinViewController* dolphinViewController,
|
||||||
|
const ViewModeController* viewModeController);
|
||||||
virtual ~DolphinColumnViewContainer();
|
virtual ~DolphinColumnViewContainer();
|
||||||
|
|
||||||
KUrl rootUrl() const;
|
KUrl rootUrl() const;
|
||||||
|
@ -127,7 +137,8 @@ private:
|
||||||
void deleteColumn(DolphinColumnView* column);
|
void deleteColumn(DolphinColumnView* column);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DolphinController* m_controller;
|
DolphinViewController* m_dolphinViewController;
|
||||||
|
const ViewModeController* m_viewModeController;
|
||||||
bool m_active;
|
bool m_active;
|
||||||
int m_index;
|
int m_index;
|
||||||
int m_contentX;
|
int m_contentX;
|
||||||
|
|
|
@ -21,13 +21,14 @@
|
||||||
#include "dolphindetailsview.h"
|
#include "dolphindetailsview.h"
|
||||||
|
|
||||||
#include "dolphinmodel.h"
|
#include "dolphinmodel.h"
|
||||||
#include "dolphincontroller.h"
|
#include "dolphinviewcontroller.h"
|
||||||
#include "dolphinfileitemdelegate.h"
|
#include "dolphinfileitemdelegate.h"
|
||||||
#include "settings/dolphinsettings.h"
|
#include "settings/dolphinsettings.h"
|
||||||
#include "dolphinsortfilterproxymodel.h"
|
#include "dolphinsortfilterproxymodel.h"
|
||||||
#include "dolphinviewautoscroller.h"
|
#include "dolphinviewautoscroller.h"
|
||||||
#include "draganddrophelper.h"
|
#include "draganddrophelper.h"
|
||||||
#include "viewextensionsfactory.h"
|
#include "viewextensionsfactory.h"
|
||||||
|
#include "viewmodecontroller.h"
|
||||||
#include "viewproperties.h"
|
#include "viewproperties.h"
|
||||||
#include "zoomlevelinfo.h"
|
#include "zoomlevelinfo.h"
|
||||||
|
|
||||||
|
@ -46,7 +47,8 @@
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
|
||||||
DolphinDetailsView::DolphinDetailsView(QWidget* parent,
|
DolphinDetailsView::DolphinDetailsView(QWidget* parent,
|
||||||
DolphinController* controller,
|
DolphinViewController* dolphinViewController,
|
||||||
|
const ViewModeController* viewModeController,
|
||||||
DolphinSortFilterProxyModel* proxyModel) :
|
DolphinSortFilterProxyModel* proxyModel) :
|
||||||
QTreeView(parent),
|
QTreeView(parent),
|
||||||
m_autoResize(true),
|
m_autoResize(true),
|
||||||
|
@ -54,7 +56,8 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent,
|
||||||
m_keyPressed(false),
|
m_keyPressed(false),
|
||||||
m_useDefaultIndexAt(true),
|
m_useDefaultIndexAt(true),
|
||||||
m_ignoreScrollTo(false),
|
m_ignoreScrollTo(false),
|
||||||
m_controller(controller),
|
m_dolphinViewController(dolphinViewController),
|
||||||
|
m_viewModeController(viewModeController),
|
||||||
m_extensionsFactory(0),
|
m_extensionsFactory(0),
|
||||||
m_expandableFoldersAction(0),
|
m_expandableFoldersAction(0),
|
||||||
m_expandedUrls(),
|
m_expandedUrls(),
|
||||||
|
@ -64,7 +67,8 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent,
|
||||||
{
|
{
|
||||||
const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
||||||
Q_ASSERT(settings != 0);
|
Q_ASSERT(settings != 0);
|
||||||
Q_ASSERT(controller != 0);
|
Q_ASSERT(dolphinViewController != 0);
|
||||||
|
Q_ASSERT(viewModeController != 0);
|
||||||
|
|
||||||
setLayoutDirection(Qt::LeftToRight);
|
setLayoutDirection(Qt::LeftToRight);
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
@ -81,7 +85,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent,
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
const ViewProperties props(controller->url());
|
const ViewProperties props(viewModeController->url());
|
||||||
setSortIndicatorSection(props.sorting());
|
setSortIndicatorSection(props.sorting());
|
||||||
setSortIndicatorOrder(props.sortOrder());
|
setSortIndicatorOrder(props.sortOrder());
|
||||||
|
|
||||||
|
@ -102,24 +106,24 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent,
|
||||||
this, SLOT(setSortIndicatorOrder(Qt::SortOrder)));
|
this, SLOT(setSortIndicatorOrder(Qt::SortOrder)));
|
||||||
|
|
||||||
connect(this, SIGNAL(clicked(const QModelIndex&)),
|
connect(this, SIGNAL(clicked(const QModelIndex&)),
|
||||||
controller, SLOT(requestTab(const QModelIndex&)));
|
dolphinViewController, SLOT(requestTab(const QModelIndex&)));
|
||||||
if (KGlobalSettings::singleClick()) {
|
if (KGlobalSettings::singleClick()) {
|
||||||
connect(this, SIGNAL(clicked(const QModelIndex&)),
|
connect(this, SIGNAL(clicked(const QModelIndex&)),
|
||||||
controller, SLOT(triggerItem(const QModelIndex&)));
|
dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
|
||||||
} else {
|
} else {
|
||||||
connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
|
connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
|
||||||
controller, SLOT(triggerItem(const QModelIndex&)));
|
dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(this, SIGNAL(entered(const QModelIndex&)),
|
connect(this, SIGNAL(entered(const QModelIndex&)),
|
||||||
this, SLOT(slotEntered(const QModelIndex&)));
|
this, SLOT(slotEntered(const QModelIndex&)));
|
||||||
connect(this, SIGNAL(viewportEntered()),
|
connect(this, SIGNAL(viewportEntered()),
|
||||||
controller, SLOT(emitViewportEntered()));
|
dolphinViewController, SLOT(emitViewportEntered()));
|
||||||
connect(controller, SIGNAL(zoomLevelChanged(int)),
|
connect(viewModeController, SIGNAL(zoomLevelChanged(int)),
|
||||||
this, SLOT(setZoomLevel(int)));
|
this, SLOT(setZoomLevel(int)));
|
||||||
connect(controller->dolphinView(), SIGNAL(additionalInfoChanged()),
|
connect(dolphinViewController->view(), SIGNAL(additionalInfoChanged()),
|
||||||
this, SLOT(updateColumnVisibility()));
|
this, SLOT(updateColumnVisibility()));
|
||||||
connect(controller, SIGNAL(activationChanged(bool)),
|
connect(viewModeController, SIGNAL(activationChanged(bool)),
|
||||||
this, SLOT(slotActivationChanged(bool)));
|
this, SLOT(slotActivationChanged(bool)));
|
||||||
|
|
||||||
if (settings->useSystemFont()) {
|
if (settings->useSystemFont()) {
|
||||||
|
@ -135,7 +139,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent,
|
||||||
setVerticalScrollMode(QTreeView::ScrollPerPixel);
|
setVerticalScrollMode(QTreeView::ScrollPerPixel);
|
||||||
setHorizontalScrollMode(QTreeView::ScrollPerPixel);
|
setHorizontalScrollMode(QTreeView::ScrollPerPixel);
|
||||||
|
|
||||||
const DolphinView* view = controller->dolphinView();
|
const DolphinView* view = dolphinViewController->view();
|
||||||
connect(view, SIGNAL(showPreviewChanged()),
|
connect(view, SIGNAL(showPreviewChanged()),
|
||||||
this, SLOT(slotShowPreviewChanged()));
|
this, SLOT(slotShowPreviewChanged()));
|
||||||
|
|
||||||
|
@ -158,7 +162,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent,
|
||||||
|
|
||||||
updateDecorationSize(view->showPreview());
|
updateDecorationSize(view->showPreview());
|
||||||
|
|
||||||
m_extensionsFactory = new ViewExtensionsFactory(this, controller);
|
m_extensionsFactory = new ViewExtensionsFactory(this, dolphinViewController, viewModeController);
|
||||||
m_extensionsFactory->fileItemDelegate()->setMinimizedNameColumn(true);
|
m_extensionsFactory->fileItemDelegate()->setMinimizedNameColumn(true);
|
||||||
m_extensionsFactory->setAutoFolderExpandingEnabled(settings->expandableFolders());
|
m_extensionsFactory->setAutoFolderExpandingEnabled(settings->expandableFolders());
|
||||||
}
|
}
|
||||||
|
@ -225,13 +229,13 @@ void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event)
|
||||||
|
|
||||||
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
||||||
m_expandableFoldersAction->setChecked(settings->expandableFolders());
|
m_expandableFoldersAction->setChecked(settings->expandableFolders());
|
||||||
m_controller->triggerContextMenuRequest(event->pos(),
|
m_dolphinViewController->triggerContextMenuRequest(event->pos(),
|
||||||
QList<QAction*>() << m_expandableFoldersAction);
|
QList<QAction*>() << m_expandableFoldersAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
|
void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
m_controller->requestActivation();
|
m_dolphinViewController->requestActivation();
|
||||||
|
|
||||||
const QModelIndex current = currentIndex();
|
const QModelIndex current = currentIndex();
|
||||||
QTreeView::mousePressEvent(event);
|
QTreeView::mousePressEvent(event);
|
||||||
|
@ -249,7 +253,7 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
|
||||||
if (!index.isValid() || (index.column() != DolphinModel::Name)) {
|
if (!index.isValid() || (index.column() != DolphinModel::Name)) {
|
||||||
// the mouse press is done somewhere outside the filename column
|
// the mouse press is done somewhere outside the filename column
|
||||||
if (QApplication::mouseButtons() & Qt::MidButton) {
|
if (QApplication::mouseButtons() & Qt::MidButton) {
|
||||||
m_controller->replaceUrlByClipboard();
|
m_dolphinViewController->replaceUrlByClipboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Qt::KeyboardModifiers mod = QApplication::keyboardModifiers();
|
const Qt::KeyboardModifiers mod = QApplication::keyboardModifiers();
|
||||||
|
@ -336,7 +340,7 @@ void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event)
|
||||||
|
|
||||||
void DolphinDetailsView::startDrag(Qt::DropActions supportedActions)
|
void DolphinDetailsView::startDrag(Qt::DropActions supportedActions)
|
||||||
{
|
{
|
||||||
DragAndDropHelper::instance().startDrag(this, supportedActions, m_controller);
|
DragAndDropHelper::instance().startDrag(this, supportedActions, m_dolphinViewController);
|
||||||
m_band.show = false;
|
m_band.show = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +370,7 @@ void DolphinDetailsView::dragMoveEvent(QDragMoveEvent* event)
|
||||||
setDirtyRegion(m_dropRect);
|
setDirtyRegion(m_dropRect);
|
||||||
const QModelIndex index = indexAt(event->pos());
|
const QModelIndex index = indexAt(event->pos());
|
||||||
if (index.isValid() && (index.column() == DolphinModel::Name)) {
|
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()) {
|
if (!item.isNull() && item.isDir()) {
|
||||||
m_dropRect = visualRect(index);
|
m_dropRect = visualRect(index);
|
||||||
} else {
|
} else {
|
||||||
|
@ -386,9 +390,9 @@ void DolphinDetailsView::dropEvent(QDropEvent* event)
|
||||||
const QModelIndex index = indexAt(event->pos());
|
const QModelIndex index = indexAt(event->pos());
|
||||||
KFileItem item;
|
KFileItem item;
|
||||||
if (index.isValid() && (index.column() == DolphinModel::Name)) {
|
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);
|
QTreeView::dropEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,7 +424,7 @@ void DolphinDetailsView::keyPressEvent(QKeyEvent* event)
|
||||||
m_keyPressed = !(event->modifiers() & Qt::ControlModifier);
|
m_keyPressed = !(event->modifiers() & Qt::ControlModifier);
|
||||||
|
|
||||||
QTreeView::keyPressEvent(event);
|
QTreeView::keyPressEvent(event);
|
||||||
m_controller->handleKeyPressEvent(event);
|
m_dolphinViewController->handleKeyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinDetailsView::keyReleaseEvent(QKeyEvent* event)
|
void DolphinDetailsView::keyReleaseEvent(QKeyEvent* event)
|
||||||
|
@ -466,7 +470,7 @@ bool DolphinDetailsView::eventFilter(QObject* watched, QEvent* event)
|
||||||
// if the mouse is above an item and moved very fast outside the widget,
|
// 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
|
// no viewportEntered() signal might be emitted although the mouse has been moved
|
||||||
// above the viewport
|
// above the viewport
|
||||||
m_controller->emitViewportEntered();
|
m_dolphinViewController->emitViewportEntered();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QTreeView::eventFilter(watched, event);
|
return QTreeView::eventFilter(watched, event);
|
||||||
|
@ -484,7 +488,7 @@ QModelIndex DolphinDetailsView::indexAt(const QPoint& point) const
|
||||||
QRect DolphinDetailsView::visualRect(const QModelIndex& index) const
|
QRect DolphinDetailsView::visualRect(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
QRect rect = QTreeView::visualRect(index);
|
QRect rect = QTreeView::visualRect(index);
|
||||||
const KFileItem item = m_controller->itemForIndex(index);
|
const KFileItem item = m_dolphinViewController->itemForIndex(index);
|
||||||
if (!item.isNull()) {
|
if (!item.isNull()) {
|
||||||
const int width = DolphinFileItemDelegate::nameColumnWidth(item.text(), viewOptions());
|
const int width = DolphinFileItemDelegate::nameColumnWidth(item.text(), viewOptions());
|
||||||
rect.setWidth(width);
|
rect.setWidth(width);
|
||||||
|
@ -530,16 +534,16 @@ void DolphinDetailsView::synchronizeSortingState(int column)
|
||||||
// invoked, but Dolphin is not informed about this.
|
// invoked, but Dolphin is not informed about this.
|
||||||
DolphinView::Sorting sorting = DolphinSortFilterProxyModel::sortingForColumn(column);
|
DolphinView::Sorting sorting = DolphinSortFilterProxyModel::sortingForColumn(column);
|
||||||
const Qt::SortOrder sortOrder = header()->sortIndicatorOrder();
|
const Qt::SortOrder sortOrder = header()->sortIndicatorOrder();
|
||||||
m_controller->indicateSortingChange(sorting);
|
m_dolphinViewController->indicateSortingChange(sorting);
|
||||||
m_controller->indicateSortOrderChange(sortOrder);
|
m_dolphinViewController->indicateSortOrderChange(sortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinDetailsView::slotEntered(const QModelIndex& index)
|
void DolphinDetailsView::slotEntered(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
if (index.column() == DolphinModel::Name) {
|
if (index.column() == DolphinModel::Name) {
|
||||||
m_controller->emitItemEntered(index);
|
m_dolphinViewController->emitItemEntered(index);
|
||||||
} else {
|
} else {
|
||||||
m_controller->emitViewportEntered();
|
m_dolphinViewController->emitViewportEntered();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +580,7 @@ void DolphinDetailsView::setZoomLevel(int level)
|
||||||
const int size = ZoomLevelInfo::iconSizeForZoomLevel(level);
|
const int size = ZoomLevelInfo::iconSizeForZoomLevel(level);
|
||||||
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
||||||
|
|
||||||
const bool showPreview = m_controller->dolphinView()->showPreview();
|
const bool showPreview = m_dolphinViewController->view()->showPreview();
|
||||||
if (showPreview) {
|
if (showPreview) {
|
||||||
settings->setPreviewSize(size);
|
settings->setPreviewSize(size);
|
||||||
} else {
|
} else {
|
||||||
|
@ -588,7 +592,7 @@ void DolphinDetailsView::setZoomLevel(int level)
|
||||||
|
|
||||||
void DolphinDetailsView::slotShowPreviewChanged()
|
void DolphinDetailsView::slotShowPreviewChanged()
|
||||||
{
|
{
|
||||||
const DolphinView* view = m_controller->dolphinView();
|
const DolphinView* view = m_dolphinViewController->view();
|
||||||
updateDecorationSize(view->showPreview());
|
updateDecorationSize(view->showPreview());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,7 +620,7 @@ void DolphinDetailsView::configureSettings(const QPoint& pos)
|
||||||
const bool show = activatedAction->isChecked();
|
const bool show = activatedAction->isChecked();
|
||||||
const int columnIndex = activatedAction->data().toInt();
|
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);
|
const KFileItemDelegate::Information info = infoForColumn(columnIndex);
|
||||||
if (show) {
|
if (show) {
|
||||||
Q_ASSERT(!list.contains(info));
|
Q_ASSERT(!list.contains(info));
|
||||||
|
@ -627,7 +631,7 @@ void DolphinDetailsView::configureSettings(const QPoint& pos)
|
||||||
list.removeAt(index);
|
list.removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_controller->indicateAdditionalInfoChange(list);
|
m_dolphinViewController->indicateAdditionalInfoChange(list);
|
||||||
setColumnHidden(columnIndex, !show);
|
setColumnHidden(columnIndex, !show);
|
||||||
resizeColumns();
|
resizeColumns();
|
||||||
}
|
}
|
||||||
|
@ -642,7 +646,7 @@ void DolphinDetailsView::updateColumnVisibility()
|
||||||
const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
||||||
const QList<int> columnPositions = settings->columnPositions();
|
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) {
|
for (int i = DolphinModel::Name; i <= DolphinModel::Version; ++i) {
|
||||||
const KFileItemDelegate::Information info = infoForColumn(i);
|
const KFileItemDelegate::Information info = infoForColumn(i);
|
||||||
const bool hide = !list.contains(info) && (i != DolphinModel::Name);
|
const bool hide = !list.contains(info) && (i != DolphinModel::Name);
|
||||||
|
@ -701,7 +705,7 @@ void DolphinDetailsView::disableAutoResizing()
|
||||||
|
|
||||||
void DolphinDetailsView::requestActivation()
|
void DolphinDetailsView::requestActivation()
|
||||||
{
|
{
|
||||||
m_controller->requestActivation();
|
m_dolphinViewController->requestActivation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinDetailsView::slotGlobalSettingsChanged(int category)
|
void DolphinDetailsView::slotGlobalSettingsChanged(int category)
|
||||||
|
@ -714,12 +718,12 @@ void DolphinDetailsView::slotGlobalSettingsChanged(int category)
|
||||||
m_font = KGlobalSettings::generalFont();
|
m_font = KGlobalSettings::generalFont();
|
||||||
}
|
}
|
||||||
//Disconnect then reconnect, since the settings have been changed, the connection requirements may have also.
|
//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(clicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
|
||||||
disconnect(this, SIGNAL(doubleClicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
|
disconnect(this, SIGNAL(doubleClicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
|
||||||
if (KGlobalSettings::singleClick()) {
|
if (KGlobalSettings::singleClick()) {
|
||||||
connect(this, SIGNAL(clicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
|
connect(this, SIGNAL(clicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
|
||||||
} else {
|
} else {
|
||||||
connect(this, SIGNAL(doubleClicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
|
connect(this, SIGNAL(doubleClicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -928,7 +932,7 @@ void DolphinDetailsView::setFoldersExpandable(bool expandable)
|
||||||
|
|
||||||
void DolphinDetailsView::slotExpanded(const QModelIndex& index)
|
void DolphinDetailsView::slotExpanded(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
KFileItem item = m_controller->itemForIndex(index);
|
KFileItem item = m_dolphinViewController->itemForIndex(index);
|
||||||
if (!item.isNull()) {
|
if (!item.isNull()) {
|
||||||
m_expandedUrls.insert(item.url());
|
m_expandedUrls.insert(item.url());
|
||||||
}
|
}
|
||||||
|
@ -936,7 +940,7 @@ void DolphinDetailsView::slotExpanded(const QModelIndex& index)
|
||||||
|
|
||||||
void DolphinDetailsView::slotCollapsed(const QModelIndex& index)
|
void DolphinDetailsView::slotCollapsed(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
KFileItem item = m_controller->itemForIndex(index);
|
KFileItem item = m_dolphinViewController->itemForIndex(index);
|
||||||
if (!item.isNull()) {
|
if (!item.isNull()) {
|
||||||
m_expandedUrls.remove(item.url());
|
m_expandedUrls.remove(item.url());
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <libdolphin_export.h>
|
#include <libdolphin_export.h>
|
||||||
|
|
||||||
class DolphinController;
|
class DolphinViewController;
|
||||||
class DolphinSortFilterProxyModel;
|
class DolphinSortFilterProxyModel;
|
||||||
class ViewExtensionsFactory;
|
class ViewExtensionsFactory;
|
||||||
|
|
||||||
|
@ -42,8 +42,18 @@ class LIBDOLPHINPRIVATE_EXPORT DolphinDetailsView : public QTreeView
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
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,
|
explicit DolphinDetailsView(QWidget* parent,
|
||||||
DolphinController* controller,
|
DolphinViewController* dolphinViewController,
|
||||||
|
const ViewModeController* viewModeController,
|
||||||
DolphinSortFilterProxyModel* model);
|
DolphinSortFilterProxyModel* model);
|
||||||
virtual ~DolphinDetailsView();
|
virtual ~DolphinDetailsView();
|
||||||
|
|
||||||
|
@ -226,7 +236,8 @@ private:
|
||||||
bool m_useDefaultIndexAt : 1; // true, if QTreeView::indexAt() should be used
|
bool m_useDefaultIndexAt : 1; // true, if QTreeView::indexAt() should be used
|
||||||
bool m_ignoreScrollTo : 1; // true if calls to scrollTo(...) should do nothing.
|
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;
|
ViewExtensionsFactory* m_extensionsFactory;
|
||||||
QAction* m_expandableFoldersAction;
|
QAction* m_expandableFoldersAction;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "dolphiniconsview.h"
|
#include "dolphiniconsview.h"
|
||||||
|
|
||||||
#include "dolphincategorydrawer.h"
|
#include "dolphincategorydrawer.h"
|
||||||
#include "dolphincontroller.h"
|
#include "dolphinviewcontroller.h"
|
||||||
#include "settings/dolphinsettings.h"
|
#include "settings/dolphinsettings.h"
|
||||||
#include "dolphinsortfilterproxymodel.h"
|
#include "dolphinsortfilterproxymodel.h"
|
||||||
#include "dolphin_iconsmodesettings.h"
|
#include "dolphin_iconsmodesettings.h"
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
#include "draganddrophelper.h"
|
#include "draganddrophelper.h"
|
||||||
#include "selectionmanager.h"
|
#include "selectionmanager.h"
|
||||||
#include "viewextensionsfactory.h"
|
#include "viewextensionsfactory.h"
|
||||||
|
#include "viewmodecontroller.h"
|
||||||
#include "zoomlevelinfo.h"
|
#include "zoomlevelinfo.h"
|
||||||
|
|
||||||
#include <kcategorizedsortfilterproxymodel.h>
|
#include <kcategorizedsortfilterproxymodel.h>
|
||||||
|
@ -39,10 +40,12 @@
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
|
||||||
DolphinIconsView::DolphinIconsView(QWidget* parent,
|
DolphinIconsView::DolphinIconsView(QWidget* parent,
|
||||||
DolphinController* controller,
|
DolphinViewController* dolphinViewController,
|
||||||
|
const ViewModeController* viewModeController,
|
||||||
DolphinSortFilterProxyModel* proxyModel) :
|
DolphinSortFilterProxyModel* proxyModel) :
|
||||||
KCategorizedView(parent),
|
KCategorizedView(parent),
|
||||||
m_controller(controller),
|
m_dolphinViewController(dolphinViewController),
|
||||||
|
m_viewModeController(viewModeController),
|
||||||
m_categoryDrawer(new DolphinCategoryDrawer(this)),
|
m_categoryDrawer(new DolphinCategoryDrawer(this)),
|
||||||
m_extensionsFactory(0),
|
m_extensionsFactory(0),
|
||||||
m_font(),
|
m_font(),
|
||||||
|
@ -52,7 +55,9 @@ DolphinIconsView::DolphinIconsView(QWidget* parent,
|
||||||
m_itemSize(),
|
m_itemSize(),
|
||||||
m_dropRect()
|
m_dropRect()
|
||||||
{
|
{
|
||||||
Q_ASSERT(controller != 0);
|
Q_ASSERT(dolphinViewController != 0);
|
||||||
|
Q_ASSERT(viewModeController != 0);
|
||||||
|
|
||||||
setModel(proxyModel);
|
setModel(proxyModel);
|
||||||
setLayoutDirection(Qt::LeftToRight);
|
setLayoutDirection(Qt::LeftToRight);
|
||||||
setViewMode(QListView::IconMode);
|
setViewMode(QListView::IconMode);
|
||||||
|
@ -65,23 +70,23 @@ DolphinIconsView::DolphinIconsView(QWidget* parent,
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
connect(this, SIGNAL(clicked(const QModelIndex&)),
|
connect(this, SIGNAL(clicked(const QModelIndex&)),
|
||||||
controller, SLOT(requestTab(const QModelIndex&)));
|
dolphinViewController, SLOT(requestTab(const QModelIndex&)));
|
||||||
if (KGlobalSettings::singleClick()) {
|
if (KGlobalSettings::singleClick()) {
|
||||||
connect(this, SIGNAL(clicked(const QModelIndex&)),
|
connect(this, SIGNAL(clicked(const QModelIndex&)),
|
||||||
controller, SLOT(triggerItem(const QModelIndex&)));
|
dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
|
||||||
} else {
|
} else {
|
||||||
connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
|
connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
|
||||||
controller, SLOT(triggerItem(const QModelIndex&)));
|
dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(this, SIGNAL(entered(const QModelIndex&)),
|
connect(this, SIGNAL(entered(const QModelIndex&)),
|
||||||
controller, SLOT(emitItemEntered(const QModelIndex&)));
|
dolphinViewController, SLOT(emitItemEntered(const QModelIndex&)));
|
||||||
connect(this, SIGNAL(viewportEntered()),
|
connect(this, SIGNAL(viewportEntered()),
|
||||||
controller, SLOT(emitViewportEntered()));
|
dolphinViewController, SLOT(emitViewportEntered()));
|
||||||
connect(controller, SIGNAL(zoomLevelChanged(int)),
|
connect(viewModeController, SIGNAL(zoomLevelChanged(int)),
|
||||||
this, SLOT(setZoomLevel(int)));
|
this, SLOT(setZoomLevel(int)));
|
||||||
|
|
||||||
const DolphinView* view = controller->dolphinView();
|
const DolphinView* view = dolphinViewController->view();
|
||||||
connect(view, SIGNAL(showPreviewChanged()),
|
connect(view, SIGNAL(showPreviewChanged()),
|
||||||
this, SLOT(slotShowPreviewChanged()));
|
this, SLOT(slotShowPreviewChanged()));
|
||||||
connect(view, SIGNAL(additionalInfoChanged()),
|
connect(view, SIGNAL(additionalInfoChanged()),
|
||||||
|
@ -122,7 +127,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent,
|
||||||
this, SLOT(slotGlobalSettingsChanged(int)));
|
this, SLOT(slotGlobalSettingsChanged(int)));
|
||||||
|
|
||||||
updateGridSize(view->showPreview(), 0);
|
updateGridSize(view->showPreview(), 0);
|
||||||
m_extensionsFactory = new ViewExtensionsFactory(this, controller);
|
m_extensionsFactory = new ViewExtensionsFactory(this, dolphinViewController, viewModeController);
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinIconsView::~DolphinIconsView()
|
DolphinIconsView::~DolphinIconsView()
|
||||||
|
@ -156,12 +161,12 @@ QStyleOptionViewItem DolphinIconsView::viewOptions() const
|
||||||
void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
|
void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
|
||||||
{
|
{
|
||||||
KCategorizedView::contextMenuEvent(event);
|
KCategorizedView::contextMenuEvent(event);
|
||||||
m_controller->triggerContextMenuRequest(event->pos());
|
m_dolphinViewController->triggerContextMenuRequest(event->pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinIconsView::mousePressEvent(QMouseEvent* event)
|
void DolphinIconsView::mousePressEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
m_controller->requestActivation();
|
m_dolphinViewController->requestActivation();
|
||||||
const QModelIndex index = indexAt(event->pos());
|
const QModelIndex index = indexAt(event->pos());
|
||||||
if (index.isValid() && (event->button() == Qt::LeftButton)) {
|
if (index.isValid() && (event->button() == Qt::LeftButton)) {
|
||||||
// TODO: It should not be necessary to manually set the dragging state, but I could
|
// TODO: It should not be necessary to manually set the dragging state, but I could
|
||||||
|
@ -173,7 +178,7 @@ void DolphinIconsView::mousePressEvent(QMouseEvent* event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!index.isValid() && (QApplication::mouseButtons() & Qt::MidButton)) {
|
if (!index.isValid() && (QApplication::mouseButtons() & Qt::MidButton)) {
|
||||||
m_controller->replaceUrlByClipboard();
|
m_dolphinViewController->replaceUrlByClipboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
KCategorizedView::mousePressEvent(event);
|
KCategorizedView::mousePressEvent(event);
|
||||||
|
@ -181,7 +186,7 @@ void DolphinIconsView::mousePressEvent(QMouseEvent* event)
|
||||||
|
|
||||||
void DolphinIconsView::startDrag(Qt::DropActions supportedActions)
|
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)
|
void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
|
||||||
|
@ -207,7 +212,7 @@ void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
|
||||||
|
|
||||||
m_dropRect.setSize(QSize()); // set as invalid
|
m_dropRect.setSize(QSize()); // set as invalid
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
const KFileItem item = m_controller->itemForIndex(index);
|
const KFileItem item = m_dolphinViewController->itemForIndex(index);
|
||||||
if (!item.isNull() && item.isDir()) {
|
if (!item.isNull() && item.isDir()) {
|
||||||
m_dropRect = visualRect(index);
|
m_dropRect = visualRect(index);
|
||||||
} else {
|
} else {
|
||||||
|
@ -225,8 +230,8 @@ void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
|
||||||
void DolphinIconsView::dropEvent(QDropEvent* event)
|
void DolphinIconsView::dropEvent(QDropEvent* event)
|
||||||
{
|
{
|
||||||
const QModelIndex index = indexAt(event->pos());
|
const QModelIndex index = indexAt(event->pos());
|
||||||
const KFileItem item = m_controller->itemForIndex(index);
|
const KFileItem item = m_dolphinViewController->itemForIndex(index);
|
||||||
m_controller->indicateDroppedUrls(item, m_controller->url(), event);
|
m_dolphinViewController->indicateDroppedUrls(item, m_viewModeController->url(), event);
|
||||||
// don't call KCategorizedView::dropEvent(event), as it moves
|
// don't call KCategorizedView::dropEvent(event), as it moves
|
||||||
// the items which is not wanted
|
// the items which is not wanted
|
||||||
}
|
}
|
||||||
|
@ -307,7 +312,7 @@ QModelIndex DolphinIconsView::moveCursor(CursorAction cursorAction, Qt::Keyboard
|
||||||
void DolphinIconsView::keyPressEvent(QKeyEvent* event)
|
void DolphinIconsView::keyPressEvent(QKeyEvent* event)
|
||||||
{
|
{
|
||||||
KCategorizedView::keyPressEvent(event);
|
KCategorizedView::keyPressEvent(event);
|
||||||
m_controller->handleKeyPressEvent(event);
|
m_dolphinViewController->handleKeyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinIconsView::wheelEvent(QWheelEvent* event)
|
void DolphinIconsView::wheelEvent(QWheelEvent* event)
|
||||||
|
@ -345,7 +350,7 @@ void DolphinIconsView::leaveEvent(QEvent* event)
|
||||||
// if the mouse is above an item and moved very fast outside the widget,
|
// 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
|
// no viewportEntered() signal might be emitted although the mouse has been moved
|
||||||
// above the viewport
|
// above the viewport
|
||||||
m_controller->emitViewportEntered();
|
m_dolphinViewController->emitViewportEntered();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinIconsView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
|
void DolphinIconsView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||||
|
@ -357,19 +362,19 @@ void DolphinIconsView::currentChanged(const QModelIndex& current, const QModelIn
|
||||||
void DolphinIconsView::resizeEvent(QResizeEvent* event)
|
void DolphinIconsView::resizeEvent(QResizeEvent* event)
|
||||||
{
|
{
|
||||||
KCategorizedView::resizeEvent(event);
|
KCategorizedView::resizeEvent(event);
|
||||||
const DolphinView* view = m_controller->dolphinView();
|
const DolphinView* view = m_dolphinViewController->view();
|
||||||
updateGridSize(view->showPreview(), view->additionalInfo().count());
|
updateGridSize(view->showPreview(), view->additionalInfo().count());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinIconsView::slotShowPreviewChanged()
|
void DolphinIconsView::slotShowPreviewChanged()
|
||||||
{
|
{
|
||||||
const DolphinView* view = m_controller->dolphinView();
|
const DolphinView* view = m_dolphinViewController->view();
|
||||||
updateGridSize(view->showPreview(), additionalInfoCount());
|
updateGridSize(view->showPreview(), additionalInfoCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinIconsView::slotAdditionalInfoChanged()
|
void DolphinIconsView::slotAdditionalInfoChanged()
|
||||||
{
|
{
|
||||||
const DolphinView* view = m_controller->dolphinView();
|
const DolphinView* view = m_dolphinViewController->view();
|
||||||
const bool showPreview = view->showPreview();
|
const bool showPreview = view->showPreview();
|
||||||
updateGridSize(showPreview, view->additionalInfo().count());
|
updateGridSize(showPreview, view->additionalInfo().count());
|
||||||
}
|
}
|
||||||
|
@ -381,7 +386,7 @@ void DolphinIconsView::setZoomLevel(int level)
|
||||||
const int oldIconSize = settings->iconSize();
|
const int oldIconSize = settings->iconSize();
|
||||||
int newIconSize = oldIconSize;
|
int newIconSize = oldIconSize;
|
||||||
|
|
||||||
const bool showPreview = m_controller->dolphinView()->showPreview();
|
const bool showPreview = m_dolphinViewController->view()->showPreview();
|
||||||
if (showPreview) {
|
if (showPreview) {
|
||||||
const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(level);
|
const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(level);
|
||||||
settings->setPreviewSize(previewSize);
|
settings->setPreviewSize(previewSize);
|
||||||
|
@ -400,7 +405,7 @@ void DolphinIconsView::setZoomLevel(int level)
|
||||||
|
|
||||||
void DolphinIconsView::requestActivation()
|
void DolphinIconsView::requestActivation()
|
||||||
{
|
{
|
||||||
m_controller->requestActivation();
|
m_dolphinViewController->requestActivation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinIconsView::slotGlobalSettingsChanged(int category)
|
void DolphinIconsView::slotGlobalSettingsChanged(int category)
|
||||||
|
@ -413,12 +418,12 @@ void DolphinIconsView::slotGlobalSettingsChanged(int category)
|
||||||
m_font = KGlobalSettings::generalFont();
|
m_font = KGlobalSettings::generalFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect(this, SIGNAL(clicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
|
disconnect(this, SIGNAL(clicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
|
||||||
disconnect(this, SIGNAL(doubleClicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
|
disconnect(this, SIGNAL(doubleClicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
|
||||||
if (KGlobalSettings::singleClick()) {
|
if (KGlobalSettings::singleClick()) {
|
||||||
connect(this, SIGNAL(clicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
|
connect(this, SIGNAL(clicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
|
||||||
} else {
|
} else {
|
||||||
connect(this, SIGNAL(doubleClicked(QModelIndex)), m_controller, SLOT(triggerItem(QModelIndex)));
|
connect(this, SIGNAL(doubleClicked(QModelIndex)), m_dolphinViewController, SLOT(triggerItem(QModelIndex)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +525,7 @@ void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount)
|
||||||
|
|
||||||
int DolphinIconsView::additionalInfoCount() const
|
int DolphinIconsView::additionalInfoCount() const
|
||||||
{
|
{
|
||||||
const DolphinView* view = m_controller->dolphinView();
|
const DolphinView* view = m_dolphinViewController->view();
|
||||||
return view->additionalInfo().count();
|
return view->additionalInfo().count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,11 @@
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include <libdolphin_export.h>
|
||||||
|
|
||||||
class DolphinController;
|
class DolphinViewController;
|
||||||
class DolphinCategoryDrawer;
|
class DolphinCategoryDrawer;
|
||||||
class DolphinSortFilterProxyModel;
|
class DolphinSortFilterProxyModel;
|
||||||
class ViewExtensionsFactory;
|
class ViewExtensionsFactory;
|
||||||
|
class ViewModeController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Represents the view, where each item is shown as an icon.
|
* @brief Represents the view, where each item is shown as an icon.
|
||||||
|
@ -47,8 +48,18 @@ class LIBDOLPHINPRIVATE_EXPORT DolphinIconsView : public KCategorizedView
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
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,
|
explicit DolphinIconsView(QWidget* parent,
|
||||||
DolphinController* controller,
|
DolphinViewController* dolphinViewController,
|
||||||
|
const ViewModeController* viewModeController,
|
||||||
DolphinSortFilterProxyModel* proxyModel);
|
DolphinSortFilterProxyModel* proxyModel);
|
||||||
virtual ~DolphinIconsView();
|
virtual ~DolphinIconsView();
|
||||||
|
|
||||||
|
@ -94,7 +105,8 @@ private:
|
||||||
int additionalInfoCount() const;
|
int additionalInfoCount() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DolphinController* m_controller;
|
DolphinViewController* m_dolphinViewController;
|
||||||
|
const ViewModeController* m_viewModeController;
|
||||||
DolphinCategoryDrawer* m_categoryDrawer;
|
DolphinCategoryDrawer* m_categoryDrawer;
|
||||||
ViewExtensionsFactory* m_extensionsFactory;
|
ViewExtensionsFactory* m_extensionsFactory;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
#include "dolphinmodel.h"
|
#include "dolphinmodel.h"
|
||||||
#include "dolphincolumnviewcontainer.h"
|
#include "dolphincolumnviewcontainer.h"
|
||||||
#include "dolphincontroller.h"
|
#include "dolphinviewcontroller.h"
|
||||||
#include "dolphindetailsview.h"
|
#include "dolphindetailsview.h"
|
||||||
#include "dolphinfileitemdelegate.h"
|
#include "dolphinfileitemdelegate.h"
|
||||||
#include "dolphinnewmenuobserver.h"
|
#include "dolphinnewmenuobserver.h"
|
||||||
|
@ -62,6 +62,7 @@
|
||||||
#include "draganddrophelper.h"
|
#include "draganddrophelper.h"
|
||||||
#include "renamedialog.h"
|
#include "renamedialog.h"
|
||||||
#include "settings/dolphinsettings.h"
|
#include "settings/dolphinsettings.h"
|
||||||
|
#include "viewmodecontroller.h"
|
||||||
#include "viewproperties.h"
|
#include "viewproperties.h"
|
||||||
#include "zoomlevelinfo.h"
|
#include "zoomlevelinfo.h"
|
||||||
#include "dolphindetailsviewexpander.h"
|
#include "dolphindetailsviewexpander.h"
|
||||||
|
@ -88,7 +89,8 @@ DolphinView::DolphinView(QWidget* parent,
|
||||||
m_assureVisibleCurrentIndex(false),
|
m_assureVisibleCurrentIndex(false),
|
||||||
m_mode(DolphinView::IconsView),
|
m_mode(DolphinView::IconsView),
|
||||||
m_topLayout(0),
|
m_topLayout(0),
|
||||||
m_controller(0),
|
m_dolphinViewController(0),
|
||||||
|
m_viewModeController(0),
|
||||||
m_viewAccessor(proxyModel),
|
m_viewAccessor(proxyModel),
|
||||||
m_selectionModel(0),
|
m_selectionModel(0),
|
||||||
m_selectionChangedTimer(0),
|
m_selectionChangedTimer(0),
|
||||||
|
@ -103,34 +105,38 @@ DolphinView::DolphinView(QWidget* parent,
|
||||||
m_topLayout->setSpacing(0);
|
m_topLayout->setSpacing(0);
|
||||||
m_topLayout->setMargin(0);
|
m_topLayout->setMargin(0);
|
||||||
|
|
||||||
m_controller = new DolphinController(this);
|
m_dolphinViewController = new DolphinViewController(this);
|
||||||
m_controller->setUrl(url);
|
|
||||||
|
|
||||||
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&)));
|
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*>&)));
|
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*)));
|
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)));
|
this, SLOT(updateSorting(DolphinView::Sorting)));
|
||||||
connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
|
connect(m_dolphinViewController, SIGNAL(sortOrderChanged(Qt::SortOrder)),
|
||||||
this, SLOT(updateSortOrder(Qt::SortOrder)));
|
this, SLOT(updateSortOrder(Qt::SortOrder)));
|
||||||
connect(m_controller, SIGNAL(sortFoldersFirstChanged(bool)),
|
connect(m_dolphinViewController, SIGNAL(sortFoldersFirstChanged(bool)),
|
||||||
this, SLOT(updateSortFoldersFirst(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&)));
|
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&)));
|
this, SLOT(triggerItem(const KFileItem&)));
|
||||||
connect(m_controller, SIGNAL(tabRequested(const KUrl&)),
|
connect(m_dolphinViewController, SIGNAL(tabRequested(const KUrl&)),
|
||||||
this, SIGNAL(tabRequested(const KUrl&)));
|
this, SIGNAL(tabRequested(const KUrl&)));
|
||||||
connect(m_controller, SIGNAL(activated()),
|
connect(m_dolphinViewController, SIGNAL(activated()),
|
||||||
this, SLOT(activate()));
|
this, SLOT(activate()));
|
||||||
connect(m_controller, SIGNAL(itemEntered(const KFileItem&)),
|
connect(m_dolphinViewController, SIGNAL(itemEntered(const KFileItem&)),
|
||||||
this, SLOT(showHoverInformation(const KFileItem&)));
|
this, SLOT(showHoverInformation(const KFileItem&)));
|
||||||
connect(m_controller, SIGNAL(viewportEntered()),
|
connect(m_dolphinViewController, SIGNAL(viewportEntered()),
|
||||||
this, SLOT(clearHoverInformation()));
|
this, SLOT(clearHoverInformation()));
|
||||||
|
connect(m_dolphinViewController, SIGNAL(urlChangeRequested(KUrl)),
|
||||||
|
m_viewModeController, SLOT(setUrl(KUrl)));
|
||||||
|
|
||||||
KDirLister* dirLister = m_viewAccessor.dirLister();
|
KDirLister* dirLister = m_viewAccessor.dirLister();
|
||||||
connect(dirLister, SIGNAL(redirection(KUrl,KUrl)),
|
connect(dirLister, SIGNAL(redirection(KUrl,KUrl)),
|
||||||
|
@ -160,9 +166,9 @@ DolphinView::~DolphinView()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const KUrl& DolphinView::url() const
|
KUrl DolphinView::url() const
|
||||||
{
|
{
|
||||||
return m_controller->url();
|
return m_viewModeController->url();
|
||||||
}
|
}
|
||||||
|
|
||||||
KUrl DolphinView::rootUrl() const
|
KUrl DolphinView::rootUrl() const
|
||||||
|
@ -202,7 +208,7 @@ void DolphinView::setActive(bool active)
|
||||||
emit activated();
|
emit activated();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_controller->indicateActivationChange(active);
|
m_viewModeController->indicateActivationChange(active);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DolphinView::isActive() const
|
bool DolphinView::isActive() const
|
||||||
|
@ -216,7 +222,7 @@ void DolphinView::setMode(Mode mode)
|
||||||
return; // the wished mode is already set
|
return; // the wished mode is already set
|
||||||
}
|
}
|
||||||
|
|
||||||
const int oldZoomLevel = m_controller->zoomLevel();
|
const int oldZoomLevel = m_viewModeController->zoomLevel();
|
||||||
m_mode = mode;
|
m_mode = mode;
|
||||||
|
|
||||||
// remember the currently selected items, so that they will
|
// remember the currently selected items, so that they will
|
||||||
|
@ -353,14 +359,14 @@ void DolphinView::setZoomLevel(int level)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level != zoomLevel()) {
|
if (level != zoomLevel()) {
|
||||||
m_controller->setZoomLevel(level);
|
m_viewModeController->setZoomLevel(level);
|
||||||
emit zoomLevelChanged(level);
|
emit zoomLevelChanged(level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DolphinView::zoomLevel() const
|
int DolphinView::zoomLevel() const
|
||||||
{
|
{
|
||||||
return m_controller->zoomLevel();
|
return m_viewModeController->zoomLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::setSorting(Sorting sorting)
|
void DolphinView::setSorting(Sorting sorting)
|
||||||
|
@ -437,7 +443,7 @@ void DolphinView::refresh()
|
||||||
m_ignoreViewProperties = false;
|
m_ignoreViewProperties = false;
|
||||||
|
|
||||||
const bool oldActivationState = m_active;
|
const bool oldActivationState = m_active;
|
||||||
const int oldZoomLevel = m_controller->zoomLevel();
|
const int oldZoomLevel = m_viewModeController->zoomLevel();
|
||||||
m_active = true;
|
m_active = true;
|
||||||
|
|
||||||
createView();
|
createView();
|
||||||
|
@ -450,7 +456,7 @@ void DolphinView::refresh()
|
||||||
|
|
||||||
void DolphinView::setNameFilter(const QString& nameFilter)
|
void DolphinView::setNameFilter(const QString& nameFilter)
|
||||||
{
|
{
|
||||||
m_controller->setNameFilter(nameFilter);
|
m_viewModeController->setNameFilter(nameFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::calculateItemCount(int& fileCount,
|
void DolphinView::calculateItemCount(int& fileCount,
|
||||||
|
@ -528,15 +534,15 @@ QString DolphinView::statusBarText() const
|
||||||
|
|
||||||
QList<QAction*> DolphinView::versionControlActions(const KFileItemList& items) const
|
QList<QAction*> DolphinView::versionControlActions(const KFileItemList& items) const
|
||||||
{
|
{
|
||||||
return m_controller->versionControlActions(items);
|
return m_dolphinViewController->versionControlActions(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::setUrl(const KUrl& url)
|
void DolphinView::setUrl(const KUrl& url)
|
||||||
{
|
{
|
||||||
if (m_controller->url() != url) {
|
if (m_viewModeController->url() != url) {
|
||||||
m_newFileNames.clear();
|
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);
|
m_viewAccessor.prepareUrlChange(url);
|
||||||
applyViewProperties();
|
applyViewProperties();
|
||||||
loadDirectory(url);
|
loadDirectory(url);
|
||||||
|
@ -726,7 +732,7 @@ void DolphinView::setShowPreview(bool show)
|
||||||
props.setShowPreview(show);
|
props.setShowPreview(show);
|
||||||
|
|
||||||
m_showPreview = show;
|
m_showPreview = show;
|
||||||
const int oldZoomLevel = m_controller->zoomLevel();
|
const int oldZoomLevel = m_viewModeController->zoomLevel();
|
||||||
emit showPreviewChanged();
|
emit showPreviewChanged();
|
||||||
|
|
||||||
// Enabling or disabling the preview might change the icon size of the view.
|
// Enabling or disabling the preview might change the icon size of the view.
|
||||||
|
@ -814,7 +820,7 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event)
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
case QEvent::FocusIn:
|
case QEvent::FocusIn:
|
||||||
if (watched == m_viewAccessor.itemView()) {
|
if (watched == m_viewAccessor.itemView()) {
|
||||||
m_controller->requestActivation();
|
m_dolphinViewController->requestActivation();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1223,7 +1229,7 @@ void DolphinView::applyViewProperties()
|
||||||
|
|
||||||
const Mode mode = props.viewMode();
|
const Mode mode = props.viewMode();
|
||||||
if (m_mode != mode) {
|
if (m_mode != mode) {
|
||||||
const int oldZoomLevel = m_controller->zoomLevel();
|
const int oldZoomLevel = m_viewModeController->zoomLevel();
|
||||||
|
|
||||||
m_mode = mode;
|
m_mode = mode;
|
||||||
createView();
|
createView();
|
||||||
|
@ -1277,7 +1283,7 @@ void DolphinView::applyViewProperties()
|
||||||
const bool showPreview = props.showPreview();
|
const bool showPreview = props.showPreview();
|
||||||
if (showPreview != m_showPreview) {
|
if (showPreview != m_showPreview) {
|
||||||
m_showPreview = showPreview;
|
m_showPreview = showPreview;
|
||||||
const int oldZoomLevel = m_controller->zoomLevel();
|
const int oldZoomLevel = m_viewModeController->zoomLevel();
|
||||||
emit showPreviewChanged();
|
emit showPreviewChanged();
|
||||||
|
|
||||||
// Enabling or disabling the preview might change the icon size of the view.
|
// Enabling or disabling the preview might change the icon size of the view.
|
||||||
|
@ -1299,14 +1305,14 @@ void DolphinView::createView()
|
||||||
deleteView();
|
deleteView();
|
||||||
|
|
||||||
Q_ASSERT(m_viewAccessor.itemView() == 0);
|
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();
|
QAbstractItemView* view = m_viewAccessor.itemView();
|
||||||
Q_ASSERT(view != 0);
|
Q_ASSERT(view != 0);
|
||||||
view->installEventFilter(this);
|
view->installEventFilter(this);
|
||||||
view->viewport()->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
|
// 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
|
// a new item view with a custom selection model. Pass the ownership of the
|
||||||
|
@ -1340,7 +1346,7 @@ void DolphinView::deleteView()
|
||||||
|
|
||||||
// disconnect all signal/slots
|
// disconnect all signal/slots
|
||||||
disconnect(view);
|
disconnect(view);
|
||||||
m_controller->disconnect(view);
|
m_viewModeController->disconnect(view);
|
||||||
view->disconnect();
|
view->disconnect();
|
||||||
|
|
||||||
m_viewAccessor.deleteView();
|
m_viewAccessor.deleteView();
|
||||||
|
@ -1357,7 +1363,7 @@ void DolphinView::updateZoomLevel(int oldZoomLevel)
|
||||||
{
|
{
|
||||||
const int newZoomLevel = ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor.itemView()->iconSize());
|
const int newZoomLevel = ZoomLevelInfo::zoomLevelForIconSize(m_viewAccessor.itemView()->iconSize());
|
||||||
if (oldZoomLevel != newZoomLevel) {
|
if (oldZoomLevel != newZoomLevel) {
|
||||||
m_controller->setZoomLevel(newZoomLevel);
|
m_viewModeController->setZoomLevel(newZoomLevel);
|
||||||
emit zoomLevelChanged(newZoomLevel);
|
emit zoomLevelChanged(newZoomLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1403,22 +1409,31 @@ DolphinView::ViewAccessor::~ViewAccessor()
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::ViewAccessor::createView(QWidget* parent,
|
void DolphinView::ViewAccessor::createView(QWidget* parent,
|
||||||
DolphinController* controller,
|
DolphinViewController* dolphinViewController,
|
||||||
|
const ViewModeController* viewModeController,
|
||||||
Mode mode)
|
Mode mode)
|
||||||
{
|
{
|
||||||
Q_ASSERT(itemView() == 0);
|
Q_ASSERT(itemView() == 0);
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case IconsView:
|
case IconsView:
|
||||||
m_iconsView = new DolphinIconsView(parent, controller, m_proxyModel);
|
m_iconsView = new DolphinIconsView(parent,
|
||||||
|
dolphinViewController,
|
||||||
|
viewModeController,
|
||||||
|
m_proxyModel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DetailsView:
|
case DetailsView:
|
||||||
m_detailsView = new DolphinDetailsView(parent, controller, m_proxyModel);
|
m_detailsView = new DolphinDetailsView(parent,
|
||||||
|
dolphinViewController,
|
||||||
|
viewModeController,
|
||||||
|
m_proxyModel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ColumnView:
|
case ColumnView:
|
||||||
m_columnsContainer = new DolphinColumnViewContainer(parent, controller);
|
m_columnsContainer = new DolphinColumnViewContainer(parent,
|
||||||
|
dolphinViewController,
|
||||||
|
viewModeController);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1563,7 +1578,7 @@ KDirLister* DolphinView::ViewAccessor::dirLister() const
|
||||||
void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
|
void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
|
||||||
{
|
{
|
||||||
emit redirection(oldUrl, newUrl);
|
emit redirection(oldUrl, newUrl);
|
||||||
m_controller->redirectToUrl(newUrl); // #186947
|
m_viewModeController->redirectToUrl(newUrl); // #186947
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::restoreContentsPosition()
|
void DolphinView::restoreContentsPosition()
|
||||||
|
|
|
@ -41,17 +41,18 @@
|
||||||
|
|
||||||
typedef KIO::FileUndoManager::CommandType CommandType;
|
typedef KIO::FileUndoManager::CommandType CommandType;
|
||||||
|
|
||||||
class DolphinController;
|
|
||||||
class DolphinColumnViewContainer;
|
class DolphinColumnViewContainer;
|
||||||
class DolphinDetailsView;
|
class DolphinDetailsView;
|
||||||
class DolphinIconsView;
|
class DolphinIconsView;
|
||||||
class DolphinModel;
|
class DolphinModel;
|
||||||
class DolphinSortFilterProxyModel;
|
class DolphinSortFilterProxyModel;
|
||||||
|
class DolphinViewController;
|
||||||
class KFilePreviewGenerator;
|
class KFilePreviewGenerator;
|
||||||
class KAction;
|
class KAction;
|
||||||
class KActionCollection;
|
class KActionCollection;
|
||||||
class KDirLister;
|
class KDirLister;
|
||||||
class KUrl;
|
class KUrl;
|
||||||
|
class ViewModeController;
|
||||||
class ViewProperties;
|
class ViewProperties;
|
||||||
class DolphinDetailsViewExpander;
|
class DolphinDetailsViewExpander;
|
||||||
|
|
||||||
|
@ -132,7 +133,7 @@ public:
|
||||||
* Returns the current active URL, where all actions are applied.
|
* Returns the current active URL, where all actions are applied.
|
||||||
* The URL navigator is synchronized with this URL.
|
* 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
|
* Returns the root URL of the view, which is defined as the first
|
||||||
|
@ -727,7 +728,10 @@ private:
|
||||||
ViewAccessor(DolphinSortFilterProxyModel* proxyModel);
|
ViewAccessor(DolphinSortFilterProxyModel* proxyModel);
|
||||||
~ViewAccessor();
|
~ViewAccessor();
|
||||||
|
|
||||||
void createView(QWidget* parent, DolphinController* controller, Mode mode);
|
void createView(QWidget* parent,
|
||||||
|
DolphinViewController* dolphinViewController,
|
||||||
|
const ViewModeController* viewModeController,
|
||||||
|
Mode mode);
|
||||||
void deleteView();
|
void deleteView();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -786,7 +790,8 @@ private:
|
||||||
|
|
||||||
QVBoxLayout* m_topLayout;
|
QVBoxLayout* m_topLayout;
|
||||||
|
|
||||||
DolphinController* m_controller;
|
DolphinViewController* m_dolphinViewController;
|
||||||
|
ViewModeController* m_viewModeController;
|
||||||
ViewAccessor m_viewAccessor;
|
ViewAccessor m_viewAccessor;
|
||||||
|
|
||||||
QItemSelectionModel* m_selectionModel; // allow to switch views without losing the selection
|
QItemSelectionModel* m_selectionModel; // allow to switch views without losing the selection
|
||||||
|
|
|
@ -48,9 +48,10 @@
|
||||||
#include <kurlnavigator.h>
|
#include <kurlnavigator.h>
|
||||||
#include <krun.h>
|
#include <krun.h>
|
||||||
|
|
||||||
|
#include "dolphin_generalsettings.h"
|
||||||
#include "dolphinmodel.h"
|
#include "dolphinmodel.h"
|
||||||
#include "dolphincolumnview.h"
|
#include "dolphincolumnview.h"
|
||||||
#include "dolphincontroller.h"
|
#include "dolphinviewcontroller.h"
|
||||||
#include "dolphinmainwindow.h"
|
#include "dolphinmainwindow.h"
|
||||||
#include "dolphindirlister.h"
|
#include "dolphindirlister.h"
|
||||||
#include "dolphinsortfilterproxymodel.h"
|
#include "dolphinsortfilterproxymodel.h"
|
||||||
|
@ -58,10 +59,10 @@
|
||||||
#include "dolphiniconsview.h"
|
#include "dolphiniconsview.h"
|
||||||
#include "draganddrophelper.h"
|
#include "draganddrophelper.h"
|
||||||
#include "filterbar.h"
|
#include "filterbar.h"
|
||||||
#include "statusbar/dolphinstatusbar.h"
|
|
||||||
#include "viewproperties.h"
|
|
||||||
#include "settings/dolphinsettings.h"
|
#include "settings/dolphinsettings.h"
|
||||||
#include "dolphin_generalsettings.h"
|
#include "statusbar/dolphinstatusbar.h"
|
||||||
|
#include "viewmodecontroller.h"
|
||||||
|
#include "viewproperties.h"
|
||||||
|
|
||||||
DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
|
DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* 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 *
|
* 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 *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
@ -14,10 +14,10 @@
|
||||||
* You should have received a copy of the GNU General Public License *
|
* You should have received a copy of the GNU General Public License *
|
||||||
* along with this program; if not, write to the *
|
* along with this program; if not, write to the *
|
||||||
* Free Software Foundation, Inc., *
|
* 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 "zoomlevelinfo.h"
|
||||||
|
|
||||||
#include <kdirmodel.h>
|
#include <kdirmodel.h>
|
||||||
|
@ -26,38 +26,31 @@
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QDir>
|
#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),
|
QObject(dolphinView),
|
||||||
m_zoomLevel(0),
|
|
||||||
m_nameFilter(),
|
|
||||||
m_url(),
|
|
||||||
m_dolphinView(dolphinView),
|
m_dolphinView(dolphinView),
|
||||||
m_itemView(0),
|
m_itemView(0),
|
||||||
m_versionControlActions()
|
m_versionControlActions()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinController::~DolphinController()
|
DolphinViewController::~DolphinViewController()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::setUrl(const KUrl& url)
|
const DolphinView* DolphinViewController::view() const
|
||||||
{
|
{
|
||||||
if (m_url != url) {
|
return m_dolphinView;
|
||||||
m_url = url;
|
|
||||||
emit cancelPreviews();
|
|
||||||
emit urlChanged(url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
if (m_itemView != 0) {
|
||||||
disconnect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
|
disconnect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
|
||||||
|
@ -67,27 +60,30 @@ void DolphinController::setItemView(QAbstractItemView* view)
|
||||||
m_itemView = view;
|
m_itemView = view;
|
||||||
|
|
||||||
if (m_itemView != 0) {
|
if (m_itemView != 0) {
|
||||||
m_zoomLevel = ZoomLevelInfo::zoomLevelForIconSize(m_itemView->iconSize());
|
|
||||||
|
|
||||||
// TODO: this is a workaround until Qt-issue 176832 has been fixed
|
// TODO: this is a workaround until Qt-issue 176832 has been fixed
|
||||||
connect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
|
connect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
|
||||||
this, SLOT(updateMouseButtonState()));
|
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)
|
const QList<QAction*>& customActions)
|
||||||
{
|
{
|
||||||
emit activated();
|
emit activated();
|
||||||
emit requestContextMenu(pos, customActions);
|
emit requestContextMenu(pos, customActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::requestActivation()
|
void DolphinViewController::requestActivation()
|
||||||
{
|
{
|
||||||
emit activated();
|
emit activated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::indicateDroppedUrls(const KFileItem& destItem,
|
void DolphinViewController::indicateDroppedUrls(const KFileItem& destItem,
|
||||||
const KUrl& destPath,
|
const KUrl& destPath,
|
||||||
QDropEvent* event)
|
QDropEvent* event)
|
||||||
{
|
{
|
||||||
|
@ -95,69 +91,41 @@ void DolphinController::indicateDroppedUrls(const KFileItem& destItem,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DolphinController::indicateSortingChange(DolphinView::Sorting sorting)
|
void DolphinViewController::indicateSortingChange(DolphinView::Sorting sorting)
|
||||||
{
|
{
|
||||||
emit sortingChanged(sorting);
|
emit sortingChanged(sorting);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::indicateSortOrderChange(Qt::SortOrder order)
|
void DolphinViewController::indicateSortOrderChange(Qt::SortOrder order)
|
||||||
{
|
{
|
||||||
emit sortOrderChanged(order);
|
emit sortOrderChanged(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::indicateSortFoldersFirstChange(bool foldersFirst)
|
void DolphinViewController::indicateSortFoldersFirstChange(bool foldersFirst)
|
||||||
{
|
{
|
||||||
emit sortFoldersFirstChanged(foldersFirst);
|
emit sortFoldersFirstChanged(foldersFirst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::indicateAdditionalInfoChange(const KFileItemDelegate::InformationList& info)
|
void DolphinViewController::indicateAdditionalInfoChange(const KFileItemDelegate::InformationList& info)
|
||||||
{
|
{
|
||||||
emit additionalInfoChanged(info);
|
emit additionalInfoChanged(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::indicateActivationChange(bool active)
|
void DolphinViewController::setVersionControlActions(QList<QAction*> actions)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
m_versionControlActions = actions;
|
m_versionControlActions = actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QAction*> DolphinController::versionControlActions(const KFileItemList& items)
|
QList<QAction*> DolphinViewController::versionControlActions(const KFileItemList& items)
|
||||||
{
|
{
|
||||||
emit requestVersionControlActions(items);
|
emit requestVersionControlActions(items);
|
||||||
// All view implementations are connected with the signal requestVersionControlActions()
|
// 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.
|
// so that the context dependent actions can be returned.
|
||||||
return m_versionControlActions;
|
return m_versionControlActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::handleKeyPressEvent(QKeyEvent* event)
|
void DolphinViewController::handleKeyPressEvent(QKeyEvent* event)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_itemView != 0);
|
Q_ASSERT(m_itemView != 0);
|
||||||
|
|
||||||
|
@ -194,7 +162,7 @@ void DolphinController::handleKeyPressEvent(QKeyEvent* event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::replaceUrlByClipboard()
|
void DolphinViewController::replaceUrlByClipboard()
|
||||||
{
|
{
|
||||||
const QClipboard* clipboard = QApplication::clipboard();
|
const QClipboard* clipboard = QApplication::clipboard();
|
||||||
QString text;
|
QString text;
|
||||||
|
@ -208,17 +176,17 @@ void DolphinController::replaceUrlByClipboard()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::emitHideToolTip()
|
void DolphinViewController::requestToolTipHiding()
|
||||||
{
|
{
|
||||||
emit hideToolTip();
|
emit hideToolTip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::emitItemTriggered(const KFileItem& item)
|
void DolphinViewController::emitItemTriggered(const KFileItem& item)
|
||||||
{
|
{
|
||||||
emit itemTriggered(item);
|
emit itemTriggered(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
KFileItem DolphinController::itemForIndex(const QModelIndex& index) const
|
KFileItem DolphinViewController::itemForIndex(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_itemView != 0);
|
Q_ASSERT(m_itemView != 0);
|
||||||
|
|
||||||
|
@ -228,7 +196,7 @@ KFileItem DolphinController::itemForIndex(const QModelIndex& index) const
|
||||||
return dirModel->itemForIndex(dirIndex);
|
return dirModel->itemForIndex(dirIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::triggerItem(const QModelIndex& index)
|
void DolphinViewController::triggerItem(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
if (m_mouseButtons & Qt::LeftButton) {
|
if (m_mouseButtons & Qt::LeftButton) {
|
||||||
const KFileItem item = itemForIndex(index);
|
const KFileItem item = itemForIndex(index);
|
||||||
|
@ -241,7 +209,7 @@ void DolphinController::triggerItem(const QModelIndex& index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::requestTab(const QModelIndex& index)
|
void DolphinViewController::requestTab(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
if (m_mouseButtons & Qt::MidButton) {
|
if (m_mouseButtons & Qt::MidButton) {
|
||||||
const KFileItem item = itemForIndex(index);
|
const KFileItem item = itemForIndex(index);
|
||||||
|
@ -254,7 +222,7 @@ void DolphinController::requestTab(const QModelIndex& index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::emitItemEntered(const QModelIndex& index)
|
void DolphinViewController::emitItemEntered(const QModelIndex& index)
|
||||||
{
|
{
|
||||||
KFileItem item = itemForIndex(index);
|
KFileItem item = itemForIndex(index);
|
||||||
if (!item.isNull()) {
|
if (!item.isNull()) {
|
||||||
|
@ -262,14 +230,14 @@ void DolphinController::emitItemEntered(const QModelIndex& index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::emitViewportEntered()
|
void DolphinViewController::emitViewportEntered()
|
||||||
{
|
{
|
||||||
emit viewportEntered();
|
emit viewportEntered();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinController::updateMouseButtonState()
|
void DolphinViewController::updateMouseButtonState()
|
||||||
{
|
{
|
||||||
m_mouseButtons = QApplication::mouseButtons();
|
m_mouseButtons = QApplication::mouseButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "dolphincontroller.moc"
|
#include "dolphinviewcontroller.moc"
|
|
@ -1,5 +1,5 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* 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 *
|
* 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 *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
@ -14,11 +14,11 @@
|
||||||
* You should have received a copy of the GNU General Public License *
|
* You should have received a copy of the GNU General Public License *
|
||||||
* along with this program; if not, write to the *
|
* along with this program; if not, write to the *
|
||||||
* Free Software Foundation, Inc., *
|
* 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
|
#ifndef DOLPHINVIEWCONTROLLER_H
|
||||||
#define DOLPHINCONTROLLER_H
|
#define DOLPHINVIEWCONTROLLER_H
|
||||||
|
|
||||||
#include <dolphinview.h>
|
#include <dolphinview.h>
|
||||||
#include <kurl.h>
|
#include <kurl.h>
|
||||||
|
@ -31,86 +31,44 @@ class KUrl;
|
||||||
class QPoint;
|
class QPoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Acts as mediator between the abstract Dolphin view and the view
|
* @brief Allows the view mode implementations (DolphinIconsView, DolphinDetailsView, DolphinColumnView)
|
||||||
* implementations.
|
* to do a limited control of the DolphinView.
|
||||||
*
|
*
|
||||||
* The abstract Dolphin view (see DolphinView) represents the parent of the controller.
|
* The DolphinView connects to the signals of DolphinViewController to react on changes
|
||||||
* The lifetime of the controller is equal to the lifetime of the Dolphin view.
|
* that have been triggered by the view mode implementations. The view mode implementations
|
||||||
* The controller is passed to the current view implementation
|
* have read access to the whole DolphinView by DolphinViewController::view(). Limited control of the
|
||||||
* (see DolphinIconsView, DolphinDetailsView and DolphinColumnView)
|
* DolphinView by the view mode implementations are defined by the public DolphinController methods.
|
||||||
* 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()
|
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT DolphinController : public QObject
|
class LIBDOLPHINPRIVATE_EXPORT DolphinViewController : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DolphinController(DolphinView* dolphinView);
|
explicit DolphinViewController(DolphinView* dolphinView);
|
||||||
virtual ~DolphinController();
|
virtual ~DolphinViewController();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows read access for the view implementation to the abstract
|
* Allows read access for the view mode implementation
|
||||||
* Dolphin view.
|
* to the DolphinView.
|
||||||
*/
|
*/
|
||||||
const DolphinView* dolphinView() const;
|
const DolphinView* view() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the URL to \a url and emits the signal urlChanged() if
|
* Requests the DolphinView to change the URL to \p url. The signal
|
||||||
* \a url is different for the current URL. This method should
|
* urlChangeRequested will be emitted.
|
||||||
* be invoked by the abstract Dolphin view whenever the current
|
|
||||||
* URL has been changed.
|
|
||||||
*/
|
*/
|
||||||
void setUrl(const KUrl& url);
|
void requestUrlChange(const KUrl& url);
|
||||||
const KUrl& url() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the URL to \a url and does nothing else. Called when
|
* Changes the current view mode implementation where the controller is working.
|
||||||
* a redirection happens.
|
* This is only necessary for views like the tree view, where internally
|
||||||
*/
|
|
||||||
void redirectToUrl(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
|
|
||||||
* several QAbstractItemView instances are used.
|
* several QAbstractItemView instances are used.
|
||||||
*/
|
*/
|
||||||
void setItemView(QAbstractItemView* view);
|
void setItemView(QAbstractItemView* view);
|
||||||
|
|
||||||
QAbstractItemView* itemView() const;
|
QAbstractItemView* itemView() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests a context menu for the position \a pos. This method
|
* Requests a context menu for the position \a pos. DolphinView
|
||||||
* should be invoked by the view implementation when a context
|
|
||||||
* menu should be opened. The abstract Dolphin view itself
|
|
||||||
* takes care itself to get the selected items depending from
|
* takes care itself to get the selected items depending from
|
||||||
* \a pos. It is possible to define a custom list of actions for
|
* \a pos. It is possible to define a custom list of actions for
|
||||||
* the context menu by \a customActions.
|
* the context menu by \a customActions.
|
||||||
|
@ -119,17 +77,14 @@ public:
|
||||||
const QList<QAction*>& customActions = QList<QAction*>());
|
const QList<QAction*>& customActions = QList<QAction*>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests an activation of the view and emits the signal
|
* Requests an activation of the DolphinView and emits the signal
|
||||||
* activated(). This method should be invoked by the view implementation
|
* activated(). This method should be invoked by the view mode implementation
|
||||||
* if e. g. a mouse click on the view has been done.
|
* 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();
|
void requestActivation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that URLs are dropped above a destination. This method
|
* Indicates that URLs are dropped above a destination. The DolphinView
|
||||||
* should be invoked by the view implementation. The abstract Dolphin view
|
|
||||||
* will start the corresponding action (copy, move, link).
|
* will start the corresponding action (copy, move, link).
|
||||||
* @param destItem Item of the destination (can be null, see KFileItem::isNull()).
|
* @param destItem Item of the destination (can be null, see KFileItem::isNull()).
|
||||||
* @param destPath Path of the destination.
|
* @param destPath Path of the destination.
|
||||||
|
@ -140,110 +95,75 @@ public:
|
||||||
QDropEvent* event);
|
QDropEvent* event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Informs the abstract Dolphin view about a sorting change done inside
|
* Informs the DolphinView about a sorting change done inside
|
||||||
* the view implementation. This method should be invoked by the view
|
* the view mode implementation.
|
||||||
* implementation (e. g. the details view uses this method in combination
|
|
||||||
* with the details header).
|
|
||||||
*/
|
*/
|
||||||
void indicateSortingChange(DolphinView::Sorting sorting);
|
void indicateSortingChange(DolphinView::Sorting sorting);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Informs the abstract Dolphin view about a sort order change done inside
|
* Informs the DolphinView about a sort order change done inside
|
||||||
* the view implementation. This method should be invoked by the view
|
* the view mode implementation.
|
||||||
* implementation (e. g. the details view uses this method in combination
|
|
||||||
* with the details header).
|
|
||||||
*/
|
*/
|
||||||
void indicateSortOrderChange(Qt::SortOrder order);
|
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
|
* (with folders first) and mixed sorting of files and folders done inside
|
||||||
* the view implementation. This method should be invoked by the view
|
* the view mode implementation.
|
||||||
* implementation (e. g. the details view uses this method in combination
|
|
||||||
* with the details header).
|
|
||||||
*/
|
*/
|
||||||
void indicateSortFoldersFirstChange(bool foldersFirst);
|
void indicateSortFoldersFirstChange(bool foldersFirst);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Informs the abstract Dolphin view about an additional information change
|
* Informs the DolphinView about an additional information change
|
||||||
* done inside the view implementation. This method should be invoked by the
|
* done inside the view mode implementation.
|
||||||
* view implementation (e. g. the details view uses this method in combination
|
|
||||||
* with the details header).
|
|
||||||
*/
|
*/
|
||||||
void indicateAdditionalInfoChange(const KFileItemDelegate::InformationList& info);
|
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
|
* 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().
|
* requestVersionControlActions().
|
||||||
*/
|
*/
|
||||||
void setVersionControlActions(QList<QAction*> actions);
|
void setVersionControlActions(QList<QAction*> actions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the version control actions that are provided for the items \p items.
|
* Emits the signal requestVersionControlActions(). The view mode implementation
|
||||||
* Is called by the abstract Dolphin view to show the version control actions
|
* listens to the signal and will invoke a DolphinViewController::setVersionControlActions()
|
||||||
* inside the context menu.
|
* and the result will be returned.
|
||||||
*/
|
*/
|
||||||
QList<QAction*> versionControlActions(const KFileItemList& items);
|
QList<QAction*> versionControlActions(const KFileItemList& items);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the name filter to \a and emits the signal nameFilterChanged().
|
* Must be be invoked in each view mode implementation whenever a key has been
|
||||||
*/
|
|
||||||
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
|
|
||||||
* pressed. If the selection model of \a view is not empty and
|
* pressed. If the selection model of \a view is not empty and
|
||||||
* the return key has been pressed, the selected items will get triggered.
|
* the return key has been pressed, the selected items will get triggered.
|
||||||
*/
|
*/
|
||||||
void handleKeyPressEvent(QKeyEvent* event);
|
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,
|
* of the clipboard as URL. If the clipboard contains no text,
|
||||||
* nothing will be done.
|
* nothing will be done.
|
||||||
*/
|
*/
|
||||||
void replaceUrlByClipboard();
|
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.
|
* 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.
|
* trigger an item directly without mouse interaction.
|
||||||
* If the item triggering is done by the mouse, it is recommended
|
* 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.
|
* the used mouse buttons to execute the correct action.
|
||||||
*/
|
*/
|
||||||
void emitItemTriggered(const KFileItem& item);
|
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;
|
KFileItem itemForIndex(const QModelIndex& index) const;
|
||||||
|
|
||||||
|
@ -252,7 +172,7 @@ public slots:
|
||||||
* Emits the signal itemTriggered() if the file item for the index \a index
|
* 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
|
* is not null and the left mouse button has been pressed. If the item is
|
||||||
* null, the signal itemEntered() is emitted.
|
* 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
|
* user has triggered an item with the mouse (see
|
||||||
* QAbstractItemView::clicked() or QAbstractItemView::doubleClicked()).
|
* QAbstractItemView::clicked() or QAbstractItemView::doubleClicked()).
|
||||||
*/
|
*/
|
||||||
|
@ -261,33 +181,27 @@ public slots:
|
||||||
/**
|
/**
|
||||||
* Emits the signal tabRequested(), if the file item for the index \a index
|
* 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.
|
* 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);
|
void requestTab(const QModelIndex& index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emits the signal itemEntered() if the file item for the index \a 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.
|
* whenever the mouse cursor is above an item.
|
||||||
*/
|
*/
|
||||||
void emitItemEntered(const QModelIndex& index);
|
void emitItemEntered(const QModelIndex& index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emits the signal viewportEntered(). The method should be invoked by
|
* 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();
|
void emitViewportEntered();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
void urlChangeRequested(const KUrl& url);
|
||||||
* Is emitted if the URL for the Dolphin controller has been changed
|
|
||||||
* to \a url.
|
|
||||||
*/
|
|
||||||
void urlChanged(const KUrl& url);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is emitted if a context menu should be opened (see triggerContextMenuRequest()).
|
* 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
|
* @param pos Position relative to the view widget where the
|
||||||
* context menu should be opened. It is recommended
|
* context menu should be opened. It is recommended
|
||||||
* to get the corresponding model index from
|
* to get the corresponding model index from
|
||||||
|
@ -299,8 +213,6 @@ signals:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is emitted if the view has been activated by e. g. a mouse click.
|
* 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();
|
void activated();
|
||||||
|
|
||||||
|
@ -316,43 +228,35 @@ signals:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is emitted if the sorting has been changed to \a sorting by
|
* Is emitted if the sorting has been changed to \a sorting by
|
||||||
* the view implementation (see indicateSortingChanged().
|
* the view mode implementation (see indicateSortingChanged().
|
||||||
* The abstract Dolphin view connects to
|
* The DolphinView connects to
|
||||||
* this signal to update its menu action.
|
* this signal to update its menu action.
|
||||||
*/
|
*/
|
||||||
void sortingChanged(DolphinView::Sorting sorting);
|
void sortingChanged(DolphinView::Sorting sorting);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is emitted if the sort order has been changed to \a order
|
* Is emitted if the sort order has been changed to \a order
|
||||||
* by the view implementation (see indicateSortOrderChanged().
|
* by the view mode implementation (see indicateSortOrderChanged().
|
||||||
* The abstract Dolphin view connects
|
* The DolphinView connects
|
||||||
* to this signal to update its menu actions.
|
* to this signal to update its menu actions.
|
||||||
*/
|
*/
|
||||||
void sortOrderChanged(Qt::SortOrder order);
|
void sortOrderChanged(Qt::SortOrder order);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is emitted if 'sort folders first' has been changed to \a foldersFirst
|
* Is emitted if 'sort folders first' has been changed to \a foldersFirst
|
||||||
* by the view implementation (see indicateSortOrderChanged().
|
* by the view mode implementation (see indicateSortOrderChanged().
|
||||||
* The abstract Dolphin view connects
|
* The DolphinView connects
|
||||||
* to this signal to update its menu actions.
|
* to this signal to update its menu actions.
|
||||||
*/
|
*/
|
||||||
void sortFoldersFirstChanged(bool foldersFirst);
|
void sortFoldersFirstChanged(bool foldersFirst);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is emitted if the additional info has been changed to \a info
|
* 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.
|
* to this signal to update its menu actions.
|
||||||
*/
|
*/
|
||||||
void additionalInfoChanged(const KFileItemDelegate::InformationList& info);
|
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
|
* Is emitted if the item \a item should be triggered. The abstract
|
||||||
* Dolphin view connects to this signal. If the item represents a directory,
|
* Dolphin view connects to this signal. If the item represents a directory,
|
||||||
|
@ -364,7 +268,6 @@ signals:
|
||||||
/**
|
/**
|
||||||
* Is emitted if the mouse cursor has entered the item
|
* Is emitted if the mouse cursor has entered the item
|
||||||
* given by \a index (see emitItemEntered()).
|
* given by \a index (see emitItemEntered()).
|
||||||
* The abstract Dolphin view connects to this signal.
|
|
||||||
*/
|
*/
|
||||||
void itemEntered(const KFileItem& item);
|
void itemEntered(const KFileItem& item);
|
||||||
|
|
||||||
|
@ -376,24 +279,12 @@ signals:
|
||||||
/**
|
/**
|
||||||
* Is emitted if the mouse cursor has entered
|
* Is emitted if the mouse cursor has entered
|
||||||
* the viewport (see emitViewportEntered()).
|
* the viewport (see emitViewportEntered()).
|
||||||
* The abstract Dolphin view connects to this signal.
|
|
||||||
*/
|
*/
|
||||||
void viewportEntered();
|
void viewportEntered();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is emitted if the view should respect the name filter \a nameFilter. The view
|
* Is emitted, if DolphinViewController::requestToolTipHiding() is invoked
|
||||||
* implementation must connect to this signal if it supports name filters.
|
* and requests to hide all tooltips.
|
||||||
*/
|
|
||||||
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.
|
|
||||||
*/
|
*/
|
||||||
void hideToolTip();
|
void hideToolTip();
|
||||||
|
|
||||||
|
@ -403,9 +294,9 @@ signals:
|
||||||
void cancelPreviews();
|
void cancelPreviews();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests the view implementation to invoke DolphinController::setVersionControlActions(),
|
* Requests the view mode implementation to invoke DolphinViewController::setVersionControlActions(),
|
||||||
* so that they can be returned with DolphinController::versionControlActions() for
|
* so that they can be returned with DolphinViewController::versionControlActions() for
|
||||||
* the abstract Dolphin view.
|
* the DolphinView.
|
||||||
*/
|
*/
|
||||||
void requestVersionControlActions(const KFileItemList& items);
|
void requestVersionControlActions(const KFileItemList& items);
|
||||||
|
|
||||||
|
@ -413,33 +304,11 @@ private slots:
|
||||||
void updateMouseButtonState();
|
void updateMouseButtonState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_zoomLevel;
|
|
||||||
QString m_nameFilter;
|
|
||||||
static Qt::MouseButtons m_mouseButtons; // TODO: this is a workaround until Qt-issue 176832 has been fixed
|
static Qt::MouseButtons m_mouseButtons; // TODO: this is a workaround until Qt-issue 176832 has been fixed
|
||||||
KUrl m_url;
|
|
||||||
DolphinView* m_dolphinView;
|
DolphinView* m_dolphinView;
|
||||||
QAbstractItemView* m_itemView;
|
QAbstractItemView* m_itemView;
|
||||||
QList<QAction*> m_versionControlActions;
|
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
|
#endif
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "draganddrophelper.h"
|
#include "draganddrophelper.h"
|
||||||
#include "dolphiniconsview.h"
|
#include "dolphiniconsview.h"
|
||||||
#include "dolphincontroller.h"
|
#include "dolphinviewcontroller.h"
|
||||||
|
|
||||||
#include <kdirmodel.h>
|
#include <kdirmodel.h>
|
||||||
#include <kfileitem.h>
|
#include <kfileitem.h>
|
||||||
|
@ -53,7 +53,7 @@ bool DragAndDropHelper::isMimeDataSupported(const QMimeData* mimeData) const
|
||||||
|
|
||||||
void DragAndDropHelper::startDrag(QAbstractItemView* itemView,
|
void DragAndDropHelper::startDrag(QAbstractItemView* itemView,
|
||||||
Qt::DropActions supportedActions,
|
Qt::DropActions supportedActions,
|
||||||
DolphinController* controller)
|
DolphinViewController* dolphinViewController)
|
||||||
{
|
{
|
||||||
// Do not start a new drag until the previous one has been finished.
|
// Do not start a new drag until the previous one has been finished.
|
||||||
// This is a (possibly temporary) fix for bug #187884.
|
// This is a (possibly temporary) fix for bug #187884.
|
||||||
|
@ -70,8 +70,8 @@ void DragAndDropHelper::startDrag(QAbstractItemView* itemView,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controller != 0) {
|
if (dolphinViewController != 0) {
|
||||||
controller->emitHideToolTip();
|
dolphinViewController->requestToolTipHiding();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDrag* drag = new QDrag(itemView);
|
QDrag* drag = new QDrag(itemView);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "libdolphin_export.h"
|
#include "libdolphin_export.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class DolphinController;
|
class DolphinViewController;
|
||||||
class KFileItem;
|
class KFileItem;
|
||||||
class KUrl;
|
class KUrl;
|
||||||
class QDropEvent;
|
class QDropEvent;
|
||||||
|
@ -57,7 +57,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void startDrag(QAbstractItemView* itemView,
|
void startDrag(QAbstractItemView* itemView,
|
||||||
Qt::DropActions supportedActions,
|
Qt::DropActions supportedActions,
|
||||||
DolphinController* controller = 0);
|
DolphinViewController* dolphinViewController = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if and only if the view \a itemView was the last view to
|
* Returns true if and only if the view \a itemView was the last view to
|
||||||
|
|
|
@ -19,9 +19,10 @@
|
||||||
|
|
||||||
#include "paneltreeview.h"
|
#include "paneltreeview.h"
|
||||||
|
|
||||||
#include "dolphincontroller.h"
|
#include "dolphinviewcontroller.h"
|
||||||
#include "dolphinmodel.h"
|
#include "dolphinmodel.h"
|
||||||
#include "draganddrophelper.h"
|
#include "draganddrophelper.h"
|
||||||
|
#include "viewmodecontroller.h"
|
||||||
|
|
||||||
#include <kfileitemdelegate.h>
|
#include <kfileitemdelegate.h>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
|
@ -19,16 +19,17 @@
|
||||||
|
|
||||||
#include "viewextensionsfactory.h"
|
#include "viewextensionsfactory.h"
|
||||||
|
|
||||||
#include "dolphincontroller.h"
|
|
||||||
#include "dolphinfileitemdelegate.h"
|
#include "dolphinfileitemdelegate.h"
|
||||||
#include "dolphinsortfilterproxymodel.h"
|
#include "dolphinsortfilterproxymodel.h"
|
||||||
#include "dolphinview.h"
|
#include "dolphinview.h"
|
||||||
|
#include "dolphinviewcontroller.h"
|
||||||
#include "dolphinviewautoscroller.h"
|
#include "dolphinviewautoscroller.h"
|
||||||
#include "folderexpander.h"
|
#include "folderexpander.h"
|
||||||
#include "selectionmanager.h"
|
#include "selectionmanager.h"
|
||||||
#include "settings/dolphinsettings.h"
|
#include "settings/dolphinsettings.h"
|
||||||
#include "tooltips/tooltipmanager.h"
|
#include "tooltips/tooltipmanager.h"
|
||||||
#include "versioncontrol/versioncontrolobserver.h"
|
#include "versioncontrol/versioncontrolobserver.h"
|
||||||
|
#include "viewmodecontroller.h"
|
||||||
|
|
||||||
#include "dolphin_generalsettings.h"
|
#include "dolphin_generalsettings.h"
|
||||||
|
|
||||||
|
@ -38,10 +39,11 @@
|
||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
|
|
||||||
ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
|
ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
|
||||||
DolphinController* controller) :
|
DolphinViewController* dolphinViewController,
|
||||||
|
const ViewModeController* viewModeController) :
|
||||||
QObject(view),
|
QObject(view),
|
||||||
m_view(view),
|
m_view(view),
|
||||||
m_controller(controller),
|
m_dolphinViewController(dolphinViewController),
|
||||||
m_toolTipManager(0),
|
m_toolTipManager(0),
|
||||||
m_previewGenerator(0),
|
m_previewGenerator(0),
|
||||||
m_selectionManager(0),
|
m_selectionManager(0),
|
||||||
|
@ -58,19 +60,19 @@ ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
|
||||||
DolphinSortFilterProxyModel* proxyModel = static_cast<DolphinSortFilterProxyModel*>(view->model());
|
DolphinSortFilterProxyModel* proxyModel = static_cast<DolphinSortFilterProxyModel*>(view->model());
|
||||||
m_toolTipManager = new ToolTipManager(view, proxyModel);
|
m_toolTipManager = new ToolTipManager(view, proxyModel);
|
||||||
|
|
||||||
connect(controller, SIGNAL(hideToolTip()),
|
connect(viewModeController, SIGNAL(hideToolTip()),
|
||||||
m_toolTipManager, SLOT(hideTip()));
|
m_toolTipManager, SLOT(hideTip()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize preview generator
|
// initialize preview generator
|
||||||
Q_ASSERT(view->iconSize().isValid());
|
Q_ASSERT(view->iconSize().isValid());
|
||||||
m_previewGenerator = new KFilePreviewGenerator(view);
|
m_previewGenerator = new KFilePreviewGenerator(view);
|
||||||
m_previewGenerator->setPreviewShown(controller->dolphinView()->showPreview());
|
m_previewGenerator->setPreviewShown(dolphinViewController->view()->showPreview());
|
||||||
connect(controller, SIGNAL(zoomLevelChanged(int)),
|
connect(viewModeController, SIGNAL(zoomLevelChanged(int)),
|
||||||
this, SLOT(slotZoomLevelChanged()));
|
this, SLOT(slotZoomLevelChanged()));
|
||||||
connect(controller, SIGNAL(cancelPreviews()),
|
connect(viewModeController, SIGNAL(cancelPreviews()),
|
||||||
this, SLOT(cancelPreviews()));
|
this, SLOT(cancelPreviews()));
|
||||||
connect(controller->dolphinView(), SIGNAL(showPreviewChanged()),
|
connect(dolphinViewController->view(), SIGNAL(showPreviewChanged()),
|
||||||
this, SLOT(slotShowPreviewChanged()));
|
this, SLOT(slotShowPreviewChanged()));
|
||||||
|
|
||||||
// initialize selection manager
|
// initialize selection manager
|
||||||
|
@ -78,7 +80,7 @@ ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
|
||||||
m_selectionManager = new SelectionManager(view);
|
m_selectionManager = new SelectionManager(view);
|
||||||
connect(m_selectionManager, SIGNAL(selectionChanged()),
|
connect(m_selectionManager, SIGNAL(selectionChanged()),
|
||||||
this, SLOT(requestActivation()));
|
this, SLOT(requestActivation()));
|
||||||
connect(controller, SIGNAL(urlChanged(const KUrl&)),
|
connect(viewModeController, SIGNAL(urlChanged(const KUrl&)),
|
||||||
m_selectionManager, SLOT(reset()));
|
m_selectionManager, SLOT(reset()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +93,7 @@ ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
|
||||||
view->setItemDelegate(m_fileItemDelegate);
|
view->setItemDelegate(m_fileItemDelegate);
|
||||||
|
|
||||||
// initialize version control observer
|
// initialize version control observer
|
||||||
const DolphinView* dolphinView = controller->dolphinView();
|
const DolphinView* dolphinView = dolphinViewController->view();
|
||||||
m_versionControlObserver = new VersionControlObserver(view);
|
m_versionControlObserver = new VersionControlObserver(view);
|
||||||
connect(m_versionControlObserver, SIGNAL(infoMessage(const QString&)),
|
connect(m_versionControlObserver, SIGNAL(infoMessage(const QString&)),
|
||||||
dolphinView, SIGNAL(infoMessage(const QString&)));
|
dolphinView, SIGNAL(infoMessage(const QString&)));
|
||||||
|
@ -99,7 +101,7 @@ ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
|
||||||
dolphinView, SIGNAL(errorMessage(const QString&)));
|
dolphinView, SIGNAL(errorMessage(const QString&)));
|
||||||
connect(m_versionControlObserver, SIGNAL(operationCompletedMessage(const QString&)),
|
connect(m_versionControlObserver, SIGNAL(operationCompletedMessage(const QString&)),
|
||||||
dolphinView, 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&)));
|
this, SLOT(slotRequestVersionControlActions(const KFileItemList&)));
|
||||||
|
|
||||||
// react on view property changes
|
// react on view property changes
|
||||||
|
@ -118,10 +120,10 @@ ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
|
||||||
m_folderExpander = new FolderExpander(view, proxyModel());
|
m_folderExpander = new FolderExpander(view, proxyModel());
|
||||||
m_folderExpander->setEnabled(settings->autoExpandFolders());
|
m_folderExpander->setEnabled(settings->autoExpandFolders());
|
||||||
connect(m_folderExpander, SIGNAL(enterDir(const QModelIndex&)),
|
connect(m_folderExpander, SIGNAL(enterDir(const QModelIndex&)),
|
||||||
controller, SLOT(triggerItem(const QModelIndex&)));
|
dolphinViewController, SLOT(triggerItem(const QModelIndex&)));
|
||||||
|
|
||||||
// react on namefilter changes
|
// react on namefilter changes
|
||||||
connect(controller, SIGNAL(nameFilterChanged(const QString&)),
|
connect(viewModeController, SIGNAL(nameFilterChanged(const QString&)),
|
||||||
this, SLOT(slotNameFilterChanged(const QString&)));
|
this, SLOT(slotNameFilterChanged(const QString&)));
|
||||||
|
|
||||||
view->viewport()->installEventFilter(this);
|
view->viewport()->installEventFilter(this);
|
||||||
|
@ -175,7 +177,7 @@ void ViewExtensionsFactory::cancelPreviews()
|
||||||
|
|
||||||
void ViewExtensionsFactory::slotShowPreviewChanged()
|
void ViewExtensionsFactory::slotShowPreviewChanged()
|
||||||
{
|
{
|
||||||
const bool show = m_controller->dolphinView()->showPreview();
|
const bool show = m_dolphinViewController->view()->showPreview();
|
||||||
m_previewGenerator->setPreviewShown(show);
|
m_previewGenerator->setPreviewShown(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +188,7 @@ void ViewExtensionsFactory::slotShowHiddenFilesChanged()
|
||||||
|
|
||||||
dirLister->stop();
|
dirLister->stop();
|
||||||
|
|
||||||
const bool show = m_controller->dolphinView()->showHiddenFiles();
|
const bool show = m_dolphinViewController->view()->showHiddenFiles();
|
||||||
dirLister->setShowingDotFiles(show);
|
dirLister->setShowingDotFiles(show);
|
||||||
|
|
||||||
const KUrl url = dirLister->url();
|
const KUrl url = dirLister->url();
|
||||||
|
@ -225,12 +227,12 @@ void ViewExtensionsFactory::slotRequestVersionControlActions(const KFileItemList
|
||||||
} else {
|
} else {
|
||||||
actions = m_versionControlObserver->contextMenuActions(items);
|
actions = m_versionControlObserver->contextMenuActions(items);
|
||||||
}
|
}
|
||||||
m_controller->setVersionControlActions(actions);
|
m_dolphinViewController->setVersionControlActions(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewExtensionsFactory::requestActivation()
|
void ViewExtensionsFactory::requestActivation()
|
||||||
{
|
{
|
||||||
m_controller->requestActivation();
|
m_dolphinViewController->requestActivation();
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinSortFilterProxyModel* ViewExtensionsFactory::proxyModel() const
|
DolphinSortFilterProxyModel* ViewExtensionsFactory::proxyModel() const
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include "dolphinview.h"
|
#include "dolphinview.h"
|
||||||
|
|
||||||
class DolphinController;
|
|
||||||
class DolphinFileItemDelegate;
|
class DolphinFileItemDelegate;
|
||||||
class DolphinSortFilterProxyModel;
|
class DolphinSortFilterProxyModel;
|
||||||
class DolphinViewAutoScroller;
|
class DolphinViewAutoScroller;
|
||||||
|
@ -35,6 +34,7 @@ class SelectionManager;
|
||||||
class ToolTipManager;
|
class ToolTipManager;
|
||||||
class QAbstractItemView;
|
class QAbstractItemView;
|
||||||
class VersionControlObserver;
|
class VersionControlObserver;
|
||||||
|
class ViewModeController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Responsible for creating extensions like tooltips and previews
|
* @brief Responsible for creating extensions like tooltips and previews
|
||||||
|
@ -51,7 +51,8 @@ class ViewExtensionsFactory : public QObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ViewExtensionsFactory(QAbstractItemView* view,
|
explicit ViewExtensionsFactory(QAbstractItemView* view,
|
||||||
DolphinController* controller);
|
DolphinViewController* dolphinViewController,
|
||||||
|
const ViewModeController* viewModeController);
|
||||||
virtual ~ViewExtensionsFactory();
|
virtual ~ViewExtensionsFactory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +91,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAbstractItemView* m_view;
|
QAbstractItemView* m_view;
|
||||||
DolphinController* m_controller;
|
DolphinViewController* m_dolphinViewController;
|
||||||
ToolTipManager* m_toolTipManager;
|
ToolTipManager* m_toolTipManager;
|
||||||
KFilePreviewGenerator* m_previewGenerator;
|
KFilePreviewGenerator* m_previewGenerator;
|
||||||
SelectionManager* m_selectionManager;
|
SelectionManager* m_selectionManager;
|
||||||
|
|
88
src/viewmodecontroller.cpp
Normal file
88
src/viewmodecontroller.cpp
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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"
|
124
src/viewmodecontroller.h
Normal file
124
src/viewmodecontroller.h
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* 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
|
Loading…
Reference in a new issue