summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-09 08:48:32 (UTC)
committer zautrix <zautrix>2005-07-09 08:48:32 (UTC)
commitf731dd9fc5b3f14c44d4de26eb5370a79c63887c (patch) (side-by-side diff)
treee3d7b3929cc8819a5451bd04c9698bc0767e49b1
parente27ad31c6016152449bbdaf4f9f387fa61183c37 (diff)
downloadkdepimpi-f731dd9fc5b3f14c44d4de26eb5370a79c63887c.zip
kdepimpi-f731dd9fc5b3f14c44d4de26eb5370a79c63887c.tar.gz
kdepimpi-f731dd9fc5b3f14c44d4de26eb5370a79c63887c.tar.bz2
fixi
Diffstat (more/less context) (show 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.cpp1
-rw-r--r--libkcal/calendar.h1
-rw-r--r--libkcal/calendarlocal.cpp75
-rw-r--r--libkcal/calendarlocal.h3
9 files changed, 126 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 940ea91..ccacc52 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1451,8 +1451,10 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
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 );
@@ -1463,8 +1465,10 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
} 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 );
@@ -1493,6 +1497,8 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
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;
@@ -1502,6 +1508,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
inR->setLastModified( modifiedCalendar );
inL = inR->clone();
inL->setIDStr( ":" );
+ inL->setCalID( 0 );// add to default cal
local->addIncidence( inL );
++addedEvent;
@@ -1559,6 +1566,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
inR = inL->clone();
inR->setIDStr( ":" );
inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
+ inR->setCalID( 0 );// add to default cal
remote->addIncidence( inR );
}
}
@@ -1573,6 +1581,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
inL->setLastModified( modifiedCalendar );
inR = inL->clone();
inR->setIDStr( ":" );
+ inR->setCalID( 0 );// add to default cal
remote->addIncidence( inR );
}
}
@@ -2143,6 +2152,15 @@ bool CalendarView::openCalendar(QString filename, bool merge)
}
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."));
@@ -3358,12 +3376,14 @@ void CalendarView::newEvent()
}
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 ) ) );
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 706d05d..799c297 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -138,6 +138,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
KOEventViewerDialog* getEventViewerDialog();
Incidence *currentSelection();
void checkSuspendAlarm();
+ void mergeFile( QString fn );
signals:
void save ();
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index b8a4cf2..f0e0f86 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -76,7 +76,8 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
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) );
@@ -112,6 +113,11 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
#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);
@@ -128,6 +134,20 @@ 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 );
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h
index ed04b7c..a69846c 100644
--- a/korganizer/journalentry.h
+++ b/korganizer/journalentry.h
@@ -55,6 +55,7 @@ class JournalEntry : public QFrame {
QSize sizeHint() const;
void setVisibleMode( bool b ) { visibleMode = b;}
void fillCalendar( int id = 0 );
+ void resizeEvent(QResizeEvent* e ) ;
protected slots:
void slotSaveTemplate();
void slotLoadTemplate();
@@ -71,6 +72,8 @@ class JournalEntry : public QFrame {
void writeJournal();
private:
+ int mMaxWidDiff;
+ int mDeskWid;
bool visibleMode;
bool showOnlyMode;
Calendar *mCalendar;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 5249300..4bedb61 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -2544,7 +2544,7 @@ void MainWindow::getFile( bool success )
setCaption( i18n("Error receiving file. Nothing changed!") );
return;
}
- mView->openCalendar( sentSyncFile() );
+ mView->mergeFile( sentSyncFile() );
if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
mSyncManager->slotSyncMenu( 999 );
}
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index a662eeb..b7990d4 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -360,6 +360,7 @@ void Calendar::addIncidenceBranch(Incidence *i)
bool Calendar::addIncidence(Incidence *i)
{
Incidence::AddVisitor<Calendar> v(this);
+ if ( i->calID() == 0 )
i->setCalID( mDefaultCalendar );
i->setCalEnabled( true );
return i->accept(v);
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 4652fe5..14a1a45 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -76,6 +76,7 @@ public:
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;
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index cce798f..3e42ec0 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -68,6 +68,81 @@ 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() );
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index 98d16a3..23b0542 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -45,6 +45,9 @@ class CalendarLocal : public Calendar
~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();
/**