X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/8cfe659711f1ea443d2c835154a7bddcd6ea72d3..f28ee3152a05f09abd117df19bb99d0966947e6b:/src/dolphindetailsview.cpp diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index d45282602..7c42d13fc 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -100,17 +100,19 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr if (KGlobalSettings::singleClick()) { connect(this, SIGNAL(clicked(const QModelIndex&)), controller, SLOT(triggerItem(const QModelIndex&))); - if (DolphinSettings::instance().generalSettings()->showSelectionToggle()) { - m_selectionManager = new SelectionManager(this); - connect(m_selectionManager, SIGNAL(selectionChanged()), - this, SLOT(requestActivation())); - connect(m_controller, SIGNAL(urlChanged(const KUrl&)), - m_selectionManager, SLOT(reset())); - } } else { connect(this, SIGNAL(doubleClicked(const QModelIndex&)), controller, SLOT(triggerItem(const QModelIndex&))); } + + if (DolphinSettings::instance().generalSettings()->showSelectionToggle()) { + m_selectionManager = new SelectionManager(this); + connect(m_selectionManager, SIGNAL(selectionChanged()), + this, SLOT(requestActivation())); + connect(m_controller, SIGNAL(urlChanged(const KUrl&)), + m_selectionManager, SLOT(reset())); + } + connect(this, SIGNAL(entered(const QModelIndex&)), this, SLOT(slotEntered(const QModelIndex&))); connect(this, SIGNAL(viewportEntered()), @@ -187,6 +189,7 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event) { m_controller->requestActivation(); + const QModelIndex current = currentIndex(); QTreeView::mousePressEvent(event); m_expandingTogglePressed = false; @@ -214,6 +217,9 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event) if (!(modifier & Qt::ShiftModifier) && !(modifier & Qt::ControlModifier)) { clearSelection(); } + + // restore the current index, other columns are handled as viewport area + selectionModel()->setCurrentIndex(current, QItemSelectionModel::Current); } if ((event->button() == Qt::LeftButton) && !m_expandingTogglePressed) { @@ -269,7 +275,18 @@ void DolphinDetailsView::mouseMoveEvent(QMouseEvent* event) void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event) { - QTreeView::mouseReleaseEvent(event); + const QModelIndex index = indexAt(event->pos()); + if (index.isValid() && (index.column() == DolphinModel::Name)) { + QTreeView::mouseReleaseEvent(event); + } else { + // don't change the current index if the cursor is released + // above any other column than the name column, as the other + // columns act as viewport + const QModelIndex current = currentIndex(); + QTreeView::mouseReleaseEvent(event); + selectionModel()->setCurrentIndex(current, QItemSelectionModel::Current); + } + m_expandingTogglePressed = false; if (m_showElasticBand) { updateElasticBand(); @@ -363,7 +380,11 @@ void DolphinDetailsView::paintEvent(QPaintEvent* event) void DolphinDetailsView::keyPressEvent(QKeyEvent* event) { - m_keyPressed = true; + // If the Control modifier is pressed, a multiple selection + // is done and DolphinDetailsView::currentChanged() may not + // not change the selection in a custom way. + m_keyPressed = !(event->modifiers() & Qt::ControlModifier); + QTreeView::keyPressEvent(event); m_controller->handleKeyPressEvent(event); } @@ -444,12 +465,9 @@ void DolphinDetailsView::synchronizeSortingState(int column) void DolphinDetailsView::slotEntered(const QModelIndex& index) { - const QPoint pos = viewport()->mapFromGlobal(QCursor::pos()); - const int nameColumnWidth = header()->sectionSize(DolphinModel::Name); - if (pos.x() < nameColumnWidth) { + if (index.column() == DolphinModel::Name) { m_controller->emitItemEntered(index); - } - else { + } else { m_controller->emitViewportEntered(); } }