Commit fa1887fa authored by Alex Diev's avatar Alex Diev
Browse files

IVE: Add tooltips

parent f12ae04c
Pipeline #7183 passed with stage
in 7 minutes and 50 seconds
......@@ -14,6 +14,7 @@
You should have received a copy of the GNU Library General Public License
along with this program. If not, see <https://www.gnu.org/licenses/lgpl-2.1.html>.
*/
#include "ivfunctiontypegraphicsitem.h"
#include "colors/colormanager.h"
......@@ -118,6 +119,17 @@ QSizeF IVFunctionTypeGraphicsItem::minimalSize() const
qMax(textSize.height(), shared::graphicsviewutils::kDefaultGraphicsItemSize.height()) };
}
QString IVFunctionTypeGraphicsItem::prepareTooltip() const
{
const QString title = shared::uniteNames<ivm::IVFunctionType *>({ entity() }, QString());
const QString instances = shared::uniteNames<QPointer<ivm::IVFunction>>(entity()->instances(), tr("Instances: "));
const QString ris = shared::uniteNames<ivm::IVInterface *>(entity()->ris(), tr("RI: "));
const QString pis = shared::uniteNames<ivm::IVInterface *>(entity()->pis(), tr("PI: "));
const QString ctxParamsStr = shared::uniteNames(entity()->contextParams(), tr("Parameters: "));
return shared::joinNonEmpty({ title, instances, ris, pis, ctxParamsStr }, QStringLiteral("<br>"));
}
void IVFunctionTypeGraphicsItem::updateTextPosition()
{
if (!m_textItem) {
......@@ -188,16 +200,6 @@ void IVFunctionTypeGraphicsItem::updateNameFromUi(const QString &name)
m_commandsStack->push(attributesCmd);
}
QString IVFunctionTypeGraphicsItem::prepareTooltip() const
{
const QString title = shared::uniteNames<ivm::IVFunctionType *>({ entity() }, QString());
const QString instances = shared::uniteNames<QPointer<ivm::IVFunction>>(entity()->instances(), tr("Instances: "));
const QString ris = shared::uniteNames<ivm::IVInterface *>(entity()->ris(), tr("RI: "));
const QString pis = shared::uniteNames<ivm::IVInterface *>(entity()->pis(), tr("PI: "));
return shared::joinNonEmpty({ title, instances, ris, pis }, QStringLiteral("<br>"));
}
bool IVFunctionTypeGraphicsItem::isRootItem() const
{
return !parentItem() && entity() && entity()->isRootObject();
......
......@@ -353,8 +353,11 @@ QString IVInterfaceGraphicsItem::ifaceLabel() const
QString IVInterfaceGraphicsItem::prepareTooltip() const
{
QString toolTip = shared::ui::VEInteractiveObject::prepareTooltip();
if (entity()->isProvided())
if (entity()->isProvided()) {
toolTip = shared::joinNonEmpty(
{ toolTip, shared::uniteNames(entity()->params(), tr("Parameters:")) }, QStringLiteral("<br>"));
return toolTip;
}
auto ri = entity()->as<const ivm::IVInterfaceRequired *>();
if (!ri)
......@@ -364,6 +367,8 @@ QString IVInterfaceGraphicsItem::prepareTooltip() const
if (toolTip != label)
toolTip = QString("%1<br><i><b>%2</b></i>").arg(label, toolTip);
toolTip = shared::joinNonEmpty(
{ toolTip, shared::uniteNames(entity()->params(), tr("Parameters:")) }, QStringLiteral("<br>"));
return toolTip;
}
......
......@@ -174,7 +174,7 @@ QString uniteNames(const QVector<Type> &collection, const QString &prefix)
{
QStringList result;
std::transform(collection.cbegin(), collection.cend(), std::back_inserter(result),
[](const Type &obj) { return obj ? obj->titleUI() : QString(); });
[](const Type &obj) { return toString(obj); });
const QString line = joinNonEmpty(result, QStringLiteral(", "));
return line.isEmpty() ? QString() : QString("<b>%1</b>%2").arg(prefix, line);
}
......
......@@ -265,4 +265,10 @@ bool InterfaceParameter::isNull() const
{
return BasicParameter::isNull() || this->operator==({});
}
QString toString(const BasicParameter &parameter)
{
return parameter.toString();
}
} // namespace shared
......@@ -135,7 +135,9 @@ protected:
Direction m_direction = { Direction::IN };
};
}
QString toString(const BasicParameter &contextParameter);
} // namespace shared
Q_DECLARE_METATYPE(shared::BasicParameter)
Q_DECLARE_METATYPE(shared::ContextParameter)
......
......@@ -222,4 +222,9 @@ VEModel *VEObject::model() const
return d->m_model;
}
QString toString(VEObject *object)
{
return object->titleUI();
}
}
......@@ -128,6 +128,8 @@ private:
const std::unique_ptr<VEObjectPrivate> d;
};
QString toString(VEObject *object);
}
Q_DECLARE_METATYPE(shared::VEObject *)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment