summaryrefslogtreecommitdiff
path: root/client/mainwindow.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/mainwindow.cc')
-rw-r--r--client/mainwindow.cc64
1 files changed, 60 insertions, 4 deletions
diff --git a/client/mainwindow.cc b/client/mainwindow.cc
index aa2337e..46662fa 100644
--- a/client/mainwindow.cc
+++ b/client/mainwindow.cc
@@ -38,20 +38,36 @@
#include <QSettings>
#include <QStatusBar>
#include <QMessageBox>
+#include <QToolBar>
+#include <QAction>
#include "macrodrawer.h"
-MainWindow::MainWindow(QString cpr, QString templ, QString host, quint16 port, QString user)
+MainWindow::MainWindow(QString cpr, QString templ, QString host,
+ quint16 port, QString user)
: QMainWindow(0, Qt::WindowContextHelpButtonHint),
- netcom(host, port, user, cpr)
+ netcom(host, port)
{
header = NULL;
+ this->cpr = cpr;
+ this->user = user;
+
setWindowTitle("Pracro - " + cpr);
QStatusBar *status = statusBar();
status->addPermanentWidget(new QLabel("Pracro v."VERSION));
+ QToolBar *toolbar = addToolBar("controls");
+ QAction *close_commit = toolbar->addAction("Close and commit");
+ QAction *close_no_commit = toolbar->addAction("Close no commit");
+ QAction *close_discard = toolbar->addAction("Close discard");
+ QAction *show_sessions = toolbar->addAction("Show sessions");
+ connect(close_commit, SIGNAL(triggered()), this, SLOT(closeCommit()));
+ connect(close_no_commit, SIGNAL(triggered()), this, SLOT(closeNoCommit()));
+ connect(close_discard, SIGNAL(triggered()), this, SLOT(closeDiscard()));
+ connect(show_sessions, SIGNAL(triggered()), this, SLOT(showSessions()));
+
QScrollArea *s = new QScrollArea();
setCentralWidget(s);
w = new QWidget();
@@ -70,6 +86,31 @@ MainWindow::~MainWindow()
{
}
+void MainWindow::closeCommit()
+{
+ netcom.commit();
+ sessions.remove(cpr);
+ close();
+}
+
+void MainWindow::closeNoCommit()
+{
+ sessions.add(cpr, user, netcom.sessionid);
+ close();
+}
+
+void MainWindow::closeDiscard()
+{
+ netcom.discard();
+ sessions.remove(cpr);
+ close();
+}
+
+void MainWindow::showSessions()
+{
+ sessions.show();
+}
+
void MainWindow::closeEvent(QCloseEvent *)
{
QSettings settings("Aasimon.org", "Pracro");
@@ -77,6 +118,7 @@ void MainWindow::closeEvent(QCloseEvent *)
settings.beginGroup("MainWindow");
settings.setValue("size", size());
settings.setValue("pos", pos());
+ settings.setValue(QString("sessions"), sessions.toVariant());
settings.endGroup();
QApplication::quit();
@@ -89,8 +131,21 @@ void MainWindow::init()
settings.beginGroup("MainWindow");
resize(settings.value("size", QSize(700, 800)).toSize());
move(settings.value("pos", QPoint(0, 0)).toPoint());
+ sessions.fromVariant(settings.value("sessions"));
settings.endGroup();
+ netcom.patientid = cpr;
+ netcom.user = user;
+
+ if(sessions.contains(cpr)) {
+ netcom.sessionid = sessions.getSessionID(cpr);
+ if(sessions.getUser(cpr) != user) {
+ // What to do? We are running an old session with a new user!
+ }
+ }
+
+ netcom.initConnection();
+
initialising = true;
update();
initialising = false;
@@ -113,7 +168,8 @@ void MainWindow::updateTemplateHeaders(QDomNode templatenode)
w->layout()->addWidget(header);
}
- statusBar()->showMessage(template_title + " (" + template_name + ")");
+ statusBar()->showMessage(template_title + " (" + template_name +
+ ") - SessionID: " + netcom.sessionid);
}
@@ -150,7 +206,7 @@ void MainWindow::update()
i++;
}
- // if(found == false || macroelement.hasAttribute("header")) {
+ // if(found == false || macroelement.hasAttribute("header")) {
if(found == false || macroelement.tagName() == "header") {
QString num;
num.sprintf("%04d", j);