Author: dmacvicar Date: Fri Apr 25 17:09:14 2008 New Revision: 47078 URL: http://svn.opensuse.org/viewcvs/yast?rev=47078&view=rev Log: ported search to sat solver search (much faster) and implemented (fate #120368) to search for keywords enabled by default. Looking for requires and provides is broken right now. Modified: trunk/qt-pkg/src/YQPkgSearchFilterView.cc trunk/qt-pkg/src/YQPkgSearchFilterView.h Modified: trunk/qt-pkg/src/YQPkgSearchFilterView.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgSearchFilterView.cc?rev=47078&r1=47077&r2=47078&view=diff ============================================================================== --- trunk/qt-pkg/src/YQPkgSearchFilterView.cc (original) +++ trunk/qt-pkg/src/YQPkgSearchFilterView.cc Fri Apr 25 17:09:14 2008 @@ -29,6 +29,8 @@ #include <QDateTime> #include <QKeyEvent> +#include "zypp/PoolQuery.h" + #define YUILogComponent "qt-pkg" #include "YUILog.h" @@ -208,6 +210,11 @@ // Create a progress dialog that is only displayed if the search takes // longer than a couple of seconds ( default: 4 ). + + zypp::PoolQuery query; + query.addKind(zypp::ResTraitszypp::Package::kind); + query.addString(_searchText->currentText().toUtf8().data()); + QProgressDialog progress( _( "Searching..." ), // text _( "&Cancel" ), // cancelButtonLabel 0, @@ -216,35 +223,59 @@ ); progress.setWindowTitle( "" ); progress.setMinimumDuration( 2000 ); // millisec - QTime timer; - QRegExp regexp( _searchText->currentText() ); - regexp.setCaseSensitivity( _caseSensitive->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive ); - regexp.setPatternSyntax( (_searchMode->currentIndex() == UseWildcards) ? QRegExp::Wildcard : QRegExp::RegExp); + QTime timer; + query.setCaseSensitive( _caseSensitive->isChecked() ); + + switch ( _searchMode->currentIndex() ) + { + case Contains: + case BeginsWith: + query.setMatchSubstring(); + break; + case ExactMatch: + break; + case UseWildcards: + query.setMatchGlob(); + break; + case UseRegExp: + query.setMatchRegex(); + break; + // Intentionally omitting "default" branch - let gcc watch for unhandled enums + } + + if ( _searchInName->isChecked() ) + query.addAttribute( zypp::sat::SolvAttr::name ); + if ( _searchInDescription->isChecked() ) + query.addAttribute( zypp::sat::SolvAttr::description ); + if ( _searchInSummary->isChecked() ) + query.addAttribute( zypp::sat::SolvAttr::summary ); + if ( _searchInRequires->isChecked() ) { + } + + if ( _searchInProvides->isChecked() ){ + } + + // always look in keywords so FATE #120368 is implemented + // but make this configurable later + query.addAttribute( zypp::sat::SolvAttr::keywords ); timer.start(); - int count = 0; - for ( ZyppPoolIterator it = zyppPkgBegin(); - it != zyppPkgEnd() && ! progress.wasCanceled(); + for ( zypp::PoolQuery::Selectable_iterator it = query.selectableBegin(); + it != query.selectableEnd() && ! progress.wasCanceled(); ++it ) { ZyppSel selectable = *it; + ZyppPkg zyppPkg = tryCastToZyppPkg( selectable->theObj() ); - bool match = - check( selectable, selectable->candidateObj(), regexp ) || - check( selectable, selectable->installedObj(), regexp ); - - // If there is neither an installed nor a candidate package, check - // any other instance. - - if ( ! match && - ! selectable->candidateObj() && - ! selectable->installedObj() ) - check( selectable, selectable->theObj(), regexp ); - + if ( zyppPkg ) + { + _matchCount++; + emit filterMatch( selectable, zyppPkg ); + } progress.setValue( count++ ); @@ -255,7 +286,7 @@ // list change all the time, thus display updates are necessary // each time. - qApp->processEvents(); + //qApp->processEvents(); timer.restart(); } } @@ -267,7 +298,6 @@ emit filterFinished(); } - bool YQPkgSearchFilterView::check( ZyppSel selectable, ZyppObj zyppObj ) @@ -363,6 +393,4 @@ return false; } - - #include "YQPkgSearchFilterView.moc" Modified: trunk/qt-pkg/src/YQPkgSearchFilterView.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgSearchFilterView.h?rev=47078&r1=47077&r2=47078&view=diff ============================================================================== --- trunk/qt-pkg/src/YQPkgSearchFilterView.h (original) +++ trunk/qt-pkg/src/YQPkgSearchFilterView.h Fri Apr 25 17:09:14 2008 @@ -127,19 +127,26 @@ UseRegExp }; + /** + * Key press event: Execute search upon 'Return' + * Reimplemented from QVBox / QWidget. + **/ + virtual void keyPressEvent( QKeyEvent * event ); + // THESE SHOULD BE DEPRECATED but still used in secondary + // filters /** * Check if pkg matches the search criteria. **/ bool check( ZyppSel selectable, ZyppObj zyppObj, const QRegExp & regexp ); - + /** * Check if a single pkg attribute matches the search criteria. **/ bool check( const string & attribute, const QRegExp & regexp ); - + /** * Check capability like * zypp::Resolvable::dep( zypp::Dep::PROVIDES ), @@ -147,13 +154,6 @@ **/ bool check( const zypp::Capabilities & capSet, const QRegExp & regexp ); - /** - * Key press event: Execute search upon 'Return' - * Reimplemented from QVBox / QWidget. - **/ - virtual void keyPressEvent( QKeyEvent * event ); - - // Data members QComboBox * _searchText; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org