summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventpopupmenu.cpp27
-rw-r--r--korganizer/koeventpopupmenu.h3
-rw-r--r--korganizer/kolistview.cpp12
-rw-r--r--korganizer/kolistview.h1
4 files changed, 38 insertions, 5 deletions
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp
index b274810..17ef81e 100644
--- a/korganizer/koeventpopupmenu.cpp
+++ b/korganizer/koeventpopupmenu.cpp
@@ -1,113 +1,130 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcursor.h> 24#include <qcursor.h>
25 25
26#include <klocale.h> 26#include <klocale.h>
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kiconloader.h> 28#include <kiconloader.h>
29 29
30#include <libkcal/event.h> 30#include <libkcal/event.h>
31 31
32#include "koeventpopupmenu.h" 32#include "koeventpopupmenu.h"
33 33
34KOEventPopupMenu::KOEventPopupMenu() 34KOEventPopupMenu::KOEventPopupMenu()
35{ 35{
36 mCurrentIncidence = 0; 36 mCurrentIncidence = 0;
37 mHasAdditionalItems = false; 37 mHasAdditionalItems = false;
38 38
39 insertItem (i18n("&Show"),this,SLOT(popupShow())); 39
40 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow())));
40 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit()))); 41 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
41 mEditOnlyItems.append(insertItem (i18n("&Delete"), 42 mEditOnlyItems.append(insertItem (i18n("&Delete"),
42 this,SLOT(popupDelete()))); 43 this,SLOT(popupDelete())));
43 mEditOnlyItems.append(insertItem (i18n("&Clone..."), 44 mEditOnlyItems.append(insertItem (i18n("&Clone..."),
44 this,SLOT(popupClone()))); 45 this,SLOT(popupClone())));
45 mEditOnlyItems.append(insertItem (i18n("&Move..."), 46 mEditOnlyItems.append(insertItem (i18n("&Move..."),
46 this,SLOT(popupMove()))); 47 this,SLOT(popupMove())));
47#ifndef DESKTOP_VERSION 48#ifndef DESKTOP_VERSION
48 mEditOnlyItems.append(insertItem (i18n("&Beam..."), 49 mEditOnlyItems.append(insertItem (i18n("&Beam..."),
49 this,SLOT(popupBeam()))); 50 this,SLOT(popupBeam())));
50#endif 51#endif
51 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), 52 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"),
52 this,SLOT(popupCancel()))); 53 this,SLOT(popupCancel())));
54 isDisabled = false;
55 QValueList<int>::Iterator it;
56 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
57 mSingleOnlyItems.append(*it);
58 }
59}
60void KOEventPopupMenu::enableDefault( bool enable )
61{
62 isDisabled = !enable;
63 QValueList<int>::Iterator it;
64 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) {
65 setItemEnabled(*it,enable);
66 }
67
53} 68}
54 69
55void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) 70void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
56{ 71{
57 mCurrentIncidence = incidence; 72 mCurrentIncidence = incidence;
58 73
59 if (mCurrentIncidence) { 74 if (mCurrentIncidence) {
60 // Enable/Disabled menu items only valid for editable events. 75 // Enable/Disabled menu items only valid for editable events.
61 QValueList<int>::Iterator it; 76 if ( !isDisabled ) {
62 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 77 QValueList<int>::Iterator it;
63 setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); 78 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
64 } 79 setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
80 }
81 }
65 popup(QCursor::pos()); 82 popup(QCursor::pos());
66 } else { 83 } else {
67 kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl; 84 kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
68 } 85 }
69} 86}
70 87
71void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, 88void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
72 const QObject *receiver, const char *member, 89 const QObject *receiver, const char *member,
73 bool editOnly) 90 bool editOnly)
74{ 91{
75 if (!mHasAdditionalItems) { 92 if (!mHasAdditionalItems) {
76 mHasAdditionalItems = true; 93 mHasAdditionalItems = true;
77 insertSeparator(); 94 insertSeparator();
78 } 95 }
79 int id = insertItem(icon,text,receiver,member); 96 int id = insertItem(icon,text,receiver,member);
80 if (editOnly) mEditOnlyItems.append(id); 97 if (editOnly) mEditOnlyItems.append(id);
81} 98}
82 99
83void KOEventPopupMenu::popupShow() 100void KOEventPopupMenu::popupShow()
84{ 101{
85 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence); 102 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
86} 103}
87 104
88void KOEventPopupMenu::popupEdit() 105void KOEventPopupMenu::popupEdit()
89{ 106{
90 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence); 107 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
91} 108}
92 109
93void KOEventPopupMenu::popupDelete() 110void KOEventPopupMenu::popupDelete()
94{ 111{
95 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence); 112 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
96} 113}
97void KOEventPopupMenu::popupClone() 114void KOEventPopupMenu::popupClone()
98{ 115{
99 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence); 116 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence);
100} 117}
101void KOEventPopupMenu::popupCancel() 118void KOEventPopupMenu::popupCancel()
102{ 119{
103 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence); 120 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence);
104} 121}
105void KOEventPopupMenu::popupMove() 122void KOEventPopupMenu::popupMove()
106{ 123{
107 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence); 124 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence);
108} 125}
109 126
110void KOEventPopupMenu::popupBeam() 127void KOEventPopupMenu::popupBeam()
111{ 128{
112 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence); 129 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence);
113} 130}
diff --git a/korganizer/koeventpopupmenu.h b/korganizer/koeventpopupmenu.h
index 6993899..8fb51fa 100644
--- a/korganizer/koeventpopupmenu.h
+++ b/korganizer/koeventpopupmenu.h
@@ -1,73 +1,76 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOEVENTPOPUPMENU_H 23#ifndef KOEVENTPOPUPMENU_H
24#define KOEVENTPOPUPMENU_H 24#define KOEVENTPOPUPMENU_H
25// 25//
26// Context menu for event views with standard event actions 26// Context menu for event views with standard event actions
27// 27//
28 28
29#include <qpopupmenu.h> 29#include <qpopupmenu.h>
30 30
31#include <libkcal/incidence.h> 31#include <libkcal/incidence.h>
32 32
33using namespace KCal; 33using namespace KCal;
34 34
35class KOEventPopupMenu : public QPopupMenu { 35class KOEventPopupMenu : public QPopupMenu {
36 Q_OBJECT 36 Q_OBJECT
37 public: 37 public:
38 KOEventPopupMenu(); 38 KOEventPopupMenu();
39 39
40 void addAdditionalItem(const QIconSet &icon,const QString &text, 40 void addAdditionalItem(const QIconSet &icon,const QString &text,
41 const QObject *receiver, const char *member, 41 const QObject *receiver, const char *member,
42 bool editOnly=false); 42 bool editOnly=false);
43 43
44 44
45 public slots: 45 public slots:
46 void showIncidencePopup(Incidence *); 46 void showIncidencePopup(Incidence *);
47 void enableDefault( bool );
47 48
48 protected slots: 49 protected slots:
49 void popupShow(); 50 void popupShow();
50 void popupEdit(); 51 void popupEdit();
51 void popupDelete(); 52 void popupDelete();
52 void popupClone(); 53 void popupClone();
53 void popupCancel(); 54 void popupCancel();
54 void popupMove(); 55 void popupMove();
55 void popupBeam(); 56 void popupBeam();
56 57
57 signals: 58 signals:
58 void editIncidenceSignal(Incidence *); 59 void editIncidenceSignal(Incidence *);
59 void showIncidenceSignal(Incidence *); 60 void showIncidenceSignal(Incidence *);
60 void deleteIncidenceSignal(Incidence *); 61 void deleteIncidenceSignal(Incidence *);
61 void cloneIncidenceSignal(Incidence *); 62 void cloneIncidenceSignal(Incidence *);
62 void cancelIncidenceSignal(Incidence *); 63 void cancelIncidenceSignal(Incidence *);
63 void moveIncidenceSignal(Incidence *); 64 void moveIncidenceSignal(Incidence *);
64 void beamIncidenceSignal(Incidence *); 65 void beamIncidenceSignal(Incidence *);
65 66
66 private: 67 private:
67 Incidence *mCurrentIncidence; 68 Incidence *mCurrentIncidence;
68 69
69 bool mHasAdditionalItems; 70 bool mHasAdditionalItems;
70 QValueList<int> mEditOnlyItems; 71 QValueList<int> mEditOnlyItems;
72 QValueList<int> mSingleOnlyItems;
73 bool isDisabled;
71}; 74};
72 75
73#endif 76#endif
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index b94916a..02247c8 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1273 +1,1285 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
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 <qlistview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qprogressbar.h> 29#include <qprogressbar.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 <qtextstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qwhatsthis.h> 35#include <qwhatsthis.h>
36#include <qregexp.h> 36#include <qregexp.h>
37 37
38#include <klocale.h> 38#include <klocale.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kglobal.h> 41#include <kglobal.h>
42 42
43#include <libkdepim/kpimglobalprefs.h> 43#include <libkdepim/kpimglobalprefs.h>
44#include <libkcal/calendar.h> 44#include <libkcal/calendar.h>
45#include <libkcal/calendarlocal.h> 45#include <libkcal/calendarlocal.h>
46#include <libkcal/icalformat.h> 46#include <libkcal/icalformat.h>
47#include <libkcal/vcalformat.h> 47#include <libkcal/vcalformat.h>
48#include <libkcal/recurrence.h> 48#include <libkcal/recurrence.h>
49#include <libkcal/filestorage.h> 49#include <libkcal/filestorage.h>
50#include <libkdepim/categoryselectdialog.h> 50#include <libkdepim/categoryselectdialog.h>
51#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
52#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54#else 54#else
55#include <qapplication.h> 55#include <qapplication.h>
56#endif 56#endif
57 57
58#ifndef KORG_NOPRINTER 58#ifndef KORG_NOPRINTER
59#include "calprinter.h" 59#include "calprinter.h"
60#endif 60#endif
61#include "koglobals.h" 61#include "koglobals.h"
62#include "koprefs.h" 62#include "koprefs.h"
63#include "kfiledialog.h" 63#include "kfiledialog.h"
64 64
65#include "kolistview.h" 65#include "kolistview.h"
66 66
67 67
68 68
69 69
70class KOListViewWhatsThis :public QWhatsThis 70class KOListViewWhatsThis :public QWhatsThis
71{ 71{
72public: 72public:
73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
74 74
75protected: 75protected:
76 virtual QString text( const QPoint& p) 76 virtual QString text( const QPoint& p)
77 { 77 {
78 return _view->getWhatsThisText(p) ; 78 return _view->getWhatsThisText(p) ;
79 } 79 }
80private: 80private:
81 QWidget* _wid; 81 QWidget* _wid;
82 KOListView * _view; 82 KOListView * _view;
83}; 83};
84 84
85 85
86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
87{ 87{
88 mItem = item; 88 mItem = item;
89 mDate = date; 89 mDate = date;
90} 90}
91 91
92ListItemVisitor::~ListItemVisitor() 92ListItemVisitor::~ListItemVisitor()
93{ 93{
94} 94}
95 95
96bool ListItemVisitor::visit(Event *e) 96bool ListItemVisitor::visit(Event *e)
97{ 97{
98 bool ok = false; 98 bool ok = false;
99 QString start, end; 99 QString start, end;
100 QDate ds, de; 100 QDate ds, de;
101 if ( e->doesRecur() ) { 101 if ( e->doesRecur() ) {
102 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 102 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
103 if ( ok ) { 103 if ( ok ) {
104 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 104 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
105 start = KGlobal::locale()->formatDate(ds,true); 105 start = KGlobal::locale()->formatDate(ds,true);
106 de = ds.addDays( days); 106 de = ds.addDays( days);
107 end = KGlobal::locale()->formatDate(de,true); 107 end = KGlobal::locale()->formatDate(de,true);
108 } 108 }
109 109
110 } 110 }
111 if ( ! ok ) { 111 if ( ! ok ) {
112 start =e->dtStartDateStr(); 112 start =e->dtStartDateStr();
113 end = e->dtEndDateStr(); 113 end = e->dtEndDateStr();
114 ds = e->dtStart().date(); 114 ds = e->dtStart().date();
115 de = e->dtEnd().date(); 115 de = e->dtEnd().date();
116 } 116 }
117 mItem->setText(0,e->summary()); 117 mItem->setText(0,e->summary());
118 mItem->setText(1,start); 118 mItem->setText(1,start);
119 if ( e->doesFloat() ) 119 if ( e->doesFloat() )
120 mItem->setText(2,"---"); 120 mItem->setText(2,"---");
121 else 121 else
122 mItem->setText(2,e->dtStartTimeStr()); 122 mItem->setText(2,e->dtStartTimeStr());
123 mItem->setText(3,end); 123 mItem->setText(3,end);
124 if ( e->doesFloat() ) 124 if ( e->doesFloat() )
125 mItem->setText(4,"---"); 125 mItem->setText(4,"---");
126 else 126 else
127 mItem->setText(4,e->dtEndTimeStr()); 127 mItem->setText(4,e->dtEndTimeStr());
128 if ( e->isAlarmEnabled() ) { 128 if ( e->isAlarmEnabled() ) {
129 mItem->setText(5,e->alarms().first()->offsetText() ); 129 mItem->setText(5,e->alarms().first()->offsetText() );
130 } else { 130 } else {
131 mItem->setText(5, i18n("No")); 131 mItem->setText(5, i18n("No"));
132 } 132 }
133 mItem->setText(6, e->recurrence()->recurrenceText()); 133 mItem->setText(6, e->recurrence()->recurrenceText());
134 if( ! e->doesRecur() ) 134 if( ! e->doesRecur() )
135 mItem->setSortKey( 6, "-" ); 135 mItem->setSortKey( 6, "-" );
136 mItem->setText(7,"---"); 136 mItem->setText(7,"---");
137 mItem->setText(8,"---"); 137 mItem->setText(8,"---");
138 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 138 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
139 mItem->setText(10,e->categoriesStr()); 139 mItem->setText(10,e->categoriesStr());
140 140
141 QString key; 141 QString key;
142 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 142 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
143 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 143 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
144 mItem->setSortKey(1,key); 144 mItem->setSortKey(1,key);
145 145
146 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 146 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
147 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 147 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
148 mItem->setSortKey(3,key); 148 mItem->setSortKey(3,key);
149 return true; 149 return true;
150} 150}
151 151
152bool ListItemVisitor::visit(Todo *t) 152bool ListItemVisitor::visit(Todo *t)
153{ 153{
154 mItem->setText(0,i18n("Todo: %1").arg(t->summary())); 154 mItem->setText(0,i18n("Todo: %1").arg(t->summary()));
155 if (t->hasStartDate()) { 155 if (t->hasStartDate()) {
156 mItem->setText(1,t->dtStartDateStr()); 156 mItem->setText(1,t->dtStartDateStr());
157 if (t->doesFloat()) { 157 if (t->doesFloat()) {
158 mItem->setText(2,"---"); 158 mItem->setText(2,"---");
159 } else { 159 } else {
160 mItem->setText(2,t->dtStartTimeStr()); 160 mItem->setText(2,t->dtStartTimeStr());
161 } 161 }
162 } else { 162 } else {
163 mItem->setText(1,"---"); 163 mItem->setText(1,"---");
164 mItem->setText(2,"---"); 164 mItem->setText(2,"---");
165 } 165 }
166 mItem->setText(3,"---"); 166 mItem->setText(3,"---");
167 mItem->setText(4,"---"); 167 mItem->setText(4,"---");
168 if ( t->isAlarmEnabled() ) { 168 if ( t->isAlarmEnabled() ) {
169 mItem->setText(5,t->alarms().first()->offsetText() ); 169 mItem->setText(5,t->alarms().first()->offsetText() );
170 } else { 170 } else {
171 mItem->setText(5, i18n("No")); 171 mItem->setText(5, i18n("No"));
172 } 172 }
173 mItem->setText(6, t->recurrence()->recurrenceText()); 173 mItem->setText(6, t->recurrence()->recurrenceText());
174 if( ! t->doesRecur() ) 174 if( ! t->doesRecur() )
175 mItem->setSortKey( 6, "-" ); 175 mItem->setSortKey( 6, "-" );
176 if (t->hasDueDate()) { 176 if (t->hasDueDate()) {
177 mItem->setText(7,t->dtDueDateStr()); 177 mItem->setText(7,t->dtDueDateStr());
178 if (t->doesFloat()) { 178 if (t->doesFloat()) {
179 mItem->setText(8,"---"); 179 mItem->setText(8,"---");
180 } else { 180 } else {
181 mItem->setText(8,t->dtDueTimeStr()); 181 mItem->setText(8,t->dtDueTimeStr());
182 } 182 }
183 } else { 183 } else {
184 mItem->setText(7,"---"); 184 mItem->setText(7,"---");
185 mItem->setText(8,"---"); 185 mItem->setText(8,"---");
186 } 186 }
187 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 187 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
188 mItem->setText(10,t->categoriesStr()); 188 mItem->setText(10,t->categoriesStr());
189 189
190 QString key; 190 QString key;
191 QDate d; 191 QDate d;
192 if (t->hasDueDate()) { 192 if (t->hasDueDate()) {
193 d = t->dtDue().date(); 193 d = t->dtDue().date();
194 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 194 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
195 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 195 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
196 mItem->setSortKey(7,key); 196 mItem->setSortKey(7,key);
197 } 197 }
198 if ( t->hasStartDate() ) { 198 if ( t->hasStartDate() ) {
199 d = t->dtStart().date(); 199 d = t->dtStart().date();
200 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 200 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
201 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 201 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
202 mItem->setSortKey(1,key); 202 mItem->setSortKey(1,key);
203 } 203 }
204 return true; 204 return true;
205} 205}
206 206
207bool ListItemVisitor::visit(Journal * j) 207bool ListItemVisitor::visit(Journal * j)
208{ 208{
209 QString des = j->description().left(30); 209 QString des = j->description().left(30);
210 des = des.simplifyWhiteSpace (); 210 des = des.simplifyWhiteSpace ();
211 des.replace (QRegExp ("\\n"),"" ); 211 des.replace (QRegExp ("\\n"),"" );
212 des.replace (QRegExp ("\\r"),"" ); 212 des.replace (QRegExp ("\\r"),"" );
213 mItem->setText(0,i18n("Journal: ")+des.left(25)); 213 mItem->setText(0,i18n("Journal: ")+des.left(25));
214 mItem->setText(1,j->dtStartDateStr()); 214 mItem->setText(1,j->dtStartDateStr());
215 mItem->setText(2,"---"); 215 mItem->setText(2,"---");
216 mItem->setText(3,"---"); 216 mItem->setText(3,"---");
217 mItem->setText(4,"---"); 217 mItem->setText(4,"---");
218 mItem->setText(5,"---"); 218 mItem->setText(5,"---");
219 mItem->setText(6,"---"); 219 mItem->setText(6,"---");
220 mItem->setText(7,j->dtStartDateStr()); 220 mItem->setText(7,j->dtStartDateStr());
221 mItem->setText(8,"---"); 221 mItem->setText(8,"---");
222 mItem->setText(9,"---"); 222 mItem->setText(9,"---");
223 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 223 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
224 224
225 QString key; 225 QString key;
226 QDate d = j->dtStart().date(); 226 QDate d = j->dtStart().date();
227 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 227 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
228 mItem->setSortKey(1,key); 228 mItem->setSortKey(1,key);
229 mItem->setSortKey(7,key); 229 mItem->setSortKey(7,key);
230 230
231 return true; 231 return true;
232} 232}
233 233
234KOListView::KOListView(Calendar *calendar, QWidget *parent, 234KOListView::KOListView(Calendar *calendar, QWidget *parent,
235 const char *name) 235 const char *name)
236 : KOEventView(calendar, parent, name) 236 : KOEventView(calendar, parent, name)
237{ 237{
238 mActiveItem = 0; 238 mActiveItem = 0;
239 mListView = new KOListViewListView(this); 239 mListView = new KOListViewListView(this);
240 mListView->addColumn(i18n("Summary")); 240 mListView->addColumn(i18n("Summary"));
241 mListView->addColumn(i18n("Start Date")); 241 mListView->addColumn(i18n("Start Date"));
242 mListView->addColumn(i18n("Start Time")); 242 mListView->addColumn(i18n("Start Time"));
243 mListView->addColumn(i18n("End Date")); 243 mListView->addColumn(i18n("End Date"));
244 mListView->addColumn(i18n("End Time")); 244 mListView->addColumn(i18n("End Time"));
245 mListView->addColumn(i18n("Alarm")); // alarm set? 245 mListView->addColumn(i18n("Alarm")); // alarm set?
246 mListView->addColumn(i18n("Recurs")); // recurs? 246 mListView->addColumn(i18n("Recurs")); // recurs?
247 mListView->addColumn(i18n("Due Date")); 247 mListView->addColumn(i18n("Due Date"));
248 mListView->addColumn(i18n("Due Time")); 248 mListView->addColumn(i18n("Due Time"));
249 mListView->addColumn(i18n("Cancelled")); 249 mListView->addColumn(i18n("Cancelled"));
250 mListView->addColumn(i18n("Categories")); 250 mListView->addColumn(i18n("Categories"));
251 251
252 mListView->setColumnAlignment(0,AlignLeft); 252 mListView->setColumnAlignment(0,AlignLeft);
253 mListView->setColumnAlignment(1,AlignLeft); 253 mListView->setColumnAlignment(1,AlignLeft);
254 mListView->setColumnAlignment(2,AlignHCenter); 254 mListView->setColumnAlignment(2,AlignHCenter);
255 mListView->setColumnAlignment(3,AlignLeft); 255 mListView->setColumnAlignment(3,AlignLeft);
256 mListView->setColumnAlignment(4,AlignHCenter); 256 mListView->setColumnAlignment(4,AlignHCenter);
257 mListView->setColumnAlignment(5,AlignLeft); 257 mListView->setColumnAlignment(5,AlignLeft);
258 mListView->setColumnAlignment(6,AlignLeft); 258 mListView->setColumnAlignment(6,AlignLeft);
259 mListView->setColumnAlignment(7,AlignLeft); 259 mListView->setColumnAlignment(7,AlignLeft);
260 mListView->setColumnAlignment(8,AlignLeft); 260 mListView->setColumnAlignment(8,AlignLeft);
261 mListView->setColumnAlignment(9,AlignLeft); 261 mListView->setColumnAlignment(9,AlignLeft);
262 mListView->setColumnAlignment(10,AlignLeft); 262 mListView->setColumnAlignment(10,AlignLeft);
263 mListView->setColumnWidthMode(10, QListView::Manual); 263 mListView->setColumnWidthMode(10, QListView::Manual);
264 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 264 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
265 265
266 int iii = 0; 266 int iii = 0;
267 for ( iii = 0; iii< 10 ; ++iii ) 267 for ( iii = 0; iii< 10 ; ++iii )
268 mListView->setColumnWidthMode( iii, QListView::Manual ); 268 mListView->setColumnWidthMode( iii, QListView::Manual );
269 269
270 QBoxLayout *layoutTop = new QVBoxLayout(this); 270 QBoxLayout *layoutTop = new QVBoxLayout(this);
271 layoutTop->addWidget(mListView); 271 layoutTop->addWidget(mListView);
272 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 272 mListView->setFont ( KOPrefs::instance()->mListViewFont );
273 mPopupMenu = eventPopup(); 273 mPopupMenu = eventPopup();
274 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 274 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
275 i18n("Select all"),this, 275 i18n("Select all"),this,
276 SLOT(allSelection()),true); 276 SLOT(allSelection()),true);
277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
278 i18n("Deselect all"),this, 278 i18n("Deselect all"),this,
279 SLOT(clearSelection()),true); 279 SLOT(clearSelection()),true);
280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
281 i18n("Delete all selected"),this, 281 i18n("Delete all selected"),this,
282 SLOT(deleteAll()),true); 282 SLOT(deleteAll()),true);
283 mPopupMenu->insertSeparator(); 283 mPopupMenu->insertSeparator();
284 QPopupMenu * exportPO = new QPopupMenu ( this ); 284 QPopupMenu * exportPO = new QPopupMenu ( this );
285 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 285 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
286 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 286 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
287 SLOT(saveToFile())); 287 SLOT(saveToFile()));
288 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 288 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
289 SLOT(saveToFileVCS())); 289 SLOT(saveToFileVCS()));
290 exportPO->insertItem( i18n("Journal/Details..."),this, 290 exportPO->insertItem( i18n("Journal/Details..."),this,
291 SLOT(saveDescriptionToFile())); 291 SLOT(saveDescriptionToFile()));
292 // mPopupMenu->insertSeparator(); 292 // mPopupMenu->insertSeparator();
293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
294 i18n("Add Categ. to selected..."),this, 294 i18n("Add Categ. to selected..."),this,
295 SLOT(addCat()),true); 295 SLOT(addCat()),true);
296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
297 i18n("Set Categ. for selected..."),this, 297 i18n("Set Categ. for selected..."),this,
298 SLOT(setCat()),true); 298 SLOT(setCat()),true);
299 //mPopupMenu->insertSeparator(); 299 //mPopupMenu->insertSeparator();
300 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 300 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
301 i18n("Set alarm for selected..."),this, 301 i18n("Set alarm for selected..."),this,
302 SLOT(setAlarm()),true); 302 SLOT(setAlarm()),true);
303 303
304 304
305#ifndef DESKTOP_VERSION 305#ifndef DESKTOP_VERSION
306 mPopupMenu->insertSeparator(); 306 mPopupMenu->insertSeparator();
307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
308 i18n("Beam selected via IR"),this, 308 i18n("Beam selected via IR"),this,
309 SLOT(beamSelected()),true); 309 SLOT(beamSelected()),true);
310#endif 310#endif
311 /* 311 /*
312 mPopupMenu = new QPopupMenu; 312 mPopupMenu = new QPopupMenu;
313 mPopupMenu->insertItem(i18n("Edit Event"), this, 313 mPopupMenu->insertItem(i18n("Edit Event"), this,
314 SLOT (editEvent())); 314 SLOT (editEvent()));
315 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 315 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
316 SLOT (deleteEvent())); 316 SLOT (deleteEvent()));
317 mPopupMenu->insertSeparator(); 317 mPopupMenu->insertSeparator();
318 mPopupMenu->insertItem(i18n("Show Dates"), this, 318 mPopupMenu->insertItem(i18n("Show Dates"), this,
319 SLOT(showDates())); 319 SLOT(showDates()));
320 mPopupMenu->insertItem(i18n("Hide Dates"), this, 320 mPopupMenu->insertItem(i18n("Hide Dates"), this,
321 SLOT(hideDates())); 321 SLOT(hideDates()));
322 */ 322 */
323 QObject::connect(mListView,SIGNAL( newEvent()), 323 QObject::connect(mListView,SIGNAL( newEvent()),
324 this,SIGNAL(signalNewEvent())); 324 this,SIGNAL(signalNewEvent()));
325 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 325 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
326 this,SLOT(defaultItemAction(QListViewItem *))); 326 this,SLOT(defaultItemAction(QListViewItem *)));
327 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 327 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
328 const QPoint &, int )), 328 const QPoint &, int )),
329 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 329 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
330 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 330 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
331 SLOT(processSelectionChange(QListViewItem *))); 331 SLOT(processSelectionChange(QListViewItem *)));
332 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 332 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
333 SIGNAL(showIncidenceSignal(Incidence *)) ); 333 SIGNAL(showIncidenceSignal(Incidence *)) );
334 334
335 readSettings(KOGlobals::config(),"KOListView Layout"); 335 readSettings(KOGlobals::config(),"KOListView Layout");
336} 336}
337 337
338KOListView::~KOListView() 338KOListView::~KOListView()
339{ 339{
340 delete mPopupMenu; 340 delete mPopupMenu;
341#if QT_VERSION >= 0x030000 341#if QT_VERSION >= 0x030000
342 342
343#else 343#else
344 delete mKOListViewWhatsThis; 344 delete mKOListViewWhatsThis;
345#endif 345#endif
346} 346}
347 347
348QString KOListView::getWhatsThisText(QPoint p) 348QString KOListView::getWhatsThisText(QPoint p)
349{ 349{
350 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 350 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
351 if ( item ) 351 if ( item )
352 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 352 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
353 KOPrefs::instance()->mWTshowDetails, 353 KOPrefs::instance()->mWTshowDetails,
354 KOPrefs::instance()->mWTshowCreated, 354 KOPrefs::instance()->mWTshowCreated,
355 KOPrefs::instance()->mWTshowChanged); 355 KOPrefs::instance()->mWTshowChanged);
356 return i18n("That is the list view" ); 356 return i18n("That is the list view" );
357 357
358} 358}
359 359
360void KOListView::updateList() 360void KOListView::updateList()
361{ 361{
362 // qDebug(" KOListView::updateList() "); 362 // qDebug(" KOListView::updateList() ");
363 363
364} 364}
365 365
366void KOListView::addCat( ) 366void KOListView::addCat( )
367{ 367{
368 setCategories( false ); 368 setCategories( false );
369} 369}
370void KOListView::setCat() 370void KOListView::setCat()
371{ 371{
372 setCategories( true ); 372 setCategories( true );
373} 373}
374void KOListView::setAlarm() 374void KOListView::setAlarm()
375{ 375{
376 KOAlarmPrefs kap( this); 376 KOAlarmPrefs kap( this);
377 if ( !kap.exec() ) 377 if ( !kap.exec() )
378 return; 378 return;
379 QStringList itemList; 379 QStringList itemList;
380 QPtrList<KOListViewItem> sel ; 380 QPtrList<KOListViewItem> sel ;
381 QListViewItem *qitem = mListView->firstChild (); 381 QListViewItem *qitem = mListView->firstChild ();
382 while ( qitem ) { 382 while ( qitem ) {
383 if ( qitem->isSelected() ) { 383 if ( qitem->isSelected() ) {
384 Incidence* inc = ((KOListViewItem *) qitem)->data(); 384 Incidence* inc = ((KOListViewItem *) qitem)->data();
385 if ( inc->type() != "Journal" ) { 385 if ( inc->type() != "Journal" ) {
386 if ( inc->type() == "Todo" ) { 386 if ( inc->type() == "Todo" ) {
387 if ( ((Todo*)inc)->hasDueDate() ) 387 if ( ((Todo*)inc)->hasDueDate() )
388 sel.append(((KOListViewItem *)qitem)); 388 sel.append(((KOListViewItem *)qitem));
389 } else 389 } else
390 sel.append(((KOListViewItem *)qitem)); 390 sel.append(((KOListViewItem *)qitem));
391 } 391 }
392 } 392 }
393 qitem = qitem->nextSibling(); 393 qitem = qitem->nextSibling();
394 } 394 }
395 int count = 0; 395 int count = 0;
396 KOListViewItem * item, *temp; 396 KOListViewItem * item, *temp;
397 item = sel.first(); 397 item = sel.first();
398 Incidence* inc; 398 Incidence* inc;
399 while ( item ) { 399 while ( item ) {
400 inc = item->data(); 400 inc = item->data();
401 ++count; 401 ++count;
402 if (kap.mAlarmButton->isChecked()) { 402 if (kap.mAlarmButton->isChecked()) {
403 if (inc->alarms().count() == 0) 403 if (inc->alarms().count() == 0)
404 inc->newAlarm(); 404 inc->newAlarm();
405 QPtrList<Alarm> alarms = inc->alarms(); 405 QPtrList<Alarm> alarms = inc->alarms();
406 Alarm *alarm; 406 Alarm *alarm;
407 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 407 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
408 alarm->setEnabled(true); 408 alarm->setEnabled(true);
409 int j = kap.mAlarmTimeEdit->value()* -60; 409 int j = kap.mAlarmTimeEdit->value()* -60;
410 if (kap.mAlarmIncrCombo->currentItem() == 1) 410 if (kap.mAlarmIncrCombo->currentItem() == 1)
411 j = j * 60; 411 j = j * 60;
412 else if (kap.mAlarmIncrCombo->currentItem() == 2) 412 else if (kap.mAlarmIncrCombo->currentItem() == 2)
413 j = j * (60 * 24); 413 j = j * (60 * 24);
414 alarm->setStartOffset( j ); 414 alarm->setStartOffset( j );
415 415
416 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 416 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
417 alarm->setProcedureAlarm(kap.mAlarmProgram); 417 alarm->setProcedureAlarm(kap.mAlarmProgram);
418 } 418 }
419 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 419 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
420 alarm->setAudioAlarm(kap.mAlarmSound); 420 alarm->setAudioAlarm(kap.mAlarmSound);
421 else 421 else
422 alarm->setType(Alarm::Invalid); 422 alarm->setType(Alarm::Invalid);
423 //alarm->setAudioAlarm("default"); 423 //alarm->setAudioAlarm("default");
424 // TODO: Deal with multiple alarms 424 // TODO: Deal with multiple alarms
425 break; // For now, stop after the first alarm 425 break; // For now, stop after the first alarm
426 } 426 }
427 } else { 427 } else {
428 Alarm* alarm = inc->alarms().first(); 428 Alarm* alarm = inc->alarms().first();
429 if ( alarm ) { 429 if ( alarm ) {
430 alarm->setEnabled(false); 430 alarm->setEnabled(false);
431 alarm->setType(Alarm::Invalid); 431 alarm->setType(Alarm::Invalid);
432 } 432 }
433 } 433 }
434 ListItemVisitor v(item, mStartDate ); 434 ListItemVisitor v(item, mStartDate );
435 inc->accept(v); 435 inc->accept(v);
436 item = sel.next(); 436 item = sel.next();
437 } 437 }
438 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); 438 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) );
439 qDebug("KO: Set alarm for %d items", count); 439 qDebug("KO: Set alarm for %d items", count);
440 calendar()->reInitAlarmSettings(); 440 calendar()->reInitAlarmSettings();
441 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 441 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
442} 442}
443void KOListView::setCategories( bool removeOld ) 443void KOListView::setCategories( bool removeOld )
444{ 444{
445 445
446 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 446 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
447 csd->setColorEnabled(); 447 csd->setColorEnabled();
448 if (! csd->exec()) { 448 if (! csd->exec()) {
449 delete csd; 449 delete csd;
450 return; 450 return;
451 } 451 }
452 QStringList catList = csd->selectedCategories(); 452 QStringList catList = csd->selectedCategories();
453 delete csd; 453 delete csd;
454 // if ( catList.count() == 0 ) 454 // if ( catList.count() == 0 )
455 // return; 455 // return;
456 //catList.sort(); 456 //catList.sort();
457 QString categoriesStr = catList.join(","); 457 QString categoriesStr = catList.join(",");
458 int i; 458 int i;
459 QStringList itemList; 459 QStringList itemList;
460 QPtrList<KOListViewItem> sel ; 460 QPtrList<KOListViewItem> sel ;
461 QListViewItem *qitem = mListView->firstChild (); 461 QListViewItem *qitem = mListView->firstChild ();
462 while ( qitem ) { 462 while ( qitem ) {
463 if ( qitem->isSelected() ) { 463 if ( qitem->isSelected() ) {
464 sel.append(((KOListViewItem *)qitem)); 464 sel.append(((KOListViewItem *)qitem));
465 } 465 }
466 qitem = qitem->nextSibling(); 466 qitem = qitem->nextSibling();
467 } 467 }
468 KOListViewItem * item, *temp; 468 KOListViewItem * item, *temp;
469 item = sel.first(); 469 item = sel.first();
470 if( item ) { 470 if( item ) {
471 Incidence* inc = item->data() ; 471 Incidence* inc = item->data() ;
472 bool setSub = false; 472 bool setSub = false;
473 if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) { 473 if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) {
474 int result = KMessageBox::warningYesNoCancel(this, 474 int result = KMessageBox::warningYesNoCancel(this,
475 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), 475 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ),
476 i18n("Todo has subtodos"), 476 i18n("Todo has subtodos"),
477 i18n("Yes"), 477 i18n("Yes"),
478 i18n("No")); 478 i18n("No"));
479 if (result == KMessageBox::Cancel) item = 0; 479 if (result == KMessageBox::Cancel) item = 0;
480 if (result == KMessageBox::Yes) setSub = true; 480 if (result == KMessageBox::Yes) setSub = true;
481 } 481 }
482 while ( item ) { 482 while ( item ) {
483 inc = item->data(); 483 inc = item->data();
484 if ( removeOld ) { 484 if ( removeOld ) {
485 inc->setCategories( catList, setSub ); 485 inc->setCategories( catList, setSub );
486 } else { 486 } else {
487 inc->addCategories( catList, setSub ); 487 inc->addCategories( catList, setSub );
488 } 488 }
489 ListItemVisitor v(item, mStartDate ); 489 ListItemVisitor v(item, mStartDate );
490 inc->accept(v); 490 inc->accept(v);
491 item = sel.next(); 491 item = sel.next();
492 } 492 }
493 } 493 }
494 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 494 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
495} 495}
496 496
497void KOListView::beamSelected() 497void KOListView::beamSelected()
498{ 498{
499 int icount = 0; 499 int icount = 0;
500 QPtrList<Incidence> delSel ; 500 QPtrList<Incidence> delSel ;
501 QListViewItem *item = mListView->firstChild (); 501 QListViewItem *item = mListView->firstChild ();
502 while ( item ) { 502 while ( item ) {
503 if ( item->isSelected() ) { 503 if ( item->isSelected() ) {
504 delSel.append(((KOListViewItem *)item)->data()); 504 delSel.append(((KOListViewItem *)item)->data());
505 ++icount; 505 ++icount;
506 } 506 }
507 507
508 item = item->nextSibling(); 508 item = item->nextSibling();
509 } 509 }
510 if ( icount ) { 510 if ( icount ) {
511 emit beamIncidenceList( delSel ); 511 emit beamIncidenceList( delSel );
512 return; 512 return;
513 QString fn ; 513 QString fn ;
514 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 514 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
515 QString mes; 515 QString mes;
516 bool createbup = true; 516 bool createbup = true;
517 if ( createbup ) { 517 if ( createbup ) {
518 QString description = "\n"; 518 QString description = "\n";
519 CalendarLocal* cal = new CalendarLocal(); 519 CalendarLocal* cal = new CalendarLocal();
520 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 520 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
521 Incidence *incidence = delSel.first(); 521 Incidence *incidence = delSel.first();
522 while ( incidence ) { 522 while ( incidence ) {
523 Incidence *in = incidence->clone(); 523 Incidence *in = incidence->clone();
524 description += in->summary() + "\n"; 524 description += in->summary() + "\n";
525 cal->addIncidence( in ); 525 cal->addIncidence( in );
526 incidence = delSel.next(); 526 incidence = delSel.next();
527 } 527 }
528 FileStorage storage( cal, fn, new VCalFormat ); 528 FileStorage storage( cal, fn, new VCalFormat );
529 storage.save(); 529 storage.save();
530 delete cal; 530 delete cal;
531 mes = i18n("KO/Pi: Ready for beaming"); 531 mes = i18n("KO/Pi: Ready for beaming");
532 topLevelWidget()->setCaption(mes); 532 topLevelWidget()->setCaption(mes);
533 533
534#ifndef DESKTOP_VERSION 534#ifndef DESKTOP_VERSION
535 Ir *ir = new Ir( this ); 535 Ir *ir = new Ir( this );
536 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 536 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
537 ir->send( fn, description, "text/x-vCalendar" ); 537 ir->send( fn, description, "text/x-vCalendar" );
538#endif 538#endif
539 } 539 }
540 } 540 }
541} 541}
542void KOListView::beamDone( Ir *ir ) 542void KOListView::beamDone( Ir *ir )
543{ 543{
544#ifndef DESKTOP_VERSION 544#ifndef DESKTOP_VERSION
545 delete ir; 545 delete ir;
546#endif 546#endif
547 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 547 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
548} 548}
549 549
550void KOListView::saveDescriptionToFile() 550void KOListView::saveDescriptionToFile()
551{ 551{
552 552
553 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 553 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
554 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 554 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
555 i18n("Continue"), i18n("Cancel"), 0, 555 i18n("Continue"), i18n("Cancel"), 0,
556 0, 1 ); 556 0, 1 );
557 if ( result != 0 ) { 557 if ( result != 0 ) {
558 return; 558 return;
559 } 559 }
560 int icount = 0; 560 int icount = 0;
561 QPtrList<Incidence> delSel ; 561 QPtrList<Incidence> delSel ;
562 QListViewItem *item = mListView->firstChild (); 562 QListViewItem *item = mListView->firstChild ();
563 while ( item ) { 563 while ( item ) {
564 if ( item->isSelected() ) { 564 if ( item->isSelected() ) {
565 delSel.append(((KOListViewItem *)item)->data()); 565 delSel.append(((KOListViewItem *)item)->data());
566 ++icount; 566 ++icount;
567 } 567 }
568 568
569 item = item->nextSibling(); 569 item = item->nextSibling();
570 } 570 }
571 if ( icount ) { 571 if ( icount ) {
572 QString fn = KOPrefs::instance()->mLastSaveFile; 572 QString fn = KOPrefs::instance()->mLastSaveFile;
573 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 573 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
574 574
575 if ( fn == "" ) 575 if ( fn == "" )
576 return; 576 return;
577 QFileInfo info; 577 QFileInfo info;
578 info.setFile( fn ); 578 info.setFile( fn );
579 QString mes; 579 QString mes;
580 bool createbup = true; 580 bool createbup = true;
581 if ( info. exists() ) { 581 if ( info. exists() ) {
582 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 582 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
583 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 583 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
584 i18n("Overwrite!"), i18n("Cancel"), 0, 584 i18n("Overwrite!"), i18n("Cancel"), 0,
585 0, 1 ); 585 0, 1 );
586 if ( result != 0 ) { 586 if ( result != 0 ) {
587 createbup = false; 587 createbup = false;
588 } 588 }
589 } 589 }
590 if ( createbup ) { 590 if ( createbup ) {
591 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 591 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
592 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 592 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
593 Incidence *incidence = delSel.first(); 593 Incidence *incidence = delSel.first();
594 icount = 0; 594 icount = 0;
595 while ( incidence ) { 595 while ( incidence ) {
596 if ( incidence->type() == "Journal" ) { 596 if ( incidence->type() == "Journal" ) {
597 text += "\n************************************\n"; 597 text += "\n************************************\n";
598 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 598 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
599 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 599 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
600 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 600 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
601 ++icount; 601 ++icount;
602 602
603 } else { 603 } else {
604 if ( !incidence->description().isEmpty() ) { 604 if ( !incidence->description().isEmpty() ) {
605 text += "\n************************************\n"; 605 text += "\n************************************\n";
606 if ( incidence->type() == "Todo" ) 606 if ( incidence->type() == "Todo" )
607 text += i18n("To-Do: "); 607 text += i18n("To-Do: ");
608 text += incidence->summary(); 608 text += incidence->summary();
609 if ( incidence->hasStartDate() ) 609 if ( incidence->hasStartDate() )
610 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 610 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
611 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 611 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
612 if ( !incidence->location().isEmpty() ) 612 if ( !incidence->location().isEmpty() )
613 text += "\n" +i18n("Location: ") + incidence->location(); 613 text += "\n" +i18n("Location: ") + incidence->location();
614 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 614 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
615 ++icount; 615 ++icount;
616 616
617 } 617 }
618 } 618 }
619 incidence = delSel.next(); 619 incidence = delSel.next();
620 } 620 }
621 QFile file( fn ); 621 QFile file( fn );
622 if (!file.open( IO_WriteOnly ) ) { 622 if (!file.open( IO_WriteOnly ) ) {
623 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 623 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
624 return; 624 return;
625 } 625 }
626 QTextStream ts( &file ); 626 QTextStream ts( &file );
627 ts << text; 627 ts << text;
628 file.close(); 628 file.close();
629 //qDebug("%s ", text.latin1()); 629 //qDebug("%s ", text.latin1());
630 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 630 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
631 KOPrefs::instance()->mLastSaveFile = fn; 631 KOPrefs::instance()->mLastSaveFile = fn;
632 topLevelWidget()->setCaption(mes); 632 topLevelWidget()->setCaption(mes);
633 } 633 }
634 } 634 }
635} 635}
636void KOListView::saveToFileVCS() 636void KOListView::saveToFileVCS()
637{ 637{
638 writeToFile( false ); 638 writeToFile( false );
639} 639}
640void KOListView::saveToFile() 640void KOListView::saveToFile()
641{ 641{
642 writeToFile( true ); 642 writeToFile( true );
643} 643}
644void KOListView::writeToFile( bool iCal ) 644void KOListView::writeToFile( bool iCal )
645{ 645{
646 646
647 int icount = 0; 647 int icount = 0;
648 QPtrList<Incidence> delSel ; 648 QPtrList<Incidence> delSel ;
649 QListViewItem *item = mListView->firstChild (); 649 QListViewItem *item = mListView->firstChild ();
650 bool journal = iCal; // warn only for vCal 650 bool journal = iCal; // warn only for vCal
651 while ( item ) { 651 while ( item ) {
652 if ( item->isSelected() ) { 652 if ( item->isSelected() ) {
653 if ( !journal ) 653 if ( !journal )
654 if ( ((KOListViewItem *)item)->data()->type() == "Journal") 654 if ( ((KOListViewItem *)item)->data()->type() == "Journal")
655 journal = true; 655 journal = true;
656 delSel.append(((KOListViewItem *)item)->data()); 656 delSel.append(((KOListViewItem *)item)->data());
657 ++icount; 657 ++icount;
658 } 658 }
659 659
660 item = item->nextSibling(); 660 item = item->nextSibling();
661 } 661 }
662 if ( !iCal && journal ) { 662 if ( !iCal && journal ) {
663 int result = KMessageBox::warningContinueCancel(this, 663 int result = KMessageBox::warningContinueCancel(this,
664 i18n("The journal entries can not be\nexported to a vCalendar file."), 664 i18n("The journal entries can not be\nexported to a vCalendar file."),
665 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 665 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
666 true); 666 true);
667 if (result != KMessageBox::Continue) return; 667 if (result != KMessageBox::Continue) return;
668 } 668 }
669 if ( icount ) { 669 if ( icount ) {
670 QString fn = KOPrefs::instance()->mLastSaveFile; 670 QString fn = KOPrefs::instance()->mLastSaveFile;
671 QString extension; 671 QString extension;
672 if ( iCal ) { 672 if ( iCal ) {
673 if ( fn.right( 4 ).lower() == ".vcs" ) { 673 if ( fn.right( 4 ).lower() == ".vcs" ) {
674 fn = fn.left( fn.length() -3) + "ics"; 674 fn = fn.left( fn.length() -3) + "ics";
675 } 675 }
676 } else { 676 } else {
677 if ( fn.right( 4 ).lower() == ".ics" ) { 677 if ( fn.right( 4 ).lower() == ".ics" ) {
678 fn = fn.left( fn.length() -3) + "vcs"; 678 fn = fn.left( fn.length() -3) + "vcs";
679 } 679 }
680 } 680 }
681 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 681 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
682 682
683 if ( fn == "" ) 683 if ( fn == "" )
684 return; 684 return;
685 QFileInfo info; 685 QFileInfo info;
686 info.setFile( fn ); 686 info.setFile( fn );
687 QString mes; 687 QString mes;
688 bool createbup = true; 688 bool createbup = true;
689 if ( info. exists() ) { 689 if ( info. exists() ) {
690 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 690 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
691 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 691 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
692 i18n("Overwrite!"), i18n("Cancel"), 0, 692 i18n("Overwrite!"), i18n("Cancel"), 0,
693 0, 1 ); 693 0, 1 );
694 if ( result != 0 ) { 694 if ( result != 0 ) {
695 createbup = false; 695 createbup = false;
696 } 696 }
697 } 697 }
698 if ( createbup ) { 698 if ( createbup ) {
699 CalendarLocal cal; 699 CalendarLocal cal;
700 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 700 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
701 Incidence *incidence = delSel.first(); 701 Incidence *incidence = delSel.first();
702 while ( incidence ) { 702 while ( incidence ) {
703 cal.addIncidence( incidence->clone() ); 703 cal.addIncidence( incidence->clone() );
704 incidence = delSel.next(); 704 incidence = delSel.next();
705 } 705 }
706 if ( iCal ) { 706 if ( iCal ) {
707 ICalFormat format; 707 ICalFormat format;
708 format.save( &cal, fn ); 708 format.save( &cal, fn );
709 } else { 709 } else {
710 710
711 VCalFormat format; 711 VCalFormat format;
712 format.save( &cal, fn ); 712 format.save( &cal, fn );
713 } 713 }
714 mes = i18n("KO/Pi:Saved %1").arg(fn ); 714 mes = i18n("KO/Pi:Saved %1").arg(fn );
715 KOPrefs::instance()->mLastSaveFile = fn; 715 KOPrefs::instance()->mLastSaveFile = fn;
716 topLevelWidget()->setCaption(mes); 716 topLevelWidget()->setCaption(mes);
717 } 717 }
718 } 718 }
719 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 719 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
720} 720}
721void KOListView::deleteAll() 721void KOListView::deleteAll()
722{ 722{
723 int icount = 0; 723 int icount = 0;
724 QPtrList<Incidence> delSel ; 724 QPtrList<Incidence> delSel ;
725 QListViewItem *item = mListView->firstChild (); 725 QListViewItem *item = mListView->firstChild ();
726 while ( item ) { 726 while ( item ) {
727 if ( item->isSelected() ) { 727 if ( item->isSelected() ) {
728 delSel.append(((KOListViewItem *)item)->data()); 728 delSel.append(((KOListViewItem *)item)->data());
729 ++icount; 729 ++icount;
730 } 730 }
731 731
732 item = item->nextSibling(); 732 item = item->nextSibling();
733 } 733 }
734 if ( icount ) { 734 if ( icount ) {
735 Incidence *incidence = delSel.first(); 735 Incidence *incidence = delSel.first();
736 Incidence *toDelete; 736 Incidence *toDelete;
737 KOPrefs *p = KOPrefs::instance(); 737 KOPrefs *p = KOPrefs::instance();
738 bool confirm = p->mConfirm; 738 bool confirm = p->mConfirm;
739 QString mess; 739 QString mess;
740 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 740 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
741 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")) ) { 741 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")) ) {
742 p->mConfirm = false; 742 p->mConfirm = false;
743 int delCounter = 0; 743 int delCounter = 0;
744 QDialog dia ( this, "p-dialog", true ); 744 QDialog dia ( this, "p-dialog", true );
745 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 745 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
746 QVBoxLayout lay( &dia ); 746 QVBoxLayout lay( &dia );
747 lay.setMargin(7); 747 lay.setMargin(7);
748 lay.setSpacing(7); 748 lay.setSpacing(7);
749 lay.addWidget( &lab); 749 lay.addWidget( &lab);
750 QProgressBar bar( icount, &dia ); 750 QProgressBar bar( icount, &dia );
751 lay.addWidget( &bar); 751 lay.addWidget( &bar);
752 int w = 220; 752 int w = 220;
753 int h = 50; 753 int h = 50;
754 int dw = QApplication::desktop()->width(); 754 int dw = QApplication::desktop()->width();
755 int dh = QApplication::desktop()->height(); 755 int dh = QApplication::desktop()->height();
756 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 756 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
757 //dia.resize( 240,50 ); 757 //dia.resize( 240,50 );
758 dia.show(); 758 dia.show();
759 759
760 while ( incidence ) { 760 while ( incidence ) {
761 bar.setProgress( delCounter ); 761 bar.setProgress( delCounter );
762 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 762 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
763 dia.setCaption( mess ); 763 dia.setCaption( mess );
764 qApp->processEvents(); 764 qApp->processEvents();
765 toDelete = (incidence); 765 toDelete = (incidence);
766 incidence = delSel.next(); 766 incidence = delSel.next();
767 emit deleteIncidenceSignal(toDelete ); 767 emit deleteIncidenceSignal(toDelete );
768 if ( dia.result() != 0 ) 768 if ( dia.result() != 0 )
769 break; 769 break;
770 770
771 } 771 }
772 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 772 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
773 topLevelWidget ()->setCaption( mess ); 773 topLevelWidget ()->setCaption( mess );
774 p->mConfirm = confirm; 774 p->mConfirm = confirm;
775 } 775 }
776 } 776 }
777 777
778 778
779} 779}
780int KOListView::maxDatesHint() 780int KOListView::maxDatesHint()
781{ 781{
782 return 0; 782 return 0;
783} 783}
784 784
785int KOListView::currentDateCount() 785int KOListView::currentDateCount()
786{ 786{
787 return 0; 787 return 0;
788} 788}
789 789
790QPtrList<Incidence> KOListView::selectedIncidences() 790QPtrList<Incidence> KOListView::selectedIncidences()
791{ 791{
792 QPtrList<Incidence> eventList; 792 QPtrList<Incidence> eventList;
793 QListViewItem *item = mListView->firstChild (); 793 QListViewItem *item = mListView->firstChild ();
794 while ( item ) { 794 while ( item ) {
795 if ( item->isSelected() ) { 795 if ( item->isSelected() ) {
796 eventList.append(((KOListViewItem *)item)->data()); 796 eventList.append(((KOListViewItem *)item)->data());
797 } 797 }
798 798
799 item = item->nextSibling(); 799 item = item->nextSibling();
800 } 800 }
801 801
802 // // QListViewItem *item = mListView->selectedItem(); 802 // // QListViewItem *item = mListView->selectedItem();
803 //if (item) eventList.append(((KOListViewItem *)item)->data()); 803 //if (item) eventList.append(((KOListViewItem *)item)->data());
804 804
805 return eventList; 805 return eventList;
806} 806}
807 807
808DateList KOListView::selectedDates() 808DateList KOListView::selectedDates()
809{ 809{
810 DateList eventList; 810 DateList eventList;
811 return eventList; 811 return eventList;
812} 812}
813 813
814void KOListView::showDates(bool show) 814void KOListView::showDates(bool show)
815{ 815{
816 // Shouldn't we set it to a value greater 0? When showDates is called with 816 // Shouldn't we set it to a value greater 0? When showDates is called with
817 // show == true at first, then the columnwidths are set to zero. 817 // show == true at first, then the columnwidths are set to zero.
818 static int oldColWidth1 = 0; 818 static int oldColWidth1 = 0;
819 static int oldColWidth3 = 0; 819 static int oldColWidth3 = 0;
820 820
821 if (!show) { 821 if (!show) {
822 oldColWidth1 = mListView->columnWidth(1); 822 oldColWidth1 = mListView->columnWidth(1);
823 oldColWidth3 = mListView->columnWidth(3); 823 oldColWidth3 = mListView->columnWidth(3);
824 mListView->setColumnWidth(1, 0); 824 mListView->setColumnWidth(1, 0);
825 mListView->setColumnWidth(3, 0); 825 mListView->setColumnWidth(3, 0);
826 } else { 826 } else {
827 mListView->setColumnWidth(1, oldColWidth1); 827 mListView->setColumnWidth(1, oldColWidth1);
828 mListView->setColumnWidth(3, oldColWidth3); 828 mListView->setColumnWidth(3, oldColWidth3);
829 } 829 }
830 mListView->repaint(); 830 mListView->repaint();
831} 831}
832 832
833void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 833void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
834 const QDate &td) 834 const QDate &td)
835{ 835{
836#ifndef KORG_NOPRINTER 836#ifndef KORG_NOPRINTER
837 calPrinter->preview(CalPrinter::Day, fd, td); 837 calPrinter->preview(CalPrinter::Day, fd, td);
838#endif 838#endif
839} 839}
840 840
841void KOListView::showDates() 841void KOListView::showDates()
842{ 842{
843 showDates(true); 843 showDates(true);
844} 844}
845 845
846void KOListView::hideDates() 846void KOListView::hideDates()
847{ 847{
848 showDates(false); 848 showDates(false);
849} 849}
850 850
851void KOListView::resetFocus() 851void KOListView::resetFocus()
852{ 852{
853 topLevelWidget()->setActiveWindow(); 853 topLevelWidget()->setActiveWindow();
854 topLevelWidget()->raise(); 854 topLevelWidget()->raise();
855 mListView->setFocus(); 855 mListView->setFocus();
856} 856}
857void KOListView::updateView() 857void KOListView::updateView()
858{ 858{
859 mListView->setFocus(); 859 mListView->setFocus();
860 if ( mListView->firstChild () ) 860 if ( mListView->firstChild () )
861 mListView->setCurrentItem( mListView->firstChild () ); 861 mListView->setCurrentItem( mListView->firstChild () );
862} 862}
863void KOListView::updateConfig() 863void KOListView::updateConfig()
864{ 864{
865 865
866 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 866 mListView->setFont ( KOPrefs::instance()->mListViewFont );
867 updateView(); 867 updateView();
868 868
869} 869}
870void KOListView::setStartDate(const QDate &start) 870void KOListView::setStartDate(const QDate &start)
871{ 871{
872 mStartDate = start; 872 mStartDate = start;
873} 873}
874 874
875void KOListView::showDates(const QDate &start, const QDate &end) 875void KOListView::showDates(const QDate &start, const QDate &end)
876{ 876{
877 clear(); 877 clear();
878 mStartDate = start; 878 mStartDate = start;
879 QDate date = start; 879 QDate date = start;
880 QPtrList<Journal> j_list; 880 QPtrList<Journal> j_list;
881 while( date <= end ) { 881 while( date <= end ) {
882 addEvents(calendar()->events(date)); 882 addEvents(calendar()->events(date));
883 addTodos(calendar()->todos(date)); 883 addTodos(calendar()->todos(date));
884 Journal* jo = calendar()->journal(date); 884 Journal* jo = calendar()->journal(date);
885 if ( jo ) 885 if ( jo )
886 j_list.append( jo ); 886 j_list.append( jo );
887 date = date.addDays( 1 ); 887 date = date.addDays( 1 );
888 } 888 }
889 addJournals(j_list); 889 addJournals(j_list);
890 emit incidenceSelected( 0 ); 890 emit incidenceSelected( 0 );
891 updateView(); 891 updateView();
892 892
893} 893}
894 894
895void KOListView::addEvents(QPtrList<Event> eventList) 895void KOListView::addEvents(QPtrList<Event> eventList)
896{ 896{
897 897
898 Event *ev; 898 Event *ev;
899 for(ev = eventList.first(); ev; ev = eventList.next()) { 899 for(ev = eventList.first(); ev; ev = eventList.next()) {
900 addIncidence(ev); 900 addIncidence(ev);
901 } 901 }
902 if ( !mListView->currentItem() ){ 902 if ( !mListView->currentItem() ){
903 updateView(); 903 updateView();
904 } 904 }
905} 905}
906 906
907void KOListView::addTodos(QPtrList<Todo> eventList) 907void KOListView::addTodos(QPtrList<Todo> eventList)
908{ 908{
909 Todo *ev; 909 Todo *ev;
910 for(ev = eventList.first(); ev; ev = eventList.next()) { 910 for(ev = eventList.first(); ev; ev = eventList.next()) {
911 addIncidence(ev); 911 addIncidence(ev);
912 } 912 }
913 if ( !mListView->currentItem() ){ 913 if ( !mListView->currentItem() ){
914 updateView(); 914 updateView();
915 } 915 }
916} 916}
917void KOListView::addJournals(QPtrList<Journal> eventList) 917void KOListView::addJournals(QPtrList<Journal> eventList)
918{ 918{
919 Journal *ev; 919 Journal *ev;
920 for(ev = eventList.first(); ev; ev = eventList.next()) { 920 for(ev = eventList.first(); ev; ev = eventList.next()) {
921 addIncidence(ev); 921 addIncidence(ev);
922 } 922 }
923 if ( !mListView->currentItem() ){ 923 if ( !mListView->currentItem() ){
924 updateView(); 924 updateView();
925 } 925 }
926} 926}
927 927
928void KOListView::addIncidence(Incidence *incidence) 928void KOListView::addIncidence(Incidence *incidence)
929{ 929{
930 if ( mUidDict.find( incidence->uid() ) ) return; 930 if ( mUidDict.find( incidence->uid() ) ) return;
931 931
932 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 932 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
933 mUidDict.insert( incidence->uid(), incidence ); 933 mUidDict.insert( incidence->uid(), incidence );
934 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 934 KOListViewItem *item = new KOListViewItem( incidence, mListView );
935 ListItemVisitor v(item, mStartDate ); 935 ListItemVisitor v(item, mStartDate );
936 if (incidence->accept(v)) { 936 if (incidence->accept(v)) {
937 return; 937 return;
938 } 938 }
939 else delete item; 939 else delete item;
940} 940}
941 941
942void KOListView::showEvents(QPtrList<Event> eventList) 942void KOListView::showEvents(QPtrList<Event> eventList)
943{ 943{
944 clear(); 944 clear();
945 945
946 addEvents(eventList); 946 addEvents(eventList);
947 947
948 // After new creation of list view no events are selected. 948 // After new creation of list view no events are selected.
949 emit incidenceSelected( 0 ); 949 emit incidenceSelected( 0 );
950} 950}
951int KOListView::count() 951int KOListView::count()
952{ 952{
953 return mListView->childCount(); 953 return mListView->childCount();
954} 954}
955 955
956void KOListView::changeEventDisplay(Event *event, int action) 956void KOListView::changeEventDisplay(Event *event, int action)
957{ 957{
958 KOListViewItem *item; 958 KOListViewItem *item;
959 959
960 switch(action) { 960 switch(action) {
961 case KOGlobals::EVENTADDED: 961 case KOGlobals::EVENTADDED:
962 addIncidence( event ); 962 addIncidence( event );
963 break; 963 break;
964 case KOGlobals::EVENTEDITED: 964 case KOGlobals::EVENTEDITED:
965 item = getItemForEvent(event); 965 item = getItemForEvent(event);
966 if (item) { 966 if (item) {
967 mUidDict.remove( event->uid() ); 967 mUidDict.remove( event->uid() );
968 delete item; 968 delete item;
969 addIncidence( event ); 969 addIncidence( event );
970 } 970 }
971 break; 971 break;
972 case KOGlobals::EVENTDELETED: 972 case KOGlobals::EVENTDELETED:
973 item = getItemForEvent(event); 973 item = getItemForEvent(event);
974 if (item) { 974 if (item) {
975 mUidDict.remove( event->uid() ); 975 mUidDict.remove( event->uid() );
976 delete item; 976 delete item;
977 } 977 }
978 break; 978 break;
979 default: 979 default:
980 ; 980 ;
981 } 981 }
982} 982}
983 983
984KOListViewItem *KOListView::getItemForEvent(Event *event) 984KOListViewItem *KOListView::getItemForEvent(Event *event)
985{ 985{
986 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 986 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
987 while (item) { 987 while (item) {
988 if (item->data() == event) return item; 988 if (item->data() == event) return item;
989 item = (KOListViewItem *)item->nextSibling(); 989 item = (KOListViewItem *)item->nextSibling();
990 } 990 }
991 return 0; 991 return 0;
992} 992}
993 993
994void KOListView::defaultItemAction(QListViewItem *i) 994void KOListView::defaultItemAction(QListViewItem *i)
995{ 995{
996 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 996 KOListViewItem *item = static_cast<KOListViewItem *>( i );
997 if ( item ) defaultAction( item->data() ); 997 if ( item ) defaultAction( item->data() );
998 998
999} 999}
1000 1000
1001void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 1001void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
1002{ 1002{
1003 mActiveItem = (KOListViewItem *)item; 1003 mActiveItem = (KOListViewItem *)item;
1004 if (mActiveItem) { 1004 if (mActiveItem) {
1005 Incidence *incidence = mActiveItem->data(); 1005 Incidence *incidence = mActiveItem->data();
1006 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) );
1006 mPopupMenu->showIncidencePopup(incidence); 1007 mPopupMenu->showIncidencePopup(incidence);
1007 1008
1008 /* 1009 /*
1009 if ( incidence && incidence->type() == "Event" ) { 1010 if ( incidence && incidence->type() == "Event" ) {
1010 Event *event = static_cast<Event *>( incidence ); 1011 Event *event = static_cast<Event *>( incidence );
1011 mPopupMenu->showEventPopup(event); 1012 mPopupMenu->showEventPopup(event);
1012 } 1013 }
1013 */ 1014 */
1014 } 1015 }
1015} 1016}
1016 1017
1017void KOListView::readSettings(KConfig *config, QString setting) 1018void KOListView::readSettings(KConfig *config, QString setting)
1018{ 1019{
1019 // qDebug("KOListView::readSettings "); 1020 // qDebug("KOListView::readSettings ");
1020 mListView->restoreLayout(config,setting); 1021 mListView->restoreLayout(config,setting);
1021} 1022}
1022 1023
1023void KOListView::writeSettings(KConfig *config, QString setting) 1024void KOListView::writeSettings(KConfig *config, QString setting)
1024{ 1025{
1025 // qDebug("KOListView::writeSettings "); 1026 // qDebug("KOListView::writeSettings ");
1026 mListView->saveLayout(config, setting); 1027 mListView->saveLayout(config, setting);
1027} 1028}
1028 1029
1029void KOListView::processSelectionChange(QListViewItem *) 1030void KOListView::processSelectionChange(QListViewItem *)
1030{ 1031{
1031 1032
1032 KOListViewItem *item = 1033 KOListViewItem *item =
1033 static_cast<KOListViewItem *>( mListView->currentItem() ); 1034 static_cast<KOListViewItem *>( mListView->currentItem() );
1034 1035
1035 if ( !item ) { 1036 if ( !item ) {
1036 emit incidenceSelected( 0 ); 1037 emit incidenceSelected( 0 );
1037 } else { 1038 } else {
1038 emit incidenceSelected( item->data() ); 1039 emit incidenceSelected( item->data() );
1039 } 1040 }
1040} 1041}
1041 1042
1042void KOListView::clearSelection() 1043void KOListView::clearSelection()
1043{ 1044{
1044 mListView->selectAll( false ); 1045 mListView->selectAll( false );
1045} 1046}
1046void KOListView::allSelection() 1047void KOListView::allSelection()
1047{ 1048{
1048 mListView->selectAll( true ); 1049 mListView->selectAll( true );
1049} 1050}
1050 1051
1051void KOListView::clear() 1052void KOListView::clear()
1052{ 1053{
1053 mListView->clear(); 1054 mListView->clear();
1054 mUidDict.clear(); 1055 mUidDict.clear();
1055} 1056}
1056 1057
1057Incidence* KOListView::currentItem() 1058Incidence* KOListView::currentItem()
1058{ 1059{
1059 if ( mListView->currentItem() ) 1060 if ( mListView->currentItem() )
1060 return ((KOListViewItem*) mListView->currentItem())->data(); 1061 return ((KOListViewItem*) mListView->currentItem())->data();
1061 return 0; 1062 return 0;
1062} 1063}
1063void KOListView::keyPressEvent ( QKeyEvent *e) 1064void KOListView::keyPressEvent ( QKeyEvent *e)
1064{ 1065{
1065 1066
1066 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1067 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1067 deleteAll(); 1068 deleteAll();
1068 return; 1069 return;
1069 } 1070 }
1070 1071
1071 e->ignore(); 1072 e->ignore();
1072} 1073}
1073void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1074void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1074{ 1075{
1075 1076
1076 switch ( e->key() ) { 1077 switch ( e->key() ) {
1077 case Qt::Key_Down: 1078 case Qt::Key_Down:
1078 if ( e->state() == ShiftButton ) { 1079 if ( e->state() == ShiftButton ) {
1079 QListViewItem* cn = currentItem(); 1080 QListViewItem* cn = currentItem();
1080 if ( !cn ) 1081 if ( !cn )
1081 cn = firstChild(); 1082 cn = firstChild();
1082 if ( !cn ) 1083 if ( !cn )
1083 return; 1084 return;
1084 while ( cn->nextSibling() ) 1085 while ( cn->nextSibling() )
1085 cn = cn->nextSibling(); 1086 cn = cn->nextSibling();
1086 setCurrentItem ( cn ); 1087 setCurrentItem ( cn );
1087 ensureItemVisible ( cn ); 1088 ensureItemVisible ( cn );
1088 1089
1089 e->accept(); 1090 e->accept();
1090 return; 1091 return;
1091 } 1092 }
1092 if ( e->state() == ControlButton ) { 1093 if ( e->state() == ControlButton ) {
1093 int count = childCount (); 1094 int count = childCount ();
1094 int jump = count / 5; 1095 int jump = count / 5;
1095 QListViewItem* cn; 1096 QListViewItem* cn;
1096 cn = currentItem(); 1097 cn = currentItem();
1097 if ( ! cn ) 1098 if ( ! cn )
1098 return; 1099 return;
1099 if ( jump == 0 ) 1100 if ( jump == 0 )
1100 jump = 1; 1101 jump = 1;
1101 while ( jump && cn->nextSibling() ) { 1102 while ( jump && cn->nextSibling() ) {
1102 cn = cn->nextSibling(); 1103 cn = cn->nextSibling();
1103 --jump; 1104 --jump;
1104 } 1105 }
1105 setCurrentItem ( cn ); 1106 setCurrentItem ( cn );
1106 ensureItemVisible ( cn ); 1107 ensureItemVisible ( cn );
1107 1108
1108 } else 1109 } else
1109 QListView::keyPressEvent ( e ) ; 1110 QListView::keyPressEvent ( e ) ;
1110 e->accept(); 1111 e->accept();
1111 break; 1112 break;
1112 1113
1113 case Qt::Key_Up: 1114 case Qt::Key_Up:
1114 if ( e->state() == ShiftButton ) { 1115 if ( e->state() == ShiftButton ) {
1115 QListViewItem* cn = firstChild(); 1116 QListViewItem* cn = firstChild();
1116 if ( cn ) { 1117 if ( cn ) {
1117 setCurrentItem ( cn ); 1118 setCurrentItem ( cn );
1118 ensureItemVisible ( cn ); 1119 ensureItemVisible ( cn );
1119 } 1120 }
1120 e->accept(); 1121 e->accept();
1121 return; 1122 return;
1122 } 1123 }
1123 if ( e->state() == ControlButton ) { 1124 if ( e->state() == ControlButton ) {
1124 int count = childCount (); 1125 int count = childCount ();
1125 int jump = count / 5; 1126 int jump = count / 5;
1126 QListViewItem* cn; 1127 QListViewItem* cn;
1127 cn = currentItem(); 1128 cn = currentItem();
1128 if ( ! cn ) 1129 if ( ! cn )
1129 return; 1130 return;
1130 if ( jump == 0 ) 1131 if ( jump == 0 )
1131 jump = 1; 1132 jump = 1;
1132 while ( jump && cn->itemAbove ()) { 1133 while ( jump && cn->itemAbove ()) {
1133 cn = cn->itemAbove (); 1134 cn = cn->itemAbove ();
1134 --jump; 1135 --jump;
1135 } 1136 }
1136 setCurrentItem ( cn ); 1137 setCurrentItem ( cn );
1137 ensureItemVisible ( cn ); 1138 ensureItemVisible ( cn );
1138 } else 1139 } else
1139 QListView::keyPressEvent ( e ) ; 1140 QListView::keyPressEvent ( e ) ;
1140 e->accept(); 1141 e->accept();
1141 break; 1142 break;
1142 case Qt::Key_I: { 1143 case Qt::Key_I: {
1143 QListViewItem* cn; 1144 QListViewItem* cn;
1144 cn = currentItem(); 1145 cn = currentItem();
1145 if ( cn ) { 1146 if ( cn ) {
1146 KOListViewItem* ci = (KOListViewItem*)( cn ); 1147 KOListViewItem* ci = (KOListViewItem*)( cn );
1147 if ( ci ){ 1148 if ( ci ){
1148 //emit showIncidence( ci->data()); 1149 //emit showIncidence( ci->data());
1149 cn = cn->nextSibling(); 1150 cn = cn->nextSibling();
1150 if ( cn ) { 1151 if ( cn ) {
1151 setCurrentItem ( cn ); 1152 setCurrentItem ( cn );
1152 ensureItemVisible ( cn ); 1153 ensureItemVisible ( cn );
1153 } 1154 }
1154 emit showIncidence( ci->data()); 1155 emit showIncidence( ci->data());
1155 } 1156 }
1156 } 1157 }
1157 e->accept(); 1158 e->accept();
1158 } 1159 }
1159 break; 1160 break;
1160 case Qt::Key_Return: 1161 case Qt::Key_Return:
1161 case Qt::Key_Enter: 1162 case Qt::Key_Enter:
1162 { 1163 {
1163 QListViewItem* cn; 1164 QListViewItem* cn;
1164 cn = currentItem(); 1165 cn = currentItem();
1165 if ( cn ) { 1166 if ( cn ) {
1166 KOListViewItem* ci = (KOListViewItem*)( cn ); 1167 KOListViewItem* ci = (KOListViewItem*)( cn );
1167 if ( ci ){ 1168 if ( ci ){
1168 if ( e->state() == ShiftButton ) 1169 if ( e->state() == ShiftButton )
1169 ci->setSelected( false ); 1170 ci->setSelected( false );
1170 else 1171 else
1171 ci->setSelected( true ); 1172 ci->setSelected( true );
1172 cn = cn->nextSibling(); 1173 cn = cn->nextSibling();
1173 if ( cn ) { 1174 if ( cn ) {
1174 setCurrentItem ( cn ); 1175 setCurrentItem ( cn );
1175 ensureItemVisible ( cn ); 1176 ensureItemVisible ( cn );
1176 } 1177 }
1177 } 1178 }
1178 } 1179 }
1179 e->accept(); 1180 e->accept();
1180 } 1181 }
1181 break; 1182 break;
1182 default: 1183 default:
1183 e->ignore(); 1184 e->ignore();
1184 } 1185 }
1185} 1186}
1186KOListViewListView::KOListViewListView(KOListView * lv ) 1187KOListViewListView::KOListViewListView(KOListView * lv )
1187 : KListView( lv, "kolistlistview", false ) 1188 : KListView( lv, "kolistlistview", false )
1188{ 1189{
1189 mYMousePos = 0; 1190 mYMousePos = 0;
1190 mPopupTimer = new QTimer(this); 1191 mPopupTimer = new QTimer(this);
1191 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1192 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1192#ifndef DESKTOP_VERSION 1193#ifndef DESKTOP_VERSION
1193 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1194 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1194#endif 1195#endif
1195 setSelectionMode( QListView::Multi ); 1196 setSelectionMode( QListView::Multi );
1196 setMultiSelection( true); 1197 setMultiSelection( true);
1197} 1198}
1199bool KOListViewListView::hasMultiSelection(QListViewItem* item)
1200{
1201 int selCount = 0;
1202 QListViewItem *qitem = firstChild ();
1203 while ( qitem ) {
1204 if ( qitem->isSelected() && item != qitem )
1205 return true;
1206 qitem = qitem->nextSibling();
1207 }
1208 return false;
1209}
1198void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1210void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1199{ 1211{
1200 if (!e) return; 1212 if (!e) return;
1201 QPoint vp = contentsToViewport(e->pos()); 1213 QPoint vp = contentsToViewport(e->pos());
1202 QListViewItem *item = itemAt(vp); 1214 QListViewItem *item = itemAt(vp);
1203 if (!item) { 1215 if (!item) {
1204 emit newEvent(); 1216 emit newEvent();
1205 return; 1217 return;
1206 } 1218 }
1207 KListView::contentsMouseDoubleClickEvent(e); 1219 KListView::contentsMouseDoubleClickEvent(e);
1208} 1220}
1209#if 0 1221#if 0
1210void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1222void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1211{ 1223{
1212 //qDebug("contentsMousePressEvent++++ "); 1224 //qDebug("contentsMousePressEvent++++ ");
1213 KListView::contentsMousePressEvent( e ); 1225 KListView::contentsMousePressEvent( e );
1214 if ( e->button() == RightButton ) { 1226 if ( e->button() == RightButton ) {
1215 QListViewItem* ci = currentItem(); 1227 QListViewItem* ci = currentItem();
1216 clearSelection () ; 1228 clearSelection () ;
1217 if ( ci ) 1229 if ( ci )
1218 ci->setSelected( true ); 1230 ci->setSelected( true );
1219 } 1231 }
1220} 1232}
1221void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1233void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1222{ 1234{
1223 KListView::contentsMouseReleaseEvent(e); 1235 KListView::contentsMouseReleaseEvent(e);
1224} 1236}
1225void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1237void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1226{ 1238{
1227 KListView::contentsMouseMoveEvent(e); 1239 KListView::contentsMouseMoveEvent(e);
1228} 1240}
1229#endif 1241#endif
1230void KOListViewListView::popupMenu() 1242void KOListViewListView::popupMenu()
1231{ 1243{
1232 mPopupTimer->stop(); 1244 mPopupTimer->stop();
1233 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1245 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1234 QApplication::postEvent( this->viewport(), e ); 1246 QApplication::postEvent( this->viewport(), e );
1235 1247
1236} 1248}
1237void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1249void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1238{ 1250{
1239 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); 1251 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y());
1240 mYMousePos = mapToGlobal( (e->pos())).y(); 1252 mYMousePos = mapToGlobal( (e->pos())).y();
1241 if ( e->button() == LeftButton ) { 1253 if ( e->button() == LeftButton ) {
1242 mPopupTimer->start( 600 ); 1254 mPopupTimer->start( 600 );
1243 mEventPos = contentsToViewport(e->pos()); 1255 mEventPos = contentsToViewport(e->pos());
1244 mEventGlobalPos = e->globalPos(); 1256 mEventGlobalPos = e->globalPos();
1245 } 1257 }
1246 KListView::contentsMousePressEvent( e ); 1258 KListView::contentsMousePressEvent( e );
1247 if ( e->button() == RightButton ) { 1259 if ( e->button() == RightButton ) {
1248 QListViewItem* ci = currentItem(); 1260 QListViewItem* ci = currentItem();
1249 //clearSelection(); 1261 //clearSelection();
1250 if ( ci ) 1262 if ( ci )
1251 ci->setSelected( true ); 1263 ci->setSelected( true );
1252 } 1264 }
1253} 1265}
1254void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1266void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1255{ 1267{
1256 mPopupTimer->stop(); 1268 mPopupTimer->stop();
1257 KListView::contentsMouseReleaseEvent(e); 1269 KListView::contentsMouseReleaseEvent(e);
1258} 1270}
1259void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1271void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1260{ 1272{
1261 // qDebug("contentsMouseMoveEv....... "); 1273 // qDebug("contentsMouseMoveEv....... ");
1262 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1274 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1263 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1275 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1264 if ( diff < 0 ) diff = -diff; 1276 if ( diff < 0 ) diff = -diff;
1265 if ( diff > 15 ) 1277 if ( diff > 15 )
1266 mPopupTimer->stop(); 1278 mPopupTimer->stop();
1267 else { 1279 else {
1268 mEventPos = contentsToViewport(e->pos()); 1280 mEventPos = contentsToViewport(e->pos());
1269 mEventGlobalPos = e->globalPos(); 1281 mEventGlobalPos = e->globalPos();
1270 } 1282 }
1271 KListView::contentsMouseMoveEvent(e); 1283 KListView::contentsMouseMoveEvent(e);
1272} 1284}
1273 1285
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index 2051d60..dee69f6 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -1,312 +1,313 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
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#ifndef _KOLISTVIEW_H 24#ifndef _KOLISTVIEW_H
25#define _KOLISTVIEW_H 25#define _KOLISTVIEW_H
26 26
27#include <qlistview.h> 27#include <qlistview.h>
28#include <qmap.h> 28#include <qmap.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include <klistview.h> 31#include <klistview.h>
32 32
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/incidence.h> 38#include <libkcal/incidence.h>
39 39
40#include "koeventview.h" 40#include "koeventview.h"
41#include "customlistviewitem.h" 41#include "customlistviewitem.h"
42 42
43using namespace KCal; 43using namespace KCal;
44 44
45class KOListViewWhatsThis; 45class KOListViewWhatsThis;
46 46
47#include <qpushbutton.h> 47#include <qpushbutton.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qdialog.h> 49#include <qdialog.h>
50#include <qtimer.h> 50#include <qtimer.h>
51#include <qcombobox.h> 51#include <qcombobox.h>
52#include <qspinbox.h> 52#include <qspinbox.h>
53#include <qtooltip.h> 53#include <qtooltip.h>
54#include <qcheckbox.h> 54#include <qcheckbox.h>
55#include <qhbox.h> 55#include <qhbox.h>
56#include <qlabel.h> 56#include <qlabel.h>
57#include <kiconloader.h> 57#include <kiconloader.h>
58#include "kfiledialog.h" 58#include "kfiledialog.h"
59#include "koprefs.h" 59#include "koprefs.h"
60class KOAlarmPrefs : public QDialog 60class KOAlarmPrefs : public QDialog
61{ 61{
62 Q_OBJECT 62 Q_OBJECT
63 public: 63 public:
64 KOAlarmPrefs( QWidget *par=0, const char *name=0 ) : 64 KOAlarmPrefs( QWidget *par=0, const char *name=0 ) :
65 QDialog( par, name, true ) 65 QDialog( par, name, true )
66 { 66 {
67 setCaption( i18n("Alarm Options") ); 67 setCaption( i18n("Alarm Options") );
68 QVBoxLayout* alarmLayout = new QVBoxLayout( this ); 68 QVBoxLayout* alarmLayout = new QVBoxLayout( this );
69 alarmLayout->setSpacing( 3 ); 69 alarmLayout->setSpacing( 3 );
70 alarmLayout->setMargin( 3 ); 70 alarmLayout->setMargin( 3 );
71 QWidget *parent = this; 71 QWidget *parent = this;
72 mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent); 72 mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent);
73 alarmLayout->addWidget(mAlarmButton); 73 alarmLayout->addWidget(mAlarmButton);
74 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 74 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
75 mAlarmTimeEdit->setValue( 15 ); 75 mAlarmTimeEdit->setValue( 15 );
76 alarmLayout->addWidget(mAlarmTimeEdit); 76 alarmLayout->addWidget(mAlarmTimeEdit);
77 mAlarmIncrCombo = new QComboBox(false, parent); 77 mAlarmIncrCombo = new QComboBox(false, parent);
78 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 78 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
79 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 79 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
80 mAlarmIncrCombo->insertItem(i18n("day(s)")); 80 mAlarmIncrCombo->insertItem(i18n("day(s)"));
81 alarmLayout->addWidget(mAlarmIncrCombo); 81 alarmLayout->addWidget(mAlarmIncrCombo);
82 QHBox * hb = new QHBox ( parent ); 82 QHBox * hb = new QHBox ( parent );
83 alarmLayout->addWidget(hb); 83 alarmLayout->addWidget(hb);
84 mAlarmSoundButton = new QPushButton(hb); 84 mAlarmSoundButton = new QPushButton(hb);
85 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 85 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
86 mAlarmSoundButton->setToggleButton(true); 86 mAlarmSoundButton->setToggleButton(true);
87 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 87 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
88 mAlarmProgramButton = new QPushButton(hb); 88 mAlarmProgramButton = new QPushButton(hb);
89 mAlarmProgramButton->setPixmap(SmallIcon("run")); 89 mAlarmProgramButton->setPixmap(SmallIcon("run"));
90 mAlarmProgramButton->setToggleButton(true); 90 mAlarmProgramButton->setToggleButton(true);
91 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 91 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
92 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 92 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
93 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 93 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
94 mAlarmLabel = new QLabel( this ); 94 mAlarmLabel = new QLabel( this );
95 alarmLayout->addWidget( mAlarmLabel ); 95 alarmLayout->addWidget( mAlarmLabel );
96 mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) ); 96 mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) );
97 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 97 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
98 mAlarmSoundButton->setOn( true ); 98 mAlarmSoundButton->setOn( true );
99 QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this ); 99 QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this );
100 alarmLayout->addWidget( ok ); 100 alarmLayout->addWidget( ok );
101 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 101 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
102 alarmLayout->addWidget( cancel ); 102 alarmLayout->addWidget( cancel );
103 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 103 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
104 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 104 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
105 resize( 200, 200 ); 105 resize( 200, 200 );
106 106
107 } 107 }
108 108
109 109
110 110
111 QString mAlarmSound, mAlarmProgram ; 111 QString mAlarmSound, mAlarmProgram ;
112 QCheckBox* mAlarmButton; 112 QCheckBox* mAlarmButton;
113 QSpinBox* mAlarmTimeEdit; 113 QSpinBox* mAlarmTimeEdit;
114 QLabel* mAlarmLabel; 114 QLabel* mAlarmLabel;
115 QComboBox* mAlarmIncrCombo ; 115 QComboBox* mAlarmIncrCombo ;
116 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; 116 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton;
117private slots: 117private slots:
118 118
119void pickAlarmSound() 119void pickAlarmSound()
120{ 120{
121 //QString prefix = mAlarmSound; 121 //QString prefix = mAlarmSound;
122 if (!mAlarmSoundButton->isOn()) { 122 if (!mAlarmSoundButton->isOn()) {
123 //mAlarmSound = ""; 123 //mAlarmSound = "";
124 QToolTip::remove(mAlarmSoundButton); 124 QToolTip::remove(mAlarmSoundButton);
125 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 125 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
126 mAlarmProgramButton->setOn(true); 126 mAlarmProgramButton->setOn(true);
127 mAlarmSoundButton->setOn(false); 127 mAlarmSoundButton->setOn(false);
128 } else { 128 } else {
129 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 129 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
130 i18n("*.wav|Wav Files"), 0)); 130 i18n("*.wav|Wav Files"), 0));
131 if (!fileName.isEmpty()) { 131 if (!fileName.isEmpty()) {
132 mAlarmSound = fileName; 132 mAlarmSound = fileName;
133 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 133 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
134 QToolTip::remove(mAlarmSoundButton); 134 QToolTip::remove(mAlarmSoundButton);
135 QString dispStr = i18n("Playing '%1'").arg(fileName); 135 QString dispStr = i18n("Playing '%1'").arg(fileName);
136 QToolTip::add(mAlarmSoundButton, dispStr); 136 QToolTip::add(mAlarmSoundButton, dispStr);
137 mAlarmProgramButton->setOn(false); 137 mAlarmProgramButton->setOn(false);
138 mAlarmSoundButton->setOn(true); 138 mAlarmSoundButton->setOn(true);
139 } else { 139 } else {
140 mAlarmProgramButton->setOn(true); 140 mAlarmProgramButton->setOn(true);
141 mAlarmSoundButton->setOn(false); 141 mAlarmSoundButton->setOn(false);
142 142
143 } 143 }
144 } 144 }
145}; 145};
146 146
147void pickAlarmProgram() 147void pickAlarmProgram()
148{ 148{
149 if (!mAlarmProgramButton->isOn()) { 149 if (!mAlarmProgramButton->isOn()) {
150 //mAlarmProgram = ""; 150 //mAlarmProgram = "";
151 QToolTip::remove(mAlarmProgramButton); 151 QToolTip::remove(mAlarmProgramButton);
152 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 152 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
153 mAlarmProgramButton->setOn(false); 153 mAlarmProgramButton->setOn(false);
154 mAlarmSoundButton->setOn(true); 154 mAlarmSoundButton->setOn(true);
155 } else { 155 } else {
156 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); 156 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0));
157 if (!fileName.isEmpty()) { 157 if (!fileName.isEmpty()) {
158 mAlarmProgram = fileName; 158 mAlarmProgram = fileName;
159 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 159 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
160 QToolTip::remove(mAlarmProgramButton); 160 QToolTip::remove(mAlarmProgramButton);
161 QString dispStr = i18n("Running '%1'").arg(fileName); 161 QString dispStr = i18n("Running '%1'").arg(fileName);
162 QToolTip::add(mAlarmProgramButton, dispStr); 162 QToolTip::add(mAlarmProgramButton, dispStr);
163 mAlarmSoundButton->setOn(false); 163 mAlarmSoundButton->setOn(false);
164 mAlarmProgramButton->setOn(true); 164 mAlarmProgramButton->setOn(true);
165 } else { 165 } else {
166 mAlarmProgramButton->setOn(false); 166 mAlarmProgramButton->setOn(false);
167 mAlarmSoundButton->setOn(true); 167 mAlarmSoundButton->setOn(true);
168 } 168 }
169 } 169 }
170}; 170};
171 171
172}; 172};
173 173
174 174
175 175
176 176
177 177
178 178
179 179
180typedef CustomListViewItem<Incidence *> KOListViewItem; 180typedef CustomListViewItem<Incidence *> KOListViewItem;
181 181
182/** 182/**
183 This class provides the initialisation of a KOListViewItem for calendar 183 This class provides the initialisation of a KOListViewItem for calendar
184 components using the Incidence::Visitor. 184 components using the Incidence::Visitor.
185*/ 185*/
186class ListItemVisitor : public Incidence::Visitor 186class ListItemVisitor : public Incidence::Visitor
187{ 187{
188 public: 188 public:
189 ListItemVisitor(KOListViewItem *, QDate d); 189 ListItemVisitor(KOListViewItem *, QDate d);
190 ~ListItemVisitor(); 190 ~ListItemVisitor();
191 191
192 bool visit(Event *); 192 bool visit(Event *);
193 bool visit(Todo *); 193 bool visit(Todo *);
194 bool visit(Journal *); 194 bool visit(Journal *);
195 195
196 private: 196 private:
197 KOListViewItem *mItem; 197 KOListViewItem *mItem;
198 QDate mDate; 198 QDate mDate;
199}; 199};
200 200
201/** 201/**
202 This class provides a multi-column list view of events. It can 202 This class provides a multi-column list view of events. It can
203 display events from one particular day or several days, it doesn't 203 display events from one particular day or several days, it doesn't
204 matter. To use a view that only handles one day at a time, use 204 matter. To use a view that only handles one day at a time, use
205 KODayListView. 205 KODayListView.
206 206
207 @short multi-column list view of various events. 207 @short multi-column list view of various events.
208 @author Preston Brown <pbrown@kde.org> 208 @author Preston Brown <pbrown@kde.org>
209 @see KOBaseView, KODayListView 209 @see KOBaseView, KODayListView
210*/ 210*/
211class KOListView; 211class KOListView;
212 212
213class KOListViewListView : public KListView 213class KOListViewListView : public KListView
214{ 214{
215 Q_OBJECT 215 Q_OBJECT
216 public: 216 public:
217 KOListViewListView(KOListView * lv ); 217 KOListViewListView(KOListView * lv );
218 bool hasMultiSelection(QListViewItem*);
218 signals: 219 signals:
219 void newEvent(); 220 void newEvent();
220 void showIncidence( Incidence* ); 221 void showIncidence( Incidence* );
221 public slots: 222 public slots:
222 void popupMenu(); 223 void popupMenu();
223 private: 224 private:
224 QPoint mEventPos; 225 QPoint mEventPos;
225 QPoint mEventGlobalPos; 226 QPoint mEventGlobalPos;
226 QTimer* mPopupTimer; 227 QTimer* mPopupTimer;
227 int mYMousePos; 228 int mYMousePos;
228 void keyPressEvent ( QKeyEvent * ) ; 229 void keyPressEvent ( QKeyEvent * ) ;
229 void contentsMouseDoubleClickEvent(QMouseEvent *e); 230 void contentsMouseDoubleClickEvent(QMouseEvent *e);
230 void contentsMousePressEvent(QMouseEvent *e); 231 void contentsMousePressEvent(QMouseEvent *e);
231 void contentsMouseReleaseEvent(QMouseEvent *e); 232 void contentsMouseReleaseEvent(QMouseEvent *e);
232 void contentsMouseMoveEvent(QMouseEvent *e); 233 void contentsMouseMoveEvent(QMouseEvent *e);
233 bool mMouseDown; 234 bool mMouseDown;
234}; 235};
235 236
236class KOListView : public KOEventView 237class KOListView : public KOEventView
237{ 238{
238 Q_OBJECT 239 Q_OBJECT
239 public: 240 public:
240 KOListView(Calendar *calendar, QWidget *parent = 0, 241 KOListView(Calendar *calendar, QWidget *parent = 0,
241 const char *name = 0); 242 const char *name = 0);
242 ~KOListView(); 243 ~KOListView();
243 244
244 virtual int maxDatesHint(); 245 virtual int maxDatesHint();
245 virtual int currentDateCount(); 246 virtual int currentDateCount();
246 virtual QPtrList<Incidence> selectedIncidences(); 247 virtual QPtrList<Incidence> selectedIncidences();
247 virtual DateList selectedDates(); 248 virtual DateList selectedDates();
248 249
249 void showDates(bool show); 250 void showDates(bool show);
250 Incidence* currentItem(); 251 Incidence* currentItem();
251 void addTodos(QPtrList<Todo> eventList); 252 void addTodos(QPtrList<Todo> eventList);
252 void addJournals(QPtrList<Journal> eventList); 253 void addJournals(QPtrList<Journal> eventList);
253 virtual void printPreview(CalPrinter *calPrinter, 254 virtual void printPreview(CalPrinter *calPrinter,
254 const QDate &, const QDate &); 255 const QDate &, const QDate &);
255 256
256 void readSettings(KConfig *config, QString setting = "KOListView Layout"); 257 void readSettings(KConfig *config, QString setting = "KOListView Layout");
257 void writeSettings(KConfig *config, QString setting = "KOListView Layout"); 258 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
258 void updateList(); 259 void updateList();
259 void setStartDate(const QDate &start); 260 void setStartDate(const QDate &start);
260 int count(); 261 int count();
261 QString getWhatsThisText(QPoint p); 262 QString getWhatsThisText(QPoint p);
262 signals: 263 signals:
263 void signalNewEvent(); 264 void signalNewEvent();
264 void beamIncidenceList(QPtrList<Incidence>); 265 void beamIncidenceList(QPtrList<Incidence>);
265 266
266 public slots: 267 public slots:
267 void resetFocus(); 268 void resetFocus();
268 virtual void updateView(); 269 virtual void updateView();
269 virtual void showDates(const QDate &start, const QDate &end); 270 virtual void showDates(const QDate &start, const QDate &end);
270 virtual void showEvents(QPtrList<Event> eventList); 271 virtual void showEvents(QPtrList<Event> eventList);
271 void clearSelection(); 272 void clearSelection();
272 void allSelection(); 273 void allSelection();
273 274
274 void clear(); 275 void clear();
275 void beamDone( Ir *ir ); 276 void beamDone( Ir *ir );
276 void showDates(); 277 void showDates();
277 void hideDates(); 278 void hideDates();
278 void deleteAll(); 279 void deleteAll();
279 void saveToFile(); 280 void saveToFile();
280 void saveToFileVCS(); 281 void saveToFileVCS();
281 void saveDescriptionToFile(); 282 void saveDescriptionToFile();
282 void beamSelected(); 283 void beamSelected();
283 void updateConfig(); 284 void updateConfig();
284 void addCat(); 285 void addCat();
285 void setCat(); 286 void setCat();
286 void setAlarm(); 287 void setAlarm();
287 void setCategories( bool removeOld ); 288 void setCategories( bool removeOld );
288 void changeEventDisplay(Event *, int); 289 void changeEventDisplay(Event *, int);
289 290
290 void defaultItemAction(QListViewItem *item); 291 void defaultItemAction(QListViewItem *item);
291 void popupMenu(QListViewItem *item,const QPoint &,int); 292 void popupMenu(QListViewItem *item,const QPoint &,int);
292 293
293 protected slots: 294 protected slots:
294 void processSelectionChange(QListViewItem *); 295 void processSelectionChange(QListViewItem *);
295 296
296 protected: 297 protected:
297 void writeToFile( bool iCal ); 298 void writeToFile( bool iCal );
298 void addEvents(QPtrList<Event> eventList); 299 void addEvents(QPtrList<Event> eventList);
299 void addIncidence(Incidence *); 300 void addIncidence(Incidence *);
300 KOListViewItem *getItemForEvent(Event *event); 301 KOListViewItem *getItemForEvent(Event *event);
301 302
302 private: 303 private:
303 KOListViewWhatsThis *mKOListViewWhatsThis; 304 KOListViewWhatsThis *mKOListViewWhatsThis;
304 KOListViewListView *mListView; 305 KOListViewListView *mListView;
305 KOEventPopupMenu *mPopupMenu; 306 KOEventPopupMenu *mPopupMenu;
306 KOListViewItem *mActiveItem; 307 KOListViewItem *mActiveItem;
307 QDict<Incidence> mUidDict; 308 QDict<Incidence> mUidDict;
308 QDate mStartDate; 309 QDate mStartDate;
309 void keyPressEvent ( QKeyEvent * ) ; 310 void keyPressEvent ( QKeyEvent * ) ;
310}; 311};
311 312
312#endif 313#endif