X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/8cfe659711f1ea443d2c835154a7bddcd6ea72d3..817f3952e2bed820ea3b50dfdfe91ccb99dcb748:/src/dolphindetailsview.cpp diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index d45282602..bcf385d36 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -100,27 +100,29 @@ 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()), controller, SLOT(emitViewportEntered())); - connect(controller, SIGNAL(zoomIn()), - this, SLOT(zoomIn())); - connect(controller, SIGNAL(zoomOut()), - this, SLOT(zoomOut())); + connect(controller, SIGNAL(zoomLevelChanged(int)), + this, SLOT(setZoomLevel(int))); connect(controller->dolphinView(), SIGNAL(additionalInfoChanged()), this, SLOT(updateColumnVisibility())); + connect(controller, SIGNAL(activationChanged(bool)), + this, SLOT(slotActivationChanged(bool))); if (settings->useSystemFont()) { m_font = KGlobalSettings::generalFont(); @@ -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(); } } @@ -471,30 +489,13 @@ QRect DolphinDetailsView::elasticBandRect() const return QRect(topLeft, m_elasticBandDestination).normalized(); } -void DolphinDetailsView::zoomIn() -{ - if (isZoomInPossible()) { - DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); - switch (settings->iconSize()) { - case KIconLoader::SizeSmall: settings->setIconSize(KIconLoader::SizeMedium); break; - case KIconLoader::SizeMedium: settings->setIconSize(KIconLoader::SizeLarge); break; - default: Q_ASSERT(false); break; - } - updateDecorationSize(); - } -} - -void DolphinDetailsView::zoomOut() +void DolphinDetailsView::setZoomLevel(int level) { - if (isZoomOutPossible()) { - DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); - switch (settings->iconSize()) { - case KIconLoader::SizeLarge: settings->setIconSize(KIconLoader::SizeMedium); break; - case KIconLoader::SizeMedium: settings->setIconSize(KIconLoader::SizeSmall); break; - default: Q_ASSERT(false); break; - } - updateDecorationSize(); - } + const int size = DolphinController::iconSizeForZoomLevel(level); + DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); + settings->setIconSize(size); + + updateDecorationSize(); } void DolphinDetailsView::configureColumns(const QPoint& pos) @@ -557,6 +558,11 @@ void DolphinDetailsView::slotHeaderSectionResized(int logicalIndex, int oldSize, } } +void DolphinDetailsView::slotActivationChanged(bool active) +{ + setAlternatingRowColors(active); +} + void DolphinDetailsView::disableAutoResizing() { m_autoResize = false; @@ -577,18 +583,6 @@ void DolphinDetailsView::updateFont() } } -bool DolphinDetailsView::isZoomInPossible() const -{ - DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); - return settings->iconSize() < KIconLoader::SizeLarge; -} - -bool DolphinDetailsView::isZoomOutPossible() const -{ - DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); - return settings->iconSize() > KIconLoader::SizeSmall; -} - void DolphinDetailsView::updateDecorationSize() { DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); @@ -596,9 +590,6 @@ void DolphinDetailsView::updateDecorationSize() setIconSize(QSize(iconSize, iconSize)); m_decorationSize = QSize(iconSize, iconSize); - m_controller->setZoomInPossible(isZoomInPossible()); - m_controller->setZoomOutPossible(isZoomOutPossible()); - if (m_selectionManager != 0) { m_selectionManager->reset(); }