summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/osearch/applnksearch.cpp4
-rw-r--r--core/pim/osearch/applnksearch.h6
-rw-r--r--core/pim/osearch/doclnksearch.cpp56
-rw-r--r--core/pim/osearch/doclnksearch.h13
-rw-r--r--core/pim/osearch/mainwindow.cpp10
-rw-r--r--core/pim/osearch/searchgroup.cpp15
-rw-r--r--core/pim/osearch/searchgroup.h3
7 files changed, 87 insertions, 20 deletions
diff --git a/core/pim/osearch/applnksearch.cpp b/core/pim/osearch/applnksearch.cpp
index 5fa36bb..403c719 100644
--- a/core/pim/osearch/applnksearch.cpp
+++ b/core/pim/osearch/applnksearch.cpp
@@ -1,67 +1,69 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "applnksearch.h" 13#include "applnksearch.h"
14 14
15#include <qpe/applnk.h> 15#include <qpe/applnk.h>
16#include <qpe/qpeapplication.h> 16#include <qpe/qpeapplication.h>
17#include <qiconset.h> 17#include <qiconset.h>
18#include <qpe/resource.h> 18#include <qpe/resource.h>
19 19
20#include "applnkitem.h" 20#include "applnkitem.h"
21 21
22AppLnkSearch::AppLnkSearch(QListView* parent, QString name): SearchGroup(parent, name) 22AppLnkSearch::AppLnkSearch(QListView* parent, QString name): SearchGroup(parent, name)
23{ 23{
24 _apps = 0; 24 _apps = 0;
25 QIconSet is = Resource::loadIconSet( "osearch/applications" ); 25 QIconSet is = Resource::loadIconSet( "osearch/applications" );
26 //QIconSet is = Resource::loadIconSet( "AppsIcon" ); 26 //QIconSet is = Resource::loadIconSet( "AppsIcon" );
27 setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); 27 setPixmap( 0, is.pixmap( QIconSet::Small, true ) );
28} 28}
29 29
30 30
31AppLnkSearch::~AppLnkSearch() 31AppLnkSearch::~AppLnkSearch()
32{ 32{
33 delete _apps; 33 delete _apps;
34} 34}
35 35
36 36
37void AppLnkSearch::load() 37void AppLnkSearch::load()
38{ 38{
39 _apps = new AppLnkSet(QPEApplication::qpeDir()); 39 _apps = new AppLnkSet(QPEApplication::qpeDir());
40} 40}
41 41
42int AppLnkSearch::search() 42int AppLnkSearch::search()
43{ 43{
44 QList<AppLnk> appList = _apps->children(); 44 QList<AppLnk> appList = _apps->children();
45 for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){ 45 for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){
46 if ( (_search.match( app->name() ) != -1) 46 if ( (_search.match( app->name() ) != -1)
47 || (_search.match(app->comment()) != -1) 47 || (_search.match(app->comment()) != -1)
48 || (_search.match(app->exec()) != -1) ) { 48 || (_search.match(app->exec()) != -1) ) {
49 insertItem( app ); 49 insertItem( app );
50 } 50 }else
51 if (searchFile( app ))
52 insertItem( app );
51 qApp->processEvents( 100 ); 53 qApp->processEvents( 100 );
52 } 54 }
53 return _resultCount; 55 return _resultCount;
54} 56}
55 57
56void AppLnkSearch::insertItem( void *rec ) 58void AppLnkSearch::insertItem( void *rec )
57{ 59{
58 new AppLnkItem( this, (AppLnk*)rec ); 60 new AppLnkItem( this, (AppLnk*)rec );
59 _resultCount++; 61 _resultCount++;
60} 62}
61 63
62void AppLnkSearch::setSearch(QRegExp re) 64void AppLnkSearch::setSearch(QRegExp re)
63{ 65{
64 setOpen( false ); 66 setOpen( false );
65 SearchGroup::setSearch( re ); 67 SearchGroup::setSearch( re );
66} 68}
67 69
diff --git a/core/pim/osearch/applnksearch.h b/core/pim/osearch/applnksearch.h
index 6bb7486..853064d 100644
--- a/core/pim/osearch/applnksearch.h
+++ b/core/pim/osearch/applnksearch.h
@@ -1,38 +1,40 @@
1// 1//
2// 2//
3// C++ Interface: $MODULE$ 3// C++ Interface: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#ifndef APPLNKSEARCH_H 13#ifndef APPLNKSEARCH_H
14#define APPLNKSEARCH_H 14#define APPLNKSEARCH_H
15 15
16#include "searchgroup.h" 16#include "searchgroup.h"
17 17
18class AppLnkSet; 18class AppLnkSet;
19class AppLnk;
19 20
20/** 21/**
21@author Patrick S. Vogt 22@author Patrick S. Vogt
22*/ 23*/
23class AppLnkSearch : public SearchGroup 24class AppLnkSearch : public SearchGroup
24{ 25{
25public: 26public:
26 AppLnkSearch(QListView* parent, QString name); 27 AppLnkSearch(QListView* parent, QString name);
27
28 ~AppLnkSearch(); 28 ~AppLnkSearch();
29 29
30 virtual void setSearch(QRegExp); 30 virtual void setSearch(QRegExp);
31
32protected:
31 virtual void load(); 33 virtual void load();
32 virtual int search(); 34 virtual int search();
33 virtual void insertItem( void* ); 35 virtual void insertItem( void* );
34 36 virtual bool searchFile(AppLnk*) { return false; };
35 AppLnkSet *_apps; 37 AppLnkSet *_apps;
36}; 38};
37 39
38#endif 40#endif
diff --git a/core/pim/osearch/doclnksearch.cpp b/core/pim/osearch/doclnksearch.cpp
index d97eeb8..321d011 100644
--- a/core/pim/osearch/doclnksearch.cpp
+++ b/core/pim/osearch/doclnksearch.cpp
@@ -1,43 +1,91 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "doclnksearch.h"
14 13
15#include <qpe/applnk.h> 14#include <qaction.h>
16#include <qpe/qpeapplication.h> 15#include <qfile.h>
17#include <qiconset.h> 16#include <qiconset.h>
17#include <qpopupmenu.h>
18#include <qtextstream.h>
19#include <qpe/applnk.h>
20#include <qpe/config.h>
18#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qpeapplication.h>
23#include <opie/owait.h>
19 24
20#include "doclnkitem.h" 25#include "doclnkitem.h"
26#include "doclnksearch.h"
21 27
22DocLnkSearch::DocLnkSearch(QListView* parent, QString name) 28DocLnkSearch::DocLnkSearch(QListView* parent, QString name)
23: AppLnkSearch(parent, name) 29: AppLnkSearch(parent, name), _popupMenu(0)
24{ 30{
25 QIconSet is = Resource::loadIconSet( "osearch/documents" ); 31 QIconSet is = Resource::loadIconSet( "osearch/documents" );
26 setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); 32 setPixmap( 0, is.pixmap( QIconSet::Small, true ) );
33
34 actionSearchInFiles = new QAction( QObject::tr("search content"),QString::null, 0, 0, 0, true );
35 Config cfg( "osearch", Config::User );
36 cfg.setGroup( "doclnk_settings" );
37 actionSearchInFiles->setOn( cfg.readBoolEntry( "search_content", false ) );
27} 38}
28 39
29 40
30DocLnkSearch::~DocLnkSearch() 41DocLnkSearch::~DocLnkSearch()
31{ 42{
43 Config cfg( "osearch", Config::User );
44 cfg.setGroup( "doclnk_settings" );
45 cfg.writeEntry( "search_content", actionSearchInFiles->isOn() );
32} 46}
33 47
34void DocLnkSearch::load() 48void DocLnkSearch::load()
35{ 49{
36 _apps = new DocLnkSet(QPEApplication::documentDir()); 50 _apps = new DocLnkSet(QPEApplication::documentDir());
37} 51}
38 52
53bool DocLnkSearch::searchFile( AppLnk *app )
54{
55 if (!actionSearchInFiles->isOn()) return false;
56 DocLnk *doc = (DocLnk*)app;
57 bool found = false;
58 if ( doc->type().contains( "text" ) ){
59#ifdef NEW_OWAIT
60 QString ouput = QObject::tr("searching %1").arg(doc->file());
61 OWait( output );
62#endif
63 QFile f(doc->file());
64 if ( f.open(IO_ReadOnly) ) {
65 QTextStream t( &f );
66 while ( !t.eof() )
67 if (_search.match( t.readLine()) != -1) {
68 found = true;
69 break;
70 }
71 }
72 f.close();
73 }
74 return found;
75}
76
39void DocLnkSearch::insertItem( void *rec ) 77void DocLnkSearch::insertItem( void *rec )
40{ 78{
41 new DocLnkItem( this, (DocLnk*)rec ); 79 new DocLnkItem( this, (DocLnk*)rec );
42 _resultCount++; 80 _resultCount++;
43} 81}
82
83
84QPopupMenu* DocLnkSearch::popupMenu()
85{
86 if (!_popupMenu){
87 _popupMenu = new QPopupMenu( 0 );
88 actionSearchInFiles->addTo( _popupMenu );
89 }
90 return _popupMenu;
91}
diff --git a/core/pim/osearch/doclnksearch.h b/core/pim/osearch/doclnksearch.h
index e2ac40b..81a8e62 100644
--- a/core/pim/osearch/doclnksearch.h
+++ b/core/pim/osearch/doclnksearch.h
@@ -1,33 +1,42 @@
1// 1//
2// 2//
3// C++ Interface: $MODULE$ 3// C++ Interface: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#ifndef DOCLNKSEARCH_H 13#ifndef DOCLNKSEARCH_H
14#define DOCLNKSEARCH_H 14#define DOCLNKSEARCH_H
15 15
16#include "applnksearch.h" 16#include "applnksearch.h"
17 17
18class QAction;
19class QPopupMenu;
20
18/** 21/**
19@author Patrick S. Vogt 22@author Patrick S. Vogt
20*/ 23*/
21class DocLnkSearch : public AppLnkSearch 24class DocLnkSearch : public AppLnkSearch
22{ 25{
23public: 26public:
24 DocLnkSearch(QListView* parent, QString name); 27 DocLnkSearch(QListView* parent, QString name);
25 ~DocLnkSearch(); 28 ~DocLnkSearch();
26 29
30 virtual QPopupMenu* popupMenu();
31
27protected: 32protected:
28 virtual void load(); 33 virtual void load();
34 virtual bool searchFile(AppLnk*);
29 virtual void insertItem( void* ); 35 virtual void insertItem( void* );
36private:
37 QAction *actionSearchInFiles;
38 QPopupMenu *_popupMenu;
30 39
31}; 40};
32 41
33#endif 42#endif
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp
index 89ab690..6070fdf 100644
--- a/core/pim/osearch/mainwindow.cpp
+++ b/core/pim/osearch/mainwindow.cpp
@@ -1,264 +1,270 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 10// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
11 11
12 12
13#include "mainwindow.h" 13#include "mainwindow.h"
14 14
15#include <qpe/qpemenubar.h> 15#include <qpe/qpemenubar.h>
16#include <qpe/qpemessagebox.h> 16#include <qpe/qpemessagebox.h>
17#include <qpe/resource.h> 17#include <qpe/resource.h>
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include <qpe/qpetoolbar.h> 19#include <qpe/qpetoolbar.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/config.h> 21#include <qpe/config.h>
22#include <qpe/global.h> 22#include <qpe/global.h>
23#include <opie/owait.h>
23#include <qaction.h> 24#include <qaction.h>
24#include <qmessagebox.h> 25#include <qmessagebox.h>
25#include <qpopupmenu.h> 26#include <qpopupmenu.h>
26#include <qtoolbutton.h> 27#include <qtoolbutton.h>
27#include <qstring.h> 28#include <qstring.h>
28#include <qlabel.h> 29#include <qlabel.h>
29#include <qfile.h> 30#include <qfile.h>
30#include <qhbuttongroup.h> 31#include <qhbuttongroup.h>
31#include <qpushbutton.h> 32#include <qpushbutton.h>
32#include <qintdict.h> 33#include <qintdict.h>
33#include <qlayout.h> 34#include <qlayout.h>
34#include <qlineedit.h> 35#include <qlineedit.h>
35#include <qtextbrowser.h> 36#include <qtextbrowser.h>
36#include <qregexp.h> 37#include <qregexp.h>
37 38
38#include "olistview.h" 39#include "olistview.h"
39#include "olistviewitem.h" 40#include "olistviewitem.h"
40#include "resultitem.h" 41#include "resultitem.h"
41#include "adresssearch.h" 42#include "adresssearch.h"
42#include "todosearch.h" 43#include "todosearch.h"
43#include "datebooksearch.h" 44#include "datebooksearch.h"
44#include "applnksearch.h" 45#include "applnksearch.h"
45#include "doclnksearch.h" 46#include "doclnksearch.h"
46 47
47MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : 48MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
48 QMainWindow( parent, name, f ), _currentItem(0) 49 QMainWindow( parent, name, f ), _currentItem(0)
49{ 50{
50 setCaption( tr("OSearch") ); 51 setCaption( tr("OSearch") );
51 52
52 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); 53 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
53 54
54 QFrame *mainFrame = new QFrame( this, "mainFrame" ); 55 QFrame *mainFrame = new QFrame( this, "mainFrame" );
55 56
56 mainLayout = new QVBoxLayout( mainFrame ); 57 mainLayout = new QVBoxLayout( mainFrame );
57 mainLayout->setSpacing( 0 ); 58 mainLayout->setSpacing( 0 );
58 mainLayout->setMargin( 0 ); 59 mainLayout->setMargin( 0 );
59 60
60 resultsList = new OListView( mainFrame ); 61 resultsList = new OListView( mainFrame );
61 resultsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); 62 resultsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
62 mainLayout->addWidget( resultsList, 1 ); 63 mainLayout->addWidget( resultsList, 1 );
63 64
64 detailsFrame = new QFrame( mainFrame, "detailsFrame" ); 65 detailsFrame = new QFrame( mainFrame, "detailsFrame" );
65 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); 66 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame );
66 richEdit = new QTextView( detailsFrame ); 67 richEdit = new QTextView( detailsFrame );
67 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); 68 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
68 //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum )); 69 //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ));
69 detailsLayout->addWidget( richEdit, 1 ); 70 detailsLayout->addWidget( richEdit, 1 );
70 71
71 buttonGroupActions = new QHButtonGroup( this ); 72 buttonGroupActions = new QHButtonGroup( this );
72 buttonGroupActions->hide(); 73 buttonGroupActions->hide();
73 _buttonCount = 0; 74 _buttonCount = 0;
74// buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 75// buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
75 76
76 buttonLayout = new QHBoxLayout( detailsFrame ); 77 buttonLayout = new QHBoxLayout( detailsFrame );
77 detailsLayout->addLayout( buttonLayout ); 78 detailsLayout->addLayout( buttonLayout );
78 79
79 mainLayout->addWidget( detailsFrame ); 80 mainLayout->addWidget( detailsFrame );
80 detailsFrame->hide(); 81 detailsFrame->hide();
81 82
82 searches.append( new AppLnkSearch( resultsList, tr("applications") ) ); 83 searches.append( new AppLnkSearch( resultsList, tr("applications") ) );
83 searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); 84 searches.append( new DocLnkSearch( resultsList, tr("documents") ) );
84 searches.append( new TodoSearch( resultsList, tr("todo") ) ); 85 searches.append( new TodoSearch( resultsList, tr("todo") ) );
85 searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); 86 searches.append( new DatebookSearch( resultsList, tr("datebook") ) );
86 searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); 87 searches.append( new AdressSearch( resultsList, tr("adressbook") ) );
87 88
88 setCentralWidget( mainFrame ); 89 setCentralWidget( mainFrame );
89 90
90 popupTimer = new QTimer(); 91 popupTimer = new QTimer();
91 searchTimer = new QTimer(); 92 searchTimer = new QTimer();
92 93
93 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); 94 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup()));
94 connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); 95 connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged()));
95 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); 96 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*)));
96 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); 97 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*)));
97 connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); 98 connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) );
98 99
99 makeMenu(); 100 makeMenu();
100 101
101 Config cfg( "osearch", Config::User ); 102 Config cfg( "osearch", Config::User );
102 cfg.setGroup( "search_settings" ); 103 cfg.setGroup( "search_settings" );
103 actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); 104 actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) );
104 actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); 105 actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) );
105// actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) ); 106// actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) );
106} 107}
107 108
108void MainWindow::makeMenu() 109void MainWindow::makeMenu()
109{ 110{
110 QPEToolBar *toolBar = new QPEToolBar( this ); 111 QPEToolBar *toolBar = new QPEToolBar( this );
111 QPEToolBar *searchBar = new QPEToolBar(this); 112 QPEToolBar *searchBar = new QPEToolBar(this);
112 QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); 113 QPEMenuBar *menuBar = new QPEMenuBar( toolBar );
113 QPopupMenu *searchMenu = new QPopupMenu( menuBar ); 114 QPopupMenu *searchMenu = new QPopupMenu( menuBar );
114// QPopupMenu *viewMenu = new QPopupMenu( menuBar ); 115// QPopupMenu *viewMenu = new QPopupMenu( menuBar );
115 QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); 116 QPopupMenu *cfgMenu = new QPopupMenu( menuBar );
116 QPopupMenu *searchOptions = new QPopupMenu( cfgMenu ); 117 QPopupMenu *searchOptions = new QPopupMenu( cfgMenu );
117 118
118 setToolBarsMovable( false ); 119 setToolBarsMovable( false );
119 toolBar->setHorizontalStretchable( true ); 120 toolBar->setHorizontalStretchable( true );
120 menuBar->insertItem( tr( "Search" ), searchMenu ); 121 menuBar->insertItem( tr( "Search" ), searchMenu );
121 menuBar->insertItem( tr( "Settings" ), cfgMenu ); 122 menuBar->insertItem( tr( "Settings" ), cfgMenu );
122 123
123 //SETTINGS MENU 124 //SETTINGS MENU
124 cfgMenu->insertItem( tr( "Search" ), searchOptions ); 125 cfgMenu->insertItem( tr( "Search" ), searchOptions );
125 QPopupMenu *pop; 126 QPopupMenu *pop;
126 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ 127 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
127 pop = s->popupMenu(); 128 pop = s->popupMenu();
128 if (pop){ 129 if (pop){
129 qDebug("inserting settings menu for %s",s->text(0).latin1()); 130 qDebug("inserting settings menu for %s",s->text(0).latin1());
130 cfgMenu->insertItem( s->text(0), pop ); 131 cfgMenu->insertItem( s->text(0), pop );
131 //connect( pop, SIGNAL( activated(int) ), SLOT( optionChanged(int) ) ); 132 //connect( pop, SIGNAL( activated(int) ), SLOT( optionChanged(int) ) );
132 } 133 }
133 } 134 }
134 135
135 136
136 //SEARCH 137 //SEARCH
137 SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); 138 SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 );
138 SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); 139 SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) );
139 connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); 140 connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) );
140 SearchAllAction->addTo( searchMenu ); 141 SearchAllAction->addTo( searchMenu );
141 searchMenu->insertItem( tr( "Options" ), searchOptions ); 142 searchMenu->insertItem( tr( "Options" ), searchOptions );
142 //connect( searchOptions, SIGNAL( activated(int) ), SLOT( optionChanged(int) ) ); 143 //connect( searchOptions, SIGNAL( activated(int) ), SLOT( optionChanged(int) ) );
143 144
144 //SEARCH OPTIONS 145 //SEARCH OPTIONS
145 //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true ); 146 //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true );
146 //actionWholeWordsOnly->addTo( searchOptions ); 147 //actionWholeWordsOnly->addTo( searchOptions );
147 actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); 148 actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true );
148 actionCaseSensitiv->addTo( searchOptions ); 149 actionCaseSensitiv->addTo( searchOptions );
149 actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); 150 actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true );
150 actionWildcards->addTo( searchOptions ); 151 actionWildcards->addTo( searchOptions );
151 152
152 //SEARCH BAR 153 //SEARCH BAR
153 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 154 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
154 QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); 155 QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" );
155 searchEdit->setFocus(); 156 searchEdit->setFocus();
156 searchBar->setHorizontalStretchable( TRUE ); 157 searchBar->setHorizontalStretchable( TRUE );
157 searchBar->setStretchableWidget( searchEdit ); 158 searchBar->setStretchableWidget( searchEdit );
158 SearchAllAction->addTo( searchBar ); 159 SearchAllAction->addTo( searchBar );
159 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 160 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
160 this, SLOT( setSearch( const QString & ) ) ); 161 this, SLOT( setSearch( const QString & ) ) );
161 162
162} 163}
163 164
164MainWindow::~MainWindow() 165MainWindow::~MainWindow()
165{ 166{
166 Config cfg( "osearch", Config::User ); 167 Config cfg( "osearch", Config::User );
167 cfg.setGroup( "search_settings" ); 168 cfg.setGroup( "search_settings" );
168 cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); 169 cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() );
169 cfg.writeEntry( "wildcards", actionWildcards->isOn() ); 170 cfg.writeEntry( "wildcards", actionWildcards->isOn() );
170 //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() ); 171 //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() );
171} 172}
172 173
173void MainWindow::setCurrent(QListViewItem *item) 174void MainWindow::setCurrent(QListViewItem *item)
174{ 175{
175 if (!item) return; 176 if (!item) return;
176 _currentItem = (OListViewItem*)item; 177 _currentItem = (OListViewItem*)item;
177 //_currentItem = dynamic_cast<OListViewItem*>(item); 178 //_currentItem = dynamic_cast<OListViewItem*>(item);
178 if (_currentItem->rtti() == OListViewItem::Result){ 179 if (_currentItem->rtti() == OListViewItem::Result){
179 ResultItem *res = (ResultItem*)item; 180 ResultItem *res = (ResultItem*)item;
180 // ResultItem *res = dynamic_cast<ResultItem*>(item); 181 // ResultItem *res = dynamic_cast<ResultItem*>(item);
181 richEdit->setText( res->toRichText() ); 182 richEdit->setText( res->toRichText() );
182 QIntDict<QString> acts = res->actions(); 183 QIntDict<QString> acts = res->actions();
183 QButton *button; 184 QButton *button;
184 for (uint i = 0; i < acts.count(); i++){ 185 for (uint i = 0; i < acts.count(); i++){
185 button = buttonGroupActions->find( i ); 186 button = buttonGroupActions->find( i );
186 qDebug("action %i >%s<",i,acts[i]->latin1()); 187 qDebug("action %i >%s<",i,acts[i]->latin1());
187 if (!button) { 188 if (!button) {
188 qDebug("BUTTON"); 189 qDebug("BUTTON");
189 button = new QPushButton( detailsFrame ); 190 button = new QPushButton( detailsFrame );
190 buttonLayout->addWidget( button, 0 ); 191 buttonLayout->addWidget( button, 0 );
191 buttonGroupActions->insert( button, i); 192 buttonGroupActions->insert( button, i);
192 } 193 }
193 button->setText( *acts[i] ); 194 button->setText( *acts[i] );
194 button->show(); 195 button->show();
195 } 196 }
196 for (uint i = acts.count(); i < _buttonCount; i++){ 197 for (uint i = acts.count(); i < _buttonCount; i++){
197 qDebug("remove button %i of %i",i, _buttonCount); 198 qDebug("remove button %i of %i",i, _buttonCount);
198 button = buttonGroupActions->find( i ); 199 button = buttonGroupActions->find( i );
199 if (button) button->hide(); 200 if (button) button->hide();
200 } 201 }
201 _buttonCount = acts.count(); 202 _buttonCount = acts.count();
202 detailsFrame->show(); 203 detailsFrame->show();
203 }else detailsFrame->hide(); 204 }else detailsFrame->hide();
204 popupTimer->start( 300, true ); 205 popupTimer->start( 300, true );
205} 206}
206 207
207void MainWindow::stopTimer(QListViewItem*) 208void MainWindow::stopTimer(QListViewItem*)
208{ 209{
209 popupTimer->stop(); 210 popupTimer->stop();
210} 211}
211 212
212void MainWindow::showPopup() 213void MainWindow::showPopup()
213{ 214{
214 qDebug("showPopup");
215 popupTimer->stop(); 215 popupTimer->stop();
216 if (!_currentItem) return; 216 if (!_currentItem) return;
217 QPopupMenu *pop = _currentItem->popupMenu(); 217 QPopupMenu *pop = _currentItem->popupMenu();
218 if (pop) pop->popup( QCursor::pos() ); 218 if (pop) pop->popup( QCursor::pos() );
219} 219}
220 220
221void MainWindow::setSearch( const QString &key ) 221void MainWindow::setSearch( const QString &key )
222{ 222{
223 searchTimer->stop(); 223 searchTimer->stop();
224 _searchString = key; 224 _searchString = key;
225 searchTimer->start( 300 ); 225 searchTimer->start( 300 );
226} 226}
227 227
228void MainWindow::searchStringChanged() 228void MainWindow::searchStringChanged()
229{ 229{
230#ifdef NEW_OWAIT
231 OWait("setting search string");
232#endif
230 searchTimer->stop(); 233 searchTimer->stop();
231 QString ss = _searchString; 234 QString ss = _searchString;
232 //ss = Global::stringQuote( _searchString ); 235 //ss = Global::stringQuote( _searchString );
233 //if (actionWholeWordsOnly->isOn()) 236 //if (actionWholeWordsOnly->isOn())
234 // ss = "\\s"+_searchString+"\\s"; 237 // ss = "\\s"+_searchString+"\\s";
235 qDebug(" set searchString >%s<",ss.latin1()); 238 //qDebug(" set searchString >%s<",ss.latin1());
236 QRegExp re( ss ); 239 QRegExp re( ss );
237 re.setCaseSensitive( actionCaseSensitiv->isOn() ); 240 re.setCaseSensitive( actionCaseSensitiv->isOn() );
238 re.setWildcard( actionWildcards->isOn() ); 241 re.setWildcard( actionWildcards->isOn() );
239 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) 242 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() )
240 s->setSearch( re ); 243 s->setSearch( re );
241} 244}
242 245
243void MainWindow::searchAll() 246void MainWindow::searchAll()
244{ 247{
248#ifdef NEW_OWAIT
249 OWait("searching...");
250#endif
245 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ 251 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
246 s->doSearch(); 252 s->doSearch();
247 //resultsList->repaint(); 253 //resultsList->repaint();
248 } 254 }
249} 255}
250 256
251void MainWindow::slotAction( int act ) 257void MainWindow::slotAction( int act )
252{ 258{
253 if (_currentItem->rtti() == OListViewItem::Result){ 259 if (_currentItem->rtti() == OListViewItem::Result){
254 ResultItem *res = (ResultItem*)_currentItem; 260 ResultItem *res = (ResultItem*)_currentItem;
255 // ResultItem *res = dynamic_cast<ResultItem*>(item); 261 // ResultItem *res = dynamic_cast<ResultItem*>(item);
256 res->action(act); 262 res->action(act);
257 } 263 }
258} 264}
259 265
260void MainWindow::optionChanged(int i) 266void MainWindow::optionChanged(int i)
261{ 267{
262 qDebug("optionChanged(%i)",i); 268 qDebug("optionChanged(%i)",i);
263 searchStringChanged(); 269 searchStringChanged();
264} 270}
diff --git a/core/pim/osearch/searchgroup.cpp b/core/pim/osearch/searchgroup.cpp
index e307696..0b58176 100644
--- a/core/pim/osearch/searchgroup.cpp
+++ b/core/pim/osearch/searchgroup.cpp
@@ -1,93 +1,92 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "searchgroup.h"
14 13
14#include <qobject.h>
15#include <qregexp.h> 15#include <qregexp.h>
16#include <qapplication.h> 16#include <qapplication.h>
17#include <opie/owait.h> 17#include <opie/owait.h>
18 18
19#include "olistviewitem.h" 19#include "olistviewitem.h"
20#include "searchgroup.h"
20 21
21//#define NEW_OWAIT
22#ifndef NEW_OWAIT 22#ifndef NEW_OWAIT
23static OWait *wait = 0; 23static OWait *wait = 0;
24#endif 24#endif
25 25
26SearchGroup::SearchGroup(QListView* parent, QString name) 26SearchGroup::SearchGroup(QListView* parent, QString name)
27: OListViewItem(parent, name) 27: OListViewItem(parent, name)
28{ 28{
29 _name = name; 29 _name = name;
30 loaded = false; 30 loaded = false;
31} 31}
32 32
33 33
34SearchGroup::~SearchGroup() 34SearchGroup::~SearchGroup()
35{ 35{
36} 36}
37 37
38 38
39void SearchGroup::expand() 39void SearchGroup::expand()
40{ 40{
41 //expanded = true; 41 //expanded = true;
42 clearList(); 42 if (_lastSearch != _search) clearList();
43 if (_search.isEmpty()) return; 43 if (_search.isEmpty()) return;
44 OListViewItem *dummy = new OListViewItem( this, "searching..."); 44 OListViewItem *dummy = new OListViewItem( this, "searching...");
45 setOpen( true ); 45 setOpen( true );
46 repaint(); 46 repaint();
47 int res_count = realSearch(); 47 int res_count = realSearch();
48 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")"); 48 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
49 delete dummy; 49 delete dummy;
50 repaint(); 50 repaint();
51} 51}
52 52
53void SearchGroup::doSearch() 53void SearchGroup::doSearch()
54{ 54{
55 clearList(); 55 clearList();
56 if (_search.isEmpty()) return; 56 if (_search.isEmpty()) return;
57 _resultCount = realSearch(); 57 _resultCount = realSearch();
58 //repaint(); 58 //repaint();
59} 59}
60 60
61void SearchGroup::setSearch(QRegExp re) 61void SearchGroup::setSearch(QRegExp re)
62{ 62{
63 if (re == _search) return; 63 if (re == _search) return;
64 setText(0, _name+" - "+re.pattern() ); 64 setText(0, _name+" - "+re.pattern() );
65 _search = re; 65 _search = re;
66 if (isOpen()) expand(); 66 if (isOpen()) expand();
67 else new OListViewItem( this, "searching..."); 67 else new OListViewItem( this, "searching...");
68} 68}
69 69
70int SearchGroup::realSearch() 70int SearchGroup::realSearch()
71{ 71{
72 if (_lastSearch == _search) return _resultCount;
72#ifndef NEW_OWAIT 73#ifndef NEW_OWAIT
73 qDebug("NOT using NEW_OWAIT");
74 if (!wait) wait = new OWait( qApp->mainWidget(), "osearch" ); 74 if (!wait) wait = new OWait( qApp->mainWidget(), "osearch" );
75 wait->show(); 75 wait->show();
76 qApp->processEvents(); 76 qApp->processEvents();
77#else 77#else
78 qDebug("using NEW_OWAIT"); 78 qDebug("********** NEW_OWAIT *************");
79 OWait::start( "osearch" ); 79 OWait( "searching" );
80#endif 80#endif
81 if (!loaded) load(); 81 if (!loaded) load();
82 _resultCount = 0; 82 _resultCount = 0;
83 _resultCount = search(); 83 _resultCount = search();
84 _lastSearch = _search;
84 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( _resultCount ) + ")"); 85 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( _resultCount ) + ")");
85 86
86#ifndef NEW_OWAIT 87#ifndef NEW_OWAIT
87 wait->hide(); 88 wait->hide();
88#else
89 OWait::stop();
90#endif 89#endif
91 return _resultCount; 90 return _resultCount;
92} 91}
93 92
diff --git a/core/pim/osearch/searchgroup.h b/core/pim/osearch/searchgroup.h
index a755e06..ad37d4e 100644
--- a/core/pim/osearch/searchgroup.h
+++ b/core/pim/osearch/searchgroup.h
@@ -1,48 +1,49 @@
1// 1//
2// 2//
3// C++ Interface: $MODULE$ 3// C++ Interface: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#ifndef SEARCHGROUP_H 13#ifndef SEARCHGROUP_H
14#define SEARCHGROUP_H 14#define SEARCHGROUP_H
15 15
16#include "olistviewitem.h" 16#include "olistviewitem.h"
17 17
18class QRegExp; 18class QRegExp;
19class QPopupMenu; 19class QPopupMenu;
20 20
21/** 21/**
22@author Patrick S. Vogt 22@author Patrick S. Vogt
23*/ 23*/
24class SearchGroup : public OListViewItem 24class SearchGroup : public OListViewItem
25{ 25{
26public: 26public:
27 SearchGroup(QListView* parent, QString name); 27 SearchGroup(QListView* parent, QString name);
28 28
29 ~SearchGroup(); 29 ~SearchGroup();
30 30
31 virtual void expand(); 31 virtual void expand();
32 virtual void doSearch(); 32 virtual void doSearch();
33 virtual void setSearch(QRegExp); 33 virtual void setSearch(QRegExp);
34 virtual int rtti() { return Searchgroup;} 34 virtual int rtti() { return Searchgroup;}
35 35
36protected: 36protected:
37 QRegExp _search;
38 virtual void load() = 0; 37 virtual void load() = 0;
39 virtual int search() = 0; 38 virtual int search() = 0;
40 virtual void insertItem( void* ) = 0; 39 virtual void insertItem( void* ) = 0;
40 QRegExp _search;
41 QRegExp _lastSearch;
41 QString _name; 42 QString _name;
42 bool loaded; 43 bool loaded;
43 int _resultCount; 44 int _resultCount;
44private: 45private:
45 int realSearch(); 46 int realSearch();
46}; 47};
47 48
48#endif 49#endif