27 files changed, 795 insertions, 371 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index cc7bf4b..68ab07a 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -1,356 +1,372 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ** $Id$ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ** | 20 | ..}^=.= = ; Library General Public License for more |
21 | **********************************************************************/ | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
22 | 30 | ||
23 | #define QTOPIA_INTERNAL_FD | 31 | #define QTOPIA_INTERNAL_FD |
24 | 32 | ||
25 | #include "datebook.h" | 33 | #include "datebook.h" |
26 | #include "datebookday.h" | 34 | #include "datebookday.h" |
27 | #include "datebooksettings.h" | 35 | #include "datebooksettings.h" |
28 | #include "datebookweek.h" | 36 | #include "datebookweek.h" |
29 | #include "modules/weeklst/datebookweeklst.h" | 37 | #include "modules/weeklst/datebookweeklst.h" |
30 | #include "modules/monthview/odatebookmonth.h" | 38 | #include "modules/monthview/odatebookmonth.h" |
31 | #include "dateentryimpl.h" | 39 | #include "dateentryimpl.h" |
32 | 40 | ||
33 | #include <opie2/odebug.h> | 41 | #include <opie2/odebug.h> |
34 | #include <opie2/oholidaypluginif.h> | 42 | #include <opie2/oholidaypluginif.h> |
35 | #include <opie2/oholidayplugin.h> | 43 | #include <opie2/oholidayplugin.h> |
36 | #include <opie2/opluginloader.h> | 44 | #include <opie2/opluginloader.h> |
45 | #include <opie2/oresource.h> | ||
37 | #include <opie2/todayplugininterface.h> | 46 | #include <opie2/todayplugininterface.h> |
38 | 47 | ||
39 | //#include <qpe/datebookmonth.h> | 48 | //#include <qpe/datebookmonth.h> |
40 | #include <qpe/qpeapplication.h> | 49 | #include <qpe/qpeapplication.h> |
41 | #include <qpe/config.h> | 50 | #include <qpe/config.h> |
42 | #include <qpe/finddialog.h> | 51 | #include <qpe/finddialog.h> |
43 | #include <qpe/ir.h> | 52 | #include <qpe/ir.h> |
44 | #include <qpe/qpemessagebox.h> | 53 | #include <qpe/qpemessagebox.h> |
45 | #include <qpe/resource.h> | ||
46 | #include <qpe/sound.h> | 54 | #include <qpe/sound.h> |
47 | #include <qpe/tzselect.h> | 55 | #include <qpe/tzselect.h> |
48 | #include <qtopia/qlibrary.h> | 56 | #include <qtopia/qlibrary.h> |
49 | 57 | ||
50 | #include <qaction.h> | 58 | #include <qaction.h> |
51 | #include <qcopchannel_qws.h> | 59 | #include <qcopchannel_qws.h> |
52 | #include <qlayout.h> | 60 | #include <qlayout.h> |
53 | #include <qmessagebox.h> | 61 | #include <qmessagebox.h> |
54 | #include <qtimer.h> | 62 | #include <qtimer.h> |
55 | #include <qtl.h> | 63 | #include <qtl.h> |
56 | #include <qtoolbar.h> | 64 | #include <qtoolbar.h> |
57 | #include <qwidgetstack.h> | 65 | #include <qwidgetstack.h> |
58 | #include <qdir.h> | 66 | #include <qdir.h> |
59 | #include <qlabel.h> | 67 | #include <qlabel.h> |
60 | 68 | ||
61 | #include <sys/stat.h> | 69 | #include <sys/stat.h> |
62 | #include <sys/types.h> | 70 | #include <sys/types.h> |
63 | #include <fcntl.h> | 71 | #include <fcntl.h> |
64 | #include <unistd.h> | 72 | #include <unistd.h> |
65 | 73 | ||
66 | #include <stdlib.h> | 74 | #include <stdlib.h> |
67 | 75 | ||
68 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | 76 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) |
69 | : QMainWindow( parent, "datebook", f ), | 77 | : QMainWindow( parent, "datebook", f ), |
70 | aPreset( FALSE ), | 78 | aPreset( FALSE ), |
71 | presetTime( -1 ), | 79 | presetTime( -1 ), |
72 | startTime( 8 ), // an acceptable default | 80 | startTime( 8 ), // an acceptable default |
73 | rowStyle( 0 ), | 81 | rowStyle( 0 ), |
74 | bJumpToCurTime(FALSE), | 82 | bJumpToCurTime(FALSE), |
75 | syncing(FALSE), | 83 | syncing(FALSE), |
76 | inSearch(FALSE), | 84 | inSearch(FALSE), |
77 | alarmCounter(0) | 85 | alarmCounter(0) |
78 | { | 86 | { |
79 | bool needEvilHack= false; // if we need an Evil Hack | 87 | bool needEvilHack= false; // if we need an Evil Hack |
80 | QTime t; | 88 | QTime t; |
81 | t.start(); | 89 | t.start(); |
82 | db = new DateBookDBHoliday; | 90 | db = new DateBookDBHoliday; |
83 | odebug << "loading db t=" << t.elapsed() << oendl; | 91 | odebug << "loading db t=" << t.elapsed() << oendl; |
84 | db_holiday = new DateBookHoliday(); | 92 | db_holiday = new DateBookHoliday(); |
85 | db->db_holiday=db_holiday; | 93 | db->db_holiday=db_holiday; |
86 | 94 | ||
87 | loadSettings(); | 95 | loadSettings(); |
88 | setCaption( tr("Calendar") ); | 96 | setCaption( tr("Calendar") ); |
89 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | 97 | setIcon( Opie::Core::OResource::loadPixmap( "datebook_icon" ) ); |
90 | 98 | ||
91 | setToolBarsMovable( FALSE ); | 99 | setToolBarsMovable( FALSE ); |
92 | 100 | ||
93 | views = new QWidgetStack( this ); | 101 | views = new QWidgetStack( this ); |
94 | setCentralWidget( views ); | 102 | setCentralWidget( views ); |
95 | 103 | ||
96 | dayView = 0; | 104 | dayView = 0; |
97 | weekView = 0; | 105 | weekView = 0; |
98 | weekLstView = 0; | 106 | weekLstView = 0; |
99 | monthView = 0; | 107 | monthView = 0; |
100 | 108 | ||
101 | // QToolBar *bar = new QToolBar( this ); | 109 | // QToolBar *bar = new QToolBar( this ); |
102 | // bar->setHorizontalStretchable( TRUE ); | 110 | // bar->setHorizontalStretchable( TRUE ); |
103 | 111 | ||
104 | // QMenuBar *mb = new QMenuBar( bar ); | 112 | // QMenuBar *mb = new QMenuBar( bar ); |
105 | // mb->setMargin( 0 ); | 113 | // mb->setMargin( 0 ); |
106 | 114 | ||
107 | // QPopupMenu *view = new QPopupMenu( this ); | 115 | // QPopupMenu *view = new QPopupMenu( this ); |
108 | // mb->insertItem( tr( "View" ), view ); | 116 | // mb->insertItem( tr( "View" ), view ); |
109 | 117 | ||
110 | QToolBar *sub_bar = new QToolBar(this); | 118 | QToolBar *sub_bar = new QToolBar(this); |
111 | sub_bar->setHorizontalStretchable(TRUE); | 119 | sub_bar->setHorizontalStretchable(TRUE); |
112 | 120 | ||
113 | QActionGroup *g = new QActionGroup( this ); | 121 | QActionGroup *g = new QActionGroup( this ); |
114 | g->setExclusive( TRUE ); | 122 | g->setExclusive( TRUE ); |
115 | 123 | ||
116 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 124 | QAction *a = new QAction( tr( "New" ), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ), |
125 | QString::null, 0, this, 0 ); | ||
117 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 126 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
118 | a->addTo( sub_bar ); | 127 | a->addTo( sub_bar ); |
119 | 128 | ||
120 | sub_bar->addSeparator(); | 129 | sub_bar->addSeparator(); |
121 | 130 | ||
122 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); | 131 | a = new QAction( tr( "Today" ), Opie::Core::OResource::loadPixmap( "datebook/to_day", Opie::Core::OResource::SmallIcon ), |
132 | QString::null, 0, g, 0 ); | ||
123 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | 133 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); |
124 | a->addTo( sub_bar ); | 134 | a->addTo( sub_bar ); |
125 | // a->addTo( view ); | 135 | // a->addTo( view ); |
126 | 136 | ||
127 | sub_bar->addSeparator(); | 137 | sub_bar->addSeparator(); |
128 | 138 | ||
129 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); | 139 | a = new QAction( tr( "Day" ), Opie::Core::OResource::loadPixmap( "day", Opie::Core::OResource::SmallIcon ), |
140 | QString::null, 0, g, 0 ); | ||
130 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); | 141 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); |
131 | a->addTo( sub_bar ); | 142 | a->addTo( sub_bar ); |
132 | // a->addTo( view ); | 143 | // a->addTo( view ); |
133 | a->setToggleAction( TRUE ); | 144 | a->setToggleAction( TRUE ); |
134 | a->setOn( TRUE ); | 145 | a->setOn( TRUE ); |
135 | dayAction = a; | 146 | dayAction = a; |
136 | 147 | ||
137 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); | 148 | a = new QAction( tr( "Week" ), Opie::Core::OResource::loadPixmap( "week", Opie::Core::OResource::SmallIcon ), |
149 | QString::null, 0, g, 0 ); | ||
138 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); | 150 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); |
139 | a->addTo( sub_bar ); | 151 | a->addTo( sub_bar ); |
140 | // a->addTo( view ); | 152 | // a->addTo( view ); |
141 | a->setToggleAction( TRUE ); | 153 | a->setToggleAction( TRUE ); |
142 | weekAction = a; | 154 | weekAction = a; |
143 | 155 | ||
144 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); | 156 | a = new QAction( tr( "WeekLst" ), Opie::Core::OResource::loadPixmap( "datebook/weeklst", Opie::Core::OResource::SmallIcon ), |
157 | QString::null, 0, g, 0 ); | ||
145 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); | 158 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); |
146 | a->addTo( sub_bar ); | 159 | a->addTo( sub_bar ); |
147 | // a->addTo( view ); | 160 | // a->addTo( view ); |
148 | a->setToggleAction( TRUE ); | 161 | a->setToggleAction( TRUE ); |
149 | weekLstAction = a; | 162 | weekLstAction = a; |
150 | 163 | ||
151 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); | 164 | a = new QAction( tr( "Month" ), Opie::Core::OResource::loadPixmap( "month", Opie::Core::OResource::SmallIcon ), |
165 | QString::null, 0, g, 0 ); | ||
152 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); | 166 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); |
153 | a->addTo( sub_bar ); | 167 | a->addTo( sub_bar ); |
154 | // a->addTo( view ); | 168 | // a->addTo( view ); |
155 | a->setToggleAction( TRUE ); | 169 | a->setToggleAction( TRUE ); |
156 | monthAction = a; | 170 | monthAction = a; |
157 | 171 | ||
158 | sub_bar->addSeparator(); | 172 | sub_bar->addSeparator(); |
159 | 173 | ||
160 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | 174 | a = new QAction( tr( "Find" ), Opie::Core::OResource::loadPixmap( "mag", Opie::Core::OResource::SmallIcon ), |
175 | QString::null, 0, this, 0 ); | ||
161 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 176 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
162 | a->addTo( sub_bar ); | 177 | a->addTo( sub_bar ); |
163 | 178 | ||
164 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); | 179 | a = new QAction( tr( "Edit..." ), Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ), |
180 | QString::null, 0, this, 0 ); | ||
165 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 181 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
166 | a->addTo( sub_bar ); | 182 | a->addTo( sub_bar ); |
167 | 183 | ||
168 | if(defaultView==DAY) viewDay(); | 184 | if(defaultView==DAY) viewDay(); |
169 | if(defaultView==WEEK) needEvilHack=true; // viewWeek(); | 185 | if(defaultView==WEEK) needEvilHack=true; // viewWeek(); |
170 | if(defaultView==WEEKLST) viewWeekLst(); | 186 | if(defaultView==WEEKLST) viewWeekLst(); |
171 | if(defaultView==MONTH) viewMonth(); | 187 | if(defaultView==MONTH) viewMonth(); |
172 | 188 | ||
173 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); | 189 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); |
174 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); | 190 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); |
175 | 191 | ||
176 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 192 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
177 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); | 193 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); |
178 | #endif | 194 | #endif |
179 | 195 | ||
180 | // listen on QPE/System | 196 | // listen on QPE/System |
181 | #if defined(Q_WS_QWS) | 197 | #if defined(Q_WS_QWS) |
182 | #if !defined(QT_NO_COP) | 198 | #if !defined(QT_NO_COP) |
183 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 199 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
184 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); | 200 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); |
185 | channel = new QCopChannel( "QPE/Datebook", this ); | 201 | channel = new QCopChannel( "QPE/Datebook", this ); |
186 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); | 202 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); |
187 | #endif | 203 | #endif |
188 | #endif | 204 | #endif |
189 | 205 | ||
190 | odebug << "done t=" << t.elapsed() << oendl; | 206 | odebug << "done t=" << t.elapsed() << oendl; |
191 | 207 | ||
192 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); | 208 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); |
193 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); | 209 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); |
194 | /* | 210 | /* |
195 | * Here is a problem description: | 211 | * Here is a problem description: |
196 | * When Weekview is the default view | 212 | * When Weekview is the default view |
197 | * a DateBookWeekView get's created | 213 | * a DateBookWeekView get's created |
198 | * redraw() get's called. So what? | 214 | * redraw() get's called. So what? |
199 | * Remember that we're still in the c'tor | 215 | * Remember that we're still in the c'tor |
200 | * and no final layout has happened? Ok | 216 | * and no final layout has happened? Ok |
201 | * now all Events get arranged. Their x | 217 | * now all Events get arranged. Their x |
202 | * position get's determined by a QHeader | 218 | * position get's determined by a QHeader |
203 | * position. But the QHeader isn't layouted or | 219 | * position. But the QHeader isn't layouted or |
204 | * at the right position. redraw() is a slot | 220 | * at the right position. redraw() is a slot |
205 | * so we'll call it then via a singleShot | 221 | * so we'll call it then via a singleShot |
206 | * from view() | 222 | * from view() |
207 | */ | 223 | */ |
208 | if( needEvilHack ){ | 224 | if( needEvilHack ){ |
209 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); | 225 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); |
210 | } | 226 | } |
211 | } | 227 | } |
212 | 228 | ||
213 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 229 | void DateBook::receive( const QCString &msg, const QByteArray &data ) |
214 | { | 230 | { |
215 | QDataStream stream( data, IO_ReadOnly ); | 231 | QDataStream stream( data, IO_ReadOnly ); |
216 | if ( msg == "timeChange(QString)" ) { | 232 | if ( msg == "timeChange(QString)" ) { |
217 | // update active view! | 233 | // update active view! |
218 | if ( dayAction->isOn() ) | 234 | if ( dayAction->isOn() ) |
219 | viewDay(); | 235 | viewDay(); |
220 | else if ( weekAction->isOn() ) | 236 | else if ( weekAction->isOn() ) |
221 | viewWeek(); | 237 | viewWeek(); |
222 | else if ( monthAction->isOn() ) | 238 | else if ( monthAction->isOn() ) |
223 | viewMonth(); | 239 | viewMonth(); |
224 | } | 240 | } |
225 | else if (msg == "editEvent(int)") { | 241 | else if (msg == "editEvent(int)") { |
226 | int uid; | 242 | int uid; |
227 | stream >> uid; | 243 | stream >> uid; |
228 | Event e=db->eventByUID(uid); | 244 | Event e=db->eventByUID(uid); |
229 | editEvent(e); | 245 | editEvent(e); |
230 | }else if (msg == "viewDefault(QDate)"){ | 246 | }else if (msg == "viewDefault(QDate)"){ |
231 | QDate day; | 247 | QDate day; |
232 | stream >> day; | 248 | stream >> day; |
233 | viewDefault(day); | 249 | viewDefault(day); |
234 | } | 250 | } |
235 | } | 251 | } |
236 | 252 | ||
237 | DateBook::~DateBook() | 253 | DateBook::~DateBook() |
238 | { | 254 | { |
239 | delete db_holiday; | 255 | delete db_holiday; |
240 | } | 256 | } |
241 | 257 | ||
242 | void DateBook::slotSettings() | 258 | void DateBook::slotSettings() |
243 | { | 259 | { |
244 | DateBookSettings frmSettings( ampm, this ); | 260 | DateBookSettings frmSettings( ampm, this ); |
245 | frmSettings.setStartTime( startTime ); | 261 | frmSettings.setStartTime( startTime ); |
246 | frmSettings.setAlarmPreset( aPreset, presetTime ); | 262 | frmSettings.setAlarmPreset( aPreset, presetTime ); |
247 | frmSettings.setJumpToCurTime( bJumpToCurTime ); | 263 | frmSettings.setJumpToCurTime( bJumpToCurTime ); |
248 | frmSettings.setRowStyle( rowStyle ); | 264 | frmSettings.setRowStyle( rowStyle ); |
249 | frmSettings.comboDefaultView->setCurrentItem(defaultView-1); | 265 | frmSettings.comboDefaultView->setCurrentItem(defaultView-1); |
250 | frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); | 266 | frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); |
251 | frmSettings.setPluginList(db_holiday->pluginManager(),db_holiday->pluginLoader()); | 267 | frmSettings.setPluginList(db_holiday->pluginManager(),db_holiday->pluginLoader()); |
252 | 268 | ||
253 | bool found=false; | 269 | bool found=false; |
254 | for (int i=0; i<(frmSettings.comboLocation->count()); i++) { | 270 | for (int i=0; i<(frmSettings.comboLocation->count()); i++) { |
255 | if ( frmSettings.comboLocation->text(i) == defaultLocation ) { | 271 | if ( frmSettings.comboLocation->text(i) == defaultLocation ) { |
256 | frmSettings.comboLocation->setCurrentItem(i); | 272 | frmSettings.comboLocation->setCurrentItem(i); |
257 | found=true; | 273 | found=true; |
258 | break; | 274 | break; |
259 | } | 275 | } |
260 | } | 276 | } |
261 | if(!found) { | 277 | if(!found) { |
262 | frmSettings.comboLocation->insertItem(defaultLocation); | 278 | frmSettings.comboLocation->insertItem(defaultLocation); |
263 | frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); | 279 | frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); |
264 | } | 280 | } |
265 | frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); | 281 | frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); |
266 | 282 | ||
267 | if ( QPEApplication::execDialog( &frmSettings ) ) { | 283 | if ( QPEApplication::execDialog( &frmSettings ) ) { |
268 | frmSettings.savePlugins(); | 284 | frmSettings.savePlugins(); |
269 | db_holiday->pluginManager()->save(); | 285 | db_holiday->pluginManager()->save(); |
270 | db_holiday->reloadPlugins(); | 286 | db_holiday->reloadPlugins(); |
271 | 287 | ||
272 | aPreset = frmSettings.alarmPreset(); | 288 | aPreset = frmSettings.alarmPreset(); |
273 | presetTime = frmSettings.presetTime(); | 289 | presetTime = frmSettings.presetTime(); |
274 | startTime = frmSettings.startTime(); | 290 | startTime = frmSettings.startTime(); |
275 | bJumpToCurTime = frmSettings.jumpToCurTime(); | 291 | bJumpToCurTime = frmSettings.jumpToCurTime(); |
276 | rowStyle = frmSettings.rowStyle(); | 292 | rowStyle = frmSettings.rowStyle(); |
277 | defaultView=frmSettings.comboDefaultView->currentItem()+1; | 293 | defaultView=frmSettings.comboDefaultView->currentItem()+1; |
278 | weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); | 294 | weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); |
279 | defaultLocation=frmSettings.comboLocation->currentText(); | 295 | defaultLocation=frmSettings.comboLocation->currentText(); |
280 | defaultCategories=frmSettings.comboCategory->currentCategories(); | 296 | defaultCategories=frmSettings.comboCategory->currentCategories(); |
281 | 297 | ||
282 | if ( dayView ) { | 298 | if ( dayView ) { |
283 | dayView->setStartViewTime( startTime ); | 299 | dayView->setStartViewTime( startTime ); |
284 | dayView->setJumpToCurTime( bJumpToCurTime ); | 300 | dayView->setJumpToCurTime( bJumpToCurTime ); |
285 | dayView->setRowStyle( rowStyle ); | 301 | dayView->setRowStyle( rowStyle ); |
286 | } | 302 | } |
287 | if ( weekView ) { | 303 | if ( weekView ) { |
288 | weekView->setStartViewTime( startTime ); | 304 | weekView->setStartViewTime( startTime ); |
289 | } | 305 | } |
290 | saveSettings(); | 306 | saveSettings(); |
291 | 307 | ||
292 | // make the change obvious | 308 | // make the change obvious |
293 | if ( views->visibleWidget() ) { | 309 | if ( views->visibleWidget() ) { |
294 | if ( views->visibleWidget() == dayView ) | 310 | if ( views->visibleWidget() == dayView ) |
295 | dayView->redraw(); | 311 | dayView->redraw(); |
296 | else if ( views->visibleWidget() == weekView ) | 312 | else if ( views->visibleWidget() == weekView ) |
297 | weekView->redraw(); | 313 | weekView->redraw(); |
298 | else if ( views->visibleWidget() == weekLstView ) | 314 | else if ( views->visibleWidget() == weekLstView ) |
299 | weekLstView->redraw(); | 315 | weekLstView->redraw(); |
300 | } | 316 | } |
301 | } | 317 | } |
302 | } | 318 | } |
303 | 319 | ||
304 | void DateBook::fileNew() | 320 | void DateBook::fileNew() |
305 | { | 321 | { |
306 | slotNewEventFromKey(""); | 322 | slotNewEventFromKey(""); |
307 | } | 323 | } |
308 | 324 | ||
309 | QString DateBook::checkEvent(const Event &e) | 325 | QString DateBook::checkEvent(const Event &e) |
310 | { | 326 | { |
311 | /* check if overlaps with itself */ | 327 | /* check if overlaps with itself */ |
312 | bool checkFailed = FALSE; | 328 | bool checkFailed = FALSE; |
313 | 329 | ||
314 | /* check the next 12 repeats. should catch most problems */ | 330 | /* check the next 12 repeats. should catch most problems */ |
315 | QDate current_date = e.start().date(); | 331 | QDate current_date = e.start().date(); |
316 | Event previous = e; | 332 | Event previous = e; |
317 | for(int i = 0; i < 12; i++) | 333 | for(int i = 0; i < 12; i++) |
318 | { | 334 | { |
319 | QDateTime next; | 335 | QDateTime next; |
320 | if (!nextOccurance(previous, current_date.addDays(1), next)) { | 336 | if (!nextOccurance(previous, current_date.addDays(1), next)) { |
321 | break; // no more repeats | 337 | break; // no more repeats |
322 | } | 338 | } |
323 | if(next < previous.end()) { | 339 | if(next < previous.end()) { |
324 | checkFailed = TRUE; | 340 | checkFailed = TRUE; |
325 | break; | 341 | break; |
326 | } | 342 | } |
327 | current_date = next.date(); | 343 | current_date = next.date(); |
328 | } | 344 | } |
329 | 345 | ||
330 | if(checkFailed) | 346 | if(checkFailed) |
331 | return tr("Event duration is potentially longer\n" | 347 | return tr("Event duration is potentially longer\n" |
332 | "than interval between repeats."); | 348 | "than interval between repeats."); |
333 | 349 | ||
334 | return QString::null; | 350 | return QString::null; |
335 | } | 351 | } |
336 | 352 | ||
337 | QDate DateBook::currentDate() | 353 | QDate DateBook::currentDate() |
338 | { | 354 | { |
339 | QDate d = QDate::currentDate(); | 355 | QDate d = QDate::currentDate(); |
340 | 356 | ||
341 | if ( dayView && views->visibleWidget() == dayView ) { | 357 | if ( dayView && views->visibleWidget() == dayView ) { |
342 | d = dayView->date(); | 358 | d = dayView->date(); |
343 | } else if ( weekView && views->visibleWidget() == weekView ) { | 359 | } else if ( weekView && views->visibleWidget() == weekView ) { |
344 | d = weekView->date(); | 360 | d = weekView->date(); |
345 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { | 361 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { |
346 | d = weekLstView->date(); | 362 | d = weekLstView->date(); |
347 | } else if ( monthView && views->visibleWidget() == monthView ) { | 363 | } else if ( monthView && views->visibleWidget() == monthView ) { |
348 | d = monthView->selectedDate(); | 364 | d = monthView->selectedDate(); |
349 | } | 365 | } |
350 | 366 | ||
351 | return d; | 367 | return d; |
352 | } | 368 | } |
353 | 369 | ||
354 | void DateBook::view(int v, const QDate &d) { | 370 | void DateBook::view(int v, const QDate &d) { |
355 | if (v==DAY) { | 371 | if (v==DAY) { |
356 | initDay(); | 372 | initDay(); |
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index 05ab781..c12f5c4 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h | |||
@@ -1,134 +1,145 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
20 | #ifndef DATEBOOK_H | 31 | #ifndef DATEBOOK_H |
21 | #define DATEBOOK_H | 32 | #define DATEBOOK_H |
22 | 33 | ||
23 | #include "datebooktypes.h" | 34 | #include "datebooktypes.h" |
24 | 35 | ||
25 | #include <qpe/datebookdb.h> | 36 | #include <qpe/datebookdb.h> |
26 | 37 | ||
27 | #include <qmainwindow.h> | 38 | #include <qmainwindow.h> |
28 | 39 | ||
29 | class QAction; | 40 | class QAction; |
30 | class QWidgetStack; | 41 | class QWidgetStack; |
31 | class DateBookDay; | 42 | class DateBookDay; |
32 | class DateBookWeek; | 43 | class DateBookWeek; |
33 | class DateBookWeekLst; | 44 | class DateBookWeekLst; |
34 | class ODateBookMonth; | 45 | class ODateBookMonth; |
35 | class Event; | 46 | class Event; |
36 | class QDate; | 47 | class QDate; |
37 | class Ir; | 48 | class Ir; |
38 | 49 | ||
39 | class DateBook : public QMainWindow | 50 | class DateBook : public QMainWindow |
40 | { | 51 | { |
41 | Q_OBJECT | 52 | Q_OBJECT |
42 | 53 | ||
43 | public: | 54 | public: |
44 | static QString appName() { return QString::fromLatin1("datebook"); } | 55 | static QString appName() { return QString::fromLatin1("datebook"); } |
45 | DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 56 | DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
46 | ~DateBook(); | 57 | ~DateBook(); |
47 | 58 | ||
48 | signals: | 59 | signals: |
49 | void newEvent(); | 60 | void newEvent(); |
50 | void signalNotFound(); | 61 | void signalNotFound(); |
51 | void signalWrapAround(); | 62 | void signalWrapAround(); |
52 | 63 | ||
53 | protected: | 64 | protected: |
54 | QDate currentDate(); | 65 | QDate currentDate(); |
55 | void timerEvent( QTimerEvent *e ); | 66 | void timerEvent( QTimerEvent *e ); |
56 | void closeEvent( QCloseEvent *e ); | 67 | void closeEvent( QCloseEvent *e ); |
57 | 68 | ||
58 | void view(int v, const QDate &d); | 69 | void view(int v, const QDate &d); |
59 | 70 | ||
60 | public slots: | 71 | public slots: |
61 | void flush(); | 72 | void flush(); |
62 | void reload(); | 73 | void reload(); |
63 | 74 | ||
64 | private slots: | 75 | private slots: |
65 | void fileNew(); | 76 | void fileNew(); |
66 | void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); | 77 | void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); |
67 | void slotSettings(); | 78 | void slotSettings(); |
68 | void slotToday(); // view today | 79 | void slotToday(); // view today |
69 | void changeClock( bool newClock ); | 80 | void changeClock( bool newClock ); |
70 | void changeWeek( bool newDay ); | 81 | void changeWeek( bool newDay ); |
71 | void appMessage(const QCString& msg, const QByteArray& data); | 82 | void appMessage(const QCString& msg, const QByteArray& data); |
72 | // handle key events in the day view... | 83 | // handle key events in the day view... |
73 | void slotNewEventFromKey( const QString &str ); | 84 | void slotNewEventFromKey( const QString &str ); |
74 | void slotFind(); | 85 | void slotFind(); |
75 | void slotDoFind( const QString &, const QDate &, bool, bool, int ); | 86 | void slotDoFind( const QString &, const QDate &, bool, bool, int ); |
76 | 87 | ||
77 | void viewDefault(const QDate &d); | 88 | void viewDefault(const QDate &d); |
78 | 89 | ||
79 | void viewDay(); | 90 | void viewDay(); |
80 | void viewWeek(); | 91 | void viewWeek(); |
81 | void viewWeekLst(); | 92 | void viewWeekLst(); |
82 | void viewMonth(); | 93 | void viewMonth(); |
83 | 94 | ||
84 | void showDay( int y, int m, int d ); | 95 | void showDay( int y, int m, int d ); |
85 | 96 | ||
86 | void insertEvent( const Event &e ); | 97 | void insertEvent( const Event &e ); |
87 | void editEvent( const Event &e ); | 98 | void editEvent( const Event &e ); |
88 | void duplicateEvent( const Event &e ); | 99 | void duplicateEvent( const Event &e ); |
89 | void removeEvent( const Event &e ); | 100 | void removeEvent( const Event &e ); |
90 | 101 | ||
91 | void receive( const QCString &msg, const QByteArray &data ); | 102 | void receive( const QCString &msg, const QByteArray &data ); |
92 | void setDocument( const QString & ); | 103 | void setDocument( const QString & ); |
93 | void beamEvent( const Event &e ); | 104 | void beamEvent( const Event &e ); |
94 | void beamDone( Ir *ir ); | 105 | void beamDone( Ir *ir ); |
95 | 106 | ||
96 | private: | 107 | private: |
97 | void addEvent( const Event &e ); | 108 | void addEvent( const Event &e ); |
98 | void initDay(); | 109 | void initDay(); |
99 | void initWeek(); | 110 | void initWeek(); |
100 | void initWeekLst(); | 111 | void initWeekLst(); |
101 | void initMonth(); | 112 | void initMonth(); |
102 | void loadSettings(); | 113 | void loadSettings(); |
103 | void saveSettings(); | 114 | void saveSettings(); |
104 | 115 | ||
105 | private: | 116 | private: |
106 | DateBookDBHoliday *db; | 117 | DateBookDBHoliday *db; |
107 | DateBookHoliday*db_holiday; | 118 | DateBookHoliday*db_holiday; |
108 | QWidgetStack *views; | 119 | QWidgetStack *views; |
109 | DateBookDay *dayView; | 120 | DateBookDay *dayView; |
110 | DateBookWeek *weekView; | 121 | DateBookWeek *weekView; |
111 | ODateBookMonth *monthView; | 122 | ODateBookMonth *monthView; |
112 | DateBookWeekLst *weekLstView; | 123 | DateBookWeekLst *weekLstView; |
113 | QAction *dayAction, *weekAction, *weekLstAction, *monthAction; | 124 | QAction *dayAction, *weekAction, *weekLstAction, *monthAction; |
114 | int weeklistviewconfig; | 125 | int weeklistviewconfig; |
115 | bool aPreset; // have everything set to alarm? | 126 | bool aPreset; // have everything set to alarm? |
116 | int presetTime; // the standard time for the alarm | 127 | int presetTime; // the standard time for the alarm |
117 | int startTime; | 128 | int startTime; |
118 | int rowStyle; | 129 | int rowStyle; |
119 | int defaultView; | 130 | int defaultView; |
120 | QArray<int> defaultCategories; | 131 | QArray<int> defaultCategories; |
121 | QString defaultLocation; | 132 | QString defaultLocation; |
122 | bool bJumpToCurTime; //should jump to current time in dayview? | 133 | bool bJumpToCurTime; //should jump to current time in dayview? |
123 | bool ampm; | 134 | bool ampm; |
124 | bool onMonday; | 135 | bool onMonday; |
125 | 136 | ||
126 | bool syncing; | 137 | bool syncing; |
127 | bool inSearch; | 138 | bool inSearch; |
128 | 139 | ||
129 | int alarmCounter; | 140 | int alarmCounter; |
130 | 141 | ||
131 | QString checkEvent(const Event &); | 142 | QString checkEvent(const Event &); |
132 | }; | 143 | }; |
133 | 144 | ||
134 | #endif | 145 | #endif |
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index 26f0303..b8385aa 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -1,221 +1,233 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
20 | 30 | ||
21 | #include "datebookday.h" | 31 | #include "datebookday.h" |
22 | #include "datebooktypes.h" | 32 | #include "datebooktypes.h" |
23 | #include "datebookdayheaderimpl.h" | 33 | #include "datebookdayheaderimpl.h" |
24 | #include "datebookdayallday.h" | 34 | #include "datebookdayallday.h" |
25 | 35 | ||
26 | #include <opie2/oholidayplugin.h> | 36 | #include <opie2/oholidayplugin.h> |
27 | #include <qpe/resource.h> | 37 | #include <opie2/oresource.h> |
28 | #include <qpe/qpeapplication.h> | 38 | |
39 | #include <qpe/applnk.h> | ||
29 | #include <qpe/ir.h> | 40 | #include <qpe/ir.h> |
41 | #include <qpe/qpeapplication.h> | ||
30 | 42 | ||
31 | #include <qsimplerichtext.h> | 43 | #include <qsimplerichtext.h> |
32 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
33 | 45 | ||
34 | 46 | ||
35 | #include <qtimer.h> | 47 | #include <qtimer.h> |
36 | 48 | ||
37 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name ) | 49 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name ) |
38 | : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() ) | 50 | : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() ) |
39 | { | 51 | { |
40 | enableClipper(TRUE); | 52 | enableClipper(TRUE); |
41 | setTopMargin( 0 ); | 53 | setTopMargin( 0 ); |
42 | horizontalHeader()->hide(); | 54 | horizontalHeader()->hide(); |
43 | setLeftMargin(38); | 55 | setLeftMargin(38); |
44 | setColumnStretchable( 0, TRUE ); | 56 | setColumnStretchable( 0, TRUE ); |
45 | setHScrollBarMode( QScrollView::AlwaysOff ); | 57 | setHScrollBarMode( QScrollView::AlwaysOff ); |
46 | verticalHeader()->setPalette(white); | 58 | verticalHeader()->setPalette(white); |
47 | verticalHeader()->setResizeEnabled(FALSE); | 59 | verticalHeader()->setResizeEnabled(FALSE); |
48 | setSelectionMode( Single ); | 60 | setSelectionMode( Single ); |
49 | 61 | ||
50 | // get rid of being able to edit things... | 62 | // get rid of being able to edit things... |
51 | QTableItem *tmp; | 63 | QTableItem *tmp; |
52 | int row; | 64 | int row; |
53 | for ( row = 0; row < numRows(); row++ ) { | 65 | for ( row = 0; row < numRows(); row++ ) { |
54 | tmp = new QTableItem( this, QTableItem::Never, QString::null); | 66 | tmp = new QTableItem( this, QTableItem::Never, QString::null); |
55 | setItem( row, 0, tmp ); | 67 | setItem( row, 0, tmp ); |
56 | //setRowHeight( row, 40); | 68 | //setRowHeight( row, 40); |
57 | } | 69 | } |
58 | 70 | ||
59 | initHeader(); | 71 | initHeader(); |
60 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); | 72 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); |
61 | } | 73 | } |
62 | 74 | ||
63 | void DateBookDayView::initHeader() | 75 | void DateBookDayView::initHeader() |
64 | { | 76 | { |
65 | QString strTmp; | 77 | QString strTmp; |
66 | int preferredWidth = 0; | 78 | int preferredWidth = 0; |
67 | for ( int i = 0; i < 24; ++i ) { | 79 | for ( int i = 0; i < 24; ++i ) { |
68 | if ( ampm ) { | 80 | if ( ampm ) { |
69 | if ( i == 0 ) | 81 | if ( i == 0 ) |
70 | strTmp = QString::number(12) + ":00"; | 82 | strTmp = QString::number(12) + ":00"; |
71 | else if ( i == 12 ) | 83 | else if ( i == 12 ) |
72 | strTmp = QString::number(12) + tr(":00p"); | 84 | strTmp = QString::number(12) + tr(":00p"); |
73 | else if ( i > 12 ) | 85 | else if ( i > 12 ) |
74 | strTmp = QString::number( i - 12 ) + tr(":00p"); | 86 | strTmp = QString::number( i - 12 ) + tr(":00p"); |
75 | else | 87 | else |
76 | strTmp = QString::number(i) + ":00"; | 88 | strTmp = QString::number(i) + ":00"; |
77 | } else { | 89 | } else { |
78 | if ( i < 10 ) | 90 | if ( i < 10 ) |
79 | strTmp = "0" + QString::number(i) + ":00"; | 91 | strTmp = "0" + QString::number(i) + ":00"; |
80 | else | 92 | else |
81 | strTmp = QString::number(i) + ":00"; | 93 | strTmp = QString::number(i) + ":00"; |
82 | } | 94 | } |
83 | strTmp = strTmp.rightJustify( 6, ' ' ); | 95 | strTmp = strTmp.rightJustify( 6, ' ' ); |
84 | verticalHeader()->setLabel( i, strTmp ); | 96 | verticalHeader()->setLabel( i, strTmp ); |
85 | 97 | ||
86 | // Compute correct width for current Font (Add some space right) | 98 | // Compute correct width for current Font (Add some space right) |
87 | int actWidth = QFontMetrics( QFont::defaultFont() ).width( strTmp + QString(" ") ); | 99 | int actWidth = QFontMetrics( QFont::defaultFont() ).width( strTmp + QString(" ") ); |
88 | if ( preferredWidth < actWidth ) | 100 | if ( preferredWidth < actWidth ) |
89 | preferredWidth = actWidth; | 101 | preferredWidth = actWidth; |
90 | setRowStretchable( i, FALSE ); | 102 | setRowStretchable( i, FALSE ); |
91 | } | 103 | } |
92 | 104 | ||
93 | // It seems as if the header has a bug. It does not resize | 105 | // It seems as if the header has a bug. It does not resize |
94 | // correct horizontally if it is used vertical.. | 106 | // correct horizontally if it is used vertical.. |
95 | // Thus, we do it manually.. | 107 | // Thus, we do it manually.. |
96 | setLeftMargin( preferredWidth ); | 108 | setLeftMargin( preferredWidth ); |
97 | } | 109 | } |
98 | 110 | ||
99 | void DateBookDayView::slotDateChanged( int y, int m, int d ) | 111 | void DateBookDayView::slotDateChanged( int y, int m, int d ) |
100 | { | 112 | { |
101 | currDate.setYMD(y,m,d); | 113 | currDate.setYMD(y,m,d); |
102 | } | 114 | } |
103 | 115 | ||
104 | void DateBookDayView::slotChangeClock( bool newClock ) | 116 | void DateBookDayView::slotChangeClock( bool newClock ) |
105 | { | 117 | { |
106 | ampm = newClock; | 118 | ampm = newClock; |
107 | initHeader(); | 119 | initHeader(); |
108 | } | 120 | } |
109 | 121 | ||
110 | bool DateBookDayView::whichClock() const | 122 | bool DateBookDayView::whichClock() const |
111 | { | 123 | { |
112 | return ampm; | 124 | return ampm; |
113 | } | 125 | } |
114 | 126 | ||
115 | void DateBookDayView::moveUp() | 127 | void DateBookDayView::moveUp() |
116 | { | 128 | { |
117 | scrollBy(0, -20); | 129 | scrollBy(0, -20); |
118 | } | 130 | } |
119 | 131 | ||
120 | void DateBookDayView::moveDown() | 132 | void DateBookDayView::moveDown() |
121 | { | 133 | { |
122 | scrollBy(0, 20); | 134 | scrollBy(0, 20); |
123 | } | 135 | } |
124 | 136 | ||
125 | void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) | 137 | void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) |
126 | { | 138 | { |
127 | int w = cr.width(); | 139 | int w = cr.width(); |
128 | int h = cr.height(); | 140 | int h = cr.height(); |
129 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); | 141 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); |
130 | if ( showGrid() ) { | 142 | if ( showGrid() ) { |
131 | // Draw our lines | 143 | // Draw our lines |
132 | int x2 = w - 1; | 144 | int x2 = w - 1; |
133 | int y2 = h - 1; | 145 | int y2 = h - 1; |
134 | QPen pen( p->pen() ); | 146 | QPen pen( p->pen() ); |
135 | p->setPen( colorGroup().dark() ); | 147 | p->setPen( colorGroup().dark() ); |
136 | p->drawLine( x2, 0, x2, y2 ); | 148 | p->drawLine( x2, 0, x2, y2 ); |
137 | p->drawLine( 0, y2, x2, y2 ); | 149 | p->drawLine( 0, y2, x2, y2 ); |
138 | 150 | ||
139 | p->setPen( colorGroup().midlight() ); | 151 | p->setPen( colorGroup().midlight() ); |
140 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); | 152 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); |
141 | 153 | ||
142 | p->setPen( pen ); | 154 | p->setPen( pen ); |
143 | } | 155 | } |
144 | } | 156 | } |
145 | 157 | ||
146 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) | 158 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) |
147 | { | 159 | { |
148 | } | 160 | } |
149 | 161 | ||
150 | void DateBookDayView::resizeEvent( QResizeEvent *e ) | 162 | void DateBookDayView::resizeEvent( QResizeEvent *e ) |
151 | { | 163 | { |
152 | QTable::resizeEvent( e ); | 164 | QTable::resizeEvent( e ); |
153 | columnWidthChanged( 0 ); | 165 | columnWidthChanged( 0 ); |
154 | emit sigColWidthChanged(); | 166 | emit sigColWidthChanged(); |
155 | } | 167 | } |
156 | 168 | ||
157 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) | 169 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) |
158 | { | 170 | { |
159 | QString txt = e->text(); | 171 | QString txt = e->text(); |
160 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { | 172 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { |
161 | // we this is some sort of thing we know about... | 173 | // we this is some sort of thing we know about... |
162 | e->accept(); | 174 | e->accept(); |
163 | emit sigCapturedKey( txt ); | 175 | emit sigCapturedKey( txt ); |
164 | } else { | 176 | } else { |
165 | // I don't know what this key is, do you? | 177 | // I don't know what this key is, do you? |
166 | e->ignore(); | 178 | e->ignore(); |
167 | } | 179 | } |
168 | } | 180 | } |
169 | 181 | ||
170 | void DateBookDayView::setRowStyle( int style ) | 182 | void DateBookDayView::setRowStyle( int style ) |
171 | { | 183 | { |
172 | if (style<0) style = 0; | 184 | if (style<0) style = 0; |
173 | 185 | ||
174 | for (int i=0; i<numRows(); i++) | 186 | for (int i=0; i<numRows(); i++) |
175 | setRowHeight(i, style*10+20); | 187 | setRowHeight(i, style*10+20); |
176 | } | 188 | } |
177 | 189 | ||
178 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ ) | 190 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ ) |
179 | { | 191 | { |
180 | int sh=99,eh=-1; | 192 | int sh=99,eh=-1; |
181 | 193 | ||
182 | for(int i=0;i<this->numSelections();i++) { | 194 | for(int i=0;i<this->numSelections();i++) { |
183 | QTableSelection sel = this->selection( i ); | 195 | QTableSelection sel = this->selection( i ); |
184 | sh = QMIN(sh,sel.topRow()); | 196 | sh = QMIN(sh,sel.topRow()); |
185 | eh = QMAX(sh,sel.bottomRow()+1); | 197 | eh = QMAX(sh,sel.bottomRow()+1); |
186 | } | 198 | } |
187 | if (sh > 23 || eh < 1) { | 199 | if (sh > 23 || eh < 1) { |
188 | sh=8; | 200 | sh=8; |
189 | eh=9; | 201 | eh=9; |
190 | } | 202 | } |
191 | 203 | ||
192 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); | 204 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); |
193 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); | 205 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); |
194 | this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); | 206 | this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); |
195 | quickLineEdit->setFocus(); | 207 | quickLineEdit->setFocus(); |
196 | quickLineEdit->show(); | 208 | quickLineEdit->show(); |
197 | } | 209 | } |
198 | 210 | ||
199 | //=========================================================================== | 211 | //=========================================================================== |
200 | 212 | ||
201 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) | 213 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) |
202 | { | 214 | { |
203 | active=1; | 215 | active=1; |
204 | quickEvent.setStart(start); | 216 | quickEvent.setStart(start); |
205 | quickEvent.setEnd(end); | 217 | quickEvent.setEnd(end); |
206 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); | 218 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); |
207 | } | 219 | } |
208 | 220 | ||
209 | void DateBookDayViewQuickLineEdit::slotReturnPressed() | 221 | void DateBookDayViewQuickLineEdit::slotReturnPressed() |
210 | { | 222 | { |
211 | if(active && (!this->text().isEmpty())) { // Fix to avoid having this event beeing added multiple times. | 223 | if(active && (!this->text().isEmpty())) { // Fix to avoid having this event beeing added multiple times. |
212 | quickEvent.setDescription(this->text()); | 224 | quickEvent.setDescription(this->text()); |
213 | connect(this,SIGNAL(insertEvent(const Event&)),this->topLevelWidget(),SLOT(insertEvent(const Event&))); | 225 | connect(this,SIGNAL(insertEvent(const Event&)),this->topLevelWidget(),SLOT(insertEvent(const Event&))); |
214 | emit(insertEvent(quickEvent)); | 226 | emit(insertEvent(quickEvent)); |
215 | active=0; | 227 | active=0; |
216 | } | 228 | } |
217 | /* we need to return to this object.. */ | 229 | /* we need to return to this object.. */ |
218 | QTimer::singleShot(500, this, SLOT(finallyCallClose()) ); // Close and also delete this widget | 230 | QTimer::singleShot(500, this, SLOT(finallyCallClose()) ); // Close and also delete this widget |
219 | } | 231 | } |
220 | void DateBookDayViewQuickLineEdit::finallyCallClose() { | 232 | void DateBookDayViewQuickLineEdit::finallyCallClose() { |
221 | close(true); // also deletes this widget... | 233 | close(true); // also deletes this widget... |
@@ -568,380 +580,382 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
568 | 580 | ||
569 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) | 581 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) |
570 | { | 582 | { |
571 | int i = 0; | 583 | int i = 0; |
572 | DateBookDayWidget *w = widgetList.at(i); | 584 | DateBookDayWidget *w = widgetList.at(i); |
573 | int wCount = widgetList.count(); | 585 | int wCount = widgetList.count(); |
574 | while ( i < wCount && w != item ) { | 586 | while ( i < wCount && w != item ) { |
575 | if ( w->geometry().intersects( geom ) ) { | 587 | if ( w->geometry().intersects( geom ) ) { |
576 | return w; | 588 | return w; |
577 | } | 589 | } |
578 | w = widgetList.at(++i); | 590 | w = widgetList.at(++i); |
579 | } | 591 | } |
580 | 592 | ||
581 | return 0; | 593 | return 0; |
582 | } | 594 | } |
583 | 595 | ||
584 | 596 | ||
585 | QDate DateBookDay::date() const | 597 | QDate DateBookDay::date() const |
586 | { | 598 | { |
587 | return currDate; | 599 | return currDate; |
588 | } | 600 | } |
589 | 601 | ||
590 | void DateBookDay::setStartViewTime( int startHere ) | 602 | void DateBookDay::setStartViewTime( int startHere ) |
591 | { | 603 | { |
592 | startTime = startHere; | 604 | startTime = startHere; |
593 | dayView()->clearSelection(); | 605 | dayView()->clearSelection(); |
594 | QTableSelection ts; | 606 | QTableSelection ts; |
595 | 607 | ||
596 | if (jumpToCurTime && this->date() == QDate::currentDate()) { //this should probably be in datebook.cpp where it's called? | 608 | if (jumpToCurTime && this->date() == QDate::currentDate()) { //this should probably be in datebook.cpp where it's called? |
597 | ts.init( QTime::currentTime().hour(), 0); | 609 | ts.init( QTime::currentTime().hour(), 0); |
598 | ts.expandTo( QTime::currentTime().hour(), 0); | 610 | ts.expandTo( QTime::currentTime().hour(), 0); |
599 | } else { | 611 | } else { |
600 | ts.init( startTime, 0 ); | 612 | ts.init( startTime, 0 ); |
601 | ts.expandTo( startTime, 0 ); | 613 | ts.expandTo( startTime, 0 ); |
602 | } | 614 | } |
603 | 615 | ||
604 | dayView()->addSelection( ts ); | 616 | dayView()->addSelection( ts ); |
605 | } | 617 | } |
606 | 618 | ||
607 | int DateBookDay::startViewTime() const | 619 | int DateBookDay::startViewTime() const |
608 | { | 620 | { |
609 | return startTime; | 621 | return startTime; |
610 | } | 622 | } |
611 | 623 | ||
612 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) | 624 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) |
613 | { | 625 | { |
614 | header->setStartOfWeek( bStartOnMonday ); | 626 | header->setStartOfWeek( bStartOnMonday ); |
615 | // redraw(); | 627 | // redraw(); |
616 | } | 628 | } |
617 | 629 | ||
618 | void DateBookDay::keyPressEvent(QKeyEvent *e) | 630 | void DateBookDay::keyPressEvent(QKeyEvent *e) |
619 | { | 631 | { |
620 | switch(e->key()) { | 632 | switch(e->key()) { |
621 | case Key_Up: | 633 | case Key_Up: |
622 | view->moveUp(); | 634 | view->moveUp(); |
623 | break; | 635 | break; |
624 | case Key_Down: | 636 | case Key_Down: |
625 | view->moveDown(); | 637 | view->moveDown(); |
626 | break; | 638 | break; |
627 | case Key_Left: | 639 | case Key_Left: |
628 | setDate(QDate(currDate).addDays(-1)); | 640 | setDate(QDate(currDate).addDays(-1)); |
629 | break; | 641 | break; |
630 | case Key_Right: | 642 | case Key_Right: |
631 | setDate(QDate(currDate).addDays(1)); | 643 | setDate(QDate(currDate).addDays(1)); |
632 | break; | 644 | break; |
633 | default: | 645 | default: |
634 | e->ignore(); | 646 | e->ignore(); |
635 | } | 647 | } |
636 | } | 648 | } |
637 | 649 | ||
638 | //=========================================================================== | 650 | //=========================================================================== |
639 | 651 | ||
640 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) | 652 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) |
641 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) | 653 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) |
642 | { | 654 | { |
643 | // why would someone use "<"? Oh well, fix it up... | 655 | // why would someone use "<"? Oh well, fix it up... |
644 | // I wonder what other things may be messed up... | 656 | // I wonder what other things may be messed up... |
645 | QString strDesc = ev.description(); | 657 | QString strDesc = ev.description(); |
646 | int where = strDesc.find( "<" ); | 658 | int where = strDesc.find( "<" ); |
647 | while ( where != -1 ) { | 659 | while ( where != -1 ) { |
648 | strDesc.remove( where, 1 ); | 660 | strDesc.remove( where, 1 ); |
649 | strDesc.insert( where, "<" ); | 661 | strDesc.insert( where, "<" ); |
650 | where = strDesc.find( "<", where ); | 662 | where = strDesc.find( "<", where ); |
651 | } | 663 | } |
652 | 664 | ||
653 | QString strCat; | 665 | QString strCat; |
654 | // ### Fix later... | 666 | // ### Fix later... |
655 | // QString strCat = ev.category(); | 667 | // QString strCat = ev.category(); |
656 | // where = strCat.find( "<" ); | 668 | // where = strCat.find( "<" ); |
657 | // while ( where != -1 ) { | 669 | // while ( where != -1 ) { |
658 | // strCat.remove( where, 1 ); | 670 | // strCat.remove( where, 1 ); |
659 | // strCat.insert( where, "<" ); | 671 | // strCat.insert( where, "<" ); |
660 | // where = strCat.find( "<", where ); | 672 | // where = strCat.find( "<", where ); |
661 | // } | 673 | // } |
662 | 674 | ||
663 | QString strNote = ev.notes(); | 675 | QString strNote = ev.notes(); |
664 | where = strNote.find( "<" ); | 676 | where = strNote.find( "<" ); |
665 | while ( where != -1 ) { | 677 | while ( where != -1 ) { |
666 | strNote.remove( where, 1 ); | 678 | strNote.remove( where, 1 ); |
667 | strNote.insert( where, "<" ); | 679 | strNote.insert( where, "<" ); |
668 | where = strNote.find( "<", where ); | 680 | where = strNote.find( "<", where ); |
669 | } | 681 | } |
670 | 682 | ||
671 | text = "<b>" + strDesc + "</b><br>" + "<i>"; | 683 | text = "<b>" + strDesc + "</b><br>" + "<i>"; |
672 | if ( !strCat.isEmpty() ) { | 684 | if ( !strCat.isEmpty() ) { |
673 | text += strCat + "</i><br>"; | 685 | text += strCat + "</i><br>"; |
674 | } | 686 | } |
675 | if (ev.event().type() == Event::Normal ) { | 687 | if (ev.event().type() == Event::Normal ) { |
676 | setEventText( text ); | 688 | setEventText( text ); |
677 | } else { | 689 | } else { |
678 | setAllDayText( text ); | 690 | setAllDayText( text ); |
679 | } | 691 | } |
680 | 692 | ||
681 | text += "<br><br>" + strNote; | 693 | text += "<br><br>" + strNote; |
682 | 694 | ||
683 | setBackgroundMode( PaletteBase ); | 695 | setBackgroundMode( PaletteBase ); |
684 | 696 | ||
685 | QTime start = ev.start(); | 697 | QTime start = ev.start(); |
686 | QTime end = ev.end(); | 698 | QTime end = ev.end(); |
687 | int y = start.hour()*60+start.minute(); | 699 | int y = start.hour()*60+start.minute(); |
688 | int h = end.hour()*60+end.minute()-y; | 700 | int h = end.hour()*60+end.minute()-y; |
689 | int rh = dateBook->dayView()->rowHeight(0); | 701 | int rh = dateBook->dayView()->rowHeight(0); |
690 | y = y*rh/60; | 702 | y = y*rh/60; |
691 | h = h*rh/60; | 703 | h = h*rh/60; |
692 | 704 | ||
693 | if ( h < 12 ) h = 12; // Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line. | 705 | if ( h < 12 ) h = 12; // Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line. |
694 | if ( y > ((24*rh)-12) ) y=(24*rh)-12; // Make sure the widget fits inside the dayview. | 706 | if ( y > ((24*rh)-12) ) y=(24*rh)-12; // Make sure the widget fits inside the dayview. |
695 | geom.setY( y ); | 707 | geom.setY( y ); |
696 | geom.setHeight( h ); | 708 | geom.setHeight( h ); |
697 | geom.setX( 0 ); | 709 | geom.setX( 0 ); |
698 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); | 710 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); |
699 | 711 | ||
700 | } | 712 | } |
701 | 713 | ||
702 | void DateBookDayWidget::setAllDayText( QString &text ) { | 714 | void DateBookDayWidget::setAllDayText( QString &text ) { |
703 | text += "<b>" + tr("This is an all day event.") + "</b>"; | 715 | text += "<b>" + tr("This is an all day event.") + "</b>"; |
704 | } | 716 | } |
705 | 717 | ||
706 | void DateBookDayWidget::setEventText( QString& text ) { | 718 | void DateBookDayWidget::setEventText( QString& text ) { |
707 | bool whichClock = dateBook->dayView()->whichClock(); | 719 | bool whichClock = dateBook->dayView()->whichClock(); |
708 | if ( ev.startDate() != ev.endDate() ) { | 720 | if ( ev.startDate() != ev.endDate() ) { |
709 | text += "<b>" + tr("Start") + "</b>: "; | 721 | text += "<b>" + tr("Start") + "</b>: "; |
710 | text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); | 722 | text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); |
711 | text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; | 723 | text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; |
712 | text += "<b>" + tr("End") + "</b>: "; | 724 | text += "<b>" + tr("End") + "</b>: "; |
713 | text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); | 725 | text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); |
714 | text += " - " + TimeString::longDateString( ev.endDate() ); | 726 | text += " - " + TimeString::longDateString( ev.endDate() ); |
715 | } else { | 727 | } else { |
716 | text += "<b>" + tr("Time") + "</b>: "; | 728 | text += "<b>" + tr("Time") + "</b>: "; |
717 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); | 729 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); |
718 | text += "<b>" + tr(" - ") + "</b>"; | 730 | text += "<b>" + tr(" - ") + "</b>"; |
719 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); | 731 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); |
720 | } | 732 | } |
721 | } | 733 | } |
722 | 734 | ||
723 | DateBookDayWidget::~DateBookDayWidget() | 735 | DateBookDayWidget::~DateBookDayWidget() |
724 | { | 736 | { |
725 | } | 737 | } |
726 | 738 | ||
727 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) | 739 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) |
728 | { | 740 | { |
729 | QPainter p( this ); | 741 | QPainter p( this ); |
730 | 742 | ||
731 | if (dateBook->getSelectedWidget() == this) { | 743 | if (dateBook->getSelectedWidget() == this) { |
732 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item | 744 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item |
733 | } else { | 745 | } else { |
734 | if (dateBook->date() == QDate::currentDate()) { | 746 | if (dateBook->date() == QDate::currentDate()) { |
735 | QTime curTime = QTime::currentTime(); | 747 | QTime curTime = QTime::currentTime(); |
736 | if (ev.end() < curTime) { | 748 | if (ev.end() < curTime) { |
737 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive | 749 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive |
738 | } else { | 750 | } else { |
739 | //change color in dependence of the time till the event starts | 751 | //change color in dependence of the time till the event starts |
740 | int duration = curTime.secsTo(ev.start()); | 752 | int duration = curTime.secsTo(ev.start()); |
741 | if (duration < 0) duration = 0; | 753 | if (duration < 0) duration = 0; |
742 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift | 754 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift |
743 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue | 755 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue |
744 | } | 756 | } |
745 | } else { | 757 | } else { |
746 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) | 758 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) |
747 | //perhaps make a distinction between future/past dates | 759 | //perhaps make a distinction between future/past dates |
748 | } | 760 | } |
749 | } | 761 | } |
750 | 762 | ||
751 | p.setPen( QColor(100, 100, 100) ); | 763 | p.setPen( QColor(100, 100, 100) ); |
752 | p.drawRect(rect()); | 764 | p.drawRect(rect()); |
753 | 765 | ||
754 | // p.drawRect(0,0, 5, height()); | 766 | // p.drawRect(0,0, 5, height()); |
755 | 767 | ||
756 | int y = 0; | 768 | int y = 0; |
757 | int d = 0; | 769 | int d = 0; |
758 | 770 | ||
759 | if ( ev.event().hasAlarm() ) { | 771 | if ( ev.event().hasAlarm() ) { |
760 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); | 772 | p.drawPixmap( width() - AppLnk::smallIconSize(), 0, |
761 | y = 20; | 773 | Opie::Core::OResource::loadPixmap( "bell", Opie::Core::OResource::SmallIcon ) ); |
774 | y = AppLnk::smallIconSize() + 2; | ||
762 | d = 20; | 775 | d = 20; |
763 | } | 776 | } |
764 | 777 | ||
765 | if ( ev.event().hasRepeat() ) { | 778 | if ( ev.event().hasRepeat() ) { |
766 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); | 779 | p.drawPixmap( width() - AppLnk::smallIconSize(), y, |
780 | Opie::Core::OResource::loadPixmap( "repeat", Opie::Core::OResource::SmallIcon ) ); | ||
767 | d = 20; | 781 | d = 20; |
768 | y += 20; | 782 | y += AppLnk::smallIconSize() + 2; |
769 | } | 783 | } |
770 | 784 | ||
771 | QSimpleRichText rt( text, font() ); | 785 | QSimpleRichText rt( text, font() ); |
772 | rt.setWidth( geom.width() - d - 6 ); | 786 | rt.setWidth( geom.width() - d - 6 ); |
773 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); | 787 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); |
774 | } | 788 | } |
775 | 789 | ||
776 | /* | 790 | /* |
777 | * we need to find the real start date for a uid | 791 | * we need to find the real start date for a uid |
778 | * we need to check from one day to another... | 792 | * we need to check from one day to another... |
779 | */ | 793 | */ |
780 | QDate DateBookDay::findRealStart( int uid, const QDate& isIncluded , DateBookDB* db) { | 794 | QDate DateBookDay::findRealStart( int uid, const QDate& isIncluded , DateBookDB* db) { |
781 | QDate dt( isIncluded ); | 795 | QDate dt( isIncluded ); |
782 | QDate fnd = dt; | 796 | QDate fnd = dt; |
783 | 797 | ||
784 | bool doAgain = true; | 798 | bool doAgain = true; |
785 | do{ | 799 | do{ |
786 | dt = dt.addDays( -1 ); | 800 | dt = dt.addDays( -1 ); |
787 | QValueList<EffectiveEvent> events = db->getEffectiveEvents( dt, dt ); | 801 | QValueList<EffectiveEvent> events = db->getEffectiveEvents( dt, dt ); |
788 | for (QValueList<EffectiveEvent>::Iterator it = events.begin(); it != events.end(); ++it ) { | 802 | for (QValueList<EffectiveEvent>::Iterator it = events.begin(); it != events.end(); ++it ) { |
789 | EffectiveEvent ev = (*it); | 803 | EffectiveEvent ev = (*it); |
790 | if ( uid == ev.event().uid() && ev.start() != QTime(0, 0, 0 ) ) | 804 | if ( uid == ev.event().uid() && ev.start() != QTime(0, 0, 0 ) ) |
791 | return ev.date(); | 805 | return ev.date(); |
792 | } | 806 | } |
793 | }while (doAgain ); | 807 | }while (doAgain ); |
794 | 808 | ||
795 | return fnd; | 809 | return fnd; |
796 | } | 810 | } |
797 | 811 | ||
798 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) | 812 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) |
799 | { | 813 | { |
800 | DateBookDayWidget *item; | 814 | DateBookDayWidget *item; |
801 | 815 | ||
802 | item = dateBook->getSelectedWidget(); | 816 | item = dateBook->getSelectedWidget(); |
803 | if (item) | 817 | if (item) |
804 | item->update(); | 818 | item->update(); |
805 | 819 | ||
806 | dateBook->setSelectedWidget(this); | 820 | dateBook->setSelectedWidget(this); |
807 | update(); | 821 | update(); |
808 | dateBook->repaint(); | 822 | dateBook->repaint(); |
809 | 823 | ||
810 | Event eve = ev.event(); | 824 | Event eve = ev.event(); |
811 | 825 | ||
812 | QPopupMenu m; | 826 | QPopupMenu m; |
813 | m.insertItem( tr( "Edit" ), 1 ); | 827 | m.insertItem( tr( "Edit" ), 1 ); |
814 | m.insertItem( tr( "Duplicate" ), 4 ); | 828 | m.insertItem( tr( "Duplicate" ), 4 ); |
815 | m.insertItem( tr( "Delete" ), 2 ); | 829 | m.insertItem( tr( "Delete" ), 2 ); |
816 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); | 830 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); |
817 | if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 ); | 831 | if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 ); |
818 | int r = m.exec( e->globalPos() ); | 832 | int r = m.exec( e->globalPos() ); |
819 | if ( r == 1 ) { | 833 | if ( r == 1 ) { |
820 | emit editMe( eve ); | 834 | emit editMe( eve ); |
821 | } else if ( r == 2 ) { | 835 | } else if ( r == 2 ) { |
822 | emit deleteMe( eve ); | 836 | emit deleteMe( eve ); |
823 | } else if ( r == 3 ) { | 837 | } else if ( r == 3 ) { |
824 | emit beamMe( eve ); | 838 | emit beamMe( eve ); |
825 | } else if ( r == 4 ) { | 839 | } else if ( r == 4 ) { |
826 | emit duplicateMe( eve ); | 840 | emit duplicateMe( eve ); |
827 | } else if ( r == 5 ) { | 841 | } else if ( r == 5 ) { |
828 | // create an Event and beam it... | 842 | // create an Event and beam it... |
829 | /* | 843 | /* |
830 | * Start with the easy stuff. If start and end date is the same we can just use | 844 | * Start with the easy stuff. If start and end date is the same we can just use |
831 | * the values of effective events | 845 | * the values of effective events |
832 | * If it is a multi day event we need to find the real start and end date... | 846 | * If it is a multi day event we need to find the real start and end date... |
833 | */ | 847 | */ |
834 | if ( ev.event().start().date() == ev.event().end().date() ) { | 848 | if ( ev.event().start().date() == ev.event().end().date() ) { |
835 | Event event( ev.event() ); | 849 | Event event( ev.event() ); |
836 | 850 | ||
837 | QDateTime dt( ev.date(), ev.start() ); | 851 | QDateTime dt( ev.date(), ev.start() ); |
838 | event.setStart( dt ); | 852 | event.setStart( dt ); |
839 | 853 | ||
840 | dt.setTime( ev.end() ); | 854 | dt.setTime( ev.end() ); |
841 | event.setEnd( dt ); | 855 | event.setEnd( dt ); |
842 | emit beamMe( event ); | 856 | emit beamMe( event ); |
843 | }else { | 857 | }else { |
844 | /* | 858 | /* |
845 | * at least the the Times are right now | 859 | * at least the the Times are right now |
846 | */ | 860 | */ |
847 | QDateTime start( ev.event().start() ); | 861 | QDateTime start( ev.event().start() ); |
848 | QDateTime end ( ev.event().end () ); | 862 | QDateTime end ( ev.event().end () ); |
849 | 863 | ||
850 | 864 | ||
851 | /* | 865 | /* |
852 | * ok we know the start date or we need to find it | 866 | * ok we know the start date or we need to find it |
853 | */ | 867 | */ |
854 | if ( ev.start() != QTime( 0, 0, 0 ) ) { | 868 | if ( ev.start() != QTime( 0, 0, 0 ) ) { |
855 | start.setDate( ev.date() ); | 869 | start.setDate( ev.date() ); |
856 | }else { | 870 | }else { |
857 | QDate dt = DateBookDay::findRealStart( ev.event().uid(), ev.date(), dateBook->db ); | 871 | QDate dt = DateBookDay::findRealStart( ev.event().uid(), ev.date(), dateBook->db ); |
858 | start.setDate( dt ); | 872 | start.setDate( dt ); |
859 | } | 873 | } |
860 | 874 | ||
861 | 875 | ||
862 | /* | 876 | /* |
863 | * ok we know now the end date... | 877 | * ok we know now the end date... |
864 | * else | 878 | * else |
865 | * get to know the offset btw the real start and real end | 879 | * get to know the offset btw the real start and real end |
866 | * and then add it to the new start date... | 880 | * and then add it to the new start date... |
867 | */ | 881 | */ |
868 | if ( ev.end() != QTime(23, 59, 59 ) ) { | 882 | if ( ev.end() != QTime(23, 59, 59 ) ) { |
869 | end.setDate( ev.date() ); | 883 | end.setDate( ev.date() ); |
870 | }else{ | 884 | }else{ |
871 | int days = ev.event().start().date().daysTo( ev.event().end().date() ); | 885 | int days = ev.event().start().date().daysTo( ev.event().end().date() ); |
872 | end.setDate( start.date().addDays( days ) ); | 886 | end.setDate( start.date().addDays( days ) ); |
873 | } | 887 | } |
874 | 888 | ||
875 | 889 | ||
876 | 890 | ||
877 | Event event( ev.event() ); | 891 | Event event( ev.event() ); |
878 | event.setStart( start ); | 892 | event.setStart( start ); |
879 | event.setEnd ( end ); | 893 | event.setEnd ( end ); |
880 | 894 | ||
881 | 895 | ||
882 | emit beamMe( event ); | 896 | emit beamMe( event ); |
883 | } | 897 | } |
884 | } | 898 | } |
885 | } | 899 | } |
886 | 900 | ||
887 | void DateBookDayWidget::setGeometry( const QRect &r ) | 901 | void DateBookDayWidget::setGeometry( const QRect &r ) |
888 | { | 902 | { |
889 | geom = r; | 903 | geom = r; |
890 | setFixedSize( r.width()+1, r.height()+1 ); | 904 | setFixedSize( r.width()+1, r.height()+1 ); |
891 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 905 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
892 | show(); | 906 | show(); |
893 | } | 907 | } |
894 | 908 | ||
895 | 909 | ||
896 | //--------------------------------------------------------------------------------------------- | 910 | //--------------------------------------------------------------------------------------------- |
897 | //--------------------------------------------------------------------------------------------- | 911 | //--------------------------------------------------------------------------------------------- |
898 | 912 | ||
899 | 913 | ||
900 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) | 914 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) |
901 | : QWidget( db->dayView()->viewport() ), dateBook( db ) | 915 | : QWidget( db->dayView()->viewport() ), dateBook( db ) |
902 | { | 916 | { |
903 | setBackgroundMode( PaletteBase ); | 917 | setBackgroundMode( PaletteBase ); |
904 | } | 918 | } |
905 | 919 | ||
906 | DateBookDayTimeMarker::~DateBookDayTimeMarker() | 920 | DateBookDayTimeMarker::~DateBookDayTimeMarker() |
907 | { | 921 | { |
908 | } | 922 | } |
909 | 923 | ||
910 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) | 924 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) |
911 | { | 925 | { |
912 | QPainter p( this ); | 926 | QPainter p( this ); |
913 | p.setBrush( QColor( 255, 0, 0 ) ); | 927 | p.setBrush( QColor( 255, 0, 0 ) ); |
914 | 928 | ||
915 | QPen pen; | 929 | QPen pen; |
916 | pen.setStyle(NoPen); | 930 | pen.setStyle(NoPen); |
917 | 931 | ||
918 | p.setPen( pen ); | 932 | p.setPen( pen ); |
919 | p.drawRect(rect()); | 933 | p.drawRect(rect()); |
920 | } | 934 | } |
921 | 935 | ||
922 | void DateBookDayTimeMarker::setTime( const QTime &t ) | 936 | void DateBookDayTimeMarker::setTime( const QTime &t ) |
923 | { | 937 | { |
924 | int y = t.hour()*60+t.minute(); | 938 | int y = t.hour()*60+t.minute(); |
925 | int rh = dateBook->dayView()->rowHeight(0); | 939 | int rh = dateBook->dayView()->rowHeight(0); |
926 | y = y*rh/60; | 940 | y = y*rh/60; |
927 | 941 | ||
928 | geom.setX( 0 ); | 942 | geom.setX( 0 ); |
929 | 943 | ||
930 | int x = dateBook->dayView()->columnWidth(0)-1; | 944 | int x = dateBook->dayView()->columnWidth(0)-1; |
931 | geom.setWidth( x ); | 945 | geom.setWidth( x ); |
932 | 946 | ||
933 | geom.setY( y ); | 947 | geom.setY( y ); |
934 | geom.setHeight( 1 ); | 948 | geom.setHeight( 1 ); |
935 | 949 | ||
936 | setGeometry( geom ); | 950 | setGeometry( geom ); |
937 | 951 | ||
938 | time = t; | 952 | time = t; |
939 | } | 953 | } |
940 | 954 | ||
941 | void DateBookDayTimeMarker::setGeometry( const QRect &r ) | 955 | void DateBookDayTimeMarker::setGeometry( const QRect &r ) |
942 | { | 956 | { |
943 | geom = r; | 957 | geom = r; |
944 | setFixedSize( r.width()+1, r.height()+1 ); | 958 | setFixedSize( r.width()+1, r.height()+1 ); |
945 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 959 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
946 | show(); | 960 | show(); |
947 | } | 961 | } |
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h index 3b75eba..82021af 100644 --- a/core/pim/datebook/datebookday.h +++ b/core/pim/datebook/datebookday.h | |||
@@ -1,211 +1,222 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
20 | #ifndef DATEBOOKDAY_H | 31 | #ifndef DATEBOOKDAY_H |
21 | #define DATEBOOKDAY_H | 32 | #define DATEBOOKDAY_H |
22 | 33 | ||
23 | #include <qpe/event.h> | 34 | #include <qpe/event.h> |
24 | 35 | ||
25 | #include <qdatetime.h> | 36 | #include <qdatetime.h> |
26 | #include <qtable.h> | 37 | #include <qtable.h> |
27 | #include <qvbox.h> | 38 | #include <qvbox.h> |
28 | #include <qlist.h> | 39 | #include <qlist.h> |
29 | 40 | ||
30 | #include "datebook.h" | 41 | #include "datebook.h" |
31 | #include "datebooktypes.h" | 42 | #include "datebooktypes.h" |
32 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
33 | 44 | ||
34 | class DateBookDayHeader; | 45 | class DateBookDayHeader; |
35 | class DateBookDB; | 46 | class DateBookDB; |
36 | class DateBookDBHoliday; | 47 | class DateBookDBHoliday; |
37 | class DatebookdayAllday; | 48 | class DatebookdayAllday; |
38 | class QDateTime; | 49 | class QDateTime; |
39 | class QMouseEvent; | 50 | class QMouseEvent; |
40 | class QPaintEvent; | 51 | class QPaintEvent; |
41 | class QResizeEvent; | 52 | class QResizeEvent; |
42 | 53 | ||
43 | class DateBookDayViewQuickLineEdit : public QLineEdit | 54 | class DateBookDayViewQuickLineEdit : public QLineEdit |
44 | { | 55 | { |
45 | Q_OBJECT | 56 | Q_OBJECT |
46 | public: | 57 | public: |
47 | DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0); | 58 | DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0); |
48 | protected: | 59 | protected: |
49 | Event quickEvent; | 60 | Event quickEvent; |
50 | int active; | 61 | int active; |
51 | void focusOutEvent( QFocusEvent *e ); | 62 | void focusOutEvent( QFocusEvent *e ); |
52 | protected slots: | 63 | protected slots: |
53 | void slotReturnPressed(void); | 64 | void slotReturnPressed(void); |
54 | void finallyCallClose(); | 65 | void finallyCallClose(); |
55 | signals: | 66 | signals: |
56 | void insertEvent(const Event &e); | 67 | void insertEvent(const Event &e); |
57 | }; | 68 | }; |
58 | 69 | ||
59 | 70 | ||
60 | class DateBookDayView : public QTable | 71 | class DateBookDayView : public QTable |
61 | { | 72 | { |
62 | Q_OBJECT | 73 | Q_OBJECT |
63 | public: | 74 | public: |
64 | DateBookDayView( bool hourClock, QWidget *parent, const char *name ); | 75 | DateBookDayView( bool hourClock, QWidget *parent, const char *name ); |
65 | bool whichClock() const; | 76 | bool whichClock() const; |
66 | 77 | ||
67 | void setRowStyle( int style ); | 78 | void setRowStyle( int style ); |
68 | 79 | ||
69 | public slots: | 80 | public slots: |
70 | void moveUp(); | 81 | void moveUp(); |
71 | void moveDown(); | 82 | void moveDown(); |
72 | void slotDateChanged( int year, int month, int day ); | 83 | void slotDateChanged( int year, int month, int day ); |
73 | 84 | ||
74 | signals: | 85 | signals: |
75 | void sigColWidthChanged(); | 86 | void sigColWidthChanged(); |
76 | void sigCapturedKey( const QString &txt ); | 87 | void sigCapturedKey( const QString &txt ); |
77 | protected slots: | 88 | protected slots: |
78 | void slotChangeClock( bool ); | 89 | void slotChangeClock( bool ); |
79 | protected: | 90 | protected: |
80 | virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); | 91 | virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); |
81 | virtual void paintFocus( QPainter *p, const QRect &cr ); | 92 | virtual void paintFocus( QPainter *p, const QRect &cr ); |
82 | 93 | ||
83 | virtual void resizeEvent( QResizeEvent *e ); | 94 | virtual void resizeEvent( QResizeEvent *e ); |
84 | void keyPressEvent( QKeyEvent *e ); | 95 | void keyPressEvent( QKeyEvent *e ); |
85 | void contentsMouseReleaseEvent( QMouseEvent *e ); | 96 | void contentsMouseReleaseEvent( QMouseEvent *e ); |
86 | void initHeader(); | 97 | void initHeader(); |
87 | private: | 98 | private: |
88 | bool ampm; | 99 | bool ampm; |
89 | QDate currDate; | 100 | QDate currDate; |
90 | DateBookDayViewQuickLineEdit *quickLineEdit; | 101 | DateBookDayViewQuickLineEdit *quickLineEdit; |
91 | }; | 102 | }; |
92 | 103 | ||
93 | class DateBookDay; | 104 | class DateBookDay; |
94 | class DateBookDayWidget : public QWidget | 105 | class DateBookDayWidget : public QWidget |
95 | { | 106 | { |
96 | Q_OBJECT | 107 | Q_OBJECT |
97 | 108 | ||
98 | public: | 109 | public: |
99 | DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ); | 110 | DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ); |
100 | ~DateBookDayWidget(); | 111 | ~DateBookDayWidget(); |
101 | 112 | ||
102 | const QRect &geometry() { return geom; } | 113 | const QRect &geometry() { return geom; } |
103 | void setGeometry( const QRect &r ); | 114 | void setGeometry( const QRect &r ); |
104 | 115 | ||
105 | const EffectiveEvent &event() const { return ev; } | 116 | const EffectiveEvent &event() const { return ev; } |
106 | 117 | ||
107 | signals: | 118 | signals: |
108 | void deleteMe( const Event &e ); | 119 | void deleteMe( const Event &e ); |
109 | void duplicateMe( const Event &e ); | 120 | void duplicateMe( const Event &e ); |
110 | void editMe( const Event &e ); | 121 | void editMe( const Event &e ); |
111 | void beamMe( const Event &e ); | 122 | void beamMe( const Event &e ); |
112 | 123 | ||
113 | protected: | 124 | protected: |
114 | void paintEvent( QPaintEvent *e ); | 125 | void paintEvent( QPaintEvent *e ); |
115 | void mousePressEvent( QMouseEvent *e ); | 126 | void mousePressEvent( QMouseEvent *e ); |
116 | 127 | ||
117 | private: | 128 | private: |
118 | /** | 129 | /** |
119 | * Sets the text for an all day Event | 130 | * Sets the text for an all day Event |
120 | * All day events have no time associated | 131 | * All day events have no time associated |
121 | */ | 132 | */ |
122 | void setAllDayText( QString& text ); | 133 | void setAllDayText( QString& text ); |
123 | 134 | ||
124 | /** | 135 | /** |
125 | * Sets the EventText | 136 | * Sets the EventText |
126 | * it got a start and an end Time | 137 | * it got a start and an end Time |
127 | */ | 138 | */ |
128 | void setEventText( QString& text ); | 139 | void setEventText( QString& text ); |
129 | EffectiveEvent ev; | 140 | EffectiveEvent ev; |
130 | DateBookDay *dateBook; | 141 | DateBookDay *dateBook; |
131 | QString text; | 142 | QString text; |
132 | QRect geom; | 143 | QRect geom; |
133 | }; | 144 | }; |
134 | 145 | ||
135 | //Marker for current time in the dayview | 146 | //Marker for current time in the dayview |
136 | class DateBookDayTimeMarker : public QWidget | 147 | class DateBookDayTimeMarker : public QWidget |
137 | { | 148 | { |
138 | Q_OBJECT | 149 | Q_OBJECT |
139 | 150 | ||
140 | public: | 151 | public: |
141 | DateBookDayTimeMarker( DateBookDay *db ); | 152 | DateBookDayTimeMarker( DateBookDay *db ); |
142 | ~DateBookDayTimeMarker(); | 153 | ~DateBookDayTimeMarker(); |
143 | 154 | ||
144 | const QRect &geometry() { return geom; } | 155 | const QRect &geometry() { return geom; } |
145 | void setGeometry( const QRect &r ); | 156 | void setGeometry( const QRect &r ); |
146 | void setTime( const QTime &t ); | 157 | void setTime( const QTime &t ); |
147 | 158 | ||
148 | signals: | 159 | signals: |
149 | 160 | ||
150 | protected: | 161 | protected: |
151 | void paintEvent( QPaintEvent *e ); | 162 | void paintEvent( QPaintEvent *e ); |
152 | 163 | ||
153 | private: | 164 | private: |
154 | QRect geom; | 165 | QRect geom; |
155 | QTime time; | 166 | QTime time; |
156 | DateBookDay *dateBook; | 167 | DateBookDay *dateBook; |
157 | }; | 168 | }; |
158 | 169 | ||
159 | //reimplemented the compareItems function so that it sorts DayWidgets by geometry heights | 170 | //reimplemented the compareItems function so that it sorts DayWidgets by geometry heights |
160 | class WidgetListClass : public QList<DateBookDayWidget> | 171 | class WidgetListClass : public QList<DateBookDayWidget> |
161 | { | 172 | { |
162 | private: | 173 | private: |
163 | 174 | ||
164 | int compareItems( QCollection::Item s1, QCollection::Item s2 ) | 175 | int compareItems( QCollection::Item s1, QCollection::Item s2 ) |
165 | { | 176 | { |
166 | //hmm, don't punish me for that ;) | 177 | //hmm, don't punish me for that ;) |
167 | if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height()) | 178 | if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height()) |
168 | { | 179 | { |
169 | return -1; | 180 | return -1; |
170 | } else | 181 | } else |
171 | { | 182 | { |
172 | return 1; | 183 | return 1; |
173 | } | 184 | } |
174 | } | 185 | } |
175 | 186 | ||
176 | 187 | ||
177 | }; | 188 | }; |
178 | 189 | ||
179 | class DateBookDay : public QVBox | 190 | class DateBookDay : public QVBox |
180 | { | 191 | { |
181 | Q_OBJECT | 192 | Q_OBJECT |
182 | 193 | ||
183 | friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB | 194 | friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB |
184 | public: | 195 | public: |
185 | DateBookDay( bool ampm, bool startOnMonday, DateBookDBHoliday *newDb,DateBookHoliday*newHdb, | 196 | DateBookDay( bool ampm, bool startOnMonday, DateBookDBHoliday *newDb,DateBookHoliday*newHdb, |
186 | QWidget *parent, const char *name ); | 197 | QWidget *parent, const char *name ); |
187 | void selectedDates( QDateTime &start, QDateTime &end ); | 198 | void selectedDates( QDateTime &start, QDateTime &end ); |
188 | 199 | ||
189 | QDate date() const; | 200 | QDate date() const; |
190 | DateBookDayView *dayView() const { return view; } | 201 | DateBookDayView *dayView() const { return view; } |
191 | void setStartViewTime( int startHere ); | 202 | void setStartViewTime( int startHere ); |
192 | int startViewTime() const; | 203 | int startViewTime() const; |
193 | void setSelectedWidget( DateBookDayWidget * ); | 204 | void setSelectedWidget( DateBookDayWidget * ); |
194 | DateBookDayWidget * getSelectedWidget( void ); | 205 | DateBookDayWidget * getSelectedWidget( void ); |
195 | void setJumpToCurTime( bool bJump ); | 206 | void setJumpToCurTime( bool bJump ); |
196 | void setRowStyle( int style ); | 207 | void setRowStyle( int style ); |
197 | static QDate findRealStart( int uid, const QDate& isIncluded, | 208 | static QDate findRealStart( int uid, const QDate& isIncluded, |
198 | DateBookDB* ); | 209 | DateBookDB* ); |
199 | 210 | ||
200 | public slots: | 211 | public slots: |
201 | void setDate( int y, int m, int d ); | 212 | void setDate( int y, int m, int d ); |
202 | void setDate( QDate ); | 213 | void setDate( QDate ); |
203 | void redraw(); | 214 | void redraw(); |
204 | void slotWeekChanged( bool bStartOnMonday ); | 215 | void slotWeekChanged( bool bStartOnMonday ); |
205 | void updateView(); //updates TimeMarker and DayWidget-colors | 216 | void updateView(); //updates TimeMarker and DayWidget-colors |
206 | 217 | ||
207 | signals: | 218 | signals: |
208 | void removeEvent( const Event& ); | 219 | void removeEvent( const Event& ); |
209 | void editEvent( const Event& ); | 220 | void editEvent( const Event& ); |
210 | void duplicateEvent( const Event& ); | 221 | void duplicateEvent( const Event& ); |
211 | void beamEvent( const Event& ); | 222 | void beamEvent( const Event& ); |
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp index 27fce44..3807542 100644 --- a/core/pim/datebook/datebookdayallday.cpp +++ b/core/pim/datebook/datebookdayallday.cpp | |||
@@ -1,200 +1,223 @@ | |||
1 | /**************************************************************************** | 1 | /* |
2 | ** GPL by Rajko Albrecht | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** | 4 | Copyright (C) Rajko Albrecht <> |
5 | ** | 5 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
6 | ** | 6 | =. |
7 | ** | 7 | .=l. |
8 | ****************************************************************************/ | 8 | .>+-= |
9 | _;:, .> :=|. This program is free software; you can | ||
10 | .> <`_, > . <= redistribute it and/or modify it under | ||
11 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
12 | .="- .-=="i, .._ License as published by the Free Software | ||
13 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
14 | ._= =} : or (at your option) any later version. | ||
15 | .%`+i> _;_. | ||
16 | .i_,=:_. -<s. This program is distributed in the hope that | ||
17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
18 | : .. .:, . . . without even the implied warranty of | ||
19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
21 | ..}^=.= = ; Library General Public License for more | ||
22 | ++= -. .` .: details. | ||
23 | : = ...= . :.=- | ||
24 | -. .:....=;==+<; You should have received a copy of the GNU | ||
25 | -_. . . )=. = Library General Public License along with | ||
26 | -- :-=` this library; see the file COPYING.LIB. | ||
27 | If not, write to the Free Software Foundation, | ||
28 | Inc., 59 Temple Place - Suite 330, | ||
29 | Boston, MA 02111-1307, USA. | ||
30 | */ | ||
31 | |||
9 | #include "datebookdayallday.h" | 32 | #include "datebookdayallday.h" |
10 | 33 | ||
11 | #include <qlayout.h> | 34 | #include <qlayout.h> |
12 | #include <qpe/ir.h> | 35 | #include <qpe/ir.h> |
13 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
14 | #include <qtimer.h> | 37 | #include <qtimer.h> |
15 | 38 | ||
16 | #include "datebookday.h" | 39 | #include "datebookday.h" |
17 | 40 | ||
18 | /* | 41 | /* |
19 | * Constructs a DatebookdayAllday which is a child of 'parent', with the | 42 | * Constructs a DatebookdayAllday which is a child of 'parent', with the |
20 | * name 'name' and widget flags set to 'f' | 43 | * name 'name' and widget flags set to 'f' |
21 | */ | 44 | */ |
22 | DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags ) | 45 | DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags ) |
23 | : QScrollView( parent, name ),item_count(0),dateBook(db) | 46 | : QScrollView( parent, name ),item_count(0),dateBook(db) |
24 | { | 47 | { |
25 | if ( !name ) | 48 | if ( !name ) |
26 | setName( "DatebookdayAllday" ); | 49 | setName( "DatebookdayAllday" ); |
27 | setMinimumSize( QSize( 0, 0 ) ); | 50 | setMinimumSize( QSize( 0, 0 ) ); |
28 | setMaximumHeight(3* (QFontMetrics(font()).height()+4) ); | 51 | setMaximumHeight(3* (QFontMetrics(font()).height()+4) ); |
29 | 52 | ||
30 | m_MainFrame = new QFrame(viewport()); | 53 | m_MainFrame = new QFrame(viewport()); |
31 | m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain); | 54 | m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain); |
32 | setFrameStyle(QFrame::NoFrame|QFrame::Plain); | 55 | setFrameStyle(QFrame::NoFrame|QFrame::Plain); |
33 | //setResizePolicy( QScrollView::Default ); | 56 | //setResizePolicy( QScrollView::Default ); |
34 | setResizePolicy(QScrollView::AutoOneFit); | 57 | setResizePolicy(QScrollView::AutoOneFit); |
35 | setHScrollBarMode( AlwaysOff ); | 58 | setHScrollBarMode( AlwaysOff ); |
36 | addChild(m_MainFrame); | 59 | addChild(m_MainFrame); |
37 | 60 | ||
38 | datebookdayalldayLayout = new QVBoxLayout( m_MainFrame ); | 61 | datebookdayalldayLayout = new QVBoxLayout( m_MainFrame ); |
39 | datebookdayalldayLayout->setSpacing( 0 ); | 62 | datebookdayalldayLayout->setSpacing( 0 ); |
40 | datebookdayalldayLayout->setMargin( 0 ); | 63 | datebookdayalldayLayout->setMargin( 0 ); |
41 | 64 | ||
42 | lblDesc = new DatebookEventDesc(parent->parentWidget(),""); | 65 | lblDesc = new DatebookEventDesc(parent->parentWidget(),""); |
43 | lblDesc->setBackgroundColor(Qt::yellow); | 66 | lblDesc->setBackgroundColor(Qt::yellow); |
44 | lblDesc->hide(); | 67 | lblDesc->hide(); |
45 | subWidgets.setAutoDelete(true); | 68 | subWidgets.setAutoDelete(true); |
46 | } | 69 | } |
47 | 70 | ||
48 | /* | 71 | /* |
49 | * Destroys the object and frees any allocated resources | 72 | * Destroys the object and frees any allocated resources |
50 | */ | 73 | */ |
51 | DatebookdayAllday::~DatebookdayAllday() | 74 | DatebookdayAllday::~DatebookdayAllday() |
52 | { | 75 | { |
53 | // no need to delete child widgets, Qt does it all for us | 76 | // no need to delete child widgets, Qt does it all for us |
54 | } | 77 | } |
55 | 78 | ||
56 | DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) | 79 | DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) |
57 | { | 80 | { |
58 | DatebookAlldayDisp * lb; | 81 | DatebookAlldayDisp * lb; |
59 | lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL); | 82 | lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL); |
60 | lb->show(); | 83 | lb->show(); |
61 | datebookdayalldayLayout->addWidget(lb); | 84 | datebookdayalldayLayout->addWidget(lb); |
62 | subWidgets.append(lb); | 85 | subWidgets.append(lb); |
63 | 86 | ||
64 | connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&))); | 87 | connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&))); |
65 | ++item_count; | 88 | ++item_count; |
66 | 89 | ||
67 | return lb; | 90 | return lb; |
68 | } | 91 | } |
69 | 92 | ||
70 | DatebookAlldayDisp* DatebookdayAllday::addHoliday(const QString&e) | 93 | DatebookAlldayDisp* DatebookdayAllday::addHoliday(const QString&e) |
71 | { | 94 | { |
72 | DatebookAlldayDisp * lb; | 95 | DatebookAlldayDisp * lb; |
73 | lb = new DatebookAlldayDisp(e,m_MainFrame,NULL); | 96 | lb = new DatebookAlldayDisp(e,m_MainFrame,NULL); |
74 | lb->show(); | 97 | lb->show(); |
75 | datebookdayalldayLayout->addWidget(lb); | 98 | datebookdayalldayLayout->addWidget(lb); |
76 | subWidgets.append(lb); | 99 | subWidgets.append(lb); |
77 | 100 | ||
78 | connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&))); | 101 | connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&))); |
79 | ++item_count; | 102 | ++item_count; |
80 | 103 | ||
81 | return lb; | 104 | return lb; |
82 | } | 105 | } |
83 | 106 | ||
84 | void DatebookdayAllday::removeAllEvents() | 107 | void DatebookdayAllday::removeAllEvents() |
85 | { | 108 | { |
86 | subWidgets.clear(); | 109 | subWidgets.clear(); |
87 | item_count = 0; | 110 | item_count = 0; |
88 | } | 111 | } |
89 | 112 | ||
90 | DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, | 113 | DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, |
91 | QWidget* parent,const char* name,WFlags f) | 114 | QWidget* parent,const char* name,WFlags f) |
92 | : QLabel(parent,name,f),m_Ev(ev),dateBook(db) | 115 | : QLabel(parent,name,f),m_Ev(ev),dateBook(db) |
93 | { | 116 | { |
94 | QString strDesc = m_Ev.description(); | 117 | QString strDesc = m_Ev.description(); |
95 | strDesc = strDesc.replace(QRegExp("<"),"<"); | 118 | strDesc = strDesc.replace(QRegExp("<"),"<"); |
96 | setBackgroundColor(yellow); | 119 | setBackgroundColor(yellow); |
97 | setText(strDesc); | 120 | setText(strDesc); |
98 | setFrameStyle(QFrame::Raised|QFrame::Panel); | 121 | setFrameStyle(QFrame::Raised|QFrame::Panel); |
99 | 122 | ||
100 | int s = QFontMetrics(font()).height()+4; | 123 | int s = QFontMetrics(font()).height()+4; |
101 | setMaximumHeight( s ); | 124 | setMaximumHeight( s ); |
102 | setMinimumSize( QSize( 0, s ) ); | 125 | setMinimumSize( QSize( 0, s ) ); |
103 | m_holiday = false; | 126 | m_holiday = false; |
104 | } | 127 | } |
105 | 128 | ||
106 | DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,const char* name, WFlags fl) | 129 | DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,const char* name, WFlags fl) |
107 | : QLabel(parent,name,fl),m_Ev(),dateBook(0) | 130 | : QLabel(parent,name,fl),m_Ev(),dateBook(0) |
108 | { | 131 | { |
109 | QString strDesc = aholiday; | 132 | QString strDesc = aholiday; |
110 | strDesc = strDesc.replace(QRegExp("<"),"<"); | 133 | strDesc = strDesc.replace(QRegExp("<"),"<"); |
111 | Event ev; | 134 | Event ev; |
112 | ev.setDescription(strDesc); | 135 | ev.setDescription(strDesc); |
113 | ev.setAllDay(true); | 136 | ev.setAllDay(true); |
114 | m_Ev.setEvent(ev); | 137 | m_Ev.setEvent(ev); |
115 | setText(strDesc); | 138 | setText(strDesc); |
116 | 139 | ||
117 | setAlignment(AlignHCenter); | 140 | setAlignment(AlignHCenter); |
118 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum)); | 141 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum)); |
119 | 142 | ||
120 | //setFrameStyle(QFrame::Raised|QFrame::Panel); | 143 | //setFrameStyle(QFrame::Raised|QFrame::Panel); |
121 | //setBackgroundColor(yellow); | 144 | //setBackgroundColor(yellow); |
122 | 145 | ||
123 | int s = QFontMetrics(font()).height()+4; | 146 | int s = QFontMetrics(font()).height()+4; |
124 | setMaximumHeight( s ); | 147 | setMaximumHeight( s ); |
125 | setMinimumSize( QSize( 0, s ) ); | 148 | setMinimumSize( QSize( 0, s ) ); |
126 | 149 | ||
127 | m_holiday = true; | 150 | m_holiday = true; |
128 | } | 151 | } |
129 | 152 | ||
130 | DatebookAlldayDisp::~DatebookAlldayDisp() | 153 | DatebookAlldayDisp::~DatebookAlldayDisp() |
131 | { | 154 | { |
132 | } | 155 | } |
133 | 156 | ||
134 | void DatebookAlldayDisp::beam_single_event() | 157 | void DatebookAlldayDisp::beam_single_event() |
135 | { | 158 | { |
136 | if (m_holiday) return; | 159 | if (m_holiday) return; |
137 | // create an Event and beam it... | 160 | // create an Event and beam it... |
138 | /* | 161 | /* |
139 | * Start with the easy stuff. If start and end date is the same we can just use | 162 | * Start with the easy stuff. If start and end date is the same we can just use |
140 | * the values of effective m_Events | 163 | * the values of effective m_Events |
141 | * If it is a multi day m_Event we need to find the real start and end date... | 164 | * If it is a multi day m_Event we need to find the real start and end date... |
142 | */ | 165 | */ |
143 | if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { | 166 | if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { |
144 | Event m_Event( m_Ev.event() ); | 167 | Event m_Event( m_Ev.event() ); |
145 | 168 | ||
146 | QDateTime dt( m_Ev.date(), m_Ev.start() ); | 169 | QDateTime dt( m_Ev.date(), m_Ev.start() ); |
147 | m_Event.setStart( dt ); | 170 | m_Event.setStart( dt ); |
148 | 171 | ||
149 | dt.setTime( m_Ev.end() ); | 172 | dt.setTime( m_Ev.end() ); |
150 | m_Event.setEnd( dt ); | 173 | m_Event.setEnd( dt ); |
151 | emit beamMe( m_Event ); | 174 | emit beamMe( m_Event ); |
152 | }else { | 175 | }else { |
153 | /* | 176 | /* |
154 | * at least the the Times are right now | 177 | * at least the the Times are right now |
155 | */ | 178 | */ |
156 | QDateTime start( m_Ev.event().start() ); | 179 | QDateTime start( m_Ev.event().start() ); |
157 | QDateTime end ( m_Ev.event().end () ); | 180 | QDateTime end ( m_Ev.event().end () ); |
158 | 181 | ||
159 | /* | 182 | /* |
160 | * ok we know the start date or we need to find it | 183 | * ok we know the start date or we need to find it |
161 | */ | 184 | */ |
162 | if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { | 185 | if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { |
163 | start.setDate( m_Ev.date() ); | 186 | start.setDate( m_Ev.date() ); |
164 | }else { | 187 | }else { |
165 | QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook ); | 188 | QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook ); |
166 | start.setDate( dt ); | 189 | start.setDate( dt ); |
167 | } | 190 | } |
168 | 191 | ||
169 | /* | 192 | /* |
170 | * ok we know now the end date... | 193 | * ok we know now the end date... |
171 | * else | 194 | * else |
172 | * get to know the offset btw the real start and real end | 195 | * get to know the offset btw the real start and real end |
173 | * and then add it to the new start date... | 196 | * and then add it to the new start date... |
174 | */ | 197 | */ |
175 | if ( m_Ev.end() != QTime(23, 59, 59 ) ) { | 198 | if ( m_Ev.end() != QTime(23, 59, 59 ) ) { |
176 | end.setDate( m_Ev.date() ); | 199 | end.setDate( m_Ev.date() ); |
177 | }else{ | 200 | }else{ |
178 | int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() ); | 201 | int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() ); |
179 | end.setDate( start.date().addDays( days ) ); | 202 | end.setDate( start.date().addDays( days ) ); |
180 | } | 203 | } |
181 | Event m_Event( m_Ev.event() ); | 204 | Event m_Event( m_Ev.event() ); |
182 | m_Event.setStart( start ); | 205 | m_Event.setStart( start ); |
183 | m_Event.setEnd ( end ); | 206 | m_Event.setEnd ( end ); |
184 | emit beamMe( m_Event ); | 207 | emit beamMe( m_Event ); |
185 | } | 208 | } |
186 | } | 209 | } |
187 | 210 | ||
188 | void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) | 211 | void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) |
189 | { | 212 | { |
190 | Event ev = m_Ev.event(); | 213 | Event ev = m_Ev.event(); |
191 | QColor b = backgroundColor(); | 214 | QColor b = backgroundColor(); |
192 | setBackgroundColor(green); | 215 | setBackgroundColor(green); |
193 | update(); | 216 | update(); |
194 | QPopupMenu m; | 217 | QPopupMenu m; |
195 | if (ev.isValidUid()) { | 218 | if (ev.isValidUid()) { |
196 | m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); | 219 | m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); |
197 | m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); | 220 | m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); |
198 | m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); | 221 | m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); |
199 | if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); | 222 | if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); |
200 | if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); | 223 | if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); |
diff --git a/core/pim/datebook/datebookdayallday.h b/core/pim/datebook/datebookdayallday.h index 4f5cffa..5395dcf 100644 --- a/core/pim/datebook/datebookdayallday.h +++ b/core/pim/datebook/datebookdayallday.h | |||
@@ -1,86 +1,117 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (C) Rajko Albrecht <> | ||
5 | Copyright (C) Opie Team <opie-devel@handhelds.org> | ||
6 | =. | ||
7 | .=l. | ||
8 | .>+-= | ||
9 | _;:, .> :=|. This program is free software; you can | ||
10 | .> <`_, > . <= redistribute it and/or modify it under | ||
11 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
12 | .="- .-=="i, .._ License as published by the Free Software | ||
13 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
14 | ._= =} : or (at your option) any later version. | ||
15 | .%`+i> _;_. | ||
16 | .i_,=:_. -<s. This program is distributed in the hope that | ||
17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
18 | : .. .:, . . . without even the implied warranty of | ||
19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
21 | ..}^=.= = ; Library General Public License for more | ||
22 | ++= -. .` .: details. | ||
23 | : = ...= . :.=- | ||
24 | -. .:....=;==+<; You should have received a copy of the GNU | ||
25 | -_. . . )=. = Library General Public License along with | ||
26 | -- :-=` this library; see the file COPYING.LIB. | ||
27 | If not, write to the Free Software Foundation, | ||
28 | Inc., 59 Temple Place - Suite 330, | ||
29 | Boston, MA 02111-1307, USA. | ||
30 | */ | ||
31 | |||
1 | #ifndef DATEBOOKDAYALLDAYBASE_H | 32 | #ifndef DATEBOOKDAYALLDAYBASE_H |
2 | #define DATEBOOKDAYALLDAYBASE_H | 33 | #define DATEBOOKDAYALLDAYBASE_H |
3 | 34 | ||
4 | #include <qvariant.h> | 35 | #include <qvariant.h> |
5 | #include <qframe.h> | 36 | #include <qframe.h> |
6 | #include <qscrollview.h> | 37 | #include <qscrollview.h> |
7 | #include <qlabel.h> | 38 | #include <qlabel.h> |
8 | #include <qlist.h> | 39 | #include <qlist.h> |
9 | #include <qpe/event.h> | 40 | #include <qpe/event.h> |
10 | 41 | ||
11 | class QVBoxLayout; | 42 | class QVBoxLayout; |
12 | class QHBoxLayout; | 43 | class QHBoxLayout; |
13 | class QGridLayout; | 44 | class QGridLayout; |
14 | class DatebookAlldayDisp; | 45 | class DatebookAlldayDisp; |
15 | class DatebookEventDesc; | 46 | class DatebookEventDesc; |
16 | class DateBookDB; | 47 | class DateBookDB; |
17 | 48 | ||
18 | class DatebookdayAllday : public QScrollView | 49 | class DatebookdayAllday : public QScrollView |
19 | { | 50 | { |
20 | Q_OBJECT | 51 | Q_OBJECT |
21 | 52 | ||
22 | public: | 53 | public: |
23 | DatebookdayAllday(DateBookDB* db, | 54 | DatebookdayAllday(DateBookDB* db, |
24 | QWidget* parent = 0, const char* name = 0, WFlags fl = 0); | 55 | QWidget* parent = 0, const char* name = 0, WFlags fl = 0); |
25 | ~DatebookdayAllday(); | 56 | ~DatebookdayAllday(); |
26 | DatebookAlldayDisp* addEvent(const EffectiveEvent&e); | 57 | DatebookAlldayDisp* addEvent(const EffectiveEvent&e); |
27 | DatebookAlldayDisp* addHoliday(const QString&e); | 58 | DatebookAlldayDisp* addHoliday(const QString&e); |
28 | const unsigned int items()const{return item_count;} | 59 | const unsigned int items()const{return item_count;} |
29 | 60 | ||
30 | public slots: | 61 | public slots: |
31 | void removeAllEvents(); | 62 | void removeAllEvents(); |
32 | 63 | ||
33 | protected: | 64 | protected: |
34 | QFrame * m_MainFrame; | 65 | QFrame * m_MainFrame; |
35 | QVBoxLayout* datebookdayalldayLayout; | 66 | QVBoxLayout* datebookdayalldayLayout; |
36 | DatebookEventDesc * lblDesc; | 67 | DatebookEventDesc * lblDesc; |
37 | unsigned int item_count; | 68 | unsigned int item_count; |
38 | QList<DatebookAlldayDisp> subWidgets; | 69 | QList<DatebookAlldayDisp> subWidgets; |
39 | DateBookDB *dateBook; | 70 | DateBookDB *dateBook; |
40 | }; | 71 | }; |
41 | 72 | ||
42 | class DatebookAlldayDisp : public QLabel | 73 | class DatebookAlldayDisp : public QLabel |
43 | { | 74 | { |
44 | Q_OBJECT | 75 | Q_OBJECT |
45 | 76 | ||
46 | public: | 77 | public: |
47 | DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e, | 78 | DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e, |
48 | QWidget* parent=0,const char* name = 0, WFlags fl=0); | 79 | QWidget* parent=0,const char* name = 0, WFlags fl=0); |
49 | DatebookAlldayDisp(const QString&aholiday, | 80 | DatebookAlldayDisp(const QString&aholiday, |
50 | QWidget* parent=0,const char* name = 0, WFlags fl=0); | 81 | QWidget* parent=0,const char* name = 0, WFlags fl=0); |
51 | virtual ~DatebookAlldayDisp(); | 82 | virtual ~DatebookAlldayDisp(); |
52 | 83 | ||
53 | signals: | 84 | signals: |
54 | void deleteMe( const Event &e ); | 85 | void deleteMe( const Event &e ); |
55 | void duplicateMe( const Event &e ); | 86 | void duplicateMe( const Event &e ); |
56 | void editMe( const Event &e ); | 87 | void editMe( const Event &e ); |
57 | void beamMe( const Event &e ); | 88 | void beamMe( const Event &e ); |
58 | void displayMe(const Event &e); | 89 | void displayMe(const Event &e); |
59 | 90 | ||
60 | public slots: | 91 | public slots: |
61 | 92 | ||
62 | protected: | 93 | protected: |
63 | EffectiveEvent m_Ev; | 94 | EffectiveEvent m_Ev; |
64 | DateBookDB* dateBook; | 95 | DateBookDB* dateBook; |
65 | void mousePressEvent( QMouseEvent *e ); | 96 | void mousePressEvent( QMouseEvent *e ); |
66 | void beam_single_event(); | 97 | void beam_single_event(); |
67 | bool m_holiday:1; | 98 | bool m_holiday:1; |
68 | }; | 99 | }; |
69 | 100 | ||
70 | class DatebookEventDesc: public QLabel | 101 | class DatebookEventDesc: public QLabel |
71 | { | 102 | { |
72 | Q_OBJECT | 103 | Q_OBJECT |
73 | 104 | ||
74 | public: | 105 | public: |
75 | DatebookEventDesc(QWidget* Parent=0,const char* name = 0); | 106 | DatebookEventDesc(QWidget* Parent=0,const char* name = 0); |
76 | virtual ~DatebookEventDesc(); | 107 | virtual ~DatebookEventDesc(); |
77 | 108 | ||
78 | public slots: | 109 | public slots: |
79 | void disp_event(const Event&e); | 110 | void disp_event(const Event&e); |
80 | 111 | ||
81 | protected: | 112 | protected: |
82 | void mousePressEvent(QMouseEvent*e); | 113 | void mousePressEvent(QMouseEvent*e); |
83 | QTimer* m_Timer; | 114 | QTimer* m_Timer; |
84 | }; | 115 | }; |
85 | 116 | ||
86 | #endif // DATEBOOKDAYALLDAYBASE_H | 117 | #endif // DATEBOOKDAYALLDAYBASE_H |
diff --git a/core/pim/datebook/datebookdayheaderimpl.cpp b/core/pim/datebook/datebookdayheaderimpl.cpp index 51b78ca..0df1bfe 100644 --- a/core/pim/datebook/datebookdayheaderimpl.cpp +++ b/core/pim/datebook/datebookdayheaderimpl.cpp | |||
@@ -1,200 +1,212 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
20 | #include "datebookdayheaderimpl.h" | 31 | #include "datebookdayheaderimpl.h" |
21 | 32 | ||
33 | #include <opie2/oresource.h> | ||
34 | |||
22 | #include <qpe/datebookmonth.h> | 35 | #include <qpe/datebookmonth.h> |
23 | #include <qpe/resource.h> | ||
24 | 36 | ||
25 | #include <qbuttongroup.h> | 37 | #include <qbuttongroup.h> |
26 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
27 | 39 | ||
28 | 40 | ||
29 | /* | 41 | /* |
30 | * Constructs a DateBookDayHeader which is a child of 'parent', with the | 42 | * Constructs a DateBookDayHeader which is a child of 'parent', with the |
31 | * name 'name' and widget flags set to 'f' | 43 | * name 'name' and widget flags set to 'f' |
32 | * | 44 | * |
33 | * The dialog will by default be modeless, unless you set 'modal' to | 45 | * The dialog will by default be modeless, unless you set 'modal' to |
34 | * TRUE to construct a modal dialog. | 46 | * TRUE to construct a modal dialog. |
35 | */ | 47 | */ |
36 | DateBookDayHeader::DateBookDayHeader( bool useMonday, | 48 | DateBookDayHeader::DateBookDayHeader( bool useMonday, |
37 | QWidget* parent, const char* name ) | 49 | QWidget* parent, const char* name ) |
38 | : DateBookDayHeaderBase( parent, name ), | 50 | : DateBookDayHeaderBase( parent, name ), |
39 | bUseMonday( useMonday ) | 51 | bUseMonday( useMonday ) |
40 | { | 52 | { |
41 | connect(date,SIGNAL(pressed()),this,SLOT(pickDate())); | 53 | connect(date,SIGNAL(pressed()),this,SLOT(pickDate())); |
42 | 54 | ||
43 | setupNames(); | 55 | setupNames(); |
44 | 56 | ||
45 | forward->setPixmap( Resource::loadPixmap( "forward" ) ); | 57 | forward->setPixmap( Opie::Core::OResource::loadPixmap( "forward" ) ); |
46 | back->setPixmap( Resource::loadPixmap( "back" ) ); | 58 | back->setPixmap( Opie::Core::OResource::loadPixmap( "back" ) ); |
47 | forwardweek->setPixmap( Resource::loadPixmap( "fastforward" ) ); | 59 | forwardweek->setPixmap( Opie::Core::OResource::loadPixmap( "fastforward" ) ); |
48 | backweek->setPixmap( Resource::loadPixmap( "fastback" ) ); | 60 | backweek->setPixmap( Opie::Core::OResource::loadPixmap( "fastback" ) ); |
49 | 61 | ||
50 | setBackgroundMode( PaletteButton ); | 62 | setBackgroundMode( PaletteButton ); |
51 | grpDays->setBackgroundMode( PaletteButton ); | 63 | grpDays->setBackgroundMode( PaletteButton ); |
52 | } | 64 | } |
53 | 65 | ||
54 | /* | 66 | /* |
55 | * Destroys the object and frees any allocated resources | 67 | * Destroys the object and frees any allocated resources |
56 | */ | 68 | */ |
57 | DateBookDayHeader::~DateBookDayHeader() | 69 | DateBookDayHeader::~DateBookDayHeader() |
58 | { | 70 | { |
59 | // no need to delete child widgets, Qt does it all for us | 71 | // no need to delete child widgets, Qt does it all for us |
60 | } | 72 | } |
61 | 73 | ||
62 | void DateBookDayHeader::setStartOfWeek( bool onMonday ) | 74 | void DateBookDayHeader::setStartOfWeek( bool onMonday ) |
63 | { | 75 | { |
64 | bUseMonday = onMonday; | 76 | bUseMonday = onMonday; |
65 | setupNames(); | 77 | setupNames(); |
66 | setDate( currDate.year(), currDate.month(), currDate.day() ); | 78 | setDate( currDate.year(), currDate.month(), currDate.day() ); |
67 | } | 79 | } |
68 | 80 | ||
69 | void DateBookDayHeader::setupNames() | 81 | void DateBookDayHeader::setupNames() |
70 | { | 82 | { |
71 | if ( bUseMonday ) { | 83 | if ( bUseMonday ) { |
72 | cmdDay1->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); | 84 | cmdDay1->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); |
73 | cmdDay2->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); | 85 | cmdDay2->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); |
74 | cmdDay3->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); | 86 | cmdDay3->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); |
75 | cmdDay4->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); | 87 | cmdDay4->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); |
76 | cmdDay5->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); | 88 | cmdDay5->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); |
77 | cmdDay6->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); | 89 | cmdDay6->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); |
78 | cmdDay7->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); | 90 | cmdDay7->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); |
79 | } else { | 91 | } else { |
80 | cmdDay1->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); | 92 | cmdDay1->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); |
81 | cmdDay2->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); | 93 | cmdDay2->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); |
82 | cmdDay3->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); | 94 | cmdDay3->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); |
83 | cmdDay4->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); | 95 | cmdDay4->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); |
84 | cmdDay5->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); | 96 | cmdDay5->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); |
85 | cmdDay6->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); | 97 | cmdDay6->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); |
86 | cmdDay7->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); | 98 | cmdDay7->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); |
87 | } | 99 | } |
88 | } | 100 | } |
89 | 101 | ||
90 | 102 | ||
91 | void DateBookDayHeader::pickDate() | 103 | void DateBookDayHeader::pickDate() |
92 | { | 104 | { |
93 | static QPopupMenu *m1 = 0; | 105 | static QPopupMenu *m1 = 0; |
94 | static DateBookMonth *picker = 0; | 106 | static DateBookMonth *picker = 0; |
95 | if ( !m1 ) { | 107 | if ( !m1 ) { |
96 | m1 = new QPopupMenu( this ); | 108 | m1 = new QPopupMenu( this ); |
97 | picker = new DateBookMonth( m1, 0, TRUE ); | 109 | picker = new DateBookMonth( m1, 0, TRUE ); |
98 | m1->insertItem( picker ); | 110 | m1->insertItem( picker ); |
99 | connect( picker, SIGNAL( dateClicked(int,int,int) ), | 111 | connect( picker, SIGNAL( dateClicked(int,int,int) ), |
100 | this, SLOT( setDate(int,int,int) ) ); | 112 | this, SLOT( setDate(int,int,int) ) ); |
101 | connect( m1, SIGNAL( aboutToHide() ), | 113 | connect( m1, SIGNAL( aboutToHide() ), |
102 | this, SLOT( gotHide() ) ); | 114 | this, SLOT( gotHide() ) ); |
103 | } | 115 | } |
104 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); | 116 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); |
105 | m1->popup(mapToGlobal(date->pos()+QPoint(0,date->height()))); | 117 | m1->popup(mapToGlobal(date->pos()+QPoint(0,date->height()))); |
106 | picker->setFocus(); | 118 | picker->setFocus(); |
107 | } | 119 | } |
108 | 120 | ||
109 | void DateBookDayHeader::gotHide() | 121 | void DateBookDayHeader::gotHide() |
110 | { | 122 | { |
111 | // we have to redo the button... | 123 | // we have to redo the button... |
112 | date->setDown( false ); | 124 | date->setDown( false ); |
113 | } | 125 | } |
114 | 126 | ||
115 | /* | 127 | /* |
116 | * public slot | 128 | * public slot |
117 | */ | 129 | */ |
118 | void DateBookDayHeader::goBack() | 130 | void DateBookDayHeader::goBack() |
119 | { | 131 | { |
120 | currDate = currDate.addDays( -1 ); | 132 | currDate = currDate.addDays( -1 ); |
121 | setDate( currDate.year(), currDate.month(), currDate.day() ); | 133 | setDate( currDate.year(), currDate.month(), currDate.day() ); |
122 | } | 134 | } |
123 | /* | 135 | /* |
124 | * public slot | 136 | * public slot |
125 | */ | 137 | */ |
126 | void DateBookDayHeader::goForward() | 138 | void DateBookDayHeader::goForward() |
127 | { | 139 | { |
128 | currDate = currDate.addDays( 1 ); | 140 | currDate = currDate.addDays( 1 ); |
129 | setDate( currDate.year(), currDate.month(), currDate.day() ); | 141 | setDate( currDate.year(), currDate.month(), currDate.day() ); |
130 | } | 142 | } |
131 | /* | 143 | /* |
132 | * public slot | 144 | * public slot |
133 | */ | 145 | */ |
134 | void DateBookDayHeader::goBackWeek() | 146 | void DateBookDayHeader::goBackWeek() |
135 | { | 147 | { |
136 | currDate = currDate.addDays( -7 ); | 148 | currDate = currDate.addDays( -7 ); |
137 | setDate( currDate.year(), currDate.month(), currDate.day() ); | 149 | setDate( currDate.year(), currDate.month(), currDate.day() ); |
138 | } | 150 | } |
139 | /* | 151 | /* |
140 | * public slot | 152 | * public slot |
141 | */ | 153 | */ |
142 | void DateBookDayHeader::goForwardWeek() | 154 | void DateBookDayHeader::goForwardWeek() |
143 | { | 155 | { |
144 | currDate = currDate.addDays( 7 ); | 156 | currDate = currDate.addDays( 7 ); |
145 | setDate( currDate.year(), currDate.month(), currDate.day() ); | 157 | setDate( currDate.year(), currDate.month(), currDate.day() ); |
146 | } | 158 | } |
147 | 159 | ||
148 | 160 | ||
149 | /* | 161 | /* |
150 | * public slot | 162 | * public slot |
151 | */ | 163 | */ |
152 | void DateBookDayHeader::setDate( int y, int m, int d ) | 164 | void DateBookDayHeader::setDate( int y, int m, int d ) |
153 | { | 165 | { |
154 | currDate.setYMD( y, m, d ); | 166 | currDate.setYMD( y, m, d ); |
155 | date->setText( TimeString::shortDate( currDate ) ); | 167 | date->setText( TimeString::shortDate( currDate ) ); |
156 | 168 | ||
157 | int iDayOfWeek = currDate.dayOfWeek(); | 169 | int iDayOfWeek = currDate.dayOfWeek(); |
158 | // cleverly adjust the day depending on how we start the week | 170 | // cleverly adjust the day depending on how we start the week |
159 | if ( bUseMonday ) | 171 | if ( bUseMonday ) |
160 | iDayOfWeek--; | 172 | iDayOfWeek--; |
161 | else { | 173 | else { |
162 | if ( iDayOfWeek == 7 ) // Sunday | 174 | if ( iDayOfWeek == 7 ) // Sunday |
163 | iDayOfWeek = 0; | 175 | iDayOfWeek = 0; |
164 | } | 176 | } |
165 | grpDays->setButton( iDayOfWeek ); | 177 | grpDays->setButton( iDayOfWeek ); |
166 | emit dateChanged( y, m, d ); | 178 | emit dateChanged( y, m, d ); |
167 | } | 179 | } |
168 | 180 | ||
169 | /* | 181 | /* |
170 | * public slot | 182 | * public slot |
171 | */ | 183 | */ |
172 | void DateBookDayHeader::setDay( int day ) | 184 | void DateBookDayHeader::setDay( int day ) |
173 | { | 185 | { |
174 | int realDay; | 186 | int realDay; |
175 | int dayOfWeek = currDate.dayOfWeek(); | 187 | int dayOfWeek = currDate.dayOfWeek(); |
176 | 188 | ||
177 | // a little adjustment is needed... | 189 | // a little adjustment is needed... |
178 | if ( bUseMonday ) | 190 | if ( bUseMonday ) |
179 | realDay = day + 1 ; | 191 | realDay = day + 1 ; |
180 | else if ( !bUseMonday && day == 0 ) // sunday | 192 | else if ( !bUseMonday && day == 0 ) // sunday |
181 | realDay = 7; | 193 | realDay = 7; |
182 | else | 194 | else |
183 | realDay = day; | 195 | realDay = day; |
184 | // special cases first... | 196 | // special cases first... |
185 | if ( realDay == 7 && !bUseMonday ) { | 197 | if ( realDay == 7 && !bUseMonday ) { |
186 | while ( currDate.dayOfWeek() != realDay ) | 198 | while ( currDate.dayOfWeek() != realDay ) |
187 | currDate = currDate.addDays( -1 ); | 199 | currDate = currDate.addDays( -1 ); |
188 | } else if ( !bUseMonday && dayOfWeek == 7 && dayOfWeek > realDay ) { | 200 | } else if ( !bUseMonday && dayOfWeek == 7 && dayOfWeek > realDay ) { |
189 | while ( currDate.dayOfWeek() != realDay ) | 201 | while ( currDate.dayOfWeek() != realDay ) |
190 | currDate = currDate.addDays( 1 ); | 202 | currDate = currDate.addDays( 1 ); |
191 | } else if ( dayOfWeek < realDay ) { | 203 | } else if ( dayOfWeek < realDay ) { |
192 | while ( currDate.dayOfWeek() < realDay ) | 204 | while ( currDate.dayOfWeek() < realDay ) |
193 | currDate = currDate.addDays( 1 ); | 205 | currDate = currDate.addDays( 1 ); |
194 | } else if ( dayOfWeek > realDay ) { | 206 | } else if ( dayOfWeek > realDay ) { |
195 | while ( currDate.dayOfWeek() > realDay ) | 207 | while ( currDate.dayOfWeek() > realDay ) |
196 | currDate = currDate.addDays( -1 ); | 208 | currDate = currDate.addDays( -1 ); |
197 | } | 209 | } |
198 | // update the date... | 210 | // update the date... |
199 | setDate( currDate.year(), currDate.month(), currDate.day() ); | 211 | setDate( currDate.year(), currDate.month(), currDate.day() ); |
200 | } | 212 | } |
diff --git a/core/pim/datebook/datebookdayheaderimpl.h b/core/pim/datebook/datebookdayheaderimpl.h index a07bd67..ea9f917 100644 --- a/core/pim/datebook/datebookdayheaderimpl.h +++ b/core/pim/datebook/datebookdayheaderimpl.h | |||
@@ -1,59 +1,70 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
20 | #ifndef DATEBOOKDAYHEADER_H | 31 | #ifndef DATEBOOKDAYHEADER_H |
21 | #define DATEBOOKDAYHEADER_H | 32 | #define DATEBOOKDAYHEADER_H |
22 | #include "datebookdayheader.h" | 33 | #include "datebookdayheader.h" |
23 | 34 | ||
24 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
25 | 36 | ||
26 | class DateBookDayHeader : public DateBookDayHeaderBase | 37 | class DateBookDayHeader : public DateBookDayHeaderBase |
27 | { | 38 | { |
28 | Q_OBJECT | 39 | Q_OBJECT |
29 | 40 | ||
30 | public: | 41 | public: |
31 | DateBookDayHeader( bool bUseMonday, QWidget* parent = 0, | 42 | DateBookDayHeader( bool bUseMonday, QWidget* parent = 0, |
32 | const char* name = 0 ); | 43 | const char* name = 0 ); |
33 | ~DateBookDayHeader(); | 44 | ~DateBookDayHeader(); |
34 | void setStartOfWeek( bool onMonday ); | 45 | void setStartOfWeek( bool onMonday ); |
35 | 46 | ||
36 | public slots: | 47 | public slots: |
37 | void goBack(); | 48 | void goBack(); |
38 | void goForward(); | 49 | void goForward(); |
39 | void goBackWeek(); | 50 | void goBackWeek(); |
40 | void goForwardWeek(); | 51 | void goForwardWeek(); |
41 | void setDate( int, int, int ); | 52 | void setDate( int, int, int ); |
42 | void setDay( int ); | 53 | void setDay( int ); |
43 | void gotHide(); | 54 | void gotHide(); |
44 | 55 | ||
45 | signals: | 56 | signals: |
46 | void dateChanged( int y, int m, int d ); | 57 | void dateChanged( int y, int m, int d ); |
47 | 58 | ||
48 | private slots: | 59 | private slots: |
49 | void pickDate(); | 60 | void pickDate(); |
50 | 61 | ||
51 | 62 | ||
52 | private: | 63 | private: |
53 | QDate currDate; | 64 | QDate currDate; |
54 | bool bUseMonday; | 65 | bool bUseMonday; |
55 | void setupNames(); | 66 | void setupNames(); |
56 | 67 | ||
57 | }; | 68 | }; |
58 | 69 | ||
59 | #endif // DATEBOOKDAYHEADER_H | 70 | #endif // DATEBOOKDAYHEADER_H |
diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp index 561dc38..c72cd59 100644 --- a/core/pim/datebook/datebooksettings.cpp +++ b/core/pim/datebook/datebooksettings.cpp | |||
@@ -1,211 +1,221 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
20 | 30 | ||
21 | #include "datebooksettings.h" | 31 | #include "datebooksettings.h" |
22 | 32 | ||
23 | #include <opie2/opluginloader.h> | 33 | #include <opie2/opluginloader.h> |
24 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
25 | #include <opie2/oholidaypluginif.h> | 35 | #include <opie2/oholidaypluginif.h> |
26 | #include <opie2/oholidayplugin.h> | 36 | #include <opie2/oholidayplugin.h> |
27 | #include <opie2/oholidayplugincfgwidget.h> | 37 | #include <opie2/oholidayplugincfgwidget.h> |
28 | 38 | ||
29 | #include <qpe/qpeapplication.h> | 39 | #include <qpe/qpeapplication.h> |
30 | 40 | ||
31 | #include <qspinbox.h> | 41 | #include <qspinbox.h> |
32 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
33 | #include <qlistview.h> | 43 | #include <qlistview.h> |
34 | #include <qheader.h> | 44 | #include <qheader.h> |
35 | #include <qtabwidget.h> | 45 | #include <qtabwidget.h> |
36 | #include <qlayout.h> | 46 | #include <qlayout.h> |
37 | 47 | ||
38 | DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, | 48 | DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, |
39 | const char *name, bool modal, WFlags fl ) | 49 | const char *name, bool modal, WFlags fl ) |
40 | : DateBookSettingsBase( parent, name, modal, fl ), | 50 | : DateBookSettingsBase( parent, name, modal, fl ), |
41 | ampm( whichClock ) | 51 | ampm( whichClock ) |
42 | { | 52 | { |
43 | init(); | 53 | init(); |
44 | QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) ); | 54 | QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) ); |
45 | QArray<int> categories; | 55 | QArray<int> categories; |
46 | comboCategory->setCategories( categories, "Calendar", tr("Calendar") ); | 56 | comboCategory->setCategories( categories, "Calendar", tr("Calendar") ); |
47 | m_loader = 0; | 57 | m_loader = 0; |
48 | m_manager = 0; | 58 | m_manager = 0; |
49 | m_PluginListView->header()->hide(); | 59 | m_PluginListView->header()->hide(); |
50 | m_PluginListView->setSorting(-1); | 60 | m_PluginListView->setSorting(-1); |
51 | } | 61 | } |
52 | 62 | ||
53 | DateBookSettings::~DateBookSettings() | 63 | DateBookSettings::~DateBookSettings() |
54 | { | 64 | { |
55 | } | 65 | } |
56 | 66 | ||
57 | void DateBookSettings::setStartTime( int newStartViewTime ) | 67 | void DateBookSettings::setStartTime( int newStartViewTime ) |
58 | { | 68 | { |
59 | if ( ampm ) { | 69 | if ( ampm ) { |
60 | if ( newStartViewTime >= 12 ) { | 70 | if ( newStartViewTime >= 12 ) { |
61 | newStartViewTime %= 12; | 71 | newStartViewTime %= 12; |
62 | if ( newStartViewTime == 0 ) | 72 | if ( newStartViewTime == 0 ) |
63 | newStartViewTime = 12; | 73 | newStartViewTime = 12; |
64 | spinStart->setSuffix( tr(":00 PM") ); | 74 | spinStart->setSuffix( tr(":00 PM") ); |
65 | } | 75 | } |
66 | else if ( newStartViewTime == 0 ) { | 76 | else if ( newStartViewTime == 0 ) { |
67 | newStartViewTime = 12; | 77 | newStartViewTime = 12; |
68 | spinStart->setSuffix( tr(":00 AM") ); | 78 | spinStart->setSuffix( tr(":00 AM") ); |
69 | } | 79 | } |
70 | oldtime = newStartViewTime; | 80 | oldtime = newStartViewTime; |
71 | } | 81 | } |
72 | spinStart->setValue( newStartViewTime ); | 82 | spinStart->setValue( newStartViewTime ); |
73 | } | 83 | } |
74 | 84 | ||
75 | int DateBookSettings::startTime() const | 85 | int DateBookSettings::startTime() const |
76 | { | 86 | { |
77 | int returnMe = spinStart->value(); | 87 | int returnMe = spinStart->value(); |
78 | if ( ampm ) { | 88 | if ( ampm ) { |
79 | if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) | 89 | if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) |
80 | returnMe += 12; | 90 | returnMe += 12; |
81 | else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) | 91 | else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) |
82 | returnMe = 0; | 92 | returnMe = 0; |
83 | } | 93 | } |
84 | return returnMe; | 94 | return returnMe; |
85 | } | 95 | } |
86 | 96 | ||
87 | void DateBookSettings::setPluginList(Opie::Core::OPluginManager*aManager,Opie::Core::OPluginLoader*aLoader) | 97 | void DateBookSettings::setPluginList(Opie::Core::OPluginManager*aManager,Opie::Core::OPluginLoader*aLoader) |
88 | { | 98 | { |
89 | m_manager = aManager; | 99 | m_manager = aManager; |
90 | m_loader = aLoader; | 100 | m_loader = aLoader; |
91 | if (!aManager||!aLoader) return; | 101 | if (!aManager||!aLoader) return; |
92 | Opie::Core::OPluginItem::List inLst = m_loader->allAvailable(true); | 102 | Opie::Core::OPluginItem::List inLst = m_loader->allAvailable(true); |
93 | QCheckListItem *pitem = 0; | 103 | QCheckListItem *pitem = 0; |
94 | 104 | ||
95 | for ( Opie::Core::OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { | 105 | for ( Opie::Core::OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { |
96 | pitem = new QCheckListItem(m_PluginListView,(*it).name(),QCheckListItem::CheckBox); | 106 | pitem = new QCheckListItem(m_PluginListView,(*it).name(),QCheckListItem::CheckBox); |
97 | pitem->setOn( (*it).isEnabled() ); | 107 | pitem->setOn( (*it).isEnabled() ); |
98 | 108 | ||
99 | Opie::Datebook::HolidayPluginIf*hif = m_loader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN); | 109 | Opie::Datebook::HolidayPluginIf*hif = m_loader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN); |
100 | if (!hif) continue; | 110 | if (!hif) continue; |
101 | Opie::Datebook::HolidayPlugin*pl = hif->plugin(); | 111 | Opie::Datebook::HolidayPlugin*pl = hif->plugin(); |
102 | if (!pl) continue; | 112 | if (!pl) continue; |
103 | Opie::Datebook::HolidayPluginConfigWidget*cfg = pl->configWidget(); | 113 | Opie::Datebook::HolidayPluginConfigWidget*cfg = pl->configWidget(); |
104 | if (!cfg) continue; | 114 | if (!cfg) continue; |
105 | QWidget * dtab = new QWidget(TabWidget,pl->description()); | 115 | QWidget * dtab = new QWidget(TabWidget,pl->description()); |
106 | QVBoxLayout*dlayout = new QVBoxLayout(dtab); | 116 | QVBoxLayout*dlayout = new QVBoxLayout(dtab); |
107 | dlayout->setMargin(2); | 117 | dlayout->setMargin(2); |
108 | dlayout->setSpacing(2); | 118 | dlayout->setSpacing(2); |
109 | cfg->reparent(dtab,0,QPoint(0,0)); | 119 | cfg->reparent(dtab,0,QPoint(0,0)); |
110 | dlayout->addWidget(cfg); | 120 | dlayout->addWidget(cfg); |
111 | TabWidget->insertTab(dtab,pl->description()); | 121 | TabWidget->insertTab(dtab,pl->description()); |
112 | 122 | ||
113 | m_cfgWidgets.append(cfg); | 123 | m_cfgWidgets.append(cfg); |
114 | } | 124 | } |
115 | } | 125 | } |
116 | void DateBookSettings::savePlugins() | 126 | void DateBookSettings::savePlugins() |
117 | { | 127 | { |
118 | QValueList<Opie::Datebook::HolidayPluginConfigWidget*>::Iterator it; | 128 | QValueList<Opie::Datebook::HolidayPluginConfigWidget*>::Iterator it; |
119 | for (it=m_cfgWidgets.begin();it!=m_cfgWidgets.end();++it) { | 129 | for (it=m_cfgWidgets.begin();it!=m_cfgWidgets.end();++it) { |
120 | (*it)->saveConfig(); | 130 | (*it)->saveConfig(); |
121 | } | 131 | } |
122 | } | 132 | } |
123 | 133 | ||
124 | void DateBookSettings::pluginItemClicked(QListViewItem *aItem) | 134 | void DateBookSettings::pluginItemClicked(QListViewItem *aItem) |
125 | { | 135 | { |
126 | if (!aItem||!m_manager||!m_loader) return; | 136 | if (!aItem||!m_manager||!m_loader) return; |
127 | QCheckListItem*pitem = ((QCheckListItem*)aItem); | 137 | QCheckListItem*pitem = ((QCheckListItem*)aItem); |
128 | 138 | ||
129 | Opie::Core::OPluginItem::List lst = m_loader->allAvailable( true ); | 139 | Opie::Core::OPluginItem::List lst = m_loader->allAvailable( true ); |
130 | for ( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 140 | for ( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
131 | if ( QString::compare( (*it).name() , pitem->text(0) ) == 0 ) { | 141 | if ( QString::compare( (*it).name() , pitem->text(0) ) == 0 ) { |
132 | m_manager->setEnabled((*it),pitem->isOn()); | 142 | m_manager->setEnabled((*it),pitem->isOn()); |
133 | break; | 143 | break; |
134 | } | 144 | } |
135 | } | 145 | } |
136 | } | 146 | } |
137 | 147 | ||
138 | void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) | 148 | void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) |
139 | { | 149 | { |
140 | chkAlarmPreset->setChecked( bAlarm ); | 150 | chkAlarmPreset->setChecked( bAlarm ); |
141 | if ( presetTime >=5 ) | 151 | if ( presetTime >=5 ) |
142 | spinPreset->setValue( presetTime ); | 152 | spinPreset->setValue( presetTime ); |
143 | } | 153 | } |
144 | 154 | ||
145 | bool DateBookSettings::alarmPreset() const | 155 | bool DateBookSettings::alarmPreset() const |
146 | { | 156 | { |
147 | return chkAlarmPreset->isChecked(); | 157 | return chkAlarmPreset->isChecked(); |
148 | } | 158 | } |
149 | 159 | ||
150 | int DateBookSettings::presetTime() const | 160 | int DateBookSettings::presetTime() const |
151 | { | 161 | { |
152 | return spinPreset->value(); | 162 | return spinPreset->value(); |
153 | } | 163 | } |
154 | 164 | ||
155 | 165 | ||
156 | void DateBookSettings::slot12Hour( int i ) | 166 | void DateBookSettings::slot12Hour( int i ) |
157 | { | 167 | { |
158 | if ( ampm ) { | 168 | if ( ampm ) { |
159 | if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { | 169 | if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { |
160 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) | 170 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) |
161 | spinStart->setSuffix( tr(":00 PM") ); | 171 | spinStart->setSuffix( tr(":00 PM") ); |
162 | } else { | 172 | } else { |
163 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) | 173 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) |
164 | spinStart->setSuffix( tr(":00 AM") ); | 174 | spinStart->setSuffix( tr(":00 AM") ); |
165 | } | 175 | } |
166 | oldtime = i; | 176 | oldtime = i; |
167 | } | 177 | } |
168 | } | 178 | } |
169 | 179 | ||
170 | void DateBookSettings::init() | 180 | void DateBookSettings::init() |
171 | { | 181 | { |
172 | if ( ampm ) { | 182 | if ( ampm ) { |
173 | spinStart->setMinValue( 1 ); | 183 | spinStart->setMinValue( 1 ); |
174 | spinStart->setMaxValue( 12 ); | 184 | spinStart->setMaxValue( 12 ); |
175 | spinStart->setValue( 12 ); | 185 | spinStart->setValue( 12 ); |
176 | spinStart->setSuffix( tr(":00 AM") ); | 186 | spinStart->setSuffix( tr(":00 AM") ); |
177 | oldtime = 12; | 187 | oldtime = 12; |
178 | } else { | 188 | } else { |
179 | spinStart->setMinValue( 0 ); | 189 | spinStart->setMinValue( 0 ); |
180 | spinStart->setMaxValue( 23 ); | 190 | spinStart->setMaxValue( 23 ); |
181 | spinStart->setSuffix( tr(":00") ); | 191 | spinStart->setSuffix( tr(":00") ); |
182 | } | 192 | } |
183 | } | 193 | } |
184 | 194 | ||
185 | void DateBookSettings::slotChangeClock( bool whichClock ) | 195 | void DateBookSettings::slotChangeClock( bool whichClock ) |
186 | { | 196 | { |
187 | int saveMe; | 197 | int saveMe; |
188 | saveMe = spinStart->value(); | 198 | saveMe = spinStart->value(); |
189 | if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { | 199 | if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { |
190 | if ( saveMe == 12 ) | 200 | if ( saveMe == 12 ) |
191 | saveMe = 0; | 201 | saveMe = 0; |
192 | } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { | 202 | } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { |
193 | if ( saveMe != 12 ) | 203 | if ( saveMe != 12 ) |
194 | saveMe += 12; | 204 | saveMe += 12; |
195 | } | 205 | } |
196 | ampm = whichClock; | 206 | ampm = whichClock; |
197 | init(); | 207 | init(); |
198 | setStartTime( saveMe ); | 208 | setStartTime( saveMe ); |
199 | } | 209 | } |
200 | 210 | ||
201 | void DateBookSettings::setJumpToCurTime( bool bJump ) | 211 | void DateBookSettings::setJumpToCurTime( bool bJump ) |
202 | { | 212 | { |
203 | chkJumpToCurTime->setChecked( bJump ); | 213 | chkJumpToCurTime->setChecked( bJump ); |
204 | } | 214 | } |
205 | 215 | ||
206 | bool DateBookSettings::jumpToCurTime() const | 216 | bool DateBookSettings::jumpToCurTime() const |
207 | { | 217 | { |
208 | return chkJumpToCurTime->isChecked(); | 218 | return chkJumpToCurTime->isChecked(); |
209 | } | 219 | } |
210 | 220 | ||
211 | void DateBookSettings::setRowStyle( int style ) | 221 | void DateBookSettings::setRowStyle( int style ) |
diff --git a/core/pim/datebook/datebooksettings.h b/core/pim/datebook/datebooksettings.h index 912088f..d3aca85 100644 --- a/core/pim/datebook/datebooksettings.h +++ b/core/pim/datebook/datebooksettings.h | |||
@@ -1,77 +1,87 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
20 | 30 | ||
21 | #ifndef DATEBOOKSETTINGS_H | 31 | #ifndef DATEBOOKSETTINGS_H |
22 | #define DATEBOOKSETTINGS_H | 32 | #define DATEBOOKSETTINGS_H |
23 | #include "datebooksettingsbase.h" | 33 | #include "datebooksettingsbase.h" |
24 | #include <qpe/categoryselect.h> | 34 | #include <qpe/categoryselect.h> |
25 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
26 | 36 | ||
27 | namespace Opie { | 37 | namespace Opie { |
28 | namespace Core { | 38 | namespace Core { |
29 | class OPluginManager; | 39 | class OPluginManager; |
30 | class OGenericPluginLoader; | 40 | class OGenericPluginLoader; |
31 | class OPluginLoader; | 41 | class OPluginLoader; |
32 | } | 42 | } |
33 | namespace Ui { | 43 | namespace Ui { |
34 | class OPluginConfigWidget; | 44 | class OPluginConfigWidget; |
35 | } | 45 | } |
36 | namespace Datebook { | 46 | namespace Datebook { |
37 | class HolidayPluginConfigWidget; | 47 | class HolidayPluginConfigWidget; |
38 | } | 48 | } |
39 | } | 49 | } |
40 | 50 | ||
41 | class DateBookSettings : public DateBookSettingsBase | 51 | class DateBookSettings : public DateBookSettingsBase |
42 | { | 52 | { |
43 | Q_OBJECT | 53 | Q_OBJECT |
44 | public: | 54 | public: |
45 | DateBookSettings( bool whichClock, QWidget *parent = 0, | 55 | DateBookSettings( bool whichClock, QWidget *parent = 0, |
46 | const char *name = 0, bool modal = TRUE, WFlags = 0 ); | 56 | const char *name = 0, bool modal = TRUE, WFlags = 0 ); |
47 | ~DateBookSettings(); | 57 | ~DateBookSettings(); |
48 | void setStartTime( int newStartViewTime ); | 58 | void setStartTime( int newStartViewTime ); |
49 | int startTime() const; | 59 | int startTime() const; |
50 | void setAlarmPreset( bool bAlarm, int presetTime ); | 60 | void setAlarmPreset( bool bAlarm, int presetTime ); |
51 | bool alarmPreset() const; | 61 | bool alarmPreset() const; |
52 | int presetTime() const; | 62 | int presetTime() const; |
53 | void setAlarmType( int alarmType ); | 63 | void setAlarmType( int alarmType ); |
54 | int alarmType() const; | 64 | int alarmType() const; |
55 | 65 | ||
56 | void setJumpToCurTime( bool bJump ); | 66 | void setJumpToCurTime( bool bJump ); |
57 | bool jumpToCurTime() const; | 67 | bool jumpToCurTime() const; |
58 | void setRowStyle( int style ); | 68 | void setRowStyle( int style ); |
59 | int rowStyle() const; | 69 | int rowStyle() const; |
60 | 70 | ||
61 | void setPluginList(Opie::Core::OPluginManager*,Opie::Core::OPluginLoader*); | 71 | void setPluginList(Opie::Core::OPluginManager*,Opie::Core::OPluginLoader*); |
62 | void savePlugins(); | 72 | void savePlugins(); |
63 | private slots: | 73 | private slots: |
64 | void slot12Hour( int ); | 74 | void slot12Hour( int ); |
65 | void slotChangeClock( bool ); | 75 | void slotChangeClock( bool ); |
66 | protected slots: | 76 | protected slots: |
67 | virtual void pluginItemClicked(QListViewItem *); | 77 | virtual void pluginItemClicked(QListViewItem *); |
68 | 78 | ||
69 | protected: | 79 | protected: |
70 | void init(); | 80 | void init(); |
71 | bool ampm; | 81 | bool ampm; |
72 | int oldtime; | 82 | int oldtime; |
73 | Opie::Core::OPluginManager*m_manager; | 83 | Opie::Core::OPluginManager*m_manager; |
74 | Opie::Core::OPluginLoader*m_loader; | 84 | Opie::Core::OPluginLoader*m_loader; |
75 | QValueList<Opie::Datebook::HolidayPluginConfigWidget*> m_cfgWidgets; | 85 | QValueList<Opie::Datebook::HolidayPluginConfigWidget*> m_cfgWidgets; |
76 | }; | 86 | }; |
77 | #endif | 87 | #endif |
diff --git a/core/pim/datebook/datebooktypes.h b/core/pim/datebook/datebooktypes.h index 9453be8..bc94561 100644 --- a/core/pim/datebook/datebooktypes.h +++ b/core/pim/datebook/datebooktypes.h | |||
@@ -1,73 +1,103 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (C) Opie Team <opie-devel@handhelds.org> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
1 | #ifndef _DATEBOOK_TYPES_H | 31 | #ifndef _DATEBOOK_TYPES_H |
2 | #define _DATEBOOK_TYPES_H | 32 | #define _DATEBOOK_TYPES_H |
3 | 33 | ||
4 | #include <qpe/datebookdb.h> | 34 | #include <qpe/datebookdb.h> |
5 | 35 | ||
6 | #include <qvaluelist.h> | 36 | #include <qvaluelist.h> |
7 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
8 | 38 | ||
9 | namespace Opie { | 39 | namespace Opie { |
10 | namespace Datebook { | 40 | namespace Datebook { |
11 | class HolidayPlugin; | 41 | class HolidayPlugin; |
12 | class HolidayPluginIf; | 42 | class HolidayPluginIf; |
13 | } | 43 | } |
14 | namespace Core { | 44 | namespace Core { |
15 | class OPluginLoader; | 45 | class OPluginLoader; |
16 | class OPluginManager; | 46 | class OPluginManager; |
17 | } | 47 | } |
18 | } | 48 | } |
19 | 49 | ||
20 | class QLibrary; | 50 | class QLibrary; |
21 | 51 | ||
22 | enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values | 52 | enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values |
23 | enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes. | 53 | enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes. |
24 | 54 | ||
25 | class DateBookDBHack : virtual public DateBookDB { | 55 | class DateBookDBHack : virtual public DateBookDB { |
26 | public: | 56 | public: |
27 | virtual ~DateBookDBHack(){} | 57 | virtual ~DateBookDBHack(){} |
28 | Event eventByUID(int id); | 58 | Event eventByUID(int id); |
29 | }; | 59 | }; |
30 | 60 | ||
31 | class DateBookHoliday | 61 | class DateBookHoliday |
32 | { | 62 | { |
33 | public: | 63 | public: |
34 | DateBookHoliday(); | 64 | DateBookHoliday(); |
35 | virtual ~DateBookHoliday(); | 65 | virtual ~DateBookHoliday(); |
36 | 66 | ||
37 | QStringList holidaylist(const QDate&); | 67 | QStringList holidaylist(const QDate&); |
38 | QStringList holidaylist(unsigned year, unsigned month, unsigned day); | 68 | QStringList holidaylist(unsigned year, unsigned month, unsigned day); |
39 | virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to ); | 69 | virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to ); |
40 | virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start); | 70 | virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start); |
41 | 71 | ||
42 | void reloadPlugins(); | 72 | void reloadPlugins(); |
43 | 73 | ||
44 | Opie::Core::OPluginLoader*pluginLoader(){return m_pluginLoader;} | 74 | Opie::Core::OPluginLoader*pluginLoader(){return m_pluginLoader;} |
45 | Opie::Core::OPluginManager*pluginManager(){return m_pluginManager;} | 75 | Opie::Core::OPluginManager*pluginManager(){return m_pluginManager;} |
46 | 76 | ||
47 | protected: | 77 | protected: |
48 | void init(); | 78 | void init(); |
49 | void deinit(); | 79 | void deinit(); |
50 | 80 | ||
51 | struct HPlugin { | 81 | struct HPlugin { |
52 | Opie::Datebook::HolidayPlugin*_plugin; | 82 | Opie::Datebook::HolidayPlugin*_plugin; |
53 | //QLibrary*_lib; | 83 | //QLibrary*_lib; |
54 | //Opie::Datebook::HolidayPluginIf*_if; | 84 | //Opie::Datebook::HolidayPluginIf*_if; |
55 | }; | 85 | }; |
56 | QValueList<HPlugin*>_pluginlist; | 86 | QValueList<HPlugin*>_pluginlist; |
57 | Opie::Core::OPluginLoader*m_pluginLoader; | 87 | Opie::Core::OPluginLoader*m_pluginLoader; |
58 | Opie::Core::OPluginManager*m_pluginManager; | 88 | Opie::Core::OPluginManager*m_pluginManager; |
59 | }; | 89 | }; |
60 | 90 | ||
61 | class DateBookDBHoliday:virtual public DateBookDBHack { | 91 | class DateBookDBHoliday:virtual public DateBookDBHack { |
62 | public: | 92 | public: |
63 | DateBookDBHoliday():DateBookDBHack(){db_holiday=0;} | 93 | DateBookDBHoliday():DateBookDBHack(){db_holiday=0;} |
64 | virtual ~DateBookDBHoliday(){} | 94 | virtual ~DateBookDBHoliday(){} |
65 | virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to ); | 95 | virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to ); |
66 | virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start); | 96 | virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start); |
67 | virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDate &from,const QDate &to ); | 97 | virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDate &from,const QDate &to ); |
68 | virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDateTime &start); | 98 | virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDateTime &start); |
69 | 99 | ||
70 | DateBookHoliday*db_holiday; | 100 | DateBookHoliday*db_holiday; |
71 | }; | 101 | }; |
72 | 102 | ||
73 | #endif | 103 | #endif |
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index a509d89..ce0b10b 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp | |||
@@ -1,211 +1,222 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
20 | #include "datebookweek.h" | 31 | #include "datebookweek.h" |
21 | #include "datebookweekheaderimpl.h" | 32 | #include "datebookweekheaderimpl.h" |
22 | #include "datebooktypes.h" | 33 | #include "datebooktypes.h" |
23 | 34 | ||
24 | #include <qpe/datebookdb.h> | 35 | #include <qpe/datebookdb.h> |
25 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/calendar.h> | 37 | #include <qpe/calendar.h> |
27 | 38 | ||
28 | #include <qheader.h> | 39 | #include <qheader.h> |
29 | #include <qlabel.h> | 40 | #include <qlabel.h> |
30 | #include <qlayout.h> | 41 | #include <qlayout.h> |
31 | #include <qtimer.h> | 42 | #include <qtimer.h> |
32 | 43 | ||
33 | //----------------------------------------------------------------- | 44 | //----------------------------------------------------------------- |
34 | 45 | ||
35 | 46 | ||
36 | DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e ) | 47 | DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e ) |
37 | : ev( e ) | 48 | : ev( e ) |
38 | { | 49 | { |
39 | // with the current implementation change the color for all day events | 50 | // with the current implementation change the color for all day events |
40 | if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) { | 51 | if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) { |
41 | c = Qt::green; | 52 | c = Qt::green; |
42 | } else { | 53 | } else { |
43 | c = ev.event().hasAlarm() ? Qt::red : Qt::blue; | 54 | c = ev.event().hasAlarm() ? Qt::red : Qt::blue; |
44 | } | 55 | } |
45 | } | 56 | } |
46 | 57 | ||
47 | void DateBookWeekItem::setGeometry( int x, int y, int w, int h ) | 58 | void DateBookWeekItem::setGeometry( int x, int y, int w, int h ) |
48 | { | 59 | { |
49 | r.setRect( x, y, w, h ); | 60 | r.setRect( x, y, w, h ); |
50 | } | 61 | } |
51 | 62 | ||
52 | 63 | ||
53 | //------------------=--------------------------------------------- | 64 | //------------------=--------------------------------------------- |
54 | 65 | ||
55 | DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday, | 66 | DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday, |
56 | QWidget *parent, const char *name ) | 67 | QWidget *parent, const char *name ) |
57 | : QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ), | 68 | : QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ), |
58 | showingEvent( false ) | 69 | showingEvent( false ) |
59 | { | 70 | { |
60 | items.setAutoDelete( true ); | 71 | items.setAutoDelete( true ); |
61 | 72 | ||
62 | viewport()->setBackgroundMode( PaletteBase ); | 73 | viewport()->setBackgroundMode( PaletteBase ); |
63 | 74 | ||
64 | header = new QHeader( this ); | 75 | header = new QHeader( this ); |
65 | header->addLabel( "" ); | 76 | header->addLabel( "" ); |
66 | 77 | ||
67 | header->setMovingEnabled( false ); | 78 | header->setMovingEnabled( false ); |
68 | header->setResizeEnabled( false ); | 79 | header->setResizeEnabled( false ); |
69 | header->setClickEnabled( false, 0 ); | 80 | header->setClickEnabled( false, 0 ); |
70 | initNames(); | 81 | initNames(); |
71 | 82 | ||
72 | 83 | ||
73 | connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) ); | 84 | connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) ); |
74 | 85 | ||
75 | QObject::connect(qApp, SIGNAL(clockChanged(bool)), | 86 | QObject::connect(qApp, SIGNAL(clockChanged(bool)), |
76 | this, SLOT(slotChangeClock(bool))); | 87 | this, SLOT(slotChangeClock(bool))); |
77 | 88 | ||
78 | QFontMetrics fm( font() ); | 89 | QFontMetrics fm( font() ); |
79 | rowHeight = fm.height()+2; | 90 | rowHeight = fm.height()+2; |
80 | 91 | ||
81 | resizeContents( width(), 24*rowHeight ); | 92 | resizeContents( width(), 24*rowHeight ); |
82 | } | 93 | } |
83 | 94 | ||
84 | void DateBookWeekView::initNames() | 95 | void DateBookWeekView::initNames() |
85 | { | 96 | { |
86 | 97 | ||
87 | static bool bFirst = true; | 98 | static bool bFirst = true; |
88 | if ( bFirst ) { | 99 | if ( bFirst ) { |
89 | if ( bOnMonday ) { | 100 | if ( bOnMonday ) { |
90 | for ( int i = 1; i<=7; i++ ) { | 101 | for ( int i = 1; i<=7; i++ ) { |
91 | header->addLabel( Calendar::nameOfDay( i ) ); | 102 | header->addLabel( Calendar::nameOfDay( i ) ); |
92 | } | 103 | } |
93 | 104 | ||
94 | } else { | 105 | } else { |
95 | header->addLabel( Calendar::nameOfDay( 7 ) ); | 106 | header->addLabel( Calendar::nameOfDay( 7 ) ); |
96 | for ( int i = 1; i<7; i++ ) { | 107 | for ( int i = 1; i<7; i++ ) { |
97 | header->addLabel( Calendar::nameOfDay( i ) ); | 108 | header->addLabel( Calendar::nameOfDay( i ) ); |
98 | } | 109 | } |
99 | } | 110 | } |
100 | bFirst = false; | 111 | bFirst = false; |
101 | } else { | 112 | } else { |
102 | // we are change things... | 113 | // we are change things... |
103 | if ( bOnMonday ) { | 114 | if ( bOnMonday ) { |
104 | for ( int i = 1; i<=7; i++ ) { | 115 | for ( int i = 1; i<=7; i++ ) { |
105 | header->setLabel( i, Calendar::nameOfDay( i ) ); | 116 | header->setLabel( i, Calendar::nameOfDay( i ) ); |
106 | } | 117 | } |
107 | 118 | ||
108 | } else { | 119 | } else { |
109 | header->setLabel( 1, Calendar::nameOfDay( 7 ) ); | 120 | header->setLabel( 1, Calendar::nameOfDay( 7 ) ); |
110 | for ( int i = 1; i<7; i++ ) { | 121 | for ( int i = 1; i<7; i++ ) { |
111 | header->setLabel( i+1, Calendar::nameOfDay( i ) ); | 122 | header->setLabel( i+1, Calendar::nameOfDay( i ) ); |
112 | } | 123 | } |
113 | 124 | ||
114 | } | 125 | } |
115 | } | 126 | } |
116 | } | 127 | } |
117 | 128 | ||
118 | 129 | ||
119 | 130 | ||
120 | void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev ) | 131 | void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev ) |
121 | { | 132 | { |
122 | items.clear(); | 133 | items.clear(); |
123 | QValueListIterator<EffectiveEvent> it; | 134 | QValueListIterator<EffectiveEvent> it; |
124 | for ( it = ev.begin(); it != ev.end(); ++it ) { | 135 | for ( it = ev.begin(); it != ev.end(); ++it ) { |
125 | DateBookWeekItem *i = new DateBookWeekItem( *it ); | 136 | DateBookWeekItem *i = new DateBookWeekItem( *it ); |
126 | if(!((i->event().end().hour()==0) && (i->event().end().minute()==0) && (i->event().startDate()!=i->event().date()))) { // Skip events ending at 00:00 starting at another day. | 137 | if(!((i->event().end().hour()==0) && (i->event().end().minute()==0) && (i->event().startDate()!=i->event().date()))) { // Skip events ending at 00:00 starting at another day. |
127 | positionItem( i ); | 138 | positionItem( i ); |
128 | items.append( i ); | 139 | items.append( i ); |
129 | } | 140 | } |
130 | } | 141 | } |
131 | viewport()->update(); | 142 | viewport()->update(); |
132 | } | 143 | } |
133 | 144 | ||
134 | void DateBookWeekView::moveToHour( int h ) | 145 | void DateBookWeekView::moveToHour( int h ) |
135 | { | 146 | { |
136 | int offset = h*rowHeight; | 147 | int offset = h*rowHeight; |
137 | setContentsPos( 0, offset ); | 148 | setContentsPos( 0, offset ); |
138 | } | 149 | } |
139 | 150 | ||
140 | void DateBookWeekView::keyPressEvent( QKeyEvent *e ) | 151 | void DateBookWeekView::keyPressEvent( QKeyEvent *e ) |
141 | { | 152 | { |
142 | e->ignore(); | 153 | e->ignore(); |
143 | } | 154 | } |
144 | 155 | ||
145 | void DateBookWeekView::slotChangeClock( bool c ) | 156 | void DateBookWeekView::slotChangeClock( bool c ) |
146 | { | 157 | { |
147 | ampm = c; | 158 | ampm = c; |
148 | viewport()->update(); | 159 | viewport()->update(); |
149 | } | 160 | } |
150 | 161 | ||
151 | static inline int db_round30min( int m ) | 162 | static inline int db_round30min( int m ) |
152 | { | 163 | { |
153 | if ( m < 15 ) | 164 | if ( m < 15 ) |
154 | m = 0; | 165 | m = 0; |
155 | else if ( m < 45 ) | 166 | else if ( m < 45 ) |
156 | m = 1; | 167 | m = 1; |
157 | else | 168 | else |
158 | m = 2; | 169 | m = 2; |
159 | 170 | ||
160 | return m; | 171 | return m; |
161 | } | 172 | } |
162 | 173 | ||
163 | void DateBookWeekView::alterDay( int day ) | 174 | void DateBookWeekView::alterDay( int day ) |
164 | { | 175 | { |
165 | if ( !bOnMonday ) { | 176 | if ( !bOnMonday ) { |
166 | day--; | 177 | day--; |
167 | } | 178 | } |
168 | emit showDay( day ); | 179 | emit showDay( day ); |
169 | } | 180 | } |
170 | 181 | ||
171 | void DateBookWeekView::positionItem( DateBookWeekItem *i ) | 182 | void DateBookWeekView::positionItem( DateBookWeekItem *i ) |
172 | { | 183 | { |
173 | const int Width = 8; | 184 | const int Width = 8; |
174 | const EffectiveEvent ev = i->event(); | 185 | const EffectiveEvent ev = i->event(); |
175 | 186 | ||
176 | // 30 minute intervals | 187 | // 30 minute intervals |
177 | int y = ev.start().hour() * 2; | 188 | int y = ev.start().hour() * 2; |
178 | y += db_round30min( ev.start().minute() ); | 189 | y += db_round30min( ev.start().minute() ); |
179 | int y2 = ev.end().hour() * 2; | 190 | int y2 = ev.end().hour() * 2; |
180 | y2 += db_round30min( ev.end().minute() ); | 191 | y2 += db_round30min( ev.end().minute() ); |
181 | if ( y > 47 ) y = 47; | 192 | if ( y > 47 ) y = 47; |
182 | if ( y2 > 48 ) y2 = 48; | 193 | if ( y2 > 48 ) y2 = 48; |
183 | y = (y * rowHeight) / 2; | 194 | y = (y * rowHeight) / 2; |
184 | y2 = (y2 * rowHeight) / 2; | 195 | y2 = (y2 * rowHeight) / 2; |
185 | 196 | ||
186 | int h; | 197 | int h; |
187 | if ( ev.event().type() == Event::AllDay ) { | 198 | if ( ev.event().type() == Event::AllDay ) { |
188 | h = (48 * rowHeight) / 2; | 199 | h = (48 * rowHeight) / 2; |
189 | y = 0; | 200 | y = 0; |
190 | } else { | 201 | } else { |
191 | h=y2-y; | 202 | h=y2-y; |
192 | if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2; | 203 | if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2; |
193 | } | 204 | } |
194 | 205 | ||
195 | int dow = ev.date().dayOfWeek(); | 206 | int dow = ev.date().dayOfWeek(); |
196 | if ( !bOnMonday ) { | 207 | if ( !bOnMonday ) { |
197 | if ( dow == 7 ) | 208 | if ( dow == 7 ) |
198 | dow = 1; | 209 | dow = 1; |
199 | else | 210 | else |
200 | dow++; | 211 | dow++; |
201 | } | 212 | } |
202 | int x = header->sectionPos( dow ) - 1; | 213 | int x = header->sectionPos( dow ) - 1; |
203 | int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); | 214 | int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); |
204 | DateBookWeekItem *isect = 0; | 215 | DateBookWeekItem *isect = 0; |
205 | do { | 216 | do { |
206 | i->setGeometry( x, y, Width, h ); | 217 | i->setGeometry( x, y, Width, h ); |
207 | isect = intersects( i ); | 218 | isect = intersects( i ); |
208 | x += Width - 1; | 219 | x += Width - 1; |
209 | } while ( isect && x < xlim ); | 220 | } while ( isect && x < xlim ); |
210 | } | 221 | } |
211 | 222 | ||
diff --git a/core/pim/datebook/datebookweek.h b/core/pim/datebook/datebookweek.h index ddf54ed..2d25f10 100644 --- a/core/pim/datebook/datebookweek.h +++ b/core/pim/datebook/datebookweek.h | |||
@@ -1,167 +1,178 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
20 | #ifndef DATEBOOKWEEK | 31 | #ifndef DATEBOOKWEEK |
21 | #define DATEBOOKWEEK | 32 | #define DATEBOOKWEEK |
22 | 33 | ||
23 | #include <qpe/event.h> | 34 | #include <qpe/event.h> |
24 | 35 | ||
25 | #include <qlist.h> | 36 | #include <qlist.h> |
26 | #include <qscrollview.h> | 37 | #include <qscrollview.h> |
27 | #include <qstring.h> | 38 | #include <qstring.h> |
28 | #include <qvaluelist.h> | 39 | #include <qvaluelist.h> |
29 | 40 | ||
30 | class DateBookDB; | 41 | class DateBookDB; |
31 | class DateBookDBHoliday; | 42 | class DateBookDBHoliday; |
32 | class DateBookWeekHeader; | 43 | class DateBookWeekHeader; |
33 | class QDate; | 44 | class QDate; |
34 | class QLabel; | 45 | class QLabel; |
35 | class QResizeEvent; | 46 | class QResizeEvent; |
36 | class QSpinBox; | 47 | class QSpinBox; |
37 | class QTimer; | 48 | class QTimer; |
38 | class QHeader; | 49 | class QHeader; |
39 | 50 | ||
40 | class DateBookWeekItem | 51 | class DateBookWeekItem |
41 | { | 52 | { |
42 | public: | 53 | public: |
43 | DateBookWeekItem( const EffectiveEvent e ); | 54 | DateBookWeekItem( const EffectiveEvent e ); |
44 | 55 | ||
45 | void setGeometry( int x, int y, int w, int h ); | 56 | void setGeometry( int x, int y, int w, int h ); |
46 | QRect geometry() const { return r; } | 57 | QRect geometry() const { return r; } |
47 | 58 | ||
48 | const QColor &color() const { return c; } | 59 | const QColor &color() const { return c; } |
49 | const EffectiveEvent event() const { return ev; } | 60 | const EffectiveEvent event() const { return ev; } |
50 | 61 | ||
51 | private: | 62 | private: |
52 | const EffectiveEvent ev; | 63 | const EffectiveEvent ev; |
53 | QRect r; | 64 | QRect r; |
54 | QColor c; | 65 | QColor c; |
55 | }; | 66 | }; |
56 | 67 | ||
57 | class DateBookWeekView : public QScrollView | 68 | class DateBookWeekView : public QScrollView |
58 | { | 69 | { |
59 | Q_OBJECT | 70 | Q_OBJECT |
60 | public: | 71 | public: |
61 | DateBookWeekView( bool ampm, bool weekOnMonday, QWidget *parent = 0, | 72 | DateBookWeekView( bool ampm, bool weekOnMonday, QWidget *parent = 0, |
62 | const char *name = 0 ); | 73 | const char *name = 0 ); |
63 | 74 | ||
64 | bool whichClock() const; | 75 | bool whichClock() const; |
65 | void showEvents( QValueList<EffectiveEvent> &ev ); | 76 | void showEvents( QValueList<EffectiveEvent> &ev ); |
66 | void moveToHour( int h ); | 77 | void moveToHour( int h ); |
67 | void setStartOfWeek( bool bOnMonday ); | 78 | void setStartOfWeek( bool bOnMonday ); |
68 | 79 | ||
69 | signals: | 80 | signals: |
70 | void showDay( int d ); | 81 | void showDay( int d ); |
71 | void signalShowEvent( const EffectiveEvent & ); | 82 | void signalShowEvent( const EffectiveEvent & ); |
72 | void signalHideEvent(); | 83 | void signalHideEvent(); |
73 | 84 | ||
74 | protected slots: | 85 | protected slots: |
75 | void keyPressEvent(QKeyEvent *); | 86 | void keyPressEvent(QKeyEvent *); |
76 | 87 | ||
77 | private slots: | 88 | private slots: |
78 | void slotChangeClock( bool ); | 89 | void slotChangeClock( bool ); |
79 | void alterDay( int ); | 90 | void alterDay( int ); |
80 | 91 | ||
81 | private: | 92 | private: |
82 | void positionItem( DateBookWeekItem *i ); | 93 | void positionItem( DateBookWeekItem *i ); |
83 | DateBookWeekItem *intersects( const DateBookWeekItem * ); | 94 | DateBookWeekItem *intersects( const DateBookWeekItem * ); |
84 | void drawContents( QPainter *p, int cx, int cy, int cw, int ch ); | 95 | void drawContents( QPainter *p, int cx, int cy, int cw, int ch ); |
85 | void contentsMousePressEvent( QMouseEvent * ); | 96 | void contentsMousePressEvent( QMouseEvent * ); |
86 | void contentsMouseReleaseEvent( QMouseEvent * ); | 97 | void contentsMouseReleaseEvent( QMouseEvent * ); |
87 | void resizeEvent( QResizeEvent * ); | 98 | void resizeEvent( QResizeEvent * ); |
88 | void initNames(); | 99 | void initNames(); |
89 | 100 | ||
90 | private: | 101 | private: |
91 | bool ampm; | 102 | bool ampm; |
92 | bool bOnMonday; | 103 | bool bOnMonday; |
93 | QHeader *header; | 104 | QHeader *header; |
94 | QList<DateBookWeekItem> items; | 105 | QList<DateBookWeekItem> items; |
95 | int rowHeight; | 106 | int rowHeight; |
96 | bool showingEvent; | 107 | bool showingEvent; |
97 | }; | 108 | }; |
98 | 109 | ||
99 | class DateBookWeek : public QWidget | 110 | class DateBookWeek : public QWidget |
100 | { | 111 | { |
101 | Q_OBJECT | 112 | Q_OBJECT |
102 | 113 | ||
103 | public: | 114 | public: |
104 | DateBookWeek( bool ampm, bool weekOnMonday, DateBookDBHoliday *newDB, | 115 | DateBookWeek( bool ampm, bool weekOnMonday, DateBookDBHoliday *newDB, |
105 | QWidget *parent = 0, const char *name = 0 ); | 116 | QWidget *parent = 0, const char *name = 0 ); |
106 | void setDate( int y, int m, int d ); | 117 | void setDate( int y, int m, int d ); |
107 | void setDate( QDate d ); | 118 | void setDate( QDate d ); |
108 | QDate date() const; | 119 | QDate date() const; |
109 | DateBookWeekView *weekView() const { return view; } | 120 | DateBookWeekView *weekView() const { return view; } |
110 | void setStartViewTime( int startHere ); | 121 | void setStartViewTime( int startHere ); |
111 | int startViewTime() const; | 122 | int startViewTime() const; |
112 | int week() const { return _week; }; | 123 | int week() const { return _week; }; |
113 | QDate weekDate() const; | 124 | QDate weekDate() const; |
114 | 125 | ||
115 | public slots: | 126 | public slots: |
116 | void redraw(); | 127 | void redraw(); |
117 | void slotWeekChanged( bool bStartOnMonday ); | 128 | void slotWeekChanged( bool bStartOnMonday ); |
118 | void slotClockChanged( bool a ); | 129 | void slotClockChanged( bool a ); |
119 | 130 | ||
120 | signals: | 131 | signals: |
121 | void showDate( int y, int m, int d ); | 132 | void showDate( int y, int m, int d ); |
122 | 133 | ||
123 | protected slots: | 134 | protected slots: |
124 | void keyPressEvent(QKeyEvent *); | 135 | void keyPressEvent(QKeyEvent *); |
125 | 136 | ||
126 | private slots: | 137 | private slots: |
127 | void showDay( int day ); | 138 | void showDay( int day ); |
128 | void dateChanged( QDate &newdate ); | 139 | void dateChanged( QDate &newdate ); |
129 | void slotShowEvent( const EffectiveEvent & ); | 140 | void slotShowEvent( const EffectiveEvent & ); |
130 | void slotHideEvent(); | 141 | void slotHideEvent(); |
131 | void slotYearChanged( int ); | 142 | void slotYearChanged( int ); |
132 | 143 | ||
133 | private: | 144 | private: |
134 | void getEvents(); | 145 | void getEvents(); |
135 | 146 | ||
136 | /** | 147 | /** |
137 | * Wow that's a hell lot of code duplication | 148 | * Wow that's a hell lot of code duplication |
138 | * in datebook. I vote for a common base class | 149 | * in datebook. I vote for a common base class |
139 | * but never the less. This add a note | 150 | * but never the less. This add a note |
140 | * that the Event is an all day event | 151 | * that the Event is an all day event |
141 | * | 152 | * |
142 | */ | 153 | */ |
143 | void generateAllDayTooltext( QString& text ); | 154 | void generateAllDayTooltext( QString& text ); |
144 | 155 | ||
145 | /** | 156 | /** |
146 | * This will add the times to the text | 157 | * This will add the times to the text |
147 | * It will be shown in the Tooltip bubble | 158 | * It will be shown in the Tooltip bubble |
148 | */ | 159 | */ |
149 | void generateNormalTooltext( QString& text, | 160 | void generateNormalTooltext( QString& text, |
150 | const EffectiveEvent &ev); | 161 | const EffectiveEvent &ev); |
151 | int year; | 162 | int year; |
152 | int _week; | 163 | int _week; |
153 | int dow; | 164 | int dow; |
154 | QDate bdate; | 165 | QDate bdate; |
155 | DateBookWeekHeader *header; | 166 | DateBookWeekHeader *header; |
156 | DateBookWeekView *view; | 167 | DateBookWeekView *view; |
157 | DateBookDBHoliday *db; | 168 | DateBookDBHoliday *db; |
158 | QLabel *lblDesc; | 169 | QLabel *lblDesc; |
159 | QTimer *tHide; | 170 | QTimer *tHide; |
160 | int startTime; | 171 | int startTime; |
161 | bool ampm; | 172 | bool ampm; |
162 | bool bStartOnMonday; | 173 | bool bStartOnMonday; |
163 | }; | 174 | }; |
164 | 175 | ||
165 | 176 | ||
166 | bool calcWeek( const QDate &d, int &week, int &year, bool startOnMonday = false ); | 177 | bool calcWeek( const QDate &d, int &week, int &year, bool startOnMonday = false ); |
167 | #endif | 178 | #endif |
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp index 7462de7..9922778 100644 --- a/core/pim/datebook/datebookweekheaderimpl.cpp +++ b/core/pim/datebook/datebookweekheaderimpl.cpp | |||
@@ -1,123 +1,134 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
20 | #include "datebookweekheaderimpl.h" | 31 | #include "datebookweekheaderimpl.h" |
21 | #include "datebookweek.h" | 32 | #include "datebookweek.h" |
22 | 33 | ||
23 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | #include <opie2/oresource.h> | ||
24 | 36 | ||
25 | #include <qpe/resource.h> | ||
26 | #include <qpe/datebookmonth.h> | 37 | #include <qpe/datebookmonth.h> |
27 | 38 | ||
28 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
29 | 40 | ||
30 | /* | 41 | /* |
31 | * Constructs a DateBookWeekHeader which is a child of 'parent', with the | 42 | * Constructs a DateBookWeekHeader which is a child of 'parent', with the |
32 | * name 'name' and widget flags set to 'f' | 43 | * name 'name' and widget flags set to 'f' |
33 | */ | 44 | */ |
34 | DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) | 45 | DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) |
35 | : DateBookWeekHeaderBase( parent, name, fl ), | 46 | : DateBookWeekHeaderBase( parent, name, fl ), |
36 | bStartOnMonday( startOnMonday ) | 47 | bStartOnMonday( startOnMonday ) |
37 | { | 48 | { |
38 | setBackgroundMode( PaletteButton ); | 49 | setBackgroundMode( PaletteButton ); |
39 | labelDate->setBackgroundMode( PaletteButton ); | 50 | labelDate->setBackgroundMode( PaletteButton ); |
40 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); | 51 | backmonth->setPixmap( Opie::Core::OResource::loadPixmap( "fastback", Opie::Core::OResource::SmallIcon ) ); |
41 | backweek->setPixmap( Resource::loadPixmap("back") ); | 52 | backweek->setPixmap( Opie::Core::OResource::loadPixmap( "back", Opie::Core::OResource::SmallIcon ) ); |
42 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); | 53 | forwardweek->setPixmap( Opie::Core::OResource::loadPixmap( "forward", Opie::Core::OResource::SmallIcon ) ); |
43 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); | 54 | forwardmonth->setPixmap( Opie::Core::OResource::loadPixmap( "fastforward", Opie::Core::OResource::SmallIcon ) ); |
44 | } | 55 | } |
45 | 56 | ||
46 | /* | 57 | /* |
47 | * Destroys the object and frees any allocated resources | 58 | * Destroys the object and frees any allocated resources |
48 | */ | 59 | */ |
49 | DateBookWeekHeader::~DateBookWeekHeader() | 60 | DateBookWeekHeader::~DateBookWeekHeader() |
50 | { | 61 | { |
51 | // no need to delete child widgets, Qt does it all for us | 62 | // no need to delete child widgets, Qt does it all for us |
52 | } | 63 | } |
53 | 64 | ||
54 | void DateBookWeekHeader::pickDate() | 65 | void DateBookWeekHeader::pickDate() |
55 | { | 66 | { |
56 | static QPopupMenu *m1 = 0; | 67 | static QPopupMenu *m1 = 0; |
57 | static DateBookMonth *picker = 0; | 68 | static DateBookMonth *picker = 0; |
58 | if ( !m1 ) { | 69 | if ( !m1 ) { |
59 | m1 = new QPopupMenu( this ); | 70 | m1 = new QPopupMenu( this ); |
60 | picker = new DateBookMonth( m1, 0, TRUE ); | 71 | picker = new DateBookMonth( m1, 0, TRUE ); |
61 | m1->insertItem( picker ); | 72 | m1->insertItem( picker ); |
62 | connect( picker, SIGNAL( dateClicked(int,int,int) ), this, SLOT( setDate(int,int,int) ) ); | 73 | connect( picker, SIGNAL( dateClicked(int,int,int) ), this, SLOT( setDate(int,int,int) ) ); |
63 | // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); | 74 | // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); |
64 | } | 75 | } |
65 | picker->setDate( date.year(), date.month(), date.day() ); | 76 | picker->setDate( date.year(), date.month(), date.day() ); |
66 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); | 77 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); |
67 | picker->setFocus(); | 78 | picker->setFocus(); |
68 | } | 79 | } |
69 | 80 | ||
70 | void DateBookWeekHeader::nextMonth() | 81 | void DateBookWeekHeader::nextMonth() |
71 | { | 82 | { |
72 | owarn << "nextMonth()" << oendl; | 83 | owarn << "nextMonth()" << oendl; |
73 | setDate(date.addDays(28)); | 84 | setDate(date.addDays(28)); |
74 | } | 85 | } |
75 | void DateBookWeekHeader::prevMonth() | 86 | void DateBookWeekHeader::prevMonth() |
76 | { | 87 | { |
77 | owarn << "prevMonth()" << oendl; | 88 | owarn << "prevMonth()" << oendl; |
78 | setDate(date.addDays(-28)); | 89 | setDate(date.addDays(-28)); |
79 | } | 90 | } |
80 | void DateBookWeekHeader::nextWeek() | 91 | void DateBookWeekHeader::nextWeek() |
81 | { | 92 | { |
82 | owarn << "nextWeek()" << oendl; | 93 | owarn << "nextWeek()" << oendl; |
83 | setDate(date.addDays(7)); | 94 | setDate(date.addDays(7)); |
84 | } | 95 | } |
85 | void DateBookWeekHeader::prevWeek() | 96 | void DateBookWeekHeader::prevWeek() |
86 | { | 97 | { |
87 | owarn << "prevWeek()" << oendl; | 98 | owarn << "prevWeek()" << oendl; |
88 | setDate(date.addDays(-7)); | 99 | setDate(date.addDays(-7)); |
89 | } | 100 | } |
90 | 101 | ||
91 | void DateBookWeekHeader::setDate( int y, int m, int d ) | 102 | void DateBookWeekHeader::setDate( int y, int m, int d ) |
92 | { | 103 | { |
93 | setDate(QDate(y,m,d)); | 104 | setDate(QDate(y,m,d)); |
94 | } | 105 | } |
95 | 106 | ||
96 | void DateBookWeekHeader::setDate(const QDate &d) { | 107 | void DateBookWeekHeader::setDate(const QDate &d) { |
97 | int year,week,dayofweek; | 108 | int year,week,dayofweek; |
98 | date=d; | 109 | date=d; |
99 | dayofweek=d.dayOfWeek(); | 110 | dayofweek=d.dayOfWeek(); |
100 | if(bStartOnMonday) | 111 | if(bStartOnMonday) |
101 | dayofweek--; | 112 | dayofweek--; |
102 | else if( dayofweek == 7 ) | 113 | else if( dayofweek == 7 ) |
103 | // we already have the right day -7 would lead to the current week.. | 114 | // we already have the right day -7 would lead to the current week.. |
104 | dayofweek = 0; | 115 | dayofweek = 0; |
105 | 116 | ||
106 | date=date.addDays(-dayofweek); | 117 | date=date.addDays(-dayofweek); |
107 | calcWeek(date,week,year,bStartOnMonday); | 118 | calcWeek(date,week,year,bStartOnMonday); |
108 | QDate start=date; | 119 | QDate start=date; |
109 | QDate stop=start.addDays(6); | 120 | QDate stop=start.addDays(6); |
110 | labelDate->setText( QString::number(start.day()) + "." + | 121 | labelDate->setText( QString::number(start.day()) + "." + |
111 | Calendar::nameOfMonth( start.month()) + "-" + | 122 | Calendar::nameOfMonth( start.month()) + "-" + |
112 | QString::number(stop.day()) + "." + | 123 | QString::number(stop.day()) + "." + |
113 | Calendar::nameOfMonth( stop.month()) +" ("+ | 124 | Calendar::nameOfMonth( stop.month()) +" ("+ |
114 | tr("w")+":"+QString::number( week ) +")"); | 125 | tr("w")+":"+QString::number( week ) +")"); |
115 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! | 126 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! |
116 | emit dateChanged(date); | 127 | emit dateChanged(date); |
117 | } | 128 | } |
118 | 129 | ||
119 | void DateBookWeekHeader::setStartOfWeek( bool onMonday ) | 130 | void DateBookWeekHeader::setStartOfWeek( bool onMonday ) |
120 | { | 131 | { |
121 | bStartOnMonday = onMonday; | 132 | bStartOnMonday = onMonday; |
122 | setDate( date ); | 133 | setDate( date ); |
123 | } | 134 | } |
diff --git a/core/pim/datebook/datebookweekheaderimpl.h b/core/pim/datebook/datebookweekheaderimpl.h index d8dce90..0b388b4 100644 --- a/core/pim/datebook/datebookweekheaderimpl.h +++ b/core/pim/datebook/datebookweekheaderimpl.h | |||
@@ -1,57 +1,68 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
20 | #ifndef DATEBOOKDAYHEADER_H | 31 | #ifndef DATEBOOKDAYHEADER_H |
21 | #define DATEBOOKDAYHEADER_H | 32 | #define DATEBOOKDAYHEADER_H |
22 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
23 | #include "datebookweekheader.h" | 34 | #include "datebookweekheader.h" |
24 | 35 | ||
25 | 36 | ||
26 | class DateBookWeekHeader : public DateBookWeekHeaderBase | 37 | class DateBookWeekHeader : public DateBookWeekHeaderBase |
27 | { | 38 | { |
28 | Q_OBJECT | 39 | Q_OBJECT |
29 | 40 | ||
30 | public: | 41 | public: |
31 | DateBookWeekHeader( bool startOnMonday, QWidget* parent = 0, | 42 | DateBookWeekHeader( bool startOnMonday, QWidget* parent = 0, |
32 | const char* name = 0, WFlags fl = 0 ); | 43 | const char* name = 0, WFlags fl = 0 ); |
33 | ~DateBookWeekHeader(); | 44 | ~DateBookWeekHeader(); |
34 | 45 | ||
35 | void setDate(const QDate &d); | 46 | void setDate(const QDate &d); |
36 | void setStartOfWeek( bool onMonday ); | 47 | void setStartOfWeek( bool onMonday ); |
37 | 48 | ||
38 | signals: | 49 | signals: |
39 | void dateChanged( QDate &date ); | 50 | void dateChanged( QDate &date ); |
40 | 51 | ||
41 | public slots: | 52 | public slots: |
42 | void pickDate(); | 53 | void pickDate(); |
43 | void nextMonth(); | 54 | void nextMonth(); |
44 | void prevMonth(); | 55 | void prevMonth(); |
45 | void nextWeek(); | 56 | void nextWeek(); |
46 | void prevWeek(); | 57 | void prevWeek(); |
47 | void setDate( int y, int m, int d); | 58 | void setDate( int y, int m, int d); |
48 | 59 | ||
49 | protected slots: | 60 | protected slots: |
50 | void keyPressEvent(QKeyEvent *e) { e->ignore(); } | 61 | void keyPressEvent(QKeyEvent *e) { e->ignore(); } |
51 | 62 | ||
52 | private: | 63 | private: |
53 | QDate date; | 64 | QDate date; |
54 | bool bStartOnMonday; | 65 | bool bStartOnMonday; |
55 | }; | 66 | }; |
56 | 67 | ||
57 | #endif // DATEBOOKDAYHEADER_H | 68 | #endif // DATEBOOKDAYHEADER_H |
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp index 297da94..adfa33f 100644 --- a/core/pim/datebook/dateentryimpl.cpp +++ b/core/pim/datebook/dateentryimpl.cpp | |||
@@ -1,211 +1,221 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
20 | 30 | ||
21 | #include "namespace_hack.h" | 31 | #include "namespace_hack.h" |
22 | #include "dateentryimpl.h" | 32 | #include "dateentryimpl.h" |
23 | #include "repeatentry.h" | 33 | #include "repeatentry.h" |
24 | 34 | ||
25 | #include <opie2/odebug.h> | 35 | #include <opie2/odebug.h> |
26 | #include <opie2/otimepicker.h> | 36 | #include <opie2/otimepicker.h> |
27 | 37 | ||
28 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
29 | #include <qpe/categoryselect.h> | 39 | #include <qpe/categoryselect.h> |
30 | #include <qpe/datebookmonth.h> | 40 | #include <qpe/datebookmonth.h> |
31 | #include <qpe/tzselect.h> | 41 | #include <qpe/tzselect.h> |
32 | 42 | ||
33 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
34 | #include <qspinbox.h> | 44 | #include <qspinbox.h> |
35 | 45 | ||
36 | #include "onoteedit.h" | 46 | #include "onoteedit.h" |
37 | 47 | ||
38 | #include <stdlib.h> | 48 | #include <stdlib.h> |
39 | #include <stdio.h> | 49 | #include <stdio.h> |
40 | 50 | ||
41 | /* | 51 | /* |
42 | * Constructs a DateEntry which is a child of 'parent', with the | 52 | * Constructs a DateEntry which is a child of 'parent', with the |
43 | * name 'name' and widget flags set to 'f' | 53 | * name 'name' and widget flags set to 'f' |
44 | * | 54 | * |
45 | * The dialog will by default be modeless, unless you set 'modal' to | 55 | * The dialog will by default be modeless, unless you set 'modal' to |
46 | * TRUE to construct a modal dialog. | 56 | * TRUE to construct a modal dialog. |
47 | */ | 57 | */ |
48 | 58 | ||
49 | DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, | 59 | DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, |
50 | const QDateTime &end, bool whichClock, QWidget* parent, | 60 | const QDateTime &end, bool whichClock, QWidget* parent, |
51 | const char* name ) | 61 | const char* name ) |
52 | : DateEntryBase( parent, name ), | 62 | : DateEntryBase( parent, name ), |
53 | ampm( whichClock ), | 63 | ampm( whichClock ), |
54 | startWeekOnMonday( startOnMonday ), | 64 | startWeekOnMonday( startOnMonday ), |
55 | m_showStart(true) | 65 | m_showStart(true) |
56 | { | 66 | { |
57 | init(); | 67 | init(); |
58 | setDates(start,end); | 68 | setDates(start,end); |
59 | setFocusProxy(comboDescription); | 69 | setFocusProxy(comboDescription); |
60 | } | 70 | } |
61 | 71 | ||
62 | bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) | 72 | bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) |
63 | { | 73 | { |
64 | if( ev->type() == QEvent::FocusIn ){ | 74 | if( ev->type() == QEvent::FocusIn ){ |
65 | if( obj == comboStart ){ | 75 | if( obj == comboStart ){ |
66 | timePickerStart->setHour(startTime.hour()); | 76 | timePickerStart->setHour(startTime.hour()); |
67 | timePickerStart->setMinute(startTime.minute()); | 77 | timePickerStart->setMinute(startTime.minute()); |
68 | TimePickerLabel->setText( tr("Start Time" ) ); | 78 | TimePickerLabel->setText( tr("Start Time" ) ); |
69 | m_showStart= true; | 79 | m_showStart= true; |
70 | }else if( obj == comboEnd ){ | 80 | }else if( obj == comboEnd ){ |
71 | timePickerStart->setHour(endTime.hour()); | 81 | timePickerStart->setHour(endTime.hour()); |
72 | timePickerStart->setMinute(endTime.minute()); | 82 | timePickerStart->setMinute(endTime.minute()); |
73 | TimePickerLabel->setText( tr("End Time") ); | 83 | TimePickerLabel->setText( tr("End Time") ); |
74 | m_showStart = false; | 84 | m_showStart = false; |
75 | } | 85 | } |
76 | } else if( ev->type() == QEvent::FocusOut ){ | 86 | } else if( ev->type() == QEvent::FocusOut ){ |
77 | // if( obj == comboEnd ){ | 87 | // if( obj == comboEnd ){ |
78 | // QString s; | 88 | // QString s; |
79 | // s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); | 89 | // s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); |
80 | // comboEnd->setText(s); | 90 | // comboEnd->setText(s); |
81 | // } | 91 | // } |
82 | // else if( obj == comboStart ){ | 92 | // else if( obj == comboStart ){ |
83 | // QString s; | 93 | // QString s; |
84 | // s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); | 94 | // s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); |
85 | // comboStart->setText(s); | 95 | // comboStart->setText(s); |
86 | // } | 96 | // } |
87 | } | 97 | } |
88 | 98 | ||
89 | return false; | 99 | return false; |
90 | } | 100 | } |
91 | 101 | ||
92 | static void addOrPick( QComboBox* combo, const QString& t ) | 102 | static void addOrPick( QComboBox* combo, const QString& t ) |
93 | { | 103 | { |
94 | // Pick an item if one excists | 104 | // Pick an item if one excists |
95 | for (int i=0; i<combo->count(); i++) { | 105 | for (int i=0; i<combo->count(); i++) { |
96 | if ( combo->text(i) == t ) { | 106 | if ( combo->text(i) == t ) { |
97 | combo->setCurrentItem(i); | 107 | combo->setCurrentItem(i); |
98 | return; | 108 | return; |
99 | } | 109 | } |
100 | } | 110 | } |
101 | 111 | ||
102 | // Else add one | 112 | // Else add one |
103 | combo->insertItem(t); | 113 | combo->insertItem(t); |
104 | combo->setCurrentItem(combo->count()-1); | 114 | combo->setCurrentItem(combo->count()-1); |
105 | } | 115 | } |
106 | 116 | ||
107 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, | 117 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, |
108 | QWidget* parent, const char* name ) | 118 | QWidget* parent, const char* name ) |
109 | : DateEntryBase( parent, name ), | 119 | : DateEntryBase( parent, name ), |
110 | ampm( whichClock ), | 120 | ampm( whichClock ), |
111 | startWeekOnMonday( startOnMonday ), | 121 | startWeekOnMonday( startOnMonday ), |
112 | m_showStart(true) | 122 | m_showStart(true) |
113 | 123 | ||
114 | { | 124 | { |
115 | init(); | 125 | init(); |
116 | setDates(event.start(),event.end()); | 126 | setDates(event.start(),event.end()); |
117 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); | 127 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); |
118 | if(!event.description().isEmpty()) | 128 | if(!event.description().isEmpty()) |
119 | addOrPick( comboDescription, event.description() ); | 129 | addOrPick( comboDescription, event.description() ); |
120 | if(!event.location().isEmpty()) | 130 | if(!event.location().isEmpty()) |
121 | addOrPick( comboLocation, event.location() ); | 131 | addOrPick( comboLocation, event.location() ); |
122 | checkAlarm->setChecked( event.hasAlarm() ); | 132 | checkAlarm->setChecked( event.hasAlarm() ); |
123 | checkAllDay->setChecked( event.type() == Event::AllDay ); | 133 | checkAllDay->setChecked( event.type() == Event::AllDay ); |
124 | if(!event.notes().isEmpty()) noteStr=event.notes(); | 134 | if(!event.notes().isEmpty()) noteStr=event.notes(); |
125 | else noteStr=""; | 135 | else noteStr=""; |
126 | spinAlarm->setValue(event.alarmTime()); | 136 | spinAlarm->setValue(event.alarmTime()); |
127 | if ( event.alarmSound() != Event::Silent ) | 137 | if ( event.alarmSound() != Event::Silent ) |
128 | comboSound->setCurrentItem( 1 ); | 138 | comboSound->setCurrentItem( 1 ); |
129 | if ( event.hasRepeat() ) { | 139 | if ( event.hasRepeat() ) { |
130 | rp = event.repeatPattern(); | 140 | rp = event.repeatPattern(); |
131 | cmdRepeat->setText( tr("Repeat...") ); | 141 | cmdRepeat->setText( tr("Repeat...") ); |
132 | } | 142 | } |
133 | setRepeatLabel(); | 143 | setRepeatLabel(); |
134 | } | 144 | } |
135 | 145 | ||
136 | void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | 146 | void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) |
137 | { | 147 | { |
138 | startDate = s.date(); | 148 | startDate = s.date(); |
139 | endDate = e.date(); | 149 | endDate = e.date(); |
140 | startTime = s.time(); | 150 | startTime = s.time(); |
141 | endTime = e.time(); | 151 | endTime = e.time(); |
142 | 152 | ||
143 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); | 153 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); |
144 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); | 154 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); |
145 | 155 | ||
146 | updateTimeEdit(true,true); | 156 | updateTimeEdit(true,true); |
147 | } | 157 | } |
148 | 158 | ||
149 | void DateEntry::updateTimeEdit(bool s, bool e) { | 159 | void DateEntry::updateTimeEdit(bool s, bool e) { |
150 | 160 | ||
151 | // Comboboxes | 161 | // Comboboxes |
152 | QString strStart, strEnd; | 162 | QString strStart, strEnd; |
153 | int shour, ehour; | 163 | int shour, ehour; |
154 | if ( ampm ) { | 164 | if ( ampm ) { |
155 | shour = startTime.hour(); | 165 | shour = startTime.hour(); |
156 | ehour = endTime.hour(); | 166 | ehour = endTime.hour(); |
157 | if ( shour >= 12 ) { | 167 | if ( shour >= 12 ) { |
158 | if ( shour > 12 ) | 168 | if ( shour > 12 ) |
159 | shour -= 12; | 169 | shour -= 12; |
160 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); | 170 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); |
161 | } else { | 171 | } else { |
162 | if ( shour == 0 ) | 172 | if ( shour == 0 ) |
163 | shour = 12; | 173 | shour = 12; |
164 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); | 174 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); |
165 | } | 175 | } |
166 | if ( ehour == 24 && endTime.minute() == 0 ) { | 176 | if ( ehour == 24 && endTime.minute() == 0 ) { |
167 | strEnd = "11:59 PM"; // or "midnight" | 177 | strEnd = "11:59 PM"; // or "midnight" |
168 | } else if ( ehour >= 12 ) { | 178 | } else if ( ehour >= 12 ) { |
169 | if ( ehour > 12 ) | 179 | if ( ehour > 12 ) |
170 | ehour -= 12; | 180 | ehour -= 12; |
171 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); | 181 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); |
172 | } else { | 182 | } else { |
173 | if ( ehour == 0 ) | 183 | if ( ehour == 0 ) |
174 | ehour = 12; | 184 | ehour = 12; |
175 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); | 185 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); |
176 | } | 186 | } |
177 | } else { | 187 | } else { |
178 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); | 188 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); |
179 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); | 189 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); |
180 | } | 190 | } |
181 | 191 | ||
182 | if (s) comboStart->setText(strStart); | 192 | if (s) comboStart->setText(strStart); |
183 | if (e) comboEnd->setText(strEnd); | 193 | if (e) comboEnd->setText(strEnd); |
184 | } | 194 | } |
185 | 195 | ||
186 | void DateEntry::init() | 196 | void DateEntry::init() |
187 | { | 197 | { |
188 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); | 198 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); |
189 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); | 199 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); |
190 | 200 | ||
191 | initCombos(); | 201 | initCombos(); |
192 | QPopupMenu *m1 = new QPopupMenu( this ); | 202 | QPopupMenu *m1 = new QPopupMenu( this ); |
193 | startPicker = new DateBookMonth( m1, 0, TRUE ); | 203 | startPicker = new DateBookMonth( m1, 0, TRUE ); |
194 | m1->insertItem( startPicker ); | 204 | m1->insertItem( startPicker ); |
195 | buttonStart->setPopup( m1 ); | 205 | buttonStart->setPopup( m1 ); |
196 | connect( startPicker, SIGNAL( dateClicked(int,int,int) ), | 206 | connect( startPicker, SIGNAL( dateClicked(int,int,int) ), |
197 | this, SLOT( startDateChanged(int,int,int) ) ); | 207 | this, SLOT( startDateChanged(int,int,int) ) ); |
198 | 208 | ||
199 | //Let start button change both start and end dates | 209 | //Let start button change both start and end dates |
200 | connect( startPicker, SIGNAL( dateClicked(int,int,int) ), | 210 | connect( startPicker, SIGNAL( dateClicked(int,int,int) ), |
201 | this, SLOT( endDateChanged(int,int,int) ) ); | 211 | this, SLOT( endDateChanged(int,int,int) ) ); |
202 | connect( qApp, SIGNAL( clockChanged(bool) ), | 212 | connect( qApp, SIGNAL( clockChanged(bool) ), |
203 | this, SLOT( slotChangeClock(bool) ) ); | 213 | this, SLOT( slotChangeClock(bool) ) ); |
204 | connect( qApp, SIGNAL(weekChanged(bool)), | 214 | connect( qApp, SIGNAL(weekChanged(bool)), |
205 | this, SLOT(slotChangeStartOfWeek(bool)) ); | 215 | this, SLOT(slotChangeStartOfWeek(bool)) ); |
206 | 216 | ||
207 | connect( editNote, SIGNAL(clicked()), | 217 | connect( editNote, SIGNAL(clicked()), |
208 | this, SLOT(slotEditNote()) ); | 218 | this, SLOT(slotEditNote()) ); |
209 | 219 | ||
210 | QPopupMenu *m2 = new QPopupMenu( this ); | 220 | QPopupMenu *m2 = new QPopupMenu( this ); |
211 | endPicker = new DateBookMonth( m2, 0, TRUE ); | 221 | endPicker = new DateBookMonth( m2, 0, TRUE ); |
diff --git a/core/pim/datebook/dateentryimpl.h b/core/pim/datebook/dateentryimpl.h index a3c4668..2d23ed1 100644 --- a/core/pim/datebook/dateentryimpl.h +++ b/core/pim/datebook/dateentryimpl.h | |||
@@ -1,79 +1,90 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
20 | #ifndef DATEENTRY_H | 31 | #ifndef DATEENTRY_H |
21 | #define DATEENTRY_H | 32 | #define DATEENTRY_H |
22 | 33 | ||
23 | #include "dateentry.h" | 34 | #include "dateentry.h" |
24 | #include "noteentryimpl.h" | 35 | #include "noteentryimpl.h" |
25 | 36 | ||
26 | #include <qpe/event.h> | 37 | #include <qpe/event.h> |
27 | 38 | ||
28 | #include <qdatetime.h> | 39 | #include <qdatetime.h> |
29 | 40 | ||
30 | class DateBookMonth; | 41 | class DateBookMonth; |
31 | 42 | ||
32 | class DateEntry : public DateEntryBase | 43 | class DateEntry : public DateEntryBase |
33 | { | 44 | { |
34 | Q_OBJECT | 45 | Q_OBJECT |
35 | 46 | ||
36 | public: | 47 | public: |
37 | DateEntry( bool startOnMonday, const QDateTime &start, | 48 | DateEntry( bool startOnMonday, const QDateTime &start, |
38 | const QDateTime &end, bool whichClock = FALSE, | 49 | const QDateTime &end, bool whichClock = FALSE, |
39 | QWidget* parent = 0, const char* name = 0 ); | 50 | QWidget* parent = 0, const char* name = 0 ); |
40 | DateEntry( bool startOnMonday, const Event &event, bool whichCLock = FALSE, | 51 | DateEntry( bool startOnMonday, const Event &event, bool whichCLock = FALSE, |
41 | QWidget* parent = 0, const char* name = 0 ); | 52 | QWidget* parent = 0, const char* name = 0 ); |
42 | ~DateEntry(); | 53 | ~DateEntry(); |
43 | 54 | ||
44 | Event event(); | 55 | Event event(); |
45 | void setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice ); | 56 | void setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice ); |
46 | virtual bool eventFilter( QObject *, QEvent * ); | 57 | virtual bool eventFilter( QObject *, QEvent * ); |
47 | public slots: | 58 | public slots: |
48 | void endDateChanged( int, int, int ); | 59 | void endDateChanged( int, int, int ); |
49 | void endTimeChanged( const QString & ); | 60 | void endTimeChanged( const QString & ); |
50 | void endTimeChanged( const QTime & ); | 61 | void endTimeChanged( const QTime & ); |
51 | void startDateChanged(int, int, int); | 62 | void startDateChanged(int, int, int); |
52 | void startTimeEdited( const QString & ); | 63 | void startTimeEdited( const QString & ); |
53 | void startTimeChanged( const QTime & ); | 64 | void startTimeChanged( const QTime & ); |
54 | void startTimePicked( const QTime & ); | 65 | void startTimePicked( const QTime & ); |
55 | void typeChanged( const QString & ); | 66 | void typeChanged( const QString & ); |
56 | void slotRepeat(); | 67 | void slotRepeat(); |
57 | void slotChangeClock( bool ); | 68 | void slotChangeClock( bool ); |
58 | void slotChangeStartOfWeek( bool ); | 69 | void slotChangeStartOfWeek( bool ); |
59 | void slotEditNote(); | 70 | void slotEditNote(); |
60 | 71 | ||
61 | private: | 72 | private: |
62 | void init(); | 73 | void init(); |
63 | void initCombos(); | 74 | void initCombos(); |
64 | void setDates( const QDateTime& s, const QDateTime& e ); | 75 | void setDates( const QDateTime& s, const QDateTime& e ); |
65 | void setRepeatLabel(); | 76 | void setRepeatLabel(); |
66 | void updateTimeEdit(bool,bool); | 77 | void updateTimeEdit(bool,bool); |
67 | 78 | ||
68 | DateBookMonth *startPicker, *endPicker; | 79 | DateBookMonth *startPicker, *endPicker; |
69 | QDate startDate, endDate; | 80 | QDate startDate, endDate; |
70 | QTime startTime, endTime; | 81 | QTime startTime, endTime; |
71 | Event::RepeatPattern rp; | 82 | Event::RepeatPattern rp; |
72 | bool ampm:1; | 83 | bool ampm:1; |
73 | bool startWeekOnMonday:1; | 84 | bool startWeekOnMonday:1; |
74 | bool m_showStart:1; | 85 | bool m_showStart:1; |
75 | 86 | ||
76 | QString noteStr; | 87 | QString noteStr; |
77 | }; | 88 | }; |
78 | 89 | ||
79 | #endif // DATEENTRY_H | 90 | #endif // DATEENTRY_H |
diff --git a/core/pim/datebook/main.cpp b/core/pim/datebook/main.cpp index 3cb60af..e96e769 100644 --- a/core/pim/datebook/main.cpp +++ b/core/pim/datebook/main.cpp | |||
@@ -1,25 +1,35 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
20 | 30 | ||
21 | #include "datebook.h" | 31 | #include "datebook.h" |
22 | #include <opie2/oapplicationfactory.h> | 32 | #include <opie2/oapplicationfactory.h> |
23 | 33 | ||
24 | using namespace Opie::Core; | 34 | using namespace Opie::Core; |
25 | OPIE_EXPORT_APP( OApplicationFactory<DateBook> ) | 35 | OPIE_EXPORT_APP( OApplicationFactory<DateBook> ) |
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp index 6556373..b36bf6d 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp +++ b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp | |||
@@ -1,159 +1,158 @@ | |||
1 | #include "namespace_hack.h" | 1 | #include "namespace_hack.h" |
2 | #include "datebookweeklst.h" | 2 | #include "datebookweeklst.h" |
3 | #include "datebookweeklstheader.h" | 3 | #include "datebookweeklstheader.h" |
4 | #include "datebookweeklstview.h" | 4 | #include "datebookweeklstview.h" |
5 | #include "datebookweeklstdblview.h" | 5 | #include "datebookweeklstdblview.h" |
6 | 6 | ||
7 | #include "datebook.h" | 7 | #include "datebook.h" |
8 | 8 | ||
9 | #include <opie2/odebug.h> | 9 | #include <opie2/odebug.h> |
10 | 10 | ||
11 | #include <qpe/datebookmonth.h> | 11 | #include <qpe/datebookmonth.h> |
12 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
13 | #include <qpe/resource.h> | ||
14 | 13 | ||
15 | #include <qlayout.h> | 14 | #include <qlayout.h> |
16 | #include <qtoolbutton.h> | 15 | #include <qtoolbutton.h> |
17 | 16 | ||
18 | using namespace Opie::Ui; | 17 | using namespace Opie::Ui; |
19 | 18 | ||
20 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, | 19 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB, |
21 | QWidget *parent, | 20 | QWidget *parent, |
22 | const char *name ) | 21 | const char *name ) |
23 | : QWidget( parent, name ), | 22 | : QWidget( parent, name ), |
24 | db( newDB ), | 23 | db( newDB ), |
25 | startTime( 0 ), | 24 | startTime( 0 ), |
26 | ampm( ap ), | 25 | ampm( ap ), |
27 | bStartOnMonday(onM) | 26 | bStartOnMonday(onM) |
28 | { | 27 | { |
29 | setFocusPolicy(StrongFocus); | 28 | setFocusPolicy(StrongFocus); |
30 | dateset = false; | 29 | dateset = false; |
31 | layout = new QVBoxLayout( this ); | 30 | layout = new QVBoxLayout( this ); |
32 | layout->setMargin(0); | 31 | layout->setMargin(0); |
33 | 32 | ||
34 | header=new DateBookWeekLstHeader(onM, this); | 33 | header=new DateBookWeekLstHeader(onM, this); |
35 | layout->addWidget( header ); | 34 | layout->addWidget( header ); |
36 | connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); | 35 | connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); |
37 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); | 36 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); |
38 | 37 | ||
39 | scroll=new QScrollView(this); | 38 | scroll=new QScrollView(this); |
40 | scroll->setResizePolicy(QScrollView::AutoOneFit); | 39 | scroll->setResizePolicy(QScrollView::AutoOneFit); |
41 | layout->addWidget(scroll); | 40 | layout->addWidget(scroll); |
42 | 41 | ||
43 | m_CurrentView=NULL; | 42 | m_CurrentView=NULL; |
44 | Config config("DateBook"); | 43 | Config config("DateBook"); |
45 | config.setGroup("Main"); | 44 | config.setGroup("Main"); |
46 | dbl=config.readBoolEntry("weeklst_dbl", false); | 45 | dbl=config.readBoolEntry("weeklst_dbl", false); |
47 | header->dbl->setOn(dbl); | 46 | header->dbl->setOn(dbl); |
48 | } | 47 | } |
49 | 48 | ||
50 | DateBookWeekLst::~DateBookWeekLst(){ | 49 | DateBookWeekLst::~DateBookWeekLst(){ |
51 | Config config("DateBook"); | 50 | Config config("DateBook"); |
52 | config.setGroup("Main"); | 51 | config.setGroup("Main"); |
53 | config.writeEntry("weeklst_dbl", dbl); | 52 | config.writeEntry("weeklst_dbl", dbl); |
54 | } | 53 | } |
55 | 54 | ||
56 | void DateBookWeekLst::setDate(const QDate &d) { | 55 | void DateBookWeekLst::setDate(const QDate &d) { |
57 | bdate=d; | 56 | bdate=d; |
58 | header->setDate(d); | 57 | header->setDate(d); |
59 | } | 58 | } |
60 | 59 | ||
61 | void DateBookWeekLst::setDbl(bool on) { | 60 | void DateBookWeekLst::setDbl(bool on) { |
62 | dbl=on; | 61 | dbl=on; |
63 | bool displayed = false; | 62 | bool displayed = false; |
64 | if (m_CurrentView) { | 63 | if (m_CurrentView) { |
65 | displayed = m_CurrentView->toggleDoubleView(on); | 64 | displayed = m_CurrentView->toggleDoubleView(on); |
66 | } | 65 | } |
67 | if (!displayed||dbl) { | 66 | if (!displayed||dbl) { |
68 | getEvents(); | 67 | getEvents(); |
69 | } | 68 | } |
70 | } | 69 | } |
71 | 70 | ||
72 | void DateBookWeekLst::redraw() {getEvents();} | 71 | void DateBookWeekLst::redraw() {getEvents();} |
73 | 72 | ||
74 | QDate DateBookWeekLst::date() { | 73 | QDate DateBookWeekLst::date() { |
75 | return bdate; | 74 | return bdate; |
76 | } | 75 | } |
77 | 76 | ||
78 | // return the date at the beginning of the week... | 77 | // return the date at the beginning of the week... |
79 | // copied from DateBookWeek | 78 | // copied from DateBookWeek |
80 | QDate DateBookWeekLst::weekDate() const | 79 | QDate DateBookWeekLst::weekDate() const |
81 | { | 80 | { |
82 | QDate d=bdate; | 81 | QDate d=bdate; |
83 | 82 | ||
84 | // Calculate offset to first day of week. | 83 | // Calculate offset to first day of week. |
85 | int dayoffset=d.dayOfWeek(); | 84 | int dayoffset=d.dayOfWeek(); |
86 | if(bStartOnMonday) dayoffset--; | 85 | if(bStartOnMonday) dayoffset--; |
87 | else if( dayoffset == 7 ) | 86 | else if( dayoffset == 7 ) |
88 | dayoffset = 0; | 87 | dayoffset = 0; |
89 | 88 | ||
90 | return d.addDays(-dayoffset); | 89 | return d.addDays(-dayoffset); |
91 | } | 90 | } |
92 | 91 | ||
93 | void DateBookWeekLst::getEvents() { | 92 | void DateBookWeekLst::getEvents() { |
94 | if (!dateset) return; | 93 | if (!dateset) return; |
95 | QDate start = weekDate(); //date(); | 94 | QDate start = weekDate(); //date(); |
96 | QDate stop = start.addDays(6); | 95 | QDate stop = start.addDays(6); |
97 | QDate start2; | 96 | QDate start2; |
98 | 97 | ||
99 | 98 | ||
100 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | 99 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); |
101 | QValueList<EffectiveEvent> el2; | 100 | QValueList<EffectiveEvent> el2; |
102 | 101 | ||
103 | if (dbl) { | 102 | if (dbl) { |
104 | start2 = start.addDays(7); | 103 | start2 = start.addDays(7); |
105 | stop = start2.addDays(6); | 104 | stop = start2.addDays(6); |
106 | el2 = db->getEffectiveEvents(start2, stop); | 105 | el2 = db->getEffectiveEvents(start2, stop); |
107 | } | 106 | } |
108 | if (!m_CurrentView) { | 107 | if (!m_CurrentView) { |
109 | if (dbl) { | 108 | if (dbl) { |
110 | m_CurrentView=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); | 109 | m_CurrentView=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); |
111 | } else { | 110 | } else { |
112 | m_CurrentView=new DateBookWeekLstDblView(el,start,bStartOnMonday,scroll); | 111 | m_CurrentView=new DateBookWeekLstDblView(el,start,bStartOnMonday,scroll); |
113 | } | 112 | } |
114 | m_CurrentView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 113 | m_CurrentView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
115 | connect (m_CurrentView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); | 114 | connect (m_CurrentView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
116 | connect (m_CurrentView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); | 115 | connect (m_CurrentView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); |
117 | connect (m_CurrentView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); | 116 | connect (m_CurrentView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); |
118 | connect (m_CurrentView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); | 117 | connect (m_CurrentView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); |
119 | connect (m_CurrentView, SIGNAL(redraw()), this, SLOT(redraw())); | 118 | connect (m_CurrentView, SIGNAL(redraw()), this, SLOT(redraw())); |
120 | connect (m_CurrentView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 119 | connect (m_CurrentView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
121 | connect (m_CurrentView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), | 120 | connect (m_CurrentView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
122 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); | 121 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
123 | scroll->addChild(m_CurrentView); | 122 | scroll->addChild(m_CurrentView); |
124 | } else { | 123 | } else { |
125 | if (dbl) { | 124 | if (dbl) { |
126 | m_CurrentView->setEvents(el,el2,start,bStartOnMonday); | 125 | m_CurrentView->setEvents(el,el2,start,bStartOnMonday); |
127 | } else { | 126 | } else { |
128 | m_CurrentView->setEvents(el,start,bStartOnMonday); | 127 | m_CurrentView->setEvents(el,start,bStartOnMonday); |
129 | } | 128 | } |
130 | } | 129 | } |
131 | scroll->updateScrollBars(); | 130 | scroll->updateScrollBars(); |
132 | } | 131 | } |
133 | 132 | ||
134 | void DateBookWeekLst::dateChanged(QDate &newdate) { | 133 | void DateBookWeekLst::dateChanged(QDate &newdate) { |
135 | dateset = true; | 134 | dateset = true; |
136 | bdate=newdate; | 135 | bdate=newdate; |
137 | odebug << "Date changed " << oendl; | 136 | odebug << "Date changed " << oendl; |
138 | getEvents(); | 137 | getEvents(); |
139 | } | 138 | } |
140 | 139 | ||
141 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | 140 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) |
142 | { | 141 | { |
143 | switch(e->key()) { | 142 | switch(e->key()) { |
144 | case Key_Up: | 143 | case Key_Up: |
145 | scroll->scrollBy(0, -20); | 144 | scroll->scrollBy(0, -20); |
146 | break; | 145 | break; |
147 | case Key_Down: | 146 | case Key_Down: |
148 | scroll->scrollBy(0, 20); | 147 | scroll->scrollBy(0, 20); |
149 | break; | 148 | break; |
150 | case Key_Left: | 149 | case Key_Left: |
151 | header->prevWeek(); | 150 | header->prevWeek(); |
152 | break; | 151 | break; |
153 | case Key_Right: | 152 | case Key_Right: |
154 | header->nextWeek(); | 153 | header->nextWeek(); |
155 | break; | 154 | break; |
156 | default: | 155 | default: |
157 | e->ignore(); | 156 | e->ignore(); |
158 | } | 157 | } |
159 | } | 158 | } |
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp index 81e0c31..2da9c22 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp +++ b/core/pim/datebook/modules/weeklst/datebookweeklstheader.cpp | |||
@@ -1,96 +1,97 @@ | |||
1 | #include "datebookweeklstheader.h" | 1 | #include "datebookweeklstheader.h" |
2 | 2 | ||
3 | #include <qpe/resource.h> | 3 | #include <opie2/oresource.h> |
4 | |||
4 | #include <qpe/datebookmonth.h> | 5 | #include <qpe/datebookmonth.h> |
5 | 6 | ||
6 | #include <qtoolbutton.h> | 7 | #include <qtoolbutton.h> |
7 | #include <qlayout.h> | 8 | #include <qlayout.h> |
8 | 9 | ||
9 | /* implenented in datebookweek.cpp - HELL */ | 10 | /* implenented in datebookweek.cpp - HELL */ |
10 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); | 11 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); |
11 | 12 | ||
12 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) | 13 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) |
13 | : DateBookWeekLstHeaderBase(parent, name, fl) | 14 | : DateBookWeekLstHeaderBase(parent, name, fl) |
14 | { | 15 | { |
15 | setBackgroundMode( PaletteButton ); | 16 | setBackgroundMode( PaletteButton ); |
16 | labelDate->setBackgroundMode( PaletteButton ); | 17 | labelDate->setBackgroundMode( PaletteButton ); |
17 | forwardweek->setBackgroundMode( PaletteButton ); | 18 | forwardweek->setBackgroundMode( PaletteButton ); |
18 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); | 19 | forwardweek->setPixmap( Opie::Core::OResource::loadPixmap( "forward", Opie::Core::OResource::SmallIcon ) ); |
19 | forwardmonth->setBackgroundMode( PaletteButton ); | 20 | forwardmonth->setBackgroundMode( PaletteButton ); |
20 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); | 21 | forwardmonth->setPixmap( Opie::Core::OResource::loadPixmap( "fastforward", Opie::Core::OResource::SmallIcon ) ); |
21 | backweek->setBackgroundMode( PaletteButton ); | 22 | backweek->setBackgroundMode( PaletteButton ); |
22 | backweek->setPixmap( Resource::loadPixmap("back") ); | 23 | backweek->setPixmap( Opie::Core::OResource::loadPixmap( "back", Opie::Core::OResource::SmallIcon ) ); |
23 | backmonth->setBackgroundMode( PaletteButton ); | 24 | backmonth->setBackgroundMode( PaletteButton ); |
24 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); | 25 | backmonth->setPixmap( Opie::Core::OResource::loadPixmap( "fastback", Opie::Core::OResource::SmallIcon ) ); |
25 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); | 26 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); |
26 | DateBookWeekLstHeaderBaseLayout->setMargin(0); | 27 | DateBookWeekLstHeaderBaseLayout->setMargin(0); |
27 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); | 28 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); |
28 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 29 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
29 | 30 | ||
30 | connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); | 31 | connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); |
31 | connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); | 32 | connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); |
32 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); | 33 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); |
33 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); | 34 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); |
34 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); | 35 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); |
35 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); | 36 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); |
36 | bStartOnMonday=onM; | 37 | bStartOnMonday=onM; |
37 | } | 38 | } |
38 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} | 39 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} |
39 | 40 | ||
40 | void DateBookWeekLstHeader::setDate(const QDate &d) { | 41 | void DateBookWeekLstHeader::setDate(const QDate &d) { |
41 | int year,week,dayofweek; | 42 | int year,week,dayofweek; |
42 | date=d; | 43 | date=d; |
43 | dayofweek=d.dayOfWeek(); | 44 | dayofweek=d.dayOfWeek(); |
44 | if(bStartOnMonday) | 45 | if(bStartOnMonday) |
45 | dayofweek--; | 46 | dayofweek--; |
46 | else if( dayofweek == 7 ) | 47 | else if( dayofweek == 7 ) |
47 | /* we already have the right day -7 would lead to the same week */ | 48 | /* we already have the right day -7 would lead to the same week */ |
48 | dayofweek = 0; | 49 | dayofweek = 0; |
49 | 50 | ||
50 | date=date.addDays(-dayofweek); | 51 | date=date.addDays(-dayofweek); |
51 | 52 | ||
52 | calcWeek(date,week,year,bStartOnMonday); | 53 | calcWeek(date,week,year,bStartOnMonday); |
53 | QDate start=date; | 54 | QDate start=date; |
54 | QDate stop=start.addDays(6); | 55 | QDate stop=start.addDays(6); |
55 | labelDate->setText( QString::number(start.day()) + "." + | 56 | labelDate->setText( QString::number(start.day()) + "." + |
56 | Calendar::nameOfMonth( start.month() ) + "-" + | 57 | Calendar::nameOfMonth( start.month() ) + "-" + |
57 | QString::number(stop.day()) + "." + | 58 | QString::number(stop.day()) + "." + |
58 | Calendar::nameOfMonth( stop.month()) +" ("+ | 59 | Calendar::nameOfMonth( stop.month()) +" ("+ |
59 | tr("w")+":"+QString::number( week ) +")"); | 60 | tr("w")+":"+QString::number( week ) +")"); |
60 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! | 61 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! |
61 | emit dateChanged(date); | 62 | emit dateChanged(date); |
62 | } | 63 | } |
63 | 64 | ||
64 | void DateBookWeekLstHeader::pickDate() { | 65 | void DateBookWeekLstHeader::pickDate() { |
65 | static QPopupMenu *m1 = 0; | 66 | static QPopupMenu *m1 = 0; |
66 | static DateBookMonth *picker = 0; | 67 | static DateBookMonth *picker = 0; |
67 | if ( !m1 ) { | 68 | if ( !m1 ) { |
68 | m1 = new QPopupMenu( this ); | 69 | m1 = new QPopupMenu( this ); |
69 | picker = new DateBookMonth( m1, 0, TRUE ); | 70 | picker = new DateBookMonth( m1, 0, TRUE ); |
70 | m1->insertItem( picker ); | 71 | m1->insertItem( picker ); |
71 | connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); | 72 | connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); |
72 | //connect( m1, SIGNAL( aboutToHide() ), | 73 | //connect( m1, SIGNAL( aboutToHide() ), |
73 | //this, SLOT( gotHide() ) ); | 74 | //this, SLOT( gotHide() ) ); |
74 | } | 75 | } |
75 | picker->setDate( date.year(), date.month(), date.day() ); | 76 | picker->setDate( date.year(), date.month(), date.day() ); |
76 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); | 77 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); |
77 | picker->setFocus(); | 78 | picker->setFocus(); |
78 | } | 79 | } |
79 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { | 80 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { |
80 | setDate(QDate(y,m,d)); | 81 | setDate(QDate(y,m,d)); |
81 | } | 82 | } |
82 | 83 | ||
83 | void DateBookWeekLstHeader::nextWeek() { | 84 | void DateBookWeekLstHeader::nextWeek() { |
84 | setDate(date.addDays(7)); | 85 | setDate(date.addDays(7)); |
85 | } | 86 | } |
86 | void DateBookWeekLstHeader::prevWeek() { | 87 | void DateBookWeekLstHeader::prevWeek() { |
87 | setDate(date.addDays(-7)); | 88 | setDate(date.addDays(-7)); |
88 | } | 89 | } |
89 | void DateBookWeekLstHeader::nextMonth() | 90 | void DateBookWeekLstHeader::nextMonth() |
90 | { | 91 | { |
91 | setDate(date.addDays(28)); | 92 | setDate(date.addDays(28)); |
92 | } | 93 | } |
93 | void DateBookWeekLstHeader::prevMonth() | 94 | void DateBookWeekLstHeader::prevMonth() |
94 | { | 95 | { |
95 | setDate(date.addDays(-28)); | 96 | setDate(date.addDays(-28)); |
96 | } | 97 | } |
diff --git a/core/pim/datebook/namespace_hack.h b/core/pim/datebook/namespace_hack.h index c15b5ed..2ed674c 100644 --- a/core/pim/datebook/namespace_hack.h +++ b/core/pim/datebook/namespace_hack.h | |||
@@ -1,20 +1,50 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (C) Opie Team <opie-devel@handhelds.org> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
1 | #ifndef NAME_SPACE_HACK_H | 31 | #ifndef NAME_SPACE_HACK_H |
2 | #define NAME_SPACE_HACK_H | 32 | #define NAME_SPACE_HACK_H |
3 | 33 | ||
4 | #include <opie2/otimepicker.h> | 34 | #include <opie2/otimepicker.h> |
5 | #include <opie2/oclickablelabel.h> | 35 | #include <opie2/oclickablelabel.h> |
6 | 36 | ||
7 | class TimePicker : public Opie::Ui::OTimePicker { | 37 | class TimePicker : public Opie::Ui::OTimePicker { |
8 | public: | 38 | public: |
9 | TimePicker( QWidget* p = 0, const char* name = 0, WFlags fl = 0 ) | 39 | TimePicker( QWidget* p = 0, const char* name = 0, WFlags fl = 0 ) |
10 | : Opie::Ui::OTimePicker(p,name,fl){} | 40 | : Opie::Ui::OTimePicker(p,name,fl){} |
11 | 41 | ||
12 | }; | 42 | }; |
13 | class ClickableLabel : public Opie::Ui::OClickableLabel { | 43 | class ClickableLabel : public Opie::Ui::OClickableLabel { |
14 | public: | 44 | public: |
15 | ClickableLabel(QWidget *p=0,const char* name=0, WFlags fl = 0 ) | 45 | ClickableLabel(QWidget *p=0,const char* name=0, WFlags fl = 0 ) |
16 | : Opie::Ui::OClickableLabel(p,name,fl){} | 46 | : Opie::Ui::OClickableLabel(p,name,fl){} |
17 | }; | 47 | }; |
18 | 48 | ||
19 | 49 | ||
20 | #endif | 50 | #endif |
diff --git a/core/pim/datebook/noteentryimpl.cpp b/core/pim/datebook/noteentryimpl.cpp index 14fe98e..f967ab2 100644 --- a/core/pim/datebook/noteentryimpl.cpp +++ b/core/pim/datebook/noteentryimpl.cpp | |||
@@ -1,15 +1,45 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (C) Opie Team <opie-devel@handhelds.org> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
1 | #include "noteentryimpl.h" | 31 | #include "noteentryimpl.h" |
2 | #include "qlabel.h" | 32 | #include "qlabel.h" |
3 | #include "onoteedit.h" | 33 | #include "onoteedit.h" |
4 | 34 | ||
5 | NoteEntry::NoteEntry(const QString &title, const QString ¬eStr, | 35 | NoteEntry::NoteEntry(const QString &title, const QString ¬eStr, |
6 | QWidget* parent, const char* name, bool modal, | 36 | QWidget* parent, const char* name, bool modal, |
7 | WFlags fl) : | 37 | WFlags fl) : |
8 | NoteEntryBase(parent, name, modal, fl) { | 38 | NoteEntryBase(parent, name, modal, fl) { |
9 | 39 | ||
10 | 40 | ||
11 | eventLabel->setText(title); | 41 | eventLabel->setText(title); |
12 | note->setText(noteStr); | 42 | note->setText(noteStr); |
13 | int l=note->length(); | 43 | int l=note->length(); |
14 | note->setCursorPosition(l,l,false); | 44 | note->setCursorPosition(l,l,false); |
15 | } | 45 | } |
diff --git a/core/pim/datebook/noteentryimpl.h b/core/pim/datebook/noteentryimpl.h index f3adfa6..86ea0ee 100644 --- a/core/pim/datebook/noteentryimpl.h +++ b/core/pim/datebook/noteentryimpl.h | |||
@@ -1,18 +1,48 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (C) Opie Team <opie-devel@handhelds.org> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
1 | #ifndef noteentryimpl_h | 31 | #ifndef noteentryimpl_h |
2 | #define noteentryimpl_h | 32 | #define noteentryimpl_h |
3 | 33 | ||
4 | #include "noteentry.h" | 34 | #include "noteentry.h" |
5 | 35 | ||
6 | class QString; | 36 | class QString; |
7 | 37 | ||
8 | class NoteEntry : public NoteEntryBase | 38 | class NoteEntry : public NoteEntryBase |
9 | { | 39 | { |
10 | Q_OBJECT | 40 | Q_OBJECT |
11 | 41 | ||
12 | public: | 42 | public: |
13 | NoteEntry(const QString &title, const QString ¬eStr, | 43 | NoteEntry(const QString &title, const QString ¬eStr, |
14 | QWidget* parent = 0, const char* name = 0, | 44 | QWidget* parent = 0, const char* name = 0, |
15 | bool modal=TRUE, WFlags fl=0); | 45 | bool modal=TRUE, WFlags fl=0); |
16 | }; | 46 | }; |
17 | 47 | ||
18 | #endif | 48 | #endif |
diff --git a/core/pim/datebook/onoteedit.cpp b/core/pim/datebook/onoteedit.cpp index d66ad86..a5f468d 100644 --- a/core/pim/datebook/onoteedit.cpp +++ b/core/pim/datebook/onoteedit.cpp | |||
@@ -1,19 +1,49 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (C) Opie Team <opie-devel@handhelds.org> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
1 | #include "onoteedit.h" | 31 | #include "onoteedit.h" |
2 | 32 | ||
3 | ONoteEdit::ONoteEdit (QWidget * parent, const char * name) : | 33 | ONoteEdit::ONoteEdit (QWidget * parent, const char * name) : |
4 | QMultiLineEdit(parent,name) { | 34 | QMultiLineEdit(parent,name) { |
5 | setDefaultTabStop(2); | 35 | setDefaultTabStop(2); |
6 | setWordWrap(WidgetWidth); | 36 | setWordWrap(WidgetWidth); |
7 | } | 37 | } |
8 | 38 | ||
9 | // Copy indentation from previous line | 39 | // Copy indentation from previous line |
10 | void ONoteEdit::newLine() { | 40 | void ONoteEdit::newLine() { |
11 | int l,c; | 41 | int l,c; |
12 | getCursorPosition(&l,&c); | 42 | getCursorPosition(&l,&c); |
13 | QString s=textLine(l); | 43 | QString s=textLine(l); |
14 | 44 | ||
15 | insert("\n"); | 45 | insert("\n"); |
16 | 46 | ||
17 | int i=0; | 47 | int i=0; |
18 | while (s[i]==' ' || s[i]=='\t') insert(QString(s[i])), i++; | 48 | while (s[i]==' ' || s[i]=='\t') insert(QString(s[i])), i++; |
19 | } | 49 | } |
diff --git a/core/pim/datebook/onoteedit.h b/core/pim/datebook/onoteedit.h index 2f71d0d..390b837 100644 --- a/core/pim/datebook/onoteedit.h +++ b/core/pim/datebook/onoteedit.h | |||
@@ -1,19 +1,49 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (C) Opie Team <opie-devel@handhelds.org> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
1 | #ifndef ONOTEEDIT_H | 31 | #ifndef ONOTEEDIT_H |
2 | #define ONOTEEDIT_H | 32 | #define ONOTEEDIT_H |
3 | 33 | ||
4 | #include <qmultilineedit.h> | 34 | #include <qmultilineedit.h> |
5 | 35 | ||
6 | class ONoteEdit: public QMultiLineEdit { | 36 | class ONoteEdit: public QMultiLineEdit { |
7 | 37 | ||
8 | Q_OBJECT | 38 | Q_OBJECT |
9 | 39 | ||
10 | public: | 40 | public: |
11 | 41 | ||
12 | ONoteEdit (QWidget * parent=0, const char * name=0); | 42 | ONoteEdit (QWidget * parent=0, const char * name=0); |
13 | 43 | ||
14 | protected: | 44 | protected: |
15 | 45 | ||
16 | virtual void newLine (); | 46 | virtual void newLine (); |
17 | }; | 47 | }; |
18 | 48 | ||
19 | #endif | 49 | #endif |
diff --git a/core/pim/datebook/repeatentry.cpp b/core/pim/datebook/repeatentry.cpp index 04c3cf3..30e296c 100644 --- a/core/pim/datebook/repeatentry.cpp +++ b/core/pim/datebook/repeatentry.cpp | |||
@@ -1,211 +1,221 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
20 | 30 | ||
21 | #include "repeatentry.h" | 31 | #include "repeatentry.h" |
22 | 32 | ||
23 | #include <qpe/datebookmonth.h> | 33 | #include <qpe/datebookmonth.h> |
24 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
25 | 35 | ||
26 | #include <qlabel.h> | 36 | #include <qlabel.h> |
27 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
28 | 38 | ||
29 | #include <time.h> | 39 | #include <time.h> |
30 | 40 | ||
31 | // Global Templates for use in setting up the repeat label... | 41 | // Global Templates for use in setting up the repeat label... |
32 | // the problem is these strings get initialized before QPEApplication can install the translator -zecke | 42 | // the problem is these strings get initialized before QPEApplication can install the translator -zecke |
33 | namespace { | 43 | namespace { |
34 | QString strDayTemplate; | 44 | QString strDayTemplate; |
35 | QString strYearTemplate; | 45 | QString strYearTemplate; |
36 | QString strMonthDateTemplate; | 46 | QString strMonthDateTemplate; |
37 | QString strMonthDayTemplate; | 47 | QString strMonthDayTemplate; |
38 | QString strWeekTemplate; | 48 | QString strWeekTemplate; |
39 | QString dayLabel[7]; | 49 | QString dayLabel[7]; |
40 | } | 50 | } |
41 | 51 | ||
42 | /* | 52 | /* |
43 | * static linkage to not polute the symbol table... | 53 | * static linkage to not polute the symbol table... |
44 | * The problem is that const and static linkage are resolved prior to installing a translator | 54 | * The problem is that const and static linkage are resolved prior to installing a translator |
45 | * leading to that the above strings are translted but to the original we delay the init of these strings... | 55 | * leading to that the above strings are translted but to the original we delay the init of these strings... |
46 | * -zecke | 56 | * -zecke |
47 | */ | 57 | */ |
48 | static void fillStrings() { | 58 | static void fillStrings() { |
49 | strDayTemplate = QObject::tr("Every"); | 59 | strDayTemplate = QObject::tr("Every"); |
50 | strYearTemplate = QObject::tr("%1 %2 every "); | 60 | strYearTemplate = QObject::tr("%1 %2 every "); |
51 | strMonthDateTemplate = QObject::tr("The %1 every "); | 61 | strMonthDateTemplate = QObject::tr("The %1 every "); |
52 | strMonthDayTemplate = QObject::tr("The %1 %1 of every"); | 62 | strMonthDayTemplate = QObject::tr("The %1 %1 of every"); |
53 | strWeekTemplate = QObject::tr("Every "); | 63 | strWeekTemplate = QObject::tr("Every "); |
54 | dayLabel[0] = QObject::tr("Monday"); | 64 | dayLabel[0] = QObject::tr("Monday"); |
55 | dayLabel[1] = QObject::tr("Tuesday"); | 65 | dayLabel[1] = QObject::tr("Tuesday"); |
56 | dayLabel[2] = QObject::tr("Wednesday"); | 66 | dayLabel[2] = QObject::tr("Wednesday"); |
57 | dayLabel[3] = QObject::tr("Thursday"); | 67 | dayLabel[3] = QObject::tr("Thursday"); |
58 | dayLabel[4] = QObject::tr("Friday"); | 68 | dayLabel[4] = QObject::tr("Friday"); |
59 | dayLabel[5] = QObject::tr("Saturday"); | 69 | dayLabel[5] = QObject::tr("Saturday"); |
60 | dayLabel[6] = QObject::tr("Sunday"); | 70 | dayLabel[6] = QObject::tr("Sunday"); |
61 | } | 71 | } |
62 | 72 | ||
63 | static QString numberPlacing( int x );// return the proper word format for | 73 | static QString numberPlacing( int x );// return the proper word format for |
64 | // x (1st, 2nd, etc) | 74 | // x (1st, 2nd, etc) |
65 | static int week( const QDate &dt ); // what week in the month is dt? | 75 | static int week( const QDate &dt ); // what week in the month is dt? |
66 | 76 | ||
67 | RepeatEntry::RepeatEntry( bool startOnMonday, | 77 | RepeatEntry::RepeatEntry( bool startOnMonday, |
68 | const QDate &newStart, QWidget *parent, | 78 | const QDate &newStart, QWidget *parent, |
69 | const char *name, bool modal, WFlags fl ) | 79 | const char *name, bool modal, WFlags fl ) |
70 | : RepeatEntryBase( parent, name, modal, fl ), | 80 | : RepeatEntryBase( parent, name, modal, fl ), |
71 | start( newStart ), | 81 | start( newStart ), |
72 | currInterval( NONE ), | 82 | currInterval( NONE ), |
73 | startWeekOnMonday( startOnMonday ) | 83 | startWeekOnMonday( startOnMonday ) |
74 | { | 84 | { |
75 | if (strDayTemplate.isEmpty() ) | 85 | if (strDayTemplate.isEmpty() ) |
76 | fillStrings(); | 86 | fillStrings(); |
77 | 87 | ||
78 | init(); | 88 | init(); |
79 | fraType->setButton( currInterval ); | 89 | fraType->setButton( currInterval ); |
80 | chkNoEnd->setChecked( TRUE ); | 90 | chkNoEnd->setChecked( TRUE ); |
81 | setupNone(); | 91 | setupNone(); |
82 | } | 92 | } |
83 | 93 | ||
84 | RepeatEntry::RepeatEntry( bool startOnMonday, const Event::RepeatPattern &rp, | 94 | RepeatEntry::RepeatEntry( bool startOnMonday, const Event::RepeatPattern &rp, |
85 | const QDate &startDate, | 95 | const QDate &startDate, |
86 | QWidget *parent, const char *name, bool modal, | 96 | QWidget *parent, const char *name, bool modal, |
87 | WFlags fl ) | 97 | WFlags fl ) |
88 | : RepeatEntryBase( parent, name, modal, fl ), | 98 | : RepeatEntryBase( parent, name, modal, fl ), |
89 | start( startDate ), | 99 | start( startDate ), |
90 | end( rp.endDate() ), | 100 | end( rp.endDate() ), |
91 | startWeekOnMonday( startOnMonday ) | 101 | startWeekOnMonday( startOnMonday ) |
92 | { | 102 | { |
93 | if (strDayTemplate.isEmpty() ) | 103 | if (strDayTemplate.isEmpty() ) |
94 | fillStrings(); | 104 | fillStrings(); |
95 | // do some stuff with the repeat pattern | 105 | // do some stuff with the repeat pattern |
96 | init(); | 106 | init(); |
97 | switch ( rp.type ) { | 107 | switch ( rp.type ) { |
98 | default: | 108 | default: |
99 | case Event::NoRepeat: | 109 | case Event::NoRepeat: |
100 | currInterval = NONE; | 110 | currInterval = NONE; |
101 | setupNone(); | 111 | setupNone(); |
102 | break; | 112 | break; |
103 | case Event::Daily: | 113 | case Event::Daily: |
104 | currInterval = DAY; | 114 | currInterval = DAY; |
105 | setupDaily(); | 115 | setupDaily(); |
106 | break; | 116 | break; |
107 | case Event::Weekly: | 117 | case Event::Weekly: |
108 | currInterval = WEEK; | 118 | currInterval = WEEK; |
109 | setupWeekly(); | 119 | setupWeekly(); |
110 | int day, buttons; | 120 | int day, buttons; |
111 | for ( day = 0x01, buttons = 0; buttons < 7; | 121 | for ( day = 0x01, buttons = 0; buttons < 7; |
112 | day = day << 1, buttons++ ) { | 122 | day = day << 1, buttons++ ) { |
113 | if ( rp.days & day ) { | 123 | if ( rp.days & day ) { |
114 | if ( startWeekOnMonday ) | 124 | if ( startWeekOnMonday ) |
115 | fraExtra->setButton( buttons ); | 125 | fraExtra->setButton( buttons ); |
116 | else { | 126 | else { |
117 | if ( buttons == 7 ) | 127 | if ( buttons == 7 ) |
118 | fraExtra->setButton( 0 ); | 128 | fraExtra->setButton( 0 ); |
119 | else | 129 | else |
120 | fraExtra->setButton( buttons + 1 ); | 130 | fraExtra->setButton( buttons + 1 ); |
121 | } | 131 | } |
122 | } | 132 | } |
123 | } | 133 | } |
124 | slotWeekLabel(); | 134 | slotWeekLabel(); |
125 | break; | 135 | break; |
126 | case Event::MonthlyDay: | 136 | case Event::MonthlyDay: |
127 | currInterval = MONTH; | 137 | currInterval = MONTH; |
128 | setupMonthly(); | 138 | setupMonthly(); |
129 | fraExtra->setButton( 0 ); | 139 | fraExtra->setButton( 0 ); |
130 | slotMonthLabel( 0 ); | 140 | slotMonthLabel( 0 ); |
131 | break; | 141 | break; |
132 | case Event::MonthlyDate: | 142 | case Event::MonthlyDate: |
133 | currInterval = MONTH; | 143 | currInterval = MONTH; |
134 | setupMonthly(); | 144 | setupMonthly(); |
135 | fraExtra->setButton( 1 ); | 145 | fraExtra->setButton( 1 ); |
136 | slotMonthLabel( 1 ); | 146 | slotMonthLabel( 1 ); |
137 | break; | 147 | break; |
138 | case Event::Yearly: | 148 | case Event::Yearly: |
139 | currInterval = YEAR; | 149 | currInterval = YEAR; |
140 | setupYearly(); | 150 | setupYearly(); |
141 | break; | 151 | break; |
142 | } | 152 | } |
143 | fraType->setButton( currInterval ); | 153 | fraType->setButton( currInterval ); |
144 | spinFreq->setValue( rp.frequency ); | 154 | spinFreq->setValue( rp.frequency ); |
145 | if ( !rp.hasEndDate ) { | 155 | if ( !rp.hasEndDate ) { |
146 | cmdEnd->setText( RepeatEntryBase::tr("No End Date") ); | 156 | cmdEnd->setText( RepeatEntryBase::tr("No End Date") ); |
147 | chkNoEnd->setChecked( TRUE ); | 157 | chkNoEnd->setChecked( TRUE ); |
148 | } else | 158 | } else |
149 | cmdEnd->setText( TimeString::shortDate( end ) ); | 159 | cmdEnd->setText( TimeString::shortDate( end ) ); |
150 | } | 160 | } |
151 | 161 | ||
152 | RepeatEntry::~RepeatEntry() | 162 | RepeatEntry::~RepeatEntry() |
153 | { | 163 | { |
154 | } | 164 | } |
155 | 165 | ||
156 | Event::RepeatPattern RepeatEntry::repeatPattern() | 166 | Event::RepeatPattern RepeatEntry::repeatPattern() |
157 | { | 167 | { |
158 | QListIterator<QToolButton> it( listRTypeButtons ); | 168 | QListIterator<QToolButton> it( listRTypeButtons ); |
159 | QListIterator<QToolButton> itExtra( listExtra ); | 169 | QListIterator<QToolButton> itExtra( listExtra ); |
160 | Event::RepeatPattern rpTmp; | 170 | Event::RepeatPattern rpTmp; |
161 | int i; | 171 | int i; |
162 | for ( i = 0; *it; ++it, i++ ) { | 172 | for ( i = 0; *it; ++it, i++ ) { |
163 | if ( (*it)->isOn() ) { | 173 | if ( (*it)->isOn() ) { |
164 | switch ( i ) { | 174 | switch ( i ) { |
165 | case NONE: | 175 | case NONE: |
166 | rpTmp.type = Event::NoRepeat; | 176 | rpTmp.type = Event::NoRepeat; |
167 | break; | 177 | break; |
168 | case DAY: | 178 | case DAY: |
169 | rpTmp.type = Event::Daily; | 179 | rpTmp.type = Event::Daily; |
170 | break; | 180 | break; |
171 | case WEEK: | 181 | case WEEK: |
172 | rpTmp.type = Event::Weekly; | 182 | rpTmp.type = Event::Weekly; |
173 | rpTmp.days = 0; | 183 | rpTmp.days = 0; |
174 | int day; | 184 | int day; |
175 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { | 185 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { |
176 | if ( (*itExtra)->isOn() ) { | 186 | if ( (*itExtra)->isOn() ) { |
177 | if ( startWeekOnMonday ) | 187 | if ( startWeekOnMonday ) |
178 | rpTmp.days |= day; | 188 | rpTmp.days |= day; |
179 | else { | 189 | else { |
180 | if ( day == 1 ) | 190 | if ( day == 1 ) |
181 | rpTmp.days |= Event::SUN; | 191 | rpTmp.days |= Event::SUN; |
182 | else | 192 | else |
183 | rpTmp.days |= day >> 1; | 193 | rpTmp.days |= day >> 1; |
184 | } | 194 | } |
185 | } | 195 | } |
186 | } | 196 | } |
187 | break; | 197 | break; |
188 | case MONTH: | 198 | case MONTH: |
189 | if ( cmdExtra1->isOn() ) | 199 | if ( cmdExtra1->isOn() ) |
190 | rpTmp.type = Event::MonthlyDay; | 200 | rpTmp.type = Event::MonthlyDay; |
191 | else if ( cmdExtra2->isOn() ) | 201 | else if ( cmdExtra2->isOn() ) |
192 | rpTmp.type = Event::MonthlyDate; | 202 | rpTmp.type = Event::MonthlyDate; |
193 | // figure out the montly day... | 203 | // figure out the montly day... |
194 | rpTmp.position = week( start ); | 204 | rpTmp.position = week( start ); |
195 | break; | 205 | break; |
196 | case YEAR: | 206 | case YEAR: |
197 | rpTmp.type = Event::Yearly; | 207 | rpTmp.type = Event::Yearly; |
198 | break; | 208 | break; |
199 | } | 209 | } |
200 | break; // no need to keep looking! | 210 | break; // no need to keep looking! |
201 | } | 211 | } |
202 | } | 212 | } |
203 | rpTmp.frequency = spinFreq->value(); | 213 | rpTmp.frequency = spinFreq->value(); |
204 | rpTmp.hasEndDate = !chkNoEnd->isChecked(); | 214 | rpTmp.hasEndDate = !chkNoEnd->isChecked(); |
205 | if ( rpTmp.hasEndDate ) { | 215 | if ( rpTmp.hasEndDate ) { |
206 | rpTmp.setEndDate( end ); | 216 | rpTmp.setEndDate( end ); |
207 | } | 217 | } |
208 | // timestamp it... | 218 | // timestamp it... |
209 | rpTmp.createTime = time( NULL ); | 219 | rpTmp.createTime = time( NULL ); |
210 | return rpTmp; | 220 | return rpTmp; |
211 | } | 221 | } |
diff --git a/core/pim/datebook/repeatentry.h b/core/pim/datebook/repeatentry.h index 949fecd..d75af3c 100644 --- a/core/pim/datebook/repeatentry.h +++ b/core/pim/datebook/repeatentry.h | |||
@@ -1,98 +1,108 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | |
4 | ** This file is part of Qtopia Environment. | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | =. |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .=l. |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .>+-= |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | _;:, .> :=|. This program is free software; you can |
9 | ** packaging of this file. | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | ** | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ** | 13 | ._= =} : or (at your option) any later version. |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | .%`+i> _;_. |
15 | ** | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | ** not clear to you. | 17 | : .. .:, . . . without even the implied warranty of |
18 | ** | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | **********************************************************************/ | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
20 | 30 | ||
21 | #ifndef REPEATENTRY_H | 31 | #ifndef REPEATENTRY_H |
22 | #define REPEATENTRY_H | 32 | #define REPEATENTRY_H |
23 | 33 | ||
24 | #include "repeatentrybase.h" | 34 | #include "repeatentrybase.h" |
25 | 35 | ||
26 | #include <qpe/event.h> | 36 | #include <qpe/event.h> |
27 | 37 | ||
28 | #include <qcheckbox.h> | 38 | #include <qcheckbox.h> |
29 | #include <qbuttongroup.h> | 39 | #include <qbuttongroup.h> |
30 | #include <qdatetime.h> | 40 | #include <qdatetime.h> |
31 | #include <qlist.h> | 41 | #include <qlist.h> |
32 | #include <qtoolbutton.h> | 42 | #include <qtoolbutton.h> |
33 | 43 | ||
34 | class DateBookMonth; | 44 | class DateBookMonth; |
35 | 45 | ||
36 | class RepeatEntry : public RepeatEntryBase | 46 | class RepeatEntry : public RepeatEntryBase |
37 | { | 47 | { |
38 | Q_OBJECT | 48 | Q_OBJECT |
39 | public: | 49 | public: |
40 | RepeatEntry( bool startOnMonday, | 50 | RepeatEntry( bool startOnMonday, |
41 | const QDate &start, QWidget *parent = 0, const char *name = 0, | 51 | const QDate &start, QWidget *parent = 0, const char *name = 0, |
42 | bool modal = TRUE, WFlags fl = 0 ); | 52 | bool modal = TRUE, WFlags fl = 0 ); |
43 | RepeatEntry( bool startOnMonday, | 53 | RepeatEntry( bool startOnMonday, |
44 | const Event::RepeatPattern &rp, const QDate &start, | 54 | const Event::RepeatPattern &rp, const QDate &start, |
45 | QWidget *parent = 0, const char *name = 0, bool modal = TRUE, | 55 | QWidget *parent = 0, const char *name = 0, bool modal = TRUE, |
46 | WFlags fl = 0 ); | 56 | WFlags fl = 0 ); |
47 | ~RepeatEntry(); | 57 | ~RepeatEntry(); |
48 | 58 | ||
49 | Event::RepeatPattern repeatPattern(); | 59 | Event::RepeatPattern repeatPattern(); |
50 | QDate endDate() { return end; }; | 60 | QDate endDate() { return end; }; |
51 | 61 | ||
52 | public slots: | 62 | public slots: |
53 | void slotSetRType( int ); | 63 | void slotSetRType( int ); |
54 | void endDateChanged( int, int, int ); | 64 | void endDateChanged( int, int, int ); |
55 | void slotNoEnd( bool unused ); | 65 | void slotNoEnd( bool unused ); |
56 | 66 | ||
57 | private slots: | 67 | private slots: |
58 | void setupRepeatLabel( const QString& ); | 68 | void setupRepeatLabel( const QString& ); |
59 | void setupRepeatLabel( int ); | 69 | void setupRepeatLabel( int ); |
60 | void slotWeekLabel(); | 70 | void slotWeekLabel(); |
61 | void slotMonthLabel( int ); | 71 | void slotMonthLabel( int ); |
62 | void slotChangeStartOfWeek( bool onMonday ); | 72 | void slotChangeStartOfWeek( bool onMonday ); |
63 | 73 | ||
64 | private: | 74 | private: |
65 | void setupNone(); | 75 | void setupNone(); |
66 | void setupDaily(); | 76 | void setupDaily(); |
67 | void setupWeekly(); | 77 | void setupWeekly(); |
68 | void setupMonthly(); | 78 | void setupMonthly(); |
69 | void setupYearly(); | 79 | void setupYearly(); |
70 | 80 | ||
71 | enum repeatButtons { NONE, DAY, WEEK, MONTH, YEAR }; | 81 | enum repeatButtons { NONE, DAY, WEEK, MONTH, YEAR }; |
72 | void init(); | 82 | void init(); |
73 | inline void hideExtras(); | 83 | inline void hideExtras(); |
74 | void showRepeatStuff(); | 84 | void showRepeatStuff(); |
75 | 85 | ||
76 | QList<QToolButton> listRTypeButtons; | 86 | QList<QToolButton> listRTypeButtons; |
77 | QList<QToolButton> listExtra; | 87 | QList<QToolButton> listExtra; |
78 | QDate start; // only used in one spot... | 88 | QDate start; // only used in one spot... |
79 | QDate end; | 89 | QDate end; |
80 | repeatButtons currInterval; | 90 | repeatButtons currInterval; |
81 | bool startWeekOnMonday; | 91 | bool startWeekOnMonday; |
82 | DateBookMonth *repeatPicker; | 92 | DateBookMonth *repeatPicker; |
83 | }; | 93 | }; |
84 | 94 | ||
85 | inline void RepeatEntry::hideExtras() | 95 | inline void RepeatEntry::hideExtras() |
86 | { | 96 | { |
87 | // hide the extra buttons... | 97 | // hide the extra buttons... |
88 | fraExtra->hide(); | 98 | fraExtra->hide(); |
89 | chkNoEnd->hide(); | 99 | chkNoEnd->hide(); |
90 | QListIterator<QToolButton> it( listExtra ); | 100 | QListIterator<QToolButton> it( listExtra ); |
91 | for ( ; *it; ++it ) { | 101 | for ( ; *it; ++it ) { |
92 | (*it)->hide(); | 102 | (*it)->hide(); |
93 | (*it)->setOn( FALSE ); | 103 | (*it)->setOn( FALSE ); |
94 | } | 104 | } |
95 | 105 | ||
96 | } | 106 | } |
97 | 107 | ||
98 | #endif | 108 | #endif |