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;
273 }
while ( postAgain() );
280 NCursesEvent NCPkgPopupTable::showAvailablesPopup( ZyppSel sel )
282 postevent = NCursesEvent();
284 if ( !fillAvailables( pkgTable, sel ) )
286 postevent = NCursesEvent::button;
293 }
while ( postAgain() );
306 int NCPkgPopupTable::preferredWidth()
308 return NCurses::cols()-15;
317 int NCPkgPopupTable::preferredHeight()
319 return NCurses::lines()-5;
330 NCursesEvent NCPkgPopupTable::wHandleInput( wint_t ch )
333 return NCursesEvent::cancel;
335 if ( ch == KEY_RETURN )
336 return NCursesEvent::button;
338 return NCDialog::wHandleInput( ch );
349 bool NCPkgPopupTable::postAgain()
351 if ( ! postevent.widget )
354 if ( postevent.widget == cancelButton )
360 postevent = NCursesEvent::cancel;
363 if ( postevent == NCursesEvent::button || postevent == NCursesEvent::cancel )
void insertVerifiedPkg(std::string pkgname)
std::set< std::string > getVerifiedPkgs()
bool createListEntry(ZyppPkg pkgPtr, ZyppSel slbPtr)
unsigned int getNumLines()
virtual void itemsCleared()
void setPackager(NCPackageSelector *pkg)
static const std::string CancelLabel()
static const std::string OKLabel()