00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <QtGui/QMessageBox>
00026 #include <QtGui/QDockWidget>
00027 #include <QtGui/QActionGroup>
00028 #include <QtGui/QFileDialog>
00029 #include <QtGui/QPrinter>
00030 #include <QtGui/QPrintDialog>
00031 #include <QtGui/QPrintPreviewDialog>
00032
00033 #include "mainwindow.h"
00034 #include "ui_mainwindow.h"
00035 #include "centralwidget.h"
00036 #include "navigationwidget.h"
00037 #include "mfertablewidget.h"
00038 #include "infodialog.h"
00039 #include "helpbrowser.h"
00040
00041 MainWindow::MainWindow(QWidget *parent)
00042 : QMainWindow(parent), ui(new Ui::MainWindowClass)
00043 {
00044 ui->setupUi(this);
00045
00046 navigationWidget = new NavigationWidget(this);
00047 navigationDockWidget = new QDockWidget("Navigation");
00048 navigationDockWidget->setWidget(navigationWidget);
00049 navigationDockWidget->setAllowedAreas(
00050 Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
00051 navigationDockWidget->setFeatures(QDockWidget::DockWidgetMovable);
00052
00053 addDockWidget(Qt::BottomDockWidgetArea, navigationDockWidget);
00054
00055 ourCentralWidget = new CentralWidget(this);
00056 mferTableWidget = new MferTableWidget;
00057
00058 setCentralWidget(ourCentralWidget);
00059 modeGroup = new QActionGroup(this);
00060 channelGroup = new QActionGroup(this);
00061 fileInfo = new InfoDialog(this);;
00062
00063 establishConnections();
00064 hideGuiElements();
00065 }
00066
00067 MainWindow::~MainWindow()
00068 {
00069 delete ui;
00070 }
00071
00072 void MainWindow::establishConnections()
00073 {
00074 connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
00075
00076 modeGroup->addAction(ui->actionSingel_Channel_Mode);
00077 modeGroup->addAction(ui->actionMulti_Channel_Mode);
00078 ui->actionSingel_Channel_Mode->setChecked(true);
00079
00080 channelGroup->addAction(ui->actionChannel_One);
00081 channelGroup->addAction(ui->actionChannel_Two);
00082 channelGroup->addAction(ui->actionChannel_Three);
00083 channelGroup->addAction(ui->actionChannel_Four);
00084 channelGroup->addAction(ui->actionChannel_Five);
00085 channelGroup->addAction(ui->actionChannel_Six);
00086 channelGroup->addAction(ui->actionChannel_Seven);
00087 channelGroup->addAction(ui->actionChannel_Eight);
00088 channelGroup->addAction(ui->actionChannel_Nine);
00089 channelGroup->addAction(ui->actionChannel_Ten);
00090 channelGroup->addAction(ui->actionChannel_Eleven);
00091 channelGroup->addAction(ui->actionChannel_Twelve);
00092 ui->actionChannel_One->setChecked(true);
00093
00094 QList<QAction *> actionList = channelGroup->actions();
00095
00096 foreach(QAction *action, actionList)
00097 connect(action, SIGNAL(triggered()), this, SLOT(channelChanged()));
00098
00099 connect(ui->actionSingel_Channel_Mode, SIGNAL(triggered()),
00100 this, SLOT(modeChanged()));
00101 connect(ui->actionMulti_Channel_Mode, SIGNAL(triggered()),
00102 this, SLOT(modeChanged()));
00103 connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()));
00104 connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(closeFile()));
00105 connect(ui->actionPrint, SIGNAL(triggered()), this, SLOT(printSlot()));
00106 connect(ui->actionPrint_Preview, SIGNAL(triggered()),
00107 this, SLOT(previewSlot()));
00108 connect(ui->actionExport_to_PDF, SIGNAL(triggered()),
00109 this, SLOT(exportSlot()));
00110
00111 connect(navigationWidget, SIGNAL(orderNewScreen(int)),
00112 ourCentralWidget, SLOT(updateScreen(int)));
00113 connect(ourCentralWidget, SIGNAL(setupSliders(int, int, QDateTime *)),
00114 navigationWidget, SLOT(setupSliders(int, int, QDateTime *)));
00115
00116 connect(ui->actionPatient_Information, SIGNAL(triggered()),
00117 this, SLOT(mferReaderSlot()));
00118
00119 connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
00120 connect(ui->actionTutorial, SIGNAL(triggered()), this, SLOT(helpSlot()));
00121
00122 connect(ui->actionZoom_in, SIGNAL(triggered()), this, SLOT(zoomInSlot()));
00123 connect(ui->actionZoom_out, SIGNAL(triggered()), this, SLOT(zoomOutSlot()));
00124 }
00125
00126 void MainWindow::modeChanged()
00127 {
00128 if (ui->actionSingel_Channel_Mode->isChecked())
00129 {
00130 channelGroup->setExclusive(true);
00131 channelGroup->setDisabled(true);
00132 ui->actionChannel_One->setChecked(true);
00133 channelGroup->setDisabled(false);
00134 ourCentralWidget->setActiveMode(CentralWidget::SINGLECHANNEL_MODE);
00135 }
00136 else
00137 {
00138
00139
00140
00141
00142
00143 ui->actionSingel_Channel_Mode->setChecked(true);
00144 notYetImplemented(tr("The multichannel mode."));
00145 modeChanged();
00146 }
00147 }
00148
00149 void MainWindow::open()
00150 {
00151 QString fileName = QFileDialog::getOpenFileName(this,
00152 tr("Open File"), ".",
00153 tr("MFER files (*.mwf)\n"
00154 "Text files (*.txt)"));
00155 if (!fileName.isEmpty())
00156 {
00157 closeFile();
00158 ourCentralWidget->setActiveMode(CentralWidget::SINGLECHANNEL_MODE);
00159 if (!ourCentralWidget->readFile(fileName))
00160 {
00161 statusBar()->showMessage(tr("Loading canceled"), 2000);
00162 ourCentralWidget->setActiveMode(CentralWidget::NODATA_MODE);
00163 hideGuiElements();
00164 return;
00165 }
00166 setWindowTitle(tr("Cardio Curves - %1").arg(fileName));
00167 statusBar()->showMessage(tr("File loaded"), 2000);
00168 showGuiElements();
00169 }
00170 }
00171
00172 void MainWindow::closeFile()
00173 {
00174 setWindowTitle("Cardio Curves");
00175 ourCentralWidget->setActiveMode(CentralWidget::NODATA_MODE);
00176 hideGuiElements();
00177 }
00178
00179 void MainWindow::printSlot()
00180 {
00181
00182 QPrinter aPrinter;
00183 QPrintDialog printDialog(&aPrinter, this);
00184 if (printDialog.exec())
00185 {
00186
00187 ourCentralWidget->printSlot(&aPrinter);
00188 }
00189 }
00190
00191 void MainWindow::previewSlot()
00192 {
00193
00194 QPrintPreviewDialog aPreview(this);
00195 aPreview.printer()->setOrientation(QPrinter::Landscape);
00196 connect(&aPreview, SIGNAL(paintRequested(QPrinter *)),
00197 ourCentralWidget, SLOT(printSlot(QPrinter *)));
00198 aPreview.exec();
00199 }
00200
00201 void MainWindow::exportSlot()
00202 {
00203
00204 QPrinter aPrinter;
00205 aPrinter.setOutputFormat(QPrinter::PdfFormat);
00206 aPrinter.setOrientation(QPrinter::Landscape);
00207
00208 QString fileName=QFileDialog::getSaveFileName(this,
00209 "Export file name", "Savename.pdf", "PDF Documents (*.pdf)");
00210
00211 aPrinter.setOutputFileName(fileName);
00212 ourCentralWidget->printSlot(&aPrinter);
00213 }
00214
00215 void MainWindow::mferReaderSlot()
00216 {
00217 if (!fileInfo->isReady())
00218 {
00219 fileInfo->fillDialog(*(ourCentralWidget->getReader()));
00220
00221 }
00222 fileInfo->showDialog();
00223 }
00224
00225 void MainWindow::about()
00226 {
00227 QMessageBox::about(this, tr("About CardioCurves"),
00228 tr("<h2>CardioCurves 0.1</h2>"
00229 "<p>Developed at University in Agder, 2009."
00230 "<p>CardioCurves is an application that "
00231 "displays medical waveforms encoded "
00232 "in accordance with the MFER ISO standard "
00233 "(Medical waveform Format Encoding Rules)."));
00234 }
00235
00236 void MainWindow::notYetImplemented(QString arg)
00237 {
00238 QMessageBox::information(this, tr("Under Construction"),
00239 tr("<p>This feature has not yet been implemented: ") + arg);
00240 }
00241
00242 void MainWindow::zoomInSlot()
00243 {
00244 notYetImplemented(tr("The zoom in function."));
00245 }
00246
00247 void MainWindow::zoomOutSlot()
00248 {
00249 notYetImplemented(tr("The zoom out function."));
00250 }
00251
00252 void MainWindow::channelChanged()
00253 {
00254 ui->actionChannel_One->setChecked(true);
00255 notYetImplemented(tr("Channel selection."));
00256 }
00257
00258 void MainWindow::helpSlot()
00259 {
00260 HelpBrowser::showPage("help.html");
00261 }
00262
00263 void MainWindow::hideGuiElements()
00264 {
00265 navigationWidget->horizontalScrollBar->setEnabled(false);
00266 navigationWidget->horizontalSlider->setEnabled(false);
00267 navigationWidget->fastBackBtn->setEnabled(false);
00268 navigationWidget->fastForwardBtn->setEnabled(false);
00269 navigationWidget->slowBackBtn->setEnabled(false);
00270 navigationWidget->slowForwardBtn->setEnabled(false);
00271 navigationWidget->skipEndBtn->setEnabled(false);
00272 navigationWidget->skipStartBtn->setEnabled(false);
00273 ui->actionPrint->setEnabled(false);
00274 ui->actionPrint_Preview->setEnabled(false);
00275 ui->actionExport_to_PDF->setEnabled(false);
00276 ui->menuView->setEnabled(false);
00277 ui->menuOptions->setEnabled(false);
00278 ui->actionClose->setEnabled(false);
00279 ui->optionsToolBar->hide();
00280 ui->ViewTollBar->hide();
00281 }
00282
00283 void MainWindow::showGuiElements()
00284 {
00285 navigationWidget->horizontalScrollBar->setEnabled(true);
00286 navigationWidget->horizontalSlider->setEnabled(true);
00287 navigationWidget->fastBackBtn->setEnabled(true);
00288 navigationWidget->fastForwardBtn->setEnabled(true);
00289 navigationWidget->slowBackBtn->setEnabled(true);
00290 navigationWidget->slowForwardBtn->setEnabled(true);
00291 navigationWidget->skipEndBtn->setEnabled(true);
00292 navigationWidget->skipStartBtn->setEnabled(true);
00293 ui->actionPrint->setEnabled(true);
00294 ui->actionPrint_Preview->setEnabled(true);
00295 ui->actionExport_to_PDF->setEnabled(true);
00296 ui->menuView->setEnabled(true);
00297 ui->menuOptions->setEnabled(true);
00298 ui->actionClose->setEnabled(true);
00299 ui->optionsToolBar->show();
00300 ui->ViewTollBar->show();
00301 }