]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinplacesmodelsingleton.h
GIT_SILENT made messages (after extraction)
[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 bool panelsLocked() const;
30 void setPanelsLocked(bool locked);
31
32 protected:
33 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
34
35 private Q_SLOTS:
36 void slotTrashEmptinessChanged(bool isEmpty);
37
38 private:
39 bool isTrash(const QModelIndex &index) const;
40
41 bool m_isEmpty = false;
42 bool m_panelsLocked = true; // common-case, panels are locked
43 };
44
45 /**
46 * @brief Provides a global KFilePlacesModel instance.
47 */
48 class DolphinPlacesModelSingleton
49 {
50
51 public:
52 static DolphinPlacesModelSingleton& instance();
53
54 DolphinPlacesModel *placesModel() const;
55 /** A suffix to the application-name of the stored bookmarks is
56 added, which is only read by PlacesItemModel. */
57 static QString applicationNameSuffix();
58
59 DolphinPlacesModelSingleton(const DolphinPlacesModelSingleton&) = delete;
60 DolphinPlacesModelSingleton& operator=(const DolphinPlacesModelSingleton&) = delete;
61
62 private:
63 DolphinPlacesModelSingleton();
64
65 QScopedPointer<DolphinPlacesModel> m_placesModel;
66 };
67
68 #endif // DOLPHINPLACESMODELSINGLETON_H