42 #include "NCWidgetFactory.h" 43 #include "NCPushButton.h" 44 #include "NCMenuButton.h" 46 #include "NCSpacing.h" 47 #include "NCRichText.h" 49 #include "NCPopupInfo.h" 50 #include "NCSelectionBox.h" 51 #include "NCMenuButton.h" 52 #include "NCPkgFilterPattern.h" 53 #include "NCPkgFilterLocale.h" 54 #include "NCPkgFilterRepo.h" 55 #include "NCPkgFilterService.h" 56 #include "NCPkgFilterClassification.h" 57 #include "NCPkgPopupDeps.h" 58 #include "NCPkgPopupDiskspace.h" 59 #include "NCPkgMenuDeps.h" 60 #include "NCPkgMenuView.h" 61 #include "NCPkgMenuExtras.h" 62 #include "NCPkgMenuConfig.h" 63 #include "NCPkgMenuHelp.h" 64 #include "NCPkgMenuAction.h" 65 #include "NCPkgPopupDescr.h" 66 #include "NCPackageSelector.h" 67 #include "NCLayoutBox.h" 68 #include "YSelectionBox.h" 69 #include "YAlignment.h" 70 #include "YNCursesUI.h" 71 #include "YApplication.h" 81 #include <zypp/ui/Selectable.h> 82 #include <zypp/base/Sysconfig.h> 84 #include "YWidgetID.h" 85 #include "YPackageSelector.h" 87 #define PATH_TO_YAST_SYSCONFIG "/etc/sysconfig/yast2" 89 #define OPTION_RECOMMENDED "PKGMGR_RECOMMENDED" 90 #define OPTION_REEVALUATE "PKGMGR_REEVALUATE_RECOMMENDED" 91 #define OPTION_VERIFY "PKGMGR_VERIFY_SYSTEM" 92 #define OPTION_AUTO_CHECK "PKGMGR_AUTO_CHECK" 93 #define OPTION_EXIT "PKGMGR_ACTION_AT_EXIT" 95 typedef zypp::Patch::Contents ZyppPatchContents;
96 typedef zypp::Patch::Contents::Selectable_iterator ZyppPatchContentsIterator;
110 NCPackageSelector::NCPackageSelector(
long modeFlags )
115 , diskspacePopup( 0 )
119 , verifySystem( false )
120 , installRecommended( false )
130 , updatelistItem( 0 )
132 , diskspaceLabel( 0 )
137 , patchPkgsVersions( 0 )
142 setFlags( modeFlags );
147 setInstallRecommended( isInstallRecommended() );
148 setAutoCheck( isAutoCheck() );
149 setVerifySystem( isVerifySystem() );
165 void NCPackageSelector::setFlags(
long modeFlags )
167 youMode = ( modeFlags & YPkg_OnlineUpdateMode ) ?
true :
false;
168 updateMode = ( modeFlags & YPkg_UpdateMode ) ?
true :
false;
169 repoMgrEnabled = ( modeFlags & YPkg_RepoMgr ) ?
true :
false;
170 testMode = ( modeFlags & YPkg_TestMode ) ?
true :
false;
171 repoMode = ( modeFlags & YPkg_RepoMode ) ?
true :
false;
172 summaryMode = ( modeFlags & YPkg_SummaryMode ) ?
true :
false;
173 onlineSearchEnabled = ( modeFlags & YPkg_OnlineSearch ) ?
true :
false;
177 void NCPackageSelector::readSysconfig()
179 sysconfig = zypp::base::sysconfig::read( PATH_TO_YAST_SYSCONFIG );
180 std::map <std::string, std::string>::const_iterator it = sysconfig.find( OPTION_EXIT );
182 if (it != sysconfig.end())
184 actionAtExit = it->second;
185 yuiMilestone() <<
"Read sysconfig's action at pkg mgr exit value: " << actionAtExit << endl;
190 yuiMilestone() <<
"Could not read " << OPTION_EXIT <<
"variable from sysconfig, disabling the menu" << endl;
195 void NCPackageSelector::writeSysconfig()
198 if ( !actionAtExit.empty() )
202 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
205 "Set behaviour when package installation has finished.");
207 catch(
const std::exception &e )
209 yuiError() <<
"Writing " << OPTION_EXIT <<
" failed" << endl;
215 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
217 (autoCheck?
"yes":
"no"),
218 "Automatic dependency checking" );
220 catch(
const std::exception &e )
222 yuiError() <<
"Writing " << OPTION_AUTO_CHECK <<
" failed" << endl;
227 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
229 (verifySystem?
"yes":
"no"),
230 "System verification mode" );
232 catch(
const std::exception &e )
234 yuiError() <<
"Writing " << OPTION_VERIFY <<
" failed" << endl;
239 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
241 (installRecommended?
"yes":
"no"),
242 "Install recommended packages" );
244 catch(
const std::exception &e )
246 yuiError() <<
"Writing " << OPTION_RECOMMENDED <<
" failed" << endl;
251 bool NCPackageSelector::checkNow(
bool *ok )
256 ret = depsPopup->showDependencies( NCPkgPopupDeps::S_Solve, ok );
257 YDialog::deleteTopmostDialog();
262 bool NCPackageSelector::systemVerification(
bool *ok )
267 ret = depsPopup->showDependencies( NCPkgPopupDeps::S_Verify, ok );
268 YDialog::deleteTopmostDialog();
273 bool NCPackageSelector::doInstallRecommended(
bool *ok )
275 zypp::getZYpp()->resolver()->setIgnoreAlreadyRecommended(
false );
276 zypp::getZYpp()->resolver()->resolvePool();
287 bool NCPackageSelector::isCleanDepsOnRemove()
289 return zypp::getZYpp()->resolver()->cleandepsOnRemove();
293 void NCPackageSelector::setCleanDepsOnRemove(
bool on )
295 zypp::getZYpp()->resolver()->setCleandepsOnRemove( on );
296 zypp::getZYpp()->resolver()->resolvePool();
305 bool NCPackageSelector::isInstallRecommended()
307 std::map <std::string, std::string>::const_iterator it = sysconfig.find( OPTION_RECOMMENDED );
309 if ( it != sysconfig.end() )
311 yuiMilestone() << OPTION_RECOMMENDED <<
": " << it->second << endl;
312 if ( it->second ==
"yes" )
313 installRecommended =
true;
314 else if ( it->second ==
"no")
315 installRecommended =
false;
317 installRecommended = !(zypp::getZYpp()->resolver()->onlyRequires());
321 installRecommended = !(zypp::getZYpp()->resolver()->onlyRequires());
323 yuiMilestone() <<
"installRecommended: " << (installRecommended?
"yes":
"no") << endl;
325 return installRecommended;
329 void NCPackageSelector::setInstallRecommended(
bool on )
331 installRecommended = on;
332 zypp::getZYpp()->resolver()->setOnlyRequires( !on );
334 zypp::getZYpp()->resolver()->resolvePool();
339 bool NCPackageSelector::isAutoCheck()
343 std::map <std::string, std::string>::const_iterator it = sysconfig.find( OPTION_AUTO_CHECK);
345 if ( it != sysconfig.end() )
347 yuiMilestone() << OPTION_AUTO_CHECK <<
": " << it->second << endl;
348 if ( it->second ==
"no" )
351 yuiMilestone() <<
"autoCheck " << (autoCheck?
"yes":
"no") << endl;
357 bool NCPackageSelector::isVerifySystem()
359 std::map <std::string, std::string>::const_iterator it = sysconfig.find( OPTION_VERIFY );
361 if ( it != sysconfig.end() )
363 yuiMilestone() << OPTION_VERIFY <<
": " << it->second << endl;
364 if ( it->second ==
"yes" )
366 else if ( it->second ==
"no")
367 verifySystem =
false;
369 verifySystem = zypp::getZYpp()->resolver()->systemVerification();
373 verifySystem = zypp::getZYpp()->resolver()->systemVerification();
375 yuiMilestone() <<
"verifySystem: " << (verifySystem?
"yes":
"no") << endl;
381 void NCPackageSelector::setVerifySystem(
bool on )
384 zypp::getZYpp()->resolver()->setSystemVerification( on );
386 zypp::getZYpp()->resolver()->resolvePool();
395 bool NCPackageSelector::isAllowVendorChange()
397 zypp::Resolver_Ptr resolver = zypp::getZYpp()->resolver();
398 bool change = resolver->allowVendorChange();
399 yuiMilestone() <<
"Vendor change allowed: " << (change?
"true":
"false") << endl;
404 void NCPackageSelector::setAllowVendorChange(
bool on )
406 zypp::getZYpp()->resolver()->setAllowVendorChange( on );
407 zypp::getZYpp()->resolver()->dupSetAllowVendorChange( on );
408 zypp::getZYpp()->resolver()->resolvePool();
415 ZyppPool p = zyppPool();
417 p.saveState<zypp::Package>();
418 p.saveState<zypp::SrcPackage>();
420 p.saveState<zypp::Patch>();
422 p.saveState<zypp::Pattern>();
427 void NCPackageSelector::restoreState()
429 ZyppPool p = zyppPool();
431 p.restoreState<zypp::Package>();
432 p.restoreState<zypp::SrcPackage>();
434 p.restoreState<zypp::Patch>();
436 p.restoreState<zypp::Pattern>();
441 bool NCPackageSelector::diffState()
443 ZyppPool p = zyppPool();
447 std::ostream & log = yuiMilestone();
448 log <<
"diffState" << endl;
449 diff = diff || p.diffState<zypp::Package>();
451 diff = diff || p.diffState<zypp::SrcPackage>();
454 diff = diff || p.diffState<zypp::Patch>();
457 diff = diff || p.diffState<zypp::Pattern>();
475 if ( event == NCursesEvent::handled )
480 if ( event == NCursesEvent::button )
482 if ( event.widget == okButton )
486 else if ( event.widget == cancelButton )
490 else if ( event.widget == filterMain )
492 retVal = filterMain->handleEvent();
494 else if ( event.widget == searchField )
496 if ( event.reason == YEvent::Activated )
498 retVal = searchPopup->showSearchResultPackages();
506 else if ( event == NCursesEvent::menu )
508 if ( event.widget == actionMenu )
510 retVal = actionMenu->handleEvent( event );
511 else if ( event.widget == viewMenu )
513 retVal = viewMenu->handleEvent( event );
514 else if ( event.widget == depsMenu )
515 retVal = depsMenu->handleEvent( event );
516 else if ( event.widget == extrasMenu )
517 retVal = extrasMenu->handleEvent( event );
518 else if ( event.widget == configMenu )
519 retVal = configMenu->handleEvent( event );
520 else if ( event.widget == helpMenu )
521 retVal = helpMenu->handleEvent( event );
522 else if ( event.widget == filterMenu )
523 retVal = filterMenu->handleEvent( event );
524 else if ( event.selection->label().substr(0, 4) ==
"pkg:" )
554 q.addKind( zypp::ResKind::patch );
555 q.addAttribute( zypp::sat::SolvAttr::keywords );
558 q.addAttribute( zypp::sat::SolvAttr::name );
562 q.addAttribute( zypp::sat::SolvAttr::summary );
565 for ( zypp::PoolQuery::Selectable_iterator it = q.selectableBegin();
566 it != q.selectableEnd(); it++)
568 yuiMilestone() << (*it)->name() << endl;
569 ZyppPatch patchPtr = tryCastToZyppPatch( (*it)->theObj() );
598 yuiError() <<
"No valid NCPkgTable widget" << endl;
606 std::list<ZyppSel> patchList( zyppPatchesBegin(), zyppPatchesEnd() );
607 patchList.sort( sortByName );
608 std::list<ZyppSel>::iterator listIt = patchList.begin();
610 while ( listIt != patchList.end() )
612 ZyppPatch patchPtr = tryCastToZyppPatch( ( *listIt)->theObj() );
621 if ( filter == NCPkgMenuFilter::F_All
635 case NCPkgMenuFilter::F_Needed:
640 case NCPkgMenuFilter::F_Unneeded:
641 packageLabel->setLabel( NCPkgStrings::InstPatches() );
645 packageLabel->setLabel( NCPkgStrings::Patches() );
665 yuiError() <<
"Widget is not a valid NCPkgTable widget" << endl;
672 std::list<zypp::PoolItem> problemList = zypp::getZYpp()->resolver()->problematicUpdateItems();
674 for ( std::list<zypp::PoolItem>::const_iterator it = problemList.begin();
675 it != problemList.end();
678 ZyppPkg pkg = tryCastToZyppPkg( (*it).resolvable() );
686 yuiMilestone() <<
"Problematic package: " << pkg->name().c_str() <<
" " <<
687 pkg->edition().asString().c_str() << endl;
714 if ( !pkgTable || !objPtr )
719 std::set<ZyppSel> patchSelectables;
720 ZyppPatch patchPtr = tryCastToZyppPatch( objPtr );
725 ZyppPatchContents patchContents( patchPtr->contents() );
727 yuiMilestone() <<
"Filtering for patch: " << patchPtr->name().c_str() <<
" number of atoms: " 728 << patchContents.size() << endl;
730 for ( ZyppPatchContentsIterator it = patchContents.selectableBegin();
731 it != patchContents.selectableEnd();
734 ZyppPkg pkg = tryCastToZyppPkg( (*it)->theObj() );
738 yuiMilestone() <<
"Patch package found: " << (*it)->name().c_str() << endl;
743 if ( inContainer( patchSelectables, sel ) )
745 yuiMilestone() <<
"Suppressing duplicate selectable: " << (*it)->name().c_str() <<
"-" <<
746 pkg->edition().asString().c_str() <<
" " <<
747 pkg->arch().asString().c_str() << endl;
751 patchSelectables.insert( sel );
752 yuiDebug() << (*it)->name().c_str() <<
": Version: " << pkg->edition().asString() << endl;
760 yuiDebug() <<
"Found unknown atom of kind %s: %s" <<
761 (*it)->kind().asString().c_str() <<
762 (*it)->name().c_str() << endl;
784 NCPkgMenuFilter::PatchFilter filter )
788 bool displayPatch =
false;
792 yuiError() <<
"Widget is not a valid NCPkgTable widget" << endl;
795 if ( !patchPtr || !selectable || !selectable->hasCandidateObj() )
797 yuiError() <<
"Patch data not valid" << endl;
800 yuiDebug() <<
"Filter: " << filter << endl;
802 if ( filter == NCPkgMenuFilter::F_All )
807 else if ( selectable->candidateObj().isRelevant() )
811 case NCPkgMenuFilter::F_Unneeded:
813 if ( selectable->candidateObj().isSatisfied() &&
814 !selectable->candidateObj().status().isToBeInstalled() )
820 case NCPkgMenuFilter::F_Needed:
822 if ( !selectable->candidateObj().isSatisfied() ||
824 selectable->candidateObj().status().isToBeInstalled() )
828 case NCPkgMenuFilter::F_Security:
830 if ( patchPtr->category() ==
"security" )
834 case NCPkgMenuFilter::F_Recommended:
836 if ( patchPtr->category() ==
"recommended" )
840 case NCPkgMenuFilter::F_Optional:
842 if ( patchPtr->category() ==
"optional" )
847 yuiWarning() <<
"Unknown patch filter" << endl;
864 wrect NCPackageSelector::deleteReplacePoint()
867 YWidget * replaceChild = replacePoint->firstChild();
872 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
879 patchPkgsVersions = 0;
896 wrect oldSize = deleteReplacePoint();
903 infoText->setSize( oldSize.Sze.W, oldSize.Sze.H );
919 wrect oldSize = deleteReplacePoint();
923 YTableHeader * tableHeader =
new YTableHeader();
924 versionsList =
new NCPkgTable( replacePoint, tableHeader );
928 if ( versionsList && packageList )
934 versionsList->setSize( oldSize.Sze.W, oldSize.Sze.H );
936 versionsList->fillAvailableList( packageList->
getSelPointer( packageList->getCurrentItem() ) );
937 versionsList->Redraw();
939 packageList->setKeyboardFocus();
954 wrect oldSize = deleteReplacePoint();
958 YTableHeader * tableHeader =
new YTableHeader();
959 patchPkgs =
new NCPkgTable( replacePoint, tableHeader );
961 if ( patchPkgs && packageList )
967 patchPkgs->
setTableType( NCPkgTable::T_PatchPkgs, strategy );
969 patchPkgs->setSize( oldSize.Sze.W, oldSize.Sze.H );
974 packageList->setKeyboardFocus();
994 ZyppSel sel = patchPkgs->
getSelPointer( patchPkgs->getCurrentItem() );
1000 _(
"Package Versions"),
1002 _(
"List of all available package versions:"),
1005 NCursesEvent input = availablePopup->showAvailablesPopup( sel );
1007 YDialog::deleteTopmostDialog();
1009 patchPkgs->setKeyboardFocus();
1013 void NCPackageSelector::clearInfoArea()
1016 infoText->setText(
"");
1020 packageLabel->setText(
".....................................");
1024 void NCPackageSelector::replaceFilter( FilterMode mode )
1026 patternLabel->setLabel(
" " );
1027 YWidget * replaceChild = replPoint->firstChild();
1032 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
1034 delete replaceChild;
1046 replaceFilterDescr( mode == Search );
1052 YTableHeader *hhh =
new YTableHeader();
1054 patternPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1055 patternPopup->Redraw();
1057 patternPopup->setKeyboardFocus();
1062 YTableHeader *hhh =
new YTableHeader();
1064 languagePopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1065 languagePopup->Redraw();
1066 languagePopup->showLocalePackages();
1067 languagePopup->setKeyboardFocus();
1072 YTableHeader *hhh =
new YTableHeader();
1074 repoPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1075 repoPopup->Redraw();
1076 repoPopup->showRepoPackages();
1077 repoPopup->setKeyboardFocus();
1082 YTableHeader *hhh =
new YTableHeader();
1084 servicePopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1085 servicePopup->Redraw();
1087 servicePopup->setKeyboardFocus();
1093 searchPopup->createLayout( replPoint );
1094 searchPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1095 searchPopup->Redraw();
1097 searchField = searchPopup->getSearchField();
1101 searchField->setKeyboardFocus();
1102 searchField->setNotify(
true);
1109 inst_summary->setSize( oldSize.Sze.W, oldSize.Sze.H );
1110 inst_summary->Redraw();
1111 inst_summary->setKeyboardFocus();
1112 pkgList->fillSummaryList(NCPkgTable::L_Changes);
1115 case PkgClassification:
1118 pkgClass->setSize( oldSize.Sze.W, oldSize.Sze.H );
1120 pkgClass->setKeyboardFocus();
1125 yuiError() <<
"zatim nic" << endl;
1136 pkgList->setCurrentItem(0);
1142 void NCPackageSelector::replaceFilterDescr(
bool b )
1144 YWidget * replaceChild = replPoint2->firstChild();
1149 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
1151 delete replaceChild;
1159 searchSet->setSize( oldSize.Sze.W, oldSize.Sze.H );
1160 searchSet->Redraw();
1164 filter_desc =
new NCRichText( replPoint2,
"");
1165 filter_desc->setSize( oldSize.Sze.W, oldSize.Sze.H );
1166 filter_desc->Redraw();
1182 std::string pkgName = link.substr(6);
1188 for (i = b; i != e; ++i)
1190 ZyppPkg pkgPtr = tryCastToZyppPkg ((*i)->theObj());
1191 if ( pkgPtr && pkgPtr->name() == pkgName )
1193 yuiMilestone() <<
"Package " << pkgName <<
" found" << endl;
1196 popupDescr->showInfoPopup( pkgPtr, *i );
1198 YDialog::deleteTopmostDialog();
1206 yuiError() <<
"Package " << pkgName <<
" NOT found" << endl;
1222 bool changes = diffState();
1227 NCPopupInfo * cancelMsg =
new NCPopupInfo( wpos( (NCurses::lines()-8)/2, (NCurses::cols()-45)/2 ),
1228 NCPkgStrings::NotifyLabel(),
1229 NCPkgStrings::CancelText(),
1233 cancelMsg->setPreferredSize( 45, 8 );
1234 cancelMsg->focusCancelButton();
1235 NCursesEvent input = cancelMsg->showInfoPopup();
1237 YDialog::deleteTopmostDialog();
1239 if ( input == NCursesEvent::cancel )
1248 yuiMilestone() <<
"Cancel button pressed - leaving package selection" << endl;
1249 const_cast<NCursesEvent &
>(event).result =
"cancel";
1264 bool closeDialog =
true;
1265 bool confirmedAllLicenses =
false;
1275 closeDialog =
false;
1280 }
while ( !confirmedAllLicenses && closeDialog );
1288 _(
"Automatic Changes"),
1290 _(
"In addition to your manual selections, the following" ),
1292 _(
"packages have been changed to resolve dependencies:" )
1294 NCursesEvent input = autoChangePopup->showInfoPopup();
1296 YDialog::deleteTopmostDialog();
1298 if ( input == NCursesEvent::cancel )
1301 closeDialog =
false;
1305 if ( diskspacePopup )
1307 std::string message =
"";
1308 message = diskspacePopup->checkDiskSpace();
1309 if ( message !=
"" )
1312 NCPopupInfo * spaceMsg =
new NCPopupInfo( wpos( (NCurses::lines()-10)/2, (NCurses::cols()-50)/2 ),
1313 NCPkgStrings::ErrorLabel(),
1315 _(
"You can choose to install anyway, but you risk getting a corrupted system." ),
1316 _(
"&Continue anyway" ),
1319 spaceMsg->setPreferredSize( 50, 10 );
1320 spaceMsg->focusOkButton();
1321 NCursesEvent input = spaceMsg->showInfoPopup();
1323 YDialog::deleteTopmostDialog();
1325 if ( input == NCursesEvent::cancel )
1328 closeDialog =
false;
1340 const_cast<NCursesEvent &
>(event).result =
"accept";
1341 yuiMilestone() <<
"OK button pressed - leaving package selection, starting installation" << endl;
1352 packageList->setKeyboardFocus();
1362 bool allConfirmed =
true;
1369 return allConfirmed;
1375 yuiMilestone() <<
"Showing all pending license agreements" << endl;
1377 bool allConfirmed =
true;
1379 for ( ZyppPoolIterator it = begin; it != end; ++it )
1381 ZyppSel sel = (*it);
1383 switch ( sel->status() )
1390 if ( sel->candidateObj() )
1392 std::string licenseText = sel->candidateObj()->licenseToConfirm();
1394 if ( ! licenseText.empty() )
1396 yuiMilestone() <<
"Package/Patch " << sel->name().c_str() <<
1397 "has a license" << endl;
1399 if ( ! sel->hasLicenceConfirmed() )
1405 yuiMilestone() <<
"License for " << sel->name().c_str() <<
1406 " is already confirmed" << endl;
1417 return allConfirmed;
1426 bool license_confirmed =
true;
1428 std::string pkgName = slbPtr->name();
1432 if ( !license_confirmed )
1435 switch ( slbPtr->status() )
1439 slbPtr->setStatus( S_Taboo );
1444 slbPtr->setStatus( S_Protected );
1455 yuiMilestone() <<
"User confirmed license agreement for " << pkgName << endl;
1456 slbPtr->setLicenceConfirmed (
true);
1473 bool cancel =
false;
1475 if ( doit || autoCheck )
1477 yuiMilestone() <<
"Checking dependencies" << endl;
1478 cancel = checkNow( & ok );
1493 std::string html_text =
"";
1494 const std::string htmlIdent(DOCTYPETAG);
1495 bool confirmed =
false;
1497 if ( license.find( htmlIdent ) != std::string::npos )
1499 html_text = license;
1503 html_text =
"<pre>" + license +
"</pre>";
1506 NCPopupInfo * info =
new NCPopupInfo ( wpos( NCurses::lines()/10, NCurses::cols()/10),
1508 _(
"End User License Agreement" ),
1509 "<i>" + pkgName +
"</i><br><br>" 1514 info->setPreferredSize( (NCurses::cols() * 80)/100, (NCurses::lines()*80)/100);
1515 info->focusOkButton();
1516 confirmed = info->showInfoPopup() != NCursesEvent::cancel;
1518 YDialog::deleteTopmostDialog();
1546 if ( diskspacePopup )
1548 diskspacePopup->checkDiskSpaceRange();
1551 if ( diskspaceLabel )
1553 diskspaceLabel->setText( diskspacePopup->calculateDiff().asString() );
1567 std::set<ZyppSel> selectablesToInstall;
1569 for ( ZyppPoolIterator patches_it = zyppPatchesBegin();
1570 patches_it != zyppPatchesEnd();
1573 ZyppPatch patch = tryCastToZyppPatch( (*patches_it)->theObj() );
1577 ZyppPatchContents patchContents( patch->contents() );
1579 for ( ZyppPatchContentsIterator contents_it = patchContents.selectableBegin();
1580 contents_it != patchContents.selectableEnd();
1583 ZyppPkg pkg = tryCastToZyppPkg( (*contents_it)->theObj() );
1592 switch ( sel->status() )
1603 selectablesToInstall.insert( sel );
1609 case S_KeepInstalled:
1623 FSize totalSize = 0;
1625 for ( std::set<ZyppSel>::iterator it = selectablesToInstall.begin();
1626 it != selectablesToInstall.end();
1629 if ( (*it)->candidateObj() )
1630 totalSize += zypp::ByteCount::SizeType((*it)->candidateObj()->installSize());
1634 if ( diskspaceLabel )
1636 diskspaceLabel->setText( totalSize.asString() );
1645 NCPkgTable * NCPackageSelector::PackageList()
1656 YLayoutBox * split = YUI::widgetFactory()->createVBox( selector );
1658 YLayoutBox * hSplit = YUI::widgetFactory()->createHBox( split );
1660 YAlignment * left1 = YUI::widgetFactory()->createLeft( hSplit );
1661 filterMenu =
new NCPkgMenuFilter( left1, NCPkgStrings::Filter(),
this );
1663 YAlignment * left2 = YUI::widgetFactory()->createLeft( hSplit );
1664 actionMenu =
new NCPkgMenuAction( left2, NCPkgStrings::Actions(),
this );
1666 YAlignment * left3 = YUI::widgetFactory()->createLeft( hSplit );
1667 viewMenu =
new NCPkgMenuView( left3, NCPkgStrings::View(),
this);
1669 YAlignment * left4 = YUI::widgetFactory()->createLeft( hSplit );
1670 depsMenu =
new NCPkgMenuDeps( left4, NCPkgStrings::Deps(),
this);
1673 YTableHeader * tableHeader =
new YTableHeader();
1675 pkgList =
new NCPkgTable( split, tableHeader );
1676 YUI_CHECK_NEW( pkgList );
1681 pkgList->
setTableType( NCPkgTable::T_Patches, strategy );
1688 std::vector<std::string> pkgHeader = pkgList->getHeader();
1692 YLayoutBox * hSplit2 = YUI::widgetFactory()->createHBox( split );
1694 YLayoutBox * hSplit3 = YUI::widgetFactory()->createHBox( hSplit2 );
1696 new NCLabel( hSplit3, _(
"Filter: " ) );
1697 packageLabel = YUI::widgetFactory()->createLabel ( hSplit3,
"....................................." );
1699 new NCSpacing( hSplit2, YD_HORIZ,
true, 0.5 );
1701 YLayoutBox * hSplit4 = YUI::widgetFactory()->createHBox( hSplit2 );
1703 new NCLabel( hSplit4, _(
"Total Download Size: " ) );
1705 diskspaceLabel = YUI::widgetFactory()->createLabel ( hSplit4,
" " );
1707 YLayoutBox * vSplit = YUI::widgetFactory()->createVBox( split );
1708 replacePoint = YUI::widgetFactory()->createReplacePoint( vSplit );
1711 YUI_CHECK_NEW( infoText );
1713 YLayoutBox * bottom_bar = YUI::widgetFactory()->createHBox( vSplit );
1714 YAlignment *ll = YUI::widgetFactory()->createLeft( bottom_bar );
1718 YAlignment *r = YUI::widgetFactory()->createRight( bottom_bar );
1719 YLayoutBox * hSplit5 = YUI::widgetFactory()->createHBox( r );
1722 cancelButton =
new NCPushButton( hSplit5, _(
"&Cancel" ) );
1723 YUI_CHECK_NEW( cancelButton );
1724 cancelButton->setFunctionKey( 9 );
1727 okButton =
new NCPushButton( hSplit5, _(
"&Accept" ) );
1728 YUI_CHECK_NEW( okButton );
1729 okButton->setFunctionKey( 10 );
1739 YLayoutBox * vsplit = YUI::widgetFactory()->createVBox( selector );
1740 YLayoutBox * menu_bar = YUI::widgetFactory()->createHBox( vsplit );
1741 YLayoutBox * panels = YUI::widgetFactory()->createVBox( vsplit );
1742 YLayoutBox * bottom_bar = YUI::widgetFactory()->createHBox( vsplit );
1744 YAlignment * left1 = YUI::widgetFactory()->createLeft( menu_bar );
1746 YLayoutBox * menu_buttons = YUI::widgetFactory()->createHBox( left1);
1747 depsMenu =
new NCPkgMenuDeps( menu_buttons, NCPkgStrings::Deps(),
this);
1748 viewMenu =
new NCPkgMenuView( menu_buttons, NCPkgStrings::View(),
this);
1751 if (isRepoMgrEnabled())
1752 configMenu =
new NCPkgMenuConfig( menu_buttons, _(
"C&onfiguration" ),
this);
1754 extrasMenu =
new NCPkgMenuExtras( menu_buttons, NCPkgStrings::Extras(),
this);
1756 YLayoutBox * hbox_top = YUI::widgetFactory()->createHBox( panels );
1757 YLayoutBox * hbox_bottom = YUI::widgetFactory()->createHBox( panels );
1759 YLayoutBox * vbox_left = YUI::widgetFactory()->createVBox( hbox_top );
1760 vbox_left->setWeight(YD_HORIZ, 1);
1761 YFrame * fr = YUI::widgetFactory()->createFrame (vbox_left,
"");
1762 YLayoutBox * vv = YUI::widgetFactory()->createVBox( fr );
1763 YAlignment *l = YUI::widgetFactory()->createLeft( vv );
1766 replPoint = YUI::widgetFactory()->createReplacePoint( vv );
1772 searchPopup->createLayout( replPoint );
1774 searchField = searchPopup->getSearchField();
1777 searchField->setKeyboardFocus();
1778 searchField->setNotify(
true );
1781 YAlignment *l1 = YUI::widgetFactory()->createLeft( vbox_left );
1782 patternLabel =
new NCLabel( l1,
" " );
1785 YTableHeader * tableHeader =
new YTableHeader();
1787 YLayoutBox * v = YUI::widgetFactory()->createVBox( hbox_top );
1788 v->setWeight(YD_HORIZ, 2);
1790 YUI_CHECK_NEW( pkgList );
1796 case NCPkgTable::T_Packages:
1798 pkgList->
setTableType( NCPkgTable::T_Packages, strategy );
1799 case NCPkgTable::T_Update:
1801 pkgList->
setTableType( NCPkgTable::T_Update, strategy );
1804 pkgList->
setTableType( NCPkgTable::T_Packages, strategy );
1811 std::vector<std::string> pkgHeader = pkgList->getHeader();
1815 YLayoutBox * hSplit2 = YUI::widgetFactory()->createHBox( v );
1816 new NCLabel( hSplit2, NCPkgStrings::PackageName() );
1817 packageLabel = YUI::widgetFactory()->createLabel ( hSplit2,
"......................" );
1818 new NCSpacing( hSplit2, YD_HORIZ,
true, 0.5 );
1819 actionMenu =
new NCPkgMenuAction ( hSplit2, NCPkgStrings::Actions(),
this );
1822 replPoint2 = YUI::widgetFactory()->createReplacePoint( hbox_bottom );
1823 replPoint2->setWeight(YD_HORIZ, 1);
1827 YLayoutBox * vSplit = YUI::widgetFactory()->createVBox( hbox_bottom );
1828 vSplit->setWeight(YD_HORIZ, 2);
1829 replacePoint = YUI::widgetFactory()->createReplacePoint( vSplit );
1831 YUI_CHECK_NEW( infoText );
1834 YAlignment *ll = YUI::widgetFactory()->createLeft( bottom_bar );
1836 YUI_CHECK_NEW( helpMenu );
1839 YAlignment *right = YUI::widgetFactory()->createRight( bottom_bar );
1840 YLayoutBox * hSplit = YUI::widgetFactory()->createHBox( right );
1843 cancelButton =
new NCPushButton( hSplit, _(
"&Cancel" ) );
1844 YUI_CHECK_NEW( cancelButton );
1845 cancelButton->setFunctionKey( 9 );
1848 okButton =
new NCPushButton( hSplit, _(
"&Accept" ) );
1849 YUI_CHECK_NEW( okButton );
1850 okButton->setFunctionKey( 10 );
1862 yuiMilestone() <<
"Filling package list: " << (NCWidget *) pkgList << endl;
1864 switch ( pkgList->getTableType() )
1866 case NCPkgTable::T_Patches:
1871 pkgList->setVisibleInfo(NCPkgTable::I_PatchDescr);
1874 pkgList->setKeyboardFocus();
1877 case NCPkgTable::T_Update:
1879 if ( ! zypp::getZYpp()->resolver()->problematicUpdateItems().empty() )
1883 pkgList->setVisibleInfo(NCPkgTable::I_Technical);
1889 case NCPkgTable::T_Packages:
1892 pkgList->setVisibleInfo(NCPkgTable::I_Technical);
1893 searchField->setKeyboardFocus();
1903 replaceFilter ( NCPackageSelector::Repositories );
1905 filterMain->setReposSelected();
1907 else if ( summaryMode )
1909 replaceFilter ( NCPackageSelector::Summary );
1911 filterMain->setSummarySelected();
1915 yuiMilestone() <<
"Switching to pkg classification filter view" << endl;
1916 replaceFilter( NCPackageSelector::PkgClassification );
1917 filterMain->setPkgClassSelected();
1919 yuiMilestone() <<
"Showing retracted installed packages" << endl;
1920 pkgClass->showRetractedInstalled();
1929 yuiMilestone() <<
"Checking for retracted installed packages..." << endl;
1931 for ( ZyppPoolIterator it = zyppPkgBegin(); it != zyppPkgEnd(); ++it )
1933 if ( (*it)->hasRetractedInstalled() )
1935 yuiMilestone() <<
"Found a retracted installed package." << endl;
1940 yuiMilestone() <<
"No retracted packages installed." << endl;
bool showInformation()
Show the corresponding information (e.g.
bool createPatchEntry(ZyppPatch pkgPtr, ZyppSel slbPtr)
Creates a line in the YOU patch table.
void showDiskSpace()
Calls the package mananager (updateDu()) and shows the required disk space.
static const std::string YOUPatches()
The label Filter: YOU Patches.
void showSelectionDependencies()
Checks and shows the selectiondependencies.
bool checkPatch(ZyppPatch patch, ZyppSel selectable, NCPkgMenuFilter::PatchFilter filter)
Check if 'patch' matches the selected filter.
static const std::string UpdateProblem()
The label for Filter: Update problem.
bool fillPatchList(NCPkgMenuFilter::PatchFilter filter)
Fills the package table with YOU patches matching the filter.
bool showPendingLicenseAgreements()
Check for license.
void createPkgLayout(YWidget *parent, NCPkgTable::NCPkgTableType type)
Create layout for the PackageSelector.
ZyppObj getDataPointer(int index)
Gets the data pointer of a certain package.
void showDownloadSize()
Shows the total download size.
bool handleEvent(const NCursesEvent &event)
Handle the given event.
void updatePackageList()
Updates the status in list of packages.
virtual ~NCPackageSelector()
Destructor.
void showPatchPackages()
Creates an NCPkgTable widget and shows all packages belonging to a patch.
void fillHeader()
Fills the header of the table.
bool fillPatchPackages(NCPkgTable *pkgTable, ZyppObj youPatch)
Fills the list of packages belonging to the youPatch.
bool anyRetractedPkgInstalled()
Return 'true' if any package is installed in a retracted version.
bool CancelHandler(const NCursesEvent &event)
Handler function for "Cancel button pressed".
bool showLicensePopup(std::string pkgName, std::string license)
Shows 'End User License Agreement' popup with license text.
void showPatternPackages()
Shows the popup with the add ons (package categories).
bool createListEntry(ZyppPkg pkgPtr, ZyppSel slbPtr)
Creates a line in the package table.
static const std::string AcceptLabel()
The label of the Accept button.
static const std::string SearchResults()
The label for Filter: Search results.
bool createInfoEntry(std::string text)
Creates a line in the table shwing an info text.
void saveState()
Check for changes.
bool fillPatchSearchList(const std::string &expr, bool checkName, bool checkSum)
Fills the package table with packages matching the search expression.
ZyppSel getSelPointer(int index)
Gets the selectable pointer of a certain package.
bool updateTable()
Set the status information if status has changed.
bool setTableType(NCPkgTableType type, NCPkgStatusStrategy *strategy)
Sets the type of the table and the status strategy (which means call particular methods to set/get th...
unsigned int getNumLines()
Returns the number of lines in the table (the table size)
static const std::string NoPatches()
Info line in empty patch list.
static const std::string YesLabel()
The label of the Yes button.
bool fillDefaultList()
Fills the default package table.
virtual void itemsCleared()
Clears the package list.
static const std::string NoLabel()
The label of the No button.
bool LinkHandler(std::string link)
Handles hyperlinks in package description.
void showServicePackages()
Make the Package List show the packages for the currently selected service.
void drawList()
Draws the package list (has to be called after the loop with addLine() calls)
void createYouLayout(YWidget *parent)
Create layout for the Online Update.
bool OkButtonHandler(const NCursesEvent &event)
Handler function for "OK button pressed".
void setPackager(NCPackageSelector *pkg)
Sets the member variable PackageSelector *packager.
void showPatchPkgVersions()
Creates an NCPkgTable widget and shows all versions of all packages belonging to a patch...
static const std::string DiskSpaceError()
The headline of the disk space popup.
void showInformation()
Creates an NCRichText widget for package (patch) information.
bool showLicenseAgreement(ZyppSel &slbPtr, std::string licenseText)
Show popup with license.
bool showPackageDependencies(bool doit)
Checks and shows the dependencies.
static const std::string CancelLabel()
The label of the Cancel button.
void showVersionsList()
Creates an NCPkgTable widget and shows all verions a the selected package.
bool fillUpdateList()
Fills the package table with packages with update problems.
ZyppSel findZyppSel(ZyppPkg pkg)
Find the corresponding ZyppSel to a ZyppPkg.