summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index ef73a78..6a9a2f1 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,303 +1,306 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkcal/kincidenceformatter.h> 42#include <libkcal/kincidenceformatter.h>
43#include <libkdepim/kpimglobalprefs.h> 43#include <libkdepim/kpimglobalprefs.h>
44 44
45#include "calendarview.h" 45#include "calendarview.h"
46#include "koviewmanager.h" 46#include "koviewmanager.h"
47#include "datenavigator.h" 47#include "datenavigator.h"
48#include "koagendaview.h" 48#include "koagendaview.h"
49#include "koagenda.h" 49#include "koagenda.h"
50#include "kodialogmanager.h" 50#include "kodialogmanager.h"
51#include "kdialogbase.h" 51#include "kdialogbase.h"
52#include "kapplication.h" 52#include "kapplication.h"
53#include "kofilterview.h" 53#include "kofilterview.h"
54#include "kstandarddirs.h" 54#include "kstandarddirs.h"
55#include "koprefs.h" 55#include "koprefs.h"
56#include "kfiledialog.h" 56#include "kfiledialog.h"
57#include "koglobals.h" 57#include "koglobals.h"
58#include "kglobal.h" 58#include "kglobal.h"
59#include "klocale.h" 59#include "klocale.h"
60#include "kconfig.h" 60#include "kconfig.h"
61#include "simplealarmclient.h" 61#include "simplealarmclient.h"
62#include "externalapphandler.h" 62#include "externalapphandler.h"
63 63
64using namespace KCal; 64using namespace KCal;
65#ifndef _WIN32_ 65#ifndef _WIN32_
66#include <unistd.h> 66#include <unistd.h>
67#else 67#else
68#include "koimportoldialog.h" 68#include "koimportoldialog.h"
69#endif 69#endif
70#include "mainwindow.h" 70#include "mainwindow.h"
71 71
72class KOex2phonePrefs : public QDialog 72class KOex2phonePrefs : public QDialog
73{ 73{
74 public: 74 public:
75 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 75 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
76 QDialog( parent, name, true ) 76 QDialog( parent, name, true )
77 { 77 {
78 setCaption( i18n("Export to phone options") ); 78 setCaption( i18n("Export to phone options") );
79 QVBoxLayout* lay = new QVBoxLayout( this ); 79 QVBoxLayout* lay = new QVBoxLayout( this );
80 lay->setSpacing( 3 ); 80 lay->setSpacing( 3 );
81 lay->setMargin( 3 ); 81 lay->setMargin( 3 );
82 82 QLabel *lab;
83 lay->addWidget(new QLabel( i18n("Please read phone sync howto to\nknow more about the connection settings."), this ) ); 83 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
84 lab->setAlignment (AlignHCenter );
84 QHBox* temphb; 85 QHBox* temphb;
85 temphb = new QHBox( this ); 86 temphb = new QHBox( this );
86 new QLabel( i18n("I/O device: "), temphb ); 87 new QLabel( i18n("I/O device: "), temphb );
87 mPhoneDevice = new QLineEdit( temphb); 88 mPhoneDevice = new QLineEdit( temphb);
88 lay->addWidget( temphb ); 89 lay->addWidget( temphb );
89 temphb = new QHBox( this ); 90 temphb = new QHBox( this );
90 new QLabel( i18n("Connection: "), temphb ); 91 new QLabel( i18n("Connection: "), temphb );
91 mPhoneConnection = new QLineEdit( temphb); 92 mPhoneConnection = new QLineEdit( temphb);
92 lay->addWidget( temphb ); 93 lay->addWidget( temphb );
93 temphb = new QHBox( this ); 94 temphb = new QHBox( this );
94 new QLabel( i18n("Model(opt.): "), temphb ); 95 new QLabel( i18n("Model(opt.): "), temphb );
95 mPhoneModel = new QLineEdit( temphb); 96 mPhoneModel = new QLineEdit( temphb);
96 lay->addWidget( temphb ); 97 lay->addWidget( temphb );
97 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 98 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
98 mWriteBackFuture->setChecked( true ); 99 mWriteBackFuture->setChecked( true );
99 lay->addWidget( mWriteBackFuture ); 100 lay->addWidget( mWriteBackFuture );
100 temphb = new QHBox( this ); 101 temphb = new QHBox( this );
101 new QLabel( i18n("Max. weeks in future: ") , temphb ); 102 new QLabel( i18n("Max. weeks in future: ") , temphb );
102 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 103 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
103 mWriteBackFutureWeeks->setValue( 8 ); 104 mWriteBackFutureWeeks->setValue( 8 );
104 lay->addWidget( temphb ); 105 lay->addWidget( temphb );
105 QPushButton * ok = new QPushButton( i18n("Export!"), this ); 106 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\n todo/calendar data on phone!"), this ) );
107 lab->setAlignment (AlignHCenter );
108 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
106 lay->addWidget( ok ); 109 lay->addWidget( ok );
107 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 110 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
108 lay->addWidget( cancel ); 111 lay->addWidget( cancel );
109 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 112 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
110 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 113 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
111 resize( 220, 220 ); 114 resize( 220, 240 );
112 115
113 } 116 }
114 117
115public: 118public:
116 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 119 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
117 QCheckBox* mWriteBackFuture; 120 QCheckBox* mWriteBackFuture;
118 QSpinBox* mWriteBackFutureWeeks; 121 QSpinBox* mWriteBackFutureWeeks;
119}; 122};
120 123
121int globalFlagBlockStartup; 124int globalFlagBlockStartup;
122MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 125MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
123 QMainWindow( parent, name ) 126 QMainWindow( parent, name )
124{ 127{
125 mPassWordPiSync = "abc"; 128 mPassWordPiSync = "abc";
126#ifdef DESKTOP_VERSION 129#ifdef DESKTOP_VERSION
127 setFont( QFont("Arial"), 14 ); 130 setFont( QFont("Arial"), 14 );
128#endif 131#endif
129 mSyncActionDialog = 0; 132 mSyncActionDialog = 0;
130 mServerSocket = 0; 133 mServerSocket = 0;
131 mClosed = false; 134 mClosed = false;
132 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 135 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
133 QString confFile = locateLocal("config","korganizerrc"); 136 QString confFile = locateLocal("config","korganizerrc");
134 QFileInfo finf ( confFile ); 137 QFileInfo finf ( confFile );
135 bool showWarning = !finf.exists(); 138 bool showWarning = !finf.exists();
136 setIcon(SmallIcon( "ko24" ) ); 139 setIcon(SmallIcon( "ko24" ) );
137 mBlockAtStartup = true; 140 mBlockAtStartup = true;
138 mFlagKeyPressed = false; 141 mFlagKeyPressed = false;
139 setCaption("KOrganizer/Pi"); 142 setCaption("KOrganizer/Pi");
140 KOPrefs *p = KOPrefs::instance(); 143 KOPrefs *p = KOPrefs::instance();
141 KPimGlobalPrefs::instance()->setGlobalConfig(); 144 KPimGlobalPrefs::instance()->setGlobalConfig();
142 // if ( QApplication::desktop()->height() > 480 ) { 145 // if ( QApplication::desktop()->height() > 480 ) {
143// if ( p->mHourSize == 4 ) 146// if ( p->mHourSize == 4 )
144// p->mHourSize = 6; 147// p->mHourSize = 6;
145// } 148// }
146 if ( p->mHourSize > 18 ) 149 if ( p->mHourSize > 18 )
147 p->mHourSize = 18; 150 p->mHourSize = 18;
148 QMainWindow::ToolBarDock tbd; 151 QMainWindow::ToolBarDock tbd;
149 if ( p->mToolBarHor ) { 152 if ( p->mToolBarHor ) {
150 if ( p->mToolBarUp ) 153 if ( p->mToolBarUp )
151 tbd = Bottom; 154 tbd = Bottom;
152 else 155 else
153 tbd = Top; 156 tbd = Top;
154 } 157 }
155 else { 158 else {
156 if ( p->mToolBarUp ) 159 if ( p->mToolBarUp )
157 tbd = Right; 160 tbd = Right;
158 else 161 else
159 tbd = Left; 162 tbd = Left;
160 } 163 }
161 if ( KOPrefs::instance()->mUseAppColors ) 164 if ( KOPrefs::instance()->mUseAppColors )
162 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
163 globalFlagBlockStartup = 1; 166 globalFlagBlockStartup = 1;
164 iconToolBar = new QPEToolBar( this ); 167 iconToolBar = new QPEToolBar( this );
165 addToolBar (iconToolBar , tbd ); 168 addToolBar (iconToolBar , tbd );
166 mBlockSaveFlag = false; 169 mBlockSaveFlag = false;
167 mCalendarModifiedFlag = false; 170 mCalendarModifiedFlag = false;
168 171
169 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 172 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
170 splash->setAlignment ( AlignCenter ); 173 splash->setAlignment ( AlignCenter );
171 setCentralWidget( splash ); 174 setCentralWidget( splash );
172#ifndef DESKTOP_VERSION 175#ifndef DESKTOP_VERSION
173 showMaximized(); 176 showMaximized();
174#endif 177#endif
175 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 178 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
176 setDefaultPreferences(); 179 setDefaultPreferences();
177 mCalendar = new CalendarLocal(); 180 mCalendar = new CalendarLocal();
178 mView = new CalendarView( mCalendar, this,"mCalendar " ); 181 mView = new CalendarView( mCalendar, this,"mCalendar " );
179 mView->hide(); 182 mView->hide();
180 //mView->resize(splash->size() ); 183 //mView->resize(splash->size() );
181 initActions(); 184 initActions();
182#ifndef DESKTOP_VERSION 185#ifndef DESKTOP_VERSION
183 iconToolBar->show(); 186 iconToolBar->show();
184 qApp->processEvents(); 187 qApp->processEvents();
185#endif 188#endif
186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 189 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
187 int vh = height() ; 190 int vh = height() ;
188 int vw = width(); 191 int vw = width();
189 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 192 //qDebug("Toolbar hei %d ",iconToolBar->height() );
190 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 193 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
191 vh -= iconToolBar->height(); 194 vh -= iconToolBar->height();
192 } else { 195 } else {
193 vw -= iconToolBar->height(); 196 vw -= iconToolBar->height();
194 } 197 }
195 //mView->setMaximumSize( splash->size() ); 198 //mView->setMaximumSize( splash->size() );
196 //mView->resize( splash->size() ); 199 //mView->resize( splash->size() );
197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
198 mView->readSettings(); 201 mView->readSettings();
199 bool newFile = false; 202 bool newFile = false;
200 if( !QFile::exists( defaultFileName() ) ) { 203 if( !QFile::exists( defaultFileName() ) ) {
201 QFileInfo finfo ( defaultFileName() ); 204 QFileInfo finfo ( defaultFileName() );
202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 205 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
203 qDebug("oldfile %s ", oldFile.latin1()); 206 qDebug("oldfile %s ", oldFile.latin1());
204 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 207 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
205 finfo.setFile( oldFile ); 208 finfo.setFile( oldFile );
206 if (finfo.exists() ) { 209 if (finfo.exists() ) {
207 KMessageBox::information( this, message); 210 KMessageBox::information( this, message);
208 mView->openCalendar( oldFile ); 211 mView->openCalendar( oldFile );
209 qApp->processEvents(); 212 qApp->processEvents();
210 } else { 213 } else {
211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 214 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
212 finfo.setFile( oldFile ); 215 finfo.setFile( oldFile );
213 if (finfo.exists() ) { 216 if (finfo.exists() ) {
214 KMessageBox::information( this, message); 217 KMessageBox::information( this, message);
215 mView->openCalendar( oldFile ); 218 mView->openCalendar( oldFile );
216 qApp->processEvents(); 219 qApp->processEvents();
217 } 220 }
218 } 221 }
219 mView->saveCalendar( defaultFileName() ); 222 mView->saveCalendar( defaultFileName() );
220 newFile = true; 223 newFile = true;
221 } 224 }
222 225
223 QTime neededSaveTime = QDateTime::currentDateTime().time(); 226 QTime neededSaveTime = QDateTime::currentDateTime().time();
224 mView->openCalendar( defaultFileName() ); 227 mView->openCalendar( defaultFileName() );
225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 228 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
226 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 229 qDebug("KO: Calendar loading time: %d ms",msNeeded );
227 230
228 if ( KOPrefs::instance()->mLanguageChanged ) { 231 if ( KOPrefs::instance()->mLanguageChanged ) {
229 KOPrefs::instance()->setCategoryDefaults(); 232 KOPrefs::instance()->setCategoryDefaults();
230 int count = mView->addCategories(); 233 int count = mView->addCategories();
231 KOPrefs::instance()->mLanguageChanged = false; 234 KOPrefs::instance()->mLanguageChanged = false;
232 } 235 }
233 processIncidenceSelection( 0 ); 236 processIncidenceSelection( 0 );
234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 237 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
235 SLOT( processIncidenceSelection( Incidence * ) ) ); 238 SLOT( processIncidenceSelection( Incidence * ) ) );
236 connect( mView, SIGNAL( modifiedChanged( bool ) ), 239 connect( mView, SIGNAL( modifiedChanged( bool ) ),
237 SLOT( slotModifiedChanged( bool ) ) ); 240 SLOT( slotModifiedChanged( bool ) ) );
238 241
239 242
240 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 243 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
241 mView->setModified( false ); 244 mView->setModified( false );
242 mBlockAtStartup = false; 245 mBlockAtStartup = false;
243 mView->setModified( false ); 246 mView->setModified( false );
244 setCentralWidget( mView ); 247 setCentralWidget( mView );
245 globalFlagBlockStartup = 0; 248 globalFlagBlockStartup = 0;
246 mView->show(); 249 mView->show();
247 delete splash; 250 delete splash;
248 if ( newFile ) 251 if ( newFile )
249 mView->updateConfig(); 252 mView->updateConfig();
250 // qApp->processEvents(); 253 // qApp->processEvents();
251 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 254 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
252 fillSyncMenu(); 255 fillSyncMenu();
253 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 256 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
254 if ( showWarning ) { 257 if ( showWarning ) {
255 KMessageBox::information( this, 258 KMessageBox::information( this,
256 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 259 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
257 qApp->processEvents(); 260 qApp->processEvents();
258 mView->dialogManager()->showSyncOptions(); 261 mView->dialogManager()->showSyncOptions();
259 } 262 }
260 263
261 //US listen for result adressed from Ka/Pi 264 //US listen for result adressed from Ka/Pi
262#ifndef DESKTOP_VERSION 265#ifndef DESKTOP_VERSION
263 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 266 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
264#endif 267#endif
265} 268}
266MainWindow::~MainWindow() 269MainWindow::~MainWindow()
267{ 270{
268 //qDebug("MainWindow::~MainWindow() "); 271 //qDebug("MainWindow::~MainWindow() ");
269 //save toolbar location 272 //save toolbar location
270 delete mServerSocket; 273 delete mServerSocket;
271 delete mCalendar; 274 delete mCalendar;
272 delete KOPrefs::instance(); 275 delete KOPrefs::instance();
273 delete KIncidenceFormatter::instance(); 276 delete KIncidenceFormatter::instance();
274 277
275 278
276} 279}
277void MainWindow::showMaximized () 280void MainWindow::showMaximized ()
278{ 281{
279#ifndef DESKTOP_VERSION 282#ifndef DESKTOP_VERSION
280 if ( ! globalFlagBlockStartup ) 283 if ( ! globalFlagBlockStartup )
281 if ( mClosed ) 284 if ( mClosed )
282 mView->goToday(); 285 mView->goToday();
283#endif 286#endif
284 QWidget::showMaximized () ; 287 QWidget::showMaximized () ;
285 mClosed = false; 288 mClosed = false;
286} 289}
287void MainWindow::closeEvent( QCloseEvent* ce ) 290void MainWindow::closeEvent( QCloseEvent* ce )
288{ 291{
289 292
290 293
291 294
292 if ( ! KOPrefs::instance()->mAskForQuit ) { 295 if ( ! KOPrefs::instance()->mAskForQuit ) {
293 saveOnClose(); 296 saveOnClose();
294 mClosed = true; 297 mClosed = true;
295 ce->accept(); 298 ce->accept();
296 return; 299 return;
297 300
298 } 301 }
299 302
300 switch( QMessageBox::information( this, "KO/Pi", 303 switch( QMessageBox::information( this, "KO/Pi",
301 i18n("Do you really want\nto close KO/Pi?"), 304 i18n("Do you really want\nto close KO/Pi?"),
302 i18n("Close"), i18n("No"), 305 i18n("Close"), i18n("No"),
303 0, 0 ) ) { 306 0, 0 ) ) {
@@ -968,384 +971,388 @@ void MainWindow::fillSyncMenu()
968 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 971 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
969 syncMenu->setItemEnabled( false , 1000 ); 972 syncMenu->setItemEnabled( false , 1000 );
970 } 973 }
971 mView->setupExternSyncProfiles(); 974 mView->setupExternSyncProfiles();
972} 975}
973 976
974int MainWindow::ringSync() 977int MainWindow::ringSync()
975{ 978{
976 int syncedProfiles = 0; 979 int syncedProfiles = 0;
977 int i; 980 int i;
978 QTime timer; 981 QTime timer;
979 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 982 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
980 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 983 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
981 KSyncProfile* temp = new KSyncProfile (); 984 KSyncProfile* temp = new KSyncProfile ();
982 KOPrefs::instance()->mAskForPreferences = false; 985 KOPrefs::instance()->mAskForPreferences = false;
983 for ( i = 0; i < syncProfileNames.count(); ++i ) { 986 for ( i = 0; i < syncProfileNames.count(); ++i ) {
984 mCurrentSyncProfile = i; 987 mCurrentSyncProfile = i;
985 temp->setName(syncProfileNames[mCurrentSyncProfile]); 988 temp->setName(syncProfileNames[mCurrentSyncProfile]);
986 temp->readConfig(&config); 989 temp->readConfig(&config);
987 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 990 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
988 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 991 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
989 ++syncedProfiles; 992 ++syncedProfiles;
990 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 993 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
991 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 994 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
992 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 995 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
993 KOPrefs::instance()->mWriteBackInFuture = 0; 996 KOPrefs::instance()->mWriteBackInFuture = 0;
994 if ( temp->getWriteBackFuture() ) 997 if ( temp->getWriteBackFuture() )
995 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 998 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
996 KOPrefs::instance()->mShowSyncSummary = false; 999 KOPrefs::instance()->mShowSyncSummary = false;
997 mView->setSyncDevice(syncProfileNames[i] ); 1000 mView->setSyncDevice(syncProfileNames[i] );
998 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1001 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
999 if ( i == 0 ) { 1002 if ( i == 0 ) {
1000 syncSharp(); 1003 syncSharp();
1001 } else { 1004 } else {
1002 if ( temp->getIsLocalFileSync() ) { 1005 if ( temp->getIsLocalFileSync() ) {
1003 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 1006 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
1004 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1007 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1005 } else { 1008 } else {
1006 if ( temp->getIsPhoneSync() ) { 1009 if ( temp->getIsPhoneSync() ) {
1007 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1010 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1008 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1011 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1009 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1012 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1010 syncPhone(); 1013 syncPhone();
1011 } else if ( temp->getIsPiSync() ) { 1014 } else if ( temp->getIsPiSync() ) {
1012 mPassWordPiSync = temp->getRemotePw(); 1015 mPassWordPiSync = temp->getRemotePw();
1013 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); 1016 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
1014 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); 1017 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
1015 syncPi(); 1018 syncPi();
1016 } else 1019 } else
1017 syncRemote( temp, false ); 1020 syncRemote( temp, false );
1018 1021
1019 } 1022 }
1020 } 1023 }
1021 timer.start(); 1024 timer.start();
1022 setCaption(i18n("Multiple sync in progress ... please wait!") ); 1025 setCaption(i18n("Multiple sync in progress ... please wait!") );
1023 while ( timer.elapsed () < 2000 ) { 1026 while ( timer.elapsed () < 2000 ) {
1024 qApp->processEvents(); 1027 qApp->processEvents();
1025#ifndef _WIN32_ 1028#ifndef _WIN32_
1026 sleep (1); 1029 sleep (1);
1027#endif 1030#endif
1028 } 1031 }
1029 1032
1030 } 1033 }
1031 1034
1032 } 1035 }
1033 delete temp; 1036 delete temp;
1034 return syncedProfiles; 1037 return syncedProfiles;
1035} 1038}
1036 1039
1037void MainWindow::multiSync( bool askforPrefs ) 1040void MainWindow::multiSync( bool askforPrefs )
1038{ 1041{
1039 if (mBlockSaveFlag) 1042 if (mBlockSaveFlag)
1040 return; 1043 return;
1041 mBlockSaveFlag = true; 1044 mBlockSaveFlag = true;
1042 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 1045 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
1043 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1046 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1044 question, 1047 question,
1045 i18n("Yes"), i18n("No"), 1048 i18n("Yes"), i18n("No"),
1046 0, 0 ) != 0 ) { 1049 0, 0 ) != 0 ) {
1047 mBlockSaveFlag = false; 1050 mBlockSaveFlag = false;
1048 setCaption(i18n("Aborted! Nothing synced!")); 1051 setCaption(i18n("Aborted! Nothing synced!"));
1049 return; 1052 return;
1050 } 1053 }
1051 mView->setSyncDevice(i18n("Multiple profiles") ); 1054 mView->setSyncDevice(i18n("Multiple profiles") );
1052 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 1055 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
1053 if ( askforPrefs ) { 1056 if ( askforPrefs ) {
1054 mView->edit_sync_options(); 1057 mView->edit_sync_options();
1055 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 1058 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
1056 } 1059 }
1057 setCaption(i18n("Multiple sync started.") ); 1060 setCaption(i18n("Multiple sync started.") );
1058 qApp->processEvents(); 1061 qApp->processEvents();
1059 int num = ringSync() ; 1062 int num = ringSync() ;
1060 if ( num > 1 ) 1063 if ( num > 1 )
1061 ringSync(); 1064 ringSync();
1062 mBlockSaveFlag = false; 1065 mBlockSaveFlag = false;
1063 if ( num ) 1066 if ( num )
1064 save(); 1067 save();
1065 if ( num ) 1068 if ( num )
1066 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 1069 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
1067 else 1070 else
1068 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 1071 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
1069 return; 1072 return;
1070} 1073}
1071void MainWindow::slotSyncMenu( int action ) 1074void MainWindow::slotSyncMenu( int action )
1072{ 1075{
1073 qDebug("syncaction %d ", action); 1076 qDebug("syncaction %d ", action);
1074 if ( action == 0 ) { 1077 if ( action == 0 ) {
1075 1078
1076 // seems to be a Qt2 event handling bug 1079 // seems to be a Qt2 event handling bug
1077 // syncmenu.clear causes a segfault at first time 1080 // syncmenu.clear causes a segfault at first time
1078 // when we call it after the main event loop, it is ok 1081 // when we call it after the main event loop, it is ok
1079 // same behaviour when calling OM/Pi via QCOP for the first time 1082 // same behaviour when calling OM/Pi via QCOP for the first time
1080 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 1083 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
1081 //confSync(); 1084 //confSync();
1082 1085
1083 return; 1086 return;
1084 } 1087 }
1085 if ( action == 1 ) { 1088 if ( action == 1 ) {
1086 multiSync( true ); 1089 multiSync( true );
1087 return; 1090 return;
1088 } 1091 }
1089 if ( action == 2 ) { 1092 if ( action == 2 ) {
1090 enableQuick(); 1093 enableQuick();
1091 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1094 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1092 return; 1095 return;
1093 } 1096 }
1094 if ( action == 3 ) { 1097 if ( action == 3 ) {
1095 delete mServerSocket; 1098 delete mServerSocket;
1096 mServerSocket = 0; 1099 mServerSocket = 0;
1097 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1100 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1098 return; 1101 return;
1099 } 1102 }
1100 1103
1101 if (mBlockSaveFlag) 1104 if (mBlockSaveFlag)
1102 return; 1105 return;
1103 mBlockSaveFlag = true; 1106 mBlockSaveFlag = true;
1104 mCurrentSyncProfile = action - 1000 ; 1107 mCurrentSyncProfile = action - 1000 ;
1105 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1108 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1106 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1109 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1107 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1110 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1108 KSyncProfile* temp = new KSyncProfile (); 1111 KSyncProfile* temp = new KSyncProfile ();
1109 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1112 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1110 temp->readConfig(&config); 1113 temp->readConfig(&config);
1111 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1114 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1112 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1115 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1113 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1116 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1114 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1117 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1115 KOPrefs::instance()->mWriteBackInFuture = 0; 1118 KOPrefs::instance()->mWriteBackInFuture = 0;
1116 if ( temp->getWriteBackFuture() ) 1119 if ( temp->getWriteBackFuture() )
1117 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1120 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1118 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1121 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1119 if ( action == 1000 ) { 1122 if ( action == 1000 ) {
1120 syncSharp(); 1123 syncSharp();
1121 1124
1122 } else if ( action == 1001 ) { 1125 } else if ( action == 1001 ) {
1123 syncLocalFile(); 1126 syncLocalFile();
1124 1127
1125 } else if ( action == 1002 ) { 1128 } else if ( action == 1002 ) {
1126 quickSyncLocalFile(); 1129 quickSyncLocalFile();
1127 1130
1128 } else if ( action >= 1003 ) { 1131 } else if ( action >= 1003 ) {
1129 if ( temp->getIsLocalFileSync() ) { 1132 if ( temp->getIsLocalFileSync() ) {
1130 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1133 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1131 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1134 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1132 } else { 1135 } else {
1133 if ( temp->getIsPhoneSync() ) { 1136 if ( temp->getIsPhoneSync() ) {
1134 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1137 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1135 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1138 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1136 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1139 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1137 syncPhone(); 1140 syncPhone();
1138 } else if ( temp->getIsPiSync() ) { 1141 } else if ( temp->getIsPiSync() ) {
1139 mPassWordPiSync = temp->getRemotePw(); 1142 mPassWordPiSync = temp->getRemotePw();
1140 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); 1143 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
1141 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); 1144 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
1142 syncPi(); 1145 syncPi();
1143 } else 1146 } else
1144 syncRemote( temp ); 1147 syncRemote( temp );
1145 1148
1146 } 1149 }
1147 } 1150 }
1148 delete temp; 1151 delete temp;
1149 mBlockSaveFlag = false; 1152 mBlockSaveFlag = false;
1150} 1153}
1151void MainWindow::exportToPhone( int mode ) 1154void MainWindow::exportToPhone( int mode )
1152{ 1155{
1153 1156
1154 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1157 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1155 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1158 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1156 KOex2phonePrefs ex2phone; 1159 KOex2phonePrefs ex2phone;
1157 ex2phone.mPhoneConnection->setText( KOPrefs::instance()->mEx2PhoneConnection ); 1160 ex2phone.mPhoneConnection->setText( KOPrefs::instance()->mEx2PhoneConnection );
1158 ex2phone.mPhoneDevice->setText( KOPrefs::instance()->mEx2PhoneDevice ); 1161 ex2phone.mPhoneDevice->setText( KOPrefs::instance()->mEx2PhoneDevice );
1159 ex2phone.mPhoneModel->setText( KOPrefs::instance()->mEx2PhoneModel ); 1162 ex2phone.mPhoneModel->setText( KOPrefs::instance()->mEx2PhoneModel );
1163 if ( mode == 1 )
1164 ex2phone.setCaption(i18n("Export complete calendar"));
1165 if ( mode == 2 )
1166 ex2phone.setCaption(i18n("Export filtered calendar"));
1160 1167
1161 if ( !ex2phone.exec() ) { 1168 if ( !ex2phone.exec() ) {
1162 return; 1169 return;
1163 } 1170 }
1164 KOPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1171 KOPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1165 KOPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1172 KOPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1166 KOPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1173 KOPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1167 1174
1168 int inFuture = 0; 1175 int inFuture = 0;
1169 if ( ex2phone.mWriteBackFuture->isChecked() ) 1176 if ( ex2phone.mWriteBackFuture->isChecked() )
1170 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1177 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1171 QPtrList<Incidence> delSel; 1178 QPtrList<Incidence> delSel;
1172 if ( mode == 1 ) 1179 if ( mode == 1 )
1173 delSel = mCalendar->rawIncidences(); 1180 delSel = mCalendar->rawIncidences();
1174 if ( mode == 2 ) 1181 if ( mode == 2 )
1175 delSel = mCalendar->incidences(); 1182 delSel = mCalendar->incidences();
1176 CalendarLocal* cal = new CalendarLocal(); 1183 CalendarLocal* cal = new CalendarLocal();
1177 cal->setLocalTime(); 1184 cal->setLocalTime();
1178 Incidence *incidence = delSel.first(); 1185 Incidence *incidence = delSel.first();
1179 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1186 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1180 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1187 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1181 while ( incidence ) { 1188 while ( incidence ) {
1182 if ( incidence->type() != "journal" ) { 1189 if ( incidence->type() != "journal" ) {
1183 bool add = true; 1190 bool add = true;
1184 if ( inFuture ) { 1191 if ( inFuture ) {
1185 QDateTime dt; 1192 QDateTime dt;
1186 if ( incidence->type() == "Todo" ) { 1193 if ( incidence->type() == "Todo" ) {
1187 Todo * t = (Todo*)incidence; 1194 Todo * t = (Todo*)incidence;
1188 if ( t->hasDueDate() ) 1195 if ( t->hasDueDate() )
1189 dt = t->dtDue(); 1196 dt = t->dtDue();
1190 else 1197 else
1191 dt = cur.addSecs( 62 ); 1198 dt = cur.addSecs( 62 );
1192 } 1199 }
1193 else { 1200 else {
1194 bool ok; 1201 bool ok;
1195 dt = incidence->getNextOccurence( cur, &ok ); 1202 dt = incidence->getNextOccurence( cur, &ok );
1196 if ( !ok ) 1203 if ( !ok )
1197 dt = cur.addSecs( -62 ); 1204 dt = cur.addSecs( -62 );
1198 } 1205 }
1199 if ( dt < cur || dt > end ) { 1206 if ( dt < cur || dt > end ) {
1200 add = false; 1207 add = false;
1201 } 1208 }
1202 } 1209 }
1203 if ( add ) { 1210 if ( add ) {
1204 Incidence *in = incidence->clone(); 1211 Incidence *in = incidence->clone();
1205 cal->addIncidence( in ); 1212 cal->addIncidence( in );
1206 } 1213 }
1207 } 1214 }
1208 incidence = delSel.next(); 1215 incidence = delSel.next();
1209 } 1216 }
1210 PhoneFormat::writeConfig( KOPrefs::instance()->mEx2PhoneDevice, 1217 PhoneFormat::writeConfig( KOPrefs::instance()->mEx2PhoneDevice,
1211 KOPrefs::instance()->mEx2PhoneConnection, 1218 KOPrefs::instance()->mEx2PhoneConnection,
1212 KOPrefs::instance()->mEx2PhoneModel ); 1219 KOPrefs::instance()->mEx2PhoneModel );
1213 1220
1214 setCaption( i18n("Writing to phone...")); 1221 setCaption( i18n("Writing to phone..."));
1215 if ( PhoneFormat::writeToPhone( cal ) ) 1222 if ( PhoneFormat::writeToPhone( cal ) )
1216 setCaption( i18n("Export to phone successful!")); 1223 setCaption( i18n("Export to phone successful!"));
1217 else 1224 else
1218 setCaption( i18n("Error exporting to phone!")); 1225 setCaption( i18n("Error exporting to phone!"));
1219 delete cal; 1226 delete cal;
1220} 1227}
1221 1228
1222 1229
1223void MainWindow::setDefaultPreferences() 1230void MainWindow::setDefaultPreferences()
1224{ 1231{
1225 KOPrefs *p = KOPrefs::instance(); 1232 KOPrefs *p = KOPrefs::instance();
1226 1233
1227 p->mCompactDialogs = true; 1234 p->mCompactDialogs = true;
1228 p->mConfirm = true; 1235 p->mConfirm = true;
1229 // p->mEnableQuickTodo = false; 1236 // p->mEnableQuickTodo = false;
1230 1237
1231} 1238}
1232 1239
1233QString MainWindow::resourcePath() 1240QString MainWindow::resourcePath()
1234{ 1241{
1235 return KGlobal::iconLoader()->iconPath(); 1242 return KGlobal::iconLoader()->iconPath();
1236} 1243}
1237 1244
1238void MainWindow::displayText( QString text ,QString cap ) 1245void MainWindow::displayText( QString text ,QString cap )
1239{ 1246{
1240 QDialog dia( this, "name", true ); ; 1247 QDialog dia( this, "name", true ); ;
1241 dia.setCaption( cap ); 1248 dia.setCaption( cap );
1242 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1249 QVBoxLayout* lay = new QVBoxLayout( &dia );
1243 lay->setSpacing( 3 ); 1250 lay->setSpacing( 3 );
1244 lay->setMargin( 3 ); 1251 lay->setMargin( 3 );
1245 QTextBrowser tb ( &dia ); 1252 QTextBrowser tb ( &dia );
1246 lay->addWidget( &tb ); 1253 lay->addWidget( &tb );
1247 tb.setText( text ); 1254 tb.setText( text );
1248#ifdef DESKTOP_VERSION 1255#ifdef DESKTOP_VERSION
1249 dia.resize( 640, 480); 1256 dia.resize( 640, 480);
1250#else 1257#else
1251 dia.showMaximized(); 1258 dia.showMaximized();
1252#endif 1259#endif
1253 dia.exec(); 1260 dia.exec();
1254} 1261}
1255void MainWindow::displayFile( QString fn, QString cap ) 1262void MainWindow::displayFile( QString fn, QString cap )
1256{ 1263{
1257 QString fileName = resourcePath() + fn; 1264 QString fileName = resourcePath() + fn;
1258 QString text; 1265 QString text;
1259 QFile file( fileName ); 1266 QFile file( fileName );
1260 if (!file.open( IO_ReadOnly ) ) { 1267 if (!file.open( IO_ReadOnly ) ) {
1261 return ; 1268 return ;
1262 1269
1263 } 1270 }
1264 QTextStream ts( &file ); 1271 QTextStream ts( &file );
1265 text = ts.read(); 1272 text = ts.read();
1266 file.close(); 1273 file.close();
1267 displayText( text, cap); 1274 displayText( text, cap);
1268} 1275}
1269void MainWindow::features() 1276void MainWindow::features()
1270{ 1277{
1271 1278
1272 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1279 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1273} 1280}
1274 1281
1275void MainWindow::usertrans() 1282void MainWindow::usertrans()
1276{ 1283{
1277 1284
1278 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1285 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1279} 1286}
1280 1287
1281void MainWindow::synchowto() 1288void MainWindow::synchowto()
1282{ 1289{
1283#if 0 1290#if 0
1284 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1291 QPtrList<Incidence> er = mCalendar->rawIncidences();
1285 Incidence* inR = er.first(); 1292 Incidence* inR = er.first();
1286 VCalFormat vf; 1293 VCalFormat vf;
1287 QString strout; 1294 QString strout;
1288 while ( inR ) { 1295 while ( inR ) {
1289 if ( inR->type() == "Todo" ) 1296 if ( inR->type() == "Todo" )
1290 strout = vf.todoToString( (Todo *) inR ); 1297 strout = vf.todoToString( (Todo *) inR );
1291 if ( inR->type() == "Event" ) 1298 if ( inR->type() == "Event" )
1292 strout = vf.eventToString( (Event *) inR ); 1299 strout = vf.eventToString( (Event *) inR );
1293 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1300 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1294 inR = er.next(); 1301 inR = er.next();
1295 } 1302 }
1296#endif 1303#endif
1297 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1304 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1298} 1305}
1299void MainWindow::faq() 1306void MainWindow::faq()
1300{ 1307{
1301 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1308 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1302 1309
1303} 1310}
1304void MainWindow::whatsNew() 1311void MainWindow::whatsNew()
1305{ 1312{
1306 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1313 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1307 1314
1308} 1315}
1309void MainWindow::licence() 1316void MainWindow::licence()
1310{ 1317{
1311 KApplication::showLicence(); 1318 KApplication::showLicence();
1312 1319
1313} 1320}
1314void MainWindow::about() 1321void MainWindow::about()
1315{ 1322{
1316 QString version; 1323 QString version;
1317#include <../version> 1324#include <../version>
1318 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1325 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1319 i18n("KOrganizer/Platform-independent\n") + 1326 i18n("KOrganizer/Platform-independent\n") +
1320 "(KO/Pi) " + version + " - " + 1327 "(KO/Pi) " + version + " - " +
1321 1328
1322#ifdef DESKTOP_VERSION 1329#ifdef DESKTOP_VERSION
1323 i18n("Desktop Edition\n") + 1330 i18n("Desktop Edition\n") +
1324#else 1331#else
1325 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1332 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1326#endif 1333#endif
1327 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1334 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1328} 1335}
1329void MainWindow::keyBindings() 1336void MainWindow::keyBindings()
1330{ 1337{
1331 QString cap = i18n("Key bindings KOrganizer/Pi"); 1338 QString cap = i18n("Key bindings KOrganizer/Pi");
1332 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1339 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1333 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1340 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1334 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1341 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1335 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1342 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1336 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1343 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1337 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1344 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1338 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1345 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1339 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1346 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1340 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1347 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1341 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1348 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1342 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1349 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1343 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1350 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1344 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1351 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1345 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1352 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1346 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1353 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1347 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1354 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1348 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1355 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1349 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1356 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1350 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1357 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1351 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1358 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+