40 #define YUILogComponent "qt-pkg" 42 #include <yui/Libyui_config.h> 47 #include "YQPkgSelDescriptionView.h" 73 _selectable = selectable;
83 QString description = fromUTF8( selectable->theObj()->description() );
85 if ( ! description.contains(
"<!-- DT:Rich -->" ) )
88 html_text += description;
99 ZyppObj zyppObj = selectable->theObj();
100 ZyppPattern pattern = tryCastToZyppPattern ( zyppObj );
105 QString summary = fromUTF8( zyppObj->summary() );
106 bool useBigFont = ( summary.length() <= 40 );
108 if ( summary.isEmpty() )
109 summary = fromUTF8( zyppObj->name() );
111 QString iconName = pattern ? pattern->icon().asString().c_str() :
"";
113 if ( iconName.isEmpty() )
115 iconName = zyppObj->name().c_str();
116 iconName.replace(
' ',
'_' );
119 if ( ! iconName.isEmpty() )
121 if ( iconName.startsWith(
"./" ) )
122 iconName.replace( QRegExp(
"^\\./" ),
"" );
124 if ( pattern && iconName.isEmpty() )
125 yuiWarning() <<
"No icon for pattern " << zyppObj->name() << endl;
129 QString html =
"<table width='100%'><tr><td>" 130 + ( useBigFont ? QString(
"<h2>" ) : QString(
"<b>" ) )
132 + ( useBigFont ? QString(
"</h2>" ) : QString(
"</b>" ) )
136 if ( ! iconName.isEmpty() )
138 QIcon icon = YQUI::ui()->loadIcon( iconName.toStdString() );
139 QPixmap pixmap = icon.pixmap(16);
140 QByteArray byteArray;
141 QBuffer buffer(&byteArray);
142 pixmap.save(&buffer,
"PNG");
143 html = QString(
"<table width='100%'><tr>" )
144 +
"<td><img src=\"data:image/png;base64," + byteArray.toBase64() +
"\"/></td>" 145 +
"<td width='100%'>" + html +
"</td>" 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...
virtual ~YQPkgSelDescriptionView()
Destructor.
virtual void showDetails(ZyppSel selectable)
Show details for the specified package: In this case the package description.