1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
17 Textdomain "packages-qt"
21 #define y2log_component "qt-pkg"
22 #include <ycp/y2log.h>
25 #include <q3popupmenu.h>
32 #include "YQPkgObjList.h"
33 #include "YQPkgTextDialog.h"
35 #include "YQIconPool.h"
42 #define VERBOSE_EXCLUDE_RULES 0
43 #define EXTRA_SOLVE_COLLECTIONS 0
46 YQPkgObjList::YQPkgObjList( QWidget * parent )
47 : QY2ListView( parent )
49 , _installedContextMenu(0)
50 , _notInstalledContextMenu(0)
52 // This class does not add any columns. This is the main reason why this is
53 // an abstract base class: It doesn't know which columns are desired and in
59 _instVersionCol = -42;
63 _satisfiedIconCol = -42;
66 _excludedItems = new YQPkgObjList::ExcludedItems( this );
70 connect( this, SIGNAL( columnClicked ( int, Q3ListViewItem *, int, const QPoint & ) ),
71 this, SLOT ( pkgObjClicked ( int, Q3ListViewItem *, int, const QPoint & ) ) );
73 connect( this, SIGNAL( columnDoubleClicked ( int, Q3ListViewItem *, int, const QPoint & ) ),
74 this, SLOT ( pkgObjClicked ( int, Q3ListViewItem *, int, const QPoint & ) ) );
76 connect( this, SIGNAL( selectionChanged ( Q3ListViewItem * ) ),
77 this, SLOT ( selectionChangedInternal( Q3ListViewItem * ) ) );
81 YQPkgObjList::~YQPkgObjList()
84 delete _excludedItems;
89 YQPkgObjList::addPkgObjItem( ZyppSel selectable, ZyppObj zyppObj )
93 y2error( "Null zypp::ui::Selectable!" );
97 YQPkgObjListItem * item = new YQPkgObjListItem( this, selectable, zyppObj );
98 applyExcludeRules( item );
103 YQPkgObjList::addPassiveItem( const QString & name,
104 const QString & summary,
107 QY2ListViewItem * item = new QY2ListViewItem( this, QString::null );
111 if ( nameCol() >= 0 && ! name.isEmpty() ) item->setText( nameCol(), name );
112 if ( summaryCol() >= 0 && ! summary.isEmpty() ) item->setText( summaryCol(), summary );
113 if ( sizeCol() >= 0 && size > 0L )
115 QString sizeStr = size.form().c_str();
117 item->setText( sizeCol(), sizeStr );
124 YQPkgObjList::pkgObjClicked( int button,
125 Q3ListViewItem * listViewItem,
129 YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (listViewItem);
133 if ( button == Qt::LeftButton )
135 if ( col == statusCol() )
136 // || col == nameCol() )
138 if ( editable() && item->editable() )
142 else if ( button == Qt::RightButton )
144 if ( editable() && item->editable() )
146 updateActions( item );
148 Q3PopupMenu * contextMenu =
149 item->selectable()->hasInstalledObj() ?
150 installedContextMenu() : notInstalledContextMenu();
153 contextMenu->popup( pos );
161 YQPkgObjList::selectionChangedInternal( Q3ListViewItem * listViewItem )
163 YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (listViewItem);
165 emit selectionChanged( item ? item->selectable() : ZyppSel() );
170 YQPkgObjList::clear()
172 emit selectionChanged( ZyppSel() );
174 _excludedItems->clear();
175 QY2ListView::clear();
180 YQPkgObjList::statusIcon( ZyppStatus status, bool enabled, bool bySelection )
182 QPixmap icon = YQIconPool::pkgNoInst();
188 case S_Del: icon = YQIconPool::pkgDel(); break;
189 case S_Install: icon = YQIconPool::pkgInstall(); break;
190 case S_KeepInstalled: icon = YQIconPool::pkgKeepInstalled(); break;
191 case S_NoInst: icon = YQIconPool::pkgNoInst(); break;
192 case S_Protected: icon = YQIconPool::pkgProtected(); break;
193 case S_Taboo: icon = YQIconPool::pkgTaboo(); break;
194 case S_Update: icon = YQIconPool::pkgUpdate(); break;
196 case S_AutoDel: icon = bySelection ?
197 YQIconPool::pkgSelAutoDel() :
198 YQIconPool::pkgAutoDel(); break;
200 case S_AutoInstall: icon = bySelection ?
201 YQIconPool::pkgSelAutoInstall() :
202 YQIconPool::pkgAutoInstall(); break;
204 case S_AutoUpdate: icon = bySelection ?
205 YQIconPool::pkgSelAutoUpdate() :
206 YQIconPool::pkgAutoUpdate(); break;
209 // Intentionally omitting 'default' branch so the compiler can
210 // catch unhandled enum states
217 case S_Del: icon = YQIconPool::disabledPkgDel(); break;
218 case S_Install: icon = YQIconPool::disabledPkgInstall(); break;
219 case S_KeepInstalled: icon = YQIconPool::disabledPkgKeepInstalled(); break;
220 case S_NoInst: icon = YQIconPool::disabledPkgNoInst(); break;
221 case S_Protected: icon = YQIconPool::disabledPkgProtected(); break;
222 case S_Taboo: icon = YQIconPool::disabledPkgTaboo(); break;
223 case S_Update: icon = YQIconPool::disabledPkgUpdate(); break;
225 case S_AutoDel: icon = bySelection ?
226 YQIconPool::disabledPkgSelAutoDel() :
227 YQIconPool::disabledPkgAutoDel(); break;
229 case S_AutoInstall: icon = bySelection ?
230 YQIconPool::disabledPkgSelAutoInstall() :
231 YQIconPool::disabledPkgAutoInstall(); break;
233 case S_AutoUpdate: icon = bySelection ?
234 YQIconPool::disabledPkgSelAutoUpdate() :
235 YQIconPool::disabledPkgAutoUpdate(); break;
237 // Intentionally omitting 'default' branch so the compiler can
238 // catch unhandled enum states
247 YQPkgObjList::statusText( ZyppStatus status ) const
251 case S_AutoDel: return _( "Autodelete" );
252 case S_AutoInstall: return _( "Autoinstall" );
253 case S_AutoUpdate: return _( "Autoupdate" );
254 case S_Del: return _( "Delete" );
255 case S_Install: return _( "Install" );
256 case S_KeepInstalled: return _( "Keep" );
257 case S_NoInst: return _( "Do Not Install" );
258 case S_Protected: return _( "Protected -- Do Not Modify" );
259 case S_Taboo: return _( "Taboo -- Never Install" );
260 case S_Update: return _( "Update" );
263 return QString::null;
268 YQPkgObjList::setCurrentStatus( ZyppStatus newStatus, bool doSelectNextItem )
270 Q3ListViewItem * listViewItem = selectedItem();
272 if ( ! listViewItem )
275 YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (listViewItem);
277 if ( item && item->editable() && _editable )
279 if ( newStatus != item->status() )
281 item->setStatus( newStatus );
283 if ( item->showLicenseAgreement() )
285 item->showNotifyTexts( newStatus );
287 else // License not confirmed?
289 // Status is now S_Taboo or S_Del - update status icon
290 item->setStatusIcon();
293 emit statusChanged();
297 if ( doSelectNextItem )
303 YQPkgObjList::setAllItemStatus( ZyppStatus newStatus, bool force )
308 YQUI::ui()->busyCursor();
309 Q3ListViewItemIterator it( this );
313 YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (*it);
315 if ( item && item->editable() && newStatus != item->status() )
317 if ( newStatus == S_Update )
319 if ( item->candidateIsNewer() || force )
320 item->setStatus( newStatus,
321 false ); // sendSignals
325 item->setStatus( newStatus,
326 false ); // sendSignals
333 emit updateItemStates();
334 emit updatePackages();
336 YQUI::ui()->normalCursor();
337 emit statusChanged();
342 YQPkgObjList::selectNextItem()
344 Q3ListViewItem * item = selectedItem();
346 if ( item && item->nextSibling() )
348 item->setSelected( false ); // Doesn't emit signals
349 ensureItemVisible( item->nextSibling() ); // Scroll if necessary
350 setSelected( item->nextSibling(), true ); // Emits signals
356 YQPkgObjList::createActions()
358 actionSetCurrentInstall = createAction( S_Install, "[+]" );
359 actionSetCurrentDontInstall = createAction( S_NoInst, "[-]" );
360 actionSetCurrentKeepInstalled = createAction( S_KeepInstalled, "[<], [-]" );
361 actionSetCurrentDelete = createAction( S_Del, "[-]" );
362 actionSetCurrentUpdate = createAction( S_Update, "[>], [+]" );
363 actionSetCurrentTaboo = createAction( S_Taboo, "[!]" );
364 actionSetCurrentProtected = createAction( S_Protected, "[*]" );
366 actionSetListInstall = createAction( S_Install, "", true );
367 actionSetListDontInstall = createAction( S_NoInst, "", true );
368 actionSetListKeepInstalled = createAction( S_KeepInstalled, "", true );
369 actionSetListDelete = createAction( S_Del, "", true );
370 actionSetListProtected = createAction( S_Protected, "", true );
372 actionSetListUpdate = createAction( _( "Update if newer version available" ),
373 statusIcon( S_Update, true ),
374 statusIcon( S_Update, false ),
378 actionSetListUpdateForce = createAction( _( "Update unconditionally" ),
379 statusIcon( S_Update, true ),
380 statusIcon( S_Update, false ),
384 actionSetListTaboo = createAction( S_Taboo, "", true );
386 connect( actionSetCurrentInstall, SIGNAL( activated() ), this, SLOT( setCurrentInstall() ) );
387 connect( actionSetCurrentDontInstall, SIGNAL( activated() ), this, SLOT( setCurrentDontInstall() ) );
388 connect( actionSetCurrentKeepInstalled, SIGNAL( activated() ), this, SLOT( setCurrentKeepInstalled() ) );
389 connect( actionSetCurrentDelete, SIGNAL( activated() ), this, SLOT( setCurrentDelete() ) );
390 connect( actionSetCurrentUpdate, SIGNAL( activated() ), this, SLOT( setCurrentUpdate() ) );
391 connect( actionSetCurrentTaboo, SIGNAL( activated() ), this, SLOT( setCurrentTaboo() ) );
392 connect( actionSetCurrentProtected, SIGNAL( activated() ), this, SLOT( setCurrentProtected() ) );
394 connect( actionSetListInstall, SIGNAL( activated() ), this, SLOT( setListInstall() ) );
395 connect( actionSetListDontInstall, SIGNAL( activated() ), this, SLOT( setListDontInstall() ) );
396 connect( actionSetListKeepInstalled, SIGNAL( activated() ), this, SLOT( setListKeepInstalled() ) );
397 connect( actionSetListDelete, SIGNAL( activated() ), this, SLOT( setListDelete() ) );
398 connect( actionSetListUpdate, SIGNAL( activated() ), this, SLOT( setListUpdate() ) );
399 connect( actionSetListUpdateForce, SIGNAL( activated() ), this, SLOT( setListUpdateForce() ) );
400 connect( actionSetListTaboo, SIGNAL( activated() ), this, SLOT( setListTaboo() ) );
401 connect( actionSetListProtected, SIGNAL( activated() ), this, SLOT( setListProtected() ) );
407 YQPkgObjList::createAction( ZyppStatus status, const QString & key, bool enabled )
409 return createAction( statusText( status ),
410 statusIcon( status, true ),
411 statusIcon( status, false ),
418 YQPkgObjList::createAction( const QString & text,
419 const QPixmap & icon,
420 const QPixmap & insensitiveIcon,
424 QString label = text;
426 if ( ! key.isEmpty() )
430 QIcon iconSet ( icon );
432 if ( ! insensitiveIcon.isNull() )
434 iconSet.setPixmap( insensitiveIcon,
439 Q3Action * action = new Q3Action( label, // text
444 Q_CHECK_PTR( action );
445 action->setEnabled( enabled );
452 YQPkgObjList::createNotInstalledContextMenu()
454 _notInstalledContextMenu = new Q3PopupMenu( this );
455 Q_CHECK_PTR( _notInstalledContextMenu );
457 actionSetCurrentInstall->addTo( _notInstalledContextMenu );
458 actionSetCurrentDontInstall->addTo( _notInstalledContextMenu );
459 actionSetCurrentTaboo->addTo( _notInstalledContextMenu );
461 addAllInListSubMenu( _notInstalledContextMenu );
466 YQPkgObjList::createInstalledContextMenu()
468 _installedContextMenu = new Q3PopupMenu( this );
469 Q_CHECK_PTR( _installedContextMenu );
471 actionSetCurrentKeepInstalled->addTo( _installedContextMenu );
472 actionSetCurrentDelete->addTo( _installedContextMenu );
473 actionSetCurrentUpdate->addTo( _installedContextMenu );
475 addAllInListSubMenu( _installedContextMenu );
480 YQPkgObjList::addAllInListSubMenu( Q3PopupMenu * menu )
482 Q3PopupMenu * submenu = new Q3PopupMenu( menu );
483 Q_CHECK_PTR( submenu );
485 actionSetListInstall->addTo( submenu );
486 actionSetListDontInstall->addTo( submenu );
487 actionSetListKeepInstalled->addTo( submenu );
488 actionSetListDelete->addTo( submenu );
489 actionSetListUpdate->addTo( submenu );
490 actionSetListUpdateForce->addTo( submenu );
491 actionSetListTaboo->addTo( submenu );
493 menu->insertItem( _( "&All in This List" ), submenu );
500 YQPkgObjList::notInstalledContextMenu()
502 if ( ! _notInstalledContextMenu )
503 createNotInstalledContextMenu();
505 return _notInstalledContextMenu;
510 YQPkgObjList::installedContextMenu()
512 if ( ! _installedContextMenu )
513 createInstalledContextMenu();
515 return _installedContextMenu;
520 YQPkgObjList::updateActions()
522 updateActions( dynamic_cast<YQPkgObjListItem *> ( selectedItem() ) );
527 YQPkgObjList::updateActions( YQPkgObjListItem * item )
531 ZyppSel selectable = item->selectable();
533 if ( selectable->hasInstalledObj() )
535 actionSetCurrentInstall->setEnabled( false );
536 actionSetCurrentDontInstall->setEnabled( false );
537 actionSetCurrentTaboo->setEnabled( false );
538 actionSetCurrentProtected->setEnabled( true );
540 actionSetCurrentKeepInstalled->setEnabled( true );
541 actionSetCurrentDelete->setEnabled( true );
542 actionSetCurrentUpdate->setEnabled( selectable->hasCandidateObj() );
546 actionSetCurrentInstall->setEnabled( selectable->hasCandidateObj() );
547 actionSetCurrentDontInstall->setEnabled( true );
548 actionSetCurrentTaboo->setEnabled( true );
549 actionSetCurrentProtected->setEnabled( false );
551 actionSetCurrentKeepInstalled->setEnabled( false );
552 actionSetCurrentDelete->setEnabled( false );
553 actionSetCurrentUpdate->setEnabled( false );
558 actionSetCurrentInstall->setEnabled( false );
559 actionSetCurrentDontInstall->setEnabled( false );
560 actionSetCurrentTaboo->setEnabled( false );
562 actionSetCurrentKeepInstalled->setEnabled( false );
563 actionSetCurrentDelete->setEnabled( false );
564 actionSetCurrentUpdate->setEnabled( false );
565 actionSetCurrentProtected->setEnabled( false );
571 YQPkgObjList::keyPressEvent( QKeyEvent * event )
575 unsigned special_combo = ( Qt::ControlButton | Qt::ShiftButton | Qt::AltButton );
577 if ( ( event->state() & special_combo ) == special_combo )
579 if ( event->key() == Qt::Key_Q )
582 y2milestone( "Debug mode %s", _debug ? "on" : "off" );
587 Q3ListViewItem * selectedListViewItem = selectedItem();
589 if ( selectedListViewItem )
591 YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (selectedListViewItem);
595 bool installed = item->selectable()->hasInstalledObj();
596 ZyppStatus status = item->status();
598 switch( event->ascii() )
600 case Qt::Key_Space: // Cycle
605 case '+': // Grab everything - install or update
609 ZyppStatus newStatus = S_KeepInstalled;
611 if ( item->candidateIsNewer() )
612 newStatus = S_Update;
614 setCurrentStatus( newStatus );
617 setCurrentStatus( S_Install );
622 case '-': // Get rid of everything - don't install or delete
623 setCurrentStatus( installed ? S_Del : S_NoInst );
631 setCurrentStatus( S_Taboo );
636 case '*': // Protected
639 setCurrentStatus( S_Protected );
644 case '>': // Update what is worth to be updated
646 if ( installed && item->candidateIsNewer() )
647 setCurrentStatus( S_Update );
652 case '<': // Revert update
654 if ( status == S_Update ||
655 status == S_AutoUpdate )
657 setCurrentStatus( S_KeepInstalled );
664 case 'B': // Toggle debugIsBroken flag
668 item->toggleDebugIsBroken();
669 item->setStatusIcon();
675 case 'S': // Toggle debugIsSatisfied flag
679 item->toggleDebugIsSatisfied();
680 item->setStatusIcon();
689 Q3ListView::keyPressEvent( event );
694 YQPkgObjList::message( const QString & text )
696 QY2ListViewItem * item = new QY2ListViewItem( this );
699 item->setText( nameCol() >= 0 ? nameCol() : 0, text );
700 item->setBackgroundColor( QColor( 0xE0, 0xE0, 0xF8 ) );
705 YQPkgObjList::addExcludeRule( YQPkgObjList::ExcludeRule * rule )
707 _excludeRules.push_back( rule );
712 YQPkgObjList::applyExcludeRules()
714 // y2debug( "Applying exclude rules" );
715 Q3ListViewItemIterator listView_it( this );
717 while ( *listView_it )
719 Q3ListViewItem * current_item = *listView_it;
721 // Advance iterator now so it remains valid even if there are changes
722 // to the QListView, e.g., if the current item is excluded and thus
723 // removed from the QListView
726 applyExcludeRules( current_item );
729 ExcludedItems::iterator excluded_it = _excludedItems->begin();
731 while ( excluded_it != _excludedItems->end() )
733 Q3ListViewItem * current_item = (*excluded_it).first;
735 // Advance iterator now so it remains valid even if there are changes
736 // to the excluded items, e.g., if the current item is un-excluded and thus
737 // removed from the excluded items
740 applyExcludeRules( current_item );
743 logExcludeStatistics();
748 YQPkgObjList::logExcludeStatistics()
750 if ( _excludedItems->size() > 0 )
752 y2milestone( "%d packages excluded", _excludedItems->size() );
754 for ( ExcludeRuleList::iterator rule_it = _excludeRules.begin();
755 rule_it != _excludeRules.end();
758 ExcludeRule * rule = *rule_it;
760 if ( rule->isEnabled() )
762 y2milestone( "Active exclude rule: \"%s\"",
763 rule->regexp().pattern().ascii() );
771 YQPkgObjList::applyExcludeRules( Q3ListViewItem * listViewItem )
773 YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *>( listViewItem );
777 bool exclude = false;
778 ExcludeRule * matchingRule = 0;
780 for ( ExcludeRuleList::iterator rule_it = _excludeRules.begin();
781 rule_it != _excludeRules.end() && ! exclude;
784 ExcludeRule * rule = *rule_it;
786 if ( rule->match( item ) )
793 if ( exclude != item->isExcluded() ) // change exclude status?
795 this->exclude( item, exclude );
797 #if VERBOSE_EXCLUDE_RULES
800 y2debug( "Rule %s matches: Excluding %s",
801 matchingRule->regexp().pattern().ascii(),
802 item->zyppObj()->name().c_str() );
806 y2debug( "Un-excluding %s", item->zyppObj()->name().c_str() );
815 YQPkgObjList::exclude( YQPkgObjListItem * item, bool exclude )
817 if ( exclude == item->isExcluded() )
820 item->setExcluded( exclude );
824 Q3ListViewItem * parentItem = item->parent();
827 parentItem->takeItem( item );
829 Q3ListView::takeItem( item );
831 _excludedItems->add( item, parentItem );
835 if ( _excludedItems->contains( item ) )
837 Q3ListViewItem * oldParent = _excludedItems->oldParentItem( item );
838 _excludedItems->remove( item );
841 oldParent->insertItem( item );
843 Q3ListView::insertItem( item );
851 YQPkgObjListItem::YQPkgObjListItem( YQPkgObjList * pkgObjList,
854 : QY2ListViewItem( pkgObjList )
855 , _pkgObjList( pkgObjList )
856 , _selectable( selectable )
857 , _zyppObj( zyppObj )
865 YQPkgObjListItem::YQPkgObjListItem( YQPkgObjList * pkgObjList,
866 QY2ListViewItem * parent,
869 : QY2ListViewItem( parent )
870 , _pkgObjList( pkgObjList )
871 , _selectable( selectable )
872 , _zyppObj( zyppObj )
880 YQPkgObjListItem::~YQPkgObjListItem()
887 YQPkgObjListItem::init()
889 if ( _zyppObj == 0 && _selectable )
890 _zyppObj = _selectable->theObj();
892 _debugIsBroken = false;
893 _debugIsSatisfied = false;
894 _candidateIsNewer = false;
895 _installedIsNewer = false;
897 const ZyppObj candidate = selectable()->candidateObj();
898 const ZyppObj installed = selectable()->installedObj();
900 if ( candidate && installed )
902 if ( candidate->edition() < installed->edition() )
903 _installedIsNewer = true;
904 else if ( installed->edition() < candidate->edition() )
905 _candidateIsNewer = true;
908 if ( nameCol() >= 0 ) setText( nameCol(), zyppObj()->name() );
909 if ( summaryCol() >= 0 ) setText( summaryCol(), zyppObj()->summary() );
911 if ( sizeCol() >= 0 )
913 zypp::ByteCount size = zyppObj()->size();
916 setText( sizeCol(), size.asString() + " " );
919 if ( instVersionCol() >= 0 )
921 if ( selectable()->hasInstalledObj() )
922 setText( instVersionCol(), installed->edition() );
924 if ( zyppObj() != selectable()->installedObj() &&
925 zyppObj() != selectable()->candidateObj() )
927 setText( versionCol(), zyppObj()->edition() );
929 else if ( selectable()->hasCandidateObj() )
931 setText( versionCol(), candidate->edition() );
936 setText( versionCol(), zyppObj()->edition() );
944 YQPkgObjListItem::updateData()
951 YQPkgObjListItem::setText( int column, const string text )
953 Q3ListViewItem::setText( column, fromUTF8( text.c_str() ) );
958 YQPkgObjListItem::setText( int column, const zypp::Edition & edition )
960 setText( column, edition.asString() );
965 YQPkgObjListItem::status() const
967 if ( ! selectable() )
969 y2error( "No selectable" );
973 return selectable()->status();
978 YQPkgObjListItem::bySelection() const
980 zypp::ResStatus::TransactByValue modifiedBy = selectable()->modifiedBy();
982 return ( modifiedBy == zypp::ResStatus::APPL_LOW ||
983 modifiedBy == zypp::ResStatus::APPL_HIGH );
988 YQPkgObjListItem::setStatus( ZyppStatus newStatus, bool sendSignals )
990 ZyppStatus oldStatus = selectable()->status();
991 selectable()->set_status( newStatus );
993 if ( oldStatus != selectable()->status() )
999 _pkgObjList->updateItemStates();
1000 _pkgObjList->sendUpdatePackages();
1009 YQPkgObjListItem::solveResolvableCollections()
1011 #if EXTRA_SOLVE_COLLECTIONS
1012 zypp::Resolver_Ptr resolver = zypp::getZYpp()->resolver();
1014 resolver->transactReset( zypp::ResStatus::APPL_LOW );
1016 resolver->transactResKind( zypp::ResTraits<zypp::Product >::kind );
1017 resolver->transactResKind( zypp::ResTraits<zypp::Selection>::kind );
1018 resolver->transactResKind( zypp::ResTraits<zypp::Pattern >::kind );
1019 resolver->transactResKind( zypp::ResTraits<zypp::Language >::kind );
1020 resolver->transactResKind( zypp::ResTraits<zypp::Patch >::kind );
1021 resolver->transactResKind( zypp::ResTraits<zypp::Atom >::kind );
1028 YQPkgObjListItem::updateStatus()
1035 YQPkgObjListItem::setStatusIcon()
1037 if ( statusCol() >= 0 )
1039 bool enabled = editable() && _pkgObjList->editable();
1040 setPixmap( statusCol(), _pkgObjList->statusIcon( status(), enabled, bySelection() ) );
1044 if ( brokenIconCol() >= 0 )
1046 // Reset this icon now - it might be the same column as satisfiedIconCol()
1047 setPixmap( brokenIconCol(), QPixmap() );
1050 if ( satisfiedIconCol() >= 0 )
1052 // Set special icon for zyppObjs that are not marked as installed,
1053 // but satisfied anyway (e.g. for patches or patterns where the user
1054 // selected all required packages manually)
1056 setPixmap( satisfiedIconCol(), isSatisfied() ? YQIconPool::pkgSatisfied() : QPixmap() );
1059 if ( brokenIconCol() >= 0 )
1061 // Set special icon for zyppObjs that are installed, but broken
1062 // (dependencies no longer satisfied, e.g. for patches or patterns)
1066 setPixmap( brokenIconCol(), YQIconPool::warningSign() );
1068 y2warning( "Broken object: %s - %s",
1069 _selectable->theObj()->name().c_str(),
1070 _selectable->theObj()->summary().c_str() );
1078 YQPkgObjListItem::isSatisfied() const
1080 if ( _debugIsSatisfied )
1083 if ( _selectable->hasInstalledObj() )
1086 return _selectable->candidatePoolItem().status().isSatisfied();
1090 bool YQPkgObjListItem::isBroken() const
1092 if ( _debugIsBroken )
1095 if ( ! _selectable->hasInstalledObj() )
1096 return false; // can't be broken if not installed
1100 case S_KeepInstalled:
1103 return _selectable->installedPoolItem().status().isIncomplete();
1105 case S_Update: // will be fixed by updating
1107 case S_Del: // will no longer be relevant after deleting
1112 case S_NoInst: // should not happen - no installed obj
1117 y2error( "Expected uninstalled zyppObj" );
1121 y2error( "Should never get here" );
1127 YQPkgObjListItem::cycleStatus()
1129 if ( ! _editable || ! _pkgObjList->editable() )
1132 ZyppStatus oldStatus = status();
1133 ZyppStatus newStatus = oldStatus;
1135 if ( selectable()->hasInstalledObj() )
1137 switch ( oldStatus )
1140 newStatus = selectable()->hasCandidateObj() ?
1141 S_KeepInstalled: S_NoInst;
1144 case S_KeepInstalled:
1145 newStatus = selectable()->hasCandidateObj() ?
1154 newStatus = S_KeepInstalled;
1158 newStatus = S_KeepInstalled;
1162 else // Pkg not installed
1164 switch ( oldStatus )
1167 if ( selectable()->hasCandidateObj() )
1169 newStatus = S_Install;
1173 y2warning( "No candidate for %s", selectable()->theObj()->name().c_str() );
1174 newStatus = S_NoInst;
1179 newStatus = S_Taboo;
1183 newStatus = S_NoInst;
1188 if ( oldStatus != newStatus )
1190 setStatus( newStatus );
1192 if ( showLicenseAgreement() )
1194 showNotifyTexts( newStatus );
1196 else // License not confirmed?
1198 // Status is now S_Taboo or S_Del - update status icon
1202 _pkgObjList->sendStatusChanged();
1208 YQPkgObjListItem::showNotifyTexts( ZyppStatus status )
1215 if ( selectable()->hasCandidateObj() )
1216 text = selectable()->candidateObj()->insnotify();
1222 if ( selectable()->hasCandidateObj() )
1223 text = selectable()->candidateObj()->delnotify();
1229 if ( ! text.empty() )
1231 y2debug( "Showing notify text" );
1232 YQPkgTextDialog::showText( _pkgObjList, selectable(), text );
1238 YQPkgObjListItem::showLicenseAgreement()
1240 return showLicenseAgreement( selectable() );
1245 YQPkgObjListItem::showLicenseAgreement( ZyppSel sel )
1249 switch ( sel->status() )
1256 if ( sel->hasLicenceConfirmed() )
1259 if ( sel->candidateObj() )
1260 licenseText = sel->candidateObj()->licenseToConfirm();
1263 default: return true;
1266 if ( licenseText.empty() )
1269 y2debug( "Showing license agreement for %s", sel->name().c_str() );
1270 bool confirmed = YQPkgTextDialog::confirmText( 0, sel, licenseText );
1274 y2milestone( "User confirmed license agreement for %s", sel->name().c_str() );
1275 sel->setLicenceConfirmed( true );
1279 // The user rejected the license agreement -
1280 // make sure the package gets unselected.
1282 switch ( sel->status() )
1287 y2warning( "User rejected license agreement for %s - setting to TABOO",
1288 sel->name().c_str() );
1290 sel->set_status( S_Taboo );
1297 y2warning( "User rejected license agreement for %s - setting to PROTECTED",
1298 sel->name().c_str() );
1300 sel->set_status( S_Protected );
1301 // S_Keep wouldn't be good enough: The next solver run might
1302 // set it to S_AutoUpdate again
1314 YQPkgObjListItem::toolTip( int col )
1316 if ( col == statusCol() )
1318 QString tip = _pkgObjList->statusText( status() );
1326 if ( bySelection() )
1327 // Translators: Additional hint what caused an auto-status
1328 tip += "\n" + _( "(by a software selection)" );
1330 tip += "\n" + _( "(by dependencies)" );
1341 if ( col == brokenIconCol() )
1344 // Translators: tool tip for patches / patterns that are installed,
1345 // but whose dependencies are broken (no longer satisfied)
1346 return _( "Dependencies broken" );
1349 // don't use "else if" here, it might be the same colum as another one!
1351 if ( col == satisfiedIconCol() )
1353 if ( isSatisfied() )
1354 // Translators: tool tip for patches / patterns that are not installed,
1355 // but whose dependencies are satisfied
1356 return _( "All dependencies satisfied" );
1359 return QString::null;
1364 * Comparison function used for sorting the list.
1366 * -1 if this < other
1367 * 0 if this == other
1368 * +1 if this > other
1371 YQPkgObjListItem::compare( Q3ListViewItem * otherListViewItem,
1373 bool ascending ) const
1375 YQPkgObjListItem * other = dynamic_cast<YQPkgObjListItem *> (otherListViewItem);
1379 if ( col == sizeCol() )
1381 // Numeric sort by size
1383 if ( this->zyppObj()->size() < other->zyppObj()->size() ) return -1;
1384 if ( this->zyppObj()->size() > other->zyppObj()->size() ) return 1;
1387 else if ( col == statusCol() )
1389 // Sorting by status depends on the numeric value of the
1390 // ZyppStatus enum, thus it is important to insert new
1391 // package states there where they make most sense. We want to show
1392 // dangerous or noteworthy states first - e.g., "taboo" which should
1393 // seldeom occur, but when it does, it is important.
1395 if ( this->status() < other->status() ) return -1;
1396 if ( this->status() > other->status() ) return 1;
1399 else if ( col == instVersionCol() ||
1400 col == versionCol() )
1402 // Sorting by version numbers doesn't make too much sense, so let's
1403 // sort by package relation:
1404 // - Installed newer than candidate (red)
1405 // - Candidate newer than installed (blue) - worthwhile updating
1407 // - Not installed, but candidate available
1409 // Within these categories, sort versions by ASCII - OK, it's
1410 // pretty random, but predictable.
1412 int thisPoints = this->versionPoints();
1413 int otherPoints = other->versionPoints();
1415 if ( thisPoints > otherPoints ) return -1;
1416 if ( thisPoints < otherPoints ) return 1;
1417 return QY2ListViewItem::compare( otherListViewItem, col, ascending );
1421 // Fallback: Use parent class method
1422 return QY2ListViewItem::compare( otherListViewItem, col, ascending );
1427 YQPkgObjListItem::versionPoints() const
1431 if ( installedIsNewer() ) points += 1000;
1432 if ( candidateIsNewer() ) points += 100;
1433 if ( selectable()->hasInstalledObj() ) points += 10;
1434 if ( selectable()->hasCandidateObj() ) points += 1;
1441 YQPkgObjListItem::setExcluded( bool excl )
1449 YQPkgObjList::ExcludeRule::ExcludeRule( YQPkgObjList * parent,
1450 const QRegExp & regexp,
1457 _parent->addExcludeRule( this );
1462 YQPkgObjList::ExcludeRule::enable( bool enable )
1466 #if VERBOSE_EXCLUDE_RULES
1467 y2debug( "%s exclude rule %s",
1468 enable ? "Enabling" : "Disabling",
1469 _regexp.pattern().ascii() );
1475 YQPkgObjList::ExcludeRule::setRegexp( const QRegExp & regexp )
1482 YQPkgObjList::ExcludeRule::setColumn( int column )
1489 YQPkgObjList::ExcludeRule::match( Q3ListViewItem * item )
1494 QString text = item->text( _column );
1496 if ( text.isEmpty() )
1499 return _regexp.exactMatch( text );
1507 YQPkgObjList::ExcludedItems::ExcludedItems( YQPkgObjList * parent )
1508 : _pkgObjList( parent )
1513 YQPkgObjList::ExcludedItems::~ExcludedItems()
1519 void YQPkgObjList::ExcludedItems::add( Q3ListViewItem * item, Q3ListViewItem * oldParent )
1521 _excludeMap.insert( ItemPair( item, oldParent ) );
1525 void YQPkgObjList::ExcludedItems::remove( Q3ListViewItem * item )
1527 ItemMap::iterator it = _excludeMap.find( item );
1529 if ( it != _excludeMap.end() )
1531 _excludeMap.erase( it );
1536 void YQPkgObjList::ExcludedItems::clear()
1538 for ( ItemMap::iterator it = _excludeMap.begin();
1539 it != _excludeMap.end();
1545 _excludeMap.clear();
1549 bool YQPkgObjList::ExcludedItems::contains( Q3ListViewItem * item )
1551 return ( _excludeMap.find( item ) != _excludeMap.end() );
1555 Q3ListViewItem * YQPkgObjList::ExcludedItems::oldParentItem( Q3ListViewItem * item )
1557 ItemMap::iterator it = _excludeMap.find( item );
1559 if ( it == _excludeMap.end() )
1567 #include "YQPkgObjList.moc"