digiKam
itemfiltermodel_p.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 : 2009-03-11
7  * Description : Qt item model for database entries - private containers
8  *
9  * Copyright (C) 2009-2011 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_ITEM_FILTER_MODEL_P_H
25 #define DIGIKAM_ITEM_FILTER_MODEL_P_H
26 
27 // Qt includes
28 
29 #include <QHash>
30 #include <QMutex>
31 #include <QMutexLocker>
32 #include <QSet>
33 #include <QThread>
34 #include <QTimer>
35 #include <QWaitCondition>
36 
37 // Local includes
38 
39 #include "iteminfo.h"
40 #include "itemfiltermodel.h"
41 #include "digikam_export.h"
42 
43 // NOTE: we need the EXPORT macro in a private header because
44 // this private header is shared across binary objects.
45 // This does NOT make this classes here any more public!
46 
47 namespace Digikam
48 {
49 
50 const int PrepareChunkSize = 101;
51 const int FilterChunkSize = 2001;
52 
54 {
55 public:
56 
58  : version (0),
59  isForReAdd(false)
60  {
61  }
62 
63  ItemFilterModelTodoPackage(const QVector<ItemInfo>& infos,
64  const QVector<QVariant>& extraValues,
65  int version,
66  bool isForReAdd)
67  : infos (infos),
69  version (version),
71  {
72  }
73 
74  QVector<ItemInfo> infos;
75  QVector<QVariant> extraValues;
76  unsigned int version;
77  bool isForReAdd;
78  QHash<qlonglong, bool> filterResults;
79 };
80 
81 // ------------------------------------------------------------------------------------------------
82 
85 
86 class DIGIKAM_DATABASE_EXPORT ItemFilterModel::ItemFilterModelPrivate : public QObject
87 {
88  Q_OBJECT
89 
90 public:
91 
94 
96  void setupWorkers();
97  void infosToProcess(const QList<ItemInfo>& infos);
98  void infosToProcess(const QList<ItemInfo>& infos, const QList<QVariant>& extraValues, bool forReAdd = true);
99 
100 public:
101 
103 
105 
110 
111  volatile unsigned int version;
112  unsigned int lastDiscardVersion;
113  unsigned int lastFilteredVersion;
114  int sentOut;
116 
118 
123 
124  QMutex mutex;
130 
131  QHash<qlonglong, bool> filterResults;
134 
136 
137 /*
138  QHash<int, QSet<qlonglong> > categoryCountHashInt;
139  QHash<QString, QSet<qlonglong> > categoryCountHashString;
140 
141 public:
142 
143  void cacheCategoryCount(int id, qlonglong imageid) const
144  {
145  const_cast<ItemFilterModelPrivate*>(this)->categoryCountHashInt[id].insert(imageid);
146  }
147 
148  void cacheCategoryCount(const QString& id, qlonglong imageid) const
149  {
150  const_cast<ItemFilterModelPrivate*>(this)->categoryCountHashString[id].insert(imageid);
151  }
152 */
153 
154 public Q_SLOTS:
155 
156  void preprocessInfos(const QList<ItemInfo>& infos, const QList<QVariant>& extraValues);
157  void processAddedInfos(const QList<ItemInfo>& infos, const QList<QVariant>& extraValues);
160 
161 Q_SIGNALS:
162 
165  void reAddItemInfos(const QList<ItemInfo>& infos, const QList<QVariant>& extraValues);
167 
168 private:
169 
170  // Disable
171 
172  explicit ItemFilterModelPrivate(QObject*) = delete;
173 };
174 
175 } // namespace Digikam
176 
177 #endif // DIGIKAM_ITEM_FILTER_MODEL_P_H
Definition: itemfiltersettings.h:313
Definition: itemfiltermodelthreads.h:85
Definition: itemfiltermodelthreads.h:69
Definition: itemfiltermodel_p.h:54
ItemFilterModelTodoPackage(const QVector< ItemInfo > &infos, const QVector< QVariant > &extraValues, int version, bool isForReAdd)
Definition: itemfiltermodel_p.h:63
bool isForReAdd
Definition: itemfiltermodel_p.h:77
QVector< ItemInfo > infos
Definition: itemfiltermodel_p.h:74
ItemFilterModelTodoPackage()
Definition: itemfiltermodel_p.h:57
unsigned int version
Definition: itemfiltermodel_p.h:76
QVector< QVariant > extraValues
Definition: itemfiltermodel_p.h:75
QHash< qlonglong, bool > filterResults
Definition: itemfiltermodel_p.h:78
Definition: itemfiltermodel.h:125
volatile unsigned int version
Definition: itemfiltermodel_p.h:111
ItemFilterSettings filter
Definition: itemfiltermodel_p.h:106
ItemFilterModelFilterer * filterer
Definition: itemfiltermodel_p.h:129
bool hasOneMatchForText
Definition: itemfiltermodel_p.h:133
void preprocessInfos(const QList< ItemInfo > &infos, const QList< QVariant > &extraValues)
VersionItemFilterSettings versionFilter
Definition: itemfiltermodel_p.h:108
unsigned int lastFilteredVersion
Definition: itemfiltermodel_p.h:113
~ItemFilterModelPrivate() override
int sentOutForReAdd
Definition: itemfiltermodel_p.h:115
GroupItemFilterSettings groupFilter
Definition: itemfiltermodel_p.h:109
void infosToProcess(const QList< ItemInfo > &infos)
unsigned int lastDiscardVersion
Definition: itemfiltermodel_p.h:112
void packageToFilter(const ItemFilterModelTodoPackage &package)
QList< ItemFilterModelPrepareHook * > prepareHooks
Definition: itemfiltermodel_p.h:135
void infosToProcess(const QList< ItemInfo > &infos, const QList< QVariant > &extraValues, bool forReAdd=true)
void reAddItemInfos(const QList< ItemInfo > &infos, const QList< QVariant > &extraValues)
QHash< qlonglong, bool > filterResults
Definition: itemfiltermodel_p.h:131
void packageDiscarded(const ItemFilterModelTodoPackage &package)
ItemFilterModel * q
Definition: itemfiltermodel_p.h:102
void packageFinished(const ItemFilterModelTodoPackage &package)
bool needPrepareComments
Definition: itemfiltermodel_p.h:120
VersionItemFilterSettings versionFilterCopy
Definition: itemfiltermodel_p.h:126
bool hasOneMatch
Definition: itemfiltermodel_p.h:132
bool needPrepareGroups
Definition: itemfiltermodel_p.h:122
bool needPrepareTags
Definition: itemfiltermodel_p.h:121
ItemModel * imageModel
Definition: itemfiltermodel_p.h:104
bool needPrepare
Definition: itemfiltermodel_p.h:119
void init(ItemFilterModel *q)
QMutex mutex
Definition: itemfiltermodel_p.h:124
QTimer * updateFilterTimer
Definition: itemfiltermodel_p.h:117
GroupItemFilterSettings groupFilterCopy
Definition: itemfiltermodel_p.h:127
ItemFilterModelPreparer * preparer
Definition: itemfiltermodel_p.h:128
int sentOut
Definition: itemfiltermodel_p.h:114
ItemFilterSettings filterCopy
Definition: itemfiltermodel_p.h:125
void packageToPrepare(const ItemFilterModelTodoPackage &package)
void processAddedInfos(const QList< ItemInfo > &infos, const QList< QVariant > &extraValues)
ItemSortSettings sorter
Definition: itemfiltermodel_p.h:107
Definition: itemfiltersettings.h:98
Definition: itemmodel.h:53
Definition: itemsortsettings.h:49
Definition: itemfiltersettings.h:269
Definition: datefolderview.cpp:43
const int PrepareChunkSize
Definition: itemfiltermodel_p.h:50
const int FilterChunkSize
Definition: itemfiltermodel_p.h:51