1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #ifndef KFILEITEMLISTWIDGET_H
21 #define KFILEITEMLISTWIDGET_H
23 #include <libdolphin_export.h>
25 #include <kitemviews/kitemlistwidget.h>
29 #include <QStaticText>
32 class KItemListStyleOption
;
34 class LIBDOLPHINPRIVATE_EXPORT KFileItemListWidget
: public KItemListWidget
46 KFileItemListWidget(QGraphicsItem
* parent
);
47 virtual ~KFileItemListWidget();
49 void setLayout(Layout layout
);
50 Layout
layout() const;
52 void setSupportsItemExpanding(bool supportsItemExpanding
);
53 bool supportsItemExpanding() const;
55 virtual void paint(QPainter
* painter
, const QStyleOptionGraphicsItem
* option
, QWidget
* widget
= 0);
57 virtual QRectF
iconRect() const;
58 virtual QRectF
textRect() const;
59 virtual QRectF
textFocusRect() const;
60 virtual QRectF
expansionToggleRect() const;
61 virtual QRectF
selectionToggleRect() const;
64 * Implementation of KItemListWidgetCreatorBase::itemSizeHint() when
65 * using the KItemListWidgetCreator-template.
69 static QSizeF
itemSizeHint(int index
, const KItemListView
* view
);
72 * Implementation of KItemListWidgetCreatorBase::preferredRoleColumnWidth() when
73 * using the KItemListWidgetCreator-template.
77 static qreal
preferredRoleColumnWidth(const QByteArray
& role
, int index
, const KItemListView
* view
);
81 * Invalidates the cache which results in calling KFileItemListWidget::refreshCache() as
82 * soon as the item need to gets repainted.
84 void invalidateCache();
87 * Is called if the cache got invalidated by KFileItemListWidget::invalidateCache().
88 * The default implementation is empty.
90 virtual void refreshCache();
92 void setTextColor(const QColor
& color
);
93 QColor
textColor() const;
95 void setOverlay(const QPixmap
& overlay
);
96 QPixmap
overlay() const;
98 virtual void dataChanged(const QHash
<QByteArray
, QVariant
>& current
, const QSet
<QByteArray
>& roles
= QSet
<QByteArray
>());
99 virtual void visibleRolesChanged(const QList
<QByteArray
>& current
, const QList
<QByteArray
>& previous
);
100 virtual void columnWidthChanged(const QByteArray
& role
, qreal current
, qreal previous
);
101 virtual void styleOptionChanged(const KItemListStyleOption
& current
, const KItemListStyleOption
& previous
);
102 virtual void hoveredChanged(bool hovered
);
103 virtual void selectedChanged(bool selected
);
104 virtual void siblingsInformationChanged(const QBitArray
& current
, const QBitArray
& previous
);
105 virtual void resizeEvent(QGraphicsSceneResizeEvent
* event
);
106 virtual void showEvent(QShowEvent
* event
);
107 virtual void hideEvent(QHideEvent
* event
);
110 void slotCutItemsChanged();
117 Generic
// Mandatory last entry
120 void triggerCacheRefreshing();
121 void updateExpansionArea();
122 void updatePixmapCache();
124 void updateTextsCache();
125 void updateIconsLayoutTextCache();
126 void updateCompactLayoutTextCache();
127 void updateDetailsLayoutTextCache();
129 void updateAdditionalInfoTextColor();
131 void drawPixmap(QPainter
* painter
, const QPixmap
& pixmap
);
132 void drawSiblingsInformation(QPainter
* painter
);
134 static QPixmap
pixmapForIcon(const QString
& name
, int size
);
135 static void applyCutEffect(QPixmap
& pixmap
);
136 static void applyHiddenEffect(QPixmap
& pixmap
);
137 static RoleType
roleType(const QByteArray
& role
);
140 * @return Shown string for the role \p role of the item with the values \p values.
142 static QString
roleText(const QByteArray
& role
, const QHash
<QByteArray
, QVariant
>& values
);
148 bool m_supportsItemExpanding
;
152 QSet
<QByteArray
> m_dirtyContentRoles
;
157 QSize m_scaledPixmapSize
;
159 QRectF m_iconRect
; // Cache for KItemListWidget::iconRect()
160 QPixmap m_hoverPixmap
; // Cache for modified m_pixmap when hovering the item
165 QStaticText staticText
;
167 QHash
<QByteArray
, TextInfo
*> m_textInfo
;
171 QList
<QByteArray
> m_sortedVisibleRoles
;
173 QRectF m_expansionArea
;
175 QColor m_customTextColor
;
176 QColor m_additionalInfoTextColor
;