36 #include <QDomElement>
37 #include <QStringList>
56 void EmbeddedFilepath::evaluate(QString* foundRoot,
bool* found, QString* foundRelative, QString* foundAbsolute)
const
58 *foundRelative = mFilePath;
60 *foundRoot = mRoots.front();
61 *foundAbsolute = mFilePath;
64 foreach (QString root, mRoots)
66 root = QDir::cleanPath(root);
67 if (!mFilePath.isEmpty() && QDir(root).exists(mFilePath))
69 *foundRelative = QDir(root).relativeFilePath(mFilePath);
71 *foundAbsolute = QDir(root).absoluteFilePath(mFilePath);
74 if (foundRelative->contains(
".."))
77 *foundRelative = *foundAbsolute;
92 QString root, relative, absolute;
93 this->evaluate(&root, &found, &relative, &absolute);
101 QString root, relative, absolute;
102 this->evaluate(&root, &found, &relative, &absolute);
110 QString root, relative, absolute;
111 this->evaluate(&root, &found, &relative, &absolute);
119 QString root, relative, absolute;
120 this->evaluate(&root, &found, &relative, &absolute);
138 FilePathProperty::FilePathProperty()
150 retval->mName = name.isEmpty() ? uid : name;
151 retval->mHelp = help;
152 retval->mFilePath.setFilepath(value);
153 foreach (QString path, paths)
154 retval->mFilePath.appendRootPath(path);
156 retval->mFilePath.setFilepath(retval->mStore.readValue(value));
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
void changed()
emit when the underlying data value is changed: The user interface will be updated.
void writeValue(const QString &val)
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()