API Documentation
Loading...
Searching...
No Matches
DesignObjectStringWidget.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 <NDEVR/QTDesignObject.h>
34#include <NDEVR/QCustomLineEdit.h>
35#include <NDEVR/RegexFunctions.h>
36namespace NDEVR
37{
39 {
40 Q_OBJECT
41 public:
42 DesignObjectStringWidget(QWidget* parent = nullptr)
43 : QCustomLineEdit(parent)
44 , m_property(DesignObject::e_design_property_size)
45 {
46 connect(this, &QCustomLineEdit::editingFinishedSignal, this, &DesignObjectStringWidget::sendCommand);
47 }
49 {
51 }
53 {
54 setTarget(object);
55 setDesignProperty(property);
56 }
58 {
59 if (m_target == object)
60 return;
61 if (!m_target.isNull())
62 {
63 disconnect(&m_target.get(), &QTDesignObject::updatedSignal, this, &DesignObjectStringWidget::onObjectUpdatedSlot);
64 disconnect(&m_target.get(), &QTDesignObject::deletedSignal, this, &DesignObjectStringWidget::onObjectDeletedSlot);
65 }
66 m_target = object;
67 if (!m_target.isNull())
68 {
69 connect(&m_target.get(), &QTDesignObject::updatedSignal, this, &DesignObjectStringWidget::onObjectUpdatedSlot);
70 connect(&m_target.get(), &QTDesignObject::deletedSignal, this, &DesignObjectStringWidget::onObjectDeletedSlot);
71 }
72 setEnabled(!m_target.isNull());
73 onObjectUpdatedSlot();
74 }
76 {
77 m_property = property;
78 if (m_title.translation().size() == 0)
79 {
80 if (property == DesignObject::DesignProperty::e_meta_data)
81 setWindowTitle(m_meta_data.formatTitleString().getAs<QString>());
82 else
83 setWindowTitle(String::DisplayString(property).translation().formatTitleString().getAs<QString>());
84 }
85 onObjectUpdatedSlot();
86 switch (property)
87 {
88 case DesignObject::DesignProperty::e_file:
89 customValidator().setRegex(RegexFunctions::FileRegex());
90 break;
91 default:
92 //customValidator().setRegex(/*"^[\\.a-zA-Z0-9_\\s-]+$"*/);
93 break;
94 }
95 }
96 void setupForMetadata(TranslatedString title, const String& metadata)
97 {
98 m_title = title;
99 m_meta_data = metadata;
100 setDesignProperty(DesignObject::DesignProperty::e_meta_data);
101 }
102 void setupForMetadata(const String& metadata)
103 {
104 m_meta_data = metadata;
105 setDesignProperty(DesignObject::DesignProperty::e_meta_data);
106 }
107 void setTitle(const TranslatedString& title) override
108 {
109 m_title = title;
110 if (m_title.translation().size() == 0)
111 {
112 if (m_property == DesignObject::DesignProperty::e_meta_data)
113 setWindowTitle(m_meta_data.formatTitleString().getAs<QString>());
114 else
115 setWindowTitle(String::DisplayString(m_property).translation().formatTitleString().getAs<QString>());
116 }
117 else
118 {
119 setWindowTitle(m_title.translation().getAs<QString>());
120 }
121 }
122 protected slots:
124 {
126 }
127 void sendCommand();
128 void onObjectUpdatedSlot();
129 protected:
133 };
134}
135
#define NDEVR_API
Definition DLLInfo.h:67
Definition DesignObject.h:66
DesignProperty
Definition DesignObject.h:94
Definition DesignObjectStringWidget.h:39
void setupForMetadata(TranslatedString title, const String &metadata)
Definition DesignObjectStringWidget.h:96
DesignObject::DesignProperty m_property
Definition DesignObjectStringWidget.h:130
DynamicPointer< QTDesignObject > m_target
Definition DesignObjectStringWidget.h:131
void setDesignProperty(DesignObject::DesignProperty property)
Definition DesignObjectStringWidget.h:75
void onObjectDeletedSlot()
Definition DesignObjectStringWidget.h:123
void setTitle(const TranslatedString &title) override
Definition DesignObjectStringWidget.h:107
void clearTarget()
Definition DesignObjectStringWidget.h:48
String m_meta_data
Definition DesignObjectStringWidget.h:132
DesignObjectStringWidget(QWidget *parent=nullptr)
Definition DesignObjectStringWidget.h:42
void setupForMetadata(const String &metadata)
Definition DesignObjectStringWidget.h:102
void setTarget(const DynamicPointer< QTDesignObject > &object)
Definition DesignObjectStringWidget.h:57
void setTarget(DesignObject::DesignProperty property, const DynamicPointer< QTDesignObject > &object)
Definition DesignObjectStringWidget.h:52
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:319
Definition QCustomLineEdit.h:118
The core String class for the software.
Definition String.h:47
Any text displayed to the user should be defined as a TranslatedString which allows the.
Definition TranslatedString.h:13
Definition ACIColor.h:37