QTreeView(parent),
m_autoResize(true),
m_controller(controller),
+ m_selectionManager(0),
m_font(),
m_decorationSize(),
m_showElasticBand(false),
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());
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&)));
updateDecorationSize();
setFocus();
+ viewport()->installEventFilter(this);
connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
this, SLOT(updateFont()));
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)) {
void DolphinDetailsView::startDrag(Qt::DropActions supportedActions)
{
DragAndDropHelper::startDrag(this, supportedActions);
+ m_showElasticBand = false;
}
void DolphinDetailsView::dragEnterEvent(QDragEnterEvent* 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)
m_controller->setZoomInPossible(isZoomInPossible());
m_controller->setZoomOutPossible(isZoomOutPossible());
+ if (m_selectionManager != 0) {
+ m_selectionManager->reset();
+ }
+
doItemsLayout();
}