92 lines
2.5 KiB
C++
92 lines
2.5 KiB
C++
/*
|
|
* ParameterItemDelegate.h
|
|
*
|
|
* Created on: 2011-9-16
|
|
* Author: dev
|
|
*/
|
|
|
|
#ifndef PAI_FRAME_WORKFLOWVIEW_PARAMETERITEMDELEGATE_H
|
|
#define PAI_FRAME_WORKFLOWVIEW_PARAMETERITEMDELEGATE_H
|
|
|
|
#include <QStyledItemDelegate>
|
|
class QWidget;
|
|
|
|
namespace pai {
|
|
namespace graphics2d {
|
|
|
|
class CParameterEditor;
|
|
class CPaiInfoEditor;
|
|
class ParameterProperty;
|
|
/**
|
|
* @brief 参数面板的参数项的表现层控件
|
|
*/
|
|
class ParameterItemDelegate :public QStyledItemDelegate
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
/**
|
|
* @brief 构造函数
|
|
* @param pView 父View控件
|
|
*/
|
|
ParameterItemDelegate(CParameterEditor* pView);
|
|
/**
|
|
* @brief 析构函数
|
|
*/
|
|
virtual ~ParameterItemDelegate();
|
|
/**
|
|
* @brief 分别为参数名和参数值创建合适的编辑器
|
|
* @param parent 父控件
|
|
* @param option 绘制样式
|
|
* @param index 参数项索引
|
|
*/
|
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem& option , const QModelIndex & index ) const;
|
|
/**
|
|
* @brief 从参数项取值并向编辑器中赋值
|
|
* @param index 参数项索引
|
|
*/
|
|
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
|
/**
|
|
* @brief 从编辑器取值并向参数项赋值
|
|
* @param editor 参数值编辑器
|
|
* @param model 参数项索引的模型结构
|
|
* @param index 参数项索引
|
|
*/
|
|
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
|
/**
|
|
* @brief 绘制每个参数项节点
|
|
* @param painter 图形设备上下文
|
|
* @param option 绘制样式
|
|
* @param index 参数项索引
|
|
*/
|
|
virtual void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
|
/**
|
|
* @brief 返回每个参数项绘制的大小
|
|
* @param option 绘制样式
|
|
* @param index 参数项索引
|
|
*/
|
|
virtual QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
|
/**
|
|
* @brief 更新编辑器的大小和位置
|
|
* @param editor 参数项编辑器
|
|
* @param option 绘制样式
|
|
* @param index 参数项索引
|
|
*/
|
|
void updateEditorGeometry ( QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
|
|
/**
|
|
* @brief 绘制每个参数项节点的背景
|
|
*/
|
|
void drawBackground ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
|
|
private slots:
|
|
/**
|
|
* @brief 编辑器编辑结束时通知框架
|
|
*/
|
|
void slotOnFinishEditing(const QString &str);
|
|
private:
|
|
CParameterEditor* m_pView;
|
|
|
|
};
|
|
|
|
}
|
|
}
|
|
#endif
|