summaryrefslogtreecommitdiffabout
path: root/korganizer/kodaymatrix.cpp
Unidiff
Diffstat (limited to 'korganizer/kodaymatrix.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index ae0a051..5133519 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -33,112 +33,113 @@
33#include <klocale.h> 33#include <klocale.h>
34 34
35#include <libkcal/vcaldrag.h> 35#include <libkcal/vcaldrag.h>
36#include <libkcal/icaldrag.h> 36#include <libkcal/icaldrag.h>
37#include <libkcal/dndfactory.h> 37#include <libkcal/dndfactory.h>
38#include <libkcal/calendarresources.h> 38#include <libkcal/calendarresources.h>
39#include <libkcal/resourcecalendar.h> 39#include <libkcal/resourcecalendar.h>
40#include <kresources/resourceselectdialog.h> 40#include <kresources/resourceselectdialog.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPLUGINS 44#ifndef KORG_NOPLUGINS
45#include "kocore.h" 45#include "kocore.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#include "koglobals.h" 48#include "koglobals.h"
49 49
50#include "kodaymatrix.h" 50#include "kodaymatrix.h"
51 51
52// ============================================================================ 52// ============================================================================
53// D Y N A M I C T I P 53// D Y N A M I C T I P
54// ============================================================================ 54// ============================================================================
55 55
56DynamicTip::DynamicTip( QWidget * parent ) 56DynamicTip::DynamicTip( QWidget * parent )
57 : QToolTip( parent ) 57 : QToolTip( parent )
58{ 58{
59 matrix = (KODayMatrix*)parent; 59 matrix = (KODayMatrix*)parent;
60} 60}
61 61
62class KODaymatrixWhatsThis :public QWhatsThis 62class KODaymatrixWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { }; 65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;};
66 ~KODaymatrixWhatsThis() { ; };
66 67
67protected: 68protected:
68 virtual QString text( const QPoint& p ) 69 virtual QString text( const QPoint& p )
69 { 70 {
70 return _view->getWhatsThisText( p ) ; 71 return _view->getWhatsThisText( p ) ;
71 } 72 }
72private: 73private:
73 KODayMatrix * _view; 74 KODayMatrix * _view;
74}; 75};
75 76
76void DynamicTip::maybeTip( const QPoint &pos ) 77void DynamicTip::maybeTip( const QPoint &pos )
77{ 78{
78 //calculate which cell of the matrix the mouse is in 79 //calculate which cell of the matrix the mouse is in
79 QRect sz = matrix->frameRect(); 80 QRect sz = matrix->frameRect();
80 int dheight = sz.height()*7 / 42; 81 int dheight = sz.height()*7 / 42;
81 int dwidth = sz.width() / 7; 82 int dwidth = sz.width() / 7;
82 int row = pos.y()/dheight; 83 int row = pos.y()/dheight;
83 int col = pos.x()/dwidth; 84 int col = pos.x()/dwidth;
84 85
85 QRect rct(col*dwidth, row*dheight, dwidth, dheight); 86 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
86 87
87// kdDebug() << "DynamicTip::maybeTip matrix cell index [" << 88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
88// col << "][" << row << "] => " <<(col+row*7) << endl; 89// col << "][" << row << "] => " <<(col+row*7) << endl;
89 90
90 //show holiday names only 91 //show holiday names only
91 QString str = matrix->getHolidayLabel(col+row*7); 92 QString str = matrix->getHolidayLabel(col+row*7);
92 if (str.isEmpty()) return; 93 if (str.isEmpty()) return;
93 tip(rct, str); 94 tip(rct, str);
94} 95}
95 96
96 97
97// ============================================================================ 98// ============================================================================
98// K O D A Y M A T R I X 99// K O D A Y M A T R I X
99// ============================================================================ 100// ============================================================================
100 101
101const int KODayMatrix::NOSELECTION = -1000; 102const int KODayMatrix::NOSELECTION = -1000;
102const int KODayMatrix::NUMDAYS = 42; 103const int KODayMatrix::NUMDAYS = 42;
103 104
104KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) 105KODayMatrix::KODayMatrix( QWidget *parent, const char *name )
105 : QFrame( parent, name ), mCalendar( 0 ) 106 : QFrame( parent, name ), mCalendar( 0 )
106 107
107#if 0 108#if 0
108KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : 109KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
109 QFrame(parent, name) 110 QFrame(parent, name)
110#endif 111#endif
111{ 112{
112 new KODaymatrixWhatsThis(this); 113 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this);
113 mPendingUpdateBeforeRepaint = false; 114 mPendingUpdateBeforeRepaint = false;
114 mouseDown = false; 115 mouseDown = false;
115 // initialize dynamic arrays 116 // initialize dynamic arrays
116 bDays.resize ( NUMDAYS ); 117 bDays.resize ( NUMDAYS );
117 days = new QDate[NUMDAYS]; 118 days = new QDate[NUMDAYS];
118 daylbls = new QString[NUMDAYS]; 119 daylbls = new QString[NUMDAYS];
119 events = new int[NUMDAYS]; 120 events = new int[NUMDAYS];
120 mToolTip = new DynamicTip(this); 121 mToolTip = new DynamicTip(this);
121 122
122 // set default values used for drawing the matrix 123 // set default values used for drawing the matrix
123 mDefaultBackColor = palette().active().base(); 124 mDefaultBackColor = palette().active().base();
124 mDefaultTextColor = palette().active().foreground(); 125 mDefaultTextColor = palette().active().foreground();
125 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 126 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
126 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 127 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
127 mSelectedDaysColor = QColor("white"); 128 mSelectedDaysColor = QColor("white");
128 mTodayMarginWidth = 2; 129 mTodayMarginWidth = 2;
129 mSelEnd = mSelStart = NOSELECTION; 130 mSelEnd = mSelStart = NOSELECTION;
130 131
131 setAcceptDrops(true); 132 setAcceptDrops(true);
132 //setFont( QFont("Arial", 10) ); 133 //setFont( QFont("Arial", 10) );
133 134
134 mUpdateTimer = new QTimer( this ); 135 mUpdateTimer = new QTimer( this );
135 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); 136 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
136 mRepaintTimer = new QTimer( this ); 137 mRepaintTimer = new QTimer( this );
137 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); 138 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
138 mDayChanged = false; 139 mDayChanged = false;
139 updateView(); 140 updateView();
140} 141}
141QString KODayMatrix::getWhatsThisText( QPoint p ) 142QString KODayMatrix::getWhatsThisText( QPoint p )
142{ 143{
143 144
144 int tmp = getDayIndexFrom(p.x(), p.y()); 145 int tmp = getDayIndexFrom(p.x(), p.y());
@@ -193,64 +194,65 @@ QString KODayMatrix::getWhatsThisText( QPoint p )
193 } 194 }
194 } 195 }
195 mToolTip.append( mToolTipText ); 196 mToolTip.append( mToolTipText );
196 } 197 }
197 mToolTip.sort(); 198 mToolTip.sort();
198 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); 199 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>");
199} 200}
200void KODayMatrix::setCalendar( Calendar *cal ) 201void KODayMatrix::setCalendar( Calendar *cal )
201{ 202{
202 mCalendar = cal; 203 mCalendar = cal;
203 204
204 setAcceptDrops( mCalendar ); 205 setAcceptDrops( mCalendar );
205 206
206 updateEvents(); 207 updateEvents();
207} 208}
208 209
209QColor KODayMatrix::getShadedColor(QColor color) 210QColor KODayMatrix::getShadedColor(QColor color)
210{ 211{
211 QColor shaded; 212 QColor shaded;
212 int h=0; 213 int h=0;
213 int s=0; 214 int s=0;
214 int v=0; 215 int v=0;
215 color.hsv(&h,&s,&v); 216 color.hsv(&h,&s,&v);
216 s = s/4; 217 s = s/4;
217 v = 192+v/4; 218 v = 192+v/4;
218 shaded.setHsv(h,s,v); 219 shaded.setHsv(h,s,v);
219 220
220 return shaded; 221 return shaded;
221} 222}
222 223
223KODayMatrix::~KODayMatrix() 224KODayMatrix::~KODayMatrix()
224{ 225{
226 delete mKODaymatrixWhatsThis;
225 delete [] days; 227 delete [] days;
226 delete [] daylbls; 228 delete [] daylbls;
227 delete [] events; 229 delete [] events;
228 delete mToolTip; 230 delete mToolTip;
229} 231}
230 232
231/* 233/*
232void KODayMatrix::setStartDate(QDate start) 234void KODayMatrix::setStartDate(QDate start)
233{ 235{
234 updateView(start); 236 updateView(start);
235} 237}
236*/ 238*/
237 239
238void KODayMatrix::addSelectedDaysTo(DateList& selDays) 240void KODayMatrix::addSelectedDaysTo(DateList& selDays)
239{ 241{
240 242
241 if (mSelStart == NOSELECTION) { 243 if (mSelStart == NOSELECTION) {
242 return; 244 return;
243 } 245 }
244 246
245 //cope with selection being out of matrix limits at top (< 0) 247 //cope with selection being out of matrix limits at top (< 0)
246 int i0 = mSelStart; 248 int i0 = mSelStart;
247 if (i0 < 0) { 249 if (i0 < 0) {
248 for (int i = i0; i < 0; i++) { 250 for (int i = i0; i < 0; i++) {
249 selDays.append(days[0].addDays(i)); 251 selDays.append(days[0].addDays(i));
250 } 252 }
251 i0 = 0; 253 i0 = 0;
252 } 254 }
253 255
254 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 256 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
255 if (mSelEnd > NUMDAYS-1) { 257 if (mSelEnd > NUMDAYS-1) {
256 for (int i = i0; i <= NUMDAYS-1; i++) { 258 for (int i = i0; i <= NUMDAYS-1; i++) {