]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kfileitemlistwidget.h
GIT_SILENT Update Appstream for new release
[dolphin.git] / src / kitemviews / kfileitemlistwidget.h
1 /*
2 * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef KFILEITEMLISTWIDGET_H
8 #define KFILEITEMLISTWIDGET_H
9
10 #include "dolphin_export.h"
11 #include "kitemviews/kstandarditemlistwidget.h"
12
13 class KFileItemListView;
14
15 /**
16 * @brief ItemList widget informant implementation for use with KFileItems.
17 *
18 * Code that does not expect KFileItems specifically should go to KStandardItemListWidgetInformant.
19 *
20 * @see KItemListWidgetInformant
21 */
22 class DOLPHIN_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidgetInformant
23 {
24 public:
25 KFileItemListWidgetInformant();
26 ~KFileItemListWidgetInformant() override;
27
28 protected:
29 QString itemText(int index, const KItemListView *view) const override;
30 bool itemIsLink(int index, const KItemListView *view) const override;
31 /** @see KStandardItemListWidget::roleText(). */
32 QString roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values, ForUsageAs forUsageAs = ForUsageAs::DisplayedText) const override;
33 QFont customizedFontForLinks(const QFont &baseFont) const override;
34
35 friend class KItemListDelegateAccessible;
36 };
37
38 /**
39 * @brief ItemList widget implementation for use with KFileItems.
40 *
41 * Code that does not expect KFileItems specifically should go to KStandardItemListWidget.
42 *
43 * @see KItemListWidget
44 */
45 class DOLPHIN_EXPORT KFileItemListWidget : public KStandardItemListWidget
46 {
47 Q_OBJECT
48
49 public:
50 KFileItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent);
51 ~KFileItemListWidget() override;
52
53 static KItemListWidgetInformant *createInformant();
54
55 /// Force-update the displayed icon
56 void forceUpdate();
57
58 protected:
59 virtual void hoverSequenceStarted() override;
60 virtual void hoverSequenceIndexChanged(int sequenceIndex) override;
61 virtual void hoverSequenceEnded() override;
62
63 bool isRoleRightAligned(const QByteArray &role) const override;
64 bool isHidden() const override;
65 QFont customizedFont(const QFont &baseFont) const override;
66
67 /**
68 * @return Selection length without MIME-type extension in number of unicode characters, which might be different from number of QChars.
69 */
70 int selectionLength(const QString &text) const override;
71
72 private:
73 KFileItemListView *listView();
74 };
75
76 #endif