summaryrefslogtreecommitdiff
path: root/tikzit/src/data/tikzdocument.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tikzit/src/data/tikzdocument.cpp')
-rw-r--r--tikzit/src/data/tikzdocument.cpp82
1 files changed, 0 insertions, 82 deletions
diff --git a/tikzit/src/data/tikzdocument.cpp b/tikzit/src/data/tikzdocument.cpp
deleted file mode 100644
index 13d4c6e..0000000
--- a/tikzit/src/data/tikzdocument.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-#include <QFile>
-#include <QFileInfo>
-#include <QSettings>
-#include <QTextStream>
-#include <QMessageBox>
-
-#include "tikzdocument.h"
-#include "tikzgraphassembler.h"
-
-TikzDocument::TikzDocument(QObject *parent) : QObject(parent)
-{
- _graph = new Graph(this);
- _parseSuccess = true;
- _fileName = "";
- _shortName = "";
- _undoStack = new QUndoStack();
-}
-
-TikzDocument::~TikzDocument()
-{
- delete _graph;
- delete _undoStack;
-}
-
-QUndoStack *TikzDocument::undoStack() const
-{
- return _undoStack;
-}
-
-Graph *TikzDocument::graph() const
-{
- return _graph;
-}
-
-QString TikzDocument::tikz() const
-{
- return _tikz;
-}
-
-void TikzDocument::open(QString fileName)
-{
- _fileName = fileName;
- QFile file(fileName);
- QFileInfo fi(file);
- _shortName = fi.fileName();
- QSettings settings("tikzit", "tikzit");
- settings.setValue("previous-file-path", fi.absolutePath());
-
- if (!file.open(QIODevice::ReadOnly)) {
-// QMessageBox::critical(this, tr("Error"),
-// tr("Could not open file"));
- _parseSuccess = false;
- return;
- }
-
- QTextStream in(&file);
- _tikz = in.readAll();
- file.close();
-
- Graph *newGraph = new Graph(this);
- TikzGraphAssembler ass(newGraph);
- if (ass.parse(_tikz)) {
- delete _graph;
- _graph = newGraph;
- foreach (Node *n, _graph->nodes()) n->attachStyle();
- foreach (Edge *e, _graph->edges()) e->updateControls();
- _parseSuccess = true;
- } else {
- delete newGraph;
- _parseSuccess = false;
- }
-}
-
-QString TikzDocument::shortName() const
-{
- return _shortName;
-}
-
-bool TikzDocument::parseSuccess() const
-{
- return _parseSuccess;
-}