Theme Editor: Made auto-expand/highlight of parse tree optional (through preferences dialog), added Simulation Time variable to device config panel, subline alternation is now dependent on that rather than time in song

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27342 a1c6a512-1295-4272-9138-f99709370657
diff --git a/utils/themeeditor/gui/editorwindow.cpp b/utils/themeeditor/gui/editorwindow.cpp
index 171e7b7..169dc3f 100644
--- a/utils/themeeditor/gui/editorwindow.cpp
+++ b/utils/themeeditor/gui/editorwindow.cpp
@@ -506,13 +506,22 @@
 
 void EditorWindow::lineChanged(int line)
 {
+    QSettings settings;
+    settings.beginGroup("EditorWindow");
+
+    if(settings.value("autoExpandTree", false).toBool())
+    {
         ui->parseTree->collapseAll();
         ParseTreeModel* model = dynamic_cast<ParseTreeModel*>
                                 (ui->parseTree->model());
         parseTreeSelection = new QItemSelectionModel(model);
-        expandLine(model, QModelIndex(), line);
+        expandLine(model, QModelIndex(), line,
+                   settings.value("autoHighlightTree", false).toBool());
         sizeColumns();
         ui->parseTree->setSelectionModel(parseTreeSelection);
+    }
+
+    settings.endGroup();
 }
 
 void EditorWindow::undo()
@@ -566,7 +575,7 @@
 
 
 void EditorWindow::expandLine(ParseTreeModel* model, QModelIndex parent,
-                              int line)
+                              int line, bool highlight)
 {
     for(int i = 0; i < model->rowCount(parent); i++)
     {
@@ -577,7 +586,7 @@
         QModelIndex data = model->index(i, ParseTreeModel::lineColumn, parent);
         QModelIndex recurse = model->index(i, 0, parent);
 
-        expandLine(model, recurse, line);
+        expandLine(model, recurse, line, highlight);
 
         if(model->data(data, Qt::DisplayRole) == line)
         {
@@ -585,12 +594,18 @@
             ui->parseTree->expand(data);
             ui->parseTree->scrollTo(parent, QAbstractItemView::PositionAtTop);
 
-            parseTreeSelection->select(data, QItemSelectionModel::Select);
-            parseTreeSelection->select(dataType, QItemSelectionModel::Select);
-            parseTreeSelection->select(dataVal, QItemSelectionModel::Select);
+            if(highlight)
+            {
+                parseTreeSelection->select(data,
+                                           QItemSelectionModel::Select);
+                parseTreeSelection->select(dataType,
+                                           QItemSelectionModel::Select);
+                parseTreeSelection->select(dataVal,
+                                           QItemSelectionModel::Select);
+            }
         }
-
     }
+
 }
 
 void EditorWindow::sizeColumns()
diff --git a/utils/themeeditor/gui/editorwindow.h b/utils/themeeditor/gui/editorwindow.h
index 6f30249..c2ae177 100644
--- a/utils/themeeditor/gui/editorwindow.h
+++ b/utils/themeeditor/gui/editorwindow.h
@@ -87,7 +87,8 @@
     void setupUI();
     void setupMenus();
     void addTab(TabContent* doc);
-    void expandLine(ParseTreeModel* model, QModelIndex parent, int line);
+    void expandLine(ParseTreeModel* model, QModelIndex parent, int line,
+                    bool highlight);
     void sizeColumns();
 
     Ui::EditorWindow *ui;
diff --git a/utils/themeeditor/gui/preferencesdialog.cpp b/utils/themeeditor/gui/preferencesdialog.cpp
index f8c71f4..dbb3249 100644
--- a/utils/themeeditor/gui/preferencesdialog.cpp
+++ b/utils/themeeditor/gui/preferencesdialog.cpp
@@ -44,7 +44,7 @@
 {
     loadColors();
     loadFont();
-    loadFontDir();
+    loadRender();
 }
 
 void PreferencesDialog::loadColors()
@@ -107,7 +107,7 @@
 
 }
 
