Commit 4a9a4017 authored by Laurent Montel's avatar Laurent Montel
Browse files

Port to no deprecated methods

parent a4e891d5
Pipeline #249339 passed with stage
in 6 minutes and 45 seconds
......@@ -36,6 +36,7 @@
#include <QMimeData>
#include <QMimeDatabase>
#include <QMimeType>
#include <kwidgetsaddons_version.h>
using namespace IncidenceEditorNG;
......@@ -188,13 +189,22 @@ void IncidenceAttachment::removeSelectedAttachments()
QString labelsStr = labels.join(QLatin1String("<nl/>"));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::questionTwoActions(nullptr,
#else
if (KMessageBox::questionYesNo(nullptr,
xi18nc("@info", "Do you really want to remove these attachments?<nl/>%1", labelsStr),
i18nc("@title:window", "Remove Attachments?"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel(),
QStringLiteral("calendarRemoveAttachments"))
#endif
xi18nc("@info", "Do you really want to remove these attachments?<nl/>%1", labelsStr),
i18nc("@title:window", "Remove Attachments?"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel(),
QStringLiteral("calendarRemoveAttachments"))
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
!= KMessageBox::ButtonCode::PrimaryAction) {
#else
!= KMessageBox::Yes) {
#endif
return;
}
......
......@@ -36,6 +36,7 @@
#include <KMessageBox>
#include <QPointer>
#include <QTreeView>
#include <kwidgetsaddons_version.h>
using namespace IncidenceEditorNG;
......@@ -199,14 +200,19 @@ void IncidenceAttendee::save(const KCalendarCore::Incidence::Ptr &incidence)
continue;
}
if (KEmailAddress::isValidAddress(attendee.email())) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (KMessageBox::warningTwoActions(nullptr,
#else
if (KMessageBox::warningYesNo(nullptr,
i18nc("@info",
"%1 does not look like a valid email address. "
"Are you sure you want to invite this participant?",
attendee.email()),
i18nc("@title:window", "Invalid Email Address"),
KGuiItem(i18nc("@action:button", "Invite"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Invite"), QStringLiteral("dialog-cancel")))
#endif
i18nc("@info",
"%1 does not look like a valid email address. "
"Are you sure you want to invite this participant?",
attendee.email()),
i18nc("@title:window", "Invalid Email Address"),
KGuiItem(i18nc("@action:button", "Invite"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Invite"), QStringLiteral("dialog-cancel")))
!= KMessageBox::Yes) {
skip = true;
}
......@@ -774,19 +780,27 @@ void IncidenceAttendee::slotOrganizerChanged(const QString &newOrganizer)
int answer;
if (currentOrganizerAttendee > -1) {
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
answer = KMessageBox::questionTwoActions(mParentWidget,
#else
answer = KMessageBox::questionYesNo(mParentWidget,
i18nc("@option",
"You are changing the organizer of this event. "
"Since the organizer is also attending this event, would you "
"like to change the corresponding attendee as well?"),
QString(),
KGuiItem(i18nc("@action:button", "Change Attendee"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Change"), QStringLiteral("dialog-cancel")));
#endif
i18nc("@option",
"You are changing the organizer of this event. "
"Since the organizer is also attending this event, would you "
"like to change the corresponding attendee as well?"),
QString(),
KGuiItem(i18nc("@action:button", "Change Attendee"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Change"), QStringLiteral("dialog-cancel")));
} else {
answer = KMessageBox::Yes;
}
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
if (currentOrganizerAttendee > -1) {
mDataModel->removeRows(currentOrganizerAttendee, 1);
}
......
......@@ -41,6 +41,7 @@
#include <KMessageBox>
#include <KSharedConfig>
#include <kwidgetsaddons_version.h>
#include <KWindowConfig>
#include <QCloseEvent>
......@@ -455,12 +456,20 @@ void IncidenceDialogPrivate::handleItemSaveFail(EditorItemManager::SaveAction, c
"Unable to store the incidence in the calendar. Try again?\n\n "
"Reason: %1",
errorMessage);
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::warningTwoActions(q,
#else
const int answer = KMessageBox::warningYesNo(q,
message,
QString(),
KGuiItem(i18nc("@action:button", "Retry"), QStringLiteral("dialog-ok")),
KStandardGuiItem::cancel());
#endif
message,
QString(),
KGuiItem(i18nc("@action:button", "Retry"), QStringLiteral("dialog-ok")),
KStandardGuiItem::cancel());
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
retry = (answer == KMessageBox::ButtonCode::PrimaryAction);
#else
retry = (answer == KMessageBox::Yes);
#endif
}
if (retry) {
......@@ -486,13 +495,21 @@ void IncidenceDialogPrivate::handleItemSaveFinish(EditorItemManager::SaveAction
"<para>Would you like to set your default events calendar to "
"<resource>%1</resource>?</para>",
collectionName);
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
const int answer = KMessageBox::questionTwoActions(q,
#else
const int answer = KMessageBox::questionYesNo(q,
message,
i18nc("@title:window", "Set Default Calendar?"),
KGuiItem(i18nc("@action:button", "Set As Default"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Set"), QStringLiteral("dialog-cancel")),
QStringLiteral("setDefaultCalendarCollection"));
#endif
message,
i18nc("@title:window", "Set Default Calendar?"),
KGuiItem(i18nc("@action:button", "Set As Default"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Set"), QStringLiteral("dialog-cancel")),
QStringLiteral("setDefaultCalendarCollection"));
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
if (answer == KMessageBox::ButtonCode::PrimaryAction) {
#else
if (answer == KMessageBox::Yes) {
#endif
CalendarSupport::KCalPrefs::instance()->setDefaultCalendarId(mItem.storageCollectionId());
}
}
......@@ -776,12 +793,20 @@ void IncidenceDialog::slotButtonClicked(QAbstractButton *button)
d->mItemManager->save();
} else if (d->mUi->buttonBox->button(QDialogButtonBox::Cancel) == button) {
if (d->isDirty()
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
&& KMessageBox::questionTwoActions(this,
#else
&& KMessageBox::questionYesNo(this,
i18nc("@info", "Do you really want to cancel?"),
i18nc("@title:window", "KOrganizer Confirmation"),
KGuiItem(i18nc("@action:button", "Cancel Editing"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Cancel"), QStringLiteral("dialog-cancel")))
#endif
i18nc("@info", "Do you really want to cancel?"),
i18nc("@title:window", "KOrganizer Confirmation"),
KGuiItem(i18nc("@action:button", "Cancel Editing"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Cancel"), QStringLiteral("dialog-cancel")))
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
== KMessageBox::ButtonCode::PrimaryAction) {
#else
== KMessageBox::Yes) {
#endif
QDialog::reject(); // Discard current changes
} else if (!d->isDirty()) {
QDialog::reject(); // No pending changes, just close the dialog.
......@@ -797,12 +822,20 @@ void IncidenceDialog::reject()
{
Q_D(IncidenceDialog);
if (d->isDirty()
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
&& KMessageBox::questionTwoActions(this,
#else
&& KMessageBox::questionYesNo(this,
i18nc("@info", "Do you really want to cancel?"),
i18nc("@title:window", "KOrganizer Confirmation"),
KGuiItem(i18nc("@action:button", "Cancel Editing"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Cancel"), QStringLiteral("dialog-cancel")))
#endif
i18nc("@info", "Do you really want to cancel?"),
i18nc("@title:window", "KOrganizer Confirmation"),
KGuiItem(i18nc("@action:button", "Cancel Editing"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Cancel"), QStringLiteral("dialog-cancel")))
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
== KMessageBox::ButtonCode::PrimaryAction) {
#else
== KMessageBox::Yes) {
#endif
QDialog::reject(); // Discard current changes
} else if (!d->isDirty()) {
QDialog::reject(); // No pending changes, just close the dialog.
......@@ -813,12 +846,20 @@ void IncidenceDialog::closeEvent(QCloseEvent *event)
{
Q_D(IncidenceDialog);
if (d->isDirty()
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
&& KMessageBox::questionTwoActions(this,
#else
&& KMessageBox::questionYesNo(this,
i18nc("@info", "Do you really want to cancel?"),
i18nc("@title:window", "KOrganizer Confirmation"),
KGuiItem(i18nc("@action:button", "Cancel Editing"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Cancel"), QStringLiteral("dialog-cancel")))
#endif
i18nc("@info", "Do you really want to cancel?"),
i18nc("@title:window", "KOrganizer Confirmation"),
KGuiItem(i18nc("@action:button", "Cancel Editing"), QStringLiteral("dialog-ok")),
KGuiItem(i18nc("@action:button", "Do Not Cancel"), QStringLiteral("dialog-cancel")))
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
== KMessageBox::ButtonCode::PrimaryAction) {
#else
== KMessageBox::Yes) {
#endif
QDialog::reject(); // Discard current changes
QDialog::closeEvent(event);
} else if (!d->isDirty()) {
......
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