summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventpopupmenu.cpp173
-rw-r--r--korganizer/koeventpopupmenu.h3
-rw-r--r--korganizer/kolistview.cpp20
-rw-r--r--korganizer/searchdialog.cpp4
4 files changed, 121 insertions, 79 deletions
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp
index 90caaf4..41d331a 100644
--- a/korganizer/koeventpopupmenu.cpp
+++ b/korganizer/koeventpopupmenu.cpp
@@ -1,168 +1,195 @@
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#include "koprefs.h" 33#include "koprefs.h"
34 34
35KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu() 35KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu()
36{ 36{
37 mCurrentIncidence = 0; 37 mCurrentIncidence = 0;
38 mHasAdditionalItems = false; 38 mHasAdditionalItems = false;
39 39
40 40
41 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow()))); 41 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow())));
42 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit()))); 42 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
43 mEditOnlyItems.append(insertItem (i18n("&Delete"), 43 mEditOnlyItems.append(insertItem (i18n("&Delete"),
44 this,SLOT(popupDelete()))); 44 this,SLOT(popupDelete())));
45 mEditOnlyItems.append(insertItem (i18n("&Clone..."), 45 mEditOnlyItems.append(insertItem (i18n("&Clone..."),
46 this,SLOT(popupClone()))); 46 this,SLOT(popupClone())));
47 mEditOnlyItems.append(insertItem (i18n("&Move..."), 47 mEditOnlyItems.append(insertItem (i18n("&Move..."),
48 this,SLOT(popupMove()))); 48 this,SLOT(popupMove())));
49#ifndef DESKTOP_VERSION 49#ifndef DESKTOP_VERSION
50 mEditOnlyItems.append(insertItem (i18n("&Beam..."), 50 mEditOnlyItems.append(insertItem (i18n("&Beam..."),
51 this,SLOT(popupBeam()))); 51 this,SLOT(popupBeam())));
52#endif 52#endif
53 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), 53 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"),
54 this,SLOT(popupCancel()))); 54 this,SLOT(popupCancel())));
55 isDisabled = false; 55 isDisabled = false;
56 mCatPopup = new QPopupMenu ( this ); 56 mCatPopup = new QPopupMenu ( this );
57 mCatPopup->setCheckable (true); 57 mCatPopup->setCheckable (true);
58 connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup())); 58 connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup()));
59 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int ))); 59 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int )));
60 mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup )); 60 mCalPopup = new QPopupMenu ( this );
61 QValueList<int>::Iterator it; 61 mCalPopup->setCheckable (true);
62 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 62 connect(mCalPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCalPopup()));
63 mSingleOnlyItems.append(*it); 63 connect(mCalPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCalPopup( int )));
64 } 64 mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup ));
65 mEditOnlyItems.append(insertItem (i18n("Calendar"),mCalPopup ));
66 QValueList<int>::Iterator it;
67 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
68 mSingleOnlyItems.append(*it);
69 }
65 70
66} 71}
67void KOEventPopupMenu::enableDefault( bool enable ) 72void KOEventPopupMenu::enableDefault( bool enable )
68{ 73{
69 isDisabled = !enable; 74 isDisabled = !enable;
70 QValueList<int>::Iterator it; 75 QValueList<int>::Iterator it;
71 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) { 76 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) {
72 setItemEnabled(*it,enable); 77 setItemEnabled(*it,enable);
73 } 78 }
74 79
75} 80}
76 81
82void KOEventPopupMenu::fillCalPopup() // CAL
83{
84 mCalPopup->clear();
85 if (!mCurrentIncidence) return;
86 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
87 while ( kkf ) {
88 int index = mCalPopup->insertItem( kkf->mName, kkf->mCalNumber);
89 if ( kkf->mErrorOnLoad || kkf->isReadOnly )
90 mCalPopup->setItemEnabled( index, false );
91 mCalPopup->setItemChecked (index, kkf->mCalNumber == mCurrentIncidence->calID());
92 kkf = KOPrefs::instance()->mCalendars.next();
93 }
94}
95void KOEventPopupMenu::computeCalPopup( int index ) // CAL
96{
97 if (!mCurrentIncidence) return;
98 mCurrentIncidence->setCalID( index );
99 emit categoryChanged( mCurrentIncidence );
100}
77void KOEventPopupMenu::fillCatPopup() 101void KOEventPopupMenu::fillCatPopup()
78{ 102{
79 mCatPopup->clear(); 103 mCatPopup->clear();
104 if (!mCurrentIncidence) return;
80 QStringList checkedCategories = mCurrentIncidence->categories(); 105 QStringList checkedCategories = mCurrentIncidence->categories();
81 int index = 0; 106 int index = 0;
82 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 107 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
83 it != KOPrefs::instance()->mCustomCategories.end (); 108 it != KOPrefs::instance()->mCustomCategories.end ();
84 ++it) { 109 ++it) {
85 mCatPopup->insertItem (*it, index ); 110 mCatPopup->insertItem (*it, index );
86 if (checkedCategories.find (*it) != checkedCategories.end ()) { 111 if (checkedCategories.find (*it) != checkedCategories.end ()) {
87 mCatPopup->setItemChecked (index, true); 112 mCatPopup->setItemChecked (index, true);
88 } 113 }
89 ++index; 114 ++index;
90 } 115 }
91} 116}
92void KOEventPopupMenu::computeCatPopup( int index ) 117void KOEventPopupMenu::computeCatPopup( int index )
93{ 118{
119 if (!mCurrentIncidence) return;
94 QStringList categories = mCurrentIncidence->categories(); 120 QStringList categories = mCurrentIncidence->categories();
95 QString colcat = categories.first(); 121 QString colcat = categories.first();
96 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) 122 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
97 categories.remove (KOPrefs::instance()->mCustomCategories[index]); 123 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
98 else 124 else
99 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); 125 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
100 categories.sort (); 126 categories.sort ();
101 if ( !colcat.isEmpty() ) { 127 if ( !colcat.isEmpty() ) {
102 if ( categories.find ( colcat ) != categories.end () ) { 128 if ( categories.find ( colcat ) != categories.end () ) {
103 categories.remove( colcat ); 129 categories.remove( colcat );
104 categories.prepend( colcat ); 130 categories.prepend( colcat );
105 } 131 }
106 } 132 }
107 mCurrentIncidence->setCategories( categories ); 133 mCurrentIncidence->setCategories( categories );
108 emit categoryChanged( mCurrentIncidence ); 134 emit categoryChanged( mCurrentIncidence );
109} 135}
110void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) 136void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
111{ 137{
112 mCurrentIncidence = incidence; 138 if ( !incidence) return;
139 mCurrentIncidence = incidence;
113 140
114 if (mCurrentIncidence) { 141 if (mCurrentIncidence) {
115 // Enable/Disabled menu items only valid for editable events. 142 // Enable/Disabled menu items only valid for editable events.
116 if ( !isDisabled ) { 143 if ( !isDisabled ) {
117 QValueList<int>::Iterator it; 144 QValueList<int>::Iterator it;
118 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 145 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
119 setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); 146 setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
120 } 147 }
121 } 148 }
122 popup(QCursor::pos()); 149 popup(QCursor::pos());
123 } 150 }
124} 151}
125 152
126void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, 153void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
127 const QObject *receiver, const char *member, 154 const QObject *receiver, const char *member,
128 bool editOnly) 155 bool editOnly)
129{ 156{
130 if (!mHasAdditionalItems) { 157 if (!mHasAdditionalItems) {
131 mHasAdditionalItems = true; 158 mHasAdditionalItems = true;
132 insertSeparator(); 159 insertSeparator();
133 } 160 }
134 int id = insertItem(icon,text,receiver,member); 161 int id = insertItem(icon,text,receiver,member);
135 if (editOnly) mEditOnlyItems.append(id); 162 if (editOnly) mEditOnlyItems.append(id);
136} 163}
137 164
138void KOEventPopupMenu::popupShow() 165void KOEventPopupMenu::popupShow()
139{ 166{
140 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence); 167 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
141} 168}
142 169
143void KOEventPopupMenu::popupEdit() 170void KOEventPopupMenu::popupEdit()
144{ 171{
145 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence); 172 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
146} 173}
147 174
148void KOEventPopupMenu::popupDelete() 175void KOEventPopupMenu::popupDelete()
149{ 176{
150 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence); 177 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
151} 178}
152void KOEventPopupMenu::popupClone() 179void KOEventPopupMenu::popupClone()
153{ 180{
154 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence); 181 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence);
155} 182}
156void KOEventPopupMenu::popupCancel() 183void KOEventPopupMenu::popupCancel()
157{ 184{
158 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence); 185 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence);
159} 186}
160void KOEventPopupMenu::popupMove() 187void KOEventPopupMenu::popupMove()
161{ 188{
162 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence); 189 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence);
163} 190}
164 191
165void KOEventPopupMenu::popupBeam() 192void KOEventPopupMenu::popupBeam()
166{ 193{
167 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence); 194 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence);
168} 195}
diff --git a/korganizer/koeventpopupmenu.h b/korganizer/koeventpopupmenu.h
index 3d8b595..e28745b 100644
--- a/korganizer/koeventpopupmenu.h
+++ b/korganizer/koeventpopupmenu.h
@@ -1,80 +1,83 @@
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 void enableDefault( bool );
48 48
49 protected slots: 49 protected slots:
50 void popupShow(); 50 void popupShow();
51 void popupEdit(); 51 void popupEdit();
52 void popupDelete(); 52 void popupDelete();
53 void popupClone(); 53 void popupClone();
54 void popupCancel(); 54 void popupCancel();
55 void popupMove(); 55 void popupMove();
56 void popupBeam(); 56 void popupBeam();
57 void fillCatPopup(); 57 void fillCatPopup();
58 void computeCatPopup( int ); 58 void computeCatPopup( int );
59 void fillCalPopup();
60 void computeCalPopup( int );
59 61
60 signals: 62 signals:
61 void editIncidenceSignal(Incidence *); 63 void editIncidenceSignal(Incidence *);
62 void showIncidenceSignal(Incidence *); 64 void showIncidenceSignal(Incidence *);
63 void deleteIncidenceSignal(Incidence *); 65 void deleteIncidenceSignal(Incidence *);
64 void cloneIncidenceSignal(Incidence *); 66 void cloneIncidenceSignal(Incidence *);
65 void cancelIncidenceSignal(Incidence *); 67 void cancelIncidenceSignal(Incidence *);
66 void moveIncidenceSignal(Incidence *); 68 void moveIncidenceSignal(Incidence *);
67 void beamIncidenceSignal(Incidence *); 69 void beamIncidenceSignal(Incidence *);
68 void categoryChanged( Incidence * ); 70 void categoryChanged( Incidence * );
69 71
70 private: 72 private:
71 Incidence *mCurrentIncidence; 73 Incidence *mCurrentIncidence;
72 74
73 bool mHasAdditionalItems; 75 bool mHasAdditionalItems;
74 QValueList<int> mEditOnlyItems; 76 QValueList<int> mEditOnlyItems;
75 QValueList<int> mSingleOnlyItems; 77 QValueList<int> mSingleOnlyItems;
76 bool isDisabled; 78 bool isDisabled;
77 QPopupMenu *mCatPopup; 79 QPopupMenu *mCatPopup;
80 QPopupMenu *mCalPopup;
78}; 81};
79 82
80#endif 83#endif
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index db3f802..cdcbbf0 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1421 +1,1431 @@
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#include <qpainter.h> 37#include <qpainter.h>
38#include <qpaintdevicemetrics.h> 38#include <qpaintdevicemetrics.h>
39 39
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43#include <kglobal.h> 43#include <kglobal.h>
44 44
45#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
46#include <libkcal/calendar.h> 46#include <libkcal/calendar.h>
47#include <libkcal/calendarlocal.h> 47#include <libkcal/calendarlocal.h>
48#include <libkcal/icalformat.h> 48#include <libkcal/icalformat.h>
49#include <libkcal/vcalformat.h> 49#include <libkcal/vcalformat.h>
50#include <libkcal/recurrence.h> 50#include <libkcal/recurrence.h>
51#include <libkcal/filestorage.h> 51#include <libkcal/filestorage.h>
52#include <libkdepim/categoryselectdialog.h> 52#include <libkdepim/categoryselectdialog.h>
53#include <libkcal/kincidenceformatter.h> 53#include <libkcal/kincidenceformatter.h>
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#else 56#else
57#include <qapplication.h> 57#include <qapplication.h>
58#endif 58#endif
59 59
60#ifndef KORG_NOPRINTER 60#ifndef KORG_NOPRINTER
61#include "calprinter.h" 61#include "calprinter.h"
62#endif 62#endif
63#include "koglobals.h" 63#include "koglobals.h"
64#include "koprefs.h" 64#include "koprefs.h"
65#include "kfiledialog.h" 65#include "kfiledialog.h"
66 66
67#include "kolistview.h" 67#include "kolistview.h"
68#include "koeventviewer.h" 68#include "koeventviewer.h"
69 69
70extern QPixmap* sgListViewCompletedPix[6]; 70extern QPixmap* sgListViewCompletedPix[6];
71 71
72class KOListViewWhatsThis :public QWhatsThis 72class KOListViewWhatsThis :public QWhatsThis
73{ 73{
74public: 74public:
75 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 75 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
76 76
77protected: 77protected:
78 virtual QString text( const QPoint& p) 78 virtual QString text( const QPoint& p)
79 { 79 {
80 return _view->getWhatsThisText(p) ; 80 return _view->getWhatsThisText(p) ;
81 } 81 }
82private: 82private:
83 QWidget* _wid; 83 QWidget* _wid;
84 KOListView * _view; 84 KOListView * _view;
85}; 85};
86 86
87 87
88ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 88ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
89{ 89{
90 mItem = item; 90 mItem = item;
91 mDate = date; 91 mDate = date;
92} 92}
93 93
94ListItemVisitor::~ListItemVisitor() 94ListItemVisitor::~ListItemVisitor()
95{ 95{
96} 96}
97 97
98bool ListItemVisitor::visit(Event *e) 98bool ListItemVisitor::visit(Event *e)
99{ 99{
100 bool ok = false; 100 bool ok = false;
101 QString start, end; 101 QString start, end;
102 QDate ds, de; 102 QDate ds, de;
103 if ( e->doesRecur() ) { 103 if ( e->doesRecur() ) {
104 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 104 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
105 if ( ok ) { 105 if ( ok ) {
106 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 106 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
107 start = KGlobal::locale()->formatDate(ds,true); 107 start = KGlobal::locale()->formatDate(ds,true);
108 de = ds.addDays( days); 108 de = ds.addDays( days);
109 end = KGlobal::locale()->formatDate(de,true); 109 end = KGlobal::locale()->formatDate(de,true);
110 } 110 }
111 111
112 } 112 }
113 if ( ! ok ) { 113 if ( ! ok ) {
114 start =e->dtStartDateStr(); 114 start =e->dtStartDateStr();
115 end = e->dtEndDateStr(); 115 end = e->dtEndDateStr();
116 ds = e->dtStart().date(); 116 ds = e->dtStart().date();
117 de = e->dtEnd().date(); 117 de = e->dtEnd().date();
118 } 118 }
119 mItem->setText(0,e->summary()); 119 mItem->setText(0,e->summary());
120 mItem->setText(1,start); 120 mItem->setText(1,start);
121 if ( e->doesFloat() ) 121 if ( e->doesFloat() )
122 mItem->setText(2,"---"); 122 mItem->setText(2,"---");
123 else 123 else
124 mItem->setText(2,e->dtStartTimeStr()); 124 mItem->setText(2,e->dtStartTimeStr());
125 mItem->setText(3,end); 125 mItem->setText(3,end);
126 if ( e->doesFloat() ) 126 if ( e->doesFloat() )
127 mItem->setText(4,"---"); 127 mItem->setText(4,"---");
128 else 128 else
129 mItem->setText(4,e->dtEndTimeStr()); 129 mItem->setText(4,e->dtEndTimeStr());
130 if ( e->isAlarmEnabled() ) { 130 if ( e->isAlarmEnabled() ) {
131 mItem->setText(5,e->alarms().first()->offsetText() ); 131 mItem->setText(5,e->alarms().first()->offsetText() );
132 } else { 132 } else {
133 mItem->setText(5, i18n("No")); 133 mItem->setText(5, i18n("No"));
134 } 134 }
135 mItem->setText(6, e->recurrence()->recurrenceText()); 135 mItem->setText(6, e->recurrence()->recurrenceText());
136 if( ! e->doesRecur() ) 136 if( ! e->doesRecur() )
137 mItem->setSortKey( 6, "-" ); 137 mItem->setSortKey( 6, "-" );
138 mItem->setText(7,"---"); 138 mItem->setText(7,"---");
139 mItem->setText(8,"---"); 139 mItem->setText(8,"---");
140 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 140 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
141 mItem->setText(10,e->categoriesStr()); 141 mItem->setText(10,e->categoriesStr());
142 mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); 142 mItem->setText(11, KOPrefs::instance()->calName( e->calID() ));
143 143
144 QString key; 144 QString key;
145 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 145 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
146 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 146 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
147 mItem->setSortKey(1,key); 147 mItem->setSortKey(1,key);
148 148
149 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 149 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
150 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 150 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
151 mItem->setSortKey(3,key); 151 mItem->setSortKey(3,key);
152 return true; 152 return true;
153} 153}
154 154
155bool ListItemVisitor::visit(Todo *t) 155bool ListItemVisitor::visit(Todo *t)
156{ 156{
157 mItem->setText(0,t->summary()); 157 mItem->setText(0,t->summary());
158 if ( t->isCompleted() ) { 158 if ( t->isCompleted() ) {
159 mItem->setSortKey(0,"99"+ t->summary().left(10)); 159 mItem->setSortKey(0,"99"+ t->summary().left(10));
160 } else 160 } else
161 mItem->setSortKey(0,QString::number( t->percentComplete() )+ t->summary().left(10)); 161 mItem->setSortKey(0,QString::number( t->percentComplete() )+ t->summary().left(10));
162 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); 162 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20]));
163 if (t->hasStartDate()) { 163 if (t->hasStartDate()) {
164 mItem->setText(1,t->dtStartDateStr()); 164 mItem->setText(1,t->dtStartDateStr());
165 if (t->doesFloat()) { 165 if (t->doesFloat()) {
166 mItem->setText(2,"---"); 166 mItem->setText(2,"---");
167 } else { 167 } else {
168 mItem->setText(2,t->dtStartTimeStr()); 168 mItem->setText(2,t->dtStartTimeStr());
169 } 169 }
170 } else { 170 } else {
171 mItem->setText(1,"---"); 171 mItem->setText(1,"---");
172 mItem->setText(2,"---"); 172 mItem->setText(2,"---");
173 } 173 }
174 mItem->setText(3,"---"); 174 mItem->setText(3,"---");
175 mItem->setText(4,"---"); 175 mItem->setText(4,"---");
176 if ( t->isAlarmEnabled() ) { 176 if ( t->isAlarmEnabled() ) {
177 mItem->setText(5,t->alarms().first()->offsetText() ); 177 mItem->setText(5,t->alarms().first()->offsetText() );
178 } else { 178 } else {
179 mItem->setText(5, i18n("No")); 179 mItem->setText(5, i18n("No"));
180 } 180 }
181 mItem->setText(6, t->recurrence()->recurrenceText()); 181 mItem->setText(6, t->recurrence()->recurrenceText());
182 if( ! t->doesRecur() ) 182 if( ! t->doesRecur() )
183 mItem->setSortKey( 6, "-" ); 183 mItem->setSortKey( 6, "-" );
184 if (t->hasDueDate()) { 184 if (t->hasDueDate()) {
185 mItem->setText(7,t->dtDueDateStr()); 185 mItem->setText(7,t->dtDueDateStr());
186 if (t->doesFloat()) { 186 if (t->doesFloat()) {
187 mItem->setText(8,"---"); 187 mItem->setText(8,"---");
188 } else { 188 } else {
189 mItem->setText(8,t->dtDueTimeStr()); 189 mItem->setText(8,t->dtDueTimeStr());
190 } 190 }
191 } else { 191 } else {
192 mItem->setText(7,"---"); 192 mItem->setText(7,"---");
193 mItem->setText(8,"---"); 193 mItem->setText(8,"---");
194 } 194 }
195 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 195 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
196 mItem->setText(10,t->categoriesStr()); 196 mItem->setText(10,t->categoriesStr());
197 mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); 197 mItem->setText(11, KOPrefs::instance()->calName( t->calID() ));
198 198
199 QString key; 199 QString key;
200 QDate d; 200 QDate d;
201 if (t->hasDueDate()) { 201 if (t->hasDueDate()) {
202 d = t->dtDue().date(); 202 d = t->dtDue().date();
203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
205 mItem->setSortKey(7,key); 205 mItem->setSortKey(7,key);
206 } 206 }
207 if ( t->hasStartDate() ) { 207 if ( t->hasStartDate() ) {
208 d = t->dtStart().date(); 208 d = t->dtStart().date();
209 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 209 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
210 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 210 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
211 mItem->setSortKey(1,key); 211 mItem->setSortKey(1,key);
212 } 212 }
213 return true; 213 return true;
214} 214}
215 215
216bool ListItemVisitor::visit(Journal * j) 216bool ListItemVisitor::visit(Journal * j)
217{ 217{
218 218
219 QString des; 219 QString des;
220 if ( !j->summary().isEmpty() ) { 220 if ( !j->summary().isEmpty() ) {
221 des = j->summary(); 221 des = j->summary();
222 } else { 222 } else {
223 des = j->description().left(30); 223 des = j->description().left(30);
224 des = des.simplifyWhiteSpace (); 224 des = des.simplifyWhiteSpace ();
225 des.replace (QRegExp ("\\n"),"" ); 225 des.replace (QRegExp ("\\n"),"" );
226 des.replace (QRegExp ("\\r"),"" ); 226 des.replace (QRegExp ("\\r"),"" );
227 } 227 }
228 mItem->setText(0,i18n("Journal: ")+des.left(25)); 228 mItem->setText(0,i18n("Journal: ")+des.left(25));
229 mItem->setText(1,j->dtStartDateStr()); 229 mItem->setText(1,j->dtStartDateStr());
230 mItem->setText(2,"---"); 230 mItem->setText(2,"---");
231 mItem->setText(3,"---"); 231 mItem->setText(3,"---");
232 mItem->setText(4,"---"); 232 mItem->setText(4,"---");
233 mItem->setText(5,"---"); 233 mItem->setText(5,"---");
234 mItem->setText(6,"---"); 234 mItem->setText(6,"---");
235 mItem->setText(7,j->dtStartDateStr()); 235 mItem->setText(7,j->dtStartDateStr());
236 mItem->setText(8,"---"); 236 mItem->setText(8,"---");
237 mItem->setText(9,"---"); 237 mItem->setText(9,"---");
238 mItem->setText(10,j->categoriesStr()); 238 mItem->setText(10,j->categoriesStr());
239 mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); 239 mItem->setText(11, KOPrefs::instance()->calName( j->calID() ));
240 240
241 QString key; 241 QString key;
242 QDate d = j->dtStart().date(); 242 QDate d = j->dtStart().date();
243 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 243 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
244 mItem->setSortKey(1,key); 244 mItem->setSortKey(1,key);
245 mItem->setSortKey(7,key); 245 mItem->setSortKey(7,key);
246 246
247 return true; 247 return true;
248} 248}
249 249
250KOListView::KOListView(Calendar *calendar, QWidget *parent, 250KOListView::KOListView(Calendar *calendar, QWidget *parent,
251 const char *name) 251 const char *name)
252 : KOEventView(calendar, parent, name) 252 : KOEventView(calendar, parent, name)
253{ 253{
254 254
255 mActiveItem = 0; 255 mActiveItem = 0;
256 mForceShowCompletedTodos = false; 256 mForceShowCompletedTodos = false;
257 mListView = new KOListViewListView(this); 257 mListView = new KOListViewListView(this);
258 mListView->addColumn(i18n("Summary")); 258 mListView->addColumn(i18n("Summary"));
259 mListView->addColumn(i18n("Start Date")); 259 mListView->addColumn(i18n("Start Date"));
260 mListView->addColumn(i18n("Start Time")); 260 mListView->addColumn(i18n("Start Time"));
261 mListView->addColumn(i18n("End Date")); 261 mListView->addColumn(i18n("End Date"));
262 mListView->addColumn(i18n("End Time")); 262 mListView->addColumn(i18n("End Time"));
263 mListView->addColumn(i18n("Alarm")); // alarm set? 263 mListView->addColumn(i18n("Alarm")); // alarm set?
264 mListView->addColumn(i18n("Recurs")); // recurs? 264 mListView->addColumn(i18n("Recurs")); // recurs?
265 mListView->addColumn(i18n("Due Date")); 265 mListView->addColumn(i18n("Due Date"));
266 mListView->addColumn(i18n("Due Time")); 266 mListView->addColumn(i18n("Due Time"));
267 mListView->addColumn(i18n("Cancelled")); 267 mListView->addColumn(i18n("Cancelled"));
268 mListView->addColumn(i18n("Categories")); 268 mListView->addColumn(i18n("Categories"));
269 mListView->addColumn(i18n("Calendar")); 269 mListView->addColumn(i18n("Calendar"));
270 270
271 mListView->setColumnAlignment(0,AlignLeft); 271 mListView->setColumnAlignment(0,AlignLeft);
272 mListView->setColumnAlignment(1,AlignLeft); 272 mListView->setColumnAlignment(1,AlignLeft);
273 mListView->setColumnAlignment(2,AlignHCenter); 273 mListView->setColumnAlignment(2,AlignHCenter);
274 mListView->setColumnAlignment(3,AlignLeft); 274 mListView->setColumnAlignment(3,AlignLeft);
275 mListView->setColumnAlignment(4,AlignHCenter); 275 mListView->setColumnAlignment(4,AlignHCenter);
276 mListView->setColumnAlignment(5,AlignLeft); 276 mListView->setColumnAlignment(5,AlignLeft);
277 mListView->setColumnAlignment(6,AlignLeft); 277 mListView->setColumnAlignment(6,AlignLeft);
278 mListView->setColumnAlignment(7,AlignLeft); 278 mListView->setColumnAlignment(7,AlignLeft);
279 mListView->setColumnAlignment(8,AlignLeft); 279 mListView->setColumnAlignment(8,AlignLeft);
280 mListView->setColumnAlignment(9,AlignLeft); 280 mListView->setColumnAlignment(9,AlignLeft);
281 mListView->setColumnAlignment(10,AlignLeft); 281 mListView->setColumnAlignment(10,AlignLeft);
282 mListView->setColumnAlignment(11,AlignLeft); 282 mListView->setColumnAlignment(11,AlignLeft);
283 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 283 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
284 284
285 int iii = 0; 285 int iii = 0;
286 for ( iii = 0; iii< 12 ; ++iii ) 286 for ( iii = 0; iii< 12 ; ++iii )
287 mListView->setColumnWidthMode( iii, QListView::Manual ); 287 mListView->setColumnWidthMode( iii, QListView::Manual );
288 288
289 QBoxLayout *layoutTop = new QVBoxLayout(this); 289 QBoxLayout *layoutTop = new QVBoxLayout(this);
290 layoutTop->addWidget(mListView); 290 layoutTop->addWidget(mListView);
291 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 291 mListView->setFont ( KOPrefs::instance()->mListViewFont );
292 mPopupMenu = eventPopup(); 292 mPopupMenu = eventPopup();
293 QPopupMenu* selPopup = new QPopupMenu ( this ); 293 QPopupMenu* selPopup = new QPopupMenu ( this );
294 mPopupMenu->insertSeparator(); 294 mPopupMenu->insertSeparator();
295 295
296 selPopup->insertItem(i18n("All"),this, 296 selPopup->insertItem(i18n("All"),this,
297 SLOT(allSelection())); 297 SLOT(allSelection()));
298 selPopup->insertItem(i18n("None"),this, 298 selPopup->insertItem(i18n("None"),this,
299 SLOT(clearSelection())); 299 SLOT(clearSelection()));
300 selPopup->insertItem(i18n("Delete selected..."),this, 300 selPopup->insertItem(i18n("Delete selected..."),this,
301 SLOT(deleteAll())); 301 SLOT(deleteAll()));
302 mPopupMenu->insertItem(i18n("Selection"), selPopup ); 302 mPopupMenu->insertItem(i18n("Selection"), selPopup );
303 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 303 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
304 i18n("Hide all selected"),this, 304 i18n("Hide all selected"),this,
305 SLOT(hideAll()),true); 305 SLOT(hideAll()),true);
306 306
307 mPopupMenu->insertSeparator(); 307 selPopup->insertSeparator();
308#ifdef DESKTOP_VERSION 308#ifdef DESKTOP_VERSION
309 mPopupMenu->insertSeparator();
309 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 310 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
310 i18n("Print complete list"),this, 311 i18n("Print complete list"),this,
311 SLOT(printList()),true); 312 SLOT(printList()),true);
312 mPopupMenu->insertSeparator();
313#endif 313#endif
314 mCalPopup = new QPopupMenu ( this ); 314 mCalPopup = new QPopupMenu ( this );
315 mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup ); 315 selPopup->insertItem( i18n("Set Calendar"), mCalPopup );
316 316
317 selPopup->insertItem(i18n("Set categories")+"...",this,
318 SLOT(setCat()) );
319 selPopup->insertItem( i18n("Set alarm..."),this,
320 SLOT(setAlarm()));
321#if 0
317 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 322 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
318 i18n("Set categories")+"...",this, 323 i18n("Set categories")+"...",this,
319 SLOT(setCat()),true); 324 SLOT(setCat()),true);
320 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 325 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
321 i18n("Set alarm..."),this, 326 i18n("Set alarm..."),this,
322 SLOT(setAlarm()),true); 327 SLOT(setAlarm()),true);
328#endif
323 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, 329 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this,
324 SLOT( populateCalPopup() )); 330 SLOT( populateCalPopup() ));
325 QObject::connect(mCalPopup,SIGNAL(activated( int )),this, 331 QObject::connect(mCalPopup,SIGNAL(activated( int )),this,
326 SLOT( setCalendar( int ) )); 332 SLOT( setCalendar( int ) ));
327 QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, 333 QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this,
328 SLOT( catChanged( Incidence * ) )); 334 SLOT( catChanged( Incidence * ) ));
329 QPopupMenu * exportPO = new QPopupMenu ( this ); 335 QPopupMenu * exportPO = new QPopupMenu ( this );
330 mPopupMenu->insertItem( i18n("Export"), exportPO ); 336 selPopup->insertItem( i18n("Export"), exportPO );
331 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 337 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
332 SLOT(saveToFile())); 338 SLOT(saveToFile()));
333 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 339 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
334 SLOT(saveToFileVCS())); 340 SLOT(saveToFileVCS()));
335 exportPO->insertItem( i18n("Journal/Details..."),this, 341 exportPO->insertItem( i18n("Journal/Details..."),this,
336 SLOT(saveDescriptionToFile())); 342 SLOT(saveDescriptionToFile()));
337 // mPopupMenu->insertSeparator(); 343 // mPopupMenu->insertSeparator();
338 // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 344 // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
339 // i18n("Add Categ. to selected..."),this, 345 // i18n("Add Categ. to selected..."),this,
340 // SLOT(addCat()),true); 346 // SLOT(addCat()),true);
341 //mPopupMenu->insertSeparator(); 347 //mPopupMenu->insertSeparator();
342#ifndef DESKTOP_VERSION 348#ifndef DESKTOP_VERSION
343 mPopupMenu->insertSeparator(); 349 selPopup->insertSeparator();
350 selPopup->insertItem( i18n("Beam via IR"),this,
351 SLOT(beamSelected()));
352#if 0
344 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 353 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
345 i18n("Beam via IR"),this, 354 i18n("Beam via IR"),this,
346 SLOT(beamSelected()),true); 355 SLOT(beamSelected()),true);
347#endif 356#endif
357#endif
348 /* 358 /*
349 mPopupMenu = new QPopupMenu; 359 mPopupMenu = new QPopupMenu;
350 mPopupMenu->insertItem(i18n("Edit Event"), this, 360 mPopupMenu->insertItem(i18n("Edit Event"), this,
351 SLOT (editEvent())); 361 SLOT (editEvent()));
352 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 362 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
353 SLOT (deleteEvent())); 363 SLOT (deleteEvent()));
354 mPopupMenu->insertSeparator(); 364 mPopupMenu->insertSeparator();
355 mPopupMenu->insertItem(i18n("Show Dates"), this, 365 mPopupMenu->insertItem(i18n("Show Dates"), this,
356 SLOT(showDates())); 366 SLOT(showDates()));
357 mPopupMenu->insertItem(i18n("Hide Dates"), this, 367 mPopupMenu->insertItem(i18n("Hide Dates"), this,
358 SLOT(hideDates())); 368 SLOT(hideDates()));
359 */ 369 */
360 QObject::connect(mListView,SIGNAL( newEvent()), 370 QObject::connect(mListView,SIGNAL( newEvent()),
361 this,SIGNAL(signalNewEvent())); 371 this,SIGNAL(signalNewEvent()));
362 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 372 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
363 this,SLOT(defaultItemAction(QListViewItem *))); 373 this,SLOT(defaultItemAction(QListViewItem *)));
364 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 374 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
365 const QPoint &, int )), 375 const QPoint &, int )),
366 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 376 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
367 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 377 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
368 SLOT(processSelectionChange(QListViewItem *))); 378 SLOT(processSelectionChange(QListViewItem *)));
369 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 379 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
370 SIGNAL(showIncidenceSignal(Incidence *)) ); 380 SIGNAL(showIncidenceSignal(Incidence *)) );
371 381
372 readSettings(KOGlobals::config(),"KOListView Layout"); 382 readSettings(KOGlobals::config(),"KOListView Layout");
373} 383}
374 384
375KOListView::~KOListView() 385KOListView::~KOListView()
376{ 386{
377 delete mPopupMenu; 387 delete mPopupMenu;
378#if QT_VERSION >= 0x030000 388#if QT_VERSION >= 0x030000
379 389
380#else 390#else
381 delete mKOListViewWhatsThis; 391 delete mKOListViewWhatsThis;
382#endif 392#endif
383} 393}
384 394
385void KOListView::catChanged( Incidence* inc) 395void KOListView::catChanged( Incidence* inc)
386{ 396{
387 KOListViewItem* item = getItemForEvent(inc); 397 KOListViewItem* item = getItemForEvent(inc);
388 if (item) { 398 if (item) {
389 ListItemVisitor v(item, mStartDate ); 399 ListItemVisitor v(item, mStartDate );
390 inc->accept(v); 400 inc->accept(v);
391 } 401 }
392} 402}
393QString KOListView::getWhatsThisText(QPoint p) 403QString KOListView::getWhatsThisText(QPoint p)
394{ 404{
395 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 405 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
396 if ( item ) 406 if ( item )
397 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 407 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
398 KOPrefs::instance()->mWTshowDetails, 408 KOPrefs::instance()->mWTshowDetails,
399 KOPrefs::instance()->mWTshowCreated, 409 KOPrefs::instance()->mWTshowCreated,
400 KOPrefs::instance()->mWTshowChanged); 410 KOPrefs::instance()->mWTshowChanged);
401 return i18n("That is the list view" ); 411 return i18n("That is the list view" );
402 412
403} 413}
404 414
405void KOListView::setCalendar( int c ) 415void KOListView::setCalendar( int c )
406{ 416{
407 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 417 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
408 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), 418 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ),
409 i18n("Continue"), i18n("Cancel"), 0, 419 i18n("Continue"), i18n("Cancel"), 0,
410 0, 1 ); 420 0, 1 );
411 if ( result != 0 ) { 421 if ( result != 0 ) {
412 return; 422 return;
413 } 423 }
414 424
415 QPtrList<Incidence> delSel = getSelectedIncidences() ; 425 QPtrList<Incidence> delSel = getSelectedIncidences() ;
416 int icount = delSel.count(); 426 int icount = delSel.count();
417 if ( icount ) { 427 if ( icount ) {
418 Incidence *incidence = delSel.first(); 428 Incidence *incidence = delSel.first();
419 while ( incidence ) { 429 while ( incidence ) {
420 incidence->setCalID( c ); 430 incidence->setCalID( c );
421 KOListViewItem * item = getItemForEvent( incidence ); 431 KOListViewItem * item = getItemForEvent( incidence );
422 if ( item ) { 432 if ( item ) {
423 ListItemVisitor v(item, mStartDate ); 433 ListItemVisitor v(item, mStartDate );
424 incidence->accept(v); 434 incidence->accept(v);
425 } 435 }
426 incidence = delSel.next(); 436 incidence = delSel.next();
427 } 437 }
428 } 438 }
429 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 439 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
430 KopiCalendarFile * cal = calendars.first(); 440 KopiCalendarFile * cal = calendars.first();
431 while ( cal ) { 441 while ( cal ) {
432 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 442 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
433 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 443 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
434 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 444 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
435 if ( cal->isStandard ) 445 if ( cal->isStandard )
436 mCalendar->setDefaultCalendar( cal->mCalNumber ); 446 mCalendar->setDefaultCalendar( cal->mCalNumber );
437 cal = calendars.next(); 447 cal = calendars.next();
438 } 448 }
439 mCalendar->setSyncEventsReadOnly(); 449 mCalendar->setSyncEventsReadOnly();
440 mCalendar->reInitAlarmSettings(); 450 mCalendar->reInitAlarmSettings();
441 451
442} 452}
443void KOListView::populateCalPopup() 453void KOListView::populateCalPopup()
444{ 454{
445 mCalPopup->clear(); 455 mCalPopup->clear();
446 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 456 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
447 while ( kkf ) { 457 while ( kkf ) {
448 int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); 458 int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber);
449 if ( kkf->mErrorOnLoad || kkf->isReadOnly ) 459 if ( kkf->mErrorOnLoad || kkf->isReadOnly )
450 mCalPopup->setItemEnabled( index, false ); 460 mCalPopup->setItemEnabled( index, false );
451 kkf = KOPrefs::instance()->mCalendars.next(); 461 kkf = KOPrefs::instance()->mCalendars.next();
452 } 462 }
453} 463}
454void KOListView::updateList() 464void KOListView::updateList()
455{ 465{
456 // qDebug(" KOListView::updateList() "); 466 // qDebug(" KOListView::updateList() ");
457 467
458} 468}
459 469
460void KOListView::clearList() 470void KOListView::clearList()
461{ 471{
462 clear (); 472 clear ();
463} 473}
464 474
465void KOListView::setCat() 475void KOListView::setCat()
466{ 476{
467 477
468 bool set = true; 478 bool set = true;
469 int result = KMessageBox::warningYesNoCancel(this, 479 int result = KMessageBox::warningYesNoCancel(this,
470 i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), 480 i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"),
471 i18n("Set categories"), 481 i18n("Set categories"),
472 i18n("Add"), 482 i18n("Add"),
473 i18n("Reset")); 483 i18n("Reset"));
474 if (result == KMessageBox::Cancel) return; 484 if (result == KMessageBox::Cancel) return;
475 if (result == KMessageBox::Yes) set = false; 485 if (result == KMessageBox::Yes) set = false;
476 setCategories( set ); 486 setCategories( set );
477} 487}
478 488
479void KOListView::setAlarm() 489void KOListView::setAlarm()
480{ 490{
481 KOAlarmPrefs kap( this); 491 KOAlarmPrefs kap( this);
482 if ( !kap.exec() ) 492 if ( !kap.exec() )
483 return; 493 return;
484 QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos 494 QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos
485 Incidence* inc = delSel.first(); 495 Incidence* inc = delSel.first();
486 int count = 0; 496 int count = 0;
487 while ( inc ) { 497 while ( inc ) {
488 ++count; 498 ++count;
489 if (kap.mAlarmButton->isChecked()) { 499 if (kap.mAlarmButton->isChecked()) {
490 if (inc->alarms().count() == 0) 500 if (inc->alarms().count() == 0)
491 inc->newAlarm(); 501 inc->newAlarm();
492 QPtrList<Alarm> alarms = inc->alarms(); 502 QPtrList<Alarm> alarms = inc->alarms();
493 Alarm *alarm; 503 Alarm *alarm;
494 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 504 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
495 alarm->setEnabled(true); 505 alarm->setEnabled(true);
496 int j = kap.mAlarmTimeEdit->value()* -60; 506 int j = kap.mAlarmTimeEdit->value()* -60;
497 if (kap.mAlarmIncrCombo->currentItem() == 1) 507 if (kap.mAlarmIncrCombo->currentItem() == 1)
498 j = j * 60; 508 j = j * 60;
499 else if (kap.mAlarmIncrCombo->currentItem() == 2) 509 else if (kap.mAlarmIncrCombo->currentItem() == 2)
500 j = j * (60 * 24); 510 j = j * (60 * 24);
501 alarm->setStartOffset( j ); 511 alarm->setStartOffset( j );
502 512
503 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 513 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
504 alarm->setProcedureAlarm(kap.mAlarmProgram); 514 alarm->setProcedureAlarm(kap.mAlarmProgram);
505 } 515 }
506 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 516 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
507 alarm->setAudioAlarm(kap.mAlarmSound); 517 alarm->setAudioAlarm(kap.mAlarmSound);
508 else 518 else
509 alarm->setType(Alarm::Invalid); 519 alarm->setType(Alarm::Invalid);
510 //alarm->setAudioAlarm("default"); 520 //alarm->setAudioAlarm("default");
511 // TODO: Deal with multiple alarms 521 // TODO: Deal with multiple alarms
512 break; // For now, stop after the first alarm 522 break; // For now, stop after the first alarm
513 } 523 }
514 } else { 524 } else {
515 Alarm* alarm = inc->alarms().first(); 525 Alarm* alarm = inc->alarms().first();
516 if ( alarm ) { 526 if ( alarm ) {
517 alarm->setEnabled(false); 527 alarm->setEnabled(false);
518 alarm->setType(Alarm::Invalid); 528 alarm->setType(Alarm::Invalid);
519 } 529 }
520 } 530 }
521 KOListViewItem* item = getItemForEvent(inc); 531 KOListViewItem* item = getItemForEvent(inc);
522 if (item) { 532 if (item) {
523 ListItemVisitor v(item, mStartDate ); 533 ListItemVisitor v(item, mStartDate );
524 inc->accept(v); 534 inc->accept(v);
525 } 535 }
526 inc = delSel.next(); 536 inc = delSel.next();
527 } 537 }
528 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); 538 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) );
529 qDebug("KO: Set alarm for %d items", count); 539 qDebug("KO: Set alarm for %d items", count);
530 calendar()->reInitAlarmSettings(); 540 calendar()->reInitAlarmSettings();
531 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 541 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
532} 542}
533void KOListView::setCategories( bool removeOld ) 543void KOListView::setCategories( bool removeOld )
534{ 544{
535 545
536 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 546 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
537 csd->setColorEnabled(); 547 csd->setColorEnabled();
538 if (! csd->exec()) { 548 if (! csd->exec()) {
539 delete csd; 549 delete csd;
540 return; 550 return;
541 } 551 }
542 QStringList catList = csd->selectedCategories(); 552 QStringList catList = csd->selectedCategories();
543 delete csd; 553 delete csd;
544 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; 554 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
545 Incidence* inc = delSel.first(); 555 Incidence* inc = delSel.first();
546 while ( inc ) { 556 while ( inc ) {
547 if ( removeOld ) { 557 if ( removeOld ) {
548 inc->setCategories( catList, false ); 558 inc->setCategories( catList, false );
549 } else { 559 } else {
550 inc->addCategories( catList, false ); 560 inc->addCategories( catList, false );
551 } 561 }
552 KOListViewItem* item = getItemForEvent(inc); 562 KOListViewItem* item = getItemForEvent(inc);
553 if (item) { 563 if (item) {
554 ListItemVisitor v(item, mStartDate ); 564 ListItemVisitor v(item, mStartDate );
555 inc->accept(v); 565 inc->accept(v);
556 } 566 }
557 inc = delSel.next(); 567 inc = delSel.next();
558 } 568 }
559 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 569 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
560} 570}
561 571
562void KOListView::beamSelected() 572void KOListView::beamSelected()
563{ 573{
564 QPtrList<Incidence> delSel = getSelectedIncidences() ; 574 QPtrList<Incidence> delSel = getSelectedIncidences() ;
565 if ( delSel.count() ) 575 if ( delSel.count() )
566 emit beamIncidenceList( delSel ); 576 emit beamIncidenceList( delSel );
567} 577}
568 578
569void KOListView::saveDescriptionToFile() 579void KOListView::saveDescriptionToFile()
570{ 580{
571 581
572 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 582 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
573 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 583 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
574 i18n("Continue"), i18n("Cancel"), 0, 584 i18n("Continue"), i18n("Cancel"), 0,
575 0, 1 ); 585 0, 1 );
576 if ( result != 0 ) { 586 if ( result != 0 ) {
577 return; 587 return;
578 } 588 }
579 QPtrList<Incidence> delSel = getSelectedIncidences() ; 589 QPtrList<Incidence> delSel = getSelectedIncidences() ;
580 int icount = delSel.count(); 590 int icount = delSel.count();
581 if ( icount ) { 591 if ( icount ) {
582 QString fn = KOPrefs::instance()->mLastSaveFile; 592 QString fn = KOPrefs::instance()->mLastSaveFile;
583 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 593 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
584 594
585 if ( fn == "" ) 595 if ( fn == "" )
586 return; 596 return;
587 QFileInfo info; 597 QFileInfo info;
588 info.setFile( fn ); 598 info.setFile( fn );
589 QString mes; 599 QString mes;
590 bool createbup = true; 600 bool createbup = true;
591 if ( info. exists() ) { 601 if ( info. exists() ) {
592 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 602 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
593 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 603 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
594 i18n("Overwrite!"), i18n("Cancel"), 0, 604 i18n("Overwrite!"), i18n("Cancel"), 0,
595 0, 1 ); 605 0, 1 );
596 if ( result != 0 ) { 606 if ( result != 0 ) {
597 createbup = false; 607 createbup = false;
598 } 608 }
599 } 609 }
600 if ( createbup ) { 610 if ( createbup ) {
601 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 611 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
602 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 612 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
603 Incidence *incidence = delSel.first(); 613 Incidence *incidence = delSel.first();
604 icount = 0; 614 icount = 0;
605 while ( incidence ) { 615 while ( incidence ) {
606 if ( incidence->typeID() == journalID ) { 616 if ( incidence->typeID() == journalID ) {
607 text += "\n************************************\n"; 617 text += "\n************************************\n";
608 if ( !incidence->summary().isEmpty() ) 618 if ( !incidence->summary().isEmpty() )
609 text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); 619 text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false );
610 else 620 else
611 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 621 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
612 if ( !incidence->location().isEmpty() ) 622 if ( !incidence->location().isEmpty() )
613 text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; 623 text +="\n(" + i18n("Location: ") + incidence->location()+ ")";
614 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 624 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
615 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 625 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
616 ++icount; 626 ++icount;
617 627
618 } else { 628 } else {
619 if ( !incidence->description().isEmpty() ) { 629 if ( !incidence->description().isEmpty() ) {
620 text += "\n************************************\n"; 630 text += "\n************************************\n";
621 if ( incidence->typeID() == todoID ) 631 if ( incidence->typeID() == todoID )
622 text += i18n("To-Do: "); 632 text += i18n("To-Do: ");
623 text += incidence->summary(); 633 text += incidence->summary();
624 if ( !incidence->location().isEmpty() ) 634 if ( !incidence->location().isEmpty() )
625 text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; 635 text +="\n(" + i18n("Location: ") + incidence->location()+ ")";
626 if ( incidence->hasStartDate() ) 636 if ( incidence->hasStartDate() )
627 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 637 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
628 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 638 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
629 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 639 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
630 ++icount; 640 ++icount;
631 641
632 } 642 }
633 } 643 }
634 incidence = delSel.next(); 644 incidence = delSel.next();
635 } 645 }
636 QFile file( fn ); 646 QFile file( fn );
637 if (!file.open( IO_WriteOnly ) ) { 647 if (!file.open( IO_WriteOnly ) ) {
638 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 648 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
639 return; 649 return;
640 } 650 }
641 QTextStream ts( &file ); 651 QTextStream ts( &file );
642 ts << text; 652 ts << text;
643 file.close(); 653 file.close();
644 //qDebug("%s ", text.latin1()); 654 //qDebug("%s ", text.latin1());
645 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 655 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
646 KOPrefs::instance()->mLastSaveFile = fn; 656 KOPrefs::instance()->mLastSaveFile = fn;
647 topLevelWidget()->setCaption(mes); 657 topLevelWidget()->setCaption(mes);
648 } 658 }
649 } 659 }
650} 660}
651void KOListView::saveToFileVCS() 661void KOListView::saveToFileVCS()
652{ 662{
653 writeToFile( false ); 663 writeToFile( false );
654} 664}
655void KOListView::saveToFile() 665void KOListView::saveToFile()
656{ 666{
657 writeToFile( true ); 667 writeToFile( true );
658} 668}
659QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) 669QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos )
660{ 670{
661 QPtrList<Incidence> delSel ; 671 QPtrList<Incidence> delSel ;
662 bool addSubTodos = false; 672 bool addSubTodos = false;
663 bool askSubTodos = true; 673 bool askSubTodos = true;
664 QListViewItem *item = mListView->firstChild (); 674 QListViewItem *item = mListView->firstChild ();
665 while ( item ) { 675 while ( item ) {
666 if ( item->isSelected() ) { 676 if ( item->isSelected() ) {
667 Incidence* inc = ((KOListViewItem *)item)->data(); 677 Incidence* inc = ((KOListViewItem *)item)->data();
668 if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { 678 if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) {
669 if ( (inc->typeID() == todoID && includeTodos) || 679 if ( (inc->typeID() == todoID && includeTodos) ||
670 (inc->typeID() == eventID && includeEvents) || 680 (inc->typeID() == eventID && includeEvents) ||
671 (inc->typeID() == journalID && includeJournals) ) { 681 (inc->typeID() == journalID && includeJournals) ) {
672 if ( inc->typeID() == todoID && onlyDueTodos ) { 682 if ( inc->typeID() == todoID && onlyDueTodos ) {
673 if ( ((Todo*)inc)->hasDueDate() ) 683 if ( ((Todo*)inc)->hasDueDate() )
674 delSel.append( inc ); 684 delSel.append( inc );
675 } else 685 } else
676 delSel.append( inc ); 686 delSel.append( inc );
677 687
678 } 688 }
679 } 689 }
680 if ( inc->typeID() == todoID ) { 690 if ( inc->typeID() == todoID ) {
681 Todo * todo = (Todo*) inc; 691 Todo * todo = (Todo*) inc;
682 if ( todo->relations().count() ) { 692 if ( todo->relations().count() ) {
683 if ( askSubTodos ) { 693 if ( askSubTodos ) {
684 int result = KMessageBox::warningYesNoCancel(this, 694 int result = KMessageBox::warningYesNoCancel(this,
685 i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), 695 i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"),
686 i18n("Todo has subtodos"), 696 i18n("Todo has subtodos"),
687 i18n("Yes"), 697 i18n("Yes"),
688 i18n("No")); 698 i18n("No"));
689 if ( result == KMessageBox::Cancel ) { 699 if ( result == KMessageBox::Cancel ) {
690 delSel.clear(); 700 delSel.clear();
691 return delSel; 701 return delSel;
692 } 702 }
693 if (result == KMessageBox::Yes) 703 if (result == KMessageBox::Yes)
694 addSubTodos = true; 704 addSubTodos = true;
695 askSubTodos = false; 705 askSubTodos = false;
696 } 706 }
697 if ( addSubTodos ) { 707 if ( addSubTodos ) {
698 QPtrList<Incidence> tempSel ; 708 QPtrList<Incidence> tempSel ;
699 inc->addRelationsToList( &tempSel ); 709 inc->addRelationsToList( &tempSel );
700 Incidence* tempinc = tempSel.first(); 710 Incidence* tempinc = tempSel.first();
701 while ( tempinc ) { 711 while ( tempinc ) {
702 if ( delSel.findRef( tempinc ) == -1 ) { 712 if ( delSel.findRef( tempinc ) == -1 ) {
703 if ( tempinc->typeID() == todoID && onlyDueTodos ) { 713 if ( tempinc->typeID() == todoID && onlyDueTodos ) {
704 if ( ((Todo*)tempinc)->hasDueDate() ) 714 if ( ((Todo*)tempinc)->hasDueDate() )
705 delSel.append( tempinc ); 715 delSel.append( tempinc );
706 } else 716 } else
707 delSel.append( tempinc ); 717 delSel.append( tempinc );
708 } 718 }
709 tempinc = tempSel.next(); 719 tempinc = tempSel.next();
710 } 720 }
711 } 721 }
712 } 722 }
713 } 723 }
714 } 724 }
715 item = item->nextSibling(); 725 item = item->nextSibling();
716 } 726 }
717 return delSel; 727 return delSel;
718} 728}
719 729
720void KOListView::writeToFile( bool iCal ) 730void KOListView::writeToFile( bool iCal )
721{ 731{
722 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; 732 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
723 if ( !iCal ) { 733 if ( !iCal ) {
724 bool journal = false; 734 bool journal = false;
725 Incidence *incidence = delSel.first(); 735 Incidence *incidence = delSel.first();
726 while ( incidence ) { 736 while ( incidence ) {
727 if ( incidence->typeID() == journalID ) { 737 if ( incidence->typeID() == journalID ) {
728 journal = true; 738 journal = true;
729 break; 739 break;
730 } 740 }
731 incidence = delSel.next(); 741 incidence = delSel.next();
732 } 742 }
733 if ( journal ) { 743 if ( journal ) {
734 int result = KMessageBox::warningContinueCancel(this, 744 int result = KMessageBox::warningContinueCancel(this,
735 i18n("The journal entries can not be\nexported to a vCalendar file."), 745 i18n("The journal entries can not be\nexported to a vCalendar file."),
736 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 746 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
737 true); 747 true);
738 if (result != KMessageBox::Continue) return; 748 if (result != KMessageBox::Continue) return;
739 } 749 }
740 } 750 }
741 if ( delSel.count() ) { 751 if ( delSel.count() ) {
742 QString fn = KOPrefs::instance()->mLastSaveFile; 752 QString fn = KOPrefs::instance()->mLastSaveFile;
743 QString extension; 753 QString extension;
744 if ( iCal ) { 754 if ( iCal ) {
745 if ( fn.right( 4 ).lower() == ".vcs" ) { 755 if ( fn.right( 4 ).lower() == ".vcs" ) {
746 fn = fn.left( fn.length() -3) + "ics"; 756 fn = fn.left( fn.length() -3) + "ics";
747 } 757 }
748 } else { 758 } else {
749 if ( fn.right( 4 ).lower() == ".ics" ) { 759 if ( fn.right( 4 ).lower() == ".ics" ) {
750 fn = fn.left( fn.length() -3) + "vcs"; 760 fn = fn.left( fn.length() -3) + "vcs";
751 } 761 }
752 } 762 }
753 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 763 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
754 764
755 if ( fn == "" ) 765 if ( fn == "" )
756 return; 766 return;
757 QFileInfo info; 767 QFileInfo info;
758 info.setFile( fn ); 768 info.setFile( fn );
759 QString mes; 769 QString mes;
760 bool createbup = true; 770 bool createbup = true;
761 if ( info. exists() ) { 771 if ( info. exists() ) {
762 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 772 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
763 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 773 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
764 i18n("Overwrite!"), i18n("Cancel"), 0, 774 i18n("Overwrite!"), i18n("Cancel"), 0,
765 0, 1 ); 775 0, 1 );
766 if ( result != 0 ) { 776 if ( result != 0 ) {
767 createbup = false; 777 createbup = false;
768 } 778 }
769 } 779 }
770 if ( createbup ) { 780 if ( createbup ) {
771 CalendarLocal cal; 781 CalendarLocal cal;
772 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 782 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
773 Incidence *incidence = delSel.first(); 783 Incidence *incidence = delSel.first();
774 while ( incidence ) { 784 while ( incidence ) {
775 cal.addIncidence( incidence->clone() ); 785 cal.addIncidence( incidence->clone() );
776 incidence = delSel.next(); 786 incidence = delSel.next();
777 } 787 }
778 if ( iCal ) { 788 if ( iCal ) {
779 ICalFormat format; 789 ICalFormat format;
780 format.save( &cal, fn ); 790 format.save( &cal, fn );
781 } else { 791 } else {
782 792
783 VCalFormat format; 793 VCalFormat format;
784 format.save( &cal, fn ); 794 format.save( &cal, fn );
785 } 795 }
786 mes = i18n("KO/Pi:Saved %1").arg(fn ); 796 mes = i18n("KO/Pi:Saved %1").arg(fn );
787 KOPrefs::instance()->mLastSaveFile = fn; 797 KOPrefs::instance()->mLastSaveFile = fn;
788 topLevelWidget()->setCaption(mes); 798 topLevelWidget()->setCaption(mes);
789 } 799 }
790 } 800 }
791 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 801 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
792} 802}
793void KOListView::hideAll() 803void KOListView::hideAll()
794{ 804{
795 QPtrList<QListViewItem> delSel ; 805 QPtrList<QListViewItem> delSel ;
796 QListViewItem *item = mListView->firstChild (); 806 QListViewItem *item = mListView->firstChild ();
797 while ( item ) { 807 while ( item ) {
798 if ( item->isSelected() ) { 808 if ( item->isSelected() ) {
799 delSel.append(item); 809 delSel.append(item);
800 } 810 }
801 item = item->nextSibling(); 811 item = item->nextSibling();
802 } 812 }
803 item = delSel.first() ; 813 item = delSel.first() ;
804 while ( item ) { 814 while ( item ) {
805 QListViewItem * del = item; 815 QListViewItem * del = item;
806 item = delSel.next(); 816 item = delSel.next();
807 delete del; 817 delete del;
808 } 818 }
809} 819}
810void KOListView::printList() 820void KOListView::printList()
811{ 821{
812 mListView->printList(); 822 mListView->printList();
813} 823}
814void KOListView::deleteAll() 824void KOListView::deleteAll()
815{ 825{
816 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; 826 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;;
817 if ( delSel.count() ) { 827 if ( delSel.count() ) {
818 int icount = delSel.count(); 828 int icount = delSel.count();
819 Incidence *incidence = delSel.first(); 829 Incidence *incidence = delSel.first();
820 Incidence *toDelete; 830 Incidence *toDelete;
821 KOPrefs *p = KOPrefs::instance(); 831 KOPrefs *p = KOPrefs::instance();
822 bool confirm = p->mConfirm; 832 bool confirm = p->mConfirm;
823 QString mess; 833 QString mess;
824 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 834 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
825 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")) ) { 835 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")) ) {
826 p->mConfirm = false; 836 p->mConfirm = false;
827 int delCounter = 0; 837 int delCounter = 0;
828 QDialog dia ( this, "p-dialog", true ); 838 QDialog dia ( this, "p-dialog", true );
829 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 839 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
830 QVBoxLayout lay( &dia ); 840 QVBoxLayout lay( &dia );
831 lay.setMargin(7); 841 lay.setMargin(7);
832 lay.setSpacing(7); 842 lay.setSpacing(7);
833 lay.addWidget( &lab); 843 lay.addWidget( &lab);
834 QProgressBar bar( icount, &dia ); 844 QProgressBar bar( icount, &dia );
835 lay.addWidget( &bar); 845 lay.addWidget( &bar);
836 int w = 220; 846 int w = 220;
837 int h = 50; 847 int h = 50;
838 int dw = QApplication::desktop()->width(); 848 int dw = QApplication::desktop()->width();
839 int dh = QApplication::desktop()->height(); 849 int dh = QApplication::desktop()->height();
840 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 850 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
841 //dia.resize( 240,50 ); 851 //dia.resize( 240,50 );
842 dia.show(); 852 dia.show();
843 853
844 while ( incidence ) { 854 while ( incidence ) {
845 bar.setProgress( delCounter ); 855 bar.setProgress( delCounter );
846 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 856 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
847 dia.setCaption( mess ); 857 dia.setCaption( mess );
848 qApp->processEvents(); 858 qApp->processEvents();
849 toDelete = (incidence); 859 toDelete = (incidence);
850 incidence = delSel.next(); 860 incidence = delSel.next();
851 emit deleteIncidenceSignal(toDelete ); 861 emit deleteIncidenceSignal(toDelete );
852 if ( dia.result() != 0 ) 862 if ( dia.result() != 0 )
853 break; 863 break;
854 864
855 } 865 }
856 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 866 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
857 topLevelWidget ()->setCaption( mess ); 867 topLevelWidget ()->setCaption( mess );
858 p->mConfirm = confirm; 868 p->mConfirm = confirm;
859 } 869 }
860 } 870 }
861 871
862 872
863} 873}
864int KOListView::maxDatesHint() 874int KOListView::maxDatesHint()
865{ 875{
866 return 0; 876 return 0;
867} 877}
868 878
869int KOListView::currentDateCount() 879int KOListView::currentDateCount()
870{ 880{
871 return 0; 881 return 0;
872} 882}
873 883
874QPtrList<Incidence> KOListView::selectedIncidences() 884QPtrList<Incidence> KOListView::selectedIncidences()
875{ 885{
876 QPtrList<Incidence> eventList; 886 QPtrList<Incidence> eventList;
877 QListViewItem *item = mListView->firstChild (); 887 QListViewItem *item = mListView->firstChild ();
878 while ( item ) { 888 while ( item ) {
879 if ( item->isSelected() ) { 889 if ( item->isSelected() ) {
880 eventList.append(((KOListViewItem *)item)->data()); 890 eventList.append(((KOListViewItem *)item)->data());
881 } 891 }
882 892
883 item = item->nextSibling(); 893 item = item->nextSibling();
884 } 894 }
885 895
886 // // QListViewItem *item = mListView->selectedItem(); 896 // // QListViewItem *item = mListView->selectedItem();
887 //if (item) eventList.append(((KOListViewItem *)item)->data()); 897 //if (item) eventList.append(((KOListViewItem *)item)->data());
888 898
889 return eventList; 899 return eventList;
890} 900}
891 901
892DateList KOListView::selectedDates() 902DateList KOListView::selectedDates()
893{ 903{
894 DateList eventList; 904 DateList eventList;
895 return eventList; 905 return eventList;
896} 906}
897 907
898void KOListView::showDates(bool show) 908void KOListView::showDates(bool show)
899{ 909{
900 // Shouldn't we set it to a value greater 0? When showDates is called with 910 // Shouldn't we set it to a value greater 0? When showDates is called with
901 // show == true at first, then the columnwidths are set to zero. 911 // show == true at first, then the columnwidths are set to zero.
902 static int oldColWidth1 = 0; 912 static int oldColWidth1 = 0;
903 static int oldColWidth3 = 0; 913 static int oldColWidth3 = 0;
904 914
905 if (!show) { 915 if (!show) {
906 oldColWidth1 = mListView->columnWidth(1); 916 oldColWidth1 = mListView->columnWidth(1);
907 oldColWidth3 = mListView->columnWidth(3); 917 oldColWidth3 = mListView->columnWidth(3);
908 mListView->setColumnWidth(1, 0); 918 mListView->setColumnWidth(1, 0);
909 mListView->setColumnWidth(3, 0); 919 mListView->setColumnWidth(3, 0);
910 } else { 920 } else {
911 mListView->setColumnWidth(1, oldColWidth1); 921 mListView->setColumnWidth(1, oldColWidth1);
912 mListView->setColumnWidth(3, oldColWidth3); 922 mListView->setColumnWidth(3, oldColWidth3);
913 } 923 }
914 mListView->repaint(); 924 mListView->repaint();
915} 925}
916 926
917void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 927void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
918 const QDate &td) 928 const QDate &td)
919{ 929{
920#ifndef KORG_NOPRINTER 930#ifndef KORG_NOPRINTER
921 calPrinter->preview(CalPrinter::Day, fd, td); 931 calPrinter->preview(CalPrinter::Day, fd, td);
922#endif 932#endif
923} 933}
924 934
925void KOListView::showDates() 935void KOListView::showDates()
926{ 936{
927 showDates(true); 937 showDates(true);
928} 938}
929 939
930void KOListView::hideDates() 940void KOListView::hideDates()
931{ 941{
932 showDates(false); 942 showDates(false);
933} 943}
934 944
935void KOListView::resetFocus() 945void KOListView::resetFocus()
936{ 946{
937 topLevelWidget()->setActiveWindow(); 947 topLevelWidget()->setActiveWindow();
938 topLevelWidget()->raise(); 948 topLevelWidget()->raise();
939 mListView->setFocus(); 949 mListView->setFocus();
940} 950}
941void KOListView::updateView() 951void KOListView::updateView()
942{ 952{
943 mListView->setFocus(); 953 mListView->setFocus();
944 if ( mListView->firstChild () ) 954 if ( mListView->firstChild () )
945 mListView->setCurrentItem( mListView->firstChild () ); 955 mListView->setCurrentItem( mListView->firstChild () );
946} 956}
947void KOListView::updateConfig() 957void KOListView::updateConfig()
948{ 958{
949 959
950 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 960 mListView->setFont ( KOPrefs::instance()->mListViewFont );
951 updateView(); 961 updateView();
952 962
953} 963}
954void KOListView::setStartDate(const QDate &start) 964void KOListView::setStartDate(const QDate &start)
955{ 965{
956 mStartDate = start; 966 mStartDate = start;
957} 967}
958 968
959void KOListView::showDates(const QDate &start, const QDate &end) 969void KOListView::showDates(const QDate &start, const QDate &end)
960{ 970{
961 clear(); 971 clear();
962 mStartDate = start; 972 mStartDate = start;
963 QDate date = start; 973 QDate date = start;
964 while( date <= end ) { 974 while( date <= end ) {
965 addEvents(calendar()->events(date)); 975 addEvents(calendar()->events(date));
966 addTodos(calendar()->todos(date)); 976 addTodos(calendar()->todos(date));
967 addJournals( calendar()->journals4Date(date) ); 977 addJournals( calendar()->journals4Date(date) );
968 date = date.addDays( 1 ); 978 date = date.addDays( 1 );
969 } 979 }
970 emit incidenceSelected( 0 ); 980 emit incidenceSelected( 0 );
971 updateView(); 981 updateView();
972 982
973} 983}
974 984
975void KOListView::addEvents(QPtrList<Event> eventList) 985void KOListView::addEvents(QPtrList<Event> eventList)
976{ 986{
977 987
978 Event *ev; 988 Event *ev;
979 for(ev = eventList.first(); ev; ev = eventList.next()) { 989 for(ev = eventList.first(); ev; ev = eventList.next()) {
980 addIncidence(ev); 990 addIncidence(ev);
981 } 991 }
982 if ( !mListView->currentItem() ){ 992 if ( !mListView->currentItem() ){
983 updateView(); 993 updateView();
984 } 994 }
985} 995}
986 996
987void KOListView::addTodos(QPtrList<Todo> eventList) 997void KOListView::addTodos(QPtrList<Todo> eventList)
988{ 998{
989 Todo *ev; 999 Todo *ev;
990 for(ev = eventList.first(); ev; ev = eventList.next()) { 1000 for(ev = eventList.first(); ev; ev = eventList.next()) {
991 addIncidence(ev); 1001 addIncidence(ev);
992 } 1002 }
993 if ( !mListView->currentItem() ){ 1003 if ( !mListView->currentItem() ){
994 updateView(); 1004 updateView();
995 } 1005 }
996} 1006}
997void KOListView::addJournals(QPtrList<Journal> eventList) 1007void KOListView::addJournals(QPtrList<Journal> eventList)
998{ 1008{
999 Journal *ev; 1009 Journal *ev;
1000 for(ev = eventList.first(); ev; ev = eventList.next()) { 1010 for(ev = eventList.first(); ev; ev = eventList.next()) {
1001 addIncidence(ev); 1011 addIncidence(ev);
1002 } 1012 }
1003 if ( !mListView->currentItem() ){ 1013 if ( !mListView->currentItem() ){
1004 updateView(); 1014 updateView();
1005 } 1015 }
1006} 1016}
1007 1017
1008void KOListView::showCompletedTodos() 1018void KOListView::showCompletedTodos()
1009{ 1019{
1010 mForceShowCompletedTodos = true; 1020 mForceShowCompletedTodos = true;
1011} 1021}
1012void KOListView::addIncidence(Incidence *incidence) 1022void KOListView::addIncidence(Incidence *incidence)
1013{ 1023{
1014 if ( mUidDict.find( incidence->uid() ) ) return; 1024 if ( mUidDict.find( incidence->uid() ) ) return;
1015 1025
1016 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 1026 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
1017 if ( incidence->typeID() == todoID ) { 1027 if ( incidence->typeID() == todoID ) {
1018 if ( ! mForceShowCompletedTodos ) { 1028 if ( ! mForceShowCompletedTodos ) {
1019 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) 1029 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() )
1020 return; 1030 return;
1021 } 1031 }
1022 } 1032 }
1023 mUidDict.insert( incidence->uid(), incidence ); 1033 mUidDict.insert( incidence->uid(), incidence );
1024 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 1034 KOListViewItem *item = new KOListViewItem( incidence, mListView );
1025 ListItemVisitor v(item, mStartDate ); 1035 ListItemVisitor v(item, mStartDate );
1026 if (incidence->accept(v)) { 1036 if (incidence->accept(v)) {
1027 return; 1037 return;
1028 } 1038 }
1029 else delete item; 1039 else delete item;
1030} 1040}
1031 1041
1032void KOListView::showEvents(QPtrList<Event> eventList) 1042void KOListView::showEvents(QPtrList<Event> eventList)
1033{ 1043{
1034 clear(); 1044 clear();
1035 1045
1036 addEvents(eventList); 1046 addEvents(eventList);
1037 1047
1038 // After new creation of list view no events are selected. 1048 // After new creation of list view no events are selected.
1039 emit incidenceSelected( 0 ); 1049 emit incidenceSelected( 0 );
1040} 1050}
1041int KOListView::count() 1051int KOListView::count()
1042{ 1052{
1043 return mListView->childCount(); 1053 return mListView->childCount();
1044} 1054}
1045 1055
1046void KOListView::changeEventDisplay(Event *event, int action) 1056void KOListView::changeEventDisplay(Event *event, int action)
1047{ 1057{
1048 KOListViewItem *item; 1058 KOListViewItem *item;
1049 1059
1050 switch(action) { 1060 switch(action) {
1051 case KOGlobals::EVENTADDED: 1061 case KOGlobals::EVENTADDED:
1052 addIncidence( event ); 1062 addIncidence( event );
1053 break; 1063 break;
1054 case KOGlobals::EVENTEDITED: 1064 case KOGlobals::EVENTEDITED:
1055 item = getItemForEvent(event); 1065 item = getItemForEvent(event);
1056 if (item) { 1066 if (item) {
1057 ListItemVisitor v(item, mStartDate ); 1067 ListItemVisitor v(item, mStartDate );
1058 ((Incidence*)event)->accept(v); 1068 ((Incidence*)event)->accept(v);
1059 } 1069 }
1060 break; 1070 break;
1061 case KOGlobals::EVENTDELETED: 1071 case KOGlobals::EVENTDELETED:
1062 item = getItemForEvent(event); 1072 item = getItemForEvent(event);
1063 if (item) { 1073 if (item) {
1064 mUidDict.remove( event->uid() ); 1074 mUidDict.remove( event->uid() );
1065 delete item; 1075 delete item;
1066 } 1076 }
1067 break; 1077 break;
1068 default: 1078 default:
1069 ; 1079 ;
1070 } 1080 }
1071} 1081}
1072 1082
1073KOListViewItem *KOListView::getItemForEvent(Incidence *event) 1083KOListViewItem *KOListView::getItemForEvent(Incidence *event)
1074{ 1084{
1075 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 1085 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
1076 while (item) { 1086 while (item) {
1077 if (item->data() == event) return item; 1087 if (item->data() == event) return item;
1078 item = (KOListViewItem *)item->nextSibling(); 1088 item = (KOListViewItem *)item->nextSibling();
1079 } 1089 }
1080 return 0; 1090 return 0;
1081} 1091}
1082 1092
1083void KOListView::defaultItemAction(QListViewItem *i) 1093void KOListView::defaultItemAction(QListViewItem *i)
1084{ 1094{
1085 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 1095 KOListViewItem *item = static_cast<KOListViewItem *>( i );
1086 if ( item ) defaultAction( item->data() ); 1096 if ( item ) defaultAction( item->data() );
1087 1097
1088} 1098}
1089 1099
1090void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 1100void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
1091{ 1101{
1092 mActiveItem = (KOListViewItem *)item; 1102 mActiveItem = (KOListViewItem *)item;
1093 if (mActiveItem) { 1103 if (mActiveItem) {
1094 Incidence *incidence = mActiveItem->data(); 1104 Incidence *incidence = mActiveItem->data();
1095 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); 1105 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) );
1096 mPopupMenu->showIncidencePopup(incidence); 1106 mPopupMenu->showIncidencePopup(incidence);
1097 1107
1098 /* 1108 /*
1099 if ( incidence && incidence->type() == "Event" ) { 1109 if ( incidence && incidence->type() == "Event" ) {
1100 Event *event = static_cast<Event *>( incidence ); 1110 Event *event = static_cast<Event *>( incidence );
1101 mPopupMenu->showEventPopup(event); 1111 mPopupMenu->showEventPopup(event);
1102 } 1112 }
1103 */ 1113 */
1104 } 1114 }
1105} 1115}
1106 1116
1107void KOListView::readSettings(KConfig *config, QString setting) 1117void KOListView::readSettings(KConfig *config, QString setting)
1108{ 1118{
1109 // qDebug("KOListView::readSettings "); 1119 // qDebug("KOListView::readSettings ");
1110 mListView->restoreLayout(config,setting); 1120 mListView->restoreLayout(config,setting);
1111} 1121}
1112 1122
1113void KOListView::writeSettings(KConfig *config, QString setting) 1123void KOListView::writeSettings(KConfig *config, QString setting)
1114{ 1124{
1115 // qDebug("KOListView::writeSettings "); 1125 // qDebug("KOListView::writeSettings ");
1116 mListView->saveLayout(config, setting); 1126 mListView->saveLayout(config, setting);
1117} 1127}
1118 1128
1119void KOListView::processSelectionChange(QListViewItem *) 1129void KOListView::processSelectionChange(QListViewItem *)
1120{ 1130{
1121 1131
1122 KOListViewItem *item = 1132 KOListViewItem *item =
1123 static_cast<KOListViewItem *>( mListView->currentItem() ); 1133 static_cast<KOListViewItem *>( mListView->currentItem() );
1124 1134
1125 if ( !item ) { 1135 if ( !item ) {
1126 emit incidenceSelected( 0 ); 1136 emit incidenceSelected( 0 );
1127 } else { 1137 } else {
1128 emit incidenceSelected( item->data() ); 1138 emit incidenceSelected( item->data() );
1129 } 1139 }
1130} 1140}
1131 1141
1132void KOListView::clearSelection() 1142void KOListView::clearSelection()
1133{ 1143{
1134 mListView->selectAll( false ); 1144 mListView->selectAll( false );
1135} 1145}
1136void KOListView::allSelection() 1146void KOListView::allSelection()
1137{ 1147{
1138 mListView->selectAll( true ); 1148 mListView->selectAll( true );
1139} 1149}
1140 1150
1141void KOListView::clear() 1151void KOListView::clear()
1142{ 1152{
1143 mListView->clear(); 1153 mListView->clear();
1144 mUidDict.clear(); 1154 mUidDict.clear();
1145} 1155}
1146 1156
1147Incidence* KOListView::currentItem() 1157Incidence* KOListView::currentItem()
1148{ 1158{
1149 if ( mListView->currentItem() ) 1159 if ( mListView->currentItem() )
1150 return ((KOListViewItem*) mListView->currentItem())->data(); 1160 return ((KOListViewItem*) mListView->currentItem())->data();
1151 return 0; 1161 return 0;
1152} 1162}
1153void KOListView::keyPressEvent ( QKeyEvent *e) 1163void KOListView::keyPressEvent ( QKeyEvent *e)
1154{ 1164{
1155 1165
1156 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1166 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1157 deleteAll(); 1167 deleteAll();
1158 return; 1168 return;
1159 } 1169 }
1160 1170
1161 e->ignore(); 1171 e->ignore();
1162} 1172}
1163void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1173void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1164{ 1174{
1165 1175
1166 switch ( e->key() ) { 1176 switch ( e->key() ) {
1167 case Qt::Key_Down: 1177 case Qt::Key_Down:
1168 if ( e->state() == ShiftButton ) { 1178 if ( e->state() == ShiftButton ) {
1169 QListViewItem* cn = currentItem(); 1179 QListViewItem* cn = currentItem();
1170 if ( !cn ) 1180 if ( !cn )
1171 cn = firstChild(); 1181 cn = firstChild();
1172 if ( !cn ) 1182 if ( !cn )
1173 return; 1183 return;
1174 while ( cn->nextSibling() ) 1184 while ( cn->nextSibling() )
1175 cn = cn->nextSibling(); 1185 cn = cn->nextSibling();
1176 setCurrentItem ( cn ); 1186 setCurrentItem ( cn );
1177 ensureItemVisible ( cn ); 1187 ensureItemVisible ( cn );
1178 1188
1179 e->accept(); 1189 e->accept();
1180 return; 1190 return;
1181 } 1191 }
1182 if ( e->state() == ControlButton ) { 1192 if ( e->state() == ControlButton ) {
1183 int count = childCount (); 1193 int count = childCount ();
1184 int jump = count / 5; 1194 int jump = count / 5;
1185 QListViewItem* cn; 1195 QListViewItem* cn;
1186 cn = currentItem(); 1196 cn = currentItem();
1187 if ( ! cn ) 1197 if ( ! cn )
1188 return; 1198 return;
1189 if ( jump == 0 ) 1199 if ( jump == 0 )
1190 jump = 1; 1200 jump = 1;
1191 while ( jump && cn->nextSibling() ) { 1201 while ( jump && cn->nextSibling() ) {
1192 cn = cn->nextSibling(); 1202 cn = cn->nextSibling();
1193 --jump; 1203 --jump;
1194 } 1204 }
1195 setCurrentItem ( cn ); 1205 setCurrentItem ( cn );
1196 ensureItemVisible ( cn ); 1206 ensureItemVisible ( cn );
1197 1207
1198 } else 1208 } else
1199 QListView::keyPressEvent ( e ) ; 1209 QListView::keyPressEvent ( e ) ;
1200 e->accept(); 1210 e->accept();
1201 break; 1211 break;
1202 1212
1203 case Qt::Key_Up: 1213 case Qt::Key_Up:
1204 if ( e->state() == ShiftButton ) { 1214 if ( e->state() == ShiftButton ) {
1205 QListViewItem* cn = firstChild(); 1215 QListViewItem* cn = firstChild();
1206 if ( cn ) { 1216 if ( cn ) {
1207 setCurrentItem ( cn ); 1217 setCurrentItem ( cn );
1208 ensureItemVisible ( cn ); 1218 ensureItemVisible ( cn );
1209 } 1219 }
1210 e->accept(); 1220 e->accept();
1211 return; 1221 return;
1212 } 1222 }
1213 if ( e->state() == ControlButton ) { 1223 if ( e->state() == ControlButton ) {
1214 int count = childCount (); 1224 int count = childCount ();
1215 int jump = count / 5; 1225 int jump = count / 5;
1216 QListViewItem* cn; 1226 QListViewItem* cn;
1217 cn = currentItem(); 1227 cn = currentItem();
1218 if ( ! cn ) 1228 if ( ! cn )
1219 return; 1229 return;
1220 if ( jump == 0 ) 1230 if ( jump == 0 )
1221 jump = 1; 1231 jump = 1;
1222 while ( jump && cn->itemAbove ()) { 1232 while ( jump && cn->itemAbove ()) {
1223 cn = cn->itemAbove (); 1233 cn = cn->itemAbove ();
1224 --jump; 1234 --jump;
1225 } 1235 }
1226 setCurrentItem ( cn ); 1236 setCurrentItem ( cn );
1227 ensureItemVisible ( cn ); 1237 ensureItemVisible ( cn );
1228 } else 1238 } else
1229 QListView::keyPressEvent ( e ) ; 1239 QListView::keyPressEvent ( e ) ;
1230 e->accept(); 1240 e->accept();
1231 break; 1241 break;
1232 case Qt::Key_I: { 1242 case Qt::Key_I: {
1233 QListViewItem* cn; 1243 QListViewItem* cn;
1234 cn = currentItem(); 1244 cn = currentItem();
1235 if ( cn ) { 1245 if ( cn ) {
1236 KOListViewItem* ci = (KOListViewItem*)( cn ); 1246 KOListViewItem* ci = (KOListViewItem*)( cn );
1237 if ( ci ){ 1247 if ( ci ){
1238 //emit showIncidence( ci->data()); 1248 //emit showIncidence( ci->data());
1239 cn = cn->nextSibling(); 1249 cn = cn->nextSibling();
1240 if ( cn ) { 1250 if ( cn ) {
1241 setCurrentItem ( cn ); 1251 setCurrentItem ( cn );
1242 ensureItemVisible ( cn ); 1252 ensureItemVisible ( cn );
1243 } 1253 }
1244 emit showIncidence( ci->data()); 1254 emit showIncidence( ci->data());
1245 } 1255 }
1246 } 1256 }
1247 e->accept(); 1257 e->accept();
1248 } 1258 }
1249 break; 1259 break;
1250 case Qt::Key_Return: 1260 case Qt::Key_Return:
1251 case Qt::Key_Enter: 1261 case Qt::Key_Enter:
1252 { 1262 {
1253 QListViewItem* cn; 1263 QListViewItem* cn;
1254 cn = currentItem(); 1264 cn = currentItem();
1255 if ( cn ) { 1265 if ( cn ) {
1256 KOListViewItem* ci = (KOListViewItem*)( cn ); 1266 KOListViewItem* ci = (KOListViewItem*)( cn );
1257 if ( ci ){ 1267 if ( ci ){
1258 if ( e->state() == ShiftButton ) 1268 if ( e->state() == ShiftButton )
1259 ci->setSelected( false ); 1269 ci->setSelected( false );
1260 else 1270 else
1261 ci->setSelected( true ); 1271 ci->setSelected( true );
1262 cn = cn->nextSibling(); 1272 cn = cn->nextSibling();
1263 if ( cn ) { 1273 if ( cn ) {
1264 setCurrentItem ( cn ); 1274 setCurrentItem ( cn );
1265 ensureItemVisible ( cn ); 1275 ensureItemVisible ( cn );
1266 } 1276 }
1267 } 1277 }
1268 } 1278 }
1269 e->accept(); 1279 e->accept();
1270 } 1280 }
1271 break; 1281 break;
1272 default: 1282 default:
1273 e->ignore(); 1283 e->ignore();
1274 } 1284 }
1275} 1285}
1276KOListViewListView::KOListViewListView(KOListView * lv ) 1286KOListViewListView::KOListViewListView(KOListView * lv )
1277 : KListView( lv, "kolistlistview", false ) 1287 : KListView( lv, "kolistlistview", false )
1278{ 1288{
1279 mYMousePos = 0; 1289 mYMousePos = 0;
1280 mPopupTimer = new QTimer(this); 1290 mPopupTimer = new QTimer(this);
1281 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1291 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1282#ifndef DESKTOP_VERSION 1292#ifndef DESKTOP_VERSION
1283 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1293 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1284#endif 1294#endif
1285 setSelectionMode( QListView::Multi ); 1295 setSelectionMode( QListView::Multi );
1286 setMultiSelection( true); 1296 setMultiSelection( true);
1287} 1297}
1288bool KOListViewListView::hasMultiSelection(QListViewItem* item) 1298bool KOListViewListView::hasMultiSelection(QListViewItem* item)
1289{ 1299{
1290 int selCount = 0; 1300 int selCount = 0;
1291 QListViewItem *qitem = firstChild (); 1301 QListViewItem *qitem = firstChild ();
1292 while ( qitem ) { 1302 while ( qitem ) {
1293 if ( qitem->isSelected() && item != qitem ) 1303 if ( qitem->isSelected() && item != qitem )
1294 return true; 1304 return true;
1295 qitem = qitem->nextSibling(); 1305 qitem = qitem->nextSibling();
1296 } 1306 }
1297 return false; 1307 return false;
1298} 1308}
1299void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1309void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1300{ 1310{
1301 if (!e) return; 1311 if (!e) return;
1302 QPoint vp = contentsToViewport(e->pos()); 1312 QPoint vp = contentsToViewport(e->pos());
1303 QListViewItem *item = itemAt(vp); 1313 QListViewItem *item = itemAt(vp);
1304 if (!item) { 1314 if (!item) {
1305 emit newEvent(); 1315 emit newEvent();
1306 return; 1316 return;
1307 } 1317 }
1308 KListView::contentsMouseDoubleClickEvent(e); 1318 KListView::contentsMouseDoubleClickEvent(e);
1309} 1319}
1310#if 0 1320#if 0
1311void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1321void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1312{ 1322{
1313 //qDebug("contentsMousePressEvent++++ "); 1323 //qDebug("contentsMousePressEvent++++ ");
1314 KListView::contentsMousePressEvent( e ); 1324 KListView::contentsMousePressEvent( e );
1315 if ( e->button() == RightButton ) { 1325 if ( e->button() == RightButton ) {
1316 QListViewItem* ci = currentItem(); 1326 QListViewItem* ci = currentItem();
1317 clearSelection () ; 1327 clearSelection () ;
1318 if ( ci ) 1328 if ( ci )
1319 ci->setSelected( true ); 1329 ci->setSelected( true );
1320 } 1330 }
1321} 1331}
1322void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1332void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1323{ 1333{
1324 KListView::contentsMouseReleaseEvent(e); 1334 KListView::contentsMouseReleaseEvent(e);
1325} 1335}
1326void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1336void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1327{ 1337{
1328 KListView::contentsMouseMoveEvent(e); 1338 KListView::contentsMouseMoveEvent(e);
1329} 1339}
1330#endif 1340#endif
1331void KOListViewListView::popupMenu() 1341void KOListViewListView::popupMenu()
1332{ 1342{
1333 mPopupTimer->stop(); 1343 mPopupTimer->stop();
1334 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1344 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1335 QApplication::postEvent( this->viewport(), e ); 1345 QApplication::postEvent( this->viewport(), e );
1336 1346
1337} 1347}
1338void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1348void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1339{ 1349{
1340 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); 1350 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y());
1341 mYMousePos = mapToGlobal( (e->pos())).y(); 1351 mYMousePos = mapToGlobal( (e->pos())).y();
1342 if ( e->button() == LeftButton ) { 1352 if ( e->button() == LeftButton ) {
1343 mPopupTimer->start( 600 ); 1353 mPopupTimer->start( 600 );
1344 mEventPos = contentsToViewport(e->pos()); 1354 mEventPos = contentsToViewport(e->pos());
1345 mEventGlobalPos = e->globalPos(); 1355 mEventGlobalPos = e->globalPos();
1346 } 1356 }
1347 KListView::contentsMousePressEvent( e ); 1357 KListView::contentsMousePressEvent( e );
1348 if ( e->button() == RightButton ) { 1358 if ( e->button() == RightButton ) {
1349 QListViewItem* ci = currentItem(); 1359 QListViewItem* ci = currentItem();
1350 //clearSelection(); 1360 //clearSelection();
1351 if ( ci ) 1361 if ( ci )
1352 ci->setSelected( true ); 1362 ci->setSelected( true );
1353 } 1363 }
1354} 1364}
1355void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1365void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1356{ 1366{
1357 mPopupTimer->stop(); 1367 mPopupTimer->stop();
1358 KListView::contentsMouseReleaseEvent(e); 1368 KListView::contentsMouseReleaseEvent(e);
1359} 1369}
1360void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1370void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1361{ 1371{
1362 // qDebug("contentsMouseMoveEv....... "); 1372 // qDebug("contentsMouseMoveEv....... ");
1363 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1373 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1364 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1374 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1365 if ( diff < 0 ) diff = -diff; 1375 if ( diff < 0 ) diff = -diff;
1366 if ( diff > 15 ) 1376 if ( diff > 15 )
1367 mPopupTimer->stop(); 1377 mPopupTimer->stop();
1368 else { 1378 else {
1369 mEventPos = contentsToViewport(e->pos()); 1379 mEventPos = contentsToViewport(e->pos());
1370 mEventGlobalPos = e->globalPos(); 1380 mEventGlobalPos = e->globalPos();
1371 } 1381 }
1372 KListView::contentsMouseMoveEvent(e); 1382 KListView::contentsMouseMoveEvent(e);
1373} 1383}
1374 1384
1375#define protected public 1385#define protected public
1376#include <qheader.h> 1386#include <qheader.h>
1377#undef protected 1387#undef protected
1378void KOListViewListView::printList() 1388void KOListViewListView::printList()
1379{ 1389{
1380#ifdef DESKTOP_VERSION 1390#ifdef DESKTOP_VERSION
1381 KOPrintPrefs pp ( this ); 1391 KOPrintPrefs pp ( this );
1382 if (!pp.exec() ) 1392 if (!pp.exec() )
1383 return; 1393 return;
1384 int scaleval = pp.printMode() ; 1394 int scaleval = pp.printMode() ;
1385 1395
1386 QPrinter printer; 1396 QPrinter printer;
1387 if (!printer.setup() ) 1397 if (!printer.setup() )
1388 return; 1398 return;
1389 clearSelection (); 1399 clearSelection ();
1390 QPainter p; 1400 QPainter p;
1391 p.begin ( &printer ); 1401 p.begin ( &printer );
1392 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 1402 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
1393 float dx, dy; 1403 float dx, dy;
1394 int wid = (m.width() * 9)/10; 1404 int wid = (m.width() * 9)/10;
1395 dx = (float) wid/(float)contentsWidth (); 1405 dx = (float) wid/(float)contentsWidth ();
1396 dy = (float)(m.height()) / (float)contentsHeight (); 1406 dy = (float)(m.height()) / (float)contentsHeight ();
1397 float scale; 1407 float scale;
1398 // scale to fit the width or height of the paper 1408 // scale to fit the width or height of the paper
1399 if ( dx < dy ) 1409 if ( dx < dy )
1400 scale = dx; 1410 scale = dx;
1401 else 1411 else
1402 scale = dy; 1412 scale = dy;
1403 1413
1404 p.translate( m.width()/10,m.width()/10 ); 1414 p.translate( m.width()/10,m.width()/10 );
1405 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { 1415 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
1406 p.scale( scale, scale ); 1416 p.scale( scale, scale );
1407 } 1417 }
1408 1418
1409 int cou = header()->count(); 1419 int cou = header()->count();
1410 int iii; 1420 int iii;
1411 QRect rect ( 0,0,0, header()->height()); 1421 QRect rect ( 0,0,0, header()->height());
1412 for ( iii = 0; iii < cou; ++iii ) { 1422 for ( iii = 0; iii < cou; ++iii ) {
1413 rect.setLeft ( header()->sectionPos( iii ) ); 1423 rect.setLeft ( header()->sectionPos( iii ) );
1414 rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); 1424 rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii));
1415 header()->paintSection ( & p, header()->mapToIndex (iii), rect ); 1425 header()->paintSection ( & p, header()->mapToIndex (iii), rect );
1416 } 1426 }
1417 p.translate( 0, header()->height()); 1427 p.translate( 0, header()->height());
1418 drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); 1428 drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () );
1419 p.end(); 1429 p.end();
1420#endif 1430#endif
1421} 1431}
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index d0865c3..efe8774 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -1,617 +1,619 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 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 <qlayout.h> 25#include <qlayout.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qgroupbox.h> 27#include <qgroupbox.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qlistview.h> 29#include <qlistview.h>
30#include <qwhatsthis.h> 30#include <qwhatsthis.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qhbuttongroup.h> 33#include <qhbuttongroup.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkdepim/kdateedit.h> 37#include <libkdepim/kdateedit.h>
38 38
39#include "koglobals.h" 39#include "koglobals.h"
40#include "koprefs.h" 40#include "koprefs.h"
41#include "klineedit.h" 41#include "klineedit.h"
42 42
43#include "calendarview.h" 43#include "calendarview.h"
44#include "koviewmanager.h" 44#include "koviewmanager.h"
45#include "searchdialog.h" 45#include "searchdialog.h"
46 46
47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
48 : QVBox( 0 ) 48 : QVBox( 0 )
49 49
50{ 50{
51 mCalendar = calendar; 51 mCalendar = calendar;
52 QFrame *topFrame = new QFrame( this ) ;//plainPage(); 52 QFrame *topFrame = new QFrame( this ) ;//plainPage();
53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); 53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
54 54
55 // Search expression 55 // Search expression
56 QHBoxLayout *subLayout = new QHBoxLayout(); 56 QHBoxLayout *subLayout = new QHBoxLayout();
57 layout->addLayout(subLayout); 57 layout->addLayout(subLayout);
58 /* 58 /*
59 searchLabel = new QLabel(topFrame); 59 searchLabel = new QLabel(topFrame);
60 searchLabel->setText(i18n("Search for:")); 60 searchLabel->setText(i18n("Search for:"));
61 subLayout->addWidget(searchLabel); 61 subLayout->addWidget(searchLabel);
62 */ 62 */
63 QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); 63 QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame );
64 //OkButton->setDefault( true ); 64 //OkButton->setDefault( true );
65 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); 65 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch()));
66 subLayout->addWidget(OkButton); 66 subLayout->addWidget(OkButton);
67 searchEdit = new KLineEdit(topFrame); 67 searchEdit = new KLineEdit(topFrame);
68 subLayout->addWidget(searchEdit); 68 subLayout->addWidget(searchEdit);
69 69
70 mAddItems = new QRadioButton( "+ ", topFrame ); 70 mAddItems = new QRadioButton( "+ ", topFrame );
71 mSubItems = new QRadioButton( "- ", topFrame ); 71 mSubItems = new QRadioButton( "- ", topFrame );
72 mRefineItems = new QRadioButton( "< ", topFrame ); 72 mRefineItems = new QRadioButton( "< ", topFrame );
73 subLayout->addWidget( mAddItems ); 73 subLayout->addWidget( mAddItems );
74 subLayout->addWidget( mSubItems ); 74 subLayout->addWidget( mSubItems );
75 subLayout->addWidget( mRefineItems ); 75 subLayout->addWidget( mRefineItems );
76 QFont fo ( mAddItems->font() ); 76 QFont fo ( mAddItems->font() );
77 fo.setBold( true ); 77 fo.setBold( true );
78 fo.setPointSize( fo.pointSize() + 2 ); 78 fo.setPointSize( fo.pointSize() + 2 );
79 mAddItems->setFont( fo ); 79 mAddItems->setFont( fo );
80 mSubItems->setFont( fo ); 80 mSubItems->setFont( fo );
81 mRefineItems->setFont( fo ); 81 mRefineItems->setFont( fo );
82 connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool ))); 82 connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool )));
83 connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool ))); 83 connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool )));
84 connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool ))); 84 connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool )));
85 85
86 QPushButton *togButton = new QPushButton( "", topFrame ); 86 QPushButton *togButton = new QPushButton( "", topFrame );
87 subLayout->addWidget(togButton); 87 subLayout->addWidget(togButton);
88 connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); 88 connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes()));
89 togButton->setPixmap(SmallIcon("1updownarrow")); 89 togButton->setPixmap(SmallIcon("1updownarrow"));
90 togButton->setMinimumWidth( togButton->sizeHint().height() ); 90 togButton->setMinimumWidth( togButton->sizeHint().height() );
91 91
92 searchEdit->setText("*"); // Find all events by default 92 searchEdit->setText("*"); // Find all events by default
93 searchEdit->setFocus(); 93 searchEdit->setFocus();
94 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 94 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
95 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 95 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
96 // Subjects to search 96 // Subjects to search
97 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 97 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
98 // topFrame); 98 // topFrame);
99 99
100 incidenceGroup = new QHBox( topFrame ); 100 incidenceGroup = new QHBox( topFrame );
101 layout->addWidget(incidenceGroup); 101 layout->addWidget(incidenceGroup);
102 102
103 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 103 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
104 //mSearchEvent->setChecked(true); 104 //mSearchEvent->setChecked(true);
105 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 105 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
106 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 106 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
107 107
108 subjectGroup = new QHBox( topFrame ); 108 subjectGroup = new QHBox( topFrame );
109 layout->addWidget(subjectGroup); 109 layout->addWidget(subjectGroup);
110 110
111 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); 111 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup);
112 mSummaryCheck->setChecked(true); 112 mSummaryCheck->setChecked(true);
113 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); 113 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup);
114 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 114 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
115 115
116 attendeeGroup = new QHBox( topFrame ); 116 attendeeGroup = new QHBox( topFrame );
117 layout->addWidget(attendeeGroup ); 117 layout->addWidget(attendeeGroup );
118 new QLabel( i18n("Attendee:"),attendeeGroup ); 118 new QLabel( i18n("Attendee:"),attendeeGroup );
119 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 119 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
120 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 120 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
121 // Date range 121 // Date range
122 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 122 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
123 // topFrame); 123 // topFrame);
124 // layout->addWidget(rangeGroup); 124 // layout->addWidget(rangeGroup);
125 125
126 QWidget *rangeWidget = new QWidget(topFrame); 126 QWidget *rangeWidget = new QWidget(topFrame);
127 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()-3); 127 int space = KDialog::spacingHint();
128 if ( QApplication::desktop()->width() <= 240 ) space = 1;
129 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,space);
128 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 130 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
129 mStartDate = new KDateEdit(rangeWidget); 131 mStartDate = new KDateEdit(rangeWidget);
130 rangeLayout->addWidget(mStartDate); 132 rangeLayout->addWidget(mStartDate);
131 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 133 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
132 mEndDate = new KDateEdit(rangeWidget); 134 mEndDate = new KDateEdit(rangeWidget);
133 mEndDate->setDate(QDate::currentDate().addDays(365)); 135 mEndDate->setDate(QDate::currentDate().addDays(365));
134 rangeLayout->addWidget(mEndDate); 136 rangeLayout->addWidget(mEndDate);
135 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); 137 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget );
136 rangeLayout->addWidget( (QWidget*)wt ); 138 rangeLayout->addWidget( (QWidget*)wt );
137 layout->addWidget(rangeWidget); 139 layout->addWidget(rangeWidget);
138 // Results list view 140 // Results list view
139 listView = new KOListView(mCalendar,topFrame); 141 listView = new KOListView(mCalendar,topFrame);
140 layout->addWidget(listView); 142 layout->addWidget(listView);
141 listView->showCompletedTodos(); 143 listView->showCompletedTodos();
142 //layout->setStretchFactor( listView, 333 ); 144 //layout->setStretchFactor( listView, 333 );
143 //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); 145 //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) );
144 //listView->setMaximumHeight( 50 ); 146 //listView->setMaximumHeight( 50 );
145 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 147 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
146 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); 148 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList()));
147 149
148 setCaption( i18n("KO/Pi Find: ")); 150 setCaption( i18n("KO/Pi Find: "));
149#ifdef DESKTOP_VERSION 151#ifdef DESKTOP_VERSION
150 OkButton = new QPushButton( i18n("Close"), this ); 152 OkButton = new QPushButton( i18n("Close"), this );
151 connect(OkButton,SIGNAL(clicked()),SLOT(hide())); 153 connect(OkButton,SIGNAL(clicked()),SLOT(hide()));
152#endif 154#endif
153} 155}
154 156
155SearchDialog::~SearchDialog() 157SearchDialog::~SearchDialog()
156{ 158{
157 159
158} 160}
159void SearchDialog::slot_add( bool b ) 161void SearchDialog::slot_add( bool b )
160{ 162{
161 if ( b ) { 163 if ( b ) {
162 if ( mSubItems->isOn() ) mSubItems->toggle(); 164 if ( mSubItems->isOn() ) mSubItems->toggle();
163 if ( mRefineItems->isOn() ) mRefineItems->toggle(); 165 if ( mRefineItems->isOn() ) mRefineItems->toggle();
164 setCaption( i18n("Matching items will be added to list")); 166 setCaption( i18n("Matching items will be added to list"));
165 } else 167 } else
166 setCaption( i18n("List will be cleared before search")); 168 setCaption( i18n("List will be cleared before search"));
167} 169}
168void SearchDialog::slot_sub( bool b) 170void SearchDialog::slot_sub( bool b)
169{ 171{
170 if ( b ) { 172 if ( b ) {
171 if ( mRefineItems->isOn() ) mRefineItems->toggle(); 173 if ( mRefineItems->isOn() ) mRefineItems->toggle();
172 if ( mAddItems->isOn() ) mAddItems->toggle(); 174 if ( mAddItems->isOn() ) mAddItems->toggle();
173 setCaption( i18n("Matching items will be removed from list")); 175 setCaption( i18n("Matching items will be removed from list"));
174 } else 176 } else
175 setCaption( i18n("List will be cleared before search")); 177 setCaption( i18n("List will be cleared before search"));
176} 178}
177void SearchDialog::slot_refine( bool b) 179void SearchDialog::slot_refine( bool b)
178{ 180{
179 if ( b ) { 181 if ( b ) {
180 if ( mSubItems->isOn() ) mSubItems->toggle(); 182 if ( mSubItems->isOn() ) mSubItems->toggle();
181 if ( mAddItems->isOn() ) mAddItems->toggle(); 183 if ( mAddItems->isOn() ) mAddItems->toggle();
182 setCaption( i18n("Search on displayed list only")); 184 setCaption( i18n("Search on displayed list only"));
183 } else 185 } else
184 setCaption( i18n("List will be cleared before search")); 186 setCaption( i18n("List will be cleared before search"));
185} 187}
186void SearchDialog::toggleCheckboxes() 188void SearchDialog::toggleCheckboxes()
187{ 189{
188 if ( incidenceGroup->isVisible() ) { 190 if ( incidenceGroup->isVisible() ) {
189 incidenceGroup->hide() ; 191 incidenceGroup->hide() ;
190 subjectGroup->hide() ; 192 subjectGroup->hide() ;
191 attendeeGroup->hide() ; 193 attendeeGroup->hide() ;
192 } else { 194 } else {
193 incidenceGroup->show() ; 195 incidenceGroup->show() ;
194 subjectGroup->show() ; 196 subjectGroup->show() ;
195 attendeeGroup->show() ; 197 attendeeGroup->show() ;
196 } 198 }
197} 199}
198void SearchDialog::raiseAndSelect() 200void SearchDialog::raiseAndSelect()
199{ 201{
200 202
201 static int currentState = 0; 203 static int currentState = 0;
202 204
203 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) 205 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() )
204 currentState = 0; 206 currentState = 0;
205 int newState = 0; 207 int newState = 0;
206 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 208 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
207 newState = VIEW_J_VIEW; 209 newState = VIEW_J_VIEW;
208 } 210 }
209 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 211 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
210 newState = VIEW_T_VIEW; 212 newState = VIEW_T_VIEW;
211 } 213 }
212 else { 214 else {
213 newState = VIEW_A_VIEW; 215 newState = VIEW_A_VIEW;
214 } 216 }
215 if ( newState != currentState ) { 217 if ( newState != currentState ) {
216 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 218 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
217 if ( ! mSearchJournal->isChecked() ) { 219 if ( ! mSearchJournal->isChecked() ) {
218 mSearchJournal->setChecked( true ); 220 mSearchJournal->setChecked( true );
219 mSearchTodo->setChecked( false ); 221 mSearchTodo->setChecked( false );
220 mSearchEvent->setChecked( false ); 222 mSearchEvent->setChecked( false );
221 mSummaryCheck->setChecked( true ); 223 mSummaryCheck->setChecked( true );
222 mDescriptionCheck->setChecked( true ); 224 mDescriptionCheck->setChecked( true );
223 225
224 } 226 }
225 } 227 }
226 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 228 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
227 if ( ! mSearchTodo->isChecked() ) { 229 if ( ! mSearchTodo->isChecked() ) {
228 mSearchTodo->setChecked( true ); 230 mSearchTodo->setChecked( true );
229 mSearchJournal->setChecked( false ); 231 mSearchJournal->setChecked( false );
230 mSearchEvent->setChecked( false ); 232 mSearchEvent->setChecked( false );
231 } 233 }
232 } 234 }
233 else { 235 else {
234 if ( ! mSearchEvent->isChecked() ) { 236 if ( ! mSearchEvent->isChecked() ) {
235 mSearchEvent->setChecked( true ); 237 mSearchEvent->setChecked( true );
236 mSearchJournal->setChecked( false ); 238 mSearchJournal->setChecked( false );
237 mSearchTodo->setChecked( false ); 239 mSearchTodo->setChecked( false );
238 } 240 }
239 } 241 }
240 } 242 }
241 currentState = newState; 243 currentState = newState;
242 raise(); 244 raise();
243} 245}
244void SearchDialog::setFocusToList() 246void SearchDialog::setFocusToList()
245{ 247{
246 listView->resetFocus(); 248 listView->resetFocus();
247} 249}
248void SearchDialog::accept() 250void SearchDialog::accept()
249{ 251{
250 doSearch(); 252 doSearch();
251} 253}
252void SearchDialog::updateList() 254void SearchDialog::updateList()
253{ 255{
254 //listView->updateList(); 256 //listView->updateList();
255 if ( isVisible() ) { 257 if ( isVisible() ) {
256 updateView(); 258 updateView();
257 //qDebug("SearchDialog::updated "); 259 //qDebug("SearchDialog::updated ");
258 } 260 }
259 else { 261 else {
260 listView->clear(); 262 listView->clear();
261 //qDebug("SearchDialog::cleared "); 263 //qDebug("SearchDialog::cleared ");
262 264
263 } 265 }
264} 266}
265void SearchDialog::searchTextChanged( const QString &_text ) 267void SearchDialog::searchTextChanged( const QString &_text )
266{ 268{
267#if 0 269#if 0
268 enableButton( KDialogBase::User1, !_text.isEmpty() ); 270 enableButton( KDialogBase::User1, !_text.isEmpty() );
269#endif 271#endif
270} 272}
271 273
272void SearchDialog::doSearch() 274void SearchDialog::doSearch()
273{ 275{
274 QRegExp re; 276 QRegExp re;
275 re.setWildcard(true); // most people understand these better. 277 re.setWildcard(true); // most people understand these better.
276 re.setCaseSensitive(false); 278 re.setCaseSensitive(false);
277 QString st = searchEdit->text(); 279 QString st = searchEdit->text();
278 if ( st.right(1) != "*") 280 if ( st.right(1) != "*")
279 st += "*"; 281 st += "*";
280 re.setPattern(st); 282 re.setPattern(st);
281 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { 283 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) {
282 KMessageBox::sorry(this, 284 KMessageBox::sorry(this,
283 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); 285 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals"));
284 return; 286 return;
285 } 287 }
286 if (!re.isValid() ) { 288 if (!re.isValid() ) {
287 KMessageBox::sorry(this, 289 KMessageBox::sorry(this,
288 i18n("Invalid search expression,\ncannot perform " 290 i18n("Invalid search expression,\ncannot perform "
289 "the search.\nPlease enter a search expression\n" 291 "the search.\nPlease enter a search expression\n"
290 "using the wildcard characters\n '*' and '?'" 292 "using the wildcard characters\n '*' and '?'"
291 "where needed.")); 293 "where needed."));
292 return; 294 return;
293 } 295 }
294 search(re); 296 search(re);
295 listView->setStartDate( mStartDate->date() ); 297 listView->setStartDate( mStartDate->date() );
296 listView->showEvents(mMatchedEvents); 298 listView->showEvents(mMatchedEvents);
297 listView->addTodos(mMatchedTodos); 299 listView->addTodos(mMatchedTodos);
298 listView->addJournals(mMatchedJournals); 300 listView->addJournals(mMatchedJournals);
299 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 301 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
300 setCaption(i18n("No items found. Use '*' and '?' where needed.")); 302 setCaption(i18n("No items found. Use '*' and '?' where needed."));
301 } else { 303 } else {
302 QString mess; 304 QString mess;
303 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 305 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
304 setCaption( i18n("KO/Pi Find: ") + mess); 306 setCaption( i18n("KO/Pi Find: ") + mess);
305 307
306 } 308 }
307 searchEdit->setFocus(); 309 searchEdit->setFocus();
308} 310}
309void SearchDialog::updateConfig() 311void SearchDialog::updateConfig()
310{ 312{
311 listView->updateConfig(); 313 listView->updateConfig();
312} 314}
313void SearchDialog::updateView() 315void SearchDialog::updateView()
314{ 316{
315 //qDebug("SearchDialog::updateView() %d ", isVisible()); 317 //qDebug("SearchDialog::updateView() %d ", isVisible());
316 QRegExp re; 318 QRegExp re;
317 re.setWildcard(true); // most people understand these better. 319 re.setWildcard(true); // most people understand these better.
318 re.setCaseSensitive(false); 320 re.setCaseSensitive(false);
319 QString st = searchEdit->text(); 321 QString st = searchEdit->text();
320 if ( st.right(1) != "*") 322 if ( st.right(1) != "*")
321 st += "*"; 323 st += "*";
322 re.setPattern(st); 324 re.setPattern(st);
323 mMatchedEvents.clear(); 325 mMatchedEvents.clear();
324 mMatchedTodos.clear(); 326 mMatchedTodos.clear();
325 mMatchedJournals.clear(); 327 mMatchedJournals.clear();
326 if (re.isValid()) { 328 if (re.isValid()) {
327 search(re); 329 search(re);
328 } 330 }
329 listView->setStartDate( mStartDate->date() ); 331 listView->setStartDate( mStartDate->date() );
330 listView->showEvents(mMatchedEvents); 332 listView->showEvents(mMatchedEvents);
331 listView->addTodos(mMatchedTodos); 333 listView->addTodos(mMatchedTodos);
332 listView->addJournals(mMatchedJournals); 334 listView->addJournals(mMatchedJournals);
333} 335}
334 336
335void SearchDialog::search(const QRegExp &re) 337void SearchDialog::search(const QRegExp &re)
336{ 338{
337 QPtrList<Event> events; 339 QPtrList<Event> events;
338 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { 340 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
339 if ( mRefineItems->isChecked() ) events = mMatchedEvents; 341 if ( mRefineItems->isChecked() ) events = mMatchedEvents;
340 mMatchedEvents.clear(); 342 mMatchedEvents.clear();
341 } 343 }
342 if ( mSearchEvent->isChecked() ) { 344 if ( mSearchEvent->isChecked() ) {
343 if ( !mRefineItems->isChecked() ) 345 if ( !mRefineItems->isChecked() )
344 events = mCalendar->events( mStartDate->date(), 346 events = mCalendar->events( mStartDate->date(),
345 mEndDate->date(), 347 mEndDate->date(),
346 false /*mInclusiveCheck->isChecked()*/ ); 348 false /*mInclusiveCheck->isChecked()*/ );
347 349
348 350
349 Event *ev; 351 Event *ev;
350 for(ev=events.first();ev;ev=events.next()) { 352 for(ev=events.first();ev;ev=events.next()) {
351 if (mSummaryCheck->isChecked()) { 353 if (mSummaryCheck->isChecked()) {
352#if QT_VERSION >= 0x030000 354#if QT_VERSION >= 0x030000
353 if (re.search(ev->summary()) != -1) 355 if (re.search(ev->summary()) != -1)
354#else 356#else
355 if (re.match(ev->summary()) != -1) 357 if (re.match(ev->summary()) != -1)
356#endif 358#endif
357 { 359 {
358 if ( mSubItems->isChecked() ) 360 if ( mSubItems->isChecked() )
359 mMatchedEvents.remove(ev); 361 mMatchedEvents.remove(ev);
360 else { 362 else {
361 if ( !mMatchedEvents.contains( ev ) ) 363 if ( !mMatchedEvents.contains( ev ) )
362 mMatchedEvents.append(ev); 364 mMatchedEvents.append(ev);
363 } 365 }
364 continue; 366 continue;
365 } 367 }
366#if QT_VERSION >= 0x030000 368#if QT_VERSION >= 0x030000
367 if (re.search(ev->location()) != -1) 369 if (re.search(ev->location()) != -1)
368#else 370#else
369 if (re.match(ev->location()) != -1) 371 if (re.match(ev->location()) != -1)
370#endif 372#endif
371 { 373 {
372 if ( mSubItems->isChecked() ) 374 if ( mSubItems->isChecked() )
373 mMatchedEvents.remove(ev); 375 mMatchedEvents.remove(ev);
374 else{ 376 else{
375 if ( !mMatchedEvents.contains( ev ) ) 377 if ( !mMatchedEvents.contains( ev ) )
376 mMatchedEvents.append(ev); 378 mMatchedEvents.append(ev);
377 } 379 }
378 continue; 380 continue;
379 } 381 }
380 } 382 }
381 if (mDescriptionCheck->isChecked()) { 383 if (mDescriptionCheck->isChecked()) {
382#if QT_VERSION >= 0x030000 384#if QT_VERSION >= 0x030000
383 if (re.search(ev->description()) != -1) 385 if (re.search(ev->description()) != -1)
384#else 386#else
385 if (re.match(ev->description()) != -1) 387 if (re.match(ev->description()) != -1)
386#endif 388#endif
387 { 389 {
388 if ( mSubItems->isChecked() ) 390 if ( mSubItems->isChecked() )
389 mMatchedEvents.remove(ev); 391 mMatchedEvents.remove(ev);
390 else{ 392 else{
391 if ( !mMatchedEvents.contains( ev ) ) 393 if ( !mMatchedEvents.contains( ev ) )
392 mMatchedEvents.append(ev); 394 mMatchedEvents.append(ev);
393 } 395 }
394 continue; 396 continue;
395 } 397 }
396 } 398 }
397 if (mCategoryCheck->isChecked()) { 399 if (mCategoryCheck->isChecked()) {
398#if QT_VERSION >= 0x030000 400#if QT_VERSION >= 0x030000
399 if (re.search(ev->categoriesStr()) != -1) 401 if (re.search(ev->categoriesStr()) != -1)
400#else 402#else
401 if (re.match(ev->categoriesStr()) != -1) 403 if (re.match(ev->categoriesStr()) != -1)
402#endif 404#endif
403 { 405 {
404 406
405 if ( mSubItems->isChecked() ) 407 if ( mSubItems->isChecked() )
406 mMatchedEvents.remove(ev); 408 mMatchedEvents.remove(ev);
407 else{ 409 else{
408 if ( !mMatchedEvents.contains( ev ) ) 410 if ( !mMatchedEvents.contains( ev ) )
409 mMatchedEvents.append(ev); 411 mMatchedEvents.append(ev);
410 } 412 }
411 continue; 413 continue;
412 } 414 }
413 } 415 }
414 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 416 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
415 QPtrList<Attendee> tmpAList = ev->attendees(); 417 QPtrList<Attendee> tmpAList = ev->attendees();
416 Attendee *a; 418 Attendee *a;
417 for (a = tmpAList.first(); a; a = tmpAList.next()) { 419 for (a = tmpAList.first(); a; a = tmpAList.next()) {
418 if (mSearchAName->isChecked()) { 420 if (mSearchAName->isChecked()) {
419#if QT_VERSION >= 0x030000 421#if QT_VERSION >= 0x030000
420 if (re.search(a->name()) != -1) 422 if (re.search(a->name()) != -1)
421#else 423#else
422 if (re.match(a->name()) != -1) 424 if (re.match(a->name()) != -1)
423#endif 425#endif
424 { 426 {
425 if ( mSubItems->isChecked() ) 427 if ( mSubItems->isChecked() )
426 mMatchedEvents.remove(ev); 428 mMatchedEvents.remove(ev);
427 else{ 429 else{
428 if ( !mMatchedEvents.contains( ev ) ) 430 if ( !mMatchedEvents.contains( ev ) )
429 mMatchedEvents.append(ev); 431 mMatchedEvents.append(ev);
430 } 432 }
431 break; 433 break;
432 } 434 }
433 } 435 }
434 if (mSearchAEmail->isChecked()) { 436 if (mSearchAEmail->isChecked()) {
435#if QT_VERSION >= 0x030000 437#if QT_VERSION >= 0x030000
436 if (re.search(a->email()) != -1) 438 if (re.search(a->email()) != -1)
437#else 439#else
438 if (re.match(a->email()) != -1) 440 if (re.match(a->email()) != -1)
439#endif 441#endif
440 { 442 {
441 if ( mSubItems->isChecked() ) 443 if ( mSubItems->isChecked() )
442 mMatchedEvents.remove(ev); 444 mMatchedEvents.remove(ev);
443 else{ 445 else{
444 if ( !mMatchedEvents.contains( ev ) ) 446 if ( !mMatchedEvents.contains( ev ) )
445 mMatchedEvents.append(ev); 447 mMatchedEvents.append(ev);
446 } 448 }
447 break; 449 break;
448 } 450 }
449 } 451 }
450 } 452 }
451 } 453 }
452 } 454 }
453 } 455 }
454 QPtrList<Todo> todos; 456 QPtrList<Todo> todos;
455 457
456 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { 458 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
457 if ( mRefineItems->isChecked() ) todos = mMatchedTodos ; 459 if ( mRefineItems->isChecked() ) todos = mMatchedTodos ;
458 mMatchedTodos.clear(); 460 mMatchedTodos.clear();
459 } 461 }
460 462
461 if ( mSearchTodo->isChecked() ) { 463 if ( mSearchTodo->isChecked() ) {
462 if ( !mRefineItems->isChecked() ) todos = mCalendar->todos( ); 464 if ( !mRefineItems->isChecked() ) todos = mCalendar->todos( );
463 Todo *tod; 465 Todo *tod;
464 for(tod=todos.first();tod;tod=todos.next()) { 466 for(tod=todos.first();tod;tod=todos.next()) {
465 if (mSummaryCheck->isChecked()) { 467 if (mSummaryCheck->isChecked()) {
466#if QT_VERSION >= 0x030000 468#if QT_VERSION >= 0x030000
467 if (re.search(tod->summary()) != -1) 469 if (re.search(tod->summary()) != -1)
468#else 470#else
469 if (re.match(tod->summary()) != -1) 471 if (re.match(tod->summary()) != -1)
470#endif 472#endif
471 { 473 {
472 if ( mSubItems->isChecked() ) 474 if ( mSubItems->isChecked() )
473 mMatchedTodos.remove(tod); 475 mMatchedTodos.remove(tod);
474 else if (!mMatchedTodos.contains( tod )) 476 else if (!mMatchedTodos.contains( tod ))
475 mMatchedTodos.append(tod); 477 mMatchedTodos.append(tod);
476 continue; 478 continue;
477 } 479 }
478 } 480 }
479 if (mDescriptionCheck->isChecked()) { 481 if (mDescriptionCheck->isChecked()) {
480#if QT_VERSION >= 0x030000 482#if QT_VERSION >= 0x030000
481 if (re.search(tod->description()) != -1) 483 if (re.search(tod->description()) != -1)
482#else 484#else
483 if (re.match(tod->description()) != -1) 485 if (re.match(tod->description()) != -1)
484#endif 486#endif
485 { 487 {
486 if ( mSubItems->isChecked() ) 488 if ( mSubItems->isChecked() )
487 mMatchedTodos.remove(tod); 489 mMatchedTodos.remove(tod);
488 else if (!mMatchedTodos.contains( tod )) 490 else if (!mMatchedTodos.contains( tod ))
489 mMatchedTodos.append(tod); 491 mMatchedTodos.append(tod);
490 continue; 492 continue;
491 } 493 }
492 } 494 }
493 if (mCategoryCheck->isChecked()) { 495 if (mCategoryCheck->isChecked()) {
494#if QT_VERSION >= 0x030000 496#if QT_VERSION >= 0x030000
495 if (re.search(tod->categoriesStr()) != -1) 497 if (re.search(tod->categoriesStr()) != -1)
496#else 498#else
497 if (re.match(tod->categoriesStr()) != -1) 499 if (re.match(tod->categoriesStr()) != -1)
498#endif 500#endif
499 { 501 {
500 if ( mSubItems->isChecked() ) 502 if ( mSubItems->isChecked() )
501 mMatchedTodos.remove(tod); 503 mMatchedTodos.remove(tod);
502 else if (!mMatchedTodos.contains( tod )) 504 else if (!mMatchedTodos.contains( tod ))
503 mMatchedTodos.append(tod); 505 mMatchedTodos.append(tod);
504 continue; 506 continue;
505 } 507 }
506 } 508 }
507 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 509 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
508 QPtrList<Attendee> tmpAList = tod->attendees(); 510 QPtrList<Attendee> tmpAList = tod->attendees();
509 Attendee *a; 511 Attendee *a;
510 for (a = tmpAList.first(); a; a = tmpAList.next()) { 512 for (a = tmpAList.first(); a; a = tmpAList.next()) {
511 if (mSearchAName->isChecked()) { 513 if (mSearchAName->isChecked()) {
512#if QT_VERSION >= 0x030000 514#if QT_VERSION >= 0x030000
513 if (re.search(a->name()) != -1) 515 if (re.search(a->name()) != -1)
514#else 516#else
515 if (re.match(a->name()) != -1) 517 if (re.match(a->name()) != -1)
516#endif 518#endif
517 { 519 {
518 if ( mSubItems->isChecked() ) 520 if ( mSubItems->isChecked() )
519 mMatchedTodos.remove(tod); 521 mMatchedTodos.remove(tod);
520 else if (!mMatchedTodos.contains( tod )) 522 else if (!mMatchedTodos.contains( tod ))
521 mMatchedTodos.append(tod); 523 mMatchedTodos.append(tod);
522 break; 524 break;
523 } 525 }
524 } 526 }
525 if (mSearchAEmail->isChecked()) { 527 if (mSearchAEmail->isChecked()) {
526#if QT_VERSION >= 0x030000 528#if QT_VERSION >= 0x030000
527 if (re.search(a->email()) != -1) 529 if (re.search(a->email()) != -1)
528#else 530#else
529 if (re.match(a->email()) != -1) 531 if (re.match(a->email()) != -1)
530#endif 532#endif
531 { 533 {
532 if ( mSubItems->isChecked() ) 534 if ( mSubItems->isChecked() )
533 mMatchedTodos.remove(tod); 535 mMatchedTodos.remove(tod);
534 else if (!mMatchedTodos.contains( tod )) 536 else if (!mMatchedTodos.contains( tod ))
535 mMatchedTodos.append(tod); 537 mMatchedTodos.append(tod);
536 break; 538 break;
537 } 539 }
538 } 540 }
539 } 541 }
540 } 542 }
541 } 543 }
542 } 544 }
543 545
544 QPtrList<Journal> journals; 546 QPtrList<Journal> journals;
545 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { 547 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
546 if ( mRefineItems->isChecked() ) journals = mMatchedJournals ; 548 if ( mRefineItems->isChecked() ) journals = mMatchedJournals ;
547 mMatchedJournals.clear(); 549 mMatchedJournals.clear();
548 } 550 }
549 if (mSearchJournal->isChecked() ) { 551 if (mSearchJournal->isChecked() ) {
550 if ( ! mRefineItems->isChecked() ) journals = mCalendar->journals(); 552 if ( ! mRefineItems->isChecked() ) journals = mCalendar->journals();
551 Journal* journ; 553 Journal* journ;
552 554
553 for(journ=journals.first();journ;journ=journals.next()) { 555 for(journ=journals.first();journ;journ=journals.next()) {
554 if ( journ->dtStart().date() <= mEndDate->date() 556 if ( journ->dtStart().date() <= mEndDate->date()
555 &&journ->dtStart().date() >= mStartDate->date()) { 557 &&journ->dtStart().date() >= mStartDate->date()) {
556 if (mDescriptionCheck->isChecked()) { 558 if (mDescriptionCheck->isChecked()) {
557#if QT_VERSION >= 0x030000 559#if QT_VERSION >= 0x030000
558 if (re.search(journ->description()) != -1) 560 if (re.search(journ->description()) != -1)
559#else 561#else
560 if (re.match(journ->description()) != -1) 562 if (re.match(journ->description()) != -1)
561#endif 563#endif
562 { 564 {
563 if ( mSubItems->isChecked() ) 565 if ( mSubItems->isChecked() )
564 mMatchedJournals.remove(journ); 566 mMatchedJournals.remove(journ);
565 else if (!mMatchedJournals.contains( journ )) 567 else if (!mMatchedJournals.contains( journ ))
566 mMatchedJournals.append(journ); 568 mMatchedJournals.append(journ);
567 continue; 569 continue;
568 } 570 }
569 } 571 }
570 if (mSummaryCheck->isChecked()) { 572 if (mSummaryCheck->isChecked()) {
571#if QT_VERSION >= 0x030000 573#if QT_VERSION >= 0x030000
572 if (re.search(journ->summary()) != -1) 574 if (re.search(journ->summary()) != -1)
573#else 575#else
574 if (re.match(journ->summary()) != -1) 576 if (re.match(journ->summary()) != -1)
575#endif 577#endif
576 { 578 {
577 if ( mSubItems->isChecked() ) 579 if ( mSubItems->isChecked() )
578 mMatchedJournals.remove(journ); 580 mMatchedJournals.remove(journ);
579 else if (!mMatchedJournals.contains( journ )) 581 else if (!mMatchedJournals.contains( journ ))
580 mMatchedJournals.append(journ); 582 mMatchedJournals.append(journ);
581 continue; 583 continue;
582 } 584 }
583 } 585 }
584 } 586 }
585 } 587 }
586 } 588 }
587 if ( mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() < 1 ) { 589 if ( mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() < 1 ) {
588 qDebug("count %d ", mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() ); 590 qDebug("count %d ", mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() );
589 if ( mRefineItems->isChecked() ) 591 if ( mRefineItems->isChecked() )
590 mRefineItems->setChecked( false ); 592 mRefineItems->setChecked( false );
591 else if ( mSubItems->isChecked() ) 593 else if ( mSubItems->isChecked() )
592 mSubItems->setChecked( false ); 594 mSubItems->setChecked( false );
593 } 595 }
594} 596}
595 597
596void SearchDialog::keyPressEvent ( QKeyEvent *e) 598void SearchDialog::keyPressEvent ( QKeyEvent *e)
597{ 599{
598 switch ( e->key() ) { 600 switch ( e->key() ) {
599 case Qt::Key_Escape: 601 case Qt::Key_Escape:
600 close(); 602 close();
601 break; 603 break;
602 case Qt::Key_F: 604 case Qt::Key_F:
603 if ( e->state() == Qt::ControlButton ) { 605 if ( e->state() == Qt::ControlButton ) {
604 606
605 } 607 }
606 break; 608 break;
607 case Qt::Key_Return: 609 case Qt::Key_Return:
608 case Qt::Key_Enter: 610 case Qt::Key_Enter:
609 doSearch(); 611 doSearch();
610 break; 612 break;
611 613
612 default: 614 default:
613 e->ignore(); 615 e->ignore();
614 } 616 }
615} 617}
616 618
617//mMatchedJournals; 619//mMatchedJournals;