NorMIT-nav  16.5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxProperty.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) 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 #include "cxProperty.h"
35 
36 namespace cx
37 {
38 
40  QObject(), mEnabled(true), mAdvanced(false), mGroup("")
41 {}
42 
43 
44 PropertyPtr Property::findProperty(std::vector<PropertyPtr> properties, QString id)
45 {
46  for(int i=0; i<properties.size(); ++i)
47  {
48  PropertyPtr adapter = properties[i];
49  if(QString::compare(adapter->getUid(), id) == 0)
50  {
51  return adapter;
52  }
53  }
54  return PropertyPtr();
55 }
56 
58 {
59  return mEnabled;
60 }
61 
63 {
64  return mAdvanced;
65 }
66 
67 QString Property::getGroup() const
68 {
69  return mGroup;
70 }
71 
72 bool Property::setEnabled(bool enabling)
73 {
74 
75  if(mEnabled == enabling)
76  return false;
77 
78  mEnabled = enabling;
79  emit changed();
80 
81  return true;
82 }
83 
84 bool Property::setAdvanced(bool advanced)
85 {
86  if(advanced == mAdvanced)
87  return false;
88 
89  mAdvanced = advanced;
90  emit changed();
91 
92  return true;
93 }
94 
95 bool Property::setGroup(QString name)
96 {
97  if(name == mGroup)
98  return false;
99 
100  mGroup = name;
101  emit changed();
102 
103  return true;
104 }
105 
106 
107 } //namespace cx
static PropertyPtr findProperty(std::vector< PropertyPtr > properties, QString id)
Definition: cxProperty.cpp:44
virtual bool setEnabled(bool enabled)
Set the enabled/disabled state of the Property.
Definition: cxProperty.cpp:72
virtual bool setGroup(QString name)
Flag the adapter as part of a group.
Definition: cxProperty.cpp:95
bool mEnabled
Definition: cxProperty.h:94
boost::shared_ptr< class Property > PropertyPtr
virtual bool getEnabled() const
Get the enabled/disabled state of the Property.
Definition: cxProperty.cpp:57
bool mAdvanced
Definition: cxProperty.h:95
void changed()
emit when the underlying data value is changed: The user interface will be updated.
QString mGroup
Definition: cxProperty.h:96
virtual bool getAdvanced() const
Get the advanced flag of the adapter.
Definition: cxProperty.cpp:62
virtual QString getGroup() const
Flag the adapter as part of a group.
Definition: cxProperty.cpp:67
virtual bool setAdvanced(bool advanced)
Set the advanced flag of the adapter.
Definition: cxProperty.cpp:84