diff options
| author | Peter Penz <[email protected]> | 2008-03-20 16:58:59 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2008-03-20 16:58:59 +0000 |
| commit | a8ada5e6857d6dec25edf8ef57af9f27a91471c1 (patch) | |
| tree | cd76cdcbae8e02405c9d4fb768d51b04384109d6 /src/dolphinfileitemdelegate.cpp | |
| parent | f738a9ff2ba3a71a6015d388c835ffa7c7e0be02 (diff) | |
QListView does not support having a margin for grids. Originally it has been tried to bypass this by overwriting QListView::visualRect(), but this has some side effects (see #155378 and #155575). The clean approach is to return a proper size hint in the file item delegate.
Currently a custom item delegate has been made for Dolphin, but we'll discuss whether it makes sense providing this feature already in KFileItemDelegate...
BUG: 155378
BUG: 155575
CCMAIL: [email protected]
svn path=/trunk/KDE/kdebase/apps/; revision=788095
Diffstat (limited to 'src/dolphinfileitemdelegate.cpp')
| -rw-r--r-- | src/dolphinfileitemdelegate.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/dolphinfileitemdelegate.cpp b/src/dolphinfileitemdelegate.cpp new file mode 100644 index 000000000..a9ecc2a71 --- /dev/null +++ b/src/dolphinfileitemdelegate.cpp @@ -0,0 +1,61 @@ +/*************************************************************************** + * Copyright (C) 2008 by Peter Penz <[email protected]> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "dolphinfileitemdelegate.h" + +DolphinFileItemDelegate::DolphinFileItemDelegate(QObject* parent) : + KFileItemDelegate(parent), + m_maxSize(0, 0) +{ +} + +DolphinFileItemDelegate::~DolphinFileItemDelegate() +{ +} + +void DolphinFileItemDelegate::setMaximumSize(const QSize& size) +{ + m_maxSize = size; +} + + +QSize DolphinFileItemDelegate::maximumSize() const +{ + return m_maxSize; +} + +QSize DolphinFileItemDelegate::sizeHint(const QStyleOptionViewItem& option, + const QModelIndex& index) const +{ + QSize size = KFileItemDelegate::sizeHint(option, index); + + const int maxWidth = m_maxSize.width(); + if ((maxWidth > 0) && (size.width() > maxWidth)) { + size.setWidth(maxWidth); + } + + const int maxHeight = m_maxSize.height(); + if ((maxHeight > 0) && (size.height() > maxHeight)) { + size.setHeight(maxHeight); + } + + return size; +} + +#include "dolphinfileitemdelegate.moc" |
