NDEVR
API Documentation
DesignObjectSearchWidget.h
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{
46 {
47 Q_OBJECT
48 public:
53 DesignObjectSearchWidget(QWidget* parent = nullptr)
54 : QCustomLineEdit(parent)
56 , m_manager(nullptr)
57 , m_ignore_case(false)
58 {
59 setPlaceholderText(_tqa("Search"));
60 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
61 customValidator().setAllowEmpty(true);
62 }
63
67 {
69 }
70
75 {
76 m_manager = lookup;
77 }
78
83 void setSearchIDs(NDPO property, const Buffer<UUID>& objects)
84 {
85 m_objects_to_search = objects;
86 m_property = property;
88 }
89
93 void setSearchIDs(const Buffer<UUID>& objects)
94 {
95 if (m_objects_to_search == objects)
96 return;
97 m_objects_to_search = objects;
99 }
100
104 void setNDPO(NDPO property)
105 {
106 m_property = property;
108 switch (property)
109 {
110 case NDPO::file:
112 break;
113 default:
114 //customValidator().setRegex(/*"^[\\.a-zA-Z0-9_\\s-]+$"*/);
115 break;
116 }
117 }
118
123 {
124 String value = getValue();
125 if (value.size() == 0)
126 return m_objects_to_search;
127 Buffer<UUID> ids;
128 const NDPO property = m_property;
129 const bool ignore_case = m_ignore_case;
130 for(const UUID& id : m_objects_to_search)
131 {
132 if(m_manager->object(id).doesPropertyContain(property, value, ignore_case))
133 {
134 ids.add(id);
135 }
136 }
137 return ids;
138 }
139
145 {
146 String value = getValue();
147 if (value.size() == 0)
148 return m_objects_to_search;
149 Buffer<UUID> ids;
150 const NDPO property = m_property;
151 const bool ignore_case = m_ignore_case;
152 for (const UUID& id : m_objects_to_search)
153 {
154 if (m_manager->object(id).doesPropertyBeginWith(property, value, ignore_case))
155 {
156 ids.add(id);
157 }
158 }
159 return ids;
160 }
161 protected slots:
166 {
167
168 }
169 protected:
174
175 };
176}
177
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
void add(t_type &&object)
Adds object to the end of the buffer.
Definition Buffer.hpp:190
A core class where all Design Objects including models, materials, and geometries are stored.
Buffer< UUID > getObjectsBeginningWithSearch() const
Returns the subset of objects whose search property begins with the current search text.
void setSearchIDs(NDPO property, const Buffer< UUID > &objects)
Sets both the property to search and the set of object UUIDs to search through.
DesignObjectSearchWidget(QWidget *parent=nullptr)
Constructs a DesignObjectSearchWidget with a search placeholder.
void setSearchIDs(const Buffer< UUID > &objects)
Sets the set of object UUIDs to search through.
void setNDPO(NDPO property)
Sets the design object property used for filtering and configures validation accordingly.
void onObjectUpdatedSlot()
Slot called when the underlying objects are updated.
DesignObjectLookup * m_manager
The lookup used to resolve object properties.
Buffer< UUID > getObjectsContainingSearch() const
Returns the subset of objects whose search property contains the current search text.
Buffer< UUID > m_objects_to_search
The set of object UUIDs being searched.
void setManager(DesignObjectLookup *lookup)
Sets the design object lookup used to resolve object properties.
void setSearchIDs()
Clears the search IDs by setting an empty buffer.
bool m_ignore_case
Whether the search is case-insensitive.
NDPO m_property
The design object property to search against.
void setPlaceholderText(const QString &value)
Sets the placeholder text displayed when the field is empty.
String getValue(bool allow_placeholder) const
Returns the current text value of the line edit.
QCustomValidator & customValidator()
Returns a mutable reference to the custom validator used for input validation.
QCustomLineEdit(QWidget *parent=Q_NULLPTR)
Constructs a QCustomLineEdit with the given parent widget.
static const char * FileRegex()
Gets a regex pattern for validating file paths.
The core String class for the NDEVR API.
Definition String.h:95
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
The primary namespace for the NDEVR SDK.
NDPO
NDPO - NDEVR Design Property Object: Values stored in the property database.
@ property_size
Sentinel value representing the total number of properties (always last).
@ file
The source file path associated with this object.