connect(m_dolphinViewController, SIGNAL(urlChangeRequested(KUrl)),
m_viewModeController, SLOT(setUrl(KUrl)));
- KDirLister* dirLister = m_viewAccessor.dirLister();
- connect(dirLister, SIGNAL(redirection(KUrl,KUrl)),
- this, SLOT(slotRedirection(KUrl,KUrl)));
- connect(dirLister, SIGNAL(completed()),
- this, SLOT(slotDirListerCompleted()));
- connect(dirLister, SIGNAL(refreshItems(const QList<QPair<KFileItem,KFileItem>>&)),
- this, SLOT(slotRefreshItems()));
-
// When a new item has been created by the "Create New..." menu, the item should
// get selected and it must be assured that the item will get visible. As the
// creation is done asynchronously, several signals must be checked:
return;
}
- // The selection model might change in the case of the column view. Disconnect
- // from the current selection model and reconnect later after the URL switch.
const bool hadSelection = hasSelection();
- QAbstractItemView* view = m_viewAccessor.itemView();
- disconnect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
- this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
+
+ // The selection model and directory lister might change in the case of the column view:
+ disconnectViewAccessor();
m_newFileNames.clear();
emit startedPathLoading(url);
- // Reconnect to the (probably) new selection model
- view = m_viewAccessor.itemView();
- connect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
- this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
+ // Reconnect to the (probably) new selection model and directory lister
+ connectViewAccessor();
+
if (hadSelection || hasSelection()) {
emitSelectionChangedSignal();
}
const int zoomLevel = ZoomLevelInfo::zoomLevelForIconSize(view->iconSize());
m_viewModeController->setZoomLevel(zoomLevel);
- connect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
- this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
+ connectViewAccessor();
setFocusProxy(m_viewAccessor.layoutTarget());
m_topLayout->insertWidget(1, m_viewAccessor.layoutTarget());
m_dolphinViewController->setItemView(0);
if (view != 0) {
- if (view->selectionModel() != 0) {
- disconnect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
- this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
- }
+ disconnectViewAccessor();
// It's important to set the keyboard focus to the parent
// before deleting the view: Otherwise when having a split
return matchingIndexes;
}
+void DolphinView::connectViewAccessor()
+{
+ KDirLister* dirLister = m_viewAccessor.dirLister();
+ connect(dirLister, SIGNAL(redirection(KUrl,KUrl)),
+ this, SLOT(slotRedirection(KUrl,KUrl)));
+ connect(dirLister, SIGNAL(completed()),
+ this, SLOT(slotDirListerCompleted()));
+ connect(dirLister, SIGNAL(refreshItems(const QList<QPair<KFileItem,KFileItem>>&)),
+ this, SLOT(slotRefreshItems()));
+
+ QAbstractItemView* view = m_viewAccessor.itemView();
+ connect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
+ this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
+}
+
+void DolphinView::disconnectViewAccessor()
+{
+ KDirLister* dirLister = m_viewAccessor.dirLister();
+ disconnect(dirLister, SIGNAL(redirection(KUrl,KUrl)),
+ this, SLOT(slotRedirection(KUrl,KUrl)));
+ disconnect(dirLister, SIGNAL(completed()),
+ this, SLOT(slotDirListerCompleted()));
+ disconnect(dirLister, SIGNAL(refreshItems(const QList<QPair<KFileItem,KFileItem>>&)),
+ this, SLOT(slotRefreshItems()));
+
+ QAbstractItemView* view = m_viewAccessor.itemView();
+ disconnect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
+ this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection)));
+}
+
DolphinView::ViewAccessor::ViewAccessor(DolphinSortFilterProxyModel* proxyModel) :
m_rootUrl(),
m_iconsView(0),