summaryrefslogtreecommitdiffstats
path: root/utils
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
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')
-rw-r--r--utils/themeeditor/parsetreemodel.cpp73
-rw-r--r--utils/themeeditor/parsetreenode.cpp1
-rw-r--r--utils/themeeditor/skin_parser.c5
3 files changed, 49 insertions, 30 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);
diff --git a/utils/themeeditor/parsetreenode.cpp b/utils/themeeditor/parsetreenode.cpp
index 98b4187a9e..22db94da89 100644
--- a/utils/themeeditor/parsetreenode.cpp
+++ b/utils/themeeditor/parsetreenode.cpp
@@ -172,6 +172,7 @@ QString ParseTreeNode::genCode() const
case COMMENT:
buffer.append(COMMENTSYM);
buffer.append(element->text);
+ buffer.append('\n');
break;
}
}
diff --git a/utils/themeeditor/skin_parser.c b/utils/themeeditor/skin_parser.c
index d118e9b97b..c0f1849523 100644
--- a/utils/themeeditor/skin_parser.c
+++ b/utils/themeeditor/skin_parser.c
@@ -738,6 +738,7 @@ int skin_parse_comment(struct skin_element* element, char** document)
*/
for(length = 0; cursor[length] != '\n' && cursor[length] != '\0'; length++);
+ length--;
element->type = COMMENT;
element->line = skin_line;
element->text = skin_alloc_string(length);
@@ -745,10 +746,10 @@ int skin_parse_comment(struct skin_element* element, char** document)
memcpy((void*)(element->text), (void*)(cursor + 1), sizeof(char) * length);
element->text[length] = '\0';
- if(cursor[length] == '\n')
+ if(cursor[length + 1] == '\n')
skin_line++;
- *document += (length + 1); /* Move cursor up past # and all text */
+ *document += (length + 2); /* Move cursor up past # and all text */
return 1;
}