]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemlistwidget.h
Fix focus-rectangle issues
[dolphin.git] / src / kitemviews / kfileitemlistwidget.h
index 4a44a846889de014a8a128cfb6df889509948a6c..44451360b343164b41e42e32d304899bb09b1790 100644 (file)
@@ -28,6 +28,9 @@
 #include <QPointF>
 #include <QStaticText>
 
+class KItemListView;
+class KItemListStyleOption;
+
 class LIBDOLPHINPRIVATE_EXPORT KFileItemListWidget : public KItemListWidget
 {
     Q_OBJECT
@@ -46,20 +49,32 @@ public:
     void setLayout(Layout layout);
     Layout layout() const;
 
+    void setSupportsItemExpanding(bool supportsItemExpanding);
+    bool supportsItemExpanding() const;
+
     virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
 
     virtual QRectF iconRect() const;
     virtual QRectF textRect() const;
+    virtual QRectF textFocusRect() const;
     virtual QRectF expansionToggleRect() const;
     virtual QRectF selectionToggleRect() const;
 
     /**
-     * @return Shown string for the role \p role of the item with the values \p values.
+     * Implementation of KItemListWidgetCreatorBase::itemSizeHint() when
+     * using the KItemListWidgetCreator-template.
+     *
+     * @see KItemListView
      */
-    // 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<QByteArray, QVariant>& values);
+    static QSizeF itemSizeHint(int index, const KItemListView* view);
+
+    /**
+     * Implementation of KItemListWidgetCreatorBase::preferredRoleColumnWidth() when
+     * using the KItemListWidgetCreator-template.
+     *
+     * @see KItemListView
+     */
+    static qreal preferredRoleColumnWidth(const QByteArray& role, int index, const KItemListView* view);
 
 protected:
     /**
@@ -79,13 +94,14 @@ protected:
 
     void setOverlay(const QPixmap& overlay);
     QPixmap overlay() const;
-    
+
     virtual void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>());
     virtual void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous);
-    virtual void visibleRolesSizesChanged(const QHash<QByteArray, QSizeF>& current, const QHash<QByteArray, QSizeF>& previous);
+    virtual void columnWidthChanged(const QByteArray& role, qreal current, qreal previous);
     virtual void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous);
     virtual void hoveredChanged(bool hovered);
     virtual void selectedChanged(bool selected);
+    virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous);
     virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
     virtual void showEvent(QShowEvent* event);
     virtual void hideEvent(QHideEvent* event);
@@ -94,17 +110,11 @@ private slots:
     void slotCutItemsChanged();
 
 private:
-    enum TextId {
+    enum RoleType {
         Name,
         Size,
         Date,
-        Permissions,
-        Owner,
-        Group,
-        Type,
-        Destination,
-        Path,
-        TextIdCount // Mandatory last entry
+        Generic  // Mandatory last entry
     };
 
     void triggerCacheRefreshing();
@@ -115,20 +125,27 @@ private:
     void updateIconsLayoutTextCache();
     void updateCompactLayoutTextCache();
     void updateDetailsLayoutTextCache();
-    
+
     void updateAdditionalInfoTextColor();
 
     void drawPixmap(QPainter* painter, const QPixmap& pixmap);
+    void drawSiblingsInformation(QPainter* painter);
 
     static QPixmap pixmapForIcon(const QString& name, int size);
-    static TextId roleTextId(const QByteArray& role);
     static void applyCutEffect(QPixmap& pixmap);
     static void applyHiddenEffect(QPixmap& pixmap);
+    static RoleType roleType(const QByteArray& role);
+
+    /**
+     * @return Shown string for the role \p role of the item with the values \p values.
+     */
+    static QString roleText(const QByteArray& role, const QHash<QByteArray, QVariant>& values);
 
 private:
     bool m_isCut;
     bool m_isHidden;
     bool m_isExpandable;
+    bool m_supportsItemExpanding;
 
     bool m_dirtyLayout;
     bool m_dirtyContent;
@@ -142,8 +159,13 @@ private:
     QRectF m_iconRect;          // Cache for KItemListWidget::iconRect()
     QPixmap m_hoverPixmap;      // Cache for modified m_pixmap when hovering the item
 
-    QPointF m_textPos[TextIdCount];
-    QStaticText m_text[TextIdCount];
+    struct TextInfo
+    {
+        QPointF pos;
+        QStaticText staticText;
+    };
+    QHash<QByteArray, TextInfo*> m_textInfo;
+
     QRectF m_textRect;
 
     QList<QByteArray> m_sortedVisibleRoles;