PDA

View Full Version : QListView and Delegate Vs a list made in HTML



PaceyIV
4th April 2009, 15:54
I'm studying an easy and fast way to create a pretty ListView where the item is something similar to the "Your Newest Album" of Amarok: a cover and some text on the left.

This is the code I found in the Amarok source code (v1.3)



void
ContextBrowser::ContructHTMLAlbums(const QStringList & reqResult, QString & htmlCode, QString stID, T_SHOW_ALBUM_TYPE showAlbumType)
{
// This function create the html code used to display a list of albums. Each album
// is a 'toggleable' block.


It does some query in the rest of code and it adds the item with lines of code like this.



// Compilation image
htmlCode.append( QStringx (
"<td width='1'>"
"<a href='fetchcover: @@@ %1'>"
"<img class='album-image' align='left' vspace='2' hspace='2' title='%2' src='%3'/>"
"</a>"
"</td>"
"<td valign='middle' align='left'>"
"<a href='compilation:%4'><span class='album-title'>%5</span></a>" )
.args( QStringList()
<< escapeHTMLAttr( reqResult[ i ].isEmpty() ? i18n( "Unknown" ) : reqResult[ i ] ) // album.name
<< i18n( "Click for information from amazon.com, right-click for menu." )
<< escapeHTMLAttr( albumImage )
<< reqResult[ i + 1 ] //album.id
<< albumName ) );


Why do they create a List in this way?
Can I make my ListView with delegating methods?
Is it possible to put a label and image in an item View entry (and layout)?
Can someone show me a code that shows how to make a pretty ListView?

Thanks