digiKam
rgtagmodel.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 : 2010-05-12
7  * Description : A model to hold information about image tags.
8  *
9  * Copyright (C) 2010 by Michael G. Hansen <mike at mghansen dot de>
10  * Copyright (C) 2010 by Gabriel Voicu <ping dot gabi at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_RG_TAG_MODEL_H
26 #define DIGIKAM_RG_TAG_MODEL_H
27 
28 // Qt includes
29 
30 #include <QAbstractItemModel>
31 #include <QItemSelectionModel>
32 
33 // Local includes
34 
35 #include "gpsitemcontainer.h"
36 #include "treebranch.h"
37 #include "digikam_export.h"
38 
39 namespace Digikam
40 {
41 
52 class DIGIKAM_EXPORT RGTagModel : public QAbstractItemModel
53 {
54  Q_OBJECT
55 
56 public:
57 
63  explicit RGTagModel(QAbstractItemModel* const externalTagModel,
64  QObject* const parent = nullptr);
65 
69  ~RGTagModel() override;
70 
72 
73  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
74  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
75  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
76  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
77  QModelIndex parent(const QModelIndex& index) const override;
78  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
79  bool setHeaderData(int section, Qt::Orientation orientation, const QVariant& value, int role) override;
80  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
81  Qt::ItemFlags flags(const QModelIndex& index) const override;
82 
84 
89  QModelIndex fromSourceIndex(const QModelIndex& externalTagModelIndex) const;
90 
95  QModelIndex toSourceIndex(const QModelIndex& tagModelIndex) const;
96 
102  void addSpacerTag(const QModelIndex& parent, const QString& spacerName);
103 
109  QPersistentModelIndex addNewTag(const QModelIndex& parent,
110  const QString& newTagName,
111  const QString& newElement);
112 
121  QList<QList<TagData> > addNewData(const QStringList& elements, const QStringList& resultedData);
122 
131  void addDataInTree(TreeBranch* currentBranch,
132  int currentRow,
133  const QStringList& addressElements,
134  const QStringList& elementsData);
135 
139  QList<TagData> getTagAddress();
140 
147  void findAndDeleteSpacersOrNewTags(TreeBranch* currentBranch,
148  int currentRow,
149  Type whatShouldRemove);
150 
156  void deleteAllSpacersOrNewTags(const QModelIndex& currentIndex, Type whatShouldRemove);
157 
170  void readdTag(TreeBranch*& currentBranch,
171  int currentRow,
172  const QList<TagData>& tagAddressElements,
173  int currentAddressElementIndex);
174 
179  void readdNewTags(const QList<QList<TagData> >& tagAddressList);
180 
185  void deleteTag(const QModelIndex& currentIndex);
186 
191  QList<QList<TagData> > getSpacers();
192 
197  void climbTreeAndGetSpacers(const TreeBranch* currentBranch);
198 
204  QList<TagData> getSpacerAddress(TreeBranch* currentBranch);
205 
211  void addExternalTags(TreeBranch* parentBranch, int currentRow);
212 
216  void addAllExternalTagsToTreeView();
217 
221  void addAllSpacersToTag(const QModelIndex& currentIndex,
222  const QStringList& spacerList,
223  int spacerListIndex);
224 
230  Type getTagType(const QModelIndex& index) const;
231 
237  TreeBranch* branchFromIndex(const QModelIndex& index) const;
238 
239 public Q_SLOTS:
240 
241  void slotSourceDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
242  void slotSourceHeaderDataChanged(const Qt::Orientation orientation, int first, int last);
243  void slotColumnsAboutToBeInserted(const QModelIndex& parent, int start, int end);
244  void slotColumnsAboutToBeMoved(const QModelIndex& sourceParent, int sourceStart, int sourceEnd,
245  const QModelIndex& destinationParent, int destinationColumn);
246  void slotColumnsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
247  void slotColumnsInserted();
248  void slotColumnsMoved();
249  void slotColumnsRemoved();
250  void slotLayoutAboutToBeChanged();
251  void slotLayoutChanged();
252  void slotModelAboutToBeReset();
253  void slotModelReset();
254  void slotRowsAboutToBeInserted(const QModelIndex& parent, int start, int end);
255  void slotRowsAboutToBeMoved(const QModelIndex& sourceParent, int sourceStart, int sourceEnd,
256  const QModelIndex& destinationParent, int destinationRow);
257  void slotRowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
258  void slotRowsInserted();
259  void slotRowsMoved();
260  void slotRowsRemoved();
261 
262 private:
263 
264  QString translateSpacer(const QString& text) const;
265 
266 private:
267 
268  class Private;
269  Private* const d;
270 };
271 
272 } // namespace Digikam
273 
274 #endif // DIGIKAM_RG_TAG_MODEL_H
The model that holds data for the tag tree displayed in ReverseGeocodingWidget.
Definition: rgtagmodel.h:53
Definition: treebranch.h:41
Definition: piwigotalker.h:48
qulonglong value
Definition: itemviewutilities.cpp:592
@ Orientation
Definition: coredbfields.h:86
Definition: datefolderview.cpp:43
Type
Definition: gpsitemcontainer.h:45