40 #define YUILogComponent "qt-pkg"
42 #include <yui/Libyui_config.h>
47 #include "YQPkgSelDescriptionView.h"
72 _selectable = selectable;
82 QString description = fromUTF8( selectable->theObj()->description() );
84 if ( ! description.contains(
"<!-- DT:Rich -->" ) )
87 html_text += description;
98 ZyppObj zyppObj = selectable->theObj();
99 ZyppPattern pattern = tryCastToZyppPattern ( zyppObj );
104 QString summary = fromUTF8( zyppObj->summary() );
105 bool useBigFont = ( summary.length() <= 40 );
107 if ( summary.isEmpty() )
108 summary = fromUTF8( zyppObj->name() );
110 QString icon = pattern ? pattern->icon().asString().c_str() :
"";
112 if ( icon.isEmpty() )
114 icon = zyppObj->name().c_str();
115 icon.replace(
' ',
'_' );
118 if ( ! icon.isEmpty() )
120 if ( icon.startsWith(
"./" ) )
121 icon.replace( QRegExp(
"^\\./" ),
"" );
123 if ( ! icon.endsWith(
".png", Qt::CaseInsensitive ) &&
124 ! icon.endsWith(
".jpg", Qt::CaseInsensitive ) )
127 QString origIconName = icon;
129 if ( ! icon.contains(
"/" ) )
136 QString iconBaseName = icon;
137 icon =
findIcon( QString( THEMEDIR ) +
"/icons/32x32/apps/" + iconBaseName );
139 if ( icon.isEmpty() )
140 icon =
findIcon( QString( THEMEDIR ) +
"/icons/48x48/apps/" + iconBaseName );
142 else if ( ! icon.startsWith(
"/" ) )
148 icon =
findIcon( QString( THEMEDIR ) +
"/" + icon );
151 if ( pattern && icon.isEmpty() )
152 yuiWarning() <<
"No icon for pattern " << zyppObj->name()
153 <<
" - icon name: " << origIconName
158 QString html =
"<table width='100%'><tr><td>"
159 + ( useBigFont ? QString(
"<h2>" ) : QString(
"<b>" ) )
161 + ( useBigFont ? QString(
"</h2>" ) : QString(
"</b>" ) )
165 if ( ! icon.isEmpty() )
167 html = QString(
"<table width='100%'><tr>" )
168 +
"<td><img src=\"" + icon +
"\"></td>"
169 +
"<td width='100%'>" + html +
"</td>"
181 if ( access( qPrintable( icon ), R_OK ) == 0 )
183 yuiDebug() <<
"Found icon " << icon << endl;
188 yuiDebug() <<
"No icon " << icon << endl;
194 #include "YQPkgSelDescriptionView.moc"
Display the description of a ZyppObj derived object along with its name and summary.
QString simpleHtmlParagraphs(QString text)
Format a multi-line text into paragraphs.
QString htmlHeading(ZyppSel selectable)
Format the heading in HTML.
YQPkgSelDescriptionView(QWidget *parent)
Constructor.
static QString htmlHeading(ZyppSel selectable, bool showVersion=false)
Returns a uniform heading in HTML format for the specified selectable: name and summary or name...
QString findIcon(const QString &icon) const
Check if 'icon' exists.
virtual ~YQPkgSelDescriptionView()
Destructor.
virtual void showDetails(ZyppSel selectable)
Show details for the specified package: In this case the package description.