digiKam
tagmngrlistmodel.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 20013-08-22
7  * Description : List View Model with support for mime data and drag-n-drop
8  *
9  * Copyright (C) 2013 by Veaceslav Munteanu <veaceslav dot munteanu90 at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_TAG_MNGR_LIST_MODEL_H
25 #define DIGIKAM_TAG_MNGR_LIST_MODEL_H
26 
27 // Qt includes
28 
29 #include <QAbstractItemModel>
30 #include <QModelIndex>
31 #include <QVariant>
32 
33 namespace Digikam
34 {
35 
36 class ListItem;
37 
38 class TagMngrListModel : public QAbstractItemModel
39 {
40  Q_OBJECT
41 
42 public:
43 
44  explicit TagMngrListModel(QObject* const parent = nullptr);
45  ~TagMngrListModel() override;
46 
54 
59  QList<ListItem*> allItems() const;
60 
61  void deleteItem(ListItem* const item);
62 
66  QVariant data(const QModelIndex& index, int role) const override;
67 
68  Qt::ItemFlags flags(const QModelIndex& index) const override;
69 
70  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
71 
72  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
73 
74  QModelIndex parent(const QModelIndex& index) const override;
75 
76  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
77 
78  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
79 
80  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
81 
86  Qt::DropActions supportedDropActions() const override;
87  QStringList mimeTypes() const override;
88  QMimeData* mimeData(const QModelIndexList& indexes) const override;
89  bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row,
90  int column, const QModelIndex& parent) override;
91 
93 
94 private:
95 
96  class Private;
97  Private* const d;
98 };
99 
100 } // namespace Digikam
101 
102 #endif // DIGIKAM_TAG_MNGR_LIST_MODEL_H
Definition: tagmngrlistitem.h:36
Definition: tagmngrlistmodel.h:39
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Definition: tagmngrlistmodel.cpp:143
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: tagmngrlistmodel.cpp:292
QModelIndex parent(const QModelIndex &index) const override
Definition: tagmngrlistmodel.cpp:332
QList< ListItem * > allItems() const
allItems - return all items from List, usually to be saved in KConfig
Definition: tagmngrlistmodel.cpp:100
Qt::DropActions supportedDropActions() const override
Definition: tagmngrlistmodel.cpp:130
TagMngrListModel(QObject *const parent=nullptr)
Definition: tagmngrlistmodel.cpp:59
ListItem * addItem(QList< QVariant > values)
addItem - add new item to list
Definition: tagmngrlistmodel.cpp:74
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: tagmngrlistmodel.cpp:277
~TagMngrListModel() override
Definition: tagmngrlistmodel.cpp:68
QStringList mimeTypes() const override
Definition: tagmngrlistmodel.cpp:135
QMimeData * mimeData(const QModelIndexList &indexes) const override
Definition: tagmngrlistmodel.cpp:161
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: tagmngrlistmodel.cpp:350
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: tagmngrlistmodel.cpp:302
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: tagmngrlistmodel.cpp:123
QVariant data(const QModelIndex &index, int role) const override
Definition: tagmngrlistmodel.cpp:255
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Definition: tagmngrlistmodel.cpp:181
void deleteItem(ListItem *const item)
Definition: tagmngrlistmodel.cpp:110
QList< int > getDragNewSelection() const
Definition: tagmngrlistmodel.cpp:105
qulonglong value
Definition: itemviewutilities.cpp:592
@ Orientation
Definition: coredbfields.h:86
Definition: datefolderview.cpp:43
DropAction
Definition: itemdragdrop.cpp:60