1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2008-02-26
7  * Description : Upper widget in the search sidebar
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_TAB_HEADER_H
25 #define DIGIKAM_SEARCH_TAB_HEADER_H
26 
27 // Qt includes
28 
29 #include <QWidget>
30 
31 // Local includes
32 
33 #include "coredbalbuminfo.h"
34 
35 namespace Digikam
36 {
37 
38 class Album;
39 class SAlbum;
40 class SearchWindow;
41 
42 class SearchTabHeader : public QWidget
43 {
44     Q_OBJECT
45 
46 public:
47 
48     explicit SearchTabHeader(QWidget* const parent);
49     ~SearchTabHeader() override;
50 
51 public Q_SLOTS:
52 
53     void selectedSearchChanged(Album* album);
54     void editSearch(SAlbum* album);
55     void newKeywordSearch();
56     void newAdvancedSearch();
57 
58 Q_SIGNALS:
59 
60     void searchShallBeSelected(const QList<Album*>& albums);
61 
62 private Q_SLOTS:
63 
64     void keywordChanged();
65     void keywordChangedTimer();
66     void editCurrentAdvancedSearch();
67     void saveSearch();
68     void storedKeywordChanged();
69     void editStoredAdvancedSearch();
70     void advancedSearchEdited(int id, const QString& query);
71 
72 private:
73 
74     void          setCurrentSearch(DatabaseSearch::Type type, const QString& query, bool selectCurrentAlbum = true);
75     QString       queryFromKeywords(const QString& keywords) const;
76     QString       keywordsFromQuery(const QString& query) const;
77     SearchWindow* searchWindow() const;
78 
79 private:
80 
81     class Private;
82     Private* const d;
83 };
84 
85 } // namespace Digikam
86 
87 #endif // DIGIKAM_SEARCH_TAB_HEADER_H
88