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