CustusX  22.04-rc5
An IGT application
cxStringPropertyBase.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 
12 
13 #ifndef CXSTRINGPROPERTYBASE_H_
14 #define CXSTRINGPROPERTYBASE_H_
15 
16 #include "cxResourceExport.h"
17 
18 #include <boost/shared_ptr.hpp>
19 #include <QObject>
20 #include <QString>
21 #include <QStringList>
22 #include <QComboBox>
23 #include "cxProperty.h"
24 
25 namespace cx
26 {
27 
65 class cxResource_EXPORT StringPropertyBase: public Property
66 {
67  Q_OBJECT
68 public:
69  StringPropertyBase() : mGuiRepresentation(grSTRING) {}
70  virtual ~StringPropertyBase(){}
71 
72 public:
74  {
76  grFILENAME
77  };
78 
79  // basic methods
80  virtual QString getDisplayName() const = 0;
81 
82  virtual QVariant getValueAsVariant() const
83  {
84  return QVariant(this->getValue());
85  }
86  virtual void setValueFromVariant(QVariant val)
87  {
88  this->setValue(val.toString());
89  }
90 
91  virtual QString getUid() const { return this->getDisplayName()+"_uid"; }
92  virtual bool setValue(const QString& value) = 0;
93  virtual QString getValue() const = 0;
94 
95 public:
96  /*
97  * If set: setValue will always fail. Adapter is used for display only.
98  */
99  virtual bool isReadOnly() const { return false; }
100  /*
101  * If true: value will always be within range. setValue using other values will fail.
102  */
103  virtual bool getAllowOnlyValuesInRange() const { return true; }
104  // optional methods
105  virtual QString getHelp() const
106  {
107  return QString();
108  }
109  virtual QStringList getValueRange() const
110  {
111  return QStringList();
112  }
113  virtual QString convertInternal2Display(QString internal)
114  {
115  return internal;
116  }
117 
118  virtual void setGuiRepresentation(GuiRepresentation type) { mGuiRepresentation = type; };
119  virtual GuiRepresentation getGuiRepresentation() { return mGuiRepresentation; };
120 
121 protected:
123 
124 };
125 typedef boost::shared_ptr<StringPropertyBase> StringPropertyBasePtr;
126 
127 } // namespace cx
128 
129 #endif /* CXSTRINGPROPERTYBASE_H_ */
virtual void setGuiRepresentation(GuiRepresentation type)
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
Superclass for all data adapters.
Definition: cxProperty.h:43
GuiRepresentation mGuiRepresentation
virtual void setValueFromVariant(QVariant val)
Abstract interface for interaction with internal string-valued data.
boost::shared_ptr< class StringPropertyBase > StringPropertyBasePtr
virtual bool isReadOnly() const
virtual QString convertInternal2Display(QString internal)
range of value. Use if data is constrained to a set.
virtual bool getAllowOnlyValuesInRange() const
virtual QString getUid() const
virtual QVariant getValueAsVariant() const
virtual QStringList getValueRange() const
Namespace for all CustusX production code.