diff options
| author | Peter Penz <[email protected]> | 2007-05-10 20:29:10 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2007-05-10 20:29:10 +0000 |
| commit | d03b27f28850e25d087f946e3a5c99b21c76f359 (patch) | |
| tree | 27cf913e6d10347df34f7172f4a128bd6246835b /src/dolphiniconsview.cpp | |
| parent | 6ab84fbd6129422dfa59c095087c7ceb1a9e1e50 (diff) | |
layout improvements in the icons view:
* do a text wrapping if the number of lines is > 1 (TODO: bugfix of KFileItemDelegate necessary, currently the text might overlap with the icon)
* increase the height for the text area if an additional information like type, date, ... is shown
svn path=/trunk/KDE/kdebase/apps/; revision=663320
Diffstat (limited to 'src/dolphiniconsview.cpp')
| -rw-r--r-- | src/dolphiniconsview.cpp | 72 |
1 files changed, 46 insertions, 26 deletions
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index 25a8581f4..c2262c1bc 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -52,7 +52,9 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle connect(this, SIGNAL(activated(const QModelIndex&)), controller, SLOT(triggerItem(const QModelIndex&))); connect(controller, SIGNAL(showPreviewChanged(bool)), - this, SLOT(updateGridSize(bool))); + this, SLOT(slotShowPreviewChanged(bool))); + connect(controller, SIGNAL(showAdditionalInfoChanged(bool)), + this, SLOT(slotShowAdditionalInfoChanged(bool))); connect(controller, SIGNAL(zoomIn()), this, SLOT(zoomIn())); connect(controller, SIGNAL(zoomOut()), @@ -69,8 +71,12 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle font.setItalic(settings->italicFont()); font.setBold(settings->boldFont()); m_viewOptions.font = font; + if (settings->numberOfTextlines() > 1) { + m_viewOptions.textElideMode = Qt::ElideNone; + m_viewOptions.features = QStyleOptionViewItemV2::WrapText; + } - updateGridSize(controller->showPreview()); + updateGridSize(controller->showPreview(), controller->showAdditionalInfo()); if (settings->arrangement() == QListView::TopToBottom) { setFlow(QListView::LeftToRight); @@ -121,30 +127,14 @@ void DolphinIconsView::dropEvent(QDropEvent* event) KListView::dropEvent(event); } -void DolphinIconsView::updateGridSize(bool showPreview) +void DolphinIconsView::slotShowPreviewChanged(bool showPreview) { - const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); - Q_ASSERT(settings != 0); - - int gridWidth = settings->gridWidth(); - int gridHeight = settings->gridHeight(); - int size = settings->iconSize(); - - if (showPreview) { - const int previewSize = settings->previewSize(); - const int diff = previewSize - size; - Q_ASSERT(diff >= 0); - gridWidth += diff; - gridHeight += diff; - - size = previewSize; - } - - m_viewOptions.decorationSize = QSize(size, size); - setGridSize(QSize(gridWidth, gridHeight)); + updateGridSize(showPreview, m_controller->showAdditionalInfo()); +} - m_controller->setZoomInPossible(isZoomInPossible()); - m_controller->setZoomOutPossible(isZoomOutPossible()); +void DolphinIconsView::slotShowAdditionalInfoChanged(bool showAdditionalInfo) +{ + updateGridSize(m_controller->showPreview(), showAdditionalInfo); } void DolphinIconsView::zoomIn() @@ -173,7 +163,7 @@ void DolphinIconsView::zoomIn() settings->setGridWidth(settings->gridWidth() + diff); settings->setGridHeight(settings->gridHeight() + diff); - updateGridSize(showPreview); + updateGridSize(showPreview, m_controller->showAdditionalInfo()); } } @@ -204,7 +194,7 @@ void DolphinIconsView::zoomOut() settings->setGridWidth(settings->gridWidth() - diff); settings->setGridHeight(settings->gridHeight() - diff); - updateGridSize(showPreview); + updateGridSize(showPreview, m_controller->showAdditionalInfo()); } } @@ -252,4 +242,34 @@ int DolphinIconsView::decreasedIconSize(int size) const return decSize; } +void DolphinIconsView::updateGridSize(bool showPreview, bool showAdditionalInfo) +{ + const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); + Q_ASSERT(settings != 0); + + int gridWidth = settings->gridWidth(); + int gridHeight = settings->gridHeight(); + int size = settings->iconSize(); + + if (showPreview) { + const int previewSize = settings->previewSize(); + const int diff = previewSize - size; + Q_ASSERT(diff >= 0); + gridWidth += diff; + gridHeight += diff; + + size = previewSize; + } + + if (showAdditionalInfo) { + gridHeight += m_viewOptions.font.pointSize() * 2; + } + + m_viewOptions.decorationSize = QSize(size, size); + setGridSize(QSize(gridWidth, gridHeight)); + + m_controller->setZoomInPossible(isZoomInPossible()); + m_controller->setZoomOutPossible(isZoomOutPossible()); +} + #include "dolphiniconsview.moc" |
