Changeset View
Changeset View
Standalone View
Standalone View
resources/kolab/kolabhelpers.cpp
Show All 21 Lines | |||||
#include <KCalCore/Incidence> | #include <KCalCore/Incidence> | ||||
#include <Akonadi/Collection> | #include <Akonadi/Collection> | ||||
#include <Akonadi/ItemFetchJob> | #include <Akonadi/ItemFetchJob> | ||||
#include <Akonadi/ItemFetchScope> | #include <Akonadi/ItemFetchScope> | ||||
#include <akonadi/notes/noteutils.h> | #include <akonadi/notes/noteutils.h> | ||||
#include <kolabobject.h> | #include <kolabobject.h> | ||||
#include <errorhandler.h> | #include <errorhandler.h> | ||||
#include <KLocalizedString> | #include <KLocalizedString> | ||||
#include <QColor> | |||||
#include "tracer.h" | #include "tracer.h" | ||||
bool KolabHelpers::checkForErrors(const Akonadi::Item &item) | bool KolabHelpers::checkForErrors(const Akonadi::Item &item) | ||||
{ | { | ||||
if (!Kolab::ErrorHandler::instance().errorOccured()) { | if (!Kolab::ErrorHandler::instance().errorOccured()) { | ||||
Kolab::ErrorHandler::instance().clear(); | Kolab::ErrorHandler::instance().clear(); | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 389 Lines • ▼ Show 20 Lines | QByteArray KolabHelpers::getFolderTypeAnnotation(const QMap< QByteArray, QByteArray > &annotations) | ||||
return annotations.value(KOLAB_FOLDER_TYPE_ANNOTATION); | return annotations.value(KOLAB_FOLDER_TYPE_ANNOTATION); | ||||
} | } | ||||
void KolabHelpers::setFolderTypeAnnotation(QMap< QByteArray, QByteArray >& annotations, const QByteArray& value) | void KolabHelpers::setFolderTypeAnnotation(QMap< QByteArray, QByteArray >& annotations, const QByteArray& value) | ||||
{ | { | ||||
annotations["/shared" KOLAB_FOLDER_TYPE_ANNOTATION] = value; | annotations["/shared" KOLAB_FOLDER_TYPE_ANNOTATION] = value; | ||||
} | } | ||||
QColor KolabHelpers::getFolderColor(const QMap<QByteArray, QByteArray> &annotations) | |||||
{ | |||||
// kolab saves the color without a "#", so we need to add it to the rgb string to have a propper QColor | |||||
if (annotations.contains("/shared" KOLAB_COLOR_ANNOTATION) && !annotations.value("/shared" KOLAB_COLOR_ANNOTATION).isEmpty()) { | |||||
return QColor(QLatin1String("#") + annotations.value("/shared" KOLAB_COLOR_ANNOTATION)); | |||||
} else if (annotations.contains("/private" KOLAB_COLOR_ANNOTATION) && !annotations.value("/private" KOLAB_COLOR_ANNOTATION).isEmpty()) { | |||||
return QColor(QLatin1String("#") + annotations.value("/private" KOLAB_COLOR_ANNOTATION)); | |||||
} | |||||
return QColor(); | |||||
} | |||||
void KolabHelpers::setFolderColor(QMap<QByteArray, QByteArray> &annotations, const QColor &color) | |||||
{ | |||||
// kolab saves the color without a "#", so we need to delete the prefix "#" if we save it to the annotations | |||||
annotations["/shared" KOLAB_COLOR_ANNOTATION] = color.name().toAscii().remove(0,1); | |||||
} | |||||
QString KolabHelpers::getIcon(Kolab::FolderType type) | QString KolabHelpers::getIcon(Kolab::FolderType type) | ||||
{ | { | ||||
switch (type) { | switch (type) { | ||||
case Kolab::EventType: | case Kolab::EventType: | ||||
case Kolab::TaskType: | case Kolab::TaskType: | ||||
case Kolab::JournalType: | case Kolab::JournalType: | ||||
return QLatin1String("view-calendar"); | return QLatin1String("view-calendar"); | ||||
case Kolab::ContactType: | case Kolab::ContactType: | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |