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
20class KDirLister;
21namespace Solid
22{
23class StorageAccess;
24class StorageVolume;
25class StorageDrive;
26class NetworkShare;
27class OpticalDrive;
28class OpticalDisc;
29class PortableMediaPlayer;
30}
31
32class KFilePlacesItem : public QObject
33{
34 Q_OBJECT
35public:
36 KFilePlacesItem(KBookmarkManager *manager, const QString &address, const QString &udi, KFilePlacesModel *parent);
37 ~KFilePlacesItem() override;
38
39 QString id() const;
40
41 bool isDevice() const;
42 KFilePlacesModel::DeviceAccessibility deviceAccessibility() const;
43 bool isTeardownAllowed() const;
44 bool isTeardownOverlayRecommended() const;
45 bool isEjectAllowed() const;
46 KBookmark bookmark() const;
47 void setBookmark(const KBookmark &bookmark);
48 Solid::Device device() const;
49 QVariant data(int role) const;
50 KFilePlacesModel::GroupType groupType() const;
51 bool isHidden() const;
52 void setHidden(bool hide);
53
54 bool hasSupportedScheme(const QStringList &schemes) const;
55
56 static KBookmark
57 createBookmark(KBookmarkManager *manager, const QString &label, const QUrl &url, const QString &iconName, KFilePlacesItem *after = nullptr);
58 /**
59 * @param untranslatedLabel text for label. If to be translated, should be set by kli18nc("KFile System Bookmarks", "Label text").untranslatedText().
60 */
61 static KBookmark createSystemBookmark(KBookmarkManager *manager,
62 const char *untranslatedLabel,
63 const QUrl &url,
64 const QString &iconName,
65 const KBookmark &after = KBookmark());
66 static KBookmark createDeviceBookmark(KBookmarkManager *manager, const Solid::Device &device);
67 static KBookmark createTagBookmark(KBookmarkManager *manager, const QString &tag);
68
69Q_SIGNALS:
70 void itemChanged(const QString &id, const QList<int> &roles = {});
71
72private Q_SLOTS:
73 void onAccessibilityChanged(bool);
74
75private:
76 QVariant bookmarkData(int role) const;
77 QVariant deviceData(int role) const;
78
79 QString iconNameForBookmark(const KBookmark &bookmark) const;
80
81 static QString generateNewId();
82 bool updateDeviceInfo(const QString &udi);
83
84 KBookmarkManager *m_manager;
85 KBookmark m_bookmark;
86 bool m_folderIsEmpty;
87 bool m_isCdrom;
88 bool m_isAccessible;
89 bool m_isTeardownAllowed;
90 bool m_isTeardownOverlayRecommended;
91 bool m_isTeardownInProgress;
92 bool m_isSetupInProgress;
93 bool m_isEjectInProgress;
94 bool m_isReadOnly;
95 QString m_text;
96 Solid::Device m_device;
97 QPointer<Solid::StorageAccess> m_access;
98 QPointer<Solid::StorageVolume> m_volume;
99 QPointer<Solid::StorageDrive> m_drive;
100 QPointer<Solid::OpticalDrive> m_opticalDrive;
101 QPointer<Solid::OpticalDisc> m_disc;
102 QPointer<Solid::PortableMediaPlayer> m_player;
103 QPointer<Solid::NetworkShare> m_networkShare;
104 QString m_deviceIconName;
105 QStringList m_emblems;
106 QString m_groupName;
107 mutable QString m_deviceDisplayName;
108};
109
110#endif
111

source code of kio/src/filewidgets/kfileplacesitem_p.h