summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp172
1 files changed, 80 insertions, 92 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 14f52b8..ed7a443 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -300,136 +300,127 @@ void KOAgenda::init()
else
setVScrollBarMode(AlwaysOff);
setStartHour(KOPrefs::instance()->mDayBegins);
calculateWorkingHours();
connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
SLOT(checkScrollBoundaries(int)));
// Create the Marcus Bains line.
if(mAllDayMode)
mMarcusBains = 0;
else {
mMarcusBains = new MarcusBains(this);
addChild(mMarcusBains);
}
mPopupKind = 0;
mPopupItem = 0;
}
void KOAgenda::clear()
{
KOAgendaItem *item;
for ( item=mItems.first(); item != 0; item=mItems.next() ) {
mUnusedItems.append( item );
//item->hide();
}
mItems.clear();
mSelectedItem = 0;
clearSelection();
}
void KOAgenda::clearSelection()
{
mSelectionCellX = 0;
mSelectionYTop = 0;
mSelectionHeight = 0;
}
void KOAgenda::marcus_bains()
{
if(mMarcusBains) mMarcusBains->updateLocation(true);
}
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 ");
+ if (columns == 0) {
+ qDebug("KOAgenda::changeColumns() called with argument 0 ");
+ return;
+ }
+ clear();
+ mColumns = columns;
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()) {
+ // 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));
+ return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
case (QEvent::Leave):
- if (!mActionItem)
- setCursor(arrowCursor);
- return true;
+ if (!mActionItem)
+ setCursor(arrowCursor);
+ return true;
default:
- return QScrollView::eventFilter(object,event);
- }
+ return QScrollView::eventFilter(object,event);
+ }
}
void KOAgenda::popupMenu()
{
mPopupTimer->stop();
if ( mPopupKind == 1 ) {
if (mActionItem ) {
endItemAction();
}
mLeftMouseDown = false; // no more leftMouse computation
if (mPopupItem) {
selectItem(mPopupItem);
emit showIncidencePopupSignal(mPopupItem->incidence());
}
} else if ( mPopupKind == 2 ) {
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
}
mNewItemPopup->popup( mPopupPos);
}
mLeftMouseDown = false;
mPopupItem = 0;
mPopupKind = 0;
}
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 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
static bool blockMoving = true;
switch (me->type()) {
case QEvent::MouseButtonPress:
if (me->button() == LeftButton) {
mPopupTimer->start( 600 );
mLeftMouseDown = true;
}
blockMoving = true;
startX = viewportPos.x();
startY = viewportPos.y();
@@ -1703,109 +1694,106 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
else
dt = todo->dtDue();
if ( overdue ) {
currentDate = QDate::currentDate();
days += todo->dtDue().date().daysTo( currentDate );
}
else
currentDate = dt.date();
if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
if ( ! mAllDayMode ) return;
// aldayagenda
globalFlagBlockAgendaItemPaint = 1;
item = insertAllDayItem(todo, currentDate,days, days);
item->show();
}
else {
if ( mAllDayMode ) return;
// mAgenda
globalFlagBlockAgendaItemPaint = 1;
int endY = timeToY(dt.time()) - 1;
int hi = 12/KOPrefs::instance()->mHourSize;
int startY = endY - 1-hi;
item = insertItem(todo,currentDate,days,startY,endY);
item->show();
}
qApp->processEvents();
globalFlagBlockAgendaItemPaint = 0;
QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
KOAgendaItem *itemit;
for ( itemit=oldconflictItems.first(); itemit != 0;
itemit=oldconflictItems.next() ) {
globalFlagBlockAgendaItemUpdate = 0;
itemit->repaintMe();
globalFlagBlockAgendaItemUpdate = 1;
itemit->repaint();
}
globalFlagBlockAgendaItemUpdate = 0;
item->repaintMe();
globalFlagBlockAgendaItemUpdate = 1;
item->repaint();
}
/*
Insert KOAgendaItem into agenda.
*/
KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
{
- //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl;
-
if (mAllDayMode) {
- kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl;
+ qDebug("KOAgenda: calling insertItem in all-day mode is illegal. ");
return 0;
}
KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
//agendaItem->setFrameStyle(WinPanel|Raised);
int YSize = YBottom - YTop + 1;
if (YSize < 0) {
- kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl;
YSize = 1;
}
int iheight = mGridSpacingY * YSize;
agendaItem->resize(mGridSpacingX,iheight );
agendaItem->setCellXY(X,YTop,YBottom);
agendaItem->setCellXWidth(X);
//addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
mItems.append(agendaItem);
placeSubCells(agendaItem);
//agendaItem->show();
marcus_bains();
return agendaItem;
}
/*
Insert all-day KOAgendaItem into agenda.
*/
KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
{
if (!mAllDayMode) {
return 0;
}
KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
agendaItem->setCellXY(XBegin,0,0);
agendaItem->setCellXWidth(XEnd);
agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
//addChild(agendaItem,XBegin*mGridSpacingX,0);
mItems.append(agendaItem);
placeSubCells(agendaItem);
//agendaItem->show();
return agendaItem;
}
void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
@@ -1845,180 +1833,180 @@ void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
else setFirst = first;
if (current == last) setLast = 0;
else setLast = last;
current->setMultiItem(setFirst,next,setLast);
current = next;
}
marcus_bains();
}
//QSizePolicy KOAgenda::sizePolicy() const
//{
// Thought this would make the all-day event agenda minimum size and the
// normal agenda take the remaining space. But it doesnīt work. The QSplitter
// donīt seem to think that an Expanding widget needs more space than a
// Preferred one.
// But it doesnīt hurt, so it stays.
// if (mAllDayMode) {
// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
// } else {
// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
// }
//}
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;
+ int frameOffset = frameWidth() * 2 +1;
+ if (mAllDayMode) {
+ mGridSpacingX = (width()-frameOffset) / mColumns;
+ mGridSpacingY = height() - 2 * frameWidth() - 1;
+ resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
+ // mGridSpacingY = height();
+ // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
- 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 :
+ 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;
+ }
+ KOPrefs::instance()->mAllDaySize = mGridSpacingY;
+ } else {
+ mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/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));
+ 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 );
}
- }
- 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);
+ checkScrollBoundaries();
+ marcus_bains();
+ drawContentsToPainter();
+ viewport()->repaint(false);
}
void KOAgenda::scrollUp()
{
- scrollBy(0,-mScrollOffset);
+ scrollBy(0,-mScrollOffset);
}
void KOAgenda::scrollDown()
{
- scrollBy(0,mScrollOffset);
+ scrollBy(0,mScrollOffset);
}
void KOAgenda::popupAlarm()
{
- if (!mClickedItem) {
- 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 );
+ if (!mClickedItem) {
+ 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;