Author: tgoettlicher
Date: Wed Feb 4 14:27:52 2009
New Revision: 55241
URL: http://svn.opensuse.org/viewcvs/yast?rev=55241&view=rev
Log:
- Added application icons to description view
- Limited file list to 500 entries
- V 2.18.3
Modified:
trunk/qt-pkg/VERSION.cmake
trunk/qt-pkg/package/yast2-qt-pkg.changes
trunk/qt-pkg/src/YQPkgDescriptionView.cc
trunk/qt-pkg/src/YQPkgDescriptionView.h
trunk/qt-pkg/src/YQPkgFileListView.cc
Modified: trunk/qt-pkg/VERSION.cmake
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/VERSION.cmake?rev=55241&r1=55240&r2=55241&view=diff
==============================================================================
--- trunk/qt-pkg/VERSION.cmake (original)
+++ trunk/qt-pkg/VERSION.cmake Wed Feb 4 14:27:52 2009
@@ -1,3 +1,3 @@
SET(VERSION_MAJOR "2")
SET(VERSION_MINOR "18")
-SET(VERSION_PATCH "2")
+SET(VERSION_PATCH "3")
Modified: trunk/qt-pkg/package/yast2-qt-pkg.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/package/yast2-qt-pkg.changes?rev=55241&r1=55240&r2=55241&view=diff
==============================================================================
--- trunk/qt-pkg/package/yast2-qt-pkg.changes (original)
+++ trunk/qt-pkg/package/yast2-qt-pkg.changes Wed Feb 4 14:27:52 2009
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Wed Feb 4 14:13:15 CET 2009 - tgoettlicher@suse.de
+
+- Added application icons to description view
+- Limited file list to 500 entries
+- V 2.18.3
+
+-------------------------------------------------------------------
Wed Feb 4 13:54:08 CET 2009 - sh@suse.de
- Added tab context menu (move left, move right, close)
Modified: trunk/qt-pkg/src/YQPkgDescriptionView.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgDescriptionView.cc?rev=55241&r1=55240&r2=55241&view=diff
==============================================================================
--- trunk/qt-pkg/src/YQPkgDescriptionView.cc (original)
+++ trunk/qt-pkg/src/YQPkgDescriptionView.cc Wed Feb 4 14:27:52 2009
@@ -21,13 +21,28 @@
#define YUILogComponent "qt-pkg"
#include "YUILog.h"
#include <QRegExp>
+#include <QFile>
+#include <QFileInfo>
#include <QList>
+#include <QSettings>
#include "zypp/VendorSupportOptions.h"
#include "YQPkgDescriptionView.h"
#include "YQPkgDescriptionDialog.h"
#include "YQi18n.h"
#include "utf8.h"
+#define DESKTOP_TRANSLATIONS "desktop_translations"
+#define DESKTOPFILEDIR "\\/share\\/applications\\/.*\\.desktop$" // RegExp
+#define ICONSIZE "32x32"
+#define ICONPATH "/usr/share/icons/locolor/"ICONSIZE"/apps/" \
+ << "/usr/share/icons/hicolor/"ICONSIZE"/apps/" \
+ << "/usr/share/icons/oxygen/"ICONSIZE"/apps/" \
+ << "/usr/share/icons/Tango/"ICONSIZE"/apps/" \
+ << "/usr/share/icons/gnome/"ICONSIZE"/apps/" \
+ << "/opt/kde3/share/icons/hicolor/"ICONSIZE"/apps/";
+
+
+
using std::list;
using std::string;
using namespace zypp;
@@ -36,6 +51,7 @@
: YQPkgGenericDetailsView( parent )
{
//FIXME setMimeSourceFactory( 0 );
+ initLang();
}
@@ -95,6 +111,12 @@
html_text += "</p>";
}
+ // show application names and icons from desktop files if available
+ ZyppPkg installed = tryCastToZyppPkg( selectable->installedObj() );
+ if ( installed )
+ {
+ html_text += applicationIconList( installed->filenames() );
+ }
html_text += htmlEnd();
setHtml( html_text );
@@ -170,4 +192,125 @@
}
+QString
+YQPkgDescriptionView::applicationIconList( const list<string> & fileList ) const
+{
+ QString html;
+ QMap desktopEntries;
+
+ QStringList desktopFiles = findDesktopFiles( fileList );
+
+ if ( desktopFiles.size() == 0 )
+ return QString();
+
+ // headline for a list of application icons that belong to a selected package
+ html += _("This package contains: ");
+ html += "<table border='0'>";
+
+ for ( int i = 0; i < desktopFiles.size(); ++i )
+ {
+ desktopEntries = readDesktopFile( desktopFiles[i] );
+
+ html += "<tr><td valign='middle' align='center'>";
+ html += QString( "" );
+ html += "</td><td valign='middle' align='left'>";
+ html += "<b>" + desktopEntries["Name"] + "</b>";
+ html += "</td></tr>";
+ }
+
+ html += "</table>";
+
+ return "<p>" + html + "</p>";
+}
+
+
+QString
+YQPkgDescriptionView::findDesktopIcon ( const QString& iconName ) const
+{
+ QStringList path;
+ path << ICONPATH;
+
+ for ( int i=0; i < path.size(); ++i )
+ {
+ QString fullName = path[i] + iconName + ".png";
+ QFile file(fullName);
+ if ( file.exists() )
+ return fullName;
+ }
+
+ return QString();
+}
+
+
+QMap
+YQPkgDescriptionView::readDesktopFile( const QString & fileName ) const
+{
+ QMap desktopEntries;
+ QString name, genericName;
+
+ QSettings file( fileName, QSettings::IniFormat );
+ file.beginGroup( "Desktop Entry" );
+ desktopEntries["Icon"] = file.value( "Icon" ).toString();
+ desktopEntries["Exec"] = file.value( "Exec" ).toString();
+
+ // translate Name
+ name = file.value( QString( "Name[%1]" ).arg( langWithCountry ) ).toString();
+
+ if ( name.isEmpty() )
+ name= file.value( QString( "Name[%1]" ).arg( lang ) ).toString() ;
+
+ if ( name.isEmpty() )
+ {
+ QFileInfo fileInfo (fileName);
+ QString msgid = QString( "Name(%1)" ).arg( fileInfo.fileName() );
+ msgid += ": ";
+ msgid += file.value( QString( "Name" )).toString();
+ name = QString::fromUtf8( dgettext( DESKTOP_TRANSLATIONS, msgid.toAscii() ) );
+
+ if ( name == msgid )
+ name = "";
+ }
+ if ( name.isEmpty() )
+ name= file.value( QString( "Name" ) ).toString() ;
+ desktopEntries["Name"] = name;
+
+ file.endGroup();
+
+ return desktopEntries;
+}
+
+
+QStringList
+YQPkgDescriptionView::findDesktopFiles( const list<string> & fileList ) const
+{
+ QStringList desktopFiles;
+
+ for ( list<string>::const_iterator it = fileList.begin();
+ it != fileList.end(); ++it )
+ {
+ QString line = fromUTF8( *it );
+
+ if ( line.contains( QRegExp( DESKTOPFILEDIR ) ) )
+ desktopFiles << line;
+ }
+
+ return desktopFiles;
+}
+
+
+void YQPkgDescriptionView::initLang()
+{
+ const char *lang_cstr = getenv( "LANG" );
+
+ if ( lang_cstr )
+ {
+ langWithCountry = lang_cstr;
+ langWithCountry.replace( QRegExp( "[@\\.].*$" ), "" ); // remove .utf8 / @euro etc.
+
+ lang = langWithCountry;
+ lang.replace( QRegExp( "_.*$" ), "" ); // remove _DE etc.
+ }
+}
+
+
#include "YQPkgDescriptionView.moc"
Modified: trunk/qt-pkg/src/YQPkgDescriptionView.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgDescriptionView.h?rev=55241&r1=55240&r2=55241&view=diff
==============================================================================
--- trunk/qt-pkg/src/YQPkgDescriptionView.h (original)
+++ trunk/qt-pkg/src/YQPkgDescriptionView.h Wed Feb 4 14:27:52 2009
@@ -23,6 +23,9 @@
#include <QUrl>
#include "YQPkgGenericDetailsView.h"
+using std::list;
+using std::string;
+
/**
* @short Display the description of a ZyppObj derived object along with its
@@ -71,6 +74,36 @@
* e.g., a "pkg:somepkg" link to another package.
**/
void showLink( const QUrl & url );
+
+ /**
+ * Return html text that contains a list of application icons.
+ **/
+ QString applicationIconList( const list<string> & fileList ) const;
+
+ /**
+ * Find absolute file name (incl. path) for a icon.
+ **/
+ QString findDesktopIcon ( const QString& iconName ) const;
+
+ /**
+ * Extract name, icon and exec attributes from a desktop file.
+ **/
+ QMap readDesktopFile( const QString & fileName ) const;
+
+ /**
+ * Search for all desktop files in a file list.
+ **/
+ QStringList findDesktopFiles( const list<string> & fileList ) const;
+
+ /**
+ * Initialize the language code (lang).
+ **/
+ void initLang();
+
+private:
+ QString langWithCountry;
+ QString lang;
+
};
Modified: trunk/qt-pkg/src/YQPkgFileListView.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgFileListView.cc?rev=55241&r1=55240&r2=55241&view=diff
==============================================================================
--- trunk/qt-pkg/src/YQPkgFileListView.cc (original)
+++ trunk/qt-pkg/src/YQPkgFileListView.cc Wed Feb 4 14:27:52 2009
@@ -28,7 +28,7 @@
#include "utf8.h"
-#define MAX_LINES 5000
+#define MAX_LINES 500
YQPkgFileListView::YQPkgFileListView( QWidget * parent )
@@ -98,9 +98,11 @@
html += "...<br>";
html += "...<br>";
}
-
- // %1 is the total number of files in a file list
- html += "<br>" + _( "%1 files total" ).arg( (unsigned long) fileList.size() );
+ else
+ {
+ // %1 is the total number of files in a file list
+ html += "<br>" + _( "%1 files total" ).arg( (unsigned long) fileList.size() );
+ }
return "<p>" + html + "</p>";
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org