-void PreferencesDialog::loadFontDir()
+void PreferencesDialog::loadRender()
 {
     QSettings settings;
     settings.beginGroup("RBFont");
@@ -115,13 +115,22 @@
     ui->fontBox->setText(settings.value("fontDir", "/").toString());
 
     settings.endGroup();
+
+    settings.beginGroup("EditorWindow");
+
+    ui->autoExpandBox->setChecked(settings.value("autoExpandTree",
+                                                 false).toBool());
+    ui->autoHighlightBox->setChecked(settings.value("autoHighlightTree",
+                                                    false).toBool());
+
+    settings.endGroup();
 }
 
 void PreferencesDialog::saveSettings()
 {
     saveColors();
     saveFont();
-    saveFontDir();
+    saveRender();
 }
 
 void PreferencesDialog::saveColors()
@@ -159,7 +168,7 @@
     settings.endGroup();
 }
 
-void PreferencesDialog::saveFontDir()
+void PreferencesDialog::saveRender()
 {
     QSettings settings;
     settings.beginGroup("RBFont");
@@ -167,6 +176,13 @@
     settings.setValue("fontDir", ui->fontBox->text());
 
     settings.endGroup();
+
+    settings.beginGroup("EditorWindow");
+
+    settings.setValue("autoExpandTree", ui->autoExpandBox->isChecked());
+    settings.setValue("autoHighlightTree", ui->autoHighlightBox->isChecked());
+
+    settings.endGroup();
 }
 
 void PreferencesDialog::setupUI()
diff --git a/utils/themeeditor/gui/preferencesdialog.h b/utils/themeeditor/gui/preferencesdialog.h
index 3df2409..cc1d7c7 100644
--- a/utils/themeeditor/gui/preferencesdialog.h
+++ b/utils/themeeditor/gui/preferencesdialog.h
@@ -55,11 +55,11 @@
     void loadSettings();
     void loadColors();
     void loadFont();
-    void loadFontDir();
+    void loadRender();
     void saveSettings();
     void saveColors();
     void saveFont();
-    void saveFontDir();
+    void saveRender();
 
     void setupUI();
 
diff --git a/utils/themeeditor/gui/preferencesdialog.ui b/utils/themeeditor/gui/preferencesdialog.ui
index 15e1743..c455ed0 100644
--- a/utils/themeeditor/gui/preferencesdialog.ui
+++ b/utils/themeeditor/gui/preferencesdialog.ui
@@ -23,6 +23,9 @@
      <property name="tabPosition">
       <enum>QTabWidget::North</enum>
      </property>
+     <property name="currentIndex">
+      <number>0</number>
+     </property>
      <widget class="QWidget" name="tab_2">
       <attribute name="title">
        <string>Editor</string>
@@ -257,10 +260,24 @@
      </widget>
      <widget class="QWidget" name="tab">
       <attribute name="title">
-       <string>Fonts</string>
+       <string>Rendering</string>
       </attribute>
       <layout class="QVBoxLayout" name="verticalLayout_4">
        <item>
+        <widget class="QCheckBox" name="autoExpandBox">
+         <property name="text">
+          <string>Auto-Expand Parse Tree</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QCheckBox" name="autoHighlightBox">
+         <property name="text">
+          <string>Auto-Highlight Parse Tree</string>
+         </property>
+        </widget>
+       </item>
+       <item>
         <layout class="QHBoxLayout" name="horizontalLayout_10">
          <item>
           <widget class="QLabel" name="label_10">
diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp
index c284b16..b2b5fbb 100644
--- a/utils/themeeditor/models/parsetreenode.cpp
+++ b/utils/themeeditor/models/parsetreenode.cpp
@@ -553,7 +553,7 @@
             times.append(findBranchTime(children[i], info));
 
         /* Now we figure out which branch to select */
-        double timeLeft = info.device()->data(QString("?pc")).toDouble();
+        double timeLeft = info.device()->data(QString("simtime")).toDouble();
         int branch = 0;
         while(timeLeft > 0)
         {
diff --git a/utils/themeeditor/resources/deviceoptions b/utils/themeeditor/resources/deviceoptions
index 8cc6381..d76baf1 100644
--- a/utils/themeeditor/resources/deviceoptions
+++ b/utils/themeeditor/resources/deviceoptions
@@ -35,6 +35,7 @@
 screenheight ; Screen Height ; spin(0,800) ; 200
 remotewidth ; Remote Width ; spin(0,800) ; 100
 remoteheight ; Remote Height ; spin(0,800); 50
+simtime ; Simulation Time ; fspin(0, 100000) ; 60.0
 showviewports ; Show Viewports ; check ; false
 rendersbs ; Render SBS If Available ; check ; true
 rtl ; Right-To-Left Language ; check ; false