From ab0a007cb369a8e9a1bf43c9386a77d36199759b Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 22 Nov 2012 13:40:51 +0100 Subject: QtBase: examples/widgets/itemviews code style Change-Id: I78a7745f7dc3add3fd7780220118d1b35b50a941 Reviewed-by: hjk --- examples/widgets/itemviews/interview/model.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'examples/widgets/itemviews/interview/model.cpp') diff --git a/examples/widgets/itemviews/interview/model.cpp b/examples/widgets/itemviews/interview/model.cpp index ef0057981b..e99eb477fb 100644 --- a/examples/widgets/itemviews/interview/model.cpp +++ b/examples/widgets/itemviews/interview/model.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "model.h" + #include #include @@ -60,10 +61,10 @@ Model::~Model() QModelIndex Model::index(int row, int column, const QModelIndex &parent) const { if (row < rc && row >= 0 && column < cc && column >= 0) { - Node *p = static_cast(parent.internalPointer()); - Node *n = node(row, p); - if (n) - return createIndex(row, column, n); + Node *parentNode = static_cast(parent.internalPointer()); + Node *childNode = node(row, parentNode); + if (childNode) + return createIndex(row, column, childNode); } return QModelIndex(); } @@ -71,10 +72,10 @@ QModelIndex Model::index(int row, int column, const QModelIndex &parent) const QModelIndex Model::parent(const QModelIndex &child) const { if (child.isValid()) { - Node *n = static_cast(child.internalPointer()); - Node *p = parent(n); - if (p) - return createIndex(row(p), 0, p); + Node *childNode = static_cast(child.internalPointer()); + Node *parentNode = parent(childNode); + if (parentNode) + return createIndex(row(parentNode), 0, parentNode); } return QModelIndex(); } @@ -130,7 +131,7 @@ Qt::ItemFlags Model::flags(const QModelIndex &index) const Model::Node *Model::node(int row, Node *parent) const { if (parent && !parent->children) - parent->children = new QVector(rc, Node(parent)); + parent->children = new QVector(rc, Node(parent)); QVector *v = parent ? parent->children : tree; return const_cast(&(v->at(row))); } @@ -142,6 +143,6 @@ Model::Node *Model::parent(Node *child) const int Model::row(Node *node) const { - const Node *first = node->parent ? &(node->parent->children->at(0)) : &(tree->at(0)); - return (node - first); + const Node *first = node->parent ? &(node->parent->children->at(0)) : &(tree->at(0)); + return node - first; } -- cgit v1.2.3