summaryrefslogtreecommitdiffabout
path: root/korganizer/kolistview.cpp
Unidiff
Diffstat (limited to 'korganizer/kolistview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kolistview.cpp193
1 files changed, 101 insertions, 92 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 192f8c0..0ea1d50 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -13,38 +13,47 @@
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlistview.h> 25#include <q3listview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <q3popupmenu.h>
29#include <qprogressbar.h> 29#include <q3progressbar.h>
30#include <qfileinfo.h> 30#include <qfileinfo.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qtextstream.h> 33#include <q3textstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qwhatsthis.h> 35#include <q3whatsthis.h>
36#include <qregexp.h> 36#include <qregexp.h>
37#include <qpainter.h> 37#include <qpainter.h>
38#include <qpaintdevicemetrics.h> 38#include <q3paintdevicemetrics.h>
39//Added by qt3to4:
40#include <QPixmap>
41#include <QMouseEvent>
42#include <QKeyEvent>
43#include <QEvent>
44#include <Q3VBoxLayout>
45#include <Q3PtrList>
46
47#include<QDesktopWidget>
39 48
40#include <klocale.h> 49#include <klocale.h>
41#include <kdebug.h> 50#include <kdebug.h>
42#include <kiconloader.h> 51#include <kiconloader.h>
43#include <kglobal.h> 52#include <kglobal.h>
44 53
45#include <libkdepim/kpimglobalprefs.h> 54#include <libkdepim/kpimglobalprefs.h>
46#include <libkcal/calendar.h> 55#include <libkcal/calendar.h>
47#include <libkcal/calendarlocal.h> 56#include <libkcal/calendarlocal.h>
48#include <libkcal/icalformat.h> 57#include <libkcal/icalformat.h>
49#include <libkcal/vcalformat.h> 58#include <libkcal/vcalformat.h>
50#include <libkcal/recurrence.h> 59#include <libkcal/recurrence.h>
@@ -61,28 +70,28 @@
61#include "calprinter.h" 70#include "calprinter.h"
62#endif 71#endif
63#include "koglobals.h" 72#include "koglobals.h"
64#include "koprefs.h" 73#include "koprefs.h"
65#include "kfiledialog.h" 74#include "kfiledialog.h"
66 75
67#include "kolistview.h" 76#include "kolistview.h"
68#include "koeventviewer.h" 77#include "koeventviewer.h"
69 78
70extern QPixmap* sgListViewCompletedPix[6]; 79extern QPixmap* sgListViewCompletedPix[6];
71extern QPixmap* sgListViewJournalPix; 80extern QPixmap* sgListViewJournalPix;
72 81
73class KOListViewWhatsThis :public QWhatsThis 82class KOListViewWhatsThis :public Q3WhatsThis
74{ 83{
75public: 84public:
76 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 85 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : Q3WhatsThis( wid ), _wid(wid),_view (view) { };
77 86
78protected: 87protected:
79 virtual QString text( const QPoint& p) 88 virtual QString text( const QPoint& p)
80 { 89 {
81 return _view->getWhatsThisText(p) ; 90 return _view->getWhatsThisText(p) ;
82 } 91 }
83private: 92private:
84 QWidget* _wid; 93 QWidget* _wid;
85 KOListView * _view; 94 KOListView * _view;
86}; 95};
87 96
88 97
@@ -265,81 +274,81 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent,
265 mListView->addColumn(i18n("Start Date")); 274 mListView->addColumn(i18n("Start Date"));
266 mListView->addColumn(i18n("Start Time")); 275 mListView->addColumn(i18n("Start Time"));
267 mListView->addColumn(i18n("End/Due Date")); 276 mListView->addColumn(i18n("End/Due Date"));
268 mListView->addColumn(i18n("End/Due Time")); 277 mListView->addColumn(i18n("End/Due Time"));
269 mListView->addColumn(i18n("Duration")); 278 mListView->addColumn(i18n("Duration"));
270 mListView->addColumn(i18n("Alarm")); // alarm set? 279 mListView->addColumn(i18n("Alarm")); // alarm set?
271 mListView->addColumn(i18n("Recurs")); // recurs? 280 mListView->addColumn(i18n("Recurs")); // recurs?
272 mListView->addColumn(i18n("Cancelled")); 281 mListView->addColumn(i18n("Cancelled"));
273 mListView->addColumn(i18n("Categories")); 282 mListView->addColumn(i18n("Categories"));
274 mListView->addColumn(i18n("Calendar")); 283 mListView->addColumn(i18n("Calendar"));
275 mListView->addColumn(i18n("Last Modified")); 284 mListView->addColumn(i18n("Last Modified"));
276 285
277 mListView->setColumnAlignment(0,AlignLeft); 286 mListView->setColumnAlignment(0,Qt::AlignLeft);
278 mListView->setColumnAlignment(1,AlignLeft); 287 mListView->setColumnAlignment(1,Qt::AlignLeft);
279 mListView->setColumnAlignment(2,AlignHCenter); 288 mListView->setColumnAlignment(2,Qt::AlignHCenter);
280 mListView->setColumnAlignment(3,AlignLeft); 289 mListView->setColumnAlignment(3,Qt::AlignLeft);
281 mListView->setColumnAlignment(4,AlignHCenter); 290 mListView->setColumnAlignment(4,Qt::AlignHCenter);
282 mListView->setColumnAlignment(5,AlignLeft); 291 mListView->setColumnAlignment(5,Qt::AlignLeft);
283 mListView->setColumnAlignment(6,AlignLeft); 292 mListView->setColumnAlignment(6,Qt::AlignLeft);
284 mListView->setColumnAlignment(7,AlignLeft); 293 mListView->setColumnAlignment(7,Qt::AlignLeft);
285 mListView->setColumnAlignment(8,AlignLeft); 294 mListView->setColumnAlignment(8,Qt::AlignLeft);
286 mListView->setColumnAlignment(9,AlignLeft); 295 mListView->setColumnAlignment(9,Qt::AlignLeft);
287 mListView->setColumnAlignment(10,AlignLeft); 296 mListView->setColumnAlignment(10,Qt::AlignLeft);
288 mListView->setColumnAlignment(11,AlignLeft); 297 mListView->setColumnAlignment(11,Qt::AlignLeft);
289 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 298 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
290 299
291 int iii = 0; 300 int iii = 0;
292 for ( iii = 0; iii< 12 ; ++iii ) 301 for ( iii = 0; iii< 12 ; ++iii )
293 mListView->setColumnWidthMode( iii, QListView::Manual ); 302 mListView->setColumnWidthMode( iii, Q3ListView::Manual );
294 303
295 QBoxLayout *layoutTop = new QVBoxLayout(this); 304 Q3BoxLayout *layoutTop = new Q3VBoxLayout(this);
296 layoutTop->addWidget(mListView); 305 layoutTop->addWidget(mListView);
297 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 306 mListView->setFont ( KOPrefs::instance()->mListViewFont );
298 mPopupMenu = eventPopup(); 307 mPopupMenu = eventPopup();
299 QPopupMenu* selPopup = new QPopupMenu ( this ); 308 Q3PopupMenu* selPopup = new Q3PopupMenu ( this );
300 mPopupMenu->insertSeparator(); 309 mPopupMenu->insertSeparator();
301 310
302 selPopup->insertItem(i18n("All"),this, 311 selPopup->insertItem(i18n("All"),this,
303 SLOT(allSelection())); 312 SLOT(allSelection()));
304 selPopup->insertItem(i18n("None"),this, 313 selPopup->insertItem(i18n("None"),this,
305 SLOT(clearSelection())); 314 SLOT(clearSelection()));
306 selPopup->insertItem(i18n("Delete selected..."),this, 315 selPopup->insertItem(i18n("Delete selected..."),this,
307 SLOT(deleteAll())); 316 SLOT(deleteAll()));
308 mPopupMenu->insertItem(i18n("Selection"), selPopup ); 317 mPopupMenu->insertItem(i18n("Selection"), selPopup );
309 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 318 mPopupMenu->addAdditionalItem(QIcon(QPixmap()),
310 i18n("Hide all selected"),this, 319 i18n("Hide all selected"),this,
311 SLOT(hideAll()),true); 320 SLOT(hideAll()),true);
312 321
313 selPopup->insertSeparator(); 322 selPopup->insertSeparator();
314 QPopupMenu * exportPO = new QPopupMenu ( this ); 323 Q3PopupMenu * exportPO = new Q3PopupMenu ( this );
315 selPopup->insertItem( i18n("Export"), exportPO ); 324 selPopup->insertItem( i18n("Export"), exportPO );
316#ifdef DESKTOP_VERSION 325#ifdef DESKTOP_VERSION
317 mPopupMenu->insertSeparator(); 326 mPopupMenu->insertSeparator();
318 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 327 mPopupMenu->addAdditionalItem(QIcon(QPixmap()),
319 i18n("Print complete list..."),this, 328 i18n("Print complete list..."),this,
320 SLOT(printList()),true); 329 SLOT(printList()),true);
321#endif 330#endif
322 mCalPopup = new QPopupMenu ( this ); 331 mCalPopup = new Q3PopupMenu ( this );
323 selPopup->insertItem( i18n("Set Calendar"), mCalPopup ); 332 selPopup->insertItem( i18n("Set Calendar"), mCalPopup );
324 333
325 selPopup->insertItem(i18n("Set categories")+"...",this, 334 selPopup->insertItem(i18n("Set categories")+"...",this,
326 SLOT(setCat()) ); 335 SLOT(setCat()) );
327 selPopup->insertItem( i18n("Set alarm..."),this, 336 selPopup->insertItem( i18n("Set alarm..."),this,
328 SLOT(setAlarm())); 337 SLOT(setAlarm()));
329#if 0 338#if 0
330 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 339 mPopupMenu->addAdditionalItem(QIcon(QPixmap()),
331 i18n("Set categories")+"...",this, 340 i18n("Set categories")+"...",this,
332 SLOT(setCat()),true); 341 SLOT(setCat()),true);
333 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 342 mPopupMenu->addAdditionalItem(QIcon(QPixmap()),
334 i18n("Set alarm..."),this, 343 i18n("Set alarm..."),this,
335 SLOT(setAlarm()),true); 344 SLOT(setAlarm()),true);
336#endif 345#endif
337 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, 346 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this,
338 SLOT( populateCalPopup() )); 347 SLOT( populateCalPopup() ));
339 QObject::connect(mCalPopup,SIGNAL(activated( int )),this, 348 QObject::connect(mCalPopup,SIGNAL(activated( int )),this,
340 SLOT( setCalendar( int ) )); 349 SLOT( setCalendar( int ) ));
341 QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, 350 QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this,
342 SLOT( catChanged( Incidence * ) )); 351 SLOT( catChanged( Incidence * ) ));
343 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 352 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
344 SLOT(saveToFile())); 353 SLOT(saveToFile()));
345 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 354 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
@@ -347,50 +356,50 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent,
347 exportPO->insertItem( i18n("Journal/Details..."),this, 356 exportPO->insertItem( i18n("Journal/Details..."),this,
348 SLOT(saveDescriptionToFile())); 357 SLOT(saveDescriptionToFile()));
349 // mPopupMenu->insertSeparator(); 358 // mPopupMenu->insertSeparator();
350 // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 359 // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
351 // i18n("Add Categ. to selected..."),this, 360 // i18n("Add Categ. to selected..."),this,
352 // SLOT(addCat()),true); 361 // SLOT(addCat()),true);
353 //mPopupMenu->insertSeparator(); 362 //mPopupMenu->insertSeparator();
354#ifndef DESKTOP_VERSION 363#ifndef DESKTOP_VERSION
355 selPopup->insertSeparator(); 364 selPopup->insertSeparator();
356 selPopup->insertItem( i18n("Beam via IR..."),this, 365 selPopup->insertItem( i18n("Beam via IR..."),this,
357 SLOT(beamSelected())); 366 SLOT(beamSelected()));
358#if 0 367#if 0
359 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 368 mPopupMenu->addAdditionalItem(QIcon(QPixmap()),
360 i18n("Beam via IR"),this, 369 i18n("Beam via IR"),this,
361 SLOT(beamSelected()),true); 370 SLOT(beamSelected()),true);
362#endif 371#endif
363#endif 372#endif
364 /* 373 /*
365 mPopupMenu = new QPopupMenu; 374 mPopupMenu = new QPopupMenu;
366 mPopupMenu->insertItem(i18n("Edit Event"), this, 375 mPopupMenu->insertItem(i18n("Edit Event"), this,
367 SLOT (editEvent())); 376 SLOT (editEvent()));
368 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 377 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
369 SLOT (deleteEvent())); 378 SLOT (deleteEvent()));
370 mPopupMenu->insertSeparator(); 379 mPopupMenu->insertSeparator();
371 mPopupMenu->insertItem(i18n("Show Dates"), this, 380 mPopupMenu->insertItem(i18n("Show Dates"), this,
372 SLOT(showDates())); 381 SLOT(showDates()));
373 mPopupMenu->insertItem(i18n("Hide Dates"), this, 382 mPopupMenu->insertItem(i18n("Hide Dates"), this,
374 SLOT(hideDates())); 383 SLOT(hideDates()));
375 */ 384 */
376 QObject::connect(mListView,SIGNAL( newEvent()), 385 QObject::connect(mListView,SIGNAL( newEvent()),
377 this,SIGNAL(signalNewEvent())); 386 this,SIGNAL(signalNewEvent()));
378 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 387 QObject::connect(mListView,SIGNAL(doubleClicked(Q3ListViewItem *)),
379 this,SLOT(defaultItemAction(QListViewItem *))); 388 this,SLOT(defaultItemAction(Q3ListViewItem *)));
380 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 389 QObject::connect(mListView,SIGNAL(rightButtonPressed( Q3ListViewItem *,
381 const QPoint &, int )), 390 const QPoint &, int )),
382 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 391 this,SLOT(popupMenu(Q3ListViewItem *,const QPoint &,int)));
383 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 392 QObject::connect(mListView,SIGNAL(currentChanged(Q3ListViewItem *)),
384 SLOT(processSelectionChange(QListViewItem *))); 393 SLOT(processSelectionChange(Q3ListViewItem *)));
385 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 394 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
386 SIGNAL(showIncidenceSignal(Incidence *)) ); 395 SIGNAL(showIncidenceSignal(Incidence *)) );
387 396
388 readSettings(KOGlobals::config(),"KOListView Layout"); 397 readSettings(KOGlobals::config(),"KOListView Layout");
389} 398}
390 399
391KOListView::~KOListView() 400KOListView::~KOListView()
392{ 401{
393 delete mPopupMenu; 402 delete mPopupMenu;
394#if QT_VERSION >= 0x030000 403#if QT_VERSION >= 0x030000
395 404
396#else 405#else
@@ -419,39 +428,39 @@ QString KOListView::getWhatsThisText(QPoint p)
419} 428}
420 429
421void KOListView::setCalendar( int c ) 430void KOListView::setCalendar( int c )
422{ 431{
423 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 432 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
424 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), 433 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ),
425 i18n("Continue"), i18n("Cancel"), 0, 434 i18n("Continue"), i18n("Cancel"), 0,
426 0, 1 ); 435 0, 1 );
427 if ( result != 0 ) { 436 if ( result != 0 ) {
428 return; 437 return;
429 } 438 }
430 439
431 QPtrList<Incidence> delSel = getSelectedIncidences() ; 440 Q3PtrList<Incidence> delSel = getSelectedIncidences() ;
432 int icount = delSel.count(); 441 int icount = delSel.count();
433 if ( icount ) { 442 if ( icount ) {
434 Incidence *incidence = delSel.first(); 443 Incidence *incidence = delSel.first();
435 while ( incidence ) { 444 while ( incidence ) {
436 incidence->setCalID( c ); 445 incidence->setCalID( c );
437 KOListViewItem * item = getItemForEvent( incidence ); 446 KOListViewItem * item = getItemForEvent( incidence );
438 if ( item ) { 447 if ( item ) {
439 ListItemVisitor v(item, mStartDate ); 448 ListItemVisitor v(item, mStartDate );
440 incidence->accept(v); 449 incidence->accept(v);
441 } 450 }
442 incidence = delSel.next(); 451 incidence = delSel.next();
443 } 452 }
444 } 453 }
445 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 454 Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
446 KopiCalendarFile * cal = calendars.first(); 455 KopiCalendarFile * cal = calendars.first();
447 while ( cal ) { 456 while ( cal ) {
448 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 457 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
449 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 458 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
450 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 459 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
451 if ( cal->isStandard ) 460 if ( cal->isStandard )
452 mCalendar->setDefaultCalendar( cal->mCalNumber ); 461 mCalendar->setDefaultCalendar( cal->mCalNumber );
453 cal = calendars.next(); 462 cal = calendars.next();
454 } 463 }
455 mCalendar->setSyncEventsReadOnly(); 464 mCalendar->setSyncEventsReadOnly();
456 mCalendar->reInitAlarmSettings(); 465 mCalendar->reInitAlarmSettings();
457 466
@@ -488,50 +497,50 @@ void KOListView::setCat()
488 i18n("Add"), 497 i18n("Add"),
489 i18n("Reset")); 498 i18n("Reset"));
490 if (result == KMessageBox::Cancel) return; 499 if (result == KMessageBox::Cancel) return;
491 if (result == KMessageBox::Yes) set = false; 500 if (result == KMessageBox::Yes) set = false;
492 setCategories( set ); 501 setCategories( set );
493} 502}
494 503
495void KOListView::setAlarm() 504void KOListView::setAlarm()
496{ 505{
497 KOAlarmPrefs kap( this); 506 KOAlarmPrefs kap( this);
498 if ( !kap.exec() ) 507 if ( !kap.exec() )
499 return; 508 return;
500 QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos 509 Q3PtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos
501 Incidence* inc = delSel.first(); 510 Incidence* inc = delSel.first();
502 int count = 0; 511 int count = 0;
503 while ( inc ) { 512 while ( inc ) {
504 ++count; 513 ++count;
505 if (kap.mAlarmButton->isChecked()) { 514 if (kap.mAlarmButton->isChecked()) {
506 if (inc->alarms().count() == 0) 515 if (inc->alarms().count() == 0)
507 inc->newAlarm(); 516 inc->newAlarm();
508 Alarm *alarm = inc->alarms().first(); 517 Alarm *alarm = inc->alarms().first();
509 alarm->setEnabled(true); 518 alarm->setEnabled(true);
510 int j = kap.mAlarmTimeEdit->value()* -60; 519 int j = kap.mAlarmTimeEdit->value()* -60;
511 if (kap.mAlarmIncrCombo->currentItem() == 1) 520 if (kap.mAlarmIncrCombo->currentItem() == 1)
512 j = j * 60; 521 j = j * 60;
513 else if (kap.mAlarmIncrCombo->currentItem() == 2) 522 else if (kap.mAlarmIncrCombo->currentItem() == 2)
514 j = j * (60 * 24); 523 j = j * (60 * 24);
515 alarm->setStartOffset( j ); 524 alarm->setStartOffset( j );
516 525
517 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 526 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
518 alarm->setProcedureAlarm(kap.mAlarmProgram); 527 alarm->setProcedureAlarm(kap.mAlarmProgram);
519 } 528 }
520 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 529 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
521 alarm->setAudioAlarm(kap.mAlarmSound); 530 alarm->setAudioAlarm(kap.mAlarmSound);
522 else 531 else
523 alarm->setType(Alarm::Invalid); 532 alarm->setType(Alarm::Invalid);
524 } else { 533 } else {
525 QPtrList<Alarm> alarms = inc->alarms(); 534 Q3PtrList<Alarm> alarms = inc->alarms();
526 Alarm *alarm; 535 Alarm *alarm;
527 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 536 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
528 alarm->setEnabled(false); 537 alarm->setEnabled(false);
529 alarm->setType(Alarm::Invalid); 538 alarm->setType(Alarm::Invalid);
530 } 539 }
531 } 540 }
532 KOListViewItem* item = getItemForEvent(inc); 541 KOListViewItem* item = getItemForEvent(inc);
533 if (item) { 542 if (item) {
534 ListItemVisitor v(item, mStartDate ); 543 ListItemVisitor v(item, mStartDate );
535 inc->accept(v); 544 inc->accept(v);
536 } 545 }
537 inc = delSel.next(); 546 inc = delSel.next();
@@ -543,60 +552,60 @@ void KOListView::setAlarm()
543} 552}
544void KOListView::setCategories( bool removeOld ) 553void KOListView::setCategories( bool removeOld )
545{ 554{
546 555
547 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 556 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
548 csd->setColorEnabled(); 557 csd->setColorEnabled();
549 if (! csd->exec()) { 558 if (! csd->exec()) {
550 delete csd; 559 delete csd;
551 return; 560 return;
552 } 561 }
553 QStringList catList = csd->selectedCategories(); 562 QStringList catList = csd->selectedCategories();
554 delete csd; 563 delete csd;
555 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; 564 Q3PtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
556 Incidence* inc = delSel.first(); 565 Incidence* inc = delSel.first();
557 while ( inc ) { 566 while ( inc ) {
558 if ( removeOld ) { 567 if ( removeOld ) {
559 inc->setCategories( catList, false ); 568 inc->setCategories( catList, false );
560 } else { 569 } else {
561 inc->addCategories( catList, false ); 570 inc->addCategories( catList, false );
562 } 571 }
563 KOListViewItem* item = getItemForEvent(inc); 572 KOListViewItem* item = getItemForEvent(inc);
564 if (item) { 573 if (item) {
565 ListItemVisitor v(item, mStartDate ); 574 ListItemVisitor v(item, mStartDate );
566 inc->accept(v); 575 inc->accept(v);
567 } 576 }
568 inc = delSel.next(); 577 inc = delSel.next();
569 } 578 }
570 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 579 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
571} 580}
572 581
573void KOListView::beamSelected() 582void KOListView::beamSelected()
574{ 583{
575 QPtrList<Incidence> delSel = getSelectedIncidences() ; 584 Q3PtrList<Incidence> delSel = getSelectedIncidences() ;
576 if ( delSel.count() ) 585 if ( delSel.count() )
577 emit beamIncidenceList( delSel ); 586 emit beamIncidenceList( delSel );
578} 587}
579 588
580void KOListView::saveDescriptionToFile() 589void KOListView::saveDescriptionToFile()
581{ 590{
582 591
583 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 592 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
584 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 593 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
585 i18n("Continue"), i18n("Cancel"), 0, 594 i18n("Continue"), i18n("Cancel"), 0,
586 0, 1 ); 595 0, 1 );
587 if ( result != 0 ) { 596 if ( result != 0 ) {
588 return; 597 return;
589 } 598 }
590 QPtrList<Incidence> delSel = getSelectedIncidences() ; 599 Q3PtrList<Incidence> delSel = getSelectedIncidences() ;
591 int icount = delSel.count(); 600 int icount = delSel.count();
592 if ( icount ) { 601 if ( icount ) {
593 QString fn = KOPrefs::instance()->mLastSaveFile; 602 QString fn = KOPrefs::instance()->mLastSaveFile;
594 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 603 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
595 604
596 if ( fn == "" ) 605 if ( fn == "" )
597 return; 606 return;
598 QFileInfo info; 607 QFileInfo info;
599 info.setFile( fn ); 608 info.setFile( fn );
600 QString mes; 609 QString mes;
601 bool createbup = true; 610 bool createbup = true;
602 if ( info. exists() ) { 611 if ( info. exists() ) {
@@ -636,52 +645,52 @@ void KOListView::saveDescriptionToFile()
636 text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; 645 text +="\n(" + i18n("Location: ") + incidence->location()+ ")";
637 if ( incidence->hasStartDate() ) 646 if ( incidence->hasStartDate() )
638 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 647 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
639 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 648 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
640 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 649 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
641 ++icount; 650 ++icount;
642 651
643 } 652 }
644 } 653 }
645 incidence = delSel.next(); 654 incidence = delSel.next();
646 } 655 }
647 QFile file( fn ); 656 QFile file( fn );
648 if (!file.open( IO_WriteOnly ) ) { 657 if (!file.open( QIODevice::WriteOnly ) ) {
649 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 658 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
650 return; 659 return;
651 } 660 }
652 QTextStream ts( &file ); 661 Q3TextStream ts( &file );
653 ts << text; 662 ts << text;
654 file.close(); 663 file.close();
655 //qDebug("%s ", text.latin1()); 664 //qDebug("%s ", text.latin1());
656 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 665 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
657 KOPrefs::instance()->mLastSaveFile = fn; 666 KOPrefs::instance()->mLastSaveFile = fn;
658 topLevelWidget()->setCaption(mes); 667 topLevelWidget()->setCaption(mes);
659 } 668 }
660 } 669 }
661} 670}
662void KOListView::saveToFileVCS() 671void KOListView::saveToFileVCS()
663{ 672{
664 writeToFile( false ); 673 writeToFile( false );
665} 674}
666void KOListView::saveToFile() 675void KOListView::saveToFile()
667{ 676{
668 writeToFile( true ); 677 writeToFile( true );
669} 678}
670QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) 679Q3PtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos )
671{ 680{
672 QPtrList<Incidence> delSel ; 681 Q3PtrList<Incidence> delSel ;
673 bool addSubTodos = false; 682 bool addSubTodos = false;
674 bool askSubTodos = true; 683 bool askSubTodos = true;
675 QListViewItem *item = mListView->firstChild (); 684 Q3ListViewItem *item = mListView->firstChild ();
676 while ( item ) { 685 while ( item ) {
677 if ( item->isSelected() ) { 686 if ( item->isSelected() ) {
678 Incidence* inc = ((KOListViewItem *)item)->data(); 687 Incidence* inc = ((KOListViewItem *)item)->data();
679 if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { 688 if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) {
680 if ( (inc->typeID() == todoID && includeTodos) || 689 if ( (inc->typeID() == todoID && includeTodos) ||
681 (inc->typeID() == eventID && includeEvents) || 690 (inc->typeID() == eventID && includeEvents) ||
682 (inc->typeID() == journalID && includeJournals) ) { 691 (inc->typeID() == journalID && includeJournals) ) {
683 if ( inc->typeID() == todoID && onlyDueTodos ) { 692 if ( inc->typeID() == todoID && onlyDueTodos ) {
684 if ( ((Todo*)inc)->hasDueDate() ) 693 if ( ((Todo*)inc)->hasDueDate() )
685 delSel.append( inc ); 694 delSel.append( inc );
686 } else 695 } else
687 delSel.append( inc ); 696 delSel.append( inc );
@@ -697,49 +706,49 @@ QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool
697 i18n("Todo has subtodos"), 706 i18n("Todo has subtodos"),
698 i18n("Yes"), 707 i18n("Yes"),
699 i18n("No")); 708 i18n("No"));
700 if ( result == KMessageBox::Cancel ) { 709 if ( result == KMessageBox::Cancel ) {
701 delSel.clear(); 710 delSel.clear();
702 return delSel; 711 return delSel;
703 } 712 }
704 if (result == KMessageBox::Yes) 713 if (result == KMessageBox::Yes)
705 addSubTodos = true; 714 addSubTodos = true;
706 askSubTodos = false; 715 askSubTodos = false;
707 } 716 }
708 if ( addSubTodos ) { 717 if ( addSubTodos ) {
709 QPtrList<Incidence> tempSel ; 718 Q3PtrList<Incidence> tempSel ;
710 inc->addRelationsToList( &tempSel ); 719 inc->addRelationsToList( &tempSel );
711 Incidence* tempinc = tempSel.first(); 720 Incidence* tempinc = tempSel.first();
712 while ( tempinc ) { 721 while ( tempinc ) {
713 if ( delSel.findRef( tempinc ) == -1 ) { 722 if ( delSel.findRef( tempinc ) == -1 ) {
714 if ( tempinc->typeID() == todoID && onlyDueTodos ) { 723 if ( tempinc->typeID() == todoID && onlyDueTodos ) {
715 if ( ((Todo*)tempinc)->hasDueDate() ) 724 if ( ((Todo*)tempinc)->hasDueDate() )
716 delSel.append( tempinc ); 725 delSel.append( tempinc );
717 } else 726 } else
718 delSel.append( tempinc ); 727 delSel.append( tempinc );
719 } 728 }
720 tempinc = tempSel.next(); 729 tempinc = tempSel.next();
721 } 730 }
722 } 731 }
723 } 732 }
724 } 733 }
725 } 734 }
726 item = item->nextSibling(); 735 item = item->nextSibling();
727 } 736 }
728 return delSel; 737 return delSel;
729} 738}
730 739
731void KOListView::writeToFile( bool iCal ) 740void KOListView::writeToFile( bool iCal )
732{ 741{
733 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; 742 Q3PtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
734 if ( !iCal ) { 743 if ( !iCal ) {
735 bool journal = false; 744 bool journal = false;
736 Incidence *incidence = delSel.first(); 745 Incidence *incidence = delSel.first();
737 while ( incidence ) { 746 while ( incidence ) {
738 if ( incidence->typeID() == journalID ) { 747 if ( incidence->typeID() == journalID ) {
739 journal = true; 748 journal = true;
740 break; 749 break;
741 } 750 }
742 incidence = delSel.next(); 751 incidence = delSel.next();
743 } 752 }
744 if ( journal ) { 753 if ( journal ) {
745 int result = KMessageBox::warningContinueCancel(this, 754 int result = KMessageBox::warningContinueCancel(this,
@@ -794,64 +803,64 @@ void KOListView::writeToFile( bool iCal )
794 VCalFormat format; 803 VCalFormat format;
795 format.save( &cal, fn ); 804 format.save( &cal, fn );
796 } 805 }
797 mes = i18n("KO/Pi:Saved %1").arg(fn ); 806 mes = i18n("KO/Pi:Saved %1").arg(fn );
798 KOPrefs::instance()->mLastSaveFile = fn; 807 KOPrefs::instance()->mLastSaveFile = fn;
799 topLevelWidget()->setCaption(mes); 808 topLevelWidget()->setCaption(mes);
800 } 809 }
801 } 810 }
802 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 811 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
803} 812}
804void KOListView::hideAll() 813void KOListView::hideAll()
805{ 814{
806 QPtrList<QListViewItem> delSel ; 815 Q3PtrList<Q3ListViewItem> delSel ;
807 QListViewItem *item = mListView->firstChild (); 816 Q3ListViewItem *item = mListView->firstChild ();
808 while ( item ) { 817 while ( item ) {
809 if ( item->isSelected() ) { 818 if ( item->isSelected() ) {
810 delSel.append(item); 819 delSel.append(item);
811 } 820 }
812 item = item->nextSibling(); 821 item = item->nextSibling();
813 } 822 }
814 item = delSel.first() ; 823 item = delSel.first() ;
815 while ( item ) { 824 while ( item ) {
816 QListViewItem * del = item; 825 Q3ListViewItem * del = item;
817 item = delSel.next(); 826 item = delSel.next();
818 delete del; 827 delete del;
819 } 828 }
820} 829}
821void KOListView::printList() 830void KOListView::printList()
822{ 831{
823 mListView->printList(); 832 mListView->printList();
824} 833}
825void KOListView::deleteAll() 834void KOListView::deleteAll()
826{ 835{
827 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; 836 Q3PtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;;
828 if ( delSel.count() ) { 837 if ( delSel.count() ) {
829 int icount = delSel.count(); 838 int icount = delSel.count();
830 Incidence *incidence = delSel.first(); 839 Incidence *incidence = delSel.first();
831 Incidence *toDelete; 840 Incidence *toDelete;
832 KOPrefs *p = KOPrefs::instance(); 841 KOPrefs *p = KOPrefs::instance();
833 bool confirm = p->mConfirm; 842 bool confirm = p->mConfirm;
834 QString mess; 843 QString mess;
835 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 844 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
836 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 845 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
837 p->mConfirm = false; 846 p->mConfirm = false;
838 int delCounter = 0; 847 int delCounter = 0;
839 QDialog dia ( this, "p-dialog", true ); 848 QDialog dia ( this, "p-dialog", true );
840 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 849 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
841 QVBoxLayout lay( &dia ); 850 Q3VBoxLayout lay( &dia );
842 lay.setMargin(7); 851 lay.setMargin(7);
843 lay.setSpacing(7); 852 lay.setSpacing(7);
844 lay.addWidget( &lab); 853 lay.addWidget( &lab);
845 QProgressBar bar( icount, &dia ); 854 Q3ProgressBar bar( icount, &dia );
846 lay.addWidget( &bar); 855 lay.addWidget( &bar);
847 int w = 220; 856 int w = 220;
848 int h = 50; 857 int h = 50;
849 int dw = QApplication::desktop()->width(); 858 int dw = QApplication::desktop()->width();
850 int dh = QApplication::desktop()->height(); 859 int dh = QApplication::desktop()->height();
851 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 860 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
852 //dia.resize( 240,50 ); 861 //dia.resize( 240,50 );
853 dia.show(); 862 dia.show();
854 KOPrefs::instance()->mGlobalUpdateDisabled = true; 863 KOPrefs::instance()->mGlobalUpdateDisabled = true;
855 while ( incidence ) { 864 while ( incidence ) {
856 bar.setProgress( delCounter ); 865 bar.setProgress( delCounter );
857 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 866 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
@@ -875,28 +884,28 @@ void KOListView::deleteAll()
875 884
876} 885}
877int KOListView::maxDatesHint() 886int KOListView::maxDatesHint()
878{ 887{
879 return 0; 888 return 0;
880} 889}
881 890
882int KOListView::currentDateCount() 891int KOListView::currentDateCount()
883{ 892{
884 return 0; 893 return 0;
885} 894}
886 895
887QPtrList<Incidence> KOListView::selectedIncidences() 896Q3PtrList<Incidence> KOListView::selectedIncidences()
888{ 897{
889 QPtrList<Incidence> eventList; 898 Q3PtrList<Incidence> eventList;
890 QListViewItem *item = mListView->firstChild (); 899 Q3ListViewItem *item = mListView->firstChild ();
891 while ( item ) { 900 while ( item ) {
892 if ( item->isSelected() ) { 901 if ( item->isSelected() ) {
893 eventList.append(((KOListViewItem *)item)->data()); 902 eventList.append(((KOListViewItem *)item)->data());
894 } 903 }
895 904
896 item = item->nextSibling(); 905 item = item->nextSibling();
897 } 906 }
898 907
899 // // QListViewItem *item = mListView->selectedItem(); 908 // // QListViewItem *item = mListView->selectedItem();
900 //if (item) eventList.append(((KOListViewItem *)item)->data()); 909 //if (item) eventList.append(((KOListViewItem *)item)->data());
901 910
902 return eventList; 911 return eventList;
@@ -978,47 +987,47 @@ void KOListView::showDates(const QDate &start, const QDate &end)
978 QDate date = start; 987 QDate date = start;
979 while( date <= end ) { 988 while( date <= end ) {
980 addEvents(calendar()->events(date)); 989 addEvents(calendar()->events(date));
981 addTodos(calendar()->todos(date)); 990 addTodos(calendar()->todos(date));
982 addJournals( calendar()->journals4Date(date) ); 991 addJournals( calendar()->journals4Date(date) );
983 date = date.addDays( 1 ); 992 date = date.addDays( 1 );
984 } 993 }
985 //emit incidenceSelected( 0 ); 994 //emit incidenceSelected( 0 );
986 updateView(); 995 updateView();
987 996
988} 997}
989 998
990void KOListView::addEvents(QPtrList<Event> eventList) 999void KOListView::addEvents(Q3PtrList<Event> eventList)
991{ 1000{
992 1001
993 Event *ev; 1002 Event *ev;
994 for(ev = eventList.first(); ev; ev = eventList.next()) { 1003 for(ev = eventList.first(); ev; ev = eventList.next()) {
995 addIncidence(ev); 1004 addIncidence(ev);
996 } 1005 }
997 if ( !mListView->currentItem() ){ 1006 if ( !mListView->currentItem() ){
998 updateView(); 1007 updateView();
999 } 1008 }
1000} 1009}
1001 1010
1002void KOListView::addTodos(QPtrList<Todo> eventList) 1011void KOListView::addTodos(Q3PtrList<Todo> eventList)
1003{ 1012{
1004 Todo *ev; 1013 Todo *ev;
1005 for(ev = eventList.first(); ev; ev = eventList.next()) { 1014 for(ev = eventList.first(); ev; ev = eventList.next()) {
1006 addIncidence(ev); 1015 addIncidence(ev);
1007 } 1016 }
1008 if ( !mListView->currentItem() ){ 1017 if ( !mListView->currentItem() ){
1009 updateView(); 1018 updateView();
1010 } 1019 }
1011} 1020}
1012void KOListView::addJournals(QPtrList<Journal> eventList) 1021void KOListView::addJournals(Q3PtrList<Journal> eventList)
1013{ 1022{
1014 Journal *ev; 1023 Journal *ev;
1015 for(ev = eventList.first(); ev; ev = eventList.next()) { 1024 for(ev = eventList.first(); ev; ev = eventList.next()) {
1016 addIncidence(ev); 1025 addIncidence(ev);
1017 } 1026 }
1018 if ( !mListView->currentItem() ){ 1027 if ( !mListView->currentItem() ){
1019 updateView(); 1028 updateView();
1020 } 1029 }
1021} 1030}
1022 1031
1023void KOListView::showCompletedTodos() 1032void KOListView::showCompletedTodos()
1024{ 1033{
@@ -1035,25 +1044,25 @@ void KOListView::addIncidence(Incidence *incidence)
1035 return; 1044 return;
1036 } 1045 }
1037 } 1046 }
1038 mUidDict.insert( incidence->uid(), incidence ); 1047 mUidDict.insert( incidence->uid(), incidence );
1039 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 1048 KOListViewItem *item = new KOListViewItem( incidence, mListView );
1040 ListItemVisitor v(item, mStartDate ); 1049 ListItemVisitor v(item, mStartDate );
1041 if (incidence->accept(v)) { 1050 if (incidence->accept(v)) {
1042 return; 1051 return;
1043 } 1052 }
1044 else delete item; 1053 else delete item;
1045} 1054}
1046 1055
1047void KOListView::showEvents(QPtrList<Event> eventList) 1056void KOListView::showEvents(Q3PtrList<Event> eventList)
1048{ 1057{
1049 clear(); 1058 clear();
1050 1059
1051 addEvents(eventList); 1060 addEvents(eventList);
1052 1061
1053 // After new creation of list view no events are selected. 1062 // After new creation of list view no events are selected.
1054 emit incidenceSelected( 0 ); 1063 emit incidenceSelected( 0 );
1055} 1064}
1056int KOListView::count() 1065int KOListView::count()
1057{ 1066{
1058 return mListView->childCount(); 1067 return mListView->childCount();
1059} 1068}
@@ -1086,32 +1095,32 @@ void KOListView::changeEventDisplay(Event *event, int action)
1086} 1095}
1087 1096
1088KOListViewItem *KOListView::getItemForEvent(Incidence *event) 1097KOListViewItem *KOListView::getItemForEvent(Incidence *event)
1089{ 1098{
1090 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 1099 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
1091 while (item) { 1100 while (item) {
1092 if (item->data() == event) return item; 1101 if (item->data() == event) return item;
1093 item = (KOListViewItem *)item->nextSibling(); 1102 item = (KOListViewItem *)item->nextSibling();
1094 } 1103 }
1095 return 0; 1104 return 0;
1096} 1105}
1097 1106
1098void KOListView::defaultItemAction(QListViewItem *i) 1107void KOListView::defaultItemAction(Q3ListViewItem *i)
1099{ 1108{
1100 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 1109 KOListViewItem *item = static_cast<KOListViewItem *>( i );
1101 if ( item ) defaultAction( item->data() ); 1110 if ( item ) defaultAction( item->data() );
1102 1111
1103} 1112}
1104 1113
1105void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 1114void KOListView::popupMenu(Q3ListViewItem *item,const QPoint &,int)
1106{ 1115{
1107 mActiveItem = (KOListViewItem *)item; 1116 mActiveItem = (KOListViewItem *)item;
1108 if (mActiveItem) { 1117 if (mActiveItem) {
1109 Incidence *incidence = mActiveItem->data(); 1118 Incidence *incidence = mActiveItem->data();
1110 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); 1119 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) );
1111 mPopupMenu->showIncidencePopup(incidence); 1120 mPopupMenu->showIncidencePopup(incidence);
1112 1121
1113 /* 1122 /*
1114 if ( incidence && incidence->type() == "Event" ) { 1123 if ( incidence && incidence->type() == "Event" ) {
1115 Event *event = static_cast<Event *>( incidence ); 1124 Event *event = static_cast<Event *>( incidence );
1116 mPopupMenu->showEventPopup(event); 1125 mPopupMenu->showEventPopup(event);
1117 } 1126 }
@@ -1122,25 +1131,25 @@ void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
1122void KOListView::readSettings(KConfig *config, QString setting) 1131void KOListView::readSettings(KConfig *config, QString setting)
1123{ 1132{
1124 // qDebug("KOListView::readSettings "); 1133 // qDebug("KOListView::readSettings ");
1125 mListView->restoreLayout(config,setting); 1134 mListView->restoreLayout(config,setting);
1126} 1135}
1127 1136
1128void KOListView::writeSettings(KConfig *config, QString setting) 1137void KOListView::writeSettings(KConfig *config, QString setting)
1129{ 1138{
1130 // qDebug("KOListView::writeSettings "); 1139 // qDebug("KOListView::writeSettings ");
1131 mListView->saveLayout(config, setting); 1140 mListView->saveLayout(config, setting);
1132} 1141}
1133 1142
1134void KOListView::processSelectionChange(QListViewItem *) 1143void KOListView::processSelectionChange(Q3ListViewItem *)
1135{ 1144{
1136 1145
1137 KOListViewItem *item = 1146 KOListViewItem *item =
1138 static_cast<KOListViewItem *>( mListView->currentItem() ); 1147 static_cast<KOListViewItem *>( mListView->currentItem() );
1139 1148
1140 if ( !item ) { 1149 if ( !item ) {
1141 emit incidenceSelected( 0 ); 1150 emit incidenceSelected( 0 );
1142 } else { 1151 } else {
1143 emit incidenceSelected( item->data() ); 1152 emit incidenceSelected( item->data() );
1144 } 1153 }
1145} 1154}
1146 1155
@@ -1171,115 +1180,115 @@ void KOListView::keyPressEvent ( QKeyEvent *e)
1171 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1180 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1172 deleteAll(); 1181 deleteAll();
1173 return; 1182 return;
1174 } 1183 }
1175 1184
1176 e->ignore(); 1185 e->ignore();
1177} 1186}
1178void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1187void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1179{ 1188{
1180 1189
1181 switch ( e->key() ) { 1190 switch ( e->key() ) {
1182 case Qt::Key_Down: 1191 case Qt::Key_Down:
1183 if ( e->state() == ShiftButton ) { 1192 if ( e->state() == Qt::ShiftButton ) {
1184 QListViewItem* cn = currentItem(); 1193 Q3ListViewItem* cn = currentItem();
1185 if ( !cn ) 1194 if ( !cn )
1186 cn = firstChild(); 1195 cn = firstChild();
1187 if ( !cn ) 1196 if ( !cn )
1188 return; 1197 return;
1189 while ( cn->nextSibling() ) 1198 while ( cn->nextSibling() )
1190 cn = cn->nextSibling(); 1199 cn = cn->nextSibling();
1191 setCurrentItem ( cn ); 1200 setCurrentItem ( cn );
1192 ensureItemVisible ( cn ); 1201 ensureItemVisible ( cn );
1193 1202
1194 e->accept(); 1203 e->accept();
1195 return; 1204 return;
1196 } 1205 }
1197 if ( e->state() == ControlButton ) { 1206 if ( e->state() == Qt::ControlButton ) {
1198 int count = childCount (); 1207 int count = childCount ();
1199 int jump = count / 5; 1208 int jump = count / 5;
1200 QListViewItem* cn; 1209 Q3ListViewItem* cn;
1201 cn = currentItem(); 1210 cn = currentItem();
1202 if ( ! cn ) 1211 if ( ! cn )
1203 return; 1212 return;
1204 if ( jump == 0 ) 1213 if ( jump == 0 )
1205 jump = 1; 1214 jump = 1;
1206 while ( jump && cn->nextSibling() ) { 1215 while ( jump && cn->nextSibling() ) {
1207 cn = cn->nextSibling(); 1216 cn = cn->nextSibling();
1208 --jump; 1217 --jump;
1209 } 1218 }
1210 setCurrentItem ( cn ); 1219 setCurrentItem ( cn );
1211 ensureItemVisible ( cn ); 1220 ensureItemVisible ( cn );
1212 1221
1213 } else 1222 } else
1214 QListView::keyPressEvent ( e ) ; 1223 Q3ListView::keyPressEvent ( e ) ;
1215 e->accept(); 1224 e->accept();
1216 break; 1225 break;
1217 1226
1218 case Qt::Key_Up: 1227 case Qt::Key_Up:
1219 if ( e->state() == ShiftButton ) { 1228 if ( e->state() == Qt::ShiftButton ) {
1220 QListViewItem* cn = firstChild(); 1229 Q3ListViewItem* cn = firstChild();
1221 if ( cn ) { 1230 if ( cn ) {
1222 setCurrentItem ( cn ); 1231 setCurrentItem ( cn );
1223 ensureItemVisible ( cn ); 1232 ensureItemVisible ( cn );
1224 } 1233 }
1225 e->accept(); 1234 e->accept();
1226 return; 1235 return;
1227 } 1236 }
1228 if ( e->state() == ControlButton ) { 1237 if ( e->state() == Qt::ControlButton ) {
1229 int count = childCount (); 1238 int count = childCount ();
1230 int jump = count / 5; 1239 int jump = count / 5;
1231 QListViewItem* cn; 1240 Q3ListViewItem* cn;
1232 cn = currentItem(); 1241 cn = currentItem();
1233 if ( ! cn ) 1242 if ( ! cn )
1234 return; 1243 return;
1235 if ( jump == 0 ) 1244 if ( jump == 0 )
1236 jump = 1; 1245 jump = 1;
1237 while ( jump && cn->itemAbove ()) { 1246 while ( jump && cn->itemAbove ()) {
1238 cn = cn->itemAbove (); 1247 cn = cn->itemAbove ();
1239 --jump; 1248 --jump;
1240 } 1249 }
1241 setCurrentItem ( cn ); 1250 setCurrentItem ( cn );
1242 ensureItemVisible ( cn ); 1251 ensureItemVisible ( cn );
1243 } else 1252 } else
1244 QListView::keyPressEvent ( e ) ; 1253 Q3ListView::keyPressEvent ( e ) ;
1245 e->accept(); 1254 e->accept();
1246 break; 1255 break;
1247 case Qt::Key_I: { 1256 case Qt::Key_I: {
1248 QListViewItem* cn; 1257 Q3ListViewItem* cn;
1249 cn = currentItem(); 1258 cn = currentItem();
1250 if ( cn ) { 1259 if ( cn ) {
1251 KOListViewItem* ci = (KOListViewItem*)( cn ); 1260 KOListViewItem* ci = (KOListViewItem*)( cn );
1252 if ( ci ){ 1261 if ( ci ){
1253 //emit showIncidence( ci->data()); 1262 //emit showIncidence( ci->data());
1254 cn = cn->nextSibling(); 1263 cn = cn->nextSibling();
1255 if ( cn ) { 1264 if ( cn ) {
1256 setCurrentItem ( cn ); 1265 setCurrentItem ( cn );
1257 ensureItemVisible ( cn ); 1266 ensureItemVisible ( cn );
1258 } 1267 }
1259 emit showIncidence( ci->data()); 1268 emit showIncidence( ci->data());
1260 } 1269 }
1261 } 1270 }
1262 e->accept(); 1271 e->accept();
1263 } 1272 }
1264 break; 1273 break;
1265 case Qt::Key_Return: 1274 case Qt::Key_Return:
1266 case Qt::Key_Enter: 1275 case Qt::Key_Enter:
1267 { 1276 {
1268 QListViewItem* cn; 1277 Q3ListViewItem* cn;
1269 cn = currentItem(); 1278 cn = currentItem();
1270 if ( cn ) { 1279 if ( cn ) {
1271 KOListViewItem* ci = (KOListViewItem*)( cn ); 1280 KOListViewItem* ci = (KOListViewItem*)( cn );
1272 if ( ci ){ 1281 if ( ci ){
1273 if ( e->state() == ShiftButton ) 1282 if ( e->state() == Qt::ShiftButton )
1274 ci->setSelected( false ); 1283 ci->setSelected( false );
1275 else 1284 else
1276 ci->setSelected( true ); 1285 ci->setSelected( true );
1277 cn = cn->nextSibling(); 1286 cn = cn->nextSibling();
1278 if ( cn ) { 1287 if ( cn ) {
1279 setCurrentItem ( cn ); 1288 setCurrentItem ( cn );
1280 ensureItemVisible ( cn ); 1289 ensureItemVisible ( cn );
1281 } else { 1290 } else {
1282 emit currentChanged( ci ); 1291 emit currentChanged( ci );
1283 } 1292 }
1284 } 1293 }
1285 } 1294 }
@@ -1291,88 +1300,88 @@ void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1291 } 1300 }
1292} 1301}
1293KOListViewListView::KOListViewListView(KOListView * lv ) 1302KOListViewListView::KOListViewListView(KOListView * lv )
1294 : KListView( lv, "kolistlistview", false ) 1303 : KListView( lv, "kolistlistview", false )
1295{ 1304{
1296 mYMousePos = 0; 1305 mYMousePos = 0;
1297 setAllColumnsShowFocus( true ); 1306 setAllColumnsShowFocus( true );
1298 mPopupTimer = new QTimer(this); 1307 mPopupTimer = new QTimer(this);
1299 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1308 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1300#ifndef DESKTOP_VERSION 1309#ifndef DESKTOP_VERSION
1301 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1310 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1302#endif 1311#endif
1303 setSelectionMode( QListView::Multi ); 1312 setSelectionMode( Q3ListView::Multi );
1304 setMultiSelection( true); 1313 setMultiSelection( true);
1305} 1314}
1306bool KOListViewListView::hasMultiSelection(QListViewItem* item) 1315bool KOListViewListView::hasMultiSelection(Q3ListViewItem* item)
1307{ 1316{
1308 QListViewItem *qitem = firstChild (); 1317 Q3ListViewItem *qitem = firstChild ();
1309 while ( qitem ) { 1318 while ( qitem ) {
1310 if ( qitem->isSelected() && item != qitem ) 1319 if ( qitem->isSelected() && item != qitem )
1311 return true; 1320 return true;
1312 qitem = qitem->nextSibling(); 1321 qitem = qitem->nextSibling();
1313 } 1322 }
1314 return false; 1323 return false;
1315} 1324}
1316void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1325void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1317{ 1326{
1318 if (!e) return; 1327 if (!e) return;
1319 QPoint vp = contentsToViewport(e->pos()); 1328 QPoint vp = contentsToViewport(e->pos());
1320 QListViewItem *item = itemAt(vp); 1329 Q3ListViewItem *item = itemAt(vp);
1321 if (!item) { 1330 if (!item) {
1322 emit newEvent(); 1331 emit newEvent();
1323 return; 1332 return;
1324 } 1333 }
1325 KListView::contentsMouseDoubleClickEvent(e); 1334 KListView::contentsMouseDoubleClickEvent(e);
1326} 1335}
1327#if 0 1336#if 0
1328void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1337void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1329{ 1338{
1330 //qDebug("contentsMousePressEvent++++ "); 1339 //qDebug("contentsMousePressEvent++++ ");
1331 KListView::contentsMousePressEvent( e ); 1340 KListView::contentsMousePressEvent( e );
1332 if ( e->button() == RightButton ) { 1341 if ( e->button() == Qt::RightButton ) {
1333 QListViewItem* ci = currentItem(); 1342 Q3ListViewItem* ci = currentItem();
1334 clearSelection () ; 1343 clearSelection () ;
1335 if ( ci ) 1344 if ( ci )
1336 ci->setSelected( true ); 1345 ci->setSelected( true );
1337 } 1346 }
1338} 1347}
1339void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1348void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1340{ 1349{
1341 KListView::contentsMouseReleaseEvent(e); 1350 KListView::contentsMouseReleaseEvent(e);
1342} 1351}
1343void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1352void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1344{ 1353{
1345 KListView::contentsMouseMoveEvent(e); 1354 KListView::contentsMouseMoveEvent(e);
1346} 1355}
1347#endif 1356#endif
1348void KOListViewListView::popupMenu() 1357void KOListViewListView::popupMenu()
1349{ 1358{
1350 mPopupTimer->stop(); 1359 mPopupTimer->stop();
1351 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1360 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, Qt::RightButton , Qt::RightButton );
1352 QApplication::postEvent( this->viewport(), e ); 1361 QApplication::postEvent( this->viewport(), e );
1353 1362
1354} 1363}
1355void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1364void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1356{ 1365{
1357 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); 1366 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y());
1358 mYMousePos = mapToGlobal( (e->pos())).y(); 1367 mYMousePos = mapToGlobal( (e->pos())).y();
1359 if ( e->button() == LeftButton ) { 1368 if ( e->button() == Qt::LeftButton ) {
1360 mPopupTimer->start( 600 ); 1369 mPopupTimer->start( 600 );
1361 mEventPos = contentsToViewport(e->pos()); 1370 mEventPos = contentsToViewport(e->pos());
1362 mEventGlobalPos = e->globalPos(); 1371 mEventGlobalPos = e->globalPos();
1363 } 1372 }
1364 KListView::contentsMousePressEvent( e ); 1373 KListView::contentsMousePressEvent( e );
1365 if ( e->button() == RightButton ) { 1374 if ( e->button() == Qt::RightButton ) {
1366 QListViewItem* ci = currentItem(); 1375 Q3ListViewItem* ci = currentItem();
1367 //clearSelection(); 1376 //clearSelection();
1368 if ( ci ) 1377 if ( ci )
1369 ci->setSelected( true ); 1378 ci->setSelected( true );
1370 } 1379 }
1371} 1380}
1372void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1381void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1373{ 1382{
1374 mPopupTimer->stop(); 1383 mPopupTimer->stop();
1375 KListView::contentsMouseReleaseEvent(e); 1384 KListView::contentsMouseReleaseEvent(e);
1376} 1385}
1377void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1386void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1378{ 1387{
@@ -1381,42 +1390,42 @@ void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1381 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1390 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1382 if ( diff < 0 ) diff = -diff; 1391 if ( diff < 0 ) diff = -diff;
1383 if ( diff > 15 ) 1392 if ( diff > 15 )
1384 mPopupTimer->stop(); 1393 mPopupTimer->stop();
1385 else { 1394 else {
1386 mEventPos = contentsToViewport(e->pos()); 1395 mEventPos = contentsToViewport(e->pos());
1387 mEventGlobalPos = e->globalPos(); 1396 mEventGlobalPos = e->globalPos();
1388 } 1397 }
1389 KListView::contentsMouseMoveEvent(e); 1398 KListView::contentsMouseMoveEvent(e);
1390} 1399}
1391 1400
1392#define protected public 1401#define protected public
1393#include <qheader.h> 1402#include <q3header.h>
1394#undef protected 1403#undef protected
1395void KOListViewListView::printList() 1404void KOListViewListView::printList()
1396{ 1405{
1397#ifdef DESKTOP_VERSION 1406#ifdef DESKTOP_VERSION
1398 KOPrintPrefs pp ( this ); 1407 KOPrintPrefs pp ( this );
1399 if (!pp.exec() ) 1408 if (!pp.exec() )
1400 return; 1409 return;
1401 int scaleval = pp.printMode() ; 1410 int scaleval = pp.printMode() ;
1402 1411
1403 QPrinter printer; 1412 QPrinter printer;
1404 if (!printer.setup() ) 1413 if (!printer.setup() )
1405 return; 1414 return;
1406 clearSelection (); 1415 clearSelection ();
1407 QPainter p; 1416 QPainter p;
1408 p.begin ( &printer ); 1417 p.begin ( &printer );
1409 p.setFont(font()); 1418 p.setFont(font());
1410 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 1419 Q3PaintDeviceMetrics m = Q3PaintDeviceMetrics ( &printer );
1411 float dx, dy; 1420 float dx, dy;
1412 int wid = (m.width() * 9)/10; 1421 int wid = (m.width() * 9)/10;
1413 dx = (float) wid/(float)contentsWidth (); 1422 dx = (float) wid/(float)contentsWidth ();
1414 dy = (float)(m.height()) / (float)contentsHeight (); 1423 dy = (float)(m.height()) / (float)contentsHeight ();
1415 float scale; 1424 float scale;
1416 // scale to fit the width or height of the paper 1425 // scale to fit the width or height of the paper
1417 if ( dx < dy ) 1426 if ( dx < dy )
1418 scale = dx; 1427 scale = dx;
1419 else 1428 else
1420 scale = dy; 1429 scale = dy;
1421 1430
1422 p.translate( m.width()/10,m.width()/10 ); 1431 p.translate( m.width()/10,m.width()/10 );
@@ -1434,25 +1443,25 @@ void KOListViewListView::printList()
1434 } 1443 }
1435 p.translate( 0, header()->height()); 1444 p.translate( 0, header()->height());
1436 //drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); 1445 //drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () );
1437 1446
1438 const QColorGroup &cg = colorGroup(); 1447 const QColorGroup &cg = colorGroup();
1439 KOListViewItem* item = (KOListViewItem* )firstChild(); 1448 KOListViewItem* item = (KOListViewItem* )firstChild();
1440 int yOff = 0; 1449 int yOff = 0;
1441 while ( item ) { 1450 while ( item ) {
1442 p.translate( 0, yOff ); 1451 p.translate( 0, yOff );
1443 p.save(); 1452 p.save();
1444 for ( iii = 0; iii < cou; ++iii ) { 1453 for ( iii = 0; iii < cou; ++iii ) {
1445 int align = columnAlignment( iii ); 1454 int align = columnAlignment( iii );
1446 if ( align == AlignAuto ) align = AlignLeft; 1455 if ( align == Qt::AlignLeft ) align = Qt::AlignLeft;
1447 p.restore(); 1456 p.restore();
1448 p.save(); 1457 p.save();
1449 p.translate( header()->sectionPos( iii ), 0); 1458 p.translate( header()->sectionPos( iii ), 0);
1450 item->paintCell( &p, cg, iii, header()->sectionSize (iii), align ); 1459 item->paintCell( &p, cg, iii, header()->sectionSize (iii), align );
1451 } 1460 }
1452 yOff = item->height(); 1461 yOff = item->height();
1453 item = (KOListViewItem* )(item->itemBelow()); 1462 item = (KOListViewItem* )(item->itemBelow());
1454 p.restore(); 1463 p.restore();
1455 } 1464 }
1456 p.end(); 1465 p.end();
1457#endif 1466#endif
1458} 1467}