X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/38fa728aa607af2fb890f4d602d68ed1ae9d2278..d4287eb8e36ead543eb595bfcaa217fa0edd2654:/src/dolphindetailsview.cpp diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 2eb631a64..29ee90830 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())); @@ -186,6 +188,11 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event) QTreeView::mousePressEvent(event); const QModelIndex index = indexAt(event->pos()); + if (index.isValid() && (event->button() == Qt::LeftButton)) { + // TODO: see comment in DolphinIconsView::mousePressEvent() + setState(QAbstractItemView::DraggingState); + } + if (!index.isValid() || (index.column() != DolphinModel::Name)) { const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); if (!(modifier & Qt::ShiftModifier) && !(modifier & Qt::ControlModifier)) { @@ -248,6 +255,7 @@ void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event) void DolphinDetailsView::startDrag(Qt::DropActions supportedActions) { DragAndDropHelper::startDrag(this, supportedActions); + m_showElasticBand = false; } void DolphinDetailsView::dragEnterEvent(QDragEnterEvent* event) @@ -344,18 +352,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 +567,10 @@ void DolphinDetailsView::updateDecorationSize() m_controller->setZoomInPossible(isZoomInPossible()); m_controller->setZoomOutPossible(isZoomOutPossible()); + if (m_selectionManager != 0) { + m_selectionManager->reset(); + } + doItemsLayout(); }