summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-01-30 21:39:03 (UTC)
committer zautrix <zautrix>2005-01-30 21:39:03 (UTC)
commit6dbf4f4a6666e7a94c68517df1659eb14cd104b9 (patch) (unidiff)
treeb98e130d6d0d6205655cf1a6e28074c0c38011d1 /korganizer
parent15c5772f8a54750115f82aea34fea47e5842ff4f (diff)
downloadkdepimpi-6dbf4f4a6666e7a94c68517df1659eb14cd104b9.zip
kdepimpi-6dbf4f4a6666e7a94c68517df1659eb14cd104b9.tar.gz
kdepimpi-6dbf4f4a6666e7a94c68517df1659eb14cd104b9.tar.bz2
fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index faa2c21..9c3621e 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -1,219 +1,220 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> 3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
4 Parts of the source code have been copied from kdpdatebutton.cpp 4 Parts of the source code have been copied from kdpdatebutton.cpp
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qevent.h> 25#include <qevent.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qptrlist.h> 27#include <qptrlist.h>
28#include <qtimer.h>
28 29
29#include <kglobal.h> 30#include <kglobal.h>
30#include <kdebug.h> 31#include <kdebug.h>
31#include <klocale.h> 32#include <klocale.h>
32 33
33#include <libkcal/vcaldrag.h> 34#include <libkcal/vcaldrag.h>
34#include <libkcal/icaldrag.h> 35#include <libkcal/icaldrag.h>
35#include <libkcal/dndfactory.h> 36#include <libkcal/dndfactory.h>
36#include <libkcal/calendarresources.h> 37#include <libkcal/calendarresources.h>
37#include <libkcal/resourcecalendar.h> 38#include <libkcal/resourcecalendar.h>
38#include <kresources/resourceselectdialog.h> 39#include <kresources/resourceselectdialog.h>
39 40
40#include <kcalendarsystem.h> 41#include <kcalendarsystem.h>
41 42
42#ifndef KORG_NOPLUGINS 43#ifndef KORG_NOPLUGINS
43#include "kocore.h" 44#include "kocore.h"
44#endif 45#endif
45#include "koprefs.h" 46#include "koprefs.h"
46#include "koglobals.h" 47#include "koglobals.h"
47 48
48#include "kodaymatrix.h" 49#include "kodaymatrix.h"
49 50
50// ============================================================================ 51// ============================================================================
51// D Y N A M I C T I P 52// D Y N A M I C T I P
52// ============================================================================ 53// ============================================================================
53 54
54DynamicTip::DynamicTip( QWidget * parent ) 55DynamicTip::DynamicTip( QWidget * parent )
55 : QToolTip( parent ) 56 : QToolTip( parent )
56{ 57{
57 matrix = (KODayMatrix*)parent; 58 matrix = (KODayMatrix*)parent;
58} 59}
59 60
60 61
61void DynamicTip::maybeTip( const QPoint &pos ) 62void DynamicTip::maybeTip( const QPoint &pos )
62{ 63{
63 //calculate which cell of the matrix the mouse is in 64 //calculate which cell of the matrix the mouse is in
64 QRect sz = matrix->frameRect(); 65 QRect sz = matrix->frameRect();
65 int dheight = sz.height()*7 / 42; 66 int dheight = sz.height()*7 / 42;
66 int dwidth = sz.width() / 7; 67 int dwidth = sz.width() / 7;
67 int row = pos.y()/dheight; 68 int row = pos.y()/dheight;
68 int col = pos.x()/dwidth; 69 int col = pos.x()/dwidth;
69 70
70 QRect rct(col*dwidth, row*dheight, dwidth, dheight); 71 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
71 72
72// kdDebug() << "DynamicTip::maybeTip matrix cell index [" << 73// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
73// col << "][" << row << "] => " <<(col+row*7) << endl; 74// col << "][" << row << "] => " <<(col+row*7) << endl;
74 75
75 //show holiday names only 76 //show holiday names only
76 QString str = matrix->getHolidayLabel(col+row*7); 77 QString str = matrix->getHolidayLabel(col+row*7);
77 if (str.isEmpty()) return; 78 if (str.isEmpty()) return;
78 tip(rct, str); 79 tip(rct, str);
79} 80}
80 81
81 82
82// ============================================================================ 83// ============================================================================
83// K O D A Y M A T R I X 84// K O D A Y M A T R I X
84// ============================================================================ 85// ============================================================================
85 86
86const int KODayMatrix::NOSELECTION = -1000; 87const int KODayMatrix::NOSELECTION = -1000;
87const int KODayMatrix::NUMDAYS = 42; 88const int KODayMatrix::NUMDAYS = 42;
88 89
89KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : 90KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
90 QFrame(parent, name) 91 QFrame(parent, name)
91{ 92{
92 mCalendar = calendar; 93 mCalendar = calendar;
93 94
94 // initialize dynamic arrays 95 // initialize dynamic arrays
95 days = new QDate[NUMDAYS]; 96 days = new QDate[NUMDAYS];
96 daylbls = new QString[NUMDAYS]; 97 daylbls = new QString[NUMDAYS];
97 events = new int[NUMDAYS]; 98 events = new int[NUMDAYS];
98 mToolTip = new DynamicTip(this); 99 mToolTip = new DynamicTip(this);
99 100
100 // set default values used for drawing the matrix 101 // set default values used for drawing the matrix
101 mDefaultBackColor = palette().active().base(); 102 mDefaultBackColor = palette().active().base();
102 mDefaultTextColor = palette().active().foreground(); 103 mDefaultTextColor = palette().active().foreground();
103 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 104 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
104 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 105 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
105 mSelectedDaysColor = QColor("white"); 106 mSelectedDaysColor = QColor("white");
106 mTodayMarginWidth = 2; 107 mTodayMarginWidth = 2;
107 mSelEnd = mSelStart = NOSELECTION; 108 mSelEnd = mSelStart = NOSELECTION;
108 109
109 setAcceptDrops(true); 110 setAcceptDrops(true);
110 //setFont( QFont("Arial", 10) ); 111 //setFont( QFont("Arial", 10) );
111 112
112 mUpdateTimer = new QTimer( this ); 113 mUpdateTimer = new QTimer( this );
113 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); 114 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
114 mRepaintTimer = new QTimer( this ); 115 mRepaintTimer = new QTimer( this );
115 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); 116 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
116 mDayChanged = false; 117 mDayChanged = false;
117 updateView(); 118 updateView();
118} 119}
119 120
120QColor KODayMatrix::getShadedColor(QColor color) 121QColor KODayMatrix::getShadedColor(QColor color)
121{ 122{
122 QColor shaded; 123 QColor shaded;
123 int h=0; 124 int h=0;
124 int s=0; 125 int s=0;
125 int v=0; 126 int v=0;
126 color.hsv(&h,&s,&v); 127 color.hsv(&h,&s,&v);
127 s = s/4; 128 s = s/4;
128 v = 192+v/4; 129 v = 192+v/4;
129 shaded.setHsv(h,s,v); 130 shaded.setHsv(h,s,v);
130 131
131 return shaded; 132 return shaded;
132} 133}
133 134
134KODayMatrix::~KODayMatrix() 135KODayMatrix::~KODayMatrix()
135{ 136{
136 delete [] days; 137 delete [] days;
137 delete [] daylbls; 138 delete [] daylbls;
138 delete [] events; 139 delete [] events;
139 delete mToolTip; 140 delete mToolTip;
140} 141}
141 142
142/* 143/*
143void KODayMatrix::setStartDate(QDate start) 144void KODayMatrix::setStartDate(QDate start)
144{ 145{
145 updateView(start); 146 updateView(start);
146} 147}
147*/ 148*/
148 149
149void KODayMatrix::addSelectedDaysTo(DateList& selDays) 150void KODayMatrix::addSelectedDaysTo(DateList& selDays)
150{ 151{
151 152
152 if (mSelStart == NOSELECTION) { 153 if (mSelStart == NOSELECTION) {
153 return; 154 return;
154 } 155 }
155 156
156 //cope with selection being out of matrix limits at top (< 0) 157 //cope with selection being out of matrix limits at top (< 0)
157 int i0 = mSelStart; 158 int i0 = mSelStart;
158 if (i0 < 0) { 159 if (i0 < 0) {
159 for (int i = i0; i < 0; i++) { 160 for (int i = i0; i < 0; i++) {
160 selDays.append(days[0].addDays(i)); 161 selDays.append(days[0].addDays(i));
161 } 162 }
162 i0 = 0; 163 i0 = 0;
163 } 164 }
164 165
165 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 166 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
166 if (mSelEnd > NUMDAYS-1) { 167 if (mSelEnd > NUMDAYS-1) {
167 for (int i = i0; i <= NUMDAYS-1; i++) { 168 for (int i = i0; i <= NUMDAYS-1; i++) {
168 selDays.append(days[i]); 169 selDays.append(days[i]);
169 } 170 }
170 for (int i = NUMDAYS; i < mSelEnd; i++) { 171 for (int i = NUMDAYS; i < mSelEnd; i++) {
171 selDays.append(days[0].addDays(i)); 172 selDays.append(days[0].addDays(i));
172 } 173 }
173 174
174 // apply normal routine to selection being entirely within matrix limits 175 // apply normal routine to selection being entirely within matrix limits
175 } else { 176 } else {
176 for (int i = i0; i <= mSelEnd; i++) { 177 for (int i = i0; i <= mSelEnd; i++) {
177 selDays.append(days[i]); 178 selDays.append(days[i]);
178 } 179 }
179 } 180 }
180} 181}
181 182
182void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 183void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
183{ 184{
184 mSelStart = startdate.daysTo(start); 185 mSelStart = startdate.daysTo(start);
185 mSelEnd = startdate.daysTo(end); 186 mSelEnd = startdate.daysTo(end);
186} 187}
187 188
188 189
189void KODayMatrix::recalculateToday() 190void KODayMatrix::recalculateToday()
190{ 191{
191 today = -1; 192 today = -1;
192 for (int i=0; i<NUMDAYS; i++) { 193 for (int i=0; i<NUMDAYS; i++) {
193 days[i] = startdate.addDays(i); 194 days[i] = startdate.addDays(i);
194 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 195 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
195 196
196 // if today is in the currently displayed month, hilight today 197 // if today is in the currently displayed month, hilight today
197 if (days[i].year() == QDate::currentDate().year() && 198 if (days[i].year() == QDate::currentDate().year() &&
198 days[i].month() == QDate::currentDate().month() && 199 days[i].month() == QDate::currentDate().month() &&
199 days[i].day() == QDate::currentDate().day()) { 200 days[i].day() == QDate::currentDate().day()) {
200 today = i; 201 today = i;
201 } 202 }
202 } 203 }
203 // qDebug(QString("Today is visible at %1.").arg(today)); 204 // qDebug(QString("Today is visible at %1.").arg(today));
204} 205}
205 206
206void KODayMatrix::updateView() 207void KODayMatrix::updateView()
207{ 208{
208 updateView(startdate); 209 updateView(startdate);
209} 210}
210void KODayMatrix::repaintViewTimed() 211void KODayMatrix::repaintViewTimed()
211{ 212{
212 qDebug("KODayMatrix::repaintViewTimed "); 213 qDebug("KODayMatrix::repaintViewTimed ");
213 mRepaintTimer->stop(); 214 mRepaintTimer->stop();
214 repaint(false); 215 repaint(false);
215} 216}
216void KODayMatrix::updateViewTimed() 217void KODayMatrix::updateViewTimed()
217{ 218{
218 219
219 mUpdateTimer->stop(); 220 mUpdateTimer->stop();