1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
|
From 215a5dad0ddd9a07e3e4ad0b7979bf72a6ea51e6 Mon Sep 17 00:00:00 2001
From: Chris Adams <chris.adams@qinetic.com.au>
Date: Thu, 1 Oct 2020 16:16:22 +1000
Subject: [PATCH 12/32] Fix QList-from-QSet conversions
Change-Id: I93a8500e4555bb33760f4bd73be8d0af0f1422f4
Reviewed-by: Pekka Vuorela <pvuorela@iki.fi>
Signed-off-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
---
.../qcontactmanagerenginev2wrapper_p.cpp | 4 ++--
.../details/qdeclarativecontactaddress_p.h | 2 +-
.../details/qdeclarativecontactfamily_p.h | 2 +-
.../qdeclarativecontactonlineaccount_p.h | 4 ++--
.../qdeclarativecontactorganization_p.h | 2 +-
.../qdeclarativecontactphonenumber_p.h | 2 +-
.../contacts/qdeclarativecontactfetchhint.cpp | 5 +++--
.../qdeclarativeorganizeritemfetchhint.cpp | 2 +-
.../qversitorganizerexporter_p.cpp | 9 ++++-----
.../qcontactmanager/tst_qcontactmanager.cpp | 18 +++++++++--------
.../tst_qorganizermanager.cpp | 20 ++++++++++---------
11 files changed, 37 insertions(+), 33 deletions(-)
diff --git a/src/contacts/qcontactmanagerenginev2wrapper_p.cpp b/src/contacts/qcontactmanagerenginev2wrapper_p.cpp
index e3b8c025..97416740 100644
--- a/src/contacts/qcontactmanagerenginev2wrapper_p.cpp
+++ b/src/contacts/qcontactmanagerenginev2wrapper_p.cpp
@@ -313,7 +313,7 @@ bool PartialSaveRequestController::start()
// Special case for the case where every contact is new - we don't need to bother fetching
// any existing contacts - just prune them down to the mask and do the save request.
QList<QContact> contactsToSave;
- QSet<QContactDetail::DetailType> mask(request()->typeMask().toSet());
+ QSet<QContactDetail::DetailType> mask(request()->typeMask().constBegin(), request()->typeMask().constEnd());
for (int i = 0; i < newContactIndices.count(); i++) {
QContact contactToSave;
partiallyCopyDetails(&contactToSave, contacts[newContactIndices[i]], mask);
@@ -341,7 +341,7 @@ void PartialSaveRequestController::handleFinishedSubRequest(QContactAbstractRequ
QMap<int, QContactManager::Error> fetchErrors(cfbir->errorMap());
QList<QContact> existingContacts(cfbir->contacts());
QList<QContact> contacts(request()->contacts());
- QSet<QContactDetail::DetailType> mask(request()->typeMask().toSet());
+ QSet<QContactDetail::DetailType> mask(request()->typeMask().constBegin(), request()->typeMask().constEnd());
for (int i = 0; i < contacts.count(); i++) {
// See if this is an existing contact or a new one
const int fetchedIdx = m_existingIdMap.value(i, -1);
diff --git a/src/imports/contacts/details/qdeclarativecontactaddress_p.h b/src/imports/contacts/details/qdeclarativecontactaddress_p.h
index c0151a5a..178c1948 100644
--- a/src/imports/contacts/details/qdeclarativecontactaddress_p.h
+++ b/src/imports/contacts/details/qdeclarativecontactaddress_p.h
@@ -144,7 +144,7 @@ public:
{
QList<int> oldList = detail().value< QList<int> >(QContactAddress::FieldSubTypes);
- if (!readOnly() && subTypes.toSet() != oldList.toSet()) {
+ if (!readOnly() && QSet<int>(subTypes.constBegin(), subTypes.constEnd()) != QSet<int>(oldList.constBegin(), oldList.constEnd())) {
detail().setValue(QContactAddress::FieldSubTypes, QVariant::fromValue(subTypes));
emit valueChanged();
}
diff --git a/src/imports/contacts/details/qdeclarativecontactfamily_p.h b/src/imports/contacts/details/qdeclarativecontactfamily_p.h
index d7df2f44..0ac79710 100644
--- a/src/imports/contacts/details/qdeclarativecontactfamily_p.h
+++ b/src/imports/contacts/details/qdeclarativecontactfamily_p.h
@@ -80,7 +80,7 @@ public:
QString spouse() const {return detail().value(QContactFamily::FieldSpouse).toString();}
void setChildren(const QStringList& v)
{
- if (!readOnly() && v.toSet() != children().toSet()) {
+ if (!readOnly() && QSet<QString>(v.constBegin(), v.constEnd()) != QSet<QString>(children().constBegin(), children().constEnd())) {
detail().setValue(QContactFamily::FieldChildren, v);
emit valueChanged();
}
diff --git a/src/imports/contacts/details/qdeclarativecontactonlineaccount_p.h b/src/imports/contacts/details/qdeclarativecontactonlineaccount_p.h
index c5e4bb45..01b9a6d5 100644
--- a/src/imports/contacts/details/qdeclarativecontactonlineaccount_p.h
+++ b/src/imports/contacts/details/qdeclarativecontactonlineaccount_p.h
@@ -121,7 +121,7 @@ public:
void setCapabilities(const QStringList& v)
{
- if (!readOnly() && v.toSet() != capabilities().toSet()) {
+ if (!readOnly() && QSet<QString>(v.constBegin(), v.constEnd()) != QSet<QString>(capabilities().constBegin(), capabilities().constEnd())) {
detail().setValue(QContactOnlineAccount::FieldCapabilities, v);
emit valueChanged();
}
@@ -132,7 +132,7 @@ public:
{
QList<int> oldList = detail().value< QList<int> >(QContactOnlineAccount::FieldSubTypes);
- if (!readOnly() && subTypes.toSet() != oldList.toSet()) {
+ if (!readOnly() && QSet<int>(subTypes.constBegin(), subTypes.constEnd()) != QSet<int>(oldList.constBegin(), oldList.constEnd())) {
detail().setValue(QContactOnlineAccount::FieldSubTypes, QVariant::fromValue(subTypes));
emit valueChanged();
}
diff --git a/src/imports/contacts/details/qdeclarativecontactorganization_p.h b/src/imports/contacts/details/qdeclarativecontactorganization_p.h
index 4f550510..7eb67436 100644
--- a/src/imports/contacts/details/qdeclarativecontactorganization_p.h
+++ b/src/imports/contacts/details/qdeclarativecontactorganization_p.h
@@ -101,7 +101,7 @@ public:
QUrl logoUrl() const {return detail().value(QContactOrganization::FieldLogoUrl).toString();}
void setDepartment(const QStringList& v)
{
- if (!readOnly() && v.toSet() != department().toSet()) {
+ if (!readOnly() && QSet<QString>(v.constBegin(), v.constEnd()) != QSet<QString>(department().constBegin(), department().constEnd())) {
detail().setValue(QContactOrganization::FieldDepartment, v);
emit valueChanged();
}
diff --git a/src/imports/contacts/details/qdeclarativecontactphonenumber_p.h b/src/imports/contacts/details/qdeclarativecontactphonenumber_p.h
index cec557bd..476f18b5 100644
--- a/src/imports/contacts/details/qdeclarativecontactphonenumber_p.h
+++ b/src/imports/contacts/details/qdeclarativecontactphonenumber_p.h
@@ -104,7 +104,7 @@ public:
{
QList<int> oldList = detail().value< QList<int> >(QContactPhoneNumber::FieldSubTypes);
- if (!readOnly() && subTypes.toSet() != oldList.toSet()) {
+ if (!readOnly() && QSet<int>(subTypes.constBegin(), subTypes.constEnd()) != QSet<int>(oldList.constBegin(), oldList.constEnd())) {
detail().setValue(QContactPhoneNumber::FieldSubTypes, QVariant::fromValue(subTypes));
emit valueChanged();
}
diff --git a/src/imports/contacts/qdeclarativecontactfetchhint.cpp b/src/imports/contacts/qdeclarativecontactfetchhint.cpp
index 6da4ee96..e80e65ae 100644
--- a/src/imports/contacts/qdeclarativecontactfetchhint.cpp
+++ b/src/imports/contacts/qdeclarativecontactfetchhint.cpp
@@ -82,7 +82,7 @@ QList<int> QDeclarativeContactFetchHint::detailTypesHint() const
}
void QDeclarativeContactFetchHint::setDetailTypesHint(const QList<int> &detailTypes)
{
- if (detailTypes.toSet() != detailTypesHint().toSet()) {
+ if (QSet<int>(detailTypes.constBegin(), detailTypes.constEnd()) != QSet<int>(detailTypesHint().constBegin(), detailTypesHint().constEnd())) {
QList<QContactDetail::DetailType> convertedDetailTypes;
foreach (const int detailType, detailTypes) {
convertedDetailTypes << static_cast<QContactDetail::DetailType>(detailType);
@@ -104,7 +104,8 @@ QStringList QDeclarativeContactFetchHint::relationshipTypesHint() const
}
void QDeclarativeContactFetchHint::setRelationshipTypesHint(const QStringList& relationshipTypes)
{
- if (relationshipTypes.toSet() != m_fetchHint.relationshipTypesHint().toSet()) {
+ if (QSet<QString>(relationshipTypes.constBegin(), relationshipTypes.constEnd())
+ != QSet<QString>(m_fetchHint.relationshipTypesHint().constBegin(), m_fetchHint.relationshipTypesHint().constEnd())) {
m_fetchHint.setRelationshipTypesHint(relationshipTypes);
emit fetchHintChanged();
}
diff --git a/src/imports/organizer/qdeclarativeorganizeritemfetchhint.cpp b/src/imports/organizer/qdeclarativeorganizeritemfetchhint.cpp
index 0824a1b6..081c5131 100644
--- a/src/imports/organizer/qdeclarativeorganizeritemfetchhint.cpp
+++ b/src/imports/organizer/qdeclarativeorganizeritemfetchhint.cpp
@@ -116,7 +116,7 @@ QList<int> QDeclarativeOrganizerItemFetchHint::detailTypesHint() const
void QDeclarativeOrganizerItemFetchHint::setDetailTypesHint(const QList<int> &detailTypes)
{
- if (detailTypes.toSet() != detailTypesHint().toSet()) {
+ if (QSet<int>(detailTypes.constBegin(), detailTypes.constEnd()) != QSet<int>(detailTypesHint().constBegin(), detailTypesHint().constEnd())) {
QList<QOrganizerItemDetail::DetailType> convertedDetailTypes;
foreach (const int detailType, detailTypes)
convertedDetailTypes << static_cast<QOrganizerItemDetail::DetailType>(detailType);
diff --git a/src/versitorganizer/qversitorganizerexporter_p.cpp b/src/versitorganizer/qversitorganizerexporter_p.cpp
index 2c6aa8a5..58ba684c 100644
--- a/src/versitorganizer/qversitorganizerexporter_p.cpp
+++ b/src/versitorganizer/qversitorganizerexporter_p.cpp
@@ -389,7 +389,7 @@ void QVersitOrganizerExporterPrivate::encodeRecurRule(
if (!rule.daysOfWeek().isEmpty()) {
value.append(QStringLiteral(";BYDAY="));
bool first = true;
- QList<Qt::DayOfWeek> daysOfWeek(QList<Qt::DayOfWeek>::fromSet(rule.daysOfWeek()));
+ QList<Qt::DayOfWeek> daysOfWeek(rule.daysOfWeek().values());
std::sort(daysOfWeek.begin(), daysOfWeek.end());
foreach (Qt::DayOfWeek day, daysOfWeek) {
if (!first)
@@ -413,8 +413,7 @@ void QVersitOrganizerExporterPrivate::encodeRecurRule(
if (!rule.monthsOfYear().isEmpty()) {
value.append(QStringLiteral(";BYMONTH="));
bool first = true;
- QList<QOrganizerRecurrenceRule::Month> months(
- QList<QOrganizerRecurrenceRule::Month>::fromSet(rule.monthsOfYear()));
+ QList<QOrganizerRecurrenceRule::Month> months(rule.monthsOfYear().values());
std::sort(months.begin(), months.end());
foreach (QOrganizerRecurrenceRule::Month month, months) {
if (!first)
@@ -440,7 +439,7 @@ void QVersitOrganizerExporterPrivate::encodeRecurRule(
*/
void QVersitOrganizerExporterPrivate::appendInts(QString* str, const QSet<int>& ints) {
bool first = true;
- QList<int> intList(QList<int>::fromSet(ints));
+ QList<int> intList(ints.values());
std::sort(intList.begin(), intList.end());
foreach (int n, intList) {
if (!first)
@@ -489,7 +488,7 @@ void QVersitOrganizerExporterPrivate::encodeRecurDates(
QString value = property.value();
bool valueIsEmpty = value.isEmpty();
- QList<QDate> dateList(QList<QDate>::fromSet(dates));
+ QList<QDate> dateList(dates.values());
std::sort(dateList.begin(), dateList.end());
foreach (const QDate& dt, dateList) {
QString str;
diff --git a/tests/auto/contacts/qcontactmanager/tst_qcontactmanager.cpp b/tests/auto/contacts/qcontactmanager/tst_qcontactmanager.cpp
index d0fb0f44..e2d5548f 100644
--- a/tests/auto/contacts/qcontactmanager/tst_qcontactmanager.cpp
+++ b/tests/auto/contacts/qcontactmanager/tst_qcontactmanager.cpp
@@ -2129,15 +2129,18 @@ void tst_QContactManager::changeSet()
QVERIFY(!changeSet.addedContacts().isEmpty());
QVERIFY(!changeSet.changedContacts().isEmpty());
QVERIFY(changeSet.removedContacts().isEmpty());
- QSet<QContactId> changedIds;
- QSet<QContactDetail::DetailType> changedTypes;
+ QSet<QContactId> changedIds, expectedIds;
+ QSet<QContactDetail::DetailType> changedTypes, expectedTypes;
foreach (const QContactChangeSet::ContactChangeList &changes, changeSet.changedContacts()) {
changedIds |= QSet<QContactId>(changes.second.constBegin(), changes.second.constEnd());
- if (changes.second.contains(id))
- changedTypes |= QSet<QContactId>(changes.first.constBegin(), changes.first.constEnd());
+ if (changes.second.contains(id)) {
+ changedTypes |= QSet<QContactDetail::DetailType>(changes.first.constBegin(), changes.first.constEnd());
+ }
}
- QCOMPARE(changedIds, (QSet<QContactId>() << id));
- QCOMPARE(changedTypes, (QSet<QContactDetail::DetailType>() << QContactName::Type << QContactBirthday::Type));
+ expectedIds.clear(); expectedIds.insert(id);
+ expectedTypes.clear(); expectedTypes.insert(QContactName::Type); expectedTypes.insert(QContactBirthday::Type);
+ QCOMPARE(changedIds, expectedIds);
+ QCOMPARE(changedTypes, expectedTypes);
changeSet.clearChangedContacts();
QVERIFY(changeSet.changedContacts().isEmpty());
@@ -2149,8 +2152,7 @@ void tst_QContactManager::changeSet()
changeSet.insertChangedContacts(l1, QList<QContactDetail::DetailType>() << QContactName::Type << QContactBirthday::Type);
changeSet.insertChangedContacts(l2, QList<QContactDetail::DetailType>() << QContactBirthday::Type << QContactName::Type << QContactBirthday::Type);
QCOMPARE(changeSet.changedContacts().size(), 1);
- QList<QContactId> expected((QSet<QContactId>(l1.constBegin(), l1.constEnd())
- | QSet<QContactId>(l2.constBegin(), l2.constEnd())).values());
+ QList<QContactId> expected((QSet<QContactId>(l1.constBegin(), l1.constEnd()) | QSet<QContactId>(l2.constBegin(), l2.constEnd())).values());
qSort(expected);
QCOMPARE(changeSet.changedContacts().first().second, expected);
diff --git a/tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp b/tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp
index 34d10d44..8fb0d218 100644
--- a/tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp
+++ b/tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp
@@ -65,6 +65,12 @@ static inline QOrganizerCollectionId makeCollectionId(uint id)
return QOrganizerCollectionId(QStringLiteral("qtorganizer:basic:"), QByteArray(reinterpret_cast<const char *>(&id), sizeof(uint)));
}
+template<typename T>
+static inline QSet<T> convertListToSet(const QList<T> &list)
+{
+ return QSet<T>(list.constBegin(), list.constEnd());
+}
+
class tst_QOrganizerManager : public QObject
{
@@ -2733,15 +2739,13 @@ void tst_QOrganizerManager::changeSet()
QSet<QOrganizerItemId> changedIds;
QSet<QOrganizerItemDetail::DetailType> changedTypes;
foreach (const QOrganizerItemChangeSet::ItemChangeList &changes, changeSet.changedItems()) {
- changedIds |= QSet<QOrganizerItemId>(changes.second.constBegin(),
- changes.second.constEnd());
+ changedIds |= convertListToSet(changes.second);
if (changes.second.contains(id)) {
- changedTypes |= QSet<QOrganizerItemId>(changes.first.constBegin(),
- changes.first.constEnd());
+ changedTypes |= convertListToSet(changes.first);
}
}
- QCOMPARE(changedIds, (QSet<QOrganizerItemId>() << id));
- QCOMPARE(changedTypes, (QSet<QOrganizerItemDetail::DetailType>() << QOrganizerItemDetail::TypeDescription << QOrganizerItemDetail::TypeTag));
+ QCOMPARE(changedIds, convertListToSet(QList<QOrganizerItemId>() << id));
+ QCOMPARE(changedTypes, convertListToSet(QList<QOrganizerItemDetail::DetailType>() << QOrganizerItemDetail::TypeDescription << QOrganizerItemDetail::TypeTag));
changeSet.clearChangedItems();
QVERIFY(changeSet.changedItems().isEmpty());
@@ -2753,9 +2757,7 @@ void tst_QOrganizerManager::changeSet()
changeSet.insertChangedItems(l1, QList<QOrganizerItemDetail::DetailType>() << QOrganizerItemDetail::TypeDescription << QOrganizerItemDetail::TypeTag);
changeSet.insertChangedItems(l2, QList<QOrganizerItemDetail::DetailType>() << QOrganizerItemDetail::TypeTag << QOrganizerItemDetail::TypeDescription << QOrganizerItemDetail::TypeTag);
QCOMPARE(changeSet.changedItems().size(), 1);
- QList<QOrganizerItemId> expected(
- (QSet<QOrganizerItemId>(l1.constBegin(), l1.constEnd())
- | QSet<QOrganizerItemId>(l2.constBegin(), l2.constEnd())).values());
+ QList<QOrganizerItemId> expected((convertListToSet(l1) | convertListToSet(l2)).values());
qSort(expected);
QCOMPARE(changeSet.changedItems().first().second, expected);
--
2.30.2
|