Theme Editor: Began working on open document functionality (still incomplete), fixed a nested conditional parsing bug in the parser, and fixed segfault-on-codegen-from-empty-tree bug

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26609 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-06 03:35:40 +00:00
parent 5619b4f6cf
commit f3491e97d0
6 changed files with 35 additions and 11 deletions

View file

@ -25,6 +25,7 @@
#include <QDesktopWidget>
#include <QFileSystemModel>
#include <QSettings>
#include <QFileDialog>
EditorWindow::EditorWindow(QWidget *parent) :
QMainWindow(parent),
@ -183,6 +184,17 @@ void EditorWindow::saveCurrentAs()
dynamic_cast<SkinDocument*>(ui->editorTabs->currentWidget())->saveAs();
}
void EditorWindow::openFile()
{
QStringList fileNames;
QSettings settings;
settings.beginGroup("SkinDocument");
QString directory = settings.value("defaultDirectory", "").toString();
fileNames = QFileDialog::getOpenFileNames(this, tr("Open Files"), directory,
SkinDocument::fileFilter());
}
void EditorWindow::tabTitleChanged(QString title)
{

View file

@ -49,6 +49,7 @@ private slots:
void closeCurrent();
void saveCurrent();
void saveCurrentAs();
void openFile();
void tabTitleChanged(QString title);
void updateCurrent(); /* Generates code in the current tab */

View file

@ -49,7 +49,10 @@ ParseTreeModel::~ParseTreeModel()
QString ParseTreeModel::genCode()
{
return root->genCode();
if(root)
return root->genCode();
else
return "";
}
bool ParseTreeModel::changeTree(const char *document)

View file

@ -685,9 +685,15 @@ int skin_parse_conditional(struct skin_element* element, char** document)
while(nested)
{
if(*cursor == ENUMLISTOPENSYM)
{
nested++;
if(*cursor == ENUMLISTCLOSESYM)
break;
}
else if(*cursor == ENUMLISTCLOSESYM)
{
nested--;
break;
}
cursor++;
}
}

View file

@ -28,12 +28,7 @@
#include <QFileDialog>
SkinDocument::SkinDocument(QWidget *parent) :
QWidget(parent), fileFilter(tr("WPS Files (*.wps *.rwps);;"
"SBS Files (*.sbs *.rsbs);;"
"FMS Files (*.fms *.rfms);;"
"All Skin Files (*.wps *.rwps *.sbs "
"*.rsbs *.fms *.rfms);;"
"All Files (*.*)"))
QWidget(parent)
{
setupUI();
@ -147,7 +142,7 @@ void SkinDocument::saveAs()
directory = settings.value("defaultDirectory", "").toString();
fileName = QFileDialog::getSaveFileName(this, tr("Save Document"),
directory, fileFilter);
directory, fileFilter());
directory = fileName;
if(fileName == "")
return;

View file

@ -33,8 +33,15 @@ class SkinDocument : public QWidget
{
Q_OBJECT
public:
const QString fileFilter;
static QString fileFilter()
{
return tr("WPS Files (*.wps *.rwps);;"
"SBS Files (*.sbs *.rsbs);;"
"FMS Files (*.fms *.rfms);;"
"All Skin Files (*.wps *.rwps *.sbs "
"*.rsbs *.fms *.rfms);;"
"All Files (*.*)");
}
SkinDocument(QWidget *parent = 0);
virtual ~SkinDocument();