Theme Editor: Beginning to work on conditional rendering, just made fix to line following code to speed up horizontal scrolling

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27168 a1c6a512-1295-4272-9138-f99709370657
diff --git a/utils/themeeditor/gui/devicestate.cpp b/utils/themeeditor/gui/devicestate.cpp
index 80efd4d..f4907e1 100644
--- a/utils/themeeditor/gui/devicestate.cpp
+++ b/utils/themeeditor/gui/devicestate.cpp
@@ -202,7 +202,8 @@
 {
 }
 
-QVariant DeviceState::data(QString tag)
+QVariant DeviceState::data(QString tag, int paramCount,
+                           skin_tag_parameter *params)
 {
     QPair<InputType, QWidget*> found =
             inputs.value(tag, QPair<InputType, QWidget*>(Slide, 0));
diff --git a/utils/themeeditor/gui/devicestate.h b/utils/themeeditor/gui/devicestate.h
index cae3cef..d3a6c46 100644
--- a/utils/themeeditor/gui/devicestate.h
+++ b/utils/themeeditor/gui/devicestate.h
@@ -28,6 +28,8 @@
 #include <QVariant>
 #include <QTabWidget>
 
+#include "skin_parser.h"
+
 class DeviceState : public QWidget {
 
     Q_OBJECT
@@ -46,7 +48,8 @@
     DeviceState(QWidget *parent = 0);
     virtual ~DeviceState();
 
-    QVariant data(QString tag);
+    QVariant data(QString tag, int paramCount = 0,
+                  skin_tag_parameter* params = 0);
     void setData(QString tag, QVariant data);
 
 signals:
diff --git a/utils/themeeditor/gui/editorwindow.cpp b/utils/themeeditor/gui/editorwindow.cpp
index ea6c91f..96f8552 100644
--- a/utils/themeeditor/gui/editorwindow.cpp
+++ b/utils/themeeditor/gui/editorwindow.cpp
@@ -499,14 +499,13 @@
 
 void EditorWindow::lineChanged(int line)
 {
-    ui->parseTree->collapseAll();
-    ParseTreeModel* model = dynamic_cast<ParseTreeModel*>
-                            (ui->parseTree->model());
-    parseTreeSelection = new QItemSelectionModel(model);
-    expandLine(model, QModelIndex(), line);
-    sizeColumns();
-    ui->parseTree->setSelectionModel(parseTreeSelection);
-
+        ui->parseTree->collapseAll();
+        ParseTreeModel* model = dynamic_cast<ParseTreeModel*>
+                                (ui->parseTree->model());
+        parseTreeSelection = new QItemSelectionModel(model);
+        expandLine(model, QModelIndex(), line);
+        sizeColumns();
+        ui->parseTree->setSelectionModel(parseTreeSelection);
 }
 
 void EditorWindow::undo()
diff --git a/utils/themeeditor/gui/skindocument.cpp b/utils/themeeditor/gui/skindocument.cpp
index f8206e1..28e5297 100644
--- a/utils/themeeditor/gui/skindocument.cpp
+++ b/utils/themeeditor/gui/skindocument.cpp
@@ -41,6 +41,7 @@
     saved = "";
     parseStatus = tr("Empty document");
     blockUpdate = false;
+    currentLine = -1;
 }
 
 SkinDocument::SkinDocument(QLabel* statusLabel, QString file,
@@ -208,8 +209,9 @@
         parseStatus = tr("Errors in document");
         statusLabel->setText(parseStatus);
     }
-    else
+    else if(editor->textCursor().blockNumber() != currentLine)
     {
+        currentLine = editor->textCursor().blockNumber();
         emit lineChanged(editor->textCursor().blockNumber() + 1);
     }
 
diff --git a/utils/themeeditor/gui/skindocument.h b/utils/themeeditor/gui/skindocument.h
index 1713023..7563b3c 100644
--- a/utils/themeeditor/gui/skindocument.h
+++ b/utils/themeeditor/gui/skindocument.h
@@ -97,6 +97,7 @@
     QString fileName;
     QString saved;
     QString parseStatus;
+    int currentLine;
 
     QLayout* layout;
     CodeEditor* editor;
diff --git a/utils/themeeditor/main.cpp b/utils/themeeditor/main.cpp
index 78df187..5dc52a0 100644
--- a/utils/themeeditor/main.cpp
+++ b/utils/themeeditor/main.cpp
@@ -19,18 +19,10 @@
  *
  ****************************************************************************/
 
-#include "skin_parser.h"
-#include "skin_debug.h"
 #include "editorwindow.h"
 
-#include <cstdlib>
-#include <cstdio>
-#include <iostream>
-
 #include <QtGui/QApplication>
 
-#include "parsetreemodel.h"
-
 int main(int argc, char* argv[])
 {
     QApplication app(argc, argv);
diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp
index 45cd62f..bdc0c30 100644
--- a/utils/themeeditor/models/parsetreenode.cpp
+++ b/utils/themeeditor/models/parsetreenode.cpp
@@ -509,7 +509,7 @@
 
 }
 
-/* This version is called for logical lines and such */
+/* This version is called for logical lines, tags, conditionals and such */
 void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport)
 {
     if(element->type == LINE)
@@ -524,10 +524,13 @@
     }
     else if(element->type == TAG)
     {
-
         if(!execTag(info, viewport))
             viewport->write(evalTag(info).toString());
-
+    }
+    else if(element->type == CONDITIONAL)
+    {
+        int child = evalTag(info, true, element->children_count).toInt();
+        //children[0]->render(info, viewport);
     }
 }
 
