]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinplacesmodelsingleton.h
Merge branch 'release/21.12'
[dolphin.git] / src / dolphinplacesmodelsingleton.h
1 /*
2 * SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef DOLPHINPLACESMODELSINGLETON_H
8 #define DOLPHINPLACESMODELSINGLETON_H
9
10 #include <QString>
11 #include <QScopedPointer>
12
13 #include <KFilePlacesModel>
14
15 /**
16 * @brief Dolphin's special-cased KFilePlacesModel
17 *
18 * It returns the trash's icon based on whether
19 * it is full or not.
20 */
21 class DolphinPlacesModel : public KFilePlacesModel
22 {
23 Q_OBJECT
24
25 public:
26 explicit DolphinPlacesModel(const QString &alternativeApplicationName, QObject *parent = nullptr);
27 ~DolphinPlacesModel() override;
28
29 protected:
30 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
31
32 private Q_SLOTS:
33 void slotTrashEmptinessChanged(bool isEmpty);
34
35 private:
36 bool isTrash(const QModelIndex &index) const;
37
38 bool m_isEmpty = false;
39 };
40
41 /**
42 * @brief Provides a global KFilePlacesModel instance.
43 */
44 class DolphinPlacesModelSingleton
45 {
46
47 public:
48 static DolphinPlacesModelSingleton& instance();
49
50 KFilePlacesModel *placesModel() const;
51 /** A suffix to the application-name of the stored bookmarks is
52 added, which is only read by PlacesItemModel. */
53 static QString applicationNameSuffix();
54
55 DolphinPlacesModelSingleton(const DolphinPlacesModelSingleton&) = delete;
56 DolphinPlacesModelSingleton& operator=(const DolphinPlacesModelSingleton&) = delete;
57
58 private:
59 DolphinPlacesModelSingleton();
60
61 QScopedPointer<KFilePlacesModel> m_placesModel;
62 };
63
64 #endif // DOLPHINPLACESMODELSINGLETON_H