[yast-commit] r57292 - in /branches/tmp/tgoettlicher/yast2cc_rewrite/src: yqdesktopfilesmodel.cpp yqdesktopfilesmodel.h yqmodulegroupsmodel.cpp yqmodulegroupsmodel.h

Author: kmachalkova Date: Thu May 21 17:16:34 2009 New Revision: 57292 URL: http://svn.opensuse.org/viewcvs/yast?rev=57292&view=rev Log: Added personal(izable) items into group view + render headlines in bold Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqdesktopfilesmodel.cpp branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqdesktopfilesmodel.h branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqdesktopfilesmodel.cpp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewri... ============================================================================== --- branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqdesktopfilesmodel.cpp (original) +++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqdesktopfilesmodel.cpp Thu May 21 17:16:34 2009 @@ -207,7 +207,6 @@ else qSort(d->desktop_files.begin(), d->desktop_files.end(), qGreater<QString>()); emit layoutChanged(); - qDebug() << "sorting" << endl; return; } @@ -281,11 +280,18 @@ } } -void YQDesktopFilesModel::addPropertyToDesktopFile( QString &fname, QString &key, QString &value) +void YQDesktopFilesModel::addPropertyToDesktopFile( QString &fname, const QString &key, QString &value) { if (d->cache.find( fname ) != d->cache.end()) { d->cache[ fname ].insert( key, value ); } + else + { + PropertyMap pm; + pm[key] = value; + + d->cache[ fname ] = pm; + } } #include "yqdesktopfilesmodel.moc" Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqdesktopfilesmodel.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewri... ============================================================================== --- branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqdesktopfilesmodel.h (original) +++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqdesktopfilesmodel.h Thu May 21 17:16:34 2009 @@ -86,7 +86,7 @@ void addDesktopFile(QString &fname); void addDesktopFiles( QStringList &flist); - void addPropertyToDesktopFile( QString &fname, QString &key, QString &value ); + void addPropertyToDesktopFile( QString &fname, const QString &key, QString &value ); protected: void readDesktopFilesDirectories(); Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewri... ============================================================================== --- branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp (original) +++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp Thu May 21 17:16:34 2009 @@ -10,6 +10,8 @@ \---------------------------------------------------------------------*/ #include <QDebug> +#include <QFont> +#include <QFontMetrics> #include <QSettings> #include <QDir> #include <QIcon> @@ -33,6 +35,7 @@ addIconPath("/usr/share/YaST2/theme/current/icons/32x32/apps"); addIconPath("/usr/share/icons/hicolor/32x32/apps"); reindex(); + addPersonalStuff(); } YQModuleGroupsModel::~YQModuleGroupsModel() @@ -61,6 +64,31 @@ return skey; } +void YQModuleGroupsModel::addPersonalStuff() +{ + QList < QPair <QString, QString> > fake; + + fake << QPair<QString, QString> ( "Personal.desktop", "Personal") + << QPair<QString, QString> ( "Favourites.desktop", "Favourites") + << QPair<QString, QString> ( "Recent.desktop", "Recently Used") + << QPair<QString, QString> ( "Modules.desktop", "Modules"); + + QPair <QString, QString> p; + + foreach( p, fake ) + { + addDesktopFile( p.first ); + addPropertyToDesktopFile( p.first, "Name", p.second ); + addPropertyToDesktopFile( p.first, "X-SuSE-YaST-Group", p.second ); + } + + typeMap["Personal"] = Headline; + typeMap["Modules"] = Headline; + typeMap["Favourites"] = Special; + typeMap["Recently Used"] = Special; + +} + void YQModuleGroupsModel::reindex() { // pairs, because sort keys don't have to be unique :( @@ -78,17 +106,33 @@ d->desktop_files.clear(); QPair<int,QString> p; - foreach( p , sortKeys ) + foreach( p, sortKeys ) { d->desktop_files << p.second; } } - QVariant YQModuleGroupsModel::data( const QModelIndex &index, int role ) const { - return YQDesktopFilesModel::data(index, role); + if (role == Qt::FontRole ) + { + QString name = propertyValue( index, "Name" ).toString(); + QFont f; + + if( typeMap[name] == Headline) + { + f.setBold(true); + QFontMetrics fm(f); + f.setPixelSize( (int) (fm.height() * 1.05) ); + QVariant myData = QVariant(f); + return myData; + } + else + return QVariant(); + } + else + return YQDesktopFilesModel::data(index, role); } #include "yqmodulegroupsmodel.moc" Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewri... ============================================================================== --- branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h (original) +++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h Thu May 21 17:16:34 2009 @@ -27,6 +27,13 @@ Q_OBJECT public: + enum Type + { + Regular, + Headline, + Special + }; + YQModuleGroupsModel( QObject * parent = 0 ); ~YQModuleGroupsModel(); @@ -48,7 +55,10 @@ QString groupId( const QModelIndex &idx ) const; private: + QMap <QString, Type> typeMap; + void reindex(); + void addPersonalStuff(); }; #endif -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
kmachalkova@svn.opensuse.org