blob: 043fdf29b0b1fab01718f23aff0ae9cc51cd441e (
plain) (
blame)
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
|
#ifndef FAVOURITECOLLECTION_HPP
#define FAVOURITECOLLECTION_HPP
#include <QObject>
#include <QAbstractListModel>
#include <QUrl>
#include <QSettings>
class FavouriteCollection : public QAbstractListModel
{
Q_OBJECT
public:
explicit FavouriteCollection(QObject *parent = nullptr);
void add(QUrl const & url);
void remove(QUrl const & url);
bool contains(QUrl const & url);
QUrl get(QModelIndex const & index) const ;
bool save(QString const & fileName) const;
bool save(QSettings & settings) const;
bool load(QString const & fileName);
bool load(QSettings & settings);
QVector<QUrl> getAll() const {
return this->items;
}
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
signals:
private:
QVector<QUrl> items;
};
#endif // FAVOURITECOLLECTION_HPP
|