bool tagsChanged;
void showTaggingPopup( const QPoint& );
+ void updateResources();
void _k_slotShowTaggingPopup();
void _k_metadataUpdateDone();
static QList<Tag> intersectTags( const QList<Resource>& );
popup->exec( pos );
if( tagsChanged ) {
- MassUpdateJob* job = MassUpdateJob::tagResources( resources, resourceTags );
- connect( job, SIGNAL( result( KJob* ) ),
- q, SLOT( _k_metadataUpdateDone() ) );
- q->setEnabled( false ); // no updates during execution
- job->start();
+ updateResources();
}
resourceTagCloud->showTags( resourceTags );
}
+void Nepomuk::ResourceTaggingWidget::Private::updateResources()
+{
+ MassUpdateJob* job = MassUpdateJob::tagResources( resources, resourceTags );
+ connect( job, SIGNAL( result( KJob* ) ),
+ q, SLOT( _k_metadataUpdateDone() ) );
+ q->setEnabled( false ); // no updates during execution
+ job->start();
+}
+
+
void Nepomuk::ResourceTaggingWidget::Private::_k_slotShowTaggingPopup()
{
showTaggingPopup( QCursor::pos() );
{
// assign it right away
d->resourceTags.append( tag );
-// d->resource.addTag( tag );
+ d->updateResources();
}
#include <KLocale>
#include <KColorScheme>
#include <KDebug>
+#include <KMenu>
+#include <KIcon>
+#include <KMessageBox>
#include <Soprano/Client/DBusModel>
#include <Soprano/QueryResultIterator>
selected( false ) {
}
+ bool operator==( const TagNode& other ) const {
+ return tag == other.tag;
+ }
+
// fixed info
Nepomuk::Tag tag;
int weight;
alignment( Qt::AlignCenter ),
sorting( SortAlpabetically ),
zoomEnabled( true ),
+ contextMenuEnabled( true ),
showAllTags( false ),
customNewTagAction( 0 ),
hoverTag( 0 ),
Qt::Alignment alignment;
Sorting sorting;
bool zoomEnabled;
+ bool contextMenuEnabled;
// The resource whose tags we are showing
// invalid if we show all tags or a selection
void Nepomuk::TagCloud::setContextMenuEnabled( bool enabled )
{
- Q_UNUSED(enabled);
+ d->contextMenuEnabled = enabled;
}
void Nepomuk::TagCloud::showResourceTags( const Resource& resource )
{
showTags( resource.tags() );
- d->resource = resource.uri();
+ d->resource = resource.resourceUri();
}
}
}
}
+ else if ( d->contextMenuEnabled &&
+ e->button() == Qt::RightButton ) {
+ if ( TagNode* node = d->tagAt( e->pos() ) ) {
+ KMenu menu;
+ QAction* a = menu.addAction( KIcon( "edit-delete" ), i18nc( "@action:menu", "Delete tag '%1'", node->text ) );
+ if ( menu.exec( e->globalPos() ) == a &&
+ KMessageBox::questionYesNo( this, i18n( "Do you really want to delete tag '%1'", node->text ) ) == KMessageBox::Yes ) {
+ if ( d->selectionEnabled &&
+ node->selected ) {
+ node->selected = false;
+ emit tagToggled( node->tag, false );
+ }
+ node->tag.remove();
+ d->nodes.removeAll( *node );
+ d->rebuildCloud();
+ }
+ }
+ }
}