Commit 6654598a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent ef5695c3
Pipeline #60346 passed with stage
in 5 minutes and 52 seconds
......@@ -538,7 +538,7 @@ void HistoryTest::createFinished(int changeId, const Akonadi::Item &item, Akonad
QVERIFY(item.parentCollection().isValid());
mItemByChangeId.insert(changeId, item);
QVERIFY(item.hasPayload());
Incidence::Ptr incidence = item.payload<KCalendarCore::Incidence::Ptr>();
auto incidence = item.payload<KCalendarCore::Incidence::Ptr>();
// mItemIdByUid.insert(incidence->uid(), item.id());
} else {
qDebug() << "Error string is " << errorString;
......
......@@ -206,7 +206,7 @@ private Q_SLOTS:
QVERIFY(retrievedItem.hasPayload());
QVERIFY(retrievedItem.hasPayload<KCalendarCore::Event::Ptr>());
QVERIFY(retrievedItem.hasPayload<KCalendarCore::Incidence::Ptr>());
Incidence::Ptr incidence = retrievedItem.payload<KCalendarCore::Incidence::Ptr>();
auto incidence = retrievedItem.payload<KCalendarCore::Incidence::Ptr>();
QCOMPARE(incidence->summary(), summary);
QCOMPARE(incidence->uid(), uid);
}
......@@ -331,7 +331,7 @@ private Q_SLOTS:
Item fetchedItem = fetchJob->items().constFirst();
QVERIFY(fetchedItem.isValid());
QVERIFY(fetchedItem.hasPayload<KCalendarCore::Incidence::Ptr>());
Incidence::Ptr incidence = fetchedItem.payload<KCalendarCore::Incidence::Ptr>();
auto incidence = fetchedItem.payload<KCalendarCore::Incidence::Ptr>();
QCOMPARE(incidence->summary(), newSummary);
QCOMPARE(incidence->revision(), expectedRevision);
delete fetchJob;
......@@ -374,7 +374,7 @@ private Q_SLOTS:
Item fetchedItem = fetchJob->items().constFirst();
QVERIFY(fetchedItem.isValid());
QVERIFY(fetchedItem.hasPayload<KCalendarCore::Incidence::Ptr>());
Incidence::Ptr incidence2 = fetchedItem.payload<KCalendarCore::Incidence::Ptr>();
auto incidence2 = fetchedItem.payload<KCalendarCore::Incidence::Ptr>();
QCOMPARE(incidence2->alarms().count(), 1);
QCOMPARE(incidence2->revision(), 0);
delete fetchJob;
......@@ -528,7 +528,7 @@ private Q_SLOTS:
QVERIFY(fetchedItem.isValid());
QVERIFY(fetchedItem.hasPayload<KCalendarCore::Event::Ptr>());
Event::Ptr incidence = fetchedItem.payload<KCalendarCore::Event::Ptr>();
auto incidence = fetchedItem.payload<KCalendarCore::Event::Ptr>();
QCOMPARE(incidence->revision(), revision + 1);
......@@ -589,7 +589,7 @@ private Q_SLOTS:
int changeId = -1;
for (int i = 0; i < numberOfModifications; ++i) {
Incidence::Ptr incidence = item.payload<KCalendarCore::Incidence::Ptr>();
auto incidence = item.payload<KCalendarCore::Incidence::Ptr>();
Q_ASSERT(incidence);
incidence->setSummary(QString::number(i));
changeId = mChanger->modifyIncidence(item);
......@@ -943,7 +943,7 @@ private Q_SLOTS:
case IncidenceChanger::ChangeTypeCreate:
if (expectedSuccess) {
QVERIFY(item.hasPayload<KCalendarCore::Incidence::Ptr>());
Incidence::Ptr incidence = item.payload<KCalendarCore::Incidence::Ptr>();
auto incidence = item.payload<KCalendarCore::Incidence::Ptr>();
QVERIFY(incidence);
QVERIFY(!incidence->uid().isEmpty());
QVERIFY(mItemIdByUid.contains(incidence->uid()));
......@@ -1174,7 +1174,7 @@ public Q_SLOTS:
QVERIFY(item.parentCollection().isValid());
mItemIdByChangeId.insert(changeId, item.id());
QVERIFY(item.hasPayload());
Incidence::Ptr incidence = item.payload<KCalendarCore::Incidence::Ptr>();
auto incidence = item.payload<KCalendarCore::Incidence::Ptr>();
mItemIdByUid.insert(incidence->uid(), item.id());
mLastItemCreated = item;
} else {
......
......@@ -219,7 +219,7 @@ void ITIPHandlerTest::testProcessITIPMessage()
processItip(iCalData, receiver, action, expectedNumIncidences, items);
if (expectedNumIncidences == 1) {
KCalendarCore::Incidence::Ptr incidence = items.first().payload<KCalendarCore::Incidence::Ptr>();
auto incidence = items.first().payload<KCalendarCore::Incidence::Ptr>();
QVERIFY(incidence);
QCOMPARE(incidence->schedulingID(), incidenceUid);
QVERIFY(incidence->schedulingID() != incidence->uid());
......@@ -345,7 +345,7 @@ void ITIPHandlerTest::testProcessITIPMessageCancel()
Item::List items;
processItip(iCalData, receiver, QStringLiteral("accepted"), 1, items);
KCalendarCore::Incidence::Ptr incidence = items.first().payload<KCalendarCore::Incidence::Ptr>();
auto incidence = items.first().payload<KCalendarCore::Incidence::Ptr>();
QVERIFY(incidence);
// good, now accept the invitation that has the CANCEL
......@@ -488,7 +488,7 @@ void ITIPHandlerTest::testOutgoingInvitations()
QFETCH(int, expectedEmailCount);
QFETCH(IncidenceChanger::InvitationPolicy, invitationPolicy);
QFETCH(bool, userCancels);
KCalendarCore::Incidence::Ptr incidence = item.payload<KCalendarCore::Incidence::Ptr>();
auto incidence = item.payload<KCalendarCore::Incidence::Ptr>();
m_pendingIncidenceChangerSignal = 1;
FakeMessageQueueJob::sUnitTestResults.clear();
......
......@@ -65,7 +65,7 @@ private Q_SLOTS:
item.setPayloadFromData(serialized);
QVERIFY(item.hasPayload<Event::Ptr>());
const Event::Ptr event = item.payload<Event::Ptr>();
const auto event = item.payload<Event::Ptr>();
QVERIFY(event != nullptr);
QCOMPARE(event->summary(), QStringLiteral("Test event"));
......@@ -110,7 +110,7 @@ private Q_SLOTS:
item2.setMimeType(mimeType);
item2.setPayloadFromData(bytes);
Event::Ptr event2 = item2.payload<Event::Ptr>();
auto event2 = item2.payload<Event::Ptr>();
QVERIFY(event2 != nullptr);
QVERIFY(event2->summary().toUtf8() == QByteArray(utf_umlaut));
QVERIFY(event2->summary().toLatin1() == QByteArray(latin1_umlaut));
......
......@@ -114,7 +114,7 @@ void SerializerPluginKCalCore::serialize(const Item &item, const QByteArray &lab
if (label != Item::FullPayload || !item.hasPayload<Incidence::Ptr>()) {
return;
}
Incidence::Ptr i = item.payload<Incidence::Ptr>();
auto i = item.payload<Incidence::Ptr>();
// Using an env variable for now while testing
if (qgetenv("KCALCORE_BINARY_SERIALIZER") == QByteArray("1")) {
......@@ -324,8 +324,8 @@ void SerializerPluginKCalCore::compare(Akonadi::AbstractDifferencesReporter *rep
Q_ASSERT(leftItem.hasPayload<Incidence::Ptr>());
Q_ASSERT(rightItem.hasPayload<Incidence::Ptr>());
const Incidence::Ptr leftIncidencePtr = leftItem.payload<Incidence::Ptr>();
const Incidence::Ptr rightIncidencePtr = rightItem.payload<Incidence::Ptr>();
const auto leftIncidencePtr = leftItem.payload<Incidence::Ptr>();
const auto rightIncidencePtr = rightItem.payload<Incidence::Ptr>();
if (leftIncidencePtr->type() == Incidence::TypeEvent) {
reporter->setLeftPropertyValueTitle(i18n("Changed Event"));
......
......@@ -79,7 +79,7 @@ bool CalFilterPartStatusProxyModel::filterAcceptsRow(int source_row, const QMode
return false;
}
const Akonadi::Item item = idx.data(Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
const auto item = idx.data(Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
if (!item.isValid()) {
return false;
}
......@@ -90,7 +90,7 @@ bool CalFilterPartStatusProxyModel::filterAcceptsRow(int source_row, const QMode
}
// Incidences from virtual collections are always ok
const Akonadi::Collection col = idx.data(Akonadi::EntityTreeModel::ParentCollectionRole).value<Akonadi::Collection>();
const auto col = idx.data(Akonadi::EntityTreeModel::ParentCollectionRole).value<Akonadi::Collection>();
if (!d->mFilterVirtual && col.isVirtual()) {
return true;
}
......
......@@ -64,7 +64,7 @@ bool CalFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &so
return false;
}
const Akonadi::Item item = idx.data(Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
const auto item = idx.data(Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
if (!item.isValid()) {
return false;
}
......
......@@ -252,7 +252,7 @@ Akonadi::Collection::List ETMCalendarPrivate::collectionsFromModel(const QAbstra
Akonadi::Item ETMCalendarPrivate::itemFromIndex(const QModelIndex &idx)
{
Akonadi::Item item = idx.data(Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
auto item = idx.data(Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
item.setParentCollection(idx.data(Akonadi::EntityTreeModel::ParentCollectionRole).value<Akonadi::Collection>());
return item;
}
......
......@@ -56,7 +56,7 @@ public:
{
if (role == Qt::CheckStateRole) {
// Don't show the checkbox if the collection can't contain incidences
const Akonadi::Collection collection = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
const auto collection = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
if (isStructuralCollection(collection)) {
return QVariant();
}
......
......@@ -570,7 +570,7 @@ void FreeBusyManagerPrivate::onHandlesFreeBusy(const QString &email, bool handle
return;
}
auto *iface = dynamic_cast<QDBusInterface *>(sender());
auto iface = dynamic_cast<QDBusInterface *>(sender());
if (!iface) {
return;
}
......@@ -632,7 +632,7 @@ void FreeBusyManagerPrivate::onFreeBusyRetrieved(const QString &email, const QSt
return;
}
auto *iface = dynamic_cast<QDBusInterface *>(sender());
auto iface = dynamic_cast<QDBusInterface *>(sender());
if (!iface) {
return;
}
......
......@@ -77,7 +77,7 @@ CreationEntry::CreationEntry(const Akonadi::Item &item, const QString &descripti
{
mLatestRevisionByItemId.insert(item.id(), item.revision());
Q_ASSERT(mItems.count() == 1);
const Incidence::Ptr incidence = mItems.constFirst().payload<KCalendarCore::Incidence::Ptr>();
const auto incidence = mItems.constFirst().payload<KCalendarCore::Incidence::Ptr>();
if (mDescription.isEmpty()) {
mDescription = i18nc("%1 is event, todo or journal", "%1 creation", KCalUtils::Stringify::incidenceType(incidence->type()));
}
......@@ -145,7 +145,7 @@ void CreationEntry::onCreateFinished(int changeId, const Akonadi::Item &item, Ak
DeletionEntry::DeletionEntry(const Akonadi::Item::List &items, const QString &description, History *q)
: Entry(items, description, q)
{
const Incidence::Ptr incidence = items.constFirst().payload<KCalendarCore::Incidence::Ptr>();
const auto incidence = items.constFirst().payload<KCalendarCore::Incidence::Ptr>();
if (mDescription.isEmpty()) {
mDescription = i18nc("%1 is event, todo or journal", "%1 deletion", KCalUtils::Stringify::incidenceType(incidence->type()));
}
......@@ -227,7 +227,7 @@ ModificationEntry::ModificationEntry(const Akonadi::Item &item, const Incidence:
: Entry(item, description, q)
, mOriginalPayload(originalPayload->clone())
{
const Incidence::Ptr incidence = mItems.constFirst().payload<KCalendarCore::Incidence::Ptr>();
const auto incidence = mItems.constFirst().payload<KCalendarCore::Incidence::Ptr>();
if (mDescription.isEmpty()) {
mDescription = i18nc("%1 is event, todo or journal", "%1 modification", KCalUtils::Stringify::incidenceType(incidence->type()));
}
......
......@@ -148,7 +148,7 @@ void MailScheduler::acceptCounterProposal(const KCalendarCore::Incidence::Ptr &i
Result result = ResultSuccess;
if (exInc.isValid() && exInc.hasPayload<KCalendarCore::Incidence::Ptr>()) {
KCalendarCore::Incidence::Ptr exIncPtr = exInc.payload<KCalendarCore::Incidence::Ptr>();
auto exIncPtr = exInc.payload<KCalendarCore::Incidence::Ptr>();
incidence->setRevision(qMax(incidence->revision(), exIncPtr->revision() + 1));
// some stuff we don't want to change, just to be safe
incidence->setSchedulingID(exIncPtr->schedulingID());
......
......@@ -51,7 +51,7 @@ PublishDialog::PublishDialog(QWidget *parent)
connect(d->mUI.mNameLineEdit, &QLineEdit::textChanged, d, &Private::updateItem);
connect(d->mUI.mEmailLineEdit, &QLineEdit::textChanged, d, &Private::updateItem);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, this);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, this);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
......
......@@ -243,7 +243,7 @@ public:
static bool hasWritableCollection(const QModelIndex &index, const QString &mimeType)
{
const Akonadi::Collection collection = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
const auto collection = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
if (collection.isValid()) {
if (collection.contentMimeTypes().contains(mimeType) && (collection.rights() & Akonadi::Collection::CanCreateItem)) {
return true;
......@@ -411,7 +411,7 @@ public:
const QModelIndexList rows = mItemSelectionModel->selectedRows();
if (rows.count() == 1) {
const QModelIndex index = rows.first();
const Collection parentCollection = index.data(EntityTreeModel::ParentCollectionRole).value<Collection>();
const auto parentCollection = index.data(EntityTreeModel::ParentCollectionRole).value<Collection>();
if (parentCollection.isValid()) {
canEditItem = canEditItem && (parentCollection.rights() & Collection::CanChangeItem);
}
......
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