summaryrefslogtreecommitdiff
path: root/libopie
authoreilers <eilers>2002-08-20 09:26:48 (UTC)
committer eilers <eilers>2002-08-20 09:26:48 (UTC)
commitb00ba7b9cdf02a4512f70694e2262ce6e3ebcb98 (patch) (unidiff)
tree7b3e6e16917f0835437ddf2e2b87439f3a7a4285 /libopie
parent08a0272257dbb26af4403f9d8d47e5bf300eb0a7 (diff)
downloadopie-b00ba7b9cdf02a4512f70694e2262ce6e3ebcb98.zip
opie-b00ba7b9cdf02a4512f70694e2262ce6e3ebcb98.tar.gz
opie-b00ba7b9cdf02a4512f70694e2262ce6e3ebcb98.tar.bz2
Added nice timepicker widget and dialog
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/libopie.pro6
-rw-r--r--libopie/otimepicker.cpp175
-rw-r--r--libopie/otimepicker.h51
-rw-r--r--libopie/otimepickerbase.h47
-rw-r--r--libopie/otimepickerbase.ui284
5 files changed, 561 insertions, 2 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro
index 1596c9a..463fce2 100644
--- a/libopie/libopie.pro
+++ b/libopie/libopie.pro
@@ -1,23 +1,25 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qte warn_on release 2CONFIG += qte warn_on release
3 HEADERS = ofontmenu.h ofileselector.h ofiledialog.h ofileview.h tododb.h todoevent.h todoresource.h todovcalresource.h xmltree.h colordialog.h colorpopupmenu.h oclickablelabel.h oprocctrl.h oprocess.h odevice.h 3 HEADERS = ofontmenu.h ofileselector.h ofiledialog.h ofileview.h tododb.h todoevent.h todoresource.h todovcalresource.h xmltree.h colordialog.h colorpopupmenu.h oclickablelabel.h oprocctrl.h oprocess.h odevice.h otimepicker.h
4 SOURCES = ofontmenu.cc ofileselector.cc ofiledialog.cc xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp colordialog.cpp colorpopupmenu.cpp oclickablelabel.cpp oprocctrl.cpp oprocess.cpp odevice.cpp 4 SOURCES = ofontmenu.cc ofileselector.cc ofiledialog.cc xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp colordialog.cpp colorpopupmenu.cpp oclickablelabel.cpp oprocctrl.cpp oprocess.cpp odevice.cpp otimepicker.cpp
5 TARGET = opie 5 TARGET = opie
6INCLUDEPATH += $(OPIEDIR)/include 6INCLUDEPATH += $(OPIEDIR)/include
7DESTDIR = $(QTDIR)/lib$(PROJMAK) 7DESTDIR = $(QTDIR)/lib$(PROJMAK)
8#VERSION = 1.0.0 8#VERSION = 1.0.0
9 9
10INTERFACES = otimepickerbase.ui
11
10TRANSLATIONS = ../i18n/de/libopie.ts \ 12TRANSLATIONS = ../i18n/de/libopie.ts \
11 ../i18n/en/libopie.ts \ 13 ../i18n/en/libopie.ts \
12 ../i18n/es/libopie.ts \ 14 ../i18n/es/libopie.ts \
13 ../i18n/fr/libopie.ts \ 15 ../i18n/fr/libopie.ts \
14 ../i18n/hu/libopie.ts \ 16 ../i18n/hu/libopie.ts \
15 ../i18n/ja/libopie.ts \ 17 ../i18n/ja/libopie.ts \
16 ../i18n/ko/libopie.ts \ 18 ../i18n/ko/libopie.ts \
17 ../i18n/no/libopie.ts \ 19 ../i18n/no/libopie.ts \
18 ../i18n/pl/libopie.ts \ 20 ../i18n/pl/libopie.ts \
19 ../i18n/pt/libopie.ts \ 21 ../i18n/pt/libopie.ts \
20 ../i18n/pt_BR/libopie.ts \ 22 ../i18n/pt_BR/libopie.ts \
21 ../i18n/sl/libopie.ts \ 23 ../i18n/sl/libopie.ts \
22 ../i18n/zh_CN/libopie.ts \ 24 ../i18n/zh_CN/libopie.ts \
23 ../i18n/zh_TW/libopie.ts 25 ../i18n/zh_TW/libopie.ts
diff --git a/libopie/otimepicker.cpp b/libopie/otimepicker.cpp
new file mode 100644
index 0000000..8e8a4e7
--- a/dev/null
+++ b/libopie/otimepicker.cpp
@@ -0,0 +1,175 @@
1#include "otimepicker.h"
2
3#include <qbuttongroup.h>
4#include <qtoolbutton.h>
5#include <qlayout.h>
6#include <qstring.h>
7#include <stdio.h>
8#include <qlineedit.h>
9
10OTimePicker::OTimePicker(QWidget* parent, const char* name,
11 WFlags fl) :
12 QWidget(parent,name,fl)
13{
14 QVBoxLayout *vbox=new QVBoxLayout(this);
15
16 OClickableLabel *r;
17 QString s;
18
19 // Hour Row
20 QWidget *row=new QWidget(this);
21 QHBoxLayout *l=new QHBoxLayout(row);
22 vbox->addWidget(row);
23
24
25 for (int i=0; i<24; i++) {
26 r=new OClickableLabel(row);
27 hourLst.append(r);
28 s.sprintf("%.2d",i);
29 r->setText(s);
30 r->setToggleButton(true);
31 r->setAlignment(AlignHCenter | AlignVCenter);
32 l->addWidget(r);
33 connect(r, SIGNAL(toggled(bool)),
34 this, SLOT(slotHour(bool)));
35
36 if (i==11) { // Second row
37 row=new QWidget(this);
38 l=new QHBoxLayout(row);
39 vbox->addWidget(row);
40 }
41 }
42
43 // Minute Row
44 row=new QWidget(this);
45 l=new QHBoxLayout(row);
46 vbox->addWidget(row);
47
48 for (int i=0; i<60; i+=5) {
49 r=new OClickableLabel(row);
50 minuteLst.append(r);
51 s.sprintf("%.2d",i);
52 r->setText(s);
53 r->setToggleButton(true);
54 r->setAlignment(AlignHCenter | AlignVCenter);
55 l->addWidget(r);
56 connect(r, SIGNAL(toggled(bool)),
57 this, SLOT(slotMinute(bool)));
58 }
59}
60
61void OTimePicker::slotHour(bool b) {
62
63 OClickableLabel *r = (OClickableLabel *) sender();
64
65 if (b) {
66 QValueListIterator<OClickableLabel *> it;
67 for (it=hourLst.begin(); it!=hourLst.end(); it++) {
68 if (*it != r) (*it)->setOn(false);
69 else tm.setHMS((*it)->text().toInt(), tm.minute(), 0);
70 }
71 emit timeChanged(tm);
72 } else {
73 r->setOn(true);
74 }
75
76}
77
78void OTimePicker::slotMinute(bool b) {
79
80 OClickableLabel *r = (OClickableLabel *) sender();
81
82 if (b) {
83 QValueListIterator<OClickableLabel *> it;
84 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) {
85 if (*it != r) (*it)->setOn(false);
86 else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0);
87 }
88 emit timeChanged(tm);
89 } else {
90 r->setOn(true);
91 }
92
93}
94
95void OTimePicker::setMinute(int m) {
96
97 QString minute;
98 minute.sprintf("%.2d",m);
99
100 QValueListIterator<OClickableLabel *> it;
101 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) {
102 if ((*it)->text() == minute) (*it)->setOn(true);
103 else (*it)->setOn(false);
104 }
105
106 tm.setHMS(tm.hour(),m,0);
107}
108
109void OTimePicker::setHour(int h) {
110
111 QString hour;
112 hour.sprintf("%.2d",h);
113
114 QValueListIterator<OClickableLabel *> it;
115 for (it=hourLst.begin(); it!=hourLst.end(); it++) {
116 if ((*it)->text() == hour) (*it)->setOn(true);
117 else (*it)->setOn(false);
118 }
119 tm.setHMS(h,tm.minute(),0);
120}
121
122
123OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl )
124 : OTimePickerDialogBase (parent , name, true , fl)
125{
126
127 connect ( m_timePicker, SIGNAL( timeChanged( const QTime& ) ),
128 this, SLOT( setTime ( const QTime& ) ) );
129 connect ( minuteField, SIGNAL( textChanged ( const QString& ) ),
130 this, SLOT ( setMinute ( const QString& ) ) );
131 connect ( hourField, SIGNAL( textChanged ( const QString& ) ),
132 this, SLOT ( setHour ( const QString& ) ) );
133
134}
135
136QTime& OTimePickerDialog::time()
137{
138 return m_time;
139}
140void OTimePickerDialog::setTime( const QTime& time )
141{
142 m_time = time;
143
144 m_timePicker->setHour ( time.hour() );
145 m_timePicker->setMinute( time.minute() );
146
147 // Set Textfields
148 if ( time.hour() < 10 )
149 hourField->setText( "0" + QString::number( time.hour() ) );
150 else
151 hourField->setText( QString::number( time.hour() ) );
152
153 if ( time.minute() < 10 )
154 minuteField->setText( "0" + QString::number( time.minute() ) );
155 else
156 minuteField->setText( QString::number( time.minute() ) );
157
158}
159
160void OTimePickerDialog::setHour ( const QString& hour )
161{
162 if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ){
163 m_time.setHMS ( hour.toInt(), m_time.minute() , 00 );
164 setTime ( m_time );
165 }
166
167}
168
169void OTimePickerDialog::setMinute ( const QString& minute )
170{
171 if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ){
172 m_time.setHMS ( m_time.hour(), minute.toInt(), 00 );
173 setTime ( m_time );
174 }
175}
diff --git a/libopie/otimepicker.h b/libopie/otimepicker.h
new file mode 100644
index 0000000..3de6698
--- a/dev/null
+++ b/libopie/otimepicker.h
@@ -0,0 +1,51 @@
1#ifndef OTIMEPICKER_H
2#define OTIMEPICKER_H
3
4#include <qwidget.h>
5#include <qvaluelist.h>
6#include <qdatetime.h>
7#include <qdialog.h>
8
9#include <opie/oclickablelabel.h>
10#include <opie/otimepickerbase.h>
11
12class OTimePicker: public QWidget {
13 Q_OBJECT
14
15 public:
16 OTimePicker(QWidget* parent = 0, const char* name = 0,
17 WFlags fl = 0);
18 void setHour(int h);
19 void setMinute(int m);
20
21 private:
22 QValueList<OClickableLabel *> hourLst;
23 QValueList<OClickableLabel *> minuteLst;
24 QTime tm;
25
26 private slots:
27 void slotHour(bool b);
28 void slotMinute(bool b);
29
30 signals:
31 void timeChanged(const QTime &);
32};
33
34class OTimePickerDialog: public OTimePickerDialogBase {
35 Q_OBJECT
36
37 public:
38 OTimePickerDialog ( QWidget* parent = 0, const char* name = NULL, WFlags fl = 0 );
39 ~OTimePickerDialog() { };
40
41 QTime& time();
42
43 public slots:
44 void setTime( const QTime& time );
45 void setHour( const QString& hour );
46 void setMinute( const QString& minute );
47
48 private:
49 QTime m_time;
50};
51#endif
diff --git a/libopie/otimepickerbase.h b/libopie/otimepickerbase.h
new file mode 100644
index 0000000..bac2b06
--- a/dev/null
+++ b/libopie/otimepickerbase.h
@@ -0,0 +1,47 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'otimepickerbase.ui'
3**
4** Created: Tue Aug 20 10:04:21 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef OTIMEPICKERDIALOGBASE_H
10#define OTIMEPICKERDIALOGBASE_H
11
12#include <qvariant.h>
13#include <qdialog.h>
14class QVBoxLayout;
15class QHBoxLayout;
16class QGridLayout;
17class OTimePicker;
18class QFrame;
19class QGroupBox;
20class QLabel;
21class QLineEdit;
22
23class OTimePickerDialogBase : public QDialog
24{
25 Q_OBJECT
26
27public:
28 OTimePickerDialogBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
29 ~OTimePickerDialogBase();
30
31 QFrame* Frame10;
32 QFrame* Frame4;
33 QLabel* TextLabel1;
34 QLineEdit* hourField;
35 QLabel* TextLabel1_2;
36 QLineEdit* minuteField;
37 QGroupBox* GroupBox1;
38 OTimePicker* m_timePicker;
39
40protected:
41 QVBoxLayout* OTimePickerDialogBaseLayout;
42 QHBoxLayout* Frame10Layout;
43 QHBoxLayout* Frame4Layout;
44 bool event( QEvent* );
45};
46
47#endif // OTIMEPICKERDIALOGBASE_H
diff --git a/libopie/otimepickerbase.ui b/libopie/otimepickerbase.ui
new file mode 100644
index 0000000..150545b
--- a/dev/null
+++ b/libopie/otimepickerbase.ui
@@ -0,0 +1,284 @@
1<!DOCTYPE UI><UI>
2<class>OTimePickerDialogBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>OTimePickerDialogBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>210</width>
15 <height>146</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>sizePolicy</name>
20 <sizepolicy>
21 <hsizetype>1</hsizetype>
22 <vsizetype>1</vsizetype>
23 </sizepolicy>
24 </property>
25 <property stdset="1">
26 <name>caption</name>
27 <string>TimePicker</string>
28 </property>
29 <property>
30 <name>layoutMargin</name>
31 </property>
32 <vbox>
33 <property stdset="1">
34 <name>margin</name>
35 <number>5</number>
36 </property>
37 <property stdset="1">
38 <name>spacing</name>
39 <number>6</number>
40 </property>
41 <widget>
42 <class>QFrame</class>
43 <property stdset="1">
44 <name>name</name>
45 <cstring>Frame10</cstring>
46 </property>
47 <property stdset="1">
48 <name>sizePolicy</name>
49 <sizepolicy>
50 <hsizetype>1</hsizetype>
51 <vsizetype>7</vsizetype>
52 </sizepolicy>
53 </property>
54 <property stdset="1">
55 <name>frameShape</name>
56 <enum>NoFrame</enum>
57 </property>
58 <property stdset="1">
59 <name>frameShadow</name>
60 <enum>Raised</enum>
61 </property>
62 <property>
63 <name>layoutMargin</name>
64 </property>
65 <hbox>
66 <property stdset="1">
67 <name>margin</name>
68 <number>2</number>
69 </property>
70 <property stdset="1">
71 <name>spacing</name>
72 <number>6</number>
73 </property>
74 <spacer>
75 <property>
76 <name>name</name>
77 <cstring>Spacer4</cstring>
78 </property>
79 <property stdset="1">
80 <name>orientation</name>
81 <enum>Horizontal</enum>
82 </property>
83 <property stdset="1">
84 <name>sizeType</name>
85 <enum>MinimumExpanding</enum>
86 </property>
87 <property>
88 <name>sizeHint</name>
89 <size>
90 <width>20</width>
91 <height>20</height>
92 </size>
93 </property>
94 </spacer>
95 <widget>
96 <class>QFrame</class>
97 <property stdset="1">
98 <name>name</name>
99 <cstring>Frame4</cstring>
100 </property>
101 <property stdset="1">
102 <name>sizePolicy</name>
103 <sizepolicy>
104 <hsizetype>4</hsizetype>
105 <vsizetype>5</vsizetype>
106 </sizepolicy>
107 </property>
108 <property stdset="1">
109 <name>frameShape</name>
110 <enum>Box</enum>
111 </property>
112 <property stdset="1">
113 <name>frameShadow</name>
114 <enum>Sunken</enum>
115 </property>
116 <property>
117 <name>layoutMargin</name>
118 </property>
119 <property>
120 <name>layoutSpacing</name>
121 </property>
122 <hbox>
123 <property stdset="1">
124 <name>margin</name>
125 <number>11</number>
126 </property>
127 <property stdset="1">
128 <name>spacing</name>
129 <number>6</number>
130 </property>
131 <widget>
132 <class>QLabel</class>
133 <property stdset="1">
134 <name>name</name>
135 <cstring>TextLabel1</cstring>
136 </property>
137 <property stdset="1">
138 <name>text</name>
139 <string>Time:</string>
140 </property>
141 </widget>
142 <widget>
143 <class>QLineEdit</class>
144 <property stdset="1">
145 <name>name</name>
146 <cstring>hourField</cstring>
147 </property>
148 <property stdset="1">
149 <name>sizePolicy</name>
150 <sizepolicy>
151 <hsizetype>4</hsizetype>
152 <vsizetype>0</vsizetype>
153 </sizepolicy>
154 </property>
155 <property stdset="1">
156 <name>alignment</name>
157 <set>AlignHCenter</set>
158 </property>
159 <property>
160 <name>hAlign</name>
161 </property>
162 </widget>
163 <widget>
164 <class>QLabel</class>
165 <property stdset="1">
166 <name>name</name>
167 <cstring>TextLabel1_2</cstring>
168 </property>
169 <property stdset="1">
170 <name>font</name>
171 <font>
172 <bold>1</bold>
173 </font>
174 </property>
175 <property stdset="1">
176 <name>text</name>
177 <string>:</string>
178 </property>
179 </widget>
180 <widget>
181 <class>QLineEdit</class>
182 <property stdset="1">
183 <name>name</name>
184 <cstring>minuteField</cstring>
185 </property>
186 <property stdset="1">
187 <name>alignment</name>
188 <set>AlignHCenter</set>
189 </property>
190 <property>
191 <name>hAlign</name>
192 </property>
193 </widget>
194 </hbox>
195 </widget>
196 <spacer>
197 <property>
198 <name>name</name>
199 <cstring>Spacer5</cstring>
200 </property>
201 <property stdset="1">
202 <name>orientation</name>
203 <enum>Horizontal</enum>
204 </property>
205 <property stdset="1">
206 <name>sizeType</name>
207 <enum>MinimumExpanding</enum>
208 </property>
209 <property>
210 <name>sizeHint</name>
211 <size>
212 <width>20</width>
213 <height>20</height>
214 </size>
215 </property>
216 </spacer>
217 </hbox>
218 </widget>
219 <widget>
220 <class>QGroupBox</class>
221 <property stdset="1">
222 <name>name</name>
223 <cstring>GroupBox1</cstring>
224 </property>
225 <property stdset="1">
226 <name>sizePolicy</name>
227 <sizepolicy>
228 <hsizetype>1</hsizetype>
229 <vsizetype>1</vsizetype>
230 </sizepolicy>
231 </property>
232 <property stdset="1">
233 <name>title</name>
234 <string>Pick Time:</string>
235 </property>
236 <widget>
237 <class>OTimePicker</class>
238 <property stdset="1">
239 <name>name</name>
240 <cstring>m_timePicker</cstring>
241 </property>
242 <property stdset="1">
243 <name>geometry</name>
244 <rect>
245 <x>10</x>
246 <y>10</y>
247 <width>180</width>
248 <height>61</height>
249 </rect>
250 </property>
251 <property stdset="1">
252 <name>sizePolicy</name>
253 <sizepolicy>
254 <hsizetype>7</hsizetype>
255 <vsizetype>4</vsizetype>
256 </sizepolicy>
257 </property>
258 </widget>
259 </widget>
260 </vbox>
261</widget>
262<customwidgets>
263 <customwidget>
264 <class>OTimePicker</class>
265 <header location="local">otimepicker.h</header>
266 <sizehint>
267 <width>-1</width>
268 <height>-1</height>
269 </sizehint>
270 <container>0</container>
271 <sizepolicy>
272 <hordata>7</hordata>
273 <verdata>1</verdata>
274 </sizepolicy>
275 <pixmap>image0</pixmap>
276 </customwidget>
277</customwidgets>
278<images>
279 <image>
280 <name>image0</name>
281 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
282 </image>
283</images>
284</UI>