From 0b311079ff19798866291034663757103c6ba935 Mon Sep 17 00:00:00 2001 From: zecke Date: Sun, 13 Apr 2003 16:57:28 +0000 Subject: Jumbo API documentation update and some API fixed ColorDialog is now OColorDialog!!! keep the namespace tidy! ColorPopupMenu is now OColorPopupMenu!!! keep the namespace tidy ColorDialog TT couldn't break bc we can so make it const QColor& OTimePicker add some convience methods more I might have forgot --- (limited to 'libopie/otimepicker.cpp') diff --git a/libopie/otimepicker.cpp b/libopie/otimepicker.cpp index 8e8a4e7..115d39b 100644 --- a/libopie/otimepicker.cpp +++ b/libopie/otimepicker.cpp @@ -7,10 +7,18 @@ #include #include -OTimePicker::OTimePicker(QWidget* parent, const char* name, + +/** + * Constructs the widget + * @param parent The parent of the OTimePicker + * @param name The name of the object + * @param fl Window Flags + */ +OTimePicker::OTimePicker(QWidget* parent, const char* name, WFlags fl) : QWidget(parent,name,fl) { + QVBoxLayout *vbox=new QVBoxLayout(this); OClickableLabel *r; @@ -20,8 +28,8 @@ OTimePicker::OTimePicker(QWidget* parent, const char* name, QWidget *row=new QWidget(this); QHBoxLayout *l=new QHBoxLayout(row); vbox->addWidget(row); - - + + for (int i=0; i<24; i++) { r=new OClickableLabel(row); hourLst.append(r); @@ -44,7 +52,7 @@ OTimePicker::OTimePicker(QWidget* parent, const char* name, row=new QWidget(this); l=new QHBoxLayout(row); vbox->addWidget(row); - + for (int i=0; i<60; i+=5) { r=new OClickableLabel(row); minuteLst.append(r); @@ -58,6 +66,14 @@ OTimePicker::OTimePicker(QWidget* parent, const char* name, } } +/** + * This method return the current time + * @return the time + */ +QTime OTimePicker::time()const { + return tm; +} + void OTimePicker::slotHour(bool b) { OClickableLabel *r = (OClickableLabel *) sender(); @@ -92,6 +108,32 @@ void OTimePicker::slotMinute(bool b) { } +/** + * Method to set the time. No signal gets emitted during this method call + * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... ) + * @param t The time to be set + */ +void OTimePicker::setTime( const QTime& t) { + setTime( t.hour(), t.minute() ); +} + +/** + * Method to set the time. No signal gets emitted during this method call + * @param h The hour + * @param m The minute. Minutes need to set by 5 minute steps + */ +void OTimePicker::setTime( int h, int m ) { + setHour(h); + setMinute(m); +} + +/* + * FIXME round minutes to the 5 minute arrangement -zecke + */ +/** + * Method to set the minutes + * @param m minutes + */ void OTimePicker::setMinute(int m) { QString minute; @@ -101,11 +143,14 @@ void OTimePicker::setMinute(int m) { for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { if ((*it)->text() == minute) (*it)->setOn(true); else (*it)->setOn(false); - } + } tm.setHMS(tm.hour(),m,0); } +/** + * Method to set the hour + */ void OTimePicker::setHour(int h) { QString hour; @@ -115,11 +160,18 @@ void OTimePicker::setHour(int h) { for (it=hourLst.begin(); it!=hourLst.end(); it++) { if ((*it)->text() == hour) (*it)->setOn(true); else (*it)->setOn(false); - } + } tm.setHMS(h,tm.minute(),0); } +/** + * This is a modal Dialog. + * + * @param parent The parent widget + * @param name The name of the object + * @param fl Possible window flags + */ OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) : OTimePickerDialogBase (parent , name, true , fl) { @@ -133,10 +185,18 @@ OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags } -QTime& OTimePickerDialog::time() +/** + * @return the time + */ +QTime OTimePickerDialog::time()const { return m_time; } + +/** + * Set the time to time + * @param time The time to be set + */ void OTimePickerDialog::setTime( const QTime& time ) { m_time = time; @@ -154,9 +214,14 @@ void OTimePickerDialog::setTime( const QTime& time ) minuteField->setText( "0" + QString::number( time.minute() ) ); else minuteField->setText( QString::number( time.minute() ) ); - + } +/** + * This method takes the current minute and tries to set hour + * to hour. This succeeds if the resulting date is valid + * @param hour The hour as a string + */ void OTimePickerDialog::setHour ( const QString& hour ) { if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ){ @@ -166,6 +231,11 @@ void OTimePickerDialog::setHour ( const QString& hour ) } +/** + * Method to set a new minute. It tries to convert the string to int and + * if the resulting date is valid a new date is set. + * @see setHour + */ void OTimePickerDialog::setMinute ( const QString& minute ) { if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ){ -- cgit v0.9.0.2