File indexing completed on 2025-01-19 03:57:59

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2008-05-19
0007  * Description : Fuzzy search sidebar tab contents.
0008  *
0009  * SPDX-FileCopyrightText: 2016-2018 by Mario Frank <mario dot frank at uni minus potsdam dot de>
0010  * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  * SPDX-FileCopyrightText: 2008-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0012  *
0013  * SPDX-License-Identifier: GPL-2.0-or-later
0014  *
0015  * ============================================================ */
0016 
0017 #ifndef DIGIKAM_FUZZY_SEARCH_VIEW_H
0018 #define DIGIKAM_FUZZY_SEARCH_VIEW_H
0019 
0020 // Qt includes
0021 
0022 #include <QDragEnterEvent>
0023 #include <QDragMoveEvent>
0024 #include <QScrollArea>
0025 #include <QDropEvent>
0026 #include <QList>
0027 
0028 // Local includes
0029 
0030 #include "statesavingobject.h"
0031 #include "album.h"
0032 
0033 class QMimeData;
0034 class QPixmap;
0035 
0036 namespace Digikam
0037 {
0038 
0039 class FuzzySearchFolderView;
0040 class ItemInfo;
0041 class LoadingDescription;
0042 class SearchModel;
0043 class SearchModificationHelper;
0044 class SearchTextBar;
0045 
0046 class FuzzySearchView : public QScrollArea,
0047                         public StateSavingObject
0048 {
0049     Q_OBJECT
0050 
0051 public:
0052 
0053     explicit FuzzySearchView(SearchModel* const searchModel,
0054                              SearchModificationHelper* const searchModificationHelper,
0055                              QWidget* const parent = nullptr);
0056     ~FuzzySearchView() override;
0057 
0058     SAlbum* currentAlbum() const;
0059     void setCurrentAlbum(SAlbum* const album);
0060 
0061     void setActive(bool val);
0062     void setItemInfo(const ItemInfo& info);
0063 
0064     void newDuplicatesSearch(const QList<PAlbum*>& albums);
0065     void newDuplicatesSearch(const QList<TAlbum*>& albums);
0066 
0067     void setConfigGroup(const KConfigGroup& group) override;
0068     void doLoadState()                                     override;
0069     void doSaveState()                                     override;
0070 
0071 protected:
0072 
0073     void dragEnterEvent(QDragEnterEvent* e)                override;
0074     void dragMoveEvent(QDragMoveEvent* e)                  override;
0075     void dropEvent(QDropEvent* e)                          override;
0076 
0077 Q_SIGNALS:
0078 
0079     void signalNotificationError(const QString& message, int type);
0080 
0081 private Q_SLOTS:
0082 
0083     void slotTabChanged(int);
0084 
0085     void slotHSChanged(int h, int s);
0086     void slotVChanged(int v);
0087     void slotPenColorChanged(const QColor&);
0088     void slotClearSketch();
0089     void slotSaveSketchSAlbum();
0090     void slotCheckNameEditSketchConditions();
0091 
0092     void slotAlbumSelected(Album* album);
0093 
0094     void slotSaveImageSAlbum();
0095     void slotCheckNameEditImageConditions();
0096     void slotThumbnailLoaded(const LoadingDescription&, const QPixmap&);
0097 
0098     void slotDirtySketch();
0099     void slotTimerSketchDone();
0100     void slotUndoRedoStateChanged(bool, bool);
0101 
0102     void slotMinLevelImageChanged(int);
0103     void slotMaxLevelImageChanged(int);
0104     void slotFuzzyAlbumsChanged();
0105     void slotTimerImageDone();
0106 
0107     void slotApplicationSettingsChanged();
0108 
0109 private:
0110 
0111     void setCurrentImage(qlonglong imageid);
0112     void setCurrentImage(const ItemInfo& info);
0113 
0114     void createNewFuzzySearchAlbumFromSketch(const QString& name, bool force = false);
0115     void createNewFuzzySearchAlbumFromImage(const QString& name, bool force = false);
0116     bool dragEventWrapper(const QMimeData* data) const;
0117 
0118     void setColor(QColor c);
0119 
0120     QWidget* setupFindSimilarPanel()             const;
0121     QWidget* setupSketchPanel()                  const;
0122     void     setupConnections();
0123 
0124 private:
0125 
0126     class Private;
0127     Private* const d;
0128 };
0129 
0130 } // namespace Digikam
0131 
0132 #endif // DIGIKAM_FUZZY_SEARCH_VIEW_H