-rw-r--r-- | core/pim/osearch/applnksearch.cpp | 4 | ||||
-rw-r--r-- | core/pim/osearch/applnksearch.h | 6 | ||||
-rw-r--r-- | core/pim/osearch/doclnksearch.cpp | 56 | ||||
-rw-r--r-- | core/pim/osearch/doclnksearch.h | 9 | ||||
-rw-r--r-- | core/pim/osearch/mainwindow.cpp | 10 | ||||
-rw-r--r-- | core/pim/osearch/searchgroup.cpp | 15 | ||||
-rw-r--r-- | core/pim/osearch/searchgroup.h | 3 |
7 files changed, 85 insertions, 18 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 @@ -49,3 +49,5 @@ int AppLnkSearch::search() insertItem( app ); - } + }else + if (searchFile( app )) + insertItem( app ); qApp->processEvents( 100 ); 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 @@ -18,2 +18,3 @@ class AppLnkSet; +class AppLnk; @@ -26,3 +27,2 @@ public: AppLnkSearch(QListView* parent, QString name); - ~AppLnkSearch(); @@ -30,2 +30,4 @@ public: virtual void setSearch(QRegExp); + +protected: virtual void load(); @@ -33,3 +35,3 @@ public: virtual void insertItem( void* ); - + virtual bool searchFile(AppLnk*) { return false; }; AppLnkSet *_apps; 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 @@ -12,13 +12,19 @@ // -#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) { @@ -26,2 +32,7 @@ DocLnkSearch::DocLnkSearch(QListView* parent, QString name) 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 ) ); } @@ -31,2 +42,5 @@ DocLnkSearch::~DocLnkSearch() { + Config cfg( "osearch", Config::User ); + cfg.setGroup( "doclnk_settings" ); + cfg.writeEntry( "search_content", actionSearchInFiles->isOn() ); } @@ -38,2 +52,26 @@ void DocLnkSearch::load() +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 ) @@ -43 +81,11 @@ void DocLnkSearch::insertItem( void *rec ) } + + +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 @@ -17,2 +17,5 @@ +class QAction; +class QPopupMenu; + /** @@ -26,5 +29,11 @@ public: + virtual QPopupMenu* popupMenu(); + protected: virtual void load(); + virtual bool searchFile(AppLnk*); virtual void insertItem( void* ); +private: + QAction *actionSearchInFiles; + QPopupMenu *_popupMenu; 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 @@ -22,2 +22,3 @@ #include <qpe/global.h> +#include <opie/owait.h> #include <qaction.h> @@ -213,3 +214,2 @@ void MainWindow::showPopup() { - qDebug("showPopup"); popupTimer->stop(); @@ -229,2 +229,5 @@ void MainWindow::searchStringChanged() { +#ifdef NEW_OWAIT + OWait("setting search string"); +#endif searchTimer->stop(); @@ -234,3 +237,3 @@ void MainWindow::searchStringChanged() // ss = "\\s"+_searchString+"\\s"; - qDebug(" set searchString >%s<",ss.latin1()); +// qDebug(" set searchString >%s<",ss.latin1()); QRegExp re( ss ); @@ -244,2 +247,5 @@ void MainWindow::searchAll() { +#ifdef NEW_OWAIT + OWait("searching..."); +#endif for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ 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 @@ -12,4 +12,4 @@ // -#include "searchgroup.h" +#include <qobject.h> #include <qregexp.h> @@ -19,4 +19,4 @@ #include "olistviewitem.h" +#include "searchgroup.h" -//#define NEW_OWAIT #ifndef NEW_OWAIT @@ -41,3 +41,3 @@ void SearchGroup::expand() //expanded = true; - clearList(); + if (_lastSearch != _search) clearList(); if (_search.isEmpty()) return; @@ -71,4 +71,4 @@ int SearchGroup::realSearch() { + if (_lastSearch == _search) return _resultCount; #ifndef NEW_OWAIT - qDebug("NOT using NEW_OWAIT"); if (!wait) wait = new OWait( qApp->mainWidget(), "osearch" ); @@ -77,4 +77,4 @@ int SearchGroup::realSearch() #else - qDebug("using NEW_OWAIT"); - OWait::start( "osearch" ); + qDebug("********** NEW_OWAIT *************"); + OWait( "searching" ); #endif @@ -83,2 +83,3 @@ int SearchGroup::realSearch() _resultCount = search(); + _lastSearch = _search; setText(0, _name + " - " + _search.pattern() + " (" + QString::number( _resultCount ) + ")"); @@ -87,4 +88,2 @@ int SearchGroup::realSearch() wait->hide(); -#else - OWait::stop(); #endif 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 @@ -36,3 +36,2 @@ public: protected: - QRegExp _search; virtual void load() = 0; @@ -40,2 +39,4 @@ protected: virtual void insertItem( void* ) = 0; + QRegExp _search; + QRegExp _lastSearch; QString _name; |