digiKam
searchview.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-01-20
7  * Description : User interface for searches
8  *
9  * Copyright (C) 2008-2012 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_SEARCH_VIEW_H
25 #define DIGIKAM_SEARCH_VIEW_H
26 
27 // Qt includes
28 
29 #include <QCache>
30 #include <QList>
31 #include <QRect>
32 #include <QWidget>
33 
34 class QHBoxLayout;
35 class QDialogButtonBox;
36 class QPushButton;
37 
38 namespace Digikam
39 {
40 
41 class SearchGroup;
42 class SearchViewBottomBar;
43 class SearchXmlCachingReader;
44 class SearchXmlWriter;
45 
47 {
48 public:
49 
51  virtual ~SearchViewThemedPartsCache() = default;
52 
53  virtual QPixmap groupLabelPixmap(int w, int h) = 0;
54  virtual QPixmap bottomBarPixmap(int w, int h) = 0;
55 
56 private:
57 
58  Q_DISABLE_COPY(SearchViewThemedPartsCache)
59 };
60 
61 class AbstractSearchGroupContainer : public QWidget
62 {
63  Q_OBJECT
64 
65 public:
66 
72  explicit AbstractSearchGroupContainer(QWidget* const parent = nullptr);
73 
74 public Q_SLOTS:
75 
77  void removeSearchGroup(SearchGroup* group);
78 
79 protected:
80 
83 
85  void readGroup(SearchXmlCachingReader& reader);
86 
88  void finishReadingGroups();
89 
91  void writeGroups(SearchXmlWriter& writer) const;
92 
95 
98 
100  virtual void addGroupToLayout(SearchGroup* group) = 0;
101 
102 protected Q_SLOTS:
103 
105 
106 protected:
107 
110 };
111 
112 // -------------------------------------------------------------------------
113 
116 {
117  Q_OBJECT
118 
119 public:
120 
121  SearchView();
122  ~SearchView() override;
123 
124  void setup();
125  void setBottomBar(SearchViewBottomBar* const bar);
126 
127  void read(const QString& search);
128  QString write() const;
129 
130  QPixmap groupLabelPixmap(int w, int h) override;
131  QPixmap bottomBarPixmap(int w, int h) override;
132 
133 Q_SIGNALS:
134 
135  void searchOk();
136  void searchTryout();
137  void searchCancel();
138 
139 protected Q_SLOTS:
140 
141  void setTheme();
142  void slotAddGroupButton();
143  void slotResetButton();
144  void startAnimation();
145  void animationFrame(int);
146  void timeLineFinished();
147 
148 protected:
149 
150  QPixmap cachedBannerPixmap(int w, int h) const;
151 
152  void paintEvent(QPaintEvent* e) override;
153  void showEvent(QShowEvent* event) override;
154 
155  SearchGroup* createSearchGroup() override;
156  void addGroupToLayout(SearchGroup* group) override;
157 
158 private:
159 
160  // Disable.
161  SearchView(QWidget*) = delete;
162  SearchView(const SearchView&) = delete;
163  SearchView& operator=(const SearchView&) = delete;
164 
165 private:
166 
167  class Private;
168  Private* const d;
169 };
170 
171 // -------------------------------------------------------------------------
172 
173 class SearchViewBottomBar : public QWidget
174 {
175  Q_OBJECT
176 
177 public:
178 
179  explicit SearchViewBottomBar(SearchViewThemedPartsCache* const cache,
180  QWidget* const parent = nullptr);
181 
182 Q_SIGNALS:
183 
184  void okPressed();
188  void resetPressed();
189 
190 protected:
191 
192  void paintEvent(QPaintEvent*) override;
193 
194 protected:
195 
196  QHBoxLayout* m_mainLayout;
197 
198  QDialogButtonBox* m_buttonBox;
199  QPushButton* m_addGroupsButton;
200  QPushButton* m_resetButton;
201 
203 };
204 
205 } // namespace Digikam
206 
207 #endif // DIGIKAM_SEARCH_VIEW_H
Definition: searchview.h:62
void removeSearchGroup(SearchGroup *group)
Definition: searchview.cpp:73
int m_groupIndex
Definition: searchview.h:108
void startReadingGroups(SearchXmlCachingReader &reader)
Call before reading the XML part that could contain group elements.
Definition: searchview.cpp:88
QList< QRect > startupAnimationAreaOfGroups() const
Collects the data from the same method of all contained groups (position relative to this widget)
Definition: searchview.cpp:141
QList< SearchGroup * > m_groups
Definition: searchview.h:109
AbstractSearchGroupContainer(QWidget *const parent=nullptr)
Definition: searchview.cpp:55
void removeSendingSearchGroup()
Definition: searchview.cpp:136
void finishReadingGroups()
Call when the XML part is finished.
Definition: searchview.cpp:111
void readGroup(SearchXmlCachingReader &reader)
Call when a group element is the current element.
Definition: searchview.cpp:93
void writeGroups(SearchXmlWriter &writer) const
Write contained groups to writer.
Definition: searchview.cpp:128
SearchGroup * addSearchGroup()
Definition: searchview.cpp:61
virtual SearchGroup * createSearchGroup()=0
Re-implement: create and setup a search group.
virtual void addGroupToLayout(SearchGroup *group)=0
Re-implement: Adds a newly created group to the layout structures.
Definition: searchgroup.h:49
Definition: searchview.h:174
void paintEvent(QPaintEvent *) override
Definition: searchview.cpp:549
QDialogButtonBox * m_buttonBox
Definition: searchview.h:198
QPushButton * m_resetButton
Definition: searchview.h:200
QHBoxLayout * m_mainLayout
Definition: searchview.h:196
QPushButton * m_addGroupsButton
Definition: searchview.h:199
SearchViewBottomBar(SearchViewThemedPartsCache *const cache, QWidget *const parent=nullptr)
Definition: searchview.cpp:504
SearchViewThemedPartsCache * m_themeCache
Definition: searchview.h:202
Definition: searchview.h:47
virtual QPixmap groupLabelPixmap(int w, int h)=0
virtual QPixmap bottomBarPixmap(int w, int h)=0
virtual ~SearchViewThemedPartsCache()=default
Definition: searchview.h:116
void setTheme()
Definition: searchview.cpp:387
void setBottomBar(SearchViewBottomBar *const bar)
Definition: searchview.cpp:221
SearchView()
Definition: searchview.cpp:177
~SearchView() override
Definition: searchview.cpp:183
QPixmap groupLabelPixmap(int w, int h) override
Definition: searchview.cpp:492
QPixmap cachedBannerPixmap(int w, int h) const
Definition: searchview.cpp:473
void read(const QString &search)
Definition: searchview.cpp:241
void timeLineFinished()
Definition: searchview.cpp:329
void slotAddGroupButton()
Definition: searchview.cpp:285
QString write() const
Definition: searchview.cpp:306
void setup()
Definition: searchview.cpp:188
SearchGroup * createSearchGroup() override
Re-implement: create and setup a search group.
Definition: searchview.cpp:277
void slotResetButton()
Definition: searchview.cpp:290
void addGroupToLayout(SearchGroup *group) override
Re-implement: Adds a newly created group to the layout structures.
Definition: searchview.cpp:270
QPixmap bottomBarPixmap(int w, int h) override
Definition: searchview.cpp:497
void startAnimation()
Definition: searchview.cpp:316
void animationFrame(int)
Definition: searchview.cpp:324
void paintEvent(QPaintEvent *e) override
Definition: searchview.cpp:351
void showEvent(QShowEvent *event) override
Definition: searchview.cpp:342
Definition: coredbsearchxml.h:376
Definition: coredbsearchxml.h:224
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43