m_topLayout(0),
m_controller(0),
m_viewAccessor(proxyModel),
+ m_selectionModel(0),
m_selectionChangedTimer(0),
m_versionControlObserver(0),
m_rootUrl(),
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.
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*)),
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);
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)