diff options
-rw-r--r-- | client/client.pro | 10 | ||||
-rw-r--r-- | client/mainwindow.cc | 7 | ||||
-rw-r--r-- | client/mainwindow.h | 3 | ||||
-rw-r--r-- | client/pcpviewer/pcpdoc.cc | 61 | ||||
-rw-r--r-- | client/pcpviewer/pcpdoc.h | 46 | ||||
-rw-r--r-- | client/pcpviewer/pcpdocuments.cc | 72 | ||||
-rw-r--r-- | client/pcpviewer/pcpdocuments.h | 54 | ||||
-rw-r--r-- | client/pcpviewer/pcpimage.cc | 41 | ||||
-rw-r--r-- | client/pcpviewer/pcpimage.h | 45 | ||||
-rw-r--r-- | client/pcpviewer/pcpjournal.cc | 43 | ||||
-rw-r--r-- | client/pcpviewer/pcpjournal.h | 47 | ||||
-rw-r--r-- | client/pcpviewer/pcppatient.cc | 45 | ||||
-rw-r--r-- | client/pcpviewer/pcppatient.h | 48 | ||||
-rw-r--r-- | client/pcpviewer/pcpviewer.cc | 98 | ||||
-rw-r--r-- | client/pcpviewer/pcpviewer.h | 12 | ||||
-rw-r--r-- | client/pracro.cc | 27 | ||||
-rw-r--r-- | client/praxisd.cc | 2 | ||||
-rw-r--r-- | client/praxisd.h | 2 |
18 files changed, 634 insertions, 29 deletions
diff --git a/client/client.pro b/client/client.pro index c6c7e86..61a6e06 100644 --- a/client/client.pro +++ b/client/client.pro @@ -56,6 +56,11 @@ HEADERS += \ expandbutton.h \ aboutbox.h \ pcpviewer/pcpviewer.h \ + pcpviewer/pcpjournal.h \ + pcpviewer/pcppatient.h \ + pcpviewer/pcpdocuments.h \ + pcpviewer/pcpdoc.h \ + pcpviewer/pcpimage.h \ widgets/common.h \ widgets/widget.h \ widgets/label.h \ @@ -98,6 +103,11 @@ SOURCES += \ expandbutton.cc \ aboutbox.cc \ pcpviewer/pcpviewer.cc \ + pcpviewer/pcpjournal.cc \ + pcpviewer/pcppatient.cc \ + pcpviewer/pcpdocuments.cc \ + pcpviewer/pcpdoc.cc \ + pcpviewer/pcpimage.cc \ widgets/common.cc \ widgets/widget.cc \ widgets/label.cc \ diff --git a/client/mainwindow.cc b/client/mainwindow.cc index 700501f..680c235 100644 --- a/client/mainwindow.cc +++ b/client/mainwindow.cc @@ -53,6 +53,9 @@ #include "debug.h" +// Declared in pracro.cc +extern QString patientname; + class Dbg : public QLabel { public: Dbg() { @@ -99,7 +102,7 @@ MainWindow::MainWindow(QString patientid, QString course, QString templ, this->course = course; this->templ = templ; - setWindowTitle("Pracro - " + patientid); + setWindowTitle("Pracro - " + patientid + ": " + patientname); setWindowIcon(QIcon(":/icons/icon.png")); QStatusBar *status = statusBar(); @@ -241,6 +244,8 @@ void MainWindow::closeEvent(QCloseEvent *event) } else { event->ignore(); } + + emit isClosing(); } void MainWindow::init() diff --git a/client/mainwindow.h b/client/mainwindow.h index 4a06724..524242c 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -48,6 +48,9 @@ public: void closeEvent(QCloseEvent *event); +signals: + void isClosing(); + public slots: // void update(); void showAbout(); diff --git a/client/pcpviewer/pcpdoc.cc b/client/pcpviewer/pcpdoc.cc new file mode 100644 index 0000000..33fbdd4 --- /dev/null +++ b/client/pcpviewer/pcpdoc.cc @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set et sw=2 ts=2: */ +/*************************************************************************** + * pcpdoc.cc + * + * Thu Oct 20 11:56:32 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 "pcpdoc.h" + +#include <QTextCodec> +#include <QByteArray> +#include <QScrollBar> + +PCPDoc::PCPDoc(QString codepage) +{ + this->codepage = codepage; + setReadOnly(true); + setFontFamily("Courier New"); +} + +void PCPDoc::setText(QString text) +{ + QTextCodec *cp850 = QTextCodec::codecForName(codepage.toStdString().c_str()); + if(!cp850) return; + + QByteArray datacp850; + datacp850 += text; + QString j = cp850->toUnicode(datacp850); + + QString jstrip; + for(int i = 0; i < j.length(); i++) { + if(j[i] != '\xb7') jstrip += j[i]; // Remove end of line symbols. + } + + setPlainText(jstrip); +} + +void PCPDoc::scrollToBottom() +{ + verticalScrollBar()->setSliderPosition(verticalScrollBar()->maximum()); +} diff --git a/client/pcpviewer/pcpdoc.h b/client/pcpviewer/pcpdoc.h new file mode 100644 index 0000000..25cbe68 --- /dev/null +++ b/client/pcpviewer/pcpdoc.h @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set et sw=2 ts=2: */ +/*************************************************************************** + * pcpdoc.h + * + * Thu Oct 20 11:56:32 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. + */ +#ifndef __PRACRO_PCPDOC_H__ +#define __PRACRO_PCPDOC_H__ + +#include <QTextEdit> +#include <QString> + +class PCPDoc : public QTextEdit { +Q_OBJECT +public: + PCPDoc(QString codepage); + + void setText(QString text); + void scrollToBottom(); + +private: + QString codepage; +}; + +#endif/*__PRACRO_PCPDOC_H__*/ diff --git a/client/pcpviewer/pcpdocuments.cc b/client/pcpviewer/pcpdocuments.cc new file mode 100644 index 0000000..a6e39ac --- /dev/null +++ b/client/pcpviewer/pcpdocuments.cc @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set et sw=2 ts=2: */ +/*************************************************************************** + * pcpdocuments.cc + * + * Thu Oct 20 09:11:18 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 "pcpdocuments.h" + +#include <QHBoxLayout> + +PCPDocuments::PCPDocuments() +{ + setLayout(new QHBoxLayout()); + tree = new QTreeWidget(this); + layout()->addWidget(tree); + + connect(tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), + this, SLOT(dblclick(QTreeWidgetItem*,int))); + + QStringList labels; + labels << "Group"; + labels << "Subject"; + labels << "Filename"; + labels << "Size"; + labels << "Date"; + tree->setColumnCount(labels.size()); + tree->setHeaderLabels(labels); + +} + +void PCPDocuments::setData(DokMenuVector d) +{ + DokMenuVector::iterator di = d.begin(); + while(di != d.end()) { + QTreeWidgetItem *item = new QTreeWidgetItem(); + + item->setText(0, di->group); + item->setText(1, di->subject); + item->setText(2, di->filename); + item->setText(3, QString::number(di->filesize)); + item->setText(4, di->date); + + tree->addTopLevelItem(item); + di++; + } +} + +void PCPDocuments::dblclick(QTreeWidgetItem *item, int) +{ + emit open(item->text(2)); +} diff --git a/client/pcpviewer/pcpdocuments.h b/client/pcpviewer/pcpdocuments.h new file mode 100644 index 0000000..ac14646 --- /dev/null +++ b/client/pcpviewer/pcpdocuments.h @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set et sw=2 ts=2: */ +/*************************************************************************** + * pcpdocuments.h + * + * Thu Oct 20 09:11:18 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. + */ +#ifndef __PRACRO_PCPDOCUMENTS_H__ +#define __PRACRO_PCPDOCUMENTS_H__ + +#include <QWidget> +#include <QTreeWidget> + +#include "praxisd.h" + +class PCPDocuments : public QWidget { +Q_OBJECT +public: + PCPDocuments(); + +signals: + void open(QString name); + +public slots: + void setData(DokMenuVector d); + +private slots: + void dblclick(QTreeWidgetItem *item, int); + +private: + QTreeWidget *tree; +}; + +#endif/*__PRACRO_PCPDOCUMENTS_H__*/ diff --git a/client/pcpviewer/pcpimage.cc b/client/pcpviewer/pcpimage.cc new file mode 100644 index 0000000..f3426b6 --- /dev/null +++ b/client/pcpviewer/pcpimage.cc @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set et sw=2 ts=2: */ +/*************************************************************************** + * pcpimage.cc + * + * Thu Oct 20 12:14:29 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 "pcpimage.h" + +PCPImage::PCPImage() +{ +} + +void PCPImage::setData(QByteArray data) +{ + image = QImage::fromData(data); + image = image.scaled(1024, 1024, + Qt::KeepAspectRatio, Qt::SmoothTransformation); + setPixmap(QPixmap::fromImage(image)); + resize(image.width(), image.height()); +} diff --git a/client/pcpviewer/pcpimage.h b/client/pcpviewer/pcpimage.h new file mode 100644 index 0000000..696a016 --- /dev/null +++ b/client/pcpviewer/pcpimage.h @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set et sw=2 ts=2: */ +/*************************************************************************** + * pcpimage.h + * + * Thu Oct 20 12:14:29 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. + */ +#ifndef __PRACRO_PCPIMAGE_H__ +#define __PRACRO_PCPIMAGE_H__ + +#include <QLabel> +#include <QByteArray> + +class PCPImage : public QLabel { +Q_OBJECT +public: + PCPImage(); + + void setData(QByteArray data); + +private: + QImage image; +}; + +#endif/*__PRACRO_PCPIMAGE_H__*/ diff --git a/client/pcpviewer/pcpjournal.cc b/client/pcpviewer/pcpjournal.cc new file mode 100644 index 0000000..ff5afad --- /dev/null +++ b/client/pcpviewer/pcpjournal.cc @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set et sw=2 ts=2: */ +/*************************************************************************** + * pcpjournal.cc + * + * Wed Oct 19 11:52:31 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 "pcpjournal.h" + +#include <QHBoxLayout> + +PCPJournal::PCPJournal() +{ + setLayout(new QHBoxLayout()); + doc = new PCPDoc("utf8"); + layout()->addWidget(doc); +} + +void PCPJournal::setData(QString data) +{ + doc->setText(data); + doc->scrollToBottom(); +} diff --git a/client/pcpviewer/pcpjournal.h b/client/pcpviewer/pcpjournal.h new file mode 100644 index 0000000..0a9cff2 --- /dev/null +++ b/client/pcpviewer/pcpjournal.h @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set et sw=2 ts=2: */ +/*************************************************************************** + * pcpjournal.h + * + * Wed Oct 19 11:52:31 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. + */ +#ifndef __PRACRO_PCPJOURNAL_H__ +#define __PRACRO_PCPJOURNAL_H__ + +#include <QWidget> + +#include "pcpdoc.h" + +class PCPJournal : public QWidget { +Q_OBJECT +public: + PCPJournal(); + +public slots: + void setData(QString); + +private: + PCPDoc *doc; +}; + +#endif/*__PRACRO_PCPJOURNAL_H__*/ diff --git a/client/pcpviewer/pcppatient.cc b/client/pcpviewer/pcppatient.cc new file mode 100644 index 0000000..5ba1845 --- /dev/null +++ b/client/pcpviewer/pcppatient.cc @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set et sw=2 ts=2: */ +/*************************************************************************** + * pcppatient.cc + * + * Thu Oct 20 09:11:08 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 "pcppatient.h" + +#include <QHBoxLayout> + +PCPPatient::PCPPatient() +{ + setLayout(new QHBoxLayout()); + j = new QLineEdit(this); + layout()->addWidget(j); +} + +void PCPPatient::setData(Patient p) +{ + QString s; + s += p.cpr+ ": " + p.fornavne + " " + p.efternavn; + j->setText(s); +} + diff --git a/client/pcpviewer/pcppatient.h b/client/pcpviewer/pcppatient.h new file mode 100644 index 0000000..6f2a740 --- /dev/null +++ b/client/pcpviewer/pcppatient.h @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set et sw=2 ts=2: */ +/*************************************************************************** + * pcppatient.h + * + * Thu Oct 20 09:11:08 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. + */ +#ifndef __PRACRO_PCPPATIENT_H__ +#define __PRACRO_PCPPATIENT_H__ + +#include <QWidget> +#include <QLineEdit> + +#include "praxisd.h" + +class PCPPatient : public QWidget { +Q_OBJECT +public: + PCPPatient(); + +public slots: + void setData(Patient p); + +private: + QLineEdit *j; +}; + +#endif/*__PRACRO_PCPPATIENT_H__*/ 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 <stdio.h> +#include <QVBoxLayout> -PCPViewer::PCPViewer(QString patientid) : praxisd("localhost", 10000) +#include <QTextCodec> + +#include "pcppatient.h" +#include "pcpjournal.h" +#include "pcpdocuments.h" +#include "pcpdoc.h" +#include "pcpimage.h" + +#include <QSplitter> +#include <QSettings> + +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(); } diff --git a/client/pcpviewer/pcpviewer.h b/client/pcpviewer/pcpviewer.h index 35459a1..81a97bf 100644 --- a/client/pcpviewer/pcpviewer.h +++ b/client/pcpviewer/pcpviewer.h @@ -30,6 +30,9 @@ #include <QWidget> +#include <QSplitter> +#include <QCloseEvent> + #include "praxisd.h" class PCPViewer : public QWidget { @@ -37,13 +40,20 @@ Q_OBJECT public: PCPViewer(QString patientid); +protected: + void closeEvent(QCloseEvent *event); + public slots: void networkError(QString text); - void gotDokMenu(DokMenuVector d); + void open(QString name); + void gotDokMenuFile(QByteArray data, QString mimetype); private: + void init(); + Praxisd praxisd; QString patientid; + QSplitter *split; }; #endif/*__PRACRO_PCPVIEWER_H__*/ diff --git a/client/pracro.cc b/client/pracro.cc index 2c9c141..abc2374 100644 --- a/client/pracro.cc +++ b/client/pracro.cc @@ -46,6 +46,7 @@ #define CONFIG_DEFAULT "pracro.ini" QString cpr; +QString patientname; QString user = USER_DEFAULT; QString config = CONFIG_DEFAULT; QString host; @@ -65,6 +66,7 @@ static void print_usage() " Server.\n"); printf(" -C --course COURSE Lists templates in COURSE.\n"); printf(" -P, --patient PATIENTID Defines the patientid for use with the macro.\n"); + printf(" -n, --name PATIENTNAME Defines the patient name for display in the window header.\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"); @@ -118,6 +120,10 @@ int main(int argc, char *argv[]) *arg == "-V") { show_viewer = true; } + else if(*arg == "--name" || + *arg == "-n") { + patientname = getParam(args, arg); + } else if(*arg == "--user" || *arg == "-U" || *arg == "-u") { @@ -182,15 +188,22 @@ int main(int argc, char *argv[]) } */ + MainWindow mainwindow(cpr, course, templ, host, port, user); + mainwindow.show(); + + PCPViewer *pcpviewer = NULL; if(show_viewer) { - PCPViewer pcpviewer(cpr); - pcpviewer.show(); - return app.exec(); - } else { - MainWindow mainwindow(cpr, course, templ, host, port, user); - mainwindow.show(); - return app.exec(); + pcpviewer = new PCPViewer(cpr); + pcpviewer->show(); + QObject::connect(&mainwindow, SIGNAL(isClosing()), + pcpviewer, SLOT(close())); } + + int ret = app.exec(); + + if(pcpviewer) delete pcpviewer; + + return ret; } #endif/*TESTING*/ diff --git a/client/praxisd.cc b/client/praxisd.cc index 5a0d88e..a77e287 100644 --- a/client/praxisd.cc +++ b/client/praxisd.cc @@ -219,7 +219,7 @@ void Praxisd::replyFinished(QNetworkReply *reply) break; case dokmenufile: - emit gotDokMenuFile(reply->readAll()); + emit gotDokMenuFile(reply->readAll(), reply->rawHeader("Content-Type")); break; } } else { diff --git a/client/praxisd.h b/client/praxisd.h index 0989274..507e63e 100644 --- a/client/praxisd.h +++ b/client/praxisd.h @@ -135,7 +135,7 @@ signals: void gotCaveList(CaveVector cave); void gotPatient(Patient patient); void gotDokMenu(DokMenuVector dokmenu); - void gotDokMenuFile(QString data); + void gotDokMenuFile(QByteArray data, QString mimetype); public slots: void replyFinished(QNetworkReply*); |