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

messagelist

  • sources
  • kde-4.12
  • kdepim
  • messagelist
messagelistutil.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2  This file is part of KMail, the KDE mail client.
3  Copyright (c) 2011 Montel Laurent <montel@kde.org>
4 
5  KMail is free software; you can redistribute it and/or modify it
6  under the terms of the GNU General Public License, version 2, as
7  published by the Free Software Foundation.
8 
9  KMail is distributed in the hope that it will be useful, but
10  WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 #include "messagelistutil.h"
19 #include "core/settings.h"
20 #include <QTextDocument>
21 
22 #include <KConfigGroup>
23 #include <KMenu>
24 #include <KIcon>
25 #include <KLocale>
26 #include <nepomuk2/nmo.h>
27 #include <Nepomuk2/Resource>
28 #include <Nepomuk2/Variant>
29 
30 
31 using namespace MessageList::Core;
32 
33 QString MessageList::Util::messageSortingConfigName()
34 {
35  return QLatin1String( "MessageSorting" );
36 }
37 
38 QString MessageList::Util::messageSortDirectionConfigName()
39 {
40  return QLatin1String( "MessageSortDirection" );
41 }
42 
43 QString MessageList::Util::groupSortingConfigName()
44 {
45  return QLatin1String( "GroupSorting" );
46 }
47 
48 QString MessageList::Util::groupSortDirectionConfigName()
49 {
50  return QLatin1String( "GroupSortDirection" );
51 }
52 
53 QString MessageList::Util::messageUniqueIdConfigName()
54 {
55  return QString::fromLatin1( "MessageUniqueIdForStorageModel%1" );
56 }
57 
58 QString MessageList::Util::storageModelSortOrderGroup()
59 {
60  return QLatin1String( "MessageListView::StorageModelSortOrder" );
61 }
62 
63 QString MessageList::Util::storageModelThemesGroup()
64 {
65  return QLatin1String( "MessageListView::StorageModelThemes" );
66 }
67 
68 QString MessageList::Util::storageModelAggregationsGroup()
69 {
70  return QLatin1String( "MessageListView::StorageModelAggregations" );
71 }
72 
73 
74 QString MessageList::Util::setForStorageModelConfigName()
75 {
76  return QString::fromLatin1( "SetForStorageModel%1" );
77 }
78 
79 QString MessageList::Util::storageModelSelectedMessageGroup()
80 {
81  return QLatin1String( "MessageListView::StorageModelSelectedMessages" );
82 }
83 
84 
85 void MessageList::Util::deleteConfig( const QString& collectionId )
86 {
87  KConfigGroup confselectedMessage( Settings::self()->config(),
88  MessageList::Util::storageModelSelectedMessageGroup() );
89  confselectedMessage.deleteEntry( MessageList::Util::messageUniqueIdConfigName().arg( collectionId ) );
90 
91  KConfigGroup storageModelOrder( Settings::self()->config(),
92  MessageList::Util::storageModelSortOrderGroup() );
93  storageModelOrder.deleteEntry( collectionId + groupSortDirectionConfigName() );
94  storageModelOrder.deleteEntry( collectionId + groupSortingConfigName() );
95  storageModelOrder.deleteEntry( collectionId + messageSortDirectionConfigName() );
96  storageModelOrder.deleteEntry( collectionId + messageSortingConfigName() );
97 
98  KConfigGroup storageModelTheme( Settings::self()->config(),
99  MessageList::Util::storageModelThemesGroup() );
100  storageModelTheme.deleteEntry( collectionId + setForStorageModelConfigName() );
101 
102 
103  KConfigGroup storageModelAggregation( Settings::self()->config(),
104  MessageList::Util::storageModelAggregationsGroup() );
105  storageModelAggregation.deleteEntry( collectionId + setForStorageModelConfigName() );
106 
107 }
108 
109 QColor MessageList::Util::unreadDefaultMessageColor()
110 {
111  return QColor( "blue" );
112 }
113 
114 QColor MessageList::Util::importantDefaultMessageColor()
115 {
116  return QColor( 0x98, 0x0, 0x0 );
117 }
118 
119 QColor MessageList::Util::todoDefaultMessageColor()
120 {
121  return QColor( 0x0, 0x98, 0x0 );
122 }
123 
124 void MessageList::Util::fillViewMenu( KMenu * menu, QObject *receiver )
125 {
126  KMenu* sortingMenu = new KMenu( i18n( "Sorting" ), menu );
127  sortingMenu->setIcon( KIcon( QLatin1String( "view-sort-ascending" ) ) );
128  menu->addMenu( sortingMenu );
129  QObject::connect( sortingMenu, SIGNAL(aboutToShow()),
130  receiver, SLOT(sortOrderMenuAboutToShow()) );
131 
132  KMenu* aggregationMenu = new KMenu( i18n( "Aggregation" ), menu );
133  aggregationMenu->setIcon( KIcon( QLatin1String( "view-process-tree" ) ) );
134  menu->addMenu( aggregationMenu );
135  QObject::connect( aggregationMenu, SIGNAL(aboutToShow()),
136  receiver, SLOT(aggregationMenuAboutToShow()) );
137 
138  KMenu* themeMenu = new KMenu( i18n( "Theme" ), menu );
139  themeMenu->setIcon( KIcon( QLatin1String( "preferences-desktop-theme" ) ) );
140  menu->addMenu( themeMenu );
141  QObject::connect( themeMenu, SIGNAL(aboutToShow()),
142  receiver, SLOT(themeMenuAboutToShow()) );
143 }
144 
145 QString MessageList::Util::contentSummary( const KUrl& url )
146 {
147  Nepomuk2::Resource mail( url );
148  const QString content =
149  mail.property( Nepomuk2::Vocabulary::NMO::plainTextMessageContent() ).toString();
150  // Extract the first 5 non-empty, non-quoted lines from the content and return it
151  int numLines = 0;
152  const int maxLines = 5;
153  const QStringList lines = content.split( QLatin1Char( '\n' ) );
154  QString ret;
155  foreach( const QString &line, lines ) {
156  const QString lineTrimmed = line.trimmed();
157  const bool isQuoted = lineTrimmed.startsWith( QLatin1Char( '>' ) ) || lineTrimmed.startsWith( QLatin1Char( '|' ) );
158  if ( !isQuoted && !lineTrimmed.isEmpty() ) {
159  ret += line + QLatin1Char( '\n' );
160  numLines++;
161  if ( numLines >= maxLines )
162  break;
163  }
164  }
165  return Qt::escape(ret);
166 }
167 
MessageList::Util::messageUniqueIdConfigName
MESSAGELIST_EXPORT QString messageUniqueIdConfigName()
Definition: messagelistutil.cpp:53
MessageList::Util::storageModelSelectedMessageGroup
MESSAGELIST_EXPORT QString storageModelSelectedMessageGroup()
Definition: messagelistutil.cpp:79
MessageList::Util::importantDefaultMessageColor
MESSAGELIST_EXPORT QColor importantDefaultMessageColor()
Definition: messagelistutil.cpp:114
MessageList::Util::storageModelSortOrderGroup
MESSAGELIST_EXPORT QString storageModelSortOrderGroup()
Definition: messagelistutil.cpp:58
MessageList::Util::groupSortingConfigName
MESSAGELIST_EXPORT QString groupSortingConfigName()
Definition: messagelistutil.cpp:43
MessageList::Util::messageSortingConfigName
MESSAGELIST_EXPORT QString messageSortingConfigName()
Definition: messagelistutil.cpp:33
QObject
MessageList::Core::Settings::self
static Settings * self()
Definition: settings.cpp:70
MessageList::Util::storageModelThemesGroup
MESSAGELIST_EXPORT QString storageModelThemesGroup()
Definition: messagelistutil.cpp:63
MessageList::Util::storageModelAggregationsGroup
MESSAGELIST_EXPORT QString storageModelAggregationsGroup()
Definition: messagelistutil.cpp:68
MessageList::Util::groupSortDirectionConfigName
MESSAGELIST_EXPORT QString groupSortDirectionConfigName()
Definition: messagelistutil.cpp:48
MessageList::Util::setForStorageModelConfigName
MESSAGELIST_EXPORT QString setForStorageModelConfigName()
Definition: messagelistutil.cpp:74
MessageList::Util::contentSummary
MESSAGELIST_EXPORT QString contentSummary(const KUrl &url)
Returns the first few lines of the actual email text This data is taken from Nepomuk, if available.
Definition: messagelistutil.cpp:145
MessageList::Util::messageSortDirectionConfigName
MESSAGELIST_EXPORT QString messageSortDirectionConfigName()
Definition: messagelistutil.cpp:38
MessageList::Util::todoDefaultMessageColor
MESSAGELIST_EXPORT QColor todoDefaultMessageColor()
Definition: messagelistutil.cpp:119
MessageList::Util::unreadDefaultMessageColor
MESSAGELIST_EXPORT QColor unreadDefaultMessageColor()
Definition: messagelistutil.cpp:109
settings.h
messagelistutil.h
MessageList::Util::fillViewMenu
MESSAGELIST_EXPORT void fillViewMenu(KMenu *menu, QObject *receiver)
Definition: messagelistutil.cpp:124
MessageList::Util::deleteConfig
MESSAGELIST_EXPORT void deleteConfig(const QString &collectionId)
Definition: messagelistutil.cpp:85
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:32 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messagelist

Skip menu "messagelist"
  • 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

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