┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dolphincolumnviewcontainer.cpp42
-rw-r--r--src/dolphincolumnviewcontainer.h8
-rw-r--r--src/dolphindetailsview.cpp1
-rw-r--r--src/dolphinview.cpp104
-rw-r--r--src/dolphinview.h12
-rw-r--r--src/folderexpander.cpp17
-rw-r--r--src/viewextensionsfactory.cpp20
-rw-r--r--src/viewextensionsfactory.h9
8 files changed, 98 insertions, 115 deletions
diff --git a/src/dolphincolumnviewcontainer.cpp b/src/dolphincolumnviewcontainer.cpp
index c1b51280b..3e067d413 100644
--- a/src/dolphincolumnviewcontainer.cpp
+++ b/src/dolphincolumnviewcontainer.cpp
@@ -22,6 +22,7 @@
#include "dolphincolumnview.h"
#include "dolphincontroller.h"
#include "dolphinsortfilterproxymodel.h"
+#include "draganddrophelper.h"
#include "settings/dolphinsettings.h"
#include "dolphin_columnmodesettings.h"
@@ -39,7 +40,8 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
m_contentX(0),
m_columns(),
m_emptyViewport(0),
- m_animation(0)
+ m_animation(0),
+ m_dragSource(0)
{
Q_ASSERT(controller != 0);
@@ -48,8 +50,6 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
setFrameShape(QFrame::NoFrame);
setLayoutDirection(Qt::LeftToRight);
- //connect(this, SIGNAL(viewportEntered()),
- // controller, SLOT(emitViewportEntered()));
connect(controller, SIGNAL(activationChanged(bool)),
this, SLOT(updateColumnsBackground(bool)));
@@ -71,6 +71,8 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
DolphinColumnViewContainer::~DolphinColumnViewContainer()
{
+ delete m_dragSource;
+ m_dragSource = 0;
}
KUrl DolphinColumnViewContainer::rootUrl() const
@@ -358,19 +360,37 @@ QPoint DolphinColumnViewContainer::columnPosition(DolphinColumnView* column, con
void DolphinColumnViewContainer::deleteColumn(DolphinColumnView* column)
{
- if (column != 0) {
- if (m_controller->itemView() == column) {
- m_controller->setItemView(0);
+ if (column == 0) {
+ return;
+ }
+
+ if (m_controller->itemView() == column) {
+ m_controller->setItemView(0);
+ }
+ // deleteWhenNotDragSource(column) does not necessarily delete column,
+ // and we want its preview generator destroyed immediately.
+ column->hide();
+ // Prevent automatic destruction of column when this DolphinColumnViewContainer
+ // is destroyed.
+ column->setParent(0);
+ column->disconnect();
+
+ if (DragAndDropHelper::instance().isDragSource(column)) {
+ // The column is a drag source (the feature "Open folders
+ // during drag operations" is used). Deleting the view
+ // during an ongoing drag operation is not allowed, so
+ // this will postponed.
+ if (m_dragSource != 0) {
+ // the old stored view is obviously not the drag source anymore
+ m_dragSource->deleteLater();
+ m_dragSource = 0;
}
- // deleteWhenNotDragSource(column) does not necessarily delete column,
- // and we want its preview generator destroyed immediately.
column->hide();
- // Prevent automatic destruction of column when this DolphinColumnViewContainer
- // is destroyed.
column->setParent(0);
column->disconnect();
- //emit requestColumnDeletion(column);
+ m_dragSource = column;
+ } else {
column->deleteLater();
}
}
diff --git a/src/dolphincolumnviewcontainer.h b/src/dolphincolumnviewcontainer.h
index 72a65b4a9..626cd98a1 100644
--- a/src/dolphincolumnviewcontainer.h
+++ b/src/dolphincolumnviewcontainer.h
@@ -58,13 +58,6 @@ public:
*/
void showColumn(const KUrl& url);
-signals:
- /**
- * Requests that the given column be deleted at the discretion
- * of the receiver of the signal.
- */
- void requestColumnDeletion(QAbstractItemView* column);
-
protected:
virtual void mousePressEvent(QMouseEvent* event);
virtual void keyPressEvent(QKeyEvent* event);
@@ -132,6 +125,7 @@ private:
QList<DolphinColumnView*> m_columns;
QFrame* m_emptyViewport;
QTimeLine* m_animation;
+ QAbstractItemView* m_dragSource;
friend class DolphinColumnView;
};
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index f0671db55..088e5dc7e 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -153,6 +153,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent,
m_extensionsFactory = new ViewExtensionsFactory(this, controller);
m_extensionsFactory->fileItemDelegate()->setMinimizedNameColumn(true);
+ m_extensionsFactory->setAutoFolderExpandingEnabled(settings->expandableFolders());
updateDecorationSize(view->showPreview());
}
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index 7e8b4e74f..dff8120c7 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -60,7 +60,6 @@
#include "dolphiniconsview.h"
#include "dolphin_generalsettings.h"
#include "draganddrophelper.h"
-#include "folderexpander.h"
#include "renamedialog.h"
#include "settings/dolphinsettings.h"
#include "viewproperties.h"
@@ -97,8 +96,7 @@ DolphinView::DolphinView(QWidget* parent,
m_activeItemUrl(),
m_createdItemUrl(),
m_selectedItems(),
- m_newFileNames(),
- m_expandedDragSource(0)
+ m_newFileNames()
{
m_topLayout = new QVBoxLayout(this);
m_topLayout->setSpacing(0);
@@ -161,8 +159,6 @@ DolphinView::DolphinView(QWidget* parent,
DolphinView::~DolphinView()
{
- delete m_expandedDragSource;
- m_expandedDragSource = 0;
}
const KUrl& DolphinView::url() const
@@ -854,18 +850,6 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event)
}
break;
- case QEvent::MouseButtonPress:
- if ((watched == m_viewAccessor.itemView()->viewport()) && (m_expandedDragSource != 0)) {
- // Listening to a mousebutton press event to delete expanded views is a
- // workaround, as it seems impossible for the FolderExpander to know when
- // a dragging outside a view has been finished. However it works quite well:
- // A mousebutton press event indicates that a drag operation must be
- // finished already.
- m_expandedDragSource->deleteLater();
- m_expandedDragSource = 0;
- }
- break;
-
case QEvent::DragEnter:
if (watched == m_viewAccessor.itemView()->viewport()) {
setActive(true);
@@ -1065,26 +1049,6 @@ bool DolphinView::itemsExpandable() const
return m_viewAccessor.itemsExpandable();
}
-void DolphinView::deleteWhenNotDragSource(QAbstractItemView *view)
-{
- if (view == 0)
- return;
-
- if (DragAndDropHelper::instance().isDragSource(view)) {
- // We must store for later deletion.
- if (m_expandedDragSource != 0) {
- // The old stored view is obviously not the drag source anymore.
- m_expandedDragSource->deleteLater();
- m_expandedDragSource = 0;
- }
- view->hide();
- m_expandedDragSource = view;
- }
- else {
- view->deleteLater();
- }
-}
-
void DolphinView::observeCreatedItem(const KUrl& url)
{
m_createdItemUrl = url;
@@ -1305,26 +1269,9 @@ void DolphinView::createView()
view->installEventFilter(this);
view->viewport()->installEventFilter(this);
-
- /* TODO: enable folder expanding again later
-
- if (m_mode != ColumnView) {
- // Give the view the ability to auto-expand its directories on hovering
- // (the column view takes care about this itself). If the details view
- // uses expandable folders, the auto-expanding should be used always.
- FolderExpander* folderExpander = new FolderExpander(view, m_viewAccessor.proxyModel());
- folderExpander->setEnabled(m_viewAccessor.hasExpandableFolders());
- connect(folderExpander, SIGNAL(enterDir(const QModelIndex&)),
- m_controller, SLOT(triggerItem(const QModelIndex&)));
-
- }
- else {
- // Listen out for requests to delete the current column.
- connect(m_viewAccessor.columnsContainer(), SIGNAL(requestColumnDeletion(QAbstractItemView*)),
- this, SLOT(deleteWhenNotDragSource(QAbstractItemView*)));
- }*/
-
m_controller->setItemView(view);
+ connect(m_controller, SIGNAL(selectionChanged()),
+ this, SLOT(emitDelayedSelectionChangedSignal()));
// 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
@@ -1336,8 +1283,6 @@ void DolphinView::createView()
}
m_selectionModel->setParent(this);
- connect(m_controller, SIGNAL(selectionChanged()),
- this, SLOT(emitDelayedSelectionChangedSignal()));
connect(view->verticalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(emitContentsMoved()));
connect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)),
@@ -1365,10 +1310,6 @@ void DolphinView::deleteView()
m_controller->disconnect(view);
view->disconnect();
- // TODO: move this code into ViewAccessor::deleteView()
- deleteWhenNotDragSource(view);
- view = 0;
-
m_viewAccessor.deleteView();
}
}
@@ -1417,10 +1358,17 @@ DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel* proxyModel)
m_iconsView(0),
m_detailsView(0),
m_columnsContainer(0),
- m_proxyModel(proxyModel)
+ m_proxyModel(proxyModel),
+ m_dragSource(0)
{
}
+DolphinView::ViewAccessor::~ViewAccessor()
+{
+ delete m_dragSource;
+ m_dragSource = 0;
+}
+
void DolphinView::ViewAccessor::createView(QWidget* parent,
DolphinController* controller,
Mode mode)
@@ -1447,9 +1395,25 @@ void DolphinView::ViewAccessor::createView(QWidget* parent,
void DolphinView::ViewAccessor::deleteView()
{
- // TODO: Move the deleteWhenNotDragSource() code into the view
- // accessor, so that creating and deleting is fully done by
- // the view accessor.
+ QAbstractItemView* view = itemView();
+ if (view != 0) {
+ if (DragAndDropHelper::instance().isDragSource(view)) {
+ // The view is a drag source (the feature "Open folders
+ // during drag operations" is used). Deleting the view
+ // during an ongoing drag operation is not allowed, so
+ // this will postponed.
+ if (m_dragSource != 0) {
+ // the old stored view is obviously not the drag source anymore
+ m_dragSource->deleteLater();
+ m_dragSource = 0;
+ }
+ view->hide();
+ m_dragSource = view;
+ } else {
+ view->deleteLater();
+ }
+ }
+
m_iconsView = 0;
m_detailsView = 0;
@@ -1505,13 +1469,6 @@ bool DolphinView::ViewAccessor::supportsCategorizedSorting() const
return m_iconsView != 0;
}
-bool DolphinView::ViewAccessor::hasExpandableFolders() const
-{
- const DolphinSettings& settings = DolphinSettings::instance();
- return settings.generalSettings()->autoExpandFolders() ||
- ((m_detailsView != 0) && settings.detailsModeSettings()->expandableFolders());
-}
-
bool DolphinView::ViewAccessor::itemsExpandable() const
{
return (m_detailsView != 0) && m_detailsView->itemsExpandable();
@@ -1524,7 +1481,6 @@ bool DolphinView::ViewAccessor::reloadOnAdditionalInfoChange() const
return m_detailsView != 0;
}
-
DolphinModel* DolphinView::ViewAccessor::dirModel() const
{
return static_cast<DolphinModel*>(proxyModel()->sourceModel());
diff --git a/src/dolphinview.h b/src/dolphinview.h
index 822eb52b0..57bf5d2f9 100644
--- a/src/dolphinview.h
+++ b/src/dolphinview.h
@@ -675,13 +675,6 @@ private slots:
void slotRefreshItems();
/**
- * If \a view can be positively identified as not being the source for the
- * current drag operation, deleteLater() it immediately. Else stores
- * it for later deletion.
- */
- void deleteWhenNotDragSource(QAbstractItemView* view);
-
- /**
* Observes the item with the URL \a url. As soon as the directory
* model indicates that the item is available, the item will
* get selected and it is assure that the item stays visible.
@@ -761,6 +754,7 @@ private:
{
public:
ViewAccessor(DolphinSortFilterProxyModel* proxyModel);
+ ~ViewAccessor();
void createView(QWidget* parent, DolphinController* controller, Mode mode);
void deleteView();
@@ -784,7 +778,6 @@ private:
KUrl rootUrl() const;
bool supportsCategorizedSorting() const;
- bool hasExpandableFolders() const;
bool itemsExpandable() const;
/**
@@ -803,6 +796,7 @@ private:
DolphinDetailsView* m_detailsView;
DolphinColumnViewContainer* m_columnsContainer;
DolphinSortFilterProxyModel* m_proxyModel;
+ QAbstractItemView* m_dragSource;
};
bool m_active : 1;
@@ -836,8 +830,6 @@ private:
* slotDirListerCompleted().
*/
QSet<QString> m_newFileNames;
-
- QAbstractItemView* m_expandedDragSource; // TODO: move to ViewAccessor
};
/// Allow using DolphinView::Mode in QVariant
diff --git a/src/folderexpander.cpp b/src/folderexpander.cpp
index 7fe775944..a2dfb137b 100644
--- a/src/folderexpander.cpp
+++ b/src/folderexpander.cpp
@@ -18,10 +18,6 @@
***************************************************************************/
#include "folderexpander.h"
-#include "dolphinview.h"
-
-#include "settings/dolphinsettings.h"
-#include "dolphin_generalsettings.h"
#include <QtCore/QTimer>
#include <QtGui/QAbstractItemView>
@@ -43,20 +39,15 @@ FolderExpander::FolderExpander(QAbstractItemView *view, QSortFilterProxyModel *p
m_autoExpandTriggerTimer(0),
m_autoExpandPos()
{
- // Validation. If these fail, the event filter is never
- // installed on the view and the FolderExpander is inactive.
if (m_view == 0) {
- kWarning() << "Need a view!";
- return; // Not valid.
+ return;
}
if (m_proxyModel == 0) {
- kWarning() << "Need a proxyModel!";
- return; // Not valid.
+ return;
}
- KDirModel *m_dirModel = qobject_cast< KDirModel* >( m_proxyModel->sourceModel() );
+ KDirModel *m_dirModel = qobject_cast<KDirModel*>(m_proxyModel->sourceModel());
if (m_dirModel == 0) {
- kWarning() << "Expected m_proxyModel's sourceModel() to be a KDirModel!";
- return; // Not valid.
+ return;
}
// Initialise auto-expand timer.
diff --git a/src/viewextensionsfactory.cpp b/src/viewextensionsfactory.cpp
index b8606d65b..a6555ae0b 100644
--- a/src/viewextensionsfactory.cpp
+++ b/src/viewextensionsfactory.cpp
@@ -24,6 +24,7 @@
#include "dolphinsortfilterproxymodel.h"
#include "dolphinview.h"
#include "dolphinviewautoscroller.h"
+#include "folderexpander.h"
#include "selectionmanager.h"
#include "settings/dolphinsettings.h"
#include "tooltips/tooltipmanager.h"
@@ -114,6 +115,15 @@ ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
controller, SLOT(emitSelectionChanged()));
+ // Give the view the ability to auto-expand its directories on hovering
+ // (the column view takes care about this itself). If the details view
+ // uses expandable folders, the auto-expanding should be used always.
+ m_folderExpander = new FolderExpander(view, proxyModel());
+ m_folderExpander->setEnabled(settings->autoExpandFolders());
+ connect(m_folderExpander, SIGNAL(enterDir(const QModelIndex&)),
+ controller, SLOT(triggerItem(const QModelIndex&)));
+
+ // react on namefilter changes
connect(controller, SIGNAL(nameFilterChanged(const QString&)),
this, SLOT(slotNameFilterChanged(const QString&)));
@@ -134,6 +144,16 @@ DolphinFileItemDelegate* ViewExtensionsFactory::fileItemDelegate() const
return m_fileItemDelegate;
}
+void ViewExtensionsFactory::setAutoFolderExpandingEnabled(bool enabled)
+{
+ m_folderExpander->setEnabled(enabled);
+}
+
+bool ViewExtensionsFactory::autoFolderExpandingEnabled() const
+{
+ return m_folderExpander->enabled();
+}
+
bool ViewExtensionsFactory::eventFilter(QObject* watched, QEvent* event)
{
Q_UNUSED(watched);
diff --git a/src/viewextensionsfactory.h b/src/viewextensionsfactory.h
index ddc1cf581..9187c10e3 100644
--- a/src/viewextensionsfactory.h
+++ b/src/viewextensionsfactory.h
@@ -29,6 +29,7 @@ class DolphinFileItemDelegate;
class DolphinSortFilterProxyModel;
class DolphinViewAutoScroller;
class KFilePreviewGenerator;
+class FolderExpander;
class QModelIndex;
class SelectionManager;
class ToolTipManager;
@@ -62,6 +63,13 @@ public:
DolphinFileItemDelegate* fileItemDelegate() const;
+ /**
+ * Enables the automatically expanding of a folder when dragging
+ * items above the folder.
+ */
+ void setAutoFolderExpandingEnabled(bool enabled);
+ bool autoFolderExpandingEnabled() const;
+
protected:
virtual bool eventFilter(QObject* watched, QEvent* event);
@@ -89,6 +97,7 @@ private:
DolphinViewAutoScroller* m_autoScroller;
DolphinFileItemDelegate* m_fileItemDelegate;
VersionControlObserver* m_versionControlObserver;
+ FolderExpander* m_folderExpander;
};
#endif