-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,643 +1,646 @@ | |||
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(); |
356 | } | 359 | } |
357 | 360 | ||
358 | void DateBook::addEvent( const Event &e ) | 361 | void DateBook::addEvent( const Event &e ) |
359 | { | 362 | { |
360 | QDate d = e.start().date(); | 363 | QDate d = e.start().date(); |
361 | initDay(); | 364 | initDay(); |
362 | dayView->setDate( d ); | 365 | dayView->setDate( d ); |
363 | } | 366 | } |
364 | 367 | ||
365 | void DateBook::showDay( int year, int month, int day ) | 368 | void DateBook::showDay( int year, int month, int day ) |
366 | { | 369 | { |
367 | initDay(); | 370 | initDay(); |
368 | dayView->setDate( year, month, day ); | 371 | dayView->setDate( year, month, day ); |
369 | views->raiseWidget( dayView ); | 372 | views->raiseWidget( dayView ); |
370 | dayAction->setOn( TRUE ); | 373 | dayAction->setOn( TRUE ); |
371 | } | 374 | } |
372 | 375 | ||
373 | void DateBook::initDay() | 376 | void DateBook::initDay() |
374 | { | 377 | { |
375 | if ( !dayView ) { | 378 | if ( !dayView ) { |
376 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); | 379 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); |
377 | views->addWidget( dayView, DAY ); | 380 | views->addWidget( dayView, DAY ); |
378 | dayView->setStartViewTime( startTime ); | 381 | dayView->setStartViewTime( startTime ); |
379 | connect( this, SIGNAL( newEvent() ), | 382 | connect( this, SIGNAL( newEvent() ), |
380 | dayView, SLOT( redraw() ) ); | 383 | dayView, SLOT( redraw() ) ); |
381 | connect( dayView, SIGNAL( newEvent() ), | 384 | connect( dayView, SIGNAL( newEvent() ), |
382 | this, SLOT( fileNew() ) ); | 385 | this, SLOT( fileNew() ) ); |
383 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), | 386 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), |
384 | this, SLOT( removeEvent( const Event & ) ) ); | 387 | this, SLOT( removeEvent( const Event & ) ) ); |
385 | connect( dayView, SIGNAL( editEvent( const Event & ) ), | 388 | connect( dayView, SIGNAL( editEvent( const Event & ) ), |
386 | this, SLOT( editEvent( const Event & ) ) ); | 389 | this, SLOT( editEvent( const Event & ) ) ); |
387 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), | 390 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), |
388 | this, SLOT( beamEvent( const Event & ) ) ); | 391 | this, SLOT( beamEvent( const Event & ) ) ); |
389 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), | 392 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), |
390 | this, SLOT(slotNewEventFromKey(const QString &)) ); | 393 | this, SLOT(slotNewEventFromKey(const QString &)) ); |
391 | } | 394 | } |
392 | } | 395 | } |
393 | 396 | ||
394 | void DateBook::initWeek() | 397 | void DateBook::initWeek() |
395 | { | 398 | { |
396 | if ( !weekView ) { | 399 | if ( !weekView ) { |
397 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); | 400 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); |
398 | weekView->setStartViewTime( startTime ); | 401 | weekView->setStartViewTime( startTime ); |
399 | views->addWidget( weekView, WEEK ); | 402 | views->addWidget( weekView, WEEK ); |
400 | connect( weekView, SIGNAL( showDate( int, int, int ) ), | 403 | connect( weekView, SIGNAL( showDate( int, int, int ) ), |
401 | this, SLOT( showDay( int, int, int ) ) ); | 404 | this, SLOT( showDay( int, int, int ) ) ); |
402 | connect( this, SIGNAL( newEvent() ), | 405 | connect( this, SIGNAL( newEvent() ), |
403 | weekView, SLOT( redraw() ) ); | 406 | weekView, SLOT( redraw() ) ); |
404 | } | 407 | } |
405 | //But also get it right: the year that we display can be different | 408 | //But also get it right: the year that we display can be different |
406 | //from the year of the current date. So, first find the year | 409 | //from the year of the current date. So, first find the year |
407 | //number of the current week. | 410 | //number of the current week. |
408 | 411 | ||
409 | int yearNumber, totWeeks; | 412 | int yearNumber, totWeeks; |
410 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); | 413 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); |
411 | 414 | ||
412 | QDate d = QDate( yearNumber, 12, 31 ); | 415 | QDate d = QDate( yearNumber, 12, 31 ); |
413 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 416 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
414 | 417 | ||
415 | while ( totWeeks == 1 ) { | 418 | while ( totWeeks == 1 ) { |
416 | d = d.addDays( -1 ); | 419 | d = d.addDays( -1 ); |
417 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 420 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
418 | } | 421 | } |
419 | if ( totWeeks != weekView->totalWeeks() ) | 422 | if ( totWeeks != weekView->totalWeeks() ) |
420 | weekView->setTotalWeeks( totWeeks ); | 423 | weekView->setTotalWeeks( totWeeks ); |
421 | } | 424 | } |
422 | 425 | ||
423 | void DateBook::initMonth() | 426 | void DateBook::initMonth() |
424 | { | 427 | { |
425 | if ( !monthView ) { | 428 | if ( !monthView ) { |
426 | monthView = new DateBookMonth( views, "month view", FALSE, db ); | 429 | monthView = new DateBookMonth( views, "month view", FALSE, db ); |
427 | views->addWidget( monthView, MONTH ); | 430 | views->addWidget( monthView, MONTH ); |
428 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), | 431 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), |
429 | this, SLOT( showDay( int, int, int ) ) ); | 432 | this, SLOT( showDay( int, int, int ) ) ); |
430 | connect( this, SIGNAL( newEvent() ), | 433 | connect( this, SIGNAL( newEvent() ), |
431 | monthView, SLOT( redraw() ) ); | 434 | monthView, SLOT( redraw() ) ); |
432 | qApp->processEvents(); | 435 | qApp->processEvents(); |
433 | } | 436 | } |
434 | } | 437 | } |
435 | 438 | ||
436 | void DateBook::loadSettings() | 439 | void DateBook::loadSettings() |
437 | { | 440 | { |
438 | { | 441 | { |
439 | Config config( "qpe" ); | 442 | Config config( "qpe" ); |
440 | config.setGroup("Time"); | 443 | config.setGroup("Time"); |
441 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 444 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
442 | onMonday = config.readBoolEntry( "MONDAY" ); | 445 | onMonday = config.readBoolEntry( "MONDAY" ); |
443 | } | 446 | } |
444 | 447 | ||
445 | { | 448 | { |
446 | Config config("DateBook"); | 449 | Config config("DateBook"); |
447 | config.setGroup("Main"); | 450 | config.setGroup("Main"); |
448 | startTime = config.readNumEntry("startviewtime", 8); | 451 | startTime = config.readNumEntry("startviewtime", 8); |
449 | aPreset = config.readBoolEntry("alarmpreset"); | 452 | aPreset = config.readBoolEntry("alarmpreset"); |
450 | presetTime = config.readNumEntry("presettime"); | 453 | presetTime = config.readNumEntry("presettime"); |
451 | } | 454 | } |
452 | } | 455 | } |
453 | 456 | ||
454 | void DateBook::saveSettings() | 457 | void DateBook::saveSettings() |
455 | { | 458 | { |
456 | Config config( "qpe" ); | 459 | Config config( "qpe" ); |
457 | Config configDB( "DateBook" ); | 460 | Config configDB( "DateBook" ); |
458 | configDB.setGroup( "Main" ); | 461 | configDB.setGroup( "Main" ); |
459 | configDB.writeEntry("startviewtime",startTime); | 462 | configDB.writeEntry("startviewtime",startTime); |
460 | configDB.writeEntry("alarmpreset",aPreset); | 463 | configDB.writeEntry("alarmpreset",aPreset); |
461 | configDB.writeEntry("presettime",presetTime); | 464 | configDB.writeEntry("presettime",presetTime); |
462 | } | 465 | } |
463 | 466 | ||
464 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) | 467 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) |
465 | { | 468 | { |
466 | bool needShow = FALSE; | 469 | bool needShow = FALSE; |
467 | if ( msg == "alarm(QDateTime,int)" ) { | 470 | if ( msg == "alarm(QDateTime,int)" ) { |
468 | QDataStream ds(data,IO_ReadOnly); | 471 | QDataStream ds(data,IO_ReadOnly); |
469 | QDateTime when; int warn; | 472 | QDateTime when; int warn; |
470 | ds >> when >> warn; | 473 | ds >> when >> warn; |
471 | 474 | ||
472 | // check to make it's okay to continue, | 475 | // check to make it's okay to continue, |
473 | // this is the case that the time was set ahead, and | 476 | // this is the case that the time was set ahead, and |
474 | // we are forced given a stale alarm... | 477 | // we are forced given a stale alarm... |
475 | QDateTime current = QDateTime::currentDateTime(); | 478 | QDateTime current = QDateTime::currentDateTime(); |
476 | if ( current.time().hour() != when.time().hour() | 479 | if ( current.time().hour() != when.time().hour() |
477 | && current.time().minute() != when.time().minute() ) | 480 | && current.time().minute() != when.time().minute() ) |
478 | return; | 481 | return; |
479 | 482 | ||
480 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); | 483 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); |
481 | if ( list.count() > 0 ) { | 484 | if ( list.count() > 0 ) { |
482 | QString msg; | 485 | QString msg; |
483 | bool bSound = FALSE; | 486 | bool bSound = FALSE; |
484 | int stopTimer = 0; | 487 | int stopTimer = 0; |
485 | bool found = FALSE; | 488 | bool found = FALSE; |
486 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 489 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); |
487 | it!=list.end(); ++it ) { | 490 | it!=list.end(); ++it ) { |
488 | if ( (*it).event().hasAlarm() ) { | 491 | if ( (*it).event().hasAlarm() ) { |
489 | found = TRUE; | 492 | found = TRUE; |
490 | msg += "<CENTER><B>" + (*it).description() + "</B>" | 493 | msg += "<CENTER><B>" + (*it).description() + "</B>" |
491 | + "<BR>" + (*it).location() + "<BR>" | 494 | + "<BR>" + (*it).location() + "<BR>" |
492 | + TimeString::dateString((*it).event().start(),ampm) | 495 | + TimeString::dateString((*it).event().start(),ampm) |
493 | + (warn | 496 | + (warn |
494 | ? tr(" (in " + QString::number(warn) | 497 | ? tr(" (in " + QString::number(warn) |
495 | + tr(" minutes)")) | 498 | + tr(" minutes)")) |
496 | : QString("")) | 499 | : QString("")) |
497 | + "<BR>" | 500 | + "<BR>" |
498 | + (*it).notes() + "</CENTER>"; | 501 | + (*it).notes() + "</CENTER>"; |
499 | if ( (*it).event().alarmSound() != Event::Silent ) { | 502 | if ( (*it).event().alarmSound() != Event::Silent ) { |
500 | bSound = TRUE; | 503 | bSound = TRUE; |
501 | } | 504 | } |
502 | } | 505 | } |
503 | } | 506 | } |
504 | if ( found ) { | 507 | if ( found ) { |
505 | if ( bSound ) { | 508 | if ( bSound ) { |
506 | Sound::soundAlarm(); | 509 | Sound::soundAlarm(); |
507 | stopTimer = startTimer( 5000 ); | 510 | stopTimer = startTimer( 5000 ); |
508 | } | 511 | } |
509 | 512 | ||
510 | QDialog dlg( this, 0, TRUE ); | 513 | QDialog dlg( this, 0, TRUE ); |
511 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); | 514 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); |
512 | QScrollView *view = new QScrollView( &dlg, "scrollView"); | 515 | QScrollView *view = new QScrollView( &dlg, "scrollView"); |
513 | view->setResizePolicy( QScrollView::AutoOneFit ); | 516 | view->setResizePolicy( QScrollView::AutoOneFit ); |
514 | vb->addWidget( view ); | 517 | vb->addWidget( view ); |
515 | QLabel *lblMsg = new QLabel( msg, &dlg ); | 518 | QLabel *lblMsg = new QLabel( msg, &dlg ); |
516 | view->addChild( lblMsg ); | 519 | view->addChild( lblMsg ); |
517 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); | 520 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); |
518 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); | 521 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); |
519 | vb->addWidget( cmdOk ); | 522 | vb->addWidget( cmdOk ); |
520 | 523 | ||
521 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 524 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
522 | dlg.showMaximized(); | 525 | dlg.showMaximized(); |
523 | #endif | 526 | #endif |
524 | needShow = dlg.exec(); | 527 | needShow = dlg.exec(); |
525 | 528 | ||
526 | if ( bSound ) | 529 | if ( bSound ) |
527 | killTimer( stopTimer ); | 530 | killTimer( stopTimer ); |
528 | } | 531 | } |
529 | } | 532 | } |
530 | } else if ( msg == "nextView()" ) { | 533 | } else if ( msg == "nextView()" ) { |
531 | QWidget* cur = views->visibleWidget(); | 534 | QWidget* cur = views->visibleWidget(); |
532 | if ( cur ) { | 535 | if ( cur ) { |
533 | if ( cur == dayView ) | 536 | if ( cur == dayView ) |
534 | viewWeek(); | 537 | viewWeek(); |
535 | else if ( cur == weekView ) | 538 | else if ( cur == weekView ) |
536 | viewMonth(); | 539 | viewMonth(); |
537 | else if ( cur == monthView ) | 540 | else if ( cur == monthView ) |
538 | viewDay(); | 541 | viewDay(); |
539 | needShow = TRUE; | 542 | needShow = TRUE; |
540 | } | 543 | } |
541 | } | 544 | } |
542 | if ( needShow ) { | 545 | if ( needShow ) { |
543 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 546 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
544 | showMaximized(); | 547 | showMaximized(); |
545 | #else | 548 | #else |
546 | show(); | 549 | show(); |
547 | #endif | 550 | #endif |
548 | raise(); | 551 | raise(); |
549 | QPEApplication::setKeepRunning(); | 552 | QPEApplication::setKeepRunning(); |
550 | setActiveWindow(); | 553 | setActiveWindow(); |
551 | } | 554 | } |
552 | } | 555 | } |
553 | 556 | ||
554 | void DateBook::reload() | 557 | void DateBook::reload() |
555 | { | 558 | { |
556 | db->reload(); | 559 | db->reload(); |
557 | if ( dayAction->isOn() ) | 560 | if ( dayAction->isOn() ) |
558 | viewDay(); | 561 | viewDay(); |
559 | else if ( weekAction->isOn() ) | 562 | else if ( weekAction->isOn() ) |
560 | viewWeek(); | 563 | viewWeek(); |
561 | else if ( monthAction->isOn() ) | 564 | else if ( monthAction->isOn() ) |
562 | viewMonth(); | 565 | viewMonth(); |
563 | syncing = FALSE; | 566 | syncing = FALSE; |
564 | } | 567 | } |
565 | 568 | ||
566 | void DateBook::flush() | 569 | void DateBook::flush() |
567 | { | 570 | { |
568 | syncing = TRUE; | 571 | syncing = TRUE; |
569 | db->save(); | 572 | db->save(); |
570 | } | 573 | } |
571 | 574 | ||
572 | void DateBook::timerEvent( QTimerEvent *e ) | 575 | void DateBook::timerEvent( QTimerEvent *e ) |
573 | { | 576 | { |
574 | static int stop = 0; | 577 | static int stop = 0; |
575 | if ( stop < 10 ) { | 578 | if ( stop < 10 ) { |
576 | Sound::soundAlarm(); | 579 | Sound::soundAlarm(); |
577 | stop++; | 580 | stop++; |
578 | } else { | 581 | } else { |
579 | stop = 0; | 582 | stop = 0; |
580 | killTimer( e->timerId() ); | 583 | killTimer( e->timerId() ); |
581 | } | 584 | } |
582 | } | 585 | } |
583 | 586 | ||
584 | void DateBook::changeClock( bool newClock ) | 587 | void DateBook::changeClock( bool newClock ) |
585 | { | 588 | { |
586 | ampm = newClock; | 589 | ampm = newClock; |
587 | // repaint the affected objects... | 590 | // repaint the affected objects... |
588 | if (dayView) dayView->redraw(); | 591 | if (dayView) dayView->redraw(); |
589 | if (weekView) weekView->redraw(); | 592 | if (weekView) weekView->redraw(); |
590 | } | 593 | } |
591 | 594 | ||
592 | void DateBook::changeWeek( bool m ) | 595 | void DateBook::changeWeek( bool m ) |
593 | { | 596 | { |
594 | /* no need to redraw, each widget catches. Do need to | 597 | /* no need to redraw, each widget catches. Do need to |
595 | store though for widgets we haven't made yet */ | 598 | store though for widgets we haven't made yet */ |
596 | onMonday = m; | 599 | onMonday = m; |
597 | } | 600 | } |
598 | 601 | ||
599 | void DateBook::slotToday() | 602 | void DateBook::slotToday() |
600 | { | 603 | { |
601 | // we need to view today | 604 | // we need to view today |
602 | QDate dt = QDate::currentDate(); | 605 | QDate dt = QDate::currentDate(); |
603 | showDay( dt.year(), dt.month(), dt.day() ); | 606 | showDay( dt.year(), dt.month(), dt.day() ); |
604 | } | 607 | } |
605 | 608 | ||
606 | void DateBook::closeEvent( QCloseEvent *e ) | 609 | void DateBook::closeEvent( QCloseEvent *e ) |
607 | { | 610 | { |
608 | if(syncing) { | 611 | if(syncing) { |
609 | /* no need to save, did that at flush */ | 612 | /* no need to save, did that at flush */ |
610 | e->accept(); | 613 | e->accept(); |
611 | return; | 614 | return; |
612 | } | 615 | } |
613 | 616 | ||
614 | // save settings will generate it's own error messages, no | 617 | // save settings will generate it's own error messages, no |
615 | // need to do checking ourselves. | 618 | // need to do checking ourselves. |
616 | saveSettings(); | 619 | saveSettings(); |
617 | if ( db->save() ) | 620 | if ( db->save() ) |
618 | e->accept(); | 621 | e->accept(); |
619 | else { | 622 | else { |
620 | if ( QMessageBox::critical( this, tr( "Out of space" ), | 623 | if ( QMessageBox::critical( this, tr( "Out of space" ), |
621 | tr("Calendar was unable to save\n" | 624 | tr("Calendar was unable to save\n" |
622 | "your changes.\n" | 625 | "your changes.\n" |
623 | "Free up some space and try again.\n" | 626 | "Free up some space and try again.\n" |
624 | "\nQuit anyway?"), | 627 | "\nQuit anyway?"), |
625 | QMessageBox::Yes|QMessageBox::Escape, | 628 | QMessageBox::Yes|QMessageBox::Escape, |
626 | QMessageBox::No|QMessageBox::Default ) | 629 | QMessageBox::No|QMessageBox::Default ) |
627 | != QMessageBox::No ) | 630 | != QMessageBox::No ) |
628 | e->accept(); | 631 | e->accept(); |
629 | else | 632 | else |
630 | e->ignore(); | 633 | e->ignore(); |
631 | } | 634 | } |
632 | } | 635 | } |
633 | 636 | ||
634 | // Entering directly from the "keyboard" | 637 | // Entering directly from the "keyboard" |
635 | void DateBook::slotNewEventFromKey( const QString &str ) | 638 | void DateBook::slotNewEventFromKey( const QString &str ) |
636 | { | 639 | { |
637 | if (syncing) { | 640 | if (syncing) { |
638 | QMessageBox::warning( this, tr("Calendar"), | 641 | QMessageBox::warning( this, tr("Calendar"), |
639 | tr( "Can not edit data, currently syncing") ); | 642 | tr( "Can not edit data, currently syncing") ); |
640 | return; | 643 | return; |
641 | } | 644 | } |
642 | 645 | ||
643 | // We get to here from a key pressed in the Day View | 646 | // We get to here from a key pressed in the Day View |