3#include "../../global.hpp"
4#include "../../genapi/value_node.hpp"
5#include "../../genapi/integer_node.hpp"
6#include "detail_property.hpp"
7#include "detail_spinbox_slider.hpp"
8#include "detail_custom_lineedit.hpp"
9#include "detail_network.hpp"
21 class IntegerProperty :
public Private::Property
27 IntegerProperty(
const ValueNodePtr &node, Property *parent)
28 : Property(node, PT_Integer, parent)
31 ipList_ <<
"Std::GevCurrentIPAddress" <<
"Std::GevCurrentSubnetMask" <<
"Std::GevCurrentDefaultGateway"
32 <<
"Std::GevPersistentIPAddress" <<
"Std::GevPersistentSubnetMask"
33 <<
"Std::GevPersistentDefaultGateway" <<
"Std::GevMCDA" <<
"Std::GevSCDA"
34 <<
"Std::GevPrimaryApplicationIPAddress";
36 ipList_ <<
"Cust::InterfaceSubnetIP" <<
"Cust::InterfaceSubnetMask" <<
"Cust::InterfaceGateway"
37 <<
"Cust::IPCfg_IP" <<
"Cust::IPCfg_Subnet" <<
"Cust::IPCfg_Gateway"
38 <<
"Cust::DeviceIP" <<
"Cust::DeviceGateway" <<
"Cust::StreamDestinationIP";
41 macList_ <<
"Std::GevMACAddress";
43 macList_ <<
"Cust::GevInterfaceMACAddress" <<
"Cust::InterfaceMAC" <<
"Cust::IPCfg_MAC" <<
"Cust::DeviceMAC";
46 QWidget *CreateEditor(QWidget *parent)
override
48 auto intNode = std::dynamic_pointer_cast<IntegerNode>(Node());
53 if (!intNode->IsAvailable())
56 auto rep = intNode->Representation();
58 return CreateIpEditor(intNode, parent);
60 return CreateMacEditor(intNode, parent);
61 return CreateIntEditor(intNode, parent);
64 QWidget *CreateIntEditor(
const IntegerNodePtr &node, QWidget *parent)
67 if (node->Min() == node->Max())
69 auto editor =
new SpinBox64(parent);
70 editor->setMinimum(node->Min());
71 editor->setMaximum(node->Max());
72 editor->setValue(node->Value());
73 editor->setSingleStep(node->Increment());
75 QObject::connect(editor, &SpinBox64::ValueChanged,
this, [=](qint64 value) { SetValue(QVariant(value)); });
80 auto editor =
new SpinBoxSlider64(parent);
81 editor->SetMinimum(node->Min());
82 editor->SetMaximum(node->Max());
83 editor->SetValue(node->Value());
84 editor->SetSingleStep(node->Increment());
86 QObject::connect(editor, &SpinBoxSlider64::ValueChanged,
this,
87 [=](qint64 value) { SetValue(QVariant(value)); });
92 QWidget *CreateIpEditor(
const IntegerNodePtr &node, QWidget *parent)
94 auto editor =
new IpLineEdit(parent);
95 IpAddress ip(node->Value());
96 editor->SetText(ip.ToQString());
98 QObject::connect(editor, &IpLineEdit::TextChanged,
this,
99 [=](
const QString &text) { SetValue(QVariant(text)); });
104 QWidget *CreateMacEditor(
const IntegerNodePtr &node, QWidget *parent)
106 auto editor =
new MacLineEdit(parent);
107 MacAddress mac(node->Value());
108 editor->SetText(mac.ToQString());
110 QObject::connect(editor, &MacLineEdit::TextChanged,
this,
111 [=](
const QString &text) { SetValue(QVariant(text)); });
116 bool SetEditorData(QWidget *editor,
const QVariant &data)
override
118 auto intNode = std::dynamic_pointer_cast<IntegerNode>(Node());
123 auto rep = intNode->Representation();
126 auto le =
dynamic_cast<IpLineEdit *
>(editor);
129 le->SetText(data.toString());
135 auto le =
dynamic_cast<MacLineEdit *
>(editor);
138 le->SetText(data.toString());
144 auto sb =
dynamic_cast<SpinBoxSlider64 *
>(editor);
147 sb->SetValue(data.toInt());
154 QVariant EditorData(QWidget *editor)
override
156 auto intNode = std::dynamic_pointer_cast<IntegerNode>(Node());
158 auto rep = intNode->Representation();
161 auto le =
dynamic_cast<IpLineEdit *
>(editor);
163 return QVariant(le->Text());
167 auto le =
dynamic_cast<MacLineEdit *
>(editor);
169 return QVariant(le->Text());
173 auto sb =
dynamic_cast<SpinBoxSlider64 *
>(editor);
175 return QVariant(sb->Value());
181 QVariant Value(
int column,
int role = Qt::UserRole)
override
185 case Qt::DisplayRole:
188 return Data(column, role);
190 auto intNode = std::dynamic_pointer_cast<IntegerNode>(Node());
191 if (intNode && intNode->IsAvailable())
193 int64_t intValue = -1;
196 intValue = intNode->Value();
198 catch (
const CvbException &e)
202 return QVariant(
"-");
205 auto rep = intNode->Representation();
208 IpAddress ip(intValue);
209 return ip.ToQString();
213 MacAddress mac(intValue);
214 return mac.ToQString();
218 return QVariant::fromValue(intValue);
226 void SetValue(
const QVariant &value)
override
228 if (
auto intNode = std::dynamic_pointer_cast<IntegerNode>(Node()))
230 auto rep = intNode->Representation();
233 if (value.type() == QVariant::String)
235 IpAddress ip(value.toString());
238 intNode->SetValue(ip.ToInt64());
240 catch (
const CvbException &)
248 if (value.type() == QVariant::String)
250 MacAddress mac(value.toString());
253 intNode->SetValue(mac.ToInt64());
255 catch (
const CvbException &)
263 if (value.type() == QVariant::LongLong)
267 intNode->SetValue(value.toLongLong());
269 catch (
const CvbException &)
278 QString HtmlDescription()
override
280 if (
auto intNode = std::dynamic_pointer_cast<IntegerNode>(Node()))
282 auto txt = QString(
"<br><table>");
283 auto min = QString(
"-");
284 auto max = QString(
"-");
285 auto rep = QString(
"-");
286 auto inc = QString(
"");
288 auto representation = intNode->Representation();
292 && macList_.contains(
UI::CvbToQt(intNode->Name())))
295 inc = QString::number(intNode->Increment());
296 min = QString::number(intNode->Min());
297 max = QString::number(intNode->Max());
299 txt.append(
"<tr><td><b>Minimum:</b></td><td align=\"right\">" + min +
"</td></tr>");
300 txt.append(
"<tr><td><b>Maximum:</b></td><td align=\"right\">" + max +
"</td></tr>");
302 txt.append(
"<tr><td><b>Increment:</b></td><td align=\"right\">" + inc +
"</td></tr>");
303 txt.append(
"<tr><td><b>Representation:</b></td><td align=\"right\">" + rep +
"</td></tr>");
304 txt.append(
"</table>");
312 QStringList macList_;
const int CVB_TIMEOUT
Timeout in function.
Definition exception.hpp:29
std::shared_ptr< IntegerNode > IntegerNodePtr
Convenience shared pointer for IntegerNode.
Definition genapi.hpp:63
std::shared_ptr< ValueNode > ValueNodePtr
Convenience shared pointer for ValueNode.
Definition genapi.hpp:91
@ MAC
MAC address in an edit control.
Definition genapi.hpp:159
@ IPv4
IPv4 address in an edit control.
Definition genapi.hpp:157
Namespace for user interface components.
Definition decl_image_scene.hpp:39
QString CvbToQt(const Cvb::String &text) noexcept
Convenience converter for strings.
Definition ui.hpp:257
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17