Q_ASSERT(settings != 0);
Q_ASSERT(controller != 0);
+ setLayoutDirection(Qt::LeftToRight);
setAcceptDrops(true);
setSortingEnabled(true);
setUniformRowHeights(true);
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();
{
m_controller->requestActivation();
+ const QModelIndex current = currentIndex();
QTreeView::mousePressEvent(event);
m_expandingTogglePressed = false;
}
if (!index.isValid() || (index.column() != DolphinModel::Name)) {
+ if (QApplication::mouseButtons() & Qt::MidButton) {
+ m_controller->replaceUrlByClipboard();
+ }
+
const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
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) {
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();
void DolphinDetailsView::keyPressEvent(QKeyEvent* event)
{
+ // 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);
- m_keyPressed = true;
}
void DolphinDetailsView::keyReleaseEvent(QKeyEvent* event)
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();
}
}
return QRect(topLeft, m_elasticBandDestination).normalized();
}
-void DolphinDetailsView::zoomIn()
+void DolphinDetailsView::setZoomLevel(int level)
{
- 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()
-{
- 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)
}
}
+void DolphinDetailsView::slotActivationChanged(bool active)
+{
+ setAlternatingRowColors(active);
+}
+
void DolphinDetailsView::disableAutoResizing()
{
m_autoResize = false;
}
}
-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();
setIconSize(QSize(iconSize, iconSize));
m_decorationSize = QSize(iconSize, iconSize);
- m_controller->setZoomInPossible(isZoomInPossible());
- m_controller->setZoomOutPossible(isZoomOutPossible());
-
if (m_selectionManager != 0) {
m_selectionManager->reset();
}