-rw-r--r-- | korganizer/calendarview.cpp | 20 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/journalentry.cpp | 22 | ||||
-rw-r--r-- | korganizer/journalentry.h | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 2 |
5 files changed, 46 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 @@ -1430,99 +1430,106 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int while ( inR ) { if ( ! bar.isVisible() ) return false; if ( incCounter % modulo == 0 ) bar.setProgress( incCounter ); ++incCounter; uid = inR->uid(); bool skipIncidence = false; if ( uid.left(15) == QString("last-syncEvent-") ) skipIncidence = true; QString idS; qApp->processEvents(); 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 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { QString des = eventLSync->description(); QString pref = "e"; 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; } } } inR = er.next(); } QPtrList<Incidence> el = local->rawIncidences(); inL = el.first(); modulo = (el.count()/10)+1; bar.setCaption (i18n("Add / remove events") ); bar.setTotalSteps ( el.count() ) ; bar.show(); incCounter = 0; @@ -1538,62 +1545,64 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int bool skipIncidence = false; if ( uid.left(15) == QString("last-syncEvent-") ) skipIncidence = true; if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) skipIncidence = true; if ( !skipIncidence ) { inR = remote->incidence( uid ); if ( ! inR ) { if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ // no conflict ********** add or delete local if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 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; int remRem = 0; if ( mSyncManager->mWriteBackInFuture ) { er = remote->rawIncidences(); remRem = er.count(); inR = er.first(); QDateTime dt; QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); while ( inR ) { if ( inR->typeID() == todoID ) { Todo * t = (Todo*)inR; if ( t->hasDueDate() ) @@ -2122,48 +2131,57 @@ bool CalendarView::openCalendar(QString filename, bool merge) } } return true; } else { // while failing to load, the calendar object could // have become partially populated. Clear it out. if ( !merge ) { mCalendar->close(); mViewManager->setDocumentId( filename ); mDialogManager->setDocumentId( filename ); mTodoList->setDocumentId( filename ); } //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() ) return true; QDateTime dt = finf.lastModified (); if ( dt <= loadedFileVersion ) return false; return true; } void CalendarView::watchSavedFile() { QFileInfo finf ( MainWindow::defaultFileName()); if ( !finf.exists() ) return; @@ -3337,54 +3355,56 @@ void CalendarView::cloneIncidence(Incidence * orgInc ) } } if ( newInc->typeID() == journalID ) { mCalendar->addJournal( (Journal*) newInc ); editJournal( (Journal*) newInc ); } setActiveWindow(); } void CalendarView::newEvent() { // TODO: Replace this code by a common eventDurationHint of KOBaseView. KOAgendaView *aView = mViewManager->agendaView(); 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) { newEvent(QDateTime(dt, QTime(0,0,0)), QDateTime(dt, QTime(0,0,0)), true); } void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) { newEvent(fromHint, toHint, false); } void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) { showEventEditor(); diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 706d05d..799c297 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -117,48 +117,49 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser const char *name = 0 ); CalendarView( Calendar *calendar, QWidget *parent = 0, const char *name = 0 ); virtual ~CalendarView(); Calendar *calendar() { return mCalendar; } KOViewManager *viewManager(); KODialogManager *dialogManager(); QDate startDate(); QDate endDate(); 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(); /** emitted when the topwidget is closing down, so that any attached child windows can also close. */ void closingDown(); /** emitted right before we die */ void closed(QWidget *); /** Emitted when state of modified flag changes */ void modifiedChanged(bool); void signalmodified(); /** Emitted when state of read-only flag changes */ void readOnlyChanged(bool); diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index b8a4cf2..f0e0f86 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp @@ -55,100 +55,120 @@ //#include "journalentry.moc" #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #endif JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : QFrame(parent) { int fac = 5; heiHint = QApplication::desktop()->height(); if ( heiHint > 800 ) fac += 2; 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); //mTitleLabel->setAlignment(AlignCenter); QPushButton * loadTemplate = new QPushButton( vb ); QPushButton * saveTemplate = new QPushButton( vb ); if ( QApplication::desktop()->width() < 321 ) iconp = SmallIcon("fileexport16"); else iconp = SmallIcon("fileexport"); saveTemplate->setPixmap (iconp ) ; int size = saveTemplate->sizeHint().height(); if ( QApplication::desktop()->width() < 321 ) iconp = SmallIcon("fileimport16"); 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 ); if ( fileName.length() == 0 ) return; QFile fileIn( fileName ); if (!fileIn.open( IO_WriteOnly ) ) { KMessageBox::error( this, i18n("Error saving template file\n '%1'.") .arg( fileName ) ); return; } // QString text; QTextStream tsIn( &fileIn ); tsIn.setCodec( QTextCodec::codecForName("utf8") ); diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h index ed04b7c..a69846c 100644 --- a/korganizer/journalentry.h +++ b/korganizer/journalentry.h @@ -34,53 +34,56 @@ class KTextEdit; class QComboBox; class KLineEdit; class KOLocationBox; using namespace KCal; class JournalEntry : public QFrame { Q_OBJECT public: JournalEntry(Calendar *,QWidget *parent); virtual ~JournalEntry(); 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; }; #endif diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 5249300..4bedb61 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -2523,49 +2523,49 @@ QString MainWindow::sentSyncFile() #ifdef DESKTOP_VERSION return locateLocal( "tmp", "copysynccal.ics" ); #else return QString( "/tmp/copysynccal.ics" ); #endif } void MainWindow::syncFileRequest() { if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { mSyncManager->slotSyncMenu( 999 ); } 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); } void MainWindow::printSel( ) { mView->viewManager()->agendaView()->agenda()->printSelection(); } void MainWindow::printCal() { mView->print();//mCp->showDialog(); } #include "libkdepim/kdatepicker.h" |