Fraxinus  16.5.0-fx-rc6
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 
34 #ifndef CXSTRINGPROPERTYBASE_H_
35 #define CXSTRINGPROPERTYBASE_H_
36 
37 #include "cxResourceExport.h"
38 
39 #include <boost/shared_ptr.hpp>
40 #include <QObject>
41 #include <QString>
42 #include <QStringList>
43 #include <QComboBox>
44 #include "cxProperty.h"
45 
46 namespace cx
47 {
48 
86 class cxResource_EXPORT StringPropertyBase: public Property
87 {
88  Q_OBJECT
89 public:
90  StringPropertyBase() : mGuiRepresentation(grSTRING) {}
91  virtual ~StringPropertyBase(){}
92 
93 public:
95  {
97  grFILENAME
98  };
99 
100  // basic methods
101  virtual QString getDisplayName() const = 0;
102 
103  virtual QVariant getValueAsVariant() const
104  {
105  return QVariant(this->getValue());
106  }
107  virtual void setValueFromVariant(QVariant val)
108  {
109  this->setValue(val.toString());
110  }
111 
112  virtual QString getUid() const { return this->getDisplayName()+"_uid"; }
113  virtual bool setValue(const QString& value) = 0;
114  virtual QString getValue() const = 0;
115 
116 public:
117  /*
118  * If set: setValue will always fail. Adapter is used for display only.
119  */
120  virtual bool isReadOnly() const { return false; }
121  /*
122  * If true: value will always be within range. setValue using other values will fail.
123  */
124  virtual bool getAllowOnlyValuesInRange() const { return true; }
125  // optional methods
126  virtual QString getHelp() const
127  {
128  return QString();
129  }
130  virtual QStringList getValueRange() const
131  {
132  return QStringList();
133  }
134  virtual QString convertInternal2Display(QString internal)
135  {
136  return internal;
137  }
138 
139  virtual void setGuiRepresentation(GuiRepresentation type) { mGuiRepresentation = type; };
140  virtual GuiRepresentation getGuiRepresentation() { return mGuiRepresentation; };
141 
142 protected:
143  GuiRepresentation mGuiRepresentation;
144 
145 };
146 typedef boost::shared_ptr<StringPropertyBase> StringPropertyBasePtr;
147 
148 } // namespace cx
149 
150 #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:64
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