PIValueTreeEdit File and Dir support
This commit is contained in:
@@ -37,14 +37,14 @@ PIValueTreeEdit::~PIValueTreeEdit() {
|
|||||||
|
|
||||||
|
|
||||||
void PIValueTreeEdit::setValue(const PIValueTree & v) {
|
void PIValueTreeEdit::setValue(const PIValueTree & v) {
|
||||||
source = v;
|
current = source = v;
|
||||||
build();
|
build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIValueTree PIValueTreeEdit::value() const {
|
PIValueTree PIValueTreeEdit::value() const {
|
||||||
applyValues();
|
applyValues();
|
||||||
return source;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -61,19 +61,36 @@ void PIValueTreeEdit::setFullEditMode(bool yes) {
|
|||||||
|
|
||||||
|
|
||||||
void PIValueTreeEdit::rollback() {
|
void PIValueTreeEdit::rollback() {
|
||||||
|
current = source;
|
||||||
build();
|
build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIValueTreeEdit::clear() {
|
void PIValueTreeEdit::clear() {
|
||||||
source = PIValueTree();
|
current = PIValueTree();
|
||||||
removeAll();
|
removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIValueTreeEdit::retranslate() {
|
||||||
|
for (const auto & i: value_edits)
|
||||||
|
i.second->retranslate();
|
||||||
|
for (const auto & i: tree_edits)
|
||||||
|
i.second->retranslate();
|
||||||
|
for (const auto & i: comm_labels) {
|
||||||
|
i.second->setText(PIVariantEditorBase::vtTr(current.child(i.first).comment()));
|
||||||
|
}
|
||||||
|
for (const auto & i: label_labels) {
|
||||||
|
i.second->setText(PIVariantEditorBase::vtTr(i.first));
|
||||||
|
}
|
||||||
|
grid->retranslate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIValueTreeEdit::changeEvent(QEvent * e) {
|
void PIValueTreeEdit::changeEvent(QEvent * e) {
|
||||||
if (e->type() == QEvent::LanguageChange) {
|
if (e->type() == QEvent::LanguageChange) {
|
||||||
if (widget_array) ui_array->retranslateUi(widget_array);
|
if (widget_array) ui_array->retranslateUi(widget_array);
|
||||||
|
retranslate();
|
||||||
}
|
}
|
||||||
QWidget::changeEvent(e);
|
QWidget::changeEvent(e);
|
||||||
}
|
}
|
||||||
@@ -104,18 +121,18 @@ void PIValueTreeEdit::build() {
|
|||||||
grid->create_edit_buttons = false;
|
grid->create_edit_buttons = false;
|
||||||
removeAll();
|
removeAll();
|
||||||
// piCout << source.attributes().value(Attribute::arrayType) << array_type;
|
// piCout << source.attributes().value(Attribute::arrayType) << array_type;
|
||||||
if (source.isArray()) {
|
if (current.isArray()) {
|
||||||
widget_array = new QWidget();
|
widget_array = new QWidget();
|
||||||
ui_array->setupUi(widget_array);
|
ui_array->setupUi(widget_array);
|
||||||
applyArrayAttributes();
|
applyArrayAttributes();
|
||||||
ui_array->layoutArray->addWidget(grid);
|
ui_array->layoutArray->addWidget(grid);
|
||||||
grid->button_add->hide();
|
grid->button_add->hide();
|
||||||
grid->show();
|
grid->show();
|
||||||
uint array_type = PIVariant::typeIDFromName(source.attribute(Attribute::arrayType).toString());
|
uint array_type = PIVariant::typeIDFromName(current.attribute(Attribute::arrayType).toString());
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (const auto & i: source.children()) {
|
for (const auto & i: current.children()) {
|
||||||
auto * ve = new PIVariantEdit();
|
auto * ve = new PIVariantEdit();
|
||||||
ve->setAttributes(source.attributes());
|
ve->setAttributes(current.attributes());
|
||||||
ve->setValue(i.value(), array_type);
|
ve->setValue(i.value(), array_type);
|
||||||
grid->add(PIValueTree(), PIString::fromNumber(++index), ve, i.comment());
|
grid->add(PIValueTree(), PIString::fromNumber(++index), ve, i.comment());
|
||||||
array_edits << ve;
|
array_edits << ve;
|
||||||
@@ -127,7 +144,7 @@ void PIValueTreeEdit::build() {
|
|||||||
array_edits.resize(grid->rowCount());
|
array_edits.resize(grid->rowCount());
|
||||||
for (int i = grid->rowCount(); i < value; ++i) {
|
for (int i = grid->rowCount(); i < value; ++i) {
|
||||||
auto * ve = new PIVariantEdit();
|
auto * ve = new PIVariantEdit();
|
||||||
ve->setAttributes(source.attributes());
|
ve->setAttributes(current.attributes());
|
||||||
ve->setValue(PIVariant::fromType(array_type), array_type);
|
ve->setValue(PIVariant::fromType(array_type), array_type);
|
||||||
grid->add(PIValueTree(), PIString::fromNumber(i + 1), ve, "");
|
grid->add(PIValueTree(), PIString::fromNumber(i + 1), ve, "");
|
||||||
array_edits << ve;
|
array_edits << ve;
|
||||||
@@ -137,9 +154,9 @@ void PIValueTreeEdit::build() {
|
|||||||
} else {
|
} else {
|
||||||
grid->create_edit_buttons = is_full_edit;
|
grid->create_edit_buttons = is_full_edit;
|
||||||
layout()->addWidget(grid);
|
layout()->addWidget(grid);
|
||||||
if (!source.hasChildren()) grid->clear();
|
if (!current.hasChildren()) grid->clear();
|
||||||
for (const auto & i: source.children()) {
|
for (const auto & i: current.children()) {
|
||||||
if (i.attribute(Attribute::hidden, false).toBool()) continue;
|
if (i.attribute(Attribute::hidden, false).toBool() && !is_full_edit) continue;
|
||||||
if (i.attribute(Attribute::isLabel, false).toBool()) {
|
if (i.attribute(Attribute::isLabel, false).toBool()) {
|
||||||
if (i.name().isEmpty()) continue;
|
if (i.name().isEmpty()) continue;
|
||||||
auto * l = newLabel(i);
|
auto * l = newLabel(i);
|
||||||
@@ -157,21 +174,21 @@ void PIValueTreeEdit::build() {
|
|||||||
|
|
||||||
|
|
||||||
void PIValueTreeEdit::applyValues() const {
|
void PIValueTreeEdit::applyValues() const {
|
||||||
if (source.isArray()) {
|
if (current.isArray()) {
|
||||||
if (array_edits.isNotEmpty()) source.mergeAttributes(array_edits[0]->attributes());
|
if (array_edits.isNotEmpty()) current.mergeAttributes(array_edits[0]->attributes());
|
||||||
source.clearChildren();
|
current.clearChildren();
|
||||||
for (int i = 0; i < array_edits.size_s(); ++i)
|
for (int i = 0; i < array_edits.size_s(); ++i)
|
||||||
source.addChild({PIString::fromNumber(i), array_edits[i]->value()});
|
current.addChild({PIString::fromNumber(i), array_edits[i]->value()});
|
||||||
} else {
|
} else {
|
||||||
auto vit = value_edits.makeIterator();
|
auto vit = value_edits.makeIterator();
|
||||||
while (vit.next()) {
|
while (vit.next()) {
|
||||||
auto & c(source.child(vit.key()));
|
auto & c(current.child(vit.key()));
|
||||||
c.mergeAttributes(vit.value()->attributes());
|
c.mergeAttributes(vit.value()->attributes());
|
||||||
c.setValue(vit.value()->value());
|
c.setValue(vit.value()->value());
|
||||||
}
|
}
|
||||||
auto tit = tree_edits.makeIterator();
|
auto tit = tree_edits.makeIterator();
|
||||||
while (tit.next()) {
|
while (tit.next()) {
|
||||||
auto & c(source.child(tit.key()));
|
auto & c(current.child(tit.key()));
|
||||||
if (!c.isNull()) c = tit.value()->value();
|
if (!c.isNull()) c = tit.value()->value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,13 +199,13 @@ void PIValueTreeEdit::actionTriggered(QToolButton * button, const PIString & vn,
|
|||||||
if (a == widget_params->actionRename) {
|
if (a == widget_params->actionRename) {
|
||||||
PIString nn = Q2PIString(QInputDialog::getText(nullptr, tr("Rename"), tr("Input new name:"), QLineEdit::Normal, PI2QString(vn)));
|
PIString nn = Q2PIString(QInputDialog::getText(nullptr, tr("Rename"), tr("Input new name:"), QLineEdit::Normal, PI2QString(vn)));
|
||||||
if (nn.isEmpty() || (nn == vn)) return;
|
if (nn.isEmpty() || (nn == vn)) return;
|
||||||
for (const auto & c: source.children()) {
|
for (const auto & c: current.children()) {
|
||||||
if (c.name() == nn) {
|
if (c.name() == nn) {
|
||||||
QMessageBox::critical(nullptr, tr("Rename"), tr("This name already exists!"));
|
QMessageBox::critical(nullptr, tr("Rename"), tr("This name already exists!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
source[vn].setName(nn);
|
current[vn].setName(nn);
|
||||||
button->setProperty(property_name, PI2QString(nn));
|
button->setProperty(property_name, PI2QString(nn));
|
||||||
grid->rename(vn, nn);
|
grid->rename(vn, nn);
|
||||||
if (value_edits.contains(vn)) {
|
if (value_edits.contains(vn)) {
|
||||||
@@ -210,7 +227,7 @@ void PIValueTreeEdit::actionTriggered(QToolButton * button, const PIString & vn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (a == widget_params->actionRemove) {
|
if (a == widget_params->actionRemove) {
|
||||||
source.remove(vn);
|
current.remove(vn);
|
||||||
grid->removeRow(grid->getRow(button));
|
grid->removeRow(grid->getRow(button));
|
||||||
value_edits.remove(vn);
|
value_edits.remove(vn);
|
||||||
tree_edits.remove(vn);
|
tree_edits.remove(vn);
|
||||||
@@ -218,7 +235,7 @@ void PIValueTreeEdit::actionTriggered(QToolButton * button, const PIString & vn,
|
|||||||
label_labels.remove(vn);
|
label_labels.remove(vn);
|
||||||
}
|
}
|
||||||
if (a == widget_params->actionChange) {
|
if (a == widget_params->actionChange) {
|
||||||
auto & vt(source[vn]);
|
auto & vt(current[vn]);
|
||||||
if (vt.isArray()) {
|
if (vt.isArray()) {
|
||||||
auto * ve = tree_edits.value(vn, nullptr);
|
auto * ve = tree_edits.value(vn, nullptr);
|
||||||
if (!ve) return;
|
if (!ve) return;
|
||||||
@@ -229,7 +246,10 @@ void PIValueTreeEdit::actionTriggered(QToolButton * button, const PIString & vn,
|
|||||||
} else {
|
} else {
|
||||||
bool was_label = vt.attribute(Attribute::isLabel, false).toBool();
|
bool was_label = vt.attribute(Attribute::isLabel, false).toBool();
|
||||||
auto * ve = value_edits.value(vn, nullptr);
|
auto * ve = value_edits.value(vn, nullptr);
|
||||||
if (ve) vt.setValue(ve->value());
|
if (ve) {
|
||||||
|
vt.setValue(ve->value());
|
||||||
|
vt.mergeAttributes(ve->attributes());
|
||||||
|
}
|
||||||
if (!widget_params->showFor(vt)) return;
|
if (!widget_params->showFor(vt)) return;
|
||||||
bool now_label = vt.attribute(Attribute::isLabel, false).toBool();
|
bool now_label = vt.attribute(Attribute::isLabel, false).toBool();
|
||||||
if (was_label ^ now_label) {
|
if (was_label ^ now_label) {
|
||||||
@@ -257,14 +277,14 @@ void PIValueTreeEdit::actionTriggered(QToolButton * button, const PIString & vn,
|
|||||||
if (cl) cl->setText(PIVariantEditorBase::vtTr(vt.comment()));
|
if (cl) cl->setText(PIVariantEditorBase::vtTr(vt.comment()));
|
||||||
}
|
}
|
||||||
if (a == widget_params->actionReorder) {
|
if (a == widget_params->actionReorder) {
|
||||||
if (!widget_reorder->showFor(source)) return;
|
if (!widget_reorder->showFor(current)) return;
|
||||||
grid->reorder(widget_reorder->map);
|
grid->reorder(widget_reorder->map);
|
||||||
auto cl = source.children();
|
auto cl = current.children();
|
||||||
source.clearChildren();
|
current.clearChildren();
|
||||||
for (int i = 0; i < cl.size_s(); ++i) {
|
for (int i = 0; i < cl.size_s(); ++i) {
|
||||||
int mi = widget_reorder->map.value(i, i);
|
int mi = widget_reorder->map.value(i, i);
|
||||||
if (mi < 0 || mi >= cl.size_s()) continue;
|
if (mi < 0 || mi >= cl.size_s()) continue;
|
||||||
source.addChild(cl[mi]);
|
current.addChild(cl[mi]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -307,15 +327,15 @@ void PIValueTreeEdit::addValueEdit(const PIValueTree & vt) {
|
|||||||
|
|
||||||
|
|
||||||
void PIValueTreeEdit::applyArrayAttributes() {
|
void PIValueTreeEdit::applyArrayAttributes() {
|
||||||
ui_array->spinCount->setRange(source.attribute(Attribute::arrayMinCount, 0).toInt(),
|
ui_array->spinCount->setRange(current.attribute(Attribute::arrayMinCount, 0).toInt(),
|
||||||
source.attribute(Attribute::arrayMaxCount, 65536).toInt());
|
current.attribute(Attribute::arrayMaxCount, 65536).toInt());
|
||||||
ui_array->spinCount->setValue(source.children().size_s());
|
ui_array->spinCount->setValue(current.children().size_s());
|
||||||
ui_array->widgetEdit->setVisible(source.attribute(Attribute::arrayResize, false).toBool());
|
ui_array->widgetEdit->setVisible(current.attribute(Attribute::arrayResize, false).toBool());
|
||||||
uint array_type = PIVariant::typeIDFromName(source.attribute(Attribute::arrayType).toString());
|
uint array_type = PIVariant::typeIDFromName(current.attribute(Attribute::arrayType).toString());
|
||||||
for (int i = 0; i < array_edits.size_s(); ++i) {
|
for (int i = 0; i < array_edits.size_s(); ++i) {
|
||||||
auto * w = array_edits[i];
|
auto * w = array_edits[i];
|
||||||
w->setAttributes(source.attributes());
|
w->setAttributes(current.attributes());
|
||||||
w->setValue(i < source.children().size_s() ? source.children()[i].value() : PIVariant(), array_type);
|
w->setValue(i < current.children().size_s() ? current.children()[i].value() : PIVariant(), array_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,7 +360,7 @@ void PIValueTreeEdit::applyVariantEdit(PIVariantEdit * ve, const PIValueTree & v
|
|||||||
void PIValueTreeEdit::newRequest(NewType type) {
|
void PIValueTreeEdit::newRequest(NewType type) {
|
||||||
PIString nn = Q2PIString(QInputDialog::getText(nullptr, tr("New item"), tr("Input new name:")));
|
PIString nn = Q2PIString(QInputDialog::getText(nullptr, tr("New item"), tr("Input new name:")));
|
||||||
if (nn.isEmpty()) return;
|
if (nn.isEmpty()) return;
|
||||||
for (const auto & c: source.children()) {
|
for (const auto & c: current.children()) {
|
||||||
if (c.name() == nn) {
|
if (c.name() == nn) {
|
||||||
QMessageBox::critical(nullptr, tr("New item"), tr("This name already exists!"));
|
QMessageBox::critical(nullptr, tr("New item"), tr("This name already exists!"));
|
||||||
return;
|
return;
|
||||||
@@ -355,7 +375,7 @@ void PIValueTreeEdit::newRequest(NewType type) {
|
|||||||
vt.setAttribute(Attribute::arrayType, PIVariant::typeName<PIString>());
|
vt.setAttribute(Attribute::arrayType, PIVariant::typeName<PIString>());
|
||||||
if (!widget_params->showFor(vt)) return;
|
if (!widget_params->showFor(vt)) return;
|
||||||
}
|
}
|
||||||
source.addChild(vt);
|
current.addChild(vt);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NewType::Value: addValueEdit(vt); break;
|
case NewType::Value: addValueEdit(vt); break;
|
||||||
case NewType::Group: addTreeEdit(vt); break;
|
case NewType::Group: addTreeEdit(vt); break;
|
||||||
@@ -501,7 +521,7 @@ void PIValueTreeEdit::GridWidgets::rename(const PIString & prev_name, const PISt
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
for (auto * l: labels)
|
for (auto * l: labels)
|
||||||
if (l->property(property_name).toString() == PI2QString(prev_name)) {
|
if (l->property(property_name).toString() == PI2QString(prev_name)) {
|
||||||
l->setProperty(property_name, PI2QString(new_name));
|
l->setProperty(property_name, PI2QString(new_name));
|
||||||
@@ -511,7 +531,6 @@ void PIValueTreeEdit::GridWidgets::rename(const PIString & prev_name, const PISt
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PIValueTreeEdit::GridWidgets::clear() {
|
void PIValueTreeEdit::GridWidgets::clear() {
|
||||||
@@ -534,6 +553,22 @@ void PIValueTreeEdit::GridWidgets::changed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIValueTreeEdit::GridWidgets::retranslate() {
|
||||||
|
if (parent->is_grouping) {
|
||||||
|
for (auto * w: widgets) {
|
||||||
|
auto * gb = qobject_cast<QGroupBox *>(w);
|
||||||
|
if (!gb) continue;
|
||||||
|
gb->setTitle(PIVariantEditorBase::vtTr(Q2PIString(gb->property(property_name).toString())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto * l: labels) {
|
||||||
|
QString nn = PIVariantEditorBase::vtTr(Q2PIString(l->property(property_name).toString()));
|
||||||
|
if (!nn.isEmpty()) nn += ':';
|
||||||
|
l->setText(nn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int PIValueTreeEdit::GridWidgets::removeRowEdits(int row) {
|
int PIValueTreeEdit::GridWidgets::removeRowEdits(int row) {
|
||||||
int col = create_edit_buttons ? 1 : 0;
|
int col = create_edit_buttons ? 1 : 0;
|
||||||
for (int c = col; c < lay->columnCount(); ++c) {
|
for (int c = col; c < lay->columnCount(); ++c) {
|
||||||
@@ -576,8 +611,8 @@ void PIValueTreeEdit::GridWidgets::removeRow(int index) {
|
|||||||
void PIValueTreeEdit::GridWidgets::simplify(const PIMap<int, int> & map) {
|
void PIValueTreeEdit::GridWidgets::simplify(const PIMap<int, int> & map) {
|
||||||
struct Info {
|
struct Info {
|
||||||
Qt::Alignment align;
|
Qt::Alignment align;
|
||||||
int row_span = 1;
|
int row_span = 0;
|
||||||
int col_span = 1;
|
int col_span = 0;
|
||||||
};
|
};
|
||||||
if (!lay) return;
|
if (!lay) return;
|
||||||
QVector<QMap<int, QWidget *>> wg;
|
QVector<QMap<int, QWidget *>> wg;
|
||||||
@@ -596,6 +631,7 @@ void PIValueTreeEdit::GridWidgets::simplify(const PIMap<int, int> & map) {
|
|||||||
info.row_span = pos[2];
|
info.row_span = pos[2];
|
||||||
info.col_span = pos[3];
|
info.col_span = pos[3];
|
||||||
wa[li->widget()] = info;
|
wa[li->widget()] = info;
|
||||||
|
c += (pos[3] - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!row.isEmpty()) wg << row;
|
if (!row.isEmpty()) wg << row;
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ public:
|
|||||||
|
|
||||||
void rollback();
|
void rollback();
|
||||||
void clear();
|
void clear();
|
||||||
|
void retranslate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class NewType {
|
enum class NewType {
|
||||||
@@ -95,6 +96,7 @@ private:
|
|||||||
void reorder(const PIMap<int, int> & map) { simplify(map); }
|
void reorder(const PIMap<int, int> & map) { simplify(map); }
|
||||||
void clear();
|
void clear();
|
||||||
void changed();
|
void changed();
|
||||||
|
void retranslate();
|
||||||
|
|
||||||
bool create_edit_buttons = false;
|
bool create_edit_buttons = false;
|
||||||
QToolButton * button_add;
|
QToolButton * button_add;
|
||||||
@@ -122,7 +124,7 @@ private:
|
|||||||
PIMap<PIString, QLabel *> comm_labels, label_labels;
|
PIMap<PIString, QLabel *> comm_labels, label_labels;
|
||||||
Ui::PIValueTreeEditArray * ui_array;
|
Ui::PIValueTreeEditArray * ui_array;
|
||||||
GridWidgets * grid = nullptr;
|
GridWidgets * grid = nullptr;
|
||||||
mutable PIValueTree source;
|
mutable PIValueTree source, current;
|
||||||
bool is_grouping = true, is_full_edit = false;
|
bool is_grouping = true, is_full_edit = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -118,3 +118,9 @@ void PIVariantEdit::setFullEditMode(bool on) {
|
|||||||
if (!editor) return;
|
if (!editor) return;
|
||||||
editor->setFullEditMode(on);
|
editor->setFullEditMode(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIVariantEdit::retranslate() {
|
||||||
|
if (!editor) return;
|
||||||
|
editor->retranslate();
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "qad_piqt_utils_export.h"
|
#include "qad_piqt_utils_export.h"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
|
#include <QDebug>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@@ -48,6 +49,8 @@ public:
|
|||||||
virtual PIVariantMap attributes() const { return PIVariantMap(); }
|
virtual PIVariantMap attributes() const { return PIVariantMap(); }
|
||||||
static PIVariantMap defaultAttributes() { return PIVariantMap(); }
|
static PIVariantMap defaultAttributes() { return PIVariantMap(); }
|
||||||
|
|
||||||
|
virtual void retranslate() {}
|
||||||
|
|
||||||
static QString vtTr(const PIString & txt);
|
static QString vtTr(const PIString & txt);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -58,6 +61,7 @@ public:
|
|||||||
}
|
}
|
||||||
factories()[type_id] = []() -> PIVariantEditorBase * { return new T(); };
|
factories()[type_id] = []() -> PIVariantEditorBase * { return new T(); };
|
||||||
default_attributes()[type_id] = T::defaultAttributes();
|
default_attributes()[type_id] = T::defaultAttributes();
|
||||||
|
// qDebug() << "register" << T::staticMetaObject.className() << type_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PIVariantEditorBase * createEditor(uint type_id);
|
static PIVariantEditorBase * createEditor(uint type_id);
|
||||||
@@ -69,7 +73,6 @@ protected:
|
|||||||
virtual void setFullEditMode(bool on) {}
|
virtual void setFullEditMode(bool on) {}
|
||||||
|
|
||||||
virtual void applyAttributes(const PIVariantMap & a) {}
|
virtual void applyAttributes(const PIVariantMap & a) {}
|
||||||
virtual void retranslate() {}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void changeEvent(QEvent * e) override;
|
void changeEvent(QEvent * e) override;
|
||||||
@@ -93,6 +96,7 @@ public:
|
|||||||
PIVariantMap attributes() const;
|
PIVariantMap attributes() const;
|
||||||
|
|
||||||
void setFullEditMode(bool on);
|
void setFullEditMode(bool on);
|
||||||
|
void retranslate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PIVariantEditorBase * editor = nullptr;
|
PIVariantEditorBase * editor = nullptr;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include "pivarianttypes.h"
|
#include "pivarianttypes.h"
|
||||||
|
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QInputDialog>>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
@@ -21,6 +23,9 @@ REGISTER_PIVARIANTEDITOR(PIDate, PIVariantEditors::Date);
|
|||||||
REGISTER_PIVARIANTEDITOR(PIDateTime, PIVariantEditors::DateTime);
|
REGISTER_PIVARIANTEDITOR(PIDateTime, PIVariantEditors::DateTime);
|
||||||
REGISTER_PIVARIANTEDITOR(PIVariantTypes::Color, PIVariantEditors::Color);
|
REGISTER_PIVARIANTEDITOR(PIVariantTypes::Color, PIVariantEditors::Color);
|
||||||
REGISTER_PIVARIANTEDITOR(PIVariantTypes::Enum, PIVariantEditors::Enum);
|
REGISTER_PIVARIANTEDITOR(PIVariantTypes::Enum, PIVariantEditors::Enum);
|
||||||
|
REGISTER_PIVARIANTEDITOR(PINetworkAddress, PIVariantEditors::NetworkAddress);
|
||||||
|
REGISTER_PIVARIANTEDITOR(PIVariantTypes::File, PIVariantEditors::File);
|
||||||
|
REGISTER_PIVARIANTEDITOR(PIVariantTypes::Dir, PIVariantEditors::Dir);
|
||||||
|
|
||||||
using Attribute = PIValueTree::Attribute;
|
using Attribute = PIValueTree::Attribute;
|
||||||
|
|
||||||
@@ -48,14 +53,19 @@ PIVariantMap PIVariantEditors::Int::defaultAttributes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIVariantEditors::Int::retranslate() {
|
||||||
|
widget->setPrefix(PIVariantEditorBase::vtTr(prefix));
|
||||||
|
widget->setSuffix(PIVariantEditorBase::vtTr(suffix));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIVariantEditors::Int::applyAttributes(const PIVariantMap & a) {
|
void PIVariantEditors::Int::applyAttributes(const PIVariantMap & a) {
|
||||||
prefix = a.value(Attribute::prefix).toString();
|
prefix = a.value(Attribute::prefix).toString();
|
||||||
suffix = a.value(Attribute::suffix).toString();
|
suffix = a.value(Attribute::suffix).toString();
|
||||||
widget->setPrefix(PIVariantEditorBase::vtTr(prefix));
|
|
||||||
widget->setSuffix(PIVariantEditorBase::vtTr(suffix));
|
|
||||||
widget->setRange(a.value(Attribute::minimum, widget->minimum()).toInt(), a.value(Attribute::maximum, widget->maximum()).toInt());
|
widget->setRange(a.value(Attribute::minimum, widget->minimum()).toInt(), a.value(Attribute::maximum, widget->maximum()).toInt());
|
||||||
widget->setSingleStep(a.value(Attribute::singleStep, widget->singleStep()).toInt());
|
widget->setSingleStep(a.value(Attribute::singleStep, widget->singleStep()).toInt());
|
||||||
widget->setReadOnly(a.value(Attribute::readOnly, widget->isReadOnly()).toBool());
|
widget->setReadOnly(a.value(Attribute::readOnly, widget->isReadOnly()).toBool());
|
||||||
|
retranslate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -85,15 +95,20 @@ PIVariantMap PIVariantEditors::Double::defaultAttributes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIVariantEditors::Double::retranslate() {
|
||||||
|
widget->setPrefix(PIVariantEditorBase::vtTr(prefix));
|
||||||
|
widget->setSuffix(PIVariantEditorBase::vtTr(suffix));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIVariantEditors::Double::applyAttributes(const PIVariantMap & a) {
|
void PIVariantEditors::Double::applyAttributes(const PIVariantMap & a) {
|
||||||
prefix = a.value(Attribute::prefix).toString();
|
prefix = a.value(Attribute::prefix).toString();
|
||||||
suffix = a.value(Attribute::suffix).toString();
|
suffix = a.value(Attribute::suffix).toString();
|
||||||
widget->setPrefix(PIVariantEditorBase::vtTr(prefix));
|
|
||||||
widget->setSuffix(PIVariantEditorBase::vtTr(suffix));
|
|
||||||
widget->setRange(a.value(Attribute::minimum, widget->minimum()).toDouble(), a.value(Attribute::maximum, widget->maximum()).toDouble());
|
widget->setRange(a.value(Attribute::minimum, widget->minimum()).toDouble(), a.value(Attribute::maximum, widget->maximum()).toDouble());
|
||||||
widget->setSingleStep(a.value(Attribute::singleStep, widget->singleStep()).toDouble());
|
widget->setSingleStep(a.value(Attribute::singleStep, widget->singleStep()).toDouble());
|
||||||
widget->setDecimals(a.value(Attribute::decimals, widget->decimals()).toInt());
|
widget->setDecimals(a.value(Attribute::decimals, widget->decimals()).toInt());
|
||||||
widget->setReadOnly(a.value(Attribute::readOnly, widget->isReadOnly()).toBool());
|
widget->setReadOnly(a.value(Attribute::readOnly, widget->isReadOnly()).toBool());
|
||||||
|
retranslate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -166,10 +181,7 @@ PIVariantEditors::Enum::Enum() {
|
|||||||
edit_widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
edit_widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
edit_widget->setLayout(new QBoxLayout(QBoxLayout::LeftToRight));
|
edit_widget->setLayout(new QBoxLayout(QBoxLayout::LeftToRight));
|
||||||
QMargins m = edit_widget->layout()->contentsMargins();
|
QMargins m = edit_widget->layout()->contentsMargins();
|
||||||
m.setTop(0);
|
edit_widget->layout()->setContentsMargins(m.left(), 0, 0, 0);
|
||||||
m.setBottom(0);
|
|
||||||
m.setRight(0);
|
|
||||||
edit_widget->layout()->setContentsMargins(m);
|
|
||||||
auto * b = new QToolButton();
|
auto * b = new QToolButton();
|
||||||
b->setIcon(QIcon(":/icons/document-edit.png"));
|
b->setIcon(QIcon(":/icons/document-edit.png"));
|
||||||
connect(b, &QToolButton::clicked, this, [this]() {
|
connect(b, &QToolButton::clicked, this, [this]() {
|
||||||
@@ -209,3 +221,174 @@ void PIVariantEditors::Enum::applyAttributes(const PIVariantMap & a) {
|
|||||||
void PIVariantEditors::Enum::setFullEditMode(bool on) {
|
void PIVariantEditors::Enum::setFullEditMode(bool on) {
|
||||||
edit_widget->setVisible(on);
|
edit_widget->setVisible(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// PIVariantEditors::NetworkAddress
|
||||||
|
|
||||||
|
PIVariantEditors::NetworkAddress::NetworkAddress() {
|
||||||
|
widget = new QLineEdit();
|
||||||
|
widget->setInputMask("000.000.000.000:00000;_");
|
||||||
|
layout()->addWidget(widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIVariantEditors::NetworkAddress::setValue(const PIVariant & v) {
|
||||||
|
if (has_port)
|
||||||
|
widget->setText(PI2QString(v.toNetworkAddress().toString()));
|
||||||
|
else
|
||||||
|
widget->setText(PI2QString(v.toNetworkAddress().ipString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIVariant PIVariantEditors::NetworkAddress::value() const {
|
||||||
|
return PINetworkAddress(Q2PIString(widget->text()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIVariantMap PIVariantEditors::NetworkAddress::attributes() const {
|
||||||
|
return {
|
||||||
|
{"port", has_port}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIVariantMap PIVariantEditors::NetworkAddress::defaultAttributes() {
|
||||||
|
return {
|
||||||
|
{"port", true}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIVariantEditors::NetworkAddress::applyAttributes(const PIVariantMap & a) {
|
||||||
|
has_port = a.value("port", true).toBool();
|
||||||
|
if (has_port)
|
||||||
|
widget->setInputMask("000.000.000.000:00000;_");
|
||||||
|
else
|
||||||
|
widget->setInputMask("000.000.000.000;_");
|
||||||
|
widget->setReadOnly(a.value(Attribute::readOnly, widget->isReadOnly()).toBool());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// PIVariantEditors::FileBase
|
||||||
|
|
||||||
|
PIVariantEditors::FileBase::FileBase() {
|
||||||
|
filter = "All files(*)";
|
||||||
|
widget = new CLineEdit();
|
||||||
|
layout()->addWidget(widget);
|
||||||
|
sel_widget = new QWidget();
|
||||||
|
sel_widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
|
sel_widget->setLayout(new QBoxLayout(QBoxLayout::LeftToRight));
|
||||||
|
QMargins m = sel_widget->layout()->contentsMargins();
|
||||||
|
sel_widget->layout()->setContentsMargins(m.left(), 0, 0, 0);
|
||||||
|
auto * b = new QToolButton();
|
||||||
|
b->setIcon(QIcon(":/icons/document-open.png"));
|
||||||
|
b->setToolTip(tr("Choose") + " ...");
|
||||||
|
connect(b, &QToolButton::clicked, this, [this]() {
|
||||||
|
QString ret;
|
||||||
|
if (is_dir)
|
||||||
|
ret = QFileDialog::getExistingDirectory(this, tr("Select directory"), widget->text());
|
||||||
|
else {
|
||||||
|
if (is_save)
|
||||||
|
ret = QFileDialog::getSaveFileName(this, tr("Select file"), widget->text(), PIVariantEditorBase::vtTr(filter));
|
||||||
|
else
|
||||||
|
ret = QFileDialog::getOpenFileName(this, tr("Select file"), widget->text(), PIVariantEditorBase::vtTr(filter));
|
||||||
|
}
|
||||||
|
if (ret.isEmpty()) return;
|
||||||
|
if (!is_abs) ret = QDir::current().relativeFilePath(ret);
|
||||||
|
widget->setText(ret);
|
||||||
|
});
|
||||||
|
sel_widget->layout()->addWidget(b);
|
||||||
|
layout()->addWidget(sel_widget);
|
||||||
|
edit_widget = new QWidget();
|
||||||
|
edit_widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
|
edit_widget->setLayout(new QBoxLayout(QBoxLayout::LeftToRight));
|
||||||
|
m = edit_widget->layout()->contentsMargins();
|
||||||
|
edit_widget->layout()->setContentsMargins(m.left(), 0, 0, 0);
|
||||||
|
b = new QToolButton();
|
||||||
|
b->setIcon(QIcon(":/icons/document-edit.png"));
|
||||||
|
b->setPopupMode(QToolButton::InstantPopup);
|
||||||
|
b->setMenu(&edit_menu);
|
||||||
|
edit_widget->layout()->addWidget(b);
|
||||||
|
layout()->setSpacing(0);
|
||||||
|
layout()->addWidget(edit_widget);
|
||||||
|
setFullEditMode(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIVariantMap PIVariantEditors::FileBase::attributes() const {
|
||||||
|
return {
|
||||||
|
{Attribute::filter, filter },
|
||||||
|
{Attribute::absolutePath, is_abs },
|
||||||
|
{Attribute::onlyExisting, !is_save}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIVariantMap PIVariantEditors::FileBase::defaultAttributes() {
|
||||||
|
return {
|
||||||
|
{Attribute::filter, "" },
|
||||||
|
{Attribute::absolutePath, false},
|
||||||
|
{Attribute::onlyExisting, true }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIVariantEditors::FileBase::applyAttributes(const PIVariantMap & a) {
|
||||||
|
filter = a.value(Attribute::filter).toString();
|
||||||
|
is_abs = a.value(Attribute::absolutePath).toBool();
|
||||||
|
is_save = !a.value(Attribute::onlyExisting, true).toBool();
|
||||||
|
bool ro = a.value(Attribute::readOnly).toBool();
|
||||||
|
widget->setReadOnly(ro);
|
||||||
|
sel_widget->setHidden(ro);
|
||||||
|
if (act_abs) act_abs->setChecked(is_abs);
|
||||||
|
if (act_save) act_save->setChecked(!is_save);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIVariantEditors::FileBase::setFullEditMode(bool on) {
|
||||||
|
edit_widget->setVisible(on);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PIVariantEditors::FileBase::createMenu() {
|
||||||
|
act_abs = edit_menu.addAction(tr("Absolute path"), this, [this](bool on) { is_abs = on; });
|
||||||
|
act_abs->setCheckable(true);
|
||||||
|
act_abs->setChecked(is_abs);
|
||||||
|
if (is_dir) return;
|
||||||
|
act_save = edit_menu.addAction(tr("Existing only"), this, [this](bool on) { is_save = !on; });
|
||||||
|
act_save->setCheckable(true);
|
||||||
|
act_save->setChecked(!is_save);
|
||||||
|
edit_menu.addAction(tr("Set filter ..."), this, [this]() {
|
||||||
|
bool ok = false;
|
||||||
|
QString nf = QInputDialog::getText(nullptr, tr("Select filter"), tr("Input filter:"), QLineEdit::Normal, PI2QString(filter), &ok);
|
||||||
|
if (!ok) return;
|
||||||
|
filter = Q2PIString(nf);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// PIVariantEditors::File
|
||||||
|
|
||||||
|
void PIVariantEditors::File::setValue(const PIVariant & v) {
|
||||||
|
widget->setText(PI2QString(v.toFile().file));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIVariant PIVariantEditors::File::value() const {
|
||||||
|
PIVariantTypes::File v;
|
||||||
|
v.file = Q2PIString(widget->text());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// PIVariantEditors::Dir
|
||||||
|
|
||||||
|
void PIVariantEditors::Dir::setValue(const PIVariant & v) {
|
||||||
|
widget->setText(PI2QString(v.toDir().dir));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIVariant PIVariantEditors::Dir::value() const {
|
||||||
|
PIVariantTypes::Dir v;
|
||||||
|
v.dir = Q2PIString(widget->text());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDateEdit>
|
#include <QDateEdit>
|
||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
|
#include <QMenu>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QTimeEdit>
|
#include <QTimeEdit>
|
||||||
#include <clineedit.h>
|
#include <clineedit.h>
|
||||||
@@ -64,6 +65,7 @@ public:
|
|||||||
PIVariant value() const override { return widget->value(); }
|
PIVariant value() const override { return widget->value(); }
|
||||||
PIVariantMap attributes() const override;
|
PIVariantMap attributes() const override;
|
||||||
static PIVariantMap defaultAttributes();
|
static PIVariantMap defaultAttributes();
|
||||||
|
void retranslate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void applyAttributes(const PIVariantMap & a) override;
|
void applyAttributes(const PIVariantMap & a) override;
|
||||||
@@ -85,6 +87,7 @@ public:
|
|||||||
PIVariant value() const override { return widget->value(); }
|
PIVariant value() const override { return widget->value(); }
|
||||||
PIVariantMap attributes() const override;
|
PIVariantMap attributes() const override;
|
||||||
static PIVariantMap defaultAttributes();
|
static PIVariantMap defaultAttributes();
|
||||||
|
void retranslate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void applyAttributes(const PIVariantMap & a) override;
|
void applyAttributes(const PIVariantMap & a) override;
|
||||||
@@ -206,6 +209,71 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class QAD_PIQT_UTILS_EXPORT NetworkAddress: public PIVariantEditorBase {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
NetworkAddress();
|
||||||
|
void setValue(const PIVariant & v) override;
|
||||||
|
PIVariant value() const override;
|
||||||
|
PIVariantMap attributes() const override;
|
||||||
|
static PIVariantMap defaultAttributes();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void applyAttributes(const PIVariantMap & a) override;
|
||||||
|
QLineEdit * widget;
|
||||||
|
bool has_port = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class QAD_PIQT_UTILS_EXPORT FileBase: public PIVariantEditorBase {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
FileBase();
|
||||||
|
PIVariantMap attributes() const override;
|
||||||
|
static PIVariantMap defaultAttributes();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void applyAttributes(const PIVariantMap & a) override;
|
||||||
|
void setFullEditMode(bool on) override;
|
||||||
|
void createMenu();
|
||||||
|
CLineEdit * widget;
|
||||||
|
QWidget * sel_widget;
|
||||||
|
QWidget * edit_widget;
|
||||||
|
QMenu edit_menu;
|
||||||
|
QAction *act_abs = nullptr, *act_save = nullptr;
|
||||||
|
bool is_dir = false, is_abs = false, is_save = false;
|
||||||
|
PIString filter;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class QAD_PIQT_UTILS_EXPORT File: public FileBase {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
File(): FileBase() {
|
||||||
|
is_dir = false;
|
||||||
|
createMenu();
|
||||||
|
}
|
||||||
|
void setValue(const PIVariant & v) override;
|
||||||
|
PIVariant value() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class QAD_PIQT_UTILS_EXPORT Dir: public FileBase {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Dir(): FileBase() {
|
||||||
|
is_dir = true;
|
||||||
|
createMenu();
|
||||||
|
}
|
||||||
|
void setValue(const PIVariant & v) override;
|
||||||
|
PIVariant value() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}; // namespace PIVariantEditors
|
}; // namespace PIVariantEditors
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
<file>../../icons/code-struct.png</file>
|
<file>../../icons/code-struct.png</file>
|
||||||
<file>../../icons/code-union.png</file>
|
<file>../../icons/code-union.png</file>
|
||||||
<file>../../icons/legend.png</file>
|
<file>../../icons/legend.png</file>
|
||||||
|
<file>../../icons/document-open.png</file>
|
||||||
<file>../../icons/document-edit.png</file>
|
<file>../../icons/document-edit.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTranslator>>
|
#include <QTranslator>
|
||||||
#include <evalspinbox.h>
|
#include <evalspinbox.h>
|
||||||
#include <piintrospection_server.h>
|
#include <piintrospection_server.h>
|
||||||
#include <qad_types.h>
|
#include <qad_types.h>
|
||||||
@@ -16,9 +16,6 @@
|
|||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
auto * qtr = new QTranslator();
|
|
||||||
qtr->load("c:/work/test_ru.qm");
|
|
||||||
a.installTranslator(qtr);
|
|
||||||
|
|
||||||
PIValueTree root, group, array;
|
PIValueTree root, group, array;
|
||||||
root.addChild({"bool", false});
|
root.addChild({"bool", false});
|
||||||
@@ -58,7 +55,7 @@ int main(int argc, char * argv[]) {
|
|||||||
QScrollArea area;
|
QScrollArea area;
|
||||||
area.setWidgetResizable(true);
|
area.setWidgetResizable(true);
|
||||||
PIValueTreeEdit e;
|
PIValueTreeEdit e;
|
||||||
e.setGroupingEnabled(false);
|
e.setGroupingEnabled(true);
|
||||||
e.setFullEditMode(true);
|
e.setFullEditMode(true);
|
||||||
e.setGeometry(500, 400, 100, 50);
|
e.setGeometry(500, 400, 100, 50);
|
||||||
// e.setValue(PIValueTreeConversions::fromJSON(PIJSON::fromJSON(PIValueTreeConversions::toJSON(vt).toJSON())));
|
// e.setValue(PIValueTreeConversions::fromJSON(PIJSON::fromJSON(PIValueTreeConversions::toJSON(vt).toJSON())));
|
||||||
@@ -70,7 +67,11 @@ int main(int argc, char * argv[]) {
|
|||||||
QTimer timer;
|
QTimer timer;
|
||||||
QObject::connect(&timer, &QTimer::timeout, [&]() { e.rollback(); });
|
QObject::connect(&timer, &QTimer::timeout, [&]() { e.rollback(); });
|
||||||
// timer.start(5);
|
// timer.start(5);
|
||||||
// QTimer::singleShot(1000, [&e](){e.setValue(50);});
|
QTimer::singleShot(1000, [&e]() {
|
||||||
|
auto * qtr = new QTranslator();
|
||||||
|
qtr->load("c:/work/test_ru.qm");
|
||||||
|
qApp->installTranslator(qtr);
|
||||||
|
});
|
||||||
// QTimer::singleShot(2000, [&e, vt]() {
|
// QTimer::singleShot(2000, [&e, vt]() {
|
||||||
// e.setValue(PIValueTreeConversions::fromText(PIValueTreeConversions::toText(vt) + "\n[]\nAHAHA = 123\n"));
|
// e.setValue(PIValueTreeConversions::fromText(PIValueTreeConversions::toText(vt) + "\n[]\nAHAHA = 123\n"));
|
||||||
//});
|
//});
|
||||||
|
|||||||
Reference in New Issue
Block a user