aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-12-19 01:54:28 +0100
committerNao Pross <naopross@thearcway.org>2017-12-19 01:54:28 +0100
commita7e74749a1c4edb2f8bc34c79e9bd1562de86ee9 (patch)
tree4282a5dfa9ef7d77823e3e8ef02a193c91e719d6 /include
parentMoved to QtCreator project with QMake (diff)
downloadOrbitingYeti-a7e74749a1c4edb2f8bc34c79e9bd1562de86ee9.tar.gz
OrbitingYeti-a7e74749a1c4edb2f8bc34c79e9bd1562de86ee9.zip
Change to Qt5 conding conventions
Data structure changes: - Structogram is no longer just a scope, because it needs to store metadata - All structures now use QString instead of std::string, to integrate better in the Qt framework New code: - MainWindow ui code, building layout - MetadataDialog to change the metadata stored in the Structogram - Painter is a widget (still unimplemented) to show the structogram on the GUI
Diffstat (limited to 'include')
-rw-r--r--include/diagram/branchstatement.h30
-rw-r--r--include/diagram/branchstatement.hpp35
-rw-r--r--include/diagram/iteratorstatement.h28
-rw-r--r--include/diagram/iteratorstatement.hpp32
-rw-r--r--include/diagram/scope.h (renamed from include/diagram/scope.hpp)34
-rw-r--r--include/diagram/statement.h (renamed from include/diagram/statement.hpp)34
-rw-r--r--include/diagram/structogram.h29
-rw-r--r--include/diagram/structogram.hpp17
-rw-r--r--include/ui/mainwindow.h13
-rw-r--r--include/ui/metadatadialog.h26
-rw-r--r--include/ui/painter.h22
11 files changed, 177 insertions, 123 deletions
diff --git a/include/diagram/branchstatement.h b/include/diagram/branchstatement.h
new file mode 100644
index 0000000..6c5e416
--- /dev/null
+++ b/include/diagram/branchstatement.h
@@ -0,0 +1,30 @@
+#ifndef DIAGRAM_BRANCHSTATEMENT_H
+#define DIAGRAM_BRANCHSTATEMENT_H
+
+#include "diagram/statement.h"
+
+#include <map>
+#include <QString>
+
+namespace samb {
+
+class BranchStatement : public Statement
+{
+public:
+ BranchStatement(Type t, const QString &condition, pointer next);
+
+ /* accessors */
+ const std::map<QString, pointer>& branches() const { return _branches; }
+ std::size_t branches_count() const { return _branchesCount; }
+
+ inline const QString& condition() const { return text(); }
+ inline void condition(const QString &condition) { return text(condition); }
+
+private:
+ std::map<QString, pointer> _branches;
+ std::size_t _branchesCount = 0;
+};
+
+} /* namespace samb */
+
+#endif /* DIAGRAM_BRANCHSTATEMENT_H */
diff --git a/include/diagram/branchstatement.hpp b/include/diagram/branchstatement.hpp
deleted file mode 100644
index b7cc495..0000000
--- a/include/diagram/branchstatement.hpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * BranchStatement.hpp
- *
- * Created on: Nov 28, 2017
- * Author: naopross
- */
-
-#ifndef SRC_DIAGRAM_BRANCHSTATEMENT_HPP_
-#define SRC_DIAGRAM_BRANCHSTATEMENT_HPP_
-
-#include "Statement.hpp"
-
-#include <map>
-
-namespace samb {
-
-class BranchStatement: public Statement {
-public:
- BranchStatement(Type t, const std::string& condition, pointer next);
-
- /* accessors */
- const std::map<std::string, pointer>& branches() const { return m_branches; }
- std::size_t branchesCount() const { return m_branchesCount; }
-
- inline const std::string& condition() const { return text(); }
- inline void condition(const std::string& condition) { return text(condition); }
-
-private:
- std::map<std::string, pointer> m_branches;
- std::size_t m_branchesCount = 0;
-};
-
-} /* namespace samb */
-
-#endif /* SRC_DIAGRAM_BRANCHSTATEMENT_HPP_ */
diff --git a/include/diagram/iteratorstatement.h b/include/diagram/iteratorstatement.h
new file mode 100644
index 0000000..a8f6d59
--- /dev/null
+++ b/include/diagram/iteratorstatement.h
@@ -0,0 +1,28 @@
+#ifndef DIAGRAM_ITERATORSTATEMENT_H
+#define DIAGRAM_ITERATORSTATEMENT_H
+
+#include "diagram/statement.h"
+#include "diagram/scope.h"
+
+#include <QString>
+
+namespace samb {
+
+class IteratorStatement : public Statement
+{
+public:
+ IteratorStatement(Type t, const QString &condition, pointer next);
+
+ /* accessors */
+ const Scope& inner() const { return _inner; }
+
+ inline const QString& condition() const { return text(); }
+ inline void condition(const QString &condition) { return text(condition); }
+
+private:
+ Scope _inner;
+};
+
+} /* namespace samb */
+
+#endif /* DIAGRAM_ITERATORSTATEMENT_H */
diff --git a/include/diagram/iteratorstatement.hpp b/include/diagram/iteratorstatement.hpp
deleted file mode 100644
index a14d78d..0000000
--- a/include/diagram/iteratorstatement.hpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * IteratorStatement.hpp
- *
- * Created on: Nov 28, 2017
- * Author: naopross
- */
-
-#ifndef SRC_DIAGRAM_ITERATORSTATEMENT_HPP_
-#define SRC_DIAGRAM_ITERATORSTATEMENT_HPP_
-
-#include "Statement.hpp"
-#include "Scope.hpp"
-
-namespace samb {
-
-class IteratorStatement: public Statement {
-public:
- IteratorStatement(Type t, const std::string& condition, pointer next);
-
- /* accessors */
- const Scope& inner() const { return m_inner; }
-
- inline const std::string& condition() const { return text(); }
- inline void condition(const std::string& condition) { return text(condition); }
-
-private:
- Scope m_inner;
-};
-
-} /* namespace samb */
-
-#endif /* SRC_DIAGRAM_ITERATORSTATEMENT_HPP_ */
diff --git a/include/diagram/scope.hpp b/include/diagram/scope.h
index bf85759..63698dd 100644
--- a/include/diagram/scope.hpp
+++ b/include/diagram/scope.h
@@ -1,12 +1,9 @@
-/*
- * Created on: Nov 28, 2017
- * Author: naopross
- */
+#ifndef DIAGRAM_SCOPE_H
+#define DIAGRAM_SCOPE_H
-#ifndef SRC_DIAGRAM_SCOPE_HPP_
-#define SRC_DIAGRAM_SCOPE_HPP_
+#include "diagram/statement.h"
-#include "Statement.hpp"
+#include <QString>
namespace samb {
@@ -17,7 +14,8 @@ namespace samb {
* BranchStatement or a IteratorStatement, to hold the statements within their
* scope.
*/
-class Scope : public Statement {
+class Scope : public Statement
+{
public:
class iterator {
public:
@@ -31,27 +29,27 @@ public:
Statement::pointer operator->() const;
private:
- Statement::pointer m_current;
+ Statement::pointer _current;
};
- explicit Scope(std::string label);
- Scope(std::string label, Statement::pointer first);
- ~Scope();
+ explicit Scope(const QString &label);
+ Scope(const QString &label, Statement::pointer first);
+ virtual ~Scope();
iterator insert_after(iterator it, Statement::pointer statement);
iterator erase_after(iterator it);
/* accessors */
- std::size_t size() const { return m_size; }
+ std::size_t size() const { return _size; }
/* iterator */
- iterator begin() { return iterator(m_head); }
- iterator end() { return iterator(m_tail); }
+ iterator begin() { return iterator(_head); }
+ iterator end() { return iterator(_tail); }
private:
- Statement::pointer m_head;
- Statement::pointer m_tail;
- std::size_t m_size = 0;
+ Statement::pointer _head;
+ Statement::pointer _tail;
+ std::size_t _size = 0;
};
} /* namespace samb */
diff --git a/include/diagram/statement.hpp b/include/diagram/statement.h
index ab8c5b7..5cce908 100644
--- a/include/diagram/statement.hpp
+++ b/include/diagram/statement.h
@@ -1,16 +1,11 @@
-/*
- * Statement.h
- *
- * Created on: Nov 23, 2017
- * Author: naopross
- */
-
-#ifndef SRC_DIAGRAM_STATEMENT_H_
-#define SRC_DIAGRAM_STATEMENT_H_
+#ifndef DIAGRAM_STATEMENT_H
+#define DIAGRAM_STATEMENT_H
#include <string>
#include <memory>
+#include <QString>
+
namespace samb {
/* Possible types of statement, according to the NS diagram paper
@@ -28,7 +23,8 @@ namespace samb {
* (linked list), that is also a common interface for the various types of
* statements.
*/
-class Statement {
+class Statement
+{
public:
using pointer = std::shared_ptr<Statement>;
@@ -44,24 +40,24 @@ public:
const Type type;
- Statement(Type t, const std::string& text);
- Statement(Type t, const std::string& text, pointer next);
+ Statement(Type t, const QString &text);
+ Statement(Type t, const QString &text, pointer next);
virtual ~Statement();
bool operator==(const Statement& other) const;
/* accessors */
- void next(pointer next) { m_next = next; }
- pointer next() const { return m_next; }
+ void next(pointer next) { _next = next; }
+ pointer next() const { return _next; }
- void text(const std::string& text) { m_text = text; }
- const std::string& text() const { return m_text; }
+ void text(const QString &text) { _text = text; }
+ const QString& text() const { return _text; }
private:
- std::string m_text;
- pointer m_next;
+ QString _text;
+ pointer _next;
};
} /* namespace samb */
-#endif /* SRC_DIAGRAM_STATEMENT_H_ */
+#endif /* DIAGRAM_STATEMENT_H */
diff --git a/include/diagram/structogram.h b/include/diagram/structogram.h
new file mode 100644
index 0000000..6b2e0db
--- /dev/null
+++ b/include/diagram/structogram.h
@@ -0,0 +1,29 @@
+#ifndef DIAGRAM_STRUCTOGRAM_H
+#define DIAGRAM_STRUCTOGRAM_H
+
+#include "diagram/scope.h"
+
+#include <QString>
+
+namespace samb {
+
+class Structogram : public Scope
+{
+public:
+ Structogram(const QString &title, const QString &author);
+ ~Structogram();
+
+ /* accessors */
+ void title(const QString &title) { text(title); }
+ const QString& title() const { return text(); }
+
+ void author(const QString &author) { _author = author; }
+ const QString& author() const { return _author; }
+
+private:
+ QString _author;
+};
+
+}
+
+#endif /* DIAGRAM_STRUCTOGRAM_H */
diff --git a/include/diagram/structogram.hpp b/include/diagram/structogram.hpp
deleted file mode 100644
index 84a4b84..0000000
--- a/include/diagram/structogram.hpp
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Structogram.hpp
- *
- * Created on: Nov 28, 2017
- * Author: naopross
- */
-
-#ifndef SRC_DIAGRAM_STRUCTOGRAM_HPP_
-#define SRC_DIAGRAM_STRUCTOGRAM_HPP_
-
-#include "Scope.hpp"
-
-namespace samb {
- typedef Scope Structogram;
-}
-
-#endif /* SRC_DIAGRAM_STRUCTOGRAM_HPP_ */
diff --git a/include/ui/mainwindow.h b/include/ui/mainwindow.h
index a3948a9..0beb4a2 100644
--- a/include/ui/mainwindow.h
+++ b/include/ui/mainwindow.h
@@ -3,6 +3,8 @@
#include <QMainWindow>
+#include "diagram/structogram.h"
+
namespace Ui {
class MainWindow;
}
@@ -12,11 +14,18 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
- explicit MainWindow(QWidget *parent = 0);
+ explicit MainWindow(samb::Structogram *structogram = nullptr, QWidget *parent = nullptr);
~MainWindow();
+private slots:
+ void on_newButton_clicked();
+ void on_metadataButton_clicked();
+
private:
- Ui::MainWindow *ui;
+ Ui::MainWindow *_ui;
+ samb::Structogram *_structogram;
+
+ void initData();
};
#endif // MAINWINDOW_H
diff --git a/include/ui/metadatadialog.h b/include/ui/metadatadialog.h
new file mode 100644
index 0000000..0ed2f17
--- /dev/null
+++ b/include/ui/metadatadialog.h
@@ -0,0 +1,26 @@
+#ifndef NEWDIALOG_H
+#define NEWDIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+class MetadataDialog;
+}
+
+class MetadataDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit MetadataDialog(QWidget *parent = 0);
+ ~MetadataDialog();
+
+ void setMetadata(const QString& title, const QString& author);
+ QString title() const;
+ QString author() const;
+
+private:
+ Ui::MetadataDialog *_ui;
+};
+
+#endif // NEWDIALOG_H
diff --git a/include/ui/painter.h b/include/ui/painter.h
new file mode 100644
index 0000000..df62776
--- /dev/null
+++ b/include/ui/painter.h
@@ -0,0 +1,22 @@
+#ifndef PAINTER_H
+#define PAINTER_H
+
+#include <QWidget>
+
+namespace Ui {
+class Painter;
+}
+
+class Painter : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit Painter(QWidget *parent = 0);
+ ~Painter();
+
+private:
+ Ui::Painter *_ui;
+};
+
+#endif // PAINTER_H