1 | /* |
2 | This file is part of the KDE project |
3 | SPDX-FileCopyrightText: 2007 Kevin Ottens <ervin@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-only |
6 | */ |
7 | |
8 | #ifndef KFILEPLACESITEM_P_H |
9 | #define KFILEPLACESITEM_P_H |
10 | |
11 | #include "kfileplacesmodel.h" |
12 | #include <KBookmark> |
13 | #include <KBookmarkManager> |
14 | #include <QObject> |
15 | #include <QPointer> |
16 | #include <QStringList> |
17 | #include <QUrl> |
18 | #include <solid/device.h> |
19 | |
20 | class KDirLister; |
21 | namespace Solid |
22 | { |
23 | class Block; |
24 | class StorageAccess; |
25 | class StorageVolume; |
26 | class StorageDrive; |
27 | class NetworkShare; |
28 | class OpticalDrive; |
29 | class OpticalDisc; |
30 | class PortableMediaPlayer; |
31 | } |
32 | |
33 | class KFilePlacesItem : public QObject |
34 | { |
35 | Q_OBJECT |
36 | public: |
37 | KFilePlacesItem(KBookmarkManager *manager, const QString &address, const QString &udi, KFilePlacesModel *parent); |
38 | ~KFilePlacesItem() override; |
39 | |
40 | QString id() const; |
41 | |
42 | bool isDevice() const; |
43 | KFilePlacesModel::DeviceAccessibility deviceAccessibility() const; |
44 | bool isTeardownAllowed() const; |
45 | bool isTeardownOverlayRecommended() const; |
46 | bool isEjectAllowed() const; |
47 | KBookmark bookmark() const; |
48 | void setBookmark(const KBookmark &bookmark); |
49 | Solid::Device device() const; |
50 | QVariant data(int role) const; |
51 | KFilePlacesModel::GroupType groupType() const; |
52 | bool isHidden() const; |
53 | void setHidden(bool hide); |
54 | |
55 | bool hasSupportedScheme(const QStringList &schemes) const; |
56 | |
57 | static KBookmark |
58 | createBookmark(KBookmarkManager *manager, const QString &label, const QUrl &url, const QString &iconName, KFilePlacesItem *after = nullptr); |
59 | /*! |
60 | * \a untranslatedLabel text for label. If to be translated, should be set by kli18nc("KFile System Bookmarks", "Label text").untranslatedText(). |
61 | */ |
62 | static KBookmark createSystemBookmark(KBookmarkManager *manager, |
63 | const char *untranslatedLabel, |
64 | const QUrl &url, |
65 | const QString &iconName, |
66 | const KBookmark &after = KBookmark()); |
67 | static KBookmark createDeviceBookmark(KBookmarkManager *manager, const Solid::Device &device); |
68 | static KBookmark createTagBookmark(KBookmarkManager *manager, const QString &tag); |
69 | |
70 | Q_SIGNALS: |
71 | void itemChanged(const QString &id, const QList<int> &roles = {}); |
72 | |
73 | private Q_SLOTS: |
74 | void onAccessibilityChanged(bool); |
75 | |
76 | private: |
77 | QVariant bookmarkData(int role) const; |
78 | QVariant deviceData(int role) const; |
79 | |
80 | QString iconNameForBookmark(const KBookmark &bookmark) const; |
81 | |
82 | static QString generateNewId(); |
83 | bool updateDeviceInfo(const QString &udi); |
84 | |
85 | KBookmarkManager *m_manager; |
86 | KBookmark m_bookmark; |
87 | bool m_folderIsEmpty; |
88 | bool m_isCdrom; |
89 | bool m_isAccessible; |
90 | bool m_isTeardownAllowed; |
91 | bool m_isTeardownOverlayRecommended; |
92 | bool m_isTeardownInProgress; |
93 | bool m_isSetupInProgress; |
94 | bool m_isEjectInProgress; |
95 | bool m_isReadOnly; |
96 | QString m_text; |
97 | Solid::Device m_device; |
98 | QPointer<Solid::StorageAccess> m_access; |
99 | QPointer<Solid::StorageVolume> m_volume; |
100 | QPointer<Solid::StorageDrive> m_drive; |
101 | QPointer<Solid::Block> m_block; |
102 | QPointer<Solid::OpticalDrive> m_opticalDrive; |
103 | QPointer<Solid::OpticalDisc> m_disc; |
104 | QPointer<Solid::PortableMediaPlayer> m_player; |
105 | QPointer<Solid::NetworkShare> m_networkShare; |
106 | QString m_deviceIconName; |
107 | QStringList m_emblems; |
108 | QString m_backingFile; |
109 | KFilePlacesModel::GroupType m_groupType = KFilePlacesModel::UnknownType; |
110 | QString m_groupName; |
111 | mutable QString m_deviceDisplayName; |
112 | }; |
113 | |
114 | #endif |
115 | |