From d733a517a3a3abe21697090d1fbdedabdf483578 Mon Sep 17 00:00:00 2001 From: senator Date: Wed, 13 Oct 2010 14:22:03 +0000 Subject: added a messagebox that appears when leaving trying to proceed without entering a patient id --- client/launcherwindow.cc | 38 ++++++++++++++++++++++++-------------- client/launcherwindow.h | 1 + 2 files changed, 25 insertions(+), 14 deletions(-) (limited to 'client') diff --git a/client/launcherwindow.cc b/client/launcherwindow.cc index 68f8e50..35ee532 100644 --- a/client/launcherwindow.cc +++ b/client/launcherwindow.cc @@ -31,23 +31,27 @@ #include #include #include +#include #include "launcherwindow.h" -LauncherWindow::LauncherWindow(QString arg, QString cpr, QString templ, QWidget *parent) +LauncherWindow::LauncherWindow(QString arg, QString cpr, QString templ, + QWidget *parent) : QDialog(parent) { setWindowTitle(tr("Pracro Launcher")); resize(250,80); - QSettings templateConfig(QFileInfo(arg). -absolutePath() + "/templates.ini", QSettings::IniFormat); + QSettings templateConfig(QFileInfo(arg).absolutePath() + + "/templates.ini", QSettings::IniFormat); QLabel *cprLabel = new QLabel(tr("Patient ID:")); cprLineEdit = new QLineEdit(); - cprLineEdit->setValidator(new QRegExpValidator(QRegExp("^[0-9]{10,10}$"), this)); + cprLineEdit->setValidator(new QRegExpValidator(QRegExp("^[0-9]{10,10}$"), + this)); QLabel *templatesLabel = new QLabel(tr("Template:")); templates = new QComboBox(); - connect(templates, SIGNAL(currentIndexChanged(int)), this, SLOT(focusCpr(int))); + connect(templates, SIGNAL(currentIndexChanged(int)), this, + SLOT(focusCpr(int))); QStringList groups = templateConfig.childGroups(); QStringList::iterator i = groups.begin(); while(i != groups.end()) { @@ -60,16 +64,9 @@ absolutePath() + "/templates.ini", QSettings::IniFormat); } i++; } - /* - templates->addItem("Refraktiv kirurgi: Forundersøgelse", - "ref_forunders"); - templates->addItem("Refraktiv kirurgi: Førstedagskontrol", - "ref_foerstedagskontrol"); - templates->addItem("Refraktiv kirurgi: Efterkontrol", - "ref_efterkontrol"); - */ + QPushButton *ok = new QPushButton(tr("Accept")); - connect(ok, SIGNAL(clicked()), this, SLOT(accept())); + connect(ok, SIGNAL(clicked()), this, SLOT(checkForCpr())); QPushButton *cancel = new QPushButton(tr("Cancel")); connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); @@ -114,3 +111,16 @@ void LauncherWindow::focusCpr(int) { cprLineEdit->setFocus(); } + +void LauncherWindow::checkForCpr() +{ + if(cprLineEdit->text().length() == 10) { + emit accept(); + } else { + QMessageBox::critical(this, tr("Incorrect Patient ID"), + tr("You need to enter a 10 character\n" + "Patient ID in order to continue."), + QMessageBox::Ok); + cprLineEdit->setFocus(); + } +} diff --git a/client/launcherwindow.h b/client/launcherwindow.h index 234a016..3f24808 100644 --- a/client/launcherwindow.h +++ b/client/launcherwindow.h @@ -44,6 +44,7 @@ public: private slots: void focusCpr(int); + void checkForCpr(); private: QLineEdit *cprLineEdit; -- cgit v1.2.3