Stellarium 0.15.2
TuiNode.hpp
1 /*
2  * Copyright (C) 2009 Matthew Gates
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
17  */
18 
19 #ifndef _TUINODE_HPP_
20 #define _TUINODE_HPP_ 1
21 
22 #include <QObject>
23 #include <QString>
24 #include <QList>
25 
30 typedef struct
31 {
32  bool accepted;
33  class TuiNode* newNode;
35 
42 class TuiNode : public QObject
43 {
44  Q_OBJECT
45 public:
51  TuiNode(const QString& text, TuiNode* parent=NULL, TuiNode* prev=NULL);
52  virtual TuiNodeResponse handleKey(int key);
53  virtual TuiNodeResponse navigation(int key);
54  virtual QString getDisplayText();
55  virtual TuiNode* getParentNode() {return parentNode;}
56  virtual void setParentNode(TuiNode* n) {parentNode=n; updateNodeNumber();}
57  virtual TuiNode* getChildNode() {return childNode;}
59  virtual void setChildNode(TuiNode* n) {childNode=n; n->setParent(this);}
60  virtual TuiNode* getPrevNode() {return prevNode;}
61  virtual void setPrevNode(TuiNode* n) {prevNode=n; updateNodeNumber();}
62  virtual TuiNode* getNextNode() {return nextNode;}
63  virtual void setNextNode(TuiNode* n) {nextNode=n;}
66  virtual void loopToTheLast();
67 
68  int getNodeNumber() {return nodeNumber;}
69  QList<int> getAncestorsNumbers() {return ancestorsNumbers;}
70 
71 protected:
72  TuiNode* parentNode;
73  TuiNode* childNode;
74  TuiNode* prevNode;
75  TuiNode* nextNode;
77  QString prefixText;
78  QString displayText;
84  QList<int> ancestorsNumbers;
86  void updateNodeNumber();
87 };
88 
89 #endif /* _TUINODE_HPP_ */
90 
int nodeNumber
Number of the node in the current menu.
Definition: TuiNode.hpp:81
QString prefixText
Text of the prefix containing the hierarchical node number.
Definition: TuiNode.hpp:77
QList< int > ancestorsNumbers
Contains the numbers of the parent nodes in the hierarchy.
Definition: TuiNode.hpp:84
TuiNode objects are linked together in a network of nodes to form the structure of a menu which may b...
Definition: TuiNode.hpp:42
TuiNode(const QString &text, TuiNode *parent=NULL, TuiNode *prev=NULL)
Create a TuiNode.
virtual void loopToTheLast()
Set prevNode to the last of the chain of nextNode-s.
virtual void setChildNode(TuiNode *n)
This also takes ownership of the child through OObject->setParent.
Definition: TuiNode.hpp:59
A TuiNodeResponse contains a flag, "accepted" if a keystroke was accepted And a link to a node...
Definition: TuiNode.hpp:30
void updateNodeNumber()
Updates nodeNumber, ancestorNumbers and prefixText.