]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kstandarditemlistwidget.h
Merge branch 'master' into frameworks
[dolphin.git] / src / kitemviews / kstandarditemlistwidget.h
index 76b0d143ca9734756ee648ac99f5afd64c7ea5db..403794fc3e53ecee6172fb64944cc8a1e69130e6 100644 (file)
@@ -38,12 +38,28 @@ public:
     KStandardItemListWidgetInformant();
     virtual ~KStandardItemListWidgetInformant();
 
-    virtual QSizeF itemSizeHint(int index, const KItemListView* view) const;
+    virtual void calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const;
 
     virtual qreal preferredRoleColumnWidth(const QByteArray& role,
                                            int index,
                                            const KItemListView* view) const;
 protected:
+    /**
+     * @return The value of the "text" role. The default implementation returns
+     *         view->model()->data(index)["text"]. If a derived class can
+     *         prevent the (possibly expensive) construction of the
+     *         QHash<QByteArray, QVariant> returned by KItemModelBase::data(int),
+     *         it can reimplement this function.
+     */
+    virtual QString itemText(int index, const KItemListView* view) const;
+
+    /**
+     * @return The value of the "isLink" role. The default implementation returns false.
+     *         The derived class should reimplement this function, when information about
+     *         links is available and in usage.
+     */
+    virtual bool itemIsLink(int index, const KItemListView* view) const;
+
     /**
      * @return String representation of the role \a role. The representation of
      *         a role might depend on other roles, so the values of all roles
@@ -52,6 +68,15 @@ protected:
     virtual QString roleText(const QByteArray& role,
                              const QHash<QByteArray, QVariant>& values) const;
 
+    /**
+    * @return A font based on baseFont which is customized for symlinks.
+    */
+    virtual QFont customizedFontForLinks(const QFont& baseFont) const;
+
+    void calculateIconsLayoutItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const;
+    void calculateCompactLayoutItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const;
+    void calculateDetailsLayoutItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const;
+
     friend class KStandardItemListWidget; // Accesses roleText()
 };
 
@@ -84,6 +109,7 @@ public:
     virtual QRectF iconRect() const;
     virtual QRectF textRect() const;
     virtual QRectF textFocusRect() const;
+    virtual QRectF selectionRect() const;
     virtual QRectF expansionToggleRect() const;
     virtual QRectF selectionToggleRect() const;
     virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
@@ -120,6 +146,8 @@ protected:
      */
     virtual QFont customizedFont(const QFont& baseFont) const;
 
+    virtual QPalette::ColorRole normalTextColorRole() const;
+
     void setTextColor(const QColor& color);
     QColor textColor() const;
 
@@ -131,6 +159,19 @@ protected:
      */
     QString roleText(const QByteArray& role, const QHash<QByteArray, QVariant>& values) const;
 
+    /**
+     * Fixes:
+     * Select the text without MIME-type extension
+     * This is file-item-specific and should be moved
+     * into KFileItemListWidget.
+     *
+     * Inherited classes can define, if the MIME-type extension
+     * should be selected or not.
+     *
+     * @return Selection length (with or without MIME-type extension)
+     */
+    virtual int selectionLength(const QString& text) 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 columnWidthChanged(const QByteArray& role, qreal current, qreal previous);
@@ -145,8 +186,8 @@ protected:
 
 private slots:
     void slotCutItemsChanged();
-    void slotRoleEditingCanceled(int index, const QByteArray& role, const QVariant& value);
-    void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value);
+    void slotRoleEditingCanceled(const QByteArray& role, const QVariant& value);
+    void slotRoleEditingFinished(const QByteArray& role, const QVariant& value);
 
 private:
     void triggerCacheRefreshing();
@@ -165,7 +206,13 @@ private:
 
     QRectF roleEditingRect(const QByteArray &role) const;
 
-    static QPixmap pixmapForIcon(const QString& name, int size);
+    /**
+     * Closes the role editor and returns the focus back
+     * to the KItemListContainer.
+     */
+    void closeRoleEditor();
+
+    static QPixmap pixmapForIcon(const QString& name, const QStringList& overlays, int size);
 
     /**
      * @return Preferred size of the rating-image based on the given
@@ -220,6 +267,7 @@ private:
     QPixmap m_rating;
 
     KItemListRoleEditor* m_roleEditor;
+    KItemListRoleEditor* m_oldRoleEditor;
 
     friend class KStandardItemListWidgetInformant; // Accesses private static methods to be able to
                                                    // share a common layout calculation