+void KEditTagsDialog::slotItemEntered(QListWidgetItem* item)
+{
+ // align the delete-button to stay on the right border
+ // of the item
+ const QRect rect = m_tagsList->visualItemRect(item);
+ const int size = rect.height();
+ const int x = rect.right() - size;
+ const int y = rect.top();
+ m_deleteButton->move(x, y);
+ m_deleteButton->resize(size, size);
+
+ m_deleteCandidate = item;
+ m_deleteButtonTimer->start();
+}
+
+void KEditTagsDialog::showDeleteButton()
+{
+ m_deleteButton->show();
+}
+
+void KEditTagsDialog::deleteTag()
+{
+ Q_ASSERT(m_deleteCandidate != 0);
+ const QString text = i18nc("@info",
+ "Should the tag <resource>%1</resource> really be deleted for all files?",
+ m_deleteCandidate->text());
+ const QString caption = i18nc("@title", "Delete tag");
+ const KGuiItem deleteItem(i18nc("@action:button", "Delete"), KIcon("edit-delete"));
+ const KGuiItem cancelItem(i18nc("@action:button", "Cancel"), KIcon("dialog-cancel"));
+ if (KMessageBox::warningYesNo(this, text, caption, deleteItem, cancelItem) == KMessageBox::Yes) {
+ const QString label = m_deleteCandidate->data(Qt::UserRole).toString();
+ Nepomuk::Tag tag(label);
+ tag.remove();
+
+ // clear list and reload it
+ for (int i = m_tagsList->count() - 1; i >= 0; --i) {
+ QListWidgetItem* item = m_tagsList->takeItem(i);
+ delete item;
+ }
+ loadTags();
+ }
+}
+