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{
42 /**--------------------------------------------------------------------------------------------------
43 \brief Allows the user to enter search terms for filtering out tables or other views.
44 **/
46 {
47 Q_OBJECT
48 public:
49 DesignObjectSearchWidget(QWidget* parent = nullptr)
50 : QCustomLineEdit(parent)
51 , m_property(DesignObject::e_design_property_size)
52 , m_manager(nullptr)
53 , m_ignore_case(false)
54 {
55 setPlaceholderText(_tqa("Search"));
56 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
57 customValidator().setAllowEmpty(true);
58 }
60 {
61 setSearchIDs(Buffer<UUID>());
62 }
64 {
65 m_manager = lookup;
66 }
68 {
69 m_objects_to_search = objects;
70 m_property = property;
71 onObjectUpdatedSlot();
72 }
73 void setSearchIDs(const Buffer<UUID>& objects)
74 {
75 if (m_objects_to_search == objects)
76 return;
77 m_objects_to_search = objects;
78 onObjectUpdatedSlot();
79 }
81 {
82 m_property = property;
83 onObjectUpdatedSlot();
84 switch (property)
85 {
86 case DesignObject::DesignProperty::e_file:
87 customValidator().setRegex(RegexFunctions::FileRegex());
88 break;
89 default:
90 //customValidator().setRegex(/*"^[\\.a-zA-Z0-9_\\s-]+$"*/);
91 break;
92 }
93 }
95 {
96 String value = getValue();
97 if (value.size() == 0)
98 return m_objects_to_search;
99 Buffer<UUID> ids;
100 const DesignObject::DesignProperty property = m_property;
101 const bool ignore_case = m_ignore_case;
102 for(const UUID& id : m_objects_to_search)
103 {
104 if(m_manager->object(id).doesPropertyContain(property, value, ignore_case))
105 {
106 ids.add(id);
107 }
108 }
109 return ids;
110 }
111
113 {
114 String value = getValue();
115 if (value.size() == 0)
116 return m_objects_to_search;
117 Buffer<UUID> ids;
118 const DesignObject::DesignProperty property = m_property;
119 const bool ignore_case = m_ignore_case;
120 for (const UUID& id : m_objects_to_search)
121 {
122 if (m_manager->object(id).doesPropertyBeginWith(property, value, ignore_case))
123 {
124 ids.add(id);
125 }
126 }
127 return ids;
128 }
129 protected slots:
130
132 {
133
134 }
135 protected:
140
141 };
142}
143
#define NDEVR_API
Definition DLLInfo.h:50
#define _tqa(var)
Definition QTTools.h:177
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
void add(t_type &&object)
Adds object to the end of the buffer.
Definition Buffer.hpp:186
constexpr t_index_type size() const
Definition Buffer.hpp:823
A low-level database object that can be used to access general stored properties within the NDEVR Mod...
Definition DesignObject.h:67
DesignProperty
Values stored in the property database.
Definition DesignObject.h:93
A core class where all Design Objects including models, materials, and geometries are stored....
Definition DesignObjectLookup.h:65
Allows the user to enter search terms for filtering out tables or other views.
Definition DesignObjectSearchWidget.h:46
Buffer< UUID > m_objects_to_search
Definition DesignObjectSearchWidget.h:138
DesignObject::DesignProperty m_property
Definition DesignObjectSearchWidget.h:136
void setDesignProperty(DesignObject::DesignProperty property)
Definition DesignObjectSearchWidget.h:80
void setManager(DesignObjectLookup *lookup)
Definition DesignObjectSearchWidget.h:63
bool m_ignore_case
Definition DesignObjectSearchWidget.h:139
DesignObjectLookup * m_manager
Definition DesignObjectSearchWidget.h:137
Buffer< UUID > getObjectsContainingSearch() const
Definition DesignObjectSearchWidget.h:94
void setSearchIDs(DesignObject::DesignProperty property, const Buffer< UUID > &objects)
Definition DesignObjectSearchWidget.h:67
DesignObjectSearchWidget(QWidget *parent=nullptr)
Definition DesignObjectSearchWidget.h:49
void setSearchIDs()
Definition DesignObjectSearchWidget.h:59
Buffer< UUID > getObjectsBeginningWithSearch() const
Definition DesignObjectSearchWidget.h:112
void onObjectUpdatedSlot()
Definition DesignObjectSearchWidget.h:131
void setSearchIDs(const Buffer< UUID > &objects)
Definition DesignObjectSearchWidget.h:73
A line edit allows users to enter and edit a single line of plain text with useful editing functions,...
Definition QCustomLineEdit.h:56
The core String class for the NDEVR API.
Definition String.h:69
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:60
Definition ACIColor.h:37