22 #include "messagetag.h"
24 #include <soprano/nao.h>
25 #include <Nepomuk2/Tag>
26 #include <Nepomuk2/Variant>
29 using namespace MailCommon;
34 tag->tagName = nepomukTag.label();
36 tag->iconName = nepomukTag.genericIcon();
37 if ( tag->iconName.isEmpty() )
38 tag->iconName = QLatin1String(
"mail-tagged");
40 tag->nepomukResourceUri = nepomukTag.uri();
42 const QString identifier = nepomukTag.property( Soprano::Vocabulary::NAO::identifier() ).toString();
43 tag->tagStatus = (identifier == QLatin1String(
"important")) ||
44 (identifier == QLatin1String(
"todo")) ||
45 (identifier == QLatin1String(
"watched")) ||
46 (identifier == QLatin1String(
"deleted")) ||
47 (identifier == QLatin1String(
"spam")) ||
48 (identifier == QLatin1String(
"replied")) ||
49 (identifier == QLatin1String(
"ignored")) ||
50 (identifier == QLatin1String(
"forwarded")) ||
51 (identifier == QLatin1String(
"sent")) ||
52 (identifier == QLatin1String(
"queued")) ||
53 (identifier == QLatin1String(
"ham"));
55 if ( nepomukTag.hasProperty( Vocabulary::MessageTag::textColor() ) ) {
56 const QString name = nepomukTag.property( Vocabulary::MessageTag::textColor() ).toString();
57 tag->textColor = QColor( name );
60 if ( nepomukTag.hasProperty( Vocabulary::MessageTag::backgroundColor() ) ) {
61 const QString name = nepomukTag.property( Vocabulary::MessageTag::backgroundColor() ).toString();
62 tag->backgroundColor = QColor( name );
65 if ( nepomukTag.hasProperty( Vocabulary::MessageTag::font() ) ) {
66 const QString fontString = nepomukTag.property( Vocabulary::MessageTag::font() ).toString();
68 font.fromString( fontString );
72 if ( nepomukTag.hasProperty( Vocabulary::MessageTag::priority() ) ) {
73 tag->priority = nepomukTag.property( Vocabulary::MessageTag::priority() ).toInt();
78 if ( nepomukTag.hasProperty( Vocabulary::MessageTag::shortcut() ) ) {
79 tag->shortcut = KShortcut( nepomukTag.property( Vocabulary::MessageTag::shortcut() ).toString() );
82 if ( nepomukTag.hasProperty( Vocabulary::MessageTag::inToolbar() ) ) {
83 tag->inToolbar = nepomukTag.property( Vocabulary::MessageTag::inToolbar() ).toBool();
86 tag->inToolbar =
false;
97 Nepomuk2::Resource symbol( QUrl(), Soprano::Vocabulary::NAO::FreeDesktopIcon() );
98 symbol.setProperty( Soprano::Vocabulary::NAO::iconName(),
iconName );
100 nepomukTag.setProperty( Soprano::Vocabulary::NAO::hasSymbol(), symbol );
102 nepomukTag.setProperty( Vocabulary::MessageTag::priority(),
priority );
103 nepomukTag.setProperty( Vocabulary::MessageTag::inToolbar(),
inToolbar );
104 nepomukTag.setProperty( Vocabulary::MessageTag::shortcut(),
shortcut.toString() );
107 nepomukTag.setProperty( Vocabulary::MessageTag::textColor(),
textColor.name() );
109 nepomukTag.removeProperty( Vocabulary::MessageTag::textColor() );
112 nepomukTag.setProperty( Vocabulary::MessageTag::backgroundColor(),
backgroundColor.name() );
114 nepomukTag.removeProperty( Vocabulary::MessageTag::backgroundColor() );
116 if ( saveFlags &
Font )
117 nepomukTag.setProperty( Vocabulary::MessageTag::font(),
textFont.toString() );
119 nepomukTag.removeProperty( Vocabulary::MessageTag::font() );
124 if ( tag1->priority < tag2->priority )
126 else if (tag1->priority == tag2->priority)
127 return ( tag1->tagName < tag2->tagName );
134 return ( tag1->tagName < tag2->tagName );
152 return !( *
this == other );
static Ptr fromNepomuk(const Nepomuk2::Tag &nepomukTag)
void saveToNepomuk(SaveFlags saveFlags) const
static bool compareName(Ptr &tag1, Ptr &tag2)
QFlags< SaveFlag > SaveFlags
bool operator==(const Tag &other) const
bool operator!=(const Tag &other) const
static bool compare(Ptr &tag1, Ptr &tag2)