summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/client.pro2
-rw-r--r--client/macrowindow.cc9
-rw-r--r--client/mainwindow.cc9
-rw-r--r--client/pracro.cc8
-rw-r--r--client/resumewidget.cc13
-rw-r--r--client/resumewidget.h8
-rw-r--r--client/viewer.cc25
-rw-r--r--client/viewer.h9
8 files changed, 71 insertions, 12 deletions
diff --git a/client/client.pro b/client/client.pro
index 7db485e..90e0b66 100644
--- a/client/client.pro
+++ b/client/client.pro
@@ -15,7 +15,7 @@ debug {
CONFIG += debug
}
-DEFINES+=VERSION=\\\"2.0.0-beta1\\\"
+DEFINES+=VERSION=\\\"2.0.0-beta2\\\"
win32 {
LIBPATH += lua/lib
diff --git a/client/macrowindow.cc b/client/macrowindow.cc
index d9060b0..b37fe5f 100644
--- a/client/macrowindow.cc
+++ b/client/macrowindow.cc
@@ -93,7 +93,14 @@ void MacroWindow::initMacro(QDomNode &node)
// Nothing to do here
} else if(xml_elem.tagName() == "resume") {
QString resume = xml_elem.text();
- ((ResumeWidget*)collapsedWidget())->setText(resume);
+ ResumeWidget::state_t state = ResumeWidget::OLD;
+ if(xml_elem.hasAttribute("state")) {
+ if(xml_elem.attribute("state") == "old") state = ResumeWidget::OLD;
+ if(xml_elem.attribute("state") == "new") state = ResumeWidget::NEW;
+ if(xml_elem.attribute("state") == "dirty") state = ResumeWidget::DIRTY;
+ }
+
+ ((ResumeWidget*)collapsedWidget())->setText(resume, state);
} else if(xml_elem.tagName() == "script") {
if(xml_elem.hasAttribute("language") &&
diff --git a/client/mainwindow.cc b/client/mainwindow.cc
index 3d49752..40daad8 100644
--- a/client/mainwindow.cc
+++ b/client/mainwindow.cc
@@ -142,6 +142,8 @@ void MainWindow::showSessions()
sessions.show();
}
+extern QWidget *viewer;
+//#include <QApplication>
void MainWindow::closeEvent(QCloseEvent *event)
{
if(isStored || QMessageBox::question(this,
@@ -150,6 +152,11 @@ void MainWindow::closeEvent(QCloseEvent *event)
"Are you sure you want to continue?",
QMessageBox::Yes | QMessageBox::No)
== QMessageBox::Yes) {
+ if(!isStored) {
+ netcom.discard();
+ sessions.remove(cpr);
+ }
+
QSettings settings("Aasimon.org", "Pracro");
settings.beginGroup("MainWindow");
@@ -159,6 +166,8 @@ void MainWindow::closeEvent(QCloseEvent *event)
settings.endGroup();
event->accept();
+ if(viewer) viewer->close();
+ // qApp->quit();
} else {
event->ignore();
}
diff --git a/client/pracro.cc b/client/pracro.cc
index bb2d952..ad46085 100644
--- a/client/pracro.cc
+++ b/client/pracro.cc
@@ -54,7 +54,7 @@ QString host;
quint16 port;
QFont *fixedfont;
-
+QWidget *viewer = NULL;
static void print_usage()
{
printf("Usage: pracro -m MACRO -c CPR -U USER\n");
@@ -173,9 +173,9 @@ int main(int argc, char *argv[])
MainWindow mainwindow(cpr, templ, host, port, user);
mainwindow.show();
- Viewer viewer(cpr, templs, host, port, user, journalpath);
- viewer.show();
-
+ Viewer v(cpr, templs, host, port, user, journalpath);
+ viewer = &v;
+ v.show();
return app.exec();
}
diff --git a/client/resumewidget.cc b/client/resumewidget.cc
index ac18578..81e3f2c 100644
--- a/client/resumewidget.cc
+++ b/client/resumewidget.cc
@@ -83,7 +83,7 @@ static QString reformatString(QString help)
return output;
}
-void ResumeWidget::setText(QString text)
+void ResumeWidget::setText(QString text, state_t state)
{
QString f;
@@ -120,6 +120,17 @@ void ResumeWidget::setText(QString text)
}
}
+ switch(state) {
+ case NEW:
+ f = "<font style='color: #00F;'>" + f + "</font>";
+ break;
+ case OLD:
+ break;
+ case DIRTY:
+ f = "<font style='color: #F00;'>" + f + "</font>";
+ break;
+ }
+
resume->setText(f);
}
diff --git a/client/resumewidget.h b/client/resumewidget.h
index fe8beb1..22f4d58 100644
--- a/client/resumewidget.h
+++ b/client/resumewidget.h
@@ -36,7 +36,13 @@ Q_OBJECT
public:
ResumeWidget(bool compact);
- void setText(QString text);
+ typedef enum {
+ NEW,
+ OLD,
+ DIRTY
+ } state_t;
+
+ void setText(QString text, state_t state);
public slots:
void showFull(const QString &);
diff --git a/client/viewer.cc b/client/viewer.cc
index c4bd3f5..eabcf16 100644
--- a/client/viewer.cc
+++ b/client/viewer.cc
@@ -35,6 +35,7 @@
#include <QSettings>
#include <QTextCodec>
+#ifdef WITH_FROGS
Status::Status()
{
QVBoxLayout *vl = new QVBoxLayout();
@@ -73,6 +74,9 @@ void Status::setStatus(QString macro, QString caption, bool done)
icons[macro]->setPixmap(QPixmap(done?":/icons/done.png":":icons/undone.png"));
}
+#endif
+
+extern QFont *fixedfont; // Defined in pracro.cc
Viewer::Viewer(QString cpr, QString templs, QString host, quint16 port,
QString user, QString journalpath)
@@ -81,11 +85,14 @@ 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()));
+
+#ifdef WITH_FROGS
netcom = new NetCom(host, port);
netcom->user = user;
netcom->patientid = cpr;
netcom->sessionid = "";
netcom->initConnection();
+#endif
host = host; port = port; user = user;
this->cpr = cpr;
@@ -95,6 +102,7 @@ Viewer::Viewer(QString cpr, QString templs, QString host, quint16 port,
QVBoxLayout *l = new QVBoxLayout();
setLayout(l);
+#ifdef WITH_FROGS
QStringList::iterator ti = this->templs.begin();
while(ti != this->templs.end()) {
Status *s = new Status();
@@ -102,10 +110,11 @@ Viewer::Viewer(QString cpr, QString templs, QString host, quint16 port,
statuses[*ti] = s;
ti++;
}
+#endif
journal = new QTextEdit();
journal->setReadOnly(true);
- journal->setFontFamily("Courier New");
+ journal->setFont(*fixedfont);
l->addWidget(journal);
init();
@@ -114,12 +123,13 @@ Viewer::Viewer(QString cpr, QString templs, QString host, quint16 port,
Viewer::~Viewer()
{
- updatetimer.stop();
- netcom->discard(); // Make sure sessionid is removed.
+#ifdef WITH_FROGS
delete netcom;
+#endif
delete journal;
}
+extern QWidget *viewer;
void Viewer::closeEvent(QCloseEvent *)
{
QSettings settings("Aasimon.org", "Pracro");
@@ -128,6 +138,13 @@ void Viewer::closeEvent(QCloseEvent *)
settings.setValue("size", size());
settings.setValue("pos", pos());
settings.endGroup();
+ viewer = NULL;
+
+ updatetimer.stop();
+
+#ifdef WITH_FROGS
+ netcom->discard(); // Make sure sessionid is removed.
+#endif
}
void Viewer::init()
@@ -143,6 +160,7 @@ void Viewer::init()
void Viewer::update()
{
+#ifdef WITH_FROGS
QStringList::iterator ti = templs.begin();
while(ti != templs.end()) {
QDomDocument xml_doc = netcom->send(*ti, "", false);
@@ -171,6 +189,7 @@ void Viewer::update()
ti++;
}
+#endif
// re-read journal file:
QString crypt;
diff --git a/client/viewer.h b/client/viewer.h
index 7877b8e..c9f1b41 100644
--- a/client/viewer.h
+++ b/client/viewer.h
@@ -36,6 +36,9 @@
#include <QMap>
#include <QHBoxLayout>
+//#define WITH_FROGS
+
+#ifdef WITH_FROGS
#include "netcom.h"
class Status : public QWidget {
@@ -49,6 +52,7 @@ private:
QMap<QString, QLabel*> icons;
QHBoxLayout *hl;
};
+#endif
class Viewer : public QWidget {
Q_OBJECT
@@ -71,10 +75,13 @@ private:
QString cpr;
QString journalpath;
QStringList templs;
- NetCom *netcom;
QTextEdit *journal;
+
+#ifdef WITH_FROGS
+ NetCom *netcom;
QMap<QString, Status* > statuses;
+#endif
};
#endif/*__PRACRO_VIEWER_H__*/