diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-01-07 00:48:27 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-01-07 00:48:27 +0100 |
commit | e0f64f9330fc30553dc9d8dcf308079f5d391526 (patch) | |
tree | 8c21a08f25208150ed4f0bcbf8496334c2e08bcc /lib/bookmarks/bookmarksmodel.h | |
parent | Updated ReadMe and pkgbuild (diff) | |
download | smolbote-e0f64f9330fc30553dc9d8dcf308079f5d391526.tar.xz |
Added BookmarksModel
TODO: Editing bookmarks
TODO: Saving bookmarks
BUG: Completer doesn't search through folders
Diffstat (limited to 'lib/bookmarks/bookmarksmodel.h')
-rw-r--r-- | lib/bookmarks/bookmarksmodel.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/bookmarks/bookmarksmodel.h b/lib/bookmarks/bookmarksmodel.h new file mode 100644 index 0000000..7493f1c --- /dev/null +++ b/lib/bookmarks/bookmarksmodel.h @@ -0,0 +1,50 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: git://neueland.iserlohn-fortress.net/smolbote.git + * + * SPDX-License-Identifier: GPL-3.0 + */ + +#include <QAbstractItemModel> +#include <QIcon> +#include "bookmarkitem.h" + +#ifndef BOOKMARKSMODEL_H +#define BOOKMARKSMODEL_H + +class QStyle; +class BookmarksModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + enum { + OpenUrlRole = Qt::UserRole + 1 + }; + + explicit BookmarksModel(QStyle *style, QObject *parent = nullptr); + ~BookmarksModel() override; + + void setRoot(BookmarkItem *root); + + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + + QModelIndex index(BookmarkItem *node) const; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &index) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role) const override; + + bool hasChildren(const QModelIndex &parent) const override ; + +private: + QIcon folderIcon; + QIcon bookmarkIcon; + + BookmarkItem *m_rootItem; + +}; + +#endif //BOOKMARKSMODEL_H |