• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kstars

timeunitbox.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           timeunitbox.cpp  -  description
00003                              -------------------
00004     begin                : Sat Apr 27 2002
00005     copyright            : (C) 2002 by Jason Harris
00006     email                : kstars@30doradus.org
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include <stdlib.h>
00019 #include <kdebug.h>
00020 #include "timeunitbox.h"
00021 #include "timeunitbox.moc"
00022 #include <qpushbutton.h>
00023 
00024 
00025 TimeUnitBox::TimeUnitBox(QWidget *parent, const char *name, bool daysonly )
00026     : QVBox( parent, name ) {
00027 
00028     UpButton = new QPushButton( "+", this );
00029     UpButton->setMaximumWidth( 22 );
00030     UpButton->setMaximumHeight( 10 );
00031     DownButton = new QPushButton( "-", this );
00032     DownButton->setMaximumWidth( 22 );
00033     DownButton->setMaximumHeight( 10 );
00034 
00035     setDaysOnly( daysonly );
00036 
00037     connect( UpButton, SIGNAL( clicked() ), this, SLOT( increase() ) );
00038     connect( DownButton, SIGNAL( clicked() ), this, SLOT( decrease() ) );
00039 }
00040 
00041 TimeUnitBox::~TimeUnitBox(){
00042 }
00043 
00044 void TimeUnitBox::setDaysOnly( bool daysonly ) {
00045     if ( daysonly ) {
00046         setMinValue( 1-DAYUNITS );
00047         setMaxValue( DAYUNITS-1 );
00048         setValue( 1 ); // Start out with days units
00049     
00050         UnitStep[0] = 0;
00051         UnitStep[1] = 1;
00052         UnitStep[2] = 5;
00053         UnitStep[3] = 8;
00054         UnitStep[4] = 14;
00055     } else {
00056         setMinValue( 1-ALLUNITS );
00057         setMaxValue( ALLUNITS-1 );
00058         setValue( 1 ); // Start out with seconds units
00059     
00060         UnitStep[0] = 0;
00061         UnitStep[1] = 4;
00062         UnitStep[2] = 10;
00063         UnitStep[3] = 16;
00064         UnitStep[4] = 21;
00065         UnitStep[5] = 25;
00066         UnitStep[6] = 28;
00067         UnitStep[7] = 34;
00068     }
00069 }
00070 
00071 void TimeUnitBox::increase() {
00072     if ( value() < maxValue() ) {
00073         setValue( value()+1 );
00074         emit valueChanged( value() );
00075     }
00076 }
00077 
00078 void TimeUnitBox::decrease() {
00079     if ( value() > minValue() ) {
00080         setValue( value()-1 );
00081         emit valueChanged( value() );
00082     }
00083 }
00084 
00085 int TimeUnitBox::unitValue() {
00086     int uval;
00087     if ( value() >= 0 ) uval = UnitStep[ value() ];
00088     else uval = -1*UnitStep[ abs( value() ) ];
00089     return uval;
00090 }
00091 
00092 int TimeUnitBox::getUnitValue( int val ) {
00093     if ( val >= 0 ) return UnitStep[ val ];
00094     else return -1*UnitStep[ abs( val ) ];
00095 }

kstars

Skip menu "kstars"
  • Main Page
  • Modules
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal