digiKam
searchtextbar.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2007-11-25
7  * Description : a bar used to search a string - version not based on database models
8  *
9  * Copyright (C) 2007-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
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_TEXT_BAR_H
25 #define DIGIKAM_SEARCH_TEXT_BAR_H
26 
27 // Qt includes
28 
29 #include <QAbstractItemModel>
30 #include <QStringList>
31 #include <QLineEdit>
32 
33 // Local includes
34 
35 #include "digikam_export.h"
36 #include "modelcompleter.h"
37 #include "statesavingobject.h"
38 
39 namespace Digikam
40 {
41 
42 class DIGIKAM_EXPORT SearchTextSettings
43 {
44 
45 public:
46 
48  : caseSensitive(Qt::CaseInsensitive)
49  {
50  }
51 
52  Qt::CaseSensitivity caseSensitive;
53 
54  QString text;
55 };
56 
57 bool DIGIKAM_EXPORT operator==(const SearchTextSettings& a, const SearchTextSettings& b);
58 
63 class DIGIKAM_EXPORT SearchTextBar : public QLineEdit,
64  public StateSavingObject
65 {
66  Q_OBJECT
67 
68 public:
69 
74  {
80 
86 
90  NO_RESULT
91  };
92 
93 public:
94 
95  explicit SearchTextBar(QWidget* const parent,
96  const QString& name,
97  const QString& msg = QString());
98  ~SearchTextBar() override;
99 
100  void setTextQueryCompletion(bool b);
101  bool hasTextQueryCompletion() const;
102 
113  void setHighlightOnResult(bool highlight);
114 
121  HighlightState getCurrentHighlightState() const;
122 
132  void setCaseSensitive(bool b);
133  bool hasCaseSensitive() const;
134 
135  void setSearchTextSettings(const SearchTextSettings& settings);
136  SearchTextSettings searchTextSettings() const;
137  ModelCompleter* completerModel() const;
138 
139 Q_SIGNALS:
140 
142  void completerHighlighted(int albumId);
144 
145 public Q_SLOTS:
146 
147  void slotSearchResult(bool match);
148 
149 private Q_SLOTS:
150 
151  void slotTextChanged();
152 
153 protected:
154 
155  void doLoadState() override;
156  void doSaveState() override;
157 
158 private:
159 
160  void contextMenuEvent(QContextMenuEvent* e) override;
161 
169  void setIgnoreCase(bool ignore);
170 
171 private:
172 
173  class Private;
174  Private* const d;
175 };
176 
177 } // namespace Digikam
178 
179 #endif // DIGIKAM_SEARCH_TEXT_BAR_H
Definition: modelcompleter.h:43
Definition: searchtextbar.h:65
HighlightState
Definition: searchtextbar.h:74
@ HAS_RESULT
Definition: searchtextbar.h:85
@ NEUTRAL
Definition: searchtextbar.h:79
void signalSearchTextSettings(const SearchTextSettings &settings)
void completerHighlighted(int albumId)
Definition: searchtextbar.h:43
SearchTextSettings()
Definition: searchtextbar.h:47
Qt::CaseSensitivity caseSensitive
Definition: searchtextbar.h:52
QString text
Definition: searchtextbar.h:54
Definition: statesavingobject.h:76
Definition: datefolderview.cpp:43
bool operator==(const SearchTextSettings &a, const SearchTextSettings &b)
Definition: searchtextbar.cpp:49