TuiNode.cpp   TuiNode.cpp 
skipping to change at line 24 skipping to change at line 24
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "TuiNode.hpp" #include "TuiNode.hpp"
#include <QKeyEvent> #include <QKeyEvent>
TuiNode::TuiNode(const QString& text, TuiNode* parent, TuiNode* prev) TuiNode::TuiNode(const QString& text, TuiNode* parent, TuiNode* prev)
: QObject(parent), parentNode(parent), childNode(NULL), prevNode(pre v), nextNode(NULL), displayText(text) : QObject(parent), parentNode(parent), childNode(Q_NULLPTR), prevNod e(prev), nextNode(Q_NULLPTR), displayText(text)
{ {
updateNodeNumber(); updateNodeNumber();
} }
TuiNodeResponse TuiNode::handleKey(int key) TuiNodeResponse TuiNode::handleKey(int key)
{ {
return navigation(key); return navigation(key);
} }
TuiNodeResponse TuiNode::navigation(int key) TuiNodeResponse TuiNode::navigation(int key)
{ {
TuiNodeResponse response; TuiNodeResponse response;
response.accepted = false; response.accepted = false;
response.newNode = this; response.newNode = this;
if (key==Qt::Key_Left) if (key==Qt::Key_Left)
{ {
if (parentNode != NULL) if (parentNode != Q_NULLPTR)
{ {
parentNode->setChildNode(this); parentNode->setChildNode(this);
response.newNode = this->parentNode; response.newNode = this->parentNode;
} }
response.accepted = true; response.accepted = true;
} }
else if (key==Qt::Key_Right) else if (key==Qt::Key_Right)
{ {
if (childNode != NULL) if (childNode != Q_NULLPTR)
{ {
response.newNode = childNode; response.newNode = childNode;
} }
response.accepted = true; response.accepted = true;
} }
else if (key==Qt::Key_Up) else if (key==Qt::Key_Up)
{ {
if (prevNode != NULL) if (prevNode != Q_NULLPTR)
{ {
response.newNode = prevNode; response.newNode = prevNode;
} }
response.accepted = true; response.accepted = true;
} }
else if (key==Qt::Key_Down) else if (key==Qt::Key_Down)
{ {
if (nextNode != NULL) if (nextNode != Q_NULLPTR)
{ {
response.newNode = nextNode; response.newNode = nextNode;
} }
response.accepted = true; response.accepted = true;
} }
return response; return response;
} }
QString TuiNode::getDisplayText() QString TuiNode::getDisplayText() const
{ {
return prefixText + q_(displayText); return prefixText + q_(displayText);
} }
void TuiNode::loopToTheLast() void TuiNode::loopToTheLast()
{ {
TuiNode* node = nextNode; TuiNode* node = nextNode;
while (node != NULL && node != this) while (node != Q_NULLPTR && node != this)
{ {
prevNode = node; prevNode = node;
node = node->getNextNode(); node = node->getNextNode();
} }
} }
void TuiNode::updateNodeNumber() void TuiNode::updateNodeNumber()
{ {
nodeNumber = 0; nodeNumber = 0;
ancestorsNumbers.clear(); ancestorsNumbers.clear();
prefixText.clear(); prefixText.clear();
if (prevNode == NULL) if (prevNode == Q_NULLPTR)
{ {
nodeNumber = 1; nodeNumber = 1;
} }
else else
{ {
nodeNumber = prevNode->getNodeNumber() + 1; nodeNumber = prevNode->getNodeNumber() + 1;
} }
if (parentNode != NULL) if (parentNode != Q_NULLPTR)
{ {
ancestorsNumbers = parentNode->getAncestorsNumbers(); ancestorsNumbers = parentNode->getAncestorsNumbers();
} }
ancestorsNumbers.append(nodeNumber); ancestorsNumbers.append(nodeNumber);
//TODO: This probably needs to be made RTL-language-friendly. --BM //TODO: This probably needs to be made RTL-language-friendly. --BM
foreach (int n, ancestorsNumbers) foreach (int n, ancestorsNumbers)
{ {
QString number = QString("%1.").arg(n); QString number = QString("%1.").arg(n);
prefixText.append(number); prefixText.append(number);
 End of changes. 9 change blocks. 
9 lines changed or deleted 9 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/