┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2009-08-29 12:51:04 +0000
committerPeter Penz <[email protected]>2009-08-29 12:51:04 +0000
commita5473c0cf255b5846ad85eebc043ebb6551e72d0 (patch)
tree19a1ca8360c102c6265e5cbcf6a8efb2c91e8ff2
parentb1536a43422d80300afe48172444dced06e03a70 (diff)
- restore functionality that selections are kept when changing the view mode
- some minor cleanups svn path=/trunk/KDE/kdebase/apps/; revision=1016955
-rw-r--r--src/dolphindetailsview.cpp3
-rw-r--r--src/dolphiniconsview.cpp2
-rw-r--r--src/dolphinview.cpp87
-rw-r--r--src/dolphinview.h4
-rw-r--r--src/viewextensionsfactory.cpp2
5 files changed, 46 insertions, 52 deletions
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index f8e589859..9d37fa674 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -139,7 +139,6 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent,
connect(view, SIGNAL(showPreviewChanged()),
this, SLOT(slotShowPreviewChanged()));
- updateDecorationSize(view->showPreview());
setFocus();
viewport()->installEventFilter(this);
@@ -156,6 +155,8 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent,
m_extensionsFactory = new ViewExtensionsFactory(this, controller);
m_extensionsFactory->fileItemDelegate()->setMinimizedNameColumn(true);
+
+ updateDecorationSize(view->showPreview());
}
DolphinDetailsView::~DolphinDetailsView()
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index efbcfd6fb..10ffd9d42 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -104,7 +104,6 @@ DolphinIconsView::DolphinIconsView(QWidget* parent,
}
setWordWrap(settings->numberOfTextlines() > 1);
- updateGridSize(view->showPreview(), 0);
if (settings->arrangement() == QListView::TopToBottom) {
setFlow(QListView::LeftToRight);
@@ -125,6 +124,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent,
this, SLOT(slotGlobalSettingsChanged(int)));
m_extensionsFactory = new ViewExtensionsFactory(this, controller);
+ updateGridSize(view->showPreview(), 0);
}
DolphinIconsView::~DolphinIconsView()
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index 929a3ed1c..19e01cb90 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -92,6 +92,7 @@ DolphinView::DolphinView(QWidget* parent,
m_topLayout(0),
m_controller(0),
m_viewAccessor(proxyModel),
+ m_selectionModel(0),
m_selectionChangedTimer(0),
m_versionControlObserver(0),
m_rootUrl(),
@@ -1300,45 +1301,16 @@ void DolphinView::createView()
deleteView();
Q_ASSERT(m_viewAccessor.itemView() == 0);
m_viewAccessor.createView(this, m_controller, m_mode);
- initializeView();
- m_topLayout->insertWidget(1, m_viewAccessor.layoutTarget());
-}
-void DolphinView::deleteView()
-{
- QAbstractItemView* view = m_viewAccessor.itemView();
- if (view != 0) {
- // It's important to set the keyboard focus to the parent
- // before deleting the view: Otherwise when having a split
- // view the other view will get the focus and will request
- // an activation (see DolphinView::eventFilter()).
- setFocusProxy(0);
- setFocus();
-
- m_topLayout->removeWidget(view);
- view->close();
-
- disconnect(view);
- m_controller->disconnect(view);
- view->disconnect();
-
- // TODO: move this code into ViewAccessor::deleteView()
- deleteWhenNotDragSource(view);
- view = 0;
-
- m_viewAccessor.deleteView();
- }
-}
-
-void DolphinView::initializeView()
-{
QAbstractItemView* view = m_viewAccessor.itemView();
Q_ASSERT(view != 0);
view->installEventFilter(this);
view->viewport()->installEventFilter(this);
setFocusProxy(view);
- //if (m_mode != ColumnView) {
+ /* 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.
@@ -1347,8 +1319,7 @@ void DolphinView::initializeView()
connect(folderExpander, SIGNAL(enterDir(const QModelIndex&)),
m_controller, SLOT(triggerItem(const QModelIndex&)));
- // TODO: enable again later
- /*}
+ }
else {
// Listen out for requests to delete the current column.
connect(m_viewAccessor.columnsContainer(), SIGNAL(requestColumnDeletion(QAbstractItemView*)),
@@ -1357,23 +1328,21 @@ void DolphinView::initializeView()
m_controller->setItemView(view);
- // TODO: reactivate selection model
- /*view->setModel(m_viewAccessor.proxyModel());
- if (m_selectionModel != 0) {
- view->setSelectionModel(m_selectionModel);
- } else {
- m_selectionModel = view->selectionModel();
- }*/
-
m_selectionChangedTimer = new QTimer(this);
m_selectionChangedTimer->setSingleShot(true);
m_selectionChangedTimer->setInterval(300);
connect(m_selectionChangedTimer, SIGNAL(timeout()),
this, SLOT(emitSelectionChangedSignal()));
- // reparent the selection model, as it should not be deleted
- // when deleting the model
- //m_selectionModel->setParent(this);
+ // 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
+ // selection model to DolphinView, so that it can be shared by all item views.
+ if (m_selectionModel != 0) {
+ view->setSelectionModel(m_selectionModel);
+ } else {
+ m_selectionModel = view->selectionModel();
+ }
+ m_selectionModel->setParent(this);
view->setSelectionMode(QAbstractItemView::ExtendedSelection);
@@ -1391,6 +1360,34 @@ void DolphinView::initializeView()
this, SLOT(emitContentsMoved()));
connect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(emitContentsMoved()));
+
+ m_topLayout->insertWidget(1, m_viewAccessor.layoutTarget());
+}
+
+void DolphinView::deleteView()
+{
+ QAbstractItemView* view = m_viewAccessor.itemView();
+ if (view != 0) {
+ // It's important to set the keyboard focus to the parent
+ // before deleting the view: Otherwise when having a split
+ // view the other view will get the focus and will request
+ // an activation (see DolphinView::eventFilter()).
+ setFocusProxy(0);
+ setFocus();
+
+ m_topLayout->removeWidget(view);
+ view->close();
+
+ disconnect(view);
+ m_controller->disconnect(view);
+ view->disconnect();
+
+ // TODO: move this code into ViewAccessor::deleteView()
+ deleteWhenNotDragSource(view);
+ view = 0;
+
+ m_viewAccessor.deleteView();
+ }
}
void DolphinView::pasteToUrl(const KUrl& url)
diff --git a/src/dolphinview.h b/src/dolphinview.h
index 08fe70e5f..b8c91333d 100644
--- a/src/dolphinview.h
+++ b/src/dolphinview.h
@@ -719,8 +719,6 @@ private:
void deleteView();
- void initializeView();
-
/**
* Helper method for DolphinView::paste() and DolphinView::pasteIntoFolder().
* Pastes the clipboard data into the URL \a url.
@@ -825,7 +823,7 @@ private:
DolphinController* m_controller;
ViewAccessor m_viewAccessor;
- QItemSelectionModel* m_selectionModel;
+ QItemSelectionModel* m_selectionModel; // allow to switch views without losing the selection
QTimer* m_selectionChangedTimer;
VersionControlObserver* m_versionControlObserver;
diff --git a/src/viewextensionsfactory.cpp b/src/viewextensionsfactory.cpp
index 198883d90..baaf3524a 100644
--- a/src/viewextensionsfactory.cpp
+++ b/src/viewextensionsfactory.cpp
@@ -75,8 +75,6 @@ ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
// initialize auto scroller
m_autoScroller = new DolphinViewAutoScroller(view);
- connect(controller, SIGNAL(currentIndexChanged(QModelIndex, QModelIndex)),
- m_autoScroller, SLOT(handleCurrentIndexChanged(QModelIndex, QModelIndex)));
// initialize file item delegate
m_fileItemDelegate = new DolphinFileItemDelegate(view);