author | harlekin <harlekin> | 2002-02-15 20:02:50 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-02-15 20:02:50 (UTC) |
commit | 50bc570309b0da3ecd4a9d0a0448b58a9a8ed2ab (patch) (unidiff) | |
tree | fefefb94f5d4c0eae01ef441900a0c7c9dd3e22b | |
parent | 8ccfea56d43fde77717cfd354b62ccb3f67585d1 (diff) | |
download | opie-50bc570309b0da3ecd4a9d0a0448b58a9a8ed2ab.zip opie-50bc570309b0da3ecd4a9d0a0448b58a9a8ed2ab.tar.gz opie-50bc570309b0da3ecd4a9d0a0448b58a9a8ed2ab.tar.bz2 |
added a icon for the today view to the menubar and change it in the view menu to first place
-rw-r--r-- | core/pim/datebook/datebook.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 6ec6cc2..e8d808f 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -1,355 +1,358 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | ** $Id$ | 19 | ** $Id$ |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | 22 | ||
23 | #define QTOPIA_INTERNAL_FD | ||
24 | |||
23 | #include "datebook.h" | 25 | #include "datebook.h" |
24 | #include "datebookday.h" | 26 | #include "datebookday.h" |
25 | #include "datebooksettings.h" | 27 | #include "datebooksettings.h" |
26 | #include "datebookweek.h" | 28 | #include "datebookweek.h" |
27 | #include "dateentryimpl.h" | 29 | #include "dateentryimpl.h" |
28 | 30 | ||
29 | #include <qpe/datebookmonth.h> | 31 | #include <qpe/datebookmonth.h> |
30 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
31 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
32 | #include <qpe/qpedebug.h> | 34 | #include <qpe/qpedebug.h> |
33 | #include <qpe/event.h> | 35 | #include <qpe/event.h> |
34 | #include <qpe/finddialog.h> | 36 | #include <qpe/finddialog.h> |
35 | #include <qpe/ir.h> | 37 | #include <qpe/ir.h> |
36 | #include <qpe/qpemenubar.h> | 38 | #include <qpe/qpemenubar.h> |
37 | #include <qpe/qpemessagebox.h> | 39 | #include <qpe/qpemessagebox.h> |
38 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
39 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
40 | #include <qpe/timestring.h> | 42 | #include <qpe/timestring.h> |
41 | #include <qpe/qpetoolbar.h> | 43 | #include <qpe/qpetoolbar.h> |
42 | #include <qpe/tzselect.h> | 44 | #include <qpe/tzselect.h> |
43 | #include <qpe/xmlreader.h> | 45 | #include <qpe/xmlreader.h> |
44 | 46 | ||
45 | #include <qaction.h> | 47 | #include <qaction.h> |
46 | #include <qcopchannel_qws.h> | 48 | #include <qcopchannel_qws.h> |
47 | #include <qdatetime.h> | 49 | #include <qdatetime.h> |
48 | #include <qdialog.h> | 50 | #include <qdialog.h> |
49 | #include <qfile.h> | 51 | #include <qfile.h> |
50 | #include <qlabel.h> | 52 | #include <qlabel.h> |
51 | #include <qlayout.h> | 53 | #include <qlayout.h> |
52 | #include <qmessagebox.h> | 54 | #include <qmessagebox.h> |
53 | #include <qpopupmenu.h> | 55 | #include <qpopupmenu.h> |
54 | #include <qpushbutton.h> | 56 | #include <qpushbutton.h> |
55 | #include <qtextcodec.h> | 57 | #include <qtextcodec.h> |
56 | #include <qtextstream.h> | 58 | #include <qtextstream.h> |
57 | #include <qtl.h> | 59 | #include <qtl.h> |
58 | #include <qwidgetstack.h> | 60 | #include <qwidgetstack.h> |
59 | #include <qwindowsystem_qws.h> | 61 | #include <qwindowsystem_qws.h> |
60 | 62 | ||
61 | #include <sys/stat.h> | 63 | #include <sys/stat.h> |
62 | #include <sys/types.h> | 64 | #include <sys/types.h> |
63 | #include <fcntl.h> | 65 | #include <fcntl.h> |
64 | #include <unistd.h> | 66 | #include <unistd.h> |
65 | 67 | ||
66 | #include <stdlib.h> | 68 | #include <stdlib.h> |
67 | 69 | ||
68 | #define DAY 1 | 70 | #define DAY 1 |
69 | #define WEEK 2 | 71 | #define WEEK 2 |
70 | #define MONTH 3 | 72 | #define MONTH 3 |
71 | 73 | ||
72 | 74 | ||
73 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | 75 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) |
74 | : QMainWindow( parent, "datebook", f ), | 76 | : QMainWindow( parent, "datebook", f ), |
75 | aPreset( FALSE ), | 77 | aPreset( FALSE ), |
76 | presetTime( -1 ), | 78 | presetTime( -1 ), |
77 | startTime( 8 ), // an acceptable default | 79 | startTime( 8 ), // an acceptable default |
78 | syncing(FALSE), | 80 | syncing(FALSE), |
79 | inSearch(FALSE) | 81 | inSearch(FALSE) |
80 | { | 82 | { |
81 | QTime t; | 83 | QTime t; |
82 | t.start(); | 84 | t.start(); |
83 | db = new DateBookDB; | 85 | db = new DateBookDB; |
84 | qDebug("loading db t=%d", t.elapsed() ); | 86 | qDebug("loading db t=%d", t.elapsed() ); |
85 | loadSettings(); | 87 | loadSettings(); |
86 | setCaption( tr("Calendar") ); | 88 | setCaption( tr("Calendar") ); |
87 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | 89 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); |
88 | 90 | ||
89 | setToolBarsMovable( FALSE ); | 91 | setToolBarsMovable( FALSE ); |
90 | 92 | ||
91 | QPEToolBar *bar = new QPEToolBar( this ); | 93 | QPEToolBar *bar = new QPEToolBar( this ); |
92 | bar->setHorizontalStretchable( TRUE ); | 94 | bar->setHorizontalStretchable( TRUE ); |
93 | 95 | ||
94 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 96 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
95 | mb->setMargin( 0 ); | 97 | mb->setMargin( 0 ); |
96 | 98 | ||
97 | QPEToolBar *sub_bar = new QPEToolBar(this); | 99 | QPEToolBar *sub_bar = new QPEToolBar(this); |
98 | 100 | ||
99 | QPopupMenu *view = new QPopupMenu( this ); | 101 | QPopupMenu *view = new QPopupMenu( this ); |
100 | QPopupMenu *settings = new QPopupMenu( this ); | 102 | QPopupMenu *settings = new QPopupMenu( this ); |
101 | 103 | ||
102 | mb->insertItem( tr( "View" ), view ); | 104 | mb->insertItem( tr( "View" ), view ); |
103 | mb->insertItem( tr( "Settings" ), settings ); | 105 | mb->insertItem( tr( "Settings" ), settings ); |
104 | 106 | ||
105 | QActionGroup *g = new QActionGroup( this ); | 107 | QActionGroup *g = new QActionGroup( this ); |
106 | g->setExclusive( TRUE ); | 108 | g->setExclusive( TRUE ); |
107 | 109 | ||
108 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 110 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), |
109 | QString::null, 0, this, 0 ); | 111 | QString::null, 0, this, 0 ); |
110 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 112 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
111 | a->addTo( sub_bar ); | 113 | a->addTo( sub_bar ); |
112 | 114 | ||
115 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 ); | ||
116 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | ||
117 | a->addTo( sub_bar ); | ||
118 | a->addTo( view ); | ||
119 | |||
113 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); | 120 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); |
114 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); | 121 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); |
115 | a->addTo( sub_bar ); | 122 | a->addTo( sub_bar ); |
116 | a->addTo( view ); | 123 | a->addTo( view ); |
117 | a->setToggleAction( TRUE ); | 124 | a->setToggleAction( TRUE ); |
118 | a->setOn( TRUE ); | 125 | a->setOn( TRUE ); |
119 | dayAction = a; | 126 | dayAction = a; |
120 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); | 127 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); |
121 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); | 128 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); |
122 | a->addTo( sub_bar ); | 129 | a->addTo( sub_bar ); |
123 | a->addTo( view ); | 130 | a->addTo( view ); |
124 | a->setToggleAction( TRUE ); | 131 | a->setToggleAction( TRUE ); |
125 | weekAction = a; | 132 | weekAction = a; |
126 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); | 133 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); |
127 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); | 134 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); |
128 | a->addTo( sub_bar ); | 135 | a->addTo( sub_bar ); |
129 | a->addTo( view ); | 136 | a->addTo( view ); |
130 | a->setToggleAction( TRUE ); | 137 | a->setToggleAction( TRUE ); |
131 | monthAction = a; | 138 | monthAction = a; |
132 | 139 | ||
133 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); | 140 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); |
134 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 141 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
135 | a->addTo( sub_bar ); | 142 | a->addTo( sub_bar ); |
136 | 143 | ||
137 | a = new QAction( tr( "Today" ), QString::null, 0, 0 ); | ||
138 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | ||
139 | a->addTo( view ); | ||
140 | |||
141 | a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); | 144 | a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); |
142 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 145 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
143 | a->addTo( settings ); | 146 | a->addTo( settings ); |
144 | 147 | ||
145 | views = new QWidgetStack( this ); | 148 | views = new QWidgetStack( this ); |
146 | setCentralWidget( views ); | 149 | setCentralWidget( views ); |
147 | 150 | ||
148 | dayView = 0; | 151 | dayView = 0; |
149 | weekView = 0; | 152 | weekView = 0; |
150 | monthView = 0; | 153 | monthView = 0; |
151 | 154 | ||
152 | viewDay(); | 155 | viewDay(); |
153 | connect( qApp, SIGNAL(clockChanged(bool)), | 156 | connect( qApp, SIGNAL(clockChanged(bool)), |
154 | this, SLOT(changeClock(bool)) ); | 157 | this, SLOT(changeClock(bool)) ); |
155 | connect( qApp, SIGNAL(weekChanged(bool)), | 158 | connect( qApp, SIGNAL(weekChanged(bool)), |
156 | this, SLOT(changeWeek(bool)) ); | 159 | this, SLOT(changeWeek(bool)) ); |
157 | 160 | ||
158 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 161 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
159 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | 162 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), |
160 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); | 163 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); |
161 | #endif | 164 | #endif |
162 | 165 | ||
163 | // listen on QPE/System | 166 | // listen on QPE/System |
164 | #if defined(Q_WS_QWS) | 167 | #if defined(Q_WS_QWS) |
165 | #if !defined(QT_NO_COP) | 168 | #if !defined(QT_NO_COP) |
166 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 169 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
167 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 170 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
168 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 171 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
169 | #endif | 172 | #endif |
170 | #endif | 173 | #endif |
171 | 174 | ||
172 | qDebug("done t=%d", t.elapsed() ); | 175 | qDebug("done t=%d", t.elapsed() ); |
173 | 176 | ||
174 | } | 177 | } |
175 | 178 | ||
176 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 179 | void DateBook::receive( const QCString &msg, const QByteArray &data ) |
177 | { | 180 | { |
178 | QDataStream stream( data, IO_ReadOnly ); | 181 | QDataStream stream( data, IO_ReadOnly ); |
179 | if ( msg == "timeChange(QString)" ) { | 182 | if ( msg == "timeChange(QString)" ) { |
180 | // update active view! | 183 | // update active view! |
181 | if ( dayAction->isOn() ) | 184 | if ( dayAction->isOn() ) |
182 | viewDay(); | 185 | viewDay(); |
183 | else if ( weekAction->isOn() ) | 186 | else if ( weekAction->isOn() ) |
184 | viewWeek(); | 187 | viewWeek(); |
185 | else if ( monthAction->isOn() ) | 188 | else if ( monthAction->isOn() ) |
186 | viewMonth(); | 189 | viewMonth(); |
187 | } | 190 | } |
188 | } | 191 | } |
189 | 192 | ||
190 | DateBook::~DateBook() | 193 | DateBook::~DateBook() |
191 | { | 194 | { |
192 | } | 195 | } |
193 | 196 | ||
194 | void DateBook::slotSettings() | 197 | void DateBook::slotSettings() |
195 | { | 198 | { |
196 | DateBookSettings frmSettings( ampm, this ); | 199 | DateBookSettings frmSettings( ampm, this ); |
197 | frmSettings.setStartTime( startTime ); | 200 | frmSettings.setStartTime( startTime ); |
198 | frmSettings.setAlarmPreset( aPreset, presetTime ); | 201 | frmSettings.setAlarmPreset( aPreset, presetTime ); |
199 | #if defined (Q_WS_QWS) || defined(_WS_QWS_) | 202 | #if defined (Q_WS_QWS) || defined(_WS_QWS_) |
200 | frmSettings.showMaximized(); | 203 | frmSettings.showMaximized(); |
201 | #endif | 204 | #endif |
202 | 205 | ||
203 | if ( frmSettings.exec() ) { | 206 | if ( frmSettings.exec() ) { |
204 | aPreset = frmSettings.alarmPreset(); | 207 | aPreset = frmSettings.alarmPreset(); |
205 | presetTime = frmSettings.presetTime(); | 208 | presetTime = frmSettings.presetTime(); |
206 | startTime = frmSettings.startTime(); | 209 | startTime = frmSettings.startTime(); |
207 | if ( dayView ) | 210 | if ( dayView ) |
208 | dayView->setStartViewTime( startTime ); | 211 | dayView->setStartViewTime( startTime ); |
209 | if ( weekView ) | 212 | if ( weekView ) |
210 | weekView->setStartViewTime( startTime ); | 213 | weekView->setStartViewTime( startTime ); |
211 | saveSettings(); | 214 | saveSettings(); |
212 | 215 | ||
213 | // make the change obvious | 216 | // make the change obvious |
214 | if ( views->visibleWidget() ) { | 217 | if ( views->visibleWidget() ) { |
215 | if ( views->visibleWidget() == dayView ) | 218 | if ( views->visibleWidget() == dayView ) |
216 | dayView->redraw(); | 219 | dayView->redraw(); |
217 | else if ( views->visibleWidget() == weekView ) | 220 | else if ( views->visibleWidget() == weekView ) |
218 | weekView->redraw(); | 221 | weekView->redraw(); |
219 | } | 222 | } |
220 | } | 223 | } |
221 | } | 224 | } |
222 | 225 | ||
223 | void DateBook::fileNew() | 226 | void DateBook::fileNew() |
224 | { | 227 | { |
225 | slotNewEventFromKey(""); | 228 | slotNewEventFromKey(""); |
226 | } | 229 | } |
227 | 230 | ||
228 | QString DateBook::checkEvent(const Event &e) | 231 | QString DateBook::checkEvent(const Event &e) |
229 | { | 232 | { |
230 | /* check if overlaps with itself */ | 233 | /* check if overlaps with itself */ |
231 | bool checkFailed = FALSE; | 234 | bool checkFailed = FALSE; |
232 | 235 | ||
233 | /* check the next 12 repeats. should catch most problems */ | 236 | /* check the next 12 repeats. should catch most problems */ |
234 | QDate current_date = e.start().date(); | 237 | QDate current_date = e.start().date(); |
235 | Event previous = e; | 238 | Event previous = e; |
236 | for(int i = 0; i < 12; i++) | 239 | for(int i = 0; i < 12; i++) |
237 | { | 240 | { |
238 | QDateTime next; | 241 | QDateTime next; |
239 | if (!nextOccurance(previous, current_date.addDays(1), next)) { | 242 | if (!nextOccurance(previous, current_date.addDays(1), next)) { |
240 | break; // no more repeats | 243 | break; // no more repeats |
241 | } | 244 | } |
242 | if(next < previous.end()) { | 245 | if(next < previous.end()) { |
243 | checkFailed = TRUE; | 246 | checkFailed = TRUE; |
244 | break; | 247 | break; |
245 | } | 248 | } |
246 | current_date = next.date(); | 249 | current_date = next.date(); |
247 | } | 250 | } |
248 | 251 | ||
249 | if(checkFailed) | 252 | if(checkFailed) |
250 | return tr("Event duration is potentially longer\n" | 253 | return tr("Event duration is potentially longer\n" |
251 | "than interval between repeats."); | 254 | "than interval between repeats."); |
252 | 255 | ||
253 | return QString::null; | 256 | return QString::null; |
254 | } | 257 | } |
255 | 258 | ||
256 | QDate DateBook::currentDate() | 259 | QDate DateBook::currentDate() |
257 | { | 260 | { |
258 | QDate d = QDate::currentDate(); | 261 | QDate d = QDate::currentDate(); |
259 | 262 | ||
260 | if ( dayView && views->visibleWidget() == dayView ) { | 263 | if ( dayView && views->visibleWidget() == dayView ) { |
261 | d = dayView->date(); | 264 | d = dayView->date(); |
262 | } else if ( weekView && views->visibleWidget() == weekView ) { | 265 | } else if ( weekView && views->visibleWidget() == weekView ) { |
263 | d = weekView->date(); | 266 | d = weekView->date(); |
264 | } else if ( monthView && views->visibleWidget() == monthView ) { | 267 | } else if ( monthView && views->visibleWidget() == monthView ) { |
265 | d = monthView->selectedDate(); | 268 | d = monthView->selectedDate(); |
266 | } | 269 | } |
267 | 270 | ||
268 | return d; | 271 | return d; |
269 | } | 272 | } |
270 | 273 | ||
271 | void DateBook::viewDay() | 274 | void DateBook::viewDay() |
272 | { | 275 | { |
273 | initDay(); | 276 | initDay(); |
274 | dayAction->setOn( TRUE ); | 277 | dayAction->setOn( TRUE ); |
275 | QDate d = currentDate(); | 278 | QDate d = currentDate(); |
276 | dayView->setDate( d ); | 279 | dayView->setDate( d ); |
277 | views->raiseWidget( dayView ); | 280 | views->raiseWidget( dayView ); |
278 | dayView->redraw(); | 281 | dayView->redraw(); |
279 | } | 282 | } |
280 | 283 | ||
281 | void DateBook::viewWeek() | 284 | void DateBook::viewWeek() |
282 | { | 285 | { |
283 | initWeek(); | 286 | initWeek(); |
284 | weekAction->setOn( TRUE ); | 287 | weekAction->setOn( TRUE ); |
285 | QDate d = currentDate(); | 288 | QDate d = currentDate(); |
286 | weekView->setDate( d ); | 289 | weekView->setDate( d ); |
287 | views->raiseWidget( weekView ); | 290 | views->raiseWidget( weekView ); |
288 | weekView->redraw(); | 291 | weekView->redraw(); |
289 | } | 292 | } |
290 | 293 | ||
291 | void DateBook::viewMonth() | 294 | void DateBook::viewMonth() |
292 | { | 295 | { |
293 | initMonth(); | 296 | initMonth(); |
294 | monthAction->setOn( TRUE ); | 297 | monthAction->setOn( TRUE ); |
295 | QDate d = currentDate(); | 298 | QDate d = currentDate(); |
296 | monthView->setDate( d.year(), d.month(), d.day() ); | 299 | monthView->setDate( d.year(), d.month(), d.day() ); |
297 | views->raiseWidget( monthView ); | 300 | views->raiseWidget( monthView ); |
298 | monthView->redraw(); | 301 | monthView->redraw(); |
299 | } | 302 | } |
300 | 303 | ||
301 | void DateBook::editEvent( const Event &e ) | 304 | void DateBook::editEvent( const Event &e ) |
302 | { | 305 | { |
303 | if (syncing) { | 306 | if (syncing) { |
304 | QMessageBox::warning( this, tr("Calendar"), | 307 | QMessageBox::warning( this, tr("Calendar"), |
305 | tr( "Can not edit data, currently syncing") ); | 308 | tr( "Can not edit data, currently syncing") ); |
306 | return; | 309 | return; |
307 | } | 310 | } |
308 | 311 | ||
309 | // workaround added for text input. | 312 | // workaround added for text input. |
310 | QDialog editDlg( this, 0, TRUE ); | 313 | QDialog editDlg( this, 0, TRUE ); |
311 | DateEntry *entry; | 314 | DateEntry *entry; |
312 | editDlg.setCaption( tr("Edit Event") ); | 315 | editDlg.setCaption( tr("Edit Event") ); |
313 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 316 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
314 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 317 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
315 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 318 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
316 | // KLUDGE!!! | 319 | // KLUDGE!!! |
317 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 320 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
318 | vb->addWidget( sv ); | 321 | vb->addWidget( sv ); |
319 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); | 322 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); |
320 | entry->timezone->setEnabled( FALSE ); | 323 | entry->timezone->setEnabled( FALSE ); |
321 | sv->addChild( entry ); | 324 | sv->addChild( entry ); |
322 | 325 | ||
323 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 326 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
324 | editDlg.showMaximized(); | 327 | editDlg.showMaximized(); |
325 | #endif | 328 | #endif |
326 | while (editDlg.exec() ) { | 329 | while (editDlg.exec() ) { |
327 | Event newEv = entry->event(); | 330 | Event newEv = entry->event(); |
328 | QString error = checkEvent(newEv); | 331 | QString error = checkEvent(newEv); |
329 | if (!error.isNull()) { | 332 | if (!error.isNull()) { |
330 | if (QMessageBox::warning(this, "error box", | 333 | if (QMessageBox::warning(this, "error box", |
331 | error, "Fix it", "Continue", 0, 0, 1) == 0) | 334 | error, "Fix it", "Continue", 0, 0, 1) == 0) |
332 | continue; | 335 | continue; |
333 | } | 336 | } |
334 | db->editEvent(e, newEv); | 337 | db->editEvent(e, newEv); |
335 | emit newEvent(); | 338 | emit newEvent(); |
336 | break; | 339 | break; |
337 | } | 340 | } |
338 | } | 341 | } |
339 | 342 | ||
340 | void DateBook::removeEvent( const Event &e ) | 343 | void DateBook::removeEvent( const Event &e ) |
341 | { | 344 | { |
342 | if (syncing) { | 345 | if (syncing) { |
343 | QMessageBox::warning( this, tr("Calendar"), | 346 | QMessageBox::warning( this, tr("Calendar"), |
344 | tr( "Can not edit data, currently syncing") ); | 347 | tr( "Can not edit data, currently syncing") ); |
345 | return; | 348 | return; |
346 | } | 349 | } |
347 | 350 | ||
348 | QString strName = e.description(); | 351 | QString strName = e.description(); |
349 | 352 | ||
350 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) | 353 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) |
351 | return; | 354 | return; |
352 | 355 | ||
353 | db->removeEvent( e ); | 356 | db->removeEvent( e ); |
354 | if ( views->visibleWidget() == dayView && dayView ) | 357 | if ( views->visibleWidget() == dayView && dayView ) |
355 | dayView->redraw(); | 358 | dayView->redraw(); |