-rw-r--r-- | core/pim/datebook/datebook.cpp | 1258 | ||||
-rw-r--r-- | core/pim/datebook/datebook.h | 87 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 1084 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.h | 60 | ||||
-rw-r--r-- | core/pim/datebook/datebookdayallday.cpp | 47 | ||||
-rw-r--r-- | core/pim/datebook/datebookdayallday.h | 4 | ||||
-rw-r--r-- | core/pim/datebook/holiday/dummy/config.in | 8 | ||||
-rw-r--r-- | core/pim/datebook/holiday/dummy/dummy.pro | 20 | ||||
-rw-r--r-- | core/pim/datebook/holiday/dummy/dummyholiday.cpp | 20 | ||||
-rw-r--r-- | core/pim/datebook/holiday/dummy/dummyholiday.h | 19 |
10 files changed, 1416 insertions, 1191 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index a18a5b4..f6aab0c 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -1,1075 +1,1151 @@ | |||
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 | 23 | #define QTOPIA_INTERNAL_FD |
24 | 24 | ||
25 | #include "datebook.h" | 25 | #include "datebook.h" |
26 | #include "datebookday.h" | 26 | #include "datebookday.h" |
27 | #include "datebooksettings.h" | 27 | #include "datebooksettings.h" |
28 | #include "datebookweek.h" | 28 | #include "datebookweek.h" |
29 | #include "datebookweeklst.h" | 29 | #include "datebookweeklst.h" |
30 | #include "dateentryimpl.h" | 30 | #include "dateentryimpl.h" |
31 | 31 | ||
32 | #include <opie2/odebug.h> | 32 | #include <opie2/odebug.h> |
33 | #include <opie2/oholidaypluginif.h> | ||
34 | #include <opie2/oholidayplugin.h> | ||
33 | 35 | ||
34 | #include <qpe/datebookmonth.h> | 36 | #include <qpe/datebookmonth.h> |
35 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
37 | #include <qpe/finddialog.h> | 39 | #include <qpe/finddialog.h> |
38 | #include <qpe/ir.h> | 40 | #include <qpe/ir.h> |
39 | #include <qpe/qpemessagebox.h> | 41 | #include <qpe/qpemessagebox.h> |
40 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 43 | #include <qpe/sound.h> |
42 | #include <qpe/tzselect.h> | 44 | #include <qpe/tzselect.h> |
43 | 45 | ||
44 | #include <qaction.h> | 46 | #include <qaction.h> |
45 | #include <qcopchannel_qws.h> | 47 | #include <qcopchannel_qws.h> |
46 | #include <qlayout.h> | 48 | #include <qlayout.h> |
47 | #include <qmessagebox.h> | 49 | #include <qmessagebox.h> |
48 | #include <qtimer.h> | 50 | #include <qtimer.h> |
49 | #include <qtl.h> | 51 | #include <qtl.h> |
50 | #include <qtoolbar.h> | 52 | #include <qtoolbar.h> |
51 | #include <qwidgetstack.h> | 53 | #include <qwidgetstack.h> |
54 | #include <qdir.h> | ||
55 | #include <qtopia/qlibrary.h> | ||
52 | 56 | ||
53 | #include <sys/stat.h> | 57 | #include <sys/stat.h> |
54 | #include <sys/types.h> | 58 | #include <sys/types.h> |
55 | #include <fcntl.h> | 59 | #include <fcntl.h> |
56 | #include <unistd.h> | 60 | #include <unistd.h> |
57 | 61 | ||
58 | #include <stdlib.h> | 62 | #include <stdlib.h> |
59 | 63 | ||
60 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | 64 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) |
61 | : QMainWindow( parent, "datebook", f ), | 65 | : QMainWindow( parent, "datebook", f ), |
62 | aPreset( FALSE ), | 66 | aPreset( FALSE ), |
63 | presetTime( -1 ), | 67 | presetTime( -1 ), |
64 | startTime( 8 ), // an acceptable default | 68 | startTime( 8 ), // an acceptable default |
65 | rowStyle( 0 ), | 69 | rowStyle( 0 ), |
66 | bJumpToCurTime(FALSE), | 70 | bJumpToCurTime(FALSE), |
67 | syncing(FALSE), | 71 | syncing(FALSE), |
68 | inSearch(FALSE), | 72 | inSearch(FALSE), |
69 | alarmCounter(0) | 73 | alarmCounter(0) |
70 | { | 74 | { |
71 | bool needEvilHack= false; // if we need an Evil Hack | 75 | bool needEvilHack= false; // if we need an Evil Hack |
72 | QTime t; | 76 | QTime t; |
73 | t.start(); | 77 | t.start(); |
74 | db = new DateBookDBHack; | 78 | db = new DateBookDBHack; |
75 | odebug << "loading db t=" << t.elapsed() << oendl; | 79 | odebug << "loading db t=" << t.elapsed() << oendl; |
76 | loadSettings(); | 80 | db_holiday = new DateBookHoliday(); |
77 | setCaption( tr("Calendar") ); | ||
78 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | ||
79 | 81 | ||
80 | setToolBarsMovable( FALSE ); | 82 | loadSettings(); |
83 | setCaption( tr("Calendar") ); | ||
84 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | ||
81 | 85 | ||
82 | views = new QWidgetStack( this ); | 86 | setToolBarsMovable( FALSE ); |
83 | setCentralWidget( views ); | ||
84 | 87 | ||
85 | dayView = 0; | 88 | views = new QWidgetStack( this ); |
86 | weekView = 0; | 89 | setCentralWidget( views ); |
87 | weekLstView = 0; | 90 | |
88 | monthView = 0; | 91 | dayView = 0; |
92 | weekView = 0; | ||
93 | weekLstView = 0; | ||
94 | monthView = 0; | ||
89 | 95 | ||
90 | // QToolBar *bar = new QToolBar( this ); | 96 | // QToolBar *bar = new QToolBar( this ); |
91 | // bar->setHorizontalStretchable( TRUE ); | 97 | // bar->setHorizontalStretchable( TRUE ); |
92 | 98 | ||
93 | // QMenuBar *mb = new QMenuBar( bar ); | 99 | // QMenuBar *mb = new QMenuBar( bar ); |
94 | // mb->setMargin( 0 ); | 100 | // mb->setMargin( 0 ); |
95 | 101 | ||
96 | // QPopupMenu *view = new QPopupMenu( this ); | 102 | // QPopupMenu *view = new QPopupMenu( this ); |
97 | // mb->insertItem( tr( "View" ), view ); | 103 | // mb->insertItem( tr( "View" ), view ); |
98 | 104 | ||
99 | QToolBar *sub_bar = new QToolBar(this); | 105 | QToolBar *sub_bar = new QToolBar(this); |
100 | sub_bar->setHorizontalStretchable(TRUE); | 106 | sub_bar->setHorizontalStretchable(TRUE); |
101 | 107 | ||
102 | QActionGroup *g = new QActionGroup( this ); | 108 | QActionGroup *g = new QActionGroup( this ); |
103 | g->setExclusive( TRUE ); | 109 | g->setExclusive( TRUE ); |
104 | 110 | ||
105 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 111 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
106 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 112 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
107 | a->addTo( sub_bar ); | 113 | a->addTo( sub_bar ); |
108 | 114 | ||
109 | sub_bar->addSeparator(); | 115 | sub_bar->addSeparator(); |
110 | 116 | ||
111 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); | 117 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); |
112 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | 118 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); |
113 | a->addTo( sub_bar ); | 119 | a->addTo( sub_bar ); |
114 | //a->addTo( view ); | 120 | // a->addTo( view ); |
115 | 121 | ||
116 | sub_bar->addSeparator(); | 122 | sub_bar->addSeparator(); |
117 | 123 | ||
118 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); | 124 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); |
119 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); | 125 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); |
120 | a->addTo( sub_bar ); | 126 | a->addTo( sub_bar ); |
121 | // a->addTo( view ); | 127 | // a->addTo( view ); |
122 | a->setToggleAction( TRUE ); | 128 | a->setToggleAction( TRUE ); |
123 | a->setOn( TRUE ); | 129 | a->setOn( TRUE ); |
124 | dayAction = a; | 130 | dayAction = a; |
125 | 131 | ||
126 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); | 132 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); |
127 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); | 133 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); |
128 | a->addTo( sub_bar ); | 134 | a->addTo( sub_bar ); |
129 | // a->addTo( view ); | 135 | // a->addTo( view ); |
130 | a->setToggleAction( TRUE ); | 136 | a->setToggleAction( TRUE ); |
131 | weekAction = a; | 137 | weekAction = a; |
132 | 138 | ||
133 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); | 139 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); |
134 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); | 140 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); |
135 | a->addTo( sub_bar ); | 141 | a->addTo( sub_bar ); |
136 | // a->addTo( view ); | 142 | // a->addTo( view ); |
137 | a->setToggleAction( TRUE ); | 143 | a->setToggleAction( TRUE ); |
138 | weekLstAction = a; | 144 | weekLstAction = a; |
139 | 145 | ||
140 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); | 146 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); |
141 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); | 147 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); |
142 | a->addTo( sub_bar ); | 148 | a->addTo( sub_bar ); |
143 | // a->addTo( view ); | 149 | // a->addTo( view ); |
144 | a->setToggleAction( TRUE ); | 150 | a->setToggleAction( TRUE ); |
145 | monthAction = a; | 151 | monthAction = a; |
146 | 152 | ||
147 | sub_bar->addSeparator(); | 153 | sub_bar->addSeparator(); |
148 | 154 | ||
149 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | 155 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); |
150 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 156 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
151 | a->addTo( sub_bar ); | 157 | a->addTo( sub_bar ); |
152 | 158 | ||
153 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); | 159 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); |
154 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 160 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
155 | a->addTo( sub_bar ); | 161 | a->addTo( sub_bar ); |
156 | 162 | ||
157 | if(defaultView==DAY) viewDay(); | 163 | if(defaultView==DAY) viewDay(); |
158 | if(defaultView==WEEK) needEvilHack=true;// viewWeek(); | 164 | if(defaultView==WEEK) needEvilHack=true; // viewWeek(); |
159 | if(defaultView==WEEKLST) viewWeekLst(); | 165 | if(defaultView==WEEKLST) viewWeekLst(); |
160 | if(defaultView==MONTH) viewMonth(); | 166 | if(defaultView==MONTH) viewMonth(); |
161 | 167 | ||
162 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); | 168 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); |
163 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); | 169 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); |
164 | 170 | ||
165 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 171 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
166 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); | 172 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); |
167 | #endif | 173 | #endif |
168 | 174 | ||
169 | // listen on QPE/System | 175 | // listen on QPE/System |
170 | #if defined(Q_WS_QWS) | 176 | #if defined(Q_WS_QWS) |
171 | #if !defined(QT_NO_COP) | 177 | #if !defined(QT_NO_COP) |
172 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 178 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
173 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); | 179 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); |
174 | channel = new QCopChannel( "QPE/Datebook", this ); | 180 | channel = new QCopChannel( "QPE/Datebook", this ); |
175 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); | 181 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); |
176 | #endif | 182 | #endif |
177 | #endif | 183 | #endif |
178 | 184 | ||
179 | odebug << "done t=" << t.elapsed() << oendl; | 185 | odebug << "done t=" << t.elapsed() << oendl; |
180 | 186 | ||
181 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); | 187 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); |
182 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); | 188 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); |
183 | /* | 189 | /* |
184 | * Here is a problem description: | 190 | * Here is a problem description: |
185 | * When Weekview is the default view | 191 | * When Weekview is the default view |
186 | * a DateBookWeekView get's created | 192 | * a DateBookWeekView get's created |
187 | * redraw() get's called. So what? | 193 | * redraw() get's called. So what? |
188 | * Remember that we're still in the c'tor | 194 | * Remember that we're still in the c'tor |
189 | * and no final layout has happened? Ok | 195 | * and no final layout has happened? Ok |
190 | * now all Events get arranged. Their x | 196 | * now all Events get arranged. Their x |
191 | * position get's determined by a QHeader | 197 | * position get's determined by a QHeader |
192 | * position. But the QHeader isn't layouted or | 198 | * position. But the QHeader isn't layouted or |
193 | * at the right position. redraw() is a slot | 199 | * at the right position. redraw() is a slot |
194 | * so we'll call it then via a singleShot | 200 | * so we'll call it then via a singleShot |
195 | * from view() | 201 | * from view() |
196 | */ | 202 | */ |
197 | if( needEvilHack ){ | 203 | if( needEvilHack ){ |
198 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); | 204 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); |
199 | } | 205 | } |
200 | } | 206 | } |
201 | 207 | ||
202 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 208 | void DateBook::receive( const QCString &msg, const QByteArray &data ) |
203 | { | 209 | { |
204 | QDataStream stream( data, IO_ReadOnly ); | 210 | QDataStream stream( data, IO_ReadOnly ); |
205 | if ( msg == "timeChange(QString)" ) { | 211 | if ( msg == "timeChange(QString)" ) { |
206 | // update active view! | 212 | // update active view! |
207 | if ( dayAction->isOn() ) | 213 | if ( dayAction->isOn() ) |
208 | viewDay(); | 214 | viewDay(); |
209 | else if ( weekAction->isOn() ) | 215 | else if ( weekAction->isOn() ) |
210 | viewWeek(); | 216 | viewWeek(); |
211 | else if ( monthAction->isOn() ) | 217 | else if ( monthAction->isOn() ) |
212 | viewMonth(); | 218 | viewMonth(); |
213 | } | 219 | } |
214 | else if (msg == "editEvent(int)") { | 220 | else if (msg == "editEvent(int)") { |
215 | int uid; | 221 | int uid; |
216 | stream >> uid; | 222 | stream >> uid; |
217 | Event e=db->eventByUID(uid); | 223 | Event e=db->eventByUID(uid); |
218 | editEvent(e); | 224 | editEvent(e); |
219 | }else if (msg == "viewDefault(QDate)"){ | 225 | }else if (msg == "viewDefault(QDate)"){ |
220 | QDate day; | 226 | QDate day; |
221 | stream >> day; | 227 | stream >> day; |
222 | viewDefault(day); | 228 | viewDefault(day); |
223 | } | 229 | } |
224 | } | 230 | } |
225 | 231 | ||
226 | DateBook::~DateBook() | 232 | DateBook::~DateBook() |
227 | { | 233 | { |
234 | delete db_holiday; | ||
228 | } | 235 | } |
229 | 236 | ||
230 | void DateBook::slotSettings() | 237 | void DateBook::slotSettings() |
231 | { | 238 | { |
232 | DateBookSettings frmSettings( ampm, this ); | 239 | DateBookSettings frmSettings( ampm, this ); |
233 | frmSettings.setStartTime( startTime ); | 240 | frmSettings.setStartTime( startTime ); |
234 | frmSettings.setAlarmPreset( aPreset, presetTime ); | 241 | frmSettings.setAlarmPreset( aPreset, presetTime ); |
235 | frmSettings.setJumpToCurTime( bJumpToCurTime ); | 242 | frmSettings.setJumpToCurTime( bJumpToCurTime ); |
236 | frmSettings.setRowStyle( rowStyle ); | 243 | frmSettings.setRowStyle( rowStyle ); |
237 | frmSettings.comboDefaultView->setCurrentItem(defaultView-1); | 244 | frmSettings.comboDefaultView->setCurrentItem(defaultView-1); |
238 | frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); | 245 | frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); |
239 | 246 | ||
240 | bool found=false; | 247 | bool found=false; |
241 | for (int i=0; i<(frmSettings.comboLocation->count()); i++) { | 248 | for (int i=0; i<(frmSettings.comboLocation->count()); i++) { |
242 | if ( frmSettings.comboLocation->text(i) == defaultLocation ) { | 249 | if ( frmSettings.comboLocation->text(i) == defaultLocation ) { |
243 | frmSettings.comboLocation->setCurrentItem(i); | 250 | frmSettings.comboLocation->setCurrentItem(i); |
244 | found=true; | 251 | found=true; |
245 | break; | 252 | break; |
246 | } | 253 | } |
247 | } | 254 | } |
248 | if(!found) { | 255 | if(!found) { |
249 | frmSettings.comboLocation->insertItem(defaultLocation); | 256 | frmSettings.comboLocation->insertItem(defaultLocation); |
250 | frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); | 257 | frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); |
251 | } | 258 | } |
252 | frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); | 259 | frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); |
253 | 260 | ||
254 | if ( QPEApplication::execDialog( &frmSettings ) ) { | 261 | if ( QPEApplication::execDialog( &frmSettings ) ) { |
255 | aPreset = frmSettings.alarmPreset(); | 262 | aPreset = frmSettings.alarmPreset(); |
256 | presetTime = frmSettings.presetTime(); | 263 | presetTime = frmSettings.presetTime(); |
257 | startTime = frmSettings.startTime(); | 264 | startTime = frmSettings.startTime(); |
258 | bJumpToCurTime = frmSettings.jumpToCurTime(); | 265 | bJumpToCurTime = frmSettings.jumpToCurTime(); |
259 | rowStyle = frmSettings.rowStyle(); | 266 | rowStyle = frmSettings.rowStyle(); |
260 | defaultView=frmSettings.comboDefaultView->currentItem()+1; | 267 | defaultView=frmSettings.comboDefaultView->currentItem()+1; |
261 | weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); | 268 | weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); |
262 | defaultLocation=frmSettings.comboLocation->currentText(); | 269 | defaultLocation=frmSettings.comboLocation->currentText(); |
263 | defaultCategories=frmSettings.comboCategory->currentCategories(); | 270 | defaultCategories=frmSettings.comboCategory->currentCategories(); |
264 | 271 | ||
265 | if ( dayView ) { | 272 | if ( dayView ) { |
266 | dayView->setStartViewTime( startTime ); | 273 | dayView->setStartViewTime( startTime ); |
267 | dayView->setJumpToCurTime( bJumpToCurTime ); | 274 | dayView->setJumpToCurTime( bJumpToCurTime ); |
268 | dayView->setRowStyle( rowStyle ); | 275 | dayView->setRowStyle( rowStyle ); |
269 | } | 276 | } |
270 | if ( weekView ) { | 277 | if ( weekView ) { |
271 | weekView->setStartViewTime( startTime ); | 278 | weekView->setStartViewTime( startTime ); |
272 | } | 279 | } |
273 | saveSettings(); | 280 | saveSettings(); |
274 | 281 | ||
275 | // make the change obvious | 282 | // make the change obvious |
276 | if ( views->visibleWidget() ) { | 283 | if ( views->visibleWidget() ) { |
277 | if ( views->visibleWidget() == dayView ) | 284 | if ( views->visibleWidget() == dayView ) |
278 | dayView->redraw(); | 285 | dayView->redraw(); |
279 | else if ( views->visibleWidget() == weekView ) | 286 | else if ( views->visibleWidget() == weekView ) |
280 | weekView->redraw(); | 287 | weekView->redraw(); |
281 | else if ( views->visibleWidget() == weekLstView ) | 288 | else if ( views->visibleWidget() == weekLstView ) |
282 | weekLstView->redraw(); | 289 | weekLstView->redraw(); |
283 | } | 290 | } |
284 | } | 291 | } |
285 | } | 292 | } |
286 | 293 | ||
287 | void DateBook::fileNew() | 294 | void DateBook::fileNew() |
288 | { | 295 | { |
289 | slotNewEventFromKey(""); | 296 | slotNewEventFromKey(""); |
290 | } | 297 | } |
291 | 298 | ||
292 | QString DateBook::checkEvent(const Event &e) | 299 | QString DateBook::checkEvent(const Event &e) |
293 | { | 300 | { |
294 | /* check if overlaps with itself */ | 301 | /* check if overlaps with itself */ |
295 | bool checkFailed = FALSE; | 302 | bool checkFailed = FALSE; |
296 | 303 | ||
297 | /* check the next 12 repeats. should catch most problems */ | 304 | /* check the next 12 repeats. should catch most problems */ |
298 | QDate current_date = e.start().date(); | 305 | QDate current_date = e.start().date(); |
299 | Event previous = e; | 306 | Event previous = e; |
300 | for(int i = 0; i < 12; i++) | 307 | for(int i = 0; i < 12; i++) |
301 | { | 308 | { |
302 | QDateTime next; | 309 | QDateTime next; |
303 | if (!nextOccurance(previous, current_date.addDays(1), next)) { | 310 | if (!nextOccurance(previous, current_date.addDays(1), next)) { |
304 | break; // no more repeats | 311 | break; // no more repeats |
305 | } | 312 | } |
306 | if(next < previous.end()) { | 313 | if(next < previous.end()) { |
307 | checkFailed = TRUE; | 314 | checkFailed = TRUE; |
308 | break; | 315 | break; |
309 | } | 316 | } |
310 | current_date = next.date(); | 317 | current_date = next.date(); |
311 | } | 318 | } |
312 | 319 | ||
313 | if(checkFailed) | 320 | if(checkFailed) |
314 | return tr("Event duration is potentially longer\n" | 321 | return tr("Event duration is potentially longer\n" |
315 | "than interval between repeats."); | 322 | "than interval between repeats."); |
316 | 323 | ||
317 | return QString::null; | 324 | return QString::null; |
318 | } | 325 | } |
319 | 326 | ||
320 | QDate DateBook::currentDate() | 327 | QDate DateBook::currentDate() |
321 | { | 328 | { |
322 | QDate d = QDate::currentDate(); | 329 | QDate d = QDate::currentDate(); |
323 | 330 | ||
324 | if ( dayView && views->visibleWidget() == dayView ) { | 331 | if ( dayView && views->visibleWidget() == dayView ) { |
325 | d = dayView->date(); | 332 | d = dayView->date(); |
326 | } else if ( weekView && views->visibleWidget() == weekView ) { | 333 | } else if ( weekView && views->visibleWidget() == weekView ) { |
327 | d = weekView->date(); | 334 | d = weekView->date(); |
328 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { | 335 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { |
329 | d = weekLstView->date(); | 336 | d = weekLstView->date(); |
330 | } else if ( monthView && views->visibleWidget() == monthView ) { | 337 | } else if ( monthView && views->visibleWidget() == monthView ) { |
331 | d = monthView->selectedDate(); | 338 | d = monthView->selectedDate(); |
332 | } | 339 | } |
333 | 340 | ||
334 | return d; | 341 | return d; |
335 | } | 342 | } |
336 | 343 | ||
337 | void DateBook::view(int v, const QDate &d) { | 344 | void DateBook::view(int v, const QDate &d) { |
338 | if (v==DAY) { | 345 | if (v==DAY) { |
339 | initDay(); | 346 | initDay(); |
340 | dayAction->setOn( TRUE ); | 347 | dayAction->setOn( TRUE ); |
341 | dayView->setDate( d ); | 348 | dayView->setDate( d ); |
342 | views->raiseWidget( dayView ); | 349 | views->raiseWidget( dayView ); |
343 | dayView->redraw(); | 350 | dayView->redraw(); |
344 | } else if (v==WEEK) { | 351 | } else if (v==WEEK) { |
345 | initWeek(); | 352 | initWeek(); |
346 | weekAction->setOn( TRUE ); | 353 | weekAction->setOn( TRUE ); |
347 | weekView->setDate( d ); | 354 | weekView->setDate( d ); |
348 | views->raiseWidget( weekView ); | 355 | views->raiseWidget( weekView ); |
349 | weekView->redraw(); | 356 | weekView->redraw(); |
350 | } else if (v==WEEKLST) { | 357 | } else if (v==WEEKLST) { |
351 | initWeekLst(); | 358 | initWeekLst(); |
352 | weekLstAction->setOn( TRUE ); | 359 | weekLstAction->setOn( TRUE ); |
353 | weekLstView->setDate(d); | 360 | weekLstView->setDate(d); |
354 | views->raiseWidget( weekLstView ); | 361 | views->raiseWidget( weekLstView ); |
355 | weekLstView->redraw(); | 362 | weekLstView->redraw(); |
356 | } else if (v==MONTH) { | 363 | } else if (v==MONTH) { |
357 | initMonth(); | 364 | initMonth(); |
358 | monthAction->setOn( TRUE ); | 365 | monthAction->setOn( TRUE ); |
359 | monthView->setDate( d.year(), d.month(), d.day() ); | 366 | monthView->setDate( d.year(), d.month(), d.day() ); |
360 | views->raiseWidget( monthView ); | 367 | views->raiseWidget( monthView ); |
361 | monthView->redraw(); | 368 | monthView->redraw(); |
362 | } | 369 | } |
363 | } | 370 | } |
364 | 371 | ||
365 | void DateBook::viewDefault(const QDate &d) { | 372 | void DateBook::viewDefault(const QDate &d) { |
366 | view(defaultView,d); | 373 | view(defaultView,d); |
367 | } | 374 | } |
368 | 375 | ||
369 | void DateBook::viewDay() { | 376 | void DateBook::viewDay() { |
370 | view(DAY,currentDate()); | 377 | view(DAY,currentDate()); |
371 | } | 378 | } |
372 | 379 | ||
373 | void DateBook::viewWeek() { | 380 | void DateBook::viewWeek() { |
374 | view(WEEK,currentDate()); | 381 | view(WEEK,currentDate()); |
375 | } | 382 | } |
376 | 383 | ||
377 | void DateBook::viewWeekLst() { | 384 | void DateBook::viewWeekLst() { |
378 | view(WEEKLST,currentDate()); | 385 | view(WEEKLST,currentDate()); |
379 | } | 386 | } |
380 | 387 | ||
381 | void DateBook::viewMonth() { | 388 | void DateBook::viewMonth() { |
382 | view(MONTH,currentDate()); | 389 | view(MONTH,currentDate()); |
383 | } | 390 | } |
384 | 391 | ||
385 | void DateBook::insertEvent( const Event &e ) | 392 | void DateBook::insertEvent( const Event &e ) |
386 | { | 393 | { |
387 | Event dupEvent=e; | 394 | Event dupEvent=e; |
388 | if(!dupEvent.isValidUid() ) // tkcRom seems to be different | 395 | if(!dupEvent.isValidUid() ) // tkcRom seems to be different |
389 | dupEvent.assignUid(); | 396 | dupEvent.assignUid(); |
390 | dupEvent.setLocation(defaultLocation); | 397 | dupEvent.setLocation(defaultLocation); |
391 | dupEvent.setCategories(defaultCategories); | 398 | dupEvent.setCategories(defaultCategories); |
392 | db->addEvent(dupEvent); | 399 | db->addEvent(dupEvent); |
393 | emit newEvent(); | 400 | emit newEvent(); |
394 | } | 401 | } |
395 | 402 | ||
396 | void DateBook::duplicateEvent( const Event &e ) | 403 | void DateBook::duplicateEvent( const Event &e ) |
397 | { | 404 | { |
398 | // Alot of code duplication, as this is almost like editEvent(); | 405 | // Alot of code duplication, as this is almost like editEvent(); |
399 | if (syncing) { | 406 | if (syncing) { |
400 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 407 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
401 | return; | 408 | return; |
402 | } | 409 | } |
403 | 410 | ||
404 | Event dupevent(e);// Make a duplicate. | 411 | Event dupevent(e); // Make a duplicate. |
405 | 412 | ||
406 | // workaround added for text input. | 413 | // workaround added for text input. |
407 | QDialog editDlg( this, 0, TRUE ); | 414 | QDialog editDlg( this, 0, TRUE ); |
408 | DateEntry *entry; | 415 | DateEntry *entry; |
409 | editDlg.setCaption( tr("Duplicate Event") ); | 416 | editDlg.setCaption( tr("Duplicate Event") ); |
410 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 417 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
411 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 418 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
412 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 419 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
413 | // KLUDGE!!! | 420 | // KLUDGE!!! |
414 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 421 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
415 | vb->addWidget( sv ); | 422 | vb->addWidget( sv ); |
416 | entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); | 423 | entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); |
417 | entry->timezone->setEnabled( FALSE ); | 424 | entry->timezone->setEnabled( FALSE ); |
418 | sv->addChild( entry ); | 425 | sv->addChild( entry ); |
419 | 426 | ||
420 | while ( QPEApplication::execDialog( &editDlg ) ) { | 427 | while ( QPEApplication::execDialog( &editDlg ) ) { |
421 | Event newEv = entry->event(); | 428 | Event newEv = entry->event(); |
422 | QString error = checkEvent(newEv); | 429 | QString error = checkEvent(newEv); |
423 | if (!error.isNull()) { | 430 | if (!error.isNull()) { |
424 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) | 431 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) |
425 | continue; | 432 | continue; |
426 | } | 433 | } |
427 | /* | 434 | /* |
428 | * The problem: | 435 | * The problem: |
429 | * DateBookDB does remove repeating events not by uid but by the time | 436 | * DateBookDB does remove repeating events not by uid but by the time |
430 | * the recurrence was created | 437 | * the recurrence was created |
431 | * so we need to update that time as well | 438 | * so we need to update that time as well |
432 | */ | 439 | */ |
433 | Event::RepeatPattern rp = newEv.repeatPattern(); | 440 | Event::RepeatPattern rp = newEv.repeatPattern(); |
434 | rp.createTime = ::time( NULL ); | 441 | rp.createTime = ::time( NULL ); |
435 | newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... | 442 | newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... |
436 | if( newEv.uid() == e.uid() || !newEv.isValidUid() ) | 443 | if( newEv.uid() == e.uid() || !newEv.isValidUid() ) |
437 | newEv.assignUid(); | 444 | newEv.assignUid(); |
438 | 445 | ||
439 | db->addEvent(newEv); | 446 | db->addEvent(newEv); |
440 | emit newEvent(); | 447 | emit newEvent(); |
441 | break; | 448 | break; |
442 | } | 449 | } |
443 | } | 450 | } |
444 | 451 | ||
445 | void DateBook::editEvent( const Event &e ) | 452 | void DateBook::editEvent( const Event &e ) |
446 | { | 453 | { |
447 | if (syncing) { | 454 | if (syncing) { |
448 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 455 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
449 | return; | 456 | return; |
450 | } | 457 | } |
451 | 458 | ||
452 | // workaround added for text input. | 459 | // workaround added for text input. |
453 | QDialog editDlg( this, 0, TRUE ); | 460 | QDialog editDlg( this, 0, TRUE ); |
454 | DateEntry *entry; | 461 | DateEntry *entry; |
455 | editDlg.setCaption( tr("Edit Event") ); | 462 | editDlg.setCaption( tr("Edit Event") ); |
456 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 463 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
457 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 464 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
458 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 465 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
459 | // KLUDGE!!! | 466 | // KLUDGE!!! |
460 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 467 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
461 | vb->addWidget( sv ); | 468 | vb->addWidget( sv ); |
462 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); | 469 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); |
463 | entry->timezone->setEnabled( FALSE ); | 470 | entry->timezone->setEnabled( FALSE ); |
464 | sv->addChild( entry ); | 471 | sv->addChild( entry ); |
465 | 472 | ||
466 | while ( QPEApplication::execDialog( &editDlg ) ) { | 473 | while ( QPEApplication::execDialog( &editDlg ) ) { |
467 | Event newEv = entry->event(); | 474 | Event newEv = entry->event(); |
468 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) | 475 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) |
469 | break; | 476 | break; |
470 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid | 477 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid |
471 | QString error = checkEvent(newEv); | 478 | QString error = checkEvent(newEv); |
472 | if (!error.isNull()) { | 479 | if (!error.isNull()) { |
473 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; | 480 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; |
474 | } | 481 | } |
475 | db->editEvent(e, newEv); | 482 | db->editEvent(e, newEv); |
476 | emit newEvent(); | 483 | emit newEvent(); |
477 | break; | 484 | break; |
478 | } | 485 | } |
479 | } | 486 | } |
480 | 487 | ||
481 | void DateBook::removeEvent( const Event &e ) | 488 | void DateBook::removeEvent( const Event &e ) |
482 | { | 489 | { |
483 | if (syncing) { | 490 | if (syncing) { |
484 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 491 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
485 | return; | 492 | return; |
486 | } | 493 | } |
487 | 494 | ||
488 | QString strName = e.description(); | 495 | QString strName = e.description(); |
489 | 496 | ||
490 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) | 497 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) |
491 | return; | 498 | return; |
492 | 499 | ||
493 | db->removeEvent( e ); | 500 | db->removeEvent( e ); |
494 | if ( views->visibleWidget() == dayView && dayView ) | 501 | if ( views->visibleWidget() == dayView && dayView ) |
495 | dayView->redraw(); | 502 | dayView->redraw(); |
496 | 503 | ||
497 | } | 504 | } |
498 | 505 | ||
499 | void DateBook::addEvent( const Event &e ) | 506 | void DateBook::addEvent( const Event &e ) |
500 | { | 507 | { |
501 | QDate d = e.start().date(); | 508 | QDate d = e.start().date(); |
502 | initDay(); | 509 | initDay(); |
503 | dayView->setDate( d ); | 510 | dayView->setDate( d ); |
504 | } | 511 | } |
505 | 512 | ||
506 | void DateBook::showDay( int year, int month, int day ) | 513 | void DateBook::showDay( int year, int month, int day ) |
507 | { | 514 | { |
508 | QDate d(year, month, day); | 515 | QDate d(year, month, day); |
509 | view(DAY,d); | 516 | view(DAY,d); |
510 | } | 517 | } |
511 | 518 | ||
512 | void DateBook::initDay() | 519 | void DateBook::initDay() |
513 | { | 520 | { |
514 | if ( !dayView ) { | 521 | if ( !dayView ) { |
515 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); | 522 | dayView = new DateBookDay( ampm, onMonday, db, db_holiday, views, "day view" ); |
516 | views->addWidget( dayView, DAY ); | 523 | views->addWidget( dayView, DAY ); |
517 | dayView->setJumpToCurTime( bJumpToCurTime ); | 524 | dayView->setJumpToCurTime( bJumpToCurTime ); |
518 | dayView->setStartViewTime( startTime ); | 525 | dayView->setStartViewTime( startTime ); |
519 | dayView->setRowStyle( rowStyle ); | 526 | dayView->setRowStyle( rowStyle ); |
520 | connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); | 527 | connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); |
521 | connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); | 528 | connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); |
522 | connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) ); | 529 | connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) ); |
523 | connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); | 530 | connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); |
524 | connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) ); | 531 | connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) ); |
525 | connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); | 532 | connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); |
526 | connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) ); | 533 | connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) ); |
527 | } | 534 | } |
528 | } | 535 | } |
529 | 536 | ||
530 | void DateBook::initWeek() | 537 | void DateBook::initWeek() |
531 | { | 538 | { |
532 | if ( !weekView ) { | 539 | if ( !weekView ) { |
533 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); | 540 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); |
534 | weekView->setStartViewTime( startTime ); | 541 | weekView->setStartViewTime( startTime ); |
535 | views->addWidget( weekView, WEEK ); | 542 | views->addWidget( weekView, WEEK ); |
536 | connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); | 543 | connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); |
537 | connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); | 544 | connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); |
538 | } | 545 | } |
539 | 546 | ||
540 | //But also get it right: the year that we display can be different | 547 | //But also get it right: the year that we display can be different |
541 | //from the year of the current date. So, first find the year | 548 | //from the year of the current date. So, first find the year |
542 | //number of the current week. | 549 | //number of the current week. |
543 | int yearNumber, totWeeks; | 550 | int yearNumber, totWeeks; |
544 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); | 551 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); |
545 | 552 | ||
546 | QDate d = QDate( yearNumber, 12, 31 ); | 553 | QDate d = QDate( yearNumber, 12, 31 ); |
547 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 554 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
548 | 555 | ||
549 | while ( totWeeks == 1 ) { | 556 | while ( totWeeks == 1 ) { |
550 | d = d.addDays( -1 ); | 557 | d = d.addDays( -1 ); |
551 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 558 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
552 | } | 559 | } |
553 | } | 560 | } |
554 | 561 | ||
555 | void DateBook::initWeekLst() { | 562 | void DateBook::initWeekLst() { |
556 | if ( !weekLstView ) { | 563 | if ( !weekLstView ) { |
557 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); | 564 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); |
558 | views->addWidget( weekLstView, WEEKLST ); | 565 | views->addWidget( weekLstView, WEEKLST ); |
559 | 566 | ||
560 | //weekLstView->setStartViewTime( startTime ); | 567 | //weekLstView->setStartViewTime( startTime ); |
561 | connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); | 568 | connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); |
562 | connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), | 569 | connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), |
563 | this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); | 570 | this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); |
564 | connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); | 571 | connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); |
565 | connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); | 572 | connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); |
566 | connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); | 573 | connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); |
567 | connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); | 574 | connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); |
568 | connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); | 575 | connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); |
569 | } | 576 | } |
570 | } | 577 | } |
571 | 578 | ||
572 | 579 | ||
573 | void DateBook::initMonth() | 580 | void DateBook::initMonth() |
574 | { | 581 | { |
575 | if ( !monthView ) { | 582 | if ( !monthView ) { |
576 | monthView = new DateBookMonth( views, "month view", FALSE, db ); | 583 | monthView = new DateBookMonth( views, "month view", FALSE, db ); |
577 | views->addWidget( monthView, MONTH ); | 584 | views->addWidget( monthView, MONTH ); |
578 | connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); | 585 | connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); |
579 | connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); | 586 | connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); |
580 | qApp->processEvents(); | 587 | qApp->processEvents(); |
581 | } | 588 | } |
582 | } | 589 | } |
583 | 590 | ||
584 | void DateBook::loadSettings() | 591 | void DateBook::loadSettings() |
585 | { | 592 | { |
586 | Config qpeconfig( "qpe" ); | 593 | Config qpeconfig( "qpe" ); |
587 | qpeconfig.setGroup("Time"); | 594 | qpeconfig.setGroup("Time"); |
588 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); | 595 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); |
589 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); | 596 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); |
590 | 597 | ||
591 | Config config("DateBook"); | 598 | Config config("DateBook"); |
592 | config.setGroup("Main"); | 599 | config.setGroup("Main"); |
593 | startTime = config.readNumEntry("startviewtime", 8); | 600 | startTime = config.readNumEntry("startviewtime", 8); |
594 | aPreset = config.readBoolEntry("alarmpreset"); | 601 | aPreset = config.readBoolEntry("alarmpreset"); |
595 | presetTime = config.readNumEntry("presettime"); | 602 | presetTime = config.readNumEntry("presettime"); |
596 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); | 603 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); |
597 | rowStyle = config.readNumEntry("rowstyle"); | 604 | rowStyle = config.readNumEntry("rowstyle"); |
598 | defaultView = config.readNumEntry("defaultview",DAY); | 605 | defaultView = config.readNumEntry("defaultview",DAY); |
599 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); | 606 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); |
600 | 607 | ||
601 | defaultLocation=config.readEntry("defaultLocation"); | 608 | defaultLocation=config.readEntry("defaultLocation"); |
602 | QString tmpString=config.readEntry("defaultCategories"); | 609 | QString tmpString=config.readEntry("defaultCategories"); |
603 | QStringList tmpStringList=QStringList::split(",",tmpString); | 610 | QStringList tmpStringList=QStringList::split(",",tmpString); |
604 | defaultCategories.truncate(0); | 611 | defaultCategories.truncate(0); |
605 | 612 | ||
606 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { | 613 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { |
607 | defaultCategories.resize(defaultCategories.count()+1); | 614 | defaultCategories.resize(defaultCategories.count()+1); |
608 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); | 615 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); |
609 | } | 616 | } |
610 | } | 617 | } |
611 | 618 | ||
612 | void DateBook::saveSettings() | 619 | void DateBook::saveSettings() |
613 | { | 620 | { |
614 | Config config( "qpe" ); | 621 | Config config( "qpe" ); |
615 | Config configDB( "DateBook" ); | 622 | Config configDB( "DateBook" ); |
616 | configDB.setGroup( "Main" ); | 623 | configDB.setGroup( "Main" ); |
617 | configDB.writeEntry("startviewtime",startTime); | 624 | configDB.writeEntry("startviewtime",startTime); |
618 | configDB.writeEntry("alarmpreset",aPreset); | 625 | configDB.writeEntry("alarmpreset",aPreset); |
619 | configDB.writeEntry("presettime",presetTime); | 626 | configDB.writeEntry("presettime",presetTime); |
620 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); | 627 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); |
621 | configDB.writeEntry("rowstyle", rowStyle); | 628 | configDB.writeEntry("rowstyle", rowStyle); |
622 | configDB.writeEntry("defaultview",defaultView); | 629 | configDB.writeEntry("defaultview",defaultView); |
623 | configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); | 630 | configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); |
624 | 631 | ||
625 | configDB.writeEntry("defaultLocation",defaultLocation); | 632 | configDB.writeEntry("defaultLocation",defaultLocation); |
626 | QStringList tmpStringList; | 633 | QStringList tmpStringList; |
627 | for( uint i=0; i<defaultCategories.count(); i++) { | 634 | for( uint i=0; i<defaultCategories.count(); i++) { |
628 | tmpStringList << QString::number(defaultCategories[i]); | 635 | tmpStringList << QString::number(defaultCategories[i]); |
629 | } | 636 | } |
630 | configDB.writeEntry("defaultCategories",tmpStringList.join(",")); | 637 | configDB.writeEntry("defaultCategories",tmpStringList.join(",")); |
631 | } | 638 | } |
632 | 639 | ||
633 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) | 640 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) |
634 | { | 641 | { |
635 | bool needShow = FALSE; | 642 | bool needShow = FALSE; |
636 | if ( msg == "alarm(QDateTime,int)" ) { | 643 | if ( msg == "alarm(QDateTime,int)" ) { |
637 | QDataStream ds(data,IO_ReadOnly); | 644 | QDataStream ds(data,IO_ReadOnly); |
638 | QDateTime when; int warn; | 645 | QDateTime when; int warn; |
639 | ds >> when >> warn; | 646 | ds >> when >> warn; |
640 | 647 | ||
641 | // check to make it's okay to continue, | 648 | // check to make it's okay to continue, |
642 | // this is the case that the time was set ahead, and | 649 | // this is the case that the time was set ahead, and |
643 | // we are forced given a stale alarm... | 650 | // we are forced given a stale alarm... |
644 | QDateTime current = QDateTime::currentDateTime(); | 651 | QDateTime current = QDateTime::currentDateTime(); |
645 | if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) | 652 | if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) |
646 | return; | 653 | return; |
647 | 654 | ||
648 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); | 655 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); |
649 | if ( list.count() > 0 ) { | 656 | if ( list.count() > 0 ) { |
650 | QString msg; | 657 | QString msg; |
651 | bool bSound = FALSE; | 658 | bool bSound = FALSE; |
652 | int stopTimer = 0; | 659 | int stopTimer = 0; |
653 | bool found = FALSE; | 660 | bool found = FALSE; |
654 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { | 661 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { |
655 | if ( (*it).event().hasAlarm() ) { | 662 | if ( (*it).event().hasAlarm() ) { |
656 | found = TRUE; | 663 | found = TRUE; |
657 | msg += "<CENTER><B>" + (*it).description() + "</B>" | 664 | msg += "<CENTER><B>" + (*it).description() + "</B>" |
658 | + "<BR>" + (*it).location() + "<BR>" | 665 | + "<BR>" + (*it).location() + "<BR>" |
659 | + TimeString::dateString((*it).event().start(),ampm) | 666 | + TimeString::dateString((*it).event().start(),ampm) |
660 | + (warn | 667 | + (warn |
661 | ? tr(" (in " + QString::number(warn) | 668 | ? tr(" (in " + QString::number(warn) |
662 | + tr(" minutes)")) | 669 | + tr(" minutes)")) |
663 | : QString("")) | 670 | : QString("")) |
664 | + "<BR>" | 671 | + "<BR>" |
665 | + (*it).notes() + "</CENTER>"; | 672 | + (*it).notes() + "</CENTER>"; |
666 | if ( (*it).event().alarmSound() != Event::Silent ) { | 673 | if ( (*it).event().alarmSound() != Event::Silent ) { |
667 | bSound = TRUE; | 674 | bSound = TRUE; |
668 | } | 675 | } |
669 | } | 676 | } |
670 | } | 677 | } |
671 | if ( found ) { | 678 | if ( found ) { |
672 | if ( bSound ) { | 679 | if ( bSound ) { |
673 | Sound::soundAlarm(); | 680 | Sound::soundAlarm(); |
674 | alarmCounter = 0; | 681 | alarmCounter = 0; |
675 | stopTimer = startTimer( 5000 ); | 682 | stopTimer = startTimer( 5000 ); |
676 | } | 683 | } |
677 | QDialog dlg( this, 0, TRUE ); | 684 | QDialog dlg( this, 0, TRUE ); |
678 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); | 685 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); |
679 | QScrollView *view = new QScrollView( &dlg, "scrollView"); | 686 | QScrollView *view = new QScrollView( &dlg, "scrollView"); |
680 | view->setResizePolicy( QScrollView::AutoOneFit ); | 687 | view->setResizePolicy( QScrollView::AutoOneFit ); |
681 | vb->addWidget( view ); | 688 | vb->addWidget( view ); |
682 | QLabel *lblMsg = new QLabel( msg, &dlg ); | 689 | QLabel *lblMsg = new QLabel( msg, &dlg ); |
683 | view->addChild( lblMsg ); | 690 | view->addChild( lblMsg ); |
684 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); | 691 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); |
685 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); | 692 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); |
686 | vb->addWidget( cmdOk ); | 693 | vb->addWidget( cmdOk ); |
687 | 694 | ||
688 | needShow = QPEApplication::execDialog( &dlg ); | 695 | needShow = QPEApplication::execDialog( &dlg ); |
689 | 696 | ||
690 | if ( bSound ) | 697 | if ( bSound ) |
691 | killTimer( stopTimer ); | 698 | killTimer( stopTimer ); |
692 | } | 699 | } |
693 | } | 700 | } |
694 | } else if ( msg == "nextView()" ) { | 701 | } else if ( msg == "nextView()" ) { |
695 | needShow = true; | 702 | needShow = true; |
696 | if ( !qApp-> activeWindow ( )) { | 703 | if ( !qApp-> activeWindow ( )) { |
697 | needShow = TRUE; | 704 | needShow = TRUE; |
698 | } else { | 705 | } else { |
699 | QWidget* cur = views->visibleWidget(); | 706 | QWidget* cur = views->visibleWidget(); |
700 | if ( cur ) { | 707 | if ( cur ) { |
701 | if ( cur == dayView ) | 708 | if ( cur == dayView ) |
702 | viewWeek(); | 709 | viewWeek(); |
703 | else if ( cur == weekView ) | 710 | else if ( cur == weekView ) |
704 | viewWeekLst(); | 711 | viewWeekLst(); |
705 | else if ( cur == weekLstView ) | 712 | else if ( cur == weekLstView ) |
706 | viewMonth(); | 713 | viewMonth(); |
707 | else if ( cur == monthView ) | 714 | else if ( cur == monthView ) |
708 | viewDay(); | 715 | viewDay(); |
709 | needShow = TRUE; | 716 | needShow = TRUE; |
710 | } | 717 | } |
711 | } | 718 | } |
712 | } else if (msg == "editEvent(int)") { | 719 | } else if (msg == "editEvent(int)") { |
713 | /* simple copy from receive */ | 720 | /* simple copy from receive */ |
714 | QDataStream stream(data,IO_ReadOnly); | 721 | QDataStream stream(data,IO_ReadOnly); |
715 | int uid; | 722 | int uid; |
716 | stream >> uid; | 723 | stream >> uid; |
717 | Event e=db->eventByUID(uid); | 724 | Event e=db->eventByUID(uid); |
718 | editEvent(e); | 725 | editEvent(e); |
719 | } else if (msg == "viewDefault(QDate)"){ | 726 | } else if (msg == "viewDefault(QDate)"){ |
720 | /* simple copy from receive */ | 727 | /* simple copy from receive */ |
721 | QDataStream stream(data,IO_ReadOnly); | 728 | QDataStream stream(data,IO_ReadOnly); |
722 | QDate day; | 729 | QDate day; |
723 | stream >> day; | 730 | stream >> day; |
724 | viewDefault(day); | 731 | viewDefault(day); |
725 | needShow = true; | 732 | needShow = true; |
726 | } | 733 | } |
727 | 734 | ||
728 | if ( needShow ) { | 735 | if ( needShow ) { |
729 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 736 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
730 | // showMaximized(); | 737 | // showMaximized(); |
731 | #else | 738 | #else |
732 | // show(); | 739 | // show(); |
733 | #endif | 740 | #endif |
734 | // raise(); | 741 | // raise(); |
735 | QPEApplication::setKeepRunning(); | 742 | QPEApplication::setKeepRunning(); |
736 | // setActiveWindow(); | 743 | // setActiveWindow(); |
737 | } | 744 | } |
738 | } | 745 | } |
739 | 746 | ||
740 | void DateBook::reload() | 747 | void DateBook::reload() |
741 | { | 748 | { |
742 | db->reload(); | 749 | db->reload(); |
743 | if ( dayAction->isOn() ) viewDay(); | 750 | if ( dayAction->isOn() ) viewDay(); |
744 | else if ( weekAction->isOn() ) viewWeek(); | 751 | else if ( weekAction->isOn() ) viewWeek(); |
745 | else if ( monthAction->isOn() ) viewMonth(); | 752 | else if ( monthAction->isOn() ) viewMonth(); |
746 | syncing = FALSE; | 753 | syncing = FALSE; |
747 | } | 754 | } |
748 | 755 | ||
749 | void DateBook::flush() | 756 | void DateBook::flush() |
750 | { | 757 | { |
751 | syncing = TRUE; | 758 | syncing = TRUE; |
752 | db->save(); | 759 | db->save(); |
753 | } | 760 | } |
754 | 761 | ||
755 | void DateBook::timerEvent( QTimerEvent *e ) | 762 | void DateBook::timerEvent( QTimerEvent *e ) |
756 | { | 763 | { |
757 | if ( alarmCounter < 10 ) { | 764 | if ( alarmCounter < 10 ) { |
758 | alarmCounter++; | 765 | alarmCounter++; |
759 | Sound::soundAlarm(); | 766 | Sound::soundAlarm(); |
760 | } else { | 767 | } else { |
761 | killTimer( e->timerId() ); | 768 | killTimer( e->timerId() ); |
762 | } | 769 | } |
763 | } | 770 | } |
764 | 771 | ||
765 | void DateBook::changeClock( bool newClock ) | 772 | void DateBook::changeClock( bool newClock ) |
766 | { | 773 | { |
767 | ampm = newClock; | 774 | ampm = newClock; |
768 | // repaint the affected objects... | 775 | // repaint the affected objects... |
769 | if (dayView) dayView->redraw(); | 776 | if (dayView) dayView->redraw(); |
770 | if (weekView) weekView->redraw(); | 777 | if (weekView) weekView->redraw(); |
771 | if (weekLstView) weekLstView->redraw(); | 778 | if (weekLstView) weekLstView->redraw(); |
772 | } | 779 | } |
773 | 780 | ||
774 | void DateBook::changeWeek( bool m ) | 781 | void DateBook::changeWeek( bool m ) |
775 | { | 782 | { |
776 | /* no need to redraw, each widget catches. Do need to | 783 | /* no need to redraw, each widget catches. Do need to |
777 | store though for widgets we haven't made yet */ | 784 | store though for widgets we haven't made yet */ |
778 | onMonday = m; | 785 | onMonday = m; |
779 | } | 786 | } |
780 | 787 | ||
781 | void DateBook::slotToday() | 788 | void DateBook::slotToday() |
782 | { | 789 | { |
783 | // we need to view today using default view | 790 | // we need to view today using default view |
784 | view(defaultView,QDate::currentDate()); | 791 | view(defaultView,QDate::currentDate()); |
785 | } | 792 | } |
786 | 793 | ||
787 | void DateBook::closeEvent( QCloseEvent *e ) | 794 | void DateBook::closeEvent( QCloseEvent *e ) |
788 | { | 795 | { |
789 | if(syncing) { | 796 | if(syncing) { |
790 | /* no need to save, did that at flush */ | 797 | /* no need to save, did that at flush */ |
791 | e->accept(); | 798 | e->accept(); |
792 | return; | 799 | return; |
793 | } | 800 | } |
794 | 801 | ||
795 | // save settings will generate it's own error messages, no | 802 | // save settings will generate it's own error messages, no |
796 | // need to do checking ourselves. | 803 | // need to do checking ourselves. |
797 | saveSettings(); | 804 | saveSettings(); |
798 | if ( db->save() ) { | 805 | if ( db->save() ) { |
799 | e->accept(); | 806 | e->accept(); |
800 | } else { | 807 | } else { |
801 | if ( QMessageBox::critical( this, tr( "Out of space" ), | 808 | if ( QMessageBox::critical( this, tr( "Out of space" ), |
802 | tr("Calendar was unable to save\n" | 809 | tr("Calendar was unable to save\n" |
803 | "your changes.\n" | 810 | "your changes.\n" |
804 | "Free up some space and try again.\n" | 811 | "Free up some space and try again.\n" |
805 | "\nQuit anyway?"), | 812 | "\nQuit anyway?"), |
806 | QMessageBox::Yes|QMessageBox::Escape, | 813 | QMessageBox::Yes|QMessageBox::Escape, |
807 | QMessageBox::No|QMessageBox::Default ) | 814 | QMessageBox::No|QMessageBox::Default ) |
808 | != QMessageBox::No ) | 815 | != QMessageBox::No ) |
809 | e->accept(); | 816 | e->accept(); |
810 | else | 817 | else |
811 | e->ignore(); | 818 | e->ignore(); |
812 | } | 819 | } |
813 | } | 820 | } |
814 | 821 | ||
815 | // Entering directly from the "keyboard" | 822 | // Entering directly from the "keyboard" |
816 | void DateBook::slotNewEventFromKey( const QString &str ) | 823 | void DateBook::slotNewEventFromKey( const QString &str ) |
817 | { | 824 | { |
818 | if (syncing) { | 825 | if (syncing) { |
819 | QMessageBox::warning( this, tr("Calendar"), | 826 | QMessageBox::warning( this, tr("Calendar"), |
820 | tr( "Can not edit data, currently syncing") ); | 827 | tr( "Can not edit data, currently syncing") ); |
821 | return; | 828 | return; |
822 | } | 829 | } |
823 | 830 | ||
824 | // We get to here from a key pressed in the Day View | 831 | // We get to here from a key pressed in the Day View |
825 | // So we can assume some things. We want the string | 832 | // So we can assume some things. We want the string |
826 | // passed in to be part of the description. | 833 | // passed in to be part of the description. |
827 | QDateTime start, end; | 834 | QDateTime start, end; |
828 | if ( views->visibleWidget() == dayView ) { | 835 | if ( views->visibleWidget() == dayView ) { |
829 | dayView->selectedDates( start, end ); | 836 | dayView->selectedDates( start, end ); |
830 | } else if ( views->visibleWidget() == monthView ) { | 837 | } else if ( views->visibleWidget() == monthView ) { |
831 | QDate d = monthView->selectedDate(); | 838 | QDate d = monthView->selectedDate(); |
832 | start = end = d; | 839 | start = end = d; |
833 | start.setTime( QTime( 10, 0 ) ); | 840 | start.setTime( QTime( 10, 0 ) ); |
834 | end.setTime( QTime( 12, 0 ) ); | 841 | end.setTime( QTime( 12, 0 ) ); |
835 | } else if ( views->visibleWidget() == weekView ) { | 842 | } else if ( views->visibleWidget() == weekView ) { |
836 | QDate d = weekView->date(); | 843 | QDate d = weekView->date(); |
837 | start = end = d; | 844 | start = end = d; |
838 | start.setTime( QTime( 10, 0 ) ); | 845 | start.setTime( QTime( 10, 0 ) ); |
839 | end.setTime( QTime( 12, 0 ) ); | 846 | end.setTime( QTime( 12, 0 ) ); |
840 | } else if ( views->visibleWidget() == weekLstView ) { | 847 | } else if ( views->visibleWidget() == weekLstView ) { |
841 | QDate d = weekLstView->date(); | 848 | QDate d = weekLstView->date(); |
842 | start = end = d; | 849 | start = end = d; |
843 | start.setTime( QTime( 10, 0 ) ); | 850 | start.setTime( QTime( 10, 0 ) ); |
844 | end.setTime( QTime( 12, 0 ) ); | 851 | end.setTime( QTime( 12, 0 ) ); |
845 | } | 852 | } |
846 | slotNewEntry(start, end, str); | 853 | slotNewEntry(start, end, str); |
847 | } | 854 | } |
848 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { | 855 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { |
849 | // argh! This really needs to be encapsulated in a class | 856 | // argh! This really needs to be encapsulated in a class |
850 | // or function. | 857 | // or function. |
851 | QDialog newDlg( this, 0, TRUE ); | 858 | QDialog newDlg( this, 0, TRUE ); |
852 | newDlg.setCaption( DateEntryBase::tr("New Event") ); | 859 | newDlg.setCaption( DateEntryBase::tr("New Event") ); |
853 | DateEntry *e; | 860 | DateEntry *e; |
854 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); | 861 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); |
855 | QScrollView *sv = new QScrollView( &newDlg ); | 862 | QScrollView *sv = new QScrollView( &newDlg ); |
856 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 863 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
857 | sv->setFrameStyle( QFrame::NoFrame ); | 864 | sv->setFrameStyle( QFrame::NoFrame ); |
858 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 865 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
859 | vb->addWidget( sv ); | 866 | vb->addWidget( sv ); |
860 | 867 | ||
861 | Event ev; | 868 | Event ev; |
862 | ev.setDescription( str ); | 869 | ev.setDescription( str ); |
863 | // When the new gui comes in, change this... | 870 | // When the new gui comes in, change this... |
864 | if(location==0) { | 871 | if(location==0) { |
865 | if(defaultLocation.isEmpty()) { | 872 | if(defaultLocation.isEmpty()) { |
866 | ev.setLocation(tr("(Unknown)")); | 873 | ev.setLocation(tr("(Unknown)")); |
867 | } else { | 874 | } else { |
868 | ev.setLocation( defaultLocation ); | 875 | ev.setLocation( defaultLocation ); |
869 | } | 876 | } |
870 | } else { | 877 | } else { |
871 | ev.setLocation(location); | 878 | ev.setLocation(location); |
872 | } | 879 | } |
873 | ev.setCategories(defaultCategories); | 880 | ev.setCategories(defaultCategories); |
874 | ev.setStart( start ); | 881 | ev.setStart( start ); |
875 | ev.setEnd( end ); | 882 | ev.setEnd( end ); |
876 | 883 | ||
877 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); | 884 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); |
878 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); | 885 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); |
879 | sv->addChild( e ); | 886 | sv->addChild( e ); |
880 | while ( QPEApplication::execDialog( &newDlg ) ) { | 887 | while ( QPEApplication::execDialog( &newDlg ) ) { |
881 | ev = e->event(); | 888 | ev = e->event(); |
882 | ev.assignUid(); | 889 | ev.assignUid(); |
883 | QString error = checkEvent( ev ); | 890 | QString error = checkEvent( ev ); |
884 | if ( !error.isNull() ) { | 891 | if ( !error.isNull() ) { |
885 | if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) | 892 | if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) |
886 | continue; | 893 | continue; |
887 | } | 894 | } |
888 | db->addEvent( ev ); | 895 | db->addEvent( ev ); |
889 | emit newEvent(); | 896 | emit newEvent(); |
890 | break; | 897 | break; |
891 | } | 898 | } |
892 | } | 899 | } |
893 | 900 | ||
894 | void DateBook::setDocument( const QString &filename ) | 901 | void DateBook::setDocument( const QString &filename ) |
895 | { | 902 | { |
896 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; | 903 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; |
897 | 904 | ||
898 | QValueList<Event> tl = Event::readVCalendar( filename ); | 905 | QValueList<Event> tl = Event::readVCalendar( filename ); |
899 | for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { | 906 | for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { |
900 | db->addEvent( *it ); | 907 | db->addEvent( *it ); |
901 | } | 908 | } |
902 | } | 909 | } |
903 | 910 | ||
904 | static const char * beamfile = "/tmp/obex/event.vcs"; | 911 | static const char * beamfile = "/tmp/obex/event.vcs"; |
905 | 912 | ||
906 | void DateBook::beamEvent( const Event &e ) | 913 | void DateBook::beamEvent( const Event &e ) |
907 | { | 914 | { |
908 | odebug << "trying to beam" << oendl; | 915 | odebug << "trying to beam" << oendl; |
909 | unlink( beamfile ); // delete if exists | 916 | unlink( beamfile ); // delete if exists |
910 | mkdir("/tmp/obex/", 0755); | 917 | mkdir("/tmp/obex/", 0755); |
911 | Event::writeVCalendar( beamfile, e ); | 918 | Event::writeVCalendar( beamfile, e ); |
912 | Ir *ir = new Ir( this ); | 919 | Ir *ir = new Ir( this ); |
913 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 920 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
914 | QString description = e.description(); | 921 | QString description = e.description(); |
915 | ir->send( beamfile, description, "text/x-vCalendar" ); | 922 | ir->send( beamfile, description, "text/x-vCalendar" ); |
916 | } | 923 | } |
917 | 924 | ||
918 | void DateBook::beamDone( Ir *ir ) | 925 | void DateBook::beamDone( Ir *ir ) |
919 | { | 926 | { |
920 | delete ir; | 927 | delete ir; |
921 | unlink( beamfile ); | 928 | unlink( beamfile ); |
922 | } | 929 | } |
923 | 930 | ||
924 | void DateBook::slotFind() | 931 | void DateBook::slotFind() |
925 | { | 932 | { |
926 | // move it to the day view... | 933 | // move it to the day view... |
927 | viewDay(); | 934 | viewDay(); |
928 | FindDialog frmFind( "Calendar", this ); // no tr needed | 935 | FindDialog frmFind( "Calendar", this ); // no tr needed |
929 | frmFind.setUseDate( true ); | 936 | frmFind.setUseDate( true ); |
930 | frmFind.setDate( currentDate() ); | 937 | frmFind.setDate( currentDate() ); |
931 | QObject::connect( &frmFind, | 938 | QObject::connect( &frmFind, |
932 | SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)), | 939 | SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)), |
933 | this, | 940 | this, |
934 | SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) ); | 941 | SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) ); |
935 | QObject::connect( this, | 942 | QObject::connect( this, |
936 | SIGNAL(signalNotFound()), | 943 | SIGNAL(signalNotFound()), |
937 | &frmFind, | 944 | &frmFind, |
938 | SLOT(slotNotFound()) ); | 945 | SLOT(slotNotFound()) ); |
939 | QObject::connect( this, | 946 | QObject::connect( this, |
940 | SIGNAL(signalWrapAround()), | 947 | SIGNAL(signalWrapAround()), |
941 | &frmFind, | 948 | &frmFind, |
942 | SLOT(slotWrapAround()) ); | 949 | SLOT(slotWrapAround()) ); |
943 | frmFind.move(0,0); | 950 | frmFind.move(0,0); |
944 | frmFind.exec(); | 951 | frmFind.exec(); |
945 | inSearch = false; | 952 | inSearch = false; |
946 | } | 953 | } |
947 | 954 | ||
948 | bool catComp( QArray<int> cats, int category ) | 955 | bool catComp( QArray<int> cats, int category ) |
949 | { | 956 | { |
950 | bool returnMe; | 957 | bool returnMe; |
951 | int i, | 958 | int i, |
952 | count; | 959 | count; |
953 | 960 | ||
954 | count = int(cats.count()); | 961 | count = int(cats.count()); |
955 | returnMe = false; | 962 | returnMe = false; |
956 | if ( (category == -1 && count == 0) || category == -2 ) | 963 | if ( (category == -1 && count == 0) || category == -2 ) |
957 | returnMe = true; | 964 | returnMe = true; |
958 | else { | 965 | else { |
959 | for ( i = 0; i < count; i++ ) { | 966 | for ( i = 0; i < count; i++ ) { |
960 | if ( category == cats[i] ) { | 967 | if ( category == cats[i] ) { |
961 | returnMe = true; | 968 | returnMe = true; |
962 | break; | 969 | break; |
963 | } | 970 | } |
964 | } | 971 | } |
965 | } | 972 | } |
966 | return returnMe; | 973 | return returnMe; |
967 | } | 974 | } |
968 | 975 | ||
969 | 976 | ||
970 | void DateBook::slotDoFind( const QString& txt, const QDate &dt, | 977 | void DateBook::slotDoFind( const QString& txt, const QDate &dt, |
971 | bool caseSensitive, bool /*backwards*/, | 978 | bool caseSensitive, bool /*backwards*/, |
972 | int category ) | 979 | int category ) |
973 | { | 980 | { |
974 | QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), | 981 | QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), |
975 | next; | 982 | next; |
976 | 983 | ||
977 | QRegExp r( txt ); | 984 | QRegExp r( txt ); |
978 | r.setCaseSensitive( caseSensitive ); | 985 | r.setCaseSensitive( caseSensitive ); |
979 | 986 | ||
980 | 987 | ||
981 | static Event rev, nonrev; | 988 | static Event rev, nonrev; |
982 | if ( !inSearch ) { | 989 | if ( !inSearch ) { |
983 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); | 990 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); |
984 | nonrev.setStart( rev.start() ); | 991 | nonrev.setStart( rev.start() ); |
985 | inSearch = true; | 992 | inSearch = true; |
986 | } | 993 | } |
987 | static QDate searchDate = dt; | 994 | static QDate searchDate = dt; |
988 | // if true at the end we will start at the begin again and afterwards | 995 | // if true at the end we will start at the begin again and afterwards |
989 | // we will emit string not found | 996 | // we will emit string not found |
990 | static bool wrapAround = true; | 997 | static bool wrapAround = true; |
991 | bool candidtate; | 998 | bool candidtate; |
992 | candidtate = false; | 999 | candidtate = false; |
993 | 1000 | ||
994 | QValueList<Event> repeats = db->getRawRepeats(); | 1001 | QValueList<Event> repeats = db->getRawRepeats(); |
995 | 1002 | ||
996 | // find the candidate for the first repeat that matches... | 1003 | // find the candidate for the first repeat that matches... |
997 | // first check if there can ever be a match and then compute | 1004 | // first check if there can ever be a match and then compute |
998 | // the next occurence from start. See if this event is closer | 1005 | // the next occurence from start. See if this event is closer |
999 | // to the beginning (start. next < dtEnd) and not smaller then the last | 1006 | // to the beginning (start. next < dtEnd) and not smaller then the last |
1000 | // result. If we find a canditate we set the dtEnd to the time | 1007 | // result. If we find a canditate we set the dtEnd to the time |
1001 | // of the ocurrence and rev to this occurence. | 1008 | // of the ocurrence and rev to this occurence. |
1002 | // set wrap around to true because there might be more events coming | 1009 | // set wrap around to true because there might be more events coming |
1003 | // and we're not at the end. | 1010 | // and we're not at the end. |
1004 | QValueListConstIterator<Event> it; | 1011 | QValueListConstIterator<Event> it; |
1005 | QDate start = dt; | 1012 | QDate start = dt; |
1006 | for ( it = repeats.begin(); it != repeats.end(); ++it ) { | 1013 | for ( it = repeats.begin(); it != repeats.end(); ++it ) { |
1007 | if ( catComp( (*it).categories(), category ) ) { | 1014 | if ( catComp( (*it).categories(), category ) ) { |
1008 | if ( (*it).match( r ) ) { | 1015 | if ( (*it).match( r ) ) { |
1009 | if ( nextOccurance( *it, start, next ) ) { | 1016 | if ( nextOccurance( *it, start, next ) ) { |
1010 | if ( next < dtEnd && !(next <= rev.start() ) ) { | 1017 | if ( next < dtEnd && !(next <= rev.start() ) ) { |
1011 | rev = *it; | 1018 | rev = *it; |
1012 | dtEnd = next; | 1019 | dtEnd = next; |
1013 | rev.setStart( next ); | 1020 | rev.setStart( next ); |
1014 | candidtate = true; | 1021 | candidtate = true; |
1015 | wrapAround = true; | 1022 | wrapAround = true; |
1016 | } | 1023 | } |
1017 | } | 1024 | } |
1018 | } | 1025 | } |
1019 | } | 1026 | } |
1020 | } | 1027 | } |
1021 | 1028 | ||
1022 | // now the for first non repeat... | 1029 | // now the for first non repeat... |
1023 | // dtEnd is set by the previous iteration of repeatingEvents | 1030 | // dtEnd is set by the previous iteration of repeatingEvents |
1024 | // check if we find a closer item. Also set dtEnd to find even | 1031 | // check if we find a closer item. Also set dtEnd to find even |
1025 | // more close occurrence | 1032 | // more close occurrence |
1026 | QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); | 1033 | QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); |
1027 | qHeapSort( nonRepeats.begin(), nonRepeats.end() ); | 1034 | qHeapSort( nonRepeats.begin(), nonRepeats.end() ); |
1028 | for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { | 1035 | for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { |
1029 | if ( catComp( (*it).categories(), category ) ) { | 1036 | if ( catComp( (*it).categories(), category ) ) { |
1030 | if ( (*it).start() < dtEnd ) { | 1037 | if ( (*it).start() < dtEnd ) { |
1031 | if ( (*it).match( r ) && !(*it <= nonrev) ) { | 1038 | if ( (*it).match( r ) && !(*it <= nonrev) ) { |
1032 | nonrev = *it; | 1039 | nonrev = *it; |
1033 | dtEnd = nonrev.start(); | 1040 | dtEnd = nonrev.start(); |
1034 | candidtate = true; | 1041 | candidtate = true; |
1035 | wrapAround = true; | 1042 | wrapAround = true; |
1036 | break; | 1043 | break; |
1037 | } | 1044 | } |
1038 | } | 1045 | } |
1039 | } | 1046 | } |
1040 | } | 1047 | } |
1041 | if ( candidtate ) { | 1048 | if ( candidtate ) { |
1042 | dayView->setStartViewTime( dtEnd.time().hour() ); | 1049 | dayView->setStartViewTime( dtEnd.time().hour() ); |
1043 | dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), | 1050 | dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), |
1044 | dtEnd.date().day() ); | 1051 | dtEnd.date().day() ); |
1045 | } else { | 1052 | } else { |
1046 | if ( wrapAround ) { | 1053 | if ( wrapAround ) { |
1047 | emit signalWrapAround(); | 1054 | emit signalWrapAround(); |
1048 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); | 1055 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); |
1049 | nonrev.setStart( rev.start() ); | 1056 | nonrev.setStart( rev.start() ); |
1050 | } else | 1057 | } else |
1051 | emit signalNotFound(); | 1058 | emit signalNotFound(); |
1052 | wrapAround = !wrapAround; | 1059 | wrapAround = !wrapAround; |
1053 | } | 1060 | } |
1054 | } | 1061 | } |
1055 | 1062 | ||
1056 | Event DateBookDBHack::eventByUID(int uid) { | 1063 | Event DateBookDBHack::eventByUID(int uid) { |
1057 | 1064 | ||
1058 | // FIXME: Dirty Hacks to get hold of the private event lists | 1065 | // FIXME: Dirty Hacks to get hold of the private event lists |
1059 | QDate start; | 1066 | QDate start; |
1060 | QDate end=start.addDays(-1); | 1067 | QDate end=start.addDays(-1); |
1061 | QValueList<Event> myEventList=getNonRepeatingEvents(start,end); | 1068 | QValueList<Event> myEventList=getNonRepeatingEvents(start,end); |
1062 | QValueList<Event> myRepeatEvents=getRawRepeats(); | 1069 | QValueList<Event> myRepeatEvents=getRawRepeats(); |
1063 | 1070 | ||
1064 | QValueList<Event>::ConstIterator it; | 1071 | QValueList<Event>::ConstIterator it; |
1065 | 1072 | ||
1066 | for (it = myEventList.begin(); it != myEventList.end(); it++) { | 1073 | for (it = myEventList.begin(); it != myEventList.end(); it++) { |
1067 | if ((*it).uid() == uid) return *it; | 1074 | if ((*it).uid() == uid) return *it; |
1068 | } | 1075 | } |
1069 | for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { | 1076 | for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { |
1070 | if ((*it).uid() == uid) return *it; | 1077 | if ((*it).uid() == uid) return *it; |
1071 | } | 1078 | } |
1072 | 1079 | ||
1073 | Event ev; | 1080 | Event ev; |
1074 | return ev; // return at least | 1081 | return ev; // return at least |
1075 | } | 1082 | } |
1083 | |||
1084 | DateBookHoliday::DateBookHoliday() | ||
1085 | { | ||
1086 | _pluginlist.clear(); | ||
1087 | init(); | ||
1088 | } | ||
1089 | |||
1090 | DateBookHoliday::~DateBookHoliday() | ||
1091 | { | ||
1092 | deinit(); | ||
1093 | } | ||
1094 | |||
1095 | void DateBookHoliday::deinit() | ||
1096 | { | ||
1097 | QValueList<HPlugin*>::Iterator it; | ||
1098 | for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { | ||
1099 | HPlugin*_pl = *it; | ||
1100 | // destructs itself? | ||
1101 | _pl->_if->release(); | ||
1102 | _pl->_lib->unload(); | ||
1103 | delete _pl->_lib; | ||
1104 | delete _pl; | ||
1105 | } | ||
1106 | _pluginlist.clear(); | ||
1107 | } | ||
1108 | |||
1109 | void DateBookHoliday::init() | ||
1110 | { | ||
1111 | deinit(); | ||
1112 | QString path = QPEApplication::qpeDir() + "plugins/datebook/holiday"; | ||
1113 | QDir dir( path, "lib*.so" ); | ||
1114 | QStringList list = dir.entryList(); | ||
1115 | QStringList::Iterator it; | ||
1116 | for (it=list.begin();it!=list.end();++it) { | ||
1117 | Opie::Datebook::HolidayPluginIf*hif = 0; | ||
1118 | QLibrary*lib=new QLibrary(path+"/"+*it); | ||
1119 | if ((lib->queryInterface(IID_HOLIDAY_PLUGIN,(QUnknownInterface**)&hif) == QS_OK) && hif) { | ||
1120 | Opie::Datebook::HolidayPlugin*pl = hif->plugin(); | ||
1121 | if (pl) { | ||
1122 | HPlugin*_pl=new HPlugin; | ||
1123 | _pl->_plugin = pl; | ||
1124 | odebug << "Found holiday " << pl->description()<<oendl; | ||
1125 | _pl->_lib = lib; | ||
1126 | _pl->_if = hif; | ||
1127 | _pluginlist.append(_pl); | ||
1128 | } else { | ||
1129 | } | ||
1130 | } else { | ||
1131 | delete lib; | ||
1132 | } | ||
1133 | } | ||
1134 | } | ||
1135 | |||
1136 | QStringList DateBookHoliday::holidaylist(const QDate&aDate) | ||
1137 | { | ||
1138 | QStringList ret; | ||
1139 | QValueList<HPlugin*>::Iterator it; | ||
1140 | for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { | ||
1141 | HPlugin*_pl = *it; | ||
1142 | ret+=_pl->_plugin->entries(aDate); | ||
1143 | } | ||
1144 | return ret; | ||
1145 | } | ||
1146 | |||
1147 | QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day) | ||
1148 | { | ||
1149 | return holidaylist(QDate(year,month,day)); | ||
1150 | } | ||
1151 | |||
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index d7cfb33..54ffcfb 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h | |||
@@ -1,139 +1,168 @@ | |||
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 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef DATEBOOK_H | 20 | #ifndef DATEBOOK_H |
21 | #define DATEBOOK_H | 21 | #define DATEBOOK_H |
22 | 22 | ||
23 | #include <qpe/datebookdb.h> | 23 | #include <qpe/datebookdb.h> |
24 | 24 | ||
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | 26 | ||
27 | enum { DAY=1,WEEK,WEEKLST,MONTH };// defaultView values | 27 | enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values |
28 | enum { NONE=0,NORMAL,EXTENDED };// WeekLstView's modes. | 28 | enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes. |
29 | 29 | ||
30 | class QAction; | 30 | class QAction; |
31 | class QWidgetStack; | 31 | class QWidgetStack; |
32 | class DateBookDay; | 32 | class DateBookDay; |
33 | class DateBookWeek; | 33 | class DateBookWeek; |
34 | class DateBookWeekLst; | 34 | class DateBookWeekLst; |
35 | class DateBookMonth; | 35 | class DateBookMonth; |
36 | class Event; | 36 | class Event; |
37 | class QDate; | 37 | class QDate; |
38 | class Ir; | 38 | class Ir; |
39 | class QLibrary; | ||
40 | |||
41 | namespace Opie { | ||
42 | namespace Datebook { | ||
43 | class HolidayPlugin; | ||
44 | class HolidayPluginIf; | ||
45 | } | ||
46 | } | ||
39 | 47 | ||
40 | class DateBookDBHack : public DateBookDB { | 48 | class DateBookDBHack : public DateBookDB { |
41 | public: | 49 | public: |
42 | Event eventByUID(int id); | 50 | Event eventByUID(int id); |
43 | }; | 51 | }; |
44 | 52 | ||
53 | class DateBookHoliday | ||
54 | { | ||
55 | public: | ||
56 | DateBookHoliday(); | ||
57 | virtual ~DateBookHoliday(); | ||
58 | |||
59 | QStringList holidaylist(const QDate&); | ||
60 | QStringList holidaylist(unsigned year, unsigned month, unsigned day); | ||
61 | protected: | ||
62 | void init(); | ||
63 | void deinit(); | ||
64 | |||
65 | struct HPlugin { | ||
66 | Opie::Datebook::HolidayPlugin*_plugin; | ||
67 | QLibrary*_lib; | ||
68 | Opie::Datebook::HolidayPluginIf*_if; | ||
69 | }; | ||
70 | QValueList<HPlugin*>_pluginlist; | ||
71 | }; | ||
72 | |||
45 | class DateBook : public QMainWindow | 73 | class DateBook : public QMainWindow |
46 | { | 74 | { |
47 | Q_OBJECT | 75 | Q_OBJECT |
48 | 76 | ||
49 | public: | 77 | public: |
50 | static QString appName() { return QString::fromLatin1("datebook"); } | 78 | static QString appName() { return QString::fromLatin1("datebook"); } |
51 | DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 79 | DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
52 | ~DateBook(); | 80 | ~DateBook(); |
53 | 81 | ||
54 | signals: | 82 | signals: |
55 | void newEvent(); | 83 | void newEvent(); |
56 | void signalNotFound(); | 84 | void signalNotFound(); |
57 | void signalWrapAround(); | 85 | void signalWrapAround(); |
58 | 86 | ||
59 | protected: | 87 | protected: |
60 | QDate currentDate(); | 88 | QDate currentDate(); |
61 | void timerEvent( QTimerEvent *e ); | 89 | void timerEvent( QTimerEvent *e ); |
62 | void closeEvent( QCloseEvent *e ); | 90 | void closeEvent( QCloseEvent *e ); |
63 | 91 | ||
64 | void view(int v, const QDate &d); | 92 | void view(int v, const QDate &d); |
65 | 93 | ||
66 | public slots: | 94 | public slots: |
67 | void flush(); | 95 | void flush(); |
68 | void reload(); | 96 | void reload(); |
69 | 97 | ||
70 | private slots: | 98 | private slots: |
71 | void fileNew(); | 99 | void fileNew(); |
72 | void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); | 100 | void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); |
73 | void slotSettings(); | 101 | void slotSettings(); |
74 | void slotToday();// view today | 102 | void slotToday(); // view today |
75 | void changeClock( bool newClock ); | 103 | void changeClock( bool newClock ); |
76 | void changeWeek( bool newDay ); | 104 | void changeWeek( bool newDay ); |
77 | void appMessage(const QCString& msg, const QByteArray& data); | 105 | void appMessage(const QCString& msg, const QByteArray& data); |
78 | // handle key events in the day view... | 106 | // handle key events in the day view... |
79 | void slotNewEventFromKey( const QString &str ); | 107 | void slotNewEventFromKey( const QString &str ); |
80 | void slotFind(); | 108 | void slotFind(); |
81 | void slotDoFind( const QString &, const QDate &, bool, bool, int ); | 109 | void slotDoFind( const QString &, const QDate &, bool, bool, int ); |
82 | 110 | ||
83 | void viewDefault(const QDate &d); | 111 | void viewDefault(const QDate &d); |
84 | 112 | ||
85 | void viewDay(); | 113 | void viewDay(); |
86 | void viewWeek(); | 114 | void viewWeek(); |
87 | void viewWeekLst(); | 115 | void viewWeekLst(); |
88 | void viewMonth(); | 116 | void viewMonth(); |
89 | 117 | ||
90 | void showDay( int y, int m, int d ); | 118 | void showDay( int y, int m, int d ); |
91 | 119 | ||
92 | void insertEvent( const Event &e ); | 120 | void insertEvent( const Event &e ); |
93 | void editEvent( const Event &e ); | 121 | void editEvent( const Event &e ); |
94 | void duplicateEvent( const Event &e ); | 122 | void duplicateEvent( const Event &e ); |
95 | void removeEvent( const Event &e ); | 123 | void removeEvent( const Event &e ); |
96 | 124 | ||
97 | void receive( const QCString &msg, const QByteArray &data ); | 125 | void receive( const QCString &msg, const QByteArray &data ); |
98 | void setDocument( const QString & ); | 126 | void setDocument( const QString & ); |
99 | void beamEvent( const Event &e ); | 127 | void beamEvent( const Event &e ); |
100 | void beamDone( Ir *ir ); | 128 | void beamDone( Ir *ir ); |
101 | 129 | ||
102 | private: | 130 | private: |
103 | void addEvent( const Event &e ); | 131 | void addEvent( const Event &e ); |
104 | void initDay(); | 132 | void initDay(); |
105 | void initWeek(); | 133 | void initWeek(); |
106 | void initWeekLst(); | 134 | void initWeekLst(); |
107 | void initMonth(); | 135 | void initMonth(); |
108 | void loadSettings(); | 136 | void loadSettings(); |
109 | void saveSettings(); | 137 | void saveSettings(); |
110 | 138 | ||
111 | private: | 139 | private: |
112 | DateBookDBHack *db; | 140 | DateBookDBHack *db; |
113 | QWidgetStack *views; | 141 | DateBookHoliday*db_holiday; |
114 | DateBookDay *dayView; | 142 | QWidgetStack *views; |
115 | DateBookWeek *weekView; | 143 | DateBookDay *dayView; |
116 | DateBookMonth *monthView; | 144 | DateBookWeek *weekView; |
117 | DateBookWeekLst *weekLstView; | 145 | DateBookMonth *monthView; |
118 | QAction *dayAction, *weekAction, *weekLstAction, *monthAction; | 146 | DateBookWeekLst *weekLstView; |
119 | int weeklistviewconfig; | 147 | QAction *dayAction, *weekAction, *weekLstAction, *monthAction; |
120 | bool aPreset; // have everything set to alarm? | 148 | int weeklistviewconfig; |
121 | int presetTime; // the standard time for the alarm | 149 | bool aPreset; // have everything set to alarm? |
122 | int startTime; | 150 | int presetTime; // the standard time for the alarm |
123 | int rowStyle; | 151 | int startTime; |
124 | int defaultView; | 152 | int rowStyle; |
125 | QArray<int> defaultCategories; | 153 | int defaultView; |
126 | QString defaultLocation; | 154 | QArray<int> defaultCategories; |
127 | bool bJumpToCurTime; //should jump to current time in dayview? | 155 | QString defaultLocation; |
128 | bool ampm; | 156 | bool bJumpToCurTime; //should jump to current time in dayview? |
129 | bool onMonday; | 157 | bool ampm; |
130 | 158 | bool onMonday; | |
131 | bool syncing; | 159 | |
132 | bool inSearch; | 160 | bool syncing; |
133 | 161 | bool inSearch; | |
134 | int alarmCounter; | 162 | |
163 | int alarmCounter; | ||
135 | 164 | ||
136 | QString checkEvent(const Event &); | 165 | QString checkEvent(const Event &); |
137 | }; | 166 | }; |
138 | 167 | ||
139 | #endif | 168 | #endif |
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index ca63dc5..dfe39e5 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -1,935 +1,945 @@ | |||
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 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "datebookday.h" | 21 | #include "datebookday.h" |
22 | #include "datebookdayheaderimpl.h" | 22 | #include "datebookdayheaderimpl.h" |
23 | #include "datebookdayallday.h" | 23 | #include "datebookdayallday.h" |
24 | 24 | ||
25 | #include <opie2/oholidayplugin.h> | ||
25 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
26 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/ir.h> | 28 | #include <qpe/ir.h> |
28 | 29 | ||
29 | #include <qsimplerichtext.h> | 30 | #include <qsimplerichtext.h> |
30 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
31 | 32 | ||
32 | 33 | ||
33 | #include <qtimer.h> | 34 | #include <qtimer.h> |
34 | 35 | ||
35 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name ) | 36 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name ) |
36 | : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() ) | 37 | : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() ) |
37 | { | 38 | { |
38 | enableClipper(TRUE); | 39 | enableClipper(TRUE); |
39 | setTopMargin( 0 ); | 40 | setTopMargin( 0 ); |
40 | horizontalHeader()->hide(); | 41 | horizontalHeader()->hide(); |
41 | setLeftMargin(38); | 42 | setLeftMargin(38); |
42 | setColumnStretchable( 0, TRUE ); | 43 | setColumnStretchable( 0, TRUE ); |
43 | setHScrollBarMode( QScrollView::AlwaysOff ); | 44 | setHScrollBarMode( QScrollView::AlwaysOff ); |
44 | verticalHeader()->setPalette(white); | 45 | verticalHeader()->setPalette(white); |
45 | verticalHeader()->setResizeEnabled(FALSE); | 46 | verticalHeader()->setResizeEnabled(FALSE); |
46 | setSelectionMode( Single ); | 47 | setSelectionMode( Single ); |
47 | 48 | ||
48 | // get rid of being able to edit things... | 49 | // get rid of being able to edit things... |
49 | QTableItem *tmp; | 50 | QTableItem *tmp; |
50 | int row; | 51 | int row; |
51 | for ( row = 0; row < numRows(); row++ ) { | 52 | for ( row = 0; row < numRows(); row++ ) { |
52 | tmp = new QTableItem( this, QTableItem::Never, QString::null); | 53 | tmp = new QTableItem( this, QTableItem::Never, QString::null); |
53 | setItem( row, 0, tmp ); | 54 | setItem( row, 0, tmp ); |
54 | //setRowHeight( row, 40); | 55 | //setRowHeight( row, 40); |
55 | } | 56 | } |
56 | 57 | ||
57 | initHeader(); | 58 | initHeader(); |
58 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); | 59 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); |
59 | } | 60 | } |
60 | 61 | ||
61 | void DateBookDayView::initHeader() | 62 | void DateBookDayView::initHeader() |
62 | { | 63 | { |
63 | QString strTmp; | 64 | QString strTmp; |
64 | int preferredWidth = 0; | 65 | int preferredWidth = 0; |
65 | for ( int i = 0; i < 24; ++i ) { | 66 | for ( int i = 0; i < 24; ++i ) { |
66 | if ( ampm ) { | 67 | if ( ampm ) { |
67 | if ( i == 0 ) | 68 | if ( i == 0 ) |
68 | strTmp = QString::number(12) + ":00"; | 69 | strTmp = QString::number(12) + ":00"; |
69 | else if ( i == 12 ) | 70 | else if ( i == 12 ) |
70 | strTmp = QString::number(12) + tr(":00p"); | 71 | strTmp = QString::number(12) + tr(":00p"); |
71 | else if ( i > 12 ) | 72 | else if ( i > 12 ) |
72 | strTmp = QString::number( i - 12 ) + tr(":00p"); | 73 | strTmp = QString::number( i - 12 ) + tr(":00p"); |
73 | else | 74 | else |
74 | strTmp = QString::number(i) + ":00"; | 75 | strTmp = QString::number(i) + ":00"; |
75 | } else { | 76 | } else { |
76 | if ( i < 10 ) | 77 | if ( i < 10 ) |
77 | strTmp = "0" + QString::number(i) + ":00"; | 78 | strTmp = "0" + QString::number(i) + ":00"; |
78 | else | 79 | else |
79 | strTmp = QString::number(i) + ":00"; | 80 | strTmp = QString::number(i) + ":00"; |
80 | } | 81 | } |
81 | strTmp = strTmp.rightJustify( 6, ' ' ); | 82 | strTmp = strTmp.rightJustify( 6, ' ' ); |
82 | verticalHeader()->setLabel( i, strTmp ); | 83 | verticalHeader()->setLabel( i, strTmp ); |
83 | 84 | ||
84 | // Compute correct width for current Font (Add some space right) | 85 | // Compute correct width for current Font (Add some space right) |
85 | int actWidth = QFontMetrics( QFont::defaultFont() ).width( strTmp + QString(" ") ); | 86 | int actWidth = QFontMetrics( QFont::defaultFont() ).width( strTmp + QString(" ") ); |
86 | if ( preferredWidth < actWidth ) | 87 | if ( preferredWidth < actWidth ) |
87 | preferredWidth = actWidth; | 88 | preferredWidth = actWidth; |
88 | setRowStretchable( i, FALSE ); | 89 | setRowStretchable( i, FALSE ); |
89 | } | 90 | } |
90 | 91 | ||
91 | // It seems as if the header has a bug. It does not resize | 92 | // It seems as if the header has a bug. It does not resize |
92 | // correct horizontally if it is used vertical.. | 93 | // correct horizontally if it is used vertical.. |
93 | // Thus, we do it manually.. | 94 | // Thus, we do it manually.. |
94 | setLeftMargin( preferredWidth ); | 95 | setLeftMargin( preferredWidth ); |
95 | } | 96 | } |
96 | 97 | ||
97 | void DateBookDayView::slotDateChanged( int y, int m, int d ) | 98 | void DateBookDayView::slotDateChanged( int y, int m, int d ) |
98 | { | 99 | { |
99 | currDate.setYMD(y,m,d); | 100 | currDate.setYMD(y,m,d); |
100 | } | 101 | } |
101 | 102 | ||
102 | void DateBookDayView::slotChangeClock( bool newClock ) | 103 | void DateBookDayView::slotChangeClock( bool newClock ) |
103 | { | 104 | { |
104 | ampm = newClock; | 105 | ampm = newClock; |
105 | initHeader(); | 106 | initHeader(); |
106 | } | 107 | } |
107 | 108 | ||
108 | bool DateBookDayView::whichClock() const | 109 | bool DateBookDayView::whichClock() const |
109 | { | 110 | { |
110 | return ampm; | 111 | return ampm; |
111 | } | 112 | } |
112 | 113 | ||
113 | void DateBookDayView::moveUp() | 114 | void DateBookDayView::moveUp() |
114 | { | 115 | { |
115 | scrollBy(0, -20); | 116 | scrollBy(0, -20); |
116 | } | 117 | } |
117 | 118 | ||
118 | void DateBookDayView::moveDown() | 119 | void DateBookDayView::moveDown() |
119 | { | 120 | { |
120 | scrollBy(0, 20); | 121 | scrollBy(0, 20); |
121 | } | 122 | } |
122 | 123 | ||
123 | void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) | 124 | void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) |
124 | { | 125 | { |
125 | int w = cr.width(); | 126 | int w = cr.width(); |
126 | int h = cr.height(); | 127 | int h = cr.height(); |
127 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); | 128 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); |
128 | if ( showGrid() ) { | 129 | if ( showGrid() ) { |
129 | // Draw our lines | 130 | // Draw our lines |
130 | int x2 = w - 1; | 131 | int x2 = w - 1; |
131 | int y2 = h - 1; | 132 | int y2 = h - 1; |
132 | QPen pen( p->pen() ); | 133 | QPen pen( p->pen() ); |
133 | p->setPen( colorGroup().dark() ); | 134 | p->setPen( colorGroup().dark() ); |
134 | p->drawLine( x2, 0, x2, y2 ); | 135 | p->drawLine( x2, 0, x2, y2 ); |
135 | p->drawLine( 0, y2, x2, y2 ); | 136 | p->drawLine( 0, y2, x2, y2 ); |
136 | 137 | ||
137 | p->setPen( colorGroup().midlight() ); | 138 | p->setPen( colorGroup().midlight() ); |
138 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); | 139 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); |
139 | 140 | ||
140 | p->setPen( pen ); | 141 | p->setPen( pen ); |
141 | } | 142 | } |
142 | } | 143 | } |
143 | 144 | ||
144 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) | 145 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) |
145 | { | 146 | { |
146 | } | 147 | } |
147 | 148 | ||
148 | void DateBookDayView::resizeEvent( QResizeEvent *e ) | 149 | void DateBookDayView::resizeEvent( QResizeEvent *e ) |
149 | { | 150 | { |
150 | QTable::resizeEvent( e ); | 151 | QTable::resizeEvent( e ); |
151 | columnWidthChanged( 0 ); | 152 | columnWidthChanged( 0 ); |
152 | emit sigColWidthChanged(); | 153 | emit sigColWidthChanged(); |
153 | } | 154 | } |
154 | 155 | ||
155 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) | 156 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) |
156 | { | 157 | { |
157 | QString txt = e->text(); | 158 | QString txt = e->text(); |
158 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { | 159 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { |
159 | // we this is some sort of thing we know about... | 160 | // we this is some sort of thing we know about... |
160 | e->accept(); | 161 | e->accept(); |
161 | emit sigCapturedKey( txt ); | 162 | emit sigCapturedKey( txt ); |
162 | } else { | 163 | } else { |
163 | // I don't know what this key is, do you? | 164 | // I don't know what this key is, do you? |
164 | e->ignore(); | 165 | e->ignore(); |
165 | } | 166 | } |
166 | } | 167 | } |
167 | 168 | ||
168 | void DateBookDayView::setRowStyle( int style ) | 169 | void DateBookDayView::setRowStyle( int style ) |
169 | { | 170 | { |
170 | if (style<0) style = 0; | 171 | if (style<0) style = 0; |
171 | 172 | ||
172 | for (int i=0; i<numRows(); i++) | 173 | for (int i=0; i<numRows(); i++) |
173 | setRowHeight(i, style*10+20); | 174 | setRowHeight(i, style*10+20); |
174 | } | 175 | } |
175 | 176 | ||
176 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ ) | 177 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ ) |
177 | { | 178 | { |
178 | int sh=99,eh=-1; | 179 | int sh=99,eh=-1; |
179 | 180 | ||
180 | for(int i=0;i<this->numSelections();i++) { | 181 | for(int i=0;i<this->numSelections();i++) { |
181 | QTableSelection sel = this->selection( i ); | 182 | QTableSelection sel = this->selection( i ); |
182 | sh = QMIN(sh,sel.topRow()); | 183 | sh = QMIN(sh,sel.topRow()); |
183 | eh = QMAX(sh,sel.bottomRow()+1); | 184 | eh = QMAX(sh,sel.bottomRow()+1); |
184 | } | 185 | } |
185 | if (sh > 23 || eh < 1) { | 186 | if (sh > 23 || eh < 1) { |
186 | sh=8; | 187 | sh=8; |
187 | eh=9; | 188 | eh=9; |
188 | } | 189 | } |
189 | 190 | ||
190 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); | 191 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); |
191 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); | 192 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); |
192 | this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); | 193 | this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); |
193 | quickLineEdit->setFocus(); | 194 | quickLineEdit->setFocus(); |
194 | quickLineEdit->show(); | 195 | quickLineEdit->show(); |
195 | } | 196 | } |
196 | 197 | ||
197 | //=========================================================================== | 198 | //=========================================================================== |
198 | 199 | ||
199 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) | 200 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) |
200 | { | 201 | { |
201 | active=1; | 202 | active=1; |
202 | quickEvent.setStart(start); | 203 | quickEvent.setStart(start); |
203 | quickEvent.setEnd(end); | 204 | quickEvent.setEnd(end); |
204 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); | 205 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); |
205 | } | 206 | } |
206 | 207 | ||
207 | void DateBookDayViewQuickLineEdit::slotReturnPressed() | 208 | void DateBookDayViewQuickLineEdit::slotReturnPressed() |
208 | { | 209 | { |
209 | if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. | 210 | if(active && (!this->text().isEmpty())) { // Fix to avoid having this event beeing added multiple times. |
210 | quickEvent.setDescription(this->text()); | 211 | quickEvent.setDescription(this->text()); |
211 | connect(this,SIGNAL(insertEvent(const Event&)),this->topLevelWidget(),SLOT(insertEvent(const Event&))); | 212 | connect(this,SIGNAL(insertEvent(const Event&)),this->topLevelWidget(),SLOT(insertEvent(const Event&))); |
212 | emit(insertEvent(quickEvent)); | 213 | emit(insertEvent(quickEvent)); |
213 | active=0; | 214 | active=0; |
214 | } | 215 | } |
215 | /* we need to return to this object.. */ | 216 | /* we need to return to this object.. */ |
216 | QTimer::singleShot(500, this, SLOT(finallyCallClose()) );// Close and also delete this widget | 217 | QTimer::singleShot(500, this, SLOT(finallyCallClose()) ); // Close and also delete this widget |
217 | } | 218 | } |
218 | void DateBookDayViewQuickLineEdit::finallyCallClose() { | 219 | void DateBookDayViewQuickLineEdit::finallyCallClose() { |
219 | close(true); // also deletes this widget... | 220 | close(true); // also deletes this widget... |
220 | } | 221 | } |
221 | 222 | ||
222 | void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */) | 223 | void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */) |
223 | { | 224 | { |
224 | slotReturnPressed(); // Reuse code to add event and close this widget. | 225 | slotReturnPressed(); // Reuse code to add event and close this widget. |
225 | } | 226 | } |
226 | 227 | ||
227 | //=========================================================================== | 228 | //=========================================================================== |
228 | 229 | ||
229 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) | 230 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, DateBookHoliday*newHdb, QWidget *parent, const char *name ) |
230 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) | 231 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) |
231 | { | 232 | { |
232 | widgetList.setAutoDelete( true ); | 233 | widgetList.setAutoDelete( true ); |
233 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); | 234 | _holiday_db = newHdb; |
234 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); | 235 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); |
236 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); | ||
235 | 237 | ||
236 | m_allDays = new DatebookdayAllday(newDb, this, "all day event list" ); | 238 | m_allDays = new DatebookdayAllday(newDb, this, "all day event list" ); |
237 | m_allDays->hide(); | 239 | m_allDays->hide(); |
238 | 240 | ||
239 | view = new DateBookDayView( ampm, this, "day view" ); | 241 | view = new DateBookDayView( ampm, this, "day view" ); |
240 | 242 | ||
241 | connect( header, SIGNAL( dateChanged(int,int,int) ), this, SLOT( dateChanged(int,int,int) ) ); | 243 | connect( header, SIGNAL( dateChanged(int,int,int) ), this, SLOT( dateChanged(int,int,int) ) ); |
242 | connect( header, SIGNAL( dateChanged(int,int,int) ), view, SLOT( slotDateChanged(int,int,int) ) ); | 244 | connect( header, SIGNAL( dateChanged(int,int,int) ), view, SLOT( slotDateChanged(int,int,int) ) ); |
243 | connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); | 245 | connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); |
244 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); | 246 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); |
245 | connect( view, SIGNAL(sigCapturedKey(const QString&)), this, SIGNAL(sigNewEvent(const QString&)) ); | 247 | connect( view, SIGNAL(sigCapturedKey(const QString&)), this, SIGNAL(sigNewEvent(const QString&)) ); |
246 | 248 | ||
247 | QTimer *timer = new QTimer( this ); | 249 | QTimer *timer = new QTimer( this ); |
248 | 250 | ||
249 | connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors | 251 | connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) ); //connect timer for updating timeMarker & daywidgetcolors |
250 | timer->start( 1000*60*5, FALSE ); //update every 5min | 252 | timer->start( 1000*60*5, FALSE ); //update every 5min |
251 | 253 | ||
252 | selectedWidget = 0; | 254 | selectedWidget = 0; |
253 | 255 | ||
254 | timeMarker = new DateBookDayTimeMarker( this ); | 256 | timeMarker = new DateBookDayTimeMarker( this ); |
255 | timeMarker->setTime( QTime::currentTime() ); | 257 | timeMarker->setTime( QTime::currentTime() ); |
256 | rowStyle = -1; // initialize with bogus values | 258 | rowStyle = -1; // initialize with bogus values |
257 | jumpToCurTime = false; | 259 | jumpToCurTime = false; |
258 | } | 260 | } |
259 | 261 | ||
260 | void DateBookDay::setJumpToCurTime( bool bJump ) | 262 | void DateBookDay::setJumpToCurTime( bool bJump ) |
261 | { | 263 | { |
262 | jumpToCurTime = bJump; | 264 | jumpToCurTime = bJump; |
263 | } | 265 | } |
264 | 266 | ||
265 | void DateBookDay::setRowStyle( int style ) | 267 | void DateBookDay::setRowStyle( int style ) |
266 | { | 268 | { |
267 | if (rowStyle != style) view->setRowStyle( style ); | 269 | if (rowStyle != style) view->setRowStyle( style ); |
268 | rowStyle = style; | 270 | rowStyle = style; |
269 | } | 271 | } |
270 | 272 | ||
271 | void DateBookDay::updateView( void ) | 273 | void DateBookDay::updateView( void ) |
272 | { | 274 | { |
273 | timeMarker->setTime( QTime::currentTime() ); | 275 | timeMarker->setTime( QTime::currentTime() ); |
274 | //need to find a way to update all DateBookDayWidgets | 276 | //need to find a way to update all DateBookDayWidgets |
275 | } | 277 | } |
276 | 278 | ||
277 | void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) | 279 | void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) |
278 | { | 280 | { |
279 | selectedWidget = w; | 281 | selectedWidget = w; |
280 | } | 282 | } |
281 | 283 | ||
282 | DateBookDayWidget * DateBookDay::getSelectedWidget( void ) | 284 | DateBookDayWidget * DateBookDay::getSelectedWidget( void ) |
283 | { | 285 | { |
284 | return selectedWidget; | 286 | return selectedWidget; |
285 | } | 287 | } |
286 | 288 | ||
287 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) | 289 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) |
288 | { | 290 | { |
289 | start.setDate( currDate ); | 291 | start.setDate( currDate ); |
290 | end.setDate( currDate ); | 292 | end.setDate( currDate ); |
291 | 293 | ||
292 | int sh=99,eh=-1; | 294 | int sh=99,eh=-1; |
293 | 295 | ||
294 | int n = dayView()->numSelections(); | 296 | int n = dayView()->numSelections(); |
295 | 297 | ||
296 | for (int i=0; i<n; i++) { | 298 | for (int i=0; i<n; i++) { |
297 | QTableSelection sel = dayView()->selection( i ); | 299 | QTableSelection sel = dayView()->selection( i ); |
298 | sh = QMIN(sh,sel.topRow()); | 300 | sh = QMIN(sh,sel.topRow()); |
299 | eh = QMAX(sh,sel.bottomRow()+1); | 301 | eh = QMAX(sh,sel.bottomRow()+1); |
300 | } | 302 | } |
301 | 303 | ||
302 | if (sh > 23 || eh < 1) { | 304 | if (sh > 23 || eh < 1) { |
303 | sh=8; | 305 | sh=8; |
304 | eh=9; | 306 | eh=9; |
305 | } | 307 | } |
306 | 308 | ||
307 | start.setTime( QTime( sh, 0, 0 ) ); | 309 | start.setTime( QTime( sh, 0, 0 ) ); |
308 | end.setTime( QTime( eh, 0, 0 ) ); | 310 | end.setTime( QTime( eh, 0, 0 ) ); |
309 | } | 311 | } |
310 | 312 | ||
311 | void DateBookDay::setDate( int y, int m, int d ) | 313 | void DateBookDay::setDate( int y, int m, int d ) |
312 | { | 314 | { |
313 | header->setDate( y, m, d ); | 315 | header->setDate( y, m, d ); |
314 | selectedWidget = 0; | 316 | selectedWidget = 0; |
315 | } | 317 | } |
316 | 318 | ||
317 | void DateBookDay::setDate( QDate d) | 319 | void DateBookDay::setDate( QDate d) |
318 | { | 320 | { |
319 | header->setDate( d.year(), d.month(), d.day() ); | 321 | header->setDate( d.year(), d.month(), d.day() ); |
320 | selectedWidget = 0; | 322 | selectedWidget = 0; |
321 | } | 323 | } |
322 | 324 | ||
323 | void DateBookDay::dateChanged( int y, int m, int d ) | 325 | void DateBookDay::dateChanged( int y, int m, int d ) |
324 | { | 326 | { |
325 | QDate date( y, m, d ); | 327 | QDate date( y, m, d ); |
326 | if ( currDate == date ) | 328 | if ( currDate == date ) |
327 | return; | 329 | return; |
328 | currDate.setYMD( y, m, d ); | 330 | currDate.setYMD( y, m, d ); |
329 | relayoutPage(); | 331 | relayoutPage(); |
330 | dayView()->clearSelection(); | 332 | dayView()->clearSelection(); |
331 | QTableSelection ts; | 333 | QTableSelection ts; |
332 | 334 | ||
333 | if (jumpToCurTime && this->date() == QDate::currentDate()) | 335 | if (jumpToCurTime && this->date() == QDate::currentDate()) |
334 | { | 336 | { |
335 | ts.init( QTime::currentTime().hour(), 0); | 337 | ts.init( QTime::currentTime().hour(), 0); |
336 | ts.expandTo( QTime::currentTime().hour(), 0); | 338 | ts.expandTo( QTime::currentTime().hour(), 0); |
337 | } else { | 339 | } else { |
338 | ts.init( startTime, 0 ); | 340 | ts.init( startTime, 0 ); |
339 | ts.expandTo( startTime, 0 ); | 341 | ts.expandTo( startTime, 0 ); |
340 | } | 342 | } |
341 | 343 | ||
342 | dayView()->addSelection( ts ); | 344 | dayView()->addSelection( ts ); |
343 | selectedWidget = 0; | 345 | selectedWidget = 0; |
344 | } | 346 | } |
345 | 347 | ||
346 | void DateBookDay::redraw() | 348 | void DateBookDay::redraw() |
347 | { | 349 | { |
348 | if ( isUpdatesEnabled() ) | 350 | if ( isUpdatesEnabled() ) |
349 | relayoutPage(); | 351 | relayoutPage(); |
350 | } | 352 | } |
351 | 353 | ||
352 | void DateBookDay::getEvents() | 354 | void DateBookDay::getEvents() |
353 | { | 355 | { |
354 | widgetList.clear(); | 356 | widgetList.clear(); |
355 | 357 | ||
356 | /* clear the AllDay List */ | 358 | /* clear the AllDay List */ |
357 | m_allDays->hide(); // just in case | 359 | m_allDays->hide(); // just in case |
358 | m_allDays->removeAllEvents(); | 360 | m_allDays->removeAllEvents(); |
359 | 361 | ||
360 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); | 362 | QStringList hdays = _holiday_db->holidaylist(currDate); |
361 | QValueListIterator<EffectiveEvent> it; | 363 | QStringList::Iterator sit; |
362 | QObject* object = 0; | 364 | QObject* object = 0; |
363 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { | 365 | for (sit=hdays.begin();sit!=hdays.end();++sit) { |
364 | EffectiveEvent ev=*it; | 366 | object = m_allDays->addHoliday(*sit); |
365 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. | 367 | if (!object) continue; |
368 | /* not to do something with it */ | ||
369 | } | ||
370 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); | ||
371 | QValueListIterator<EffectiveEvent> it; | ||
372 | |||
373 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { | ||
374 | EffectiveEvent ev=*it; | ||
375 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) { // Skip events ending at 00:00 starting at another day. | ||
366 | if (ev.event().type() == Event::AllDay ) { | 376 | if (ev.event().type() == Event::AllDay ) { |
367 | object = m_allDays->addEvent( ev ); | 377 | object = m_allDays->addEvent( ev ); |
368 | if (!object) | 378 | if (!object) |
369 | continue; | 379 | continue; |
370 | }else { | 380 | }else { |
371 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); | 381 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); |
372 | widgetList.append( w ); | 382 | widgetList.append( w ); |
373 | object = w; | 383 | object = w; |
374 | } | 384 | } |
375 | 385 | ||
376 | connect( object, SIGNAL( deleteMe(const Event&) ), this, SIGNAL( removeEvent(const Event&) ) ); | 386 | connect( object, SIGNAL( deleteMe(const Event&) ), this, SIGNAL( removeEvent(const Event&) ) ); |
377 | connect( object, SIGNAL( duplicateMe(const Event&) ), this, SIGNAL( duplicateEvent(const Event&) ) ); | 387 | connect( object, SIGNAL( duplicateMe(const Event&) ), this, SIGNAL( duplicateEvent(const Event&) ) ); |
378 | connect( object, SIGNAL( editMe(const Event&) ), this, SIGNAL( editEvent(const Event&) ) ); | 388 | connect( object, SIGNAL( editMe(const Event&) ), this, SIGNAL( editEvent(const Event&) ) ); |
379 | connect( object, SIGNAL( beamMe(const Event&) ), this, SIGNAL( beamEvent(const Event&) ) ); | 389 | connect( object, SIGNAL( beamMe(const Event&) ), this, SIGNAL( beamEvent(const Event&) ) ); |
380 | 390 | ||
381 | } | 391 | } |
382 | } | 392 | } |
383 | } | 393 | } |
384 | 394 | ||
385 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) | 395 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) |
386 | { | 396 | { |
387 | int place = 0; | 397 | int place = 0; |
388 | int start = item->event().start().hour(); | 398 | int start = item->event().start().hour(); |
389 | QTime e = item->event().end(); | 399 | QTime e = item->event().end(); |
390 | int end = e.hour(); | 400 | int end = e.hour(); |
391 | if ( e.minute() < 5 ) | 401 | if ( e.minute() < 5 ) |
392 | end--; | 402 | end--; |
393 | if ( end < start ) | 403 | if ( end < start ) |
394 | end = start; | 404 | end = start; |
395 | while ( place < maxn ) { | 405 | while ( place < maxn ) { |
396 | bool free = TRUE; | 406 | bool free = TRUE; |
397 | int s = start; | 407 | int s = start; |
398 | while( s <= end ) { | 408 | while( s <= end ) { |
399 | if ( used[10*s+place] ) { | 409 | if ( used[10*s+place] ) { |
400 | free = FALSE; | 410 | free = FALSE; |
401 | break; | 411 | break; |
402 | } | 412 | } |
403 | s++; | 413 | s++; |
404 | } | 414 | } |
405 | if ( free ) | 415 | if ( free ) |
406 | break; | 416 | break; |
407 | place++; | 417 | place++; |
408 | } | 418 | } |
409 | if ( place == maxn ) { | 419 | if ( place == maxn ) { |
410 | return -1; | 420 | return -1; |
411 | } | 421 | } |
412 | while( start <= end ) { | 422 | while( start <= end ) { |
413 | used[10*start+place] = TRUE; | 423 | used[10*start+place] = TRUE; |
414 | start++; | 424 | start++; |
415 | } | 425 | } |
416 | return place; | 426 | return place; |
417 | } | 427 | } |
418 | 428 | ||
419 | 429 | ||
420 | void DateBookDay::relayoutPage( bool fromResize ) | 430 | void DateBookDay::relayoutPage( bool fromResize ) |
421 | { | 431 | { |
422 | setUpdatesEnabled( FALSE ); | 432 | setUpdatesEnabled( FALSE ); |
423 | if ( !fromResize ) { | 433 | if ( !fromResize ) { |
424 | getEvents(); // no need we already have them! | 434 | getEvents(); // no need we already have them! |
425 | 435 | ||
426 | if (m_allDays->items() > 0 ) | 436 | if (m_allDays->items() > 0 ) |
427 | m_allDays->show(); | 437 | m_allDays->show(); |
428 | /* | 438 | /* |
429 | * else if ( m_allDays->items() == 0 ) already hide in getEvents | 439 | * else if ( m_allDays->items() == 0 ) already hide in getEvents |
430 | */ | 440 | */ |
431 | } | 441 | } |
432 | 442 | ||
433 | widgetList.sort(); | 443 | widgetList.sort(); |
434 | //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning | 444 | //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning |
435 | //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view | 445 | //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view |
436 | 446 | ||
437 | int wCount = widgetList.count(); | 447 | int wCount = widgetList.count(); |
438 | int wid = view->columnWidth(0)-1; | 448 | int wid = view->columnWidth(0)-1; |
439 | int wd; | 449 | int wd; |
440 | int n = 1; | 450 | int n = 1; |
441 | 451 | ||
442 | QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget | 452 | QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget |
443 | 453 | ||
444 | for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); | 454 | for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); |
445 | 455 | ||
446 | if ( wCount < 20 ) { | 456 | if ( wCount < 20 ) { |
447 | 457 | ||
448 | QArray<QRect> geometries(wCount); | 458 | QArray<QRect> geometries(wCount); |
449 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector | 459 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++); //stores geometry for each widget in vector |
450 | 460 | ||
451 | for ( int i = 0; i < wCount; i++) { | 461 | for ( int i = 0; i < wCount; i++) { |
452 | QValueList<int> intersectedWidgets; | 462 | QValueList<int> intersectedWidgets; |
453 | 463 | ||
454 | //find all widgets intersecting with widgetList.at(i) | 464 | //find all widgets intersecting with widgetList.at(i) |
455 | for ( int j = 0; j < wCount; j++) { | 465 | for ( int j = 0; j < wCount; j++) { |
456 | if (i != j) | 466 | if (i != j) |
457 | if (geometries[j].intersects(geometries[i])) | 467 | if (geometries[j].intersects(geometries[i])) |
458 | intersectedWidgets.append(j); | 468 | intersectedWidgets.append(j); |
459 | } | 469 | } |
460 | 470 | ||
461 | //for each of these intersecting widgets find out how many widgets are they intersecting with | 471 | //for each of these intersecting widgets find out how many widgets are they intersecting with |
462 | for ( uint j = 0; j < intersectedWidgets.count(); j++) | 472 | for ( uint j = 0; j < intersectedWidgets.count(); j++) |
463 | { | 473 | { |
464 | QArray<int> inter(wCount); | 474 | QArray<int> inter(wCount); |
465 | inter[j]=1; | 475 | inter[j]=1; |
466 | 476 | ||
467 | if (intersectedWidgets[j] != -1) | 477 | if (intersectedWidgets[j] != -1) |
468 | for ( uint k = j; k < intersectedWidgets.count(); k++) { | 478 | for ( uint k = j; k < intersectedWidgets.count(); k++) { |
469 | if (j != k && intersectedWidgets[k] != -1) | 479 | if (j != k && intersectedWidgets[k] != -1) |
470 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { | 480 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { |
471 | inter[j]++; | 481 | inter[j]++; |
472 | intersectedWidgets[k] = -1; | 482 | intersectedWidgets[k] = -1; |
473 | } | 483 | } |
474 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; | 484 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; |
475 | } | 485 | } |
476 | } | 486 | } |
477 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; | 487 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; |
478 | } | 488 | } |
479 | 489 | ||
480 | 490 | ||
481 | for ( int i = 0; i < wCount; i++) { | 491 | for ( int i = 0; i < wCount; i++) { |
482 | DateBookDayWidget *w = widgetList.at(i); | 492 | DateBookDayWidget *w = widgetList.at(i); |
483 | QRect geom = w->geometry(); | 493 | QRect geom = w->geometry(); |
484 | geom.setX( 0 ); | 494 | geom.setX( 0 ); |
485 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); | 495 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); |
486 | geom.setWidth( wd ); | 496 | geom.setWidth( wd ); |
487 | while ( intersects( w, geom ) ) { | 497 | while ( intersects( w, geom ) ) { |
488 | geom.moveBy( wd + 2 + 1, 0 ); | 498 | geom.moveBy( wd + 2 + 1, 0 ); |
489 | } | 499 | } |
490 | w->setGeometry( geom ); | 500 | w->setGeometry( geom ); |
491 | } | 501 | } |
492 | 502 | ||
493 | if (jumpToCurTime && this->date() == QDate::currentDate()) { | 503 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
494 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 504 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
495 | } else { | 505 | } else { |
496 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 506 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
497 | } | 507 | } |
498 | } else { | 508 | } else { |
499 | int hours[24]; | 509 | int hours[24]; |
500 | memset( hours, 0, 24*sizeof( int ) ); | 510 | memset( hours, 0, 24*sizeof( int ) ); |
501 | bool overFlow = FALSE; | 511 | bool overFlow = FALSE; |
502 | for ( int i = 0; i < wCount; i++ ) { | 512 | for ( int i = 0; i < wCount; i++ ) { |
503 | DateBookDayWidget *w = widgetList.at(i); | 513 | DateBookDayWidget *w = widgetList.at(i); |
504 | int start = w->event().start().hour(); | 514 | int start = w->event().start().hour(); |
505 | QTime e = w->event().end(); | 515 | QTime e = w->event().end(); |
506 | int end = e.hour(); | 516 | int end = e.hour(); |
507 | if ( e.minute() < 5 ) | 517 | if ( e.minute() < 5 ) |
508 | end--; | 518 | end--; |
509 | if ( end < start ) | 519 | if ( end < start ) |
510 | end = start; | 520 | end = start; |
511 | while( start <= end ) { | 521 | while( start <= end ) { |
512 | hours[start]++; | 522 | hours[start]++; |
513 | if ( hours[start] >= 10 ) | 523 | if ( hours[start] >= 10 ) |
514 | overFlow = TRUE; | 524 | overFlow = TRUE; |
515 | ++start; | 525 | ++start; |
516 | } | 526 | } |
517 | if ( overFlow ) | 527 | if ( overFlow ) |
518 | break; | 528 | break; |
519 | } | 529 | } |
520 | for ( int i = 0; i < 24; i++ ) { | 530 | for ( int i = 0; i < 24; i++ ) { |
521 | n = QMAX( n, hours[i] ); | 531 | n = QMAX( n, hours[i] ); |
522 | } | 532 | } |
523 | wid = ( view->columnWidth(0)-1 ) / n; | 533 | wid = ( view->columnWidth(0)-1 ) / n; |
524 | 534 | ||
525 | bool used[24*10]; | 535 | bool used[24*10]; |
526 | memset( used, FALSE, 24*10*sizeof( bool ) ); | 536 | memset( used, FALSE, 24*10*sizeof( bool ) ); |
527 | 537 | ||
528 | for ( int i = 0; i < wCount; i++ ) { | 538 | for ( int i = 0; i < wCount; i++ ) { |
529 | DateBookDayWidget *w = widgetList.at(i); | 539 | DateBookDayWidget *w = widgetList.at(i); |
530 | int xp = place( w, used, n ); | 540 | int xp = place( w, used, n ); |
531 | if ( xp != -1 ) { | 541 | if ( xp != -1 ) { |
532 | QRect geom = w->geometry(); | 542 | QRect geom = w->geometry(); |
533 | geom.setX( xp*(wid+2) ); | 543 | geom.setX( xp*(wid+2) ); |
534 | geom.setWidth( wid ); | 544 | geom.setWidth( wid ); |
535 | w->setGeometry( geom ); | 545 | w->setGeometry( geom ); |
536 | } | 546 | } |
537 | } | 547 | } |
538 | 548 | ||
539 | if (jumpToCurTime && this->date() == QDate::currentDate()) { | 549 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
540 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 550 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
541 | } else { | 551 | } else { |
542 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 552 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
543 | } | 553 | } |
544 | } | 554 | } |
545 | 555 | ||
546 | timeMarker->setTime( QTime::currentTime() );//display timeMarker | 556 | timeMarker->setTime( QTime::currentTime() ); //display timeMarker |
547 | timeMarker->raise(); //on top of all widgets | 557 | timeMarker->raise(); //on top of all widgets |
548 | if (this->date() == QDate::currentDate()) { //only show timeMarker on current day | 558 | if (this->date() == QDate::currentDate()) { //only show timeMarker on current day |
549 | timeMarker->show(); | 559 | timeMarker->show(); |
550 | } else { | 560 | } else { |
551 | timeMarker->hide(); | 561 | timeMarker->hide(); |
552 | } | 562 | } |
553 | setUpdatesEnabled( TRUE ); | 563 | setUpdatesEnabled( TRUE ); |
554 | return; | 564 | return; |
555 | } | 565 | } |
556 | 566 | ||
557 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) | 567 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) |
558 | { | 568 | { |
559 | int i = 0; | 569 | int i = 0; |
560 | DateBookDayWidget *w = widgetList.at(i); | 570 | DateBookDayWidget *w = widgetList.at(i); |
561 | int wCount = widgetList.count(); | 571 | int wCount = widgetList.count(); |
562 | while ( i < wCount && w != item ) { | 572 | while ( i < wCount && w != item ) { |
563 | if ( w->geometry().intersects( geom ) ) { | 573 | if ( w->geometry().intersects( geom ) ) { |
564 | return w; | 574 | return w; |
565 | } | 575 | } |
566 | w = widgetList.at(++i); | 576 | w = widgetList.at(++i); |
567 | } | 577 | } |
568 | 578 | ||
569 | return 0; | 579 | return 0; |
570 | } | 580 | } |
571 | 581 | ||
572 | 582 | ||
573 | QDate DateBookDay::date() const | 583 | QDate DateBookDay::date() const |
574 | { | 584 | { |
575 | return currDate; | 585 | return currDate; |
576 | } | 586 | } |
577 | 587 | ||
578 | void DateBookDay::setStartViewTime( int startHere ) | 588 | void DateBookDay::setStartViewTime( int startHere ) |
579 | { | 589 | { |
580 | startTime = startHere; | 590 | startTime = startHere; |
581 | dayView()->clearSelection(); | 591 | dayView()->clearSelection(); |
582 | QTableSelection ts; | 592 | QTableSelection ts; |
583 | 593 | ||
584 | if (jumpToCurTime && this->date() == QDate::currentDate()) {//this should probably be in datebook.cpp where it's called? | 594 | if (jumpToCurTime && this->date() == QDate::currentDate()) { //this should probably be in datebook.cpp where it's called? |
585 | ts.init( QTime::currentTime().hour(), 0); | 595 | ts.init( QTime::currentTime().hour(), 0); |
586 | ts.expandTo( QTime::currentTime().hour(), 0); | 596 | ts.expandTo( QTime::currentTime().hour(), 0); |
587 | } else { | 597 | } else { |
588 | ts.init( startTime, 0 ); | 598 | ts.init( startTime, 0 ); |
589 | ts.expandTo( startTime, 0 ); | 599 | ts.expandTo( startTime, 0 ); |
590 | } | 600 | } |
591 | 601 | ||
592 | dayView()->addSelection( ts ); | 602 | dayView()->addSelection( ts ); |
593 | } | 603 | } |
594 | 604 | ||
595 | int DateBookDay::startViewTime() const | 605 | int DateBookDay::startViewTime() const |
596 | { | 606 | { |
597 | return startTime; | 607 | return startTime; |
598 | } | 608 | } |
599 | 609 | ||
600 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) | 610 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) |
601 | { | 611 | { |
602 | header->setStartOfWeek( bStartOnMonday ); | 612 | header->setStartOfWeek( bStartOnMonday ); |
603 | //redraw(); | 613 | // redraw(); |
604 | } | 614 | } |
605 | 615 | ||
606 | void DateBookDay::keyPressEvent(QKeyEvent *e) | 616 | void DateBookDay::keyPressEvent(QKeyEvent *e) |
607 | { | 617 | { |
608 | switch(e->key()) { | 618 | switch(e->key()) { |
609 | case Key_Up: | 619 | case Key_Up: |
610 | view->moveUp(); | 620 | view->moveUp(); |
611 | break; | 621 | break; |
612 | case Key_Down: | 622 | case Key_Down: |
613 | view->moveDown(); | 623 | view->moveDown(); |
614 | break; | 624 | break; |
615 | case Key_Left: | 625 | case Key_Left: |
616 | setDate(QDate(currDate).addDays(-1)); | 626 | setDate(QDate(currDate).addDays(-1)); |
617 | break; | 627 | break; |
618 | case Key_Right: | 628 | case Key_Right: |
619 | setDate(QDate(currDate).addDays(1)); | 629 | setDate(QDate(currDate).addDays(1)); |
620 | break; | 630 | break; |
621 | default: | 631 | default: |
622 | e->ignore(); | 632 | e->ignore(); |
623 | } | 633 | } |
624 | } | 634 | } |
625 | 635 | ||
626 | //=========================================================================== | 636 | //=========================================================================== |
627 | 637 | ||
628 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) | 638 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) |
629 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) | 639 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) |
630 | { | 640 | { |
631 | // why would someone use "<"? Oh well, fix it up... | 641 | // why would someone use "<"? Oh well, fix it up... |
632 | // I wonder what other things may be messed up... | 642 | // I wonder what other things may be messed up... |
633 | QString strDesc = ev.description(); | 643 | QString strDesc = ev.description(); |
634 | int where = strDesc.find( "<" ); | 644 | int where = strDesc.find( "<" ); |
635 | while ( where != -1 ) { | 645 | while ( where != -1 ) { |
636 | strDesc.remove( where, 1 ); | 646 | strDesc.remove( where, 1 ); |
637 | strDesc.insert( where, "<" ); | 647 | strDesc.insert( where, "<" ); |
638 | where = strDesc.find( "<", where ); | 648 | where = strDesc.find( "<", where ); |
639 | } | 649 | } |
640 | 650 | ||
641 | QString strCat; | 651 | QString strCat; |
642 | // ### Fix later... | 652 | // ### Fix later... |
643 | // QString strCat = ev.category(); | 653 | // QString strCat = ev.category(); |
644 | // where = strCat.find( "<" ); | 654 | // where = strCat.find( "<" ); |
645 | // while ( where != -1 ) { | 655 | // while ( where != -1 ) { |
646 | // strCat.remove( where, 1 ); | 656 | // strCat.remove( where, 1 ); |
647 | // strCat.insert( where, "<" ); | 657 | // strCat.insert( where, "<" ); |
648 | // where = strCat.find( "<", where ); | 658 | // where = strCat.find( "<", where ); |
649 | // } | 659 | // } |
650 | 660 | ||
651 | QString strNote = ev.notes(); | 661 | QString strNote = ev.notes(); |
652 | where = strNote.find( "<" ); | 662 | where = strNote.find( "<" ); |
653 | while ( where != -1 ) { | 663 | while ( where != -1 ) { |
654 | strNote.remove( where, 1 ); | 664 | strNote.remove( where, 1 ); |
655 | strNote.insert( where, "<" ); | 665 | strNote.insert( where, "<" ); |
656 | where = strNote.find( "<", where ); | 666 | where = strNote.find( "<", where ); |
657 | } | 667 | } |
658 | 668 | ||
659 | text = "<b>" + strDesc + "</b><br>" + "<i>"; | 669 | text = "<b>" + strDesc + "</b><br>" + "<i>"; |
660 | if ( !strCat.isEmpty() ) { | 670 | if ( !strCat.isEmpty() ) { |
661 | text += strCat + "</i><br>"; | 671 | text += strCat + "</i><br>"; |
662 | } | 672 | } |
663 | if (ev.event().type() == Event::Normal ) { | 673 | if (ev.event().type() == Event::Normal ) { |
664 | setEventText( text ); | 674 | setEventText( text ); |
665 | } else { | 675 | } else { |
666 | setAllDayText( text ); | 676 | setAllDayText( text ); |
667 | } | 677 | } |
668 | 678 | ||
669 | text += "<br><br>" + strNote; | 679 | text += "<br><br>" + strNote; |
670 | 680 | ||
671 | setBackgroundMode( PaletteBase ); | 681 | setBackgroundMode( PaletteBase ); |
672 | 682 | ||
673 | QTime start = ev.start(); | 683 | QTime start = ev.start(); |
674 | QTime end = ev.end(); | 684 | QTime end = ev.end(); |
675 | int y = start.hour()*60+start.minute(); | 685 | int y = start.hour()*60+start.minute(); |
676 | int h = end.hour()*60+end.minute()-y; | 686 | int h = end.hour()*60+end.minute()-y; |
677 | int rh = dateBook->dayView()->rowHeight(0); | 687 | int rh = dateBook->dayView()->rowHeight(0); |
678 | y = y*rh/60; | 688 | y = y*rh/60; |
679 | h = h*rh/60; | 689 | h = h*rh/60; |
680 | 690 | ||
681 | 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. | 691 | 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. |
682 | if ( y > ((24*rh)-12) ) y=(24*rh)-12;// Make sure the widget fits inside the dayview. | 692 | if ( y > ((24*rh)-12) ) y=(24*rh)-12; // Make sure the widget fits inside the dayview. |
683 | geom.setY( y ); | 693 | geom.setY( y ); |
684 | geom.setHeight( h ); | 694 | geom.setHeight( h ); |
685 | geom.setX( 0 ); | 695 | geom.setX( 0 ); |
686 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); | 696 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); |
687 | 697 | ||
688 | } | 698 | } |
689 | 699 | ||
690 | void DateBookDayWidget::setAllDayText( QString &text ) { | 700 | void DateBookDayWidget::setAllDayText( QString &text ) { |
691 | text += "<b>" + tr("This is an all day event.") + "</b>"; | 701 | text += "<b>" + tr("This is an all day event.") + "</b>"; |
692 | } | 702 | } |
693 | 703 | ||
694 | void DateBookDayWidget::setEventText( QString& text ) { | 704 | void DateBookDayWidget::setEventText( QString& text ) { |
695 | bool whichClock = dateBook->dayView()->whichClock(); | 705 | bool whichClock = dateBook->dayView()->whichClock(); |
696 | if ( ev.startDate() != ev.endDate() ) { | 706 | if ( ev.startDate() != ev.endDate() ) { |
697 | text += "<b>" + tr("Start") + "</b>: "; | 707 | text += "<b>" + tr("Start") + "</b>: "; |
698 | text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); | 708 | text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); |
699 | text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; | 709 | text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; |
700 | text += "<b>" + tr("End") + "</b>: "; | 710 | text += "<b>" + tr("End") + "</b>: "; |
701 | text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); | 711 | text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); |
702 | text += " - " + TimeString::longDateString( ev.endDate() ); | 712 | text += " - " + TimeString::longDateString( ev.endDate() ); |
703 | } else { | 713 | } else { |
704 | text += "<b>" + tr("Time") + "</b>: "; | 714 | text += "<b>" + tr("Time") + "</b>: "; |
705 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); | 715 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); |
706 | text += "<b>" + tr(" - ") + "</b>"; | 716 | text += "<b>" + tr(" - ") + "</b>"; |
707 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); | 717 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); |
708 | } | 718 | } |
709 | } | 719 | } |
710 | 720 | ||
711 | DateBookDayWidget::~DateBookDayWidget() | 721 | DateBookDayWidget::~DateBookDayWidget() |
712 | { | 722 | { |
713 | } | 723 | } |
714 | 724 | ||
715 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) | 725 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) |
716 | { | 726 | { |
717 | QPainter p( this ); | 727 | QPainter p( this ); |
718 | 728 | ||
719 | if (dateBook->getSelectedWidget() == this) { | 729 | if (dateBook->getSelectedWidget() == this) { |
720 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item | 730 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item |
721 | } else { | 731 | } else { |
722 | if (dateBook->date() == QDate::currentDate()) { | 732 | if (dateBook->date() == QDate::currentDate()) { |
723 | QTime curTime = QTime::currentTime(); | 733 | QTime curTime = QTime::currentTime(); |
724 | if (ev.end() < curTime) { | 734 | if (ev.end() < curTime) { |
725 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive | 735 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive |
726 | } else { | 736 | } else { |
727 | //change color in dependence of the time till the event starts | 737 | //change color in dependence of the time till the event starts |
728 | int duration = curTime.secsTo(ev.start()); | 738 | int duration = curTime.secsTo(ev.start()); |
729 | if (duration < 0) duration = 0; | 739 | if (duration < 0) duration = 0; |
730 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift | 740 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift |
731 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue | 741 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue |
732 | } | 742 | } |
733 | } else { | 743 | } else { |
734 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) | 744 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) |
735 | //perhaps make a distinction between future/past dates | 745 | //perhaps make a distinction between future/past dates |
736 | } | 746 | } |
737 | } | 747 | } |
738 | 748 | ||
739 | p.setPen( QColor(100, 100, 100) ); | 749 | p.setPen( QColor(100, 100, 100) ); |
740 | p.drawRect(rect()); | 750 | p.drawRect(rect()); |
741 | 751 | ||
742 | // p.drawRect(0,0, 5, height()); | 752 | // p.drawRect(0,0, 5, height()); |
743 | 753 | ||
744 | int y = 0; | 754 | int y = 0; |
745 | int d = 0; | 755 | int d = 0; |
746 | 756 | ||
747 | if ( ev.event().hasAlarm() ) { | 757 | if ( ev.event().hasAlarm() ) { |
748 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); | 758 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); |
749 | y = 20; | 759 | y = 20; |
750 | d = 20; | 760 | d = 20; |
751 | } | 761 | } |
752 | 762 | ||
753 | if ( ev.event().hasRepeat() ) { | 763 | if ( ev.event().hasRepeat() ) { |
754 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); | 764 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); |
755 | d = 20; | 765 | d = 20; |
756 | y += 20; | 766 | y += 20; |
757 | } | 767 | } |
758 | 768 | ||
759 | QSimpleRichText rt( text, font() ); | 769 | QSimpleRichText rt( text, font() ); |
760 | rt.setWidth( geom.width() - d - 6 ); | 770 | rt.setWidth( geom.width() - d - 6 ); |
761 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); | 771 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); |
762 | } | 772 | } |
763 | 773 | ||
764 | /* | 774 | /* |
765 | * we need to find the real start date for a uid | 775 | * we need to find the real start date for a uid |
766 | * we need to check from one day to another... | 776 | * we need to check from one day to another... |
767 | */ | 777 | */ |
768 | QDate DateBookDay::findRealStart( int uid, const QDate& isIncluded , DateBookDB* db) { | 778 | QDate DateBookDay::findRealStart( int uid, const QDate& isIncluded , DateBookDB* db) { |
769 | QDate dt( isIncluded ); | 779 | QDate dt( isIncluded ); |
770 | QDate fnd = dt; | 780 | QDate fnd = dt; |
771 | 781 | ||
772 | bool doAgain = true; | 782 | bool doAgain = true; |
773 | do{ | 783 | do{ |
774 | dt = dt.addDays( -1 ); | 784 | dt = dt.addDays( -1 ); |
775 | QValueList<EffectiveEvent> events = db->getEffectiveEvents( dt, dt ); | 785 | QValueList<EffectiveEvent> events = db->getEffectiveEvents( dt, dt ); |
776 | for (QValueList<EffectiveEvent>::Iterator it = events.begin(); it != events.end(); ++it ) { | 786 | for (QValueList<EffectiveEvent>::Iterator it = events.begin(); it != events.end(); ++it ) { |
777 | EffectiveEvent ev = (*it); | 787 | EffectiveEvent ev = (*it); |
778 | if ( uid == ev.event().uid() && ev.start() != QTime(0, 0, 0 ) ) | 788 | if ( uid == ev.event().uid() && ev.start() != QTime(0, 0, 0 ) ) |
779 | return ev.date(); | 789 | return ev.date(); |
780 | } | 790 | } |
781 | }while (doAgain ); | 791 | }while (doAgain ); |
782 | 792 | ||
783 | return fnd; | 793 | return fnd; |
784 | } | 794 | } |
785 | 795 | ||
786 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) | 796 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) |
787 | { | 797 | { |
788 | DateBookDayWidget *item; | 798 | DateBookDayWidget *item; |
789 | 799 | ||
790 | item = dateBook->getSelectedWidget(); | 800 | item = dateBook->getSelectedWidget(); |
791 | if (item) | 801 | if (item) |
792 | item->update(); | 802 | item->update(); |
793 | 803 | ||
794 | dateBook->setSelectedWidget(this); | 804 | dateBook->setSelectedWidget(this); |
795 | update(); | 805 | update(); |
796 | dateBook->repaint(); | 806 | dateBook->repaint(); |
797 | 807 | ||
798 | Event eve = ev.event(); | 808 | Event eve = ev.event(); |
799 | 809 | ||
800 | QPopupMenu m; | 810 | QPopupMenu m; |
801 | m.insertItem( tr( "Edit" ), 1 ); | 811 | m.insertItem( tr( "Edit" ), 1 ); |
802 | m.insertItem( tr( "Duplicate" ), 4 ); | 812 | m.insertItem( tr( "Duplicate" ), 4 ); |
803 | m.insertItem( tr( "Delete" ), 2 ); | 813 | m.insertItem( tr( "Delete" ), 2 ); |
804 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); | 814 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); |
805 | if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 ); | 815 | if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 ); |
806 | int r = m.exec( e->globalPos() ); | 816 | int r = m.exec( e->globalPos() ); |
807 | if ( r == 1 ) { | 817 | if ( r == 1 ) { |
808 | emit editMe( eve ); | 818 | emit editMe( eve ); |
809 | } else if ( r == 2 ) { | 819 | } else if ( r == 2 ) { |
810 | emit deleteMe( eve ); | 820 | emit deleteMe( eve ); |
811 | } else if ( r == 3 ) { | 821 | } else if ( r == 3 ) { |
812 | emit beamMe( eve ); | 822 | emit beamMe( eve ); |
813 | } else if ( r == 4 ) { | 823 | } else if ( r == 4 ) { |
814 | emit duplicateMe( eve ); | 824 | emit duplicateMe( eve ); |
815 | } else if ( r == 5 ) { | 825 | } else if ( r == 5 ) { |
816 | // create an Event and beam it... | 826 | // create an Event and beam it... |
817 | /* | 827 | /* |
818 | * Start with the easy stuff. If start and end date is the same we can just use | 828 | * Start with the easy stuff. If start and end date is the same we can just use |
819 | * the values of effective events | 829 | * the values of effective events |
820 | * If it is a multi day event we need to find the real start and end date... | 830 | * If it is a multi day event we need to find the real start and end date... |
821 | */ | 831 | */ |
822 | if ( ev.event().start().date() == ev.event().end().date() ) { | 832 | if ( ev.event().start().date() == ev.event().end().date() ) { |
823 | Event event( ev.event() ); | 833 | Event event( ev.event() ); |
824 | 834 | ||
825 | QDateTime dt( ev.date(), ev.start() ); | 835 | QDateTime dt( ev.date(), ev.start() ); |
826 | event.setStart( dt ); | 836 | event.setStart( dt ); |
827 | 837 | ||
828 | dt.setTime( ev.end() ); | 838 | dt.setTime( ev.end() ); |
829 | event.setEnd( dt ); | 839 | event.setEnd( dt ); |
830 | emit beamMe( event ); | 840 | emit beamMe( event ); |
831 | }else { | 841 | }else { |
832 | /* | 842 | /* |
833 | * at least the the Times are right now | 843 | * at least the the Times are right now |
834 | */ | 844 | */ |
835 | QDateTime start( ev.event().start() ); | 845 | QDateTime start( ev.event().start() ); |
836 | QDateTime end ( ev.event().end () ); | 846 | QDateTime end ( ev.event().end () ); |
837 | 847 | ||
838 | 848 | ||
839 | /* | 849 | /* |
840 | * ok we know the start date or we need to find it | 850 | * ok we know the start date or we need to find it |
841 | */ | 851 | */ |
842 | if ( ev.start() != QTime( 0, 0, 0 ) ) { | 852 | if ( ev.start() != QTime( 0, 0, 0 ) ) { |
843 | start.setDate( ev.date() ); | 853 | start.setDate( ev.date() ); |
844 | }else { | 854 | }else { |
845 | QDate dt = DateBookDay::findRealStart( ev.event().uid(), ev.date(), dateBook->db ); | 855 | QDate dt = DateBookDay::findRealStart( ev.event().uid(), ev.date(), dateBook->db ); |
846 | start.setDate( dt ); | 856 | start.setDate( dt ); |
847 | } | 857 | } |
848 | 858 | ||
849 | 859 | ||
850 | /* | 860 | /* |
851 | * ok we know now the end date... | 861 | * ok we know now the end date... |
852 | * else | 862 | * else |
853 | * get to know the offset btw the real start and real end | 863 | * get to know the offset btw the real start and real end |
854 | * and then add it to the new start date... | 864 | * and then add it to the new start date... |
855 | */ | 865 | */ |
856 | if ( ev.end() != QTime(23, 59, 59 ) ) { | 866 | if ( ev.end() != QTime(23, 59, 59 ) ) { |
857 | end.setDate( ev.date() ); | 867 | end.setDate( ev.date() ); |
858 | }else{ | 868 | }else{ |
859 | int days = ev.event().start().date().daysTo( ev.event().end().date() ); | 869 | int days = ev.event().start().date().daysTo( ev.event().end().date() ); |
860 | end.setDate( start.date().addDays( days ) ); | 870 | end.setDate( start.date().addDays( days ) ); |
861 | } | 871 | } |
862 | 872 | ||
863 | 873 | ||
864 | 874 | ||
865 | Event event( ev.event() ); | 875 | Event event( ev.event() ); |
866 | event.setStart( start ); | 876 | event.setStart( start ); |
867 | event.setEnd ( end ); | 877 | event.setEnd ( end ); |
868 | 878 | ||
869 | 879 | ||
870 | emit beamMe( event ); | 880 | emit beamMe( event ); |
871 | } | 881 | } |
872 | } | 882 | } |
873 | } | 883 | } |
874 | 884 | ||
875 | void DateBookDayWidget::setGeometry( const QRect &r ) | 885 | void DateBookDayWidget::setGeometry( const QRect &r ) |
876 | { | 886 | { |
877 | geom = r; | 887 | geom = r; |
878 | setFixedSize( r.width()+1, r.height()+1 ); | 888 | setFixedSize( r.width()+1, r.height()+1 ); |
879 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 889 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
880 | show(); | 890 | show(); |
881 | } | 891 | } |
882 | 892 | ||
883 | 893 | ||
884 | //--------------------------------------------------------------------------------------------- | 894 | //--------------------------------------------------------------------------------------------- |
885 | //--------------------------------------------------------------------------------------------- | 895 | //--------------------------------------------------------------------------------------------- |
886 | 896 | ||
887 | 897 | ||
888 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) | 898 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) |
889 | : QWidget( db->dayView()->viewport() ), dateBook( db ) | 899 | : QWidget( db->dayView()->viewport() ), dateBook( db ) |
890 | { | 900 | { |
891 | setBackgroundMode( PaletteBase ); | 901 | setBackgroundMode( PaletteBase ); |
892 | } | 902 | } |
893 | 903 | ||
894 | DateBookDayTimeMarker::~DateBookDayTimeMarker() | 904 | DateBookDayTimeMarker::~DateBookDayTimeMarker() |
895 | { | 905 | { |
896 | } | 906 | } |
897 | 907 | ||
898 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) | 908 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) |
899 | { | 909 | { |
900 | QPainter p( this ); | 910 | QPainter p( this ); |
901 | p.setBrush( QColor( 255, 0, 0 ) ); | 911 | p.setBrush( QColor( 255, 0, 0 ) ); |
902 | 912 | ||
903 | QPen pen; | 913 | QPen pen; |
904 | pen.setStyle(NoPen); | 914 | pen.setStyle(NoPen); |
905 | 915 | ||
906 | p.setPen( pen ); | 916 | p.setPen( pen ); |
907 | p.drawRect(rect()); | 917 | p.drawRect(rect()); |
908 | } | 918 | } |
909 | 919 | ||
910 | void DateBookDayTimeMarker::setTime( const QTime &t ) | 920 | void DateBookDayTimeMarker::setTime( const QTime &t ) |
911 | { | 921 | { |
912 | int y = t.hour()*60+t.minute(); | 922 | int y = t.hour()*60+t.minute(); |
913 | int rh = dateBook->dayView()->rowHeight(0); | 923 | int rh = dateBook->dayView()->rowHeight(0); |
914 | y = y*rh/60; | 924 | y = y*rh/60; |
915 | 925 | ||
916 | geom.setX( 0 ); | 926 | geom.setX( 0 ); |
917 | 927 | ||
918 | int x = dateBook->dayView()->columnWidth(0)-1; | 928 | int x = dateBook->dayView()->columnWidth(0)-1; |
919 | geom.setWidth( x ); | 929 | geom.setWidth( x ); |
920 | 930 | ||
921 | geom.setY( y ); | 931 | geom.setY( y ); |
922 | geom.setHeight( 1 ); | 932 | geom.setHeight( 1 ); |
923 | 933 | ||
924 | setGeometry( geom ); | 934 | setGeometry( geom ); |
925 | 935 | ||
926 | time = t; | 936 | time = t; |
927 | } | 937 | } |
928 | 938 | ||
929 | void DateBookDayTimeMarker::setGeometry( const QRect &r ) | 939 | void DateBookDayTimeMarker::setGeometry( const QRect &r ) |
930 | { | 940 | { |
931 | geom = r; | 941 | geom = r; |
932 | setFixedSize( r.width()+1, r.height()+1 ); | 942 | setFixedSize( r.width()+1, r.height()+1 ); |
933 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 943 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
934 | show(); | 944 | show(); |
935 | } | 945 | } |
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h index c8cb26b..3e44364 100644 --- a/core/pim/datebook/datebookday.h +++ b/core/pim/datebook/datebookday.h | |||
@@ -1,236 +1,238 @@ | |||
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 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef DATEBOOKDAY_H | 20 | #ifndef DATEBOOKDAY_H |
21 | #define DATEBOOKDAY_H | 21 | #define DATEBOOKDAY_H |
22 | 22 | ||
23 | #include <qpe/event.h> | 23 | #include <qpe/event.h> |
24 | 24 | ||
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qtable.h> | 26 | #include <qtable.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qlist.h> | 28 | #include <qlist.h> |
29 | 29 | ||
30 | #include "datebook.h" | 30 | #include "datebook.h" |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | 32 | ||
33 | class DateBookDayHeader; | 33 | class DateBookDayHeader; |
34 | class DateBookDB; | 34 | class DateBookDB; |
35 | class DatebookdayAllday; | 35 | class DatebookdayAllday; |
36 | class QDateTime; | 36 | class QDateTime; |
37 | class QMouseEvent; | 37 | class QMouseEvent; |
38 | class QPaintEvent; | 38 | class QPaintEvent; |
39 | class QResizeEvent; | 39 | class QResizeEvent; |
40 | 40 | ||
41 | class DateBookDayViewQuickLineEdit : public QLineEdit | 41 | class DateBookDayViewQuickLineEdit : public QLineEdit |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0); | 45 | DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0); |
46 | protected: | 46 | protected: |
47 | Event quickEvent; | 47 | Event quickEvent; |
48 | int active; | 48 | int active; |
49 | void focusOutEvent( QFocusEvent *e ); | 49 | void focusOutEvent( QFocusEvent *e ); |
50 | protected slots: | 50 | protected slots: |
51 | void slotReturnPressed(void); | 51 | void slotReturnPressed(void); |
52 | void finallyCallClose(); | 52 | void finallyCallClose(); |
53 | signals: | 53 | signals: |
54 | void insertEvent(const Event &e); | 54 | void insertEvent(const Event &e); |
55 | }; | 55 | }; |
56 | 56 | ||
57 | 57 | ||
58 | class DateBookDayView : public QTable | 58 | class DateBookDayView : public QTable |
59 | { | 59 | { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | public: | 61 | public: |
62 | DateBookDayView( bool hourClock, QWidget *parent, const char *name ); | 62 | DateBookDayView( bool hourClock, QWidget *parent, const char *name ); |
63 | bool whichClock() const; | 63 | bool whichClock() const; |
64 | 64 | ||
65 | void setRowStyle( int style ); | 65 | void setRowStyle( int style ); |
66 | 66 | ||
67 | public slots: | 67 | public slots: |
68 | void moveUp(); | 68 | void moveUp(); |
69 | void moveDown(); | 69 | void moveDown(); |
70 | void slotDateChanged( int year, int month, int day ); | 70 | void slotDateChanged( int year, int month, int day ); |
71 | 71 | ||
72 | signals: | 72 | signals: |
73 | void sigColWidthChanged(); | 73 | void sigColWidthChanged(); |
74 | void sigCapturedKey( const QString &txt ); | 74 | void sigCapturedKey( const QString &txt ); |
75 | protected slots: | 75 | protected slots: |
76 | void slotChangeClock( bool ); | 76 | void slotChangeClock( bool ); |
77 | protected: | 77 | protected: |
78 | virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); | 78 | virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); |
79 | virtual void paintFocus( QPainter *p, const QRect &cr ); | 79 | virtual void paintFocus( QPainter *p, const QRect &cr ); |
80 | 80 | ||
81 | virtual void resizeEvent( QResizeEvent *e ); | 81 | virtual void resizeEvent( QResizeEvent *e ); |
82 | void keyPressEvent( QKeyEvent *e ); | 82 | void keyPressEvent( QKeyEvent *e ); |
83 | void contentsMouseReleaseEvent( QMouseEvent *e ); | 83 | void contentsMouseReleaseEvent( QMouseEvent *e ); |
84 | void initHeader(); | 84 | void initHeader(); |
85 | private: | 85 | private: |
86 | bool ampm; | 86 | bool ampm; |
87 | QDate currDate; | 87 | QDate currDate; |
88 | DateBookDayViewQuickLineEdit *quickLineEdit; | 88 | DateBookDayViewQuickLineEdit *quickLineEdit; |
89 | }; | 89 | }; |
90 | 90 | ||
91 | class DateBookDay; | 91 | class DateBookDay; |
92 | class DateBookDayWidget : public QWidget | 92 | class DateBookDayWidget : public QWidget |
93 | { | 93 | { |
94 | Q_OBJECT | 94 | Q_OBJECT |
95 | 95 | ||
96 | public: | 96 | public: |
97 | DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ); | 97 | DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ); |
98 | ~DateBookDayWidget(); | 98 | ~DateBookDayWidget(); |
99 | 99 | ||
100 | const QRect &geometry() { return geom; } | 100 | const QRect &geometry() { return geom; } |
101 | void setGeometry( const QRect &r ); | 101 | void setGeometry( const QRect &r ); |
102 | 102 | ||
103 | const EffectiveEvent &event() const { return ev; } | 103 | const EffectiveEvent &event() const { return ev; } |
104 | 104 | ||
105 | signals: | 105 | signals: |
106 | void deleteMe( const Event &e ); | 106 | void deleteMe( const Event &e ); |
107 | void duplicateMe( const Event &e ); | 107 | void duplicateMe( const Event &e ); |
108 | void editMe( const Event &e ); | 108 | void editMe( const Event &e ); |
109 | void beamMe( const Event &e ); | 109 | void beamMe( const Event &e ); |
110 | 110 | ||
111 | protected: | 111 | protected: |
112 | void paintEvent( QPaintEvent *e ); | 112 | void paintEvent( QPaintEvent *e ); |
113 | void mousePressEvent( QMouseEvent *e ); | 113 | void mousePressEvent( QMouseEvent *e ); |
114 | 114 | ||
115 | private: | 115 | private: |
116 | /** | 116 | /** |
117 | * Sets the text for an all day Event | 117 | * Sets the text for an all day Event |
118 | * All day events have no time associated | 118 | * All day events have no time associated |
119 | */ | 119 | */ |
120 | void setAllDayText( QString& text ); | 120 | void setAllDayText( QString& text ); |
121 | 121 | ||
122 | /** | 122 | /** |
123 | * Sets the EventText | 123 | * Sets the EventText |
124 | * it got a start and an end Time | 124 | * it got a start and an end Time |
125 | */ | 125 | */ |
126 | void setEventText( QString& text ); | 126 | void setEventText( QString& text ); |
127 | EffectiveEvent ev; | 127 | EffectiveEvent ev; |
128 | DateBookDay *dateBook; | 128 | DateBookDay *dateBook; |
129 | QString text; | 129 | QString text; |
130 | QRect geom; | 130 | QRect geom; |
131 | }; | 131 | }; |
132 | 132 | ||
133 | //Marker for current time in the dayview | 133 | //Marker for current time in the dayview |
134 | class DateBookDayTimeMarker : public QWidget | 134 | class DateBookDayTimeMarker : public QWidget |
135 | { | 135 | { |
136 | Q_OBJECT | 136 | Q_OBJECT |
137 | 137 | ||
138 | public: | 138 | public: |
139 | DateBookDayTimeMarker( DateBookDay *db ); | 139 | DateBookDayTimeMarker( DateBookDay *db ); |
140 | ~DateBookDayTimeMarker(); | 140 | ~DateBookDayTimeMarker(); |
141 | 141 | ||
142 | const QRect &geometry() { return geom; } | 142 | const QRect &geometry() { return geom; } |
143 | void setGeometry( const QRect &r ); | 143 | void setGeometry( const QRect &r ); |
144 | void setTime( const QTime &t ); | 144 | void setTime( const QTime &t ); |
145 | 145 | ||
146 | signals: | 146 | signals: |
147 | 147 | ||
148 | protected: | 148 | protected: |
149 | void paintEvent( QPaintEvent *e ); | 149 | void paintEvent( QPaintEvent *e ); |
150 | 150 | ||
151 | private: | 151 | private: |
152 | QRect geom; | 152 | QRect geom; |
153 | QTime time; | 153 | QTime time; |
154 | DateBookDay *dateBook; | 154 | DateBookDay *dateBook; |
155 | }; | 155 | }; |
156 | 156 | ||
157 | //reimplemented the compareItems function so that it sorts DayWidgets by geometry heights | 157 | //reimplemented the compareItems function so that it sorts DayWidgets by geometry heights |
158 | class WidgetListClass : public QList<DateBookDayWidget> | 158 | class WidgetListClass : public QList<DateBookDayWidget> |
159 | { | 159 | { |
160 | private: | 160 | private: |
161 | 161 | ||
162 | int compareItems( QCollection::Item s1, QCollection::Item s2 ) | 162 | int compareItems( QCollection::Item s1, QCollection::Item s2 ) |
163 | { | 163 | { |
164 | //hmm, don't punish me for that ;) | 164 | //hmm, don't punish me for that ;) |
165 | if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height()) | 165 | if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height()) |
166 | { | 166 | { |
167 | return -1; | 167 | return -1; |
168 | } else | 168 | } else |
169 | { | 169 | { |
170 | return 1; | 170 | return 1; |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||
175 | }; | 175 | }; |
176 | 176 | ||
177 | class DateBookDay : public QVBox | 177 | class DateBookDay : public QVBox |
178 | { | 178 | { |
179 | Q_OBJECT | 179 | Q_OBJECT |
180 | 180 | ||
181 | friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB | 181 | friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB |
182 | public: | 182 | public: |
183 | DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, | 183 | DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb,DateBookHoliday*newHdb, |
184 | QWidget *parent, const char *name ); | 184 | QWidget *parent, const char *name ); |
185 | void selectedDates( QDateTime &start, QDateTime &end ); | 185 | void selectedDates( QDateTime &start, QDateTime &end ); |
186 | |||
186 | QDate date() const; | 187 | QDate date() const; |
187 | DateBookDayView *dayView() const { return view; } | 188 | DateBookDayView *dayView() const { return view; } |
188 | void setStartViewTime( int startHere ); | 189 | void setStartViewTime( int startHere ); |
189 | int startViewTime() const; | 190 | int startViewTime() const; |
190 | void setSelectedWidget( DateBookDayWidget * ); | 191 | void setSelectedWidget( DateBookDayWidget * ); |
191 | DateBookDayWidget * getSelectedWidget( void ); | 192 | DateBookDayWidget * getSelectedWidget( void ); |
192 | void setJumpToCurTime( bool bJump ); | 193 | void setJumpToCurTime( bool bJump ); |
193 | void setRowStyle( int style ); | 194 | void setRowStyle( int style ); |
194 | static QDate findRealStart( int uid, const QDate& isIncluded, | 195 | static QDate findRealStart( int uid, const QDate& isIncluded, |
195 | DateBookDB* ); | 196 | DateBookDB* ); |
196 | 197 | ||
197 | public slots: | 198 | public slots: |
198 | void setDate( int y, int m, int d ); | 199 | void setDate( int y, int m, int d ); |
199 | void setDate( QDate ); | 200 | void setDate( QDate ); |
200 | void redraw(); | 201 | void redraw(); |
201 | void slotWeekChanged( bool bStartOnMonday ); | 202 | void slotWeekChanged( bool bStartOnMonday ); |
202 | void updateView();//updates TimeMarker and DayWidget-colors | 203 | void updateView(); //updates TimeMarker and DayWidget-colors |
203 | 204 | ||
204 | signals: | 205 | signals: |
205 | void removeEvent( const Event& ); | 206 | void removeEvent( const Event& ); |
206 | void editEvent( const Event& ); | 207 | void editEvent( const Event& ); |
207 | void duplicateEvent( const Event& ); | 208 | void duplicateEvent( const Event& ); |
208 | void beamEvent( const Event& ); | 209 | void beamEvent( const Event& ); |
209 | void newEvent(); | 210 | void newEvent(); |
210 | void sigNewEvent( const QString & ); | 211 | void sigNewEvent( const QString & ); |
211 | 212 | ||
212 | protected slots: | 213 | protected slots: |
213 | void keyPressEvent(QKeyEvent *); | 214 | void keyPressEvent(QKeyEvent *); |
214 | 215 | ||
215 | private slots: | 216 | private slots: |
216 | void dateChanged( int y, int m, int d ); | 217 | void dateChanged( int y, int m, int d ); |
217 | void slotColWidthChanged() { relayoutPage(); }; | 218 | void slotColWidthChanged() { relayoutPage(); }; |
218 | 219 | ||
219 | private: | 220 | private: |
220 | void getEvents(); | 221 | void getEvents(); |
221 | void relayoutPage( bool fromResize = false ); | 222 | void relayoutPage( bool fromResize = false ); |
222 | DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom ); | 223 | DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom ); |
223 | QDate currDate; | 224 | QDate currDate; |
224 | DateBookDayView *view; | 225 | DateBookDayView *view; |
225 | DateBookDayHeader *header; | 226 | DateBookDayHeader *header; |
226 | DatebookdayAllday *m_allDays; | 227 | DatebookdayAllday *m_allDays; |
227 | DateBookDB *db; | 228 | DateBookDB *db; |
228 | WidgetListClass widgetList;//reimplemented QList for sorting widgets by height | 229 | WidgetListClass widgetList; //reimplemented QList for sorting widgets by height |
229 | int startTime; | 230 | int startTime; |
230 | bool jumpToCurTime;//should we jump to current time in dayview? | 231 | bool jumpToCurTime; //should we jump to current time in dayview? |
231 | int rowStyle; | 232 | int rowStyle; |
232 | DateBookDayWidget *selectedWidget; //actual selected widget (obviously) | 233 | DateBookDayWidget *selectedWidget; //actual selected widget (obviously) |
233 | DateBookDayTimeMarker *timeMarker;//marker for current time | 234 | DateBookDayTimeMarker *timeMarker; //marker for current time |
235 | DateBookHoliday*_holiday_db; | ||
234 | }; | 236 | }; |
235 | 237 | ||
236 | #endif | 238 | #endif |
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp index a0aefd3..3c3f482 100644 --- a/core/pim/datebook/datebookdayallday.cpp +++ b/core/pim/datebook/datebookdayallday.cpp | |||
@@ -21,186 +21,223 @@ | |||
21 | */ | 21 | */ |
22 | DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags ) | 22 | DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags ) |
23 | : QScrollView( parent, name ),item_count(0),dateBook(db) | 23 | : QScrollView( parent, name ),item_count(0),dateBook(db) |
24 | { | 24 | { |
25 | if ( !name ) | 25 | if ( !name ) |
26 | setName( "DatebookdayAllday" ); | 26 | setName( "DatebookdayAllday" ); |
27 | setMinimumSize( QSize( 0, 0 ) ); | 27 | setMinimumSize( QSize( 0, 0 ) ); |
28 | setMaximumHeight(3* (QFontMetrics(font()).height()+4) ); | 28 | setMaximumHeight(3* (QFontMetrics(font()).height()+4) ); |
29 | 29 | ||
30 | m_MainFrame = new QFrame(viewport()); | 30 | m_MainFrame = new QFrame(viewport()); |
31 | m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain); | 31 | m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain); |
32 | setFrameStyle(QFrame::NoFrame|QFrame::Plain); | 32 | setFrameStyle(QFrame::NoFrame|QFrame::Plain); |
33 | setResizePolicy( QScrollView::Default ); | 33 | setResizePolicy( QScrollView::Default ); |
34 | setHScrollBarMode( AlwaysOff ); | 34 | setHScrollBarMode( AlwaysOff ); |
35 | addChild(m_MainFrame); | 35 | addChild(m_MainFrame); |
36 | 36 | ||
37 | datebookdayalldayLayout = new QVBoxLayout( m_MainFrame ); | 37 | datebookdayalldayLayout = new QVBoxLayout( m_MainFrame ); |
38 | datebookdayalldayLayout->setSpacing( 0 ); | 38 | datebookdayalldayLayout->setSpacing( 0 ); |
39 | datebookdayalldayLayout->setMargin( 0 ); | 39 | datebookdayalldayLayout->setMargin( 0 ); |
40 | 40 | ||
41 | lblDesc = new DatebookEventDesc(parent->parentWidget(),""); | 41 | lblDesc = new DatebookEventDesc(parent->parentWidget(),""); |
42 | lblDesc->setBackgroundColor(Qt::yellow); | 42 | lblDesc->setBackgroundColor(Qt::yellow); |
43 | lblDesc->hide(); | 43 | lblDesc->hide(); |
44 | subWidgets.setAutoDelete(true); | 44 | subWidgets.setAutoDelete(true); |
45 | } | 45 | } |
46 | 46 | ||
47 | /* | 47 | /* |
48 | * Destroys the object and frees any allocated resources | 48 | * Destroys the object and frees any allocated resources |
49 | */ | 49 | */ |
50 | DatebookdayAllday::~DatebookdayAllday() | 50 | DatebookdayAllday::~DatebookdayAllday() |
51 | { | 51 | { |
52 | // no need to delete child widgets, Qt does it all for us | 52 | // no need to delete child widgets, Qt does it all for us |
53 | } | 53 | } |
54 | 54 | ||
55 | DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) | 55 | DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) |
56 | { | 56 | { |
57 | DatebookAlldayDisp * lb; | 57 | DatebookAlldayDisp * lb; |
58 | lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL); | 58 | lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL); |
59 | lb->show(); | 59 | lb->show(); |
60 | datebookdayalldayLayout->addWidget(lb); | 60 | datebookdayalldayLayout->addWidget(lb); |
61 | subWidgets.append(lb); | 61 | subWidgets.append(lb); |
62 | 62 | ||
63 | connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&))); | 63 | connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&))); |
64 | ++item_count; | 64 | ++item_count; |
65 | 65 | ||
66 | return lb; | 66 | return lb; |
67 | } | 67 | } |
68 | 68 | ||
69 | DatebookAlldayDisp* DatebookdayAllday::addHoliday(const QString&e) | ||
70 | { | ||
71 | DatebookAlldayDisp * lb; | ||
72 | lb = new DatebookAlldayDisp(e,m_MainFrame,NULL); | ||
73 | lb->show(); | ||
74 | datebookdayalldayLayout->addWidget(lb); | ||
75 | subWidgets.append(lb); | ||
76 | |||
77 | connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&))); | ||
78 | ++item_count; | ||
79 | |||
80 | return lb; | ||
81 | } | ||
82 | |||
69 | void DatebookdayAllday::removeAllEvents() | 83 | void DatebookdayAllday::removeAllEvents() |
70 | { | 84 | { |
71 | subWidgets.clear(); | 85 | subWidgets.clear(); |
72 | item_count = 0; | 86 | item_count = 0; |
73 | } | 87 | } |
74 | 88 | ||
75 | DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, | 89 | DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, |
76 | QWidget* parent,const char* name,WFlags f) | 90 | QWidget* parent,const char* name,WFlags f) |
77 | : QLabel(parent,name,f),m_Ev(ev),dateBook(db) | 91 | : QLabel(parent,name,f),m_Ev(ev),dateBook(db) |
78 | { | 92 | { |
79 | QString strDesc = m_Ev.description(); | 93 | QString strDesc = m_Ev.description(); |
80 | strDesc = strDesc.replace(QRegExp("<"),"<"); | 94 | strDesc = strDesc.replace(QRegExp("<"),"<"); |
81 | setBackgroundColor(yellow); | 95 | setBackgroundColor(yellow); |
82 | setText(strDesc); | 96 | setText(strDesc); |
83 | setFrameStyle(QFrame::Raised|QFrame::Panel); | 97 | setFrameStyle(QFrame::Raised|QFrame::Panel); |
84 | 98 | ||
85 | int s = QFontMetrics(font()).height()+4; | 99 | int s = QFontMetrics(font()).height()+4; |
86 | setMaximumHeight( s ); | 100 | setMaximumHeight( s ); |
87 | setMinimumSize( QSize( 0, s ) ); | 101 | setMinimumSize( QSize( 0, s ) ); |
102 | m_holiday = false; | ||
103 | } | ||
104 | |||
105 | DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,const char* name, WFlags fl) | ||
106 | : QLabel(parent,name,fl),m_Ev(),dateBook(0) | ||
107 | { | ||
108 | QString strDesc = aholiday; | ||
109 | strDesc = strDesc.replace(QRegExp("<"),"<"); | ||
110 | Event ev; | ||
111 | ev.setDescription(strDesc); | ||
112 | ev.setAllDay(true); | ||
113 | m_Ev.setEvent(ev); | ||
114 | setBackgroundColor(yellow); | ||
115 | setText(strDesc); | ||
116 | setFrameStyle(QFrame::Raised|QFrame::Panel); | ||
117 | |||
118 | int s = QFontMetrics(font()).height()+4; | ||
119 | setMaximumHeight( s ); | ||
120 | setMinimumSize( QSize( 0, s ) ); | ||
121 | m_holiday = true; | ||
88 | } | 122 | } |
89 | 123 | ||
90 | DatebookAlldayDisp::~DatebookAlldayDisp() | 124 | DatebookAlldayDisp::~DatebookAlldayDisp() |
91 | { | 125 | { |
92 | } | 126 | } |
93 | 127 | ||
94 | void DatebookAlldayDisp::beam_single_event() | 128 | void DatebookAlldayDisp::beam_single_event() |
95 | { | 129 | { |
130 | if (m_holiday) return; | ||
96 | // create an Event and beam it... | 131 | // create an Event and beam it... |
97 | /* | 132 | /* |
98 | * Start with the easy stuff. If start and end date is the same we can just use | 133 | * Start with the easy stuff. If start and end date is the same we can just use |
99 | * the values of effective m_Events | 134 | * the values of effective m_Events |
100 | * If it is a multi day m_Event we need to find the real start and end date... | 135 | * If it is a multi day m_Event we need to find the real start and end date... |
101 | */ | 136 | */ |
102 | if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { | 137 | if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { |
103 | Event m_Event( m_Ev.event() ); | 138 | Event m_Event( m_Ev.event() ); |
104 | 139 | ||
105 | QDateTime dt( m_Ev.date(), m_Ev.start() ); | 140 | QDateTime dt( m_Ev.date(), m_Ev.start() ); |
106 | m_Event.setStart( dt ); | 141 | m_Event.setStart( dt ); |
107 | 142 | ||
108 | dt.setTime( m_Ev.end() ); | 143 | dt.setTime( m_Ev.end() ); |
109 | m_Event.setEnd( dt ); | 144 | m_Event.setEnd( dt ); |
110 | emit beamMe( m_Event ); | 145 | emit beamMe( m_Event ); |
111 | }else { | 146 | }else { |
112 | /* | 147 | /* |
113 | * at least the the Times are right now | 148 | * at least the the Times are right now |
114 | */ | 149 | */ |
115 | QDateTime start( m_Ev.event().start() ); | 150 | QDateTime start( m_Ev.event().start() ); |
116 | QDateTime end ( m_Ev.event().end () ); | 151 | QDateTime end ( m_Ev.event().end () ); |
117 | 152 | ||
118 | /* | 153 | /* |
119 | * ok we know the start date or we need to find it | 154 | * ok we know the start date or we need to find it |
120 | */ | 155 | */ |
121 | if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { | 156 | if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { |
122 | start.setDate( m_Ev.date() ); | 157 | start.setDate( m_Ev.date() ); |
123 | }else { | 158 | }else { |
124 | QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook ); | 159 | QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook ); |
125 | start.setDate( dt ); | 160 | start.setDate( dt ); |
126 | } | 161 | } |
127 | 162 | ||
128 | /* | 163 | /* |
129 | * ok we know now the end date... | 164 | * ok we know now the end date... |
130 | * else | 165 | * else |
131 | * get to know the offset btw the real start and real end | 166 | * get to know the offset btw the real start and real end |
132 | * and then add it to the new start date... | 167 | * and then add it to the new start date... |
133 | */ | 168 | */ |
134 | if ( m_Ev.end() != QTime(23, 59, 59 ) ) { | 169 | if ( m_Ev.end() != QTime(23, 59, 59 ) ) { |
135 | end.setDate( m_Ev.date() ); | 170 | end.setDate( m_Ev.date() ); |
136 | }else{ | 171 | }else{ |
137 | int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() ); | 172 | int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() ); |
138 | end.setDate( start.date().addDays( days ) ); | 173 | end.setDate( start.date().addDays( days ) ); |
139 | } | 174 | } |
140 | Event m_Event( m_Ev.event() ); | 175 | Event m_Event( m_Ev.event() ); |
141 | m_Event.setStart( start ); | 176 | m_Event.setStart( start ); |
142 | m_Event.setEnd ( end ); | 177 | m_Event.setEnd ( end ); |
143 | emit beamMe( m_Event ); | 178 | emit beamMe( m_Event ); |
144 | } | 179 | } |
145 | } | 180 | } |
146 | 181 | ||
147 | void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) | 182 | void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) |
148 | { | 183 | { |
149 | Event ev = m_Ev.event(); | 184 | Event ev = m_Ev.event(); |
150 | QColor b = backgroundColor(); | 185 | QColor b = backgroundColor(); |
151 | setBackgroundColor(green); | 186 | setBackgroundColor(green); |
152 | update(); | 187 | update(); |
153 | QPopupMenu m; | 188 | QPopupMenu m; |
154 | m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); | 189 | if (!m_holiday) { |
155 | m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); | 190 | m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); |
156 | m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); | 191 | m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); |
157 | if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); | 192 | m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); |
158 | if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); | 193 | if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); |
194 | if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); | ||
195 | } | ||
159 | m.insertItem( tr( "Info"),6); | 196 | m.insertItem( tr( "Info"),6); |
160 | int r = m.exec( e->globalPos() ); | 197 | int r = m.exec( e->globalPos() ); |
161 | setBackgroundColor(b); | 198 | setBackgroundColor(b); |
162 | update(); | 199 | update(); |
163 | switch (r) { | 200 | switch (r) { |
164 | case 1: | 201 | case 1: |
165 | emit editMe( ev ); | 202 | emit editMe( ev ); |
166 | break; | 203 | break; |
167 | case 2: | 204 | case 2: |
168 | emit deleteMe( ev ); | 205 | emit deleteMe( ev ); |
169 | break; | 206 | break; |
170 | case 3: | 207 | case 3: |
171 | emit beamMe( ev ); | 208 | emit beamMe( ev ); |
172 | break; | 209 | break; |
173 | case 4: | 210 | case 4: |
174 | emit duplicateMe( ev ); | 211 | emit duplicateMe( ev ); |
175 | break; | 212 | break; |
176 | case 5: | 213 | case 5: |
177 | beam_single_event(); | 214 | beam_single_event(); |
178 | break; | 215 | break; |
179 | case 6: | 216 | case 6: |
180 | emit displayMe( ev ); | 217 | emit displayMe( ev ); |
181 | break; | 218 | break; |
182 | default: | 219 | default: |
183 | break; | 220 | break; |
184 | } | 221 | } |
185 | } | 222 | } |
186 | 223 | ||
187 | DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name) | 224 | DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name) |
188 | :QLabel(parent,name) | 225 | :QLabel(parent,name) |
189 | { | 226 | { |
190 | m_Timer=new QTimer(this); | 227 | m_Timer=new QTimer(this); |
191 | connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide())); | 228 | connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide())); |
192 | setFrameStyle(QFrame::Sunken|QFrame::Panel); | 229 | setFrameStyle(QFrame::Sunken|QFrame::Panel); |
193 | setTextFormat(RichText); | 230 | setTextFormat(RichText); |
194 | } | 231 | } |
195 | 232 | ||
196 | DatebookEventDesc::~DatebookEventDesc() | 233 | DatebookEventDesc::~DatebookEventDesc() |
197 | { | 234 | { |
198 | } | 235 | } |
199 | 236 | ||
200 | void DatebookEventDesc::mousePressEvent(QMouseEvent*) | 237 | void DatebookEventDesc::mousePressEvent(QMouseEvent*) |
201 | { | 238 | { |
202 | hide(); | 239 | hide(); |
203 | if (m_Timer->isActive()) m_Timer->stop(); | 240 | if (m_Timer->isActive()) m_Timer->stop(); |
204 | } | 241 | } |
205 | 242 | ||
206 | void DatebookEventDesc::disp_event(const Event&e) | 243 | void DatebookEventDesc::disp_event(const Event&e) |
diff --git a/core/pim/datebook/datebookdayallday.h b/core/pim/datebook/datebookdayallday.h index f5867e5..4f5cffa 100644 --- a/core/pim/datebook/datebookdayallday.h +++ b/core/pim/datebook/datebookdayallday.h | |||
@@ -1,82 +1,86 @@ | |||
1 | #ifndef DATEBOOKDAYALLDAYBASE_H | 1 | #ifndef DATEBOOKDAYALLDAYBASE_H |
2 | #define DATEBOOKDAYALLDAYBASE_H | 2 | #define DATEBOOKDAYALLDAYBASE_H |
3 | 3 | ||
4 | #include <qvariant.h> | 4 | #include <qvariant.h> |
5 | #include <qframe.h> | 5 | #include <qframe.h> |
6 | #include <qscrollview.h> | 6 | #include <qscrollview.h> |
7 | #include <qlabel.h> | 7 | #include <qlabel.h> |
8 | #include <qlist.h> | 8 | #include <qlist.h> |
9 | #include <qpe/event.h> | 9 | #include <qpe/event.h> |
10 | 10 | ||
11 | class QVBoxLayout; | 11 | class QVBoxLayout; |
12 | class QHBoxLayout; | 12 | class QHBoxLayout; |
13 | class QGridLayout; | 13 | class QGridLayout; |
14 | class DatebookAlldayDisp; | 14 | class DatebookAlldayDisp; |
15 | class DatebookEventDesc; | 15 | class DatebookEventDesc; |
16 | class DateBookDB; | 16 | class DateBookDB; |
17 | 17 | ||
18 | class DatebookdayAllday : public QScrollView | 18 | class DatebookdayAllday : public QScrollView |
19 | { | 19 | { |
20 | Q_OBJECT | 20 | Q_OBJECT |
21 | 21 | ||
22 | public: | 22 | public: |
23 | DatebookdayAllday(DateBookDB* db, | 23 | DatebookdayAllday(DateBookDB* db, |
24 | QWidget* parent = 0, const char* name = 0, WFlags fl = 0); | 24 | QWidget* parent = 0, const char* name = 0, WFlags fl = 0); |
25 | ~DatebookdayAllday(); | 25 | ~DatebookdayAllday(); |
26 | DatebookAlldayDisp* addEvent(const EffectiveEvent&e); | 26 | DatebookAlldayDisp* addEvent(const EffectiveEvent&e); |
27 | DatebookAlldayDisp* addHoliday(const QString&e); | ||
27 | const unsigned int items()const{return item_count;} | 28 | const unsigned int items()const{return item_count;} |
28 | 29 | ||
29 | public slots: | 30 | public slots: |
30 | void removeAllEvents(); | 31 | void removeAllEvents(); |
31 | 32 | ||
32 | protected: | 33 | protected: |
33 | QFrame * m_MainFrame; | 34 | QFrame * m_MainFrame; |
34 | QVBoxLayout* datebookdayalldayLayout; | 35 | QVBoxLayout* datebookdayalldayLayout; |
35 | DatebookEventDesc * lblDesc; | 36 | DatebookEventDesc * lblDesc; |
36 | unsigned int item_count; | 37 | unsigned int item_count; |
37 | QList<DatebookAlldayDisp> subWidgets; | 38 | QList<DatebookAlldayDisp> subWidgets; |
38 | DateBookDB *dateBook; | 39 | DateBookDB *dateBook; |
39 | }; | 40 | }; |
40 | 41 | ||
41 | class DatebookAlldayDisp : public QLabel | 42 | class DatebookAlldayDisp : public QLabel |
42 | { | 43 | { |
43 | Q_OBJECT | 44 | Q_OBJECT |
44 | 45 | ||
45 | public: | 46 | public: |
46 | DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e, | 47 | DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e, |
47 | QWidget* parent=0,const char* name = 0, WFlags fl=0); | 48 | QWidget* parent=0,const char* name = 0, WFlags fl=0); |
49 | DatebookAlldayDisp(const QString&aholiday, | ||
50 | QWidget* parent=0,const char* name = 0, WFlags fl=0); | ||
48 | virtual ~DatebookAlldayDisp(); | 51 | virtual ~DatebookAlldayDisp(); |
49 | 52 | ||
50 | signals: | 53 | signals: |
51 | void deleteMe( const Event &e ); | 54 | void deleteMe( const Event &e ); |
52 | void duplicateMe( const Event &e ); | 55 | void duplicateMe( const Event &e ); |
53 | void editMe( const Event &e ); | 56 | void editMe( const Event &e ); |
54 | void beamMe( const Event &e ); | 57 | void beamMe( const Event &e ); |
55 | void displayMe(const Event &e); | 58 | void displayMe(const Event &e); |
56 | 59 | ||
57 | public slots: | 60 | public slots: |
58 | 61 | ||
59 | protected: | 62 | protected: |
60 | EffectiveEvent m_Ev; | 63 | EffectiveEvent m_Ev; |
61 | DateBookDB* dateBook; | 64 | DateBookDB* dateBook; |
62 | void mousePressEvent( QMouseEvent *e ); | 65 | void mousePressEvent( QMouseEvent *e ); |
63 | void beam_single_event(); | 66 | void beam_single_event(); |
67 | bool m_holiday:1; | ||
64 | }; | 68 | }; |
65 | 69 | ||
66 | class DatebookEventDesc: public QLabel | 70 | class DatebookEventDesc: public QLabel |
67 | { | 71 | { |
68 | Q_OBJECT | 72 | Q_OBJECT |
69 | 73 | ||
70 | public: | 74 | public: |
71 | DatebookEventDesc(QWidget* Parent=0,const char* name = 0); | 75 | DatebookEventDesc(QWidget* Parent=0,const char* name = 0); |
72 | virtual ~DatebookEventDesc(); | 76 | virtual ~DatebookEventDesc(); |
73 | 77 | ||
74 | public slots: | 78 | public slots: |
75 | void disp_event(const Event&e); | 79 | void disp_event(const Event&e); |
76 | 80 | ||
77 | protected: | 81 | protected: |
78 | void mousePressEvent(QMouseEvent*e); | 82 | void mousePressEvent(QMouseEvent*e); |
79 | QTimer* m_Timer; | 83 | QTimer* m_Timer; |
80 | }; | 84 | }; |
81 | 85 | ||
82 | #endif // DATEBOOKDAYALLDAYBASE_H | 86 | #endif // DATEBOOKDAYALLDAYBASE_H |
diff --git a/core/pim/datebook/holiday/dummy/config.in b/core/pim/datebook/holiday/dummy/config.in new file mode 100644 index 0000000..caa90bc --- a/dev/null +++ b/core/pim/datebook/holiday/dummy/config.in | |||
@@ -0,0 +1,8 @@ | |||
1 | config DATEBOOK_DUMMY_HOLIDAY | ||
2 | boolean "opie-datebook-dummyholidayplugin" | ||
3 | default "n" | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM | ||
5 | |||
6 | comment "opie-datebook-dummyholidayplugin requires libopie2core, libopie2ui, libopie2pim" | ||
7 | depends !( ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM ) | ||
8 | |||
diff --git a/core/pim/datebook/holiday/dummy/dummy.pro b/core/pim/datebook/holiday/dummy/dummy.pro new file mode 100644 index 0000000..768bb77 --- a/dev/null +++ b/core/pim/datebook/holiday/dummy/dummy.pro | |||
@@ -0,0 +1,20 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG -= moc | ||
3 | CONFIG += qt plugin | ||
4 | |||
5 | # Input | ||
6 | HEADERS = dummyholiday.h | ||
7 | SOURCES = dummyholiday.cpp | ||
8 | INTERFACES= | ||
9 | |||
10 | INCLUDEPATH += $(OPIEDIR)/include \ | ||
11 | ../ ../library | ||
12 | DEPENDPATH += $(OPIEDIR)/include \ | ||
13 | ../ ../library | ||
14 | |||
15 | LIBS+= -lqpe -lopiecore2 -lopieui2 | ||
16 | |||
17 | DESTDIR = $(OPIEDIR)/plugins/datebook/holiday | ||
18 | TARGET = dummyholidayplugin | ||
19 | |||
20 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/core/pim/datebook/holiday/dummy/dummyholiday.cpp b/core/pim/datebook/holiday/dummy/dummyholiday.cpp new file mode 100644 index 0000000..dd00b9b --- a/dev/null +++ b/core/pim/datebook/holiday/dummy/dummyholiday.cpp | |||
@@ -0,0 +1,20 @@ | |||
1 | #include "dummyholiday.h" | ||
2 | |||
3 | #include <qobject.h> | ||
4 | |||
5 | QString DummyHoliday::description() | ||
6 | { | ||
7 | return QObject::tr("Test holiday plugin","dummyholiday"); | ||
8 | } | ||
9 | |||
10 | QStringList DummyHoliday::entries(const QDate&aDate) | ||
11 | { | ||
12 | return entries(0,0,aDate.day()); | ||
13 | } | ||
14 | |||
15 | QStringList DummyHoliday::entries(unsigned year, unsigned month, unsigned day) | ||
16 | { | ||
17 | QStringList ret; | ||
18 | if (day%2==0) ret.append(QObject::tr("You have a holiday!","dummyholiday")); | ||
19 | return ret; | ||
20 | } | ||
diff --git a/core/pim/datebook/holiday/dummy/dummyholiday.h b/core/pim/datebook/holiday/dummy/dummyholiday.h new file mode 100644 index 0000000..9b28f24 --- a/dev/null +++ b/core/pim/datebook/holiday/dummy/dummyholiday.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef __DUMMY_HOLIDAY_H | ||
2 | #define __DUMMY_HOLIDAY_H | ||
3 | |||
4 | #include <opie2/oholidayplugin.h> | ||
5 | #include <opie2/oholidaypluginif.h> | ||
6 | |||
7 | class DummyHoliday:public Opie::Datebook::HolidayPlugin | ||
8 | { | ||
9 | public: | ||
10 | DummyHoliday():Opie::Datebook::HolidayPlugin(){} | ||
11 | virtual ~DummyHoliday(){} | ||
12 | |||
13 | virtual QString description(); | ||
14 | virtual QStringList entries(const QDate&); | ||
15 | virtual QStringList entries(unsigned year, unsigned month, unsigned day); | ||
16 | }; | ||
17 | |||
18 | EXPORT_HOLIDAY_PLUGIN(DummyHoliday); | ||
19 | #endif | ||