(trunk qt) 1. fix icon sizing issue. 2. add a mechanism to get the favicon from the hostname as an alternative to passing in the full announce UR.L

This commit is contained in:
Charles Kerr 2010-07-30 22:23:47 +00:00
parent ab7fafcf42
commit 729bbd292f
2 changed files with 17 additions and 2 deletions

View File

@ -81,10 +81,22 @@ Favicons :: getHost( const QUrl& url )
QPixmap
Favicons :: find( const QUrl& url )
{
return findFromHost( getHost( url ) );
}
namespace
{
const QSize rightSize( 16, 16 );
};
QPixmap
Favicons :: findFromHost( const QString& host )
{
ensureCacheDirHasBeenScanned( );
return myPixmaps[ getHost(url) ];
const QPixmap pixmap = myPixmaps[ host ];
return pixmap.size()==rightSize ? pixmap : pixmap.scaled(rightSize);
}
void
@ -97,7 +109,7 @@ Favicons :: add( const QUrl& url )
if( !myPixmaps.contains( host ) )
{
// add a placholder s.t. we only ping the server once per session
QPixmap tmp( 16, 16 );
QPixmap tmp( rightSize );
tmp.fill( Qt::transparent );
myPixmaps.insert( host, tmp );

View File

@ -38,6 +38,9 @@ class Favicons: public QObject
/* returns a cached pixmap, or a NULL pixmap if there's no match in the cache */
QPixmap find( const QUrl& url );
/* returns a cached pixmap, or a NULL pixmap if there's no match in the cache */
QPixmap findFromHost( const QString& host );
/* this will emit a signal when (if) the icon becomes ready */
void add( const QUrl& url );