]> git.lyx.org Git - lyx.git/blobdiff - src/lyxled/LayoutEditor.cpp
add busy.gif to resources (in line with cmake)
[lyx.git] / src / lyxled / LayoutEditor.cpp
index 660c7f908654a45462c80f9d7d315f8d112af277..12b98711bbdcb065a1a4b8c5888b9aaefad5b28c 100644 (file)
@@ -73,6 +73,132 @@ void MainWindow::loadLayoutFile(QString const & fileName)
 }
 
 
+void MainWindow::loadLayoutFile(QString const & fileName,
+       QStandardItem * parent)
+{
+       QFile file(fileName);
+#if 0
+       file.open(QIODevice::ReadOnly);
+       QString contents = file.readAll();
+       file.close();
+       qDebug() << "contents: " << contents;
+#endif
+
+       file.open(QIODevice::ReadOnly);
+
+       QTextStream ts(&file);
+       while (!ts.atEnd()) {
+               QList<QStandardItem *> row;
+               QString code;
+               ts >> code;
+               //qDebug() << "CODE: " << code;
+               if (code.startsWith('#')) {
+                       QString line = code + ' ' + ts.readLine();
+                       //row.append(new QStandardItem("Comment"));
+                       //row.append(new QStandardItem(code + ' ' + ts.readLine()));
+                       //parent->appendRow(row);
+               } else if (isInsensitivelyEqual(code, "Input")) {
+                       QString inputFile;
+                       ts >> inputFile;
+                       QStandardItem * item = new QStandardItem(inputFile);
+                       row.append(item);
+                       parent->appendRow(row);
+                       inputFile = fileName.left(fileName.lastIndexOf('/')) + '/' + inputFile;
+                       qDebug() << "INPUT: " << inputFile;
+                       loadLayoutFile(inputFile, item);
+               } else if (isInsensitivelyEqual(code, "Style")) {
+                       QString style;
+                       ts >> style;
+                       //while (!ts.atEnd() && !isInsensitivelyEqual(code, "EndStyle"))
+                       //      ts >> code;
+                       QStandardItem * item = new QStandardItem(style);
+                       row.append(item);
+                       parent->appendRow(row);
+               } else {
+                       //row.append(new QStandardItem(code));
+                       //parent->appendRow(row);
+               }
+       }
+       
+       file.close();
+}
+
+} // namespace lyx
+
+#include "LayoutEditor.h"
+
+#include "ui_MainWindowUi.h"
+
+#include <QDebug>
+#include <QFile>
+#include <QList>
+#include <QStandardItem>
+#include <QStandardItemModel>
+#include <QString>
+#include <QTreeView>
+
+
+namespace lyx {
+
+/////////////////////////////////////////////////////////////////////////
+//
+// LayoutTree
+//
+/////////////////////////////////////////////////////////////////////////
+
+LayoutTree::LayoutTree(QWidget * parent) 
+       : QTreeView(parent)
+{}
+
+
+/////////////////////////////////////////////////////////////////////////
+//
+// LayoutEditor
+//
+/////////////////////////////////////////////////////////////////////////
+
+LayoutEditor::LayoutEditor(QWidget * parent) 
+       : QWidget(parent)
+{}
+
+
+/////////////////////////////////////////////////////////////////////////
+//
+// MainWindow
+//
+/////////////////////////////////////////////////////////////////////////
+
+MainWindow::MainWindow()
+{
+       ui_ = new Ui::MainWindow;
+       ui_->setupUi(this);
+
+       model_ = new QStandardItemModel(this);
+       view_ = new LayoutTree(this);
+       view_->setModel(model_);
+       //setCentralWidget(view_);
+
+       ui_->dockLayoutTree->setWidget(view_);
+}
+
+
+MainWindow::~MainWindow()
+{
+       delete ui_;
+}
+
+static bool isInsensitivelyEqual(QString const & s1, QString const & s2)
+{
+       return s1.compare(s2, Qt::CaseInsensitive) == 0;
+}
+
+void MainWindow::loadLayoutFile(QString const & fileName)
+{
+       loadLayoutFile(fileName, model_->invisibleRootItem());
+       view_->expandAll();
+}
+
+
 void MainWindow::loadLayoutFile(QString const & fileName,
        QStandardItem * parent)
 {