41 #define YUILogComponent "ncurses-pkg" 44 #include "NCPkgFilterClassification.h" 47 #include "NCLayoutBox.h" 48 #include "NCSpacing.h" 49 #include "NCPackageSelector.h" 70 :NCSelectionBox( parent,
"" )
74 suggested =
new YItem( _(
"Suggested Packages") );
77 recommended =
new YItem( _(
"Recommended Packages") );
78 addItem( recommended );
80 orphaned =
new YItem( _(
"Orphaned Packages") );
83 unneeded =
new YItem( _(
"Unneeded Packages" ) );
86 multiversion =
new YItem( _(
"Multiversion Packages" ) );
87 addItem( multiversion );
89 retracted =
new YItem( _(
"Retracted Packages" ) );
92 retractedInstalled =
new YItem( _(
"Retracted Installed Packages" ) );
93 addItem( retractedInstalled );
95 all =
new YItem( _(
"All Packages" ) );
103 bool NCPkgFilterClassification::showPackages()
105 NCPkgTable * packageList = packager->PackageList();
106 YItem * pkgClass = currentPkgClass();
107 yuiMilestone() <<
"Showing pkg class: " << pkgClass->label() << endl;
114 yuiError() <<
"No valid NCPkgTable widget" << endl;
121 for ( ZyppPoolIterator it = zyppPkgBegin();
125 ZyppSel selectable = *it;
131 if ( selectable->installedObj() )
133 match = check( selectable, tryCastToZyppPkg( selectable->installedObj() ), pkgClass );
136 else if ( selectable->hasCandidateObj() )
138 match = check( selectable, tryCastToZyppPkg( selectable->candidateObj() ), pkgClass );
145 zypp::ui::Selectable::picklist_iterator it = selectable->picklistBegin();
146 while ( it != selectable->picklistEnd() && !match )
148 check( selectable, tryCastToZyppPkg( *it ), pkgClass );
155 packageList->setCurrentItem( 0 );
162 packager->clearInfoArea();
164 yuiMilestone() <<
"Filling package list \"" << pkgClass->label() <<
"\"" << endl;
170 void NCPkgFilterClassification::showRetractedInstalled()
172 selectItem( retractedInstalled,
true );
178 bool NCPkgFilterClassification::check( ZyppSel selectable, ZyppPkg pkg, YItem * pkgClass )
180 NCPkgTable * packageList = packager->PackageList();
183 yuiDebug() << zypp::PoolItem( pkg ) << endl;
185 if ( !packageList || !selectable || !pkg )
187 yuiError() <<
"No valid data" << endl;
193 if ( pkgClass == all ) match =
true;
194 else if ( pkgClass == recommended ) match = zypp::PoolItem( pkg ).status().isRecommended();
195 else if ( pkgClass == suggested ) match = zypp::PoolItem( pkg ).status().isSuggested();
196 else if ( pkgClass == orphaned ) match = zypp::PoolItem( pkg ).status().isOrphaned();
197 else if ( pkgClass == unneeded ) match = zypp::PoolItem( pkg ).status().isUnneeded();
198 else if ( pkgClass == multiversion ) match = selectable->multiversionInstall();
199 else if ( pkgClass == retracted ) match = selectable->hasRetracted();
200 else if ( pkgClass == retractedInstalled ) match = selectable->hasRetractedInstalled();
209 void NCPkgFilterClassification::showDescription()
211 std::string description;
212 YItem * pkgClass = currentPkgClass();
214 if ( pkgClass == recommended )
216 description = _(
"This is a list of useful packages. They will be additionally installed if recommended by a newly installed package.");
218 else if ( pkgClass == suggested )
220 description = _(
"It's suggested to install these packages because they fit to already installed packages. The decision to install it is by the user.");
222 else if ( pkgClass == orphaned )
224 description = _(
"The solver has detected that these packages are without a repository, i.e. updates aren't possible.");
226 else if ( pkgClass == unneeded )
228 description = _(
"These packages might be unneeded because former dependencies don't apply any longer.");
230 else if ( pkgClass == multiversion )
232 description = _(
"These packages might be installed in several versions in parallel.");
234 else if ( pkgClass == retracted )
236 description = _(
"These packages have versions that are retracted. Using those versions is strongly discouraged.");
238 else if ( pkgClass == retractedInstalled )
240 description = _(
"These packages have a retracted version installed. Consider up- or downgrading them to a different version.");
242 else if ( pkgClass == all )
244 description = _(
"All packages known by the package manager, no filtering applied.");
247 packager->FilterDescription()->setText ( description );
251 YItem * NCPkgFilterClassification::currentPkgClass()
const 253 int index = getCurrentItem();
255 return itemAt( index );
259 void NCPkgFilterClassification::setCurrentPkgClass( YItem * item )
261 int index = itemIndex( item );
264 setCurrentItem( index );
268 int NCPkgFilterClassification::itemIndex( YItem * item )
const 270 for (
int i=0; i < itemsCount(); ++i )
272 if ( itemAt( i ) == item )
280 NCursesEvent NCPkgFilterClassification::wHandleInput( wint_t ch )
282 NCursesEvent ret = NCursesEvent::none;
293 ret = NCursesEvent::handled;
299 ret = NCSelectionBox::wHandleInput( ch );
bool showInformation()
Show the corresponding information (e.g.
NCPkgFilterClassification(YWidget *parent, NCPackageSelector *pkg)
A helper class to hold repository data in a neat table widget.
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)