summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authordeva <deva>2010-05-27 09:41:29 +0000
committerdeva <deva>2010-05-27 09:41:29 +0000
commit73934812611cc7120175e26761d71fae9233c1e8 (patch)
treed02a57f4d9f67ec073e330e4461e4f8cf98b4de5 /client
parent3d48d173bc89b8868bf28f22d875ff0667a24021 (diff)
Use new commit/discard methods in netcom.
Diffstat (limited to 'client')
-rw-r--r--client/mainwindow.cc64
-rw-r--r--client/mainwindow.h14
-rw-r--r--client/viewer.cc9
3 files changed, 80 insertions, 7 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);
diff --git a/client/mainwindow.h b/client/mainwindow.h
index e19b070..6f88058 100644
--- a/client/mainwindow.h
+++ b/client/mainwindow.h
@@ -33,19 +33,24 @@
#include <QPushButton>
#include "netcom.h"
#include "macrowindow.h"
-
+#include "sessions.h"
#include "macro.h"
class MainWindow : public QMainWindow {
Q_OBJECT
public:
- MainWindow(QString cpr, QString templ, QString host, quint16 port, QString user);
+ MainWindow(QString cpr, QString templ, QString host, quint16 port,
+ QString user);
~MainWindow();
void closeEvent(QCloseEvent *event);
public slots:
void update();
+ void closeCommit();
+ void closeNoCommit();
+ void closeDiscard();
+ void showSessions();
private:
void updateTemplateHeaders(QDomNode templatenode);
@@ -53,6 +58,9 @@ private:
QString templ;
NetCom netcom;
+ QString cpr;
+ QString user;
+
// QMap< QString, MacroWindow* > macros;
Macros macros;
QWidget *w;
@@ -61,6 +69,8 @@ private:
bool initialising;
+ Sessions sessions;
+
void init();
};
diff --git a/client/viewer.cc b/client/viewer.cc
index 09b6e47..c4bd3f5 100644
--- a/client/viewer.cc
+++ b/client/viewer.cc
@@ -81,7 +81,12 @@ Viewer::Viewer(QString cpr, QString templs, QString host, quint16 port,
this->templs = templs.split(QRegExp("\\W+"), QString::SkipEmptyParts);
connect(&updatetimer, SIGNAL(timeout()), this, SLOT(update()));
- netcom = new NetCom(host, port, user, cpr);
+ netcom = new NetCom(host, port);
+ netcom->user = user;
+ netcom->patientid = cpr;
+ netcom->sessionid = "";
+ netcom->initConnection();
+
host = host; port = port; user = user;
this->cpr = cpr;
this->journalpath = journalpath;
@@ -109,6 +114,8 @@ Viewer::Viewer(QString cpr, QString templs, QString host, quint16 port,
Viewer::~Viewer()
{
+ updatetimer.stop();
+ netcom->discard(); // Make sure sessionid is removed.
delete netcom;
delete journal;
}