File indexing completed on 2023-10-01 04:05:46

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2007 Kevin Ottens <ervin@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #ifndef KFILEPLACESITEM_P_H
0009 #define KFILEPLACESITEM_P_H
0010 
0011 #include "kfileplacesmodel.h"
0012 #include <KBookmark>
0013 #include <QObject>
0014 #include <QPointer>
0015 #include <QStringList>
0016 #include <QUrl>
0017 #include <solid/device.h>
0018 
0019 class KDirLister;
0020 namespace Solid
0021 {
0022 class StorageAccess;
0023 class StorageVolume;
0024 class StorageDrive;
0025 class NetworkShare;
0026 class OpticalDisc;
0027 class PortableMediaPlayer;
0028 }
0029 
0030 class KFilePlacesItem : public QObject
0031 {
0032     Q_OBJECT
0033 public:
0034     KFilePlacesItem(KBookmarkManager *manager, const QString &address, const QString &udi, KFilePlacesModel *parent);
0035     ~KFilePlacesItem() override;
0036 
0037     QString id() const;
0038 
0039     bool isDevice() const;
0040     KFilePlacesModel::DeviceAccessibility deviceAccessibility() const;
0041     bool isTeardownAllowed() const;
0042     bool isTeardownOverlayRecommended() const;
0043     bool isEjectAllowed() const;
0044     KBookmark bookmark() const;
0045     void setBookmark(const KBookmark &bookmark);
0046     Solid::Device device() const;
0047     QVariant data(int role) const;
0048     KFilePlacesModel::GroupType groupType() const;
0049     bool isHidden() const;
0050     void setHidden(bool hide);
0051 
0052     bool hasSupportedScheme(const QStringList &schemes) const;
0053 
0054     static KBookmark
0055     createBookmark(KBookmarkManager *manager, const QString &label, const QUrl &url, const QString &iconName, KFilePlacesItem *after = nullptr);
0056     /**
0057      * @param untranslatedLabel text for label. If to be translated, should be set by kli18nc("KFile System Bookmarks", "Label text").untranslatedText().
0058      */
0059     static KBookmark createSystemBookmark(KBookmarkManager *manager,
0060                                           const char *untranslatedLabel,
0061                                           const QUrl &url,
0062                                           const QString &iconName,
0063                                           const KBookmark &after = KBookmark());
0064     static KBookmark createDeviceBookmark(KBookmarkManager *manager, const QString &udi);
0065     static KBookmark createTagBookmark(KBookmarkManager *manager, const QString &tag);
0066 
0067 Q_SIGNALS:
0068     void itemChanged(const QString &id, const QVector<int> &roles = {});
0069 
0070 private Q_SLOTS:
0071     void onAccessibilityChanged(bool);
0072 
0073 private:
0074     QVariant bookmarkData(int role) const;
0075     QVariant deviceData(int role) const;
0076 
0077     QString iconNameForBookmark(const KBookmark &bookmark) const;
0078 
0079     static QString generateNewId();
0080     bool updateDeviceInfo(const QString &udi);
0081 
0082     KBookmarkManager *m_manager;
0083     KBookmark m_bookmark;
0084     bool m_folderIsEmpty;
0085     bool m_isCdrom;
0086     bool m_isAccessible;
0087     bool m_isTeardownAllowed;
0088     bool m_isTeardownOverlayRecommended;
0089     bool m_isTeardownInProgress;
0090     bool m_isSetupInProgress;
0091     QString m_text;
0092     Solid::Device m_device;
0093     QPointer<Solid::StorageAccess> m_access;
0094     QPointer<Solid::StorageVolume> m_volume;
0095     QPointer<Solid::StorageDrive> m_drive;
0096     QPointer<Solid::OpticalDisc> m_disc;
0097     QPointer<Solid::PortableMediaPlayer> m_player;
0098     QPointer<Solid::NetworkShare> m_networkShare;
0099     QString m_deviceIconName;
0100     QStringList m_emblems;
0101     QString m_groupName;
0102     mutable QString m_deviceDisplayName;
0103 };
0104 
0105 #endif