Author: kmachalkova
Date: Mon Jun 1 16:53:21 2009
New Revision: 57389
URL: http://svn.opensuse.org/viewcvs/yast?rev=57389&view=rev
Log:
Use "Name" as secondary sorting key (for consistency),
not .desktop file path
Modified:
branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp
branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h
Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp?rev=57389&r1=57388&r2=57389&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp (original)
+++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp Mon Jun 1 16:53:21 2009
@@ -55,15 +55,18 @@
return groupid;
}
-
-int YQModuleGroupsModel::sortKeyForGroup ( QString &fname )
+QVariant YQModuleGroupsModel::valueFromFile ( QString &fname, int key )
{
int pos = d->desktop_files.indexOf( fname );
- QModelIndex idx = index( pos, SortKey );
- int skey = data( idx, Qt::UserRole ).toInt();
- return skey;
-}
+ if ( pos == -1 )
+ return QVariant();
+
+ QModelIndex idx = index( pos, key );
+ return data( idx, Qt::UserRole);
+
+}
+
void YQModuleGroupsModel::addPersonalStuff()
{
QList < QPair > fake;
@@ -93,13 +96,17 @@
{
// pairs, because sort keys don't have to be unique :(
QList< QPair< int, QString> > sortKeys;
+ QMap < QString, QString > groupNames;
QStringListIterator it( d->desktop_files );
while (it.hasNext())
{
QString dfile(it.next());
- sortKeys.append( qMakePair( sortKeyForGroup(dfile), dfile) );
+ int sortKey = valueFromFile( dfile, YQDesktopFilesModel::SortKey).toInt();
+ QString name = valueFromFile( dfile, YQDesktopFilesModel::Name).toString();
+ sortKeys.append( qMakePair( sortKey, name) );
+ groupNames.insert( name, dfile );
}
qSort(sortKeys.begin(), sortKeys.end(), paircmp);
@@ -108,7 +115,7 @@
QPair p;
foreach( p, sortKeys )
{
- d->desktop_files << p.second;
+ d->desktop_files << groupNames[p.second];
}
}
Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h?rev=57389&r1=57388&r2=57389&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h (original)
+++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h Mon Jun 1 16:53:21 2009
@@ -47,7 +47,7 @@
*/
QModelIndex indexForGroupId( const QString &groupid ) const;
- int sortKeyForGroup( QString &fname );
+ QVariant valueFromFile( QString &fname, int key );
/**
* Returns the group id for a given group
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org