digiKam
facetagseditor.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-08-08
7  * Description : Faces tags editor allowing easy manipulation of face tags
8  *
9  * Copyright (C) 2010-2011 by Aditya Bhatt <adityabhatt1991 at gmail dot com>
10  * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
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_FACE_TAGS_EDITOR_H
26 #define DIGIKAM_FACE_TAGS_EDITOR_H
27 
28 // Qt includes
29 
30 #include <QFlags>
31 #include <QMap>
32 #include <QList>
33 #include <QRect>
34 #include <QString>
35 #include <QVariant>
36 
37 // Local includes
38 
39 #include "facetagsiface.h"
40 #include "digikam_export.h"
41 #include "facetags.h"
42 
43 namespace Digikam
44 {
45 
46 class ItemTagPair;
47 class ItemInfo;
48 
49 class DIGIKAM_DATABASE_EXPORT FaceTagsEditor
50 {
51 public:
52 
54  virtual ~FaceTagsEditor();
55 
56  // --- Read from database -----------------------------------------------------------------------------------------
57 
61  int numberOfFaces(qlonglong imageid) const;
62 
66  int faceCountForPersonInImage(qlonglong imageid, int tagId) const;
67 
71  QList<FaceTagsIface> databaseFaces(qlonglong imageid) const;
72 
77  QList<FaceTagsIface> unconfirmedFaceTagsIfaces(qlonglong imageid) const;
78 
83  QList<FaceTagsIface> unconfirmedNameFaceTagsIfaces(qlonglong imageid) const;
84 
85  QList<FaceTagsIface> databaseFacesForTraining(qlonglong imageid) const;
86  QList<FaceTagsIface> confirmedFaceTagsIfaces(qlonglong imageid) const;
87  QList<FaceTagsIface> ignoredFaceTagsIfaces(qlonglong imageid) const;
88 
93  QList<QRect> getTagRects(qlonglong imageid) const;
94 
95  // --- Add / Confirm ---
96 
103  void add(const FaceTagsIface& face, bool trainFace = true);
104  FaceTagsIface add(qlonglong imageid, int tagId, const TagRegion& region, bool trainFace = true);
105  FaceTagsIface addManually(const FaceTagsIface& face);
106 
110  FaceTagsIface changeSuggestedName(const FaceTagsIface& previousEntry, int unconfirmedNameTagId);
111 
119  QMap<QString, QString> getSuggestedNames(qlonglong id) const;
120 
130  FaceTagsIface confirmName(const FaceTagsIface& face, int tagId = -1,
131  const TagRegion& confirmedRegion = TagRegion());
132 
136  static FaceTagsIface confirmedEntry(const FaceTagsIface& face, int tagId = -1,
137  const TagRegion& confirmedRegion = TagRegion());
138 
143  static FaceTagsIface unconfirmedEntry(qlonglong imageId, int tagId, const TagRegion& region);
144  static FaceTagsIface unknownPersonEntry(qlonglong imageId, const TagRegion& region);
145 
146  // --- Remove entries ---
147 
152  void removeFace(const FaceTagsIface& face, bool touchTags = true);
153  void removeFaces(const QList<FaceTagsIface>& faces);
154 
158  void removeAllFaces(qlonglong imageid);
159 
163  void removeFace(qlonglong imageid, const QRect& rect);
164 
165  // --- Edit entry ---
166 
170  FaceTagsIface changeRegion(const FaceTagsIface& face, const TagRegion& newRegion);
171 
175  FaceTagsIface changeTag(const FaceTagsIface& face, int newTagId, ItemInfo& info);
176 
177  // --- Utilities ---
178 
179  QList<FaceTagsIface> databaseFaces(qlonglong imageId, FaceTagsIface::TypeFlags flags) const;
180  QList<ItemTagPair> faceItemTagPairs(qlonglong imageid, FaceTagsIface::TypeFlags flags) const;
181 
182 protected:
183 
184  void addFaceAndTag(ItemTagPair& pair, const FaceTagsIface& face, const QStringList& properties, bool addTag);
185  void removeFaceAndTag(ItemTagPair& pair, const FaceTagsIface& face, bool touchTags);
186 
187  virtual void addNormalTag(qlonglong imageid, int tagId);
188  virtual void removeNormalTag(qlonglong imageid, int tagId);
189  virtual void removeNormalTags(qlonglong imageid, const QList<int>& tagId);
190 
191 private:
192 
193  Q_DISABLE_COPY(FaceTagsEditor)
194 };
195 
196 } // namespace Digikam
197 
198 #endif // DIGIKAM_FACE_TAGS_EDITOR_H
Definition: facetagseditor.h:50
Definition: facetagsiface.h:44
Definition: iteminfo.h:78
Definition: itemtagpair.h:46
Definition: tagregion.h:47
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43