diff options
author | deva <deva> | 2011-01-28 08:50:27 +0000 |
---|---|---|
committer | deva <deva> | 2011-01-28 08:50:27 +0000 |
commit | 7917d099f34acda6c4c90bca28710a7bd67800e9 (patch) | |
tree | ea9427001b1bf6cd99b04e064a7948d8550e12d8 | |
parent | 34366d806d70184876ad7d195f21c7d4c257c778 (diff) |
New cross client session system.
-rw-r--r-- | client/client.pro | 2 | ||||
-rw-r--r-- | client/macro.cc | 11 | ||||
-rw-r--r-- | client/mainwindow.cc | 33 | ||||
-rw-r--r-- | client/mainwindow.h | 6 | ||||
-rw-r--r-- | client/netcom.cc | 46 | ||||
-rw-r--r-- | client/netcom.h | 13 | ||||
-rw-r--r-- | client/widgets/altcombobox.cc | 4 |
7 files changed, 76 insertions, 39 deletions
diff --git a/client/client.pro b/client/client.pro index fe54880..509ad9d 100644 --- a/client/client.pro +++ b/client/client.pro @@ -46,7 +46,6 @@ HEADERS += \ messagebox.h \ netcom.h \ resumewidget.h \ - sessions.h \ viewer.h \ widgets.h \ widgets/common.h \ @@ -83,7 +82,6 @@ SOURCES += \ messagebox.cc \ netcom.cc \ resumewidget.cc \ - sessions.cc \ viewer.cc \ widgets/common.cc \ widgets/widget.cc \ diff --git a/client/macro.cc b/client/macro.cc index 3bcdaeb..4ac56f6 100644 --- a/client/macro.cc +++ b/client/macro.cc @@ -111,8 +111,15 @@ void Macro::init(QBoxLayout *layout, Macros ¯os, drawer = new MacroDrawer(this, xml_elem.attribute("caption", name), NULL/*edge*/); drawer->connect(drawer, SIGNAL(toggle()), window, SLOT(toggleMacro())); - drawer->connect(window, SIGNAL(activationChanged(bool)), drawer, - SLOT(activationChange(bool))); + drawer->connect(window, SIGNAL(activationChanged(bool)), + drawer, SLOT(activationChange(bool))); + + /* + QObject::connect(drawer, SIGNAL(toggle()), window, SLOT(toggleMacro())); + QObject::connect(window, SIGNAL(activationChanged(bool)), + drawer, SLOT(activationChange(bool))); + */ + //drawer->setAutoFillBackground(true); //drawer->setContentsMargins(1,1,1,1); window->setActive(false); diff --git a/client/mainwindow.cc b/client/mainwindow.cc index 4b6810b..551a78b 100644 --- a/client/mainwindow.cc +++ b/client/mainwindow.cc @@ -71,6 +71,7 @@ MainWindow::MainWindow(QString cpr, QString templ, QString host, this->cpr = cpr; this->user = user; + this->templ = templ; setWindowTitle("Pracro - " + cpr); setWindowIcon(QIcon(":/icons/icon.png")); @@ -94,13 +95,13 @@ MainWindow::MainWindow(QString cpr, QString templ, QString host, connect(close_discard, SIGNAL(triggered()), this, SLOT(closeDiscard())); */ toolbar->addSeparator(); - + /* QAction *show_sessions = toolbar->addAction(tr("Show sessions")); show_sessions->setIcon(QPixmap(":icons/icon_current_sessions.png")); - + */ connect(close_commit, SIGNAL(triggered()), this, SLOT(closeCommit())); connect(close_no_commit, SIGNAL(triggered()), this, SLOT(closeNoCommit())); - connect(show_sessions, SIGNAL(triggered()), this, SLOT(showSessions())); + // connect(show_sessions, SIGNAL(triggered()), this, SLOT(showSessions())); QScrollArea *s = new QScrollArea(); setCentralWidget(s); @@ -109,15 +110,15 @@ MainWindow::MainWindow(QString cpr, QString templ, QString host, s->setWidgetResizable(true); w->setLayout(new QVBoxLayout()); - this->templ = templ; setStatusBar(status); init(); - + /* if(sessions.isEmpty()) { show_sessions->setEnabled(false); } + */ } MainWindow::~MainWindow() @@ -127,7 +128,7 @@ MainWindow::~MainWindow() void MainWindow::closeCommit() { netcom.commit(); - sessions.remove(cpr); + // sessions.remove(cpr); isStored = true; close(); } @@ -139,8 +140,9 @@ void MainWindow::closeNoCommit() tr("This session will be stored on this computer " "only. To reopen it at a later time, simply " "open the same patient again.")); - sessions.add(cpr, user, netcom.sessionid); + // sessions.add(cpr, user, netcom.sessionid); isStored = true; + netcom.nocommit(); close(); } @@ -154,17 +156,17 @@ void MainWindow::closeDiscard() QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { netcom.discard(); - sessions.remove(cpr); + // sessions.remove(cpr); isStored = true; close(); } } - +/* void MainWindow::showSessions() { sessions.show(); } - +*/ extern QWidget *viewer; //#include <QApplication> void MainWindow::closeEvent(QCloseEvent *event) @@ -179,7 +181,7 @@ void MainWindow::closeEvent(QCloseEvent *event) == QMessageBox::Yes) { if(!isStored) { netcom.discard(); - sessions.remove(cpr); + // sessions.remove(cpr); } QSettings settings("Aasimon.org", "Pracro"); @@ -187,7 +189,7 @@ void MainWindow::closeEvent(QCloseEvent *event) settings.beginGroup("MainWindow"); settings.setValue("size", size()); settings.setValue("pos", pos()); - settings.setValue(QString("sessions"), sessions.toVariant()); + // settings.setValue(QString("sessions"), sessions.toVariant()); settings.endGroup(); event->accept(); @@ -205,19 +207,20 @@ 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")); + // sessions.fromVariant(settings.value("sessions")); settings.endGroup(); netcom.patientid = cpr; + netcom.templ = templ; 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; diff --git a/client/mainwindow.h b/client/mainwindow.h index a9fb596..03abf09 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -34,7 +34,7 @@ #include <QFont> #include "netcom.h" -#include "sessions.h" +//#include "sessions.h" #include "macro.h" class QLabel; @@ -52,7 +52,7 @@ public slots: void closeCommit(); void closeNoCommit(); void closeDiscard(); - void showSessions(); + // void showSessions(); private: void updateTemplateHeaders(QDomNode templatenode); @@ -71,7 +71,7 @@ private: bool initialising; - Sessions sessions; + // Sessions sessions; void init(); diff --git a/client/netcom.cc b/client/netcom.cc index d04493f..d2d3cdd 100644 --- a/client/netcom.cc +++ b/client/netcom.cc @@ -81,22 +81,36 @@ void NetCom::replyFinished(QNetworkReply *reply) finished[reply] = true; } -QDomDocument NetCom::makeTransfer(QDomDocument &doc, - bool commit, bool lockgui, bool discard) +QDomDocument NetCom::makeTransfer(QDomDocument &doc, bool lockgui, + session_state_t state) { DEBUG(netcom, "Making transfer:\n%s", doc.toString().toStdString().c_str()); if(lockgui && qApp->activeWindow()) qApp->activeWindow()->setEnabled(false); if(lockgui) QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - if(sessionid != "") request.setRawHeader("SessionID", - sessionid.toStdString().c_str()); - if(commit) { - request.setRawHeader("SessionCommit", "yes"); + LOG(netcom, "SESSION ID: %s\n", sessionid.toStdString().c_str()); + + if(sessionid != "") { + request.setRawHeader("SessionID", sessionid.toStdString().c_str()); + } else { + request.setRawHeader("SessionPatientID", patientid.toStdString().c_str()); + request.setRawHeader("SessionTemplate", templ.toStdString().c_str()); } - if(discard) { + switch(state) { + case ::commit: + request.setRawHeader("SessionCommit", "yes"); + break; + case ::discard: request.setRawHeader("SessionDiscard", "yes"); + break; + case ::nocommit: + request.setRawHeader("SessionNoCommit", "yes"); + break; + default: + case ::none: + break; } // QNetworkReply *reply = manager->get(request); @@ -117,7 +131,7 @@ QDomDocument NetCom::makeTransfer(QDomDocument &doc, if(reply->hasRawHeader("SessionID")) { sessionid = reply->rawHeader("SessionID"); - LOG(netcom, "SESSION ID: %s\n", sessionid.toStdString().c_str()); + LOG(netcom, "Reply SESSION ID: %s\n", sessionid.toStdString().c_str()); } if(lockgui) QApplication::restoreOverrideCursor(); @@ -129,19 +143,25 @@ QDomDocument NetCom::makeTransfer(QDomDocument &doc, QDomDocument NetCom::initConnection() { QDomDocument doc; - return makeTransfer(doc, false, true); + return makeTransfer(doc, true); } QDomDocument NetCom::commit() { QDomDocument doc; - return makeTransfer(doc, true, true); + return makeTransfer(doc, true, ::commit); +} + +QDomDocument NetCom::nocommit() +{ + QDomDocument doc; + return makeTransfer(doc, true, ::nocommit); } QDomDocument NetCom::discard() { QDomDocument doc; - return makeTransfer(doc, false, true, true); + return makeTransfer(doc, true, ::discard); } QDomDocument NetCom::send(QString templ, QString macro, bool lockgui) @@ -163,7 +183,7 @@ QDomDocument NetCom::send(QString templ, QString macro, bool lockgui) if(macro != "") request_elem.setAttribute("macro", macro); pracro_elem.appendChild(request_elem); - return makeTransfer(doc, false, lockgui); + return makeTransfer(doc, lockgui); } QDomDocument NetCom::send(QVector< Widget* > widgets, QString templ, @@ -206,5 +226,5 @@ QDomDocument NetCom::send(QVector< Widget* > widgets, QString templ, i++; } - return makeTransfer(doc, false, true); + return makeTransfer(doc, true); } diff --git a/client/netcom.h b/client/netcom.h index 79bb78f..e6478a5 100644 --- a/client/netcom.h +++ b/client/netcom.h @@ -39,6 +39,13 @@ //#include "widgets/widget.h" class Widget; +typedef enum { + none, + commit, + nocommit, + discard +} session_state_t; + class NetCom : public QObject { Q_OBJECT public: @@ -50,11 +57,13 @@ public: QString macro, QString version); QDomDocument initConnection(); QDomDocument commit(); + QDomDocument nocommit(); QDomDocument discard(); QString sessionid; QString user; QString patientid; + QString templ; public slots: void replyFinished(QNetworkReply*); @@ -67,8 +76,8 @@ private: QMap<QNetworkReply *, bool> finished; - QDomDocument makeTransfer(QDomDocument &dom, - bool commit, bool lockgui, bool discard = false); + QDomDocument makeTransfer(QDomDocument &dom, bool lockgui, + session_state_t state = none); }; #endif/*__PRACRO_NETCOM_H__*/ diff --git a/client/widgets/altcombobox.cc b/client/widgets/altcombobox.cc index 224822e..a816cbd 100644 --- a/client/widgets/altcombobox.cc +++ b/client/widgets/altcombobox.cc @@ -244,7 +244,7 @@ void AltComboBox::setWdgValid(bool valid) palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200))); } - frame->setPalette(palette); - combobox->qwidget()->setPalette(palette); + // frame->setPalette(palette); + combobox->setWdgValid(valid); // if(innerwidget) innerwidget->setWdgValid(valid); } |