author | zautrix <zautrix> | 2004-08-01 13:25:33 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-01 13:25:33 (UTC) |
commit | 043f0968a982bd7d2d288615530f8976aeb98002 (patch) (side-by-side diff) | |
tree | 275caee79fbe7e6517068336cfa421cb6eefc0db | |
parent | 2de3f124cc4c2fb542b3ebf7cfc944f69a211b0f (diff) | |
download | kdepimpi-043f0968a982bd7d2d288615530f8976aeb98002.zip kdepimpi-043f0968a982bd7d2d288615530f8976aeb98002.tar.gz kdepimpi-043f0968a982bd7d2d288615530f8976aeb98002.tar.bz2 |
sync dialog moved
-rw-r--r-- | korganizer/calendarview.cpp | 6 | ||||
-rw-r--r-- | korganizer/kosyncprefsdialog.cpp | 468 | ||||
-rw-r--r-- | korganizer/kosyncprefsdialog.h | 113 |
3 files changed, 3 insertions, 584 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index c75d10e..387b751 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1,1202 +1,1202 @@ /* This file is part of KOrganizer. Requires the Qt and KDE widget libraries, available at no cost at http://www.troll.no and http://www.kde.org respectively Copyright (c) 1997, 1998, 1999 Preston Brown (preston.brown@yale.edu) Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) Ian Dawes (iadawes@globalserve.net) Laszlo Boloni (boloni@cs.purdue.edu) Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <stdlib.h> #include <qapplication.h> #include <qradiobutton.h> #include <qbuttongroup.h> #include <qlayout.h> #include <qclipboard.h> #include <qcursor.h> #include <qmessagebox.h> #include <qprogressbar.h> #include <qmultilineedit.h> #include <qtimer.h> #include <qwidgetstack.h> #include <qptrlist.h> #include <qregexp.h> #include <qgroupbox.h> #include <qfile.h> #include <qdir.h> #ifndef KORG_NOSPLITTER #include <qsplitter.h> #endif #include <kglobal.h> #include <kdebug.h> #include <kstandarddirs.h> #include <kfiledialog.h> #include <kmessagebox.h> #include <knotifyclient.h> #include <kconfig.h> -#include "kosyncprefsdialog.h" +#include <libkdepim/ksyncprefsdialog.h> #include <krun.h> #include <kdirwatch.h> #include <libkdepim/kdatepicker.h> #include <libkdepim/ksyncprofile.h> #include <libkcal/vcaldrag.h> #include <libkcal/icaldrag.h> #include <libkcal/icalformat.h> #include <libkcal/vcalformat.h> #include <libkcal/scheduler.h> #include <libkcal/calendarlocal.h> #include <libkcal/journal.h> #include <libkcal/calfilter.h> #include <libkcal/attendee.h> #include <libkcal/dndfactory.h> #include <libkcal/freebusy.h> #include <libkcal/filestorage.h> #include <libkcal/calendarresources.h> #include <libkcal/qtopiaformat.h> #include "../kalarmd/alarmdialog.h" #ifndef DESKTOP_VERSION #include <libkcal/sharpformat.h> #endif #ifndef KORG_NOMAIL #include "komailclient.h" #endif #ifndef KORG_NOPRINTER #include "calprinter.h" #endif #ifndef KORG_NOPLUGINS #include "kocore.h" #endif #include "koeventeditor.h" #include "kotodoeditor.h" #include "koprefs.h" #include "koeventviewerdialog.h" #include "publishdialog.h" #include "kofilterview.h" #include "koglobals.h" #include "koviewmanager.h" #include "koagendaview.h" #include "kodialogmanager.h" #include "outgoingdialog.h" #include "incomingdialog.h" #include "statusdialog.h" #include "kdatenavigator.h" #include "kotodoview.h" #include "datenavigator.h" #include "resourceview.h" #include "navigatorbar.h" #include "searchdialog.h" #include "mainwindow.h" #include "calendarview.h" #ifndef DESKTOP_VERSION #include <qtopia/alarmserver.h> #endif #ifndef _WIN32_ #include <stdlib.h> #include <stdio.h> #include <unistd.h> #else #include <qprocess.h> #endif using namespace KOrg; using namespace KCal; extern int globalFlagBlockAgenda; extern int globalFlagBlockStartup; class KOBeamPrefs : public QDialog { public: KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Beam Options") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); lay->addWidget( time ); time->setExclusive ( true ) ; vcal = new QRadioButton(" vCalendar ", format ); ical = new QRadioButton(" iCalendar ", format ); vcal->setChecked( true ); tz = new QRadioButton(i18n(" With timezone "), time ); local = new QRadioButton(i18n(" Local time "), time ); tz->setChecked( true ); QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 200, 200 ); } bool beamVcal() { return vcal->isChecked(); } bool beamLocal() { return local->isChecked(); } private: QRadioButton* vcal, *ical, *local, *tz; }; class KOCatPrefs : public QDialog { public: KOCatPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Manage new Categories") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); lay->addWidget( lab ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; addCatBut = new QRadioButton(i18n("Add to category list"), format ); new QRadioButton(i18n("Remove from Events/Todos"), format ); addCatBut->setChecked( true ); QPushButton * ok = new QPushButton( i18n("OK"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 200, 200 ); } bool addCat() { return addCatBut->isChecked(); } private: QRadioButton* addCatBut; }; CalendarView::CalendarView( CalendarResources *calendar, QWidget *parent, const char *name ) : CalendarViewBase( parent, name ), mCalendar( calendar ), mResourceManager( calendar->resourceManager() ) { mEventEditor = 0; mTodoEditor = 0; init(); } CalendarView::CalendarView( Calendar *calendar, QWidget *parent, const char *name ) : CalendarViewBase( parent, name ), mCalendar( calendar ), mResourceManager( 0 ) { mEventEditor = 0; mTodoEditor = 0; init();} void CalendarView::init() { beamDialog = new KOBeamPrefs(); mDatePickerMode = 0; mCurrentSyncDevice = ""; writeLocale(); mViewManager = new KOViewManager( this ); mDialogManager = new KODialogManager( this ); mEventViewerDialog = 0; mModified = false; mReadOnly = false; mSelectedIncidence = 0; mCalPrinter = 0; mFilters.setAutoDelete(true); mCalendar->registerObserver( this ); // TODO: Make sure that view is updated, when calendar is changed. mStorage = new FileStorage( mCalendar ); mNavigator = new DateNavigator( this, "datevav", mViewManager ); QBoxLayout *topLayout = (QBoxLayout*)layout(); #ifndef KORG_NOSPLITTER // create the main layout frames. mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); topLayout->addWidget(mPanner); mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, "CalendarView::LeftFrame"); mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, "CalendarView::DateNavigator", QDate::currentDate() ); mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); #ifdef KORG_NORESOURCEVIEW mResourceView = 0; #else if ( mResourceManager ) { mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); mResourceView->updateView(); connect( mResourceView, SIGNAL( resourcesChanged() ), SLOT( updateView() ) ); } else { mResourceView = 0; } #endif QWidget *rightBox = new QWidget( mPanner ); QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); rightLayout->addWidget( mNavigatorBar ); mRightFrame = new QWidgetStack( rightBox ); rightLayout->addWidget( mRightFrame, 1 ); mLeftFrame = mLeftSplitter; #else QWidget *mainBox = new QWidget( this ); QWidget *leftFrame = new QWidget( mainBox ); QBoxLayout * mainBoxLayout; QBoxLayout * leftFrameLayout; if ( KOPrefs::instance()->mVerticalScreen ) { mainBoxLayout = new QVBoxLayout(mainBox); leftFrameLayout = new QHBoxLayout(leftFrame ); } else { mainBoxLayout = new QHBoxLayout(mainBox); leftFrameLayout = new QVBoxLayout(leftFrame ); } topLayout->addWidget( mainBox ); mainBoxLayout->addWidget (leftFrame); mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, "CalendarView::DateNavigator", QDate::currentDate()); // mDateNavigator->blockSignals( true ); leftFrameLayout->addWidget( mDateNavigator ); mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); if ( QApplication::desktop()->width() < 480 ) { leftFrameLayout->addWidget(mFilterView); leftFrameLayout->addWidget(mTodoList, 2 ); } else { leftFrameLayout->addWidget(mTodoList,2 ); leftFrameLayout->addWidget(mFilterView ); } mFilterView->hide(); QWidget *rightBox = new QWidget( mainBox ); mainBoxLayout->addWidget ( rightBox, 10 ); QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); mRightFrame = new QWidgetStack( rightBox ); rightLayout->addWidget( mNavigatorBar ); rightLayout->addWidget( mRightFrame, 10 ); mLeftFrame = leftFrame; if ( KOPrefs::instance()->mVerticalScreen ) { mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); } else { mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); } //qDebug("Calendarview Size %d %d ", width(), height()); #endif connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), SLOT( showDates( const KCal::DateList & ) ) ); connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); connect( mNavigatorBar, SIGNAL( goPrevYear() ), mNavigator, SLOT( selectPreviousYear() ) ); connect( mNavigatorBar, SIGNAL( goNextYear() ), mNavigator, SLOT( selectNextYear() ) ); connect( mNavigatorBar, SIGNAL( goPrevMonth() ), mNavigator, SLOT( selectPreviousMonth() ) ); connect( mNavigatorBar, SIGNAL( goNextMonth() ), mNavigator, SLOT( selectNextMonth() ) ); connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), mNavigator, SLOT( selectWeek( const QDate & ) ) ); connect( mDateNavigator, SIGNAL( goPrevYear() ), mNavigator, SLOT( selectPreviousYear() ) ); connect( mDateNavigator, SIGNAL( goNextYear() ), mNavigator, SLOT( selectNextYear() ) ); connect( mDateNavigator, SIGNAL( goPrevMonth() ), mNavigator, SLOT( selectPreviousMonth() ) ); connect( mDateNavigator, SIGNAL( goNextMonth() ), mNavigator, SLOT( selectNextMonth() ) ); connect( mDateNavigator, SIGNAL( goPrevious() ), mNavigator, SLOT( selectPrevious() ) ); connect( mDateNavigator, SIGNAL( goNext() ), mNavigator, SLOT( selectNext() ) ); connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), mNavigator, SLOT( slotMonthSelect( int ) ) ); connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), mNavigator, SLOT( slotMonthSelect( int ) ) ); connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), SLOT( eventAdded( Event *) ) ); connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); connect( this, SIGNAL( configChanged() ), mDateNavigator, SLOT( updateConfig() ) ); connect( mTodoList, SIGNAL( newTodoSignal() ), SLOT( newTodo() ) ); connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), SLOT( newSubTodo( Todo * ) ) ); connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), SLOT( editTodo( Todo * ) ) ); connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), SLOT( showTodo( Todo *) ) ); connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), SLOT( deleteTodo( Todo *) ) ); connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); connect( mTodoList, SIGNAL( purgeCompletedSignal() ), SLOT( purgeCompleted() ) ); connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), SIGNAL( todoModified( Todo *, int ) ) ); connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), this, SLOT ( cloneIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), this, SLOT (cancelIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), this, SLOT ( moveIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), this, SLOT ( beamIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), this, SLOT ( todo_unsub( Todo * ) ) ); connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, SLOT( updateTodo( Todo *, int ) ) ); connect( this, SIGNAL( todoModified( Todo *, int )), this, SLOT( changeTodoDisplay( Todo *, int ) ) ); connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); connect(QApplication::clipboard(),SIGNAL(dataChanged()), SLOT(checkClipboard())); connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), SLOT( processTodoListSelection( Incidence * ) ) ); connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); // kdDebug() << "CalendarView::CalendarView() done" << endl; mDateFrame = new QVBox(0,0,WType_Popup); //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 ); } CalendarView::~CalendarView() { // kdDebug() << "~CalendarView()" << endl; //qDebug("CalendarView::~CalendarView() "); delete mDialogManager; delete mViewManager; delete mStorage; delete mDateFrame ; delete beamDialog; //kdDebug() << "~CalendarView() done" << endl; } void CalendarView::timerAlarm() { //qDebug("CalendarView::timerAlarm() "); computeAlarm(mAlarmNotification ); } void CalendarView::suspendAlarm() { //qDebug(" CalendarView::suspendAlarm() "); computeAlarm(mSuspendAlarmNotification ); } void CalendarView::startAlarm( QString mess , QString filename) { mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); } void CalendarView::checkNextTimerAlarm() { mCalendar->checkAlarmForIncidence( 0, true ); } void CalendarView::computeAlarm( QString msg ) { QString mess = msg; QString mAlarmMessage = mess.mid( 9 ); QString filename = MainWindow::resourcePath(); filename += "koalarm.wav"; QString tempfilename; if ( mess.left( 13 ) == "suspend_alarm") { bool error = false; int len = mess.mid( 13 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 13, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( ! error ) { filename = tempfilename; } mAlarmMessage = mess.mid( 13+len+3 ); //qDebug("suspend file %s ",tempfilename.latin1() ); startAlarm( mAlarmMessage, filename); return; } if ( mess.left( 11 ) == "timer_alarm") { //mTimerTime = 0; startAlarm( mess.mid( 11 ), filename ); return; } if ( mess.left( 10 ) == "proc_alarm") { bool error = false; int len = mess.mid( 10 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 10, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( error ) { mAlarmMessage = "Procedure Alarm\nError - File not found\n"; mAlarmMessage += mess.mid( 10+len+3+9 ); } else { //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); //qDebug("-----system command %s ",tempfilename.latin1() ); #ifndef _WIN32_ if ( vfork () == 0 ) { execl ( tempfilename.latin1(), 0 ); return; } #else QProcess* p = new QProcess(); p->addArgument( tempfilename.latin1() ); p->start(); return; #endif return; } //qDebug("+++++++system command %s ",tempfilename.latin1() ); } if ( mess.left( 11 ) == "audio_alarm") { bool error = false; int len = mess.mid( 11 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 11, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( ! error ) { filename = tempfilename; } mAlarmMessage = mess.mid( 11+len+3+9 ); //qDebug("audio file command %s ",tempfilename.latin1() ); } if ( mess.left( 9 ) == "cal_alarm") { mAlarmMessage = mess.mid( 9 ) ; } startAlarm( mAlarmMessage, filename ); } void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) { //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); mSuspendAlarmNotification = noti; int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); mSuspendTimer->start( ms , true ); } void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) { //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { #ifndef DESKTOP_VERSION AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); #endif return; } int maxSec; //maxSec = 5; //testing only maxSec = 86400+3600; // one day+1hour mAlarmNotification = noti; int sec = QDateTime::currentDateTime().secsTo( qdt ); if ( sec > maxSec ) { mRecheckAlarmTimer->start( maxSec * 1000 ); // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); return; } else { mRecheckAlarmTimer->stop(); } //qDebug("Alarm timer started with secs: %d ", sec); mAlarmTimer->start( sec *1000 , true ); } // called by mRecheckAlarmTimer to get next alarm // we need this, because a QTimer has only a max range of 25 days void CalendarView::recheckTimerAlarm() { mAlarmTimer->stop(); mRecheckAlarmTimer->stop(); mCalendar->checkAlarmForIncidence( 0, true ); } void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) { //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { #ifndef DESKTOP_VERSION AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); #endif return; } mAlarmTimer->stop(); } void CalendarView::selectWeekNum ( int num ) { dateNavigator()->selectWeek( num ); mViewManager->showWeekView(); } KOViewManager *CalendarView::viewManager() { return mViewManager; } KODialogManager *CalendarView::dialogManager() { return mDialogManager; } QDate CalendarView::startDate() { DateList dates = mNavigator->selectedDates(); return dates.first(); } QDate CalendarView::endDate() { DateList dates = mNavigator->selectedDates(); return dates.last(); } void CalendarView::createPrinter() { #ifndef KORG_NOPRINTER if (!mCalPrinter) { mCalPrinter = new CalPrinter(this, mCalendar); connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); } #endif } void CalendarView::confSync() { - static KOSyncPrefsDialog* sp = 0; + static KSyncPrefsDialog* sp = 0; if ( ! sp ) { - sp = new KOSyncPrefsDialog( this, "syncprefs", true ); + sp = new KSyncPrefsDialog( this, "syncprefs", true ); } sp->setLocalMachineName ( KOPrefs::instance()->mLocalMachineName ); sp->usrReadConfig(); #ifndef DESKTOP_VERSION sp->showMaximized(); #else sp->show(); #endif sp->exec(); KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); } //KOPrefs::instance()->mWriteBackFile //KOPrefs::instance()->mWriteBackExistingOnly // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) { //void setZaurusId(int id); // int zaurusId() const; // void setZaurusUid(int id); // int zaurusUid() const; // void setZaurusStat(int id); // int zaurusStat() const; // 0 equal // 1 take local // 2 take remote // 3 cancel QDateTime lastSync = mLastCalendarSync; if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { bool remCh, locCh; remCh = ( remote->zaurusUid() != local->zaurusUid() ); locCh = ( local->lastModified() > mLastCalendarSync ); //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); if ( !remCh && ! locCh ) { //qDebug("both not changed "); lastSync = local->lastModified().addDays(1); } else { if ( locCh ) { //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); lastSync = local->lastModified().addDays( -1 ); if ( !remCh ) remote->setLastModified( lastSync.addDays( -1 ) ); } else { //qDebug(" not loc changed "); lastSync = local->lastModified().addDays( 1 ); if ( remCh ) remote->setLastModified( lastSync.addDays( 1 ) ); } } full = true; if ( mode < SYNC_PREF_ASK ) mode = SYNC_PREF_ASK; } else { if ( local->lastModified() == remote->lastModified() ) if ( local->revision() == remote->revision() ) return 0; } // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); //full = true; //debug only if ( full ) { bool equ = false; if ( local->type() == "Event" ) { equ = (*((Event*) local) == *((Event*) remote)); } else if ( local->type() =="Todo" ) equ = (*((Todo*) local) == (*(Todo*) remote)); else if ( local->type() =="Journal" ) equ = (*((Journal*) local) == *((Journal*) remote)); if ( equ ) { //qDebug("equal "); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { local->setZaurusUid( remote->zaurusUid() ); } if ( mode < SYNC_PREF_FORCE_LOCAL ) return 0; }//else //debug only //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); } int result; bool localIsNew; if ( full && mode < SYNC_PREF_NEWEST ) mode = SYNC_PREF_ASK; switch( mode ) { case SYNC_PREF_LOCAL: if ( lastSync > remote->lastModified() ) return 1; if ( lastSync > local->lastModified() ) return 2; return 1; break; case SYNC_PREF_REMOTE: if ( lastSync > remote->lastModified() ) return 1; if ( lastSync > local->lastModified() ) return 2; return 2; break; case SYNC_PREF_NEWEST: if ( local->lastModified() > remote->lastModified() ) return 1; else return 2; break; case SYNC_PREF_ASK: //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); if ( lastSync > remote->lastModified() ) return 1; if ( lastSync > local->lastModified() ) return 2; //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); localIsNew = local->lastModified() > remote->lastModified(); if ( localIsNew ) getEventViewerDialog()->setColorMode( 1 ); else getEventViewerDialog()->setColorMode( 2 ); getEventViewerDialog()->setIncidence(local); if ( localIsNew ) getEventViewerDialog()->setColorMode( 2 ); else getEventViewerDialog()->setColorMode( 1 ); getEventViewerDialog()->addIncidence(remote); getEventViewerDialog()->setColorMode( 0 ); //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); getEventViewerDialog()->showMe(); result = getEventViewerDialog()->executeS( localIsNew ); return result; break; case SYNC_PREF_FORCE_LOCAL: return 1; break; case SYNC_PREF_FORCE_REMOTE: return 2; break; default: // SYNC_PREF_TAKE_BOTH not implemented break; } return 0; } Event* CalendarView::getLastSyncEvent() { Event* lse; //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); if (!lse) { lse = new Event(); lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); lse->setDtStart( mLastCalendarSync ); lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); lse->setCategories( i18n("SyncEvent") ); lse->setReadOnly( true ); mCalendar->addEvent( lse ); } return lse; } void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) { if ( ! lastSync ) return; if ( toDelete->zaurusId() < 0 ) return; if ( toDelete->type() == "Journal" ) return; QString des = lastSync->description(); QString pref = "e"; if ( toDelete->type() == "Todo" ) pref = "t"; des += pref+ QString::number ( toDelete->zaurusId() ) + ","; lastSync->setReadOnly( false ); lastSync->setDescription( des ); lastSync->setReadOnly( true ); } bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) { bool syncOK = true; int addedEvent = 0; int addedEventR = 0; int deletedEventR = 0; int deletedEventL = 0; int changedLocal = 0; int changedRemote = 0; //QPtrList<Event> el = local->rawEvents(); Event* eventR; QString uid; int take; Event* eventL; Event* eventRSync; Event* eventLSync; Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); bool fullDateRange = false; mLastCalendarSync = QDateTime::currentDateTime(); QDateTime modifiedCalendar = mLastCalendarSync;; eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); if ( eventR ) { eventRSync = (Event*) eventR->clone(); remote->deleteEvent(eventR ); } else { fullDateRange = true; eventRSync = new Event(); eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); eventRSync->setDtStart( mLastCalendarSync ); eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); eventRSync->setCategories( i18n("SyncEvent") ); } eventLSync = getLastSyncEvent(); if ( eventLSync->dtStart() == mLastCalendarSync ) fullDateRange = true; if ( ! fullDateRange ) { if ( eventLSync->dtStart() != eventRSync->dtStart() ) { // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); fullDateRange = true; } } if ( fullDateRange ) mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); else mLastCalendarSync = eventLSync->dtStart(); // for resyncing if own file has changed if ( mCurrentSyncDevice == "deleteaftersync" ) { mLastCalendarSync = loadedFileVersion; qDebug("setting mLastCalendarSync "); } //qDebug("*************************** "); qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); QPtrList<Incidence> er = remote->rawIncidences(); Incidence* inR = er.first(); Incidence* inL; QProgressBar bar( er.count(),0 ); bar.setCaption (i18n("Syncing - close to abort!") ); int w = 300; if ( QApplication::desktop()->width() < 320 ) w = 220; int h = bar.sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); int modulo = (er.count()/10)+1; int incCounter = 0; while ( inR ) { if ( ! bar.isVisible() ) return false; if ( incCounter % modulo == 0 ) bar.setProgress( incCounter ); ++incCounter; uid = inR->uid(); bool skipIncidence = false; if ( uid.left(21) == QString("last-syncEvent-device") ) skipIncidence = true; qApp->processEvents(); if ( !skipIncidence ) { inL = local->incidence( uid ); if ( inL ) { // maybe conflict - same uid in both calendars int maxrev = inL->revision(); if ( maxrev < inR->revision() ) maxrev = inR->revision(); 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 inL->setZaurusUid( inR->zaurusUid() ); remote->deleteIncidence( inR ); if ( inL->revision() < maxrev ) inL->setRevision( maxrev ); remote->addIncidence( inL->clone() ); ++changedRemote; } else { if ( inR->revision() < maxrev ) inR->setRevision( maxrev ); local->deleteIncidence( inL ); local->addIncidence( inR->clone() ); ++changedLocal; } } } else { // no conflict if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { QString des = eventLSync->description(); QString pref = "e"; if ( inR->type() == "Todo" ) pref = "t"; if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); //remote->deleteIncidence( inR ); ++deletedEventR; } else { inR->setLastModified( modifiedCalendar ); local->addIncidence( inR->clone() ); ++addedEvent; } } else { if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { inR->setLastModified( modifiedCalendar ); local->addIncidence( inR->clone() ); ++addedEvent; } else { checkSharpEvent(eventRSyncSharp, inR); remote->deleteIncidence( inR ); ++deletedEventR; } } } } 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; while ( inL ) { qApp->processEvents(); if ( ! bar.isVisible() ) return false; if ( incCounter % modulo == 0 ) bar.setProgress( incCounter ); ++incCounter; uid = inL->uid(); bool skipIncidence = false; if ( uid.left(21) == QString("last-syncEvent-device") ) skipIncidence = true; if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) skipIncidence = true; if ( !skipIncidence ) { inR = remote->incidence( uid ); if ( ! inR ) { if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { if ( inL->zaurusId() >= 0 && mode != 4 ) { local->deleteIncidence( inL ); ++deletedEventL; } else { if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { inL->setZaurusId( -1 ); ++addedEventR; inL->setLastModified( modifiedCalendar ); remote->addIncidence( inL->clone() ); } } } else { if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { checkSharpEvent(eventLSyncSharp, inL); local->deleteIncidence( inL ); ++deletedEventL; } else { if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { ++addedEventR; inL->setLastModified( modifiedCalendar ); remote->addIncidence( inL->clone() ); } } } } } inL = el.next(); } bar.hide(); mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); eventLSync->setReadOnly( false ); eventLSync->setDtStart( mLastCalendarSync ); eventRSync->setDtStart( mLastCalendarSync ); eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); eventLSync->setReadOnly( true ); if ( mGlobalSyncMode == SYNC_MODE_NORMAL) remote->addEvent( eventRSync ); QString mes; mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); if ( KOPrefs::instance()->mShowSyncSummary ) { KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); } qDebug( mes ); mCalendar->checkAlarmForIncidence( 0, true ); return syncOK; } void CalendarView::setSyncDevice( QString s ) { mCurrentSyncDevice= s; } void CalendarView::setSyncName( QString s ) { mCurrentSyncName= s; } bool CalendarView::syncCalendar(QString filename, int mode) { mGlobalSyncMode = SYNC_MODE_NORMAL; CalendarLocal* calendar = new CalendarLocal(); calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); FileStorage* storage = new FileStorage( calendar ); bool syncOK = false; storage->setFileName( filename ); // qDebug("loading ... "); if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { getEventViewerDialog()->setSyncMode( true ); syncOK = synchronizeCalendar( mCalendar, calendar, mode ); getEventViewerDialog()->setSyncMode( false ); if ( syncOK ) { if ( KOPrefs::instance()->mWriteBackFile ) { storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); storage->save(); } } setModified( true ); } delete storage; delete calendar; if ( syncOK ) updateView(); return syncOK; } void CalendarView::syncSharp() { #ifndef DESKTOP_VERSION mGlobalSyncMode = SYNC_MODE_EXTERNAL; //mCurrentSyncDevice = "sharp-DTM"; if ( KOPrefs::instance()->mAskForPreferences ) edit_sync_options(); qApp->processEvents(); CalendarLocal* calendar = new CalendarLocal(); calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); bool syncOK = false; SharpFormat sharpFormat; if ( sharpFormat.load( calendar, mCalendar ) ) { getEventViewerDialog()->setSyncMode( true ); syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); getEventViewerDialog()->setSyncMode( false ); qApp->processEvents(); if ( syncOK ) { if ( KOPrefs::instance()->mWriteBackFile ) { QPtrList<Incidence> iL = mCalendar->rawIncidences(); Incidence* inc = iL.first(); /* obsolete while ( inc ) { inc->setZaurusStat( inc->revision () ); inc = iL.next(); } */ // pending: clean last sync event description sharpFormat.save(calendar); iL = calendar->rawIncidences(); inc = iL.first(); Incidence* loc; while ( inc ) { if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { loc = mCalendar->incidence(inc->uid() ); if ( loc ) { loc->setZaurusId( inc->zaurusId() ); loc->setZaurusUid( inc->zaurusUid() ); } } inc = iL.next(); } Incidence* lse = getLastSyncEvent(); if ( lse ) { lse->setReadOnly( false ); lse->setDescription( "" ); lse->setReadOnly( true ); } } } setModified( true ); } else { QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), question, i18n("Ok")) ; } delete calendar; updateView(); return ;//syncOK; #endif diff --git a/korganizer/kosyncprefsdialog.cpp b/korganizer/kosyncprefsdialog.cpp deleted file mode 100644 index 7c838f5..0000000 --- a/korganizer/kosyncprefsdialog.cpp +++ b/dev/null @@ -1,468 +0,0 @@ -/* - This file is part of KOrganizer. - Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - As a special exception, permission is given to link this program - with any edition of Qt, and distribute the resulting executable, - without including the source code for Qt in the source distribution. -*/ - -#include <qlayout.h> -#include <qlabel.h> -#include <qgroupbox.h> -#include <qbuttongroup.h> -#include <qlineedit.h> -#include <qfont.h> -#include <qslider.h> -#include <qfile.h> -#include <qdir.h> -#include <qtextstream.h> -#include <qcombobox.h> -#include <qvbox.h> -#include <qhbox.h> -#include <qspinbox.h> -#include <qdatetime.h> -#include <qcheckbox.h> -#include <qradiobutton.h> -#include <qpushbutton.h> -#include <qstrlist.h> -#include <qapplication.h> - -#include <kcolorbutton.h> -#include <kdebug.h> -#include <klocale.h> -#include <kglobal.h> -#include <kfontdialog.h> -#include <kmessagebox.h> -#include <kcolordialog.h> -#include <kiconloader.h> -#include <kemailsettings.h> -#include <kstandarddirs.h> -#include <kfiledialog.h> -#include <kmessagebox.h> - -#include <kurlrequester.h> -#include <klineedit.h> -#include <libkdepim/ksyncprofile.h> - - -//#include "koprefs.h" - -#include "kosyncprefsdialog.h" -//#include "koglobals.h" - - -KOSyncPrefsDialog::KOSyncPrefsDialog(QWidget *parent, char *name, bool modal) : - KDialog(parent,name,true) -{ - - setCaption( i18n("Synchronization Preferences")); - - mSyncProfiles.setAutoDelete( true ); - setupSyncAlgTab(); -} - - -KOSyncPrefsDialog::~KOSyncPrefsDialog() -{ -} - -#include <qlayout.h> -#include <qscrollview.h> -void KOSyncPrefsDialog::setupSyncAlgTab() -{ - QLabel * lab; - //QFrame *page = addPage(i18n("Sync Prefs"),0,0); - QVBox * mainbox = new QVBox( this ); - QScrollView* sv = new QScrollView( mainbox ); - QHBoxLayout * lay = new QHBoxLayout( this ); - lay->addWidget( mainbox ); - QHBox * b_box = new QHBox( mainbox ); - - QPushButton* button = new QPushButton( i18n("Ok"), b_box ); - connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); - button = new QPushButton( i18n("Cancel"), b_box ); - connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); - //QBoxLayout * sl = new QVBoxLayout(this ); - //sl->addWidget ( sv ); - sv->setResizePolicy ( QScrollView::AutoOneFit ); - QFrame *topFrame = new QFrame ( sv ); - sv->addChild( topFrame ); - mSetupSyncAlgTab = topFrame; - QGridLayout *topLayout = new QGridLayout(topFrame,6,2); - topLayout->setSpacing(spacingHint()); - topLayout->setMargin(marginHint()); - - //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); - int iii = 0; - //topLayout->addMultiCellWidget(lab , iii,iii,0,1); - //++iii; - - mMyMachineName = new QLineEdit(topFrame); - lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); - topLayout->addWidget(lab ,iii,0); - topLayout->addWidget(mMyMachineName,iii,1); - ++iii; - - QHBox* buttonbox = new QHBox( topFrame); - topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); - ++iii; - button = new QPushButton( i18n("New profile"), buttonbox ); - connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); - - button = new QPushButton( i18n("Clone profile"), buttonbox ); - connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); - - button = new QPushButton( i18n("Delete profile"), buttonbox ); - connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); - - mProfileBox = new QComboBox(topFrame); - mProfileBox->setEditable ( true ); - connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); - connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); - - lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); - topLayout->addWidget(lab ,iii,0); - topLayout->addWidget(mProfileBox, iii,1); - ++iii; - - mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), topFrame ); - topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1); - ++iii; - - mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); - topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); - ++iii; - QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); - topLayout->addMultiCellWidget(gr, iii,iii,0,1); - ++iii; - loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); - rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); - newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); - ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); - f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); - f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); - // both = new QRadioButton ( i18n("Take both on conflict"), gr ); - - mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); - topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); - ++iii; - - mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), topFrame ); - topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); - ++iii; - - mWriteBackFile = new QCheckBox( i18n("Write back file"), topFrame ); - topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); - ++iii; - - proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); - gr = proGr; - topLayout->addMultiCellWidget(gr, iii,iii,0,1); - ++iii; - mIsLocal = new QRadioButton ( i18n("Local file"), gr ); - mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); - connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); - - localFileWidget = new QVBox( topFrame); - topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); - ++iii; - QHBox* temphb = new QHBox( localFileWidget ); - lab = new QLabel( i18n("Local file:"), temphb); - mRemoteFile = new QLineEdit(localFileWidget); - - button = new QPushButton( i18n("Choose..."), temphb ); - connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); - - - remoteFileWidget = new QVBox( topFrame); - topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); - ++iii; - lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); - mRemotePrecommand = new QLineEdit(remoteFileWidget); - - lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); - mLocalTempFile = new QLineEdit(remoteFileWidget); - - - lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); - mRemotePostcommand = new QLineEdit(remoteFileWidget); - - lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); - temphb = new QHBox( remoteFileWidget ); - button = new QPushButton( i18n("ssh/scp"), temphb ); - connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); - button = new QPushButton( i18n("ftp"), temphb ); - connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); - lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); - - -} -void KOSyncPrefsDialog::slotOK() -{ - if ( mMyMachineName->text() == "undefined" ) { - KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); - return; - } - int i; - for (i = 0; i < mSyncProfileNames.count(); ++ i) { - if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { - KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); - return; - } - } - usrWriteConfig(); - QDialog::accept(); -} -void KOSyncPrefsDialog::accept() -{ - slotOK(); -} -void KOSyncPrefsDialog::chooseFile() -{ - QString fn = QDir::homeDirPath(); - - fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); - if ( fn == "" ) - return; - mRemoteFile->setText( fn ); -} - -void KOSyncPrefsDialog::textChanged( const QString & s ) -{ - if ( mProfileBox->count() == 0 ) - return; - if ( currentSelection < 3 ) { - //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); - mProfileBox->blockSignals( true ); - mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); - mProfileBox->blockSignals( false ); - return; - } - //qDebug("cur i %d ",mProfileBox-> currentItem () ); - mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; - KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; - prof->setName( s ); - mSyncProfileNames[mProfileBox-> currentItem ()] = s; -} -void KOSyncPrefsDialog::profileChanged( int item ) -{ - //qDebug("KOSyncPrefsDialog::profileChanged %d ", item ); - KSyncProfile* prof; - saveProfile(); - currentSelection = item; - prof = mSyncProfiles.at(item) ; - mRemotePrecommand->setText(prof->getPreSyncCommand()); - mRemotePostcommand->setText(prof->getPostSyncCommand()); - mLocalTempFile->setText(prof->getLocalTempFile()); - mRemoteFile->setText(prof->getRemoteFileName()) ; - mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); - mAskForPreferences->setChecked( prof->getAskForPreferences()); - mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); - mWriteBackFile->setChecked( prof->getWriteBackFile()); - mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); - - switch ( prof->getSyncPrefs() ) { - case 0: - loc->setChecked( true); - break; - case 1: - rem->setChecked( true ); - break; - case 2: - newest->setChecked( true); - break; - case 3: - ask->setChecked( true); - break; - case 4: - f_loc->setChecked( true); - break; - case 5: - f_rem->setChecked( true); - break; - case 6: - //both->setChecked( true); - break; - default: - break; - } - mIsLocal->setChecked(prof->getIsLocalFileSync()) ; - mIsNotLocal->setChecked(!prof->getIsLocalFileSync()); - proGr->setEnabled( item > 2 ); - if ( item < 3 ) { - localFileWidget->setEnabled(false); - remoteFileWidget->setEnabled(false); - - } else - kindChanged( prof->getIsLocalFileSync() ); -} - -void KOSyncPrefsDialog::fillSSH() -{ - mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); - mLocalTempFile->setText("/tmp/mycalendar.ics" ); - mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); -} -void KOSyncPrefsDialog::fillFTP() -{ - mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); - mLocalTempFile->setText("/tmp/mycalendar.ics" ); - mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); - -} -void KOSyncPrefsDialog::kindChanged( bool b ) -{ - - localFileWidget->setEnabled(b); - remoteFileWidget->setEnabled(!b); - -} -void KOSyncPrefsDialog::deleteProfile() -{ - //qDebug("KOSyncPrefsDialog::deleteProfile() "); - if ( currentSelection >= 0 ) { - if ( currentSelection < 3 ) { - KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); - return; - } - KSyncProfile* temp = mSyncProfiles.at(currentSelection); - mSyncProfiles.remove( temp ); - mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); - insertProfiles(); - } -} - -void KOSyncPrefsDialog::saveProfile() -{ - KSyncProfile* prof; - if ( currentSelection >= 0 ) { - prof = mSyncProfiles.at(currentSelection) ; - prof->setPreSyncCommand( mRemotePrecommand->text()); - prof->setPostSyncCommand( mRemotePostcommand->text() ); - prof->setLocalTempFile( mLocalTempFile->text()); - prof->setRemoteFileName( mRemoteFile->text() ); - prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); - prof->setAskForPreferences( mAskForPreferences->isChecked()); - prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); - prof->setWriteBackFile( mWriteBackFile->isChecked()); - prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); - int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; - prof->setSyncPrefs( syncprefs); - prof->setIsLocalFileSync( mIsLocal->isChecked() ); - } - -} - -void KOSyncPrefsDialog::insertProfiles() -{ - int curItem = mProfileBox->currentItem(); - mProfileBox->blockSignals( true ); - mProfileBox->clear(); - mProfileBox->insertStringList (mSyncProfileNames ); - int item = mSyncProfileNames.count() -1; - if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) - mProfileBox->setCurrentItem( curItem ); - else if ( item >= 0 ) { - mProfileBox->setCurrentItem( item ); - } - currentSelection = -1; - if ( mSyncProfileNames.count() > 0 ) { - //qDebug(" profileChanged( mProfileBox->currentItem() "); - profileChanged( mProfileBox->currentItem() ); - currentSelection = mProfileBox->currentItem(); - } - mProfileBox->blockSignals( false ); -} - -void KOSyncPrefsDialog::addProfile ( KSyncProfile* temp ) -{ - saveProfile(); - mSyncProfiles.append( temp ); - mSyncProfileNames << temp->getName(); - insertProfiles(); - int last = mProfileBox->count() -1; - mProfileBox->blockSignals( true ); - mProfileBox->setCurrentItem( last ); - mProfileBox->blockSignals( false ); - profileChanged(last); -} -void KOSyncPrefsDialog::newProfile() -{ - addProfile ( new KSyncProfile () ); -} - -void KOSyncPrefsDialog::cloneProfile() -{ - if ( currentSelection >= 0 ) - addProfile (mSyncProfiles.at(currentSelection)->clone()) ; - else - newProfile(); -} - -void KOSyncPrefsDialog::setLocalMachineName ( const QString& name ) -{ - mMyMachineName->setText( name ); - -} -QString KOSyncPrefsDialog::getLocalMachineName ( ) -{ - return mMyMachineName->text(); -} - -QStringList KOSyncPrefsDialog::getSyncProfileNames() -{ - return mSyncProfileNames; -} -void KOSyncPrefsDialog::usrReadConfig() -{ - //KConfig *config = KOGlobals::config(); - KConfig config ( locateLocal( "config","syncprofilesrc" ) ); - config.setGroup("SyncProfiles"); - mSyncProfileNames =config.readListEntry("SyncProfileNames"); - int i; - KSyncProfile* temp ; - mSyncProfiles.clear(); - for ( i = 0; i < mSyncProfileNames.count();++i ) { - temp = new KSyncProfile (); - temp->setName( mSyncProfileNames[i] ); - temp->readConfig( &config ); - mSyncProfiles.append( temp ); - } - insertProfiles(); - //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); -} - - -void KOSyncPrefsDialog::usrWriteConfig() -{ - saveProfile(); - if ( currentSelection >= 0 ) - profileChanged(currentSelection); - //KConfig *config = KOGlobals::config(); - KConfig config ( locateLocal( "config","syncprofilesrc" ) ); - config.setGroup("SyncProfiles"); - KSyncProfile* prof = mSyncProfiles.first(); - while ( prof ) { - prof->writeConfig(&config); - prof = mSyncProfiles.next(); - } - //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; - //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); - config.writeEntry("SyncProfileNames",&mSyncProfileNames); -} - diff --git a/korganizer/kosyncprefsdialog.h b/korganizer/kosyncprefsdialog.h deleted file mode 100644 index 541d18b..0000000 --- a/korganizer/kosyncprefsdialog.h +++ b/dev/null @@ -1,113 +0,0 @@ -/* - This file is part of KOrganizer. - Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - As a special exception, permission is given to link this program - with any edition of Qt, and distribute the resulting executable, - without including the source code for Qt in the source distribution. -*/ -#ifndef _KOPREFSDIALOG_H -#define _KOPREFSDIALOG_H - -//#include <qframe.h> -//#include <qdict.h> -#include <qvbox.h> -#include <qhbox.h> -//#include <qcolor.h> -//#include <qlistview.h> - -#include <kdialogbase.h> - -#include <libkdepim/kprefsdialog.h> - -class KColorButton; -class QSpinBox;; -class QRadioButton; -class QCheckBox; -class QSlider; -class KURLRequester; -class QComboBox; -class QLineEdit; -class QStringList; -class KSyncProfile; - -/** Dialog to change the korganizer configuration. - */ -class KOSyncPrefsDialog : public KDialog -{ - Q_OBJECT - public: - /** Initialize dialog and pages */ - KOSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); - ~KOSyncPrefsDialog(); - void usrReadConfig(); - void setLocalMachineName ( const QString& name ); - QString getLocalMachineName ( ); - - QStringList getSyncProfileNames(); - - public slots: - protected slots: - void accept(); - void deleteProfile(); - void newProfile(); - void cloneProfile(); - void kindChanged(bool); - void fillSSH(); - void fillFTP(); - void textChanged( const QString & ); - void profileChanged( int ); - void chooseFile(); - void slotOK(); - - protected: - void usrWriteConfig(); - - void setupSyncAlgTab(); - - private: - int currentSelection; - QPtrList<KSyncProfile> mSyncProfiles; - QStringList mSyncProfileNames; - QLineEdit * mMyMachineName; - QComboBox * mProfileBox; - QRadioButton* mIsLocal; - QRadioButton* mIsNotLocal; - QCheckBox* mIncludeInRing; - void addProfile ( KSyncProfile* ); - void insertProfiles(); - void saveProfile(); - QButtonGroup* proGr; - - QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both; - - - QLineEdit * mRemotePostcommand; - QLineEdit * mRemotePrecommand; - QLineEdit * mRemoteFile; - QLineEdit * mLocalTempFile; - QWidget* mSetupSyncAlgTab; - - QVBox* localFileWidget; - QVBox* remoteFileWidget; - QCheckBox* mWriteBackFile; - QCheckBox* mWriteBackExisting; - QCheckBox* mAskForPreferences; - QCheckBox* mShowSummaryAfterSync; -}; - -#endif |