summaryrefslogtreecommitdiff
path: root/core/pim/osearch/doclnksearch.cpp
authortille <tille>2003-05-16 15:18:21 (UTC)
committer tille <tille>2003-05-16 15:18:21 (UTC)
commit75f1e9815410e75a6f9ae76d8db716c0c315ea45 (patch) (side-by-side diff)
treef21eea4fb09db52644dc0141f8d368997ec322f0 /core/pim/osearch/doclnksearch.cpp
parent708f1846703c3f13f7c9ac67130b6930f9607523 (diff)
downloadopie-75f1e9815410e75a6f9ae76d8db716c0c315ea45.zip
opie-75f1e9815410e75a6f9ae76d8db716c0c315ea45.tar.gz
opie-75f1e9815410e75a6f9ae76d8db716c0c315ea45.tar.bz2
search in text documents
Diffstat (limited to 'core/pim/osearch/doclnksearch.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/osearch/doclnksearch.cpp56
1 files changed, 52 insertions, 4 deletions
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
@@ -10,25 +10,39 @@
// 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()
@@ -36,8 +50,42 @@ 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;
+}