Commit 9bc182c8 authored by Volker Krause's avatar Volker Krause
Browse files

Use a vector rather than a hash for storing attendee/combobox pairs

Summary:
We don't need the hash features here, so this unnecessarily relies on
Attendee being pointer-like.

Subscribers: kde-pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D21535
parent 6e684550
......@@ -51,7 +51,7 @@ private Q_SLOTS:
QCOMPARE(dialog.updateAttendees().count(), 3);
// Just make sure, that the QCombobox is sorted like we think
QComboBox *first = dialog.mAttendeeDecision[attendees[0]];
QComboBox *first = dialog.mAttendeeDecision[0].second;
QCOMPARE((IndividualMailDialog::Decisions)first->itemData(0, Qt::UserRole).toInt(),
IndividualMailDialog::Update);
QCOMPARE((IndividualMailDialog::Decisions)first->itemData(1, Qt::UserRole).toInt(),
......
......@@ -39,6 +39,7 @@ IndividualMailDialog::IndividualMailDialog(const QString &question, const KCalCo
setWindowTitle(i18nc("@title:window", "Group Scheduling Email"));
m_detailsWidget = new QWidget();
QGridLayout *layout = new QGridLayout(m_detailsWidget);
mAttendeeDecision.reserve(attendees.size());
int row = 0;
for (const KCalCore::Attendee::Ptr &attendee : attendees) {
QComboBox *options = new QComboBox();
......@@ -52,7 +53,7 @@ IndividualMailDialog::IndividualMailDialog(const QString &question, const KCalCo
"Options for this particular attendee."));
options->setToolTip(i18nc("@info:tooltip",
"Choose an option for this attendee."));
mAttendeeDecision[attendee] = options;
mAttendeeDecision.push_back(std::make_pair(attendee, options));
layout->addWidget(new QLabel(attendee->fullName()), row, 0);
layout->addWidget(options, row, 1);
......@@ -103,9 +104,9 @@ KCalCore::Attendee::List IndividualMailDialog::editAttendees() const
{
KCalCore::Attendee::List edit;
for (auto it = mAttendeeDecision.cbegin(), end = mAttendeeDecision.cend(); it != end; ++it) {
int index = it.value()->currentIndex();
if (it.value()->itemData(index, Qt::UserRole) == Edit) {
edit.append(it.key());
const int index = (*it).second->currentIndex();
if ((*it).second->itemData(index, Qt::UserRole) == Edit) {
edit.append((*it).first);
}
}
return edit;
......@@ -115,9 +116,9 @@ KCalCore::Attendee::List IndividualMailDialog::updateAttendees() const
{
KCalCore::Attendee::List update;
for (auto it = mAttendeeDecision.cbegin(), end = mAttendeeDecision.cend(); it != end; ++it) {
int index = it.value()->currentIndex();
if (it.value()->itemData(index, Qt::UserRole) == Update) {
update.append(it.key());
const int index = (*it).second->currentIndex();
if ((*it).second->itemData(index, Qt::UserRole) == Update) {
update.append((*it).first);
}
}
return update;
......
......@@ -55,7 +55,7 @@ public:
private:
void updateButtonState();
QHash<KCalCore::Attendee::Ptr, QComboBox *> mAttendeeDecision;
std::vector<std::pair<KCalCore::Attendee::Ptr, QComboBox*>> mAttendeeDecision;
QDialogButtonBox *m_buttons = nullptr;
QWidget *m_detailsWidget = 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