summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-07 20:46:00 (UTC)
committer zautrix <zautrix>2005-07-07 20:46:00 (UTC)
commitde5621f2fd3924f27c05459ae555b3bd06c5e584 (patch) (side-by-side diff)
tree589d19415e3c0ff6c08cec375db145242581c143
parent766b53919de14b8faec22db32b6a750acde0b760 (diff)
downloadkdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.zip
kdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.tar.gz
kdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt13
-rw-r--r--korganizer/calendarview.cpp153
-rw-r--r--korganizer/kotodoview.cpp16
-rw-r--r--libkcal/event.cpp115
-rw-r--r--libkcal/event.h2
-rw-r--r--libkcal/incidencebase.cpp8
-rw-r--r--libkcal/incidencebase.h4
7 files changed, 243 insertions, 68 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt
index b225594..43bc343 100644
--- a/bin/kdepim/korganizer/germantranslation.txt
+++ b/bin/kdepim/korganizer/germantranslation.txt
@@ -1456,65 +1456,62 @@
{ "Cancel - do not start"," Abbrechen - Todo nicht starten" },
{ "The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n"How do I change the timezone?"\nas well!","Die Zeitzone wurde geändert!\nSollen die Kalender neu geladen\nwerden num die Zeiten\nder Termine zu ändern?\nBitte lesen Sie auch\nMenu: Help->FAQ:\n"How do I change the timezone?"" },
{ "Reload","Neu laden" },
{ "Timezone settings","Zeitzoneneinstellung" },
{ "Title: ","Titel: " },
{ "Journal from: ","Journal vom: " },
{ "Journal: %1 from ","Journal: %1 vom " },
{ "<b>Click here to edit categories: </b>","<b>Klicke hier um Kategorien zu ändern: </b>" },
{ "Selected Item","Ausgewähltes Item" },
{ "Select Date...","Wähle Datum..." },
{ "After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:","Nach dem Importieren/Laden/Syncen kann es neue Kategorien in den Terminen oder Todos geben, die nicht automatisch der Kategorieliste hinzugefügt werden. Bitte wählen Sie, was <b>jetzt</b> passieren soll:" },
{ "Change category list now!","Ändere Kategorieliste jetzt!" },
{ "Edit category list...","Ändere Kategorieliste..." },
{ "Toolbar changes needs a restart!","Neustart benötigt für Toolbaränderungen!" },
{ "Filepath: ","Dateipfad: " },
{ "You can try to reload the calendar in the Resource View!","In der Resourcenansicht können Sie erneut versuchen den Kalender zu laden!" },
{ "<b>WARNING:</b> There is a pending suspended alarm!","<b>WARNUNG:</b> Es gibt einen laufenden Suspendalarm!" },
{ "Pending Suspend Alarm","Laufender Suspend Alarm" },
{ "Error loading calendar %1","Fehler beim Laden von Kalender %1" },
{ "Calendar(s) not loaded:","Nicht geladene(r) Kalender:" },
{ "Loding of calendar(s) failed","Laden von Kalendern fehlgeschlagen" },
{ "Alarm Options","Alarm Einstellungen" },
{ "Delete selected...","Lösche Ausgewählte..." },
{ "None","Nichts" },
{ "Selection","Auswahl" },
{ "Set categories","Setze Kategorien" },
{ "This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!","Das fügt die ausgewählten\nEinträge dem Kalender\n%1\nhinzu und entfernt sie von\nihrem aktuellen Kalender!" },
{ "Reset","Neu setzen" },
{ "Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?","Möchten Sie Kategorien zu den ausgewählten Einträgen <b>hinzufügen</b> oder die Liste <b>neu setzen</b> (d.h. vorhandene Kategorien löschen)?" },
{ "The file\n%1\ndoes not exist!\nShall I create it for you?","Die Datei\n%1\nexistiert nicht!\nSoll sie neu angelegt werden?" },
{ "Sorry, cannot create the file\n%1!\nNo calendar added!","Kann leider die Datei\n%1\nnicht anlegen!\nKein Kalender hinzugefügt!" },
{ "\nNO\n WRITEABLE\n CALENDAR\n FOUND!\n\nPlease fix your calendar settings!\n","\nKEIN\n SCHREIBBARER\n KALENDER\n GEFUNDEN!\n\nBitte korrigieren Sie\nihre Kalendereinstellungen!\n" },
{ "\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n","\nDie Datei\n%1\nwurde verändert!\nDatei Grösse: %2 Bytes.\nZuletzt geändert: %3\nMöchten Sie:\n\n - Speichern und die Datei überschreiben?\n - Mit Datei Synchronisieren, dann speichern?\n - Abbrechen ohne zu speichern? \n" },
{ "Edit","Edit" },
{ "Last Modified","Zuletzt geändert" },
{ "Journal viewer","Journal Anzeige" },
{ "Configure Calendar Files...","Konfiguriere Kalenderdateien..." },
{ "You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>.","Sie können <b>mehr als eine</b> Kalenderdatei in KO/Pi darstellen und benutzen. Eine Kalenderdatei wird <b>Resource</b> genannt. Um einen Kalender hinzuzufügen oder die Kalendereinstellungen zu ändern benutzen Sie bitte das Menu: <b>Ansicht -> Resourcenansicht umschalten</b>." },
{ "Hide Completed","Verstecke erledigte Todos" },
{ "Show not Running","Zeige nicht Laufende" },
{ "Click to add new Todo","Klick für neues Todo!" },
{ "Show next conflict for","Zeige nächsten Konflikt für" },
{ "All events","Alle Termine" },
{ "Allday events","Ganztagestermine" },
{ "Events with time","Termine mit Zeit" },
{ "No conflict found within the next two years","Kein Konflikt innerhalb der nächsten zwei Jahre gefunden" },
{ "Conflict %1 <-> %2","Konflikt %1 <-> %2" },
{ "<p><b>Q</b>: Show next date with conflicting events\n ","<p><b>Q</b>: Zeige nächstes Datum mit Terminen im Konflikt\n " },
+{ "Week view mode uses row layout","Wochenansicht Modus nutzt Reihenlayout" },
+{ "The event\n%1\nconflicts with event\n%2\nat date\n%3.\n","Der Termin\n%1\nist im Konflikt mit Termin\n%2\nam Datum\n%3.\n" },
+{ "KO/Pi Conflict delected","KO/Pi Konflikt erkannt" },
+{ "Show date","Zeige Datum" },
+{ "No problem!","Kein Problem!" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
-{ "","" },
-{ "","" },
-{ "","" },
-{ "","" },
-{ "","" },
-
-
-
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index e766b8f..65750af 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -611,145 +611,202 @@ void CalendarView::init()
//mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
mDateFrame->setLineWidth(3);
mDateFrame->hide();
mDateFrame->setCaption( i18n( "Pick a date to display"));
mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
mEventEditor = mDialogManager->getEventEditor();
mTodoEditor = mDialogManager->getTodoEditor();
mFlagEditDescription = false;
mSuspendTimer = new QTimer( this );
mAlarmTimer = new QTimer( this );
mRecheckAlarmTimer = new QTimer( this );
connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
mAlarmDialog = new AlarmDialog( this );
connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
mAlarmDialog->setServerNotification( false );
mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
#ifndef DESKTOP_VERSION
//US listen for arriving address resultsets
connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
#endif
mDateNavigator->setCalendar( mCalendar );
}
CalendarView::~CalendarView()
{
// kdDebug() << "~CalendarView()" << endl;
//qDebug("CalendarView::~CalendarView() ");
delete mDialogManager;
delete mViewManager;
delete mStorage;
delete mDateFrame ;
delete mEventViewerDialog;
//kdDebug() << "~CalendarView() done" << endl;
}
void CalendarView::nextConflict( bool all, bool allday )
{
- QDate start = mNavigator->selectedDates().first().addDays(1);
+
+ QPtrList<Event> testlist = mCalendar->events();
+ Event * test = testlist.first();
+ while ( test ) {
+ test->setTagged( false );
+ }
+ QDateTime startDT = QDateTime (mNavigator->selectedDates().first().addDays(1), QTime ( 0,0,0));
+ QDateTime conflict;
+ QDateTime retVal;
+ bool found = false;
+ Event * cE = 0;
+ QPtrList<Event> testlist2 = testlist;
+ while ( test ) {
+ Event * test2 = testlist2.first();
+ while ( test2 ) {
+ if ( !test2->isTagged() ) {
+ if ( test->isOverlapping ( test2, &retVal, true ) ) {
+ if ( ! found ) {
+ if ( retVal >= startDT ) {
+ conflict = retVal;
+ cE = test;
+ found = true;
+ }
+ } else {
+ if ( retVal >= startDT && retVal < conflict ) {
+ conflict = retVal;
+ cE = test;
+ }
+ }
+ }
+ }
+ test2 = testlist2.next();
+ }
+ test->setTagged( true );
+ test = testlist.next();
+ }
+ if ( found ) {
+ if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
+ mViewManager->showDayView();
+ mNavigator->slotDaySelect( conflict.date() );
+ int hour = conflict.time().hour();
+ mViewManager->agendaView()->setStartHour( hour );
+ topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
+ return;
+ }
+
+ topLevelWidget()->setCaption( i18n("No conflict found within the next two years") );
+ qDebug("No conflict found ");
+ return;
+
+
+
+
+
+#if 0
+
+
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 ");
+#endif
}
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 )
{
if ( readO ) {
emit save();
}
mCalendar->setReadOnly( id, readO );
}
void CalendarView::setScrollBarStep(int val )
{
#ifdef DESKTOP_VERSION
mDateScrollBar->setLineStep ( val );
#endif
}
void CalendarView::scrollBarValue(int val )
{
#ifdef DESKTOP_VERSION
if ( QApplication::desktop()->width() < 800 ) return;
static bool block = false;
if ( block ) return;
block = true;
int count = mNavigator->selectedDates().count();
int day = mNavigator->selectedDates().first().dayOfYear();
int stepdays = val;
if ( mDateScrollBar->lineStep () <= count ) {
//val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
//qDebug("VAL %d ",val );
stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
stepdays = day+stepdays;
if ( stepdays < 0 ) stepdays = 0;
}
if ( stepdays == day ) {
block = false;
return;
@@ -2650,194 +2707,174 @@ void CalendarView::eventChanged(Event *event)
}
void CalendarView::eventAdded(Event *event)
{
changeEventDisplay(event,KOGlobals::EVENTADDED);
}
void CalendarView::eventToBeDeleted(Event *)
{
kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
}
void CalendarView::eventDeleted()
{
changeEventDisplay(0,KOGlobals::EVENTDELETED);
}
void CalendarView::changeTodoDisplay(Todo *which, int action)
{
changeIncidenceDisplay((Incidence *)which, action);
mDateNavigator->updateView(); //LR
//mDialogManager->updateSearchDialog();
if (which) {
mViewManager->updateWNview();
//mTodoList->updateView();
}
}
void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
{
updateUnmanagedViews();
//qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
if ( action == KOGlobals::EVENTDELETED ) { //delete
mCalendar->checkAlarmForIncidence( 0, true );
if ( mEventViewerDialog )
mEventViewerDialog->hide();
}
else
mCalendar->checkAlarmForIncidence( which , false );
}
// most of the changeEventDisplays() right now just call the view's
// total update mode, but they SHOULD be recoded to be more refresh-efficient.
void CalendarView::changeEventDisplay(Event *which, int action)
{
// kdDebug() << "CalendarView::changeEventDisplay" << endl;
changeIncidenceDisplay((Incidence *)which, action);
-
-
static bool clearallviews = false;
if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
if ( clearallviews ) {
clearAllViews();
clearallviews = false;
}
return;
}
clearallviews = true;
-
-
-
mDateNavigator->updateView();
//mDialogManager->updateSearchDialog();
-
if (which) {
// If there is an event view visible update the display
mViewManager->currentView()->changeEventDisplay(which,action);
// TODO: check, if update needed
// if (which->getTodoStatus()) {
mTodoList->updateView();
if ( action != KOGlobals::EVENTDELETED ) {
mConflictingEvent = which ;
QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) );
}
// }
} else {
mViewManager->currentView()->updateView();
}
}
void CalendarView::checkConflictForEvent()
{
if (!KOPrefs::instance()->mConfirm)
return;
if ( ! mConflictingEvent ) return;
if ( mConflictingEvent->doesFloat() ) {
mConflictingEvent = 0;
return;
}
- bool all = false;
- bool allday = false;
- Event * ev = mConflictingEvent;
- mConflictingEvent = 0;
- QDate start = ev->dtStart().date();
- QDate end = ev->dtEnd().date().addDays(1);
- while ( start < end ) {
- QPtrList<Event> test = calendar()->events( start );
- //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 ) {
- QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( ev->summary(),0 ) ).arg( KGlobal::formatMessage ( t_ev->summary(),0 )).arg(KGlobal::locale()->formatDate(start) ) ;
- qApp->processEvents();
- int km = KMessageBox::warningContinueCancel(this,mess,
- i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!"));
- if ( km != KMessageBox::Continue )
- return;
-
- 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;
+ QPtrList<Event> testlist = mCalendar->events();
+ Event * test = testlist.first();
+ QDateTime conflict;
+ QDateTime retVal;
+ bool found = false;
+ Event * cE = 0;
+ while ( test ) {
+ if ( !test->doesFloat() ) {
+ if ( mConflictingEvent->isOverlapping ( test, &retVal, true ) ) {
+ if ( ! found ) {
+ conflict = retVal;
+ cE = test;
+ } else {
+ if ( retVal < conflict ) {
+ conflict = retVal;
+ cE = test;
+ }
}
+ found = true;
}
- t_ev = test.next();
}
- start = start.addDays( 1 );
+ test = testlist.next();
}
- qDebug("No conflict found ");
-
+ if ( found ) {
+ QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ;
+ qApp->processEvents();
+ int km = KMessageBox::warningContinueCancel(this,mess,
+ i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!"));
+ if ( km != KMessageBox::Continue )
+ return;
+ if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
+ mViewManager->showDayView();
+ mNavigator->slotDaySelect( conflict.date() );
+ int hour = conflict.time().hour();
+ mViewManager->agendaView()->setStartHour( hour );
+ topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
+ return;
+ }
+
+ return;
+
}
void CalendarView::updateTodoViews()
{
mTodoList->updateView();
mViewManager->currentView()->updateView();
}
void CalendarView::clearAllViews()
{
mTodoList->clearList();
mViewManager->clearAllViews();
SearchDialog * sd = mDialogManager->getSearchDialog();
if ( sd ) {
KOListView* kol = sd->listview();
if ( kol )
kol->clearList();
}
}
void CalendarView::updateView()
{
static bool clearallviews = false;
if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
if ( clearallviews ) {
clearAllViews();
clearallviews = false;
}
return;
}
clearallviews = true;
DateList tmpList = mNavigator->selectedDates();
if ( KOPrefs::instance()->mHideNonStartedTodos )
mTodoList->updateView();
// We assume that the navigator only selects consecutive days.
updateView( tmpList.first(), tmpList.last() );
}
void CalendarView::updateUnmanagedViews()
{
mDateNavigator->updateDayMatrix();
}
int CalendarView::msgItemDelete(const QString name)
{
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 2c017e1..c2ad886 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -357,96 +357,100 @@ void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
void KOTodoListView::paintEvent(QPaintEvent* e)
{
emit paintNeeded();
QListView::paintEvent( e);
}
void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
{
#ifndef KORG_NODND
//QListView::contentsMouseMoveEvent(e);
if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
QApplication::startDragDistance()*3) {
mMousePressed = false;
QListViewItem *item = itemAt(contentsToViewport(mPressPos));
if (item) {
DndFactory factory( mCalendar );
ICalDrag *vd = factory.createDrag(
((KOTodoViewItem *)item)->todo(),viewport());
internalDrop = false;
// we cannot do any senseful here, because the DnD is still broken in Qt
if (vd->drag()) {
if ( !internalDrop ) {
//emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
qDebug("Dnd: External move: Delete drag source ");
} else
qDebug("Dnd: Internal move ");
} else {
if ( !internalDrop ) {
qDebug("Dnd: External Copy");
} else
qDebug("DnD: Internal copy: Copy pending");
}
}
}
#endif
}
void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
{
if ( !e->isAutoRepeat() ) {
mFlagKeyPressed = false;
}
}
void KOTodoListView::keyPressEvent ( QKeyEvent * e )
{
qApp->processEvents();
+ if ( !isVisible() ) {
+ e->ignore();
+ return;
+ }
if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
e->ignore();
// qDebug(" ignore %d",e->isAutoRepeat() );
return;
}
if (! e->isAutoRepeat() )
mFlagKeyPressed = true;
QListViewItem* cn;
if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
cn = currentItem();
if ( cn ) {
KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
if ( ci ){
if ( e->state() == ShiftButton )
ci->setOn( false );
else
ci->setOn( true );
cn = cn->itemBelow();
if ( cn ) {
setCurrentItem ( cn );
ensureItemVisible ( cn );
}
}
}
return;
}
if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
switch ( e->key() ) {
case Qt::Key_Down:
case Qt::Key_Up:
QListView::keyPressEvent ( e );
break;
case Qt::Key_Left:
case Qt::Key_Right:
QListView::keyPressEvent ( e );
e->accept();
return;
break;
default:
e->ignore();
break;
}
return;
}
e->ignore();
@@ -1554,104 +1558,114 @@ void KOTodoView::toggleCompleted()
{
KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
updateView();
if ( KOPrefs::instance()->mShowCompletedTodo )
topLevelWidget()->setCaption(i18n("Show Completed"));
else
topLevelWidget()->setCaption(i18n("Hide Completed"));
}
void KOTodoView::addQuickTodo()
{
addQuickTodoPar( 0 );
}
void KOTodoView::addQuickTodoPar( Todo * parentTodo)
{
Todo *todo = new Todo();
todo->setSummary(mQuickAdd->text());
todo->setOrganizer(KOPrefs::instance()->email());
if ( parentTodo ) {
todo->setRelatedTo(parentTodo);
todo->setCategories (parentTodo->categoriesStr ());
todo->setSecrecy (parentTodo->secrecy ());
if ( parentTodo->priority() < 3 )
todo->setPriority( parentTodo->priority() );
todo->setCalID( parentTodo->calID() );
} else {
CalFilter * cf = mCalendar->filter();
if ( cf ) {
if ( cf->isEnabled()&& cf->showCategories()) {
todo->setCategories(cf->categoryList());
}
if ( cf->isEnabled() )
todo->setSecrecy( cf->getSecrecy());
}
}
mCalendar->addTodo(todo);
mQuickAdd->setText("");
todoModified (todo, KOGlobals::EVENTADDED );
updateView();
}
void KOTodoView::keyPressEvent ( QKeyEvent * e )
{
// e->ignore();
//return;
- //qDebug("KOTodoView::keyPressEvent ");
+ //qDebug("KOTodoView::keyPressEvent ");
+ if ( !isVisible() ) {
+ e->ignore();
+ return;
+ }
switch ( e->key() ) {
case Qt::Key_Down:
case Qt::Key_Up:
QWidget::keyPressEvent ( e );
break;
case Qt::Key_Q:
+
+
+ if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) {
+ e->ignore();
+ break;
+ }
toggleQuickTodo();
break;
case Qt::Key_U:
if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
unparentTodo();
e->accept();
} else
e->ignore();
break;
case Qt::Key_S:
if ( e->state() == Qt::ControlButton ) {
e->ignore();
break;
}
if ( e->state() == Qt::ShiftButton ) {
mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
reparentTodo();
e->accept();
} else
e->ignore();
break;
case Qt::Key_P:
if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
if ( pendingSubtodo )
itemClicked(mActiveItem);
e->accept();
} else
e->ignore();
break;
case Qt::Key_Escape:
if ( pendingSubtodo ) {
itemClicked(0);
e->accept();
} else
e->ignore();
break;
default:
e->ignore();
}
if ( true ) {
if ( e->key() == Qt::Key_I ) {
KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
if ( cn ) {
mActiveItem = cn;
KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 7cd81fa..235ae55 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -126,96 +126,211 @@ QDateTime Event::dtEnd() const
QString Event::dtEndTimeStr() const
{
return KGlobal::locale()->formatTime(mDtEnd.time());
}
QString Event::dtEndDateStr(bool shortfmt) const
{
return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt);
}
QString Event::dtEndStr(bool shortfmt) const
{
return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt);
}
void Event::setHasEndDate(bool b)
{
mHasEndDate = b;
}
bool Event::hasEndDate() const
{
return mHasEndDate;
}
bool Event::isMultiDay() const
{
bool multi = !(dtStart().date() == dtEnd().date());
return multi;
}
void Event::setTransparency(Event::Transparency transparency)
{
if (mReadOnly) return;
mTransparency = transparency;
updated();
}
Event::Transparency Event::transparency() const
{
return mTransparency;
}
void Event::setDuration(int seconds)
{
setHasEndDate(false);
Incidence::setDuration(seconds);
}
+bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, bool inFutureOnly )
+{
+ if ( testEvent == this )
+ return false;
+ if ( ! doesRecur() && !testEvent->doesRecur() ) {
+ QDateTime te;
+ if ( testEvent->doesFloat() )
+ te = testEvent->mDtEnd.addDays( 1 );
+ else
+ te = testEvent->mDtEnd;
+ QDateTime e;
+ if ( doesFloat() )
+ e = mDtEnd.addDays( 1 );
+ else
+ e = mDtEnd;
+ if ( mDtStart < te && testEvent->mDtStart < e ) {
+ if ( mDtStart < testEvent->mDtStart )
+ *overlapDT = testEvent->mDtStart;
+ else
+ *overlapDT = mDtStart;
+ if ( inFutureOnly )
+ return (*overlapDT >= QDateTime::currentDateTime() );
+ return true;
+ }
+ return false;
+ }
+ Event *nonRecur = 0;
+ Event *recurEvent = 0;
+ if ( ! doesRecur() ) {
+ nonRecur = this;
+ recurEvent = testEvent;
+ }
+ else if ( !testEvent->doesRecur() ) {
+ nonRecur = testEvent;
+ recurEvent = this;
+ }
+ if ( nonRecur ) {
+ QDateTime enr;
+ if ( nonRecur->doesFloat() )
+ enr = nonRecur->mDtEnd.addDays( 1 );
+ else
+ enr = nonRecur->mDtEnd;
+ if ( enr < recurEvent->mDtStart )
+ return false;
+ if ( inFutureOnly && enr < QDateTime::currentDateTime() )
+ return false;
+ int recDuration = recurEvent->mDtStart.secsTo( recurEvent->mDtEnd );
+ if ( recurEvent->doesFloat() )
+ recDuration += 86400;
+ bool ok = true;
+ QDateTime recStart = recurEvent->mDtStart.addSecs( -300);;
+ while ( ok ) {
+ recStart = recurEvent->getNextOccurence( recStart.addSecs( 60 ), &ok );
+ if ( ok ) {
+ if ( recStart > enr )
+ return false;
+ QDateTime recEnd = recStart.addSecs( recDuration );
+ if ( nonRecur->mDtStart < recEnd && recStart < nonRecur->mDtEnd ) {
+ if ( nonRecur->mDtStart < recStart )
+ *overlapDT = recStart;
+ else
+ *overlapDT = nonRecur->mDtStart;
+ if ( inFutureOnly ) {
+ if ( *overlapDT >= QDateTime::currentDateTime() )
+ return true;
+ } else
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ QDateTime incidenceStart = mDtStart;
+ int duration = mDtStart.secsTo( mDtEnd );
+ if ( doesFloat() )
+ duration += 86400;
+ QDateTime testincidenceStart = testEvent->mDtStart;
+ int testduration = testEvent->mDtStart.secsTo( testEvent->mDtEnd );
+ if ( testEvent->doesFloat() )
+ testduration += 86400;
+ bool computeThis = false;
+ if ( incidenceStart < testincidenceStart )
+ computeThis = true;
+ bool ok = true;
+ if ( computeThis )
+ incidenceStart = incidenceStart.addSecs( -300 );
+ else
+ testincidenceStart = testincidenceStart.addSecs( -300 );
+ int count = 0;
+ while ( ok ) {
+ ++count;
+ if ( count > 1000 ) break;
+ if ( computeThis )
+ incidenceStart = getNextOccurence( incidenceStart.addSecs( 60 ), &ok );
+ else
+ testincidenceStart = testEvent->getNextOccurence( testincidenceStart.addSecs( 60 ), &ok );
+ if ( ok ) {
+ if ( incidenceStart < testincidenceStart.addSecs( testduration ) && testincidenceStart < incidenceStart.addSecs( duration ) ) {
+ if ( incidenceStart < testincidenceStart )
+ *overlapDT = testincidenceStart;
+ else
+ *overlapDT = incidenceStart;
+ if ( inFutureOnly ) {
+ if ( *overlapDT >= QDateTime::currentDateTime() )
+ return true;
+ } else
+ return true;
+ }
+ computeThis = ( incidenceStart < testincidenceStart );
+ }
+
+ }
+ return false;
+}
QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
{
*ok = false;
if ( !alarmEnabled() )
return QDateTime ();
bool yes;
QDateTime incidenceStart = getNextOccurence( start_dt, &yes );
if ( ! yes || cancelled() ) {
*ok = false;
return QDateTime ();
}
bool enabled = false;
Alarm* alarm;
int off = 0;
QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
// if ( QDateTime::currentDateTime() > incidenceStart ){
// *ok = false;
// return incidenceStart;
// }
for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
if (alarm->enabled()) {
if ( alarm->hasTime () ) {
if ( alarm->time() < alarmStart ) {
alarmStart = alarm->time();
enabled = true;
off = alarmStart.secsTo( incidenceStart );
}
} else {
int secs = alarm->startOffset().asSeconds();
if ( incidenceStart.addSecs( secs ) < alarmStart ) {
alarmStart = incidenceStart.addSecs( secs );
enabled = true;
off = -secs;
}
}
}
}
if ( enabled ) {
if ( alarmStart > start_dt ) {
*ok = true;
* offset = off;
return alarmStart;
}
}
*ok = false;
return QDateTime ();
diff --git a/libkcal/event.h b/libkcal/event.h
index 287d403..80c11c4 100644
--- a/libkcal/event.h
+++ b/libkcal/event.h
@@ -29,63 +29,65 @@ namespace KCal {
/**
This class provides an Event in the sense of RFC2445.
*/
class Event : public Incidence
{
public:
enum Transparency { Opaque, Transparent };
typedef ListBase<Event> List;
Event();
Event(const Event &);
~Event();
QCString type() const { return "Event"; }
IncTypeID typeID() const { return eventID; }
Incidence *clone();
QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const;
/** for setting an event's ending date/time with a QDateTime. */
void setDtEnd(const QDateTime &dtEnd);
/** Return the event's ending date/time as a QDateTime. */
virtual QDateTime dtEnd() const;
/** returns an event's end time as a string formatted according to the
users locale settings */
QString dtEndTimeStr() const;
/** returns an event's end date as a string formatted according to the
users locale settings */
QString dtEndDateStr(bool shortfmt=true) const;
/** returns an event's end date and time as a string formatted according
to the users locale settings */
QString dtEndStr(bool shortfmt=true) const;
void setHasEndDate(bool);
/** Return whether the event has an end date/time. */
bool hasEndDate() const;
/** Return true if the event spans multiple days, otherwise return false. */
bool isMultiDay() const;
/** set the event's time transparency level. */
void setTransparency(Transparency transparency);
/** get the event's time transparency level. */
Transparency transparency() const;
void setDuration(int seconds);
bool contains ( Event*);
+ bool isOverlapping ( Event*, QDateTime*, bool inFutureOnly );
+
private:
bool accept(Visitor &v) { return v.visit(this); }
QDateTime mDtEnd;
bool mHasEndDate;
Transparency mTransparency;
};
bool operator==( const Event&, const Event& );
}
#endif
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 96039df..dcead02 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -94,96 +94,104 @@ bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
while ( a1 ) {
if ( !( (*a1) == (*a2)) )
{
//qDebug("Attendee not equal ");
return false;
}
a1 = i1.attendees().next();
a2 = i2.attendees().next();
}
}
//if ( i1.dtStart() != i2.dtStart() )
// return false;
#if 0
qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
qDebug("1 %d ",i1.duration() == i2.duration() );
qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
qDebug("6 %d ",i1.organizer() == i2.organizer() );
#endif
if ( i1.hasDuration() == i2.hasDuration() ) {
if ( i1.hasDuration() ) {
if ( i1.duration() != i2.duration() )
return false;
}
} else {
return false;
}
return ( i1.organizer() == i2.organizer() &&
// i1.uid() == i2.uid() &&
// Don't compare lastModified, otherwise the operator is not
// of much use. We are not comparing for identity, after all.
i1.doesFloat() == i2.doesFloat() &&
i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
// no need to compare mObserver
}
QDateTime IncidenceBase::getEvenTime( QDateTime dt )
{
QTime t = dt.time();
dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
return dt;
}
+bool IncidenceBase::isTagged() const
+{
+ return mIsTagged;
+}
+void IncidenceBase::setTagged( bool b)
+{
+ mIsTagged = b;
+}
void IncidenceBase::setCalID( int id )
{
if ( mCalID > 0 )
updated();
mCalID = id;
}
int IncidenceBase::calID() const
{
return mCalID;
}
void IncidenceBase::setCalEnabled( bool b )
{
mCalEnabled = b;
}
bool IncidenceBase::calEnabled() const
{
return mCalEnabled;
}
void IncidenceBase::setAlarmEnabled( bool b )
{
mAlarmEnabled = b;
}
bool IncidenceBase::alarmEnabled() const
{
return mAlarmEnabled;
}
void IncidenceBase::setUid(const QString &uid)
{
mUid = uid;
updated();
}
QString IncidenceBase::uid() const
{
return mUid;
}
void IncidenceBase::setLastModified(const QDateTime &lm)
{
// DON'T! updated() because we call this from
// Calendar::updateEvent().
mLastModified = getEvenTime(lm);
//qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
}
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index dc6024a..bccf287 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -102,82 +102,84 @@ class IncidenceBase : public CustomProperties
Add Attendee to this incidence. IncidenceBase takes ownership of the
Attendee object.
*/
bool addAttendee(Attendee *a, bool doupdate=true );
// void removeAttendee(Attendee *a);
// void removeAttendee(const char *n);
/** Remove all Attendees. */
void clearAttendees();
/** Return list of attendees. */
QPtrList<Attendee> attendees() const { return mAttendees; };
/** Return number of attendees. */
int attendeeCount() const { return mAttendees.count(); };
/** Return the Attendee with this email */
Attendee* attendeeByMail(const QString &);
/** Return first Attendee with one of this emails */
Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null);
/** pilot syncronization states */
enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
/** Set synchronisation satus. */
void setSyncStatus(int stat);
/** Return synchronisation status. */
int syncStatus() const;
/** Set Pilot Id. */
void setPilotId(int id);
/** Return Pilot Id. */
int pilotId() const;
void setTempSyncStat(int id);
int tempSyncStat() const;
void setIDStr( const QString & );
QString IDStr() const;
void setID( const QString &, const QString & );
QString getID( const QString & );
void setCsum( const QString &, const QString & );
QString getCsum( const QString & );
void removeID(const QString &);
void registerObserver( Observer * );
void unRegisterObserver( Observer * );
void updated();
void setCalID( int id );
int calID() const;
void setCalEnabled( bool );
bool calEnabled() const;
void setAlarmEnabled( bool );
bool alarmEnabled() const;
-
+ bool isTagged() const;
+ void setTagged( bool );
protected:
+ bool mIsTagged;
QDateTime mDtStart;
bool mReadOnly;
QDateTime getEvenTime( QDateTime );
private:
// base components
QString mOrganizer;
QString mUid;
int mCalID;
bool mCalEnabled;
bool mAlarmEnabled;
QDateTime mLastModified;
QPtrList<Attendee> mAttendees;
bool mFloats;
int mDuration;
bool mHasDuration;
QString mExternalId;
int mTempSyncStat;
// PILOT SYNCHRONIZATION STUFF
int mPilotId; // unique id for pilot sync
int mSyncStatus; // status (for sync)
QPtrList<Observer> mObservers;
};
bool operator==( const IncidenceBase&, const IncidenceBase& );
}
#endif