digiKam
collectionscannerhints.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 : 2008-09-09
7  * Description : Hint data containers for the collection scanner
8  *
9  * Copyright (C) 2008 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
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_COLLECTION_SCANNER_HINTS_H
25 #define DIGIKAM_COLLECTION_SCANNER_HINTS_H
26 
27 #include "digikam_config.h"
28 
29 // Qt includes
30 
31 #include <QDateTime>
32 #include <QList>
33 #include <QStringList>
34 
35 #ifdef HAVE_DBUS
36 # include <QDBusArgument>
37 # include "dbenginedbusutils.h"
38 #endif
39 
40 // Local includes
41 
42 #include "digikam_export.h"
43 
44 namespace Digikam
45 {
46 
47 class AlbumCopyMoveHint;
48 class CollectionLocation;
49 class CollectionScannerObserver;
50 class ItemInfo;
51 class ItemCopyMoveHint;
52 class ItemChangeHint;
53 class ItemMetadataAdjustmentHint;
54 
56 {
57 public:
58 
60 
62  virtual ~CollectionScannerHintContainer() = default;
63 
64  virtual void recordHints(const QList<AlbumCopyMoveHint>& hints) = 0;
65  virtual void recordHints(const QList<ItemCopyMoveHint>& hints) = 0;
66  virtual void recordHints(const QList<ItemChangeHint>& hints) = 0;
67  virtual void recordHint(const ItemMetadataAdjustmentHint& hints) = 0;
68 
69  virtual void clear() = 0;
70 
71 private:
72 
73  Q_DISABLE_COPY(CollectionScannerHintContainer)
74 };
75 
76 // ------------------------------------------------------------------------------
77 
78 namespace CollectionScannerHints
79 {
80 
81 class DIGIKAM_DATABASE_EXPORT Album
82 {
83 public:
84 
85  Album();
86  Album(int albumRootId, int albumId);
87 
88  bool isNull() const;
89  uint qHash() const;
90  bool operator==(const Album& other) const;
91 
92 public:
93 
95  int albumId;
96 };
97 
98 // ---------------------------------------------------------------------------
99 
100 class DIGIKAM_DATABASE_EXPORT DstPath
101 {
102 public:
103 
104  DstPath();
105  DstPath(int albumRootId, const QString& relativePath);
106 
107  bool isNull() const;
108  uint qHash() const;
109  bool operator==(const DstPath& other) const;
110 
111 public:
112 
114  QString relativePath;
115 };
116 
117 // ---------------------------------------------------------------------------
118 
119 class DIGIKAM_DATABASE_EXPORT Item
120 {
121 public:
122 
123  Item();
124  explicit Item(qlonglong id);
125 
126  bool isNull() const;
127  uint qHash() const;
128  bool operator==(const Item& other) const;
129 
130 public:
131 
132  qlonglong id;
133 };
134 
135 inline uint qHash(const Album& src)
136 {
137  return src.qHash();
138 }
139 
140 inline uint qHash(const DstPath& dst)
141 {
142  return dst.qHash();
143 }
144 
145 inline uint qHash(const Item& item)
146 {
147  return item.qHash();
148 }
149 
150 } // namespace CollectionScannerHints
151 
152 // ---------------------------------------------------------------------------
153 
154 class DIGIKAM_DATABASE_EXPORT AlbumCopyMoveHint
155 {
156 public:
157 
164  AlbumCopyMoveHint(int srcAlbumRootId, int srcAlbum,
165  int dstAlbumRootId, const QString& dstRelativePath);
166 
167  int albumRootIdSrc() const;
168  int albumIdSrc() const;
169  bool isSrcAlbum(int albumRootId, int albumId) const;
170 
172  {
173  return m_src;
174  }
175 
176  int albumRootIdDst() const;
177  QString relativePathDst() const;
178  bool isDstAlbum(int albumRootId, const QString& relativePath) const;
179 
181  {
182  return m_dst;
183  }
184 
185  uint qHash() const;
186 
188  {
189  return (src == m_src);
190  }
191 
193  {
194  return (dst == m_dst);
195  }
196 
197 #ifdef HAVE_DBUS
198 
199  AlbumCopyMoveHint& operator<<(const QDBusArgument& argument);
200  const AlbumCopyMoveHint& operator>>(QDBusArgument& argument) const;
201 
202 #endif
203 
204  operator const CollectionScannerHints::Album& () const
205  {
206  return m_src;
207  }
208 
209  operator const CollectionScannerHints::DstPath& () const
210  {
211  return m_dst;
212  }
213 
214 protected:
215 
218 };
219 
220 // ---------------------------------------------------------------------------
221 
222 class DIGIKAM_DATABASE_EXPORT ItemCopyMoveHint
223 {
224 public:
225 
233  ItemCopyMoveHint(const QList<qlonglong>& srcIds,
234  int dstAlbumRootId,
235  int albumId,
236  const QStringList& dstNames);
237 
238  QList<qlonglong> srcIds() const;
239  bool isSrcId(qlonglong id) const;
240  int albumRootIdDst() const;
241  int albumIdDst() const;
242  bool isDstAlbum(int albumRootId, int albumId) const;
243 
245  {
246  return m_dst;
247  }
248 
249  QStringList dstNames() const;
250  QString dstName(qlonglong id) const;
251 
253  {
254  return (dst == m_dst);
255  }
256 
257 #ifdef HAVE_DBUS
258 
259  ItemCopyMoveHint& operator<<(const QDBusArgument& argument);
260  const ItemCopyMoveHint& operator>>(QDBusArgument& argument) const;
261 
262 #endif
263 
264  operator const CollectionScannerHints::Album& () const
265  {
266  return m_dst;
267  }
268 
269 protected:
270 
273  QStringList m_dstNames;
274 };
275 
276 // ---------------------------------------------------------------------------
277 
278 class DIGIKAM_DATABASE_EXPORT ItemChangeHint
279 {
280 public:
281 
288  {
290  ItemRescan
291  };
292 
293 public:
294 
295  ItemChangeHint();
296  explicit ItemChangeHint(const QList<qlonglong>& srcIds,
297  ChangeType type = ItemModified);
298 
299  QList<qlonglong> ids() const;
300  bool isId(qlonglong id) const;
301  ChangeType changeType() const;
302 
303  bool isModified() const
304  {
305  return (changeType() == ItemModified);
306  }
307 
308  bool needsRescan() const
309  {
310  return (changeType() == ItemRescan);
311  }
312 
313 #ifdef HAVE_DBUS
314 
315  ItemChangeHint& operator<<(const QDBusArgument& argument);
316  const ItemChangeHint& operator>>(QDBusArgument& argument) const;
317 
318 #endif
319 
320 protected:
321 
324 };
325 
326 // ---------------------------------------------------------------------------
327 
328 class DIGIKAM_DATABASE_EXPORT ItemMetadataAdjustmentHint
329 {
330 public:
331 
340  {
343  MetadataEditingAborted
344  };
345 
346 public:
347 
349  explicit ItemMetadataAdjustmentHint(qlonglong id,
350  AdjustmentStatus status,
351  const QDateTime& modificationDateOnDisk,
352  qlonglong fileSize);
353 
354  qlonglong id() const;
355  AdjustmentStatus adjustmentStatus() const;
356  QDateTime modificationDate() const;
357  qlonglong fileSize() const;
358 
359  bool isAboutToEdit() const
360  {
361  return (adjustmentStatus() == AboutToEditMetadata);
362  }
363 
364  bool isEditingFinished() const
365  {
366  return (adjustmentStatus() == MetadataEditingFinished);
367  }
368 
370  {
371  return (adjustmentStatus() == MetadataEditingAborted);
372  }
373 
374 #ifdef HAVE_DBUS
375 
376  ItemMetadataAdjustmentHint& operator<<(const QDBusArgument& argument);
377  const ItemMetadataAdjustmentHint& operator>>(QDBusArgument& argument) const;
378 
379 #endif
380 
381 protected:
382 
383  qlonglong m_id;
386  qlonglong m_fileSize;
387 };
388 
389 inline uint qHash(const Digikam::AlbumCopyMoveHint& hint)
390 {
391  return hint.qHash();
392 }
393 
394 } // namespace Digikam
395 
396 #ifdef HAVE_DBUS
397 
401 
402 #endif
403 
404 #endif // DIGIKAM_COLLECTION_SCANNER_HINTS_H
Definition: collectionscannerhints.h:155
CollectionScannerHints::Album src() const
Definition: collectionscannerhints.h:171
CollectionScannerHints::Album m_src
Definition: collectionscannerhints.h:216
CollectionScannerHints::DstPath dst() const
Definition: collectionscannerhints.h:180
uint qHash() const
Definition: collectionscannerhints.cpp:163
bool operator==(const CollectionScannerHints::DstPath &dst) const
Definition: collectionscannerhints.h:192
CollectionScannerHints::DstPath m_dst
Definition: collectionscannerhints.h:217
bool operator==(const CollectionScannerHints::Album &src) const
Definition: collectionscannerhints.h:187
Definition: collectionscannerhints.h:56
virtual void recordHints(const QList< ItemCopyMoveHint > &hints)=0
virtual ~CollectionScannerHintContainer()=default
CollectionScannerHintContainer()=default
Note: All methods of this class must be thread-safe.
virtual void recordHints(const QList< AlbumCopyMoveHint > &hints)=0
virtual void recordHint(const ItemMetadataAdjustmentHint &hints)=0
virtual void recordHints(const QList< ItemChangeHint > &hints)=0
Definition: collectionscannerhints.h:82
uint qHash() const
Definition: collectionscannerhints.cpp:58
int albumId
Definition: collectionscannerhints.h:95
int albumRootId
Definition: collectionscannerhints.h:94
Definition: collectionscannerhints.h:101
int albumRootId
Definition: collectionscannerhints.h:113
QString relativePath
Definition: collectionscannerhints.h:114
uint qHash() const
Definition: collectionscannerhints.cpp:86
Definition: collectionscannerhints.h:120
uint qHash() const
Definition: collectionscannerhints.cpp:111
qlonglong id
Definition: collectionscannerhints.h:132
Definition: collectionscannerhints.h:279
ChangeType m_type
Definition: collectionscannerhints.h:323
QList< qlonglong > m_ids
Definition: collectionscannerhints.h:322
bool needsRescan() const
Definition: collectionscannerhints.h:308
bool isModified() const
Definition: collectionscannerhints.h:303
ChangeType
Definition: collectionscannerhints.h:288
@ ItemModified
treat as if modification date changed
Definition: collectionscannerhints.h:289
Definition: collectionscannerhints.h:223
QStringList m_dstNames
Definition: collectionscannerhints.h:273
CollectionScannerHints::Album dst() const
Definition: collectionscannerhints.h:244
QList< qlonglong > m_srcIds
Definition: collectionscannerhints.h:271
bool operator==(const CollectionScannerHints::Album &dst) const
Definition: collectionscannerhints.h:252
CollectionScannerHints::Album m_dst
Definition: collectionscannerhints.h:272
Definition: collectionscannerhints.h:329
QDateTime m_modificationDate
Definition: collectionscannerhints.h:385
qlonglong m_id
Definition: collectionscannerhints.h:383
AdjustmentStatus
Definition: collectionscannerhints.h:340
@ AboutToEditMetadata
The file is about to be edited. Suspends scanning. The Finished hint must follow.
Definition: collectionscannerhints.h:341
@ MetadataEditingFinished
The file's metadata has been edited as described above.
Definition: collectionscannerhints.h:342
AdjustmentStatus m_status
Definition: collectionscannerhints.h:384
bool isEditingFinished() const
Definition: collectionscannerhints.h:364
qlonglong m_fileSize
Definition: collectionscannerhints.h:386
bool isAboutToEdit() const
Definition: collectionscannerhints.h:359
bool isEditingFinishedAborted() const
Definition: collectionscannerhints.h:369
Definition: piwigotalker.h:48
#define DECLARE_METATYPE_FOR_DBUS(x)
Definition: dbenginedbusutils.h:29
uint qHash(const Album &src)
Definition: collectionscannerhints.h:135
@ Album
Definition: coredbfields.h:58
Definition: datefolderview.cpp:43
QDebug operator<<(QDebug dbg, const DbEngineParameters &p)
Definition: dbengineparameters.cpp:863
QDataStream & operator>>(QDataStream &ds, PhotoInfoContainer &info)
Definition: photoinfocontainer.cpp:117
bool operator==(const SearchTextSettings &a, const SearchTextSettings &b)
Definition: searchtextbar.cpp:49
uint qHash(const PAlbumPath &id)
Definition: albummanager_p.h:141