42 #include "NCWidgetFactory.h"
43 #include "NCPushButton.h"
44 #include "NCMenuButton.h"
46 #include "NCSpacing.h"
47 #include "NCRichText.h"
49 #include "NCPkgFilterRPMGroups.h"
50 #include "NCPopupInfo.h"
51 #include "NCSelectionBox.h"
52 #include "NCMenuButton.h"
53 #include "NCPkgFilterPattern.h"
54 #include "NCPkgFilterLocale.h"
55 #include "NCPkgFilterRepo.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 )
116 , diskspacePopup( 0 )
119 , verifySystem( false )
120 , installRecommended( false )
130 , updatelistItem( 0 )
132 , diskspaceLabel( 0 )
137 , patchPkgsVersions( 0 )
143 setFlags( modeFlags );
148 setInstallRecommended( isInstallRecommended() );
149 setAutoCheck( isAutoCheck() );
150 setVerifySystem( isVerifySystem() );
165 void NCPackageSelector::setFlags(
long modeFlags )
167 youMode = ( modeFlags & YPkg_OnlineUpdateMode ) ?
true :
false ;
169 updateMode = ( modeFlags & YPkg_UpdateMode ) ?
true :
false ;
171 repoMgrEnabled = (modeFlags & YPkg_RepoMgr) ?
true :
false;
173 testMode = (modeFlags & YPkg_TestMode ) ?
true :
false ;
175 repoMode = ( modeFlags & YPkg_RepoMode ) ?
true :
false;
177 summaryMode = ( modeFlags & YPkg_SummaryMode ) ?
true :
false;
180 void NCPackageSelector::readSysconfig()
182 sysconfig = zypp::base::sysconfig::read( PATH_TO_YAST_SYSCONFIG );
183 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_EXIT );
185 if (it != sysconfig.end())
187 actionAtExit = it->second;
188 yuiMilestone() <<
"Read sysconfig's action at pkg mgr exit value: " << actionAtExit << endl;
193 yuiMilestone() <<
"Could not read " << OPTION_EXIT <<
"variable from sysconfig, disabling the menu" << endl;
197 void NCPackageSelector::writeSysconfig( )
200 if( !actionAtExit.empty() )
204 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
207 "Set behaviour when package installation has finished.");
209 catch(
const std::exception &e )
211 yuiError() <<
"Writing " << OPTION_EXIT <<
" failed" << endl;
217 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
219 (autoCheck?
"yes":
"no"),
220 "Automatic dependency checking" );
222 catch(
const std::exception &e )
224 yuiError() <<
"Writing " << OPTION_AUTO_CHECK <<
" failed" << endl;
229 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
231 (verifySystem?
"yes":
"no"),
232 "System verification mode" );
234 catch(
const std::exception &e )
236 yuiError() <<
"Writing " << OPTION_VERIFY <<
" failed" << endl;
241 zypp::base::sysconfig::writeStringVal( PATH_TO_YAST_SYSCONFIG,
243 (installRecommended?
"yes":
"no"),
244 "Install recommended packages" );
246 catch(
const std::exception &e )
248 yuiError() <<
"Writing " << OPTION_RECOMMENDED <<
" failed" << endl;
252 bool NCPackageSelector::checkNow(
bool *ok )
257 ret = depsPopup->showDependencies( NCPkgPopupDeps::S_Solve, ok );
258 YDialog::deleteTopmostDialog();
262 bool NCPackageSelector::systemVerification(
bool *ok )
267 ret = depsPopup->showDependencies( NCPkgPopupDeps::S_Verify, ok );
268 YDialog::deleteTopmostDialog();
272 bool NCPackageSelector::doInstallRecommended(
bool *ok )
274 zypp::getZYpp()->resolver()->setIgnoreAlreadyRecommended(
false );
275 zypp::getZYpp()->resolver()->resolvePool();
285 bool NCPackageSelector::isCleanDepsOnRemove()
287 return zypp::getZYpp()->resolver()->cleandepsOnRemove();
290 void NCPackageSelector::setCleanDepsOnRemove(
bool on )
292 zypp::getZYpp()->resolver()->setCleandepsOnRemove( on );
293 zypp::getZYpp()->resolver()->resolvePool();
301 bool NCPackageSelector::isInstallRecommended()
303 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_RECOMMENDED );
305 if ( it != sysconfig.end() )
307 yuiMilestone() << OPTION_RECOMMENDED <<
": " << it->second << endl;
308 if ( it->second ==
"yes" )
309 installRecommended =
true;
310 else if ( it->second ==
"no")
311 installRecommended =
false;
313 installRecommended = !(zypp::getZYpp()->resolver()->onlyRequires());
317 installRecommended = !(zypp::getZYpp()->resolver()->onlyRequires());
319 yuiMilestone() <<
"installRecommended: " << (installRecommended?
"yes":
"no") << endl;
321 return installRecommended;
324 void NCPackageSelector::setInstallRecommended(
bool on )
326 installRecommended = on;
327 zypp::getZYpp()->resolver()->setOnlyRequires( !on );
329 zypp::getZYpp()->resolver()->resolvePool();
334 bool NCPackageSelector::isAutoCheck()
338 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_AUTO_CHECK);
340 if ( it != sysconfig.end() )
342 yuiMilestone() << OPTION_AUTO_CHECK <<
": " << it->second << endl;
343 if ( it->second ==
"no" )
346 yuiMilestone() <<
"autoCheck " << (autoCheck?
"yes":
"no") << endl;
351 bool NCPackageSelector::isVerifySystem( )
353 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_VERIFY );
355 if ( it != sysconfig.end() )
357 yuiMilestone() << OPTION_VERIFY <<
": " << it->second << endl;
358 if ( it->second ==
"yes" )
360 else if ( it->second ==
"no")
361 verifySystem =
false;
363 verifySystem = zypp::getZYpp()->resolver()->systemVerification();
367 verifySystem = zypp::getZYpp()->resolver()->systemVerification();
369 yuiMilestone() <<
"verifySystem: " << (verifySystem?
"yes":
"no") << endl;
374 void NCPackageSelector::setVerifySystem(
bool on )
377 zypp::getZYpp()->resolver()->setSystemVerification( on );
379 zypp::getZYpp()->resolver()->resolvePool();
387 bool NCPackageSelector::isAllowVendorChange()
389 zypp::Resolver_Ptr resolver = zypp::getZYpp()->resolver();
390 bool change = resolver->allowVendorChange();
391 yuiMilestone() <<
"Vendor change allowed: " << (change?
"true":
"false") << endl;
395 void NCPackageSelector::setAllowVendorChange(
bool on )
397 zypp::getZYpp()->resolver()->setAllowVendorChange( on );
398 zypp::getZYpp()->resolver()->resolvePool();
409 ZyppPool p = zyppPool ();
411 p.saveState<zypp::Package> ();
412 p.saveState<zypp::SrcPackage> ();
414 p.saveState<zypp::Patch> ();
416 p.saveState<zypp::Pattern> ();
420 void NCPackageSelector::restoreState ()
422 ZyppPool p = zyppPool ();
424 p.restoreState<zypp::Package> ();
425 p.restoreState<zypp::SrcPackage> ();
427 p.restoreState<zypp::Patch> ();
429 p.restoreState<zypp::Pattern> ();
433 bool NCPackageSelector::diffState ()
435 ZyppPool p = zyppPool ();
439 std::ostream & log = yuiMilestone();
440 log <<
"diffState" << endl;
441 diff = diff || p.diffState<zypp::Package> ();
443 diff = diff || p.diffState<zypp::SrcPackage> ();
446 diff = diff || p.diffState<zypp::Patch> ();
449 diff = diff || p.diffState<zypp::Pattern> ();
466 if ( event == NCursesEvent::handled )
469 yuiMilestone() <<
"widget event: " <<
event << endl;
471 if ( event == NCursesEvent::button )
473 if ( event.widget == okButton )
477 else if ( event.widget == cancelButton )
481 else if ( event.widget == filterPopup )
483 retVal = filterPopup->handleEvent();
485 else if ( event.widget == filterMain )
487 retVal = filterMain->handleEvent();
489 else if ( event.widget == searchField )
491 if ( event.reason == YEvent::Activated )
493 retVal = searchPopup->showSearchResultPackages();
501 else if ( event == NCursesEvent::menu )
503 if ( event.widget == actionMenu )
505 retVal = actionMenu->handleEvent( event );
506 else if ( event.widget == viewMenu )
508 retVal = viewMenu->handleEvent( event );
509 else if ( event.widget == depsMenu )
510 retVal = depsMenu->handleEvent( event );
511 else if ( event.widget == extrasMenu )
512 retVal = extrasMenu->handleEvent( event );
513 else if ( event.widget == configMenu )
514 retVal = configMenu->handleEvent( event );
515 else if ( event.widget == helpMenu )
516 retVal = helpMenu->handleEvent( event );
517 else if ( event.widget == filterMenu )
518 retVal = filterMenu->handleEvent( event );
519 else if ( event.selection->label().substr(0,4) ==
"pkg:" )
548 q.addKind( zypp::ResKind::patch );
549 q.addAttribute( zypp::sat::SolvAttr::keywords );
552 q.addAttribute( zypp::sat::SolvAttr::name );
556 q.addAttribute( zypp::sat::SolvAttr::summary );
559 for( zypp::PoolQuery::Selectable_iterator it = q.selectableBegin();
560 it != q.selectableEnd(); it++)
562 yuiMilestone() << (*it)->name() << endl;
563 ZyppPatch patchPtr = tryCastToZyppPatch( (*it)->theObj() );
592 yuiError() <<
"No valid NCPkgTable widget" << endl;
600 std::list<ZyppSel> patchList( zyppPatchesBegin (), zyppPatchesEnd () );
601 patchList.sort( sortByName );
602 std::list<ZyppSel>::iterator listIt = patchList.begin();
604 while ( listIt != patchList.end() )
606 ZyppPatch patchPtr = tryCastToZyppPatch( ( *listIt)->theObj() );
615 if ( filter == NCPkgMenuFilter::F_All
629 case NCPkgMenuFilter::F_Needed:
635 case NCPkgMenuFilter::F_Unneeded:
637 packageLabel->setLabel( NCPkgStrings::InstPatches() );
642 packageLabel->setLabel( NCPkgStrings::Patches() );
662 yuiError() <<
"Widget is not a valid NCPkgTable widget" << endl;
669 std::list<zypp::PoolItem> problemList = zypp::getZYpp()->resolver()->problematicUpdateItems();
671 for ( std::list<zypp::PoolItem>::const_iterator it = problemList.begin();
672 it != problemList.end();
675 ZyppPkg pkg = tryCastToZyppPkg( (*it).resolvable() );
683 yuiMilestone() <<
"Problematic package: " << pkg->name().c_str() <<
" " <<
684 pkg->edition().asString().c_str() << endl;
710 if ( !pkgTable || !objPtr )
715 std::set<ZyppSel> patchSelectables;
716 ZyppPatch patchPtr = tryCastToZyppPatch( objPtr );
721 ZyppPatchContents patchContents( patchPtr->contents() );
723 yuiMilestone() <<
"Filtering for patch: " << patchPtr->name().c_str() <<
" number of atoms: "
724 << patchContents.size() << endl ;
726 for ( ZyppPatchContentsIterator it = patchContents.selectableBegin();
727 it != patchContents.selectableEnd();
730 ZyppPkg pkg = tryCastToZyppPkg( (*it)->theObj() );
734 yuiMilestone() <<
"Patch package found: " << (*it)->name().c_str() << endl;
739 if ( inContainer( patchSelectables, sel ) )
741 yuiMilestone() <<
"Suppressing duplicate selectable: " << (*it)->name().c_str() <<
"-" <<
742 pkg->edition().asString().c_str() <<
" " <<
743 pkg->arch().asString().c_str() << endl;
747 patchSelectables.insert( sel );
748 yuiDebug() << (*it)->name().c_str() <<
": Version: " << pkg->edition().asString() << endl;
756 yuiDebug() <<
"Found unknown atom of kind %s: %s" <<
757 (*it)->kind().asString().c_str() <<
758 (*it)->name().c_str() << endl;
778 NCPkgMenuFilter::PatchFilter filter )
782 bool displayPatch =
false;
786 yuiError() <<
"Widget is not a valid NCPkgTable widget" << endl;
789 if ( !patchPtr || !selectable || !selectable->hasCandidateObj() )
791 yuiError() <<
"Patch data not valid" << endl;
794 yuiDebug() <<
"Filter: " << filter << endl;
796 if ( filter == NCPkgMenuFilter::F_All )
801 else if ( selectable->candidateObj().isRelevant() )
805 case NCPkgMenuFilter::F_Unneeded:
807 if ( selectable->candidateObj().isSatisfied() &&
808 !selectable->candidateObj().status().isToBeInstalled() )
814 case NCPkgMenuFilter::F_Needed:
816 if ( !selectable->candidateObj().isSatisfied() ||
818 selectable->candidateObj().status().isToBeInstalled() )
822 case NCPkgMenuFilter::F_Security:
824 if ( patchPtr->category() ==
"security" )
828 case NCPkgMenuFilter::F_Recommended:
830 if ( patchPtr->category() ==
"recommended" )
834 case NCPkgMenuFilter::F_Optional:
836 if ( patchPtr->category() ==
"optional" )
841 yuiWarning() <<
"Unknown patch filter" << endl;
857 wrect NCPackageSelector::deleteReplacePoint()
860 YWidget * replaceChild = replacePoint->firstChild();
865 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
872 patchPkgsVersions = 0;
888 wrect oldSize = deleteReplacePoint();
895 infoText->setSize( oldSize.Sze.W, oldSize.Sze.H );
910 wrect oldSize = deleteReplacePoint();
914 YTableHeader * tableHeader =
new YTableHeader();
915 versionsList =
new NCPkgTable( replacePoint, tableHeader );
919 if ( versionsList && packageList )
925 versionsList->setSize( oldSize.Sze.W, oldSize.Sze.H );
927 versionsList->fillAvailableList( packageList->
getSelPointer( packageList->getCurrentItem() ) );
928 versionsList->Redraw();
930 packageList->setKeyboardFocus();
945 wrect oldSize = deleteReplacePoint();
949 YTableHeader * tableHeader =
new YTableHeader();
950 patchPkgs =
new NCPkgTable( replacePoint, tableHeader );
952 if ( patchPkgs && packageList )
958 patchPkgs->
setTableType( NCPkgTable::T_PatchPkgs, strategy );
960 patchPkgs->setSize( oldSize.Sze.W, oldSize.Sze.H );
965 packageList->setKeyboardFocus();
984 ZyppSel sel = patchPkgs->
getSelPointer( patchPkgs->getCurrentItem() );
990 _(
"Package Versions"),
992 _(
"List of all available package versions:"),
995 NCursesEvent input = availablePopup->showAvailablesPopup( sel );
997 YDialog::deleteTopmostDialog();
999 patchPkgs->setKeyboardFocus();
1003 void NCPackageSelector::clearInfoArea()
1006 infoText->setText(
"");
1010 packageLabel->setText(
".....................................");
1013 void NCPackageSelector::replaceFilter( FilterMode mode)
1015 patternLabel->setLabel(
" " );
1016 YWidget * replaceChild = replPoint->firstChild();
1021 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
1023 delete replaceChild;
1034 replaceFilterDescr( mode == Search );
1040 YTableHeader *hhh =
new YTableHeader ();
1042 patternPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1043 patternPopup->Redraw();
1045 patternPopup->setKeyboardFocus();
1050 YTableHeader *hhh =
new YTableHeader ();
1052 languagePopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1053 languagePopup->Redraw();
1054 languagePopup->showLocalePackages();
1055 languagePopup->setKeyboardFocus();
1060 YTableHeader *hhh =
new YTableHeader ();
1062 repoPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1063 repoPopup->Redraw();
1064 repoPopup->showRepoPackages();
1065 repoPopup->setKeyboardFocus();
1071 filterPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1072 filterPopup->Redraw();
1074 YStringTreeItem * defaultGroup = filterPopup->getDefaultRpmGroup();
1078 yuiMilestone() <<
"default RPM group: " << defaultGroup->value().translation() << endl;
1079 filterPopup->showRPMGroupPackages ( defaultGroup->value().translation(), defaultGroup );
1083 yuiError() <<
"No default RPM group available" << endl;
1085 filterPopup->setKeyboardFocus();
1091 searchPopup->createLayout( replPoint );
1092 searchPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1093 searchPopup->Redraw();
1095 searchField = searchPopup->getSearchField();
1098 searchField->setKeyboardFocus();
1099 searchField->setNotify(
true);
1106 inst_summary->setSize( oldSize.Sze.W, oldSize.Sze.H );
1107 inst_summary->Redraw();
1108 inst_summary->setKeyboardFocus();
1109 pkgList->fillSummaryList(NCPkgTable::L_Changes);
1112 case PkgClassification:
1115 pkgClass->setSize( oldSize.Sze.W, oldSize.Sze.H );
1117 pkgClass->setKeyboardFocus();
1122 yuiError() <<
"zatim nic" << endl;
1132 pkgList->setCurrentItem(0);
1138 void NCPackageSelector::replaceFilterDescr(
bool b )
1140 YWidget * replaceChild = replPoint2->firstChild();
1145 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
1147 delete replaceChild;
1155 searchSet->setSize( oldSize.Sze.W, oldSize.Sze.H );
1156 searchSet->Redraw();
1160 filter_desc =
new NCRichText( replPoint2,
"");
1161 filter_desc->setSize( oldSize.Sze.W, oldSize.Sze.H );
1162 filter_desc->Redraw();
1177 std::string pkgName = link.substr(6);
1183 for (i = b; i != e; ++i)
1185 ZyppPkg pkgPtr = tryCastToZyppPkg ((*i)->theObj());
1186 if ( pkgPtr && pkgPtr->name() == pkgName )
1188 yuiMilestone() <<
"Package " << pkgName <<
" found" << endl;
1191 popupDescr->showInfoPopup( pkgPtr, *i );
1193 YDialog::deleteTopmostDialog();
1201 yuiError() <<
"Package " << pkgName <<
" NOT found" << endl;
1217 bool changes = diffState ();
1221 NCPopupInfo * cancelMsg =
new NCPopupInfo( wpos( (NCurses::lines()-8)/2, (NCurses::cols()-45)/2 ),
1222 NCPkgStrings::NotifyLabel(),
1223 NCPkgStrings::CancelText(),
1227 cancelMsg->setPreferredSize( 45, 8 );
1228 cancelMsg->focusCancelButton();
1229 NCursesEvent input = cancelMsg->showInfoPopup( );
1231 YDialog::deleteTopmostDialog();
1233 if ( input == NCursesEvent::cancel ) {
1241 yuiMilestone() <<
"Cancel button pressed - leaving package selection" << endl;
1242 const_cast<NCursesEvent &
>(event).result =
"cancel";
1256 bool closeDialog =
true;
1257 bool confirmedAllLicenses =
false;
1267 closeDialog =
false;
1272 }
while ( !confirmedAllLicenses && closeDialog );
1280 _(
"Automatic Changes"),
1282 _(
"In addition to your manual selections, the following" ),
1284 _(
"packages have been changed to resolve dependencies:" )
1286 NCursesEvent input = autoChangePopup->showInfoPopup();
1288 YDialog::deleteTopmostDialog();
1290 if ( input == NCursesEvent::cancel )
1293 closeDialog =
false;
1297 if ( diskspacePopup )
1299 std::string message =
"";
1300 message = diskspacePopup->checkDiskSpace();
1301 if ( message !=
"" )
1304 NCPopupInfo * spaceMsg =
new NCPopupInfo( wpos( (NCurses::lines()-10)/2, (NCurses::cols()-50)/2 ),
1305 NCPkgStrings::ErrorLabel(),
1307 _(
"You can choose to install anyway, but you risk getting a corrupted system." ),
1308 _(
"&Continue anyway" ),
1311 spaceMsg->setPreferredSize( 50, 10 );
1312 spaceMsg->focusOkButton();
1313 NCursesEvent input = spaceMsg->showInfoPopup( );
1315 YDialog::deleteTopmostDialog();
1317 if ( input == NCursesEvent::cancel )
1320 closeDialog =
false;
1332 const_cast<NCursesEvent &
>(event).result =
"accept";
1333 yuiMilestone() <<
"OK button pressed - leaving package selection, starting installation" << endl;
1344 packageList->setKeyboardFocus();
1353 bool allConfirmed =
true;
1360 return allConfirmed;
1365 yuiMilestone() <<
"Showing all pending license agreements" << endl;
1367 bool allConfirmed =
true;
1369 for ( ZyppPoolIterator it = begin; it != end; ++it )
1371 ZyppSel sel = (*it);
1373 switch ( sel->status() )
1380 if ( sel->candidateObj() )
1382 std::string licenseText = sel->candidateObj()->licenseToConfirm();
1384 if ( ! licenseText.empty() )
1386 yuiMilestone() <<
"Package/Patch " << sel->name().c_str() <<
1387 "has a license" << endl;
1389 if( ! sel->hasLicenceConfirmed() )
1395 yuiMilestone() <<
"License for " << sel->name().c_str() <<
1396 " is already confirmed" << endl;
1407 return allConfirmed;
1415 bool license_confirmed =
true;
1417 std::string pkgName = slbPtr->name();
1421 if ( !license_confirmed )
1424 switch ( slbPtr->status() )
1428 slbPtr->setStatus( S_Taboo );
1433 slbPtr->setStatus( S_Protected );
1442 yuiMilestone() <<
"User confirmed license agreement for " << pkgName << endl;
1443 slbPtr->setLicenceConfirmed (
true);
1459 bool cancel =
false;
1461 if ( doit || autoCheck )
1463 yuiMilestone() <<
"Checking dependencies" << endl;
1464 cancel = checkNow( & ok );
1487 std::string html_text =
"";
1488 const std::string htmlIdent(DOCTYPETAG);
1489 bool confirmed =
false;
1491 if ( license.find( htmlIdent ) != std::string::npos )
1493 html_text = license;
1497 html_text =
"<pre>" + license +
"</pre>";
1500 NCPopupInfo * info =
new NCPopupInfo ( wpos( NCurses::lines()/10, NCurses::cols()/10),
1502 _(
"End User License Agreement" ),
1503 "<i>" + pkgName +
"</i><br><br>"
1508 info->setPreferredSize( (NCurses::cols() * 80)/100, (NCurses::lines()*80)/100);
1509 info->focusOkButton();
1510 confirmed = info->showInfoPopup( ) != NCursesEvent::cancel;
1512 YDialog::deleteTopmostDialog();
1540 if ( diskspacePopup )
1542 diskspacePopup->checkDiskSpaceRange( );
1545 if ( diskspaceLabel )
1547 diskspaceLabel->setText( diskspacePopup->calculateDiff().asString() );
1561 std::set<ZyppSel> selectablesToInstall;
1563 for ( ZyppPoolIterator patches_it = zyppPatchesBegin();
1564 patches_it != zyppPatchesEnd();
1567 ZyppPatch patch = tryCastToZyppPatch( (*patches_it)->theObj() );
1571 ZyppPatchContents patchContents( patch->contents() );
1573 for ( ZyppPatchContentsIterator contents_it = patchContents.selectableBegin();
1574 contents_it != patchContents.selectableEnd();
1577 ZyppPkg pkg = tryCastToZyppPkg( (*contents_it)->theObj() );
1586 switch ( sel->status() )
1597 selectablesToInstall.insert( sel );
1603 case S_KeepInstalled:
1617 FSize totalSize = 0;
1619 for ( std::set<ZyppSel>::iterator it = selectablesToInstall.begin();
1620 it != selectablesToInstall.end();
1623 if ( (*it)->candidateObj() )
1624 totalSize += (*it)->candidateObj()->installSize();
1628 if ( diskspaceLabel )
1630 diskspaceLabel->setText( totalSize.asString() );
1639 NCPkgTable * NCPackageSelector::PackageList()
1650 YLayoutBox * split = YUI::widgetFactory()->createVBox( selector );
1652 YLayoutBox * hSplit = YUI::widgetFactory()->createHBox( split );
1654 YAlignment * left1 = YUI::widgetFactory()->createLeft( hSplit );
1655 filterMenu =
new NCPkgMenuFilter( left1, NCPkgStrings::Filter(),
this );
1657 YAlignment * left2 = YUI::widgetFactory()->createLeft( hSplit );
1658 actionMenu =
new NCPkgMenuAction( left2, NCPkgStrings::Actions(),
this );
1660 YAlignment * left3 = YUI::widgetFactory()->createLeft( hSplit );
1661 viewMenu =
new NCPkgMenuView( left3, NCPkgStrings::View(),
this);
1663 YAlignment * left4 = YUI::widgetFactory()->createLeft( hSplit );
1664 depsMenu =
new NCPkgMenuDeps( left4, NCPkgStrings::Deps(),
this);
1667 YTableHeader * tableHeader =
new YTableHeader();
1669 pkgList =
new NCPkgTable( split, tableHeader );
1670 YUI_CHECK_NEW( pkgList );
1675 pkgList->
setTableType( NCPkgTable::T_Patches, strategy );
1682 std::vector<std::string> pkgHeader;
1683 pkgList->getHeader( pkgHeader );
1687 YLayoutBox * hSplit2 = YUI::widgetFactory()->createHBox( split );
1689 YLayoutBox * hSplit3 = YUI::widgetFactory()->createHBox( hSplit2 );
1691 new NCLabel( hSplit3, _(
"Filter: " ) );
1692 packageLabel = YUI::widgetFactory()->createLabel ( hSplit3,
"....................................." );
1694 new NCSpacing( hSplit2, YD_HORIZ,
true, 0.5 );
1696 YLayoutBox * hSplit4 = YUI::widgetFactory()->createHBox( hSplit2 );
1698 new NCLabel( hSplit4, _(
"Total Download Size: " ) );
1700 diskspaceLabel = YUI::widgetFactory()->createLabel ( hSplit4,
" " );
1702 YLayoutBox * vSplit = YUI::widgetFactory()->createVBox( split );
1703 replacePoint = YUI::widgetFactory()->createReplacePoint( vSplit );
1706 YUI_CHECK_NEW( infoText );
1708 YLayoutBox * bottom_bar = YUI::widgetFactory()->createHBox( vSplit );
1709 YAlignment *ll = YUI::widgetFactory()->createLeft( bottom_bar );
1713 YAlignment *r = YUI::widgetFactory()->createRight( bottom_bar );
1714 YLayoutBox * hSplit5 = YUI::widgetFactory()->createHBox( r );
1717 cancelButton =
new NCPushButton( hSplit5, _(
"&Cancel" ) );
1718 YUI_CHECK_NEW( cancelButton );
1719 cancelButton->setFunctionKey( 9 );
1722 okButton =
new NCPushButton( hSplit5, _(
"&Accept" ) );
1723 YUI_CHECK_NEW( okButton );
1724 okButton->setFunctionKey( 10 );
1734 YLayoutBox * vsplit = YUI::widgetFactory()->createVBox( selector );
1735 YLayoutBox * menu_bar = YUI::widgetFactory()->createHBox( vsplit );
1736 YLayoutBox * panels = YUI::widgetFactory()->createVBox( vsplit );
1737 YLayoutBox * bottom_bar = YUI::widgetFactory()->createHBox( vsplit );
1739 YAlignment * left1 = YUI::widgetFactory()->createLeft( menu_bar );
1741 YLayoutBox * menu_buttons = YUI::widgetFactory()->createHBox( left1);
1742 depsMenu =
new NCPkgMenuDeps( menu_buttons, NCPkgStrings::Deps(),
this);
1743 viewMenu =
new NCPkgMenuView( menu_buttons, NCPkgStrings::View(),
this);
1746 if (isRepoMgrEnabled())
1747 configMenu =
new NCPkgMenuConfig( menu_buttons, _(
"C&onfiguration" ),
this);
1749 extrasMenu =
new NCPkgMenuExtras( menu_buttons, NCPkgStrings::Extras(),
this);
1751 YLayoutBox * hbox_top = YUI::widgetFactory()->createHBox( panels );
1752 YLayoutBox * hbox_bottom = YUI::widgetFactory()->createHBox( panels );
1754 YLayoutBox * vbox_left = YUI::widgetFactory()->createVBox( hbox_top );
1755 vbox_left->setWeight(YD_HORIZ,1);
1756 YFrame * fr = YUI::widgetFactory()->createFrame (vbox_left,
"");
1757 YLayoutBox * vv = YUI::widgetFactory()->createVBox( fr );
1758 YAlignment *l = YUI::widgetFactory()->createLeft( vv );
1761 replPoint = YUI::widgetFactory()->createReplacePoint( vv );
1764 searchPopup->createLayout( replPoint );
1766 searchField = searchPopup->getSearchField();
1769 searchField->setKeyboardFocus();
1770 searchField->setNotify(
true );
1773 YAlignment *l1 = YUI::widgetFactory()->createLeft( vbox_left );
1774 patternLabel =
new NCLabel( l1,
" " );
1777 YTableHeader * tableHeader =
new YTableHeader();
1779 YLayoutBox * v = YUI::widgetFactory()->createVBox( hbox_top );
1780 v->setWeight(YD_HORIZ,2);
1782 YUI_CHECK_NEW( pkgList );
1788 case NCPkgTable::T_Packages:
1790 pkgList->
setTableType( NCPkgTable::T_Packages, strategy );
1791 case NCPkgTable::T_Update:
1793 pkgList->
setTableType( NCPkgTable::T_Update, strategy );
1796 pkgList->
setTableType( NCPkgTable::T_Packages, strategy );
1803 std::vector<std::string> pkgHeader;
1804 pkgList->getHeader( pkgHeader );
1808 YLayoutBox * hSplit2 = YUI::widgetFactory()->createHBox( v );
1809 new NCLabel( hSplit2, NCPkgStrings::PackageName() );
1810 packageLabel = YUI::widgetFactory()->createLabel ( hSplit2,
"......................" );
1811 new NCSpacing( hSplit2, YD_HORIZ,
true, 0.5 );
1812 actionMenu =
new NCPkgMenuAction ( hSplit2, NCPkgStrings::Actions(),
this );
1815 replPoint2 = YUI::widgetFactory()->createReplacePoint( hbox_bottom );
1816 replPoint2->setWeight(YD_HORIZ, 1);
1820 YLayoutBox * vSplit = YUI::widgetFactory()->createVBox( hbox_bottom );
1821 vSplit->setWeight(YD_HORIZ, 2);
1822 replacePoint = YUI::widgetFactory()->createReplacePoint( vSplit );
1824 YUI_CHECK_NEW( infoText );
1827 YAlignment *ll = YUI::widgetFactory()->createLeft( bottom_bar );
1829 YUI_CHECK_NEW( helpMenu );
1832 YAlignment *right = YUI::widgetFactory()->createRight( bottom_bar );
1833 YLayoutBox * hSplit = YUI::widgetFactory()->createHBox( right );
1836 cancelButton =
new NCPushButton( hSplit, _(
"&Cancel" ) );
1837 YUI_CHECK_NEW( cancelButton );
1838 cancelButton->setFunctionKey( 9 );
1841 okButton =
new NCPushButton( hSplit, _(
"&Accept" ) );
1842 YUI_CHECK_NEW( okButton );
1843 okButton->setFunctionKey( 10 );
1855 yuiMilestone() <<
"Filling package list: " << (NCWidget *) pkgList << endl;
1857 switch ( pkgList->getTableType() )
1859 case NCPkgTable::T_Patches: {
1863 pkgList->setVisibleInfo(NCPkgTable::I_PatchDescr);
1866 pkgList->setKeyboardFocus();
1869 case NCPkgTable::T_Update: {
1870 if ( ! zypp::getZYpp()->resolver()->problematicUpdateItems().empty() )
1874 pkgList->setVisibleInfo(NCPkgTable::I_Technical);
1880 case NCPkgTable::T_Packages: {
1882 pkgList->setVisibleInfo(NCPkgTable::I_Technical);
1883 searchField->setKeyboardFocus();
1893 replaceFilter ( NCPackageSelector::Repositories );
1895 filterMain->setReposSelected();
1897 else if ( summaryMode )
1899 replaceFilter ( NCPackageSelector::Summary );
1901 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 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.