summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils/themeeditor/parsetreenode.cpp21
-rw-r--r--utils/themeeditor/skin_parser.c31
2 files changed, 33 insertions, 19 deletions
diff --git a/utils/themeeditor/parsetreenode.cpp b/utils/themeeditor/parsetreenode.cpp
index 6f6154039c..df4e770f9c 100644
--- a/utils/themeeditor/parsetreenode.cpp
+++ b/utils/themeeditor/parsetreenode.cpp
@@ -56,6 +56,7 @@ ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent)
56 } 56 }
57 break; 57 break;
58 58
59 case VIEWPORT:
59 case CONDITIONAL: 60 case CONDITIONAL:
60 for(int i = 0; i < element->params_count; i++) 61 for(int i = 0; i < element->params_count; i++)
61 children.append(new ParseTreeNode(&data->params[i], this)); 62 children.append(new ParseTreeNode(&data->params[i], this));
@@ -70,7 +71,6 @@ ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent)
70 } 71 }
71 break; 72 break;
72 73
73 case VIEWPORT:
74 case LINE: 74 case LINE:
75 for(int i = 0; i < data->children_count; i++) 75 for(int i = 0; i < data->children_count; i++)
76 { 76 {
@@ -104,10 +104,23 @@ QString ParseTreeNode::genCode() const
104 { 104 {
105 105
106 case VIEWPORT: 106 case VIEWPORT:
107 buffer.append(children[0]->genCode()); 107 /* Generating the Viewport tag, if necessary */
108 if(children[0]->element->type == TAG) 108 if(element->tag)
109 {
110 buffer.append(TAGSYM);
111 buffer.append(element->tag->name);
112 buffer.append(ARGLISTOPENSYM);
113 for(int i = 0; i < element->params_count; i++)
114 {
115 buffer.append(children[i]->genCode());
116 if(i != element->params_count - 1)
117 buffer.append(ARGLISTSEPERATESYM);
118 }
119 buffer.append(ARGLISTCLOSESYM);
109 buffer.append('\n'); 120 buffer.append('\n');
110 for(int i = 1; i < children.count(); i++) 121 }
122
123 for(int i = element->params_count; i < children.count(); i++)
111 buffer.append(children[i]->genCode()); 124 buffer.append(children[i]->genCode());
112 break; 125 break;
113 126
diff --git a/utils/themeeditor/skin_parser.c b/utils/themeeditor/skin_parser.c
index f17f68854a..e6a6350d13 100644
--- a/utils/themeeditor/skin_parser.c
+++ b/utils/themeeditor/skin_parser.c
@@ -124,24 +124,19 @@ static struct skin_element* skin_parse_viewport(char** document)
124 /* Parsing out the viewport tag if there is one */ 124 /* Parsing out the viewport tag if there is one */
125 if(check_viewport(cursor)) 125 if(check_viewport(cursor))
126 { 126 {
127 retval->children_count = 2; 127 skin_parse_tag(retval, &cursor);
128 retval->children = skin_alloc_children(2);
129 retval->children[0] = skin_alloc_element();
130 skin_parse_tag(retval->children[0], &cursor);
131 if(*cursor == '\n') 128 if(*cursor == '\n')
132 { 129 {
133 cursor++; 130 cursor++;
134 skin_line++; 131 skin_line++;
135 } 132 }
136 } 133 }
137 else 134
138 { 135 retval->children_count = 1;
139 retval->children_count = 1; 136 retval->children = skin_alloc_children(1);
140 retval->children = skin_alloc_children(1);
141 }
142 137
143 138
144 while(*cursor != '\0' && !(check_viewport(cursor) && cursor != *document)) 139 do
145 { 140 {
146 141
147 /* First, we check to see if this line will contain sublines */ 142 /* First, we check to see if this line will contain sublines */
@@ -217,10 +212,11 @@ static struct skin_element* skin_parse_viewport(char** document)
217 skin_line++; 212 skin_line++;
218 } 213 }
219 } 214 }
215 while(*cursor != '\0' && !(check_viewport(cursor) && cursor != *document));
220 216
221 *document = cursor; 217 *document = cursor;
222 218
223 retval->children[retval->children_count - 1] = root; 219 retval->children[0] = root;
224 return retval; 220 return retval;
225 221
226} 222}
@@ -253,8 +249,11 @@ static struct skin_element* skin_parse_line_optional(char** document,
253 retval = skin_alloc_element(); 249 retval = skin_alloc_element();
254 retval->type = LINE; 250 retval->type = LINE;
255 retval->line = skin_line; 251 retval->line = skin_line;
256 retval->children_count = 1; 252 if(*cursor != '\0')
257 retval->children = skin_alloc_children(1); 253 retval->children_count = 1;
254 else retval->children_count = 0;
255 if(retval->children_count > 0)
256 retval->children = skin_alloc_children(1);
258 257
259 while(*cursor != '\n' && *cursor != '\0' && *cursor != MULTILINESYM 258 while(*cursor != '\n' && *cursor != '\0' && *cursor != MULTILINESYM
260 && !((*cursor == ARGLISTSEPERATESYM 259 && !((*cursor == ARGLISTSEPERATESYM
@@ -302,7 +301,8 @@ static struct skin_element* skin_parse_line_optional(char** document,
302 /* Moving up the calling function's pointer */ 301 /* Moving up the calling function's pointer */
303 *document = cursor; 302 *document = cursor;
304 303
305 retval->children[0] = root; 304 if(root)
305 retval->children[0] = root;
306 return retval; 306 return retval;
307} 307}
308 308
@@ -432,7 +432,7 @@ static int skin_parse_tag(struct skin_element* element, char** document)
432 } 432 }
433 433
434 /* Copying basic tag info */ 434 /* Copying basic tag info */
435 if(element->type != CONDITIONAL) 435 if(element->type != CONDITIONAL && element->type != VIEWPORT)
436 element->type = TAG; 436 element->type = TAG;
437 element->tag = tag; 437 element->tag = tag;
438 tag_args = tag->params; 438 tag_args = tag->params;
@@ -851,6 +851,7 @@ struct skin_element* skin_alloc_element()
851 struct skin_element* retval = (struct skin_element*) 851 struct skin_element* retval = (struct skin_element*)
852 skin_alloc(sizeof(struct skin_element)); 852 skin_alloc(sizeof(struct skin_element));
853 retval->next = NULL; 853 retval->next = NULL;
854 retval->tag = NULL;
854 retval->params_count = 0; 855 retval->params_count = 0;
855 retval->children_count = 0; 856 retval->children_count = 0;
856 857