author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /korganizer/kolistview.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | korganizer/kolistview.cpp | 193 |
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 | |||
@@ -9,46 +9,55 @@ | |||
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
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> |
51 | #include <libkcal/filestorage.h> | 60 | #include <libkcal/filestorage.h> |
52 | #include <libkdepim/categoryselectdialog.h> | 61 | #include <libkdepim/categoryselectdialog.h> |
53 | #include <libkcal/kincidenceformatter.h> | 62 | #include <libkcal/kincidenceformatter.h> |
54 | #ifndef DESKTOP_VERSION | 63 | #ifndef DESKTOP_VERSION |
@@ -57,36 +66,36 @@ | |||
57 | #include <qapplication.h> | 66 | #include <qapplication.h> |
58 | #endif | 67 | #endif |
59 | 68 | ||
60 | #ifndef KORG_NOPRINTER | 69 | #ifndef KORG_NOPRINTER |
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 | ||
70 | extern QPixmap* sgListViewCompletedPix[6]; | 79 | extern QPixmap* sgListViewCompletedPix[6]; |
71 | extern QPixmap* sgListViewJournalPix; | 80 | extern QPixmap* sgListViewJournalPix; |
72 | 81 | ||
73 | class KOListViewWhatsThis :public QWhatsThis | 82 | class KOListViewWhatsThis :public Q3WhatsThis |
74 | { | 83 | { |
75 | public: | 84 | public: |
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 | ||
78 | protected: | 87 | protected: |
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 | } |
83 | private: | 92 | private: |
84 | QWidget* _wid; | 93 | QWidget* _wid; |
85 | KOListView * _view; | 94 | KOListView * _view; |
86 | }; | 95 | }; |
87 | 96 | ||
88 | 97 | ||
89 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 98 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
90 | { | 99 | { |
91 | mItem = item; | 100 | mItem = item; |
92 | mDate = date; | 101 | mDate = date; |
@@ -261,140 +270,140 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent, | |||
261 | mActiveItem = 0; | 270 | mActiveItem = 0; |
262 | mForceShowCompletedTodos = false; | 271 | mForceShowCompletedTodos = false; |
263 | mListView = new KOListViewListView(this); | 272 | mListView = new KOListViewListView(this); |
264 | mListView->addColumn(i18n("Summary")); | 273 | mListView->addColumn(i18n("Summary")); |
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, |
346 | SLOT(saveToFileVCS())); | 355 | SLOT(saveToFileVCS())); |
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 | ||
391 | KOListView::~KOListView() | 400 | KOListView::~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 |
397 | delete mKOListViewWhatsThis; | 406 | delete mKOListViewWhatsThis; |
398 | #endif | 407 | #endif |
399 | } | 408 | } |
400 | 409 | ||
@@ -415,47 +424,47 @@ QString KOListView::getWhatsThisText(QPoint p) | |||
415 | KOPrefs::instance()->mWTshowCreated, | 424 | KOPrefs::instance()->mWTshowCreated, |
416 | KOPrefs::instance()->mWTshowChanged); | 425 | KOPrefs::instance()->mWTshowChanged); |
417 | return i18n("That is the list view" ); | 426 | return i18n("That is the list view" ); |
418 | 427 | ||
419 | } | 428 | } |
420 | 429 | ||
421 | void KOListView::setCalendar( int c ) | 430 | void 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 | ||
458 | } | 467 | } |
459 | void KOListView::populateCalPopup() | 468 | void KOListView::populateCalPopup() |
460 | { | 469 | { |
461 | mCalPopup->clear(); | 470 | mCalPopup->clear(); |
@@ -484,123 +493,123 @@ void KOListView::setCat() | |||
484 | bool set = true; | 493 | bool set = true; |
485 | int result = KMessageBox::warningYesNoCancel(this, | 494 | int result = KMessageBox::warningYesNoCancel(this, |
486 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), | 495 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), |
487 | i18n("Set categories"), | 496 | i18n("Set categories"), |
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 | ||
495 | void KOListView::setAlarm() | 504 | void 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(); |
538 | } | 547 | } |
539 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); | 548 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); |
540 | qDebug("KO: Set alarm for %d items", count); | 549 | qDebug("KO: Set alarm for %d items", count); |
541 | calendar()->reInitAlarmSettings(); | 550 | calendar()->reInitAlarmSettings(); |
542 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 551 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
543 | } | 552 | } |
544 | void KOListView::setCategories( bool removeOld ) | 553 | void 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 | ||
573 | void KOListView::beamSelected() | 582 | void 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 | ||
580 | void KOListView::saveDescriptionToFile() | 589 | void 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() ) { |
603 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 612 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
604 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 613 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
605 | i18n("Overwrite!"), i18n("Cancel"), 0, | 614 | i18n("Overwrite!"), i18n("Cancel"), 0, |
606 | 0, 1 ); | 615 | 0, 1 ); |
@@ -632,60 +641,60 @@ void KOListView::saveDescriptionToFile() | |||
632 | if ( incidence->typeID() == todoID ) | 641 | if ( incidence->typeID() == todoID ) |
633 | text += i18n("To-Do: "); | 642 | text += i18n("To-Do: "); |
634 | text += incidence->summary(); | 643 | text += incidence->summary(); |
635 | if ( !incidence->location().isEmpty() ) | 644 | if ( !incidence->location().isEmpty() ) |
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 | } |
662 | void KOListView::saveToFileVCS() | 671 | void KOListView::saveToFileVCS() |
663 | { | 672 | { |
664 | writeToFile( false ); | 673 | writeToFile( false ); |
665 | } | 674 | } |
666 | void KOListView::saveToFile() | 675 | void KOListView::saveToFile() |
667 | { | 676 | { |
668 | writeToFile( true ); | 677 | writeToFile( true ); |
669 | } | 678 | } |
670 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) | 679 | Q3PtrList<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 ); |
688 | 697 | ||
689 | } | 698 | } |
690 | } | 699 | } |
691 | if ( inc->typeID() == todoID ) { | 700 | if ( inc->typeID() == todoID ) { |
@@ -693,57 +702,57 @@ QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool | |||
693 | if ( todo->relations().count() ) { | 702 | if ( todo->relations().count() ) { |
694 | if ( askSubTodos ) { | 703 | if ( askSubTodos ) { |
695 | int result = KMessageBox::warningYesNoCancel(this, | 704 | int result = KMessageBox::warningYesNoCancel(this, |
696 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), | 705 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), |
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 | ||
731 | void KOListView::writeToFile( bool iCal ) | 740 | void 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, |
746 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 755 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
747 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 756 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
748 | true); | 757 | true); |
749 | if (result != KMessageBox::Continue) return; | 758 | if (result != KMessageBox::Continue) return; |
@@ -790,72 +799,72 @@ void KOListView::writeToFile( bool iCal ) | |||
790 | ICalFormat format; | 799 | ICalFormat format; |
791 | format.save( &cal, fn ); | 800 | format.save( &cal, fn ); |
792 | } else { | 801 | } else { |
793 | 802 | ||
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 | } |
804 | void KOListView::hideAll() | 813 | void 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 | } |
821 | void KOListView::printList() | 830 | void KOListView::printList() |
822 | { | 831 | { |
823 | mListView->printList(); | 832 | mListView->printList(); |
824 | } | 833 | } |
825 | void KOListView::deleteAll() | 834 | void 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 ); |
858 | dia.setCaption( mess ); | 867 | dia.setCaption( mess ); |
859 | qApp->processEvents(); | 868 | qApp->processEvents(); |
860 | toDelete = (incidence); | 869 | toDelete = (incidence); |
861 | incidence = delSel.next(); | 870 | incidence = delSel.next(); |
@@ -871,36 +880,36 @@ void KOListView::deleteAll() | |||
871 | p->mConfirm = confirm; | 880 | p->mConfirm = confirm; |
872 | } | 881 | } |
873 | } | 882 | } |
874 | 883 | ||
875 | 884 | ||
876 | } | 885 | } |
877 | int KOListView::maxDatesHint() | 886 | int KOListView::maxDatesHint() |
878 | { | 887 | { |
879 | return 0; | 888 | return 0; |
880 | } | 889 | } |
881 | 890 | ||
882 | int KOListView::currentDateCount() | 891 | int KOListView::currentDateCount() |
883 | { | 892 | { |
884 | return 0; | 893 | return 0; |
885 | } | 894 | } |
886 | 895 | ||
887 | QPtrList<Incidence> KOListView::selectedIncidences() | 896 | Q3PtrList<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; |
903 | } | 912 | } |
904 | 913 | ||
905 | DateList KOListView::selectedDates() | 914 | DateList KOListView::selectedDates() |
906 | { | 915 | { |
@@ -974,55 +983,55 @@ void KOListView::setStartDate(const QDate &start) | |||
974 | void KOListView::showDates(const QDate &start, const QDate &end) | 983 | void KOListView::showDates(const QDate &start, const QDate &end) |
975 | { | 984 | { |
976 | clear(); | 985 | clear(); |
977 | mStartDate = start; | 986 | mStartDate = start; |
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 | ||
990 | void KOListView::addEvents(QPtrList<Event> eventList) | 999 | void 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 | ||
1002 | void KOListView::addTodos(QPtrList<Todo> eventList) | 1011 | void 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 | } |
1012 | void KOListView::addJournals(QPtrList<Journal> eventList) | 1021 | void 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 | ||
1023 | void KOListView::showCompletedTodos() | 1032 | void KOListView::showCompletedTodos() |
1024 | { | 1033 | { |
1025 | mForceShowCompletedTodos = true; | 1034 | mForceShowCompletedTodos = true; |
1026 | } | 1035 | } |
1027 | void KOListView::addIncidence(Incidence *incidence) | 1036 | void KOListView::addIncidence(Incidence *incidence) |
1028 | { | 1037 | { |
@@ -1031,33 +1040,33 @@ void KOListView::addIncidence(Incidence *incidence) | |||
1031 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 1040 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
1032 | if ( incidence->typeID() == todoID ) { | 1041 | if ( incidence->typeID() == todoID ) { |
1033 | if ( ! mForceShowCompletedTodos ) { | 1042 | if ( ! mForceShowCompletedTodos ) { |
1034 | if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) | 1043 | if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) |
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 | ||
1047 | void KOListView::showEvents(QPtrList<Event> eventList) | 1056 | void 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 | } |
1056 | int KOListView::count() | 1065 | int KOListView::count() |
1057 | { | 1066 | { |
1058 | return mListView->childCount(); | 1067 | return mListView->childCount(); |
1059 | } | 1068 | } |
1060 | 1069 | ||
1061 | void KOListView::changeEventDisplay(Event *event, int action) | 1070 | void KOListView::changeEventDisplay(Event *event, int action) |
1062 | { | 1071 | { |
1063 | KOListViewItem *item; | 1072 | KOListViewItem *item; |
@@ -1082,69 +1091,69 @@ void KOListView::changeEventDisplay(Event *event, int action) | |||
1082 | break; | 1091 | break; |
1083 | default: | 1092 | default: |
1084 | ; | 1093 | ; |
1085 | } | 1094 | } |
1086 | } | 1095 | } |
1087 | 1096 | ||
1088 | KOListViewItem *KOListView::getItemForEvent(Incidence *event) | 1097 | KOListViewItem *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 | ||
1098 | void KOListView::defaultItemAction(QListViewItem *i) | 1107 | void 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 | ||
1105 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 1114 | void 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 | } |
1118 | */ | 1127 | */ |
1119 | } | 1128 | } |
1120 | } | 1129 | } |
1121 | 1130 | ||
1122 | void KOListView::readSettings(KConfig *config, QString setting) | 1131 | void 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 | ||
1128 | void KOListView::writeSettings(KConfig *config, QString setting) | 1137 | void 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 | ||
1134 | void KOListView::processSelectionChange(QListViewItem *) | 1143 | void 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 | ||
1147 | void KOListView::clearSelection() | 1156 | void KOListView::clearSelection() |
1148 | { | 1157 | { |
1149 | mListView->selectAll( false ); | 1158 | mListView->selectAll( false ); |
1150 | } | 1159 | } |
@@ -1167,260 +1176,260 @@ Incidence* KOListView::currentItem() | |||
1167 | } | 1176 | } |
1168 | void KOListView::keyPressEvent ( QKeyEvent *e) | 1177 | void KOListView::keyPressEvent ( QKeyEvent *e) |
1169 | { | 1178 | { |
1170 | 1179 | ||
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 | } |
1178 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) | 1187 | void 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 | } |
1286 | e->accept(); | 1295 | e->accept(); |
1287 | } | 1296 | } |
1288 | break; | 1297 | break; |
1289 | default: | 1298 | default: |
1290 | e->ignore(); | 1299 | e->ignore(); |
1291 | } | 1300 | } |
1292 | } | 1301 | } |
1293 | KOListViewListView::KOListViewListView(KOListView * lv ) | 1302 | KOListViewListView::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 | } |
1306 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) | 1315 | bool 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 | } |
1316 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1325 | void 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 |
1328 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1337 | void 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 | } |
1339 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1348 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1340 | { | 1349 | { |
1341 | KListView::contentsMouseReleaseEvent(e); | 1350 | KListView::contentsMouseReleaseEvent(e); |
1342 | } | 1351 | } |
1343 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1352 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1344 | { | 1353 | { |
1345 | KListView::contentsMouseMoveEvent(e); | 1354 | KListView::contentsMouseMoveEvent(e); |
1346 | } | 1355 | } |
1347 | #endif | 1356 | #endif |
1348 | void KOListViewListView::popupMenu() | 1357 | void 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 | } |
1355 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1364 | void 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 | } |
1372 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1381 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1373 | { | 1382 | { |
1374 | mPopupTimer->stop(); | 1383 | mPopupTimer->stop(); |
1375 | KListView::contentsMouseReleaseEvent(e); | 1384 | KListView::contentsMouseReleaseEvent(e); |
1376 | } | 1385 | } |
1377 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1386 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1378 | { | 1387 | { |
1379 | // qDebug("contentsMouseMoveEv....... "); | 1388 | // qDebug("contentsMouseMoveEv....... "); |
1380 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); | 1389 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); |
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 |
1395 | void KOListViewListView::printList() | 1404 | void 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 ); |
1423 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 1432 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
1424 | p.scale( scale, scale ); | 1433 | p.scale( scale, scale ); |
1425 | } | 1434 | } |
1426 | 1435 | ||
@@ -1430,29 +1439,29 @@ void KOListViewListView::printList() | |||
1430 | for ( iii = 0; iii < cou; ++iii ) { | 1439 | for ( iii = 0; iii < cou; ++iii ) { |
1431 | rect.setLeft ( header()->sectionPos( iii ) ); | 1440 | rect.setLeft ( header()->sectionPos( iii ) ); |
1432 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); | 1441 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); |
1433 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); | 1442 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); |
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 | } |