summaryrefslogtreecommitdiffabout
path: root/korganizer/kdatenavigator.cpp
Unidiff
Diffstat (limited to 'korganizer/kdatenavigator.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kdatenavigator.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 6697602..ecc7a2f 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -1,152 +1,156 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001,2002 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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qkeycode.h> 25#include <qnamespace.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qframe.h> 28#include <q3frame.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qapplication.h> 30#include <qapplication.h>
31//Added by qt3to4:
32#include <QWheelEvent>
33#include <Q3GridLayout>
34#include <QEvent>
31 35
32#include <kdebug.h> 36#include <kdebug.h>
33#include <klocale.h> 37#include <klocale.h>
34#include <kglobal.h> 38#include <kglobal.h>
35 39
36#include "koglobals.h" 40#include "koglobals.h"
37#include "koprefs.h" 41#include "koprefs.h"
38#ifndef KORG_NOPLUGINS 42#ifndef KORG_NOPLUGINS
39#include "kocore.h" 43#include "kocore.h"
40#endif 44#endif
41 45
42#include <kcalendarsystem.h> 46#include <kcalendarsystem.h>
43 47
44#include "navigatorbar.h" 48#include "navigatorbar.h"
45 49
46#include "kdatenavigator.h" 50#include "kdatenavigator.h"
47 51
48KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) 52KDateNavigator::KDateNavigator( QWidget *parent, const char *name )
49 : QFrame(parent, name), 53 : Q3Frame(parent, name),
50 updateTimer(0L) 54 updateTimer(0L)
51{ 55{
52 setFrameStyle(QFrame::NoFrame); 56 setFrameStyle(Q3Frame::NoFrame);
53 QDate startDate = QDate::currentDate(); 57 QDate startDate = QDate::currentDate();
54 QGridLayout *topLayout = new QGridLayout(this,8,8); 58 Q3GridLayout *topLayout = new Q3GridLayout(this,8,8);
55 59
56 if (! startDate.isValid()) { 60 if (! startDate.isValid()) {
57 qDebug("KDateNavigator::invalid startdate "); 61 qDebug("KDateNavigator::invalid startdate ");
58 startDate = QDate::currentDate(); 62 startDate = QDate::currentDate();
59 } 63 }
60 mMonthSignalOffset = 0; 64 mMonthSignalOffset = 0;
61 mSelectedDates.append(startDate); 65 mSelectedDates.append(startDate);
62 m_MthYr = startDate; 66 m_MthYr = startDate;
63 m_bShowWeekNums = true; 67 m_bShowWeekNums = true;
64 setFont( KOPrefs::instance()->mDateNavigatorFont ); 68 setFont( KOPrefs::instance()->mDateNavigatorFont );
65 mNavigatorBar = new NavigatorBar( startDate, this ); 69 mNavigatorBar = new NavigatorBar( startDate, this );
66 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); 70 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 );
67 //mNavigatorBar->resize( 1,1); 71 //mNavigatorBar->resize( 1,1);
68 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 72 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
69 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 73 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
70 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 74 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
71 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 75 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
72 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 76 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
73 77
74 // get the day of the week on the first day 78 // get the day of the week on the first day
75 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 79 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
76 m_fstDayOfWk = dayone.dayOfWeek(); 80 m_fstDayOfWk = dayone.dayOfWeek();
77 81
78 int i; 82 int i;
79 83
80 // Set up the heading fields. 84 // Set up the heading fields.
81 for( i = 0; i < 7; i++ ) { 85 for( i = 0; i < 7; i++ ) {
82 headings[i] = new QLabel("",this); 86 headings[i] = new QLabel("",this);
83 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); 87 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
84 headings[i]->setAlignment(AlignCenter); 88 headings[i]->setAlignment(Qt::AlignCenter);
85 headings[i]->installEventFilter(this); 89 headings[i]->installEventFilter(this);
86 90
87 topLayout->addWidget(headings[i],1,i+1); 91 topLayout->addWidget(headings[i],1,i+1);
88 } 92 }
89 93
90 // Create the weeknumber labels 94 // Create the weeknumber labels
91 for( i = 0; i < 6; i++ ) { 95 for( i = 0; i < 6; i++ ) {
92 weeknos[i] = new QLabel(this); 96 weeknos[i] = new QLabel(this);
93 weeknos[i]->setAlignment(AlignCenter ); 97 weeknos[i]->setAlignment(Qt::AlignCenter );
94 //weeknos[i]->setFont(QFont("Arial", 10)); 98 //weeknos[i]->setFont(QFont("Arial", 10));
95 if(!m_bShowWeekNums) { 99 if(!m_bShowWeekNums) {
96 weeknos[i]->hide(); 100 weeknos[i]->hide();
97 } 101 }
98 weeknos[i]->installEventFilter(this); 102 weeknos[i]->installEventFilter(this);
99 103
100 topLayout->addWidget(weeknos[i],i+2,0); 104 topLayout->addWidget(weeknos[i],i+2,0);
101 } 105 }
102 106
103 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); 107 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix");
104 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); 108 daymatrix->setFrameStyle(Q3Frame::Panel|Q3Frame::Sunken);
105 daymatrix->setLineWidth(1); 109 daymatrix->setLineWidth(1);
106 110
107 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), 111 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
108 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 112 SIGNAL( datesSelected( const KCal::DateList & ) ) );
109 113
110 connect( daymatrix, SIGNAL( eventDropped( Event * ) ), 114 connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
111 SIGNAL( eventDropped( Event * ) ) ); 115 SIGNAL( eventDropped( Event * ) ) );
112 116
113 topLayout->addMultiCellWidget(daymatrix,2,7,1,7); 117 topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
114 118
115 // read settings from configuration file. 119 // read settings from configuration file.
116 updateConfig(); 120 updateConfig();
117 enableRollover(FollowMonth); 121 enableRollover(FollowMonth);
118 mySizeHint = sizeHintTwoButtons(); 122 mySizeHint = sizeHintTwoButtons();
119 myFullSizeHint = sizeHintTwoButtons( 4 ); 123 myFullSizeHint = sizeHintTwoButtons( 4 );
120 mFontChanged = false; 124 mFontChanged = false;
121 //resize ( 3,3 ); 125 //resize ( 3,3 );
122 126
123} 127}
124void KDateNavigator::changeFont ( QFont fo ) 128void KDateNavigator::changeFont ( QFont fo )
125{ 129{
126 setFont( fo ); 130 setFont( fo );
127 mNavigatorBar->resetFont( fo ); 131 mNavigatorBar->resetFont( fo );
128} 132}
129QFont KDateNavigator::yourFontHint( QSize si , bool *b) 133QFont KDateNavigator::yourFontHint( QSize si , bool *b)
130{ 134{
131 QFont fo = KOPrefs::instance()->mDateNavigatorFont; 135 QFont fo = KOPrefs::instance()->mDateNavigatorFont;
132 *b = false; 136 *b = false;
133 int fontPoint = fo.pointSize(); 137 int fontPoint = fo.pointSize();
134 while ( fontPoint > 5 ) { 138 while ( fontPoint > 5 ) {
135 --fontPoint; 139 --fontPoint;
136 fo.setPointSize( fontPoint ); 140 fo.setPointSize( fontPoint );
137 setFont( fo ); 141 setFont( fo );
138 mFontChanged = true; 142 mFontChanged = true;
139 mNavigatorBar->resetFont( fo ); 143 mNavigatorBar->resetFont( fo );
140 QSize sh = sizeHintTwoButtons( 2 ); 144 QSize sh = sizeHintTwoButtons( 2 );
141 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); 145 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() );
142 if ( si.width() > sh.width() && si.height() > sh.height()) { 146 if ( si.width() > sh.width() && si.height() > sh.height()) {
143 if ( si.width() / sh.width() == 1 ) { 147 if ( si.width() / sh.width() == 1 ) {
144 if ( si.width() < sizeHintTwoButtons( 4 ).width()) 148 if ( si.width() < sizeHintTwoButtons( 4 ).width())
145 continue; 149 continue;
146 } 150 }
147 *b = true; 151 *b = true;
148 break; 152 break;
149 } 153 }
150 } 154 }
151 return fo; 155 return fo;
152} 156}