summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagenda.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 7e9fa71..7d9d674 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -64,96 +64,97 @@ extern int globalFlagBlockStartup;
////////////////////////////////////////////////////////////////////////////
MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
: QFrame(_agenda->viewport(),name), agenda(_agenda)
{
setLineWidth(0);
setMargin(0);
setBackgroundColor(Qt::red);
minutes = new QTimer(this);
connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
minutes->start(0, true);
mTimeBox = new QLabel(this);
mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
QPalette pal = mTimeBox->palette();
pal.setColor(QColorGroup::Foreground, Qt::red);
mTimeBox->setPalette(pal);
//mTimeBox->setAutoMask(true);
agenda->addChild(mTimeBox);
oldToday = -1;
}
MarcusBains::~MarcusBains()
{
//delete minutes;
}
void MarcusBains::hideMe()
{
hide(); mTimeBox->hide();
}
int MarcusBains::todayColumn()
{
QDate currentDate = QDate::currentDate();
DateList dateList = agenda->dateList();
DateList::ConstIterator it;
int col = 0;
for(it = dateList.begin(); it != dateList.end(); ++it) {
if((*it) == currentDate)
return KOGlobals::self()->reverseLayout() ?
agenda->columns() - 1 - col : col;
++col;
}
return -1;
}
void MarcusBains::updateLoc()
{
+ if ( !agenda->invalidPixmap() )
updateLocation();
}
void MarcusBains::updateLocation(bool recalculate)
{
QTime tim = QTime::currentTime();
//qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
if((tim.hour() == 0) && (oldTime.hour()==23))
recalculate = true;
int mins = tim.hour()*60 + tim.minute();
int minutesPerCell = 24 * 60 / agenda->rows();
int y = mins*agenda->gridSpacingY()/minutesPerCell;
int today = recalculate ? todayColumn() : oldToday;
int x = agenda->gridSpacingX()*today;
bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
oldTime = tim;
oldToday = today;
if(disabled || (today<0)) {
hide(); mTimeBox->hide();
return;
} else {
show(); mTimeBox->show();
}
if(recalculate)
setFixedSize(agenda->gridSpacingX(),1);
agenda->moveChild(this, x, y);
raise();
if(recalculate)
//mTimeBox->setFont(QFont("helvetica",10));
mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
mTimeBox->adjustSize();
// the -2 below is there because there is a bug in this program
// somewhere, where the last column of this widget is a few pixels
// narrower than the other columns.
int offs = (today==agenda->columns()-1) ? -4 : 0;
agenda->moveChild(mTimeBox,
x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
y-mTimeBox->height());
mTimeBox->raise();
//mTimeBox->setAutoMask(true);
int secs = QTime::currentTime().second();
@@ -396,102 +397,106 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
if (!mActionItem)
setCursor(arrowCursor);
return true;
default:
return QScrollView::eventFilter(object,event);
}
}
void KOAgenda::popupMenu()
{
mPopupTimer->stop();
if ( mPopupKind == 1 || mPopupKind == 3 ) {
if (mActionItem ) {
endItemAction();
}
mLeftMouseDown = false; // no more leftMouse computation
if (mPopupItem) {
//mClickedItem = mPopupItem;
selectItem(mPopupItem);
if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 )
mAllAgendaPopup->installEventFilter( this );
emit showIncidencePopupSignal(mPopupItem->incidence());
}
} else if ( mPopupKind == 2 || mPopupKind == 4 ) {
if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
endSelectAction( false ); // do not emit new event signal
mLeftMouseDown = false; // no more leftMouse computation
}
if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 )
mNewItemPopup->installEventFilter( this );
mNewItemPopup->popup( mPopupPos);
}
mLeftMouseDown = false;
mPopupItem = 0;
mPopupKind = 0;
}
void KOAgenda::categoryChanged(Incidence * inc)
{
KOAgendaItem *item;
for ( item=mItems.first(); item != 0; item=mItems.next() ) {
if ( item->incidence() == inc ) {
item->initColor ();
item->updateItem();
}
}
}
+bool KOAgenda::invalidPixmap()
+{
+ return mInvalidPixmap;
+}
bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
{
if ( mInvalidPixmap ) {
mInvalidPixmap = false;
- qDebug("KO: Upsizing Pixmaps ");
+ qDebug("KO: efm Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1());
computeSizes();
emit updateViewSignal();
return true;
}
emit sendPing();
static int startX = 0;
static int startY = 0;
int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 );
static bool blockMoving = true;
//qDebug("KOAgenda::eventFilter_mous ");
if ( object == mNewItemPopup ) {
//qDebug("mNewItemPopup ");
if ( me->type() == QEvent::MouseButtonRelease ) {
mNewItemPopup->removeEventFilter( this );
int dX = me->globalPos().x() - mPopupPos.x();;
if ( dX < 0 )
dX = -dX;
int dY = me->globalPos().y() - mPopupPos.y();
if ( dY < 0 )
dY = -dY;
if ( dX > blockmoveDist || dY > blockmoveDist ) {
mNewItemPopup->hide();
}
}
return true;
}
if ( object == mAllAgendaPopup ) {
//qDebug(" mAllAgendaPopup ");
if ( me->type() == QEvent::MouseButtonRelease ) {
mAllAgendaPopup->removeEventFilter( this );
int dX = me->globalPos().x() - mPopupPos.x();;
if ( dX < 0 )
dX = -dX;
int dY = me->globalPos().y() - mPopupPos.y();
if ( dY < 0 )
dY = -dY;
if ( dX > blockmoveDist || dY > blockmoveDist ) {
mAllAgendaPopup->hide();
}
}
return true;
}
QPoint viewportPos;
if (object != viewport()) {
blockmoveDist = blockmoveDist*2;
viewportPos = ((QWidget *)object)->mapToParent(me->pos());
} else {
@@ -1236,101 +1241,102 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
for ( item2=conflictItems2.first(); item2 != 0;
item2=conflictItems2.next() ) {
if ( item2->subCells() != maxSubCells) {
item2->setSubCells(maxSubCells);
if (mAllDayMode) {
item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
} else {
item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
}
int x,y;
gridToContents(item2->cellX(),item2->cellYTop(),x,y);
if (mAllDayMode) {
y += item2->subCell() * newSubCellWidth;
} else {
x += item2->subCell() * newSubCellWidth;
}
moveChild(item2,x,y);
//qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
}
}
}
}
} else {
placeItem->setSubCell(0);
placeItem->setSubCells(1);
if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
else placeItem->resize(mGridSpacingX,placeItem->height());
int x,y;
gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
moveChild(placeItem,x,y);
}
placeItem->setConflictItems(conflictItems);
// for ( item=conflictItems.first(); item != 0;
// item=conflictItems.next() ) {
// //item->updateItem();
// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
// }
// placeItem->updateItem();
}
void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
{
if ( globalFlagBlockAgenda )
return;
if ( mInvalidPixmap ) {
mInvalidPixmap = false;
- qDebug("KO: Upsizing Pixmaps ");
+ qDebug("KO: dc Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1());
computeSizes();
emit updateViewSignal();
return;
}
+ //qDebug("KOAgenda::drawContents %s", QDateTime::currentDateTime().toString().latin1());
if ( ! mAllDayMode ) {
// currently not working for
//qDebug("KOAgenda::drawContents ");
#if 0
if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
qDebug("WAU ");
drawContentsToPainter();
}
#endif
QPaintDevice* pd = p->device();
p->end();
int vx, vy;
int selectionX = KOGlobals::self()->reverseLayout() ?
(mColumns - 1 - mSelectionCellX) * mGridSpacingX :
mSelectionCellX * mGridSpacingX;
contentsToViewport ( cx, cy, vx,vy);
//qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
int vxSel, vySel;
contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
int off = mSelectionHeight;
if ( vySel < 0 )
off += vySel;
//qDebug("OFF %d %d %d", off,vySel, vy );
bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
} else {
bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
}
}
if ( mSelectionHeight > 0 ) {
//qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
// bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
int hei = mSelectionHeight;
int offset = 0;
while ( hei > 0 ) {
int p_hei = 5;
if ( hei < 5 ) p_hei = hei;
hei -= 5;
bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
offset += 5;