Mailinglist Archive: yast-commit (883 mails)

< Previous Next >
[yast-commit] r57838 - in /trunk/control-center/src: yqdesktopfilesmodel.cpp yqdesktopfilesmodel.h
  • From: kmachalkova@xxxxxxxxxxxxxxxx
  • Date: Thu, 02 Jul 2009 10:12:22 -0000
  • Message-id: <E1MMJHC-0007G9-5z@xxxxxxxxxxxxxxxx>
Author: kmachalkova
Date: Thu Jul 2 12:12:21 2009
New Revision: 57838

URL: http://svn.opensuse.org/viewcvs/yast?rev=57838&view=rev
Log:
Helper function (to search icon dirs for given
icon name)

Modified:
trunk/control-center/src/yqdesktopfilesmodel.cpp
trunk/control-center/src/yqdesktopfilesmodel.h

Modified: trunk/control-center/src/yqdesktopfilesmodel.cpp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/control-center/src/yqdesktopfilesmodel.cpp?rev=57838&r1=57837&r2=57838&view=diff
==============================================================================
--- trunk/control-center/src/yqdesktopfilesmodel.cpp (original)
+++ trunk/control-center/src/yqdesktopfilesmodel.cpp Thu Jul 2 12:12:21 2009
@@ -239,8 +239,26 @@
else
return msgstr;

-}
+}
+
+QVariant YQDesktopFilesModel::findIcon( QString &icon ) const
+{
+ QRegExp extension( "\\.(png|jpg)$", Qt::CaseInsensitive );
+ if ( icon.indexOf( extension ) < 0 ) // no .png or .jpg extension?
+ icon += ".png"; // assume .png
+ QStringListIterator it(d->icon_dirs);
+ while (it.hasNext())
+ {
+ QString icondir(it.next());
+ if ( QFile::exists(icondir + "/" + icon) )
+ {
+ return QIcon(icondir + "/" + icon);
+ }
+ }
+ return QVariant();

+}
+
void YQDesktopFilesModel::sort( int, Qt::SortOrder order )
{
emit layoutAboutToBeChanged();
@@ -264,19 +282,7 @@
else if ( role == Qt::DecorationRole )
{
QString icon = propertyValue( index, "Icon" ).toString();
- QRegExp extension( "\\.(png|jpg)$", Qt::CaseInsensitive );
- if ( icon.indexOf( extension ) < 0 ) // no .png or .jpg extension?
- icon += ".png"; // assume .png
- QStringListIterator it(d->icon_dirs);
- while (it.hasNext())
- {
- QString icondir(it.next());
- if ( QFile::exists(icondir + "/" + icon) )
- {
- return QIcon(icondir + "/" + icon);
- }
- }
- return QVariant();
+ return findIcon( icon );
}
else if ( role == Qt::UserRole )
{
@@ -343,4 +349,6 @@
d->cache[ fname ] = pm;
}
}
+
+
#include "yqdesktopfilesmodel.moc"

Modified: trunk/control-center/src/yqdesktopfilesmodel.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/control-center/src/yqdesktopfilesmodel.h?rev=57838&r1=57837&r2=57838&view=diff
==============================================================================
--- trunk/control-center/src/yqdesktopfilesmodel.h (original)
+++ trunk/control-center/src/yqdesktopfilesmodel.h Thu Jul 2 12:12:21 2009
@@ -82,6 +82,7 @@
*/
QVariant propertyValue( const QModelIndex &index, const QString &key )
const;
QVariant translatedPropertyValue( const QModelIndex &index, const QString
&key ) const;
+ QVariant findIcon ( QString &icon ) const;

virtual QVariant data( const QModelIndex &index, int role =
Qt::DisplayRole ) const;


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

< Previous Next >
This Thread
  • No further messages