-rw-r--r-- | korganizer/koagenda.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 662576f..92c1cd6 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -64,49 +64,49 @@ extern int globalFlagBlockStartup; | |||
64 | //////////////////////////////////////////////////////////////////////////// | 64 | //////////////////////////////////////////////////////////////////////////// |
65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
67 | { | 67 | { |
68 | setLineWidth(0); | 68 | setLineWidth(0); |
69 | setMargin(0); | 69 | setMargin(0); |
70 | setBackgroundColor(Qt::red); | 70 | setBackgroundColor(Qt::red); |
71 | minutes = new QTimer(this); | 71 | minutes = new QTimer(this); |
72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
73 | minutes->start(0, true); | 73 | minutes->start(0, true); |
74 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
76 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
77 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
78 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
79 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
80 | 80 | ||
81 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
82 | 82 | ||
83 | oldToday = -1; | 83 | oldToday = -1; |
84 | } | 84 | } |
85 | 85 | ||
86 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
87 | { | 87 | { |
88 | delete minutes; | 88 | //delete minutes; |
89 | } | 89 | } |
90 | 90 | ||
91 | int MarcusBains::todayColumn() | 91 | int MarcusBains::todayColumn() |
92 | { | 92 | { |
93 | QDate currentDate = QDate::currentDate(); | 93 | QDate currentDate = QDate::currentDate(); |
94 | 94 | ||
95 | DateList dateList = agenda->dateList(); | 95 | DateList dateList = agenda->dateList(); |
96 | DateList::ConstIterator it; | 96 | DateList::ConstIterator it; |
97 | int col = 0; | 97 | int col = 0; |
98 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 98 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
99 | if((*it) == currentDate) | 99 | if((*it) == currentDate) |
100 | return KOGlobals::self()->reverseLayout() ? | 100 | return KOGlobals::self()->reverseLayout() ? |
101 | agenda->columns() - 1 - col : col; | 101 | agenda->columns() - 1 - col : col; |
102 | ++col; | 102 | ++col; |
103 | } | 103 | } |
104 | 104 | ||
105 | return -1; | 105 | return -1; |
106 | } | 106 | } |
107 | void MarcusBains::updateLoc() | 107 | void MarcusBains::updateLoc() |
108 | { | 108 | { |
109 | updateLocation(); | 109 | updateLocation(); |
110 | } | 110 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 111 | void MarcusBains::updateLocation(bool recalculate) |
112 | { | 112 | { |
@@ -130,52 +130,53 @@ void MarcusBains::updateLocation(bool recalculate) | |||
130 | hide(); mTimeBox->hide(); | 130 | hide(); mTimeBox->hide(); |
131 | return; | 131 | return; |
132 | } else { | 132 | } else { |
133 | show(); mTimeBox->show(); | 133 | show(); mTimeBox->show(); |
134 | } | 134 | } |
135 | 135 | ||
136 | if(recalculate) | 136 | if(recalculate) |
137 | setFixedSize(agenda->gridSpacingX(),1); | 137 | setFixedSize(agenda->gridSpacingX(),1); |
138 | agenda->moveChild(this, x, y); | 138 | agenda->moveChild(this, x, y); |
139 | raise(); | 139 | raise(); |
140 | 140 | ||
141 | if(recalculate) | 141 | if(recalculate) |
142 | //mTimeBox->setFont(QFont("helvetica",10)); | 142 | //mTimeBox->setFont(QFont("helvetica",10)); |
143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
144 | 144 | ||
145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
146 | mTimeBox->adjustSize(); | 146 | mTimeBox->adjustSize(); |
147 | // the -2 below is there because there is a bug in this program | 147 | // the -2 below is there because there is a bug in this program |
148 | // somewhere, where the last column of this widget is a few pixels | 148 | // somewhere, where the last column of this widget is a few pixels |
149 | // narrower than the other columns. | 149 | // narrower than the other columns. |
150 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 150 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
151 | agenda->moveChild(mTimeBox, | 151 | agenda->moveChild(mTimeBox, |
152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
153 | y-mTimeBox->height()); | 153 | y-mTimeBox->height()); |
154 | |||
155 | mTimeBox->raise(); | 154 | mTimeBox->raise(); |
156 | //mTimeBox->setAutoMask(true); | 155 | //mTimeBox->setAutoMask(true); |
157 | minutes->start(5000,true); | 156 | int secs = QTime::currentTime().second(); |
157 | qDebug("second %d ", secs ); | ||
158 | minutes->start( (60 - secs +1)*1000 ,true); | ||
158 | } | 159 | } |
159 | 160 | ||
160 | 161 | ||
161 | //////////////////////////////////////////////////////////////////////////// | 162 | //////////////////////////////////////////////////////////////////////////// |
162 | 163 | ||
163 | 164 | ||
164 | /* | 165 | /* |
165 | Create an agenda widget with rows rows and columns columns. | 166 | Create an agenda widget with rows rows and columns columns. |
166 | */ | 167 | */ |
167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 168 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
168 | const char *name,WFlags f) : | 169 | const char *name,WFlags f) : |
169 | QScrollView(parent,name,f) | 170 | QScrollView(parent,name,f) |
170 | { | 171 | { |
171 | 172 | ||
172 | mAllAgendaPopup = 0; | 173 | mAllAgendaPopup = 0; |
173 | mColumns = columns; | 174 | mColumns = columns; |
174 | mRows = rows; | 175 | mRows = rows; |
175 | mGridSpacingY = rowSize; | 176 | mGridSpacingY = rowSize; |
176 | mAllDayMode = false; | 177 | mAllDayMode = false; |
177 | #ifndef DESKTOP_VERSION | 178 | #ifndef DESKTOP_VERSION |
178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 179 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
179 | #endif | 180 | #endif |
180 | mHolidayMask = 0; | 181 | mHolidayMask = 0; |
181 | init(); | 182 | init(); |
@@ -421,49 +422,49 @@ void KOAgenda::popupMenu() | |||
421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 422 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
422 | mNewItemPopup->installEventFilter( this ); | 423 | mNewItemPopup->installEventFilter( this ); |
423 | mNewItemPopup->popup( mPopupPos); | 424 | mNewItemPopup->popup( mPopupPos); |
424 | 425 | ||
425 | } | 426 | } |
426 | mLeftMouseDown = false; | 427 | mLeftMouseDown = false; |
427 | mPopupItem = 0; | 428 | mPopupItem = 0; |
428 | mPopupKind = 0; | 429 | mPopupKind = 0; |
429 | } | 430 | } |
430 | void KOAgenda::categoryChanged(Incidence * inc) | 431 | void KOAgenda::categoryChanged(Incidence * inc) |
431 | { | 432 | { |
432 | KOAgendaItem *item; | 433 | KOAgendaItem *item; |
433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 434 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
434 | if ( item->incidence() == inc ) { | 435 | if ( item->incidence() == inc ) { |
435 | item->initColor (); | 436 | item->initColor (); |
436 | item->updateItem(); | 437 | item->updateItem(); |
437 | } | 438 | } |
438 | } | 439 | } |
439 | } | 440 | } |
440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 441 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
441 | { | 442 | { |
442 | 443 | ||
443 | if ( mInvalidPixmap ) { | 444 | if ( mInvalidPixmap ) { |
444 | mInvalidPixmap = false; | 445 | mInvalidPixmap = false; |
445 | qDebug("InvalidPixmap "); | 446 | qDebug("KO: Upsizing Pixmaps "); |
446 | computeSizes(); | 447 | computeSizes(); |
447 | emit updateViewSignal(); | 448 | emit updateViewSignal(); |
448 | return true; | 449 | return true; |
449 | } | 450 | } |
450 | emit sendPing(); | 451 | emit sendPing(); |
451 | static int startX = 0; | 452 | static int startX = 0; |
452 | static int startY = 0; | 453 | static int startY = 0; |
453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 454 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
454 | static bool blockMoving = true; | 455 | static bool blockMoving = true; |
455 | 456 | ||
456 | //qDebug("KOAgenda::eventFilter_mous "); | 457 | //qDebug("KOAgenda::eventFilter_mous "); |
457 | if ( object == mNewItemPopup ) { | 458 | if ( object == mNewItemPopup ) { |
458 | //qDebug("mNewItemPopup "); | 459 | //qDebug("mNewItemPopup "); |
459 | if ( me->type() == QEvent::MouseButtonRelease ) { | 460 | if ( me->type() == QEvent::MouseButtonRelease ) { |
460 | mNewItemPopup->removeEventFilter( this ); | 461 | mNewItemPopup->removeEventFilter( this ); |
461 | int dX = me->globalPos().x() - mPopupPos.x();; | 462 | int dX = me->globalPos().x() - mPopupPos.x();; |
462 | if ( dX < 0 ) | 463 | if ( dX < 0 ) |
463 | dX = -dX; | 464 | dX = -dX; |
464 | int dY = me->globalPos().y() - mPopupPos.y(); | 465 | int dY = me->globalPos().y() - mPopupPos.y(); |
465 | if ( dY < 0 ) | 466 | if ( dY < 0 ) |
466 | dY = -dY; | 467 | dY = -dY; |
467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 468 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
468 | mNewItemPopup->hide(); | 469 | mNewItemPopup->hide(); |
469 | } | 470 | } |
@@ -1255,49 +1256,49 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | |||
1255 | placeItem->setSubCell(0); | 1256 | placeItem->setSubCell(0); |
1256 | placeItem->setSubCells(1); | 1257 | placeItem->setSubCells(1); |
1257 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1258 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1258 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1259 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1259 | int x,y; | 1260 | int x,y; |
1260 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1261 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1261 | moveChild(placeItem,x,y); | 1262 | moveChild(placeItem,x,y); |
1262 | } | 1263 | } |
1263 | placeItem->setConflictItems(conflictItems); | 1264 | placeItem->setConflictItems(conflictItems); |
1264 | // for ( item=conflictItems.first(); item != 0; | 1265 | // for ( item=conflictItems.first(); item != 0; |
1265 | // item=conflictItems.next() ) { | 1266 | // item=conflictItems.next() ) { |
1266 | // //item->updateItem(); | 1267 | // //item->updateItem(); |
1267 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1268 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1268 | // } | 1269 | // } |
1269 | // placeItem->updateItem(); | 1270 | // placeItem->updateItem(); |
1270 | } | 1271 | } |
1271 | 1272 | ||
1272 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1273 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1273 | { | 1274 | { |
1274 | if ( globalFlagBlockAgenda ) | 1275 | if ( globalFlagBlockAgenda ) |
1275 | return; | 1276 | return; |
1276 | 1277 | ||
1277 | if ( mInvalidPixmap ) { | 1278 | if ( mInvalidPixmap ) { |
1278 | mInvalidPixmap = false; | 1279 | mInvalidPixmap = false; |
1279 | qDebug("InvalidPixmap "); | 1280 | qDebug("KO: Upsizing Pixmaps "); |
1280 | computeSizes(); | 1281 | computeSizes(); |
1281 | emit updateViewSignal(); | 1282 | emit updateViewSignal(); |
1282 | return; | 1283 | return; |
1283 | } | 1284 | } |
1284 | if ( ! mAllDayMode ) { | 1285 | if ( ! mAllDayMode ) { |
1285 | // currently not working for | 1286 | // currently not working for |
1286 | 1287 | ||
1287 | //qDebug("KOAgenda::drawContents "); | 1288 | //qDebug("KOAgenda::drawContents "); |
1288 | #if 0 | 1289 | #if 0 |
1289 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1290 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1290 | qDebug("WAU "); | 1291 | qDebug("WAU "); |
1291 | drawContentsToPainter(); | 1292 | drawContentsToPainter(); |
1292 | } | 1293 | } |
1293 | #endif | 1294 | #endif |
1294 | QPaintDevice* pd = p->device(); | 1295 | QPaintDevice* pd = p->device(); |
1295 | p->end(); | 1296 | p->end(); |
1296 | int vx, vy; | 1297 | int vx, vy; |
1297 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1298 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1298 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1299 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1299 | mSelectionCellX * mGridSpacingX; | 1300 | mSelectionCellX * mGridSpacingX; |
1300 | contentsToViewport ( cx, cy, vx,vy); | 1301 | contentsToViewport ( cx, cy, vx,vy); |
1301 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1302 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1302 | 1303 | ||
1303 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1304 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
@@ -1396,49 +1397,49 @@ void KOAgenda::finishUpdate() | |||
1396 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1397 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1397 | if (mAllDayMode) { | 1398 | if (mAllDayMode) { |
1398 | y += item->subCell() * newSubCellWidth; | 1399 | y += item->subCell() * newSubCellWidth; |
1399 | } else { | 1400 | } else { |
1400 | x += item->subCell() * newSubCellWidth; | 1401 | x += item->subCell() * newSubCellWidth; |
1401 | } | 1402 | } |
1402 | moveChild(item,x,y); | 1403 | moveChild(item,x,y); |
1403 | } | 1404 | } |
1404 | } | 1405 | } |
1405 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1406 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1406 | if ( !item->isVisible() ) | 1407 | if ( !item->isVisible() ) |
1407 | item->show(); | 1408 | item->show(); |
1408 | 1409 | ||
1409 | } | 1410 | } |
1410 | globalFlagBlockAgendaItemUpdate = 0; | 1411 | globalFlagBlockAgendaItemUpdate = 0; |
1411 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1412 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1412 | item->repaintMe( ); | 1413 | item->repaintMe( ); |
1413 | } | 1414 | } |
1414 | globalFlagBlockAgendaItemUpdate = 1; | 1415 | globalFlagBlockAgendaItemUpdate = 1; |
1415 | qApp->processEvents(); | 1416 | qApp->processEvents(); |
1416 | globalFlagBlockAgendaItemPaint = 0; | 1417 | globalFlagBlockAgendaItemPaint = 0; |
1417 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1418 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1418 | item->repaint( false ); | 1419 | item->repaint( false ); |
1419 | } | 1420 | } |
1420 | 1421 | marcus_bains(); | |
1421 | } | 1422 | } |
1422 | 1423 | ||
1423 | /* | 1424 | /* |
1424 | Draw grid in the background of the agenda. | 1425 | Draw grid in the background of the agenda. |
1425 | */ | 1426 | */ |
1426 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1427 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1427 | { | 1428 | { |
1428 | 1429 | ||
1429 | 1430 | ||
1430 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1431 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1431 | return; | 1432 | return; |
1432 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1433 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1433 | return; | 1434 | return; |
1434 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1435 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1435 | if ( ch < 1 ) | 1436 | if ( ch < 1 ) |
1436 | ch = 1; | 1437 | ch = 1; |
1437 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1438 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1438 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1439 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1439 | } | 1440 | } |
1440 | mCurPixWid = contentsWidth(); | 1441 | mCurPixWid = contentsWidth(); |
1441 | mCurPixHei = ch; | 1442 | mCurPixHei = ch; |
1442 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { | 1443 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { |
1443 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); | 1444 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); |
1444 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1445 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
@@ -1779,49 +1780,48 @@ KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int | |||
1779 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); | 1780 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1780 | return 0; | 1781 | return 0; |
1781 | } | 1782 | } |
1782 | 1783 | ||
1783 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1784 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1784 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1785 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1785 | 1786 | ||
1786 | int YSize = YBottom - YTop + 1; | 1787 | int YSize = YBottom - YTop + 1; |
1787 | if (YSize < 0) { | 1788 | if (YSize < 0) { |
1788 | YSize = 1; | 1789 | YSize = 1; |
1789 | } | 1790 | } |
1790 | int iheight = mGridSpacingY * YSize; | 1791 | int iheight = mGridSpacingY * YSize; |
1791 | 1792 | ||
1792 | agendaItem->resize(mGridSpacingX,iheight ); | 1793 | agendaItem->resize(mGridSpacingX,iheight ); |
1793 | agendaItem->setCellXY(X,YTop,YBottom); | 1794 | agendaItem->setCellXY(X,YTop,YBottom); |
1794 | agendaItem->setCellXWidth(X); | 1795 | agendaItem->setCellXWidth(X); |
1795 | 1796 | ||
1796 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1797 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1797 | mItems.append(agendaItem); | 1798 | mItems.append(agendaItem); |
1798 | 1799 | ||
1799 | placeSubCells(agendaItem); | 1800 | placeSubCells(agendaItem); |
1800 | 1801 | ||
1801 | //agendaItem->show(); | 1802 | //agendaItem->show(); |
1802 | 1803 | ||
1803 | marcus_bains(); | ||
1804 | 1804 | ||
1805 | return agendaItem; | 1805 | return agendaItem; |
1806 | } | 1806 | } |
1807 | 1807 | ||
1808 | 1808 | ||
1809 | /* | 1809 | /* |
1810 | Insert all-day KOAgendaItem into agenda. | 1810 | Insert all-day KOAgendaItem into agenda. |
1811 | */ | 1811 | */ |
1812 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1812 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1813 | { | 1813 | { |
1814 | if (!mAllDayMode) { | 1814 | if (!mAllDayMode) { |
1815 | return 0; | 1815 | return 0; |
1816 | } | 1816 | } |
1817 | 1817 | ||
1818 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1818 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1819 | 1819 | ||
1820 | agendaItem->setCellXY(XBegin,0,0); | 1820 | agendaItem->setCellXY(XBegin,0,0); |
1821 | agendaItem->setCellXWidth(XEnd); | 1821 | agendaItem->setCellXWidth(XEnd); |
1822 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1822 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1823 | 1823 | ||
1824 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1824 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1825 | mItems.append(agendaItem); | 1825 | mItems.append(agendaItem); |
1826 | 1826 | ||
1827 | placeSubCells(agendaItem); | 1827 | placeSubCells(agendaItem); |
@@ -1852,50 +1852,48 @@ void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | |||
1852 | if (cellX == XEnd) cellYBottom = YBottom; | 1852 | if (cellX == XEnd) cellYBottom = YBottom; |
1853 | else cellYBottom = rows() - 1; | 1853 | else cellYBottom = rows() - 1; |
1854 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1854 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1855 | newtext.append(event->summary()); | 1855 | newtext.append(event->summary()); |
1856 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1856 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1857 | current->setText(newtext); | 1857 | current->setText(newtext); |
1858 | multiItems.append(current); | 1858 | multiItems.append(current); |
1859 | } | 1859 | } |
1860 | 1860 | ||
1861 | KOAgendaItem *next = 0; | 1861 | KOAgendaItem *next = 0; |
1862 | KOAgendaItem *last = multiItems.last(); | 1862 | KOAgendaItem *last = multiItems.last(); |
1863 | KOAgendaItem *first = multiItems.first(); | 1863 | KOAgendaItem *first = multiItems.first(); |
1864 | KOAgendaItem *setFirst,*setLast; | 1864 | KOAgendaItem *setFirst,*setLast; |
1865 | current = first; | 1865 | current = first; |
1866 | while (current) { | 1866 | while (current) { |
1867 | next = multiItems.next(); | 1867 | next = multiItems.next(); |
1868 | if (current == first) setFirst = 0; | 1868 | if (current == first) setFirst = 0; |
1869 | else setFirst = first; | 1869 | else setFirst = first; |
1870 | if (current == last) setLast = 0; | 1870 | if (current == last) setLast = 0; |
1871 | else setLast = last; | 1871 | else setLast = last; |
1872 | 1872 | ||
1873 | current->setMultiItem(setFirst,next,setLast); | 1873 | current->setMultiItem(setFirst,next,setLast); |
1874 | current = next; | 1874 | current = next; |
1875 | } | 1875 | } |
1876 | |||
1877 | marcus_bains(); | ||
1878 | } | 1876 | } |
1879 | 1877 | ||
1880 | 1878 | ||
1881 | //QSizePolicy KOAgenda::sizePolicy() const | 1879 | //QSizePolicy KOAgenda::sizePolicy() const |
1882 | //{ | 1880 | //{ |
1883 | // Thought this would make the all-day event agenda minimum size and the | 1881 | // Thought this would make the all-day event agenda minimum size and the |
1884 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1882 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1885 | // don´t seem to think that an Expanding widget needs more space than a | 1883 | // don´t seem to think that an Expanding widget needs more space than a |
1886 | // Preferred one. | 1884 | // Preferred one. |
1887 | // But it doesn´t hurt, so it stays. | 1885 | // But it doesn´t hurt, so it stays. |
1888 | // if (mAllDayMode) { | 1886 | // if (mAllDayMode) { |
1889 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1887 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1890 | // } else { | 1888 | // } else { |
1891 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1889 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1892 | // } | 1890 | // } |
1893 | //} | 1891 | //} |
1894 | void KOAgenda::finishResize ( ) | 1892 | void KOAgenda::finishResize ( ) |
1895 | { | 1893 | { |
1896 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1894 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1897 | if ( globalFlagBlockAgenda == 0 ) { | 1895 | if ( globalFlagBlockAgenda == 0 ) { |
1898 | finishUpdate(); | 1896 | finishUpdate(); |
1899 | //qDebug("finishUpdate() called "); | 1897 | //qDebug("finishUpdate() called "); |
1900 | } | 1898 | } |
1901 | } | 1899 | } |
@@ -1938,61 +1936,60 @@ void KOAgenda::computeSizes() | |||
1938 | if (height() > mGridSpacingY * mRows + 1 ) { | 1936 | if (height() > mGridSpacingY * mRows + 1 ) { |
1939 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1937 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1940 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1938 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1941 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1939 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1942 | emit resizedSignal(); | 1940 | emit resizedSignal(); |
1943 | } else | 1941 | } else |
1944 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1942 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1945 | KOAgendaItem *item; | 1943 | KOAgendaItem *item; |
1946 | int subCellWidth; | 1944 | int subCellWidth; |
1947 | 1945 | ||
1948 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1946 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1949 | subCellWidth = mGridSpacingX / item->subCells(); | 1947 | subCellWidth = mGridSpacingX / item->subCells(); |
1950 | item->resize(subCellWidth,item->height()); | 1948 | item->resize(subCellWidth,item->height()); |
1951 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1949 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1952 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1950 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1953 | item->cellX() * mGridSpacingX) + | 1951 | item->cellX() * mGridSpacingX) + |
1954 | item->subCell() * subCellWidth,childY(item)); | 1952 | item->subCell() * subCellWidth,childY(item)); |
1955 | } | 1953 | } |
1956 | } | 1954 | } |
1957 | int cw = contentsWidth(); | 1955 | int cw = contentsWidth(); |
1958 | int ch = contentsHeight(); | 1956 | int ch = contentsHeight(); |
1959 | if ( mAllDayMode ) { | 1957 | if ( mAllDayMode ) { |
1960 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1958 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1961 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { | 1959 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { |
1962 | qDebug("paintPixAll->resize "); | 1960 | //qDebug("paintPixAll->resize "); |
1963 | paintPixAll->resize( cw, ch ); | 1961 | paintPixAll->resize( cw, ch ); |
1964 | } | 1962 | } |
1965 | } else { | 1963 | } else { |
1966 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1964 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1967 | if ( paintPix->width() < cw || paintPix->height() < ch ) { | 1965 | if ( paintPix->width() < cw || paintPix->height() < ch ) { |
1968 | qDebug("paintPix->resize "); | 1966 | //qDebug("paintPix->resize "); |
1969 | paintPix->resize( cw , ch ); | 1967 | paintPix->resize( cw , ch ); |
1970 | } | 1968 | } |
1971 | } | 1969 | } |
1972 | 1970 | ||
1973 | checkScrollBoundaries(); | 1971 | checkScrollBoundaries(); |
1974 | marcus_bains(); | ||
1975 | drawContentsToPainter(); | 1972 | drawContentsToPainter(); |
1976 | viewport()->repaint(false); | 1973 | viewport()->repaint(false); |
1977 | } | 1974 | } |
1978 | 1975 | ||
1979 | void KOAgenda::scrollUp() | 1976 | void KOAgenda::scrollUp() |
1980 | { | 1977 | { |
1981 | scrollBy(0,-mScrollOffset); | 1978 | scrollBy(0,-mScrollOffset); |
1982 | } | 1979 | } |
1983 | 1980 | ||
1984 | 1981 | ||
1985 | void KOAgenda::scrollDown() | 1982 | void KOAgenda::scrollDown() |
1986 | { | 1983 | { |
1987 | scrollBy(0,mScrollOffset); | 1984 | scrollBy(0,mScrollOffset); |
1988 | } | 1985 | } |
1989 | 1986 | ||
1990 | void KOAgenda::popupAlarm() | 1987 | void KOAgenda::popupAlarm() |
1991 | { | 1988 | { |
1992 | if (!mClickedItem) { | 1989 | if (!mClickedItem) { |
1993 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1990 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1994 | return; | 1991 | return; |
1995 | } | 1992 | } |
1996 | // TODO: deal correctly with multiple alarms | 1993 | // TODO: deal correctly with multiple alarms |
1997 | Alarm* alarm; | 1994 | Alarm* alarm; |
1998 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1995 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
@@ -2010,49 +2007,48 @@ void KOAgenda::popupAlarm() | |||
2010 | int KOAgenda::minimumWidth() const | 2007 | int KOAgenda::minimumWidth() const |
2011 | { | 2008 | { |
2012 | // TODO:: develop a way to dynamically determine the minimum width | 2009 | // TODO:: develop a way to dynamically determine the minimum width |
2013 | int min = 100; | 2010 | int min = 100; |
2014 | 2011 | ||
2015 | return min; | 2012 | return min; |
2016 | } | 2013 | } |
2017 | 2014 | ||
2018 | void KOAgenda::updateConfig() | 2015 | void KOAgenda::updateConfig() |
2019 | { | 2016 | { |
2020 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 2017 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
2021 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 2018 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
2022 | if ( mAllDayMode ) { | 2019 | if ( mAllDayMode ) { |
2023 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 2020 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
2024 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 2021 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
2025 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 2022 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
2026 | // setMaximumHeight( mGridSpacingY+1 ); | 2023 | // setMaximumHeight( mGridSpacingY+1 ); |
2027 | viewport()->repaint( false ); | 2024 | viewport()->repaint( false ); |
2028 | //setFixedHeight( mGridSpacingY+1 ); | 2025 | //setFixedHeight( mGridSpacingY+1 ); |
2029 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 2026 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
2030 | } | 2027 | } |
2031 | else { | 2028 | else { |
2032 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 2029 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
2033 | calculateWorkingHours(); | 2030 | calculateWorkingHours(); |
2034 | marcus_bains(); | ||
2035 | } | 2031 | } |
2036 | } | 2032 | } |
2037 | 2033 | ||
2038 | void KOAgenda::checkScrollBoundaries() | 2034 | void KOAgenda::checkScrollBoundaries() |
2039 | { | 2035 | { |
2040 | // Invalidate old values to force update | 2036 | // Invalidate old values to force update |
2041 | mOldLowerScrollValue = -1; | 2037 | mOldLowerScrollValue = -1; |
2042 | mOldUpperScrollValue = -1; | 2038 | mOldUpperScrollValue = -1; |
2043 | 2039 | ||
2044 | checkScrollBoundaries(verticalScrollBar()->value()); | 2040 | checkScrollBoundaries(verticalScrollBar()->value()); |
2045 | } | 2041 | } |
2046 | 2042 | ||
2047 | void KOAgenda::checkScrollBoundaries(int v) | 2043 | void KOAgenda::checkScrollBoundaries(int v) |
2048 | { | 2044 | { |
2049 | if ( mGridSpacingY == 0 ) | 2045 | if ( mGridSpacingY == 0 ) |
2050 | return; | 2046 | return; |
2051 | int yMin = v/mGridSpacingY; | 2047 | int yMin = v/mGridSpacingY; |
2052 | int yMax = (v+visibleHeight())/mGridSpacingY; | 2048 | int yMax = (v+visibleHeight())/mGridSpacingY; |
2053 | 2049 | ||
2054 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 2050 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
2055 | 2051 | ||
2056 | if (yMin != mOldLowerScrollValue) { | 2052 | if (yMin != mOldLowerScrollValue) { |
2057 | mOldLowerScrollValue = yMin; | 2053 | mOldLowerScrollValue = yMin; |
2058 | emit lowerYChanged(yMin); | 2054 | emit lowerYChanged(yMin); |
@@ -2103,49 +2099,48 @@ void KOAgenda::keyPressEvent( QKeyEvent *kev ) | |||
2103 | ; | 2099 | ; |
2104 | } | 2100 | } |
2105 | } | 2101 | } |
2106 | 2102 | ||
2107 | void KOAgenda::calculateWorkingHours() | 2103 | void KOAgenda::calculateWorkingHours() |
2108 | { | 2104 | { |
2109 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 2105 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
2110 | mWorkingHoursEnable = !mAllDayMode; | 2106 | mWorkingHoursEnable = !mAllDayMode; |
2111 | 2107 | ||
2112 | mWorkingHoursYTop = mGridSpacingY * | 2108 | mWorkingHoursYTop = mGridSpacingY * |
2113 | KOPrefs::instance()->mWorkingHoursStart * 4; | 2109 | KOPrefs::instance()->mWorkingHoursStart * 4; |
2114 | mWorkingHoursYBottom = mGridSpacingY * | 2110 | mWorkingHoursYBottom = mGridSpacingY * |
2115 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 2111 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
2116 | } | 2112 | } |
2117 | 2113 | ||
2118 | 2114 | ||
2119 | DateList KOAgenda::dateList() const | 2115 | DateList KOAgenda::dateList() const |
2120 | { | 2116 | { |
2121 | return mSelectedDates; | 2117 | return mSelectedDates; |
2122 | } | 2118 | } |
2123 | 2119 | ||
2124 | void KOAgenda::setDateList(const DateList &selectedDates) | 2120 | void KOAgenda::setDateList(const DateList &selectedDates) |
2125 | { | 2121 | { |
2126 | mSelectedDates = selectedDates; | 2122 | mSelectedDates = selectedDates; |
2127 | marcus_bains(); | ||
2128 | } | 2123 | } |
2129 | 2124 | ||
2130 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 2125 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
2131 | { | 2126 | { |
2132 | mHolidayMask = mask; | 2127 | mHolidayMask = mask; |
2133 | 2128 | ||
2134 | /* | 2129 | /* |
2135 | kdDebug() << "HolidayMask: "; | 2130 | kdDebug() << "HolidayMask: "; |
2136 | for(uint i=0;i<mask->count();++i) { | 2131 | for(uint i=0;i<mask->count();++i) { |
2137 | kdDebug() << (mask->at(i) ? "*" : "o"); | 2132 | kdDebug() << (mask->at(i) ? "*" : "o"); |
2138 | } | 2133 | } |
2139 | kdDebug() << endl; | 2134 | kdDebug() << endl; |
2140 | */ | 2135 | */ |
2141 | } | 2136 | } |
2142 | 2137 | ||
2143 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 2138 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
2144 | { | 2139 | { |
2145 | 2140 | ||
2146 | QScrollView::contentsMousePressEvent(event); | 2141 | QScrollView::contentsMousePressEvent(event); |
2147 | } | 2142 | } |
2148 | 2143 | ||
2149 | void KOAgenda::storePosition() | 2144 | void KOAgenda::storePosition() |
2150 | { | 2145 | { |
2151 | //mContentPosition | 2146 | //mContentPosition |