kviewshell
pageRangeWidget.cpp
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #include <kdebug.h>
00022 
00023 #include "pageRangeWidget.h"
00024 
00025 
00026 PageRangeWidget::PageRangeWidget( Q_UINT16 _from, Q_UINT16 _to, Q_UINT16 _current, QWidget *parent, const char *name) : PageRangeWidget_base(parent, name)
00027 {
00028   
00029   if ((from == 0) || (to == 0))
00030     return;
00031   if (_from > _to) {
00032     kdError() << "PageRangeWidget::PageRangeWidget(..): from > to" << endl;
00033     _to = _from;
00034   }
00035   if (_current < _from) {
00036     kdError() << "PageRangeWidget::PageRangeWidget(..): _current < _from" << endl;
00037     _current = _from;
00038   }
00039   if (_current > _to) {
00040     kdError() << "PageRangeWidget::PageRangeWidget(..): _current > _to" << endl;
00041     _current = _to;
00042   }
00043 
00044   connect(from, SIGNAL(valueChanged(int)), this, SLOT(fromValueChanged(int)));
00045   connect(to, SIGNAL(valueChanged(int)), this, SLOT(toValueChanged(int)));
00046 
00047   from->setRange(_from, _to);
00048   from->setValue(_current);
00049   to->setRange(_from, _to);
00050   to->setValue(_current);
00051 }
00052 
00053 
00054 void PageRangeWidget::toValueChanged(int val)
00055 {
00056   if (val < from->value())
00057     from->setValue(val);
00058 }
00059 
00060 
00061 void PageRangeWidget::fromValueChanged(int val)
00062 {
00063   if (val > to->value())
00064     to->setValue(val);
00065 }
00066 
00067 #include "pageRangeWidget.moc"
00068