summaryrefslogtreecommitdiff
authortille <tille>2003-05-11 19:19:30 (UTC)
committer tille <tille>2003-05-11 19:19:30 (UTC)
commit43c18630840a98aed8deb96b454957c40f0a4344 (patch) (side-by-side diff)
tree60e5b68d1d172c77560d5af7bea83e81be7144a6
parent38dc2fd6258f11ba0507c7bd8f8dfd5b39bc0df5 (diff)
downloadopie-43c18630840a98aed8deb96b454957c40f0a4344.zip
opie-43c18630840a98aed8deb96b454957c40f0a4344.tar.gz
opie-43c18630840a98aed8deb96b454957c40f0a4344.tar.bz2
improved applnk and doclnk searching
clean up: - mainwindow: handling of searchgroups - searchgroups: introduced load, search and insertItem functions - flexible actions handling - doclnksearch inherits applnksearch
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/osearch/adresssearch.cpp15
-rw-r--r--core/pim/osearch/adresssearch.h6
-rw-r--r--core/pim/osearch/applnkitem.cpp26
-rw-r--r--core/pim/osearch/applnkitem.h4
-rw-r--r--core/pim/osearch/applnksearch.cpp25
-rw-r--r--core/pim/osearch/applnksearch.h11
-rw-r--r--core/pim/osearch/contactitem.cpp25
-rw-r--r--core/pim/osearch/contactitem.h5
-rw-r--r--core/pim/osearch/datebooksearch.cpp18
-rw-r--r--core/pim/osearch/datebooksearch.h6
-rw-r--r--core/pim/osearch/doclnkitem.cpp48
-rw-r--r--core/pim/osearch/doclnkitem.h4
-rw-r--r--core/pim/osearch/doclnksearch.cpp24
-rw-r--r--core/pim/osearch/doclnksearch.h14
-rw-r--r--core/pim/osearch/eventitem.cpp22
-rw-r--r--core/pim/osearch/eventitem.h4
-rw-r--r--core/pim/osearch/mainwindow.cpp92
-rw-r--r--core/pim/osearch/mainwindow.h25
-rw-r--r--core/pim/osearch/resultitem.cpp12
-rw-r--r--core/pim/osearch/resultitem.h6
-rw-r--r--core/pim/osearch/searchgroup.cpp24
-rw-r--r--core/pim/osearch/searchgroup.h9
-rw-r--r--core/pim/osearch/todoitem.cpp30
-rw-r--r--core/pim/osearch/todoitem.h7
-rw-r--r--core/pim/osearch/todosearch.cpp19
-rw-r--r--core/pim/osearch/todosearch.h8
26 files changed, 279 insertions, 210 deletions
diff --git a/core/pim/osearch/adresssearch.cpp b/core/pim/osearch/adresssearch.cpp
index 0ee8eba..69ad9ef 100644
--- a/core/pim/osearch/adresssearch.cpp
+++ b/core/pim/osearch/adresssearch.cpp
@@ -9,37 +9,42 @@
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "adresssearch.h"
#include <opie/ocontactaccess.h>
#include <qstring.h>
#include "contactitem.h"
//#include <qdir.h>
AdressSearch::AdressSearch(QListView* parent, QString name):
SearchGroup(parent, name)
{
_contacts = 0;
}
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
@@ -5,34 +5,34 @@
// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef ADRESSSEARCH_H
#define ADRESSSEARCH_H
#include "searchgroup.h"
class OContactAccess;
/**
@author Patrick S. Vogt
*/
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
@@ -1,54 +1,50 @@
//
//
// C++ Implementation: $MODULE$
//
-// Description:
+// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "applnkitem.h"
#include <qpe/applnk.h>
AppLnkItem::AppLnkItem(OListViewItem* parent, AppLnk *app)
: ResultItem(parent)
{
_app = app;
setText(0, _app->name() );
}
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
@@ -6,32 +6,32 @@
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef APPLNKITEM_H
#define APPLNKITEM_H
#include "resultitem.h"
class AppLnk;
/**
@author Patrick S. Vogt
*/
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
@@ -1,46 +1,55 @@
//
//
// C++ Implementation: $MODULE$
//
-// Description:
+// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "applnksearch.h"
#include <qpe/applnk.h>
#include <qpe/qpeapplication.h>
#include "applnkitem.h"
AppLnkSearch::AppLnkSearch(QListView* parent, QString name): SearchGroup(parent, name)
{
_apps = 0;
}
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
@@ -1,35 +1,38 @@
//
//
// C++ Interface: $MODULE$
//
-// Description:
+// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef APPLNKSEARCH_H
#define APPLNKSEARCH_H
#include "searchgroup.h"
class AppLnkSet;
/**
@author Patrick S. Vogt
*/
class AppLnkSearch : public SearchGroup
{
public:
AppLnkSearch(QListView* parent, QString name);
~AppLnkSearch();
- virtual void expand();
-private:
- AppLnkSet *_apps;
+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
@@ -1,51 +1,56 @@
//
//
// C++ Implementation: $MODULE$
//
-// Description:
+// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "contactitem.h"
#include <opie/ocontact.h>
#include <qpe/qcopenvelope_qws.h>
ContactItem::ContactItem(OListViewItem* parent, OContact *contact)
: ResultItem(parent)
{
_contact = contact;
setText(0, _contact->toShortText());
}
ContactItem::~ContactItem()
{
delete _contact;
}
QString ContactItem::toRichText()
{
return _contact->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
@@ -7,33 +7,34 @@
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef CONTACTITEM_H
#define CONTACTITEM_H
#include "resultitem.h"
class OContact;
/**
@author Patrick S. Vogt
*/
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;
};
#endif
diff --git a/core/pim/osearch/datebooksearch.cpp b/core/pim/osearch/datebooksearch.cpp
index 83b99f5..68699fa 100644
--- a/core/pim/osearch/datebooksearch.cpp
+++ b/core/pim/osearch/datebooksearch.cpp
@@ -9,38 +9,42 @@
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "datebooksearch.h"
#include "eventitem.h"
#include <opie/oevent.h>
#include <opie/odatebookaccess.h>
DatebookSearch::DatebookSearch(QListView* parent, QString name)
: SearchGroup(parent, name)
{
_dates = 0;
}
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
@@ -6,31 +6,35 @@
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef DATEBOOKSEARCH_H
#define DATEBOOKSEARCH_H
#include "searchgroup.h"
class ODateBookAccess;
/**
@author Patrick S. Vogt
*/
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
@@ -1,54 +1,70 @@
//
//
// C++ Implementation: $MODULE$
//
-// Description:
+// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// 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
@@ -6,32 +6,32 @@
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef DOCLNKITEM_H
#define DOCLNKITEM_H
#include "resultitem.h"
class DocLnk;
/**
@author Patrick S. Vogt
*/
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
@@ -1,46 +1,38 @@
//
//
// C++ Implementation: $MODULE$
//
// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "doclnksearch.h"
#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
@@ -1,35 +1,33 @@
//
//
// C++ Interface: $MODULE$
//
// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// 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
@@ -13,38 +13,42 @@
#include "eventitem.h"
#include <qdatetime.h>
#include <qpe/qcopenvelope_qws.h>
#include <opie/oevent.h>
EventItem::EventItem(OListViewItem* parent, OEvent *event)
: ResultItem(parent)
{
_event = event;
setText(0, _event->toShortText() );
}
EventItem::~EventItem()
{
}
QString EventItem::toRichText()
{
return _event->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
@@ -7,33 +7,33 @@
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef EVENTITEM_H
#define EVENTITEM_H
#include "resultitem.h"
class OEvent;
/**
@author Patrick S. Vogt
*/
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;
};
#endif
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp
index 140d7bb..a0b7b23 100644
--- a/core/pim/osearch/mainwindow.cpp
+++ b/core/pim/osearch/mainwindow.cpp
@@ -4,179 +4,201 @@
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
#include "mainwindow.h"
#include <qpe/qpemenubar.h>
#include <qpe/qpemessagebox.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/qpetoolbar.h>
#include <qpe/qpeapplication.h>
#include <qaction.h>
#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"
#include "resultitem.h"
#include "adresssearch.h"
#include "todosearch.h"
#include "datebooksearch.h"
#include "applnksearch.h"
#include "doclnksearch.h"
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 );
// QPEMenuBar *menuBar = new QPEMenuBar( toolBar );
// QPopupMenu *searchMenu = new QPopupMenu( menuBar );
// QPopupMenu *viewMenu = new QPopupMenu( menuBar );
// QPopupMenu *cfgMenu = new QPopupMenu( menuBar );
//
setToolBarsMovable( false );
// toolBar->setHorizontalStretchable( true );
// menuBar->insertItem( tr( "Search" ), searchMenu );
// menuBar->insertItem( tr( "View" ), viewMenu );
// menuBar->insertItem( tr( "Settings" ), cfgMenu );
//SEARCH
QPEToolBar *searchBar = new QPEToolBar(this);
addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
QLabel *label = new QLabel( tr("Search: "), searchBar );
// label->setBackgroundMode( PaletteForeground );
searchBar->setHorizontalStretchable( TRUE );
QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" );
searchBar->setStretchableWidget( searchEdit );
connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
this, SLOT( setSearch( const QString & ) ) );
}
MainWindow::~MainWindow()
{
}
void MainWindow::setCurrent(QListViewItem *item)
{
if (!item) return;
_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 );
}
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
@@ -1,73 +1,70 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
#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
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~MainWindow();
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
@@ -6,36 +6,24 @@
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "resultitem.h"
#include <qmessagebox.h>
#include <opie/otodo.h>
ResultItem::ResultItem(OListViewItem* parent)
: 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
@@ -1,33 +1,35 @@
//
//
// C++ Interface: $MODULE$
//
// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// 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
{
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
@@ -1,57 +1,73 @@
//
//
// C++ Implementation: $MODULE$
//
// Description:
//
//
// 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;
+ toDel = item;
+ item = item->nextSibling();
+ delete toDel;
}
expanded = true;
}
void SearchGroup::setSearch(QString s)
{
setSearch( QRegExp( s ) );
_search.setCaseSensitive(false);
}
void SearchGroup::setSearch(QRegExp re)
{
setText(0, _name+" - "+re.pattern() );
_search = re;
if (expanded) expand();
else new OListViewItem( this, "searching...");
}
diff --git a/core/pim/osearch/searchgroup.h b/core/pim/osearch/searchgroup.h
index d26ff17..ebe1193 100644
--- a/core/pim/osearch/searchgroup.h
+++ b/core/pim/osearch/searchgroup.h
@@ -1,42 +1,49 @@
//
//
// C++ Interface: $MODULE$
//
// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef SEARCHGROUP_H
#define SEARCHGROUP_H
#include "olistviewitem.h"
-#include <qregexp.h>
+class QRegExp;
/**
@author Patrick S. Vogt
*/
class SearchGroup : public OListViewItem
{
public:
SearchGroup(QListView* parent, QString name);
~SearchGroup();
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
@@ -1,54 +1,52 @@
//
//
// C++ Implementation: $MODULE$
//
-// Description:
+// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "todoitem.h"
#include <opie/otodo.h>
#include <qpe/qcopenvelope_qws.h>
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)");
- 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
@@ -1,38 +1,37 @@
//
//
// C++ Interface: $MODULE$
//
-// Description:
+// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef TODOITEM_H
#define TODOITEM_H
#include "resultitem.h"
class OTodo;
/**
@author Patrick S. Vogt
*/
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;
};
#endif
diff --git a/core/pim/osearch/todosearch.cpp b/core/pim/osearch/todosearch.cpp
index cbe356b..6a73530 100644
--- a/core/pim/osearch/todosearch.cpp
+++ b/core/pim/osearch/todosearch.cpp
@@ -9,43 +9,42 @@
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "todosearch.h"
#include <opie/otodoaccess.h>
#include <opie/otodo.h>
#include "todoitem.h"
TodoSearch::TodoSearch(QListView* parent, QString name)
: SearchGroup(parent, name)
{
_todos = 0;
}
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
@@ -1,35 +1,39 @@
//
//
// C++ Interface: $MODULE$
//
// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef TODOSEARCH_H
#define TODOSEARCH_H
#include "searchgroup.h"
class OTodoAccess;
/**
@author Patrick S. Vogt
*/
-class TodoSearch : public SearchGroup
+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