summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt2
-rw-r--r--korganizer/komonthview.cpp207
-rw-r--r--korganizer/komonthview.h10
3 files changed, 168 insertions, 51 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index e24ee43..3ba0841 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,60 +1,62 @@
1Info about the changes in new versions of KDE-Pim/Pi 1Info about the changes in new versions of KDE-Pim/Pi
2 2
3********** VERSION 2.0.3 ************ 3********** VERSION 2.0.3 ************
4 4
5KO/Pi: 5KO/Pi:
6Added feature for changing alarm settings for many items at once: 6Added feature for changing alarm settings for many items at once:
7Open list view (or search dialog), select the desired items and choose in 7Open list view (or search dialog), select the desired items and choose in
8the popup menu: Set alarm for selected... 8the popup menu: Set alarm for selected...
9 9
10Added to the event/todo viewer the option to send an email to 10Added to the event/todo viewer the option to send an email to
11all attendees or all selected (with RSVP) attendees. 11all attendees or all selected (with RSVP) attendees.
12 12
13Made the week-month mode changing in month view faster.
14
13********** VERSION 2.0.2 ************ 15********** VERSION 2.0.2 ************
14 16
15KO/Pi: 17KO/Pi:
16Fixed the layout problem of the day label buttons 18Fixed the layout problem of the day label buttons
17of the agenda view introduced in version 2.0.1. 19of the agenda view introduced in version 2.0.1.
18 20
19Added WhatsThis support for the todo view and the list view. 21Added WhatsThis support for the todo view and the list view.
20 22
21Added a quite useful feature to the montview. 23Added a quite useful feature to the montview.
22Just click on the week numbers on the left. 24Just click on the week numbers on the left.
23And in the top right corner of month view/agenda view 25And in the top right corner of month view/agenda view
24there is now a "week number quick selector". 26there is now a "week number quick selector".
25(Click on the black triangle). 27(Click on the black triangle).
26 28
27Made the quite difficult timezone change in KO/Pi easy. 29Made the quite difficult timezone change in KO/Pi easy.
28 30
29OM/Pi: 31OM/Pi:
30Fixed too small icons on desktop. 32Fixed too small icons on desktop.
31Fixed non visible icons in mainwindow on Z with fastload enabled. 33Fixed non visible icons in mainwindow on Z with fastload enabled.
32Added signature file setting to smtp account config. 34Added signature file setting to smtp account config.
33And the signature can be edited and saved in the edit mail dialog. 35And the signature can be edited and saved in the edit mail dialog.
34That does mean: 36That does mean:
35Simply edit the signature for the selected smtp account in the 37Simply edit the signature for the selected smtp account in the
36edit new mail dialog and press the "save signature" button there. 38edit new mail dialog and press the "save signature" button there.
37Then the signature is saved to the file specified in the smtp account settings. 39Then the signature is saved to the file specified in the smtp account settings.
38If there is no file specified, it is saved automatically to the file 40If there is no file specified, it is saved automatically to the file
39kdepim/apps/kopiemail/<accountname>.sig. 41kdepim/apps/kopiemail/<accountname>.sig.
40 42
41 43
42 44
43********** VERSION 2.0.1 ************ 45********** VERSION 2.0.1 ************
44 46
45Oooops ... I forgot to test on the Zaurus 5500 ... 47Oooops ... I forgot to test on the Zaurus 5500 ...
46 48
47Fixed many problems of new (english) strings (and german translations) 49Fixed many problems of new (english) strings (and german translations)
48introduced in the latest versions, where the text was not fitting on the 50introduced in the latest versions, where the text was not fitting on the
49240x320 display of the Zaurus 5500. 51240x320 display of the Zaurus 5500.
50 52
51KO/Pi: 53KO/Pi:
52Added a popup menu ( press pen and hold to get popup ) to the agenda view 54Added a popup menu ( press pen and hold to get popup ) to the agenda view
53with many useful items (add event/todo, show next week, two weeks, month, journal). 55with many useful items (add event/todo, show next week, two weeks, month, journal).
54 56
55Added items to the todolist popup menu for: 57Added items to the todolist popup menu for:
56Display all opened, all closed or all todos flat. 58Display all opened, all closed or all todos flat.
57The "flat" view makes is possible to sort all todos after ,e.g., prio or date. 59The "flat" view makes is possible to sort all todos after ,e.g., prio or date.
58Made the reparenting of todos on the desktop possible via Drag&Drop. 60Made the reparenting of todos on the desktop possible via Drag&Drop.
59Fixed several bugs in setting the completed datetime for todos. 61Fixed several bugs in setting the completed datetime for todos.
60Added info about completed datetime of todos to the todo viewer. 62Added info about completed datetime of todos to the todo viewer.
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9c1e4c3..daa37fd 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,73 +1,74 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qwidgetstack.h>
26#include <qpushbutton.h> 27#include <qpushbutton.h>
27#include <qtooltip.h> 28#include <qtooltip.h>
28#include <qpainter.h> 29#include <qpainter.h>
29#include <qwhatsthis.h> 30#include <qwhatsthis.h>
30#ifndef DESKTOP_VERSION 31#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
32#else 33#else
33#include <qapplication.h> 34#include <qapplication.h>
34#endif 35#endif
35 36
36#include <kdebug.h> 37#include <kdebug.h>
37#include <klocale.h> 38#include <klocale.h>
38#include <kglobal.h> 39#include <kglobal.h>
39#include <kconfig.h> 40#include <kconfig.h>
40#include <kiconloader.h> 41#include <kiconloader.h>
41 42
42#include <kcalendarsystem.h> 43#include <kcalendarsystem.h>
43 44
44#ifndef KORG_NOPRINTER 45#ifndef KORG_NOPRINTER
45#include "calprinter.h" 46#include "calprinter.h"
46#endif 47#endif
47#include "koprefs.h" 48#include "koprefs.h"
48#ifndef KORG_NOPLUGINS 49#ifndef KORG_NOPLUGINS
49#include "kocore.h" 50#include "kocore.h"
50#endif 51#endif
51#include "koglobals.h" 52#include "koglobals.h"
52#include <libkcal/kincidenceformatter.h> 53#include <libkcal/kincidenceformatter.h>
53 54
54#include "komonthview.h" 55#include "komonthview.h"
55 56
56#define PIXMAP_SIZE 5 57#define PIXMAP_SIZE 5
57#ifdef DESKTOP_VERSION 58#ifdef DESKTOP_VERSION
58QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 59QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
59#endif 60#endif
60class KNOWhatsThis :public QWhatsThis 61class KNOWhatsThis :public QWhatsThis
61{ 62{
62public: 63public:
63 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 64 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
64 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 65 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
65 66
66protected: 67protected:
67 virtual QString text( const QPoint& p) 68 virtual QString text( const QPoint& p)
68 { 69 {
69 return _wid->getWhatsThisText(p) ; 70 return _wid->getWhatsThisText(p) ;
70 }; 71 };
71private: 72private:
72 KNoScrollListBox* _wid; 73 KNoScrollListBox* _wid;
73 74
@@ -223,98 +224,98 @@ void MonthViewItem::paint(QPainter *p)
223 x += size + 1; 224 x += size + 1;
224 } 225 }
225 } 226 }
226 QFontMetrics fm = p->fontMetrics(); 227 QFontMetrics fm = p->fontMetrics();
227 int yPos; 228 int yPos;
228 int pmheight = size; 229 int pmheight = size;
229 if( pmheight < fm.height() ) 230 if( pmheight < fm.height() )
230 yPos = fm.ascent() + fm.leading()/2; 231 yPos = fm.ascent() + fm.leading()/2;
231 else 232 else
232 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 233 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
233 p->setPen( palette().color( QPalette::Normal, sel ? \ 234 p->setPen( palette().color( QPalette::Normal, sel ? \
234 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 235 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
235 p->drawText( x, yPos, text() ); 236 p->drawText( x, yPos, text() );
236 if ( mIncidence->cancelled() ) { 237 if ( mIncidence->cancelled() ) {
237 int wid = fm.width( text() ); 238 int wid = fm.width( text() );
238 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); 239 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2);
239 } 240 }
240 241
241} 242}
242 243
243int MonthViewItem::height(const QListBox *lb) const 244int MonthViewItem::height(const QListBox *lb) const
244{ 245{
245 return lb->fontMetrics().lineSpacing()+1; 246 return lb->fontMetrics().lineSpacing()+1;
246} 247}
247 248
248int MonthViewItem::width(const QListBox *lb) const 249int MonthViewItem::width(const QListBox *lb) const
249{ 250{
250 int size = PIXMAP_SIZE; 251 int size = PIXMAP_SIZE;
251 if ( QApplication::desktop()->width() < 300 ) 252 if ( QApplication::desktop()->width() < 300 )
252 size = 3; 253 size = 3;
253 int x = 1; 254 int x = 1;
254 if ( mInfo ) { 255 if ( mInfo ) {
255 x += size + 1; 256 x += size + 1;
256 } 257 }
257 if( mRecur ) { 258 if( mRecur ) {
258 x += size+1; 259 x += size+1;
259 } 260 }
260 if( mAlarm ) { 261 if( mAlarm ) {
261 x += size+1; 262 x += size+1;
262 } 263 }
263 if( mReply ) { 264 if( mReply ) {
264 x += size+1; 265 x += size+1;
265 } 266 }
266 267
267 return( x + lb->fontMetrics().width( text() ) + 1 ); 268 return( x + lb->fontMetrics().width( text() ) + 1 );
268} 269}
269 270
270 271
271MonthViewCell::MonthViewCell( KOMonthView *parent) 272MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
272 : QWidget( parent ), 273 : QWidget( par ),
273 mMonthView( parent ) 274 mMonthView( parent )
274{ 275{
275 276
276 QVBoxLayout *topLayout = new QVBoxLayout( this ); 277 QVBoxLayout *topLayout = new QVBoxLayout( this );
277 278
278 // mLabel = new QLabel( this );QPushButton 279 // mLabel = new QLabel( this );QPushButton
279 mLabel = new QPushButton( this ); 280 mLabel = new QPushButton( this );
280 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 281 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
281 //mLabel->setLineWidth( 1 ); 282 //mLabel->setLineWidth( 1 );
282 //mLabel->setAlignment( AlignCenter ); 283 //mLabel->setAlignment( AlignCenter );
283 mLabel->setFlat( true ); 284 mLabel->setFlat( true );
284 mItemList = new KNoScrollListBox( this ); 285 mItemList = new KNoScrollListBox( this );
285 mItemList->setMinimumSize( 10, 10 ); 286 mItemList->setMinimumSize( 10, 10 );
286 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 287 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
287 mItemList->setLineWidth( 1 ); 288 mItemList->setLineWidth( 1 );
288 topLayout->addWidget( mItemList ); 289 topLayout->addWidget( mItemList );
289 mLabel->raise(); 290 mLabel->raise();
290 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 291 // QColor( 0,0,255 ) QColor( 160,1600,255 )
291 mStandardPalette = palette(); 292 mStandardPalette = palette();
292 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 293 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
293 294
294 enableScrollBars( false ); 295 enableScrollBars( false );
295 updateConfig(); 296 updateConfig();
296 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 297 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
297 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 298 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
298 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 299 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
299 SLOT( defaultAction( QListBoxItem * ) ) ); 300 SLOT( defaultAction( QListBoxItem * ) ) );
300 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 301 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
301 const QPoint &) ), 302 const QPoint &) ),
302 SLOT( contextMenu( QListBoxItem * ) ) ); 303 SLOT( contextMenu( QListBoxItem * ) ) );
303 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 304 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
304 SLOT( selection( QListBoxItem * ) ) ); 305 SLOT( selection( QListBoxItem * ) ) );
305 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 306 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
306 SLOT( cellClicked( QListBoxItem * ) ) ); 307 SLOT( cellClicked( QListBoxItem * ) ) );
307 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 308 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
308 SLOT( selection( QListBoxItem * ) ) ); 309 SLOT( selection( QListBoxItem * ) ) );
309} 310}
310#ifdef DESKTOP_VERSION 311#ifdef DESKTOP_VERSION
311QToolTipGroup *MonthViewCell::toolTipGroup() 312QToolTipGroup *MonthViewCell::toolTipGroup()
312{ 313{
313 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 314 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
314 return mToolTipGroup; 315 return mToolTipGroup;
315} 316}
316#endif 317#endif
317 318
318void MonthViewCell::setDate( const QDate &date ) 319void MonthViewCell::setDate( const QDate &date )
319{ 320{
320 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 321 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
@@ -721,662 +722,768 @@ void MonthViewCell::newEvent()
721void MonthViewCell::cellClicked( QListBoxItem *item ) 722void MonthViewCell::cellClicked( QListBoxItem *item )
722{ 723{
723 static QListBoxItem * lastClicked = 0; 724 static QListBoxItem * lastClicked = 0;
724 if ( item == 0 ) { 725 if ( item == 0 ) {
725 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 726 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
726 emit newEventSignal( dt ); 727 emit newEventSignal( dt );
727 return; 728 return;
728 } 729 }
729 /* 730 /*
730 if ( lastClicked ) 731 if ( lastClicked )
731 if ( ! item ) { 732 if ( ! item ) {
732 if ( lastClicked->listBox() != item->listBox() ) 733 if ( lastClicked->listBox() != item->listBox() )
733 lastClicked->listBox()->clearSelection(); 734 lastClicked->listBox()->clearSelection();
734 } 735 }
735 */ 736 */
736 737
737 mMonthView->setSelectedCell( this ); 738 mMonthView->setSelectedCell( this );
738 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 739 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
739 select(); 740 select();
740} 741}
741 742
742void MonthViewCell::contextMenu( QListBoxItem *item ) 743void MonthViewCell::contextMenu( QListBoxItem *item )
743{ 744{
744 if ( !item ) return; 745 if ( !item ) return;
745 746
746 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 747 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
747 Incidence *incidence = eventItem->incidence(); 748 Incidence *incidence = eventItem->incidence();
748 if ( incidence ) mMonthView->showContextMenu( incidence ); 749 if ( incidence ) mMonthView->showContextMenu( incidence );
749} 750}
750 751
751void MonthViewCell::selection( QListBoxItem *item ) 752void MonthViewCell::selection( QListBoxItem *item )
752{ 753{
753 if ( !item ) return; 754 if ( !item ) return;
754 755
755 mMonthView->setSelectedCell( this ); 756 mMonthView->setSelectedCell( this );
756} 757}
757 758
758 759
759// ******************************************************************************* 760// *******************************************************************************
760// ******************************************************************************* 761// *******************************************************************************
761// ******************************************************************************* 762// *******************************************************************************
762 763
763 764
764KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 765KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
765 : KOEventView( calendar, parent, name ), 766 : KOEventView( calendar, parent, name ),
766 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 767 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
767 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 768 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
768{ 769{
770
771 clPending = true;
772 mWidStack = new QWidgetStack( this );
773 QHBoxLayout* hb = new QHBoxLayout( this );
774 mMonthView = new QWidget( mWidStack );
775 mWeekView = new QWidget( mWidStack );
776#if QT_VERSION >= 0x030000
777 mWidStack->addWidget(mMonthView );
778 mWidStack->addWidget(mWeekView );
779#else
780 mWidStack->addWidget( mMonthView, 1 );
781 mWidStack->addWidget( mWeekView , 1 );
782#endif
783 hb->addWidget( mWidStack );
769 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 784 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
770 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 785 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
771 if ( mShowWeekView ) 786 if ( mShowWeekView )
772 mWeekStartsMonday = true; 787 mWeekStartsMonday = true;
773 updatePossible = false; 788 updatePossible = false;
774 mCells.setAutoDelete( true ); 789 mCells.setAutoDelete( true );
775 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 790 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
776 // mDayLayout = new QGridLayout( this );
777 // create the day of the week labels (Sun, Mon, etc) and add them to
778 // the layout.
779 mDayLabels.resize( mDaysPerWeek ); 791 mDayLabels.resize( mDaysPerWeek );
792 mDayLabelsW.resize( mDaysPerWeek );
780 QFont bfont = font(); 793 QFont bfont = font();
781 if ( QApplication::desktop()->width() < 650 ) { 794 if ( QApplication::desktop()->width() < 650 ) {
782 bfont.setPointSize( bfont.pointSize() - 2 ); 795 bfont.setPointSize( bfont.pointSize() - 2 );
783 } 796 }
784 bfont.setBold( true ); 797 bfont.setBold( true );
785 int i; 798 int i;
786 799
787 for( i = 0; i < mDaysPerWeek; i++ ) { 800 for( i = 0; i < mDaysPerWeek; i++ ) {
788 QLabel *label = new QLabel( this ); 801 QLabel *label = new QLabel( mMonthView );
789 label->setFont(bfont); 802 label->setFont(bfont);
790 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 803 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
791 label->setLineWidth(1); 804 label->setLineWidth(1);
792 label->setAlignment(AlignCenter); 805 label->setAlignment(AlignCenter);
793 mDayLabels.insert( i, label ); 806 mDayLabels.insert( i, label );
807 label = new QLabel( mWeekView );
808 label->setFont(bfont);
809 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
810 label->setLineWidth(1);
811 label->setAlignment(AlignCenter);
812 mDayLabelsW.insert( i, label );
794 } 813 }
795 814
796 bfont.setBold( false ); 815 bfont.setBold( false );
797 mWeekLabels.resize( mNumWeeks+1 ); 816 mWeekLabels.resize( mNumWeeks+1 );
817 mWeekLabelsW.resize( 2 );
798 for( i = 0; i < mNumWeeks+1; i++ ) { 818 for( i = 0; i < mNumWeeks+1; i++ ) {
799 KOWeekButton *label = new KOWeekButton( this ); 819 KOWeekButton *label = new KOWeekButton( mMonthView );
800 label->setFont(bfont); 820 label->setFont(bfont);
801 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 821 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
802 label->setFlat(true); 822 label->setFlat(true);
803 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 823 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
804 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 824 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
805 //label->setLineWidth(1); 825 //label->setLineWidth(1);
806 //label->setAlignment(AlignCenter); 826 //label->setAlignment(AlignCenter);
807 mWeekLabels.insert( i, label ); 827 mWeekLabels.insert( i, label );
808 } 828 }
809 mWeekLabels[mNumWeeks]->setText( i18n("")); 829 mWeekLabels[mNumWeeks]->setText( i18n("W"));
810 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 830 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
831
832 for( i = 0; i < 1+1; i++ ) {
833 KOWeekButton *label = new KOWeekButton( mWeekView );
834 label->setFont(bfont);
835 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
836 label->setFlat(true);
837 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
838 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
839 //label->setLineWidth(1);
840 //label->setAlignment(AlignCenter);
841 mWeekLabelsW.insert( i, label );
842 }
843 mWeekLabelsW[1]->setText( i18n("W"));
844
845
811 int row, col; 846 int row, col;
812 mCells.resize( mNumCells ); 847 mCells.resize( mNumCells );
813 for( row = 0; row < mNumWeeks; ++row ) { 848 for( row = 0; row < mNumWeeks; ++row ) {
814 for( col = 0; col < mDaysPerWeek; ++col ) { 849 for( col = 0; col < mDaysPerWeek; ++col ) {
815 MonthViewCell *cell = new MonthViewCell( this ); 850 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
816 mCells.insert( row * mDaysPerWeek + col, cell ); 851 mCells.insert( row * mDaysPerWeek + col, cell );
817 852
818 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 853 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
819 SLOT( defaultAction( Incidence * ) ) ); 854 SLOT( defaultAction( Incidence * ) ) );
820 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 855 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
821 SIGNAL( newEventSignal( QDateTime ) ) ); 856 SIGNAL( newEventSignal( QDateTime ) ) );
822 connect( cell, SIGNAL( showDaySignal( QDate ) ), 857 connect( cell, SIGNAL( showDaySignal( QDate ) ),
823 SIGNAL( showDaySignal( QDate ) ) ); 858 SIGNAL( showDaySignal( QDate ) ) );
824 } 859 }
825 } 860 }
861 mCellsW.resize( mDaysPerWeek );
862 for( col = 0; col < mDaysPerWeek; ++col ) {
863 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
864 mCellsW.insert( col, cell );
865
866 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
867 SLOT( defaultAction( Incidence * ) ) );
868 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
869 SIGNAL( newEventSignal( QDateTime ) ) );
870 connect( cell, SIGNAL( showDaySignal( QDate ) ),
871 SIGNAL( showDaySignal( QDate ) ) );
872 }
826 873
827 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 874 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
828 mContextMenu = eventPopup(); 875 mContextMenu = eventPopup();
829 // updateConfig(); //useless here 876 // updateConfig(); //useless here
830 877
831 mWeekLabels[mNumWeeks]->setText( i18n("W")); 878 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
879#if 0
880 mWidStack = new QWidgetStack( this );
881 mMonthView = new QWidget( mWidStack );
882 mWeekView = new QWidget( mWidStack );
883#endif
884 if ( mShowWeekView )
885 mWidStack->raiseWidget( mWeekView );
886 else
887 mWidStack->raiseWidget( mMonthView );
888
832 emit incidenceSelected( 0 ); 889 emit incidenceSelected( 0 );
833} 890}
834 891
835KOMonthView::~KOMonthView() 892KOMonthView::~KOMonthView()
836{ 893{
837 delete mContextMenu; 894 delete mContextMenu;
838} 895}
839void KOMonthView::selectDateWeekNum ( int ) 896void KOMonthView::selectDateWeekNum ( int )
840{ 897{
841 898
842} 899}
843void KOMonthView::selectInternalWeekNum ( int n ) 900void KOMonthView::selectInternalWeekNum ( int n )
844{ 901{
845 emit selectWeekNum ( n );
846 switchView(); 902 switchView();
903 emit selectWeekNum ( n );
847} 904}
848 905
849void KOMonthView::switchView() 906void KOMonthView::switchView()
850{ 907{
908
851 if ( selectedCell( ) ) 909 if ( selectedCell( ) )
852 selectedCell()->deselect(); 910 selectedCell()->deselect();
853 mShowWeekView = !mShowWeekView; 911 mShowWeekView = !mShowWeekView;
854 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 912 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
855 //emit showNavigator( !mShowWeekView ); 913 //emit showNavigator( !mShowWeekView );
856 computeLayout(); 914 if ( clPending ) {
857 updateConfig(); 915 computeLayout();
916 updateConfig();
917 }
918 if ( mShowWeekView )
919 mWidStack->raiseWidget( mWeekView );
920 else
921 mWidStack->raiseWidget( mMonthView );
922 clPending = false;
858} 923}
859 924
860int KOMonthView::maxDatesHint() 925int KOMonthView::maxDatesHint()
861{ 926{
862 return mNumCells; 927 return mNumCells;
863} 928}
864 929
865int KOMonthView::currentDateCount() 930int KOMonthView::currentDateCount()
866{ 931{
867 return mNumCells; 932 return mNumCells;
868} 933}
869 934
870QPtrList<Incidence> KOMonthView::selectedIncidences() 935QPtrList<Incidence> KOMonthView::selectedIncidences()
871{ 936{
872 QPtrList<Incidence> selected; 937 QPtrList<Incidence> selected;
873 938
874 if ( mSelectedCell ) { 939 if ( mSelectedCell ) {
875 Incidence *incidence = mSelectedCell->selectedIncidence(); 940 Incidence *incidence = mSelectedCell->selectedIncidence();
876 if ( incidence ) selected.append( incidence ); 941 if ( incidence ) selected.append( incidence );
877 } 942 }
878 943
879 return selected; 944 return selected;
880} 945}
881 946
882DateList KOMonthView::selectedDates() 947DateList KOMonthView::selectedDates()
883{ 948{
884 DateList selected; 949 DateList selected;
885 950
886 if ( mSelectedCell ) { 951 if ( mSelectedCell ) {
887 QDate qd = mSelectedCell->selectedIncidenceDate(); 952 QDate qd = mSelectedCell->selectedIncidenceDate();
888 if ( qd.isValid() ) selected.append( qd ); 953 if ( qd.isValid() ) selected.append( qd );
889 } 954 }
890 955
891 return selected; 956 return selected;
892} 957}
893 958
894void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 959void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
895 const QDate &td) 960 const QDate &td)
896{ 961{
897#ifndef KORG_NOPRINTER 962#ifndef KORG_NOPRINTER
898 calPrinter->preview(CalPrinter::Month, fd, td); 963 calPrinter->preview(CalPrinter::Month, fd, td);
899#endif 964#endif
900} 965}
901 966
902void KOMonthView::updateConfig() 967void KOMonthView::updateConfig()
903{ 968{
904 969
905 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 970 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
906 971
907 if ( mShowWeekView ) { 972 if ( mShowWeekView ) {
908 mWeekStartsMonday = true; 973 mWeekStartsMonday = true;
909 } 974 }
910 QFontMetrics fontmetric(mDayLabels[0]->font()); 975 QFontMetrics fontmetric(mDayLabels[0]->font());
911 mWidthLongDayLabel = 0; 976 mWidthLongDayLabel = 0;
912 977
913 for (int i = 0; i < 7; i++) { 978 for (int i = 0; i < 7; i++) {
914 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 979 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
915 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 980 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
916 } 981 }
917 bool temp = mShowSatSunComp ; 982 bool temp = mShowSatSunComp ;
918 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 983 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
919 if ( ! mShowWeekView ) { 984 if ( ! mShowWeekView ) {
920 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 985 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
921 computeLayout(); 986 computeLayout();
922 } 987 }
923 updateDayLabels(); 988 updateDayLabels();
924 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 989 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
925 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 990 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
926 //resizeEvent( 0 ); 991 //resizeEvent( 0 );
927 for (uint i = 0; i < mCells.count(); ++i) { 992 for (uint i = 0; i < mCells.count(); ++i) {
928 mCells[i]->updateConfig(); 993 mCells[i]->updateConfig();
929 } 994 }
930#ifdef DESKTOP_VERSION 995#ifdef DESKTOP_VERSION
931 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 996 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
932#endif 997#endif
933 updateView(); 998 updateView();
934} 999}
935 1000
936void KOMonthView::updateDayLabels() 1001void KOMonthView::updateDayLabels()
937{ 1002{
938 1003
1004 QPtrVector<QLabel> *mDayLabelsT;
1005#if 0
1006 if (mShowWeekView )
1007 mDayLabelsT = &mDayLabelsW;
1008 else
1009 mDayLabelsT = &mDayLabels;
1010#endif
1011
1012 mDayLabelsT = &mDayLabelsW;
1013 for (int i = 0; i < 7; i++) {
1014 if (mWeekStartsMonday) {
1015 bool show = mShortDayLabels;
1016 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1017 show = true;
1018 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1019 } else {
1020 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
1021 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
1022
1023 }
1024 }
1025 mDayLabelsT = &mDayLabels;
939 for (int i = 0; i < 7; i++) { 1026 for (int i = 0; i < 7; i++) {
940 if (mWeekStartsMonday) { 1027 if (mWeekStartsMonday) {
941 bool show = mShortDayLabels; 1028 bool show = mShortDayLabels;
942 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 1029 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
943 show = true; 1030 show = true;
944 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1031 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
945 } else { 1032 } else {
946 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 1033 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
947 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 1034 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
948 1035
949 } 1036 }
950 } 1037 }
1038
951} 1039}
952 1040
953void KOMonthView::showDates(const QDate &start, const QDate &) 1041void KOMonthView::showDates(const QDate &start, const QDate &)
954{ 1042{
955 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1043 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
956 1044
1045 QPtrVector<MonthViewCell> *cells;
1046 QPtrVector<QLabel> *dayLabels;
1047 QPtrVector<KOWeekButton> *weekLabels;
1048 int weekNum = 6;
1049 if ( mShowWeekView ) {
1050 weekNum = 1;
1051 cells = &mCellsW;
1052 dayLabels = &mDayLabelsW;
1053 weekLabels = &mWeekLabelsW;
1054 } else {
1055 cells = &mCells;
1056 dayLabels = &mDayLabels;
1057 weekLabels = &mWeekLabels;
1058 }
957 1059
958 mStartDate = start; 1060 mStartDate = start;
959 1061
960 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1062 int startWeekDay = mWeekStartsMonday ? 1 : 7;
961 1063
962 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1064 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
963 mStartDate = mStartDate.addDays( -1 ); 1065 mStartDate = mStartDate.addDays( -1 );
964 } 1066 }
965 1067
966 bool primary = false; 1068 bool primary = false;
967 uint i; 1069 uint i;
968 for( i = 0; i < mCells.size(); ++i ) { 1070 for( i = 0; i < (*cells).size(); ++i ) {
969 QDate date = mStartDate.addDays( i ); 1071 QDate date = mStartDate.addDays( i );
970 mCells[i]->setDate( date ); 1072 (*cells)[i]->setDate( date );
971 1073
972#ifndef KORG_NOPLUGINS 1074#ifndef KORG_NOPLUGINS
973 // add holiday, if present 1075 // add holiday, if present
974 QString hstring(KOCore::self()->holiday(date)); 1076 QString hstring(KOCore::self()->holiday(date));
975 mCells[i]->setHoliday( hstring ); 1077 (*cells)[i]->setHoliday( hstring );
976#endif 1078#endif
977 1079
978 } 1080 }
979 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1081 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
980 for( i = 0; i < 6; ++i ) { 1082 for( i = 0; i < weekNum; ++i ) {
981 int wno; 1083 int wno;
982 // remember, according to ISO 8601, the first week of the year is the 1084 // remember, according to ISO 8601, the first week of the year is the
983 // first week that contains a thursday. Thus we must subtract off 4, 1085 // first week that contains a thursday. Thus we must subtract off 4,
984 // not just 1. 1086 // not just 1.
985 int dayOfYear = date.dayOfYear(); 1087 int dayOfYear = date.dayOfYear();
986 if (dayOfYear % 7 != 0) 1088 if (dayOfYear % 7 != 0)
987 wno = dayOfYear / 7 + 1; 1089 wno = dayOfYear / 7 + 1;
988 else 1090 else
989 wno =dayOfYear / 7; 1091 wno =dayOfYear / 7;
990 mWeekLabels[i]->setWeekNum( wno ); 1092 (*weekLabels)[i]->setWeekNum( wno );
991 date = date.addDays( 7 ); 1093 date = date.addDays( 7 );
992 } 1094 }
993 updateView(); 1095 updateView();
994} 1096}
995 1097
996void KOMonthView::showEvents(QPtrList<Event>) 1098void KOMonthView::showEvents(QPtrList<Event>)
997{ 1099{
998 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1100 qDebug("KOMonthView::selectEvents is not implemented yet. ");
999} 1101}
1000 1102
1001void KOMonthView::changeEventDisplay(Event *, int) 1103void KOMonthView::changeEventDisplay(Event *, int)
1002{ 1104{
1003 // this should be re-written to be much more efficient, but this 1105 // this should be re-written to be much more efficient, but this
1004 // quick-and-dirty-hack gets the job done for right now. 1106 // quick-and-dirty-hack gets the job done for right now.
1005 updateView(); 1107 updateView();
1006} 1108}
1007 1109
1008void KOMonthView::updateView() 1110void KOMonthView::updateView()
1009{ 1111{
1010 1112
1011 if ( !updatePossible ) 1113 if ( !updatePossible )
1012 return; 1114 return;
1013 //QTime ti; 1115 //QTime ti;
1014 //ti.start(); 1116 //ti.start();
1117 QPtrVector<MonthViewCell> *cells;
1118 if ( mShowWeekView ) {
1119 cells = &mCellsW;
1120 } else {
1121 cells = &mCells;
1122 }
1015#if 1 1123#if 1
1016 int i; 1124 int i;
1017 int timeSpan = mCells.size()-1; 1125 int timeSpan = (*cells).size()-1;
1018 if ( KOPrefs::instance()->mMonthViewWeek ) 1126 if ( KOPrefs::instance()->mMonthViewWeek )
1019 timeSpan = 6; 1127 timeSpan = 6;
1020 for( i = 0; i < timeSpan + 1; ++i ) { 1128 for( i = 0; i < timeSpan + 1; ++i ) {
1021 mCells[i]->startUpdateCell(); 1129 (*cells)[i]->startUpdateCell();
1022 } 1130 }
1023 1131
1024 QPtrList<Event> events = calendar()->events(); 1132 QPtrList<Event> events = calendar()->events();
1025 Event *event; 1133 Event *event;
1026 QDateTime dt; 1134 QDateTime dt;
1027 bool ok; 1135 bool ok;
1028 QDate endDate = mStartDate.addDays( timeSpan ); 1136 QDate endDate = mStartDate.addDays( timeSpan );
1029 for( event = events.first(); event; event = events.next() ) { // for event 1137 for( event = events.first(); event; event = events.next() ) { // for event
1030 if ( event->doesRecur() ) { 1138 if ( event->doesRecur() ) {
1031 bool last; 1139 bool last;
1032 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1140 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1033 QDateTime incidenceEnd; 1141 QDateTime incidenceEnd;
1034 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1142 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1035 bool invalid = false; 1143 bool invalid = false;
1036 while( true ) { 1144 while( true ) {
1037 if ( incidenceStart.isValid() ) { 1145 if ( incidenceStart.isValid() ) {
1038 incidenceEnd = incidenceStart.addDays( eventlen ); 1146 incidenceEnd = incidenceStart.addDays( eventlen );
1039 int st = incidenceStart.date().daysTo( endDate ); 1147 int st = incidenceStart.date().daysTo( endDate );
1040 if ( st >= 0 ) { // start before timeend 1148 if ( st >= 0 ) { // start before timeend
1041 int end = mStartDate.daysTo( incidenceEnd.date() ); 1149 int end = mStartDate.daysTo( incidenceEnd.date() );
1042 if ( end >= 0 ) { // end after timestart --- got one! 1150 if ( end >= 0 ) { // end after timestart --- got one!
1043 //normalize 1151 //normalize
1044 st = timeSpan - st; 1152 st = timeSpan - st;
1045 if ( st < 0 ) st = 0; 1153 if ( st < 0 ) st = 0;
1046 if ( end > timeSpan ) end = timeSpan; 1154 if ( end > timeSpan ) end = timeSpan;
1047 int iii; 1155 int iii;
1048 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1156 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1049 for ( iii = st;iii<= end;++iii) 1157 for ( iii = st;iii<= end;++iii)
1050 mCells[iii]->insertEvent( event ); 1158 (*cells)[iii]->insertEvent( event );
1051 } 1159 }
1052 } 1160 }
1053 } else { 1161 } else {
1054 if ( invalid ) 1162 if ( invalid )
1055 break; 1163 break;
1056 invalid = true; 1164 invalid = true;
1057 //qDebug("invalid %s", event->summary().latin1()); 1165 //qDebug("invalid %s", event->summary().latin1());
1058 incidenceStart = QDateTime( mStartDate ); 1166 incidenceStart = QDateTime( mStartDate );
1059 } 1167 }
1060 if ( last ) 1168 if ( last )
1061 break; 1169 break;
1062 bool ok; 1170 bool ok;
1063 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1171 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1064 if ( ! ok ) 1172 if ( ! ok )
1065 break; 1173 break;
1066 if ( incidenceStart.date() > endDate ) 1174 if ( incidenceStart.date() > endDate )
1067 break; 1175 break;
1068 } 1176 }
1069 } else { // no recur 1177 } else { // no recur
1070 int st = event->dtStart().date().daysTo( endDate ); 1178 int st = event->dtStart().date().daysTo( endDate );
1071 if ( st >= 0 ) { // start before timeend 1179 if ( st >= 0 ) { // start before timeend
1072 int end = mStartDate.daysTo( event->dtEnd().date() ); 1180 int end = mStartDate.daysTo( event->dtEnd().date() );
1073 if ( end >= 0 ) { // end after timestart --- got one! 1181 if ( end >= 0 ) { // end after timestart --- got one!
1074 //normalize 1182 //normalize
1075 st = timeSpan - st; 1183 st = timeSpan - st;
1076 if ( st < 0 ) st = 0; 1184 if ( st < 0 ) st = 0;
1077 if ( end > timeSpan ) end = timeSpan; 1185 if ( end > timeSpan ) end = timeSpan;
1078 int iii; 1186 int iii;
1079 for ( iii = st;iii<= end;++iii) 1187 for ( iii = st;iii<= end;++iii)
1080 mCells[iii]->insertEvent( event ); 1188 (*cells)[iii]->insertEvent( event );
1081 } 1189 }
1082 } 1190 }
1083 } 1191 }
1084 } 1192 }
1085 // insert due todos 1193 // insert due todos
1086 QPtrList<Todo> todos = calendar()->todos( ); 1194 QPtrList<Todo> todos = calendar()->todos( );
1087 Todo *todo; 1195 Todo *todo;
1088 for(todo = todos.first(); todo; todo = todos.next()) { 1196 for(todo = todos.first(); todo; todo = todos.next()) {
1089 //insertTodo( todo ); 1197 //insertTodo( todo );
1090 if ( todo->hasDueDate() ) { 1198 if ( todo->hasDueDate() ) {
1091 int day = mStartDate.daysTo( todo->dtDue().date() ); 1199 int day = mStartDate.daysTo( todo->dtDue().date() );
1092 if ( day >= 0 && day < timeSpan + 1) { 1200 if ( day >= 0 && day < timeSpan + 1) {
1093 mCells[day]->insertTodo( todo ); 1201 (*cells)[day]->insertTodo( todo );
1094 } 1202 }
1095 } 1203 }
1096 } 1204 }
1097 1205
1098 for( i = 0; i < timeSpan+1; ++i ) { 1206 for( i = 0; i < timeSpan+1; ++i ) {
1099 mCells[i]->finishUpdateCell(); 1207 (*cells)[i]->finishUpdateCell();
1100 } 1208 }
1101 processSelectionChange(); 1209 processSelectionChange();
1102 mCells[0]->setFocus(); 1210 (*cells)[0]->setFocus();
1103 1211
1104 1212
1105#else 1213#else
1106 // old code 1214 // old code
1107 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1215 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1108 int i; 1216 int i;
1109 for( i = 0; i < mCells.count(); ++i ) { 1217 for( i = 0; i < (*cells).count(); ++i ) {
1110 mCells[i]->updateCell(); 1218 (*cells)[i]->updateCell();
1111 } 1219 }
1112 1220
1113 //qDebug("KOMonthView::updateView() "); 1221 //qDebug("KOMonthView::updateView() ");
1114 processSelectionChange(); 1222 processSelectionChange();
1115 // qDebug("---------------------------------------------------------------------+ "); 1223 // qDebug("---------------------------------------------------------------------+ ");
1116 mCells[0]->setFocus(); 1224 (*cells)[0]->setFocus();
1117#endif 1225#endif
1118 1226
1119 //qDebug("update time %d ", ti.elapsed()); 1227 //qDebug("update time %d ", ti.elapsed());
1120} 1228}
1121 1229
1122void KOMonthView::resizeEvent(QResizeEvent * e) 1230void KOMonthView::resizeEvent(QResizeEvent * e)
1123{ 1231{
1124 computeLayout(); 1232 computeLayout();
1125 mCells[0]->setFocus(); 1233 clPending = true;
1234 if ( mShowWeekView )
1235 mCellsW[0]->setFocus();
1236 else
1237 mCells[0]->setFocus();
1126} 1238}
1127void KOMonthView::computeLayoutWeek() 1239void KOMonthView::computeLayoutWeek()
1128{ 1240{
1129 1241
1130 int daysToShow; 1242 int daysToShow;
1131 bool combinedSatSun = false; 1243 bool combinedSatSun = false;
1132 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1244 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1133 daysToShow = 6; 1245 daysToShow = 6;
1134 combinedSatSun = true; 1246 combinedSatSun = true;
1135 } 1247 }
1136 int tWid = topLevelWidget()->size().width(); 1248 int tWid = topLevelWidget()->size().width();
1137 int tHei = topLevelWidget()->size().height(); 1249 int tHei = topLevelWidget()->size().height();
1138 1250
1139 int wid = size().width();//e 1251 int wid = size().width();//e
1140 int hei = size().height()-1; 1252 int hei = size().height()-1;
1141 1253
1142 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1254 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1143 return; 1255 return;
1144 1256
1145 if ( wid < hei ) 1257 if ( wid < hei )
1146 daysToShow = 2; 1258 daysToShow = 2;
1147 else 1259 else
1148 daysToShow = 3; 1260 daysToShow = 3;
1149 mShowSatSunComp = true; 1261 mShowSatSunComp = true;
1150 combinedSatSun = true; 1262 combinedSatSun = true;
1151 1263
1152 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1264 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1153 QFontMetrics fm ( mWeekLabels[0]->font() ); 1265 QFontMetrics fm ( mWeekLabels[0]->font() );
1154 int weeklabelwid = fm.width( "888" ); 1266 int weeklabelwid = fm.width( "888" );
1155 wid -= weeklabelwid; 1267 wid -= weeklabelwid;
1156 1268
1157 int colWid = wid / daysToShow; 1269 int colWid = wid / daysToShow;
1158 int lastCol = wid - ( colWid*6 ); 1270 int lastCol = wid - ( colWid*6 );
1159 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1271 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1160 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1272 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1161 int colModulo = wid % daysToShow; 1273 int colModulo = wid % daysToShow;
1162 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1274 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1163 //qDebug("rowmod %d ", rowModulo); 1275 //qDebug("rowmod %d ", rowModulo);
1164 int i; 1276 int i;
1165 int x,y,w,h; 1277 int x,y,w,h;
1166 x= 0; 1278 x= 0;
1167 y= 0; 1279 y= 0;
1168 w = colWid; 1280 w = colWid;
1169 h = dayLabelHei ; 1281 h = dayLabelHei ;
1170 for ( i = 0; i < 7; i++) { 1282 for ( i = 0; i < 7; i++) {
1171 if ( i && !( i % daysToShow) && i < 6) { 1283 if ( i && !( i % daysToShow) && i < 6) {
1172 y += hei/(5-daysToShow); 1284 y += hei/(5-daysToShow);
1173 x = 0; 1285 x = 0;
1174 w = colWid; 1286 w = colWid;
1175 } 1287 }
1176 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1288 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1177 ++w; 1289 ++w;
1178 } 1290 }
1179 if ( i >= 5 ) { 1291 if ( i >= 5 ) {
1180 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); 1292 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
1181 x -= (w/2 ); 1293 x -= (w/2 );
1182 } 1294 }
1183 else 1295 else
1184 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1296 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h);
1185 x += w; 1297 x += w;
1186 } 1298 }
1187 x= 0; 1299 x= 0;
1188 y= dayLabelHei; 1300 y= dayLabelHei;
1189 w = colWid; 1301 w = colWid;
1190 h = cellHei; 1302 h = cellHei;
1191 for ( i = 0; i < mCells.count(); ++i) { 1303 for ( i = 0; i < mCellsW.count(); ++i) {
1192 if ( i > 6 ) { 1304 if ( i > 6 ) {
1193 mCells[i]->hide(); 1305 mCellsW[i]->hide();
1194 continue; 1306 continue;
1195 } 1307 }
1196 1308
1197 w = colWid; 1309 w = colWid;
1198 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1310 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1199 ++w; 1311 ++w;
1200 } 1312 }
1201 if ( i == (daysToShow-1-rowModulo)*7) 1313 if ( i == (daysToShow-1-rowModulo)*7)
1202 ++h; 1314 ++h;
1203 1315
1204 if ( i >= 5 ) { 1316 if ( i >= 5 ) {
1205 if ( i ==5 ) { 1317 if ( i ==5 ) {
1206 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1318 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1207 x -= w ;y += h/2; 1319 x -= w ;y += h/2;
1208 } else { 1320 } else {
1209 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1321 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1210 ++w; 1322 ++w;
1211 } 1323 }
1212 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1324 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1213 y -= h/2; 1325 y -= h/2;
1214 } 1326 }
1215 } else 1327 } else
1216 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1328 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1217 1329
1218 1330
1219 x += w; 1331 x += w;
1220 if ( x + w/2 > wid ) { 1332 if ( x + w/2 > wid ) {
1221 x = 0; 1333 x = 0;
1222 y += h+dayLabelHei ; 1334 y += h+dayLabelHei ;
1223 } 1335 }
1224 } 1336 }
1225 y= dayLabelHei; 1337 y= dayLabelHei;
1226 h = cellHei ; 1338 h = cellHei ;
1227 mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1339 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1228 for ( i = 1; i < 6; i++) { 1340 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1229 mWeekLabels[i]->hide();
1230 }
1231 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1232 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1341 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1233 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1342 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1234 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1343 mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ;
1235 updateDayLabels(); 1344 updateDayLabels();
1236 bool forceUpdate = !updatePossible; 1345 bool forceUpdate = !updatePossible;
1237 updatePossible = true; 1346 updatePossible = true;
1238 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1347 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1239 if ( forceUpdate ) 1348 if ( forceUpdate )
1240 updateView(); 1349 updateView();
1241} 1350}
1242void KOMonthView::computeLayout() 1351void KOMonthView::computeLayout()
1243{ 1352{
1244 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 1353 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
1245 // note this only changes the text if the requested size crosses the 1354 // note this only changes the text if the requested size crosses the
1246 // threshold between big enough to support the full name and not big 1355 // threshold between big enough to support the full name and not big
1247 // enough. 1356 // enough.
1248 if ( mShowWeekView ){ 1357 if ( mShowWeekView ){
1249 computeLayoutWeek(); 1358 computeLayoutWeek();
1250 return; 1359 return;
1251 } 1360 }
1252 int daysToShow = 7; 1361 int daysToShow = 7;
1253 bool combinedSatSun = false; 1362 bool combinedSatSun = false;
1254 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1363 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1255 daysToShow = 6; 1364 daysToShow = 6;
1256 combinedSatSun = true; 1365 combinedSatSun = true;
1257 } 1366 }
1258 int tWid = topLevelWidget()->size().width(); 1367 int tWid = topLevelWidget()->size().width();
1259 int tHei = topLevelWidget()->size().height(); 1368 int tHei = topLevelWidget()->size().height();
1260 1369
1261 int wid = size().width();//e 1370 int wid = size().width();//e
1262 int hei = size().height()-1; 1371 int hei = size().height()-1;
1263 1372
1264 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1373 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1265 return; 1374 return;
1266 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1375 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1267 QFontMetrics fm ( mWeekLabels[0]->font() ); 1376 QFontMetrics fm ( mWeekLabels[0]->font() );
1268 int weeklabelwid = fm.width( "888" ); 1377 int weeklabelwid = fm.width( "888" );
1269 wid -= weeklabelwid; 1378 wid -= weeklabelwid;
1270 1379
1271 int colWid = wid / daysToShow; 1380 int colWid = wid / daysToShow;
1272 int lastCol = wid - ( colWid*6 ); 1381 int lastCol = wid - ( colWid*6 );
1273 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1382 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1274 int cellHei = (hei - dayLabelHei) /6; 1383 int cellHei = (hei - dayLabelHei) /6;
1275 int colModulo = wid % daysToShow; 1384 int colModulo = wid % daysToShow;
1276 int rowModulo = (hei- dayLabelHei) % 6; 1385 int rowModulo = (hei- dayLabelHei) % 6;
1277 //qDebug("rowmod %d ", rowModulo); 1386 //qDebug("rowmod %d ", rowModulo);
1278 int i; 1387 int i;
1279 int x,y,w,h; 1388 int x,y,w,h;
1280 x= 0; 1389 x= 0;
1281 y= 0; 1390 y= 0;
1282 w = colWid; 1391 w = colWid;
1283 h = dayLabelHei ; 1392 h = dayLabelHei ;
1284 for ( i = 0; i < 7; i++) { 1393 for ( i = 0; i < 7; i++) {
1285 if ( i == daysToShow-colModulo ) 1394 if ( i == daysToShow-colModulo )
1286 ++w; 1395 ++w;
1287 if ( combinedSatSun ) { 1396 if ( combinedSatSun ) {
1288 if ( i >= daysToShow-1 ) { 1397 if ( i >= daysToShow-1 ) {
1289 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1398 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1290 x -= w/2 ; 1399 x -= w/2 ;
1291 } 1400 }
1292 else 1401 else
1293 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1402 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1294 } else 1403 } else
1295 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1404 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1296 x += w; 1405 x += w;
1297 } 1406 }
1298 x= 0; 1407 x= 0;
1299 y= dayLabelHei; 1408 y= dayLabelHei;
1300 w = colWid; 1409 w = colWid;
1301 h = cellHei ; 1410 h = cellHei ;
1302 for ( i = 0; i < mCells.count(); ++i) { 1411 for ( i = 0; i < mCells.count(); ++i) {
1303 mCells[i]->show();
1304 w = colWid; 1412 w = colWid;
1305 if ( ((i) % 7) >= 7-colModulo ) { 1413 if ( ((i) % 7) >= 7-colModulo ) {
1306 ++w; 1414 ++w;
1307 } 1415 }
1308 if ( i == (6-rowModulo)*7) 1416 if ( i == (6-rowModulo)*7)
1309 ++h; 1417 ++h;
1310 if ( combinedSatSun ) { 1418 if ( combinedSatSun ) {
1311 if ( (i)%7 >= daysToShow-1 ) { 1419 if ( (i)%7 >= daysToShow-1 ) {
1312 if ( (i)%7 == daysToShow-1 ) { 1420 if ( (i)%7 == daysToShow-1 ) {
1313 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1421 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1314 x -= w ;y += h/2; 1422 x -= w ;y += h/2;
1315 } else { 1423 } else {
1316 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1424 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1317 y -= h/2; 1425 y -= h/2;
1318 } 1426 }
1319 } else 1427 } else
1320 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1428 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1321 1429
1322 } 1430 }
1323 else 1431 else
1324 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1432 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1325 x += w; 1433 x += w;
1326 if ( x + w/2 > wid ) { 1434 if ( x + w/2 > wid ) {
1327 x = 0; 1435 x = 0;
1328 y += h; 1436 y += h;
1329 } 1437 }
1330 } 1438 }
1331 y= dayLabelHei; 1439 y= dayLabelHei;
1332 h = cellHei ; 1440 h = cellHei ;
1333 for ( i = 0; i < 6; i++) { 1441 for ( i = 0; i < 6; i++) {
1334 mWeekLabels[i]->show();
1335 if ( i == (6-rowModulo)) 1442 if ( i == (6-rowModulo))
1336 ++h; 1443 ++h;
1337 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1444 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1338 y += h; 1445 y += h;
1339 } 1446 }
1340 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1447 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1341 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1448 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1342 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1449 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1343 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1450 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1344 updateDayLabels(); 1451 updateDayLabels();
1345 bool forceUpdate = !updatePossible; 1452 bool forceUpdate = !updatePossible;
1346 updatePossible = true; 1453 updatePossible = true;
1347 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1454 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1348 if ( forceUpdate ) 1455 if ( forceUpdate )
1349 updateView(); 1456 updateView();
1350} 1457}
1351 1458
1352void KOMonthView::showContextMenu( Incidence *incidence ) 1459void KOMonthView::showContextMenu( Incidence *incidence )
1353{ 1460{
1354 mContextMenu->showIncidencePopup(incidence); 1461 mContextMenu->showIncidencePopup(incidence);
1355 /* 1462 /*
1356 if( incidence && incidence->type() == "Event" ) { 1463 if( incidence && incidence->type() == "Event" ) {
1357 Event *event = static_cast<Event *>(incidence); 1464 Event *event = static_cast<Event *>(incidence);
1358 mContextMenu->showEventPopup(event); 1465 mContextMenu->showEventPopup(event);
1359 } else { 1466 } else {
1360 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1467 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1361 } 1468 }
1362 */ 1469 */
1363} 1470}
1364MonthViewCell * KOMonthView::selectedCell( ) 1471MonthViewCell * KOMonthView::selectedCell( )
1365{ 1472{
1366 return mSelectedCell; 1473 return mSelectedCell;
1367} 1474}
1368void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1475void KOMonthView::setSelectedCell( MonthViewCell *cell )
1369{ 1476{
1370 // qDebug("KOMonthView::setSelectedCell "); 1477 // qDebug("KOMonthView::setSelectedCell ");
1371 if ( mSelectedCell && mSelectedCell != cell ) { 1478 if ( mSelectedCell && mSelectedCell != cell ) {
1372 MonthViewCell * mvc = mSelectedCell; 1479 MonthViewCell * mvc = mSelectedCell;
1373 mSelectedCell = cell; 1480 mSelectedCell = cell;
1374 mvc->deselect(); 1481 mvc->deselect();
1375 } else 1482 } else
1376 mSelectedCell = cell; 1483 mSelectedCell = cell;
1377 // if ( mSelectedCell ) 1484 // if ( mSelectedCell )
1378 // mSelectedCell->select(); 1485 // mSelectedCell->select();
1379 if ( !mSelectedCell ) 1486 if ( !mSelectedCell )
1380 emit incidenceSelected( 0 ); 1487 emit incidenceSelected( 0 );
1381 else 1488 else
1382 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1489 emit incidenceSelected( mSelectedCell->selectedIncidence() );
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 1ed200b..b89b2bc 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,75 +1,76 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef _KOMONTHVIEW_H 20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H 21#define _KOMONTHVIEW_H
22 22
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qwidgetstack.h>
28#include <qlayout.h> 29#include <qlayout.h>
29#include <qintdict.h> 30#include <qintdict.h>
30#include <qpushbutton.h> 31#include <qpushbutton.h>
31#include <qvaluelist.h> 32#include <qvaluelist.h>
32#include <qptrvector.h> 33#include <qptrvector.h>
33 34
34#include <libkcal/calendar.h> 35#include <libkcal/calendar.h>
35#include <libkcal/event.h> 36#include <libkcal/event.h>
36 37
37#include "koeventview.h" 38#include "koeventview.h"
38 39
39#ifdef DESKTOP_VERSION 40#ifdef DESKTOP_VERSION
40class QToolTipGroup; 41class QToolTipGroup;
41#endif 42#endif
42 43
43class KNOWhatsThis; 44class KNOWhatsThis;
44class KOWeekButton : public QPushButton 45class KOWeekButton : public QPushButton
45{ 46{
46 Q_OBJECT 47 Q_OBJECT
47 public: 48 public:
48 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 49 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
49 QPushButton( parent, name) 50 QPushButton( parent, name)
50 { 51 {
51 connect( this, SIGNAL( clicked() ), 52 connect( this, SIGNAL( clicked() ),
52 SLOT( bottonClicked() )); 53 SLOT( bottonClicked() ));
53 mNumber = -1; 54 mNumber = -1;
54 } 55 }
55 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 56 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
56 signals: 57 signals:
57 void selectWeekNum ( int ); 58 void selectWeekNum ( int );
58private: 59private:
59 int mNumber; 60 int mNumber;
60private slots : 61private slots :
61 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 62 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
62}; 63};
63 64
64class KNoScrollListBox: public QListBox 65class KNoScrollListBox: public QListBox
65{ 66{
66 Q_OBJECT 67 Q_OBJECT
67 public: 68 public:
68 KNoScrollListBox(QWidget *parent=0, const char *name=0); 69 KNoScrollListBox(QWidget *parent=0, const char *name=0);
69 ~KNoScrollListBox(); 70 ~KNoScrollListBox();
70 QString getWhatsThisText(QPoint p) ; 71 QString getWhatsThisText(QPoint p) ;
71 72
72 signals: 73 signals:
73 void shiftDown(); 74 void shiftDown();
74 void shiftUp(); 75 void shiftUp();
75 void rightClick(); 76 void rightClick();
@@ -80,97 +81,97 @@ class KNoScrollListBox: public QListBox
80 void mousePressEvent(QMouseEvent *); 81 void mousePressEvent(QMouseEvent *);
81 82
82 private: 83 private:
83 KNOWhatsThis * mWT; 84 KNOWhatsThis * mWT;
84}; 85};
85 86
86 87
87class MonthViewItem: public QListBoxItem 88class MonthViewItem: public QListBoxItem
88{ 89{
89 public: 90 public:
90 MonthViewItem( Incidence *, QDate qd, const QString & title ); 91 MonthViewItem( Incidence *, QDate qd, const QString & title );
91 92
92 void setRecur(bool on) { mRecur = on; } 93 void setRecur(bool on) { mRecur = on; }
93 void setAlarm(bool on) { mAlarm = on; } 94 void setAlarm(bool on) { mAlarm = on; }
94 void setReply(bool on) { mReply = on; } 95 void setReply(bool on) { mReply = on; }
95 void setMoreInfo(bool on) { mInfo = on; } 96 void setMoreInfo(bool on) { mInfo = on; }
96 97
97 98
98 void setPalette(const QPalette &p) { mPalette = p; } 99 void setPalette(const QPalette &p) { mPalette = p; }
99 QPalette palette() const { return mPalette; } 100 QPalette palette() const { return mPalette; }
100 101
101 Incidence *incidence() const { return mIncidence; } 102 Incidence *incidence() const { return mIncidence; }
102 QDate incidenceDate() { return mDate; } 103 QDate incidenceDate() { return mDate; }
103 104
104 protected: 105 protected:
105 virtual void paint(QPainter *); 106 virtual void paint(QPainter *);
106 virtual int height(const QListBox *) const; 107 virtual int height(const QListBox *) const;
107 virtual int width(const QListBox *) const; 108 virtual int width(const QListBox *) const;
108 109
109 private: 110 private:
110 bool mRecur; 111 bool mRecur;
111 bool mAlarm; 112 bool mAlarm;
112 bool mReply; 113 bool mReply;
113 bool mInfo; 114 bool mInfo;
114 115
115 QPalette mPalette; 116 QPalette mPalette;
116 QDate mDate; 117 QDate mDate;
117 118
118 Incidence *mIncidence; 119 Incidence *mIncidence;
119}; 120};
120 121
121 122
122class KOMonthView; 123class KOMonthView;
123 124
124class MonthViewCell : public QWidget 125class MonthViewCell : public QWidget
125{ 126{
126 Q_OBJECT 127 Q_OBJECT
127 public: 128 public:
128 MonthViewCell( KOMonthView * ); 129 MonthViewCell(KOMonthView *,QWidget* );
129 130
130 void setDate( const QDate & ); 131 void setDate( const QDate & );
131 QDate date() const; 132 QDate date() const;
132 133
133 void setPrimary( bool ); 134 void setPrimary( bool );
134 bool isPrimary() const; 135 bool isPrimary() const;
135 136
136 void setHoliday( bool ); 137 void setHoliday( bool );
137 void setHoliday( const QString & ); 138 void setHoliday( const QString & );
138 139
139 void updateCell(); 140 void updateCell();
140 void startUpdateCell(); 141 void startUpdateCell();
141 void finishUpdateCell(); 142 void finishUpdateCell();
142 void insertEvent(Event *); 143 void insertEvent(Event *);
143 void insertTodo(Todo *); 144 void insertTodo(Todo *);
144 145
145 void updateConfig(); 146 void updateConfig();
146 147
147 void enableScrollBars( bool ); 148 void enableScrollBars( bool );
148 149
149 Incidence *selectedIncidence(); 150 Incidence *selectedIncidence();
150 QDate selectedIncidenceDate(); 151 QDate selectedIncidenceDate();
151 152
152 void deselect(); 153 void deselect();
153 void select(); 154 void select();
154 void clear(); 155 void clear();
155 156
156#ifdef DESKTOP_VERSION 157#ifdef DESKTOP_VERSION
157 static QToolTipGroup *toolTipGroup(); 158 static QToolTipGroup *toolTipGroup();
158#endif 159#endif
159 signals: 160 signals:
160 void defaultAction( Incidence * ); 161 void defaultAction( Incidence * );
161 void newEventSignal( QDateTime ); 162 void newEventSignal( QDateTime );
162 void showDaySignal( QDate ); 163 void showDaySignal( QDate );
163 164
164 protected: 165 protected:
165 QString mToolTip; 166 QString mToolTip;
166 void resizeEvent( QResizeEvent * ); 167 void resizeEvent( QResizeEvent * );
167 168
168 protected slots: 169 protected slots:
169 void defaultAction( QListBoxItem * ); 170 void defaultAction( QListBoxItem * );
170 void contextMenu( QListBoxItem * ); 171 void contextMenu( QListBoxItem * );
171 void selection( QListBoxItem * ); 172 void selection( QListBoxItem * );
172 void cellClicked( QListBoxItem * ); 173 void cellClicked( QListBoxItem * );
173 void newEvent(); 174 void newEvent();
174 void showDay(); 175 void showDay();
175 176
176 private: 177 private:
@@ -211,75 +212,82 @@ class KOMonthView: public KOEventView
211 virtual int maxDatesHint(); 212 virtual int maxDatesHint();
212 213
213 /** Returns number of currently shown dates. */ 214 /** Returns number of currently shown dates. */
214 virtual int currentDateCount(); 215 virtual int currentDateCount();
215 216
216 /** returns the currently selected events */ 217 /** returns the currently selected events */
217 virtual QPtrList<Incidence> selectedIncidences(); 218 virtual QPtrList<Incidence> selectedIncidences();
218 219
219 /** returns dates of the currently selected events */ 220 /** returns dates of the currently selected events */
220 virtual DateList selectedDates(); 221 virtual DateList selectedDates();
221 222
222 virtual void printPreview(CalPrinter *calPrinter, 223 virtual void printPreview(CalPrinter *calPrinter,
223 const QDate &, const QDate &); 224 const QDate &, const QDate &);
224 bool isMonthView() { return true; } 225 bool isMonthView() { return true; }
225 bool isUpdatePossible() { return updatePossible; } 226 bool isUpdatePossible() { return updatePossible; }
226 227
227 MonthViewCell * selectedCell(); 228 MonthViewCell * selectedCell();
228 public slots: 229 public slots:
229 virtual void updateView(); 230 virtual void updateView();
230 virtual void updateConfig(); 231 virtual void updateConfig();
231 virtual void showDates(const QDate &start, const QDate &end); 232 virtual void showDates(const QDate &start, const QDate &end);
232 virtual void showEvents(QPtrList<Event> eventList); 233 virtual void showEvents(QPtrList<Event> eventList);
233 234
234 void changeEventDisplay(Event *, int); 235 void changeEventDisplay(Event *, int);
235 236
236 void clearSelection(); 237 void clearSelection();
237 238
238 void showContextMenu( Incidence * ); 239 void showContextMenu( Incidence * );
239 240
240 void setSelectedCell( MonthViewCell * ); 241 void setSelectedCell( MonthViewCell * );
241 242
242 protected slots: 243 protected slots:
243 void selectDateWeekNum ( int ); 244 void selectDateWeekNum ( int );
244 void selectInternalWeekNum ( int ); 245 void selectInternalWeekNum ( int );
245 void switchView(); 246 void switchView();
246 void processSelectionChange(); 247 void processSelectionChange();
247 signals: 248 signals:
248 void nextMonth(); 249 void nextMonth();
249 void prevMonth(); 250 void prevMonth();
250 void showNavigator( bool ); 251 void showNavigator( bool );
251 void selectWeekNum ( int ); 252 void selectWeekNum ( int );
252 void showDaySignal( QDate ); 253 void showDaySignal( QDate );
253 protected: 254 protected:
254 void resizeEvent(QResizeEvent *); 255 void resizeEvent(QResizeEvent *);
255 void viewChanged(); 256 void viewChanged();
256 void updateDayLabels(); 257 void updateDayLabels();
257 258
258 private: 259 private:
260 bool clPending;
261 QWidgetStack * mWidStack;
262 QWidget* mMonthView;
263 QWidget* mWeekView;
259 bool mShowWeekView; 264 bool mShowWeekView;
260 bool updatePossible; 265 bool updatePossible;
261 int mDaysPerWeek; 266 int mDaysPerWeek;
262 int mNumWeeks; 267 int mNumWeeks;
263 int mNumCells; 268 int mNumCells;
264 bool mWeekStartsMonday; 269 bool mWeekStartsMonday;
265 bool mShowSatSunComp; 270 bool mShowSatSunComp;
266 void computeLayout(); 271 void computeLayout();
267 void computeLayoutWeek(); 272 void computeLayoutWeek();
268 273
269 QPtrVector<MonthViewCell> mCells; 274 QPtrVector<MonthViewCell> mCells;
270 QPtrVector<QLabel> mDayLabels; 275 QPtrVector<QLabel> mDayLabels;
271 QPtrVector<KOWeekButton> mWeekLabels; 276 QPtrVector<KOWeekButton> mWeekLabels;
277 QPtrVector<MonthViewCell> mCellsW;
278 QPtrVector<QLabel> mDayLabelsW;
279 QPtrVector<KOWeekButton> mWeekLabelsW;
272 280
273 bool mShortDayLabels; 281 bool mShortDayLabels;
274 int mWidthLongDayLabel; 282 int mWidthLongDayLabel;
275 283
276 QDate mStartDate; 284 QDate mStartDate;
277 285
278 MonthViewCell *mSelectedCell; 286 MonthViewCell *mSelectedCell;
279 287
280 KOEventPopupMenu *mContextMenu; 288 KOEventPopupMenu *mContextMenu;
281 void keyPressEvent ( QKeyEvent * ) ; 289 void keyPressEvent ( QKeyEvent * ) ;
282 290
283}; 291};
284 292
285#endif 293#endif