-rw-r--r-- | korganizer/koagenda.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 0280c74..c339b57 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -51,24 +51,25 @@ | |||
51 | #include <libkcal/todo.h> | 51 | #include <libkcal/todo.h> |
52 | 52 | ||
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | //extern bool globalFlagBlockPainting; | 57 | //extern bool globalFlagBlockPainting; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | bool KOAgenda::mInvalidPixmap = false; | ||
63 | //////////////////////////////////////////////////////////////////////////// | 64 | //////////////////////////////////////////////////////////////////////////// |
64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
66 | { | 67 | { |
67 | setLineWidth(0); | 68 | setLineWidth(0); |
68 | setMargin(0); | 69 | setMargin(0); |
69 | setBackgroundColor(Qt::red); | 70 | setBackgroundColor(Qt::red); |
70 | minutes = new QTimer(this); | 71 | minutes = new QTimer(this); |
71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
72 | minutes->start(0, true); | 73 | minutes->start(0, true); |
73 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
74 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
@@ -169,24 +170,25 @@ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | |||
169 | { | 170 | { |
170 | 171 | ||
171 | mAllAgendaPopup = 0; | 172 | mAllAgendaPopup = 0; |
172 | mColumns = columns; | 173 | mColumns = columns; |
173 | mRows = rows; | 174 | mRows = rows; |
174 | mGridSpacingY = rowSize; | 175 | mGridSpacingY = rowSize; |
175 | mAllDayMode = false; | 176 | mAllDayMode = false; |
176 | #ifndef DESKTOP_VERSION | 177 | #ifndef DESKTOP_VERSION |
177 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
178 | #endif | 179 | #endif |
179 | mHolidayMask = 0; | 180 | mHolidayMask = 0; |
180 | init(); | 181 | init(); |
182 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); | ||
181 | } | 183 | } |
182 | 184 | ||
183 | /* | 185 | /* |
184 | Create an agenda widget with columns columns and one row. This is used for | 186 | Create an agenda widget with columns columns and one row. This is used for |
185 | all-day events. | 187 | all-day events. |
186 | */ | 188 | */ |
187 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 189 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
188 | QScrollView(parent,name,f) | 190 | QScrollView(parent,name,f) |
189 | { | 191 | { |
190 | mAllAgendaPopup = 0; | 192 | mAllAgendaPopup = 0; |
191 | blockResize = false; | 193 | blockResize = false; |
192 | mColumns = columns; | 194 | mColumns = columns; |
@@ -308,26 +310,42 @@ void KOAgenda::init() | |||
308 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 310 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
309 | SLOT(checkScrollBoundaries(int))); | 311 | SLOT(checkScrollBoundaries(int))); |
310 | 312 | ||
311 | // Create the Marcus Bains line. | 313 | // Create the Marcus Bains line. |
312 | if(mAllDayMode) | 314 | if(mAllDayMode) |
313 | mMarcusBains = 0; | 315 | mMarcusBains = 0; |
314 | else { | 316 | else { |
315 | mMarcusBains = new MarcusBains(this); | 317 | mMarcusBains = new MarcusBains(this); |
316 | addChild(mMarcusBains); | 318 | addChild(mMarcusBains); |
317 | } | 319 | } |
318 | mPopupKind = 0; | 320 | mPopupKind = 0; |
319 | mPopupItem = 0; | 321 | mPopupItem = 0; |
322 | mInvalidPixmap = false; | ||
323 | |||
320 | } | 324 | } |
321 | 325 | ||
326 | void KOAgenda::shrinkPixmap() | ||
327 | { | ||
328 | mPaintPixmap.resize( 20,20); | ||
329 | mInvalidPixmap = true; | ||
330 | } | ||
331 | void KOAgenda::slotContentMove(int,int) | ||
332 | { | ||
333 | if ( mActionType == NOP ) | ||
334 | slotClearSelection(); | ||
335 | if ( mSelectedItem && !mActionItem ) { | ||
336 | deselectItem(); | ||
337 | emit incidenceSelected( 0 ); | ||
338 | } | ||
339 | } | ||
322 | void KOAgenda::clear() | 340 | void KOAgenda::clear() |
323 | { | 341 | { |
324 | KOAgendaItem *item; | 342 | KOAgendaItem *item; |
325 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 343 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
326 | mUnusedItems.append( item ); | 344 | mUnusedItems.append( item ); |
327 | //item->hide(); | 345 | //item->hide(); |
328 | } | 346 | } |
329 | mItems.clear(); | 347 | mItems.clear(); |
330 | mSelectedItem = 0; | 348 | mSelectedItem = 0; |
331 | clearSelection(); | 349 | clearSelection(); |
332 | } | 350 | } |
333 | 351 | ||
@@ -913,24 +931,25 @@ void KOAgenda::performItemAction(QPoint viewportPos) | |||
913 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 931 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
914 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 932 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
915 | if (!moveItem) moveItem = mActionItem; | 933 | if (!moveItem) moveItem = mActionItem; |
916 | while (moveItem) { | 934 | while (moveItem) { |
917 | int dy; | 935 | int dy; |
918 | if (isMultiItem) dy = 0; | 936 | if (isMultiItem) dy = 0; |
919 | else dy = gy - mCurrentCellY; | 937 | else dy = gy - mCurrentCellY; |
920 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 938 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
921 | int x,y; | 939 | int x,y; |
922 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 940 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
923 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 941 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
924 | mGridSpacingY * moveItem->cellHeight()); | 942 | mGridSpacingY * moveItem->cellHeight()); |
943 | moveItem->raise(); | ||
925 | moveChild(moveItem,x,y); | 944 | moveChild(moveItem,x,y); |
926 | moveItem = moveItem->nextMultiItem(); | 945 | moveItem = moveItem->nextMultiItem(); |
927 | } | 946 | } |
928 | } else if (mActionType == RESIZETOP) { | 947 | } else if (mActionType == RESIZETOP) { |
929 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 948 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
930 | mActionItem->expandTop(gy - mCurrentCellY); | 949 | mActionItem->expandTop(gy - mCurrentCellY); |
931 | mActionItem->resize(mActionItem->width(), | 950 | mActionItem->resize(mActionItem->width(), |
932 | mGridSpacingY * mActionItem->cellHeight()); | 951 | mGridSpacingY * mActionItem->cellHeight()); |
933 | int x,y; | 952 | int x,y; |
934 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 953 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
935 | //moveChild(mActionItem,childX(mActionItem),y); | 954 | //moveChild(mActionItem,childX(mActionItem),y); |
936 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 955 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
@@ -1235,24 +1254,31 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | |||
1235 | // for ( item=conflictItems.first(); item != 0; | 1254 | // for ( item=conflictItems.first(); item != 0; |
1236 | // item=conflictItems.next() ) { | 1255 | // item=conflictItems.next() ) { |
1237 | // //item->updateItem(); | 1256 | // //item->updateItem(); |
1238 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1257 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1239 | // } | 1258 | // } |
1240 | // placeItem->updateItem(); | 1259 | // placeItem->updateItem(); |
1241 | } | 1260 | } |
1242 | 1261 | ||
1243 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1262 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1244 | { | 1263 | { |
1245 | if ( globalFlagBlockAgenda ) | 1264 | if ( globalFlagBlockAgenda ) |
1246 | return; | 1265 | return; |
1266 | |||
1267 | if ( mInvalidPixmap ) { | ||
1268 | mInvalidPixmap = false; | ||
1269 | qDebug("InvalidPixmap "); | ||
1270 | QTimer::singleShot( 0, this, SIGNAL( updateViewSignal() )); | ||
1271 | return; | ||
1272 | } | ||
1247 | if ( ! mAllDayMode ) { | 1273 | if ( ! mAllDayMode ) { |
1248 | // currently not working for | 1274 | // currently not working for |
1249 | 1275 | ||
1250 | //qDebug("KOAgenda::drawContents "); | 1276 | //qDebug("KOAgenda::drawContents "); |
1251 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1277 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1252 | ;//drawContentsToPainter(); | 1278 | ;//drawContentsToPainter(); |
1253 | 1279 | ||
1254 | QPaintDevice* pd = p->device(); | 1280 | QPaintDevice* pd = p->device(); |
1255 | p->end(); | 1281 | p->end(); |
1256 | int vx, vy; | 1282 | int vx, vy; |
1257 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1283 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1258 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1284 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
@@ -1907,31 +1933,31 @@ void KOAgenda::computeSizes() | |||
1907 | item->resize(subCellWidth,item->height()); | 1933 | item->resize(subCellWidth,item->height()); |
1908 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1934 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1909 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1935 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1910 | item->cellX() * mGridSpacingX) + | 1936 | item->cellX() * mGridSpacingX) + |
1911 | item->subCell() * subCellWidth,childY(item)); | 1937 | item->subCell() * subCellWidth,childY(item)); |
1912 | } | 1938 | } |
1913 | } | 1939 | } |
1914 | int cw = contentsWidth(); | 1940 | int cw = contentsWidth(); |
1915 | int ch = contentsHeight(); | 1941 | int ch = contentsHeight(); |
1916 | if ( mAllDayMode ) { | 1942 | if ( mAllDayMode ) { |
1917 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1943 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1918 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { | 1944 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { |
1919 | //qDebug("paintPixAll->resize "); | 1945 | qDebug("paintPixAll->resize "); |
1920 | paintPixAll->resize( cw, ch ); | 1946 | paintPixAll->resize( cw, ch ); |
1921 | } | 1947 | } |
1922 | } else { | 1948 | } else { |
1923 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1949 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1924 | if ( paintPix->width() < cw || paintPix->height() < ch ) { | 1950 | if ( paintPix->width() < cw || paintPix->height() < ch ) { |
1925 | //qDebug("paintPix->resize "); | 1951 | qDebug("paintPix->resize "); |
1926 | paintPix->resize( cw , ch ); | 1952 | paintPix->resize( cw , ch ); |
1927 | } | 1953 | } |
1928 | } | 1954 | } |
1929 | 1955 | ||
1930 | checkScrollBoundaries(); | 1956 | checkScrollBoundaries(); |
1931 | marcus_bains(); | 1957 | marcus_bains(); |
1932 | drawContentsToPainter(); | 1958 | drawContentsToPainter(); |
1933 | viewport()->repaint(false); | 1959 | viewport()->repaint(false); |
1934 | } | 1960 | } |
1935 | 1961 | ||
1936 | void KOAgenda::scrollUp() | 1962 | void KOAgenda::scrollUp() |
1937 | { | 1963 | { |