Theme Editor: Items from line under cursor now selected in parse tree view

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26870 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-16 19:24:53 +00:00
parent 23b9df2890
commit 60d5f5050b
3 changed files with 19 additions and 2 deletions

View file

@ -101,7 +101,6 @@ void EditorWindow::loadSettings()
restoreState(state);
}
}
void EditorWindow::saveSettings()
@ -137,6 +136,7 @@ void EditorWindow::setupUI()
parseStatus = new QLabel(this);
ui->statusbar->addPermanentWidget(parseStatus);
parseTreeSelection = 0;
}
void EditorWindow::setupMenus()
@ -400,10 +400,14 @@ void EditorWindow::updateCurrent()
void EditorWindow::lineChanged(int line)
{
ui->parseTree->collapseAll();
if(parseTreeSelection)
parseTreeSelection->deleteLater();
ParseTreeModel* model = dynamic_cast<ParseTreeModel*>
(ui->parseTree->model());
parseTreeSelection = new QItemSelectionModel(model);
expandLine(model, QModelIndex(), line);
sizeColumns();
ui->parseTree->setSelectionModel(parseTreeSelection);
}
@ -412,6 +416,10 @@ void EditorWindow::expandLine(ParseTreeModel* model, QModelIndex parent,
{
for(int i = 0; i < model->rowCount(parent); i++)
{
QModelIndex dataType = model->index(i, ParseTreeModel::typeColumn,
parent);
QModelIndex dataVal = model->index(i, ParseTreeModel::valueColumn,
parent);
QModelIndex data = model->index(i, ParseTreeModel::lineColumn, parent);
QModelIndex recurse = model->index(i, 0, parent);
@ -422,6 +430,10 @@ void EditorWindow::expandLine(ParseTreeModel* model, QModelIndex parent,
ui->parseTree->expand(parent);
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);
}
}

View file

@ -24,6 +24,7 @@
#include <QMainWindow>
#include <QLabel>
#include <QItemSelectionModel>
#include "parsetreemodel.h"
#include "skinhighlighter.h"
@ -84,6 +85,7 @@ private:
PreferencesDialog* prefs;
QLabel* parseStatus;
ProjectModel* project;
QItemSelectionModel* parseTreeSelection;
};
#endif // EDITORWINDOW_H

View file

@ -40,7 +40,7 @@
<x>0</x>
<y>0</y>
<width>628</width>
<height>25</height>
<height>27</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -130,6 +130,9 @@
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item>