1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2008-05-19
7  * Description : Fuzzy search sidebar tab contents.
8  *
9  * Copyright (C) 2016-2018 by Mario Frank <mario dot frank at uni minus potsdam dot de>
10  * Copyright (C) 2008-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  * Copyright (C) 2008-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_FUZZY_SEARCH_VIEW_H
27 #define DIGIKAM_FUZZY_SEARCH_VIEW_H
28 
29 // Qt includes
30 
31 #include <QDragEnterEvent>
32 #include <QDragMoveEvent>
33 #include <QScrollArea>
34 #include <QDropEvent>
35 
36 // Local includes
37 
38 #include "statesavingobject.h"
39 
40 class QMimeData;
41 class QPixmap;
42 
43 namespace Digikam
44 {
45 
46 class Album;
47 class FuzzySearchFolderView;
48 class ItemInfo;
49 class LoadingDescription;
50 class SAlbum;
51 class PAlbum;
52 class TAlbum;
53 class SearchModel;
54 class SearchModificationHelper;
55 class SearchTextBar;
56 
57 class FuzzySearchView : public QScrollArea,
58                         public StateSavingObject
59 {
60     Q_OBJECT
61 
62 public:
63 
64     explicit FuzzySearchView(SearchModel* const searchModel,
65                              SearchModificationHelper* const searchModificationHelper,
66                              QWidget* const parent = nullptr);
67     ~FuzzySearchView() override;
68 
69     SAlbum* currentAlbum() const;
70     void setCurrentAlbum(SAlbum* const album);
71 
72     void setActive(bool val);
73     void setItemInfo(const ItemInfo& info);
74 
75     void newDuplicatesSearch(const QList<PAlbum*>& albums);
76     void newDuplicatesSearch(const QList<TAlbum*>& albums);
77 
78     void setConfigGroup(const KConfigGroup& group) override;
79     void doLoadState()                                     override;
80     void doSaveState()                                     override;
81 
82 protected:
83 
84     void dragEnterEvent(QDragEnterEvent* e)                override;
85     void dragMoveEvent(QDragMoveEvent* e)                  override;
86     void dropEvent(QDropEvent* e)                          override;
87 
88 Q_SIGNALS:
89 
90     void signalNotificationError(const QString& message, int type);
91 
92 private Q_SLOTS:
93 
94     void slotTabChanged(int);
95 
96     void slotHSChanged(int h, int s);
97     void slotVChanged(int v);
98     void slotPenColorChanged(const QColor&);
99     void slotClearSketch();
100     void slotSaveSketchSAlbum();
101     void slotCheckNameEditSketchConditions();
102 
103     void slotAlbumSelected(Album* album);
104 
105     void slotSaveImageSAlbum();
106     void slotCheckNameEditImageConditions();
107     void slotThumbnailLoaded(const LoadingDescription&, const QPixmap&);
108 
109     void slotDirtySketch();
110     void slotTimerSketchDone();
111     void slotUndoRedoStateChanged(bool, bool);
112 
113     void slotMinLevelImageChanged(int);
114     void slotMaxLevelImageChanged(int);
115     void slotFuzzyAlbumsChanged();
116     void slotTimerImageDone();
117 
118     void slotApplicationSettingsChanged();
119 
120 private:
121 
122     void setCurrentImage(qlonglong imageid);
123     void setCurrentImage(const ItemInfo& info);
124 
125     void createNewFuzzySearchAlbumFromSketch(const QString& name, bool force = false);
126     void createNewFuzzySearchAlbumFromImage(const QString& name, bool force = false);
127     bool dragEventWrapper(const QMimeData* data) const;
128 
129     void setColor(QColor c);
130 
131     QWidget* setupFindSimilarPanel()             const;
132     QWidget* setupSketchPanel()                  const;
133     void     setupConnections();
134 
135 private:
136 
137     class Private;
138     Private* const d;
139 };
140 
141 } // namespace Digikam
142 
143 #endif // DIGIKAM_FUZZY_SEARCH_VIEW_H
144