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>
00026
00027 #include "navigationwidget.h"
00028
00029 NavigationWidget::NavigationWidget(QWidget *parent)
00030 : QWidget(parent)
00031 {
00032 setupUi(this);
00033
00034 connect(horizontalSlider, SIGNAL(valueChanged(int)),
00035 this, SLOT(sliderChanged(int)));
00036 connect(horizontalScrollBar, SIGNAL(valueChanged(int)),
00037 this, SLOT(scrollbarChanged(int)));
00038 connect(skipStartBtn, SIGNAL(released()), this, SLOT(skipStartSlot()));
00039 connect(skipEndBtn, SIGNAL(released()), this, SLOT(skipEndSlot()));
00040 connect(fastBackBtn, SIGNAL(released()), this, SLOT(fastBackwardSlot()));
00041 connect(fastForwardBtn, SIGNAL(released()), this, SLOT(fastForwardSlot()));
00042 connect(slowBackBtn, SIGNAL(released()), this, SLOT(slowBackwardSlot()));
00043 connect(slowForwardBtn, SIGNAL(released()), this, SLOT(slowForwardSlot()));
00044 }
00045
00046 void NavigationWidget::setupSliders(int screens,
00047 int patientId,
00048 QDateTime *startingPoint)
00049 {
00050 numberofScreens = screens;
00051 currentScreen = 0;
00052 lastScrollbarpositions = numberofScreens % 10;
00053 if (lastScrollbarpositions != 0)
00054 totalSliderpositions = (numberofScreens / 10) + 1;
00055 else
00056 totalSliderpositions = (numberofScreens / 10);
00057
00058 totalScrollbarpositions = 10;
00059
00060 sliderPosition = 0;
00061 scrollbarPosition = 0;
00062
00063 horizontalSlider->setMaximum(totalSliderpositions);
00064 if (totalSliderpositions == 1)
00065 horizontalScrollBar->setMaximum(lastScrollbarpositions);
00066 else
00067 horizontalScrollBar->setMaximum(totalScrollbarpositions);
00068 }
00069
00070 void NavigationWidget::sliderChanged(int newValue)
00071 {
00072
00073 if ((horizontalSlider->sliderPosition() - 1) != sliderPosition)
00074 {
00075 sliderPosition = horizontalSlider->sliderPosition() - 1;
00076 scrollbarPosition = 0;
00077 horizontalScrollBar->setValue(horizontalScrollBar->minimum());
00078
00079 if ((horizontalSlider->sliderPosition() == horizontalSlider->maximum())
00080 && lastScrollbarpositions != 0)
00081 horizontalScrollBar->setMaximum(lastScrollbarpositions);
00082 else
00083 horizontalScrollBar->setMaximum(totalScrollbarpositions);
00084
00085 currentScreen = sliderPosition * 10 + scrollbarPosition;
00086 emit orderNewScreen(currentScreen);
00087 }
00088 }
00089
00090 void NavigationWidget::scrollbarChanged(int newValue)
00091 {
00092
00093 if ((horizontalScrollBar->sliderPosition() - 1) != scrollbarPosition)
00094 {
00095 scrollbarPosition = horizontalScrollBar->sliderPosition() - 1;
00096
00097 currentScreen = sliderPosition * 10 + scrollbarPosition;
00098 emit orderNewScreen(currentScreen);
00099 }
00100 }
00101
00102 void NavigationWidget::skipStartSlot()
00103 {
00104
00105 if (sliderPosition == 0)
00106 return;
00107 else
00108 {
00109 horizontalSlider->setValue(horizontalSlider->minimum());
00110 horizontalScrollBar->setValue(horizontalScrollBar->minimum());
00111 horizontalScrollBar->setMaximum(totalScrollbarpositions);
00112 sliderPosition = 0;
00113 scrollbarPosition = 0;
00114 currentScreen = 0;
00115 emit orderNewScreen(currentScreen);
00116 }
00117 }
00118
00119 void NavigationWidget::skipEndSlot()
00120 {
00121
00122 if (sliderPosition == (horizontalSlider->maximum() - 1))
00123 return;
00124 else
00125 {
00126 horizontalSlider->setValue(horizontalSlider->maximum());
00127 horizontalScrollBar->setValue(horizontalScrollBar->minimum());
00128 if (lastScrollbarpositions != 0)
00129 horizontalScrollBar->setMaximum(lastScrollbarpositions);
00130 else
00131 horizontalScrollBar->setMaximum(totalScrollbarpositions);
00132
00133 sliderPosition = horizontalSlider->sliderPosition() - 1;
00134 scrollbarPosition = 0;
00135
00136 currentScreen = sliderPosition * 10 + scrollbarPosition;
00137 emit orderNewScreen(currentScreen);
00138 }
00139 }
00140
00141 void NavigationWidget::slowBackwardSlot()
00142 {
00143
00144 if (horizontalScrollBar->sliderPosition() == horizontalScrollBar->minimum())
00145 return;
00146 else
00147 {
00148 horizontalScrollBar->setValue(horizontalScrollBar->value() - 1);
00149 scrollbarPosition = horizontalScrollBar->sliderPosition() - 1;
00150 currentScreen = sliderPosition * 10 + scrollbarPosition;
00151 emit orderNewScreen(currentScreen);
00152 }
00153 }
00154
00155 void NavigationWidget::slowForwardSlot()
00156 {
00157
00158 if (horizontalScrollBar->sliderPosition() == horizontalScrollBar->maximum())
00159 return;
00160 else
00161 {
00162 horizontalScrollBar->setValue(horizontalScrollBar->value() + 1);
00163 scrollbarPosition = horizontalScrollBar->sliderPosition() - 1;
00164 currentScreen = sliderPosition * 10 + scrollbarPosition;
00165 emit orderNewScreen(currentScreen);
00166 }
00167 }
00168
00169 void NavigationWidget::fastBackwardSlot()
00170 {
00171
00172 if (horizontalSlider->sliderPosition() == horizontalSlider->minimum())
00173 return;
00174 else
00175 {
00176 horizontalSlider->setValue(horizontalSlider->value() - 1);
00177 sliderPosition = horizontalSlider->sliderPosition() - 1;
00178 scrollbarPosition = 0;
00179 horizontalScrollBar->setValue(horizontalScrollBar->minimum());
00180
00181 if ((horizontalSlider->sliderPosition() == horizontalSlider->maximum())
00182 && lastScrollbarpositions != 0)
00183 horizontalScrollBar->setMaximum(lastScrollbarpositions);
00184 else
00185 horizontalScrollBar->setMaximum(totalScrollbarpositions);
00186
00187 currentScreen = sliderPosition * 10 + scrollbarPosition;
00188 emit orderNewScreen(currentScreen);
00189 }
00190 }
00191
00192 void NavigationWidget::fastForwardSlot()
00193 {
00194
00195 if (horizontalSlider->sliderPosition() == horizontalSlider->maximum())
00196 return;
00197 else
00198 {
00199 horizontalSlider->setValue(horizontalSlider->value() + 1);
00200 sliderPosition = horizontalSlider->sliderPosition() - 1;
00201 scrollbarPosition = 0;
00202 horizontalScrollBar->setValue(horizontalScrollBar->minimum());
00203
00204 if ((horizontalSlider->sliderPosition() == horizontalSlider->maximum())
00205 && lastScrollbarpositions != 0)
00206 horizontalScrollBar->setMaximum(lastScrollbarpositions);
00207 else
00208 horizontalScrollBar->setMaximum(totalScrollbarpositions);
00209
00210 currentScreen = sliderPosition * 10 + scrollbarPosition;
00211 emit orderNewScreen(currentScreen);
00212 }
00213 }