summaryrefslogtreecommitdiff
path: root/libopie2/opieui/otimepicker.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opieui/otimepicker.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/otimepicker.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/libopie2/opieui/otimepicker.cpp b/libopie2/opieui/otimepicker.cpp
index 66f9ce0..7de0fd3 100644
--- a/libopie2/opieui/otimepicker.cpp
+++ b/libopie2/opieui/otimepicker.cpp
@@ -1,85 +1,89 @@
/*
This file is part of the Opie Project
Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
+/* OPIE */
+#include <opie2/otimepicker.h>
+
/* QT */
+#include <qgroupbox.h>
#include <qlayout.h>
#include <qlineedit.h>
-/* OPIE */
-#include <opie2/otimepicker.h>
-using namespace Opie;
+
+namespace Opie {
+namespace Ui {
/**
* 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, Qt::WFlags fl)
:QWidget(parent,name,fl)
{
QVBoxLayout *vbox=new QVBoxLayout(this);
OClickableLabel *r;
QString s;
// Hour Row
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);
s.sprintf("%.2d",i);
r->setText(s);
r->setToggleButton(true);
r->setAlignment(AlignHCenter | AlignVCenter);
l->addWidget(r);
connect(r, SIGNAL(toggled(bool)),
this, SLOT(slotHour(bool)));
if (i==11)
{ // Second row
row=new QWidget(this);
l=new QHBoxLayout(row);
vbox->addWidget(row);
}
}
// Minute Row
row=new QWidget(this);
l=new QHBoxLayout(row);
vbox->addWidget(row);
for (int i=0; i<60; i+=5)
{
r=new OClickableLabel(row);
@@ -175,118 +179,123 @@ void OTimePicker::setTime( int h, int m )
* Method to set the minutes
* @param m minutes
*/
void OTimePicker::setMinute(int m)
{
QString minute;
minute.sprintf("%.2d",m);
QValueListIterator<OClickableLabel *> it;
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;
hour.sprintf("%.2d",h);
QValueListIterator<OClickableLabel *> it;
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)
{
+ m_timePicker = new OTimePicker( GroupBox1, "m_timePicker" );
+ GroupBox1Layout->addWidget( m_timePicker, 0, 0 );
connect ( m_timePicker, SIGNAL( timeChanged(const QTime&) ),
this, SLOT( setTime(const QTime&) ) );
connect ( minuteField, SIGNAL( textChanged(const QString&) ),
this, SLOT ( setMinute(const QString&) ) );
connect ( hourField, SIGNAL( textChanged(const QString&) ),
this, SLOT ( setHour(const QString&) ) );
}
/**
* @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() );
// Set Textfields
if ( time.hour() < 10 )
hourField->setText( "0" + QString::number( time.hour() ) );
else
hourField->setText( QString::number( time.hour() ) );
if ( time.minute() < 10 )
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 );
}
}
+
+}
+}