Commit 8726eb4e7cafb8c8c55e8b6c9901e15021ab41a4

Authored by Josh Klontz
1 parent 89089d76

rearranged functions

sdk/openbr_plugin.cpp
... ... @@ -110,29 +110,6 @@ QVariant File::value(const QString &key) const
110 110 return m_metadata.contains(key) ? m_metadata.value(key) : Globals->property(qPrintable(key));
111 111 }
112 112  
113   -QString File::subject(int label)
114   -{
115   - return Globals->classes.key(label, QString::number(label));
116   -}
117   -
118   -float File::label() const
119   -{
120   - const QVariant variant = value("Label");
121   - if (variant.isNull()) return -1;
122   -
123   - if (Globals->classes.contains(variant.toString()))
124   - return Globals->classes.value(variant.toString());
125   -
126   - bool ok;
127   - const float val = variant.toFloat(&ok);
128   - return ok ? val : -1;
129   -}
130   -
131   -void File::remove(const QString &key)
132   -{
133   - m_metadata.remove(key);
134   -}
135   -
136 113 void File::set(const QString &key, const QVariant &value)
137 114 {
138 115 if (key == "Label") {
... ... @@ -153,6 +130,24 @@ void File::set(const QString &key, const QVariant &value)
153 130 m_metadata.insert(key, value);
154 131 }
155 132  
  133 +QString File::subject(int label)
  134 +{
  135 + return Globals->classes.key(label, QString::number(label));
  136 +}
  137 +
  138 +float File::label() const
  139 +{
  140 + const QVariant variant = value("Label");
  141 + if (variant.isNull()) return -1;
  142 +
  143 + if (Globals->classes.contains(variant.toString()))
  144 + return Globals->classes.value(variant.toString());
  145 +
  146 + bool ok;
  147 + const float val = variant.toFloat(&ok);
  148 + return ok ? val : -1;
  149 +}
  150 +
156 151 QList<QPointF> File::landmarks() const
157 152 {
158 153 QList<QPointF> landmarks;
... ...
sdk/openbr_plugin.h
... ... @@ -161,12 +161,15 @@ struct BR_EXPORT File
161 161 inline operator QString() const { return name; } /*!< \brief Returns #name. */
162 162 QString flat() const; /*!< \brief A stringified version of the file with metadata. */
163 163 QString hash() const; /*!< \brief A hash of the file. */
164   - inline void clear() { name.clear(); m_metadata.clear(); } /*!< \brief Clears the file's name and metadata. */
165 164  
166 165 inline QList<QString> localKeys() const { return m_metadata.keys(); } /*!< \brief Returns the private metadata keys. */
167 166 inline QMap<QString,QVariant> localMetadata() const { return m_metadata; } /*!< \brief Returns the private metadata. */
  167 +
168 168 void append(const QMap<QString,QVariant> &localMetadata); /*!< \brief Add new metadata fields. */
169 169 void append(const File &other); /*!< \brief Append another file using \c separator. */
  170 + inline File &operator+=(const QMap<QString,QVariant> &other) { append(other); return *this; } /*!< \brief Add new metadata fields. */
  171 + inline File &operator+=(const File &other) { append(other); return *this; } /*!< \brief Append another file using \c separator. */
  172 +
170 173 QList<File> split() const; /*!< \brief Split the file using \c separator. */
171 174 QList<File> split(const QString &separator) const; /*!< \brief Split the file. */
172 175  
... ... @@ -181,8 +184,6 @@ struct BR_EXPORT File
181 184 inline bool operator<=(const File &other) const { return name <= other.name; } /*!< \brief Compare name. */
182 185 inline bool operator>(const File &other) const { return name > other.name; } /*!< \brief Compare name. */
183 186 inline bool operator>=(const File &other) const { return name >= other.name; } /*!< \brief Compare name. */
184   - inline File &operator+=(const QMap<QString,QVariant> &other) { append(other); return *this; } /*!< \brief Add new metadata fields. */
185   - inline File &operator+=(const File &other) { append(other); return *this; } /*!< \brief Append another file using \c separator. */
186 187  
187 188 inline bool isNull() const { return name.isEmpty() && m_metadata.isEmpty(); } /*!< \brief Returns \c true if name and metadata are empty, \c false otherwise. */
188 189 inline bool isTerminal() const { return name == "terminal"; } /*!< \brief Returns \c true if #name is "terminal", \c false otherwise. */
... ... @@ -195,14 +196,8 @@ struct BR_EXPORT File
195 196  
196 197 bool contains(const QString &key) const; /*!< \brief Returns \c true if the key has an associated value, \c false otherwise. */
197 198 QVariant value(const QString &key) const; /*!< \brief Returns the value for the specified key. */
198   - static QString subject(int label); /*!< \brief Looks up the subject for the provided label. */
199   - inline QString subject() const { return subject(label()); } /*!< \brief Looks up the subject from the file's label. */
200   - inline bool failed() const { return get<bool>("FTE", false) || get<bool>("FTO", false); } /*!< \brief Returns \c true if the file failed to open or enroll, \c false otherwise. */
201   -
202   - void remove(const QString &key); /*!< \brief Remove the metadata key. */
203 199 void set(const QString &key, const QVariant &value); /*!< \brief Insert or overwrite the metadata key with the specified value. */
204   - float label() const; /*!< \brief Convenience function for retrieving the file's \c Label. */
205   - inline void setLabel(float label) { set("Label", label); } /*!< \brief Convenience function for setting the file's \c Label. */
  200 + inline void remove(const QString &key) { m_metadata.remove(key); } /*!< \brief Remove the metadata key. */
206 201  
207 202 /*!< \brief Returns a value for the key, throwing an error if the key does not exist. */
208 203 template <typename T>
... ... @@ -224,6 +219,12 @@ struct BR_EXPORT File
224 219 return variant.value<T>();
225 220 }
226 221  
  222 + static QString subject(int label); /*!< \brief Looks up the subject for the provided label. */
  223 + inline QString subject() const { return subject(label()); } /*!< \brief Looks up the subject from the file's label. */
  224 + float label() const; /*!< \brief Convenience function for retrieving the file's \c Label. */
  225 + inline void setLabel(float label) { set("Label", label); } /*!< \brief Convenience function for setting the file's \c Label. */
  226 + inline bool failed() const { return get<bool>("FTE", false) || get<bool>("FTO", false); } /*!< \brief Returns \c true if the file failed to open or enroll, \c false otherwise. */
  227 +
227 228 QList<QPointF> landmarks() const; /*!< \brief Returns the file's landmark list. */
228 229 QList<QPointF> namedLandmarks() const; /*!< \brief Returns landmarks derived from metadata keys. */
229 230 void appendLandmark(const QPointF &landmark); /*!< \brief Adds a landmark to the file's landmark list. */
... ... @@ -239,8 +240,8 @@ struct BR_EXPORT File
239 240  
240 241 private:
241 242 QMap<QString,QVariant> m_metadata;
242   - BR_EXPORT friend QDataStream &operator<<(QDataStream &stream, const File &file); /*!< */
243   - BR_EXPORT friend QDataStream &operator>>(QDataStream &stream, File &file); /*!< */
  243 + BR_EXPORT friend QDataStream &operator<<(QDataStream &stream, const File &file);
  244 + BR_EXPORT friend QDataStream &operator>>(QDataStream &stream, File &file);
244 245  
245 246 void init(const QString &file);
246 247 };
... ...