summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koprefs.cpp6
-rw-r--r--korganizer/koprefs.h3
-rw-r--r--korganizer/mainwindow.cpp134
-rw-r--r--korganizer/mainwindow.h1
4 files changed, 144 insertions, 0 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index c28da9a..716a125 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -77,6 +77,12 @@ KOPrefs::KOPrefs() :
mJornalViewFont = QFont("helvetica",12);
KPrefs::setCurrentGroup("General");
+
+
+ addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm");
+ addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda");
+ addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i");
+
addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index d9ac851..a1ba8b3 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -210,6 +210,9 @@ class KOPrefs : public KPimPrefs
QString mPhoneDevice;
QString mPhoneConnection;
QString mPhoneModel;
+ QString mEx2PhoneDevice;
+ QString mEx2PhoneConnection;
+ QString mEx2PhoneModel;
int mLastSyncTime;
int mSyncAlgoPrefs;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index de94b8c..ef73a78 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -13,6 +13,8 @@
#include <qapp.h>
#include <qfileinfo.h>
#include <qlabel.h>
+#include <qspinbox.h>
+#include <qcheckbox.h>
#include <qmap.h>
#include <qwmatrix.h>
#include <qtextbrowser.h>
@@ -35,6 +37,7 @@
#endif
#include <libkcal/calendarlocal.h>
#include <libkcal/todo.h>
+#include <libkcal/phoneformat.h>
#include <libkdepim/ksyncprofile.h>
#include <libkcal/kincidenceformatter.h>
#include <libkdepim/kpimglobalprefs.h>
@@ -66,6 +69,55 @@ using namespace KCal;
#endif
#include "mainwindow.h"
+class KOex2phonePrefs : public QDialog
+{
+ public:
+ KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
+ QDialog( parent, name, true )
+ {
+ setCaption( i18n("Export to phone options") );
+ QVBoxLayout* lay = new QVBoxLayout( this );
+ lay->setSpacing( 3 );
+ lay->setMargin( 3 );
+
+ lay->addWidget(new QLabel( i18n("Please read phone sync howto to\nknow more about the connection settings."), this ) );
+ QHBox* temphb;
+ temphb = new QHBox( this );
+ new QLabel( i18n("I/O device: "), temphb );
+ mPhoneDevice = new QLineEdit( temphb);
+ lay->addWidget( temphb );
+ temphb = new QHBox( this );
+ new QLabel( i18n("Connection: "), temphb );
+ mPhoneConnection = new QLineEdit( temphb);
+ lay->addWidget( temphb );
+ temphb = new QHBox( this );
+ new QLabel( i18n("Model(opt.): "), temphb );
+ mPhoneModel = new QLineEdit( temphb);
+ lay->addWidget( temphb );
+ mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
+ mWriteBackFuture->setChecked( true );
+ lay->addWidget( mWriteBackFuture );
+ temphb = new QHBox( this );
+ new QLabel( i18n("Max. weeks in future: ") , temphb );
+ mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
+ mWriteBackFutureWeeks->setValue( 8 );
+ lay->addWidget( temphb );
+ QPushButton * ok = new QPushButton( i18n("Export!"), 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( 220, 220 );
+
+ }
+
+public:
+ QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
+ QCheckBox* mWriteBackFuture;
+ QSpinBox* mWriteBackFutureWeeks;
+};
+
int globalFlagBlockStartup;
MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
QMainWindow( parent, name )
@@ -653,6 +705,15 @@ void MainWindow::initActions()
action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
this );
action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
+
+
+ //LR
+ QPopupMenu *ex2phone = new QPopupMenu( this );
+ ex2phone->insertItem(i18n("Complete calendar..."), 1 );
+ ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
+ connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
+ importMenu->insertItem( i18n("Export to phone"), ex2phone );
+
importMenu->insertSeparator();
action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
this );
@@ -1087,6 +1148,78 @@ void MainWindow::slotSyncMenu( int action )
delete temp;
mBlockSaveFlag = false;
}
+void MainWindow::exportToPhone( int mode )
+{
+
+ //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
+ //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
+ KOex2phonePrefs ex2phone;
+ ex2phone.mPhoneConnection->setText( KOPrefs::instance()->mEx2PhoneConnection );
+ ex2phone.mPhoneDevice->setText( KOPrefs::instance()->mEx2PhoneDevice );
+ ex2phone.mPhoneModel->setText( KOPrefs::instance()->mEx2PhoneModel );
+
+ if ( !ex2phone.exec() ) {
+ return;
+ }
+ KOPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
+ KOPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
+ KOPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
+
+ int inFuture = 0;
+ if ( ex2phone.mWriteBackFuture->isChecked() )
+ inFuture = ex2phone.mWriteBackFutureWeeks->value();
+ QPtrList<Incidence> delSel;
+ if ( mode == 1 )
+ delSel = mCalendar->rawIncidences();
+ if ( mode == 2 )
+ delSel = mCalendar->incidences();
+ CalendarLocal* cal = new CalendarLocal();
+ cal->setLocalTime();
+ Incidence *incidence = delSel.first();
+ QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
+ QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
+ while ( incidence ) {
+ if ( incidence->type() != "journal" ) {
+ bool add = true;
+ if ( inFuture ) {
+ QDateTime dt;
+ if ( incidence->type() == "Todo" ) {
+ Todo * t = (Todo*)incidence;
+ if ( t->hasDueDate() )
+ dt = t->dtDue();
+ else
+ dt = cur.addSecs( 62 );
+ }
+ else {
+ bool ok;
+ dt = incidence->getNextOccurence( cur, &ok );
+ if ( !ok )
+ dt = cur.addSecs( -62 );
+ }
+ if ( dt < cur || dt > end ) {
+ add = false;
+ }
+ }
+ if ( add ) {
+ Incidence *in = incidence->clone();
+ cal->addIncidence( in );
+ }
+ }
+ incidence = delSel.next();
+ }
+ PhoneFormat::writeConfig( KOPrefs::instance()->mEx2PhoneDevice,
+ KOPrefs::instance()->mEx2PhoneConnection,
+ KOPrefs::instance()->mEx2PhoneModel );
+
+ setCaption( i18n("Writing to phone..."));
+ if ( PhoneFormat::writeToPhone( cal ) )
+ setCaption( i18n("Export to phone successful!"));
+ else
+ setCaption( i18n("Error exporting to phone!"));
+ delete cal;
+}
+
+
void MainWindow::setDefaultPreferences()
{
KOPrefs *p = KOPrefs::instance();
@@ -1094,6 +1227,7 @@ void MainWindow::setDefaultPreferences()
p->mCompactDialogs = true;
p->mConfirm = true;
// p->mEnableQuickTodo = false;
+
}
QString MainWindow::resourcePath()
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 7b24b88..74c7f45 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -144,6 +144,7 @@ class MainWindow : public QMainWindow
void exportVCalendar();
void fillFilterMenu();
void selectFilter( int );
+ void exportToPhone( int );
void slotSyncMenu( int );
void confSync();