LibrePCB Developers Documentation
searchtoolbar.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_EDITOR_SEARCHTOOLBAR_H
21#define LIBREPCB_EDITOR_SEARCHTOOLBAR_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include <QtCore>
27#include <QtWidgets>
28
29#include <functional>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35namespace editor {
36
37/*******************************************************************************
38 * Class SearchToolBar
39 ******************************************************************************/
40
44class SearchToolBar final : public QToolBar {
45 Q_OBJECT
46
47public:
48 typedef std::function<QStringList()> CompleterListFunction;
49
50 // Constructors / Destructor
51 SearchToolBar(const SearchToolBar& other) = delete;
52 explicit SearchToolBar(QWidget* parent = nullptr) noexcept;
53 ~SearchToolBar() noexcept;
54
55 // Getters
56 QString getText() const noexcept { return mLineEdit->text(); }
57
58 // Setters
59 void setPlaceholderText(const QString& text) noexcept {
60 mLineEdit->setPlaceholderText(text);
61 }
64 }
65
66 // General Methods
67 void clear() noexcept;
68 void selectAllAndSetFocus() noexcept;
69 void findNext() noexcept;
70 void findPrevious() noexcept;
71
72 // Operator Overloadings
73 SearchToolBar& operator=(const SearchToolBar& rhs) = delete;
74
75signals:
76 void textChanged(const QString& text);
77 void goToTriggered(const QString& name, int index = 0);
78
79private:
80 void updateCompleter() noexcept;
81 void textChangedHandler(const QString& text) noexcept;
82
83private:
85 QScopedPointer<QLineEdit> mLineEdit;
86 bool mForward;
87 int mIndex;
88};
89
90/*******************************************************************************
91 * End of File
92 ******************************************************************************/
93
94} // namespace editor
95} // namespace librepcb
96
97#endif
The SearchToolBar class.
Definition: searchtoolbar.h:44
void clear() noexcept
Definition: searchtoolbar.cpp:66
CompleterListFunction mCompleterListFunction
Definition: searchtoolbar.h:84
void goToTriggered(const QString &name, int index=0)
int mIndex
Number of searches with the current search term.
Definition: searchtoolbar.h:87
QString getText() const noexcept
Definition: searchtoolbar.h:56
void updateCompleter() noexcept
Definition: searchtoolbar.cpp:97
void textChangedHandler(const QString &text) noexcept
Definition: searchtoolbar.cpp:107
void setPlaceholderText(const QString &text) noexcept
Definition: searchtoolbar.h:59
SearchToolBar(const SearchToolBar &other)=delete
QScopedPointer< QLineEdit > mLineEdit
Definition: searchtoolbar.h:85
std::function< QStringList()> CompleterListFunction
Definition: searchtoolbar.h:48
bool mForward
Current search direction (forward or backward)
Definition: searchtoolbar.h:86
void findNext() noexcept
Definition: searchtoolbar.cpp:75
void setCompleterListFunction(CompleterListFunction fun) noexcept
Definition: searchtoolbar.h:62
void findPrevious() noexcept
Definition: searchtoolbar.cpp:84
void textChanged(const QString &text)
void selectAllAndSetFocus() noexcept
Definition: searchtoolbar.cpp:70
Definition: occmodel.cpp:77