Skip to content

Commit

Permalink
App: fix PropertyXLink file path saving
Browse files Browse the repository at this point in the history
Also modified ProeprtyLinkItem to show file path as tooltip.
  • Loading branch information
realthunder authored and wwmayer committed Nov 10, 2019
1 parent a85ce19 commit b0c9325
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
11 changes: 4 additions & 7 deletions src/App/PropertyLinks.cpp
Expand Up @@ -2902,6 +2902,8 @@ void PropertyXLink::setValue(App::DocumentObject *lValue,
if(lValue == owner)
throw Base::ValueError("self linking");

aboutToSetValue();

DocInfoPtr info;
const char *name = "";
if(lValue) {
Expand All @@ -2921,7 +2923,6 @@ void PropertyXLink::setValue(App::DocumentObject *lValue,
}

setFlag(LinkDetached,false);
aboutToSetValue();
#ifndef USE_OLD_DAG
if (!owner->testStatus(ObjectStatus::Destroy) && _pcScope!=LinkScope::Hidden) {
if(_pcLink)
Expand All @@ -2934,9 +2935,7 @@ void PropertyXLink::setValue(App::DocumentObject *lValue,
unlink();
docInfo = info;
}
if(docInfo)
filePath = docInfo->filePath();
else
if(!docInfo)
filePath.clear();
_pcLink=lValue;
if(docInfo && docInfo->pcDoc)
Expand Down Expand Up @@ -2981,9 +2980,7 @@ void PropertyXLink::setValue(std::string &&filename, std::string &&name,
unlink();
docInfo = info;
}
if(docInfo)
filePath = docInfo->filePath();
else
if(!docInfo)
filePath.clear();
if(docInfo && docInfo->pcDoc)
stamp=docInfo->pcDoc->LastModifiedDate.getValue();
Expand Down
4 changes: 4 additions & 0 deletions src/App/PropertyLinks.h
Expand Up @@ -1125,6 +1125,10 @@ class AppExport PropertyXLink : public PropertyLinkGlobal

virtual void setAllowPartial(bool enable) override;

const char *getFilePath() const {
return filePath.c_str();
}

protected:
void unlink();
void detach();
Expand Down
15 changes: 12 additions & 3 deletions src/Gui/propertyeditor/PropertyItem.cpp
Expand Up @@ -3625,10 +3625,19 @@ QVariant PropertyLinkItem::toString(const QVariant& prop) const
}

QVariant PropertyLinkItem::data(int column, int role) const {
if(propertyItems.size() && column == 1 && role == Qt::TextColorRole) {
if(propertyItems.size() && column == 1
&& (role == Qt::TextColorRole || role == Qt::ToolTipRole))
{
auto xlink = Base::freecad_dynamic_cast<const App::PropertyXLink>(propertyItems[0]);
if(xlink && xlink->checkRestore()>1)
return QVariant::fromValue(QColor(0xff,0,0));
if(xlink) {
if(role==Qt::TextColorRole && xlink->checkRestore()>1)
return QVariant::fromValue(QColor(0xff,0,0));
else if(role == Qt::ToolTipRole) {
const char *filePath = xlink->getFilePath();
if(filePath && filePath[0])
return QVariant::fromValue(QString::fromUtf8(filePath));
}
}
}
return PropertyItem::data(column,role);
}
Expand Down

0 comments on commit b0c9325

Please sign in to comment.