Mailinglist Archive: yast-commit (819 mails)

< Previous Next >
[yast-commit] r54937 - /branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/
  • From: sh-sh-sh@xxxxxxxxxxxxxxxx
  • Date: Fri, 23 Jan 2009 12:28:08 -0000
  • Message-id: <E1LQL8q-0000z6-Nk@xxxxxxxxxxxxxxxx>
Author: sh-sh-sh
Date: Fri Jan 23 13:28:08 2009
New Revision: 54937

URL: http://svn.opensuse.org/viewcvs/yast?rev=54937&view=rev
Log:
Peaceful coexistence between PackageKit groups view
and good old RPM group tags view

Added:

branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgPackageKitGroupsFilterView.cc

branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgPackageKitGroupsFilterView.h
Modified:
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/CMakeLists.txt
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPackageSelector.cc
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPackageSelector.h

branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgRpmGroupTagsFilterView.cc
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgRpmGroupTagsFilterView.h

Modified: branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/CMakeLists.txt
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/CMakeLists.txt?rev=54937&r1=54936&r2=54937&view=diff
==============================================================================
--- branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/CMakeLists.txt (original)
+++ branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/CMakeLists.txt Fri Jan 23
13:28:08 2009
@@ -37,6 +37,7 @@
YQPkgLangList.cc
YQPkgList.cc
YQPkgObjList.cc
+ YQPkgPackageKitGroupsFilterView.cc
YQPkgPatchFilterView.cc
YQPkgPatchList.cc
YQPkgPatternList.cc

Modified: branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPackageSelector.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPackageSelector.cc?rev=54937&r1=54936&r2=54937&view=diff
==============================================================================
--- branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPackageSelector.cc
(original)
+++ branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPackageSelector.cc Fri Jan
23 13:28:08 2009
@@ -68,14 +68,15 @@
#include "YQPkgDiskUsageWarningDialog.h"
#include "YQPkgFileListView.h"
#include "YQPkgFilterTab.h"
-#include "YQPkgRepoFilterView.h"
-#include "YQPkgRepoList.h"
#include "YQPkgLangList.h"
#include "YQPkgList.h"
+#include "YQPkgPackageKitGroupsFilterView.h"
#include "YQPkgPatchFilterView.h"
#include "YQPkgPatchList.h"
#include "YQPkgPatternList.h"
#include "YQPkgProductDialog.h"
+#include "YQPkgRepoFilterView.h"
+#include "YQPkgRepoList.h"
#include "YQPkgRpmGroupTagsFilterView.h"
#include "YQPkgSearchFilterView.h"
#include "YQPkgStatusFilterView.h"
@@ -83,6 +84,7 @@
#include "YQPkgTextDialog.h"
#include "YQPkgUpdateProblemFilterView.h"
#include "YQPkgVersionsView.h"
+
#include "zypp/SysContent.h"
#include "zypp/base/String.h"

@@ -113,8 +115,10 @@
_autoDependenciesAction = 0;
_detailsViews = 0;
_filters = 0;
- _repoFilterView = 0;
_langList = 0;
+ _packageKitGroupsFilterView = 0;
+ _patchFilterView = 0;
+ _patchList = 0;
_patternList = 0;
_pkgChangeLogView = 0;
_pkgDependenciesView = 0;
@@ -123,12 +127,11 @@
_pkgList = 0;
_pkgTechnicalDetailsView = 0;
_pkgVersionsView = 0;
+ _repoFilterView = 0;
_rpmGroupTagsFilterView = 0;
_searchFilterView = 0;
_statusFilterView = 0;
_updateProblemFilterView = 0;
- _patchFilterView = 0;
- _patchList = 0;
_excludeDevelPkgs = 0;
_excludeDebugInfoPkgs = 0;

@@ -298,12 +301,24 @@


//
+ // PackageKit group view
+ //
+
+ _packageKitGroupsFilterView = new YQPkgPackageKitGroupsFilterView( parent
);
+ YUI_CHECK_NEW( _packageKitGroupsFilterView );
+ _filters->addPage( _( "Package Groups" ), _packageKitGroupsFilterView,
"package_groups" );
+
+ connect( this, SIGNAL( loadData() ),
+ _packageKitGroupsFilterView, SLOT ( filter() ) );
+
+
+ //
// RPM group tags view
//

_rpmGroupTagsFilterView = new YQPkgRpmGroupTagsFilterView( parent );
YUI_CHECK_NEW( _rpmGroupTagsFilterView );
- _filters->addPage( _( "Package Groups" ), _rpmGroupTagsFilterView,
"package_groups" );
+ _filters->addPage( _( "RPM Groups" ), _rpmGroupTagsFilterView,
"rpm_groups" );

