590 lines
21 KiB
C++
590 lines
21 KiB
C++
/*
|
||
* PaiInfoEditor.cpp
|
||
*
|
||
* Created on: 2011-10-25
|
||
* Author: dev
|
||
*/
|
||
#include <cassert>
|
||
#include <set>
|
||
#include <vector>
|
||
#include <QLabel>
|
||
#include <QWidget>
|
||
#include <QSpinBox>
|
||
#include <QDoubleSpinBox>
|
||
#include <QCheckBox>
|
||
#include <QTableWidget>
|
||
#include <QHBoxLayout>
|
||
#include <QtDebug>
|
||
#include <QTreeView>
|
||
#include <QMovie>
|
||
#include <QPainter>
|
||
#include <QPen>
|
||
#include <QDialogButtonBox>
|
||
#include <QModelIndex>
|
||
#include <QApplication>
|
||
#include <QMouseEvent>
|
||
#include <QDialog>
|
||
#include "DialogFactory.h"
|
||
#include "ParameterProperty.h"
|
||
#include "PaiInfoEditor.h"
|
||
#include "PaiLineEdit.h"
|
||
#include "ParameterTableWidget.h"
|
||
// #include "VFSFactory.h"
|
||
// #include "File.h"
|
||
#include "PELibraryModule.h"
|
||
#include "PaiLineEdit.h"
|
||
#include "PaiLabel.h"
|
||
#include "ParameterEditor.h"
|
||
#include "PaiPushButton.h"
|
||
#include "PaiToolButton.h"
|
||
#include "PaiObjectBrowser.h"
|
||
// #include "PaiSeisData.h"
|
||
// #include "Log.h"
|
||
#include "WorkflowConst.h"
|
||
// #include "TimeStampLogger.h"
|
||
#include "GeometryUtils.h"
|
||
const char* g_szDeleteButtonName = "pai_parameter_editor_delete_button";
|
||
const char* g_szHideShowButtonName = "pai_parameter_editor_hideshow_button";
|
||
using namespace pai;
|
||
// using namespace pai::ios::vfs;
|
||
using namespace pai::gui;
|
||
using namespace pai::module;
|
||
|
||
namespace pai {
|
||
namespace graphics2d {
|
||
|
||
CPaiInfoEditor::CPaiInfoEditor(ParameterProperty* pParameterProperty, QWidget *parent,const QString& strDisplayName) :
|
||
QFrame(parent),
|
||
m_pParameterProperty(pParameterProperty),
|
||
m_label(NULL),
|
||
m_pInternalEditor(NULL),
|
||
m_pMovieLabel(NULL),
|
||
HideBrothers(false),
|
||
HideOptionals(false),
|
||
m_pMovie(NULL)
|
||
{
|
||
// TODO Auto-generated constructor stub
|
||
setObjectName(strDisplayName);
|
||
|
||
m_pInternalEditor = CreateInternalEditor();
|
||
assert(m_pInternalEditor != NULL);
|
||
|
||
CParameterTableWidget *pTempTable = dynamic_cast<CParameterTableWidget*>(m_pInternalEditor);
|
||
if (pTempTable != NULL)
|
||
{
|
||
pTempTable->GetTable()->installEventFilter(this);
|
||
}
|
||
else
|
||
{
|
||
CParameterItemRadioButtonGroup *pGroup = dynamic_cast<CParameterItemRadioButtonGroup *>(m_pInternalEditor);
|
||
if (NULL != pGroup)
|
||
{
|
||
pGroup->installEventFilter(this);
|
||
}
|
||
else
|
||
{
|
||
m_pInternalEditor->installEventFilter(this);
|
||
}
|
||
}
|
||
|
||
QBoxLayout *layout = new QVBoxLayout;
|
||
layout->setMargin(1);
|
||
layout->setSpacing(0);
|
||
|
||
QBoxLayout *pHLayout = new QHBoxLayout;
|
||
pHLayout->setMargin(0);
|
||
pHLayout->setSpacing(0);
|
||
pHLayout->addWidget(m_pInternalEditor);
|
||
pHLayout->setAlignment(Qt::AlignRight);
|
||
if(HasDeleteButton())
|
||
{
|
||
pai::gui::PaiToolButton* pDeleteButton = new pai::gui::PaiToolButton(QIcon(::GetImagePath()+"icon/Cancel.png"),this);
|
||
pDeleteButton->setObjectName(g_szDeleteButtonName);
|
||
pDeleteButton->setMaximumSize(m_pInternalEditor->sizeHint().height(),m_pInternalEditor->sizeHint().height());
|
||
connect(pDeleteButton,SIGNAL(clicked()),this,SLOT(slotOnDeleteButtonClick()));
|
||
pHLayout->addWidget(pDeleteButton);
|
||
pDeleteButton->setToolTip("删除当前井段参数");
|
||
|
||
// pHideShowButton = new pai::gui::PaiToolButton(QIcon(::GetImagePath()+"icon/DoubleUp.png"),this);
|
||
// pHideShowButton->setObjectName(g_szHideShowButtonName);
|
||
// pHideShowButton->setMaximumSize(m_pInternalEditor->sizeHint().height(),m_pInternalEditor->sizeHint().height());
|
||
// connect(pHideShowButton,SIGNAL(clicked()),this,SLOT(slotOnHideShowButtonClick()));
|
||
// pHLayout->addWidget(pHideShowButton);
|
||
// pHideShowButton->setToolTip("显示隐藏当前井段参数");
|
||
|
||
pHideShowOptionalButton = new pai::gui::PaiToolButton(QIcon(::GetImagePath()+"icon/SingleUp.png"),this);
|
||
pHideShowOptionalButton->setObjectName(g_szHideShowButtonName);
|
||
pHideShowOptionalButton->setMaximumSize(m_pInternalEditor->sizeHint().height(),m_pInternalEditor->sizeHint().height());
|
||
connect(pHideShowOptionalButton,SIGNAL(clicked()),this,SLOT(slotOnHideShowOptionalButtonClick()));
|
||
pHLayout->addWidget(pHideShowOptionalButton);
|
||
pHideShowOptionalButton->setToolTip("显示隐藏当前井段可选参数");
|
||
|
||
}
|
||
m_label = new PaiLabel(this);
|
||
layout->addWidget(m_label);
|
||
m_label->setVisible(false);
|
||
setLayout(layout);
|
||
|
||
m_pMovieLabel = new QPushButton(this);
|
||
m_pMovieLabel->setFixedWidth(16);
|
||
m_pMovieLabel->setFixedHeight(m_label->height());
|
||
|
||
pHLayout->addWidget(m_pMovieLabel);
|
||
layout->addLayout(pHLayout);
|
||
|
||
|
||
if ((m_pParameterProperty != NULL) && (m_pParameterProperty->GetErrorMessage() != ""))
|
||
{
|
||
slotSetErrorMessage(m_pParameterProperty->GetErrorMessage());
|
||
}
|
||
|
||
connect(m_pMovieLabel, SIGNAL(clicked()),this, SLOT(slotShowLoadingAnimate()));
|
||
}
|
||
|
||
CPaiInfoEditor::~CPaiInfoEditor()
|
||
{
|
||
// TODO Auto-generated destructor stub
|
||
}
|
||
|
||
bool CPaiInfoEditor::eventFilter(QObject *obj, QEvent *event)
|
||
{
|
||
if (event->type() == QEvent::FocusIn)
|
||
{
|
||
//模拟单击QFrame事件
|
||
{
|
||
QPoint pos;
|
||
QPoint(size().width()-1, size().height()-1);
|
||
QMouseEvent *mEvnPress = new QMouseEvent(QEvent::MouseButtonPress, pos, Qt::LeftButton,Qt::LeftButton, Qt::NoModifier);
|
||
QApplication::sendEvent(this,mEvnPress);
|
||
QMouseEvent *mEvnRelease = new QMouseEvent(QEvent::MouseButtonRelease, pos, Qt::LeftButton,Qt::LeftButton, Qt::NoModifier);
|
||
QApplication::sendEvent(this,mEvnRelease);
|
||
}
|
||
}
|
||
if (event->type() == QEvent::FocusOut)
|
||
{
|
||
CParameterItemLineEdit* pItemLineEdit = dynamic_cast<CParameterItemLineEdit *> (m_pInternalEditor);
|
||
if (pItemLineEdit)
|
||
{
|
||
if (m_pParameterProperty && m_pParameterProperty->GetParameterItem())
|
||
{
|
||
pai::module::CParameterItem *pItem = m_pParameterProperty->GetParameterItem();
|
||
if (pItem->GetType() == pai::module::ParmType_INT || pItem->GetType() == pai::module::ParmType_LONG || pItem->GetType()
|
||
== pai::module::ParmType_FLOAT || pItem->GetType() == pai::module::ParmType_DOUBLE)
|
||
{
|
||
QString currentText = pItemLineEdit->text();
|
||
if (currentText.compare("+") == 0 || currentText.compare("-") == 0)
|
||
{
|
||
pItem->SetStringValue(currentText.toStdString());
|
||
emit editFocuseOut();
|
||
}
|
||
else if (currentText.isEmpty())
|
||
{
|
||
pItem->SetStringValue("");
|
||
emit editFocuseOut();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return QObject::eventFilter(obj, event);
|
||
}
|
||
|
||
QWidget* CPaiInfoEditor::CreateInternalEditor()
|
||
{
|
||
assert(m_pParameterProperty != NULL);
|
||
QWidget* pInternalEditor = NULL;
|
||
|
||
pai::module::ParameterInputType parameterInputType = m_pParameterProperty->GetInputType();
|
||
switch(parameterInputType)
|
||
{
|
||
case pai::module::COMBOX:
|
||
{
|
||
pInternalEditor = new CParameterItemComboBox(m_pParameterProperty->GetParameterItem(),this);
|
||
connect(pInternalEditor, SIGNAL(signalInternalIndexChanged()),this,SIGNAL(_signalInternalEditorLostFocus(const QString &)));
|
||
}
|
||
break;
|
||
case pai::module::RADIOBOX:
|
||
{
|
||
pInternalEditor = new CParameterItemRadioButtonGroup(m_pParameterProperty->GetParameterItem(),this);
|
||
connect(pInternalEditor, SIGNAL(signalInternalIndexChanged()),this,SIGNAL(_signalInternalEditorLostFocus(const QString &)));
|
||
}
|
||
break;
|
||
case pai::module::SPINBOX:
|
||
{
|
||
pInternalEditor = new CParameterItemSpinBox(m_pParameterProperty->GetParameterItem(),this);
|
||
connect(pInternalEditor, SIGNAL(editingFinished()),this, SIGNAL(_signalInternalEditorLostFocus(const QString &)));
|
||
}
|
||
break;
|
||
case pai::module::DOUBLESPINBOX:
|
||
{
|
||
pInternalEditor = new CParameterItemDoubleSpinBox(m_pParameterProperty->GetParameterItem(),this);
|
||
connect(pInternalEditor, SIGNAL(editingFinished()),this,SIGNAL(_signalInternalEditorLostFocus(const QString &)));
|
||
}
|
||
break;
|
||
case pai::module::CHECKBOX:
|
||
{
|
||
pInternalEditor = new CParameterItemCheckBox(m_pParameterProperty->GetParameterItem(),this);
|
||
connect(pInternalEditor, SIGNAL(clicked(bool)),this ,SIGNAL(_signalInternalEditorLostFocus(const QString &)));
|
||
}
|
||
break;
|
||
case pai::module::EDITABLEDGRID:
|
||
{
|
||
pInternalEditor = new CParameterTableWidget(m_pParameterProperty->GetParameterItem(),this);
|
||
connect(((CParameterTableWidget*)pInternalEditor), SIGNAL(signalOnFinishEditingRowOrCell()),this ,SIGNAL(_signalInternalEditorLostFocus(const QString &)));
|
||
}
|
||
break;
|
||
case pai::module::HDFSFILEEDITOR:
|
||
{
|
||
pInternalEditor = new CHdfsFileEditor(m_pParameterProperty->GetWorkflowID(),this);
|
||
connect(pInternalEditor, SIGNAL(editingFinished()),this ,SIGNAL(_signalInternalEditorLostFocus(const QString &)));
|
||
}
|
||
break;
|
||
case pai::module::HDFSFILEBROWSER:
|
||
{
|
||
pInternalEditor = new CPaiObjectBrowser(m_pParameterProperty->GetAcceptDropTypes(),this);
|
||
connect(pInternalEditor, SIGNAL(editingFinished()),this ,SIGNAL(_signalInternalEditorLostFocus(const QString &)));
|
||
|
||
}
|
||
break;
|
||
case pai::module::NONEINPUT:
|
||
{
|
||
//我们暂时用NONEINPUT类型来对应数组参数项的添加按钮
|
||
pInternalEditor = new CParameterItemButtonBox(m_pParameterProperty->GetParameterItem(),this);
|
||
}
|
||
break;
|
||
case pai::module::SPLIT:
|
||
{
|
||
pInternalEditor = new CParameterItemCheckBoxGroup(m_pParameterProperty->GetParameterItem(),this);
|
||
}
|
||
break;
|
||
case pai::module::TEXTEDIT:
|
||
default:
|
||
{
|
||
pai::module::CParameterItem *pItem=dynamic_cast<pai::module::CParameterItem *>(m_pParameterProperty->GetParameterItem());
|
||
pInternalEditor = new CParameterItemLineEdit(m_pParameterProperty->GetParameterItem(),this);
|
||
|
||
ParameterType paramType = pItem->GetType();
|
||
if (paramType == pai::module::ParmType_STRING)
|
||
{
|
||
QRegExp regExp("[A-Za-z0-9#_*αβγδεζηθικλμνξοπρστυφχψ]{0,100}");//正则表达式,第一位字为a-z,第二位为1-9的数字,后边是0-2位0-9的数字
|
||
((QLineEdit*)pInternalEditor)->setValidator(new QRegExpValidator(regExp,this));
|
||
}
|
||
else if (paramType == pai::module::ParmType_INT)
|
||
{
|
||
((QLineEdit*)pInternalEditor)->setValidator(new QIntValidator(-9999999,9999999,this));
|
||
}
|
||
else if (paramType == pai::module::ParmType_DOUBLE)
|
||
{
|
||
((QLineEdit*)pInternalEditor)->setValidator(new QDoubleValidator(-9999999,9999999,6,this));
|
||
}
|
||
else if (paramType == pai::module::ParmType_FLOAT)
|
||
{
|
||
((QLineEdit*)pInternalEditor)->setValidator(new QDoubleValidator(-9999999,9999999,6,this));
|
||
}
|
||
else if (paramType == pai::module::ParmType_BOOL)
|
||
{
|
||
}
|
||
connect(pInternalEditor, SIGNAL(EditingFinished(const QString &)),this ,SIGNAL(_signalInternalEditorLostFocus(const QString &)));
|
||
connect(this, SIGNAL(editFocuseOut()),this ,SIGNAL(_signalInternalEditorLostFocus(const QString &)));
|
||
}
|
||
}
|
||
if(!pInternalEditor)
|
||
{
|
||
return NULL;
|
||
}
|
||
|
||
if(m_pParameterProperty->GetParameterItem()!=NULL)
|
||
{
|
||
if (parameterInputType != pai::module::EDITABLEDGRID)
|
||
{
|
||
pInternalEditor->setProperty("IsSameWithDefault", true);
|
||
}
|
||
QString descTips = GetToolTipDescription(QString::fromStdString(m_pParameterProperty->GetParameterItem()->GetDescription()));
|
||
|
||
pInternalEditor->setToolTip(descTips);
|
||
|
||
if ((parameterInputType != pai::module::EDITABLEDGRID && m_pParameterProperty->GetParameterItem()->GetDefault() == "")
|
||
|| parameterInputType == pai::module::HDFSFILEBROWSER
|
||
|| parameterInputType == pai::module::HDFSFILEEDITOR
|
||
|| !m_pParameterProperty->GetParameterItem()->SameAsDefault())
|
||
{
|
||
pInternalEditor->setProperty("IsSameWithDefault", false);
|
||
}
|
||
}
|
||
|
||
//因为样式表中LineEdit的border在hover和focus时会发生变化,所以有时控件会出现上下动的情况。设置最大值,避免此现象。
|
||
//表格除外,因为设计需要能自动调整高度
|
||
if (parameterInputType != pai::module::EDITABLEDGRID && parameterInputType != pai::module::COMBOX)
|
||
{
|
||
// pInternalEditor->setMaximumHeight(pInternalEditor->sizeHint().height());
|
||
}
|
||
else if (parameterInputType == pai::module::COMBOX)
|
||
{
|
||
//这里为了保证combobox的文本框和LineEdit的高度一样。
|
||
pInternalEditor->setMaximumHeight(26);
|
||
}
|
||
|
||
return pInternalEditor;
|
||
}
|
||
QSize CPaiInfoEditor::sizeHint() const
|
||
{
|
||
if (dynamic_cast<CParameterTableWidget*>(m_pInternalEditor))
|
||
{
|
||
return m_pInternalEditor->sizeHint() + QSize(0, layout()->contentsMargins().top() + layout()->contentsMargins().bottom())
|
||
+ QSize(0, m_label->isVisible() ? m_label->size().height() : 0);
|
||
}
|
||
else
|
||
{
|
||
return QFrame::sizeHint();
|
||
}
|
||
}
|
||
QString CPaiInfoEditor::GetToolTipDescription(QString description)
|
||
{
|
||
QString descTips;
|
||
int i = 0;
|
||
QString temp = description.section(' ', i, g_iMaxToolTipLength - 1);
|
||
i++;
|
||
QString tempNext = description.section(' ', i*g_iMaxToolTipLength, (i + 1)*g_iMaxToolTipLength - 1);
|
||
|
||
if (!temp.isEmpty() && !tempNext.isEmpty())
|
||
{
|
||
do
|
||
{
|
||
descTips += temp;
|
||
descTips += "\r\n";
|
||
temp = tempNext;
|
||
i++;
|
||
tempNext = description.section(' ', i*g_iMaxToolTipLength, (i + 1)*g_iMaxToolTipLength - 1);
|
||
}while(!tempNext.isEmpty());
|
||
|
||
if (!temp.isEmpty())
|
||
{
|
||
descTips += temp;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
descTips = description;
|
||
}
|
||
return descTips;
|
||
}
|
||
|
||
QWidget* CPaiInfoEditor::GetInternalEditor() const
|
||
{
|
||
return m_pInternalEditor;
|
||
}
|
||
|
||
void CPaiInfoEditor::slotSetErrorMessage(const QString& errorMessage)
|
||
{
|
||
if(m_label != NULL)
|
||
{
|
||
// m_label->setText(errorMessage.left(errorMessage.indexOf('$')));
|
||
// m_label->ShowPromptMessge(errorMessage != "" ? PaiLabel::PT_Error : PaiLabel::PT_Information);
|
||
// m_label->setVisible(errorMessage != "");
|
||
}
|
||
|
||
if(dynamic_cast<PaiSpinBox*>(m_pInternalEditor))
|
||
{
|
||
PaiSpinBox* pSpinBox=dynamic_cast<PaiSpinBox*>(m_pInternalEditor);
|
||
pSpinBox->SetStyle(PaiSpinBox::ErrorFlag,errorMessage != "");
|
||
}
|
||
else if(dynamic_cast<QDoubleSpinBox*>(m_pInternalEditor))
|
||
{
|
||
// pai::log::Debug(_FLF("not supported for setErroryMessage on double spin box!"));
|
||
}
|
||
else if(dynamic_cast<CParameterTableWidget*>(m_pInternalEditor))
|
||
{
|
||
CParameterTableWidget* pTableWgt = dynamic_cast<CParameterTableWidget*>(m_pInternalEditor);
|
||
pTableWgt->setError(errorMessage);
|
||
}
|
||
else
|
||
{
|
||
if(m_pInternalEditor)
|
||
{
|
||
m_pInternalEditor->setStyleSheet((errorMessage != "") ? ("border:2px solid #ff0000;") : (""));
|
||
}
|
||
}
|
||
}
|
||
|
||
void CPaiInfoEditor::slotShowLoadingAnimate()
|
||
{
|
||
CParameterEditor*pEdit=NULL;
|
||
QPushButton*pPush=dynamic_cast<QPushButton*>(sender());
|
||
if(pPush)
|
||
{
|
||
QWidget *pw=dynamic_cast<QWidget *>(pPush->parent());
|
||
while(pw){
|
||
pw=dynamic_cast<QWidget *>(pw->parent());
|
||
pEdit=dynamic_cast<CParameterEditor*>(pw);
|
||
if(pEdit) break;
|
||
}
|
||
}
|
||
#define GetClassID_ChooseCurveDlg() "{160FF62C-A430-4D75-ADB4-7F895D622D1E}"
|
||
IDialogFactory& afactory=CDialogFactory::GetFatory();
|
||
QUuid classID = QUuid(GetClassID_ChooseCurveDlg());
|
||
CDialogFactory* adlg=afactory.CreateObject(classID);
|
||
QDialog * pDlg = dynamic_cast<QDialog *>(adlg);
|
||
Qt::WindowFlags flags = pDlg->windowFlags();
|
||
flags |= Qt::WindowStaysOnTopHint;
|
||
flags &= ~Qt::WindowContextHelpButtonHint;
|
||
pDlg->setWindowFlags(flags);
|
||
// pDlg->setParent(pEdit);
|
||
if(pEdit) {
|
||
if(pEdit->GetModuleInfo())
|
||
{
|
||
PELibraryModule*pMoudle=dynamic_cast<PELibraryModule*>(pEdit->GetModuleInfo()->GetModule());
|
||
if(pMoudle)
|
||
{
|
||
pDlg->setWindowTitle(pMoudle->GetSlfFileName());
|
||
}
|
||
}
|
||
}
|
||
if ( QDialog::Accepted == pDlg->exec())
|
||
{
|
||
QString strFilePath = pDlg->windowTitle();
|
||
QString curve=strFilePath.split("@").at(0);
|
||
QLineEdit*pLineEdit=dynamic_cast<QLineEdit*>(m_pInternalEditor);
|
||
if(pLineEdit) pLineEdit->setText(curve);
|
||
CParameterItemLineEdit* pItemLineEdit = dynamic_cast<CParameterItemLineEdit *> (m_pInternalEditor);
|
||
if (pItemLineEdit)
|
||
{
|
||
if (m_pParameterProperty && m_pParameterProperty->GetParameterItem())
|
||
{
|
||
pai::module::CParameterItem *pItem = m_pParameterProperty->GetParameterItem();
|
||
QString currentText = pItemLineEdit->text();
|
||
pItem->SetStringValue(currentText.toStdString());
|
||
emit editFocuseOut();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
void CPaiInfoEditor::slotStopAnimate()
|
||
{
|
||
if(m_pMovie != NULL)
|
||
{
|
||
m_pMovie->stop();
|
||
// m_pMovieLabel->setMovie(NULL);
|
||
m_pMovieLabel->update();
|
||
}
|
||
// pai::gui::TimeStampLogger::GetInstance().WriteGUIBenchMarkLog("Workflow", false, "Show parameter validation animation");
|
||
}
|
||
|
||
void CPaiInfoEditor::slotOnDeleteButtonClick()
|
||
{
|
||
emit signalDeleteItem(_GetDeleteItemID(m_pParameterProperty));
|
||
}
|
||
|
||
|
||
|
||
void CPaiInfoEditor::slotOnHideShowButtonClick()
|
||
{
|
||
HideBrothers=!HideBrothers;
|
||
// if(HideBrothers)
|
||
// pHideShowButton->setIcon(QIcon(::GetImagePath()+"icon/DoubleDown.png"));
|
||
// else
|
||
// pHideShowButton->setIcon(QIcon(::GetImagePath()+"icon/DoubleUp.png"));
|
||
emit signalHideShowItems(_GetDeleteItemID(m_pParameterProperty),HideBrothers);
|
||
}
|
||
|
||
void CPaiInfoEditor::slotOnHideShowOptionalButtonClick()
|
||
{
|
||
HideOptionals=!HideOptionals;
|
||
if(HideOptionals)
|
||
pHideShowOptionalButton->setIcon(QIcon(::GetImagePath()+"icon/SingleDown.png"));
|
||
else
|
||
pHideShowOptionalButton->setIcon(QIcon(::GetImagePath()+"icon/SingleUp.png"));
|
||
emit signalHideShowOptionalItems(_GetDeleteItemID(m_pParameterProperty),HideOptionals);
|
||
}
|
||
|
||
QString CPaiInfoEditor::_GetDeleteItemID(ParameterProperty* pParameterProperty) const
|
||
{
|
||
assert(pParameterProperty != NULL);
|
||
CParameterItem * pParameterItem = pParameterProperty->GetParameterItem();
|
||
QString strInputData("");
|
||
if(pParameterItem != NULL && pParameterItem->GetInputData().find("HasDeleteButton")!=std::string::npos)
|
||
{
|
||
CParameterItem * pArrayItemParameterItem = pParameterItem->GetParentItem();//这里是为InputOutput模块的文件删除所定制的逻辑,不具有普适性
|
||
if(pArrayItemParameterItem != NULL)
|
||
{
|
||
return QString::fromStdString(pArrayItemParameterItem->GetId());
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
|
||
void CPaiInfoEditor::slotDataPropertyChanged(const QModelIndex& dataIndex,const QString& strPropertyName,const QVariant& varPropertyValue)
|
||
{
|
||
ParameterProperty* parameterPro = static_cast<ParameterProperty*> (dataIndex.internalPointer());
|
||
if((m_pParameterProperty != NULL) && (m_pParameterProperty == parameterPro))
|
||
{
|
||
if(strPropertyName == "Enable" && QString::fromStdString(m_pParameterProperty->GetParamItem()->GetId()).contains(".outputoverwrite"))
|
||
{
|
||
CParameterItemCheckBox *pItemCheckBox = dynamic_cast<CParameterItemCheckBox*>(m_pInternalEditor);
|
||
if (pItemCheckBox)
|
||
{
|
||
pItemCheckBox->setEnabled(varPropertyValue.toBool());
|
||
|
||
if(m_pInternalEditor != NULL)
|
||
{
|
||
if (varPropertyValue.toBool())
|
||
{
|
||
m_pInternalEditor->setStyleSheet("QCheckBox{color:#447FBE; background-color: white }");
|
||
}
|
||
else
|
||
{
|
||
m_pInternalEditor->setStyleSheet("QCheckBox{color:gray; background-color: white }");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if(strPropertyName == "LayerPickChanged" && m_pParameterProperty->GetParamItem()->GetId() == "SurfaceID")
|
||
{
|
||
CParameterItemComboBox *pItemComboBox = dynamic_cast<CParameterItemComboBox*>(m_pInternalEditor);
|
||
if (pItemComboBox)
|
||
{
|
||
QString strInputMetaData = QString::fromStdString(m_pParameterProperty->GetParamItem()->GetInputMetaData());
|
||
pItemComboBox->clear();
|
||
QStringList strComboboxTexts = strInputMetaData.split('/');
|
||
pItemComboBox->addItems(strComboboxTexts);
|
||
}
|
||
}
|
||
|
||
if(strPropertyName == "Ability")
|
||
{
|
||
m_pInternalEditor->setEnabled(varPropertyValue.toBool());
|
||
|
||
if(dynamic_cast<CParameterTableWidget*>(m_pInternalEditor))
|
||
{
|
||
CParameterTableWidget* pTableWgt = dynamic_cast<CParameterTableWidget*>(m_pInternalEditor);
|
||
pTableWgt->ShowAddButton(varPropertyValue.toBool());
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
void CPaiInfoEditor::slotUpdateHideShowItemsIcon(bool hide)
|
||
{
|
||
// if(hide)
|
||
// pHideShowButton->setIcon(QIcon(::GetImagePath()+"icon/DoubleDown.png"));
|
||
// else
|
||
// pHideShowButton->setIcon(QIcon(::GetImagePath()+"icon/DoubleUp.png"));
|
||
}
|
||
|
||
bool CPaiInfoEditor::HasDeleteButton() const
|
||
{
|
||
return _GetDeleteItemID(m_pParameterProperty) != "";
|
||
}
|
||
|
||
void CPaiInfoEditor::slotShowDeleteButton(bool bShow)
|
||
{
|
||
QWidget* pDeleteButton = findChild<QWidget*>(g_szDeleteButtonName);
|
||
if(pDeleteButton != NULL)
|
||
{
|
||
pDeleteButton->setVisible(bShow);
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|