diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-29 20:17:42 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-29 20:17:42 +0200 |
| commit | 8e910f26a28b1b1beae363e6c19f39224f74e2e8 (patch) | |
| tree | 282b768b54c0966578944a5b2cd717ba0fe58cfa /src/favouritecollection.hpp.bak | |
| parent | dcba6f90718d3f009380ad2b2994790866b881e2 (diff) | |
| download | kristall-8e910f26a28b1b1beae363e6c19f39224f74e2e8.tar.gz | |
Paves road for new favourite system: Refactors the favourites into tree structure instead of flat list.
Diffstat (limited to 'src/favouritecollection.hpp.bak')
| -rw-r--r-- | src/favouritecollection.hpp.bak | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/favouritecollection.hpp.bak b/src/favouritecollection.hpp.bak new file mode 100644 index 0000000..043fdf2 --- /dev/null +++ b/src/favouritecollection.hpp.bak @@ -0,0 +1,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 |
