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
******************************************************************************/
34
namespace
librepcb
{
35
namespace
editor {
36
37
/*******************************************************************************
38
* Class SearchToolBar
39
******************************************************************************/
40
44
class
SearchToolBar
final :
public
QToolBar {
45
Q_OBJECT
46
47
public
:
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
}
62
void
setCompleterListFunction
(
CompleterListFunction
fun)
noexcept
{
63
mCompleterListFunction
= fun;
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
75
signals:
76
void
textChanged
(const QString& text);
77
void
goToTriggered
(const QString& name,
int
index = 0);
78
79
private:
80
void
updateCompleter
() noexcept;
81
void
textChangedHandler
(const QString& text) noexcept;
82
83
private:
84
CompleterListFunction
mCompleterListFunction
;
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
librepcb::editor::SearchToolBar
The SearchToolBar class.
Definition:
searchtoolbar.h:44
librepcb::editor::SearchToolBar::clear
void clear() noexcept
Definition:
searchtoolbar.cpp:66
librepcb::editor::SearchToolBar::mCompleterListFunction
CompleterListFunction mCompleterListFunction
Definition:
searchtoolbar.h:84
librepcb::editor::SearchToolBar::goToTriggered
void goToTriggered(const QString &name, int index=0)
librepcb::editor::SearchToolBar::mIndex
int mIndex
Number of searches with the current search term.
Definition:
searchtoolbar.h:87
librepcb::editor::SearchToolBar::getText
QString getText() const noexcept
Definition:
searchtoolbar.h:56
librepcb::editor::SearchToolBar::updateCompleter
void updateCompleter() noexcept
Definition:
searchtoolbar.cpp:97
librepcb::editor::SearchToolBar::textChangedHandler
void textChangedHandler(const QString &text) noexcept
Definition:
searchtoolbar.cpp:107
librepcb::editor::SearchToolBar::setPlaceholderText
void setPlaceholderText(const QString &text) noexcept
Definition:
searchtoolbar.h:59
librepcb::editor::SearchToolBar::SearchToolBar
SearchToolBar(const SearchToolBar &other)=delete
librepcb::editor::SearchToolBar::mLineEdit
QScopedPointer< QLineEdit > mLineEdit
Definition:
searchtoolbar.h:85
librepcb::editor::SearchToolBar::CompleterListFunction
std::function< QStringList()> CompleterListFunction
Definition:
searchtoolbar.h:48
librepcb::editor::SearchToolBar::mForward
bool mForward
Current search direction (forward or backward)
Definition:
searchtoolbar.h:86
librepcb::editor::SearchToolBar::findNext
void findNext() noexcept
Definition:
searchtoolbar.cpp:75
librepcb::editor::SearchToolBar::setCompleterListFunction
void setCompleterListFunction(CompleterListFunction fun) noexcept
Definition:
searchtoolbar.h:62
librepcb::editor::SearchToolBar::findPrevious
void findPrevious() noexcept
Definition:
searchtoolbar.cpp:84
librepcb::editor::SearchToolBar::textChanged
void textChanged(const QString &text)
librepcb::editor::SearchToolBar::selectAllAndSetFocus
void selectAllAndSetFocus() noexcept
Definition:
searchtoolbar.cpp:70
librepcb
Definition:
occmodel.cpp:77
libs
librepcb
editor
widgets
searchtoolbar.h
Generated on Tue Nov 19 2024 20:15:51 for LibrePCB Developers Documentation by
1.9.4