summaryrefslogtreecommitdiffstats
path: root/korganizer/plugins/printing/year
diff options
context:
space:
mode:
Diffstat (limited to 'korganizer/plugins/printing/year')
-rw-r--r--korganizer/plugins/printing/year/Makefile.am14
-rw-r--r--korganizer/plugins/printing/year/calprintyearconfig_base.ui200
-rw-r--r--korganizer/plugins/printing/year/yearprint.cpp204
-rw-r--r--korganizer/plugins/printing/year/yearprint.desktop84
-rw-r--r--korganizer/plugins/printing/year/yearprint.h65
5 files changed, 567 insertions, 0 deletions
diff --git a/korganizer/plugins/printing/year/Makefile.am b/korganizer/plugins/printing/year/Makefile.am
new file mode 100644
index 00000000..f51e29e6
--- /dev/null
+++ b/korganizer/plugins/printing/year/Makefile.am
@@ -0,0 +1,14 @@
+INCLUDES = -I$(top_srcdir)/korganizer/interfaces -I$(top_srcdir)/korganizer/printing -I$(top_srcdir) $(all_includes)
+
+kde_module_LTLIBRARIES = libkorg_yearlyprint.la
+
+libkorg_yearlyprint_la_SOURCES =calprintyearconfig_base.ui yearprint.cpp
+libkorg_yearlyprint_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries)
+libkorg_yearlyprint_la_LIBADD = $(LIB_KDECORE) $(LIB_KDEUI) $(top_builddir)/korganizer/printing/libkorg_stdprinting.la
+
+noinst_HEADERS =
+
+servicedir = $(kde_servicesdir)/korganizer
+service_DATA = yearprint.desktop
+
+METASOURCES = AUTO
diff --git a/korganizer/plugins/printing/year/calprintyearconfig_base.ui b/korganizer/plugins/printing/year/calprintyearconfig_base.ui
new file mode 100644
index 00000000..43d906d6
--- /dev/null
+++ b/korganizer/plugins/printing/year/calprintyearconfig_base.ui
@@ -0,0 +1,200 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>CalPrintYearConfig_Base</class>
+<comment>Configuration page for the yearly print mode.</comment>
+<author>Reinhold Kainhofer &lt;reinhold@kainhofer.com&gt;</author>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>CalPrintYear_Base</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>340</width>
+ <height>237</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>CalPrintYear_Base</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>mDateRangeGroup</cstring>
+ </property>
+ <property name="title">
+ <string>Yearly print options</string>
+ </property>
+ <property name="selectedId" stdset="0">
+ <number>-1</number>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>mYearLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Print &amp;Year:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>mYear</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>mPagesLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Number of &amp;pages:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>mPages</cstring>
+ </property>
+ </widget>
+ <widget class="QSpinBox" row="0" column="1">
+ <property name="name">
+ <cstring>mYear</cstring>
+ </property>
+ <property name="maxValue">
+ <number>2500</number>
+ </property>
+ <property name="minValue">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>2007</number>
+ </property>
+ </widget>
+ <spacer row="0" column="2">
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>120</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QComboBox" row="1" column="1">
+ <property name="name">
+ <cstring>mPages</cstring>
+ </property>
+ </widget>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>131</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>mDisplayOptionsGroup</cstring>
+ </property>
+ <property name="title">
+ <string>Display Options</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>mSubDaysLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Show sub-day events as:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>mHolidaysLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Show holidays as:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="0" column="1">
+ <item>
+ <property name="text">
+ <string>Text</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Time Boxes</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>mSubDays</cstring>
+ </property>
+ <property name="currentItem">
+ <number>1</number>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="1" column="1">
+ <item>
+ <property name="text">
+ <string>Text</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Time Boxes</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>mHolidays</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/korganizer/plugins/printing/year/yearprint.cpp b/korganizer/plugins/printing/year/yearprint.cpp
new file mode 100644
index 00000000..d71cd9f0
--- /dev/null
+++ b/korganizer/plugins/printing/year/yearprint.cpp
@@ -0,0 +1,204 @@
+/*
+ This file is part of KOrganizer.
+
+ Copyright (c) 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef KORG_NOPRINTER
+
+#include "calprintyearconfig_base.h"
+#include "yearprint.h"
+
+#include <libkcal/calendar.h>
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kcalendarsystem.h>
+#include <klocale.h>
+
+#include <qcheckbox.h>
+#include <qspinbox.h>
+#include <qcombobox.h>
+#include <qpainter.h>
+
+class YearPrintFactory : public KOrg::PrintPluginFactory {
+ public:
+ KOrg::PrintPlugin *create() { return new CalPrintYear; }
+};
+
+K_EXPORT_COMPONENT_FACTORY( libkorg_yearlyprint, YearPrintFactory )
+
+
+/**************************************************************
+ * Print Year
+ **************************************************************/
+
+QWidget *CalPrintYear::createConfigWidget( QWidget *w )
+{
+ return new CalPrintYearConfig_Base( w );
+}
+
+void CalPrintYear::readSettingsWidget()
+{
+ CalPrintYearConfig_Base *cfg =
+ dynamic_cast<CalPrintYearConfig_Base*>( mConfigWidget );
+ if ( cfg ) {
+ mYear = cfg->mYear->value();
+ mPages = cfg->mPages->currentText().toInt();
+ mSubDaysEvents = (cfg->mSubDays->currentItem()==0)?Text:TimeBoxes;
+ mHolidaysEvents = (cfg->mHolidays->currentItem()==0)?Text:TimeBoxes;
+ }
+}
+
+void CalPrintYear::setSettingsWidget()
+{
+ CalPrintYearConfig_Base *cfg =
+ dynamic_cast<CalPrintYearConfig_Base*>( mConfigWidget );
+ if ( cfg ) {
+ const KCalendarSystem *calsys = calendarSystem();
+ QDate start;
+ calsys->setYMD( start, mYear, 1, 1 );
+ int months = calsys->monthsInYear( start );
+ int pages=0, prevPages=0;
+ for ( int i=1; i<= months; ++i ) {
+ pages = (months-1)/i + 1;
+ if ( pages != prevPages ) {
+ prevPages = pages;
+ cfg->mPages->insertItem( QString::number( pages ), 0 );
+ }
+ }
+
+ cfg->mYear->setValue( mYear );
+ cfg->mPages->setCurrentText( QString::number( mPages ) );
+
+ cfg->mSubDays->setCurrentItem( (mSubDaysEvents==Text)?0:1 );
+ cfg->mHolidays->setCurrentItem( (mHolidaysEvents==Text)?0:1 );
+ }
+}
+
+void CalPrintYear::loadConfig()
+{
+ if ( mConfig ) {
+ mYear = mConfig->readNumEntry( "Year", 2007 );
+ mPages = mConfig->readNumEntry( "Pages", 1 );
+ mSubDaysEvents = mConfig->readNumEntry( "ShowSubDayEventsAs", TimeBoxes );
+ mHolidaysEvents = mConfig->readNumEntry( "ShowHolidaysAs", Text );
+ }
+ setSettingsWidget();
+}
+
+void CalPrintYear::saveConfig()
+{
+ kdDebug(5850) << "CalPrintYear::saveConfig()" << endl;
+
+ readSettingsWidget();
+ if ( mConfig ) {
+ mConfig->writeEntry( "Year", mYear );
+ mConfig->writeEntry( "Pages", mPages );
+ mConfig->writeEntry( "Pages", mPages );
+ mConfig->writeEntry( "ShowSubDayEventsAs", mSubDaysEvents );
+ mConfig->writeEntry( "ShowHolidaysAs", mHolidaysEvents );
+ }
+}
+
+KPrinter::Orientation CalPrintYear::defaultOrientation()
+{
+ return ( mPages == 1 )?(KPrinter::Landscape):(KPrinter::Portrait);
+}
+
+
+void CalPrintYear::setDateRange( const QDate& from, const QDate& to )
+{
+ CalPrintPluginBase::setDateRange( from, to );
+ CalPrintYearConfig_Base *cfg =
+ dynamic_cast<CalPrintYearConfig_Base*>( mConfigWidget );
+ if ( cfg ) {
+ cfg->mYear->setValue( from.year() );
+ }
+}
+
+void CalPrintYear::print( QPainter &p, int width, int height )
+{
+kdDebug()<<"CalPrintYear::print, width: "<<width<<", height: "<<height<<endl;
+ QRect headerBox( 0, 0, width, headerHeight() );
+kdDebug()<<"headerBox: "<<headerBox<<endl;
+ const KCalendarSystem *calsys = calendarSystem();
+ KLocale *locale = KGlobal::locale();
+ if ( !calsys || !locale ) return;
+
+ QDate start;
+ calsys->setYMD( start, mYear, 1, 1 );
+
+ // Determine the nr of months and the max nr of days per month (dependent on
+ // calendar system!!!!)
+ QDate temp( start );
+ int months = calsys->monthsInYear( start );
+ int maxdays = 1;
+ for ( int i = 1; i< months; ++i ) {
+ maxdays = QMAX( maxdays, temp.daysInMonth() );
+ temp = calsys->addMonths( temp, 1 );
+ }
+
+ // Now determine the months per page so that the printout fits on
+ // exactly mPages pages
+ int monthsPerPage = (months-1) / mPages + 1;
+ int pages = (months-1) / monthsPerPage + 1;
+ int thismonth = 0;
+ temp = start;
+ for ( int page = 0; page < pages; ++page ) {
+ if ( page > 0 ) {
+ mPrinter->newPage();
+ }
+ QDate end( calsys->addMonths( start, monthsPerPage ) );
+ end = calsys->addDays( end, -1 );
+ QString title;
+ if ( orientation() == KPrinter::Landscape ) {
+ title = i18n("date from - to", "%1 - %2");
+ } else {
+ title = i18n("date from -\nto", "%1 -\n%2");
+ }
+ drawHeader( p, title
+ .arg( locale->formatDate( start ) )
+ .arg( locale->formatDate( end ) ),
+ calsys->addMonths( start, -1), calsys->addMonths( start, monthsPerPage ),
+ headerBox );
+
+ QRect monthesBox( headerBox );
+ monthesBox.setTop( monthesBox.bottom() + padding() );
+ monthesBox.setBottom( height );
+
+ drawBox( p, BOX_BORDER_WIDTH, monthesBox );
+ float monthwidth = float(monthesBox.width()) / float( monthsPerPage );
+
+ for ( int j=0; j<monthsPerPage; ++j ) {
+ if ( ++thismonth > months ) break;
+ int xstart = int(j*monthwidth + 0.5);
+ int xend = int((j+1)*monthwidth + 0.5);
+ QRect monthBox( xstart, monthesBox.top(), xend-xstart, monthesBox.height() );
+ drawMonth( p, temp, monthBox, maxdays, mSubDaysEvents, mHolidaysEvents );
+
+ temp = calsys->addMonths( temp, 1 );
+ }
+ start = calsys->addMonths( start, monthsPerPage );
+ }
+}
+
+#endif
diff --git a/korganizer/plugins/printing/year/yearprint.desktop b/korganizer/plugins/printing/year/yearprint.desktop
new file mode 100644
index 00000000..5edafedc
--- /dev/null
+++ b/korganizer/plugins/printing/year/yearprint.desktop
@@ -0,0 +1,84 @@
+[Desktop Entry]
+X-KDE-Library=libkorg_yearlyprint
+Name=Yearly Print Style
+Name[af]=Druk styl: Jaarliks
+Name[bg]=Стил за отпечатване на годишно разписание
+Name[ca]=Estil d'impressió anual
+Name[cs]=Roční tiskový styl
+Name[da]=Yearly udskriftsstil
+Name[de]=Jahres-Druckstil
+Name[el]=Στυλ ετήσιας εκτύπωσης
+Name[eo]=Pojara Presostilo
+Name[es]=Estilo de impresión del diario
+Name[et]=Aastakalendri trükkimise stiil
+Name[fa]=سبک چاپ نشریه
+Name[fr]=Impression annuelle
+Name[fy]=Printstyl foar jierkalinder
+Name[gl]=Estilo de impresión anual
+Name[hu]=Éves naptár nyomtatási stílus
+Name[is]=Ársyfirlitsprentstíll
+Name[it]=Stile di stampa annuale
+Name[ja]=年毎印刷スタイル
+Name[kk]=Жылдық басу стилі
+Name[km]=រចនាប័ទ្ម​បោះពុម្ព​ប្រចាំ​ឆ្នាំ
+Name[lt]=Metų spausdinimo stilius
+Name[nb]=Utskriftsstil for kalender
+Name[nds]=Johrkalenner-Druckstil
+Name[ne]=वार्षिक मुद्रण शैली
+Name[nl]=Printstijl voor jaarkalender
+Name[pl]=Styl drukowania roku
+Name[pt]=Estilo de Impressão em Anuário
+Name[pt_BR]=Estilo de Impressão de Calendário Anual
+Name[ru]=Календарь на год
+Name[sk]=Štýl tlače pre rok
+Name[sl]=Letni slog tiskanja
+Name[sr]=Годишњи стил штампе
+Name[sr@Latn]=Godišnji stil štampe
+Name[sv]=Årlig utskriftsstil
+Name[tr]=Yıllık Yazdırma Stili
+Name[uk]=Стиль друку щорічником
+Name[zh_CN]=按年打印样式
+Name[zh_TW]=年度列印風格
+Comment=This plugin allows you to print out a yearly calendar.
+Comment[af]=Hierdie inprop module maak dit moontlik om 'n kalender vir 'n hele jaar te druk.
+Comment[bg]=Приставката служи за печат на годишния календар.
+Comment[ca]=Aquest endollable us permet imprimir un calendari anual.
+Comment[cs]=Tento modul umožňuje tisk ročního kalendáře.
+Comment[da]=Dette plugin gør at du kan udskrive en årlig kalender
+Comment[de]=Mit diesem Modul können Jahresübersichten gedruckt werden.
+Comment[el]=Αυτό το πρόσθετο σας επιτρέπει να εκτυπώσετε ένα ετήσιο ημερολόγιο.
+Comment[es]=Este plugin le permite imprimir entradas del diario.
+Comment[et]=See plugin võimaldab trükkida terve aasta kalendri.
+Comment[fa]=این وصله، به شما اجازه می‌دهد که مدخلهای نشریه )مدخلهای روزانه( را چاپ کنید.
+Comment[fr]=Ce module vous permet d'imprimer l'ensemble de l'année
+Comment[fy]=Dizze plugin makket it mooglik om in jierkalinder út te printsjen.
+Comment[gl]=Este engadido permítelle imprimir un calendario anual.
+Comment[hu]=Ez a modul egy egész éves naptár kinyomtatását teszi lehetővé.
+Comment[is]=Þetta íforrit gerir þér kleyft að prenta út dagbókarfærslur fyrir allt árið.
+Comment[it]=Questo plugin ti permette di stampare un calendario annuale.
+Comment[ja]=このプラグインにより、年毎のカレンダーを印刷できるようになります。
+Comment[kk]=Бұл жылдық күнтізбені басып шығаратын модулі.
+Comment[km]=កម្មវិធី​ជំនួយ​នេះ​អនុញ្ញាត​ឲ្យ​អ្នក​បោះពុម្ព​​ប្រតិទិន​ប្រចាំ​ឆ្នាំ ។
+Comment[lt]=Šis priedas leidžia spausdinti metų kalendorių.
+Comment[mk]=Овој приклучок Ви овозможува да испечатите годишен календар.
+Comment[nb]=Med dette programtillegget kan du skrive ut en årskalender.
+Comment[nds]=Mit dit Moduul kannst Du en Kalenner för't hele Johr utdrucken.
+Comment[ne]=यो प्लगइनले तपाईँलाई वार्षिक पात्रो मुद्रण गर्न अनुमति दिन्छ ।
+Comment[nl]=Deze plugin maakt het mogelijk om een jaarkalender af te drukken.
+Comment[pl]=Ta wtyczka pozwala drukować roczny kalendarz.
+Comment[pt]=Este 'plugin' permite-lhe imprimir um calendário anual.
+Comment[pt_BR]=Este plug-in permite imprimir um calendário anual.
+Comment[ru]=Этот модуль позволяет печатать календарь на год.
+Comment[sk]=Tento modul vám umožní vytlačiť kalendár na rok.
+Comment[sl]=Ta vstavek vam omogoča natis letnega koledarja.
+Comment[sr]=Овај прикључак вам омогућава да одштампате годишњи календар.
+Comment[sr@Latn]=Ovaj priključak vam omogućava da odštampate godišnji kalendar.
+Comment[sv]=Det här insticksprogrammet gör att du kan skriva ut en årlig kalender.
+Comment[tr]=Bu eklenti, yıllık takvimi yazıcıdan çıkartmanızı sağlar.
+Comment[uk]=Цей журнал надає можливість друкувати щорічний календар.
+Comment[zh_CN]=此插件允许您打印年历。
+Comment[zh_TW]=此外掛程式讓您印出年曆。
+Type=Service
+ServiceTypes=Calendar/Plugin,KOrganizer/PrintPlugin
+X-KDE-KOrganizer-HasSettings=false
+X-KDE-PluginInterfaceVersion=2
diff --git a/korganizer/plugins/printing/year/yearprint.h b/korganizer/plugins/printing/year/yearprint.h
new file mode 100644
index 00000000..3191150b
--- /dev/null
+++ b/korganizer/plugins/printing/year/yearprint.h
@@ -0,0 +1,65 @@
+/*
+ This file is part of KOrganizer.
+
+ Copyright (c) 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+#ifndef YEARPRINT_H
+#define YEARPRINT_H
+
+#include <klocale.h>
+#include "calprintpluginbase.h"
+
+#ifndef KORG_NOPRINTER
+namespace KCal {
+class Calendar;
+}
+
+using namespace KCal;
+
+class CalPrintYear : public CalPrintPluginBase
+{
+ public:
+ CalPrintYear():CalPrintPluginBase() {}
+ virtual ~CalPrintYear() {}
+ virtual QString description() { return i18n("Print &Year"); }
+ virtual QString info() { return i18n("Prints a calendar for an entire year"); }
+ virtual int sortID() { return 900; }
+ virtual bool enabled() { return true; }
+ virtual QWidget *createConfigWidget( QWidget* );
+ virtual KPrinter::Orientation defaultOrientation();
+
+ public:
+ virtual void print(QPainter &p, int width, int height);
+ virtual void readSettingsWidget();
+ virtual void setSettingsWidget();
+ virtual void loadConfig();
+ virtual void saveConfig();
+ virtual void setDateRange( const QDate& from, const QDate& to );
+
+ protected:
+ int mYear;
+ int mPages;
+ int mSubDaysEvents, mHolidaysEvents;
+};
+
+
+#endif
+#endif