summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp66
1 files changed, 59 insertions, 7 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 7e0b216..73ee5cb 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -75,212 +75,232 @@ MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
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;
}
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()
{
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);
minutes->start(5000,true);
}
////////////////////////////////////////////////////////////////////////////
/*
Create an agenda widget with rows rows and columns columns.
*/
KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
const char *name,WFlags f) :
QScrollView(parent,name,f)
{
-
+ mNewItemPopup = new QPopupMenu( this );
+ connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
+ QString pathString = "";
+ if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
+ if ( QApplication::desktop()->width() < 480 )
+ pathString += "icons16/";
+ } else
+ pathString += "iconsmini/";
+
+ mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
+ mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
+
mColumns = columns;
mRows = rows;
mGridSpacingY = rowSize;
mAllDayMode = false;
#ifndef DESKTOP_VERSION
QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
#endif
mHolidayMask = 0;
init();
}
/*
Create an agenda widget with columns columns and one row. This is used for
all-day events.
*/
KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
QScrollView(parent,name,f)
{
-
+ mNewItemPopup = new QPopupMenu( this );
+ connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
+ QString pathString = "";
+ if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
+ if ( QApplication::desktop()->width() < 480 )
+ pathString += "icons16/";
+ } else
+ pathString += "iconsmini/";
+ mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."),1 );
+ mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
blockResize = false;
mColumns = columns;
mRows = 1;
//qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
mGridSpacingY = KOPrefs::instance()->mAllDaySize;
mAllDayMode = true;
#ifndef DESKTOP_VERSION
QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
#endif
mHolidayMask = 0;
init();
}
KOAgenda::~KOAgenda()
{
if(mMarcusBains) delete mMarcusBains;
}
Incidence *KOAgenda::selectedIncidence() const
{
return (mSelectedItem ? mSelectedItem->incidence() : 0);
}
QDate KOAgenda::selectedIncidenceDate() const
{
return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
}
void KOAgenda::init()
{
#ifndef _WIN32_
int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
viewport()->setWFlags ( wflags);
#endif
mGridSpacingX = 80;
mResizeBorderWidth = 8;
mScrollBorderWidth = 8;
mScrollDelay = 30;
mScrollOffset = 10;
mPaintPixmap.resize( 20,20);
//enableClipper(true);
// Grab key strokes for keyboard navigation of agenda. Seems to have no
// effect. Has to be fixed.
setFocusPolicy(WheelFocus);
connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
mStartCellX = 0;
mStartCellY = 0;
mCurrentCellX = 0;
mCurrentCellY = 0;
mSelectionCellX = 0;
mSelectionYTop = 0;
mSelectionHeight = 0;
mOldLowerScrollValue = -1;
mOldUpperScrollValue = -1;
mClickedItem = 0;
mActionItem = 0;
mActionType = NOP;
mItemMoved = false;
mSelectedItem = 0;
// mItems.setAutoDelete(true);
resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
viewport()->update();
setMinimumSize(30, 1);
// setMaximumHeight(mGridSpacingY * mRows + 5);
// Disable horizontal scrollbar. This is a hack. The geometry should be
// controlled in a way that the contents horizontally always fits. Then it is
// not necessary to turn off the scrollbar.
setHScrollBarMode(AlwaysOff);
if ( ! mAllDayMode )
setVScrollBarMode(AlwaysOn);
else
setVScrollBarMode(AlwaysOff);
setStartHour(KOPrefs::instance()->mDayBegins);
calculateWorkingHours();
@@ -325,390 +345,422 @@ void KOAgenda::changeColumns(int columns)
{
if (columns == 0) {
kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl;
return;
}
clear();
mColumns = columns;
// setMinimumSize(mColumns * 10, mGridSpacingY + 1);
// init();
// update();
//qDebug("KOAgenda::changeColumns ");
computeSizes();
// QResizeEvent event( size(), size() );
//QApplication::sendEvent( this, &event );
}
/*
This is the eventFilter function, which gets all events from the KOAgendaItems
contained in the agenda. It has to handle moving and resizing for all items.
*/
bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
{
// kdDebug() << "KOAgenda::eventFilter" << endl;
switch(event->type()) {
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
case (QEvent::Leave):
if (!mActionItem)
setCursor(arrowCursor);
return true;
default:
return QScrollView::eventFilter(object,event);
}
}
bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
{
//qDebug("KOAgenda::eventFilter_mous ");
QPoint viewportPos;
if (object != viewport()) {
viewportPos = ((QWidget *)object)->mapToParent(me->pos());
} else {
viewportPos = me->pos();
}
static int startX = 0;
static int startY = 0;
static bool block = true;
switch (me->type()) {
case QEvent::MouseButtonPress:
//qDebug("QEvent::MouseButtonPress: ");
// kdDebug() << "koagenda: filtered button press" << endl;
if (object != viewport()) {
if (me->button() == RightButton) {
mClickedItem = (KOAgendaItem *)object;
if (mClickedItem) {
selectItem(mClickedItem);
// emit showIncidencePopupSignal(mClickedItem->incidence());
}
//mItemPopup->popup(QCursor::pos());
} else {
mActionItem = (KOAgendaItem *)object;
if (mActionItem) {
if ( mSelectionHeight > 0 ) {
int selectionCellX = mSelectionCellX * mGridSpacingX;
int selectionYTop = mSelectionYTop;
int gridSpacingX = mGridSpacingX;
int selectionHeight = mSelectionHeight;
clearSelection();
repaintContents( selectionCellX, selectionYTop,
gridSpacingX, selectionHeight,false );
}
selectItem(mActionItem);
Incidence *incidence = mActionItem->incidence();
if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
mActionItem = 0;
} else {
startItemAction(viewportPos);
startX = viewportPos.x();
startY = viewportPos.y();
block = true;
}
}
}
} else {
selectItem(0);
mActionItem = 0;
- setCursor(arrowCursor);
- startSelectAction(viewportPos);
+ if (me->button() == RightButton ) {
+ blockNewEvent = true;
+ qDebug("right ");
+ int x,y;
+ viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
+ int gx,gy;
+ contentsToGrid(x,y,gx,gy);
+ mStartCellX = gx;
+ mStartCellY = gy;
+ mCurrentCellX = gx;
+ mCurrentCellY = gy;
+ mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
+
+ } else {
+ blockNewEvent = false;
+ setCursor(arrowCursor);
+ startSelectAction(viewportPos);
+ }
}
break;
case QEvent::MouseButtonRelease:
//qDebug("QEvent::MouseButtonRelease: ");
if (me->button() == RightButton && block ) {
if (object != viewport()) {
mClickedItem = (KOAgendaItem *)object;
if (mActionItem ) {
endItemAction();
}
if (mClickedItem) {
selectItem(mClickedItem);
emit showIncidencePopupSignal(mClickedItem->incidence());
}
}
break;
}
block = true;
if (mActionItem) {
QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
//qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
mScrollUpTimer.stop();
mScrollDownTimer.stop();
mActionItem->resetMove();
placeSubCells( mActionItem );
// emit startDragSignal( mActionItem->incidence() );
setCursor( arrowCursor );
mActionItem = 0;
mActionType = NOP;
mItemMoved = 0;
return true;
}
endItemAction();
} else if ( mActionType == SELECT ) {
- endSelectAction();
+ if (me->button() == RightButton ) {
+
+ } else {
+ endSelectAction( !blockNewEvent );
+ }
}
break;
case QEvent::MouseMove:
if (object != viewport()) {
KOAgendaItem *moveItem = (KOAgendaItem *)object;
//qDebug("moveItem %d ",moveItem );
if (!moveItem->incidence()->isReadOnly() /*&&
!moveItem->incidence()->recurrence()->doesRecur()*/ )
if (!mActionItem)
setNoActionCursor(moveItem,viewportPos);
else {
if ( block ) {
int dX, dY;
dX = startX - viewportPos.x();
if ( dX < 0 )
dX = -dX;
dY = viewportPos.y() - startY;
if ( dY < 0 )
dY = -dY;
int diff = 30;
if ( QApplication::desktop()->width() < 480 )
diff = 15;
// qDebug(" %d %d ",dX, dY );
if ( dX > diff || dY > diff ) {
block = false;
}
}
if ( !block )
performItemAction(viewportPos);
}
} else {
if ( mActionType == SELECT ) {
performSelectAction( viewportPos );
}
}
break;
case QEvent::MouseButtonDblClick:
if (object == viewport()) {
selectItem(0);
int x,y;
viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
int gx,gy;
contentsToGrid(x,y,gx,gy);
emit newEventSignal(gx,gy);
} else {
KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
selectItem(doubleClickedItem);
if ( KOPrefs::instance()->mEditOnDoubleClick )
emit editIncidenceSignal(doubleClickedItem->incidence());
else
emit showIncidenceSignal(doubleClickedItem->incidence());
}
break;
default:
break;
}
return true;
}
+void KOAgenda::newItem( int item )
+{
+ qDebug("new %d ", item);
+ if ( item == 1 ) { //new event
+ newEventSignal(mStartCellX ,mStartCellY );
+ }
+ if ( item == 2 ) { //new event
+ newTodoSignal(mStartCellX ,mStartCellY );
+ }
+}
void KOAgenda::startSelectAction(QPoint viewportPos)
{
//emit newStartSelectSignal();
mActionType = SELECT;
int x,y;
viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
int gx,gy;
contentsToGrid(x,y,gx,gy);
mStartCellX = gx;
mStartCellY = gy;
mCurrentCellX = gx;
mCurrentCellY = gy;
// Store coordinates of old selection
int selectionX = mSelectionCellX * mGridSpacingX;
int selectionYTop = mSelectionYTop;
int selectionHeight = mSelectionHeight;
// Store new selection
mSelectionCellX = gx;
mSelectionYTop = gy * mGridSpacingY;
mSelectionHeight = mGridSpacingY;
// Clear old selection
repaintContents( selectionX, selectionYTop,
mGridSpacingX, selectionHeight,false );
// Paint new selection
// repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop,
// mGridSpacingX, mSelectionHeight );
}
void KOAgenda::performSelectAction(QPoint viewportPos)
{
int x,y;
viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
int gx,gy;
contentsToGrid(x,y,gx,gy);
QPoint clipperPos = clipper()->
mapFromGlobal(viewport()->mapToGlobal(viewportPos));
// Scroll if cursor was moved to upper or lower end of agenda.
if (clipperPos.y() < mScrollBorderWidth) {
mScrollUpTimer.start(mScrollDelay);
} else if (visibleHeight() - clipperPos.y() <
mScrollBorderWidth) {
mScrollDownTimer.start(mScrollDelay);
} else {
mScrollUpTimer.stop();
mScrollDownTimer.stop();
}
if ( gy > mCurrentCellY ) {
mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
#if 0
// FIXME: Repaint only the newly selected region
repaintContents( mSelectionCellX * mGridSpacingX,
mCurrentCellY + mGridSpacingY,
mGridSpacingX,
mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY );
#else
repaintContents( (KOGlobals::self()->reverseLayout() ?
mColumns - 1 - mSelectionCellX : mSelectionCellX) *
mGridSpacingX, mSelectionYTop,
mGridSpacingX, mSelectionHeight , false);
#endif
mCurrentCellY = gy;
} else if ( gy < mCurrentCellY ) {
if ( gy >= mStartCellY ) {
int selectionHeight = mSelectionHeight;
mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
repaintContents( (KOGlobals::self()->reverseLayout() ?
mColumns - 1 - mSelectionCellX : mSelectionCellX) *
mGridSpacingX, mSelectionYTop,
mGridSpacingX, selectionHeight,false );
mCurrentCellY = gy;
} else {
}
}
}
-void KOAgenda::endSelectAction()
+void KOAgenda::endSelectAction( bool emitNewEvent )
{
mActionType = NOP;
mScrollUpTimer.stop();
mScrollDownTimer.stop();
emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
+ if ( emitNewEvent && mStartCellY < mCurrentCellY )
+ emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
}
void KOAgenda::startItemAction(QPoint viewportPos)
{
int x,y;
viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
int gx,gy;
contentsToGrid(x,y,gx,gy);
mStartCellX = gx;
mStartCellY = gy;
mCurrentCellX = gx;
mCurrentCellY = gy;
if (mAllDayMode) {
int gridDistanceX = (x - gx * mGridSpacingX);
if (gridDistanceX < mResizeBorderWidth &&
mActionItem->cellX() == mCurrentCellX) {
mActionType = RESIZELEFT;
setCursor(sizeHorCursor);
} else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
mActionItem->cellXWidth() == mCurrentCellX) {
mActionType = RESIZERIGHT;
setCursor(sizeHorCursor);
} else {
mActionType = MOVE;
mActionItem->startMove();
setCursor(sizeAllCursor);
}
} else {
int gridDistanceY = (y - gy * mGridSpacingY);
bool allowResize = ( mActionItem->incidence()->type() != "Todo" );
if (allowResize && gridDistanceY < mResizeBorderWidth &&
mActionItem->cellYTop() == mCurrentCellY &&
!mActionItem->firstMultiItem()) {
mActionType = RESIZETOP;
setCursor(sizeVerCursor);
} else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
mActionItem->cellYBottom() == mCurrentCellY &&
!mActionItem->lastMultiItem()) {
mActionType = RESIZEBOTTOM;
setCursor(sizeVerCursor);
} else {
mActionType = MOVE;
mActionItem->startMove();
setCursor(sizeAllCursor);
}
}
}
void KOAgenda::performItemAction(QPoint viewportPos)
{
// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
// QPoint point = viewport()->mapToGlobal(viewportPos);
// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
// point = clipper()->mapFromGlobal(point);
// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
// kdDebug() << "visible height: " << visibleHeight() << endl;
int x,y;
viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
int gx,gy;
contentsToGrid(x,y,gx,gy);
QPoint clipperPos = clipper()->
mapFromGlobal(viewport()->mapToGlobal(viewportPos));
// Cursor left active agenda area.
// This starts a drag.
if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
if ( mActionType == MOVE ) {
mScrollUpTimer.stop();
mScrollDownTimer.stop();
mActionItem->resetMove();
placeSubCells( mActionItem );
// emit startDragSignal( mActionItem->incidence() );
setCursor( arrowCursor );
mActionItem = 0;
mActionType = NOP;
mItemMoved = 0;
return;
}
} else {
switch ( mActionType ) {
case MOVE:
setCursor( sizeAllCursor );
break;
case RESIZETOP:
case RESIZEBOTTOM:
setCursor( sizeVerCursor );
break;
case RESIZELEFT:
case RESIZERIGHT:
setCursor( sizeHorCursor );
break;
default:
@@ -1567,193 +1619,193 @@ void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
//}
void KOAgenda::finishResize ( )
{
//qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
if ( globalFlagBlockAgenda == 0 ) {
finishUpdate();
//qDebug("finishUpdate() called ");
}
}
/*
Overridden from QScrollView to provide proper resizing of KOAgendaItems.
*/
void KOAgenda::resizeEvent ( QResizeEvent *ev )
{
mResizeTimer.start( 150 , true );
computeSizes();
return;
}
void KOAgenda::computeSizes()
{
if ( globalFlagBlockStartup )
return;
if (mAllDayMode) {
mGridSpacingX = (width()-3) / mColumns;
mGridSpacingY = height() - 2 * frameWidth() - 1;
resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
// mGridSpacingY = height();
// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
KOAgendaItem *item;
int subCellWidth;
for ( item=mItems.first(); item != 0; item=mItems.next() ) {
subCellWidth = mGridSpacingY / item->subCells();
item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
moveChild(item,KOGlobals::self()->reverseLayout() ?
(mColumns - 1 - item->cellX()) * mGridSpacingX :
item->cellX() * mGridSpacingX,
item->subCell() * subCellWidth);
}
KOPrefs::instance()->mAllDaySize = mGridSpacingY;
} else {
mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns;
if (height() > mGridSpacingY * mRows + 1 ) {
KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
mGridSpacingY = KOPrefs::instance()->mHourSize ;
resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
emit resizedSignal();
} else
resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
KOAgendaItem *item;
int subCellWidth;
for ( item=mItems.first(); item != 0; item=mItems.next() ) {
subCellWidth = mGridSpacingX / item->subCells();
item->resize(subCellWidth,item->height());
moveChild(item,(KOGlobals::self()->reverseLayout() ?
(mColumns - 1 - item->cellX()) * mGridSpacingX :
item->cellX() * mGridSpacingX) +
item->subCell() * subCellWidth,childY(item));
}
}
int cw = contentsWidth();
int ch = contentsHeight();
if ( mAllDayMode ) {
QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 )
paintPixAll->resize( cw, ch );
} else {
QPixmap* paintPix = KOAgendaItem::paintPix();
if ( paintPix->width() < cw || paintPix->height() < ch )
KOAgendaItem::resizePixmap( cw , ch );
}
checkScrollBoundaries();
marcus_bains();
drawContentsToPainter();
viewport()->repaint(false);
}
void KOAgenda::scrollUp()
{
scrollBy(0,-mScrollOffset);
}
void KOAgenda::scrollDown()
{
scrollBy(0,mScrollOffset);
}
void KOAgenda::popupAlarm()
{
if (!mClickedItem) {
- kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl;
+ qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
return;
}
// TODO: deal correctly with multiple alarms
Alarm* alarm;
QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
for(alarm=list.first();alarm;alarm=list.next()) {
alarm->toggleAlarm();
}
emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
mClickedItem->paintMe( true );
mClickedItem->repaint( false );
}
/*
Calculates the minimum width
*/
int KOAgenda::minimumWidth() const
{
// TODO:: develop a way to dynamically determine the minimum width
int min = 100;
return min;
}
void KOAgenda::updateConfig()
{
if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
if ( mAllDayMode ) {
mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
//mGridSpacingY = KOPrefs::instance()->mAllDaySize;
resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
// setMaximumHeight( mGridSpacingY+1 );
viewport()->repaint( false );
//setFixedHeight( mGridSpacingY+1 );
//qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
}
else {
mGridSpacingY = KOPrefs::instance()->mHourSize;
calculateWorkingHours();
marcus_bains();
}
}
void KOAgenda::checkScrollBoundaries()
{
// Invalidate old values to force update
mOldLowerScrollValue = -1;
mOldUpperScrollValue = -1;
checkScrollBoundaries(verticalScrollBar()->value());
}
void KOAgenda::checkScrollBoundaries(int v)
{
if ( mGridSpacingY == 0 )
return;
int yMin = v/mGridSpacingY;
int yMax = (v+visibleHeight())/mGridSpacingY;
// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
if (yMin != mOldLowerScrollValue) {
mOldLowerScrollValue = yMin;
emit lowerYChanged(yMin);
}
if (yMax != mOldUpperScrollValue) {
mOldUpperScrollValue = yMax;
emit upperYChanged(yMax);
}
}
void KOAgenda::deselectItem()
{
if (mSelectedItem.isNull()) return;
mSelectedItem->select(false);
mSelectedItem = 0;
}
void KOAgenda::selectItem(KOAgendaItem *item)
{
if ((KOAgendaItem *)mSelectedItem == item) return;
deselectItem();
if (item == 0) {
emit incidenceSelected( 0 );
return;
}
mSelectedItem = item;
mSelectedItem->select();
emit incidenceSelected( mSelectedItem->incidence() );
}
// This function seems never be called.
void KOAgenda::keyPressEvent( QKeyEvent *kev )
{
switch(kev->key()) {