Stellarium 0.14.3
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;}
58  virtual void setChildNode(TuiNode* n) {childNode=n;}
59  virtual TuiNode* getPrevNode() {return prevNode;}
60  virtual void setPrevNode(TuiNode* n) {prevNode=n; updateNodeNumber();}
61  virtual TuiNode* getNextNode() {return nextNode;}
62  virtual void setNextNode(TuiNode* n) {nextNode=n;}
65  virtual void loopToTheLast();
66 
67  int getNodeNumber() {return nodeNumber;}
68  QList<int> getAncestorsNumbers() {return ancestorsNumbers;}
69 
70 protected:
71  TuiNode* parentNode;
72  TuiNode* childNode;
73  TuiNode* prevNode;
74  TuiNode* nextNode;
76  QString prefixText;
77  QString displayText;
83  QList<int> ancestorsNumbers;
85  void updateNodeNumber();
86 };
87 
88 #endif /* _TUINODE_HPP_ */
89 
int nodeNumber
Number of the node in the current menu.
Definition: TuiNode.hpp:80
QString prefixText
Text of the prefix containing the hierarchical node number.
Definition: TuiNode.hpp:76
QList< int > ancestorsNumbers
Contains the numbers of the parent nodes in the hierarchy.
Definition: TuiNode.hpp:83
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.
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.