PIValueTreeEdit develop ...
This commit is contained in:
@@ -20,43 +20,47 @@
|
||||
#ifndef pivariant_edit_H
|
||||
#define pivariant_edit_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
#include "pivariant.h"
|
||||
#include "qad_piqt_utils_export.h"
|
||||
|
||||
#define REGISTER_PIVARIANTEDITOR(type_name, class_name) \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
|
||||
#define REGISTER_PIVARIANTEDITOR(type_name, class_name) \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
PIVariantEditorBase::registerEditor<class_name>(PIVariant::typeIDFromName(PIStringAscii(#type_name))); \
|
||||
STATIC_INITIALIZER_END \
|
||||
STATIC_INITIALIZER_END
|
||||
|
||||
class PIVariantEdit;
|
||||
|
||||
|
||||
class QAD_PIQT_UTILS_EXPORT PIVariantEditorBase: public QWidget {
|
||||
friend class PIVariantEdit;
|
||||
|
||||
public:
|
||||
PIVariantEditorBase() {createBoxLayout();}
|
||||
PIVariantEditorBase() { createBoxLayout(); }
|
||||
virtual ~PIVariantEditorBase() {}
|
||||
|
||||
virtual void setValue(const PIVariant & v) = 0;
|
||||
virtual PIVariant value() const = 0;
|
||||
virtual PIVariant value() const = 0;
|
||||
|
||||
virtual PIVariantMap defaultAttributes() const {return PIVariantMap();}
|
||||
virtual PIVariantMap defaultAttributes() const { return PIVariantMap(); }
|
||||
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
static void registerEditor(uint type_id) {
|
||||
if (factories().contains(type_id)) {
|
||||
piCout << "[PIVariantEditorBase::registerEditor] Editor with typeID" << type_id << "already registered, ignore";
|
||||
return;
|
||||
}
|
||||
factories()[type_id] = []()->PIVariantEditorBase*{return new T();};
|
||||
factories()[type_id] = []() -> PIVariantEditorBase * { return new T(); };
|
||||
}
|
||||
static PIVariantEditorBase * createEditor(uint type_id);
|
||||
static bool editorExists(uint type_id);
|
||||
|
||||
protected:
|
||||
void createBoxLayout(QBoxLayout::Direction d = QBoxLayout::LeftToRight);
|
||||
virtual void setFullEditMode(bool on) {}
|
||||
|
||||
virtual void applyAttributes(const PIVariantMap & a) {}
|
||||
virtual void retranslate() {}
|
||||
@@ -64,8 +68,7 @@ protected:
|
||||
private:
|
||||
void changeEvent(QEvent * e) override;
|
||||
|
||||
static PIMap<uint, PIVariantEditorBase*(*)()> & factories();
|
||||
|
||||
static PIMap<uint, PIVariantEditorBase * (*)()> & factories();
|
||||
};
|
||||
|
||||
|
||||
@@ -80,12 +83,13 @@ public:
|
||||
void setAttributes(const PIVariantMap & a);
|
||||
PIVariantMap defaultAttributes() const;
|
||||
|
||||
void setFullEditMode(bool on);
|
||||
|
||||
private:
|
||||
PIVariantEditorBase * editor = nullptr;
|
||||
PIVariantMap _attributes;
|
||||
QLabel * label;
|
||||
uint current_type_id = -1;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user