File indexing completed on 2025-01-26 05:06:22

0001 /*
0002     SPDX-FileCopyrightText: 2014 Eike Hein <hein@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QSortFilterProxyModel>
0010 
0011 class KFilePlacesModel;
0012 
0013 class PlacesModel : public QSortFilterProxyModel
0014 {
0015     Q_OBJECT
0016 
0017     Q_PROPERTY(bool activityLinkingEnabled READ activityLinkingEnabled CONSTANT)
0018     Q_PROPERTY(bool showDesktopEntry READ showDesktopEntry WRITE setShowDesktopEntry NOTIFY showDesktopEntryChanged)
0019 
0020 public:
0021     explicit PlacesModel(QObject *parent = nullptr);
0022     ~PlacesModel() override;
0023 
0024     bool activityLinkingEnabled() const;
0025 
0026     bool showDesktopEntry() const;
0027     void setShowDesktopEntry(bool showDesktopEntry);
0028 
0029     QHash<int, QByteArray> roleNames() const override;
0030     Q_INVOKABLE QString urlForIndex(int idx) const;
0031     Q_INVOKABLE int indexForUrl(const QString &url) const;
0032 
0033 Q_SIGNALS:
0034     void placesChanged() const;
0035     void showDesktopEntryChanged() const;
0036 
0037 protected:
0038     bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
0039 
0040 private:
0041     KFilePlacesModel *const m_sourceModel;
0042     bool m_showDesktopEntry = true;
0043 };