summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-28 23:39:37 (UTC)
committer zautrix <zautrix>2005-03-28 23:39:37 (UTC)
commit4e7c45695672ecdbd0cd14cac0ea29a8e134ee78 (patch) (unidiff)
tree6815e055d6cb35d56d43f036261f5be9d2a9c350
parent4034290f894ff7d1b0cf1197078e0ed832566bb7 (diff)
downloadkdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.zip
kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.tar.gz
kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.tar.bz2
montview sunday fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt2
-rw-r--r--korganizer/kdatenavigator.cpp18
-rw-r--r--korganizer/komonthview.cpp25
-rw-r--r--korganizer/komonthview.h2
-rw-r--r--korganizer/mainwindow.cpp28
-rw-r--r--microkde/kdecore/klocale.cpp37
-rw-r--r--microkde/kdecore/klocale.h2
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
@@ -6,12 +6,14 @@ KO/Pi:
6Fix for creating events/todos via the abgenda context menu. 6Fix for creating events/todos via the abgenda context menu.
7Added option to split toolbar to 3 toolbars. 7Added option to split toolbar to 3 toolbars.
8Added option to show one small filter-view-toolbar. 8Added option to show one small filter-view-toolbar.
9Added a print option to the desktop version: 9Added a print option to the desktop version:
10Now you can print out the view of the "Event Viewer". 10Now you can print out the view of the "Event Viewer".
11That means you can print all data of one particular event/todo. 11That means you can print all data of one particular event/todo.
12Added scaling options to printout of Event Viewer and What'sNext View.
13Fixed some problems in the month view in "week start sunday" mode.
12 14
13********** VERSION 2.0.21 ************ 15********** VERSION 2.0.21 ************
14 16
15Fixed another SMTP problem in OM/Pi. 17Fixed another SMTP problem in OM/Pi.
16Some small changed in the new datenavigator in KO/Pi. 18Some small changed in the new datenavigator in KO/Pi.
17Changed default setting for new filter in KA/Pi to "exclude categories". 19Changed default setting for new filter in KA/Pi to "exclude categories".
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 38bddc2..2fca49e 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -319,31 +319,29 @@ void KDateNavigator::updateView()
319 setUpdatesEnabled( false ); 319 setUpdatesEnabled( false );
320 320
321 int i; 321 int i;
322 322
323// kdDebug() << "updateView() -> daymatrix->updateView()" << endl; 323// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
324 daymatrix->updateView(); 324 daymatrix->updateView();
325 325 int sub = 4;
326 if ( ! KGlobal::locale()->weekStartsMonday() )
327 --sub;
326 // set the week numbers. 328 // set the week numbers.
327 for(i = 0; i < 6; i++) { 329 for(i = 0; i < 6; i++) {
328 QString weeknum;
329 // remember, according to ISO 8601, the first week of the year is the 330 // remember, according to ISO 8601, the first week of the year is the
330 // first week that contains a thursday. Thus we must subtract off 4, 331 // first week that contains a thursday. Thus we must subtract off 4,
331 // not just 1. 332 // not just 1.
332 333
333 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); 334 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear();
334 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); 335 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub)));
335 336 int weekNo;
336 int add = 0;
337 if ( ! KGlobal::locale()->weekStartsMonday() )
338 ++add;
339 if (dayOfYear % 7 != 0) 337 if (dayOfYear % 7 != 0)
340 weeknum.setNum(dayOfYear / 7 + 1+add); 338 weekNo = (dayOfYear / 7 + 1);
341 else 339 else
342 weeknum.setNum(dayOfYear / 7 +add); 340 weekNo = (dayOfYear / 7);
343 weeknos[i]->setText(weeknum); 341 weeknos[i]->setText(QString::number( weekNo ));
344 } 342 }
345 343
346 setUpdatesEnabled( true ); 344 setUpdatesEnabled( true );
347// kdDebug() << "updateView() -> repaint()" << endl; 345// kdDebug() << "updateView() -> repaint()" << endl;
348 repaint(); 346 repaint();
349 // daymatrix->repaint(); 347 // daymatrix->repaint();
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9085775..d825493 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -998,16 +998,13 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
998#else 998#else
999 mWidStack->addWidget( mMonthView, 1 ); 999 mWidStack->addWidget( mMonthView, 1 );
1000 mWidStack->addWidget( mWeekView , 1 ); 1000 mWidStack->addWidget( mWeekView , 1 );
1001#endif 1001#endif
1002 hb->addWidget( mNavigatorBar ); 1002 hb->addWidget( mNavigatorBar );
1003 hb->addWidget( mWidStack ); 1003 hb->addWidget( mWidStack );
1004 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1005 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1004 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1006 if ( mShowWeekView )
1007 mWeekStartsMonday = true;
1008 updatePossible = false; 1005 updatePossible = false;
1009 //updatePossible = true; 1006 //updatePossible = true;
1010 mCells.setAutoDelete( true ); 1007 mCells.setAutoDelete( true );
1011 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1008 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1012 mDayLabels.resize( mDaysPerWeek ); 1009 mDayLabels.resize( mDaysPerWeek );
1013 mDayLabelsW.resize( mDaysPerWeek ); 1010 mDayLabelsW.resize( mDaysPerWeek );
@@ -1214,15 +1211,15 @@ void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1214#endif 1211#endif
1215} 1212}
1216 1213
1217void KOMonthView::updateConfig() 1214void KOMonthView::updateConfig()
1218{ 1215{
1219 1216
1220 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1217 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1221 1218
1222 if ( mShowWeekView ) { 1219 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1223 mWeekStartsMonday = true; 1220 mWeekStartsMonday = true;
1224 } 1221 }
1225 QFontMetrics fontmetric(mDayLabels[0]->font()); 1222 QFontMetrics fontmetric(mDayLabels[0]->font());
1226 mWidthLongDayLabel = 0; 1223 mWidthLongDayLabel = 0;
1227 1224
1228 for (int i = 0; i < 7; i++) { 1225 for (int i = 0; i < 7; i++) {
@@ -1256,26 +1253,22 @@ void KOMonthView::updateDayLabels()
1256{ 1253{
1257 1254
1258 QPtrVector<QLabel> *mDayLabelsT; 1255 QPtrVector<QLabel> *mDayLabelsT;
1259 1256
1260 mDayLabelsT = &mDayLabelsW; 1257 mDayLabelsT = &mDayLabelsW;
1261 for (int i = 0; i < 7; i++) { 1258 for (int i = 0; i < 7; i++) {
1262 if (mWeekStartsMonday) { 1259 {
1263 bool show = mShortDayLabelsW; 1260 bool show = mShortDayLabelsW;
1264 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1261 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1265 show = true; 1262 show = true;
1266 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1263 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1267 } else {
1268 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW));
1269 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW));
1270
1271 } 1264 }
1272 } 1265 }
1273 mDayLabelsT = &mDayLabels; 1266 mDayLabelsT = &mDayLabels;
1274 for (int i = 0; i < 7; i++) { 1267 for (int i = 0; i < 7; i++) {
1275 if (mWeekStartsMonday) { 1268 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
1276 bool show = mShortDayLabelsM; 1269 bool show = mShortDayLabelsM;
1277 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1270 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1278 show = true; 1271 show = true;
1279 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1272 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1280 } else { 1273 } else {
1281 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1274 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
@@ -1291,31 +1284,37 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
1291 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1284 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1292 1285
1293 QPtrVector<MonthViewCell> *cells; 1286 QPtrVector<MonthViewCell> *cells;
1294 QPtrVector<QLabel> *dayLabels; 1287 QPtrVector<QLabel> *dayLabels;
1295 QPtrVector<KOWeekButton> *weekLabels; 1288 QPtrVector<KOWeekButton> *weekLabels;
1296 int weekNum = 6; 1289 int weekNum = 6;
1290 mStartDate = start;
1297 if ( mShowWeekView ) { 1291 if ( mShowWeekView ) {
1298 weekNum = 1; 1292 weekNum = 1;
1299 cells = &mCellsW; 1293 cells = &mCellsW;
1300 dayLabels = &mDayLabelsW; 1294 dayLabels = &mDayLabelsW;
1301 weekLabels = &mWeekLabelsW; 1295 weekLabels = &mWeekLabelsW;
1296 if ( !KGlobal::locale()->weekStartsMonday() ) {
1297 mStartDate = mStartDate.addDays( 1 );
1298 }
1302 } else { 1299 } else {
1303 cells = &mCells; 1300 cells = &mCells;
1304 dayLabels = &mDayLabels; 1301 dayLabels = &mDayLabels;
1305 weekLabels = &mWeekLabels; 1302 weekLabels = &mWeekLabels;
1306 } 1303 }
1307 1304
1308 mStartDate = start; 1305 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1309 1306
1307 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1308 mWeekStartsMonday = true;
1309 }
1310 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1310 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1311 1311
1312 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1312 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1313 mStartDate = mStartDate.addDays( -1 ); 1313 mStartDate = mStartDate.addDays( -1 );
1314 } 1314 }
1315
1316 bool primary = false; 1315 bool primary = false;
1317 uint i; 1316 uint i;
1318 for( i = 0; i < (*cells).size(); ++i ) { 1317 for( i = 0; i < (*cells).size(); ++i ) {
1319 QDate date = mStartDate.addDays( i ); 1318 QDate date = mStartDate.addDays( i );
1320 (*cells)[i]->setDate( date ); 1319 (*cells)[i]->setDate( date );
1321 1320
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index a58f6b8..9e724c7 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -283,13 +283,13 @@ class KOMonthView: public KOEventView
283 QWidget* mWeekView; 283 QWidget* mWeekView;
284 bool mShowWeekView; 284 bool mShowWeekView;
285 bool updatePossible; 285 bool updatePossible;
286 int mDaysPerWeek; 286 int mDaysPerWeek;
287 int mNumWeeks; 287 int mNumWeeks;
288 int mNumCells; 288 int mNumCells;
289 bool mWeekStartsMonday; 289 //bool mWeekStartsMonday;
290 bool mShowSatSunComp; 290 bool mShowSatSunComp;
291 void computeLayout(); 291 void computeLayout();
292 void computeLayoutWeek(); 292 void computeLayoutWeek();
293 293
294 QPtrVector<MonthViewCell> mCells; 294 QPtrVector<MonthViewCell> mCells;
295 QPtrVector<QLabel> mDayLabels; 295 QPtrVector<QLabel> mDayLabels;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 2da592b..8e52968 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1475,39 +1475,17 @@ QString MainWindow::syncFileName()
1475#ifdef DESKTOP_VERSION 1475#ifdef DESKTOP_VERSION
1476 return locateLocal( "tmp", "synccalendar.ics" ); 1476 return locateLocal( "tmp", "synccalendar.ics" );
1477#else 1477#else
1478 return QString( "/tmp/synccalendar.ics" ); 1478 return QString( "/tmp/synccalendar.ics" );
1479#endif 1479#endif
1480} 1480}
1481#include "koglobals.h"
1482#include <kcalendarsystem.h>
1481void MainWindow::updateWeek(QDate seda) 1483void MainWindow::updateWeek(QDate seda)
1482{ 1484{
1483 int weekNum = 0; 1485 int weekNum = KGlobal::locale()->weekNum ( seda );
1484 QDate d = QDate ( seda.year(), 1,1);
1485 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday
1486 if ( seda.addDays(6).year() != seda.year() ) {
1487 if ( seda.year() != d.year() ) {
1488 if ( d.dayOfWeek() > 4 )
1489 d = QDate ( seda.year(), 1,1);
1490 else
1491 weekNum = 1;
1492 } else {
1493 QDate dd( seda.year()+1, 1,1);
1494 if ( dd.dayOfWeek() <= 4 )
1495 weekNum = 1;
1496 }
1497 }
1498 if ( weekNum == 0 ){
1499 int dow = d.dayOfWeek();
1500 if ( dow <= 4 )
1501 d = d.addDays( 1-dow );
1502 else // 5,6,7
1503 d = d.addDays( 8-dow );
1504 // we have the first week of the year.we are on monday
1505 weekNum = d.daysTo( seda ) / 7 +1;
1506 }
1507
1508 mWeekPixmap.fill( mWeekBgColor ); 1486 mWeekPixmap.fill( mWeekBgColor );
1509 QPainter p ( &mWeekPixmap ); 1487 QPainter p ( &mWeekPixmap );
1510 p.setFont( mWeekFont ); 1488 p.setFont( mWeekFont );
1511 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1489 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1512 p.end(); 1490 p.end();
1513 QIconSet icon3 ( mWeekPixmap ); 1491 QIconSet icon3 ( mWeekPixmap );
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
@@ -265,12 +265,49 @@ QString KLocale::translate( const char *index ) const
265 265
266QString KLocale::translate( const char *, const char *fallback) const 266QString KLocale::translate( const char *, const char *fallback) const
267{ 267{
268 return i18n( fallback ); 268 return i18n( fallback );
269} 269}
270 270
271int KLocale::weekNum ( const QDate & date )
272{
273 QDate seda = date;
274 int weekNum = 0;
275 int dayofweek = seda.dayOfWeek(); // 1... 7 Mo .. So. Do = 4
276 int daystoprevthursday = (dayofweek + 3) % 7 ;
277 int dayofyear = seda.dayOfYear();
278 int prevThursday = dayofyear - ( daystoprevthursday );
279 int subweeknum = 0;
280 if ( prevThursday < 1 ) {
281 seda = seda.addDays( - daystoprevthursday );
282 dayofyear = seda.dayOfYear();
283 prevThursday = dayofyear;
284 subweeknum = prevThursday / 7;
285 if ( prevThursday % 7 != 0 )
286 ++subweeknum;
287 } else {
288 if ( dayofyear >= 360 ) { //maybe week 1
289 seda = seda.addDays( 7 - daystoprevthursday );
290 dayofyear = seda.dayOfYear();
291 if ( dayofyear < 360 && ( dayofweek < 4 || dayofweek == 7 && !mWeekStartsMonday ) )
292 return 1;
293 }
294 }
295 if ( ! weekNum ) {
296 weekNum = prevThursday / 7;
297 if ( prevThursday % 7 != 0 )
298 ++weekNum;
299 if ( dayofweek < 4 )
300 ++weekNum;
301 else if ( dayofweek == 7 && !mWeekStartsMonday )
302 ++weekNum;
303 if ( weekNum > subweeknum )
304 weekNum -= subweeknum;
305 }
306 return weekNum;
307}
271QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const 308QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const
272{ 309{
273 const QString rst = timeFormat(intIntDateFormat); 310 const QString rst = timeFormat(intIntDateFormat);
274 311
275 // only "pm/am" here can grow, the rest shrinks, but 312 // only "pm/am" here can grow, the rest shrinks, but
276 // I'm rather safe than sorry 313 // I'm rather safe than sorry
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
@@ -62,13 +62,13 @@ class KLocale
62 int weekStartDay() const; 62 int weekStartDay() const;
63 63
64 QString weekDayName(int,bool=false) const; 64 QString weekDayName(int,bool=false) const;
65 QString monthName(int,bool=false) const; 65 QString monthName(int,bool=false) const;
66 66
67 QString country() const; 67 QString country() const;
68 68 int weekNum ( const QDate & );
69 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; 69 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const;
70 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; 70 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const;
71 QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const; 71 QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const;
72 72
73 void insertCatalogue ( const QString & ); 73 void insertCatalogue ( const QString & );
74 74