Diffstat (limited to 'core/pim/osearch/doclnksearch.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/osearch/doclnksearch.cpp | 56 |
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 | |||
@@ -12,13 +12,19 @@ | |||
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 | ||
22 | DocLnkSearch::DocLnkSearch(QListView* parent, QString name) | 28 | DocLnkSearch::DocLnkSearch(QListView* parent, QString name) |
23 | : AppLnkSearch(parent, name) | 29 | : AppLnkSearch(parent, name), _popupMenu(0) |
24 | { | 30 | { |
@@ -26,2 +32,7 @@ DocLnkSearch::DocLnkSearch(QListView* parent, QString name) | |||
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 | } |
@@ -31,2 +42,5 @@ DocLnkSearch::~DocLnkSearch() | |||
31 | { | 42 | { |
43 | Config cfg( "osearch", Config::User ); | ||
44 | cfg.setGroup( "doclnk_settings" ); | ||
45 | cfg.writeEntry( "search_content", actionSearchInFiles->isOn() ); | ||
32 | } | 46 | } |
@@ -38,2 +52,26 @@ void DocLnkSearch::load() | |||
38 | 52 | ||
53 | bool 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 | |||
39 | void DocLnkSearch::insertItem( void *rec ) | 77 | void DocLnkSearch::insertItem( void *rec ) |
@@ -43 +81,11 @@ void DocLnkSearch::insertItem( void *rec ) | |||
43 | } | 81 | } |
82 | |||
83 | |||
84 | QPopupMenu* DocLnkSearch::popupMenu() | ||
85 | { | ||
86 | if (!_popupMenu){ | ||
87 | _popupMenu = new QPopupMenu( 0 ); | ||
88 | actionSearchInFiles->addTo( _popupMenu ); | ||
89 | } | ||
90 | return _popupMenu; | ||
91 | } | ||