summaryrefslogtreecommitdiff
Unidiff
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
@@ -29,17 +29,22 @@ AdressSearch::~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
@@ -25,12 +25,12 @@ class AdressSearch : public SearchGroup
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};
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,9 +1,9 @@
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//
@@ -29,26 +29,22 @@ AppLnkItem::~AppLnkItem()
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
@@ -26,10 +26,10 @@ public:
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};
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,9 +1,9 @@
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//
@@ -28,19 +28,28 @@ AppLnkSearch::~AppLnkSearch()
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,9 +1,9 @@
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//
@@ -26,10 +26,13 @@ public:
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,9 +1,9 @@
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//
@@ -33,19 +33,24 @@ QString 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
@@ -27,10 +27,11 @@ public:
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
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
@@ -29,18 +29,22 @@ DatebookSearch::~DatebookSearch()
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
@@ -26,9 +26,13 @@ public:
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};
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,9 +1,9 @@
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//
@@ -12,43 +12,59 @@
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
@@ -26,10 +26,10 @@ public:
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};
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
@@ -16,31 +16,23 @@
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
@@ -12,24 +12,22 @@
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
@@ -33,18 +33,22 @@ QString 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
@@ -27,10 +27,10 @@ public:
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
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
@@ -24,9 +24,11 @@
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
@@ -43,44 +45,52 @@ MainWindow::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
@@ -88,11 +98,10 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
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()
@@ -135,8 +144,32 @@ void MainWindow::setCurrent(QListViewItem *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 );
@@ -149,34 +182,23 @@ void MainWindow::stopTimer(QListViewItem*)
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
@@ -14,23 +14,23 @@
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
@@ -47,26 +47,23 @@ public slots:
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
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
@@ -26,16 +26,4 @@ ResultItem::ResultItem(OListViewItem* parent)
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
@@ -12,8 +12,10 @@
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
@@ -25,9 +27,9 @@ public:
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
@@ -10,14 +10,18 @@
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
@@ -27,16 +31,28 @@ SearchGroup::~SearchGroup()
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
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
@@ -14,9 +14,9 @@
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*/
@@ -31,12 +31,19 @@ public:
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,9 +1,9 @@
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//
@@ -21,34 +21,32 @@ TodoItem::TodoItem(OListViewItem* parent, OTodo *todo)
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,9 +1,9 @@
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//
@@ -24,12 +24,11 @@ class TodoItem : public ResultItem
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
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
@@ -29,23 +29,22 @@ TodoSearch::~TodoSearch()
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
@@ -19,16 +19,20 @@ class 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