digiKam
facetagsiface.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-09-27
7  * Description : Interface for info stored about a face tag in the database
8  *
9  * Copyright (C) 2010 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_IFACE_H
26 #define DIGIKAM_FACE_TAGS_IFACE_H
27 
28 // Qt includes
29 
30 #include <QFlags>
31 #include <QVariant>
32 
33 // Local includes
34 
35 #include "tagregion.h"
36 #include "digikam_export.h"
37 
38 class QDebug;
39 
40 namespace Digikam
41 {
42 
43 class DIGIKAM_DATABASE_EXPORT FaceTagsIface
44 {
45 public:
46 
47  enum Type
48  {
49  InvalidFace = 0,
50  UnknownName = 1 << 0,
51  UnconfirmedName = 1 << 1,
52  IgnoredName = 1 << 2,
53  ConfirmedName = 1 << 3,
54  FaceForTraining = 1 << 4,
55 
56  UnconfirmedTypes = UnknownName | UnconfirmedName,
57  NormalFaces = UnknownName | UnconfirmedName | IgnoredName | ConfirmedName,
58  AllTypes = UnknownName | UnconfirmedName | IgnoredName | ConfirmedName | FaceForTraining,
59  TypeFirst = UnknownName,
60  TypeLast = FaceForTraining
61  };
62  Q_DECLARE_FLAGS(TypeFlags, Type)
63 
64 public:
65 
66  FaceTagsIface();
67  FaceTagsIface(Type type, qlonglong imageId, int tagId, const TagRegion& region);
68  FaceTagsIface(const QString& attribute, qlonglong imageId, int tagId, const TagRegion& region);
69 
70  bool isNull() const;
71 
72  Type type() const;
73  qlonglong imageId() const;
74  int tagId() const;
75  TagRegion region() const;
76 
77  bool isInvalidFace() const
78  {
79  return (type() == InvalidFace);
80  }
81 
82  bool isUnknownName() const
83  {
84  return (type() == UnknownName);
85  }
86 
87  bool isUnconfirmedName() const
88  {
89  return (type() == UnconfirmedName);
90  }
91 
92  bool isUnconfirmedType() const
93  {
94  return (type() & UnconfirmedTypes);
95  }
96 
97  bool isIgnoredName() const
98  {
99  return (type() == IgnoredName);
100  }
101 
102  bool isConfirmedName() const
103  {
104  return (type() == ConfirmedName);
105  }
106 
107  bool isForTraining() const
108  {
109  return (type() == FaceForTraining);
110  }
111 
112  void setType(Type type);
113  void setTagId(int tagId);
114  void setRegion(const TagRegion& region);
115 
116  bool operator==(const FaceTagsIface& other) const;
117 
121  static QStringList attributesForFlags(TypeFlags flags);
122 
126  static QString attributeForType(Type type);
127 
132  static Type typeForId(int tagId);
133 
138  static Type typeForAttribute(const QString& attribute, int tagId = 0);
139 
143  QString getAutodetectedPersonString() const;
144 
150  static FaceTagsIface fromVariant(const QVariant& var);
151  QVariant toVariant() const;
152 
156  static FaceTagsIface fromListing(qlonglong imageid, const QList<QVariant>& values);
157 
158 protected:
159 
161  qlonglong m_imageId;
162  int m_tagId;
164 };
165 
166 DIGIKAM_DATABASE_EXPORT QDebug operator<<(QDebug dbg, const FaceTagsIface& f);
167 
168 } // namespace Digikam
169 
170 Q_DECLARE_OPERATORS_FOR_FLAGS(Digikam::FaceTagsIface::TypeFlags)
171 
172 #endif // DIGIKAM_FACE_TAGS_IFACE_H
Definition: facetagsiface.h:44
bool isConfirmedName() const
Definition: facetagsiface.h:102
bool isInvalidFace() const
Definition: facetagsiface.h:77
qlonglong m_imageId
Definition: facetagsiface.h:161
TagRegion m_region
Definition: facetagsiface.h:163
bool isForTraining() const
Definition: facetagsiface.h:107
Type m_type
Definition: facetagsiface.h:160
bool isUnconfirmedType() const
Definition: facetagsiface.h:92
Type
Definition: facetagsiface.h:48
bool isUnknownName() const
Definition: facetagsiface.h:82
int m_tagId
Definition: facetagsiface.h:162
bool isIgnoredName() const
Definition: facetagsiface.h:97
bool isUnconfirmedName() const
Definition: facetagsiface.h:87
Definition: tagregion.h:47
Definition: datefolderview.cpp:43
QDebug operator<<(QDebug dbg, const DbEngineParameters &p)
Definition: dbengineparameters.cpp:863
bool operator==(const SearchTextSettings &a, const SearchTextSettings &b)
Definition: searchtextbar.cpp:49
Type
Definition: gpsitemcontainer.h:45