X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/5ce591f6c455bd91e4be4fbfed3939de20156e96..a35af3a0d2022a23c5a1cc30d693141a13673b8f:/src/kitemviews/kstandarditemlistwidget.h diff --git a/src/kitemviews/kstandarditemlistwidget.h b/src/kitemviews/kstandarditemlistwidget.h index d182755fa..18f86dbcb 100644 --- a/src/kitemviews/kstandarditemlistwidget.h +++ b/src/kitemviews/kstandarditemlistwidget.h @@ -54,12 +54,19 @@ protected: */ virtual bool itemIsLink(int index, const KItemListView *view) const; + /** Configure whether the requested text should be optimized for viewing on a screen or for being read out aloud by a text-to-speech engine. */ + enum class ForUsageAs { DisplayedText, SpokenText }; + /** + * @param role The role the text is being requested for. + * @param values The data of the item. All the data is passed because the text might depend on multiple data points. + * @param forUsageAs Whether the roleText should be optimized for displaying (i.e. kept somewhat short) or optimized for speaking e.g. by screen readers + * or text-to-speech in general (i.e. by prefering announcing a month as July instead of as the number 7). * @return String representation of the role \a role. The representation of * a role might depend on other roles, so the values of all roles * are passed as parameter. */ - virtual QString roleText(const QByteArray &role, const QHash &values) const; + virtual QString roleText(const QByteArray &role, const QHash &values, ForUsageAs forUsageAs = ForUsageAs::DisplayedText) const; /** * @return A font based on baseFont which is customized for symlinks. @@ -151,8 +158,8 @@ protected: void setTextColor(const QColor &color); QColor textColor(const QWidget &widget) const; - void setOverlay(const QPixmap &overlay); - QPixmap overlay() const; + void setOverlays(QHash &overlay); + QHash overlays() const; /** * @see KStandardItemListWidgetInformant::roleText(). @@ -169,7 +176,7 @@ protected: void dataChanged(const QHash ¤t, const QSet &roles = QSet()) override; void visibleRolesChanged(const QList ¤t, const QList &previous) override; void columnWidthChanged(const QByteArray &role, qreal current, qreal previous) override; - void sidePaddingChanged(qreal width) override; + void sidePaddingChanged(qreal leftPaddingWidth, qreal rightPaddingWidth) override; void styleOptionChanged(const KItemListStyleOption ¤t, const KItemListStyleOption &previous) override; void hoveredChanged(bool hovered) override; void selectedChanged(bool selected) override; @@ -205,13 +212,18 @@ private: void updateCompactLayoutTextCache(); void updateDetailsLayoutTextCache(); + QPixmap addOverlays(const QPixmap &pixmap, + const QHash &overlays, + const QSize &size, + qreal devicePixelRatioF, + QIcon::Mode mode = QIcon::Normal) const; + void drawPixmap(QPainter *painter, const QPixmap &pixmap); + /** Draw the lines and arrows that visualize the expanded state and level of this row. */ void drawSiblingsInformation(QPainter *painter); QRectF roleEditingRect(const QByteArray &role) const; - QString elideRightKeepExtension(const QString &text, int elidingWidth) const; - /** * Escapes text for display purposes. * @@ -225,7 +237,7 @@ private: */ void closeRoleEditor(); - QPixmap pixmapForIcon(const QString &name, const QStringList &overlays, int size, QIcon::Mode mode) const; + QPixmap pixmapForIcon(const QString &name, const QSize &size, QIcon::Mode mode) const; /** * @return Preferred size of the rating-image based on the given @@ -277,7 +289,7 @@ private: QColor m_customTextColor; QColor m_additionalInfoTextColor; - QPixmap m_overlay; + QHash m_overlays; QPixmap m_rating; KItemListRoleEditor *m_roleEditor;