summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/osearch/applnksearch.cpp5
-rw-r--r--core/pim/osearch/contactitem.cpp4
-rw-r--r--core/pim/osearch/datebooksearch.cpp53
-rw-r--r--core/pim/osearch/datebooksearch.h8
-rw-r--r--core/pim/osearch/doclnksearch.cpp1
-rw-r--r--core/pim/osearch/mainwindow.cpp45
-rw-r--r--core/pim/osearch/mainwindow.h2
-rw-r--r--core/pim/osearch/olistviewitem.cpp11
-rw-r--r--core/pim/osearch/olistviewitem.h3
-rw-r--r--core/pim/osearch/searchgroup.cpp50
-rw-r--r--core/pim/osearch/searchgroup.h9
-rw-r--r--core/pim/osearch/todosearch.cpp37
-rw-r--r--core/pim/osearch/todosearch.h6
13 files changed, 175 insertions, 59 deletions
diff --git a/core/pim/osearch/applnksearch.cpp b/core/pim/osearch/applnksearch.cpp
index d5b181b..5fa36bb 100644
--- a/core/pim/osearch/applnksearch.cpp
+++ b/core/pim/osearch/applnksearch.cpp
@@ -1,68 +1,67 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "applnksearch.h" 13#include "applnksearch.h"
14 14
15#include <qpe/applnk.h> 15#include <qpe/applnk.h>
16#include <qpe/qpeapplication.h> 16#include <qpe/qpeapplication.h>
17#include <qiconset.h> 17#include <qiconset.h>
18#include <qpe/resource.h> 18#include <qpe/resource.h>
19 19
20#include "applnkitem.h" 20#include "applnkitem.h"
21 21
22AppLnkSearch::AppLnkSearch(QListView* parent, QString name): SearchGroup(parent, name) 22AppLnkSearch::AppLnkSearch(QListView* parent, QString name): SearchGroup(parent, name)
23{ 23{
24 _apps = 0; 24 _apps = 0;
25 QIconSet is = Resource::loadIconSet( "osearch/applications" ); 25 QIconSet is = Resource::loadIconSet( "osearch/applications" );
26 //QIconSet is = Resource::loadIconSet( "AppsIcon" ); 26 //QIconSet is = Resource::loadIconSet( "AppsIcon" );
27 setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); 27 setPixmap( 0, is.pixmap( QIconSet::Small, true ) );
28} 28}
29 29
30 30
31AppLnkSearch::~AppLnkSearch() 31AppLnkSearch::~AppLnkSearch()
32{ 32{
33 delete _apps; 33 delete _apps;
34} 34}
35 35
36 36
37void AppLnkSearch::load() 37void AppLnkSearch::load()
38{ 38{
39 _apps = new AppLnkSet(QPEApplication::qpeDir()); 39 _apps = new AppLnkSet(QPEApplication::qpeDir());
40} 40}
41 41
42int AppLnkSearch::search() 42int AppLnkSearch::search()
43{ 43{
44 int count = 0;
45 QList<AppLnk> appList = _apps->children(); 44 QList<AppLnk> appList = _apps->children();
46 for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){ 45 for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){
47 if ( (_search.match( app->name() ) != -1) 46 if ( (_search.match( app->name() ) != -1)
48 || (_search.match(app->comment()) != -1) 47 || (_search.match(app->comment()) != -1)
49 || (_search.match(app->exec()) != -1) ) { 48 || (_search.match(app->exec()) != -1) ) {
50 count++;
51 insertItem( app ); 49 insertItem( app );
52 } 50 }
53 qApp->processEvents( 100 ); 51 qApp->processEvents( 100 );
54 } 52 }
55 return count; 53 return _resultCount;
56} 54}
57 55
58void AppLnkSearch::insertItem( void *rec ) 56void AppLnkSearch::insertItem( void *rec )
59{ 57{
60 new AppLnkItem( this, (AppLnk*)rec ); 58 new AppLnkItem( this, (AppLnk*)rec );
59 _resultCount++;
61} 60}
62 61
63void AppLnkSearch::setSearch(QRegExp re) 62void AppLnkSearch::setSearch(QRegExp re)
64{ 63{
65 setOpen( false ); 64 setOpen( false );
66 SearchGroup::setSearch( re ); 65 SearchGroup::setSearch( re );
67} 66}
68 67
diff --git a/core/pim/osearch/contactitem.cpp b/core/pim/osearch/contactitem.cpp
index 1d24b18..ad43ba2 100644
--- a/core/pim/osearch/contactitem.cpp
+++ b/core/pim/osearch/contactitem.cpp
@@ -25,104 +25,104 @@ ContactItem::ContactItem(OListViewItem* parent, OContact *contact)
25 setIcon(); 25 setIcon();
26} 26}
27 27
28void ContactItem::setIcon() 28void ContactItem::setIcon()
29{ 29{
30 QPixmap icon; 30 QPixmap icon;
31 switch ( _contact->lastHitField() ) { 31 switch ( _contact->lastHitField() ) {
32 case -1: 32 case -1:
33 icon = Resource::loadPixmap( "reset" ); 33 icon = Resource::loadPixmap( "reset" );
34 break; 34 break;
35 case Qtopia::BusinessPhone: 35 case Qtopia::BusinessPhone:
36 icon = Resource::loadPixmap( "addressbook/phonework" ); 36 icon = Resource::loadPixmap( "addressbook/phonework" );
37 break; 37 break;
38 case Qtopia::BusinessFax: 38 case Qtopia::BusinessFax:
39 icon = Resource::loadPixmap( "addressbook/faxwork" ); 39 icon = Resource::loadPixmap( "addressbook/faxwork" );
40 break; 40 break;
41 case Qtopia::BusinessMobile: 41 case Qtopia::BusinessMobile:
42 icon = Resource::loadPixmap( "addressbook/mobilework" ); 42 icon = Resource::loadPixmap( "addressbook/mobilework" );
43 break; 43 break;
44 case Qtopia::DefaultEmail: 44 case Qtopia::DefaultEmail:
45 icon = Resource::loadPixmap( "addressbook/email" ); 45 icon = Resource::loadPixmap( "addressbook/email" );
46 break; 46 break;
47 case Qtopia::Emails: 47 case Qtopia::Emails:
48 icon = Resource::loadPixmap( "addressbook/email" ); 48 icon = Resource::loadPixmap( "addressbook/email" );
49 break; 49 break;
50 case Qtopia::HomePhone: 50 case Qtopia::HomePhone:
51 icon = Resource::loadPixmap( "addressbook/phonehome" ); 51 icon = Resource::loadPixmap( "addressbook/phonehome" );
52 break; 52 break;
53 case Qtopia::HomeFax: 53 case Qtopia::HomeFax:
54 icon = Resource::loadPixmap( "addressbook/faxhome" ); 54 icon = Resource::loadPixmap( "addressbook/faxhome" );
55 break; 55 break;
56 case Qtopia::HomeMobile: 56 case Qtopia::HomeMobile:
57 icon = Resource::loadPixmap( "addressbook/mobilehome" ); 57 icon = Resource::loadPixmap( "addressbook/mobilehome" );
58 break; 58 break;
59 case Qtopia::HomeWebPage: 59 case Qtopia::HomeWebPage:
60 icon = Resource::loadPixmap( "addressbook/webpagehome" ); 60 icon = Resource::loadPixmap( "addressbook/webpagehome" );
61 break; 61 break;
62 case Qtopia::BusinessWebPage: 62 case Qtopia::BusinessWebPage:
63 icon = Resource::loadPixmap( "addressbook/webpagework" ); 63 icon = Resource::loadPixmap( "addressbook/webpagework" );
64 break; 64 break;
65 case Qtopia::Title: 65 case Qtopia::Title:
66 case Qtopia::JobTitle: 66 case Qtopia::JobTitle:
67 case Qtopia::FirstName: 67 case Qtopia::FirstName:
68 case Qtopia::MiddleName: 68 case Qtopia::MiddleName:
69 case Qtopia::LastName: 69 case Qtopia::LastName:
70 case Qtopia::Suffix: 70 case Qtopia::Suffix:
71 case Qtopia::Nickname: 71 case Qtopia::Nickname:
72 case Qtopia::FileAs: 72 case Qtopia::FileAs:
73 icon = Resource::loadPixmap( "addressbook/identity" ); 73 icon = Resource::loadPixmap( "osearch/identity" );
74 break; 74 break;
75 case Qtopia::HomeStreet: 75 case Qtopia::HomeStreet:
76 case Qtopia::HomeCity: 76 case Qtopia::HomeCity:
77 case Qtopia::HomeState: 77 case Qtopia::HomeState:
78 case Qtopia::HomeZip: 78 case Qtopia::HomeZip:
79 case Qtopia::HomeCountry: 79 case Qtopia::HomeCountry:
80 icon = Resource::loadPixmap( "addressbook/addresshome" ); 80 icon = Resource::loadPixmap( "osearch/addresshome" );
81 break; 81 break;
82 case Qtopia::Company: 82 case Qtopia::Company:
83 case Qtopia::BusinessCity: 83 case Qtopia::BusinessCity:
84 case Qtopia::BusinessStreet: 84 case Qtopia::BusinessStreet:
85 case Qtopia::BusinessZip: 85 case Qtopia::BusinessZip:
86 case Qtopia::BusinessCountry: 86 case Qtopia::BusinessCountry:
87 case Qtopia::Department: 87 case Qtopia::Department:
88 case Qtopia::Office: 88 case Qtopia::Office:
89 case Qtopia::Manager: 89 case Qtopia::Manager:
90 case Qtopia::BusinessPager: 90 case Qtopia::BusinessPager:
91 case Qtopia::Profession: 91 case Qtopia::Profession:
92 icon = Resource::loadPixmap( "addressbook/addresshome" ); 92 icon = Resource::loadPixmap( "addressbook/addresshome" );
93 break; 93 break;
94 case Qtopia::Assistant: 94 case Qtopia::Assistant:
95 case Qtopia::Spouse: 95 case Qtopia::Spouse:
96 case Qtopia::Children: 96 case Qtopia::Children:
97 icon = Resource::loadPixmap( "osearch/personal" ); 97 icon = Resource::loadPixmap( "osearch/personal" );
98 break; 98 break;
99 case Qtopia::Birthday: 99 case Qtopia::Birthday:
100 case Qtopia::Anniversary: 100 case Qtopia::Anniversary:
101 icon = Resource::loadPixmap( "osearch/clock" ); 101 icon = Resource::loadPixmap( "osearch/clock" );
102 break; 102 break;
103 case Qtopia::Notes: 103 case Qtopia::Notes:
104 icon = Resource::loadPixmap( "txt" ); 104 icon = Resource::loadPixmap( "txt" );
105 break; 105 break;
106 default: 106 default:
107 icon = Resource::loadPixmap( "DocsIcon" ); 107 icon = Resource::loadPixmap( "DocsIcon" );
108 break; 108 break;
109 } 109 }
110 setPixmap( 0, icon ); 110 setPixmap( 0, icon );
111} 111}
112 112
113ContactItem::~ContactItem() 113ContactItem::~ContactItem()
114{ 114{
115 delete _contact; 115 delete _contact;
116} 116}
117 117
118 118
119QString ContactItem::toRichText() 119QString ContactItem::toRichText()
120{ 120{
121 return _contact->toRichText(); 121 return _contact->toRichText();
122} 122}
123 123
124void ContactItem::action( int act ) 124void ContactItem::action( int act )
125{ 125{
126if (act == 0){ 126if (act == 0){
127 QCopEnvelope e("QPE/Application/addressbook", "show(int)"); 127 QCopEnvelope e("QPE/Application/addressbook", "show(int)");
128 e << _contact->uid(); 128 e << _contact->uid();
diff --git a/core/pim/osearch/datebooksearch.cpp b/core/pim/osearch/datebooksearch.cpp
index 7aabcea..5da7ae9 100644
--- a/core/pim/osearch/datebooksearch.cpp
+++ b/core/pim/osearch/datebooksearch.cpp
@@ -1,55 +1,92 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "datebooksearch.h" 13#include "datebooksearch.h"
14 14
15#include "eventitem.h" 15#include "eventitem.h"
16 16
17#include <qpe/resource.h>
18#include <qpe/config.h>
17#include <opie/oevent.h> 19#include <opie/oevent.h>
20#include <opie/orecur.h>
18#include <opie/odatebookaccess.h> 21#include <opie/odatebookaccess.h>
19#include <qiconset.h> 22#include <qiconset.h>
20#include <qpe/resource.h> 23#include <qaction.h>
24#include <qdatetime.h>
25#include <qpopupmenu.h>
21 26
22DatebookSearch::DatebookSearch(QListView* parent, QString name) 27DatebookSearch::DatebookSearch(QListView* parent, QString name)
23: SearchGroup(parent, name) 28: SearchGroup(parent, name), _dates(0), _popupMenu(0)
24{ 29{
25 _dates = 0;
26 QIconSet is = Resource::loadIconSet( "datebook/DateBook" ); 30 QIconSet is = Resource::loadIconSet( "datebook/DateBook" );
27 setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); 31 setPixmap( 0, is.pixmap( QIconSet::Small, true ) );
28 32 actionShowPastEvents = new QAction( QObject::tr("show past events"),QString::null, 0, 0, 0, true );
33 actionSearchInDates = new QAction( QObject::tr("search in dates"),QString::null, 0, 0, 0, true );
34 Config cfg( "osearch", Config::User );
35 cfg.setGroup( "datebook_settings" );
36 actionShowPastEvents->setOn( cfg.readBoolEntry( "show_past_events", false ) );
37 actionSearchInDates->setOn( cfg.readBoolEntry( "search_in_dates", true ) );
29} 38}
30 39
31
32DatebookSearch::~DatebookSearch() 40DatebookSearch::~DatebookSearch()
33{ 41{
42 qDebug("SAVE DATEBOOK SEARCH CONFIG");
43 Config cfg( "osearch", Config::User );
44 cfg.setGroup( "datebook_settings" );
45 cfg.writeEntry( "show_past_events", actionShowPastEvents->isOn() );
46 cfg.writeEntry( "search_in_dates", actionSearchInDates->isOn() );
34 delete _dates; 47 delete _dates;
48 delete _popupMenu;
49 delete actionShowPastEvents;
50 delete actionSearchInDates;
35} 51}
36 52
37 53
38void DatebookSearch::load() 54void DatebookSearch::load()
39{ 55{
40 _dates = new ODateBookAccess(); 56 _dates = new ODateBookAccess();
41 _dates->load(); 57 _dates->load();
42} 58}
43 59
44int DatebookSearch::search() 60int DatebookSearch::search()
45{ 61{
46 ORecordList<OEvent> results = _dates->matchRegexp(_search); 62 ORecordList<OEvent> results = _dates->matchRegexp(_search);
47 for (uint i = 0; i < results.count(); i++) 63 for (uint i = 0; i < results.count(); i++)
48 new EventItem( this, new OEvent( results[i] )); 64 insertItem( new OEvent( results[i] ) );
49 return results.count(); 65 return _resultCount;
50} 66}
51 67
52void DatebookSearch::insertItem( void* ) 68void DatebookSearch::insertItem( void *rec )
53{ 69{
70 OEvent *ev = (OEvent*)rec;
71 if ( !actionShowPastEvents->isOn() &&
72 ev->endDateTime() < QDateTime::currentDateTime() &&
73 !ev->recurrence().doesRecur()
74 ) return;
75 if ( !actionSearchInDates->isOn() && (
76 ev->lastHitField() == Qtopia::StartDateTime ||
77 ev->lastHitField() == Qtopia::EndDateTime )
78 ) return;
79 new EventItem( this, ev );
80 _resultCount++;
81}
54 82
83QPopupMenu* DatebookSearch::popupMenu()
84{
85 if (!_popupMenu){
86 _popupMenu = new QPopupMenu( 0 );
87 actionShowPastEvents->addTo( _popupMenu );
88 actionSearchInDates->addTo( _popupMenu );
89 }
90 return _popupMenu;
55} 91}
92
diff --git a/core/pim/osearch/datebooksearch.h b/core/pim/osearch/datebooksearch.h
index bb31462..a6d115e 100644
--- a/core/pim/osearch/datebooksearch.h
+++ b/core/pim/osearch/datebooksearch.h
@@ -1,40 +1,44 @@
1// 1//
2// 2//
3// C++ Interface: $MODULE$ 3// C++ Interface: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#ifndef DATEBOOKSEARCH_H 13#ifndef DATEBOOKSEARCH_H
14#define DATEBOOKSEARCH_H 14#define DATEBOOKSEARCH_H
15 15
16#include "searchgroup.h" 16#include "searchgroup.h"
17 17
18class ODateBookAccess; 18class ODateBookAccess;
19class QAction;
19 20
20/** 21/**
21@author Patrick S. Vogt 22@author Patrick S. Vogt
22*/ 23*/
23class DatebookSearch : public SearchGroup 24class DatebookSearch : public SearchGroup
24{ 25{
25public: 26public:
26 DatebookSearch(QListView* parent, QString name); 27 DatebookSearch(QListView* parent, QString name);
27
28 ~DatebookSearch(); 28 ~DatebookSearch();
29 29
30 virtual QPopupMenu* popupMenu();
31
30protected: 32protected:
31 virtual void load(); 33 virtual void load();
32 virtual int search(); 34 virtual int search();
33 virtual void insertItem( void* ); 35 virtual void insertItem( void* );
34 36
35private: 37private:
36 ODateBookAccess *_dates; 38 ODateBookAccess *_dates;
37 39 QAction *actionShowPastEvents;
40 QAction *actionSearchInDates;
41 QPopupMenu *_popupMenu;
38}; 42};
39 43
40#endif 44#endif
diff --git a/core/pim/osearch/doclnksearch.cpp b/core/pim/osearch/doclnksearch.cpp
index 123eaa0..d97eeb8 100644
--- a/core/pim/osearch/doclnksearch.cpp
+++ b/core/pim/osearch/doclnksearch.cpp
@@ -1,42 +1,43 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "doclnksearch.h" 13#include "doclnksearch.h"
14 14
15#include <qpe/applnk.h> 15#include <qpe/applnk.h>
16#include <qpe/qpeapplication.h> 16#include <qpe/qpeapplication.h>
17#include <qiconset.h> 17#include <qiconset.h>
18#include <qpe/resource.h> 18#include <qpe/resource.h>
19 19
20#include "doclnkitem.h" 20#include "doclnkitem.h"
21 21
22DocLnkSearch::DocLnkSearch(QListView* parent, QString name) 22DocLnkSearch::DocLnkSearch(QListView* parent, QString name)
23: AppLnkSearch(parent, name) 23: AppLnkSearch(parent, name)
24{ 24{
25 QIconSet is = Resource::loadIconSet( "osearch/documents" ); 25 QIconSet is = Resource::loadIconSet( "osearch/documents" );
26 setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); 26 setPixmap( 0, is.pixmap( QIconSet::Small, true ) );
27} 27}
28 28
29 29
30DocLnkSearch::~DocLnkSearch() 30DocLnkSearch::~DocLnkSearch()
31{ 31{
32} 32}
33 33
34void DocLnkSearch::load() 34void DocLnkSearch::load()
35{ 35{
36 _apps = new DocLnkSet(QPEApplication::documentDir()); 36 _apps = new DocLnkSet(QPEApplication::documentDir());
37} 37}
38 38
39void DocLnkSearch::insertItem( void *rec ) 39void DocLnkSearch::insertItem( void *rec )
40{ 40{
41 new DocLnkItem( this, (DocLnk*)rec ); 41 new DocLnkItem( this, (DocLnk*)rec );
42 _resultCount++;
42} 43}
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp
index b80c637..89ab690 100644
--- a/core/pim/osearch/mainwindow.cpp
+++ b/core/pim/osearch/mainwindow.cpp
@@ -1,237 +1,264 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 10// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
11 11
12 12
13#include "mainwindow.h" 13#include "mainwindow.h"
14 14
15#include <qpe/qpemenubar.h> 15#include <qpe/qpemenubar.h>
16#include <qpe/qpemessagebox.h> 16#include <qpe/qpemessagebox.h>
17#include <qpe/resource.h> 17#include <qpe/resource.h>
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include <qpe/qpetoolbar.h> 19#include <qpe/qpetoolbar.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/config.h> 21#include <qpe/config.h>
22#include <qpe/global.h>
22#include <qaction.h> 23#include <qaction.h>
23#include <qmessagebox.h> 24#include <qmessagebox.h>
24#include <qpopupmenu.h> 25#include <qpopupmenu.h>
25#include <qtoolbutton.h> 26#include <qtoolbutton.h>
26#include <qstring.h> 27#include <qstring.h>
27#include <qlabel.h> 28#include <qlabel.h>
28#include <qfile.h> 29#include <qfile.h>
29#include <qhbuttongroup.h> 30#include <qhbuttongroup.h>
30#include <qpushbutton.h> 31#include <qpushbutton.h>
31#include <qintdict.h> 32#include <qintdict.h>
32#include <qlayout.h> 33#include <qlayout.h>
33#include <qlineedit.h> 34#include <qlineedit.h>
34#include <qtextbrowser.h> 35#include <qtextbrowser.h>
35#include <qregexp.h> 36#include <qregexp.h>
36 37
37#include "olistview.h" 38#include "olistview.h"
38#include "olistviewitem.h" 39#include "olistviewitem.h"
39#include "resultitem.h" 40#include "resultitem.h"
40#include "adresssearch.h" 41#include "adresssearch.h"
41#include "todosearch.h" 42#include "todosearch.h"
42#include "datebooksearch.h" 43#include "datebooksearch.h"
43#include "applnksearch.h" 44#include "applnksearch.h"
44#include "doclnksearch.h" 45#include "doclnksearch.h"
45 46
46MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : 47MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
47 QMainWindow( parent, name, f ), _currentItem(0) 48 QMainWindow( parent, name, f ), _currentItem(0)
48{ 49{
49 setCaption( tr("OSearch") ); 50 setCaption( tr("OSearch") );
50 51
51 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); 52 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
52 53
53 QFrame *mainFrame = new QFrame( this, "mainFrame" ); 54 QFrame *mainFrame = new QFrame( this, "mainFrame" );
54 55
55 mainLayout = new QVBoxLayout( mainFrame ); 56 mainLayout = new QVBoxLayout( mainFrame );
56 mainLayout->setSpacing( 0 ); 57 mainLayout->setSpacing( 0 );
57 mainLayout->setMargin( 0 ); 58 mainLayout->setMargin( 0 );
58 59
59 resultsList = new OListView( mainFrame ); 60 resultsList = new OListView( mainFrame );
60 resultsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); 61 resultsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
61 mainLayout->addWidget( resultsList, 1 ); 62 mainLayout->addWidget( resultsList, 1 );
62 63
63 detailsFrame = new QFrame( mainFrame, "detailsFrame" ); 64 detailsFrame = new QFrame( mainFrame, "detailsFrame" );
64 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); 65 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame );
65 richEdit = new QTextView( detailsFrame ); 66 richEdit = new QTextView( detailsFrame );
66 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); 67 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
67 //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum )); 68 //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ));
68 detailsLayout->addWidget( richEdit, 1 ); 69 detailsLayout->addWidget( richEdit, 1 );
69 70
70 buttonGroupActions = new QHButtonGroup( this ); 71 buttonGroupActions = new QHButtonGroup( this );
71 buttonGroupActions->hide(); 72 buttonGroupActions->hide();
72 _buttonCount = 0; 73 _buttonCount = 0;
73// buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 74// buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
74 75
75 buttonLayout = new QHBoxLayout( detailsFrame ); 76 buttonLayout = new QHBoxLayout( detailsFrame );
76 detailsLayout->addLayout( buttonLayout ); 77 detailsLayout->addLayout( buttonLayout );
77 78
78 mainLayout->addWidget( detailsFrame ); 79 mainLayout->addWidget( detailsFrame );
79 detailsFrame->hide(); 80 detailsFrame->hide();
80 81
81 searches.append( new AppLnkSearch( resultsList, tr("applications") ) ); 82 searches.append( new AppLnkSearch( resultsList, tr("applications") ) );
82 searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); 83 searches.append( new DocLnkSearch( resultsList, tr("documents") ) );
83 searches.append( new TodoSearch( resultsList, tr("todo") ) ); 84 searches.append( new TodoSearch( resultsList, tr("todo") ) );
84 searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); 85 searches.append( new DatebookSearch( resultsList, tr("datebook") ) );
85 searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); 86 searches.append( new AdressSearch( resultsList, tr("adressbook") ) );
86 87
87 makeMenu();
88 setCentralWidget( mainFrame ); 88 setCentralWidget( mainFrame );
89 89
90 popupTimer = new QTimer(); 90 popupTimer = new QTimer();
91 searchTimer = new QTimer(); 91 searchTimer = new QTimer();
92 92
93 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); 93 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup()));
94 connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); 94 connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged()));
95 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); 95 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*)));
96 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); 96 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*)));
97 connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); 97 connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) );
98 98
99 makeMenu();
99 100
100 Config cfg( "osearch", Config::User ); 101 Config cfg( "osearch", Config::User );
101 cfg.setGroup( "search_settings" ); 102 cfg.setGroup( "search_settings" );
102 actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); 103 actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) );
103 actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); 104 actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) );
105// actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) );
104} 106}
105 107
106void MainWindow::makeMenu() 108void MainWindow::makeMenu()
107{ 109{
108 QPEToolBar *toolBar = new QPEToolBar( this ); 110 QPEToolBar *toolBar = new QPEToolBar( this );
109 QPEToolBar *searchBar = new QPEToolBar(this); 111 QPEToolBar *searchBar = new QPEToolBar(this);
110 QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); 112 QPEMenuBar *menuBar = new QPEMenuBar( toolBar );
111 QPopupMenu *searchMenu = new QPopupMenu( menuBar ); 113 QPopupMenu *searchMenu = new QPopupMenu( menuBar );
112// QPopupMenu *viewMenu = new QPopupMenu( menuBar ); 114// QPopupMenu *viewMenu = new QPopupMenu( menuBar );
113 QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); 115 QPopupMenu *cfgMenu = new QPopupMenu( menuBar );
114 QPopupMenu *searchOptions = new QPopupMenu( cfgMenu ); 116 QPopupMenu *searchOptions = new QPopupMenu( cfgMenu );
115 117
116 setToolBarsMovable( false ); 118 setToolBarsMovable( false );
117 toolBar->setHorizontalStretchable( true ); 119 toolBar->setHorizontalStretchable( true );
118 menuBar->insertItem( tr( "Search" ), searchMenu ); 120 menuBar->insertItem( tr( "Search" ), searchMenu );
119 menuBar->insertItem( tr( "Settings" ), cfgMenu ); 121 menuBar->insertItem( tr( "Settings" ), cfgMenu );
122
123 //SETTINGS MENU
120 cfgMenu->insertItem( tr( "Search" ), searchOptions ); 124 cfgMenu->insertItem( tr( "Search" ), searchOptions );
125 QPopupMenu *pop;
126 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
127 pop = s->popupMenu();
128 if (pop){
129 qDebug("inserting settings menu for %s",s->text(0).latin1());
130 cfgMenu->insertItem( s->text(0), pop );
131 //connect( pop, SIGNAL( activated(int) ), SLOT( optionChanged(int) ) );
132 }
133 }
121 134
122 135
123 //SEARCH 136 //SEARCH
124 SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); 137 SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 );
125 SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); 138 SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) );
126 connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); 139 connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) );
127 SearchAllAction->addTo( searchMenu ); 140 SearchAllAction->addTo( searchMenu );
128 searchMenu->insertItem( tr( "Options" ), searchOptions ); 141 searchMenu->insertItem( tr( "Options" ), searchOptions );
142 //connect( searchOptions, SIGNAL( activated(int) ), SLOT( optionChanged(int) ) );
129 143
130 //SEARCH OPTIONS 144 //SEARCH OPTIONS
145 //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true );
146 //actionWholeWordsOnly->addTo( searchOptions );
131 actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); 147 actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true );
132 actionCaseSensitiv->addTo( searchOptions ); 148 actionCaseSensitiv->addTo( searchOptions );
133 actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); 149 actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true );
134 actionWildcards->addTo( searchOptions ); 150 actionWildcards->addTo( searchOptions );
135 151
136 //SEARCH BAR 152 //SEARCH BAR
137 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 153 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
138 QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); 154 QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" );
139 searchEdit->setFocus(); 155 searchEdit->setFocus();
140 searchBar->setHorizontalStretchable( TRUE ); 156 searchBar->setHorizontalStretchable( TRUE );
141 searchBar->setStretchableWidget( searchEdit ); 157 searchBar->setStretchableWidget( searchEdit );
142 SearchAllAction->addTo( searchBar ); 158 SearchAllAction->addTo( searchBar );
143 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 159 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
144 this, SLOT( setSearch( const QString & ) ) ); 160 this, SLOT( setSearch( const QString & ) ) );
145 161
146} 162}
147 163
148MainWindow::~MainWindow() 164MainWindow::~MainWindow()
149{ 165{
150 Config cfg( "osearch", Config::User ); 166 Config cfg( "osearch", Config::User );
151 cfg.setGroup( "search_settings" ); 167 cfg.setGroup( "search_settings" );
152 cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); 168 cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() );
153 cfg.writeEntry( "wildcards", actionWildcards->isOn() ); 169 cfg.writeEntry( "wildcards", actionWildcards->isOn() );
170 //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() );
154} 171}
155 172
156void MainWindow::setCurrent(QListViewItem *item) 173void MainWindow::setCurrent(QListViewItem *item)
157{ 174{
158 if (!item) return; 175 if (!item) return;
159 _currentItem = (OListViewItem*)item; 176 _currentItem = (OListViewItem*)item;
160 //_currentItem = dynamic_cast<OListViewItem*>(item); 177 //_currentItem = dynamic_cast<OListViewItem*>(item);
161 if (_currentItem->rtti() == OListViewItem::Result){ 178 if (_currentItem->rtti() == OListViewItem::Result){
162 ResultItem *res = (ResultItem*)item; 179 ResultItem *res = (ResultItem*)item;
163 // ResultItem *res = dynamic_cast<ResultItem*>(item); 180 // ResultItem *res = dynamic_cast<ResultItem*>(item);
164 richEdit->setText( res->toRichText() ); 181 richEdit->setText( res->toRichText() );
165 QIntDict<QString> acts = res->actions(); 182 QIntDict<QString> acts = res->actions();
166 QButton *button; 183 QButton *button;
167 for (uint i = 0; i < acts.count(); i++){ 184 for (uint i = 0; i < acts.count(); i++){
168 button = buttonGroupActions->find( i ); 185 button = buttonGroupActions->find( i );
169 qDebug("action %i >%s<",i,acts[i]->latin1()); 186 qDebug("action %i >%s<",i,acts[i]->latin1());
170 if (!button) { 187 if (!button) {
171 qDebug("BUTTON"); 188 qDebug("BUTTON");
172 button = new QPushButton( detailsFrame ); 189 button = new QPushButton( detailsFrame );
173 buttonLayout->addWidget( button, 0 ); 190 buttonLayout->addWidget( button, 0 );
174 buttonGroupActions->insert( button, i); 191 buttonGroupActions->insert( button, i);
175 } 192 }
176 button->setText( *acts[i] ); 193 button->setText( *acts[i] );
177 button->show(); 194 button->show();
178 } 195 }
179 for (uint i = acts.count(); i < _buttonCount; i++){ 196 for (uint i = acts.count(); i < _buttonCount; i++){
180 qDebug("remove button %i of %i",i, _buttonCount); 197 qDebug("remove button %i of %i",i, _buttonCount);
181 button = buttonGroupActions->find( i ); 198 button = buttonGroupActions->find( i );
182 if (button) button->hide(); 199 if (button) button->hide();
183 } 200 }
184 _buttonCount = acts.count(); 201 _buttonCount = acts.count();
185 // buttonShow = new QPushButton( detailsFrame, "Show" ) ;
186 // buttonShow->setText( "test" );
187 // buttonLayout->addWidget( buttonShow, 0 );
188// buttonGroupActions->insert(buttonShow);
189 detailsFrame->show(); 202 detailsFrame->show();
190 }else detailsFrame->hide(); 203 }else detailsFrame->hide();
191 //_currentItem = (OListViewItem*)item; 204 popupTimer->start( 300, true );
192 popupTimer->start( 300 );
193} 205}
194 206
195void MainWindow::stopTimer(QListViewItem*) 207void MainWindow::stopTimer(QListViewItem*)
196{ 208{
197 popupTimer->stop(); 209 popupTimer->stop();
198} 210}
199 211
200void MainWindow::showPopup() 212void MainWindow::showPopup()
201{ 213{
202 qDebug("showPopup"); 214 qDebug("showPopup");
215 popupTimer->stop();
203 if (!_currentItem) return; 216 if (!_currentItem) return;
217 QPopupMenu *pop = _currentItem->popupMenu();
218 if (pop) pop->popup( QCursor::pos() );
204} 219}
205 220
206void MainWindow::setSearch( const QString &key ) 221void MainWindow::setSearch( const QString &key )
207{ 222{
208 searchTimer->stop(); 223 searchTimer->stop();
209 _searchString = key; 224 _searchString = key;
210 searchTimer->start( 300 ); 225 searchTimer->start( 300 );
211} 226}
212 227
213void MainWindow::searchStringChanged() 228void MainWindow::searchStringChanged()
214{ 229{
215 searchTimer->stop(); 230 searchTimer->stop();
216 QRegExp re( _searchString, actionCaseSensitiv->isOn(), actionWildcards->isOn() ); 231 QString ss = _searchString;
232 //ss = Global::stringQuote( _searchString );
233 //if (actionWholeWordsOnly->isOn())
234 // ss = "\\s"+_searchString+"\\s";
235 qDebug(" set searchString >%s<",ss.latin1());
236 QRegExp re( ss );
237 re.setCaseSensitive( actionCaseSensitiv->isOn() );
238 re.setWildcard( actionWildcards->isOn() );
217 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) 239 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() )
218 s->setSearch( re ); 240 s->setSearch( re );
219} 241}
220 242
221void MainWindow::searchAll() 243void MainWindow::searchAll()
222{ 244{
223 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ 245 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
224 s->doSearch(); 246 s->doSearch();
225 //resultsList->repaint(); 247 //resultsList->repaint();
226 } 248 }
227} 249}
228 250
229void MainWindow::slotAction( int act) 251void MainWindow::slotAction( int act )
230{ 252{
231 if (_currentItem->rtti() == OListViewItem::Result){ 253 if (_currentItem->rtti() == OListViewItem::Result){
232 ResultItem *res = (ResultItem*)_currentItem; 254 ResultItem *res = (ResultItem*)_currentItem;
233 // ResultItem *res = dynamic_cast<ResultItem*>(item); 255 // ResultItem *res = dynamic_cast<ResultItem*>(item);
234 res->action(act); 256 res->action(act);
235 } 257 }
236} 258}
237 259
260void MainWindow::optionChanged(int i)
261{
262 qDebug("optionChanged(%i)",i);
263 searchStringChanged();
264}
diff --git a/core/pim/osearch/mainwindow.h b/core/pim/osearch/mainwindow.h
index 939762e..cba11c5 100644
--- a/core/pim/osearch/mainwindow.h
+++ b/core/pim/osearch/mainwindow.h
@@ -6,71 +6,73 @@
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 10// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
11 11
12#ifndef MAINWINDOW_H 12#ifndef MAINWINDOW_H
13#define MAINWINDOW_H 13#define MAINWINDOW_H
14 14
15#include <qmainwindow.h> 15#include <qmainwindow.h>
16#include <qdialog.h> 16#include <qdialog.h>
17#include <qaction.h> 17#include <qaction.h>
18#include <qlist.h> 18#include <qlist.h>
19#include <qtimer.h> 19#include <qtimer.h>
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21 21
22class QPEToolBar; 22class QPEToolBar;
23class QVBoxLayout; 23class QVBoxLayout;
24class QHBoxLayout; 24class QHBoxLayout;
25class QTextView; 25class QTextView;
26class QFrame; 26class QFrame;
27class QListViewItem; 27class QListViewItem;
28class OListView; 28class OListView;
29class OListViewItem; 29class OListViewItem;
30class QHButtonGroup; 30class QHButtonGroup;
31 31
32class SearchGroup; 32class SearchGroup;
33 33
34class MainWindow : public QMainWindow 34class MainWindow : public QMainWindow
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 37
38 38
39public: 39public:
40 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 40 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
41 ~MainWindow(); 41 ~MainWindow();
42 42
43 43
44public slots: 44public slots:
45 void setCurrent(QListViewItem*); 45 void setCurrent(QListViewItem*);
46 void setSearch( const QString& ); 46 void setSearch( const QString& );
47 void searchAll(); 47 void searchAll();
48 48
49protected slots: 49protected slots:
50 void slotAction(int); 50 void slotAction(int);
51 void showPopup(); 51 void showPopup();
52 void stopTimer( QListViewItem* ); 52 void stopTimer( QListViewItem* );
53 void searchStringChanged(); 53 void searchStringChanged();
54 void optionChanged(int);
54 55
55private: 56private:
56 OListView *resultsList; 57 OListView *resultsList;
57 QTextView *richEdit; 58 QTextView *richEdit;
58 OListViewItem *_currentItem; 59 OListViewItem *_currentItem;
59 QVBoxLayout *mainLayout; 60 QVBoxLayout *mainLayout;
60 QHBoxLayout *buttonLayout; 61 QHBoxLayout *buttonLayout;
61 QFrame *detailsFrame; 62 QFrame *detailsFrame;
62 QTimer *popupTimer; 63 QTimer *popupTimer;
63 QTimer *searchTimer; 64 QTimer *searchTimer;
64 65
65 QString _searchString; 66 QString _searchString;
66 QList<SearchGroup> searches; 67 QList<SearchGroup> searches;
67 QHButtonGroup *buttonGroupActions; 68 QHButtonGroup *buttonGroupActions;
68 QAction *SearchAllAction; 69 QAction *SearchAllAction;
69 QAction *actionCaseSensitiv; 70 QAction *actionCaseSensitiv;
70 QAction *actionWildcards; 71 QAction *actionWildcards;
72 //QAction *actionWholeWordsOnly;
71 uint _buttonCount; 73 uint _buttonCount;
72 void makeMenu(); 74 void makeMenu();
73}; 75};
74 76
75#endif 77#endif
76 78
diff --git a/core/pim/osearch/olistviewitem.cpp b/core/pim/osearch/olistviewitem.cpp
index 29c5942..2d67559 100644
--- a/core/pim/osearch/olistviewitem.cpp
+++ b/core/pim/osearch/olistviewitem.cpp
@@ -1,30 +1,41 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10#include "olistviewitem.h" 10#include "olistviewitem.h"
11 11
12OListViewItem::OListViewItem(OListViewItem *parent) 12OListViewItem::OListViewItem(OListViewItem *parent)
13 : QListViewItem(parent) 13 : QListViewItem(parent)
14{ 14{
15} 15}
16 16
17OListViewItem::OListViewItem(OListViewItem *parent, QString name) 17OListViewItem::OListViewItem(OListViewItem *parent, QString name)
18 : QListViewItem(parent,name) 18 : QListViewItem(parent,name)
19{ 19{
20} 20}
21 21
22OListViewItem::OListViewItem(QListView *parent, QString name) 22OListViewItem::OListViewItem(QListView *parent, QString name)
23 : QListViewItem(parent, name) 23 : QListViewItem(parent, name)
24{ 24{
25} 25}
26 26
27OListViewItem::~OListViewItem() 27OListViewItem::~OListViewItem()
28{ 28{
29} 29}
30 30
31void OListViewItem::clearList()
32{
33 QListViewItem *item = firstChild();
34 QListViewItem *toDel;
35 while ( item != 0 ) {
36 toDel = item;
37 item = item->nextSibling();
38 delete toDel;
39 }
40}
41
diff --git a/core/pim/osearch/olistviewitem.h b/core/pim/osearch/olistviewitem.h
index 66471f1..9e072a1 100644
--- a/core/pim/osearch/olistviewitem.h
+++ b/core/pim/osearch/olistviewitem.h
@@ -1,29 +1,32 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10#ifndef LISTVIEWITEMCONF_H 10#ifndef LISTVIEWITEMCONF_H
11#define LISTVIEWITEMCONF_H 11#define LISTVIEWITEMCONF_H
12 12
13#include <qlistview.h> 13#include <qlistview.h>
14 14
15 15
16class OListViewItem : public QListViewItem 16class OListViewItem : public QListViewItem
17{ 17{
18public: 18public:
19 enum {Raw, Searchgroup, Result, Contact, Todo, Event}; 19 enum {Raw, Searchgroup, Result, Contact, Todo, Event};
20 OListViewItem(OListViewItem *parent); 20 OListViewItem(OListViewItem *parent);
21 OListViewItem(OListViewItem *parent, QString name); 21 OListViewItem(OListViewItem *parent, QString name);
22 OListViewItem(QListView *parent, QString name); 22 OListViewItem(QListView *parent, QString name);
23 ~OListViewItem(); 23 ~OListViewItem();
24 24
25 virtual void expand(){}; 25 virtual void expand(){};
26 virtual int rtti() { return Raw;} 26 virtual int rtti() { return Raw;}
27 virtual QPopupMenu* popupMenu() { return 0;};
28 void clearList();
29
27}; 30};
28 31
29#endif 32#endif
diff --git a/core/pim/osearch/searchgroup.cpp b/core/pim/osearch/searchgroup.cpp
index 490deea..e307696 100644
--- a/core/pim/osearch/searchgroup.cpp
+++ b/core/pim/osearch/searchgroup.cpp
@@ -1,87 +1,93 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "searchgroup.h" 13#include "searchgroup.h"
14 14
15#include <qregexp.h> 15#include <qregexp.h>
16// #include <qapplication.h> 16#include <qapplication.h>
17// #include <opie/owait.h> 17#include <opie/owait.h>
18 18
19#include "olistviewitem.h" 19#include "olistviewitem.h"
20 20
21//#define NEW_OWAIT
22#ifndef NEW_OWAIT
23static OWait *wait = 0;
24#endif
25
21SearchGroup::SearchGroup(QListView* parent, QString name) 26SearchGroup::SearchGroup(QListView* parent, QString name)
22: OListViewItem(parent, name) 27: OListViewItem(parent, name)
23{ 28{
24 _name = name; 29 _name = name;
25 loaded = false; 30 loaded = false;
26} 31}
27 32
28 33
29SearchGroup::~SearchGroup() 34SearchGroup::~SearchGroup()
30{ 35{
31} 36}
32 37
33 38
34void SearchGroup::expand() 39void SearchGroup::expand()
35{ 40{
36 //expanded = true; 41 //expanded = true;
37 clearList(); 42 clearList();
38 if (_search.isEmpty()) return; 43 if (_search.isEmpty()) return;
39 OListViewItem *dummy = new OListViewItem( this, "searching..."); 44 OListViewItem *dummy = new OListViewItem( this, "searching...");
40 setOpen( true ); 45 setOpen( true );
41 repaint(); 46 repaint();
42 int res_count = realSearch(); 47 int res_count = realSearch();
43 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")"); 48 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
44 delete dummy; 49 delete dummy;
45 repaint(); 50 repaint();
46} 51}
47 52
48void SearchGroup::doSearch() 53void SearchGroup::doSearch()
49{ 54{
50 clearList(); 55 clearList();
51 if (_search.isEmpty()) return; 56 if (_search.isEmpty()) return;
52 int res_count = realSearch(); 57 _resultCount = realSearch();
53 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
54 //repaint(); 58 //repaint();
55} 59}
56 60
57void SearchGroup::clearList()
58{
59 QListViewItem *item = firstChild();
60 QListViewItem *toDel;
61 while ( item != 0 ) {
62 toDel = item;
63 item = item->nextSibling();
64 delete toDel;
65 }
66}
67
68void SearchGroup::setSearch(QRegExp re) 61void SearchGroup::setSearch(QRegExp re)
69{ 62{
63 if (re == _search) return;
70 setText(0, _name+" - "+re.pattern() ); 64 setText(0, _name+" - "+re.pattern() );
71 _search = re; 65 _search = re;
72 if (isOpen()) expand(); 66 if (isOpen()) expand();
73 else new OListViewItem( this, "searching..."); 67 else new OListViewItem( this, "searching...");
74} 68}
75 69
76int SearchGroup::realSearch() 70int SearchGroup::realSearch()
77{ 71{
78 //emit isSearching( tr(" Searching for %s in %s" ).arg( _search.pattern().latin1()).arg( _name ) ); 72#ifndef NEW_OWAIT
79 /*OWait *wait = new OWait( qApp->mainWidget(), "test" ); 73 qDebug("NOT using NEW_OWAIT");
80 wait->show();*/ 74 if (!wait) wait = new OWait( qApp->mainWidget(), "osearch" );
75 wait->show();
76 qApp->processEvents();
77#else
78 qDebug("using NEW_OWAIT");
79 OWait::start( "osearch" );
80#endif
81 if (!loaded) load(); 81 if (!loaded) load();
82 int count = search(); 82 _resultCount = 0;
83 /*wait->hide(); 83 _resultCount = search();
84 delete wait;*/ 84 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( _resultCount ) + ")");
85 return count; 85
86#ifndef NEW_OWAIT
87 wait->hide();
88#else
89 OWait::stop();
90#endif
91 return _resultCount;
86} 92}
87 93
diff --git a/core/pim/osearch/searchgroup.h b/core/pim/osearch/searchgroup.h
index 32f32e0..a755e06 100644
--- a/core/pim/osearch/searchgroup.h
+++ b/core/pim/osearch/searchgroup.h
@@ -1,51 +1,48 @@
1// 1//
2// 2//
3// C++ Interface: $MODULE$ 3// C++ Interface: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#ifndef SEARCHGROUP_H 13#ifndef SEARCHGROUP_H
14#define SEARCHGROUP_H 14#define SEARCHGROUP_H
15 15
16#include "olistviewitem.h" 16#include "olistviewitem.h"
17 17
18class QRegExp; 18class QRegExp;
19class QPopupMenu;
19 20
20/** 21/**
21@author Patrick S. Vogt 22@author Patrick S. Vogt
22*/ 23*/
23class SearchGroup : public OListViewItem //, QObject 24class SearchGroup : public OListViewItem
24{ 25{
25//Q_OBJECT
26public: 26public:
27 SearchGroup(QListView* parent, QString name); 27 SearchGroup(QListView* parent, QString name);
28 28
29 ~SearchGroup(); 29 ~SearchGroup();
30 30
31 virtual void expand(); 31 virtual void expand();
32 virtual void doSearch(); 32 virtual void doSearch();
33 virtual void setSearch(QRegExp); 33 virtual void setSearch(QRegExp);
34 virtual int rtti() { return Searchgroup;} 34 virtual int rtti() { return Searchgroup;}
35 35
36// signals:
37 // isSearching(QString);
38
39protected: 36protected:
40 QRegExp _search; 37 QRegExp _search;
41 virtual void load() = 0; 38 virtual void load() = 0;
42 virtual int search() = 0; 39 virtual int search() = 0;
43 virtual void insertItem( void* ) = 0; 40 virtual void insertItem( void* ) = 0;
44 void clearList();
45 QString _name; 41 QString _name;
46 bool loaded; 42 bool loaded;
43 int _resultCount;
47private: 44private:
48 int realSearch(); 45 int realSearch();
49}; 46};
50 47
51#endif 48#endif
diff --git a/core/pim/osearch/todosearch.cpp b/core/pim/osearch/todosearch.cpp
index c9fa61a..08bbe93 100644
--- a/core/pim/osearch/todosearch.cpp
+++ b/core/pim/osearch/todosearch.cpp
@@ -1,55 +1,80 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "todosearch.h" 13#include "todosearch.h"
14 14
15#include <opie/otodoaccess.h> 15#include <opie/otodoaccess.h>
16#include <opie/otodo.h> 16#include <opie/otodo.h>
17#include <qiconset.h>
18#include <qpe/resource.h> 17#include <qpe/resource.h>
18#include <qpe/config.h>
19#include <qiconset.h>
20#include <qaction.h>
21#include <qpopupmenu.h>
19#include "todoitem.h" 22#include "todoitem.h"
20 23
21TodoSearch::TodoSearch(QListView* parent, QString name) 24TodoSearch::TodoSearch(QListView* parent, QString name)
22: SearchGroup(parent, name) 25: SearchGroup(parent, name), _todos(0), _popupMenu(0)
23{ 26{
24 _todos = 0;
25 //AppLnkSet als(QPEApplication::qpeDir()); 27 //AppLnkSet als(QPEApplication::qpeDir());
26 //setPixmap( 0, als.findExec("todolist")->pixmap() ); 28 //setPixmap( 0, als.findExec("todolist")->pixmap() );
27 QIconSet is = Resource::loadIconSet( "todo/TodoList" ); 29 QIconSet is = Resource::loadIconSet( "todo/TodoList" );
28 setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); 30 setPixmap( 0, is.pixmap( QIconSet::Small, true ) );
31 actionShowCompleted = new QAction( QObject::tr("show completed tasks"),QString::null, 0, 0, 0, true );
32 Config cfg( "osearch", Config::User );
33 cfg.setGroup( "todo_settings" );
34 actionShowCompleted->setOn( cfg.readBoolEntry( "show_completed_tasks", false ) );
35
29} 36}
30 37
31 38
32TodoSearch::~TodoSearch() 39TodoSearch::~TodoSearch()
33{ 40{
41 Config cfg( "osearch", Config::User );
42 cfg.setGroup( "todo_settings" );
43 cfg.writeEntry( "show_completed_tasks", actionShowCompleted->isOn() );
44 delete _popupMenu;
45 delete actionShowCompleted;
34 delete _todos; 46 delete _todos;
35} 47}
36 48
37 49
38void TodoSearch::load() 50void TodoSearch::load()
39{ 51{
40 _todos = new OTodoAccess(); 52 _todos = new OTodoAccess();
41 _todos->load(); 53 _todos->load();
42} 54}
43 55
44int TodoSearch::search() 56int TodoSearch::search()
45{ 57{
46 ORecordList<OTodo> results = _todos->matchRegexp(_search); 58 ORecordList<OTodo> results = _todos->matchRegexp(_search);
47 for (uint i = 0; i < results.count(); i++) 59 for (uint i = 0; i < results.count(); i++)
48 new TodoItem( this, new OTodo( results[i] )); 60 insertItem( new OTodo( results[i] ));
49 return results.count(); 61 return _resultCount;
50} 62}
51 63
52void TodoSearch::insertItem( void* ) 64void TodoSearch::insertItem( void *rec )
53{ 65{
66 OTodo *todo = (OTodo*)rec;
67 if (!actionShowCompleted->isOn() &&
68 todo->isCompleted() ) return;
69 new TodoItem( this, todo );
70 _resultCount++;
71}
54 72
73QPopupMenu* TodoSearch::popupMenu()
74{
75 if (!_popupMenu){
76 _popupMenu = new QPopupMenu( 0 );
77 actionShowCompleted->addTo( _popupMenu );
78 }
79 return _popupMenu;
55} 80}
diff --git a/core/pim/osearch/todosearch.h b/core/pim/osearch/todosearch.h
index 1d025d6..ee175da 100644
--- a/core/pim/osearch/todosearch.h
+++ b/core/pim/osearch/todosearch.h
@@ -1,39 +1,43 @@
1// 1//
2// 2//
3// C++ Interface: $MODULE$ 3// C++ Interface: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#ifndef TODOSEARCH_H 13#ifndef TODOSEARCH_H
14#define TODOSEARCH_H 14#define TODOSEARCH_H
15 15
16#include "searchgroup.h" 16#include "searchgroup.h"
17 17
18class OTodoAccess; 18class OTodoAccess;
19class QAction;
19 20
20/** 21/**
21@author Patrick S. Vogt 22@author Patrick S. Vogt
22*/ 23*/
23class TodoSearch : public SearchGroup 24class TodoSearch : public SearchGroup
24{ 25{
25public: 26public:
26 TodoSearch(QListView* parent, QString name); 27 TodoSearch(QListView* parent, QString name);
27
28 ~TodoSearch(); 28 ~TodoSearch();
29 29
30 virtual QPopupMenu* popupMenu();
31
30protected: 32protected:
31 virtual void load(); 33 virtual void load();
32 virtual int search(); 34 virtual int search();
33 virtual void insertItem( void* ); 35 virtual void insertItem( void* );
34 36
35private: 37private:
36 OTodoAccess *_todos; 38 OTodoAccess *_todos;
39 QAction *actionShowCompleted;
40 QPopupMenu *_popupMenu;
37}; 41};
38 42
39#endif 43#endif