1 /***************************************************************************
2 timeunitbox.cpp - description
4 begin : Sat Apr 27 2002
5 copyright : (C) 2002 by Jason Harris
6 email : kstars@30doradus.org
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
20 #include "timeunitbox.h"
21 #include "timeunitbox.moc"
22 #include <qpushbutton.h>
25 TimeUnitBox::TimeUnitBox(QWidget
*parent
, const char *name
)
26 : QVBox( parent
, name
) {
28 UpButton
= new QPushButton( "+", this );
29 UpButton
->setMaximumWidth( 22 );
30 UpButton
->setMaximumHeight( 10 );
31 DownButton
= new QPushButton( "-", this );
32 DownButton
->setMaximumWidth( 22 );
33 DownButton
->setMaximumHeight( 10 );
35 setMinValue( 1-NUNITS
);
36 setMaxValue( NUNITS
-1 );
37 setValue( 1 ); // Start out with seconds units
48 connect( UpButton
, SIGNAL( clicked() ), this, SLOT( increase() ) );
49 connect( DownButton
, SIGNAL( clicked() ), this, SLOT( decrease() ) );
52 TimeUnitBox::~TimeUnitBox(){
55 void TimeUnitBox::increase() {
56 if ( value() < maxValue() ) {
57 setValue( value()+1 );
58 emit
valueChanged( value() );
62 void TimeUnitBox::decrease() {
63 if ( value() > minValue() ) {
64 setValue( value()-1 );
65 emit
valueChanged( value() );
69 int TimeUnitBox::unitValue() {
71 if ( value() >= 0 ) uval
= UnitStep
[ value() ];
72 else uval
= -1*UnitStep
[ abs( value() ) ];
76 int TimeUnitBox::getUnitValue( int val
) {
77 if ( val
>= 0 ) return UnitStep
[ val
];
78 else return -1*UnitStep
[ abs( val
) ];