mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Move code for initializing and handling view extensions to the new class ViewExtensionsFactory. Beside making DolphinView less complex this will allow the column view to share the view extension code instead of (partly) duplicating it as it has been done before.
Currently only the tooltips- and filepreview-handling have been moved into ViewExtensionsFactory, a further cleanup will be done later. svn path=/trunk/KDE/kdebase/apps/; revision=1016893
This commit is contained in:
parent
e1c74b05fd
commit
c05395ef9a
16 changed files with 196 additions and 79 deletions
|
@ -49,6 +49,7 @@ set(dolphinprivate_LIB_SRCS
|
|||
tooltips/kformattedballoontipdelegate.cpp
|
||||
tooltips/tooltipmanager.cpp
|
||||
versioncontrolobserver.cpp
|
||||
viewextensionsfactory.cpp
|
||||
viewproperties.cpp
|
||||
zoomlevelinfo.cpp
|
||||
)
|
||||
|
|
|
@ -33,12 +33,12 @@
|
|||
#include "selectionmanager.h"
|
||||
#include "tooltips/tooltipmanager.h"
|
||||
#include "versioncontrolobserver.h"
|
||||
#include "viewextensionsfactory.h"
|
||||
#include "zoomlevelinfo.h"
|
||||
|
||||
#include <kcolorscheme.h>
|
||||
#include <kdirlister.h>
|
||||
#include <kfileitem.h>
|
||||
#include <kfilepreviewgenerator.h>
|
||||
#include <kio/previewjob.h>
|
||||
#include <kiconeffect.h>
|
||||
#include <kjob.h>
|
||||
|
@ -58,6 +58,7 @@ DolphinColumnView::DolphinColumnView(QWidget* parent,
|
|||
m_container(container),
|
||||
m_selectionManager(0),
|
||||
m_autoScroller(0),
|
||||
m_extensionsFactory(0),
|
||||
m_url(url),
|
||||
m_childUrl(),
|
||||
m_font(),
|
||||
|
@ -65,8 +66,6 @@ DolphinColumnView::DolphinColumnView(QWidget* parent,
|
|||
m_dirLister(0),
|
||||
m_dolphinModel(0),
|
||||
m_proxyModel(0),
|
||||
m_previewGenerator(0),
|
||||
m_toolTipManager(0),
|
||||
m_dropRect()
|
||||
{
|
||||
setMouseTracking(true);
|
||||
|
@ -149,13 +148,6 @@ DolphinColumnView::DolphinColumnView(QWidget* parent,
|
|||
m_selectionManager, SLOT(reset()));
|
||||
}
|
||||
|
||||
//m_previewGenerator = new KFilePreviewGenerator(this);
|
||||
//m_previewGenerator->setPreviewShown(m_container->m_controller->dolphinView()->showPreview());
|
||||
|
||||
//if (DolphinSettings::instance().generalSettings()->showToolTips()) {
|
||||
// m_toolTipManager = new ToolTipManager(this, m_proxyModel);
|
||||
//}
|
||||
|
||||
//m_dirLister->openUrl(url, KDirLister::NoFlags);
|
||||
|
||||
connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
|
||||
|
@ -180,6 +172,8 @@ DolphinColumnView::DolphinColumnView(QWidget* parent,
|
|||
this, SLOT(setNameFilter(const QString&)));
|
||||
|
||||
updateDecorationSize(dolphinView->showPreview());
|
||||
|
||||
m_extensionsFactory = new ViewExtensionsFactory(this, controller);
|
||||
}
|
||||
|
||||
DolphinColumnView::~DolphinColumnView()
|
||||
|
@ -391,10 +385,6 @@ void DolphinColumnView::keyPressEvent(QKeyEvent* event)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_toolTipManager != 0) {
|
||||
m_toolTipManager->hideTip();
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinColumnView::contextMenuEvent(QContextMenuEvent* event)
|
||||
|
@ -413,10 +403,6 @@ void DolphinColumnView::contextMenuEvent(QContextMenuEvent* event)
|
|||
clearSelection();
|
||||
}
|
||||
|
||||
if (m_toolTipManager != 0) {
|
||||
m_toolTipManager->hideTip();
|
||||
}
|
||||
|
||||
const QPoint pos = m_container->viewport()->mapFromGlobal(event->globalPos());
|
||||
Q_ASSERT(m_container->m_controller->itemView() == this);
|
||||
m_container->m_controller->triggerContextMenuRequest(pos);
|
||||
|
|
|
@ -34,11 +34,10 @@ class DolphinModel;
|
|||
class DolphinSortFilterProxyModel;
|
||||
class DolphinDirLister;
|
||||
class DolphinViewAutoScroller;
|
||||
class KFilePreviewGenerator;
|
||||
class KFileItem;
|
||||
class KFileItemList;
|
||||
class SelectionManager;
|
||||
class ToolTipManager;
|
||||
class ViewExtensionsFactory;
|
||||
|
||||
/**
|
||||
* Represents one column inside the DolphinColumnViewContainer.
|
||||
|
@ -127,6 +126,7 @@ private:
|
|||
DolphinColumnViewContainer* m_container;
|
||||
SelectionManager* m_selectionManager;
|
||||
DolphinViewAutoScroller* m_autoScroller;
|
||||
ViewExtensionsFactory* m_extensionsFactory;
|
||||
KUrl m_url; // URL of the directory that is shown
|
||||
KUrl m_childUrl; // URL of the next column that is shown
|
||||
|
||||
|
@ -137,10 +137,6 @@ private:
|
|||
DolphinModel* m_dolphinModel;
|
||||
DolphinSortFilterProxyModel* m_proxyModel;
|
||||
|
||||
KFilePreviewGenerator* m_previewGenerator;
|
||||
|
||||
ToolTipManager* m_toolTipManager;
|
||||
|
||||
QRect m_dropRect;
|
||||
|
||||
friend class DolphinColumnViewContainer;
|
||||
|
|
|
@ -26,13 +26,12 @@
|
|||
|
||||
#include "dolphin_columnmodesettings.h"
|
||||
|
||||
#include <kfilepreviewgenerator.h>
|
||||
|
||||
#include <QPoint>
|
||||
#include <QScrollBar>
|
||||
#include <QTimeLine>
|
||||
|
||||
DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent, DolphinController* controller) :
|
||||
DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
|
||||
DolphinController* controller) :
|
||||
QScrollArea(parent),
|
||||
m_controller(controller),
|
||||
m_active(false),
|
||||
|
@ -358,8 +357,6 @@ void DolphinColumnViewContainer::deleteColumn(DolphinColumnView* column)
|
|||
}
|
||||
// deleteWhenNotDragSource(column) does not necessarily delete column,
|
||||
// and we want its preview generator destroyed immediately.
|
||||
column->m_previewGenerator->deleteLater();
|
||||
column->m_previewGenerator = 0;
|
||||
column->hide();
|
||||
// Prevent automatic destruction of column when this DolphinColumnViewContainer
|
||||
// is destroyed.
|
||||
|
|
|
@ -44,7 +44,8 @@ class DolphinColumnViewContainer : public QScrollArea
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DolphinColumnViewContainer(QWidget* parent, DolphinController* controller);
|
||||
explicit DolphinColumnViewContainer(QWidget* parent,
|
||||
DolphinController* controller);
|
||||
virtual ~DolphinColumnViewContainer();
|
||||
|
||||
KUrl rootUrl() const;
|
||||
|
|
|
@ -46,6 +46,7 @@ void DolphinController::setUrl(const KUrl& url)
|
|||
{
|
||||
if (m_url != url) {
|
||||
m_url = url;
|
||||
emit cancelPreviews();
|
||||
emit urlChanged(url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,8 +67,6 @@ class QPoint;
|
|||
*
|
||||
* The communication of the abstract view to the view implementations is done by:
|
||||
* - setUrl()
|
||||
* - setShowHiddenFiles()
|
||||
* - setShowPreview()
|
||||
* - indicateActivationChange()
|
||||
* - setNameFilter()
|
||||
* - setZoomLevel()
|
||||
|
@ -397,6 +395,11 @@ signals:
|
|||
*/
|
||||
void hideToolTip();
|
||||
|
||||
/**
|
||||
* Is emitted if pending previews should be canceled (e. g. because of an URL change).
|
||||
*/
|
||||
void cancelPreviews();
|
||||
|
||||
private slots:
|
||||
void updateMouseButtonState();
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "dolphinviewautoscroller.h"
|
||||
#include "draganddrophelper.h"
|
||||
#include "selectionmanager.h"
|
||||
#include "viewextensionsfactory.h"
|
||||
#include "viewproperties.h"
|
||||
#include "zoomlevelinfo.h"
|
||||
|
||||
|
@ -45,7 +46,9 @@
|
|||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
|
||||
DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* controller) :
|
||||
DolphinDetailsView::DolphinDetailsView(QWidget* parent,
|
||||
DolphinController* controller,
|
||||
DolphinSortFilterProxyModel* proxyModel) :
|
||||
QTreeView(parent),
|
||||
m_autoResize(true),
|
||||
m_expandingTogglePressed(false),
|
||||
|
@ -55,6 +58,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
|
|||
m_controller(controller),
|
||||
m_selectionManager(0),
|
||||
m_autoScroller(0),
|
||||
m_extensionsFactory(0),
|
||||
m_expandableFoldersAction(0),
|
||||
m_font(),
|
||||
m_decorationSize(),
|
||||
|
@ -75,6 +79,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
|
|||
setRootIsDecorated(settings->expandableFolders());
|
||||
setItemsExpandable(settings->expandableFolders());
|
||||
setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
setModel(proxyModel);
|
||||
|
||||
setMouseTracking(true);
|
||||
m_autoScroller = new DolphinViewAutoScroller(this);
|
||||
|
@ -160,6 +165,8 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
|
|||
m_expandableFoldersAction->setCheckable(true);
|
||||
connect(m_expandableFoldersAction, SIGNAL(toggled(bool)),
|
||||
this, SLOT(setFoldersExpandable(bool)));
|
||||
|
||||
m_extensionsFactory = new ViewExtensionsFactory(this, controller);
|
||||
}
|
||||
|
||||
DolphinDetailsView::~DolphinDetailsView()
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
|
||||
class DolphinController;
|
||||
class SelectionManager;
|
||||
class DolphinSortFilterProxyModel;
|
||||
class DolphinViewAutoScroller;
|
||||
class ViewExtensionsFactory;
|
||||
|
||||
/**
|
||||
* @brief Represents the details view which shows the name, size,
|
||||
|
@ -42,7 +44,9 @@ class LIBDOLPHINPRIVATE_EXPORT DolphinDetailsView : public QTreeView
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DolphinDetailsView(QWidget* parent, DolphinController* controller);
|
||||
explicit DolphinDetailsView(QWidget* parent,
|
||||
DolphinController* controller,
|
||||
DolphinSortFilterProxyModel* model);
|
||||
virtual ~DolphinDetailsView();
|
||||
|
||||
protected:
|
||||
|
@ -202,6 +206,7 @@ private:
|
|||
DolphinController* m_controller;
|
||||
SelectionManager* m_selectionManager;
|
||||
DolphinViewAutoScroller* m_autoScroller;
|
||||
ViewExtensionsFactory* m_extensionsFactory;
|
||||
QAction* m_expandableFoldersAction;
|
||||
|
||||
QFont m_font;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "dolphin_generalsettings.h"
|
||||
#include "draganddrophelper.h"
|
||||
#include "selectionmanager.h"
|
||||
#include "viewextensionsfactory.h"
|
||||
#include "zoomlevelinfo.h"
|
||||
|
||||
#include <kcategorizedsortfilterproxymodel.h>
|
||||
|
@ -39,12 +40,15 @@
|
|||
#include <QApplication>
|
||||
#include <QScrollBar>
|
||||
|
||||
DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) :
|
||||
DolphinIconsView::DolphinIconsView(QWidget* parent,
|
||||
DolphinController* controller,
|
||||
DolphinSortFilterProxyModel* proxyModel) :
|
||||
KCategorizedView(parent),
|
||||
m_controller(controller),
|
||||
m_selectionManager(0),
|
||||
m_autoScroller(0),
|
||||
m_categoryDrawer(0),
|
||||
m_extensionsFactory(0),
|
||||
m_font(),
|
||||
m_decorationSize(),
|
||||
m_decorationPosition(QStyleOptionViewItem::Top),
|
||||
|
@ -53,6 +57,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
|
|||
m_dropRect()
|
||||
{
|
||||
Q_ASSERT(controller != 0);
|
||||
setModel(proxyModel);
|
||||
setLayoutDirection(Qt::LeftToRight);
|
||||
setViewMode(QListView::IconMode);
|
||||
setResizeMode(QListView::Adjust);
|
||||
|
@ -130,6 +135,8 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
|
|||
|
||||
connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)),
|
||||
this, SLOT(slotGlobalSettingsChanged(int)));
|
||||
|
||||
m_extensionsFactory = new ViewExtensionsFactory(this, controller);
|
||||
}
|
||||
|
||||
DolphinIconsView::~DolphinIconsView()
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
class DolphinController;
|
||||
class SelectionManager;
|
||||
class DolphinCategoryDrawer;
|
||||
class DolphinSortFilterProxyModel;
|
||||
class DolphinViewAutoScroller;
|
||||
class ViewExtensionsFactory;
|
||||
|
||||
/**
|
||||
* @brief Represents the view, where each item is shown as an icon.
|
||||
|
@ -47,7 +49,9 @@ class LIBDOLPHINPRIVATE_EXPORT DolphinIconsView : public KCategorizedView
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DolphinIconsView(QWidget* parent, DolphinController* controller);
|
||||
explicit DolphinIconsView(QWidget* parent,
|
||||
DolphinController* controller,
|
||||
DolphinSortFilterProxyModel* proxyModel);
|
||||
virtual ~DolphinIconsView();
|
||||
|
||||
protected slots:
|
||||
|
@ -96,6 +100,7 @@ private:
|
|||
SelectionManager* m_selectionManager;
|
||||
DolphinViewAutoScroller* m_autoScroller;
|
||||
DolphinCategoryDrawer* m_categoryDrawer;
|
||||
ViewExtensionsFactory* m_extensionsFactory;
|
||||
|
||||
QFont m_font;
|
||||
QSize m_decorationSize;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include <kactioncollection.h>
|
||||
#include <kcolorscheme.h>
|
||||
#include <kdirlister.h>
|
||||
#include <kfilepreviewgenerator.h>
|
||||
#include <kiconeffect.h>
|
||||
#include <kfileitem.h>
|
||||
#include <klocale.h>
|
||||
|
@ -62,7 +61,6 @@
|
|||
#include "draganddrophelper.h"
|
||||
#include "folderexpander.h"
|
||||
#include "renamedialog.h"
|
||||
#include "tooltips/tooltipmanager.h"
|
||||
#include "settings/dolphinsettings.h"
|
||||
#include "versioncontrolobserver.h"
|
||||
#include "viewproperties.h"
|
||||
|
@ -96,8 +94,6 @@ DolphinView::DolphinView(QWidget* parent,
|
|||
m_viewAccessor(proxyModel),
|
||||
m_selectionModel(0),
|
||||
m_selectionChangedTimer(0),
|
||||
m_previewGenerator(0),
|
||||
m_toolTipManager(0),
|
||||
m_versionControlObserver(0),
|
||||
m_rootUrl(),
|
||||
m_activeItemUrl(),
|
||||
|
@ -388,7 +384,6 @@ void DolphinView::setZoomLevel(int level)
|
|||
|
||||
if (level != zoomLevel()) {
|
||||
m_controller->setZoomLevel(level);
|
||||
m_previewGenerator->updateIcons();
|
||||
emit zoomLevelChanged(level);
|
||||
}
|
||||
}
|
||||
|
@ -483,7 +478,6 @@ void DolphinView::updateView(const KUrl& url, const KUrl& rootUrl)
|
|||
return;
|
||||
}
|
||||
|
||||
m_previewGenerator->cancelPreviews();
|
||||
m_controller->setUrl(url); // emits urlChanged, which we forward
|
||||
if (m_viewAccessor.prepareUrlChange(url)) {
|
||||
initializeView();
|
||||
|
@ -754,8 +748,6 @@ void DolphinView::setShowPreview(bool show)
|
|||
props.setShowPreview(show);
|
||||
|
||||
m_showPreview = show;
|
||||
m_previewGenerator->setPreviewShown(show);
|
||||
|
||||
const int oldZoomLevel = m_controller->zoomLevel();
|
||||
emit showPreviewChanged();
|
||||
|
||||
|
@ -886,10 +878,6 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event)
|
|||
|
||||
case QEvent::KeyPress:
|
||||
if (watched == m_viewAccessor.itemView()) {
|
||||
if (m_toolTipManager != 0) {
|
||||
m_toolTipManager->hideTip();
|
||||
}
|
||||
|
||||
// clear the selection when Escape has been pressed
|
||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
||||
if (keyEvent->key() == Qt::Key_Escape) {
|
||||
|
@ -924,9 +912,6 @@ void DolphinView::triggerItem(const KFileItem& item)
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_toolTipManager != 0) {
|
||||
m_toolTipManager->hideTip();
|
||||
}
|
||||
emit itemTriggered(item); // caught by DolphinViewContainer or DolphinPart
|
||||
}
|
||||
|
||||
|
@ -953,10 +938,6 @@ void DolphinView::openContextMenu(const QPoint& pos,
|
|||
item = m_viewAccessor.dirModel()->itemForIndex(dolphinModelIndex);
|
||||
}
|
||||
|
||||
if (m_toolTipManager != 0) {
|
||||
m_toolTipManager->hideTip();
|
||||
}
|
||||
|
||||
m_isContextMenuOpen = true; // TODO: workaround for Qt-issue 207192
|
||||
emit requestContextMenu(item, url(), customActions);
|
||||
m_isContextMenuOpen = false;
|
||||
|
@ -1300,8 +1281,6 @@ void DolphinView::applyViewProperties()
|
|||
const bool showPreview = props.showPreview();
|
||||
if (showPreview != m_showPreview) {
|
||||
m_showPreview = showPreview;
|
||||
m_previewGenerator->setPreviewShown(showPreview);
|
||||
|
||||
const int oldZoomLevel = m_controller->zoomLevel();
|
||||
emit showPreviewChanged();
|
||||
|
||||
|
@ -1342,11 +1321,6 @@ void DolphinView::deleteView()
|
|||
m_topLayout->removeWidget(view);
|
||||
view->close();
|
||||
|
||||
// m_previewGenerator's parent is not always destroyed, and we
|
||||
// don't want two active at once - manually delete.
|
||||
delete m_previewGenerator;
|
||||
m_previewGenerator = 0;
|
||||
|
||||
disconnect(view);
|
||||
m_controller->disconnect(view);
|
||||
view->disconnect();
|
||||
|
@ -1357,7 +1331,6 @@ void DolphinView::deleteView()
|
|||
|
||||
m_viewAccessor.deleteView();
|
||||
m_fileItemDelegate = 0;
|
||||
m_toolTipManager = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1412,9 +1385,6 @@ void DolphinView::initializeView()
|
|||
|
||||
view->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
||||
m_previewGenerator = new KFilePreviewGenerator(view);
|
||||
m_previewGenerator->setPreviewShown(m_showPreview);
|
||||
|
||||
m_versionControlObserver = new VersionControlObserver(view);
|
||||
connect(m_versionControlObserver, SIGNAL(infoMessage(const QString&)),
|
||||
this, SIGNAL(infoMessage(const QString&)));
|
||||
|
@ -1423,12 +1393,6 @@ void DolphinView::initializeView()
|
|||
connect(m_versionControlObserver, SIGNAL(operationCompletedMessage(const QString&)),
|
||||
this, SIGNAL(operationCompletedMessage(const QString&)));
|
||||
|
||||
if (DolphinSettings::instance().generalSettings()->showToolTips()) {
|
||||
m_toolTipManager = new ToolTipManager(view, m_viewAccessor.proxyModel());
|
||||
connect(m_controller, SIGNAL(hideToolTip()),
|
||||
m_toolTipManager, SLOT(hideTip()));
|
||||
}
|
||||
|
||||
connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
||||
this, SLOT(emitDelayedSelectionChangedSignal()));
|
||||
connect(view->verticalScrollBar(), SIGNAL(valueChanged(int)),
|
||||
|
@ -1493,11 +1457,11 @@ void DolphinView::ViewAccessor::createView(QWidget* parent,
|
|||
|
||||
switch (mode) {
|
||||
case IconsView:
|
||||
m_iconsView = new DolphinIconsView(parent, controller);
|
||||
m_iconsView = new DolphinIconsView(parent, controller, m_proxyModel);
|
||||
break;
|
||||
|
||||
case DetailsView:
|
||||
m_detailsView = new DolphinDetailsView(parent, controller);
|
||||
m_detailsView = new DolphinDetailsView(parent, controller, m_proxyModel);
|
||||
break;
|
||||
|
||||
case ColumnView:
|
||||
|
|
|
@ -54,7 +54,6 @@ class KAction;
|
|||
class KActionCollection;
|
||||
class KDirLister;
|
||||
class KUrl;
|
||||
class ToolTipManager;
|
||||
class VersionControlObserver;
|
||||
class ViewProperties;
|
||||
|
||||
|
@ -824,9 +823,6 @@ private:
|
|||
QItemSelectionModel* m_selectionModel;
|
||||
QTimer* m_selectionChangedTimer;
|
||||
|
||||
KFilePreviewGenerator* m_previewGenerator;
|
||||
ToolTipManager* m_toolTipManager;
|
||||
|
||||
VersionControlObserver* m_versionControlObserver;
|
||||
|
||||
KUrl m_rootUrl;
|
||||
|
|
|
@ -86,6 +86,7 @@ ToolTipManager::ToolTipManager(QAbstractItemView* parent,
|
|||
this, SLOT(hideTip()));
|
||||
|
||||
m_view->viewport()->installEventFilter(this);
|
||||
m_view->installEventFilter(this);
|
||||
}
|
||||
|
||||
ToolTipManager::~ToolTipManager()
|
||||
|
@ -99,7 +100,16 @@ void ToolTipManager::hideTip()
|
|||
|
||||
bool ToolTipManager::eventFilter(QObject* watched, QEvent* event)
|
||||
{
|
||||
if ((watched == m_view->viewport()) && (event->type() == QEvent::Leave)) {
|
||||
if (watched == m_view->viewport()) {
|
||||
switch (event->type()) {
|
||||
case QEvent::Leave:
|
||||
case QEvent::MouseButtonPress:
|
||||
hideToolTip();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if ((watched == m_view) && (event->type() == QEvent::KeyPress)) {
|
||||
hideToolTip();
|
||||
}
|
||||
|
||||
|
|
79
src/viewextensionsfactory.cpp
Normal file
79
src/viewextensionsfactory.cpp
Normal file
|
@ -0,0 +1,79 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2009 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 "viewextensionsfactory.h"
|
||||
|
||||
#include "dolphincontroller.h"
|
||||
#include "dolphinsortfilterproxymodel.h"
|
||||
#include "dolphinview.h"
|
||||
#include "settings/dolphinsettings.h"
|
||||
#include "tooltips/tooltipmanager.h"
|
||||
|
||||
#include "dolphin_generalsettings.h"
|
||||
|
||||
#include <kfilepreviewgenerator.h>
|
||||
#include <QAbstractItemView>
|
||||
|
||||
ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
|
||||
DolphinController* controller) :
|
||||
QObject(view),
|
||||
m_controller(controller),
|
||||
m_toolTipManager(0),
|
||||
m_previewGenerator(0)
|
||||
{
|
||||
if (DolphinSettings::instance().generalSettings()->showToolTips()) {
|
||||
DolphinSortFilterProxyModel* proxyModel = static_cast<DolphinSortFilterProxyModel*>(view->model());
|
||||
m_toolTipManager = new ToolTipManager(view, proxyModel);
|
||||
|
||||
connect(controller, SIGNAL(hideToolTip()),
|
||||
m_toolTipManager, SLOT(hideTip()));
|
||||
}
|
||||
|
||||
m_previewGenerator = new KFilePreviewGenerator(view);
|
||||
m_previewGenerator->setPreviewShown(controller->dolphinView()->showPreview());
|
||||
connect(controller, SIGNAL(zoomLevelChanged(int)),
|
||||
this, SLOT(updateIcons()));
|
||||
connect(controller, SIGNAL(cancelPreviews()),
|
||||
this, SLOT(cancelPreviews()));
|
||||
connect(controller->dolphinView(), SIGNAL(showPreviewChanged()),
|
||||
this, SLOT(slotShowPreviewChanged()));
|
||||
}
|
||||
|
||||
ViewExtensionsFactory::~ViewExtensionsFactory()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewExtensionsFactory::updateIcons()
|
||||
{
|
||||
m_previewGenerator->updateIcons();
|
||||
}
|
||||
|
||||
void ViewExtensionsFactory::cancelPreviews()
|
||||
{
|
||||
m_previewGenerator->cancelPreviews();
|
||||
}
|
||||
|
||||
void ViewExtensionsFactory::slotShowPreviewChanged()
|
||||
{
|
||||
const bool show = m_controller->dolphinView()->showPreview();
|
||||
m_previewGenerator->setPreviewShown(show);
|
||||
}
|
||||
|
||||
#include "viewextensionsfactory.moc"
|
||||
|
59
src/viewextensionsfactory.h
Normal file
59
src/viewextensionsfactory.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2009 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 VIEWEXTENSIONSFACTORY_H
|
||||
#define VIEWEXTENSIONSFACTORY_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class DolphinController;
|
||||
class KFilePreviewGenerator;
|
||||
class ToolTipManager;
|
||||
class QAbstractItemView;
|
||||
|
||||
class ViewExtensionsFactory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ViewExtensionsFactory(QAbstractItemView* view,
|
||||
DolphinController* controller);
|
||||
virtual ~ViewExtensionsFactory();
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* Tells the preview generator to update all icons.
|
||||
*/
|
||||
void updateIcons();
|
||||
|
||||
/**
|
||||
* Tells the preview generator to cancel all pending previews.
|
||||
*/
|
||||
void cancelPreviews();
|
||||
|
||||
void slotShowPreviewChanged();
|
||||
|
||||
private:
|
||||
DolphinController* m_controller;
|
||||
ToolTipManager* m_toolTipManager;
|
||||
KFilePreviewGenerator* m_previewGenerator;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in a new issue