From 9cf81b4fbe5f2ca389c14014931ffd06d2697140 Mon Sep 17 00:00:00 2001 From: dmacvicar Date: Sat, 8 Dec 2007 01:02:48 +0000 Subject: [PATCH] YQPkgSearchFilterView QT3_SUPPORT, damn this one was boring git-svn-id: http://svn.opensuse.org/svn/yast/trunk/qt4@42840 e0cc52ee-31ee-0310-8b87-e83c4596d67c --- src/pkg/YQPkgSearchFilterView.cc | 116 +++++++++++++++++-------------- src/pkg/YQPkgSearchFilterView.h | 9 ++- 2 files changed, 66 insertions(+), 59 deletions(-) diff --git a/src/pkg/YQPkgSearchFilterView.cc b/src/pkg/YQPkgSearchFilterView.cc index ff8e652..a9e0de1 100644 --- a/src/pkg/YQPkgSearchFilterView.cc +++ b/src/pkg/YQPkgSearchFilterView.cc @@ -18,19 +18,16 @@ /-*/ -#define QT3_SUPPORT 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -//Added by qt3to4: -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define y2log_component "qt-pkg" #include @@ -51,63 +48,74 @@ using std::string; YQPkgSearchFilterView::YQPkgSearchFilterView( QWidget * parent ) - : Q3VBox( parent ) + : QWidget( parent ) { + QVBoxLayout *layout = new QVBoxLayout; + setLayout(layout); _matchCount = 0; - setMargin( MARGIN ); - setSpacing( SPACING ); + layout->setMargin( MARGIN ); + layout->setSpacing( SPACING ); - addVStretch( this ); + layout->addStretch(); // Headline QLabel * label = new QLabel( _( "Searc&h:" ), this ); Q_CHECK_PTR( label ); + layout->addWidget(label); label->setFont( YQUI::yqApp()->headingFont() ); // Input field ( combo box ) for search text _searchText = new QComboBox( this ); Q_CHECK_PTR( _searchText ); + layout->addWidget(_searchText); _searchText->setEditable( true ); label->setBuddy( _searchText ); // Box for search button - Q3HBox * hbox = new Q3HBox( this ); + QHBoxLayout * hbox = new QHBoxLayout( this ); Q_CHECK_PTR( hbox ); - - addHStretch( hbox ); + layout->addLayout(hbox); + hbox->addStretch(); // Search button - _searchButton = new QPushButton( _( "&Search" ), hbox ); + _searchButton = new QPushButton( _( "&Search" ), this ); Q_CHECK_PTR( _searchButton ); + hbox->addWidget(_searchButton); connect( _searchButton, SIGNAL( clicked() ), this, SLOT ( filter() ) ); - addVStretch( this ); + layout->addStretch(); // // Where to search // - - Q3VGroupBox * gbox = new Q3VGroupBox( _( "Search in" ), this ); + + QGroupBox * gbox = new QGroupBox( _( "Search in" ), this ); Q_CHECK_PTR( gbox ); - + QVBoxLayout *vlayout = new QVBoxLayout; + gbox->setLayout(vlayout); _searchInName = new QCheckBox( _( "&Name" ), gbox ); Q_CHECK_PTR( _searchInName ); + vlayout->addWidget(_searchInName); _searchInSummary = new QCheckBox( _( "Su&mmary" ), gbox ); Q_CHECK_PTR( _searchInSummary ); + vlayout->addWidget(_searchInSummary); _searchInDescription = new QCheckBox( _( "Descr&iption" ), gbox ); Q_CHECK_PTR( _searchInDescription ); + vlayout->addWidget(_searchInDescription); - addVStretch( gbox ); + vlayout->addStretch(); // Intentionally NOT marking RPM tags for translation _searchInProvides = new QCheckBox( "RPM \"&Provides\"" , gbox ); Q_CHECK_PTR( _searchInProvides ); + vlayout->addWidget(_searchInProvides); _searchInRequires = new QCheckBox( "RPM \"Re&quires\"" , gbox ); Q_CHECK_PTR( _searchInRequires ); + vlayout->addWidget(_searchInRequires); _searchInName->setChecked( true ); _searchInSummary->setChecked( true ); - addVStretch( this ); + layout->addStretch(); // @@ -116,30 +124,34 @@ YQPkgSearchFilterView::YQPkgSearchFilterView( QWidget * parent ) label = new QLabel( _( "Search &Mode:" ), this ); Q_CHECK_PTR( label ); + layout->addWidget(label); _searchMode = new QComboBox( this ); Q_CHECK_PTR( _searchMode ); + layout->addWidget(_searchMode); + _searchMode->setEditable( false ); label->setBuddy( _searchMode ); // Caution: combo box items must be inserted in the same order as enum SearchMode! - _searchMode->insertItem( _( "Contains" ) ); - _searchMode->insertItem( _( "Begins with" ) ); - _searchMode->insertItem( _( "Exact Match" ) ); - _searchMode->insertItem( _( "Use Wild Cards" ) ); - _searchMode->insertItem( _( "Use Regular Expression" ) ); + _searchMode->addItem( _( "Contains" ) ); + _searchMode->addItem( _( "Begins with" ) ); + _searchMode->addItem( _( "Exact Match" ) ); + _searchMode->addItem( _( "Use Wild Cards" ) ); + _searchMode->addItem( _( "Use Regular Expression" ) ); - _searchMode->setCurrentItem( Contains ); + _searchMode->setCurrentIndex( Contains ); - addVStretch( this ); + layout->addStretch(); _caseSensitive = new QCheckBox( _( "Case Sensiti&ve" ), this ); Q_CHECK_PTR( _caseSensitive ); + layout->addWidget(_caseSensitive); for ( int i=0; i < 6; i++ ) - addVStretch( this ); + layout->addStretch(); } @@ -154,7 +166,7 @@ YQPkgSearchFilterView::keyPressEvent( QKeyEvent * event ) { if ( event ) { - if ( event->state() == 0 ) // No Ctrl / Alt / Shift etc. pressed + if ( event->modifiers() == Qt::NoModifier ) // No Ctrl / Alt / Shift etc. pressed { if ( event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter ) @@ -166,7 +178,7 @@ YQPkgSearchFilterView::keyPressEvent( QKeyEvent * event ) } - Q3VBox::keyPressEvent( event ); + QWidget::keyPressEvent( event ); } @@ -203,22 +215,19 @@ YQPkgSearchFilterView::filter() // Create a progress dialog that is only displayed if the search takes // longer than a couple of seconds ( default: 4 ). - Q3ProgressDialog progress( _( "Searching..." ), // text + QProgressDialog progress( _( "Searching..." ), // text _( "&Cancel" ), // cancelButtonLabel -#ifdef FIXME - Y2PM::packageManager().size(), // totalSteps -#else + 0, 1000, -#endif - this, 0, // parent, name - true ); // modal - progress.setCaption( "" ); + this // parent + ); + progress.setWindowTitle( "" ); progress.setMinimumDuration( 2000 ); // millisec QTime timer; QRegExp regexp( _searchText->currentText() ); - regexp.setCaseSensitive( _caseSensitive->isChecked() ); - regexp.setWildcard( _searchMode->currentItem() == UseWildcards ); + regexp.setCaseSensitivity( _caseSensitive->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive ); + regexp.setPatternSyntax( (_searchMode->currentIndex() == UseWildcards) ? QRegExp::Wildcard : QRegExp::RegExp); timer.start(); @@ -226,7 +235,7 @@ YQPkgSearchFilterView::filter() int count = 0; for ( ZyppPoolIterator it = zyppPkgBegin(); - it != zyppPkgEnd() && ! progress.wasCancelled(); + it != zyppPkgEnd() && ! progress.wasCanceled(); ++it ) { ZyppSel selectable = *it; @@ -244,7 +253,7 @@ YQPkgSearchFilterView::filter() check( selectable, selectable->theObj(), regexp ); - progress.setProgress( count++ ); + progress.setValue( count++ ); if ( timer.elapsed() > 300 ) // milisec { @@ -271,9 +280,8 @@ YQPkgSearchFilterView::check( ZyppSel selectable, ZyppObj zyppObj ) { QRegExp regexp( _searchText->currentText() ); - regexp.setCaseSensitive( _caseSensitive->isChecked() ); - regexp.setWildcard( _searchMode->currentItem() == UseWildcards ); - + regexp.setCaseSensitivity( _caseSensitive->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive ); + regexp.setPatternSyntax( (_searchMode->currentIndex() == UseWildcards) ? QRegExp::Wildcard : QRegExp::RegExp); return check( selectable, zyppObj, regexp ); } @@ -316,10 +324,10 @@ YQPkgSearchFilterView::check( const string & attribute, QString searchText = _searchText->currentText(); bool match = false; - switch ( _searchMode->currentItem() ) + switch ( _searchMode->currentIndex() ) { case Contains: - match = att.contains( searchText, _caseSensitive->isChecked() ); + match = att.contains( searchText, _caseSensitive->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive); break; case BeginsWith: diff --git a/src/pkg/YQPkgSearchFilterView.h b/src/pkg/YQPkgSearchFilterView.h index 1460828..8753db9 100644 --- a/src/pkg/YQPkgSearchFilterView.h +++ b/src/pkg/YQPkgSearchFilterView.h @@ -21,10 +21,9 @@ #define YQPkgSearchFilterView_h #include "YQZypp.h" -#include -#include -//Added by qt3to4: -#include +#include +#include +#include class QComboBox; @@ -39,7 +38,7 @@ using std::string; /** * @short Filter view for searching within packages **/ -class YQPkgSearchFilterView : public Q3VBox +class YQPkgSearchFilterView : public QWidget { Q_OBJECT -- 2.39.2