┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinfileitemdelegate.h
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-10-15 21:23:42 +0000
committerPeter Penz <[email protected]>2008-10-15 21:23:42 +0000
commit994095076cccdb703b2bb285d4118bd9c654fd93 (patch)
treee995c1e81df37ff024c01d1a84765b9b48e6baeb /src/dolphinfileitemdelegate.h
parentd6a2d5594fc7dd95e0b4d6c993672de706d3bba5 (diff)
Assure that the item delegate draws the hover effect and the selection for the details view only above the icon + name. Open issue: The performance when selecting files by the rubberband is too slow (will be fixed before KDE 4.2).
CCBUG: 165999 CCMAIL: [email protected] svn path=/trunk/KDE/kdebase/apps/; revision=871874
Diffstat (limited to 'src/dolphinfileitemdelegate.h')
-rw-r--r--src/dolphinfileitemdelegate.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/dolphinfileitemdelegate.h b/src/dolphinfileitemdelegate.h
new file mode 100644
index 000000000..589ba7178
--- /dev/null
+++ b/src/dolphinfileitemdelegate.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ * 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 *
+ ***************************************************************************/
+
+#ifndef DOLPHINFILEITEMDELEGATE_H
+#define DOLPHINFILEITEMDELEGATE_H
+
+#include <kfileitemdelegate.h>
+
+/**
+ * Extends KFileItemDelegate by the ability to show the hover effect
+ * and the selection in a minimized way for the name column of
+ * the details view.
+ *
+ * Note that this is a workaround, as Qt does not support having custom
+ * shapes within the visual rect of an item view. The visual part of
+ * workaround is handled inside DolphinFileItemDelegate, the behavior
+ * changes are handled in DolphinDetailsView.
+ */
+class DolphinFileItemDelegate : public KFileItemDelegate
+{
+public:
+ explicit DolphinFileItemDelegate(QObject* parent = 0);
+ virtual ~DolphinFileItemDelegate();
+
+ /**
+ * If \a minimized is true, the hover effect and the selection are
+ * only drawn above the icon and text of an item. Per default
+ * \a minimized is false, which means that the whole visual rect is
+ * used like in KFileItemDelegate.
+ */
+ void setMinimizedNameColumn(bool minimized);
+ bool hasMinimizedNameColumn() const;
+
+ virtual void paint(QPainter* painter,
+ const QStyleOptionViewItem& option,
+ const QModelIndex& index) const;
+
+ /**
+ * Returns the minimized width of the name column for the name \a name. This method
+ * is also used in DolphinDetailsView to handle the selection of items correctly.
+ */
+ static int nameColumnWidth(const QString& name, const QStyleOptionViewItem& option);
+
+private:
+ bool m_hasMinimizedNameColumn;
+};
+
+inline void DolphinFileItemDelegate::setMinimizedNameColumn(bool minimized)
+{
+ m_hasMinimizedNameColumn = minimized;
+}
+
+inline bool DolphinFileItemDelegate::hasMinimizedNameColumn() const
+{
+ return m_hasMinimizedNameColumn;
+}
+
+#endif