X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/d3a04321886e8ca39ab91a647a9547ebe4d52154..d4287eb8e36ead543eb595bfcaa217fa0edd2654:/src/tagcloud/tagcloud.cpp diff --git a/src/tagcloud/tagcloud.cpp b/src/tagcloud/tagcloud.cpp index 8fe5cba89..e59074fab 100644 --- a/src/tagcloud/tagcloud.cpp +++ b/src/tagcloud/tagcloud.cpp @@ -131,7 +131,7 @@ public: hoverTag( 0 ), cachedHfwWidth( -1 ), m_parent( parent ) { - newTagNode.text = i18n( "New Tag..." ); + newTagNode.text = i18nc( "@label", "New Tag..." ); } int maxFontSize; @@ -204,7 +204,7 @@ int Nepomuk::TagCloud::Private::calculateWeight( const Nepomuk::Tag& tag ) Soprano::QueryResultIterator it = ResourceManager::instance()->mainModel()->executeQuery( QString( "select ?r where { ?r <%1> <%2> . }" ) .arg( Soprano::Vocabulary::NAO::hasTag().toString() ) - .arg( tag.resourceUri().toString() ), + .arg( QString::fromAscii( tag.resourceUri().toEncoded() ) ), Soprano::Query::QueryLanguageSparql ); int w = 0; while ( it.next() ) { @@ -651,7 +651,7 @@ void Nepomuk::TagCloud::showTags( const QList& tags ) d->showAllTags = false; d->invalidateCachedValues(); d->nodes.clear(); - Q_FOREACH( Tag tag, tags ) { + Q_FOREACH( const Tag &tag, tags ) { TagNode node; node.tag = tag; node.weight = d->calculateWeight( tag ); @@ -732,10 +732,11 @@ QSize Nepomuk::TagCloud::sizeHint() const QSize Nepomuk::TagCloud::minimumSizeHint() const { + return QFrame::minimumSizeHint(); // If we have tags d->rebuildCloud() has been called at least once, // thus, we have proper rects (i.e. needed sizes) if ( d->nodes.isEmpty() && !d->newTagButtonEnabled ) { - return QSize( fontMetrics().width( i18n( "No Tags" ) ), fontMetrics().height() ); + return QSize( fontMetrics().width( i18nc( "@label Indicator when no tags defined", "No Tags" ) ), fontMetrics().height() ); } else { QSize size; @@ -760,6 +761,8 @@ int Nepomuk::TagCloud::heightForWidth( int contentsWidth ) const // If we have tags d->rebuildCloud() has been called at least once, // thus, we have proper rects (i.e. needed sizes) + // FIXME: add zoom here + if ( d->cachedHfwWidth != contentsWidth ) { // have to keep in mind the frame contentsWidth -= frameWidth()*2; @@ -829,46 +832,41 @@ void Nepomuk::TagCloud::paintEvent( QPaintEvent* e ) QPainter p( this ); QRegion paintRegion = e->region(); - if ( d->nodes.isEmpty() && !d->newTagButtonEnabled ) { - p.drawText( contentsRect(), d->alignment, i18n( "No Tags" ) ); - } - else { - p.save(); - p.setMatrix( d->zoomMatrix ); + p.save(); + p.setMatrix( d->zoomMatrix ); - for ( QList::iterator it = d->nodes.begin(); - it != d->nodes.end(); ++it ) { - TagNode& node = *it; - - if ( paintRegion.contains( node.zoomedRect ) ) { - p.setFont( node.font ); + for ( QList::iterator it = d->nodes.begin(); + it != d->nodes.end(); ++it ) { + TagNode& node = *it; - if ( &node == d->hoverTag ) { - p.setPen( hoverTextBrush.brush( this ).color() ); - } - else if ( d->selectionEnabled && node.selected ) { - p.setPen( activeTextBrush.brush( this ).color() ); - } - else { - p.setPen( normalTextBrush.brush( this ).color() ); - } - p.drawText( node.rect, Qt::AlignCenter, node.text ); - } - } + if ( paintRegion.contains( node.zoomedRect ) ) { + p.setFont( node.font ); - if ( d->newTagButtonEnabled ) { - p.setFont( d->newTagNode.font ); - if ( &d->newTagNode == d->hoverTag ) { + if ( &node == d->hoverTag ) { p.setPen( hoverTextBrush.brush( this ).color() ); } + else if ( d->selectionEnabled && node.selected ) { + p.setPen( activeTextBrush.brush( this ).color() ); + } else { p.setPen( normalTextBrush.brush( this ).color() ); } - p.drawText( d->newTagNode.rect, Qt::AlignCenter, d->customNewTagAction ? d->customNewTagAction->text() : d->newTagNode.text ); + p.drawText( node.rect, Qt::AlignCenter, node.text ); } + } - p.restore(); + if ( d->newTagButtonEnabled ) { + p.setFont( d->newTagNode.font ); + if ( &d->newTagNode == d->hoverTag ) { + p.setPen( hoverTextBrush.brush( this ).color() ); + } + else { + p.setPen( normalTextBrush.brush( this ).color() ); + } + p.drawText( d->newTagNode.rect, Qt::AlignCenter, d->customNewTagAction ? d->customNewTagAction->text() : d->newTagNode.text ); } + + p.restore(); }