#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)),
this, SLOT(slotShowPreviewChanged(bool)));
- connect(controller, SIGNAL(showAdditionalInfoChanged(bool)),
- this, SLOT(slotShowAdditionalInfoChanged(bool)));
+ connect(controller, SIGNAL(additionalInfoCountChanged(int)),
+ this, SLOT(slotAdditionalInfoCountChanged(int)));
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);
m_viewOptions.font = font;
setWordWrap(settings->numberOfTextlines() > 1);
- updateGridSize(controller->showPreview(), controller->showAdditionalInfo());
+ updateGridSize(controller->showPreview(), controller->additionalInfoCount());
if (settings->arrangement() == QListView::TopToBottom) {
setFlow(QListView::LeftToRight);
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->showAdditionalInfo());
+ updateGridSize(showPreview, m_controller->additionalInfoCount());
}
-void DolphinIconsView::slotShowAdditionalInfoChanged(bool showAdditionalInfo)
+void DolphinIconsView::slotAdditionalInfoCountChanged(int count)
{
- updateGridSize(m_controller->showPreview(), showAdditionalInfo);
+ updateGridSize(m_controller->showPreview(), count);
}
void DolphinIconsView::zoomIn()
settings->setItemWidth(settings->itemWidth() + diff);
settings->setItemHeight(settings->itemHeight() + diff);
- updateGridSize(showPreview, m_controller->showAdditionalInfo());
+ updateGridSize(showPreview, m_controller->additionalInfoCount());
}
}
settings->setItemWidth(settings->itemWidth() - diff);
settings->setItemHeight(settings->itemHeight() - diff);
- updateGridSize(showPreview, m_controller->showAdditionalInfo());
+ updateGridSize(showPreview, m_controller->additionalInfoCount());
}
}
{
IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
const int size = m_controller->showPreview() ? settings->previewSize() : settings->iconSize();
- return size < K3Icon::SizeEnormous;
+ return size < KIconLoader::SizeEnormous;
}
bool DolphinIconsView::isZoomOutPossible() const
{
IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
const int size = m_controller->showPreview() ? settings->previewSize() : settings->iconSize();
- return size > K3Icon::SizeSmall;
+ return size > KIconLoader::SizeSmall;
}
int DolphinIconsView::increasedIconSize(int size) const
{
- // TODO: get rid of K3Icon sizes
int incSize = 0;
switch (size) {
- case K3Icon::SizeSmall: incSize = K3Icon::SizeSmallMedium; break;
- case K3Icon::SizeSmallMedium: incSize = K3Icon::SizeMedium; break;
- case K3Icon::SizeMedium: incSize = K3Icon::SizeLarge; break;
- case K3Icon::SizeLarge: incSize = K3Icon::SizeHuge; break;
- case K3Icon::SizeHuge: incSize = K3Icon::SizeEnormous; break;
+ case KIconLoader::SizeSmall: incSize = KIconLoader::SizeSmallMedium; break;
+ case KIconLoader::SizeSmallMedium: incSize = KIconLoader::SizeMedium; break;
+ case KIconLoader::SizeMedium: incSize = KIconLoader::SizeLarge; break;
+ case KIconLoader::SizeLarge: incSize = KIconLoader::SizeHuge; break;
+ case KIconLoader::SizeHuge: incSize = KIconLoader::SizeEnormous; break;
default: Q_ASSERT(false); break;
}
return incSize;
int DolphinIconsView::decreasedIconSize(int size) const
{
- // TODO: get rid of K3Icon sizes
int decSize = 0;
switch (size) {
- case K3Icon::SizeSmallMedium: decSize = K3Icon::SizeSmall; break;
- case K3Icon::SizeMedium: decSize = K3Icon::SizeSmallMedium; break;
- case K3Icon::SizeLarge: decSize = K3Icon::SizeMedium; break;
- case K3Icon::SizeHuge: decSize = K3Icon::SizeLarge; break;
- case K3Icon::SizeEnormous: decSize = K3Icon::SizeHuge; break;
+ case KIconLoader::SizeSmallMedium: decSize = KIconLoader::SizeSmall; break;
+ case KIconLoader::SizeMedium: decSize = KIconLoader::SizeSmallMedium; break;
+ case KIconLoader::SizeLarge: decSize = KIconLoader::SizeMedium; break;
+ case KIconLoader::SizeHuge: decSize = KIconLoader::SizeLarge; break;
+ case KIconLoader::SizeEnormous: decSize = KIconLoader::SizeHuge; break;
default: Q_ASSERT(false); break;
}
return decSize;
}
-void DolphinIconsView::updateGridSize(bool showPreview, bool showAdditionalInfo)
+void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount)
{
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
Q_ASSERT(settings != 0);
size = previewSize;
}
- if (showAdditionalInfo) {
- itemHeight += m_viewOptions.font.pointSize() * 2;
- }
+ Q_ASSERT(additionalInfoCount >= 0);
+ itemHeight += additionalInfoCount * m_viewOptions.font.pointSize() * 2;
if (settings->arrangement() == QListView::TopToBottom) {
// The decoration width indirectly defines the maximum
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"