X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/ba0c58c2213de28db158ae81318d9c328952fdec..5f57256a2f293622c7a10844adae29190907b9eb:/src/kitemviews/kfileitemlistwidget.h diff --git a/src/kitemviews/kfileitemlistwidget.h b/src/kitemviews/kfileitemlistwidget.h index 3e47b567b..fbb0300f8 100644 --- a/src/kitemviews/kfileitemlistwidget.h +++ b/src/kitemviews/kfileitemlistwidget.h @@ -20,130 +20,42 @@ #ifndef KFILEITEMLISTWIDGET_H #define KFILEITEMLISTWIDGET_H -#include +#include "dolphin_export.h" -#include +#include -#include -#include -#include - -class LIBDOLPHINPRIVATE_EXPORT KFileItemListWidget : public KItemListWidget +class DOLPHIN_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidgetInformant { - Q_OBJECT - public: - enum Layout - { - IconsLayout, - CompactLayout, - DetailsLayout - }; - - KFileItemListWidget(QGraphicsItem* parent); - virtual ~KFileItemListWidget(); + KFileItemListWidgetInformant(); + ~KFileItemListWidgetInformant() override; - void setLayout(Layout layout); - Layout layout() const; +protected: + QString itemText(int index, const KItemListView* view) const override; + bool itemIsLink(int index, const KItemListView* view) const override; + QString roleText(const QByteArray& role, const QHash& values) const override; + QFont customizedFontForLinks(const QFont& baseFont) const override; +}; - virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); +class DOLPHIN_EXPORT KFileItemListWidget : public KStandardItemListWidget +{ + Q_OBJECT - virtual QRectF iconRect() const; - virtual QRectF textRect() const; - virtual QRectF expansionToggleRect() const; - virtual QRectF selectionToggleRect() const; +public: + KFileItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent); + ~KFileItemListWidget() override; - /** - * @return Shown string for the role \p role of the item with the values \p values. - */ - // TODO: Move this method to a helper class shared by KFileItemListWidget and - // KFileItemListView to share information that is required to calculate the size hints - // in KFileItemListView and to represent the actual data in KFileItemListWidget. - static QString roleText(const QByteArray& role, const QHash& values); + static KItemListWidgetInformant* createInformant(); protected: - /** - * Invalidates the cache which results in calling KFileItemListWidget::refreshCache() as - * soon as the item need to gets repainted. - */ - void invalidateCache(); + bool isRoleRightAligned(const QByteArray& role) const override; + bool isHidden() const override; + QFont customizedFont(const QFont& baseFont) const override; /** - * Is called if the cache got invalidated by KFileItemListWidget::invalidateCache(). - * The default implementation is empty. + * @return Selection length without MIME-type extension */ - virtual void refreshCache(); - - void setTextColor(const QColor& color); - QColor textColor() const; - - void setOverlay(const QPixmap& overlay); - QPixmap overlay() const; - - virtual void dataChanged(const QHash& current, const QSet& roles = QSet()); - virtual void visibleRolesChanged(const QList& current, const QList& previous); - virtual void visibleRolesSizesChanged(const QHash& current, const QHash& previous); - virtual void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous); - virtual void hoveredChanged(bool hovered); - virtual void selectedChanged(bool selected); - virtual void resizeEvent(QGraphicsSceneResizeEvent* event); - -private: - enum TextId { - Name, - Size, - Date, - Permissions, - Owner, - Group, - Type, - Destination, - Path, - TextIdCount // Mandatory last entry - }; - - void triggerCacheRefreshing(); - void updateExpansionArea(); - void updatePixmapCache(); - - void updateTextsCache(); - void updateIconsLayoutTextCache(); - void updateCompactLayoutTextCache(); - void updateDetailsLayoutTextCache(); - - void updateAdditionalInfoTextColor(); - - void drawPixmap(QPainter* painter, const QPixmap& pixmap); - - static QPixmap pixmapForIcon(const QString& name, int size); - static TextId roleTextId(const QByteArray& role); - -private: - bool m_isDir; - bool m_dirtyLayout; - bool m_dirtyContent; - QSet m_dirtyContentRoles; - - Layout m_layout; - QPointF m_pixmapPos; - QPixmap m_pixmap; - QSize m_scaledPixmapSize; - - QRectF m_hoverPixmapRect; - QPixmap m_hoverPixmap; - - QPointF m_textPos[TextIdCount]; - QStaticText m_text[TextIdCount]; - QRectF m_textRect; - - QList m_sortedVisibleRoles; - - QRectF m_expansionArea; - - QColor m_customTextColor; - QColor m_additionalInfoTextColor; - - QPixmap m_overlay; + int selectionLength(const QString& text) const override; }; #endif