author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /korganizer/kodaymatrix.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | korganizer/kodaymatrix.cpp | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 52fd1e8..4f681b3 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -21,15 +21,24 @@ | |||
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 ode for Qt in the source distribution. | 22 | without including the source ode 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 <q3ptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 29 | #include <q3whatsthis.h> |
30 | //Added by qt3to4: | ||
31 | #include <QDragLeaveEvent> | ||
32 | #include <Q3Frame> | ||
33 | #include <QDragEnterEvent> | ||
34 | #include <QDragMoveEvent> | ||
35 | #include <QDropEvent> | ||
36 | #include <QResizeEvent> | ||
37 | #include <QMouseEvent> | ||
38 | #include <QPaintEvent> | ||
30 | 39 | ||
31 | #include <kglobal.h> | 40 | #include <kglobal.h> |
32 | #include <kdebug.h> | 41 | #include <kdebug.h> |
33 | #include <klocale.h> | 42 | #include <klocale.h> |
34 | 43 | ||
35 | #include <libkcal/vcaldrag.h> | 44 | #include <libkcal/vcaldrag.h> |
@@ -51,21 +60,21 @@ | |||
51 | 60 | ||
52 | // ============================================================================ | 61 | // ============================================================================ |
53 | // D Y N A M I C T I P | 62 | // D Y N A M I C T I P |
54 | // ============================================================================ | 63 | // ============================================================================ |
55 | 64 | ||
56 | DynamicTip::DynamicTip( QWidget * parent ) | 65 | DynamicTip::DynamicTip( QWidget * parent ) |
57 | : QToolTip( parent ) | 66 | /* TODO:hacker: : QToolTip( parent ) */ |
58 | { | 67 | { |
59 | matrix = (KODayMatrix*)parent; | 68 | matrix = (KODayMatrix*)parent; |
60 | } | 69 | } |
61 | 70 | ||
62 | class KODaymatrixWhatsThis :public QWhatsThis | 71 | class KODaymatrixWhatsThis :public Q3WhatsThis |
63 | { | 72 | { |
64 | public: | 73 | public: |
65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; | 74 | KODaymatrixWhatsThis( KODayMatrix* view ) : Q3WhatsThis( view ),_view (view) { ;}; |
66 | ~KODaymatrixWhatsThis() { ; }; | 75 | ~KODaymatrixWhatsThis() { ; }; |
67 | 76 | ||
68 | protected: | 77 | protected: |
69 | virtual QString text( const QPoint& p ) | 78 | virtual QString text( const QPoint& p ) |
70 | { | 79 | { |
71 | return _view->getWhatsThisText( p ) ; | 80 | return _view->getWhatsThisText( p ) ; |
@@ -88,25 +97,25 @@ void DynamicTip::maybeTip( const QPoint &pos ) | |||
88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 97 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
89 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 98 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
90 | 99 | ||
91 | //show holiday names only | 100 | //show holiday names only |
92 | QString str = matrix->getHolidayLabel(col+row*7); | 101 | QString str = matrix->getHolidayLabel(col+row*7); |
93 | if (str.isEmpty()) return; | 102 | if (str.isEmpty()) return; |
94 | tip(rct, str); | 103 | /* TODO:hacker: tip(rct, str);*/ |
95 | } | 104 | } |
96 | 105 | ||
97 | 106 | ||
98 | // ============================================================================ | 107 | // ============================================================================ |
99 | // K O D A Y M A T R I X | 108 | // K O D A Y M A T R I X |
100 | // ============================================================================ | 109 | // ============================================================================ |
101 | 110 | ||
102 | const int KODayMatrix::NOSELECTION = -1000; | 111 | const int KODayMatrix::NOSELECTION = -1000; |
103 | const int KODayMatrix::NUMDAYS = 42; | 112 | const int KODayMatrix::NUMDAYS = 42; |
104 | 113 | ||
105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 114 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
106 | : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) | 115 | : Q3Frame( parent, name , Qt::WNoAutoErase ), mCalendar( 0 ) |
107 | 116 | ||
108 | 117 | ||
109 | { | 118 | { |
110 | mLastView = -1; | 119 | mLastView = -1; |
111 | oldW = 0; | 120 | oldW = 0; |
112 | oldH = 0; | 121 | oldH = 0; |
@@ -148,13 +157,13 @@ QString KODayMatrix::getWhatsThisText( QPoint p ) | |||
148 | { | 157 | { |
149 | 158 | ||
150 | int tmp = getDayIndexFrom(p.x(), p.y()); | 159 | int tmp = getDayIndexFrom(p.x(), p.y()); |
151 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) | 160 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) |
152 | return QString(); | 161 | return QString(); |
153 | QDate mDate = days[tmp]; | 162 | QDate mDate = days[tmp]; |
154 | QPtrList<Event> eventlist = mCalendar->events(mDate); | 163 | Q3PtrList<Event> eventlist = mCalendar->events(mDate); |
155 | Event *event; | 164 | Event *event; |
156 | QStringList mToolTip; | 165 | QStringList mToolTip; |
157 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 166 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
158 | QString mToolTipText; | 167 | QString mToolTipText; |
159 | QString text; | 168 | QString text; |
160 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 169 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
@@ -202,13 +211,13 @@ QString KODayMatrix::getWhatsThisText( QPoint p ) | |||
202 | mToolTipText += " (" + event->location() + ")"; | 211 | mToolTipText += " (" + event->location() + ")"; |
203 | //qDebug("TTT: %s ", mToolTipText.latin1()); | 212 | //qDebug("TTT: %s ", mToolTipText.latin1()); |
204 | mToolTip.append( deTag( mToolTipText ) ); | 213 | mToolTip.append( deTag( mToolTipText ) ); |
205 | } | 214 | } |
206 | mToolTip.sort(); | 215 | mToolTip.sort(); |
207 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { | 216 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { |
208 | QPtrList<Todo> todolist = mCalendar->todos(mDate); | 217 | Q3PtrList<Todo> todolist = mCalendar->todos(mDate); |
209 | Todo *todo; | 218 | Todo *todo; |
210 | for(todo=todolist.first();todo != 0;todo=todolist.next()) { | 219 | for(todo=todolist.first();todo != 0;todo=todolist.next()) { |
211 | QString mToolTipText; | 220 | QString mToolTipText; |
212 | if ( !todo->doesFloat() ) | 221 | if ( !todo->doesFloat() ) |
213 | mToolTipText += KGlobal::locale()->formatTime(todo->dtDue().time())+" "; | 222 | mToolTipText += KGlobal::locale()->formatTime(todo->dtDue().time())+" "; |
214 | mToolTipText += todo->summary(); | 223 | mToolTipText += todo->summary(); |
@@ -217,13 +226,13 @@ QString KODayMatrix::getWhatsThisText( QPoint p ) | |||
217 | mToolTipText = deTag( mToolTipText); | 226 | mToolTipText = deTag( mToolTipText); |
218 | mToolTipText = "<b>" + i18n("Todo: ") + "</b>"+ mToolTipText; | 227 | mToolTipText = "<b>" + i18n("Todo: ") + "</b>"+ mToolTipText; |
219 | mToolTip.append( mToolTipText ); | 228 | mToolTip.append( mToolTipText ); |
220 | } | 229 | } |
221 | } | 230 | } |
222 | if (KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | 231 | if (KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { |
223 | QPtrList<Journal> j_list = mCalendar->journals4Date( mDate ); | 232 | Q3PtrList<Journal> j_list = mCalendar->journals4Date( mDate ); |
224 | Journal *j = j_list.first(); | 233 | Journal *j = j_list.first(); |
225 | while ( j ) { | 234 | while ( j ) { |
226 | QString mToolTipText; | 235 | QString mToolTipText; |
227 | if ( !j->summary().isEmpty() ) { | 236 | if ( !j->summary().isEmpty() ) { |
228 | mToolTipText = j->summary().left(30); | 237 | mToolTipText = j->summary().left(30); |
229 | if ( j->summary().length() > 30 ) | 238 | if ( j->summary().length() > 30 ) |
@@ -438,13 +447,13 @@ void KODayMatrix::updateViewTimed() | |||
438 | } | 447 | } |
439 | #if 1 | 448 | #if 1 |
440 | 449 | ||
441 | 450 | ||
442 | int i; | 451 | int i; |
443 | int timeSpan = NUMDAYS-1; | 452 | int timeSpan = NUMDAYS-1; |
444 | QPtrList<Event> events = mCalendar->events(); | 453 | Q3PtrList<Event> events = mCalendar->events(); |
445 | Event *event; | 454 | Event *event; |
446 | QDateTime dt; | 455 | QDateTime dt; |
447 | bool ok; | 456 | bool ok; |
448 | bDays.fill( false); | 457 | bDays.fill( false); |
449 | pDays.fill( false); | 458 | pDays.fill( false); |
450 | hDays.fill( false); | 459 | hDays.fill( false); |
@@ -523,13 +532,13 @@ void KODayMatrix::updateViewTimed() | |||
523 | pDays.setBit(i); | 532 | pDays.setBit(i); |
524 | } | 533 | } |
525 | } | 534 | } |
526 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { | 535 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { |
527 | bDays.fill( false); | 536 | bDays.fill( false); |
528 | // insert due todos | 537 | // insert due todos |
529 | QPtrList<Todo> todos = mCalendar->todos( ); | 538 | Q3PtrList<Todo> todos = mCalendar->todos( ); |
530 | Todo *todo; | 539 | Todo *todo; |
531 | for(todo = todos.first(); todo; todo = todos.next()) { | 540 | for(todo = todos.first(); todo; todo = todos.next()) { |
532 | //insertTodo( todo ); | 541 | //insertTodo( todo ); |
533 | if ( todo->hasDueDate() ) { | 542 | if ( todo->hasDueDate() ) { |
534 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 543 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
535 | if ( day >= 0 && day < timeSpan + 1) { | 544 | if ( day >= 0 && day < timeSpan + 1) { |
@@ -548,13 +557,13 @@ void KODayMatrix::updateViewTimed() | |||
548 | } | 557 | } |
549 | } | 558 | } |
550 | } | 559 | } |
551 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | 560 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { |
552 | bDays.fill( false); | 561 | bDays.fill( false); |
553 | // insert due todos | 562 | // insert due todos |
554 | QPtrList<Journal> todos = mCalendar->journals( ); | 563 | Q3PtrList<Journal> todos = mCalendar->journals( ); |
555 | Journal *todo; | 564 | Journal *todo; |
556 | for(todo = todos.first(); todo; todo = todos.next()) { | 565 | for(todo = todos.first(); todo; todo = todos.next()) { |
557 | int day = mStartDate.daysTo( todo->dtStart().date() ); | 566 | int day = mStartDate.daysTo( todo->dtStart().date() ); |
558 | if ( day >= 0 && day < timeSpan + 1) { | 567 | if ( day >= 0 && day < timeSpan + 1) { |
559 | int i = day; | 568 | int i = day; |
560 | QString holiStr = mHolidays[i]; | 569 | QString holiStr = mHolidays[i]; |
@@ -572,13 +581,13 @@ void KODayMatrix::updateViewTimed() | |||
572 | } | 581 | } |
573 | } | 582 | } |
574 | #else | 583 | #else |
575 | //qDebug("KODayMatrix::updateViewTimed "); | 584 | //qDebug("KODayMatrix::updateViewTimed "); |
576 | for(int i = 0; i < NUMDAYS; i++) { | 585 | for(int i = 0; i < NUMDAYS; i++) { |
577 | // if events are set for the day then remember to draw it bold | 586 | // if events are set for the day then remember to draw it bold |
578 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 587 | Q3PtrList<Event> eventlist = mCalendar->events(days[i]); |
579 | Event *event; | 588 | Event *event; |
580 | int numEvents = eventlist.count(); | 589 | int numEvents = eventlist.count(); |
581 | QString holiStr = ""; | 590 | QString holiStr = ""; |
582 | bDays.clearBit(i); | 591 | bDays.clearBit(i); |
583 | hDays.clearBit(i); | 592 | hDays.clearBit(i); |
584 | eDays.clearBit(i); | 593 | eDays.clearBit(i); |
@@ -672,13 +681,13 @@ void KODayMatrix::updateView(QDate actdate) | |||
672 | void KODayMatrix::updateEvents() | 681 | void KODayMatrix::updateEvents() |
673 | { | 682 | { |
674 | if ( !mCalendar ) return; | 683 | if ( !mCalendar ) return; |
675 | 684 | ||
676 | for( int i = 0; i < NUMDAYS; i++ ) { | 685 | for( int i = 0; i < NUMDAYS; i++ ) { |
677 | // if events are set for the day then remember to draw it bold | 686 | // if events are set for the day then remember to draw it bold |
678 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 687 | Q3PtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
679 | int numEvents = eventlist.count(); | 688 | int numEvents = eventlist.count(); |
680 | Event *event; | 689 | Event *event; |
681 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 690 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
682 | ushort recurType = event->doesRecur(); | 691 | ushort recurType = event->doesRecur(); |
683 | 692 | ||
684 | if ( ( recurType == Recurrence::rDaily && | 693 | if ( ( recurType == Recurrence::rDaily && |
@@ -736,26 +745,26 @@ int KODayMatrix::getDayIndexFrom(int x, int y) | |||
736 | // M O U S E E V E N T H A N D L I N G | 745 | // M O U S E E V E N T H A N D L I N G |
737 | // ---------------------------------------------------------------------------- | 746 | // ---------------------------------------------------------------------------- |
738 | 747 | ||
739 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 748 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
740 | { | 749 | { |
741 | 750 | ||
742 | if ( e->button() == LeftButton ) | 751 | if ( e->button() == Qt::LeftButton ) |
743 | mouseDown = true; | 752 | mouseDown = true; |
744 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 753 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
745 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 754 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
746 | mSelInit = mSelStart; | 755 | mSelInit = mSelStart; |
747 | mSelEnd = mSelStart; | 756 | mSelEnd = mSelStart; |
748 | mRedrawNeeded = true; | 757 | mRedrawNeeded = true; |
749 | repaint(false); | 758 | repaint(false); |
750 | } | 759 | } |
751 | 760 | ||
752 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 761 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
753 | { | 762 | { |
754 | mRedrawNeeded = true; | 763 | mRedrawNeeded = true; |
755 | if ( e->button() == LeftButton ) | 764 | if ( e->button() == Qt::LeftButton ) |
756 | if ( ! mouseDown ) { | 765 | if ( ! mouseDown ) { |
757 | return; | 766 | return; |
758 | } | 767 | } |
759 | else | 768 | else |
760 | mouseDown = false; | 769 | mouseDown = false; |
761 | int tmp = getDayIndexFrom(e->x(), e->y()); | 770 | int tmp = getDayIndexFrom(e->x(), e->y()); |
@@ -1192,26 +1201,26 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) | |||
1192 | p.setPen(mDefaultTextColor); | 1201 | p.setPen(mDefaultTextColor); |
1193 | p.drawRect(0, 0, width(), height()); | 1202 | p.drawRect(0, 0, width(), height()); |
1194 | } else { | 1203 | } else { |
1195 | //qDebug("NO redraw "); | 1204 | //qDebug("NO redraw "); |
1196 | } | 1205 | } |
1197 | 1206 | ||
1198 | bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP); | 1207 | bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,QPainter::CompositionMode_Source); |
1199 | mRedrawNeeded = false; | 1208 | mRedrawNeeded = false; |
1200 | } | 1209 | } |
1201 | 1210 | ||
1202 | // ---------------------------------------------------------------------------- | 1211 | // ---------------------------------------------------------------------------- |
1203 | // R E SI Z E E V E N T H A N D L I N G | 1212 | // R E SI Z E E V E N T H A N D L I N G |
1204 | // ---------------------------------------------------------------------------- | 1213 | // ---------------------------------------------------------------------------- |
1205 | 1214 | ||
1206 | void KODayMatrix::resizeEvent(QResizeEvent * e) | 1215 | void KODayMatrix::resizeEvent(QResizeEvent * e) |
1207 | { | 1216 | { |
1208 | QRect sz = frameRect(); | 1217 | QRect sz = frameRect(); |
1209 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 1218 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
1210 | daysize.setWidth(sz.width() / 7); | 1219 | daysize.setWidth(sz.width() / 7); |
1211 | QFrame::resizeEvent( e ); | 1220 | Q3Frame::resizeEvent( e ); |
1212 | } | 1221 | } |
1213 | 1222 | ||
1214 | QSize KODayMatrix::sizeHint() const | 1223 | QSize KODayMatrix::sizeHint() const |
1215 | { | 1224 | { |
1216 | 1225 | ||
1217 | QFontMetrics fm ( font() ); | 1226 | QFontMetrics fm ( font() ); |