Author: gs
Date: Sat Nov 10 08:17:28 2007
New Revision: 41951
URL: http://svn.opensuse.org/viewcvs/yast?rev=41951&view=rev
Log:
get correct widget ids
Modified:
branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.cc
branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.h
Modified: branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.cc?rev=41951&r1=41950&r2=41951&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.cc (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.cc Sat Nov 10 08:17:28 2007
@@ -50,6 +50,7 @@
#include "YWidgetID.h"
#include "YCPDialogParser.h"
+#include "YCPValueWidgetID.h"
#include "YPackageSelector.h"
typedef zypp::ui::PatchContents ZyppPatchContents;
@@ -60,6 +61,7 @@
#include
#include
#include
+#include "YEvent.h"
#define DEFAULT_EXPORT_FILE_NAME "user-packages.xml"
@@ -215,6 +217,7 @@
// call YDialog::deleteTopmostDialog() instead at the end of
// NCPackageSelectorPlugin::runPkgSelection
}
+
///////////////////////////////////////////////////////////////////
//
// createPopups
@@ -271,8 +274,6 @@
YStringTreeItem * NCPackageSelector::getDefaultRpmGroup()
{
- NCMIL << "Calling getDefaultRpmGroup()" << endl;
-
if ( filterPopup )
return filterPopup->getDefaultGroup();
else
@@ -432,6 +433,43 @@
return diff;
}
+string NCPackageSelector::getButtonId( YWidget * button )
+{
+ YCPValueWidgetID * ycpId;
+ string id;
+
+ if ( !button )
+ return id;
+
+ YWidgetID * widgetId = button->id();
+ if ( widgetId )
+ {
+ ycpId = dynamic_cast(widgetId);
+ if ( ycpId )
+ {
+ id = ycpId->toString();
+ }
+ }
+ return id;
+}
+
+string NCPackageSelector::getMenuId( YMenuItem *menuItem )
+{
+ string id;
+ YMenuEvent * menuEvent;
+
+ if ( !menuItem )
+ return id;
+
+ menuEvent = new YMenuEvent( menuItem );
+ if ( menuEvent )
+ {
+ YCPValue selectionId = menuEvent->id();
+ id = selectionId->toString();
+ }
+ return id;
+}
+
///////////////////////////////////////////////////////////////////
//
// handleEvent
@@ -441,7 +479,7 @@
bool NCPackageSelector::handleEvent ( const NCursesEvent& event )
{
bool retVal = false;
- YWidgetID * currentId = 0;
+ string currentId = "";
//YCPValue currentId = YCPNull();
if ( event == NCursesEvent::handled )
@@ -450,28 +488,32 @@
// Get the id of the widget which is affected
if ( event == NCursesEvent::button )
{
- currentId = dynamic_cast(event.widget)->id();
+ YWidget * widget = dynamic_cast(event.widget);
+ if ( widget )
+ currentId = getButtonId( widget );
}
else if ( event == NCursesEvent::menu )
{
- currentId = event.selection;
+ currentId = getMenuId(event.selection);
}
// Find the handler-function for the given widget-nameId
- if ( currentId )
+ if ( currentId != "" )
{
- UIMIL << "Selected widget id: " << currentId->toString() << endl;
+ UIMIL << "Selected widget id: " << currentId << endl;
+ // remove '"' at begin and end of cuurentId
+ string linkId = currentId.substr(1,currentId.substr().length()-2);
// hyperlink
//if ( currentId->isString()
// && currentId->asString()->value().substr(0, 4) == "pkg:" )
- if ( currentId->toString().substr(0,4) == "pkg:" )
+ if ( linkId.substr(0,4) == "pkg:" )
{
//LinkHandler( currentId->asString()->value() );
- LinkHandler( currentId->toString() );
+ LinkHandler( linkId );
return true;
}
- tHandlerMap::iterator it = eventHandlerMap.find ( currentId->toString() );
+ tHandlerMap::iterator it = eventHandlerMap.find ( currentId );
if (it != eventHandlerMap.end()) // if currentId found in map
{
@@ -480,7 +522,7 @@
}
else
{
- UIERR << "Unhandled event for widget-Id: " << currentId->toString() << endl;
+ UIERR << "Unhandled event for widget-Id: " << currentId << endl;
// return true means: don't leave the event loop in runPkgSelection
retVal = true;
@@ -1460,7 +1502,7 @@
NCERR << "*** InformationHandler RETURN false ***" << endl;
return false;
}
-
+#if 0
if ( visibleInfo->isEqual( event.selection ) )
{
// information selection has not changed
@@ -1568,7 +1610,7 @@
}
packageList->setKeyboardFocus();
-
+#endif
UIMIL << "Change package info to: " << visibleInfo->toString() << endl;
return true;
}
@@ -1590,8 +1632,9 @@
NCPkgNames::OKLabel() );
info->setNiceSize( 35, 5 );
+ string selId = getMenuId( event.selection );
// ( event.selection->compare( NCPkgNames::ShowDeps() ) == YO_EQUAL )
- if ( event.selection->toString() == "showdeps" )
+ if ( selId == NCPkgNames::ShowDeps()->toString() )
{
bool ok = false;
@@ -1609,14 +1652,14 @@
showDiskSpace();
}
// else if ( event.selection->compare( NCPkgNames::VerifySystem() ) == YO_EQUAL )
- else if ( event.selection->toString() == "verifysystem" )
+ else if ( selId == NCPkgNames::VerifySystem()->toString() )
{
verifyPackageDependencies();
updatePackageList();
showDiskSpace();
}
// else if ( event.selection->compare( NCPkgNames::AutoDeps() ) == YO_EQUAL )
- else if ( event.selection->toString() == "autodeps" )
+ else if ( selId == NCPkgNames::AutoDeps()->toString() )
{
char menu[2000];
@@ -1717,18 +1760,20 @@
{
return false;
}
-
+ string selId = getMenuId( event.selection );
+
// if ( event.selection->compare( NCPkgNames::RpmGroups() ) == YO_EQUAL )
- if ( event.selection->toString() == "groups" )
+ if ( selId == NCPkgNames::RpmGroups()->toString() )
{
if ( filterPopup )
{
+ NCMIL << "Showing RPM groups" << endl;
// show the filter popup (fills the package list)
retEvent = filterPopup->showFilterPopup( );
}
}
// else if ( event.selection->compare( NCPkgNames::Selections() ) == YO_EQUAL )
- else if ( event.selection->toString() == "selections" )
+ else if ( selId == NCPkgNames::Selections()->toString() )
{
if ( selectionPopup )
{
@@ -1737,7 +1782,7 @@
}
}
// else if ( event.selection->compare( NCPkgNames::Patterns() ) == YO_EQUAL )
- else if ( event.selection->toString() == "patterns" )
+ else if ( selId == NCPkgNames::Patterns()->toString() )
{
if ( patternPopup )
{
@@ -1746,7 +1791,7 @@
}
}
// else if ( event.selection->compare( NCPkgNames::Languages() ) == YO_EQUAL )
- else if ( event.selection->toString() == "languages" )
+ else if ( selId == NCPkgNames::Languages()->toString() )
{
if ( languagePopup )
{
@@ -1756,57 +1801,57 @@
}
// patches
// else if ( event.selection->compare( NCPkgNames::Recommended() ) == YO_EQUAL )
- else if ( event.selection->toString() == "recommended" )
+ else if ( selId == NCPkgNames::Recommended()->toString() )
{
fillPatchList( "recommended" ); // patch kind
}
// else if ( event.selection->compare( NCPkgNames::Security() ) == YO_EQUAL )
- else if ( event.selection->toString() == "security" )
+ else if ( selId == NCPkgNames::Security()->toString() )
{
fillPatchList( "security" ); // patch kind
}
// else if ( event.selection->compare( NCPkgNames::Optional() ) == YO_EQUAL )
- else if ( event.selection->toString() == "optional" )
+ else if ( selId == NCPkgNames::Optional()->toString() )
{
fillPatchList( "optional" ); // patch kind
}
// else if ( event.selection->compare( NCPkgNames::YaST2Patches() ) == YO_EQUAL )
- else if ( event.selection->toString() == "yast2" )
+ else if ( selId == NCPkgNames::YaST2Patches()->toString() )
{
fillPatchList( "YaST2" ); // patch kind
}
// else if ( event.selection->compare( NCPkgNames::AllPatches() ) == YO_EQUAL )
- else if ( event.selection->toString() == "allpatches" )
+ else if ( selId == NCPkgNames::AllPatches()->toString() )
{
fillPatchList( "all" ); // show all patches
}
// else if ( event.selection->compare( NCPkgNames::InstalledPatches() ) == YO_EQUAL )
- else if ( event.selection->toString() == "instpatches" )
+ else if ( selId == NCPkgNames::InstalledPatches()->toString() )
{
fillPatchList( "installed" ); // show installed patches
}
// else if ( event.selection->compare( NCPkgNames::InstallablePatches() ) == YO_EQUAL )
- else if ( event.selection->toString() == "installablepatches" )
+ else if ( selId == NCPkgNames::InstallablePatches()->toString() )
{
fillPatchList( "installable" ); // show installed patches
}
// else if ( event.selection->compare( NCPkgNames::NewPatches() ) == YO_EQUAL )
- else if ( event.selection->toString() == "newpatches" )
+ else if ( selId == NCPkgNames::NewPatches()->toString() )
{
fillPatchList( "new" ); // show new patches
}
// else if ( event.selection->compare( NCPkgNames::UpdateList() ) == YO_EQUAL )
- else if ( event.selection->toString() == "updatelist" )
+ else if ( selId == NCPkgNames::UpdateList()->toString() )
{
fillUpdateList();
}
// else if ( event.selection->compare( NCPkgNames::Whatif() ) == YO_EQUAL )
- else if ( event.selection->toString() == "whatif" )
+ else if ( selId == NCPkgNames::Whatif()->toString() )
{
fillSummaryList( NCPkgTable::L_Changes );
}
// else if ( event.selection->compare( NCPkgNames::Installed() ) == YO_EQUAL )
- else if ( event.selection->toString() == "installed" )
+ else if ( selId == NCPkgNames::Installed()->toString() )
{
fillSummaryList( NCPkgTable::L_Installed );
}
@@ -1829,7 +1874,7 @@
bool NCPackageSelector::StatusHandler( const NCursesEvent& event )
{
NCPkgTable * packageList = getPackageList();
-
+
if ( !packageList
|| !event.selection )
{
@@ -1842,14 +1887,16 @@
return true;
}
+ string selId = getMenuId( event.selection );
+
// call the corresponding method of NCPkgTable
// if ( event.selection->compare( NCPkgNames::Toggle() ) == YO_EQUAL )
- if ( event.selection->toString() == "toggle" )
+ if ( selId == NCPkgNames::Toggle()->toString() )
{
packageList->toggleObjStatus( );
}
// else if ( event.selection->compare( NCPkgNames::Select() ) == YO_EQUAL )
- else if ( event.selection->toString() =="select" )
+ else if ( selId == NCPkgNames::Select()->toString() )
{
if ( testMode )
diskspacePopup->setDiskSpace( '+' );
@@ -1857,7 +1904,7 @@
packageList->changeObjStatus( '+' );
}
// else if ( event.selection->compare( NCPkgNames::Delete() ) == YO_EQUAL )
- else if (event.selection->toString() == "delete" )
+ else if (selId == NCPkgNames::Delete()->toString() )
{
if ( testMode )
diskspacePopup->setDiskSpace( '-' );
@@ -1865,7 +1912,7 @@
packageList->changeObjStatus( '-' );
}
// else if ( event.selection->compare( NCPkgNames::Update() ) == YO_EQUAL )
- else if (event.selection->toString() == "update" )
+ else if ( selId == NCPkgNames::Update()->toString() )
{
if ( testMode )
diskspacePopup->checkDiskSpaceRange();
@@ -1873,61 +1920,61 @@
packageList->changeObjStatus( '>' );
}
// else if ( event.selection->compare( NCPkgNames::TabooOn() ) == YO_EQUAL )
- else if (event.selection->toString() == "tabooOn" )
+ else if (selId == NCPkgNames::TabooOn()->toString() )
{
packageList->changeObjStatus( '!' );
}
// else if ( event.selection->compare( NCPkgNames::TabooOff() ) == YO_EQUAL )
- else if (event.selection->toString() == "tabooOff" )
+ else if (selId == NCPkgNames::TabooOff()->toString() )
{
packageList->changeObjStatus( '%' );
}
// else if ( event.selection->compare( NCPkgNames::SourceYes() ) == YO_EQUAL )
- else if (event.selection->toString() == "sourceYes" )
+ else if (selId == NCPkgNames::SourceYes()->toString() )
{
#ifdef FIXME
packageList->SourceInstall( true );
#endif
}
// else if ( event.selection->compare( NCPkgNames::SourceNo() ) == YO_EQUAL )
- else if (event.selection->toString() == "sourceNo" )
+ else if (selId == NCPkgNames::SourceNo()->toString() )
{
#ifdef FIXME
packageList->SourceInstall( false );
#endif
}
// else if ( event.selection->compare( NCPkgNames::InstallAll() ) == YO_EQUAL )
- else if (event.selection->toString() == "selall" )
+ else if (selId == NCPkgNames::InstallAll()->toString() )
{
packageList->changeListObjStatus( NCPkgTable::A_Install );
}
// else if ( event.selection->compare( NCPkgNames::DontInstall() ) == YO_EQUAL )
- else if (event.selection->toString() == "deselall" )
+ else if (selId == "deselall" )
{
packageList->changeListObjStatus( NCPkgTable::A_DontInstall );
}
// else if ( event.selection->compare( NCPkgNames::DeleteAll() ) == YO_EQUAL )
- else if (event.selection->toString() == "delall" )
+ else if (selId == NCPkgNames::DeleteAll()->toString() )
{
packageList->changeListObjStatus( NCPkgTable::A_Delete );
}
// else if ( event.selection->compare( NCPkgNames::DontDelete() ) == YO_EQUAL )
- else if (event.selection->toString() == "dontdel" )
+ else if (selId == NCPkgNames::DontDelete()->toString() )
{
packageList->changeListObjStatus( NCPkgTable::A_DontDelete );
}
// else if ( event.selection->compare( NCPkgNames::UpdateNewer() ) == YO_EQUAL )
- else if (event.selection->toString() == "updnewer" )
+ else if (selId == NCPkgNames::UpdateNewer()->toString() )
{
packageList->changeListObjStatus( NCPkgTable::A_UpdateNewer );
}
// else if ( event.selection->compare( NCPkgNames::UpdateAll() ) == YO_EQUAL )
- else if (event.selection->toString() == "updall" )
+ else if (selId == NCPkgNames::UpdateAll()->toString() )
{
packageList->changeListObjStatus( NCPkgTable::A_Update );
}
// else if ( event.selection->compare( NCPkgNames::DontUpdate() ) == YO_EQUAL )
- else if (event.selection->toString() == "dontupd" )
+ else if (selId == NCPkgNames::DontUpdate()->toString() )
{
packageList->changeListObjStatus( NCPkgTable::A_DontUpdate );
}
@@ -2053,9 +2100,11 @@
return false;
}
+ string selId = getMenuId( event.selection );
+
//Export package list into file
// if ( event.selection->compare( NCPkgNames::ExportToFile() ) == YO_EQUAL )
- if ( event.selection->toString() =="export" )
+ if ( selId == NCPkgNames::ExportToFile()->toString() )
{
//Ask for file to save into
YCPValue filename = YNCursesUI::ui()->askForSaveFileName( YCPString(DEFAULT_EXPORT_FILE_NAME),
@@ -2109,7 +2158,7 @@
//Import package list from file
// else if ( event.selection->compare( NCPkgNames::ImportFromFile() ) == YO_EQUAL )
- else if ( event.selection->toString() =="import" )
+ else if ( selId == NCPkgNames::ImportFromFile()->toString() )
{
//ask for file to open
YCPValue filename = YNCursesUI::ui()->askForExistingFile( YCPString(DEFAULT_EXPORT_FILE_NAME),
@@ -2208,9 +2257,11 @@
{
return false;
}
+
+ string selId = getMenuId( event.selection );
// if ( event.selection->compare( NCPkgNames::GeneralHelp() ) == YO_EQUAL )
- if ( event.selection->toString() == "help_general" )
+ if ( selId == NCPkgNames::GeneralHelp()->toString() )
{
text += NCPkgNames::HelpPkgInst1();
text += NCPkgNames::HelpPkgInst12();
@@ -2222,7 +2273,7 @@
text += NCPkgNames::HelpPkgInst6();
}
// else if ( event.selection->compare( NCPkgNames::StatusHelp() ) == YO_EQUAL )
- else if ( event.selection->toString() == "help_status" )
+ else if ( selId == NCPkgNames::StatusHelp()->toString() )
{
text += NCPkgNames::HelpOnStatus1();
text += NCPkgNames::HelpOnStatus2();
@@ -2233,12 +2284,12 @@
text += NCPkgNames::HelpOnStatus7();
}
// else if ( event.selection->compare( NCPkgNames::UpdateHelp() ) == YO_EQUAL )
- else if ( event.selection->toString() == "help_update" )
+ else if ( selId == NCPkgNames::UpdateHelp()->toString() )
{
text += NCPkgNames::HelpOnUpdate();
}
// else if ( event.selection->compare( NCPkgNames::SearchHelp() ) == YO_EQUAL )
- else if ( event.selection->toString() == "help_search" )
+ else if ( selId == NCPkgNames::SearchHelp()->toString() )
{
headline = YCPString(NCPkgNames::SearchHeadline());
text += NCPkgNames::HelpOnSearch();
Modified: branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.h?rev=41951&r1=41950&r2=41951&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.h (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.h Sat Nov 10 08:17:28 2007
@@ -114,6 +114,8 @@
protected:
+ string getButtonId( YWidget *button );
+ string getMenuId( YMenuItem *menu );
public:
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org