author | zecke <zecke> | 2002-11-30 11:31:24 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-11-30 11:31:24 (UTC) |
commit | cfb09f9ae7b710b3079320f3b268c45c3fae8979 (patch) (unidiff) | |
tree | 7dda9c82a59f8ca6a2cf55271b2749b71e29b26e | |
parent | 9b8b30fa6cbdf1424b29cde21fae112e8bf96e6d (diff) | |
download | opie-cfb09f9ae7b710b3079320f3b268c45c3fae8979.zip opie-cfb09f9ae7b710b3079320f3b268c45c3fae8979.tar.gz opie-cfb09f9ae7b710b3079320f3b268c45c3fae8979.tar.bz2 |
pelling updates
libopie.pro additions
-rw-r--r-- | libopie/libopie.pro | 6 | ||||
-rw-r--r-- | libopie/orecurrancewidget.cpp | 20 | ||||
-rw-r--r-- | libopie/orecurrancewidget.h | 6 |
3 files changed, 27 insertions, 5 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro index b7537cc..2e76cb1 100644 --- a/libopie/libopie.pro +++ b/libopie/libopie.pro | |||
@@ -1,93 +1,99 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qte warn_on release | 2 | CONFIG += qte warn_on release |
3 | HEADERS = ofontmenu.h \ | 3 | HEADERS = ofontmenu.h \ |
4 | ocolorbutton.h \ | 4 | ocolorbutton.h \ |
5 | ofiledialog.h ofileselector.h tododb.h \ | 5 | ofiledialog.h ofileselector.h tododb.h \ |
6 | ocheckitem.h todoevent.h todoresource.h \ | 6 | ocheckitem.h todoevent.h todoresource.h \ |
7 | todovcalresource.h xmltree.h \ | 7 | todovcalresource.h xmltree.h \ |
8 | colordialog.h colorpopupmenu.h \ | 8 | colordialog.h colorpopupmenu.h \ |
9 | oclickablelabel.h oprocctrl.h \ | 9 | oclickablelabel.h oprocctrl.h \ |
10 | oprocess.h odevice.h \ | 10 | oprocess.h odevice.h \ |
11 | otimepicker.h otabwidget.h \ | 11 | otimepicker.h otabwidget.h \ |
12 | otabbar.h otabinfo.h \ | 12 | otabbar.h otabinfo.h \ |
13 | ofontselector.h \ | 13 | ofontselector.h \ |
14 | pim/opimrecord.h \ | 14 | pim/opimrecord.h \ |
15 | pim/otodo.h \ | 15 | pim/otodo.h \ |
16 | pim/orecordlist.h \ | 16 | pim/orecordlist.h \ |
17 | pim/opimaccesstemplate.h \ | 17 | pim/opimaccesstemplate.h \ |
18 | pim/opimaccessbackend.h \ | 18 | pim/opimaccessbackend.h \ |
19 | pim/otodoaccess.h \ | 19 | pim/otodoaccess.h \ |
20 | pim/otodoaccessbackend.h \ | 20 | pim/otodoaccessbackend.h \ |
21 | pim/ocontact.h \ | 21 | pim/ocontact.h \ |
22 | pim/ocontactaccess.h \ | 22 | pim/ocontactaccess.h \ |
23 | pim/ocontactaccessbackend.h \ | 23 | pim/ocontactaccessbackend.h \ |
24 | pim/ocontactaccessbackend_xml.h \ | 24 | pim/ocontactaccessbackend_xml.h \ |
25 | pim/ocontactaccessbackend_vcard.h \ | 25 | pim/ocontactaccessbackend_vcard.h \ |
26 | pim/obackendfactory.h \ | 26 | pim/obackendfactory.h \ |
27 | pim/opimcache.h \ | 27 | pim/opimcache.h \ |
28 | pim/otodoaccessvcal.h \ | 28 | pim/otodoaccessvcal.h \ |
29 | pim/orecur.h \ | 29 | pim/orecur.h \ |
30 | pim/opimstate.h \ | 30 | pim/opimstate.h \ |
31 | pim/opimxrefpartner.h \ | 31 | pim/opimxrefpartner.h \ |
32 | pim/opimxref.h \ | 32 | pim/opimxref.h \ |
33 | pim/opimxrefmanager.h \ | 33 | pim/opimxrefmanager.h \ |
34 | pim/opimmaintainer.h \ | 34 | pim/opimmaintainer.h \ |
35 | pim/opimnotify.h \ | ||
36 | pim/opimnotifymanager.h \ | ||
37 | pim/opimmainwindow.h \ | ||
35 | orecurrancewidget.h \ | 38 | orecurrancewidget.h \ |
36 | oticker.h | 39 | oticker.h |
37 | # pim/otodoaccesssql.h \ | 40 | # pim/otodoaccesssql.h \ |
38 | 41 | ||
39 | SOURCES = ofontmenu.cc \ | 42 | SOURCES = ofontmenu.cc \ |
40 | ocolorbutton.cpp \ | 43 | ocolorbutton.cpp \ |
41 | sharp_compat.cpp \ | 44 | sharp_compat.cpp \ |
42 | xmltree.cc \ | 45 | xmltree.cc \ |
43 | ofiledialog.cc ofileselector.cc \ | 46 | ofiledialog.cc ofileselector.cc \ |
44 | ocheckitem.cpp tododb.cpp todoevent.cpp \ | 47 | ocheckitem.cpp tododb.cpp todoevent.cpp \ |
45 | todovcalresource.cpp colordialog.cpp \ | 48 | todovcalresource.cpp colordialog.cpp \ |
46 | colorpopupmenu.cpp oclickablelabel.cpp \ | 49 | colorpopupmenu.cpp oclickablelabel.cpp \ |
47 | oprocctrl.cpp oprocess.cpp \ | 50 | oprocctrl.cpp oprocess.cpp \ |
48 | odevice.cpp otimepicker.cpp \ | 51 | odevice.cpp otimepicker.cpp \ |
49 | otabwidget.cpp otabbar.cpp \ | 52 | otabwidget.cpp otabbar.cpp \ |
50 | ofontselector.cpp \ | 53 | ofontselector.cpp \ |
51 | pim/otodo.cpp \ | 54 | pim/otodo.cpp \ |
52 | pim/opimrecord.cpp \ | 55 | pim/opimrecord.cpp \ |
53 | pim/otodoaccess.cpp \ | 56 | pim/otodoaccess.cpp \ |
54 | pim/otodoaccessbackend.cpp \ | 57 | pim/otodoaccessbackend.cpp \ |
55 | pim/otodoaccessxml.cpp \ | 58 | pim/otodoaccessxml.cpp \ |
56 | pim/ocontact.cpp \ | 59 | pim/ocontact.cpp \ |
57 | pim/ocontactaccess.cpp \ | 60 | pim/ocontactaccess.cpp \ |
58 | pim/ocontactaccessbackend_vcard.cpp \ | 61 | pim/ocontactaccessbackend_vcard.cpp \ |
59 | pim/otodoaccessvcal.cpp \ | 62 | pim/otodoaccessvcal.cpp \ |
60 | pim/orecur.cpp \ | 63 | pim/orecur.cpp \ |
61 | pim/opimstate.cpp \ | 64 | pim/opimstate.cpp \ |
62 | pim/opimxrefpartner.cpp \ | 65 | pim/opimxrefpartner.cpp \ |
63 | pim/opimxref.cpp \ | 66 | pim/opimxref.cpp \ |
64 | pim/opimxrefmanager.cpp \ | 67 | pim/opimxrefmanager.cpp \ |
65 | pim/opimmaintainer.cpp \ | 68 | pim/opimmaintainer.cpp \ |
69 | pim/opimnotify.cpp \ | ||
70 | pim/opimnotifymanager.cpp \ | ||
71 | pim/opimmainwindow.cpp \ | ||
66 | orecurrancewidget.cpp \ | 72 | orecurrancewidget.cpp \ |
67 | oticker.cpp | 73 | oticker.cpp |
68 | # pim/otodoaccesssql.cpp \ | 74 | # pim/otodoaccesssql.cpp \ |
69 | 75 | ||
70 | TARGET = opie | 76 | TARGET = opie |
71 | INCLUDEPATH += $(OPIEDIR)/include | 77 | INCLUDEPATH += $(OPIEDIR)/include |
72 | DESTDIR = $(QTDIR)/lib$(PROJMAK) | 78 | DESTDIR = $(QTDIR)/lib$(PROJMAK) |
73 | #VERSION = 1.0.0 | 79 | #VERSION = 1.0.0 |
74 | 80 | ||
75 | # LIBS += -lopiesql | 81 | # LIBS += -lopiesql |
76 | 82 | ||
77 | INTERFACES = otimepickerbase.ui orecurrancebase.ui | 83 | INTERFACES = otimepickerbase.ui orecurrancebase.ui |
78 | 84 | ||
79 | TRANSLATIONS = ../i18n/de/libopie.ts \ | 85 | TRANSLATIONS = ../i18n/de/libopie.ts \ |
80 | ../i18n/en/libopie.ts \ | 86 | ../i18n/en/libopie.ts \ |
81 | ../i18n/es/libopie.ts \ | 87 | ../i18n/es/libopie.ts \ |
82 | ../i18n/fr/libopie.ts \ | 88 | ../i18n/fr/libopie.ts \ |
83 | ../i18n/hu/libopie.ts \ | 89 | ../i18n/hu/libopie.ts \ |
84 | ../i18n/ja/libopie.ts \ | 90 | ../i18n/ja/libopie.ts \ |
85 | ../i18n/ko/libopie.ts \ | 91 | ../i18n/ko/libopie.ts \ |
86 | ../i18n/no/libopie.ts \ | 92 | ../i18n/no/libopie.ts \ |
87 | ../i18n/pl/libopie.ts \ | 93 | ../i18n/pl/libopie.ts \ |
88 | ../i18n/pt/libopie.ts \ | 94 | ../i18n/pt/libopie.ts \ |
89 | ../i18n/pt_BR/libopie.ts \ | 95 | ../i18n/pt_BR/libopie.ts \ |
90 | ../i18n/sl/libopie.ts \ | 96 | ../i18n/sl/libopie.ts \ |
91 | ../i18n/zh_CN/libopie.ts \ | 97 | ../i18n/zh_CN/libopie.ts \ |
92 | ../i18n/zh_TW/libopie.ts \ | 98 | ../i18n/zh_TW/libopie.ts \ |
93 | ../i18n/da/libopie.ts | 99 | ../i18n/da/libopie.ts |
diff --git a/libopie/orecurrancewidget.cpp b/libopie/orecurrancewidget.cpp index 53cee65..0484ab9 100644 --- a/libopie/orecurrancewidget.cpp +++ b/libopie/orecurrancewidget.cpp | |||
@@ -1,370 +1,382 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qlabel.h> | 2 | #include <qlabel.h> |
3 | #include <qpopupmenu.h> | 3 | #include <qpopupmenu.h> |
4 | #include <qspinbox.h> | 4 | #include <qspinbox.h> |
5 | 5 | ||
6 | #include <qpe/timestring.h> | 6 | #include <qpe/timestring.h> |
7 | 7 | ||
8 | #include "orecurrancewidget.h" | 8 | #include "orecurrancewidget.h" |
9 | 9 | ||
10 | // Global Templates for use in setting up the repeat label... | 10 | // Global Templates for use in setting up the repeat label... |
11 | const QString strDayTemplate = QObject::tr("Every"); | 11 | const QString strDayTemplate = QObject::tr("Every"); |
12 | const QString strYearTemplate = QObject::tr("%1 %2 every "); | 12 | const QString strYearTemplate = QObject::tr("%1 %2 every "); |
13 | const QString strMonthDateTemplate = QObject::tr("The %1 every "); | 13 | const QString strMonthDateTemplate = QObject::tr("The %1 every "); |
14 | const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every"); | 14 | const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every"); |
15 | const QString strWeekTemplate = QObject::tr("Every "); | 15 | const QString strWeekTemplate = QObject::tr("Every "); |
16 | const QString dayLabel[] = { QObject::tr("Monday"), | 16 | const QString dayLabel[] = { QObject::tr("Monday"), |
17 | QObject::tr("Tuesday"), | 17 | QObject::tr("Tuesday"), |
18 | QObject::tr("Wednesday"), | 18 | QObject::tr("Wednesday"), |
19 | QObject::tr("Thursday"), | 19 | QObject::tr("Thursday"), |
20 | QObject::tr("Friday"), | 20 | QObject::tr("Friday"), |
21 | QObject::tr("Saturday"), | 21 | QObject::tr("Saturday"), |
22 | QObject::tr("Sunday") }; | 22 | QObject::tr("Sunday") }; |
23 | 23 | ||
24 | 24 | ||
25 | static QString numberPlacing( int x );// return the proper word format for | 25 | static QString numberPlacing( int x );// return the proper word format for |
26 | // x (1st, 2nd, etc) | 26 | // x (1st, 2nd, etc) |
27 | static int week( const QDate &dt ); // what week in the month is dt? | 27 | static int week( const QDate &dt ); // what week in the month is dt? |
28 | 28 | ||
29 | 29 | ||
30 | ORecurranceWidget::ORecurranceWidget( bool startOnMonday, | 30 | ORecurranceWidget::ORecurranceWidget( bool startOnMonday, |
31 | const QDate& newStart, | 31 | const QDate& newStart, |
32 | QWidget* parent, | 32 | QWidget* parent, |
33 | const char* name, | 33 | const char* name, |
34 | bool modal, | 34 | bool modal, |
35 | WFlags fl ) | 35 | WFlags fl ) |
36 | : ORecurranceBase( parent, name, modal, fl ), | 36 | : ORecurranceBase( parent, name, modal, fl ), |
37 | start( newStart ), | 37 | start( newStart ), |
38 | currInterval( None ), | 38 | currInterval( None ), |
39 | startWeekOnMonday( startOnMonday ) | 39 | startWeekOnMonday( startOnMonday ) |
40 | { | 40 | { |
41 | init(); | 41 | init(); |
42 | fraType->setButton( currInterval ); | 42 | fraType->setButton( currInterval ); |
43 | chkNoEnd->setChecked( TRUE ); | 43 | chkNoEnd->setChecked( TRUE ); |
44 | setupNone(); | 44 | setupNone(); |
45 | } | 45 | } |
46 | ORecurranceWidget::ORecurranceWidget( bool startOnMonday, | 46 | ORecurranceWidget::ORecurranceWidget( bool startOnMonday, |
47 | const ORecur& rp, const QDate& startDate, | 47 | const ORecur& rp, const QDate& startDate, |
48 | QWidget* parent, const char* name, | 48 | QWidget* parent, const char* name, |
49 | bool modal, WFlags fl) | 49 | bool modal, WFlags fl) |
50 | : ORecurranceBase( parent, name, modal, fl ), | 50 | : ORecurranceBase( parent, name, modal, fl ), |
51 | start( startDate ), | 51 | start( startDate ), |
52 | end( rp.endDate() ), | 52 | end( rp.endDate() ), |
53 | startWeekOnMonday( startOnMonday ) | 53 | startWeekOnMonday( startOnMonday ) |
54 | { | 54 | { |
55 | // do some stuff with the repeat pattern | 55 | // do some stuff with the repeat pattern |
56 | init(); | 56 | init(); |
57 | setRecurrence( rp ); | ||
58 | } | ||
59 | |||
60 | ORecurranceWidget::~ORecurranceWidget() { | ||
61 | } | ||
62 | void ORecurranceWidget::setStartDate( const QDate& date ) { | ||
63 | qWarning("ORecurranceWidget::setStartDate"); | ||
64 | setRecurrence( recurrence(), date ); | ||
65 | } | ||
66 | void ORecurranceWidget::setRecurrence( const ORecur& rp ) { | ||
67 | setRecurrence( rp, start ); | ||
68 | } | ||
69 | void ORecurranceWidget::setRecurrence( const ORecur& rp, const QDate& date ) { | ||
70 | start = date; | ||
71 | end = rp.endDate(); | ||
57 | switch ( rp.type() ) { | 72 | switch ( rp.type() ) { |
58 | default: | 73 | default: |
59 | case ORecur::NoRepeat: | 74 | case ORecur::NoRepeat: |
60 | currInterval = None; | 75 | currInterval = None; |
61 | setupNone(); | 76 | setupNone(); |
62 | break; | 77 | break; |
63 | case ORecur::Daily: | 78 | case ORecur::Daily: |
64 | currInterval = Day; | 79 | currInterval = Day; |
65 | setupDaily(); | 80 | setupDaily(); |
66 | break; | 81 | break; |
67 | case ORecur::Weekly: | 82 | case ORecur::Weekly: |
68 | currInterval = Week; | 83 | currInterval = Week; |
69 | setupWeekly(); | 84 | setupWeekly(); |
70 | int day, buttons; | 85 | int day, buttons; |
71 | for ( day = 0x01, buttons = 0; buttons < 7; | 86 | for ( day = 0x01, buttons = 0; buttons < 7; |
72 | day = day << 1, buttons++ ) { | 87 | day = day << 1, buttons++ ) { |
73 | if ( rp.days() & day ) { | 88 | if ( rp.days() & day ) { |
74 | if ( startWeekOnMonday ) | 89 | if ( startWeekOnMonday ) |
75 | fraExtra->setButton( buttons ); | 90 | fraExtra->setButton( buttons ); |
76 | else { | 91 | else { |
77 | if ( buttons == 7 ) | 92 | if ( buttons == 7 ) |
78 | fraExtra->setButton( 0 ); | 93 | fraExtra->setButton( 0 ); |
79 | else | 94 | else |
80 | fraExtra->setButton( buttons + 1 ); | 95 | fraExtra->setButton( buttons + 1 ); |
81 | } | 96 | } |
82 | } | 97 | } |
83 | } | 98 | } |
84 | slotWeekLabel(); | 99 | slotWeekLabel(); |
85 | break; | 100 | break; |
86 | case ORecur::MonthlyDay: | 101 | case ORecur::MonthlyDay: |
87 | currInterval = Month; | 102 | currInterval = Month; |
88 | setupMonthly(); | 103 | setupMonthly(); |
89 | fraExtra->setButton( 0 ); | 104 | fraExtra->setButton( 0 ); |
90 | slotMonthLabel( 0 ); | 105 | slotMonthLabel( 0 ); |
91 | break; | 106 | break; |
92 | case ORecur::MonthlyDate: | 107 | case ORecur::MonthlyDate: |
93 | currInterval = Month; | 108 | currInterval = Month; |
94 | setupMonthly(); | 109 | setupMonthly(); |
95 | fraExtra->setButton( 1 ); | 110 | fraExtra->setButton( 1 ); |
96 | slotMonthLabel( 1 ); | 111 | slotMonthLabel( 1 ); |
97 | break; | 112 | break; |
98 | case ORecur::Yearly: | 113 | case ORecur::Yearly: |
99 | currInterval = Year; | 114 | currInterval = Year; |
100 | setupYearly(); | 115 | setupYearly(); |
101 | break; | 116 | break; |
102 | } | 117 | } |
103 | fraType->setButton( currInterval ); | 118 | fraType->setButton( currInterval ); |
104 | spinFreq->setValue( rp.frequency() ); | 119 | spinFreq->setValue( rp.frequency() ); |
105 | if ( !rp.hasEndDate() ) { | 120 | if ( !rp.hasEndDate() ) { |
106 | cmdEnd->setText( tr("No End Date") ); | 121 | cmdEnd->setText( tr("No End Date") ); |
107 | chkNoEnd->setChecked( TRUE ); | 122 | chkNoEnd->setChecked( TRUE ); |
108 | } else | 123 | } else |
109 | cmdEnd->setText( TimeString::shortDate( end ) ); | 124 | cmdEnd->setText( TimeString::shortDate( end ) ); |
110 | } | 125 | } |
111 | ORecurranceWidget::~ORecurranceWidget() { | 126 | ORecur ORecurranceWidget::recurrence()const { |
112 | |||
113 | } | ||
114 | ORecur ORecurranceWidget::recurrance()const { | ||
115 | QListIterator<QToolButton> it( listRTypeButtons ); | 127 | QListIterator<QToolButton> it( listRTypeButtons ); |
116 | QListIterator<QToolButton> itExtra( listExtra ); | 128 | QListIterator<QToolButton> itExtra( listExtra ); |
117 | ORecur rpTmp; | 129 | ORecur rpTmp; |
118 | int i; | 130 | int i; |
119 | for ( i = 0; *it; ++it, i++ ) { | 131 | for ( i = 0; *it; ++it, i++ ) { |
120 | if ( (*it)->isOn() ) { | 132 | if ( (*it)->isOn() ) { |
121 | switch ( i ) { | 133 | switch ( i ) { |
122 | case None: | 134 | case None: |
123 | rpTmp.setType( ORecur::NoRepeat ); | 135 | rpTmp.setType( ORecur::NoRepeat ); |
124 | break; | 136 | break; |
125 | case Day: | 137 | case Day: |
126 | rpTmp.setType( ORecur::Daily ); | 138 | rpTmp.setType( ORecur::Daily ); |
127 | break; | 139 | break; |
128 | case Week:{ | 140 | case Week:{ |
129 | rpTmp.setType( ORecur::Weekly ); | 141 | rpTmp.setType( ORecur::Weekly ); |
130 | int day; | 142 | int day; |
131 | int day2 = 0; | 143 | int day2 = 0; |
132 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { | 144 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { |
133 | if ( (*itExtra)->isOn() ) { | 145 | if ( (*itExtra)->isOn() ) { |
134 | if ( startWeekOnMonday ) | 146 | if ( startWeekOnMonday ) |
135 | day2 |= day; | 147 | day2 |= day; |
136 | else { | 148 | else { |
137 | if ( day == 1 ) | 149 | if ( day == 1 ) |
138 | day2 |= Event::SUN; | 150 | day2 |= Event::SUN; |
139 | else | 151 | else |
140 | day2 |= day >> 1; | 152 | day2 |= day >> 1; |
141 | } | 153 | } |
142 | } | 154 | } |
143 | } | 155 | } |
144 | rpTmp.setDays( day2 ); | 156 | rpTmp.setDays( day2 ); |
145 | } | 157 | } |
146 | break; | 158 | break; |
147 | case Month: | 159 | case Month: |
148 | if ( cmdExtra1->isOn() ) | 160 | if ( cmdExtra1->isOn() ) |
149 | rpTmp.setType( ORecur::MonthlyDay ); | 161 | rpTmp.setType( ORecur::MonthlyDay ); |
150 | else if ( cmdExtra2->isOn() ) | 162 | else if ( cmdExtra2->isOn() ) |
151 | rpTmp.setType( ORecur::MonthlyDate ); | 163 | rpTmp.setType( ORecur::MonthlyDate ); |
152 | // figure out the montly day... | 164 | // figure out the montly day... |
153 | rpTmp.setPosition( week( start ) ); | 165 | rpTmp.setPosition( week( start ) ); |
154 | break; | 166 | break; |
155 | case Year: | 167 | case Year: |
156 | rpTmp.setType( ORecur::Yearly ); | 168 | rpTmp.setType( ORecur::Yearly ); |
157 | break; | 169 | break; |
158 | } | 170 | } |
159 | break; // no need to keep looking! | 171 | break; // no need to keep looking! |
160 | } | 172 | } |
161 | } | 173 | } |
162 | rpTmp.setFrequency(spinFreq->value() ); | 174 | rpTmp.setFrequency(spinFreq->value() ); |
163 | rpTmp.setHasEndDate( !chkNoEnd->isChecked() ); | 175 | rpTmp.setHasEndDate( !chkNoEnd->isChecked() ); |
164 | if ( rpTmp.hasEndDate() ) { | 176 | if ( rpTmp.hasEndDate() ) { |
165 | rpTmp.setEndDate( end ); | 177 | rpTmp.setEndDate( end ); |
166 | } | 178 | } |
167 | // timestamp it... | 179 | // timestamp it... |
168 | rpTmp.setCreateTime( time( NULL ) ); | 180 | rpTmp.setCreateTime( time( NULL ) ); |
169 | return rpTmp; | 181 | return rpTmp; |
170 | } | 182 | } |
171 | QDate ORecurranceWidget::endDate()const { | 183 | QDate ORecurranceWidget::endDate()const { |
172 | return end; | 184 | return end; |
173 | } | 185 | } |
174 | void ORecurranceWidget::slotSetRType(int rtype) { | 186 | void ORecurranceWidget::slotSetRType(int rtype) { |
175 | // now call the right function based on the type... | 187 | // now call the right function based on the type... |
176 | currInterval = static_cast<repeatButtons>(rtype); | 188 | currInterval = static_cast<repeatButtons>(rtype); |
177 | switch ( currInterval ) { | 189 | switch ( currInterval ) { |
178 | case None: | 190 | case None: |
179 | setupNone(); | 191 | setupNone(); |
180 | break; | 192 | break; |
181 | case Day: | 193 | case Day: |
182 | setupDaily(); | 194 | setupDaily(); |
183 | break; | 195 | break; |
184 | case Week: | 196 | case Week: |
185 | setupWeekly(); | 197 | setupWeekly(); |
186 | slotWeekLabel(); | 198 | slotWeekLabel(); |
187 | break; | 199 | break; |
188 | case Month: | 200 | case Month: |
189 | setupMonthly(); | 201 | setupMonthly(); |
190 | cmdExtra2->setOn( TRUE ); | 202 | cmdExtra2->setOn( TRUE ); |
191 | slotMonthLabel( 1 ); | 203 | slotMonthLabel( 1 ); |
192 | break; | 204 | break; |
193 | case Year: | 205 | case Year: |
194 | setupYearly(); | 206 | setupYearly(); |
195 | break; | 207 | break; |
196 | } | 208 | } |
197 | } | 209 | } |
198 | void ORecurranceWidget::endDateChanged(int y, int m, int d) { | 210 | void ORecurranceWidget::endDateChanged(int y, int m, int d) { |
199 | end.setYMD( y, m, d ); | 211 | end.setYMD( y, m, d ); |
200 | if ( end < start ) | 212 | if ( end < start ) |
201 | end = start; | 213 | end = start; |
202 | cmdEnd->setText( TimeString::shortDate( end ) ); | 214 | cmdEnd->setText( TimeString::shortDate( end ) ); |
203 | repeatPicker->setDate( end.year(), end.month(), end.day() ); | 215 | repeatPicker->setDate( end.year(), end.month(), end.day() ); |
204 | } | 216 | } |
205 | void ORecurranceWidget::slotNoEnd( bool unused) { | 217 | void ORecurranceWidget::slotNoEnd( bool unused) { |
206 | // if the item was toggled, then go ahead and set it to the maximum date | 218 | // if the item was toggled, then go ahead and set it to the maximum date |
207 | if ( unused ) { | 219 | if ( unused ) { |
208 | end.setYMD( 3000, 12, 31 ); | 220 | end.setYMD( 3000, 12, 31 ); |
209 | cmdEnd->setText( tr("No End Date") ); | 221 | cmdEnd->setText( tr("No End Date") ); |
210 | } else { | 222 | } else { |
211 | end = start; | 223 | end = start; |
212 | cmdEnd->setText( TimeString::shortDate(end) ); | 224 | cmdEnd->setText( TimeString::shortDate(end) ); |
213 | } | 225 | } |
214 | } | 226 | } |
215 | void ORecurranceWidget::setupRepeatLabel( const QString& s) { | 227 | void ORecurranceWidget::setupRepeatLabel( const QString& s) { |
216 | lblVar1->setText( s ); | 228 | lblVar1->setText( s ); |
217 | } | 229 | } |
218 | void ORecurranceWidget::setupRepeatLabel( int x) { | 230 | void ORecurranceWidget::setupRepeatLabel( int x) { |
219 | // change the spelling based on the value of x | 231 | // change the spelling based on the value of x |
220 | QString strVar2; | 232 | QString strVar2; |
221 | 233 | ||
222 | if ( x > 1 ) | 234 | if ( x > 1 ) |
223 | lblVar1->show(); | 235 | lblVar1->show(); |
224 | else | 236 | else |
225 | lblVar1->hide(); | 237 | lblVar1->hide(); |
226 | 238 | ||
227 | switch ( currInterval ) { | 239 | switch ( currInterval ) { |
228 | case None: | 240 | case None: |
229 | break; | 241 | break; |
230 | case Day: | 242 | case Day: |
231 | if ( x > 1 ) | 243 | if ( x > 1 ) |
232 | strVar2 = tr( "days" ); | 244 | strVar2 = tr( "days" ); |
233 | else | 245 | else |
234 | strVar2 = tr( "day" ); | 246 | strVar2 = tr( "day" ); |
235 | break; | 247 | break; |
236 | case Week: | 248 | case Week: |
237 | if ( x > 1 ) | 249 | if ( x > 1 ) |
238 | strVar2 = tr( "weeks" ); | 250 | strVar2 = tr( "weeks" ); |
239 | else | 251 | else |
240 | strVar2 = tr( "week" ); | 252 | strVar2 = tr( "week" ); |
241 | break; | 253 | break; |
242 | case Month: | 254 | case Month: |
243 | if ( x > 1 ) | 255 | if ( x > 1 ) |
244 | strVar2 = tr( "months" ); | 256 | strVar2 = tr( "months" ); |
245 | else | 257 | else |
246 | strVar2 = tr( "month" ); | 258 | strVar2 = tr( "month" ); |
247 | break; | 259 | break; |
248 | case Year: | 260 | case Year: |
249 | if ( x > 1 ) | 261 | if ( x > 1 ) |
250 | strVar2 = tr( "years" ); | 262 | strVar2 = tr( "years" ); |
251 | else | 263 | else |
252 | strVar2 = tr( "year" ); | 264 | strVar2 = tr( "year" ); |
253 | break; | 265 | break; |
254 | } | 266 | } |
255 | if ( !strVar2.isNull() ) | 267 | if ( !strVar2.isNull() ) |
256 | lblVar2->setText( strVar2 ); | 268 | lblVar2->setText( strVar2 ); |
257 | } | 269 | } |
258 | void ORecurranceWidget::slotWeekLabel() { | 270 | void ORecurranceWidget::slotWeekLabel() { |
259 | QString str; | 271 | QString str; |
260 | QListIterator<QToolButton> it( listExtra ); | 272 | QListIterator<QToolButton> it( listExtra ); |
261 | unsigned int i; | 273 | unsigned int i; |
262 | unsigned int keepMe; | 274 | unsigned int keepMe; |
263 | bool bNeedCarriage = FALSE; | 275 | bool bNeedCarriage = FALSE; |
264 | // don't do something we'll regret!!! | 276 | // don't do something we'll regret!!! |
265 | if ( currInterval != Week ) | 277 | if ( currInterval != Week ) |
266 | return; | 278 | return; |
267 | 279 | ||
268 | if ( startWeekOnMonday ) | 280 | if ( startWeekOnMonday ) |
269 | keepMe = start.dayOfWeek() - 1; | 281 | keepMe = start.dayOfWeek() - 1; |
270 | else | 282 | else |
271 | keepMe = start.dayOfWeek() % 7; | 283 | keepMe = start.dayOfWeek() % 7; |
272 | 284 | ||
273 | QStringList list; | 285 | QStringList list; |
274 | for ( i = 0; *it; ++it, i++ ) { | 286 | for ( i = 0; *it; ++it, i++ ) { |
275 | // a crazy check, if you are repeating weekly, the current day | 287 | // a crazy check, if you are repeating weekly, the current day |
276 | // must be selected!!! | 288 | // must be selected!!! |
277 | if ( i == keepMe && !( (*it)->isOn() ) ) | 289 | if ( i == keepMe && !( (*it)->isOn() ) ) |
278 | (*it)->setOn( TRUE ); | 290 | (*it)->setOn( TRUE ); |
279 | if ( (*it)->isOn() ) { | 291 | if ( (*it)->isOn() ) { |
280 | if ( startWeekOnMonday ) | 292 | if ( startWeekOnMonday ) |
281 | list.append( dayLabel[i] ); | 293 | list.append( dayLabel[i] ); |
282 | else { | 294 | else { |
283 | if ( i == 0 ) | 295 | if ( i == 0 ) |
284 | list.append( dayLabel[6] ); | 296 | list.append( dayLabel[6] ); |
285 | else | 297 | else |
286 | list.append( dayLabel[i - 1] ); | 298 | list.append( dayLabel[i - 1] ); |
287 | } | 299 | } |
288 | } | 300 | } |
289 | } | 301 | } |
290 | QStringList::Iterator itStr; | 302 | QStringList::Iterator itStr; |
291 | for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { | 303 | for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { |
292 | if ( i == 3 ) | 304 | if ( i == 3 ) |
293 | bNeedCarriage = TRUE; | 305 | bNeedCarriage = TRUE; |
294 | else | 306 | else |
295 | bNeedCarriage = FALSE; | 307 | bNeedCarriage = FALSE; |
296 | if ( str.isNull() ) | 308 | if ( str.isNull() ) |
297 | str = *itStr; | 309 | str = *itStr; |
298 | else if ( i == list.count() - 1 ) { | 310 | else if ( i == list.count() - 1 ) { |
299 | if ( i < 2 ) | 311 | if ( i < 2 ) |
300 | str += tr(" and ") + *itStr; | 312 | str += tr(" and ") + *itStr; |
301 | else { | 313 | else { |
302 | if ( bNeedCarriage ) | 314 | if ( bNeedCarriage ) |
303 | str += tr( ",\nand " ) + *itStr; | 315 | str += tr( ",\nand " ) + *itStr; |
304 | else | 316 | else |
305 | str += tr( ", and " ) + *itStr; | 317 | str += tr( ", and " ) + *itStr; |
306 | } | 318 | } |
307 | } else { | 319 | } else { |
308 | if ( bNeedCarriage ) | 320 | if ( bNeedCarriage ) |
309 | str += ",\n" + *itStr; | 321 | str += ",\n" + *itStr; |
310 | else | 322 | else |
311 | str += ", " + *itStr; | 323 | str += ", " + *itStr; |
312 | } | 324 | } |
313 | } | 325 | } |
314 | str = str.prepend( "on " ); | 326 | str = str.prepend( "on " ); |
315 | lblWeekVar->setText( str ); | 327 | lblWeekVar->setText( str ); |
316 | } | 328 | } |
317 | void ORecurranceWidget::slotMonthLabel(int type) { | 329 | void ORecurranceWidget::slotMonthLabel(int type) { |
318 | QString str; | 330 | QString str; |
319 | if ( currInterval != Month || type > 1 ) | 331 | if ( currInterval != Month || type > 1 ) |
320 | return; | 332 | return; |
321 | if ( type == 1 ) | 333 | if ( type == 1 ) |
322 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); | 334 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); |
323 | else | 335 | else |
324 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) | 336 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) |
325 | .arg( dayLabel[start.dayOfWeek() - 1] ); | 337 | .arg( dayLabel[start.dayOfWeek() - 1] ); |
326 | lblRepeat->setText( str ); | 338 | lblRepeat->setText( str ); |
327 | } | 339 | } |
328 | void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) { | 340 | void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) { |
329 | startWeekOnMonday = onMonday; | 341 | startWeekOnMonday = onMonday; |
330 | // we need to make this unintrusive as possible... | 342 | // we need to make this unintrusive as possible... |
331 | int saveSpin = spinFreq->value(); | 343 | int saveSpin = spinFreq->value(); |
332 | char days = 0; | 344 | char days = 0; |
333 | int day; | 345 | int day; |
334 | QListIterator<QToolButton> itExtra( listExtra ); | 346 | QListIterator<QToolButton> itExtra( listExtra ); |
335 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { | 347 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { |
336 | if ( (*itExtra)->isOn() ) { | 348 | if ( (*itExtra)->isOn() ) { |
337 | if ( !startWeekOnMonday ) | 349 | if ( !startWeekOnMonday ) |
338 | days |= day; | 350 | days |= day; |
339 | else { | 351 | else { |
340 | if ( day == 1 ) | 352 | if ( day == 1 ) |
341 | days |= ORecur::SUN; | 353 | days |= ORecur::SUN; |
342 | else | 354 | else |
343 | days |= day >> 1; | 355 | days |= day >> 1; |
344 | } | 356 | } |
345 | } | 357 | } |
346 | } | 358 | } |
347 | setupWeekly(); | 359 | setupWeekly(); |
348 | spinFreq->setValue( saveSpin ); | 360 | spinFreq->setValue( saveSpin ); |
349 | int buttons; | 361 | int buttons; |
350 | for ( day = 0x01, buttons = 0; buttons < 7; | 362 | for ( day = 0x01, buttons = 0; buttons < 7; |
351 | day = day << 1, buttons++ ) { | 363 | day = day << 1, buttons++ ) { |
352 | if ( days & day ) { | 364 | if ( days & day ) { |
353 | if ( startWeekOnMonday ) | 365 | if ( startWeekOnMonday ) |
354 | fraExtra->setButton( buttons ); | 366 | fraExtra->setButton( buttons ); |
355 | else { | 367 | else { |
356 | if ( buttons == 7 ) | 368 | if ( buttons == 7 ) |
357 | fraExtra->setButton( 0 ); | 369 | fraExtra->setButton( 0 ); |
358 | else | 370 | else |
359 | fraExtra->setButton( buttons + 1 ); | 371 | fraExtra->setButton( buttons + 1 ); |
360 | } | 372 | } |
361 | } | 373 | } |
362 | } | 374 | } |
363 | slotWeekLabel(); | 375 | slotWeekLabel(); |
364 | } | 376 | } |
365 | void ORecurranceWidget::setupNone() { | 377 | void ORecurranceWidget::setupNone() { |
366 | lblRepeat->setText( tr("No Repeat") ); | 378 | lblRepeat->setText( tr("No Repeat") ); |
367 | lblVar1->hide(); | 379 | lblVar1->hide(); |
368 | lblVar2->hide(); | 380 | lblVar2->hide(); |
369 | hideExtras(); | 381 | hideExtras(); |
370 | cmdEnd->hide(); | 382 | cmdEnd->hide(); |
diff --git a/libopie/orecurrancewidget.h b/libopie/orecurrancewidget.h index f2d7f87..4a8dd08 100644 --- a/libopie/orecurrancewidget.h +++ b/libopie/orecurrancewidget.h | |||
@@ -1,68 +1,72 @@ | |||
1 | /* | 1 | /* |
2 | * GPL and based on the widget from TT | 2 | * GPL and based on the widget from TT |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef OPIE_RECURRANCE_WIDGET_H | 5 | #ifndef OPIE_RECURRANCE_WIDGET_H |
6 | #define OPIE_RECURRANCE_WIDGET_H | 6 | #define OPIE_RECURRANCE_WIDGET_H |
7 | 7 | ||
8 | #include <qlist.h> | 8 | #include <qlist.h> |
9 | #include <qtoolbutton.h> | 9 | #include <qtoolbutton.h> |
10 | #include <qcheckbox.h> | 10 | #include <qcheckbox.h> |
11 | #include <qdatetime.h> | 11 | #include <qdatetime.h> |
12 | #include <qbuttongroup.h> | 12 | #include <qbuttongroup.h> |
13 | 13 | ||
14 | #include <qpe/datebookmonth.h> | 14 | #include <qpe/datebookmonth.h> |
15 | 15 | ||
16 | #include "orecurrancebase.h" | 16 | #include "orecurrancebase.h" |
17 | #include <opie/orecur.h> | 17 | #include <opie/orecur.h> |
18 | 18 | ||
19 | // FIXME spelling!!!! -zecke | ||
19 | class ORecurranceWidget : public ORecurranceBase { | 20 | class ORecurranceWidget : public ORecurranceBase { |
20 | Q_OBJECT | 21 | Q_OBJECT |
21 | public: | 22 | public: |
22 | ORecurranceWidget( bool startOnMonday, | 23 | ORecurranceWidget( bool startOnMonday, |
23 | const QDate& start, QWidget* parent = 0, | 24 | const QDate& start, QWidget* parent = 0, |
24 | const char* name = 0, bool modal = TRUE, | 25 | const char* name = 0, bool modal = TRUE, |
25 | WFlags fl = 0 ); | 26 | WFlags fl = 0 ); |
26 | ORecurranceWidget( bool startOnMonday, | 27 | ORecurranceWidget( bool startOnMonday, |
27 | const ORecur& rp, const QDate& start, | 28 | const ORecur& rp, const QDate& start, |
28 | QWidget* parent = 0, const char* name =0, | 29 | QWidget* parent = 0, const char* name =0, |
29 | bool modal = TRUE, WFlags = 0 ); | 30 | bool modal = TRUE, WFlags = 0 ); |
30 | ~ORecurranceWidget(); | 31 | ~ORecurranceWidget(); |
31 | ORecur recurrance()const; | 32 | ORecur recurrence()const; |
32 | QDate endDate()const; | 33 | QDate endDate()const; |
33 | 34 | ||
34 | public slots: | 35 | public slots: |
35 | void slotSetRType( int ); | 36 | void slotSetRType( int ); |
36 | void endDateChanged( int, int, int ); | 37 | void endDateChanged( int, int, int ); |
37 | void slotNoEnd( bool unused ); | 38 | void slotNoEnd( bool unused ); |
39 | void setStartDate( const QDate& ); | ||
40 | void setRecurrence( const ORecur& recur, const QDate& start ); | ||
41 | void setRecurrence( const ORecur& recur ); | ||
38 | 42 | ||
39 | private slots: | 43 | private slots: |
40 | void setupRepeatLabel( const QString& ); | 44 | void setupRepeatLabel( const QString& ); |
41 | void setupRepeatLabel( int ); | 45 | void setupRepeatLabel( int ); |
42 | void slotWeekLabel(); | 46 | void slotWeekLabel(); |
43 | void slotMonthLabel( int ); | 47 | void slotMonthLabel( int ); |
44 | void slotChangeStartOfWeek( bool onMonday ); | 48 | void slotChangeStartOfWeek( bool onMonday ); |
45 | 49 | ||
46 | private: | 50 | private: |
47 | void setupNone(); | 51 | void setupNone(); |
48 | void setupDaily(); | 52 | void setupDaily(); |
49 | void setupWeekly(); | 53 | void setupWeekly(); |
50 | void setupMonthly(); | 54 | void setupMonthly(); |
51 | void setupYearly(); | 55 | void setupYearly(); |
52 | 56 | ||
53 | enum repeatButtons { None, Day, Week, Month, Year }; | 57 | enum repeatButtons { None, Day, Week, Month, Year }; |
54 | void init(); | 58 | void init(); |
55 | void hideExtras(); | 59 | void hideExtras(); |
56 | void showRepeatStuff(); | 60 | void showRepeatStuff(); |
57 | 61 | ||
58 | QList<QToolButton> listRTypeButtons; | 62 | QList<QToolButton> listRTypeButtons; |
59 | QList<QToolButton> listExtra; | 63 | QList<QToolButton> listExtra; |
60 | QDate start; // only used in one spot... | 64 | QDate start; // only used in one spot... |
61 | QDate end; | 65 | QDate end; |
62 | repeatButtons currInterval; | 66 | repeatButtons currInterval; |
63 | bool startWeekOnMonday : 1; | 67 | bool startWeekOnMonday : 1; |
64 | DateBookMonth *repeatPicker; | 68 | DateBookMonth *repeatPicker; |
65 | 69 | ||
66 | }; | 70 | }; |
67 | 71 | ||
68 | #endif | 72 | #endif |