Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 7e7f8e35 authored by Laurent Montel's avatar Laurent Montel 😁

Fix delete multi item

parent 0d28264b
......@@ -103,7 +103,7 @@ void FollowUpReminderAgent::showConfigureDialog(qlonglong windowId)
}
if (dialog->exec()) {
const QList<qint32> lstRemoveItem = dialog->listRemoveId();
if (FollowUpReminder::FollowUpReminderUtil::removeFollowupReminderInfo(FollowUpReminder::FollowUpReminderUtil::defaultConfig(), lstRemoveItem)) {
if (FollowUpReminder::FollowUpReminderUtil::removeFollowupReminderInfo(FollowUpReminder::FollowUpReminderUtil::defaultConfig(), lstRemoveItem, true)) {
mManager->load();
}
}
......
......@@ -181,13 +181,17 @@ void FollowUpReminderInfoWidget::customContextMenuRequested(const QPoint &pos)
{
Q_UNUSED(pos);
const QList<QTreeWidgetItem *> listItems = mTreeWidget->selectedItems();
if ( !listItems.isEmpty() ) {
FollowUpReminderInfoItem *mailItem = static_cast<FollowUpReminderInfoItem *>(listItems.at(0));
const int nbElementSelected = listItems.count();
if ( nbElementSelected > 0 ) {
KMenu menu;
QAction *showMessage = 0;
if (mailItem && mailItem->data(0, AnswerItemFound).toBool()) {
showMessage = menu.addAction(i18n("Show Message"));
menu.addSeparator();
FollowUpReminderInfoItem *mailItem = 0;
if ( (nbElementSelected == 1) ) {
mailItem = static_cast<FollowUpReminderInfoItem *>(listItems.at(0));
if (mailItem->data(0, AnswerItemFound).toBool()) {
showMessage = menu.addAction(i18n("Show Message"));
menu.addSeparator();
}
}
QAction *deleteItem = menu.addAction(KIcon(QLatin1String("edit-delete")), i18n("Delete"));
QAction *result = menu.exec(QCursor::pos());
......@@ -195,7 +199,7 @@ void FollowUpReminderInfoWidget::customContextMenuRequested(const QPoint &pos)
if (result == showMessage) {
openShowMessage(mailItem->info()->answerMessageItemId());
} else if (result == deleteItem) {
removeItem(mailItem);
removeItem(listItems);
}
}
}
......@@ -207,14 +211,17 @@ void FollowUpReminderInfoWidget::openShowMessage(Akonadi::Item::Id id)
job->start();
}
void FollowUpReminderInfoWidget::removeItem(FollowUpReminderInfoItem *mailItem)
void FollowUpReminderInfoWidget::removeItem(const QList<QTreeWidgetItem *> &mailItemLst)
{
if (mailItem) {
mListRemoveId << mailItem->info()->uniqueIdentifier();
delete mailItem;
mChanged = true;
} else {
if (mailItemLst.isEmpty()) {
qDebug() << "Not item selected";
} else {
Q_FOREACH (QTreeWidgetItem *item, mailItemLst) {
FollowUpReminderInfoItem *mailItem = static_cast<FollowUpReminderInfoItem *>(item);
mListRemoveId << mailItem->info()->uniqueIdentifier();
delete mailItem;
}
mChanged = true;
}
}
......
......@@ -64,7 +64,7 @@ private slots:
private:
void createOrUpdateItem(FollowUpReminder::FollowUpReminderInfo *info, FollowUpReminderInfoItem *item = 0);
void removeItem(FollowUpReminderInfoItem *mailItem);
void removeItem(const QList<QTreeWidgetItem *> &mailItem);
void openShowMessage(Akonadi::Item::Id id);
enum ItemData {
AnswerItemId = Qt::UserRole + 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment