X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/38fa728aa607af2fb890f4d602d68ed1ae9d2278..50acc2d6ecbae2fb3c228bf779b23eabf3346cb1:/src/dolphindetailsview.cpp diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 2eb631a64..08d03fb0b 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -47,6 +47,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr QTreeView(parent), m_autoResize(true), m_controller(controller), + m_selectionManager(0), m_font(), m_decorationSize(), m_showElasticBand(false), @@ -66,9 +67,9 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr setAlternatingRowColors(true); setRootIsDecorated(settings->expandableFolders()); setItemsExpandable(settings->expandableFolders()); + setEditTriggers(QAbstractItemView::NoEditTriggers); setMouseTracking(true); - viewport()->setAttribute(Qt::WA_Hover); const ViewProperties props(controller->url()); setSortIndicatorSection(props.sorting()); @@ -98,12 +99,12 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr connect(this, SIGNAL(clicked(const QModelIndex&)), controller, SLOT(triggerItem(const QModelIndex&))); if (DolphinSettings::instance().generalSettings()->showSelectionToggle()) { - SelectionManager* selManager = new SelectionManager(this); - connect(selManager, SIGNAL(selectionChanged()), + m_selectionManager = new SelectionManager(this); + connect(m_selectionManager, SIGNAL(selectionChanged()), this, SLOT(requestActivation())); connect(m_controller, SIGNAL(urlChanged(const KUrl&)), - selManager, SLOT(reset())); - } + m_selectionManager, SLOT(reset())); + } } else { connect(this, SIGNAL(doubleClicked(const QModelIndex&)), controller, SLOT(triggerItem(const QModelIndex&))); @@ -134,6 +135,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr updateDecorationSize(); setFocus(); + viewport()->installEventFilter(this); connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()), this, SLOT(updateFont())); @@ -344,18 +346,40 @@ void DolphinDetailsView::resizeEvent(QResizeEvent* event) void DolphinDetailsView::wheelEvent(QWheelEvent* event) { + if (m_selectionManager != 0) { + m_selectionManager->reset(); + } + // let Ctrl+wheel events propagate to the DolphinView for icon zooming if (event->modifiers() & Qt::ControlModifier) { event->ignore(); return; } + QTreeView::wheelEvent(event); } void DolphinDetailsView::currentChanged(const QModelIndex& current, const QModelIndex& previous) { QTreeView::currentChanged(current, previous); - selectionModel()->select(current, QItemSelectionModel::ClearAndSelect); + + // Stay consistent with QListView: When changing the current index by key presses, + // also change the selection. + if (QApplication::mouseButtons() == Qt::NoButton) { + selectionModel()->select(current, QItemSelectionModel::ClearAndSelect); + } +} + +bool DolphinDetailsView::eventFilter(QObject* watched, QEvent* event) +{ + if ((watched == viewport()) && (event->type() == QEvent::Leave)) { + // if the mouse is above an item and moved very fast outside the widget, + // no viewportEntered() signal might be emitted although the mouse has been moved + // above the viewport + m_controller->emitViewportEntered(); + } + + return QTreeView::eventFilter(watched, event); } void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting) @@ -537,6 +561,10 @@ void DolphinDetailsView::updateDecorationSize() m_controller->setZoomInPossible(isZoomInPossible()); m_controller->setZoomOutPossible(isZoomOutPossible()); + if (m_selectionManager != 0) { + m_selectionManager->reset(); + } + doItemsLayout(); }