aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/mainwindow.cpp
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 /src/ui/mainwindow.cpp
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 'src/ui/mainwindow.cpp')
-rw-r--r--src/ui/mainwindow.cpp60
1 files changed, 56 insertions, 4 deletions
diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp
index 7e4ca77..5a60391 100644
--- a/src/ui/mainwindow.cpp
+++ b/src/ui/mainwindow.cpp
@@ -1,14 +1,66 @@
#include "ui/mainwindow.h"
#include "ui_mainwindow.h"
-MainWindow::MainWindow(QWidget *parent) :
+#include "ui/metadatadialog.h"
+
+#include <iostream>
+
+MainWindow::MainWindow(samb::Structogram *structogram, QWidget *parent) :
QMainWindow(parent),
- ui(new Ui::MainWindow)
+ _ui(new Ui::MainWindow),
+ _structogram(structogram)
{
- ui->setupUi(this);
+ _ui->setupUi(this);
+ initData();
}
MainWindow::~MainWindow()
{
- delete ui;
+ delete _ui;
+}
+
+/**** private slots ****/
+
+void MainWindow::on_newButton_clicked()
+{
+ if (_structogram != nullptr)
+ {
+ // TODO: implement save dialog
+ std::cout << "TODO: implement save dialog" << std::endl;
+
+ delete _structogram;
+ _structogram = nullptr;
+ }
+
+ MetadataDialog *dialog = new MetadataDialog(this);
+ if (dialog->exec() == QDialog::Accepted)
+ {
+ _structogram = new samb::Structogram(dialog->title(), dialog->author());
+ }
+
+ delete dialog;
+}
+
+void MainWindow::on_metadataButton_clicked()
+{
+ if (_structogram == nullptr) { return; }
+
+ MetadataDialog *dialog = new MetadataDialog(this);
+ dialog->setMetadata(_structogram->title(), _structogram->author());
+
+ if (dialog->exec() == QDialog::Accepted)
+ {
+ _structogram->title(dialog->title());
+ _structogram->author(dialog->author());
+ }
+}
+
+/**** private methods ****/
+
+void MainWindow::initData()
+{
+ if (_structogram == nullptr)
+ {
+ _structogram = new samb::Structogram("", "");
+ }
}