-rw-r--r-- | korganizer/calendarview.cpp | 80 | ||||
-rw-r--r-- | korganizer/calendarview.h | 4 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 71 |
3 files changed, 126 insertions, 29 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index bc1c0c7..9a114d0 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -656,2 +656,68 @@ CalendarView::~CalendarView() } +void CalendarView::nextConflict( bool all, bool allday ) +{ + QDate start = mNavigator->selectedDates().first().addDays(1); + QDate end = start.addDays( 365*2); + while ( start < end ) { + QPtrList<Event> eventList = calendar()->events( start ); + Event * ev = eventList.first(); + QPtrList<Event> test = eventList; + while ( ev ) { + //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); + Event * t_ev = test.first(); + QDateTime es = ev->dtStart(); + QDateTime ee = ev->dtEnd(); + if ( ev->doesFloat() ) + ee = ee.addDays( 1 ); + if ( ! all ) { + if ( ev->doesFloat() != allday ) + t_ev = 0; + } + while ( t_ev ) { + bool skip = false; + if ( ! all ) { + if ( t_ev->doesFloat() != allday ) + skip = true; + } + if ( !skip && ev != t_ev ) { + QDateTime ets = t_ev->dtStart(); + QDateTime ete = t_ev->dtEnd(); + if ( t_ev->doesFloat() ) + ete = ete.addDays( 1 ); + //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); + if ( es < ete && ets < ee ) { + if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) + mViewManager->showDayView(); + mNavigator->slotDaySelect( start ); + int hour = es.time().hour(); + if ( ets > es ) + hour = ets.time().hour(); + mViewManager->agendaView()->setStartHour( hour ); + topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); + return; + } + } + t_ev = test.next(); + } + ev = eventList.next(); + } + start = start.addDays( 1 ); + } + topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); + qDebug("No conflict found "); +} + +void CalendarView::conflictAll() +{ + nextConflict ( true, true ); +} +void CalendarView::conflictAllday() +{ + nextConflict ( false, true ); +} +void CalendarView::conflictNotAll() +{ + nextConflict ( false, false ); +} + void CalendarView::setCalReadOnly( int id, bool readO ) @@ -3164,3 +3230,3 @@ void CalendarView::cloneIncidence(Incidence * orgInc ) int result = KMessageBox::warningYesNoCancel(this, - i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), + i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), i18n("Todo has subtodos"), @@ -3502,3 +3568,3 @@ void CalendarView::deleteTodo(Todo *todo) if (KOPrefs::instance()->mConfirm) { - QString text = todo->summary().left(20); + QString text = KGlobal::formatMessage ( todo->summary(),0 ); if (!todo->relations().isEmpty()) { @@ -3548,3 +3614,3 @@ void CalendarView::deleteJournal(Journal *jour) } - switch (msgItemDelete( i18n("Journal:") +"\n"+des.left(20))) { + switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { case KMessageBox::Continue: // OK @@ -3574,3 +3640,3 @@ void CalendarView::deleteEvent(Event *anEvent) if (KOPrefs::instance()->mConfirm) { - km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + + 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?"), @@ -3582,3 +3648,3 @@ void CalendarView::deleteEvent(Event *anEvent) } else { - km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + + 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")+ @@ -3623,3 +3689,3 @@ void CalendarView::deleteEvent(Event *anEvent) if (KOPrefs::instance()->mConfirm) { - switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + + switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + i18n("\nAre you sure you want\nto delete this event?"), @@ -4582,3 +4648,3 @@ void CalendarView::undo_delete() } - if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + + if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + i18n("\nAre you sure you want\nto restore this?"), diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index a5f230a..51eb1d4 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -202,2 +202,6 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser public slots: + void nextConflict( bool all, bool allday ); + void conflictAll(); + void conflictAllday(); + void conflictNotAll(); void setCalReadOnly( int id, bool readO ); diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 9c2ac82..bfae1b5 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -661,2 +661,3 @@ void MainWindow::initActions() mCurrentItemMenu = new QPopupMenu ( this ); + QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); QPopupMenu *importMenu = new QPopupMenu( this ); @@ -791,11 +792,38 @@ void MainWindow::initActions() mView->dialogManager(), SLOT( showSearchDialog() ) ); + actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); + action = new QAction( "Undo Delete", i18n("All events"), 0, this ); + action->addTo( nextConflictMenu ); + connect( action, SIGNAL( activated() ), + mView, SLOT( conflictAll() ) ); + + action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); + action->addTo( nextConflictMenu ); + connect( action, SIGNAL( activated() ), + mView, SLOT( conflictAllday() ) ); + + action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); + action->addTo( nextConflictMenu ); + connect( action, SIGNAL( activated() ), + mView, SLOT( conflictNotAll() ) ); + actionMenu->insertSeparator(); + icon = loadPixmap( pathString + "newevent" ); + QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); + ne_action->addTo( mCurrentItemMenu ); + connect( ne_action, SIGNAL( activated() ), + mView, SLOT( newEvent() ) ); + icon = loadPixmap( pathString + "newtodo" ); + configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); + QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); + nt_action->addTo( mCurrentItemMenu ); + connect( nt_action, SIGNAL( activated() ), + mView, SLOT( newTodo() ) ); + mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, + this ); + mNewSubTodoAction->addTo( mCurrentItemMenu ); + connect( mNewSubTodoAction, SIGNAL( activated() ), + mView, SLOT( newSubTodo() ) ); - - action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); - action->addTo( mCurrentItemMenu ); - connect( action, SIGNAL( activated() ), - mView, SLOT( undo_delete() ) ); mCurrentItemMenu->insertSeparator(); @@ -846,14 +874,8 @@ void MainWindow::initActions() - QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); - ne_action->addTo( actionMenu ); - connect( ne_action, SIGNAL( activated() ), - mView, SLOT( newEvent() ) ); - icon = loadPixmap( pathString + "newtodo" ); - configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); - QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); - nt_action->addTo( actionMenu ); - connect( nt_action, SIGNAL( activated() ), - mView, SLOT( newTodo() ) ); - - + + mCurrentItemMenu->insertSeparator(); + action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); + action->addTo( mCurrentItemMenu ); + connect( action, SIGNAL( activated() ), + mView, SLOT( undo_delete() ) ); @@ -998,7 +1020,3 @@ void MainWindow::initActions() - mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, - this ); - mNewSubTodoAction->addTo( actionMenu ); - connect( mNewSubTodoAction, SIGNAL( activated() ), - mView, SLOT( newSubTodo() ) ); + @@ -1567,2 +1585,3 @@ void MainWindow::keyBindings() i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ + i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ @@ -2101,2 +2120,10 @@ void MainWindow::keyPressEvent ( QKeyEvent * e ) break; + case Qt::Key_Q: + if ( e->state() == Qt::ControlButton ) + mView->conflictNotAll(); + else if ( e->state() == Qt::ShiftButton ) + mView->conflictAllday(); + else + mView->conflictAll(); + break; case Qt::Key_J: |