summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show 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.cpp24
-rw-r--r--core/pim/osearch/applnkitem.h4
-rw-r--r--core/pim/osearch/applnksearch.cpp23
-rw-r--r--core/pim/osearch/applnksearch.h7
-rw-r--r--core/pim/osearch/contactitem.cpp21
-rw-r--r--core/pim/osearch/contactitem.h5
-rw-r--r--core/pim/osearch/datebooksearch.cpp16
-rw-r--r--core/pim/osearch/datebooksearch.h6
-rw-r--r--core/pim/osearch/doclnkitem.cpp46
-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.cpp18
-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.cpp18
-rw-r--r--core/pim/osearch/searchgroup.h9
-rw-r--r--core/pim/osearch/todoitem.cpp24
-rw-r--r--core/pim/osearch/todoitem.h5
-rw-r--r--core/pim/osearch/todosearch.cpp17
-rw-r--r--core/pim/osearch/todosearch.h6
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
@@ -27,19 +27,24 @@ AdressSearch::AdressSearch(QListView* parent, QString name):
AdressSearch::~AdressSearch()
{
delete _contacts;
}
+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++) {
new ContactItem( this, new OContact( results[i] ));
}
+ 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
@@ -23,16 +23,16 @@ class OContactAccess;
class AdressSearch : public SearchGroup
{
public:
AdressSearch(QListView* parent, QString name);
~AdressSearch();
- virtual void expand();
-
protected:
-
+ virtual void load();
+ virtual int search();
+ virtual void insertItem( void* );
private:
OContactAccess *_contacts;
};
#endif
diff --git a/core/pim/osearch/applnkitem.cpp b/core/pim/osearch/applnkitem.cpp
index f45ed68..2152da4 100644
--- a/core/pim/osearch/applnkitem.cpp
+++ b/core/pim/osearch/applnkitem.cpp
@@ -27,28 +27,24 @@ AppLnkItem::~AppLnkItem()
}
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;
}
-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
@@ -24,14 +24,14 @@ class AppLnkItem : public ResultItem
{
public:
AppLnkItem(OListViewItem* parent, AppLnk *app);
~AppLnkItem();
virtual QString toRichText();
- virtual void editItem();
- virtual void showItem();
+ virtual void action( int );
+ virtual QIntDict<QString> actions();
private:
AppLnk *_app;
};
#endif
diff --git a/core/pim/osearch/applnksearch.cpp b/core/pim/osearch/applnksearch.cpp
index 7872ae3..d5b2930 100644
--- a/core/pim/osearch/applnksearch.cpp
+++ b/core/pim/osearch/applnksearch.cpp
@@ -26,21 +26,30 @@ AppLnkSearch::AppLnkSearch(QListView* parent, QString name): SearchGroup(parent,
AppLnkSearch::~AppLnkSearch()
{
delete _apps;
}
-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
@@ -24,12 +24,15 @@ class AppLnkSearch : public SearchGroup
{
public:
AppLnkSearch(QListView* parent, QString name);
~AppLnkSearch();
- virtual void expand();
-private:
+protected:
+ virtual void load();
+ virtual int search();
+ virtual void insertItem( void* );
+
AppLnkSet *_apps;
};
#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
@@ -31,21 +31,26 @@ ContactItem::~ContactItem()
QString ContactItem::toRichText()
{
return _contact->toRichText();
}
-
-void ContactItem::editItem()
+void ContactItem::action( int act )
{
+if (act == 0){
+ QCopEnvelope e("QPE/Application/addressbook", "show(int)");
+ e << _contact->uid();
+}else if(act == 1){
QCopEnvelope e("QPE/Application/addressbook", "edit(int)");
-// QCopEnvelope e("QPE/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
@@ -25,14 +25,15 @@ class ContactItem : public ResultItem
public:
ContactItem(OListViewItem* parent, OContact *contact);
~ContactItem();
virtual QString toRichText();
- virtual void showItem();
- virtual void editItem();
+ virtual void action( int );
+ virtual QIntDict<QString> actions();
+
private:
OContact *_contact;
};
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
@@ -27,20 +27,24 @@ DatebookSearch::DatebookSearch(QListView* parent, QString name)
DatebookSearch::~DatebookSearch()
{
delete _dates;
}
-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
@@ -24,13 +24,17 @@ class DatebookSearch : public SearchGroup
{
public:
DatebookSearch(QListView* parent, QString name);
~DatebookSearch();
- virtual void expand();
+protected:
+ virtual void load();
+ virtual int search();
+ virtual void insertItem( void* );
+
private:
ODateBookAccess *_dates;
};
#endif
diff --git a/core/pim/osearch/doclnkitem.cpp b/core/pim/osearch/doclnkitem.cpp
index fd19727..75dee58 100644
--- a/core/pim/osearch/doclnkitem.cpp
+++ b/core/pim/osearch/doclnkitem.cpp
@@ -10,45 +10,61 @@
// Copyright: See COPYING file that comes with this distribution
//
//
#include "doclnkitem.h"
#include <qpe/applnk.h>
+#include <qfile.h>
+#include <qtextstream.h>
DocLnkItem::DocLnkItem(OListViewItem* parent, DocLnk *app)
: ResultItem(parent)
{
_doc = app;
setText(0, _doc->name() );
}
-
DocLnkItem::~DocLnkItem()
{
}
-
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;
}
-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
@@ -24,14 +24,14 @@ class DocLnkItem : public ResultItem
{
public:
DocLnkItem(OListViewItem* parent, DocLnk *app);
~DocLnkItem();
virtual QString toRichText();
- virtual void editItem();
- virtual void showItem();
+ virtual void action( int );
+ virtual QIntDict<QString> actions();
private:
DocLnk *_doc;
};
#endif
diff --git a/core/pim/osearch/doclnksearch.cpp b/core/pim/osearch/doclnksearch.cpp
index e99a385..f2a60e9 100644
--- a/core/pim/osearch/doclnksearch.cpp
+++ b/core/pim/osearch/doclnksearch.cpp
@@ -14,33 +14,25 @@
#include <qpe/applnk.h>
#include <qpe/qpeapplication.h>
#include "doclnkitem.h"
-DocLnkSearch::DocLnkSearch(QListView* parent, QString name): SearchGroup(parent, name)
+DocLnkSearch::DocLnkSearch(QListView* parent, QString name)
+: AppLnkSearch(parent, name)
{
- _docs = 0;
}
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
@@ -10,26 +10,24 @@
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef DOCLNKSEARCH_H
#define DOCLNKSEARCH_H
-#include "searchgroup.h"
-
-class DocLnkSet;
+#include "applnksearch.h"
/**
@author Patrick S. Vogt
*/
-class DocLnkSearch : public SearchGroup
+class DocLnkSearch : public AppLnkSearch
{
public:
DocLnkSearch(QListView* parent, QString name);
-
~DocLnkSearch();
- virtual void expand();
-private:
- DocLnkSet *_docs;
+protected:
+ virtual void load();
+ virtual void insertItem( void* );
+
};
#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
@@ -31,20 +31,24 @@ EventItem::~EventItem()
QString EventItem::toRichText()
{
return _event->toRichText();
}
-void EventItem::editItem()
+void EventItem::action( int act )
{
+ 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
@@ -25,14 +25,14 @@ class EventItem : public ResultItem
public:
EventItem(OListViewItem* parent, OEvent *event);
~EventItem();
virtual QString toRichText();
- virtual void editItem();
- virtual void showItem();
+ virtual void action( int );
+ virtual QIntDict<QString> actions();
private:
OEvent *_event;
};
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
@@ -22,13 +22,15 @@
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qtoolbutton.h>
#include <qstring.h>
#include <qlabel.h>
#include <qfile.h>
+#include <qhbuttongroup.h>
#include <qpushbutton.h>
+#include <qintdict.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qtextbrowser.h>
#include "olistview.h"
#include "olistviewitem.h"
@@ -41,60 +43,67 @@
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
QMainWindow( parent, name, f ), _currentItem(0)
{
setCaption( tr("OSearch") );
- setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
+ setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
QFrame *mainFrame = new QFrame( this, "mainFrame" );
mainLayout = new QVBoxLayout( mainFrame );
mainLayout->setSpacing( 0 );
mainLayout->setMargin( 0 );
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 );
detailsFrame = new QFrame( mainFrame, "detailsFrame" );
QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame );
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") ) );
makeMenu();
setCentralWidget( mainFrame );
popupTimer = new QTimer();
connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup()));
connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*)));
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() ) );
}
void MainWindow::makeMenu()
{
// QPEToolBar *toolBar = new QPEToolBar( this );
@@ -133,12 +142,36 @@ void MainWindow::setCurrent(QListViewItem *item)
_currentItem = (OListViewItem*)item;
// _currentItem = dynamic_cast<OListViewItem*>(item);
if (_currentItem->rtti() == OListViewItem::Result){
ResultItem *res = (ResultItem*)item;
// ResultItem *res = dynamic_cast<ResultItem*>(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();
}else detailsFrame->hide();
//_currentItem = (OListViewItem*)item;
popupTimer->start( 300 );
}
@@ -147,36 +180,25 @@ void MainWindow::stopTimer(QListViewItem*)
popupTimer->stop();
}
void MainWindow::showPopup()
{
qDebug("showPopup");
- if (!_item) return;
+ if (!_currentItem) return;
}
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 );
}
-void MainWindow::showItem()
+void MainWindow::slotAction( int act)
{
if (_currentItem->rtti() == OListViewItem::Result){
ResultItem *res = (ResultItem*)_currentItem;
// ResultItem *res = dynamic_cast<ResultItem*>(item);
- res->showItem();
+ res->action(act);
}
}
-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
@@ -12,27 +12,27 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
#include <qdialog.h>
#include <qaction.h>
+#include <qlist.h>
#include <qtimer.h>
#include <qpopupmenu.h>
class QPEToolBar;
class QVBoxLayout;
+class QHBoxLayout;
class QTextView;
class QFrame;
class QListViewItem;
class OListView;
class OListViewItem;
-class AdressSearch;
-class TodoSearch;
-class DatebookSearch;
-class AppLnkSearch;
-class DocLnkSearch;
+class QHButtonGroup;
+
+class SearchGroup;
class MainWindow : public QMainWindow
{
Q_OBJECT
@@ -45,29 +45,26 @@ public slots:
void setCurrent(QListViewItem*);
void showPopup();
void stopTimer( QListViewItem* );
void setSearch( const QString& );
protected slots:
- void showItem();
- void editItem();
+ void slotAction(int);
private:
OListView *resultsList;
QTextView *richEdit;
OListViewItem *_currentItem;
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();
};
#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
@@ -24,18 +24,6 @@ ResultItem::ResultItem(OListViewItem* parent)
}
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
@@ -10,12 +10,14 @@
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef RESULTITEM_H
#define RESULTITEM_H
+#include <qintdict.h>
+
#include "olistviewitem.h"
/**
@author Patrick S. Vogt
*/
class ResultItem : public OListViewItem
@@ -23,11 +25,11 @@ class ResultItem : public OListViewItem
public:
ResultItem(OListViewItem* parent);
~ResultItem();
virtual QString toRichText() {return "no text";};
virtual int rtti() { return Result;}
- virtual void showItem();
- virtual void editItem();
+ virtual void action( int ) = 0;
+ virtual QIntDict<QString> actions() = 0;
};
#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
@@ -8,36 +8,52 @@
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "searchgroup.h"
+
+#include <qregexp.h>
+
#include "olistviewitem.h"
SearchGroup::SearchGroup(QListView* parent, QString name)
: OListViewItem(parent, name)
{
_name = name;
+ loaded = false;
expanded = false;
}
SearchGroup::~SearchGroup()
{
}
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();
QListViewItem *toDel;
while ( item != 0 ) {
toDel = item;
item = item->nextSibling();
- //takeItem(toDel);
delete toDel;
}
expanded = true;
}
void SearchGroup::setSearch(QString s)
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
@@ -12,13 +12,13 @@
//
#ifndef SEARCHGROUP_H
#define SEARCHGROUP_H
#include "olistviewitem.h"
-#include <qregexp.h>
+class QRegExp;
/**
@author Patrick S. Vogt
*/
class SearchGroup : public OListViewItem
{
@@ -29,14 +29,21 @@ public:
virtual void expand();
virtual void setSearch(QString);
virtual void setSearch(QRegExp);
virtual int rtti() { return Searchgroup;}
+
+
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;
};
#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
@@ -19,36 +19,34 @@ TodoItem::TodoItem(OListViewItem* parent, OTodo *todo)
: ResultItem(parent)
{
_todo = todo;
setText( 0, todo->toShortText() );
}
-
TodoItem::~TodoItem()
{
delete _todo;
}
-
-void TodoItem::expand()
-{
- ResultItem::expand();
-}
-
QString TodoItem::toRichText()
{
return _todo->toRichText();
}
-void TodoItem::showItem()
+void TodoItem::action( int act )
{
-// QCopEnvelope e("QPE/Todolist", "show(int)");
+ 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
@@ -22,16 +22,15 @@ class OTodo;
class TodoItem : public ResultItem
{
public:
TodoItem(OListViewItem* parent, OTodo *todo);
~TodoItem();
- virtual void expand();
virtual QString toRichText();
- virtual void showItem();
- virtual void editItem();
+ virtual void action( int );
+ virtual QIntDict<QString> actions();
private:
OTodo *_todo;
};
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
@@ -27,25 +27,24 @@ TodoSearch::TodoSearch(QListView* parent, QString name)
TodoSearch::~TodoSearch()
{
delete _todos;
}
-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
@@ -24,12 +24,16 @@ class TodoSearch : public SearchGroup
{
public:
TodoSearch(QListView* parent, QString name);
~TodoSearch();
- virtual void expand();
+protected:
+ virtual void load();
+ virtual int search();
+ virtual void insertItem( void* );
+
private:
OTodoAccess *_todos;
};
#endif