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

calendarsupport

  • sources
  • kde-4.12
  • kdepim
  • calendarsupport
categoryconfig.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
3  Copyright (c) 2005 Rafal Rzepecki <divide@users.sourceforge.net>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "categoryconfig.h"
22 
23 #include <KConfigSkeleton>
24 #include <KLocalizedString>
25 
26 using namespace CalendarSupport;
27 
28 static QStringList categoryDefaults()
29 {
30  QStringList l;
31  l << i18nc( "incidence category: appointment", "Appointment" )
32  << i18nc( "incidence category", "Business" )
33  << i18nc( "incidence category", "Meeting" )
34  << i18nc( "incidence category: phone call","Phone Call" )
35  << i18nc( "incidence category", "Education" )
36  << i18nc( "incidence category: "
37  "official or unofficial observance of "
38  "religious/national/cultural/other significance, "
39  "often accompanied by celebrations or festivities", "Holiday" )
40  << i18nc( "incidence category: "
41  "a lengthy time away from work or school, a trip abroad, "
42  "or simply a pleasure trip away from home", "Vacation" )
43  << i18nc( "incidence category: "
44  "examples: anniversary of historical or personal event; "
45  "big date; remembrance, etc", "Special Occasion" )
46  << i18nc( "incidence category", "Personal" )
47  << i18nc( "incidence category: "
48  "typically associated with leaving home for business, "
49  "and not pleasure", "Travel" )
50  << i18nc( "incidence category", "Miscellaneous" )
51  << i18nc( "incidence category", "Birthday" );
52  return l;
53 }
54 
55 class CategoryConfig::Private
56 {
57  public:
58  explicit Private( KCoreConfigSkeleton *cfg ) : config( cfg )
59  {
60  mDefaultCategoryColor = QColor( 151, 235, 121 );
61  }
62 
63  QColor mDefaultCategoryColor;
64  KCoreConfigSkeleton *config;
65 };
66 
67 QHash<QString,QColor> CategoryConfig::readColors() const
68 {
69  // Category colors
70  QHash<QString,QColor> categoryColors;
71  KConfigGroup colorsConfig( d->config->config(), "Category Colors2" );
72  const QStringList cats = customCategories();
73  Q_FOREACH ( const QString & category, cats ) {
74  const QColor color = colorsConfig.readEntry( category, d->mDefaultCategoryColor );
75  if ( color != d->mDefaultCategoryColor ) {
76  categoryColors.insert( category, color );
77  }
78  }
79 
80  return categoryColors;
81 }
82 
83 void CategoryConfig::setColors( const QHash<QString,QColor> &colors )
84 {
85  KConfigGroup colorsConfig( d->config->config(), "Category Colors2" );
86  QHash<QString, QColor>::const_iterator i = colors.constBegin();
87  QHash<QString, QColor>::const_iterator end = colors.constEnd();
88  while ( i != end ) {
89  colorsConfig.writeEntry( i.key(), i.value() );
90  ++i;
91  }
92 }
93 
94 CategoryConfig::CategoryConfig( KCoreConfigSkeleton *cfg, QObject *parent )
95  : QObject( parent ), d( new Private( cfg ) )
96 {
97 }
98 
99 CategoryConfig::~CategoryConfig()
100 {
101  delete d;
102 }
103 
104 void CategoryConfig::writeConfig()
105 {
106  d->config->writeConfig();
107 }
108 
109 QStringList CategoryConfig::customCategories() const
110 {
111  KConfigGroup group( d->config->config(), "General" );
112  QStringList cats = group.readEntry( "Custom Categories", QStringList() );
113 
114  if ( cats.isEmpty() ) {
115  cats = categoryDefaults();
116  }
117  cats.sort();
118  return cats;
119 }
120 
121 void CategoryConfig::setCustomCategories( const QStringList &categories )
122 {
123  KConfigGroup group( d->config->config(), "General" );
124  group.writeEntry( "Custom Categories", categories );
125 }
126 
127 const QString CategoryConfig::categorySeparator( QLatin1Char(':') );
128 
129 #include "categoryconfig.moc"
CalendarSupport::CategoryConfig::setColors
void setColors(const QHash< QString, QColor > &colors)
Definition: categoryconfig.cpp:83
CalendarSupport::CategoryConfig::customCategories
QStringList customCategories() const
Definition: categoryconfig.cpp:109
QObject
CalendarSupport::CategoryConfig::setCustomCategories
void setCustomCategories(const QStringList &categories)
Definition: categoryconfig.cpp:121
CalendarSupport::CategoryConfig::categorySeparator
static const QString categorySeparator
Definition: categoryconfig.h:47
categoryDefaults
static QStringList categoryDefaults()
Definition: categoryconfig.cpp:28
CalendarSupport::CategoryConfig::~CategoryConfig
~CategoryConfig()
Definition: categoryconfig.cpp:99
CalendarSupport::categories
CALENDARSUPPORT_EXPORT QStringList categories(const KCalCore::Incidence::List &incidences)
Definition: utils.cpp:746
CalendarSupport::CategoryConfig::writeConfig
void writeConfig()
Definition: categoryconfig.cpp:104
CalendarSupport::CategoryConfig::readColors
QHash< QString, QColor > readColors() const
Definition: categoryconfig.cpp:67
CalendarSupport::CategoryConfig::CategoryConfig
CategoryConfig(KCoreConfigSkeleton *cfg, QObject *parent=0)
Definition: categoryconfig.cpp:94
categoryconfig.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:54:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

calendarsupport

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