LibrePCB Developers Documentation
Loading...
Searching...
No Matches
searchcontext.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_SEARCHCONTEXT_H
21#define LIBREPCB_EDITOR_SEARCHCONTEXT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include <QtCore>
27
28#include <slint.h>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34namespace editor {
35
36/*******************************************************************************
37 * Class SearchContext
38 ******************************************************************************/
39
43class SearchContext final : public QObject {
44 Q_OBJECT
45
46public:
47 // Constructors / Destructor
48 SearchContext(const SearchContext& other) = delete;
49 explicit SearchContext(QObject* parent = nullptr) noexcept;
50 ~SearchContext() noexcept;
51
52 // General Methods
53 void init() noexcept;
54 void deinit() noexcept;
55 void setTerm(const QString& term) noexcept;
56 const QString& getTerm() const noexcept { return mTerm; }
57 void setSuggestions(const QStringList& list) noexcept;
58 const std::shared_ptr<slint::FilterModel<slint::SharedString>>&
59 getSuggestions() const noexcept {
61 }
62 void findNext() noexcept;
63 void findPrevious() noexcept;
64
65 // Operator Overloadings
66 SearchContext& operator=(const SearchContext& rhs) = delete;
67
68signals:
69 void goToTriggered(const QString& name, int index = 0);
70
71private:
72 QString mTerm;
73 bool mForward;
74 int mIndex;
75
76 std::shared_ptr<slint::VectorModel<slint::SharedString>> mSuggestions;
77 std::shared_ptr<slint::FilterModel<slint::SharedString>> mSuggestionsFiltered;
78};
79
80/*******************************************************************************
81 * End of File
82 ******************************************************************************/
83
84} // namespace editor
85} // namespace librepcb
86
87#endif
The SearchContext class.
Definition searchcontext.h:43
std::shared_ptr< slint::FilterModel< slint::SharedString > > mSuggestionsFiltered
Definition searchcontext.h:77
void goToTriggered(const QString &name, int index=0)
int mIndex
Number of searches with the current search term.
Definition searchcontext.h:74
void deinit() noexcept
Definition searchcontext.cpp:62
QString mTerm
Definition searchcontext.h:72
std::shared_ptr< slint::VectorModel< slint::SharedString > > mSuggestions
Definition searchcontext.h:76
bool mForward
Current search direction (forward or backward)
Definition searchcontext.h:73
void setSuggestions(const QStringList &list) noexcept
Definition searchcontext.cpp:78
const std::shared_ptr< slint::FilterModel< slint::SharedString > > & getSuggestions() const noexcept
Definition searchcontext.h:59
void findNext() noexcept
Definition searchcontext.cpp:89
void init() noexcept
Definition searchcontext.cpp:50
void findPrevious() noexcept
Definition searchcontext.cpp:98
const QString & getTerm() const noexcept
Definition searchcontext.h:56
SearchContext(const SearchContext &other)=delete
void setTerm(const QString &term) noexcept
Definition searchcontext.cpp:67
Definition occmodel.cpp:77
Definition uuid.h:186