Commit 6fc9b0ba authored by Laurent Montel's avatar Laurent Montel
Browse files

Add menu for select all or deselect all

parent 44b0d2ef
Pipeline #228551 passed with stage
in 28 minutes and 39 seconds
......@@ -16,7 +16,7 @@ macro( kaddressbook_merge _source _additional _additionallib)
add_executable( ${_name} ${_test} ${_name}.h)
add_test(NAME ${_name} COMMAND ${_name} )
ecm_mark_as_test(kaddressbookmerge-${_name})
target_link_libraries( ${_name} kaddressbookmergelibprivate Qt::Test KF5::AkonadiCore KF5::Contacts ${_additionallib})
target_link_libraries( ${_name} kaddressbookmergelibprivate Qt::Test KF5::AkonadiCore KF5::Contacts KF5::I18n ${_additionallib})
endmacro()
kaddressbook_merge(mergecontactstest.cpp "../job/mergecontacts.cpp;../kaddressbookmergelibprivate_debug.cpp" "")
......@@ -39,7 +39,7 @@ if (KDEPIM_RUN_AKONADI_TEST)
add_akonadi_isolated_test_advanced( mergecontactselectinformationtabwidgettest.cpp "${kaddressbookmergelibprivate_common_SRCS}" "kaddressbookmergelibprivate;KF5::Contacts")
add_akonadi_isolated_test_advanced(mergecontactsdialogtest.cpp "${kaddressbookmergelibprivate_common_SRCS};../widgets/mergecontacterrorlabel.cpp;../widgets/mergecontactinfowidget.cpp" "kaddressbookmergelibprivate;KF5::Contacts;KF5::AkonadiContact;KF5::I18n;KF5::WidgetsAddons")
add_akonadi_isolated_test_advanced(mergecontactwidgetlisttest.cpp "${kaddressbookmergelibprivate_common_SRCS};../manualmerge/mergecontactwidgetlist.cpp;" "kaddressbookmergelibprivate;KF5::Contacts;KF5::AkonadiContact")
add_akonadi_isolated_test_advanced(mergecontactwidgetlisttest.cpp "${kaddressbookmergelibprivate_common_SRCS};../manualmerge/mergecontactwidgetlist.cpp;" "kaddressbookmergelibprivate;KF5::Contacts;KF5::AkonadiContact;KF5::I18n")
endif()
......
......@@ -6,10 +6,15 @@
#include "mergecontactwidgetlist.h"
#include <KLocalizedString>
#include <QMenu>
using namespace KABMergeContacts;
MergeContactWidgetList::MergeContactWidgetList(QWidget *parent)
: QListWidget(parent)
{
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &MergeContactWidgetList::customContextMenuRequested, this, &MergeContactWidgetList::slotCustomContextMenuRequested);
}
MergeContactWidgetList::~MergeContactWidgetList() = default;
......@@ -27,6 +32,30 @@ QString MergeContactWidgetList::itemName(const KContacts::Addressee &address) co
return address.fullEmail();
}
void MergeContactWidgetList::slotCustomContextMenuRequested(const QPoint &)
{
QMenu menu(this);
menu.addAction(i18n("Select All"), this, &MergeContactWidgetList::slotSelectAll);
menu.addAction(i18n("Deselect All"), this, &MergeContactWidgetList::slotDeselectAll);
menu.exec(QCursor::pos());
}
void MergeContactWidgetList::slotSelectAll()
{
for (int i = 0; i < count(); ++i) {
QListWidgetItem *itemWidget = item(i);
itemWidget->setCheckState(Qt::Checked);
}
}
void MergeContactWidgetList::slotDeselectAll()
{
for (int i = 0; i < count(); ++i) {
QListWidgetItem *itemWidget = item(i);
itemWidget->setCheckState(Qt::Unchecked);
}
}
void MergeContactWidgetList::fillListContact(const Akonadi::Item::List &items)
{
clear();
......
......@@ -35,5 +35,8 @@ public:
private:
Q_REQUIRED_RESULT QString itemName(const KContacts::Addressee &address) const;
void slotCustomContextMenuRequested(const QPoint &);
void slotSelectAll();
void slotDeselectAll();
};
}
Supports Markdown
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