summaryrefslogtreecommitdiff
authortille <tille>2003-05-11 19:19:30 (UTC)
committer tille <tille>2003-05-11 19:19:30 (UTC)
commit43c18630840a98aed8deb96b454957c40f0a4344 (patch) (unidiff)
tree60e5b68d1d172c77560d5af7bea83e81be7144a6
parent38dc2fd6258f11ba0507c7bd8f8dfd5b39bc0df5 (diff)
downloadopie-43c18630840a98aed8deb96b454957c40f0a4344.zip
opie-43c18630840a98aed8deb96b454957c40f0a4344.tar.gz
opie-43c18630840a98aed8deb96b454957c40f0a4344.tar.bz2
improved applnk and doclnk searching
clean up: - mainwindow: handling of searchgroups - searchgroups: introduced load, search and insertItem functions - flexible actions handling - doclnksearch inherits applnksearch
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/osearch/adresssearch.cpp15
-rw-r--r--core/pim/osearch/adresssearch.h6
-rw-r--r--core/pim/osearch/applnkitem.cpp26
-rw-r--r--core/pim/osearch/applnkitem.h4
-rw-r--r--core/pim/osearch/applnksearch.cpp25
-rw-r--r--core/pim/osearch/applnksearch.h11
-rw-r--r--core/pim/osearch/contactitem.cpp25
-rw-r--r--core/pim/osearch/contactitem.h5
-rw-r--r--core/pim/osearch/datebooksearch.cpp18
-rw-r--r--core/pim/osearch/datebooksearch.h6
-rw-r--r--core/pim/osearch/doclnkitem.cpp48
-rw-r--r--core/pim/osearch/doclnkitem.h4
-rw-r--r--core/pim/osearch/doclnksearch.cpp24
-rw-r--r--core/pim/osearch/doclnksearch.h14
-rw-r--r--core/pim/osearch/eventitem.cpp22
-rw-r--r--core/pim/osearch/eventitem.h4
-rw-r--r--core/pim/osearch/mainwindow.cpp92
-rw-r--r--core/pim/osearch/mainwindow.h25
-rw-r--r--core/pim/osearch/resultitem.cpp12
-rw-r--r--core/pim/osearch/resultitem.h6
-rw-r--r--core/pim/osearch/searchgroup.cpp24
-rw-r--r--core/pim/osearch/searchgroup.h9
-rw-r--r--core/pim/osearch/todoitem.cpp30
-rw-r--r--core/pim/osearch/todoitem.h7
-rw-r--r--core/pim/osearch/todosearch.cpp19
-rw-r--r--core/pim/osearch/todosearch.h8
26 files changed, 279 insertions, 210 deletions
diff --git a/core/pim/osearch/adresssearch.cpp b/core/pim/osearch/adresssearch.cpp
index 0ee8eba..69ad9ef 100644
--- a/core/pim/osearch/adresssearch.cpp
+++ b/core/pim/osearch/adresssearch.cpp
@@ -1,45 +1,50 @@
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 "adresssearch.h" 13#include "adresssearch.h"
14 14
15#include <opie/ocontactaccess.h> 15#include <opie/ocontactaccess.h>
16#include <qstring.h> 16#include <qstring.h>
17 17
18#include "contactitem.h" 18#include "contactitem.h"
19//#include <qdir.h> 19//#include <qdir.h>
20 20
21AdressSearch::AdressSearch(QListView* parent, QString name): 21AdressSearch::AdressSearch(QListView* parent, QString name):
22 SearchGroup(parent, name) 22 SearchGroup(parent, name)
23{ 23{
24 _contacts = 0; 24 _contacts = 0;
25} 25}
26 26
27 27
28AdressSearch::~AdressSearch() 28AdressSearch::~AdressSearch()
29{ 29{
30 delete _contacts; 30 delete _contacts;
31} 31}
32 32
33void AdressSearch::load()
34{
35 _contacts = new OContactAccess("osearch");
36}
33 37
34void AdressSearch::expand() 38int AdressSearch::search()
35{ 39{
36 SearchGroup::expand();
37 if (_search.isEmpty()) return;
38 if (!_contacts) _contacts = new OContactAccess("osearch");
39 ORecordList<OContact> results = _contacts->matchRegexp(_search); 40 ORecordList<OContact> results = _contacts->matchRegexp(_search);
40 setText(0, text(0) + " (" + QString::number( results.count() ) + ")" );
41 for (uint i = 0; i < results.count(); i++) { 41 for (uint i = 0; i < results.count(); i++) {
42 new ContactItem( this, new OContact( results[i] )); 42 new ContactItem( this, new OContact( results[i] ));
43 } 43 }
44 return results.count();
44} 45}
45 46
47void AdressSearch::insertItem( void* )
48{
49
50}
diff --git a/core/pim/osearch/adresssearch.h b/core/pim/osearch/adresssearch.h
index ab560d0..d5c7622 100644
--- a/core/pim/osearch/adresssearch.h
+++ b/core/pim/osearch/adresssearch.h
@@ -1,38 +1,38 @@
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 ADRESSSEARCH_H 13#ifndef ADRESSSEARCH_H
14#define ADRESSSEARCH_H 14#define ADRESSSEARCH_H
15 15
16#include "searchgroup.h" 16#include "searchgroup.h"
17 17
18class OContactAccess; 18class OContactAccess;
19 19
20/** 20/**
21@author Patrick S. Vogt 21@author Patrick S. Vogt
22*/ 22*/
23class AdressSearch : public SearchGroup 23class AdressSearch : public SearchGroup
24{ 24{
25public: 25public:
26 AdressSearch(QListView* parent, QString name); 26 AdressSearch(QListView* parent, QString name);
27 ~AdressSearch(); 27 ~AdressSearch();
28 28
29 virtual void expand();
30
31protected: 29protected:
32 30 virtual void load();
31 virtual int search();
32 virtual void insertItem( void* );
33 33
34private: 34private:
35 OContactAccess *_contacts; 35 OContactAccess *_contacts;
36}; 36};
37 37
38#endif 38#endif
diff --git a/core/pim/osearch/applnkitem.cpp b/core/pim/osearch/applnkitem.cpp
index f45ed68..2152da4 100644
--- a/core/pim/osearch/applnkitem.cpp
+++ b/core/pim/osearch/applnkitem.cpp
@@ -1,54 +1,50 @@
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 "applnkitem.h" 13#include "applnkitem.h"
14 14
15#include <qpe/applnk.h> 15#include <qpe/applnk.h>
16 16
17AppLnkItem::AppLnkItem(OListViewItem* parent, AppLnk *app) 17AppLnkItem::AppLnkItem(OListViewItem* parent, AppLnk *app)
18 : ResultItem(parent) 18 : ResultItem(parent)
19{ 19{
20 _app = app; 20 _app = app;
21 setText(0, _app->name() ); 21 setText(0, _app->name() );
22} 22}
23 23
24 24
25AppLnkItem::~AppLnkItem() 25AppLnkItem::~AppLnkItem()
26{ 26{
27} 27}
28 28
29 29
30QString AppLnkItem::toRichText() 30QString AppLnkItem::toRichText()
31{ 31{
32 QString text; 32 QString text;
33 text += "<b><h3>"; 33 text += "<b><h3>" + _app->name() + "</b></h3><br>";
34 text += _app->name(); 34 text += _app->comment() + "<br>";
35 text += "</b></h3><br>"; 35 text += "<br>`" + _app->exec() + "`<br>";
36 text += _app->comment();
37 text += "<br><br>`";
38 text += _app->exec();
39 text += "`";
40 return text; 36 return text;
41} 37}
42 38
43void AppLnkItem::editItem() 39void AppLnkItem::action( int act )
44{ 40{
45 _app->execute(); 41 if (!_app->isValid()) qDebug("INVALID");
42 if (act == 0) _app->execute();
46} 43}
47 44
48void AppLnkItem::showItem() 45QIntDict<QString> AppLnkItem::actions()
49{ 46{
50 /* QCopEnvelope e("QPE/Application/addressbook", "edit(int)"); 47 QIntDict<QString> result;
51 e << _contact->uid();*/ 48 result.insert( 0, new QString( QObject::tr("execute") ) );
52 ResultItem::showItem(); 49 return result;
53} 50}
54
diff --git a/core/pim/osearch/applnkitem.h b/core/pim/osearch/applnkitem.h
index b28631a..4aa1274 100644
--- a/core/pim/osearch/applnkitem.h
+++ b/core/pim/osearch/applnkitem.h
@@ -1,37 +1,37 @@
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 APPLNKITEM_H 13#ifndef APPLNKITEM_H
14#define APPLNKITEM_H 14#define APPLNKITEM_H
15 15
16#include "resultitem.h" 16#include "resultitem.h"
17 17
18class AppLnk; 18class AppLnk;
19 19
20/** 20/**
21@author Patrick S. Vogt 21@author Patrick S. Vogt
22*/ 22*/
23class AppLnkItem : public ResultItem 23class AppLnkItem : public ResultItem
24{ 24{
25public: 25public:
26 AppLnkItem(OListViewItem* parent, AppLnk *app); 26 AppLnkItem(OListViewItem* parent, AppLnk *app);
27 ~AppLnkItem(); 27 ~AppLnkItem();
28 28
29 virtual QString toRichText(); 29 virtual QString toRichText();
30 virtual void editItem(); 30 virtual void action( int );
31 virtual void showItem(); 31 virtual QIntDict<QString> actions();
32 32
33private: 33private:
34 AppLnk *_app; 34 AppLnk *_app;
35}; 35};
36 36
37#endif 37#endif
diff --git a/core/pim/osearch/applnksearch.cpp b/core/pim/osearch/applnksearch.cpp
index 7872ae3..d5b2930 100644
--- a/core/pim/osearch/applnksearch.cpp
+++ b/core/pim/osearch/applnksearch.cpp
@@ -1,46 +1,55 @@
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 17
18#include "applnkitem.h" 18#include "applnkitem.h"
19 19
20AppLnkSearch::AppLnkSearch(QListView* parent, QString name): SearchGroup(parent, name) 20AppLnkSearch::AppLnkSearch(QListView* parent, QString name): SearchGroup(parent, name)
21{ 21{
22 _apps = 0; 22 _apps = 0;
23} 23}
24 24
25 25
26AppLnkSearch::~AppLnkSearch() 26AppLnkSearch::~AppLnkSearch()
27{ 27{
28 delete _apps; 28 delete _apps;
29} 29}
30 30
31 31
32void AppLnkSearch::expand() 32void AppLnkSearch::load()
33{ 33{
34 SearchGroup::expand(); 34 _apps = new AppLnkSet(QPEApplication::qpeDir());
35 if (_search.isEmpty()) return; 35}
36 if (!_apps) _apps = new AppLnkSet(QPEApplication::qpeDir()); 36
37int AppLnkSearch::search()
38{
39 int count = 0;
37 QList<AppLnk> appList = _apps->children(); 40 QList<AppLnk> appList = _apps->children();
38 for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){ 41 for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){
39 // if (app->name().contains(_search) || app->comment().contains(_search))
40 if ( (_search.match( app->name() ) != -1) 42 if ( (_search.match( app->name() ) != -1)
41 || (_search.match(app->comment()) != -1) 43 || (_search.match(app->comment()) != -1)
42 || (_search.match(app->exec()) != -1) ) 44 || (_search.match(app->exec()) != -1) ) {
43 new AppLnkItem( this, app ); 45 count++;
46 insertItem( app );
47 }
44 } 48 }
49 return count;
45} 50}
46 51
52void AppLnkSearch::insertItem( void *rec )
53{
54 new AppLnkItem( this, (AppLnk*)rec );
55}
diff --git a/core/pim/osearch/applnksearch.h b/core/pim/osearch/applnksearch.h
index e283cd3..d88a8ce 100644
--- a/core/pim/osearch/applnksearch.h
+++ b/core/pim/osearch/applnksearch.h
@@ -1,35 +1,38 @@
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 APPLNKSEARCH_H 13#ifndef APPLNKSEARCH_H
14#define APPLNKSEARCH_H 14#define APPLNKSEARCH_H
15 15
16#include "searchgroup.h" 16#include "searchgroup.h"
17 17
18class AppLnkSet; 18class AppLnkSet;
19 19
20/** 20/**
21@author Patrick S. Vogt 21@author Patrick S. Vogt
22*/ 22*/
23class AppLnkSearch : public SearchGroup 23class AppLnkSearch : public SearchGroup
24{ 24{
25public: 25public:
26 AppLnkSearch(QListView* parent, QString name); 26 AppLnkSearch(QListView* parent, QString name);
27 27
28 ~AppLnkSearch(); 28 ~AppLnkSearch();
29 29
30 virtual void expand(); 30protected:
31private: 31 virtual void load();
32 AppLnkSet *_apps; 32 virtual int search();
33 virtual void insertItem( void* );
34
35 AppLnkSet *_apps;
33}; 36};
34 37
35#endif 38#endif
diff --git a/core/pim/osearch/contactitem.cpp b/core/pim/osearch/contactitem.cpp
index 788a415..7d8ecf1 100644
--- a/core/pim/osearch/contactitem.cpp
+++ b/core/pim/osearch/contactitem.cpp
@@ -1,51 +1,56 @@
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 "contactitem.h" 13#include "contactitem.h"
14 14
15#include <opie/ocontact.h> 15#include <opie/ocontact.h>
16#include <qpe/qcopenvelope_qws.h> 16#include <qpe/qcopenvelope_qws.h>
17 17
18ContactItem::ContactItem(OListViewItem* parent, OContact *contact) 18ContactItem::ContactItem(OListViewItem* parent, OContact *contact)
19: ResultItem(parent) 19: ResultItem(parent)
20{ 20{
21 _contact = contact; 21 _contact = contact;
22 setText(0, _contact->toShortText()); 22 setText(0, _contact->toShortText());
23} 23}
24 24
25 25
26ContactItem::~ContactItem() 26ContactItem::~ContactItem()
27{ 27{
28 delete _contact; 28 delete _contact;
29} 29}
30 30
31 31
32QString ContactItem::toRichText() 32QString ContactItem::toRichText()
33{ 33{
34 return _contact->toRichText(); 34 return _contact->toRichText();
35} 35}
36 36
37 37void ContactItem::action( int act )
38void ContactItem::editItem()
39{ 38{
40 QCopEnvelope e("QPE/Application/addressbook", "edit(int)"); 39if (act == 0){
41 //QCopEnvelope e("QPE/Addressbook", "edit(int)"); 40 QCopEnvelope e("QPE/Application/addressbook", "show(int)");
42 e << _contact->uid(); 41 e << _contact->uid();
42}else if(act == 1){
43 QCopEnvelope e("QPE/Application/addressbook", "edit(int)");
44 e << _contact->uid();
43} 45}
44 46
45void ContactItem::showItem()
46{
47 QCopEnvelope e("QPE/Application/addressbook", "show(int)");
48 //QCopEnvelope e("QPE/Addressbook", "show(int)");
49 e << _contact->uid();
50} 47}
51 48
49QIntDict<QString> ContactItem::actions()
50{
51 QIntDict<QString> result;
52 result.insert( 0, new QString( QObject::tr("show") ) );
53 result.insert( 1, new QString( QObject::tr("edit") ) );
54 return result;
55
56}
diff --git a/core/pim/osearch/contactitem.h b/core/pim/osearch/contactitem.h
index 431adef..5e0017d 100644
--- a/core/pim/osearch/contactitem.h
+++ b/core/pim/osearch/contactitem.h
@@ -1,39 +1,40 @@
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 CONTACTITEM_H 13#ifndef CONTACTITEM_H
14#define CONTACTITEM_H 14#define CONTACTITEM_H
15 15
16#include "resultitem.h" 16#include "resultitem.h"
17 17
18class OContact; 18class OContact;
19 19
20/** 20/**
21@author Patrick S. Vogt 21@author Patrick S. Vogt
22*/ 22*/
23class ContactItem : public ResultItem 23class ContactItem : public ResultItem
24{ 24{
25public: 25public:
26 ContactItem(OListViewItem* parent, OContact *contact); 26 ContactItem(OListViewItem* parent, OContact *contact);
27 27
28 ~ContactItem(); 28 ~ContactItem();
29 29
30 virtual QString toRichText(); 30 virtual QString toRichText();
31 virtual void showItem(); 31 virtual void action( int );
32 virtual void editItem(); 32 virtual QIntDict<QString> actions();
33
33 34
34private: 35private:
35 OContact *_contact; 36 OContact *_contact;
36 37
37}; 38};
38 39
39#endif 40#endif
diff --git a/core/pim/osearch/datebooksearch.cpp b/core/pim/osearch/datebooksearch.cpp
index 83b99f5..68699fa 100644
--- a/core/pim/osearch/datebooksearch.cpp
+++ b/core/pim/osearch/datebooksearch.cpp
@@ -1,46 +1,50 @@
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 <opie/oevent.h> 17#include <opie/oevent.h>
18#include <opie/odatebookaccess.h> 18#include <opie/odatebookaccess.h>
19 19
20DatebookSearch::DatebookSearch(QListView* parent, QString name) 20DatebookSearch::DatebookSearch(QListView* parent, QString name)
21: SearchGroup(parent, name) 21: SearchGroup(parent, name)
22{ 22{
23 _dates = 0; 23 _dates = 0;
24} 24}
25 25
26 26
27DatebookSearch::~DatebookSearch() 27DatebookSearch::~DatebookSearch()
28{ 28{
29 delete _dates; 29 delete _dates;
30} 30}
31 31
32 32
33void DatebookSearch::expand() 33void DatebookSearch::load()
34{ 34{
35 SearchGroup::expand();
36 if (!_dates){
37 _dates = new ODateBookAccess(); 35 _dates = new ODateBookAccess();
38 _dates->load(); 36 _dates->load();
39 } 37}
38
39int DatebookSearch::search()
40{
40 ORecordList<OEvent> results = _dates->matchRegexp(_search); 41 ORecordList<OEvent> results = _dates->matchRegexp(_search);
41 setText(0, text(0) + " (" + QString::number( results.count() ) + ")" ); 42 for (uint i = 0; i < results.count(); i++)
42 for (uint i = 0; i < results.count(); i++) {
43 new EventItem( this, new OEvent( results[i] )); 43 new EventItem( this, new OEvent( results[i] ));
44 } 44 return results.count();
45} 45}
46 46
47void DatebookSearch::insertItem( void* )
48{
49
50}
diff --git a/core/pim/osearch/datebooksearch.h b/core/pim/osearch/datebooksearch.h
index 35bbe5a..bb31462 100644
--- a/core/pim/osearch/datebooksearch.h
+++ b/core/pim/osearch/datebooksearch.h
@@ -1,36 +1,40 @@
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;
19 19
20/** 20/**
21@author Patrick S. Vogt 21@author Patrick S. Vogt
22*/ 22*/
23class DatebookSearch : public SearchGroup 23class DatebookSearch : public SearchGroup
24{ 24{
25public: 25public:
26 DatebookSearch(QListView* parent, QString name); 26 DatebookSearch(QListView* parent, QString name);
27 27
28 ~DatebookSearch(); 28 ~DatebookSearch();
29 29
30 virtual void expand(); 30protected:
31 virtual void load();
32 virtual int search();
33 virtual void insertItem( void* );
34
31private: 35private:
32 ODateBookAccess *_dates; 36 ODateBookAccess *_dates;
33 37
34}; 38};
35 39
36#endif 40#endif
diff --git a/core/pim/osearch/doclnkitem.cpp b/core/pim/osearch/doclnkitem.cpp
index fd19727..75dee58 100644
--- a/core/pim/osearch/doclnkitem.cpp
+++ b/core/pim/osearch/doclnkitem.cpp
@@ -1,54 +1,70 @@
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 "doclnkitem.h" 13#include "doclnkitem.h"
14 14
15#include <qpe/applnk.h> 15#include <qpe/applnk.h>
16#include <qfile.h>
17#include <qtextstream.h>
16 18
17DocLnkItem::DocLnkItem(OListViewItem* parent, DocLnk *app) 19DocLnkItem::DocLnkItem(OListViewItem* parent, DocLnk *app)
18 : ResultItem(parent) 20 : ResultItem(parent)
19{ 21{
20 _doc = app; 22 _doc = app;
21 setText(0, _doc->name() ); 23 setText(0, _doc->name() );
22} 24}
23 25
24
25DocLnkItem::~DocLnkItem() 26DocLnkItem::~DocLnkItem()
26{ 27{
27} 28}
28 29
29
30QString DocLnkItem::toRichText() 30QString DocLnkItem::toRichText()
31{ 31{
32 QString text; 32 QString text;
33 text += "<b><h3>"; 33 text += "<b><h3>" + _doc->name() + "</b></h3><br>";
34 text += _doc->name(); 34 text += _doc->comment() + "<br>";
35 text += "</b></h3><br>"; 35 text += "File: " + _doc->file() + "<br>";
36 text += _doc->comment(); 36 text += "Mimetype: " + _doc->type() + "<br>";
37 text += "<br><br>`"; 37 if ( _doc->type().contains( "text" ) ){
38 text += "<br><br><hr><br>";
39 QFile f(_doc->file());
40 if ( f.open(IO_ReadOnly) ) {
41 QTextStream t( &f );
42 while ( !t.eof() )
43 text += t.readLine() + "<br>";
44 }
45 f.close();
46 }
47 /* text += "<br><br>`";
38 text += _doc->exec(); 48 text += _doc->exec();
39 text += "`"; 49 text += "`";*/
50 QStringList list = _doc->mimeTypes();
51 int i = 0;
52 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
53 text += QString::number( i++) + " - " + *it ;
54 }
40 return text; 55 return text;
41} 56}
42 57
43void DocLnkItem::editItem() 58void DocLnkItem::action( int act )
44{ 59{
45 _doc->execute(); 60 qDebug("action %i",act);
61 if (!_doc->isValid()) qDebug("INVALID");
62 if (act == 0) _doc->execute();
46} 63}
47 64
48void DocLnkItem::showItem() 65QIntDict<QString> DocLnkItem::actions()
49{ 66{
50 /* QCopEnvelope e("QPE/Application/addressbook", "edit(int)"); 67 QIntDict<QString> result;
51 e << _contact->uid();*/ 68 result.insert( 0, new QString( QObject::tr("open with ") + _doc->exec() ) );
52 ResultItem::showItem(); 69 return result;
53} 70}
54
diff --git a/core/pim/osearch/doclnkitem.h b/core/pim/osearch/doclnkitem.h
index 2718733..4fd6dd7 100644
--- a/core/pim/osearch/doclnkitem.h
+++ b/core/pim/osearch/doclnkitem.h
@@ -1,37 +1,37 @@
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 DOCLNKITEM_H 13#ifndef DOCLNKITEM_H
14#define DOCLNKITEM_H 14#define DOCLNKITEM_H
15 15
16#include "resultitem.h" 16#include "resultitem.h"
17 17
18class DocLnk; 18class DocLnk;
19 19
20/** 20/**
21@author Patrick S. Vogt 21@author Patrick S. Vogt
22*/ 22*/
23class DocLnkItem : public ResultItem 23class DocLnkItem : public ResultItem
24{ 24{
25public: 25public:
26 DocLnkItem(OListViewItem* parent, DocLnk *app); 26 DocLnkItem(OListViewItem* parent, DocLnk *app);
27 ~DocLnkItem(); 27 ~DocLnkItem();
28 28
29 virtual QString toRichText(); 29 virtual QString toRichText();
30 virtual void editItem(); 30 virtual void action( int );
31 virtual void showItem(); 31 virtual QIntDict<QString> actions();
32 32
33private: 33private:
34 DocLnk *_doc; 34 DocLnk *_doc;
35}; 35};
36 36
37#endif 37#endif
diff --git a/core/pim/osearch/doclnksearch.cpp b/core/pim/osearch/doclnksearch.cpp
index e99a385..f2a60e9 100644
--- a/core/pim/osearch/doclnksearch.cpp
+++ b/core/pim/osearch/doclnksearch.cpp
@@ -1,46 +1,38 @@
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 17
18#include "doclnkitem.h" 18#include "doclnkitem.h"
19 19
20DocLnkSearch::DocLnkSearch(QListView* parent, QString name): SearchGroup(parent, name) 20DocLnkSearch::DocLnkSearch(QListView* parent, QString name)
21: AppLnkSearch(parent, name)
21{ 22{
22 _docs = 0;
23} 23}
24 24
25 25
26DocLnkSearch::~DocLnkSearch() 26DocLnkSearch::~DocLnkSearch()
27{ 27{
28 delete _docs;
29} 28}
30 29
31 30void DocLnkSearch::load()
32void DocLnkSearch::expand()
33{ 31{
34 SearchGroup::expand(); 32 _apps = new DocLnkSet(QPEApplication::documentDir());
35 if (_search.isEmpty()) return;
36 if (!_docs) _docs = new DocLnkSet(QPEApplication::documentDir());
37 QList<DocLnk> appList = _docs->children();
38 for ( DocLnk *app = appList.first(); app != 0; app = appList.next() ){
39 // if (app->name().contains(_search) || app->comment().contains(_search))
40 if ( (_search.match( app->name() ) != -1)
41 || (_search.match(app->comment()) != -1)
42 || (_search.match(app->exec()) != -1) )
43 new DocLnkItem( this, app );
44 }
45} 33}
46 34
35void DocLnkSearch::insertItem( void *rec )
36{
37 new DocLnkItem( this, (DocLnk*)rec );
38}
diff --git a/core/pim/osearch/doclnksearch.h b/core/pim/osearch/doclnksearch.h
index ec740de..e2ac40b 100644
--- a/core/pim/osearch/doclnksearch.h
+++ b/core/pim/osearch/doclnksearch.h
@@ -1,35 +1,33 @@
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 DOCLNKSEARCH_H 13#ifndef DOCLNKSEARCH_H
14#define DOCLNKSEARCH_H 14#define DOCLNKSEARCH_H
15 15
16#include "searchgroup.h" 16#include "applnksearch.h"
17
18class DocLnkSet;
19 17
20/** 18/**
21@author Patrick S. Vogt 19@author Patrick S. Vogt
22*/ 20*/
23class DocLnkSearch : public SearchGroup 21class DocLnkSearch : public AppLnkSearch
24{ 22{
25public: 23public:
26 DocLnkSearch(QListView* parent, QString name); 24 DocLnkSearch(QListView* parent, QString name);
27
28 ~DocLnkSearch(); 25 ~DocLnkSearch();
29 26
30 virtual void expand(); 27protected:
31private: 28 virtual void load();
32 DocLnkSet *_docs; 29 virtual void insertItem( void* );
30
33}; 31};
34 32
35#endif 33#endif
diff --git a/core/pim/osearch/eventitem.cpp b/core/pim/osearch/eventitem.cpp
index 758ad85..3b84b42 100644
--- a/core/pim/osearch/eventitem.cpp
+++ b/core/pim/osearch/eventitem.cpp
@@ -1,50 +1,54 @@
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 "eventitem.h" 13#include "eventitem.h"
14 14
15#include <qdatetime.h> 15#include <qdatetime.h>
16#include <qpe/qcopenvelope_qws.h> 16#include <qpe/qcopenvelope_qws.h>
17#include <opie/oevent.h> 17#include <opie/oevent.h>
18 18
19EventItem::EventItem(OListViewItem* parent, OEvent *event) 19EventItem::EventItem(OListViewItem* parent, OEvent *event)
20 : ResultItem(parent) 20 : ResultItem(parent)
21{ 21{
22 _event = event; 22 _event = event;
23 setText(0, _event->toShortText() ); 23 setText(0, _event->toShortText() );
24} 24}
25 25
26 26
27EventItem::~EventItem() 27EventItem::~EventItem()
28{ 28{
29} 29}
30 30
31 31
32QString EventItem::toRichText() 32QString EventItem::toRichText()
33{ 33{
34 return _event->toRichText(); 34 return _event->toRichText();
35} 35}
36 36
37void EventItem::editItem() 37void EventItem::action( int act )
38{ 38{
39 QCopEnvelope e("QPE/Application/datebook", "editEvent(int)"); 39 if (act == 0){
40 e << _event->uid(); 40 QCopEnvelope e("QPE/Application/datebook", "viewDefault(QDate)");
41 e << _event->startDateTime().date();
42 }else if(act == 1){
43 QCopEnvelope e("QPE/Application/datebook", "editEvent(int)");
44 e << _event->uid();
45 }
41} 46}
42 47
43void EventItem::showItem() 48QIntDict<QString> EventItem::actions()
44{ 49{
45 QCopEnvelope e("QPE/Application/datebook", "viewDefault(QDate)"); 50 QIntDict<QString> result;
46 QDate day = _event->startDateTime().date(); 51 result.insert( 0, new QString( QObject::tr("show") ) );
47 qDebug("sending view day %s",day.toString().latin1()); 52 result.insert( 1, new QString( QObject::tr("edit") ) );
48 e << day; 53 return result;
49} 54}
50
diff --git a/core/pim/osearch/eventitem.h b/core/pim/osearch/eventitem.h
index 999f0ac..d0d45a8 100644
--- a/core/pim/osearch/eventitem.h
+++ b/core/pim/osearch/eventitem.h
@@ -1,39 +1,39 @@
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 EVENTITEM_H 13#ifndef EVENTITEM_H
14#define EVENTITEM_H 14#define EVENTITEM_H
15 15
16#include "resultitem.h" 16#include "resultitem.h"
17 17
18class OEvent; 18class OEvent;
19 19
20/** 20/**
21@author Patrick S. Vogt 21@author Patrick S. Vogt
22*/ 22*/
23class EventItem : public ResultItem 23class EventItem : public ResultItem
24{ 24{
25public: 25public:
26 EventItem(OListViewItem* parent, OEvent *event); 26 EventItem(OListViewItem* parent, OEvent *event);
27 27
28 ~EventItem(); 28 ~EventItem();
29 29
30 virtual QString toRichText(); 30 virtual QString toRichText();
31 virtual void editItem(); 31 virtual void action( int );
32 virtual void showItem(); 32 virtual QIntDict<QString> actions();
33 33
34private: 34private:
35 OEvent *_event; 35 OEvent *_event;
36 36
37}; 37};
38 38
39#endif 39#endif
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp
index 140d7bb..a0b7b23 100644
--- a/core/pim/osearch/mainwindow.cpp
+++ b/core/pim/osearch/mainwindow.cpp
@@ -1,182 +1,204 @@
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 <qaction.h> 21#include <qaction.h>
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qpopupmenu.h> 23#include <qpopupmenu.h>
24#include <qtoolbutton.h> 24#include <qtoolbutton.h>
25#include <qstring.h> 25#include <qstring.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qfile.h> 27#include <qfile.h>
28#include <qhbuttongroup.h>
28#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qintdict.h>
29#include <qlayout.h> 31#include <qlayout.h>
30#include <qlineedit.h> 32#include <qlineedit.h>
31#include <qtextbrowser.h> 33#include <qtextbrowser.h>
32 34
33#include "olistview.h" 35#include "olistview.h"
34#include "olistviewitem.h" 36#include "olistviewitem.h"
35#include "resultitem.h" 37#include "resultitem.h"
36#include "adresssearch.h" 38#include "adresssearch.h"
37#include "todosearch.h" 39#include "todosearch.h"
38#include "datebooksearch.h" 40#include "datebooksearch.h"
39#include "applnksearch.h" 41#include "applnksearch.h"
40#include "doclnksearch.h" 42#include "doclnksearch.h"
41 43
42MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : 44MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
43 QMainWindow( parent, name, f ), _currentItem(0) 45 QMainWindow( parent, name, f ), _currentItem(0)
44{ 46{
45 setCaption( tr("OSearch") ); 47 setCaption( tr("OSearch") );
46 48
47 setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 49 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
48 50
49 QFrame *mainFrame = new QFrame( this, "mainFrame" ); 51 QFrame *mainFrame = new QFrame( this, "mainFrame" );
50 52
51 mainLayout = new QVBoxLayout( mainFrame ); 53 mainLayout = new QVBoxLayout( mainFrame );
52 mainLayout->setSpacing( 0 ); 54 mainLayout->setSpacing( 0 );
53 mainLayout->setMargin( 0 ); 55 mainLayout->setMargin( 0 );
54 56
55 resultsList = new OListView( mainFrame ); 57 resultsList = new OListView( mainFrame );
56 resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 58 resultsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
57 mainLayout->addWidget( resultsList ); 59 mainLayout->addWidget( resultsList, 1 );
58 60
59 detailsFrame = new QFrame( mainFrame, "detailsFrame" ); 61 detailsFrame = new QFrame( mainFrame, "detailsFrame" );
60 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); 62 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame );
61 richEdit = new QTextView( detailsFrame ); 63 richEdit = new QTextView( detailsFrame );
62 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 64 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
63 detailsLayout->addWidget( richEdit, 0 ); 65 //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ));
64 QHBoxLayout *buttonLayout = new QHBoxLayout( detailsFrame ); 66 detailsLayout->addWidget( richEdit, 1 );
65 detailsLayout->addLayout( buttonLayout, 0 ); 67
68 buttonGroupActions = new QHButtonGroup( this );
69 _buttonCount = 0;
70// buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
71
72 buttonLayout = new QHBoxLayout( detailsFrame );
73 buttonGroupActions->hide();
74 //buttonLayout->addWidget( buttonGroupActions, 0 );
75
76 detailsLayout->addLayout( buttonLayout );
77 /*
66 QPushButton *buttonShow = new QPushButton( detailsFrame, "Show" ); 78 QPushButton *buttonShow = new QPushButton( detailsFrame, "Show" );
67 buttonShow->setText( tr("show") ); 79 buttonShow->setText( tr("show") );
68// buttonShow->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
69 QPushButton *buttonEdit = new QPushButton( detailsFrame, "Edit" ); 80 QPushButton *buttonEdit = new QPushButton( detailsFrame, "Edit" );
70 buttonEdit->setText( tr("edit") ); 81 buttonEdit->setText( tr("edit") );
71 // buttonEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
72 buttonLayout->addWidget( buttonShow, 0 ); 82 buttonLayout->addWidget( buttonShow, 0 );
73 buttonLayout->addWidget( buttonEdit, 0 ); 83 buttonLayout->addWidget( buttonEdit, 0 );
74 84*/
75 mainLayout->addWidget( detailsFrame, 0 ); 85 mainLayout->addWidget( detailsFrame );
76 detailsFrame->hide(); 86 detailsFrame->hide();
77 87
78 adrSearch = new AdressSearch( resultsList, tr("adressbook") ); 88 searches.append( new AdressSearch( resultsList, tr("adressbook") ) );
79 todoSearch = new TodoSearch( resultsList, tr("todo") ); 89 searches.append( new TodoSearch( resultsList, tr("todo") ) );
80 datebookSearch = new DatebookSearch( resultsList, tr("datebook") ); 90 searches.append( new DatebookSearch( resultsList, tr("datebook") ) );
81 applnkSearch = new AppLnkSearch( resultsList, tr("applications") ); 91 searches.append( new AppLnkSearch( resultsList, tr("applications") ) );
82 doclnkSearch = new DocLnkSearch( resultsList, tr("documents") ); 92 searches.append( new DocLnkSearch( resultsList, tr("documents") ) );
83 93
84 makeMenu(); 94 makeMenu();
85 setCentralWidget( mainFrame ); 95 setCentralWidget( mainFrame );
86 96
87 popupTimer = new QTimer(); 97 popupTimer = new QTimer();
88 98
89 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); 99 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup()));
90 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); 100 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*)));
91 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); 101 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*)));
92 connect(buttonShow, SIGNAL(clicked()), SLOT( showItem() ) ); 102 connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) );
93 connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) ); 103// connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) );
94
95 104
96} 105}
97 106
98void MainWindow::makeMenu() 107void MainWindow::makeMenu()
99{ 108{
100// QPEToolBar *toolBar = new QPEToolBar( this ); 109// QPEToolBar *toolBar = new QPEToolBar( this );
101// QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); 110// QPEMenuBar *menuBar = new QPEMenuBar( toolBar );
102// QPopupMenu *searchMenu = new QPopupMenu( menuBar ); 111// QPopupMenu *searchMenu = new QPopupMenu( menuBar );
103// QPopupMenu *viewMenu = new QPopupMenu( menuBar ); 112// QPopupMenu *viewMenu = new QPopupMenu( menuBar );
104// QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); 113// QPopupMenu *cfgMenu = new QPopupMenu( menuBar );
105// 114//
106 setToolBarsMovable( false ); 115 setToolBarsMovable( false );
107// toolBar->setHorizontalStretchable( true ); 116// toolBar->setHorizontalStretchable( true );
108// menuBar->insertItem( tr( "Search" ), searchMenu ); 117// menuBar->insertItem( tr( "Search" ), searchMenu );
109// menuBar->insertItem( tr( "View" ), viewMenu ); 118// menuBar->insertItem( tr( "View" ), viewMenu );
110// menuBar->insertItem( tr( "Settings" ), cfgMenu ); 119// menuBar->insertItem( tr( "Settings" ), cfgMenu );
111 120
112 //SEARCH 121 //SEARCH
113 QPEToolBar *searchBar = new QPEToolBar(this); 122 QPEToolBar *searchBar = new QPEToolBar(this);
114 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 123 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
115 QLabel *label = new QLabel( tr("Search: "), searchBar ); 124 QLabel *label = new QLabel( tr("Search: "), searchBar );
116// label->setBackgroundMode( PaletteForeground ); 125// label->setBackgroundMode( PaletteForeground );
117 searchBar->setHorizontalStretchable( TRUE ); 126 searchBar->setHorizontalStretchable( TRUE );
118 QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); 127 QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" );
119 searchBar->setStretchableWidget( searchEdit ); 128 searchBar->setStretchableWidget( searchEdit );
120 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 129 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
121 this, SLOT( setSearch( const QString & ) ) ); 130 this, SLOT( setSearch( const QString & ) ) );
122 131
123 132
124} 133}
125 134
126MainWindow::~MainWindow() 135MainWindow::~MainWindow()
127{ 136{
128} 137}
129 138
130void MainWindow::setCurrent(QListViewItem *item) 139void MainWindow::setCurrent(QListViewItem *item)
131{ 140{
132 if (!item) return; 141 if (!item) return;
133 _currentItem = (OListViewItem*)item; 142 _currentItem = (OListViewItem*)item;
134 //_currentItem = dynamic_cast<OListViewItem*>(item); 143 //_currentItem = dynamic_cast<OListViewItem*>(item);
135 if (_currentItem->rtti() == OListViewItem::Result){ 144 if (_currentItem->rtti() == OListViewItem::Result){
136 ResultItem *res = (ResultItem*)item; 145 ResultItem *res = (ResultItem*)item;
137 // ResultItem *res = dynamic_cast<ResultItem*>(item); 146 // ResultItem *res = dynamic_cast<ResultItem*>(item);
138 richEdit->setText( res->toRichText() ); 147 richEdit->setText( res->toRichText() );
148 QIntDict<QString> acts = res->actions();
149 QButton *button;
150 for (uint i = 0; i < acts.count(); i++){
151 button = buttonGroupActions->find( i );
152 qDebug("action %i >%s<",i,acts[i]->latin1());
153 if (!button) {
154 qDebug("BUTTON");
155 button = new QPushButton( detailsFrame );
156 buttonLayout->addWidget( button, 0 );
157 buttonGroupActions->insert( button, i);
158 }
159 button->setText( *acts[i] );
160 button->show();
161 }
162 for (uint i = acts.count(); i < _buttonCount; i++){
163 qDebug("remove button %i of %i",i, _buttonCount);
164 button = buttonGroupActions->find( i );
165 if (button) button->hide();
166 }
167 _buttonCount = acts.count();
168 // buttonShow = new QPushButton( detailsFrame, "Show" ) ;
169 // buttonShow->setText( "test" );
170 // buttonLayout->addWidget( buttonShow, 0 );
171// buttonGroupActions->insert(buttonShow);
139 detailsFrame->show(); 172 detailsFrame->show();
140 }else detailsFrame->hide(); 173 }else detailsFrame->hide();
141 //_currentItem = (OListViewItem*)item; 174 //_currentItem = (OListViewItem*)item;
142 popupTimer->start( 300 ); 175 popupTimer->start( 300 );
143} 176}
144 177
145void MainWindow::stopTimer(QListViewItem*) 178void MainWindow::stopTimer(QListViewItem*)
146{ 179{
147 popupTimer->stop(); 180 popupTimer->stop();
148} 181}
149 182
150void MainWindow::showPopup() 183void MainWindow::showPopup()
151{ 184{
152 qDebug("showPopup"); 185 qDebug("showPopup");
153 if (!_item) return; 186 if (!_currentItem) return;
154} 187}
155 188
156void MainWindow::setSearch( const QString &key ) 189void MainWindow::setSearch( const QString &key )
157{ 190{
158 adrSearch->setSearch(key); 191 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() )
159 todoSearch->setSearch(key); 192 s->setSearch( key );
160 datebookSearch->setSearch(key);
161 applnkSearch->setSearch(key);
162 doclnkSearch->setSearch(key);
163} 193}
164 194
165 195
166void MainWindow::showItem() 196void MainWindow::slotAction( int act)
167{ 197{
168 if (_currentItem->rtti() == OListViewItem::Result){ 198 if (_currentItem->rtti() == OListViewItem::Result){
169 ResultItem *res = (ResultItem*)_currentItem; 199 ResultItem *res = (ResultItem*)_currentItem;
170 // ResultItem *res = dynamic_cast<ResultItem*>(item); 200 // ResultItem *res = dynamic_cast<ResultItem*>(item);
171 res->showItem(); 201 res->action(act);
172 } 202 }
173} 203}
174 204
175void MainWindow::editItem()
176{
177 if (_currentItem->rtti() == OListViewItem::Result){
178 ResultItem *res = (ResultItem*)_currentItem;
179 // ResultItem *res = dynamic_cast<ResultItem*>(item);
180 res->editItem();
181 }
182}
diff --git a/core/pim/osearch/mainwindow.h b/core/pim/osearch/mainwindow.h
index 424b4ba..f6ae0a4 100644
--- a/core/pim/osearch/mainwindow.h
+++ b/core/pim/osearch/mainwindow.h
@@ -1,73 +1,70 @@
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#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 <qtimer.h> 19#include <qtimer.h>
19#include <qpopupmenu.h> 20#include <qpopupmenu.h>
20 21
21class QPEToolBar; 22class QPEToolBar;
22class QVBoxLayout; 23class QVBoxLayout;
24class QHBoxLayout;
23class QTextView; 25class QTextView;
24class QFrame; 26class QFrame;
25class QListViewItem; 27class QListViewItem;
26class OListView; 28class OListView;
27class OListViewItem; 29class OListViewItem;
28class AdressSearch; 30class QHButtonGroup;
29class TodoSearch; 31
30class DatebookSearch; 32class SearchGroup;
31class AppLnkSearch;
32class DocLnkSearch;
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 showPopup(); 46 void showPopup();
47 void stopTimer( QListViewItem* ); 47 void stopTimer( QListViewItem* );
48 void setSearch( const QString& ); 48 void setSearch( const QString& );
49 49
50protected slots: 50protected slots:
51 void showItem(); 51 void slotAction(int);
52 void editItem();
53 52
54private: 53private:
55 OListView *resultsList; 54 OListView *resultsList;
56 QTextView *richEdit; 55 QTextView *richEdit;
57 OListViewItem *_currentItem; 56 OListViewItem *_currentItem;
58 QVBoxLayout *mainLayout; 57 QVBoxLayout *mainLayout;
58 QHBoxLayout *buttonLayout;
59 QFrame *detailsFrame; 59 QFrame *detailsFrame;
60 OListViewItem *_item; 60// OListViewItem *_item;
61 QTimer *popupTimer; 61 QTimer *popupTimer;
62 62
63 AdressSearch *adrSearch; 63 QList<SearchGroup> searches;
64 TodoSearch *todoSearch; 64 QHButtonGroup *buttonGroupActions;
65 DatebookSearch *datebookSearch; 65 uint _buttonCount;
66 AppLnkSearch *applnkSearch;
67 DocLnkSearch *doclnkSearch;
68
69 void makeMenu(); 66 void makeMenu();
70}; 67};
71 68
72#endif 69#endif
73 70
diff --git a/core/pim/osearch/resultitem.cpp b/core/pim/osearch/resultitem.cpp
index 31114d2..2c1e95a 100644
--- a/core/pim/osearch/resultitem.cpp
+++ b/core/pim/osearch/resultitem.cpp
@@ -1,41 +1,29 @@
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 "resultitem.h" 13#include "resultitem.h"
14 14
15#include <qmessagebox.h> 15#include <qmessagebox.h>
16 16
17#include <opie/otodo.h> 17#include <opie/otodo.h>
18 18
19 19
20ResultItem::ResultItem(OListViewItem* parent) 20ResultItem::ResultItem(OListViewItem* parent)
21: OListViewItem(parent) 21: OListViewItem(parent)
22{ 22{
23 23
24} 24}
25 25
26 26
27ResultItem::~ResultItem() 27ResultItem::~ResultItem()
28{ 28{
29} 29}
30
31void ResultItem::showItem()
32{
33 QMessageBox::warning(0,"Not implemented","show is not yet implemented for this");
34}
35
36
37void ResultItem::editItem()
38{
39 QMessageBox::warning(0,"Not implemented","edit is not yet implemented for this");
40}
41
diff --git a/core/pim/osearch/resultitem.h b/core/pim/osearch/resultitem.h
index 2cfb7f8..9e87f99 100644
--- a/core/pim/osearch/resultitem.h
+++ b/core/pim/osearch/resultitem.h
@@ -1,33 +1,35 @@
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 RESULTITEM_H 13#ifndef RESULTITEM_H
14#define RESULTITEM_H 14#define RESULTITEM_H
15 15
16#include <qintdict.h>
17
16#include "olistviewitem.h" 18#include "olistviewitem.h"
17 19
18/** 20/**
19@author Patrick S. Vogt 21@author Patrick S. Vogt
20*/ 22*/
21class ResultItem : public OListViewItem 23class ResultItem : public OListViewItem
22{ 24{
23public: 25public:
24 ResultItem(OListViewItem* parent); 26 ResultItem(OListViewItem* parent);
25 ~ResultItem(); 27 ~ResultItem();
26 28
27 virtual QString toRichText() {return "no text";}; 29 virtual QString toRichText() {return "no text";};
28 virtual int rtti() { return Result;} 30 virtual int rtti() { return Result;}
29 virtual void showItem(); 31 virtual void action( int ) = 0;
30 virtual void editItem(); 32 virtual QIntDict<QString> actions() = 0;
31}; 33};
32 34
33#endif 35#endif
diff --git a/core/pim/osearch/searchgroup.cpp b/core/pim/osearch/searchgroup.cpp
index dce3b14..d062207 100644
--- a/core/pim/osearch/searchgroup.cpp
+++ b/core/pim/osearch/searchgroup.cpp
@@ -1,57 +1,73 @@
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
15#include <qregexp.h>
16
14#include "olistviewitem.h" 17#include "olistviewitem.h"
15 18
16SearchGroup::SearchGroup(QListView* parent, QString name) 19SearchGroup::SearchGroup(QListView* parent, QString name)
17: OListViewItem(parent, name) 20: OListViewItem(parent, name)
18{ 21{
19 _name = name; 22 _name = name;
23 loaded = false;
20 expanded = false; 24 expanded = false;
21} 25}
22 26
23 27
24SearchGroup::~SearchGroup() 28SearchGroup::~SearchGroup()
25{ 29{
26} 30}
27 31
28 32
29void SearchGroup::expand() 33void SearchGroup::expand()
30{ 34{
35 clearList();
36 if (_search.isEmpty()) return;
37 OListViewItem *dummy = new OListViewItem( this, "searching...");
38 setOpen( expanded );
39 if (!loaded) load();
40 int res_count = search();
41 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
42 delete dummy;
43}
44
45
46void SearchGroup::clearList()
47{
31 QListViewItem *item = firstChild(); 48 QListViewItem *item = firstChild();
32 QListViewItem *toDel; 49 QListViewItem *toDel;
33 50
34 while ( item != 0 ) { 51 while ( item != 0 ) {
35 toDel = item; 52 toDel = item;
36 item = item->nextSibling(); 53 item = item->nextSibling();
37 //takeItem(toDel); 54 delete toDel;
38 delete toDel;
39 } 55 }
40 expanded = true; 56 expanded = true;
41} 57}
42 58
43void SearchGroup::setSearch(QString s) 59void SearchGroup::setSearch(QString s)
44{ 60{
45 setSearch( QRegExp( s ) ); 61 setSearch( QRegExp( s ) );
46 _search.setCaseSensitive(false); 62 _search.setCaseSensitive(false);
47} 63}
48 64
49 65
50void SearchGroup::setSearch(QRegExp re) 66void SearchGroup::setSearch(QRegExp re)
51{ 67{
52 setText(0, _name+" - "+re.pattern() ); 68 setText(0, _name+" - "+re.pattern() );
53 _search = re; 69 _search = re;
54 if (expanded) expand(); 70 if (expanded) expand();
55 else new OListViewItem( this, "searching..."); 71 else new OListViewItem( this, "searching...");
56} 72}
57 73
diff --git a/core/pim/osearch/searchgroup.h b/core/pim/osearch/searchgroup.h
index d26ff17..ebe1193 100644
--- a/core/pim/osearch/searchgroup.h
+++ b/core/pim/osearch/searchgroup.h
@@ -1,42 +1,49 @@
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
18#include <qregexp.h> 18class QRegExp;
19 19
20/** 20/**
21@author Patrick S. Vogt 21@author Patrick S. Vogt
22*/ 22*/
23class SearchGroup : public OListViewItem 23class SearchGroup : public OListViewItem
24{ 24{
25public: 25public:
26 SearchGroup(QListView* parent, QString name); 26 SearchGroup(QListView* parent, QString name);
27 27
28 ~SearchGroup(); 28 ~SearchGroup();
29 29
30 virtual void expand(); 30 virtual void expand();
31 virtual void setSearch(QString); 31 virtual void setSearch(QString);
32 virtual void setSearch(QRegExp); 32 virtual void setSearch(QRegExp);
33 virtual int rtti() { return Searchgroup;} 33 virtual int rtti() { return Searchgroup;}
34 34
35
36
35protected: 37protected:
36 QRegExp _search; 38 QRegExp _search;
39 virtual void load() = 0;
40 virtual int search() = 0;
41 virtual void insertItem( void* ) = 0;
37private: 42private:
43 void clearList();
38 QString _name; 44 QString _name;
39 bool expanded; 45 bool expanded;
46 bool loaded;
40}; 47};
41 48
42#endif 49#endif
diff --git a/core/pim/osearch/todoitem.cpp b/core/pim/osearch/todoitem.cpp
index 145b423..8b354f1 100644
--- a/core/pim/osearch/todoitem.cpp
+++ b/core/pim/osearch/todoitem.cpp
@@ -1,54 +1,52 @@
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 "todoitem.h" 13#include "todoitem.h"
14 14
15#include <opie/otodo.h> 15#include <opie/otodo.h>
16#include <qpe/qcopenvelope_qws.h> 16#include <qpe/qcopenvelope_qws.h>
17 17
18TodoItem::TodoItem(OListViewItem* parent, OTodo *todo) 18TodoItem::TodoItem(OListViewItem* parent, OTodo *todo)
19: ResultItem(parent) 19: ResultItem(parent)
20{ 20{
21 _todo = todo; 21 _todo = todo;
22 setText( 0, todo->toShortText() ); 22 setText( 0, todo->toShortText() );
23} 23}
24 24
25
26TodoItem::~TodoItem() 25TodoItem::~TodoItem()
27{ 26{
28 delete _todo; 27 delete _todo;
29} 28}
30 29
31
32void TodoItem::expand()
33{
34 ResultItem::expand();
35}
36
37QString TodoItem::toRichText() 30QString TodoItem::toRichText()
38{ 31{
39 return _todo->toRichText(); 32 return _todo->toRichText();
40} 33}
41 34
42void TodoItem::showItem() 35void TodoItem::action( int act )
43{ 36{
44 //QCopEnvelope e("QPE/Todolist", "show(int)"); 37 if (act == 0){
45 QCopEnvelope e("QPE/Application/todolist", "show(int)"); 38 QCopEnvelope e("QPE/Application/todolist", "show(int)");
46 e << _todo->uid(); 39 e << _todo->uid();
40 }else if (act == 1){
41 QCopEnvelope e("QPE/Application/todolist", "edit(int)");
42 e << _todo->uid();
43 }
47} 44}
48 45
49void TodoItem::editItem() 46QIntDict<QString> TodoItem::actions()
50{ 47{
51 //QCopEnvelope e("QPE/Todolist", "edit(int)"); 48 QIntDict<QString> result;
52 QCopEnvelope e("QPE/Application/todolist", "edit(int)"); 49 result.insert( 0, new QString( QObject::tr("show") ) );
53 e << _todo->uid(); 50 result.insert( 1, new QString( QObject::tr("edit") ) );
51 return result;
54} 52}
diff --git a/core/pim/osearch/todoitem.h b/core/pim/osearch/todoitem.h
index 6f34915..9dfd4ff 100644
--- a/core/pim/osearch/todoitem.h
+++ b/core/pim/osearch/todoitem.h
@@ -1,38 +1,37 @@
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 TODOITEM_H 13#ifndef TODOITEM_H
14#define TODOITEM_H 14#define TODOITEM_H
15 15
16#include "resultitem.h" 16#include "resultitem.h"
17class OTodo; 17class OTodo;
18 18
19/** 19/**
20@author Patrick S. Vogt 20@author Patrick S. Vogt
21*/ 21*/
22class TodoItem : public ResultItem 22class TodoItem : public ResultItem
23{ 23{
24public: 24public:
25 TodoItem(OListViewItem* parent, OTodo *todo); 25 TodoItem(OListViewItem* parent, OTodo *todo);
26 ~TodoItem(); 26 ~TodoItem();
27 27
28 virtual void expand();
29 virtual QString toRichText(); 28 virtual QString toRichText();
30 virtual void showItem(); 29 virtual void action( int );
31 virtual void editItem(); 30 virtual QIntDict<QString> actions();
32 31
33private: 32private:
34 OTodo *_todo; 33 OTodo *_todo;
35 34
36}; 35};
37 36
38#endif 37#endif
diff --git a/core/pim/osearch/todosearch.cpp b/core/pim/osearch/todosearch.cpp
index cbe356b..6a73530 100644
--- a/core/pim/osearch/todosearch.cpp
+++ b/core/pim/osearch/todosearch.cpp
@@ -1,51 +1,50 @@
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 17
18#include "todoitem.h" 18#include "todoitem.h"
19 19
20TodoSearch::TodoSearch(QListView* parent, QString name) 20TodoSearch::TodoSearch(QListView* parent, QString name)
21: SearchGroup(parent, name) 21: SearchGroup(parent, name)
22{ 22{
23 _todos = 0; 23 _todos = 0;
24} 24}
25 25
26 26
27TodoSearch::~TodoSearch() 27TodoSearch::~TodoSearch()
28{ 28{
29 delete _todos; 29 delete _todos;
30} 30}
31 31
32 32
33void TodoSearch::expand() 33void TodoSearch::load()
34{ 34{
35 SearchGroup::expand();
36 if (_search.isEmpty()) return;
37
38 if (!_todos){
39 _todos = new OTodoAccess(); 35 _todos = new OTodoAccess();
40 _todos->load(); 36 _todos->load();
41 } 37}
42 38
39int TodoSearch::search()
40{
43 ORecordList<OTodo> results = _todos->matchRegexp(_search); 41 ORecordList<OTodo> results = _todos->matchRegexp(_search);
44 setText(0, text(0) + " (" + QString::number( results.count() ) + ")"); 42 for (uint i = 0; i < results.count(); i++)
45 for (uint i = 0; i < results.count(); i++) {
46 new TodoItem( this, new OTodo( results[i] )); 43 new TodoItem( this, new OTodo( results[i] ));
47 } 44 return results.count();
48
49} 45}
50 46
47void TodoSearch::insertItem( void* )
48{
51 49
50}
diff --git a/core/pim/osearch/todosearch.h b/core/pim/osearch/todosearch.h
index 856be1f..1d025d6 100644
--- a/core/pim/osearch/todosearch.h
+++ b/core/pim/osearch/todosearch.h
@@ -1,35 +1,39 @@
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;
19 19
20/** 20/**
21@author Patrick S. Vogt 21@author Patrick S. Vogt
22*/ 22*/
23class TodoSearch : public SearchGroup 23class TodoSearch : public SearchGroup
24{ 24{
25public: 25public:
26 TodoSearch(QListView* parent, QString name); 26 TodoSearch(QListView* parent, QString name);
27 27
28 ~TodoSearch(); 28 ~TodoSearch();
29 29
30 virtual void expand(); 30protected:
31 virtual void load();
32 virtual int search();
33 virtual void insertItem( void* );
34
31private: 35private:
32 OTodoAccess *_todos; 36 OTodoAccess *_todos;
33}; 37};
34 38
35#endif 39#endif