summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/main.cpp24
-rw-r--r--utils/themeeditor/parsetreemodel.cpp45
-rw-r--r--utils/themeeditor/parsetreemodel.h2
-rw-r--r--utils/themeeditor/parsetreenode.cpp4
4 files changed, 54 insertions, 21 deletions
diff --git a/utils/themeeditor/main.cpp b/utils/themeeditor/main.cpp
index 27ce2da23f..f876b1906e 100644
--- a/utils/themeeditor/main.cpp
+++ b/utils/themeeditor/main.cpp
@@ -36,12 +36,22 @@ extern "C"
int main(int argc, char* argv[])
{
+ QApplication app(argc, argv);
char doc[] = "#Comment\n%Vd(U);Hey\n%?bl(test,3,5,2,1)<param2|param3>";
+ ParseTreeModel tree(doc);
+
+ QTreeView view;
+ view.setModel(&tree);
+ view.show();
+
+ return app.exec();
+
+ /*
struct skin_element* test = skin_parse(doc);
- ParseTreeNode tree(test);
+ ParseTreeModel tree(doc);
std::cout << "----" << std::endl;
if(std::string(doc) == tree.genCode().toStdString())
std::cout << "Code in/out matches" << std::endl;
@@ -50,17 +60,7 @@ int main(int argc, char* argv[])
skin_free_tree(test);
+ */
-/*
- QApplication app(argc, argv);
-
- QTreeView tree;
- ParseTreeModel model(doc);
- tree.setModel(&model);
- tree.show();
-
- return app.exec();
-*/
- return 0;
}
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()
QModelIndex ParseTreeModel::index(int row, int column,
const QModelIndex& parent) const
{
- return QModelIndex();
+ if(!hasIndex(row, column, parent))
+ return QModelIndex();
+
+ ParseTreeNode* foundParent;
+
+ if(parent.isValid())
+ foundParent = static_cast<ParseTreeNode*>(parent.internalPointer());
+ else
+ foundParent = root;
+
+ if(row < foundParent->numChildren() && row >= 0)
+ return createIndex(row, column, foundParent->child(row));
+ else
+ return QModelIndex();
}
QModelIndex ParseTreeModel::parent(const QModelIndex &child) const
{
- return QModelIndex();
+ if(!child.isValid())
+ return QModelIndex();
+
+ ParseTreeNode* foundParent = static_cast<ParseTreeNode*>
+ (child.internalPointer())->getParent();
+
+ if(foundParent == root)
+ return QModelIndex();
+
+ return createIndex(foundParent->getRow(), 0, foundParent);
}
int ParseTreeModel::rowCount(const QModelIndex &parent) const
{
- return 0;
+ if(!parent.isValid())
+ return root->numChildren();
+
+ if(parent.column() > 0)
+ return 0;
+
+ return static_cast<ParseTreeNode*>(parent.internalPointer())->numChildren();
}
int ParseTreeModel::columnCount(const QModelIndex &parent) const
{
- return 0;
+ return 3;
}
QVariant ParseTreeModel::data(const QModelIndex &index, int role) const
{
- return QVariant();
+ if(!index.isValid())
+ return QVariant();
+
+ if(role != Qt::DisplayRole)
+ return QVariant();
+
+ return static_cast<ParseTreeNode*>(index.internalPointer())->
+ data(index.column());
}
diff --git a/utils/themeeditor/parsetreemodel.h b/utils/themeeditor/parsetreemodel.h
index 4abf623672..eedfe3f6bb 100644
--- a/utils/themeeditor/parsetreemodel.h
+++ b/utils/themeeditor/parsetreemodel.h
@@ -39,7 +39,7 @@ class ParseTreeModel : public QAbstractItemModel
Q_OBJECT
public:
- /* Initializes a tree with a WPS document in a string */
+ /* Initializes a tree with a skin document in a string */
ParseTreeModel(char* document, QObject* parent = 0);
virtual ~ParseTreeModel();
diff --git a/utils/themeeditor/parsetreenode.cpp b/utils/themeeditor/parsetreenode.cpp
index 60a18b8dbc..caafff5f43 100644
--- a/utils/themeeditor/parsetreenode.cpp
+++ b/utils/themeeditor/parsetreenode.cpp
@@ -273,9 +273,8 @@ QVariant ParseTreeNode::data(int column) const
switch(element->type)
{
case LINE:
- return QString();
-
case SUBLINES:
+ case CONDITIONAL:
return QString();
case NEWLINE:
@@ -285,7 +284,6 @@ QVariant ParseTreeNode::data(int column) const
case COMMENT:
return QString(element->text);
- case CONDITIONAL:
case TAG:
return QString(element->name);
}