Debian Codegraph @

include/BookmarksPanel/BookmarksItemModel.h

raw symbols SCIP
1 /*
2 * Copyright 2014 Mihai Niculescu <[email protected]>
3 *
4 * This file is part of EqualX Project (https://launchpad.net/equalx/)
5 *
6 * EqualX is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * EqualX is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef BOOKMARKSITEMMODEL_H
21 #define BOOKMARKSITEMMODEL_H
22
23 #include <QAbstractItemModel>
24 #include <QModelIndexList>
25
26 #include "Library/LibraryData.h"
27
28 class BookmarkItem;
29 class LibraryManager;
30
31 class BookmarksItemModel : public QAbstractItemModel
32 {
33 Q_OBJECT
34 public:
35 BookmarksItemModel(LibraryManager* lib, QObject *parent = 0);
36 ~BookmarksItemModel();
37
38 QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
39 bool canFetchMore(const QModelIndex &parent) const;
40 void fetchMore(const QModelIndex &parent);
41 bool hasChildren(const QModelIndex &parent) const;
42
43 QVariant headerData(int section, Qt::Orientation orientation,
44 int role = Qt::DisplayRole) const;
45 QModelIndex index(int row, int column,
46 const QModelIndex &parent = QModelIndex()) const;
47
48 BookmarkItem* invisibleRootItem() const;
49 BookmarkItem* itemFromIndex(const QModelIndex &index) const;
50
51 QModelIndex parent(const QModelIndex &index) const;
52 int rowCount(const QModelIndex &parent = QModelIndex()) const;
53 int columnCount(const QModelIndex &parent = QModelIndex()) const;
54
55 bool insertRow(int row, const QModelIndex &parent);
56 bool insertRows(int row, int count, const QModelIndex &parent); // insert undefined rows into model, but not in library (use setData to make them valid)
57 bool removeRow(int row, const QModelIndex & parent = QModelIndex());
58 bool removeRows(int row, int count, const QModelIndex &parent);
59
60 // drag n drop support
61 Qt::DropActions supportedDropActions() const;
62 Qt::DropActions supportedDragActions() const;
63 Qt::ItemFlags flags(const QModelIndex &index) const;
64 QStringList mimeTypes() const;
65 QMimeData *mimeData(const QModelIndexList &indexes) const;
66 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
67
68 // Specific methods to this model
69 QVariant getCompleteData(const QModelIndex &index) const; // returns complete data from DB of this index
70
71 public slots:
72 void onFolderChanged(const QString &dirPath);
73 private:
74 QModelIndex findItem(const QString &dirPath);
75
76 BookmarkItem *mRootItem;
77 LibraryManager *mLibrary;
78 };
79
80 #endif // BOOKMARKSITEMMODEL_H