summaryrefslogtreecommitdiff
path: root/libopie/otimepicker.cpp
Unidiff
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
@@ -7,10 +7,18 @@
7#include <stdio.h> 7#include <stdio.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9 9
10
11/**
12 * Constructs the widget
13 * @param parent The parent of the OTimePicker
14 * @param name The name of the object
15 * @param fl Window Flags
16 */
10OTimePicker::OTimePicker(QWidget* parent, const char* name, 17OTimePicker::OTimePicker(QWidget* parent, const char* name,
11 WFlags fl) : 18 WFlags fl) :
12 QWidget(parent,name,fl) 19 QWidget(parent,name,fl)
13{ 20{
21
14 QVBoxLayout *vbox=new QVBoxLayout(this); 22 QVBoxLayout *vbox=new QVBoxLayout(this);
15 23
16 OClickableLabel *r; 24 OClickableLabel *r;
@@ -58,6 +66,14 @@ OTimePicker::OTimePicker(QWidget* parent, const char* name,
58 } 66 }
59} 67}
60 68
69/**
70 * This method return the current time
71 * @return the time
72 */
73QTime OTimePicker::time()const {
74 return tm;
75}
76
61void OTimePicker::slotHour(bool b) { 77void OTimePicker::slotHour(bool b) {
62 78
63 OClickableLabel *r = (OClickableLabel *) sender(); 79 OClickableLabel *r = (OClickableLabel *) sender();
@@ -92,6 +108,32 @@ void OTimePicker::slotMinute(bool b) {
92 108
93} 109}
94 110
111/**
112 * Method to set the time. No signal gets emitted during this method call
113 * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... )
114 * @param t The time to be set
115 */
116void OTimePicker::setTime( const QTime& t) {
117 setTime( t.hour(), t.minute() );
118}
119
120/**
121 * Method to set the time. No signal gets emitted during this method call
122 * @param h The hour
123 * @param m The minute. Minutes need to set by 5 minute steps
124 */
125void OTimePicker::setTime( int h, int m ) {
126 setHour(h);
127 setMinute(m);
128}
129
130/*
131 * FIXME round minutes to the 5 minute arrangement -zecke
132 */
133/**
134 * Method to set the minutes
135 * @param m minutes
136 */
95void OTimePicker::setMinute(int m) { 137void OTimePicker::setMinute(int m) {
96 138
97 QString minute; 139 QString minute;
@@ -106,6 +148,9 @@ void OTimePicker::setMinute(int m) {
106 tm.setHMS(tm.hour(),m,0); 148 tm.setHMS(tm.hour(),m,0);
107} 149}
108 150
151/**
152 * Method to set the hour
153 */
109void OTimePicker::setHour(int h) { 154void OTimePicker::setHour(int h) {
110 155
111 QString hour; 156 QString hour;
@@ -120,6 +165,13 @@ void OTimePicker::setHour(int h) {
120} 165}
121 166
122 167
168/**
169 * This is a modal Dialog.
170 *
171 * @param parent The parent widget
172 * @param name The name of the object
173 * @param fl Possible window flags
174 */
123OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) 175OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl )
124 : OTimePickerDialogBase (parent , name, true , fl) 176 : OTimePickerDialogBase (parent , name, true , fl)
125{ 177{
@@ -133,10 +185,18 @@ OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags
133 185
134} 186}
135 187
136QTime& OTimePickerDialog::time() 188/**
189 * @return the time
190 */
191QTime OTimePickerDialog::time()const
137{ 192{
138 return m_time; 193 return m_time;
139} 194}
195
196/**
197 * Set the time to time
198 * @param time The time to be set
199 */
140void OTimePickerDialog::setTime( const QTime& time ) 200void OTimePickerDialog::setTime( const QTime& time )
141{ 201{
142 m_time = time; 202 m_time = time;
@@ -157,6 +217,11 @@ void OTimePickerDialog::setTime( const QTime& time )
157 217
158} 218}
159 219
220/**
221 * This method takes the current minute and tries to set hour
222 * to hour. This succeeds if the resulting date is valid
223 * @param hour The hour as a string
224 */
160void OTimePickerDialog::setHour ( const QString& hour ) 225void OTimePickerDialog::setHour ( const QString& hour )
161{ 226{
162 if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ){ 227 if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ){
@@ -166,6 +231,11 @@ void OTimePickerDialog::setHour ( const QString& hour )
166 231
167} 232}
168 233
234/**
235 * Method to set a new minute. It tries to convert the string to int and
236 * if the resulting date is valid a new date is set.
237 * @see setHour
238 */
169void OTimePickerDialog::setMinute ( const QString& minute ) 239void OTimePickerDialog::setMinute ( const QString& minute )
170{ 240{
171 if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ){ 241 if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ){