summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-02-15 20:02:50 (UTC)
committer harlekin <harlekin>2002-02-15 20:02:50 (UTC)
commit50bc570309b0da3ecd4a9d0a0448b58a9a8ed2ab (patch) (unidiff)
treefefefb94f5d4c0eae01ef441900a0c7c9dd3e22b
parent8ccfea56d43fde77717cfd354b62ccb3f67585d1 (diff)
downloadopie-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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp13
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,188 +1,191 @@
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
73DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 75DateBook::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
176void DateBook::receive( const QCString &msg, const QByteArray &data ) 179void 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}
@@ -211,97 +214,97 @@ void DateBook::slotSettings()
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
223void DateBook::fileNew() 226void DateBook::fileNew()
224{ 227{
225 slotNewEventFromKey(""); 228 slotNewEventFromKey("");
226} 229}
227 230
228QString DateBook::checkEvent(const Event &e) 231QString 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
256QDate DateBook::currentDate() 259QDate 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
271void DateBook::viewDay() 274void 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
281void DateBook::viewWeek() 284void 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
291void DateBook::viewMonth() 294void 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
301void DateBook::editEvent( const Event &e ) 304void 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 }