Author: kmachalkova Date: Thu Feb 28 12:42:26 2008 New Revision: 45100 URL: http://svn.opensuse.org/viewcvs/yast?rev=45100&view=rev Log: moved Modified: branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.cc branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.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=45100&r1=45099&r2=45100&view=diff ============================================================================== --- branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.cc (original) +++ branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.cc Thu Feb 28 12:42:26 2008 @@ -43,9 +43,8 @@ #include "YApplication.h" #include "NCi18n.h" -#include <boost/bind.hpp> -#include <fstream> -#include <iomanip> +//#include <fstream> +//#include <iomanip> #include <list> #include <string> #include <set> @@ -53,7 +52,6 @@ #include "NCZypp.h" // tryCastToZyppPkg(), tryCastToZyppPatch() #include <zypp/ui/Selectable.h> #include <zypp/ui/PatchContents.h> -#include <zypp/SysContent.h> #include "YWidgetID.h" //#include "YCPDialogParser.h" @@ -63,15 +61,11 @@ typedef zypp::ui::PatchContents ZyppPatchContents; typedef zypp::ui::PatchContents::const_iterator ZyppPatchContentsIterator; -typedef zypp::syscontent::Reader::Entry ZyppReaderEntry; -typedef std::pair<string, ZyppReaderEntry> importMapPair; #include <ycp/Parser.h> #include "YCP_UI.h" // FIXME: Get rid of this when ReplaceWidget() is no longer done with YCP #include "YEvent.h" -#define DEFAULT_EXPORT_FILE_NAME "user-packages.xml" - using namespace std; using std::string; using std::wstring; @@ -151,11 +145,8 @@ , patchpkgsItem( 0 ) , pkgversionsItem( 0 ) , etcMenu( 0 ) - , allpksItem( 0 ) - , exportItem( 0 ) - , importItem( 0 ) , testcaseItem( 0 ) - , filterLabel( 0 ) + , packageLabel( 0 ) , diskspaceLabel( 0 ) , infoText( 0 ) , replacePoint( 0 ) @@ -540,12 +531,6 @@ retVal = depsMenu->handleEvent( event ); else if ( event.widget == extrasMenu ) retVal = extrasMenu->handleEvent( event ); - else if ( event.widget == etcMenu ) - { - if ( (event.selection == exportItem) || (event.selection == importItem) ) - // import/export file list - retVal = FileHandler( event ); - } else if ( event.selection->label().substr(0,4) == "pkg:" ) // handle hyper links retVal = LinkHandler( event.selection->label() ); @@ -692,9 +677,9 @@ // NCDBG << "Filter: " << label << endl; // // show the selected filter label - // if ( filterLabel ) + // if ( packageLabel ) // { - // filterLabel->setLabel( label ); + // packageLabel->setLabel( label ); // } //} @@ -784,9 +769,9 @@ packageList->drawList(); // set filter label to 'Search' - if ( filterLabel ) + if ( packageLabel ) { - filterLabel->setText( NCPkgNames::SearchResults() ); + packageLabel->setText( NCPkgNames::SearchResults() ); } return true; @@ -832,9 +817,9 @@ packageList->drawList(); // set filter label to 'Search' - if ( filterLabel ) + if ( packageLabel ) { - filterLabel->setLabel( NCPkgNames::SearchResults() ); + packageLabel->setLabel( NCPkgNames::SearchResults() ); } return true; @@ -886,20 +871,20 @@ packageList->drawList(); // show the selected filter label - if ( filterLabel ) + if ( packageLabel ) { if ( filter == "installable" ) { // show common label "Online Update Patches" - filterLabel->setLabel( NCPkgNames::YOUPatches() ); + packageLabel->setLabel( NCPkgNames::YOUPatches() ); } else if ( filter == "installed" ) { - filterLabel->setLabel( NCPkgNames::InstPatches() ); + packageLabel->setLabel( NCPkgNames::InstPatches() ); } else { - filterLabel->setLabel( NCPkgNames::Patches() ); + packageLabel->setLabel( NCPkgNames::Patches() ); } } @@ -951,9 +936,9 @@ packageList->drawList(); // show the selected filter label - if ( filterLabel ) + if ( packageLabel ) { - filterLabel->setLabel( NCPkgNames::UpdateProblem() ); + packageLabel->setLabel( NCPkgNames::UpdateProblem() ); } return true; @@ -1131,9 +1116,9 @@ packageList->drawList(); // show the selected filter label - if ( filterLabel ) + if ( packageLabel ) { - filterLabel->setLabel( NCPkgNames::InstSummary() ); + packageLabel->setLabel( NCPkgNames::InstSummary() ); } return true; @@ -1202,9 +1187,9 @@ if ( ! label.empty() ) { // show the selected filter label - if ( filterLabel ) + if ( packageLabel ) { - filterLabel->setText( label ); + packageLabel->setText( label ); } } @@ -1277,12 +1262,12 @@ //and show the whole stuff to the user pkgList->drawList(); - if ( repoPopup && filterLabel ) + if ( repoPopup && packageLabel ) { ZyppProduct product = repoPopup->findProductForRepo( repo ); if ( product ) { - filterLabel->setLabel( product->summary() ); + packageLabel->setLabel( product->summary() ); } } @@ -1459,78 +1444,6 @@ return displayPatch; } -void NCPackageSelector::importSelectable( ZyppSel selectable, bool isWanted, const char* kind ) -{ - ZyppStatus oldStatus = selectable->status(); - ZyppStatus newStatus = oldStatus; - - //Package/Pattern is on the list - if (isWanted) - { - switch (oldStatus) - { - //Keep status for installed ones - case S_Install: - case S_AutoInstall: - case S_Update: - case S_AutoUpdate: - case S_KeepInstalled: - case S_Protected: - newStatus = oldStatus; - break; - - //Keep also those marked for deletion - case S_Del: - case S_AutoDel: - newStatus = S_KeepInstalled; - NCDBG << "Keeping " << kind << " " << selectable->name().c_str() << endl; - break; - - //Add not yet installed pkgs (if they have candidate available) - case S_NoInst: - case S_Taboo: - if ( selectable->hasCandidateObj() ) - { - newStatus = S_Install; - NCDBG << "Adding " << kind << " " << selectable->name().c_str() << endl; - } - else - { - NCDBG << "Cannot add " << kind << " " << selectable->name().c_str() << - " " << " - no candidate." << endl; - } - break; - } - } - //Package/Pattern is not on the list - else - { - switch (oldStatus) - { - //Mark installed ones for deletion - case S_Install: - case S_AutoInstall: - case S_Update: - case S_AutoUpdate: - case S_KeepInstalled: - case S_Protected: - newStatus = S_Del; - NCDBG << "Deleting " << kind << " " << selectable->name().c_str() << endl; - break; - - //Keep status for not installed, taboo and to-be-deleted - case S_Del: - case S_AutoDel: - case S_NoInst: - case S_Taboo: - newStatus = oldStatus; - break; - } - } - - if (oldStatus != newStatus) - selectable->set_status( newStatus ); -} /////////////////////////////////////////////////////////////////// // @@ -1873,158 +1786,6 @@ /////////////////////////////////////////////////////////////////// // -// File handler -// -// export/import all packages and patterns list to/from file -// -bool NCPackageSelector::FileHandler( const NCursesEvent& event ) -{ - if ( !event.selection ) - { - return false; - } - - //Export package list into file - if ( event.selection == exportItem ) - { - //Ask for file to save into - string filename = YUI::app()->askForSaveFileName( DEFAULT_EXPORT_FILE_NAME, - "*.xml", - _("Export List of All Packages and Patterns to File" )); - - if ( ! filename.empty() ) - { - zypp::syscontent::Writer writer; - const zypp::ResPool & pool = zypp::getZYpp()->pool(); - - //some strange C++ magic (c) by ma - for_each( pool.begin(), pool.end(), - boost::bind( &zypp::syscontent::Writer::addIf, - boost::ref(writer), - _1)); - - try - { - //open file for writing and try to dump syscontent into it - std::ofstream exportFile( filename.c_str() ); - exportFile.exceptions(std::ios_base::badbit | std::ios_base::failbit ); - exportFile << writer; - - NCMIL << "Exported list of packages and patterns to " << filename << endl; - } - - catch (std::exception & exception) - { - NCWAR << "Error exporting list of packages and patterns to " << filename << endl; - - //delete partially written file (don't care if it doesn't exist) - (void) unlink( filename.c_str() ); - - //present error popup to the user - NCPopupInfo * errorMsg = new NCPopupInfo( wpos( (NCurses::lines()-5)/2, (NCurses::cols()-40)/2 ), - NCPkgNames::ErrorLabel(), - _("Error exporting list of packages and patterns to ") - // FIXME: String addition is evil for translators! - + filename, - NCPkgNames::OKLabel(), - ""); - errorMsg->setNiceSize(40,5); - NCursesEvent input = errorMsg->showInfoPopup(); - - YDialog::deleteTopmostDialog(); - } - - return true; - } - } - - //Import package list from file - else if ( event.selection == importItem ) - { - //ask for file to open - string filename = YUI::app()->askForExistingFile( DEFAULT_EXPORT_FILE_NAME, - "*.xml", - _("Import List of All Packages and Patterns from File")); - - if ( ! filename.empty() ) - { - NCPkgTable * packageList = PackageList(); - NCMIL << "Importing list of packages and patterns from " << filename << endl; - - try - { - std::ifstream importFile ( filename.c_str() ); - zypp::syscontent::Reader reader (importFile); - - //maps to store package/pattern data into - map<string, ZyppReaderEntry> importPkgs; - map<string, ZyppReaderEntry> importPatterns; - - //Import syscontent reader to a map $[ "package_name" : pointer_to_data] - for (zypp::syscontent::Reader::const_iterator it = reader.begin(); - it != reader.end(); - it ++ ) - { - string kind = it->kind(); - - // importMapPair => std::pair<string, ZyppReaderEntry> - if ( kind == "package" ) - importPkgs.insert( importMapPair( it->name(), *it ) ); - else if ( kind == "pattern" ) - importPatterns.insert( importMapPair( it->name(), *it ) ); - } - - NCMIL << "Found " << importPkgs.size() << " packages and " << importPatterns.size() << " patterns." << endl; - - //Change status of appropriate packages and patterns - for (ZyppPoolIterator it = zyppPkgBegin(); - it != zyppPkgEnd(); - it++ ) - { - ZyppSel selectable = *it; - //isWanted => package name found in importPkgs map - importSelectable ( *it, importPkgs.find( selectable->name() ) != importPkgs.end(), "package" ); - } - - for (ZyppPoolIterator it = zyppPatternsBegin(); - it != zyppPatternsEnd(); - it++ ) - { - ZyppSel selectable = *it; - importSelectable ( *it, importPatterns.find( selectable->name() ) != importPatterns.end(), "pattern" ); - } - - //Switch to installation summary filter - fillSummaryList(NCPkgTable::L_Changes); - - //... and finally display the result - packageList->showInformation(); - packageList->setKeyboardFocus(); - - return true; - } - catch ( const zypp::Exception & exception ) - { - NCWAR << "Error importing list of packages and patterns from" << filename << endl; - - NCPopupInfo * errorMsg = new NCPopupInfo( wpos( (NCurses::lines()-5)/2, (NCurses::cols()-40)/2) , - NCPkgNames::ErrorLabel(), - _("Error importing list of packages and patterns from ") - // FIXME: String addition is evil for translators! - + filename, - NCPkgNames::OKLabel(), - ""); - errorMsg->setNiceSize(40,5); - NCursesEvent input = errorMsg->showInfoPopup(); - - YDialog::deleteTopmostDialog(); - } - } - } - return true; -} -/////////////////////////////////////////////////////////////////// -// // HelpHandler // // Show the help popup @@ -3012,7 +2773,7 @@ // label text - keep it short new NCLabel( hSplit2, _( "Package: " ) ); - filterLabel = YUI::widgetFactory()->createLabel ( hSplit2, "......................" ); + packageLabel = YUI::widgetFactory()->createLabel ( hSplit2, "......................" ); new NCSpacing( hSplit2, YD_HORIZ, true, 0.5 ); @@ -3045,33 +2806,6 @@ } -void NCPackageSelector::createEtcMenu( ) -{ - // menu item of the Etc. menu - package dependency check - depsItem = new YMenuItem( _( "&Dependencies" ) ); - // menu items of the Etc./Dependencies submenu - showdepsItem = new YMenuItem( depsItem, _( " &Check Dependencies Now" ) ); - if ( autoCheck ) - // menu entry: dependency check off - autodepsItem = new YMenuItem( depsItem, _( "[X] &Automatic Dependency Check" ) ); - else - // menu entry: dependency check on - noautodepsItem = new YMenuItem( depsItem, _( "[ ] &Automatic Dependency Check" ) ); - - verifyItem = new YMenuItem( depsItem, _( " &Verify System" ) ); - // menu item - list of all packages in the system - allpksItem = new YMenuItem( _("All &Packages List" ) ); - exportItem = new YMenuItem( allpksItem, _("&Export to File") ); - importItem = new YMenuItem( allpksItem, _("&Import from File") ); - testcaseItem = new YMenuItem( _( "Generate Dependency Resolver &Test Case" ) ); - - YItemCollection itemCollection4; - itemCollection4.push_back( depsItem ); - itemCollection4.push_back( allpksItem ); - itemCollection4.push_back( testcaseItem ); - etcMenu->addItems( itemCollection4 ); -} - // // Fill package list with packages of default RPM group/update list or installable patches // 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=45100&r1=45099&r2=45100&view=diff ============================================================================== --- branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.h (original) +++ branches/tmp/bubli/ncurses-pkg/src/NCPackageSelector.h Thu Feb 28 12:42:26 2008 @@ -153,13 +153,11 @@ YMenuItem * noautodepsItem; YMenuItem * verifyItem; YMenuItem * allpksItem; - YMenuItem * exportItem; - YMenuItem * importItem ; YMenuItem * testcaseItem; // labels - YLabel * filterLabel; + YLabel * packageLabel; YLabel * diskspaceLabel; // information about packages @@ -220,7 +218,6 @@ * @return void */ void createPkgLayout( YWidget * parent, NCPkgTable::NCPkgTableType type ); - void createEtcMenu(); /** * Create layout for the Online Update @@ -232,7 +229,9 @@ // returns the package table widget NCPkgTable * PackageList(); - NCPkgPopupDeps *DepsPopup() {return depsPopup; } + NCPkgPopupDeps *DepsPopup() { return depsPopup; } + NCPkgPopupDiskspace *diskSpacePopup() { return diskspacePopup; } + YLabel *PackageLabel() { return packageLabel; } bool checkNow( bool *ok ) { return depsPopup->showDependencies( NCPkgPopupDeps::S_Solve, ok ); } @@ -350,12 +349,6 @@ bool InformationHandler ( const NCursesEvent& event ); /** - * Export/Import list of all packages and patterns to/from file - * - */ - bool FileHandler ( const NCursesEvent& event ); - - /** * Handler function for "OK button pressed" * @param event The Ncurses event * @return bool @@ -458,18 +451,7 @@ **/ bool checkPatch( ZyppPatch patch, ZyppSel selectable, string filter ); - /** - * Set status of a selectable according to its presence - * in the list imported from xml file (zypp::syscontent::Reader) - * - * @param selectable a selectable - * @param isWanted should be installed or not - * @param kind "package" or "pattern" - * @return void - **/ - void importSelectable ( ZyppSel selectable, bool isWanted, const char* kind ); - - /** + /** * Returns whether automatic dependency is on or off * @return bool */ @@ -497,7 +479,6 @@ */ bool match( string s1, string s2, bool ignoreCase ); - NCPkgPopupDiskspace *diskSpacePopup() { return diskspacePopup; } /** * Calls the package mananager (updateDu()) and shows the required disk space */ -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org