Refactoring

This commit is contained in:
Nikolaj Schlej 2016-07-16 09:08:41 +02:00
parent 4745d61905
commit f90427229d
2 changed files with 9 additions and 12 deletions

View File

@ -91,3 +91,10 @@ int TreeItem::row() const
} }
return 0; return 0;
} }
TreeItem* TreeItem::child(int row)
{
std::list<TreeItem*>::iterator child = childItems.begin();
std::advance(child, row);
return *child;
}

View File

@ -21,16 +21,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "ustring.h" #include "ustring.h"
#include "basetypes.h" #include "basetypes.h"
template <typename ForwardIt>
ForwardIt u_std_next(
ForwardIt it,
typename std::iterator_traits<ForwardIt>::difference_type n = 1
)
{
std::advance(it, n);
return it;
}
class TreeItem class TreeItem
{ {
public: public:
@ -47,14 +37,14 @@ public:
UINT8 insertChildAfter(TreeItem *item, TreeItem *newItem); // Non-trivial implementation in CPP file UINT8 insertChildAfter(TreeItem *item, TreeItem *newItem); // Non-trivial implementation in CPP file
// Model support operations // Model support operations
TreeItem *child(int row) { return *u_std_next(childItems.begin(), row); } TreeItem *child(int row); // Non-trivial implementation in CPP file
int childCount() const {return childItems.size(); } int childCount() const {return childItems.size(); }
int columnCount() const { return 5; } int columnCount() const { return 5; }
UString data(int column) const; // Non-trivial implementation in CPP file UString data(int column) const; // Non-trivial implementation in CPP file
int row() const; // Non-trivial implementation in CPP file int row() const; // Non-trivial implementation in CPP file
TreeItem *parent() { return parentItem; } TreeItem *parent() { return parentItem; }
// Reading operations for item parameters // Getters and setters for item parameters
UString name() const { return itemName; } UString name() const { return itemName; }
void setName(const UString &text) { itemName = text; } void setName(const UString &text) { itemName = text; }