diff options
| author | Sebastian Trueg <[email protected]> | 2009-04-28 08:17:59 +0000 |
|---|---|---|
| committer | Sebastian Trueg <[email protected]> | 2009-04-28 08:17:59 +0000 |
| commit | f8e5a0064ce5f47ad320d0bd4e7ade4c5f64ea00 (patch) | |
| tree | 50d93be7cb9a5e70d580862711689cbec822beb6 /src/panels/information | |
| parent | 74f07c7860d6b04c2a0b74a151b9003f71b118cf (diff) | |
Fixed context menu to delete tags.
BUG: 165188
svn path=/trunk/KDE/kdebase/apps/; revision=960282
Diffstat (limited to 'src/panels/information')
| -rw-r--r-- | src/panels/information/resourcetaggingwidget.cpp | 19 | ||||
| -rw-r--r-- | src/panels/information/tagcloud.cpp | 31 | ||||
| -rw-r--r-- | src/panels/information/taggingpopup.h | 2 |
3 files changed, 43 insertions, 9 deletions
diff --git a/src/panels/information/resourcetaggingwidget.cpp b/src/panels/information/resourcetaggingwidget.cpp index 34892f30c..ac14e45a0 100644 --- a/src/panels/information/resourcetaggingwidget.cpp +++ b/src/panels/information/resourcetaggingwidget.cpp @@ -51,6 +51,7 @@ public: bool tagsChanged; void showTaggingPopup( const QPoint& ); + void updateResources(); void _k_slotShowTaggingPopup(); void _k_metadataUpdateDone(); static QList<Tag> intersectTags( const QList<Resource>& ); @@ -71,17 +72,23 @@ void Nepomuk::ResourceTaggingWidget::Private::showTaggingPopup( const QPoint& po 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() ); @@ -181,7 +188,7 @@ void Nepomuk::ResourceTaggingWidget::slotTagAdded( const Nepomuk::Tag& tag ) { // assign it right away d->resourceTags.append( tag ); -// d->resource.addTag( tag ); + d->updateResources(); } diff --git a/src/panels/information/tagcloud.cpp b/src/panels/information/tagcloud.cpp index 0074d1796..ef1df5fa4 100644 --- a/src/panels/information/tagcloud.cpp +++ b/src/panels/information/tagcloud.cpp @@ -36,6 +36,9 @@ #include <KLocale> #include <KColorScheme> #include <KDebug> +#include <KMenu> +#include <KIcon> +#include <KMessageBox> #include <Soprano/Client/DBusModel> #include <Soprano/QueryResultIterator> @@ -58,6 +61,10 @@ namespace { selected( false ) { } + bool operator==( const TagNode& other ) const { + return tag == other.tag; + } + // fixed info Nepomuk::Tag tag; int weight; @@ -126,6 +133,7 @@ public: alignment( Qt::AlignCenter ), sorting( SortAlpabetically ), zoomEnabled( true ), + contextMenuEnabled( true ), showAllTags( false ), customNewTagAction( 0 ), hoverTag( 0 ), @@ -142,6 +150,7 @@ public: 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 @@ -612,7 +621,7 @@ void Nepomuk::TagCloud::setZoomEnabled( bool zoom ) void Nepomuk::TagCloud::setContextMenuEnabled( bool enabled ) { - Q_UNUSED(enabled); + d->contextMenuEnabled = enabled; } @@ -641,7 +650,7 @@ void Nepomuk::TagCloud::showAllTags() void Nepomuk::TagCloud::showResourceTags( const Resource& resource ) { showTags( resource.tags() ); - d->resource = resource.uri(); + d->resource = resource.resourceUri(); } @@ -903,6 +912,24 @@ void Nepomuk::TagCloud::mousePressEvent( QMouseEvent* e ) } } } + 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(); + } + } + } } diff --git a/src/panels/information/taggingpopup.h b/src/panels/information/taggingpopup.h index 99cee701c..db9472b23 100644 --- a/src/panels/information/taggingpopup.h +++ b/src/panels/information/taggingpopup.h @@ -35,7 +35,7 @@ namespace Nepomuk { void popup( const QPoint& pos ); void exec( const QPoint& pos ); - bool event( QEvent* e ); + bool event( QEvent* e ); protected: void mousePressEvent( QMouseEvent* e ); |
