description and tooltip are protected in RichParameter

This commit is contained in:
alemuntoni 2020-07-30 16:00:04 +02:00
parent 07aad36c65
commit 69898a2be8
5 changed files with 45 additions and 34 deletions

View File

@ -28,6 +28,16 @@ const Value& RichParameter::value() const
return *val;
}
const QString& RichParameter::fieldDescription() const
{
return fieldDesc;
}
const QString& RichParameter::toolTip() const
{
return tooltip;
}
Value& RichParameter::value()
{
return *val;

View File

@ -39,6 +39,8 @@ public:
const QString& name() const;
const Value& value() const;
const QString& fieldDescription() const;
const QString& toolTip() const;
Value& value();
virtual void accept(Visitor& v) = 0;
virtual RichParameter* clone() const = 0;
@ -50,7 +52,6 @@ protected:
QString pName;
Value* val;
public:
QString fieldDesc;
QString tooltip;
};

View File

@ -76,7 +76,7 @@ void RichParameterCopyConstructor::visit( RichMesh& pd )
{
lastCreated = new RichMesh(pd);
// if (pd.val != NULL)
// lastCreated = new RichMesh(pd.name(),pd.value().getMesh(),pd.value().getMesh(),pd.meshdoc,pd.fieldDesc,pd.tooltip);
// lastCreated = new RichMesh(pd.name(),pd.value().getMesh(),pd.value().getMesh(),pd.meshdoc,pd.fieldDescription(),pd.toolTip());
// else
// lastCreated = new RichMesh(pd.name(),pd.meshindex);
}
@ -103,27 +103,27 @@ void RichParameterXMLVisitor::visit( RichBool& pd )
v = "true";
else
v = "false";
fillRichParameterAttribute("RichBool",pd.name(),v,pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichBool",pd.name(),v,pd.fieldDescription(),pd.toolTip());
}
void RichParameterXMLVisitor::visit( RichInt& pd )
{
fillRichParameterAttribute("RichInt",pd.name(),QString::number(pd.value().getInt()),pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichInt",pd.name(),QString::number(pd.value().getInt()),pd.fieldDescription(),pd.toolTip());
}
void RichParameterXMLVisitor::visit( RichFloat& pd )
{
fillRichParameterAttribute("RichFloat",pd.name(),QString::number(pd.value().getFloat()),pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichFloat",pd.name(),QString::number(pd.value().getFloat()),pd.fieldDescription(),pd.toolTip());
}
void RichParameterXMLVisitor::visit( RichString& pd )
{
fillRichParameterAttribute("RichString",pd.name(),pd.value().getString(),pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichString",pd.name(),pd.value().getString(),pd.fieldDescription(),pd.toolTip());
}
void RichParameterXMLVisitor::visit( RichMatrix44f& pd )
{
fillRichParameterAttribute("RichMatrix44f",pd.name(),pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichMatrix44f",pd.name(),pd.fieldDescription(),pd.toolTip());
vcg::Matrix44f mat = pd.value().getMatrix44f();
for(unsigned int ii = 0;ii < 16;++ii)
parElem.setAttribute(QString("val")+QString::number(ii),QString::number(mat.V()[ii]));
@ -131,7 +131,7 @@ void RichParameterXMLVisitor::visit( RichMatrix44f& pd )
void RichParameterXMLVisitor::visit( RichPoint3f& pd )
{
fillRichParameterAttribute("RichPoint3f",pd.name(),pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichPoint3f",pd.name(),pd.fieldDescription(),pd.toolTip());
vcg::Point3f p = pd.value().getPoint3f();
parElem.setAttribute("x",QString::number(p.X()));
parElem.setAttribute("y",QString::number(p.Y()));
@ -140,14 +140,14 @@ void RichParameterXMLVisitor::visit( RichPoint3f& pd )
void RichParameterXMLVisitor::visit( RichShotf& pd )
{
fillRichParameterAttribute("RichShotf",pd.name(),pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichShotf",pd.name(),pd.fieldDescription(),pd.toolTip());
assert(0); // TODO !!!!
}
void RichParameterXMLVisitor::visit( RichColor& pd )
{
fillRichParameterAttribute("RichColor",pd.name(),pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichColor",pd.name(),pd.fieldDescription(),pd.toolTip());
QColor p = pd.value().getColor();
parElem.setAttribute("r",QString::number(p.red()));
parElem.setAttribute("g",QString::number(p.green()));
@ -157,14 +157,14 @@ void RichParameterXMLVisitor::visit( RichColor& pd )
void RichParameterXMLVisitor::visit( RichAbsPerc& pd )
{
fillRichParameterAttribute("RichAbsPerc",pd.name(),QString::number(pd.value().getAbsPerc()),pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichAbsPerc",pd.name(),QString::number(pd.value().getAbsPerc()),pd.fieldDescription(),pd.toolTip());
parElem.setAttribute("min",QString::number(pd.min));
parElem.setAttribute("max",QString::number(pd.max));
}
void RichParameterXMLVisitor::visit( RichEnum& pd )
{
fillRichParameterAttribute("RichEnum",pd.name(),QString::number(pd.value().getEnum()),pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichEnum",pd.name(),QString::number(pd.value().getEnum()),pd.fieldDescription(),pd.toolTip());
parElem.setAttribute("enum_cardinality",pd.enumvalues.size());
for(int ii = 0; ii < pd.enumvalues.size();++ii)
parElem.setAttribute(QString("enum_val")+QString::number(ii),pd.enumvalues.at(ii));
@ -178,14 +178,14 @@ void RichParameterXMLVisitor::visit( RichEnum& pd )
void RichParameterXMLVisitor::visit(RichDynamicFloat& pd)
{
fillRichParameterAttribute("RichDynamicFloat",pd.name(),QString::number(pd.value().getDynamicFloat()),pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichDynamicFloat",pd.name(),QString::number(pd.value().getDynamicFloat()),pd.fieldDescription(),pd.toolTip());
parElem.setAttribute("min",QString::number(pd.min));
parElem.setAttribute("max",QString::number(pd.max));
}
void RichParameterXMLVisitor::visit( RichOpenFile& pd )
{
fillRichParameterAttribute("RichOpenFile",pd.name(),pd.value().getFileName(),pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichOpenFile",pd.name(),pd.value().getFileName(),pd.fieldDescription(),pd.toolTip());
parElem.setAttribute("exts_cardinality",pd.exts.size());
for(int ii = 0; ii < pd.exts.size();++ii)
parElem.setAttribute(QString("ext_val")+QString::number(ii),pd.exts[ii]);
@ -193,14 +193,14 @@ void RichParameterXMLVisitor::visit( RichOpenFile& pd )
void RichParameterXMLVisitor::visit( RichSaveFile& pd )
{
fillRichParameterAttribute("RichSaveFile",pd.name(),pd.value().getFileName(),pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichSaveFile",pd.name(),pd.value().getFileName(),pd.fieldDescription(),pd.toolTip());
parElem.setAttribute("ext",pd.ext);
}
void RichParameterXMLVisitor::visit( RichMesh& pd )
{
// MeshDecoration* dec = reinterpret_cast<MeshDecoration*>(pd.pd);
fillRichParameterAttribute("RichMesh",pd.name(),QString::number(pd.meshindex),pd.fieldDesc,pd.tooltip);
fillRichParameterAttribute("RichMesh",pd.name(),QString::number(pd.meshindex),pd.fieldDescription(),pd.toolTip());
}
void RichParameterValueToStringVisitor::visit( RichBool& pd )

View File

@ -128,8 +128,8 @@ AbsPercWidget::AbsPercWidget(QWidget *p, RichAbsPerc* rabs):MeshLabWidget(p,rabs
m_min = rabs->min;
m_max = rabs->max;
fieldDesc = new QLabel(rp->fieldDesc + " (abs and %)",this);
fieldDesc->setToolTip(rp->tooltip);
fieldDesc = new QLabel(rp->fieldDescription() + " (abs and %)",this);
fieldDesc->setToolTip(rp->toolTip());
absSB = new QDoubleSpinBox(this);
percSB = new QDoubleSpinBox(this);
@ -246,8 +246,8 @@ Point3fWidget::Point3fWidget(QWidget *p, RichPoint3f* rpf, QWidget *gla_curr): M
//qDebug("Creating a Point3fWidget");
paramName = rpf->name();
//int row = gridLay->rowCount() - 1;
descLab = new QLabel(rpf->fieldDesc,this);
descLab->setToolTip(rpf->fieldDesc);
descLab = new QLabel(rpf->fieldDescription(),this);
descLab->setToolTip(rpf->fieldDescription());
//gridLay->addWidget(descLab,row,0);
vlay = new QHBoxLayout();
@ -386,8 +386,8 @@ Matrix44fWidget::Matrix44fWidget(QWidget *p, RichMatrix44f* rpf, QWidget *gla_c
paramName = rpf->name();
//int row = gridLay->rowCount() - 1;
descLab = new QLabel(rpf->fieldDesc,this);
descLab->setToolTip(rpf->fieldDesc);
descLab = new QLabel(rpf->fieldDescription(),this);
descLab->setToolTip(rpf->fieldDescription());
//gridLay->addWidget(descLab,row,0,Qt::AlignTop);
vlay = new QVBoxLayout();
lay44 = new QGridLayout();
@ -547,8 +547,8 @@ ShotfWidget::ShotfWidget(QWidget *p, RichShotf* rpf, QWidget *gla_curr): MeshLab
paramName = rpf->name();
//int row = gridLay->rowCount() - 1;
descLab = new QLabel(rpf->fieldDesc,p);
descLab->setToolTip(rpf->fieldDesc);
descLab = new QLabel(rpf->fieldDescription(),p);
descLab->setToolTip(rpf->fieldDescription());
//gridLay->addWidget(descLab,row,0,Qt::AlignTop);
hlay = new QHBoxLayout();
@ -664,7 +664,7 @@ ComboWidget::ComboWidget(QWidget *p, RichParameter* rpar) :MeshLabWidget(p,rpar)
void ComboWidget::Init(QWidget *p,int defaultEnum, QStringList values)
{
enumLabel = new QLabel(this);
enumLabel->setText(rp->fieldDesc);
enumLabel->setText(rp->fieldDescription());
enumCombo = new QComboBox(this);
enumCombo->addItems(values);
setIndex(defaultEnum);
@ -1041,7 +1041,7 @@ DynamicFloatWidget::DynamicFloatWidget(QWidget *p, RichDynamicFloat* rdf):MeshLa
valueSlider = new QSlider(Qt::Horizontal,this);
valueSlider->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
fieldDesc = new QLabel(rp->fieldDesc,this);
fieldDesc = new QLabel(rp->fieldDescription(),this);
valueSlider->setMinimum(0);
valueSlider->setMaximum(100);
valueSlider->setValue(floatToInt(rp->value().getFloat()));
@ -1156,7 +1156,7 @@ MeshLabWidget::MeshLabWidget( QWidget* p,RichParameter* rpar )
//setParent(p);
if (rp!= NULL)
{
helpLab = new QLabel("<small>"+rpar->tooltip +"</small>",this);
helpLab = new QLabel("<small>"+rpar->toolTip() +"</small>",this);
helpLab->setTextFormat(Qt::RichText);
helpLab->setWordWrap(true);
helpLab->setVisible(false);
@ -1200,8 +1200,8 @@ void MeshLabWidget::addWidgetToGridLayout( QGridLayout* lay, const int r)
BoolWidget::BoolWidget(QWidget* p, RichBool* rb )
:MeshLabWidget(p,rb)
{
cb = new QCheckBox(rp->fieldDesc,this);
cb->setToolTip(rp->tooltip);
cb = new QCheckBox(rp->fieldDescription(),this);
cb->setToolTip(rp->toolTip());
cb->setChecked(rp->value().getBool());
connect(cb,SIGNAL(stateChanged(int)),p,SIGNAL(parameterChanged()));
@ -1239,11 +1239,11 @@ void BoolWidget::addWidgetToGridLayout(QGridLayout* lay,const int r)
LineEditWidget::LineEditWidget( QWidget* p,RichParameter* rpar )
:MeshLabWidget(p,rpar)
{
lab = new QLabel(rp->fieldDesc,this);
lab = new QLabel(rp->fieldDescription(),this);
lned = new QLineEdit(this);
//int row = gridLay->rowCount() -1;
lab->setToolTip(rp->tooltip);
lab->setToolTip(rp->toolTip());
//gridLay->addWidget(lab,row,0);
//gridLay->addWidget(lned,row,1);
connect(lned,SIGNAL(editingFinished()),this,SLOT(changeChecker()));
@ -1350,7 +1350,7 @@ ColorWidget::ColorWidget(QWidget *p, RichColor* newColor)
:MeshLabWidget(p,newColor),pickcol()
{
colorLabel = new QLabel(this);
descLabel = new QLabel(rp->fieldDesc,this);
descLabel = new QLabel(rp->fieldDescription(),this);
colorButton = new QPushButton(this);
colorButton->setAutoFillBackground(true);
colorButton->setFlat(true);
@ -1518,7 +1518,7 @@ IOFileWidget::IOFileWidget( QWidget* p,RichParameter* rpar )
filename = new QLineEdit(this);
filename->setText(tr(""));
browse = new QPushButton(this);
descLab = new QLabel(rp->fieldDesc,this);
descLab = new QLabel(rp->fieldDescription(),this);
browse->setText("...");
//const QColor cl = rp->pd->defvalue().getColor();
//resetWidgetValue();

View File

@ -120,7 +120,7 @@ public:
foreach(RichParameter* pp, FPM[filterAction->text()].paramList)
{
fprintf(fp,"<TR><TD> \\c %s </TD> <TD> %s </TD> <TD><i> %s -- </i></TD> </TR>\n",
qUtf8Printable(pp->value().typeName()), qUtf8Printable(pp->fieldDesc), qUtf8Printable(pp->tooltip));
qUtf8Printable(pp->value().typeName()), qUtf8Printable(pp->fieldDescription()), qUtf8Printable(pp->toolTip()));
}
fprintf(fp,"</TABLE>\n");
}