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( YQPkgObjListItem * item )
523 item = dynamic_cast<YQPkgObjListItem *> ( selectedItem() );
527 ZyppSel selectable = item->selectable();
529 if ( selectable->hasInstalledObj() )
531 actionSetCurrentInstall->setEnabled( false );
532 actionSetCurrentDontInstall->setEnabled( false );
533 actionSetCurrentTaboo->setEnabled( false );
534 actionSetCurrentProtected->setEnabled( true );
536 actionSetCurrentKeepInstalled->setEnabled( true );
537 actionSetCurrentDelete->setEnabled( true );
538 actionSetCurrentUpdate->setEnabled( selectable->hasCandidateObj() );
542 actionSetCurrentInstall->setEnabled( selectable->hasCandidateObj() );
543 actionSetCurrentDontInstall->setEnabled( true );
544 actionSetCurrentTaboo->setEnabled( true );
545 actionSetCurrentProtected->setEnabled( false );
547 actionSetCurrentKeepInstalled->setEnabled( false );
548 actionSetCurrentDelete->setEnabled( false );
549 actionSetCurrentUpdate->setEnabled( false );
554 actionSetCurrentInstall->setEnabled( false );
555 actionSetCurrentDontInstall->setEnabled( false );
556 actionSetCurrentTaboo->setEnabled( false );
558 actionSetCurrentKeepInstalled->setEnabled( false );
559 actionSetCurrentDelete->setEnabled( false );
560 actionSetCurrentUpdate->setEnabled( false );
561 actionSetCurrentProtected->setEnabled( false );
567 YQPkgObjList::keyPressEvent( QKeyEvent * event )
571 unsigned special_combo = ( Qt::ControlButton | Qt::ShiftButton | Qt::AltButton );
573 if ( ( event->state() & special_combo ) == special_combo )
575 if ( event->key() == Qt::Key_Q )
578 y2milestone( "Debug mode %s", _debug ? "on" : "off" );
583 Q3ListViewItem * selectedListViewItem = selectedItem();
585 if ( selectedListViewItem )
587 YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (selectedListViewItem);
591 bool installed = item->selectable()->hasInstalledObj();
592 ZyppStatus status = item->status();
594 switch( event->ascii() )
596 case Qt::Key_Space: // Cycle
601 case '+': // Grab everything - install or update
605 ZyppStatus newStatus = S_KeepInstalled;
607 if ( item->candidateIsNewer() )
608 newStatus = S_Update;
610 setCurrentStatus( newStatus );
613 setCurrentStatus( S_Install );
618 case '-': // Get rid of everything - don't install or delete
619 setCurrentStatus( installed ? S_Del : S_NoInst );
627 setCurrentStatus( S_Taboo );
632 case '*': // Protected
635 setCurrentStatus( S_Protected );
640 case '>': // Update what is worth to be updated
642 if ( installed && item->candidateIsNewer() )
643 setCurrentStatus( S_Update );
648 case '<': // Revert update
650 if ( status == S_Update ||
651 status == S_AutoUpdate )
653 setCurrentStatus( S_KeepInstalled );
660 case 'B': // Toggle debugIsBroken flag
664 item->toggleDebugIsBroken();
665 item->setStatusIcon();
671 case 'S': // Toggle debugIsSatisfied flag
675 item->toggleDebugIsSatisfied();
676 item->setStatusIcon();
685 Q3ListView::keyPressEvent( event );
690 YQPkgObjList::message( const QString & text )
692 QY2ListViewItem * item = new QY2ListViewItem( this );
695 item->setText( nameCol() >= 0 ? nameCol() : 0, text );
696 item->setBackgroundColor( QColor( 0xE0, 0xE0, 0xF8 ) );
701 YQPkgObjList::addExcludeRule( YQPkgObjList::ExcludeRule * rule )
703 _excludeRules.push_back( rule );
708 YQPkgObjList::applyExcludeRules()
710 // y2debug( "Applying exclude rules" );
711 Q3ListViewItemIterator listView_it( this );
713 while ( *listView_it )
715 Q3ListViewItem * current_item = *listView_it;
717 // Advance iterator now so it remains valid even if there are changes
718 // to the QListView, e.g., if the current item is excluded and thus
719 // removed from the QListView
722 applyExcludeRules( current_item );
725 ExcludedItems::iterator excluded_it = _excludedItems->begin();
727 while ( excluded_it != _excludedItems->end() )
729 Q3ListViewItem * current_item = (*excluded_it).first;
731 // Advance iterator now so it remains valid even if there are changes
732 // to the excluded items, e.g., if the current item is un-excluded and thus
733 // removed from the excluded items
736 applyExcludeRules( current_item );
739 logExcludeStatistics();
744 YQPkgObjList::logExcludeStatistics()
746 if ( _excludedItems->size() > 0 )
748 y2milestone( "%d packages excluded", _excludedItems->size() );
750 for ( ExcludeRuleList::iterator rule_it = _excludeRules.begin();
751 rule_it != _excludeRules.end();
754 ExcludeRule * rule = *rule_it;
756 if ( rule->isEnabled() )
758 y2milestone( "Active exclude rule: \"%s\"",
759 rule->regexp().pattern().ascii() );
767 YQPkgObjList::applyExcludeRules( Q3ListViewItem * listViewItem )
769 YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *>( listViewItem );
773 bool exclude = false;
774 ExcludeRule * matchingRule = 0;
776 for ( ExcludeRuleList::iterator rule_it = _excludeRules.begin();
777 rule_it != _excludeRules.end() && ! exclude;
780 ExcludeRule * rule = *rule_it;
782 if ( rule->match( item ) )
789 if ( exclude != item->isExcluded() ) // change exclude status?
791 this->exclude( item, exclude );
793 #if VERBOSE_EXCLUDE_RULES
796 y2debug( "Rule %s matches: Excluding %s",
797 matchingRule->regexp().pattern().ascii(),
798 item->zyppObj()->name().c_str() );
802 y2debug( "Un-excluding %s", item->zyppObj()->name().c_str() );
811 YQPkgObjList::exclude( YQPkgObjListItem * item, bool exclude )
813 if ( exclude == item->isExcluded() )
816 item->setExcluded( exclude );
820 Q3ListViewItem * parentItem = item->parent();
823 parentItem->takeItem( item );
825 Q3ListView::takeItem( item );
827 _excludedItems->add( item, parentItem );
831 if ( _excludedItems->contains( item ) )
833 Q3ListViewItem * oldParent = _excludedItems->oldParentItem( item );
834 _excludedItems->remove( item );
837 oldParent->insertItem( item );
839 Q3ListView::insertItem( item );
847 YQPkgObjListItem::YQPkgObjListItem( YQPkgObjList * pkgObjList,
850 : QY2ListViewItem( pkgObjList )
851 , _pkgObjList( pkgObjList )
852 , _selectable( selectable )
853 , _zyppObj( zyppObj )
861 YQPkgObjListItem::YQPkgObjListItem( YQPkgObjList * pkgObjList,
862 QY2ListViewItem * parent,
865 : QY2ListViewItem( parent )
866 , _pkgObjList( pkgObjList )
867 , _selectable( selectable )
868 , _zyppObj( zyppObj )
876 YQPkgObjListItem::~YQPkgObjListItem()
883 YQPkgObjListItem::init()
885 if ( _zyppObj == 0 && _selectable )
886 _zyppObj = _selectable->theObj();
888 _debugIsBroken = false;
889 _debugIsSatisfied = false;
890 _candidateIsNewer = false;
891 _installedIsNewer = false;
893 const ZyppObj candidate = selectable()->candidateObj();
894 const ZyppObj installed = selectable()->installedObj();
896 if ( candidate && installed )
898 if ( candidate->edition() < installed->edition() )
899 _installedIsNewer = true;
900 else if ( installed->edition() < candidate->edition() )
901 _candidateIsNewer = true;
904 if ( nameCol() >= 0 ) setText( nameCol(), zyppObj()->name() );
905 if ( summaryCol() >= 0 ) setText( summaryCol(), zyppObj()->summary() );
907 if ( sizeCol() >= 0 )
909 zypp::ByteCount size = zyppObj()->size();
912 setText( sizeCol(), size.asString() + " " );
915 if ( instVersionCol() >= 0 )
917 if ( selectable()->hasInstalledObj() )
918 setText( instVersionCol(), installed->edition() );
920 if ( zyppObj() != selectable()->installedObj() &&
921 zyppObj() != selectable()->candidateObj() )
923 setText( versionCol(), zyppObj()->edition() );
925 else if ( selectable()->hasCandidateObj() )
927 setText( versionCol(), candidate->edition() );
932 setText( versionCol(), zyppObj()->edition() );
940 YQPkgObjListItem::updateData()
947 YQPkgObjListItem::setText( int column, const string text )
949 Q3ListViewItem::setText( column, fromUTF8( text.c_str() ) );
954 YQPkgObjListItem::setText( int column, const zypp::Edition & edition )
956 setText( column, edition.asString() );
961 YQPkgObjListItem::status() const
963 if ( ! selectable() )
965 y2error( "No selectable" );
969 return selectable()->status();
974 YQPkgObjListItem::bySelection() const
976 zypp::ResStatus::TransactByValue modifiedBy = selectable()->modifiedBy();
978 return ( modifiedBy == zypp::ResStatus::APPL_LOW ||
979 modifiedBy == zypp::ResStatus::APPL_HIGH );
984 YQPkgObjListItem::setStatus( ZyppStatus newStatus, bool sendSignals )
986 ZyppStatus oldStatus = selectable()->status();
987 selectable()->set_status( newStatus );
989 if ( oldStatus != selectable()->status() )
995 _pkgObjList->updateItemStates();
996 _pkgObjList->sendUpdatePackages();
1005 YQPkgObjListItem::solveResolvableCollections()
1007 #if EXTRA_SOLVE_COLLECTIONS
1008 zypp::Resolver_Ptr resolver = zypp::getZYpp()->resolver();
1010 resolver->transactReset( zypp::ResStatus::APPL_LOW );
1012 resolver->transactResKind( zypp::ResTraits<zypp::Product >::kind );
1013 resolver->transactResKind( zypp::ResTraits<zypp::Selection>::kind );
1014 resolver->transactResKind( zypp::ResTraits<zypp::Pattern >::kind );
1015 resolver->transactResKind( zypp::ResTraits<zypp::Language >::kind );
1016 resolver->transactResKind( zypp::ResTraits<zypp::Patch >::kind );
1017 resolver->transactResKind( zypp::ResTraits<zypp::Atom >::kind );
1024 YQPkgObjListItem::updateStatus()
1031 YQPkgObjListItem::setStatusIcon()
1033 if ( statusCol() >= 0 )
1035 bool enabled = editable() && _pkgObjList->editable();
1036 setPixmap( statusCol(), _pkgObjList->statusIcon( status(), enabled, bySelection() ) );
1040 if ( brokenIconCol() >= 0 )
1042 // Reset this icon now - it might be the same column as satisfiedIconCol()
1043 setPixmap( brokenIconCol(), QPixmap() );
1046 if ( satisfiedIconCol() >= 0 )
1048 // Set special icon for zyppObjs that are not marked as installed,
1049 // but satisfied anyway (e.g. for patches or patterns where the user
1050 // selected all required packages manually)
1052 setPixmap( satisfiedIconCol(), isSatisfied() ? YQIconPool::pkgSatisfied() : QPixmap() );
1055 if ( brokenIconCol() >= 0 )
1057 // Set special icon for zyppObjs that are installed, but broken
1058 // (dependencies no longer satisfied, e.g. for patches or patterns)
1062 setPixmap( brokenIconCol(), YQIconPool::warningSign() );
1064 y2warning( "Broken object: %s - %s",
1065 _selectable->theObj()->name().c_str(),
1066 _selectable->theObj()->summary().c_str() );
1074 YQPkgObjListItem::isSatisfied() const
1076 if ( _debugIsSatisfied )
1079 if ( _selectable->hasInstalledObj() )
1082 return _selectable->candidatePoolItem().status().isSatisfied();
1086 bool YQPkgObjListItem::isBroken() const
1088 if ( _debugIsBroken )
1091 if ( ! _selectable->hasInstalledObj() )
1092 return false; // can't be broken if not installed
1096 case S_KeepInstalled:
1099 return _selectable->installedPoolItem().status().isIncomplete();
1101 case S_Update: // will be fixed by updating
1103 case S_Del: // will no longer be relevant after deleting
1108 case S_NoInst: // should not happen - no installed obj
1113 y2error( "Expected uninstalled zyppObj" );
1117 y2error( "Should never get here" );
1123 YQPkgObjListItem::cycleStatus()
1125 if ( ! _editable || ! _pkgObjList->editable() )
1128 ZyppStatus oldStatus = status();
1129 ZyppStatus newStatus = oldStatus;
1131 if ( selectable()->hasInstalledObj() )
1133 switch ( oldStatus )
1136 newStatus = selectable()->hasCandidateObj() ?
1137 S_KeepInstalled: S_NoInst;
1140 case S_KeepInstalled:
1141 newStatus = selectable()->hasCandidateObj() ?
1150 newStatus = S_KeepInstalled;
1154 newStatus = S_KeepInstalled;
1158 else // Pkg not installed
1160 switch ( oldStatus )
1163 if ( selectable()->hasCandidateObj() )
1165 newStatus = S_Install;
1169 y2warning( "No candidate for %s", selectable()->theObj()->name().c_str() );
1170 newStatus = S_NoInst;
1175 newStatus = S_Taboo;
1179 newStatus = S_NoInst;
1184 if ( oldStatus != newStatus )
1186 setStatus( newStatus );
1188 if ( showLicenseAgreement() )
1190 showNotifyTexts( newStatus );
1192 else // License not confirmed?
1194 // Status is now S_Taboo or S_Del - update status icon
1198 _pkgObjList->sendStatusChanged();
1204 YQPkgObjListItem::showNotifyTexts( ZyppStatus status )
1211 if ( selectable()->hasCandidateObj() )
1212 text = selectable()->candidateObj()->insnotify();
1218 if ( selectable()->hasCandidateObj() )
1219 text = selectable()->candidateObj()->delnotify();
1225 if ( ! text.empty() )
1227 y2debug( "Showing notify text" );
1228 YQPkgTextDialog::showText( _pkgObjList, selectable(), text );
1234 YQPkgObjListItem::showLicenseAgreement()
1236 return showLicenseAgreement( selectable() );
1241 YQPkgObjListItem::showLicenseAgreement( ZyppSel sel )
1245 switch ( sel->status() )
1252 if ( sel->hasLicenceConfirmed() )
1255 if ( sel->candidateObj() )
1256 licenseText = sel->candidateObj()->licenseToConfirm();
1259 default: return true;
1262 if ( licenseText.empty() )
1265 y2debug( "Showing license agreement for %s", sel->name().c_str() );
1266 bool confirmed = YQPkgTextDialog::confirmText( 0, sel, licenseText );
1270 y2milestone( "User confirmed license agreement for %s", sel->name().c_str() );
1271 sel->setLicenceConfirmed( true );
1275 // The user rejected the license agreement -
1276 // make sure the package gets unselected.
1278 switch ( sel->status() )
1283 y2warning( "User rejected license agreement for %s - setting to TABOO",
1284 sel->name().c_str() );
1286 sel->set_status( S_Taboo );
1293 y2warning( "User rejected license agreement for %s - setting to PROTECTED",
1294 sel->name().c_str() );
1296 sel->set_status( S_Protected );
1297 // S_Keep wouldn't be good enough: The next solver run might
1298 // set it to S_AutoUpdate again
1310 YQPkgObjListItem::toolTip( int col )
1312 if ( col == statusCol() )
1314 QString tip = _pkgObjList->statusText( status() );
1322 if ( bySelection() )
1323 // Translators: Additional hint what caused an auto-status
1324 tip += "\n" + _( "(by a software selection)" );
1326 tip += "\n" + _( "(by dependencies)" );
1337 if ( col == brokenIconCol() )
1340 // Translators: tool tip for patches / patterns that are installed,
1341 // but whose dependencies are broken (no longer satisfied)
1342 return _( "Dependencies broken" );
1345 // don't use "else if" here, it might be the same colum as another one!
1347 if ( col == satisfiedIconCol() )
1349 if ( isSatisfied() )
1350 // Translators: tool tip for patches / patterns that are not installed,
1351 // but whose dependencies are satisfied
1352 return _( "All dependencies satisfied" );
1355 return QString::null;
1360 * Comparison function used for sorting the list.
1362 * -1 if this < other
1363 * 0 if this == other
1364 * +1 if this > other
1367 YQPkgObjListItem::compare( Q3ListViewItem * otherListViewItem,
1369 bool ascending ) const
1371 YQPkgObjListItem * other = dynamic_cast<YQPkgObjListItem *> (otherListViewItem);
1375 if ( col == sizeCol() )
1377 // Numeric sort by size
1379 if ( this->zyppObj()->size() < other->zyppObj()->size() ) return -1;
1380 if ( this->zyppObj()->size() > other->zyppObj()->size() ) return 1;
1383 else if ( col == statusCol() )
1385 // Sorting by status depends on the numeric value of the
1386 // ZyppStatus enum, thus it is important to insert new
1387 // package states there where they make most sense. We want to show
1388 // dangerous or noteworthy states first - e.g., "taboo" which should
1389 // seldeom occur, but when it does, it is important.
1391 if ( this->status() < other->status() ) return -1;
1392 if ( this->status() > other->status() ) return 1;
1395 else if ( col == instVersionCol() ||
1396 col == versionCol() )
1398 // Sorting by version numbers doesn't make too much sense, so let's
1399 // sort by package relation:
1400 // - Installed newer than candidate (red)
1401 // - Candidate newer than installed (blue) - worthwhile updating
1403 // - Not installed, but candidate available
1405 // Within these categories, sort versions by ASCII - OK, it's
1406 // pretty random, but predictable.
1408 int thisPoints = this->versionPoints();
1409 int otherPoints = other->versionPoints();
1411 if ( thisPoints > otherPoints ) return -1;
1412 if ( thisPoints < otherPoints ) return 1;
1413 return QY2ListViewItem::compare( otherListViewItem, col, ascending );
1417 // Fallback: Use parent class method
1418 return QY2ListViewItem::compare( otherListViewItem, col, ascending );
1423 YQPkgObjListItem::versionPoints() const
1427 if ( installedIsNewer() ) points += 1000;
1428 if ( candidateIsNewer() ) points += 100;
1429 if ( selectable()->hasInstalledObj() ) points += 10;
1430 if ( selectable()->hasCandidateObj() ) points += 1;
1437 YQPkgObjListItem::setExcluded( bool excl )
1445 YQPkgObjList::ExcludeRule::ExcludeRule( YQPkgObjList * parent,
1446 const QRegExp & regexp,
1453 _parent->addExcludeRule( this );
1458 YQPkgObjList::ExcludeRule::enable( bool enable )
1462 #if VERBOSE_EXCLUDE_RULES
1463 y2debug( "%s exclude rule %s",
1464 enable ? "Enabling" : "Disabling",
1465 _regexp.pattern().ascii() );
1471 YQPkgObjList::ExcludeRule::setRegexp( const QRegExp & regexp )
1478 YQPkgObjList::ExcludeRule::setColumn( int column )
1485 YQPkgObjList::ExcludeRule::match( Q3ListViewItem * item )
1490 QString text = item->text( _column );
1492 if ( text.isEmpty() )
1495 return _regexp.exactMatch( text );
1503 YQPkgObjList::ExcludedItems::ExcludedItems( YQPkgObjList * parent )
1504 : _pkgObjList( parent )
1509 YQPkgObjList::ExcludedItems::~ExcludedItems()
1515 void YQPkgObjList::ExcludedItems::add( Q3ListViewItem * item, Q3ListViewItem * oldParent )
1517 _excludeMap.insert( ItemPair( item, oldParent ) );
1521 void YQPkgObjList::ExcludedItems::remove( Q3ListViewItem * item )
1523 ItemMap::iterator it = _excludeMap.find( item );
1525 if ( it != _excludeMap.end() )
1527 _excludeMap.erase( it );
1532 void YQPkgObjList::ExcludedItems::clear()
1534 for ( ItemMap::iterator it = _excludeMap.begin();
1535 it != _excludeMap.end();
1541 _excludeMap.clear();
1545 bool YQPkgObjList::ExcludedItems::contains( Q3ListViewItem * item )
1547 return ( _excludeMap.find( item ) != _excludeMap.end() );
1551 Q3ListViewItem * YQPkgObjList::ExcludedItems::oldParentItem( Q3ListViewItem * item )
1553 ItemMap::iterator it = _excludeMap.find( item );
1555 if ( it == _excludeMap.end() )
1563 #include "YQPkgObjList.moc"