X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/3c1c185400a55103cea3ed567de167df87b59945..f11c699fa203dd2cde0e85c63a6d186e3fa6a3de:/src/dolphiniconsview.cpp diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index 6b584612c..5107d5697 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -26,6 +26,7 @@ #include "dolphin_iconsmodesettings.h" #include +#include #include #include @@ -53,24 +54,25 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle // RETURN-key in keyPressEvent(). if (KGlobalSettings::singleClick()) { connect(this, SIGNAL(clicked(const QModelIndex&)), - controller, SLOT(triggerItem(const QModelIndex&))); + this, SLOT(triggerItem(const QModelIndex&))); } else { connect(this, SIGNAL(doubleClicked(const QModelIndex&)), - controller, SLOT(triggerItem(const QModelIndex&))); + this, SLOT(triggerItem(const QModelIndex&))); } - connect(this, SIGNAL(entered(const QModelIndex&)), - controller, SLOT(emitItemEntered(const QModelIndex&))); connect(this, SIGNAL(viewportEntered()), controller, SLOT(emitViewportEntered())); connect(controller, SIGNAL(showPreviewChanged(bool)), this, SLOT(slotShowPreviewChanged(bool))); - connect(controller, SIGNAL(additionalInfoCountChanged(int)), - this, SLOT(slotAdditionalInfoCountChanged(int))); + connect(controller->dolphinView(), SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)), + this, SLOT(slotAdditionalInfoChanged(const KFileItemDelegate::InformationList&))); connect(controller, SIGNAL(zoomIn()), this, SLOT(zoomIn())); connect(controller, SIGNAL(zoomOut()), this, SLOT(zoomOut())); + connect(this, SIGNAL(entered(const QModelIndex&)), + this, SLOT(slotEntered(const QModelIndex&))); + // apply the icons mode settings to the widget const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); Q_ASSERT(settings != 0); @@ -84,7 +86,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle m_viewOptions.font = font; setWordWrap(settings->numberOfTextlines() > 1); - updateGridSize(controller->showPreview(), controller->additionalInfoCount()); + updateGridSize(controller->showPreview(), 0); if (settings->arrangement() == QListView::TopToBottom) { setFlow(QListView::LeftToRight); @@ -97,6 +99,8 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle m_categoryDrawer = new DolphinCategoryDrawer(); setCategoryDrawer(m_categoryDrawer); + + setFocus(); } DolphinIconsView::~DolphinIconsView() @@ -147,7 +151,7 @@ void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event) void DolphinIconsView::mousePressEvent(QMouseEvent* event) { - m_controller->triggerActivation(); + m_controller->requestActivation(); if (!indexAt(event->pos()).isValid()) { const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); if (!(modifier & Qt::ShiftModifier) && !(modifier & Qt::ControlModifier)) { @@ -191,11 +195,15 @@ void DolphinIconsView::dropEvent(QDropEvent* event) if (!selectionModel()->isSelected(indexAt(event->pos()))) { const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); if (!urls.isEmpty()) { - m_controller->indicateDroppedUrls(urls, - m_controller->url(), - indexAt(event->pos()), - event->source()); - event->acceptProposedAction(); + const QModelIndex index = indexAt(event->pos()); + if (index.isValid()) { + const KFileItem item = itemForIndex(index); + m_controller->indicateDroppedUrls(urls, + m_controller->url(), + item, + event->source()); + event->acceptProposedAction(); + } } } @@ -220,22 +228,33 @@ void DolphinIconsView::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); } } +void DolphinIconsView::triggerItem(const QModelIndex& index) +{ + m_controller->triggerItem(itemForIndex(index)); +} + +void DolphinIconsView::slotEntered(const QModelIndex& index) +{ + m_controller->emitItemEntered(itemForIndex(index)); +} + void DolphinIconsView::slotShowPreviewChanged(bool showPreview) { - updateGridSize(showPreview, m_controller->additionalInfoCount()); + const int infoCount = m_controller->dolphinView()->additionalInfo().count(); + updateGridSize(showPreview, infoCount); } -void DolphinIconsView::slotAdditionalInfoCountChanged(int count) +void DolphinIconsView::slotAdditionalInfoChanged(const KFileItemDelegate::InformationList& info) { - updateGridSize(m_controller->showPreview(), count); + updateGridSize(m_controller->showPreview(), info.count()); } void DolphinIconsView::zoomIn() @@ -264,7 +283,8 @@ void DolphinIconsView::zoomIn() settings->setItemWidth(settings->itemWidth() + diff); settings->setItemHeight(settings->itemHeight() + diff); - updateGridSize(showPreview, m_controller->additionalInfoCount()); + const int infoCount = m_controller->dolphinView()->additionalInfo().count(); + updateGridSize(showPreview, infoCount); } } @@ -295,7 +315,8 @@ void DolphinIconsView::zoomOut() settings->setItemWidth(settings->itemWidth() - diff); settings->setItemHeight(settings->itemHeight() - diff); - updateGridSize(showPreview, m_controller->additionalInfoCount()); + const int infoCount = m_controller->dolphinView()->additionalInfo().count(); + updateGridSize(showPreview, infoCount); } } @@ -381,4 +402,13 @@ void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount) m_controller->setZoomOutPossible(isZoomOutPossible()); } +KFileItem DolphinIconsView::itemForIndex(const QModelIndex& index) const +{ + QAbstractProxyModel* proxyModel = static_cast(model()); + KDirModel* dirModel = static_cast(proxyModel->sourceModel()); + const QModelIndex dirIndex = proxyModel->mapToSource(index); + return dirModel->itemForIndex(dirIndex); +} + + #include "dolphiniconsview.moc"