summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2011-07-01 11:41:35 +0000
committerdeva <deva>2011-07-01 11:41:35 +0000
commit5eb7e97b9d529c93ebbddcc52c4a8f96e95928ba (patch)
treeca70b2bb206c6c2aa707015f8a2963d8a4e143b5
parent112b2b7bde8d215d1e62b91320c01e8aa2309cac (diff)
Removed the viewer. It is no longer needed.
-rw-r--r--client/pracro.cc54
-rw-r--r--client/pracro.ini1
-rw-r--r--client/viewer.cc229
-rw-r--r--client/viewer.h88
4 files changed, 12 insertions, 360 deletions
diff --git a/client/pracro.cc b/client/pracro.cc
index 2a6a109..b4d06d8 100644
--- a/client/pracro.cc
+++ b/client/pracro.cc
@@ -61,21 +61,20 @@ QFont *fixedfont = NULL;
static void print_usage()
{
- printf("Usage: pracro -m MACRO -c CPR -U USER\n");
+ printf("Usage: pracro [params]\n");
printf("Executes the requested Pracro MACRO using supplied CPR and USER.\n");
printf("\n");
printf(" -h, --help Displays this help text.\n");
printf(" -t, --template TEMPLATE Requests template TEMPLATE from the Pracro \n"
" Server, defaults to \""TEMPLATE_DEFAULT"\".\n");
- printf(" -C, --cpr CPR Defines the cpr for use with the macro,\n"
+ printf(" -C --course COURSE Lists templates in COURSE.\n");
+ printf(" -P, --patient PATIENTID Defines the patientid for use with the macro,\n"
" defaults to \""CPR_DEFAULT"\".\n");
printf(" -c, --config FILE The configfile to use. Default is \""CONFIG_DEFAULT"\"\n");
printf(" -u, -U, --user USER Defines the requesting user(not the patient),\n"
" defaults to \""USER_DEFAULT"\"\n");
printf(" -v, --version Print version information and exit.\n");
printf(" -d, --debug Make debug console available.\n");
- printf(" -V, --viewer TEMPLATES Show the viewer with TEMPLATES.\n");
- printf(" -O, --viewer-only TEMPLATES\n");
printf(" Show the viewer only (no pracro editor window) with TEMPLATES.\n");
}
@@ -100,8 +99,7 @@ int main(int argc, char *argv[])
QString macro = MACRO_DEFAULT;
QString templ = TEMPLATE_DEFAULT;
- bool show_viewer = false;
- bool show_editor = true;
+ QString course;
QString templs;
QStringList args = app.arguments();
@@ -128,8 +126,12 @@ int main(int argc, char *argv[])
*arg == "-t") {
templ = getParam(args, arg);
}
- else if(*arg == "--cpr" ||
+ else if(*arg == "--course" ||
*arg == "-C") {
+ course = getParam(args, arg);
+ }
+ else if(*arg == "--patientid" ||
+ *arg == "-P") {
cpr = getParam(args, arg);
}
else if(*arg == "--config" ||
@@ -140,17 +142,6 @@ int main(int argc, char *argv[])
*arg == "-d") {
dbg_init();
}
- else if(*arg == "--viewer" ||
- *arg == "-V") {
- templs = getParam(args, arg);
- show_viewer = true;
- }
- else if(*arg == "--viewer-only" ||
- *arg == "-O") {
- templs = getParam(args, arg);
- show_viewer = true;
- show_editor = false;
- }
else {
print_version();
print_usage();
@@ -188,31 +179,10 @@ int main(int argc, char *argv[])
}
}
- if(show_editor && show_viewer) {
- MainWindow mainwindow(cpr, templ, host, port, user);
- mainwindow.show();
-
- Viewer v(cpr, templs, host, port, user, journalpath);
- viewer = &v;
- v.show();
- return app.exec();
- }
-
- if(show_editor) {
- MainWindow mainwindow(cpr, templ, host, port, user);
- mainwindow.show();
-
- return app.exec();
- }
-
- if(show_viewer) {
- Viewer viewer(cpr, templs, host, port, user, journalpath);
- viewer.show();
-
- return app.exec();
- }
+ MainWindow mainwindow(cpr, templ, host, port, user);
+ mainwindow.show();
- return 1;
+ return app.exec();
}
diff --git a/client/pracro.ini b/client/pracro.ini
index c3d0dce..25fd0bf 100644
--- a/client/pracro.ini
+++ b/client/pracro.ini
@@ -2,4 +2,3 @@
#host=pracserv.j.auh.dk
host=localhost
port=12345
-journalpath="/home/deva/docs/uploadserver/data/" \ No newline at end of file
diff --git a/client/viewer.cc b/client/viewer.cc
deleted file mode 100644
index 170210c..0000000
--- a/client/viewer.cc
+++ /dev/null
@@ -1,229 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set et sw=2 ts=2: */
-/***************************************************************************
- * viewer.cc
- *
- * Mon Aug 17 08:53:29 CEST 2009
- * Copyright 2009 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of Pracro.
- *
- * Pracro is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Pracro is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Pracro; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#include "viewer.h"
-
-#include <QVBoxLayout>
-#include <QHBoxLayout>
-#include <QFile>
-#include <QScrollBar>
-
-#include <QSettings>
-#include <QTextCodec>
-
-#ifdef WITH_FROGS
-Status::Status()
-{
- QVBoxLayout *vl = new QVBoxLayout();
- setLayout(vl);
- this->caption = new QLabel();
- vl->addWidget(this->caption);
-
- QHBoxLayout *ohl = new QHBoxLayout();
- ohl->setContentsMargins(0,0,0,0);
- vl->addLayout(ohl);
-
- hl = new QHBoxLayout();
- hl->setContentsMargins(0,0,0,0);
- ohl->addLayout(hl);
-
- ohl->addStretch();
-}
-
-void Status::setCaption(QString caption)
-{
- this->caption->setText(caption + ":");
-}
-
-void Status::setStatus(QString macro, QString caption, bool done)
-{
- if(icons.find(macro) == icons.end()) {
- QLabel *icon = new QLabel();
- icon->setContentsMargins(0,0,0,0);
- icon->setMargin(0);
- icon->setIndent(0);
- icon->setWhatsThis(caption);
- icon->setToolTip(caption);
- icons[macro] = icon;
- hl->addWidget(icon);
- }
-
- 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)
- : QWidget(NULL)
-{
- 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;
- this->journalpath = journalpath;
- updatetimer.start(10000); // Trigger every 10 seconds
-
- QVBoxLayout *l = new QVBoxLayout();
- setLayout(l);
-
-#ifdef WITH_FROGS
- QStringList::iterator ti = this->templs.begin();
- while(ti != this->templs.end()) {
- Status *s = new Status();
- l->addWidget(s);
- statuses[*ti] = s;
- ti++;
- }
-#endif
-
- journal = new QPlainTextEdit();
- journal->setReadOnly(true);
- journal->setFont(*fixedfont);
- l->addWidget(journal);
-
- init();
- show();
- update();
-}
-
-Viewer::~Viewer()
-{
-#ifdef WITH_FROGS
- delete netcom;
-#endif
- delete journal;
-}
-
-extern QWidget *viewer;
-void Viewer::closeEvent(QCloseEvent *)
-{
- QSettings settings("Aasimon.org", "Pracro");
-
- settings.beginGroup("ViewerWindow");
- 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()
-{
- QSettings settings("Aasimon.org", "Pracro");
-
- settings.beginGroup("ViewerWindow");
- resize(settings.value("size", QSize(700, 800)).toSize());
- move(settings.value("pos", QPoint(0, 0)).toPoint());
- settings.endGroup();
-}
-
-
-void Viewer::update()
-{
-#ifdef WITH_FROGS
- QStringList::iterator ti = templs.begin();
- while(ti != templs.end()) {
- QDomDocument xml_doc = netcom->send(*ti, "", false);
-
- QDomNodeList templates = xml_doc.documentElement().childNodes();
- QDomNode templatenode = templates.at(0); // There can be only one! (Swush, flomp)
- QDomElement templateelement = templatenode.toElement();
-
- statuses[*ti]->setCaption(templateelement.attribute("title"));
-
- QDomNodeList macronodes = templatenode.childNodes();
- for(int j = 0; j < macronodes.count(); j++) {
- QDomNode macronode = macronodes.at(j);
- QDomElement macroelement = macronode.toElement();
-
- if(macroelement.tagName() != "macro") continue;
-
- if(macroelement.attribute("static") == "true") continue;
-
- QString macroname = macroelement.attribute("name");
- QString caption = macroelement.attribute("caption");
- QString completed = macroelement.attribute("completed");
-
- statuses[*ti]->setStatus(macroname, caption, completed == "true");
- }
-
- ti++;
- }
-#endif
-
- // re-read journal file:
- QString crypt;
- for(int i = cpr.length() - 1; i >= 0; i--) {
- if(i == 2 || i == 3) continue;
- crypt += QString::number(9 - cpr.mid(i, 1).toInt());
- }
-
- QString filename = journalpath + "/" + cpr.mid(2,2) + "/" + crypt + "/JOURNAL.TXT";
-
- QTextCodec *cp850 = QTextCodec::codecForName("cp850");
- if(!cp850) {
- printf("Could not find decoder for cp850!\n");
- }
-
- QFile jfile(filename);
- jfile.open(QIODevice::ReadOnly);
- QByteArray jcp850 = jfile.readAll();
- QString j = cp850->toUnicode(jcp850);
-
- QString jstrip;
- for(int i = 0; i < j.length(); i++) {
- if(j[i] != '·' && j[i] != '')
- jstrip += j[i]; // Remove end of line and file symbols.
- }
-
- if(jlast != jstrip) {
- int max = journal->verticalScrollBar()->maximum();
- int pos = journal->verticalScrollBar()->value();
- journal->setPlainText(jstrip);
- // Scroll to bottom if we were there already
- if(pos == max) pos = journal->verticalScrollBar()->maximum();
- journal->verticalScrollBar()->setValue(pos);
- jlast = jstrip;
- }
-}
diff --git a/client/viewer.h b/client/viewer.h
deleted file mode 100644
index 799bb3d..0000000
--- a/client/viewer.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set et sw=2 ts=2: */
-/***************************************************************************
- * viewer.h
- *
- * Mon Aug 17 08:53:29 CEST 2009
- * Copyright 2009 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of Pracro.
- *
- * Pracro is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Pracro is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Pracro; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#ifndef __PRACRO_VIEWER_H__
-#define __PRACRO_VIEWER_H__
-
-#include <QApplication>
-#include <QPlainTextEdit>
-#include <QTimer>
-#include <QLabel>
-#include <QStringList>
-#include <QMap>
-#include <QHBoxLayout>
-
-//#define WITH_FROGS
-
-#ifdef WITH_FROGS
-#include "netcom.h"
-
-class Status : public QWidget {
-public:
- Status();
- void setStatus(QString macro, QString caption, bool done);
- void setCaption(QString caption);
-
-private:
- QLabel *caption;
- QMap<QString, QLabel*> icons;
- QHBoxLayout *hl;
-};
-#endif
-
-class Viewer : public QWidget {
-Q_OBJECT
-public:
- Viewer(QString cpr, QString templ, QString host, quint16 port,
- QString user, QString journalpath);
- ~Viewer();
-
- void init();
-
-protected:
- void closeEvent(QCloseEvent *);
-
-public slots:
- void update();
-
-private:
- QTimer updatetimer;
-
- QString cpr;
- QString journalpath;
- QStringList templs;
-
- QPlainTextEdit *journal;
- QString jlast;
-
-#ifdef WITH_FROGS
- NetCom *netcom;
- QMap<QString, Status* > statuses;
-#endif
-};
-
-#endif/*__PRACRO_VIEWER_H__*/