summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -32,10 +32,10 @@ AdressSearch::~AdressSearch()
+void AdressSearch::load()
+{
+ _contacts = new OContactAccess("osearch");
+}
-void AdressSearch::expand()
+int AdressSearch::search()
{
- SearchGroup::expand();
- if (_search.isEmpty()) return;
- if (!_contacts) _contacts = new OContactAccess("osearch");
ORecordList<OContact> results = _contacts->matchRegexp(_search);
- setText(0, text(0) + " (" + QString::number( results.count() ) + ")" );
for (uint i = 0; i < results.count(); i++) {
@@ -43,3 +43,8 @@ void AdressSearch::expand()
}
+ return results.count();
}
+void AdressSearch::insertItem( void* )
+{
+
+}
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:
- virtual void expand();
-
protected:
-
+ virtual void load();
+ virtual int search();
+ virtual void insertItem( void* );
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
@@ -4,3 +4,3 @@
//
-// Description:
+// Description:
//
@@ -32,9 +32,5 @@ QString AppLnkItem::toRichText()
QString text;
- text += "<b><h3>";
- text += _app->name();
- text += "</b></h3><br>";
- text += _app->comment();
- text += "<br><br>`";
- text += _app->exec();
- text += "`";
+ text += "<b><h3>" + _app->name() + "</b></h3><br>";
+ text += _app->comment() + "<br>";
+ text += "<br>`" + _app->exec() + "`<br>";
return text;
@@ -42,13 +38,13 @@ QString AppLnkItem::toRichText()
-void AppLnkItem::editItem()
+void AppLnkItem::action( int act )
{
- _app->execute();
+ if (!_app->isValid()) qDebug("INVALID");
+ if (act == 0) _app->execute();
}
-void AppLnkItem::showItem()
+QIntDict<QString> AppLnkItem::actions()
{
-/* QCopEnvelope e("QPE/Application/addressbook", "edit(int)");
- e << _contact->uid();*/
- ResultItem::showItem();
+ QIntDict<QString> result;
+ result.insert( 0, new QString( QObject::tr("execute") ) );
+ return result;
}
-
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:
virtual QString toRichText();
- virtual void editItem();
- virtual void showItem();
+ virtual void action( int );
+ virtual QIntDict<QString> actions();
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
@@ -4,3 +4,3 @@
//
-// Description:
+// Description:
//
@@ -31,16 +31,25 @@ AppLnkSearch::~AppLnkSearch()
-void AppLnkSearch::expand()
+void AppLnkSearch::load()
{
- SearchGroup::expand();
- if (_search.isEmpty()) return;
- if (!_apps) _apps = new AppLnkSet(QPEApplication::qpeDir());
+ _apps = new AppLnkSet(QPEApplication::qpeDir());
+}
+
+int AppLnkSearch::search()
+{
+ int count = 0;
QList<AppLnk> appList = _apps->children();
for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){
-// if (app->name().contains(_search) || app->comment().contains(_search))
if ( (_search.match( app->name() ) != -1)
|| (_search.match(app->comment()) != -1)
- || (_search.match(app->exec()) != -1) )
- new AppLnkItem( this, app );
+ || (_search.match(app->exec()) != -1) ) {
+ count++;
+ insertItem( app );
+ }
}
+ return count;
}
+void AppLnkSearch::insertItem( void *rec )
+{
+ new AppLnkItem( this, (AppLnk*)rec );
+}
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
@@ -4,3 +4,3 @@
//
-// Description:
+// Description:
//
@@ -29,5 +29,8 @@ public:
- virtual void expand();
-private:
- AppLnkSet *_apps;
+protected:
+ virtual void load();
+ virtual int search();
+ virtual void insertItem( void* );
+
+ 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
@@ -4,3 +4,3 @@
//
-// Description:
+// Description:
//
@@ -36,16 +36,21 @@ QString ContactItem::toRichText()
-
-void ContactItem::editItem()
+void ContactItem::action( int act )
{
- QCopEnvelope e("QPE/Application/addressbook", "edit(int)");
-// QCopEnvelope e("QPE/Addressbook", "edit(int)");
+if (act == 0){
+ QCopEnvelope e("QPE/Application/addressbook", "show(int)");
e << _contact->uid();
+}else if(act == 1){
+ QCopEnvelope e("QPE/Application/addressbook", "edit(int)");
+ e << _contact->uid();
}
-void ContactItem::showItem()
-{
- QCopEnvelope e("QPE/Application/addressbook", "show(int)");
-// QCopEnvelope e("QPE/Addressbook", "show(int)");
- e << _contact->uid();
}
+QIntDict<QString> ContactItem::actions()
+{
+ QIntDict<QString> result;
+ result.insert( 0, new QString( QObject::tr("show") ) );
+ result.insert( 1, new QString( QObject::tr("edit") ) );
+ return result;
+
+}
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:
virtual QString toRichText();
- virtual void showItem();
- virtual void editItem();
+ virtual void action( int );
+ virtual QIntDict<QString> actions();
+
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,15 +32,19 @@ DatebookSearch::~DatebookSearch()
-void DatebookSearch::expand()
+void DatebookSearch::load()
{
- SearchGroup::expand();
- if (!_dates){
_dates = new ODateBookAccess();
_dates->load();
- }
+}
+
+int DatebookSearch::search()
+{
ORecordList<OEvent> results = _dates->matchRegexp(_search);
- setText(0, text(0) + " (" + QString::number( results.count() ) + ")" );
- for (uint i = 0; i < results.count(); i++) {
+ for (uint i = 0; i < results.count(); i++)
new EventItem( this, new OEvent( results[i] ));
- }
+ return results.count();
}
+void DatebookSearch::insertItem( void* )
+{
+
+}
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:
- virtual void expand();
+protected:
+ virtual void load();
+ virtual int search();
+ virtual void insertItem( void* );
+
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
@@ -4,3 +4,3 @@
//
-// Description:
+// Description:
//
@@ -15,2 +15,4 @@
#include <qpe/applnk.h>
+#include <qfile.h>
+#include <qtextstream.h>
@@ -23,3 +25,2 @@ DocLnkItem::DocLnkItem(OListViewItem* parent, DocLnk *app)
-
DocLnkItem::~DocLnkItem()
@@ -28,3 +29,2 @@ DocLnkItem::~DocLnkItem()
-
QString DocLnkItem::toRichText()
@@ -32,9 +32,24 @@ QString DocLnkItem::toRichText()
QString text;
- text += "<b><h3>";
- text += _doc->name();
- text += "</b></h3><br>";
- text += _doc->comment();
- text += "<br><br>`";
+ text += "<b><h3>" + _doc->name() + "</b></h3><br>";
+ text += _doc->comment() + "<br>";
+ text += "File: " + _doc->file() + "<br>";
+ text += "Mimetype: " + _doc->type() + "<br>";
+ if ( _doc->type().contains( "text" ) ){
+ text += "<br><br><hr><br>";
+ QFile f(_doc->file());
+ if ( f.open(IO_ReadOnly) ) {
+ QTextStream t( &f );
+ while ( !t.eof() )
+ text += t.readLine() + "<br>";
+ }
+ f.close();
+ }
+ /* text += "<br><br>`";
text += _doc->exec();
- text += "`";
+ text += "`";*/
+ QStringList list = _doc->mimeTypes();
+ int i = 0;
+ for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
+ text += QString::number( i++) + " - " + *it ;
+ }
return text;
@@ -42,13 +57,14 @@ QString DocLnkItem::toRichText()
-void DocLnkItem::editItem()
+void DocLnkItem::action( int act )
{
- _doc->execute();
+ qDebug("action %i",act);
+ if (!_doc->isValid()) qDebug("INVALID");
+ if (act == 0) _doc->execute();
}
-void DocLnkItem::showItem()
+QIntDict<QString> DocLnkItem::actions()
{
-/* QCopEnvelope e("QPE/Application/addressbook", "edit(int)");
- e << _contact->uid();*/
- ResultItem::showItem();
+ QIntDict<QString> result;
+ result.insert( 0, new QString( QObject::tr("open with ") + _doc->exec() ) );
+ return result;
}
-
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:
virtual QString toRichText();
- virtual void editItem();
- virtual void showItem();
+ virtual void action( int );
+ virtual QIntDict<QString> actions();
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 @@
-DocLnkSearch::DocLnkSearch(QListView* parent, QString name): SearchGroup(parent, name)
+DocLnkSearch::DocLnkSearch(QListView* parent, QString name)
+: AppLnkSearch(parent, name)
{
- _docs = 0;
}
@@ -27,20 +27,12 @@ DocLnkSearch::~DocLnkSearch()
{
- delete _docs;
}
-
-void DocLnkSearch::expand()
+void DocLnkSearch::load()
{
- SearchGroup::expand();
- if (_search.isEmpty()) return;
- if (!_docs) _docs = new DocLnkSet(QPEApplication::documentDir());
- QList<DocLnk> appList = _docs->children();
- for ( DocLnk *app = appList.first(); app != 0; app = appList.next() ){
-// if (app->name().contains(_search) || app->comment().contains(_search))
- if ( (_search.match( app->name() ) != -1)
- || (_search.match(app->comment()) != -1)
- || (_search.match(app->exec()) != -1) )
- new DocLnkItem( this, app );
- }
+ _apps = new DocLnkSet(QPEApplication::documentDir());
}
+void DocLnkSearch::insertItem( void *rec )
+{
+ new DocLnkItem( this, (DocLnk*)rec );
+}
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 @@
-#include "searchgroup.h"
-
-class DocLnkSet;
+#include "applnksearch.h"
@@ -22,3 +20,3 @@ class DocLnkSet;
*/
-class DocLnkSearch : public SearchGroup
+class DocLnkSearch : public AppLnkSearch
{
@@ -26,8 +24,8 @@ public:
DocLnkSearch(QListView* parent, QString name);
-
~DocLnkSearch();
- virtual void expand();
-private:
- DocLnkSet *_docs;
+protected:
+ virtual void load();
+ virtual void insertItem( void* );
+
};
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,15 +36,19 @@ QString EventItem::toRichText()
-void EventItem::editItem()
+void EventItem::action( int act )
{
- QCopEnvelope e("QPE/Application/datebook", "editEvent(int)");
- e << _event->uid();
+ if (act == 0){
+ QCopEnvelope e("QPE/Application/datebook", "viewDefault(QDate)");
+ e << _event->startDateTime().date();
+ }else if(act == 1){
+ QCopEnvelope e("QPE/Application/datebook", "editEvent(int)");
+ e << _event->uid();
+ }
}
-void EventItem::showItem()
+QIntDict<QString> EventItem::actions()
{
- QCopEnvelope e("QPE/Application/datebook", "viewDefault(QDate)");
- QDate day = _event->startDateTime().date();
- qDebug("sending view day %s",day.toString().latin1());
- e << day;
+ QIntDict<QString> result;
+ result.insert( 0, new QString( QObject::tr("show") ) );
+ result.insert( 1, new QString( QObject::tr("edit") ) );
+ return result;
}
-
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:
virtual QString toRichText();
- virtual void editItem();
- virtual void showItem();
+ virtual void action( int );
+ virtual QIntDict<QString> actions();
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 @@
#include <qfile.h>
+#include <qhbuttongroup.h>
#include <qpushbutton.h>
+#include <qintdict.h>
#include <qlayout.h>
@@ -46,3 +48,3 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
- setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
+ setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
@@ -55,4 +57,4 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
resultsList = new OListView( mainFrame );
- resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
- mainLayout->addWidget( resultsList );
+ resultsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
+ mainLayout->addWidget( resultsList, 1 );
@@ -61,23 +63,31 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
richEdit = new QTextView( detailsFrame );
- richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
- detailsLayout->addWidget( richEdit, 0 );
- QHBoxLayout *buttonLayout = new QHBoxLayout( detailsFrame );
- detailsLayout->addLayout( buttonLayout, 0 );
+ richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
+ //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ));
+ detailsLayout->addWidget( richEdit, 1 );
+
+ buttonGroupActions = new QHButtonGroup( this );
+ _buttonCount = 0;
+// buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
+
+ buttonLayout = new QHBoxLayout( detailsFrame );
+ buttonGroupActions->hide();
+ //buttonLayout->addWidget( buttonGroupActions, 0 );
+
+ detailsLayout->addLayout( buttonLayout );
+ /*
QPushButton *buttonShow = new QPushButton( detailsFrame, "Show" );
buttonShow->setText( tr("show") );
-// buttonShow->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
QPushButton *buttonEdit = new QPushButton( detailsFrame, "Edit" );
buttonEdit->setText( tr("edit") );
- // buttonEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
buttonLayout->addWidget( buttonShow, 0 );
buttonLayout->addWidget( buttonEdit, 0 );
-
- mainLayout->addWidget( detailsFrame, 0 );
+*/
+ mainLayout->addWidget( detailsFrame );
detailsFrame->hide();
- adrSearch = new AdressSearch( resultsList, tr("adressbook") );
- todoSearch = new TodoSearch( resultsList, tr("todo") );
- datebookSearch = new DatebookSearch( resultsList, tr("datebook") );
- applnkSearch = new AppLnkSearch( resultsList, tr("applications") );
- doclnkSearch = new DocLnkSearch( resultsList, tr("documents") );
+ searches.append( new AdressSearch( resultsList, tr("adressbook") ) );
+ searches.append( new TodoSearch( resultsList, tr("todo") ) );
+ searches.append( new DatebookSearch( resultsList, tr("datebook") ) );
+ searches.append( new AppLnkSearch( resultsList, tr("applications") ) );
+ searches.append( new DocLnkSearch( resultsList, tr("documents") ) );
@@ -91,5 +101,4 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*)));
- connect(buttonShow, SIGNAL(clicked()), SLOT( showItem() ) );
- connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) );
-
+ connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) );
+// connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) );
@@ -138,2 +147,26 @@ void MainWindow::setCurrent(QListViewItem *item)
richEdit->setText( res->toRichText() );
+ QIntDict<QString> acts = res->actions();
+ QButton *button;
+ for (uint i = 0; i < acts.count(); i++){
+ button = buttonGroupActions->find( i );
+ qDebug("action %i >%s<",i,acts[i]->latin1());
+ if (!button) {
+ qDebug("BUTTON");
+ button = new QPushButton( detailsFrame );
+ buttonLayout->addWidget( button, 0 );
+ buttonGroupActions->insert( button, i);
+ }
+ button->setText( *acts[i] );
+ button->show();
+ }
+ for (uint i = acts.count(); i < _buttonCount; i++){
+ qDebug("remove button %i of %i",i, _buttonCount);
+ button = buttonGroupActions->find( i );
+ if (button) button->hide();
+ }
+ _buttonCount = acts.count();
+// buttonShow = new QPushButton( detailsFrame, "Show" ) ;
+// buttonShow->setText( "test" );
+// buttonLayout->addWidget( buttonShow, 0 );
+// buttonGroupActions->insert(buttonShow);
detailsFrame->show();
@@ -152,3 +185,3 @@ void MainWindow::showPopup()
qDebug("showPopup");
- if (!_item) return;
+ if (!_currentItem) return;
}
@@ -157,7 +190,4 @@ void MainWindow::setSearch( const QString &key )
{
- adrSearch->setSearch(key);
- todoSearch->setSearch(key);
- datebookSearch->setSearch(key);
- applnkSearch->setSearch(key);
- doclnkSearch->setSearch(key);
+ for (SearchGroup *s = searches.first(); s != 0; s = searches.next() )
+ s->setSearch( key );
}
@@ -165,3 +195,3 @@ void MainWindow::setSearch( const QString &key )
-void MainWindow::showItem()
+void MainWindow::slotAction( int act)
{
@@ -170,3 +200,3 @@ void MainWindow::showItem()
// ResultItem *res = dynamic_cast<ResultItem*>(item);
- res->showItem();
+ res->action(act);
}
@@ -174,9 +204 @@ void MainWindow::showItem()
-void MainWindow::editItem()
-{
- if (_currentItem->rtti() == OListViewItem::Result){
- ResultItem *res = (ResultItem*)_currentItem;
-// ResultItem *res = dynamic_cast<ResultItem*>(item);
- res->editItem();
- }
-}
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 @@
#include <qaction.h>
+#include <qlist.h>
#include <qtimer.h>
@@ -22,2 +23,3 @@ class QPEToolBar;
class QVBoxLayout;
+class QHBoxLayout;
class QTextView;
@@ -27,7 +29,5 @@ class OListView;
class OListViewItem;
-class AdressSearch;
-class TodoSearch;
-class DatebookSearch;
-class AppLnkSearch;
-class DocLnkSearch;
+class QHButtonGroup;
+
+class SearchGroup;
@@ -50,4 +50,3 @@ public slots:
protected slots:
- void showItem();
- void editItem();
+ void slotAction(int);
@@ -58,12 +57,10 @@ private:
QVBoxLayout *mainLayout;
+ QHBoxLayout *buttonLayout;
QFrame *detailsFrame;
- OListViewItem *_item;
+// OListViewItem *_item;
QTimer *popupTimer;
- AdressSearch *adrSearch;
- TodoSearch *todoSearch;
- DatebookSearch *datebookSearch;
- AppLnkSearch *applnkSearch;
- DocLnkSearch *doclnkSearch;
-
+ QList<SearchGroup> searches;
+ QHButtonGroup *buttonGroupActions;
+ uint _buttonCount;
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()
}
-
-void ResultItem::showItem()
-{
- QMessageBox::warning(0,"Not implemented","show is not yet implemented for this");
-}
-
-
-void ResultItem::editItem()
-{
- QMessageBox::warning(0,"Not implemented","edit is not yet implemented for this");
-}
-
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 @@
+#include <qintdict.h>
+
#include "olistviewitem.h"
@@ -28,4 +30,4 @@ public:
virtual int rtti() { return Result;}
- virtual void showItem();
- virtual void editItem();
+ virtual void action( int ) = 0;
+ virtual QIntDict<QString> actions() = 0;
};
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 @@
#include "searchgroup.h"
+
+#include <qregexp.h>
+
#include "olistviewitem.h"
@@ -19,2 +22,3 @@ SearchGroup::SearchGroup(QListView* parent, QString name)
_name = name;
+ loaded = false;
expanded = false;
@@ -30,2 +34,15 @@ void SearchGroup::expand()
{
+ clearList();
+ if (_search.isEmpty()) return;
+ OListViewItem *dummy = new OListViewItem( this, "searching...");
+ setOpen( expanded );
+ if (!loaded) load();
+ int res_count = search();
+ setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
+ delete dummy;
+}
+
+
+void SearchGroup::clearList()
+{
QListViewItem *item = firstChild();
@@ -34,6 +51,5 @@ void SearchGroup::expand()
while ( item != 0 ) {
- toDel = item;
- item = item->nextSibling();
- //takeItem(toDel);
- delete toDel;
+ toDel = item;
+ item = item->nextSibling();
+ 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 @@
-#include <qregexp.h>
+class QRegExp;
@@ -34,7 +34,14 @@ public:
+
+
protected:
QRegExp _search;
+ virtual void load() = 0;
+ virtual int search() = 0;
+ virtual void insertItem( void* ) = 0;
private:
+ void clearList();
QString _name;
bool expanded;
+ bool loaded;
};
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
@@ -4,3 +4,3 @@
//
-// Description:
+// Description:
//
@@ -24,3 +24,2 @@ TodoItem::TodoItem(OListViewItem* parent, OTodo *todo)
-
TodoItem::~TodoItem()
@@ -30,8 +29,2 @@ TodoItem::~TodoItem()
-
-void TodoItem::expand()
-{
- ResultItem::expand();
-}
-
QString TodoItem::toRichText()
@@ -41,14 +34,19 @@ QString TodoItem::toRichText()
-void TodoItem::showItem()
+void TodoItem::action( int act )
{
-// QCopEnvelope e("QPE/Todolist", "show(int)");
- QCopEnvelope e("QPE/Application/todolist", "show(int)");
- e << _todo->uid();
+ if (act == 0){
+ QCopEnvelope e("QPE/Application/todolist", "show(int)");
+ e << _todo->uid();
+ }else if (act == 1){
+ QCopEnvelope e("QPE/Application/todolist", "edit(int)");
+ e << _todo->uid();
+ }
}
-void TodoItem::editItem()
+QIntDict<QString> TodoItem::actions()
{
-// QCopEnvelope e("QPE/Todolist", "edit(int)");
- QCopEnvelope e("QPE/Application/todolist", "edit(int)");
- e << _todo->uid();
+ QIntDict<QString> result;
+ result.insert( 0, new QString( QObject::tr("show") ) );
+ result.insert( 1, new QString( QObject::tr("edit") ) );
+ return result;
}
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
@@ -4,3 +4,3 @@
//
-// Description:
+// Description:
//
@@ -27,6 +27,5 @@ public:
- virtual void expand();
virtual QString toRichText();
- virtual void showItem();
- virtual void editItem();
+ virtual void action( int );
+ virtual QIntDict<QString> actions();
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,20 +32,19 @@ TodoSearch::~TodoSearch()
-void TodoSearch::expand()
+void TodoSearch::load()
{
- SearchGroup::expand();
- if (_search.isEmpty()) return;
-
- if (!_todos){
_todos = new OTodoAccess();
_todos->load();
- }
+}
+int TodoSearch::search()
+{
ORecordList<OTodo> results = _todos->matchRegexp(_search);
- setText(0, text(0) + " (" + QString::number( results.count() ) + ")");
- for (uint i = 0; i < results.count(); i++) {
+ for (uint i = 0; i < results.count(); i++)
new TodoItem( this, new OTodo( results[i] ));
- }
-
+ return results.count();
}
+void TodoSearch::insertItem( void* )
+{
+}
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
@@ -22,3 +22,3 @@ class OTodoAccess;
*/
-class TodoSearch : public SearchGroup
+class TodoSearch : public SearchGroup
{
@@ -29,3 +29,7 @@ public:
- virtual void expand();
+protected:
+ virtual void load();
+ virtual int search();
+ virtual void insertItem( void* );
+
private: