Stellarium 0.12.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