NorMIT-nav  22.09
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 }
cx::BoolProperty::initialize
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
Definition: cxBoolProperty.cpp:30
cx::BoolProperty
Definition: cxBoolProperty.h:40
cx::BoolProperty::setHelp
void setHelp(QString val)
Definition: cxBoolProperty.cpp:58
cx::BoolProperty::getValue
virtual bool getValue() const
get the data value.
Definition: cxBoolProperty.cpp:64
cx::BoolProperty::getUid
virtual QString getUid() const
Definition: cxBoolProperty.cpp:48
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::BoolProperty::getDisplayName
virtual QString getDisplayName() const
name of data entity. Used for display to user.
Definition: cxBoolProperty.cpp:42
cx::Property::changed
void changed()
emit when the underlying data value is changed: The user interface will be updated.
cx::BoolPropertyPtr
boost::shared_ptr< class BoolProperty > BoolPropertyPtr
Definition: cxPlusConnectWidget.h:29
cx::BoolProperty::getHelp
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
Definition: cxBoolProperty.cpp:53
cx::XmlOptionItem
Helper class for storing one string value in an xml document.
Definition: cxXmlOptionItem.h:38
cx::BoolProperty::valueWasSet
void valueWasSet()
cxTypeConversions.h
cx::BoolProperty::setValue
virtual bool setValue(bool value)
set the data value.
Definition: cxBoolProperty.cpp:69
cx::XmlOptionItem::writeValue
void writeValue(const QString &val)
Definition: cxXmlOptionItem.cpp:189
cxBoolProperty.h