Commit 92adff99 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove deprecated I18N_NOOP macro

parent 55b6ceef
Pipeline #98180 failed with stage
in 24 minutes and 46 seconds
......@@ -5,23 +5,37 @@
*/
#include "formathelpers.h"
#include "ki18n_version.h"
#include "kolabdefinitions.h"
#include <KLocalizedString>
#if KI18N_VERSION >= QT_VERSION_CHECK(5, 89, 0)
#include <klazylocalizedstring.h>
#undef I18N_NOOP
#define I18N_NOOP kli18n
#endif
namespace Kolab
{
static const struct {
const char *name;
#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0)
const char *label;
} folderTypeData[] = {{KOLAB_FOLDER_TYPE_MAIL, ""},
{KOLAB_FOLDER_TYPE_CONTACT, I18N_NOOP("Contacts")},
{KOLAB_FOLDER_TYPE_EVENT, I18N_NOOP("Calendar")},
{KOLAB_FOLDER_TYPE_TASK, I18N_NOOP("Tasks")},
{KOLAB_FOLDER_TYPE_JOURNAL, I18N_NOOP("Journal")},
{KOLAB_FOLDER_TYPE_NOTE, I18N_NOOP("Notes")},
{KOLAB_FOLDER_TYPE_CONFIGURATION, I18N_NOOP("Configuration")},
{KOLAB_FOLDER_TYPE_FREEBUSY, I18N_NOOP("Freebusy")},
{KOLAB_FOLDER_TYPE_FILE, I18N_NOOP("Files")}};
#else
const KLazyLocalizedString label;
#endif
} folderTypeData[] = {
#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0)
{KOLAB_FOLDER_TYPE_MAIL, ""},
#else
{KOLAB_FOLDER_TYPE_MAIL, KLazyLocalizedString()},
#endif
{KOLAB_FOLDER_TYPE_CONTACT, I18N_NOOP("Contacts")},
{KOLAB_FOLDER_TYPE_EVENT, I18N_NOOP("Calendar")},
{KOLAB_FOLDER_TYPE_TASK, I18N_NOOP("Tasks")},
{KOLAB_FOLDER_TYPE_JOURNAL, I18N_NOOP("Journal")},
{KOLAB_FOLDER_TYPE_NOTE, I18N_NOOP("Notes")},
{KOLAB_FOLDER_TYPE_CONFIGURATION, I18N_NOOP("Configuration")},
{KOLAB_FOLDER_TYPE_FREEBUSY, I18N_NOOP("Freebusy")},
{KOLAB_FOLDER_TYPE_FILE, I18N_NOOP("Files")}};
static const int numFolderTypeData = sizeof folderTypeData / sizeof *folderTypeData;
std::string folderAnnotation(FolderType type, bool isDefault)
......@@ -74,9 +88,15 @@ FolderType folderTypeFromString(const std::string &folderTypeName)
FolderType guessFolderTypeFromName(const std::string &name)
{
for (int i = 0; i < numFolderTypeData; ++i) {
#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0)
if (name == i18n(folderTypeData[i].label).toStdString() || name == folderTypeData[i].label) {
return static_cast<FolderType>(i);
}
#else
if (name == KLocalizedString(folderTypeData[i].label).toString().toStdString() || name == folderTypeData[i].label.untranslatedText()) {
return static_cast<FolderType>(i);
}
#endif
}
return MailType;
}
......@@ -84,6 +104,10 @@ FolderType guessFolderTypeFromName(const std::string &name)
std::string nameForFolderType(FolderType type)
{
Q_ASSERT(type >= 0 && type < LastType);
#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0)
return i18n(folderTypeData[type].label).toStdString();
#else
return KLocalizedString(folderTypeData[type].label).toString().toStdString();
#endif
}
}
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