author | zautrix <zautrix> | 2005-02-23 10:58:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-23 10:58:09 (UTC) |
commit | 36704cb63582c161d2ab5c63e66ee63bbf3b865f (patch) (unidiff) | |
tree | 1541d63b50f7bc50278c6fed164f4b5228f18362 /korganizer | |
parent | 87a2f1a301beae2a8550c340348741c69f0ac1dd (diff) | |
download | kdepimpi-36704cb63582c161d2ab5c63e66ee63bbf3b865f.zip kdepimpi-36704cb63582c161d2ab5c63e66ee63bbf3b865f.tar.gz kdepimpi-36704cb63582c161d2ab5c63e66ee63bbf3b865f.tar.bz2 |
fixed layout problem
-rw-r--r-- | korganizer/koagenda.cpp | 31 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 1 |
2 files changed, 30 insertions, 2 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index a72e470..195b1fa 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1034,117 +1034,144 @@ void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | |||
1034 | place spans. When the sub cell width change of one of this items affects a | 1034 | place spans. When the sub cell width change of one of this items affects a |
1035 | cell, where other items are, which do not overlap in Y with the item to place, | 1035 | cell, where other items are, which do not overlap in Y with the item to place, |
1036 | the display gets corrupted, although the corruption looks quite nice. | 1036 | the display gets corrupted, although the corruption looks quite nice. |
1037 | */ | 1037 | */ |
1038 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1038 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1039 | { | 1039 | { |
1040 | 1040 | ||
1041 | QPtrList<KOAgendaItem> conflictItems; | 1041 | QPtrList<KOAgendaItem> conflictItems; |
1042 | int maxSubCells = 0; | 1042 | int maxSubCells = 0; |
1043 | QIntDict<KOAgendaItem> subCellDict(5); | 1043 | QIntDict<KOAgendaItem> subCellDict(5); |
1044 | 1044 | ||
1045 | KOAgendaItem *item; | 1045 | KOAgendaItem *item; |
1046 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1046 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1047 | if (item != placeItem) { | 1047 | if (item != placeItem) { |
1048 | if (placeItem->cellX() <= item->cellXWidth() && | 1048 | if (placeItem->cellX() <= item->cellXWidth() && |
1049 | placeItem->cellXWidth() >= item->cellX()) { | 1049 | placeItem->cellXWidth() >= item->cellX()) { |
1050 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1050 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1051 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1051 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1052 | conflictItems.append(item); | 1052 | conflictItems.append(item); |
1053 | if (item->subCells() > maxSubCells) | 1053 | if (item->subCells() > maxSubCells) |
1054 | maxSubCells = item->subCells(); | 1054 | maxSubCells = item->subCells(); |
1055 | subCellDict.insert(item->subCell(),item); | 1055 | subCellDict.insert(item->subCell(),item); |
1056 | } | 1056 | } |
1057 | } | 1057 | } |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | if (conflictItems.count() > 0) { | 1061 | if (conflictItems.count() > 0) { |
1062 | // Look for unused sub cell and insert item | 1062 | // Look for unused sub cell and insert item |
1063 | int i; | 1063 | int i; |
1064 | for(i=0;i<maxSubCells;++i) { | 1064 | for(i=0;i<maxSubCells;++i) { |
1065 | if (!subCellDict.find(i)) { | 1065 | if (!subCellDict.find(i)) { |
1066 | placeItem->setSubCell(i); | 1066 | placeItem->setSubCell(i); |
1067 | break; | 1067 | break; |
1068 | } | 1068 | } |
1069 | } | 1069 | } |
1070 | if (i == maxSubCells) { | 1070 | if (i == maxSubCells) { |
1071 | placeItem->setSubCell(maxSubCells); | 1071 | placeItem->setSubCell(maxSubCells); |
1072 | maxSubCells++; // add new item to number of sub cells | 1072 | maxSubCells++; // add new item to number of sub cells |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | // Prepare for sub cell geometry adjustment | 1075 | // Prepare for sub cell geometry adjustment |
1076 | int newSubCellWidth; | 1076 | int newSubCellWidth; |
1077 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1077 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1078 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1078 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1079 | conflictItems.append(placeItem); | 1079 | conflictItems.append(placeItem); |
1080 | 1080 | ||
1081 | 1081 | ||
1082 | // Adjust sub cell geometry of all items | 1082 | // Adjust sub cell geometry of all direct conflict items |
1083 | for ( item=conflictItems.first(); item != 0; | 1083 | for ( item=conflictItems.first(); item != 0; |
1084 | item=conflictItems.next() ) { | 1084 | item=conflictItems.next() ) { |
1085 | item->setSubCells(maxSubCells); | 1085 | item->setSubCells(maxSubCells); |
1086 | if (mAllDayMode) { | 1086 | if (mAllDayMode) { |
1087 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1087 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1088 | } else { | 1088 | } else { |
1089 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1089 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1090 | } | 1090 | } |
1091 | int x,y; | 1091 | int x,y; |
1092 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1092 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1093 | if (mAllDayMode) { | 1093 | if (mAllDayMode) { |
1094 | y += item->subCell() * newSubCellWidth; | 1094 | y += item->subCell() * newSubCellWidth; |
1095 | } else { | 1095 | } else { |
1096 | x += item->subCell() * newSubCellWidth; | 1096 | x += item->subCell() * newSubCellWidth; |
1097 | } | 1097 | } |
1098 | moveChild(item,x,y); | 1098 | moveChild(item,x,y); |
1099 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1099 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1100 | //item->updateItem(); | 1100 | //item->updateItem(); |
1101 | } | 1101 | } |
1102 | 1102 | // Adjust sub cell geometry of all conflict items of all conflict items | |
1103 | for ( item=conflictItems.first(); item != 0; | ||
1104 | item=conflictItems.next() ) { | ||
1105 | if ( placeItem != item ) { | ||
1106 | KOAgendaItem *item2; | ||
1107 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | ||
1108 | for ( item2=conflictItems2.first(); item2 != 0; | ||
1109 | item2=conflictItems2.next() ) { | ||
1110 | if ( item2->subCells() != maxSubCells) { | ||
1111 | item2->setSubCells(maxSubCells); | ||
1112 | if (mAllDayMode) { | ||
1113 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | ||
1114 | } else { | ||
1115 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | ||
1116 | } | ||
1117 | int x,y; | ||
1118 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | ||
1119 | if (mAllDayMode) { | ||
1120 | y += item2->subCell() * newSubCellWidth; | ||
1121 | } else { | ||
1122 | x += item2->subCell() * newSubCellWidth; | ||
1123 | } | ||
1124 | moveChild(item2,x,y); | ||
1125 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | ||
1126 | } | ||
1127 | } | ||
1128 | } | ||
1129 | } | ||
1103 | } else { | 1130 | } else { |
1104 | placeItem->setSubCell(0); | 1131 | placeItem->setSubCell(0); |
1105 | placeItem->setSubCells(1); | 1132 | placeItem->setSubCells(1); |
1106 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1133 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1107 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1134 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1108 | int x,y; | 1135 | int x,y; |
1109 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1136 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1110 | moveChild(placeItem,x,y); | 1137 | moveChild(placeItem,x,y); |
1111 | } | 1138 | } |
1112 | placeItem->setConflictItems(conflictItems); | 1139 | placeItem->setConflictItems(conflictItems); |
1113 | // for ( item=conflictItems.first(); item != 0; | 1140 | // for ( item=conflictItems.first(); item != 0; |
1114 | // item=conflictItems.next() ) { | 1141 | // item=conflictItems.next() ) { |
1115 | // //item->updateItem(); | 1142 | // //item->updateItem(); |
1116 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1143 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1117 | // } | 1144 | // } |
1118 | // placeItem->updateItem(); | 1145 | // placeItem->updateItem(); |
1119 | } | 1146 | } |
1120 | 1147 | ||
1121 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1148 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1122 | { | 1149 | { |
1123 | if ( globalFlagBlockAgenda ) | 1150 | if ( globalFlagBlockAgenda ) |
1124 | return; | 1151 | return; |
1125 | //qDebug("KOAgenda::drawContents "); | 1152 | //qDebug("KOAgenda::drawContents "); |
1126 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1153 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1127 | ;//drawContentsToPainter(); | 1154 | ;//drawContentsToPainter(); |
1128 | 1155 | ||
1129 | QPaintDevice* pd = p->device(); | 1156 | QPaintDevice* pd = p->device(); |
1130 | p->end(); | 1157 | p->end(); |
1131 | int vx, vy; | 1158 | int vx, vy; |
1132 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1159 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1133 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1160 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1134 | mSelectionCellX * mGridSpacingX; | 1161 | mSelectionCellX * mGridSpacingX; |
1135 | contentsToViewport ( cx, cy, vx,vy); | 1162 | contentsToViewport ( cx, cy, vx,vy); |
1136 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1163 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1137 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1164 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1138 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1165 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1139 | 1166 | ||
1140 | if ( mSelectionHeight > 0 ) { | 1167 | if ( mSelectionHeight > 0 ) { |
1141 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1168 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1142 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1169 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1143 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1170 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1144 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1171 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1145 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1172 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1146 | } | 1173 | } |
1147 | } | 1174 | } |
1148 | //qDebug("btbl "); | 1175 | //qDebug("btbl "); |
1149 | p->begin( pd ); | 1176 | p->begin( pd ); |
1150 | //qDebug("end "); | 1177 | //qDebug("end "); |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index d0a7b07..38bd93a 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -90,96 +90,97 @@ KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool | |||
90 | QString KOAgendaItem::getWhatsThisText() | 90 | QString 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, | 94 | KOPrefs::instance()->mWTshowDetails, |
95 | KOPrefs::instance()->mWTshowCreated, | 95 | KOPrefs::instance()->mWTshowCreated, |
96 | KOPrefs::instance()->mWTshowChanged); | 96 | KOPrefs::instance()->mWTshowChanged); |
97 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 97 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
98 | } | 98 | } |
99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
100 | { | 100 | { |
101 | mIncidence = incidence; | 101 | mIncidence = incidence; |
102 | mDate = qd; | 102 | mDate = qd; |
103 | mFirstMultiItem = 0; | 103 | mFirstMultiItem = 0; |
104 | mNextMultiItem = 0; | 104 | mNextMultiItem = 0; |
105 | mLastMultiItem = 0; | 105 | mLastMultiItem = 0; |
106 | computeText(); | 106 | computeText(); |
107 | 107 | ||
108 | if ( (incidence->type() == "Todo") && | 108 | if ( (incidence->type() == "Todo") && |
109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && |
110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) |
112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
113 | else | 113 | else |
114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
115 | } | 115 | } |
116 | else { | 116 | else { |
117 | QStringList categories = mIncidence->categories(); | 117 | QStringList categories = mIncidence->categories(); |
118 | QString cat = categories.first(); | 118 | QString cat = categories.first(); |
119 | if (cat.isEmpty()) { | 119 | if (cat.isEmpty()) { |
120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) | 120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) |
121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
122 | else | 122 | else |
123 | mBackgroundColor =KOPrefs::instance()->mEventColor; | 123 | mBackgroundColor =KOPrefs::instance()->mEventColor; |
124 | } else { | 124 | } else { |
125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { | 126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { |
127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | } | 132 | } |
133 | mColorGroup = QColorGroup( mBackgroundColor.light(), | 133 | mColorGroup = QColorGroup( mBackgroundColor.light(), |
134 | mBackgroundColor.dark(),mBackgroundColor.light(), | 134 | mBackgroundColor.dark(),mBackgroundColor.light(), |
135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; | 135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; |
136 | setBackgroundColor( mBackgroundColor ); | 136 | setBackgroundColor( mBackgroundColor ); |
137 | 137 | ||
138 | mConflictItems.clear(); | ||
138 | setCellXY(0,0,1); | 139 | setCellXY(0,0,1); |
139 | setCellXWidth(0); | 140 | setCellXWidth(0); |
140 | setSubCell(0); | 141 | setSubCell(0); |
141 | setSubCells(1); | 142 | setSubCells(1); |
142 | setMultiItem(0,0,0); | 143 | setMultiItem(0,0,0); |
143 | startMove(); | 144 | startMove(); |
144 | mSelected = true; | 145 | mSelected = true; |
145 | select(false); | 146 | select(false); |
146 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 147 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
147 | mFontPixelSize = fontinf.height();; | 148 | mFontPixelSize = fontinf.height();; |
148 | hide(); | 149 | hide(); |
149 | xPaintCoord = -1; | 150 | xPaintCoord = -1; |
150 | yPaintCoord = -1; | 151 | yPaintCoord = -1; |
151 | } | 152 | } |
152 | 153 | ||
153 | 154 | ||
154 | KOAgendaItem::~KOAgendaItem() | 155 | KOAgendaItem::~KOAgendaItem() |
155 | { | 156 | { |
156 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 157 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
157 | 158 | ||
158 | } | 159 | } |
159 | 160 | ||
160 | void KOAgendaItem::recreateIncidence() | 161 | void KOAgendaItem::recreateIncidence() |
161 | { | 162 | { |
162 | #if 0 | 163 | #if 0 |
163 | Incidence* newInc = mIncidence->clone(); | 164 | Incidence* newInc = mIncidence->clone(); |
164 | newInc->recreate(); | 165 | newInc->recreate(); |
165 | if ( mIncidence->doesRecur() ) { | 166 | if ( mIncidence->doesRecur() ) { |
166 | mIncidence->addExDate( mDate ); | 167 | mIncidence->addExDate( mDate ); |
167 | newInc->recurrence()->unsetRecurs(); | 168 | newInc->recurrence()->unsetRecurs(); |
168 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 169 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
169 | QTime tim = mIncidence->dtStart().time(); | 170 | QTime tim = mIncidence->dtStart().time(); |
170 | newInc->setDtStart( QDateTime(mDate, tim) ); | 171 | newInc->setDtStart( QDateTime(mDate, tim) ); |
171 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 172 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
172 | } | 173 | } |
173 | #endif | 174 | #endif |
174 | mIncidence = mIncidence->recreateCloneException( mDate ); | 175 | mIncidence = mIncidence->recreateCloneException( mDate ); |
175 | } | 176 | } |
176 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 177 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
177 | { | 178 | { |
178 | int size = AGENDA_ICON_SIZE; | 179 | int size = AGENDA_ICON_SIZE; |
179 | 180 | ||
180 | int yOff = 0; | 181 | int yOff = 0; |
181 | int xOff = 0; | 182 | int xOff = 0; |
182 | int x = pos().x() +3; | 183 | int x = pos().x() +3; |
183 | int y; | 184 | int y; |
184 | if ( mAllDay ) | 185 | if ( mAllDay ) |
185 | y = pos().y()+3; | 186 | y = pos().y()+3; |