Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

searchgroup.cpp

Go to the documentation of this file.
00001 //
00002 //
00003 // C++ Implementation: $MODULE$
00004 //
00005 // Description:
00006 //
00007 //
00008 // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
00009 //
00010 // Copyright: See COPYING file that comes with this distribution
00011 //
00012 //
00013 #include "searchgroup.h"
00014 
00015 #include <opie2/odebug.h>
00016 #include <opie2/owait.h>
00017 
00018 #include <qapplication.h>
00019 
00020 #ifndef NEW_OWAIT
00021 static Opie::Ui::OWait *wait = 0;
00022 #endif
00023 
00024 SearchGroup::SearchGroup(QListView* parent, QString name)
00025 : OListViewItem(parent, name)
00026 {
00027         _name = name;
00028         loaded = false;
00029 }
00030 
00031 
00032 SearchGroup::~SearchGroup()
00033 {
00034 }
00035 
00036 
00037 void SearchGroup::expand()
00038 {
00039         //expanded = true;
00040         if (_lastSearch != _search) clearList();
00041         if (_search.isEmpty()) return;
00042         OListViewItem *dummy = new OListViewItem( this, "searching...");
00043         setOpen( true );
00044         repaint();
00045         int res_count = realSearch();
00046         setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
00047         delete dummy;
00048         repaint();
00049 }
00050 
00051 void SearchGroup::doSearch()
00052 {
00053         clearList();
00054         if (_search.isEmpty()) return;
00055         _resultCount = realSearch();
00056 //      repaint();
00057 }
00058 
00059 void SearchGroup::setSearch(QRegExp re)
00060 {
00061         if (re == _search) return;
00062         setText(0, _name+" - "+re.pattern() );
00063         _search = re;
00064         if (isOpen()) expand();
00065         else new OListViewItem( this, "searching...");
00066 }
00067 
00068 int SearchGroup::realSearch()
00069 {
00070         if (_lastSearch == _search) return _resultCount;
00071 #ifndef NEW_OWAIT
00072         if (!wait) wait = new Opie::Ui::OWait( qApp->mainWidget(), "osearch" );
00073         wait->show();
00074         qApp->processEvents();
00075 #else
00076         Opie:Core::odebug << "********** NEW_OWAIT *************" << oendl;
00077         OWait( "searching" );
00078 #endif
00079         if (!loaded) load();
00080         _resultCount = 0;
00081         _resultCount = search();
00082         _lastSearch = _search;
00083         setText(0, _name + " - " + _search.pattern() + " (" + QString::number( _resultCount ) + ")");
00084 
00085 #ifndef NEW_OWAIT
00086         wait->hide();
00087 #endif
00088         return _resultCount;
00089 }
00090 

Generated on Sat Nov 5 16:15:54 2005 for OPIE by  doxygen 1.4.2