Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxFilePathPropertyBase.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 #ifndef CXFILEPATHPROPERTYBASE_H
12 #define CXFILEPATHPROPERTYBASE_H
13 
14 #include "cxProperty.h"
15 #include <QObject>
16 #include <QDomElement>
17 #include "cxXmlOptionItem.h"
18 
19 namespace cx
20 {
21 
31 class cxResource_EXPORT EmbeddedFilepath
32 {
33 public:
34  void appendRootPath(QString path);
35  void setFilepath(QString filename);
36 
37  QString getRelativeFilepath() const;
38  QString getAbsoluteFilepath() const;
39  bool exists() const;
40  QString getRootPath() const;
41  QStringList getRootPaths() const;
42 
43 private:
44  void evaluate(QString* foundRoot, bool* found, QString* foundRelative, QString* foundAbsolute) const;
45  QStringList mRoots;
46  QString mFilePath;
47 };
48 
57 class cxResource_EXPORT FilePathPropertyBase: public Property
58 {
59  Q_OBJECT
60 public:
63 
64  // basic methods
65  virtual QString getDisplayName() const;// = 0;///< name of data entity. Used for display to user.
66 
67  virtual QVariant getValueAsVariant() const
68  {
69  return QVariant(this->getValue());
70  }
71  virtual void setValueFromVariant(QVariant val)
72  {
73  this->setValue(val.toString());
74  }
75 
76  virtual QString getUid() const { return this->getDisplayName()+"_uid"; }
77  virtual bool setValue(const QString& value);// = 0; ///< set the data value.
78  virtual QString getValue() const;// = 0; ///< get the data value.
79 
80  EmbeddedFilepath getEmbeddedPath();
81 
82 signals:
83  void valueWasSet();
84 
85 protected:
86  QString mName;
87  QString mUid;
88  QString mHelp;
91 
92 };
93 }//cx
94 #endif // CXFILEPATHPROPERTYBASE_H
virtual QString getUid() const
virtual QVariant getValueAsVariant() const
Superclass for all data adapters.
Definition: cxProperty.h:43
Helper class for storing one string value in an xml document.
QString mName
emitted when the value is set using setValue() (similar to changed(), but more constrained) ...
Base class for properties using a file path.
virtual void setValueFromVariant(QVariant val)
Namespace for all CustusX production code.