summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaitem.cpp
Unidiff
Diffstat (limited to 'korganizer/koagendaitem.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp70
1 files changed, 40 insertions, 30 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 407424d..0f9a38f 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -16,19 +16,29 @@
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 <q3hbox.h>
23#include <qvbox.h> 23#include <q3vbox.h>
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qwhatsthis.h> 25#include <q3whatsthis.h>
26#include <qdragobject.h> 26#include <q3dragobject.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <QDesktopWidget>
30//Added by qt3to4:
31#include <Q3PtrList>
32#include <QPixmap>
33#include <QDragEnterEvent>
34#include <QDropEvent>
35#include <QResizeEvent>
36#include <QMouseEvent>
37#include <QEvent>
38#include <QPaintEvent>
29 39
30#include <kiconloader.h> 40#include <kiconloader.h>
31#include <kdebug.h> 41#include <kdebug.h>
32#include <kglobal.h> 42#include <kglobal.h>
33#include <klocale.h> 43#include <klocale.h>
34#ifndef DESKTOP_VERSION 44#ifndef DESKTOP_VERSION
@@ -54,36 +64,36 @@ extern int globalFlagBlockAgendaItemUpdate;
54//-------------------------------------------------------------------------- 64//--------------------------------------------------------------------------
55 65
56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 66QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
57 67
58//-------------------------------------------------------------------------- 68//--------------------------------------------------------------------------
59 69
60class KOAgendaItemWhatsThis :public QWhatsThis 70class KOAgendaItemWhatsThis :public Q3WhatsThis
61{ 71{
62public: 72public:
63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 73 KOAgendaItemWhatsThis( KOAgendaItem* view ) : Q3WhatsThis( view ),_view (view) { };
64 74
65protected: 75protected:
66 virtual QString text( const QPoint& ) 76 virtual QString text( const QPoint& )
67 { 77 {
68 return _view->getWhatsThisText() ; 78 return _view->getWhatsThisText() ;
69 } 79 }
70private: 80private:
71 KOAgendaItem * _view; 81 KOAgendaItem * _view;
72}; 82};
73 83
74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 84KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
75 const char *name,WFlags) : 85 const char *name,Qt::WFlags) :
76 QWidget(parent, name), mIncidence(incidence), mDate(qd) 86 QWidget(parent, name), mIncidence(incidence), mDate(qd)
77{ 87{
78#ifndef DESKTOP_VERSION 88#ifndef DESKTOP_VERSION
79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 89 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
80#endif 90#endif
81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); 91 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this);
82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 92 Qt::WindowFlags wflags = windowFlags() |Qt::WRepaintNoErase;// WResizeNoErase
83 setWFlags ( wflags); 93 setWindowFlags ( wflags);
84 mAllDay = allday; 94 mAllDay = allday;
85 init ( incidence, qd ); 95 init ( incidence, qd );
86 //setMouseTracking(true); 96 //setMouseTracking(true);
87 //setAcceptDrops(true); 97 //setAcceptDrops(true);
88 xPaintCoord = -1; 98 xPaintCoord = -1;
89 yPaintCoord = -1; 99 yPaintCoord = -1;
@@ -100,13 +110,13 @@ QString KOAgendaItem::getWhatsThisText()
100 110
101void KOAgendaItem::initColor () 111void KOAgendaItem::initColor ()
102{ 112{
103 if ( (mIncidence->typeID() == todoID ) && 113 if ( (mIncidence->typeID() == todoID ) &&
104 ( !((static_cast<Todo*>(mIncidence))->isCompleted()) && 114 ( !((static_cast<Todo*>(mIncidence))->isCompleted()) &&
105 ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) { 115 ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) {
106 if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date()) 116 if ( (static_cast<Todo*>(mIncidence))->dtDue() < (QDateTime)QDateTime::currentDateTime().date())
107 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 117 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
108 else 118 else
109 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 119 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
110 } 120 }
111 else { 121 else {
112 QStringList categories = mIncidence->categories(); 122 QStringList categories = mIncidence->categories();
@@ -129,13 +139,13 @@ void KOAgendaItem::initColor ()
129 QColor BackgroundColor ( mBackgroundColor ); 139 QColor BackgroundColor ( mBackgroundColor );
130 if ( mIncidence->calID() > 1 ) { 140 if ( mIncidence->calID() > 1 ) {
131 //BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); 141 //BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() );
132 } 142 }
133 mColorGroup = QColorGroup( BackgroundColor.light(), 143 mColorGroup = QColorGroup( BackgroundColor.light(),
134 BackgroundColor.dark(),BackgroundColor.light(), 144 BackgroundColor.dark(),BackgroundColor.light(),
135 BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; 145 BackgroundColor.dark(),BackgroundColor, Qt::black, BackgroundColor) ;
136 setBackgroundColor( mBackgroundColor ); 146 setBackgroundColor( mBackgroundColor );
137 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); 147 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250);
138} 148}
139void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 149void KOAgendaItem::init ( Incidence *incidence, QDate qd )
140{ 150{
141 mIncidence = incidence; 151 mIncidence = incidence;
@@ -225,62 +235,62 @@ bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
225 if ( horLayout ) 235 if ( horLayout )
226 ++xOff; 236 ++xOff;
227 else 237 else
228 ++yOff; 238 ++yOff;
229 } 239 }
230 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { 240 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) {
231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 241 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::red );
232 if ( horLayout ) 242 if ( horLayout )
233 ++xOff; 243 ++xOff;
234 else 244 else
235 ++yOff; 245 ++yOff;
236 } 246 }
237 if (mIncidence->doesRecur()) { 247 if (mIncidence->doesRecur()) {
238 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 248 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::blue );
239 if ( horLayout ) 249 if ( horLayout )
240 ++xOff; 250 ++xOff;
241 else 251 else
242 ++yOff; 252 ++yOff;
243 } 253 }
244 if (mIncidence->description().length() > 0) { 254 if (mIncidence->description().length() > 0) {
245 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 255 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::darkGreen );
246 if ( horLayout ) 256 if ( horLayout )
247 ++xOff; 257 ++xOff;
248 else 258 else
249 ++yOff; 259 ++yOff;
250 } 260 }
251 if (mIncidence->isReadOnly()) { 261 if (mIncidence->isReadOnly()) {
252 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 262 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::white );
253 if ( horLayout ) 263 if ( horLayout )
254 ++xOff; 264 ++xOff;
255 else 265 else
256 ++yOff; 266 ++yOff;
257 } 267 }
258 268
259 if (mIncidence->attendeeCount()>0) { 269 if (mIncidence->attendeeCount()>0) {
260 270
261 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 271 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
262 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 272 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::black );
263 if ( horLayout ) 273 if ( horLayout )
264 ++xOff; 274 ++xOff;
265 else 275 else
266 ++yOff; 276 ++yOff;
267 } else { 277 } else {
268 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 278 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
269 if (me!=0) { 279 if (me!=0) {
270 280
271 281
272 } else { 282 } else {
273 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 283 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::yellow );
274 if ( horLayout ) 284 if ( horLayout )
275 ++xOff; 285 ++xOff;
276 else 286 else
277 ++yOff; 287 ++yOff;
278 288
279 } 289 }
280 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 290 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::darkYellow );
281 if ( horLayout ) 291 if ( horLayout )
282 ++xOff; 292 ++xOff;
283 else 293 else
284 ++yOff; 294 ++yOff;
285 295
286 } 296 }
@@ -417,39 +427,39 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint )
417 else 427 else
418 if ( nfh < h -2 ) 428 if ( nfh < h -2 )
419 ++yy; 429 ++yy;
420 } 430 }
421 int align; 431 int align;
422#ifndef DESKTOP_VERSION 432#ifndef DESKTOP_VERSION
423 align = ( AlignLeft|WordBreak|AlignTop); 433 align = ( Qt::AlignLeft|Qt::TextWordWrap|Qt::AlignTop);
424#else 434#else
425 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 435 align = ( Qt::AlignLeft|Qt::TextWrapAnywhere|Qt::TextWordWrap|Qt::AlignTop);
426#endif 436#endif
427 if ( addIcon ) { 437 if ( addIcon ) {
428 if ( ! horLayout ) { 438 if ( ! horLayout ) {
429 x += AGENDA_ICON_SIZE+3; 439 x += AGENDA_ICON_SIZE+3;
430 w -= (AGENDA_ICON_SIZE+3); 440 w -= (AGENDA_ICON_SIZE+3);
431 } 441 }
432 else { 442 else {
433 yy+= AGENDA_ICON_SIZE+2; 443 yy+= AGENDA_ICON_SIZE+2;
434 h -=(AGENDA_ICON_SIZE+3); 444 h -=(AGENDA_ICON_SIZE+3);
435 } 445 }
436 } 446 }
437 if ( mWhiteText ) 447 if ( mWhiteText )
438 paint->setPen ( white); 448 paint->setPen ( Qt::white);
439 if ( x < 0 ) { 449 if ( x < 0 ) {
440 w = w+x-3; 450 w = w+x-3;
441 x = 3; 451 x = 3;
442 if ( !horLayout && addIcon ) 452 if ( !horLayout && addIcon )
443 x += AGENDA_ICON_SIZE+3; 453 x += AGENDA_ICON_SIZE+3;
444 if ( w > parentWidget()->width() ){ 454 if ( w > parentWidget()->width() ){
445 w = parentWidget()->width() - 6; 455 w = parentWidget()->width() - 6;
446#ifndef DESKTOP_VERSION 456#ifndef DESKTOP_VERSION
447 align = ( AlignHCenter|WordBreak|AlignTop); 457 align = ( Qt::AlignHCenter|Qt::TextWordWrap|Qt::AlignTop);
448#else 458#else
449 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 459 align = ( Qt::AlignHCenter|Qt::TextWrapAnywhere|Qt::TextWordWrap|Qt::AlignTop);
450#endif 460#endif
451 461
452 } 462 }
453 } 463 }
454 QRect dr; 464 QRect dr;
455 if ( w + x > parentWidget()->width() ) 465 if ( w + x > parentWidget()->width() )
@@ -558,13 +568,13 @@ void KOAgendaItem::paintEvent ( QPaintEvent *e )
558 if ( rw <= 1 ) { 568 if ( rw <= 1 ) {
559 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 569 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
560 return; 570 return;
561 } 571 }
562 } 572 }
563 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 573 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
564 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 574 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,QPainter::CompositionMode_Source);
565} 575}
566void KOAgendaItem::computeText() 576void KOAgendaItem::computeText()
567{ 577{
568 mDisplayedText = mIncidence->summary(); 578 mDisplayedText = mIncidence->summary();
569 if ( (mIncidence->typeID() == todoID ) ) { 579 if ( (mIncidence->typeID() == todoID ) ) {
570 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 580 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
@@ -625,13 +635,13 @@ void KOAgendaItem::computeText()
625 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 635 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
626 } 636 }
627 637
628 if (!mIncidence->location().isEmpty()) { 638 if (!mIncidence->location().isEmpty()) {
629 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 639 tipText += "\n"+i18n("Location: ")+mIncidence->location();
630 } 640 }
631 QToolTip::add(this,tipText,toolTipGroup(),""); 641 QToolTip::add(this,tipText /*TODO:hacker: ,toolTipGroup(),"" */);
632#endif 642#endif
633} 643}
634void KOAgendaItem::updateItem() 644void KOAgendaItem::updateItem()
635{ 645{
636 computeText(); 646 computeText();
637 647
@@ -792,33 +802,33 @@ void KOAgendaItem::expandRight(int dx)
792 if (newXWidth < newX) newXWidth = newX; 802 if (newXWidth < newX) newXWidth = newX;
793 setCellX(newX,newXWidth); 803 setCellX(newX,newXWidth);
794} 804}
795 805
796QToolTipGroup *KOAgendaItem::toolTipGroup() 806QToolTipGroup *KOAgendaItem::toolTipGroup()
797{ 807{
798 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 808 /* TODO:hacker: if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); */
799 return mToolTipGroup; 809 return mToolTipGroup;
800} 810}
801 811
802void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 812void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
803{ 813{
804#ifndef KORG_NODND 814#ifndef KORG_NODND
805 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 815 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
806 !QTextDrag::canDecode( e ) ) { 816 !Q3TextDrag::canDecode( e ) ) {
807 e->ignore(); 817 e->ignore();
808 return; 818 return;
809 } 819 }
810 e->accept(); 820 e->accept();
811#endif 821#endif
812} 822}
813 823
814void KOAgendaItem::dropEvent( QDropEvent *e ) 824void KOAgendaItem::dropEvent( QDropEvent *e )
815{ 825{
816#ifndef KORG_NODND 826#ifndef KORG_NODND
817 QString text; 827 QString text;
818 if(QTextDrag::decode(e,text)) 828 if(Q3TextDrag::decode(e,text))
819 { 829 {
820 kdDebug() << "Dropped : " << text << endl; 830 kdDebug() << "Dropped : " << text << endl;
821 QStringList emails = QStringList::split(",",text); 831 QStringList emails = QStringList::split(",",text);
822 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 832 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
823 kdDebug() << " Email: " << (*it) << endl; 833 kdDebug() << " Email: " << (*it) << endl;
824 int pos = (*it).find("<"); 834 int pos = (*it).find("<");
@@ -830,18 +840,18 @@ void KOAgendaItem::dropEvent( QDropEvent *e )
830 } 840 }
831 } 841 }
832#endif 842#endif
833} 843}
834 844
835 845
836QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 846Q3PtrList<KOAgendaItem> KOAgendaItem::conflictItems()
837{ 847{
838 return mConflictItems; 848 return mConflictItems;
839} 849}
840 850
841void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 851void KOAgendaItem::setConflictItems(Q3PtrList<KOAgendaItem> ci)
842{ 852{
843 mConflictItems = ci; 853 mConflictItems = ci;
844 KOAgendaItem *item; 854 KOAgendaItem *item;
845 for ( item=mConflictItems.first(); item != 0; 855 for ( item=mConflictItems.first(); item != 0;
846 item=mConflictItems.next() ) { 856 item=mConflictItems.next() ) {
847 item->addConflictItem(this); 857 item->addConflictItem(this);