Author: dmacvicar Date: Thu Mar 24 12:36:13 2011 New Revision: 63655
URL: http://svn.opensuse.org/viewcvs/yast?rev=63655&view=rev Log: more backporting of ZYpp API changes
Modified: branches/tmp/dmacvicar/zc10/qt/src/YQPkgLangList.cc branches/tmp/dmacvicar/zc10/qt/src/YQPkgList.cc branches/tmp/dmacvicar/zc10/qt/src/YQPkgObjList.cc branches/tmp/dmacvicar/zc10/qt/src/YQPkgPatchFilterView.cc branches/tmp/dmacvicar/zc10/qt/src/YQPkgPatchList.cc branches/tmp/dmacvicar/zc10/qt/src/YQPkgPatternList.cc branches/tmp/dmacvicar/zc10/qt/src/YQPkgSearchFilterView.cc branches/tmp/dmacvicar/zc10/qt/src/YQPkgSelDescriptionView.cc branches/tmp/dmacvicar/zc10/qt/src/YQPkgTechnicalDetailsView.cc branches/tmp/dmacvicar/zc10/qt/src/include/YQPkgLangList.h branches/tmp/dmacvicar/zc10/qt/src/include/YQPkgObjList.h branches/tmp/dmacvicar/zc10/qt/src/include/YQPkgSearchFilterView.h
Modified: branches/tmp/dmacvicar/zc10/qt/src/YQPkgLangList.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/qt/src/YQPk... ============================================================================== --- branches/tmp/dmacvicar/zc10/qt/src/YQPkgLangList.cc (original) +++ branches/tmp/dmacvicar/zc10/qt/src/YQPkgLangList.cc Thu Mar 24 12:36:13 2011 @@ -19,11 +19,11 @@ /-*/
-#define YUILogComponent "qt-pkg" -#include "YUILog.h" +#define y2log_component "qt-pkg" +#include "ycp/y2log.h" #include <qregexp.h>
-#include <QHeaderView> +//#include <QHeaderView> #include "YQi18n.h" #include "utf8.h" #include "YQPkgLangList.h" @@ -37,38 +37,23 @@ : YQPkgObjList( parent ) #warning "base class works with zypp::Resolvable, but zypp::Locale isn't one any longer!" { - yuiDebug() << "Creating language list" << endl; + y2debug("Creating language list");
int numCol = 0; - QStringList headers; - headers << ""; _statusCol = numCol++; - + addColumn(""); _statusCol = numCol++; // Translators: Table column heading for language ISO code like "de_DE", "en_US" // Please keep this short to avoid stretching the column too wide! - headers << _( "Code" ); _nameCol = numCol++; + addColumn(_("Code")); _nameCol = numCol++; + addColumn(_("Language")); _summaryCol = numCol++;
- // Full (human readable) language / country name like "German (Austria)" - headers << _( "Language"); _summaryCol = numCol++; setAllColumnsShowFocus( true ); - setHeaderLabels(headers); - header()->setResizeMode( _nameCol, QHeaderView::ResizeToContents ); - header()->setResizeMode( _summaryCol, QHeaderView::Stretch ); - - - setSortingEnabled( true ); - header()->setSortIndicatorShown( true ); - header()->setClickable( true ); - - sortByColumn( nameCol(), Qt::AscendingOrder );
- connect( this, SIGNAL( currentItemChanged ( QListViewItem *, QListViewItem * ) ), + connect( this, SIGNAL( selectionChanged ( QListViewItem * ) ), this, SLOT ( filter() ) );
fillList(); selectSomething(); - resizeColumnToContents(_statusCol); - - yuiDebug() << "Creating language list done" << endl; + y2debug("Creating language list done"); }
@@ -82,7 +67,7 @@ YQPkgLangList::fillList() { clear(); - yuiDebug() << "Filling language list" << endl; + y2debug("Filling language list");
zypp::LocaleSet locales = zypp::getZYpp()->pool().getAvailableLocales();
@@ -93,7 +78,7 @@ addLangItem( *it ); }
- yuiDebug() << "Language list filled" << endl; + y2debug("Language list filled"); }
@@ -119,22 +104,22 @@
zypp::sat::LocaleSupport myLocale( lang ); for_( it, myLocale.selectableBegin(), myLocale.selectableEnd() ) - { + { ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() ); if ( zyppPkg ) { if ( (*it)->installedSize() > 0 ) ++installed; ++total; - + emit filterMatch( *it, zyppPkg ); } } //selection()->setInstalledPackages(installed); //selection()->setTotalPackages(total); - + //selection()->setText( _summaryCol, QString().sprintf("%s (%d/%d)", zyppPattern->summary().c_str(), installed, total)); - + } emit filterFinished(); } @@ -149,7 +134,7 @@ YQPkgLangListItem * YQPkgLangList::selection() const { - QTreeWidgetItem * item = currentItem(); + QListViewItem * item = selectedItem();
if ( ! item ) return 0; @@ -157,29 +142,6 @@ return dynamic_cast<YQPkgLangListItem *> (item); }
- -void -YQPkgLangList::updateActions( YQPkgObjListItem * item) -{ -#if 0 - YQPkgLangListItem *litem; - if ( !item) - litem = dynamic_cast<YQPkgLangListItem *> ( currentItem() ); - else - litem = dynamic_cast<YQPkgLangListItem *> ( item ); -#endif - - actionSetCurrentInstall->setEnabled( true ); - actionSetCurrentDontInstall->setEnabled( true ); - actionSetCurrentTaboo->setEnabled( true ); - actionSetCurrentProtected->setEnabled( false ); - - actionSetCurrentKeepInstalled->setEnabled( false ); - actionSetCurrentDelete->setEnabled( false ); - actionSetCurrentUpdate->setEnabled( false ); -} - - YQPkgLangListItem::YQPkgLangListItem( YQPkgLangList * langList, const zypp::Locale & lang ) : YQPkgObjListItem( langList ) @@ -233,7 +195,7 @@ YQPkgLangListItem::setStatus( ZyppStatus newStatus, bool sendSignals ) { ZyppStatus oldStatus = status(); - + switch ( newStatus ) { case S_Install: @@ -289,23 +251,4 @@ _pkgObjList->sendStatusChanged(); }
-bool YQPkgLangListItem::operator<( const QTreeWidgetItem & otherListViewItem ) const -{ - const YQPkgLangListItem * other = dynamic_cast<const YQPkgLangListItem *> (&otherListViewItem); - int col = treeWidget()->sortColumn(); - - if ( other ) - { - if ( col == nameCol() ) - { - return ( strcoll( this->zyppLang().code().c_str(), other->zyppLang().code().c_str() ) < 0 ); - } - if ( col == summaryCol() ) - { - return ( strcoll( this->zyppLang().name().c_str(), other->zyppLang().name().c_str() ) < 0 ); - } - } - - return QY2ListViewItem::operator<( otherListViewItem ); -} #include "YQPkgLangList.moc"
Modified: branches/tmp/dmacvicar/zc10/qt/src/YQPkgList.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/qt/src/YQPk... ============================================================================== --- branches/tmp/dmacvicar/zc10/qt/src/YQPkgList.cc (original) +++ branches/tmp/dmacvicar/zc10/qt/src/YQPkgList.cc Thu Mar 24 12:36:13 2011 @@ -497,7 +497,7 @@ if ( doChange ) { if ( ! countOnly ) - selectable->set_status( newStatus ); + selectable->setStatus( newStatus );
changedCount++; // y2milestone( "Updating %s", selectable->name().c_str() );
Modified: branches/tmp/dmacvicar/zc10/qt/src/YQPkgObjList.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/qt/src/YQPk... ============================================================================== --- branches/tmp/dmacvicar/zc10/qt/src/YQPkgObjList.cc (original) +++ branches/tmp/dmacvicar/zc10/qt/src/YQPkgObjList.cc Thu Mar 24 12:36:13 2011 @@ -717,6 +717,14 @@ init(); }
+YQPkgObjListItem::YQPkgObjListItem( YQPkgObjList * pkgObjList ) + : QY2ListViewItem( pkgObjList ) + , _pkgObjList( pkgObjList ) + , _selectable( 0 ) + , _zyppObj( 0 ) + , _editable( true ) +{ +}
YQPkgObjListItem::~YQPkgObjListItem() { @@ -751,7 +759,7 @@
if ( sizeCol() >= 0 ) { - zypp::ByteCount size = zyppObj()->size(); + zypp::ByteCount size = zyppObj()->installSize();
if ( size > 0L ) setText( sizeCol(), size.asString() + " " ); @@ -829,7 +837,7 @@ YQPkgObjListItem::setStatus( ZyppStatus newStatus, bool sendSignals ) { ZyppStatus oldStatus = selectable()->status(); - selectable()->set_status( newStatus ); + selectable()->setStatus( newStatus );
if ( oldStatus != selectable()->status() ) { @@ -849,16 +857,7 @@ void YQPkgObjListItem::solveResolvableCollections() { - zypp::Resolver_Ptr resolver = zypp::getZYpp()->resolver(); - - resolver->transactReset( zypp::ResStatus::APPL_LOW ); - - resolver->transactResKind( zypp::ResTraits<zypp::Product >::kind ); - resolver->transactResKind( zypp::ResTraitszypp::Selection::kind ); - resolver->transactResKind( zypp::ResTraits<zypp::Pattern >::kind ); - resolver->transactResKind( zypp::ResTraits<zypp::Language >::kind ); - resolver->transactResKind( zypp::ResTraits<zypp::Patch >::kind ); - resolver->transactResKind( zypp::ResTraits<zypp::Atom >::kind ); + zypp::getZYpp()->resolver()->resolvePool(); }
@@ -924,7 +923,7 @@ if ( _selectable->hasInstalledObj() ) return false;
- return _selectable->candidatePoolItem().status().isSatisfied(); + return _selectable->candidateObj().isSatisfied(); }
@@ -941,7 +940,7 @@ case S_KeepInstalled: case S_Protected:
- return _selectable->installedPoolItem().status().isIncomplete(); + return _selectable->installedObj().isBroken();
case S_Update: // will be fixed by updating case S_AutoUpdate: @@ -1128,7 +1127,7 @@ y2warning( "User rejected license agreement for %s - setting to TABOO", sel->name().c_str() );
- sel->set_status( S_Taboo ); + sel->setStatus( S_Taboo ); break;
@@ -1138,7 +1137,7 @@ y2warning( "User rejected license agreement for %s - setting to PROTECTED", sel->name().c_str() );
- sel->set_status( S_Protected ); + sel->setStatus( S_Protected ); // S_Keep wouldn't be good enough: The next solver run might // set it to S_AutoUpdate again break; @@ -1221,8 +1220,8 @@ { // Numeric sort by size
- if ( this->zyppObj()->size() < other->zyppObj()->size() ) return -1; - if ( this->zyppObj()->size() > other->zyppObj()->size() ) return 1; + if ( this->zyppObj()->installSize() < other->zyppObj()->installSize() ) return -1; + if ( this->zyppObj()->installSize() > other->zyppObj()->installSize() ) return 1; return 0; } else if ( col == statusCol() )
Modified: branches/tmp/dmacvicar/zc10/qt/src/YQPkgPatchFilterView.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/qt/src/YQPk... ============================================================================== --- branches/tmp/dmacvicar/zc10/qt/src/YQPkgPatchFilterView.cc (original) +++ branches/tmp/dmacvicar/zc10/qt/src/YQPkgPatchFilterView.cc Thu Mar 24 12:36:13 2011 @@ -29,20 +29,18 @@ #include <qdatetime.h>
#include <y2util/FSize.h> -#include <zypp/ui/PatchContents.h>
#include "YQPkgPatchFilterView.h" #include "YQPkgPatchList.h" #include "YQPkgDescriptionView.h" -#include "YQPkgSelList.h" #include "QY2LayoutUtils.h" #include "YQi18n.h"
-typedef zypp::ui::PatchContents ZyppPatchContents; -typedef zypp::ui::PatchContents::const_iterator ZyppPatchContentsIterator; - using std::set;
+typedef zypp::Patch::Contents ZyppPatchContents; +typedef zypp::Patch::Contents::const_iterator ZyppPatchContentsIterator; + #define ENABLE_TOTAL_DOWNLOAD_SIZE 0
#define SPACING 6 // between subwidgets @@ -131,56 +129,56 @@ void YQPkgPatchFilterView::updateTotalDownloadSize() { - set<ZyppSel> selectablesToInstall; - QTime calcTime; - calcTime.start(); - - for ( ZyppPoolIterator patches_it = zyppPatchesBegin(); - patches_it != zyppPatchesEnd(); - ++patches_it ) + set<ZyppSel> selectablesToInstall; + QTime calcTime; + calcTime.start(); + + for ( ZyppPoolIterator patches_it = zyppPatchesBegin(); + patches_it != zyppPatchesEnd(); + ++patches_it ) { - ZyppPatch patch = tryCastToZyppPatch( (*patches_it)->theObj() ); + ZyppPatch patch = tryCastToZyppPatch( (*patches_it)->theObj() );
- if ( patch ) + if ( patch ) { - ZyppPatchContents patchContents( patch ); + ZyppPatchContents patchContents( patch->contents() );
- for ( ZyppPatchContentsIterator contents_it = patchContents.begin(); - contents_it != patchContents.end(); - ++contents_it ) + for ( ZyppPatchContentsIterator contents_it = patchContents.begin(); + contents_it != patchContents.end(); + ++contents_it ) { - ZyppPkg pkg = tryCastToZyppPkg( *contents_it ); - ZyppSel sel; + ZyppPkg pkg = zypp::makezypp::Package(*contents_it); + ZyppSel sel;
- if ( pkg ) - sel = _selMapper.findZyppSel( pkg ); + if ( pkg ) + sel = _selMapper.findZyppSel( pkg );
- if ( sel ) + if ( sel ) { - switch ( sel->status() ) + switch ( sel->status() ) { - case S_Install: - case S_AutoInstall: - case S_Update: - case S_AutoUpdate: - // Insert the patch contents selectables into a set, - // don't immediately sum up their sizes: The same - // package could be in more than one patch, but of - // course it will be downloaded only once. - - selectablesToInstall.insert( sel ); - break; - - case S_Del: - case S_AutoDel: - case S_NoInst: - case S_KeepInstalled: - case S_Taboo: - case S_Protected: - break; + case S_Install: + case S_AutoInstall: + case S_Update: + case S_AutoUpdate: + // Insert the patch contents selectables into a set, + // don't immediately sum up their sizes: The same + // package could be in more than one patch, but of + // course it will be downloaded only once. + + selectablesToInstall.insert( sel ); + break; + + case S_Del: + case S_AutoDel: + case S_NoInst: + case S_KeepInstalled: + case S_Taboo: + case S_Protected: + break;
- // intentionally omitting 'default' branch so the compiler can - // catch unhandled enum states + // intentionally omitting 'default' branch so the compiler can + // catch unhandled enum states }
} @@ -189,20 +187,19 @@ }
- FSize totalSize = 0; + FSize totalSize = 0;
- for ( set<ZyppSel>::iterator it = selectablesToInstall.begin(); - it != selectablesToInstall.end(); - ++it ) + for ( set<ZyppSel>::iterator it = selectablesToInstall.begin(); + it != selectablesToInstall.end(); + ++it ) { - if ( (*it)->candidateObj() ) - totalSize += (*it)->candidateObj()->size(); + if ( (*it)->candidateObj() ) + totalSize += (*it)->candidateObj()->installSize(); }
#if ENABLE_TOTAL_DOWNLOAD_SIZE - _totalDownloadSize->setText( totalSize.asString().c_str() ); + _totalDownloadSize->setText( totalSize.asString().c_str() ); #endif - y2debug( "Calculated total download size in %d millisec", calcTime.elapsed() ); }
Modified: branches/tmp/dmacvicar/zc10/qt/src/YQPkgPatchList.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/qt/src/YQPk... ============================================================================== --- branches/tmp/dmacvicar/zc10/qt/src/YQPkgPatchList.cc (original) +++ branches/tmp/dmacvicar/zc10/qt/src/YQPkgPatchList.cc Thu Mar 24 12:36:13 2011 @@ -24,7 +24,7 @@
#include <qpopupmenu.h> #include <qaction.h> -#include <zypp/ui/PatchContents.h> +#include <zypp/Patch.h> #include <set>
#include "YQi18n.h" @@ -36,14 +36,9 @@
#define VERBOSE_PATCH_LIST 1
- -typedef zypp::ui::PatchContents ZyppPatchContents; -typedef zypp::ui::PatchContents::const_iterator ZyppPatchContentsIterator; - using std::list; using std::set;
- YQPkgPatchList::YQPkgPatchList( QWidget * parent ) : YQPkgObjList( parent ) { @@ -102,144 +97,90 @@ _filterCriteria = filterCriteria; }
- void YQPkgPatchList::fillList() { - clear(); - y2debug( "Filling patch list" ); - - for ( ZyppPoolIterator it = zyppPatchesBegin(); - it != zyppPatchesEnd(); - ++it ) - { - ZyppSel selectable = *it; - ZyppPatch zyppPatch = tryCastToZyppPatch( selectable->theObj() ); - - if ( zyppPatch ) - { - bool displayPatch = false; - - switch ( _filterCriteria ) - { - case RelevantPatches: // needed + broken + satisfied (but not installed) + // wee need to do a full solve in order + // to get the satisfied status correctly + + clear(); + y2debug("Filling patch list");
- if ( selectable->hasInstalledObj() ) // installed? - { - if ( selectable->installedPoolItem().status().isIncomplete() ) // patch broken? - { - // The patch is broken: It had been installed, but the user somehow - // downgraded individual packages belonging to the patch to older versions. - - displayPatch = true; - - y2warning( "Installed patch is broken: %s - %s", - zyppPatch->name().c_str(), - zyppPatch->summary().c_str() ); - } - } - else // not installed - { - if ( selectable->hasCandidateObj() && - selectable->candidatePoolItem().status().isSatisfied() ) - { - // This is a pretty exotic case, but still it might happen: - // - // The patch itelf is not installed, but it is satisfied because the - // user updated all the packages belonging to the patch to the versions - // the patch requires. All that is missing now is to get the patch meta - // data onto the system. So let's display the patch to give the user - // a chance to install it (if he so chooses). - - displayPatch = true; - - y2milestone( "Patch satisfied, but not installed yet: %s - %s", - zyppPatch->name().c_str(), - zyppPatch->summary().c_str() ); - } - } - - if ( selectable->hasCandidateObj() ) // candidate available? - { - // The most common case: There is a candidate patch, i.e. one that could be - // installed, but either no version of that patch is installed or there is a - // newer one to which the patch could be updated. - - if ( selectable->candidatePoolItem().status().isNeeded() ) // patch really needed? - { - // Patches are needed if any of the packages that belong to the patch - // are installed on the system. - - displayPatch = true; - } - else - { - // None of the packages that belong to the patch is installed on the system. - - y2debug( "Patch not needed: %s - %s", - zyppPatch->name().c_str(), - zyppPatch->summary().c_str() ); - } - } - break; - - - case RelevantAndInstalledPatches: // needed + broken + installed - - if ( selectable->hasInstalledObj() ) // installed? - { - displayPatch = true; - } - else // not installed - display only if needed - { - zypp::ResStatus candidateStatus = selectable->candidatePoolItem().status(); - - if ( candidateStatus.isNeeded() || - candidateStatus.isSatisfied() ) - { - displayPatch = true; - } - else - { - y2milestone( "Patch not needed: %s - %s", - zyppPatch->name().c_str(), - zyppPatch->summary().c_str() ); - } - } - break;
+ for ( ZyppPoolIterator it = zyppPatchesBegin(); + it != zyppPatchesEnd(); + ++it ) + { + ZyppSel selectable = *it; + ZyppPatch zyppPatch = tryCastToZyppPatch( selectable->theObj() );
- case AllPatches: + if ( zyppPatch ) + { + bool displayPatch = false; + + switch ( _filterCriteria ) + { + case RelevantPatches:// needed + broken + satisfied (but not installed) + + // only shows patches relevant to the system + if ( selectable->hasCandidateObj() && + selectable->candidateObj().isRelevant() ) + { + // and only those that are needed + if ( ! selectable->candidateObj().isSatisfied() || + // may be it is satisfied because is preselected + selectable->candidateObj().status().isToBeInstalled() ) displayPatch = true; - break; - - // Intentionally omitting "default" so the compiler - // can catch unhandled enum values - } - - if ( displayPatch ) - { + else + y2debug( "Patch %s is already satisfied", zyppPatch->ident().c_str()); + } + else + y2debug( "Patch %s is not relevant to the system", zyppPatch->ident().c_str()); + break; + case RelevantAndInstalledPatches:// patches we dont need + + // only shows patches relevant to the system + if ( ( selectable->hasCandidateObj() ) && + ( ! selectable->candidateObj().isRelevant() + || ( selectable->candidateObj().isSatisfied() && + ! selectable->candidateObj().status().isToBeInstalled() ) ) ) + { + // now we show satisfied patches too + displayPatch = true; + } + break; + case AllPatches: + displayPatch = true; + break; + + // Intentionally omitting "default" so the compiler + // can catch unhandled enum values + default: + y2debug("unknown patch filter"); + + } + + if ( displayPatch ) + { #if VERBOSE_PATCH_LIST y2debug( "Displaying patch %s - %s", zyppPatch->name().c_str(), zyppPatch->summary().c_str() ); #endif - addPatchItem( *it, zyppPatch); - } - } - else - { - y2error( "Found non-patch selectable" ); - } - } - - - if ( ! firstChild() ) - message( _( "No patches available." ) );
- y2debug( "patch list filled" ); + addPatchItem( *it, zyppPatch); + } + } + else + { + y2error("Found non-patch selectable"); + } + } + + y2debug("Patch list filled"); + //resizeColumnToContents(_statusCol); + //resizeColumnToContents(_nameCol); + //resizeColumnToContents(_categoryCol); }
- - void YQPkgPatchList::message( const QString & text ) { @@ -263,75 +204,40 @@ void YQPkgPatchList::filter() { - emit filterStart(); - std::set<ZyppSel> patchSelectables; + emit filterStart();
- if ( selection() ) + if ( selection() ) { - ZyppPatch patch = selection()->zyppPatch(); - - if ( patch ) - { - ZyppPatchContents patchContents( patch ); - - for ( ZyppPatchContentsIterator it = patchContents.begin(); - it != patchContents.end(); - ++it ) - { - ZyppPkg pkg = tryCastToZyppPkg( *it ); + ZyppPatch patch = selection()->zyppPatch();
- if ( pkg ) - { - y2debug( "Found patch pkg: %s arch: %s", (*it)->name().c_str(), (*it)->arch().asString().c_str() ); - - ZyppSel sel = _selMapper.findZyppSel( pkg ); - - if ( sel ) - { - if ( contains( patchSelectables, sel ) ) - { - y2milestone( "Suppressing duplicate selectable %s-%s arch: %s", - (*it)->name().c_str(), - (*it)->edition().asString().c_str(), - (*it)->arch().asString().c_str() ); - } - else - { - patchSelectables.insert( sel ); - emit filterMatch( sel, pkg ); - } - } - else - y2error( "No selectable for pkg %s", (*it)->name().c_str() ); - } - else // No ZyppPkg - some other kind of object (script, message) - { - if ( zypp::isKindzypp::Script ( *it ) ) - { - y2debug( "Found patch script %s", (*it)->name().c_str() ); - emit filterMatch( _( "Script" ), fromUTF8( (*it)->name() ), -1 ); - } - else if ( zypp::isKindzypp::Message ( *it ) ) - { - y2debug( "Found patch message %s (ignoring)", (*it)->name().c_str() ); - } - else - { - y2error( "Found unknown object of kind %s in patch: %s-%s arch: %s", - (*it)->kind().asString().c_str(), - (*it)->name().c_str(), - (*it)->edition().asString().c_str(), - (*it)->arch().asString().c_str() ); - } - } - } - } + if ( patch ) + { + zypp::Patch::Contents contents(patch->contents()); + //y2milestone(contents.asString().c_str()); + + for ( zypp::Patch::Contents::Selectable_iterator it = contents.selectableBegin(); + it != contents.selectableEnd(); + ++it ) + { + ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() ); + if ( zyppPkg ) + { + emit filterMatch( *it, zyppPkg ); + } + } + } + else + { + y2milestone("patch is bogus"); + } + } + else + y2warning("selection empty");
- emit filterFinished(); + emit filterFinished(); }
- void YQPkgPatchList::addPatchItem( ZyppSel selectable, ZyppPatch zyppPatch ) @@ -555,7 +461,7 @@ if ( ! text.isEmpty() ) text += "\n";
- text += fromUTF8( zyppPatch()->size().asString().c_str() ); + text += fromUTF8( zyppPatch()->downloadSize().asString().c_str() ); } }
Modified: branches/tmp/dmacvicar/zc10/qt/src/YQPkgPatternList.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/qt/src/YQPk... ============================================================================== --- branches/tmp/dmacvicar/zc10/qt/src/YQPkgPatternList.cc (original) +++ branches/tmp/dmacvicar/zc10/qt/src/YQPkgPatternList.cc Thu Mar 24 12:36:13 2011 @@ -28,7 +28,6 @@ #include <zypp/Resolver.h> #include <qpainter.h> #include <qheader.h> -#include <zypp/ui/PatternContents.h>
#include "YQi18n.h" #include "utf8.h" @@ -152,44 +151,45 @@ filter(); }
- void YQPkgPatternList::filter() { - emit filterStart(); + emit filterStart();
- if ( selection() ) // The seleted QListViewItem + if ( selection() )// The seleted QListViewItem { - ZyppPattern zyppPattern = selection()->zyppPattern(); + ZyppPattern zyppPattern = selection()->zyppPattern();
- if ( zyppPattern ) - { - zypp::ui::PatternContents patternContents( zyppPattern ); - set<string> wanted = patternContents.install_packages(); - - for ( ZyppPoolIterator it = zyppPkgBegin(); - it != zyppPkgEnd(); - ++it ) - { - string name = (*it)->theObj()->name(); - - if ( contains( wanted, name ) ) - { - ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() ); - - if ( zyppPkg ) - { - emit filterMatch( *it, zyppPkg ); - } - } - } - } + if ( zyppPattern ) + { + int total = 0; + int installed = 0; + + zypp::Pattern::Contents c(zyppPattern->contents()); + for ( zypp::Pattern::Contents::Selectable_iterator it = c.selectableBegin(); + it != c.selectableEnd(); + ++it ) + { + ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() ); + if ( zyppPkg ) + { + if ( (*it)->installedSize() > 0 ) + ++installed; + ++total; + + emit filterMatch( *it, zyppPkg ); + } + } + //selection()->setInstalledPackages(installed); + //selection()->setTotalPackages(total); + //selection()->resetToolTip(); + } }
- emit filterFinished(); + emit filterFinished(); + //resizeColumnToContents(_howmanyCol); }
- void YQPkgPatternList::addPatternItem( ZyppSel selectable, ZyppPattern zyppPattern )
Modified: branches/tmp/dmacvicar/zc10/qt/src/YQPkgSearchFilterView.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/qt/src/YQPk... ============================================================================== --- branches/tmp/dmacvicar/zc10/qt/src/YQPkgSearchFilterView.cc (original) +++ branches/tmp/dmacvicar/zc10/qt/src/YQPkgSearchFilterView.cc Thu Mar 24 12:36:13 2011 @@ -28,6 +28,10 @@ #include <qvgroupbox.h> #include <qprogressdialog.h> #include <qdatetime.h> +#include <qmessagebox.h> +#include <qcursor.h> + +#include <zypp/PoolQuery.h>
#define y2log_component "qt-pkg" #include <ycp/y2log.h> @@ -93,6 +97,7 @@ _searchInName = new QCheckBox( _( "&Name" ), gbox ); CHECK_PTR( _searchInName ); _searchInSummary = new QCheckBox( _( "Su&mmary" ), gbox ); CHECK_PTR( _searchInSummary ); _searchInDescription = new QCheckBox( _( "Descr&iption" ), gbox ); CHECK_PTR( _searchInDescription ); + _searchInKeywords = new QCheckBox( _( "&Keywords" ), gbox ); CHECK_PTR( _searchInKeywords );
addVStretch( gbox );
@@ -100,6 +105,8 @@ _searchInProvides = new QCheckBox( "RPM "&Provides"" , gbox ); CHECK_PTR( _searchInProvides ); _searchInRequires = new QCheckBox( "RPM "Re&quires"" , gbox ); CHECK_PTR( _searchInRequires );
+ _searchInFileList = new QCheckBox( _( "File list"), gbox ); CHECK_PTR( _searchInFileList ); + _searchInName->setChecked( true ); _searchInSummary->setChecked( true );
@@ -187,81 +194,147 @@ filter(); }
- void YQPkgSearchFilterView::filter() { - emit filterStart(); - _matchCount = 0; - - if ( ! _searchText->currentText().isEmpty() ) - { - // Create a progress dialog that is only displayed if the search takes - // longer than a couple of seconds ( default: 4 ). - - QProgressDialog progress( _( "Searching..." ), // text - _( "&Cancel" ), // cancelButtonLabel -#ifdef FIXME - Y2PM::packageManager().size(), // totalSteps -#else - 1000, -#endif - this, 0, // parent, name - true ); // modal - progress.setCaption( "" ); - progress.setMinimumDuration( 2000 ); // millisec - QTime timer; - - QRegExp regexp = _searchText->currentText(); - regexp.setCaseSensitive( _caseSensitive->isChecked() ); - regexp.setWildcard( _searchMode->currentItem() == UseWildcards ); - - timer.start(); - - - int count = 0; - - for ( ZyppPoolIterator it = zyppPkgBegin(); - it != zyppPkgEnd(); - ++it ) - { - ZyppSel selectable = *it; - - 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 ); + emit filterStart(); + _matchCount = 0;
- - progress.setProgress( count++ ); - - if ( timer.elapsed() > 300 ) // milisec - { - // Process events only every 300 milliseconds - this is very - // expensive since both the progress dialog and the package - // list change all the time, thus display updates are necessary - // each time. - - qApp->processEvents(); - timer.restart(); - } - } - - if ( _matchCount == 0 ) - emit message( _( "No Results." ) ); - } + try + { + if ( ! _searchText->currentText().isEmpty() ) + { + // 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::ResKind::package); + + string searchtext = _searchText->currentText().ascii(); + + QProgressDialog progress( _( "Searching..." ),// text + _( "&Cancel" ),// cancelButtonLabel + 1000, + this// parent + ); + //progress.setWindowTitle( "" ); + progress.setMinimumDuration( 1500 ); // millisec + + // HACK, this should go to YQPackageSelector + parentWidget()->parentWidget()->setCursor(QCursor(Qt::WaitCursor)); + progress.setCursor(QCursor(Qt::ArrowCursor)); + + QTime timer; + query.setCaseSensitive( _caseSensitive->isChecked() ); + + switch ( _searchMode->currentItem() ) + { + case Contains: + query.setMatchSubstring(); + break; + case BeginsWith: + query.setMatchRegex(); + searchtext = "^" + searchtext; + break; + case ExactMatch: + query.setMatchExact(); + break; + case UseWildcards: + query.setMatchGlob(); + break; + case UseRegExp: + query.setMatchRegex(); + break; + + // Intentionally omitting "default" branch - let gcc watch for unhandled enums + } + + query.addString( searchtext ); + + 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() )query.addAttribute( zypp::sat::SolvAttr("solvable:requires") ); + if ( _searchInProvides->isChecked() )query.addAttribute( zypp::sat::SolvAttr("solvable:provides") ); + if ( _searchInFileList->isChecked() ) query.addAttribute( zypp::sat::SolvAttr::filelist ); + if ( _searchInKeywords->isChecked() ) query.addAttribute( zypp::sat::SolvAttr::keywords ); + + _searchText->setEnabled(false); + _searchButton->setEnabled(false); + + timer.start(); + + int count = 0; + + for ( zypp::PoolQuery::Selectable_iterator it = query.selectableBegin(); + it != query.selectableEnd() && ! progress.wasCanceled(); + ++it ) + { + ZyppSel selectable = *it; + ZyppPkg zyppPkg = tryCastToZyppPkg( selectable->theObj() ); + + if ( zyppPkg ) + { + _matchCount++; + emit filterMatch( selectable, zyppPkg ); + } + + if ( progress.wasCanceled() ) + break; + + progress.setProgress( count++ ); + + if ( timer.elapsed() > 300 ) // milisec + { + // Process events only every 300 milliseconds - this is very + // expensive since both the progress dialog and the package + // list change all the time, thus display updates are necessary + // each time. + + qApp->processEvents(); + timer.restart(); + } + } + + if ( _matchCount == 0 ) + emit message( _( "No Results." ) ); + } + } + catch ( const std::exception & exception ) + { + //y2warning("CAUGHT zypp exception: %s", exception.what().c_str()); + + QMessageBox msgBox; + + // Translators: This is a (short) text indicating that something went + // wrong while searching for packages. At this point, it is not clear + // if it's a user error (e.g., syntax error in regular expression) or + // an internal error. But there is a "Details" button that will return + // the original (translated) error message. + + QString heading = _( "Query Error" ); + + if ( heading.length() < 25 )// Avoid very narrow message boxes + { + QString blanks; + blanks.fill( ' ', 50 - heading.length() ); + heading += blanks; + } + + msgBox.setText( heading ); + msgBox.setIcon( QMessageBox::Warning ); + msgBox.setText( fromUTF8( exception.what() ) ); + msgBox.exec(); + } + + _searchText->setEnabled(true); + _searchButton->setEnabled(true); + parentWidget()->parentWidget()->setCursor(Qt::ArrowCursor);
emit filterFinished(); }
- bool YQPkgSearchFilterView::check( ZyppSel selectable, ZyppObj zyppObj ) @@ -340,22 +413,23 @@
bool -YQPkgSearchFilterView::check( const zypp::CapSet & capSet, const QRegExp & regexp ) +YQPkgSearchFilterView::check( const zypp::Capabilities& capSet, const QRegExp & regexp ) { - for ( zypp::CapSet::const_iterator it = capSet.begin(); - it != capSet.end(); - ++it ) + for ( zypp::Capabilities::const_iterator it = capSet.begin(); + it != capSet.end(); + ++it ) { - if ( check( ( *it).index(), regexp ) ) + zypp::CapDetail cap( *it ); + + if ( cap.isSimple() && check( cap.name().asString(), regexp ) ) { - // y2debug( "Match for %s", (*it).asString().c_str() ); - return true; + // yuiDebug() << "Match for " << (*it).asString() << endl; + return true; } }
- return false; + return false; }
- #include "YQPkgSearchFilterView.moc"
Modified: branches/tmp/dmacvicar/zc10/qt/src/YQPkgSelDescriptionView.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/qt/src/YQPk... ============================================================================== --- branches/tmp/dmacvicar/zc10/qt/src/YQPkgSelDescriptionView.cc (original) +++ branches/tmp/dmacvicar/zc10/qt/src/YQPkgSelDescriptionView.cc Thu Mar 24 12:36:13 2011 @@ -75,10 +75,9 @@ YQPkgSelDescriptionView::htmlHeading( ZyppSel selectable ) { ZyppObj zyppObj = selectable->theObj(); - ZyppSelection selection = tryCastToZyppSelection( zyppObj ); ZyppPattern pattern = tryCastToZyppPattern ( zyppObj );
- if ( ! selection && ! pattern ) + if ( ! pattern ) return YQPkgGenericDetailsView::htmlHeading( selectable );
QString summary = fromUTF8( zyppObj->summary() );
Modified: branches/tmp/dmacvicar/zc10/qt/src/YQPkgTechnicalDetailsView.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/qt/src/YQPk... ============================================================================== --- branches/tmp/dmacvicar/zc10/qt/src/YQPkgTechnicalDetailsView.cc (original) +++ branches/tmp/dmacvicar/zc10/qt/src/YQPkgTechnicalDetailsView.cc Thu Mar 24 12:36:13 2011 @@ -118,79 +118,75 @@ return translated.join( "/" ); }
- QString YQPkgTechnicalDetailsView::simpleTable( ZyppSel selectable, - ZyppPkg pkg ) + ZyppPkg pkg ) { - QString html = "<br>" + - table( - row( hcell( _( "Version:" ) ) + cell( pkg->edition().asString() ) ) + - row( hcell( _( "Build Time:" ) ) + cell( pkg->buildtime() ) ) + - ( pkg == selectable->installedObj() ? - row( hcell( _( "Install Time:" ) ) + cell( pkg->installtime() ) ) - : "" ) + - row( hcell( _( "Package Group:" ) ) + cell( formatRpmGroup( pkg ) ) ) + - row( hcell( _( "License:" ) ) + cell( pkg->license() ) ) + - row( hcell( _( "Installed Size:" ) ) + cell( pkg->size().asString() ) ) + - row( hcell( _( "Archive Size:" ) ) + cell( pkg->archivesize().asString() ) ) + - row( hcell( _( "Distribution:" ) ) + cell( pkg->distribution() ) ) + - row( hcell( _( "Vendor:" ) ) + cell( pkg->vendor() ) ) + - row( hcell( _( "Packager:" ) ) + cell( pkg->packager() ) ) + - row( hcell( _( "Architecture:" ) ) + cell( pkg->arch().asString() ) ) + - row( hcell( _( "OS:" ) ) + cell( pkg->os() ) ) + - row( hcell( _( "Build Host:" ) ) + cell( pkg->buildhost() ) ) + - row( hcell( _( "URL:" ) ) + cell( pkg->url() ) ) + -#ifdef FIXME_missing_in_zypp - row( hcell( _( "Source RPM:" ) ) + cell( pkg->sourceloc() ) ) + -#endif - row( hcell( _( "Media No.:" ) ) + cell( pkg->sourceMediaNr() ) ) + - row( hcell( _( "Authors:" ) ) + authorsListCell( pkg ) ) - ); + QString html; + + html += row( hcell( _( "Version:") ) + cell( pkg->edition().asString()) ); + html += row( hcell( _( "Build Time:") ) + cell( pkg->buildtime()) ); + + html += + pkg == selectable->installedObj() ? + row( hcell( _( "Install Time:" ) ) + cell( pkg->installtime() ) ) : ""; + + html += row( hcell( _( "Package Group:") ) + cell( formatRpmGroup( pkg )) ); + html += row( hcell( _( "License:") ) + cell( pkg->license()) ); + html += row( hcell( _( "Installed Size:" ) ) + cell( pkg->installSize().asString()) ); + html += row( hcell( _( "Download Size:" ) ) + cell( pkg->downloadSize().asString()) ); + html += row( hcell( _( "Distribution:") ) + cell( pkg->distribution()) ); + html += row( hcell( _( "Vendor:") ) + cell( pkg->vendor()) ); + html += row( hcell( _( "Packager:") ) + cell( pkg->packager()) ); + html += row( hcell( _( "Architecture:") ) + cell( pkg->arch().asString()) ); + html += row( hcell( _( "Build Host:") ) + cell( pkg->buildhost()) ); + html += row( hcell( _( "URL:") ) + cell( pkg->url()) ); + html += row( hcell( _( "Source Package:" ) ) + cell( pkg->sourcePkgName() + "-" + pkg->sourcePkgEdition().asString() ) ); + html += row( hcell( _( "Media No.:") ) + cell( pkg->mediaNr()) ); + html += row( hcell( _( "Authors:") ) + authorsListCell( pkg) ); + + html = "<br>" + table( html );
return html; }
- QString -YQPkgTechnicalDetailsView::complexTable( ZyppSel selectable, - ZyppPkg installed, - ZyppPkg candidate ) +YQPkgTechnicalDetailsView::complexTable( ZyppSel selectable, + ZyppPkg installed, + ZyppPkg candidate ) { - ZyppPkg p1 = candidate; - ZyppPkg p2 = installed; + ZyppPkg p1 = candidate; + ZyppPkg p2 = installed;
- QString p1_header = _( "<b>Alternate Version</b>" ); - QString p2_header = _( "<b>Installed Version</b>" ); + QString p1_header = _( "<b>Alternate Version</b>" ); + QString p2_header = _( "<b>Installed Version</b>" );
- QString html = "<br>" + - table( - row( hcell( QString( "" ) ) + hcell( "<b>" + p1_header + "</b>" ) + hcell( "<b>" + p2_header + "</b>" ) ) + - - row( hcell( _( "Version:" ) ) + cell( p1->edition().asString() ) + cell( p2->edition().asString() ) ) + - row( hcell( _( "Build Time:" ) ) + cell( p1->buildtime() ) + cell( p2->buildtime() ) ) + - row( hcell( _( "Install Time:" ) ) + cell( p1->installtime() ) + cell( p2->installtime() ) ) + - row( hcell( _( "Package Group:" ) ) + cell( formatRpmGroup( p1 ) ) + cell( formatRpmGroup( p2 ) ) ) + - row( hcell( _( "License:" ) ) + cell( p1->license() ) + cell( p2->license() ) ) + - row( hcell( _( "Installed Size:" ) ) + cell( p1->size().asString() ) + cell( p2->size().asString() ) ) + - row( hcell( _( "Archive Size:" ) ) + cell( p1->archivesize().asString() ) + cell( p2->archivesize().asString() ) ) + - row( hcell( _( "Distribution:" ) ) + cell( p1->distribution() ) + cell( p2->distribution() ) ) + - row( hcell( _( "Vendor:" ) ) + cell( p1->vendor() ) + cell( p2->vendor() ) ) + - row( hcell( _( "Packager:" ) ) + cell( p1->packager() ) + cell( p2->packager() ) ) + - row( hcell( _( "Architecture:" ) ) + cell( p1->arch().asString() ) + cell( p2->arch().asString() ) ) + - row( hcell( _( "OS:" ) ) + cell( p1->os() ) + cell( p2->os() ) ) + - row( hcell( _( "Build Host:" ) ) + cell( p1->buildhost() ) + cell( p2->buildhost() ) ) + - row( hcell( _( "URL:" ) ) + cell( p1->url() ) + cell( p2->url() ) ) + -#ifdef FIXME_missing_in_zypp - row( hcell( _( "Source RPM:" ) ) + cell( p1->sourceloc() ) + cell( p2->sourceloc() ) ) + -#endif - row( hcell( _( "Media No.:" ) ) + cell( p1->sourceMediaNr() ) + cell( p2->sourceMediaNr() ) ) + - row( hcell( _( "Authors:" ) ) + authorsListCell( p1 ) + authorsListCell( p2 ) ) - ); + QString html;
- return html; + html += row( hcell( QString( "" ) ) + hcell( "<b>" + p1_header + "</b>" ) + hcell( "<b>" + p2_header + "</b>") ); + + html += row( hcell( _( "Version:") ) + cell( p1->edition().asString()) + cell( p2->edition().asString()) ); + html += row( hcell( _( "Build Time:") ) + cell( p1->buildtime()) + cell( p2->buildtime()) ); + html += row( hcell( _( "Install Time:") ) + cell( p1->installtime()) + cell( p2->installtime()) ); + html += row( hcell( _( "Package Group:") ) + cell( formatRpmGroup( p1 )) + cell( formatRpmGroup( p2 )) ); + html += row( hcell( _( "License:") ) + cell( p1->license()) + cell( p2->license()) ); + html += row( hcell( _( "Installed Size:" ) ) + cell( p1->installSize().asString()) + cell( p2->installSize().asString()) ); + html += row( hcell( _( "Download Size:" ) ) + cell( p1->downloadSize().asString()) + cell( p2->downloadSize().asString()) ); + html += row( hcell( _( "Distribution:") ) + cell( p1->distribution()) + cell( p2->distribution()) ); + html += row( hcell( _( "Vendor:") ) + cell( p1->vendor()) + cell( p2->vendor()) ); + html += row( hcell( _( "Packager:") ) + cell( p1->packager()) + cell( p2->packager()) ); + html += row( hcell( _( "Architecture:") ) + cell( p1->arch().asString()) + cell( p2->arch().asString()) ); + html += row( hcell( _( "Build Host:") ) + cell( p1->buildhost()) + cell( p2->buildhost()) ); + html += row( hcell( _( "URL:") ) + cell( p1->url()) + cell( p2->url()) ); + html += row( hcell( _( "Source Package:") ) + cell( p1->sourcePkgName() + "-" + p1->sourcePkgEdition().asString() ) + + cell( p2->sourcePkgName() + "-" + p2->sourcePkgEdition().asString()) ); + html += row( hcell( _( "Media No.:") ) + cell( p1->mediaNr()) + cell( p2->mediaNr()) ); + html += row( hcell( _( "Authors:") ) + authorsListCell( p1) + authorsListCell( p2) ); + + + html = "<br>" + table( html ); + + return html; }
- - #include "YQPkgTechnicalDetailsView.moc"
Modified: branches/tmp/dmacvicar/zc10/qt/src/include/YQPkgLangList.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/qt/src/incl... ============================================================================== --- branches/tmp/dmacvicar/zc10/qt/src/include/YQPkgLangList.h (original) +++ branches/tmp/dmacvicar/zc10/qt/src/include/YQPkgLangList.h Thu Mar 24 12:36:13 2011 @@ -158,13 +158,6 @@ **/ virtual void cycleStatus();
- /** - * Sorting function. Redefined here (bnc#428355) as the one from - * parent YQPkgObjList can't be used - it refers to zyppObj's which - * are NULL here as zypp::Locale is not zypp::ResObject anymore - **/ - virtual bool operator< ( const QListViewItem & other ) const; - protected:
/**
Modified: branches/tmp/dmacvicar/zc10/qt/src/include/YQPkgObjList.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/qt/src/incl... ============================================================================== --- branches/tmp/dmacvicar/zc10/qt/src/include/YQPkgObjList.h (original) +++ branches/tmp/dmacvicar/zc10/qt/src/include/YQPkgObjList.h Thu Mar 24 12:36:13 2011 @@ -354,6 +354,9 @@ ZyppSel selectable, ZyppObj zyppObj = 0 );
+ YQPkgObjListItem( YQPkgObjList * pkgObjList ); + + protected: /** * Constructor for non-root items.
Modified: branches/tmp/dmacvicar/zc10/qt/src/include/YQPkgSearchFilterView.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/zc10/qt/src/incl... ============================================================================== --- branches/tmp/dmacvicar/zc10/qt/src/include/YQPkgSearchFilterView.h (original) +++ branches/tmp/dmacvicar/zc10/qt/src/include/YQPkgSearchFilterView.h Thu Mar 24 12:36:13 2011 @@ -160,11 +160,13 @@ QComboBox * _searchText; QPushButton * _searchButton;
- QCheckBox * _searchInName; - QCheckBox * _searchInSummary; - QCheckBox * _searchInDescription; - QCheckBox * _searchInRequires; - QCheckBox * _searchInProvides; + QCheckBox *_searchInName; + QCheckBox *_searchInKeywords; + QCheckBox *_searchInSummary; + QCheckBox *_searchInDescription; + QCheckBox *_searchInRequires; + QCheckBox *_searchInProvides; + QCheckBox *_searchInFileList;
QComboBox * _searchMode; QCheckBox * _caseSensitive;
yast-commit@lists.opensuse.org