1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org>
4 SPDX-FileCopyrightText: 2007 Pino Toscano <pino@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef OPENWITHDIALOG_P_H
10#define OPENWITHDIALOG_P_H
11
12#include <QAbstractItemModel>
13#include <QSortFilterProxyModel>
14#include <QTreeView>
15
16#include <memory>
17
18class KApplicationModelPrivate;
19
20/**
21 * @internal
22 */
23class KApplicationModel : public QAbstractItemModel
24{
25 Q_OBJECT
26
27public:
28 explicit KApplicationModel(QObject *parent = nullptr);
29 ~KApplicationModel() override;
30 bool canFetchMore(const QModelIndex &parent) const override;
31 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
32 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
33 void fetchMore(const QModelIndex &parent) override;
34 // Qt::ItemFlags flags(const QModelIndex &index) const override;
35 bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
36 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
37 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
38 QModelIndex parent(const QModelIndex &index) const override;
39 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
40
41 QString entryPathFor(const QModelIndex &index) const;
42 QString execFor(const QModelIndex &index) const;
43 bool isDirectory(const QModelIndex &index) const;
44 void fetchAll(const QModelIndex &parent);
45
46private:
47 friend class KApplicationModelPrivate;
48 std::unique_ptr<KApplicationModelPrivate> const d;
49
50 Q_DISABLE_COPY(KApplicationModel)
51};
52
53/**
54 * @internal
55 */
56class QTreeViewProxyFilter : public QSortFilterProxyModel
57{
58 Q_OBJECT
59
60public:
61 explicit QTreeViewProxyFilter(QObject *parent = nullptr);
62 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
63};
64
65class KApplicationViewPrivate;
66
67/**
68 * @internal
69 */
70class KApplicationView : public QTreeView
71{
72 Q_OBJECT
73
74public:
75 explicit KApplicationView(QWidget *parent = nullptr);
76 ~KApplicationView() override;
77
78 void setModels(KApplicationModel *model, QSortFilterProxyModel *proxyModel);
79 QSortFilterProxyModel *proxyModel();
80
81 bool isDirSel() const;
82
83Q_SIGNALS:
84 void selected(const QString &_name, const QString &_exec);
85 void highlighted(const QString &_name, const QString &_exec);
86
87protected Q_SLOTS:
88 void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
89
90private Q_SLOTS:
91 void slotSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
92
93private:
94 friend class KApplicationViewPrivate;
95 std::unique_ptr<KApplicationViewPrivate> const d;
96
97 Q_DISABLE_COPY(KApplicationView)
98};
99
100#endif
101

source code of kio/src/widgets/kopenwithdialog_p.h