kstars
timestepbox.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 #include <stdlib.h>
00019 #include <qtooltip.h>
00020 #include <qwhatsthis.h>
00021 #include <kdebug.h>
00022 #include <klocale.h>
00023
00024 #include "timestepbox.h"
00025
00026 TimeStepBox::TimeStepBox( QWidget *parent, const char* name, bool daysonly )
00027 : QFrame( parent, name ) {
00028
00029 timeBox = new TimeSpinBox( this, "timebox", daysonly );
00030 unitBox = new TimeUnitBox( this, "unitbox", daysonly );
00031
00032 QToolTip::add( timeBox, i18n( "Adjust time step" ) );
00033 QToolTip::add( unitBox, i18n( "Adjust time step units" ) );
00034
00035 QWhatsThis::add( this, i18n( "Set the timescale for the simulation clock. A setting of \"1 sec\" means the clock advances in real-time, keeping up perfectly with your CPU clock. Higher values make the simulation clock run faster, lower values make it run slower. Negative values make it run backwards."
00036 "\n\n"
00037 "There are two pairs of up/down buttons. The left pair will cycle through all available timesteps in sequence. Since there are a large number of timesteps, the right pair is provided to skip to the next higher/lower unit of time. For example, if the timescale is currently \"1 min\", the right up button will make it \"1 hour\", and the right down button will make it \"1 sec\"" ) );
00038 hlay = new QHBoxLayout( this, 2, 0 );
00039 hlay->addWidget( timeBox );
00040 hlay->addWidget( unitBox );
00041 hlay->activate();
00042
00043 timeBox->setValue( 4 );
00044
00045 connect( unitBox, SIGNAL( valueChanged( int ) ), this, SLOT( changeUnits() ) );
00046 connect( timeBox, SIGNAL( valueChanged( int ) ), this, SLOT( syncUnits( int ) ) );
00047 connect( timeBox, SIGNAL( scaleChanged( float ) ), this, SIGNAL( scaleChanged( float ) ) );
00048
00049 }
00050
00051 void TimeStepBox::changeUnits( void ) {
00052 timeBox->setValue( unitBox->unitValue() );
00053 }
00054
00055 void TimeStepBox::syncUnits( int tstep ) {
00056 int i;
00057 for ( i=unitbox()->maxValue(); i>=unitbox()->minValue(); --i )
00058 if ( abs(tstep) >= unitBox->getUnitValue( i ) ) break;
00059
00060
00061 disconnect( unitBox, SIGNAL( valueChanged( int ) ), this, SLOT( changeUnits() ) );
00062 unitBox->setValue( tstep < 0 ? -i : i );
00063 connect( unitBox, SIGNAL( valueChanged( int ) ), this, SLOT( changeUnits() ) );
00064 }
00065
00066 void TimeStepBox::setDaysOnly( bool daysonly ) {
00067 tsbox()->setDaysOnly( daysonly );
00068 unitbox()->setDaysOnly( daysonly );
00069 }
00070
00071 #include "timestepbox.moc"