26 files changed, 260 insertions, 191 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 | |||
@@ -32,10 +32,10 @@ AdressSearch::~AdressSearch() | |||
32 | 32 | ||
33 | void AdressSearch::load() | ||
34 | { | ||
35 | _contacts = new OContactAccess("osearch"); | ||
36 | } | ||
33 | 37 | ||
34 | void AdressSearch::expand() | 38 | int 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++) { |
@@ -43,3 +43,8 @@ void AdressSearch::expand() | |||
43 | } | 43 | } |
44 | return results.count(); | ||
44 | } | 45 | } |
45 | 46 | ||
47 | void 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 | |||
@@ -28,6 +28,6 @@ public: | |||
28 | 28 | ||
29 | virtual void expand(); | ||
30 | |||
31 | protected: | 29 | protected: |
32 | 30 | virtual void load(); | |
31 | virtual int search(); | ||
32 | virtual void insertItem( void* ); | ||
33 | 33 | ||
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 | |||
@@ -32,9 +32,5 @@ QString AppLnkItem::toRichText() | |||
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; |
@@ -42,13 +38,13 @@ QString AppLnkItem::toRichText() | |||
42 | 38 | ||
43 | void AppLnkItem::editItem() | 39 | void 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 | ||
48 | void AppLnkItem::showItem() | 45 | QIntDict<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 | |||
@@ -29,4 +29,4 @@ public: | |||
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 | ||
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 | |||
@@ -31,16 +31,25 @@ AppLnkSearch::~AppLnkSearch() | |||
31 | 31 | ||
32 | void AppLnkSearch::expand() | 32 | void 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 | |
37 | int 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 ); | ||
44 | } | 47 | } |
45 | } | 48 | } |
49 | return count; | ||
50 | } | ||
46 | 51 | ||
52 | void 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 | |||
@@ -29,4 +29,7 @@ public: | |||
29 | 29 | ||
30 | virtual void expand(); | 30 | protected: |
31 | private: | 31 | virtual void load(); |
32 | virtual int search(); | ||
33 | virtual void insertItem( void* ); | ||
34 | |||
32 | AppLnkSet *_apps; | 35 | AppLnkSet *_apps; |
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 | |||
@@ -36,7 +36,9 @@ QString ContactItem::toRichText() | |||
36 | 36 | ||
37 | 37 | void ContactItem::action( int act ) | |
38 | void ContactItem::editItem() | ||
39 | { | 38 | { |
39 | if (act == 0){ | ||
40 | QCopEnvelope e("QPE/Application/addressbook", "show(int)"); | ||
41 | e << _contact->uid(); | ||
42 | }else if(act == 1){ | ||
40 | QCopEnvelope e("QPE/Application/addressbook", "edit(int)"); | 43 | QCopEnvelope e("QPE/Application/addressbook", "edit(int)"); |
41 | //QCopEnvelope e("QPE/Addressbook", "edit(int)"); | ||
42 | e << _contact->uid(); | 44 | e << _contact->uid(); |
@@ -44,8 +46,11 @@ void ContactItem::editItem() | |||
44 | 46 | ||
45 | void 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 | ||
49 | QIntDict<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 | |||
@@ -30,4 +30,5 @@ public: | |||
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 | ||
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 | |||
@@ -32,6 +32,4 @@ DatebookSearch::~DatebookSearch() | |||
32 | 32 | ||
33 | void DatebookSearch::expand() | 33 | void DatebookSearch::load() |
34 | { | 34 | { |
35 | SearchGroup::expand(); | ||
36 | if (!_dates){ | ||
37 | _dates = new ODateBookAccess(); | 35 | _dates = new ODateBookAccess(); |
@@ -39,8 +37,14 @@ void DatebookSearch::expand() | |||
39 | } | 37 | } |
38 | |||
39 | int 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 | ||
47 | void 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 | |||
@@ -29,3 +29,7 @@ public: | |||
29 | 29 | ||
30 | virtual void expand(); | 30 | protected: |
31 | virtual void load(); | ||
32 | virtual int search(); | ||
33 | virtual void insertItem( void* ); | ||
34 | |||
31 | private: | 35 | private: |
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 | |||
@@ -15,2 +15,4 @@ | |||
15 | #include <qpe/applnk.h> | 15 | #include <qpe/applnk.h> |
16 | #include <qfile.h> | ||
17 | #include <qtextstream.h> | ||
16 | 18 | ||
@@ -23,3 +25,2 @@ DocLnkItem::DocLnkItem(OListViewItem* parent, DocLnk *app) | |||
23 | 25 | ||
24 | |||
25 | DocLnkItem::~DocLnkItem() | 26 | DocLnkItem::~DocLnkItem() |
@@ -28,3 +29,2 @@ DocLnkItem::~DocLnkItem() | |||
28 | 29 | ||
29 | |||
30 | QString DocLnkItem::toRichText() | 30 | QString DocLnkItem::toRichText() |
@@ -32,9 +32,24 @@ QString DocLnkItem::toRichText() | |||
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; |
@@ -42,13 +57,14 @@ QString DocLnkItem::toRichText() | |||
42 | 57 | ||
43 | void DocLnkItem::editItem() | 58 | void 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 | ||
48 | void DocLnkItem::showItem() | 65 | QIntDict<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 | |||
@@ -29,4 +29,4 @@ public: | |||
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 | ||
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 | |||
@@ -19,5 +19,5 @@ | |||
19 | 19 | ||
20 | DocLnkSearch::DocLnkSearch(QListView* parent, QString name): SearchGroup(parent, name) | 20 | DocLnkSearch::DocLnkSearch(QListView* parent, QString name) |
21 | : AppLnkSearch(parent, name) | ||
21 | { | 22 | { |
22 | _docs = 0; | ||
23 | } | 23 | } |
@@ -27,20 +27,12 @@ DocLnkSearch::~DocLnkSearch() | |||
27 | { | 27 | { |
28 | delete _docs; | ||
29 | } | 28 | } |
30 | 29 | ||
31 | 30 | void DocLnkSearch::load() | |
32 | void 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 | ||
35 | void 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 | |||
@@ -15,5 +15,3 @@ | |||
15 | 15 | ||
16 | #include "searchgroup.h" | 16 | #include "applnksearch.h" |
17 | |||
18 | class DocLnkSet; | ||
19 | 17 | ||
@@ -22,3 +20,3 @@ class DocLnkSet; | |||
22 | */ | 20 | */ |
23 | class DocLnkSearch : public SearchGroup | 21 | class DocLnkSearch : public AppLnkSearch |
24 | { | 22 | { |
@@ -26,8 +24,8 @@ public: | |||
26 | DocLnkSearch(QListView* parent, QString name); | 24 | DocLnkSearch(QListView* parent, QString name); |
27 | |||
28 | ~DocLnkSearch(); | 25 | ~DocLnkSearch(); |
29 | 26 | ||
30 | virtual void expand(); | 27 | protected: |
31 | private: | 28 | virtual void load(); |
32 | DocLnkSet *_docs; | 29 | virtual void insertItem( void* ); |
30 | |||
33 | }; | 31 | }; |
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 | |||
@@ -36,4 +36,8 @@ QString EventItem::toRichText() | |||
36 | 36 | ||
37 | void EventItem::editItem() | 37 | void EventItem::action( int act ) |
38 | { | 38 | { |
39 | if (act == 0){ | ||
40 | QCopEnvelope e("QPE/Application/datebook", "viewDefault(QDate)"); | ||
41 | e << _event->startDateTime().date(); | ||
42 | }else if(act == 1){ | ||
39 | QCopEnvelope e("QPE/Application/datebook", "editEvent(int)"); | 43 | QCopEnvelope e("QPE/Application/datebook", "editEvent(int)"); |
@@ -41,10 +45,10 @@ void EventItem::editItem() | |||
41 | } | 45 | } |
46 | } | ||
42 | 47 | ||
43 | void EventItem::showItem() | 48 | QIntDict<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 | |||
@@ -30,4 +30,4 @@ public: | |||
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 | ||
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 | |||
@@ -27,3 +27,5 @@ | |||
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> |
@@ -46,3 +48,3 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
46 | 48 | ||
47 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 49 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); |
48 | 50 | ||
@@ -55,4 +57,4 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
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 | ||
@@ -61,23 +63,31 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
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 | ||
@@ -91,5 +101,4 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
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 | ||
@@ -138,2 +147,26 @@ void MainWindow::setCurrent(QListViewItem *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(); |
@@ -152,3 +185,3 @@ void MainWindow::showPopup() | |||
152 | qDebug("showPopup"); | 185 | qDebug("showPopup"); |
153 | if (!_item) return; | 186 | if (!_currentItem) return; |
154 | } | 187 | } |
@@ -157,7 +190,4 @@ void 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 | } |
@@ -165,3 +195,3 @@ void MainWindow::setSearch( const QString &key ) | |||
165 | 195 | ||
166 | void MainWindow::showItem() | 196 | void MainWindow::slotAction( int act) |
167 | { | 197 | { |
@@ -170,3 +200,3 @@ void MainWindow::showItem() | |||
170 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | 200 | // ResultItem *res = dynamic_cast<ResultItem*>(item); |
171 | res->showItem(); | 201 | res->action(act); |
172 | } | 202 | } |
@@ -174,9 +204 @@ void MainWindow::showItem() | |||
174 | |||
175 | void 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 | |||
@@ -17,2 +17,3 @@ | |||
17 | #include <qaction.h> | 17 | #include <qaction.h> |
18 | #include <qlist.h> | ||
18 | #include <qtimer.h> | 19 | #include <qtimer.h> |
@@ -22,2 +23,3 @@ class QPEToolBar; | |||
22 | class QVBoxLayout; | 23 | class QVBoxLayout; |
24 | class QHBoxLayout; | ||
23 | class QTextView; | 25 | class QTextView; |
@@ -27,7 +29,5 @@ class OListView; | |||
27 | class OListViewItem; | 29 | class OListViewItem; |
28 | class AdressSearch; | 30 | class QHButtonGroup; |
29 | class TodoSearch; | 31 | |
30 | class DatebookSearch; | 32 | class SearchGroup; |
31 | class AppLnkSearch; | ||
32 | class DocLnkSearch; | ||
33 | 33 | ||
@@ -50,4 +50,3 @@ public slots: | |||
50 | protected slots: | 50 | protected slots: |
51 | void showItem(); | 51 | void slotAction(int); |
52 | void editItem(); | ||
53 | 52 | ||
@@ -58,12 +57,10 @@ private: | |||
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(); |
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 | |||
@@ -29,13 +29 @@ ResultItem::~ResultItem() | |||
29 | } | } | |
30 | |||
31 | void ResultItem::showItem() | ||
32 | { | ||
33 | QMessageBox::warning(0,"Not implemented","show is not yet implemented for this"); | ||
34 | } | ||
35 | |||
36 | |||
37 | void 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 | |||
@@ -15,2 +15,4 @@ | |||
15 | 15 | ||
16 | #include <qintdict.h> | ||
17 | |||
16 | #include "olistviewitem.h" | 18 | #include "olistviewitem.h" |
@@ -28,4 +30,4 @@ public: | |||
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 | }; |
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 | |||
@@ -13,2 +13,5 @@ | |||
13 | #include "searchgroup.h" | 13 | #include "searchgroup.h" |
14 | |||
15 | #include <qregexp.h> | ||
16 | |||
14 | #include "olistviewitem.h" | 17 | #include "olistviewitem.h" |
@@ -19,2 +22,3 @@ SearchGroup::SearchGroup(QListView* parent, QString name) | |||
19 | _name = name; | 22 | _name = name; |
23 | loaded = false; | ||
20 | expanded = false; | 24 | expanded = false; |
@@ -30,2 +34,15 @@ void 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 | |||
46 | void SearchGroup::clearList() | ||
47 | { | ||
31 | QListViewItem *item = firstChild(); | 48 | QListViewItem *item = firstChild(); |
@@ -36,3 +53,2 @@ void SearchGroup::expand() | |||
36 | item = item->nextSibling(); | 53 | item = item->nextSibling(); |
37 | //takeItem(toDel); | ||
38 | delete toDel; | 54 | delete toDel; |
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 | |||
@@ -17,3 +17,3 @@ | |||
17 | 17 | ||
18 | #include <qregexp.h> | 18 | class QRegExp; |
19 | 19 | ||
@@ -34,7 +34,14 @@ public: | |||
34 | 34 | ||
35 | |||
36 | |||
35 | protected: | 37 | protected: |
36 | QRegExp _search; | 38 | QRegExp _search; |
39 | virtual void load() = 0; | ||
40 | virtual int search() = 0; | ||
41 | virtual void insertItem( void* ) = 0; | ||
37 | private: | 42 | private: |
43 | void clearList(); | ||
38 | QString _name; | 44 | QString _name; |
39 | bool expanded; | 45 | bool expanded; |
46 | bool loaded; | ||
40 | }; | 47 | }; |
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 | |||
@@ -24,3 +24,2 @@ TodoItem::TodoItem(OListViewItem* parent, OTodo *todo) | |||
24 | 24 | ||
25 | |||
26 | TodoItem::~TodoItem() | 25 | TodoItem::~TodoItem() |
@@ -30,8 +29,2 @@ TodoItem::~TodoItem() | |||
30 | 29 | ||
31 | |||
32 | void TodoItem::expand() | ||
33 | { | ||
34 | ResultItem::expand(); | ||
35 | } | ||
36 | |||
37 | QString TodoItem::toRichText() | 30 | QString TodoItem::toRichText() |
@@ -41,14 +34,19 @@ QString TodoItem::toRichText() | |||
41 | 34 | ||
42 | void TodoItem::showItem() | 35 | void 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 | ||
49 | void TodoItem::editItem() | 46 | QIntDict<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 | |||
@@ -27,6 +27,5 @@ public: | |||
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 | ||
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 | |||
@@ -32,8 +32,4 @@ TodoSearch::~TodoSearch() | |||
32 | 32 | ||
33 | void TodoSearch::expand() | 33 | void TodoSearch::load() |
34 | { | 34 | { |
35 | SearchGroup::expand(); | ||
36 | if (_search.isEmpty()) return; | ||
37 | |||
38 | if (!_todos){ | ||
39 | _todos = new OTodoAccess(); | 35 | _todos = new OTodoAccess(); |
@@ -42,10 +38,13 @@ void TodoSearch::expand() | |||
42 | 38 | ||
39 | int 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] )); |
44 | return results.count(); | ||
47 | } | 45 | } |
48 | 46 | ||
49 | } | 47 | void TodoSearch::insertItem( void* ) |
50 | 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 | |||
@@ -29,3 +29,7 @@ public: | |||
29 | 29 | ||
30 | virtual void expand(); | 30 | protected: |
31 | virtual void load(); | ||
32 | virtual int search(); | ||
33 | virtual void insertItem( void* ); | ||
34 | |||
31 | private: | 35 | private: |