summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-02 17:31:20 (UTC)
committer zautrix <zautrix>2005-07-02 17:31:20 (UTC)
commit0233482f5f4baf7a0af45229b02c5deaab17a412 (patch) (unidiff)
treef22927da2ae116c53dc87026ce60b56704309e56
parent78866028c185f4227bfb653ee2050d7feb2e2b78 (diff)
downloadkdepimpi-0233482f5f4baf7a0af45229b02c5deaab17a412.zip
kdepimpi-0233482f5f4baf7a0af45229b02c5deaab17a412.tar.gz
kdepimpi-0233482f5f4baf7a0af45229b02c5deaab17a412.tar.bz2
mv warnings removed
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp10
-rw-r--r--korganizer/kolistview.h1
-rw-r--r--korganizer/komonthview.cpp35
-rw-r--r--korganizer/komonthview.h6
4 files changed, 35 insertions, 17 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 1b4397f..db3f802 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -135,440 +135,450 @@ bool ListItemVisitor::visit(Event *e)
135 mItem->setText(6, e->recurrence()->recurrenceText()); 135 mItem->setText(6, e->recurrence()->recurrenceText());
136 if( ! e->doesRecur() ) 136 if( ! e->doesRecur() )
137 mItem->setSortKey( 6, "-" ); 137 mItem->setSortKey( 6, "-" );
138 mItem->setText(7,"---"); 138 mItem->setText(7,"---");
139 mItem->setText(8,"---"); 139 mItem->setText(8,"---");
140 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 140 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
141 mItem->setText(10,e->categoriesStr()); 141 mItem->setText(10,e->categoriesStr());
142 mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); 142 mItem->setText(11, KOPrefs::instance()->calName( e->calID() ));
143 143
144 QString key; 144 QString key;
145 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 145 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
146 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 146 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
147 mItem->setSortKey(1,key); 147 mItem->setSortKey(1,key);
148 148
149 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 149 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
150 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 150 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
151 mItem->setSortKey(3,key); 151 mItem->setSortKey(3,key);
152 return true; 152 return true;
153} 153}
154 154
155bool ListItemVisitor::visit(Todo *t) 155bool ListItemVisitor::visit(Todo *t)
156{ 156{
157 mItem->setText(0,t->summary()); 157 mItem->setText(0,t->summary());
158 if ( t->isCompleted() ) { 158 if ( t->isCompleted() ) {
159 mItem->setSortKey(0,"99"+ t->summary().left(10)); 159 mItem->setSortKey(0,"99"+ t->summary().left(10));
160 } else 160 } else
161 mItem->setSortKey(0,QString::number( t->percentComplete() )+ t->summary().left(10)); 161 mItem->setSortKey(0,QString::number( t->percentComplete() )+ t->summary().left(10));
162 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); 162 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20]));
163 if (t->hasStartDate()) { 163 if (t->hasStartDate()) {
164 mItem->setText(1,t->dtStartDateStr()); 164 mItem->setText(1,t->dtStartDateStr());
165 if (t->doesFloat()) { 165 if (t->doesFloat()) {
166 mItem->setText(2,"---"); 166 mItem->setText(2,"---");
167 } else { 167 } else {
168 mItem->setText(2,t->dtStartTimeStr()); 168 mItem->setText(2,t->dtStartTimeStr());
169 } 169 }
170 } else { 170 } else {
171 mItem->setText(1,"---"); 171 mItem->setText(1,"---");
172 mItem->setText(2,"---"); 172 mItem->setText(2,"---");
173 } 173 }
174 mItem->setText(3,"---"); 174 mItem->setText(3,"---");
175 mItem->setText(4,"---"); 175 mItem->setText(4,"---");
176 if ( t->isAlarmEnabled() ) { 176 if ( t->isAlarmEnabled() ) {
177 mItem->setText(5,t->alarms().first()->offsetText() ); 177 mItem->setText(5,t->alarms().first()->offsetText() );
178 } else { 178 } else {
179 mItem->setText(5, i18n("No")); 179 mItem->setText(5, i18n("No"));
180 } 180 }
181 mItem->setText(6, t->recurrence()->recurrenceText()); 181 mItem->setText(6, t->recurrence()->recurrenceText());
182 if( ! t->doesRecur() ) 182 if( ! t->doesRecur() )
183 mItem->setSortKey( 6, "-" ); 183 mItem->setSortKey( 6, "-" );
184 if (t->hasDueDate()) { 184 if (t->hasDueDate()) {
185 mItem->setText(7,t->dtDueDateStr()); 185 mItem->setText(7,t->dtDueDateStr());
186 if (t->doesFloat()) { 186 if (t->doesFloat()) {
187 mItem->setText(8,"---"); 187 mItem->setText(8,"---");
188 } else { 188 } else {
189 mItem->setText(8,t->dtDueTimeStr()); 189 mItem->setText(8,t->dtDueTimeStr());
190 } 190 }
191 } else { 191 } else {
192 mItem->setText(7,"---"); 192 mItem->setText(7,"---");
193 mItem->setText(8,"---"); 193 mItem->setText(8,"---");
194 } 194 }
195 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 195 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
196 mItem->setText(10,t->categoriesStr()); 196 mItem->setText(10,t->categoriesStr());
197 mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); 197 mItem->setText(11, KOPrefs::instance()->calName( t->calID() ));
198 198
199 QString key; 199 QString key;
200 QDate d; 200 QDate d;
201 if (t->hasDueDate()) { 201 if (t->hasDueDate()) {
202 d = t->dtDue().date(); 202 d = t->dtDue().date();
203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
205 mItem->setSortKey(7,key); 205 mItem->setSortKey(7,key);
206 } 206 }
207 if ( t->hasStartDate() ) { 207 if ( t->hasStartDate() ) {
208 d = t->dtStart().date(); 208 d = t->dtStart().date();
209 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 209 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
210 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 210 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
211 mItem->setSortKey(1,key); 211 mItem->setSortKey(1,key);
212 } 212 }
213 return true; 213 return true;
214} 214}
215 215
216bool ListItemVisitor::visit(Journal * j) 216bool ListItemVisitor::visit(Journal * j)
217{ 217{
218 218
219 QString des; 219 QString des;
220 if ( !j->summary().isEmpty() ) { 220 if ( !j->summary().isEmpty() ) {
221 des = j->summary(); 221 des = j->summary();
222 } else { 222 } else {
223 des = j->description().left(30); 223 des = j->description().left(30);
224 des = des.simplifyWhiteSpace (); 224 des = des.simplifyWhiteSpace ();
225 des.replace (QRegExp ("\\n"),"" ); 225 des.replace (QRegExp ("\\n"),"" );
226 des.replace (QRegExp ("\\r"),"" ); 226 des.replace (QRegExp ("\\r"),"" );
227 } 227 }
228 mItem->setText(0,i18n("Journal: ")+des.left(25)); 228 mItem->setText(0,i18n("Journal: ")+des.left(25));
229 mItem->setText(1,j->dtStartDateStr()); 229 mItem->setText(1,j->dtStartDateStr());
230 mItem->setText(2,"---"); 230 mItem->setText(2,"---");
231 mItem->setText(3,"---"); 231 mItem->setText(3,"---");
232 mItem->setText(4,"---"); 232 mItem->setText(4,"---");
233 mItem->setText(5,"---"); 233 mItem->setText(5,"---");
234 mItem->setText(6,"---"); 234 mItem->setText(6,"---");
235 mItem->setText(7,j->dtStartDateStr()); 235 mItem->setText(7,j->dtStartDateStr());
236 mItem->setText(8,"---"); 236 mItem->setText(8,"---");
237 mItem->setText(9,"---"); 237 mItem->setText(9,"---");
238 mItem->setText(10,j->categoriesStr()); 238 mItem->setText(10,j->categoriesStr());
239 mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); 239 mItem->setText(11, KOPrefs::instance()->calName( j->calID() ));
240 240
241 QString key; 241 QString key;
242 QDate d = j->dtStart().date(); 242 QDate d = j->dtStart().date();
243 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 243 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
244 mItem->setSortKey(1,key); 244 mItem->setSortKey(1,key);
245 mItem->setSortKey(7,key); 245 mItem->setSortKey(7,key);
246 246
247 return true; 247 return true;
248} 248}
249 249
250KOListView::KOListView(Calendar *calendar, QWidget *parent, 250KOListView::KOListView(Calendar *calendar, QWidget *parent,
251 const char *name) 251 const char *name)
252 : KOEventView(calendar, parent, name) 252 : KOEventView(calendar, parent, name)
253{ 253{
254 254
255 mActiveItem = 0; 255 mActiveItem = 0;
256 mForceShowCompletedTodos = false; 256 mForceShowCompletedTodos = false;
257 mListView = new KOListViewListView(this); 257 mListView = new KOListViewListView(this);
258 mListView->addColumn(i18n("Summary")); 258 mListView->addColumn(i18n("Summary"));
259 mListView->addColumn(i18n("Start Date")); 259 mListView->addColumn(i18n("Start Date"));
260 mListView->addColumn(i18n("Start Time")); 260 mListView->addColumn(i18n("Start Time"));
261 mListView->addColumn(i18n("End Date")); 261 mListView->addColumn(i18n("End Date"));
262 mListView->addColumn(i18n("End Time")); 262 mListView->addColumn(i18n("End Time"));
263 mListView->addColumn(i18n("Alarm")); // alarm set? 263 mListView->addColumn(i18n("Alarm")); // alarm set?
264 mListView->addColumn(i18n("Recurs")); // recurs? 264 mListView->addColumn(i18n("Recurs")); // recurs?
265 mListView->addColumn(i18n("Due Date")); 265 mListView->addColumn(i18n("Due Date"));
266 mListView->addColumn(i18n("Due Time")); 266 mListView->addColumn(i18n("Due Time"));
267 mListView->addColumn(i18n("Cancelled")); 267 mListView->addColumn(i18n("Cancelled"));
268 mListView->addColumn(i18n("Categories")); 268 mListView->addColumn(i18n("Categories"));
269 mListView->addColumn(i18n("Calendar")); 269 mListView->addColumn(i18n("Calendar"));
270 270
271 mListView->setColumnAlignment(0,AlignLeft); 271 mListView->setColumnAlignment(0,AlignLeft);
272 mListView->setColumnAlignment(1,AlignLeft); 272 mListView->setColumnAlignment(1,AlignLeft);
273 mListView->setColumnAlignment(2,AlignHCenter); 273 mListView->setColumnAlignment(2,AlignHCenter);
274 mListView->setColumnAlignment(3,AlignLeft); 274 mListView->setColumnAlignment(3,AlignLeft);
275 mListView->setColumnAlignment(4,AlignHCenter); 275 mListView->setColumnAlignment(4,AlignHCenter);
276 mListView->setColumnAlignment(5,AlignLeft); 276 mListView->setColumnAlignment(5,AlignLeft);
277 mListView->setColumnAlignment(6,AlignLeft); 277 mListView->setColumnAlignment(6,AlignLeft);
278 mListView->setColumnAlignment(7,AlignLeft); 278 mListView->setColumnAlignment(7,AlignLeft);
279 mListView->setColumnAlignment(8,AlignLeft); 279 mListView->setColumnAlignment(8,AlignLeft);
280 mListView->setColumnAlignment(9,AlignLeft); 280 mListView->setColumnAlignment(9,AlignLeft);
281 mListView->setColumnAlignment(10,AlignLeft); 281 mListView->setColumnAlignment(10,AlignLeft);
282 mListView->setColumnAlignment(11,AlignLeft); 282 mListView->setColumnAlignment(11,AlignLeft);
283 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 283 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
284 284
285 int iii = 0; 285 int iii = 0;
286 for ( iii = 0; iii< 12 ; ++iii ) 286 for ( iii = 0; iii< 12 ; ++iii )
287 mListView->setColumnWidthMode( iii, QListView::Manual ); 287 mListView->setColumnWidthMode( iii, QListView::Manual );
288 288
289 QBoxLayout *layoutTop = new QVBoxLayout(this); 289 QBoxLayout *layoutTop = new QVBoxLayout(this);
290 layoutTop->addWidget(mListView); 290 layoutTop->addWidget(mListView);
291 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 291 mListView->setFont ( KOPrefs::instance()->mListViewFont );
292 mPopupMenu = eventPopup(); 292 mPopupMenu = eventPopup();
293 QPopupMenu* selPopup = new QPopupMenu ( this ); 293 QPopupMenu* selPopup = new QPopupMenu ( this );
294 mPopupMenu->insertSeparator(); 294 mPopupMenu->insertSeparator();
295 295
296 selPopup->insertItem(i18n("All"),this, 296 selPopup->insertItem(i18n("All"),this,
297 SLOT(allSelection())); 297 SLOT(allSelection()));
298 selPopup->insertItem(i18n("None"),this, 298 selPopup->insertItem(i18n("None"),this,
299 SLOT(clearSelection())); 299 SLOT(clearSelection()));
300 selPopup->insertItem(i18n("Delete selected..."),this, 300 selPopup->insertItem(i18n("Delete selected..."),this,
301 SLOT(deleteAll())); 301 SLOT(deleteAll()));
302 mPopupMenu->insertItem(i18n("Selection"), selPopup ); 302 mPopupMenu->insertItem(i18n("Selection"), selPopup );
303 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 303 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
304 i18n("Hide all selected"),this, 304 i18n("Hide all selected"),this,
305 SLOT(hideAll()),true); 305 SLOT(hideAll()),true);
306 306
307 mPopupMenu->insertSeparator(); 307 mPopupMenu->insertSeparator();
308#ifdef DESKTOP_VERSION 308#ifdef DESKTOP_VERSION
309 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 309 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
310 i18n("Print complete list"),this, 310 i18n("Print complete list"),this,
311 SLOT(printList()),true); 311 SLOT(printList()),true);
312 mPopupMenu->insertSeparator(); 312 mPopupMenu->insertSeparator();
313#endif 313#endif
314 mCalPopup = new QPopupMenu ( this ); 314 mCalPopup = new QPopupMenu ( this );
315 mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup ); 315 mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup );
316 316
317 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 317 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
318 i18n("Set categories")+"...",this, 318 i18n("Set categories")+"...",this,
319 SLOT(setCat()),true); 319 SLOT(setCat()),true);
320 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 320 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
321 i18n("Set alarm..."),this, 321 i18n("Set alarm..."),this,
322 SLOT(setAlarm()),true); 322 SLOT(setAlarm()),true);
323 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, 323 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this,
324 SLOT( populateCalPopup() )); 324 SLOT( populateCalPopup() ));
325 QObject::connect(mCalPopup,SIGNAL(activated( int )),this, 325 QObject::connect(mCalPopup,SIGNAL(activated( int )),this,
326 SLOT( setCalendar( int ) )); 326 SLOT( setCalendar( int ) ));
327 QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this,
328 SLOT( catChanged( Incidence * ) ));
327 QPopupMenu * exportPO = new QPopupMenu ( this ); 329 QPopupMenu * exportPO = new QPopupMenu ( this );
328 mPopupMenu->insertItem( i18n("Export"), exportPO ); 330 mPopupMenu->insertItem( i18n("Export"), exportPO );
329 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 331 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
330 SLOT(saveToFile())); 332 SLOT(saveToFile()));
331 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 333 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
332 SLOT(saveToFileVCS())); 334 SLOT(saveToFileVCS()));
333 exportPO->insertItem( i18n("Journal/Details..."),this, 335 exportPO->insertItem( i18n("Journal/Details..."),this,
334 SLOT(saveDescriptionToFile())); 336 SLOT(saveDescriptionToFile()));
335 // mPopupMenu->insertSeparator(); 337 // mPopupMenu->insertSeparator();
336 // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 338 // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
337 // i18n("Add Categ. to selected..."),this, 339 // i18n("Add Categ. to selected..."),this,
338 // SLOT(addCat()),true); 340 // SLOT(addCat()),true);
339 //mPopupMenu->insertSeparator(); 341 //mPopupMenu->insertSeparator();
340#ifndef DESKTOP_VERSION 342#ifndef DESKTOP_VERSION
341 mPopupMenu->insertSeparator(); 343 mPopupMenu->insertSeparator();
342 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 344 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
343 i18n("Beam via IR"),this, 345 i18n("Beam via IR"),this,
344 SLOT(beamSelected()),true); 346 SLOT(beamSelected()),true);
345#endif 347#endif
346 /* 348 /*
347 mPopupMenu = new QPopupMenu; 349 mPopupMenu = new QPopupMenu;
348 mPopupMenu->insertItem(i18n("Edit Event"), this, 350 mPopupMenu->insertItem(i18n("Edit Event"), this,
349 SLOT (editEvent())); 351 SLOT (editEvent()));
350 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 352 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
351 SLOT (deleteEvent())); 353 SLOT (deleteEvent()));
352 mPopupMenu->insertSeparator(); 354 mPopupMenu->insertSeparator();
353 mPopupMenu->insertItem(i18n("Show Dates"), this, 355 mPopupMenu->insertItem(i18n("Show Dates"), this,
354 SLOT(showDates())); 356 SLOT(showDates()));
355 mPopupMenu->insertItem(i18n("Hide Dates"), this, 357 mPopupMenu->insertItem(i18n("Hide Dates"), this,
356 SLOT(hideDates())); 358 SLOT(hideDates()));
357 */ 359 */
358 QObject::connect(mListView,SIGNAL( newEvent()), 360 QObject::connect(mListView,SIGNAL( newEvent()),
359 this,SIGNAL(signalNewEvent())); 361 this,SIGNAL(signalNewEvent()));
360 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 362 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
361 this,SLOT(defaultItemAction(QListViewItem *))); 363 this,SLOT(defaultItemAction(QListViewItem *)));
362 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 364 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
363 const QPoint &, int )), 365 const QPoint &, int )),
364 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 366 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
365 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 367 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
366 SLOT(processSelectionChange(QListViewItem *))); 368 SLOT(processSelectionChange(QListViewItem *)));
367 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 369 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
368 SIGNAL(showIncidenceSignal(Incidence *)) ); 370 SIGNAL(showIncidenceSignal(Incidence *)) );
369 371
370 readSettings(KOGlobals::config(),"KOListView Layout"); 372 readSettings(KOGlobals::config(),"KOListView Layout");
371} 373}
372 374
373KOListView::~KOListView() 375KOListView::~KOListView()
374{ 376{
375 delete mPopupMenu; 377 delete mPopupMenu;
376#if QT_VERSION >= 0x030000 378#if QT_VERSION >= 0x030000
377 379
378#else 380#else
379 delete mKOListViewWhatsThis; 381 delete mKOListViewWhatsThis;
380#endif 382#endif
381} 383}
382 384
385void KOListView::catChanged( Incidence* inc)
386{
387 KOListViewItem* item = getItemForEvent(inc);
388 if (item) {
389 ListItemVisitor v(item, mStartDate );
390 inc->accept(v);
391 }
392}
383QString KOListView::getWhatsThisText(QPoint p) 393QString KOListView::getWhatsThisText(QPoint p)
384{ 394{
385 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 395 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
386 if ( item ) 396 if ( item )
387 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 397 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
388 KOPrefs::instance()->mWTshowDetails, 398 KOPrefs::instance()->mWTshowDetails,
389 KOPrefs::instance()->mWTshowCreated, 399 KOPrefs::instance()->mWTshowCreated,
390 KOPrefs::instance()->mWTshowChanged); 400 KOPrefs::instance()->mWTshowChanged);
391 return i18n("That is the list view" ); 401 return i18n("That is the list view" );
392 402
393} 403}
394 404
395void KOListView::setCalendar( int c ) 405void KOListView::setCalendar( int c )
396{ 406{
397 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 407 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
398 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), 408 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ),
399 i18n("Continue"), i18n("Cancel"), 0, 409 i18n("Continue"), i18n("Cancel"), 0,
400 0, 1 ); 410 0, 1 );
401 if ( result != 0 ) { 411 if ( result != 0 ) {
402 return; 412 return;
403 } 413 }
404 414
405 QPtrList<Incidence> delSel = getSelectedIncidences() ; 415 QPtrList<Incidence> delSel = getSelectedIncidences() ;
406 int icount = delSel.count(); 416 int icount = delSel.count();
407 if ( icount ) { 417 if ( icount ) {
408 Incidence *incidence = delSel.first(); 418 Incidence *incidence = delSel.first();
409 while ( incidence ) { 419 while ( incidence ) {
410 incidence->setCalID( c ); 420 incidence->setCalID( c );
411 KOListViewItem * item = getItemForEvent( incidence ); 421 KOListViewItem * item = getItemForEvent( incidence );
412 if ( item ) { 422 if ( item ) {
413 ListItemVisitor v(item, mStartDate ); 423 ListItemVisitor v(item, mStartDate );
414 incidence->accept(v); 424 incidence->accept(v);
415 } 425 }
416 incidence = delSel.next(); 426 incidence = delSel.next();
417 } 427 }
418 } 428 }
419 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 429 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
420 KopiCalendarFile * cal = calendars.first(); 430 KopiCalendarFile * cal = calendars.first();
421 while ( cal ) { 431 while ( cal ) {
422 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 432 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
423 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 433 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
424 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 434 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
425 if ( cal->isStandard ) 435 if ( cal->isStandard )
426 mCalendar->setDefaultCalendar( cal->mCalNumber ); 436 mCalendar->setDefaultCalendar( cal->mCalNumber );
427 cal = calendars.next(); 437 cal = calendars.next();
428 } 438 }
429 mCalendar->setSyncEventsReadOnly(); 439 mCalendar->setSyncEventsReadOnly();
430 mCalendar->reInitAlarmSettings(); 440 mCalendar->reInitAlarmSettings();
431 441
432} 442}
433void KOListView::populateCalPopup() 443void KOListView::populateCalPopup()
434{ 444{
435 mCalPopup->clear(); 445 mCalPopup->clear();
436 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 446 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
437 while ( kkf ) { 447 while ( kkf ) {
438 int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); 448 int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber);
439 if ( kkf->mErrorOnLoad || kkf->isReadOnly ) 449 if ( kkf->mErrorOnLoad || kkf->isReadOnly )
440 mCalPopup->setItemEnabled( index, false ); 450 mCalPopup->setItemEnabled( index, false );
441 kkf = KOPrefs::instance()->mCalendars.next(); 451 kkf = KOPrefs::instance()->mCalendars.next();
442 } 452 }
443} 453}
444void KOListView::updateList() 454void KOListView::updateList()
445{ 455{
446 // qDebug(" KOListView::updateList() "); 456 // qDebug(" KOListView::updateList() ");
447 457
448} 458}
449 459
450void KOListView::clearList() 460void KOListView::clearList()
451{ 461{
452 clear (); 462 clear ();
453} 463}
454 464
455void KOListView::setCat() 465void KOListView::setCat()
456{ 466{
457 467
458 bool set = true; 468 bool set = true;
459 int result = KMessageBox::warningYesNoCancel(this, 469 int result = KMessageBox::warningYesNoCancel(this,
460 i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), 470 i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"),
461 i18n("Set categories"), 471 i18n("Set categories"),
462 i18n("Add"), 472 i18n("Add"),
463 i18n("Reset")); 473 i18n("Reset"));
464 if (result == KMessageBox::Cancel) return; 474 if (result == KMessageBox::Cancel) return;
465 if (result == KMessageBox::Yes) set = false; 475 if (result == KMessageBox::Yes) set = false;
466 setCategories( set ); 476 setCategories( set );
467} 477}
468 478
469void KOListView::setAlarm() 479void KOListView::setAlarm()
470{ 480{
471 KOAlarmPrefs kap( this); 481 KOAlarmPrefs kap( this);
472 if ( !kap.exec() ) 482 if ( !kap.exec() )
473 return; 483 return;
474 QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos 484 QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos
475 Incidence* inc = delSel.first(); 485 Incidence* inc = delSel.first();
476 int count = 0; 486 int count = 0;
477 while ( inc ) { 487 while ( inc ) {
478 ++count; 488 ++count;
479 if (kap.mAlarmButton->isChecked()) { 489 if (kap.mAlarmButton->isChecked()) {
480 if (inc->alarms().count() == 0) 490 if (inc->alarms().count() == 0)
481 inc->newAlarm(); 491 inc->newAlarm();
482 QPtrList<Alarm> alarms = inc->alarms(); 492 QPtrList<Alarm> alarms = inc->alarms();
483 Alarm *alarm; 493 Alarm *alarm;
484 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 494 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
485 alarm->setEnabled(true); 495 alarm->setEnabled(true);
486 int j = kap.mAlarmTimeEdit->value()* -60; 496 int j = kap.mAlarmTimeEdit->value()* -60;
487 if (kap.mAlarmIncrCombo->currentItem() == 1) 497 if (kap.mAlarmIncrCombo->currentItem() == 1)
488 j = j * 60; 498 j = j * 60;
489 else if (kap.mAlarmIncrCombo->currentItem() == 2) 499 else if (kap.mAlarmIncrCombo->currentItem() == 2)
490 j = j * (60 * 24); 500 j = j * (60 * 24);
491 alarm->setStartOffset( j ); 501 alarm->setStartOffset( j );
492 502
493 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 503 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
494 alarm->setProcedureAlarm(kap.mAlarmProgram); 504 alarm->setProcedureAlarm(kap.mAlarmProgram);
495 } 505 }
496 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 506 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
497 alarm->setAudioAlarm(kap.mAlarmSound); 507 alarm->setAudioAlarm(kap.mAlarmSound);
498 else 508 else
499 alarm->setType(Alarm::Invalid); 509 alarm->setType(Alarm::Invalid);
500 //alarm->setAudioAlarm("default"); 510 //alarm->setAudioAlarm("default");
501 // TODO: Deal with multiple alarms 511 // TODO: Deal with multiple alarms
502 break; // For now, stop after the first alarm 512 break; // For now, stop after the first alarm
503 } 513 }
504 } else { 514 } else {
505 Alarm* alarm = inc->alarms().first(); 515 Alarm* alarm = inc->alarms().first();
506 if ( alarm ) { 516 if ( alarm ) {
507 alarm->setEnabled(false); 517 alarm->setEnabled(false);
508 alarm->setType(Alarm::Invalid); 518 alarm->setType(Alarm::Invalid);
509 } 519 }
510 } 520 }
511 KOListViewItem* item = getItemForEvent(inc); 521 KOListViewItem* item = getItemForEvent(inc);
512 if (item) { 522 if (item) {
513 ListItemVisitor v(item, mStartDate ); 523 ListItemVisitor v(item, mStartDate );
514 inc->accept(v); 524 inc->accept(v);
515 } 525 }
516 inc = delSel.next(); 526 inc = delSel.next();
517 } 527 }
518 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); 528 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) );
519 qDebug("KO: Set alarm for %d items", count); 529 qDebug("KO: Set alarm for %d items", count);
520 calendar()->reInitAlarmSettings(); 530 calendar()->reInitAlarmSettings();
521 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 531 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
522} 532}
523void KOListView::setCategories( bool removeOld ) 533void KOListView::setCategories( bool removeOld )
524{ 534{
525 535
526 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 536 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
527 csd->setColorEnabled(); 537 csd->setColorEnabled();
528 if (! csd->exec()) { 538 if (! csd->exec()) {
529 delete csd; 539 delete csd;
530 return; 540 return;
531 } 541 }
532 QStringList catList = csd->selectedCategories(); 542 QStringList catList = csd->selectedCategories();
533 delete csd; 543 delete csd;
534 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; 544 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
535 Incidence* inc = delSel.first(); 545 Incidence* inc = delSel.first();
536 while ( inc ) { 546 while ( inc ) {
537 if ( removeOld ) { 547 if ( removeOld ) {
538 inc->setCategories( catList, false ); 548 inc->setCategories( catList, false );
539 } else { 549 } else {
540 inc->addCategories( catList, false ); 550 inc->addCategories( catList, false );
541 } 551 }
542 KOListViewItem* item = getItemForEvent(inc); 552 KOListViewItem* item = getItemForEvent(inc);
543 if (item) { 553 if (item) {
544 ListItemVisitor v(item, mStartDate ); 554 ListItemVisitor v(item, mStartDate );
545 inc->accept(v); 555 inc->accept(v);
546 } 556 }
547 inc = delSel.next(); 557 inc = delSel.next();
548 } 558 }
549 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 559 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
550} 560}
551 561
552void KOListView::beamSelected() 562void KOListView::beamSelected()
553{ 563{
554 QPtrList<Incidence> delSel = getSelectedIncidences() ; 564 QPtrList<Incidence> delSel = getSelectedIncidences() ;
555 if ( delSel.count() ) 565 if ( delSel.count() )
556 emit beamIncidenceList( delSel ); 566 emit beamIncidenceList( delSel );
557} 567}
558 568
559void KOListView::saveDescriptionToFile() 569void KOListView::saveDescriptionToFile()
560{ 570{
561 571
562 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 572 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
563 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 573 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
564 i18n("Continue"), i18n("Cancel"), 0, 574 i18n("Continue"), i18n("Cancel"), 0,
565 0, 1 ); 575 0, 1 );
566 if ( result != 0 ) { 576 if ( result != 0 ) {
567 return; 577 return;
568 } 578 }
569 QPtrList<Incidence> delSel = getSelectedIncidences() ; 579 QPtrList<Incidence> delSel = getSelectedIncidences() ;
570 int icount = delSel.count(); 580 int icount = delSel.count();
571 if ( icount ) { 581 if ( icount ) {
572 QString fn = KOPrefs::instance()->mLastSaveFile; 582 QString fn = KOPrefs::instance()->mLastSaveFile;
573 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 583 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
574 584
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index a54b550..99d0561 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -105,212 +105,213 @@ class KOAlarmPrefs : public QDialog
105 105
106 QString mAlarmSound, mAlarmProgram ; 106 QString mAlarmSound, mAlarmProgram ;
107 QCheckBox* mAlarmButton; 107 QCheckBox* mAlarmButton;
108 QSpinBox* mAlarmTimeEdit; 108 QSpinBox* mAlarmTimeEdit;
109 QLabel* mAlarmLabel; 109 QLabel* mAlarmLabel;
110 QComboBox* mAlarmIncrCombo ; 110 QComboBox* mAlarmIncrCombo ;
111 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; 111 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton;
112private slots: 112private slots:
113 113
114void pickAlarmSound() 114void pickAlarmSound()
115{ 115{
116 //QString prefix = mAlarmSound; 116 //QString prefix = mAlarmSound;
117 if (!mAlarmSoundButton->isOn()) { 117 if (!mAlarmSoundButton->isOn()) {
118 //mAlarmSound = ""; 118 //mAlarmSound = "";
119 QToolTip::remove(mAlarmSoundButton); 119 QToolTip::remove(mAlarmSoundButton);
120 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 120 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
121 mAlarmProgramButton->setOn(true); 121 mAlarmProgramButton->setOn(true);
122 mAlarmSoundButton->setOn(false); 122 mAlarmSoundButton->setOn(false);
123 } else { 123 } else {
124 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 124 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
125 i18n("*.wav|Wav Files"), 0)); 125 i18n("*.wav|Wav Files"), 0));
126 if (!fileName.isEmpty()) { 126 if (!fileName.isEmpty()) {
127 mAlarmSound = fileName; 127 mAlarmSound = fileName;
128 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 128 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
129 QToolTip::remove(mAlarmSoundButton); 129 QToolTip::remove(mAlarmSoundButton);
130 QString dispStr = i18n("Playing '%1'").arg(fileName); 130 QString dispStr = i18n("Playing '%1'").arg(fileName);
131 QToolTip::add(mAlarmSoundButton, dispStr); 131 QToolTip::add(mAlarmSoundButton, dispStr);
132 mAlarmProgramButton->setOn(false); 132 mAlarmProgramButton->setOn(false);
133 mAlarmSoundButton->setOn(true); 133 mAlarmSoundButton->setOn(true);
134 } else { 134 } else {
135 mAlarmProgramButton->setOn(true); 135 mAlarmProgramButton->setOn(true);
136 mAlarmSoundButton->setOn(false); 136 mAlarmSoundButton->setOn(false);
137 137
138 } 138 }
139 } 139 }
140}; 140};
141 141
142void pickAlarmProgram() 142void pickAlarmProgram()
143{ 143{
144 if (!mAlarmProgramButton->isOn()) { 144 if (!mAlarmProgramButton->isOn()) {
145 //mAlarmProgram = ""; 145 //mAlarmProgram = "";
146 QToolTip::remove(mAlarmProgramButton); 146 QToolTip::remove(mAlarmProgramButton);
147 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 147 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
148 mAlarmProgramButton->setOn(false); 148 mAlarmProgramButton->setOn(false);
149 mAlarmSoundButton->setOn(true); 149 mAlarmSoundButton->setOn(true);
150 } else { 150 } else {
151 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); 151 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0));
152 if (!fileName.isEmpty()) { 152 if (!fileName.isEmpty()) {
153 mAlarmProgram = fileName; 153 mAlarmProgram = fileName;
154 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 154 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
155 QToolTip::remove(mAlarmProgramButton); 155 QToolTip::remove(mAlarmProgramButton);
156 QString dispStr = i18n("Running '%1'").arg(fileName); 156 QString dispStr = i18n("Running '%1'").arg(fileName);
157 QToolTip::add(mAlarmProgramButton, dispStr); 157 QToolTip::add(mAlarmProgramButton, dispStr);
158 mAlarmSoundButton->setOn(false); 158 mAlarmSoundButton->setOn(false);
159 mAlarmProgramButton->setOn(true); 159 mAlarmProgramButton->setOn(true);
160 } else { 160 } else {
161 mAlarmProgramButton->setOn(false); 161 mAlarmProgramButton->setOn(false);
162 mAlarmSoundButton->setOn(true); 162 mAlarmSoundButton->setOn(true);
163 } 163 }
164 } 164 }
165}; 165};
166 166
167}; 167};
168 168
169 169
170 170
171 171
172 172
173 173
174 174
175typedef CustomListViewItem<Incidence *> KOListViewItem; 175typedef CustomListViewItem<Incidence *> KOListViewItem;
176 176
177/** 177/**
178 This class provides the initialisation of a KOListViewItem for calendar 178 This class provides the initialisation of a KOListViewItem for calendar
179 components using the Incidence::Visitor. 179 components using the Incidence::Visitor.
180*/ 180*/
181class ListItemVisitor : public Incidence::Visitor 181class ListItemVisitor : public Incidence::Visitor
182{ 182{
183 public: 183 public:
184 ListItemVisitor(KOListViewItem *, QDate d); 184 ListItemVisitor(KOListViewItem *, QDate d);
185 ~ListItemVisitor(); 185 ~ListItemVisitor();
186 186
187 bool visit(Event *); 187 bool visit(Event *);
188 bool visit(Todo *); 188 bool visit(Todo *);
189 bool visit(Journal *); 189 bool visit(Journal *);
190 190
191 private: 191 private:
192 KOListViewItem *mItem; 192 KOListViewItem *mItem;
193 QDate mDate; 193 QDate mDate;
194}; 194};
195 195
196/** 196/**
197 This class provides a multi-column list view of events. It can 197 This class provides a multi-column list view of events. It can
198 display events from one particular day or several days, it doesn't 198 display events from one particular day or several days, it doesn't
199 matter. To use a view that only handles one day at a time, use 199 matter. To use a view that only handles one day at a time, use
200 KODayListView. 200 KODayListView.
201 201
202 @short multi-column list view of various events. 202 @short multi-column list view of various events.
203 @author Preston Brown <pbrown@kde.org> 203 @author Preston Brown <pbrown@kde.org>
204 @see KOBaseView, KODayListView 204 @see KOBaseView, KODayListView
205*/ 205*/
206class KOListView; 206class KOListView;
207 207
208class KOListViewListView : public KListView 208class KOListViewListView : public KListView
209{ 209{
210 Q_OBJECT 210 Q_OBJECT
211 public: 211 public:
212 KOListViewListView(KOListView * lv ); 212 KOListViewListView(KOListView * lv );
213 bool hasMultiSelection(QListViewItem*); 213 bool hasMultiSelection(QListViewItem*);
214 void printList(); 214 void printList();
215 signals: 215 signals:
216 void newEvent(); 216 void newEvent();
217 void showIncidence( Incidence* ); 217 void showIncidence( Incidence* );
218 public slots: 218 public slots:
219 void popupMenu(); 219 void popupMenu();
220 private: 220 private:
221 QPoint mEventPos; 221 QPoint mEventPos;
222 QPoint mEventGlobalPos; 222 QPoint mEventGlobalPos;
223 QTimer* mPopupTimer; 223 QTimer* mPopupTimer;
224 int mYMousePos; 224 int mYMousePos;
225 void keyPressEvent ( QKeyEvent * ) ; 225 void keyPressEvent ( QKeyEvent * ) ;
226 void contentsMouseDoubleClickEvent(QMouseEvent *e); 226 void contentsMouseDoubleClickEvent(QMouseEvent *e);
227 void contentsMousePressEvent(QMouseEvent *e); 227 void contentsMousePressEvent(QMouseEvent *e);
228 void contentsMouseReleaseEvent(QMouseEvent *e); 228 void contentsMouseReleaseEvent(QMouseEvent *e);
229 void contentsMouseMoveEvent(QMouseEvent *e); 229 void contentsMouseMoveEvent(QMouseEvent *e);
230 bool mMouseDown; 230 bool mMouseDown;
231}; 231};
232 232
233class KOListView : public KOEventView 233class KOListView : public KOEventView
234{ 234{
235 Q_OBJECT 235 Q_OBJECT
236 public: 236 public:
237 KOListView(Calendar *calendar, QWidget *parent = 0, 237 KOListView(Calendar *calendar, QWidget *parent = 0,
238 const char *name = 0); 238 const char *name = 0);
239 ~KOListView(); 239 ~KOListView();
240 240
241 virtual int maxDatesHint(); 241 virtual int maxDatesHint();
242 virtual int currentDateCount(); 242 virtual int currentDateCount();
243 virtual QPtrList<Incidence> selectedIncidences(); 243 virtual QPtrList<Incidence> selectedIncidences();
244 virtual DateList selectedDates(); 244 virtual DateList selectedDates();
245 245
246 void showDates(bool show); 246 void showDates(bool show);
247 Incidence* currentItem(); 247 Incidence* currentItem();
248 void addTodos(QPtrList<Todo> eventList); 248 void addTodos(QPtrList<Todo> eventList);
249 void addJournals(QPtrList<Journal> eventList); 249 void addJournals(QPtrList<Journal> eventList);
250 virtual void printPreview(CalPrinter *calPrinter, 250 virtual void printPreview(CalPrinter *calPrinter,
251 const QDate &, const QDate &); 251 const QDate &, const QDate &);
252 252
253 void readSettings(KConfig *config, QString setting = "KOListView Layout"); 253 void readSettings(KConfig *config, QString setting = "KOListView Layout");
254 void writeSettings(KConfig *config, QString setting = "KOListView Layout"); 254 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
255 void updateList(); 255 void updateList();
256 void clearList(); 256 void clearList();
257 void setStartDate(const QDate &start); 257 void setStartDate(const QDate &start);
258 int count(); 258 int count();
259 QString getWhatsThisText(QPoint p); 259 QString getWhatsThisText(QPoint p);
260 QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false ); 260 QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false );
261 void showCompletedTodos(); 261 void showCompletedTodos();
262 signals: 262 signals:
263 void signalNewEvent(); 263 void signalNewEvent();
264 void beamIncidenceList(QPtrList<Incidence>); 264 void beamIncidenceList(QPtrList<Incidence>);
265 265
266 public slots: 266 public slots:
267 void hideAll(); 267 void hideAll();
268 void printList(); 268 void printList();
269 void resetFocus(); 269 void resetFocus();
270 virtual void updateView(); 270 virtual void updateView();
271 virtual void showDates(const QDate &start, const QDate &end); 271 virtual void showDates(const QDate &start, const QDate &end);
272 virtual void showEvents(QPtrList<Event> eventList); 272 virtual void showEvents(QPtrList<Event> eventList);
273 void clearSelection(); 273 void clearSelection();
274 void allSelection(); 274 void allSelection();
275 275
276 void clear(); 276 void clear();
277 void showDates(); 277 void showDates();
278 void hideDates(); 278 void hideDates();
279 void deleteAll(); 279 void deleteAll();
280 void saveToFile(); 280 void saveToFile();
281 void saveToFileVCS(); 281 void saveToFileVCS();
282 void saveDescriptionToFile(); 282 void saveDescriptionToFile();
283 void beamSelected(); 283 void beamSelected();
284 void updateConfig(); 284 void updateConfig();
285 void setCat(); 285 void setCat();
286 void setAlarm(); 286 void setAlarm();
287 void setCategories( bool removeOld ); 287 void setCategories( bool removeOld );
288 void changeEventDisplay(Event *, int); 288 void changeEventDisplay(Event *, int);
289 289
290 void defaultItemAction(QListViewItem *item); 290 void defaultItemAction(QListViewItem *item);
291 void popupMenu(QListViewItem *item,const QPoint &,int); 291 void popupMenu(QListViewItem *item,const QPoint &,int);
292 void setCalendar( int c ); 292 void setCalendar( int c );
293 void populateCalPopup(); 293 void populateCalPopup();
294 294
295 protected slots: 295 protected slots:
296 void processSelectionChange(QListViewItem *); 296 void processSelectionChange(QListViewItem *);
297 void catChanged( Incidence* );
297 298
298 protected: 299 protected:
299 void writeToFile( bool iCal ); 300 void writeToFile( bool iCal );
300 void addEvents(QPtrList<Event> eventList); 301 void addEvents(QPtrList<Event> eventList);
301 void addIncidence(Incidence *); 302 void addIncidence(Incidence *);
302 KOListViewItem *getItemForEvent(Incidence *event); 303 KOListViewItem *getItemForEvent(Incidence *event);
303 304
304 private: 305 private:
305 bool mForceShowCompletedTodos; 306 bool mForceShowCompletedTodos;
306 QPopupMenu* mCalPopup; 307 QPopupMenu* mCalPopup;
307 KOListViewWhatsThis *mKOListViewWhatsThis; 308 KOListViewWhatsThis *mKOListViewWhatsThis;
308 KOListViewListView *mListView; 309 KOListViewListView *mListView;
309 KOEventPopupMenu *mPopupMenu; 310 KOEventPopupMenu *mPopupMenu;
310 KOListViewItem *mActiveItem; 311 KOListViewItem *mActiveItem;
311 QDict<Incidence> mUidDict; 312 QDict<Incidence> mUidDict;
312 QDate mStartDate; 313 QDate mStartDate;
313 void keyPressEvent ( QKeyEvent * ) ; 314 void keyPressEvent ( QKeyEvent * ) ;
314}; 315};
315 316
316#endif 317#endif
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 4fc447e..2289977 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -13,426 +13,426 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qwhatsthis.h> 31#include <qwhatsthis.h>
32#ifndef DESKTOP_VERSION 32#ifndef DESKTOP_VERSION
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#else 34#else
35#include <qapplication.h> 35#include <qapplication.h>
36#endif 36#endif
37 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kglobal.h> 40#include <kglobal.h>
41#include <kconfig.h> 41#include <kconfig.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43 43
44#include <kcalendarsystem.h> 44#include <kcalendarsystem.h>
45 45
46#ifndef KORG_NOPRINTER 46#ifndef KORG_NOPRINTER
47#include "calprinter.h" 47#include "calprinter.h"
48#endif 48#endif
49#include "koprefs.h" 49#include "koprefs.h"
50#ifndef KORG_NOPLUGINS 50#ifndef KORG_NOPLUGINS
51#include "kocore.h" 51#include "kocore.h"
52#endif 52#endif
53#include "koglobals.h" 53#include "koglobals.h"
54#include <libkcal/kincidenceformatter.h> 54#include <libkcal/kincidenceformatter.h>
55 55
56#include "komonthview.h" 56#include "komonthview.h"
57 57
58#define PIXMAP_SIZE 5 58#define PIXMAP_SIZE 5
59#ifdef DESKTOP_VERSION 59#ifdef DESKTOP_VERSION
60QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 60QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
61#endif 61#endif
62class KNOWhatsThis :public QWhatsThis 62class KNOWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p) 69 virtual QString text( const QPoint& p)
70 { 70 {
71 return _wid->getWhatsThisText(p) ; 71 return _wid->getWhatsThisText(p) ;
72 }; 72 };
73private: 73private:
74 KNoScrollListBox* _wid; 74 KNoScrollListBox* _wid;
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
80 : QListBox(parent, name, WRepaintNoErase) 80 : QListBox(parent, name, WRepaintNoErase)
81{ 81{
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
84#endif 84#endif
85 mWT = new KNOWhatsThis(this); 85 mWT = new KNOWhatsThis(this);
86 resetOnFocusIn = true; 86 resetOnFocusIn = true;
87 setVScrollBarMode(QScrollView::AlwaysOff); 87 setVScrollBarMode(QScrollView::AlwaysOff);
88 setHScrollBarMode(QScrollView::AlwaysOff); 88 setHScrollBarMode(QScrollView::AlwaysOff);
89} 89}
90KNoScrollListBox::~KNoScrollListBox() 90KNoScrollListBox::~KNoScrollListBox()
91{ 91{
92#if QT_VERSION >= 0x030000 92#if QT_VERSION >= 0x030000
93 93
94#else 94#else
95 delete mWT; 95 delete mWT;
96#endif 96#endif
97} 97}
98 98
99 99
100void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) 100void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
101{ 101{
102 QListBox::focusInEvent ( e ); 102 QListBox::focusInEvent ( e );
103 if ( count() ){ 103 if ( count() ){
104 int ci = currentItem(); 104 int ci = currentItem();
105 if ( ci < 0 ) ci = 0; 105 if ( ci < 0 ) ci = 0;
106 106
107 setCurrentItem( ci ); 107 setCurrentItem( ci );
108 setSelected ( ci, true ); 108 setSelected ( ci, true );
109 emit highlighted( item ( ci ) ); 109 emit highlighted( item ( ci ) );
110 110
111 resetOnFocusIn = true; 111 resetOnFocusIn = true;
112 112
113 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { 113 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
114 QListBoxItem *fi = firstItem (); 114 QListBoxItem *fi = firstItem ();
115 if (fi ) { 115 if (fi ) {
116 int ihei = fi->height( this ); 116 int ihei = fi->height( this );
117 int hei = numRows () * ihei; 117 int hei = numRows () * ihei;
118 if ( hei < height() - horizontalScrollBar()->height () ) { 118 if ( hei < height() - horizontalScrollBar()->height () ) {
119 setVScrollBarMode(QScrollView::AlwaysOff); 119 setVScrollBarMode(QScrollView::AlwaysOff);
120 } 120 }
121 else 121 else
122 setVScrollBarMode(QScrollView::Auto); 122 setVScrollBarMode(QScrollView::Auto);
123 if ( ihei *3 > height() ) { 123 if ( ihei *3 > height() ) {
124 setHScrollBarMode(QScrollView::AlwaysOff); 124 setHScrollBarMode(QScrollView::AlwaysOff);
125 } 125 }
126 else { 126 else {
127 setHScrollBarMode(QScrollView::Auto); 127 setHScrollBarMode(QScrollView::Auto);
128 } 128 }
129 } else { 129 } else {
130 setVScrollBarMode(QScrollView::Auto); 130 setVScrollBarMode(QScrollView::Auto);
131 setHScrollBarMode(QScrollView::Auto); 131 setHScrollBarMode(QScrollView::Auto);
132 } 132 }
133 } 133 }
134 } 134 }
135} 135}
136void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) 136void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
137{ 137{
138 int i = currentItem (); 138 int i = currentItem ();
139 if ( i >= 0 ) { 139 if ( i >= 0 ) {
140 setSelected ( i, false ); 140 setSelected ( i, false );
141 } 141 }
142 QListBox::focusOutEvent ( e ); 142 QListBox::focusOutEvent ( e );
143 setVScrollBarMode(QScrollView::AlwaysOff); 143 setVScrollBarMode(QScrollView::AlwaysOff);
144 setHScrollBarMode(QScrollView::AlwaysOff); 144 setHScrollBarMode(QScrollView::AlwaysOff);
145 emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); 145 emit highlightIncidence( 0, (MonthViewCell*)this, 0 );
146} 146}
147 147
148QString KNoScrollListBox::getWhatsThisText(QPoint p) 148QString KNoScrollListBox::getWhatsThisText(QPoint p)
149{ 149{
150 QListBoxItem* item = itemAt ( p ); 150 QListBoxItem* item = itemAt ( p );
151 if ( ! item ) { 151 if ( ! item ) {
152 return i18n("Click in the cell\nto add an event!"); 152 return i18n("Click in the cell\nto add an event!");
153 } 153 }
154 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 154 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
155 KOPrefs::instance()->mWTshowDetails, 155 KOPrefs::instance()->mWTshowDetails,
156 KOPrefs::instance()->mWTshowCreated, 156 KOPrefs::instance()->mWTshowCreated,
157 KOPrefs::instance()->mWTshowChanged); 157 KOPrefs::instance()->mWTshowChanged);
158} 158}
159void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 159void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
160{ 160{
161 //qDebug("KNoScrollListBox::keyPressEvent "); 161 //qDebug("KNoScrollListBox::keyPressEvent ");
162 switch(e->key()) { 162 switch(e->key()) {
163 case Key_Right: 163 case Key_Right:
164 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 164 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
165 { 165 {
166 e->ignore(); 166 e->ignore();
167 return; 167 return;
168 } 168 }
169 scrollBy(10,0); 169 scrollBy(10,0);
170 break; 170 break;
171 case Key_Left: 171 case Key_Left:
172 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 172 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
173 { 173 {
174 e->ignore(); 174 e->ignore();
175 return; 175 return;
176 } 176 }
177 scrollBy(-10,0); 177 scrollBy(-10,0);
178 break; 178 break;
179 case Key_Up: 179 case Key_Up:
180 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 180 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
181 e->ignore(); 181 e->ignore();
182 break; 182 break;
183 } 183 }
184 if ( count() ) { 184 if ( count() ) {
185 if ( currentItem() == 0 ) { 185 if ( currentItem() == 0 ) {
186 emit prevCell(); 186 emit prevCell();
187 } else { 187 } else {
188 setCurrentItem((currentItem()+count()-1)%count()); 188 setCurrentItem((currentItem()+count()-1)%count());
189 if(!itemVisible(currentItem())) { 189 if(!itemVisible(currentItem())) {
190 if((unsigned int) currentItem() == (count()-1)) { 190 if((unsigned int) currentItem() == (count()-1)) {
191 setTopItem(currentItem()-numItemsVisible()+1); 191 setTopItem(currentItem()-numItemsVisible()+1);
192 } else { 192 } else {
193 setTopItem(topItem()-1); 193 setTopItem(topItem()-1);
194 } 194 }
195 } 195 }
196 } 196 }
197 } 197 }
198 break; 198 break;
199 case Key_Down: 199 case Key_Down:
200 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 200 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
201 e->ignore(); 201 e->ignore();
202 break; 202 break;
203 } 203 }
204 if ( count () ) { 204 if ( count () ) {
205 if ( currentItem()+1 == count () ) { 205 if ( ((uint)currentItem()+1) == count () ) {
206 emit nextCell(); 206 emit nextCell();
207 } else { 207 } else {
208 setCurrentItem((currentItem()+1)%count()); 208 setCurrentItem((currentItem()+1)%count());
209 if(!itemVisible(currentItem())) { 209 if(!itemVisible(currentItem())) {
210 if(currentItem() == 0) { 210 if(currentItem() == 0) {
211 setTopItem(0); 211 setTopItem(0);
212 } else { 212 } else {
213 setTopItem(topItem()+1); 213 setTopItem(topItem()+1);
214 } 214 }
215 } 215 }
216 } 216 }
217 } 217 }
218 break; 218 break;
219 case Key_I: 219 case Key_I:
220 QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); 220 QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
221 e->ignore(); 221 e->ignore();
222 break; 222 break;
223 case Key_Return: 223 case Key_Return:
224 case Key_Enter: 224 case Key_Enter:
225 { 225 {
226 if ( currentItem() >= 0 ) { 226 if ( currentItem() >= 0 ) {
227 emit doubleClicked( item( currentItem() ) ); 227 emit doubleClicked( item( currentItem() ) );
228 e->accept(); 228 e->accept();
229 } else { 229 } else {
230 e->ignore(); 230 e->ignore();
231 } 231 }
232 } 232 }
233 break; 233 break;
234 case Key_Shift: 234 case Key_Shift:
235 emit shiftDown(); 235 emit shiftDown();
236 break; 236 break;
237 default: 237 default:
238 e->ignore(); 238 e->ignore();
239 break; 239 break;
240 } 240 }
241} 241}
242 242
243void KNoScrollListBox::oneDown() 243void KNoScrollListBox::oneDown()
244{ 244{
245 if ( count () ) { 245 if ( count () ) {
246 if ( currentItem()+1 == count () ) { 246 if ( ((uint)currentItem()+1) == count () ) {
247 emit nextCell(); 247 emit nextCell();
248 } else { 248 } else {
249 resetOnFocusIn = false; 249 resetOnFocusIn = false;
250 setCurrentItem((currentItem()+1)%count()); 250 setCurrentItem((currentItem()+1)%count());
251 if(!itemVisible(currentItem())) { 251 if(!itemVisible(currentItem())) {
252 if(currentItem() == 0) { 252 if(currentItem() == 0) {
253 setTopItem(0); 253 setTopItem(0);
254 } else { 254 } else {
255 setTopItem(topItem()+1); 255 setTopItem(topItem()+1);
256 } 256 }
257 } 257 }
258 } 258 }
259 } 259 }
260} 260}
261void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 261void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
262{ 262{
263 switch(e->key()) { 263 switch(e->key()) {
264 case Key_Shift: 264 case Key_Shift:
265 emit shiftUp(); 265 emit shiftUp();
266 break; 266 break;
267 default: 267 default:
268 break; 268 break;
269 } 269 }
270} 270}
271 271
272void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 272void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
273{ 273{
274 QListBox::mousePressEvent(e); 274 QListBox::mousePressEvent(e);
275 275
276 if(e->button() == RightButton) { 276 if(e->button() == RightButton) {
277 emit rightClick(); 277 emit rightClick();
278 } 278 }
279} 279}
280 280
281MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) 281MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s)
282 : QListBoxItem() 282 : QListBoxItem()
283{ 283{
284 mblockRepaint = true; 284 mblockRepaint = true;
285 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 285 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
286 recycle( incidence, s ); 286 recycle( incidence, s );
287} 287}
288void MonthViewItem::recycle( Incidence *incidence, const QString & s) 288void MonthViewItem::recycle( Incidence *incidence, const QString & s)
289{ 289{
290 mDisplayHighlighted = false; 290 mDisplayHighlighted = false;
291 setText( s ); 291 setText( s );
292 mMultiday = 0; 292 mMultiday = 0;
293 mIncidence = incidence; 293 mIncidence = incidence;
294 mRecur = false; 294 mRecur = false;
295 mAlarm = false; 295 mAlarm = false;
296 mReply = false; 296 mReply = false;
297 mInfo = false; 297 mInfo = false;
298 mdayPos = 0; 298 mdayPos = 0;
299} 299}
300 300
301bool MonthViewItem::setHighlightedFalse() 301bool MonthViewItem::setHighlightedFalse()
302{ 302{
303 if ( !mDisplayHighlighted ) 303 if ( !mDisplayHighlighted )
304 return false; 304 return false;
305 mDisplayHighlighted = false; 305 mDisplayHighlighted = false;
306 return true; 306 return true;
307} 307}
308 308
309bool MonthViewItem::setHighlighted( Incidence * inc ) 309bool MonthViewItem::setHighlighted( Incidence * inc )
310{ 310{
311 if ( inc == mIncidence ) { 311 if ( inc == mIncidence ) {
312 if ( mDisplayHighlighted ) 312 if ( mDisplayHighlighted )
313 return false; 313 return false;
314 mDisplayHighlighted = true; 314 mDisplayHighlighted = true;
315 return true; 315 return true;
316 } else { 316 } else {
317 if ( !mDisplayHighlighted ) 317 if ( !mDisplayHighlighted )
318 return false; 318 return false;
319 mDisplayHighlighted = false; 319 mDisplayHighlighted = false;
320 return true; 320 return true;
321 } 321 }
322 return false; 322 return false;
323} 323}
324void MonthViewItem::paint(QPainter *p) 324void MonthViewItem::paint(QPainter *p)
325{ 325{
326 if ( mblockRepaint || !mIncidence ) { 326 if ( mblockRepaint || !mIncidence ) {
327 return; 327 return;
328 } 328 }
329#if QT_VERSION >= 0x030000 329#if QT_VERSION >= 0x030000
330 bool sel = isSelected(); 330 bool sel = isSelected();
331#else 331#else
332 bool sel = selected(); 332 bool sel = selected();
333#endif 333#endif
334 int heihei = height( listBox () ); 334 int heihei = height( listBox () );
335 int x = 1; 335 int x = 1;
336 if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel ) 336 if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel )
337 { 337 {
338 338
339 p->setBackgroundColor( palette().color( QPalette::Normal, \ 339 p->setBackgroundColor( palette().color( QPalette::Normal, \
340 sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); 340 sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) );
341 p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); 341 p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei );
342 } 342 }
343 343
344 //int y = 3;//(height() - mRecurPixmap.height()) /2; 344 //int y = 3;//(height() - mRecurPixmap.height()) /2;
345 int size = PIXMAP_SIZE; 345 int size = PIXMAP_SIZE;
346 if ( QApplication::desktop()->width() < 300 ) 346 if ( QApplication::desktop()->width() < 300 )
347 size = 3; 347 size = 3;
348 int y = (heihei - size -1 ) /2; 348 int y = (heihei - size -1 ) /2;
349 349
350 if ( mIncidence->calID() > 1 ) { 350 if ( mIncidence->calID() > 1 ) {
351 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); 351 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) );
352 p->drawRect ( x, y-2,size,size+4); 352 p->drawRect ( x, y-2,size,size+4);
353 x += size + 1; 353 x += size + 1;
354 } 354 }
355 if ( KOPrefs::instance()->mMonthShowIcons ) { 355 if ( KOPrefs::instance()->mMonthShowIcons ) {
356 if ( mInfo ) { 356 if ( mInfo ) {
357 p->fillRect ( x, y,size,size, Qt::darkGreen ); 357 p->fillRect ( x, y,size,size, Qt::darkGreen );
358 x += size + 1; 358 x += size + 1;
359 } 359 }
360 if ( mRecur ) { 360 if ( mRecur ) {
361 p->fillRect ( x, y,size,size, Qt::blue ); 361 p->fillRect ( x, y,size,size, Qt::blue );
362 x += size + 1; 362 x += size + 1;
363 } 363 }
364 if ( mAlarm ) { 364 if ( mAlarm ) {
365 p->fillRect ( x, y,size,size, Qt::red ); 365 p->fillRect ( x, y,size,size, Qt::red );
366 x += size + 1; 366 x += size + 1;
367 } 367 }
368 if ( mReply ) { 368 if ( mReply ) {
369 p->fillRect ( x, y,size,size, Qt::yellow ); 369 p->fillRect ( x, y,size,size, Qt::yellow );
370 x += size + 1; 370 x += size + 1;
371 } 371 }
372 } 372 }
373 373
374 374
375 375
376 376
377 if ( sel ) p->setPen( Qt::white ); 377 if ( sel ) p->setPen( Qt::white );
378 else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); 378 else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) );
379 379
380#if 0 380#if 0
381 p->setPen( palette().color( QPalette::Normal, sel ? \ 381 p->setPen( palette().color( QPalette::Normal, sel ? \
382 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 382 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
383#endif 383#endif
384 QColor textColor = p->pen().color(); 384 QColor textColor = p->pen().color();
385 385
386 386
387 if ( mMultiday ) { 387 if ( mMultiday ) {
388 int yyy = y+(size/2); 388 int yyy = y+(size/2);
389 int sizeM = size+2; 389 int sizeM = size+2;
390 p->setBrush( QBrush( textColor ) ); 390 p->setBrush( QBrush( textColor ) );
391 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 391 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
392 if ( mMultiday == 2 || mMultiday == 3 ) { 392 if ( mMultiday == 2 || mMultiday == 3 ) {
393 QPointArray pa ( 3 ); 393 QPointArray pa ( 3 );
394 pa.setPoint (0, x, yyy ); 394 pa.setPoint (0, x, yyy );
395 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 395 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
396 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 396 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
397 p->drawPolygon( pa ); 397 p->drawPolygon( pa );
398 } 398 }
399 if ( mMultiday == 2 || mMultiday == 1 ) { 399 if ( mMultiday == 2 || mMultiday == 1 ) {
400 QPointArray pa ( 3 ); 400 QPointArray pa ( 3 );
401 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 401 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
402 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 402 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
403 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 403 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
404 p->drawPolygon( pa ); 404 p->drawPolygon( pa );
405 } 405 }
406 if ( mMultiday == 1 ) { 406 if ( mMultiday == 1 ) {
407 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 407 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
408 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 408 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
409 } 409 }
410 if ( mMultiday == 3 ) { 410 if ( mMultiday == 3 ) {
411 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 411 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
412 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 412 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
413 413
414 } 414 }
415 x += sizeM/2 + 1; 415 x += sizeM/2 + 1;
416 x += sizeM + 1; 416 x += sizeM + 1;
417 } 417 }
418 418
419 if ( mIncidence->typeID() == todoID ){ 419 if ( mIncidence->typeID() == todoID ){
420 Todo* td = ( Todo* ) mIncidence; 420 Todo* td = ( Todo* ) mIncidence;
421 if ( td->isCompleted() ) { 421 if ( td->isCompleted() ) {
422 int half = size/2; 422 int half = size/2;
423 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 423 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
424 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 424 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
425 x += half+half + 4; 425 x += half+half + 4;
426 426
427 } else { 427 } else {
428 int val = td->percentComplete()/20; 428 int val = td->percentComplete()/20;
429 p->fillRect ( x+1, y-2, val ,size+4,textColor ); 429 p->fillRect ( x+1, y-2, val ,size+4,textColor );
430 p->drawRect ( x, y-2,7,size+4); 430 p->drawRect ( x, y-2,7,size+4);
431 x += size + 3; 431 x += size + 3;
432 } 432 }
433 } 433 }
434 QFontMetrics fm = p->fontMetrics(); 434 QFontMetrics fm = p->fontMetrics();
435 int yPos; 435 int yPos;
436 int pmheight = size; 436 int pmheight = size;
437 if( pmheight < fm.height() ) 437 if( pmheight < fm.height() )
438 yPos = fm.ascent() + fm.leading()/2; 438 yPos = fm.ascent() + fm.leading()/2;
@@ -1103,1148 +1103,1153 @@ void MonthViewCell::contextMenu( QListBoxItem *item )
1103 mMonthView->setPopupCell( this ); 1103 mMonthView->setPopupCell( this );
1104 if ( !item ) { 1104 if ( !item ) {
1105 mMonthView->showContextMenu( 0 ); 1105 mMonthView->showContextMenu( 0 );
1106 return; 1106 return;
1107 } 1107 }
1108 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1108 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1109 Incidence *incidence = eventItem->incidence(); 1109 Incidence *incidence = eventItem->incidence();
1110 if ( incidence ) mMonthView->showContextMenu( incidence ); 1110 if ( incidence ) mMonthView->showContextMenu( incidence );
1111} 1111}
1112 1112
1113void MonthViewCell::selection( QListBoxItem *item ) 1113void MonthViewCell::selection( QListBoxItem *item )
1114{ 1114{
1115 if ( !item ) { 1115 if ( !item ) {
1116 emit highlightIncidence( 0 , this, 0 ); 1116 emit highlightIncidence( 0 , this, 0 );
1117 return; 1117 return;
1118 } 1118 }
1119 MonthViewItem * it = (static_cast<MonthViewItem *>( item )); 1119 MonthViewItem * it = (static_cast<MonthViewItem *>( item ));
1120 emit highlightIncidence( it->incidence(), this, it->multiDay() ); 1120 emit highlightIncidence( it->incidence(), this, it->multiDay() );
1121 mMonthView->setSelectedCell( this ); 1121 mMonthView->setSelectedCell( this );
1122} 1122}
1123 1123
1124void MonthViewCell::deHighLight() 1124void MonthViewCell::deHighLight()
1125{ 1125{
1126 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 1126 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
1127 while ( mitem ) { 1127 while ( mitem ) {
1128 if ( mitem->setHighlightedFalse() ) 1128 if ( mitem->setHighlightedFalse() )
1129 updateItem ( mitem ); 1129 updateItem ( mitem );
1130 mitem = (MonthViewItem *)mitem->next(); 1130 mitem = (MonthViewItem *)mitem->next();
1131 } 1131 }
1132} 1132}
1133// returns true if no inc found 1133// returns true if no inc found
1134bool MonthViewCell::doHighLight( Incidence * inc ) 1134bool MonthViewCell::doHighLight( Incidence * inc )
1135{ 1135{
1136 1136
1137 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 1137 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
1138 while ( mitem ) { 1138 while ( mitem ) {
1139 if ( mitem->incidence() == inc ) { 1139 if ( mitem->incidence() == inc ) {
1140 if ( mitem->setHighlighted( inc ) ) 1140 if ( mitem->setHighlighted( inc ) )
1141 updateItem ( mitem ); 1141 updateItem ( mitem );
1142 return false; 1142 return false;
1143 } 1143 }
1144 mitem = (MonthViewItem *)mitem->next(); 1144 mitem = (MonthViewItem *)mitem->next();
1145 } 1145 }
1146 return true; 1146 return true;
1147} 1147}
1148// ******************************************************************************* 1148// *******************************************************************************
1149// ******************************************************************************* 1149// *******************************************************************************
1150// ******************************************************************************* 1150// *******************************************************************************
1151 1151
1152 1152
1153KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1153KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1154 : KOEventView( calendar, parent, name ), 1154 : KOEventView( calendar, parent, name ),
1155 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1155 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1156 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1156 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1157{ 1157{
1158 mFlagKeyPressed = false; 1158 mFlagKeyPressed = false;
1159 mShortDayLabelsM = false; 1159 mShortDayLabelsM = false;
1160 mShortDayLabelsW = false; 1160 mShortDayLabelsW = false;
1161 skipResize = false; 1161 skipResize = false;
1162 clPending = true; 1162 clPending = true;
1163 mPopupCell = 0; 1163 mPopupCell = 0;
1164 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1164 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1165 mWidStack = new QWidgetStack( this ); 1165 mWidStack = new QWidgetStack( this );
1166 QVBoxLayout* hb = new QVBoxLayout( this ); 1166 QVBoxLayout* hb = new QVBoxLayout( this );
1167 mMonthView = new QWidget( mWidStack ); 1167 mMonthView = new QWidget( mWidStack );
1168 mWeekView = new QWidget( mWidStack ); 1168 mWeekView = new QWidget( mWidStack );
1169#if QT_VERSION >= 0x030000 1169#if QT_VERSION >= 0x030000
1170 mWidStack->addWidget(mMonthView ); 1170 mWidStack->addWidget(mMonthView );
1171 mWidStack->addWidget(mWeekView ); 1171 mWidStack->addWidget(mWeekView );
1172#else 1172#else
1173 mWidStack->addWidget( mMonthView, 1 ); 1173 mWidStack->addWidget( mMonthView, 1 );
1174 mWidStack->addWidget( mWeekView , 1 ); 1174 mWidStack->addWidget( mWeekView , 1 );
1175#endif 1175#endif
1176 hb->addWidget( mNavigatorBar ); 1176 hb->addWidget( mNavigatorBar );
1177 hb->addWidget( mWidStack ); 1177 hb->addWidget( mWidStack );
1178 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1178 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1179 updatePossible = false; 1179 updatePossible = false;
1180 //updatePossible = true; 1180 //updatePossible = true;
1181 mCells.setAutoDelete( true ); 1181 mCells.setAutoDelete( true );
1182 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1182 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1183 mDayLabels.resize( mDaysPerWeek ); 1183 mDayLabels.resize( mDaysPerWeek );
1184 mDayLabelsW.resize( mDaysPerWeek ); 1184 mDayLabelsW.resize( mDaysPerWeek );
1185 QFont bfont = font(); 1185 QFont bfont = font();
1186 if ( QApplication::desktop()->width() < 650 ) { 1186 if ( QApplication::desktop()->width() < 650 ) {
1187 bfont.setPointSize( bfont.pointSize() - 2 ); 1187 bfont.setPointSize( bfont.pointSize() - 2 );
1188 } 1188 }
1189 bfont.setBold( true ); 1189 bfont.setBold( true );
1190 int i; 1190 int i;
1191 1191
1192 for( i = 0; i < mDaysPerWeek; i++ ) { 1192 for( i = 0; i < mDaysPerWeek; i++ ) {
1193 QLabel *label = new QLabel( mMonthView ); 1193 QLabel *label = new QLabel( mMonthView );
1194 label->setFont(bfont); 1194 label->setFont(bfont);
1195 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1195 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1196 label->setLineWidth(1); 1196 label->setLineWidth(1);
1197 label->setAlignment(AlignCenter); 1197 label->setAlignment(AlignCenter);
1198 mDayLabels.insert( i, label ); 1198 mDayLabels.insert( i, label );
1199 label = new QLabel( mWeekView ); 1199 label = new QLabel( mWeekView );
1200 label->setFont(bfont); 1200 label->setFont(bfont);
1201 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1201 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1202 label->setLineWidth(1); 1202 label->setLineWidth(1);
1203 label->setAlignment(AlignCenter); 1203 label->setAlignment(AlignCenter);
1204 mDayLabelsW.insert( i, label ); 1204 mDayLabelsW.insert( i, label );
1205 } 1205 }
1206 1206
1207 bfont.setBold( false ); 1207 bfont.setBold( false );
1208 mWeekLabels.resize( mNumWeeks+1 ); 1208 mWeekLabels.resize( mNumWeeks+1 );
1209 mWeekLabelsW.resize( 2 ); 1209 mWeekLabelsW.resize( 2 );
1210 for( i = 0; i < mNumWeeks+1; i++ ) { 1210 for( i = 0; i < mNumWeeks+1; i++ ) {
1211 KOWeekButton *label = new KOWeekButton( mMonthView ); 1211 KOWeekButton *label = new KOWeekButton( mMonthView );
1212 label->setFocusPolicy(NoFocus); 1212 label->setFocusPolicy(NoFocus);
1213 label->setFont(bfont); 1213 label->setFont(bfont);
1214 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1214 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1215 label->setFlat(true); 1215 label->setFlat(true);
1216 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1216 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1217 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1217 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1218 //label->setLineWidth(1); 1218 //label->setLineWidth(1);
1219 //label->setAlignment(AlignCenter); 1219 //label->setAlignment(AlignCenter);
1220 mWeekLabels.insert( i, label ); 1220 mWeekLabels.insert( i, label );
1221 } 1221 }
1222 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1222 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1223 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 1223 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1224 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1224 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1225 1225
1226 for( i = 0; i < 1+1; i++ ) { 1226 for( i = 0; i < 1+1; i++ ) {
1227 KOWeekButton *label = new KOWeekButton( mWeekView ); 1227 KOWeekButton *label = new KOWeekButton( mWeekView );
1228 label->setFocusPolicy(NoFocus); 1228 label->setFocusPolicy(NoFocus);
1229 label->setFont(bfont); 1229 label->setFont(bfont);
1230 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1230 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1231 label->setFlat(true); 1231 label->setFlat(true);
1232 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1232 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1233 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1233 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1234 //label->setLineWidth(1); 1234 //label->setLineWidth(1);
1235 //label->setAlignment(AlignCenter); 1235 //label->setAlignment(AlignCenter);
1236 mWeekLabelsW.insert( i, label ); 1236 mWeekLabelsW.insert( i, label );
1237 } 1237 }
1238 mWeekLabelsW[1]->setText( i18n("W")); 1238 mWeekLabelsW[1]->setText( i18n("W"));
1239 mWeekLabelsW[1]->setFocusPolicy(WheelFocus); 1239 mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
1240 1240
1241 1241
1242 int row, col; 1242 int row, col;
1243 mCells.resize( mNumCells ); 1243 mCells.resize( mNumCells );
1244 for( row = 0; row < mNumWeeks; ++row ) { 1244 for( row = 0; row < mNumWeeks; ++row ) {
1245 for( col = 0; col < mDaysPerWeek; ++col ) { 1245 for( col = 0; col < mDaysPerWeek; ++col ) {
1246 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1246 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1247 mCells.insert( row * mDaysPerWeek + col, cell ); 1247 mCells.insert( row * mDaysPerWeek + col, cell );
1248 1248
1249 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1249 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1250 SLOT( defaultAction( Incidence * ) ) ); 1250 SLOT( defaultAction( Incidence * ) ) );
1251 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1251 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1252 SIGNAL( newEventSignal( QDateTime ) ) ); 1252 SIGNAL( newEventSignal( QDateTime ) ) );
1253 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1253 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1254 SIGNAL( showDaySignal( QDate ) ) ); 1254 SIGNAL( showDaySignal( QDate ) ) );
1255 connect( cell, SIGNAL( nextCell() ), 1255 connect( cell, SIGNAL( nextCell() ),
1256 SLOT( nextCell() ) ); 1256 SLOT( nextCell() ) );
1257 connect( cell, SIGNAL( prevCell() ), 1257 connect( cell, SIGNAL( prevCell() ),
1258 SLOT( prevCell() ) ); 1258 SLOT( prevCell() ) );
1259 connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), 1259 connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ),
1260 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); 1260 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) ));
1261 } 1261 }
1262 } 1262 }
1263 mCellsW.resize( mDaysPerWeek ); 1263 mCellsW.resize( mDaysPerWeek );
1264 for( col = 0; col < mDaysPerWeek; ++col ) { 1264 for( col = 0; col < mDaysPerWeek; ++col ) {
1265 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1265 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1266 mCellsW.insert( col, cell ); 1266 mCellsW.insert( col, cell );
1267 1267
1268 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1268 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1269 SLOT( defaultAction( Incidence * ) ) ); 1269 SLOT( defaultAction( Incidence * ) ) );
1270 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1270 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1271 SIGNAL( newEventSignal( QDateTime ) ) ); 1271 SIGNAL( newEventSignal( QDateTime ) ) );
1272 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1272 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1273 SIGNAL( showDaySignal( QDate ) ) ); 1273 SIGNAL( showDaySignal( QDate ) ) );
1274 connect( cell, SIGNAL( nextCell() ), 1274 connect( cell, SIGNAL( nextCell() ),
1275 SLOT( nextCell() ) ); 1275 SLOT( nextCell() ) );
1276 connect( cell, SIGNAL( prevCell() ), 1276 connect( cell, SIGNAL( prevCell() ),
1277 SLOT( prevCell() ) ); 1277 SLOT( prevCell() ) );
1278 connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), 1278 connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ),
1279 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); 1279 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) ));
1280 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1280 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1281 } 1281 }
1282 1282
1283 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1283 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1284 mContextMenu = eventPopup(); 1284 mContextMenu = eventPopup();
1285 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1285 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1286 i18n("New Event..."),this, 1286 i18n("New Event..."),this,
1287 SLOT(slotNewEvent()),false); 1287 SLOT(slotNewEvent()),false);
1288 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1288 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1289 i18n("New Todo..."),this, 1289 i18n("New Todo..."),this,
1290 SLOT(slotNewTodo()),false); 1290 SLOT(slotNewTodo()),false);
1291 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1291 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1292 i18n("Journal"),this, 1292 i18n("Journal"),this,
1293 SLOT(slotEditJournal()),false); 1293 SLOT(slotEditJournal()),false);
1294 1294
1295 connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this,
1296 SLOT( catChanged( Incidence * ) ));
1295 1297
1296 1298
1297 QString pathString = ""; 1299 QString pathString = "";
1298 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 1300 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
1299 if ( QApplication::desktop()->width() < 480 ) 1301 if ( QApplication::desktop()->width() < 480 )
1300 pathString += "icons16/"; 1302 pathString += "icons16/";
1301 } else 1303 } else
1302 pathString += "iconsmini/"; 1304 pathString += "iconsmini/";
1303 mNewItemMenu = new QPopupMenu( this ); 1305 mNewItemMenu = new QPopupMenu( this );
1304 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); 1306 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent()));
1305 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); 1307 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false);
1306 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); 1308 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false);
1307 1309
1308 // updateConfig(); //useless here... 1310 // updateConfig(); //useless here...
1309 // ... but we need mWidthLongDayLabel computed 1311 // ... but we need mWidthLongDayLabel computed
1310 QFontMetrics fontmetric(mDayLabels[0]->font()); 1312 QFontMetrics fontmetric(mDayLabels[0]->font());
1311 mWidthLongDayLabel = 0; 1313 mWidthLongDayLabel = 0;
1312 for (int i = 0; i < 7; i++) { 1314 for (int i = 0; i < 7; i++) {
1313 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1315 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1314 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1316 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1315 } 1317 }
1316 1318
1317 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1319 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1318 1320
1319#if 0 1321#if 0
1320 if ( mShowWeekView ) 1322 if ( mShowWeekView )
1321 mWidStack->raiseWidget( mWeekView ); 1323 mWidStack->raiseWidget( mWeekView );
1322 else 1324 else
1323 mWidStack->raiseWidget( mMonthView ); 1325 mWidStack->raiseWidget( mMonthView );
1324#endif 1326#endif
1325 1327
1326 emit incidenceSelected( 0 ); 1328 emit incidenceSelected( 0 );
1327 1329
1328 mComputeLayoutTimer = new QTimer( this ); 1330 mComputeLayoutTimer = new QTimer( this );
1329 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1331 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1330 1332
1331 1333
1332#ifndef DESKTOP_VERSION 1334#ifndef DESKTOP_VERSION
1333 resize( QApplication::desktop()->size() ); 1335 resize( QApplication::desktop()->size() );
1334#else 1336#else
1335 resize(640, 480 ); 1337 resize(640, 480 );
1336 updatePossible = true; 1338 updatePossible = true;
1337#endif 1339#endif
1338 computeLayout(); 1340 computeLayout();
1339 1341
1340 if ( mShowWeekView ) 1342 if ( mShowWeekView )
1341 mWidStack->raiseWidget( mWeekView ); 1343 mWidStack->raiseWidget( mWeekView );
1342 else 1344 else
1343 mWidStack->raiseWidget( mMonthView ); 1345 mWidStack->raiseWidget( mMonthView );
1344} 1346}
1345 1347
1346KOMonthView::~KOMonthView() 1348KOMonthView::~KOMonthView()
1347{ 1349{
1348 delete mContextMenu; 1350 delete mContextMenu;
1349} 1351}
1350 1352
1353void KOMonthView::catChanged( Incidence * )
1354{
1355 updateView();
1356}
1351void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) 1357void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday )
1352{ 1358{
1353 static Incidence * lastInc = 0; 1359 static Incidence * lastInc = 0;
1354 static MonthViewCell * lastCell = 0; 1360 static MonthViewCell * lastCell = 0;
1355 1361
1356 if ( lastInc == inc && lastCell == mc ) 1362 if ( lastInc == inc && lastCell == mc )
1357 return; 1363 return;
1358 lastInc = inc; 1364 lastInc = inc;
1359 lastCell = mc; 1365 lastCell = mc;
1360 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); 1366 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday );
1361 1367
1362 bool weekview = false; 1368 bool weekview = false;
1363 int index = 0; 1369 uint index = 0;
1364 for (uint i = 0; i < mCellsW.count(); ++i) { 1370 for (uint i = 0; i < mCellsW.count(); ++i) {
1365 if ( mCellsW[i] == mc ) { 1371 if ( mCellsW[i] == mc ) {
1366 weekview = true; 1372 weekview = true;
1367 index = i; 1373 index = i;
1368 break; 1374 break;
1369 } 1375 }
1370 } 1376 }
1371 QPtrVector<MonthViewCell> *cells; 1377 QPtrVector<MonthViewCell> *cells;
1372 if ( weekview ) 1378 if ( weekview )
1373 cells = &mCellsW; 1379 cells = &mCellsW;
1374 else { 1380 else {
1375 for (uint i = 0; i < mCells.count(); ++i) { 1381 for (uint i = 0; i < mCells.count(); ++i) {
1376 if ( mCells[i] == mc ) { 1382 if ( mCells[i] == mc ) {
1377 index = i; 1383 index = i;
1378 break; 1384 break;
1379 } 1385 }
1380 } 1386 }
1381 cells = &mCells; 1387 cells = &mCells;
1382 } 1388 }
1383 for (uint i = 0; i < (*cells).count(); ++i) { 1389 for (uint i = 0; i < (*cells).count(); ++i) {
1384 (*cells)[i]->deHighLight(); 1390 (*cells)[i]->deHighLight();
1385 } 1391 }
1386 if ( ! inc ) 1392 if ( ! inc )
1387 return; 1393 return;
1388 1394
1389 int count = (*cells).count(); 1395 uint count = (*cells).count();
1390 bool goLeft = (mday > 1 && index > 0); 1396 bool goLeft = (mday > 1 && index > 0);
1391 bool goRight = (mday < 3 && mday > 0 && index < count -1); 1397 bool goRight = (mday < 3 && mday > 0 && index < count -1);
1392 for (uint iii = 1; iii < count; ++iii) { 1398 for (uint iii = 1; iii < count; ++iii) {
1393 if ( goLeft ) { 1399 if ( goLeft ) {
1394 int left = index - iii; 1400 int left = index - iii;
1395 if ( left >= 0 ) { 1401 if ( left >= 0 ) {
1396 if ( (*cells)[(uint)left]->doHighLight(inc) ) 1402 if ( (*cells)[(uint)left]->doHighLight(inc) )
1397 goLeft = false; 1403 goLeft = false;
1398 } else 1404 } else
1399 goLeft = false; 1405 goLeft = false;
1400 } 1406 }
1401 if ( goRight ) { 1407 if ( goRight ) {
1402 int right = index + iii; 1408 uint right = index + iii;
1403 if ( right < count ) { 1409 if ( right < count ) {
1404 if ( (*cells)[right]->doHighLight(inc) ) 1410 if ( (*cells)[right]->doHighLight(inc) )
1405 goRight = false; 1411 goRight = false;
1406 1412
1407 } else 1413 } else
1408 goRight = false; 1414 goRight = false;
1409 } 1415 }
1410 1416
1411 } 1417 }
1412#if 0 1418#if 0
1413 if ( mday > 1 && index > 0 ) 1419 if ( mday > 1 && index > 0 )
1414 for (int i = index-1; i >= 0; --i) { 1420 for (int i = index-1; i >= 0; --i) {
1415 //qDebug("index %d iii %d ", index, i); 1421 //qDebug("index %d iii %d ", index, i);
1416 if ( (*cells)[(uint)i]->doHighLight(inc) ) 1422 if ( (*cells)[(uint)i]->doHighLight(inc) )
1417 break; 1423 break;
1418 } 1424 }
1419 if ( mday < 3 && mday > 0 && index < (*cells).count()-1) 1425 if ( mday < 3 && mday > 0 && index < (*cells).count()-1)
1420 for (uint i = index+1; i < (*cells).count(); ++i) { 1426 for (uint i = index+1; i < (*cells).count(); ++i) {
1421 if ( (*cells)[i]->doHighLight(inc) ) 1427 if ( (*cells)[i]->doHighLight(inc) )
1422 break; 1428 break;
1423 } 1429 }
1424#endif 1430#endif
1425 1431
1426} 1432}
1427void KOMonthView::selectInternalWeekNum ( int n ) 1433void KOMonthView::selectInternalWeekNum ( int n )
1428{ 1434{
1429 switchView(); 1435 switchView();
1430 if ( !KOPrefs::instance()->mMonthViewWeek ) 1436 if ( !KOPrefs::instance()->mMonthViewWeek )
1431 emit selectMonth (); 1437 emit selectMonth ();
1432 else 1438 else
1433 emit selectWeekNum ( n ); 1439 emit selectWeekNum ( n );
1434} 1440}
1435 1441
1436int KOMonthView::currentWeek() 1442int KOMonthView::currentWeek()
1437{ 1443{
1438 if ( mShowWeekView ) 1444 if ( mShowWeekView )
1439 return mWeekLabelsW[0]->getWeekNum(); 1445 return mWeekLabelsW[0]->getWeekNum();
1440 return mWeekLabels[0]->getWeekNum(); 1446 return mWeekLabels[0]->getWeekNum();
1441} 1447}
1442void KOMonthView::switchView() 1448void KOMonthView::switchView()
1443{ 1449{
1444 if ( selectedCell( ) ) 1450 if ( selectedCell( ) )
1445 selectedCell()->deselect(); 1451 selectedCell()->deselect();
1446 mShowWeekView = !mShowWeekView; 1452 mShowWeekView = !mShowWeekView;
1447 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1453 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1448 if ( clPending ) { 1454 if ( clPending ) {
1449 computeLayout(); 1455 computeLayout();
1450 updateConfig(); 1456 updateConfig();
1451 } 1457 }
1452 if ( mShowWeekView ) 1458 if ( mShowWeekView )
1453 mWidStack->raiseWidget( mWeekView ); 1459 mWidStack->raiseWidget( mWeekView );
1454 else 1460 else
1455 mWidStack->raiseWidget( mMonthView ); 1461 mWidStack->raiseWidget( mMonthView );
1456 clPending = false; 1462 clPending = false;
1457} 1463}
1458 1464
1459int KOMonthView::maxDatesHint() 1465int KOMonthView::maxDatesHint()
1460{ 1466{
1461 return mNumCells; 1467 return mNumCells;
1462} 1468}
1463 1469
1464int KOMonthView::currentDateCount() 1470int KOMonthView::currentDateCount()
1465{ 1471{
1466 return mNumCells; 1472 return mNumCells;
1467} 1473}
1468 1474
1469QPtrList<Incidence> KOMonthView::selectedIncidences() 1475QPtrList<Incidence> KOMonthView::selectedIncidences()
1470{ 1476{
1471 QPtrList<Incidence> selected; 1477 QPtrList<Incidence> selected;
1472 1478
1473 if ( mSelectedCell ) { 1479 if ( mSelectedCell ) {
1474 Incidence *incidence = mSelectedCell->selectedIncidence(); 1480 Incidence *incidence = mSelectedCell->selectedIncidence();
1475 if ( incidence ) selected.append( incidence ); 1481 if ( incidence ) selected.append( incidence );
1476 } 1482 }
1477 1483
1478 return selected; 1484 return selected;
1479} 1485}
1480 1486
1481DateList KOMonthView::selectedDates() 1487DateList KOMonthView::selectedDates()
1482{ 1488{
1483 DateList selected; 1489 DateList selected;
1484 1490
1485 if ( mSelectedCell ) { 1491 if ( mSelectedCell ) {
1486 QDate qd = mSelectedCell->selectedIncidenceDate(); 1492 QDate qd = mSelectedCell->selectedIncidenceDate();
1487 if ( qd.isValid() ) selected.append( qd ); 1493 if ( qd.isValid() ) selected.append( qd );
1488 } 1494 }
1489 1495
1490 return selected; 1496 return selected;
1491} 1497}
1492 1498#if 0
1493void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1499void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1494 const QDate &td) 1500 const QDate &td)
1495{ 1501{
1496#ifndef KORG_NOPRINTER 1502#ifndef KORG_NOPRINTER
1497 calPrinter->preview(CalPrinter::Month, fd, td); 1503 calPrinter->preview(CalPrinter::Month, fd, td);
1498#endif 1504#endif
1499} 1505}
1500 1506#endif
1501void KOMonthView::updateConfig() 1507void KOMonthView::updateConfig()
1502{ 1508{
1503 1509
1504 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1510 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1505 1511
1506 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1512 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1507 mWeekStartsMonday = true; 1513 mWeekStartsMonday = true;
1508 } 1514 }
1509 QFontMetrics fontmetric(mDayLabels[0]->font()); 1515 QFontMetrics fontmetric(mDayLabels[0]->font());
1510 mWidthLongDayLabel = 0; 1516 mWidthLongDayLabel = 0;
1511 1517
1512 for (int i = 0; i < 7; i++) { 1518 for (int i = 0; i < 7; i++) {
1513 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1519 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1514 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1520 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1515 } 1521 }
1516 bool temp = mShowSatSunComp ; 1522 bool temp = mShowSatSunComp ;
1517 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1523 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1518 if ( ! mShowWeekView ) { 1524 if ( ! mShowWeekView ) {
1519 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1525 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1520 computeLayout(); 1526 computeLayout();
1521 } 1527 }
1522 updateDayLabels(); 1528 updateDayLabels();
1523 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1529 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1524 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1530 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1525 //resizeEvent( 0 ); 1531 //resizeEvent( 0 );
1526 for (uint i = 0; i < mCells.count(); ++i) { 1532 for (uint i = 0; i < mCells.count(); ++i) {
1527 mCells[i]->updateConfig(); 1533 mCells[i]->updateConfig();
1528 } 1534 }
1529 1535
1530 for (uint i = 0; i < mCellsW.count(); ++i) { 1536 for (uint i = 0; i < mCellsW.count(); ++i) {
1531 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1537 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1532 } 1538 }
1533#ifdef DESKTOP_VERSION 1539#ifdef DESKTOP_VERSION
1534 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1540 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1535#endif 1541#endif
1536 updateView(); 1542 updateView();
1537} 1543}
1538 1544
1539void KOMonthView::updateDayLabels() 1545void KOMonthView::updateDayLabels()
1540{ 1546{
1541 1547
1542 QPtrVector<QLabel> *mDayLabelsT; 1548 QPtrVector<QLabel> *mDayLabelsT;
1543 1549
1544 mDayLabelsT = &mDayLabelsW; 1550 mDayLabelsT = &mDayLabelsW;
1545 for (int i = 0; i < 7; i++) { 1551 for (int i = 0; i < 7; i++) {
1546 { 1552 {
1547 bool show = mShortDayLabelsW; 1553 bool show = mShortDayLabelsW;
1548 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1554 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1549 show = true; 1555 show = true;
1550 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1556 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1551 } 1557 }
1552 } 1558 }
1553 mDayLabelsT = &mDayLabels; 1559 mDayLabelsT = &mDayLabels;
1554 for (int i = 0; i < 7; i++) { 1560 for (int i = 0; i < 7; i++) {
1555 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { 1561 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
1556 bool show = mShortDayLabelsM; 1562 bool show = mShortDayLabelsM;
1557 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1563 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1558 show = true; 1564 show = true;
1559 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1565 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1560 } else { 1566 } else {
1561 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1567 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1562 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1568 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1563 1569
1564 } 1570 }
1565 } 1571 }
1566 1572
1567} 1573}
1568 1574
1569void KOMonthView::clearList() 1575void KOMonthView::clearList()
1570{ 1576{
1571 unsigned int i; 1577 unsigned int i;
1572 for( i = 0; i < mCells.size(); ++i ) { 1578 for( i = 0; i < mCells.size(); ++i ) {
1573 mCells[i]->clear(); 1579 mCells[i]->clear();
1574 } 1580 }
1575 for( i = 0; i < mCellsW.size(); ++i ) { 1581 for( i = 0; i < mCellsW.size(); ++i ) {
1576 mCellsW[i]->clear(); 1582 mCellsW[i]->clear();
1577 } 1583 }
1578} 1584}
1579void KOMonthView::showDates(const QDate &start, const QDate &) 1585void KOMonthView::showDates(const QDate &start, const QDate &)
1580{ 1586{
1581 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1587 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1582 1588
1583 QPtrVector<MonthViewCell> *cells; 1589 QPtrVector<MonthViewCell> *cells;
1584 QPtrVector<QLabel> *dayLabels; 1590 QPtrVector<QLabel> *dayLabels;
1585 QPtrVector<KOWeekButton> *weekLabels; 1591 QPtrVector<KOWeekButton> *weekLabels;
1586 int weekNum = 6; 1592 uint weekNum = 6;
1587 mStartDate = start; 1593 mStartDate = start;
1588 if ( mShowWeekView ) { 1594 if ( mShowWeekView ) {
1589 weekNum = 1; 1595 weekNum = 1;
1590 cells = &mCellsW; 1596 cells = &mCellsW;
1591 dayLabels = &mDayLabelsW; 1597 dayLabels = &mDayLabelsW;
1592 weekLabels = &mWeekLabelsW; 1598 weekLabels = &mWeekLabelsW;
1593 if ( !KGlobal::locale()->weekStartsMonday() ) { 1599 if ( !KGlobal::locale()->weekStartsMonday() ) {
1594 mStartDate = mStartDate.addDays( 1 ); 1600 mStartDate = mStartDate.addDays( 1 );
1595 } 1601 }
1596 } else { 1602 } else {
1597 cells = &mCells; 1603 cells = &mCells;
1598 dayLabels = &mDayLabels; 1604 dayLabels = &mDayLabels;
1599 weekLabels = &mWeekLabels; 1605 weekLabels = &mWeekLabels;
1600 } 1606 }
1601 1607
1602 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1608 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1603 1609
1604 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1610 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1605 mWeekStartsMonday = true; 1611 mWeekStartsMonday = true;
1606 } 1612 }
1607 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1613 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1608 1614
1609 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1615 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1610 mStartDate = mStartDate.addDays( -1 ); 1616 mStartDate = mStartDate.addDays( -1 );
1611 } 1617 }
1612 bool primary = false;
1613 uint i; 1618 uint i;
1614 for( i = 0; i < (*cells).size(); ++i ) { 1619 for( i = 0; i < (*cells).size(); ++i ) {
1615 QDate date = mStartDate.addDays( i ); 1620 QDate date = mStartDate.addDays( i );
1616 (*cells)[i]->setDate( date ); 1621 (*cells)[i]->setDate( date );
1617 1622
1618#ifndef KORG_NOPLUGINS 1623#ifndef KORG_NOPLUGINS
1619 // add holiday, if present 1624 // add holiday, if present
1620 QString hstring(KOCore::self()->holiday(date)); 1625 QString hstring(KOCore::self()->holiday(date));
1621 (*cells)[i]->setHoliday( hstring ); 1626 (*cells)[i]->setHoliday( hstring );
1622#endif 1627#endif
1623 1628
1624 } 1629 }
1625 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1630 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1626 for( i = 0; i < weekNum; ++i ) { 1631 for( i = 0; i < weekNum; ++i ) {
1627 int wno; 1632 int wno;
1628 // remember, according to ISO 8601, the first week of the year is the 1633 // remember, according to ISO 8601, the first week of the year is the
1629 // first week that contains a thursday. Thus we must subtract off 4, 1634 // first week that contains a thursday. Thus we must subtract off 4,
1630 // not just 1. 1635 // not just 1.
1631 int dayOfYear = date.dayOfYear(); 1636 int dayOfYear = date.dayOfYear();
1632 if (dayOfYear % 7 != 0) 1637 if (dayOfYear % 7 != 0)
1633 wno = dayOfYear / 7 + 1; 1638 wno = dayOfYear / 7 + 1;
1634 else 1639 else
1635 wno =dayOfYear / 7; 1640 wno =dayOfYear / 7;
1636 (*weekLabels)[i]->setWeekNum( wno ); 1641 (*weekLabels)[i]->setWeekNum( wno );
1637 date = date.addDays( 7 ); 1642 date = date.addDays( 7 );
1638 } 1643 }
1639 updateView(); 1644 updateView();
1640} 1645}
1641 1646
1642void KOMonthView::showEvents(QPtrList<Event>) 1647void KOMonthView::showEvents(QPtrList<Event>)
1643{ 1648{
1644 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1649 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1645} 1650}
1646 1651
1647void KOMonthView::changeEventDisplay(Event *, int) 1652void KOMonthView::changeEventDisplay(Event *, int)
1648{ 1653{
1649 // this should be re-written to be much more efficient, but this 1654 // this should be re-written to be much more efficient, but this
1650 // quick-and-dirty-hack gets the job done for right now. 1655 // quick-and-dirty-hack gets the job done for right now.
1651 //qDebug("KOMonthView::changeEventDisplay "); 1656 //qDebug("KOMonthView::changeEventDisplay ");
1652 updateView(); 1657 updateView();
1653} 1658}
1654 1659
1655void KOMonthView::updateView() 1660void KOMonthView::updateView()
1656{ 1661{
1657 1662
1658 if ( !updatePossible ) 1663 if ( !updatePossible )
1659 return; 1664 return;
1660 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1665 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1661 //QTime ti; 1666 //QTime ti;
1662 //ti.start(); 1667 //ti.start();
1663 clearSelection(); 1668 clearSelection();
1664 QPtrVector<MonthViewCell> *cells; 1669 QPtrVector<MonthViewCell> *cells;
1665 if ( mShowWeekView ) { 1670 if ( mShowWeekView ) {
1666 cells = &mCellsW; 1671 cells = &mCellsW;
1667 } else { 1672 } else {
1668 cells = &mCells; 1673 cells = &mCells;
1669 } 1674 }
1670#if 1 1675#if 1
1671 int i; 1676 int i;
1672 int timeSpan = (*cells).size()-1; 1677 int timeSpan = (*cells).size()-1;
1673 if ( KOPrefs::instance()->mMonthViewWeek ) 1678 if ( KOPrefs::instance()->mMonthViewWeek )
1674 timeSpan = 6; 1679 timeSpan = 6;
1675 for( i = 0; i < timeSpan + 1; ++i ) { 1680 for( i = 0; i < timeSpan + 1; ++i ) {
1676 (*cells)[i]->startUpdateCell(); 1681 (*cells)[i]->startUpdateCell();
1677 } 1682 }
1678 1683
1679 QPtrList<Event> events = calendar()->events(); 1684 QPtrList<Event> events = calendar()->events();
1680 Event *event; 1685 Event *event;
1681 QDateTime dt; 1686 QDateTime dt;
1682 bool ok;
1683 QDate endDate = mStartDate.addDays( timeSpan ); 1687 QDate endDate = mStartDate.addDays( timeSpan );
1684 for( event = events.first(); event; event = events.next() ) { // for event 1688 for( event = events.first(); event; event = events.next() ) { // for event
1685 if ( event->doesRecur() ) { 1689 if ( event->doesRecur() ) {
1686 bool last; 1690 bool last;
1687 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1691 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1688 QDateTime incidenceEnd; 1692 QDateTime incidenceEnd;
1689 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1693 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1690 bool invalid = false; 1694 bool invalid = false;
1691 while( true ) { 1695 while( true ) {
1692 if ( incidenceStart.isValid() ) { 1696 if ( incidenceStart.isValid() ) {
1693 incidenceEnd = incidenceStart.addDays( eventlen ); 1697 incidenceEnd = incidenceStart.addDays( eventlen );
1694 int st = incidenceStart.date().daysTo( endDate ); 1698 int st = incidenceStart.date().daysTo( endDate );
1695 if ( st >= 0 ) { // start before timeend 1699 if ( st >= 0 ) { // start before timeend
1696 int end = mStartDate.daysTo( incidenceEnd.date() ); 1700 int end = mStartDate.daysTo( incidenceEnd.date() );
1697 if ( end >= 0 ) { // end after timestart --- got one! 1701 if ( end >= 0 ) { // end after timestart --- got one!
1698 //normalize 1702 //normalize
1699 st = timeSpan - st; 1703 st = timeSpan - st;
1700 if ( st < 0 ) st = 0; 1704 if ( st < 0 ) st = 0;
1701 if ( end > timeSpan ) end = timeSpan; 1705 if ( end > timeSpan ) end = timeSpan;
1702 int iii; 1706 int iii;
1703 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1707 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1704 for ( iii = st;iii<= end;++iii) 1708 for ( iii = st;iii<= end;++iii)
1705 (*cells)[iii]->insertEvent( event ); 1709 (*cells)[iii]->insertEvent( event );
1706 } 1710 }
1707 } 1711 }
1708 } else { 1712 } else {
1709 if ( invalid ) 1713 if ( invalid )
1710 break; 1714 break;
1711 invalid = true; 1715 invalid = true;
1712 //qDebug("invalid %s", event->summary().latin1()); 1716 //qDebug("invalid %s", event->summary().latin1());
1713 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1717 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1714 } 1718 }
1715 if ( last ) 1719 if ( last )
1716 break; 1720 break;
1717 bool ok; 1721 bool ok;
1718 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1722 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1719 if ( ! ok ) 1723 if ( ! ok )
1720 break; 1724 break;
1721 if ( incidenceStart.date() > endDate ) 1725 if ( incidenceStart.date() > endDate )
1722 break; 1726 break;
1723 } 1727 }
1724 } else { // no recur 1728 } else { // no recur
1725 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1729 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1726 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1730 if ( event->uid().left(15) == QString("last-syncEvent-") )
1727 continue; 1731 continue;
1728 int st = event->dtStart().date().daysTo( endDate ); 1732 int st = event->dtStart().date().daysTo( endDate );
1729 if ( st >= 0 ) { // start before timeend 1733 if ( st >= 0 ) { // start before timeend
1730 int end = mStartDate.daysTo( event->dtEnd().date() ); 1734 int end = mStartDate.daysTo( event->dtEnd().date() );
1731 if ( end >= 0 ) { // end after timestart --- got one! 1735 if ( end >= 0 ) { // end after timestart --- got one!
1732 //normalize 1736 //normalize
1733 st = timeSpan - st; 1737 st = timeSpan - st;
1734 if ( st < 0 ) st = 0; 1738 if ( st < 0 ) st = 0;
1735 if ( end > timeSpan ) end = timeSpan; 1739 if ( end > timeSpan ) end = timeSpan;
1736 int iii; 1740 int iii;
1737 for ( iii = st;iii<= end;++iii) 1741 for ( iii = st;iii<= end;++iii)
1738 (*cells)[iii]->insertEvent( event ); 1742 (*cells)[iii]->insertEvent( event );
1739 } 1743 }
1740 } 1744 }
1741 } 1745 }
1742 } 1746 }
1743 // insert due todos 1747 // insert due todos
1744 QPtrList<Todo> todos = calendar()->todos( ); 1748 QPtrList<Todo> todos = calendar()->todos( );
1745 Todo *todo; 1749 Todo *todo;
1746 for(todo = todos.first(); todo; todo = todos.next()) { 1750 for(todo = todos.first(); todo; todo = todos.next()) {
1747 //insertTodo( todo ); 1751 //insertTodo( todo );
1748 if ( todo->hasDueDate() ) { 1752 if ( todo->hasDueDate() ) {
1749 int day = mStartDate.daysTo( todo->dtDue().date() ); 1753 int day = mStartDate.daysTo( todo->dtDue().date() );
1750 if ( day >= 0 && day < timeSpan + 1) { 1754 if ( day >= 0 && day < timeSpan + 1) {
1751 (*cells)[day]->insertTodo( todo ); 1755 (*cells)[day]->insertTodo( todo );
1752 } 1756 }
1753 } 1757 }
1754 } 1758 }
1755 1759
1756 for( i = 0; i < timeSpan+1; ++i ) { 1760 for( i = 0; i < timeSpan+1; ++i ) {
1757 (*cells)[i]->finishUpdateCell(); 1761 (*cells)[i]->finishUpdateCell();
1758 } 1762 }
1759 processSelectionChange(); 1763 processSelectionChange();
1760 //qApp->processEvents(); 1764 //qApp->processEvents();
1761 for( i = 0; i < timeSpan+1; ++i ) { 1765 for( i = 0; i < timeSpan+1; ++i ) {
1762 //(*cells)[i]->repaintfinishUpdateCell(); 1766 //(*cells)[i]->repaintfinishUpdateCell();
1763 QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); 1767 QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) );
1764 } 1768 }
1765 setKeyBFocus(); 1769 setKeyBFocus();
1766#else 1770#else
1767 // old code 1771 // old code
1768 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1772 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1769 int i; 1773 int i;
1770 for( i = 0; i < (*cells).count(); ++i ) { 1774 for( i = 0; i < (*cells).count(); ++i ) {
1771 (*cells)[i]->updateCell(); 1775 (*cells)[i]->updateCell();
1772 } 1776 }
1773 1777
1774 //qDebug("KOMonthView::updateView() "); 1778 //qDebug("KOMonthView::updateView() ");
1775 processSelectionChange(); 1779 processSelectionChange();
1776 // qDebug("---------------------------------------------------------------------+ "); 1780 // qDebug("---------------------------------------------------------------------+ ");
1777 (*cells)[0]->setFocus(); 1781 (*cells)[0]->setFocus();
1778#endif 1782#endif
1779 1783
1780 //qDebug("update time %d ", ti.elapsed()); 1784 //qDebug("update time %d ", ti.elapsed());
1781} 1785}
1782 1786
1783void KOMonthView::setKeyBoardFocus() 1787void KOMonthView::setKeyBoardFocus()
1784{ 1788{
1785 //qDebug("KOMonthView::setKeyBoardFocus() "); 1789 //qDebug("KOMonthView::setKeyBoardFocus() ");
1786 bool shootAgain = false; 1790 bool shootAgain = false;
1787 if ( mShowWeekView ) { 1791 if ( mShowWeekView ) {
1788 shootAgain = !mWeekLabelsW[1]->hasFocus(); 1792 shootAgain = !mWeekLabelsW[1]->hasFocus();
1789 mWeekLabelsW[1]->setFocus(); 1793 mWeekLabelsW[1]->setFocus();
1790 } 1794 }
1791 else { 1795 else {
1792 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); 1796 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus();
1793 mWeekLabels[mNumWeeks]->setFocus(); 1797 mWeekLabels[mNumWeeks]->setFocus();
1794 } 1798 }
1795 --mKBFcounter; 1799 --mKBFcounter;
1796 if ( shootAgain && mKBFcounter > 0 ) { 1800 if ( shootAgain && mKBFcounter > 0 ) {
1797 QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); 1801 QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) );
1798 } 1802 }
1799} 1803}
1800void KOMonthView::setKeyBFocus() 1804void KOMonthView::setKeyBFocus()
1801{ 1805{
1802 //qDebug("KOMonthView::setKeyBFocus() "); 1806 //qDebug("KOMonthView::setKeyBFocus() ");
1803 mKBFcounter = 10; 1807 mKBFcounter = 10;
1804 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); 1808 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
1805} 1809}
1806void KOMonthView::resizeEvent(QResizeEvent * e) 1810void KOMonthView::resizeEvent(QResizeEvent * e)
1807{ 1811{
1808 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1812 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1809 if ( isVisible() ) { 1813 if ( isVisible() ) {
1810 //qDebug("KOMonthView::isVisible "); 1814 //qDebug("KOMonthView::isVisible ");
1811 slotComputeLayout(); 1815 slotComputeLayout();
1812 } else 1816 } else
1813 mComputeLayoutTimer->start( 100 ); 1817 mComputeLayoutTimer->start( 100 );
1818 KOEventView::resizeEvent( e );
1814} 1819}
1815 1820
1816void KOMonthView::slotComputeLayout() 1821void KOMonthView::slotComputeLayout()
1817{ 1822{
1818 mComputeLayoutTimer->stop(); 1823 mComputeLayoutTimer->stop();
1819 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); 1824 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
1820 computeLayout(); 1825 computeLayout();
1821 clPending = true; 1826 clPending = true;
1822 setKeyBFocus(); 1827 setKeyBFocus();
1823} 1828}
1824void KOMonthView::computeLayoutWeek() 1829void KOMonthView::computeLayoutWeek()
1825{ 1830{
1826 static int lastWid = 0; 1831 static int lastWid = 0;
1827 static int lastHei = 0; 1832 static int lastHei = 0;
1828 int daysToShow; 1833 int daysToShow;
1829 bool combinedSatSun = false; 1834 bool combinedSatSun = false;
1830 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1835 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1831 daysToShow = 6; 1836 daysToShow = 6;
1832 combinedSatSun = true; 1837 combinedSatSun = true;
1833 } 1838 }
1834 int tWid = topLevelWidget()->size().width(); 1839 int tWid = topLevelWidget()->size().width();
1835 int tHei = topLevelWidget()->size().height(); 1840 int tHei = topLevelWidget()->size().height();
1836 1841
1837 int wid = width();//e 1842 int wid = width();//e
1838 int hei = height()-1-mNavigatorBar->height(); 1843 int hei = height()-1-mNavigatorBar->height();
1839 1844
1840 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1845 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1841 return; 1846 return;
1842 1847
1843 if ( lastWid == width() && lastHei == height() ) { 1848 if ( lastWid == width() && lastHei == height() ) {
1844 //qDebug("KOListWeekView::No compute layout needed "); 1849 //qDebug("KOListWeekView::No compute layout needed ");
1845 return; 1850 return;
1846 } 1851 }
1847 lastWid = width(); 1852 lastWid = width();
1848 lastHei = height(); 1853 lastHei = height();
1849 1854
1850 1855
1851 if ( wid < hei ) 1856 if ( wid < hei )
1852 daysToShow = 2; 1857 daysToShow = 2;
1853 else 1858 else
1854 daysToShow = 3; 1859 daysToShow = 3;
1855 mShowSatSunComp = true; 1860 mShowSatSunComp = true;
1856 combinedSatSun = true; 1861 combinedSatSun = true;
1857 1862
1858 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1863 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1859 QFontMetrics fm ( mWeekLabels[0]->font() ); 1864 QFontMetrics fm ( mWeekLabels[0]->font() );
1860 int weeklabelwid = fm.width( "888" ); 1865 int weeklabelwid = fm.width( "888" );
1861 wid -= weeklabelwid; 1866 wid -= weeklabelwid;
1862 1867
1863 int colWid = wid / daysToShow; 1868 int colWid = wid / daysToShow;
1864 int lastCol = wid - ( colWid*6 );
1865 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1869 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1866 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1870 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1867 int colModulo = wid % daysToShow; 1871 int colModulo = wid % daysToShow;
1868 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1872 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1869 //qDebug("rowmod %d ", rowModulo); 1873 //qDebug("rowmod %d ", rowModulo);
1870 int i; 1874 int i;
1871 int x,y,w,h; 1875 int x,y,w,h;
1872 x= 0; 1876 x= 0;
1873 y= 0; 1877 y= 0;
1874 w = colWid; 1878 w = colWid;
1875 h = dayLabelHei ; 1879 h = dayLabelHei ;
1876 for ( i = 0; i < 7; i++) { 1880 for ( i = 0; i < 7; i++) {
1877 if ( i && !( i % daysToShow) && i < 6) { 1881 if ( i && !( i % daysToShow) && i < 6) {
1878 y += hei/(5-daysToShow); 1882 y += hei/(5-daysToShow);
1879 x = 0; 1883 x = 0;
1880 w = colWid; 1884 w = colWid;
1881 } 1885 }
1882 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1886 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1883 ++w; 1887 ++w;
1884 } 1888 }
1885 if ( i >= 5 ) { 1889 if ( i >= 5 ) {
1886 int wi = width() - x - weeklabelwid; 1890 int wi = width() - x - weeklabelwid;
1887 if ( i == 5 ) { 1891 if ( i == 5 ) {
1888 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); 1892 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h);
1889 } else { 1893 } else {
1890 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1894 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1891 } 1895 }
1892 x = x - w + wi - (wi/2 ); 1896 x = x - w + wi - (wi/2 );
1893 } 1897 }
1894 else { 1898 else {
1895 int wi = w; 1899 int wi = w;
1896 if ( !(( i+1) % daysToShow)) { 1900 if ( !(( i+1) % daysToShow)) {
1897 wi = width() - x - weeklabelwid; 1901 wi = width() - x - weeklabelwid;
1898 } 1902 }
1899 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1903 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1900 } 1904 }
1901 x += w; 1905 x += w;
1902 } 1906 }
1903 x= 0; 1907 x= 0;
1904 y= dayLabelHei; 1908 y= dayLabelHei;
1905 w = colWid; 1909 w = colWid;
1906 h = cellHei; 1910 h = cellHei;
1907 int max = 0; 1911 int max = 0;
1908 for ( i = 0; i < mCellsW.count(); ++i) { 1912 int w_count = mCellsW.count();
1913 for ( i = 0; i < w_count; ++i) {
1909 if ( i > 6 ) { 1914 if ( i > 6 ) {
1910 mCellsW[i]->hide(); 1915 mCellsW[i]->hide();
1911 continue; 1916 continue;
1912 } 1917 }
1913 1918
1914 w = colWid; 1919 w = colWid;
1915 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1920 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1916 ++w; 1921 ++w;
1917 } 1922 }
1918 if ( i == (daysToShow-1-rowModulo)*7) 1923 if ( i == (daysToShow-1-rowModulo)*7)
1919 ++h; 1924 ++h;
1920 1925
1921 if ( i >= 5 ) { 1926 if ( i >= 5 ) {
1922 if ( i ==5 ) { 1927 if ( i ==5 ) {
1923 max = h/2; 1928 max = h/2;
1924 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1929 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1925 x -= w ;y += h/2; 1930 x -= w ;y += h/2;
1926 } else { 1931 } else {
1927 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1932 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1928 ++w; 1933 ++w;
1929 } 1934 }
1930 max = h-h/2; 1935 max = h-h/2;
1931 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1936 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1932 y -= h/2; 1937 y -= h/2;
1933 } 1938 }
1934 } else { 1939 } else {
1935 max = h; 1940 max = h;
1936 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1941 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1937 } 1942 }
1938 1943
1939 1944
1940 x += w; 1945 x += w;
1941 if ( x + w/2 > wid ) { 1946 if ( x + w/2 > wid ) {
1942 x = 0; 1947 x = 0;
1943 y += h+dayLabelHei ; 1948 y += h+dayLabelHei ;
1944 } 1949 }
1945 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); 1950 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 );
1946 } 1951 }
1947 y= dayLabelHei; 1952 y= dayLabelHei;
1948 h = cellHei ; 1953 h = cellHei ;
1949 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1954 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1950 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1955 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1951 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1956 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1952 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1957 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1953 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1958 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1954 updateDayLabels(); 1959 updateDayLabels();
1955 //bool forceUpdate = !updatePossible; 1960 //bool forceUpdate = !updatePossible;
1956 updatePossible = true; 1961 updatePossible = true;
1957 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1962 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1958 //if ( forceUpdate ) 1963 //if ( forceUpdate )
1959 // updateView(); 1964 // updateView();
1960} 1965}
1961void KOMonthView::computeLayout() 1966void KOMonthView::computeLayout()
1962{ 1967{
1963 1968
1964 1969
1965 static int lastWid = 0; 1970 static int lastWid = 0;
1966 static int lastHei = 0; 1971 static int lastHei = 0;
1967 1972
1968 if ( mShowWeekView ){ 1973 if ( mShowWeekView ){
1969 computeLayoutWeek(); 1974 computeLayoutWeek();
1970 return; 1975 return;
1971 } 1976 }
1972 int daysToShow = 7; 1977 int daysToShow = 7;
1973 bool combinedSatSun = false; 1978 bool combinedSatSun = false;
1974 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1979 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1975 daysToShow = 6; 1980 daysToShow = 6;
1976 combinedSatSun = true; 1981 combinedSatSun = true;
1977 } 1982 }
1978 int tWid = topLevelWidget()->size().width(); 1983 int tWid = topLevelWidget()->size().width();
1979 int tHei = topLevelWidget()->size().height(); 1984 int tHei = topLevelWidget()->size().height();
1980 1985
1981 int wid = width();//e 1986 int wid = width();//e
1982 int hei = height()-1-mNavigatorBar->height(); 1987 int hei = height()-1-mNavigatorBar->height();
1983 1988
1984 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 1989 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1985 return; 1990 return;
1986 } 1991 }
1987 if ( lastWid == width() && lastHei == height() ){ 1992 if ( lastWid == width() && lastHei == height() ){
1988 //qDebug("KOMonthview::No compute layout needed "); 1993 //qDebug("KOMonthview::No compute layout needed ");
1989 return; 1994 return;
1990 } 1995 }
1991 1996
1992 lastWid = width(); 1997 lastWid = width();
1993 lastHei = height(); 1998 lastHei = height();
1994 //qDebug("KOMonthView::computeLayout() MMM ------------------- "); 1999 //qDebug("KOMonthView::computeLayout() MMM ------------------- ");
1995 QFontMetrics fm ( mWeekLabels[0]->font() ); 2000 QFontMetrics fm ( mWeekLabels[0]->font() );
1996 int weeklabelwid = fm.width( "888" ); 2001 int weeklabelwid = fm.width( "888" );
1997 wid -= weeklabelwid; 2002 wid -= weeklabelwid;
1998 2003
1999 int colWid = wid / daysToShow; 2004 int colWid = wid / daysToShow;
2000 int lastCol = wid - ( colWid*6 );
2001 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 2005 int dayLabelHei = mDayLabels[0]->sizeHint().height();
2002 int cellHei = (hei - dayLabelHei) /6; 2006 int cellHei = (hei - dayLabelHei) /6;
2003 int colModulo = wid % daysToShow; 2007 int colModulo = wid % daysToShow;
2004 int rowModulo = (hei- dayLabelHei) % 6; 2008 int rowModulo = (hei- dayLabelHei) % 6;
2005 //qDebug("rowmod %d ", rowModulo); 2009 //qDebug("rowmod %d ", rowModulo);
2006 int i; 2010 int i;
2007 int x,y,w,h; 2011 int x,y,w,h;
2008 x= 0; 2012 x= 0;
2009 y= 0; 2013 y= 0;
2010 w = colWid; 2014 w = colWid;
2011 h = dayLabelHei ; 2015 h = dayLabelHei ;
2012 for ( i = 0; i < 7; i++) { 2016 for ( i = 0; i < 7; i++) {
2013 if ( i == daysToShow-colModulo ) 2017 if ( i == daysToShow-colModulo )
2014 ++w; 2018 ++w;
2015 if ( combinedSatSun ) { 2019 if ( combinedSatSun ) {
2016 if ( i >= daysToShow-1 ) { 2020 if ( i >= daysToShow-1 ) {
2017 2021
2018 if ( i == 6 ) 2022 if ( i == 6 )
2019 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); 2023 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h);
2020 else 2024 else
2021 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 2025 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
2022 x -= w/2 ; 2026 x -= w/2 ;
2023 } 2027 }
2024 else 2028 else
2025 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 2029 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
2026 } else 2030 } else
2027 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 2031 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
2028 x += w; 2032 x += w;
2029 } 2033 }
2030 x= 0; 2034 x= 0;
2031 y= dayLabelHei; 2035 y= dayLabelHei;
2032 w = colWid; 2036 w = colWid;
2033 h = cellHei ; 2037 h = cellHei ;
2034 int max = 0; 2038 int max = 0;
2035 for ( i = 0; i < mCells.count(); ++i) { 2039 int mc_count = mCells.count();
2040 for ( i = 0; i < mc_count; ++i) {
2036 //qDebug("iii %d ", i); 2041 //qDebug("iii %d ", i);
2037 w = colWid; 2042 w = colWid;
2038 if ( ((i) % 7) >= 7-colModulo ) { 2043 if ( ((i) % 7) >= 7-colModulo ) {
2039 ++w; 2044 ++w;
2040 } 2045 }
2041 if ( i == (6-rowModulo)*7) 2046 if ( i == (6-rowModulo)*7)
2042 ++h; 2047 ++h;
2043 if ( combinedSatSun ) { 2048 if ( combinedSatSun ) {
2044 if ( (i)%7 >= daysToShow-1 ) { 2049 if ( (i)%7 >= daysToShow-1 ) {
2045 if ( (i)%7 == daysToShow-1 ) { 2050 if ( (i)%7 == daysToShow-1 ) {
2046 w = width()-x-weeklabelwid; 2051 w = width()-x-weeklabelwid;
2047 max = h/2; 2052 max = h/2;
2048 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 2053 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
2049 x -= w ;y += h/2; 2054 x -= w ;y += h/2;
2050 } else { 2055 } else {
2051 w = width()-x-weeklabelwid; 2056 w = width()-x-weeklabelwid;
2052 max = h-h/2; 2057 max = h-h/2;
2053 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 2058 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
2054 y -= h/2; 2059 y -= h/2;
2055 } 2060 }
2056 } else { 2061 } else {
2057 max = h; 2062 max = h;
2058 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 2063 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
2059 } 2064 }
2060 2065
2061 } 2066 }
2062 else { 2067 else {
2063 max = h; 2068 max = h;
2064 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 2069 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
2065 } 2070 }
2066 x += w; 2071 x += w;
2067 if ( x + w/2 > wid ) { 2072 if ( x + w/2 > wid ) {
2068 x = 0; 2073 x = 0;
2069 y += h; 2074 y += h;
2070 } 2075 }
2071 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); 2076 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 );
2072 } 2077 }
2073 y= dayLabelHei; 2078 y= dayLabelHei;
2074 h = cellHei ; 2079 h = cellHei ;
2075 for ( i = 0; i < 6; i++) { 2080 for ( i = 0; i < 6; i++) {
2076 if ( i == (6-rowModulo)) 2081 if ( i == (6-rowModulo))
2077 ++h; 2082 ++h;
2078 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 2083 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
2079 y += h; 2084 y += h;
2080 } 2085 }
2081 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 2086 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
2082 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 2087 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
2083 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 2088 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
2084 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 2089 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
2085 updateDayLabels(); 2090 updateDayLabels();
2086 //bool forceUpdate = !updatePossible; 2091 //bool forceUpdate = !updatePossible;
2087 updatePossible = true; 2092 updatePossible = true;
2088 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 2093 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
2089} 2094}
2090 2095
2091void KOMonthView::showContextMenu( Incidence *incidence ) 2096void KOMonthView::showContextMenu( Incidence *incidence )
2092{ 2097{
2093 if( incidence ) 2098 if( incidence )
2094 mContextMenu->showIncidencePopup(incidence); 2099 mContextMenu->showIncidencePopup(incidence);
2095 else { 2100 else {
2096 //qDebug("KOMonthView::showContextMenu "); 2101 //qDebug("KOMonthView::showContextMenu ");
2097 mNewItemMenu->popup(QCursor::pos()); 2102 mNewItemMenu->popup(QCursor::pos());
2098 } 2103 }
2099 /* 2104 /*
2100 if( incidence && incidence->typeID() == eventID ) { 2105 if( incidence && incidence->typeID() == eventID ) {
2101 Event *event = static_cast<Event *>(incidence); 2106 Event *event = static_cast<Event *>(incidence);
2102 mContextMenu->showEventPopup(event); 2107 mContextMenu->showEventPopup(event);
2103 } else { 2108 } else {
2104 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 2109 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
2105 } 2110 }
2106 */ 2111 */
2107} 2112}
2108MonthViewCell * KOMonthView::selectedCell( ) 2113MonthViewCell * KOMonthView::selectedCell( )
2109{ 2114{
2110 return mSelectedCell; 2115 return mSelectedCell;
2111} 2116}
2112void KOMonthView::setSelectedCell( MonthViewCell *cell ) 2117void KOMonthView::setSelectedCell( MonthViewCell *cell )
2113{ 2118{
2114 //qDebug("KOMonthView::setSelectedCell %d", cell); 2119 //qDebug("KOMonthView::setSelectedCell %d", cell);
2115 if ( mSelectedCell && mSelectedCell != cell ) { 2120 if ( mSelectedCell && mSelectedCell != cell ) {
2116 MonthViewCell * mvc = mSelectedCell; 2121 MonthViewCell * mvc = mSelectedCell;
2117 mSelectedCell = cell; 2122 mSelectedCell = cell;
2118 mvc->deselect(); 2123 mvc->deselect();
2119 } else 2124 } else
2120 mSelectedCell = cell; 2125 mSelectedCell = cell;
2121 // if ( mSelectedCell ) 2126 // if ( mSelectedCell )
2122 // mSelectedCell->select(); 2127 // mSelectedCell->select();
2123 if ( !mSelectedCell ) 2128 if ( !mSelectedCell )
2124 emit incidenceSelected( 0 ); 2129 emit incidenceSelected( 0 );
2125 else 2130 else
2126 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 2131 emit incidenceSelected( mSelectedCell->selectedIncidence() );
2127} 2132}
2128 2133
2129void KOMonthView::processSelectionChange() 2134void KOMonthView::processSelectionChange()
2130{ 2135{
2131 QPtrList<Incidence> incidences = selectedIncidences(); 2136 QPtrList<Incidence> incidences = selectedIncidences();
2132 if (incidences.count() > 0) { 2137 if (incidences.count() > 0) {
2133 emit incidenceSelected( incidences.first() ); 2138 emit incidenceSelected( incidences.first() );
2134 } else { 2139 } else {
2135 emit incidenceSelected( 0 ); 2140 emit incidenceSelected( 0 );
2136 clearSelection(); 2141 clearSelection();
2137 } 2142 }
2138} 2143}
2139 2144
2140void KOMonthView::clearSelection() 2145void KOMonthView::clearSelection()
2141{ 2146{
2142 if ( mSelectedCell ) { 2147 if ( mSelectedCell ) {
2143 mSelectedCell->deselect(); 2148 mSelectedCell->deselect();
2144 mSelectedCell = 0; 2149 mSelectedCell = 0;
2145 } 2150 }
2146} 2151}
2147 2152
2148void KOMonthView::keyReleaseEvent ( QKeyEvent * e) 2153void KOMonthView::keyReleaseEvent ( QKeyEvent * e)
2149{ 2154{
2150 if ( !e->isAutoRepeat() ) { 2155 if ( !e->isAutoRepeat() ) {
2151 mFlagKeyPressed = false; 2156 mFlagKeyPressed = false;
2152 } 2157 }
2153} 2158}
2154 2159
2155void KOMonthView::keyPressEvent ( QKeyEvent * e ) 2160void KOMonthView::keyPressEvent ( QKeyEvent * e )
2156{ 2161{
2157 2162
2158 qApp->processEvents(); 2163 qApp->processEvents();
2159 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 2164 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
2160 //e->ignore(); 2165 //e->ignore();
2161 e->accept(); 2166 e->accept();
2162 return; 2167 return;
2163 } 2168 }
2164 if (! e->isAutoRepeat() ) 2169 if (! e->isAutoRepeat() )
2165 mFlagKeyPressed = true; 2170 mFlagKeyPressed = true;
2166 switch(e->key()) { 2171 switch(e->key()) {
2167 case Key_Up: 2172 case Key_Up:
2168 { 2173 {
2169 if ( mShowWeekView ) { 2174 if ( mShowWeekView ) {
2170 emit selectWeekNum ( currentWeek() - 1 ); 2175 emit selectWeekNum ( currentWeek() - 1 );
2171 } 2176 }
2172 else { 2177 else {
2173 emit prevMonth(); 2178 emit prevMonth();
2174 } 2179 }
2175 } 2180 }
2176 e->accept(); 2181 e->accept();
2177 break; 2182 break;
2178 case Key_Down: 2183 case Key_Down:
2179 { 2184 {
2180 if ( mShowWeekView ) { 2185 if ( mShowWeekView ) {
2181 emit selectWeekNum ( currentWeek() +1); 2186 emit selectWeekNum ( currentWeek() +1);
2182 } 2187 }
2183 else { 2188 else {
2184 emit nextMonth(); 2189 emit nextMonth();
2185 } 2190 }
2186 2191
2187 } 2192 }
2188 e->accept(); 2193 e->accept();
2189 break; 2194 break;
2190 case Key_Return: 2195 case Key_Return:
2191 case Key_Enter: 2196 case Key_Enter:
2192 { 2197 {
2193 selectInternalWeekNum ( currentWeek() ); 2198 selectInternalWeekNum ( currentWeek() );
2194 } 2199 }
2195 e->accept(); 2200 e->accept();
2196 break; 2201 break;
2197 case Key_D: 2202 case Key_D:
2198 if ( mSelectedCell ) { 2203 if ( mSelectedCell ) {
2199 mSelectedCell->showDay(); 2204 mSelectedCell->showDay();
2200 e->accept(); 2205 e->accept();
2201 } else { 2206 } else {
2202 e->ignore(); 2207 e->ignore();
2203 } 2208 }
2204 break; 2209 break;
2205 default: 2210 default:
2206 e->ignore(); 2211 e->ignore();
2207 break; 2212 break;
2208 } 2213 }
2209} 2214}
2210 2215
2211void KOMonthView::nextCell() 2216void KOMonthView::nextCell()
2212{ 2217{
2213 bool res = focusNextPrevChild ( true ); 2218 focusNextPrevChild ( true );
2214} 2219}
2215void KOMonthView::prevCell() 2220void KOMonthView::prevCell()
2216{ 2221{
2217 focusNextPrevChild ( false ); 2222 focusNextPrevChild ( false );
2218} 2223}
2219 2224
2220void KOMonthView::slotNewTodo() 2225void KOMonthView::slotNewTodo()
2221{ 2226{
2222 //qDebug("KOMonthView::slotNewTodo() "); 2227 //qDebug("KOMonthView::slotNewTodo() ");
2223 if ( mPopupCell ){ 2228 if ( mPopupCell ){
2224 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 2229 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
2225 emit newTodoSignal(dt,true); 2230 emit newTodoSignal(dt,true);
2226 } 2231 }
2227 mPopupCell = 0; 2232 mPopupCell = 0;
2228} 2233}
2229void KOMonthView::slotNewEvent() 2234void KOMonthView::slotNewEvent()
2230{ 2235{
2231 if ( mPopupCell ) { 2236 if ( mPopupCell ) {
2232 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 2237 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
2233 emit newEventSignal( dt ); 2238 emit newEventSignal( dt );
2234 } 2239 }
2235 //qDebug("KOMonthView::slotNewEvent() "); 2240 //qDebug("KOMonthView::slotNewEvent() ");
2236 mPopupCell = 0; 2241 mPopupCell = 0;
2237} 2242}
2238 2243
2239void KOMonthView::slotEditJournal() 2244void KOMonthView::slotEditJournal()
2240{ 2245{
2241 if ( mPopupCell ) 2246 if ( mPopupCell )
2242 emit showJournalSignal( 7, mPopupCell->date() ); 2247 emit showJournalSignal( 7, mPopupCell->date() );
2243 //qDebug("KOMonthView::slotEditJournal() "); 2248 //qDebug("KOMonthView::slotEditJournal() ");
2244 mPopupCell = 0; 2249 mPopupCell = 0;
2245} 2250}
2246 2251
2247void KOMonthView::setPopupCell( MonthViewCell * c) 2252void KOMonthView::setPopupCell( MonthViewCell * c)
2248{ 2253{
2249 mPopupCell = c; 2254 mPopupCell = c;
2250} 2255}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index a41eb54..4d62e9b 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -7,340 +7,342 @@
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef _KOMONTHVIEW_H 20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H 21#define _KOMONTHVIEW_H
22 22
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qintdict.h> 31#include <qintdict.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qvaluelist.h> 33#include <qvaluelist.h>
34#include <qptrvector.h> 34#include <qptrvector.h>
35 35
36#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
37#include <libkcal/event.h> 37#include <libkcal/event.h>
38 38
39#include "koeventview.h" 39#include "koeventview.h"
40#include "navigatorbar.h" 40#include "navigatorbar.h"
41 41
42#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
43class QToolTipGroup; 43class QToolTipGroup;
44#endif 44#endif
45 45
46class KNOWhatsThis; 46class KNOWhatsThis;
47class MonthViewCell; 47class MonthViewCell;
48class KOWeekButton : public QPushButton 48class KOWeekButton : public QPushButton
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 public: 51 public:
52 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 52 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
53 QPushButton( parent, name) 53 QPushButton( parent, name)
54 { 54 {
55 connect( this, SIGNAL( clicked() ), 55 connect( this, SIGNAL( clicked() ),
56 SLOT( bottonClicked() )); 56 SLOT( bottonClicked() ));
57 mNumber = -1; 57 mNumber = -1;
58 } 58 }
59 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 59 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
60 int getWeekNum() { return mNumber;} 60 int getWeekNum() { return mNumber;}
61 signals: 61 signals:
62 void selectWeekNum ( int ); 62 void selectWeekNum ( int );
63private: 63private:
64 void focusInEvent ( QFocusEvent * ){;} 64 void focusInEvent ( QFocusEvent * ){;}
65 int mNumber; 65 int mNumber;
66 void keyPressEvent ( QKeyEvent * e ) 66 void keyPressEvent ( QKeyEvent * e )
67 { 67 {
68 e->ignore(); 68 e->ignore();
69 } 69 }
70 70
71private slots : 71private slots :
72 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 72 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
73}; 73};
74 74
75class KNoScrollListBox: public QListBox 75class KNoScrollListBox: public QListBox
76{ 76{
77 Q_OBJECT 77 Q_OBJECT
78 public: 78 public:
79 KNoScrollListBox(QWidget *parent=0, const char *name=0); 79 KNoScrollListBox(QWidget *parent=0, const char *name=0);
80 ~KNoScrollListBox(); 80 ~KNoScrollListBox();
81 QString getWhatsThisText(QPoint p) ; 81 QString getWhatsThisText(QPoint p) ;
82 82
83 signals: 83 signals:
84 void shiftDown(); 84 void shiftDown();
85 void shiftUp(); 85 void shiftUp();
86 void rightClick(); 86 void rightClick();
87 void nextCell(); 87 void nextCell();
88 void prevCell(); 88 void prevCell();
89 void highlightIncidence( Incidence * , MonthViewCell*, int ); 89 void highlightIncidence( Incidence * , MonthViewCell*, int );
90 90
91 protected slots: 91 protected slots:
92 void oneDown(); 92 void oneDown();
93 void keyPressEvent(QKeyEvent *); 93 void keyPressEvent(QKeyEvent *);
94 void keyReleaseEvent(QKeyEvent *); 94 void keyReleaseEvent(QKeyEvent *);
95 void mousePressEvent(QMouseEvent *); 95 void mousePressEvent(QMouseEvent *);
96 void focusInEvent ( QFocusEvent * ); 96 void focusInEvent ( QFocusEvent * );
97 void focusOutEvent ( QFocusEvent * ); 97 void focusOutEvent ( QFocusEvent * );
98 98
99 private: 99 private:
100 bool resetOnFocusIn; 100 bool resetOnFocusIn;
101 KNOWhatsThis * mWT; 101 KNOWhatsThis * mWT;
102}; 102};
103 103
104 104
105class MonthViewItem: public QListBoxItem 105class MonthViewItem: public QListBoxItem
106{ 106{
107 public: 107 public:
108 MonthViewItem( Incidence *,const QString & title ); 108 MonthViewItem( Incidence *,const QString & title );
109 void recycle( Incidence *incidence, const QString & s); 109 void recycle( Incidence *incidence, const QString & s);
110 void setRecur(bool on) { mRecur = on; } 110 void setRecur(bool on) { mRecur = on; }
111 void setAlarm(bool on) { mAlarm = on; } 111 void setAlarm(bool on) { mAlarm = on; }
112 void setReply(bool on) { mReply = on; } 112 void setReply(bool on) { mReply = on; }
113 void setMoreInfo(bool on) { mInfo = on; } 113 void setMoreInfo(bool on) { mInfo = on; }
114 void setMultiDay(int type) { mMultiday = type; } 114 void setMultiDay(int type) { mMultiday = type; }
115 int multiDay() { return mMultiday; } 115 int multiDay() { return mMultiday; }
116 void setMultiDayPos(int type) { mdayPos = type; } 116 void setMultiDayPos(int type) { mdayPos = type; }
117 int gettMultiDayPos() { return mdayPos; } 117 int gettMultiDayPos() { return mdayPos; }
118 void setBlockRepaint(bool on) { mblockRepaint = on; } 118 void setBlockRepaint(bool on) { mblockRepaint = on; }
119 bool setHighlighted( Incidence * ); 119 bool setHighlighted( Incidence * );
120 120
121 void setPalette(const QPalette &p) { mPalette = p; } 121 void setPalette(const QPalette &p) { mPalette = p; }
122 QPalette palette() const { return mPalette; } 122 QPalette palette() const { return mPalette; }
123 bool setHighlightedFalse(); 123 bool setHighlightedFalse();
124 Incidence *incidence() const { return mIncidence; } 124 Incidence *incidence() const { return mIncidence; }
125 125
126 protected: 126 protected:
127 virtual void paint(QPainter *); 127 virtual void paint(QPainter *);
128 virtual int height(const QListBox *) const; 128 virtual int height(const QListBox *) const;
129 virtual int width(const QListBox *) const; 129 virtual int width(const QListBox *) const;
130 130
131 private: 131 private:
132 int mdayPos; 132 int mdayPos;
133 bool isWeekItem; 133 bool isWeekItem;
134 bool mblockRepaint; 134 bool mblockRepaint;
135 int mMultiday; 135 int mMultiday;
136 bool mRecur; 136 bool mRecur;
137 bool mAlarm; 137 bool mAlarm;
138 bool mReply; 138 bool mReply;
139 bool mInfo; 139 bool mInfo;
140 bool mDisplayHighlighted; 140 bool mDisplayHighlighted;
141 141
142 QPalette mPalette; 142 QPalette mPalette;
143 QDate mDate; 143 QDate mDate;
144 144
145 Incidence *mIncidence; 145 Incidence *mIncidence;
146}; 146};
147 147
148 148
149class KOMonthView; 149class KOMonthView;
150 150
151class MonthViewCell : public KNoScrollListBox 151class MonthViewCell : public KNoScrollListBox
152{ 152{
153 Q_OBJECT 153 Q_OBJECT
154 public: 154 public:
155 MonthViewCell(KOMonthView *,QWidget* ); 155 MonthViewCell(KOMonthView *,QWidget* );
156 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} 156 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
157 157
158 void setDate( const QDate & ); 158 void setDate( const QDate & );
159 QDate date() const; 159 QDate date() const;
160 160
161 void setPrimary( bool ); 161 void setPrimary( bool );
162 bool isPrimary() const; 162 bool isPrimary() const;
163 163
164 void setHoliday( bool ); 164 void setHoliday( bool );
165 void setHoliday( const QString & ); 165 void setHoliday( const QString & );
166 166
167 void updateCell(); 167 void updateCell();
168 void startUpdateCell(); 168 void startUpdateCell();
169 void finishUpdateCell(); 169 void finishUpdateCell();
170 int insertEvent(Event *); 170 int insertEvent(Event *);
171 void insertTodo(Todo *); 171 void insertTodo(Todo *);
172 172
173 void updateConfig( bool bigFont = false ); 173 void updateConfig( bool bigFont = false );
174 174
175 void enableScrollBars( bool ); 175 void enableScrollBars( bool );
176 176
177 Incidence *selectedIncidence(); 177 Incidence *selectedIncidence();
178 QDate selectedIncidenceDate(); 178 QDate selectedIncidenceDate();
179 QPushButton * dateLabel() { return mLabel; } 179 QPushButton * dateLabel() { return mLabel; }
180 bool doHighLight( Incidence *); 180 bool doHighLight( Incidence *);
181 void deselect(); 181 void deselect();
182 void select(); 182 void select();
183#ifdef DESKTOP_VERSION 183#ifdef DESKTOP_VERSION
184 static QToolTipGroup *toolTipGroup(); 184 static QToolTipGroup *toolTipGroup();
185#endif 185#endif
186 signals: 186 signals:
187 void defaultAction( Incidence * ); 187 void defaultAction( Incidence * );
188 void newEventSignal( QDateTime ); 188 void newEventSignal( QDateTime );
189 void showDaySignal( QDate ); 189 void showDaySignal( QDate );
190 190
191 protected: 191 protected:
192 QStringList mToolTip; 192 QStringList mToolTip;
193 void resizeEvent( QResizeEvent * ); 193 void resizeEvent( QResizeEvent * );
194 194
195public slots: 195public slots:
196 void showDay(); 196 void showDay();
197 void deHighLight(); 197 void deHighLight();
198 void repaintfinishUpdateCell(); 198 void repaintfinishUpdateCell();
199 protected slots: 199 protected slots:
200 void defaultAction( QListBoxItem * ); 200 void defaultAction( QListBoxItem * );
201 void contextMenu( QListBoxItem * ); 201 void contextMenu( QListBoxItem * );
202 void selection( QListBoxItem * ); 202 void selection( QListBoxItem * );
203 void cellClicked( QListBoxItem * ); 203 void cellClicked( QListBoxItem * );
204 void newEvent(); 204 void newEvent();
205 205
206 private: 206 private:
207 int mdayCount; 207 int mdayCount;
208 QPtrList <MonthViewItem> mAvailItemList; 208 QPtrList <MonthViewItem> mAvailItemList;
209 KOMonthView *mMonthView; 209 KOMonthView *mMonthView;
210 int currentPalette; 210 int currentPalette;
211 211
212 QDate mDate; 212 QDate mDate;
213 bool mPrimary; 213 bool mPrimary;
214 bool mHoliday; 214 bool mHoliday;
215 QString mHolidayString; 215 QString mHolidayString;
216 216
217 //QLabel *mLabel; 217 //QLabel *mLabel;
218 QPushButton *mLabel; 218 QPushButton *mLabel;
219 //QListBox *mItemList; 219 //QListBox *mItemList;
220#ifdef DESKTOP_VERSION 220#ifdef DESKTOP_VERSION
221 static QToolTipGroup *mToolTipGroup; 221 static QToolTipGroup *mToolTipGroup;
222#endif 222#endif
223 QSize mLabelSize; 223 QSize mLabelSize;
224 QSize mLabelBigSize; 224 QSize mLabelBigSize;
225 QPalette mHolidayPalette; 225 QPalette mHolidayPalette;
226 QPalette mStandardPalette; 226 QPalette mStandardPalette;
227 QPalette mPrimaryPalette; 227 QPalette mPrimaryPalette;
228 QPalette mNonPrimaryPalette; 228 QPalette mNonPrimaryPalette;
229 void setMyPalette(); 229 void setMyPalette();
230 QPalette getPalette (); 230 QPalette getPalette ();
231 231
232}; 232};
233 233
234 234
235class KOMonthView: public KOEventView 235class KOMonthView: public KOEventView
236{ 236{
237 Q_OBJECT 237 Q_OBJECT
238 public: 238 public:
239 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 239 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
240 ~KOMonthView(); 240 ~KOMonthView();
241 241
242 /** Returns maximum number of days supported by the komonthview */ 242 /** Returns maximum number of days supported by the komonthview */
243 virtual int maxDatesHint(); 243 virtual int maxDatesHint();
244 244
245 /** Returns number of currently shown dates. */ 245 /** Returns number of currently shown dates. */
246 virtual int currentDateCount(); 246 virtual int currentDateCount();
247 247
248 /** returns the currently selected events */ 248 /** returns the currently selected events */
249 virtual QPtrList<Incidence> selectedIncidences(); 249 virtual QPtrList<Incidence> selectedIncidences();
250 250
251 /** returns dates of the currently selected events */ 251 /** returns dates of the currently selected events */
252 virtual DateList selectedDates(); 252 virtual DateList selectedDates();
253 253#if 0
254 virtual void printPreview(CalPrinter *calPrinter, 254 virtual void printPreview(CalPrinter *calPrinter,
255 const QDate &, const QDate &); 255 const QDate &, const QDate &);
256#endif
256 bool isMonthView() { return !mShowWeekView; } 257 bool isMonthView() { return !mShowWeekView; }
257 bool isUpdatePossible() { return updatePossible; } 258 bool isUpdatePossible() { return updatePossible; }
258 259
259 MonthViewCell * selectedCell(); 260 MonthViewCell * selectedCell();
260 bool skipResize; 261 bool skipResize;
261 NavigatorBar* navigatorBar() { return mNavigatorBar ;} 262 NavigatorBar* navigatorBar() { return mNavigatorBar ;}
262 void clearList(); 263 void clearList();
263 public slots: 264 public slots:
264 void incidenceHighlighted( Incidence *, MonthViewCell*, int ); 265 void incidenceHighlighted( Incidence *, MonthViewCell*, int );
265 void nextCell(); 266 void nextCell();
266 void prevCell(); 267 void prevCell();
267 virtual void updateView(); 268 virtual void updateView();
268 virtual void updateConfig(); 269 virtual void updateConfig();
269 virtual void showDates(const QDate &start, const QDate &end); 270 virtual void showDates(const QDate &start, const QDate &end);
270 virtual void showEvents(QPtrList<Event> eventList); 271 virtual void showEvents(QPtrList<Event> eventList);
271 272
272 void changeEventDisplay(Event *, int); 273 void changeEventDisplay(Event *, int);
273 274
274 void clearSelection(); 275 void clearSelection();
275 276
276 void showContextMenu( Incidence * ); 277 void showContextMenu( Incidence * );
277 278
278 void setSelectedCell( MonthViewCell * ); 279 void setSelectedCell( MonthViewCell * );
279 void setPopupCell( MonthViewCell * ); 280 void setPopupCell( MonthViewCell * );
280 void switchView(); 281 void switchView();
281 void setKeyBFocus(); 282 void setKeyBFocus();
282 283
283 protected slots: 284 protected slots:
285 void catChanged( Incidence * );
284 void setKeyBoardFocus(); 286 void setKeyBoardFocus();
285 void slotNewTodo(); 287 void slotNewTodo();
286 void slotNewEvent(); 288 void slotNewEvent();
287 void slotEditJournal(); 289 void slotEditJournal();
288 void slotComputeLayout(); 290 void slotComputeLayout();
289 void selectInternalWeekNum ( int ); 291 void selectInternalWeekNum ( int );
290 void processSelectionChange(); 292 void processSelectionChange();
291 signals: 293 signals:
292 void nextMonth(); 294 void nextMonth();
293 void prevMonth(); 295 void prevMonth();
294 void selectWeekNum ( int ); 296 void selectWeekNum ( int );
295 void selectMonth (); 297 void selectMonth ();
296 void showDaySignal( QDate ); 298 void showDaySignal( QDate );
297 void newTodoSignal( QDateTime, bool ); 299 void newTodoSignal( QDateTime, bool );
298 void showJournalSignal( int,QDate ); 300 void showJournalSignal( int,QDate );
299 protected: 301 protected:
300 void resizeEvent(QResizeEvent *); 302 void resizeEvent(QResizeEvent *);
301 void viewChanged(); 303 void viewChanged();
302 void updateDayLabels(); 304 void updateDayLabels();
303 305
304 private: 306 private:
305 int mKBFcounter; 307 int mKBFcounter;
306 QTimer* mComputeLayoutTimer; 308 QTimer* mComputeLayoutTimer;
307 NavigatorBar* mNavigatorBar; 309 NavigatorBar* mNavigatorBar;
308 int currentWeek(); 310 int currentWeek();
309 bool clPending; 311 bool clPending;
310 QWidgetStack * mWidStack; 312 QWidgetStack * mWidStack;
311 QWidget* mMonthView; 313 QWidget* mMonthView;
312 QWidget* mWeekView; 314 QWidget* mWeekView;
313 bool mShowWeekView; 315 bool mShowWeekView;
314 bool updatePossible; 316 bool updatePossible;
315 int mDaysPerWeek; 317 int mDaysPerWeek;
316 int mNumWeeks; 318 int mNumWeeks;
317 int mNumCells; 319 int mNumCells;
318 //bool mWeekStartsMonday; 320 //bool mWeekStartsMonday;
319 bool mShowSatSunComp; 321 bool mShowSatSunComp;
320 void computeLayout(); 322 void computeLayout();
321 void computeLayoutWeek(); 323 void computeLayoutWeek();
322 324
323 QPtrVector<MonthViewCell> mCells; 325 QPtrVector<MonthViewCell> mCells;
324 QPtrVector<QLabel> mDayLabels; 326 QPtrVector<QLabel> mDayLabels;
325 QPtrVector<KOWeekButton> mWeekLabels; 327 QPtrVector<KOWeekButton> mWeekLabels;
326 QPtrVector<MonthViewCell> mCellsW; 328 QPtrVector<MonthViewCell> mCellsW;
327 QPtrVector<QLabel> mDayLabelsW; 329 QPtrVector<QLabel> mDayLabelsW;
328 QPtrVector<KOWeekButton> mWeekLabelsW; 330 QPtrVector<KOWeekButton> mWeekLabelsW;
329 331
330 bool mShortDayLabelsM; 332 bool mShortDayLabelsM;
331 bool mShortDayLabelsW; 333 bool mShortDayLabelsW;
332 int mWidthLongDayLabel; 334 int mWidthLongDayLabel;
333 335
334 QDate mStartDate; 336 QDate mStartDate;
335 337
336 MonthViewCell *mSelectedCell; 338 MonthViewCell *mSelectedCell;
337 MonthViewCell *mPopupCell; 339 MonthViewCell *mPopupCell;
338 bool mFlagKeyPressed; 340 bool mFlagKeyPressed;
339 KOEventPopupMenu *mContextMenu; 341 KOEventPopupMenu *mContextMenu;
340 QPopupMenu *mNewItemMenu; 342 QPopupMenu *mNewItemMenu;
341 void keyPressEvent ( QKeyEvent * ) ; 343 void keyPressEvent ( QKeyEvent * ) ;
342 void keyReleaseEvent ( QKeyEvent * ) ; 344 void keyReleaseEvent ( QKeyEvent * ) ;
343 345
344}; 346};
345 347
346#endif 348#endif