summaryrefslogtreecommitdiff
path: root/libopie
Side-by-side diff
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,13 +1,15 @@
TEMPLATE = lib
CONFIG += qte warn_on release
-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
-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
+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
+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
TARGET = opie
INCLUDEPATH += $(OPIEDIR)/include
DESTDIR = $(QTDIR)/lib$(PROJMAK)
#VERSION = 1.0.0
+INTERFACES = otimepickerbase.ui
+
TRANSLATIONS = ../i18n/de/libopie.ts \
../i18n/en/libopie.ts \
../i18n/es/libopie.ts \
../i18n/fr/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 @@
+#include "otimepicker.h"
+
+#include <qbuttongroup.h>
+#include <qtoolbutton.h>
+#include <qlayout.h>
+#include <qstring.h>
+#include <stdio.h>
+#include <qlineedit.h>
+
+OTimePicker::OTimePicker(QWidget* parent, const char* name,
+ 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);
+ minuteLst.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(slotMinute(bool)));
+ }
+}
+
+void OTimePicker::slotHour(bool b) {
+
+ OClickableLabel *r = (OClickableLabel *) sender();
+
+ if (b) {
+ QValueListIterator<OClickableLabel *> it;
+ for (it=hourLst.begin(); it!=hourLst.end(); it++) {
+ if (*it != r) (*it)->setOn(false);
+ else tm.setHMS((*it)->text().toInt(), tm.minute(), 0);
+ }
+ emit timeChanged(tm);
+ } else {
+ r->setOn(true);
+ }
+
+}
+
+void OTimePicker::slotMinute(bool b) {
+
+ OClickableLabel *r = (OClickableLabel *) sender();
+
+ if (b) {
+ QValueListIterator<OClickableLabel *> it;
+ for (it=minuteLst.begin(); it!=minuteLst.end(); it++) {
+ if (*it != r) (*it)->setOn(false);
+ else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0);
+ }
+ emit timeChanged(tm);
+ } else {
+ r->setOn(true);
+ }
+
+}
+
+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);
+}
+
+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);
+}
+
+
+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& ) ) );
+ connect ( minuteField, SIGNAL( textChanged ( const QString& ) ),
+ this, SLOT ( setMinute ( const QString& ) ) );
+ connect ( hourField, SIGNAL( textChanged ( const QString& ) ),
+ this, SLOT ( setHour ( const QString& ) ) );
+
+}
+
+QTime& OTimePickerDialog::time()
+{
+ return m_time;
+}
+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() ) );
+
+}
+
+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 );
+ }
+
+}
+
+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 );
+ }
+}
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 @@
+#ifndef OTIMEPICKER_H
+#define OTIMEPICKER_H
+
+#include <qwidget.h>
+#include <qvaluelist.h>
+#include <qdatetime.h>
+#include <qdialog.h>
+
+#include <opie/oclickablelabel.h>
+#include <opie/otimepickerbase.h>
+
+class OTimePicker: public QWidget {
+ Q_OBJECT
+
+ public:
+ OTimePicker(QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0);
+ void setHour(int h);
+ void setMinute(int m);
+
+ private:
+ QValueList<OClickableLabel *> hourLst;
+ QValueList<OClickableLabel *> minuteLst;
+ QTime tm;
+
+ private slots:
+ void slotHour(bool b);
+ void slotMinute(bool b);
+
+ signals:
+ void timeChanged(const QTime &);
+};
+
+class OTimePickerDialog: public OTimePickerDialogBase {
+ Q_OBJECT
+
+ public:
+ OTimePickerDialog ( QWidget* parent = 0, const char* name = NULL, WFlags fl = 0 );
+ ~OTimePickerDialog() { };
+
+ QTime& time();
+
+ public slots:
+ void setTime( const QTime& time );
+ void setHour( const QString& hour );
+ void setMinute( const QString& minute );
+
+ private:
+ QTime m_time;
+};
+#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 @@
+/****************************************************************************
+** Form interface generated from reading ui file 'otimepickerbase.ui'
+**
+** Created: Tue Aug 20 10:04:21 2002
+** by: The User Interface Compiler (uic)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+#ifndef OTIMEPICKERDIALOGBASE_H
+#define OTIMEPICKERDIALOGBASE_H
+
+#include <qvariant.h>
+#include <qdialog.h>
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class OTimePicker;
+class QFrame;
+class QGroupBox;
+class QLabel;
+class QLineEdit;
+
+class OTimePickerDialogBase : public QDialog
+{
+ Q_OBJECT
+
+public:
+ OTimePickerDialogBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~OTimePickerDialogBase();
+
+ QFrame* Frame10;
+ QFrame* Frame4;
+ QLabel* TextLabel1;
+ QLineEdit* hourField;
+ QLabel* TextLabel1_2;
+ QLineEdit* minuteField;
+ QGroupBox* GroupBox1;
+ OTimePicker* m_timePicker;
+
+protected:
+ QVBoxLayout* OTimePickerDialogBaseLayout;
+ QHBoxLayout* Frame10Layout;
+ QHBoxLayout* Frame4Layout;
+ bool event( QEvent* );
+};
+
+#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 @@
+<!DOCTYPE UI><UI>
+<class>OTimePickerDialogBase</class>
+<widget>
+ <class>QDialog</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>OTimePickerDialogBase</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>210</width>
+ <height>146</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>TimePicker</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>5</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QFrame</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Frame10</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>7</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>frameShape</name>
+ <enum>NoFrame</enum>
+ </property>
+ <property stdset="1">
+ <name>frameShadow</name>
+ <enum>Raised</enum>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>2</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer4</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>MinimumExpanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget>
+ <class>QFrame</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Frame4</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>frameShape</name>
+ <enum>Box</enum>
+ </property>
+ <property stdset="1">
+ <name>frameShadow</name>
+ <enum>Sunken</enum>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Time:</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>hourField</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>AlignHCenter</set>
+ </property>
+ <property>
+ <name>hAlign</name>
+ </property>
+ </widget>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>:</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>minuteField</cstring>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>AlignHCenter</set>
+ </property>
+ <property>
+ <name>hAlign</name>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer5</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>MinimumExpanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget>
+ <class>QGroupBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>GroupBox1</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>title</name>
+ <string>Pick Time:</string>
+ </property>
+ <widget>
+ <class>OTimePicker</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>m_timePicker</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>180</width>
+ <height>61</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ </widget>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>OTimePicker</class>
+ <header location="local">otimepicker.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>7</hordata>
+ <verdata>1</verdata>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image>
+ <name>image0</name>
+ <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
+ </image>
+</images>
+</UI>