X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/02e2ef207d60098708de5ef77847e4cd1ca08397..d0e7eabcaa259eeef14fa9c29b36cfefc46f8143:/src/dolphindetailsview.cpp diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index c26d3d5b5..8e8eec2ec 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -28,9 +28,11 @@ #include "dolphin_detailsmodesettings.h" +#include #include #include +#include #include #include #include @@ -82,10 +84,10 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr // RETURN-key in keyPressEvent(). if (KGlobalSettings::singleClick()) { connect(this, SIGNAL(clicked(const QModelIndex&)), - this, SLOT(slotItemActivated(const QModelIndex&))); + this, SLOT(triggerItem(const QModelIndex&))); } else { connect(this, SIGNAL(doubleClicked(const QModelIndex&)), - this, SLOT(slotItemActivated(const QModelIndex&))); + this, SLOT(triggerItem(const QModelIndex&))); } connect(this, SIGNAL(entered(const QModelIndex&)), this, SLOT(slotEntered(const QModelIndex&))); @@ -112,7 +114,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr // check avoids a division by zero happening on versions before 4.3.1. // Right now KDE in theory can be shipped with Qt 4.3.0 and above. // ereslibre -#if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 2)) +#if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 2) || defined(QT_KDE_QT_COPY)) setVerticalScrollMode(QTreeView::ScrollPerPixel); setHorizontalScrollMode(QTreeView::ScrollPerPixel); #endif @@ -166,7 +168,7 @@ bool DolphinDetailsView::event(QEvent* event) // check avoids a division by zero happening on versions before 4.3.1. // Right now KDE in theory can be shipped with Qt 4.3.0 and above. // ereslibre -#if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 2)) +#if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 2) || defined(QT_KDE_QT_COPY)) else if (event->type() == QEvent::UpdateRequest) { // a wheel movement will scroll 4 items if (model()->rowCount() > 0) { @@ -191,7 +193,7 @@ void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event) void DolphinDetailsView::mousePressEvent(QMouseEvent* event) { - m_controller->triggerActivation(); + m_controller->requestActivation(); QTreeView::mousePressEvent(event); @@ -315,11 +317,11 @@ void DolphinDetailsView::keyPressEvent(QKeyEvent* event) const QItemSelectionModel* selModel = selectionModel(); const QModelIndex currentIndex = selModel->currentIndex(); - const bool triggerItem = currentIndex.isValid() - && (event->key() == Qt::Key_Return) - && (selModel->selectedIndexes().count() <= 1); - if (triggerItem) { - m_controller->triggerItem(currentIndex); + const bool trigger = currentIndex.isValid() + && (event->key() == Qt::Key_Return) + && (selModel->selectedIndexes().count() <= 1); + if (trigger) { + triggerItem(currentIndex); } } @@ -383,7 +385,7 @@ void DolphinDetailsView::slotEntered(const QModelIndex& index) const QPoint pos = viewport()->mapFromGlobal(QCursor::pos()); const int nameColumnWidth = header()->sectionSize(DolphinModel::Name); if (pos.x() < nameColumnWidth) { - m_controller->emitItemEntered(index); + m_controller->emitItemEntered(itemForIndex(index)); } else { m_controller->emitViewportEntered(); @@ -399,6 +401,13 @@ void DolphinDetailsView::updateElasticBand() setDirtyRegion(dirtyRegion); } +QRect DolphinDetailsView::elasticBandRect() const +{ + const QPoint pos(contentsPos()); + const QPoint topLeft(m_elasticBandOrigin.x() - pos.x(), m_elasticBandOrigin.y() - pos.y()); + return QRect(topLeft, m_elasticBandDestination).normalized(); +} + void DolphinDetailsView::zoomIn() { if (isZoomInPossible()) { @@ -425,13 +434,14 @@ void DolphinDetailsView::zoomOut() } } -void DolphinDetailsView::slotItemActivated(const QModelIndex& index) +void DolphinDetailsView::triggerItem(const QModelIndex& index) { + const KFileItem item = itemForIndex(index); if (index.isValid() && (index.column() == KDirModel::Name)) { - m_controller->triggerItem(index); + m_controller->triggerItem(item); } else { clearSelection(); - m_controller->emitItemEntered(index); + m_controller->emitItemEntered(item); } } @@ -518,16 +528,12 @@ QPoint DolphinDetailsView::contentsPos() const return QPoint(0, y); } -QRect DolphinDetailsView::elasticBandRect() const -{ - const QPoint pos(contentsPos()); - const QPoint topLeft(m_elasticBandOrigin.x() - pos.x(), m_elasticBandOrigin.y() - pos.y()); - return QRect(topLeft, m_elasticBandDestination).normalized(); -} - -static bool isValidNameIndex(const QModelIndex& index) +KFileItem DolphinDetailsView::itemForIndex(const QModelIndex& index) const { - return index.isValid() && (index.column() == KDirModel::Name); + QAbstractProxyModel* proxyModel = static_cast(model()); + KDirModel* dirModel = static_cast(proxyModel->sourceModel()); + const QModelIndex dirIndex = proxyModel->mapToSource(index); + return dirModel->itemForIndex(dirIndex); } #include "dolphindetailsview.moc"