From 82a2317dd87c0011717c0c29d3d171bb5ee81242 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 3 Nov 2011 10:40:04 +0100 Subject: Initial version of complete pcpraxis viewer, with patient info, journal view and docmenu. --- client/pcpviewer/pcpviewer.cc | 98 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 80 insertions(+), 18 deletions(-) (limited to 'client/pcpviewer/pcpviewer.cc') diff --git a/client/pcpviewer/pcpviewer.cc b/client/pcpviewer/pcpviewer.cc index 739a681..5853e0a 100644 --- a/client/pcpviewer/pcpviewer.cc +++ b/client/pcpviewer/pcpviewer.cc @@ -27,40 +27,102 @@ */ #include "pcpviewer.h" -#include +#include -PCPViewer::PCPViewer(QString patientid) : praxisd("localhost", 10000) +#include + +#include "pcppatient.h" +#include "pcpjournal.h" +#include "pcpdocuments.h" +#include "pcpdoc.h" +#include "pcpimage.h" + +#include +#include + +PCPViewer::PCPViewer(QString patientid) : praxisd("sarge", 10000) { this->patientid = patientid; + setLayout(new QVBoxLayout()); + connect(&praxisd, SIGNAL(networkError(QString)), this, SLOT(networkError(QString))); - /* + PCPPatient *patient = new PCPPatient(); + layout()->addWidget(patient); connect(&praxisd, SIGNAL(gotPatient(Patient)), - this, SLOT(gotPatient(Patient))); - */ + patient, SLOT(setData(Patient))); + + split = new QSplitter(Qt::Vertical); + + PCPJournal *journal = new PCPJournal(); + split->addWidget(journal); + connect(&praxisd, SIGNAL(gotJournal(QString)), + journal, SLOT(setData(QString))); + + PCPDocuments *documents = new PCPDocuments(); + split->addWidget(documents); connect(&praxisd, SIGNAL(gotDokMenu(DokMenuVector)), - this, SLOT(gotDokMenu(DokMenuVector))); + documents, SLOT(setData(DokMenuVector))); + connect(documents, SIGNAL(open(QString)), + this, SLOT(open(QString))); + connect(&praxisd, SIGNAL(gotDokMenuFile(QByteArray, QString)), + this, SLOT(gotDokMenuFile(QByteArray, QString))); + + layout()->addWidget(split); + + init(); + praxisd.journal_get_by_cpr(patientid); + praxisd.patient_get_by_cpr(patientid); praxisd.dokmenu_get_all_by_cpr(patientid); } -void PCPViewer::networkError(QString text) +void PCPViewer::networkError(QString) +{ + // printf("ERROR: %s\n", text.toStdString().c_str()); +} + +void PCPViewer::open(QString name) { - printf("ERROR: %s\n", text.toStdString().c_str()); + praxisd.dokmenu_get_by_cpr_and_name(patientid, name); } -void PCPViewer::gotDokMenu(DokMenuVector d) +void PCPViewer::gotDokMenuFile(QByteArray data, QString mimetype) { - DokMenuVector::iterator di = d.begin(); - while(di != d.end()) { - printf("%s %s %s %d %s\n", - di->group.toStdString().c_str(), - di->subject.toStdString().c_str(), - di->filename.toStdString().c_str(), - di->filesize, - di->date.toStdString().c_str()); - di++; + if(mimetype == "image/jpeg; charset=binary") { + PCPImage *img = new PCPImage(); + img->setData(data); + img->show(); } + + if(mimetype == "text/plain; charset=cp850") { + PCPDoc *doc = new PCPDoc("cp850"); + doc->setText(data); + doc->resize(600, 750); + doc->show(); + } +} + +void PCPViewer::closeEvent(QCloseEvent *event) +{ + QSettings settings("Aasimon.org", "PCPViewer"); + + settings.beginGroup("MainWindow"); + settings.setValue("geometry", saveGeometry()); + settings.setValue("split", split->saveState()); + settings.endGroup(); + + event->accept(); +} + +void PCPViewer::init() +{ + QSettings settings("Aasimon.org", "PCPViewer"); + + settings.beginGroup("MainWindow"); + restoreGeometry(settings.value("geometry").toByteArray()); + split->restoreState(settings.value("split").toByteArray()); + settings.endGroup(); } -- cgit v1.2.3