15 #include <QDomElement> 16 #include <QStringList> 35 void EmbeddedFilepath::evaluate(QString* foundRoot,
bool* found, QString* foundRelative, QString* foundAbsolute)
const 37 *foundRelative = mFilePath;
39 *foundRoot = mRoots.front();
40 *foundAbsolute = mFilePath;
43 foreach (QString root, mRoots)
45 root = QDir::cleanPath(root);
46 if (!mFilePath.isEmpty() && QDir(root).exists(mFilePath))
48 *foundRelative = QDir(root).relativeFilePath(mFilePath);
50 *foundAbsolute = QDir(root).absoluteFilePath(mFilePath);
53 if (foundRelative->contains(
".."))
56 *foundRelative = *foundAbsolute;
71 QString root, relative, absolute;
72 this->evaluate(&root, &found, &relative, &absolute);
80 QString root, relative, absolute;
81 this->evaluate(&root, &found, &relative, &absolute);
89 QString root, relative, absolute;
90 this->evaluate(&root, &found, &relative, &absolute);
98 QString root, relative, absolute;
99 this->evaluate(&root, &found, &relative, &absolute);
117 FilePathProperty::FilePathProperty()
129 retval->mName = name.isEmpty() ? uid : name;
130 retval->mHelp = help;
131 retval->mFilePath.setFilepath(value);
132 foreach (QString path, paths)
133 retval->mFilePath.appendRootPath(path);
135 retval->mFilePath.setFilepath(retval->mStore.readValue(value));
166 return mFilePath.getRelativeFilepath();
171 if (val == this->getValue())
174 mFilePath.setFilepath(val);
175 mStore.writeValue(mFilePath.getRelativeFilepath());
188 return this->getValue();
193 this->setValue(val.toString());
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
QStringList getRootPaths() const
return the root of the existing root, first if no existing.
virtual void setHelp(QString val)
virtual QString getValue() const
get the data value.
QString getAbsoluteFilepath() const
return absolute filepath, select the existing root
void setFilepath(QString filename)
relative to one of the root paths or absolute
Helper class for storing one string value in an xml document.
virtual void setValueFromVariant(QVariant val)
void appendRootPath(QString path)
virtual QVariant getValueAsVariant() const
virtual QString getUid() const
static FilePathPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList paths, QDomNode root=QDomNode())
QString getRelativeFilepath() const
return filepath relative to root.
boost::shared_ptr< class FilePathProperty > FilePathPropertyPtr
virtual QString getDisplayName() const
name of data entity. Used for display to user.
virtual bool setValue(const QString &value)
set the data value.
QString getRootPath() const
return the root of the existing root, first if no existing.
EmbeddedFilepath getEmbeddedPath()
Namespace for all CustusX production code.