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,2183 +1,2190 @@
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 ) ) {
304 case 0: 307 case 0:
305 saveOnClose(); 308 saveOnClose();
306 mClosed = true; 309 mClosed = true;
307 ce->accept(); 310 ce->accept();
308 break; 311 break;
309 case 1: 312 case 1:
310 ce->ignore(); 313 ce->ignore();
311 break; 314 break;
312 case 2: 315 case 2:
313 316
314 default: 317 default:
315 break; 318 break;
316 } 319 }
317 320
318 321
319} 322}
320 323
321void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 324void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
322{ 325{
323 QDataStream stream( data, IO_ReadOnly ); 326 QDataStream stream( data, IO_ReadOnly );
324 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 327 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
325 //QString datamess; 328 //QString datamess;
326 //qDebug("message "); 329 //qDebug("message ");
327 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 330 qDebug("KO: QCOP message received: %s ", cmsg.data() );
328 331
329 if ( cmsg == "-writeFile" ) { 332 if ( cmsg == "-writeFile" ) {
330 // I made from the "-writeFile" an "-writeAlarm" 333 // I made from the "-writeFile" an "-writeAlarm"
331 mView->viewManager()->showWhatsNextView(); 334 mView->viewManager()->showWhatsNextView();
332 mCalendar->checkAlarmForIncidence( 0, true); 335 mCalendar->checkAlarmForIncidence( 0, true);
333 showMaximized(); 336 showMaximized();
334 raise(); 337 raise();
335 return; 338 return;
336 } 339 }
337 340
338 if ( cmsg == "-writeFile" ) { 341 if ( cmsg == "-writeFile" ) {
339 // I made from the "-writeFile" an "-writeAlarm" 342 // I made from the "-writeFile" an "-writeAlarm"
340 mView->viewManager()->showWhatsNextView(); 343 mView->viewManager()->showWhatsNextView();
341 mCalendar->checkAlarmForIncidence( 0, true); 344 mCalendar->checkAlarmForIncidence( 0, true);
342 showMaximized(); 345 showMaximized();
343 raise(); 346 raise();
344 return; 347 return;
345 348
346 } 349 }
347 if ( cmsg == "-writeFileSilent" ) { 350 if ( cmsg == "-writeFileSilent" ) {
348 // I made from the "-writeFile" an "-writeAlarm" 351 // I made from the "-writeFile" an "-writeAlarm"
349 // mView->viewManager()->showWhatsNextView(); 352 // mView->viewManager()->showWhatsNextView();
350 mCalendar->checkAlarmForIncidence( 0, true); 353 mCalendar->checkAlarmForIncidence( 0, true);
351 //showMaximized(); 354 //showMaximized();
352 //raise(); 355 //raise();
353 hide(); 356 hide();
354 return; 357 return;
355 } 358 }
356 if ( cmsg == "-newCountdown" ) { 359 if ( cmsg == "-newCountdown" ) {
357 qDebug("newCountdown "); 360 qDebug("newCountdown ");
358 361
359 } 362 }
360 QString msg ; 363 QString msg ;
361 QString allmsg = cmsg; 364 QString allmsg = cmsg;
362 while ( allmsg.length() > 0 ) { 365 while ( allmsg.length() > 0 ) {
363 int nextC = allmsg.find( "-", 1 ); 366 int nextC = allmsg.find( "-", 1 );
364 if ( nextC == -1 ) { 367 if ( nextC == -1 ) {
365 msg = allmsg; 368 msg = allmsg;
366 allmsg = ""; 369 allmsg = "";
367 } else{ 370 } else{
368 msg = allmsg.left( nextC ); 371 msg = allmsg.left( nextC );
369 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 372 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
370 } 373 }
371 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 374 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
372 if ( msg == "-newEvent" ) { 375 if ( msg == "-newEvent" ) {
373 mView->newEvent(); 376 mView->newEvent();
374 } 377 }
375 if ( msg == "-newTodo" ) { 378 if ( msg == "-newTodo" ) {
376 mView->newTodo(); 379 mView->newTodo();
377 380
378 } 381 }
379 if ( msg == "-showWN" ) { 382 if ( msg == "-showWN" ) {
380 mView->viewManager()->showWhatsNextView(); 383 mView->viewManager()->showWhatsNextView();
381 } 384 }
382 if ( msg == "-showTodo" ) { 385 if ( msg == "-showTodo" ) {
383 mView->viewManager()->showTodoView(); 386 mView->viewManager()->showTodoView();
384 } 387 }
385 if ( msg == "-showList" ) { 388 if ( msg == "-showList" ) {
386 mView->viewManager()->showListView(); 389 mView->viewManager()->showListView();
387 } 390 }
388 else if ( msg == "-showDay" ) { 391 else if ( msg == "-showDay" ) {
389 mView->viewManager()->showDayView(); 392 mView->viewManager()->showDayView();
390 } 393 }
391 else if ( msg == "-showWWeek" ) { 394 else if ( msg == "-showWWeek" ) {
392 mView->viewManager()->showWorkWeekView(); 395 mView->viewManager()->showWorkWeekView();
393 } 396 }
394 else if ( msg == "-ringSync" ) { 397 else if ( msg == "-ringSync" ) {
395 multiSync( false ); 398 multiSync( false );
396 } 399 }
397 else if ( msg == "-showWeek" ) { 400 else if ( msg == "-showWeek" ) {
398 mView->viewManager()->showWeekView(); 401 mView->viewManager()->showWeekView();
399 } 402 }
400 else if ( msg == "-showTodo" ) { 403 else if ( msg == "-showTodo" ) {
401 mView->viewManager()->showTodoView(); 404 mView->viewManager()->showTodoView();
402 } 405 }
403 else if ( msg == "-showJournal" ) { 406 else if ( msg == "-showJournal" ) {
404 mView->dateNavigator()->selectDates( 1 ); 407 mView->dateNavigator()->selectDates( 1 );
405 mView->dateNavigator()->selectToday(); 408 mView->dateNavigator()->selectToday();
406 mView->viewManager()->showJournalView(); 409 mView->viewManager()->showJournalView();
407 } 410 }
408 else if ( msg == "-showKO" ) { 411 else if ( msg == "-showKO" ) {
409 mView->viewManager()->showNextXView(); 412 mView->viewManager()->showNextXView();
410 } 413 }
411 else if ( msg == "-showWNext" || msg == "nextView()" ) { 414 else if ( msg == "-showWNext" || msg == "nextView()" ) {
412 mView->viewManager()->showWhatsNextView(); 415 mView->viewManager()->showWhatsNextView();
413 } 416 }
414 else if ( msg == "-showNextXView" ) { 417 else if ( msg == "-showNextXView" ) {
415 mView->viewManager()->showNextXView(); 418 mView->viewManager()->showNextXView();
416 } 419 }
417 420
418 421
419 } 422 }
420 423
421 showMaximized(); 424 showMaximized();
422 raise(); 425 raise();
423} 426}
424 427
425QPixmap MainWindow::loadPixmap( QString name ) 428QPixmap MainWindow::loadPixmap( QString name )
426{ 429{
427 return SmallIcon( name ); 430 return SmallIcon( name );
428 431
429} 432}
430void MainWindow::initActions() 433void MainWindow::initActions()
431{ 434{
432 //KOPrefs::instance()->mShowFullMenu 435 //KOPrefs::instance()->mShowFullMenu
433 iconToolBar->clear(); 436 iconToolBar->clear();
434 KOPrefs *p = KOPrefs::instance(); 437 KOPrefs *p = KOPrefs::instance();
435 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 438 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
436 439
437 QPopupMenu *viewMenu = new QPopupMenu( this ); 440 QPopupMenu *viewMenu = new QPopupMenu( this );
438 QPopupMenu *actionMenu = new QPopupMenu( this ); 441 QPopupMenu *actionMenu = new QPopupMenu( this );
439 QPopupMenu *importMenu = new QPopupMenu( this ); 442 QPopupMenu *importMenu = new QPopupMenu( this );
440 selectFilterMenu = new QPopupMenu( this ); 443 selectFilterMenu = new QPopupMenu( this );
441 selectFilterMenu->setCheckable( true ); 444 selectFilterMenu->setCheckable( true );
442 syncMenu = new QPopupMenu( this ); 445 syncMenu = new QPopupMenu( this );
443 configureAgendaMenu = new QPopupMenu( this ); 446 configureAgendaMenu = new QPopupMenu( this );
444 configureToolBarMenu = new QPopupMenu( this ); 447 configureToolBarMenu = new QPopupMenu( this );
445 QPopupMenu *helpMenu = new QPopupMenu( this ); 448 QPopupMenu *helpMenu = new QPopupMenu( this );
446 if ( KOPrefs::instance()->mShowFullMenu ) { 449 if ( KOPrefs::instance()->mShowFullMenu ) {
447 QMenuBar *menuBar1; 450 QMenuBar *menuBar1;
448 menuBar1 = menuBar(); 451 menuBar1 = menuBar();
449 menuBar1->insertItem( i18n("File"), importMenu ); 452 menuBar1->insertItem( i18n("File"), importMenu );
450 menuBar1->insertItem( i18n("View"), viewMenu ); 453 menuBar1->insertItem( i18n("View"), viewMenu );
451 menuBar1->insertItem( i18n("Actions"), actionMenu ); 454 menuBar1->insertItem( i18n("Actions"), actionMenu );
452 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 455 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
453 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 456 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
454 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 457 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
455 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 458 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
456 menuBar1->insertItem( i18n("Help"), helpMenu ); 459 menuBar1->insertItem( i18n("Help"), helpMenu );
457 } else { 460 } else {
458 QPEMenuBar *menuBar1; 461 QPEMenuBar *menuBar1;
459 menuBar1 = new QPEMenuBar( iconToolBar ); 462 menuBar1 = new QPEMenuBar( iconToolBar );
460 QPopupMenu *menuBar = new QPopupMenu( this ); 463 QPopupMenu *menuBar = new QPopupMenu( this );
461 menuBar1->insertItem( i18n("ME"), menuBar); 464 menuBar1->insertItem( i18n("ME"), menuBar);
462 menuBar->insertItem( i18n("File"), importMenu ); 465 menuBar->insertItem( i18n("File"), importMenu );
463 menuBar->insertItem( i18n("View"), viewMenu ); 466 menuBar->insertItem( i18n("View"), viewMenu );
464 menuBar->insertItem( i18n("Actions"), actionMenu ); 467 menuBar->insertItem( i18n("Actions"), actionMenu );
465 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 468 menuBar->insertItem( i18n("Synchronize"), syncMenu );
466 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 469 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
467 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 470 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
468 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 471 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
469 menuBar->insertItem( i18n("Help"), helpMenu ); 472 menuBar->insertItem( i18n("Help"), helpMenu );
470 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 473 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
471 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 474 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
472 } 475 }
473 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 476 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
474 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 477 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
475 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 478 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
476 479
477 // ****************** 480 // ******************
478 QAction *action; 481 QAction *action;
479 QIconSet icon; 482 QIconSet icon;
480 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 483 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
481 configureToolBarMenu->setCheckable( true ); 484 configureToolBarMenu->setCheckable( true );
482 485
483 QString pathString = ""; 486 QString pathString = "";
484 if ( !p->mToolBarMiniIcons ) { 487 if ( !p->mToolBarMiniIcons ) {
485 if ( QApplication::desktop()->width() < 480 ) 488 if ( QApplication::desktop()->width() < 480 )
486 pathString += "icons16/"; 489 pathString += "icons16/";
487 } else 490 } else
488 pathString += "iconsmini/"; 491 pathString += "iconsmini/";
489 configureAgendaMenu->setCheckable( true ); 492 configureAgendaMenu->setCheckable( true );
490 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 493 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
491 configureAgendaMenu->insertSeparator(); 494 configureAgendaMenu->insertSeparator();
492 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 495 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
493 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 496 configureAgendaMenu->insertItem(i18n("Small"), 6 );
494 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 497 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
495 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 498 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
496 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 499 configureAgendaMenu->insertItem(i18n("Large"), 12 );
497 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 500 configureAgendaMenu->insertItem(i18n("Big"), 14 );
498 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 501 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
499 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 502 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
500 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 503 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
501 504
502 icon = loadPixmap( pathString + "configure" ); 505 icon = loadPixmap( pathString + "configure" );
503 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 506 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
504 action->addTo( actionMenu ); 507 action->addTo( actionMenu );
505 connect( action, SIGNAL( activated() ), 508 connect( action, SIGNAL( activated() ),
506 mView, SLOT( edit_options() ) ); 509 mView, SLOT( edit_options() ) );
507 actionMenu->insertSeparator(); 510 actionMenu->insertSeparator();
508 icon = loadPixmap( pathString + "newevent" ); 511 icon = loadPixmap( pathString + "newevent" );
509 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 512 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
510 configureToolBarMenu->insertSeparator(); 513 configureToolBarMenu->insertSeparator();
511 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 514 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
512 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 515 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
513 ne_action->addTo( actionMenu ); 516 ne_action->addTo( actionMenu );
514 connect( ne_action, SIGNAL( activated() ), 517 connect( ne_action, SIGNAL( activated() ),
515 mView, SLOT( newEvent() ) ); 518 mView, SLOT( newEvent() ) );
516 icon = loadPixmap( pathString + "newtodo" ); 519 icon = loadPixmap( pathString + "newtodo" );
517 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 520 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
518 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 521 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
519 nt_action->addTo( actionMenu ); 522 nt_action->addTo( actionMenu );
520 connect( nt_action, SIGNAL( activated() ), 523 connect( nt_action, SIGNAL( activated() ),
521 mView, SLOT( newTodo() ) ); 524 mView, SLOT( newTodo() ) );
522 icon = loadPixmap( pathString + "navi" ); 525 icon = loadPixmap( pathString + "navi" );
523 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 526 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
524 action->addTo( viewMenu ); 527 action->addTo( viewMenu );
525 connect( action, SIGNAL( activated() ), 528 connect( action, SIGNAL( activated() ),
526 mView, SLOT( toggleDateNavigatorWidget() ) ); 529 mView, SLOT( toggleDateNavigatorWidget() ) );
527 icon = loadPixmap( pathString + "filter" ); 530 icon = loadPixmap( pathString + "filter" );
528 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 531 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
529 action->addTo( viewMenu ); 532 action->addTo( viewMenu );
530 connect( action, SIGNAL( activated() ), 533 connect( action, SIGNAL( activated() ),
531 mView, SLOT( toggleFilter() ) ); 534 mView, SLOT( toggleFilter() ) );
532 535
533 536
534 viewMenu->insertSeparator(); 537 viewMenu->insertSeparator();
535 icon = loadPixmap( pathString + "picker" ); 538 icon = loadPixmap( pathString + "picker" );
536 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 539 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
537 action->addTo( viewMenu ); 540 action->addTo( viewMenu );
538 connect( action, SIGNAL( activated() ), 541 connect( action, SIGNAL( activated() ),
539 mView, SLOT( showDatePicker() ) ); 542 mView, SLOT( showDatePicker() ) );
540 action->addTo( iconToolBar ); 543 action->addTo( iconToolBar );
541 viewMenu->insertSeparator(); 544 viewMenu->insertSeparator();
542 icon = loadPixmap( pathString + "list" ); 545 icon = loadPixmap( pathString + "list" );
543 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 546 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
544 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 547 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
545 showlist_action->addTo( viewMenu ); 548 showlist_action->addTo( viewMenu );
546 connect( showlist_action, SIGNAL( activated() ), 549 connect( showlist_action, SIGNAL( activated() ),
547 mView->viewManager(), SLOT( showListView() ) ); 550 mView->viewManager(), SLOT( showListView() ) );
548 551
549 552
550 icon = loadPixmap( pathString + "day" ); 553 icon = loadPixmap( pathString + "day" );
551 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 554 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
552 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 555 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
553 day1_action->addTo( viewMenu ); 556 day1_action->addTo( viewMenu );
554 // action->addTo( toolBar ); 557 // action->addTo( toolBar );
555 connect( day1_action, SIGNAL( activated() ), 558 connect( day1_action, SIGNAL( activated() ),
556 mView->viewManager(), SLOT( showDayView() ) ); 559 mView->viewManager(), SLOT( showDayView() ) );
557 560
558 icon = loadPixmap( pathString + "workweek" ); 561 icon = loadPixmap( pathString + "workweek" );
559 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 562 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
560 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 563 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
561 day5_action->addTo( viewMenu ); 564 day5_action->addTo( viewMenu );
562 connect( day5_action, SIGNAL( activated() ), 565 connect( day5_action, SIGNAL( activated() ),
563 mView->viewManager(), SLOT( showWorkWeekView() ) ); 566 mView->viewManager(), SLOT( showWorkWeekView() ) );
564 567
565 icon = loadPixmap( pathString + "week" ); 568 icon = loadPixmap( pathString + "week" );
566 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 569 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
567 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 570 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
568 day7_action->addTo( viewMenu ); 571 day7_action->addTo( viewMenu );
569 connect( day7_action, SIGNAL( activated() ), 572 connect( day7_action, SIGNAL( activated() ),
570 mView->viewManager(), SLOT( showWeekView() ) ); 573 mView->viewManager(), SLOT( showWeekView() ) );
571 574
572 icon = loadPixmap( pathString + "month" ); 575 icon = loadPixmap( pathString + "month" );
573 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 576 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
574 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 577 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
575 month_action->addTo( viewMenu ); 578 month_action->addTo( viewMenu );
576 connect( month_action, SIGNAL( activated() ), 579 connect( month_action, SIGNAL( activated() ),
577 mView->viewManager(), SLOT( showMonthView() ) ); 580 mView->viewManager(), SLOT( showMonthView() ) );
578 581
579 icon = loadPixmap( pathString + "todo" ); 582 icon = loadPixmap( pathString + "todo" );
580 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 583 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
581 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 584 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
582 todoview_action->addTo( viewMenu ); 585 todoview_action->addTo( viewMenu );
583 connect( todoview_action, SIGNAL( activated() ), 586 connect( todoview_action, SIGNAL( activated() ),
584 mView->viewManager(), SLOT( showTodoView() ) ); 587 mView->viewManager(), SLOT( showTodoView() ) );
585 588
586 icon = loadPixmap( pathString + "journal" ); 589 icon = loadPixmap( pathString + "journal" );
587 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 590 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
588 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 591 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
589 viewjournal_action->addTo( viewMenu ); 592 viewjournal_action->addTo( viewMenu );
590 connect( viewjournal_action, SIGNAL( activated() ), 593 connect( viewjournal_action, SIGNAL( activated() ),
591 mView->viewManager(), SLOT( showJournalView() ) ); 594 mView->viewManager(), SLOT( showJournalView() ) );
592 595
593 icon = loadPixmap( pathString + "xdays" ); 596 icon = loadPixmap( pathString + "xdays" );
594 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 597 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
595 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 598 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
596 xdays_action->addTo( viewMenu ); 599 xdays_action->addTo( viewMenu );
597 connect( xdays_action, SIGNAL( activated() ), 600 connect( xdays_action, SIGNAL( activated() ),
598 mView->viewManager(), SLOT( showNextXView() ) ); 601 mView->viewManager(), SLOT( showNextXView() ) );
599 602
600 icon = loadPixmap( pathString + "whatsnext" ); 603 icon = loadPixmap( pathString + "whatsnext" );
601 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 604 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
602 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 605 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
603 whatsnext_action->addTo( viewMenu ); 606 whatsnext_action->addTo( viewMenu );
604 connect( whatsnext_action, SIGNAL( activated() ), 607 connect( whatsnext_action, SIGNAL( activated() ),
605 mView->viewManager(), SLOT( showWhatsNextView() ) ); 608 mView->viewManager(), SLOT( showWhatsNextView() ) );
606 609
607#if 0 610#if 0
608 action = new QAction( "view_timespan", "Time Span", 0, this ); 611 action = new QAction( "view_timespan", "Time Span", 0, this );
609 action->addTo( viewMenu ); 612 action->addTo( viewMenu );
610 connect( action, SIGNAL( activated() ), 613 connect( action, SIGNAL( activated() ),
611 mView->viewManager(), SLOT( showTimeSpanView() ) ); 614 mView->viewManager(), SLOT( showTimeSpanView() ) );
612#endif 615#endif
613 616
614 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 617 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
615 this ); 618 this );
616 mNewSubTodoAction->addTo( actionMenu ); 619 mNewSubTodoAction->addTo( actionMenu );
617 connect( mNewSubTodoAction, SIGNAL( activated() ), 620 connect( mNewSubTodoAction, SIGNAL( activated() ),
618 mView, SLOT( newSubTodo() ) ); 621 mView, SLOT( newSubTodo() ) );
619 622
620 actionMenu->insertSeparator(); 623 actionMenu->insertSeparator();
621 624
622 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 625 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
623 mShowAction->addTo( actionMenu ); 626 mShowAction->addTo( actionMenu );
624 connect( mShowAction, SIGNAL( activated() ), 627 connect( mShowAction, SIGNAL( activated() ),
625 mView, SLOT( showIncidence() ) ); 628 mView, SLOT( showIncidence() ) );
626 629
627 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 630 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
628 mEditAction->addTo( actionMenu ); 631 mEditAction->addTo( actionMenu );
629 connect( mEditAction, SIGNAL( activated() ), 632 connect( mEditAction, SIGNAL( activated() ),
630 mView, SLOT( editIncidence() ) ); 633 mView, SLOT( editIncidence() ) );
631 634
632 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 635 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
633 mDeleteAction->addTo( actionMenu ); 636 mDeleteAction->addTo( actionMenu );
634 connect( mDeleteAction, SIGNAL( activated() ), 637 connect( mDeleteAction, SIGNAL( activated() ),
635 mView, SLOT( deleteIncidence() ) ); 638 mView, SLOT( deleteIncidence() ) );
636 639
637 actionMenu->insertSeparator(); 640 actionMenu->insertSeparator();
638 641
639 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 642 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
640 this ); 643 this );
641 action->addTo( actionMenu ); 644 action->addTo( actionMenu );
642 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 645 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
643 646
644 icon = loadPixmap( pathString + "search" ); 647 icon = loadPixmap( pathString + "search" );
645 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 648 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
646 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 649 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
647 search_action->addTo( actionMenu ); 650 search_action->addTo( actionMenu );
648 connect( search_action, SIGNAL( activated() ), 651 connect( search_action, SIGNAL( activated() ),
649 mView->dialogManager(), SLOT( showSearchDialog() ) ); 652 mView->dialogManager(), SLOT( showSearchDialog() ) );
650 653
651 icon = loadPixmap( pathString + "today" ); 654 icon = loadPixmap( pathString + "today" );
652 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 655 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
653 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 656 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
654 today_action->addTo( actionMenu ); 657 today_action->addTo( actionMenu );
655 connect( today_action, SIGNAL( activated() ), 658 connect( today_action, SIGNAL( activated() ),
656 mView, SLOT( goToday() ) ); 659 mView, SLOT( goToday() ) );
657 660
658 if ( KOPrefs::instance()->mShowFullMenu ) { 661 if ( KOPrefs::instance()->mShowFullMenu ) {
659 actionMenu->insertSeparator(); 662 actionMenu->insertSeparator();
660 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 663 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
661 664
662 } 665 }
663 // actionMenu->insertSeparator(); 666 // actionMenu->insertSeparator();
664 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 667 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
665 this ); 668 this );
666 action->addTo( importMenu ); 669 action->addTo( importMenu );
667 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 670 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
668 action = new QAction( "import_quick", i18n("Import last file"), 0, 671 action = new QAction( "import_quick", i18n("Import last file"), 0,
669 this ); 672 this );
670 action->addTo( importMenu ); 673 action->addTo( importMenu );
671 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 674 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
672 importMenu->insertSeparator(); 675 importMenu->insertSeparator();
673 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 676 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
674 this ); 677 this );
675 action->addTo( importMenu ); 678 action->addTo( importMenu );
676 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 679 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
677#ifndef DESKTOP_VERSION 680#ifndef DESKTOP_VERSION
678 importMenu->insertSeparator(); 681 importMenu->insertSeparator();
679 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 682 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
680 this ); 683 this );
681 action->addTo( importMenu ); 684 action->addTo( importMenu );
682 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 685 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
683#else 686#else
684#ifdef _WIN32_ 687#ifdef _WIN32_
685 importMenu->insertSeparator(); 688 importMenu->insertSeparator();
686 action = new QAction( "import_ol", i18n("Import from OL"), 0, 689 action = new QAction( "import_ol", i18n("Import from OL"), 0,
687 this ); 690 this );
688 action->addTo( importMenu ); 691 action->addTo( importMenu );
689 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 692 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
690#endif 693#endif
691#endif 694#endif
692 695
693 importMenu->insertSeparator(); 696 importMenu->insertSeparator();
694 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 697 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
695 this ); 698 this );
696 action->addTo( importMenu ); 699 action->addTo( importMenu );
697 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 700 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
698 701
699 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 702 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
700 this ); 703 this );
701 action->addTo( importMenu ); 704 action->addTo( importMenu );
702 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 705 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
703 706
704 importMenu->insertSeparator(); 707 importMenu->insertSeparator();
705 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 708 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
706 this ); 709 this );
707 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 710 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
708 711
709 712
710 //LR 713 //LR
711 QPopupMenu *ex2phone = new QPopupMenu( this ); 714 QPopupMenu *ex2phone = new QPopupMenu( this );
712 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 715 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
713 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 716 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
714 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 717 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
715 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 718 importMenu->insertItem( i18n("Export to phone"), ex2phone );
716 719
717 importMenu->insertSeparator(); 720 importMenu->insertSeparator();
718 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 721 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
719 this ); 722 this );
720 action->addTo( importMenu ); 723 action->addTo( importMenu );
721 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 724 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
722#ifndef DESKTOP_VERSION 725#ifndef DESKTOP_VERSION
723 importMenu->insertSeparator(); 726 importMenu->insertSeparator();
724 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 727 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
725 this ); 728 this );
726 action->addTo( importMenu ); 729 action->addTo( importMenu );
727 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 730 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
728 731
729 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 732 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
730 this ); 733 this );
731 action->addTo( importMenu ); 734 action->addTo( importMenu );
732 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 735 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
733#else 736#else
734 importMenu->insertSeparator(); 737 importMenu->insertSeparator();
735 icon = loadPixmap( pathString + "print" ); 738 icon = loadPixmap( pathString + "print" );
736 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 739 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
737 action->addTo( importMenu ); 740 action->addTo( importMenu );
738 connect( action, SIGNAL( activated() ), 741 connect( action, SIGNAL( activated() ),
739 this, SLOT( printCal() ) ); 742 this, SLOT( printCal() ) );
740 743
741 icon = loadPixmap( pathString + "print" ); 744 icon = loadPixmap( pathString + "print" );
742 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 745 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
743 action->addTo( importMenu ); 746 action->addTo( importMenu );
744 connect( action, SIGNAL( activated() ), 747 connect( action, SIGNAL( activated() ),
745 this, SLOT( printSel() ) ); 748 this, SLOT( printSel() ) );
746#endif 749#endif
747 importMenu->insertSeparator(); 750 importMenu->insertSeparator();
748 action = new QAction( "beam all", i18n("Save"), 0, 751 action = new QAction( "beam all", i18n("Save"), 0,
749 this ); 752 this );
750 action->addTo( importMenu ); 753 action->addTo( importMenu );
751 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 754 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
752 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 755 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
753 this ); 756 this );
754 action->addTo( importMenu ); 757 action->addTo( importMenu );
755 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 758 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
756 759
757 //menuBar->insertItem( "Configure",configureMenu ); 760 //menuBar->insertItem( "Configure",configureMenu );
758 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 761 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
759 icon = loadPixmap( "korganizer/korganizer" ); 762 icon = loadPixmap( "korganizer/korganizer" );
760 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 763 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
761 action->addTo( helpMenu ); 764 action->addTo( helpMenu );
762 connect( action, SIGNAL( activated() ), 765 connect( action, SIGNAL( activated() ),
763 SLOT( keyBindings() ) ); 766 SLOT( keyBindings() ) );
764 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 767 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
765 action->addTo( helpMenu ); 768 action->addTo( helpMenu );
766 connect( action, SIGNAL( activated() ), 769 connect( action, SIGNAL( activated() ),
767 SLOT( features() ) ); 770 SLOT( features() ) );
768 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 771 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
769 action->addTo( helpMenu ); 772 action->addTo( helpMenu );
770 connect( action, SIGNAL( activated() ), 773 connect( action, SIGNAL( activated() ),
771 SLOT( aboutAutoSaving() ) ); 774 SLOT( aboutAutoSaving() ) );
772 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 775 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
773 action->addTo( helpMenu ); 776 action->addTo( helpMenu );
774 connect( action, SIGNAL( activated() ), 777 connect( action, SIGNAL( activated() ),
775 SLOT( aboutKnownBugs() ) ); 778 SLOT( aboutKnownBugs() ) );
776 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 779 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
777 action->addTo( helpMenu ); 780 action->addTo( helpMenu );
778 connect( action, SIGNAL( activated() ), 781 connect( action, SIGNAL( activated() ),
779 SLOT( usertrans() ) ); 782 SLOT( usertrans() ) );
780 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 783 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
781 action->addTo( helpMenu ); 784 action->addTo( helpMenu );
782 connect( action, SIGNAL( activated() ), 785 connect( action, SIGNAL( activated() ),
783 SLOT( synchowto() ) ); 786 SLOT( synchowto() ) );
784 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 787 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
785 action->addTo( helpMenu ); 788 action->addTo( helpMenu );
786 connect( action, SIGNAL( activated() ), 789 connect( action, SIGNAL( activated() ),
787 SLOT( whatsNew() ) ); 790 SLOT( whatsNew() ) );
788 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 791 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
789 action->addTo( helpMenu ); 792 action->addTo( helpMenu );
790 connect( action, SIGNAL( activated() ), 793 connect( action, SIGNAL( activated() ),
791 SLOT( faq() ) ); 794 SLOT( faq() ) );
792 795
793 796
794 action = new QAction( "about", i18n("About..."), 0, this ); 797 action = new QAction( "about", i18n("About..."), 0, this );
795 action->addTo( helpMenu ); 798 action->addTo( helpMenu );
796 connect( action, SIGNAL( activated() ), 799 connect( action, SIGNAL( activated() ),
797 SLOT( about() ) ); 800 SLOT( about() ) );
798 action = new QAction( "licence", i18n("Licence..."), 0, this ); 801 action = new QAction( "licence", i18n("Licence..."), 0, this );
799 action->addTo( helpMenu ); 802 action->addTo( helpMenu );
800 connect( action, SIGNAL( activated() ), 803 connect( action, SIGNAL( activated() ),
801 SLOT( licence() ) ); 804 SLOT( licence() ) );
802 //menuBar->insertSeparator(); 805 //menuBar->insertSeparator();
803 806
804 // ****************************************************** 807 // ******************************************************
805 // menubar icons 808 // menubar icons
806 809
807 810
808 iconToolBar->setHorizontalStretchable (true ); 811 iconToolBar->setHorizontalStretchable (true );
809 //menuBar->insertItem( iconToolBar ); 812 //menuBar->insertItem( iconToolBar );
810 //xdays_action 813 //xdays_action
811 if (p-> mShowIconNewEvent) 814 if (p-> mShowIconNewEvent)
812 ne_action->addTo( iconToolBar ); 815 ne_action->addTo( iconToolBar );
813 if (p->mShowIconNewTodo ) 816 if (p->mShowIconNewTodo )
814 nt_action->addTo( iconToolBar ); 817 nt_action->addTo( iconToolBar );
815 if (p-> mShowIconSearch) 818 if (p-> mShowIconSearch)
816 search_action->addTo( iconToolBar ); 819 search_action->addTo( iconToolBar );
817 if (p-> mShowIconNext) 820 if (p-> mShowIconNext)
818 whatsnext_action->addTo( iconToolBar ); 821 whatsnext_action->addTo( iconToolBar );
819 if (p-> mShowIconNextDays) 822 if (p-> mShowIconNextDays)
820 xdays_action->addTo( iconToolBar ); 823 xdays_action->addTo( iconToolBar );
821 if (p-> mShowIconList) 824 if (p-> mShowIconList)
822 showlist_action->addTo( iconToolBar ); 825 showlist_action->addTo( iconToolBar );
823 if (p-> mShowIconDay1) 826 if (p-> mShowIconDay1)
824 day1_action->addTo( iconToolBar ); 827 day1_action->addTo( iconToolBar );
825 if (p-> mShowIconDay5) 828 if (p-> mShowIconDay5)
826 day5_action->addTo( iconToolBar ); 829 day5_action->addTo( iconToolBar );
827 if (p-> mShowIconDay7) 830 if (p-> mShowIconDay7)
828 day7_action->addTo( iconToolBar ); 831 day7_action->addTo( iconToolBar );
829 if (p-> mShowIconMonth) 832 if (p-> mShowIconMonth)
830 month_action->addTo( iconToolBar ); 833 month_action->addTo( iconToolBar );
831 if (p-> mShowIconTodoview) 834 if (p-> mShowIconTodoview)
832 todoview_action->addTo( iconToolBar ); 835 todoview_action->addTo( iconToolBar );
833 if (p-> mShowIconJournal) 836 if (p-> mShowIconJournal)
834 viewjournal_action->addTo( iconToolBar ); 837 viewjournal_action->addTo( iconToolBar );
835 icon = loadPixmap( pathString + "2leftarrowB" ); 838 icon = loadPixmap( pathString + "2leftarrowB" );
836 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 839 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
837 if (p-> mShowIconBackFast) { 840 if (p-> mShowIconBackFast) {
838 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 841 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
839 connect( action, SIGNAL( activated() ), 842 connect( action, SIGNAL( activated() ),
840 mView, SLOT( goPreviousMonth() ) ); 843 mView, SLOT( goPreviousMonth() ) );
841 action->addTo( iconToolBar ); 844 action->addTo( iconToolBar );
842 } 845 }
843 icon = loadPixmap( pathString + "1leftarrowB" ); 846 icon = loadPixmap( pathString + "1leftarrowB" );
844 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 847 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
845 if (p-> mShowIconBack) { 848 if (p-> mShowIconBack) {
846 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 849 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
847 connect( action, SIGNAL( activated() ), 850 connect( action, SIGNAL( activated() ),
848 mView, SLOT( goPrevious() ) ); 851 mView, SLOT( goPrevious() ) );
849 action->addTo( iconToolBar ); 852 action->addTo( iconToolBar );
850 } 853 }
851 if (p-> mShowIconToday) 854 if (p-> mShowIconToday)
852 today_action->addTo( iconToolBar ); 855 today_action->addTo( iconToolBar );
853 icon = loadPixmap( pathString + "1rightarrowB" ); 856 icon = loadPixmap( pathString + "1rightarrowB" );
854 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 857 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
855 if (p-> mShowIconForward) { 858 if (p-> mShowIconForward) {
856 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 859 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
857 connect( action, SIGNAL( activated() ), 860 connect( action, SIGNAL( activated() ),
858 mView, SLOT( goNext() ) ); 861 mView, SLOT( goNext() ) );
859 action->addTo( iconToolBar ); 862 action->addTo( iconToolBar );
860 } 863 }
861 icon = loadPixmap( pathString + "2rightarrowB" ); 864 icon = loadPixmap( pathString + "2rightarrowB" );
862 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 865 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
863 if (p-> mShowIconForwardFast) { 866 if (p-> mShowIconForwardFast) {
864 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 867 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
865 connect( action, SIGNAL( activated() ), 868 connect( action, SIGNAL( activated() ),
866 mView, SLOT( goNextMonth() ) ); 869 mView, SLOT( goNextMonth() ) );
867 action->addTo( iconToolBar ); 870 action->addTo( iconToolBar );
868 } 871 }
869 872
870 873
871 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 874 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
872 875
873 if (p-> mShowIconNewEvent) 876 if (p-> mShowIconNewEvent)
874 configureToolBarMenu->setItemChecked( 10, true ); 877 configureToolBarMenu->setItemChecked( 10, true );
875 if (p->mShowIconNewTodo ) 878 if (p->mShowIconNewTodo )
876 configureToolBarMenu->setItemChecked( 20, true ); 879 configureToolBarMenu->setItemChecked( 20, true );
877 if (p-> mShowIconSearch) 880 if (p-> mShowIconSearch)
878 configureToolBarMenu->setItemChecked( 120, true ); 881 configureToolBarMenu->setItemChecked( 120, true );
879 if (p-> mShowIconList) 882 if (p-> mShowIconList)
880 configureToolBarMenu->setItemChecked( 30, true ); 883 configureToolBarMenu->setItemChecked( 30, true );
881 if (p-> mShowIconDay1) 884 if (p-> mShowIconDay1)
882 configureToolBarMenu->setItemChecked( 40, true ); 885 configureToolBarMenu->setItemChecked( 40, true );
883 if (p-> mShowIconDay5) 886 if (p-> mShowIconDay5)
884 configureToolBarMenu->setItemChecked( 50, true ); 887 configureToolBarMenu->setItemChecked( 50, true );
885 if (p-> mShowIconDay7) 888 if (p-> mShowIconDay7)
886 configureToolBarMenu->setItemChecked( 60, true ); 889 configureToolBarMenu->setItemChecked( 60, true );
887 if (p-> mShowIconMonth) 890 if (p-> mShowIconMonth)
888 configureToolBarMenu->setItemChecked( 70, true ); 891 configureToolBarMenu->setItemChecked( 70, true );
889 if (p-> mShowIconTodoview) 892 if (p-> mShowIconTodoview)
890 configureToolBarMenu->setItemChecked( 80, true ); 893 configureToolBarMenu->setItemChecked( 80, true );
891 if (p-> mShowIconBackFast) 894 if (p-> mShowIconBackFast)
892 configureToolBarMenu->setItemChecked( 200, true ); 895 configureToolBarMenu->setItemChecked( 200, true );
893 if (p-> mShowIconBack) 896 if (p-> mShowIconBack)
894 configureToolBarMenu->setItemChecked( 210, true ); 897 configureToolBarMenu->setItemChecked( 210, true );
895 if (p-> mShowIconToday) 898 if (p-> mShowIconToday)
896 configureToolBarMenu->setItemChecked( 130, true ); 899 configureToolBarMenu->setItemChecked( 130, true );
897 if (p-> mShowIconForward) 900 if (p-> mShowIconForward)
898 configureToolBarMenu->setItemChecked( 220, true ); 901 configureToolBarMenu->setItemChecked( 220, true );
899 if (p-> mShowIconForwardFast) 902 if (p-> mShowIconForwardFast)
900 configureToolBarMenu->setItemChecked( 230, true ); 903 configureToolBarMenu->setItemChecked( 230, true );
901 if (p-> mShowIconNextDays) 904 if (p-> mShowIconNextDays)
902 configureToolBarMenu->setItemChecked( 100, true ); 905 configureToolBarMenu->setItemChecked( 100, true );
903 if (p-> mShowIconNext) 906 if (p-> mShowIconNext)
904 configureToolBarMenu->setItemChecked( 110, true ); 907 configureToolBarMenu->setItemChecked( 110, true );
905 if (p-> mShowIconJournal) 908 if (p-> mShowIconJournal)
906 configureToolBarMenu->setItemChecked( 90, true ); 909 configureToolBarMenu->setItemChecked( 90, true );
907 if (p-> mShowIconWhatsThis) 910 if (p-> mShowIconWhatsThis)
908 configureToolBarMenu->setItemChecked( 300, true ); 911 configureToolBarMenu->setItemChecked( 300, true );
909 912
910 QLabel* dummy = new QLabel( iconToolBar ); 913 QLabel* dummy = new QLabel( iconToolBar );
911 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 914 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
912 if (!p-> mShowIconStretch) 915 if (!p-> mShowIconStretch)
913 iconToolBar->setStretchableWidget ( dummy ) ; 916 iconToolBar->setStretchableWidget ( dummy ) ;
914 else 917 else
915 configureToolBarMenu->setItemChecked( 5, true ); 918 configureToolBarMenu->setItemChecked( 5, true );
916 if (p-> mShowIconWhatsThis) 919 if (p-> mShowIconWhatsThis)
917 QWhatsThis::whatsThisButton ( iconToolBar ); 920 QWhatsThis::whatsThisButton ( iconToolBar );
918 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 921 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
919 configureAgenda( p->mHourSize ); 922 configureAgenda( p->mHourSize );
920 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 923 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
921} 924}
922void MainWindow::fillSyncMenu() 925void MainWindow::fillSyncMenu()
923{ 926{
924 if ( syncMenu->count() ) 927 if ( syncMenu->count() )
925 syncMenu->clear(); 928 syncMenu->clear();
926 syncMenu->insertItem( i18n("Configure..."), 0 ); 929 syncMenu->insertItem( i18n("Configure..."), 0 );
927 syncMenu->insertSeparator(); 930 syncMenu->insertSeparator();
928 if ( mServerSocket == 0 ) { 931 if ( mServerSocket == 0 ) {
929 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 932 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
930 } else { 933 } else {
931 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 934 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
932 } 935 }
933 syncMenu->insertSeparator(); 936 syncMenu->insertSeparator();
934 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 937 syncMenu->insertItem( i18n("Multiple sync"), 1 );
935 syncMenu->insertSeparator(); 938 syncMenu->insertSeparator();
936 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 939 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
937 config.setGroup("General"); 940 config.setGroup("General");
938 QStringList prof = config.readListEntry("SyncProfileNames"); 941 QStringList prof = config.readListEntry("SyncProfileNames");
939 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 942 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
940 if ( prof.count() < 3 ) { 943 if ( prof.count() < 3 ) {
941 prof.clear(); 944 prof.clear();
942 prof << i18n("Sharp_DTM"); 945 prof << i18n("Sharp_DTM");
943 prof << i18n("Local_file"); 946 prof << i18n("Local_file");
944 prof << i18n("Last_file"); 947 prof << i18n("Last_file");
945 KSyncProfile* temp = new KSyncProfile (); 948 KSyncProfile* temp = new KSyncProfile ();
946 temp->setName( prof[0] ); 949 temp->setName( prof[0] );
947 temp->writeConfig(&config); 950 temp->writeConfig(&config);
948 temp->setName( prof[1] ); 951 temp->setName( prof[1] );
949 temp->writeConfig(&config); 952 temp->writeConfig(&config);
950 temp->setName( prof[2] ); 953 temp->setName( prof[2] );
951 temp->writeConfig(&config); 954 temp->writeConfig(&config);
952 config.setGroup("General"); 955 config.setGroup("General");
953 config.writeEntry("SyncProfileNames",prof); 956 config.writeEntry("SyncProfileNames",prof);
954 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 957 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
955 config.sync(); 958 config.sync();
956 delete temp; 959 delete temp;
957 } 960 }
958 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 961 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
959 KOPrefs::instance()->mSyncProfileNames = prof; 962 KOPrefs::instance()->mSyncProfileNames = prof;
960 int i; 963 int i;
961 for ( i = 0; i < prof.count(); ++i ) { 964 for ( i = 0; i < prof.count(); ++i ) {
962 965
963 syncMenu->insertItem( prof[i], 1000+i ); 966 syncMenu->insertItem( prof[i], 1000+i );
964 if ( i == 2 ) 967 if ( i == 2 )
965 syncMenu->insertSeparator(); 968 syncMenu->insertSeparator();
966 } 969 }
967 QDir app_dir; 970 QDir app_dir;
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")+
1352 i18n("<p><h3>In agenda view:</h3></p>\n") + 1359 i18n("<p><h3>In agenda view:</h3></p>\n") +
1353 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1360 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1354 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1361 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1355 i18n("<p><h3>In todo view:</h3></p>\n") + 1362 i18n("<p><h3>In todo view:</h3></p>\n") +
1356 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1363 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1357 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1364 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1358 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1365 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1359 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1366 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1360 i18n("<p><h3>In list view:</h3></p>\n") + 1367 i18n("<p><h3>In list view:</h3></p>\n") +
1361 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1368 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1362 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1369 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1363 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1370 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1364 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1371 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1365 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1372 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1366 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1373 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1367 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1374 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1368 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1375 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1369 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1376 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1370 i18n("<p><b>E</b>: Edit item</p>\n") + 1377 i18n("<p><b>E</b>: Edit item</p>\n") +
1371 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1378 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1372 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1379 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1373 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1380 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1374 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1381 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1375 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1382 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1376 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1383 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1377 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1384 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1378 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1385 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1379 i18n("<p><b>White</b>: Item readonly</p>\n"); 1386 i18n("<p><b>White</b>: Item readonly</p>\n");
1380 displayText( text, cap); 1387 displayText( text, cap);
1381 1388
1382} 1389}
1383void MainWindow::aboutAutoSaving() 1390void MainWindow::aboutAutoSaving()
1384{ 1391{
1385 QMessageBox* msg; 1392 QMessageBox* msg;
1386 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1393 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1387 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, 1394 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon,
1388 QMessageBox::Ok, 1395 QMessageBox::Ok,
1389 QMessageBox::NoButton, 1396 QMessageBox::NoButton,
1390 QMessageBox::NoButton); 1397 QMessageBox::NoButton);
1391 msg->exec(); 1398 msg->exec();
1392 delete msg; 1399 delete msg;
1393 1400
1394 1401
1395} 1402}
1396void MainWindow::aboutKnownBugs() 1403void MainWindow::aboutKnownBugs()
1397{ 1404{
1398 QMessageBox* msg; 1405 QMessageBox* msg;
1399 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1406 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1400 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1407 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1401 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1408 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1402 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1409 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1403 i18n("\nor report them in the bugtracker on\n") + 1410 i18n("\nor report them in the bugtracker on\n") +
1404 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1411 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1405 QMessageBox::NoIcon, 1412 QMessageBox::NoIcon,
1406 QMessageBox::Ok, 1413 QMessageBox::Ok,
1407 QMessageBox::NoButton, 1414 QMessageBox::NoButton,
1408 QMessageBox::NoButton); 1415 QMessageBox::NoButton);
1409 msg->exec(); 1416 msg->exec();
1410 delete msg; 1417 delete msg;
1411 1418
1412} 1419}
1413 1420
1414QString MainWindow::defaultFileName() 1421QString MainWindow::defaultFileName()
1415{ 1422{
1416 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1423 return locateLocal( "data", "korganizer/mycalendar.ics" );
1417} 1424}
1418QString MainWindow::syncFileName() 1425QString MainWindow::syncFileName()
1419{ 1426{
1420#ifdef _WIN32_ 1427#ifdef _WIN32_
1421 return locateLocal( "tmp", "synccalendar.ics" ); 1428 return locateLocal( "tmp", "synccalendar.ics" );
1422#else 1429#else
1423 return QString( "/tmp/kopitempfile.ics" ); 1430 return QString( "/tmp/kopitempfile.ics" );
1424#endif 1431#endif
1425} 1432}
1426 1433
1427void MainWindow::processIncidenceSelection( Incidence *incidence ) 1434void MainWindow::processIncidenceSelection( Incidence *incidence )
1428{ 1435{
1429 if ( !incidence ) { 1436 if ( !incidence ) {
1430 enableIncidenceActions( false ); 1437 enableIncidenceActions( false );
1431 1438
1432 mNewSubTodoAction->setEnabled( false ); 1439 mNewSubTodoAction->setEnabled( false );
1433 setCaptionToDates(); 1440 setCaptionToDates();
1434 return; 1441 return;
1435 1442
1436 } 1443 }
1437 1444
1438 //KGlobal::locale()->formatDateTime(nextA, true); 1445 //KGlobal::locale()->formatDateTime(nextA, true);
1439 QString startString = ""; 1446 QString startString = "";
1440 if ( incidence->type() != "Todo" ) { 1447 if ( incidence->type() != "Todo" ) {
1441 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1448 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1442 if ( incidence->doesFloat() ) { 1449 if ( incidence->doesFloat() ) {
1443 startString += ": "+incidence->dtStartDateStr( true ); 1450 startString += ": "+incidence->dtStartDateStr( true );
1444 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1451 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1445 1452
1446 } else { 1453 } else {
1447 startString = ": "+incidence->dtStartStr(true); 1454 startString = ": "+incidence->dtStartStr(true);
1448 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1455 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1449 1456
1450 } 1457 }
1451 1458
1452 } else { 1459 } else {
1453 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1460 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1454 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1461 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1455 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1462 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1456 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1463 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1457 } 1464 }
1458 1465
1459 } 1466 }
1460 else 1467 else
1461 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1468 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1462 if ( !incidence->location().isEmpty() ) 1469 if ( !incidence->location().isEmpty() )
1463 startString += " (" +incidence->location()+")"; 1470 startString += " (" +incidence->location()+")";
1464 setCaption( incidence->summary()+startString); 1471 setCaption( incidence->summary()+startString);
1465 1472
1466 enableIncidenceActions( true ); 1473 enableIncidenceActions( true );
1467 1474
1468 if ( incidence->type() == "Event" ) { 1475 if ( incidence->type() == "Event" ) {
1469 mShowAction->setText( i18n("Show Event...") ); 1476 mShowAction->setText( i18n("Show Event...") );
1470 mEditAction->setText( i18n("Edit Event...") ); 1477 mEditAction->setText( i18n("Edit Event...") );
1471 mDeleteAction->setText( i18n("Delete Event...") ); 1478 mDeleteAction->setText( i18n("Delete Event...") );
1472 1479
1473 mNewSubTodoAction->setEnabled( false ); 1480 mNewSubTodoAction->setEnabled( false );
1474 } else if ( incidence->type() == "Todo" ) { 1481 } else if ( incidence->type() == "Todo" ) {
1475 mShowAction->setText( i18n("Show Todo...") ); 1482 mShowAction->setText( i18n("Show Todo...") );
1476 mEditAction->setText( i18n("Edit Todo...") ); 1483 mEditAction->setText( i18n("Edit Todo...") );
1477 mDeleteAction->setText( i18n("Delete Todo...") ); 1484 mDeleteAction->setText( i18n("Delete Todo...") );
1478 1485
1479 mNewSubTodoAction->setEnabled( true ); 1486 mNewSubTodoAction->setEnabled( true );
1480 } else { 1487 } else {
1481 mShowAction->setText( i18n("Show...") ); 1488 mShowAction->setText( i18n("Show...") );
1482 mShowAction->setText( i18n("Edit...") ); 1489 mShowAction->setText( i18n("Edit...") );
1483 mShowAction->setText( i18n("Delete...") ); 1490 mShowAction->setText( i18n("Delete...") );
1484 1491
1485 mNewSubTodoAction->setEnabled( false ); 1492 mNewSubTodoAction->setEnabled( false );
1486 } 1493 }
1487} 1494}
1488 1495
1489void MainWindow::enableIncidenceActions( bool enabled ) 1496void MainWindow::enableIncidenceActions( bool enabled )
1490{ 1497{
1491 mShowAction->setEnabled( enabled ); 1498 mShowAction->setEnabled( enabled );
1492 mEditAction->setEnabled( enabled ); 1499 mEditAction->setEnabled( enabled );
1493 mDeleteAction->setEnabled( enabled ); 1500 mDeleteAction->setEnabled( enabled );
1494} 1501}
1495 1502
1496void MainWindow::importOL() 1503void MainWindow::importOL()
1497{ 1504{
1498#ifdef _WIN32_ 1505#ifdef _WIN32_
1499 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1506 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1500 id->exec(); 1507 id->exec();
1501 delete id; 1508 delete id;
1502 mView->updateView(); 1509 mView->updateView();
1503#endif 1510#endif
1504} 1511}
1505void MainWindow::importBday() 1512void MainWindow::importBday()
1506{ 1513{
1507 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1514 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1508 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1515 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1509 i18n("Import!"), i18n("Cancel"), 0, 1516 i18n("Import!"), i18n("Cancel"), 0,
1510 0, 1 ); 1517 0, 1 );
1511 if ( result == 0 ) { 1518 if ( result == 0 ) {
1512 mView->importBday(); 1519 mView->importBday();
1513 1520
1514 } 1521 }
1515 1522
1516 1523
1517} 1524}
1518void MainWindow::importQtopia() 1525void MainWindow::importQtopia()
1519{ 1526{
1520#ifndef DESKTOP_VERSION 1527#ifndef DESKTOP_VERSION
1521 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1528 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1522 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1529 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1523 i18n("Import!"), i18n("Cancel"), 0, 1530 i18n("Import!"), i18n("Cancel"), 0,
1524 0, 1 ); 1531 0, 1 );
1525 if ( result == 0 ) { 1532 if ( result == 0 ) {
1526 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1533 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1527 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1534 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1528 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1535 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1529 mView->importQtopia( categories, datebook, todolist ); 1536 mView->importQtopia( categories, datebook, todolist );
1530 } 1537 }
1531#else 1538#else
1532 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1539 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1533 i18n("Not supported \non desktop!\n"), 1540 i18n("Not supported \non desktop!\n"),
1534 i18n("Ok"), i18n("Cancel"), 0, 1541 i18n("Ok"), i18n("Cancel"), 0,
1535 0, 1 ); 1542 0, 1 );
1536 1543
1537#endif 1544#endif
1538} 1545}
1539 1546
1540void MainWindow::saveOnClose() 1547void MainWindow::saveOnClose()
1541{ 1548{
1542 KOPrefs *p = KOPrefs::instance(); 1549 KOPrefs *p = KOPrefs::instance();
1543 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1550 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1544 p->mToolBarUp = iconToolBar->x() > width()/2 || 1551 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1545 iconToolBar->y() > height()/2; 1552 iconToolBar->y() > height()/2;
1546 mView->writeSettings(); 1553 mView->writeSettings();
1547 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1554 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1548 save(); 1555 save();
1549} 1556}
1550void MainWindow::slotModifiedChanged( bool changed ) 1557void MainWindow::slotModifiedChanged( bool changed )
1551{ 1558{
1552 if ( mBlockAtStartup ) 1559 if ( mBlockAtStartup )
1553 return; 1560 return;
1554 int msec; 1561 int msec;
1555 // we store the changes after 1 minute, 1562 // we store the changes after 1 minute,
1556 // and for safety reasons after 10 minutes again 1563 // and for safety reasons after 10 minutes again
1557 if ( !mBlockSaveFlag ) 1564 if ( !mBlockSaveFlag )
1558 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1565 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1559 else 1566 else
1560 msec = 1000 * 600; 1567 msec = 1000 * 600;
1561 mSaveTimer.start( msec, true ); // 1 minute 1568 mSaveTimer.start( msec, true ); // 1 minute
1562 qDebug("KO: Saving File in %d secs!", msec/1000); 1569 qDebug("KO: Saving File in %d secs!", msec/1000);
1563 mCalendarModifiedFlag = true; 1570 mCalendarModifiedFlag = true;
1564} 1571}
1565void MainWindow::save() 1572void MainWindow::save()
1566{ 1573{
1567 if ( mBlockSaveFlag ) 1574 if ( mBlockSaveFlag )
1568 return; 1575 return;
1569 bool store = mBlockSaveFlag; 1576 bool store = mBlockSaveFlag;
1570 mBlockSaveFlag = true; 1577 mBlockSaveFlag = true;
1571 if ( mView->checkFileVersion( defaultFileName()) ) { 1578 if ( mView->checkFileVersion( defaultFileName()) ) {
1572 1579
1573 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1580 QTime neededSaveTime = QDateTime::currentDateTime().time();
1574 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1581 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1575 qDebug("KO: Start saving data to file!"); 1582 qDebug("KO: Start saving data to file!");
1576 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1583 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1577 mView->saveCalendar( defaultFileName() ); 1584 mView->saveCalendar( defaultFileName() );
1578 1585
1579 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1586 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1580 mView->watchSavedFile(); 1587 mView->watchSavedFile();
1581 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1588 qDebug("KO: Needed %d ms for saving.",msNeeded );
1582 QString savemes; 1589 QString savemes;
1583 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1590 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1584 setCaption(savemes); 1591 setCaption(savemes);
1585 } else 1592 } else
1586 setCaption(i18n("Saving cancelled!")); 1593 setCaption(i18n("Saving cancelled!"));
1587 mCalendarModifiedFlag = false; 1594 mCalendarModifiedFlag = false;
1588 mBlockSaveFlag = store; 1595 mBlockSaveFlag = store;
1589} 1596}
1590 1597
1591void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1598void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1592{ 1599{
1593 if ( !e->isAutoRepeat() ) { 1600 if ( !e->isAutoRepeat() ) {
1594 mFlagKeyPressed = false; 1601 mFlagKeyPressed = false;
1595 } 1602 }
1596} 1603}
1597void MainWindow::keyPressEvent ( QKeyEvent * e ) 1604void MainWindow::keyPressEvent ( QKeyEvent * e )
1598{ 1605{
1599 qApp->processEvents(); 1606 qApp->processEvents();
1600 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1607 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1601 e->ignore(); 1608 e->ignore();
1602 // qDebug(" ignore %d",e->isAutoRepeat() ); 1609 // qDebug(" ignore %d",e->isAutoRepeat() );
1603 return; 1610 return;
1604 } 1611 }
1605 if (! e->isAutoRepeat() ) 1612 if (! e->isAutoRepeat() )
1606 mFlagKeyPressed = true; 1613 mFlagKeyPressed = true;
1607 KOPrefs *p = KOPrefs::instance(); 1614 KOPrefs *p = KOPrefs::instance();
1608 bool showSelectedDates = false; 1615 bool showSelectedDates = false;
1609 int size; 1616 int size;
1610 int pro = 0; 1617 int pro = 0;
1611 //qDebug("MainWindow::keyPressEvent "); 1618 //qDebug("MainWindow::keyPressEvent ");
1612 switch ( e->key() ) { 1619 switch ( e->key() ) {
1613 case Qt::Key_Right: 1620 case Qt::Key_Right:
1614 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1621 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1615 mView->goNextMonth(); 1622 mView->goNextMonth();
1616 else 1623 else
1617 mView->goNext(); 1624 mView->goNext();
1618 showSelectedDates = true; 1625 showSelectedDates = true;
1619 break; 1626 break;
1620 case Qt::Key_Left: 1627 case Qt::Key_Left:
1621 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1628 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1622 mView->goPreviousMonth(); 1629 mView->goPreviousMonth();
1623 else 1630 else
1624 mView->goPrevious(); 1631 mView->goPrevious();
1625 showSelectedDates = true; 1632 showSelectedDates = true;
1626 break; 1633 break;
1627 case Qt::Key_Down: 1634 case Qt::Key_Down:
1628 mView->viewManager()->agendaView()->scrollOneHourDown(); 1635 mView->viewManager()->agendaView()->scrollOneHourDown();
1629 break; 1636 break;
1630 case Qt::Key_Up: 1637 case Qt::Key_Up:
1631 mView->viewManager()->agendaView()->scrollOneHourUp(); 1638 mView->viewManager()->agendaView()->scrollOneHourUp();
1632 break; 1639 break;
1633 case Qt::Key_I: 1640 case Qt::Key_I:
1634 mView->showIncidence(); 1641 mView->showIncidence();
1635 break; 1642 break;
1636 case Qt::Key_Delete: 1643 case Qt::Key_Delete:
1637 case Qt::Key_Backspace: 1644 case Qt::Key_Backspace:
1638 mView->deleteIncidence(); 1645 mView->deleteIncidence();
1639 break; 1646 break;
1640 case Qt::Key_D: 1647 case Qt::Key_D:
1641 mView->viewManager()->showDayView(); 1648 mView->viewManager()->showDayView();
1642 showSelectedDates = true; 1649 showSelectedDates = true;
1643 break; 1650 break;
1644 case Qt::Key_O: 1651 case Qt::Key_O:
1645 mView->toggleFilerEnabled( ); 1652 mView->toggleFilerEnabled( );
1646 break; 1653 break;
1647 case Qt::Key_0: 1654 case Qt::Key_0:
1648 case Qt::Key_1: 1655 case Qt::Key_1:
1649 case Qt::Key_2: 1656 case Qt::Key_2:
1650 case Qt::Key_3: 1657 case Qt::Key_3:
1651 case Qt::Key_4: 1658 case Qt::Key_4:
1652 case Qt::Key_5: 1659 case Qt::Key_5:
1653 case Qt::Key_6: 1660 case Qt::Key_6:
1654 case Qt::Key_7: 1661 case Qt::Key_7:
1655 case Qt::Key_8: 1662 case Qt::Key_8:
1656 case Qt::Key_9: 1663 case Qt::Key_9:
1657 pro = e->key()-48; 1664 pro = e->key()-48;
1658 if ( pro == 0 ) 1665 if ( pro == 0 )
1659 pro = 10; 1666 pro = 10;
1660 if ( e->state() == Qt::ControlButton) 1667 if ( e->state() == Qt::ControlButton)
1661 pro += 10; 1668 pro += 10;
1662 break; 1669 break;
1663 case Qt::Key_M: 1670 case Qt::Key_M:
1664 mView->viewManager()->showMonthView(); 1671 mView->viewManager()->showMonthView();
1665 showSelectedDates = true; 1672 showSelectedDates = true;
1666 break; 1673 break;
1667 case Qt::Key_Insert: 1674 case Qt::Key_Insert:
1668 mView->newEvent(); 1675 mView->newEvent();
1669 break; 1676 break;
1670 case Qt::Key_S : 1677 case Qt::Key_S :
1671 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1678 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1672 mView->newSubTodo(); 1679 mView->newSubTodo();
1673 else 1680 else
1674 mView->dialogManager()->showSearchDialog(); 1681 mView->dialogManager()->showSearchDialog();
1675 break; 1682 break;
1676 case Qt::Key_Y : 1683 case Qt::Key_Y :
1677 case Qt::Key_Z : 1684 case Qt::Key_Z :
1678 mView->viewManager()->showWorkWeekView(); 1685 mView->viewManager()->showWorkWeekView();
1679 showSelectedDates = true; 1686 showSelectedDates = true;
1680 break; 1687 break;
1681 case Qt::Key_U : 1688 case Qt::Key_U :
1682 mView->viewManager()->showWeekView(); 1689 mView->viewManager()->showWeekView();
1683 showSelectedDates = true; 1690 showSelectedDates = true;
1684 break; 1691 break;
1685 case Qt::Key_H : 1692 case Qt::Key_H :
1686 keyBindings(); 1693 keyBindings();
1687 break; 1694 break;
1688 case Qt::Key_W: 1695 case Qt::Key_W:
1689 mView->viewManager()->showWhatsNextView(); 1696 mView->viewManager()->showWhatsNextView();
1690 break; 1697 break;
1691 case Qt::Key_L: 1698 case Qt::Key_L:
1692 mView->viewManager()->showListView(); 1699 mView->viewManager()->showListView();
1693 break; 1700 break;
1694 case Qt::Key_N: 1701 case Qt::Key_N:
1695 mView->viewManager()->showNextXView(); 1702 mView->viewManager()->showNextXView();
1696 showSelectedDates = true; 1703 showSelectedDates = true;
1697 break; 1704 break;
1698 case Qt::Key_V: 1705 case Qt::Key_V:
1699 mView->viewManager()->showTodoView(); 1706 mView->viewManager()->showTodoView();
1700 break; 1707 break;
1701 case Qt::Key_C: 1708 case Qt::Key_C:
1702 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1709 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1703 break; 1710 break;
1704 case Qt::Key_P: 1711 case Qt::Key_P:
1705 mView->showDatePicker( ); 1712 mView->showDatePicker( );
1706 break; 1713 break;
1707 case Qt::Key_F: 1714 case Qt::Key_F:
1708 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1715 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1709 mView->editFilters(); 1716 mView->editFilters();
1710 else 1717 else
1711 mView->toggleFilter(); 1718 mView->toggleFilter();
1712 break; 1719 break;
1713 case Qt::Key_X: 1720 case Qt::Key_X:
1714 mView->toggleDateNavigatorWidget(); 1721 mView->toggleDateNavigatorWidget();
1715 break; 1722 break;
1716 case Qt::Key_Space: 1723 case Qt::Key_Space:
1717 mView->toggleExpand(); 1724 mView->toggleExpand();
1718 break; 1725 break;
1719 case Qt::Key_A: 1726 case Qt::Key_A:
1720 mView->toggleAllDaySize(); 1727 mView->toggleAllDaySize();
1721 break; 1728 break;
1722 case Qt::Key_T: 1729 case Qt::Key_T:
1723 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1730 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1724 mView->newTodo(); 1731 mView->newTodo();
1725 else { 1732 else {
1726 mView->goToday(); 1733 mView->goToday();
1727 showSelectedDates = true; 1734 showSelectedDates = true;
1728 } 1735 }
1729 break; 1736 break;
1730 case Qt::Key_J: 1737 case Qt::Key_J:
1731 mView->viewManager()->showJournalView(); 1738 mView->viewManager()->showJournalView();
1732 break; 1739 break;
1733 case Qt::Key_B: 1740 case Qt::Key_B:
1734 mView->editIncidenceDescription();; 1741 mView->editIncidenceDescription();;
1735 break; 1742 break;
1736 // case Qt::Key_Return: 1743 // case Qt::Key_Return:
1737 case Qt::Key_E: 1744 case Qt::Key_E:
1738 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1745 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1739 mView->newEvent(); 1746 mView->newEvent();
1740 else 1747 else
1741 mView->editIncidence(); 1748 mView->editIncidence();
1742 break; 1749 break;
1743 case Qt::Key_Plus: 1750 case Qt::Key_Plus:
1744 size = p->mHourSize +2; 1751 size = p->mHourSize +2;
1745 if ( size <= 18 ) 1752 if ( size <= 18 )
1746 configureAgenda( size ); 1753 configureAgenda( size );
1747 break; 1754 break;
1748 case Qt::Key_Minus: 1755 case Qt::Key_Minus:
1749 size = p->mHourSize - 2; 1756 size = p->mHourSize - 2;
1750 if ( size >= 4 ) 1757 if ( size >= 4 )
1751 configureAgenda( size ); 1758 configureAgenda( size );
1752 break; 1759 break;
1753 1760
1754 1761
1755 default: 1762 default:
1756 e->ignore(); 1763 e->ignore();
1757 } 1764 }
1758 if ( pro > 0 ) { 1765 if ( pro > 0 ) {
1759 mView->selectFilter( pro-1 ); 1766 mView->selectFilter( pro-1 );
1760 } 1767 }
1761 if ( showSelectedDates ) { 1768 if ( showSelectedDates ) {
1762 ;// setCaptionToDates(); 1769 ;// setCaptionToDates();
1763 } 1770 }
1764 1771
1765} 1772}
1766 1773
1767void MainWindow::fillFilterMenu() 1774void MainWindow::fillFilterMenu()
1768{ 1775{
1769 selectFilterMenu->clear(); 1776 selectFilterMenu->clear();
1770 bool disable = false; 1777 bool disable = false;
1771 if ( mView->filterView()->filtersEnabled() ) { 1778 if ( mView->filterView()->filtersEnabled() ) {
1772 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1779 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1773 } 1780 }
1774 else { 1781 else {
1775 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1782 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1776 disable = true; 1783 disable = true;
1777 } 1784 }
1778 selectFilterMenu->insertSeparator(); 1785 selectFilterMenu->insertSeparator();
1779 QPtrList<CalFilter> fili = mView->filters(); 1786 QPtrList<CalFilter> fili = mView->filters();
1780 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1787 CalFilter *curfilter = mView->filterView()->selectedFilter();
1781 CalFilter *filter = fili.first(); 1788 CalFilter *filter = fili.first();
1782 int iii = 1; 1789 int iii = 1;
1783 while(filter) { 1790 while(filter) {
1784 selectFilterMenu->insertItem( filter->name(), iii ); 1791 selectFilterMenu->insertItem( filter->name(), iii );
1785 if ( filter == curfilter) 1792 if ( filter == curfilter)
1786 selectFilterMenu->setItemChecked( iii, true ); 1793 selectFilterMenu->setItemChecked( iii, true );
1787 if ( disable ) 1794 if ( disable )
1788 selectFilterMenu->setItemEnabled( iii, false ); 1795 selectFilterMenu->setItemEnabled( iii, false );
1789 filter = fili.next(); 1796 filter = fili.next();
1790 ++iii; 1797 ++iii;
1791 } 1798 }
1792} 1799}
1793void MainWindow::selectFilter( int fil ) 1800void MainWindow::selectFilter( int fil )
1794{ 1801{
1795 if ( fil == 0 ) { 1802 if ( fil == 0 ) {
1796 mView->toggleFilerEnabled( ); 1803 mView->toggleFilerEnabled( );
1797 } else { 1804 } else {
1798 mView->selectFilter( fil-1 ); 1805 mView->selectFilter( fil-1 );
1799 } 1806 }
1800} 1807}
1801void MainWindow::configureToolBar( int item ) 1808void MainWindow::configureToolBar( int item )
1802{ 1809{
1803 1810
1804 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1811 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1805 KOPrefs *p = KOPrefs::instance(); 1812 KOPrefs *p = KOPrefs::instance();
1806 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1813 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1807 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1814 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1808 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1815 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1809 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1816 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1810 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1817 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1811 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1818 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1812 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1819 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1813 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1820 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1814 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1821 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1815 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1822 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1816 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1823 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1817 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1824 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1818 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1825 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1819 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1826 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1820 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1827 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1821 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1828 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1822 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1829 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1823 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1830 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1824 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1831 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1825 // initActions(); 1832 // initActions();
1826} 1833}
1827 1834
1828void MainWindow::setCaptionToDates() 1835void MainWindow::setCaptionToDates()
1829{ 1836{
1830 QString selDates; 1837 QString selDates;
1831 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1838 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1832 if (mView->startDate() < mView->endDate() ) 1839 if (mView->startDate() < mView->endDate() )
1833 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1840 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1834 setCaption( i18n("Dates: ") + selDates ); 1841 setCaption( i18n("Dates: ") + selDates );
1835 1842
1836} 1843}
1837// parameter item == 0: reinit 1844// parameter item == 0: reinit
1838void MainWindow::configureAgenda( int item ) 1845void MainWindow::configureAgenda( int item )
1839{ 1846{
1840 1847
1841 KOPrefs *p = KOPrefs::instance(); 1848 KOPrefs *p = KOPrefs::instance();
1842 1849
1843 int i; 1850 int i;
1844 if ( item == 1 ) { 1851 if ( item == 1 ) {
1845 mView->toggleAllDaySize(); 1852 mView->toggleAllDaySize();
1846 return; 1853 return;
1847 } 1854 }
1848 // do not allow 4 for widgets higher than 480 1855 // do not allow 4 for widgets higher than 480
1849 // if ( QApplication::desktop()->height() > 480 ) { 1856 // if ( QApplication::desktop()->height() > 480 ) {
1850// if ( item == 4 ) 1857// if ( item == 4 )
1851// item = 6; 1858// item = 6;
1852// } 1859// }
1853 for ( i = 4; i <= 18; i= i+2 ) 1860 for ( i = 4; i <= 18; i= i+2 )
1854 configureAgendaMenu->setItemChecked( i, false ); 1861 configureAgendaMenu->setItemChecked( i, false );
1855 configureAgendaMenu->setItemChecked( item, true ); 1862 configureAgendaMenu->setItemChecked( item, true );
1856 if ( p->mHourSize == item ) 1863 if ( p->mHourSize == item )
1857 return; 1864 return;
1858 p->mHourSize=item; 1865 p->mHourSize=item;
1859 mView->viewManager()->agendaView()->updateConfig(); 1866 mView->viewManager()->agendaView()->updateConfig();
1860} 1867}
1861 1868
1862void MainWindow::saveCalendar() 1869void MainWindow::saveCalendar()
1863{ 1870{
1864 QString fn = KOPrefs::instance()->mLastSaveFile; 1871 QString fn = KOPrefs::instance()->mLastSaveFile;
1865 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1872 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1866 1873
1867 if ( fn == "" ) 1874 if ( fn == "" )
1868 return; 1875 return;
1869 QFileInfo info; 1876 QFileInfo info;
1870 info.setFile( fn ); 1877 info.setFile( fn );
1871 QString mes; 1878 QString mes;
1872 bool createbup = true; 1879 bool createbup = true;
1873 if ( info. exists() ) { 1880 if ( info. exists() ) {
1874 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1881 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1875 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1882 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1876 i18n("Overwrite!"), i18n("Cancel"), 0, 1883 i18n("Overwrite!"), i18n("Cancel"), 0,
1877 0, 1 ); 1884 0, 1 );
1878 if ( result != 0 ) { 1885 if ( result != 0 ) {
1879 createbup = false; 1886 createbup = false;
1880 } 1887 }
1881 } 1888 }
1882 if ( createbup ) { 1889 if ( createbup ) {
1883 mView->saveCalendar( fn ); 1890 mView->saveCalendar( fn );
1884 mes = i18n("KO/Pi:Saved %1").arg(fn); 1891 mes = i18n("KO/Pi:Saved %1").arg(fn);
1885 KOPrefs::instance()->mLastSaveFile = fn; 1892 KOPrefs::instance()->mLastSaveFile = fn;
1886 setCaption(mes); 1893 setCaption(mes);
1887 } 1894 }
1888} 1895}
1889void MainWindow::loadCalendar() 1896void MainWindow::loadCalendar()
1890{ 1897{
1891 1898
1892 QString fn = KOPrefs::instance()->mLastLoadFile; 1899 QString fn = KOPrefs::instance()->mLastLoadFile;
1893 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1900 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1894 1901
1895 if ( fn == "" ) 1902 if ( fn == "" )
1896 return; 1903 return;
1897 QFileInfo info; 1904 QFileInfo info;
1898 info.setFile( fn ); 1905 info.setFile( fn );
1899 QString mess; 1906 QString mess;
1900 bool loadbup = true; 1907 bool loadbup = true;
1901 if ( info. exists() ) { 1908 if ( info. exists() ) {
1902 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1909 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1903 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1910 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1904 mess, 1911 mess,
1905 i18n("Load!"), i18n("Cancel"), 0, 1912 i18n("Load!"), i18n("Cancel"), 0,
1906 0, 1 ); 1913 0, 1 );
1907 if ( result != 0 ) { 1914 if ( result != 0 ) {
1908 loadbup = false; 1915 loadbup = false;
1909 } 1916 }
1910 } else { 1917 } else {
1911 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1918 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1912 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1919 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1913 0, 1 ); 1920 0, 1 );
1914 1921
1915 return; 1922 return;
1916 } 1923 }
1917 if ( loadbup ) { 1924 if ( loadbup ) {
1918 mView->openCalendar( fn ); 1925 mView->openCalendar( fn );
1919 KOPrefs::instance()->mLastLoadFile = fn; 1926 KOPrefs::instance()->mLastLoadFile = fn;
1920 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1927 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1921 setCaption(mess); 1928 setCaption(mess);
1922 } 1929 }
1923 1930
1924} 1931}
1925void MainWindow::quickImportIcal() 1932void MainWindow::quickImportIcal()
1926{ 1933{
1927 importFile( KOPrefs::instance()->mLastImportFile, false ); 1934 importFile( KOPrefs::instance()->mLastImportFile, false );
1928} 1935}
1929void MainWindow::importFile( QString fn, bool quick ) 1936void MainWindow::importFile( QString fn, bool quick )
1930{ 1937{
1931 QFileInfo info; 1938 QFileInfo info;
1932 info.setFile( fn ); 1939 info.setFile( fn );
1933 QString mess; 1940 QString mess;
1934 bool loadbup = true; 1941 bool loadbup = true;
1935 if ( !info. exists() ) { 1942 if ( !info. exists() ) {
1936 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1943 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1937 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1944 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1938 mess ); 1945 mess );
1939 return; 1946 return;
1940 } 1947 }
1941 int result = 0; 1948 int result = 0;
1942 if ( !quick ) { 1949 if ( !quick ) {
1943 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1950 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1944 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1951 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1945 mess, 1952 mess,
1946 "Import", "Cancel", 0, 1953 "Import", "Cancel", 0,
1947 0, 1 ); 1954 0, 1 );
1948 } 1955 }
1949 if ( result == 0 ) { 1956 if ( result == 0 ) {
1950 if ( mView->openCalendar( fn, true )) { 1957 if ( mView->openCalendar( fn, true )) {
1951 KOPrefs::instance()->mLastImportFile = fn; 1958 KOPrefs::instance()->mLastImportFile = fn;
1952 setCaption(i18n("Imported file successfully")); 1959 setCaption(i18n("Imported file successfully"));
1953 } else { 1960 } else {
1954 setCaption(i18n("Error importing file")); 1961 setCaption(i18n("Error importing file"));
1955 } 1962 }
1956 } 1963 }
1957} 1964}
1958 1965
1959void MainWindow::importIcal() 1966void MainWindow::importIcal()
1960{ 1967{
1961 1968
1962 QString fn =KOPrefs::instance()->mLastImportFile; 1969 QString fn =KOPrefs::instance()->mLastImportFile;
1963 1970
1964 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1971 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1965 if ( fn == "" ) 1972 if ( fn == "" )
1966 return; 1973 return;
1967 importFile( fn, true ); 1974 importFile( fn, true );
1968 1975
1969} 1976}
1970 1977
1971void MainWindow::exportVCalendar() 1978void MainWindow::exportVCalendar()
1972{ 1979{
1973 QString fn = KOPrefs::instance()->mLastVcalFile; 1980 QString fn = KOPrefs::instance()->mLastVcalFile;
1974 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1981 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1975 if ( fn == "" ) 1982 if ( fn == "" )
1976 return; 1983 return;
1977 QFileInfo info; 1984 QFileInfo info;
1978 info.setFile( fn ); 1985 info.setFile( fn );
1979 QString mes; 1986 QString mes;
1980 bool createbup = true; 1987 bool createbup = true;
1981 if ( info. exists() ) { 1988 if ( info. exists() ) {
1982 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1989 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1983 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1990 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1984 i18n("Overwrite!"), i18n("Cancel"), 0, 1991 i18n("Overwrite!"), i18n("Cancel"), 0,
1985 0, 1 ); 1992 0, 1 );
1986 if ( result != 0 ) { 1993 if ( result != 0 ) {
1987 createbup = false; 1994 createbup = false;
1988 } 1995 }
1989 } 1996 }
1990 if ( createbup ) { 1997 if ( createbup ) {
1991 if ( mView->exportVCalendar( fn ) ) { 1998 if ( mView->exportVCalendar( fn ) ) {
1992 KOPrefs::instance()->mLastVcalFile = fn; 1999 KOPrefs::instance()->mLastVcalFile = fn;
1993 if ( fn.length() > 20 ) 2000 if ( fn.length() > 20 )
1994 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2001 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1995 else 2002 else
1996 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2003 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1997 setCaption(mes); 2004 setCaption(mes);
1998 } 2005 }
1999 } 2006 }
2000 2007
2001} 2008}
2002QString MainWindow::getPassword( ) 2009QString MainWindow::getPassword( )
2003{ 2010{
2004 QString retfile = ""; 2011 QString retfile = "";
2005 QDialog dia ( this, "input-dialog", true ); 2012 QDialog dia ( this, "input-dialog", true );
2006 QLineEdit lab ( &dia ); 2013 QLineEdit lab ( &dia );
2007 lab.setEchoMode( QLineEdit::Password ); 2014 lab.setEchoMode( QLineEdit::Password );
2008 QVBoxLayout lay( &dia ); 2015 QVBoxLayout lay( &dia );
2009 lay.setMargin(7); 2016 lay.setMargin(7);
2010 lay.setSpacing(7); 2017 lay.setSpacing(7);
2011 lay.addWidget( &lab); 2018 lay.addWidget( &lab);
2012 dia.setFixedSize( 230,50 ); 2019 dia.setFixedSize( 230,50 );
2013 dia.setCaption( i18n("Enter password") ); 2020 dia.setCaption( i18n("Enter password") );
2014 QPushButton pb ( "OK", &dia); 2021 QPushButton pb ( "OK", &dia);
2015 lay.addWidget( &pb ); 2022 lay.addWidget( &pb );
2016 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2023 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2017 dia.show(); 2024 dia.show();
2018 int res = dia.exec(); 2025 int res = dia.exec();
2019 if ( res ) 2026 if ( res )
2020 retfile = lab.text(); 2027 retfile = lab.text();
2021 dia.hide(); 2028 dia.hide();
2022 qApp->processEvents(); 2029 qApp->processEvents();
2023 return retfile; 2030 return retfile;
2024 2031
2025} 2032}
2026 2033
2027void MainWindow::enableQuick() 2034void MainWindow::enableQuick()
2028{ 2035{
2029 QDialog dia ( this, "input-dialog", true ); 2036 QDialog dia ( this, "input-dialog", true );
2030 QLineEdit lab ( &dia ); 2037 QLineEdit lab ( &dia );
2031 QVBoxLayout lay( &dia ); 2038 QVBoxLayout lay( &dia );
2032 lab.setText( KOPrefs::instance()->mPassiveSyncPort ); 2039 lab.setText( KOPrefs::instance()->mPassiveSyncPort );
2033 lay.setMargin(7); 2040 lay.setMargin(7);
2034 lay.setSpacing(7); 2041 lay.setSpacing(7);
2035 QLabel label ( i18n("Port number (Default: 9197)"), &dia ); 2042 QLabel label ( i18n("Port number (Default: 9197)"), &dia );
2036 lay.addWidget( &label); 2043 lay.addWidget( &label);
2037 lay.addWidget( &lab); 2044 lay.addWidget( &lab);
2038 2045
2039 QLineEdit lepw ( &dia ); 2046 QLineEdit lepw ( &dia );
2040 lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); 2047 lepw.setText( KOPrefs::instance()->mPassiveSyncPw );
2041 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 2048 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
2042 lay.addWidget( &label2); 2049 lay.addWidget( &label2);
2043 lay.addWidget( &lepw); 2050 lay.addWidget( &lepw);
2044 dia.setFixedSize( 230,80 ); 2051 dia.setFixedSize( 230,80 );
2045 dia.setCaption( i18n("Enter port for Pi-Sync") ); 2052 dia.setCaption( i18n("Enter port for Pi-Sync") );
2046 QPushButton pb ( "OK", &dia); 2053 QPushButton pb ( "OK", &dia);
2047 lay.addWidget( &pb ); 2054 lay.addWidget( &pb );
2048 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2055 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2049 dia.show(); 2056 dia.show();
2050 if ( ! dia.exec() ) 2057 if ( ! dia.exec() )
2051 return; 2058 return;
2052 dia.hide(); 2059 dia.hide();
2053 qApp->processEvents(); 2060 qApp->processEvents();
2054 KOPrefs::instance()->mPassiveSyncPw = lepw.text(); 2061 KOPrefs::instance()->mPassiveSyncPw = lepw.text();
2055 KOPrefs::instance()->mPassiveSyncPort = lab.text(); 2062 KOPrefs::instance()->mPassiveSyncPort = lab.text();
2056 bool ok; 2063 bool ok;
2057 Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); 2064 Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok);
2058 if ( ! ok ) { 2065 if ( ! ok ) {
2059 KMessageBox::information( this, i18n("No valid port")); 2066 KMessageBox::information( this, i18n("No valid port"));
2060 return; 2067 return;
2061 } 2068 }
2062 //qDebug("port %d ", port); 2069 //qDebug("port %d ", port);
2063 mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); 2070 mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 );
2064 mServerSocket->setFileName( defaultFileName() ); 2071 mServerSocket->setFileName( defaultFileName() );
2065 //qDebug("connected "); 2072 //qDebug("connected ");
2066 if ( !mServerSocket->ok() ) { 2073 if ( !mServerSocket->ok() ) {
2067 KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); 2074 KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!"));
2068 delete mServerSocket; 2075 delete mServerSocket;
2069 mServerSocket = 0; 2076 mServerSocket = 0;
2070 return; 2077 return;
2071 } 2078 }
2072 connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); 2079 connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) );
2073 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); 2080 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) );
2074} 2081}
2075 2082
2076void MainWindow::getFile( bool success ) 2083void MainWindow::getFile( bool success )
2077{ 2084{
2078 if ( ! success ) { 2085 if ( ! success ) {
2079 setCaption( i18n("Error receiving file. Nothing changed!") ); 2086 setCaption( i18n("Error receiving file. Nothing changed!") );
2080 return; 2087 return;
2081 } 2088 }
2082 mView->watchSavedFile(); 2089 mView->watchSavedFile();
2083 mView->openCalendar( defaultFileName() ); 2090 mView->openCalendar( defaultFileName() );
2084 setCaption( i18n("Pi-Sync successful!") ); 2091 setCaption( i18n("Pi-Sync successful!") );
2085 2092
2086} 2093}
2087 2094
2088 2095
2089void MainWindow::syncPi() 2096void MainWindow::syncPi()
2090{ 2097{
2091 qApp->processEvents(); 2098 qApp->processEvents();
2092 bool ok; 2099 bool ok;
2093 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); 2100 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
2094 if ( ! ok ) { 2101 if ( ! ok ) {
2095 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 2102 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
2096 return; 2103 return;
2097 } 2104 }
2098 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); 2105 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this );
2099 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 2106 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
2100 setCaption( i18n("Sending request for remote file ...") ); 2107 setCaption( i18n("Sending request for remote file ...") );
2101 commandSocket->readFile( syncFileName() ); 2108 commandSocket->readFile( syncFileName() );
2102} 2109}
2103 2110
2104void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) 2111void MainWindow::deleteCommandSocket(KCommandSocket*s, int state)
2105{ 2112{
2106 qDebug("MainWindow::deleteCommandSocket %d", state); 2113 qDebug("MainWindow::deleteCommandSocket %d", state);
2107 2114
2108 //enum { success, errorW, errorR, quiet }; 2115 //enum { success, errorW, errorR, quiet };
2109 if ( state == KCommandSocket::errorR ) { 2116 if ( state == KCommandSocket::errorR ) {
2110 setCaption( i18n("ERROR: Receiving remote file failed.") ); 2117 setCaption( i18n("ERROR: Receiving remote file failed.") );
2111 delete s; 2118 delete s;
2112 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); 2119 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
2113 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 2120 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
2114 commandSocket->sendStop(); 2121 commandSocket->sendStop();
2115 return; 2122 return;
2116 2123
2117 } else if ( state == KCommandSocket::errorW ) { 2124 } else if ( state == KCommandSocket::errorW ) {
2118 setCaption( i18n("ERROR:Writing back file failed.") ); 2125 setCaption( i18n("ERROR:Writing back file failed.") );
2119 2126
2120 } else if ( state == KCommandSocket::successR ) { 2127 } else if ( state == KCommandSocket::successR ) {
2121 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 2128 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
2122 2129
2123 } else if ( state == KCommandSocket::successW ) { 2130 } else if ( state == KCommandSocket::successW ) {
2124 setCaption( i18n("Pi-Sync succesful!") ); 2131 setCaption( i18n("Pi-Sync succesful!") );
2125 } 2132 }
2126 2133
2127 delete s; 2134 delete s;
2128} 2135}
2129 2136
2130void MainWindow::readFileFromSocket() 2137void MainWindow::readFileFromSocket()
2131{ 2138{
2132 QString fileName = syncFileName(); 2139 QString fileName = syncFileName();
2133 setCaption( i18n("Remote file saved to temp file.") ); 2140 setCaption( i18n("Remote file saved to temp file.") );
2134 if ( ! syncWithFile( fileName , true ) ) { 2141 if ( ! syncWithFile( fileName , true ) ) {
2135 setCaption( i18n("Syncing failed.") ); 2142 setCaption( i18n("Syncing failed.") );
2136 qDebug("Syncing failed "); 2143 qDebug("Syncing failed ");
2137 return; 2144 return;
2138 } 2145 }
2139 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); 2146 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
2140 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 2147 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
2141 if ( KOPrefs::instance()->mWriteBackFile ) 2148 if ( KOPrefs::instance()->mWriteBackFile )
2142 commandSocket->writeFile( fileName ); 2149 commandSocket->writeFile( fileName );
2143 else { 2150 else {
2144 commandSocket->sendStop(); 2151 commandSocket->sendStop();
2145 setCaption( i18n("Pi-Sync succesful!") ); 2152 setCaption( i18n("Pi-Sync succesful!") );
2146 } 2153 }
2147} 2154}
2148 2155
2149void MainWindow::syncLocalFile() 2156void MainWindow::syncLocalFile()
2150{ 2157{
2151 2158
2152 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 2159 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
2153 2160
2154 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2161 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2155 if ( fn == "" ) 2162 if ( fn == "" )
2156 return; 2163 return;
2157 //mView->setSyncDevice("local-file" ); 2164 //mView->setSyncDevice("local-file" );
2158 if ( syncWithFile( fn, false ) ) { 2165 if ( syncWithFile( fn, false ) ) {
2159 // Event* e = mView->getLastSyncEvent(); 2166 // Event* e = mView->getLastSyncEvent();
2160// e->setReadOnly( false ); 2167// e->setReadOnly( false );
2161// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2168// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2162// e->setReadOnly( true ); 2169// e->setReadOnly( true );
2163 } 2170 }
2164 2171
2165} 2172}
2166 2173
2167bool MainWindow::syncWithFile( QString fn , bool quick ) 2174bool MainWindow::syncWithFile( QString fn , bool quick )
2168{ 2175{
2169 bool ret = false; 2176 bool ret = false;
2170 QFileInfo info; 2177 QFileInfo info;
2171 info.setFile( fn ); 2178 info.setFile( fn );
2172 QString mess; 2179 QString mess;
2173 bool loadbup = true; 2180 bool loadbup = true;
2174 if ( !info. exists() ) { 2181 if ( !info. exists() ) {
2175 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2182 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2176 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2183 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2177 mess ); 2184 mess );
2178 return ret; 2185 return ret;
2179 } 2186 }
2180 int result = 0; 2187 int result = 0;
2181 if ( !quick ) { 2188 if ( !quick ) {
2182 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2189 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2183 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2190 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),