Author: kmachalkova
Date: Thu Feb 28 17:25:10 2008
New Revision: 45108
URL: http://svn.opensuse.org/viewcvs/yast?rev=45108&view=rev
Log:
Filtering pkgs by group moved
Modified:
branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.cc
branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupTree.cc
branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupTree.h
Modified: branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.cc?rev=45108&r1=45107&r2=45108&view=diff
==============================================================================
--- branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.cc (original)
+++ branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.cc Thu Feb 28 17:25:10 2008
@@ -80,14 +80,14 @@
//
// CompFunc
//
-bool sortByName( ZyppSel ptr1, ZyppSel ptr2 )
-{
- if ( ptr1->name() < ptr2->name() )
- {
- return true;
- }
- return false;
-}
+//bool sortByName( ZyppSel ptr1, ZyppSel ptr2 )
+//{
+// if ( ptr1->name() < ptr2->name() )
+// {
+// return true;
+// }
+// return false;
+//}
///////////////////////////////////////////////////////////////////
//
@@ -511,8 +511,7 @@
retVal = CancelHandler( event );
else if ( event.widget == filterPopup )
{
- retVal = true;
- NCINT << "porn.bat" << endl;
+ retVal = filterPopup->handleEvent();
}
}
else if ( event == NCursesEvent::menu )
@@ -2840,12 +2839,12 @@
}
}
case NCPkgTable::T_Packages: {
- YStringTreeItem * defaultGroup = getDefaultRpmGroup();
+ YStringTreeItem * defaultGroup = filterPopup->getDefaultRpmGroup();
if ( defaultGroup )
{
NCMIL << "default RPM group: " << defaultGroup->value().translation() << endl;
- fillPackageList ( defaultGroup->value().translation(), defaultGroup );
+ filterPopup->fillPackageList ( defaultGroup->value().translation(), defaultGroup );
// set the visible info to package description
setVisibleInfo ( pkginfoItem );
@@ -2864,5 +2863,4 @@
pkgList->setKeyboardFocus();
- return true;
-}
+ return true;}
Modified: branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupTree.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupTree.cc?rev=45108&r1=45107&r2=45108&view=diff
==============================================================================
--- branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupTree.cc (original)
+++ branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupTree.cc Thu Feb 28 17:25:10 2008
@@ -84,15 +84,32 @@
: NCTree( parent, label )
, filterTree( this )
, packager ( pkg )
+ , _rpmGroupsTree (0)
{
// create the layout (the NCTree)
//createLayout( NCPkgNames::RpmTreeLabel() );
-
setNotify(true);
+
+ _rpmGroupsTree = new YRpmGroupsTree ();
+
+ ZyppPoolIterator b = zyppPkgBegin ();
+ ZyppPoolIterator e = zyppPkgEnd ();
+ ZyppPoolIterator i;
+
+ for ( i = b; i != e; ++i )
+ {
+ ZyppPkg zyppPkg = tryCastToZyppPkg( (*i)->theObj() );
+ if ( zyppPkg )
+ {
+ _rpmGroupsTree->addRpmGroup (zyppPkg->group ());
+ NCDBG << "Adding group: " << zyppPkg->group() << endl;
+ }
+ }
+
if ( pkg->rpmGroupsTree() )
{
// clone the tree (fill the NCTree)
- cloneTree( pkg->rpmGroupsTree()->root(), 0 );
+ cloneTree( _rpmGroupsTree->root(), 0 );
}
}
@@ -136,8 +153,8 @@
//
// DESCRIPTION :
//
-//NCursesEvent NCPkgPopupTree::showFilterPopup( )
-//{
+bool NCPkgPopupTree::handleEvent( )
+{
// postevent = NCursesEvent();
//
// // event loop
@@ -150,42 +167,148 @@
// if ( !packager || !filterTree )
// return postevent;
//
-// YStringTreeItem * origItem;
+ YStringTreeItem * origItem;
//
// // get the currently selected rpm group and show the package list
// if ( postevent.detail == NCursesEvent::USERDEF )
// {
-// const YTreeItem * item = filterTree->getCurrentItem();
-//
-// if ( item )
-// {
-// const NCRpmGroupItem * rpmGroupItem = dynamic_cast(item);
-//
-// if ( rpmGroupItem )
-// {
-// // get the original rpm group item (YStringTreeItem)
-// origItem = rpmGroupItem->getOrigItem();
-//
-// if ( origItem )
-// {
-// string label = origItem->value().translation();
-//
-// // fill the package list
-// packager->fillPackageList( label, origItem );
-//
-// NCMIL << "Selected RPM group: " << label << endl;
-// }
-// }
-// }
-// else
-// {
-// NCERR << "Current item not valid" << endl;
-// }
-// }
-//
-// return postevent;
-//}
+ const YTreeItem * item = filterTree->getCurrentItem();
+
+ if ( item )
+ {
+ const NCRpmGroupItem * rpmGroupItem = dynamic_cast(item);
+
+ if ( rpmGroupItem )
+ {
+ // get the original rpm group item (YStringTreeItem)
+ origItem = rpmGroupItem->getOrigItem();
+
+ if ( origItem )
+ {
+ string label = origItem->value().translation();
+
+ // fill the package list
+ fillPackageList( label, origItem );
+
+ NCMIL << "Selected RPM group: " << label << endl;
+ }
+ }
+ }
+ else
+ {
+ NCERR << "Current item not valid" << endl;
+ }
+
+ return true;
+}
+
+YStringTreeItem * NCPkgPopupTree::getDefaultRpmGroup()
+{
+ if ( _rpmGroupsTree &&
+ _rpmGroupsTree->root() )
+ return _rpmGroupsTree->root()->firstChild();
+ else
+ return 0;
+}
+
+
+bool NCPkgPopupTree::checkPackage( ZyppObj opkg, ZyppSel slb,
+ YStringTreeItem * rpmGroup )
+{
+ ZyppPkg pkg = tryCastToZyppPkg (opkg);
+ if ( ! pkg || ! rpmGroup )
+ return false;
+
+ NCPkgTable * packageList = packager->PackageList();
+
+ if ( !packageList )
+ {
+ UIERR << "Widget is not a valid NCPkgTable widget" << endl;
+ return false;
+ }
+
+ string group_str = _rpmGroupsTree->rpmGroup (rpmGroup);
+ NCINT << group_str << endl;
+ // is the requested rpm group a prefix of this package's group?
+ if ( pkg->group ().find (group_str) == 0 )
+ {
+ NCINT << slb->name() << endl;
+ packageList->createListEntry( pkg, slb );
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool NCPkgPopupTree::fillPackageList ( const string & label, YStringTreeItem *rpmGroup )
+{
+ NCPkgTable * packageList = packager->PackageList();
+
+ if ( !packageList )
+ {
+ UIERR << "No valid NCPkgTable widget" << endl;
+ return false;
+ }
+
+ // clear the package table
+ packageList->itemsCleared ();
+
+ // get the package list and sort it
+ list<ZyppSel> pkgList( zyppPkgBegin (), zyppPkgEnd () );
+ pkgList.sort( sortByName );
+ // fill the package table
+ list<ZyppSel>::iterator listIt;
+ ZyppPkg pkgPtr;
+
+
+ for ( listIt = pkgList.begin(); listIt != pkgList.end(); ++listIt )
+ {
+ ZyppSel selectable = *listIt;
+
+ // Multiple instances of this package may or may not be in the same
+ // RPM group, so let's check both the installed version (if there
+ // is any) and the candidate version.
+ //
+ // Make sure we emit only one filterMatch() signal if both exist
+ // and both are in the same RPM group. We don't want multiple list
+ // entries for the same package!
+
+ bool match =
+ checkPackage( selectable->candidateObj(), selectable, rpmGroup ) ||
+ checkPackage( selectable->installedObj(), selectable, rpmGroup );
+
+ // If there is neither an installed nor a candidate package, check
+ // any other instance.
+
+ if ( ! match &&
+ ! selectable->installedObj() &&
+ ! selectable->candidateObj() )
+ checkPackage( selectable->theObj(), selectable, rpmGroup );
+
+ }
+
+ // show the package list
+ packageList->drawList();
+
+ NCMIL << "Fill package list" << endl;
+
+ if ( ! label.empty() )
+ {
+ YLabel *packageLabel = packager->PackageLabel();
+ // show the selected filter label
+ if ( packageLabel )
+ {
+ packageLabel->setText( label );
+ }
+ }
+
+ return true;
+
+}
///////////////////////////////////////////////////////////////////
//
//
Modified: branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupTree.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupTree.h?rev=45108&r1=45107&r2=45108&view=diff
==============================================================================
--- branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupTree.h (original)
+++ branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupTree.h Thu Feb 28 17:25:10 2008
@@ -28,6 +28,7 @@
#include "NCTree.h"
#include "NCLabel.h"
#include "NCRichText.h"
+#include "NCZypp.h"
#include
@@ -52,6 +53,8 @@
NCPackageSelector * packager; // connection to the PackageSelector
+ YRpmGroupsTree * _rpmGroupsTree; // rpm groups of the found packages
+
// internal use (copies tree items)
void cloneTree( YStringTreeItem * parentOrig, NCRpmGroupItem * parentClone );
@@ -76,6 +79,14 @@
void createLayout( const string & label );
+ bool handleEvent();
+
+ YStringTreeItem * getDefaultRpmGroup();
+
+ bool checkPackage( ZyppObj opkg, ZyppSel slb, YStringTreeItem *rpmGroup);
+
+ bool fillPackageList ( const string & label, YStringTreeItem *rpmGroup );
+
void addItem( YTreeItem * newItem );
//NCursesEvent showFilterPopup( );
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org