[frameworks/kcalendarcore] src: Add translated names for attendee status and role enums
Allen Winter <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit b715a3b1645179e6356f58b62861a585b0034414 by Allen Winter, on behalf of Volker Krause.
Committed on 14/08/2026 at 14:32.
Pushed by vkrause into branch 'master'.
Add translated names for attendee status and role enums
Moved here from kcalutils.
M +44 -0 src/attendee.cpp
M +20 -0 src/attendee.h
https://invent.kde.org/frameworks/kcalendarcore/-/commit/b715a3b1645179e6356f58b62861a585b0034414
diff --git a/src/attendee.cpp b/src/attendee.cpp
index f765ef0ab..b0ae6b49c 100644
--- a/src/attendee.cpp
+++ b/src/attendee.cpp
@@ -22,6 +22,7 @@
#include "person.h"
#include "person_p.h"
+#include <QCoreApplication>
#include <QDataStream>
using namespace KCalendarCore;
@@ -49,6 +50,11 @@ public:
QString mName;
QString mEmail;
+ static QString tr(const char *s, const char *c = nullptr, int n = -1)
+ {
+ return QCoreApplication::translate("KCalendarCore::AttendeePrivate", s, c, n);
+ }
+
private:
QString sCuType;
CuType mCuType = Attendee::Individual;
@@ -299,6 +305,44 @@ const CustomProperties &Attendee::customProperties() const
return d->mCustomProperties;
}
+QString Attendee::roleName(Attendee::Role role)
+{
+ switch (role) {
+ case Attendee::Chair:
+ return Attendee::Private::tr("Chair", "@item chairperson");
+ case Attendee::ReqParticipant:
+ return Attendee::Private::tr("Participant", "@item participation is required");
+ case Attendee::OptParticipant:
+ return Attendee::Private::tr("Optional Participant", "@item participation is optional");
+ case Attendee::NonParticipant:
+ return Attendee::Private::tr("Observer", "@item non-participant copied for information");
+ }
+ return {};
+}
+
+QString Attendee::statusName(Attendee::PartStat status)
+{
+ switch (status) {
+ case Attendee::NeedsAction:
+ return Attendee::Private::tr("Needs Action", "@item event, to-do or journal needs action");
+ case Attendee::Accepted:
+ return Attendee::Private::tr("Accepted", "@item event, to-do or journal accepted");
+ case Attendee::Declined:
+ return Attendee::Private::tr("Declined", "@item event, to-do or journal declined");
+ case Attendee::Tentative:
+ return Attendee::Private::tr("Tentative", "@item event or to-do tentatively accepted");
+ case Attendee::Delegated:
+ return Attendee::Private::tr("Delegated", "@item event or to-do delegated");
+ case Attendee::Completed:
+ return Attendee::Private::tr("Completed", "@item to-do completed");
+ case Attendee::InProcess:
+ return Attendee::Private::tr("In Process", "@item to-do in process of being completed");
+ case Attendee::None:
+ return Attendee::Private::tr("Unknown", "@item event or to-do status unknown");
+ }
+ return {};
+}
+
QDataStream &KCalendarCore::operator<<(QDataStream &stream, const KCalendarCore::Attendee &attendee)
{
KCalendarCore::Person p(attendee.name(), attendee.email());
diff --git a/src/attendee.h b/src/attendee.h
index 0fbf5db6e..6270c6f48 100644
--- a/src/attendee.h
+++ b/src/attendee.h
@@ -509,6 +509,26 @@ public:
*/
Attendee &operator=(const Attendee &attendee);
+ /*!
+ Returns the translated display name of \a role.
+
+ \param role the Attendee::Role to convert to a string
+ \return the localized string representation of the attendee role
+
+ \since 6.30
+ */
+ [[nodiscard]] static QString roleName(Role role);
+
+ /*!
+ Returns a translated string representation of an Attendee participation status.
+
+ \param status the Attendee::PartStat to convert to a string
+ \return the localized string representation of the attendee status
+
+ \since 6.30
+ */
+ [[nodiscard]] static QString statusName(PartStat status);
+
private:
//@cond PRIVATE
class Private;