summaryrefslogtreecommitdiff
path: root/libopie/otimepicker.cpp
Side-by-side diff
Diffstat (limited to 'libopie/otimepicker.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie/otimepicker.cpp72
1 files changed, 71 insertions, 1 deletions
diff --git a/libopie/otimepicker.cpp b/libopie/otimepicker.cpp
index 8e8a4e7..115d39b 100644
--- a/libopie/otimepicker.cpp
+++ b/libopie/otimepicker.cpp
@@ -4,16 +4,24 @@
#include <qtoolbutton.h>
#include <qlayout.h>
#include <qstring.h>
#include <stdio.h>
#include <qlineedit.h>
+
+/**
+ * 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;
QString s;
// Hour Row
@@ -55,12 +63,20 @@ OTimePicker::OTimePicker(QWidget* parent, const char* name,
l->addWidget(r);
connect(r, SIGNAL(toggled(bool)),
this, SLOT(slotMinute(bool)));
}
}
+/**
+ * This method return the current time
+ * @return the time
+ */
+QTime OTimePicker::time()const {
+ return tm;
+}
+
void OTimePicker::slotHour(bool b) {
OClickableLabel *r = (OClickableLabel *) sender();
if (b) {
QValueListIterator<OClickableLabel *> it;
@@ -89,12 +105,38 @@ void OTimePicker::slotMinute(bool b) {
} else {
r->setOn(true);
}
}
+/**
+ * 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;
minute.sprintf("%.2d",m);
QValueListIterator<OClickableLabel *> it;
@@ -103,12 +145,15 @@ void OTimePicker::setMinute(int m) {
else (*it)->setOn(false);
}
tm.setHMS(tm.hour(),m,0);
}
+/**
+ * Method to set the hour
+ */
void OTimePicker::setHour(int h) {
QString hour;
hour.sprintf("%.2d",h);
QValueListIterator<OClickableLabel *> it;
@@ -117,12 +162,19 @@ void OTimePicker::setHour(int h) {
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)
{
connect ( m_timePicker, SIGNAL( timeChanged( const QTime& ) ),
this, SLOT( setTime ( const QTime& ) ) );
@@ -130,16 +182,24 @@ OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags
this, SLOT ( setMinute ( const QString& ) ) );
connect ( hourField, SIGNAL( textChanged ( const QString& ) ),
this, SLOT ( setHour ( const QString& ) ) );
}
-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;
m_timePicker->setHour ( time.hour() );
m_timePicker->setMinute( time.minute() );
@@ -154,21 +214,31 @@ 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 ) ){
m_time.setHMS ( hour.toInt(), m_time.minute() , 00 );
setTime ( m_time );
}
}
+/**
+ * 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 ) ){
m_time.setHMS ( m_time.hour(), minute.toInt(), 00 );
setTime ( m_time );
}