25 #include <tqapplication.h>
28 #include <tdeglobal.h>
29 #include <tdeconfig.h>
30 #include <kstandarddirs.h>
31 #include <tdeglobalsettings.h>
32 #include <tdelocale.h>
33 #include <kstaticdeleter.h>
34 #include <kiconloader.h>
36 #include <kcalendarsystem.h>
37 #include <kholidays.h>
39 #include "alarmclient.h"
41 #include "koglobals.h"
43 #include "korganizer_part.h"
46 class NopAlarmClient :
public AlarmClient
54 KOGlobals *KOGlobals::mSelf = 0;
56 static KStaticDeleter<KOGlobals> koGlobalsDeleter;
58 KOGlobals *KOGlobals::self()
61 koGlobalsDeleter.setObject( mSelf,
new KOGlobals );
67 KOGlobals::KOGlobals()
72 mOwnInstance =
new TDEInstance(
"korganizer" );
73 mOwnInstance->config()->setGroup(
"General" );
74 mOwnInstance->iconLoader()->addAppDir(
"tdepim" );
75 TDEGlobal::iconLoader()->addAppDir(
"tdepim" );
77 mAlarmClient =
new AlarmClient;
80 TDEConfig* KOGlobals::config()
const
82 return mOwnInstance->config();
85 KOGlobals::~KOGlobals()
92 const KCalendarSystem *KOGlobals::calendarSystem()
const
94 return TDEGlobal::locale()->calendar();
97 AlarmClient *KOGlobals::alarmClient()
const
102 void KOGlobals::fitDialogToScreen( TQWidget *wid,
bool force )
104 bool resized =
false;
106 int w = wid->frameSize().width();
107 int h = wid->frameSize().height();
109 TQRect desk = TDEGlobalSettings::desktopGeometry( wid );
110 if ( w > desk.width() ) {
115 if ( h > desk.height() - 30 ) {
116 h = desk.height() - 30;
120 if ( resized || force ) {
122 wid->move( desk.x(), desk.y()+15 );
123 if ( force ) wid->setFixedSize( w, h );
127 bool KOGlobals::reverseLayout()
129 return TQApplication::reverseLayout();
132 TQPixmap KOGlobals::smallIcon(
const TQString& name )
134 return SmallIcon( name, mOwnInstance );
137 TQIconSet KOGlobals::smallIconSet(
const TQString& name,
int size )
139 return SmallIconSet( name, size, mOwnInstance );
142 TQStringList KOGlobals::holiday(
const TQDate &date )
146 if ( !mHolidays )
return hdays;
147 TQValueList<KHoliday> list = mHolidays->getHolidays( date );
148 TQValueList<KHoliday>::ConstIterator it = list.begin();
149 for ( ; it != list.end(); ++it ) {
150 hdays.append( (*it).text );
155 bool KOGlobals::isWorkDay(
const TQDate &date )
157 int mask( ~( KOPrefs::instance()->mWorkWeekMask ) );
159 bool nonWorkDay = ( mask & ( 1 << ( date.dayOfWeek() - 1 ) ) );
160 if ( KOPrefs::instance()->mExcludeHolidays && mHolidays ) {
161 TQValueList<KHoliday> list = mHolidays->getHolidays( date );
162 TQValueList<KHoliday>::ConstIterator it = list.begin();
163 for ( ; it != list.end(); ++it ) {
164 nonWorkDay = nonWorkDay
165 || ( (*it).Category == KHolidays::HOLIDAY );
171 int KOGlobals::getWorkWeekMask()
173 return KOPrefs::instance()->mWorkWeekMask;
176 void KOGlobals::setHolidays( KHolidays *h )
182 KHolidays *KOGlobals::holidays()
const