summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -46,9 +46,11 @@ int AppLnkSearch::search()
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;
}
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
@@ -15,24 +15,26 @@
#include "searchgroup.h"
class AppLnkSet;
+class AppLnk;
/**
@author Patrick S. Vogt
*/
class AppLnkSearch : public SearchGroup
{
public:
AppLnkSearch(QListView* parent, QString name);
-
~AppLnkSearch();
virtual void setSearch(QRegExp);
+
+protected:
virtual void load();
virtual int search();
virtual void insertItem( void* );
-
+ virtual bool searchFile(AppLnk*) { return false; };
AppLnkSet *_apps;
};
#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
@@ -9,35 +9,83 @@
//
// Copyright: See COPYING file that comes with this distribution
//
//
-#include "doclnksearch.h"
-#include <qpe/applnk.h>
-#include <qpe/qpeapplication.h>
+#include <qaction.h>
+#include <qfile.h>
#include <qiconset.h>
+#include <qpopupmenu.h>
+#include <qtextstream.h>
+#include <qpe/applnk.h>
+#include <qpe/config.h>
#include <qpe/resource.h>
+#include <qpe/qpeapplication.h>
+#include <opie/owait.h>
#include "doclnkitem.h"
+#include "doclnksearch.h"
DocLnkSearch::DocLnkSearch(QListView* parent, QString name)
-: AppLnkSearch(parent, name)
+: AppLnkSearch(parent, name), _popupMenu(0)
{
QIconSet is = Resource::loadIconSet( "osearch/documents" );
setPixmap( 0, is.pixmap( QIconSet::Small, true ) );
+
+ actionSearchInFiles = new QAction( QObject::tr("search content"),QString::null, 0, 0, 0, true );
+ Config cfg( "osearch", Config::User );
+ cfg.setGroup( "doclnk_settings" );
+ actionSearchInFiles->setOn( cfg.readBoolEntry( "search_content", false ) );
}
DocLnkSearch::~DocLnkSearch()
{
+ Config cfg( "osearch", Config::User );
+ cfg.setGroup( "doclnk_settings" );
+ cfg.writeEntry( "search_content", actionSearchInFiles->isOn() );
}
void DocLnkSearch::load()
{
_apps = new DocLnkSet(QPEApplication::documentDir());
}
+bool DocLnkSearch::searchFile( AppLnk *app )
+{
+ if (!actionSearchInFiles->isOn()) return false;
+ DocLnk *doc = (DocLnk*)app;
+ bool found = false;
+ if ( doc->type().contains( "text" ) ){
+#ifdef NEW_OWAIT
+ QString ouput = QObject::tr("searching %1").arg(doc->file());
+ OWait( output );
+#endif
+ 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 );
_resultCount++;
}
+
+
+QPopupMenu* DocLnkSearch::popupMenu()
+{
+ if (!_popupMenu){
+ _popupMenu = new QPopupMenu( 0 );
+ actionSearchInFiles->addTo( _popupMenu );
+ }
+ return _popupMenu;
+}
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,9 +1,9 @@
//
//
// C++ Interface: $MODULE$
//
-// Description:
+// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
@@ -14,20 +14,29 @@
#define DOCLNKSEARCH_H
#include "applnksearch.h"
+class QAction;
+class QPopupMenu;
+
/**
@author Patrick S. Vogt
*/
-class DocLnkSearch : public AppLnkSearch
+class DocLnkSearch : public AppLnkSearch
{
public:
DocLnkSearch(QListView* parent, QString name);
~DocLnkSearch();
+ virtual QPopupMenu* popupMenu();
+
protected:
virtual void load();
+ virtual bool searchFile(AppLnk*);
virtual void insertItem( void* );
+private:
+ QAction *actionSearchInFiles;
+ QPopupMenu *_popupMenu;
};
#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
@@ -19,8 +19,9 @@
#include <qpe/qpetoolbar.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpe/global.h>
+#include <opie/owait.h>
#include <qaction.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qtoolbutton.h>
@@ -210,9 +211,8 @@ void MainWindow::stopTimer(QListViewItem*)
}
void MainWindow::showPopup()
{
- qDebug("showPopup");
popupTimer->stop();
if (!_currentItem) return;
QPopupMenu *pop = _currentItem->popupMenu();
if (pop) pop->popup( QCursor::pos() );
@@ -226,14 +226,17 @@ void MainWindow::setSearch( const QString &key )
}
void MainWindow::searchStringChanged()
{
+#ifdef NEW_OWAIT
+ OWait("setting search string");
+#endif
searchTimer->stop();
QString ss = _searchString;
//ss = Global::stringQuote( _searchString );
// if (actionWholeWordsOnly->isOn())
// ss = "\\s"+_searchString+"\\s";
- qDebug(" set searchString >%s<",ss.latin1());
+// qDebug(" set searchString >%s<",ss.latin1());
QRegExp re( ss );
re.setCaseSensitive( actionCaseSensitiv->isOn() );
re.setWildcard( actionWildcards->isOn() );
for (SearchGroup *s = searches.first(); s != 0; s = searches.next() )
@@ -241,8 +244,11 @@ void MainWindow::searchStringChanged()
}
void MainWindow::searchAll()
{
+#ifdef NEW_OWAIT
+ OWait("searching...");
+#endif
for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
s->doSearch();
//resultsList->repaint();
}
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
@@ -9,17 +9,17 @@
//
// Copyright: See COPYING file that comes with this distribution
//
//
-#include "searchgroup.h"
+#include <qobject.h>
#include <qregexp.h>
#include <qapplication.h>
#include <opie/owait.h>
#include "olistviewitem.h"
+#include "searchgroup.h"
-//#define NEW_OWAIT
#ifndef NEW_OWAIT
static OWait *wait = 0;
#endif
@@ -38,9 +38,9 @@ SearchGroup::~SearchGroup()
void SearchGroup::expand()
{
//expanded = true;
- clearList();
+ if (_lastSearch != _search) clearList();
if (_search.isEmpty()) return;
OListViewItem *dummy = new OListViewItem( this, "searching...");
setOpen( true );
repaint();
@@ -68,26 +68,25 @@ void SearchGroup::setSearch(QRegExp re)
}
int SearchGroup::realSearch()
{
+ if (_lastSearch == _search) return _resultCount;
#ifndef NEW_OWAIT
- qDebug("NOT using NEW_OWAIT");
if (!wait) wait = new OWait( qApp->mainWidget(), "osearch" );
wait->show();
qApp->processEvents();
#else
- qDebug("using NEW_OWAIT");
- OWait::start( "osearch" );
+ qDebug("********** NEW_OWAIT *************");
+ OWait( "searching" );
#endif
if (!loaded) load();
_resultCount = 0;
_resultCount = search();
+ _lastSearch = _search;
setText(0, _name + " - " + _search.pattern() + " (" + QString::number( _resultCount ) + ")");
#ifndef NEW_OWAIT
wait->hide();
-#else
- OWait::stop();
#endif
return _resultCount;
}
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
@@ -33,12 +33,13 @@ public:
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;
+ QRegExp _search;
+ QRegExp _lastSearch;
QString _name;
bool loaded;
int _resultCount;
private: