Author: kmachalkova
Date: Thu Mar 20 17:31:57 2008
New Revision: 45660
URL: http://svn.opensuse.org/viewcvs/yast?rev=45660&view=rev
Log:
Search widget broken into two pieces
Added:
branches/tmp/bubli/ncurses-pkg/src/NCPkgSearchSettings.cc
branches/tmp/bubli/ncurses-pkg/src/NCPkgSearchSettings.h
Modified:
branches/tmp/bubli/ncurses-pkg/src/Makefile.am
branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.cc
branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.h
branches/tmp/bubli/ncurses-pkg/src/NCPkgNames.cc
branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupSearch.cc
branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupSearch.h
Modified: branches/tmp/bubli/ncurses-pkg/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/bubli/ncurses-pkg/src/Makefile.am?rev=45660&r1=45659&r2=45660&view=diff
==============================================================================
--- branches/tmp/bubli/ncurses-pkg/src/Makefile.am (original)
+++ branches/tmp/bubli/ncurses-pkg/src/Makefile.am Thu Mar 20 17:31:57 2008
@@ -33,6 +33,7 @@
NCPkgPopupTable.h \
NCPkgPopupRepo.h \
NCPkgPopupSearch.h \
+ NCPkgSearchSettings.h \
NCPkgPopupSelection.h \
NCPkgPopupTree.h \
NCPkgNames.h \
@@ -58,6 +59,7 @@
NCPkgPopupTable.cc \
NCPkgPopupRepo.cc \
NCPkgPopupSearch.cc \
+ NCPkgSearchSettings.cc \
NCPkgPopupSelection.cc \
NCPkgPopupTree.cc \
NCPkgNames.cc
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=45660&r1=45659&r2=45660&view=diff
==============================================================================
--- branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.cc (original)
+++ branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.cc Thu Mar 20 17:31:57 2008
@@ -77,16 +77,6 @@
///////////////////////////////////////////////////////////////////
//
-// ignore case compare
-//
-bool ic_compare ( char c1, char c2 )
-{
- return ( toupper( c1 ) == toupper( c2 ) );
-}
-
-
-///////////////////////////////////////////////////////////////////
-//
// Constructor
//
NCPackageSelector::NCPackageSelector( YNCursesUI * ui, YWidget * wRoot, long modeFlags )
@@ -229,7 +219,7 @@
}
// create the search popup
- searchPopup = new NCPkgPopupSearch( wpos( 1, 1 ), this );
+ //searchPopup = new NCPkgPopupSearch( wpos( 1, 1 ), this );
// the dependency popup
depsPopup = new NCPkgPopupDeps( wpos( 3, 8 ), this );
@@ -349,6 +339,11 @@
{
retVal = filterMain->handleEvent();
}
+ else if ( event.widget == searchButton )
+ {
+ retVal = searchPopup->postAgain();
+ NCINT << "porn.bat" << endl;
+ }
}
else if ( event == NCursesEvent::menu )
{
@@ -377,98 +372,6 @@
return retVal;
}
-
-///////////////////////////////////////////////////////////////////
-//
-// fillSearchList
-//
-// Fills the package table
-//
-bool NCPackageSelector::fillSearchList( const string & expr,
- bool ignoreCase,
- bool checkName,
- bool checkSummary,
- bool checkDescr,
- bool checkProvides,
- bool checkRequires )
-{
- NCPkgTable * packageList = PackageList();
-
- if ( !packageList )
- {
- return false;
- }
-
- // clear the package table
- packageList->itemsCleared ();
-
-// FIXME filter it inside zypp
- ZyppPoolIterator b = zyppPkgBegin ();
- ZyppPoolIterator e = zyppPkgEnd ();
- ZyppPoolIterator i;
-
- // get the package list and sort it
- list<ZyppSel> pkgList( b, e );
- pkgList.sort( sortByName );
-
- // fill the package table
- list<ZyppSel>::iterator listIt = pkgList.begin();
- ZyppPkg pkg;
- string description = "";
- string provides = "";
- string requires = "";
-
- while ( listIt != pkgList.end() )
- {
- if ( (*listIt)->installedObj() )
- pkg = tryCastToZyppPkg ((*listIt)->installedObj());
- else
- pkg = tryCastToZyppPkg ((*listIt)->theObj());
-
- if ( pkg )
- {
- if ( checkDescr )
- {
- zypp::Text value = pkg->description();
- description = createDescrText( value );
- }
- if ( checkProvides )
- {
- zypp::CapSet value = pkg->dep (zypp::Dep::PROVIDES);
- //provides = createRelLine( value );
- }
- if ( checkRequires )
- {
- zypp::CapSet value = pkg->dep (zypp::Dep::REQUIRES);
- //requires = createRelLine( value );
- }
- if ( ( checkName && match( pkg->name(), expr, ignoreCase )) ||
- ( checkSummary && match( pkg->summary(), expr, ignoreCase) ) ||
- ( checkDescr && match( description, expr, ignoreCase) ) ||
- ( checkProvides && match( provides, expr, ignoreCase) ) ||
- ( checkRequires && match( requires, expr, ignoreCase) )
- )
- {
- // search sucessful
- packageList->createListEntry( pkg, *listIt );
- }
- }
-
- ++listIt;
- }
-
- // show the package list
- packageList->drawList();
-
- // set filter label to 'Search'
- if ( packageLabel )
- {
- packageLabel->setText( NCPkgNames::SearchResults() );
- }
-
- return true;
-}
-
///////////////////////////////////////////////////////////////////
//
// fillPatchSearchList
@@ -497,11 +400,11 @@
if ( patchPtr )
{
- if ( match( (*listIt)->name(), expr, true ) )
- {
+ //if ( match( (*listIt)->name(), expr, true ) )
+ //{
// search sucessful
packageList->createPatchEntry( patchPtr, *listIt );
- }
+ // }
}
++listIt;
}
@@ -817,30 +720,6 @@
}
-///////////////////////////////////////////////////////////////////
-//
-// match
-//
-
-bool NCPackageSelector::match ( string s1, string s2, bool ignoreCase )
-{
- string::iterator pos;
-
- if ( ignoreCase )
- {
- pos = search( s1.begin(), s1.end(),
- s2.begin(), s2.end(),
- ic_compare );
- }
- else
- {
- pos = search( s1.begin(), s1.end(),
- s2.begin(), s2.end() );
- }
-
- return ( pos != s1.end() );
-}
-
// patches
@@ -968,6 +847,7 @@
}
// open the search popup
+ #if 0
NCursesEvent retEvent = searchPopup->showSearchPopup();
if ( retEvent == NCursesEvent::button )
@@ -979,7 +859,7 @@
{
NCMIL << "Search is canceled" << endl;
}
-
+ #endif
packageList->setKeyboardFocus();
return true;
@@ -1137,6 +1017,7 @@
patternPopup = 0;
languagePopup = 0;
repoPopup = 0;
+ searchPopup = 0;
}
switch (mode)
@@ -1184,7 +1065,7 @@
NCMIL << "default RPM group: " << defaultGroup->value().translation() << endl;
filterPopup->fillPackageList ( defaultGroup->value().translation(), defaultGroup );
// show the package description of the current item
- pkgList->showInformation ();
+ //pkgList->showInformation ();
///infoText->update( pkgList->getDataPointer(0), pkgList->getSelPointer(0), NCPkgTable::I_Descr );
}
else
@@ -1193,13 +1074,60 @@
}
break;
}
+ case Search:
+ {
+ searchPopup = new NCPkgPopupSearch ( replPoint, YD_VERT, this );
+ searchPopup->setSize( oldSize.Sze.W, oldSize.Sze.H );
+ searchPopup->Redraw();
+ break;
+ }
default:
NCINT << "zatim nic" << endl;
}
- pkgList->setCurrentItem(0);
- pkgList->showInformation ();
+
+ if (mode == Search)
+ {
+ replaceFilterDescr( true);
+ pkgList->itemsCleared();
+ }
+ else
+ {
+ replaceFilterDescr( false );
+ pkgList->setCurrentItem(0);
+ pkgList->showInformation ();
+ }
}
+
+void NCPackageSelector::replaceFilterDescr( bool b )
+{
+ YWidget * replaceChild = replPoint2->firstChild();
+ wrect oldSize;
+
+ if ( replaceChild )
+ {
+ oldSize = dynamic_cast(replaceChild)->wGetSize();
+
+ delete replaceChild;
+ filter_desc = 0;
+ searchSet = 0;
+ }
+
+ if (b)
+ {
+ searchSet = new NCPkgSearchSettings( replPoint2, _("Search in") );
+ searchSet->setSize( oldSize.Sze.W, oldSize.Sze.H );
+ searchSet->Redraw();
+ }
+ else
+ {
+ filter_desc = new NCRichText( replPoint2, _("Some text here"));
+ filter_desc->setSize( oldSize.Sze.W, oldSize.Sze.H );
+ filter_desc->Redraw();
+ }
+
+}
+
///////////////////////////////////////////////////////////////////
//
// FilterHandler
@@ -2038,9 +1966,10 @@
new NCSpacing( hSplit2, YD_HORIZ, true, 0.5 );
actionMenu = new NCPkgMenuAction ( hSplit2, _( "A&ctions" ), this );
-
- NCRichText *filter_desc = new NCRichText( hbox_bottom, "Some text here" );
- filter_desc->setWeight(YD_HORIZ, 1);
+
+ replPoint2 = YUI::widgetFactory()->createReplacePoint( hbox_bottom );
+ replPoint2->setWeight(YD_HORIZ, 1);
+ filter_desc = new NCRichText( replPoint2, "Some text here" );
YLayoutBox * vSplit = YUI::widgetFactory()->createVBox( hbox_bottom );
vSplit->setWeight(YD_HORIZ, 2);
replacePoint = YUI::widgetFactory()->createReplacePoint( vSplit );
@@ -2123,4 +2052,6 @@
pkgList->setKeyboardFocus();
- return true;}
+ return true;
+
+}
Modified: branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.h?rev=45660&r1=45659&r2=45660&view=diff
==============================================================================
--- branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.h (original)
+++ branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.h Thu Mar 20 17:31:57 2008
@@ -47,6 +47,7 @@
#include "NCPkgPackageDetails.h"
#include "NCPkgPopupDeps.h"
#include "NCPkgFilterMain.h"
+#include "NCPkgSearchSettings.h"
#include "NCPkgSelMapper.h"
@@ -61,6 +62,7 @@
class NCPkgMenuDeps;
class NCPkgMenuAction;
class NCPkgMenuView;
+class NCPkgSearchSettings;
class NCPkgPackageDetails;
class NCPkgFilterMain;
class NCPushButton;
@@ -162,8 +164,12 @@
// information about packages
NCPkgPackageDetails * infoText; // short/longdecsription, filelist
+ NCRichText * filter_desc;
+ NCPushButton *searchButton;
+ NCPkgSearchSettings *searchSet;
YReplacePoint * replacePoint; // replace point for info text
YReplacePoint * replPoint;
+ YReplacePoint * replPoint2; //tohle pak urcite prejmenuj, Bublino
NCPkgTable * versionsList; // list of available package versions
// information about patches
@@ -175,10 +181,6 @@
YMenuItem * visibleInfo; // current visible package info (description, file list, ...)
- // internal use (copies tree items got from YPkgRpmGroupTagsFilterView)
- void cloneTree( YStringTreeItem * parentOrig, YTreeItem * parentClone );
-
-
// Mapping from ZyppPkg to the correspoinding ZyppSel.
NCPkgSelMapper selMapper;
@@ -245,7 +247,10 @@
NCPkgTable *VersionsList() { return versionsList; }
void setVersionsList ( NCPkgTable *table ) { versionsList = table; }
+
YReplacePoint *ReplacePoint() { return replacePoint; }
+ NCPkgSearchSettings *SearchSettings() { return searchSet; }
+ void setSearchButton( NCPushButton *pb ) { searchButton = pb; }
bool checkNow( bool *ok ) { return depsPopup->showDependencies( NCPkgPopupDeps::S_Solve, ok ); }
@@ -289,14 +294,6 @@
* @param checkRequires Check in Requires (true or false)
* @return bool
*/
- bool fillSearchList( const string & expr,
- bool ignoreCase,
- bool checkName,
- bool checkSummary,
- bool checkDescr,
- bool checkProvides,
- bool checkRequires );
-
bool fillPatchSearchList( const string & expr );
bool fillDefaultList();
@@ -330,6 +327,7 @@
void replaceInfoText ( bool b );
void replaceFilter ( FilterMode mode);
+ void replaceFilterDescr ( bool b );
/**
* Handler function for "OK button pressed"
* @param event The Ncurses event
@@ -411,14 +409,6 @@
string createDescrText( zypp::Text t );
/**
- * Used for package search
- * @param s1 Search in s1
- * @param s2 Searching for s2
- * @return bool
- */
- bool match( string s1, string s2, bool ignoreCase );
-
- /**
* Calls the package mananager (updateDu()) and shows the required disk space
*/
void showDiskSpace();
Modified: branches/tmp/bubli/ncurses-pkg/src/NCPkgNames.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/bubli/ncurses-pkg/src/NCPkgNames.cc?rev=45660&r1=45659&r2=45660&view=diff
==============================================================================
--- branches/tmp/bubli/ncurses-pkg/src/NCPkgNames.cc (original)
+++ branches/tmp/bubli/ncurses-pkg/src/NCPkgNames.cc Thu Mar 20 17:31:57 2008
@@ -265,35 +265,35 @@
const string NCPkgNames::CheckDescr()
{
// label of a combo box (search popup)
- static const string value = _( "&Description (time-consuming)" );
+ static const string value = _( "Description (time-consuming)" );
return value;
}
const string NCPkgNames::CheckName()
{
// label of a combo box (search popup)
- static const string value = _( "&Name of the Package" );
+ static const string value = _( "Name of the Package" );
return value;
}
const string NCPkgNames::CheckSummary()
{
// label of a combo box (search popup)
- static const string value = _( "S&ummary" );
+ static const string value = _( "Summary" );
return value;
}
const string NCPkgNames::CheckProvides()
{
// label of a combo box (search popup)
- static const string value = _( "&Provides" );
+ static const string value = _( "Provides" );
return value;
}
const string NCPkgNames::CheckRequires()
{
// label of a combo box (search popup)
- static const string value = _( "&Requires" );
+ static const string value = _( "Requires" );
return value;
}
Modified: branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupSearch.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupSearch.cc?rev=45660&r1=45659&r2=45660&view=diff
==============================================================================
--- branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupSearch.cc (original)
+++ branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupSearch.cc Thu Mar 20 17:31:57 2008
@@ -19,6 +19,7 @@
#include "Y2Log.h"
#include "NCPkgPopupSearch.h"
+#include "NCAlignment.h"
#include "NCTree.h"
#include "YMenuButton.h"
#include "YDialog.h"
@@ -28,6 +29,7 @@
#include "NCPkgNames.h"
#include "NCPackageSelector.h"
+#include "NCPkgSearchSettings.h"
#include "NCi18n.h"
@@ -35,6 +37,10 @@
Textdomain "packages"
*/
+bool ic_compare ( char c1, char c2 )
+{
+ return ( toupper( c1 ) == toupper( c2 ) );
+}
///////////////////////////////////////////////////////////////////
//
//
@@ -43,8 +49,10 @@
//
// DESCRIPTION :
//
-NCPkgPopupSearch::NCPkgPopupSearch( const wpos at, NCPackageSelector * pkger )
- : NCPopup( at, false )
+//NCPkgPopupSearch::NCPkgPopupSearch( const wpos at, NCPackageSelector * pkger )
+// : NCPopup( at, false )
+NCPkgPopupSearch::NCPkgPopupSearch( YWidget *parent, YUIDimension dim, NCPackageSelector *pkger )
+ : NCLayoutBox( parent, dim )
, searchExpr( 0 )
, ignoreCase( 0 )
, checkName( 0 )
@@ -53,12 +61,13 @@
, checkProvides( 0 )
, checkRequires( 0 )
, cancelButton( 0 )
+ , searchButton( 0 )
, packager( pkger )
{
- if ( !packager->isYouMode() )
- createLayout( _( "Package Search" ) );
- else
- createLayout( _("Search for Patch Name") );
+ // if ( !packager->isYouMode() )
+ // createLayout( _( "Package Search" ) );
+ // else
+ createLayout( parent );
}
///////////////////////////////////////////////////////////////////
@@ -81,41 +90,51 @@
//
// DESCRIPTION :
//
-void NCPkgPopupSearch::createLayout( const string & headline )
+void NCPkgPopupSearch::createLayout( YWidget *parent )
{
// vertical split is the (only) child of the dialog
- NCLayoutBox * vSplit = new NCLayoutBox( this, YD_VERT );
+ //NCLayoutBox * vSplit = new NCLayoutBox( parent, YD_VERT );
- new NCSpacing( vSplit, YD_VERT, false, 0.8 ); // stretchable = false
+// new NCSpacing( vSplit, YD_VERT, false, 0.8 ); // stretchable = false
- new NCLabel( vSplit, headline, true, false ); // isHeading = true
+ // new NCLabel( vSplit, headline, true, false ); // isHeading = true
- new NCSpacing( vSplit, YD_VERT, false, 0.6 );
+ // new NCSpacing( vSplit, YD_VERT, false, 0.6 );
- NCFrame * frame0 = new NCFrame( vSplit, "" );
+ NCFrame * frame0 = new NCFrame( this, "" );
// add the input field (a editable combo box)
- searchExpr = new NCComboBox( frame0,
+ NCLayoutBox * vSplit = new NCLayoutBox ( frame0, YD_VERT);
+ new NCSpacing( vSplit, YD_VERT, true, 0.5 );
+
+ NCLayoutBox * hSplit = new NCLayoutBox ( vSplit, YD_HORIZ);
+ searchExpr = new NCComboBox( hSplit,
NCPkgNames::SearchPhrase(),
true ); // editable = true
searchExpr->setStretchable( YD_HORIZ, true );
-
searchExpr->addItem( new YTableItem() );
- new NCSpacing( vSplit, YD_VERT, false, 0.6 );
+ NCLayoutBox * bogus = new NCLayoutBox ( hSplit, YD_VERT);
+ new NCSpacing( bogus, YD_VERT, false, 1.0 );
+ searchButton = new NCPushButton( bogus, NCPkgNames::MenuEntrySearch());
+ packager->setSearchButton( searchButton );
+
+ new NCSpacing( vSplit, YD_VERT, false, 0.5 );
if ( !packager->isYouMode() )
{
// add the checkBox ignore case
- NCLayoutBox * hSplit2 = new NCLayoutBox( vSplit, YD_HORIZ );
- new NCSpacing( hSplit2, YD_HORIZ, true, 0.1 );
+ //NCLayoutBox * hSplit2 = new NCLayoutBox( this, YD_HORIZ );
+ NCAlignment *left = new NCAlignment( vSplit, YAlignBegin, YAlignUnchanged );
- ignoreCase = new NCCheckBox( hSplit2, NCPkgNames::IgnoreCase(), true ); // checked = true
- new NCSpacing( vSplit, YD_VERT, false, 0.6 );
+ ignoreCase = new NCCheckBox( left, NCPkgNames::IgnoreCase(), true );
+ new NCSpacing( vSplit, YD_VERT, true, 0.5 );
+// new NCSpacing( this, YD_VERT, false, 0.6 );
// label of a frame in search popup (without hotkey)
- NCFrame * frame = new NCFrame( vSplit, _( " Search in " ) );
+ #if 0
+ NCFrame * frame = new NCFrame( this, _( " Search in " ) );
NCLayoutBox * vSplit3 = new NCLayoutBox( frame, YD_VERT );
checkName = new NCCheckBox( vSplit3, NCPkgNames::CheckName(), true );
@@ -132,24 +151,25 @@
checkRequires = new NCCheckBox( vSplit3, NCPkgNames::CheckRequires(), false );
checkRequires->setStretchable(YD_HORIZ, true );
+ #endif
- new NCSpacing( vSplit, YD_VERT, false, 0.8 );
+// new NCSpacing( this, YD_VERT, false, 0.8 );
}
- NCLayoutBox * hSplit3 = new NCLayoutBox( vSplit, YD_HORIZ );
+ //NCLayoutBox * hSplit3 = new NCLayoutBox( vSplit, YD_HORIZ );
- new NCSpacing( hSplit3, YD_HORIZ, true, 0.2 );
+ //new NCSpacing( hSplit3, YD_HORIZ, true, 0.2 );
- // add the cancel and the ok button
- okButton = new NCPushButton( hSplit3, NCPkgNames::OKLabel() );
- okButton->setFunctionKey( 10 );
+ //// add the cancel and the ok button
+ //okButton = new NCPushButton( hSplit3, NCPkgNames::OKLabel() );
+ //okButton->setFunctionKey( 10 );
- new NCSpacing( hSplit3, YD_HORIZ, true, 0.4 );
+ //new NCSpacing( hSplit3, YD_HORIZ, true, 0.4 );
- cancelButton = new NCPushButton( hSplit3, NCPkgNames::CancelLabel() );
- cancelButton->setFunctionKey( 9 );
-
- new NCSpacing( hSplit3, YD_HORIZ, true, 0.2 );
+ //cancelButton = new NCPushButton( hSplit3, NCPkgNames::CancelLabel() );
+ //cancelButton->setFunctionKey( 9 );
+ //
+ //new NCSpacing( hSplit3, YD_HORIZ, true, 0.2 );
}
@@ -161,21 +181,21 @@
//
// DESCRIPTION :
//
-NCursesEvent & NCPkgPopupSearch::showSearchPopup( )
-{
- postevent = NCursesEvent();
- do {
- popupDialog();
- if ( searchExpr )
- {
- searchExpr->setKeyboardFocus();
- }
- } while ( postAgain() );
-
- popdownDialog();
-
- return postevent;
-}
+//NCursesEvent & NCPkgPopupSearch::showSearchPopup( )
+//{
+// postevent = NCursesEvent();
+// do {
+// popupDialog();
+// if ( searchExpr )
+// {
+// searchExpr->setKeyboardFocus();
+// }
+// } while ( postAgain() );
+//
+// popdownDialog();
+//
+// return postevent;
+//}
///////////////////////////////////////////////////////////////////
//
@@ -204,32 +224,138 @@
return value;
}
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : NCPkgPopupSearch::niceSize
-// METHOD TYPE : void
-//
-// DESCRIPTION :
-//
-long NCPkgPopupSearch::nicesize(YUIDimension dim)
+bool NCPkgPopupSearch::match( string s1, string s2, bool ignoreCase )
{
- long vdim;
+ string::iterator pos;
- if ( !packager->isYouMode() )
+ if ( ignoreCase )
{
- if ( NCurses::lines() > 20 )
- vdim = 20;
- else
- vdim = NCurses::lines()-4;
+ pos = ::search( s1.begin(), s1.end(),
+ s2.begin(), s2.end(),
+ ic_compare );
}
else
{
- vdim = 10;
+ pos = search( s1.begin(), s1.end(),
+ s2.begin(), s2.end() );
}
-
- return ( dim == YD_HORIZ ? NCurses::cols()/2 : vdim );
+
+ return ( pos != s1.end() );
}
+
+
+bool NCPkgPopupSearch::fillSearchList( const string & expr,
+ bool ignoreCase,
+ bool checkName,
+ bool checkSummary,
+ bool checkDescr,
+ bool checkProvides,
+ bool checkRequires )
+{
+ NCPkgTable * packageList = packager->PackageList();
+
+ if ( !packageList )
+ {
+ return false;
+ }
+
+ // clear the package table
+ packageList->itemsCleared ();
+
+// FIXME filter it inside zypp
+ ZyppPoolIterator b = zyppPkgBegin ();
+ ZyppPoolIterator e = zyppPkgEnd ();
+ ZyppPoolIterator i;
+
+ // get the package list and sort it
+ list<ZyppSel> pkgList( b, e );
+ pkgList.sort( sortByName );
+
+ // fill the package table
+ list<ZyppSel>::iterator listIt = pkgList.begin();
+ ZyppPkg pkg;
+ string description = "";
+ string provides = "";
+ string requires = "";
+
+ while ( listIt != pkgList.end() )
+ {
+ if ( (*listIt)->installedObj() )
+ pkg = tryCastToZyppPkg ((*listIt)->installedObj());
+ else
+ pkg = tryCastToZyppPkg ((*listIt)->theObj());
+
+ if ( pkg )
+ {
+ if ( checkDescr )
+ {
+ description = pkg->description();
+ //zypp::Text value = pkg->description();
+ //description = createDescrText( value );
+ }
+ if ( checkProvides )
+ {
+ zypp::CapSet value = pkg->dep (zypp::Dep::PROVIDES);
+ //provides = createRelLine( value );
+ }
+ if ( checkRequires )
+ {
+ zypp::CapSet value = pkg->dep (zypp::Dep::REQUIRES);
+ //requires = createRelLine( value );
+ }
+ if ( ( checkName && match( pkg->name(), expr, ignoreCase )) ||
+ ( checkSummary && match( pkg->summary(), expr, ignoreCase) ) ||
+ ( checkDescr && match( description, expr, ignoreCase) ) ||
+ ( checkProvides && match( provides, expr, ignoreCase) ) ||
+ ( checkRequires && match( requires, expr, ignoreCase) )
+ )
+ {
+ // search sucessful
+ packageList->createListEntry( pkg, *listIt );
+ }
+ }
+
+ ++listIt;
+ }
+
+ // show the package list
+ packageList->drawList();
+
+ // set filter label to 'Search'
+ //if ( packageLabel )
+ //{
+// packageLabel->setText( NCPkgNames::SearchResults() );
+ // }
+
+ return true;
+
+}
+///////////////////////////////////////////////////////////////////
+//
+//
+// METHOD NAME : NCPkgPopupSearch::niceSize
+// METHOD TYPE : void
+//
+// DESCRIPTION :
+//
+//long NCPkgPopupSearch::nicesize(YUIDimension dim)
+//{
+// long vdim;
+//
+// if ( !packager->isYouMode() )
+// {
+// if ( NCurses::lines() > 20 )
+// vdim = 20;
+// else
+// vdim = NCurses::lines()-4;
+// }
+// else
+// {
+// vdim = 10;
+// }
+//
+// return ( dim == YD_HORIZ ? NCurses::cols()/2 : vdim );
+//}
///////////////////////////////////////////////////////////////////
//
//
@@ -240,14 +366,20 @@
//
NCursesEvent NCPkgPopupSearch::wHandleInput( wint_t ch )
{
+ NCursesEvent ret = NCursesEvent::none;
if ( ch == 27 ) // ESC
- return NCursesEvent::cancel;
+ ret = NCursesEvent::cancel;
// start package search if Return is pressed
- if ( ch == KEY_RETURN )
- return NCursesEvent::button;
+ else if ( ch == KEY_RETURN )
+ ret = NCursesEvent::button;
+ else
+ ret = NCWidget::wHandleInput( ch );
- return NCDialog::wHandleInput( ch );
+ if (ret.widget == searchButton)
+ NCINT << "porn bat" << endl;
+
+ return ret;
}
///////////////////////////////////////////////////////////////////
@@ -260,45 +392,46 @@
//
bool NCPkgPopupSearch::postAgain()
{
- if ( ! postevent.widget )
- return false;
-
- postevent.result = "";
-
- if ( postevent.widget == cancelButton )
- {
- postevent = NCursesEvent::cancel;
- }
- else if ( postevent == NCursesEvent::button )
- {
- // get the search expression
- postevent.result = getSearchExpression();
+ // if ( ! postevent.widget )
+ // return false;
- string filter = postevent.result;
+ // postevent.result = "";
+ // if ( postevent.widget == cancelButton )
+ // {
+ // postevent = NCursesEvent::cancel;
+ // }
+// else if ( postevent == NCursesEvent::button )
+// {
+// // get the search expression
+// postevent.result = getSearchExpression();
+//
+ NCPkgSearchSettings *settings = packager->SearchSettings();
+ string filter = getSearchExpression();
+//
if ( !packager->isYouMode() )
{
// fill the package list with packages matching the search expression
- packager->fillSearchList( filter,
+ fillSearchList( filter,
getCheckBoxValue( ignoreCase ),
- getCheckBoxValue( checkName ),
- getCheckBoxValue( checkSummary ),
- getCheckBoxValue( checkDescr ),
- getCheckBoxValue( checkProvides ),
- getCheckBoxValue( checkRequires )
+ settings->doCheckName(),
+ settings->doCheckSummary(),
+ settings->doCheckDescr(),
+ settings->doCheckProvides(),
+ settings->doCheckRequires()
);
}
else
{
packager->fillPatchSearchList( filter );
}
- }
+// }
- if ( postevent == NCursesEvent::button || postevent == NCursesEvent::cancel )
- {
- // return false means: close the popup dialog
- return false;
- }
+ // if ( postevent == NCursesEvent::button || postevent == NCursesEvent::cancel )
+ // {
+ // // return false means: close the popup dialog
+ // return false;
+ // }
return true;
}
Modified: branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupSearch.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupSearch.h?rev=45660&r1=45659&r2=45660&view=diff
==============================================================================
--- branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupSearch.h (original)
+++ branches/tmp/bubli/ncurses-pkg/src/NCPkgPopupSearch.h Thu Mar 20 17:31:57 2008
@@ -23,11 +23,14 @@
#include <vector>
#include <string>
+#include <set>
using namespace std;
+using std::string;
#include "NCPopup.h"
#include "NCComboBox.h"
#include "NCLabel.h"
+#include "NCLayoutBox.h"
#include "NCRichText.h"
#include "NCCheckBox.h"
#include "NCPushButton.h"
@@ -40,7 +43,7 @@
//
// DESCRIPTION :
//
-class NCPkgPopupSearch : public NCPopup {
+class NCPkgPopupSearch : public NCLayoutBox {
NCPkgPopupSearch & operator=( const NCPkgPopupSearch & );
NCPkgPopupSearch ( const NCPkgPopupSearch & );
@@ -57,6 +60,7 @@
NCPushButton * cancelButton;
NCPushButton * okButton;
+ NCPushButton * searchButton;
NCPackageSelector * packager; // connection to the package selector
@@ -66,21 +70,32 @@
string getSearchExpression() const;
- virtual bool postAgain();
virtual NCursesEvent wHandleInput( wint_t ch );
public:
- NCPkgPopupSearch( const wpos at, NCPackageSelector *pkger );
+ //NCPkgPopupSearch( const wpos at, NCPackageSelector *pkger );
+ NCPkgPopupSearch( YWidget *parent, YUIDimension dim, NCPackageSelector *pkger );
virtual ~NCPkgPopupSearch();
- virtual long nicesize(YUIDimension dim);
+ //virtual long nicesize(YUIDimension dim);
+
+ void createLayout( YWidget *parent );
+
+ virtual bool postAgain();
+
+ bool match ( string s1, string s2, bool ignoreCase );
+ // NCursesEvent & showSearchPopup( );
+ bool fillSearchList( const string & expr,
+ bool ignoreCase,
+ bool checkName,
+ bool checkSummary,
+ bool checkDescr,
+ bool checkProvides,
+ bool checkRequires );
- void createLayout( const string & headline );
- NCursesEvent & showSearchPopup( );
-
};
///////////////////////////////////////////////////////////////////
Added: branches/tmp/bubli/ncurses-pkg/src/NCPkgSearchSettings.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/bubli/ncurses-pkg/src/NCPkgSearchSettings.cc?rev=45660&view=auto
==============================================================================
--- branches/tmp/bubli/ncurses-pkg/src/NCPkgSearchSettings.cc (added)
+++ branches/tmp/bubli/ncurses-pkg/src/NCPkgSearchSettings.cc Thu Mar 20 17:31:57 2008
@@ -0,0 +1,68 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| | core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: NCPkgFilterMain.cc
+
+ Author: Hedgehog Painter
+
+/-*/
+
+#include "NCPkgSearchSettings.h"
+#include "NCPkgNames.h"
+
+NCPkgSearchSettings::NCPkgSearchSettings ( YWidget *parent, string label)
+ : NCMultiSelectionBox ( parent, label)
+{
+ createLayout();
+}
+
+NCPkgSearchSettings::~NCPkgSearchSettings()
+{
+
+}
+
+void NCPkgSearchSettings::createLayout()
+{
+ checkName = new YItem (NCPkgNames::CheckName(), true);
+ items.push_back (checkName);
+ checkSummary = new YItem (NCPkgNames::CheckSummary(), true);
+ items.push_back (checkSummary);
+ checkDescr = new YItem (NCPkgNames::CheckDescr() );
+ items.push_back (checkDescr);
+ checkProvides = new YItem (NCPkgNames::CheckProvides() );
+ items.push_back (checkProvides);
+ checkRequires = new YItem (NCPkgNames::CheckRequires() );
+ items.push_back (checkRequires);
+
+ addItems( items );
+}
+
+bool NCPkgSearchSettings::doCheckName()
+{
+ return checkName->selected();
+}
+bool NCPkgSearchSettings::doCheckSummary()
+{
+ return checkSummary->selected();
+}
+bool NCPkgSearchSettings::doCheckDescr()
+{
+ return checkDescr->selected();
+}
+bool NCPkgSearchSettings::doCheckProvides()
+{
+ return checkProvides->selected();
+}
+bool NCPkgSearchSettings::doCheckRequires()
+{
+ return checkRequires->selected();
+}
+
Added: branches/tmp/bubli/ncurses-pkg/src/NCPkgSearchSettings.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/bubli/ncurses-pkg/src/NCPkgSearchSettings.h?rev=45660&view=auto
==============================================================================
--- branches/tmp/bubli/ncurses-pkg/src/NCPkgSearchSettings.h (added)
+++ branches/tmp/bubli/ncurses-pkg/src/NCPkgSearchSettings.h Thu Mar 20 17:31:57 2008
@@ -0,0 +1,52 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: NCPkgFilterMain.h
+
+ Author: Hedgehog Painter
+
+/-*/
+
+#ifndef NCPkgSearchSettings_h
+#define NCPkgSearchSettings_h
+
+#include "NCMultiSelectionBox.h"
+
+class NCPkgSearchSettings : public NCMultiSelectionBox {
+
+ NCPkgSearchSettings & operator=( const NCPkgSearchSettings & );
+ NCPkgSearchSettings ( const NCPkgSearchSettings & );
+
+public:
+
+ YItemCollection items;
+ YItem *checkName;
+ YItem *checkSummary;
+ YItem *checkDescr;
+ YItem *checkProvides;
+ YItem *checkRequires;
+
+
+ NCPkgSearchSettings (YWidget *parent, string label);
+ virtual ~NCPkgSearchSettings();
+
+ void createLayout();
+
+ bool doCheckName();
+ bool doCheckSummary();
+ bool doCheckDescr();
+ bool doCheckProvides();
+ bool doCheckRequires();
+
+};
+
+#endif
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org