[yast-commit] r53739 - in /trunk/qt-pkg/src: YQPkgChangesDialog.cc YQPkgChangesDialog.h
Author: dmacvicar Date: Fri Nov 28 17:40:35 2008 New Revision: 53739 URL: http://svn.opensuse.org/viewcvs/yast?rev=53739&view=rev Log: - of course, we can research what is new in Qt 4.x and stop making mappings between gui and data, when one has a nice way to store user data as QVariants. Something that the whole Qt UI could benefit from. Strange that findData() function does not seem to work with our custom type, however a normal loop, works. Modified: trunk/qt-pkg/src/YQPkgChangesDialog.cc trunk/qt-pkg/src/YQPkgChangesDialog.h Modified: trunk/qt-pkg/src/YQPkgChangesDialog.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgChangesDialog.cc?rev=53739&r1=53738&r2=53739&view=diff ============================================================================== --- trunk/qt-pkg/src/YQPkgChangesDialog.cc (original) +++ trunk/qt-pkg/src/YQPkgChangesDialog.cc Fri Nov 28 17:40:35 2008 @@ -89,13 +89,12 @@ _filter = new QComboBox(this); // add the items. - _filter->addItems( QStringList() << _("All") - << _("Selected by the user") - << _("Automatic Changes") ); + _filter->addItem(_("All"), QVariant::fromValue(Filters(FilterAll))); + _filter->addItem(_("Selected by the user"), QVariant::fromValue(Filters(FilterUser))); + _filter->addItem(_("Automatic Changes"), QVariant::fromValue(Filters(FilterAutomatic))); _filter->setCurrentIndex(0); - layout->addWidget(_filter); connect( _filter, SIGNAL(currentIndexChanged(int)), SLOT(slotFilterChanged(int))); @@ -142,42 +141,6 @@ } } -YQPkgChangesDialog::Filters -YQPkgChangesDialog::indexToFilter( int i ) const -{ - switch (i) - { - case FilterIndexUser: - return FilterUser; - case FilterIndexAutomatic: - return FilterAutomatic; - case FilterIndexAll: - default: - return FilterAll; - } - return FilterAll; -} - -int -YQPkgChangesDialog::filterToIndex( Filters f ) const -{ - switch (f) - { - case FilterAll: - return FilterIndexAll; - case FilterUser: - return FilterIndexUser; - case FilterAutomatic: - return FilterIndexAutomatic; - default: - return FilterIndexAll; - } - - return FilterIndexAll; -} - - - void YQPkgChangesDialog::filter( Filters f ) { @@ -188,8 +151,18 @@ YQPkgChangesDialog::slotFilterChanged( int index ) { yuiMilestone() << "filter index changed to: " << index << endl; - Filters f = indexToFilter(index); - filter(f); + QVariant v = _filter->itemData(index); + + if ( v.isValid() && v.canConvert<Filters>() ) + { + Filters f = v.value<Filters>(); + filter(f); + } + else + { + yuiError() << "Can't find filter for index " << index << endl; + } + } void @@ -201,16 +174,34 @@ void YQPkgChangesDialog::setFilter( const QRegExp ®exp, Filters f ) { - int index = filterToIndex(f); - yuiMilestone() << "filter changed to: " << f << ", index: " << index << endl; - // so we dont get called again - _filter->blockSignals(true); - - // try to set the widget - _filter->setCurrentIndex(f); + yuiMilestone() << "filter changed to: " << f << endl; - _filter->blockSignals(false); - filter(regexp, f); + int index = -1; + for ( int k = 0; k < _filter->count(); ++k ) + { + QVariant v = _filter->itemData(k); + if ( v.isValid() && v.canConvert<Filters>() ) + { + + Filters setf = v.value<Filters>(); + if ( setf == f ) + index = k; + } + } + + if ( index != -1 ) + { + // so we dont get called again + _filter->blockSignals(true); + // try to set the widget + _filter->setCurrentIndex(f); + _filter->blockSignals(false); + filter(regexp, f); + } + else + { + yuiError() << "Can't find index for filter " << f << endl; + } } Modified: trunk/qt-pkg/src/YQPkgChangesDialog.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgChangesDialog.h?rev=53739&r1=53738&r2=53739&view=diff ============================================================================== --- trunk/qt-pkg/src/YQPkgChangesDialog.h (original) +++ trunk/qt-pkg/src/YQPkgChangesDialog.h Fri Nov 28 17:40:35 2008 @@ -138,16 +138,6 @@ void slotFilterChanged( int index ); protected: - - /** - * convert filter index into a filter combination - */ - Filters indexToFilter( int i ) const; - /** - * Filter to combobox index - */ - int filterToIndex( Filters f ) const; - /** * Constructor: Creates a changes dialog with text 'message' on * top, a list packages with an "auto" status that is not set via selections -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
dmacvicar@svn.opensuse.org