You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWATI/Include/iBase/Interface/IxPtyPano.h

71 lines
1.9 KiB
C++

#pragma once
#include <functional>
#include <QVariant>
#include <QStringList>
#include "IxInterface.h"
#include "IxPtySource.h"
#include "IxPtyItem.h"
class ZxProperty;
class QString;
class IxPtySource;
class IxPtyItem;
typedef std::function<void (const QVariant& )> ZX_PROPERTY_CHANGED_CALLBACK;
struct ZX_PROPERTY_CHANGED_CALLBACK_EX
{
ZX_PROPERTY_CHANGED_CALLBACK callback;
QVariant oldValue;
IxPtySource* obj;
};
// 属性表接口
class IxPtyPano
: virtual public IxInterface
{
public:
// 添加分组
virtual IxPtyItem* addGroup(const QString& key, bool expand = true, bool visible = true) = 0;
// 添加属性
virtual IxPtyItem* add(ZX_PROPERTY_CHANGED_CALLBACK callback, const QString& key, const QVariant& var, IxPtyItem::ItemType type = IxPtyItem::typeDefault) = 0;
// 填属性表
virtual void beginSession(const QString& configName, IxInterface* pSessionOwner) = 0;
virtual void endSession() = 0;
// 为指定对象填写属性表
virtual void beginObject(IxPtySource* p) = 0;
virtual void endObject() = 0;
// 获取指定条目
virtual IxPtyItem* findPropertyItem(const QString& sKey) = 0;
// 清空属性表
virtual void clear(IxInterface* pSessionOwner = 0) = 0;
};
inline IxPtyItem* IxPtyItem::findPropertyItem(const QString& key)
{ return getPtyPano()->findPropertyItem(key); }
// 可分别指定get/set的方法.
#define ZX_PROP(_key, _getProp, _setProp) \
sheet->add( ([this](const QVariant& v){ this->_setProp(qvariant_cast<decltype(this->_getProp())>(v));}) \
, _key, QVariant::fromValue(this->_getProp()))
// 可挂接只读属性.
#define ZX_PROP_R(_key, _getProp) \
sheet->add( 0 , _key, QVariant::fromValue(this->_getProp()) )
/// 可挂接只读属性.
/// ZX_PROP_NR("v", _value)
#define ZX_PROP_NR(_key, _value) \
sheet->add(0, _key, QVariant::fromValue(this->_value))