"Fossies" - the Fresh Open Source Software Archive

Member "digikam-6.3.0/core/utilities/searchwindow/searchfields.h" (4 Sep 2019, 14032 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 "searchfields.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  * Copyright (C) 2011-2019 by Gilles Caulier <caulier dot gilles at gmail dot com>
   11  *
   12  * This program is free software; you can redistribute it
   13  * and/or modify it under the terms of the GNU General
   14  * Public License as published by the Free Software Foundation;
   15  * either version 2, or (at your option)
   16  * any later version.
   17  *
   18  * This program is distributed in the hope that it will be useful,
   19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   21  * GNU General Public License for more details.
   22  *
   23  * ============================================================ */
   24 
   25 #ifndef DIGIKAM_SEARCH_FIELDS_H
   26 #define DIGIKAM_SEARCH_FIELDS_H
   27 
   28 // Qt includes
   29 
   30 #include <QObject>
   31 #include <QWidget>
   32 #include <QMap>
   33 
   34 // Local includes
   35 
   36 #include "coredbsearchxml.h"
   37 #include "searchutilities.h"
   38 #include "visibilitycontroller.h"
   39 
   40 class QLabel;
   41 class QCheckBox;
   42 class QGridLayout;
   43 class QSpinBox;
   44 class QDoubleSpinBox;
   45 class QTimeEdit;
   46 class QTreeView;
   47 class QComboBox;
   48 class QLineEdit;
   49 
   50 namespace Digikam
   51 {
   52 
   53 class DAdjustableLabel;
   54 class AbstractAlbumTreeViewSelectComboBox;
   55 class SearchFieldGroup;
   56 class SqueezedComboBox;
   57 class DDateEdit;
   58 class ChoiceSearchModel;
   59 class ChoiceSearchComboBox;
   60 class RatingComboBox;
   61 class PickLabelFilter;
   62 class ColorLabelFilter;
   63 
   64 class SearchField : public QObject, public VisibilityObject
   65 {
   66     Q_OBJECT
   67 
   68 public:
   69 
   70     enum WidgetRectType
   71     {
   72         LabelAndValueWidgetRects,
   73         ValueWidgetRectsOnly
   74     };
   75 
   76 public:
   77 
   78     static SearchField* createField(const QString& fieldName, SearchFieldGroup* const parent);
   79 
   80     explicit SearchField(QObject* const parent);
   81 
   82     void setup(QGridLayout* const layout, int row = -1);
   83     void setFieldName(const QString& fieldName);
   84     void setCategoryLabelVisible(bool visible);
   85     void setCategoryLabelVisibleFromPreviousField(SearchField* const previousField);
   86 
   87     QList<QRect> widgetRects(WidgetRectType = ValueWidgetRectsOnly) const;
   88 
   89     virtual void setText(const QString& label, const QString& detailLabel);
   90 
   91     virtual bool supportsField(const QString& fieldName);
   92     virtual void read(SearchXmlCachingReader& reader) = 0;
   93     virtual void write(SearchXmlWriter& writer) = 0;
   94     virtual void reset() = 0;
   95 
   96     virtual void setVisible(bool visible) override;
   97     virtual bool isVisible() override;
   98 
   99 protected Q_SLOTS:
  100 
  101     void clearButtonClicked();
  102 
  103 protected:
  104 
  105     void setValidValueState(bool valueIsValid);
  106 
  107     virtual void setupValueWidgets(QGridLayout* layout, int row, int column) = 0;
  108     virtual void setupLabels(QGridLayout* layout, int line);
  109 
  110     virtual void setValueWidgetsVisible(bool visible) = 0;
  111     virtual QList<QRect> valueWidgetRects() const = 0;
  112 
  113 protected:
  114 
  115     QString              m_name;
  116 
  117     QLabel*              m_label;
  118     QLabel*              m_detailLabel;
  119 
  120     AnimatedClearButton* m_clearButton;
  121 
  122     bool                 m_categoryLabelVisible;
  123     bool                 m_valueIsValid;
  124 };
  125 
  126 //-----------------------------------------------------------------------------
  127 
  128 class SearchFieldText : public SearchField
  129 {
  130     Q_OBJECT
  131 
  132 public:
  133 
  134     explicit SearchFieldText(QObject* const parent);
  135 
  136     virtual void setupValueWidgets(QGridLayout* layout, int row, int column) override;
  137     virtual void read(SearchXmlCachingReader& reader) override;
  138     virtual void write(SearchXmlWriter& writer) override;
  139     virtual void setValueWidgetsVisible(bool visible) override;
  140     virtual void reset() override;
  141     virtual QList<QRect> valueWidgetRects() const override;
  142 
  143 protected Q_SLOTS:
  144 
  145     void valueChanged(const QString& text);
  146 
  147 protected:
  148 
  149     QLineEdit* m_edit;
  150 };
  151 
  152 //-----------------------------------------------------------------------------
  153 
  154 class SearchFieldKeyword : public SearchFieldText
  155 {
  156 public:
  157 
  158     explicit SearchFieldKeyword(QObject* const parent);
  159 
  160     virtual void read(SearchXmlCachingReader& reader) override;
  161     virtual void write(SearchXmlWriter& writer) override;
  162 };
  163 
  164 //-----------------------------------------------------------------------------
  165 
  166 class SearchFieldRangeInt : public SearchField
  167 {
  168     Q_OBJECT
  169 
  170 public:
  171 
  172     explicit SearchFieldRangeInt(QObject* const parent);
  173 
  174     void setBetweenText(const QString& text);
  175     void setNoValueText(const QString& text);
  176     void setNumberPrefixAndSuffix(const QString& prefix, const QString& suffix);
  177     void setBoundary(int min, int max, int step = 1);
  178     void enableFractionMagic(const QString& prefix);
  179 
  180     void setSuggestedValues(const QList<int>& values);
  181     void setSuggestedInitialValue(int initialValue);
  182     void setSingleSteps(int smaller, int larger);
  183     void setInvertStepping(bool invert);
  184 
  185     virtual void setupValueWidgets(QGridLayout* layout, int row, int column) override;
  186     virtual void read(SearchXmlCachingReader& reader) override;
  187     virtual void write(SearchXmlWriter& writer) override;
  188     virtual void reset() override;
  189     virtual void setValueWidgetsVisible(bool visible) override;
  190     virtual QList<QRect> valueWidgetRects() const override;
  191 
  192 protected Q_SLOTS:
  193 
  194     void valueChanged();
  195 
  196 protected:
  197 
  198     int                    m_min;
  199     int                    m_max;
  200     bool                   m_reciprocal;
  201     CustomStepsIntSpinBox* m_firstBox;
  202     CustomStepsIntSpinBox* m_secondBox;
  203     QLabel*                m_betweenLabel;
  204 };
  205 
  206 //-----------------------------------------------------------------------------
  207 
  208 class SearchFieldRangeDouble : public SearchField
  209 {
  210     Q_OBJECT
  211 
  212 public:
  213 
  214     explicit SearchFieldRangeDouble(QObject* const parent);
  215 
  216     void setBetweenText(const QString& text);
  217     void setNoValueText(const QString& text);
  218     void setNumberPrefixAndSuffix(const QString& prefix, const QString& suffix);
  219     void setBoundary(double min, double max, int decimals, double step);
  220     void setFactor(double factor);
  221 
  222     void setSuggestedValues(const QList<double>& values);
  223     void setSuggestedInitialValue(double initialValue);
  224     void setSingleSteps(double smaller, double larger);
  225     void setInvertStepping(bool invert);
  226 
  227     virtual void setupValueWidgets(QGridLayout* layout, int row, int column) override;
  228     virtual void read(SearchXmlCachingReader& reader) override;
  229     virtual void write(SearchXmlWriter& writer) override;
  230     virtual void reset() override;
  231     virtual void setValueWidgetsVisible(bool visible) override;
  232     virtual QList<QRect> valueWidgetRects() const override;
  233 
  234 protected Q_SLOTS:
  235 
  236     void valueChanged();
  237 
  238 protected:
  239 
  240     double                    m_min;
  241     double                    m_max;
  242     double                    m_factor;
  243     CustomStepsDoubleSpinBox* m_firstBox;
  244     CustomStepsDoubleSpinBox* m_secondBox;
  245     QLabel*                   m_betweenLabel;
  246 };
  247 
  248 //-----------------------------------------------------------------------------
  249 
  250 class SearchFieldRangeDate : public SearchField
  251 {
  252     Q_OBJECT
  253 
  254 public:
  255 
  256     enum Type
  257     {
  258         DateOnly,
  259         DateTime
  260     };
  261 
  262 public:
  263 
  264     SearchFieldRangeDate(QObject* const parent, Type type);
  265 
  266     void setBetweenText(const QString& between);
  267     void setBoundary(const QDateTime& min, const QDateTime& max);
  268 
  269     virtual void setupValueWidgets(QGridLayout* layout, int row, int column) override;
  270     virtual void read(SearchXmlCachingReader& reader) override;
  271     virtual void write(SearchXmlWriter& writer) override;
  272     virtual void reset() override;
  273     virtual void setValueWidgetsVisible(bool visible) override;
  274     virtual QList<QRect> valueWidgetRects() const override;
  275 
  276 protected Q_SLOTS:
  277 
  278     void valueChanged();
  279 
  280 protected:
  281 
  282     QTimeEdit* m_firstTimeEdit;
  283     DDateEdit* m_firstDateEdit;
  284     QTimeEdit* m_secondTimeEdit;
  285     DDateEdit* m_secondDateEdit;
  286     QLabel*    m_betweenLabel;
  287 
  288     Type       m_type;
  289 };
  290 
  291 //-----------------------------------------------------------------------------
  292 
  293 class SearchFieldChoice : public SearchField
  294 {
  295     Q_OBJECT
  296 
  297 public:
  298 
  299     explicit SearchFieldChoice(QObject* const parent);
  300 
  301     void setChoice(const QMap<int, QString>& map);
  302     void setChoice(const QStringList& choice);
  303     void setAnyText(const QString& anyText);
  304 
  305     virtual void setupValueWidgets(QGridLayout* layout, int row, int column) override;
  306     virtual void read(SearchXmlCachingReader& reader) override;
  307     virtual void write(SearchXmlWriter& writer) override;
  308     virtual void reset() override;
  309     virtual void setValueWidgetsVisible(bool visible) override;
  310     virtual QList<QRect> valueWidgetRects() const override;
  311 
  312 protected Q_SLOTS:
  313 
  314     void checkStateChanged();
  315 
  316 protected:
  317 
  318     void updateComboText();
  319 
  320 protected:
  321 
  322     ChoiceSearchComboBox* m_comboBox;
  323     QVariant::Type        m_type;
  324     QString               m_anyText;
  325     ChoiceSearchModel*    m_model;
  326 };
  327 
  328 //-----------------------------------------------------------------------------
  329 
  330 class Album;
  331 class AbstractCheckableAlbumModel;
  332 //class AlbumSelectComboBox;
  333 class AbstractAlbumTreeViewSelectComboBox;
  334 class AlbumTreeViewSelectComboBox;
  335 class TagTreeViewSelectComboBox;
  336 class SqueezedComboBox;
  337 
  338 class SearchFieldAlbum : public SearchField
  339 {
  340     Q_OBJECT
  341 
  342 public:
  343 
  344     enum Type
  345     {
  346         TypeAlbum,
  347         TypeTag
  348     };
  349 
  350     enum Operation
  351     {
  352         All,
  353         OneOf
  354     };
  355 
  356 public:
  357 
  358     SearchFieldAlbum(QObject* const parent, Type type);
  359 
  360     virtual void setupValueWidgets(QGridLayout* layout, int row, int column) override;
  361     virtual void read(SearchXmlCachingReader& reader) override;
  362     virtual void write(SearchXmlWriter& writer) override;
  363     virtual void reset() override;
  364     virtual void setValueWidgetsVisible(bool visible) override;
  365     virtual QList<QRect> valueWidgetRects() const override;
  366 
  367 protected Q_SLOTS:
  368 
  369     void updateState();
  370 
  371 protected:
  372 
  373     QWidget*                             m_wrapperBox;
  374     AlbumTreeViewSelectComboBox*         m_albumComboBox;
  375     TagTreeViewSelectComboBox*           m_tagComboBox;
  376     SqueezedComboBox*                    m_operation;
  377     Type                                 m_type;
  378     AbstractCheckableAlbumModel*         m_model;
  379 };
  380 
  381 //-----------------------------------------------------------------------------
  382 
  383 class SearchFieldRating : public SearchField
  384 {
  385     Q_OBJECT
  386 
  387 public:
  388 
  389     explicit SearchFieldRating(QObject* const parent);
  390 
  391     void setBetweenText(const QString& text);
  392 
  393     virtual void setupValueWidgets(QGridLayout* layout, int row, int column) override;
  394     virtual void read(SearchXmlCachingReader& reader) override;
  395     virtual void write(SearchXmlWriter& writer) override;
  396     virtual void reset() override;
  397     virtual void setValueWidgetsVisible(bool visible) override;
  398     virtual QList<QRect> valueWidgetRects() const override;
  399 
  400 protected Q_SLOTS:
  401 
  402     void firstValueChanged();
  403     void secondValueChanged();
  404 
  405 protected:
  406 
  407     RatingComboBox* m_firstBox;
  408     RatingComboBox* m_secondBox;
  409     QLabel*         m_betweenLabel;
  410 };
  411 
  412 //-----------------------------------------------------------------------------
  413 
  414 class SearchFieldComboBox : public SearchField
  415 {
  416     Q_OBJECT
  417 
  418 public:
  419 
  420     explicit SearchFieldComboBox(QObject* const  parent);
  421 
  422     virtual void setupValueWidgets(QGridLayout* layout, int row, int column) override;
  423     virtual void write(SearchXmlWriter& writer) override;
  424     virtual void reset() override;
  425     virtual void setValueWidgetsVisible(bool visible) override;
  426     virtual QList<QRect> valueWidgetRects() const override;
  427 
  428 protected Q_SLOTS:
  429 
  430     void indexChanged(int);
  431 
  432 protected:
  433 
  434     QComboBox* m_comboBox;
  435 };
  436 
  437 //-----------------------------------------------------------------------------
  438 
  439 class SearchFieldCheckBox : public SearchField
  440 {
  441     Q_OBJECT
  442 
  443 public:
  444 
  445     explicit SearchFieldCheckBox(QObject* const parent);
  446 
  447     void setLabel(const QString& text);
  448 
  449     virtual void setupValueWidgets(QGridLayout* layout, int row, int column) override;
  450     virtual void read(SearchXmlCachingReader& reader) override;
  451     virtual void write(SearchXmlWriter& writer) override;
  452     virtual void reset() override;
  453     virtual void setValueWidgetsVisible(bool visible) override;
  454     virtual QList<QRect> valueWidgetRects() const override;
  455 
  456 protected Q_SLOTS:
  457 
  458     void slotToggled(bool checked);
  459 
  460 protected:
  461 
  462     QCheckBox* m_checkBox;
  463     QString    m_text;
  464 };
  465 
  466 //-----------------------------------------------------------------------------
  467 
  468 class SearchFieldColorDepth : public SearchFieldComboBox
  469 {
  470     Q_OBJECT
  471 
  472 public:
  473 
  474     explicit SearchFieldColorDepth(QObject* const parent);
  475 
  476     virtual void setupValueWidgets(QGridLayout* layout, int row, int column) override;
  477     virtual void read(SearchXmlCachingReader& reader) override;
  478 };
  479 
  480 //-----------------------------------------------------------------------------
  481 
  482 class SearchFieldPageOrientation: public SearchFieldComboBox
  483 {
  484     Q_OBJECT
  485 
  486 public:
  487 
  488     explicit SearchFieldPageOrientation(QObject* const parent);
  489 
  490     virtual void setupValueWidgets(QGridLayout* layout, int row, int column) override;
  491     virtual void read(SearchXmlCachingReader& reader) override;
  492 };
  493 
  494 //-----------------------------------------------------------------------------
  495 
  496 class SearchFieldLabels : public SearchField
  497 {
  498     Q_OBJECT
  499 
  500 public:
  501 
  502     explicit SearchFieldLabels(QObject* const parent);
  503 
  504     virtual void setupValueWidgets(QGridLayout* layout, int row, int column) override;
  505     virtual void read(SearchXmlCachingReader& reader) override;
  506     virtual void write(SearchXmlWriter& writer) override;
  507     virtual void reset() override;
  508     virtual void setValueWidgetsVisible(bool visible) override;
  509     virtual QList<QRect> valueWidgetRects() const override;
  510 
  511 protected Q_SLOTS:
  512 
  513     void updateState();
  514 
  515 protected:
  516 
  517     PickLabelFilter*  m_pickLabelFilter;
  518     ColorLabelFilter* m_colorLabelFilter;
  519 };
  520 
  521 } // namespace Digikam
  522 
  523 #endif // DIGIKAM_SEARCH_FIELDS_H