author | zautrix <zautrix> | 2005-03-28 23:39:37 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-28 23:39:37 (UTC) |
commit | 4e7c45695672ecdbd0cd14cac0ea29a8e134ee78 (patch) (side-by-side diff) | |
tree | 6815e055d6cb35d56d43f036261f5be9d2a9c350 | |
parent | 4034290f894ff7d1b0cf1197078e0ed832566bb7 (diff) | |
download | kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.zip kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.tar.gz kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.tar.bz2 |
montview sunday fix
-rw-r--r-- | bin/kdepim/WhatsNew.txt | 2 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 18 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 25 | ||||
-rw-r--r-- | korganizer/komonthview.h | 2 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 28 | ||||
-rw-r--r-- | microkde/kdecore/klocale.cpp | 37 | ||||
-rw-r--r-- | microkde/kdecore/klocale.h | 2 |
7 files changed, 64 insertions, 50 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index ce68a1d..b5285bf 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt @@ -1,27 +1,29 @@ Info about the changes in new versions of KDE-Pim/Pi ********** VERSION 2.0.22 ************ KO/Pi: Fix for creating events/todos via the abgenda context menu. Added option to split toolbar to 3 toolbars. Added option to show one small filter-view-toolbar. Added a print option to the desktop version: Now you can print out the view of the "Event Viewer". That means you can print all data of one particular event/todo. +Added scaling options to printout of Event Viewer and What'sNext View. +Fixed some problems in the month view in "week start sunday" mode. ********** VERSION 2.0.21 ************ Fixed another SMTP problem in OM/Pi. Some small changed in the new datenavigator in KO/Pi. Changed default setting for new filter in KA/Pi to "exclude categories". Changed the default font size for 640x480 display . Changed popup menu behaviour in agenda and list view. Fixed some layout problems of the date label size in the month view. Made month view update faster. Made first datenavigator repainting faster. Changed the title of the event/todo edit dialogs. Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course). Many small usebility fixes in KO/Pi. Pressing the "Calendar" button on the Z switches now to the next view in KO/Pi. The set of possible "next views" are the views you have toolbar buttons for. diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index 38bddc2..2fca49e 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp @@ -309,51 +309,49 @@ void KDateNavigator::updateDates() void KDateNavigator::updateDayMatrix() { daymatrix->updateView(); //daymatrix->repaint(); } void KDateNavigator::updateView() { setUpdatesEnabled( false ); int i; // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; daymatrix->updateView(); - + int sub = 4; + if ( ! KGlobal::locale()->weekStartsMonday() ) + --sub; // set the week numbers. for(i = 0; i < 6; i++) { - QString weeknum; // remember, according to ISO 8601, the first week of the year is the // first week that contains a thursday. Thus we must subtract off 4, // not just 1. //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); - int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); - - int add = 0; - if ( ! KGlobal::locale()->weekStartsMonday() ) - ++add; + int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub))); + int weekNo; if (dayOfYear % 7 != 0) - weeknum.setNum(dayOfYear / 7 + 1+add); + weekNo = (dayOfYear / 7 + 1); else - weeknum.setNum(dayOfYear / 7 +add); - weeknos[i]->setText(weeknum); + weekNo = (dayOfYear / 7); + weeknos[i]->setText(QString::number( weekNo )); } setUpdatesEnabled( true ); // kdDebug() << "updateView() -> repaint()" << endl; repaint(); // daymatrix->repaint(); } void KDateNavigator::updateConfig() { int day; for(int i=0; i<7; i++) { // take the first letter of the day name to be the abbreviation if (KGlobal::locale()->weekStartsMonday()) { day = i+1; } else { diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 9085775..d825493 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -988,36 +988,33 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) skipResize = false; clPending = true; mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); mWidStack = new QWidgetStack( this ); QVBoxLayout* hb = new QVBoxLayout( this ); mMonthView = new QWidget( mWidStack ); mWeekView = new QWidget( mWidStack ); #if QT_VERSION >= 0x030000 mWidStack->addWidget(mMonthView ); mWidStack->addWidget(mWeekView ); #else mWidStack->addWidget( mMonthView, 1 ); mWidStack->addWidget( mWeekView , 1 ); #endif hb->addWidget( mNavigatorBar ); hb->addWidget( mWidStack ); - mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); mShowWeekView = KOPrefs::instance()->mMonthViewWeek; - if ( mShowWeekView ) - mWeekStartsMonday = true; updatePossible = false; //updatePossible = true; mCells.setAutoDelete( true ); mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; mDayLabels.resize( mDaysPerWeek ); mDayLabelsW.resize( mDaysPerWeek ); QFont bfont = font(); if ( QApplication::desktop()->width() < 650 ) { bfont.setPointSize( bfont.pointSize() - 2 ); } bfont.setBold( true ); int i; for( i = 0; i < mDaysPerWeek; i++ ) { QLabel *label = new QLabel( mMonthView ); label->setFont(bfont); @@ -1204,35 +1201,35 @@ DateList KOMonthView::selectedDates() } return selected; } void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER calPrinter->preview(CalPrinter::Month, fd, td); #endif } void KOMonthView::updateConfig() { - mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); + int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); - if ( mShowWeekView ) { + if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { mWeekStartsMonday = true; } QFontMetrics fontmetric(mDayLabels[0]->font()); mWidthLongDayLabel = 0; for (int i = 0; i < 7; i++) { int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; } bool temp = mShowSatSunComp ; mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; if ( ! mShowWeekView ) { if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) computeLayout(); } updateDayLabels(); @@ -1246,86 +1243,88 @@ void KOMonthView::updateConfig() for (uint i = 0; i < mCellsW.count(); ++i) { mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); } #ifdef DESKTOP_VERSION MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); #endif updateView(); } void KOMonthView::updateDayLabels() { QPtrVector<QLabel> *mDayLabelsT; mDayLabelsT = &mDayLabelsW; for (int i = 0; i < 7; i++) { - if (mWeekStartsMonday) { + { bool show = mShortDayLabelsW; if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) show = true; (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); - } else { - if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); - else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); - } } mDayLabelsT = &mDayLabels; for (int i = 0; i < 7; i++) { - if (mWeekStartsMonday) { + if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { bool show = mShortDayLabelsM; if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) show = true; (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); } else { if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); } } } void KOMonthView::showDates(const QDate &start, const QDate &) { // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; QPtrVector<MonthViewCell> *cells; QPtrVector<QLabel> *dayLabels; QPtrVector<KOWeekButton> *weekLabels; int weekNum = 6; + mStartDate = start; if ( mShowWeekView ) { weekNum = 1; cells = &mCellsW; dayLabels = &mDayLabelsW; weekLabels = &mWeekLabelsW; + if ( !KGlobal::locale()->weekStartsMonday() ) { + mStartDate = mStartDate.addDays( 1 ); + } } else { cells = &mCells; dayLabels = &mDayLabels; weekLabels = &mWeekLabels; } - mStartDate = start; + int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); + if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { + mWeekStartsMonday = true; + } int startWeekDay = mWeekStartsMonday ? 1 : 7; while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { mStartDate = mStartDate.addDays( -1 ); } - bool primary = false; uint i; for( i = 0; i < (*cells).size(); ++i ) { QDate date = mStartDate.addDays( i ); (*cells)[i]->setDate( date ); #ifndef KORG_NOPLUGINS // add holiday, if present QString hstring(KOCore::self()->holiday(date)); (*cells)[i]->setHoliday( hstring ); #endif } QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); for( i = 0; i < weekNum; ++i ) { int wno; diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index a58f6b8..9e724c7 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -273,33 +273,33 @@ class KOMonthView: public KOEventView void viewChanged(); void updateDayLabels(); private: QTimer* mComputeLayoutTimer; NavigatorBar* mNavigatorBar; int currentWeek(); bool clPending; QWidgetStack * mWidStack; QWidget* mMonthView; QWidget* mWeekView; bool mShowWeekView; bool updatePossible; int mDaysPerWeek; int mNumWeeks; int mNumCells; - bool mWeekStartsMonday; + //bool mWeekStartsMonday; bool mShowSatSunComp; void computeLayout(); void computeLayoutWeek(); QPtrVector<MonthViewCell> mCells; QPtrVector<QLabel> mDayLabels; QPtrVector<KOWeekButton> mWeekLabels; QPtrVector<MonthViewCell> mCellsW; QPtrVector<QLabel> mDayLabelsW; QPtrVector<KOWeekButton> mWeekLabelsW; bool mShortDayLabelsM; bool mShortDayLabelsW; int mWidthLongDayLabel; QDate mStartDate; diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 2da592b..8e52968 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -1465,59 +1465,37 @@ void MainWindow::aboutKnownBugs() delete msg; } QString MainWindow::defaultFileName() { return locateLocal( "data", "korganizer/mycalendar.ics" ); } QString MainWindow::syncFileName() { #ifdef DESKTOP_VERSION return locateLocal( "tmp", "synccalendar.ics" ); #else return QString( "/tmp/synccalendar.ics" ); #endif } +#include "koglobals.h" +#include <kcalendarsystem.h> void MainWindow::updateWeek(QDate seda) { - int weekNum = 0; - QDate d = QDate ( seda.year(), 1,1); - seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday - if ( seda.addDays(6).year() != seda.year() ) { - if ( seda.year() != d.year() ) { - if ( d.dayOfWeek() > 4 ) - d = QDate ( seda.year(), 1,1); - else - weekNum = 1; - } else { - QDate dd( seda.year()+1, 1,1); - if ( dd.dayOfWeek() <= 4 ) - weekNum = 1; - } - } - if ( weekNum == 0 ){ - int dow = d.dayOfWeek(); - if ( dow <= 4 ) - d = d.addDays( 1-dow ); - else // 5,6,7 - d = d.addDays( 8-dow ); - // we have the first week of the year.we are on monday - weekNum = d.daysTo( seda ) / 7 +1; - } - + int weekNum = KGlobal::locale()->weekNum ( seda ); mWeekPixmap.fill( mWeekBgColor ); QPainter p ( &mWeekPixmap ); p.setFont( mWeekFont ); p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); p.end(); QIconSet icon3 ( mWeekPixmap ); mWeekAction->setIconSet ( icon3 ); } void MainWindow::updateWeekNum(const DateList &selectedDates) { updateWeek( selectedDates.first() ); } void MainWindow::processIncidenceSelection( Incidence *incidence ) { diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index 7f31ab1..1d8ae9f 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp @@ -255,32 +255,69 @@ void KLocale::setLanguage( int i ) mLanguage = i; } int KLocale::language( ) { return mLanguage; } QString KLocale::translate( const char *index ) const { return i18n( index ); } QString KLocale::translate( const char *, const char *fallback) const { return i18n( fallback ); } +int KLocale::weekNum ( const QDate & date ) +{ + QDate seda = date; + int weekNum = 0; + int dayofweek = seda.dayOfWeek(); // 1... 7 Mo .. So. Do = 4 + int daystoprevthursday = (dayofweek + 3) % 7 ; + int dayofyear = seda.dayOfYear(); + int prevThursday = dayofyear - ( daystoprevthursday ); + int subweeknum = 0; + if ( prevThursday < 1 ) { + seda = seda.addDays( - daystoprevthursday ); + dayofyear = seda.dayOfYear(); + prevThursday = dayofyear; + subweeknum = prevThursday / 7; + if ( prevThursday % 7 != 0 ) + ++subweeknum; + } else { + if ( dayofyear >= 360 ) { //maybe week 1 + seda = seda.addDays( 7 - daystoprevthursday ); + dayofyear = seda.dayOfYear(); + if ( dayofyear < 360 && ( dayofweek < 4 || dayofweek == 7 && !mWeekStartsMonday ) ) + return 1; + } + } + if ( ! weekNum ) { + weekNum = prevThursday / 7; + if ( prevThursday % 7 != 0 ) + ++weekNum; + if ( dayofweek < 4 ) + ++weekNum; + else if ( dayofweek == 7 && !mWeekStartsMonday ) + ++weekNum; + if ( weekNum > subweeknum ) + weekNum -= subweeknum; + } + return weekNum; +} QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const { const QString rst = timeFormat(intIntDateFormat); // only "pm/am" here can grow, the rest shrinks, but // I'm rather safe than sorry QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; uint index = 0; bool escape = false; int number = 0; for ( uint format_index = 0; format_index < rst.length(); format_index++ ) { if ( !escape ) { diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h index 14660d6..58e0b39 100644 --- a/microkde/kdecore/klocale.h +++ b/microkde/kdecore/klocale.h @@ -52,33 +52,33 @@ class KLocale QDate readDate(const QString &str, bool* ok = 0) const; QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; QTime readTime(const QString &str, bool* ok = 0) const; QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; bool use12Clock() const; bool weekStartsMonday() const; int weekStartDay() const; QString weekDayName(int,bool=false) const; QString monthName(int,bool=false) const; QString country() const; - + int weekNum ( const QDate & ); QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const; void insertCatalogue ( const QString & ); KCalendarSystem *calendar(); void setHore24Format ( bool ); void setWeekStartMonday( bool ); void setIntDateFormat( IntDateFormat ); void setIntTimeFormat( IntDateFormat ); IntDateFormat getIntDateFormat( ); IntDateFormat getIntTimeFormat( ); void setLanguage( int ); int language(); void setDateFormat( QString ); |