summaryrefslogtreecommitdiff
path: root/tikzit
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2017-01-20 12:30:31 +0100
committerAleks Kissinger <aleks0@gmail.com>2017-01-20 12:30:31 +0100
commitda45cb6f70f72d804e0a9ed58562e94455672359 (patch)
tree7e985db13abffadfade40c84f86265996e197171 /tikzit
parentb4f6b3997ba1d1355a42e6d2cd90e7715a9f9114 (diff)
parsing
Diffstat (limited to 'tikzit')
-rw-r--r--tikzit/src/data/graphelementdata.cpp5
-rw-r--r--tikzit/src/data/graphelementdata.h1
-rw-r--r--tikzit/src/data/tikzlexer.lpp9
-rw-r--r--tikzit/src/data/tikzparser.ypp12
-rw-r--r--tikzit/src/gui/propertypalette.cpp11
-rw-r--r--tikzit/src/gui/propertypalette.h2
-rw-r--r--tikzit/src/gui/toolpalette.cpp1
-rw-r--r--tikzit/tikzit.pro5
-rw-r--r--tikzit/tikzit.pro.user2
9 files changed, 36 insertions, 12 deletions
diff --git a/tikzit/src/data/graphelementdata.cpp b/tikzit/src/data/graphelementdata.cpp
index 04c7760..8e4a7cc 100644
--- a/tikzit/src/data/graphelementdata.cpp
+++ b/tikzit/src/data/graphelementdata.cpp
@@ -32,6 +32,11 @@ void GraphElementData::unsetProperty(QString key)
_properties.remove(i);
}
+void GraphElementData::operator <<(GraphElementProperty p)
+{
+ _properties << p;
+}
+
void GraphElementData::setAtom(QString atom)
{
GraphElementProperty a(atom);
diff --git a/tikzit/src/data/graphelementdata.h b/tikzit/src/data/graphelementdata.h
index fee65e7..e3d7a68 100644
--- a/tikzit/src/data/graphelementdata.h
+++ b/tikzit/src/data/graphelementdata.h
@@ -49,6 +49,7 @@ public:
// bool removeRows(int position, int rows,
// const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE;
+ void operator <<(GraphElementProperty p);
signals:
public slots:
diff --git a/tikzit/src/data/tikzlexer.lpp b/tikzit/src/data/tikzlexer.lpp
index 19c4d85..7040d52 100644
--- a/tikzit/src/data/tikzlexer.lpp
+++ b/tikzit/src/data/tikzlexer.lpp
@@ -23,6 +23,7 @@
#include "tikzparser.h"
#include <QString>
+#include <stringstream>
#define YY_USER_ACTION \
yylloc->first_line = yylloc->last_line; \
@@ -120,7 +121,7 @@ to { return TO; }
/* we assume node names (and anchor names) never contain
newlines */
<noderef>[^\.\{\)\n]+ {
- yylval->nsstr=[NSString stringWithUTF8String:yytext];
+ yylval->qstr=QString(yytext);
return REFSTRING;
}
<noderef>\) {
@@ -129,7 +130,7 @@ to { return TO; }
}
<INITIAL,props>\{ {
- NSMutableString *buf = [NSMutableString string];
+ std::stringstream buf;
unsigned int brace_depth = 1;
unsigned int escape = 0;
while (1) {
@@ -154,10 +155,10 @@ to { return TO; }
yylloc->last_line += 1;
yylloc->last_column = 0;
}
- [buf appendFormat:@"%c", c];
+ buf << c;
}
- yylval->nsstr = buf;
+ yylval->qstr = QString(buf.str());
return DELIMITEDSTRING;
}
diff --git a/tikzit/src/data/tikzparser.ypp b/tikzit/src/data/tikzparser.ypp
index e97b1c7..ca3b4e4 100644
--- a/tikzit/src/data/tikzparser.ypp
+++ b/tikzit/src/data/tikzparser.ypp
@@ -52,7 +52,7 @@
%{
#include "node.h"
#include "edge.h"
- #include "graphelementdata.h"
+#include "graphelementdata.h"
#include "graphelementproperty.h"
#include "tikzlexer.h"
@@ -139,21 +139,21 @@ optproperties:
| { $$ = 0; };
properties: extraproperties property
{
- [$1 addObject:$2];
+ $1 << $2;
$$ = $1;
};
extraproperties:
extraproperties property ","
{
- [$1 addObject:$2];
+ $1 << $2;
$$ = $1;
}
- | { $$ = [GraphElementData data]; };
+ | { $$ = GraphElementData(); };
property:
val "=" val
- { $$ = [GraphElementProperty property:$1 withValue:$3]; }
+ { $$ = GraphElementProperty($1,$3); }
| val
- { $$ = [GraphElementProperty atom:$1]; };
+ { $$ = GraphElementProperty($1); };
val: PROPSTRING { $$ = $1; } | DELIMITEDSTRING { $$ = $1; };
nodename: "(" REFSTRING ")" { $$ = $2; };
diff --git a/tikzit/src/gui/propertypalette.cpp b/tikzit/src/gui/propertypalette.cpp
index 6fc9ef9..e3eec17 100644
--- a/tikzit/src/gui/propertypalette.cpp
+++ b/tikzit/src/gui/propertypalette.cpp
@@ -4,6 +4,8 @@
#include <QModelIndex>
#include <QDebug>
+#include <QCloseEvent>
+#include <QSettings>
PropertyPalette::PropertyPalette(QWidget *parent) :
QDockWidget(parent),
@@ -18,9 +20,18 @@ PropertyPalette::PropertyPalette(QWidget *parent) :
QModelIndex i = d->index(0,0);
qDebug() << "data: " << i.data();
ui->treeView->setModel(d);
+
+ QSettings settings("tikzit", "tikzit");
+ restoreGeometry(settings.value("property-palette-geometry").toByteArray());
}
PropertyPalette::~PropertyPalette()
{
delete ui;
}
+
+void PropertyPalette::closeEvent(QCloseEvent *event) {
+ QSettings settings("tikzit", "tikzit");
+ settings.setValue("property-palette-geometry", saveGeometry());
+ QDockWidget::closeEvent(event);
+}
diff --git a/tikzit/src/gui/propertypalette.h b/tikzit/src/gui/propertypalette.h
index 8e8e5b3..f2f1955 100644
--- a/tikzit/src/gui/propertypalette.h
+++ b/tikzit/src/gui/propertypalette.h
@@ -15,6 +15,8 @@ public:
explicit PropertyPalette(QWidget *parent = 0);
~PropertyPalette();
+protected:
+ void closeEvent(QCloseEvent *event);
private:
Ui::PropertyPalette *ui;
};
diff --git a/tikzit/src/gui/toolpalette.cpp b/tikzit/src/gui/toolpalette.cpp
index fd06730..fbbc8fd 100644
--- a/tikzit/src/gui/toolpalette.cpp
+++ b/tikzit/src/gui/toolpalette.cpp
@@ -13,6 +13,7 @@ ToolPalette::ToolPalette(QWidget *parent) :
| Qt::WindowDoesNotAcceptFocus);
setOrientation(Qt::Vertical);
setFocusPolicy(Qt::NoFocus);
+ setGeometry(100,200,30,195);
tools = new QActionGroup(this);
diff --git a/tikzit/tikzit.pro b/tikzit/tikzit.pro
index 15a8c29..fce1860 100644
--- a/tikzit/tikzit.pro
+++ b/tikzit/tikzit.pro
@@ -44,7 +44,10 @@ HEADERS += src/gui/mainwindow.h \
src/data/tikzgraphassembler.h \
src/data/graphelementdata.h \
src/data/graphelementproperty.h \
- src/gui/propertypalette.h
+ src/gui/propertypalette.h \
+ src/data/tikzlexer.lpp \
+ src/data/tikzparser.ypp \
+ src/data/tikzparserdefs.h
FORMS += src/gui/mainwindow.ui \
src/gui/propertypalette.ui
diff --git a/tikzit/tikzit.pro.user b/tikzit/tikzit.pro.user
index f8495a5..058f7ba 100644
--- a/tikzit/tikzit.pro.user
+++ b/tikzit/tikzit.pro.user
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.2.0, 2017-01-15T13:42:00. -->
+<!-- Written by QtCreator 4.2.0, 2017-01-20T11:40:07. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>