-rw-r--r-- | korganizer/koagendaitem.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index a8e0678..a42d07b 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -52,140 +52,144 @@ extern int globalFlagBlockAgendaItemUpdate; | |||
52 | 52 | ||
53 | 53 | ||
54 | //-------------------------------------------------------------------------- | 54 | //-------------------------------------------------------------------------- |
55 | 55 | ||
56 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 56 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
57 | 57 | ||
58 | //-------------------------------------------------------------------------- | 58 | //-------------------------------------------------------------------------- |
59 | 59 | ||
60 | class KOAgendaItemWhatsThis :public QWhatsThis | 60 | class KOAgendaItemWhatsThis :public QWhatsThis |
61 | { | 61 | { |
62 | public: | 62 | public: |
63 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; | 63 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | virtual QString text( const QPoint& ) | 66 | virtual QString text( const QPoint& ) |
67 | { | 67 | { |
68 | return _view->getWhatsThisText() ; | 68 | return _view->getWhatsThisText() ; |
69 | } | 69 | } |
70 | private: | 70 | private: |
71 | KOAgendaItem * _view; | 71 | KOAgendaItem * _view; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 74 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
75 | const char *name,WFlags) : | 75 | const char *name,WFlags) : |
76 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 76 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
77 | { | 77 | { |
78 | #ifndef DESKTOP_VERSION | 78 | #ifndef DESKTOP_VERSION |
79 | //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 79 | //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
80 | #endif | 80 | #endif |
81 | mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); | 81 | mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); |
82 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 82 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
83 | setWFlags ( wflags); | 83 | setWFlags ( wflags); |
84 | mAllDay = allday; | 84 | mAllDay = allday; |
85 | init ( incidence, qd ); | 85 | init ( incidence, qd ); |
86 | //setMouseTracking(true); | 86 | //setMouseTracking(true); |
87 | //setAcceptDrops(true); | 87 | //setAcceptDrops(true); |
88 | xPaintCoord = -1; | 88 | xPaintCoord = -1; |
89 | yPaintCoord = -1; | 89 | yPaintCoord = -1; |
90 | } | 90 | } |
91 | QString KOAgendaItem::getWhatsThisText() | 91 | QString KOAgendaItem::getWhatsThisText() |
92 | { | 92 | { |
93 | if ( mIncidence ) | 93 | if ( mIncidence ) |
94 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, | 94 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, |
95 | KOPrefs::instance()->mWTshowDetails, | 95 | KOPrefs::instance()->mWTshowDetails, |
96 | KOPrefs::instance()->mWTshowCreated, | 96 | KOPrefs::instance()->mWTshowCreated, |
97 | KOPrefs::instance()->mWTshowChanged); | 97 | KOPrefs::instance()->mWTshowChanged); |
98 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 98 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
99 | } | 99 | } |
100 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | ||
101 | { | ||
102 | mIncidence = incidence; | ||
103 | mDate = qd; | ||
104 | mFirstMultiItem = 0; | ||
105 | mNextMultiItem = 0; | ||
106 | mLastMultiItem = 0; | ||
107 | computeText(); | ||
108 | 100 | ||
109 | if ( (incidence->typeID() == todoID ) && | 101 | void KOAgendaItem::initColor () |
110 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 102 | { |
111 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 103 | if ( (mIncidence->typeID() == todoID ) && |
112 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 104 | ( !((static_cast<Todo*>(mIncidence))->isCompleted()) && |
105 | ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) { | ||
106 | if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date()) | ||
113 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 107 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
114 | else | 108 | else |
115 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 109 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
116 | } | 110 | } |
117 | else { | 111 | else { |
118 | QStringList categories = mIncidence->categories(); | 112 | QStringList categories = mIncidence->categories(); |
119 | QString cat = categories.first(); | 113 | QString cat = categories.first(); |
120 | if (cat.isEmpty()) { | 114 | if (cat.isEmpty()) { |
121 | if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) | 115 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) |
122 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 116 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
123 | else | 117 | else |
124 | mBackgroundColor =KOPrefs::instance()->defaultColor( incidence->calID() ); | 118 | mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() ); |
125 | } else { | 119 | } else { |
126 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 120 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
127 | if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) { | 121 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) { |
128 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 122 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
129 | mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; | 123 | mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; |
130 | } | 124 | } |
131 | } | 125 | } |
132 | 126 | ||
133 | } | 127 | } |
134 | 128 | ||
135 | QColor BackgroundColor ( mBackgroundColor ); | 129 | QColor BackgroundColor ( mBackgroundColor ); |
136 | if ( mIncidence->calID() > 1 ) { | 130 | if ( mIncidence->calID() > 1 ) { |
137 | BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); | 131 | BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); |
138 | } | 132 | } |
139 | mColorGroup = QColorGroup( BackgroundColor.light(), | 133 | mColorGroup = QColorGroup( BackgroundColor.light(), |
140 | BackgroundColor.dark(),BackgroundColor.light(), | 134 | BackgroundColor.dark(),BackgroundColor.light(), |
141 | BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; | 135 | BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; |
142 | setBackgroundColor( mBackgroundColor ); | 136 | setBackgroundColor( mBackgroundColor ); |
143 | mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); | 137 | mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); |
138 | } | ||
139 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | ||
140 | { | ||
141 | mIncidence = incidence; | ||
142 | mDate = qd; | ||
143 | mFirstMultiItem = 0; | ||
144 | mNextMultiItem = 0; | ||
145 | mLastMultiItem = 0; | ||
146 | computeText(); | ||
147 | initColor(); | ||
144 | mConflictItems.clear(); | 148 | mConflictItems.clear(); |
145 | setCellXY(0,0,1); | 149 | setCellXY(0,0,1); |
146 | setCellXWidth(0); | 150 | setCellXWidth(0); |
147 | setSubCell(0); | 151 | setSubCell(0); |
148 | setSubCells(1); | 152 | setSubCells(1); |
149 | setMultiItem(0,0,0); | 153 | setMultiItem(0,0,0); |
150 | startMove(); | 154 | startMove(); |
151 | mSelected = true; | 155 | mSelected = true; |
152 | select(false); | 156 | select(false); |
153 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 157 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
154 | mFontPixelSize = fontinf.height();; | 158 | mFontPixelSize = fontinf.height();; |
155 | hide(); | 159 | hide(); |
156 | xPaintCoord = -1; | 160 | xPaintCoord = -1; |
157 | yPaintCoord = -1; | 161 | yPaintCoord = -1; |
158 | } | 162 | } |
159 | 163 | ||
160 | 164 | ||
161 | KOAgendaItem::~KOAgendaItem() | 165 | KOAgendaItem::~KOAgendaItem() |
162 | { | 166 | { |
163 | #if QT_VERSION >= 0x030000 | 167 | #if QT_VERSION >= 0x030000 |
164 | 168 | ||
165 | #else | 169 | #else |
166 | delete mKOAgendaItemWhatsThis; | 170 | delete mKOAgendaItemWhatsThis; |
167 | #endif | 171 | #endif |
168 | 172 | ||
169 | } | 173 | } |
170 | 174 | ||
171 | void KOAgendaItem::recreateIncidence() | 175 | void KOAgendaItem::recreateIncidence() |
172 | { | 176 | { |
173 | #if 0 | 177 | #if 0 |
174 | Incidence* newInc = mIncidence->clone(); | 178 | Incidence* newInc = mIncidence->clone(); |
175 | newInc->recreate(); | 179 | newInc->recreate(); |
176 | if ( mIncidence->doesRecur() ) { | 180 | if ( mIncidence->doesRecur() ) { |
177 | mIncidence->addExDate( mDate ); | 181 | mIncidence->addExDate( mDate ); |
178 | newInc->recurrence()->unsetRecurs(); | 182 | newInc->recurrence()->unsetRecurs(); |
179 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 183 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
180 | QTime tim = mIncidence->dtStart().time(); | 184 | QTime tim = mIncidence->dtStart().time(); |
181 | newInc->setDtStart( QDateTime(mDate, tim) ); | 185 | newInc->setDtStart( QDateTime(mDate, tim) ); |
182 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 186 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
183 | } | 187 | } |
184 | #endif | 188 | #endif |
185 | mIncidence = mIncidence->recreateCloneException( mDate ); | 189 | mIncidence = mIncidence->recreateCloneException( mDate ); |
186 | } | 190 | } |
187 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 191 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
188 | { | 192 | { |
189 | int size = AGENDA_ICON_SIZE; | 193 | int size = AGENDA_ICON_SIZE; |
190 | 194 | ||
191 | int yOff = 0; | 195 | int yOff = 0; |