diff --git a/utils/themeeditor/resources/deviceoptions b/utils/themeeditor/resources/deviceoptions
index 855c8ba..b9081c6 100644
--- a/utils/themeeditor/resources/deviceoptions
+++ b/utils/themeeditor/resources/deviceoptions
@@ -23,6 +23,9 @@
 #
 # Blank lines are ignored
 #
+# A ? at the beginning of a field indicates that it's a special value for
+# conditionals
+#
 # Be warned: because this file is compiled into the application, I'm not
 # performing much of any error checking on it: screwing up the syntax may very
 # well segfault the application on startup
@@ -100,14 +103,14 @@
 ps ; Shuffle ; check ; true
 pt ; Total Track Time ; text ; 3:00
 pv ; Current Volume (dB) ; spin(-100,100) ; 0
-$pv ; Current Volume (Conditional) ; combo(Mute, Below 0 dB, 0 dB, Above 0 dB) ; 0 dB
+?pv ; Current Volume (Conditional) ; combo(Mute, Below 0 dB, 0 dB, Above 0 dB) ; 0 dB
 pS ; Track Starting ; check ; true
 pE ; Track Ending ; check ; false
 Sp ; Playback Pitch ; fspin(50,200) ; 100
 rp ; Song Playcount ; spin(0,10000) ; 20
 rr ; Song Rating ; spin(0,10) ; 5
 ra ; Autoscore ; spin(0,10) ; 7
-$C ; Album Art Available ; check ; true
+?C ; Album Art Available ; check ; true
 
 [Hardware Status]
 bl ; Battery Level (-1 for unknown) ; spin(-1,100) ; 50
@@ -122,7 +125,7 @@
 
 [Playback Status]
 rg ; Replaygain Value (dB) ; fspin(-100,20) ; 0
-$rg ; Replaygain Status (Conditional) ; combo(Off, Track, Album, TrackShuffle, AlbumShuffle, No Tag) ; Off
+?rg ; Replaygain Status (Conditional) ; combo(Off, Track, Album, TrackShuffle, AlbumShuffle, No Tag) ; Off
 mm ; Repeat Mode ; combo(Off, All, One, Shuffle, A-B) ; All
 mp ; Playback Mode ; combo(Stop, Play, Pause, Fast Forward, Rewind, Recording, Recording Paused, FM Radio Playing, FM Radio Muted) ; Play
 xf ; Crossfade Type ; combo(Off, Automatic Track Skip Only, Shuffle, Shuffle or Manual Track Skip, Always) ; Always
@@ -137,7 +140,7 @@
 cI ; 12h Hour ; text ; 09
 cl ; 12h Hour (No Padding) ; text ; 9
 cm ; Month (Padded) ; text ; 03
-$cm ; Month (Conditional) ; combo(January, February, March, April, May, Jun, July, August, September, October, November, December) ; January
+?cm ; Month (Conditional) ; combo(January, February, March, April, May, Jun, July, August, September, October, November, December) ; January
 cM ; Minute (Padded) ; text ; 29
 cS ; Second (Padded) ; text ; 50
 cy ; Last Two Digits of Year (Padded) ; text ; 09
@@ -147,9 +150,9 @@
 ca ; Abbreviated Weekday Name ; combo(Sun, Mon, Tue, Thu, Fri, Sat); Tue
 cb ; Abbreviated Month Name ; combo(Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec) ; Jan
 cu ; Day of Week (1..7, 1 is Monday) ; spin(1,7) ; 2
-$cu ; Day of Week (Monday First, Conditional) ; combo(Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday) ; Tuesday
+?cu ; Day of Week (Monday First, Conditional) ; combo(Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday) ; Tuesday
 cw ; Day of Week (0..6, 0 is Sunday) ; spin(0,6) ; 2
-$cw ; Day of Week (Sunday First, Conditional) ; combo(Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday) ; Tuesday
+?cw ; Day of Week (Sunday First, Conditional) ; combo(Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday) ; Tuesday
 
 [Recording Status]
 Rp ; Target Has Recorder ; check ; false