summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-19 00:37:51 (UTC)
committer zautrix <zautrix>2004-10-19 00:37:51 (UTC)
commit0f35c6660ed4c304b7c75f2a607f0f27ba436601 (patch) (unidiff)
treeb5e43d5bb00528d40eb0f94eeef5cf7d6cf00995
parent9fd09e806dfe3df5abdf70991b6ec170fed51078 (diff)
downloadkdepimpi-0f35c6660ed4c304b7c75f2a607f0f27ba436601.zip
kdepimpi-0f35c6660ed4c304b7c75f2a607f0f27ba436601.tar.gz
kdepimpi-0f35c6660ed4c304b7c75f2a607f0f27ba436601.tar.bz2
added pisync auto start
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp2
-rw-r--r--libkdepim/kpimprefs.cpp2
-rw-r--r--libkdepim/kpimprefs.h2
-rw-r--r--libkdepim/ksyncmanager.cpp87
-rw-r--r--libkdepim/ksyncmanager.h2
5 files changed, 64 insertions, 31 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index c3e9f75..02ca523 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1825 +1,1825 @@
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 <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "simplealarmclient.h" 62#include "simplealarmclient.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#include "koimportoldialog.h" 69#include "koimportoldialog.h"
70#endif 70#endif
71#include "mainwindow.h" 71#include "mainwindow.h"
72 72
73class KOex2phonePrefs : public QDialog 73class KOex2phonePrefs : public QDialog
74{ 74{
75 public: 75 public:
76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
77 QDialog( parent, name, true ) 77 QDialog( parent, name, true )
78 { 78 {
79 setCaption( i18n("Export to phone options") ); 79 setCaption( i18n("Export to phone options") );
80 QVBoxLayout* lay = new QVBoxLayout( this ); 80 QVBoxLayout* lay = new QVBoxLayout( this );
81 lay->setSpacing( 3 ); 81 lay->setSpacing( 3 );
82 lay->setMargin( 3 ); 82 lay->setMargin( 3 );
83 QLabel *lab; 83 QLabel *lab;
84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
85 lab->setAlignment (AlignHCenter ); 85 lab->setAlignment (AlignHCenter );
86 QHBox* temphb; 86 QHBox* temphb;
87 temphb = new QHBox( this ); 87 temphb = new QHBox( this );
88 new QLabel( i18n("I/O device: "), temphb ); 88 new QLabel( i18n("I/O device: "), temphb );
89 mPhoneDevice = new QLineEdit( temphb); 89 mPhoneDevice = new QLineEdit( temphb);
90 lay->addWidget( temphb ); 90 lay->addWidget( temphb );
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("Connection: "), temphb ); 92 new QLabel( i18n("Connection: "), temphb );
93 mPhoneConnection = new QLineEdit( temphb); 93 mPhoneConnection = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Model(opt.): "), temphb ); 96 new QLabel( i18n("Model(opt.): "), temphb );
97 mPhoneModel = new QLineEdit( temphb); 97 mPhoneModel = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
100 mWriteBackFuture->setChecked( true ); 100 mWriteBackFuture->setChecked( true );
101 lay->addWidget( mWriteBackFuture ); 101 lay->addWidget( mWriteBackFuture );
102 temphb = new QHBox( this ); 102 temphb = new QHBox( this );
103 new QLabel( i18n("Max. weeks in future: ") , temphb ); 103 new QLabel( i18n("Max. weeks in future: ") , temphb );
104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
105 mWriteBackFutureWeeks->setValue( 8 ); 105 mWriteBackFutureWeeks->setValue( 8 );
106 lay->addWidget( temphb ); 106 lay->addWidget( temphb );
107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
108 lab->setAlignment (AlignHCenter ); 108 lab->setAlignment (AlignHCenter );
109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
110 lay->addWidget( ok ); 110 lay->addWidget( ok );
111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
112 lay->addWidget( cancel ); 112 lay->addWidget( cancel );
113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
115 resize( 220, 240 ); 115 resize( 220, 240 );
116 116
117 } 117 }
118 118
119public: 119public:
120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
121 QCheckBox* mWriteBackFuture; 121 QCheckBox* mWriteBackFuture;
122 QSpinBox* mWriteBackFutureWeeks; 122 QSpinBox* mWriteBackFutureWeeks;
123}; 123};
124 124
125int globalFlagBlockStartup; 125int globalFlagBlockStartup;
126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
127 QMainWindow( parent, name ) 127 QMainWindow( parent, name )
128{ 128{
129 129
130#ifdef DESKTOP_VERSION 130#ifdef DESKTOP_VERSION
131 setFont( QFont("Arial"), 14 ); 131 setFont( QFont("Arial"), 14 );
132#endif 132#endif
133 mClosed = false; 133 mClosed = false;
134 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 134 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
135 QString confFile = locateLocal("config","korganizerrc"); 135 QString confFile = locateLocal("config","korganizerrc");
136 QFileInfo finf ( confFile ); 136 QFileInfo finf ( confFile );
137 bool showWarning = !finf.exists(); 137 bool showWarning = !finf.exists();
138 setIcon(SmallIcon( "ko24" ) ); 138 setIcon(SmallIcon( "ko24" ) );
139 mBlockAtStartup = true; 139 mBlockAtStartup = true;
140 mFlagKeyPressed = false; 140 mFlagKeyPressed = false;
141 setCaption("KOrganizer/Pi"); 141 setCaption("KOrganizer/Pi");
142 KOPrefs *p = KOPrefs::instance(); 142 KOPrefs *p = KOPrefs::instance();
143 KPimGlobalPrefs::instance()->setGlobalConfig(); 143 KPimGlobalPrefs::instance()->setGlobalConfig();
144 if ( p->mHourSize > 18 ) 144 if ( p->mHourSize > 18 )
145 p->mHourSize = 18; 145 p->mHourSize = 18;
146 QMainWindow::ToolBarDock tbd; 146 QMainWindow::ToolBarDock tbd;
147 if ( p->mToolBarHor ) { 147 if ( p->mToolBarHor ) {
148 if ( p->mToolBarUp ) 148 if ( p->mToolBarUp )
149 tbd = Bottom; 149 tbd = Bottom;
150 else 150 else
151 tbd = Top; 151 tbd = Top;
152 } 152 }
153 else { 153 else {
154 if ( p->mToolBarUp ) 154 if ( p->mToolBarUp )
155 tbd = Right; 155 tbd = Right;
156 else 156 else
157 tbd = Left; 157 tbd = Left;
158 } 158 }
159 if ( KOPrefs::instance()->mUseAppColors ) 159 if ( KOPrefs::instance()->mUseAppColors )
160 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 160 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
161 globalFlagBlockStartup = 1; 161 globalFlagBlockStartup = 1;
162 iconToolBar = new QPEToolBar( this ); 162 iconToolBar = new QPEToolBar( this );
163 addToolBar (iconToolBar , tbd ); 163 addToolBar (iconToolBar , tbd );
164 mCalendarModifiedFlag = false; 164 mCalendarModifiedFlag = false;
165 165
166 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 166 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
167 splash->setAlignment ( AlignCenter ); 167 splash->setAlignment ( AlignCenter );
168 setCentralWidget( splash ); 168 setCentralWidget( splash );
169#ifndef DESKTOP_VERSION 169#ifndef DESKTOP_VERSION
170 showMaximized(); 170 showMaximized();
171#endif 171#endif
172 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 172 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
173 setDefaultPreferences(); 173 setDefaultPreferences();
174 mCalendar = new CalendarLocal(); 174 mCalendar = new CalendarLocal();
175 mView = new CalendarView( mCalendar, this,"mCalendar " ); 175 mView = new CalendarView( mCalendar, this,"mCalendar " );
176 mView->hide(); 176 mView->hide();
177 //mView->resize(splash->size() ); 177 //mView->resize(splash->size() );
178 initActions(); 178 initActions();
179 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 179 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
180 mSyncManager->setBlockSave(false); 180 mSyncManager->setBlockSave(false);
181 mView->setSyncManager(mSyncManager); 181 mView->setSyncManager(mSyncManager);
182#ifndef DESKTOP_VERSION 182#ifndef DESKTOP_VERSION
183 iconToolBar->show(); 183 iconToolBar->show();
184 qApp->processEvents(); 184 qApp->processEvents();
185#endif 185#endif
186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
187 int vh = height() ; 187 int vh = height() ;
188 int vw = width(); 188 int vw = width();
189 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 189 //qDebug("Toolbar hei %d ",iconToolBar->height() );
190 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 190 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
191 vh -= iconToolBar->height(); 191 vh -= iconToolBar->height();
192 } else { 192 } else {
193 vw -= iconToolBar->height(); 193 vw -= iconToolBar->height();
194 } 194 }
195 //mView->setMaximumSize( splash->size() ); 195 //mView->setMaximumSize( splash->size() );
196 //mView->resize( splash->size() ); 196 //mView->resize( splash->size() );
197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
198 mView->readSettings(); 198 mView->readSettings();
199 bool newFile = false; 199 bool newFile = false;
200 if( !QFile::exists( defaultFileName() ) ) { 200 if( !QFile::exists( defaultFileName() ) ) {
201 QFileInfo finfo ( defaultFileName() ); 201 QFileInfo finfo ( defaultFileName() );
202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
203 qDebug("oldfile %s ", oldFile.latin1()); 203 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"; 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";
205 finfo.setFile( oldFile ); 205 finfo.setFile( oldFile );
206 if (finfo.exists() ) { 206 if (finfo.exists() ) {
207 KMessageBox::information( this, message); 207 KMessageBox::information( this, message);
208 mView->openCalendar( oldFile ); 208 mView->openCalendar( oldFile );
209 qApp->processEvents(); 209 qApp->processEvents();
210 } else { 210 } else {
211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
212 finfo.setFile( oldFile ); 212 finfo.setFile( oldFile );
213 if (finfo.exists() ) { 213 if (finfo.exists() ) {
214 KMessageBox::information( this, message); 214 KMessageBox::information( this, message);
215 mView->openCalendar( oldFile ); 215 mView->openCalendar( oldFile );
216 qApp->processEvents(); 216 qApp->processEvents();
217 } 217 }
218 } 218 }
219 mView->saveCalendar( defaultFileName() ); 219 mView->saveCalendar( defaultFileName() );
220 newFile = true; 220 newFile = true;
221 } 221 }
222 222
223 QTime neededSaveTime = QDateTime::currentDateTime().time(); 223 QTime neededSaveTime = QDateTime::currentDateTime().time();
224 mView->openCalendar( defaultFileName() ); 224 mView->openCalendar( defaultFileName() );
225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
226 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 226 qDebug("KO: Calendar loading time: %d ms",msNeeded );
227 227
228 if ( KOPrefs::instance()->mLanguageChanged ) { 228 if ( KOPrefs::instance()->mLanguageChanged ) {
229 KOPrefs::instance()->setCategoryDefaults(); 229 KOPrefs::instance()->setCategoryDefaults();
230 int count = mView->addCategories(); 230 int count = mView->addCategories();
231 KOPrefs::instance()->mLanguageChanged = false; 231 KOPrefs::instance()->mLanguageChanged = false;
232 } 232 }
233 processIncidenceSelection( 0 ); 233 processIncidenceSelection( 0 );
234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
235 SLOT( processIncidenceSelection( Incidence * ) ) ); 235 SLOT( processIncidenceSelection( Incidence * ) ) );
236 connect( mView, SIGNAL( modifiedChanged( bool ) ), 236 connect( mView, SIGNAL( modifiedChanged( bool ) ),
237 SLOT( slotModifiedChanged( bool ) ) ); 237 SLOT( slotModifiedChanged( bool ) ) );
238 238
239 239
240 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 240 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
241 mView->setModified( false ); 241 mView->setModified( false );
242 mBlockAtStartup = false; 242 mBlockAtStartup = false;
243 mView->setModified( false ); 243 mView->setModified( false );
244 setCentralWidget( mView ); 244 setCentralWidget( mView );
245 globalFlagBlockStartup = 0; 245 globalFlagBlockStartup = 0;
246 mView->show(); 246 mView->show();
247 delete splash; 247 delete splash;
248 if ( newFile ) 248 if ( newFile )
249 mView->updateConfig(); 249 mView->updateConfig();
250 // qApp->processEvents(); 250 // qApp->processEvents();
251 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 251 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
252 //fillSyncMenu(); 252 //fillSyncMenu();
253 253
254 254
255 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 255 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
256 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 256 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
257 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 257 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
258 mSyncManager->setDefaultFileName( defaultFileName()); 258 mSyncManager->setDefaultFileName( defaultFileName());
259 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 259 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
260 mSyncManager->fillSyncMenu(); 260 mSyncManager->fillSyncMenu();
261 261
262 262
263 263
264 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 264 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
265 if ( showWarning ) { 265 if ( showWarning ) {
266 KMessageBox::information( this, 266 KMessageBox::information( this,
267 "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"); 267 "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");
268 qApp->processEvents(); 268 qApp->processEvents();
269 mView->dialogManager()->showSyncOptions(); 269 mView->dialogManager()->showSyncOptions();
270 } 270 }
271 271
272 //US listen for result adressed from Ka/Pi 272 //US listen for result adressed from Ka/Pi
273#ifndef DESKTOP_VERSION 273#ifndef DESKTOP_VERSION
274 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 274 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
275#endif 275#endif
276 276
277} 277}
278MainWindow::~MainWindow() 278MainWindow::~MainWindow()
279{ 279{
280 //qDebug("MainWindow::~MainWindow() "); 280 //qDebug("MainWindow::~MainWindow() ");
281 //save toolbar location 281 //save toolbar location
282 delete mCalendar; 282 delete mCalendar;
283 delete mSyncManager; 283 delete mSyncManager;
284 284
285 285
286} 286}
287void MainWindow::showMaximized () 287void MainWindow::showMaximized ()
288{ 288{
289#ifndef DESKTOP_VERSION 289#ifndef DESKTOP_VERSION
290 if ( ! globalFlagBlockStartup ) 290 if ( ! globalFlagBlockStartup )
291 if ( mClosed ) 291 if ( mClosed )
292 mView->goToday(); 292 mView->goToday();
293#endif 293#endif
294 QWidget::showMaximized () ; 294 QWidget::showMaximized () ;
295 mClosed = false; 295 mClosed = false;
296} 296}
297void MainWindow::closeEvent( QCloseEvent* ce ) 297void MainWindow::closeEvent( QCloseEvent* ce )
298{ 298{
299 299
300 300
301 301
302 if ( ! KOPrefs::instance()->mAskForQuit ) { 302 if ( ! KOPrefs::instance()->mAskForQuit ) {
303 saveOnClose(); 303 saveOnClose();
304 mClosed = true; 304 mClosed = true;
305 ce->accept(); 305 ce->accept();
306 return; 306 return;
307 307
308 } 308 }
309 309
310 switch( QMessageBox::information( this, "KO/Pi", 310 switch( QMessageBox::information( this, "KO/Pi",
311 i18n("Do you really want\nto close KO/Pi?"), 311 i18n("Do you really want\nto close KO/Pi?"),
312 i18n("Close"), i18n("No"), 312 i18n("Close"), i18n("No"),
313 0, 0 ) ) { 313 0, 0 ) ) {
314 case 0: 314 case 0:
315 saveOnClose(); 315 saveOnClose();
316 mClosed = true; 316 mClosed = true;
317 ce->accept(); 317 ce->accept();
318 break; 318 break;
319 case 1: 319 case 1:
320 ce->ignore(); 320 ce->ignore();
321 break; 321 break;
322 case 2: 322 case 2:
323 323
324 default: 324 default:
325 break; 325 break;
326 } 326 }
327 327
328 328
329} 329}
330 330
331void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 331void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
332{ 332{
333 QDataStream stream( data, IO_ReadOnly ); 333 QDataStream stream( data, IO_ReadOnly );
334 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 334 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
335 //QString datamess; 335 //QString datamess;
336 //qDebug("message "); 336 //qDebug("message ");
337 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 337 qDebug("KO: QCOP message received: %s ", cmsg.data() );
338 338
339 if ( cmsg == "setDocument(QString)" ) { 339 if ( cmsg == "setDocument(QString)" ) {
340 QDataStream stream( data, IO_ReadOnly ); 340 QDataStream stream( data, IO_ReadOnly );
341 QString fileName; 341 QString fileName;
342 stream >> fileName; 342 stream >> fileName;
343 //qDebug("filename %s ", fileName.latin1()); 343 //qDebug("filename %s ", fileName.latin1());
344 showMaximized(); 344 showMaximized();
345 raise(); 345 raise();
346 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 346 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
347 mSyncManager->slotSyncMenu( 1002 ); 347 mSyncManager->slotSyncMenu( 1002 );
348 return; 348 return;
349 } 349 }
350 350
351 if ( cmsg == "-writeFile" ) { 351 if ( cmsg == "-writeFile" ) {
352 // I made from the "-writeFile" an "-writeAlarm" 352 // I made from the "-writeFile" an "-writeAlarm"
353 mView->viewManager()->showWhatsNextView(); 353 mView->viewManager()->showWhatsNextView();
354 mCalendar->checkAlarmForIncidence( 0, true); 354 mCalendar->checkAlarmForIncidence( 0, true);
355 showMaximized(); 355 showMaximized();
356 raise(); 356 raise();
357 return; 357 return;
358 358
359 } 359 }
360 if ( cmsg == "-writeFileSilent" ) { 360 if ( cmsg == "-writeFileSilent" ) {
361 // I made from the "-writeFile" an "-writeAlarm" 361 // I made from the "-writeFile" an "-writeAlarm"
362 // mView->viewManager()->showWhatsNextView(); 362 // mView->viewManager()->showWhatsNextView();
363 mCalendar->checkAlarmForIncidence( 0, true); 363 mCalendar->checkAlarmForIncidence( 0, true);
364 //showMaximized(); 364 //showMaximized();
365 //raise(); 365 //raise();
366 hide(); 366 hide();
367 return; 367 return;
368 } 368 }
369 if ( cmsg == "-newCountdown" ) { 369 if ( cmsg == "-newCountdown" ) {
370 qDebug("newCountdown "); 370 qDebug("newCountdown ");
371 371
372 } 372 }
373 QString msg ; 373 QString msg ;
374 QString allmsg = cmsg; 374 QString allmsg = cmsg;
375 while ( allmsg.length() > 0 ) { 375 while ( allmsg.length() > 0 ) {
376 int nextC = allmsg.find( "-", 1 ); 376 int nextC = allmsg.find( "-", 1 );
377 if ( nextC == -1 ) { 377 if ( nextC == -1 ) {
378 msg = allmsg; 378 msg = allmsg;
379 allmsg = ""; 379 allmsg = "";
380 } else{ 380 } else{
381 msg = allmsg.left( nextC ); 381 msg = allmsg.left( nextC );
382 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 382 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
383 } 383 }
384 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 384 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
385 if ( msg == "-newEvent" ) { 385 if ( msg == "-newEvent" ) {
386 mView->newEvent(); 386 mView->newEvent();
387 } 387 }
388 if ( msg == "-newTodo" ) { 388 if ( msg == "-newTodo" ) {
389 mView->newTodo(); 389 mView->newTodo();
390 390
391 } 391 }
392 if ( msg == "-showWN" ) { 392 if ( msg == "-showWN" ) {
393 mView->viewManager()->showWhatsNextView(); 393 mView->viewManager()->showWhatsNextView();
394 } 394 }
395 if ( msg == "-showTodo" ) { 395 if ( msg == "-showTodo" ) {
396 mView->viewManager()->showTodoView(); 396 mView->viewManager()->showTodoView();
397 } 397 }
398 if ( msg == "-showList" ) { 398 if ( msg == "-showList" ) {
399 mView->viewManager()->showListView(); 399 mView->viewManager()->showListView();
400 } 400 }
401 else if ( msg == "-showDay" ) { 401 else if ( msg == "-showDay" ) {
402 mView->viewManager()->showDayView(); 402 mView->viewManager()->showDayView();
403 } 403 }
404 else if ( msg == "-showWWeek" ) { 404 else if ( msg == "-showWWeek" ) {
405 mView->viewManager()->showWorkWeekView(); 405 mView->viewManager()->showWorkWeekView();
406 } 406 }
407 else if ( msg == "-ringSync" ) { 407 else if ( msg == "-ringSync" ) {
408 mSyncManager->multiSync( false ); 408 mSyncManager->multiSync( false );
409 } 409 }
410 else if ( msg == "-showWeek" ) { 410 else if ( msg == "-showWeek" ) {
411 mView->viewManager()->showWeekView(); 411 mView->viewManager()->showWeekView();
412 } 412 }
413 else if ( msg == "-showTodo" ) { 413 else if ( msg == "-showTodo" ) {
414 mView->viewManager()->showTodoView(); 414 mView->viewManager()->showTodoView();
415 } 415 }
416 else if ( msg == "-showJournal" ) { 416 else if ( msg == "-showJournal" ) {
417 mView->dateNavigator()->selectDates( 1 ); 417 mView->dateNavigator()->selectDates( 1 );
418 mView->dateNavigator()->selectToday(); 418 mView->dateNavigator()->selectToday();
419 mView->viewManager()->showJournalView(); 419 mView->viewManager()->showJournalView();
420 } 420 }
421 else if ( msg == "-showKO" ) { 421 else if ( msg == "-showKO" ) {
422 mView->viewManager()->showNextXView(); 422 mView->viewManager()->showNextXView();
423 } 423 }
424 else if ( msg == "-showWNext" || msg == "nextView()" ) { 424 else if ( msg == "-showWNext" || msg == "nextView()" ) {
425 mView->viewManager()->showWhatsNextView(); 425 mView->viewManager()->showWhatsNextView();
426 } 426 }
427 else if ( msg == "-showNextXView" ) { 427 else if ( msg == "-showNextXView" ) {
428 mView->viewManager()->showNextXView(); 428 mView->viewManager()->showNextXView();
429 } 429 }
430 430
431 431
432 } 432 }
433 433
434 showMaximized(); 434 showMaximized();
435 raise(); 435 raise();
436} 436}
437 437
438QPixmap MainWindow::loadPixmap( QString name ) 438QPixmap MainWindow::loadPixmap( QString name )
439{ 439{
440 return SmallIcon( name ); 440 return SmallIcon( name );
441 441
442} 442}
443void MainWindow::initActions() 443void MainWindow::initActions()
444{ 444{
445 //KOPrefs::instance()->mShowFullMenu 445 //KOPrefs::instance()->mShowFullMenu
446 iconToolBar->clear(); 446 iconToolBar->clear();
447 KOPrefs *p = KOPrefs::instance(); 447 KOPrefs *p = KOPrefs::instance();
448 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 448 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
449 449
450 QPopupMenu *viewMenu = new QPopupMenu( this ); 450 QPopupMenu *viewMenu = new QPopupMenu( this );
451 QPopupMenu *actionMenu = new QPopupMenu( this ); 451 QPopupMenu *actionMenu = new QPopupMenu( this );
452 QPopupMenu *importMenu = new QPopupMenu( this ); 452 QPopupMenu *importMenu = new QPopupMenu( this );
453 selectFilterMenu = new QPopupMenu( this ); 453 selectFilterMenu = new QPopupMenu( this );
454 selectFilterMenu->setCheckable( true ); 454 selectFilterMenu->setCheckable( true );
455 syncMenu = new QPopupMenu( this ); 455 syncMenu = new QPopupMenu( this );
456 configureAgendaMenu = new QPopupMenu( this ); 456 configureAgendaMenu = new QPopupMenu( this );
457 configureToolBarMenu = new QPopupMenu( this ); 457 configureToolBarMenu = new QPopupMenu( this );
458 QPopupMenu *helpMenu = new QPopupMenu( this ); 458 QPopupMenu *helpMenu = new QPopupMenu( this );
459 if ( KOPrefs::instance()->mShowFullMenu ) { 459 if ( KOPrefs::instance()->mShowFullMenu ) {
460 QMenuBar *menuBar1; 460 QMenuBar *menuBar1;
461 menuBar1 = menuBar(); 461 menuBar1 = menuBar();
462 menuBar1->insertItem( i18n("File"), importMenu ); 462 menuBar1->insertItem( i18n("File"), importMenu );
463 menuBar1->insertItem( i18n("View"), viewMenu ); 463 menuBar1->insertItem( i18n("View"), viewMenu );
464 menuBar1->insertItem( i18n("Actions"), actionMenu ); 464 menuBar1->insertItem( i18n("Actions"), actionMenu );
465 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 465 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
466 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 466 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
467 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 467 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
468 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 468 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
469 menuBar1->insertItem( i18n("Help"), helpMenu ); 469 menuBar1->insertItem( i18n("Help"), helpMenu );
470 } else { 470 } else {
471 QPEMenuBar *menuBar1; 471 QPEMenuBar *menuBar1;
472 menuBar1 = new QPEMenuBar( iconToolBar ); 472 menuBar1 = new QPEMenuBar( iconToolBar );
473 QPopupMenu *menuBar = new QPopupMenu( this ); 473 QPopupMenu *menuBar = new QPopupMenu( this );
474 menuBar1->insertItem( i18n("ME"), menuBar); 474 menuBar1->insertItem( i18n("ME"), menuBar);
475 menuBar->insertItem( i18n("File"), importMenu ); 475 menuBar->insertItem( i18n("File"), importMenu );
476 menuBar->insertItem( i18n("View"), viewMenu ); 476 menuBar->insertItem( i18n("View"), viewMenu );
477 menuBar->insertItem( i18n("Actions"), actionMenu ); 477 menuBar->insertItem( i18n("Actions"), actionMenu );
478 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 478 menuBar->insertItem( i18n("Synchronize"), syncMenu );
479 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 479 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
480 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 480 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
481 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 481 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
482 menuBar->insertItem( i18n("Help"), helpMenu ); 482 menuBar->insertItem( i18n("Help"), helpMenu );
483 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 483 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
484 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 484 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
485 } 485 }
486 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 486 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
487 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 487 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
488 488
489 // ****************** 489 // ******************
490 QAction *action; 490 QAction *action;
491 QIconSet icon; 491 QIconSet icon;
492 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 492 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
493 configureToolBarMenu->setCheckable( true ); 493 configureToolBarMenu->setCheckable( true );
494 494
495 QString pathString = ""; 495 QString pathString = "";
496 if ( !p->mToolBarMiniIcons ) { 496 if ( !p->mToolBarMiniIcons ) {
497 if ( QApplication::desktop()->width() < 480 ) 497 if ( QApplication::desktop()->width() < 480 )
498 pathString += "icons16/"; 498 pathString += "icons16/";
499 } else 499 } else
500 pathString += "iconsmini/"; 500 pathString += "iconsmini/";
501 configureAgendaMenu->setCheckable( true ); 501 configureAgendaMenu->setCheckable( true );
502 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 502 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
503 configureAgendaMenu->insertSeparator(); 503 configureAgendaMenu->insertSeparator();
504 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 504 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
505 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 505 configureAgendaMenu->insertItem(i18n("Small"), 6 );
506 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 506 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
507 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 507 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
508 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 508 configureAgendaMenu->insertItem(i18n("Large"), 12 );
509 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 509 configureAgendaMenu->insertItem(i18n("Big"), 14 );
510 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 510 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
511 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 511 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
512 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 512 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
513 513
514 icon = loadPixmap( pathString + "configure" ); 514 icon = loadPixmap( pathString + "configure" );
515 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 515 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
516 action->addTo( actionMenu ); 516 action->addTo( actionMenu );
517 connect( action, SIGNAL( activated() ), 517 connect( action, SIGNAL( activated() ),
518 mView, SLOT( edit_options() ) ); 518 mView, SLOT( edit_options() ) );
519 actionMenu->insertSeparator(); 519 actionMenu->insertSeparator();
520 icon = loadPixmap( pathString + "newevent" ); 520 icon = loadPixmap( pathString + "newevent" );
521 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 521 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
522 configureToolBarMenu->insertSeparator(); 522 configureToolBarMenu->insertSeparator();
523 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 523 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
524 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 524 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
525 ne_action->addTo( actionMenu ); 525 ne_action->addTo( actionMenu );
526 connect( ne_action, SIGNAL( activated() ), 526 connect( ne_action, SIGNAL( activated() ),
527 mView, SLOT( newEvent() ) ); 527 mView, SLOT( newEvent() ) );
528 icon = loadPixmap( pathString + "newtodo" ); 528 icon = loadPixmap( pathString + "newtodo" );
529 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 529 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
530 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 530 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
531 nt_action->addTo( actionMenu ); 531 nt_action->addTo( actionMenu );
532 connect( nt_action, SIGNAL( activated() ), 532 connect( nt_action, SIGNAL( activated() ),
533 mView, SLOT( newTodo() ) ); 533 mView, SLOT( newTodo() ) );
534 icon = loadPixmap( pathString + "navi" ); 534 icon = loadPixmap( pathString + "navi" );
535 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 535 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
536 action->addTo( viewMenu ); 536 action->addTo( viewMenu );
537 connect( action, SIGNAL( activated() ), 537 connect( action, SIGNAL( activated() ),
538 mView, SLOT( toggleDateNavigatorWidget() ) ); 538 mView, SLOT( toggleDateNavigatorWidget() ) );
539 icon = loadPixmap( pathString + "filter" ); 539 icon = loadPixmap( pathString + "filter" );
540 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 540 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
541 action->addTo( viewMenu ); 541 action->addTo( viewMenu );
542 connect( action, SIGNAL( activated() ), 542 connect( action, SIGNAL( activated() ),
543 mView, SLOT( toggleFilter() ) ); 543 mView, SLOT( toggleFilter() ) );
544 544
545 545
546 viewMenu->insertSeparator(); 546 viewMenu->insertSeparator();
547 icon = loadPixmap( pathString + "picker" ); 547 icon = loadPixmap( pathString + "picker" );
548 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 548 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
549 action->addTo( viewMenu ); 549 action->addTo( viewMenu );
550 connect( action, SIGNAL( activated() ), 550 connect( action, SIGNAL( activated() ),
551 mView, SLOT( showDatePicker() ) ); 551 mView, SLOT( showDatePicker() ) );
552 action->addTo( iconToolBar ); 552 action->addTo( iconToolBar );
553 viewMenu->insertSeparator(); 553 viewMenu->insertSeparator();
554 icon = loadPixmap( pathString + "list" ); 554 icon = loadPixmap( pathString + "list" );
555 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 555 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
556 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 556 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
557 showlist_action->addTo( viewMenu ); 557 showlist_action->addTo( viewMenu );
558 connect( showlist_action, SIGNAL( activated() ), 558 connect( showlist_action, SIGNAL( activated() ),
559 mView->viewManager(), SLOT( showListView() ) ); 559 mView->viewManager(), SLOT( showListView() ) );
560 560
561 561
562 icon = loadPixmap( pathString + "day" ); 562 icon = loadPixmap( pathString + "day" );
563 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 563 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
564 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 564 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
565 day1_action->addTo( viewMenu ); 565 day1_action->addTo( viewMenu );
566 // action->addTo( toolBar ); 566 // action->addTo( toolBar );
567 connect( day1_action, SIGNAL( activated() ), 567 connect( day1_action, SIGNAL( activated() ),
568 mView->viewManager(), SLOT( showDayView() ) ); 568 mView->viewManager(), SLOT( showDayView() ) );
569 569
570 icon = loadPixmap( pathString + "workweek" ); 570 icon = loadPixmap( pathString + "workweek" );
571 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 571 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
572 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 572 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
573 day5_action->addTo( viewMenu ); 573 day5_action->addTo( viewMenu );
574 connect( day5_action, SIGNAL( activated() ), 574 connect( day5_action, SIGNAL( activated() ),
575 mView->viewManager(), SLOT( showWorkWeekView() ) ); 575 mView->viewManager(), SLOT( showWorkWeekView() ) );
576 576
577 icon = loadPixmap( pathString + "week" ); 577 icon = loadPixmap( pathString + "week" );
578 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 578 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
579 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 579 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
580 day7_action->addTo( viewMenu ); 580 day7_action->addTo( viewMenu );
581 connect( day7_action, SIGNAL( activated() ), 581 connect( day7_action, SIGNAL( activated() ),
582 mView->viewManager(), SLOT( showWeekView() ) ); 582 mView->viewManager(), SLOT( showWeekView() ) );
583 583
584 icon = loadPixmap( pathString + "month" ); 584 icon = loadPixmap( pathString + "month" );
585 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 585 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
586 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 586 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
587 month_action->addTo( viewMenu ); 587 month_action->addTo( viewMenu );
588 connect( month_action, SIGNAL( activated() ), 588 connect( month_action, SIGNAL( activated() ),
589 mView->viewManager(), SLOT( showMonthView() ) ); 589 mView->viewManager(), SLOT( showMonthView() ) );
590 590
591 icon = loadPixmap( pathString + "todo" ); 591 icon = loadPixmap( pathString + "todo" );
592 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 592 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
593 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 593 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
594 todoview_action->addTo( viewMenu ); 594 todoview_action->addTo( viewMenu );
595 connect( todoview_action, SIGNAL( activated() ), 595 connect( todoview_action, SIGNAL( activated() ),
596 mView->viewManager(), SLOT( showTodoView() ) ); 596 mView->viewManager(), SLOT( showTodoView() ) );
597 597
598 icon = loadPixmap( pathString + "journal" ); 598 icon = loadPixmap( pathString + "journal" );
599 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 599 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
600 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 600 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
601 viewjournal_action->addTo( viewMenu ); 601 viewjournal_action->addTo( viewMenu );
602 connect( viewjournal_action, SIGNAL( activated() ), 602 connect( viewjournal_action, SIGNAL( activated() ),
603 mView->viewManager(), SLOT( showJournalView() ) ); 603 mView->viewManager(), SLOT( showJournalView() ) );
604 604
605 icon = loadPixmap( pathString + "xdays" ); 605 icon = loadPixmap( pathString + "xdays" );
606 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 606 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
607 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 607 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
608 xdays_action->addTo( viewMenu ); 608 xdays_action->addTo( viewMenu );
609 connect( xdays_action, SIGNAL( activated() ), 609 connect( xdays_action, SIGNAL( activated() ),
610 mView->viewManager(), SLOT( showNextXView() ) ); 610 mView->viewManager(), SLOT( showNextXView() ) );
611 611
612 icon = loadPixmap( pathString + "whatsnext" ); 612 icon = loadPixmap( pathString + "whatsnext" );
613 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 613 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
614 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 614 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
615 whatsnext_action->addTo( viewMenu ); 615 whatsnext_action->addTo( viewMenu );
616 connect( whatsnext_action, SIGNAL( activated() ), 616 connect( whatsnext_action, SIGNAL( activated() ),
617 mView->viewManager(), SLOT( showWhatsNextView() ) ); 617 mView->viewManager(), SLOT( showWhatsNextView() ) );
618 618
619#if 0 619#if 0
620 action = new QAction( "view_timespan", "Time Span", 0, this ); 620 action = new QAction( "view_timespan", "Time Span", 0, this );
621 action->addTo( viewMenu ); 621 action->addTo( viewMenu );
622 connect( action, SIGNAL( activated() ), 622 connect( action, SIGNAL( activated() ),
623 mView->viewManager(), SLOT( showTimeSpanView() ) ); 623 mView->viewManager(), SLOT( showTimeSpanView() ) );
624#endif 624#endif
625 625
626 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 626 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
627 this ); 627 this );
628 mNewSubTodoAction->addTo( actionMenu ); 628 mNewSubTodoAction->addTo( actionMenu );
629 connect( mNewSubTodoAction, SIGNAL( activated() ), 629 connect( mNewSubTodoAction, SIGNAL( activated() ),
630 mView, SLOT( newSubTodo() ) ); 630 mView, SLOT( newSubTodo() ) );
631 631
632 actionMenu->insertSeparator(); 632 actionMenu->insertSeparator();
633 633
634 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 634 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
635 mShowAction->addTo( actionMenu ); 635 mShowAction->addTo( actionMenu );
636 connect( mShowAction, SIGNAL( activated() ), 636 connect( mShowAction, SIGNAL( activated() ),
637 mView, SLOT( showIncidence() ) ); 637 mView, SLOT( showIncidence() ) );
638 638
639 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 639 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
640 mEditAction->addTo( actionMenu ); 640 mEditAction->addTo( actionMenu );
641 connect( mEditAction, SIGNAL( activated() ), 641 connect( mEditAction, SIGNAL( activated() ),
642 mView, SLOT( editIncidence() ) ); 642 mView, SLOT( editIncidence() ) );
643 643
644 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 644 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
645 mDeleteAction->addTo( actionMenu ); 645 mDeleteAction->addTo( actionMenu );
646 connect( mDeleteAction, SIGNAL( activated() ), 646 connect( mDeleteAction, SIGNAL( activated() ),
647 mView, SLOT( deleteIncidence() ) ); 647 mView, SLOT( deleteIncidence() ) );
648 648
649 649
650 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 650 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
651 mCloneAction->addTo( actionMenu ); 651 mCloneAction->addTo( actionMenu );
652 connect( mCloneAction, SIGNAL( activated() ), 652 connect( mCloneAction, SIGNAL( activated() ),
653 mView, SLOT( cloneIncidence() ) ); 653 mView, SLOT( cloneIncidence() ) );
654 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 654 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
655 mMoveAction->addTo( actionMenu ); 655 mMoveAction->addTo( actionMenu );
656 connect( mMoveAction, SIGNAL( activated() ), 656 connect( mMoveAction, SIGNAL( activated() ),
657 mView, SLOT( moveIncidence() ) ); 657 mView, SLOT( moveIncidence() ) );
658 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 658 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
659 mBeamAction->addTo( actionMenu ); 659 mBeamAction->addTo( actionMenu );
660 connect( mBeamAction, SIGNAL( activated() ), 660 connect( mBeamAction, SIGNAL( activated() ),
661 mView, SLOT( beamIncidence() ) ); 661 mView, SLOT( beamIncidence() ) );
662 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 662 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
663 mCancelAction->addTo( actionMenu ); 663 mCancelAction->addTo( actionMenu );
664 connect( mCancelAction, SIGNAL( activated() ), 664 connect( mCancelAction, SIGNAL( activated() ),
665 mView, SLOT( toggleCancelIncidence() ) ); 665 mView, SLOT( toggleCancelIncidence() ) );
666 666
667 actionMenu->insertSeparator(); 667 actionMenu->insertSeparator();
668 668
669 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 669 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
670 this ); 670 this );
671 action->addTo( actionMenu ); 671 action->addTo( actionMenu );
672 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 672 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
673 673
674 icon = loadPixmap( pathString + "search" ); 674 icon = loadPixmap( pathString + "search" );
675 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 675 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
676 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 676 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
677 search_action->addTo( actionMenu ); 677 search_action->addTo( actionMenu );
678 connect( search_action, SIGNAL( activated() ), 678 connect( search_action, SIGNAL( activated() ),
679 mView->dialogManager(), SLOT( showSearchDialog() ) ); 679 mView->dialogManager(), SLOT( showSearchDialog() ) );
680 680
681 icon = loadPixmap( pathString + "today" ); 681 icon = loadPixmap( pathString + "today" );
682 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 682 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
683 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 683 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
684 today_action->addTo( actionMenu ); 684 today_action->addTo( actionMenu );
685 connect( today_action, SIGNAL( activated() ), 685 connect( today_action, SIGNAL( activated() ),
686 mView, SLOT( goToday() ) ); 686 mView, SLOT( goToday() ) );
687 687
688 if ( KOPrefs::instance()->mShowFullMenu ) { 688 if ( KOPrefs::instance()->mShowFullMenu ) {
689 actionMenu->insertSeparator(); 689 actionMenu->insertSeparator();
690 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 690 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
691 691
692 } 692 }
693 // actionMenu->insertSeparator(); 693 // actionMenu->insertSeparator();
694 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 694 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
695 this ); 695 this );
696 action->addTo( importMenu ); 696 action->addTo( importMenu );
697 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 697 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
698 action = new QAction( "import_quick", i18n("Import last file"), 0, 698 action = new QAction( "import_quick", i18n("Import last file"), 0,
699 this ); 699 this );
700 action->addTo( importMenu ); 700 action->addTo( importMenu );
701 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 701 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
702 importMenu->insertSeparator(); 702 importMenu->insertSeparator();
703 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 703 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
704 this ); 704 this );
705 action->addTo( importMenu ); 705 action->addTo( importMenu );
706 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 706 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
707#ifndef DESKTOP_VERSION 707#ifndef DESKTOP_VERSION
708 importMenu->insertSeparator(); 708 importMenu->insertSeparator();
709 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 709 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
710 this ); 710 this );
711 action->addTo( importMenu ); 711 action->addTo( importMenu );
712 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 712 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
713#else 713#else
714#ifdef _WIN32_ 714#ifdef _WIN32_
715 importMenu->insertSeparator(); 715 importMenu->insertSeparator();
716 action = new QAction( "import_ol", i18n("Import from OL"), 0, 716 action = new QAction( "import_ol", i18n("Import from OL"), 0,
717 this ); 717 this );
718 action->addTo( importMenu ); 718 action->addTo( importMenu );
719 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 719 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
720#endif 720#endif
721#endif 721#endif
722 722
723 importMenu->insertSeparator(); 723 importMenu->insertSeparator();
724 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 724 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
725 this ); 725 this );
726 action->addTo( importMenu ); 726 action->addTo( importMenu );
727 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 727 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
728 728
729 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 729 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
730 this ); 730 this );
731 action->addTo( importMenu ); 731 action->addTo( importMenu );
732 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 732 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
733 733
734 importMenu->insertSeparator(); 734 importMenu->insertSeparator();
735 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 735 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
736 this ); 736 this );
737 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 737 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
738 738
739 739
740 //LR 740 //LR
741 QPopupMenu *ex2phone = new QPopupMenu( this ); 741 QPopupMenu *ex2phone = new QPopupMenu( this );
742 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 742 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
743 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 743 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
744 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 744 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
745 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 745 importMenu->insertItem( i18n("Export to phone"), ex2phone );
746 746
747 importMenu->insertSeparator(); 747 importMenu->insertSeparator();
748 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 748 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
749 this ); 749 this );
750 action->addTo( importMenu ); 750 action->addTo( importMenu );
751 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 751 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
752#ifndef DESKTOP_VERSION 752#ifndef DESKTOP_VERSION
753 importMenu->insertSeparator(); 753 importMenu->insertSeparator();
754 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 754 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
755 this ); 755 this );
756 action->addTo( importMenu ); 756 action->addTo( importMenu );
757 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 757 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
758 758
759 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 759 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
760 this ); 760 this );
761 action->addTo( importMenu ); 761 action->addTo( importMenu );
762 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 762 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
763#else 763#else
764 importMenu->insertSeparator(); 764 importMenu->insertSeparator();
765 icon = loadPixmap( pathString + "print" ); 765 icon = loadPixmap( pathString + "print" );
766 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 766 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
767 action->addTo( importMenu ); 767 action->addTo( importMenu );
768 connect( action, SIGNAL( activated() ), 768 connect( action, SIGNAL( activated() ),
769 this, SLOT( printCal() ) ); 769 this, SLOT( printCal() ) );
770 770
771 icon = loadPixmap( pathString + "print" ); 771 icon = loadPixmap( pathString + "print" );
772 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 772 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
773 action->addTo( importMenu ); 773 action->addTo( importMenu );
774 connect( action, SIGNAL( activated() ), 774 connect( action, SIGNAL( activated() ),
775 this, SLOT( printSel() ) ); 775 this, SLOT( printSel() ) );
776#endif 776#endif
777 importMenu->insertSeparator(); 777 importMenu->insertSeparator();
778 action = new QAction( "beam all", i18n("Save"), 0, 778 action = new QAction( "beam all", i18n("Save"), 0,
779 this ); 779 this );
780 action->addTo( importMenu ); 780 action->addTo( importMenu );
781 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 781 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
782 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 782 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
783 this ); 783 this );
784 action->addTo( importMenu ); 784 action->addTo( importMenu );
785 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 785 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
786 786
787 //menuBar->insertItem( "Configure",configureMenu ); 787 //menuBar->insertItem( "Configure",configureMenu );
788 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 788 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
789 icon = loadPixmap( "korganizer/korganizer" ); 789 icon = loadPixmap( "korganizer/korganizer" );
790 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 790 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
791 action->addTo( helpMenu ); 791 action->addTo( helpMenu );
792 connect( action, SIGNAL( activated() ), 792 connect( action, SIGNAL( activated() ),
793 SLOT( keyBindings() ) ); 793 SLOT( keyBindings() ) );
794 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 794 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
795 action->addTo( helpMenu ); 795 action->addTo( helpMenu );
796 connect( action, SIGNAL( activated() ), 796 connect( action, SIGNAL( activated() ),
797 SLOT( features() ) ); 797 SLOT( features() ) );
798 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 798 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
799 action->addTo( helpMenu ); 799 action->addTo( helpMenu );
800 connect( action, SIGNAL( activated() ), 800 connect( action, SIGNAL( activated() ),
801 SLOT( aboutAutoSaving() ) ); 801 SLOT( aboutAutoSaving() ) );
802 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 802 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
803 action->addTo( helpMenu ); 803 action->addTo( helpMenu );
804 connect( action, SIGNAL( activated() ), 804 connect( action, SIGNAL( activated() ),
805 SLOT( aboutKnownBugs() ) ); 805 SLOT( aboutKnownBugs() ) );
806 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 806 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
807 action->addTo( helpMenu ); 807 action->addTo( helpMenu );
808 connect( action, SIGNAL( activated() ), 808 connect( action, SIGNAL( activated() ),
809 SLOT( usertrans() ) ); 809 SLOT( usertrans() ) );
810 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 810 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
811 action->addTo( helpMenu ); 811 action->addTo( helpMenu );
812 connect( action, SIGNAL( activated() ), 812 connect( action, SIGNAL( activated() ),
813 SLOT( synchowto() ) ); 813 SLOT( synchowto() ) );
814 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 814 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
815 action->addTo( helpMenu ); 815 action->addTo( helpMenu );
816 connect( action, SIGNAL( activated() ), 816 connect( action, SIGNAL( activated() ),
817 SLOT( whatsNew() ) ); 817 SLOT( whatsNew() ) );
818 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 818 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
819 action->addTo( helpMenu ); 819 action->addTo( helpMenu );
820 connect( action, SIGNAL( activated() ), 820 connect( action, SIGNAL( activated() ),
821 SLOT( faq() ) ); 821 SLOT( faq() ) );
822 822
823 823
824 action = new QAction( "about", i18n("About..."), 0, this ); 824 action = new QAction( "about", i18n("About..."), 0, this );
825 action->addTo( helpMenu ); 825 action->addTo( helpMenu );
826 connect( action, SIGNAL( activated() ), 826 connect( action, SIGNAL( activated() ),
827 SLOT( about() ) ); 827 SLOT( about() ) );
828 action = new QAction( "licence", i18n("Licence..."), 0, this ); 828 action = new QAction( "licence", i18n("Licence..."), 0, this );
829 action->addTo( helpMenu ); 829 action->addTo( helpMenu );
830 connect( action, SIGNAL( activated() ), 830 connect( action, SIGNAL( activated() ),
831 SLOT( licence() ) ); 831 SLOT( licence() ) );
832 //menuBar->insertSeparator(); 832 //menuBar->insertSeparator();
833 833
834 // ****************************************************** 834 // ******************************************************
835 // menubar icons 835 // menubar icons
836 836
837 837
838 iconToolBar->setHorizontalStretchable (true ); 838 iconToolBar->setHorizontalStretchable (true );
839 //menuBar->insertItem( iconToolBar ); 839 //menuBar->insertItem( iconToolBar );
840 //xdays_action 840 //xdays_action
841 if (p-> mShowIconNewEvent) 841 if (p-> mShowIconNewEvent)
842 ne_action->addTo( iconToolBar ); 842 ne_action->addTo( iconToolBar );
843 if (p->mShowIconNewTodo ) 843 if (p->mShowIconNewTodo )
844 nt_action->addTo( iconToolBar ); 844 nt_action->addTo( iconToolBar );
845 if (p-> mShowIconSearch) 845 if (p-> mShowIconSearch)
846 search_action->addTo( iconToolBar ); 846 search_action->addTo( iconToolBar );
847 if (p-> mShowIconNext) 847 if (p-> mShowIconNext)
848 whatsnext_action->addTo( iconToolBar ); 848 whatsnext_action->addTo( iconToolBar );
849 if (p-> mShowIconNextDays) 849 if (p-> mShowIconNextDays)
850 xdays_action->addTo( iconToolBar ); 850 xdays_action->addTo( iconToolBar );
851 if (p-> mShowIconList) 851 if (p-> mShowIconList)
852 showlist_action->addTo( iconToolBar ); 852 showlist_action->addTo( iconToolBar );
853 if (p-> mShowIconDay1) 853 if (p-> mShowIconDay1)
854 day1_action->addTo( iconToolBar ); 854 day1_action->addTo( iconToolBar );
855 if (p-> mShowIconDay5) 855 if (p-> mShowIconDay5)
856 day5_action->addTo( iconToolBar ); 856 day5_action->addTo( iconToolBar );
857 if (p-> mShowIconDay7) 857 if (p-> mShowIconDay7)
858 day7_action->addTo( iconToolBar ); 858 day7_action->addTo( iconToolBar );
859 if (p-> mShowIconMonth) 859 if (p-> mShowIconMonth)
860 month_action->addTo( iconToolBar ); 860 month_action->addTo( iconToolBar );
861 if (p-> mShowIconTodoview) 861 if (p-> mShowIconTodoview)
862 todoview_action->addTo( iconToolBar ); 862 todoview_action->addTo( iconToolBar );
863 if (p-> mShowIconJournal) 863 if (p-> mShowIconJournal)
864 viewjournal_action->addTo( iconToolBar ); 864 viewjournal_action->addTo( iconToolBar );
865 icon = loadPixmap( pathString + "2leftarrowB" ); 865 icon = loadPixmap( pathString + "2leftarrowB" );
866 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 866 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
867 if (p-> mShowIconBackFast) { 867 if (p-> mShowIconBackFast) {
868 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 868 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
869 connect( action, SIGNAL( activated() ), 869 connect( action, SIGNAL( activated() ),
870 mView, SLOT( goPreviousMonth() ) ); 870 mView, SLOT( goPreviousMonth() ) );
871 action->addTo( iconToolBar ); 871 action->addTo( iconToolBar );
872 } 872 }
873 icon = loadPixmap( pathString + "1leftarrowB" ); 873 icon = loadPixmap( pathString + "1leftarrowB" );
874 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 874 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
875 if (p-> mShowIconBack) { 875 if (p-> mShowIconBack) {
876 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 876 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
877 connect( action, SIGNAL( activated() ), 877 connect( action, SIGNAL( activated() ),
878 mView, SLOT( goPrevious() ) ); 878 mView, SLOT( goPrevious() ) );
879 action->addTo( iconToolBar ); 879 action->addTo( iconToolBar );
880 } 880 }
881 if (p-> mShowIconToday) 881 if (p-> mShowIconToday)
882 today_action->addTo( iconToolBar ); 882 today_action->addTo( iconToolBar );
883 icon = loadPixmap( pathString + "1rightarrowB" ); 883 icon = loadPixmap( pathString + "1rightarrowB" );
884 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 884 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
885 if (p-> mShowIconForward) { 885 if (p-> mShowIconForward) {
886 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 886 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
887 connect( action, SIGNAL( activated() ), 887 connect( action, SIGNAL( activated() ),
888 mView, SLOT( goNext() ) ); 888 mView, SLOT( goNext() ) );
889 action->addTo( iconToolBar ); 889 action->addTo( iconToolBar );
890 } 890 }
891 icon = loadPixmap( pathString + "2rightarrowB" ); 891 icon = loadPixmap( pathString + "2rightarrowB" );
892 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 892 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
893 if (p-> mShowIconForwardFast) { 893 if (p-> mShowIconForwardFast) {
894 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 894 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
895 connect( action, SIGNAL( activated() ), 895 connect( action, SIGNAL( activated() ),
896 mView, SLOT( goNextMonth() ) ); 896 mView, SLOT( goNextMonth() ) );
897 action->addTo( iconToolBar ); 897 action->addTo( iconToolBar );
898 } 898 }
899 899
900 900
901 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 901 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
902 902
903 if (p-> mShowIconNewEvent) 903 if (p-> mShowIconNewEvent)
904 configureToolBarMenu->setItemChecked( 10, true ); 904 configureToolBarMenu->setItemChecked( 10, true );
905 if (p->mShowIconNewTodo ) 905 if (p->mShowIconNewTodo )
906 configureToolBarMenu->setItemChecked( 20, true ); 906 configureToolBarMenu->setItemChecked( 20, true );
907 if (p-> mShowIconSearch) 907 if (p-> mShowIconSearch)
908 configureToolBarMenu->setItemChecked( 120, true ); 908 configureToolBarMenu->setItemChecked( 120, true );
909 if (p-> mShowIconList) 909 if (p-> mShowIconList)
910 configureToolBarMenu->setItemChecked( 30, true ); 910 configureToolBarMenu->setItemChecked( 30, true );
911 if (p-> mShowIconDay1) 911 if (p-> mShowIconDay1)
912 configureToolBarMenu->setItemChecked( 40, true ); 912 configureToolBarMenu->setItemChecked( 40, true );
913 if (p-> mShowIconDay5) 913 if (p-> mShowIconDay5)
914 configureToolBarMenu->setItemChecked( 50, true ); 914 configureToolBarMenu->setItemChecked( 50, true );
915 if (p-> mShowIconDay7) 915 if (p-> mShowIconDay7)
916 configureToolBarMenu->setItemChecked( 60, true ); 916 configureToolBarMenu->setItemChecked( 60, true );
917 if (p-> mShowIconMonth) 917 if (p-> mShowIconMonth)
918 configureToolBarMenu->setItemChecked( 70, true ); 918 configureToolBarMenu->setItemChecked( 70, true );
919 if (p-> mShowIconTodoview) 919 if (p-> mShowIconTodoview)
920 configureToolBarMenu->setItemChecked( 80, true ); 920 configureToolBarMenu->setItemChecked( 80, true );
921 if (p-> mShowIconBackFast) 921 if (p-> mShowIconBackFast)
922 configureToolBarMenu->setItemChecked( 200, true ); 922 configureToolBarMenu->setItemChecked( 200, true );
923 if (p-> mShowIconBack) 923 if (p-> mShowIconBack)
924 configureToolBarMenu->setItemChecked( 210, true ); 924 configureToolBarMenu->setItemChecked( 210, true );
925 if (p-> mShowIconToday) 925 if (p-> mShowIconToday)
926 configureToolBarMenu->setItemChecked( 130, true ); 926 configureToolBarMenu->setItemChecked( 130, true );
927 if (p-> mShowIconForward) 927 if (p-> mShowIconForward)
928 configureToolBarMenu->setItemChecked( 220, true ); 928 configureToolBarMenu->setItemChecked( 220, true );
929 if (p-> mShowIconForwardFast) 929 if (p-> mShowIconForwardFast)
930 configureToolBarMenu->setItemChecked( 230, true ); 930 configureToolBarMenu->setItemChecked( 230, true );
931 if (p-> mShowIconNextDays) 931 if (p-> mShowIconNextDays)
932 configureToolBarMenu->setItemChecked( 100, true ); 932 configureToolBarMenu->setItemChecked( 100, true );
933 if (p-> mShowIconNext) 933 if (p-> mShowIconNext)
934 configureToolBarMenu->setItemChecked( 110, true ); 934 configureToolBarMenu->setItemChecked( 110, true );
935 if (p-> mShowIconJournal) 935 if (p-> mShowIconJournal)
936 configureToolBarMenu->setItemChecked( 90, true ); 936 configureToolBarMenu->setItemChecked( 90, true );
937 if (p-> mShowIconWhatsThis) 937 if (p-> mShowIconWhatsThis)
938 configureToolBarMenu->setItemChecked( 300, true ); 938 configureToolBarMenu->setItemChecked( 300, true );
939 939
940 QLabel* dummy = new QLabel( iconToolBar ); 940 QLabel* dummy = new QLabel( iconToolBar );
941 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 941 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
942 if (!p-> mShowIconStretch) 942 if (!p-> mShowIconStretch)
943 iconToolBar->setStretchableWidget ( dummy ) ; 943 iconToolBar->setStretchableWidget ( dummy ) ;
944 else 944 else
945 configureToolBarMenu->setItemChecked( 5, true ); 945 configureToolBarMenu->setItemChecked( 5, true );
946 if (p-> mShowIconWhatsThis) 946 if (p-> mShowIconWhatsThis)
947 QWhatsThis::whatsThisButton ( iconToolBar ); 947 QWhatsThis::whatsThisButton ( iconToolBar );
948 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 948 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
949 configureAgenda( p->mHourSize ); 949 configureAgenda( p->mHourSize );
950 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 950 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
951} 951}
952 952
953void MainWindow::exportToPhone( int mode ) 953void MainWindow::exportToPhone( int mode )
954{ 954{
955 955
956 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 956 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
957 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 957 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
958 KOex2phonePrefs ex2phone; 958 KOex2phonePrefs ex2phone;
959 959
960 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 960 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
961 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 961 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
962 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 962 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
963 if ( mode == 1 ) 963 if ( mode == 1 )
964 ex2phone.setCaption(i18n("Export complete calendar")); 964 ex2phone.setCaption(i18n("Export complete calendar"));
965 if ( mode == 2 ) 965 if ( mode == 2 )
966 ex2phone.setCaption(i18n("Export filtered calendar")); 966 ex2phone.setCaption(i18n("Export filtered calendar"));
967 967
968 if ( !ex2phone.exec() ) { 968 if ( !ex2phone.exec() ) {
969 return; 969 return;
970 } 970 }
971 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 971 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
972 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 972 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
973 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 973 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
974 974
975 int inFuture = 0; 975 int inFuture = 0;
976 if ( ex2phone.mWriteBackFuture->isChecked() ) 976 if ( ex2phone.mWriteBackFuture->isChecked() )
977 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 977 inFuture = ex2phone.mWriteBackFutureWeeks->value();
978 QPtrList<Incidence> delSel; 978 QPtrList<Incidence> delSel;
979 if ( mode == 1 ) 979 if ( mode == 1 )
980 delSel = mCalendar->rawIncidences(); 980 delSel = mCalendar->rawIncidences();
981 if ( mode == 2 ) 981 if ( mode == 2 )
982 delSel = mCalendar->incidences(); 982 delSel = mCalendar->incidences();
983 CalendarLocal* cal = new CalendarLocal(); 983 CalendarLocal* cal = new CalendarLocal();
984 cal->setLocalTime(); 984 cal->setLocalTime();
985 Incidence *incidence = delSel.first(); 985 Incidence *incidence = delSel.first();
986 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 986 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
987 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 987 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
988 while ( incidence ) { 988 while ( incidence ) {
989 if ( incidence->type() != "Journal" ) { 989 if ( incidence->type() != "Journal" ) {
990 bool add = true; 990 bool add = true;
991 if ( inFuture ) { 991 if ( inFuture ) {
992 QDateTime dt; 992 QDateTime dt;
993 if ( incidence->type() == "Todo" ) { 993 if ( incidence->type() == "Todo" ) {
994 Todo * t = (Todo*)incidence; 994 Todo * t = (Todo*)incidence;
995 if ( t->hasDueDate() ) 995 if ( t->hasDueDate() )
996 dt = t->dtDue(); 996 dt = t->dtDue();
997 else 997 else
998 dt = cur.addSecs( 62 ); 998 dt = cur.addSecs( 62 );
999 } 999 }
1000 else { 1000 else {
1001 bool ok; 1001 bool ok;
1002 dt = incidence->getNextOccurence( cur, &ok ); 1002 dt = incidence->getNextOccurence( cur, &ok );
1003 if ( !ok ) 1003 if ( !ok )
1004 dt = cur.addSecs( -62 ); 1004 dt = cur.addSecs( -62 );
1005 } 1005 }
1006 if ( dt < cur || dt > end ) { 1006 if ( dt < cur || dt > end ) {
1007 add = false; 1007 add = false;
1008 } 1008 }
1009 } 1009 }
1010 if ( add ) { 1010 if ( add ) {
1011 Incidence *in = incidence->clone(); 1011 Incidence *in = incidence->clone();
1012 cal->addIncidence( in ); 1012 cal->addIncidence( in );
1013 } 1013 }
1014 } 1014 }
1015 incidence = delSel.next(); 1015 incidence = delSel.next();
1016 } 1016 }
1017 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1017 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1018 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1018 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1019 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1019 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1020 1020
1021 setCaption( i18n("Writing to phone...")); 1021 setCaption( i18n("Writing to phone..."));
1022 if ( PhoneFormat::writeToPhone( cal ) ) 1022 if ( PhoneFormat::writeToPhone( cal ) )
1023 setCaption( i18n("Export to phone successful!")); 1023 setCaption( i18n("Export to phone successful!"));
1024 else 1024 else
1025 setCaption( i18n("Error exporting to phone!")); 1025 setCaption( i18n("Error exporting to phone!"));
1026 delete cal; 1026 delete cal;
1027} 1027}
1028 1028
1029 1029
1030void MainWindow::setDefaultPreferences() 1030void MainWindow::setDefaultPreferences()
1031{ 1031{
1032 KOPrefs *p = KOPrefs::instance(); 1032 KOPrefs *p = KOPrefs::instance();
1033 1033
1034 p->mCompactDialogs = true; 1034 p->mCompactDialogs = true;
1035 p->mConfirm = true; 1035 p->mConfirm = true;
1036 // p->mEnableQuickTodo = false; 1036 // p->mEnableQuickTodo = false;
1037 1037
1038} 1038}
1039 1039
1040QString MainWindow::resourcePath() 1040QString MainWindow::resourcePath()
1041{ 1041{
1042 return KGlobal::iconLoader()->iconPath(); 1042 return KGlobal::iconLoader()->iconPath();
1043} 1043}
1044 1044
1045void MainWindow::displayText( QString text ,QString cap ) 1045void MainWindow::displayText( QString text ,QString cap )
1046{ 1046{
1047 QDialog dia( this, "name", true ); ; 1047 QDialog dia( this, "name", true ); ;
1048 dia.setCaption( cap ); 1048 dia.setCaption( cap );
1049 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1049 QVBoxLayout* lay = new QVBoxLayout( &dia );
1050 lay->setSpacing( 3 ); 1050 lay->setSpacing( 3 );
1051 lay->setMargin( 3 ); 1051 lay->setMargin( 3 );
1052 QTextBrowser tb ( &dia ); 1052 QTextBrowser tb ( &dia );
1053 lay->addWidget( &tb ); 1053 lay->addWidget( &tb );
1054 tb.setText( text ); 1054 tb.setText( text );
1055#ifdef DESKTOP_VERSION 1055#ifdef DESKTOP_VERSION
1056 dia.resize( 640, 480); 1056 dia.resize( 640, 480);
1057#else 1057#else
1058 dia.showMaximized(); 1058 dia.showMaximized();
1059#endif 1059#endif
1060 dia.exec(); 1060 dia.exec();
1061} 1061}
1062void MainWindow::displayFile( QString fn, QString cap ) 1062void MainWindow::displayFile( QString fn, QString cap )
1063{ 1063{
1064 QString fileName = resourcePath() + fn; 1064 QString fileName = resourcePath() + fn;
1065 QString text; 1065 QString text;
1066 QFile file( fileName ); 1066 QFile file( fileName );
1067 if (!file.open( IO_ReadOnly ) ) { 1067 if (!file.open( IO_ReadOnly ) ) {
1068 return ; 1068 return ;
1069 1069
1070 } 1070 }
1071 QTextStream ts( &file ); 1071 QTextStream ts( &file );
1072 text = ts.read(); 1072 text = ts.read();
1073 file.close(); 1073 file.close();
1074 displayText( text, cap); 1074 displayText( text, cap);
1075} 1075}
1076void MainWindow::features() 1076void MainWindow::features()
1077{ 1077{
1078 1078
1079 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1079 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1080} 1080}
1081 1081
1082void MainWindow::usertrans() 1082void MainWindow::usertrans()
1083{ 1083{
1084 1084
1085 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1085 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1086} 1086}
1087 1087
1088void MainWindow::synchowto() 1088void MainWindow::synchowto()
1089{ 1089{
1090 1090
1091 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1091 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1092} 1092}
1093void MainWindow::faq() 1093void MainWindow::faq()
1094{ 1094{
1095 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1095 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1096 1096
1097} 1097}
1098void MainWindow::whatsNew() 1098void MainWindow::whatsNew()
1099{ 1099{
1100 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1100 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1101 1101
1102} 1102}
1103void MainWindow::licence() 1103void MainWindow::licence()
1104{ 1104{
1105 KApplication::showLicence(); 1105 KApplication::showLicence();
1106 1106
1107} 1107}
1108void MainWindow::about() 1108void MainWindow::about()
1109{ 1109{
1110 QString version; 1110 QString version;
1111#include <../version> 1111#include <../version>
1112 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1112 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1113 i18n("KOrganizer/Platform-independent\n") + 1113 i18n("KOrganizer/Platform-independent\n") +
1114 "(KO/Pi) " + version + " - " + 1114 "(KO/Pi) " + version + " - " +
1115 1115
1116#ifdef DESKTOP_VERSION 1116#ifdef DESKTOP_VERSION
1117 i18n("Desktop Edition\n") + 1117 i18n("Desktop Edition\n") +
1118#else 1118#else
1119 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1119 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1120#endif 1120#endif
1121 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") ); 1121 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") );
1122} 1122}
1123void MainWindow::keyBindings() 1123void MainWindow::keyBindings()
1124{ 1124{
1125 QString cap = i18n("Key bindings KOrganizer/Pi"); 1125 QString cap = i18n("Key bindings KOrganizer/Pi");
1126 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1126 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1127 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1127 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1128 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1128 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1129 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1129 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1130 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1130 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1131 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1131 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1132 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1132 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1133 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1133 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1134 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1134 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1135 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1135 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1136 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1136 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1137 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1137 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1138 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1138 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1139 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1139 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1140 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1140 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1141 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1141 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1142 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1142 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1143 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1143 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1144 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1144 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1145 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1145 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1146 i18n("<p><h3>In agenda view:</h3></p>\n") + 1146 i18n("<p><h3>In agenda view:</h3></p>\n") +
1147 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1147 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1148 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1148 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1149 i18n("<p><h3>In todo view:</h3></p>\n") + 1149 i18n("<p><h3>In todo view:</h3></p>\n") +
1150 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1150 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1151 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1151 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1152 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1152 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1153 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1153 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1154 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1154 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1155 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1155 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1156 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1156 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1157 i18n("<p><h3>In list view:</h3></p>\n") + 1157 i18n("<p><h3>In list view:</h3></p>\n") +
1158 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1158 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1159 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1159 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1160 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1160 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1161 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1161 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1162 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1162 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1163 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1163 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1164 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1164 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1165 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1165 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1166 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1166 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1167 i18n("<p><b>E</b>: Edit item</p>\n") + 1167 i18n("<p><b>E</b>: Edit item</p>\n") +
1168 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1168 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1169 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1169 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1170 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1170 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1171 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1171 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1172 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1172 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1173 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1173 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1174 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1174 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1175 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1175 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1176 i18n("<p><b>White</b>: Item readonly</p>\n"); 1176 i18n("<p><b>White</b>: Item readonly</p>\n");
1177 displayText( text, cap); 1177 displayText( text, cap);
1178 1178
1179} 1179}
1180void MainWindow::aboutAutoSaving() 1180void MainWindow::aboutAutoSaving()
1181{ 1181{
1182 QMessageBox* msg; 1182 QMessageBox* msg;
1183 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1183 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1184 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, 1184 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,
1185 QMessageBox::Ok, 1185 QMessageBox::Ok,
1186 QMessageBox::NoButton, 1186 QMessageBox::NoButton,
1187 QMessageBox::NoButton); 1187 QMessageBox::NoButton);
1188 msg->exec(); 1188 msg->exec();
1189 delete msg; 1189 delete msg;
1190 1190
1191 1191
1192} 1192}
1193void MainWindow::aboutKnownBugs() 1193void MainWindow::aboutKnownBugs()
1194{ 1194{
1195 QMessageBox* msg; 1195 QMessageBox* msg;
1196 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1196 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1197 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")+ 1197 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")+
1198 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1198 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1199 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1199 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1200 i18n("\nor report them in the bugtracker on\n") + 1200 i18n("\nor report them in the bugtracker on\n") +
1201 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1201 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1202 QMessageBox::NoIcon, 1202 QMessageBox::NoIcon,
1203 QMessageBox::Ok, 1203 QMessageBox::Ok,
1204 QMessageBox::NoButton, 1204 QMessageBox::NoButton,
1205 QMessageBox::NoButton); 1205 QMessageBox::NoButton);
1206 msg->exec(); 1206 msg->exec();
1207 delete msg; 1207 delete msg;
1208 1208
1209} 1209}
1210 1210
1211QString MainWindow::defaultFileName() 1211QString MainWindow::defaultFileName()
1212{ 1212{
1213 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1213 return locateLocal( "data", "korganizer/mycalendar.ics" );
1214} 1214}
1215QString MainWindow::syncFileName() 1215QString MainWindow::syncFileName()
1216{ 1216{
1217#ifdef DESKTOP_VERSION 1217#ifdef DESKTOP_VERSION
1218 return locateLocal( "tmp", "synccalendar.ics" ); 1218 return locateLocal( "tmp", "synccalendar.ics" );
1219#else 1219#else
1220 return QString( "/tmp/synccalendar.ics" ); 1220 return QString( "/tmp/synccalendar.ics" );
1221#endif 1221#endif
1222} 1222}
1223 1223
1224void MainWindow::processIncidenceSelection( Incidence *incidence ) 1224void MainWindow::processIncidenceSelection( Incidence *incidence )
1225{ 1225{
1226 if ( !incidence ) { 1226 if ( !incidence ) {
1227 enableIncidenceActions( false ); 1227 enableIncidenceActions( false );
1228 1228
1229 mNewSubTodoAction->setEnabled( false ); 1229 mNewSubTodoAction->setEnabled( false );
1230 setCaptionToDates(); 1230 setCaptionToDates();
1231 return; 1231 return;
1232 1232
1233 } 1233 }
1234 1234
1235 //KGlobal::locale()->formatDateTime(nextA, true); 1235 //KGlobal::locale()->formatDateTime(nextA, true);
1236 QString startString = ""; 1236 QString startString = "";
1237 if ( incidence->type() != "Todo" ) { 1237 if ( incidence->type() != "Todo" ) {
1238 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1238 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1239 if ( incidence->doesFloat() ) { 1239 if ( incidence->doesFloat() ) {
1240 startString += ": "+incidence->dtStartDateStr( true ); 1240 startString += ": "+incidence->dtStartDateStr( true );
1241 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1241 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1242 1242
1243 } else { 1243 } else {
1244 startString = ": "+incidence->dtStartStr(true); 1244 startString = ": "+incidence->dtStartStr(true);
1245 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1245 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1246 1246
1247 } 1247 }
1248 1248
1249 } else { 1249 } else {
1250 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1250 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1251 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1251 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1252 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1252 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1253 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1253 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1254 } 1254 }
1255 1255
1256 } 1256 }
1257 else 1257 else
1258 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1258 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1259 if ( !incidence->location().isEmpty() ) 1259 if ( !incidence->location().isEmpty() )
1260 startString += " (" +incidence->location()+")"; 1260 startString += " (" +incidence->location()+")";
1261 setCaption( incidence->summary()+startString); 1261 setCaption( incidence->summary()+startString);
1262 1262
1263 enableIncidenceActions( true ); 1263 enableIncidenceActions( true );
1264 1264
1265 if ( incidence->type() == "Event" ) { 1265 if ( incidence->type() == "Event" ) {
1266 mShowAction->setText( i18n("Show Event...") ); 1266 mShowAction->setText( i18n("Show Event...") );
1267 mEditAction->setText( i18n("Edit Event...") ); 1267 mEditAction->setText( i18n("Edit Event...") );
1268 mDeleteAction->setText( i18n("Delete Event...") ); 1268 mDeleteAction->setText( i18n("Delete Event...") );
1269 1269
1270 mNewSubTodoAction->setEnabled( false ); 1270 mNewSubTodoAction->setEnabled( false );
1271 } else if ( incidence->type() == "Todo" ) { 1271 } else if ( incidence->type() == "Todo" ) {
1272 mShowAction->setText( i18n("Show Todo...") ); 1272 mShowAction->setText( i18n("Show Todo...") );
1273 mEditAction->setText( i18n("Edit Todo...") ); 1273 mEditAction->setText( i18n("Edit Todo...") );
1274 mDeleteAction->setText( i18n("Delete Todo...") ); 1274 mDeleteAction->setText( i18n("Delete Todo...") );
1275 1275
1276 mNewSubTodoAction->setEnabled( true ); 1276 mNewSubTodoAction->setEnabled( true );
1277 } else { 1277 } else {
1278 mShowAction->setText( i18n("Show...") ); 1278 mShowAction->setText( i18n("Show...") );
1279 mShowAction->setText( i18n("Edit...") ); 1279 mShowAction->setText( i18n("Edit...") );
1280 mShowAction->setText( i18n("Delete...") ); 1280 mShowAction->setText( i18n("Delete...") );
1281 1281
1282 mNewSubTodoAction->setEnabled( false ); 1282 mNewSubTodoAction->setEnabled( false );
1283 } 1283 }
1284} 1284}
1285 1285
1286void MainWindow::enableIncidenceActions( bool enabled ) 1286void MainWindow::enableIncidenceActions( bool enabled )
1287{ 1287{
1288 mShowAction->setEnabled( enabled ); 1288 mShowAction->setEnabled( enabled );
1289 mEditAction->setEnabled( enabled ); 1289 mEditAction->setEnabled( enabled );
1290 mDeleteAction->setEnabled( enabled ); 1290 mDeleteAction->setEnabled( enabled );
1291 1291
1292 mCloneAction->setEnabled( enabled ); 1292 mCloneAction->setEnabled( enabled );
1293 mMoveAction->setEnabled( enabled ); 1293 mMoveAction->setEnabled( enabled );
1294 mBeamAction->setEnabled( enabled ); 1294 mBeamAction->setEnabled( enabled );
1295 mCancelAction->setEnabled( enabled ); 1295 mCancelAction->setEnabled( enabled );
1296} 1296}
1297 1297
1298void MainWindow::importOL() 1298void MainWindow::importOL()
1299{ 1299{
1300#ifdef _WIN32_ 1300#ifdef _WIN32_
1301 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1301 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1302 id->exec(); 1302 id->exec();
1303 delete id; 1303 delete id;
1304 mView->updateView(); 1304 mView->updateView();
1305#endif 1305#endif
1306} 1306}
1307void MainWindow::importBday() 1307void MainWindow::importBday()
1308{ 1308{
1309 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1309 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1310 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1310 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1311 i18n("Import!"), i18n("Cancel"), 0, 1311 i18n("Import!"), i18n("Cancel"), 0,
1312 0, 1 ); 1312 0, 1 );
1313 if ( result == 0 ) { 1313 if ( result == 0 ) {
1314 mView->importBday(); 1314 mView->importBday();
1315 1315
1316 } 1316 }
1317 1317
1318 1318
1319} 1319}
1320void MainWindow::importQtopia() 1320void MainWindow::importQtopia()
1321{ 1321{
1322#ifndef DESKTOP_VERSION 1322#ifndef DESKTOP_VERSION
1323 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1323 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1324 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"), 1324 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"),
1325 i18n("Import!"), i18n("Cancel"), 0, 1325 i18n("Import!"), i18n("Cancel"), 0,
1326 0, 1 ); 1326 0, 1 );
1327 if ( result == 0 ) { 1327 if ( result == 0 ) {
1328 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1328 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1329 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1329 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1330 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1330 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1331 mView->importQtopia( categories, datebook, todolist ); 1331 mView->importQtopia( categories, datebook, todolist );
1332 } 1332 }
1333#else 1333#else
1334 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1334 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1335 i18n("Not supported \non desktop!\n"), 1335 i18n("Not supported \non desktop!\n"),
1336 i18n("Ok"), i18n("Cancel"), 0, 1336 i18n("Ok"), i18n("Cancel"), 0,
1337 0, 1 ); 1337 0, 1 );
1338 1338
1339#endif 1339#endif
1340} 1340}
1341 1341
1342void MainWindow::saveOnClose() 1342void MainWindow::saveOnClose()
1343{ 1343{
1344 KOPrefs *p = KOPrefs::instance(); 1344 KOPrefs *p = KOPrefs::instance();
1345 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1345 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1346 p->mToolBarUp = iconToolBar->x() > width()/2 || 1346 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1347 iconToolBar->y() > height()/2; 1347 iconToolBar->y() > height()/2;
1348 mView->writeSettings(); 1348 mView->writeSettings();
1349 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1349 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1350 save(); 1350 save();
1351} 1351}
1352void MainWindow::slotModifiedChanged( bool changed ) 1352void MainWindow::slotModifiedChanged( bool changed )
1353{ 1353{
1354 if ( mBlockAtStartup ) 1354 if ( mBlockAtStartup )
1355 return; 1355 return;
1356 int msec; 1356 int msec;
1357 // we store the changes after 1 minute, 1357 // we store the changes after 1 minute,
1358 // and for safety reasons after 10 minutes again 1358 // and for safety reasons after 10 minutes again
1359 if ( !mSyncManager->blockSave() ) 1359 if ( !mSyncManager->blockSave() )
1360 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1360 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1361 else 1361 else
1362 msec = 1000 * 600; 1362 msec = 1000 * 600;
1363 mSaveTimer.start( msec, true ); // 1 minute 1363 mSaveTimer.start( msec, true ); // 1 minute
1364 qDebug("KO: Saving File in %d secs!", msec/1000); 1364 qDebug("KO: Saving File in %d secs!", msec/1000);
1365 mCalendarModifiedFlag = true; 1365 mCalendarModifiedFlag = true;
1366} 1366}
1367void MainWindow::save() 1367void MainWindow::save()
1368{ 1368{
1369 if ( mSyncManager->blockSave() ) 1369 if ( mSyncManager->blockSave() )
1370 return; 1370 return;
1371 mSyncManager->setBlockSave(true); 1371 mSyncManager->setBlockSave(true);
1372 if ( mView->checkFileVersion( defaultFileName()) ) { 1372 if ( mView->checkFileVersion( defaultFileName()) ) {
1373 1373
1374 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1374 QTime neededSaveTime = QDateTime::currentDateTime().time();
1375 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1375 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1376 qDebug("KO: Start saving data to file!"); 1376 qDebug("KO: Start saving data to file!");
1377 mView->saveCalendar( defaultFileName() ); 1377 mView->saveCalendar( defaultFileName() );
1378 1378
1379 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1379 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1380 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1380 qDebug("KO: Needed %d ms for saving.",msNeeded );
1381 QString savemes; 1381 QString savemes;
1382 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1382 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1383 setCaption(savemes); 1383 setCaption(savemes);
1384 } else 1384 } else
1385 setCaption(i18n("Saving cancelled!")); 1385 setCaption(i18n("Saving cancelled!"));
1386 mCalendarModifiedFlag = false; 1386 mCalendarModifiedFlag = false;
1387 mSyncManager->setBlockSave( false ); 1387 mSyncManager->setBlockSave( false );
1388} 1388}
1389 1389
1390void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1390void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1391{ 1391{
1392 if ( !e->isAutoRepeat() ) { 1392 if ( !e->isAutoRepeat() ) {
1393 mFlagKeyPressed = false; 1393 mFlagKeyPressed = false;
1394 } 1394 }
1395} 1395}
1396void MainWindow::keyPressEvent ( QKeyEvent * e ) 1396void MainWindow::keyPressEvent ( QKeyEvent * e )
1397{ 1397{
1398 qApp->processEvents(); 1398 qApp->processEvents();
1399 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1399 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1400 e->ignore(); 1400 e->ignore();
1401 // qDebug(" ignore %d",e->isAutoRepeat() ); 1401 // qDebug(" ignore %d",e->isAutoRepeat() );
1402 return; 1402 return;
1403 } 1403 }
1404 if (! e->isAutoRepeat() ) 1404 if (! e->isAutoRepeat() )
1405 mFlagKeyPressed = true; 1405 mFlagKeyPressed = true;
1406 KOPrefs *p = KOPrefs::instance(); 1406 KOPrefs *p = KOPrefs::instance();
1407 bool showSelectedDates = false; 1407 bool showSelectedDates = false;
1408 int size; 1408 int size;
1409 int pro = 0; 1409 int pro = 0;
1410 //qDebug("MainWindow::keyPressEvent "); 1410 //qDebug("MainWindow::keyPressEvent ");
1411 switch ( e->key() ) { 1411 switch ( e->key() ) {
1412 case Qt::Key_Right: 1412 case Qt::Key_Right:
1413 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1413 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1414 mView->goNextMonth(); 1414 mView->goNextMonth();
1415 else 1415 else
1416 mView->goNext(); 1416 mView->goNext();
1417 showSelectedDates = true; 1417 showSelectedDates = true;
1418 break; 1418 break;
1419 case Qt::Key_Left: 1419 case Qt::Key_Left:
1420 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1420 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1421 mView->goPreviousMonth(); 1421 mView->goPreviousMonth();
1422 else 1422 else
1423 mView->goPrevious(); 1423 mView->goPrevious();
1424 showSelectedDates = true; 1424 showSelectedDates = true;
1425 break; 1425 break;
1426 case Qt::Key_Down: 1426 case Qt::Key_Down:
1427 mView->viewManager()->agendaView()->scrollOneHourDown(); 1427 mView->viewManager()->agendaView()->scrollOneHourDown();
1428 break; 1428 break;
1429 case Qt::Key_Up: 1429 case Qt::Key_Up:
1430 mView->viewManager()->agendaView()->scrollOneHourUp(); 1430 mView->viewManager()->agendaView()->scrollOneHourUp();
1431 break; 1431 break;
1432 case Qt::Key_I: 1432 case Qt::Key_I:
1433 mView->showIncidence(); 1433 mView->showIncidence();
1434 break; 1434 break;
1435 case Qt::Key_Delete: 1435 case Qt::Key_Delete:
1436 case Qt::Key_Backspace: 1436 case Qt::Key_Backspace:
1437 mView->deleteIncidence(); 1437 mView->deleteIncidence();
1438 break; 1438 break;
1439 case Qt::Key_D: 1439 case Qt::Key_D:
1440 mView->viewManager()->showDayView(); 1440 mView->viewManager()->showDayView();
1441 showSelectedDates = true; 1441 showSelectedDates = true;
1442 break; 1442 break;
1443 case Qt::Key_O: 1443 case Qt::Key_O:
1444 mView->toggleFilerEnabled( ); 1444 mView->toggleFilerEnabled( );
1445 break; 1445 break;
1446 case Qt::Key_0: 1446 case Qt::Key_0:
1447 case Qt::Key_1: 1447 case Qt::Key_1:
1448 case Qt::Key_2: 1448 case Qt::Key_2:
1449 case Qt::Key_3: 1449 case Qt::Key_3:
1450 case Qt::Key_4: 1450 case Qt::Key_4:
1451 case Qt::Key_5: 1451 case Qt::Key_5:
1452 case Qt::Key_6: 1452 case Qt::Key_6:
1453 case Qt::Key_7: 1453 case Qt::Key_7:
1454 case Qt::Key_8: 1454 case Qt::Key_8:
1455 case Qt::Key_9: 1455 case Qt::Key_9:
1456 pro = e->key()-48; 1456 pro = e->key()-48;
1457 if ( pro == 0 ) 1457 if ( pro == 0 )
1458 pro = 10; 1458 pro = 10;
1459 if ( e->state() == Qt::ControlButton) 1459 if ( e->state() == Qt::ControlButton)
1460 pro += 10; 1460 pro += 10;
1461 break; 1461 break;
1462 case Qt::Key_M: 1462 case Qt::Key_M:
1463 mView->viewManager()->showMonthView(); 1463 mView->viewManager()->showMonthView();
1464 showSelectedDates = true; 1464 showSelectedDates = true;
1465 break; 1465 break;
1466 case Qt::Key_Insert: 1466 case Qt::Key_Insert:
1467 mView->newEvent(); 1467 mView->newEvent();
1468 break; 1468 break;
1469 case Qt::Key_S : 1469 case Qt::Key_S :
1470 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1470 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1471 mView->newSubTodo(); 1471 mView->newSubTodo();
1472 else 1472 else
1473 mView->dialogManager()->showSearchDialog(); 1473 mView->dialogManager()->showSearchDialog();
1474 break; 1474 break;
1475 case Qt::Key_Y : 1475 case Qt::Key_Y :
1476 case Qt::Key_Z : 1476 case Qt::Key_Z :
1477 mView->viewManager()->showWorkWeekView(); 1477 mView->viewManager()->showWorkWeekView();
1478 showSelectedDates = true; 1478 showSelectedDates = true;
1479 break; 1479 break;
1480 case Qt::Key_U : 1480 case Qt::Key_U :
1481 mView->viewManager()->showWeekView(); 1481 mView->viewManager()->showWeekView();
1482 showSelectedDates = true; 1482 showSelectedDates = true;
1483 break; 1483 break;
1484 case Qt::Key_H : 1484 case Qt::Key_H :
1485 keyBindings(); 1485 keyBindings();
1486 break; 1486 break;
1487 case Qt::Key_W: 1487 case Qt::Key_W:
1488 mView->viewManager()->showWhatsNextView(); 1488 mView->viewManager()->showWhatsNextView();
1489 break; 1489 break;
1490 case Qt::Key_L: 1490 case Qt::Key_L:
1491 mView->viewManager()->showListView(); 1491 mView->viewManager()->showListView();
1492 break; 1492 break;
1493 case Qt::Key_N: 1493 case Qt::Key_N:
1494 mView->viewManager()->showNextXView(); 1494 mView->viewManager()->showNextXView();
1495 showSelectedDates = true; 1495 showSelectedDates = true;
1496 break; 1496 break;
1497 case Qt::Key_V: 1497 case Qt::Key_V:
1498 mView->viewManager()->showTodoView(); 1498 mView->viewManager()->showTodoView();
1499 break; 1499 break;
1500 case Qt::Key_C: 1500 case Qt::Key_C:
1501 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1501 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1502 break; 1502 break;
1503 case Qt::Key_P: 1503 case Qt::Key_P:
1504 mView->showDatePicker( ); 1504 mView->showDatePicker( );
1505 break; 1505 break;
1506 case Qt::Key_F: 1506 case Qt::Key_F:
1507 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1507 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1508 mView->editFilters(); 1508 mView->editFilters();
1509 else 1509 else
1510 mView->toggleFilter(); 1510 mView->toggleFilter();
1511 break; 1511 break;
1512 case Qt::Key_X: 1512 case Qt::Key_X:
1513 mView->toggleDateNavigatorWidget(); 1513 mView->toggleDateNavigatorWidget();
1514 break; 1514 break;
1515 case Qt::Key_Space: 1515 case Qt::Key_Space:
1516 mView->toggleExpand(); 1516 mView->toggleExpand();
1517 break; 1517 break;
1518 case Qt::Key_A: 1518 case Qt::Key_A:
1519 mView->toggleAllDaySize(); 1519 mView->toggleAllDaySize();
1520 break; 1520 break;
1521 case Qt::Key_T: 1521 case Qt::Key_T:
1522 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1522 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1523 mView->newTodo(); 1523 mView->newTodo();
1524 else { 1524 else {
1525 mView->goToday(); 1525 mView->goToday();
1526 showSelectedDates = true; 1526 showSelectedDates = true;
1527 } 1527 }
1528 break; 1528 break;
1529 case Qt::Key_J: 1529 case Qt::Key_J:
1530 mView->viewManager()->showJournalView(); 1530 mView->viewManager()->showJournalView();
1531 break; 1531 break;
1532 case Qt::Key_B: 1532 case Qt::Key_B:
1533 mView->editIncidenceDescription();; 1533 mView->editIncidenceDescription();;
1534 break; 1534 break;
1535 // case Qt::Key_Return: 1535 // case Qt::Key_Return:
1536 case Qt::Key_E: 1536 case Qt::Key_E:
1537 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1537 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1538 mView->newEvent(); 1538 mView->newEvent();
1539 else 1539 else
1540 mView->editIncidence(); 1540 mView->editIncidence();
1541 break; 1541 break;
1542 case Qt::Key_Plus: 1542 case Qt::Key_Plus:
1543 size = p->mHourSize +2; 1543 size = p->mHourSize +2;
1544 if ( size <= 18 ) 1544 if ( size <= 18 )
1545 configureAgenda( size ); 1545 configureAgenda( size );
1546 break; 1546 break;
1547 case Qt::Key_Minus: 1547 case Qt::Key_Minus:
1548 size = p->mHourSize - 2; 1548 size = p->mHourSize - 2;
1549 if ( size >= 4 ) 1549 if ( size >= 4 )
1550 configureAgenda( size ); 1550 configureAgenda( size );
1551 break; 1551 break;
1552 1552
1553 1553
1554 default: 1554 default:
1555 e->ignore(); 1555 e->ignore();
1556 } 1556 }
1557 if ( pro > 0 ) { 1557 if ( pro > 0 ) {
1558 mView->selectFilter( pro-1 ); 1558 mView->selectFilter( pro-1 );
1559 } 1559 }
1560 if ( showSelectedDates ) { 1560 if ( showSelectedDates ) {
1561 ;// setCaptionToDates(); 1561 ;// setCaptionToDates();
1562 } 1562 }
1563 1563
1564} 1564}
1565 1565
1566void MainWindow::fillFilterMenu() 1566void MainWindow::fillFilterMenu()
1567{ 1567{
1568 selectFilterMenu->clear(); 1568 selectFilterMenu->clear();
1569 bool disable = false; 1569 bool disable = false;
1570 if ( mView->filterView()->filtersEnabled() ) { 1570 if ( mView->filterView()->filtersEnabled() ) {
1571 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1571 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1572 } 1572 }
1573 else { 1573 else {
1574 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1574 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1575 disable = true; 1575 disable = true;
1576 } 1576 }
1577 selectFilterMenu->insertSeparator(); 1577 selectFilterMenu->insertSeparator();
1578 QPtrList<CalFilter> fili = mView->filters(); 1578 QPtrList<CalFilter> fili = mView->filters();
1579 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1579 CalFilter *curfilter = mView->filterView()->selectedFilter();
1580 CalFilter *filter = fili.first(); 1580 CalFilter *filter = fili.first();
1581 int iii = 1; 1581 int iii = 1;
1582 while(filter) { 1582 while(filter) {
1583 selectFilterMenu->insertItem( filter->name(), iii ); 1583 selectFilterMenu->insertItem( filter->name(), iii );
1584 if ( filter == curfilter) 1584 if ( filter == curfilter)
1585 selectFilterMenu->setItemChecked( iii, true ); 1585 selectFilterMenu->setItemChecked( iii, true );
1586 if ( disable ) 1586 if ( disable )
1587 selectFilterMenu->setItemEnabled( iii, false ); 1587 selectFilterMenu->setItemEnabled( iii, false );
1588 filter = fili.next(); 1588 filter = fili.next();
1589 ++iii; 1589 ++iii;
1590 } 1590 }
1591} 1591}
1592void MainWindow::selectFilter( int fil ) 1592void MainWindow::selectFilter( int fil )
1593{ 1593{
1594 if ( fil == 0 ) { 1594 if ( fil == 0 ) {
1595 mView->toggleFilerEnabled( ); 1595 mView->toggleFilerEnabled( );
1596 } else { 1596 } else {
1597 mView->selectFilter( fil-1 ); 1597 mView->selectFilter( fil-1 );
1598 } 1598 }
1599} 1599}
1600void MainWindow::configureToolBar( int item ) 1600void MainWindow::configureToolBar( int item )
1601{ 1601{
1602 1602
1603 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1603 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1604 KOPrefs *p = KOPrefs::instance(); 1604 KOPrefs *p = KOPrefs::instance();
1605 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1605 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1606 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1606 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1607 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1607 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1608 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1608 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1609 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1609 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1610 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1610 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1611 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1611 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1612 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1612 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1613 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1613 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1614 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1614 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1615 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1615 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1616 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1616 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1617 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1617 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1618 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1618 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1619 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1619 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1620 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1620 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1621 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1621 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1622 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1622 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1623 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1623 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1624 // initActions(); 1624 // initActions();
1625} 1625}
1626 1626
1627void MainWindow::setCaptionToDates() 1627void MainWindow::setCaptionToDates()
1628{ 1628{
1629 QString selDates; 1629 QString selDates;
1630 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1630 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1631 if (mView->startDate() < mView->endDate() ) 1631 if (mView->startDate() < mView->endDate() )
1632 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1632 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1633 setCaption( i18n("Dates: ") + selDates ); 1633 setCaption( i18n("Dates: ") + selDates );
1634 1634
1635} 1635}
1636// parameter item == 0: reinit 1636// parameter item == 0: reinit
1637void MainWindow::configureAgenda( int item ) 1637void MainWindow::configureAgenda( int item )
1638{ 1638{
1639 1639
1640 KOPrefs *p = KOPrefs::instance(); 1640 KOPrefs *p = KOPrefs::instance();
1641 1641
1642 int i; 1642 int i;
1643 if ( item == 1 ) { 1643 if ( item == 1 ) {
1644 mView->toggleAllDaySize(); 1644 mView->toggleAllDaySize();
1645 return; 1645 return;
1646 } 1646 }
1647 // do not allow 4 for widgets higher than 480 1647 // do not allow 4 for widgets higher than 480
1648 // if ( QApplication::desktop()->height() > 480 ) { 1648 // if ( QApplication::desktop()->height() > 480 ) {
1649// if ( item == 4 ) 1649// if ( item == 4 )
1650// item = 6; 1650// item = 6;
1651// } 1651// }
1652 for ( i = 4; i <= 18; i= i+2 ) 1652 for ( i = 4; i <= 18; i= i+2 )
1653 configureAgendaMenu->setItemChecked( i, false ); 1653 configureAgendaMenu->setItemChecked( i, false );
1654 configureAgendaMenu->setItemChecked( item, true ); 1654 configureAgendaMenu->setItemChecked( item, true );
1655 if ( p->mHourSize == item ) 1655 if ( p->mHourSize == item )
1656 return; 1656 return;
1657 p->mHourSize=item; 1657 p->mHourSize=item;
1658 mView->viewManager()->agendaView()->updateConfig(); 1658 mView->viewManager()->agendaView()->updateConfig();
1659} 1659}
1660 1660
1661void MainWindow::saveCalendar() 1661void MainWindow::saveCalendar()
1662{ 1662{
1663 QString fn = KOPrefs::instance()->mLastSaveFile; 1663 QString fn = KOPrefs::instance()->mLastSaveFile;
1664 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1664 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1665 1665
1666 if ( fn == "" ) 1666 if ( fn == "" )
1667 return; 1667 return;
1668 QFileInfo info; 1668 QFileInfo info;
1669 info.setFile( fn ); 1669 info.setFile( fn );
1670 QString mes; 1670 QString mes;
1671 bool createbup = true; 1671 bool createbup = true;
1672 if ( info. exists() ) { 1672 if ( info. exists() ) {
1673 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1673 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1674 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1674 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1675 i18n("Overwrite!"), i18n("Cancel"), 0, 1675 i18n("Overwrite!"), i18n("Cancel"), 0,
1676 0, 1 ); 1676 0, 1 );
1677 if ( result != 0 ) { 1677 if ( result != 0 ) {
1678 createbup = false; 1678 createbup = false;
1679 } 1679 }
1680 } 1680 }
1681 if ( createbup ) { 1681 if ( createbup ) {
1682 mView->saveCalendar( fn ); 1682 mView->saveCalendar( fn );
1683 mes = i18n("KO/Pi:Saved %1").arg(fn); 1683 mes = i18n("KO/Pi:Saved %1").arg(fn);
1684 KOPrefs::instance()->mLastSaveFile = fn; 1684 KOPrefs::instance()->mLastSaveFile = fn;
1685 setCaption(mes); 1685 setCaption(mes);
1686 } 1686 }
1687} 1687}
1688void MainWindow::loadCalendar() 1688void MainWindow::loadCalendar()
1689{ 1689{
1690 1690
1691 QString fn = KOPrefs::instance()->mLastLoadFile; 1691 QString fn = KOPrefs::instance()->mLastLoadFile;
1692 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1692 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1693 1693
1694 if ( fn == "" ) 1694 if ( fn == "" )
1695 return; 1695 return;
1696 QFileInfo info; 1696 QFileInfo info;
1697 info.setFile( fn ); 1697 info.setFile( fn );
1698 QString mess; 1698 QString mess;
1699 bool loadbup = true; 1699 bool loadbup = true;
1700 if ( info. exists() ) { 1700 if ( info. exists() ) {
1701 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1701 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1702 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1702 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1703 mess, 1703 mess,
1704 i18n("Load!"), i18n("Cancel"), 0, 1704 i18n("Load!"), i18n("Cancel"), 0,
1705 0, 1 ); 1705 0, 1 );
1706 if ( result != 0 ) { 1706 if ( result != 0 ) {
1707 loadbup = false; 1707 loadbup = false;
1708 } 1708 }
1709 } else { 1709 } else {
1710 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1710 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1711 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1711 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1712 0, 1 ); 1712 0, 1 );
1713 1713
1714 return; 1714 return;
1715 } 1715 }
1716 if ( loadbup ) { 1716 if ( loadbup ) {
1717 mView->openCalendar( fn ); 1717 mView->openCalendar( fn );
1718 KOPrefs::instance()->mLastLoadFile = fn; 1718 KOPrefs::instance()->mLastLoadFile = fn;
1719 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1719 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1720 setCaption(mess); 1720 setCaption(mess);
1721 } 1721 }
1722 1722
1723} 1723}
1724void MainWindow::quickImportIcal() 1724void MainWindow::quickImportIcal()
1725{ 1725{
1726 importFile( KOPrefs::instance()->mLastImportFile, false ); 1726 importFile( KOPrefs::instance()->mLastImportFile, false );
1727} 1727}
1728void MainWindow::importFile( QString fn, bool quick ) 1728void MainWindow::importFile( QString fn, bool quick )
1729{ 1729{
1730 QFileInfo info; 1730 QFileInfo info;
1731 info.setFile( fn ); 1731 info.setFile( fn );
1732 QString mess; 1732 QString mess;
1733 bool loadbup = true; 1733 bool loadbup = true;
1734 if ( !info. exists() ) { 1734 if ( !info. exists() ) {
1735 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1735 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1736 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1736 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1737 mess ); 1737 mess );
1738 return; 1738 return;
1739 } 1739 }
1740 int result = 0; 1740 int result = 0;
1741 if ( !quick ) { 1741 if ( !quick ) {
1742 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 )); 1742 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 ));
1743 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1743 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1744 mess, 1744 mess,
1745 "Import", "Cancel", 0, 1745 "Import", "Cancel", 0,
1746 0, 1 ); 1746 0, 1 );
1747 } 1747 }
1748 if ( result == 0 ) { 1748 if ( result == 0 ) {
1749 if ( mView->openCalendar( fn, true )) { 1749 if ( mView->openCalendar( fn, true )) {
1750 KOPrefs::instance()->mLastImportFile = fn; 1750 KOPrefs::instance()->mLastImportFile = fn;
1751 setCaption(i18n("Imported file successfully")); 1751 setCaption(i18n("Imported file successfully"));
1752 } else { 1752 } else {
1753 setCaption(i18n("Error importing file")); 1753 setCaption(i18n("Error importing file"));
1754 } 1754 }
1755 } 1755 }
1756} 1756}
1757 1757
1758void MainWindow::importIcal() 1758void MainWindow::importIcal()
1759{ 1759{
1760 1760
1761 QString fn =KOPrefs::instance()->mLastImportFile; 1761 QString fn =KOPrefs::instance()->mLastImportFile;
1762 1762
1763 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1763 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1764 if ( fn == "" ) 1764 if ( fn == "" )
1765 return; 1765 return;
1766 importFile( fn, true ); 1766 importFile( fn, true );
1767 1767
1768} 1768}
1769 1769
1770void MainWindow::exportVCalendar() 1770void MainWindow::exportVCalendar()
1771{ 1771{
1772 QString fn = KOPrefs::instance()->mLastVcalFile; 1772 QString fn = KOPrefs::instance()->mLastVcalFile;
1773 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1773 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1774 if ( fn == "" ) 1774 if ( fn == "" )
1775 return; 1775 return;
1776 QFileInfo info; 1776 QFileInfo info;
1777 info.setFile( fn ); 1777 info.setFile( fn );
1778 QString mes; 1778 QString mes;
1779 bool createbup = true; 1779 bool createbup = true;
1780 if ( info. exists() ) { 1780 if ( info. exists() ) {
1781 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1781 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1782 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1782 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1783 i18n("Overwrite!"), i18n("Cancel"), 0, 1783 i18n("Overwrite!"), i18n("Cancel"), 0,
1784 0, 1 ); 1784 0, 1 );
1785 if ( result != 0 ) { 1785 if ( result != 0 ) {
1786 createbup = false; 1786 createbup = false;
1787 } 1787 }
1788 } 1788 }
1789 if ( createbup ) { 1789 if ( createbup ) {
1790 if ( mView->exportVCalendar( fn ) ) { 1790 if ( mView->exportVCalendar( fn ) ) {
1791 KOPrefs::instance()->mLastVcalFile = fn; 1791 KOPrefs::instance()->mLastVcalFile = fn;
1792 if ( fn.length() > 20 ) 1792 if ( fn.length() > 20 )
1793 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1793 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1794 else 1794 else
1795 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1795 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1796 setCaption(mes); 1796 setCaption(mes);
1797 } 1797 }
1798 } 1798 }
1799 1799
1800} 1800}
1801 1801
1802void MainWindow::syncFileRequest() 1802void MainWindow::syncFileRequest()
1803{ 1803{
1804 save(); 1804 save();
1805} 1805}
1806void MainWindow::getFile( bool success ) 1806void MainWindow::getFile( bool success )
1807{ 1807{
1808 if ( ! success ) { 1808 if ( ! success ) {
1809 setCaption( i18n("Error receiving file. Nothing changed!") ); 1809 setCaption( i18n("Error receiving file. Nothing changed!") );
1810 return; 1810 return;
1811 } 1811 }
1812 mView->openCalendar( defaultFileName() ); 1812 mView->openCalendar( defaultFileName() );
1813 setCaption( i18n("Pi-Sync successful!") ); 1813 setCaption( i18n("Pi-Sync successful!") );
1814} 1814}
1815 1815
1816void MainWindow::printSel( ) 1816void MainWindow::printSel( )
1817{ 1817{
1818 mView->viewManager()->agendaView()->agenda()->printSelection(); 1818 mView->viewManager()->agendaView()->agenda()->printSelection();
1819} 1819}
1820 1820
1821void MainWindow::printCal() 1821void MainWindow::printCal()
1822{ 1822{
1823 mView->print();//mCp->showDialog(); 1823 mView->print();//mCp->showDialog();
1824} 1824}
1825 1825
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp
index c21ebaa..a05e65f 100644
--- a/libkdepim/kpimprefs.cpp
+++ b/libkdepim/kpimprefs.cpp
@@ -1,82 +1,84 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kconfig.h> 32#include <kconfig.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kdebug.h> 34#include <kdebug.h>
35 35
36#include "kpimprefs.h" 36#include "kpimprefs.h"
37 37
38KPimPrefs::KPimPrefs( const QString &name ) : 38KPimPrefs::KPimPrefs( const QString &name ) :
39 KPrefs( name ) 39 KPrefs( name )
40{ 40{
41#ifdef _WIN32_ 41#ifdef _WIN32_
42 QString hdp= locateLocal("data","korganizer")+"\\\\"; 42 QString hdp= locateLocal("data","korganizer")+"\\\\";
43#else 43#else
44 QString hdp= locateLocal("data","korganizer")+"/"; 44 QString hdp= locateLocal("data","korganizer")+"/";
45#endif 45#endif
46 config()->setGroup("SyncOptions"); 46 config()->setGroup("SyncOptions");
47 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); 47 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
48 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); 48 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" );
49 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); 49 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
50 addItemBool("PassiveSyncWithDesktop",&mPassiveSyncWithDesktop,false );
51 addItemBool("PassiveSyncAutoStart",&mPassiveSyncAutoStart,false );
50 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); 52 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
51} 53}
52 54
53KPimPrefs::~KPimPrefs() 55KPimPrefs::~KPimPrefs()
54{ 56{
55} 57}
56 58
57void KPimPrefs::usrSetDefaults() 59void KPimPrefs::usrSetDefaults()
58{ 60{
59 setCategoryDefaults(); 61 setCategoryDefaults();
60} 62}
61 63
62void KPimPrefs::usrReadConfig() 64void KPimPrefs::usrReadConfig()
63{ 65{
64 kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl; 66 kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl;
65 67
66 config()->setGroup("General"); 68 config()->setGroup("General");
67 mCustomCategories = config()->readListEntry("Custom Categories"); 69 mCustomCategories = config()->readListEntry("Custom Categories");
68 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 70 if (mCustomCategories.isEmpty()) setCategoryDefaults();
69} 71}
70 72
71 73
72void KPimPrefs::usrWriteConfig() 74void KPimPrefs::usrWriteConfig()
73{ 75{
74 config()->setGroup("General"); 76 config()->setGroup("General");
75 config()->writeEntry("Custom Categories",mCustomCategories); 77 config()->writeEntry("Custom Categories",mCustomCategories);
76} 78}
77 79
78void KPimPrefs::setCategoryDefaults() 80void KPimPrefs::setCategoryDefaults()
79{ 81{
80 // empty implementation 82 // empty implementation
81} 83}
82 84
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h
index 9346f7d..c177bd6 100644
--- a/libkdepim/kpimprefs.h
+++ b/libkdepim/kpimprefs.h
@@ -1,71 +1,73 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#ifndef KPIMPREFS_H 31#ifndef KPIMPREFS_H
32#define KPIMPREFS_H 32#define KPIMPREFS_H
33 33
34#include <qstringlist.h> 34#include <qstringlist.h>
35 35
36#include "kprefs.h" 36#include "kprefs.h"
37 37
38class KPimPrefs : public KPrefs 38class KPimPrefs : public KPrefs
39{ 39{
40 public: 40 public:
41 41
42 KPimPrefs( const QString &name = QString::null ); 42 KPimPrefs( const QString &name = QString::null );
43 43
44 virtual ~KPimPrefs(); 44 virtual ~KPimPrefs();
45 45
46 /** Set preferences to default values */ 46 /** Set preferences to default values */
47 void usrSetDefaults(); 47 void usrSetDefaults();
48 48
49 /** Read preferences from config file */ 49 /** Read preferences from config file */
50 void usrReadConfig(); 50 void usrReadConfig();
51 51
52 /** Write preferences to config file */ 52 /** Write preferences to config file */
53 void usrWriteConfig(); 53 void usrWriteConfig();
54 54
55 55
56 public: 56 public:
57 QStringList mCustomCategories; 57 QStringList mCustomCategories;
58 QString mPassiveSyncPort; 58 QString mPassiveSyncPort;
59 QString mPassiveSyncPw; 59 QString mPassiveSyncPw;
60 bool mPassiveSyncWithDesktop;
61 bool mPassiveSyncAutoStart;
60 int mRingSyncAlgoPrefs; 62 int mRingSyncAlgoPrefs;
61 QString mLastSyncedLocalFile; 63 QString mLastSyncedLocalFile;
62 64
63 65
64 protected: 66 protected:
65 virtual void setCategoryDefaults(); 67 virtual void setCategoryDefaults();
66 68
67 69
68 70
69}; 71};
70 72
71#endif 73#endif
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 40d8e47..75c0b2b 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1284 +1,1313 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <qbuttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51#include <qcheckbox.h>
51 52
52#include <klocale.h> 53#include <klocale.h>
53#include <kglobal.h> 54#include <kglobal.h>
54#include <kconfig.h> 55#include <kconfig.h>
55#include <kfiledialog.h> 56#include <kfiledialog.h>
56 57
57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 58KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) 59 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu)
59{ 60{
60 mServerSocket = 0; 61 mServerSocket = 0;
61 bar = new QProgressBar ( 1, 0 ); 62 bar = new QProgressBar ( 1, 0 );
62 bar->setCaption (""); 63 bar->setCaption ("");
63 64
64 int w = 300; 65 int w = 300;
65 if ( QApplication::desktop()->width() < 320 ) 66 if ( QApplication::desktop()->width() < 320 )
66 w = 220; 67 w = 220;
67 int h = bar->sizeHint().height() ; 68 int h = bar->sizeHint().height() ;
68 int dw = QApplication::desktop()->width(); 69 int dw = QApplication::desktop()->width();
69 int dh = QApplication::desktop()->height(); 70 int dh = QApplication::desktop()->height();
70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 71 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
72 if ( mPrefs->mPassiveSyncAutoStart )
73 enableQuick( false );
71 74
72} 75}
73 76
74KSyncManager::~KSyncManager() 77KSyncManager::~KSyncManager()
75{ 78{
76 delete bar; 79 delete bar;
77} 80}
78 81
79 82
80void KSyncManager::fillSyncMenu() 83void KSyncManager::fillSyncMenu()
81{ 84{
82 if ( mSyncMenu->count() ) 85 if ( mSyncMenu->count() )
83 mSyncMenu->clear(); 86 mSyncMenu->clear();
84 87
85 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 88 mSyncMenu->insertItem( i18n("Configure..."), 0 );
86 mSyncMenu->insertSeparator(); 89 mSyncMenu->insertSeparator();
87 if ( mServerSocket == 0 ) { 90 if ( mServerSocket == 0 ) {
88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 91 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
89 } else { 92 } else {
90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 93 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
91 } 94 }
92 mSyncMenu->insertSeparator(); 95 mSyncMenu->insertSeparator();
93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 96 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
94 mSyncMenu->insertSeparator(); 97 mSyncMenu->insertSeparator();
95 98
96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 99 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
97 config.setGroup("General"); 100 config.setGroup("General");
98 QStringList prof = config.readListEntry("SyncProfileNames"); 101 QStringList prof = config.readListEntry("SyncProfileNames");
99 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 102 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
100 if ( prof.count() < 2 ) { 103 if ( prof.count() < 2 ) {
101 prof.clear(); 104 prof.clear();
102#ifdef DESKTOP_VERSION 105#ifdef DESKTOP_VERSION
103#ifdef _WIN32_ 106#ifdef _WIN32_
104 prof << i18n("OutLook(not_implemented)"); 107 prof << i18n("OutLook(not_implemented)");
105#else 108#else
106 prof << i18n("KDE_Desktop"); 109 prof << i18n("KDE_Desktop");
107#endif 110#endif
108#else 111#else
109 prof << i18n("Sharp_DTM"); 112 prof << i18n("Sharp_DTM");
110#endif 113#endif
111 prof << i18n("Local_file"); 114 prof << i18n("Local_file");
112 prof << i18n("Last_file"); 115 prof << i18n("Last_file");
113 KSyncProfile* temp = new KSyncProfile (); 116 KSyncProfile* temp = new KSyncProfile ();
114 temp->setName( prof[0] ); 117 temp->setName( prof[0] );
115 temp->writeConfig(&config); 118 temp->writeConfig(&config);
116 temp->setName( prof[1] ); 119 temp->setName( prof[1] );
117 temp->writeConfig(&config); 120 temp->writeConfig(&config);
118 temp->setName( prof[2] ); 121 temp->setName( prof[2] );
119 temp->writeConfig(&config); 122 temp->writeConfig(&config);
120 config.setGroup("General"); 123 config.setGroup("General");
121 config.writeEntry("SyncProfileNames",prof); 124 config.writeEntry("SyncProfileNames",prof);
122 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 125 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
123 config.sync(); 126 config.sync();
124 delete temp; 127 delete temp;
125 } 128 }
126 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 129 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
127 mSyncProfileNames = prof; 130 mSyncProfileNames = prof;
128 unsigned int i; 131 unsigned int i;
129 for ( i = 0; i < prof.count(); ++i ) { 132 for ( i = 0; i < prof.count(); ++i ) {
130 mSyncMenu->insertItem( prof[i], 1000+i ); 133 mSyncMenu->insertItem( prof[i], 1000+i );
131 if ( i == 2 ) 134 if ( i == 2 )
132 mSyncMenu->insertSeparator(); 135 mSyncMenu->insertSeparator();
133 } 136 }
134 QDir app_dir; 137 QDir app_dir;
135 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 138 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
136 if ( mTargetApp == PWMPI) { 139 if ( mTargetApp == PWMPI) {
137 mSyncMenu->removeItem( 1000 ); 140 mSyncMenu->removeItem( 1000 );
138 } 141 }
139#ifndef DESKTOP_VERSION 142#ifndef DESKTOP_VERSION
140 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 143 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
141 mSyncMenu->removeItem( 1000 ); 144 mSyncMenu->removeItem( 1000 );
142 } 145 }
143#endif 146#endif
144 mSyncMenu->removeItem( 1002 ); 147 mSyncMenu->removeItem( 1002 );
145} 148}
146 149
147void KSyncManager::slotSyncMenu( int action ) 150void KSyncManager::slotSyncMenu( int action )
148{ 151{
149 qDebug("syncaction %d ", action); 152 qDebug("syncaction %d ", action);
150 if ( action == 0 ) { 153 if ( action == 0 ) {
151 154
152 // seems to be a Qt2 event handling bug 155 // seems to be a Qt2 event handling bug
153 // syncmenu.clear causes a segfault at first time 156 // syncmenu.clear causes a segfault at first time
154 // when we call it after the main event loop, it is ok 157 // when we call it after the main event loop, it is ok
155 // same behaviour when calling OM/Pi via QCOP for the first time 158 // same behaviour when calling OM/Pi via QCOP for the first time
156 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 159 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
157 //confSync(); 160 //confSync();
158 161
159 return; 162 return;
160 } 163 }
161 if ( action == 1 ) { 164 if ( action == 1 ) {
162 multiSync( true ); 165 multiSync( true );
163 return; 166 return;
164 } 167 }
165 if ( action == 2 ) { 168 if ( action == 2 ) {
166 enableQuick(); 169 enableQuick();
167 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 170 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
168 return; 171 return;
169 } 172 }
170 if ( action == 3 ) { 173 if ( action == 3 ) {
171 delete mServerSocket; 174 delete mServerSocket;
172 mServerSocket = 0; 175 mServerSocket = 0;
173 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 176 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
174 return; 177 return;
175 } 178 }
176 179
177 if (blockSave()) 180 if (blockSave())
178 return; 181 return;
179 182
180 setBlockSave(true); 183 setBlockSave(true);
181 184
182 mCurrentSyncProfile = action - 1000 ; 185 mCurrentSyncProfile = action - 1000 ;
183 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 186 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
184 mCurrentSyncName = mLocalMachineName ; 187 mCurrentSyncName = mLocalMachineName ;
185 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 188 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
186 KSyncProfile* temp = new KSyncProfile (); 189 KSyncProfile* temp = new KSyncProfile ();
187 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 190 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
188 temp->readConfig(&config); 191 temp->readConfig(&config);
189 mAskForPreferences = temp->getAskForPreferences(); 192 mAskForPreferences = temp->getAskForPreferences();
190 mSyncAlgoPrefs = temp->getSyncPrefs(); 193 mSyncAlgoPrefs = temp->getSyncPrefs();
191 mWriteBackFile = temp->getWriteBackFile(); 194 mWriteBackFile = temp->getWriteBackFile();
192 mWriteBackExistingOnly = temp->getWriteBackExisting(); 195 mWriteBackExistingOnly = temp->getWriteBackExisting();
193 mIsKapiFile = temp->getIsKapiFile(); 196 mIsKapiFile = temp->getIsKapiFile();
194 mWriteBackInFuture = 0; 197 mWriteBackInFuture = 0;
195 if ( temp->getWriteBackFuture() ) 198 if ( temp->getWriteBackFuture() )
196 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 199 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
197 mShowSyncSummary = temp->getShowSummaryAfterSync(); 200 mShowSyncSummary = temp->getShowSummaryAfterSync();
198 if ( action == 1000 ) { 201 if ( action == 1000 ) {
199#ifdef DESKTOP_VERSION 202#ifdef DESKTOP_VERSION
200 syncKDE(); 203 syncKDE();
201#else 204#else
202 syncSharp(); 205 syncSharp();
203#endif 206#endif
204 207
205 } else if ( action == 1001 ) { 208 } else if ( action == 1001 ) {
206 syncLocalFile(); 209 syncLocalFile();
207 210
208 } else if ( action == 1002 ) { 211 } else if ( action == 1002 ) {
209 mWriteBackFile = false; 212 mWriteBackFile = false;
210 mAskForPreferences = false; 213 mAskForPreferences = false;
211 mShowSyncSummary = false; 214 mShowSyncSummary = false;
212 mSyncAlgoPrefs = 3; 215 mSyncAlgoPrefs = 3;
213 quickSyncLocalFile(); 216 quickSyncLocalFile();
214 217
215 } else if ( action >= 1003 ) { 218 } else if ( action >= 1003 ) {
216 if ( temp->getIsLocalFileSync() ) { 219 if ( temp->getIsLocalFileSync() ) {
217 switch(mTargetApp) 220 switch(mTargetApp)
218 { 221 {
219 case (KAPI): 222 case (KAPI):
220 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 223 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
221 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 224 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
222 break; 225 break;
223 case (KOPI): 226 case (KOPI):
224 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 227 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
225 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 228 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
226 break; 229 break;
227 case (PWMPI): 230 case (PWMPI):
228 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 231 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
229 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 232 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
230 break; 233 break;
231 default: 234 default:
232 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 235 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
233 break; 236 break;
234 237
235 } 238 }
236 } else { 239 } else {
237 if ( temp->getIsPhoneSync() ) { 240 if ( temp->getIsPhoneSync() ) {
238 mPhoneDevice = temp->getPhoneDevice( ) ; 241 mPhoneDevice = temp->getPhoneDevice( ) ;
239 mPhoneConnection = temp->getPhoneConnection( ); 242 mPhoneConnection = temp->getPhoneConnection( );
240 mPhoneModel = temp->getPhoneModel( ); 243 mPhoneModel = temp->getPhoneModel( );
241 syncPhone(); 244 syncPhone();
242 } else if ( temp->getIsPiSync() ) { 245 } else if ( temp->getIsPiSync() ) {
243 if ( mTargetApp == KAPI ) { 246 if ( mTargetApp == KAPI ) {
244 mPassWordPiSync = temp->getRemotePwAB(); 247 mPassWordPiSync = temp->getRemotePwAB();
245 mActiveSyncPort = temp->getRemotePortAB(); 248 mActiveSyncPort = temp->getRemotePortAB();
246 mActiveSyncIP = temp->getRemoteIPAB(); 249 mActiveSyncIP = temp->getRemoteIPAB();
247 } else if ( mTargetApp == KOPI ) { 250 } else if ( mTargetApp == KOPI ) {
248 mPassWordPiSync = temp->getRemotePw(); 251 mPassWordPiSync = temp->getRemotePw();
249 mActiveSyncPort = temp->getRemotePort(); 252 mActiveSyncPort = temp->getRemotePort();
250 mActiveSyncIP = temp->getRemoteIP(); 253 mActiveSyncIP = temp->getRemoteIP();
251 } else { 254 } else {
252 mPassWordPiSync = temp->getRemotePwPWM(); 255 mPassWordPiSync = temp->getRemotePwPWM();
253 mActiveSyncPort = temp->getRemotePortPWM(); 256 mActiveSyncPort = temp->getRemotePortPWM();
254 mActiveSyncIP = temp->getRemoteIPPWM(); 257 mActiveSyncIP = temp->getRemoteIPPWM();
255 } 258 }
256 syncPi(); 259 syncPi();
257 while ( !mPisyncFinished ) { 260 while ( !mPisyncFinished ) {
258 //qDebug("waiting "); 261 //qDebug("waiting ");
259 qApp->processEvents(); 262 qApp->processEvents();
260 } 263 }
261 } else 264 } else
262 syncRemote( temp ); 265 syncRemote( temp );
263 266
264 } 267 }
265 } 268 }
266 delete temp; 269 delete temp;
267 setBlockSave(false); 270 setBlockSave(false);
268} 271}
269 272
270void KSyncManager::enableQuick() 273void KSyncManager::enableQuick( bool ask )
271{ 274{
272 QDialog dia ( 0, "input-dialog", true ); 275 bool autoStart;
273 QLineEdit lab ( &dia ); 276 if ( ask ) {
274 QVBoxLayout lay( &dia ); 277 QDialog dia ( 0, "input-dialog", true );
275 lab.setText( mPrefs->mPassiveSyncPort ); 278 QLineEdit lab ( &dia );
276 lay.setMargin(7); 279 QVBoxLayout lay( &dia );
277 lay.setSpacing(7); 280 lab.setText( mPrefs->mPassiveSyncPort );
278 int po = 9197+mTargetApp; 281 lay.setMargin(7);
279 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 282 lay.setSpacing(7);
280 lay.addWidget( &label); 283 int po = 9197+mTargetApp;
281 lay.addWidget( &lab); 284 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
282 285 lay.addWidget( &label);
283 QLineEdit lepw ( &dia ); 286 lay.addWidget( &lab);
284 lepw.setText( mPrefs->mPassiveSyncPw ); 287
285 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 288 QLineEdit lepw ( &dia );
286 lay.addWidget( &label2); 289 lepw.setText( mPrefs->mPassiveSyncPw );
287 lay.addWidget( &lepw); 290 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
288 dia.setFixedSize( 230,80 ); 291 lay.addWidget( &label2);
289 dia.setCaption( i18n("Enter port for Pi-Sync") ); 292 lay.addWidget( &lepw);
290 QPushButton pb ( "OK", &dia); 293 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
291 lay.addWidget( &pb ); 294 lay.addWidget( &autostart);
292 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 295 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
293 dia.show(); 296#ifdef DESKTOP_VERSION
294 if ( ! dia.exec() ) 297#ifdef _WIN32_
295 return; 298 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
296 dia.hide(); 299#else
297 qApp->processEvents(); 300 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
298 mPrefs->mPassiveSyncPw = lepw.text(); 301#endif
299 mPrefs->mPassiveSyncPort = lab.text(); 302 lay.addWidget( &syncdesktop);
303#else
304 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
305 syncdesktop.hide();
306#endif
307 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
308
309 dia.setFixedSize( 230,120 );
310 dia.setCaption( i18n("Enter port for Pi-Sync") );
311 QPushButton pb ( "OK", &dia);
312 lay.addWidget( &pb );
313 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
314 dia.show();
315 if ( ! dia.exec() )
316 return;
317 dia.hide();
318 qApp->processEvents();
319 mPrefs->mPassiveSyncPw = lepw.text();
320 mPrefs->mPassiveSyncPort = lab.text();
321 autoStart = autostart.isChecked();
322 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
323 }
324 else
325 autoStart = mPrefs->mPassiveSyncAutoStart;
300 bool ok; 326 bool ok;
327 mPrefs->mPassiveSyncAutoStart = false;
301 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 328 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
302 if ( ! ok ) { 329 if ( ! ok ) {
303 KMessageBox::information( 0, i18n("No valid port")); 330 KMessageBox::information( 0, i18n("No valid port"));
304 return; 331 return;
305 } 332 }
306 //qDebug("port %d ", port); 333 //qDebug("port %d ", port);
307 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 334 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
308 mServerSocket->setFileName( defaultFileName() ); 335 mServerSocket->setFileName( defaultFileName() );
309 //qDebug("connected "); 336 //qDebug("connected ");
310 if ( !mServerSocket->ok() ) { 337 if ( !mServerSocket->ok() ) {
311 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 338 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
312 delete mServerSocket; 339 delete mServerSocket;
313 mServerSocket = 0; 340 mServerSocket = 0;
314 return; 341 return;
315 } 342 }
343
344 mPrefs->mPassiveSyncAutoStart = autoStart;
316 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 345 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
317 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 346 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
318} 347}
319 348
320void KSyncManager::syncLocalFile() 349void KSyncManager::syncLocalFile()
321{ 350{
322 351
323 QString fn =mPrefs->mLastSyncedLocalFile; 352 QString fn =mPrefs->mLastSyncedLocalFile;
324 QString ext; 353 QString ext;
325 354
326 switch(mTargetApp) 355 switch(mTargetApp)
327 { 356 {
328 case (KAPI): 357 case (KAPI):
329 ext = "(*.vcf)"; 358 ext = "(*.vcf)";
330 break; 359 break;
331 case (KOPI): 360 case (KOPI):
332 ext = "(*.ics/*.vcs)"; 361 ext = "(*.ics/*.vcs)";
333 break; 362 break;
334 case (PWMPI): 363 case (PWMPI):
335 ext = "(*.pwm)"; 364 ext = "(*.pwm)";
336 break; 365 break;
337 default: 366 default:
338 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 367 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
339 break; 368 break;
340 369
341 } 370 }
342 371
343 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 372 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
344 if ( fn == "" ) 373 if ( fn == "" )
345 return; 374 return;
346 if ( syncWithFile( fn, false ) ) { 375 if ( syncWithFile( fn, false ) ) {
347 qDebug("syncLocalFile() successful "); 376 qDebug("syncLocalFile() successful ");
348 } 377 }
349 378
350} 379}
351 380
352bool KSyncManager::syncWithFile( QString fn , bool quick ) 381bool KSyncManager::syncWithFile( QString fn , bool quick )
353{ 382{
354 bool ret = false; 383 bool ret = false;
355 QFileInfo info; 384 QFileInfo info;
356 info.setFile( fn ); 385 info.setFile( fn );
357 QString mess; 386 QString mess;
358 bool loadbup = true; 387 bool loadbup = true;
359 if ( !info. exists() ) { 388 if ( !info. exists() ) {
360 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 389 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
361 int result = QMessageBox::warning( mParent, i18n("Warning!"), 390 int result = QMessageBox::warning( mParent, i18n("Warning!"),
362 mess ); 391 mess );
363 return ret; 392 return ret;
364 } 393 }
365 int result = 0; 394 int result = 0;
366 if ( !quick ) { 395 if ( !quick ) {
367 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 396 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
368 result = QMessageBox::warning( mParent, i18n("Warning!"), 397 result = QMessageBox::warning( mParent, i18n("Warning!"),
369 mess, 398 mess,
370 i18n("Sync"), i18n("Cancel"), 0, 399 i18n("Sync"), i18n("Cancel"), 0,
371 0, 1 ); 400 0, 1 );
372 if ( result ) 401 if ( result )
373 return false; 402 return false;
374 } 403 }
375 if ( mAskForPreferences ) 404 if ( mAskForPreferences )
376 edit_sync_options(); 405 edit_sync_options();
377 if ( result == 0 ) { 406 if ( result == 0 ) {
378 //qDebug("Now sycing ... "); 407 //qDebug("Now sycing ... ");
379 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 408 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
380 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 409 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
381 else 410 else
382 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 411 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
383 if ( ! quick ) 412 if ( ! quick )
384 mPrefs->mLastSyncedLocalFile = fn; 413 mPrefs->mLastSyncedLocalFile = fn;
385 } 414 }
386 return ret; 415 return ret;
387} 416}
388 417
389void KSyncManager::quickSyncLocalFile() 418void KSyncManager::quickSyncLocalFile()
390{ 419{
391 420
392 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 421 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
393 qDebug("quick syncLocalFile() successful "); 422 qDebug("quick syncLocalFile() successful ");
394 423
395 } 424 }
396} 425}
397 426
398void KSyncManager::multiSync( bool askforPrefs ) 427void KSyncManager::multiSync( bool askforPrefs )
399{ 428{
400 if (blockSave()) 429 if (blockSave())
401 return; 430 return;
402 setBlockSave(true); 431 setBlockSave(true);
403 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 432 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
404 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 433 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
405 question, 434 question,
406 i18n("Yes"), i18n("No"), 435 i18n("Yes"), i18n("No"),
407 0, 0 ) != 0 ) { 436 0, 0 ) != 0 ) {
408 setBlockSave(false); 437 setBlockSave(false);
409 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 438 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
410 return; 439 return;
411 } 440 }
412 mCurrentSyncDevice = i18n("Multiple profiles") ; 441 mCurrentSyncDevice = i18n("Multiple profiles") ;
413 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 442 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
414 if ( askforPrefs ) { 443 if ( askforPrefs ) {
415 edit_sync_options(); 444 edit_sync_options();
416 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 445 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
417 } 446 }
418 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 447 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
419 qApp->processEvents(); 448 qApp->processEvents();
420 int num = ringSync() ; 449 int num = ringSync() ;
421 if ( num > 1 ) 450 if ( num > 1 )
422 ringSync(); 451 ringSync();
423 setBlockSave(false); 452 setBlockSave(false);
424 if ( num ) 453 if ( num )
425 emit save(); 454 emit save();
426 if ( num ) 455 if ( num )
427 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 456 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
428 else 457 else
429 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 458 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
430 return; 459 return;
431} 460}
432 461
433int KSyncManager::ringSync() 462int KSyncManager::ringSync()
434{ 463{
435 int syncedProfiles = 0; 464 int syncedProfiles = 0;
436 unsigned int i; 465 unsigned int i;
437 QTime timer; 466 QTime timer;
438 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 467 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
439 QStringList syncProfileNames = mSyncProfileNames; 468 QStringList syncProfileNames = mSyncProfileNames;
440 KSyncProfile* temp = new KSyncProfile (); 469 KSyncProfile* temp = new KSyncProfile ();
441 mAskForPreferences = false; 470 mAskForPreferences = false;
442 for ( i = 0; i < syncProfileNames.count(); ++i ) { 471 for ( i = 0; i < syncProfileNames.count(); ++i ) {
443 mCurrentSyncProfile = i; 472 mCurrentSyncProfile = i;
444 temp->setName(syncProfileNames[mCurrentSyncProfile]); 473 temp->setName(syncProfileNames[mCurrentSyncProfile]);
445 temp->readConfig(&config); 474 temp->readConfig(&config);
446 475
447 bool includeInRingSync; 476 bool includeInRingSync;
448 switch(mTargetApp) 477 switch(mTargetApp)
449 { 478 {
450 case (KAPI): 479 case (KAPI):
451 includeInRingSync = temp->getIncludeInRingSyncAB(); 480 includeInRingSync = temp->getIncludeInRingSyncAB();
452 break; 481 break;
453 case (KOPI): 482 case (KOPI):
454 includeInRingSync = temp->getIncludeInRingSync(); 483 includeInRingSync = temp->getIncludeInRingSync();
455 break; 484 break;
456 case (PWMPI): 485 case (PWMPI):
457 includeInRingSync = temp->getIncludeInRingSyncPWM(); 486 includeInRingSync = temp->getIncludeInRingSyncPWM();
458 break; 487 break;
459 default: 488 default:
460 qDebug("KSyncManager::ringSync: invalid apptype selected"); 489 qDebug("KSyncManager::ringSync: invalid apptype selected");
461 break; 490 break;
462 491
463 } 492 }
464 493
465 494
466 if ( includeInRingSync && ( i < 1 || i > 2 )) { 495 if ( includeInRingSync && ( i < 1 || i > 2 )) {
467 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 496 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
468 ++syncedProfiles; 497 ++syncedProfiles;
469 // mAskForPreferences = temp->getAskForPreferences(); 498 // mAskForPreferences = temp->getAskForPreferences();
470 mWriteBackFile = temp->getWriteBackFile(); 499 mWriteBackFile = temp->getWriteBackFile();
471 mWriteBackExistingOnly = temp->getWriteBackExisting(); 500 mWriteBackExistingOnly = temp->getWriteBackExisting();
472 mWriteBackInFuture = 0; 501 mWriteBackInFuture = 0;
473 if ( temp->getWriteBackFuture() ) 502 if ( temp->getWriteBackFuture() )
474 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 503 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
475 mShowSyncSummary = false; 504 mShowSyncSummary = false;
476 mCurrentSyncDevice = syncProfileNames[i] ; 505 mCurrentSyncDevice = syncProfileNames[i] ;
477 mCurrentSyncName = mLocalMachineName; 506 mCurrentSyncName = mLocalMachineName;
478 if ( i == 0 ) { 507 if ( i == 0 ) {
479#ifdef DESKTOP_VERSION 508#ifdef DESKTOP_VERSION
480 syncKDE(); 509 syncKDE();
481#else 510#else
482 syncSharp(); 511 syncSharp();
483#endif 512#endif
484 } else { 513 } else {
485 if ( temp->getIsLocalFileSync() ) { 514 if ( temp->getIsLocalFileSync() ) {
486 switch(mTargetApp) 515 switch(mTargetApp)
487 { 516 {
488 case (KAPI): 517 case (KAPI):
489 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 518 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
490 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 519 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
491 break; 520 break;
492 case (KOPI): 521 case (KOPI):
493 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 522 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
494 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 523 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
495 break; 524 break;
496 case (PWMPI): 525 case (PWMPI):
497 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 526 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
498 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 527 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
499 break; 528 break;
500 default: 529 default:
501 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 530 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
502 break; 531 break;
503 } 532 }
504 } else { 533 } else {
505 if ( temp->getIsPhoneSync() ) { 534 if ( temp->getIsPhoneSync() ) {
506 mPhoneDevice = temp->getPhoneDevice( ) ; 535 mPhoneDevice = temp->getPhoneDevice( ) ;
507 mPhoneConnection = temp->getPhoneConnection( ); 536 mPhoneConnection = temp->getPhoneConnection( );
508 mPhoneModel = temp->getPhoneModel( ); 537 mPhoneModel = temp->getPhoneModel( );
509 syncPhone(); 538 syncPhone();
510 } else if ( temp->getIsPiSync() ) { 539 } else if ( temp->getIsPiSync() ) {
511 if ( mTargetApp == KAPI ) { 540 if ( mTargetApp == KAPI ) {
512 mPassWordPiSync = temp->getRemotePwAB(); 541 mPassWordPiSync = temp->getRemotePwAB();
513 mActiveSyncPort = temp->getRemotePortAB(); 542 mActiveSyncPort = temp->getRemotePortAB();
514 mActiveSyncIP = temp->getRemoteIPAB(); 543 mActiveSyncIP = temp->getRemoteIPAB();
515 } else if ( mTargetApp == KOPI ) { 544 } else if ( mTargetApp == KOPI ) {
516 mPassWordPiSync = temp->getRemotePw(); 545 mPassWordPiSync = temp->getRemotePw();
517 mActiveSyncPort = temp->getRemotePort(); 546 mActiveSyncPort = temp->getRemotePort();
518 mActiveSyncIP = temp->getRemoteIP(); 547 mActiveSyncIP = temp->getRemoteIP();
519 } else { 548 } else {
520 mPassWordPiSync = temp->getRemotePwPWM(); 549 mPassWordPiSync = temp->getRemotePwPWM();
521 mActiveSyncPort = temp->getRemotePortPWM(); 550 mActiveSyncPort = temp->getRemotePortPWM();
522 mActiveSyncIP = temp->getRemoteIPPWM(); 551 mActiveSyncIP = temp->getRemoteIPPWM();
523 } 552 }
524 syncPi(); 553 syncPi();
525 while ( !mPisyncFinished ) { 554 while ( !mPisyncFinished ) {
526 //qDebug("waiting "); 555 //qDebug("waiting ");
527 qApp->processEvents(); 556 qApp->processEvents();
528 } 557 }
529 timer.start(); 558 timer.start();
530 while ( timer.elapsed () < 2000 ) { 559 while ( timer.elapsed () < 2000 ) {
531 qApp->processEvents(); 560 qApp->processEvents();
532 } 561 }
533 } else 562 } else
534 syncRemote( temp, false ); 563 syncRemote( temp, false );
535 564
536 } 565 }
537 } 566 }
538 timer.start(); 567 timer.start();
539 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 568 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
540 while ( timer.elapsed () < 2000 ) { 569 while ( timer.elapsed () < 2000 ) {
541 qApp->processEvents(); 570 qApp->processEvents();
542#ifndef _WIN32_ 571#ifndef _WIN32_
543 sleep (1); 572 sleep (1);
544#endif 573#endif
545 } 574 }
546 575
547 } 576 }
548 577
549 } 578 }
550 delete temp; 579 delete temp;
551 return syncedProfiles; 580 return syncedProfiles;
552} 581}
553 582
554void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 583void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
555{ 584{
556 QString question; 585 QString question;
557 if ( ask ) { 586 if ( ask ) {
558 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 587 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
559 if ( QMessageBox::information( mParent, i18n("Sync"), 588 if ( QMessageBox::information( mParent, i18n("Sync"),
560 question, 589 question,
561 i18n("Yes"), i18n("No"), 590 i18n("Yes"), i18n("No"),
562 0, 0 ) != 0 ) 591 0, 0 ) != 0 )
563 return; 592 return;
564 } 593 }
565 594
566 QString preCommand; 595 QString preCommand;
567 QString localTempFile; 596 QString localTempFile;
568 QString postCommand; 597 QString postCommand;
569 598
570 switch(mTargetApp) 599 switch(mTargetApp)
571 { 600 {
572 case (KAPI): 601 case (KAPI):
573 preCommand = prof->getPreSyncCommandAB(); 602 preCommand = prof->getPreSyncCommandAB();
574 postCommand = prof->getPostSyncCommandAB(); 603 postCommand = prof->getPostSyncCommandAB();
575 localTempFile = prof->getLocalTempFileAB(); 604 localTempFile = prof->getLocalTempFileAB();
576 break; 605 break;
577 case (KOPI): 606 case (KOPI):
578 preCommand = prof->getPreSyncCommand(); 607 preCommand = prof->getPreSyncCommand();
579 postCommand = prof->getPostSyncCommand(); 608 postCommand = prof->getPostSyncCommand();
580 localTempFile = prof->getLocalTempFile(); 609 localTempFile = prof->getLocalTempFile();
581 break; 610 break;
582 case (PWMPI): 611 case (PWMPI):
583 preCommand = prof->getPreSyncCommandPWM(); 612 preCommand = prof->getPreSyncCommandPWM();
584 postCommand = prof->getPostSyncCommandPWM(); 613 postCommand = prof->getPostSyncCommandPWM();
585 localTempFile = prof->getLocalTempFilePWM(); 614 localTempFile = prof->getLocalTempFilePWM();
586 break; 615 break;
587 default: 616 default:
588 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 617 qDebug("KSyncManager::syncRemote: invalid apptype selected");
589 break; 618 break;
590 } 619 }
591 620
592 621
593 int fi; 622 int fi;
594 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 623 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
595 QString pwd = getPassword(); 624 QString pwd = getPassword();
596 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 625 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
597 626
598 } 627 }
599 int maxlen = 30; 628 int maxlen = 30;
600 if ( QApplication::desktop()->width() > 320 ) 629 if ( QApplication::desktop()->width() > 320 )
601 maxlen += 25; 630 maxlen += 25;
602 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 631 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
603 int fileSize = 0; 632 int fileSize = 0;
604 int result = system ( preCommand ); 633 int result = system ( preCommand );
605 // 0 : okay 634 // 0 : okay
606 // 256: no such file or dir 635 // 256: no such file or dir
607 // 636 //
608 qDebug("Sync: Remote copy result(0 = okay): %d ",result ); 637 qDebug("Sync: Remote copy result(0 = okay): %d ",result );
609 if ( result != 0 ) { 638 if ( result != 0 ) {
610 unsigned int len = maxlen; 639 unsigned int len = maxlen;
611 while ( len < preCommand.length() ) { 640 while ( len < preCommand.length() ) {
612 preCommand.insert( len , "\n" ); 641 preCommand.insert( len , "\n" );
613 len += maxlen +2; 642 len += maxlen +2;
614 } 643 }
615 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 644 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
616 QMessageBox::information( mParent, i18n("Sync - ERROR"), 645 QMessageBox::information( mParent, i18n("Sync - ERROR"),
617 question, 646 question,
618 i18n("Okay!")) ; 647 i18n("Okay!")) ;
619 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 648 mParent->topLevelWidget()->setCaption ("KDE-Pim");
620 return; 649 return;
621 } 650 }
622 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 651 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
623 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 652 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
624 653
625 if ( syncWithFile( localTempFile, true ) ) { 654 if ( syncWithFile( localTempFile, true ) ) {
626 655
627 if ( mWriteBackFile ) { 656 if ( mWriteBackFile ) {
628 int fi; 657 int fi;
629 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 658 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
630 QString pwd = getPassword(); 659 QString pwd = getPassword();
631 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 660 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
632 661
633 } 662 }
634 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 663 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
635 result = system ( postCommand ); 664 result = system ( postCommand );
636 qDebug("Sync:Writing back file result: %d ", result); 665 qDebug("Sync:Writing back file result: %d ", result);
637 if ( result != 0 ) { 666 if ( result != 0 ) {
638 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 667 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
639 return; 668 return;
640 } else { 669 } else {
641 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 670 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
642 } 671 }
643 } 672 }
644 } 673 }
645 return; 674 return;
646} 675}
647void KSyncManager::edit_pisync_options() 676void KSyncManager::edit_pisync_options()
648{ 677{
649 QDialog dia( mParent, "dia", true ); 678 QDialog dia( mParent, "dia", true );
650 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 679 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
651 QVBoxLayout lay ( &dia ); 680 QVBoxLayout lay ( &dia );
652 lay.setSpacing( 5 ); 681 lay.setSpacing( 5 );
653 lay.setMargin( 3 ); 682 lay.setMargin( 3 );
654 QLabel lab1 ( i18n("Password for remote access:"), &dia); 683 QLabel lab1 ( i18n("Password for remote access:"), &dia);
655 lay.addWidget( &lab1 ); 684 lay.addWidget( &lab1 );
656 QLineEdit le1 (&dia ); 685 QLineEdit le1 (&dia );
657 lay.addWidget( &le1 ); 686 lay.addWidget( &le1 );
658 QLabel lab2 ( i18n("Remote IP address:"), &dia); 687 QLabel lab2 ( i18n("Remote IP address:"), &dia);
659 lay.addWidget( &lab2 ); 688 lay.addWidget( &lab2 );
660 QLineEdit le2 (&dia ); 689 QLineEdit le2 (&dia );
661 lay.addWidget( &le2 ); 690 lay.addWidget( &le2 );
662 QLabel lab3 ( i18n("Remote port number:"), &dia); 691 QLabel lab3 ( i18n("Remote port number:"), &dia);
663 lay.addWidget( &lab3 ); 692 lay.addWidget( &lab3 );
664 QLineEdit le3 (&dia ); 693 QLineEdit le3 (&dia );
665 lay.addWidget( &le3 ); 694 lay.addWidget( &le3 );
666 QPushButton pb ( "OK", &dia); 695 QPushButton pb ( "OK", &dia);
667 lay.addWidget( &pb ); 696 lay.addWidget( &pb );
668 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 697 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
669 le1.setText( mPassWordPiSync ); 698 le1.setText( mPassWordPiSync );
670 le2.setText( mActiveSyncIP ); 699 le2.setText( mActiveSyncIP );
671 le3.setText( mActiveSyncPort ); 700 le3.setText( mActiveSyncPort );
672 if ( dia.exec() ) { 701 if ( dia.exec() ) {
673 mPassWordPiSync = le1.text(); 702 mPassWordPiSync = le1.text();
674 mActiveSyncPort = le3.text(); 703 mActiveSyncPort = le3.text();
675 mActiveSyncIP = le2.text(); 704 mActiveSyncIP = le2.text();
676 } 705 }
677 706
678} 707}
679void KSyncManager::edit_sync_options() 708void KSyncManager::edit_sync_options()
680{ 709{
681 710
682 QDialog dia( mParent, "dia", true ); 711 QDialog dia( mParent, "dia", true );
683 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 712 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
684 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 713 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
685 QVBoxLayout lay ( &dia ); 714 QVBoxLayout lay ( &dia );
686 lay.setSpacing( 2 ); 715 lay.setSpacing( 2 );
687 lay.setMargin( 3 ); 716 lay.setMargin( 3 );
688 lay.addWidget(&gr); 717 lay.addWidget(&gr);
689 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 718 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
690 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 719 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
691 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 720 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
692 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 721 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
693 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 722 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
694 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 723 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
695 //QRadioButton both( i18n("Take both on conflict"), &gr ); 724 //QRadioButton both( i18n("Take both on conflict"), &gr );
696 QPushButton pb ( "OK", &dia); 725 QPushButton pb ( "OK", &dia);
697 lay.addWidget( &pb ); 726 lay.addWidget( &pb );
698 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 727 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
699 switch ( mSyncAlgoPrefs ) { 728 switch ( mSyncAlgoPrefs ) {
700 case 0: 729 case 0:
701 loc.setChecked( true); 730 loc.setChecked( true);
702 break; 731 break;
703 case 1: 732 case 1:
704 rem.setChecked( true ); 733 rem.setChecked( true );
705 break; 734 break;
706 case 2: 735 case 2:
707 newest.setChecked( true); 736 newest.setChecked( true);
708 break; 737 break;
709 case 3: 738 case 3:
710 ask.setChecked( true); 739 ask.setChecked( true);
711 break; 740 break;
712 case 4: 741 case 4:
713 f_loc.setChecked( true); 742 f_loc.setChecked( true);
714 break; 743 break;
715 case 5: 744 case 5:
716 f_rem.setChecked( true); 745 f_rem.setChecked( true);
717 break; 746 break;
718 case 6: 747 case 6:
719 // both.setChecked( true); 748 // both.setChecked( true);
720 break; 749 break;
721 default: 750 default:
722 break; 751 break;
723 } 752 }
724 if ( dia.exec() ) { 753 if ( dia.exec() ) {
725 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 754 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
726 } 755 }
727 756
728 757
729} 758}
730 759
731QString KSyncManager::getPassword( ) 760QString KSyncManager::getPassword( )
732{ 761{
733 QString retfile = ""; 762 QString retfile = "";
734 QDialog dia ( mParent, "input-dialog", true ); 763 QDialog dia ( mParent, "input-dialog", true );
735 QLineEdit lab ( &dia ); 764 QLineEdit lab ( &dia );
736 lab.setEchoMode( QLineEdit::Password ); 765 lab.setEchoMode( QLineEdit::Password );
737 QVBoxLayout lay( &dia ); 766 QVBoxLayout lay( &dia );
738 lay.setMargin(7); 767 lay.setMargin(7);
739 lay.setSpacing(7); 768 lay.setSpacing(7);
740 lay.addWidget( &lab); 769 lay.addWidget( &lab);
741 dia.setFixedSize( 230,50 ); 770 dia.setFixedSize( 230,50 );
742 dia.setCaption( i18n("Enter password") ); 771 dia.setCaption( i18n("Enter password") );
743 QPushButton pb ( "OK", &dia); 772 QPushButton pb ( "OK", &dia);
744 lay.addWidget( &pb ); 773 lay.addWidget( &pb );
745 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 774 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
746 dia.show(); 775 dia.show();
747 int res = dia.exec(); 776 int res = dia.exec();
748 if ( res ) 777 if ( res )
749 retfile = lab.text(); 778 retfile = lab.text();
750 dia.hide(); 779 dia.hide();
751 qApp->processEvents(); 780 qApp->processEvents();
752 return retfile; 781 return retfile;
753 782
754} 783}
755 784
756 785
757void KSyncManager::confSync() 786void KSyncManager::confSync()
758{ 787{
759 static KSyncPrefsDialog* sp = 0; 788 static KSyncPrefsDialog* sp = 0;
760 if ( ! sp ) { 789 if ( ! sp ) {
761 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 790 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
762 } 791 }
763 sp->usrReadConfig(); 792 sp->usrReadConfig();
764#ifndef DESKTOP_VERSION 793#ifndef DESKTOP_VERSION
765 sp->showMaximized(); 794 sp->showMaximized();
766#else 795#else
767 sp->show(); 796 sp->show();
768#endif 797#endif
769 sp->exec(); 798 sp->exec();
770 mSyncProfileNames = sp->getSyncProfileNames(); 799 mSyncProfileNames = sp->getSyncProfileNames();
771 mLocalMachineName = sp->getLocalMachineName (); 800 mLocalMachineName = sp->getLocalMachineName ();
772 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 801 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
773} 802}
774void KSyncManager::syncKDE() 803void KSyncManager::syncKDE()
775{ 804{
776 emit save(); 805 emit save();
777 switch(mTargetApp) 806 switch(mTargetApp)
778 { 807 {
779 case (KAPI): 808 case (KAPI):
780 809
781 break; 810 break;
782 case (KOPI): 811 case (KOPI):
783 { 812 {
784#ifdef DESKTOP_VERSION 813#ifdef DESKTOP_VERSION
785 QString command = qApp->applicationDirPath () + "/kdecaldump"; 814 QString command = qApp->applicationDirPath () + "/kdecaldump";
786#else 815#else
787 QString command = "kdecaldump"; 816 QString command = "kdecaldump";
788#endif 817#endif
789 if ( ! QFile::exists ( command ) ) 818 if ( ! QFile::exists ( command ) )
790 command = "kdecaldump"; 819 command = "kdecaldump";
791 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 820 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
792 system ( command.latin1()); 821 system ( command.latin1());
793 if ( syncWithFile( fileName,true ) ) { 822 if ( syncWithFile( fileName,true ) ) {
794 if ( mWriteBackFile ) { 823 if ( mWriteBackFile ) {
795 command += " --read"; 824 command += " --read";
796 system ( command.latin1()); 825 system ( command.latin1());
797 } 826 }
798 } 827 }
799 828
800 } 829 }
801 break; 830 break;
802 case (PWMPI): 831 case (PWMPI):
803 832
804 break; 833 break;
805 default: 834 default:
806 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 835 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
807 break; 836 break;
808 837
809 } 838 }
810} 839}
811 840
812void KSyncManager::syncSharp() 841void KSyncManager::syncSharp()
813{ 842{
814 843
815 if ( ! syncExternalApplication("sharp") ) 844 if ( ! syncExternalApplication("sharp") )
816 qDebug("ERROR sync sharp "); 845 qDebug("ERROR sync sharp ");
817} 846}
818 847
819bool KSyncManager::syncExternalApplication(QString resource) 848bool KSyncManager::syncExternalApplication(QString resource)
820{ 849{
821 850
822 emit save(); 851 emit save();
823 852
824 if ( mAskForPreferences ) 853 if ( mAskForPreferences )
825 edit_sync_options(); 854 edit_sync_options();
826 855
827 qDebug("Sync extern %s", resource.latin1()); 856 qDebug("Sync extern %s", resource.latin1());
828 857
829 bool syncOK = mImplementation->syncExternal(this, resource); 858 bool syncOK = mImplementation->syncExternal(this, resource);
830 859
831 return syncOK; 860 return syncOK;
832 861
833} 862}
834 863
835void KSyncManager::syncPhone() 864void KSyncManager::syncPhone()
836{ 865{
837 866
838 syncExternalApplication("phone"); 867 syncExternalApplication("phone");
839 868
840} 869}
841 870
842void KSyncManager::showProgressBar(int percentage, QString caption, int total) 871void KSyncManager::showProgressBar(int percentage, QString caption, int total)
843{ 872{
844 if (!bar->isVisible()) 873 if (!bar->isVisible())
845 { 874 {
846 bar->setCaption (caption); 875 bar->setCaption (caption);
847 bar->setTotalSteps ( total ) ; 876 bar->setTotalSteps ( total ) ;
848 877
849 bar->show(); 878 bar->show();
850 } 879 }
851 880
852 bar->setProgress( percentage ); 881 bar->setProgress( percentage );
853} 882}
854 883
855void KSyncManager::hideProgressBar() 884void KSyncManager::hideProgressBar()
856{ 885{
857 bar->hide(); 886 bar->hide();
858} 887}
859 888
860bool KSyncManager::isProgressBarCanceled() 889bool KSyncManager::isProgressBarCanceled()
861{ 890{
862 return !bar->isVisible(); 891 return !bar->isVisible();
863} 892}
864 893
865QString KSyncManager::syncFileName() 894QString KSyncManager::syncFileName()
866{ 895{
867 896
868 QString fn = "tempfile"; 897 QString fn = "tempfile";
869 switch(mTargetApp) 898 switch(mTargetApp)
870 { 899 {
871 case (KAPI): 900 case (KAPI):
872 fn = "tempsyncab.vcf"; 901 fn = "tempsyncab.vcf";
873 break; 902 break;
874 case (KOPI): 903 case (KOPI):
875 fn = "tempsynccal.ics"; 904 fn = "tempsynccal.ics";
876 break; 905 break;
877 case (PWMPI): 906 case (PWMPI):
878 fn = "tempsyncpw.pwm"; 907 fn = "tempsyncpw.pwm";
879 break; 908 break;
880 default: 909 default:
881 break; 910 break;
882 } 911 }
883#ifdef _WIN32_ 912#ifdef _WIN32_
884 return locateLocal( "tmp", fn ); 913 return locateLocal( "tmp", fn );
885#else 914#else
886 return (QString( "/tmp/" )+ fn ); 915 return (QString( "/tmp/" )+ fn );
887#endif 916#endif
888} 917}
889 918
890void KSyncManager::syncPi() 919void KSyncManager::syncPi()
891{ 920{
892 mPisyncFinished = false; 921 mPisyncFinished = false;
893 qApp->processEvents(); 922 qApp->processEvents();
894 if ( mAskForPreferences ) 923 if ( mAskForPreferences )
895 edit_pisync_options(); 924 edit_pisync_options();
896 bool ok; 925 bool ok;
897 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 926 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
898 if ( ! ok ) { 927 if ( ! ok ) {
899 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 928 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
900 return; 929 return;
901 } 930 }
902 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 931 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
903 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 932 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
904 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 933 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
905 commandSocket->readFile( syncFileName() ); 934 commandSocket->readFile( syncFileName() );
906} 935}
907 936
908void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 937void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
909{ 938{
910 //enum { success, errorW, errorR, quiet }; 939 //enum { success, errorW, errorR, quiet };
911 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 940 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
912 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 941 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
913 delete s; 942 delete s;
914 if ( state == KCommandSocket::errorR ) { 943 if ( state == KCommandSocket::errorR ) {
915 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 944 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
916 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 945 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
917 commandSocket->sendStop(); 946 commandSocket->sendStop();
918 } 947 }
919 mPisyncFinished = true; 948 mPisyncFinished = true;
920 return; 949 return;
921 950
922 } else if ( state == KCommandSocket::errorW ) { 951 } else if ( state == KCommandSocket::errorW ) {
923 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 952 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
924 mPisyncFinished = true; 953 mPisyncFinished = true;
925 954
926 } else if ( state == KCommandSocket::successR ) { 955 } else if ( state == KCommandSocket::successR ) {
927 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 956 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
928 957
929 } else if ( state == KCommandSocket::successW ) { 958 } else if ( state == KCommandSocket::successW ) {
930 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 959 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
931 mPisyncFinished = true; 960 mPisyncFinished = true;
932 } 961 }
933 962
934 delete s; 963 delete s;
935} 964}
936 965
937void KSyncManager::readFileFromSocket() 966void KSyncManager::readFileFromSocket()
938{ 967{
939 QString fileName = syncFileName(); 968 QString fileName = syncFileName();
940 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 969 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
941 if ( ! syncWithFile( fileName , true ) ) { 970 if ( ! syncWithFile( fileName , true ) ) {
942 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 971 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
943 mPisyncFinished = true; 972 mPisyncFinished = true;
944 return; 973 return;
945 } 974 }
946 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 975 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
947 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 976 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
948 if ( mWriteBackFile ) 977 if ( mWriteBackFile )
949 commandSocket->writeFile( fileName ); 978 commandSocket->writeFile( fileName );
950 else { 979 else {
951 commandSocket->sendStop(); 980 commandSocket->sendStop();
952 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 981 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
953 mPisyncFinished = true; 982 mPisyncFinished = true;
954 } 983 }
955} 984}
956 985
957KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 986KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
958{ 987{
959 mPassWord = pw; 988 mPassWord = pw;
960 mSocket = 0; 989 mSocket = 0;
961 mSyncActionDialog = 0; 990 mSyncActionDialog = 0;
962 blockRC = false; 991 blockRC = false;
963}; 992};
964 993
965void KServerSocket::newConnection ( int socket ) 994void KServerSocket::newConnection ( int socket )
966{ 995{
967 // qDebug("KServerSocket:New connection %d ", socket); 996 // qDebug("KServerSocket:New connection %d ", socket);
968 if ( mSocket ) { 997 if ( mSocket ) {
969 qDebug("KServerSocket::newConnection Socket deleted! "); 998 qDebug("KServerSocket::newConnection Socket deleted! ");
970 delete mSocket; 999 delete mSocket;
971 mSocket = 0; 1000 mSocket = 0;
972 } 1001 }
973 mSocket = new QSocket( this ); 1002 mSocket = new QSocket( this );
974 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1003 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
975 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1004 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
976 mSocket->setSocket( socket ); 1005 mSocket->setSocket( socket );
977} 1006}
978 1007
979void KServerSocket::discardClient() 1008void KServerSocket::discardClient()
980{ 1009{
981 //qDebug(" KServerSocket::discardClient()"); 1010 //qDebug(" KServerSocket::discardClient()");
982 if ( mSocket ) { 1011 if ( mSocket ) {
983 delete mSocket; 1012 delete mSocket;
984 mSocket = 0; 1013 mSocket = 0;
985 } 1014 }
986 //emit endConnect(); 1015 //emit endConnect();
987} 1016}
988void KServerSocket::readClient() 1017void KServerSocket::readClient()
989{ 1018{
990 if ( blockRC ) 1019 if ( blockRC )
991 return; 1020 return;
992 if ( mSocket == 0 ) { 1021 if ( mSocket == 0 ) {
993 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 1022 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
994 return; 1023 return;
995 } 1024 }
996 //qDebug("KServerSocket::readClient()"); 1025 //qDebug("KServerSocket::readClient()");
997 if ( mSocket->canReadLine() ) { 1026 if ( mSocket->canReadLine() ) {
998 QString line = mSocket->readLine(); 1027 QString line = mSocket->readLine();
999 //qDebug("KServerSocket readline: %s ", line.latin1()); 1028 //qDebug("KServerSocket readline: %s ", line.latin1());
1000 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1029 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1001 if ( tokens[0] == "GET" ) { 1030 if ( tokens[0] == "GET" ) {
1002 if ( tokens[1] == mPassWord ) 1031 if ( tokens[1] == mPassWord )
1003 //emit sendFile( mSocket ); 1032 //emit sendFile( mSocket );
1004 send_file(); 1033 send_file();
1005 else { 1034 else {
1006 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 1035 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
1007 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1036 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1008 } 1037 }
1009 } 1038 }
1010 if ( tokens[0] == "PUT" ) { 1039 if ( tokens[0] == "PUT" ) {
1011 if ( tokens[1] == mPassWord ) { 1040 if ( tokens[1] == mPassWord ) {
1012 //emit getFile( mSocket ); 1041 //emit getFile( mSocket );
1013 blockRC = true; 1042 blockRC = true;
1014 get_file(); 1043 get_file();
1015 } 1044 }
1016 else { 1045 else {
1017 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 1046 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
1018 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1047 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1019 } 1048 }
1020 } 1049 }
1021 if ( tokens[0] == "STOP" ) { 1050 if ( tokens[0] == "STOP" ) {
1022 //emit endConnect(); 1051 //emit endConnect();
1023 end_connect(); 1052 end_connect();
1024 } 1053 }
1025 } 1054 }
1026} 1055}
1027void KServerSocket::end_connect() 1056void KServerSocket::end_connect()
1028{ 1057{
1029 delete mSyncActionDialog; 1058 delete mSyncActionDialog;
1030 mSyncActionDialog = 0; 1059 mSyncActionDialog = 0;
1031} 1060}
1032void KServerSocket::send_file() 1061void KServerSocket::send_file()
1033{ 1062{
1034 //qDebug("MainWindow::sendFile(QSocket* s) "); 1063 //qDebug("MainWindow::sendFile(QSocket* s) ");
1035 if ( mSyncActionDialog ) 1064 if ( mSyncActionDialog )
1036 delete mSyncActionDialog; 1065 delete mSyncActionDialog;
1037 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1066 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1038 mSyncActionDialog->setCaption(i18n("Received sync request")); 1067 mSyncActionDialog->setCaption(i18n("Received sync request"));
1039 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1068 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1040 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1069 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1041 lay->addWidget( label); 1070 lay->addWidget( label);
1042 lay->setMargin(7); 1071 lay->setMargin(7);
1043 lay->setSpacing(7); 1072 lay->setSpacing(7);
1044 mSyncActionDialog->setFixedSize( 230, 120); 1073 mSyncActionDialog->setFixedSize( 230, 120);
1045 mSyncActionDialog->show(); 1074 mSyncActionDialog->show();
1046 mSyncActionDialog->raise(); 1075 mSyncActionDialog->raise();
1047 emit request_file(); 1076 emit request_file();
1048 qApp->processEvents(); 1077 qApp->processEvents();
1049 QString fileName = mFileName; 1078 QString fileName = mFileName;
1050 QFile file( fileName ); 1079 QFile file( fileName );
1051 if (!file.open( IO_ReadOnly ) ) { 1080 if (!file.open( IO_ReadOnly ) ) {
1052 delete mSyncActionDialog; 1081 delete mSyncActionDialog;
1053 mSyncActionDialog = 0; 1082 mSyncActionDialog = 0;
1054 qDebug("KSS::error open file "); 1083 qDebug("KSS::error open file ");
1055 mSocket->close(); 1084 mSocket->close();
1056 if ( mSocket->state() == QSocket::Idle ) 1085 if ( mSocket->state() == QSocket::Idle )
1057 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1086 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1058 return ; 1087 return ;
1059 1088
1060 } 1089 }
1061 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1090 mSyncActionDialog->setCaption( i18n("Sending file...") );
1062 QTextStream ts( &file ); 1091 QTextStream ts( &file );
1063 ts.setEncoding( QTextStream::Latin1 ); 1092 ts.setEncoding( QTextStream::Latin1 );
1064 1093
1065 QTextStream os( mSocket ); 1094 QTextStream os( mSocket );
1066 os.setEncoding( QTextStream::Latin1 ); 1095 os.setEncoding( QTextStream::Latin1 );
1067 while ( ! ts.atEnd() ) { 1096 while ( ! ts.atEnd() ) {
1068 os << ts.readLine() << "\r\n"; 1097 os << ts.readLine() << "\r\n";
1069 } 1098 }
1070 //os << ts.read(); 1099 //os << ts.read();
1071 file.close(); 1100 file.close();
1072 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1101 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1073 mSocket->close(); 1102 mSocket->close();
1074 if ( mSocket->state() == QSocket::Idle ) 1103 if ( mSocket->state() == QSocket::Idle )
1075 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1104 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1076} 1105}
1077void KServerSocket::get_file() 1106void KServerSocket::get_file()
1078{ 1107{
1079 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1108 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1080 1109
1081 piTime.start(); 1110 piTime.start();
1082 piFileString = ""; 1111 piFileString = "";
1083 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1112 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1084} 1113}
1085 1114
1086 1115
1087void KServerSocket::readBackFileFromSocket() 1116void KServerSocket::readBackFileFromSocket()
1088{ 1117{
1089 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1118 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1090 while ( mSocket->canReadLine () ) { 1119 while ( mSocket->canReadLine () ) {
1091 piTime.restart(); 1120 piTime.restart();
1092 QString line = mSocket->readLine (); 1121 QString line = mSocket->readLine ();
1093 piFileString += line; 1122 piFileString += line;
1094 //qDebug("readline: %s ", line.latin1()); 1123 //qDebug("readline: %s ", line.latin1());
1095 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1124 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1096 1125
1097 } 1126 }
1098 if ( piTime.elapsed () < 3000 ) { 1127 if ( piTime.elapsed () < 3000 ) {
1099 // wait for more 1128 // wait for more
1100 //qDebug("waitformore "); 1129 //qDebug("waitformore ");
1101 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1130 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1102 return; 1131 return;
1103 } 1132 }
1104 QString fileName = mFileName; 1133 QString fileName = mFileName;
1105 QFile file ( fileName ); 1134 QFile file ( fileName );
1106 if (!file.open( IO_WriteOnly ) ) { 1135 if (!file.open( IO_WriteOnly ) ) {
1107 delete mSyncActionDialog; 1136 delete mSyncActionDialog;
1108 mSyncActionDialog = 0; 1137 mSyncActionDialog = 0;
1109 qDebug("KSS:Error open read back file "); 1138 qDebug("KSS:Error open read back file ");
1110 piFileString = ""; 1139 piFileString = "";
1111 emit file_received( false ); 1140 emit file_received( false );
1112 blockRC = false; 1141 blockRC = false;
1113 return ; 1142 return ;
1114 1143
1115 } 1144 }
1116 1145
1117 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1146 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1118 QTextStream ts ( &file ); 1147 QTextStream ts ( &file );
1119 ts.setEncoding( QTextStream::Latin1 ); 1148 ts.setEncoding( QTextStream::Latin1 );
1120 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1149 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1121 ts << piFileString; 1150 ts << piFileString;
1122 mSocket->close(); 1151 mSocket->close();
1123 if ( mSocket->state() == QSocket::Idle ) 1152 if ( mSocket->state() == QSocket::Idle )
1124 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1153 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1125 file.close(); 1154 file.close();
1126 delete mSyncActionDialog; 1155 delete mSyncActionDialog;
1127 mSyncActionDialog = 0; 1156 mSyncActionDialog = 0;
1128 piFileString = ""; 1157 piFileString = "";
1129 blockRC = false; 1158 blockRC = false;
1130 emit file_received( true ); 1159 emit file_received( true );
1131 1160
1132} 1161}
1133 1162
1134KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 1163KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
1135{ 1164{
1136 mPassWord = password; 1165 mPassWord = password;
1137 mSocket = 0; 1166 mSocket = 0;
1138 mPort = port; 1167 mPort = port;
1139 mHost = host; 1168 mHost = host;
1140 1169
1141 mRetVal = quiet; 1170 mRetVal = quiet;
1142 mTimerSocket = new QTimer ( this ); 1171 mTimerSocket = new QTimer ( this );
1143 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1172 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1144} 1173}
1145void KCommandSocket::readFile( QString fn ) 1174void KCommandSocket::readFile( QString fn )
1146{ 1175{
1147 if ( !mSocket ) { 1176 if ( !mSocket ) {
1148 mSocket = new QSocket( this ); 1177 mSocket = new QSocket( this );
1149 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1178 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1150 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1179 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1151 } 1180 }
1152 mFileString = ""; 1181 mFileString = "";
1153 mFileName = fn; 1182 mFileName = fn;
1154 mFirst = true; 1183 mFirst = true;
1155 mSocket->connectToHost( mHost, mPort ); 1184 mSocket->connectToHost( mHost, mPort );
1156 QTextStream os( mSocket ); 1185 QTextStream os( mSocket );
1157 os.setEncoding( QTextStream::Latin1 ); 1186 os.setEncoding( QTextStream::Latin1 );
1158 os << "GET " << mPassWord << "\r\n"; 1187 os << "GET " << mPassWord << "\r\n";
1159 mTimerSocket->start( 10000 ); 1188 mTimerSocket->start( 10000 );
1160} 1189}
1161 1190
1162void KCommandSocket::writeFile( QString fileName ) 1191void KCommandSocket::writeFile( QString fileName )
1163{ 1192{
1164 if ( !mSocket ) { 1193 if ( !mSocket ) {
1165 mSocket = new QSocket( this ); 1194 mSocket = new QSocket( this );
1166 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1195 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1167 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1196 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1168 } 1197 }
1169 mFileName = fileName ; 1198 mFileName = fileName ;
1170 mSocket->connectToHost( mHost, mPort ); 1199 mSocket->connectToHost( mHost, mPort );
1171} 1200}
1172void KCommandSocket::writeFileToSocket() 1201void KCommandSocket::writeFileToSocket()
1173{ 1202{
1174 QFile file2( mFileName ); 1203 QFile file2( mFileName );
1175 if (!file2.open( IO_ReadOnly ) ) { 1204 if (!file2.open( IO_ReadOnly ) ) {
1176 mRetVal= errorW; 1205 mRetVal= errorW;
1177 mSocket->close(); 1206 mSocket->close();
1178 if ( mSocket->state() == QSocket::Idle ) 1207 if ( mSocket->state() == QSocket::Idle )
1179 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1208 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1180 return ; 1209 return ;
1181 } 1210 }
1182 QTextStream ts2( &file2 ); 1211 QTextStream ts2( &file2 );
1183 ts2.setEncoding( QTextStream::Latin1 ); 1212 ts2.setEncoding( QTextStream::Latin1 );
1184 QTextStream os2( mSocket ); 1213 QTextStream os2( mSocket );
1185 os2.setEncoding( QTextStream::Latin1 ); 1214 os2.setEncoding( QTextStream::Latin1 );
1186 os2 << "PUT " << mPassWord << "\r\n";; 1215 os2 << "PUT " << mPassWord << "\r\n";;
1187 while ( ! ts2.atEnd() ) { 1216 while ( ! ts2.atEnd() ) {
1188 os2 << ts2.readLine() << "\r\n"; 1217 os2 << ts2.readLine() << "\r\n";
1189 } 1218 }
1190 mRetVal= successW; 1219 mRetVal= successW;
1191 file2.close(); 1220 file2.close();
1192 mSocket->close(); 1221 mSocket->close();
1193 if ( mSocket->state() == QSocket::Idle ) 1222 if ( mSocket->state() == QSocket::Idle )
1194 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1223 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1195} 1224}
1196void KCommandSocket::sendStop() 1225void KCommandSocket::sendStop()
1197{ 1226{
1198 if ( !mSocket ) { 1227 if ( !mSocket ) {
1199 mSocket = new QSocket( this ); 1228 mSocket = new QSocket( this );
1200 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1229 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1201 } 1230 }
1202 mSocket->connectToHost( mHost, mPort ); 1231 mSocket->connectToHost( mHost, mPort );
1203 QTextStream os2( mSocket ); 1232 QTextStream os2( mSocket );
1204 os2.setEncoding( QTextStream::Latin1 ); 1233 os2.setEncoding( QTextStream::Latin1 );
1205 os2 << "STOP\r\n"; 1234 os2 << "STOP\r\n";
1206 mSocket->close(); 1235 mSocket->close();
1207 if ( mSocket->state() == QSocket::Idle ) 1236 if ( mSocket->state() == QSocket::Idle )
1208 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1237 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1209} 1238}
1210 1239
1211void KCommandSocket::startReadFileFromSocket() 1240void KCommandSocket::startReadFileFromSocket()
1212{ 1241{
1213 if ( ! mFirst ) 1242 if ( ! mFirst )
1214 return; 1243 return;
1215 mFirst = false; 1244 mFirst = false;
1216 mTimerSocket->stop(); 1245 mTimerSocket->stop();
1217 mFileString = ""; 1246 mFileString = "";
1218 mTime.start(); 1247 mTime.start();
1219 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1248 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1220 1249
1221} 1250}
1222void KCommandSocket::readFileFromSocket() 1251void KCommandSocket::readFileFromSocket()
1223{ 1252{
1224 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1253 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1225 while ( mSocket->canReadLine () ) { 1254 while ( mSocket->canReadLine () ) {
1226 mTime.restart(); 1255 mTime.restart();
1227 QString line = mSocket->readLine (); 1256 QString line = mSocket->readLine ();
1228 mFileString += line; 1257 mFileString += line;
1229 //qDebug("readline: %s ", line.latin1()); 1258 //qDebug("readline: %s ", line.latin1());
1230 } 1259 }
1231 if ( mTime.elapsed () < 3000 ) { 1260 if ( mTime.elapsed () < 3000 ) {
1232 // wait for more 1261 // wait for more
1233 //qDebug("waitformore "); 1262 //qDebug("waitformore ");
1234 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1263 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1235 return; 1264 return;
1236 } 1265 }
1237 QString fileName = mFileName; 1266 QString fileName = mFileName;
1238 QFile file ( fileName ); 1267 QFile file ( fileName );
1239 if (!file.open( IO_WriteOnly ) ) { 1268 if (!file.open( IO_WriteOnly ) ) {
1240 mFileString = ""; 1269 mFileString = "";
1241 mRetVal = errorR; 1270 mRetVal = errorR;
1242 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1271 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1243 deleteSocket(); 1272 deleteSocket();
1244 return ; 1273 return ;
1245 1274
1246 } 1275 }
1247 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1276 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1248 QTextStream ts ( &file ); 1277 QTextStream ts ( &file );
1249 ts.setEncoding( QTextStream::Latin1 ); 1278 ts.setEncoding( QTextStream::Latin1 );
1250 ts << mFileString; 1279 ts << mFileString;
1251 file.close(); 1280 file.close();
1252 mFileString = ""; 1281 mFileString = "";
1253 mRetVal = successR; 1282 mRetVal = successR;
1254 mSocket->close(); 1283 mSocket->close();
1255 // if state is not idle, deleteSocket(); is called via 1284 // if state is not idle, deleteSocket(); is called via
1256 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1285 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1257 if ( mSocket->state() == QSocket::Idle ) 1286 if ( mSocket->state() == QSocket::Idle )
1258 deleteSocket(); 1287 deleteSocket();
1259} 1288}
1260 1289
1261void KCommandSocket::deleteSocket() 1290void KCommandSocket::deleteSocket()
1262{ 1291{
1263 //qDebug("KCommandSocket::deleteSocket() "); 1292 //qDebug("KCommandSocket::deleteSocket() ");
1264 if ( mTimerSocket->isActive () ) { 1293 if ( mTimerSocket->isActive () ) {
1265 mTimerSocket->stop(); 1294 mTimerSocket->stop();
1266 mRetVal = errorTO; 1295 mRetVal = errorTO;
1267 qDebug("Connection to remote host timed out"); 1296 qDebug("Connection to remote host timed out");
1268 if ( mSocket ) { 1297 if ( mSocket ) {
1269 mSocket->close(); 1298 mSocket->close();
1270 //if ( mSocket->state() == QSocket::Idle ) 1299 //if ( mSocket->state() == QSocket::Idle )
1271 // deleteSocket(); 1300 // deleteSocket();
1272 delete mSocket; 1301 delete mSocket;
1273 mSocket = 0; 1302 mSocket = 0;
1274 } 1303 }
1275 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 1304 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1276 emit commandFinished( this, mRetVal ); 1305 emit commandFinished( this, mRetVal );
1277 return; 1306 return;
1278 } 1307 }
1279 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1308 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1280 if ( mSocket) 1309 if ( mSocket)
1281 delete mSocket; 1310 delete mSocket;
1282 mSocket = 0; 1311 mSocket = 0;
1283 emit commandFinished( this, mRetVal ); 1312 emit commandFinished( this, mRetVal );
1284} 1313}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index ffb1ea4..7b9c499 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,211 +1,211 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20 $Id$ 20 $Id$
21*/ 21*/
22#ifndef _KSYNCMANAGER_H 22#ifndef _KSYNCMANAGER_H
23#define _KSYNCMANAGER_H 23#define _KSYNCMANAGER_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qsocket.h> 27#include <qsocket.h>
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qserversocket.h> 29#include <qserversocket.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qregexp.h> 31#include <qregexp.h>
32 32
33class QPopupMenu; 33class QPopupMenu;
34class KSyncProfile; 34class KSyncProfile;
35class KPimPrefs; 35class KPimPrefs;
36class QWidget; 36class QWidget;
37class KSyncManager; 37class KSyncManager;
38class KSyncInterface; 38class KSyncInterface;
39class QProgressBar; 39class QProgressBar;
40 40
41 41
42class KServerSocket : public QServerSocket 42class KServerSocket : public QServerSocket
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46 public: 46 public:
47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
48 48
49 void newConnection ( int socket ) ; 49 void newConnection ( int socket ) ;
50 void setFileName( QString fn ) {mFileName = fn;}; 50 void setFileName( QString fn ) {mFileName = fn;};
51 signals: 51 signals:
52 void file_received( bool ); 52 void file_received( bool );
53 void request_file(); 53 void request_file();
54 void saveFile(); 54 void saveFile();
55 void endConnect(); 55 void endConnect();
56 private slots: 56 private slots:
57 void discardClient(); 57 void discardClient();
58 void readClient(); 58 void readClient();
59 void readBackFileFromSocket(); 59 void readBackFileFromSocket();
60 private : 60 private :
61 bool blockRC; 61 bool blockRC;
62 void send_file(); 62 void send_file();
63 void get_file(); 63 void get_file();
64 void end_connect(); 64 void end_connect();
65 QDialog* mSyncActionDialog; 65 QDialog* mSyncActionDialog;
66 QSocket* mSocket; 66 QSocket* mSocket;
67 QString mPassWord; 67 QString mPassWord;
68 QString mFileName; 68 QString mFileName;
69 QTime piTime; 69 QTime piTime;
70 QString piFileString; 70 QString piFileString;
71}; 71};
72 72
73class KCommandSocket : public QObject 73class KCommandSocket : public QObject
74{ 74{
75 Q_OBJECT 75 Q_OBJECT
76 public: 76 public:
77 enum state { successR, errorR, successW, errorW, errorTO, quiet }; 77 enum state { successR, errorR, successW, errorW, errorTO, quiet };
78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
79 void readFile( QString ); 79 void readFile( QString );
80 void writeFile( QString ); 80 void writeFile( QString );
81 void sendStop(); 81 void sendStop();
82 82
83 signals: 83 signals:
84 void commandFinished( KCommandSocket*, int ); 84 void commandFinished( KCommandSocket*, int );
85 private slots: 85 private slots:
86 void startReadFileFromSocket(); 86 void startReadFileFromSocket();
87 void readFileFromSocket(); 87 void readFileFromSocket();
88 void deleteSocket(); 88 void deleteSocket();
89 void writeFileToSocket(); 89 void writeFileToSocket();
90 private : 90 private :
91 QSocket* mSocket; 91 QSocket* mSocket;
92 QString mPassWord; 92 QString mPassWord;
93 Q_UINT16 mPort; 93 Q_UINT16 mPort;
94 QString mHost; 94 QString mHost;
95 QString mFileName; 95 QString mFileName;
96 QTimer* mTimerSocket; 96 QTimer* mTimerSocket;
97 int mRetVal; 97 int mRetVal;
98 QTime mTime; 98 QTime mTime;
99 QString mFileString; 99 QString mFileString;
100 bool mFirst; 100 bool mFirst;
101}; 101};
102 102
103 103
104class KSyncManager : public QObject 104class KSyncManager : public QObject
105{ 105{
106 Q_OBJECT 106 Q_OBJECT
107 107
108 public: 108 public:
109 enum TargetApp { 109 enum TargetApp {
110 KOPI = 0, 110 KOPI = 0,
111 KAPI = 1, 111 KAPI = 1,
112 PWMPI = 2 }; 112 PWMPI = 2 };
113 113
114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
115 ~KSyncManager() ; 115 ~KSyncManager() ;
116 116
117 void multiSync( bool askforPrefs ); 117 void multiSync( bool askforPrefs );
118 bool blockSave() { return mBlockSaveFlag; } 118 bool blockSave() { return mBlockSaveFlag; }
119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
120 void setDefaultFileName( QString s) { mDefFileName = s ;} 120 void setDefaultFileName( QString s) { mDefFileName = s ;}
121 QString defaultFileName() { return mDefFileName ;} 121 QString defaultFileName() { return mDefFileName ;}
122 QString syncFileName(); 122 QString syncFileName();
123 void enableQuick( bool ask = true);
123 124
124 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 125 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
125 QString getCurrentSyncName() { return mCurrentSyncName; } 126 QString getCurrentSyncName() { return mCurrentSyncName; }
126 127
127 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 128 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
128 void hideProgressBar(); 129 void hideProgressBar();
129 bool isProgressBarCanceled(); 130 bool isProgressBarCanceled();
130 131
131 // sync stuff 132 // sync stuff
132 QString mLocalMachineName; 133 QString mLocalMachineName;
133 QStringList mExternSyncProfiles; 134 QStringList mExternSyncProfiles;
134 QStringList mSyncProfileNames; 135 QStringList mSyncProfileNames;
135 bool mAskForPreferences; 136 bool mAskForPreferences;
136 bool mShowSyncSummary; 137 bool mShowSyncSummary;
137 bool mIsKapiFile; 138 bool mIsKapiFile;
138 bool mWriteBackExistingOnly; 139 bool mWriteBackExistingOnly;
139 int mSyncAlgoPrefs; 140 int mSyncAlgoPrefs;
140 bool mWriteBackFile; 141 bool mWriteBackFile;
141 int mWriteBackInFuture; 142 int mWriteBackInFuture;
142 QString mPhoneDevice; 143 QString mPhoneDevice;
143 QString mPhoneConnection; 144 QString mPhoneConnection;
144 QString mPhoneModel; 145 QString mPhoneModel;
145 QString mPassWordPiSync; 146 QString mPassWordPiSync;
146 QString mActiveSyncPort; 147 QString mActiveSyncPort;
147 QString mActiveSyncIP ; 148 QString mActiveSyncIP ;
148 149
149 signals: 150 signals:
150 void save(); 151 void save();
151 void request_file(); 152 void request_file();
152 void getFile( bool ); 153 void getFile( bool );
153 154
154 public slots: 155 public slots:
155 void slotSyncMenu( int ); 156 void slotSyncMenu( int );
156 void deleteCommandSocket(KCommandSocket*s, int state); 157 void deleteCommandSocket(KCommandSocket*s, int state);
157 void readFileFromSocket(); 158 void readFileFromSocket();
158 void fillSyncMenu(); 159 void fillSyncMenu();
159 160
160 private: 161 private:
161 void syncPi(); 162 void syncPi();
162 KServerSocket * mServerSocket; 163 KServerSocket * mServerSocket;
163 void enableQuick();
164 KPimPrefs* mPrefs; 164 KPimPrefs* mPrefs;
165 QString mDefFileName; 165 QString mDefFileName;
166 QString mCurrentSyncDevice; 166 QString mCurrentSyncDevice;
167 QString mCurrentSyncName; 167 QString mCurrentSyncName;
168 void quickSyncLocalFile(); 168 void quickSyncLocalFile();
169 bool syncWithFile( QString fn , bool quick ); 169 bool syncWithFile( QString fn , bool quick );
170 void syncLocalFile(); 170 void syncLocalFile();
171 void syncPhone(); 171 void syncPhone();
172 void syncSharp(); 172 void syncSharp();
173 void syncKDE(); 173 void syncKDE();
174 bool syncExternalApplication(QString); 174 bool syncExternalApplication(QString);
175 int mCurrentSyncProfile ; 175 int mCurrentSyncProfile ;
176 void syncRemote( KSyncProfile* prof, bool ask = true); 176 void syncRemote( KSyncProfile* prof, bool ask = true);
177 void edit_sync_options(); 177 void edit_sync_options();
178 void edit_pisync_options(); 178 void edit_pisync_options();
179 int ringSync(); 179 int ringSync();
180 QString getPassword( ); 180 QString getPassword( );
181 bool mPisyncFinished; 181 bool mPisyncFinished;
182 bool mBlockSaveFlag; 182 bool mBlockSaveFlag;
183 QWidget* mParent; 183 QWidget* mParent;
184 KSyncInterface* mImplementation; 184 KSyncInterface* mImplementation;
185 TargetApp mTargetApp; 185 TargetApp mTargetApp;
186 QPopupMenu* mSyncMenu; 186 QPopupMenu* mSyncMenu;
187 QProgressBar* bar; 187 QProgressBar* bar;
188 188
189private slots: 189private slots:
190 void confSync(); 190 void confSync();
191 191
192 192
193}; 193};
194 194
195 195
196class KSyncInterface 196class KSyncInterface
197{ 197{
198 public : 198 public :
199 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 199 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
200 virtual bool syncExternal(KSyncManager* manager, QString resource) 200 virtual bool syncExternal(KSyncManager* manager, QString resource)
201 { 201 {
202 // empty implementation, because some syncable applications do not 202 // empty implementation, because some syncable applications do not
203 // have an external(sharpdtm) syncmode, like pwmanager. 203 // have an external(sharpdtm) syncmode, like pwmanager.
204 return false; 204 return false;
205 } 205 }
206 206
207 207
208}; 208};
209 209
210 210
211#endif 211#endif