Merge branch 'master' into multinode

This commit is contained in:
Russell Greene
2017-01-20 18:58:33 -07:00
5 changed files with 71 additions and 2 deletions
+25
View File
@@ -22,7 +22,32 @@ public:
QString
caption() const override
{ return QString("Division"); }
virtual bool
portCaptionVisible(PortType portType, PortIndex portIndex) const override
{ return true; }
virtual QString
portCaption(PortType portType, PortIndex portIndex) const override
{
switch (portType)
{
case PortType::In:
if (portIndex == 0)
return QString("Dividend");
else if (portIndex == 1)
return QString("Divisor");
break;
case PortType::Out:
return QString("Result");
default:
break;
}
return QString("");
}
QString
name() const override
{ return QString("Division"); }
+25
View File
@@ -24,6 +24,31 @@ public:
caption() const override
{ return QString("Subtraction"); }
virtual bool
portCaptionVisible(PortType portType, PortIndex portIndex) const override
{ return true; }
virtual QString
portCaption(PortType portType, PortIndex portIndex) const override
{
switch (portType)
{
case PortType::In:
if (portIndex == 0)
return QString("Minuend");
else if (portIndex == 1)
return QString("Subtrahend");
break;
case PortType::Out:
return QString("Result");
default:
break;
}
return QString("");
}
QString
name() const override
{ return QString("Subtraction"); }
+8
View File
@@ -29,6 +29,14 @@ public:
virtual bool
captionVisible() const { return true; }
/// Port caption is used in GUI to label individual ports
virtual QString
portCaption(PortType portType, PortIndex portIndex) const { return QString(""); }
/// It is possible to hide port caption in GUI
virtual bool
portCaptionVisible(PortType portType, PortIndex portIndex) const { return false; }
/// Name makes this model unique
virtual QString
name() const = 0;
+7 -1
View File
@@ -256,7 +256,13 @@ portWidth(PortType portType) const
for (auto i = 0ul; i < _dataModel->nPorts(portType); ++i)
{
auto const &name = _dataModel->dataType(PortType::In, i).name;
QString name;
if (_dataModel->portCaptionVisible(portType, i))
name = _dataModel->portCaption(portType, i);
else
name = _dataModel->dataType(portType, i).name;
width = std::max(unsigned(_fontMetrics.width(name)),
width);
}
+6 -1
View File
@@ -271,7 +271,12 @@ drawEntryLabels(QPainter * painter,
else
painter->setPen(nodeStyle.FontColor);
QString s = model->dataType(portType, i).name;
QString s;
if (model->portCaptionVisible(portType, i))
s = model->portCaption(portType, i);
else
s = model->dataType(portType, i).name;
auto rect = metrics.boundingRect(s);