summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventviewerdialog.cpp6
-rw-r--r--korganizer/kolistview.cpp2
-rw-r--r--korganizer/searchdialog.cpp9
-rw-r--r--korganizer/searchdialog.h4
4 files changed, 18 insertions, 3 deletions
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp
index e2c8e6e..f606124 100644
--- a/korganizer/koeventviewerdialog.cpp
+++ b/korganizer/koeventviewerdialog.cpp
@@ -1,292 +1,298 @@
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 19
20#include <klocale.h> 20#include <klocale.h>
21 21
22#include <libkcal/event.h> 22#include <libkcal/event.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qpushbutton.h> 24#include <qpushbutton.h>
25 25
26#include "koeventviewer.h" 26#include "koeventviewer.h"
27#include "koprefs.h" 27#include "koprefs.h"
28#include <libkcal/todo.h> 28#include <libkcal/todo.h>
29#include "qapp.h" 29#include "qapp.h"
30 30
31#include "koeventviewerdialog.h" 31#include "koeventviewerdialog.h"
32extern int globalFlagBlockAgenda; 32extern int globalFlagBlockAgenda;
33 33
34KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) 34KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name)
35 : KDialogBase(parent,name, 35 : KDialogBase(parent,name,
36#ifndef DESKTOP_VERSION 36#ifndef DESKTOP_VERSION
37 true , 37 true ,
38#else 38#else
39 false, 39 false,
40#endif 40#endif
41 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) 41 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda"))
42{ 42{
43 sendSignalViewerClosed = true; 43 sendSignalViewerClosed = true;
44 mEventViewer = new KOEventViewer(this); 44 mEventViewer = new KOEventViewer(this);
45 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 45 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
46 setMainWidget(mEventViewer); 46 setMainWidget(mEventViewer);
47 setButtonText(Ok, i18n("Edit") ); 47 setButtonText(Ok, i18n("Edit") );
48 48
49 QObject::connect(findButton( Ok ),SIGNAL(clicked()), 49 QObject::connect(findButton( Ok ),SIGNAL(clicked()),
50 SLOT(editIncidence())); 50 SLOT(editIncidence()));
51 QObject::connect(this,SIGNAL(user1Clicked()), 51 QObject::connect(this,SIGNAL(user1Clicked()),
52 SLOT(showIncidence())); 52 SLOT(showIncidence()));
53 mIncidence = 0; 53 mIncidence = 0;
54 // TODO: Set a sensible size (based on the content?). 54 // TODO: Set a sensible size (based on the content?).
55 //showMaximized(); 55 //showMaximized();
56 //qDebug("++++++++++++KOEventViewerDialog() "); 56 //qDebug("++++++++++++KOEventViewerDialog() ");
57 // if ( KOPrefs::instance()->mCompactDialogs ) { 57 // if ( KOPrefs::instance()->mCompactDialogs ) {
58// setFixedSize( 240,284 ); 58// setFixedSize( 240,284 );
59// move( 0, 15 ); 59// move( 0, 15 );
60// } else { 60// } else {
61// setMinimumSize(300,200); 61// setMinimumSize(300,200);
62// resize(320,300); 62// resize(320,300);
63// } 63// }
64 mSyncMode = false; 64 mSyncMode = false;
65 mSyncResult = 0; 65 mSyncResult = 0;
66 66
67} 67}
68 68
69KOEventViewerDialog::~KOEventViewerDialog() 69KOEventViewerDialog::~KOEventViewerDialog()
70{ 70{
71 //qDebug("-------~KOEventViewerDialog() "); 71 //qDebug("-------~KOEventViewerDialog() ");
72} 72}
73void KOEventViewerDialog::showMe() 73void KOEventViewerDialog::showMe()
74{ 74{
75 75
76#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
77 int x,y,w,h; 77 int x,y,w,h;
78 x = geometry().x(); 78 x = geometry().x();
79 y = geometry().y(); 79 y = geometry().y();
80 w = width(); 80 w = width();
81 h = height(); 81 h = height();
82 show(); 82 show();
83 setGeometry(x,y,w,h); 83 setGeometry(x,y,w,h);
84#else 84#else
85 showMaximized(); 85 showMaximized();
86#endif 86#endif
87 raise(); 87 raise();
88 setActiveWindow(); 88 setActiveWindow();
89 mEventViewer->setFocus(); 89 mEventViewer->setFocus();
90 90
91} 91}
92void KOEventViewerDialog::setSyncMode( bool b ) 92void KOEventViewerDialog::setSyncMode( bool b )
93{ 93{
94 mSyncMode = b; 94 mSyncMode = b;
95 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); 95 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode );
96 if ( mSyncMode ) { 96 if ( mSyncMode ) {
97 findButton( Close )->setText( i18n("Cancel Sync")); 97 findButton( Close )->setText( i18n("Cancel Sync"));
98 findButton( Ok )->setText( i18n("Remote")); 98 findButton( Ok )->setText( i18n("Remote"));
99 findButton( User1 )->setText( i18n("Local")); 99 findButton( User1 )->setText( i18n("Local"));
100 } else { 100 } else {
101 findButton( Close )->setText( i18n("Close")); 101 findButton( Close )->setText( i18n("Close"));
102 findButton( Ok )->setText( i18n("Edit")); 102 findButton( Ok )->setText( i18n("Edit"));
103 findButton( User1 )->setText( i18n("Agenda")); 103 findButton( User1 )->setText( i18n("Agenda"));
104 } 104 }
105 mEventViewer->setSyncMode( b ); 105 mEventViewer->setSyncMode( b );
106} 106}
107void KOEventViewerDialog::setColorMode( int m ) 107void KOEventViewerDialog::setColorMode( int m )
108{ 108{
109 mEventViewer->setColorMode( m ); 109 mEventViewer->setColorMode( m );
110} 110}
111int KOEventViewerDialog::executeS( bool local ) 111int KOEventViewerDialog::executeS( bool local )
112{ 112{
113 mSyncResult = 3; 113 mSyncResult = 3;
114 if ( local ) 114 if ( local )
115 findButton( User1 )->setFocus(); 115 findButton( User1 )->setFocus();
116 else 116 else
117 findButton( Ok )->setFocus(); 117 findButton( Ok )->setFocus();
118 exec(); 118 exec();
119 return mSyncResult; 119 return mSyncResult;
120} 120}
121 121
122void KOEventViewerDialog::updateConfig() 122void KOEventViewerDialog::updateConfig()
123{ 123{
124 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 124 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
125 125
126} 126}
127void KOEventViewerDialog::setEvent(Event *event) 127void KOEventViewerDialog::setEvent(Event *event)
128{ 128{
129 mEventViewer->setEvent(event); 129 mEventViewer->setEvent(event);
130 mIncidence = event; 130 mIncidence = event;
131 mEventViewer->setFocus(); 131 mEventViewer->setFocus();
132 //findButton( Close )->setFocus(); 132 //findButton( Close )->setFocus();
133 if ( !mSyncMode ) { 133 if ( !mSyncMode ) {
134 findButton( User1 )->setText( i18n("Agenda")); 134 findButton( User1 )->setText( i18n("Agenda"));
135 } 135 }
136} 136}
137void KOEventViewerDialog::setIncidence(Incidence *in ) 137void KOEventViewerDialog::setIncidence(Incidence *in )
138{ 138{
139 if ( in->type() == "Event" ) 139 if ( in->type() == "Event" )
140 setEvent( (Event*) in ); 140 setEvent( (Event*) in );
141 else if ( in->type() =="Todo" ) 141 else if ( in->type() =="Todo" )
142 setTodo( (Todo*) in ); 142 setTodo( (Todo*) in );
143 else if ( in->type() =="Journal" ) 143 else if ( in->type() =="Journal" )
144 setJournal( (Journal*) in ); 144 setJournal( (Journal*) in );
145} 145}
146void KOEventViewerDialog::addIncidence(Incidence *in) 146void KOEventViewerDialog::addIncidence(Incidence *in)
147{ 147{
148 if ( in->type() == "Event" ) 148 if ( in->type() == "Event" )
149 addEvent( (Event*) in ); 149 addEvent( (Event*) in );
150 else if ( in->type() =="Todo" ) 150 else if ( in->type() =="Todo" )
151 mEventViewer->setTodo( (Todo*) in, false ); 151 mEventViewer->setTodo( (Todo*) in, false );
152 else if ( in->type() =="Journal" ) 152 else if ( in->type() =="Journal" )
153 mEventViewer->setJournal( (Journal*) in, false ); 153 mEventViewer->setJournal( (Journal*) in, false );
154 if ( mSyncMode ) { 154 if ( mSyncMode ) {
155 findButton( User1 )->setFocus(); 155 findButton( User1 )->setFocus();
156 setCaption(i18n("Conflict! Please choose entry")); 156 setCaption(i18n("Conflict! Please choose entry"));
157 } 157 }
158} 158}
159 159
160void KOEventViewerDialog::addEvent(Event *event) 160void KOEventViewerDialog::addEvent(Event *event)
161{ 161{
162 mEventViewer->addEvent(event); 162 mEventViewer->addEvent(event);
163 mIncidence = event; 163 mIncidence = event;
164 mEventViewer->setFocus(); 164 mEventViewer->setFocus();
165 //findButton( Close )->setFocus(); 165 //findButton( Close )->setFocus();
166 if ( !mSyncMode ) { 166 if ( !mSyncMode ) {
167 findButton( User1 )->setText( i18n("Agenda")); 167 findButton( User1 )->setText( i18n("Agenda"));
168 } 168 }
169} 169}
170 170
171void KOEventViewerDialog::setTodo(Todo *event) 171void KOEventViewerDialog::setTodo(Todo *event)
172{ 172{
173 mEventViewer->setTodo(event); 173 mEventViewer->setTodo(event);
174 mIncidence = (Incidence*)event; 174 mIncidence = (Incidence*)event;
175 mEventViewer->setFocus(); 175 mEventViewer->setFocus();
176 //findButton( Close )->setFocus(); 176 //findButton( Close )->setFocus();
177 if ( !mSyncMode ) { 177 if ( !mSyncMode ) {
178 findButton( User1 )->setText( i18n("Set complete")); 178 findButton( User1 )->setText( i18n("Set complete"));
179 } 179 }
180} 180}
181void KOEventViewerDialog::setJournal(Journal *j) 181void KOEventViewerDialog::setJournal(Journal *j)
182{ 182{
183 mEventViewer->setJournal(j); 183 mEventViewer->setJournal(j);
184 mIncidence = (Incidence*)j; 184 mIncidence = (Incidence*)j;
185 mEventViewer->setFocus(); 185 mEventViewer->setFocus();
186 //findButton( Close )->setFocus(); 186 //findButton( Close )->setFocus();
187 if ( !mSyncMode ) { 187 if ( !mSyncMode ) {
188 findButton( User1 )->setText( i18n("Agenda")); 188 findButton( User1 )->setText( i18n("Agenda"));
189 } 189 }
190} 190}
191 191
192void KOEventViewerDialog::addText(QString text) 192void KOEventViewerDialog::addText(QString text)
193{ 193{
194 mEventViewer->addText(text); 194 mEventViewer->addText(text);
195 mEventViewer->setFocus(); 195 mEventViewer->setFocus();
196 //findButton( Close )->setFocus(); 196 //findButton( Close )->setFocus();
197} 197}
198void KOEventViewerDialog::editIncidence() 198void KOEventViewerDialog::editIncidence()
199{ 199{
200 sendSignalViewerClosed = false; 200 sendSignalViewerClosed = false;
201 if ( mSyncMode ) { 201 if ( mSyncMode ) {
202 mSyncResult = 2; 202 mSyncResult = 2;
203 accept(); 203 accept();
204 return; 204 return;
205 } 205 }
206 if ( mIncidence ){ 206 if ( mIncidence ){
207#ifndef DESKTOP_VERSION 207#ifndef DESKTOP_VERSION
208 hide(); 208 hide();
209#endif 209#endif
210 emit editIncidence( mIncidence ); 210 emit editIncidence( mIncidence );
211 } 211 }
212} 212}
213void KOEventViewerDialog::showIncidence() 213void KOEventViewerDialog::showIncidence()
214{ 214{
215 sendSignalViewerClosed = false; 215 sendSignalViewerClosed = false;
216 if ( mSyncMode ) { 216 if ( mSyncMode ) {
217 mSyncResult = 1; 217 mSyncResult = 1;
218 accept(); 218 accept();
219 return; 219 return;
220 } 220 }
221 221
222 if ( mIncidence ){ 222 if ( mIncidence ){
223#ifndef DESKTOP_VERSION 223#ifndef DESKTOP_VERSION
224 hide(); 224 hide();
225#endif 225#endif
226 QDate date; 226 QDate date;
227 if ( mIncidence->type() == "Todo" ) { 227 if ( mIncidence->type() == "Todo" ) {
228 /* 228 /*
229 if ( ((Todo*)mIncidence)->hasDueDate() ) 229 if ( ((Todo*)mIncidence)->hasDueDate() )
230 date = ((Todo*)mIncidence)->dtDue().date(); 230 date = ((Todo*)mIncidence)->dtDue().date();
231 else { 231 else {
232 globalFlagBlockAgenda = 2; 232 globalFlagBlockAgenda = 2;
233 emit showAgendaView( false ); 233 emit showAgendaView( false );
234 return; 234 return;
235 } 235 }
236 */ 236 */
237 ((Todo*)mIncidence)->setCompleted( true ); 237 ((Todo*)mIncidence)->setCompleted( true );
238 ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); 238 ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() );
239 hide(); 239 hide();
240 emit todoCompleted(((Todo*)mIncidence)); 240 emit todoCompleted(((Todo*)mIncidence));
241 return; 241 return;
242 242
243 } else 243 } else
244 date = mIncidence->dtStart().date(); 244 date = mIncidence->dtStart().date();
245 globalFlagBlockAgenda = 1; 245 globalFlagBlockAgenda = 1;
246 emit showAgendaView( false ); 246 emit showAgendaView( false );
247 globalFlagBlockAgenda = 2; 247 globalFlagBlockAgenda = 2;
248 emit jumpToTime( date ); 248 emit jumpToTime( date );
249 } 249 }
250} 250}
251void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) 251void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e )
252{ 252{
253 switch ( e->key() ) { 253 switch ( e->key() ) {
254 254
255 case Qt::Key_A : 255 case Qt::Key_A :
256 case Qt::Key_L : 256 case Qt::Key_L :
257 showIncidence(); 257 showIncidence();
258 break; 258 break;
259 case Qt::Key_E : 259 case Qt::Key_E :
260 case Qt::Key_R : 260 case Qt::Key_R :
261 editIncidence(); 261 editIncidence();
262 break; 262 break;
263 case Qt::Key_C: 263 case Qt::Key_C:
264 case Qt::Key_Escape: 264 case Qt::Key_Escape:
265 sendSignalViewerClosed = true;
265 close(); 266 close();
266 break; 267 break;
267 case Qt::Key_I: 268 case Qt::Key_I:
269#ifndef DESKTOP_VERSION
270 sendSignalViewerClosed = true;
271 close();
272#else
268 sendSignalViewerClosed = true; 273 sendSignalViewerClosed = true;
269 slotViewerClosed(); 274 slotViewerClosed();
270 //accept(); 275 //accept();
276#endif
271 break; 277 break;
272 default: 278 default:
273 KDialogBase::keyPressEvent ( e ); 279 KDialogBase::keyPressEvent ( e );
274 break; 280 break;
275 } 281 }
276 282
277} 283}
278void KOEventViewerDialog::hideEvent ( QHideEvent * e ) 284void KOEventViewerDialog::hideEvent ( QHideEvent * e )
279{ 285{
280 KDialogBase::hideEvent ( e ); 286 KDialogBase::hideEvent ( e );
281 QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); 287 QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) );
282} 288}
283 289
284void KOEventViewerDialog::slotViewerClosed() 290void KOEventViewerDialog::slotViewerClosed()
285{ 291{
286 if ( sendSignalViewerClosed ) { 292 if ( sendSignalViewerClosed ) {
287 //qDebug("KOEventViewerDialog::hideEvent "); 293 //qDebug("KOEventViewerDialog::hideEvent ");
288 emit signalViewerClosed(); 294 emit signalViewerClosed();
289 } 295 }
290 sendSignalViewerClosed = true; 296 sendSignalViewerClosed = true;
291} 297}
292 298
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 6acee75..710a9f9 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -574,617 +574,617 @@ void KOListView::saveDescriptionToFile()
574 ++icount; 574 ++icount;
575 575
576 } else { 576 } else {
577 if ( !incidence->description().isEmpty() ) { 577 if ( !incidence->description().isEmpty() ) {
578 text += "\n************************************\n"; 578 text += "\n************************************\n";
579 if ( incidence->type() == "Todo" ) 579 if ( incidence->type() == "Todo" )
580 text += i18n("To-Do: "); 580 text += i18n("To-Do: ");
581 text += incidence->summary(); 581 text += incidence->summary();
582 if ( incidence->hasStartDate() ) 582 if ( incidence->hasStartDate() )
583 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 583 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
584 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 584 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
585 if ( !incidence->location().isEmpty() ) 585 if ( !incidence->location().isEmpty() )
586 text += "\n" +i18n("Location: ") + incidence->location(); 586 text += "\n" +i18n("Location: ") + incidence->location();
587 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 587 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
588 ++icount; 588 ++icount;
589 589
590 } 590 }
591 } 591 }
592 incidence = delSel.next(); 592 incidence = delSel.next();
593 } 593 }
594 QFile file( fn ); 594 QFile file( fn );
595 if (!file.open( IO_WriteOnly ) ) { 595 if (!file.open( IO_WriteOnly ) ) {
596 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 596 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
597 return; 597 return;
598 } 598 }
599 QTextStream ts( &file ); 599 QTextStream ts( &file );
600 ts << text; 600 ts << text;
601 file.close(); 601 file.close();
602 //qDebug("%s ", text.latin1()); 602 //qDebug("%s ", text.latin1());
603 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 603 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
604 KOPrefs::instance()->mLastSaveFile = fn; 604 KOPrefs::instance()->mLastSaveFile = fn;
605 topLevelWidget()->setCaption(mes); 605 topLevelWidget()->setCaption(mes);
606 } 606 }
607 } 607 }
608} 608}
609void KOListView::saveToFile() 609void KOListView::saveToFile()
610{ 610{
611 611
612 int icount = 0; 612 int icount = 0;
613 QPtrList<Incidence> delSel ; 613 QPtrList<Incidence> delSel ;
614 QListViewItem *item = mListView->firstChild (); 614 QListViewItem *item = mListView->firstChild ();
615 while ( item ) { 615 while ( item ) {
616 if ( item->isSelected() ) { 616 if ( item->isSelected() ) {
617 delSel.append(((KOListViewItem *)item)->data()); 617 delSel.append(((KOListViewItem *)item)->data());
618 ++icount; 618 ++icount;
619 } 619 }
620 620
621 item = item->nextSibling(); 621 item = item->nextSibling();
622 } 622 }
623 if ( icount ) { 623 if ( icount ) {
624 QString fn = KOPrefs::instance()->mLastSaveFile; 624 QString fn = KOPrefs::instance()->mLastSaveFile;
625 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 625 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
626 626
627 if ( fn == "" ) 627 if ( fn == "" )
628 return; 628 return;
629 QFileInfo info; 629 QFileInfo info;
630 info.setFile( fn ); 630 info.setFile( fn );
631 QString mes; 631 QString mes;
632 bool createbup = true; 632 bool createbup = true;
633 if ( info. exists() ) { 633 if ( info. exists() ) {
634 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 634 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
635 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 635 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
636 i18n("Overwrite!"), i18n("Cancel"), 0, 636 i18n("Overwrite!"), i18n("Cancel"), 0,
637 0, 1 ); 637 0, 1 );
638 if ( result != 0 ) { 638 if ( result != 0 ) {
639 createbup = false; 639 createbup = false;
640 } 640 }
641 } 641 }
642 if ( createbup ) { 642 if ( createbup ) {
643 CalendarLocal cal; 643 CalendarLocal cal;
644 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 644 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
645 Incidence *incidence = delSel.first(); 645 Incidence *incidence = delSel.first();
646 while ( incidence ) { 646 while ( incidence ) {
647 cal.addIncidence( incidence->clone() ); 647 cal.addIncidence( incidence->clone() );
648 incidence = delSel.next(); 648 incidence = delSel.next();
649 } 649 }
650 ICalFormat format; 650 ICalFormat format;
651 format.save( &cal, fn ); 651 format.save( &cal, fn );
652 mes = i18n("KO/Pi:Saved %1").arg(fn ); 652 mes = i18n("KO/Pi:Saved %1").arg(fn );
653 KOPrefs::instance()->mLastSaveFile = fn; 653 KOPrefs::instance()->mLastSaveFile = fn;
654 topLevelWidget()->setCaption(mes); 654 topLevelWidget()->setCaption(mes);
655 } 655 }
656 } 656 }
657} 657}
658void KOListView::deleteAll() 658void KOListView::deleteAll()
659{ 659{
660 int icount = 0; 660 int icount = 0;
661 QPtrList<Incidence> delSel ; 661 QPtrList<Incidence> delSel ;
662 QListViewItem *item = mListView->firstChild (); 662 QListViewItem *item = mListView->firstChild ();
663 while ( item ) { 663 while ( item ) {
664 if ( item->isSelected() ) { 664 if ( item->isSelected() ) {
665 delSel.append(((KOListViewItem *)item)->data()); 665 delSel.append(((KOListViewItem *)item)->data());
666 ++icount; 666 ++icount;
667 } 667 }
668 668
669 item = item->nextSibling(); 669 item = item->nextSibling();
670 } 670 }
671 if ( icount ) { 671 if ( icount ) {
672 Incidence *incidence = delSel.first(); 672 Incidence *incidence = delSel.first();
673 Incidence *toDelete; 673 Incidence *toDelete;
674 KOPrefs *p = KOPrefs::instance(); 674 KOPrefs *p = KOPrefs::instance();
675 bool confirm = p->mConfirm; 675 bool confirm = p->mConfirm;
676 QString mess; 676 QString mess;
677 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 677 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
678 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")) ) { 678 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")) ) {
679 p->mConfirm = false; 679 p->mConfirm = false;
680 int delCounter = 0; 680 int delCounter = 0;
681 QDialog dia ( this, "p-dialog", true ); 681 QDialog dia ( this, "p-dialog", true );
682 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 682 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
683 QVBoxLayout lay( &dia ); 683 QVBoxLayout lay( &dia );
684 lay.setMargin(7); 684 lay.setMargin(7);
685 lay.setSpacing(7); 685 lay.setSpacing(7);
686 lay.addWidget( &lab); 686 lay.addWidget( &lab);
687 QProgressBar bar( icount, &dia ); 687 QProgressBar bar( icount, &dia );
688 lay.addWidget( &bar); 688 lay.addWidget( &bar);
689 int w = 220; 689 int w = 220;
690 int h = 50; 690 int h = 50;
691 int dw = QApplication::desktop()->width(); 691 int dw = QApplication::desktop()->width();
692 int dh = QApplication::desktop()->height(); 692 int dh = QApplication::desktop()->height();
693 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 693 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
694 //dia.resize( 240,50 ); 694 //dia.resize( 240,50 );
695 dia.show(); 695 dia.show();
696 696
697 while ( incidence ) { 697 while ( incidence ) {
698 bar.setProgress( delCounter ); 698 bar.setProgress( delCounter );
699 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 699 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
700 dia.setCaption( mess ); 700 dia.setCaption( mess );
701 qApp->processEvents(); 701 qApp->processEvents();
702 toDelete = (incidence); 702 toDelete = (incidence);
703 incidence = delSel.next(); 703 incidence = delSel.next();
704 emit deleteIncidenceSignal(toDelete ); 704 emit deleteIncidenceSignal(toDelete );
705 if ( dia.result() != 0 ) 705 if ( dia.result() != 0 )
706 break; 706 break;
707 707
708 } 708 }
709 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 709 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
710 topLevelWidget ()->setCaption( mess ); 710 topLevelWidget ()->setCaption( mess );
711 p->mConfirm = confirm; 711 p->mConfirm = confirm;
712 } 712 }
713 } 713 }
714 714
715 715
716} 716}
717int KOListView::maxDatesHint() 717int KOListView::maxDatesHint()
718{ 718{
719 return 0; 719 return 0;
720} 720}
721 721
722int KOListView::currentDateCount() 722int KOListView::currentDateCount()
723{ 723{
724 return 0; 724 return 0;
725} 725}
726 726
727QPtrList<Incidence> KOListView::selectedIncidences() 727QPtrList<Incidence> KOListView::selectedIncidences()
728{ 728{
729 QPtrList<Incidence> eventList; 729 QPtrList<Incidence> eventList;
730 QListViewItem *item = mListView->firstChild (); 730 QListViewItem *item = mListView->firstChild ();
731 while ( item ) { 731 while ( item ) {
732 if ( item->isSelected() ) { 732 if ( item->isSelected() ) {
733 eventList.append(((KOListViewItem *)item)->data()); 733 eventList.append(((KOListViewItem *)item)->data());
734 } 734 }
735 735
736 item = item->nextSibling(); 736 item = item->nextSibling();
737 } 737 }
738 738
739 // // QListViewItem *item = mListView->selectedItem(); 739 // // QListViewItem *item = mListView->selectedItem();
740 //if (item) eventList.append(((KOListViewItem *)item)->data()); 740 //if (item) eventList.append(((KOListViewItem *)item)->data());
741 741
742 return eventList; 742 return eventList;
743} 743}
744 744
745DateList KOListView::selectedDates() 745DateList KOListView::selectedDates()
746{ 746{
747 DateList eventList; 747 DateList eventList;
748 return eventList; 748 return eventList;
749} 749}
750 750
751void KOListView::showDates(bool show) 751void KOListView::showDates(bool show)
752{ 752{
753 // Shouldn't we set it to a value greater 0? When showDates is called with 753 // Shouldn't we set it to a value greater 0? When showDates is called with
754 // show == true at first, then the columnwidths are set to zero. 754 // show == true at first, then the columnwidths are set to zero.
755 static int oldColWidth1 = 0; 755 static int oldColWidth1 = 0;
756 static int oldColWidth3 = 0; 756 static int oldColWidth3 = 0;
757 757
758 if (!show) { 758 if (!show) {
759 oldColWidth1 = mListView->columnWidth(1); 759 oldColWidth1 = mListView->columnWidth(1);
760 oldColWidth3 = mListView->columnWidth(3); 760 oldColWidth3 = mListView->columnWidth(3);
761 mListView->setColumnWidth(1, 0); 761 mListView->setColumnWidth(1, 0);
762 mListView->setColumnWidth(3, 0); 762 mListView->setColumnWidth(3, 0);
763 } else { 763 } else {
764 mListView->setColumnWidth(1, oldColWidth1); 764 mListView->setColumnWidth(1, oldColWidth1);
765 mListView->setColumnWidth(3, oldColWidth3); 765 mListView->setColumnWidth(3, oldColWidth3);
766 } 766 }
767 mListView->repaint(); 767 mListView->repaint();
768} 768}
769 769
770void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 770void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
771 const QDate &td) 771 const QDate &td)
772{ 772{
773#ifndef KORG_NOPRINTER 773#ifndef KORG_NOPRINTER
774 calPrinter->preview(CalPrinter::Day, fd, td); 774 calPrinter->preview(CalPrinter::Day, fd, td);
775#endif 775#endif
776} 776}
777 777
778void KOListView::showDates() 778void KOListView::showDates()
779{ 779{
780 showDates(true); 780 showDates(true);
781} 781}
782 782
783void KOListView::hideDates() 783void KOListView::hideDates()
784{ 784{
785 showDates(false); 785 showDates(false);
786} 786}
787void KOListView::resetFocus() 787void KOListView::resetFocus()
788{ 788{
789 mListView->setFocus(); 789 mListView->setFocus();
790} 790}
791void KOListView::updateView() 791void KOListView::updateView()
792{ 792{
793 mListView->setFocus(); 793 mListView->setFocus();
794 if ( mListView->firstChild () ) 794 if ( mListView->firstChild () )
795 mListView->setCurrentItem( mListView->firstChild () ); 795 mListView->setCurrentItem( mListView->firstChild () );
796} 796}
797void KOListView::updateConfig() 797void KOListView::updateConfig()
798{ 798{
799 799
800 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 800 mListView->setFont ( KOPrefs::instance()->mListViewFont );
801 updateView(); 801 updateView();
802 802
803} 803}
804void KOListView::setStartDate(const QDate &start) 804void KOListView::setStartDate(const QDate &start)
805{ 805{
806 mStartDate = start; 806 mStartDate = start;
807} 807}
808 808
809void KOListView::showDates(const QDate &start, const QDate &end) 809void KOListView::showDates(const QDate &start, const QDate &end)
810{ 810{
811 clear(); 811 clear();
812 mStartDate = start; 812 mStartDate = start;
813 QDate date = start; 813 QDate date = start;
814 QPtrList<Journal> j_list; 814 QPtrList<Journal> j_list;
815 while( date <= end ) { 815 while( date <= end ) {
816 addEvents(calendar()->events(date)); 816 addEvents(calendar()->events(date));
817 addTodos(calendar()->todos(date)); 817 addTodos(calendar()->todos(date));
818 Journal* jo = calendar()->journal(date); 818 Journal* jo = calendar()->journal(date);
819 if ( jo ) 819 if ( jo )
820 j_list.append( jo ); 820 j_list.append( jo );
821 date = date.addDays( 1 ); 821 date = date.addDays( 1 );
822 } 822 }
823 addJournals(j_list); 823 addJournals(j_list);
824 emit incidenceSelected( 0 ); 824 emit incidenceSelected( 0 );
825 updateView(); 825 updateView();
826 826
827} 827}
828 828
829void KOListView::addEvents(QPtrList<Event> eventList) 829void KOListView::addEvents(QPtrList<Event> eventList)
830{ 830{
831 Event *ev; 831 Event *ev;
832 for(ev = eventList.first(); ev; ev = eventList.next()) { 832 for(ev = eventList.first(); ev; ev = eventList.next()) {
833 addIncidence(ev); 833 addIncidence(ev);
834 } 834 }
835 if ( !mListView->currentItem() ){ 835 if ( !mListView->currentItem() ){
836 updateView(); 836 updateView();
837 } 837 }
838} 838}
839 839
840void KOListView::addTodos(QPtrList<Todo> eventList) 840void KOListView::addTodos(QPtrList<Todo> eventList)
841{ 841{
842 Todo *ev; 842 Todo *ev;
843 for(ev = eventList.first(); ev; ev = eventList.next()) { 843 for(ev = eventList.first(); ev; ev = eventList.next()) {
844 addIncidence(ev); 844 addIncidence(ev);
845 } 845 }
846 if ( !mListView->currentItem() ){ 846 if ( !mListView->currentItem() ){
847 updateView(); 847 updateView();
848 } 848 }
849} 849}
850void KOListView::addJournals(QPtrList<Journal> eventList) 850void KOListView::addJournals(QPtrList<Journal> eventList)
851{ 851{
852 Journal *ev; 852 Journal *ev;
853 for(ev = eventList.first(); ev; ev = eventList.next()) { 853 for(ev = eventList.first(); ev; ev = eventList.next()) {
854 addIncidence(ev); 854 addIncidence(ev);
855 } 855 }
856 if ( !mListView->currentItem() ){ 856 if ( !mListView->currentItem() ){
857 updateView(); 857 updateView();
858 } 858 }
859} 859}
860 860
861void KOListView::addIncidence(Incidence *incidence) 861void KOListView::addIncidence(Incidence *incidence)
862{ 862{
863 if ( mUidDict.find( incidence->uid() ) ) return; 863 if ( mUidDict.find( incidence->uid() ) ) return;
864 864
865 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 865 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
866 mUidDict.insert( incidence->uid(), incidence ); 866 mUidDict.insert( incidence->uid(), incidence );
867 867
868 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 868 KOListViewItem *item = new KOListViewItem( incidence, mListView );
869 ListItemVisitor v(item, mStartDate ); 869 ListItemVisitor v(item, mStartDate );
870 if (incidence->accept(v)) return; 870 if (incidence->accept(v)) return;
871 else delete item; 871 else delete item;
872 //qDebug("delete item "); 872 //qDebug("delete item ");
873} 873}
874 874
875void KOListView::showEvents(QPtrList<Event> eventList) 875void KOListView::showEvents(QPtrList<Event> eventList)
876{ 876{
877 clear(); 877 clear();
878 878
879 addEvents(eventList); 879 addEvents(eventList);
880 880
881 // After new creation of list view no events are selected. 881 // After new creation of list view no events are selected.
882 emit incidenceSelected( 0 ); 882 emit incidenceSelected( 0 );
883} 883}
884int KOListView::count() 884int KOListView::count()
885{ 885{
886 return mListView->childCount(); 886 return mListView->childCount();
887} 887}
888 888
889void KOListView::changeEventDisplay(Event *event, int action) 889void KOListView::changeEventDisplay(Event *event, int action)
890{ 890{
891 KOListViewItem *item; 891 KOListViewItem *item;
892 892
893 switch(action) { 893 switch(action) {
894 case KOGlobals::EVENTADDED: 894 case KOGlobals::EVENTADDED:
895 addIncidence( event ); 895 addIncidence( event );
896 break; 896 break;
897 case KOGlobals::EVENTEDITED: 897 case KOGlobals::EVENTEDITED:
898 item = getItemForEvent(event); 898 item = getItemForEvent(event);
899 if (item) { 899 if (item) {
900 mUidDict.remove( event->uid() ); 900 mUidDict.remove( event->uid() );
901 delete item; 901 delete item;
902 addIncidence( event ); 902 addIncidence( event );
903 } 903 }
904 break; 904 break;
905 case KOGlobals::EVENTDELETED: 905 case KOGlobals::EVENTDELETED:
906 item = getItemForEvent(event); 906 item = getItemForEvent(event);
907 if (item) { 907 if (item) {
908 mUidDict.remove( event->uid() ); 908 mUidDict.remove( event->uid() );
909 delete item; 909 delete item;
910 } 910 }
911 break; 911 break;
912 default: 912 default:
913 ; 913 ;
914 } 914 }
915} 915}
916 916
917KOListViewItem *KOListView::getItemForEvent(Event *event) 917KOListViewItem *KOListView::getItemForEvent(Event *event)
918{ 918{
919 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 919 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
920 while (item) { 920 while (item) {
921 if (item->data() == event) return item; 921 if (item->data() == event) return item;
922 item = (KOListViewItem *)item->nextSibling(); 922 item = (KOListViewItem *)item->nextSibling();
923 } 923 }
924 return 0; 924 return 0;
925} 925}
926 926
927void KOListView::defaultItemAction(QListViewItem *i) 927void KOListView::defaultItemAction(QListViewItem *i)
928{ 928{
929 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 929 KOListViewItem *item = static_cast<KOListViewItem *>( i );
930 if ( item ) defaultAction( item->data() ); 930 if ( item ) defaultAction( item->data() );
931 931
932} 932}
933 933
934void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 934void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
935{ 935{
936 mActiveItem = (KOListViewItem *)item; 936 mActiveItem = (KOListViewItem *)item;
937 if (mActiveItem) { 937 if (mActiveItem) {
938 Incidence *incidence = mActiveItem->data(); 938 Incidence *incidence = mActiveItem->data();
939 mPopupMenu->showIncidencePopup(incidence); 939 mPopupMenu->showIncidencePopup(incidence);
940 940
941 /* 941 /*
942 if ( incidence && incidence->type() == "Event" ) { 942 if ( incidence && incidence->type() == "Event" ) {
943 Event *event = static_cast<Event *>( incidence ); 943 Event *event = static_cast<Event *>( incidence );
944 mPopupMenu->showEventPopup(event); 944 mPopupMenu->showEventPopup(event);
945 } 945 }
946 */ 946 */
947 } 947 }
948} 948}
949 949
950void KOListView::readSettings(KConfig *config, QString setting) 950void KOListView::readSettings(KConfig *config, QString setting)
951{ 951{
952 // qDebug("KOListView::readSettings "); 952 // qDebug("KOListView::readSettings ");
953 mListView->restoreLayout(config,setting); 953 mListView->restoreLayout(config,setting);
954} 954}
955 955
956void KOListView::writeSettings(KConfig *config, QString setting) 956void KOListView::writeSettings(KConfig *config, QString setting)
957{ 957{
958 // qDebug("KOListView::writeSettings "); 958 // qDebug("KOListView::writeSettings ");
959 mListView->saveLayout(config, setting); 959 mListView->saveLayout(config, setting);
960} 960}
961 961
962void KOListView::processSelectionChange(QListViewItem *) 962void KOListView::processSelectionChange(QListViewItem *)
963{ 963{
964 964
965 KOListViewItem *item = 965 KOListViewItem *item =
966 static_cast<KOListViewItem *>( mListView->currentItem() ); 966 static_cast<KOListViewItem *>( mListView->currentItem() );
967 967
968 if ( !item ) { 968 if ( !item ) {
969 emit incidenceSelected( 0 ); 969 emit incidenceSelected( 0 );
970 } else { 970 } else {
971 emit incidenceSelected( item->data() ); 971 emit incidenceSelected( item->data() );
972 } 972 }
973} 973}
974 974
975void KOListView::clearSelection() 975void KOListView::clearSelection()
976{ 976{
977 mListView->selectAll( false ); 977 mListView->selectAll( false );
978} 978}
979void KOListView::allSelection() 979void KOListView::allSelection()
980{ 980{
981 mListView->selectAll( true ); 981 mListView->selectAll( true );
982} 982}
983 983
984void KOListView::clear() 984void KOListView::clear()
985{ 985{
986 mListView->clear(); 986 mListView->clear();
987 mUidDict.clear(); 987 mUidDict.clear();
988} 988}
989 989
990Incidence* KOListView::currentItem() 990Incidence* KOListView::currentItem()
991{ 991{
992 if ( mListView->currentItem() ) 992 if ( mListView->currentItem() )
993 return ((KOListViewItem*) mListView->currentItem())->data(); 993 return ((KOListViewItem*) mListView->currentItem())->data();
994 return 0; 994 return 0;
995} 995}
996void KOListView::keyPressEvent ( QKeyEvent *e) 996void KOListView::keyPressEvent ( QKeyEvent *e)
997{ 997{
998 998
999 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 999 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1000 deleteAll(); 1000 deleteAll();
1001 return; 1001 return;
1002 } 1002 }
1003 1003
1004 e->ignore(); 1004 e->ignore();
1005} 1005}
1006void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1006void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1007{ 1007{
1008 1008
1009 switch ( e->key() ) { 1009 switch ( e->key() ) {
1010 case Qt::Key_Down: 1010 case Qt::Key_Down:
1011 if ( e->state() == ShiftButton ) { 1011 if ( e->state() == ShiftButton ) {
1012 QListViewItem* cn = currentItem(); 1012 QListViewItem* cn = currentItem();
1013 if ( !cn ) 1013 if ( !cn )
1014 cn = firstChild(); 1014 cn = firstChild();
1015 if ( !cn ) 1015 if ( !cn )
1016 return; 1016 return;
1017 while ( cn->nextSibling() ) 1017 while ( cn->nextSibling() )
1018 cn = cn->nextSibling(); 1018 cn = cn->nextSibling();
1019 setCurrentItem ( cn ); 1019 setCurrentItem ( cn );
1020 ensureItemVisible ( cn ); 1020 ensureItemVisible ( cn );
1021 1021
1022 e->accept(); 1022 e->accept();
1023 return; 1023 return;
1024 } 1024 }
1025 if ( e->state() == ControlButton ) { 1025 if ( e->state() == ControlButton ) {
1026 int count = childCount (); 1026 int count = childCount ();
1027 int jump = count / 5; 1027 int jump = count / 5;
1028 QListViewItem* cn; 1028 QListViewItem* cn;
1029 cn = currentItem(); 1029 cn = currentItem();
1030 if ( ! cn ) 1030 if ( ! cn )
1031 return; 1031 return;
1032 if ( jump == 0 ) 1032 if ( jump == 0 )
1033 jump = 1; 1033 jump = 1;
1034 while ( jump && cn->nextSibling() ) { 1034 while ( jump && cn->nextSibling() ) {
1035 cn = cn->nextSibling(); 1035 cn = cn->nextSibling();
1036 --jump; 1036 --jump;
1037 } 1037 }
1038 setCurrentItem ( cn ); 1038 setCurrentItem ( cn );
1039 ensureItemVisible ( cn ); 1039 ensureItemVisible ( cn );
1040 1040
1041 } else 1041 } else
1042 QListView::keyPressEvent ( e ) ; 1042 QListView::keyPressEvent ( e ) ;
1043 e->accept(); 1043 e->accept();
1044 break; 1044 break;
1045 1045
1046 case Qt::Key_Up: 1046 case Qt::Key_Up:
1047 if ( e->state() == ShiftButton ) { 1047 if ( e->state() == ShiftButton ) {
1048 QListViewItem* cn = firstChild(); 1048 QListViewItem* cn = firstChild();
1049 if ( cn ) { 1049 if ( cn ) {
1050 setCurrentItem ( cn ); 1050 setCurrentItem ( cn );
1051 ensureItemVisible ( cn ); 1051 ensureItemVisible ( cn );
1052 } 1052 }
1053 e->accept(); 1053 e->accept();
1054 return; 1054 return;
1055 } 1055 }
1056 if ( e->state() == ControlButton ) { 1056 if ( e->state() == ControlButton ) {
1057 int count = childCount (); 1057 int count = childCount ();
1058 int jump = count / 5; 1058 int jump = count / 5;
1059 QListViewItem* cn; 1059 QListViewItem* cn;
1060 cn = currentItem(); 1060 cn = currentItem();
1061 if ( ! cn ) 1061 if ( ! cn )
1062 return; 1062 return;
1063 if ( jump == 0 ) 1063 if ( jump == 0 )
1064 jump = 1; 1064 jump = 1;
1065 while ( jump && cn->itemAbove ()) { 1065 while ( jump && cn->itemAbove ()) {
1066 cn = cn->itemAbove (); 1066 cn = cn->itemAbove ();
1067 --jump; 1067 --jump;
1068 } 1068 }
1069 setCurrentItem ( cn ); 1069 setCurrentItem ( cn );
1070 ensureItemVisible ( cn ); 1070 ensureItemVisible ( cn );
1071 } else 1071 } else
1072 QListView::keyPressEvent ( e ) ; 1072 QListView::keyPressEvent ( e ) ;
1073 e->accept(); 1073 e->accept();
1074 break; 1074 break;
1075 case Qt::Key_I: { 1075 case Qt::Key_I: {
1076 QListViewItem* cn; 1076 QListViewItem* cn;
1077 cn = currentItem(); 1077 cn = currentItem();
1078 if ( cn ) { 1078 if ( cn ) {
1079 KOListViewItem* ci = (KOListViewItem*)( cn ); 1079 KOListViewItem* ci = (KOListViewItem*)( cn );
1080 if ( ci ){ 1080 if ( ci ){
1081 //emit showIncidence( ci->data()); 1081 //emit showIncidence( ci->data());
1082 cn = cn->nextSibling(); 1082 cn = cn->nextSibling();
1083 if ( cn ) { 1083 if ( cn ) {
1084 setCurrentItem ( cn ); 1084 setCurrentItem ( cn );
1085 ensureItemVisible ( cn ); 1085 ensureItemVisible ( cn );
1086 emit showIncidence( ci->data());
1087 } 1086 }
1087 emit showIncidence( ci->data());
1088 } 1088 }
1089 } 1089 }
1090 e->accept(); 1090 e->accept();
1091 } 1091 }
1092 break; 1092 break;
1093 case Qt::Key_Return: 1093 case Qt::Key_Return:
1094 case Qt::Key_Enter: 1094 case Qt::Key_Enter:
1095 { 1095 {
1096 QListViewItem* cn; 1096 QListViewItem* cn;
1097 cn = currentItem(); 1097 cn = currentItem();
1098 if ( cn ) { 1098 if ( cn ) {
1099 KOListViewItem* ci = (KOListViewItem*)( cn ); 1099 KOListViewItem* ci = (KOListViewItem*)( cn );
1100 if ( ci ){ 1100 if ( ci ){
1101 if ( e->state() == ShiftButton ) 1101 if ( e->state() == ShiftButton )
1102 ci->setSelected( false ); 1102 ci->setSelected( false );
1103 else 1103 else
1104 ci->setSelected( true ); 1104 ci->setSelected( true );
1105 cn = cn->nextSibling(); 1105 cn = cn->nextSibling();
1106 if ( cn ) { 1106 if ( cn ) {
1107 setCurrentItem ( cn ); 1107 setCurrentItem ( cn );
1108 ensureItemVisible ( cn ); 1108 ensureItemVisible ( cn );
1109 } 1109 }
1110 } 1110 }
1111 } 1111 }
1112 e->accept(); 1112 e->accept();
1113 } 1113 }
1114 break; 1114 break;
1115 default: 1115 default:
1116 e->ignore(); 1116 e->ignore();
1117 } 1117 }
1118} 1118}
1119KOListViewListView::KOListViewListView(KOListView * lv ) 1119KOListViewListView::KOListViewListView(KOListView * lv )
1120 : KListView( lv ) 1120 : KListView( lv )
1121{ 1121{
1122#ifndef DESKTOP_VERSION 1122#ifndef DESKTOP_VERSION
1123 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1123 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1124#endif 1124#endif
1125 mYMousePos = -1000; 1125 mYMousePos = -1000;
1126 setSelectionMode( QListView::Multi ); 1126 setSelectionMode( QListView::Multi );
1127 setMultiSelection( true); 1127 setMultiSelection( true);
1128 mAllowPopupMenu = true; 1128 mAllowPopupMenu = true;
1129 mMouseDown = false; 1129 mMouseDown = false;
1130 1130
1131} 1131}
1132void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1132void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1133{ 1133{
1134 if (!e) return; 1134 if (!e) return;
1135 QPoint vp = contentsToViewport(e->pos()); 1135 QPoint vp = contentsToViewport(e->pos());
1136 QListViewItem *item = itemAt(vp); 1136 QListViewItem *item = itemAt(vp);
1137 if (!item) { 1137 if (!item) {
1138 emit newEvent(); 1138 emit newEvent();
1139 return; 1139 return;
1140 } 1140 }
1141 KListView::contentsMouseDoubleClickEvent(e); 1141 KListView::contentsMouseDoubleClickEvent(e);
1142} 1142}
1143 1143
1144 1144
1145void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1145void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1146{ 1146{
1147 //qDebug("contentsMousePressEvent++++ "); 1147 //qDebug("contentsMousePressEvent++++ ");
1148 if (! mMouseDown ) { 1148 if (! mMouseDown ) {
1149 mAllowPopupMenu = true; 1149 mAllowPopupMenu = true;
1150 mYMousePos = mapToGlobal( (e->pos())).y(); 1150 mYMousePos = mapToGlobal( (e->pos())).y();
1151 } 1151 }
1152 if ( e->button() == RightButton && mMouseDown ) 1152 if ( e->button() == RightButton && mMouseDown )
1153 return; 1153 return;
1154 if ( e->button() == LeftButton ) 1154 if ( e->button() == LeftButton )
1155 mMouseDown = true; 1155 mMouseDown = true;
1156 KListView::contentsMousePressEvent( e ); 1156 KListView::contentsMousePressEvent( e );
1157} 1157}
1158void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1158void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1159{ 1159{
1160 //qDebug("contentsMouseReleaseEv---- "); 1160 //qDebug("contentsMouseReleaseEv---- ");
1161 if ( ! mMouseDown ) { 1161 if ( ! mMouseDown ) {
1162 if ( e->button() == RightButton && ! mAllowPopupMenu ) 1162 if ( e->button() == RightButton && ! mAllowPopupMenu )
1163 return; 1163 return;
1164 QListViewItem* ci = currentItem(); 1164 QListViewItem* ci = currentItem();
1165 if ( ci ) 1165 if ( ci )
1166 ci->setSelected( true ); 1166 ci->setSelected( true );
1167 KListView::contentsMouseReleaseEvent(e); 1167 KListView::contentsMouseReleaseEvent(e);
1168 return; 1168 return;
1169 } 1169 }
1170 if ( e->button() == LeftButton ) 1170 if ( e->button() == LeftButton )
1171 mMouseDown = false; 1171 mMouseDown = false;
1172 if ( e->button() == RightButton && ! mAllowPopupMenu ) 1172 if ( e->button() == RightButton && ! mAllowPopupMenu )
1173 return; 1173 return;
1174 if ( e->button() == RightButton ) { 1174 if ( e->button() == RightButton ) {
1175 QListViewItem* ci = currentItem(); 1175 QListViewItem* ci = currentItem();
1176 if ( ci ) 1176 if ( ci )
1177 ci->setSelected( true ); 1177 ci->setSelected( true );
1178 } 1178 }
1179 KListView::contentsMouseReleaseEvent(e); 1179 KListView::contentsMouseReleaseEvent(e);
1180} 1180}
1181void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1181void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1182{ 1182{
1183 // qDebug("contentsMouseMoveEv....... "); 1183 // qDebug("contentsMouseMoveEv....... ");
1184 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1184 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1185 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1185 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1186 if ( diff < 0 ) diff = -diff; 1186 if ( diff < 0 ) diff = -diff;
1187 if ( diff > 20 ) 1187 if ( diff > 20 )
1188 mAllowPopupMenu = false; 1188 mAllowPopupMenu = false;
1189 KListView::contentsMouseMoveEvent(e); 1189 KListView::contentsMouseMoveEvent(e);
1190} 1190}
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index cef59a2..678e1bd 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -1,405 +1,412 @@
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 <qwhatsthis.h> 30#include <qwhatsthis.h>
30#include <qlineedit.h> 31#include <qlineedit.h>
31#include <qpushbutton.h> 32#include <qpushbutton.h>
32 33
33#include <klocale.h> 34#include <klocale.h>
34#include <kmessagebox.h> 35#include <kmessagebox.h>
35 36
36#include <libkdepim/kdateedit.h> 37#include <libkdepim/kdateedit.h>
37 38
38#include "koglobals.h" 39#include "koglobals.h"
39#include "koprefs.h" 40#include "koprefs.h"
41#include "klineedit.h"
40 42
41#include "calendarview.h" 43#include "calendarview.h"
42#include "koviewmanager.h" 44#include "koviewmanager.h"
43#include "searchdialog.h" 45#include "searchdialog.h"
44 46
45SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
46 : QVBox( 0 ) 48 : QVBox( 0 )
47 49
48{ 50{
49 mCalendar = calendar; 51 mCalendar = calendar;
50 QFrame *topFrame = new QFrame( this ) ;//plainPage(); 52 QFrame *topFrame = new QFrame( this ) ;//plainPage();
51 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); 53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
52 54
53 // Search expression 55 // Search expression
54 QHBoxLayout *subLayout = new QHBoxLayout(); 56 QHBoxLayout *subLayout = new QHBoxLayout();
55 layout->addLayout(subLayout); 57 layout->addLayout(subLayout);
56 searchLabel = new QLabel(topFrame); 58 searchLabel = new QLabel(topFrame);
57 searchLabel->setText(i18n("Search for:")); 59 searchLabel->setText(i18n("Search for:"));
58 subLayout->addWidget(searchLabel); 60 subLayout->addWidget(searchLabel);
59 61
60 searchEdit = new QLineEdit(topFrame); 62 searchEdit = new KLineEdit(topFrame);
61 subLayout->addWidget(searchEdit); 63 subLayout->addWidget(searchEdit);
62 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame ); 64 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame );
63 //OkButton->setDefault( true ); 65 //OkButton->setDefault( true );
64 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); 66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch()));
65 subLayout->addWidget(OkButton); 67 subLayout->addWidget(OkButton);
66 searchEdit->setText("*"); // Find all events by default 68 searchEdit->setText("*"); // Find all events by default
67 searchEdit->setFocus(); 69 searchEdit->setFocus();
68 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 70 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
69 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 71 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
70 // Subjects to search 72 // Subjects to search
71 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 73 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
72 // topFrame); 74 // topFrame);
73 75
74 QHBox *incidenceGroup = new QHBox( topFrame ); 76 QHBox *incidenceGroup = new QHBox( topFrame );
75 layout->addWidget(incidenceGroup); 77 layout->addWidget(incidenceGroup);
76 78
77 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 79 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
78 mSearchEvent->setChecked(true); 80 mSearchEvent->setChecked(true);
79 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 81 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
80 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 82 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
81 83
82 QHBox *subjectGroup = new QHBox( topFrame ); 84 QHBox *subjectGroup = new QHBox( topFrame );
83 layout->addWidget(subjectGroup); 85 layout->addWidget(subjectGroup);
84 86
85 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); 87 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup);
86 mSummaryCheck->setChecked(true); 88 mSummaryCheck->setChecked(true);
87 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); 89 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup);
88 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 90 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
89 91
90 QHBox *attendeeGroup = new QHBox( topFrame ); 92 QHBox *attendeeGroup = new QHBox( topFrame );
91 layout->addWidget(attendeeGroup ); 93 layout->addWidget(attendeeGroup );
92 new QLabel( i18n("Attendee:"),attendeeGroup ); 94 new QLabel( i18n("Attendee:"),attendeeGroup );
93 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 95 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
94 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 96 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
95 // Date range 97 // Date range
96 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 98 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
97 // topFrame); 99 // topFrame);
98 // layout->addWidget(rangeGroup); 100 // layout->addWidget(rangeGroup);
99 101
100 QWidget *rangeWidget = new QWidget(topFrame); 102 QWidget *rangeWidget = new QWidget(topFrame);
101 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); 103 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint());
102 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 104 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
103 mStartDate = new KDateEdit(rangeWidget); 105 mStartDate = new KDateEdit(rangeWidget);
104 rangeLayout->addWidget(mStartDate); 106 rangeLayout->addWidget(mStartDate);
105 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 107 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
106 mEndDate = new KDateEdit(rangeWidget); 108 mEndDate = new KDateEdit(rangeWidget);
107 mEndDate->setDate(QDate::currentDate().addDays(365)); 109 mEndDate->setDate(QDate::currentDate().addDays(365));
108 rangeLayout->addWidget(mEndDate); 110 rangeLayout->addWidget(mEndDate);
109 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); 111 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget );
110 rangeLayout->addWidget( (QWidget*)wt ); 112 rangeLayout->addWidget( (QWidget*)wt );
111 layout->addWidget(rangeWidget); 113 layout->addWidget(rangeWidget);
112 // Results list view 114 // Results list view
113 listView = new KOListView(mCalendar,topFrame); 115 listView = new KOListView(mCalendar,topFrame);
114 layout->addWidget(listView); 116 layout->addWidget(listView);
115 117
116 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 118 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
119 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList()));
117 120
118 setCaption( i18n("KO/Pi Find: ")); 121 setCaption( i18n("KO/Pi Find: "));
119#ifdef DESKTOP_VERSION 122#ifdef DESKTOP_VERSION
120 OkButton = new QPushButton( i18n("Close"), this ); 123 OkButton = new QPushButton( i18n("Close"), this );
121 connect(OkButton,SIGNAL(clicked()),SLOT(hide())); 124 connect(OkButton,SIGNAL(clicked()),SLOT(hide()));
122#endif 125#endif
123} 126}
124 127
125SearchDialog::~SearchDialog() 128SearchDialog::~SearchDialog()
126{ 129{
127 130
128} 131}
132void SearchDialog::setFocusToList()
133{
134 listView->resetFocus();
135}
129void SearchDialog::accept() 136void SearchDialog::accept()
130{ 137{
131 doSearch(); 138 doSearch();
132} 139}
133void SearchDialog::updateList() 140void SearchDialog::updateList()
134{ 141{
135 //listView->updateList(); 142 //listView->updateList();
136 if ( isVisible() ) { 143 if ( isVisible() ) {
137 updateView(); 144 updateView();
138 //qDebug("SearchDialog::updated "); 145 //qDebug("SearchDialog::updated ");
139 } 146 }
140 else { 147 else {
141 listView->clear(); 148 listView->clear();
142 //qDebug("SearchDialog::cleared "); 149 //qDebug("SearchDialog::cleared ");
143 150
144 } 151 }
145} 152}
146void SearchDialog::searchTextChanged( const QString &_text ) 153void SearchDialog::searchTextChanged( const QString &_text )
147{ 154{
148#if 0 155#if 0
149 enableButton( KDialogBase::User1, !_text.isEmpty() ); 156 enableButton( KDialogBase::User1, !_text.isEmpty() );
150#endif 157#endif
151} 158}
152 159
153void SearchDialog::doSearch() 160void SearchDialog::doSearch()
154{ 161{
155 QRegExp re; 162 QRegExp re;
156 163
157 re.setWildcard(true); // most people understand these better. 164 re.setWildcard(true); // most people understand these better.
158 re.setCaseSensitive(false); 165 re.setCaseSensitive(false);
159 re.setPattern(searchEdit->text()); 166 re.setPattern(searchEdit->text());
160 if (!re.isValid() ) { 167 if (!re.isValid() ) {
161 KMessageBox::sorry(this, 168 KMessageBox::sorry(this,
162 i18n("Invalid search expression,\ncannot perform " 169 i18n("Invalid search expression,\ncannot perform "
163 "the search.\nPlease enter a search expression\n" 170 "the search.\nPlease enter a search expression\n"
164 "using the wildcard characters\n '*' and '?'" 171 "using the wildcard characters\n '*' and '?'"
165 "where needed.")); 172 "where needed."));
166 return; 173 return;
167 } 174 }
168 175
169 search(re); 176 search(re);
170 177
171 listView->setStartDate( mStartDate->date() ); 178 listView->setStartDate( mStartDate->date() );
172 listView->showEvents(mMatchedEvents); 179 listView->showEvents(mMatchedEvents);
173 listView->addTodos(mMatchedTodos); 180 listView->addTodos(mMatchedTodos);
174 listView->addJournals(mMatchedJournals); 181 listView->addJournals(mMatchedJournals);
175 182
176 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 183 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
177 setCaption(i18n("No items found. Use '*' and '?' where needed.")); 184 setCaption(i18n("No items found. Use '*' and '?' where needed."));
178 } else { 185 } else {
179 QString mess; 186 QString mess;
180 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 187 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
181 setCaption( i18n("KO/Pi Find: ") + mess); 188 setCaption( i18n("KO/Pi Find: ") + mess);
182 189
183 } 190 }
184 searchEdit->setFocus(); 191 searchEdit->setFocus();
185} 192}
186void SearchDialog::updateConfig() 193void SearchDialog::updateConfig()
187{ 194{
188 listView->updateConfig(); 195 listView->updateConfig();
189} 196}
190void SearchDialog::updateView() 197void SearchDialog::updateView()
191{ 198{
192 199
193 QRegExp re; 200 QRegExp re;
194 re.setWildcard(true); // most people understand these better. 201 re.setWildcard(true); // most people understand these better.
195 re.setCaseSensitive(false); 202 re.setCaseSensitive(false);
196 re.setPattern(searchEdit->text()); 203 re.setPattern(searchEdit->text());
197 if (re.isValid()) { 204 if (re.isValid()) {
198 search(re); 205 search(re);
199 } else { 206 } else {
200 mMatchedEvents.clear(); 207 mMatchedEvents.clear();
201 mMatchedTodos.clear(); 208 mMatchedTodos.clear();
202 mMatchedJournals.clear(); 209 mMatchedJournals.clear();
203 } 210 }
204 listView->setStartDate( mStartDate->date() ); 211 listView->setStartDate( mStartDate->date() );
205 listView->showEvents(mMatchedEvents); 212 listView->showEvents(mMatchedEvents);
206 listView->addTodos(mMatchedTodos); 213 listView->addTodos(mMatchedTodos);
207 listView->addJournals(mMatchedJournals); 214 listView->addJournals(mMatchedJournals);
208} 215}
209 216
210void SearchDialog::search(const QRegExp &re) 217void SearchDialog::search(const QRegExp &re)
211{ 218{
212 QPtrList<Event> events = mCalendar->events( mStartDate->date(), 219 QPtrList<Event> events = mCalendar->events( mStartDate->date(),
213 mEndDate->date(), 220 mEndDate->date(),
214 false /*mInclusiveCheck->isChecked()*/ ); 221 false /*mInclusiveCheck->isChecked()*/ );
215 222
216 mMatchedEvents.clear(); 223 mMatchedEvents.clear();
217 if ( mSearchEvent->isChecked() ) { 224 if ( mSearchEvent->isChecked() ) {
218 Event *ev; 225 Event *ev;
219 for(ev=events.first();ev;ev=events.next()) { 226 for(ev=events.first();ev;ev=events.next()) {
220 if (mSummaryCheck->isChecked()) { 227 if (mSummaryCheck->isChecked()) {
221#if QT_VERSION >= 0x030000 228#if QT_VERSION >= 0x030000
222 if (re.search(ev->summary()) != -1) 229 if (re.search(ev->summary()) != -1)
223#else 230#else
224 if (re.match(ev->summary()) != -1) 231 if (re.match(ev->summary()) != -1)
225#endif 232#endif
226 { 233 {
227 mMatchedEvents.append(ev); 234 mMatchedEvents.append(ev);
228 continue; 235 continue;
229 } 236 }
230#if QT_VERSION >= 0x030000 237#if QT_VERSION >= 0x030000
231 if (re.search(ev->location()) != -1) 238 if (re.search(ev->location()) != -1)
232#else 239#else
233 if (re.match(ev->location()) != -1) 240 if (re.match(ev->location()) != -1)
234#endif 241#endif
235 { 242 {
236 mMatchedEvents.append(ev); 243 mMatchedEvents.append(ev);
237 continue; 244 continue;
238 } 245 }
239 } 246 }
240 if (mDescriptionCheck->isChecked()) { 247 if (mDescriptionCheck->isChecked()) {
241#if QT_VERSION >= 0x030000 248#if QT_VERSION >= 0x030000
242 if (re.search(ev->description()) != -1) 249 if (re.search(ev->description()) != -1)
243#else 250#else
244 if (re.match(ev->description()) != -1) 251 if (re.match(ev->description()) != -1)
245#endif 252#endif
246 { 253 {
247 mMatchedEvents.append(ev); 254 mMatchedEvents.append(ev);
248 continue; 255 continue;
249 } 256 }
250 } 257 }
251 if (mCategoryCheck->isChecked()) { 258 if (mCategoryCheck->isChecked()) {
252#if QT_VERSION >= 0x030000 259#if QT_VERSION >= 0x030000
253 if (re.search(ev->categoriesStr()) != -1) 260 if (re.search(ev->categoriesStr()) != -1)
254#else 261#else
255 if (re.match(ev->categoriesStr()) != -1) 262 if (re.match(ev->categoriesStr()) != -1)
256#endif 263#endif
257 { 264 {
258 mMatchedEvents.append(ev); 265 mMatchedEvents.append(ev);
259 continue; 266 continue;
260 } 267 }
261 } 268 }
262 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 269 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
263 QPtrList<Attendee> tmpAList = ev->attendees(); 270 QPtrList<Attendee> tmpAList = ev->attendees();
264 Attendee *a; 271 Attendee *a;
265 for (a = tmpAList.first(); a; a = tmpAList.next()) { 272 for (a = tmpAList.first(); a; a = tmpAList.next()) {
266 if (mSearchAName->isChecked()) { 273 if (mSearchAName->isChecked()) {
267#if QT_VERSION >= 0x030000 274#if QT_VERSION >= 0x030000
268 if (re.search(a->name()) != -1) 275 if (re.search(a->name()) != -1)
269#else 276#else
270 if (re.match(a->name()) != -1) 277 if (re.match(a->name()) != -1)
271#endif 278#endif
272 { 279 {
273 mMatchedEvents.append(ev); 280 mMatchedEvents.append(ev);
274 break; 281 break;
275 } 282 }
276 } 283 }
277 if (mSearchAEmail->isChecked()) { 284 if (mSearchAEmail->isChecked()) {
278#if QT_VERSION >= 0x030000 285#if QT_VERSION >= 0x030000
279 if (re.search(a->email()) != -1) 286 if (re.search(a->email()) != -1)
280#else 287#else
281 if (re.match(a->email()) != -1) 288 if (re.match(a->email()) != -1)
282#endif 289#endif
283 { 290 {
284 mMatchedEvents.append(ev); 291 mMatchedEvents.append(ev);
285 break; 292 break;
286 } 293 }
287 } 294 }
288 } 295 }
289 } 296 }
290 } 297 }
291 } 298 }
292 QPtrList<Todo> todos = mCalendar->todos( ); 299 QPtrList<Todo> todos = mCalendar->todos( );
293 mMatchedTodos.clear(); 300 mMatchedTodos.clear();
294 if ( mSearchTodo->isChecked() ) { 301 if ( mSearchTodo->isChecked() ) {
295 Todo *tod; 302 Todo *tod;
296 for(tod=todos.first();tod;tod=todos.next()) { 303 for(tod=todos.first();tod;tod=todos.next()) {
297 if (mSummaryCheck->isChecked()) { 304 if (mSummaryCheck->isChecked()) {
298#if QT_VERSION >= 0x030000 305#if QT_VERSION >= 0x030000
299 if (re.search(tod->summary()) != -1) 306 if (re.search(tod->summary()) != -1)
300#else 307#else
301 if (re.match(tod->summary()) != -1) 308 if (re.match(tod->summary()) != -1)
302#endif 309#endif
303 { 310 {
304 mMatchedTodos.append(tod); 311 mMatchedTodos.append(tod);
305 continue; 312 continue;
306 } 313 }
307 } 314 }
308 if (mDescriptionCheck->isChecked()) { 315 if (mDescriptionCheck->isChecked()) {
309#if QT_VERSION >= 0x030000 316#if QT_VERSION >= 0x030000
310 if (re.search(tod->description()) != -1) 317 if (re.search(tod->description()) != -1)
311#else 318#else
312 if (re.match(tod->description()) != -1) 319 if (re.match(tod->description()) != -1)
313#endif 320#endif
314 { 321 {
315 mMatchedTodos.append(tod); 322 mMatchedTodos.append(tod);
316 continue; 323 continue;
317 } 324 }
318 } 325 }
319 if (mCategoryCheck->isChecked()) { 326 if (mCategoryCheck->isChecked()) {
320#if QT_VERSION >= 0x030000 327#if QT_VERSION >= 0x030000
321 if (re.search(tod->categoriesStr()) != -1) 328 if (re.search(tod->categoriesStr()) != -1)
322#else 329#else
323 if (re.match(tod->categoriesStr()) != -1) 330 if (re.match(tod->categoriesStr()) != -1)
324#endif 331#endif
325 { 332 {
326 mMatchedTodos.append(tod); 333 mMatchedTodos.append(tod);
327 continue; 334 continue;
328 } 335 }
329 } 336 }
330 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 337 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
331 QPtrList<Attendee> tmpAList = tod->attendees(); 338 QPtrList<Attendee> tmpAList = tod->attendees();
332 Attendee *a; 339 Attendee *a;
333 for (a = tmpAList.first(); a; a = tmpAList.next()) { 340 for (a = tmpAList.first(); a; a = tmpAList.next()) {
334 if (mSearchAName->isChecked()) { 341 if (mSearchAName->isChecked()) {
335#if QT_VERSION >= 0x030000 342#if QT_VERSION >= 0x030000
336 if (re.search(a->name()) != -1) 343 if (re.search(a->name()) != -1)
337#else 344#else
338 if (re.match(a->name()) != -1) 345 if (re.match(a->name()) != -1)
339#endif 346#endif
340 { 347 {
341 mMatchedTodos.append(tod); 348 mMatchedTodos.append(tod);
342 break; 349 break;
343 } 350 }
344 } 351 }
345 if (mSearchAEmail->isChecked()) { 352 if (mSearchAEmail->isChecked()) {
346#if QT_VERSION >= 0x030000 353#if QT_VERSION >= 0x030000
347 if (re.search(a->email()) != -1) 354 if (re.search(a->email()) != -1)
348#else 355#else
349 if (re.match(a->email()) != -1) 356 if (re.match(a->email()) != -1)
350#endif 357#endif
351 { 358 {
352 mMatchedTodos.append(tod); 359 mMatchedTodos.append(tod);
353 break; 360 break;
354 } 361 }
355 } 362 }
356 } 363 }
357 } 364 }
358 } 365 }
359 } 366 }
360 mMatchedJournals.clear(); 367 mMatchedJournals.clear();
361 if (mSearchJournal->isChecked() ) { 368 if (mSearchJournal->isChecked() ) {
362 QPtrList<Journal> journals = mCalendar->journals( ); 369 QPtrList<Journal> journals = mCalendar->journals( );
363 Journal* journ; 370 Journal* journ;
364 371
365 for(journ=journals.first();journ;journ=journals.next()) { 372 for(journ=journals.first();journ;journ=journals.next()) {
366 if ( journ->dtStart().date() <= mEndDate->date() 373 if ( journ->dtStart().date() <= mEndDate->date()
367 &&journ->dtStart().date() >= mStartDate->date()) { 374 &&journ->dtStart().date() >= mStartDate->date()) {
368#if QT_VERSION >= 0x030000 375#if QT_VERSION >= 0x030000
369 if (re.search(journ->description()) != -1) 376 if (re.search(journ->description()) != -1)
370#else 377#else
371 if (re.match(journ->description()) != -1) 378 if (re.match(journ->description()) != -1)
372#endif 379#endif
373 { 380 {
374 mMatchedJournals.append(journ); 381 mMatchedJournals.append(journ);
375 continue; 382 continue;
376 } 383 }
377 } 384 }
378 } 385 }
379 } 386 }
380 387
381} 388}
382 389
383void SearchDialog::keyPressEvent ( QKeyEvent *e) 390void SearchDialog::keyPressEvent ( QKeyEvent *e)
384{ 391{
385 switch ( e->key() ) { 392 switch ( e->key() ) {
386 case Qt::Key_Escape: 393 case Qt::Key_Escape:
387 hide(); 394 hide();
388 break; 395 break;
389 case Qt::Key_F: 396 case Qt::Key_F:
390 if ( e->state() == Qt::ControlButton ) { 397 if ( e->state() == Qt::ControlButton ) {
391 qDebug("full "); 398 qDebug("full ");
392 399
393 } 400 }
394 break; 401 break;
395 case Qt::Key_Return: 402 case Qt::Key_Return:
396 case Qt::Key_Enter: 403 case Qt::Key_Enter:
397 doSearch(); 404 doSearch();
398 break; 405 break;
399 406
400 default: 407 default:
401 e->ignore(); 408 e->ignore();
402 } 409 }
403} 410}
404 411
405//mMatchedJournals; 412//mMatchedJournals;
diff --git a/korganizer/searchdialog.h b/korganizer/searchdialog.h
index f4aad9e..b730ed5 100644
--- a/korganizer/searchdialog.h
+++ b/korganizer/searchdialog.h
@@ -1,92 +1,94 @@
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#ifndef SEARCHDIALOG_H 24#ifndef SEARCHDIALOG_H
25#define SEARCHDIALOG_H 25#define SEARCHDIALOG_H
26 26
27#include <qregexp.h> 27#include <qregexp.h>
28 28
29#include <kdialogbase.h> 29#include <kdialogbase.h>
30#include <qvbox.h> 30#include <qvbox.h>
31 31
32#include <libkcal/calendar.h> 32#include <libkcal/calendar.h>
33 33
34#include "kolistview.h" 34#include "kolistview.h"
35 35
36class KDateEdit; 36class KDateEdit;
37class QCheckBox; 37class QCheckBox;
38class QLineEdit; 38class QLineEdit;
39class KLineEdit;
39class QLabel; 40class QLabel;
40class CalendarView; 41class CalendarView;
41 42
42using namespace KCal; 43using namespace KCal;
43class SearchDialog : public QVBox 44class SearchDialog : public QVBox
44{ 45{
45 Q_OBJECT 46 Q_OBJECT
46 public: 47 public:
47 SearchDialog(Calendar *calendar,CalendarView *parent=0); 48 SearchDialog(Calendar *calendar,CalendarView *parent=0);
48 virtual ~SearchDialog(); 49 virtual ~SearchDialog();
49 KOListView *listview(){ return listView;} 50 KOListView *listview(){ return listView;}
50 void updateView(); 51 void updateView();
51 52
52 public slots: 53 public slots:
53 void changeEventDisplay(Event *, int) { updateView(); } 54 void changeEventDisplay(Event *, int) { updateView(); }
54 void updateConfig(); 55 void updateConfig();
55 void updateList(); 56 void updateList();
56 protected slots: 57 protected slots:
58 void setFocusToList();
57 void accept(); 59 void accept();
58 void doSearch(); 60 void doSearch();
59 void searchTextChanged( const QString &_text ); 61 void searchTextChanged( const QString &_text );
60 62
61 signals: 63 signals:
62 void showEventSignal(Event *); 64 void showEventSignal(Event *);
63 void editEventSignal(Event *); 65 void editEventSignal(Event *);
64 void deleteEventSignal(Event *); 66 void deleteEventSignal(Event *);
65 67
66 private: 68 private:
67 void search(const QRegExp &); 69 void search(const QRegExp &);
68 70
69 Calendar *mCalendar; 71 Calendar *mCalendar;
70 72
71 QPtrList<Event> mMatchedEvents; 73 QPtrList<Event> mMatchedEvents;
72 QPtrList<Todo> mMatchedTodos; 74 QPtrList<Todo> mMatchedTodos;
73 QPtrList<Journal> mMatchedJournals; 75 QPtrList<Journal> mMatchedJournals;
74 76
75 QLabel *searchLabel; 77 QLabel *searchLabel;
76 QLineEdit *searchEdit; 78 KLineEdit *searchEdit;
77 KOListView *listView; 79 KOListView *listView;
78 80
79 KDateEdit *mStartDate; 81 KDateEdit *mStartDate;
80 KDateEdit *mEndDate; 82 KDateEdit *mEndDate;
81 QCheckBox *mSummaryCheck; 83 QCheckBox *mSummaryCheck;
82 QCheckBox *mDescriptionCheck; 84 QCheckBox *mDescriptionCheck;
83 QCheckBox *mCategoryCheck; 85 QCheckBox *mCategoryCheck;
84 QCheckBox *mSearchEvent; 86 QCheckBox *mSearchEvent;
85 QCheckBox *mSearchTodo; 87 QCheckBox *mSearchTodo;
86 QCheckBox *mSearchJournal; 88 QCheckBox *mSearchJournal;
87 QCheckBox *mSearchAName; 89 QCheckBox *mSearchAName;
88 QCheckBox *mSearchAEmail; 90 QCheckBox *mSearchAEmail;
89 void keyPressEvent ( QKeyEvent *e) ; 91 void keyPressEvent ( QKeyEvent *e) ;
90}; 92};
91 93
92#endif 94#endif