-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 4 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 2 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 172 | ||||
-rw-r--r-- | korganizer/koeventviewer.cpp | 6 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 4 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 6 | ||||
-rw-r--r-- | korganizer/kotodoeditor.cpp | 3 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 4 |
11 files changed, 108 insertions, 99 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a76f2ed..a9d42f0 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -3570,385 +3570,385 @@ KOEventViewerDialog* CalendarView::getEventViewerDialog() connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), viewManager(), SLOT( showAgendaView( bool ) ) ); connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), this, SLOT( slotViewerClosed() ) ); connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), this, SLOT( todoChanged(Todo *) ) ); connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); mEventViewerDialog->resize( 640, 480 ); } return mEventViewerDialog; } void CalendarView::showEvent(Event *event) { getEventViewerDialog()->setEvent(event); getEventViewerDialog()->showMe(); } void CalendarView::showTodo(Todo *event) { getEventViewerDialog()->setTodo(event); getEventViewerDialog()->showMe(); } void CalendarView::showJournal( Journal *jour ) { getEventViewerDialog()->setJournal(jour); getEventViewerDialog()->showMe(); } // void CalendarView::todoModified (Todo *event, int changed) // { // // if (mDialogList.find (event) != mDialogList.end ()) { // // kdDebug() << "Todo modified and open" << endl; // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; // // temp->modified (changed); // // } // mViewManager->updateView(); // } void CalendarView::appointment_show() { Event *anEvent = 0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->typeID() == eventID ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } showEvent(anEvent); } void CalendarView::appointment_edit() { Event *anEvent = 0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->typeID() == eventID ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } editEvent(anEvent); } void CalendarView::appointment_delete() { Event *anEvent = 0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->typeID() == eventID ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } deleteEvent(anEvent); } void CalendarView::todo_resub( Todo * parent, Todo * sub ) { if (!sub) return; if ( sub->relatedTo() == parent ) return; sub->setRelatedTo(parent); sub->updated(); setModified(true); updateView(); } void CalendarView::todo_unsub(Todo *anTodo ) { todo_resub( 0, anTodo ); } void CalendarView::deleteTodo(Todo *todo) { if (!todo) { KNotifyClient::beep(); return; } if (KOPrefs::instance()->mConfirm) { QString text = KGlobal::formatMessage ( todo->summary(),0 ); if (!todo->relations().isEmpty()) { text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); } switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { case KMessageBox::Continue: // OK bool deleteT = false; if (!todo->relations().isEmpty()) { deleteT = removeCompletedSubTodos( todo ); } // deleteT == true: todo already deleted in removeCompletedSubTodos if ( !deleteT ) { checkExternalId( todo ); calendar()->deleteTodo(todo); changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); updateView(); } break; } // switch } else { checkExternalId( todo ); mCalendar->deleteTodo(todo); changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); updateView(); } emit updateSearchDialog(); } void CalendarView::deleteJournal(Journal *jour) { if (!jour) { KNotifyClient::beep(); return; } if (KOPrefs::instance()->mConfirm) { QString des; if ( !jour->summary().isEmpty() ) { des = jour->summary(); } else { des = jour->description().left(30); des = des.simplifyWhiteSpace (); des.replace (QRegExp ("\\n"),"" ); des.replace (QRegExp ("\\r"),"" ); } switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { case KMessageBox::Continue: // OK calendar()->deleteJournal(jour); updateView(); break; } // switch } else { calendar()->deleteJournal(jour);; updateView(); } emit updateSearchDialog(); } void CalendarView::deleteEvent(Event *anEvent) { if (!anEvent) { KNotifyClient::beep(); return; } - if (anEvent->recurrence()->doesRecur()) { + if (anEvent->doesRecur()) { QDate itemDate = mViewManager->currentSelectionDate(); int km; if (!itemDate.isValid()) { //kdDebug() << "Date Not Valid" << endl; if (KOPrefs::instance()->mConfirm) { km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), i18n("KO/Pi Confirmation"),i18n("Delete All")); if ( km == KMessageBox::Continue ) km = KMessageBox::No; // No = all below } else km = KMessageBox::No; } else { km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), i18n("KO/Pi Confirmation"),i18n("Current"), i18n("All")); } switch(km) { case KMessageBox::No: // Continue // all //qDebug("KMessageBox::No "); if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) schedule(Scheduler::Cancel,anEvent); checkExternalId( anEvent); mCalendar->deleteEvent(anEvent); changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); break; // Disabled because it does not work //#if 0 case KMessageBox::Yes: // just this one //QDate qd = mNavigator->selectedDates().first(); //if (!qd.isValid()) { // kdDebug() << "no date selected, or invalid date" << endl; // KNotifyClient::beep(); // return; //} //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { anEvent->addExDate(itemDate); int duration = anEvent->recurrence()->duration(); if ( duration > 0 ) { anEvent->recurrence()->setDuration( duration - 1 ); } changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); } break; //#endif } // switch } else { if (KOPrefs::instance()->mConfirm) { switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + i18n("\nAre you sure you want\nto delete this event?"), i18n("KO/Pi Confirmation"),i18n("Delete"))) { case KMessageBox::Continue: // OK if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) schedule(Scheduler::Cancel,anEvent); checkExternalId( anEvent); mCalendar->deleteEvent(anEvent); changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); break; } // switch } else { if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) schedule(Scheduler::Cancel,anEvent); checkExternalId( anEvent); mCalendar->deleteEvent(anEvent); changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); } } // if-else emit updateSearchDialog(); } bool CalendarView::deleteEvent(const QString &uid) { Event *ev = mCalendar->event(uid); if (ev) { deleteEvent(ev); return true; } else { return false; } } /*****************************************************************************/ void CalendarView::action_mail() { #ifndef KORG_NOMAIL KOMailClient mailClient; Incidence *incidence = currentSelection(); if (!incidence) { KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); return; } if(incidence->attendeeCount() == 0 ) { KMessageBox::sorry(this, i18n("Can't generate mail:\nNo attendees defined.\n")); return; } CalendarLocal cal_tmp; Event *event = 0; Event *ev = 0; if ( incidence && incidence->typeID() == eventID ) { event = static_cast<Event *>(incidence); ev = new Event(*event); cal_tmp.addEvent(ev); } ICalFormat mForm(); QString attachment = mForm.toString( &cal_tmp ); if (ev) delete(ev); mailClient.mailAttendees(currentSelection(), attachment); #endif #if 0 Event *anEvent = 0; if (mViewManager->currentView()->isEventView()) { anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); } if (!anEvent) { KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); return; } if(anEvent->attendeeCount() == 0 ) { KMessageBox::sorry(this, i18n("Can't generate mail:\nNo attendees defined.\n")); return; } mailobject.emailEvent(anEvent); #endif } void CalendarView::schedule_publish(Incidence *incidence) { Event *event = 0; Todo *todo = 0; if (incidence == 0) { incidence = mViewManager->currentView()->selectedIncidences().first(); if (incidence == 0) { incidence = mTodoList->selectedIncidences().first(); } } if ( incidence && incidence->typeID() == eventID ) { event = static_cast<Event *>(incidence); } else { if ( incidence && incidence->typeID() == todoID ) { todo = static_cast<Todo *>(incidence); } } if (!event && !todo) { KMessageBox::sorry(this,i18n("No event selected.")); return; } PublishDialog *publishdlg = new PublishDialog(); if (incidence->attendeeCount()>0) { QPtrList<Attendee> attendees = incidence->attendees(); attendees.first(); while ( attendees.current()!=0 ) { publishdlg->addAttendee(attendees.current()); attendees.next(); } } bool send = true; if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { if ( publishdlg->exec() != QDialog::Accepted ) send = false; } if ( send ) { OutgoingDialog *dlg = mDialogManager->outgoingDialog(); if ( event ) { Event *ev = new Event(*event); ev->registerObserver(0); ev->clearAttendees(); if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { delete(ev); } } else { if ( todo ) { diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 0dd5ef5..c738f7e 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -390,385 +390,385 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) case (QEvent::Leave): 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::eventFilter_mouse(QObject *object, QMouseEvent *me) { if ( mInvalidPixmap ) { mInvalidPixmap = false; qDebug("KO: Upsizing Pixmaps "); 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 { viewportPos = me->pos(); } bool objIsNotViewport = (object != viewport()); bool leftButt = false; #ifdef DESKTOP_VERSION leftButt = (me->button() == LeftButton); #endif switch (me->type()) { case QEvent::MouseButtonPress: if (me->button() == LeftButton) { mPopupTimer->start( 600 ); mLeftMouseDown = true; } blockMoving = true; startX = viewportPos.x(); startY = viewportPos.y(); mPopupPos = me->globalPos(); if ( objIsNotViewport && !leftButt ) { KOAgendaItem * tempItem = (KOAgendaItem *)object; if (mAllDayMode) { if ( tempItem->height() > 10 ) { int minV = tempItem->height()/4; if ( minV > (blockmoveDist/2)-2 ) { if ( minV > blockmoveDist ) minV = blockmoveDist; else minV = (blockmoveDist/2); } bool border = false; int diff = tempItem->y() - viewportPos.y(); if ( diff < 0 ) diff *= -1; if ( diff < minV ) { border = true; objIsNotViewport = false; } if ( ! border ) { diff = tempItem->y() + tempItem->height()- viewportPos.y(); if ( diff < 0 ) diff *= -1; if ( diff < minV ) { border = true; objIsNotViewport = false; } } } } else { // not allday if ( tempItem->width() > 10 ) { int minH = tempItem->width()/4; if ( minH > (blockmoveDist/2)-2 ) { if ( minH > blockmoveDist ) minH = blockmoveDist; else minH = (blockmoveDist/2); } bool border = false; int diff = tempItem->x() - viewportPos.x(); if ( diff < 0 ) diff *= -1; if ( diff < minH ) { border = true; objIsNotViewport = false; } if ( ! border ) { diff = tempItem->x() + tempItem->width() - viewportPos.x(); if ( diff < 0 ) diff *= -1; if ( diff < minH ) { border = true; objIsNotViewport = false; } } } } } if ( objIsNotViewport ) { mPopupItem = (KOAgendaItem *)object; mPopupKind = 1; if (me->button() == RightButton) { mPopupKind = 3; popupMenu(); } else if (me->button() == LeftButton) { mActionItem = (KOAgendaItem *)object; if (mActionItem) { emit signalClearSelection(); slotClearSelection(); selectItem(mActionItem); Incidence *incidence = mActionItem->incidence(); - if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { + if ( incidence->isReadOnly() /*|| incidence->doesRecur() */) { mActionItem = 0; } else { startItemAction(viewportPos); } } } } else { // ---------- viewport() mPopupItem = 0; mPopupKind = 2; selectItem(0); mActionItem = 0; if (me->button() == RightButton) { int x,y; viewportToContents(viewportPos.x(),viewportPos.y(),x,y); int gx,gy; contentsToGrid(x,y,gx,gy); mCurrentCellX = gx; mCurrentCellY = gy; mStartCellX = gx; mStartCellY = gy; mPopupKind = 4; popupMenu(); } else if (me->button() == LeftButton) { setCursor(arrowCursor); startSelectAction(viewportPos); } } break; case QEvent::MouseButtonRelease: if (me->button() == LeftButton ) { mPopupTimer->stop(); } if (object != viewport()) { if (me->button() == LeftButton && mLeftMouseDown) { 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; mLeftMouseDown = false; return true; } endItemAction(); } } } else { // ---------- viewport() if (me->button() == LeftButton && mLeftMouseDown ) { //left click endSelectAction( true ); // emit new event signal } } if (me->button() == LeftButton) mLeftMouseDown = false; break; case QEvent::MouseMove: //qDebug("mm "); if ( !mLeftMouseDown ) return false; if ( blockMoving ) { int dX, dY; dX = startX - viewportPos.x(); if ( dX < 0 ) dX = -dX; dY = viewportPos.y() - startY; if ( dY < 0 ) dY = -dY; //qDebug("%d %d %d ", dX, dY , blockmoveDist ); if ( dX > blockmoveDist || dY > blockmoveDist ) { blockMoving = false; } } if ( ! blockMoving ) mPopupTimer->stop(); if (object != viewport()) { KOAgendaItem *moveItem = (KOAgendaItem *)object; if (!moveItem->incidence()->isReadOnly() ) { if (!mActionItem) setNoActionCursor(moveItem,viewportPos); else { if ( !blockMoving ) performItemAction(viewportPos); } } } else { // ---------- viewport() mPopupPos = viewport()->mapToGlobal( me->pos() ); if ( mActionType == SELECT ) { performSelectAction( viewportPos ); } } break; case QEvent::MouseButtonDblClick: mPopupTimer->stop(); 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 ) { if ( item == 1 ) { //new event newEventSignal(mStartCellX ,mStartCellY ); } else if ( item == 2 ) { //new event newTodoSignal(mStartCellX ,mStartCellY ); } else { emit showDateView( item, mStartCellX ); // 3Day view // 4Week view // 5Month view // 6Journal view } } void KOAgenda::slotClearSelection() { if (mSelectionHeight) { int selectionX = mSelectionCellX * mGridSpacingX; int top = mSelectionYTop - 2 *mGridSpacingY; int hei = mSelectionHeight + 4 *mGridSpacingY; clearSelection(); repaintContents( selectionX, top, mGridSpacingX, hei ,false ); } } void KOAgenda::startSelectAction(QPoint viewportPos) { emit signalClearSelection(); slotClearSelection(); 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 new selection mSelectionCellX = gx; mSelectionYTop = gy * mGridSpacingY; mSelectionHeight = mGridSpacingY; // Paint new selection repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, mGridSpacingX-1, 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()-> @@ -810,385 +810,385 @@ void KOAgenda::performSelectAction(QPoint viewportPos) } } } 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()->typeID() != todoID ); 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: setCursor( arrowCursor ); } } // Scroll if item 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(); } // Move or resize item if necessary if (mCurrentCellX != gx || mCurrentCellY != gy) { mItemMoved = true; mActionItem->raise(); if (mActionType == MOVE) { // Move all items belonging to a multi item KOAgendaItem *moveItem = mActionItem->firstMultiItem(); bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); if (!moveItem) moveItem = mActionItem; while (moveItem) { int dy; if (isMultiItem) dy = 0; else dy = gy - mCurrentCellY; moveItem->moveRelative(gx - mCurrentCellX,dy); int x,y; gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); moveItem->resize(mGridSpacingX * moveItem->cellWidth(), mGridSpacingY * moveItem->cellHeight()); moveItem->raise(); moveChild(moveItem,x,y); moveItem = moveItem->nextMultiItem(); } } else if (mActionType == RESIZETOP) { if (mCurrentCellY <= mActionItem->cellYBottom()) { mActionItem->expandTop(gy - mCurrentCellY); mActionItem->resize(mActionItem->width(), mGridSpacingY * mActionItem->cellHeight()); int x,y; gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); //moveChild(mActionItem,childX(mActionItem),y); QScrollView::moveChild( mActionItem,childX(mActionItem),y ); } } else if (mActionType == RESIZEBOTTOM) { if (mCurrentCellY >= mActionItem->cellYTop()) { mActionItem->expandBottom(gy - mCurrentCellY); mActionItem->resize(mActionItem->width(), mGridSpacingY * mActionItem->cellHeight()); } } else if (mActionType == RESIZELEFT) { if (mCurrentCellX <= mActionItem->cellXWidth()) { mActionItem->expandLeft(gx - mCurrentCellX); mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), mActionItem->height()); int x,y; gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); moveChild(mActionItem,x,childY(mActionItem)); } } else if (mActionType == RESIZERIGHT) { if (mCurrentCellX >= mActionItem->cellX()) { mActionItem->expandRight(gx - mCurrentCellX); mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), mActionItem->height()); } } mCurrentCellX = gx; mCurrentCellY = gy; } } void KOAgenda::endItemAction() { if ( mItemMoved ) { KOAgendaItem *placeItem = mActionItem->firstMultiItem(); if ( !placeItem ) { placeItem = mActionItem; } - if ( placeItem->incidence()->recurrence()->doesRecur() ) { + if ( placeItem->incidence()->doesRecur() ) { Incidence* oldInc = placeItem->incidence(); placeItem->recreateIncidence(); emit addToCalSignal(placeItem->incidence(), oldInc ); } int type = mActionType; if ( mAllDayMode ) type = -1; KOAgendaItem *modifiedItem = placeItem; //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); KOAgendaItem *item; if ( placeItem->incidence()->typeID() == todoID ) { mSelectedItem = 0; //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); modifiedItem->mLastMoveXPos = mCurrentCellX; emit itemModified( modifiedItem, mActionType ); } else { globalFlagBlockAgendaItemPaint = 1; for ( item=oldconflictItems.first(); item != 0; item=oldconflictItems.next() ) { placeSubCells(item); } while ( placeItem ) { //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); oldconflictItems = placeItem->conflictItems(); for ( item=oldconflictItems.first(); item != 0; item=oldconflictItems.next() ) { placeSubCells(item); } placeSubCells( placeItem ); placeItem = placeItem->nextMultiItem(); } globalFlagBlockAgendaItemPaint = 0; for ( item=oldconflictItems.first(); item != 0; item=oldconflictItems.next() ) { globalFlagBlockAgendaItemUpdate = 0; item->repaintMe(); globalFlagBlockAgendaItemUpdate = 1; item->repaint( false ); } placeItem = modifiedItem; while ( placeItem ) { //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); globalFlagBlockAgendaItemUpdate = 0; placeItem->repaintMe(); globalFlagBlockAgendaItemUpdate = 1; placeItem->repaint(false); placeItem = placeItem->nextMultiItem(); } emit itemModified( modifiedItem, mActionType ); placeItem = modifiedItem; while ( placeItem ) { oldconflictItems = placeItem->conflictItems(); for ( item=oldconflictItems.first(); item != 0; item=oldconflictItems.next() ) { placeSubCells(item); } placeSubCells( placeItem ); placeItem = placeItem->nextMultiItem(); } placeItem = modifiedItem; while ( placeItem ) { oldconflictItems = placeItem->conflictItems(); for ( item=oldconflictItems.first(); item != 0; item=oldconflictItems.next() ) { globalFlagBlockAgendaItemUpdate = 0; item->repaintMe(); globalFlagBlockAgendaItemUpdate = 1; item->repaint(false); } placeItem = placeItem->nextMultiItem(); } /* oldconflictItems = modifiedItem->conflictItems(); for ( item=oldconflictItems.first(); item != 0; item=oldconflictItems.next() ) { globalFlagBlockAgendaItemUpdate = 0; item->paintMe(false); globalFlagBlockAgendaItemUpdate = 1; item->repaint(false); } */ } } if ( mActionItem ) emit incidenceSelected( mActionItem->incidence() ); mScrollUpTimer.stop(); mScrollDownTimer.stop(); setCursor( arrowCursor ); mActionItem = 0; mActionType = NOP; mItemMoved = 0; } void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,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; int x,y; viewportToContents(viewportPos.x(),viewportPos.y(),x,y); // kdDebug() << "contents: " << x << "," << y << "\n" << endl; int gx,gy; contentsToGrid(x,y,gx,gy); // Change cursor to resize cursor if appropriate if (mAllDayMode) { int gridDistanceX = (x - gx * mGridSpacingX); if (gridDistanceX < mResizeBorderWidth && moveItem->cellX() == gx) { setCursor(sizeHorCursor); } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && moveItem->cellXWidth() == gx) { setCursor(sizeHorCursor); } else { setCursor(arrowCursor); } } else { int gridDistanceY = (y - gy * mGridSpacingY); if (gridDistanceY < mResizeBorderWidth && moveItem->cellYTop() == gy && !moveItem->firstMultiItem()) { setCursor(sizeVerCursor); } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && moveItem->cellYBottom() == gy && !moveItem->lastMultiItem()) { setCursor(sizeVerCursor); } else { setCursor(arrowCursor); } } } /* Place item in cell and take care that multiple items using the same cell do not overlap. This method is not yet optimal. It doesn´t use the maximum space it can get in all cases. At the moment the method has a bug: When an item is placed only the sub cell widths of the items are changed, which are within the Y region the item to place spans. When the sub cell width change of one of this items affects a cell, where other items are, which do not overlap in Y with the item to place, the display gets corrupted, although the corruption looks quite nice. */ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) { QPtrList<KOAgendaItem> conflictItems; int maxSubCells = 0; QIntDict<KOAgendaItem> subCellDict(7); KOAgendaItem *item; for ( item=mItems.first(); item != 0; item=mItems.next() ) { if (item != placeItem) { if (placeItem->cellX() <= item->cellXWidth() && placeItem->cellXWidth() >= item->cellX()) { if ((placeItem->cellYTop() <= item->cellYBottom()) && (placeItem->cellYBottom() >= item->cellYTop())) { conflictItems.append(item); if (item->subCells() > maxSubCells) maxSubCells = item->subCells(); subCellDict.insert(item->subCell(),item); } } } } if (conflictItems.count() > 0) { // Look for unused sub cell and insert item int i; for(i=0;i<maxSubCells;++i) { if (!subCellDict.find(i)) { placeItem->setSubCell(i); break; } } diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 303a92a..49ad9b8 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp @@ -45,385 +45,385 @@ extern int globalFlagBlockAgenda; extern int globalFlagBlockAgendaItemPaint; extern int globalFlagBlockAgendaItemUpdate; #include "koprefs.h" #include "koagendaitem.h" //#include "koagendaitem.moc" //-------------------------------------------------------------------------- QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; //-------------------------------------------------------------------------- class KOAgendaItemWhatsThis :public QWhatsThis { public: KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; protected: virtual QString text( const QPoint& ) { return _view->getWhatsThisText() ; } private: KOAgendaItem * _view; }; KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, const char *name,WFlags) : QWidget(parent, name), mIncidence(incidence), mDate(qd) { #ifndef DESKTOP_VERSION //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); #endif mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase setWFlags ( wflags); mAllDay = allday; init ( incidence, qd ); //setMouseTracking(true); //setAcceptDrops(true); xPaintCoord = -1; yPaintCoord = -1; } QString KOAgendaItem::getWhatsThisText() { if ( mIncidence ) return KIncidenceFormatter::instance()->getFormattedText( mIncidence, KOPrefs::instance()->mWTshowDetails, KOPrefs::instance()->mWTshowCreated, KOPrefs::instance()->mWTshowChanged); return "KOAgendaItem::getWhatsThisText()::internal error"; } void KOAgendaItem::initColor () { if ( (mIncidence->typeID() == todoID ) && ( !((static_cast<Todo*>(mIncidence))->isCompleted()) && ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) { if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date()) mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; else mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; } else { QStringList categories = mIncidence->categories(); QString cat = categories.first(); if (cat.isEmpty()) { if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; else mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() ); } else { mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) { if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; } } } QColor BackgroundColor ( mBackgroundColor ); if ( mIncidence->calID() > 1 ) { //BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); } mColorGroup = QColorGroup( BackgroundColor.light(), BackgroundColor.dark(),BackgroundColor.light(), BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; setBackgroundColor( mBackgroundColor ); mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); } void KOAgendaItem::init ( Incidence *incidence, QDate qd ) { mIncidence = incidence; mDate = qd; mFirstMultiItem = 0; mNextMultiItem = 0; mLastMultiItem = 0; computeText(); initColor(); mConflictItems.clear(); setCellXY(0,0,1); setCellXWidth(0); setSubCell(0); setSubCells(1); setMultiItem(0,0,0); startMove(); mSelected = true; select(false); QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); mFontPixelSize = fontinf.height();; hide(); xPaintCoord = -1; yPaintCoord = -1; } KOAgendaItem::~KOAgendaItem() { #if QT_VERSION >= 0x030000 #else delete mKOAgendaItemWhatsThis; #endif } void KOAgendaItem::recreateIncidence() { #if 0 Incidence* newInc = mIncidence->clone(); newInc->recreate(); if ( mIncidence->doesRecur() ) { mIncidence->addExDate( mDate ); newInc->recurrence()->unsetRecurs(); int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); QTime tim = mIncidence->dtStart().time(); newInc->setDtStart( QDateTime(mDate, tim) ); ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); } #endif mIncidence = mIncidence->recreateCloneException( mDate ); } bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) { int size = AGENDA_ICON_SIZE; int yOff = 0; int xOff = 0; int x = pos().x(); if ( x < 0 ) x = 0; x += 3; int y; if ( mAllDay ) y = pos().y()+3; else y = mCellYTop * ( height() / cellHeight() ) +3; if ( mIncidence->calID() > 1 ) { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 ); if ( horLayout ){ ++xOff; ++x; } else { ++yOff; ++y; } } if (mIncidence->cancelled() && height() < 20 ) { int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); if ( horLayout ) ++xOff; else ++yOff; } if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); if ( horLayout ) ++xOff; else ++yOff; } - if (mIncidence->recurrence()->doesRecur()) { + if (mIncidence->doesRecur()) { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); if ( horLayout ) ++xOff; else ++yOff; } if (mIncidence->description().length() > 0) { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); if ( horLayout ) ++xOff; else ++yOff; } if (mIncidence->isReadOnly()) { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); if ( horLayout ) ++xOff; else ++yOff; } if (mIncidence->attendeeCount()>0) { if (mIncidence->organizer() == KOPrefs::instance()->email()) { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); if ( horLayout ) ++xOff; else ++yOff; } else { Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); if (me!=0) { } else { p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); if ( horLayout ) ++xOff; else ++yOff; } p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); if ( horLayout ) ++xOff; else ++yOff; } } return ( yOff || xOff ); } void KOAgendaItem::select(bool selected) { //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); if (mSelected == selected) return; mSelected = selected; if ( ! isVisible() ) return; if ( firstMultiItem() ) firstMultiItem()->select( selected ); if ( !firstMultiItem() && nextMultiItem() ) { KOAgendaItem * placeItem = nextMultiItem(); while ( placeItem ) { placeItem->select( selected ); placeItem = placeItem->nextMultiItem(); } } globalFlagBlockAgendaItemUpdate = 0; paintMe( selected ); globalFlagBlockAgendaItemUpdate = 1; repaint( false ); } /* The eventFilter has to filter the mouse events of the agenda item childs. The events are fed into the event handling method of KOAgendaItem. This allows the KOAgenda to handle the KOAgendaItems by using an eventFilter. */ bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) { if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick || e->type() == QEvent::MouseButtonRelease || e->type() == QEvent::MouseMove) { QMouseEvent *me = (QMouseEvent *)e; QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> mapToGlobal(me->pos())); QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); return event(&returnEvent); } else { return false; } } void KOAgendaItem::repaintMe( ) { paintMe ( mSelected ); } void KOAgendaItem::paintMe( bool selected, QPainter* paint ) { if ( globalFlagBlockAgendaItemUpdate && ! selected) return; QPainter pa; if ( mSelected ) { pa.begin( this ); } else { if ( mAllDay ) pa.begin( paintPixAllday() ); else pa.begin( paintPix() ); } int x, yy, w, h; float nfh = 7.0; x = pos().x(); w = width(); h = height (); if ( mAllDay ) yy = y(); else yy = mCellYTop * ( height() / cellHeight() ); if ( mSelected ) { pa.translate( -x, -yy ); } xPaintCoord= x; yPaintCoord = yy; wPaintCoord = width(); hPaintCoord = height(); //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); if ( paint == 0 ) paint = &pa; bool horLayout = ( w < h ); int maxhei = mFontPixelSize+4; if ( horLayout ) maxhei += AGENDA_ICON_SIZE -4; bool small = ( h < maxhei ); if ( ! small ) paint->setFont(KOPrefs::instance()->mAgendaViewFont); else { QFont f = KOPrefs::instance()->mAgendaViewFont; f.setBold( false ); int fh = f.pointSize(); nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; if ( nfh < 6 ) nfh = 6; f.setPointSize( nfh ); paint->setFont(f); } paint->fillRect ( x, yy, w, h, mBackgroundColor ); static const QPixmap completedPxmp = SmallIcon("greenhook16"); static const QPixmap overduePxmp = SmallIcon("redcross16"); if ( mIncidence->typeID() == todoID ) { Todo* tempTodo = static_cast<Todo*>(mIncidence); int xx = pos().x()+(width()-completedPxmp.width()-3 ); int yyy = yy+3; if ( tempTodo->isCompleted() ) paint->drawPixmap ( xx, yyy, completedPxmp ); else { paint->drawPixmap ( xx, yyy, overduePxmp ); } } bool addIcon = false; if ( ! small || w > 3 * h || h > 3* w ) addIcon = updateIcons( paint, horLayout ); //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); if ( ! small ) { x += 3; yy += 3;w -= 6; h-= 5; } else { x += 2; yy += 1;w -= 4; h-= 4; if ( nfh < 6.01 ) { yy -= 2; h += 4; } else if ( nfh < h -2 ) ++yy; } int align; #ifndef DESKTOP_VERSION align = ( AlignLeft|WordBreak|AlignTop); #else align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); #endif if ( addIcon ) { if ( ! horLayout ) { x += AGENDA_ICON_SIZE+3; diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index a01323a..04f30bb 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -1012,385 +1012,385 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) int lenInSecs; // if ( type == KOAgenda::RESIZETOP ) // qDebug("RESIZETOP "); // if ( type == KOAgenda::RESIZEBOTTOM ) // qDebug("RESIZEBOTTOM "); // if ( type == KOAgenda::MOVE ) // qDebug("MOVE "); if ( item->incidence()->typeID() == eventID ) { startDt =item->incidence()->dtStart(); endDt = item->incidence()->dtEnd(); lenInSecs = startDt.secsTo( endDt ); } // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { startDate = mSelectedDates[item->mLastMoveXPos]; } else { if (item->cellX() < 0) { startDate = (mSelectedDates.first()).addDays(item->cellX()); } else { startDate = mSelectedDates[item->cellX()]; } } startDt.setDate(startDate); if (item->incidence()->doesFloat()) { endDt.setDate(startDate.addDays(item->cellWidth() - 1)); } else { if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) startDt.setTime(mAgenda->gyToTime(item->cellYTop())); if ( item->incidence()->typeID() == eventID ) { if ( type == KOAgenda::MOVE ) { endDt = startDt.addSecs(lenInSecs); } else if ( type == KOAgenda::RESIZEBOTTOM ) { if (item->lastMultiItem()) { endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); endDt.setDate(startDate. addDays(item->lastMultiItem()->cellX() - item->cellX())); } else { endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); endDt.setDate(startDate); } } } else { // todo if (item->lastMultiItem()) { endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); endDt.setDate(startDate. addDays(item->lastMultiItem()->cellX() - item->cellX())); } else { //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); if ( item->cellYBottom() > 0 ) endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); else endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); endDt.setDate(startDate); } } } if ( item->incidence()->typeID() == eventID ) { item->incidence()->setDtStart(startDt); (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); } else if ( item->incidence()->typeID() == todoID ) { Todo* to = static_cast<Todo*>(item->incidence()); to->setDtDue(endDt); if ( to->hasStartDate() ) { if (to->dtStart() >= to->dtDue() ) to->setDtStart(to->dtDue().addDays( -2 )); } } //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); item->incidence()->setRevision(item->incidence()->revision()+1); item->setItemDate(startDt.date()); //item->updateItem(); if ( item->incidence()->typeID() == todoID ) { emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); } else emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); item->updateItem(); } void KOAgendaView::showDates( const QDate &start, const QDate &end ) { // kdDebug() << "KOAgendaView::selectDates" << endl; mSelectedDates.clear(); // qDebug("KOAgendaView::showDates "); QDate d = start; while (d <= end) { mSelectedDates.append(d); d = d.addDays( 1 ); } // and update the view fillAgenda(); } void KOAgendaView::showEvents(QPtrList<Event>) { kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; } void KOAgendaView::changeEventDisplay(Event *, int) { // qDebug("KOAgendaView::changeEventDisplay "); // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; // this should be re-written to be MUCH smarter. Right now we // are just playing dumb. fillAgenda(); } void KOAgendaView::fillAgenda(const QDate &) { // qDebug("KOAgendaView::fillAgenda "); fillAgenda(); } void KOAgendaView::fillAgenda() { if ( globalFlagBlockStartup ) return; if ( globalFlagBlockAgenda == 1 ) return; static bool onlyOne = false; if ( onlyOne ) return; onlyOne = true; //if ( globalFlagBlockAgenda == 2 ) //globalFlagBlockAgenda = 0; // globalFlagBlockPainting = false; if ( globalFlagBlockAgenda == 0 ) globalFlagBlockAgenda = 1; // clearView(); //qDebug("fillAgenda()++++ "); globalFlagBlockAgendaItemPaint = 1; mAllDayAgenda->changeColumns(mSelectedDates.count()); mAgenda->changeColumns(mSelectedDates.count()); qApp->processEvents(); mEventIndicatorTop->changeColumns(mSelectedDates.count()); mEventIndicatorBottom->changeColumns(mSelectedDates.count()); setHolidayMasks(); mMinY.resize(mSelectedDates.count()); mMaxY.resize(mSelectedDates.count()); QPtrList<Event> dayEvents; // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. // Therefore, gtodoset all of them. QPtrList<Todo> todos = calendar()->todos(); mAgenda->setDateList(mSelectedDates); QDate today = QDate::currentDate(); DateList::ConstIterator dit; int curCol = 0; int maxCol = mSelectedDates.count()-1; for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { QDate currentDate = *dit; // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() // << endl; dayEvents = calendar()->events(currentDate,false); // Default values, which can never be reached mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; unsigned int numEvent; //qDebug("+++++NUMEVENT %d", dayEvents.count()); for(numEvent=0;numEvent<dayEvents.count();++numEvent) { Event *event = dayEvents.at(numEvent); if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) if ( event->uid().left(15) == QString("last-syncEvent-") ) continue; // kdDebug() << " Event: " << event->summary() << endl; int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; if (event->doesFloat()) { - if (event->recurrence()->doesRecur()) { + if (event->doesRecur()) { if (event->isMultiDay() ) { endX = endX - beginX;// endX is now number of days if ( event->recursOn( currentDate ) ) { endX += curCol; beginX = curCol; mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); } else { //qDebug("days endX %d curCol %d max Col %d %s",endX ,curCol, maxCol, currentDate.toString().latin1()); if ( curCol == maxCol && maxCol+1 < endX ) { int i; for ( i = 1; i< endX; ++i ) { if ( event->recursOn( currentDate.addDays( -i ) ) ) break; } if ( i > maxCol ) { mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); //qDebug("BINGO "); } } else { QDate dateit = currentDate.addDays( -endX ); if ( event->recursOn( dateit ) ) { //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); if ( curCol-endX < 0 ) { mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); } } } } } else { mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); } } else { if (beginX <= 0 && curCol == 0) { mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); } else if (beginX == curCol) { mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); } } } else if (event->isMultiDay()) { if ( event->doesRecur () ) { QDate dateit = currentDate; int count = 0; int max = event->dtStart().daysTo( event->dtEnd() ) +2; while (! event->recursOn( dateit ) && count <= max ) { ++count; dateit = dateit.addDays( -1 ); } bool ok; QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); if ( ok ) { int secs = event->dtStart().secsTo( event->dtEnd() ); QDateTime nextOcend =nextOcstart.addSecs( secs ); ; beginX = currentDate.daysTo(nextOcstart.date()) + curCol; endX = currentDate.daysTo(nextOcend.date()) + curCol; } } int startY = mAgenda->timeToY(event->dtStart().time()); int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); if ((beginX <= 0 && curCol == 0) || beginX == curCol) { //qDebug("insert!!! "); mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); } if (beginX == curCol) { mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); if (startY < mMinY[curCol]) mMinY[curCol] = startY; } else if (endX == curCol) { mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; } else { mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); } } else { int startY = mAgenda->timeToY(event->dtStart().time()); int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; if (endY < startY) endY = startY; mAgenda->insertItem(event,currentDate,curCol,startY,endY); if (startY < mMinY[curCol]) mMinY[curCol] = startY; if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; } } // ---------- [display Todos -------------- unsigned int numTodo; for (numTodo = 0; numTodo < todos.count(); ++numTodo) { Todo *todo = todos.at(numTodo); if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. // Already completed items can be displayed on their original due date //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; bool fillIn = false; if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) fillIn = true; if ( ! fillIn && !todo->hasCompletedDate() ) fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); if ( fillIn ) { if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue if ( KOPrefs::instance()->mShowTodoInAgenda ) mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); } else { QDateTime dt; if ( todo->hasCompletedDate() ) dt = todo->completed(); else dt = todo->dtDue();; int endY = mAgenda->timeToY(dt.time()) - 1; int hi = (18/KOPrefs::instance()->mHourSize); //qDebug("hei %d ",KOPrefs::instance()->mHourSize); int startY = endY -hi; mAgenda->insertItem(todo,currentDate,curCol,startY,endY); if (startY < mMinY[curCol]) mMinY[curCol] = startY; if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; } } } // ---------- display Todos] -------------- ++curCol; } mAgenda->hideUnused(); mAllDayAgenda->hideUnused(); mAgenda->checkScrollBoundaries(); deleteSelectedDateTime(); createDayLabels(); emit incidenceSelected( 0 ); if ( globalFlagBlockAgenda == 2 ) { if ( KOPrefs::instance()->mSetTimeToDayStartAt ) setStartHour( KOPrefs::instance()->mDayBegins ); else if ( KOPrefs::instance()->mCenterOnCurrentTime ) setStartHour( QTime::currentTime ().hour() ); } qApp->processEvents(); globalFlagBlockAgenda = 0; mAllDayAgenda->drawContentsToPainter(); mAgenda->drawContentsToPainter(); repaintAgenda(); startIdleTimeout(); onlyOne = false; } void KOAgendaView::repaintAgenda() { mAgenda->viewport()->repaint( false ); mAllDayAgenda->viewport()->repaint( false ); mAgenda->finishUpdate(); mAllDayAgenda->finishUpdate(); } void KOAgendaView::clearView() { mAllDayAgenda->clear(); mAgenda->clear(); } void KOAgendaView::clearList() { clearView(); mAllDayAgenda->hideUnused(); mAgenda->hideUnused(); } void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER if (fd == td) calPrinter->preview(CalPrinter::Day, fd, td); else calPrinter->preview(CalPrinter::Week, fd, td); #endif } // void KOAgendaView::updateMovedTodo() // { // // updateConfig(); // // emit updateTodoViews(); // } void KOAgendaView::slotShowDateView( int mode , int d ) { diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index ec1154a..057df0d 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -264,385 +264,385 @@ void KODayMatrix::setCalendar( Calendar *cal ) mCalendar = cal; setAcceptDrops( mCalendar ); updateEvents(); } QColor KODayMatrix::getShadedColor(QColor color) { QColor shaded; int h=0; int s=0; int v=0; color.hsv(&h,&s,&v); s = s/4; v = 192+v/4; shaded.setHsv(h,s,v); return shaded; } KODayMatrix::~KODayMatrix() { #if QT_VERSION >= 0x030000 #else delete mKODaymatrixWhatsThis; #endif // delete mKODaymatrixWhatsThis; delete [] days; delete [] daylbls; //delete [] events; delete mToolTip; } /* void KODayMatrix::setStartDate(QDate start) { updateView(start); } */ void KODayMatrix::addSelectedDaysTo(DateList& selDays) { if (mSelStart == NOSELECTION) { return; } //cope with selection being out of matrix limits at top (< 0) int i0 = mSelStart; if (i0 < 0) { for (int i = i0; i < 0; i++) { selDays.append(days[0].addDays(i)); } i0 = 0; } //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) if (mSelEnd > NUMDAYS-1) { for (int i = i0; i <= NUMDAYS-1; i++) { selDays.append(days[i]); } for (int i = NUMDAYS; i < mSelEnd; i++) { selDays.append(days[0].addDays(i)); } // apply normal routine to selection being entirely within matrix limits } else { for (int i = i0; i <= mSelEnd; i++) { selDays.append(days[i]); } } } bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) { mRedrawNeeded = true; bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); mSelStart = startdate.daysTo(start); if ( mSelStart < 0 ) mSelStart = 0; mSelEnd = startdate.daysTo(end); if ( mSelEnd > NUMDAYS-1 ) mSelEnd = NUMDAYS-1; if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { clearSelection(); if ( noSel ) return false; } return true; } void KODayMatrix::clearSelection() { mSelEnd = mSelStart = NOSELECTION; } void KODayMatrix::recalculateToday() { today = -1; for (int i=0; i<NUMDAYS; i++) { //events[i] = 0; days[i] = startdate.addDays(i); daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); // if today is in the currently displayed month, hilight today if (days[i].year() == QDate::currentDate().year() && days[i].month() == QDate::currentDate().month() && days[i].day() == QDate::currentDate().day()) { today = i; } } // qDebug(QString("Today is visible at %1.").arg(today)); } void KODayMatrix::updateView() { updateView(startdate); } void KODayMatrix::repaintViewTimed() { mRedrawNeeded = true; // bDays.fill( false); //pDays.fill( false); //hDays.fill( false); //eDays.fill( false); mRepaintTimer->stop(); int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday int i; for(i = 0; i < NUMDAYS; i++) { if ( ( (i+startDay) % 7 == 0 ) ) { pDays.setBit(i); } } repaint(false); } void KODayMatrix::computeEvent(Event *event, int i ) { QString holiStr = mHolidays[i]; if ( event->isHoliday()) { pDays.setBit(i); hDays.setBit(i); if ( !holiStr.isEmpty() ) holiStr += "\n"; holiStr += event->summary(); if ( !event->location().isEmpty() ) holiStr += " (" + event->location() + ")"; mHolidays[i] =holiStr ; eDays.setBit(i); } if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_T_VIEW && KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) { if ( event->isBirthday()) { pDays.setBit(i); if ( !holiStr.isEmpty() ) holiStr += "\n"; holiStr += i18n("Birthday") + ": "+event->summary(); if ( !event->location().isEmpty() ) holiStr += " (" + event->location() + ")"; bDays.setBit(i); mHolidays[i] =holiStr ; } } if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) eDays.setBit(i); } void KODayMatrix::updateViewTimed() { mUpdateTimer->stop(); if ( !mCalendar ) { qDebug("NOT CAL "); return; } #if 1 int i; int timeSpan = NUMDAYS-1; QPtrList<Event> events = mCalendar->events(); Event *event; QDateTime dt; bool ok; bDays.fill( false); pDays.fill( false); hDays.fill( false); eDays.fill( false); mHolidays.clear(); QDate mStartDate = days[0]; QDate endDate = mStartDate.addDays( timeSpan ); for( event = events.first(); event; event = events.next() ) { // for event - ushort recurType = event->recurrence()->doesRecur(); + ushort recurType = event->doesRecur(); if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { continue; } if ( event->doesRecur() ) { bool last; QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); QDateTime incidenceEnd; int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); bool invalid = false; while( true ) { if ( incidenceStart.isValid() ) { incidenceEnd = incidenceStart.addDays( eventlen ); int st = incidenceStart.date().daysTo( endDate ); if ( st >= 0 ) { // start before timeend int end = mStartDate.daysTo( incidenceEnd.date() ); if ( end >= 0 ) { // end after timestart --- got one! //normalize st = timeSpan - st; if ( st < 0 ) st = 0; if ( end > timeSpan ) end = timeSpan; int iii; //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); for ( iii = st;iii<= end;++iii) { computeEvent( event, iii ); } } } } else { if ( invalid ) break; invalid = true; //qDebug("invalid %s", event->summary().latin1()); incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; } if ( last ) break; bool ok; incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); if ( ! ok ) break; if ( incidenceStart.date() > endDate ) break; } } else { // no recur int st = event->dtStart().date().daysTo( endDate ); if ( st >= 0 ) { // start before timeend int end = mStartDate.daysTo( event->dtEnd().date() ); if ( end >= 0 ) { // end after timestart --- got one! //normalize st = timeSpan - st; if ( st < 0 ) st = 0; if ( end > timeSpan ) end = timeSpan; int iii; for ( iii = st;iii<= end;++iii) computeEvent( event, iii ); } } } } int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday for(i = 0; i < NUMDAYS; i++) { if ( ( (i+startDay) % 7 == 0 ) ) { pDays.setBit(i); } } if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { bDays.fill( false); // insert due todos QPtrList<Todo> todos = mCalendar->todos( ); Todo *todo; for(todo = todos.first(); todo; todo = todos.next()) { //insertTodo( todo ); if ( todo->hasDueDate() ) { int day = mStartDate.daysTo( todo->dtDue().date() ); if ( day >= 0 && day < timeSpan + 1) { int i = day; QString holiStr = mHolidays[i]; pDays.setBit(i); if ( !holiStr.isEmpty() ) holiStr += "\n"; holiStr += i18n("Todo") + ": "+todo->summary(); if ( !todo->location().isEmpty() ) holiStr += " (" + todo->location() + ")"; bDays.setBit(i); mHolidays[i] =holiStr ; eDays.setBit(i); } } } } if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { bDays.fill( false); // insert due todos QPtrList<Journal> todos = mCalendar->journals( ); Journal *todo; for(todo = todos.first(); todo; todo = todos.next()) { int day = mStartDate.daysTo( todo->dtStart().date() ); if ( day >= 0 && day < timeSpan + 1) { int i = day; QString holiStr = mHolidays[i]; pDays.setBit(i); if ( !holiStr.isEmpty() ) holiStr += "\n"; holiStr += i18n("Journal: ")+todo->summary().left(25); if ( todo->summary().length() > 25 ) holiStr +="..."; bDays.setBit(i); mHolidays[i] =holiStr ; eDays.setBit(i); } } } #else //qDebug("KODayMatrix::updateViewTimed "); for(int i = 0; i < NUMDAYS; i++) { // if events are set for the day then remember to draw it bold QPtrList<Event> eventlist = mCalendar->events(days[i]); Event *event; int numEvents = eventlist.count(); QString holiStr = ""; bDays.clearBit(i); hDays.clearBit(i); eDays.clearBit(i); for(event=eventlist.first();event != 0;event=eventlist.next()) { ushort recurType = event->recurrence()->doesRecur(); if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { numEvents--; } if ( event->isHoliday()) { hDays.setBit(i); if ( !holiStr.isEmpty() ) holiStr += "\n"; holiStr += event->summary(); if ( !event->location().isEmpty() ) holiStr += " (" + event->location() + ")"; } if ( event->isBirthday()) { if ( !holiStr.isEmpty() ) holiStr += "\n"; holiStr += i18n("Birthday") + ": "+event->summary(); if ( !event->location().isEmpty() ) holiStr += " (" + event->location() + ")"; bDays.setBit(i); } } if ( numEvents ) eDays.setBit(i); //if it is a holy day then draw it red. Sundays are consider holidays, too if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || !holiStr.isEmpty()) { mHolidays[i] = holiStr; } else { mHolidays[i] = QString::null; } } #endif mRedrawNeeded = true; if ( ! mPendingUpdateBeforeRepaint ) repaint(false); } void KODayMatrix::updateView(QDate actdate) { if ( mLastView != KOPrefs::instance()->mCurrentDisplayedView ) mRedrawNeeded = true; mLastView = KOPrefs::instance()->mCurrentDisplayedView; if ( ! actdate.isValid() ) { //qDebug("date not valid "); return; } mDayChanged = false; //flag to indicate if the starting day of the matrix has changed by this call //mDayChanged = false; // if a new startdate is to be set then apply Cornelius's calculation // of the first day to be shown if (actdate != startdate) { // reset index of selection according to shift of starting date from startdate to actdate if (mSelStart != NOSELECTION) { int tmp = actdate.daysTo(startdate); //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; // shift selection if new one would be visible at least partly ! if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { // nested if is required for next X display pushed from a different month - correction required // otherwise, for month forward and backward, it must be avoided if( mSelStart > NUMDAYS || mSelStart < 0 ) mSelStart = mSelStart + tmp; if( mSelEnd > NUMDAYS || mSelEnd < 0 ) mSelEnd = mSelEnd + tmp; } diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index de4e4f7..89504db 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp @@ -708,413 +708,419 @@ void RecurrenceChooser::setType( int type ) } } } void RecurrenceChooser::emitChoice() { emit chosen ( type() ); } /////////////////////////////// Main Widget ///////////////////////////// KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : QWidget( parent, name ) { QGridLayout *topLayout = new QGridLayout( this, 2,2 ); topLayout->setSpacing( KDialog::spacingHint() ); topLayout->setMargin( KDialog::marginHintSmall() ); mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); connect( mEnabledCheck, SIGNAL( toggled( bool ) ), SLOT( setEnabled( bool ) ) ); topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), this ); topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); if ( QApplication::desktop()->width() <= 640 ) { mTimeGroupBox->hide(); } // QFrame *timeFrame = new QFrame( mTimeGroupBox ); // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); mDateTimeLabel = new QLabel( mTimeGroupBox ); // mDateTimeLabel = new QLabel( timeFrame ); // layoutTimeFrame->addWidget( mDateTimeLabel ); //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), SLOT( showCurrentRule( int ) ) ); mRuleStack = new QWidgetStack( mRuleBox ); mDaily = new RecurDaily( mRuleStack ); mRuleStack->addWidget( mDaily, 0 ); mWeekly = new RecurWeekly( mRuleStack ); mRuleStack->addWidget( mWeekly, 0 ); mMonthly = new RecurMonthly( mRuleStack ); mRuleStack->addWidget( mMonthly, 0 ); mYearly = new RecurYearly( mRuleStack ); mRuleStack->addWidget( mYearly, 0 ); showCurrentRule( mRecurrenceChooser->type() ); mRecurrenceRangeWidget = 0; mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); mRecurrenceRange = mRecurrenceRangeDialog; mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), this ); connect( mRecurrenceRangeButton, SIGNAL( clicked() ), SLOT( showRecurrenceRangeDialog() ) ); mExceptionsWidget = 0; mExceptionsDialog = new ExceptionsDialog( this ); mExceptions = mExceptionsDialog; mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); if ( QApplication::desktop()->width() < 320 ) { topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); } else { topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); topLayout->addWidget( mExceptionsButton, 3, 1 ); } connect( mExceptionsButton, SIGNAL( clicked() ), SLOT( showExceptionsDialog() ) ); } KOEditorRecurrence::~KOEditorRecurrence() { } void KOEditorRecurrence::setEnabled( bool enabled ) { // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; mTimeGroupBox->setEnabled( enabled ); if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); mRuleBox->setEnabled( enabled ); } void KOEditorRecurrence::showCurrentRule( int current ) { switch ( current ) { case Daily: mRuleStack->raiseWidget( mDaily ); break; case Weekly: mRuleStack->raiseWidget( mWeekly ); break; case Monthly: mRuleStack->raiseWidget( mMonthly ); break; default: case Yearly: mRuleStack->raiseWidget( mYearly ); break; } } void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) { // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; mRecurrenceRange->setDateTimes( start, end ); mExceptions->setDefaults( end ); } void KOEditorRecurrence::setDefaultsDates( QDateTime from, QDateTime to ) { setDateTimes( from, to ); QBitArray days( 7 ); days.fill( 0 ); days.setBit( from.date().dayOfWeek()- 1); mWeekly->setDays( days ); bool byPos = mMonthly->byPos(); if ( byPos ) mMonthly->setByDay( from.date().day()-1 ); mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); if ( ! byPos) mMonthly->setByDay( from.date().day()-1 ); bool byDay = mYearly->byDay(); if ( ! byDay ) mYearly->setByDay( from.date().dayOfYear() ); mYearly->setByMonth( from.date().month(), from.date().day() ); if ( byDay ) mYearly->setByDay( from.date().dayOfYear() ); } void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to ) { // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); //setDateTimes( from, to ); bool enabled = false; mEnabledCheck->setChecked( enabled ); setEnabled( enabled ); mExceptions->setDefaults( to ); mRecurrenceRange->setDefaults( to ); mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); showCurrentRule( mRecurrenceChooser->type() ); mDaily->setFrequency( 1 ); mWeekly->setFrequency( 1 ); mMonthly->setFrequency( 1 ); mYearly->setFrequency( 1 ); setDefaultsDates( from, to ); } void KOEditorRecurrence::readEvent(Incidence *event) { QDateTime dtEnd; if ( event->typeID() == eventID ) dtEnd = ((Event*)event)->dtEnd(); else dtEnd = ((Todo*)event)->dtDue(); setDefaults( event->dtStart(), dtEnd ); QBitArray rDays( 7 ); QPtrList<Recurrence::rMonthPos> rmp; QPtrList<int> rmd; int day = 0; int count = 0; int month = 0; setDateTimes( event->dtStart(), dtEnd ); - Recurrence *r = event->recurrence(); - int f = r->frequency(); + - int recurs = r->doesRecur(); + int recurs = event->doesRecur(); mEnabledCheck->setChecked( recurs ); setEnabled( recurs ); int recurrenceType = RecurrenceChooser::Weekly; - - switch ( recurs ) { - case Recurrence::rNone: - setDefaults( event->dtStart(), dtEnd ); - break; - case Recurrence::rDaily: - recurrenceType = RecurrenceChooser::Daily; - mDaily->setFrequency( f ); - break; - case Recurrence::rWeekly: - recurrenceType = RecurrenceChooser::Weekly; - mWeekly->setFrequency( f ); - mWeekly->setDays( r->days() ); - break; - case Recurrence::rMonthlyPos: - // we only handle one possibility in the list right now, - // so I have hardcoded calls with first(). If we make the GUI - // more extended, this can be changed. - recurrenceType = RecurrenceChooser::Monthly; - - rmp = r->monthPositions(); - if ( rmp.first()->negative ) - count = 5 - rmp.first()->rPos - 1; - else - count = rmp.first()->rPos - 1; - day = 0; - while ( !rmp.first()->rDays.testBit( day ) ) ++day; - mMonthly->setByPos( count, day ); - - mMonthly->setFrequency( f ); - - break; - case Recurrence::rMonthlyDay: - recurrenceType = RecurrenceChooser::Monthly; - - rmd = r->monthDays(); - day = *rmd.first() - 1; - mMonthly->setByDay( day ); - - mMonthly->setFrequency( f ); - - break; - case Recurrence::rYearlyMonth: - { - recurrenceType = RecurrenceChooser::Yearly; - //qDebug("Recurrence::rYearlyMonth: "); - day = event->dtStart().date().day(); - rmd = r->yearNums(); - if ( rmd.count() > 0 ) - month = *rmd.first(); - else - month = event->dtStart().date().month() ; - mYearly->setByMonth( month, day ); + if ( recurs ) { + Recurrence *r = event->recurrence(); + int f = r->frequency(); + switch ( recurs ) { + case Recurrence::rNone: + setDefaults( event->dtStart(), dtEnd ); + break; + case Recurrence::rDaily: + recurrenceType = RecurrenceChooser::Daily; + mDaily->setFrequency( f ); + break; + case Recurrence::rWeekly: + recurrenceType = RecurrenceChooser::Weekly; + mWeekly->setFrequency( f ); + mWeekly->setDays( r->days() ); + break; + case Recurrence::rMonthlyPos: + // we only handle one possibility in the list right now, + // so I have hardcoded calls with first(). If we make the GUI + // more extended, this can be changed. + recurrenceType = RecurrenceChooser::Monthly; + + rmp = r->monthPositions(); + if ( rmp.first()->negative ) + count = 5 - rmp.first()->rPos - 1; + else + count = rmp.first()->rPos - 1; + day = 0; + while ( !rmp.first()->rDays.testBit( day ) ) ++day; + mMonthly->setByPos( count, day ); + + mMonthly->setFrequency( f ); + + break; + case Recurrence::rMonthlyDay: + recurrenceType = RecurrenceChooser::Monthly; + + rmd = r->monthDays(); + day = *rmd.first() - 1; + mMonthly->setByDay( day ); + + mMonthly->setFrequency( f ); + + break; + case Recurrence::rYearlyMonth: + { + recurrenceType = RecurrenceChooser::Yearly; + //qDebug("Recurrence::rYearlyMonth: "); + day = event->dtStart().date().day(); + rmd = r->yearNums(); + if ( rmd.count() > 0 ) + month = *rmd.first(); + else + month = event->dtStart().date().month() ; + mYearly->setByMonth( month, day ); #if 0 - //qDebug("2day = %d ",day ); - QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); - int month; - if ( !monthlist.isEmpty() ) { - month = monthlist.first()->rPos ; - } else { - month = event->dtStart().date().month() ; - } - mYearly->setByMonth( day, month ); + //qDebug("2day = %d ",day ); + QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); + int month; + if ( !monthlist.isEmpty() ) { + month = monthlist.first()->rPos ; + } else { + month = event->dtStart().date().month() ; + } + mYearly->setByMonth( day, month ); #endif - mYearly->setFrequency( f ); - } + mYearly->setFrequency( f ); + } - break; - case Recurrence::rYearlyDay: - //qDebug("Recurrence::rYearlyDay: "); - recurrenceType = RecurrenceChooser::Yearly; - mYearly->setByDay( event->dtStart().date().dayOfYear() ); - mYearly->setFrequency( f ); - break; - default: - setDefaults( event->dtStart(), dtEnd ); - break; + break; + case Recurrence::rYearlyDay: + //qDebug("Recurrence::rYearlyDay: "); + recurrenceType = RecurrenceChooser::Yearly; + mYearly->setByDay( event->dtStart().date().dayOfYear() ); + mYearly->setFrequency( f ); + break; + default: + setDefaults( event->dtStart(), dtEnd ); + break; + } } - mRecurrenceChooser->setType( recurrenceType ); showCurrentRule( recurrenceType ); mRecurrenceRange->setDateTimes( event->dtStart() ); - if ( r->doesRecur() ) { + if ( event->doesRecur() ) { + Recurrence *r = event->recurrence(); mRecurrenceRange->setDuration( r->duration() ); if ( r->duration() == 0 ) { if ( r->endDate() < event->dtStart().date() ) mRecurrenceRange->setEndDate( event->dtStart().date() ); else mRecurrenceRange->setEndDate( r->endDate() ); } else mRecurrenceRange->setEndDate( event->dtStart().date() ); } mExceptions->setDates( event->exDates() ); } void KOEditorRecurrence::writeEvent( Incidence *event ) { - Recurrence *r = event->recurrence(); + - // clear out any old settings; - r->unsetRecurs(); + if ( !mEnabledCheck->isChecked() ) { + if ( event->doesRecur() ) + event->recurrence()->unsetRecurs(); + } else { + Recurrence *r = event->recurrence(); - if ( mEnabledCheck->isChecked() ) { + // clear out any old settings; + r->unsetRecurs(); int duration = mRecurrenceRange->duration(); QDate endDate; if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); int recurrenceType = mRecurrenceChooser->type(); if ( recurrenceType == RecurrenceChooser::Daily ) { int freq = mDaily->frequency(); if ( duration != 0 ) r->setDaily( freq, duration ); else r->setDaily( freq, endDate ); } else if ( recurrenceType == RecurrenceChooser::Weekly ) { int freq = mWeekly->frequency(); QBitArray days = mWeekly->days(); int j; bool found = false; for (j = 0; j < 7 ; ++j ) { found |=days.at(j); } if ( !found ) { days.setBit( event->dtStart().date().dayOfWeek()-1); //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); } if ( duration != 0 ) r->setWeekly( freq, days, duration ); else r->setWeekly( freq, days, endDate ); } else if ( recurrenceType == RecurrenceChooser::Monthly ) { int freq = mMonthly->frequency(); if ( mMonthly->byPos() ) { int pos = mMonthly->count(); QBitArray days( 7 ); days.fill( false ); days.setBit( mMonthly->weekday() ); if ( duration != 0 ) r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); else r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); r->addMonthlyPos( pos, days ); } else { // it's by day int day = mMonthly->day(); if ( duration != 0 ) { r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); } else { r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); } r->addMonthlyDay( day ); } } else if ( recurrenceType == RecurrenceChooser::Yearly ) { //qDebug("RecurrenceChooser::Yearly "); int freq = mYearly->frequency(); if ( mYearly->byDay() ) { if ( duration != 0 ) { r->setYearly( Recurrence::rYearlyDay, freq, duration ); } else { r->setYearly( Recurrence::rYearlyDay, freq, endDate ); } r->addYearlyNum( event->dtStart().date().dayOfYear() ); } else { if ( duration != 0 ) { r->setYearly( Recurrence::rYearlyMonth, freq, duration ); } else { r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); } r->addYearlyNum( mYearly->month() ); } } event->setExDates( mExceptions->dates() ); } } void KOEditorRecurrence::setDateTimeStr( const QString &str ) { mDateTimeLabel->setText( str ); } bool KOEditorRecurrence::validateInput() { // Check input here return true; } void KOEditorRecurrence::showExceptionsDialog() { DateList dates = mExceptions->dates(); int result = mExceptionsDialog->exec(); if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); } void KOEditorRecurrence::showRecurrenceRangeDialog() { int duration = mRecurrenceRange->duration(); QDate endDate = mRecurrenceRange->endDate(); int result = mRecurrenceRangeDialog->exec(); if ( result == QDialog::Rejected ) { mRecurrenceRange->setDuration( duration ); mRecurrenceRange->setEndDate( endDate ); } } diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index a690ab1..db695f5 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp @@ -158,519 +158,519 @@ void KOEventViewer::setSource(const QString& n) QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); if (attendees.count()) { Attendee *a; for(a=attendees.first();a;a=attendees.next()) { if ( "uid:"+a->uid() == n ) { bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); return; } } } return; } //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); // the result should now arrive through method insertAttendees //QString uid = "uid:"+(*it).uid(); #endif if ( n.left(6) == "mailto" ) { // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); #ifndef DESKTOP_VERSION if ( n.mid(7,3) == "ALL" ) { mailToAttendees( true ); } else if ( n.mid(7,4) == "RSVP" ) { mailToAttendees( false ); } else { QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); e << n.mid(7); } #endif } #ifndef KORG_NODCOP kdDebug() << "KOEventViewer::setSource(): " << n << endl; QString tmpStr; if (n.startsWith("mailto:")) { KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); //emit showIncidence(n); return; } else if (n.startsWith("uid:")) { DCOPClient *client = KApplication::kApplication()->dcopClient(); const QByteArray noParamData; const QByteArray paramData; QByteArray replyData; QCString replyTypeStr; #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) bool foundAbbrowser = PING_ABBROWSER; if (foundAbbrowser) { //KAddressbook is already running, so just DCOP to it to bring up the contact editor //client->send("kaddressbook","KAddressBookIface", QDataStream arg(paramData, IO_WriteOnly); arg << n.mid(6); client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); return; } else { /* KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. We start it without its main interface */ KIconLoader* iconLoader = new KIconLoader(); QString iconPath = iconLoader->iconPath("go",KIcon::Small); ActionManager::setStartedKAddressBook(true); tmpStr = "kaddressbook --editor-only --uid "; tmpStr += KProcess::quote(n.mid(6)); KRun::runCommand(tmpStr,"KAddressBook",iconPath); return; } } else { //QTextBrowser::setSource(n); } #endif } void KOEventViewer::mailToAttendees( bool all ) { QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); if (attendees.count() == 0) return; QStringList nameList; QStringList emailList; QStringList uidList; Attendee* a; for(a=attendees.first();a;a=attendees.next()) { if ( !all && !a->RSVP() ) continue; if (!a->email().isEmpty()) { nameList.append (a->name() ); emailList.append (a->email() ); uidList.append (a->uid() ); } } QString uid = "ComposeMailUIpick2"+mMailSubject; #ifndef DESKTOP_VERSION bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); #endif } void KOEventViewer::addTag(const QString & tag,const QString & text) { int number=text.contains("\n"); QString str = "<" + tag + ">"; QString tmpText=text; QString tmpStr=str; if(number !=-1) { if (number > 0) { int pos=0; QString tmp; for(int i=0;i<=number;i++) { pos=tmpText.find("\n"); tmp=tmpText.left(pos); tmpText=tmpText.right(tmpText.length()-pos-1); tmpStr+=tmp+"<br>"; } } else tmpStr += tmpText; tmpStr+="</" + tag + ">"; mText.append(tmpStr); } else { str += text + "</" + tag + ">"; mText.append(str); } } void KOEventViewer::setColorMode( int m ) { mColorMode = m; } void KOEventViewer::appendEvent(Event *event, int mode ) { mMailSubject = ""; mCurrentIncidence = event; bool shortDate = KOPrefs::instance()->mShortDateInViewer; bool wideScreen = ( QApplication::desktop()->width() >= 640 ); topLevelWidget()->setCaption(i18n("Event Viewer")); if ( mode == 0 ) { addTag("h2",deTag(event->summary())); formatReadOnly(event); } else { if ( mColorMode == 1 ) { mText +="<font color=\"#00A000\">"; } if ( mColorMode == 2 ) { mText +="<font color=\"#C00000\">"; } // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; if ( mode == 1 ) { addTag("h2",i18n( "Local: " ) +deTag(event->summary())); } else { addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); } formatReadOnly(event); addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); if ( mColorMode ) mText += "</font>"; } mMailSubject += i18n( "Meeting " )+ event->summary(); if (event->cancelled ()) { mText +="<font color=\"#B00000\">"; addTag("i",i18n("This event has been cancelled!")); mText.append("<br>"); mText += "</font>"; mMailSubject += i18n("(cancelled)"); } if (event->doesFloat()) { if (event->isMultiDay()) { mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") .arg(event->dtStartDateStr(shortDate)) .arg(event->dtEndDateStr(shortDate))); } else { mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); } } else { if (event->isMultiDay()) { mText.append(i18n("<p><b>From:</b> %1</p> ") .arg(event->dtStartStr( shortDate))); mText.append(i18n("<p><b>To:</b> %1</p>") .arg(event->dtEndStr(shortDate))); } else { mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") .arg(event->dtStartTimeStr()) .arg(event->dtEndTimeStr())); mText.append(i18n("<p><b>On:</b> %1</p> ") .arg(event->dtStartDateStr( shortDate ))); } } if (!event->location().isEmpty()) { addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); mMailSubject += i18n(" at ") + event->location(); } - if (event->recurrence()->doesRecur()) { + if (event->doesRecur()) { - QString recurText = event->recurrence()->recurrenceText(); + QString recurText = event->recurrenceText(); addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); bool ok; QDate start = QDate::currentDate(); QDateTime next; next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); if ( ok ) { if ( wideScreen ){ addTag("p",i18n("<b>Next recurrence is on:</b>") +" " + KGlobal::locale()->formatDate( next.date(), shortDate ) ); } else { addTag("p",i18n("<b>Next recurrence is on:</b>") ); addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); } mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); } else { bool last; QDate nextd; nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); if ( last ) { if ( wideScreen ){ addTag("p",i18n("<b>Last recurrence was on:</b>") +" " + KGlobal::locale()->formatDate( nextd, shortDate )); } else{ addTag("p",i18n("<b>Last recurrence was on:</b>") ); addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); } } } } else { mMailSubject += i18n(" - " )+event->dtStartStr( true ); } if (event->isAlarmEnabled()) { Alarm *alarm =event->alarms().first() ; QDateTime t = alarm->time(); QString s =i18n("( %1 before )").arg( alarm->offsetText() ); if(wideScreen ){ addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); }else{ addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); } //addTag("p",s); } addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); formatCategories(event); formatAttendees(event); if ( KOPrefs::instance()->mEVshowCreated ) { if(wideScreen ){ addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); }else{ addTag("p",i18n("<b>Created: ") +" </b>"); addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); } } if ( KOPrefs::instance()->mEVshowChanged ) { if(wideScreen ){ addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); }else{ addTag("p",i18n("<b>Last modified: ") +" </b>"); addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); } } if ( KOPrefs::instance()->mEVshowDetails ) { if (!event->description().isEmpty()) { addTag("p",i18n("<b>Details: </b>")); addTag("p",deTag(event->description())); } } setText(mText); //QWhatsThis::add(this,mText); } void KOEventViewer::appendTodo(Todo *event, int mode ) { mMailSubject = ""; mCurrentIncidence = event; topLevelWidget()->setCaption(i18n("Todo Viewer")); bool shortDate = KOPrefs::instance()->mShortDateInViewer; bool wideScreen = ( QApplication::desktop()->width() >= 640 ); if (mode == 0 ) { addTag("h2",deTag(event->summary())); formatReadOnly(event); } else { if ( mColorMode == 1 ) { mText +="<font color=\"#00A000\">"; } if ( mColorMode == 2 ) { mText +="<font color=\"#B00000\">"; } if ( mode == 1 ) { addTag("h2",i18n( "Local: " ) +deTag(event->summary())); } else { addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); } formatReadOnly(event); addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); if ( mColorMode ) mText += "</font>"; } mMailSubject += i18n( "Todo " )+ event->summary(); if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { mText +="<font color=\"#B00000\">"; addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); mText += "</font>"; } else { mText.append(i18n("<p><i>%1 % completed</i></p>") .arg(event->percentComplete())); } if (event->cancelled ()) { mText +="<font color=\"#B00000\">"; addTag("i",i18n("This todo has been cancelled!")); mText.append("<br>"); mText += "</font>"; mMailSubject += i18n("(cancelled)"); } - if (event->recurrence()->doesRecur()) { + if (event->doesRecur()) { QString recurText = event->recurrence()->recurrenceText(); addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); } if (event->hasStartDate()) { mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); } if (event->hasDueDate()) { mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); mMailSubject += i18n(" - " )+event->dtDueStr( true ); } if (!event->location().isEmpty()) { addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); mMailSubject += i18n(" at ") + event->location(); } mText.append(i18n("<p><b>Priority:</b> %2</p>") .arg(QString::number(event->priority()))); if (event->isAlarmEnabled()) { Alarm *alarm =event->alarms().first() ; QDateTime t = alarm->time(); QString s =i18n("( %1 before )").arg( alarm->offsetText() ); if ( wideScreen ) { addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); } else { addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); } } addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); formatCategories(event); formatAttendees(event); if ( KOPrefs::instance()->mEVshowCreated ) { if(wideScreen ){ addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); } else { addTag("p",i18n("<b>Created: ") +" </b>"); addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); } } if ( KOPrefs::instance()->mEVshowChanged ) { if(wideScreen ){ addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); } else { addTag("p",i18n("<b>Last modified: ") +" </b>"); addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); } } if ( event->relatedTo() ) { addTag("b",i18n("Parent todo:<br>")); QString t_name = "[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] ";// +event->relatedTo()->summary()); mText += t_name; mText += "<a href=\"todo_uid:" + event->relatedTo()->uid() + "\">"; mText += deTag(event->relatedTo()->summary()); mText += "</a><br>"; // mText.append(deTag("[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] " +event->relatedTo()->summary()) +"<br>"); } QPtrList<Incidence> Relations = event->relations(); Incidence *to; if ( Relations.first() ) addTag("b",i18n("Sub todos:<br>")); for (to=Relations.first();to;to=Relations.next()) { QString t_name = "[" +QString::number(((Todo*)to)->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%] ";// +to->relatedTo()->summary()); mText += t_name; mText += "<a href=\"todo_uid:" + to->uid() + "\">"; mText += deTag(to->summary()); mText += "</a><br>"; } if ( KOPrefs::instance()->mEVshowDetails ) { if (!event->description().isEmpty()) { addTag("p",i18n("<b>Details: </b>")); addTag("p",deTag(event->description())); } } setText(mText); } void KOEventViewer::formatCategories(Incidence *event) { if (!event->categoriesStr().isEmpty()) { if (event->categories().count() == 1) { addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); } else { addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; } } } void KOEventViewer::formatAttendees(Incidence *event) { QPtrList<Attendee> attendees = event->attendees(); if (attendees.count()) { QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); addTag("h3",i18n("Organizer")); mText.append("<ul><li>"); #ifndef KORG_NOKABC #ifdef DESKTOP_VERSION KABC::AddressBook *add_book = KABC::StdAddressBook::self(); KABC::Addressee::List addressList; addressList = add_book->findByEmail(event->organizer()); KABC::Addressee o = addressList.first(); if (!o.isEmpty() && addressList.size()<2) { mText += "<a href=\"uid:" + o.uid() + "\">"; mText += o.formattedName(); mText += "</a>\n"; } else { mText.append(event->organizer()); } #else //DESKTOP_VERSION mText += "<a href=\"uid:organizer\">"; mText += event->organizer(); mText += "</a>\n"; #endif //DESKTOP_VERSION #else mText.append(event->organizer()); #endif if (iconPath) { mText += " <a href=\"mailto:" + event->organizer() + "\">"; mText += "<IMG src=\"" + iconPath + "\">"; mText += "</a>\n"; } mText.append("</li></ul>"); addTag("h3",i18n("Attendees")); Attendee *a; mText.append("<ul>"); int a_count = 0; int a_count_nr = 0; for(a=attendees.first();a;a=attendees.next()) { #ifndef KORG_NOKABC #ifdef DESKTOP_VERSION if (a->name().isEmpty()) { addressList = add_book->findByEmail(a->email()); KABC::Addressee o = addressList.first(); if (!o.isEmpty() && addressList.size()<2) { mText += "<a href=\"uid:" + o.uid() + "\">"; mText += o.formattedName(); mText += "</a>\n"; } else { mText += "<li>"; mText.append(a->email()); mText += "\n"; } } else { mText += "<li><a href=\"uid:" + a->uid() + "\">"; if (!a->name().isEmpty()) mText += a->name(); else mText += a->email(); mText += "</a>\n"; } #else //DESKTOP_VERSION mText += "<li><a href=\"uid:" + a->uid() + "\">"; if (!a->name().isEmpty()) mText += a->name(); else mText += a->email(); mText += "</a>\n"; #endif //DESKTOP_VERSION #else //qDebug("nokabc "); mText += "<li><a href=\"uid:" + a->uid() + "\">"; if (!a->name().isEmpty()) mText += a->name(); else mText += a->email(); mText += "</a>\n"; #endif if (!a->email().isEmpty()) { if (iconPath) { mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; if ( a->RSVP() ) { ++a_count_nr; mText += "<IMG src=\"" + iconPath + "\">"; } else { diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index d25f671..e7a5e0e 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -1,379 +1,379 @@ /* This file is part of KOrganizer. Copyright (c) 1999 Preston Brown Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qlistview.h> #include <qlayout.h> #include <qlabel.h> #include <qpopupmenu.h> #include <qprogressbar.h> #include <qfileinfo.h> #include <qmessagebox.h> #include <qdialog.h> #include <qtextstream.h> #include <qdir.h> #include <qwhatsthis.h> #include <qregexp.h> #include <qpainter.h> #include <qpaintdevicemetrics.h> #include <klocale.h> #include <kdebug.h> #include <kiconloader.h> #include <kglobal.h> #include <libkdepim/kpimglobalprefs.h> #include <libkcal/calendar.h> #include <libkcal/calendarlocal.h> #include <libkcal/icalformat.h> #include <libkcal/vcalformat.h> #include <libkcal/recurrence.h> #include <libkcal/filestorage.h> #include <libkdepim/categoryselectdialog.h> #include <libkcal/kincidenceformatter.h> #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif #ifndef KORG_NOPRINTER #include "calprinter.h" #endif #include "koglobals.h" #include "koprefs.h" #include "kfiledialog.h" #include "kolistview.h" #include "koeventviewer.h" extern QPixmap* sgListViewCompletedPix[6]; extern QPixmap* sgListViewJournalPix; class KOListViewWhatsThis :public QWhatsThis { public: KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; protected: virtual QString text( const QPoint& p) { return _view->getWhatsThisText(p) ; } private: QWidget* _wid; KOListView * _view; }; ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) { mItem = item; mDate = date; } ListItemVisitor::~ListItemVisitor() { } bool ListItemVisitor::visit(Event *e) { bool ok = false; QString start, end; QDate ds, de; if ( e->doesRecur() ) { ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); if ( ok ) { int days = e->dtStart().date().daysTo(e->dtEnd().date() ); start = KGlobal::locale()->formatDate(ds,true); de = ds.addDays( days); end = KGlobal::locale()->formatDate(de,true); } } if ( ! ok ) { start =e->dtStartDateStr(); end = e->dtEndDateStr(); ds = e->dtStart().date(); de = e->dtEnd().date(); } mItem->setText(0,e->summary()); mItem->setText(1,start); if ( e->doesFloat() ) mItem->setText(2,"---"); else mItem->setText(2,e->dtStartTimeStr()); mItem->setText(3,end); if ( e->doesFloat() ) mItem->setText(4,"---"); else mItem->setText(4,e->dtEndTimeStr()); if ( e->isAlarmEnabled() ) { mItem->setText(5,e->alarms().first()->offsetText() ); } else { mItem->setText(5, i18n("No")); } - mItem->setText(6, e->recurrence()->recurrenceText()); + mItem->setText(6, e->recurrenceText()); if( ! e->doesRecur() ) mItem->setSortKey( 6, "-" ); mItem->setText(7,"---"); mItem->setText(8,"---"); mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); mItem->setText(10,e->categoriesStr()); mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); mItem->setText(12, KGlobal::locale()->formatDateTime( e->lastModified(), true, true )); QString key; QDate d = e->lastModified().date(); QTime t = e->lastModified().time(); key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); mItem->setSortKey(12,key); t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); mItem->setSortKey(1,key); t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); mItem->setSortKey(3,key); return true; } bool ListItemVisitor::visit(Todo *t) { mItem->setText(0,t->summary()); if ( t->isCompleted() ) { mItem->setSortKey(0,"99"+ t->summary().left(10)); } else mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10)); mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); if (t->hasStartDate()) { mItem->setText(1,t->dtStartDateStr()); if (t->doesFloat()) { mItem->setText(2,"---"); } else { mItem->setText(2,t->dtStartTimeStr()); } } else { mItem->setText(1,"---"); mItem->setText(2,"---"); } mItem->setText(3,"---"); mItem->setText(4,"---"); if ( t->isAlarmEnabled() ) { mItem->setText(5,t->alarms().first()->offsetText() ); } else { mItem->setText(5, i18n("No")); } - mItem->setText(6, t->recurrence()->recurrenceText()); + mItem->setText(6, t->recurrenceText()); if( ! t->doesRecur() ) mItem->setSortKey( 6, "-" ); if (t->hasDueDate()) { mItem->setText(7,t->dtDueDateStr()); if (t->doesFloat()) { mItem->setText(8,"---"); } else { mItem->setText(8,t->dtDueTimeStr()); } } else { mItem->setText(7,"---"); mItem->setText(8,"---"); } mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); mItem->setText(10,t->categoriesStr()); mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); mItem->setText(12, KGlobal::locale()->formatDateTime( t->lastModified(), true, true )); QString key; QDate d = t->lastModified().date(); QTime tm = t->lastModified().time(); key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); mItem->setSortKey(12,key); if (t->hasDueDate()) { d = t->dtDue().date(); tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); mItem->setSortKey(7,key); } if ( t->hasStartDate() ) { d = t->dtStart().date(); tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); mItem->setSortKey(1,key); } return true; } bool ListItemVisitor::visit(Journal * j) { QString des; mItem->setPixmap( 0, *sgListViewJournalPix); if ( !j->summary().isEmpty() ) { des = j->summary(); } else { des = j->description().left(30); des = des.simplifyWhiteSpace (); des.replace (QRegExp ("\\n"),"" ); des.replace (QRegExp ("\\r"),"" ); } mItem->setText(0,des.left(25)); mItem->setSortKey(0,"0"+ des.left(25)); mItem->setText(1,j->dtStartDateStr()); mItem->setText(2,"---"); mItem->setText(3,"---"); mItem->setText(4,"---"); mItem->setText(5,"---"); mItem->setText(6,"---"); mItem->setText(7,j->dtStartDateStr()); mItem->setText(8,"---"); mItem->setText(9,"---"); mItem->setText(10,j->categoriesStr()); mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); mItem->setText(12, KGlobal::locale()->formatDateTime( j->lastModified(), true, true )); QString key; QDate d = j->lastModified().date(); QTime tm = j->lastModified().time(); key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); mItem->setSortKey(12,key); d = j->dtStart().date(); key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); mItem->setSortKey(1,key); mItem->setSortKey(7,key); return true; } KOListView::KOListView(Calendar *calendar, QWidget *parent, const char *name) : KOEventView(calendar, parent, name) { mActiveItem = 0; mForceShowCompletedTodos = false; mListView = new KOListViewListView(this); mListView->addColumn(i18n("Summary")); mListView->addColumn(i18n("Start Date")); mListView->addColumn(i18n("Start Time")); mListView->addColumn(i18n("End Date")); mListView->addColumn(i18n("End Time")); mListView->addColumn(i18n("Alarm")); // alarm set? mListView->addColumn(i18n("Recurs")); // recurs? mListView->addColumn(i18n("Due Date")); mListView->addColumn(i18n("Due Time")); mListView->addColumn(i18n("Cancelled")); mListView->addColumn(i18n("Categories")); mListView->addColumn(i18n("Calendar")); mListView->addColumn(i18n("Last Modified")); mListView->setColumnAlignment(0,AlignLeft); mListView->setColumnAlignment(1,AlignLeft); mListView->setColumnAlignment(2,AlignHCenter); mListView->setColumnAlignment(3,AlignLeft); mListView->setColumnAlignment(4,AlignHCenter); mListView->setColumnAlignment(5,AlignLeft); mListView->setColumnAlignment(6,AlignLeft); mListView->setColumnAlignment(7,AlignLeft); mListView->setColumnAlignment(8,AlignLeft); mListView->setColumnAlignment(9,AlignLeft); mListView->setColumnAlignment(10,AlignLeft); mListView->setColumnAlignment(11,AlignLeft); mListView->setColumnAlignment(12,AlignLeft); mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); int iii = 0; for ( iii = 0; iii< 13 ; ++iii ) mListView->setColumnWidthMode( iii, QListView::Manual ); QBoxLayout *layoutTop = new QVBoxLayout(this); layoutTop->addWidget(mListView); mListView->setFont ( KOPrefs::instance()->mListViewFont ); mPopupMenu = eventPopup(); QPopupMenu* selPopup = new QPopupMenu ( this ); mPopupMenu->insertSeparator(); selPopup->insertItem(i18n("All"),this, SLOT(allSelection())); selPopup->insertItem(i18n("None"),this, SLOT(clearSelection())); selPopup->insertItem(i18n("Delete selected..."),this, SLOT(deleteAll())); mPopupMenu->insertItem(i18n("Selection"), selPopup ); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Hide all selected"),this, SLOT(hideAll()),true); selPopup->insertSeparator(); QPopupMenu * exportPO = new QPopupMenu ( this ); selPopup->insertItem( i18n("Export"), exportPO ); #ifdef DESKTOP_VERSION mPopupMenu->insertSeparator(); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Print complete list..."),this, SLOT(printList()),true); #endif mCalPopup = new QPopupMenu ( this ); selPopup->insertItem( i18n("Set Calendar"), mCalPopup ); selPopup->insertItem(i18n("Set categories")+"...",this, SLOT(setCat()) ); selPopup->insertItem( i18n("Set alarm..."),this, SLOT(setAlarm())); #if 0 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Set categories")+"...",this, SLOT(setCat()),true); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Set alarm..."),this, SLOT(setAlarm()),true); #endif QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, SLOT( populateCalPopup() )); QObject::connect(mCalPopup,SIGNAL(activated( int )),this, SLOT( setCalendar( int ) )); QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, SLOT( catChanged( Incidence * ) )); exportPO->insertItem( i18n("As iCal (ics) file..."),this, SLOT(saveToFile())); exportPO->insertItem( i18n("As vCal (vcs) file..."),this, SLOT(saveToFileVCS())); exportPO->insertItem( i18n("Journal/Details..."),this, SLOT(saveDescriptionToFile())); // mPopupMenu->insertSeparator(); // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), // i18n("Add Categ. to selected..."),this, // SLOT(addCat()),true); //mPopupMenu->insertSeparator(); #ifndef DESKTOP_VERSION selPopup->insertSeparator(); selPopup->insertItem( i18n("Beam via IR..."),this, SLOT(beamSelected())); #if 0 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Beam via IR"),this, SLOT(beamSelected()),true); #endif #endif /* mPopupMenu = new QPopupMenu; mPopupMenu->insertItem(i18n("Edit Event"), this, SLOT (editEvent())); diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 498d9b0..eea9a4d 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -598,702 +598,704 @@ void MonthViewCell::setMyPalette() QPalette MonthViewCell::getPalette () { if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) return mStandardPalette; if ( mHoliday) { return mHolidayPalette ; } else { if ( mPrimary ) { return mPrimaryPalette ; } } return mNonPrimaryPalette; } bool MonthViewCell::isPrimary() const { return mPrimary; } void MonthViewCell::setHoliday( bool holiday ) { mHoliday = holiday; //setMyPalette(); } void MonthViewCell::setHoliday( const QString &holiday ) { mHolidayString = holiday; if ( !holiday.isEmpty() ) { setHoliday( true ); } } void MonthViewCell::startUpdateCell() { blockSignals( true ); mdayCount = 0; setFocusPolicy(NoFocus); if ( !mMonthView->isUpdatePossible() ) return; MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { mitem->setBlockRepaint( true ); mitem = (MonthViewItem *)mitem->next(); } if ( mAvailItemList.count() > 20 ) { mAvailItemList.setAutoDelete( true ); mAvailItemList.clear(); mAvailItemList.setAutoDelete( false ); clear(); } setPrimary( mDate.month()%2 ); setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); if ( mDate == QDate::currentDate() ) { setLineWidth( 3 ); } else { setLineWidth( 1 ); } MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); //clear(); while ( CurrentAvailItem ) { MonthViewItem *item = CurrentAvailItem; //item->setHighlightedFalse(); item->recycle( 0, ""); CurrentAvailItem = (MonthViewItem *)item->next(); mAvailItemList.append( item ); takeItem ( item ); } #ifdef DESKTOP_VERSION QToolTip::remove(this); #endif mToolTip.clear(); //qApp->processEvents(); #if 0 if ( !mHolidayString.isEmpty() ) { MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); item->setPalette( mHolidayPalette ); insertItem( item ); mToolTip.append ( mHolidayString ); } #endif } int MonthViewCell::insertEvent(Event *event) { bool useToolTips = true; #ifndef DESKTOP_VERSION useToolTips = false; #endif QString mToolTipText; setFocusPolicy(WheelFocus); if ( !(event->doesRecur() == Recurrence::rNone) ) { if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) return mdayCount; else if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) return mdayCount; } if ( event->isHoliday()) { setHoliday( true ); if ( mDate.dayOfWeek() == 7 ) setLineWidth( 3 ); } QString text; int multiday = 0;// 1 = start, 2 = midddle, 3 = end day if (event->isMultiDay()) { QString prefix = "<->";multiday = 2; QString time; if ( event->doesRecur() ) { if ( event->recursOn( mDate) ) { prefix ="->" ;multiday = 1; } else { int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); if ( event->recursOn( mDate.addDays( -days)) ) { prefix ="<-" ;multiday = 3; } } } else { if (mDate == event->dtStart().date()) { prefix ="->" ;multiday = 1; } else if (mDate == event->dtEnd().date()) { prefix ="<-" ;multiday = 3; } } if ( !event->doesFloat() ) { if ( mDate == event->dtStart().date () ) time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; else if ( mDate == event->dtEnd().date () ) time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; } text = time + event->summary(); if ( useToolTips ) mToolTipText += prefix + text; } else { if (event->doesFloat()) { text = event->summary(); if ( useToolTips ) mToolTipText += text; } else { text = KGlobal::locale()->formatTime(event->dtStart().time()); text += " " + event->summary(); if ( useToolTips ) mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); } } if ( useToolTips && ! event->location().isEmpty() ) { mToolTipText += " (" + event->location() +")"; } MonthViewItem *item ; if ( mAvailItemList.count() ) { item = mAvailItemList.first(); mAvailItemList.remove( item ); item->recycle( event, text ); } else { item = new MonthViewItem( event, text ); } QPalette pal; if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { QStringList categories = event->categories(); QString cat = categories.first(); if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { pal = getPalette(); if (cat.isEmpty()) { //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); } else { pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); } } else { if (cat.isEmpty()) { //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); } else { pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); } } } else { pal = mStandardPalette ; } pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); item->setPalette( pal ); - item->setRecur( event->recurrence()->doesRecur() ); + item->setRecur( event->doesRecur() ); item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); item->setMoreInfo( event->description().length() > 0 ); #ifdef DESKTOP_VERSION Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, KOPrefs::instance()->email()); if ( me != 0 ) { if ( me->status() == Attendee::NeedsAction && me->RSVP()) item->setReply(true && multiday < 2); else item->setReply(false); } else item->setReply(false); #endif item->setMultiDay( multiday ); if ( multiday ) { insertItem( item ,mdayCount); ++mdayCount; } else { uint i = mdayCount; uint pos = mdayCount; uint itcount = count(); if ( itcount > 1000 ) { qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); itcount = 0; } for ( i = pos; i < itcount;++i ) { // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); QListBoxItem* it = this->item ( i ); if ( it && text < it->text() ) { pos = i; break; } ++pos; } insertItem( item ,pos); } if ( useToolTips ) { mToolTip.append( mToolTipText ); } return mdayCount; } void MonthViewCell::insertTodo(Todo *todo) { setFocusPolicy(WheelFocus); QString text; if (todo->hasDueDate()) { if (!todo->doesFloat()) { text += KGlobal::locale()->formatTime(todo->dtDue().time()); text += " "; } } text += todo->summary(); MonthViewItem *item ; if ( mAvailItemList.count() ) { item = mAvailItemList.first(); mAvailItemList.remove( item ); item->recycle( todo, text ); } else { item = new MonthViewItem( todo, text ); } //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); //item->setPalette( mStandardPalette ); QPalette pal; if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { QStringList categories = todo->categories(); QString cat = categories.first(); if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { pal = getPalette(); if (cat.isEmpty()) { //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); } else { pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); } } else { if (cat.isEmpty()) { //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); } else { pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); } } } else { pal = mStandardPalette ; } pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); item->setPalette( pal ); - item->setRecur( todo->recurrence()->doesRecur() ); + item->setRecur( todo->doesRecur() ); item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); item->setMoreInfo( todo->description().length() > 0 ); insertItem( item , count()); #ifdef DESKTOP_VERSION mToolTip.append( text ); #endif } void MonthViewCell::repaintfinishUpdateCell() { MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { mitem->setBlockRepaint( false ); updateItem ( mitem ); mitem = (MonthViewItem *)mitem->next(); } blockSignals( false ); } void MonthViewCell::finishUpdateCell() { #ifdef DESKTOP_VERSION if (mToolTip.count() > 0 ) { mToolTip.sort(); QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); } #endif //sort(); //setMyPalette(); setMyPalette(); resizeEvent( 0 ); } void MonthViewCell::updateCell() { if ( !mMonthView->isUpdatePossible() ) return; startUpdateCell(); //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); Event *event; for( event = events.first(); event; event = events.next() ) { // for event insertEvent(event); } // insert due todos QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); Todo *todo; for(todo = todos.first(); todo; todo = todos.next()) { insertTodo( todo ); } finishUpdateCell(); // if ( isVisible()) //qApp->processEvents(); } void MonthViewCell::updateConfig( bool bigFont ) // = false { if ( bigFont ) { QFont fo = KOPrefs::instance()->mMonthViewFont; int ps = fo.pointSize() + 2; if ( ps < 18 ) ps += 2; fo.setPointSize( ps ); setFont( fo ); } else setFont( KOPrefs::instance()->mMonthViewFont ); QFontMetrics fm( font() ); mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); mHolidayPalette = mStandardPalette; mPrimaryPalette = mStandardPalette; mNonPrimaryPalette = mStandardPalette; if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); } //updateCell(); } void MonthViewCell::enableScrollBars( bool enabled ) { return; if ( enabled ) { QListBoxItem *fi = firstItem (); if (fi ) { int ihei = fi->height( this ); int hei = numRows () * ihei; if ( hei < height() - horizontalScrollBar()->height () ) { setVScrollBarMode(QScrollView::AlwaysOff); } else setVScrollBarMode(QScrollView::Auto); if ( ihei *3 > height() ) { setHScrollBarMode(QScrollView::AlwaysOff); } else { setHScrollBarMode(QScrollView::Auto); } } else { setVScrollBarMode(QScrollView::Auto); setHScrollBarMode(QScrollView::Auto); } } else { setVScrollBarMode(QScrollView::AlwaysOff); setHScrollBarMode(QScrollView::AlwaysOff); } } Incidence *MonthViewCell::selectedIncidence() { int index = currentItem(); if ( index < 0 ) return 0; MonthViewItem *mitem = static_cast<MonthViewItem *>( item( index ) ); if ( !mitem ) return 0; return mitem->incidence(); } QDate MonthViewCell::selectedIncidenceDate() { QDate qd; int index = currentItem(); if ( index < 0 ) return qd; return mDate; } void MonthViewCell::deselect() { clearSelection(); enableScrollBars( false ); // updateCell(); } void MonthViewCell::select() { ;// updateCell(); } void MonthViewCell::resizeEvent ( QResizeEvent * e ) { if ( !mMonthView->isUpdatePossible() ) return; //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); deselect(); mLabel->setMaximumHeight( height() - lineWidth()*2 ); QString text; //mLabel->setText( text ); bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); mLabel->resize( mLabelBigSize ); } else { mLabel->resize( mLabelSize ); text = QString::number( mDate.day() ); } mLabel->setText( text ); int size = height() - mLabel->height() - lineWidth()-1; //qDebug("LW %d ", lineWidth()); if ( size > 0 ) verticalScrollBar()->setMaximumHeight( size ); size = width() - mLabel->width() -lineWidth()-1; if ( size > 0 ) horizontalScrollBar()->setMaximumWidth( size ); mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); // mItemList->resize ( width(), height () ); if ( e ) KNoScrollListBox::resizeEvent ( e ); } void MonthViewCell::defaultAction( QListBoxItem *item ) { if ( !item ) { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); return; } MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); Incidence *incidence = eventItem->incidence(); if ( incidence ) mMonthView->defaultAction( incidence ); } void MonthViewCell::showDay() { emit showDaySignal( date() ); } void MonthViewCell::newEvent() { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); } void MonthViewCell::cellClicked( QListBoxItem *item ) { mMonthView->setSelectedCell( this ); if ( item == 0 ) { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); return; } } void MonthViewCell::contextMenu( QListBoxItem *item ) { mMonthView->setPopupCell( this ); if ( !item ) { mMonthView->showContextMenu( 0 ); return; } + //selection( item ); + //qApp->processEvents(); MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); Incidence *incidence = eventItem->incidence(); if ( incidence ) mMonthView->showContextMenu( incidence ); } void MonthViewCell::selection( QListBoxItem *item ) { if ( !item ) { emit highlightIncidence( 0 , this, 0 ); return; } MonthViewItem * it = (static_cast<MonthViewItem *>( item )); emit highlightIncidence( it->incidence(), this, it->multiDay() ); mMonthView->setSelectedCell( this ); } void MonthViewCell::deHighLight() { MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { if ( mitem->setHighlightedFalse() ) updateItem ( mitem ); mitem = (MonthViewItem *)mitem->next(); } } // returns true if no inc found bool MonthViewCell::doHighLight( Incidence * inc ) { MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { if ( mitem->incidence() == inc ) { if ( mitem->setHighlighted( inc ) ) updateItem ( mitem ); return false; } mitem = (MonthViewItem *)mitem->next(); } return true; } // ******************************************************************************* // ******************************************************************************* // ******************************************************************************* KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) : KOEventView( calendar, parent, name ), mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) { mFlagKeyPressed = false; mShortDayLabelsM = false; mShortDayLabelsW = false; skipResize = false; clPending = true; mPopupCell = 0; mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); mWidStack = new QWidgetStack( this ); QVBoxLayout* hb = new QVBoxLayout( this ); mMonthView = new QWidget( mWidStack ); mWeekView = new QWidget( mWidStack ); #if QT_VERSION >= 0x030000 mWidStack->addWidget(mMonthView ); mWidStack->addWidget(mWeekView ); #else mWidStack->addWidget( mMonthView, 1 ); mWidStack->addWidget( mWeekView , 1 ); #endif hb->addWidget( mNavigatorBar ); hb->addWidget( mWidStack ); mShowWeekView = KOPrefs::instance()->mMonthViewWeek; updatePossible = false; //updatePossible = true; mCells.setAutoDelete( true ); mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; mDayLabels.resize( mDaysPerWeek ); mDayLabelsW.resize( mDaysPerWeek ); QFont bfont = font(); if ( QApplication::desktop()->width() < 650 ) { bfont.setPointSize( bfont.pointSize() - 2 ); } bfont.setBold( true ); int i; for( i = 0; i < mDaysPerWeek; i++ ) { QLabel *label = new QLabel( mMonthView ); label->setFont(bfont); label->setFrameStyle(QFrame::Panel|QFrame::Raised); label->setLineWidth(1); label->setAlignment(AlignCenter); mDayLabels.insert( i, label ); label = new QLabel( mWeekView ); label->setFont(bfont); label->setFrameStyle(QFrame::Panel|QFrame::Raised); label->setLineWidth(1); label->setAlignment(AlignCenter); mDayLabelsW.insert( i, label ); } bfont.setBold( false ); mWeekLabels.resize( mNumWeeks+1 ); mWeekLabelsW.resize( 2 ); for( i = 0; i < mNumWeeks+1; i++ ) { KOWeekButton *label = new KOWeekButton( mMonthView ); label->setFocusPolicy(NoFocus); label->setFont(bfont); connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); label->setFlat(true); QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); //label->setFrameStyle(QFrame::Panel|QFrame::Raised); //label->setLineWidth(1); //label->setAlignment(AlignCenter); mWeekLabels.insert( i, label ); } mWeekLabels[mNumWeeks]->setText( i18n("W")); mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); for( i = 0; i < 1+1; i++ ) { KOWeekButton *label = new KOWeekButton( mWeekView ); label->setFocusPolicy(NoFocus); label->setFont(bfont); connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); label->setFlat(true); QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); //label->setFrameStyle(QFrame::Panel|QFrame::Raised); //label->setLineWidth(1); //label->setAlignment(AlignCenter); mWeekLabelsW.insert( i, label ); } mWeekLabelsW[1]->setText( i18n("W")); mWeekLabelsW[1]->setFocusPolicy(WheelFocus); int row, col; mCells.resize( mNumCells ); for( row = 0; row < mNumWeeks; ++row ) { for( col = 0; col < mDaysPerWeek; ++col ) { MonthViewCell *cell = new MonthViewCell( this, mMonthView ); mCells.insert( row * mDaysPerWeek + col, cell ); connect( cell, SIGNAL( defaultAction( Incidence * ) ), SLOT( defaultAction( Incidence * ) ) ); connect( cell, SIGNAL( newEventSignal( QDateTime ) ), SIGNAL( newEventSignal( QDateTime ) ) ); connect( cell, SIGNAL( showDaySignal( QDate ) ), SIGNAL( showDaySignal( QDate ) ) ); connect( cell, SIGNAL( nextCell() ), SLOT( nextCell() ) ); connect( cell, SIGNAL( prevCell() ), SLOT( prevCell() ) ); connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); } } mCellsW.resize( mDaysPerWeek ); for( col = 0; col < mDaysPerWeek; ++col ) { MonthViewCell *cell = new MonthViewCell( this, mWeekView ); mCellsW.insert( col, cell ); connect( cell, SIGNAL( defaultAction( Incidence * ) ), SLOT( defaultAction( Incidence * ) ) ); connect( cell, SIGNAL( newEventSignal( QDateTime ) ), SIGNAL( newEventSignal( QDateTime ) ) ); connect( cell, SIGNAL( showDaySignal( QDate ) ), SIGNAL( showDaySignal( QDate ) ) ); connect( cell, SIGNAL( nextCell() ), SLOT( nextCell() ) ); connect( cell, SIGNAL( prevCell() ), SLOT( prevCell() ) ); connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); } //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); mContextMenu = eventPopup(); mContextMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("New Event..."),this, SLOT(slotNewEvent()),false); mContextMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("New Todo..."),this, SLOT(slotNewTodo()),false); mContextMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Journal"),this, SLOT(slotEditJournal()),false); connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, SLOT( catChanged( Incidence * ) )); QString pathString = ""; diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 100a81b..682f83b 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp @@ -188,266 +188,267 @@ void KOTodoEditor::setupGeneral() QBoxLayout *topLayout = new QVBoxLayout(topFrame); topLayout->setSpacing(spacingHint()); mGeneral->initHeader(topFrame,topLayout); mGeneral->initTime(topFrame,topLayout); mGeneral->initStatus(topFrame,topLayout); QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); mGeneral->initAlarm(topFrame,alarmLineLayout); mGeneral->initDescription(topFrame,topLayout); QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); mGeneral->initCategories( topFrame, detailsLayout ); mGeneral->initSecrecy( topFrame, detailsLayout ); } mGeneral->finishSetup(); } void KOTodoEditor::editTodo(Todo *todo, bool editDescription) { //init(); mTodo = todo; readTodo(mTodo); if ( editDescription ) { showPage( 1 ); mGeneral->setFocusOn( 1 ); } else { showPage( 0 ); mGeneral->setFocusOn( 2 ); } checkRecurrence(); } void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) { //init(); mTodo = 0; setDefaults(due,relatedTodo,allDay); } void KOTodoEditor::loadDefaults() { setDefaults(QDateTime::currentDateTime().addDays(7),0,false); } bool KOTodoEditor::processInput( bool emitTime ) { if (!validateInput()) return false; Todo *todo = 0; if (mTodo) todo = mTodo; else { todo = new Todo; todo->setOrganizer(KOPrefs::instance()->email()); } writeTodo(todo); if ( emitTime ) { globalFlagBlockAgenda = 1; emit showAgendaView( false ); if ( todo->hasDueDate() ) emit jumpToTime( todo->dtDue().date() ); globalFlagBlockAgenda = 2; } if (mTodo) { todo->setRevision(todo->revision()+1); emit todoChanged(todo); } else { mCalendar->addTodo(todo); mTodo = todo; emit todoAdded(todo); } return true; } void KOTodoEditor::deleteTodo() { if (mTodo) { if (KOPrefs::instance()->mConfirm) { switch (msgItemDelete()) { case KMessageBox::Continue: // OK emit todoToBeDeleted(mTodo); emit dialogClose(mTodo); mCalendar->deleteTodo(mTodo); emit todoDeleted(); reject(); break; } } else { emit todoToBeDeleted(mTodo); emit dialogClose(mTodo); mCalendar->deleteTodo(mTodo); emit todoDeleted(); reject(); } } else { reject(); } } void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) { mRelatedTodo = relatedEvent; mGeneral->setDefaults(due,allDay); mDetails->setDefaults(); showPage( 0 ); if ( mRelatedTodo ) { mGeneral->fillCalCombo(mRelatedTodo->calID() ); mGeneral->setCategories (mRelatedTodo->categoriesStr ()); mGeneral->setSecrecy (mRelatedTodo->secrecy ()); if ( mRelatedTodo->priority() < 3 ) mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); int len = mRelatedTodo->summary().length(); mGeneral->mSummaryEdit->lineEdit()->setFocus(); mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); } else mGeneral->setFocusOn( 2 ); tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); } void KOTodoEditor::checkRecurrence() { if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); if ( mTodo ) mRecurrence->readEvent( mTodo ); else { bool time = mGeneral->mTimeButton->isChecked(); QDateTime from,to; if ( time ) { to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; } else { to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; } if ( to < from ) to = from; mRecurrence->setDefaults(from,to); } } else { tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); } } void KOTodoEditor::readTodo(Todo *todo) { mGeneral->readTodo(todo); mDetails->readEvent(todo); mRelatedTodo = 0;//todo->relatedTo(); // categories // mCategoryDialog->setSelected(todo->categories()); // We should handle read-only events here. } void KOTodoEditor::writeTodo(Todo *event) { bool maybeComputeRecurrenceTime = false; if( event->hasRecurrenceID() && event->percentComplete() < 100) maybeComputeRecurrenceTime = true; event->setHasRecurrenceID( false ); mGeneral->writeTodo(event); mDetails->writeEvent(event); // set related event, i.e. parent to-do in this case. if (mRelatedTodo) { event->setRelatedTo(mRelatedTodo); } if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { mRecurrence->writeEvent(event); if ( event->doesRecur() ) { int addSec = -1 ; if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 ) addSec = 1; event->setRecurrenceID( event->dtStart().addSecs( addSec ) ); event->setRecurDates(); } else { event->setHasRecurrenceID( false ); } } else { event->setHasRecurrenceID( false ); - event->recurrence()->unsetRecurs(); + if ( event->doesRecur() ) + event->recurrence()->unsetRecurs(); } } bool KOTodoEditor::validateInput() { if (!mGeneral->validateInput()) return false; if (!mDetails->validateInput()) return false; return true; } int KOTodoEditor::msgItemDelete() { return KMessageBox::warningContinueCancel(this, i18n("This item will be permanently deleted."), i18n("KOrganizer Confirmation"),i18n("Delete")); } void KOTodoEditor::modified (int modification) { if (modification == KOGlobals::CATEGORY_MODIFIED || KOGlobals::UNKNOWN_MODIFIED == modification ) // mCategoryDialog->setSelected (mTodo->categories ()); mGeneral->modified (mTodo, modification); } void KOTodoEditor::slotLoadTemplate() { QString fileName =locateLocal( "templates", "todos" ); QDir t_dir; if ( !t_dir.exists(fileName) ) t_dir.mkdir ( fileName ); fileName += "/todo"; fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); if ( fileName.length() == 0 ) return; CalendarLocal cal; ICalFormat format; if ( !format.load( &cal, fileName ) ) { KMessageBox::error( this, i18n("Error loading template file\n '%1'.") .arg( fileName ) ); return ; } QPtrList<Todo> todos = cal.todos(); Todo * todo = todos.first(); if ( !todo ) { KMessageBox::error( this, i18n("Template does not\ncontain a valid Todo.")); } else { readTodo( todo ); } } void KOTodoEditor::slotSaveTemplate() { QString fileName =locateLocal( "templates", "todos" ); QDir t_dir; if ( !t_dir.exists(fileName) ) t_dir.mkdir ( fileName ); fileName += "/todo"; fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); if ( fileName.length() > 0 ) saveTemplate( fileName ); } void KOTodoEditor::saveTemplate( const QString &templateName ) { Todo *todo = new Todo; writeTodo( todo ); saveAsTemplate( todo, templateName ); } diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index fafcb58..f88403c 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp @@ -318,486 +318,486 @@ void KOWhatsNextView::updateView() mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; mText += "<ul>\n"; while (!gotone && priority<6) { todo = todos.first(); while(todo) { if (!todo->isCompleted() && (todo->priority() == priority) ) { mCurrentMaxPrio = priority - priosFound + topmostPrios -1; if ( appendTodo(todo) ) gotone = true; } todo = todos.next(); } if ( gotone ) { gotone = false; ++priosFound; if ( priosFound == topmostPrios ) break; } priority++; // kdDebug() << "adding the todos..." << endl; } mText += "</ul>\n"; } int replys = 0; events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); if (events.count() > 0) { Event *ev = events.first(); while(ev) { Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); if (me!=0) { if (me->status()==Attendee::NeedsAction && me->RSVP()) { if (replys == 0) { mText += "<p></p>"; // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); //mText += "<h2>"; //<img src=\""; // mText += ipath; // mText += "\">"; //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; mText += "<table>\n"; } replys++; appendEvent(ev,true); } } ev = events.next(); } } todos = calendar()->todos(); if (todos.count() > 0) { Todo *to = todos.first(); while(to) { if ( !to->isCompleted() ){ Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); if (me!=0) { if (me->status()==Attendee::NeedsAction && me->RSVP()) { if (replys == 0) { mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; mText += "<table>\n"; } replys++; appendEvent(to, true); } } } to = todos.next(); } } if (replys > 0 ) mText += "</table>\n"; mText += "</td></tr>\n</table>\n"; mView->setText(mText); mView->setFocus(); // QPixmap bPix = SmallIcon( "back" ); // qDebug("xxxxxxxxxxxxxxxxxxxxx "); // QWidget* test = new QWidget(); // test->setBackgroundMode(FixedPixmap ); // test->setBackgroundPixmap ( bPix ); // test->resize( 300, 400 ); // test->show(); // mView->setBackgroundMode(FixedPixmap ); // mView->setBackgroundPixmap ( bPix ); // qDebug("%s ",mText.latin1()); } void KOWhatsNextView::appendDay( int i, QDate eventDate ) { QString date; QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { if ( i == 0 ) { //mText += "<table>\n"; return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; } else if ( i == 1 ) date = "<em><font color=\"#000080\">" + day + "</font></em>" ; else date = "<em><font color=\"#000080\">" + day + "</font></em>"; mText += "<h2>" + date + "</h2>\n"; //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; mText += "<table>\n"; } else { if ( i == 0 ) { //mText += "<table>\n"; return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; } #ifdef DESKTOP_VERSION else if ( i == 1 ) { date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; } else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; #else else if ( i == 1 ) { date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; } else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; #endif mText += "<h2>" + date + "</h2>\n"; //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; mText += "<table>\n"; } } void KOWhatsNextView::showDates(const QDate &, const QDate &) { updateView(); } void KOWhatsNextView::showEvents(QPtrList<Event>) { } void KOWhatsNextView::changeEventDisplay(Event *, int action) { switch(action) { case KOGlobals::EVENTADDED: updateView(); break; case KOGlobals::EVENTEDITED: updateView(); break; case KOGlobals::EVENTDELETED: updateView(); break; default: updateView(); kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; } } bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) { if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) return false; QDateTime cdt = QDateTime::currentDateTime(); QDateTime noc; QString tempText; if ( appendTable && !notRed ) { tempText = "<table>"; } bool ok = true; if ( reply ) { noc = ev->getNextOccurence( cdt, &ok ); if (! ok && ev->typeID() == eventID) return false; } bool bDay = false; if ( ev->isBirthday() || ev->isAnniversary() ) bDay = true; tempText += "<tr><td><b>"; if (ev->typeID() == eventID ) { if (reply) { if (!ev->doesFloat()) tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; else tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; } else { if (!ev->doesFloat()) { Event *event = static_cast<Event *>(ev); QDateTime st,end; - if ( event->recurrence()->doesRecur() ) { + if ( event->doesRecur() ) { QDate recDate= mEventDate; int days = event->dtStart().date().daysTo (event->dtEnd().date() ); while ( ! event->recursOn( recDate ) ) { recDate = recDate.addDays( -1 ); } st = QDateTime ( recDate, event->dtStart().time() ); end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); } else { st = event->dtStart(); end = event->dtEnd(); } QString dateText; // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); if ( st.date() < mEventDate ) dateText = "++:++-"; else dateText = event->dtStartTimeStr() + "-"; if ( KOPrefs::instance()->mWhatsNextTime2Lines ) dateText += " "; if ( end.date() > mEventDate ) dateText += "++:++"; else dateText += event->dtEndTimeStr(); if ( notRed ) tempText += dateText; else { if ( end < cdt ) { if ( !KOPrefs::instance()->mWNViewShowsPast ) return false; tempText += "<font color=\"#F00000\">" + dateText + "</font>"; } else if ( st < cdt ) tempText += "<font color=\"#008000\">" + dateText + "</font>"; else tempText += dateText; } } else { if ( bDay ) { if ( ev->isBirthday()) tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>"; else tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>"; } else { if ( ((Event*)ev)->isMultiDay() ) { QString dfs = KGlobal::locale()->dateFormatShort(); KGlobal::locale()->setDateFormatShort("%d.%b"); tempText +=KGlobal::locale()->formatDate(((Event*)ev)->dtStart().date(), true, KLocale::Userdefined) + "-"; if ( KOPrefs::instance()->mWhatsNextTime2Lines ) tempText += " "; tempText +=KGlobal::locale()->formatDate(((Event*)ev)->dtEnd().date(), true, KLocale::Userdefined); KGlobal::locale()->setDateFormatShort(dfs); } else { tempText += " " ;//i18n("Allday:"); } } } } } else { mTodos.append( ev ); tempText += i18n("ToDo:"); if ( KOPrefs::instance()->mWhatsNextTime2Lines ) tempText += " "; if (reply) { tempText += " "; if ( noc != cdt ) { tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; } } else { if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; QString dfs = KGlobal::locale()->dateFormatShort(); KGlobal::locale()->setDateFormatShort("%d.%b"); tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; KGlobal::locale()->setDateFormatShort(dfs); } else { if (!ev->doesFloat() ) if( ( (Todo*)ev)->dtDue() < cdt ) { tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; } else tempText +=((Todo*)ev)->dtDueTimeStr(); mTodos.append( ev ); } } } tempText += "</b></td><td>"; bool needClose = false; if ( ev->cancelled() ) { tempText += "<font color=\"#F00000\">[c"; needClose =true; } if ( ev->isAlarmEnabled() && ev->alarmEnabled()) { if ( !needClose) tempText +="["; tempText += "a"; needClose =true; } if ( ev->description().length() > 0 ) { if ( !needClose) tempText +="["; tempText += "i"; needClose =true; } - if ( ev->recurrence()->doesRecur() ) { + if ( ev->doesRecur() ) { if ( !needClose) tempText +="["; tempText += "r"; needClose =true; } if ( needClose ) { tempText += "] "; } if ( ev->cancelled() ) tempText += "</font>"; tempText += "<a "; if (ev->typeID() == eventID ) tempText += "href=\"event:"; if (ev->typeID() == todoID ) tempText += "href=\"todo:"; tempText += ev->uid() + "\">"; if ( ev->summary().length() > 0 ) tempText += ev->summary(); else tempText += i18n("-no summary-"); if ( bDay ) { noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); if ( ok ) { int years = 0; if ( ev->typeID() == todoID ) { years = noc.date().year() -((Todo*)ev)->dtDue().date().year(); } else years = noc.date().year() - ev->dtStart().date().year(); tempText += i18n(" (%1 y.)"). arg( years ); } } tempText += "</a>"; if ( KOPrefs::instance()->mWNViewShowLocation ) if ( !ev->location().isEmpty() ) tempText += " ("+ev->location() +")"; if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) tempText += " ["+ev->relatedTo()->summary() +"]"; tempText += "</td></tr>\n"; mText += tempText; return true; } bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) { if ( mTodos.find( ev ) != mTodos.end() ) return false; mTodos.append( ev ); if ( !isSub ) mText += "<p>"; else mText += "<li>"; mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; mText += ind; bool needClose = false; if ( ev->cancelled() ) { mText += "<font color=\"#F00000\">[c"; needClose =true; } if ( ev->isAlarmEnabled() && ev->alarmEnabled() ) { if ( !needClose) mText +="["; mText += "a"; needClose =true; } if ( ev->description().length() > 0 ) { if ( !needClose) mText +="["; mText += "i"; needClose =true; } if ( ev->doesRecur() ) { if ( !needClose) mText +="["; mText += "r"; needClose =true; } // if ( ev->recurrence()->doesRecur() ) { // if ( !needClose) // mText +="("; // mText += "r"; // needClose =true; // } if ( needClose ) mText += "] "; if ( ev->cancelled() ) mText += "</font>"; mText += "<a href=\"todo:" + ev->uid() + "\">"; if ( ev->summary().length() > 0 ) mText += ev->summary(); else mText += i18n("-no summary-"); mText += "</a>"; if ( ((Todo*)ev)->hasDueDate () ) { QString year = ""; int ye = ((Todo*)ev)->dtDue().date().year(); if ( QDateTime::currentDateTime().date().year() != ye ) year = QString::number( ye ); QString dfs = KGlobal::locale()->dateFormatShort(); KGlobal::locale()->setDateFormatShort("%d.%b"); mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; KGlobal::locale()->setDateFormatShort(dfs); } if ( KOPrefs::instance()->mWNViewShowLocation ) if ( !ev->location().isEmpty() ) mText += " ("+ev->location() +")"; if ( !isSub ) { if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) mText += " ["+ev->relatedTo()->summary() +"]"; mText += "</p>\n"; } else { ind += "-"; mText += "</li>\n"; } QPtrList<Incidence> Relations = ev->relations(); Incidence *to; for (to=Relations.first();to;to=Relations.next()) { if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio ) appendTodo( to, ind , true ); } return true; } /* void KOWhatsNextView::createEventViewer() { if (!mEventViewer) { mEventViewer = new KOEventViewerDialog(this); } } */ void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) { mEventViewer = v; } // TODO: Create this function in CalendarView and remove it from here void KOWhatsNextView::showIncidence(const QString &uid) { if ( !mEventViewer ) { qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); return; } //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); if (uid.startsWith("event:")) { #ifdef DESKTOP_VERSION Event *event = calendar()->event(uid.mid(8)); #else Event *event = calendar()->event(uid.mid(6)); #endif //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); if (!event) return; //createEventViewer(); mEventViewer->setEvent(event); } else if (uid.startsWith("todo:")) { #ifdef DESKTOP_VERSION Todo *todo = calendar()->todo(uid.mid(7)); #else Todo *todo = calendar()->todo(uid.mid(5)); #endif if (!todo) return; //createEventViewer(); mEventViewer->setTodo(todo); } else { return; } mEventViewer->showMe(); mEventViewer->raise(); } |