PIValueTreeEdit develop ...

This commit is contained in:
2022-12-13 21:44:44 +03:00
parent a1a001035f
commit 3d3892a126
9 changed files with 492 additions and 137 deletions

View File

@@ -1,5 +1,7 @@
#include "pivariant_edit.h"
#include "piqt.h"
#include <QEvent>
@@ -12,6 +14,11 @@ PIVariantEditorBase * PIVariantEditorBase::createEditor(uint type_id) {
}
bool PIVariantEditorBase::editorExists(uint type_id) {
return factories().value(type_id, nullptr);
}
void PIVariantEditorBase::createBoxLayout(QBoxLayout::Direction d) {
auto * l = new QBoxLayout(d);
l->setContentsMargins(0, 0, 0, 0);
@@ -20,20 +27,17 @@ void PIVariantEditorBase::createBoxLayout(QBoxLayout::Direction d) {
void PIVariantEditorBase::changeEvent(QEvent * e) {
if (e->type() == QEvent::LanguageChange)
retranslate();
if (e->type() == QEvent::LanguageChange) retranslate();
QWidget::changeEvent(e);
}
PIMap<uint, PIVariantEditorBase*(*)()> & PIVariantEditorBase::factories() {
static PIMap<uint, PIVariantEditorBase*(*)()> ret;
PIMap<uint, PIVariantEditorBase * (*)()> & PIVariantEditorBase::factories() {
static PIMap<uint, PIVariantEditorBase * (*)()> ret;
return ret;
}
PIVariantEdit::PIVariantEdit(QWidget * parent): QWidget(parent) {
label = new QLabel();
label->setAlignment(Qt::AlignCenter);
@@ -54,7 +58,7 @@ void PIVariantEdit::setValue(const PIVariant & v, uint type_id) {
if (current_type_id != type_id || !editor) {
if (editor) delete editor;
current_type_id = type_id;
editor = PIVariantEditorBase::createEditor(current_type_id);
editor = PIVariantEditorBase::createEditor(current_type_id);
if (editor) {
editor->applyAttributes(_attributes);
layout()->removeWidget(label);
@@ -88,3 +92,9 @@ PIVariantMap PIVariantEdit::defaultAttributes() const {
if (!editor) return PIVariantMap();
return editor->defaultAttributes();
}
void PIVariantEdit::setFullEditMode(bool on) {
if (!editor) return;
editor->setFullEditMode(on);
}