NorMIT-nav  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
cx::FilePathPropertyBase::getValueAsVariant
virtual QVariant getValueAsVariant() const
Definition: cxFilePathPropertyBase.h:67
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::FilePathPropertyBase::mName
QString mName
emitted when the value is set using setValue() (similar to changed(), but more constrained)
Definition: cxFilePathPropertyBase.h:86
cxXmlOptionItem.h
cx::FilePathPropertyBase::~FilePathPropertyBase
virtual ~FilePathPropertyBase()
Definition: cxFilePathPropertyBase.h:62
cx::FilePathPropertyBase::mStore
XmlOptionItem mStore
Definition: cxFilePathPropertyBase.h:90
cx::FilePathPropertyBase::getUid
virtual QString getUid() const
Definition: cxFilePathPropertyBase.h:76
cx::EmbeddedFilepath
Definition: cxFilePathPropertyBase.h:31
cx::FilePathPropertyBase
Base class for properties using a file path.
Definition: cxFilePathPropertyBase.h:57
cx::XmlOptionItem
Helper class for storing one string value in an xml document.
Definition: cxXmlOptionItem.h:38
cx::FilePathPropertyBase::setValueFromVariant
virtual void setValueFromVariant(QVariant val)
Definition: cxFilePathPropertyBase.h:71
cxProperty.h
cx::FilePathPropertyBase::mFilePath
EmbeddedFilepath mFilePath
Definition: cxFilePathPropertyBase.h:89
cx::FilePathPropertyBase::mHelp
QString mHelp
Definition: cxFilePathPropertyBase.h:88
cx::Property
Superclass for all data adapters.
Definition: cxProperty.h:43
cx::FilePathPropertyBase::mUid
QString mUid
Definition: cxFilePathPropertyBase.h:87