summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook/clickablelabel.cpp71
-rw-r--r--core/pim/datebook/clickablelabel.h10
-rw-r--r--core/pim/datebook/datebook.cpp11
-rw-r--r--core/pim/datebook/datebook.pro6
-rw-r--r--core/pim/datebook/dateentry.ui639
-rw-r--r--core/pim/datebook/dateentryimpl.cpp95
-rw-r--r--core/pim/datebook/dateentryimpl.h7
-rw-r--r--core/pim/datebook/timepicker.cpp119
-rw-r--r--core/pim/datebook/timepicker.h32
9 files changed, 340 insertions, 650 deletions
diff --git a/core/pim/datebook/clickablelabel.cpp b/core/pim/datebook/clickablelabel.cpp
index 6912c34..1dd0d15 100644
--- a/core/pim/datebook/clickablelabel.cpp
+++ b/core/pim/datebook/clickablelabel.cpp
@@ -1,31 +1,88 @@
#include "clickablelabel.h"
+#include <stdio.h>
ClickableLabel::ClickableLabel(QWidget* parent = 0,
const char* name = 0,
WFlags fl = 0) :
QLabel(parent,name,fl)
{
- setFrameShape(NoFrame);
+ textInverted=false;
+ isToggle=false;
+ isDown=false;
+ showState(false);
setFrameShadow(Sunken);
}
+void ClickableLabel::setToggleButton(bool t) {
+ isToggle=t;
+}
+
void ClickableLabel::mousePressEvent( QMouseEvent *e ) {
- setFrameShape(Panel);
- repaint();
+ if (isToggle && isDown) {
+ showState(false);
+ } else {
+ showState(true);
+ }
}
void ClickableLabel::mouseReleaseEvent( QMouseEvent *e ) {
- setFrameShape(NoFrame);
- repaint();
+ if (rect().contains(e->pos()) && isToggle) isDown=!isDown;
+
+ if (isToggle && isDown) {
+ showState(true);
+ } else {
+ showState(false);
+ }
+
if (rect().contains(e->pos())) {
+ if (isToggle) {
+ emit toggled(isDown);
+ }
emit clicked();
}
}
void ClickableLabel::mouseMoveEvent( QMouseEvent *e ) {
if (rect().contains(e->pos())) {
- setFrameShape(Panel);
+ if (isToggle && isDown) {
+ showState(false);
} else {
- setFrameShape(NoFrame);
+ showState(true);
}
+ } else {
+ if (isToggle && isDown) {
+ showState(true);
+ } else {
+ showState(false);
+ }
+ }
+}
+
+void ClickableLabel::showState(bool on) {
+ if (on) {
+ //setFrameShape(Panel);
+ setInverted(true);
+ setBackgroundMode(PaletteHighlight);
+ } else {
+ //setFrameShape(NoFrame);
+ setInverted(false);
+ setBackgroundMode(PaletteBackground);
+ }
+ repaint();
+}
+
+void ClickableLabel::setInverted(bool on) {
+ if ( (!textInverted && on) || (textInverted && !on) ) {
+ QPalette pal=palette();
+ QColor col=pal.color(QPalette::Normal, QColorGroup::Foreground);
+ col.setRgb(255-col.red(),255-col.green(),255-col.blue());
+ pal.setColor(QPalette::Normal, QColorGroup::Foreground, col);
+ setPalette(pal);
+ textInverted=!textInverted;
+ }
+}
+
+void ClickableLabel::setOn(bool on) {
+ isDown=on;
+ showState(isDown);
}
diff --git a/core/pim/datebook/clickablelabel.h b/core/pim/datebook/clickablelabel.h
index b6d33ad..d00fee6 100644
--- a/core/pim/datebook/clickablelabel.h
+++ b/core/pim/datebook/clickablelabel.h
@@ -8,13 +8,23 @@ class ClickableLabel: public QLabel
Q_OBJECT
public:
ClickableLabel(QWidget* parent = 0, const char* name = 0,
WFlags fl = 0);
+ void setToggleButton(bool t);
protected:
void mousePressEvent( QMouseEvent *e );
void mouseReleaseEvent( QMouseEvent *e );
void mouseMoveEvent( QMouseEvent *e );
+ public slots:
+ void setOn(bool on);
signals:
void clicked();
+ void toggled(bool on);
+ private:
+ bool isToggle;
+ bool isDown;
+ void showState(bool on);
+ bool textInverted;
+ void setInverted(bool on);
};
#endif
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 92dbdc8..2deb96f 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -206,8 +206,11 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
#if !defined(QT_NO_COP)
QCopChannel *channel = new QCopChannel( "QPE/System", this );
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT(receive(const QCString&, const QByteArray&)) );
+ channel = new QCopChannel( "QPE/Datebook", this );
+ connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
+ this, SLOT(receive(const QCString&, const QByteArray&)) );
#endif
#endif
qDebug("done t=%d", t.elapsed() );
@@ -225,8 +228,16 @@ void DateBook::receive( const QCString &msg, const QByteArray &data )
viewWeek();
else if ( monthAction->isOn() )
viewMonth();
}
+ else if (msg == "editEvent(int)") {
+ /* Not yet working...
+ int uid;
+ stream >> uid;
+ Event e=db->getEvent(uid);
+ editEvent(e);
+ */
+ }
}
DateBook::~DateBook()
{
diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro
index 314a56a..09d5c2d 100644
--- a/core/pim/datebook/datebook.pro
+++ b/core/pim/datebook/datebook.pro
@@ -10,9 +10,10 @@ HEADERS = datebookday.h \
datebookweek.h \
datebookweeklst.h \
datebookweekheaderimpl.h \
repeatentry.h \
- clickablelabel.h
+ clickablelabel.h \
+ timepicker.h
SOURCES = main.cpp \
datebookday.cpp \
datebook.cpp \
@@ -22,9 +23,10 @@ SOURCES = main.cpp \
datebookweek.cpp \
datebookweeklst.cpp \
datebookweekheaderimpl.cpp \
repeatentry.cpp \
- clickablelabel.cpp
+ clickablelabel.cpp \
+ timepicker.cpp
INTERFACES = dateentry.ui \
datebookdayheader.ui \
datebooksettingsbase.ui \
diff --git a/core/pim/datebook/dateentry.ui b/core/pim/datebook/dateentry.ui
index eac4e23..22ff32d 100644
--- a/core/pim/datebook/dateentry.ui
+++ b/core/pim/datebook/dateentry.ui
@@ -229,308 +229,19 @@
<string>Jan 02 00</string>
</property>
</widget>
<widget row="3" column="2" rowspan="1" colspan="2" >
- <class>QComboBox</class>
- <item>
- <property>
- <name>text</name>
- <string>00:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>00:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>01:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>01:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>02:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>02:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>03:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>03:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>04:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>04:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>05:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>05:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>06:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>06:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>07:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>07:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>08:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>08:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>09:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>09:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>10:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>10:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>11:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>11:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>12:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>12:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>13:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>13:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>14:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>14:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>15:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>15:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>16:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>16:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>17:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>17:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>18:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>18:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>19:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>19:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>20:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>20:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>21:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>21:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>22:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>22:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>23:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>23:30</string>
- </property>
- </item>
+ <class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>comboStart</cstring>
</property>
+ </widget>
+ <widget row="5" column="1" colspan="3">
+ <class>TimePicker</class>
<property stdset="1">
- <name>editable</name>
- <bool>true</bool>
- </property>
- <property stdset="1">
- <name>duplicatesEnabled</name>
- <bool>false</bool>
+ <name>name</name>
+ <cstring>timePickerStart</cstring>
</property>
</widget>
<widget row="4" column="1" >
<class>QPushButton</class>
@@ -543,309 +254,13 @@
<string>Jan 02 00</string>
</property>
</widget>
<widget row="4" column="2" rowspan="1" colspan="2" >
- <class>QComboBox</class>
- <item>
- <property>
- <name>text</name>
- <string>00:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>00:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>01:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>01:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>02:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>02:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>03:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>03:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>04:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>04:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>05:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>05:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>06:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>06:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>07:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>07:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>08:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>08:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>09:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>09:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>10:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>10:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>11:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>11:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>12:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>12:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>13:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>13:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>14:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>14:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>15:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>15:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>16:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>16:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>17:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>17:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>18:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>18:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>19:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>19:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>20:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>20:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>21:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>21:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>22:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>22:30</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>23:00</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>23:30</string>
- </property>
- </item>
+ <class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>comboEnd</cstring>
</property>
- <property stdset="1">
- <name>editable</name>
- <bool>true</bool>
- </property>
- <property stdset="1">
- <name>duplicatesEnabled</name>
- <bool>false</bool>
- </property>
</widget>
<widget row="4" column="0" >
<class>QLabel</class>
<property stdset="1">
@@ -856,9 +271,9 @@
<name>text</name>
<string>End</string>
</property>
</widget>
- <widget row="5" column="0" >
+ <widget row="6" column="0" >
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>checkAllDay</cstring>
@@ -867,9 +282,9 @@
<name>text</name>
<string>All day</string>
</property>
</widget>
- <widget row="6" column="0" >
+ <widget row="7" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel3_2_2</cstring>
@@ -878,16 +293,16 @@
<name>text</name>
<string>Time zone:</string>
</property>
</widget>
- <widget row="6" column="1" rowspan="1" colspan="3" >
+ <widget row="7" column="1" rowspan="1" colspan="3" >
<class>TimeZoneSelector</class>
<property stdset="1">
<name>name</name>
<cstring>timezone</cstring>
</property>
</widget>
- <widget row="7" column="0" >
+ <widget row="8" column="0" >
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>checkAlarm</cstring>
@@ -908,9 +323,9 @@
<name>checked</name>
<bool>false</bool>
</property>
</widget>
- <widget row="7" column="1" rowspan="1" colspan="2" >
+ <widget row="8" column="1" rowspan="1" colspan="2" >
<class>QSpinBox</class>
<property stdset="1">
<name>name</name>
<cstring>spinAlarm</cstring>
@@ -939,9 +354,9 @@
<name>value</name>
<number>5</number>
</property>
</widget>
- <widget row="7" column="3" >
+ <widget row="8" column="3" >
<class>QComboBox</class>
<item>
<property>
<name>text</name>
@@ -962,9 +377,9 @@
<name>enabled</name>
<bool>false</bool>
</property>
</widget>
- <widget row="8" column="0" >
+ <widget row="9" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>lblRepeat</cstring>
@@ -973,9 +388,9 @@
<name>text</name>
<string>Repeat</string>
</property>
</widget>
- <widget row="8" column="1" rowspan="1" colspan="3" >
+ <widget row="9" column="1" rowspan="1" colspan="3" >
<class>QToolButton</class>
<property stdset="1">
<name>name</name>
<cstring>cmdRepeat</cstring>
@@ -988,9 +403,9 @@
<name>text</name>
<string>No Repeat...</string>
</property>
</widget>
- <widget row="9" column="0" rowspan="1" colspan="4" >
+ <widget row="10" column="0" rowspan="1" colspan="4" >
<class>QMultiLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>editNote</cstring>
@@ -1026,8 +441,22 @@
<verdata>1</verdata>
</sizepolicy>
<pixmap>image1</pixmap>
</customwidget>
+ <customwidget>
+ <class>TimePicker</class>
+ <header location="local">timepicker.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>7</hordata>
+ <verdata>1</verdata>
+ </sizepolicy>
+ <pixmap>image1</pixmap>
+ </customwidget>
</customwidgets>
<images>
<image>
<name>image0</name>
@@ -1046,9 +475,9 @@
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>comboEnd</sender>
- <signal>activated(const QString&amp;)</signal>
+ <signal>textChanged(const QString&amp;)</signal>
<receiver>DateEntryBase</receiver>
<slot>endTimeChanged( const QString &amp; )</slot>
</connection>
<connection>
@@ -1058,11 +487,11 @@
<slot>slotRepeat()</slot>
</connection>
<connection>
<sender>comboStart</sender>
- <signal>activated(int)</signal>
+ <signal>textChanged(const QString &amp;)</signal>
<receiver>DateEntryBase</receiver>
- <slot>startTimeChanged( int )</slot>
+ <slot>startTimeEdited( const QString &amp; )</slot>
</connection>
<connection>
<sender>checkAllDay</sender>
<signal>toggled(bool)</signal>
@@ -1087,9 +516,9 @@
<slot access="public">slotRepeat()</slot>
<slot access="public">slotWait( int )</slot>
<slot access="public">startDateChanged( const QString &amp; )</slot>
<slot access="public">startDateChanged(int, int, int)</slot>
- <slot access="public">startTimeChanged( int )</slot>
+ <slot access="public">startTimeEdited( const QString &amp; )</slot>
<slot access="public">typeChanged( const QString &amp; )</slot>
<slot access="public">tzexecute(void)</slot>
</connections>
</UI>
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index b2e3e3a..1c43363 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -38,8 +38,10 @@
#include <qscrollview.h>
#include <qspinbox.h>
#include <qtoolbutton.h>
+#include "timepicker.h"
+
#include <stdlib.h>
#include <stdiostream.h>
@@ -64,15 +66,19 @@ DateEntry::DateEntry( bool startOnMonday, const QDateTime &start,
}
static void addOrPick( QComboBox* combo, const QString& t )
{
+ // Pick an item if one excists
for (int i=0; i<combo->count(); i++) {
if ( combo->text(i) == t ) {
combo->setCurrentItem(i);
return;
}
}
- combo->setEditText(t);
+
+ // Else add one
+ combo->insertItem(t);
+ combo->setCurrentItem(combo->count()-1);
}
DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock,
QWidget* parent, const char* name )
@@ -102,47 +108,52 @@ DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock,
}
void DateEntry::setDates( const QDateTime& s, const QDateTime& e )
{
- int shour,
- ehour;
- QString strStart,
- strEnd;
startDate = s.date();
endDate = e.date();
startTime = s.time();
endTime = e.time();
startDateChanged( s.date().year(), s.date().month(), s.date().day() );
+ endDateChanged( e.date().year(), e.date().month(), e.date().day() );
+ updateTimeEdit(true,true);
+}
+
+void DateEntry::updateTimeEdit(bool s, bool e) {
+
+ // Comboboxes
+ QString strStart, strEnd;
+ int shour, ehour;
if ( ampm ) {
- shour = s.time().hour();
- ehour = e.time().hour();
+ shour = startTime.hour();
+ ehour = endTime.hour();
if ( shour >= 12 ) {
if ( shour > 12 )
shour -= 12;
- strStart.sprintf( "%d:%02d PM", shour, s.time().minute() );
+ strStart.sprintf( "%d:%02d PM", shour, startTime.minute() );
} else {
if ( shour == 0 )
shour = 12;
- strStart.sprintf( "%d:%02d AM", shour, s.time().minute() );
+ strStart.sprintf( "%d:%02d AM", shour, startTime.minute() );
}
- if ( ehour == 24 && e.time().minute() == 0 ) {
+ if ( ehour == 24 && endTime.minute() == 0 ) {
strEnd = "11:59 PM"; // or "midnight"
} else if ( ehour >= 12 ) {
if ( ehour > 12 )
ehour -= 12;
- strEnd.sprintf( "%d:%02d PM", ehour, e.time().minute() );
+ strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() );
} else {
if ( ehour == 0 )
ehour = 12;
- strEnd.sprintf( "%d:%02d AM", ehour, e.time().minute() );
+ strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() );
}
} else {
- strStart.sprintf( "%02d:%02d", s.time().hour(), s.time().minute() );
- strEnd.sprintf( "%02d:%02d", e.time().hour(), e.time().minute() );
+ strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() );
+ strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() );
}
- addOrPick(comboStart, strStart );
- endDateChanged( e.date().year(), e.date().month(), e.date().day() );
- addOrPick(comboEnd, strEnd );
+
+ if (s) comboStart->setText(strStart);
+ if (e) comboEnd->setText(strEnd);
}
void DateEntry::init()
{
@@ -170,8 +181,12 @@ void DateEntry::init()
m2->insertItem( endPicker );
buttonEnd->setPopup( m2 );
connect( endPicker, SIGNAL( dateClicked( int, int, int ) ),
this, SLOT( endDateChanged( int, int, int ) ) );
+
+ connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ),
+ this, SLOT( startTimePicked(const QTime &) ));
+ editNote->setFixedVisibleLines(3);
}
/*
* Destroys the object and frees any allocated resources
@@ -239,10 +254,14 @@ void DateEntry::endTimeChanged( const QString &s )
if ( endDate > startDate || tmpTime >= startTime ) {
endTime = tmpTime;
} else {
endTime = startTime;
- comboEnd->setCurrentItem( comboStart->currentItem() );
+ //comboEnd->setCurrentItem( comboStart->currentItem() );
}
+
+}
+
+void DateEntry::endTimeChanged( const QTime &t ) {
}
/*
* public slot
@@ -269,14 +288,27 @@ void DateEntry::startDateChanged( int y, int m, int d )
/*
* public slot
*/
-void DateEntry::startTimeChanged( int index )
+void DateEntry::startTimeEdited( const QString &s )
{
- startTime = parseTime(comboStart->text(index),ampm);
- changeEndCombo( index );
- //cout << "Start: " << comboStart->currentText() << endl;
+ startTimeChanged(parseTime(s,ampm));
+ updateTimeEdit(false,true);
+ timePickerStart->setHour(startTime.hour());
+ timePickerStart->setMinute(startTime.minute());
}
+
+void DateEntry::startTimeChanged( const QTime &t )
+{
+ int duration=startTime.secsTo(endTime);
+ startTime = t;
+ endTime=t.addSecs(duration);
+}
+void DateEntry::startTimePicked( const QTime &t ) {
+ startTimeChanged(t);
+ updateTimeEdit(true,true);
+}
+
/*
* public slot
*/
void DateEntry::typeChanged( const QString &s )
@@ -285,18 +317,8 @@ void DateEntry::typeChanged( const QString &s )
buttonStart->setEnabled( b );
comboStart->setEnabled( b );
comboEnd->setEnabled( b );
}
-/*
- * public slot
- */
-void DateEntry::changeEndCombo( int change )
-{
- if ( change + 2 < comboEnd->count() )
- change += 2;
- comboEnd->setCurrentItem( change );
- endTimeChanged( comboEnd->currentText() );
-}
void DateEntry::slotRepeat()
{
// Work around for compiler Bug..
@@ -335,10 +357,13 @@ Event DateEntry::event()
QDate tmp = endDate;
endDate = startDate;
startDate = tmp;
}
- startTime = parseTime( comboStart->currentText(), ampm );
- endTime = parseTime( comboEnd->currentText(), ampm );
+
+ // This is now done in the changed slots
+ // startTime = parseTime( comboStart->text(), ampm );
+ //endTime = parseTime( comboEnd->text(), ampm );
+
if ( startTime > endTime && endDate == startDate ) {
QTime tmp = endTime;
endTime = startTime;
startTime = tmp;
@@ -426,8 +451,9 @@ void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundT
}
void DateEntry::initCombos()
{
+ /*
comboStart->clear();
comboEnd->clear();
if ( ampm ) {
for ( int i = 0; i < 24; i++ ) {
@@ -471,8 +497,9 @@ void DateEntry::initCombos()
comboEnd->insertItem( QString::number(i) + ":30" );
}
}
}
+ */
}
void DateEntry::slotChangeClock( bool whichClock )
{
diff --git a/core/pim/datebook/dateentryimpl.h b/core/pim/datebook/dateentryimpl.h
index 785af7a..bde3119 100644
--- a/core/pim/datebook/dateentryimpl.h
+++ b/core/pim/datebook/dateentryimpl.h
@@ -45,12 +45,14 @@ public:
public slots:
void endDateChanged( int, int, int );
void endTimeChanged( const QString & );
+ void endTimeChanged( const QTime & );
void startDateChanged(int, int, int);
- void startTimeChanged( int index );
+ void startTimeEdited( const QString & );
+ void startTimeChanged( const QTime & );
+ void startTimePicked( const QTime & );
void typeChanged( const QString & );
- void changeEndCombo( int change );
void slotRepeat();
void slotChangeClock( bool );
void slotChangeStartOfWeek( bool );
@@ -58,8 +60,9 @@ private:
void init();
void initCombos();
void setDates( const QDateTime& s, const QDateTime& e );
void setRepeatLabel();
+ void updateTimeEdit(bool,bool);
DateBookMonth *startPicker, *endPicker;
QDate startDate, endDate;
QTime startTime, endTime;
diff --git a/core/pim/datebook/timepicker.cpp b/core/pim/datebook/timepicker.cpp
new file mode 100644
index 0000000..5f08a05
--- a/dev/null
+++ b/core/pim/datebook/timepicker.cpp
@@ -0,0 +1,119 @@
+#include "timepicker.h"
+
+#include <qbuttongroup.h>
+#include <qtoolbutton.h>
+#include <qlayout.h>
+#include "clickablelabel.h"
+#include <qstring.h>
+
+TimePicker::TimePicker(QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0) :
+ QWidget(parent,name,fl)
+{
+ QVBoxLayout *vbox=new QVBoxLayout(this);
+
+ ClickableLabel *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 ClickableLabel(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 ClickableLabel(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 TimePicker::slotHour(bool b) {
+
+ ClickableLabel *r = (ClickableLabel *) sender();
+
+ if (b) {
+ QValueListIterator<ClickableLabel *> 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 TimePicker::slotMinute(bool b) {
+
+ ClickableLabel *r = (ClickableLabel *) sender();
+
+ if (b) {
+ QValueListIterator<ClickableLabel *> 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 TimePicker::setMinute(int m) {
+
+ QString minute;
+ minute.sprintf("%.2d",m);
+
+ QValueListIterator<ClickableLabel *> 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 TimePicker::setHour(int h) {
+
+ QString hour;
+ hour.sprintf("%.2d",h);
+
+ QValueListIterator<ClickableLabel *> 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);
+}
diff --git a/core/pim/datebook/timepicker.h b/core/pim/datebook/timepicker.h
new file mode 100644
index 0000000..0acadcb
--- a/dev/null
+++ b/core/pim/datebook/timepicker.h
@@ -0,0 +1,32 @@
+#ifndef TIMEPICKER_H
+#define TIMEPICKER_H
+
+#include <qwidget.h>
+#include <qvaluelist.h>
+#include "clickablelabel.h"
+#include <qdatetime.h>
+
+class TimePicker: public QWidget {
+ Q_OBJECT
+
+ public:
+ TimePicker(QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0);
+ void setHour(int h);
+ void setMinute(int m);
+
+ private:
+ QValueList<ClickableLabel *> hourLst;
+ QValueList<ClickableLabel *> minuteLst;
+ QTime tm;
+
+ private slots:
+ void slotHour(bool b);
+ void slotMinute(bool b);
+
+ signals:
+ void timeChanged(const QTime &);
+};
+
+
+#endif