1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/* -*- 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 <QVBoxLayout>
#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("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();
}
|