summaryrefslogtreecommitdiff
path: root/libopie/otimepicker.cpp
Unidiff
Diffstat (limited to 'libopie/otimepicker.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/otimepicker.cpp3
1 files changed, 0 insertions, 3 deletions
diff --git a/libopie/otimepicker.cpp b/libopie/otimepicker.cpp
index 115d39b..1eca7c5 100644
--- a/libopie/otimepicker.cpp
+++ b/libopie/otimepicker.cpp
@@ -1,134 +1,131 @@
1#include "otimepicker.h" 1#include "otimepicker.h"
2 2
3#include <qbuttongroup.h>
4#include <qtoolbutton.h>
5#include <qlayout.h> 3#include <qlayout.h>
6#include <qstring.h>
7#include <stdio.h> 4#include <stdio.h>
8#include <qlineedit.h> 5#include <qlineedit.h>
9 6
10 7
11/** 8/**
12 * Constructs the widget 9 * Constructs the widget
13 * @param parent The parent of the OTimePicker 10 * @param parent The parent of the OTimePicker
14 * @param name The name of the object 11 * @param name The name of the object
15 * @param fl Window Flags 12 * @param fl Window Flags
16 */ 13 */
17OTimePicker::OTimePicker(QWidget* parent, const char* name, 14OTimePicker::OTimePicker(QWidget* parent, const char* name,
18 WFlags fl) : 15 WFlags fl) :
19 QWidget(parent,name,fl) 16 QWidget(parent,name,fl)
20{ 17{
21 18
22 QVBoxLayout *vbox=new QVBoxLayout(this); 19 QVBoxLayout *vbox=new QVBoxLayout(this);
23 20
24 OClickableLabel *r; 21 OClickableLabel *r;
25 QString s; 22 QString s;
26 23
27 // Hour Row 24 // Hour Row
28 QWidget *row=new QWidget(this); 25 QWidget *row=new QWidget(this);
29 QHBoxLayout *l=new QHBoxLayout(row); 26 QHBoxLayout *l=new QHBoxLayout(row);
30 vbox->addWidget(row); 27 vbox->addWidget(row);
31 28
32 29
33 for (int i=0; i<24; i++) { 30 for (int i=0; i<24; i++) {
34 r=new OClickableLabel(row); 31 r=new OClickableLabel(row);
35 hourLst.append(r); 32 hourLst.append(r);
36 s.sprintf("%.2d",i); 33 s.sprintf("%.2d",i);
37 r->setText(s); 34 r->setText(s);
38 r->setToggleButton(true); 35 r->setToggleButton(true);
39 r->setAlignment(AlignHCenter | AlignVCenter); 36 r->setAlignment(AlignHCenter | AlignVCenter);
40 l->addWidget(r); 37 l->addWidget(r);
41 connect(r, SIGNAL(toggled(bool)), 38 connect(r, SIGNAL(toggled(bool)),
42 this, SLOT(slotHour(bool))); 39 this, SLOT(slotHour(bool)));
43 40
44 if (i==11) { // Second row 41 if (i==11) { // Second row
45 row=new QWidget(this); 42 row=new QWidget(this);
46 l=new QHBoxLayout(row); 43 l=new QHBoxLayout(row);
47 vbox->addWidget(row); 44 vbox->addWidget(row);
48 } 45 }
49 } 46 }
50 47
51 // Minute Row 48 // Minute Row
52 row=new QWidget(this); 49 row=new QWidget(this);
53 l=new QHBoxLayout(row); 50 l=new QHBoxLayout(row);
54 vbox->addWidget(row); 51 vbox->addWidget(row);
55 52
56 for (int i=0; i<60; i+=5) { 53 for (int i=0; i<60; i+=5) {
57 r=new OClickableLabel(row); 54 r=new OClickableLabel(row);
58 minuteLst.append(r); 55 minuteLst.append(r);
59 s.sprintf("%.2d",i); 56 s.sprintf("%.2d",i);
60 r->setText(s); 57 r->setText(s);
61 r->setToggleButton(true); 58 r->setToggleButton(true);
62 r->setAlignment(AlignHCenter | AlignVCenter); 59 r->setAlignment(AlignHCenter | AlignVCenter);
63 l->addWidget(r); 60 l->addWidget(r);
64 connect(r, SIGNAL(toggled(bool)), 61 connect(r, SIGNAL(toggled(bool)),
65 this, SLOT(slotMinute(bool))); 62 this, SLOT(slotMinute(bool)));
66 } 63 }
67} 64}
68 65
69/** 66/**
70 * This method return the current time 67 * This method return the current time
71 * @return the time 68 * @return the time
72 */ 69 */
73QTime OTimePicker::time()const { 70QTime OTimePicker::time()const {
74 return tm; 71 return tm;
75} 72}
76 73
77void OTimePicker::slotHour(bool b) { 74void OTimePicker::slotHour(bool b) {
78 75
79 OClickableLabel *r = (OClickableLabel *) sender(); 76 OClickableLabel *r = (OClickableLabel *) sender();
80 77
81 if (b) { 78 if (b) {
82 QValueListIterator<OClickableLabel *> it; 79 QValueListIterator<OClickableLabel *> it;
83 for (it=hourLst.begin(); it!=hourLst.end(); it++) { 80 for (it=hourLst.begin(); it!=hourLst.end(); it++) {
84 if (*it != r) (*it)->setOn(false); 81 if (*it != r) (*it)->setOn(false);
85 else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); 82 else tm.setHMS((*it)->text().toInt(), tm.minute(), 0);
86 } 83 }
87 emit timeChanged(tm); 84 emit timeChanged(tm);
88 } else { 85 } else {
89 r->setOn(true); 86 r->setOn(true);
90 } 87 }
91 88
92} 89}
93 90
94void OTimePicker::slotMinute(bool b) { 91void OTimePicker::slotMinute(bool b) {
95 92
96 OClickableLabel *r = (OClickableLabel *) sender(); 93 OClickableLabel *r = (OClickableLabel *) sender();
97 94
98 if (b) { 95 if (b) {
99 QValueListIterator<OClickableLabel *> it; 96 QValueListIterator<OClickableLabel *> it;
100 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { 97 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) {
101 if (*it != r) (*it)->setOn(false); 98 if (*it != r) (*it)->setOn(false);
102 else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); 99 else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0);
103 } 100 }
104 emit timeChanged(tm); 101 emit timeChanged(tm);
105 } else { 102 } else {
106 r->setOn(true); 103 r->setOn(true);
107 } 104 }
108 105
109} 106}
110 107
111/** 108/**
112 * Method to set the time. No signal gets emitted during this method call 109 * 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... ) 110 * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... )
114 * @param t The time to be set 111 * @param t The time to be set
115 */ 112 */
116void OTimePicker::setTime( const QTime& t) { 113void OTimePicker::setTime( const QTime& t) {
117 setTime( t.hour(), t.minute() ); 114 setTime( t.hour(), t.minute() );
118} 115}
119 116
120/** 117/**
121 * Method to set the time. No signal gets emitted during this method call 118 * Method to set the time. No signal gets emitted during this method call
122 * @param h The hour 119 * @param h The hour
123 * @param m The minute. Minutes need to set by 5 minute steps 120 * @param m The minute. Minutes need to set by 5 minute steps
124 */ 121 */
125void OTimePicker::setTime( int h, int m ) { 122void OTimePicker::setTime( int h, int m ) {
126 setHour(h); 123 setHour(h);
127 setMinute(m); 124 setMinute(m);
128} 125}
129 126
130/* 127/*
131 * FIXME round minutes to the 5 minute arrangement -zecke 128 * FIXME round minutes to the 5 minute arrangement -zecke
132 */ 129 */
133/** 130/**
134 * Method to set the minutes 131 * Method to set the minutes