diff options
Diffstat (limited to 'utils/themeeditor/parsetreemodel.cpp')
-rw-r--r-- | utils/themeeditor/parsetreemodel.cpp | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/utils/themeeditor/parsetreemodel.cpp b/utils/themeeditor/parsetreemodel.cpp index 4c46320bb3..08f10615ef 100644 --- a/utils/themeeditor/parsetreemodel.cpp +++ b/utils/themeeditor/parsetreemodel.cpp | |||
@@ -47,24 +47,59 @@ QString ParseTreeModel::genCode() | |||
47 | QModelIndex ParseTreeModel::index(int row, int column, | 47 | QModelIndex ParseTreeModel::index(int row, int column, |
48 | const QModelIndex& parent) const | 48 | const QModelIndex& parent) const |
49 | { | 49 | { |
50 | return QModelIndex(); | 50 | if(!hasIndex(row, column, parent)) |
51 | return QModelIndex(); | ||
52 | |||
53 | ParseTreeNode* foundParent; | ||
54 | |||
55 | if(parent.isValid()) | ||
56 | foundParent = static_cast<ParseTreeNode*>(parent.internalPointer()); | ||
57 | else | ||
58 | foundParent = root; | ||
59 | |||
60 | if(row < foundParent->numChildren() && row >= 0) | ||
61 | return createIndex(row, column, foundParent->child(row)); | ||
62 | else | ||
63 | return QModelIndex(); | ||
51 | } | 64 | } |
52 | 65 | ||
53 | QModelIndex ParseTreeModel::parent(const QModelIndex &child) const | 66 | QModelIndex ParseTreeModel::parent(const QModelIndex &child) const |
54 | { | 67 | { |
55 | return QModelIndex(); | 68 | if(!child.isValid()) |
69 | return QModelIndex(); | ||
70 | |||
71 | ParseTreeNode* foundParent = static_cast<ParseTreeNode*> | ||
72 | (child.internalPointer())->getParent(); | ||
73 | |||
74 | if(foundParent == root) | ||
75 | return QModelIndex(); | ||
76 | |||
77 | return createIndex(foundParent->getRow(), 0, foundParent); | ||
56 | } | 78 | } |
57 | 79 | ||
58 | int ParseTreeModel::rowCount(const QModelIndex &parent) const | 80 | int ParseTreeModel::rowCount(const QModelIndex &parent) const |
59 | { | 81 | { |
60 | return 0; | 82 | if(!parent.isValid()) |
83 | return root->numChildren(); | ||
84 | |||
85 | if(parent.column() > 0) | ||
86 | return 0; | ||
87 | |||
88 | return static_cast<ParseTreeNode*>(parent.internalPointer())->numChildren(); | ||
61 | } | 89 | } |
62 | 90 | ||
63 | int ParseTreeModel::columnCount(const QModelIndex &parent) const | 91 | int ParseTreeModel::columnCount(const QModelIndex &parent) const |
64 | { | 92 | { |
65 | return 0; | 93 | return 3; |
66 | } | 94 | } |
67 | QVariant ParseTreeModel::data(const QModelIndex &index, int role) const | 95 | QVariant ParseTreeModel::data(const QModelIndex &index, int role) const |
68 | { | 96 | { |
69 | return QVariant(); | 97 | if(!index.isValid()) |
98 | return QVariant(); | ||
99 | |||
100 | if(role != Qt::DisplayRole) | ||
101 | return QVariant(); | ||
102 | |||
103 | return static_cast<ParseTreeNode*>(index.internalPointer())-> | ||
104 | data(index.column()); | ||
70 | } | 105 | } |