summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/osearch/adresssearch.cpp5
-rw-r--r--core/pim/osearch/applnksearch.cpp2
-rw-r--r--core/pim/osearch/datebooksearch.cpp2
-rw-r--r--core/pim/osearch/doclnksearch.cpp2
-rw-r--r--core/pim/osearch/eventitem.cpp2
-rw-r--r--core/pim/osearch/mainwindow.cpp39
-rw-r--r--core/pim/osearch/mainwindow.h20
-rw-r--r--core/pim/osearch/searchgroup.h2
-rw-r--r--core/pim/osearch/todosearch.cpp2
9 files changed, 45 insertions, 31 deletions
diff --git a/core/pim/osearch/adresssearch.cpp b/core/pim/osearch/adresssearch.cpp
index 2cd545f..f117fe6 100644
--- a/core/pim/osearch/adresssearch.cpp
+++ b/core/pim/osearch/adresssearch.cpp
@@ -1,59 +1,60 @@
//
//
// C++ Implementation: $MODULE$
//
// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "adresssearch.h"
#include <qstring.h>
#include <qiconset.h>
-#include <qwhatsthis.h>
+//#include <qwhatsthis.h>
#include <qpe/resource.h>
#include <opie/ocontactaccess.h>
#include "contactitem.h"
AdressSearch::AdressSearch(QListView* parent, QString name):
SearchGroup(parent, name)
{
_contacts = 0;
QIconSet is = Resource::loadIconSet( "addressbook/AddressBook" );
setPixmap( 0, is.pixmap( QIconSet::Small, true ) );
+// QWhatsThis::add( this, QObject::tr("Search the addressbook") );
/* QPixmap pix = Resource::loadPixmap( "addressbook/AddressBook" );
QImage img = pix.convertToImage();
img.smoothScale( 14, 14 );
pix.convertFromImage( img );
setPixmap( 0, pix );*/
}
AdressSearch::~AdressSearch()
{
delete _contacts;
}
void AdressSearch::load()
{
_contacts = new OContactAccess("osearch");
}
int AdressSearch::search()
{
ORecordList<OContact> results = _contacts->matchRegexp(_search);
for (uint i = 0; i < results.count(); i++) {
- new ContactItem( this, new OContact( results[i] ));
+ (void)new ContactItem( this, new OContact( results[i] ));
}
return results.count();
}
void AdressSearch::insertItem( void* )
{
}
diff --git a/core/pim/osearch/applnksearch.cpp b/core/pim/osearch/applnksearch.cpp
index 403c719..b15275a 100644
--- a/core/pim/osearch/applnksearch.cpp
+++ b/core/pim/osearch/applnksearch.cpp
@@ -44,26 +44,26 @@ int AppLnkSearch::search()
QList<AppLnk> appList = _apps->children();
for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){
if ( (_search.match( app->name() ) != -1)
|| (_search.match(app->comment()) != -1)
|| (_search.match(app->exec()) != -1) ) {
insertItem( app );
}else
if (searchFile( app ))
insertItem( app );
qApp->processEvents( 100 );
}
return _resultCount;
}
void AppLnkSearch::insertItem( void *rec )
{
- new AppLnkItem( this, (AppLnk*)rec );
+ (void)new AppLnkItem( this, (AppLnk*)rec );
_resultCount++;
}
void AppLnkSearch::setSearch(QRegExp re)
{
setOpen( false );
SearchGroup::setSearch( re );
}
diff --git a/core/pim/osearch/datebooksearch.cpp b/core/pim/osearch/datebooksearch.cpp
index 5da7ae9..be2bf25 100644
--- a/core/pim/osearch/datebooksearch.cpp
+++ b/core/pim/osearch/datebooksearch.cpp
@@ -63,30 +63,30 @@ int DatebookSearch::search()
for (uint i = 0; i < results.count(); i++)
insertItem( new OEvent( results[i] ) );
return _resultCount;
}
void DatebookSearch::insertItem( void *rec )
{
OEvent *ev = (OEvent*)rec;
if ( !actionShowPastEvents->isOn() &&
ev->endDateTime() < QDateTime::currentDateTime() &&
!ev->recurrence().doesRecur()
) return;
if ( !actionSearchInDates->isOn() && (
ev->lastHitField() == Qtopia::StartDateTime ||
ev->lastHitField() == Qtopia::EndDateTime )
) return;
- new EventItem( this, ev );
+ (void)new EventItem( this, ev );
_resultCount++;
}
QPopupMenu* DatebookSearch::popupMenu()
{
if (!_popupMenu){
_popupMenu = new QPopupMenu( 0 );
actionShowPastEvents->addTo( _popupMenu );
actionSearchInDates->addTo( _popupMenu );
}
return _popupMenu;
}
diff --git a/core/pim/osearch/doclnksearch.cpp b/core/pim/osearch/doclnksearch.cpp
index 321d011..3428798 100644
--- a/core/pim/osearch/doclnksearch.cpp
+++ b/core/pim/osearch/doclnksearch.cpp
@@ -63,29 +63,29 @@ bool DocLnkSearch::searchFile( AppLnk *app )
QFile f(doc->file());
if ( f.open(IO_ReadOnly) ) {
QTextStream t( &f );
while ( !t.eof() )
if (_search.match( t.readLine()) != -1) {
found = true;
break;
}
}
f.close();
}
return found;
}
void DocLnkSearch::insertItem( void *rec )
{
- new DocLnkItem( this, (DocLnk*)rec );
+ (void)new DocLnkItem( this, (DocLnk*)rec );
_resultCount++;
}
QPopupMenu* DocLnkSearch::popupMenu()
{
if (!_popupMenu){
_popupMenu = new QPopupMenu( 0 );
actionSearchInFiles->addTo( _popupMenu );
}
return _popupMenu;
}
diff --git a/core/pim/osearch/eventitem.cpp b/core/pim/osearch/eventitem.cpp
index 24ce8e8..3228093 100644
--- a/core/pim/osearch/eventitem.cpp
+++ b/core/pim/osearch/eventitem.cpp
@@ -3,32 +3,33 @@
// C++ Implementation: $MODULE$
//
// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "eventitem.h"
#include <qdatetime.h>
#include <qpixmap.h>
#include <qpe/resource.h>
#include <qpe/qcopenvelope_qws.h>
+//#include <qwhatsthis.h>
#include <opie/oevent.h>
EventItem::EventItem(OListViewItem* parent, OEvent *event)
: ResultItem(parent)
{
_event = event;
setText(0, _event->toShortText() );
setIcon();
}
EventItem::~EventItem()
{
}
@@ -49,32 +50,33 @@ void EventItem::action( int act )
}
QIntDict<QString> EventItem::actions()
{
QIntDict<QString> result;
result.insert( 0, new QString( QObject::tr("show") ) );
result.insert( 1, new QString( QObject::tr("edit") ) );
return result;
}
void EventItem::setIcon()
{
QPixmap icon;
switch ( _event->lastHitField() ) {
case -1:
icon = Resource::loadPixmap( "reset" );
+// QWhatsThis::add( icon, QObject::tr("Enter your search terms here") );
break;
case Qtopia::DatebookDescription:
icon = Resource::loadPixmap( "osearch/summary" );
break;
case Qtopia::Notes:
icon = Resource::loadPixmap( "txt" );
break;
case Qtopia::Location:
icon = Resource::loadPixmap( "home" );
break;
case Qtopia::StartDateTime:
case Qtopia::EndDateTime:
icon = Resource::loadPixmap( "osearch/clock" );
break;
default:
icon = Resource::loadPixmap( "DocsIcon" );
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp
index c6934db..aa52061 100644
--- a/core/pim/osearch/mainwindow.cpp
+++ b/core/pim/osearch/mainwindow.cpp
@@ -6,36 +6,38 @@
* (at your option) any later version. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
#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 <qhbox.h>
#include <qpushbutton.h>
#include <qintdict.h>
#include <qlayout.h>
#include <qlineedit.h>
+#include <qsignalmapper.h>
#include <qtextbrowser.h>
#include <qregexp.h>
#include <qwhatsthis.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 <qpe/config.h>
#include <qpe/global.h>
#include <opie/owait.h>
#include "olistview.h"
#include "olistviewitem.h"
#include "resultitem.h"
@@ -58,58 +60,60 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
mainLayout = new QVBoxLayout( mainFrame );
mainLayout->setSpacing( 0 );
mainLayout->setMargin( 0 );
resultsList = new OListView( mainFrame );
resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
mainLayout->addWidget( resultsList );
detailsFrame = new QFrame( mainFrame, "detailsFrame" );
QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame );
richEdit = new QTextView( detailsFrame );
QWhatsThis::add( richEdit, tr("The details of the current result") );
richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
detailsLayout->addWidget( richEdit );
- buttonGroupActions = new QHButtonGroup( this );
- buttonGroupActions->hide();
- _buttonCount = 0;
+ buttonBox = new QHBox( mainFrame, "Button Box" );
- buttonLayout = new QHBoxLayout( detailsFrame );
- detailsLayout->addLayout( buttonLayout );
+ _buttonCount = 0;
mainLayout->addWidget( detailsFrame );
+ mainLayout->addWidget( buttonBox );
detailsFrame->hide();
+ buttonBox->hide();
searches.append( new AppLnkSearch( resultsList, tr("applications") ) );
searches.append( new DocLnkSearch( resultsList, tr("documents") ) );
searches.append( new TodoSearch( resultsList, tr("todo") ) );
searches.append( new DatebookSearch( resultsList, tr("datebook") ) );
searches.append( new AdressSearch( resultsList, tr("adressbook") ) );
setCentralWidget( mainFrame );
popupTimer = new QTimer();
searchTimer = new QTimer();
connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup()));
connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged()));
connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*)));
connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*)));
- connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) );
+
+ signalMapper = new QSignalMapper( this );
+
+ connect(signalMapper, SIGNAL(mapped(int)), SLOT( slotAction(int) ) );
makeMenu();
Config cfg( "osearch", Config::User );
cfg.setGroup( "search_settings" );
actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) );
actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) );
// actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) );
}
void MainWindow::makeMenu()
{
QPEToolBar *toolBar = new QPEToolBar( this );
QPEToolBar *searchBar = new QPEToolBar(this);
QPEMenuBar *menuBar = new QPEMenuBar( toolBar );
QPopupMenu *searchMenu = new QPopupMenu( menuBar );
@@ -170,48 +174,55 @@ MainWindow::~MainWindow()
cfg.writeEntry( "wildcards", actionWildcards->isOn() );
//cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() );
}
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 );
+ button = buttonMap[i];
if (!button) {
- button = new QPushButton( detailsFrame );
- buttonLayout->addWidget( button, 0 );
- buttonGroupActions->insert( button, i);
+ qWarning(" no button for %s", (*acts[i]).latin1() );
+ button = new QPushButton( buttonBox );
+ buttonMap.insert( i, button );
+ signalMapper->setMapping(button, i );
+ connect(button, SIGNAL(clicked() ), signalMapper, SLOT(map() ) );
}
button->setText( *acts[i] );
button->show();
}
for (uint i = acts.count(); i < _buttonCount; i++){
- button = buttonGroupActions->find( i );
+ button = buttonMap[i];
if (button) button->hide();
}
_buttonCount = acts.count();
detailsFrame->show();
- }else detailsFrame->hide();
+ buttonBox->show();
+
+ }else {
+ detailsFrame->hide();
+ buttonBox->hide();
+ }
popupTimer->start( 300, true );
}
void MainWindow::stopTimer(QListViewItem*)
{
popupTimer->stop();
}
void MainWindow::showPopup()
{
popupTimer->stop();
if (!_currentItem) return;
QPopupMenu *pop = _currentItem->popupMenu();
if (pop) pop->popup( QCursor::pos() );
}
@@ -240,27 +251,27 @@ void MainWindow::searchStringChanged()
s->setSearch( re );
}
void MainWindow::searchAll()
{
#ifdef NEW_OWAIT
OWait("searching...");
#endif
for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
s->doSearch();
//resultsList->repaint();
}
}
void MainWindow::slotAction( int act )
{
- if (_currentItem->rtti() == OListViewItem::Result){
+ if ( _currentItem && _currentItem->rtti() == OListViewItem::Result){
ResultItem *res = (ResultItem*)_currentItem;
// ResultItem *res = dynamic_cast<ResultItem*>(item);
res->action(act);
}
}
-void MainWindow::optionChanged(int i)
+void MainWindow::optionChanged(int )
{
searchStringChanged();
}
diff --git a/core/pim/osearch/mainwindow.h b/core/pim/osearch/mainwindow.h
index cba11c5..1f5c4bb 100644
--- a/core/pim/osearch/mainwindow.h
+++ b/core/pim/osearch/mainwindow.h
@@ -1,78 +1,78 @@
/***************************************************************************
* *
* 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>
+#include <qmap.h>
+class QAction;
class QPEToolBar;
+class QHBox;
class QVBoxLayout;
-class QHBoxLayout;
class QTextView;
class QFrame;
-class QListViewItem;
class OListView;
class OListViewItem;
-class QHButtonGroup;
-
+class QListViewItem;
+class QPopupMenu;
+class QSignalMapper;
+class QTimer;
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 setSearch( const QString& );
void searchAll();
protected slots:
void slotAction(int);
void showPopup();
void stopTimer( QListViewItem* );
void searchStringChanged();
void optionChanged(int);
private:
+ QHBox *buttonBox;
+ QMap<int, QButton*> buttonMap;
+ QSignalMapper* signalMapper;
OListView *resultsList;
QTextView *richEdit;
OListViewItem *_currentItem;
QVBoxLayout *mainLayout;
- QHBoxLayout *buttonLayout;
QFrame *detailsFrame;
QTimer *popupTimer;
QTimer *searchTimer;
QString _searchString;
QList<SearchGroup> searches;
- QHButtonGroup *buttonGroupActions;
QAction *SearchAllAction;
QAction *actionCaseSensitiv;
QAction *actionWildcards;
//QAction *actionWholeWordsOnly;
uint _buttonCount;
void makeMenu();
};
#endif
diff --git a/core/pim/osearch/searchgroup.h b/core/pim/osearch/searchgroup.h
index ad37d4e..de74efb 100644
--- a/core/pim/osearch/searchgroup.h
+++ b/core/pim/osearch/searchgroup.h
@@ -27,23 +27,23 @@ public:
SearchGroup(QListView* parent, QString name);
~SearchGroup();
virtual void expand();
virtual void doSearch();
virtual void setSearch(QRegExp);
virtual int rtti() { return Searchgroup;}
protected:
virtual void load() = 0;
virtual int search() = 0;
virtual void insertItem( void* ) = 0;
QRegExp _search;
QRegExp _lastSearch;
QString _name;
- bool loaded;
+ bool loaded : 1;
int _resultCount;
private:
int realSearch();
};
#endif
diff --git a/core/pim/osearch/todosearch.cpp b/core/pim/osearch/todosearch.cpp
index 08bbe93..5c1d7a5 100644
--- a/core/pim/osearch/todosearch.cpp
+++ b/core/pim/osearch/todosearch.cpp
@@ -53,28 +53,28 @@ void TodoSearch::load()
_todos->load();
}
int TodoSearch::search()
{
ORecordList<OTodo> results = _todos->matchRegexp(_search);
for (uint i = 0; i < results.count(); i++)
insertItem( new OTodo( results[i] ));
return _resultCount;
}
void TodoSearch::insertItem( void *rec )
{
OTodo *todo = (OTodo*)rec;
if (!actionShowCompleted->isOn() &&
todo->isCompleted() ) return;
- new TodoItem( this, todo );
+ (void)new TodoItem( this, todo );
_resultCount++;
}
QPopupMenu* TodoSearch::popupMenu()
{
if (!_popupMenu){
_popupMenu = new QPopupMenu( 0 );
actionShowCompleted->addTo( _popupMenu );
}
return _popupMenu;
}