digiKam
iteminfocache.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 : 2007-05-01
7  * Description : ItemInfo common data
8  *
9  * Copyright (C) 2007-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2013-2022 by Gilles Caulier <caulier dot gilles 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_ITEM_INFO_CACHE_H
26 #define DIGIKAM_ITEM_INFO_CACHE_H
27 
28 // Qt includes
29 
30 #include <QHash>
31 #include <QObject>
32 #include <QMultiHash>
33 #include <QExplicitlySharedDataPointer>
34 
35 // Local includes
36 
37 #include "coredbwatch.h"
38 
39 namespace Digikam
40 {
41 
42 class AlbumShortInfo;
43 class ItemInfoData;
44 
45 // NOTE: No need to EXPORT this class
46 class ItemInfoCache : public QObject
47 {
48  Q_OBJECT
49 
50 public:
51 
52  ItemInfoCache();
53  ~ItemInfoCache() override;
54 
60  QExplicitlySharedDataPointer<ItemInfoData> infoForId(qlonglong id);
61 
66  void dropInfo(const QExplicitlySharedDataPointer<ItemInfoData>& infoPtr);
67 
73  void cacheByName(const QExplicitlySharedDataPointer<ItemInfoData>& infoPtr);
74 
80  QExplicitlySharedDataPointer<ItemInfoData> infoForPath(int albumRootId,
81  const QString& relativePath,
82  const QString& name);
83 
87  QString albumRelativePath(int albumId);
88 
92  int getImageGroupedCount(qlonglong id);
93 
97  void invalidate();
98 
99 private Q_SLOTS:
100 
101  void slotImageChanged(const ImageChangeset& changeset);
102  void slotImageTagChanged(const ImageTagChangeset& changeset);
103  void slotAlbumChange(const AlbumChangeset&);
104 
105 private:
106 
107  // Disable
108  explicit ItemInfoCache(QObject*) = delete;
109 
110  QList<AlbumShortInfo>::const_iterator findAlbum(int id);
111  void checkAlbums();
112 
113 private:
114 
115  QMultiHash<QString, ItemInfoData*> m_nameHash;
116  QHash<qlonglong, ItemInfoData*> m_infoHash;
117  QHash<ItemInfoData*, QString> m_dataHash;
118  volatile bool m_needUpdateAlbums;
119  volatile bool m_needUpdateGrouped;
120  QList<qlonglong> m_grouped;
121  QList<AlbumShortInfo> m_albums;
122 };
123 
124 } // namespace Digikam
125 
126 #endif // DIGIKAM_ITEM_INFO_CACHE_H
Definition: coredbchangesets.h:262
Definition: coredbchangesets.h:48
Definition: coredbchangesets.h:80
Definition: iteminfocache.h:47
ItemInfoCache()
Definition: iteminfocache.cpp:40
QExplicitlySharedDataPointer< ItemInfoData > infoForPath(int albumRootId, const QString &relativePath, const QString &name)
Definition: iteminfocache.cpp:137
int getImageGroupedCount(qlonglong id)
Definition: iteminfocache.cpp:85
QString albumRelativePath(int albumId)
Definition: iteminfocache.cpp:207
void dropInfo(const QExplicitlySharedDataPointer< ItemInfoData > &infoPtr)
Definition: iteminfocache.cpp:167
void cacheByName(const QExplicitlySharedDataPointer< ItemInfoData > &infoPtr)
Definition: iteminfocache.cpp:120
~ItemInfoCache() override
Definition: iteminfocache.cpp:63
void invalidate()
Definition: iteminfocache.cpp:221
QExplicitlySharedDataPointer< ItemInfoData > infoForId(qlonglong id)
Definition: iteminfocache.cpp:100
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43