forked from KDE/okular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
recentitemsmodel.h
64 lines (49 loc) · 1.26 KB
/
recentitemsmodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
SPDX-FileCopyrightText: 2021 Jiří Wolker <[email protected]>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef RECENTITEMSMODEL_H
#define RECENTITEMSMODEL_H
#include <QAbstractListModel>
#include <QFileIconProvider>
#include <QList>
#include <QModelIndex>
#include <QString>
#include <QUrl>
class KConfigGroup;
/**
* @todo write docs
*/
class RecentItemsModel : public QAbstractListModel
{
Q_OBJECT
public:
struct RecentItem {
QString name;
QUrl url;
};
/**
* Default constructor
*/
RecentItemsModel();
/**
* Destructor
*/
~RecentItemsModel() override;
void loadEntries(const KConfigGroup &cg);
void clearEntries();
int maxItems() const
{
return m_maxItems;
}
RecentItemsModel::RecentItem const *getItem(const QModelIndex &) const;
RecentItemsModel::RecentItem const *getItem(int index) const;
// Model implementation:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::ItemDataRole::DisplayRole) const override;
private:
QList<RecentItemsModel::RecentItem> m_recentItems;
int m_maxItems = 20;
QFileIconProvider m_iconProvider;
};
#endif // RECENTITEMSMODEL_H