#include "dolphin_iconsmodesettings.h"
#include <kdialog.h>
+#include <kdirmodel.h>
#include <QAbstractProxyModel>
#include <QApplication>
// 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)),
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);
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());
m_controller->setZoomOutPossible(isZoomOutPossible());
}
+KFileItem DolphinIconsView::itemForIndex(const QModelIndex& index) const
+{
+ QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(model());
+ KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
+ const QModelIndex dirIndex = proxyModel->mapToSource(index);
+ return dirModel->itemForIndex(dirIndex);
+}
+
+
#include "dolphiniconsview.moc"