summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaitem.cpp
Unidiff
Diffstat (limited to 'korganizer/koagendaitem.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 6a312b3..cead612 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,189 +1,192 @@
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 <qlabel.h> 20#include <qlabel.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qhbox.h> 22#include <qhbox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qwhatsthis.h> 25#include <qwhatsthis.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qpainter.h> 28#include <qpainter.h>
29 29
30#include <kiconloader.h> 30#include <kiconloader.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#define AGENDA_ICON_SIZE 5 36#define AGENDA_ICON_SIZE 5
37#else 37#else
38#define AGENDA_ICON_SIZE 7 38#define AGENDA_ICON_SIZE 7
39#endif 39#endif
40#include <libkcal/icaldrag.h> 40#include <libkcal/icaldrag.h>
41#include <libkcal/vcaldrag.h> 41#include <libkcal/vcaldrag.h>
42#include <libkcal/kincidenceformatter.h> 42#include <libkcal/kincidenceformatter.h>
43extern int globalFlagBlockAgenda; 43extern int globalFlagBlockAgenda;
44extern int globalFlagBlockAgendaItemPaint; 44extern int globalFlagBlockAgendaItemPaint;
45extern int globalFlagBlockAgendaItemUpdate; 45extern int globalFlagBlockAgendaItemUpdate;
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48 48
49#include "koagendaitem.h" 49#include "koagendaitem.h"
50//#include "koagendaitem.moc" 50//#include "koagendaitem.moc"
51 51
52 52
53//-------------------------------------------------------------------------- 53//--------------------------------------------------------------------------
54 54
55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
56 56
57//-------------------------------------------------------------------------- 57//--------------------------------------------------------------------------
58 58
59class KOAgendaItemWhatsThis :public QWhatsThis 59class KOAgendaItemWhatsThis :public QWhatsThis
60{ 60{
61public: 61public:
62 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 62 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
63 63
64protected: 64protected:
65 virtual QString text( const QPoint& ) 65 virtual QString text( const QPoint& )
66 { 66 {
67 return _view->getWhatsThisText() ; 67 return _view->getWhatsThisText() ;
68 } 68 }
69private: 69private:
70 KOAgendaItem * _view; 70 KOAgendaItem * _view;
71}; 71};
72 72
73KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 73KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
74 const char *name,WFlags) : 74 const char *name,WFlags) :
75 QWidget(parent, name), mIncidence(incidence), mDate(qd) 75 QWidget(parent, name), mIncidence(incidence), mDate(qd)
76{ 76{
77#ifndef DESKTOP_VERSION 77#ifndef DESKTOP_VERSION
78 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 78 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
79#endif 79#endif
80 new KOAgendaItemWhatsThis(this); 80 new KOAgendaItemWhatsThis(this);
81 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 81 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
82 setWFlags ( wflags); 82 setWFlags ( wflags);
83 mAllDay = allday; 83 mAllDay = allday;
84 init ( incidence, qd ); 84 init ( incidence, qd );
85 setMouseTracking(true); 85 setMouseTracking(true);
86 //setAcceptDrops(true); 86 //setAcceptDrops(true);
87 xPaintCoord = -1; 87 xPaintCoord = -1;
88 yPaintCoord = -1; 88 yPaintCoord = -1;
89} 89}
90QString KOAgendaItem::getWhatsThisText() 90QString KOAgendaItem::getWhatsThisText()
91{ 91{
92 if ( mIncidence ) 92 if ( mIncidence )
93 return KIncidenceFormatter::instance()->getFormattedText( mIncidence ); 93 return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
94 KOPrefs::instance()->mWTshowDetails,
95 KOPrefs::instance()->mWTshowCreated,
96 KOPrefs::instance()->mWTshowChanged);
94 return "KOAgendaItem::getWhatsThisText()::internal error"; 97 return "KOAgendaItem::getWhatsThisText()::internal error";
95} 98}
96void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 99void KOAgendaItem::init ( Incidence *incidence, QDate qd )
97{ 100{
98 mIncidence = incidence; 101 mIncidence = incidence;
99 mDate = qd; 102 mDate = qd;
100 mFirstMultiItem = 0; 103 mFirstMultiItem = 0;
101 mNextMultiItem = 0; 104 mNextMultiItem = 0;
102 mLastMultiItem = 0; 105 mLastMultiItem = 0;
103 computeText(); 106 computeText();
104 107
105 if ( (incidence->type() == "Todo") && 108 if ( (incidence->type() == "Todo") &&
106 ( !((static_cast<Todo*>(incidence))->isCompleted()) && 109 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
107 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { 110 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
108 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) 111 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
109 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 112 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
110 else 113 else
111 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 114 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
112 } 115 }
113 else { 116 else {
114 QStringList categories = mIncidence->categories(); 117 QStringList categories = mIncidence->categories();
115 QString cat = categories.first(); 118 QString cat = categories.first();
116 if (cat.isEmpty()) { 119 if (cat.isEmpty()) {
117 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) 120 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) )
118 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 121 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
119 else 122 else
120 mBackgroundColor =KOPrefs::instance()->mEventColor; 123 mBackgroundColor =KOPrefs::instance()->mEventColor;
121 } else { 124 } else {
122 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 125 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
123 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 126 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) {
124 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 127 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
125 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 128 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
126 } 129 }
127 } 130 }
128 131
129 } 132 }
130 mColorGroup = QColorGroup( mBackgroundColor.light(), 133 mColorGroup = QColorGroup( mBackgroundColor.light(),
131 mBackgroundColor.dark(),mBackgroundColor.light(), 134 mBackgroundColor.dark(),mBackgroundColor.light(),
132 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 135 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
133 setBackgroundColor( mBackgroundColor ); 136 setBackgroundColor( mBackgroundColor );
134 137
135 setCellXY(0,0,1); 138 setCellXY(0,0,1);
136 setCellXWidth(0); 139 setCellXWidth(0);
137 setSubCell(0); 140 setSubCell(0);
138 setSubCells(1); 141 setSubCells(1);
139 setMultiItem(0,0,0); 142 setMultiItem(0,0,0);
140 startMove(); 143 startMove();
141 mSelected = true; 144 mSelected = true;
142 select(false); 145 select(false);
143 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 146 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
144 mFontPixelSize = fontinf.height();; 147 mFontPixelSize = fontinf.height();;
145 hide(); 148 hide();
146 xPaintCoord = -1; 149 xPaintCoord = -1;
147 yPaintCoord = -1; 150 yPaintCoord = -1;
148} 151}
149 152
150 153
151KOAgendaItem::~KOAgendaItem() 154KOAgendaItem::~KOAgendaItem()
152{ 155{
153 // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); 156 // qDebug("deleteKOAgendaItem::~KOAgendaItem( ");
154 157
155} 158}
156 159
157void KOAgendaItem::recreateIncidence() 160void KOAgendaItem::recreateIncidence()
158{ 161{
159#if 0 162#if 0
160 Incidence* newInc = mIncidence->clone(); 163 Incidence* newInc = mIncidence->clone();
161 newInc->recreate(); 164 newInc->recreate();
162 if ( mIncidence->doesRecur() ) { 165 if ( mIncidence->doesRecur() ) {
163 mIncidence->addExDate( mDate ); 166 mIncidence->addExDate( mDate );
164 newInc->recurrence()->unsetRecurs(); 167 newInc->recurrence()->unsetRecurs();
165 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 168 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
166 QTime tim = mIncidence->dtStart().time(); 169 QTime tim = mIncidence->dtStart().time();
167 newInc->setDtStart( QDateTime(mDate, tim) ); 170 newInc->setDtStart( QDateTime(mDate, tim) );
168 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 171 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
169 } 172 }
170#endif 173#endif
171 mIncidence = mIncidence->recreateCloneException( mDate ); 174 mIncidence = mIncidence->recreateCloneException( mDate );
172} 175}
173bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 176bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
174{ 177{
175 int size = AGENDA_ICON_SIZE; 178 int size = AGENDA_ICON_SIZE;
176 179
177 int yOff = 0; 180 int yOff = 0;
178 int xOff = 0; 181 int xOff = 0;
179 int x = pos().x() +3; 182 int x = pos().x() +3;
180 int y; 183 int y;
181 if ( mAllDay ) 184 if ( mAllDay )
182 y = pos().y()+3; 185 y = pos().y()+3;
183 else 186 else
184 y = mCellYTop * ( height() / cellHeight() ) +3; 187 y = mCellYTop * ( height() / cellHeight() ) +3;
185 if (mIncidence->cancelled()) { 188 if (mIncidence->cancelled()) {
186 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 189 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
187 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 190 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
188 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 191 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
189 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 192 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );