aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-12-19 22:47:05 +0100
committerNao Pross <naopross@thearcway.org>2017-12-19 22:47:05 +0100
commit631f37ee26c19d38408ee733ffda24ad283c7921 (patch)
tree0d12f7201337ac9c459aac48b5e4421f6a1f7db2 /include
parentUpdate gitignore for QtCreator (diff)
downloadOrbitingYeti-631f37ee26c19d38408ee733ffda24ad283c7921.tar.gz
OrbitingYeti-631f37ee26c19d38408ee733ffda24ad283c7921.zip
Implement basic ui
Changes: - Clean up code to use Qt coding style - Add comments to some methods - Add debugtools to have debug_msg() and debug_err() macros - New Serializer class header to save / load data - MetadataDialog: check validity of metadata - MainWindow: initial code for `tool' buttons to edit the structogram - MainWindow: open / save dialog
Diffstat (limited to 'include')
-rw-r--r--include/debugtools.h27
-rw-r--r--include/diagram/branchstatement.h4
-rw-r--r--include/diagram/iteratorstatement.h4
-rw-r--r--include/diagram/structogram.h10
-rw-r--r--include/io/serializer.h18
-rw-r--r--include/ui/mainwindow.h8
-rw-r--r--include/ui/metadatadialog.h6
7 files changed, 71 insertions, 6 deletions
diff --git a/include/debugtools.h b/include/debugtools.h
new file mode 100644
index 0000000..cd6940b
--- /dev/null
+++ b/include/debugtools.h
@@ -0,0 +1,27 @@
+#ifndef DEBUGTOOLS_H
+#define DEBUGTOOLS_H
+
+#ifdef QT_NO_DEBUG
+
+void debug_msg(...) {}
+void debug_err(...) {}
+
+#else
+#include <iostream>
+
+#define debug_msg(msg) \
+do { \
+ std::cout << "DEBUG [" \
+ << __FILE__ << " @ " << __LINE__ \
+ << "]: " << msg << std::endl; \
+} while (0)
+
+#define debug_err(msg) \
+do { \
+ std::cerr << "ERROR [" \
+ << __FILE__ << " @ " << __LINE__ \
+ << "]: " << msg << std::endl; \
+} while (0)
+
+#endif // QT_NO_DEBUG
+#endif // DEBUGTOOLS_H
diff --git a/include/diagram/branchstatement.h b/include/diagram/branchstatement.h
index 6c5e416..3d8c385 100644
--- a/include/diagram/branchstatement.h
+++ b/include/diagram/branchstatement.h
@@ -8,13 +8,15 @@
namespace samb {
+/* Implementation for Statement::DECISION, Statement::SWITCH
+ */
class BranchStatement : public Statement
{
public:
BranchStatement(Type t, const QString &condition, pointer next);
/* accessors */
- const std::map<QString, pointer>& branches() const { return _branches; }
+ std::map<QString, pointer>& branches() { return _branches; }
std::size_t branches_count() const { return _branchesCount; }
inline const QString& condition() const { return text(); }
diff --git a/include/diagram/iteratorstatement.h b/include/diagram/iteratorstatement.h
index a8f6d59..e7fbba0 100644
--- a/include/diagram/iteratorstatement.h
+++ b/include/diagram/iteratorstatement.h
@@ -8,13 +8,15 @@
namespace samb {
+/* Implementation for Statement::WHILE Statement::UNTIL
+ */
class IteratorStatement : public Statement
{
public:
IteratorStatement(Type t, const QString &condition, pointer next);
/* accessors */
- const Scope& inner() const { return _inner; }
+ Scope& inner() { return _inner; }
inline const QString& condition() const { return text(); }
inline void condition(const QString &condition) { return text(condition); }
diff --git a/include/diagram/structogram.h b/include/diagram/structogram.h
index 6b2e0db..cd501aa 100644
--- a/include/diagram/structogram.h
+++ b/include/diagram/structogram.h
@@ -7,15 +7,19 @@
namespace samb {
+/* A structogram is a specific type of scope, that is the root scope.
+ * As a result it contains some metadata informations about the author,
+ * date of creation ecc.
+ */
class Structogram : public Scope
{
public:
Structogram(const QString &title, const QString &author);
- ~Structogram();
+ virtual ~Structogram();
/* accessors */
- void title(const QString &title) { text(title); }
- const QString& title() const { return text(); }
+ inline void title(const QString &title) { text(title); }
+ inline const QString& title() const { return text(); }
void author(const QString &author) { _author = author; }
const QString& author() const { return _author; }
diff --git a/include/io/serializer.h b/include/io/serializer.h
new file mode 100644
index 0000000..901d913
--- /dev/null
+++ b/include/io/serializer.h
@@ -0,0 +1,18 @@
+#ifndef SERIALIZER_H
+#define SERIALIZER_H
+
+#include "diagram/structogram.h"
+
+#include <QFileInfo>
+
+class Serializer
+{
+public:
+ explicit Serializer();
+ virtual ~Serializer();
+
+ bool write(const samb::Structogram &structogram, QFileInfo into);
+ bool load(samb::Structogram &structogram, QFileInfo from);
+};
+
+#endif // SERIALIZER_H
diff --git a/include/ui/mainwindow.h b/include/ui/mainwindow.h
index 0beb4a2..3061440 100644
--- a/include/ui/mainwindow.h
+++ b/include/ui/mainwindow.h
@@ -19,13 +19,19 @@ public:
private slots:
void on_newButton_clicked();
+ void on_openButton_clicked();
+ void on_saveButton_clicked();
+
+ void on_refreshButton_clicked();
void on_metadataButton_clicked();
+ void on_newStatementButton_clicked();
private:
Ui::MainWindow *_ui;
samb::Structogram *_structogram;
- void initData();
+ bool askSaveDialog();
+ void toolButtonsEnabled(bool state);
};
#endif // MAINWINDOW_H
diff --git a/include/ui/metadatadialog.h b/include/ui/metadatadialog.h
index 0ed2f17..81af9da 100644
--- a/include/ui/metadatadialog.h
+++ b/include/ui/metadatadialog.h
@@ -2,6 +2,7 @@
#define NEWDIALOG_H
#include <QDialog>
+#include <QAbstractButton>
namespace Ui {
class MetadataDialog;
@@ -15,10 +16,15 @@ public:
explicit MetadataDialog(QWidget *parent = 0);
~MetadataDialog();
+ bool isValid() const;
void setMetadata(const QString& title, const QString& author);
QString title() const;
QString author() const;
+private slots:
+ void on_titleEdit_textChanged();
+ void on_authorEdit_textChanged();
+
private:
Ui::MetadataDialog *_ui;
};