"Fossies" - the Fresh Open Source Software Archive

Member "digikam-6.3.0/core/utilities/searchwindow/searchview.h" (4 Sep 2019, 4676 Bytes) of package /linux/misc/digikam-6.3.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "searchview.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 6.2.0_vs_6.3.0.

    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 
   46 class SearchViewThemedPartsCache
   47 {
   48 public:
   49 
   50     virtual ~SearchViewThemedPartsCache()
   51     {
   52     }
   53 
   54     virtual QPixmap groupLabelPixmap(int w, int h) = 0;
   55     virtual QPixmap bottomBarPixmap(int w, int h) = 0;
   56 };
   57 
   58 class AbstractSearchGroupContainer : public QWidget
   59 {
   60     Q_OBJECT
   61 
   62 public:
   63 
   64     /// Abstract base class for classes that contain SearchGroups
   65     // To contain common code of SearchView and SearchGroup,
   66     // as SearchGroups can have subgroups.
   67 
   68     explicit AbstractSearchGroupContainer(QWidget* const parent = nullptr);
   69 
   70 public Q_SLOTS:
   71 
   72     SearchGroup* addSearchGroup();
   73     void removeSearchGroup(SearchGroup* group);
   74 
   75 protected:
   76 
   77     /// Call before reading the XML part that could contain group elements
   78     void startReadingGroups(SearchXmlCachingReader& reader);
   79 
   80     /// Call when a group element is the current element
   81     void readGroup(SearchXmlCachingReader& reader);
   82 
   83     /// Call when the XML part is finished
   84     void finishReadingGroups();
   85 
   86     /// Write contained groups to writer
   87     void writeGroups(SearchXmlWriter& writer) const;
   88 
   89     /// Collects the data from the same method of all contained groups (position relative to this widget)
   90     QList<QRect> startupAnimationAreaOfGroups() const;
   91 
   92     /// Re-implement: create and setup a search group
   93     virtual SearchGroup* createSearchGroup() = 0;
   94 
   95     /// Re-implement: Adds a newly created group to the layout structures
   96     virtual void addGroupToLayout(SearchGroup* group) = 0;
   97 
   98 protected Q_SLOTS:
   99 
  100     void removeSendingSearchGroup();
  101 
  102 protected:
  103 
  104     int                 m_groupIndex;
  105     QList<SearchGroup*> m_groups;
  106 };
  107 
  108 // -------------------------------------------------------------------------
  109 
  110 class SearchView : public AbstractSearchGroupContainer, public SearchViewThemedPartsCache
  111 {
  112     Q_OBJECT
  113 
  114 public:
  115 
  116     SearchView();
  117     ~SearchView();
  118 
  119     void setup();
  120     void setBottomBar(SearchViewBottomBar* const bar);
  121 
  122     void read(const QString& search);
  123     QString write() const;
  124 
  125     QPixmap groupLabelPixmap(int w, int h) override;
  126     QPixmap bottomBarPixmap(int w, int h) override;
  127 
  128 Q_SIGNALS:
  129 
  130     void searchOk();
  131     void searchTryout();
  132     void searchCancel();
  133 
  134 protected Q_SLOTS:
  135 
  136     void setTheme();
  137     void slotAddGroupButton();
  138     void slotResetButton();
  139     void startAnimation();
  140     void animationFrame(int);
  141     void timeLineFinished();
  142 
  143 protected:
  144 
  145     QPixmap cachedBannerPixmap(int w, int h) const;
  146 
  147     virtual void paintEvent(QPaintEvent* e) override;
  148     virtual void showEvent(QShowEvent* event) override;
  149 
  150     virtual SearchGroup* createSearchGroup() override;
  151     virtual void addGroupToLayout(SearchGroup* group) override;
  152 
  153 private:
  154 
  155     class Private;
  156     Private* const d;
  157 };
  158 
  159 // -------------------------------------------------------------------------
  160 
  161 class SearchViewBottomBar : public QWidget
  162 {
  163     Q_OBJECT
  164 
  165 public:
  166 
  167     explicit SearchViewBottomBar(SearchViewThemedPartsCache* const cache, QWidget* const parent = nullptr);
  168 
  169 Q_SIGNALS:
  170 
  171     void okPressed();
  172     void cancelPressed();
  173     void tryoutPressed();
  174     void addGroupPressed();
  175     void resetPressed();
  176 
  177 protected:
  178 
  179     virtual void paintEvent(QPaintEvent*) override;
  180 
  181 protected:
  182 
  183     QHBoxLayout*                m_mainLayout;
  184 
  185     QDialogButtonBox*           m_buttonBox;
  186     QPushButton*                m_addGroupsButton;
  187     QPushButton*                m_resetButton;
  188 
  189     SearchViewThemedPartsCache* m_themeCache;
  190 };
  191 
  192 } // namespace Digikam
  193 
  194 #endif // DIGIKAM_SEARCH_VIEW_H