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_REEVALUATE "PKGMGR_REEVALUATE_RECOMMENDED"
90 #define OPTION_VERIFY "PKGMGR_VERIFY_SYSTEM"
91 #define OPTION_AUTO_CHECK "PKGMGR_AUTO_CHECK"
92 #define OPTION_EXIT "PKGMGR_ACTION_AT_EXIT"
94 typedef zypp::Patch::Contents ZyppPatchContents;
95 typedef zypp::Patch::Contents::Selectable_iterator ZyppPatchContentsIterator;
109 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 setInstallAlreadyRecommended( isInstallAlreadyRecommended() );
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 for already installed packages" );
245 catch(
const std::exception &e )
247 yuiError() <<
"Writing " << OPTION_REEVALUATE <<
" 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();
275 bool NCPackageSelector::isCleanDepsOnRemove()
277 return zypp::getZYpp()->resolver()->cleandepsOnRemove();
280 void NCPackageSelector::setCleanDepsOnRemove(
bool on )
282 zypp::getZYpp()->resolver()->setCleandepsOnRemove( on );
283 zypp::getZYpp()->resolver()->resolvePool();
291 bool NCPackageSelector::isInstallAlreadyRecommended()
293 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_REEVALUATE );
295 if ( it != sysconfig.end() )
297 yuiMilestone() << OPTION_REEVALUATE<<
": " << it->second << endl;
298 if ( it->second ==
"yes" )
299 installRecommended =
true;
300 else if ( it->second ==
"no")
301 installRecommended =
false;
303 installRecommended = !(zypp::getZYpp()->resolver()->ignoreAlreadyRecommended());
307 installRecommended = !(zypp::getZYpp()->resolver()->ignoreAlreadyRecommended());
309 yuiMilestone() <<
"installRecommended: " << (installRecommended?
"yes":
"no") << endl;
311 return installRecommended;
314 void NCPackageSelector::setInstallAlreadyRecommended(
bool on )
316 installRecommended = on;
317 zypp::getZYpp()->resolver()->setIgnoreAlreadyRecommended( !on );
319 zypp::getZYpp()->resolver()->resolvePool();
324 bool NCPackageSelector::isAutoCheck()
328 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_AUTO_CHECK);
330 if ( it != sysconfig.end() )
332 yuiMilestone() << OPTION_AUTO_CHECK <<
": " << it->second << endl;
333 if ( it->second ==
"no" )
336 yuiMilestone() <<
"autoCheck " << (autoCheck?
"yes":
"no") << endl;
341 bool NCPackageSelector::isVerifySystem( )
343 std::map <std::string,std::string>::const_iterator it = sysconfig.find( OPTION_VERIFY );
345 if ( it != sysconfig.end() )
347 yuiMilestone() << OPTION_VERIFY <<
": " << it->second << endl;
348 if ( it->second ==
"yes" )
350 else if ( it->second ==
"no")
351 verifySystem =
false;
353 verifySystem = zypp::getZYpp()->resolver()->systemVerification();
357 verifySystem = zypp::getZYpp()->resolver()->systemVerification();
359 yuiMilestone() <<
"verifySystem: " << (verifySystem?
"yes":
"no") << endl;
364 void NCPackageSelector::setVerifySystem(
bool on )
367 zypp::getZYpp()->resolver()->setSystemVerification( on );
369 zypp::getZYpp()->resolver()->resolvePool();
377 bool NCPackageSelector::isAllowVendorChange()
379 zypp::Resolver_Ptr resolver = zypp::getZYpp()->resolver();
380 bool change = resolver->allowVendorChange();
381 yuiMilestone() <<
"Vendor change allowed: " << (change?
"true":
"false") << endl;
385 void NCPackageSelector::setAllowVendorChange(
bool on )
387 zypp::getZYpp()->resolver()->setAllowVendorChange( on );
388 zypp::getZYpp()->resolver()->resolvePool();
399 ZyppPool p = zyppPool ();
401 p.saveState<zypp::Package> ();
402 p.saveState<zypp::SrcPackage> ();
404 p.saveState<zypp::Patch> ();
406 p.saveState<zypp::Pattern> ();
410 void NCPackageSelector::restoreState ()
412 ZyppPool p = zyppPool ();
414 p.restoreState<zypp::Package> ();
415 p.restoreState<zypp::SrcPackage> ();
417 p.restoreState<zypp::Patch> ();
419 p.restoreState<zypp::Pattern> ();
423 bool NCPackageSelector::diffState ()
425 ZyppPool p = zyppPool ();
429 std::ostream & log = yuiMilestone();
430 log <<
"diffState" << endl;
431 diff = diff || p.diffState<zypp::Package> ();
433 diff = diff || p.diffState<zypp::SrcPackage> ();
436 diff = diff || p.diffState<zypp::Patch> ();
439 diff = diff || p.diffState<zypp::Pattern> ();
456 if ( event == NCursesEvent::handled )
459 yuiMilestone() <<
"widget event: " <<
event << endl;
461 if ( event == NCursesEvent::button )
463 if ( event.widget == okButton )
467 else if ( event.widget == cancelButton )
471 else if ( event.widget == filterPopup )
473 retVal = filterPopup->handleEvent();
475 else if ( event.widget == filterMain )
477 retVal = filterMain->handleEvent();
479 else if ( event.widget == searchField )
481 if ( event.reason == YEvent::Activated )
483 retVal = searchPopup->showSearchResultPackages();
491 else if ( event == NCursesEvent::menu )
493 if ( event.widget == actionMenu )
495 retVal = actionMenu->handleEvent( event );
496 else if ( event.widget == viewMenu )
498 retVal = viewMenu->handleEvent( event );
499 else if ( event.widget == depsMenu )
500 retVal = depsMenu->handleEvent( event );
501 else if ( event.widget == extrasMenu )
502 retVal = extrasMenu->handleEvent( event );
503 else if ( event.widget == configMenu )
504 retVal = configMenu->handleEvent( event );
505 else if ( event.widget == helpMenu )
506 retVal = helpMenu->handleEvent( event );
507 else if ( event.widget == filterMenu )
508 retVal = filterMenu->handleEvent( event );
509 else if ( event.selection->label().substr(0,4) ==
"pkg:" )
538 q.addKind( zypp::ResKind::patch );
539 q.addAttribute( zypp::sat::SolvAttr::keywords );
542 q.addAttribute( zypp::sat::SolvAttr::name );
546 q.addAttribute( zypp::sat::SolvAttr::summary );
549 for( zypp::PoolQuery::Selectable_iterator it = q.selectableBegin();
550 it != q.selectableEnd(); it++)
552 yuiMilestone() << (*it)->name() << endl;
553 ZyppPatch patchPtr = tryCastToZyppPatch( (*it)->theObj() );
582 yuiError() <<
"No valid NCPkgTable widget" << endl;
590 std::list<ZyppSel> patchList( zyppPatchesBegin (), zyppPatchesEnd () );
591 patchList.sort( sortByName );
592 std::list<ZyppSel>::iterator listIt = patchList.begin();
594 while ( listIt != patchList.end() )
596 ZyppPatch patchPtr = tryCastToZyppPatch( ( *listIt)->theObj() );
605 if ( filter == NCPkgMenuFilter::F_All
619 case NCPkgMenuFilter::F_Needed:
625 case NCPkgMenuFilter::F_Unneeded:
627 packageLabel->setLabel( NCPkgStrings::InstPatches() );
632 packageLabel->setLabel( NCPkgStrings::Patches() );
652 yuiError() <<
"Widget is not a valid NCPkgTable widget" << endl;
659 std::list<zypp::PoolItem> problemList = zypp::getZYpp()->resolver()->problematicUpdateItems();
661 for ( std::list<zypp::PoolItem>::const_iterator it = problemList.begin();
662 it != problemList.end();
665 ZyppPkg pkg = tryCastToZyppPkg( (*it).resolvable() );
673 yuiMilestone() <<
"Problematic package: " << pkg->name().c_str() <<
" " <<
674 pkg->edition().asString().c_str() << endl;
700 if ( !pkgTable || !objPtr )
705 std::set<ZyppSel> patchSelectables;
706 ZyppPatch patchPtr = tryCastToZyppPatch( objPtr );
711 ZyppPatchContents patchContents( patchPtr->contents() );
713 yuiMilestone() <<
"Filtering for patch: " << patchPtr->name().c_str() <<
" number of atoms: "
714 << patchContents.size() << endl ;
716 for ( ZyppPatchContentsIterator it = patchContents.selectableBegin();
717 it != patchContents.selectableEnd();
720 ZyppPkg pkg = tryCastToZyppPkg( (*it)->theObj() );
724 yuiMilestone() <<
"Patch package found: " << (*it)->name().c_str() << endl;
729 if ( inContainer( patchSelectables, sel ) )
731 yuiMilestone() <<
"Suppressing duplicate selectable: " << (*it)->name().c_str() <<
"-" <<
732 pkg->edition().asString().c_str() <<
" " <<
733 pkg->arch().asString().c_str() << endl;
737 patchSelectables.insert( sel );
738 yuiDebug() << (*it)->name().c_str() <<
": Version: " << pkg->edition().asString() << endl;
746 yuiDebug() <<
"Found unknown atom of kind %s: %s" <<
747 (*it)->kind().asString().c_str() <<
748 (*it)->name().c_str() << endl;
768 NCPkgMenuFilter::PatchFilter filter )
772 bool displayPatch =
false;
776 yuiError() <<
"Widget is not a valid NCPkgTable widget" << endl;
779 if ( !patchPtr || !selectable || !selectable->hasCandidateObj() )
781 yuiError() <<
"Patch data not valid" << endl;
784 yuiDebug() <<
"Filter: " << filter << endl;
786 if ( filter == NCPkgMenuFilter::F_All )
791 else if ( selectable->candidateObj().isRelevant() )
795 case NCPkgMenuFilter::F_Unneeded:
797 if ( selectable->candidateObj().isSatisfied() &&
798 !selectable->candidateObj().status().isToBeInstalled() )
804 case NCPkgMenuFilter::F_Needed:
806 if ( !selectable->candidateObj().isSatisfied() ||
808 selectable->candidateObj().status().isToBeInstalled() )
812 case NCPkgMenuFilter::F_Security:
814 if ( patchPtr->category() ==
"security" )
818 case NCPkgMenuFilter::F_Recommended:
820 if ( patchPtr->category() ==
"recommended" )
824 case NCPkgMenuFilter::F_Optional:
826 if ( patchPtr->category() ==
"optional" )
831 yuiWarning() <<
"Unknown patch filter" << endl;
847 wrect NCPackageSelector::deleteReplacePoint()
850 YWidget * replaceChild = replacePoint->firstChild();
855 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
862 patchPkgsVersions = 0;
878 wrect oldSize = deleteReplacePoint();
885 infoText->setSize( oldSize.Sze.W, oldSize.Sze.H );
900 wrect oldSize = deleteReplacePoint();
904 YTableHeader * tableHeader =
new YTableHeader();
905 versionsList =
new NCPkgTable( replacePoint, tableHeader );
909 if ( versionsList && packageList )
915 versionsList->setSize( oldSize.Sze.W, oldSize.Sze.H );
917 versionsList->fillAvailableList( packageList->
getSelPointer( packageList->getCurrentItem() ) );
918 versionsList->Redraw();
920 packageList->setKeyboardFocus();
935 wrect oldSize = deleteReplacePoint();
939 YTableHeader * tableHeader =
new YTableHeader();
940 patchPkgs =
new NCPkgTable( replacePoint, tableHeader );
942 if ( patchPkgs && packageList )
948 patchPkgs->
setTableType( NCPkgTable::T_PatchPkgs, strategy );
950 patchPkgs->setSize( oldSize.Sze.W, oldSize.Sze.H );
955 packageList->setKeyboardFocus();
974 ZyppSel sel = patchPkgs->
getSelPointer( patchPkgs->getCurrentItem() );
980 _(
"Package Versions"),
982 _(
"List of all available package versions:"),
985 NCursesEvent input = availablePopup->showAvailablesPopup( sel );
987 YDialog::deleteTopmostDialog();
989 patchPkgs->setKeyboardFocus();
993 void NCPackageSelector::clearInfoArea()
996 infoText->setText(
"");
1000 packageLabel->setText(
".....................................");
1003 void NCPackageSelector::replaceFilter( FilterMode mode)
1005 patternLabel->setLabel(
" " );
1006 YWidget * replaceChild = replPoint->firstChild();
1011 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
1013 delete replaceChild;
1024 replaceFilterDescr( mode == Search );
1030 YTableHeader *hhh =
new YTableHeader ();
1032 patternPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1033 patternPopup->Redraw();
1035 patternPopup->setKeyboardFocus();
1040 YTableHeader *hhh =
new YTableHeader ();
1042 languagePopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1043 languagePopup->Redraw();
1044 languagePopup->showLocalePackages();
1045 languagePopup->setKeyboardFocus();
1050 YTableHeader *hhh =
new YTableHeader ();
1052 repoPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1053 repoPopup->Redraw();
1054 repoPopup->showRepoPackages();
1055 repoPopup->setKeyboardFocus();
1061 filterPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1062 filterPopup->Redraw();
1064 YStringTreeItem * defaultGroup = filterPopup->getDefaultRpmGroup();
1068 yuiMilestone() <<
"default RPM group: " << defaultGroup->value().translation() << endl;
1069 filterPopup->showRPMGroupPackages ( defaultGroup->value().translation(), defaultGroup );
1073 yuiError() <<
"No default RPM group available" << endl;
1075 filterPopup->setKeyboardFocus();
1081 searchPopup->createLayout( replPoint );
1082 searchPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
1083 searchPopup->Redraw();
1085 searchField = searchPopup->getSearchField();
1088 searchField->setKeyboardFocus();
1089 searchField->setNotify(
true);
1096 inst_summary->setSize( oldSize.Sze.W, oldSize.Sze.H );
1097 inst_summary->Redraw();
1098 inst_summary->setKeyboardFocus();
1099 pkgList->fillSummaryList(NCPkgTable::L_Changes);
1102 case PkgClassification:
1105 pkgClass->setSize( oldSize.Sze.W, oldSize.Sze.H );
1107 pkgClass->setKeyboardFocus();
1112 yuiError() <<
"zatim nic" << endl;
1122 pkgList->setCurrentItem(0);
1128 void NCPackageSelector::replaceFilterDescr(
bool b )
1130 YWidget * replaceChild = replPoint2->firstChild();
1135 oldSize =
dynamic_cast<NCWidget *
>(replaceChild)->wGetSize();
1137 delete replaceChild;
1145 searchSet->setSize( oldSize.Sze.W, oldSize.Sze.H );
1146 searchSet->Redraw();
1150 filter_desc =
new NCRichText( replPoint2,
"");
1151 filter_desc->setSize( oldSize.Sze.W, oldSize.Sze.H );
1152 filter_desc->Redraw();
1167 std::string pkgName = link.substr(6);
1173 for (i = b; i != e; ++i)
1175 ZyppPkg pkgPtr = tryCastToZyppPkg ((*i)->theObj());
1176 if ( pkgPtr && pkgPtr->name() == pkgName )
1178 yuiMilestone() <<
"Package " << pkgName <<
" found" << endl;
1181 popupDescr->showInfoPopup( pkgPtr, *i );
1183 YDialog::deleteTopmostDialog();
1191 yuiError() <<
"Package " << pkgName <<
" NOT found" << endl;
1207 bool changes = diffState ();
1211 NCPopupInfo * cancelMsg =
new NCPopupInfo( wpos( (NCurses::lines()-8)/2, (NCurses::cols()-45)/2 ),
1212 NCPkgStrings::NotifyLabel(),
1213 NCPkgStrings::CancelText(),
1217 cancelMsg->setPreferredSize( 45, 8 );
1218 cancelMsg->focusCancelButton();
1219 NCursesEvent input = cancelMsg->showInfoPopup( );
1221 YDialog::deleteTopmostDialog();
1223 if ( input == NCursesEvent::cancel ) {
1231 yuiMilestone() <<
"Cancel button pressed - leaving package selection" << endl;
1232 const_cast<NCursesEvent &
>(event).result =
"cancel";
1246 bool closeDialog =
true;
1247 bool confirmedAllLicenses =
false;
1257 closeDialog =
false;
1262 }
while ( !confirmedAllLicenses && closeDialog );
1270 _(
"Automatic Changes"),
1272 _(
"In addition to your manual selections, the following" ),
1274 _(
"packages have been changed to resolve dependencies:" )
1276 NCursesEvent input = autoChangePopup->showInfoPopup();
1278 YDialog::deleteTopmostDialog();
1280 if ( input == NCursesEvent::cancel )
1283 closeDialog =
false;
1287 if ( diskspacePopup )
1289 std::string message =
"";
1290 message = diskspacePopup->checkDiskSpace();
1291 if ( message !=
"" )
1294 NCPopupInfo * spaceMsg =
new NCPopupInfo( wpos( (NCurses::lines()-10)/2, (NCurses::cols()-50)/2 ),
1295 NCPkgStrings::ErrorLabel(),
1297 _(
"You can choose to install anyway, but you risk getting a corrupted system." ),
1298 _(
"&Continue anyway" ),
1301 spaceMsg->setPreferredSize( 50, 10 );
1302 spaceMsg->focusOkButton();
1303 NCursesEvent input = spaceMsg->showInfoPopup( );
1305 YDialog::deleteTopmostDialog();
1307 if ( input == NCursesEvent::cancel )
1310 closeDialog =
false;
1322 const_cast<NCursesEvent &
>(event).result =
"accept";
1323 yuiMilestone() <<
"OK button pressed - leaving package selection, starting installation" << endl;
1334 packageList->setKeyboardFocus();
1343 bool allConfirmed =
true;
1350 return allConfirmed;
1355 yuiMilestone() <<
"Showing all pending license agreements" << endl;
1357 bool allConfirmed =
true;
1359 for ( ZyppPoolIterator it = begin; it != end; ++it )
1361 ZyppSel sel = (*it);
1363 switch ( sel->status() )
1370 if ( sel->candidateObj() )
1372 std::string licenseText = sel->candidateObj()->licenseToConfirm();
1374 if ( ! licenseText.empty() )
1376 yuiMilestone() <<
"Package/Patch " << sel->name().c_str() <<
1377 "has a license" << endl;
1379 if( ! sel->hasLicenceConfirmed() )
1385 yuiMilestone() <<
"License for " << sel->name().c_str() <<
1386 " is already confirmed" << endl;
1397 return allConfirmed;
1405 bool license_confirmed =
true;
1407 std::string pkgName = slbPtr->name();
1411 if ( !license_confirmed )
1414 switch ( slbPtr->status() )
1418 slbPtr->setStatus( S_Taboo );
1423 slbPtr->setStatus( S_Protected );
1432 yuiMilestone() <<
"User confirmed license agreement for " << pkgName << endl;
1433 slbPtr->setLicenceConfirmed (
true);
1449 bool cancel =
false;
1451 if ( doit || autoCheck )
1453 yuiMilestone() <<
"Checking dependencies" << endl;
1454 cancel = checkNow( & ok );
1477 std::string html_text =
"";
1478 const std::string htmlIdent(DOCTYPETAG);
1479 bool confirmed =
false;
1481 if ( license.find( htmlIdent ) != std::string::npos )
1483 html_text = license;
1487 html_text =
"<pre>" + license +
"</pre>";
1490 NCPopupInfo * info =
new NCPopupInfo ( wpos( NCurses::lines()/10, NCurses::cols()/10),
1492 _(
"End User License Agreement" ),
1493 "<i>" + pkgName +
"</i><br><br>"
1498 info->setPreferredSize( (NCurses::cols() * 80)/100, (NCurses::lines()*80)/100);
1499 info->focusOkButton();
1500 confirmed = info->showInfoPopup( ) != NCursesEvent::cancel;
1502 YDialog::deleteTopmostDialog();
1530 if ( diskspacePopup )
1532 diskspacePopup->checkDiskSpaceRange( );
1535 if ( diskspaceLabel )
1537 diskspaceLabel->setText( diskspacePopup->calculateDiff().asString() );
1551 std::set<ZyppSel> selectablesToInstall;
1553 for ( ZyppPoolIterator patches_it = zyppPatchesBegin();
1554 patches_it != zyppPatchesEnd();
1557 ZyppPatch patch = tryCastToZyppPatch( (*patches_it)->theObj() );
1561 ZyppPatchContents patchContents( patch->contents() );
1563 for ( ZyppPatchContentsIterator contents_it = patchContents.selectableBegin();
1564 contents_it != patchContents.selectableEnd();
1567 ZyppPkg pkg = tryCastToZyppPkg( (*contents_it)->theObj() );
1576 switch ( sel->status() )
1587 selectablesToInstall.insert( sel );
1593 case S_KeepInstalled:
1607 FSize totalSize = 0;
1609 for ( std::set<ZyppSel>::iterator it = selectablesToInstall.begin();
1610 it != selectablesToInstall.end();
1613 if ( (*it)->candidateObj() )
1614 totalSize += (*it)->candidateObj()->installSize();
1618 if ( diskspaceLabel )
1620 diskspaceLabel->setText( totalSize.asString() );
1629 NCPkgTable * NCPackageSelector::PackageList()
1640 YLayoutBox * split = YUI::widgetFactory()->createVBox( selector );
1642 YLayoutBox * hSplit = YUI::widgetFactory()->createHBox( split );
1644 YAlignment * left1 = YUI::widgetFactory()->createLeft( hSplit );
1645 filterMenu =
new NCPkgMenuFilter( left1, NCPkgStrings::Filter(),
this );
1647 YAlignment * left2 = YUI::widgetFactory()->createLeft( hSplit );
1648 actionMenu =
new NCPkgMenuAction( left2, NCPkgStrings::Actions(),
this );
1650 YAlignment * left3 = YUI::widgetFactory()->createLeft( hSplit );
1651 viewMenu =
new NCPkgMenuView( left3, NCPkgStrings::View(),
this);
1653 YAlignment * left4 = YUI::widgetFactory()->createLeft( hSplit );
1654 depsMenu =
new NCPkgMenuDeps( left4, NCPkgStrings::Deps(),
this);
1657 YTableHeader * tableHeader =
new YTableHeader();
1659 pkgList =
new NCPkgTable( split, tableHeader );
1660 YUI_CHECK_NEW( pkgList );
1665 pkgList->
setTableType( NCPkgTable::T_Patches, strategy );
1672 std::vector<std::string> pkgHeader;
1673 pkgList->getHeader( pkgHeader );
1677 YLayoutBox * hSplit2 = YUI::widgetFactory()->createHBox( split );
1679 YLayoutBox * hSplit3 = YUI::widgetFactory()->createHBox( hSplit2 );
1681 new NCLabel( hSplit3, _(
"Filter: " ) );
1682 packageLabel = YUI::widgetFactory()->createLabel ( hSplit3,
"....................................." );
1684 new NCSpacing( hSplit2, YD_HORIZ,
true, 0.5 );
1686 YLayoutBox * hSplit4 = YUI::widgetFactory()->createHBox( hSplit2 );
1688 new NCLabel( hSplit4, _(
"Total Download Size: " ) );
1690 diskspaceLabel = YUI::widgetFactory()->createLabel ( hSplit4,
" " );
1692 YLayoutBox * vSplit = YUI::widgetFactory()->createVBox( split );
1693 replacePoint = YUI::widgetFactory()->createReplacePoint( vSplit );
1696 YUI_CHECK_NEW( infoText );
1698 YLayoutBox * bottom_bar = YUI::widgetFactory()->createHBox( vSplit );
1699 YAlignment *ll = YUI::widgetFactory()->createLeft( bottom_bar );
1703 YAlignment *r = YUI::widgetFactory()->createRight( bottom_bar );
1704 YLayoutBox * hSplit5 = YUI::widgetFactory()->createHBox( r );
1707 cancelButton =
new NCPushButton( hSplit5, _(
"&Cancel" ) );
1708 YUI_CHECK_NEW( cancelButton );
1709 cancelButton->setFunctionKey( 9 );
1712 okButton =
new NCPushButton( hSplit5, _(
"&Accept" ) );
1713 YUI_CHECK_NEW( okButton );
1714 okButton->setFunctionKey( 10 );
1724 YLayoutBox * vsplit = YUI::widgetFactory()->createVBox( selector );
1725 YLayoutBox * menu_bar = YUI::widgetFactory()->createHBox( vsplit );
1726 YLayoutBox * panels = YUI::widgetFactory()->createVBox( vsplit );
1727 YLayoutBox * bottom_bar = YUI::widgetFactory()->createHBox( vsplit );
1729 YAlignment * left1 = YUI::widgetFactory()->createLeft( menu_bar );
1731 YLayoutBox * menu_buttons = YUI::widgetFactory()->createHBox( left1);
1732 depsMenu =
new NCPkgMenuDeps( menu_buttons, NCPkgStrings::Deps(),
this);
1733 viewMenu =
new NCPkgMenuView( menu_buttons, NCPkgStrings::View(),
this);
1736 if (isRepoMgrEnabled())
1737 configMenu =
new NCPkgMenuConfig( menu_buttons, _(
"C&onfiguration" ),
this);
1739 extrasMenu =
new NCPkgMenuExtras( menu_buttons, NCPkgStrings::Extras(),
this);
1741 YLayoutBox * hbox_top = YUI::widgetFactory()->createHBox( panels );
1742 YLayoutBox * hbox_bottom = YUI::widgetFactory()->createHBox( panels );
1744 YLayoutBox * vbox_left = YUI::widgetFactory()->createVBox( hbox_top );
1745 vbox_left->setWeight(YD_HORIZ,1);
1746 YFrame * fr = YUI::widgetFactory()->createFrame (vbox_left,
"");
1747 YLayoutBox * vv = YUI::widgetFactory()->createVBox( fr );
1748 YAlignment *l = YUI::widgetFactory()->createLeft( vv );
1751 replPoint = YUI::widgetFactory()->createReplacePoint( vv );
1754 searchPopup->createLayout( replPoint );
1756 searchField = searchPopup->getSearchField();
1759 searchField->setKeyboardFocus();
1760 searchField->setNotify(
true );
1763 YAlignment *l1 = YUI::widgetFactory()->createLeft( vbox_left );
1764 patternLabel =
new NCLabel( l1,
" " );
1767 YTableHeader * tableHeader =
new YTableHeader();
1769 YLayoutBox * v = YUI::widgetFactory()->createVBox( hbox_top );
1770 v->setWeight(YD_HORIZ,2);
1772 YUI_CHECK_NEW( pkgList );
1778 case NCPkgTable::T_Packages:
1780 pkgList->
setTableType( NCPkgTable::T_Packages, strategy );
1781 case NCPkgTable::T_Update:
1783 pkgList->
setTableType( NCPkgTable::T_Update, strategy );
1786 pkgList->
setTableType( NCPkgTable::T_Packages, strategy );
1793 std::vector<std::string> pkgHeader;
1794 pkgList->getHeader( pkgHeader );
1798 YLayoutBox * hSplit2 = YUI::widgetFactory()->createHBox( v );
1799 new NCLabel( hSplit2, NCPkgStrings::PackageName() );
1800 packageLabel = YUI::widgetFactory()->createLabel ( hSplit2,
"......................" );
1801 new NCSpacing( hSplit2, YD_HORIZ,
true, 0.5 );
1802 actionMenu =
new NCPkgMenuAction ( hSplit2, NCPkgStrings::Actions(),
this );
1805 replPoint2 = YUI::widgetFactory()->createReplacePoint( hbox_bottom );
1806 replPoint2->setWeight(YD_HORIZ, 1);
1810 YLayoutBox * vSplit = YUI::widgetFactory()->createVBox( hbox_bottom );
1811 vSplit->setWeight(YD_HORIZ, 2);
1812 replacePoint = YUI::widgetFactory()->createReplacePoint( vSplit );
1814 YUI_CHECK_NEW( infoText );
1817 YAlignment *ll = YUI::widgetFactory()->createLeft( bottom_bar );
1819 YUI_CHECK_NEW( helpMenu );
1822 YAlignment *right = YUI::widgetFactory()->createRight( bottom_bar );
1823 YLayoutBox * hSplit = YUI::widgetFactory()->createHBox( right );
1826 cancelButton =
new NCPushButton( hSplit, _(
"&Cancel" ) );
1827 YUI_CHECK_NEW( cancelButton );
1828 cancelButton->setFunctionKey( 9 );
1831 okButton =
new NCPushButton( hSplit, _(
"&Accept" ) );
1832 YUI_CHECK_NEW( okButton );
1833 okButton->setFunctionKey( 10 );
1845 yuiMilestone() <<
"Filling package list: " << (NCWidget *) pkgList << endl;
1847 switch ( pkgList->getTableType() )
1849 case NCPkgTable::T_Patches: {
1853 pkgList->setVisibleInfo(NCPkgTable::I_PatchDescr);
1856 pkgList->setKeyboardFocus();
1859 case NCPkgTable::T_Update: {
1860 if ( ! zypp::getZYpp()->resolver()->problematicUpdateItems().empty() )
1864 pkgList->setVisibleInfo(NCPkgTable::I_Technical);
1870 case NCPkgTable::T_Packages: {
1872 pkgList->setVisibleInfo(NCPkgTable::I_Technical);
1873 searchField->setKeyboardFocus();
1883 replaceFilter ( NCPackageSelector::Repositories );
1885 filterMain->setReposSelected();
1887 else if ( summaryMode )
1889 replaceFilter ( NCPackageSelector::Summary );
1891 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.