• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

knotes

  • sources
  • kde-4.14
  • kdepim
  • knotes
  • print
knoteprintobject.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013-2015 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "knoteprintobject.h"
19 #include "noteshared/attributes/notealarmattribute.h"
20 #include "noteshared/attributes/notelockattribute.h"
21 #include "noteshared/attributes/notedisplayattribute.h"
22 
23 
24 #include <KMime/KMimeMessage>
25 
26 #include <KLocale>
27 #include <KLocalizedString>
28 #include <KGlobal>
29 
30 KNotePrintObject::KNotePrintObject(const Akonadi::Item &item, QObject *parent)
31  : QObject(parent),
32  mItem(item)
33 {
34 }
35 
36 KNotePrintObject::~KNotePrintObject()
37 {
38 
39 }
40 
41 QString KNotePrintObject::description() const
42 {
43  KMime::Message::Ptr noteMessage = mItem.payload<KMime::Message::Ptr>();
44  if ( noteMessage->contentType()->isHTMLText() ) {
45  return noteMessage->mainBodyPart()->decodedText();
46  } else {
47  return noteMessage->mainBodyPart()->decodedText().replace(QLatin1Char('\n'), QLatin1String("<br>"));
48  }
49 }
50 
51 QString KNotePrintObject::name() const
52 {
53  KMime::Message::Ptr noteMessage = mItem.payload<KMime::Message::Ptr>();
54  const KMime::Headers::Subject * const subject = noteMessage ? noteMessage->subject(false) : 0;
55  return subject ? subject->asUnicodeString() : QString();
56 }
57 
58 QString KNotePrintObject::currentDateTime() const
59 {
60  const QDateTime now = QDateTime::currentDateTime();
61  return KGlobal::locale()->formatDateTime( now );
62 }
63 
64 bool KNotePrintObject::hasAlarm() const
65 {
66  return mItem.hasAttribute<NoteShared::NoteAlarmAttribute>();
67 }
68 
69 QString KNotePrintObject::alarm() const
70 {
71  NoteShared::NoteAlarmAttribute *attr = mItem.attribute<NoteShared::NoteAlarmAttribute>();
72  if (attr) {
73  return KGlobal::locale()->formatDateTime(attr->dateTime(),KLocale::LongDate);
74  }
75  return QString();
76 }
77 
78 bool KNotePrintObject::isLock() const
79 {
80  return mItem.hasAttribute<NoteShared::NoteLockAttribute>();
81 }
82 
83 QString KNotePrintObject::backgroundColorName() const
84 {
85  if (mItem.hasAttribute<NoteShared::NoteDisplayAttribute>()) {
86  return mItem.attribute<NoteShared::NoteDisplayAttribute>()->backgroundColor().name();
87  }
88  return QString();
89 }
KNotePrintObject::description
QString description() const
KNotePrintObject::name
QString name() const
KNotePrintObject::isLock
bool isLock() const
KNotePrintObject::hasAlarm
bool hasAlarm() const
KNotePrintObject::alarm
QString alarm() const
KNotePrintObject::~KNotePrintObject
~KNotePrintObject()
Definition: knoteprintobject.cpp:36
knoteprintobject.h
QObject
KNotePrintObject::backgroundColorName
QString backgroundColorName() const
QString
KNotePrintObject::KNotePrintObject
KNotePrintObject(const Akonadi::Item &item, QObject *parent=0)
Definition: knoteprintobject.cpp:30
QLatin1Char
KNotePrintObject::currentDateTime
QString currentDateTime() const
QDateTime::currentDateTime
QDateTime currentDateTime()
QLatin1String
QDateTime
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knotes

Skip menu "knotes"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal