Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxBoolProperty.cpp
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 /*
14  * sscBoolProperty.cpp
15  *
16  * Created on: Feb 7, 2011
17  * Author: christiana
18  */
19 
20 #include "cxBoolProperty.h"
21 #include <iostream>
22 #include "cxTypeConversions.h"
23 
24 namespace cx
25 {
26 
30 BoolPropertyPtr BoolProperty::initialize(const QString& uid, QString name, QString help, bool value,
31  QDomNode root)
32 {
33  BoolPropertyPtr retval(new BoolProperty());
34  retval->mUid = uid;
35  retval->mName = name.isEmpty() ? uid : name;
36  retval->mHelp = help;
37  retval->mStore = XmlOptionItem(uid, root.toElement());
38  retval->mValue = retval->mStore.readValue(QString::number(value)).toInt();
39  return retval;
40 }
41 
43 {
44  return mName;
45 }
46 
47 
48 QString BoolProperty::getUid() const
49 {
50  return mUid;
51 }
52 
53 QString BoolProperty::getHelp() const
54 {
55  return mHelp;
56 }
57 
58 void BoolProperty::setHelp(QString val)
59 {
60  mHelp = val;
61  emit changed();
62 }
63 
65 {
66  return mValue;
67 }
68 
69 bool BoolProperty::setValue(bool val)
70 {
71  if (val == mValue)
72  return false;
73 
74  mValue = val;
75  mStore.writeValue(QString::number(val));
76  emit valueWasSet();
77  emit changed();
78  return true;
79 }
80 
81 }
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
virtual bool setValue(bool value)
set the data value.
void setHelp(QString val)
virtual bool getValue() const
get the data value.
virtual QString getDisplayName() const
name of data entity. Used for display to user.
Helper class for storing one string value in an xml document.
void changed()
emit when the underlying data value is changed: The user interface will be updated.
void writeValue(const QString &val)
boost::shared_ptr< class BoolProperty > BoolPropertyPtr
QString readValue(const QString &defval) const
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
virtual QString getUid() const
Namespace for all CustusX production code.