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

korganizer

  • sources
  • kde-4.12
  • kdepim
  • korganizer
koglobals.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 2002,2003 Cornelius Schumacher <schumacher@kde.org>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc.,
18  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  As a special exception, permission is given to link this program
21  with any edition of Qt, and distribute the resulting executable,
22  without including the source code for Qt in the source distribution.
23 */
24 
25 #include "koglobals.h"
26 #include "koprefs.h"
27 
28 #include <KHolidays/HolidayRegion>
29 
30 #include <KGlobal>
31 #include <KIconLoader>
32 
33 #include <QApplication>
34 
35 class KOGlobalsSingletonPrivate
36 {
37  public:
38  KOGlobals instance;
39 };
40 
41 K_GLOBAL_STATIC( KOGlobalsSingletonPrivate, sKOGlobalsSingletonPrivate )
42 
43 KOGlobals *KOGlobals::self()
44 {
45  return &sKOGlobalsSingletonPrivate->instance;
46 }
47 
48 KOGlobals::KOGlobals()
49  : mOwnInstance( "korganizer" ), mHolidays( 0 )
50 {
51  KIconLoader::global()->addAppDir( QLatin1String("kdepim") );
52 }
53 
54 KConfig *KOGlobals::config() const
55 {
56  KSharedConfig::Ptr c = mOwnInstance.config();
57  return c.data();
58 }
59 
60 KOGlobals::~KOGlobals()
61 {
62  delete mHolidays;
63 }
64 
65 const KCalendarSystem *KOGlobals::calendarSystem() const
66 {
67  return KGlobal::locale()->calendar();
68 }
69 
70 bool KOGlobals::reverseLayout()
71 {
72  return QApplication::isRightToLeft();
73 }
74 
75 QPixmap KOGlobals::smallIcon( const QString &name ) const
76 {
77  return SmallIcon( name );
78 }
79 
80 QMap<QDate,QStringList> KOGlobals::holiday( const QDate &start, const QDate &end ) const
81 {
82  QMap<QDate,QStringList> holidaysByDate;
83 
84  if ( !mHolidays ) {
85  return holidaysByDate;
86  }
87 
88  const KHolidays::Holiday::List list = mHolidays->holidays( start, end );
89  for ( int i = 0; i < list.count(); ++i ) {
90  const KHolidays::Holiday &h = list.at( i );
91  holidaysByDate[h.date()].append( h.text() );
92  }
93  return holidaysByDate;
94 }
95 
96 QList<QDate> KOGlobals::workDays( const QDate &startDate,
97  const QDate &endDate ) const
98 {
99  QList<QDate> result;
100 
101  const int mask( ~( KOPrefs::instance()->mWorkWeekMask ) );
102  const int numDays = startDate.daysTo( endDate ) + 1;
103 
104  for ( int i = 0; i < numDays; ++i ) {
105  const QDate date = startDate.addDays( i );
106  if ( !( mask & ( 1 << ( date.dayOfWeek() - 1 ) ) ) ) {
107  result.append( date );
108  }
109  }
110 
111  if ( mHolidays && KOPrefs::instance()->mExcludeHolidays ) {
112  const KHolidays::Holiday::List list = mHolidays->holidays( startDate, endDate );
113  for ( int i = 0; i < list.count(); ++i ) {
114  const KHolidays::Holiday &h = list.at( i );
115  const QString dateString = h.date().toString();
116  if ( h.dayType() == KHolidays::Holiday::NonWorkday ) {
117  result.removeAll( h.date() );
118  }
119  }
120  }
121 
122  return result;
123 }
124 
125 int KOGlobals::getWorkWeekMask()
126 {
127  return KOPrefs::instance()->mWorkWeekMask;
128 }
129 
130 void KOGlobals::setHolidays( KHolidays::HolidayRegion *h )
131 {
132  delete mHolidays;
133  mHolidays = h;
134 }
135 
136 KHolidays::HolidayRegion *KOGlobals::holidays() const
137 {
138  return mHolidays;
139 }
koglobals.h
KOGlobals::KOGlobals
KOGlobals()
Definition: koglobals.cpp:48
KOGlobals::holiday
QMap< QDate, QStringList > holiday(const QDate &start, const QDate &end) const
Definition: koglobals.cpp:80
KOPrefsBase::mWorkWeekMask
int mWorkWeekMask
Definition: koprefs_base.h:3197
KOGlobals::holidays
KHolidays::HolidayRegion * holidays() const
return the HolidayRegion object or 0 if none has been defined
Definition: koglobals.cpp:136
KOGlobals::~KOGlobals
~KOGlobals()
Definition: koglobals.cpp:60
koprefs.h
KOGlobals::setHolidays
void setHolidays(KHolidays::HolidayRegion *h)
Set which holidays the user wants to use.
Definition: koglobals.cpp:130
KOGlobals::calendarSystem
const KCalendarSystem * calendarSystem() const
Definition: koglobals.cpp:65
KOGlobals::workDays
QList< QDate > workDays(const QDate &start, const QDate &end) const
Returns a list containing work days between start and .
Definition: koglobals.cpp:96
KOGlobals::reverseLayout
static bool reverseLayout()
Definition: koglobals.cpp:70
KOGlobals::smallIcon
QPixmap smallIcon(const QString &name) const
Definition: koglobals.cpp:75
KOPrefs::instance
static KOPrefs * instance()
Get instance of KOPrefs.
Definition: koprefs.cpp:68
KOGlobals
Definition: koglobals.h:39
KOGlobals::getWorkWeekMask
int getWorkWeekMask()
Definition: koglobals.cpp:125
KOGlobals::config
KConfig * config() const
Definition: koglobals.cpp:54
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

korganizer

Skip menu "korganizer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

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