connect( this, SIGNAL( loadData() ),
_rpmGroupTagsFilterView, SLOT ( filter() ) );
@@ -837,12 +852,15 @@
{
connectFilter( _updateProblemFilterView, _pkgList, false );
connectFilter( _patternList, _pkgList );
- connectFilter( _langList, _pkgList );
+ connectFilter( _langList, _pkgList );
connectFilter( _repoFilterView, _pkgList, false );
+ connectFilter( _packageKitGroupsFilterView, _pkgList, false );
connectFilter( _rpmGroupTagsFilterView, _pkgList, false );
- //FIXMEconnectFilter( _langList, _pkgList );
connectFilter( _statusFilterView, _pkgList, false );
connectFilter( _searchFilterView, _pkgList, false );
+
+ // FIXME
+ // connectFilter( _langList, _pkgList );

if ( _searchFilterView && _pkgList )
{

Modified: branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPackageSelector.h
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPackageSelector.h?rev=54937&r1=54936&r2=54937&view=diff
==============================================================================
--- branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPackageSelector.h
(original)
+++ branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPackageSelector.h Fri Jan
23 13:28:08 2009
@@ -47,6 +47,7 @@
class YQPkgFilterTab;
class YQPkgLangList;
class YQPkgList;
+class YQPkgPackageKitGroupsFilterView;
class YQPkgPatchFilterView;
class YQPkgPatchList;
class YQPkgPatternList;
@@ -302,6 +303,7 @@
YQPkgLangList * _langList;
YQPkgList * _pkgList;
YQPkgPatternList * _patternList;
+ YQPkgPackageKitGroupsFilterView * _packageKitGroupsFilterView;
YQPkgRpmGroupTagsFilterView * _rpmGroupTagsFilterView;
YQPkgSearchFilterView * _searchFilterView;
YQPkgStatusFilterView * _statusFilterView;

Added:
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgPackageKitGroupsFilterView.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgPackageKitGroupsFilterView.cc?rev=54937&view=auto
==============================================================================
---
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgPackageKitGroupsFilterView.cc
(added)
+++
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgPackageKitGroupsFilterView.cc
Fri Jan 23 13:28:08 2009
@@ -0,0 +1,403 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YQPkgPackageKitGroupsFilterView.cc
+
+ Authors: Duncan Mac-Vicar Prett <duncan@xxxxxxx>
+ Stefan Hundhammer <sh@xxxxxxx>
+
+ Textdomain "qt-pkg"
+
+/-*/
+
+
+#define YUILogComponent "qt-pkg"
+#include "YUILog.h"
+
+#include <QApplication>
+
+#include "YQPackageSelector.h"
+#include "zypp/sat/LookupAttr.h"
+
+#include "YQPkgPackageKitGroupsFilterView.h"
+#include "YQi18n.h"
+#include "utf8.h"
+
+
+QString
+translatedText( YPkgGroupEnum group )
+{
+ switch ( group )
+ {
+ case PK_GROUP_ENUM_ACCESSIBILITY: return _( "Accessibility"
);
+ case PK_GROUP_ENUM_ACCESSORIES: return _( "Accessories"
);
+ case PK_GROUP_ENUM_EDUCATION: return _( "Education"
);
+ case PK_GROUP_ENUM_GAMES: return _( "Games"
);
+ case PK_GROUP_ENUM_GRAPHICS: return _( "Graphics"
);
+ case PK_GROUP_ENUM_INTERNET: return _( "Internet"
);
+ case PK_GROUP_ENUM_OFFICE: return _( "Office"
);
+ case PK_GROUP_ENUM_OTHER: return _( "Other"
);
+ case PK_GROUP_ENUM_PROGRAMMING: return _( "Programming"
);
+ case PK_GROUP_ENUM_MULTIMEDIA: return _( "Multimedia"
);
+ case PK_GROUP_ENUM_SYSTEM: return _( "System"
);
+ case PK_GROUP_ENUM_DESKTOP_GNOME: return _( "GNOME Desktop"
);
+ case PK_GROUP_ENUM_DESKTOP_KDE: return _( "KDE Desktop"
);
+ case PK_GROUP_ENUM_DESKTOP_XFCE: return _( "XFCE Desktop"
);
+ case PK_GROUP_ENUM_DESKTOP_OTHER: return _( "Other Desktops"
);
+ case PK_GROUP_ENUM_PUBLISHING: return _( "Publishing"
);
+ case PK_GROUP_ENUM_SERVERS: return _( "Servers"
);
+ case PK_GROUP_ENUM_FONTS: return _( "Fonts"
);
+ case PK_GROUP_ENUM_ADMIN_TOOLS: return _( "Admin Tools"
);
+ case PK_GROUP_ENUM_LEGACY: return _( "Legacy"
);
+ case PK_GROUP_ENUM_LOCALIZATION: return _( "Localization"
);
+ case PK_GROUP_ENUM_VIRTUALIZATION: return _( "Virtualization"
);
+ case PK_GROUP_ENUM_SECURITY: return _( "Security"
);
+ case PK_GROUP_ENUM_POWER_MANAGEMENT: return _( "Power Management"
);
+ case PK_GROUP_ENUM_COMMUNICATION: return _( "Communication"
);
+ case PK_GROUP_ENUM_NETWORK: return _( "Network"
);
+ case PK_GROUP_ENUM_MAPS: return _( "Maps"
);
+ case PK_GROUP_ENUM_REPOS: return _( "Software Sources"
);
+ case PK_GROUP_ENUM_UNKNOWN: return _( "Unknown Group"
);
+
+ case YPKG_GROUP_ALL: return _( "All Packages"
);
+ case YPKG_GROUP_SUGGESTED: return _( "Suggested Packages"
);
+ case YPKG_GROUP_RECOMMENDED: return _( "Recommended
Packages");
+
+ // Intentionally omitting 'default' case so gcc can catch unhandled
enums
+ }
+
+ return _("Unknown Group");
+}
+
+
+string
+groupIcon( YPkgGroupEnum group )
+{
+ switch ( group )
+ {
+ case PK_GROUP_ENUM_ACCESSIBILITY: return( "package_main"
);
+ case PK_GROUP_ENUM_ACCESSORIES: return( "package_applications"
);
+ case PK_GROUP_ENUM_EDUCATION: return( "package_edutainment"
);
+ case PK_GROUP_ENUM_GAMES: return( "package_games"
);
+ case PK_GROUP_ENUM_GRAPHICS: return( "package_graphics"
);
+ case PK_GROUP_ENUM_INTERNET: return( "package_network"
);
+ case PK_GROUP_ENUM_OFFICE: return(
"package_office_addressbook" );
+ case PK_GROUP_ENUM_OTHER: return( "package_main"
);
+ case PK_GROUP_ENUM_PROGRAMMING: return( "package_development"
);
+ case PK_GROUP_ENUM_MULTIMEDIA: return( "package_multimedia"
);
+ case PK_GROUP_ENUM_SYSTEM: return( "yast-system"
);
+ case PK_GROUP_ENUM_DESKTOP_GNOME: return( "pattern-gnome"
);
+ case PK_GROUP_ENUM_DESKTOP_KDE: return( "pattern-kde"
);
+ case PK_GROUP_ENUM_DESKTOP_XFCE: return(
"package_utility_desktop" );
+ case PK_GROUP_ENUM_DESKTOP_OTHER: return(
"package_utility_desktop" );
+ case PK_GROUP_ENUM_PUBLISHING: return( "package_main"
);
+ case PK_GROUP_ENUM_SERVERS: return( "package_editors"
);
+ case PK_GROUP_ENUM_FONTS: return( "package_main"
);
+ case PK_GROUP_ENUM_ADMIN_TOOLS: return( "yast-sysconfig"
);
+ case PK_GROUP_ENUM_LEGACY: return( "package_main"
);
+ case PK_GROUP_ENUM_LOCALIZATION: return( "yast-language"
);
+ case PK_GROUP_ENUM_VIRTUALIZATION: return( "yast-create-new-vm"
);
+ case PK_GROUP_ENUM_SECURITY: return( "yast-security"
);
+ case PK_GROUP_ENUM_POWER_MANAGEMENT: return(
"package_settings_power" );
+ case PK_GROUP_ENUM_COMMUNICATION: return( "yast-modem"
);
+ case PK_GROUP_ENUM_NETWORK: return( "package_network"
);
+ case PK_GROUP_ENUM_MAPS: return( "package_main"
);
+ case PK_GROUP_ENUM_REPOS: return( "package_main"
);
+ case PK_GROUP_ENUM_UNKNOWN: return( "package_main"
);
+
+ case YPKG_GROUP_SUGGESTED: return(
"package_edutainment_languages" );
+ case YPKG_GROUP_RECOMMENDED: return(
"package_edutainment_languages" );
+ case YPKG_GROUP_ALL: return( "package_main"
);
+
+ // Intentionally omitting 'default' case so gcc can catch unhandled
enums
+ }
+
+ return( "" );
+}
+
+
+YPkgGroupEnum
+rpmGroupToPackageKitGroup( const string & rpmGroup )
+{
+ string group = zypp::str::toLower( rpmGroup );
+
+ if ( group.find( "amusements/teaching" ) != string::npos ) return
PK_GROUP_ENUM_EDUCATION;
+ if ( group.find( "amusements" ) != string::npos ) return
PK_GROUP_ENUM_GAMES;
+ if ( group.find( "development" ) != string::npos ) return
PK_GROUP_ENUM_PROGRAMMING;
+ if ( group.find( "hardware" ) != string::npos )
return PK_GROUP_ENUM_SYSTEM;
+ if ( group.find( "archiving" ) != string::npos ) return
PK_GROUP_ENUM_ADMIN_TOOLS;
+ if ( group.find( "clustering" ) != string::npos ) return
PK_GROUP_ENUM_ADMIN_TOOLS;
+ if ( group.find( "system/monitoring" ) != string::npos ) return
PK_GROUP_ENUM_ADMIN_TOOLS;
+ if ( group.find( "databases" ) != string::npos ) return
PK_GROUP_ENUM_ADMIN_TOOLS;
+ if ( group.find( "system/management" ) != string::npos ) return
PK_GROUP_ENUM_ADMIN_TOOLS;
+ if ( group.find( "graphics" ) != string::npos )
return PK_GROUP_ENUM_GRAPHICS;
+ if ( group.find( "multimedia" ) != string::npos ) return
PK_GROUP_ENUM_MULTIMEDIA;
+ if ( group.find( "network" ) != string::npos ) return
PK_GROUP_ENUM_NETWORK;
+ if ( group.find( "office" ) != string::npos ) return
PK_GROUP_ENUM_OFFICE;
+ if ( group.find( "text" ) != string::npos ) return
PK_GROUP_ENUM_OFFICE;
+ if ( group.find( "editors" ) != string::npos ) return
PK_GROUP_ENUM_OFFICE;
+ if ( group.find( "publishing" ) != string::npos ) return
PK_GROUP_ENUM_PUBLISHING;
+ if ( group.find( "security" ) != string::npos )
return PK_GROUP_ENUM_SECURITY;
+ if ( group.find( "telephony" ) != string::npos ) return
PK_GROUP_ENUM_COMMUNICATION;
+ if ( group.find( "gnome" ) != string::npos ) return
PK_GROUP_ENUM_DESKTOP_GNOME;
+ if ( group.find( "kde" ) != string::npos ) return
PK_GROUP_ENUM_DESKTOP_KDE;
+ if ( group.find( "xfce" ) != string::npos ) return
PK_GROUP_ENUM_DESKTOP_XFCE;
+ if ( group.find( "gui/other" ) != string::npos ) return
PK_GROUP_ENUM_DESKTOP_OTHER;
+ if ( group.find( "localization" ) != string::npos ) return
PK_GROUP_ENUM_LOCALIZATION;
+ if ( group.find( "system" ) != string::npos ) return
PK_GROUP_ENUM_SYSTEM;
+ if ( group.find( "scientific" ) != string::npos ) return
PK_GROUP_ENUM_EDUCATION;
+
+ return PK_GROUP_ENUM_UNKNOWN;
+}
+
+
+
+
+YQPkgPackageKitGroupsFilterView::YQPkgPackageKitGroupsFilterView( QWidget *
parent )
+ : QTreeWidget( parent )
+ , _selectedGroup(YPKG_GROUP_ALL)
+{
+ setIconSize(QSize(32,32));
+ setHeaderLabels( QStringList(_( "Package Groups" )) );
+ setRootIsDecorated( false );
+ setSortingEnabled( true );
+ connect( this, SIGNAL( currentItemChanged ( QTreeWidgetItem *,
QTreeWidgetItem * ) ),
+ this, SLOT ( slotSelectionChanged ( QTreeWidgetItem * ) ) );
+ fillGroups();
+
+ selectSomething();
+}
+
+
+YQPkgPackageKitGroupsFilterView::~YQPkgPackageKitGroupsFilterView()
+{
+}
+
+
+void
+YQPkgPackageKitGroupsFilterView::fillGroups()
+{
+ if ( _groupsMap.empty() )
+ {
+ zypp::sat::LookupAttr rpmgroups( zypp::sat::SolvAttr::group );
+ for ( zypp::sat::LookupAttr::iterator it = rpmgroups.begin();
+ it != rpmgroups.end();
+ ++it )
+ {
+ YPkgGroupEnum group;
+ std::map<std::string, YPkgGroupEnum>::const_iterator itg =
_groupsCache.find(it.asString());
+ if ( itg == _groupsCache.end() )
+ {
+ group = rpmGroupToPackageKitGroup( it.asString() );
+ _groupsCache[it.asString()] = group;
+ }
+ else
+ {
+ group = itg->second;
+ }
+
+ //std::cout << it.asString() << std::endl;
+
+ if ( _groupsMap.find(group) == _groupsMap.end() )
+ {
+ _groupsMap[group] = new YQPkgPackageKitGroup( this, group );
+ }
+ }
+
+ _groupsMap[ YPKG_GROUP_ALL ] = new YQPkgPackageKitGroup( this,
YPKG_GROUP_ALL );
+ _groupsMap[ YPKG_GROUP_RECOMMENDED ] = new YQPkgPackageKitGroup( this,
YPKG_GROUP_RECOMMENDED );
+ _groupsMap[ YPKG_GROUP_SUGGESTED ] = new YQPkgPackageKitGroup( this,
YPKG_GROUP_SUGGESTED );
+
+ }
+}
+
+
+void
+YQPkgPackageKitGroupsFilterView::selectSomething()
+{
+// FIXME
+// QTreeWidgetItem * item = children().first();
+//
+// if ( item )
+// setCurrentItem(item);
+}
+
+
+void
+YQPkgPackageKitGroupsFilterView::filterIfVisible()
+{
+ if ( isVisible() )
+ filter();
+}
+
+
+void
+YQPkgPackageKitGroupsFilterView::filter()
+{
+ emit filterStart();
+ // yuiDebug() << "Filtering packages for RPM group \"" <<
selectedRpmGroup() << "\"" << endl;
+
+ if ( selection() )
+ {
+ for ( ZyppPoolIterator it = zyppPkgBegin();
+ it != zyppPkgEnd();
+ ++it )
+ {
+ ZyppSel selectable = *it;
+
+ // Multiple instances of this package may or may not be in the same
+ // 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 group. We don't want multiple list
+ // entries for the same package!
+
+ bool match =
+ check( selectable, tryCastToZyppPkg( selectable->candidateObj()
) ) ||
+ check( selectable, tryCastToZyppPkg( selectable->installedObj()
) );
+
+ // If there is neither an installed nor a candidate package, check
+ // any other instance.
+
+ if ( ! match &&
+ ! selectable->candidateObj() &&
+ ! selectable->installedObj() )
+ check( selectable, tryCastToZyppPkg( selectable->theObj() ) );
+ }
+ }
+
+ emit filterFinished();
+}
+
+
+void
+YQPkgPackageKitGroupsFilterView::slotSelectionChanged( QTreeWidgetItem *
newSelection )
+{
+ YQPkgPackageKitGroup * sel = dynamic_cast<YQPkgPackageKitGroup *>(
newSelection );
+
+ if ( sel )
+ {
+ _selectedGroup = sel->group();
+ // for the list of reccommended packages, we need
+ // to solve first
+ if ( _selectedGroup == YPKG_GROUP_SUGGESTED ||
+ _selectedGroup == YPKG_GROUP_RECOMMENDED )
+ {
+ // set the busy cursor for the solving
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+ zypp::getZYpp()->resolver()->resolvePool();
+ QApplication::restoreOverrideCursor();
+ }
+
+ }
+ else
+ {
+ _selectedGroup = YPKG_GROUP_ALL;
+ }
+
+ filter();
+}
+
+
+bool
+YQPkgPackageKitGroupsFilterView::check( ZyppSel selectable,
+ ZyppPkg pkg )
+{
+ if ( ! pkg || ! selection() )
+ return false;
+
+ if ( selection()->group() == YPKG_GROUP_ALL ) // Special
case: All packages
+ {
+ emit filterMatch( selectable, pkg );
+ return true;
+ }
+
+ YPkgGroupEnum pk_group = rpmGroupToPackageKitGroup( pkg->group() );
+
+ if ( pk_group == selectedGroup() )
+ {
+ emit filterMatch( selectable, pkg );
+ return true;
+ }
+
+ if ( selectable->candidateObj() )
+ {
+ if ( selectedGroup() == YPKG_GROUP_RECOMMENDED &&
+ zypp::PoolItem(pkg).status().isRecommended() )
+ {
+ emit filterMatch( selectable, pkg );
+ return true;
+ }
+ if ( selectedGroup() == YPKG_GROUP_SUGGESTED &&
+ zypp::PoolItem(pkg).status().isSuggested() )
+ {
+ emit filterMatch( selectable, pkg );
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+YQPkgPackageKitGroup *
+YQPkgPackageKitGroupsFilterView::selection() const
+{
+ QTreeWidgetItem * item = currentItem();
+
+ if ( ! item )
+ return 0;
+
+ return dynamic_cast<YQPkgPackageKitGroup *> ( item );
+}
+
+
+
+
+YQPkgPackageKitGroup::YQPkgPackageKitGroup( YQPkgPackageKitGroupsFilterView *
parentFilterView,
+ YPkgGroupEnum group )
+ : QTreeWidgetItem( parentFilterView )
+ , _filterView( parentFilterView )
+ , _group( group )
+{
+ QFont f = font(0);
+ QFontMetrics fm(f);
+ f.setPixelSize( (int) ( fm.height() * 1.1 ) );
+ setFont(0,f);
+
+ string iconName = groupIcon( group );
+ setText( 0, translatedText( group ) );
+ setIcon( 0, QIcon( QString( YQPackageSelector::iconPath( iconName, 32
).c_str() ) ) );
+}
+
+
+YQPkgPackageKitGroup::~YQPkgPackageKitGroup()
+{
+ // NOP
+}
+
+
+bool
+YQPkgPackageKitGroup::operator< ( const QTreeWidgetItem & otherListViewItem )
const
+{
+ const YQPkgPackageKitGroup * otherCategoryItem =
+ dynamic_cast<const YQPkgPackageKitGroup *>(&otherListViewItem);
+
+ if ( otherCategoryItem )
+ return group() > otherCategoryItem->group();
+ else
+ return true;
+}
+
+
+#include "YQPkgPackageKitGroupsFilterView.moc"

Added:
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgPackageKitGroupsFilterView.h
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgPackageKitGroupsFilterView.h?rev=54937&view=auto
==============================================================================
---
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgPackageKitGroupsFilterView.h
(added)
+++
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgPackageKitGroupsFilterView.h
Fri Jan 23 13:28:08 2009
@@ -0,0 +1,203 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YQPkgPackageKitGroupsFilterView.h
+
+ Authors: Duncan Mac-Vicar Prett <duncan@xxxxxxx>
+ Stefan Hundhammer <sh@xxxxxxx>
+
+/-*/
+
+
+#ifndef YQPkgPackageKitGroupsFilterView_h
+#define YQPkgPackageKitGroupsFilterView_h
+
+#include <map>
+#include "YQZypp.h"
+#include "YRpmGroupsTree.h"
+#include <QTreeWidget>
+
+using std::string;
+
+typedef enum
+{
+ //
+ // PackageKit values
+ //
+
+ PK_GROUP_ENUM_ACCESSIBILITY,
+ PK_GROUP_ENUM_ACCESSORIES,
+ PK_GROUP_ENUM_EDUCATION,
+ PK_GROUP_ENUM_GAMES,
+ PK_GROUP_ENUM_GRAPHICS,
+ PK_GROUP_ENUM_INTERNET,
+ PK_GROUP_ENUM_OFFICE,
+ PK_GROUP_ENUM_OTHER,
+ PK_GROUP_ENUM_PROGRAMMING,
+ PK_GROUP_ENUM_MULTIMEDIA,
+ PK_GROUP_ENUM_SYSTEM,
+ PK_GROUP_ENUM_DESKTOP_GNOME,
+ PK_GROUP_ENUM_DESKTOP_KDE,
+ PK_GROUP_ENUM_DESKTOP_XFCE,
+ PK_GROUP_ENUM_DESKTOP_OTHER,
+ PK_GROUP_ENUM_PUBLISHING,
+ PK_GROUP_ENUM_SERVERS,
+ PK_GROUP_ENUM_FONTS,
+ PK_GROUP_ENUM_ADMIN_TOOLS,
+ PK_GROUP_ENUM_LEGACY,
+ PK_GROUP_ENUM_LOCALIZATION,
+ PK_GROUP_ENUM_VIRTUALIZATION,
+ PK_GROUP_ENUM_SECURITY,
+ PK_GROUP_ENUM_POWER_MANAGEMENT,
+ PK_GROUP_ENUM_COMMUNICATION,
+ PK_GROUP_ENUM_NETWORK,
+ PK_GROUP_ENUM_MAPS,
+ PK_GROUP_ENUM_REPOS,
+ PK_GROUP_ENUM_UNKNOWN,
+
+ //
+ // Other values
+ //
+
+ YPKG_GROUP_SUGGESTED,
+ YPKG_GROUP_RECOMMENDED,
+ YPKG_GROUP_ALL,
+} YPkgGroupEnum;
+
+
+class YQPkgPackageKitGroup;
+
+
+/**
+ * Filter view for PackageKit groups. Uses the packages' RPM group tags and
+ * maps them to the corresponding PackageKit group.
+ **/
+class YQPkgPackageKitGroupsFilterView : public QTreeWidget
+{
+ Q_OBJECT
+
+public:
+
+ /**
+ * Constructor
+ **/
+ YQPkgPackageKitGroupsFilterView( QWidget * parent );
+
+ /**
+ * Destructor
+ **/
+ virtual ~YQPkgPackageKitGroupsFilterView();
+
+ /**
+ * Returns the currently selected item or 0 if there is none.
+ **/
+ YQPkgPackageKitGroup * selection() const;
+
+ /**
+ * Check if 'pkg' matches the selected group.
+ * Returns true if there is a match, false otherwise.
+ **/
+ bool check( ZyppSel selectable,
+ ZyppPkg pkg );
+
+ /**
+ * Returns the (untranslated!) currently selected group enum
+ **/
+ YPkgGroupEnum selectedGroup() const { return _selectedGroup; }
+
+public slots:
+
+ /**
+ * Filter according to the view's rules and current selection.
+ * Emits those signals:
+ * filterStart()
+ * filterMatch() for each pkg that matches the filter
+ * filterFinished()
+ **/
+ void filter();
+
+ /**
+ * Same as filter(), but only if this widget is currently visible.
+ **/
+ void filterIfVisible();
+
+ /**
+ * Select a list entry (if there is any).
+ * Usually this will be the first list entry, but don't rely on that - this
+ * might change without notice. Emits signal currentItemChanged().
+ **/
+ void selectSomething();
+
+signals:
+
+ /**
+ * Emitted when the filtering starts. Use this to clear package lists
+ * etc. prior to adding new entries.
+ **/
+ void filterStart();
+
+ /**
+ * Emitted during filtering for each pkg that matches the filter.
+ **/
+ void filterMatch( ZyppSel selectable,
+ ZyppPkg pkg );
+
+ /**
+ * Emitted when filtering is finished.
+ **/
+ void filterFinished();
+
+
+protected slots:
+
+ void slotSelectionChanged( QTreeWidgetItem * newSelection );
+
+
+protected:
+
+ void fillGroups();
+
+ //
+ // Data members
+ //
+
+ YPkgGroupEnum _selectedGroup;
+ std::map<YPkgGroupEnum, YQPkgPackageKitGroup *> _groupsMap;
+
+ // map to cache converted groups
+ std::map<std::string, YPkgGroupEnum> _groupsCache;
+};
+
+
+class YQPkgPackageKitGroup: public QTreeWidgetItem
+{
+public:
+
+ YQPkgPackageKitGroup( YQPkgPackageKitGroupsFilterView * parentFilterView,
+ YPkgGroupEnum group );
+ virtual ~YQPkgPackageKitGroup();
+
+ YQPkgPackageKitGroupsFilterView * filterView() const { return _filterView;
}
+ YPkgGroupEnum group() const { return _group; }
+ virtual bool operator< ( const QTreeWidgetItem & otherListViewItem ) const;
+
+
+private:
+
+ // Data members
+
+ YQPkgPackageKitGroupsFilterView * _filterView;
+ YPkgGroupEnum _group;
+};
+
+
+#endif // ifndef YQPkgPackageKitGroupsFilterView_h

Modified:
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgRpmGroupTagsFilterView.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgRpmGroupTagsFilterView.cc?rev=54937&r1=54936&r2=54937&view=diff
==============================================================================
---
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgRpmGroupTagsFilterView.cc
(original)
+++
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgRpmGroupTagsFilterView.cc
Fri Jan 23 13:28:08 2009
@@ -22,200 +22,89 @@
#define YUILogComponent "qt-pkg"
#include "YUILog.h"

-#include <QApplication>
-
-#include "YQPackageSelector.h"
-#include "zypp/sat/LookupAttr.h"
-
#include "YQPkgRpmGroupTagsFilterView.h"
#include "YQi18n.h"
#include "utf8.h"


-QString
-translatedText( YPkgGroupEnum group )
-{
- switch ( group )
- {
- case PK_GROUP_ENUM_ACCESSIBILITY: return _( "Accessibility"
);
- case PK_GROUP_ENUM_ACCESSORIES: return _( "Accessories"
);
- case PK_GROUP_ENUM_EDUCATION: return _( "Education"
);
- case PK_GROUP_ENUM_GAMES: return _( "Games"
);
- case PK_GROUP_ENUM_GRAPHICS: return _( "Graphics"
);
- case PK_GROUP_ENUM_INTERNET: return _( "Internet"
);
- case PK_GROUP_ENUM_OFFICE: return _( "Office"
);
- case PK_GROUP_ENUM_OTHER: return _( "Other"
);
- case PK_GROUP_ENUM_PROGRAMMING: return _( "Programming"
);
- case PK_GROUP_ENUM_MULTIMEDIA: return _( "Multimedia"
);
- case PK_GROUP_ENUM_SYSTEM: return _( "System"
);
- case PK_GROUP_ENUM_DESKTOP_GNOME: return _( "GNOME Desktop"
);
- case PK_GROUP_ENUM_DESKTOP_KDE: return _( "KDE Desktop"
);
- case PK_GROUP_ENUM_DESKTOP_XFCE: return _( "XFCE Desktop"
);
- case PK_GROUP_ENUM_DESKTOP_OTHER: return _( "Other Desktops"
);
- case PK_GROUP_ENUM_PUBLISHING: return _( "Publishing"
);
- case PK_GROUP_ENUM_SERVERS: return _( "Servers"
);
- case PK_GROUP_ENUM_FONTS: return _( "Fonts"
);
- case PK_GROUP_ENUM_ADMIN_TOOLS: return _( "Admin Tools"
);
- case PK_GROUP_ENUM_LEGACY: return _( "Legacy"
);
- case PK_GROUP_ENUM_LOCALIZATION: return _( "Localization"
);
- case PK_GROUP_ENUM_VIRTUALIZATION: return _( "Virtualization"
);
- case PK_GROUP_ENUM_SECURITY: return _( "Security"
);
- case PK_GROUP_ENUM_POWER_MANAGEMENT: return _( "Power Management"
);
- case PK_GROUP_ENUM_COMMUNICATION: return _( "Communication"
);
- case PK_GROUP_ENUM_NETWORK: return _( "Network"
);
- case PK_GROUP_ENUM_MAPS: return _( "Maps"
);
- case PK_GROUP_ENUM_REPOS: return _( "Software Sources"
);
- case PK_GROUP_ENUM_UNKNOWN: return _( "Unknown Group"
);
-
- case YPKG_GROUP_ALL: return _( "All Packages"
);
- case YPKG_GROUP_SUGGESTED: return _( "Suggested Packages"
);
- case YPKG_GROUP_RECOMMENDED: return _( "Recommended
Packages");

- // Intentionally omitting 'default' case so gcc can catch unhandled
enums
- }
-
- return _("Unknown Group");
-}
+YRpmGroupsTree * YQPkgRpmGroupTagsFilterView::_rpmGroupsTree = 0;


-string
-groupIcon( YPkgGroupEnum group )
+YQPkgRpmGroupTagsFilterView::YQPkgRpmGroupTagsFilterView( QWidget * parent )
+ : QTreeWidget( parent )
{
- switch ( group )
- {
- case PK_GROUP_ENUM_ACCESSIBILITY: return( "package_main"
);
- case PK_GROUP_ENUM_ACCESSORIES: return( "package_applications"
);
- case PK_GROUP_ENUM_EDUCATION: return( "package_edutainment"
);
- case PK_GROUP_ENUM_GAMES: return( "package_games"
);
- case PK_GROUP_ENUM_GRAPHICS: return( "package_graphics"
);
- case PK_GROUP_ENUM_INTERNET: return( "package_network"
);
- case PK_GROUP_ENUM_OFFICE: return(
"package_office_addressbook" );
- case PK_GROUP_ENUM_OTHER: return( "package_main"
);
- case PK_GROUP_ENUM_PROGRAMMING: return( "package_development"
);
- case PK_GROUP_ENUM_MULTIMEDIA: return( "package_multimedia"
);
- case PK_GROUP_ENUM_SYSTEM: return( "yast-system"
);
- case PK_GROUP_ENUM_DESKTOP_GNOME: return( "pattern-gnome"
);
- case PK_GROUP_ENUM_DESKTOP_KDE: return( "pattern-kde"
);
- case PK_GROUP_ENUM_DESKTOP_XFCE: return(
"package_utility_desktop" );
- case PK_GROUP_ENUM_DESKTOP_OTHER: return(
"package_utility_desktop" );
- case PK_GROUP_ENUM_PUBLISHING: return( "package_main"
);
- case PK_GROUP_ENUM_SERVERS: return( "package_editors"
);
- case PK_GROUP_ENUM_FONTS: return( "package_main"
);
- case PK_GROUP_ENUM_ADMIN_TOOLS: return( "yast-sysconfig"
);
- case PK_GROUP_ENUM_LEGACY: return( "package_main"
);
- case PK_GROUP_ENUM_LOCALIZATION: return( "yast-language"
);
- case PK_GROUP_ENUM_VIRTUALIZATION: return( "yast-create-new-vm"
);
- case PK_GROUP_ENUM_SECURITY: return( "yast-security"
);
- case PK_GROUP_ENUM_POWER_MANAGEMENT: return(
"package_settings_power" );
- case PK_GROUP_ENUM_COMMUNICATION: return( "yast-modem"
);
- case PK_GROUP_ENUM_NETWORK: return( "package_network"
);
- case PK_GROUP_ENUM_MAPS: return( "package_main"
);
- case PK_GROUP_ENUM_REPOS: return( "package_main"
);
- case PK_GROUP_ENUM_UNKNOWN: return( "package_main"
);
-
- case YPKG_GROUP_SUGGESTED: return(
"package_edutainment_languages" );
- case YPKG_GROUP_RECOMMENDED: return(
"package_edutainment_languages" );
- case YPKG_GROUP_ALL: return( "package_main"
);
+ setHeaderLabels( QStringList(_( "Package Groups" )) );
+ setRootIsDecorated( true );
+ cloneTree( rpmGroupsTree()->root(), 0 );

- // Intentionally omitting 'default' case so gcc can catch unhandled
enums
- }
+ new YQPkgRpmGroupTag( this, _( "zzz All" ), 0 );
+
+ connect( this, SIGNAL( currentItemChanged ( QTreeWidgetItem *,
QTreeWidgetItem * ) ),
+ this, SLOT ( slotSelectionChanged ( QTreeWidgetItem * ) ) );

- return( "" );
+ selectSomething();
}


-YPkgGroupEnum
-rpmGroupToPackageKitGroup( const string & rpmGroup )
+YQPkgRpmGroupTagsFilterView::~YQPkgRpmGroupTagsFilterView()
{
- string group = zypp::str::toLower( rpmGroup );
+}

- if ( group.find( "amusements/teaching" ) != string::npos ) return
PK_GROUP_ENUM_EDUCATION;
- if ( group.find( "amusements" ) != string::npos ) return
PK_GROUP_ENUM_GAMES;
- if ( group.find( "development" ) != string::npos ) return
PK_GROUP_ENUM_PROGRAMMING;
- if ( group.find( "hardware" ) != string::npos )
return PK_GROUP_ENUM_SYSTEM;
- if ( group.find( "archiving" ) != string::npos ) return
PK_GROUP_ENUM_ADMIN_TOOLS;
- if ( group.find( "clustering" ) != string::npos ) return
PK_GROUP_ENUM_ADMIN_TOOLS;
- if ( group.find( "system/monitoring" ) != string::npos ) return
PK_GROUP_ENUM_ADMIN_TOOLS;
- if ( group.find( "databases" ) != string::npos ) return
PK_GROUP_ENUM_ADMIN_TOOLS;
- if ( group.find( "system/management" ) != string::npos ) return
PK_GROUP_ENUM_ADMIN_TOOLS;
- if ( group.find( "graphics" ) != string::npos )
return PK_GROUP_ENUM_GRAPHICS;
- if ( group.find( "multimedia" ) != string::npos ) return
PK_GROUP_ENUM_MULTIMEDIA;
- if ( group.find( "network" ) != string::npos ) return
PK_GROUP_ENUM_NETWORK;
- if ( group.find( "office" ) != string::npos ) return
PK_GROUP_ENUM_OFFICE;
- if ( group.find( "text" ) != string::npos ) return
PK_GROUP_ENUM_OFFICE;
- if ( group.find( "editors" ) != string::npos ) return
PK_GROUP_ENUM_OFFICE;
- if ( group.find( "publishing" ) != string::npos ) return
PK_GROUP_ENUM_PUBLISHING;
- if ( group.find( "security" ) != string::npos )
return PK_GROUP_ENUM_SECURITY;
- if ( group.find( "telephony" ) != string::npos ) return
PK_GROUP_ENUM_COMMUNICATION;
- if ( group.find( "gnome" ) != string::npos ) return
PK_GROUP_ENUM_DESKTOP_GNOME;
- if ( group.find( "kde" ) != string::npos ) return
PK_GROUP_ENUM_DESKTOP_KDE;
- if ( group.find( "xfce" ) != string::npos ) return
PK_GROUP_ENUM_DESKTOP_XFCE;
- if ( group.find( "gui/other" ) != string::npos ) return
PK_GROUP_ENUM_DESKTOP_OTHER;
- if ( group.find( "localization" ) != string::npos ) return
PK_GROUP_ENUM_LOCALIZATION;
- if ( group.find( "system" ) != string::npos ) return
PK_GROUP_ENUM_SYSTEM;
- if ( group.find( "scientific" ) != string::npos ) return
PK_GROUP_ENUM_EDUCATION;

- return PK_GROUP_ENUM_UNKNOWN;
-}
+YRpmGroupsTree *
+YQPkgRpmGroupTagsFilterView::rpmGroupsTree()
+{
+ if ( ! _rpmGroupsTree )
+ {
+ _rpmGroupsTree = new YRpmGroupsTree();
+ Q_CHECK_PTR( _rpmGroupsTree );

+ fillRpmGroupsTree();
+ }

+ return _rpmGroupsTree;
+}


-YQPkgRpmGroupTagsFilterView::YQPkgRpmGroupTagsFilterView( QWidget * parent )
- : QTreeWidget( parent )
- , _selectedGroup(YPKG_GROUP_ALL)
+void
+YQPkgRpmGroupTagsFilterView::fillRpmGroupsTree()
{
- setIconSize(QSize(32,32));
- setHeaderLabels( QStringList(_( "Package Groups" )) );
- setRootIsDecorated( false );
- setSortingEnabled( true );
- connect( this, SIGNAL( currentItemChanged ( QTreeWidgetItem *,
QTreeWidgetItem * ) ),
- this, SLOT ( slotSelectionChanged ( QTreeWidgetItem * ) ) );
- fillGroups();
+ yuiDebug() << "Filling RPM groups tree" << endl;

- selectSomething();
-}
+ for ( ZyppPoolIterator it = zyppPkgBegin();
+ it != zyppPkgEnd();
+ ++it )
+ {
+ ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() );

+ if ( zyppPkg )
+ rpmGroupsTree()->addRpmGroup( zyppPkg->group() );
+ }

-YQPkgRpmGroupTagsFilterView::~YQPkgRpmGroupTagsFilterView()
-{
+ yuiDebug() << "Filling RPM groups tree done" << endl;
}


void
-YQPkgRpmGroupTagsFilterView::fillGroups()
+YQPkgRpmGroupTagsFilterView::cloneTree( YStringTreeItem * parentRpmGroup,
+ YQPkgRpmGroupTag * parentClone )
{
- if ( _groupsMap.empty() )
- {
- zypp::sat::LookupAttr rpmgroups( zypp::sat::SolvAttr::group );
- for ( zypp::sat::LookupAttr::iterator it = rpmgroups.begin();
- it != rpmgroups.end();
- ++it )
- {
- YPkgGroupEnum group;
- std::map<std::string, YPkgGroupEnum>::const_iterator itg =
_groupsCache.find(it.asString());
- if ( itg == _groupsCache.end() )
- {
- group = rpmGroupToPackageKitGroup( it.asString() );
- _groupsCache[it.asString()] = group;
- }
- else
- {
- group = itg->second;
- }
-
- //std::cout << it.asString() << std::endl;
-
- if ( _groupsMap.find(group) == _groupsMap.end() )
- {
- _groupsMap[group] = new YQPkgRpmGroupTag( this, group );
- }
- }
-
- _groupsMap[ YPKG_GROUP_ALL ] = new YQPkgRpmGroupTag( this,
YPKG_GROUP_ALL );
- _groupsMap[ YPKG_GROUP_RECOMMENDED ] = new YQPkgRpmGroupTag( this,
YPKG_GROUP_RECOMMENDED );
- _groupsMap[ YPKG_GROUP_SUGGESTED ] = new YQPkgRpmGroupTag( this,
YPKG_GROUP_SUGGESTED );
+ YStringTreeItem * child = parentRpmGroup->firstChild();
+ YQPkgRpmGroupTag * clone;

+ while ( child )
+ {
+ if ( parentClone )
+ clone = new YQPkgRpmGroupTag( this, parentClone, child );
+ else
+ clone = new YQPkgRpmGroupTag( this, child );
+
+ Q_CHECK_PTR( clone );
+ //FIXME clone->setExpanded( clone->depth() < 1 );
+ clone->setExpanded( true );
+ cloneTree( child, clone );
+ child = child->next();
}
}

@@ -225,9 +114,9 @@
{
// FIXME
// QTreeWidgetItem * item = children().first();
-//
+//
// if ( item )
-// setCurrentItem(item);
+// setCurrentItem(item);
}


@@ -244,7 +133,7 @@
{
emit filterStart();
// yuiDebug() << "Filtering packages for RPM group \"" <<
selectedRpmGroup() << "\"" << endl;
-
+
if ( selection() )
{
for ( ZyppPoolIterator it = zyppPkgBegin();
@@ -269,7 +158,7 @@
// any other instance.

if ( ! match &&
- ! selectable->candidateObj() &&
+ ! selectable->candidateObj() &&
! selectable->installedObj() )
check( selectable, tryCastToZyppPkg( selectable->theObj() ) );
}
@@ -286,22 +175,14 @@

if ( sel )
{
- _selectedGroup = sel->group();
- // for the list of reccommended packages, we need
- // to solve first
- if ( _selectedGroup == YPKG_GROUP_SUGGESTED ||
- _selectedGroup == YPKG_GROUP_RECOMMENDED )
- {
- // set the busy cursor for the solving
- QApplication::setOverrideCursor(Qt::WaitCursor);
- zypp::getZYpp()->resolver()->resolvePool();
- QApplication::restoreOverrideCursor();
- }
-
+ if ( sel->rpmGroup() )
+ _selectedRpmGroup = rpmGroupsTree()->rpmGroup( sel->rpmGroup() );
+ else
+ _selectedRpmGroup = "*"; // "zzz_All"
}
else
{
- _selectedGroup = YPKG_GROUP_ALL;
+ _selectedRpmGroup = "";
}

filter();
@@ -309,42 +190,28 @@


bool
-YQPkgRpmGroupTagsFilterView::check( ZyppSel selectable,
- ZyppPkg pkg )
+YQPkgRpmGroupTagsFilterView::check( ZyppSel selectable,
+ ZyppPkg pkg )
{
if ( ! pkg || ! selection() )
return false;

- if ( selection()->group() == YPKG_GROUP_ALL ) // Special
case: All packages
+ if ( selection()->rpmGroup() == 0 ) // Special case: All
packages
{
emit filterMatch( selectable, pkg );
return true;
}

- YPkgGroupEnum groupn = rpmGroupToPackageKitGroup( pkg->group() );
-
- if ( groupn == selectedGroup() )
+ if ( selectedRpmGroup().empty() )
+ return false;
+
+ if ( pkg->group() == selectedRpmGroup() || // full match?
+ pkg->group().find( selectedRpmGroup() + "/" ) == 0 ) // starts with
selected?
{
emit filterMatch( selectable, pkg );
return true;
}

- if ( selectable->candidateObj() )
- {
- if ( selectedGroup() == YPKG_GROUP_RECOMMENDED &&
- zypp::PoolItem(pkg).status().isRecommended() )
- {
- emit filterMatch( selectable, pkg );
- return true;
- }
- if ( selectedGroup() == YPKG_GROUP_SUGGESTED &&
- zypp::PoolItem(pkg).status().isSuggested() )
- {
- emit filterMatch( selectable, pkg );
- return true;
- }
- }
-
return false;
}

@@ -363,40 +230,45 @@



-YQPkgRpmGroupTag::YQPkgRpmGroupTag( YQPkgRpmGroupTagsFilterView *
parentFilterView,
- YPkgGroupEnum group )
+
+
+YQPkgRpmGroupTag::YQPkgRpmGroupTag( YQPkgRpmGroupTagsFilterView *
parentFilterView,
+ YStringTreeItem *
rpmGroup )
: QTreeWidgetItem( parentFilterView )
, _filterView( parentFilterView )
- , _group( group )
+ , _rpmGroup( rpmGroup )
{
- QFont f = font(0);
- QFontMetrics fm(f);
- f.setPixelSize( (int) ( fm.height() * 1.1 ) );
- setFont(0,f);
-
- string iconName = groupIcon( group );
- setText( 0, translatedText( group ) );
- setIcon( 0, QIcon( QString( YQPackageSelector::iconPath( iconName, 32
).c_str() ) ) );
+ setText( 0, fromUTF8( _rpmGroup->value().translation() ) );
}


-YQPkgRpmGroupTag::~YQPkgRpmGroupTag()
+YQPkgRpmGroupTag::YQPkgRpmGroupTag( YQPkgRpmGroupTagsFilterView *
parentFilterView,
+ YQPkgRpmGroupTag *
parentGroupTag,
+ YStringTreeItem *
rpmGroup )
+ : QTreeWidgetItem( parentGroupTag )
+ , _filterView( parentFilterView )
+ , _rpmGroup( rpmGroup )
{
- // NOP
+ setText( 0, fromUTF8( _rpmGroup->value().translation() ) );
}


-bool
-YQPkgRpmGroupTag::operator< ( const QTreeWidgetItem & otherListViewItem ) const
+YQPkgRpmGroupTag::YQPkgRpmGroupTag( YQPkgRpmGroupTagsFilterView *
parentFilterView,
+ const QString &
rpmGroupName,
+ YStringTreeItem *
rpmGroup )
+ : QTreeWidgetItem( parentFilterView )
+ , _filterView( parentFilterView )
+ , _rpmGroup( rpmGroup )
{
- const YQPkgRpmGroupTag * otherCategoryItem =
- dynamic_cast<const YQPkgRpmGroupTag *>(&otherListViewItem);
+ setText( 0, rpmGroupName );
+}

- if ( otherCategoryItem )
- return group() > otherCategoryItem->group();
- else
- return true;
+
+YQPkgRpmGroupTag::~YQPkgRpmGroupTag()
+{
+ // NOP
}


+
#include "YQPkgRpmGroupTagsFilterView.moc"

Modified:
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgRpmGroupTagsFilterView.h
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgRpmGroupTagsFilterView.h?rev=54937&r1=54936&r2=54937&view=diff
==============================================================================
---
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgRpmGroupTagsFilterView.h
(original)
+++
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgRpmGroupTagsFilterView.h
Fri Jan 23 13:28:08 2009
@@ -20,57 +20,12 @@
#ifndef YQPkgRpmGroupTagsFilterView_h
#define YQPkgRpmGroupTagsFilterView_h

-#include <map>
#include "YQZypp.h"
-#include "YRpmGroupsTree.h"
#include <QTreeWidget>
+#include <YRpmGroupsTree.h>

-using std::string;
-
-typedef enum
-{
- //
- // PackageKit values
- //
-
- PK_GROUP_ENUM_ACCESSIBILITY,
- PK_GROUP_ENUM_ACCESSORIES,
- PK_GROUP_ENUM_EDUCATION,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_GRAPHICS,
- PK_GROUP_ENUM_INTERNET,
- PK_GROUP_ENUM_OFFICE,
- PK_GROUP_ENUM_OTHER,
- PK_GROUP_ENUM_PROGRAMMING,
- PK_GROUP_ENUM_MULTIMEDIA,
- PK_GROUP_ENUM_SYSTEM,
- PK_GROUP_ENUM_DESKTOP_GNOME,
- PK_GROUP_ENUM_DESKTOP_KDE,
- PK_GROUP_ENUM_DESKTOP_XFCE,
- PK_GROUP_ENUM_DESKTOP_OTHER,
- PK_GROUP_ENUM_PUBLISHING,
- PK_GROUP_ENUM_SERVERS,
- PK_GROUP_ENUM_FONTS,
- PK_GROUP_ENUM_ADMIN_TOOLS,
- PK_GROUP_ENUM_LEGACY,
- PK_GROUP_ENUM_LOCALIZATION,
- PK_GROUP_ENUM_VIRTUALIZATION,
- PK_GROUP_ENUM_SECURITY,
- PK_GROUP_ENUM_POWER_MANAGEMENT,
- PK_GROUP_ENUM_COMMUNICATION,
- PK_GROUP_ENUM_NETWORK,
- PK_GROUP_ENUM_MAPS,
- PK_GROUP_ENUM_REPOS,
- PK_GROUP_ENUM_UNKNOWN,

- //
- // Other values
- //
-
- YPKG_GROUP_SUGGESTED,
- YPKG_GROUP_RECOMMENDED,
- YPKG_GROUP_ALL,
-} YPkgGroupEnum;
+using std::string;

class YQPkgRpmGroupTag;

@@ -109,9 +64,11 @@
ZyppPkg pkg );

/**
- * Returns the (untranslated!) currently selected group enum
+ * Returns the (untranslated!) currently selected RPM group as string.
+ * Special case: "*" is returned if "zzz_All" is selected.
**/
- YPkgGroupEnum selectedGroup() const { return _selectedGroup; }
+ const string & selectedRpmGroup() const { return _selectedRpmGroup; }
+

public slots:

@@ -136,6 +93,13 @@
**/
void selectSomething();

+ /**
+ * Returns the internal RPM groups tree and fills it
+ * if it doesn't exist yet.
+ **/
+ static YRpmGroupsTree * rpmGroupsTree();
+
+
signals:

/**
@@ -163,25 +127,58 @@
**/
void slotSelectionChanged( QTreeWidgetItem * newSelection );

+
protected:

- void fillGroups();
+ /**
+ * Fill the internal RPM groups tree with RPM groups of all packages
+ * currently in the pool
+ **/
+ static void fillRpmGroupsTree();
+
+ /**
+ * Recursively clone the RPM group tag tree for the QListView widget:
+ * Make a deep copy of the tree starting at 'parentRpmGroup' and
+ * 'parentClone'.
+ **/
+ void cloneTree( YStringTreeItem * parentRpmGroup,
+ YQPkgRpmGroupTag * parentClone = 0 );
+
//
// Data members
//

- YPkgGroupEnum _selectedGroup;
- std::map<YPkgGroupEnum, YQPkgRpmGroupTag*> _groupsMap;
- // map to cache converted groups
- std::map<std::string, YPkgGroupEnum> _groupsCache;
+ string _selectedRpmGroup;
+
+ static YRpmGroupsTree * _rpmGroupsTree;
};

+
+
class YQPkgRpmGroupTag: public QTreeWidgetItem
{
public:

+ /**
+ * Constructor for toplevel RPM group tags
+ **/
+ YQPkgRpmGroupTag( YQPkgRpmGroupTagsFilterView * parentFilterView,
+ YStringTreeItem * rpmGroup );
+
+ /**
+ * Constructor for RPM group tags that have a parent
+ **/
+ YQPkgRpmGroupTag( YQPkgRpmGroupTagsFilterView * parentFilterView,
+ YQPkgRpmGroupTag * parentGroupTag,
+ YStringTreeItem * rpmGroup );
+
+ /**
+ * Constructor for toplevel RPM group tags via STL string
+ * ( for special cases like "zzz All" )
+ **/
YQPkgRpmGroupTag( YQPkgRpmGroupTagsFilterView * parentFilterView,
- YPkgGroupEnum group );
+ const QString & rpmGroupName,
+ YStringTreeItem * rpmGroup );

/**
* Destructor
@@ -194,15 +191,18 @@
**/
YQPkgRpmGroupTagsFilterView * filterView() const { return _filterView; }

- YPkgGroupEnum group() const { return _group; }
+ /**
+ * Returns the original tree item
+ **/
+ const YStringTreeItem * rpmGroup() const { return _rpmGroup; }
+

- virtual bool operator< ( const QTreeWidgetItem & otherListViewItem ) const;
private:

// Data members

YQPkgRpmGroupTagsFilterView * _filterView;
- YPkgGroupEnum _group;
+ YStringTreeItem * _rpmGroup;
};



--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages