-rw-r--r-- | korganizer/calendarview.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 1d62046..e4c067e 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -34,220 +34,225 @@ #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 <libkdepim/ksyncprefsdialog.h> #include <krun.h> #include <kdirwatch.h> #include <libkdepim/kdatepicker.h> #include <libkdepim/ksyncprofile.h> #include <libkdepim/kpimglobalprefs.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> #include <externalapphandler.h> #endif #include <libkcal/phoneformat.h> #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 +#ifdef DESKTOP_VERSION +#include <kabc/stdaddressbook.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 ); + tz->setChecked( true );#ifdef DESKTOP_VERSION +#include <kabc/stdaddressbook.h> +#endif 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. @@ -1237,193 +1242,192 @@ bool CalendarView::syncCalendar(QString filename, int mode) } void CalendarView::syncPhone() { syncExternal( 1 ); } void CalendarView::syncExternal( int mode ) { 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; bool loadSuccess = false; PhoneFormat* phoneFormat = 0; #ifndef DESKTOP_VERSION SharpFormat* sharpFormat = 0; if ( mode == 0 ) { // sharp sharpFormat = new SharpFormat () ; loadSuccess = sharpFormat->load( calendar, mCalendar ); } else #endif if ( mode == 1 ) { // phone phoneFormat = new PhoneFormat (mCurrentSyncDevice, KOPrefs::instance()->mPhoneDevice, KOPrefs::instance()->mPhoneConnection, KOPrefs::instance()->mPhoneModel); loadSuccess = phoneFormat->load( calendar,mCalendar); } else return; if ( loadSuccess ) { 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(); if ( phoneFormat ) { while ( inc ) { inc->removeID(mCurrentSyncDevice); inc = iL.next(); } } #ifndef DESKTOP_VERSION if ( sharpFormat ) sharpFormat->save(calendar); #endif if ( phoneFormat ) phoneFormat->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->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); } } 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; } void CalendarView::syncSharp() { syncExternal( 0 ); } -//#include <kabc/stdaddressbook.h> bool CalendarView::importBday() { #ifndef KORG_NOKABC #ifdef DESKTOP_VERSION KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); KABC::AddressBook::Iterator it; int count = 0; for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { ++count; } QProgressBar bar(count,0 ); 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(); bar.setCaption (i18n("Reading addressbook - close to abort!") ); qApp->processEvents(); count = 0; int addCount = 0; KCal::Attendee* a = 0; for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { if ( ! bar.isVisible() ) return false; bar.setProgress( count++ ); qApp->processEvents(); //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); if ( (*it).birthday().date().isValid() ){ a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) ++addCount; } QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); if ( anni.isValid() ){ a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) ++addCount; } } updateView(); topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); #else //DESKTOP_VERSION ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); // the result should now arrive through method insertBirthdays #endif //DESKTOP_VERSION #endif //KORG_NOKABC return true; } // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, const QStringList& anniversaryList, const QStringList& realNameList, const QStringList& emailList, const QStringList& assembledNameList, const QStringList& uidList) { qDebug("CalendarView::insertBirthdays"); if (uid == this->name()) { int count = birthdayList.count(); int addCount = 0; KCal::Attendee* a = 0; qDebug("CalView 1 %i", count); QProgressBar bar(count,0 ); 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(); bar.setCaption (i18n("inserting birthdays - close to abort!") ); qApp->processEvents(); QDate birthday; QDate anniversary; QString realName; QString email; QString assembledName; QString uid; bool ok = true; for ( int i = 0; i < count; i++) { if ( ! bar.isVisible() ) return; |