From a8ada5e6857d6dec25edf8ef57af9f27a91471c1 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Thu, 20 Mar 2008 16:58:59 +0000 Subject: 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: fredrik@kde.org svn path=/trunk/KDE/kdebase/apps/; revision=788095 --- src/dolphinfileitemdelegate.h | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/dolphinfileitemdelegate.h (limited to 'src/dolphinfileitemdelegate.h') diff --git a/src/dolphinfileitemdelegate.h b/src/dolphinfileitemdelegate.h new file mode 100644 index 000000000..2f0167cd9 --- /dev/null +++ b/src/dolphinfileitemdelegate.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2008 by Peter Penz * + * * + * 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 * + ***************************************************************************/ + +#ifndef DOLPHINFILEITEMDELEGATE_H +#define DOLPHINFILEITEMDELEGATE_H + +#include + +/** + * @brief Extends KFileItemDelegate with the ability to set + * a maximum size. + */ +class DolphinFileItemDelegate : public KFileItemDelegate +{ + Q_OBJECT + +public: + explicit DolphinFileItemDelegate(QObject* parent = 0); + virtual ~DolphinFileItemDelegate(); + + void setMaximumSize(const QSize& size); + QSize maximumSize() const; + + /** @see QItemDelegate::sizeHint() */ + virtual QSize sizeHint(const QStyleOptionViewItem& option, + const QModelIndex& index) const; + +private: + QSize m_maxSize; +}; + +#endif -- cgit v1.3