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>
31 class LIBDOLPHINPRIVATE_EXPORT KFileItemListWidget
: public KItemListWidget
43 KFileItemListWidget(QGraphicsItem
* parent
);
44 virtual ~KFileItemListWidget();
46 void setLayout(Layout layout
);
47 Layout
layout() const;
49 virtual void paint(QPainter
* painter
, const QStyleOptionGraphicsItem
* option
, QWidget
* widget
= 0);
51 virtual QRectF
iconBoundingRect() const;
52 virtual QRectF
textBoundingRect() const;
53 virtual QRectF
expansionToggleRect() const;
56 virtual void dataChanged(const QHash
<QByteArray
, QVariant
>& current
, const QSet
<QByteArray
>& roles
= QSet
<QByteArray
>());
57 virtual void visibleRolesChanged(const QHash
<QByteArray
, int>& current
, const QHash
<QByteArray
, int>& previous
);
58 virtual void visibleRolesSizesChanged(const QHash
<QByteArray
, QSizeF
>& current
, const QHash
<QByteArray
, QSizeF
>& previous
);
59 virtual void styleOptionChanged(const KItemListStyleOption
& current
, const KItemListStyleOption
& previous
);
60 virtual void hoveredChanged(bool hovered
);
61 virtual void resizeEvent(QGraphicsSceneResizeEvent
* event
);
74 TextIdCount
// Mandatory last entry
78 void updateExpansionArea();
79 void updatePixmapCache();
81 void updateTextsCache();
82 void updateIconsLayoutTextCache();
83 void updateCompactLayoutTextCache();
84 void updateDetailsLayoutTextCache();
86 QString
roleText(TextId textId
, const QVariant
& roleValue
) const;
88 void drawPixmap(QPainter
* painter
, const QPixmap
& pixmap
);
90 static QPixmap
pixmapForIcon(const QString
& name
, int size
);
91 static TextId
roleTextId(const QByteArray
& role
);
97 QSet
<QByteArray
> m_dirtyContentRoles
;
102 QSize m_scaledPixmapSize
;
104 QRectF m_hoverPixmapRect
;
105 QPixmap m_hoverPixmap
;
107 QPointF m_textPos
[TextIdCount
];
108 QStaticText m_text
[TextIdCount
];
109 QRectF m_textBoundingRect
;
111 QList
<QByteArray
> m_sortedVisibleRoles
;
113 QRectF m_expansionArea
;
114 QColor m_additionalInfoTextColor
;