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 )
118 , verifySystem( false )
119 , installRecommended( false )
129 , updatelistItem( 0 )
131 , diskspaceLabel( 0 )
136 , patchPkgsVersions( 0 )
142 setFlags( modeFlags );
147 setInstallRecommended( isInstallRecommended() );
148 setAutoCheck( isAutoCheck() );
149 setVerifySystem( isVerifySystem() );
164 void NCPackageSelector::setFlags(
long modeFlags )
166 youMode = ( modeFlags & YPkg_OnlineUpdateMode ) ?
true :
false ;
168 updateMode = ( modeFlags & YPkg_UpdateMode ) ?
true :
false ;
170 repoMgrEnabled = (modeFlags & YPkg_RepoMgr) ?
true :
false;
172 testMode = (modeFlags & YPkg_TestMode ) ?
true :
false ;
174 repoMode = ( modeFlags & YPkg_RepoMode ) ?
true :
false;
176 summaryMode = ( modeFlags & YPkg_SummaryMode ) ?
true :
false;
179 void NCPackageSelector::readSysconfig()
181 sysconfig = zypp::base::sysconfig::read( PATH_TO_YAST_SYSCONFIG );
182 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_EXIT );
184 if (it != sysconfig.end())
186 actionAtExit = it->second;
187 yuiMilestone() <<
"Read sysconfig's action at pkg mgr exit value: " << actionAtExit << endl;
192 yuiMilestone() <<
"Could not read " << OPTION_EXIT <<
"variable from sysconfig, disabling the menu" << endl;
196 void NCPackageSelector::writeSysconfig( )
199 if( !actionAtExit.empty() )
203 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
206 "Set behaviour when package installation has finished.");
208 catch(
const std::exception &e )
210 yuiError() <<
"Writing " << OPTION_EXIT <<
" failed" << endl;
216 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
218 (autoCheck?
"yes":
"no"),
219 "Automatic dependency checking" );
221 catch(
const std::exception &e )
223 yuiError() <<
"Writing " << OPTION_AUTO_CHECK <<
" failed" << endl;
228 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
230 (verifySystem?
"yes":
"no"),
231 "System verification mode" );
233 catch(
const std::exception &e )
235 yuiError() <<
"Writing " << OPTION_VERIFY <<
" failed" << endl;
240 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
242 (installRecommended?
"yes":
"no"),
243 "Install recommended packages" );
245 catch(
const std::exception &e )
247 yuiError() <<
"Writing " << OPTION_RECOMMENDED <<
" failed" << endl;
251 bool NCPackageSelector::checkNow(
bool *ok )
256 ret = depsPopup->showDependencies( NCPkgPopupDeps::S_Solve, ok );
257 YDialog::deleteTopmostDialog();
261 bool NCPackageSelector::systemVerification(
bool *ok )
266 ret = depsPopup->showDependencies( NCPkgPopupDeps::S_Verify, ok );
267 YDialog::deleteTopmostDialog();
271 bool NCPackageSelector::doInstallRecommended(
bool *ok )
273 zypp::getZYpp()->resolver()->setIgnoreAlreadyRecommended(
false );
274 zypp::getZYpp()->resolver()->resolvePool();
284 bool NCPackageSelector::isCleanDepsOnRemove()
286 return zypp::getZYpp()->resolver()->cleandepsOnRemove();
289 void NCPackageSelector::setCleanDepsOnRemove(
bool on )
291 zypp::getZYpp()->resolver()->setCleandepsOnRemove( on );
292 zypp::getZYpp()->resolver()->resolvePool();
300 bool NCPackageSelector::isInstallRecommended()
302 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_RECOMMENDED );
304 if ( it != sysconfig.end() )
306 yuiMilestone() << OPTION_RECOMMENDED <<
": " << it->second << endl;
307 if ( it->second ==
"yes" )
308 installRecommended =
true;
309 else if ( it->second ==
"no")
310 installRecommended =
false;
312 installRecommended = !(zypp::getZYpp()->resolver()->onlyRequires());
316 installRecommended = !(zypp::getZYpp()->resolver()->onlyRequires());
318 yuiMilestone() <<
"installRecommended: " << (installRecommended?
"yes":
"no") << endl;
320 return installRecommended;
323 void NCPackageSelector::setInstallRecommended(
bool on )
325 installRecommended = on;
326 zypp::getZYpp()->resolver()->setOnlyRequires( !on );
328 zypp::getZYpp()->resolver()->resolvePool();
333 bool NCPackageSelector::isAutoCheck()
337 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_AUTO_CHECK);
339 if ( it != sysconfig.end() )
341 yuiMilestone() << OPTION_AUTO_CHECK <<
": " << it->second << endl;
342 if ( it->second ==
"no" )
345 yuiMilestone() <<
"autoCheck " << (autoCheck?
"yes":
"no") << endl;
350 bool NCPackageSelector::isVerifySystem( )
352 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_VERIFY );
354 if ( it != sysconfig.end() )
356 yuiMilestone() << OPTION_VERIFY <<
": " << it->second << endl;
357 if ( it->second ==
"yes" )
359 else if ( it->second ==
"no")
360 verifySystem =
false;
362 verifySystem = zypp::getZYpp()->resolver()->systemVerification();
366 verifySystem = zypp::getZYpp()->resolver()->systemVerification();
368 yuiMilestone() <<
"verifySystem: " << (verifySystem?
"yes":
"no") << endl;
373 void NCPackageSelector::setVerifySystem(
bool on )
376 zypp::getZYpp()->resolver()->setSystemVerification( on );
378 zypp::getZYpp()->resolver()->resolvePool();
386 bool NCPackageSelector::isAllowVendorChange()
388 zypp::Resolver_Ptr resolver = zypp::getZYpp()->resolver();
389 bool change = resolver->allowVendorChange();
390 yuiMilestone() <<
"Vendor change allowed: " << (change?
"true":
"false") << endl;
394 void NCPackageSelector::setAllowVendorChange(
bool on )
396 zypp::getZYpp()->resolver()->setAllowVendorChange( on );
397 zypp::getZYpp()->resolver()->resolvePool();
408 ZyppPool p = zyppPool ();
410 p.saveState<zypp::Package> ();
411 p.saveState<zypp::SrcPackage> ();
413 p.saveState<zypp::Patch> ();
415 p.saveState<zypp::Pattern> ();
419 void NCPackageSelector::restoreState ()
421 ZyppPool p = zyppPool ();
423 p.restoreState<zypp::Package> ();
424 p.restoreState<zypp::SrcPackage> ();
426 p.restoreState<zypp::Patch> ();
428 p.restoreState<zypp::Pattern> ();
432 bool NCPackageSelector::diffState ()
434 ZyppPool p = zyppPool ();
438 std::ostream & log = yuiMilestone();
439 log <<
"diffState" << endl;
440 diff = diff || p.diffState<zypp::Package> ();
442 diff = diff || p.diffState<zypp::SrcPackage> ();
445 diff = diff || p.diffState<zypp::Patch> ();
448 diff = diff || p.diffState<zypp::Pattern> ();
465 if ( event == NCursesEvent::handled )
468 yuiMilestone() <<
"widget event: " <<
event << endl;
470 if ( event == NCursesEvent::button )
472 if ( event.widget == okButton )
476 else if ( event.widget == cancelButton )
480 else if ( event.widget == filterMain )
482 retVal = filterMain->handleEvent();
484 else if ( event.widget == searchField )
486 if ( event.reason == YEvent::Activated )
488 retVal = searchPopup->showSearchResultPackages();
496 else if ( event == NCursesEvent::menu )
498 if ( event.widget == actionMenu )
500 retVal = actionMenu->handleEvent( event );
501 else if ( event.widget == viewMenu )
503 retVal = viewMenu->handleEvent( event );
504 else if ( event.widget == depsMenu )
505 retVal = depsMenu->handleEvent( event );
506 else if ( event.widget == extrasMenu )
507 retVal = extrasMenu->handleEvent( event );
508 else if ( event.widget == configMenu )
509 retVal = configMenu->handleEvent( event );
510 else if ( event.widget == helpMenu )
511 retVal = helpMenu->handleEvent( event );
512 else if ( event.widget == filterMenu )
513 retVal = filterMenu->handleEvent( event );
514 else if ( event.selection->label().substr(0,4) ==
"pkg:" )
543 q.addKind( zypp::ResKind::patch );
544 q.addAttribute( zypp::sat::SolvAttr::keywords );
547 q.addAttribute( zypp::sat::SolvAttr::name );
551 q.addAttribute( zypp::sat::SolvAttr::summary );
554 for( zypp::PoolQuery::Selectable_iterator it = q.selectableBegin();
555 it != q.selectableEnd(); it++)
557 yuiMilestone() << (*it)->name() << endl;
558 ZyppPatch patchPtr = tryCastToZyppPatch( (*it)->theObj() );
587 yuiError() <<
"No valid NCPkgTable widget" << endl;
595 std::list<ZyppSel> patchList( zyppPatchesBegin (), zyppPatchesEnd () );
596 patchList.sort( sortByName );
597 std::list<ZyppSel>::iterator listIt = patchList.begin();
599 while ( listIt != patchList.end() )
601 ZyppPatch patchPtr = tryCastToZyppPatch( ( *listIt)->theObj() );
610 if ( filter == NCPkgMenuFilter::F_All
624 case NCPkgMenuFilter::F_Needed:
630 case NCPkgMenuFilter::F_Unneeded:
632 packageLabel->setLabel( NCPkgStrings::InstPatches() );
637 packageLabel->setLabel( NCPkgStrings::Patches() );
657 yuiError() <<
"Widget is not a valid NCPkgTable widget" << endl;
664 std::list<zypp::PoolItem> problemList = zypp::getZYpp()->resolver()->problematicUpdateItems();
666 for ( std::list<zypp::PoolItem>::const_iterator it = problemList.begin();
667 it != problemList.end();
670 ZyppPkg pkg = tryCastToZyppPkg( (*it).resolvable() );
678 yuiMilestone() <<
"Problematic package: " << pkg->name().c_str() <<
" " <<
679 pkg->edition().asString().c_str() << endl;
705 if ( !pkgTable || !objPtr )
710 std::set<ZyppSel> patchSelectables;
711 ZyppPatch patchPtr = tryCastToZyppPatch( objPtr );
716 ZyppPatchContents patchContents( patchPtr->contents() );
718 yuiMilestone() <<
"Filtering for patch: " << patchPtr->name().c_str() <<
" number of atoms: " 719 << patchContents.size() << endl ;
721 for ( ZyppPatchContentsIterator it = patchContents.selectableBegin();
722 it != patchContents.selectableEnd();
725 ZyppPkg pkg = tryCastToZyppPkg( (*it)->theObj() );
729 yuiMilestone() <<
"Patch package found: " << (*it)->name().c_str() << endl;
734 if ( inContainer( patchSelectables, sel ) )
736 yuiMilestone() <<
"Suppressing duplicate selectable: " << (*it)->name().c_str() <<
"-" <<
737 pkg->edition().asString().c_str() <<
" " <<
738 pkg->arch().asString().c_str() << endl;
742 patchSelectables.insert( sel );
743 yuiDebug() << (*it)->name().c_str() <<
": Version: " << pkg->edition().asString() << endl;
751 yuiDebug() <<
"Found unknown atom of kind %s: %s" <<
752 (*it)->kind().asString().c_str() <<
753 (*it)->name().c_str() << endl;
773 NCPkgMenuFilter::PatchFilter filter )
777 bool displayPatch =
false;
781 yuiError() <<
"Widget is not a valid NCPkgTable widget" << endl;
784 if ( !patchPtr || !selectable || !selectable->hasCandidateObj() )
786 yuiError() <<
"Patch data not valid" << endl;
789 yuiDebug() <<
"Filter: " << filter << endl;
791 if ( filter == NCPkgMenuFilter::F_All )
796 else if ( selectable->candidateObj().isRelevant() )
800 case NCPkgMenuFilter::F_Unneeded:
802 if ( selectable->candidateObj().isSatisfied() &&
803 !selectable->candidateObj().status().isToBeInstalled() )
809 case NCPkgMenuFilter::F_Needed:
811 if ( !selectable->candidateObj().isSatisfied() ||
813 selectable->candidateObj().status().isToBeInstalled() )
817 case NCPkgMenuFilter::F_Security:
819 if ( patchPtr->category() ==
"security" )
823 case NCPkgMenuFilter::F_Recommended:
825 if ( patchPtr->category() ==
"recommended" )
829 case NCPkgMenuFilter::F_Optional:
831 if ( patchPtr->category() ==
"optional" )
836 yuiWarning() <<
"Unknown patch filter" << endl;
852 wrect NCPackageSelector::deleteReplacePoint()
855 YWidget * replaceChild = replacePoint->firstChild();
860 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
867 patchPkgsVersions = 0;
883 wrect oldSize = deleteReplacePoint();
890 infoText->setSize( oldSize.Sze.W, oldSize.Sze.H );
905 wrect oldSize = deleteReplacePoint();
909 YTableHeader * tableHeader =
new YTableHeader();
910 versionsList =
new NCPkgTable( replacePoint, tableHeader );
914 if ( versionsList && packageList )
920 versionsList->setSize( oldSize.Sze.W, oldSize.Sze.H );
922 versionsList->fillAvailableList( packageList->
getSelPointer( packageList->getCurrentItem() ) );
923 versionsList->Redraw();
925 packageList->setKeyboardFocus();
940 wrect oldSize = deleteReplacePoint();
944 YTableHeader * tableHeader =
new YTableHeader();
945 patchPkgs =
new NCPkgTable( replacePoint, tableHeader );
947 if ( patchPkgs && packageList )
953 patchPkgs->
setTableType( NCPkgTable::T_PatchPkgs, strategy );
955 patchPkgs->setSize( oldSize.Sze.W, oldSize.Sze.H );
960 packageList->setKeyboardFocus();
979 ZyppSel sel = patchPkgs->
getSelPointer( patchPkgs->getCurrentItem() );
985 _(
"Package Versions"),
987 _(
"List of all available package versions:"),
990 NCursesEvent input = availablePopup->showAvailablesPopup( sel );
992 YDialog::deleteTopmostDialog();
994 patchPkgs->setKeyboardFocus();
998 void NCPackageSelector::clearInfoArea()
1001 infoText->setText(
"");
1005 packageLabel->setText(
".....................................");
1008 void NCPackageSelector::replaceFilter( FilterMode mode)
1010 patternLabel->setLabel(
" " );
1011 YWidget * replaceChild = replPoint->firstChild();
1016 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
1018 delete replaceChild;
1029 replaceFilterDescr( mode == Search );
1035 YTableHeader *hhh =
new YTableHeader ();
1037 patternPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1038 patternPopup->Redraw();
1040 patternPopup->setKeyboardFocus();
1045 YTableHeader *hhh =
new YTableHeader ();
1047 languagePopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1048 languagePopup->Redraw();
1049 languagePopup->showLocalePackages();
1050 languagePopup->setKeyboardFocus();
1055 YTableHeader *hhh =
new YTableHeader ();
1057 repoPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1058 repoPopup->Redraw();
1059 repoPopup->showRepoPackages();
1060 repoPopup->setKeyboardFocus();
1065 YTableHeader *hhh =
new YTableHeader ();
1067 servicePopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1068 servicePopup->Redraw();
1070 servicePopup->setKeyboardFocus();
1076 searchPopup->createLayout( replPoint );
1077 searchPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1078 searchPopup->Redraw();
1080 searchField = searchPopup->getSearchField();
1083 searchField->setKeyboardFocus();
1084 searchField->setNotify(
true);
1091 inst_summary->setSize( oldSize.Sze.W, oldSize.Sze.H );
1092 inst_summary->Redraw();
1093 inst_summary->setKeyboardFocus();
1094 pkgList->fillSummaryList(NCPkgTable::L_Changes);
1097 case PkgClassification:
1100 pkgClass->setSize( oldSize.Sze.W, oldSize.Sze.H );
1102 pkgClass->setKeyboardFocus();
1107 yuiError() <<
"zatim nic" << endl;
1117 pkgList->setCurrentItem(0);
1123 void NCPackageSelector::replaceFilterDescr(
bool b )
1125 YWidget * replaceChild = replPoint2->firstChild();
1130 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
1132 delete replaceChild;
1140 searchSet->setSize( oldSize.Sze.W, oldSize.Sze.H );
1141 searchSet->Redraw();
1145 filter_desc =
new NCRichText( replPoint2,
"");
1146 filter_desc->setSize( oldSize.Sze.W, oldSize.Sze.H );
1147 filter_desc->Redraw();
1162 std::string pkgName = link.substr(6);
1168 for (i = b; i != e; ++i)
1170 ZyppPkg pkgPtr = tryCastToZyppPkg ((*i)->theObj());
1171 if ( pkgPtr && pkgPtr->name() == pkgName )
1173 yuiMilestone() <<
"Package " << pkgName <<
" found" << endl;
1176 popupDescr->showInfoPopup( pkgPtr, *i );
1178 YDialog::deleteTopmostDialog();
1186 yuiError() <<
"Package " << pkgName <<
" NOT found" << endl;
1202 bool changes = diffState ();
1206 NCPopupInfo * cancelMsg =
new NCPopupInfo( wpos( (NCurses::lines()-8)/2, (NCurses::cols()-45)/2 ),
1207 NCPkgStrings::NotifyLabel(),
1208 NCPkgStrings::CancelText(),
1212 cancelMsg->setPreferredSize( 45, 8 );
1213 cancelMsg->focusCancelButton();
1214 NCursesEvent input = cancelMsg->showInfoPopup( );
1216 YDialog::deleteTopmostDialog();
1218 if ( input == NCursesEvent::cancel ) {
1226 yuiMilestone() <<
"Cancel button pressed - leaving package selection" << endl;
1227 const_cast<NCursesEvent &
>(event).result =
"cancel";
1241 bool closeDialog =
true;
1242 bool confirmedAllLicenses =
false;
1252 closeDialog =
false;
1257 }
while ( !confirmedAllLicenses && closeDialog );
1265 _(
"Automatic Changes"),
1267 _(
"In addition to your manual selections, the following" ),
1269 _(
"packages have been changed to resolve dependencies:" )
1271 NCursesEvent input = autoChangePopup->showInfoPopup();
1273 YDialog::deleteTopmostDialog();
1275 if ( input == NCursesEvent::cancel )
1278 closeDialog =
false;
1282 if ( diskspacePopup )
1284 std::string message =
"";
1285 message = diskspacePopup->checkDiskSpace();
1286 if ( message !=
"" )
1289 NCPopupInfo * spaceMsg =
new NCPopupInfo( wpos( (NCurses::lines()-10)/2, (NCurses::cols()-50)/2 ),
1290 NCPkgStrings::ErrorLabel(),
1292 _(
"You can choose to install anyway, but you risk getting a corrupted system." ),
1293 _(
"&Continue anyway" ),
1296 spaceMsg->setPreferredSize( 50, 10 );
1297 spaceMsg->focusOkButton();
1298 NCursesEvent input = spaceMsg->showInfoPopup( );
1300 YDialog::deleteTopmostDialog();
1302 if ( input == NCursesEvent::cancel )
1305 closeDialog =
false;
1317 const_cast<NCursesEvent &
>(event).result =
"accept";
1318 yuiMilestone() <<
"OK button pressed - leaving package selection, starting installation" << endl;
1329 packageList->setKeyboardFocus();
1338 bool allConfirmed =
true;
1345 return allConfirmed;
1350 yuiMilestone() <<
"Showing all pending license agreements" << endl;
1352 bool allConfirmed =
true;
1354 for ( ZyppPoolIterator it = begin; it != end; ++it )
1356 ZyppSel sel = (*it);
1358 switch ( sel->status() )
1365 if ( sel->candidateObj() )
1367 std::string licenseText = sel->candidateObj()->licenseToConfirm();
1369 if ( ! licenseText.empty() )
1371 yuiMilestone() <<
"Package/Patch " << sel->name().c_str() <<
1372 "has a license" << endl;
1374 if( ! sel->hasLicenceConfirmed() )
1380 yuiMilestone() <<
"License for " << sel->name().c_str() <<
1381 " is already confirmed" << endl;
1392 return allConfirmed;
1400 bool license_confirmed =
true;
1402 std::string pkgName = slbPtr->name();
1406 if ( !license_confirmed )
1409 switch ( slbPtr->status() )
1413 slbPtr->setStatus( S_Taboo );
1418 slbPtr->setStatus( S_Protected );
1427 yuiMilestone() <<
"User confirmed license agreement for " << pkgName << endl;
1428 slbPtr->setLicenceConfirmed (
true);
1444 bool cancel =
false;
1446 if ( doit || autoCheck )
1448 yuiMilestone() <<
"Checking dependencies" << endl;
1449 cancel = checkNow( & ok );
1472 std::string html_text =
"";
1473 const std::string htmlIdent(DOCTYPETAG);
1474 bool confirmed =
false;
1476 if ( license.find( htmlIdent ) != std::string::npos )
1478 html_text = license;
1482 html_text =
"<pre>" + license +
"</pre>";
1485 NCPopupInfo * info =
new NCPopupInfo ( wpos( NCurses::lines()/10, NCurses::cols()/10),
1487 _(
"End User License Agreement" ),
1488 "<i>" + pkgName +
"</i><br><br>" 1493 info->setPreferredSize( (NCurses::cols() * 80)/100, (NCurses::lines()*80)/100);
1494 info->focusOkButton();
1495 confirmed = info->showInfoPopup( ) != NCursesEvent::cancel;
1497 YDialog::deleteTopmostDialog();
1525 if ( diskspacePopup )
1527 diskspacePopup->checkDiskSpaceRange( );
1530 if ( diskspaceLabel )
1532 diskspaceLabel->setText( diskspacePopup->calculateDiff().asString() );
1546 std::set<ZyppSel> selectablesToInstall;
1548 for ( ZyppPoolIterator patches_it = zyppPatchesBegin();
1549 patches_it != zyppPatchesEnd();
1552 ZyppPatch patch = tryCastToZyppPatch( (*patches_it)->theObj() );
1556 ZyppPatchContents patchContents( patch->contents() );
1558 for ( ZyppPatchContentsIterator contents_it = patchContents.selectableBegin();
1559 contents_it != patchContents.selectableEnd();
1562 ZyppPkg pkg = tryCastToZyppPkg( (*contents_it)->theObj() );
1571 switch ( sel->status() )
1582 selectablesToInstall.insert( sel );
1588 case S_KeepInstalled:
1602 FSize totalSize = 0;
1604 for ( std::set<ZyppSel>::iterator it = selectablesToInstall.begin();
1605 it != selectablesToInstall.end();
1608 if ( (*it)->candidateObj() )
1609 totalSize += zypp::ByteCount::SizeType((*it)->candidateObj()->installSize());
1613 if ( diskspaceLabel )
1615 diskspaceLabel->setText( totalSize.asString() );
1624 NCPkgTable * NCPackageSelector::PackageList()
1635 YLayoutBox * split = YUI::widgetFactory()->createVBox( selector );
1637 YLayoutBox * hSplit = YUI::widgetFactory()->createHBox( split );
1639 YAlignment * left1 = YUI::widgetFactory()->createLeft( hSplit );
1640 filterMenu =
new NCPkgMenuFilter( left1, NCPkgStrings::Filter(),
this );
1642 YAlignment * left2 = YUI::widgetFactory()->createLeft( hSplit );
1643 actionMenu =
new NCPkgMenuAction( left2, NCPkgStrings::Actions(),
this );
1645 YAlignment * left3 = YUI::widgetFactory()->createLeft( hSplit );
1646 viewMenu =
new NCPkgMenuView( left3, NCPkgStrings::View(),
this);
1648 YAlignment * left4 = YUI::widgetFactory()->createLeft( hSplit );
1649 depsMenu =
new NCPkgMenuDeps( left4, NCPkgStrings::Deps(),
this);
1652 YTableHeader * tableHeader =
new YTableHeader();
1654 pkgList =
new NCPkgTable( split, tableHeader );
1655 YUI_CHECK_NEW( pkgList );
1660 pkgList->
setTableType( NCPkgTable::T_Patches, strategy );
1667 std::vector<std::string> pkgHeader;
1668 pkgList->getHeader( pkgHeader );
1672 YLayoutBox * hSplit2 = YUI::widgetFactory()->createHBox( split );
1674 YLayoutBox * hSplit3 = YUI::widgetFactory()->createHBox( hSplit2 );
1676 new NCLabel( hSplit3, _(
"Filter: " ) );
1677 packageLabel = YUI::widgetFactory()->createLabel ( hSplit3,
"....................................." );
1679 new NCSpacing( hSplit2, YD_HORIZ,
true, 0.5 );
1681 YLayoutBox * hSplit4 = YUI::widgetFactory()->createHBox( hSplit2 );
1683 new NCLabel( hSplit4, _(
"Total Download Size: " ) );
1685 diskspaceLabel = YUI::widgetFactory()->createLabel ( hSplit4,
" " );
1687 YLayoutBox * vSplit = YUI::widgetFactory()->createVBox( split );
1688 replacePoint = YUI::widgetFactory()->createReplacePoint( vSplit );
1691 YUI_CHECK_NEW( infoText );
1693 YLayoutBox * bottom_bar = YUI::widgetFactory()->createHBox( vSplit );
1694 YAlignment *ll = YUI::widgetFactory()->createLeft( bottom_bar );
1698 YAlignment *r = YUI::widgetFactory()->createRight( bottom_bar );
1699 YLayoutBox * hSplit5 = YUI::widgetFactory()->createHBox( r );
1702 cancelButton =
new NCPushButton( hSplit5, _(
"&Cancel" ) );
1703 YUI_CHECK_NEW( cancelButton );
1704 cancelButton->setFunctionKey( 9 );
1707 okButton =
new NCPushButton( hSplit5, _(
"&Accept" ) );
1708 YUI_CHECK_NEW( okButton );
1709 okButton->setFunctionKey( 10 );
1719 YLayoutBox * vsplit = YUI::widgetFactory()->createVBox( selector );
1720 YLayoutBox * menu_bar = YUI::widgetFactory()->createHBox( vsplit );
1721 YLayoutBox * panels = YUI::widgetFactory()->createVBox( vsplit );
1722 YLayoutBox * bottom_bar = YUI::widgetFactory()->createHBox( vsplit );
1724 YAlignment * left1 = YUI::widgetFactory()->createLeft( menu_bar );
1726 YLayoutBox * menu_buttons = YUI::widgetFactory()->createHBox( left1);
1727 depsMenu =
new NCPkgMenuDeps( menu_buttons, NCPkgStrings::Deps(),
this);
1728 viewMenu =
new NCPkgMenuView( menu_buttons, NCPkgStrings::View(),
this);
1731 if (isRepoMgrEnabled())
1732 configMenu =
new NCPkgMenuConfig( menu_buttons, _(
"C&onfiguration" ),
this);
1734 extrasMenu =
new NCPkgMenuExtras( menu_buttons, NCPkgStrings::Extras(),
this);
1736 YLayoutBox * hbox_top = YUI::widgetFactory()->createHBox( panels );
1737 YLayoutBox * hbox_bottom = YUI::widgetFactory()->createHBox( panels );
1739 YLayoutBox * vbox_left = YUI::widgetFactory()->createVBox( hbox_top );
1740 vbox_left->setWeight(YD_HORIZ,1);
1741 YFrame * fr = YUI::widgetFactory()->createFrame (vbox_left,
"");
1742 YLayoutBox * vv = YUI::widgetFactory()->createVBox( fr );
1743 YAlignment *l = YUI::widgetFactory()->createLeft( vv );
1746 replPoint = YUI::widgetFactory()->createReplacePoint( vv );
1749 searchPopup->createLayout( replPoint );
1751 searchField = searchPopup->getSearchField();
1754 searchField->setKeyboardFocus();
1755 searchField->setNotify(
true );
1758 YAlignment *l1 = YUI::widgetFactory()->createLeft( vbox_left );
1759 patternLabel =
new NCLabel( l1,
" " );
1762 YTableHeader * tableHeader =
new YTableHeader();
1764 YLayoutBox * v = YUI::widgetFactory()->createVBox( hbox_top );
1765 v->setWeight(YD_HORIZ,2);
1767 YUI_CHECK_NEW( pkgList );
1773 case NCPkgTable::T_Packages:
1775 pkgList->
setTableType( NCPkgTable::T_Packages, strategy );
1776 case NCPkgTable::T_Update:
1778 pkgList->
setTableType( NCPkgTable::T_Update, strategy );
1781 pkgList->
setTableType( NCPkgTable::T_Packages, strategy );
1788 std::vector<std::string> pkgHeader;
1789 pkgList->getHeader( pkgHeader );
1793 YLayoutBox * hSplit2 = YUI::widgetFactory()->createHBox( v );
1794 new NCLabel( hSplit2, NCPkgStrings::PackageName() );
1795 packageLabel = YUI::widgetFactory()->createLabel ( hSplit2,
"......................" );
1796 new NCSpacing( hSplit2, YD_HORIZ,
true, 0.5 );
1797 actionMenu =
new NCPkgMenuAction ( hSplit2, NCPkgStrings::Actions(),
this );
1800 replPoint2 = YUI::widgetFactory()->createReplacePoint( hbox_bottom );
1801 replPoint2->setWeight(YD_HORIZ, 1);
1805 YLayoutBox * vSplit = YUI::widgetFactory()->createVBox( hbox_bottom );
1806 vSplit->setWeight(YD_HORIZ, 2);
1807 replacePoint = YUI::widgetFactory()->createReplacePoint( vSplit );
1809 YUI_CHECK_NEW( infoText );
1812 YAlignment *ll = YUI::widgetFactory()->createLeft( bottom_bar );
1814 YUI_CHECK_NEW( helpMenu );
1817 YAlignment *right = YUI::widgetFactory()->createRight( bottom_bar );
1818 YLayoutBox * hSplit = YUI::widgetFactory()->createHBox( right );
1821 cancelButton =
new NCPushButton( hSplit, _(
"&Cancel" ) );
1822 YUI_CHECK_NEW( cancelButton );
1823 cancelButton->setFunctionKey( 9 );
1826 okButton =
new NCPushButton( hSplit, _(
"&Accept" ) );
1827 YUI_CHECK_NEW( okButton );
1828 okButton->setFunctionKey( 10 );
1840 yuiMilestone() <<
"Filling package list: " << (NCWidget *) pkgList << endl;
1842 switch ( pkgList->getTableType() )
1844 case NCPkgTable::T_Patches: {
1848 pkgList->setVisibleInfo(NCPkgTable::I_PatchDescr);
1851 pkgList->setKeyboardFocus();
1854 case NCPkgTable::T_Update: {
1855 if ( ! zypp::getZYpp()->resolver()->problematicUpdateItems().empty() )
1859 pkgList->setVisibleInfo(NCPkgTable::I_Technical);
1865 case NCPkgTable::T_Packages: {
1867 pkgList->setVisibleInfo(NCPkgTable::I_Technical);
1868 searchField->setKeyboardFocus();
1878 replaceFilter ( NCPackageSelector::Repositories );
1880 filterMain->setReposSelected();
1882 else if ( summaryMode )
1884 replaceFilter ( NCPackageSelector::Summary );
1886 filterMain->setSummarySelected();
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 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.