#3325: DlgPropertyLink as editor of Tip property

This commit is contained in:
wmayer
2018-01-28 22:37:03 +01:00
parent 5d1fb6937e
commit f9b04b1551
4 changed files with 53 additions and 6 deletions

View File

@@ -196,6 +196,42 @@ std::vector<DocumentObject*> DocumentObject::getOutList(void) const
return ret;
}
std::vector<App::DocumentObject*> DocumentObject::getOutListOfProperty(App::Property* prop) const
{
std::vector<DocumentObject*> ret;
if (!prop || prop->getContainer() != this)
return ret;
if (prop->isDerivedFrom(PropertyLinkList::getClassTypeId())) {
const std::vector<DocumentObject*> &OutList = static_cast<PropertyLinkList*>(prop)->getValues();
for (std::vector<DocumentObject*>::const_iterator It2 = OutList.begin();It2 != OutList.end(); ++It2) {
if (*It2)
ret.push_back(*It2);
}
}
else if (prop->isDerivedFrom(PropertyLinkSubList::getClassTypeId())) {
const std::vector<DocumentObject*> &OutList = static_cast<PropertyLinkSubList*>(prop)->getValues();
for (std::vector<DocumentObject*>::const_iterator It2 = OutList.begin();It2 != OutList.end(); ++It2) {
if (*It2)
ret.push_back(*It2);
}
}
else if (prop->isDerivedFrom(PropertyLink::getClassTypeId())) {
if (static_cast<PropertyLink*>(prop)->getValue())
ret.push_back(static_cast<PropertyLink*>(prop)->getValue());
}
else if (prop->isDerivedFrom(PropertyLinkSub::getClassTypeId())) {
if (static_cast<PropertyLinkSub*>(prop)->getValue())
ret.push_back(static_cast<PropertyLinkSub*>(prop)->getValue());
}
else if (prop == &ExpressionEngine) {
// Get document objects that this document object relies on
ExpressionEngine.getDocumentObjectDeps(ret);
}
return ret;
}
#ifdef USE_OLD_DAG
std::vector<App::DocumentObject*> DocumentObject::getInList(void) const
{

View File

@@ -138,7 +138,9 @@ public:
//@{
/// returns a list of objects this object is pointing to by Links
std::vector<App::DocumentObject*> getOutList(void) const;
/// returns a list of objects this object is pointing to by Links and all further descended
/// returns a list of objects linked by the property
std::vector<App::DocumentObject*> getOutListOfProperty(App::Property*) const;
/// returns a list of objects this object is pointing to by Links and all further descended
std::vector<App::DocumentObject*> getOutListRecursive(void) const;
/// get all possible paths from this to another object following the OutList
std::vector<std::list<App::DocumentObject*> > getPathsByOutList(App::DocumentObject* to) const;

View File

@@ -48,7 +48,7 @@ DlgPropertyLink::DlgPropertyLink(const QStringList& list, QWidget* parent, Qt::W
: QDialog(parent, fl), link(list), ui(new Ui_DlgPropertyLink)
{
#ifdef FC_DEBUG
assert(list.size() == 4);
assert(list.size() >= 5);
#endif
ui->setupUi(this);
findObjects(ui->checkObjectType->isChecked(), QString());
@@ -125,6 +125,7 @@ void DlgPropertyLink::findObjects(bool on, const QString& searchText)
QString docName = link[0]; // document name
QString objName = link[1]; // internal object name
QString parName = link[3]; // internal object name of the parent of the link property
QString proName = link[4]; // property name
bool isSingleSelection = (ui->listWidget->selectionMode() == QAbstractItemView::SingleSelection);
App::Document* doc = App::GetApplication().getDocument((const char*)docName.toLatin1());
@@ -155,8 +156,10 @@ void DlgPropertyLink::findObjects(bool on, const QString& searchText)
App::DocumentObject* par = doc->getObject((const char*)parName.toLatin1());
if (par) {
// for multi-selection we need all objects
if (isSingleSelection)
outList = par->getOutList();
if (isSingleSelection) {
App::Property* prop = par->getPropertyByName((const char*)proName.toLatin1());
outList = par->getOutListOfProperty(prop);
}
outList.push_back(par);
}

View File

@@ -3493,7 +3493,8 @@ QVariant PropertyLinkItem::value(const App::Property* prop) const
const App::PropertyLink* prop_link = static_cast<const App::PropertyLink*>(prop);
App::PropertyContainer* c = prop_link->getContainer();
// the list has four elements: [document name, internal name, label, internal name of container]
// the list has five elements:
// [document name, internal name, label, internal name of container, property name]
App::DocumentObject* obj = prop_link->getValue();
QStringList list;
if (obj) {
@@ -3527,6 +3528,8 @@ QVariant PropertyLinkItem::value(const App::Property* prop) const
list << QString::fromLatin1("Null");
}
list << QString::fromLatin1(prop->getName());
return QVariant(list);
}
@@ -3675,7 +3678,8 @@ QVariant PropertyLinkListItem::value(const App::Property* prop) const
objName = QString::fromLatin1("Null");
}
// each item is a list of four elements: [document name, internal name, label, internal name of container]
// each item is a list of five elements:
//[document name, internal name, label, internal name of container, property name]
// the variant list contains at least one item
std::vector<App::DocumentObject*> obj = prop_link->getValues();
QVariantList varList;
@@ -3686,6 +3690,7 @@ QVariant PropertyLinkListItem::value(const App::Property* prop) const
list << QString::fromLatin1((*it)->getNameInDocument());
list << QString::fromUtf8((*it)->Label.getValue());
list << objName;
list << QString::fromLatin1(prop->getName());
varList << list;
}
}
@@ -3706,6 +3711,7 @@ QVariant PropertyLinkListItem::value(const App::Property* prop) const
// the object label
list << QString::fromLatin1("");
list << objName;
list << QString::fromLatin1(prop->getName());
varList << list;
}