┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphiniconsview.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-07-18 19:52:28 +0000
committerPeter Penz <[email protected]>2007-07-18 19:52:28 +0000
commit43b2b591ece9c4485d9c8c03f27a733ddccdac5f (patch)
tree24694b4add8f62d274eaf92419082007f8504f54 /src/dolphiniconsview.cpp
parentee5c2c1666a229509ab24429c8dcdf8a4d456e7f (diff)
Assure that the item size is not exceeded -> the spacing is also respected for texts that cannot be wrapped
svn path=/trunk/KDE/kdebase/apps/; revision=689651
Diffstat (limited to 'src/dolphiniconsview.cpp')
-rw-r--r--src/dolphiniconsview.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index 237a319c8..394dae317 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -35,7 +35,9 @@
DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) :
KCategorizedView(parent),
m_controller(controller),
- m_dragging(false)
+ m_itemSize(),
+ m_dragging(false),
+ m_dropRect()
{
Q_ASSERT(controller != 0);
setViewMode(QListView::IconMode);
@@ -93,6 +95,39 @@ DolphinIconsView::~DolphinIconsView()
{
}
+QRect DolphinIconsView::visualRect(const QModelIndex& index) const
+{
+ if (itemCategorizer() == 0) {
+ const bool leftToRightFlow = (flow() == QListView::LeftToRight);
+
+ QRect itemRect = KCategorizedView::visualRect(index);
+ const int maxWidth = m_itemSize.width();
+ const int maxHeight = m_itemSize.height();
+
+ if (itemRect.width() > maxWidth) {
+ // assure that the maximum item width is not exceeded
+ if (leftToRightFlow) {
+ const int left = itemRect.left() + (itemRect.width() - maxWidth) / 2;
+ itemRect.setLeft(left);
+ }
+ itemRect.setWidth(maxWidth);
+ }
+
+ if (itemRect.height() > maxHeight) {
+ // assure that the maximum item height is not exceeded
+ if (!leftToRightFlow) {
+ const int top = itemRect.top() + (itemRect.height() - maxHeight) / 2;
+ itemRect.setTop(top);
+ }
+ itemRect.setHeight(maxHeight);
+ }
+
+ return itemRect;
+ }
+
+ return KCategorizedView::visualRect(index);
+}
+
QStyleOptionViewItem DolphinIconsView::viewOptions() const
{
return m_viewOptions;
@@ -321,6 +356,8 @@ void DolphinIconsView::updateGridSize(bool showPreview, bool showAdditionalInfo)
const int spacing = settings->gridSpacing();
setGridSize(QSize(itemWidth + spacing, itemHeight + spacing));
+ m_itemSize = QSize(itemWidth, itemHeight);
+
m_controller->setZoomInPossible(isZoomInPossible());
m_controller->setZoomOutPossible(isZoomOutPossible());
}