/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set et sw=2 ts=2: */ /*************************************************************************** * pcpviewer.cc * * Tue Oct 11 14:13:34 CEST 2011 * Copyright 2011 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 "pcpviewer.h" #include #include #include "pcppatient.h" #include "pcpjournal.h" #include "pcpdocuments.h" #include "pcpdoc.h" #include "pcpimage.h" #include #include PCPViewer::PCPViewer(QString patientid) : praxisd("praxisd.j.auh.dk", 10000) { setWindowTitle(tr("Pracro Patient View")); setWindowIcon(QIcon(":/icons/icon.png")); 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)), 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)), 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) { // printf("ERROR: %s\n", text.toStdString().c_str()); } void PCPViewer::open(QString name) { praxisd.dokmenu_get_by_cpr_and_name(patientid, name); } void PCPViewer::gotDokMenuFile(QByteArray data, QString mimetype) { 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(); }