summaryrefslogtreecommitdiffstats
path: root/utils/themeeditor/parsetreemodel.cpp
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-01 20:19:51 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-01 20:19:51 +0000
commit279969618d28e23ac83b6e81c7b7bbf1adaf5b74 (patch)
treeb875450c631cdae21c7c6befbb1ea4bde232423c /utils/themeeditor/parsetreemodel.cpp
parent5943f4c5e239475a32ac2b341a6df8189c8f1768 (diff)
downloadrockbox-279969618d28e23ac83b6e81c7b7bbf1adaf5b74.tar.gz
rockbox-279969618d28e23ac83b6e81c7b7bbf1adaf5b74.tar.bz2
rockbox-279969618d28e23ac83b6e81c7b7bbf1adaf5b74.zip
Theme Editor: Made text and comments editable from a treeview
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26453 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/parsetreemodel.cpp')
-rw-r--r--utils/themeeditor/parsetreemodel.cpp73
1 files changed, 45 insertions, 28 deletions
diff --git a/utils/themeeditor/parsetreemodel.cpp b/utils/themeeditor/parsetreemodel.cpp
index a0e3abb03b..24eebac8d6 100644
--- a/utils/themeeditor/parsetreemodel.cpp
+++ b/utils/themeeditor/parsetreemodel.cpp
@@ -142,8 +142,14 @@ Qt::ItemFlags ParseTreeModel::flags(const QModelIndex &index) const
ParseTreeNode* element = static_cast<ParseTreeNode*>
(index.internalPointer());
- if(element->isParam() && index.column() == valueColumn)
+
+ if((element->isParam()
+ || element->getElement()->type == TEXT
+ || element->getElement()->type == COMMENT)
+ && index.column() == valueColumn)
+ {
retval |= Qt::ItemIsEditable;
+ }
return retval;
}
@@ -157,43 +163,54 @@ bool ParseTreeModel::setData(const QModelIndex &index, const QVariant &value,
if(index.column() != valueColumn)
return false;
- ParseTreeNode* element = static_cast<ParseTreeNode*>
+ ParseTreeNode* node = static_cast<ParseTreeNode*>
(index.internalPointer());
- if(!element->isParam())
- return false;
-
- struct skin_tag_parameter* param = element->getParam();
-
- /* Now that we've established that we do, in fact, have a parameter, we'll
- * set it to its new value if an acceptable one has been entered
- */
- if(value.toString().trimmed() == QString(QChar(DEFAULTSYM)))
+ if(node->isParam())
{
- if(islower(param->type_code))
- param->type = skin_tag_parameter::DEFAULT;
+ struct skin_tag_parameter* param = node->getParam();
+
+ /* Now that we've established that we do, in fact, have a parameter,
+ * set it to its new value if an acceptable one has been entered
+ */
+ if(value.toString().trimmed() == QString(QChar(DEFAULTSYM)))
+ {
+ if(islower(param->type_code))
+ param->type = skin_tag_parameter::DEFAULT;
+ else
+ return false;
+ }
+ else if(tolower(param->type_code) == 's'
+ || tolower(param->type_code) == 'f')
+ {
+ if(param->type == skin_tag_parameter::STRING)
+ free(param->data.text);
+
+ param->type = skin_tag_parameter::STRING;
+ param->data.text = strdup(value.toString().trimmed().toAscii());
+ }
+ else if(tolower(param->type_code) == 'i')
+ {
+ if(!value.canConvert(QVariant::Int))
+ return false;
+
+ param->type = skin_tag_parameter::NUMERIC;
+ param->data.numeric = value.toInt();
+ }
else
+ {
return false;
+ }
}
- else if(tolower(param->type_code) == 's' || tolower(param->type_code) == 'f')
+ else
{
- if(param->type == skin_tag_parameter::STRING)
- free(param->data.text);
+ struct skin_element* element = node->getElement();
- param->type = skin_tag_parameter::STRING;
- param->data.text = strdup(value.toString().trimmed().toAscii());
- }
- else if(tolower(param->type_code) == 'i')
- {
- if(!value.canConvert(QVariant::Int))
+ if(element->type != COMMENT && element->type != TEXT)
return false;
- param->type = skin_tag_parameter::NUMERIC;
- param->data.numeric = value.toInt();
- }
- else
- {
- return false;
+ free(element->text);
+ element->text = strdup(value.toString().trimmed().toAscii());
}
emit dataChanged(index, index);