Make compile without deprecated methods

wilder-rebase
Laurent Montel 4 years ago
parent dc61356ded
commit 66e511ecf2
  1. 4
      CMakeLists.txt
  2. 15
      src/mdn/mdnadvicehelper.cpp
  3. 39
      src/search/searchrule/searchrulestatus.h
  4. 74
      src/search/widgethandler/statusrulewidgethandler.cpp

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set(PIM_VERSION "5.19.40")
set(PIM_VERSION "5.19.41")
project(mailcommon VERSION ${PIM_VERSION})
@ -101,7 +101,7 @@ endif()
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f02)
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055800)
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055900)
########### CMake Config Files ###########
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5MailCommon")

@ -6,13 +6,18 @@
#include "mdnadvicehelper.h"
#include "filter/mdnadvicedialog.h"
#include "ki18n_version.h"
#include "mailcommon_debug.h"
#include <Akonadi/ItemModifyJob>
#include <KLocalizedString>
#include <MessageComposer/Util>
#include <MessageViewer/MessageViewerSettings>
#include <QPointer>
#if KI18N_VERSION >= QT_VERSION_CHECK(5, 89, 0)
#include <klazylocalizedstring.h>
#undef I18N_NOOP
#define I18N_NOOP kli18n
#endif
#include <KCursorSaver>
using MessageComposer::MessageFactoryNG;
using namespace MailCommon;
@ -20,7 +25,11 @@ using namespace MailCommon;
static const struct {
const char *dontAskAgainID;
bool canDeny;
#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0)
const char *text;
#else
const KLazyLocalizedString text;
#endif
} mdnMessageBoxes[] = {
{"mdnNormalAsk",
true,
@ -188,7 +197,11 @@ int MDNAdviceHelper::requestAdviceOnMDN(const char *what)
for (int i = 0; i < numMdnMessageBoxes; ++i) {
if (!qstrcmp(what, mdnMessageBoxes[i].dontAskAgainID)) {
KCursorSaver saver(Qt::ArrowCursor);
#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0)
const MessageComposer::MDNAdvice answer = questionIgnoreSend(i18n(mdnMessageBoxes[i].text), mdnMessageBoxes[i].canDeny);
#else
const MessageComposer::MDNAdvice answer = questionIgnoreSend(KLocalizedString(mdnMessageBoxes[i].text).toString(), mdnMessageBoxes[i].canDeny);
#endif
switch (answer) {
case MessageComposer::MDNSend:
return 3;

@ -8,42 +8,17 @@
#include <Akonadi/Item>
#include "ki18n_version.h"
#include "mailcommon/searchpattern.h"
#include <Akonadi/KMime/MessageStatus>
#if KI18N_VERSION >= QT_VERSION_CHECK(5, 89, 0)
#include <klazylocalizedstring.h>
#undef I18NC_NOOP
#define I18NC_NOOP kli18nc
#endif
namespace MailCommon
{
// TODO: Check if the below one is needed or not!
// The below are used in several places and here so they are accessible.
struct MessageStatusInfo {
const char *context;
const char *text;
const char *icon;
};
// If you change the ordering here; also do it in the enum below
static const MessageStatusInfo StatusValues[] = {
{I18NC_NOOP("message status", "Important"), "emblem-important"},
{I18NC_NOOP("message status", "Action Item"), "mail-task"},
{I18NC_NOOP("message status", "Unread"), "mail-unread"},
{I18NC_NOOP("message status", "Read"), "mail-read"},
{I18NC_NOOP("message status", "Deleted"), "mail-deleted"},
{I18NC_NOOP("message status", "Replied"), "mail-replied"},
{I18NC_NOOP("message status", "Forwarded"), "mail-forwarded"},
{I18NC_NOOP("message status", "Queued"), "mail-queued"},
{I18NC_NOOP("message status", "Sent"), "mail-sent"},
{I18NC_NOOP("message status", "Watched"), "mail-thread-watch"},
{I18NC_NOOP("message status", "Ignored"), "mail-thread-ignored"},
{I18NC_NOOP("message status", "Spam"), "mail-mark-junk"},
{I18NC_NOOP("message status", "Ham"), "mail-mark-notjunk"},
{I18NC_NOOP("message status", "Has Attachment"), "mail-attachment"} // must be last
};
static const int StatusValueCount = sizeof(StatusValues) / sizeof(MessageStatusInfo);
// we want to show all status entries in the quick search bar, but only the
// ones up to attachment in the search/filter dialog, because there the
// attachment case is handled separately.
static const int StatusValueCountWithoutHidden = StatusValueCount - 1;
/**
* This class represents a search to be performed against the status of a
* message. The status is represented by a bitfield.

@ -28,6 +28,40 @@ static const struct {
} StatusFunctions[] = {{SearchRule::FuncContains, I18N_NOOP("is")}, {SearchRule::FuncContainsNot, I18N_NOOP("is not")}};
static const int StatusFunctionCount = sizeof(StatusFunctions) / sizeof(*StatusFunctions);
struct MessageStatusInfo {
#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0)
const char *context;
const char *text;
#else
const KLazyLocalizedString text;
#endif
const char *icon;
};
// If you change the ordering here; also do it in the enum below
static const MessageStatusInfo StatusValues[] = {
{I18NC_NOOP("message status", "Important"), "emblem-important"},
{I18NC_NOOP("message status", "Action Item"), "mail-task"},
{I18NC_NOOP("message status", "Unread"), "mail-unread"},
{I18NC_NOOP("message status", "Read"), "mail-read"},
{I18NC_NOOP("message status", "Deleted"), "mail-deleted"},
{I18NC_NOOP("message status", "Replied"), "mail-replied"},
{I18NC_NOOP("message status", "Forwarded"), "mail-forwarded"},
{I18NC_NOOP("message status", "Queued"), "mail-queued"},
{I18NC_NOOP("message status", "Sent"), "mail-sent"},
{I18NC_NOOP("message status", "Watched"), "mail-thread-watch"},
{I18NC_NOOP("message status", "Ignored"), "mail-thread-ignored"},
{I18NC_NOOP("message status", "Spam"), "mail-mark-junk"},
{I18NC_NOOP("message status", "Ham"), "mail-mark-notjunk"},
{I18NC_NOOP("message status", "Has Attachment"), "mail-attachment"} // must be last
};
static const int StatusValueCount = sizeof(StatusValues) / sizeof(MessageStatusInfo);
// we want to show all status entries in the quick search bar, but only the
// ones up to attachment in the search/filter dialog, because there the
// attachment case is handled separately.
static const int StatusValueCountWithoutHidden = StatusValueCount - 1;
//---------------------------------------------------------------------------
QWidget *StatusRuleWidgetHandler::createFunctionWidget(int number, QStackedWidget *functionStack, const QObject *receiver, bool /*isBalooSearch*/) const
@ -62,11 +96,19 @@ QWidget *StatusRuleWidgetHandler::createValueWidget(int number, QStackedWidget *
auto statusCombo = new QComboBox(valueStack);
statusCombo->setMinimumWidth(50);
statusCombo->setObjectName(QStringLiteral("statusRuleValueCombo"));
for (int i = 0; i < MailCommon::StatusValueCountWithoutHidden; ++i) {
if (MailCommon::StatusValues[i].icon != nullptr) {
statusCombo->addItem(QIcon::fromTheme(QLatin1String(MailCommon::StatusValues[i].icon)), i18nc("message status", MailCommon::StatusValues[i].text));
for (int i = 0; i < StatusValueCountWithoutHidden; ++i) {
if (StatusValues[i].icon != nullptr) {
#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0)
statusCombo->addItem(QIcon::fromTheme(QLatin1String(StatusValues[i].icon)), i18nc("message status", StatusValues[i].text));
#else
statusCombo->addItem(QIcon::fromTheme(QLatin1String(StatusValues[i].icon)), KLocalizedString(StatusValues[i].text).toString());
#endif
} else {
statusCombo->addItem(i18nc("message status", MailCommon::StatusValues[i].text));
#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0)
statusCombo->addItem(i18nc("message status", StatusValues[i].text));
#else
statusCombo->addItem(KLocalizedString(StatusValues[i].text).toString());
#endif
}
}
statusCombo->adjustSize();
@ -121,7 +163,11 @@ QString StatusRuleWidgetHandler::value(const QByteArray &field, const QStackedWi
const int status = currentStatusValue(valueStack);
if (status != -1) {
return QString::fromLatin1(MailCommon::StatusValues[status].text);
#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0)
return QString::fromLatin1(StatusValues[status].text);
#else
return KLocalizedString(StatusValues[status].text).untranslatedText();
#endif
} else {
return QString();
}
@ -137,7 +183,11 @@ QString StatusRuleWidgetHandler::prettyValue(const QByteArray &field, const QSta
const int status = currentStatusValue(valueStack);
if (status != -1) {
return i18nc("message status", MailCommon::StatusValues[status].text);
#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0)
return QString::fromLatin1(StatusValues[status].text);
#else
return KLocalizedString(StatusValues[status].text).toString();
#endif
} else {
return QString();
}
@ -207,17 +257,23 @@ bool StatusRuleWidgetHandler::setRule(QStackedWidget *functionStack, QStackedWid
// set the value
const QString value = rule->contents();
int valueIndex = 0;
for (; valueIndex < MailCommon::StatusValueCountWithoutHidden; ++valueIndex) {
if (value == QString::fromLatin1(MailCommon::StatusValues[valueIndex].text)) {
for (; valueIndex < StatusValueCountWithoutHidden; ++valueIndex) {
#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0)
if (value == QString::fromLatin1(StatusValues[valueIndex].text)) {
break;
}
#else
if (value == KLocalizedString(StatusValues[valueIndex].text).untranslatedText()) {
break;
}
#endif
}
const auto statusCombo = valueStack->findChild<QComboBox *>(QStringLiteral("statusRuleValueCombo"));
if (statusCombo) {
statusCombo->blockSignals(true);
if (valueIndex < MailCommon::StatusValueCountWithoutHidden) {
if (valueIndex < StatusValueCountWithoutHidden) {
statusCombo->setCurrentIndex(valueIndex);
} else {
statusCombo->setCurrentIndex(0);

Loading…
Cancel
Save