summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp20
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/journalentry.cpp22
-rw-r--r--korganizer/journalentry.h3
-rw-r--r--korganizer/mainwindow.cpp2
-rw-r--r--libkcal/calendar.cpp3
-rw-r--r--libkcal/calendar.h1
-rw-r--r--libkcal/calendarlocal.cpp75
-rw-r--r--libkcal/calendarlocal.h3
9 files changed, 127 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 940ea91..ccacc52 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1442,38 +1442,42 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
if ( !skipIncidence ) {
inL = local->incidence( uid );
if ( inL ) { // maybe conflict - same uid in both calendars
if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
//qDebug("take %d %s ", take, inL->summary().latin1());
if ( take == 3 )
return false;
if ( take == 1 ) {// take local **********************
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
else
idS = inR->IDStr();
+ int calID = inR->calID();
remote->deleteIncidence( inR );
inR = inL->clone();
+ inR->setCalID( calID );
inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
inR->setIDStr( idS );
remote->addIncidence( inR );
if ( mSyncManager->syncWithDesktop() )
inR->setPilotId( 2 );
++changedRemote;
} else {// take remote **********************
idS = inL->IDStr();
int pid = inL->pilotId();
+ int calID = inL->calID();
local->deleteIncidence( inL );
inL = inR->clone();
+ inL->setCalID( calID );
if ( mSyncManager->syncWithDesktop() )
inL->setPilotId( pid );
inL->setIDStr( idS );
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
}
local->addIncidence( inL );
++changedLocal;
}
}
} else { // no conflict ********** add or delete remote
@@ -1484,33 +1488,36 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
if ( inR->typeID() == todoID )
pref = "t";
if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
//remote->deleteIncidence( inR );
++deletedEventR;
} else {
inR->setLastModified( modifiedCalendar );
inL = inR->clone();
inL->setIDStr( ":" );
inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
+
+ inL->setCalID( 0 );// add to default cal
local->addIncidence( inL );
++addedEvent;
}
} else {
if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
inR->setLastModified( modifiedCalendar );
inL = inR->clone();
inL->setIDStr( ":" );
+ inL->setCalID( 0 );// add to default cal
local->addIncidence( inL );
++addedEvent;
} else {
checkExternSyncEvent(eventRSyncSharp, inR);
remote->deleteIncidence( inR );
++deletedEventR;
}
}
} else {
++filteredIN;
}
@@ -1550,38 +1557,40 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! mSyncManager->mWriteBackExistingOnly ) {
inL->removeID(mCurrentSyncDevice );
++addedEventR;
//qDebug("remote added Incidence %s ", inL->summary().latin1());
inL->setLastModified( modifiedCalendar );
inR = inL->clone();
inR->setIDStr( ":" );
inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
+ inR->setCalID( 0 );// add to default cal
remote->addIncidence( inR );
}
}
} else {
if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
checkExternSyncEvent(eventLSyncSharp, inL);
local->deleteIncidence( inL );
++deletedEventL;
} else {
if ( ! mSyncManager->mWriteBackExistingOnly ) {
++addedEventR;
inL->setLastModified( modifiedCalendar );
inR = inL->clone();
inR->setIDStr( ":" );
+ inR->setCalID( 0 );// add to default cal
remote->addIncidence( inR );
}
}
}
} else {
++filteredOUT;
}
}
}
inL = el.next();
}
int delFut = 0;
@@ -2134,24 +2143,33 @@ bool CalendarView::openCalendar(QString filename, bool merge)
//KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
globalFlagBlockAgenda = 2;
mCalendar->reInitAlarmSettings();
setSyncEventsReadOnly();
updateUnmanagedViews();
updateView();
}
return false;
}
+void CalendarView::mergeFile( QString fn )
+{
+ clearAllViews();
+ mCalendar->mergeCalendarFile( fn );
+ mCalendar->reInitAlarmSettings();
+ setSyncEventsReadOnly();
+ updateUnmanagedViews();
+ updateView();
+}
void CalendarView::showOpenError()
{
KMessageBox::error(this,i18n("Couldn't load calendar\n."));
}
void CalendarView::setLoadedFileVersion(QDateTime dt)
{
loadedFileVersion = dt;
}
bool CalendarView::checkFileChanged(QString fn)
{
QFileInfo finf ( fn );
if ( !finf.exists() )
@@ -3349,30 +3367,32 @@ void CalendarView::newEvent()
if (aView) {
if (aView->selectionStart().isValid()) {
if (aView->selectedIsAllDay()) {
newEvent(aView->selectionStart(),aView->selectionEnd(),true);
} else {
newEvent(aView->selectionStart(),aView->selectionEnd());
}
return;
}
}
QDate date = mNavigator->selectedDates().first();
+#if 0
QDateTime current = QDateTime::currentDateTime();
if ( date <= current.date() ) {
int hour = current.time().hour() +1;
newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
} else
+#endif
newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
}
void CalendarView::newEvent(QDateTime fh)
{
newEvent(fh,
QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
}
void CalendarView::newEvent(QDate dt)
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 706d05d..799c297 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -129,24 +129,25 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
QWidgetStack *viewStack();
QWidget *leftFrame();
DateNavigator *dateNavigator();
KDateNavigator *dateNavigatorWidget();
void addView(KOrg::BaseView *);
void showView(KOrg::BaseView *);
KOEventViewerDialog* getEventViewerDialog();
Incidence *currentSelection();
void checkSuspendAlarm();
+ void mergeFile( QString fn );
signals:
void save ();
void saveStopTimer ();
void tempDisableBR(bool);
/** This todo has been modified */
void todoModified(Todo *, int);
/** when change is made to options dialog, the topwidget will catch this
* and emit this signal which notifies all widgets which have registered
* for notification to update their settings. */
void configChanged();
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index b8a4cf2..f0e0f86 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -67,25 +67,26 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
heiHint = heiHint / fac;
showOnlyMode = false;
mCalendar = calendar;
mJournal = 0;
visibleMode = true;
QHBox * vb = new QHBox ( this );
QPixmap iconp;
vb->setMargin ( KDialog::marginHint()-1 );
QPushButton * toggleJournal = new QPushButton( vb );
iconp = SmallIcon("1updownarrow");
toggleJournal->setPixmap (iconp ) ;
- vb->setStretchFactor (new QLabel(" "+i18n("Title: "),vb),1);
+ QLabel* textLabel = new QLabel(" "+i18n("Title: "),vb);
+ vb->setStretchFactor (textLabel,1);
vb->setStretchFactor( toggleJournal, 1 );
mTitle = new KOLocationBox(TRUE, vb, 30);
mTitle->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) );
mCalendarBox = new QComboBox(vb);
mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) );
#ifndef DESKTOP_VERSION
mTitle->setSizeLimit( 8 );
mCalendarBox->setSizeLimit( 8 );
#endif
vb->setStretchFactor ( mTitle, 8 );
vb->setStretchFactor ( mCalendarBox, 3 );
//mTitleLabel->setMargin(0);
@@ -103,40 +104,59 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
else
iconp = SmallIcon("fileimport");
loadTemplate->setPixmap (iconp ) ;
loadTemplate->setFixedSize( size, size );
saveTemplate->setFixedSize( size, size );
toggleJournal->setFixedSize( size , size );
mTitle->setFixedHeight( size+4);
mCalendarBox->setFixedHeight( size+4);
mEditor = new KTextEdit(this);
#ifndef DESKTOP_VERSION
QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold );
#endif
+ mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width();
+ mDeskWid = QApplication::desktop()->width();
+ int maxwid = mDeskWid - mMaxWidDiff;
+ mTitle->setMaximumWidth( maxwid/2 +20 );
+ mCalendarBox->setMaximumWidth( maxwid/2 -20 );
mEditor->setWordWrap( KTextEdit::WidgetWidth );
QBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->addWidget(vb);
topLayout->addWidget(mEditor);
mEditor->installEventFilter(this);
connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) );
mTitle->load( KOLocationBox::SUMMARYJOURNAL );
mTitle->lineEdit ()->setText("");
}
JournalEntry::~JournalEntry()
{
//qDebug("JournalEntry::~JournalEntry() ");
}
+void JournalEntry::resizeEvent(QResizeEvent* e )
+{
+#ifndef DESKTOP_VERSION
+ if ( mDeskWid != QApplication::desktop()->width() ) {
+ mDeskWid == QApplication::desktop()->width();
+ int maxwid = mDeskWid - mMaxWidDiff;
+ mTitle->setMaximumWidth( maxwid/2 +20 );
+ mCalendarBox->setMaximumWidth( maxwid/2 -20 );
+ }
+ setMaximumWidth( QApplication::desktop()->width() );
+ qDebug("MAXXX %d ", QApplication::desktop()->width());
+#endif
+ QFrame::resizeEvent( e );
+}
QSize JournalEntry::sizeHint() const
{
return QSize ( 240, heiHint );
}
void JournalEntry::slotSaveTemplate()
{
QString fileName =locateLocal( "templates", "journals" );
QDir t_dir;
if ( !t_dir.exists(fileName) )
t_dir.mkdir ( fileName );
fileName += "/journal";
fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this );
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h
index ed04b7c..a69846c 100644
--- a/korganizer/journalentry.h
+++ b/korganizer/journalentry.h
@@ -46,40 +46,43 @@ class JournalEntry : public QFrame {
void setJournal(Journal *, bool saveJournal = true );
Journal *journal() const;
void setDate(const QDate &);
void clear();
void flushEntry();
void setShowOnly();
QSize sizeHint() const;
void setVisibleMode( bool b ) { visibleMode = b;}
void fillCalendar( int id = 0 );
+ void resizeEvent(QResizeEvent* e ) ;
protected slots:
void slotSaveTemplate();
void slotLoadTemplate();
void toggleShowJournal();
void setVisibleOn();
signals:
void deleteJournal(Journal *);
void newJournal();
void showJournalOnly( Journal * );
protected:
bool eventFilter( QObject *o, QEvent *e );
void writeJournal();
private:
+ int mMaxWidDiff;
+ int mDeskWid;
bool visibleMode;
bool showOnlyMode;
Calendar *mCalendar;
Journal *mJournal;
QDate mDate;
void keyPressEvent ( QKeyEvent * ) ;
QComboBox *mCalendarBox;
KOLocationBox * mTitle;
KTextEdit *mEditor;
int heiHint;
};
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 5249300..4bedb61 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -2535,25 +2535,25 @@ void MainWindow::syncFileRequest()
setCaption(i18n("Saving Data to temp file ..." ));
mView->saveCalendar( sentSyncFile() );
setCaption(i18n("Data saved to temp file!" ));
}
void MainWindow::getFile( bool success )
{
if ( ! success ) {
setCaption( i18n("Error receiving file. Nothing changed!") );
return;
}
- mView->openCalendar( sentSyncFile() );
+ mView->mergeFile( sentSyncFile() );
if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
mSyncManager->slotSyncMenu( 999 );
}
setCaption( i18n("Pi-Sync successful!") );
}
void MainWindow::printListView()
{
QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items.");
KMessageBox::information( this, message);
}
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index a662eeb..b7990d4 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -351,25 +351,26 @@ void Calendar::addIncidenceBranch(Incidence *i)
{
addIncidence( i );
Incidence * inc;
QPtrList<Incidence> Relations = i->relations();
for (inc=Relations.first();inc;inc=Relations.next()) {
addIncidenceBranch( inc );
}
}
bool Calendar::addIncidence(Incidence *i)
{
Incidence::AddVisitor<Calendar> v(this);
- i->setCalID( mDefaultCalendar );
+ if ( i->calID() == 0 )
+ i->setCalID( mDefaultCalendar );
i->setCalEnabled( true );
return i->accept(v);
}
void Calendar::deleteIncidence(Incidence *in)
{
if ( in->typeID() == eventID )
deleteEvent( (Event*) in );
else if ( in->typeID() == todoID )
deleteTodo( (Todo*) in);
else if ( in->typeID() == journalID )
deleteJournal( (Journal*) in );
}
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 4652fe5..14a1a45 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -67,24 +67,25 @@ public:
virtual ~Calendar();
Incidence * undoIncidence() { return mUndoIncidence; };
bool undoDeleteIncidence();
void deleteIncidence(Incidence *in);
void resetTempSyncStat();
void resetPilotStat(int id);
/**
Clears out the current calendar, freeing all used memory etc.
*/
virtual void close() = 0;
virtual void addCalendar( Calendar* ) = 0;
virtual bool addCalendarFile( QString name, int id ) = 0;
+ virtual bool mergeCalendarFile( QString name ) = 0;
virtual void setSyncEventsReadOnly() = 0;
virtual void stopAllTodos() = 0;
/**
Sync changes in memory to persistant storage.
*/
virtual void save() = 0;
virtual QPtrList<Event> getExternLastSyncEvents() = 0;
virtual void removeSyncInfo( QString syncProfile) = 0;
virtual bool isSaving() { return false; }
/**
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index cce798f..3e42ec0 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -59,24 +59,99 @@ CalendarLocal::CalendarLocal(const QString &timeZoneId)
void CalendarLocal::init()
{
mNextAlarmIncidence = 0;
}
CalendarLocal::~CalendarLocal()
{
if ( mDeleteIncidencesOnClose )
close();
}
+bool CalendarLocal::mergeCalendarFile( QString name )
+{
+ CalendarLocal calendar( timeZoneId() );
+ calendar.setDefaultCalendar( 1 );
+ if ( calendar.load( name ) ) {
+ mergeCalendar( &calendar );
+ return true;
+ }
+ return false;
+}
+
+Incidence* CalendarLocal::incidenceForUid( const QString& uid )
+{
+ Todo *todo;;
+ Incidence *retVal = 0;
+ for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
+ if ( todo->uid() == uid ) {
+ if ( retVal ) {
+ if ( retVal->calID() > todo->calID() ) {
+ retVal = todo;
+ }
+ } else {
+ retVal = todo;
+ }
+ }
+ }
+ if ( retVal ) return retVal;
+ Event *event;
+ for ( event = mEventList.first(); event; event = mEventList.next() ) {
+ if ( event->uid() == uid ) {
+ if ( retVal ) {
+ if ( retVal->calID() > event->calID() ) {
+ retVal = event;
+ }
+ } else {
+ retVal = event;
+ }
+ }
+ }
+ if ( retVal ) return retVal;
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ if ( it->uid() == uid ) {
+ if ( retVal ) {
+ if ( retVal->calID() > it->calID() ) {
+ retVal = it;
+ }
+ } else {
+ retVal = it;
+ }
+ }
+ return retVal;
+}
+
+bool CalendarLocal::mergeCalendar( Calendar* remote )
+{
+ QPtrList<Incidence> er = remote->rawIncidences();
+ Incidence* inR = er.first();
+ Incidence* inL;
+ while ( inR ) {
+ inL = incidenceForUid( inR->uid() );
+ if ( inL ) {
+ int calID = inL->calID();
+ deleteIncidence( inL );
+ inL = inR->clone();
+ inL->setCalID( calID );
+ addIncidence( inL );
+ } else {
+ inL = inR->clone();
+ inL->setCalID( 0 );// add to default cal
+ addIncidence( inL );
+ }
+ inR = er.next();
+ }
+ return true;
+}
bool CalendarLocal::addCalendarFile( QString name, int id )
{
CalendarLocal calendar( timeZoneId() );
calendar.setDefaultCalendar( id );
if ( calendar.load( name ) ) {
addCalendar( &calendar );
return true;
}
return false;
}
void CalendarLocal::setSyncEventsReadOnly()
{
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index 98d16a3..23b0542 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -36,24 +36,27 @@ class CalendarLocal : public Calendar
public:
/**
Constructs a new calendar, with variables initialized to sane values.
*/
CalendarLocal();
/**
Constructs a new calendar, with variables initialized to sane values.
*/
CalendarLocal( const QString &timeZoneId );
~CalendarLocal();
void addCalendar( Calendar* );
bool addCalendarFile( QString name, int id );
+ bool mergeCalendarFile( QString name );
+ bool mergeCalendar( Calendar* cal );
+ Incidence* incidenceForUid( const QString& uid );
void setSyncEventsReadOnly();
void stopAllTodos();
/**
Loads a calendar on disk in vCalendar or iCalendar format into the current
calendar. Any information already present is lost.
@return true, if successfull, false on error.
@param fileName the name of the calendar on disk.
*/
bool load( const QString &fileName );
/**
Writes out the calendar to disk in the specified \a format.
CalendarLocal takes ownership of the CalFormat object.