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/client.pro | 10 ++++ client/pcpviewer/pcpdoc.cc | 73 ++++++++++++++++++++++++++++++ client/pcpviewer/pcpdoc.h | 45 ++++++++++++++++++ client/pcpviewer/pcpdocuments.cc | 72 +++++++++++++++++++++++++++++ client/pcpviewer/pcpdocuments.h | 54 ++++++++++++++++++++++ client/pcpviewer/pcpimage.cc | 41 +++++++++++++++++ client/pcpviewer/pcpimage.h | 45 ++++++++++++++++++ client/pcpviewer/pcpjournal.cc | 42 +++++++++++++++++ client/pcpviewer/pcpjournal.h | 47 +++++++++++++++++++ client/pcpviewer/pcppatient.cc | 45 ++++++++++++++++++ client/pcpviewer/pcppatient.h | 48 ++++++++++++++++++++ client/pcpviewer/pcpviewer.cc | 98 ++++++++++++++++++++++++++++++++-------- client/pcpviewer/pcpviewer.h | 12 ++++- client/praxisd.cc | 2 +- client/praxisd.h | 2 +- 15 files changed, 615 insertions(+), 21 deletions(-) create mode 100644 client/pcpviewer/pcpdoc.cc create mode 100644 client/pcpviewer/pcpdoc.h create mode 100644 client/pcpviewer/pcpdocuments.cc create mode 100644 client/pcpviewer/pcpdocuments.h create mode 100644 client/pcpviewer/pcpimage.cc create mode 100644 client/pcpviewer/pcpimage.h create mode 100644 client/pcpviewer/pcpjournal.cc create mode 100644 client/pcpviewer/pcpjournal.h create mode 100644 client/pcpviewer/pcppatient.cc create mode 100644 client/pcpviewer/pcppatient.h (limited to 'client') 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/pcpviewer/pcpdoc.cc b/client/pcpviewer/pcpdoc.cc new file mode 100644 index 0000000..0d2aa41 --- /dev/null +++ b/client/pcpviewer/pcpdoc.cc @@ -0,0 +1,73 @@ +/* -*- 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 +#include + +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); +} + +#ifdef TEST_PCPDOC +//Additional dependency files +//deps: +//Required cflags (autoconf vars may be used) +//cflags: +//Required link options (autoconf vars may be used) +//libs: +#include "test.h" + +TEST_BEGIN; + +// TODO: Put some testcode here (see test.h for usable macros). +TEST_TRUE(false, "No tests yet!"); + +TEST_END; + +#endif/*TEST_PCPDOC*/ diff --git a/client/pcpviewer/pcpdoc.h b/client/pcpviewer/pcpdoc.h new file mode 100644 index 0000000..ad48a26 --- /dev/null +++ b/client/pcpviewer/pcpdoc.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: */ +/*************************************************************************** + * 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 +#include + +class PCPDoc : public QTextEdit { +Q_OBJECT +public: + PCPDoc(QString codepage); + + void setText(QString text); + +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 + +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 +#include + +#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 +#include + +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..0ebaf4b --- /dev/null +++ b/client/pcpviewer/pcpjournal.cc @@ -0,0 +1,42 @@ +/* -*- 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 + +PCPJournal::PCPJournal() +{ + setLayout(new QHBoxLayout()); + doc = new PCPDoc("utf8"); + layout()->addWidget(doc); +} + +void PCPJournal::setData(QString data) +{ + doc->setText(data); +} 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 + +#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 + +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 +#include + +#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 +#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(); } 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 +#include +#include + #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/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*); -- cgit v1.2.3 From 8910e356af01a11cf769b891c1aa51eed2cf960f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 3 Nov 2011 10:45:35 +0100 Subject: Scroll journal to bottom. --- client/pcpviewer/pcpdoc.cc | 22 +++++----------------- client/pcpviewer/pcpdoc.h | 1 + client/pcpviewer/pcpjournal.cc | 1 + 3 files changed, 7 insertions(+), 17 deletions(-) (limited to 'client') diff --git a/client/pcpviewer/pcpdoc.cc b/client/pcpviewer/pcpdoc.cc index 0d2aa41..33fbdd4 100644 --- a/client/pcpviewer/pcpdoc.cc +++ b/client/pcpviewer/pcpdoc.cc @@ -29,6 +29,7 @@ #include #include +#include PCPDoc::PCPDoc(QString codepage) { @@ -54,20 +55,7 @@ void PCPDoc::setText(QString text) setPlainText(jstrip); } -#ifdef TEST_PCPDOC -//Additional dependency files -//deps: -//Required cflags (autoconf vars may be used) -//cflags: -//Required link options (autoconf vars may be used) -//libs: -#include "test.h" - -TEST_BEGIN; - -// TODO: Put some testcode here (see test.h for usable macros). -TEST_TRUE(false, "No tests yet!"); - -TEST_END; - -#endif/*TEST_PCPDOC*/ +void PCPDoc::scrollToBottom() +{ + verticalScrollBar()->setSliderPosition(verticalScrollBar()->maximum()); +} diff --git a/client/pcpviewer/pcpdoc.h b/client/pcpviewer/pcpdoc.h index ad48a26..25cbe68 100644 --- a/client/pcpviewer/pcpdoc.h +++ b/client/pcpviewer/pcpdoc.h @@ -37,6 +37,7 @@ public: PCPDoc(QString codepage); void setText(QString text); + void scrollToBottom(); private: QString codepage; diff --git a/client/pcpviewer/pcpjournal.cc b/client/pcpviewer/pcpjournal.cc index 0ebaf4b..ff5afad 100644 --- a/client/pcpviewer/pcpjournal.cc +++ b/client/pcpviewer/pcpjournal.cc @@ -39,4 +39,5 @@ PCPJournal::PCPJournal() void PCPJournal::setData(QString data) { doc->setText(data); + doc->scrollToBottom(); } -- cgit v1.2.3 From f8e858a204bdcfc955ebcec20a78d7a41f6076f5 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 3 Nov 2011 11:07:10 +0100 Subject: Show pcpviewer side-by-side with mainwindow and close it upon mainwindow close. --- client/mainwindow.cc | 2 ++ client/mainwindow.h | 3 +++ client/pracro.cc | 21 ++++++++++++++------- 3 files changed, 19 insertions(+), 7 deletions(-) (limited to 'client') diff --git a/client/mainwindow.cc b/client/mainwindow.cc index 1a63434..ece1572 100644 --- a/client/mainwindow.cc +++ b/client/mainwindow.cc @@ -242,6 +242,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/pracro.cc b/client/pracro.cc index 2c9c141..a2f06f3 100644 --- a/client/pracro.cc +++ b/client/pracro.cc @@ -182,15 +182,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*/ -- cgit v1.2.3 From 140d002d641d22d2dc9e9a1e7c234b747c979a16 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 3 Nov 2011 11:28:29 +0100 Subject: Added -n/--name parameter for displaying patient name in title bar of the mainwindow. --- client/mainwindow.cc | 5 ++++- client/pracro.cc | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/mainwindow.cc b/client/mainwindow.cc index ece1572..27d8486 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(); diff --git a/client/pracro.cc b/client/pracro.cc index a2f06f3..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") { -- cgit v1.2.3