API Documentation
Loading...
Searching...
No Matches
DesignObjectSearchWidget.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: NDEVR
28File: DesignObjectStringWidget
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/QCustomLineEdit.h>
35#include <NDEVR/QCustomValidator.h>
36#include <NDEVR/DesignObjectLookup.h>
37#include <NDEVR/DesignObject.h>
38#include <NDEVR/RegexFunctions.h>
39
40namespace NDEVR
41{
43 {
44 Q_OBJECT
45 public:
46 DesignObjectSearchWidget(QWidget* parent = nullptr)
47 : QCustomLineEdit(parent)
48 , m_property(DesignObject::e_design_property_size)
49 , m_manager(nullptr)
50 , m_ignore_case(false)
51 {
52 setPlaceholderText(_tqa("Search"));
53 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
54 customValidator().setAllowEmpty(true);
55 }
57 {
58 setSearchIDs(Buffer<UUID>());
59 }
61 {
62 m_manager = lookup;
63 }
65 {
66 m_objects_to_search = objects;
67 m_property = property;
68 onObjectUpdatedSlot();
69 }
70 void setSearchIDs(const Buffer<UUID>& objects)
71 {
72 if (m_objects_to_search == objects)
73 return;
74 m_objects_to_search = objects;
75 onObjectUpdatedSlot();
76 }
78 {
79 m_property = property;
80 onObjectUpdatedSlot();
81 switch (property)
82 {
83 case DesignObject::DesignProperty::e_file:
84 customValidator().setRegex(RegexFunctions::FileRegex());
85 break;
86 default:
87 //customValidator().setRegex(/*"^[\\.a-zA-Z0-9_\\s-]+$"*/);
88 break;
89 }
90 }
92 {
93 String value = getValue();
94 if (value.size() == 0)
95 return m_objects_to_search;
96 Buffer<UUID> ids;
97 const DesignObject::DesignProperty property = m_property;
98 const bool ignore_case = m_ignore_case;
99 for(const UUID& id : m_objects_to_search)
100 {
101 if(m_manager->object(id).doesPropertyContain(property, value, ignore_case))
102 {
103 ids.add(id);
104 }
105 }
106 return ids;
107 }
108
110 {
111 String value = getValue();
112 if (value.size() == 0)
113 return m_objects_to_search;
114 Buffer<UUID> ids;
115 const DesignObject::DesignProperty property = m_property;
116 const bool ignore_case = m_ignore_case;
117 for (const UUID& id : m_objects_to_search)
118 {
119 if (m_manager->object(id).doesPropertyBeginWith(property, value, ignore_case))
120 {
121 ids.add(id);
122 }
123 }
124 return ids;
125 }
126 protected slots:
127
129 {
130
131 }
132 protected:
137
138 };
139}
140
#define NDEVR_API
Definition DLLInfo.h:67
#define _tqa(var)
Definition QTTools.h:192
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
void add(t_type &&object)
Definition Buffer.hpp:199
constexpr t_index_type size() const
Definition Buffer.hpp:1461
Definition DesignObject.h:66
DesignProperty
Definition DesignObject.h:94
Definition DesignObjectLookup.h:61
Definition DesignObjectSearchWidget.h:43
Buffer< UUID > m_objects_to_search
Definition DesignObjectSearchWidget.h:135
DesignObject::DesignProperty m_property
Definition DesignObjectSearchWidget.h:133
void setDesignProperty(DesignObject::DesignProperty property)
Definition DesignObjectSearchWidget.h:77
void setManager(DesignObjectLookup *lookup)
Definition DesignObjectSearchWidget.h:60
bool m_ignore_case
Definition DesignObjectSearchWidget.h:136
DesignObjectLookup * m_manager
Definition DesignObjectSearchWidget.h:134
Buffer< UUID > getObjectsContainingSearch() const
Definition DesignObjectSearchWidget.h:91
void setSearchIDs(DesignObject::DesignProperty property, const Buffer< UUID > &objects)
Definition DesignObjectSearchWidget.h:64
DesignObjectSearchWidget(QWidget *parent=nullptr)
Definition DesignObjectSearchWidget.h:46
void setSearchIDs()
Definition DesignObjectSearchWidget.h:56
Buffer< UUID > getObjectsBeginningWithSearch() const
Definition DesignObjectSearchWidget.h:109
void onObjectUpdatedSlot()
Definition DesignObjectSearchWidget.h:128
void setSearchIDs(const Buffer< UUID > &objects)
Definition DesignObjectSearchWidget.h:70
Definition QCustomLineEdit.h:118
Definition String.h:40
Definition UUID.h:66
Definition ACIColor.h:37