Add App::Link support to Cloud module

ONLY enabled if the Cloud Module is compiled into FreeCAD
    ALL files must be saved into a Cloud Based storage
    Add a Signal to the PropertyLink to enable support of external storage
    Put the Assembly Document as active document

Signed-off-by: Jean-Marie Verdun <jmverdun3@gmail.com>
This commit is contained in:
Jean-Marie Verdun
2020-07-12 19:51:23 -04:00
committed by Yorik van Havre
parent cb2099aa6b
commit 0b1af7c838
6 changed files with 87 additions and 13 deletions

View File

@@ -2463,6 +2463,19 @@ public:
const char *filename, App::Document *pDoc, bool relative, QString *fullPath = 0)
{
bool absolute;
// The path could be an URI, in that case
// TODO: build a far much more resilient approach to test for an URI
std::string prefix("https://");
std::string FileName(filename);
auto res = std::mismatch(prefix.begin(), prefix.end(), FileName.begin());
if ( res.first == prefix.end() )
{
// We do have an URI
QString path = QString::fromUtf8(filename);
if ( fullPath )
*fullPath = path;
return std::string(filename);
}
// make sure the filename is aboluste path
QString path = QDir::cleanPath(QString::fromUtf8(filename));
if((absolute=QFileInfo(path).isAbsolute())) {
@@ -2534,12 +2547,28 @@ public:
}
static QString getFullPath(const char *p) {
if(!p) return QString();
return QFileInfo(QString::fromUtf8(p)).canonicalFilePath();
}
QString path = QString::fromUtf8(p);;
std::string prefix("https://");
std::string Path(path.toStdString());
auto res = std::mismatch(prefix.begin(), prefix.end(), Path.begin());
if ( res.first == prefix.end() )
return(path);
else
{
if(!p) return QString();
return QFileInfo(QString::fromUtf8(p)).canonicalFilePath();
}
}
QString getFullPath() const {
return QFileInfo(myPos->first).canonicalFilePath();
QString path = myPos->first;
std::string prefix("https://");
std::string Path(path.toStdString());
auto res = std::mismatch(prefix.begin(), prefix.end(), Path.begin());
if ( res.first == prefix.end() )
return(path);
else
return QFileInfo(myPos->first).canonicalFilePath();
}
const char *filePath() const {
@@ -2984,6 +3013,7 @@ void PropertyXLink::setValue(std::string &&filename, std::string &&name,
DocumentObject *pObject=0;
DocInfoPtr info;
if(filename.size()) {
owner->getDocument()->signalLinkXsetValue(filename);
info = DocInfo::get(filename.c_str(),owner->getDocument(),this,name.c_str());
if(info->pcDoc)
pObject = info->pcDoc->getObject(name.c_str());