Skip to content

Commit

Permalink
show a popup for versions of patch packages to be able to show multi …
Browse files Browse the repository at this point in the history
…version packages
  • Loading branch information
gabi2 committed Jul 25, 2013
1 parent 191a3de commit 6373172
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 51 deletions.
51 changes: 11 additions & 40 deletions src/NCPackageSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ bool NCPackageSelector::fillUpdateList( )
// fillPatchPackages
//
//
bool NCPackageSelector::fillPatchPackages ( NCPkgTable * pkgTable, ZyppObj objPtr, bool versions )
bool NCPackageSelector::fillPatchPackages ( NCPkgTable * pkgTable, ZyppObj objPtr )
{
if ( !pkgTable || !objPtr )
return false;
Expand Down Expand Up @@ -738,27 +738,6 @@ bool NCPackageSelector::fillPatchPackages ( NCPkgTable * pkgTable, ZyppObj objPt
yuiDebug() << (*it)->name().c_str() << ": Version: " << pkg->edition().asString() << endl;

pkgTable->createListEntry( pkg, sel );

if ( versions ) // additionally show all availables
{
zypp::ui::Selectable::available_iterator
b = sel->availableBegin (),
e = sel->availableEnd (),
it;
for (it = b; it != e; ++it)
{
ZyppPkg pkgAvail = tryCastToZyppPkg (*it);
if ( pkgAvail )
{
if ( pkg->edition() != pkgAvail->edition() ||
pkg->arch() != pkgAvail->arch() )
{
pkgTable->createListEntry( pkgAvail, sel );
}
}
}

} // if ( versions )
}
}
}
Expand Down Expand Up @@ -988,27 +967,19 @@ void NCPackageSelector::showPatchPackages()
//
void NCPackageSelector::showPatchPkgVersions()
{
wrect oldSize = deleteReplacePoint();
NCPkgTable * packageList = PackageList();

// show a package table with versions of the packages beloning to a patch
YTableHeader * tableHeader = new YTableHeader();
patchPkgsVersions = new NCPkgTable( replacePoint, tableHeader );

if ( patchPkgsVersions && packageList )
// only available if patch packages are currently shown
if ( patchPkgs )
{
// set the connection to the NCPackageSelector !!!!
patchPkgsVersions->setPackager( this );
// set status strategy and table type
NCPkgStatusStrategy * strategy = new AvailableStatStrategy();
patchPkgsVersions->setTableType( NCPkgTable::T_Availables, strategy );
patchPkgsVersions->fillHeader( );
patchPkgsVersions->setSize( oldSize.Sze.W, oldSize.Sze.H );
// get selected line and show availables for this package
ZyppSel sel = patchPkgs->getSelPointer( patchPkgs->getCurrentItem() );

fillPatchPackages( patchPkgsVersions, packageList->getDataPointer( packageList->getCurrentItem() ), true );
patchPkgsVersions->Redraw();
// show the availables
NCPkgPopupTable * availablePopup = new NCPkgPopupTable( wpos( 3, 8), this );
NCursesEvent input = availablePopup->showAvailablesPopup( sel );

packageList->setKeyboardFocus();
YDialog::deleteTopmostDialog();

patchPkgs->setKeyboardFocus();
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/NCPackageSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,9 @@ class NCPackageSelector
* Fills the list of packages belonging to the youPatch
* @param pkgTable The table widget
* @param youPatch Show all packages belonging to the patch
* @param versions Show all versions of all packages belonging to the patch
* @return bool
*/
bool fillPatchPackages ( NCPkgTable * pkgTable, ZyppObj youPatch, bool versions = false );
bool fillPatchPackages ( NCPkgTable * pkgTable, ZyppObj youPatch );

/**
* Fills the package table with packages matching the search expression
Expand Down
4 changes: 2 additions & 2 deletions src/NCPkgMenuView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ bool NCPkgMenuView::handleEvent ( const NCursesEvent & event)
}
else if ( event.selection == patchPkgVersions )
{
pkg->showPatchPkgVersions();
pkgList->setVisibleInfo (NCPkgTable::I_PatchPkgsVersions);
pkg->showPatchPkgVersions(); // opens a popup
pkgList->setVisibleInfo (NCPkgTable::I_PatchPkgs); // info remains patch pkgs
}
else
{
Expand Down
35 changes: 34 additions & 1 deletion src/NCPkgPopupTable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
#include "NCPushButton.h"
#include "NCPkgTable.h"

#include "NCZypp.h"
#include "NCi18n.h"

#include <zypp/ui/Selectable.h>
Expand Down Expand Up @@ -223,6 +222,20 @@ bool NCPkgPopupTable::fillAutoChanges( NCPkgTable * pkgTable )
}
}

bool NCPkgPopupTable::fillAvailables( NCPkgTable * pkgTable, ZyppSel sel )
{
if ( !pkgTable )
return false;

pkgTable->itemsCleared(); // clear the table
pkgTable->fillAvailableList( sel );

pkgTable->drawList();

return true;
}


///////////////////////////////////////////////////////////////////
//
//
Expand Down Expand Up @@ -251,6 +264,26 @@ NCursesEvent NCPkgPopupTable::showInfoPopup( )
return postevent;
}

NCursesEvent NCPkgPopupTable::showAvailablesPopup( ZyppSel sel )
{
postevent = NCursesEvent();

if ( !fillAvailables( pkgTable, sel ) )
{
postevent = NCursesEvent::button;
return postevent;
}

do {
// show the popup
popupDialog( );
} while ( postAgain() );

popdownDialog();

return postevent;
}

///////////////////////////////////////////////////////////////////
//
//
Expand Down
4 changes: 4 additions & 0 deletions src/NCPkgPopupTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <algorithm>

#include "NCPopup.h"
#include "NCZypp.h"

class NCPkgTable;
class NCPushButton;
Expand Down Expand Up @@ -89,9 +90,12 @@ class NCPkgPopupTable : public NCPopup {

bool fillAutoChanges( NCPkgTable * pkgTable );

bool fillAvailables( NCPkgTable * pkgTable, ZyppSel sel );

void createLayout( );

NCursesEvent showInfoPopup( );
NCursesEvent showAvailablesPopup( ZyppSel sel );

};

Expand Down
11 changes: 7 additions & 4 deletions src/NCPkgTable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ bool NCPkgTable::showInformation ( )
ZyppObj objPtr = getDataPointer( getCurrentItem() );
ZyppSel slbPtr = getSelPointer( getCurrentItem() );

yuiMilestone() << "*** show info for " << slbPtr->name() << "***" << endl;
if ( !packager )
return false;

Expand All @@ -781,7 +782,10 @@ bool NCPkgTable::showInformation ( )
case T_Patches:
// show the patch info
if (objPtr && slbPtr )
{
yuiMilestone() << "updateinfo" << endl;
updateInfo( objPtr, slbPtr, VisibleInfo() );
}
break;
default:
break;
Expand Down Expand Up @@ -1240,11 +1244,10 @@ void NCPkgTable::updateInfo( ZyppObj pkgPtr, ZyppSel slbPtr, NCPkgTableInfoType
break;
case I_PatchPkgs:
if ( packager->PatchPkgs() )
{
yuiMilestone() << "fillPatchPackages" << endl;
packager->fillPatchPackages( packager->PatchPkgs(), pkgPtr );
break;
case I_PatchPkgsVersions:
if ( packager->PatchPkgsVersions() )
packager->fillPatchPackages( packager->PatchPkgsVersions(), pkgPtr, true );
}
break;
// Intentionally omitting 'default' branch so the compiler can
// catch unhandled enum states
Expand Down
3 changes: 1 addition & 2 deletions src/NCPkgTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ class NCPkgTable : public NCTable {
I_Files,
I_Deps,
I_PatchDescr,
I_PatchPkgs,
I_PatchPkgsVersions
I_PatchPkgs
};

private:
Expand Down

0 comments on commit 6373172

Please sign in to comment.