From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- korganizer/plugins/printing/year/Makefile.am | 14 ++ .../printing/year/calprintyearconfig_base.ui | 200 ++++++++++++++++++++ korganizer/plugins/printing/year/yearprint.cpp | 204 +++++++++++++++++++++ korganizer/plugins/printing/year/yearprint.desktop | 84 +++++++++ korganizer/plugins/printing/year/yearprint.h | 65 +++++++ 5 files changed, 567 insertions(+) create mode 100644 korganizer/plugins/printing/year/Makefile.am create mode 100644 korganizer/plugins/printing/year/calprintyearconfig_base.ui create mode 100644 korganizer/plugins/printing/year/yearprint.cpp create mode 100644 korganizer/plugins/printing/year/yearprint.desktop create mode 100644 korganizer/plugins/printing/year/yearprint.h (limited to 'korganizer/plugins/printing/year') diff --git a/korganizer/plugins/printing/year/Makefile.am b/korganizer/plugins/printing/year/Makefile.am new file mode 100644 index 000000000..f51e29e61 --- /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 000000000..43d906d6c --- /dev/null +++ b/korganizer/plugins/printing/year/calprintyearconfig_base.ui @@ -0,0 +1,200 @@ + +CalPrintYearConfig_Base +Configuration page for the yearly print mode. +Reinhold Kainhofer <reinhold@kainhofer.com> + + + CalPrintYear_Base + + + + 0 + 0 + 340 + 237 + + + + CalPrintYear_Base + + + + unnamed + + + 0 + + + + mDateRangeGroup + + + Yearly print options + + + -1 + + + + unnamed + + + + mYearLabel + + + Print &Year: + + + mYear + + + + + mPagesLabel + + + Number of &pages: + + + mPages + + + + + mYear + + + 2500 + + + 0 + + + 2007 + + + + + spacer4 + + + Horizontal + + + Expanding + + + + 120 + 21 + + + + + + mPages + + + + + spacer5 + + + Horizontal + + + Expanding + + + + 131 + 21 + + + + + + + + mDisplayOptionsGroup + + + Display Options + + + + unnamed + + + + mSubDaysLabel + + + Show sub-day events as: + + + + + mHolidaysLabel + + + Show holidays as: + + + + + + Text + + + + + Time Boxes + + + + mSubDays + + + 1 + + + + + + Text + + + + + Time Boxes + + + + mHolidays + + + + + + + spacer3 + + + Vertical + + + Expanding + + + + 21 + 40 + + + + + + + diff --git a/korganizer/plugins/printing/year/yearprint.cpp b/korganizer/plugins/printing/year/yearprint.cpp new file mode 100644 index 000000000..d71cd9f08 --- /dev/null +++ b/korganizer/plugins/printing/year/yearprint.cpp @@ -0,0 +1,204 @@ +/* + This file is part of KOrganizer. + + Copyright (c) 2004 Reinhold Kainhofer + + 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 + +#include +#include +#include +#include + +#include +#include +#include +#include + +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( 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( 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( mConfigWidget ); + if ( cfg ) { + cfg->mYear->setValue( from.year() ); + } +} + +void CalPrintYear::print( QPainter &p, int width, int height ) +{ +kdDebug()<<"CalPrintYear::print, width: "<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 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 000000000..5edafedc2 --- /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 000000000..3191150b2 --- /dev/null +++ b/korganizer/plugins/printing/year/yearprint.h @@ -0,0 +1,65 @@ +/* + This file is part of KOrganizer. + + Copyright (c) 2004 Reinhold Kainhofer + + 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 +#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 -- cgit v1.2.1