Commit 348adbe2 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Show number of emails selected

parent b1a3d79a
Pipeline #89610 passed with stage
in 42 minutes and 27 seconds
......@@ -24,6 +24,7 @@
#include <KSharedConfig>
#include <QDialogButtonBox>
#include <QKeyEvent>
#include <QLabel>
#include <QTreeView>
#include <QVBoxLayout>
......@@ -35,6 +36,7 @@ static const char myRecipientsPickerConfigGroupName[] = "RecipientsPicker";
RecipientsPicker::RecipientsPicker(QWidget *parent)
: QDialog(parent)
, mView(new Akonadi::RecipientsPickerWidget(true, nullptr, this))
, mSelectedLabel(new QLabel(this))
{
setObjectName(QStringLiteral("RecipientsPicker"));
setWindowTitle(i18nc("@title:window", "Select Recipient"));
......@@ -47,6 +49,8 @@ RecipientsPicker::RecipientsPicker(QWidget *parent)
connect(mView->view()->selectionModel(), &QItemSelectionModel::selectionChanged, this, &RecipientsPicker::slotSelectionChanged);
connect(mView->view(), &QAbstractItemView::doubleClicked, this, &RecipientsPicker::slotPicked);
mainLayout->addWidget(mSelectedLabel);
auto searchLDAPButton = new QPushButton(i18n("Search &Directory Service"), this);
connect(searchLDAPButton, &QPushButton::clicked, this, &RecipientsPicker::slotSearchLDAP);
mainLayout->addWidget(searchLDAPButton);
......@@ -91,13 +95,24 @@ RecipientsPicker::~RecipientsPicker()
writeConfig();
}
void RecipientsPicker::updateLabel(int nbSelected)
{
if (nbSelected == 0) {
mSelectedLabel->setText({});
} else {
mSelectedLabel->setText(i18np("%1 selected email", "%1 selected emails", nbSelected));
}
}
void RecipientsPicker::slotSelectionChanged()
{
const bool hasSelection = !mView->emailAddressSelectionWidget()->selectedAddresses().isEmpty();
const int selectedItems{mView->emailAddressSelectionWidget()->selectedAddresses().count()};
const bool hasSelection = (selectedItems != 0);
mUser1Button->setEnabled(hasSelection);
mUser2Button->setEnabled(hasSelection);
mUser3Button->setEnabled(hasSelection);
mUser4Button->setEnabled(hasSelection);
updateLabel(selectedItems);
}
void RecipientsPicker::setRecipients(const Recipient::List &)
......
......@@ -13,7 +13,7 @@
#include <QDialog>
class QPushButton;
class QLabel;
namespace PimCommon
{
class LdapSearchDialog;
......@@ -60,6 +60,7 @@ protected Q_SLOTS:
void slotSelectionChanged();
private:
void updateLabel(int nbSelected);
Akonadi::RecipientsPickerWidget *const mView;
PimCommon::LdapSearchDialog *mLdapSearchDialog = nullptr;
......@@ -69,6 +70,7 @@ private:
QPushButton *mUser3Button = nullptr;
QPushButton *mUser2Button = nullptr;
QPushButton *mUser1Button = nullptr;
QLabel *const mSelectedLabel = nullptr;
};
}
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