1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQPkgDescriptionView.cc
15 Author: Stefan Hundhammer <sh@suse.de>
19 #define y2log_component "qt-pkg"
20 #include <ycp/y2log.h>
24 #include "YQPkgDescriptionView.h"
25 #include "YQPkgDescriptionDialog.h"
33 YQPkgDescriptionView::YQPkgDescriptionView( QWidget * parent )
34 : YQPkgGenericDetailsView( parent )
36 //FIXME setMimeSourceFactory( 0 );
40 YQPkgDescriptionView::~YQPkgDescriptionView()
47 YQPkgDescriptionView::showDetails( ZyppSel selectable )
49 _selectable = selectable;
57 QString html_text = htmlHeading( selectable );
59 QString description = fromUTF8( selectable->theObj()->description() );
61 if ( ! description.contains( "<!-- DT:Rich -->" ) )
62 description = simpleHtmlParagraphs( description );
64 html_text += description;
68 //FIXME ensureVisible( 0, 0 ); // Otherwise hyperlinks will be centered
73 QString YQPkgDescriptionView::simpleHtmlParagraphs( QString text )
75 bool foundAuthorsList = false;
76 QString html_text = "<p>";
78 QStringList lines = text.trimmed().split( '\n', QString::KeepEmptyParts );
79 QStringList::const_iterator it = lines.begin();
81 while ( it != lines.end() )
83 QString line = htmlEscape( *it ).trimmed();
85 if ( line.startsWith( "Authors:" ) )
87 line = "<p><b>" + line + "</b><ul>";
88 foundAuthorsList = true;
91 if ( foundAuthorsList )
93 if ( ! line.startsWith( "-----" ) && ! line.isEmpty() )
94 html_text += "<li>" + line + "</li>";
99 html_text += "</p><p>";
101 html_text += " " + line;
107 if ( foundAuthorsList )
108 html_text += "</ul>";
117 YQPkgDescriptionView::showLink( const QString & url )
119 if ( url.startsWith( "pkg:" ) )
121 QString pkgName = url;
122 pkgName.remove( QRegExp( "^pkg:/*" ) ); // Remove leading protocol and slashes
123 pkgName.remove( QRegExp( "/*$" ) ); // Remove trailing slashes
124 y2milestone( "Hyperlinking to package '%s'", qPrintable(pkgName) );
125 YQPkgDescriptionDialog::showDescriptionDialog( pkgName );
129 y2error( "Protocol not supported - can't follow hyperlink '%s'",
136 YQPkgDescriptionView::setSource( const QString & url )
142 #include "YQPkgDescriptionView.moc"