Optika GUI Toolik  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Optika_treeitem.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Optika: A Tool For Developing Parameter Obtaining GUIs
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, with Sandia Corporation, the
8 // U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Kurtis Nusbaum (klnusbaum@gmail.com)
38 //
39 // ***********************************************************************
40 // @HEADER
41 #ifndef OPTIKA_TREEITEM_HPP_
42 #define OPTIKA_TREEITEM_HPP_
43 
44 #include <QList>
45 #include <QVariant>
47 
52 namespace Optika{
56 class TreeItem{
57 public:
60 
69  TreeItem(const QString& name, RCP<ParameterEntry> parameterEntry, TreeItem *parent = 0, bool isHeader=false);
70 
74  ~TreeItem();
75 
77 
79 
80 
84  void printOut() const;
85 
87 
89 
90 
97  TreeItem *child(int row);
98 
106  return parameterEntry.getConst();
107  }
108 
113  inline bool hasEntry() const{
114  return parameterEntry != null;
115  }
116 
122  int childCount() const;
123 
129  const QList<TreeItem*> getChildItems();
130 
136  int columnCount() const;
137 
145  QVariant data(int column, int role = Qt::DisplayRole) const;
146 
152  TreeItem *parent();
153 
159  int row() const;
160 
167  bool hasValidValue() const;
168 
181  QString getCurrentInvalidValueMessage() const;
182 
188  void appendChild(TreeItem *child);
189 
195  bool changeValue(QVariant value);
196 
203 
210  static QString getTypeId(const RCP<const ParameterEntry> parameter);
211 
212 
214 
215 private:
216 
219 
223  const QString name;
224 
228  QString myTypeId;
229 
233  QList<TreeItem*> childItems;
234 
239 
244 
248  QString docString;
249 
253  bool isHeader;
254 
256 
259 
266  void changeValueForArray(QVariant value, QString type, bool twoD=false);
267 
269 
270 };
271 
272 
273 
274 }
275 
276 #endif /* OPTIKA_TREEITEM_HPP_ */
RCP< const T > getConst() const
void appendChild(TreeItem *child)
Appends a child TreeItem to the TreeItem.
QVariant data(int column, int role=Qt::DisplayRole) const
Returns the data located in a particular column.
int childCount() const
Gets the number of child nodes this item has.
bool changeValue(QVariant value)
Changes the value of the TreeItem. Should only be used with TreeItems that represent Parameters...
QString getCurrentInvalidValueMessage() const
Gets a message desribing the error with the current value.
bool isHeader
Whether or not this is a header treeitem.
TreeItem(const QString &name, RCP< ParameterEntry > parameterEntry, TreeItem *parent=0, bool isHeader=false)
Constructs a TreeItem object.
void printOut() const
Prints out the values in the TreeItem.
TreeItem * child(int row)
Returns the child treeitem in the row specified by the row argument.
const QString name
the name of the tree item.
RCP< const ParameterEntry > getEntry() const
Gets the ParameterEntry associated with this TreeItem.
The TreeItem class is the item class used by the TreeModel class.
bool hasValidValue() const
Determines whether or not the current value associated with the TreeItem is valid.
QList< TreeItem * > childItems
The childitems of the TreeItem.
~TreeItem()
Deconstrcutor for the TreeItem.
TreeItem * parentItem
The parent TreeItem.
void changeValueForArray(QVariant value, QString type, bool twoD=false)
Changes the value of an array.
int columnCount() const
How man columns the TreeItem has. Should always be 3.
QString myTypeId
The type id associated with this TreeItem.
RCP< ParameterEntry > parameterEntry
The ParameterEntry being represented by the TreeItem.
static QString getTypeId(const RCP< const ParameterEntry > parameter)
Gets the type id to be used for the TreeItem.
bool hasEntry() const
Returns whether or not this TreeItem has a ParameterEntry associated with it.
int row() const
Returns the row in which this TreeItem is located.
const QList< TreeItem * > getChildItems()
Gets a list of all the child items.
QString docString
The docString for the TreeItem.
TreeItem * parent()
Gets the parent TreeItem.
void setValidator(RCP< const ParameterEntryValidator > validator)
Sets the validator for the parameter the TreeItem represents.