41 #define YUILogComponent "ncurses-pkg" 44 #include "YMenuButton.h" 47 #include "NCLayoutBox.h" 48 #include "NCSpacing.h" 49 #include "NCPkgStrings.h" 50 #include "NCPackageSelector.h" 52 #include "NCPushButton.h" 53 #include "NCPkgTable.h" 57 #include <zypp/ui/Selectable.h> 58 #include <zypp/ui/UserWantedPackages.h> 60 #include "NCPkgPopupTable.h" 81 : NCPopup( at, false )
87 createLayout( headline, label1, label2, add_cancel );
98 NCPkgPopupTable::~NCPkgPopupTable()
110 void NCPkgPopupTable::createLayout( std::string headline,
116 NCLayoutBox * split =
new NCLayoutBox(
this, YD_VERT );
118 new NCSpacing( split, YD_VERT,
false, 0.6 );
121 new NCLabel( split, headline,
true,
false );
123 new NCSpacing( split, YD_VERT,
false, 0.6 );
128 new NCLabel( split, label1,
false,
false );
133 new NCLabel( split, label2,
false,
false );
135 YTableHeader * tableHeader =
new YTableHeader();
137 pkgTable =
new NCPkgTable( split, tableHeader );
142 NCLayoutBox * hSplit =
new NCLayoutBox( split, YD_HORIZ );
143 new NCSpacing( hSplit, YD_HORIZ,
true, 0.2 );
147 okButton->setFunctionKey( 10 );
148 okButton->setKeyboardFocus();
152 new NCSpacing( hSplit, YD_HORIZ,
true, 0.4 );
156 cancelButton->setFunctionKey( 9 );
158 new NCSpacing( hSplit, YD_HORIZ,
true, 0.2 );
160 new NCSpacing( split, YD_VERT,
false, 0.6 );
172 bool NCPkgPopupTable::fillAutoChanges(
NCPkgTable * pkgTable )
179 std::set<std::string> ignoredNames;
180 std::set<std::string> userWantedNames = zypp::ui::userWantedPackageNames();
185 std::insert_iterator< std::set<std::string> > result (ignoredNames, ignoredNames.begin());
187 if (!verifiedNames.empty())
190 set_union(userWantedNames.begin(), userWantedNames.end(),
191 verifiedNames.begin(), verifiedNames.end(), result );
195 ignoredNames = userWantedNames;
197 for ( std::set<std::string>::iterator it = ignoredNames.begin(); it != ignoredNames.end(); ++it )
198 yuiMilestone() <<
"Ignoring: " << *it << endl;
205 for (it = b; it != e; ++it)
210 if ( slb->toModify() && slb->modifiedBy() != zypp::ResStatus::USER )
212 if ( ! inContainer( ignoredNames, slb->name() ) )
214 ZyppPkg pkgPtr = tryCastToZyppPkg (slb->theObj());
217 yuiMilestone() <<
"The status of " << pkgPtr->name() <<
" has automatically changed" << endl;
238 bool NCPkgPopupTable::fillAvailables(
NCPkgTable * pkgTable, ZyppSel sel )
244 pkgTable->fillAvailableList( sel );
260 NCursesEvent NCPkgPopupTable::showInfoPopup()
262 postevent = NCursesEvent();
264 if ( !fillAutoChanges( pkgTable ) )
266 postevent = NCursesEvent::button;
274 }
while ( postAgain() );
281 NCursesEvent NCPkgPopupTable::showAvailablesPopup( ZyppSel sel )
283 postevent = NCursesEvent();
285 if ( !fillAvailables( pkgTable, sel ) )
287 postevent = NCursesEvent::button;
295 }
while ( postAgain() );
308 int NCPkgPopupTable::preferredWidth()
310 return NCurses::cols()-15;
319 int NCPkgPopupTable::preferredHeight()
321 return NCurses::lines()-5;
332 NCursesEvent NCPkgPopupTable::wHandleInput( wint_t ch )
335 return NCursesEvent::cancel;
337 if ( ch == KEY_RETURN )
338 return NCursesEvent::button;
340 return NCDialog::wHandleInput( ch );
351 bool NCPkgPopupTable::postAgain()
353 if ( ! postevent.widget )
356 if ( postevent.widget == cancelButton )
362 postevent = NCursesEvent::cancel;
365 if ( postevent == NCursesEvent::button || postevent == NCursesEvent::cancel )
void insertVerifiedPkg(std::string pkgname)
Insert package name into the list of already selected for automatic changes.
void clearVerifiedPkgs()
Empty the std::set of packages selected for automatic changes.
std::set< std::string > getVerifiedPkgs()
Get list of packages already selected for automatic changes (usually via 'verify system' call) ...
void fillHeader()
Fills the header of the table.
bool createListEntry(ZyppPkg pkgPtr, ZyppSel slbPtr)
Creates a line in the package table.
unsigned int getNumLines()
Returns the number of lines in the table (the table size)
virtual void itemsCleared()
Clears the package list.
void drawList()
Draws the package list (has to be called after the loop with addLine() calls)
void setPackager(NCPackageSelector *pkg)
Sets the member variable PackageSelector *packager.
static const std::string CancelLabel()
The label of the Cancel button.
static const std::string OKLabel()
The label of the OK button.