Commit d514594f authored by Volker Krause's avatar Volker Krause Committed by Laurent Montel
Browse files

Adapt to displayName() having been moved to akonadi-calendar

parent 4e9ce531
Pipeline #173478 passed with stage
in 3 minutes and 41 seconds
......@@ -42,7 +42,7 @@ set(QT_REQUIRED_VERSION "5.15.2")
set(KMIME_LIB_VERSION "5.20.40")
set(CALENDARUTILS_LIB_VERSION "5.20.40")
set(IDENTITYMANAGEMENT_LIB_VERSION "5.20.40")
set(AKONADICALENDAR_LIB_VERSION "5.20.42")
set(AKONADICALENDAR_LIB_VERSION "5.20.43")
set(AKONADI_VERSION "5.20.40")
set(AKONADI_NOTES_VERSION "5.20.40")
find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED)
......
......@@ -77,7 +77,7 @@ public:
QString text;
if (mCurrentItem.isValid()) {
text = KCalUtils::IncidenceFormatter::extensiveDisplayStr(CalendarSupport::displayName(mCalendar, mParentCollection),
text = KCalUtils::IncidenceFormatter::extensiveDisplayStr(Akonadi::CalendarUtils::displayName(mCalendar, mParentCollection),
Akonadi::CalendarUtils::incidence(mCurrentItem),
mDate);
text.prepend(mHeaderText);
......
......@@ -420,135 +420,6 @@ Akonadi::Collection::List CalendarSupport::collectionsFromIndexes(const QModelIn
return l;
}
QString CalendarSupport::displayName(Akonadi::ETMCalendar *calendar, const Akonadi::Collection &c)
{
Akonadi::Collection fullCollection;
if (calendar && calendar->collection(c.id()).isValid()) {
fullCollection = calendar->collection(c.id());
} else {
fullCollection = c;
}
QString cName = fullCollection.name();
const QString resourceName = fullCollection.resource();
// Kolab Groupware
if (resourceName.contains(QLatin1String("kolab"))) {
QString typeStr = cName; // contents type: "Calendar", "Tasks", etc
QString ownerStr; // folder owner: "fred", "ethel", etc
QString nameStr; // folder name: "Public", "Test", etc
if (calendar) {
Akonadi::Collection p = c.parentCollection();
while (p != Akonadi::Collection::root()) {
Akonadi::Collection tCol = calendar->collection(p.id());
const QString tName = tCol.name();
if (tName.startsWith(QLatin1String("shared.cal"), Qt::CaseInsensitive)) {
ownerStr = QStringLiteral("Shared");
nameStr = cName;
typeStr = i18n("Calendar");
break;
} else if (tName.startsWith(QLatin1String("shared.tasks"), Qt::CaseInsensitive)
|| tName.startsWith(QLatin1String("shared.todo"), Qt::CaseInsensitive)) {
ownerStr = QStringLiteral("Shared");
nameStr = cName;
typeStr = i18n("Tasks");
break;
} else if (tName.startsWith(QLatin1String("shared.journal"), Qt::CaseInsensitive)) {
ownerStr = QStringLiteral("Shared");
nameStr = cName;
typeStr = i18n("Journal");
break;
} else if (tName.startsWith(QLatin1String("shared.notes"), Qt::CaseInsensitive)) {
ownerStr = QStringLiteral("Shared");
nameStr = cName;
typeStr = i18n("Notes");
break;
} else if (tName != i18n("Calendar") && tName != i18n("Tasks") && tName != i18n("Journal") && tName != i18n("Notes")) {
ownerStr = tName;
break;
} else {
nameStr = typeStr;
typeStr = tName;
}
p = p.parentCollection();
}
}
if (!ownerStr.isEmpty()) {
if (!ownerStr.compare(QLatin1String("INBOX"), Qt::CaseInsensitive)) {
return i18nc("%1 is folder contents", "My Kolab %1", typeStr);
} else if (!ownerStr.compare(QLatin1String("SHARED"), Qt::CaseInsensitive) || !ownerStr.compare(QLatin1String("CALENDAR"), Qt::CaseInsensitive)
|| !ownerStr.compare(QLatin1String("RESOURCES"), Qt::CaseInsensitive)) {
return i18nc("%1 is folder name, %2 is folder contents", "Shared Kolab %1 %2", nameStr, typeStr);
} else {
if (nameStr.isEmpty()) {
return i18nc("%1 is folder owner name, %2 is folder contents", "%1's Kolab %2", ownerStr, typeStr);
} else {
return i18nc("%1 is folder owner name, %2 is folder name, %3 is folder contents", "%1's %2 Kolab %3", ownerStr, nameStr, typeStr);
}
}
} else {
return i18nc("%1 is folder contents", "Kolab %1", typeStr);
}
} // end kolab section
// Dav Groupware
if (resourceName.contains(QLatin1String("davgroupware"))) {
const QString resourceDisplayName = Akonadi::AgentManager::self()->instance(resourceName).name();
return i18nc("%1 is the folder name", "%1 in %2", fullCollection.displayName(), resourceDisplayName);
} // end caldav section
// Google
if (resourceName.contains(QLatin1String("google"))) {
QString ownerStr; // folder owner: "user@gmail.com"
if (calendar) {
Akonadi::Collection p = c.parentCollection();
ownerStr = calendar->collection(p.id()).displayName();
}
const QString nameStr = c.displayName(); // folder name: can be anything
QString typeStr;
const QString mimeStr = c.contentMimeTypes().join(QLatin1Char(','));
if (mimeStr.contains(QLatin1String(".event"))) {
typeStr = i18n("Calendar");
} else if (mimeStr.contains(QLatin1String(".todo"))) {
typeStr = i18n("Tasks");
} else if (mimeStr.contains(QLatin1String(".journal"))) {
typeStr = i18n("Journal");
} else if (mimeStr.contains(QLatin1String(".note"))) {
typeStr = i18n("Notes");
} else {
typeStr = mimeStr;
}
if (!ownerStr.isEmpty()) {
const int atChar = ownerStr.lastIndexOf(QLatin1Char('@'));
if (atChar >= 0) {
ownerStr.truncate(atChar);
}
if (nameStr.isEmpty()) {
return i18nc("%1 is folder owner name, %2 is folder contents", "%1's Google %2", ownerStr, typeStr);
} else {
return i18nc("%1 is folder owner name, %2 is folder name", "%1's %2", ownerStr, nameStr);
}
} else {
return i18nc("%1 is folder contents", "Google %1", typeStr);
}
} // end google section
// Not groupware so the collection is "mine"
const QString dName = fullCollection.displayName();
if (!dName.isEmpty()) {
return fullCollection.name().startsWith(QLatin1String("akonadi_")) ? i18n("My %1", dName) : dName;
} else if (!fullCollection.name().isEmpty()) {
return fullCollection.name();
} else {
return i18nc("unknown resource", "Unknown");
}
}
QString CalendarSupport::toolTipString(const Akonadi::Collection &coll, bool richText)
{
Q_UNUSED(richText)
......
......@@ -171,8 +171,6 @@ CALENDARSUPPORT_EXPORT Akonadi::Collection::Id collectionIdFromIndex(const QMode
CALENDARSUPPORT_EXPORT Akonadi::Collection::List collectionsFromIndexes(const QModelIndexList &indexes);
CALENDARSUPPORT_EXPORT QString displayName(Akonadi::ETMCalendar *calendar, const Akonadi::Collection &coll);
CALENDARSUPPORT_EXPORT QString subMimeTypeForIncidence(const KCalendarCore::Incidence::Ptr &incidence);
/**
......
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