summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-03 18:03:18 (UTC)
committer zautrix <zautrix>2004-10-03 18:03:18 (UTC)
commitdd8f6efd23350b101065ddb64f35920f24010185 (patch) (unidiff)
tree76475452c6c8854178a84e5fff863a21a8e117d3
parent2a7b61c2b45a0a0344ae65633b2578b4cde1753f (diff)
downloadkdepimpi-dd8f6efd23350b101065ddb64f35920f24010185.zip
kdepimpi-dd8f6efd23350b101065ddb64f35920f24010185.tar.gz
kdepimpi-dd8f6efd23350b101065ddb64f35920f24010185.tar.bz2
Fixes for desktop. Fixed kdehomedir on wintendo
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp10
-rw-r--r--libkdepim/libkdepim.pro2
-rw-r--r--microkde/kdecore/kstandarddirs.cpp27
3 files changed, 27 insertions, 12 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index f4ac0d6..7bf33d3 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2559 +1,2561 @@
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 <qmap.h> 16#include <qmap.h>
17#include <qwmatrix.h> 17#include <qwmatrix.h>
18#include <qtextbrowser.h> 18#include <qtextbrowser.h>
19#include <qtextstream.h> 19#include <qtextstream.h>
20#ifndef DESKTOP_VERSION 20#ifndef DESKTOP_VERSION
21#include <qpe/global.h> 21#include <qpe/global.h>
22#include <qpe/qpemenubar.h> 22#include <qpe/qpemenubar.h>
23#include <qpe/qpetoolbar.h> 23#include <qpe/qpetoolbar.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qtopia/alarmserver.h> 26#include <qtopia/alarmserver.h>
27#include <qtopia/qcopenvelope_qws.h> 27#include <qtopia/qcopenvelope_qws.h>
28#include <unistd.h> // for sleep 28#include <unistd.h> // for sleep
29#else 29#else
30#include <qmenubar.h> 30#include <qmenubar.h>
31#include <qtoolbar.h> 31#include <qtoolbar.h>
32#include <qapplication.h> 32#include <qapplication.h>
33//#include <resource.h> 33//#include <resource.h>
34 34
35#endif 35#endif
36#include <libkcal/calendarlocal.h> 36#include <libkcal/calendarlocal.h>
37#include <libkcal/todo.h> 37#include <libkcal/todo.h>
38#include <libkdepim/ksyncprofile.h> 38#include <libkdepim/ksyncprofile.h>
39#include <libkcal/kincidenceformatter.h> 39#include <libkcal/kincidenceformatter.h>
40#include <libkdepim/kpimglobalprefs.h> 40#include <libkdepim/kpimglobalprefs.h>
41 41
42#include "calendarview.h" 42#include "calendarview.h"
43#include "koviewmanager.h" 43#include "koviewmanager.h"
44#include "datenavigator.h" 44#include "datenavigator.h"
45#include "koagendaview.h" 45#include "koagendaview.h"
46#include "koagenda.h" 46#include "koagenda.h"
47#include "kodialogmanager.h" 47#include "kodialogmanager.h"
48#include "kdialogbase.h" 48#include "kdialogbase.h"
49#include "kapplication.h" 49#include "kapplication.h"
50#include "kofilterview.h" 50#include "kofilterview.h"
51#include "kstandarddirs.h" 51#include "kstandarddirs.h"
52#include "koprefs.h" 52#include "koprefs.h"
53#include "kfiledialog.h" 53#include "kfiledialog.h"
54#include "koglobals.h" 54#include "koglobals.h"
55#include "kglobal.h" 55#include "kglobal.h"
56#include "klocale.h" 56#include "klocale.h"
57#include "kconfig.h" 57#include "kconfig.h"
58#include "simplealarmclient.h" 58#include "simplealarmclient.h"
59#include "externalapphandler.h" 59#include "externalapphandler.h"
60 60
61using namespace KCal; 61using namespace KCal;
62#ifndef _WIN32_ 62#ifndef _WIN32_
63#include <unistd.h> 63#include <unistd.h>
64#else 64#else
65#include "koimportoldialog.h" 65#include "koimportoldialog.h"
66#endif 66#endif
67#include "mainwindow.h" 67#include "mainwindow.h"
68 68
69int globalFlagBlockStartup; 69int globalFlagBlockStartup;
70MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 70MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
71 QMainWindow( parent, name ) 71 QMainWindow( parent, name )
72{ 72{
73 73
74#ifdef DESKTOP_VERSION 74#ifdef DESKTOP_VERSION
75 setFont( QFont("Arial"), 14 ); 75 setFont( QFont("Arial"), 14 );
76#endif 76#endif
77 mCommandSocket = 0; 77 mCommandSocket = 0;
78 mCommandSocketFinish = 0; 78 mCommandSocketFinish = 0;
79 mSyncActionDialog = 0; 79 mSyncActionDialog = 0;
80 mServerSocket = 0; 80 mServerSocket = 0;
81 mClosed = false; 81 mClosed = false;
82 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 82 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
83 QString confFile = locateLocal("config","korganizerrc"); 83 QString confFile = locateLocal("config","korganizerrc");
84 QFileInfo finf ( confFile ); 84 QFileInfo finf ( confFile );
85 bool showWarning = !finf.exists(); 85 bool showWarning = !finf.exists();
86 setIcon(SmallIcon( "ko24" ) ); 86 setIcon(SmallIcon( "ko24" ) );
87 mBlockAtStartup = true; 87 mBlockAtStartup = true;
88 mFlagKeyPressed = false; 88 mFlagKeyPressed = false;
89 setCaption("KOrganizer/Pi"); 89 setCaption("KOrganizer/Pi");
90 KOPrefs *p = KOPrefs::instance(); 90 KOPrefs *p = KOPrefs::instance();
91 KPimGlobalPrefs::instance()->setGlobalConfig(); 91 KPimGlobalPrefs::instance()->setGlobalConfig();
92 // if ( QApplication::desktop()->height() > 480 ) { 92 // if ( QApplication::desktop()->height() > 480 ) {
93// if ( p->mHourSize == 4 ) 93// if ( p->mHourSize == 4 )
94// p->mHourSize = 6; 94// p->mHourSize = 6;
95// } 95// }
96 if ( p->mHourSize > 18 ) 96 if ( p->mHourSize > 18 )
97 p->mHourSize = 18; 97 p->mHourSize = 18;
98 QMainWindow::ToolBarDock tbd; 98 QMainWindow::ToolBarDock tbd;
99 if ( p->mToolBarHor ) { 99 if ( p->mToolBarHor ) {
100 if ( p->mToolBarUp ) 100 if ( p->mToolBarUp )
101 tbd = Bottom; 101 tbd = Bottom;
102 else 102 else
103 tbd = Top; 103 tbd = Top;
104 } 104 }
105 else { 105 else {
106 if ( p->mToolBarUp ) 106 if ( p->mToolBarUp )
107 tbd = Right; 107 tbd = Right;
108 else 108 else
109 tbd = Left; 109 tbd = Left;
110 } 110 }
111 if ( KOPrefs::instance()->mUseAppColors ) 111 if ( KOPrefs::instance()->mUseAppColors )
112 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 112 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
113 globalFlagBlockStartup = 1; 113 globalFlagBlockStartup = 1;
114 iconToolBar = new QPEToolBar( this ); 114 iconToolBar = new QPEToolBar( this );
115 addToolBar (iconToolBar , tbd ); 115 addToolBar (iconToolBar , tbd );
116 mBlockSaveFlag = false; 116 mBlockSaveFlag = false;
117 mCalendarModifiedFlag = false; 117 mCalendarModifiedFlag = false;
118 118
119 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 119 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
120 splash->setAlignment ( AlignCenter ); 120 splash->setAlignment ( AlignCenter );
121 setCentralWidget( splash ); 121 setCentralWidget( splash );
122#ifndef DESKTOP_VERSION 122#ifndef DESKTOP_VERSION
123 showMaximized(); 123 showMaximized();
124#endif 124#endif
125 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 125 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
126 setDefaultPreferences(); 126 setDefaultPreferences();
127 mCalendar = new CalendarLocal(); 127 mCalendar = new CalendarLocal();
128 mView = new CalendarView( mCalendar, this,"mCalendar " ); 128 mView = new CalendarView( mCalendar, this,"mCalendar " );
129 mView->hide(); 129 mView->hide();
130 //mView->resize(splash->size() ); 130 //mView->resize(splash->size() );
131 initActions(); 131 initActions();
132#ifndef DESKTOP_VERSION 132#ifndef DESKTOP_VERSION
133 iconToolBar->show(); 133 iconToolBar->show();
134 qApp->processEvents(); 134 qApp->processEvents();
135#endif 135#endif
136 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 136 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
137 int vh = height() ; 137 int vh = height() ;
138 int vw = width(); 138 int vw = width();
139 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 139 //qDebug("Toolbar hei %d ",iconToolBar->height() );
140 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 140 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
141 vh -= iconToolBar->height(); 141 vh -= iconToolBar->height();
142 } else { 142 } else {
143 vw -= iconToolBar->height(); 143 vw -= iconToolBar->height();
144 } 144 }
145 //mView->setMaximumSize( splash->size() ); 145 //mView->setMaximumSize( splash->size() );
146 //mView->resize( splash->size() ); 146 //mView->resize( splash->size() );
147 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 147 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
148 mView->readSettings(); 148 mView->readSettings();
149 bool oldOpened = false; 149 bool oldOpened = false;
150 bool newFile = false; 150 bool newFile = false;
151 if( !QFile::exists( defaultFileName() ) ) { 151 if( !QFile::exists( defaultFileName() ) ) {
152 QFileInfo finfo ( defaultFileName() ); 152 QFileInfo finfo ( defaultFileName() );
153 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 153 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
154 qDebug("oldfile %s ", oldFile.latin1()); 154 qDebug("oldfile %s ", oldFile.latin1());
155 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"; 155 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";
156 finfo.setFile( oldFile ); 156 finfo.setFile( oldFile );
157 if (finfo.exists() ) { 157 if (finfo.exists() ) {
158 KMessageBox::information( this, message); 158 KMessageBox::information( this, message);
159 mView->openCalendar( oldFile ); 159 mView->openCalendar( oldFile );
160 qApp->processEvents(); 160 qApp->processEvents();
161 } else { 161 } else {
162 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 162 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
163 finfo.setFile( oldFile ); 163 finfo.setFile( oldFile );
164 if (finfo.exists() ) { 164 if (finfo.exists() ) {
165 KMessageBox::information( this, message); 165 KMessageBox::information( this, message);
166 mView->openCalendar( oldFile ); 166 mView->openCalendar( oldFile );
167 qApp->processEvents(); 167 qApp->processEvents();
168 } 168 }
169 } 169 }
170 mView->saveCalendar( defaultFileName() ); 170 mView->saveCalendar( defaultFileName() );
171 newFile = true; 171 newFile = true;
172 } 172 }
173 173
174 QTime neededSaveTime = QDateTime::currentDateTime().time(); 174 QTime neededSaveTime = QDateTime::currentDateTime().time();
175 if ( ! oldOpened ) 175 if ( ! oldOpened )
176 mView->openCalendar( defaultFileName() ); 176 mView->openCalendar( defaultFileName() );
177 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 177 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
178 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 178 qDebug("KO: Calendar loading time: %d ms",msNeeded );
179 179
180 if ( KOPrefs::instance()->mLanguageChanged ) { 180 if ( KOPrefs::instance()->mLanguageChanged ) {
181 KOPrefs::instance()->setCategoryDefaults(); 181 KOPrefs::instance()->setCategoryDefaults();
182 int count = mView->addCategories(); 182 int count = mView->addCategories();
183 KOPrefs::instance()->mLanguageChanged = false; 183 KOPrefs::instance()->mLanguageChanged = false;
184 } 184 }
185 processIncidenceSelection( 0 ); 185 processIncidenceSelection( 0 );
186 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 186 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
187 SLOT( processIncidenceSelection( Incidence * ) ) ); 187 SLOT( processIncidenceSelection( Incidence * ) ) );
188 connect( mView, SIGNAL( modifiedChanged( bool ) ), 188 connect( mView, SIGNAL( modifiedChanged( bool ) ),
189 SLOT( slotModifiedChanged( bool ) ) ); 189 SLOT( slotModifiedChanged( bool ) ) );
190 190
191 191
192 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 192 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
193 mView->setModified( false ); 193 mView->setModified( false );
194 mBlockAtStartup = false; 194 mBlockAtStartup = false;
195 mView->setModified( false ); 195 mView->setModified( false );
196 setCentralWidget( mView ); 196 setCentralWidget( mView );
197 globalFlagBlockStartup = 0; 197 globalFlagBlockStartup = 0;
198 mView->show(); 198 mView->show();
199 delete splash; 199 delete splash;
200 if ( newFile ) 200 if ( newFile )
201 mView->updateConfig(); 201 mView->updateConfig();
202 // qApp->processEvents(); 202 // qApp->processEvents();
203 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 203 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
204 fillSyncMenu(); 204 fillSyncMenu();
205 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 205 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
206 if ( showWarning ) { 206 if ( showWarning ) {
207 KMessageBox::information( this, 207 KMessageBox::information( this,
208 "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"); 208 "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");
209 qApp->processEvents(); 209 qApp->processEvents();
210 mView->dialogManager()->showSyncOptions(); 210 mView->dialogManager()->showSyncOptions();
211 } 211 }
212 212
213 //US listen for result adressed from Ka/Pi 213 //US listen for result adressed from Ka/Pi
214#ifndef DESKTOP_VERSION 214#ifndef DESKTOP_VERSION
215 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 215 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
216#endif 216#endif
217} 217}
218MainWindow::~MainWindow() 218MainWindow::~MainWindow()
219{ 219{
220 //qDebug("MainWindow::~MainWindow() "); 220 //qDebug("MainWindow::~MainWindow() ");
221 //save toolbar location 221 //save toolbar location
222 delete mServerSocket; 222 delete mServerSocket;
223 delete mCalendar; 223 delete mCalendar;
224 delete KOPrefs::instance(); 224 delete KOPrefs::instance();
225 delete KIncidenceFormatter::instance(); 225 delete KIncidenceFormatter::instance();
226 226
227 227
228} 228}
229void MainWindow::showMaximized () 229void MainWindow::showMaximized ()
230{ 230{
231#ifndef DESKTOP_VERSION 231#ifndef DESKTOP_VERSION
232 if ( ! globalFlagBlockStartup ) 232 if ( ! globalFlagBlockStartup )
233 if ( mClosed ) 233 if ( mClosed )
234 mView->goToday(); 234 mView->goToday();
235#endif 235#endif
236 QWidget::showMaximized () ; 236 QWidget::showMaximized () ;
237 mClosed = false; 237 mClosed = false;
238} 238}
239void MainWindow::closeEvent( QCloseEvent* ce ) 239void MainWindow::closeEvent( QCloseEvent* ce )
240{ 240{
241 241
242 242
243 243
244 if ( ! KOPrefs::instance()->mAskForQuit ) { 244 if ( ! KOPrefs::instance()->mAskForQuit ) {
245 saveOnClose(); 245 saveOnClose();
246 mClosed = true; 246 mClosed = true;
247 ce->accept(); 247 ce->accept();
248 return; 248 return;
249 249
250 } 250 }
251 251
252 switch( QMessageBox::information( this, "KO/Pi", 252 switch( QMessageBox::information( this, "KO/Pi",
253 i18n("Do you really want\nto close KO/Pi?"), 253 i18n("Do you really want\nto close KO/Pi?"),
254 i18n("Close"), i18n("No"), 254 i18n("Close"), i18n("No"),
255 0, 0 ) ) { 255 0, 0 ) ) {
256 case 0: 256 case 0:
257 saveOnClose(); 257 saveOnClose();
258 mClosed = true; 258 mClosed = true;
259 ce->accept(); 259 ce->accept();
260 break; 260 break;
261 case 1: 261 case 1:
262 ce->ignore(); 262 ce->ignore();
263 break; 263 break;
264 case 2: 264 case 2:
265 265
266 default: 266 default:
267 break; 267 break;
268 } 268 }
269 269
270 270
271} 271}
272 272
273void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 273void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
274{ 274{
275 QDataStream stream( data, IO_ReadOnly ); 275 QDataStream stream( data, IO_ReadOnly );
276 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 276 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
277 //QString datamess; 277 //QString datamess;
278 //qDebug("message "); 278 //qDebug("message ");
279 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 279 qDebug("KO: QCOP message received: %s ", cmsg.data() );
280 280
281 if ( cmsg == "-writeFile" ) { 281 if ( cmsg == "-writeFile" ) {
282 // I made from the "-writeFile" an "-writeAlarm" 282 // I made from the "-writeFile" an "-writeAlarm"
283 mView->viewManager()->showWhatsNextView(); 283 mView->viewManager()->showWhatsNextView();
284 mCalendar->checkAlarmForIncidence( 0, true); 284 mCalendar->checkAlarmForIncidence( 0, true);
285 showMaximized(); 285 showMaximized();
286 raise(); 286 raise();
287 return; 287 return;
288 } 288 }
289 289
290 if ( cmsg == "-writeFile" ) { 290 if ( cmsg == "-writeFile" ) {
291 // I made from the "-writeFile" an "-writeAlarm" 291 // I made from the "-writeFile" an "-writeAlarm"
292 mView->viewManager()->showWhatsNextView(); 292 mView->viewManager()->showWhatsNextView();
293 mCalendar->checkAlarmForIncidence( 0, true); 293 mCalendar->checkAlarmForIncidence( 0, true);
294 showMaximized(); 294 showMaximized();
295 raise(); 295 raise();
296 return; 296 return;
297 297
298 } 298 }
299 if ( cmsg == "-writeFileSilent" ) { 299 if ( cmsg == "-writeFileSilent" ) {
300 // I made from the "-writeFile" an "-writeAlarm" 300 // I made from the "-writeFile" an "-writeAlarm"
301 // mView->viewManager()->showWhatsNextView(); 301 // mView->viewManager()->showWhatsNextView();
302 mCalendar->checkAlarmForIncidence( 0, true); 302 mCalendar->checkAlarmForIncidence( 0, true);
303 //showMaximized(); 303 //showMaximized();
304 //raise(); 304 //raise();
305 hide(); 305 hide();
306 return; 306 return;
307 } 307 }
308 if ( cmsg == "-newCountdown" ) { 308 if ( cmsg == "-newCountdown" ) {
309 qDebug("newCountdown "); 309 qDebug("newCountdown ");
310 310
311 } 311 }
312 QString msg ; 312 QString msg ;
313 QString allmsg = cmsg; 313 QString allmsg = cmsg;
314 while ( allmsg.length() > 0 ) { 314 while ( allmsg.length() > 0 ) {
315 int nextC = allmsg.find( "-", 1 ); 315 int nextC = allmsg.find( "-", 1 );
316 if ( nextC == -1 ) { 316 if ( nextC == -1 ) {
317 msg = allmsg; 317 msg = allmsg;
318 allmsg = ""; 318 allmsg = "";
319 } else{ 319 } else{
320 msg = allmsg.left( nextC ); 320 msg = allmsg.left( nextC );
321 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 321 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
322 } 322 }
323 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 323 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
324 if ( msg == "-newEvent" ) { 324 if ( msg == "-newEvent" ) {
325 mView->newEvent(); 325 mView->newEvent();
326 } 326 }
327 if ( msg == "-newTodo" ) { 327 if ( msg == "-newTodo" ) {
328 mView->newTodo(); 328 mView->newTodo();
329 329
330 } 330 }
331 if ( msg == "-showWN" ) { 331 if ( msg == "-showWN" ) {
332 mView->viewManager()->showWhatsNextView(); 332 mView->viewManager()->showWhatsNextView();
333 } 333 }
334 if ( msg == "-showTodo" ) { 334 if ( msg == "-showTodo" ) {
335 mView->viewManager()->showTodoView(); 335 mView->viewManager()->showTodoView();
336 } 336 }
337 if ( msg == "-showList" ) { 337 if ( msg == "-showList" ) {
338 mView->viewManager()->showListView(); 338 mView->viewManager()->showListView();
339 } 339 }
340 else if ( msg == "-showDay" ) { 340 else if ( msg == "-showDay" ) {
341 mView->viewManager()->showDayView(); 341 mView->viewManager()->showDayView();
342 } 342 }
343 else if ( msg == "-showWWeek" ) { 343 else if ( msg == "-showWWeek" ) {
344 mView->viewManager()->showWorkWeekView(); 344 mView->viewManager()->showWorkWeekView();
345 } 345 }
346 else if ( msg == "-ringSync" ) { 346 else if ( msg == "-ringSync" ) {
347 multiSync( false ); 347 multiSync( false );
348 } 348 }
349 else if ( msg == "-showWeek" ) { 349 else if ( msg == "-showWeek" ) {
350 mView->viewManager()->showWeekView(); 350 mView->viewManager()->showWeekView();
351 } 351 }
352 else if ( msg == "-showTodo" ) { 352 else if ( msg == "-showTodo" ) {
353 mView->viewManager()->showTodoView(); 353 mView->viewManager()->showTodoView();
354 } 354 }
355 else if ( msg == "-showJournal" ) { 355 else if ( msg == "-showJournal" ) {
356 mView->dateNavigator()->selectDates( 1 ); 356 mView->dateNavigator()->selectDates( 1 );
357 mView->dateNavigator()->selectToday(); 357 mView->dateNavigator()->selectToday();
358 mView->viewManager()->showJournalView(); 358 mView->viewManager()->showJournalView();
359 } 359 }
360 else if ( msg == "-showKO" ) { 360 else if ( msg == "-showKO" ) {
361 mView->viewManager()->showNextXView(); 361 mView->viewManager()->showNextXView();
362 } 362 }
363 else if ( msg == "-showWNext" || msg == "nextView()" ) { 363 else if ( msg == "-showWNext" || msg == "nextView()" ) {
364 mView->viewManager()->showWhatsNextView(); 364 mView->viewManager()->showWhatsNextView();
365 } 365 }
366 else if ( msg == "-showNextXView" ) { 366 else if ( msg == "-showNextXView" ) {
367 mView->viewManager()->showNextXView(); 367 mView->viewManager()->showNextXView();
368 } 368 }
369 369
370 370
371 } 371 }
372 372
373 showMaximized(); 373 showMaximized();
374 raise(); 374 raise();
375} 375}
376 376
377QPixmap MainWindow::loadPixmap( QString name ) 377QPixmap MainWindow::loadPixmap( QString name )
378{ 378{
379 return SmallIcon( name ); 379 return SmallIcon( name );
380 380
381} 381}
382void MainWindow::initActions() 382void MainWindow::initActions()
383{ 383{
384 //KOPrefs::instance()->mShowFullMenu 384 //KOPrefs::instance()->mShowFullMenu
385 iconToolBar->clear(); 385 iconToolBar->clear();
386 KOPrefs *p = KOPrefs::instance(); 386 KOPrefs *p = KOPrefs::instance();
387 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 387 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
388 388
389 QPopupMenu *viewMenu = new QPopupMenu( this ); 389 QPopupMenu *viewMenu = new QPopupMenu( this );
390 QPopupMenu *actionMenu = new QPopupMenu( this ); 390 QPopupMenu *actionMenu = new QPopupMenu( this );
391 QPopupMenu *importMenu = new QPopupMenu( this ); 391 QPopupMenu *importMenu = new QPopupMenu( this );
392 selectFilterMenu = new QPopupMenu( this ); 392 selectFilterMenu = new QPopupMenu( this );
393 selectFilterMenu->setCheckable( true ); 393 selectFilterMenu->setCheckable( true );
394 syncMenu = new QPopupMenu( this ); 394 syncMenu = new QPopupMenu( this );
395 configureAgendaMenu = new QPopupMenu( this ); 395 configureAgendaMenu = new QPopupMenu( this );
396 configureToolBarMenu = new QPopupMenu( this ); 396 configureToolBarMenu = new QPopupMenu( this );
397 QPopupMenu *helpMenu = new QPopupMenu( this ); 397 QPopupMenu *helpMenu = new QPopupMenu( this );
398 if ( KOPrefs::instance()->mShowFullMenu ) { 398 if ( KOPrefs::instance()->mShowFullMenu ) {
399 QMenuBar *menuBar1; 399 QMenuBar *menuBar1;
400 menuBar1 = menuBar(); 400 menuBar1 = menuBar();
401 menuBar1->insertItem( i18n("File"), importMenu ); 401 menuBar1->insertItem( i18n("File"), importMenu );
402 menuBar1->insertItem( i18n("View"), viewMenu ); 402 menuBar1->insertItem( i18n("View"), viewMenu );
403 menuBar1->insertItem( i18n("Actions"), actionMenu ); 403 menuBar1->insertItem( i18n("Actions"), actionMenu );
404 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 404 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
405 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 405 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
406 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 406 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
407 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 407 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
408 menuBar1->insertItem( i18n("Help"), helpMenu ); 408 menuBar1->insertItem( i18n("Help"), helpMenu );
409 } else { 409 } else {
410 QPEMenuBar *menuBar1; 410 QPEMenuBar *menuBar1;
411 menuBar1 = new QPEMenuBar( iconToolBar ); 411 menuBar1 = new QPEMenuBar( iconToolBar );
412 QPopupMenu *menuBar = new QPopupMenu( this ); 412 QPopupMenu *menuBar = new QPopupMenu( this );
413 menuBar1->insertItem( i18n("ME"), menuBar); 413 menuBar1->insertItem( i18n("ME"), menuBar);
414 menuBar->insertItem( i18n("File"), importMenu ); 414 menuBar->insertItem( i18n("File"), importMenu );
415 menuBar->insertItem( i18n("View"), viewMenu ); 415 menuBar->insertItem( i18n("View"), viewMenu );
416 menuBar->insertItem( i18n("Actions"), actionMenu ); 416 menuBar->insertItem( i18n("Actions"), actionMenu );
417 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 417 menuBar->insertItem( i18n("Synchronize"), syncMenu );
418 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 418 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
419 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 419 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
420 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 420 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
421 menuBar->insertItem( i18n("Help"), helpMenu ); 421 menuBar->insertItem( i18n("Help"), helpMenu );
422 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 422 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
423 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 423 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
424 } 424 }
425 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 425 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
426 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 426 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
427 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 427 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
428 428
429 // ****************** 429 // ******************
430 QAction *action; 430 QAction *action;
431 QIconSet icon; 431 QIconSet icon;
432 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 432 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
433 configureToolBarMenu->setCheckable( true ); 433 configureToolBarMenu->setCheckable( true );
434 434
435 QString pathString = ""; 435 QString pathString = "";
436 if ( !p->mToolBarMiniIcons ) { 436 if ( !p->mToolBarMiniIcons ) {
437 if ( QApplication::desktop()->width() < 480 ) 437 if ( QApplication::desktop()->width() < 480 )
438 pathString += "icons16/"; 438 pathString += "icons16/";
439 } else 439 } else
440 pathString += "iconsmini/"; 440 pathString += "iconsmini/";
441 configureAgendaMenu->setCheckable( true ); 441 configureAgendaMenu->setCheckable( true );
442 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 442 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
443 configureAgendaMenu->insertSeparator(); 443 configureAgendaMenu->insertSeparator();
444 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 444 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
445 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 445 configureAgendaMenu->insertItem(i18n("Small"), 6 );
446 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 446 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
447 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 447 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
448 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 448 configureAgendaMenu->insertItem(i18n("Large"), 12 );
449 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 449 configureAgendaMenu->insertItem(i18n("Big"), 14 );
450 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 450 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
451 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 451 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
452 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 452 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
453 453
454 icon = loadPixmap( pathString + "configure" ); 454 icon = loadPixmap( pathString + "configure" );
455 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 455 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
456 action->addTo( actionMenu ); 456 action->addTo( actionMenu );
457 connect( action, SIGNAL( activated() ), 457 connect( action, SIGNAL( activated() ),
458 mView, SLOT( edit_options() ) ); 458 mView, SLOT( edit_options() ) );
459 actionMenu->insertSeparator(); 459 actionMenu->insertSeparator();
460 icon = loadPixmap( pathString + "newevent" ); 460 icon = loadPixmap( pathString + "newevent" );
461 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 461 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
462 configureToolBarMenu->insertSeparator(); 462 configureToolBarMenu->insertSeparator();
463 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 463 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
464 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 464 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
465 ne_action->addTo( actionMenu ); 465 ne_action->addTo( actionMenu );
466 connect( ne_action, SIGNAL( activated() ), 466 connect( ne_action, SIGNAL( activated() ),
467 mView, SLOT( newEvent() ) ); 467 mView, SLOT( newEvent() ) );
468 icon = loadPixmap( pathString + "newtodo" ); 468 icon = loadPixmap( pathString + "newtodo" );
469 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 469 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
470 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 470 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
471 nt_action->addTo( actionMenu ); 471 nt_action->addTo( actionMenu );
472 connect( nt_action, SIGNAL( activated() ), 472 connect( nt_action, SIGNAL( activated() ),
473 mView, SLOT( newTodo() ) ); 473 mView, SLOT( newTodo() ) );
474 icon = loadPixmap( pathString + "navi" ); 474 icon = loadPixmap( pathString + "navi" );
475 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 475 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
476 action->addTo( viewMenu ); 476 action->addTo( viewMenu );
477 connect( action, SIGNAL( activated() ), 477 connect( action, SIGNAL( activated() ),
478 mView, SLOT( toggleDateNavigatorWidget() ) ); 478 mView, SLOT( toggleDateNavigatorWidget() ) );
479 icon = loadPixmap( pathString + "filter" ); 479 icon = loadPixmap( pathString + "filter" );
480 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 480 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
481 action->addTo( viewMenu ); 481 action->addTo( viewMenu );
482 connect( action, SIGNAL( activated() ), 482 connect( action, SIGNAL( activated() ),
483 mView, SLOT( toggleFilter() ) ); 483 mView, SLOT( toggleFilter() ) );
484 484
485 485
486 viewMenu->insertSeparator(); 486 viewMenu->insertSeparator();
487 icon = loadPixmap( pathString + "picker" ); 487 icon = loadPixmap( pathString + "picker" );
488 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 488 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
489 action->addTo( viewMenu ); 489 action->addTo( viewMenu );
490 connect( action, SIGNAL( activated() ), 490 connect( action, SIGNAL( activated() ),
491 mView, SLOT( showDatePicker() ) ); 491 mView, SLOT( showDatePicker() ) );
492 action->addTo( iconToolBar ); 492 action->addTo( iconToolBar );
493 viewMenu->insertSeparator(); 493 viewMenu->insertSeparator();
494 icon = loadPixmap( pathString + "list" ); 494 icon = loadPixmap( pathString + "list" );
495 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 495 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
496 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 496 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
497 showlist_action->addTo( viewMenu ); 497 showlist_action->addTo( viewMenu );
498 connect( showlist_action, SIGNAL( activated() ), 498 connect( showlist_action, SIGNAL( activated() ),
499 mView->viewManager(), SLOT( showListView() ) ); 499 mView->viewManager(), SLOT( showListView() ) );
500 500
501 501
502 icon = loadPixmap( pathString + "day" ); 502 icon = loadPixmap( pathString + "day" );
503 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 503 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
504 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 504 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
505 day1_action->addTo( viewMenu ); 505 day1_action->addTo( viewMenu );
506 // action->addTo( toolBar ); 506 // action->addTo( toolBar );
507 connect( day1_action, SIGNAL( activated() ), 507 connect( day1_action, SIGNAL( activated() ),
508 mView->viewManager(), SLOT( showDayView() ) ); 508 mView->viewManager(), SLOT( showDayView() ) );
509 509
510 icon = loadPixmap( pathString + "workweek" ); 510 icon = loadPixmap( pathString + "workweek" );
511 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 511 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
512 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 512 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
513 day5_action->addTo( viewMenu ); 513 day5_action->addTo( viewMenu );
514 connect( day5_action, SIGNAL( activated() ), 514 connect( day5_action, SIGNAL( activated() ),
515 mView->viewManager(), SLOT( showWorkWeekView() ) ); 515 mView->viewManager(), SLOT( showWorkWeekView() ) );
516 516
517 icon = loadPixmap( pathString + "week" ); 517 icon = loadPixmap( pathString + "week" );
518 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 518 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
519 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 519 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
520 day7_action->addTo( viewMenu ); 520 day7_action->addTo( viewMenu );
521 connect( day7_action, SIGNAL( activated() ), 521 connect( day7_action, SIGNAL( activated() ),
522 mView->viewManager(), SLOT( showWeekView() ) ); 522 mView->viewManager(), SLOT( showWeekView() ) );
523 523
524 icon = loadPixmap( pathString + "month" ); 524 icon = loadPixmap( pathString + "month" );
525 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 525 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
526 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 526 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
527 month_action->addTo( viewMenu ); 527 month_action->addTo( viewMenu );
528 connect( month_action, SIGNAL( activated() ), 528 connect( month_action, SIGNAL( activated() ),
529 mView->viewManager(), SLOT( showMonthView() ) ); 529 mView->viewManager(), SLOT( showMonthView() ) );
530 530
531 icon = loadPixmap( pathString + "todo" ); 531 icon = loadPixmap( pathString + "todo" );
532 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 532 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
533 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 533 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
534 todoview_action->addTo( viewMenu ); 534 todoview_action->addTo( viewMenu );
535 connect( todoview_action, SIGNAL( activated() ), 535 connect( todoview_action, SIGNAL( activated() ),
536 mView->viewManager(), SLOT( showTodoView() ) ); 536 mView->viewManager(), SLOT( showTodoView() ) );
537 537
538 icon = loadPixmap( pathString + "journal" ); 538 icon = loadPixmap( pathString + "journal" );
539 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 539 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
540 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 540 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
541 viewjournal_action->addTo( viewMenu ); 541 viewjournal_action->addTo( viewMenu );
542 connect( viewjournal_action, SIGNAL( activated() ), 542 connect( viewjournal_action, SIGNAL( activated() ),
543 mView->viewManager(), SLOT( showJournalView() ) ); 543 mView->viewManager(), SLOT( showJournalView() ) );
544 544
545 icon = loadPixmap( pathString + "xdays" ); 545 icon = loadPixmap( pathString + "xdays" );
546 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 546 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
547 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 547 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
548 xdays_action->addTo( viewMenu ); 548 xdays_action->addTo( viewMenu );
549 connect( xdays_action, SIGNAL( activated() ), 549 connect( xdays_action, SIGNAL( activated() ),
550 mView->viewManager(), SLOT( showNextXView() ) ); 550 mView->viewManager(), SLOT( showNextXView() ) );
551 551
552 icon = loadPixmap( pathString + "whatsnext" ); 552 icon = loadPixmap( pathString + "whatsnext" );
553 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 553 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
554 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 554 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
555 whatsnext_action->addTo( viewMenu ); 555 whatsnext_action->addTo( viewMenu );
556 connect( whatsnext_action, SIGNAL( activated() ), 556 connect( whatsnext_action, SIGNAL( activated() ),
557 mView->viewManager(), SLOT( showWhatsNextView() ) ); 557 mView->viewManager(), SLOT( showWhatsNextView() ) );
558 558
559#if 0 559#if 0
560 action = new QAction( "view_timespan", "Time Span", 0, this ); 560 action = new QAction( "view_timespan", "Time Span", 0, this );
561 action->addTo( viewMenu ); 561 action->addTo( viewMenu );
562 connect( action, SIGNAL( activated() ), 562 connect( action, SIGNAL( activated() ),
563 mView->viewManager(), SLOT( showTimeSpanView() ) ); 563 mView->viewManager(), SLOT( showTimeSpanView() ) );
564#endif 564#endif
565 565
566 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 566 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
567 this ); 567 this );
568 mNewSubTodoAction->addTo( actionMenu ); 568 mNewSubTodoAction->addTo( actionMenu );
569 connect( mNewSubTodoAction, SIGNAL( activated() ), 569 connect( mNewSubTodoAction, SIGNAL( activated() ),
570 mView, SLOT( newSubTodo() ) ); 570 mView, SLOT( newSubTodo() ) );
571 571
572 actionMenu->insertSeparator(); 572 actionMenu->insertSeparator();
573 573
574 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 574 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
575 mShowAction->addTo( actionMenu ); 575 mShowAction->addTo( actionMenu );
576 connect( mShowAction, SIGNAL( activated() ), 576 connect( mShowAction, SIGNAL( activated() ),
577 mView, SLOT( showIncidence() ) ); 577 mView, SLOT( showIncidence() ) );
578 578
579 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 579 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
580 mEditAction->addTo( actionMenu ); 580 mEditAction->addTo( actionMenu );
581 connect( mEditAction, SIGNAL( activated() ), 581 connect( mEditAction, SIGNAL( activated() ),
582 mView, SLOT( editIncidence() ) ); 582 mView, SLOT( editIncidence() ) );
583 583
584 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 584 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
585 mDeleteAction->addTo( actionMenu ); 585 mDeleteAction->addTo( actionMenu );
586 connect( mDeleteAction, SIGNAL( activated() ), 586 connect( mDeleteAction, SIGNAL( activated() ),
587 mView, SLOT( deleteIncidence() ) ); 587 mView, SLOT( deleteIncidence() ) );
588 588
589 actionMenu->insertSeparator(); 589 actionMenu->insertSeparator();
590 590
591 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 591 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
592 this ); 592 this );
593 action->addTo( actionMenu ); 593 action->addTo( actionMenu );
594 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 594 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
595 595
596 icon = loadPixmap( pathString + "search" ); 596 icon = loadPixmap( pathString + "search" );
597 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 597 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
598 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 598 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
599 search_action->addTo( actionMenu ); 599 search_action->addTo( actionMenu );
600 connect( search_action, SIGNAL( activated() ), 600 connect( search_action, SIGNAL( activated() ),
601 mView->dialogManager(), SLOT( showSearchDialog() ) ); 601 mView->dialogManager(), SLOT( showSearchDialog() ) );
602 602
603 icon = loadPixmap( pathString + "today" ); 603 icon = loadPixmap( pathString + "today" );
604 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 604 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
605 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 605 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
606 today_action->addTo( actionMenu ); 606 today_action->addTo( actionMenu );
607 connect( today_action, SIGNAL( activated() ), 607 connect( today_action, SIGNAL( activated() ),
608 mView, SLOT( goToday() ) ); 608 mView, SLOT( goToday() ) );
609 609
610 if ( KOPrefs::instance()->mShowFullMenu ) { 610 if ( KOPrefs::instance()->mShowFullMenu ) {
611 actionMenu->insertSeparator(); 611 actionMenu->insertSeparator();
612 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 612 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
613 613
614 } 614 }
615 // actionMenu->insertSeparator(); 615 // actionMenu->insertSeparator();
616 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 616 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
617 this ); 617 this );
618 action->addTo( importMenu ); 618 action->addTo( importMenu );
619 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 619 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
620 action = new QAction( "import_quick", i18n("Import last file"), 0, 620 action = new QAction( "import_quick", i18n("Import last file"), 0,
621 this ); 621 this );
622 action->addTo( importMenu ); 622 action->addTo( importMenu );
623 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 623 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
624 importMenu->insertSeparator(); 624 importMenu->insertSeparator();
625 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 625 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
626 this ); 626 this );
627 action->addTo( importMenu ); 627 action->addTo( importMenu );
628 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 628 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
629#ifndef DESKTOP_VERSION 629#ifndef DESKTOP_VERSION
630 importMenu->insertSeparator(); 630 importMenu->insertSeparator();
631 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 631 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
632 this ); 632 this );
633 action->addTo( importMenu ); 633 action->addTo( importMenu );
634 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 634 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
635#else 635#else
636#ifdef _WIN32_ 636#ifdef _WIN32_
637 importMenu->insertSeparator(); 637 importMenu->insertSeparator();
638 action = new QAction( "import_ol", i18n("Import from OL"), 0, 638 action = new QAction( "import_ol", i18n("Import from OL"), 0,
639 this ); 639 this );
640 action->addTo( importMenu ); 640 action->addTo( importMenu );
641 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 641 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
642#endif 642#endif
643#endif 643#endif
644 644
645 importMenu->insertSeparator(); 645 importMenu->insertSeparator();
646 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 646 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
647 this ); 647 this );
648 action->addTo( importMenu ); 648 action->addTo( importMenu );
649 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 649 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
650 650
651 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 651 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
652 this ); 652 this );
653 action->addTo( importMenu ); 653 action->addTo( importMenu );
654 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 654 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
655 655
656 importMenu->insertSeparator(); 656 importMenu->insertSeparator();
657 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 657 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
658 this ); 658 this );
659 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 659 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
660 importMenu->insertSeparator(); 660 importMenu->insertSeparator();
661 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 661 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
662 this ); 662 this );
663 action->addTo( importMenu ); 663 action->addTo( importMenu );
664 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 664 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
665#ifndef DESKTOP_VERSION 665#ifndef DESKTOP_VERSION
666 importMenu->insertSeparator(); 666 importMenu->insertSeparator();
667 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 667 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
668 this ); 668 this );
669 action->addTo( importMenu ); 669 action->addTo( importMenu );
670 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 670 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
671 671
672 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 672 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
673 this ); 673 this );
674 action->addTo( importMenu ); 674 action->addTo( importMenu );
675 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 675 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
676#else 676#else
677 importMenu->insertSeparator(); 677 importMenu->insertSeparator();
678 icon = loadPixmap( pathString + "print" ); 678 icon = loadPixmap( pathString + "print" );
679 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 679 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
680 action->addTo( importMenu ); 680 action->addTo( importMenu );
681 connect( action, SIGNAL( activated() ), 681 connect( action, SIGNAL( activated() ),
682 this, SLOT( printCal() ) ); 682 this, SLOT( printCal() ) );
683 683
684 icon = loadPixmap( pathString + "print" ); 684 icon = loadPixmap( pathString + "print" );
685 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 685 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
686 action->addTo( importMenu ); 686 action->addTo( importMenu );
687 connect( action, SIGNAL( activated() ), 687 connect( action, SIGNAL( activated() ),
688 this, SLOT( printSel() ) ); 688 this, SLOT( printSel() ) );
689#endif 689#endif
690 importMenu->insertSeparator(); 690 importMenu->insertSeparator();
691 action = new QAction( "beam all", i18n("Save"), 0, 691 action = new QAction( "beam all", i18n("Save"), 0,
692 this ); 692 this );
693 action->addTo( importMenu ); 693 action->addTo( importMenu );
694 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 694 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
695 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 695 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
696 this ); 696 this );
697 action->addTo( importMenu ); 697 action->addTo( importMenu );
698 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 698 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
699 699
700 //menuBar->insertItem( "Configure",configureMenu ); 700 //menuBar->insertItem( "Configure",configureMenu );
701 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 701 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
702 icon = loadPixmap( "korganizer/korganizer" ); 702 icon = loadPixmap( "korganizer/korganizer" );
703 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 703 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
704 action->addTo( helpMenu ); 704 action->addTo( helpMenu );
705 connect( action, SIGNAL( activated() ), 705 connect( action, SIGNAL( activated() ),
706 SLOT( keyBindings() ) ); 706 SLOT( keyBindings() ) );
707 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 707 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
708 action->addTo( helpMenu ); 708 action->addTo( helpMenu );
709 connect( action, SIGNAL( activated() ), 709 connect( action, SIGNAL( activated() ),
710 SLOT( features() ) ); 710 SLOT( features() ) );
711 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 711 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
712 action->addTo( helpMenu ); 712 action->addTo( helpMenu );
713 connect( action, SIGNAL( activated() ), 713 connect( action, SIGNAL( activated() ),
714 SLOT( aboutAutoSaving() ) ); 714 SLOT( aboutAutoSaving() ) );
715 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 715 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
716 action->addTo( helpMenu ); 716 action->addTo( helpMenu );
717 connect( action, SIGNAL( activated() ), 717 connect( action, SIGNAL( activated() ),
718 SLOT( aboutKnownBugs() ) ); 718 SLOT( aboutKnownBugs() ) );
719 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 719 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
720 action->addTo( helpMenu ); 720 action->addTo( helpMenu );
721 connect( action, SIGNAL( activated() ), 721 connect( action, SIGNAL( activated() ),
722 SLOT( usertrans() ) ); 722 SLOT( usertrans() ) );
723 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 723 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
724 action->addTo( helpMenu ); 724 action->addTo( helpMenu );
725 connect( action, SIGNAL( activated() ), 725 connect( action, SIGNAL( activated() ),
726 SLOT( synchowto() ) ); 726 SLOT( synchowto() ) );
727 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 727 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
728 action->addTo( helpMenu ); 728 action->addTo( helpMenu );
729 connect( action, SIGNAL( activated() ), 729 connect( action, SIGNAL( activated() ),
730 SLOT( whatsNew() ) ); 730 SLOT( whatsNew() ) );
731 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 731 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
732 action->addTo( helpMenu ); 732 action->addTo( helpMenu );
733 connect( action, SIGNAL( activated() ), 733 connect( action, SIGNAL( activated() ),
734 SLOT( faq() ) ); 734 SLOT( faq() ) );
735 735
736 736
737 action = new QAction( "about", i18n("About..."), 0, this ); 737 action = new QAction( "about", i18n("About..."), 0, this );
738 action->addTo( helpMenu ); 738 action->addTo( helpMenu );
739 connect( action, SIGNAL( activated() ), 739 connect( action, SIGNAL( activated() ),
740 SLOT( about() ) ); 740 SLOT( about() ) );
741 action = new QAction( "licence", i18n("Licence..."), 0, this ); 741 action = new QAction( "licence", i18n("Licence..."), 0, this );
742 action->addTo( helpMenu ); 742 action->addTo( helpMenu );
743 connect( action, SIGNAL( activated() ), 743 connect( action, SIGNAL( activated() ),
744 SLOT( licence() ) ); 744 SLOT( licence() ) );
745 //menuBar->insertSeparator(); 745 //menuBar->insertSeparator();
746 746
747 // ****************************************************** 747 // ******************************************************
748 // menubar icons 748 // menubar icons
749 749
750 750
751 iconToolBar->setHorizontalStretchable (true ); 751 iconToolBar->setHorizontalStretchable (true );
752 //menuBar->insertItem( iconToolBar ); 752 //menuBar->insertItem( iconToolBar );
753 //xdays_action 753 //xdays_action
754 if (p-> mShowIconNewEvent) 754 if (p-> mShowIconNewEvent)
755 ne_action->addTo( iconToolBar ); 755 ne_action->addTo( iconToolBar );
756 if (p->mShowIconNewTodo ) 756 if (p->mShowIconNewTodo )
757 nt_action->addTo( iconToolBar ); 757 nt_action->addTo( iconToolBar );
758 if (p-> mShowIconSearch) 758 if (p-> mShowIconSearch)
759 search_action->addTo( iconToolBar ); 759 search_action->addTo( iconToolBar );
760 if (p-> mShowIconNext) 760 if (p-> mShowIconNext)
761 whatsnext_action->addTo( iconToolBar ); 761 whatsnext_action->addTo( iconToolBar );
762 if (p-> mShowIconNextDays) 762 if (p-> mShowIconNextDays)
763 xdays_action->addTo( iconToolBar ); 763 xdays_action->addTo( iconToolBar );
764 if (p-> mShowIconList) 764 if (p-> mShowIconList)
765 showlist_action->addTo( iconToolBar ); 765 showlist_action->addTo( iconToolBar );
766 if (p-> mShowIconDay1) 766 if (p-> mShowIconDay1)
767 day1_action->addTo( iconToolBar ); 767 day1_action->addTo( iconToolBar );
768 if (p-> mShowIconDay5) 768 if (p-> mShowIconDay5)
769 day5_action->addTo( iconToolBar ); 769 day5_action->addTo( iconToolBar );
770 if (p-> mShowIconDay7) 770 if (p-> mShowIconDay7)
771 day7_action->addTo( iconToolBar ); 771 day7_action->addTo( iconToolBar );
772 if (p-> mShowIconMonth) 772 if (p-> mShowIconMonth)
773 month_action->addTo( iconToolBar ); 773 month_action->addTo( iconToolBar );
774 if (p-> mShowIconTodoview) 774 if (p-> mShowIconTodoview)
775 todoview_action->addTo( iconToolBar ); 775 todoview_action->addTo( iconToolBar );
776 if (p-> mShowIconJournal) 776 if (p-> mShowIconJournal)
777 viewjournal_action->addTo( iconToolBar ); 777 viewjournal_action->addTo( iconToolBar );
778 icon = loadPixmap( pathString + "2leftarrowB" ); 778 icon = loadPixmap( pathString + "2leftarrowB" );
779 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 779 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
780 if (p-> mShowIconBackFast) { 780 if (p-> mShowIconBackFast) {
781 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 781 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
782 connect( action, SIGNAL( activated() ), 782 connect( action, SIGNAL( activated() ),
783 mView, SLOT( goPreviousMonth() ) ); 783 mView, SLOT( goPreviousMonth() ) );
784 action->addTo( iconToolBar ); 784 action->addTo( iconToolBar );
785 } 785 }
786 icon = loadPixmap( pathString + "1leftarrowB" ); 786 icon = loadPixmap( pathString + "1leftarrowB" );
787 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 787 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
788 if (p-> mShowIconBack) { 788 if (p-> mShowIconBack) {
789 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 789 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
790 connect( action, SIGNAL( activated() ), 790 connect( action, SIGNAL( activated() ),
791 mView, SLOT( goPrevious() ) ); 791 mView, SLOT( goPrevious() ) );
792 action->addTo( iconToolBar ); 792 action->addTo( iconToolBar );
793 } 793 }
794 if (p-> mShowIconToday) 794 if (p-> mShowIconToday)
795 today_action->addTo( iconToolBar ); 795 today_action->addTo( iconToolBar );
796 icon = loadPixmap( pathString + "1rightarrowB" ); 796 icon = loadPixmap( pathString + "1rightarrowB" );
797 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 797 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
798 if (p-> mShowIconForward) { 798 if (p-> mShowIconForward) {
799 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 799 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
800 connect( action, SIGNAL( activated() ), 800 connect( action, SIGNAL( activated() ),
801 mView, SLOT( goNext() ) ); 801 mView, SLOT( goNext() ) );
802 action->addTo( iconToolBar ); 802 action->addTo( iconToolBar );
803 } 803 }
804 icon = loadPixmap( pathString + "2rightarrowB" ); 804 icon = loadPixmap( pathString + "2rightarrowB" );
805 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 805 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
806 if (p-> mShowIconForwardFast) { 806 if (p-> mShowIconForwardFast) {
807 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 807 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
808 connect( action, SIGNAL( activated() ), 808 connect( action, SIGNAL( activated() ),
809 mView, SLOT( goNextMonth() ) ); 809 mView, SLOT( goNextMonth() ) );
810 action->addTo( iconToolBar ); 810 action->addTo( iconToolBar );
811 } 811 }
812 812
813 813
814 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 814 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
815 815
816 if (p-> mShowIconNewEvent) 816 if (p-> mShowIconNewEvent)
817 configureToolBarMenu->setItemChecked( 10, true ); 817 configureToolBarMenu->setItemChecked( 10, true );
818 if (p->mShowIconNewTodo ) 818 if (p->mShowIconNewTodo )
819 configureToolBarMenu->setItemChecked( 20, true ); 819 configureToolBarMenu->setItemChecked( 20, true );
820 if (p-> mShowIconSearch) 820 if (p-> mShowIconSearch)
821 configureToolBarMenu->setItemChecked( 120, true ); 821 configureToolBarMenu->setItemChecked( 120, true );
822 if (p-> mShowIconList) 822 if (p-> mShowIconList)
823 configureToolBarMenu->setItemChecked( 30, true ); 823 configureToolBarMenu->setItemChecked( 30, true );
824 if (p-> mShowIconDay1) 824 if (p-> mShowIconDay1)
825 configureToolBarMenu->setItemChecked( 40, true ); 825 configureToolBarMenu->setItemChecked( 40, true );
826 if (p-> mShowIconDay5) 826 if (p-> mShowIconDay5)
827 configureToolBarMenu->setItemChecked( 50, true ); 827 configureToolBarMenu->setItemChecked( 50, true );
828 if (p-> mShowIconDay7) 828 if (p-> mShowIconDay7)
829 configureToolBarMenu->setItemChecked( 60, true ); 829 configureToolBarMenu->setItemChecked( 60, true );
830 if (p-> mShowIconMonth) 830 if (p-> mShowIconMonth)
831 configureToolBarMenu->setItemChecked( 70, true ); 831 configureToolBarMenu->setItemChecked( 70, true );
832 if (p-> mShowIconTodoview) 832 if (p-> mShowIconTodoview)
833 configureToolBarMenu->setItemChecked( 80, true ); 833 configureToolBarMenu->setItemChecked( 80, true );
834 if (p-> mShowIconBackFast) 834 if (p-> mShowIconBackFast)
835 configureToolBarMenu->setItemChecked( 200, true ); 835 configureToolBarMenu->setItemChecked( 200, true );
836 if (p-> mShowIconBack) 836 if (p-> mShowIconBack)
837 configureToolBarMenu->setItemChecked( 210, true ); 837 configureToolBarMenu->setItemChecked( 210, true );
838 if (p-> mShowIconToday) 838 if (p-> mShowIconToday)
839 configureToolBarMenu->setItemChecked( 130, true ); 839 configureToolBarMenu->setItemChecked( 130, true );
840 if (p-> mShowIconForward) 840 if (p-> mShowIconForward)
841 configureToolBarMenu->setItemChecked( 220, true ); 841 configureToolBarMenu->setItemChecked( 220, true );
842 if (p-> mShowIconForwardFast) 842 if (p-> mShowIconForwardFast)
843 configureToolBarMenu->setItemChecked( 230, true ); 843 configureToolBarMenu->setItemChecked( 230, true );
844 if (p-> mShowIconNextDays) 844 if (p-> mShowIconNextDays)
845 configureToolBarMenu->setItemChecked( 100, true ); 845 configureToolBarMenu->setItemChecked( 100, true );
846 if (p-> mShowIconNext) 846 if (p-> mShowIconNext)
847 configureToolBarMenu->setItemChecked( 110, true ); 847 configureToolBarMenu->setItemChecked( 110, true );
848 if (p-> mShowIconJournal) 848 if (p-> mShowIconJournal)
849 configureToolBarMenu->setItemChecked( 90, true ); 849 configureToolBarMenu->setItemChecked( 90, true );
850 if (p-> mShowIconWhatsThis) 850 if (p-> mShowIconWhatsThis)
851 configureToolBarMenu->setItemChecked( 300, true ); 851 configureToolBarMenu->setItemChecked( 300, true );
852 852
853 QLabel* dummy = new QLabel( iconToolBar ); 853 QLabel* dummy = new QLabel( iconToolBar );
854 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 854 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
855 if (!p-> mShowIconStretch) 855 if (!p-> mShowIconStretch)
856 iconToolBar->setStretchableWidget ( dummy ) ; 856 iconToolBar->setStretchableWidget ( dummy ) ;
857 else 857 else
858 configureToolBarMenu->setItemChecked( 5, true ); 858 configureToolBarMenu->setItemChecked( 5, true );
859 if (p-> mShowIconWhatsThis) 859 if (p-> mShowIconWhatsThis)
860 QWhatsThis::whatsThisButton ( iconToolBar ); 860 QWhatsThis::whatsThisButton ( iconToolBar );
861 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 861 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
862 configureAgenda( p->mHourSize ); 862 configureAgenda( p->mHourSize );
863 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 863 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
864} 864}
865void MainWindow::fillSyncMenu() 865void MainWindow::fillSyncMenu()
866{ 866{
867 if ( syncMenu->count() ) 867 if ( syncMenu->count() )
868 syncMenu->clear(); 868 syncMenu->clear();
869 syncMenu->insertItem( i18n("Configure..."), 0 ); 869 syncMenu->insertItem( i18n("Configure..."), 0 );
870 syncMenu->insertSeparator(); 870 syncMenu->insertSeparator();
871 if ( mServerSocket == 0 ) { 871 if ( mServerSocket == 0 ) {
872 syncMenu->insertItem( i18n("Enable Easy-Pi-Sync"), 2 ); 872 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
873 } else { 873 } else {
874 syncMenu->insertItem( i18n("Disable Easy-Pi-Sync"), 3 ); 874 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
875 } 875 }
876 syncMenu->insertSeparator(); 876 syncMenu->insertSeparator();
877 syncMenu->insertItem( i18n("New Easy-Pi-Sync!"), 4 ); 877 syncMenu->insertItem( i18n("New Pi-Sync!"), 4 );
878 syncMenu->insertItem( i18n("Quick Easy-Pi-Sync!"), 5 ); 878 syncMenu->insertItem( i18n("Quick Pi-Sync!"), 5 );
879 syncMenu->insertSeparator(); 879 syncMenu->insertSeparator();
880 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 880 syncMenu->insertItem( i18n("Multiple sync"), 1 );
881 syncMenu->insertSeparator(); 881 syncMenu->insertSeparator();
882 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 882 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
883 config.setGroup("General"); 883 config.setGroup("General");
884 QStringList prof = config.readListEntry("SyncProfileNames"); 884 QStringList prof = config.readListEntry("SyncProfileNames");
885 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 885 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
886 if ( prof.count() < 3 ) { 886 if ( prof.count() < 3 ) {
887 prof.clear(); 887 prof.clear();
888 prof << i18n("Sharp_DTM"); 888 prof << i18n("Sharp_DTM");
889 prof << i18n("Local_file"); 889 prof << i18n("Local_file");
890 prof << i18n("Last_file"); 890 prof << i18n("Last_file");
891 KSyncProfile* temp = new KSyncProfile (); 891 KSyncProfile* temp = new KSyncProfile ();
892 temp->setName( prof[0] ); 892 temp->setName( prof[0] );
893 temp->writeConfig(&config); 893 temp->writeConfig(&config);
894 temp->setName( prof[1] ); 894 temp->setName( prof[1] );
895 temp->writeConfig(&config); 895 temp->writeConfig(&config);
896 temp->setName( prof[2] ); 896 temp->setName( prof[2] );
897 temp->writeConfig(&config); 897 temp->writeConfig(&config);
898 config.setGroup("General"); 898 config.setGroup("General");
899 config.writeEntry("SyncProfileNames",prof); 899 config.writeEntry("SyncProfileNames",prof);
900 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 900 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
901 config.sync(); 901 config.sync();
902 delete temp; 902 delete temp;
903 } 903 }
904 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 904 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
905 KOPrefs::instance()->mSyncProfileNames = prof; 905 KOPrefs::instance()->mSyncProfileNames = prof;
906 int i; 906 int i;
907 for ( i = 0; i < prof.count(); ++i ) { 907 for ( i = 0; i < prof.count(); ++i ) {
908 908
909 syncMenu->insertItem( prof[i], 1000+i ); 909 syncMenu->insertItem( prof[i], 1000+i );
910 if ( i == 2 ) 910 if ( i == 2 )
911 syncMenu->insertSeparator(); 911 syncMenu->insertSeparator();
912 } 912 }
913 QDir app_dir; 913 QDir app_dir;
914 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 914 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
915 syncMenu->setItemEnabled( false , 1000 ); 915 syncMenu->setItemEnabled( false , 1000 );
916 } 916 }
917 mView->setupExternSyncProfiles(); 917 mView->setupExternSyncProfiles();
918} 918}
919 919
920int MainWindow::ringSync() 920int MainWindow::ringSync()
921{ 921{
922 int syncedProfiles = 0; 922 int syncedProfiles = 0;
923 int i; 923 int i;
924 QTime timer; 924 QTime timer;
925 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 925 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
926 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 926 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
927 KSyncProfile* temp = new KSyncProfile (); 927 KSyncProfile* temp = new KSyncProfile ();
928 KOPrefs::instance()->mAskForPreferences = false; 928 KOPrefs::instance()->mAskForPreferences = false;
929 for ( i = 0; i < syncProfileNames.count(); ++i ) { 929 for ( i = 0; i < syncProfileNames.count(); ++i ) {
930 mCurrentSyncProfile = i; 930 mCurrentSyncProfile = i;
931 temp->setName(syncProfileNames[mCurrentSyncProfile]); 931 temp->setName(syncProfileNames[mCurrentSyncProfile]);
932 temp->readConfig(&config); 932 temp->readConfig(&config);
933 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 933 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
934 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 934 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
935 ++syncedProfiles; 935 ++syncedProfiles;
936 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 936 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
937 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 937 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
938 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 938 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
939 KOPrefs::instance()->mWriteBackInFuture = 0; 939 KOPrefs::instance()->mWriteBackInFuture = 0;
940 if ( temp->getWriteBackFuture() ) 940 if ( temp->getWriteBackFuture() )
941 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 941 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
942 KOPrefs::instance()->mShowSyncSummary = false; 942 KOPrefs::instance()->mShowSyncSummary = false;
943 mView->setSyncDevice(syncProfileNames[i] ); 943 mView->setSyncDevice(syncProfileNames[i] );
944 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 944 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
945 if ( i == 0 ) { 945 if ( i == 0 ) {
946 syncSharp(); 946 syncSharp();
947 } else { 947 } else {
948 if ( temp->getIsLocalFileSync() ) { 948 if ( temp->getIsLocalFileSync() ) {
949 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 949 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
950 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 950 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
951 } else { 951 } else {
952 if ( temp->getIsPhoneSync() ) { 952 if ( temp->getIsPhoneSync() ) {
953 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 953 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
954 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 954 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
955 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 955 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
956 syncPhone(); 956 syncPhone();
957 } else 957 } else
958 syncRemote( temp, false ); 958 syncRemote( temp, false );
959 959
960 } 960 }
961 } 961 }
962 timer.start(); 962 timer.start();
963 setCaption(i18n("Multiple sync in progress ... please wait!") ); 963 setCaption(i18n("Multiple sync in progress ... please wait!") );
964 while ( timer.elapsed () < 2000 ) { 964 while ( timer.elapsed () < 2000 ) {
965 qApp->processEvents(); 965 qApp->processEvents();
966#ifndef _WIN32_ 966#ifndef _WIN32_
967 sleep (1); 967 sleep (1);
968#endif 968#endif
969 } 969 }
970 970
971 } 971 }
972 972
973 } 973 }
974 delete temp; 974 delete temp;
975 return syncedProfiles; 975 return syncedProfiles;
976} 976}
977 977
978void MainWindow::multiSync( bool askforPrefs ) 978void MainWindow::multiSync( bool askforPrefs )
979{ 979{
980 if (mBlockSaveFlag) 980 if (mBlockSaveFlag)
981 return; 981 return;
982 mBlockSaveFlag = true; 982 mBlockSaveFlag = true;
983 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 983 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
984 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 984 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
985 question, 985 question,
986 i18n("Yes"), i18n("No"), 986 i18n("Yes"), i18n("No"),
987 0, 0 ) != 0 ) { 987 0, 0 ) != 0 ) {
988 mBlockSaveFlag = false; 988 mBlockSaveFlag = false;
989 setCaption(i18n("Aborted! Nothing synced!")); 989 setCaption(i18n("Aborted! Nothing synced!"));
990 return; 990 return;
991 } 991 }
992 mView->setSyncDevice(i18n("Multiple profiles") ); 992 mView->setSyncDevice(i18n("Multiple profiles") );
993 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 993 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
994 if ( askforPrefs ) { 994 if ( askforPrefs ) {
995 mView->edit_sync_options(); 995 mView->edit_sync_options();
996 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 996 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
997 } 997 }
998 setCaption(i18n("Multiple sync started.") ); 998 setCaption(i18n("Multiple sync started.") );
999 qApp->processEvents(); 999 qApp->processEvents();
1000 int num = ringSync() ; 1000 int num = ringSync() ;
1001 if ( num > 1 ) 1001 if ( num > 1 )
1002 ringSync(); 1002 ringSync();
1003 mBlockSaveFlag = false; 1003 mBlockSaveFlag = false;
1004 if ( num ) 1004 if ( num )
1005 save(); 1005 save();
1006 if ( num ) 1006 if ( num )
1007 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 1007 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
1008 else 1008 else
1009 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 1009 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
1010 return; 1010 return;
1011} 1011}
1012void MainWindow::slotSyncMenu( int action ) 1012void MainWindow::slotSyncMenu( int action )
1013{ 1013{
1014 qDebug("syncaction %d ", action); 1014 qDebug("syncaction %d ", action);
1015 if ( action == 0 ) { 1015 if ( action == 0 ) {
1016 1016
1017 // seems to be a Qt2 event handling bug 1017 // seems to be a Qt2 event handling bug
1018 // syncmenu.clear causes a segfault at first time 1018 // syncmenu.clear causes a segfault at first time
1019 // when we call it after the main event loop, it is ok 1019 // when we call it after the main event loop, it is ok
1020 // same behaviour when calling OM/Pi via QCOP for the first time 1020 // same behaviour when calling OM/Pi via QCOP for the first time
1021 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 1021 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
1022 //confSync(); 1022 //confSync();
1023 1023
1024 return; 1024 return;
1025 } 1025 }
1026 if ( action == 1 ) { 1026 if ( action == 1 ) {
1027 multiSync( true ); 1027 multiSync( true );
1028 return; 1028 return;
1029 } 1029 }
1030 if ( action == 2 ) { 1030 if ( action == 2 ) {
1031 enableQuick(); 1031 enableQuick();
1032 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1032 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1033 return; 1033 return;
1034 } 1034 }
1035 if ( action == 3 ) { 1035 if ( action == 3 ) {
1036 delete mServerSocket; 1036 delete mServerSocket;
1037 mServerSocket = 0; 1037 mServerSocket = 0;
1038 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1038 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1039 return; 1039 return;
1040 } 1040 }
1041 if ( action == 4 ) { 1041 if ( action == 4 ) {
1042 performQuick(); 1042 performQuick();
1043 return; 1043 return;
1044 } 1044 }
1045 if ( action == 5 ) { 1045 if ( action == 5 ) {
1046 performQuickQuick(); 1046 performQuickQuick();
1047 return; 1047 return;
1048 } 1048 }
1049 1049
1050 if (mBlockSaveFlag) 1050 if (mBlockSaveFlag)
1051 return; 1051 return;
1052 mBlockSaveFlag = true; 1052 mBlockSaveFlag = true;
1053 mCurrentSyncProfile = action - 1000 ; 1053 mCurrentSyncProfile = action - 1000 ;
1054 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1054 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1055 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1055 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1056 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1056 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1057 KSyncProfile* temp = new KSyncProfile (); 1057 KSyncProfile* temp = new KSyncProfile ();
1058 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1058 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1059 temp->readConfig(&config); 1059 temp->readConfig(&config);
1060 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1060 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1061 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1061 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1062 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1062 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1063 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1063 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1064 KOPrefs::instance()->mWriteBackInFuture = 0; 1064 KOPrefs::instance()->mWriteBackInFuture = 0;
1065 if ( temp->getWriteBackFuture() ) 1065 if ( temp->getWriteBackFuture() )
1066 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1066 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1067 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1067 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1068 if ( action == 1000 ) { 1068 if ( action == 1000 ) {
1069 syncSharp(); 1069 syncSharp();
1070 1070
1071 } else if ( action == 1001 ) { 1071 } else if ( action == 1001 ) {
1072 syncLocalFile(); 1072 syncLocalFile();
1073 1073
1074 } else if ( action == 1002 ) { 1074 } else if ( action == 1002 ) {
1075 quickSyncLocalFile(); 1075 quickSyncLocalFile();
1076 1076
1077 } else if ( action >= 1003 ) { 1077 } else if ( action >= 1003 ) {
1078 if ( temp->getIsLocalFileSync() ) { 1078 if ( temp->getIsLocalFileSync() ) {
1079 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1079 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1080 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1080 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1081 } else { 1081 } else {
1082 if ( temp->getIsPhoneSync() ) { 1082 if ( temp->getIsPhoneSync() ) {
1083 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1083 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1084 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1084 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1085 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1085 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1086 syncPhone(); 1086 syncPhone();
1087 } else 1087 } else
1088 syncRemote( temp ); 1088 syncRemote( temp );
1089 1089
1090 } 1090 }
1091 } 1091 }
1092 delete temp; 1092 delete temp;
1093 mBlockSaveFlag = false; 1093 mBlockSaveFlag = false;
1094} 1094}
1095void MainWindow::setDefaultPreferences() 1095void MainWindow::setDefaultPreferences()
1096{ 1096{
1097 KOPrefs *p = KOPrefs::instance(); 1097 KOPrefs *p = KOPrefs::instance();
1098 1098
1099 p->mCompactDialogs = true; 1099 p->mCompactDialogs = true;
1100 p->mConfirm = true; 1100 p->mConfirm = true;
1101 // p->mEnableQuickTodo = false; 1101 // p->mEnableQuickTodo = false;
1102} 1102}
1103 1103
1104QString MainWindow::resourcePath() 1104QString MainWindow::resourcePath()
1105{ 1105{
1106 return KGlobal::iconLoader()->iconPath(); 1106 return KGlobal::iconLoader()->iconPath();
1107} 1107}
1108 1108
1109void MainWindow::displayText( QString text ,QString cap ) 1109void MainWindow::displayText( QString text ,QString cap )
1110{ 1110{
1111 QDialog dia( this, "name", true ); ; 1111 QDialog dia( this, "name", true ); ;
1112 dia.setCaption( cap ); 1112 dia.setCaption( cap );
1113 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1113 QVBoxLayout* lay = new QVBoxLayout( &dia );
1114 lay->setSpacing( 3 ); 1114 lay->setSpacing( 3 );
1115 lay->setMargin( 3 ); 1115 lay->setMargin( 3 );
1116 QTextBrowser tb ( &dia ); 1116 QTextBrowser tb ( &dia );
1117 lay->addWidget( &tb ); 1117 lay->addWidget( &tb );
1118 tb.setText( text ); 1118 tb.setText( text );
1119#ifdef DESKTOP_VERSION 1119#ifdef DESKTOP_VERSION
1120 dia.resize( 640, 480); 1120 dia.resize( 640, 480);
1121#else 1121#else
1122 dia.showMaximized(); 1122 dia.showMaximized();
1123#endif 1123#endif
1124 dia.exec(); 1124 dia.exec();
1125} 1125}
1126void MainWindow::displayFile( QString fn, QString cap ) 1126void MainWindow::displayFile( QString fn, QString cap )
1127{ 1127{
1128 QString fileName = resourcePath() + fn; 1128 QString fileName = resourcePath() + fn;
1129 QString text; 1129 QString text;
1130 QFile file( fileName ); 1130 QFile file( fileName );
1131 if (!file.open( IO_ReadOnly ) ) { 1131 if (!file.open( IO_ReadOnly ) ) {
1132 return ; 1132 return ;
1133 1133
1134 } 1134 }
1135 QTextStream ts( &file ); 1135 QTextStream ts( &file );
1136 text = ts.read(); 1136 text = ts.read();
1137 file.close(); 1137 file.close();
1138 displayText( text, cap); 1138 displayText( text, cap);
1139} 1139}
1140void MainWindow::features() 1140void MainWindow::features()
1141{ 1141{
1142 1142
1143 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1143 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1144} 1144}
1145 1145
1146void MainWindow::usertrans() 1146void MainWindow::usertrans()
1147{ 1147{
1148 1148
1149 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1149 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1150} 1150}
1151 1151
1152void MainWindow::synchowto() 1152void MainWindow::synchowto()
1153{ 1153{
1154#if 0 1154#if 0
1155 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1155 QPtrList<Incidence> er = mCalendar->rawIncidences();
1156 Incidence* inR = er.first(); 1156 Incidence* inR = er.first();
1157 VCalFormat vf; 1157 VCalFormat vf;
1158 QString strout; 1158 QString strout;
1159 while ( inR ) { 1159 while ( inR ) {
1160 if ( inR->type() == "Todo" ) 1160 if ( inR->type() == "Todo" )
1161 strout = vf.todoToString( (Todo *) inR ); 1161 strout = vf.todoToString( (Todo *) inR );
1162 if ( inR->type() == "Event" ) 1162 if ( inR->type() == "Event" )
1163 strout = vf.eventToString( (Event *) inR ); 1163 strout = vf.eventToString( (Event *) inR );
1164 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1164 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1165 inR = er.next(); 1165 inR = er.next();
1166 } 1166 }
1167#endif 1167#endif
1168 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1168 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1169} 1169}
1170void MainWindow::faq() 1170void MainWindow::faq()
1171{ 1171{
1172 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1172 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1173 1173
1174} 1174}
1175void MainWindow::whatsNew() 1175void MainWindow::whatsNew()
1176{ 1176{
1177 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1177 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1178 1178
1179} 1179}
1180void MainWindow::licence() 1180void MainWindow::licence()
1181{ 1181{
1182 KApplication::showLicence(); 1182 KApplication::showLicence();
1183 1183
1184} 1184}
1185void MainWindow::about() 1185void MainWindow::about()
1186{ 1186{
1187 QString version; 1187 QString version;
1188#include <../version> 1188#include <../version>
1189 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1189 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1190 i18n("KOrganizer/Platform-independent\n") + 1190 i18n("KOrganizer/Platform-independent\n") +
1191 "(KO/Pi) " + version + " - " + 1191 "(KO/Pi) " + version + " - " +
1192 1192
1193#ifdef DESKTOP_VERSION 1193#ifdef DESKTOP_VERSION
1194 i18n("Desktop Edition\n") + 1194 i18n("Desktop Edition\n") +
1195#else 1195#else
1196 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1196 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1197#endif 1197#endif
1198 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") ); 1198 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") );
1199} 1199}
1200void MainWindow::keyBindings() 1200void MainWindow::keyBindings()
1201{ 1201{
1202 QString cap = i18n("Key bindings KOrganizer/Pi"); 1202 QString cap = i18n("Key bindings KOrganizer/Pi");
1203 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1203 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1204 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1204 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1205 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1205 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1206 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1206 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1207 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1207 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1208 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1208 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1209 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1209 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1210 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1210 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1211 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1211 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1212 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1212 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1213 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1213 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1214 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1214 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1215 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1215 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1216 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1216 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1217 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1217 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1218 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1218 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1219 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1219 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1220 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1220 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1221 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1221 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1222 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1222 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1223 i18n("<p><h3>In agenda view:</h3></p>\n") + 1223 i18n("<p><h3>In agenda view:</h3></p>\n") +
1224 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1224 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1225 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1225 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1226 i18n("<p><h3>In todo view:</h3></p>\n") + 1226 i18n("<p><h3>In todo view:</h3></p>\n") +
1227 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1227 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1228 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1228 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1229 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1229 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1230 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1230 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1231 i18n("<p><h3>In list view:</h3></p>\n") + 1231 i18n("<p><h3>In list view:</h3></p>\n") +
1232 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1232 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1233 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1233 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1234 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1234 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1235 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1235 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1236 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1236 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1237 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1237 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1238 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1238 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1239 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1239 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1240 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1240 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1241 i18n("<p><b>E</b>: Edit item</p>\n") + 1241 i18n("<p><b>E</b>: Edit item</p>\n") +
1242 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1242 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1243 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1243 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1244 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1244 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1245 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1245 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1246 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1246 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1247 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1247 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1248 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1248 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1249 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1249 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1250 i18n("<p><b>White</b>: Item readonly</p>\n"); 1250 i18n("<p><b>White</b>: Item readonly</p>\n");
1251 displayText( text, cap); 1251 displayText( text, cap);
1252 1252
1253} 1253}
1254void MainWindow::aboutAutoSaving() 1254void MainWindow::aboutAutoSaving()
1255{ 1255{
1256 QMessageBox* msg; 1256 QMessageBox* msg;
1257 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1257 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1258 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, 1258 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,
1259 QMessageBox::Ok, 1259 QMessageBox::Ok,
1260 QMessageBox::NoButton, 1260 QMessageBox::NoButton,
1261 QMessageBox::NoButton); 1261 QMessageBox::NoButton);
1262 msg->exec(); 1262 msg->exec();
1263 delete msg; 1263 delete msg;
1264 1264
1265 1265
1266} 1266}
1267void MainWindow::aboutKnownBugs() 1267void MainWindow::aboutKnownBugs()
1268{ 1268{
1269 QMessageBox* msg; 1269 QMessageBox* msg;
1270 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1270 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1271 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")+ 1271 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")+
1272 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1272 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1273 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1273 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1274 i18n("\nor report them in the bugtracker on\n") + 1274 i18n("\nor report them in the bugtracker on\n") +
1275 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1275 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1276 QMessageBox::NoIcon, 1276 QMessageBox::NoIcon,
1277 QMessageBox::Ok, 1277 QMessageBox::Ok,
1278 QMessageBox::NoButton, 1278 QMessageBox::NoButton,
1279 QMessageBox::NoButton); 1279 QMessageBox::NoButton);
1280 msg->exec(); 1280 msg->exec();
1281 delete msg; 1281 delete msg;
1282 1282
1283} 1283}
1284 1284
1285QString MainWindow::defaultFileName() 1285QString MainWindow::defaultFileName()
1286{ 1286{
1287 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1287 return locateLocal( "data", "korganizer/mycalendar.ics" );
1288} 1288}
1289 1289
1290void MainWindow::processIncidenceSelection( Incidence *incidence ) 1290void MainWindow::processIncidenceSelection( Incidence *incidence )
1291{ 1291{
1292 if ( !incidence ) { 1292 if ( !incidence ) {
1293 enableIncidenceActions( false ); 1293 enableIncidenceActions( false );
1294 1294
1295 mNewSubTodoAction->setEnabled( false ); 1295 mNewSubTodoAction->setEnabled( false );
1296 setCaptionToDates(); 1296 setCaptionToDates();
1297 return; 1297 return;
1298 1298
1299 } 1299 }
1300 1300
1301 //KGlobal::locale()->formatDateTime(nextA, true); 1301 //KGlobal::locale()->formatDateTime(nextA, true);
1302 QString startString = ""; 1302 QString startString = "";
1303 if ( incidence->type() != "Todo" ) { 1303 if ( incidence->type() != "Todo" ) {
1304 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1304 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1305 if ( incidence->doesFloat() ) { 1305 if ( incidence->doesFloat() ) {
1306 startString += ": "+incidence->dtStartDateStr( true ); 1306 startString += ": "+incidence->dtStartDateStr( true );
1307 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1307 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1308 1308
1309 } else { 1309 } else {
1310 startString = ": "+incidence->dtStartStr(true); 1310 startString = ": "+incidence->dtStartStr(true);
1311 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1311 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1312 1312
1313 } 1313 }
1314 1314
1315 } else { 1315 } else {
1316 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1316 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1317 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1317 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1318 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1318 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1319 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1319 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1320 } 1320 }
1321 1321
1322 } 1322 }
1323 else 1323 else
1324 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1324 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1325 if ( !incidence->location().isEmpty() ) 1325 if ( !incidence->location().isEmpty() )
1326 startString += " (" +incidence->location()+")"; 1326 startString += " (" +incidence->location()+")";
1327 setCaption( incidence->summary()+startString); 1327 setCaption( incidence->summary()+startString);
1328 1328
1329 enableIncidenceActions( true ); 1329 enableIncidenceActions( true );
1330 1330
1331 if ( incidence->type() == "Event" ) { 1331 if ( incidence->type() == "Event" ) {
1332 mShowAction->setText( i18n("Show Event...") ); 1332 mShowAction->setText( i18n("Show Event...") );
1333 mEditAction->setText( i18n("Edit Event...") ); 1333 mEditAction->setText( i18n("Edit Event...") );
1334 mDeleteAction->setText( i18n("Delete Event...") ); 1334 mDeleteAction->setText( i18n("Delete Event...") );
1335 1335
1336 mNewSubTodoAction->setEnabled( false ); 1336 mNewSubTodoAction->setEnabled( false );
1337 } else if ( incidence->type() == "Todo" ) { 1337 } else if ( incidence->type() == "Todo" ) {
1338 mShowAction->setText( i18n("Show Todo...") ); 1338 mShowAction->setText( i18n("Show Todo...") );
1339 mEditAction->setText( i18n("Edit Todo...") ); 1339 mEditAction->setText( i18n("Edit Todo...") );
1340 mDeleteAction->setText( i18n("Delete Todo...") ); 1340 mDeleteAction->setText( i18n("Delete Todo...") );
1341 1341
1342 mNewSubTodoAction->setEnabled( true ); 1342 mNewSubTodoAction->setEnabled( true );
1343 } else { 1343 } else {
1344 mShowAction->setText( i18n("Show...") ); 1344 mShowAction->setText( i18n("Show...") );
1345 mShowAction->setText( i18n("Edit...") ); 1345 mShowAction->setText( i18n("Edit...") );
1346 mShowAction->setText( i18n("Delete...") ); 1346 mShowAction->setText( i18n("Delete...") );
1347 1347
1348 mNewSubTodoAction->setEnabled( false ); 1348 mNewSubTodoAction->setEnabled( false );
1349 } 1349 }
1350} 1350}
1351 1351
1352void MainWindow::enableIncidenceActions( bool enabled ) 1352void MainWindow::enableIncidenceActions( bool enabled )
1353{ 1353{
1354 mShowAction->setEnabled( enabled ); 1354 mShowAction->setEnabled( enabled );
1355 mEditAction->setEnabled( enabled ); 1355 mEditAction->setEnabled( enabled );
1356 mDeleteAction->setEnabled( enabled ); 1356 mDeleteAction->setEnabled( enabled );
1357} 1357}
1358 1358
1359void MainWindow::importOL() 1359void MainWindow::importOL()
1360{ 1360{
1361#ifdef _WIN32_ 1361#ifdef _WIN32_
1362 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1362 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1363 id->exec(); 1363 id->exec();
1364 delete id; 1364 delete id;
1365 mView->updateView(); 1365 mView->updateView();
1366#endif 1366#endif
1367} 1367}
1368void MainWindow::importBday() 1368void MainWindow::importBday()
1369{ 1369{
1370 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1370 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1371 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1371 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1372 i18n("Import!"), i18n("Cancel"), 0, 1372 i18n("Import!"), i18n("Cancel"), 0,
1373 0, 1 ); 1373 0, 1 );
1374 if ( result == 0 ) { 1374 if ( result == 0 ) {
1375 mView->importBday(); 1375 mView->importBday();
1376 1376
1377 } 1377 }
1378 1378
1379 1379
1380} 1380}
1381void MainWindow::importQtopia() 1381void MainWindow::importQtopia()
1382{ 1382{
1383#ifndef DESKTOP_VERSION 1383#ifndef DESKTOP_VERSION
1384 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1384 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1385 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"), 1385 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"),
1386 i18n("Import!"), i18n("Cancel"), 0, 1386 i18n("Import!"), i18n("Cancel"), 0,
1387 0, 1 ); 1387 0, 1 );
1388 if ( result == 0 ) { 1388 if ( result == 0 ) {
1389 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1389 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1390 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1390 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1391 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1391 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1392 mView->importQtopia( categories, datebook, todolist ); 1392 mView->importQtopia( categories, datebook, todolist );
1393 } 1393 }
1394#else 1394#else
1395 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1395 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1396 i18n("Not supported \non desktop!\n"), 1396 i18n("Not supported \non desktop!\n"),
1397 i18n("Ok"), i18n("Cancel"), 0, 1397 i18n("Ok"), i18n("Cancel"), 0,
1398 0, 1 ); 1398 0, 1 );
1399 1399
1400#endif 1400#endif
1401} 1401}
1402 1402
1403void MainWindow::saveOnClose() 1403void MainWindow::saveOnClose()
1404{ 1404{
1405 KOPrefs *p = KOPrefs::instance(); 1405 KOPrefs *p = KOPrefs::instance();
1406 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1406 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1407 p->mToolBarUp = iconToolBar->x() > width()/2 || 1407 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1408 iconToolBar->y() > height()/2; 1408 iconToolBar->y() > height()/2;
1409 mView->writeSettings(); 1409 mView->writeSettings();
1410 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1410 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1411 save(); 1411 save();
1412} 1412}
1413void MainWindow::slotModifiedChanged( bool changed ) 1413void MainWindow::slotModifiedChanged( bool changed )
1414{ 1414{
1415 if ( mBlockAtStartup ) 1415 if ( mBlockAtStartup )
1416 return; 1416 return;
1417 int msec; 1417 int msec;
1418 // we store the changes after 1 minute, 1418 // we store the changes after 1 minute,
1419 // and for safety reasons after 10 minutes again 1419 // and for safety reasons after 10 minutes again
1420 if ( !mBlockSaveFlag ) 1420 if ( !mBlockSaveFlag )
1421 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1421 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1422 else 1422 else
1423 msec = 1000 * 600; 1423 msec = 1000 * 600;
1424 mSaveTimer.start( msec, true ); // 1 minute 1424 mSaveTimer.start( msec, true ); // 1 minute
1425 qDebug("KO: Saving File in %d secs!", msec/1000); 1425 qDebug("KO: Saving File in %d secs!", msec/1000);
1426 mCalendarModifiedFlag = true; 1426 mCalendarModifiedFlag = true;
1427} 1427}
1428void MainWindow::save() 1428void MainWindow::save()
1429{ 1429{
1430 if ( mBlockSaveFlag ) 1430 if ( mBlockSaveFlag )
1431 return; 1431 return;
1432 bool store = mBlockSaveFlag; 1432 bool store = mBlockSaveFlag;
1433 mBlockSaveFlag = true; 1433 mBlockSaveFlag = true;
1434 if ( mView->checkFileVersion( defaultFileName()) ) { 1434 if ( mView->checkFileVersion( defaultFileName()) ) {
1435 1435
1436 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1436 QTime neededSaveTime = QDateTime::currentDateTime().time();
1437 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1437 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1438 qDebug("KO: Start saving data to file!"); 1438 qDebug("KO: Start saving data to file!");
1439 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1439 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1440 mView->saveCalendar( defaultFileName() ); 1440 mView->saveCalendar( defaultFileName() );
1441 1441
1442 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1442 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1443 mView->watchSavedFile(); 1443 mView->watchSavedFile();
1444 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1444 qDebug("KO: Needed %d ms for saving.",msNeeded );
1445 QString savemes; 1445 QString savemes;
1446 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1446 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1447 setCaption(savemes); 1447 setCaption(savemes);
1448 } else 1448 } else
1449 setCaption(i18n("Saving cancelled!")); 1449 setCaption(i18n("Saving cancelled!"));
1450 mCalendarModifiedFlag = false; 1450 mCalendarModifiedFlag = false;
1451 mBlockSaveFlag = store; 1451 mBlockSaveFlag = store;
1452} 1452}
1453 1453
1454void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1454void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1455{ 1455{
1456 if ( !e->isAutoRepeat() ) { 1456 if ( !e->isAutoRepeat() ) {
1457 mFlagKeyPressed = false; 1457 mFlagKeyPressed = false;
1458 } 1458 }
1459} 1459}
1460void MainWindow::keyPressEvent ( QKeyEvent * e ) 1460void MainWindow::keyPressEvent ( QKeyEvent * e )
1461{ 1461{
1462 qApp->processEvents(); 1462 qApp->processEvents();
1463 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1463 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1464 e->ignore(); 1464 e->ignore();
1465 // qDebug(" ignore %d",e->isAutoRepeat() ); 1465 // qDebug(" ignore %d",e->isAutoRepeat() );
1466 return; 1466 return;
1467 } 1467 }
1468 if (! e->isAutoRepeat() ) 1468 if (! e->isAutoRepeat() )
1469 mFlagKeyPressed = true; 1469 mFlagKeyPressed = true;
1470 KOPrefs *p = KOPrefs::instance(); 1470 KOPrefs *p = KOPrefs::instance();
1471 bool showSelectedDates = false; 1471 bool showSelectedDates = false;
1472 int size; 1472 int size;
1473 int pro = 0; 1473 int pro = 0;
1474 //qDebug("MainWindow::keyPressEvent "); 1474 //qDebug("MainWindow::keyPressEvent ");
1475 switch ( e->key() ) { 1475 switch ( e->key() ) {
1476 case Qt::Key_Right: 1476 case Qt::Key_Right:
1477 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1477 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1478 mView->goNextMonth(); 1478 mView->goNextMonth();
1479 else 1479 else
1480 mView->goNext(); 1480 mView->goNext();
1481 showSelectedDates = true; 1481 showSelectedDates = true;
1482 break; 1482 break;
1483 case Qt::Key_Left: 1483 case Qt::Key_Left:
1484 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1484 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1485 mView->goPreviousMonth(); 1485 mView->goPreviousMonth();
1486 else 1486 else
1487 mView->goPrevious(); 1487 mView->goPrevious();
1488 showSelectedDates = true; 1488 showSelectedDates = true;
1489 break; 1489 break;
1490 case Qt::Key_Down: 1490 case Qt::Key_Down:
1491 mView->viewManager()->agendaView()->scrollOneHourDown(); 1491 mView->viewManager()->agendaView()->scrollOneHourDown();
1492 break; 1492 break;
1493 case Qt::Key_Up: 1493 case Qt::Key_Up:
1494 mView->viewManager()->agendaView()->scrollOneHourUp(); 1494 mView->viewManager()->agendaView()->scrollOneHourUp();
1495 break; 1495 break;
1496 case Qt::Key_I: 1496 case Qt::Key_I:
1497 mView->showIncidence(); 1497 mView->showIncidence();
1498 break; 1498 break;
1499 case Qt::Key_Delete: 1499 case Qt::Key_Delete:
1500 case Qt::Key_Backspace: 1500 case Qt::Key_Backspace:
1501 mView->deleteIncidence(); 1501 mView->deleteIncidence();
1502 break; 1502 break;
1503 case Qt::Key_D: 1503 case Qt::Key_D:
1504 mView->viewManager()->showDayView(); 1504 mView->viewManager()->showDayView();
1505 showSelectedDates = true; 1505 showSelectedDates = true;
1506 break; 1506 break;
1507 case Qt::Key_O: 1507 case Qt::Key_O:
1508 mView->toggleFilerEnabled( ); 1508 mView->toggleFilerEnabled( );
1509 break; 1509 break;
1510 case Qt::Key_0: 1510 case Qt::Key_0:
1511 case Qt::Key_1: 1511 case Qt::Key_1:
1512 case Qt::Key_2: 1512 case Qt::Key_2:
1513 case Qt::Key_3: 1513 case Qt::Key_3:
1514 case Qt::Key_4: 1514 case Qt::Key_4:
1515 case Qt::Key_5: 1515 case Qt::Key_5:
1516 case Qt::Key_6: 1516 case Qt::Key_6:
1517 case Qt::Key_7: 1517 case Qt::Key_7:
1518 case Qt::Key_8: 1518 case Qt::Key_8:
1519 case Qt::Key_9: 1519 case Qt::Key_9:
1520 pro = e->key()-48; 1520 pro = e->key()-48;
1521 if ( pro == 0 ) 1521 if ( pro == 0 )
1522 pro = 10; 1522 pro = 10;
1523 if ( e->state() == Qt::ControlButton) 1523 if ( e->state() == Qt::ControlButton)
1524 pro += 10; 1524 pro += 10;
1525 break; 1525 break;
1526 case Qt::Key_M: 1526 case Qt::Key_M:
1527 mView->viewManager()->showMonthView(); 1527 mView->viewManager()->showMonthView();
1528 showSelectedDates = true; 1528 showSelectedDates = true;
1529 break; 1529 break;
1530 case Qt::Key_Insert: 1530 case Qt::Key_Insert:
1531 mView->newEvent(); 1531 mView->newEvent();
1532 break; 1532 break;
1533 case Qt::Key_S : 1533 case Qt::Key_S :
1534 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1534 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1535 mView->newSubTodo(); 1535 mView->newSubTodo();
1536 else 1536 else
1537 mView->dialogManager()->showSearchDialog(); 1537 mView->dialogManager()->showSearchDialog();
1538 break; 1538 break;
1539 case Qt::Key_Y : 1539 case Qt::Key_Y :
1540 case Qt::Key_Z : 1540 case Qt::Key_Z :
1541 mView->viewManager()->showWorkWeekView(); 1541 mView->viewManager()->showWorkWeekView();
1542 showSelectedDates = true; 1542 showSelectedDates = true;
1543 break; 1543 break;
1544 case Qt::Key_U : 1544 case Qt::Key_U :
1545 mView->viewManager()->showWeekView(); 1545 mView->viewManager()->showWeekView();
1546 showSelectedDates = true; 1546 showSelectedDates = true;
1547 break; 1547 break;
1548 case Qt::Key_H : 1548 case Qt::Key_H :
1549 keyBindings(); 1549 keyBindings();
1550 break; 1550 break;
1551 case Qt::Key_W: 1551 case Qt::Key_W:
1552 mView->viewManager()->showWhatsNextView(); 1552 mView->viewManager()->showWhatsNextView();
1553 break; 1553 break;
1554 case Qt::Key_L: 1554 case Qt::Key_L:
1555 mView->viewManager()->showListView(); 1555 mView->viewManager()->showListView();
1556 break; 1556 break;
1557 case Qt::Key_N: 1557 case Qt::Key_N:
1558 mView->viewManager()->showNextXView(); 1558 mView->viewManager()->showNextXView();
1559 showSelectedDates = true; 1559 showSelectedDates = true;
1560 break; 1560 break;
1561 case Qt::Key_V: 1561 case Qt::Key_V:
1562 mView->viewManager()->showTodoView(); 1562 mView->viewManager()->showTodoView();
1563 break; 1563 break;
1564 case Qt::Key_C: 1564 case Qt::Key_C:
1565 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1565 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1566 break; 1566 break;
1567 case Qt::Key_P: 1567 case Qt::Key_P:
1568 mView->showDatePicker( ); 1568 mView->showDatePicker( );
1569 break; 1569 break;
1570 case Qt::Key_F: 1570 case Qt::Key_F:
1571 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1571 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1572 mView->editFilters(); 1572 mView->editFilters();
1573 else 1573 else
1574 mView->toggleFilter(); 1574 mView->toggleFilter();
1575 break; 1575 break;
1576 case Qt::Key_X: 1576 case Qt::Key_X:
1577 mView->toggleDateNavigatorWidget(); 1577 mView->toggleDateNavigatorWidget();
1578 break; 1578 break;
1579 case Qt::Key_Space: 1579 case Qt::Key_Space:
1580 mView->toggleExpand(); 1580 mView->toggleExpand();
1581 break; 1581 break;
1582 case Qt::Key_A: 1582 case Qt::Key_A:
1583 mView->toggleAllDaySize(); 1583 mView->toggleAllDaySize();
1584 break; 1584 break;
1585 case Qt::Key_T: 1585 case Qt::Key_T:
1586 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1586 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1587 mView->newTodo(); 1587 mView->newTodo();
1588 else { 1588 else {
1589 mView->goToday(); 1589 mView->goToday();
1590 showSelectedDates = true; 1590 showSelectedDates = true;
1591 } 1591 }
1592 break; 1592 break;
1593 case Qt::Key_J: 1593 case Qt::Key_J:
1594 mView->viewManager()->showJournalView(); 1594 mView->viewManager()->showJournalView();
1595 break; 1595 break;
1596 case Qt::Key_B: 1596 case Qt::Key_B:
1597 mView->editIncidenceDescription();; 1597 mView->editIncidenceDescription();;
1598 break; 1598 break;
1599 // case Qt::Key_Return: 1599 // case Qt::Key_Return:
1600 case Qt::Key_E: 1600 case Qt::Key_E:
1601 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1601 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1602 mView->newEvent(); 1602 mView->newEvent();
1603 else 1603 else
1604 mView->editIncidence(); 1604 mView->editIncidence();
1605 break; 1605 break;
1606 case Qt::Key_Plus: 1606 case Qt::Key_Plus:
1607 size = p->mHourSize +2; 1607 size = p->mHourSize +2;
1608 if ( size <= 18 ) 1608 if ( size <= 18 )
1609 configureAgenda( size ); 1609 configureAgenda( size );
1610 break; 1610 break;
1611 case Qt::Key_Minus: 1611 case Qt::Key_Minus:
1612 size = p->mHourSize - 2; 1612 size = p->mHourSize - 2;
1613 if ( size >= 4 ) 1613 if ( size >= 4 )
1614 configureAgenda( size ); 1614 configureAgenda( size );
1615 break; 1615 break;
1616 1616
1617 1617
1618 default: 1618 default:
1619 e->ignore(); 1619 e->ignore();
1620 } 1620 }
1621 if ( pro > 0 ) { 1621 if ( pro > 0 ) {
1622 mView->selectFilter( pro-1 ); 1622 mView->selectFilter( pro-1 );
1623 } 1623 }
1624 if ( showSelectedDates ) { 1624 if ( showSelectedDates ) {
1625 ;// setCaptionToDates(); 1625 ;// setCaptionToDates();
1626 } 1626 }
1627 1627
1628} 1628}
1629 1629
1630void MainWindow::fillFilterMenu() 1630void MainWindow::fillFilterMenu()
1631{ 1631{
1632 selectFilterMenu->clear(); 1632 selectFilterMenu->clear();
1633 bool disable = false; 1633 bool disable = false;
1634 if ( mView->filterView()->filtersEnabled() ) { 1634 if ( mView->filterView()->filtersEnabled() ) {
1635 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1635 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1636 } 1636 }
1637 else { 1637 else {
1638 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1638 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1639 disable = true; 1639 disable = true;
1640 } 1640 }
1641 selectFilterMenu->insertSeparator(); 1641 selectFilterMenu->insertSeparator();
1642 QPtrList<CalFilter> fili = mView->filters(); 1642 QPtrList<CalFilter> fili = mView->filters();
1643 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1643 CalFilter *curfilter = mView->filterView()->selectedFilter();
1644 CalFilter *filter = fili.first(); 1644 CalFilter *filter = fili.first();
1645 int iii = 1; 1645 int iii = 1;
1646 while(filter) { 1646 while(filter) {
1647 selectFilterMenu->insertItem( filter->name(), iii ); 1647 selectFilterMenu->insertItem( filter->name(), iii );
1648 if ( filter == curfilter) 1648 if ( filter == curfilter)
1649 selectFilterMenu->setItemChecked( iii, true ); 1649 selectFilterMenu->setItemChecked( iii, true );
1650 if ( disable ) 1650 if ( disable )
1651 selectFilterMenu->setItemEnabled( iii, false ); 1651 selectFilterMenu->setItemEnabled( iii, false );
1652 filter = fili.next(); 1652 filter = fili.next();
1653 ++iii; 1653 ++iii;
1654 } 1654 }
1655} 1655}
1656void MainWindow::selectFilter( int fil ) 1656void MainWindow::selectFilter( int fil )
1657{ 1657{
1658 if ( fil == 0 ) { 1658 if ( fil == 0 ) {
1659 mView->toggleFilerEnabled( ); 1659 mView->toggleFilerEnabled( );
1660 } else { 1660 } else {
1661 mView->selectFilter( fil-1 ); 1661 mView->selectFilter( fil-1 );
1662 } 1662 }
1663} 1663}
1664void MainWindow::configureToolBar( int item ) 1664void MainWindow::configureToolBar( int item )
1665{ 1665{
1666 1666
1667 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1667 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1668 KOPrefs *p = KOPrefs::instance(); 1668 KOPrefs *p = KOPrefs::instance();
1669 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1669 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1670 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1670 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1671 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1671 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1672 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1672 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1673 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1673 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1674 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1674 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1675 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1675 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1676 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1676 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1677 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1677 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1678 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1678 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1679 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1679 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1680 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1680 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1681 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1681 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1682 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1682 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1683 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1683 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1684 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1684 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1685 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1685 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1686 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1686 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1687 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1687 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1688 // initActions(); 1688 // initActions();
1689} 1689}
1690 1690
1691void MainWindow::setCaptionToDates() 1691void MainWindow::setCaptionToDates()
1692{ 1692{
1693 QString selDates; 1693 QString selDates;
1694 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1694 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1695 if (mView->startDate() < mView->endDate() ) 1695 if (mView->startDate() < mView->endDate() )
1696 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1696 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1697 setCaption( i18n("Dates: ") + selDates ); 1697 setCaption( i18n("Dates: ") + selDates );
1698 1698
1699} 1699}
1700// parameter item == 0: reinit 1700// parameter item == 0: reinit
1701void MainWindow::configureAgenda( int item ) 1701void MainWindow::configureAgenda( int item )
1702{ 1702{
1703 1703
1704 KOPrefs *p = KOPrefs::instance(); 1704 KOPrefs *p = KOPrefs::instance();
1705 1705
1706 int i; 1706 int i;
1707 if ( item == 1 ) { 1707 if ( item == 1 ) {
1708 mView->toggleAllDaySize(); 1708 mView->toggleAllDaySize();
1709 return; 1709 return;
1710 } 1710 }
1711 // do not allow 4 for widgets higher than 480 1711 // do not allow 4 for widgets higher than 480
1712 // if ( QApplication::desktop()->height() > 480 ) { 1712 // if ( QApplication::desktop()->height() > 480 ) {
1713// if ( item == 4 ) 1713// if ( item == 4 )
1714// item = 6; 1714// item = 6;
1715// } 1715// }
1716 for ( i = 4; i <= 18; i= i+2 ) 1716 for ( i = 4; i <= 18; i= i+2 )
1717 configureAgendaMenu->setItemChecked( i, false ); 1717 configureAgendaMenu->setItemChecked( i, false );
1718 configureAgendaMenu->setItemChecked( item, true ); 1718 configureAgendaMenu->setItemChecked( item, true );
1719 if ( p->mHourSize == item ) 1719 if ( p->mHourSize == item )
1720 return; 1720 return;
1721 p->mHourSize=item; 1721 p->mHourSize=item;
1722 mView->viewManager()->agendaView()->updateConfig(); 1722 mView->viewManager()->agendaView()->updateConfig();
1723} 1723}
1724 1724
1725void MainWindow::saveCalendar() 1725void MainWindow::saveCalendar()
1726{ 1726{
1727 QString fn = KOPrefs::instance()->mLastSaveFile; 1727 QString fn = KOPrefs::instance()->mLastSaveFile;
1728 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1728 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1729 1729
1730 if ( fn == "" ) 1730 if ( fn == "" )
1731 return; 1731 return;
1732 QFileInfo info; 1732 QFileInfo info;
1733 info.setFile( fn ); 1733 info.setFile( fn );
1734 QString mes; 1734 QString mes;
1735 bool createbup = true; 1735 bool createbup = true;
1736 if ( info. exists() ) { 1736 if ( info. exists() ) {
1737 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1737 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1738 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1738 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1739 i18n("Overwrite!"), i18n("Cancel"), 0, 1739 i18n("Overwrite!"), i18n("Cancel"), 0,
1740 0, 1 ); 1740 0, 1 );
1741 if ( result != 0 ) { 1741 if ( result != 0 ) {
1742 createbup = false; 1742 createbup = false;
1743 } 1743 }
1744 } 1744 }
1745 if ( createbup ) { 1745 if ( createbup ) {
1746 mView->saveCalendar( fn ); 1746 mView->saveCalendar( fn );
1747 mes = i18n("KO/Pi:Saved %1").arg(fn); 1747 mes = i18n("KO/Pi:Saved %1").arg(fn);
1748 KOPrefs::instance()->mLastSaveFile = fn; 1748 KOPrefs::instance()->mLastSaveFile = fn;
1749 setCaption(mes); 1749 setCaption(mes);
1750 } 1750 }
1751} 1751}
1752void MainWindow::loadCalendar() 1752void MainWindow::loadCalendar()
1753{ 1753{
1754 1754
1755 QString fn = KOPrefs::instance()->mLastLoadFile; 1755 QString fn = KOPrefs::instance()->mLastLoadFile;
1756 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1756 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1757 1757
1758 if ( fn == "" ) 1758 if ( fn == "" )
1759 return; 1759 return;
1760 QFileInfo info; 1760 QFileInfo info;
1761 info.setFile( fn ); 1761 info.setFile( fn );
1762 QString mess; 1762 QString mess;
1763 bool loadbup = true; 1763 bool loadbup = true;
1764 if ( info. exists() ) { 1764 if ( info. exists() ) {
1765 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1765 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1766 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1766 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1767 mess, 1767 mess,
1768 i18n("Load!"), i18n("Cancel"), 0, 1768 i18n("Load!"), i18n("Cancel"), 0,
1769 0, 1 ); 1769 0, 1 );
1770 if ( result != 0 ) { 1770 if ( result != 0 ) {
1771 loadbup = false; 1771 loadbup = false;
1772 } 1772 }
1773 } else { 1773 } else {
1774 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1774 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1775 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1775 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1776 0, 1 ); 1776 0, 1 );
1777 1777
1778 return; 1778 return;
1779 } 1779 }
1780 if ( loadbup ) { 1780 if ( loadbup ) {
1781 mView->openCalendar( fn ); 1781 mView->openCalendar( fn );
1782 KOPrefs::instance()->mLastLoadFile = fn; 1782 KOPrefs::instance()->mLastLoadFile = fn;
1783 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1783 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1784 setCaption(mess); 1784 setCaption(mess);
1785 } 1785 }
1786 1786
1787} 1787}
1788void MainWindow::quickImportIcal() 1788void MainWindow::quickImportIcal()
1789{ 1789{
1790 importFile( KOPrefs::instance()->mLastImportFile, false ); 1790 importFile( KOPrefs::instance()->mLastImportFile, false );
1791} 1791}
1792void MainWindow::importFile( QString fn, bool quick ) 1792void MainWindow::importFile( QString fn, bool quick )
1793{ 1793{
1794 QFileInfo info; 1794 QFileInfo info;
1795 info.setFile( fn ); 1795 info.setFile( fn );
1796 QString mess; 1796 QString mess;
1797 bool loadbup = true; 1797 bool loadbup = true;
1798 if ( !info. exists() ) { 1798 if ( !info. exists() ) {
1799 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1799 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1800 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1800 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1801 mess ); 1801 mess );
1802 return; 1802 return;
1803 } 1803 }
1804 int result = 0; 1804 int result = 0;
1805 if ( !quick ) { 1805 if ( !quick ) {
1806 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 )); 1806 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 ));
1807 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1807 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1808 mess, 1808 mess,
1809 "Import", "Cancel", 0, 1809 "Import", "Cancel", 0,
1810 0, 1 ); 1810 0, 1 );
1811 } 1811 }
1812 if ( result == 0 ) { 1812 if ( result == 0 ) {
1813 if ( mView->openCalendar( fn, true )) { 1813 if ( mView->openCalendar( fn, true )) {
1814 KOPrefs::instance()->mLastImportFile = fn; 1814 KOPrefs::instance()->mLastImportFile = fn;
1815 setCaption(i18n("Imported file successfully")); 1815 setCaption(i18n("Imported file successfully"));
1816 } else { 1816 } else {
1817 setCaption(i18n("Error importing file")); 1817 setCaption(i18n("Error importing file"));
1818 } 1818 }
1819 } 1819 }
1820} 1820}
1821 1821
1822void MainWindow::importIcal() 1822void MainWindow::importIcal()
1823{ 1823{
1824 1824
1825 QString fn =KOPrefs::instance()->mLastImportFile; 1825 QString fn =KOPrefs::instance()->mLastImportFile;
1826 1826
1827 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1827 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1828 if ( fn == "" ) 1828 if ( fn == "" )
1829 return; 1829 return;
1830 importFile( fn, true ); 1830 importFile( fn, true );
1831 1831
1832} 1832}
1833 1833
1834void MainWindow::exportVCalendar() 1834void MainWindow::exportVCalendar()
1835{ 1835{
1836 QString fn = KOPrefs::instance()->mLastVcalFile; 1836 QString fn = KOPrefs::instance()->mLastVcalFile;
1837 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1837 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1838 if ( fn == "" ) 1838 if ( fn == "" )
1839 return; 1839 return;
1840 QFileInfo info; 1840 QFileInfo info;
1841 info.setFile( fn ); 1841 info.setFile( fn );
1842 QString mes; 1842 QString mes;
1843 bool createbup = true; 1843 bool createbup = true;
1844 if ( info. exists() ) { 1844 if ( info. exists() ) {
1845 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1845 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1846 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1846 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1847 i18n("Overwrite!"), i18n("Cancel"), 0, 1847 i18n("Overwrite!"), i18n("Cancel"), 0,
1848 0, 1 ); 1848 0, 1 );
1849 if ( result != 0 ) { 1849 if ( result != 0 ) {
1850 createbup = false; 1850 createbup = false;
1851 } 1851 }
1852 } 1852 }
1853 if ( createbup ) { 1853 if ( createbup ) {
1854 if ( mView->exportVCalendar( fn ) ) { 1854 if ( mView->exportVCalendar( fn ) ) {
1855 KOPrefs::instance()->mLastVcalFile = fn; 1855 KOPrefs::instance()->mLastVcalFile = fn;
1856 if ( fn.length() > 20 ) 1856 if ( fn.length() > 20 )
1857 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1857 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1858 else 1858 else
1859 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1859 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1860 setCaption(mes); 1860 setCaption(mes);
1861 } 1861 }
1862 } 1862 }
1863 1863
1864} 1864}
1865QString MainWindow::getPassword( ) 1865QString MainWindow::getPassword( )
1866{ 1866{
1867 QString retfile = ""; 1867 QString retfile = "";
1868 QDialog dia ( this, "input-dialog", true ); 1868 QDialog dia ( this, "input-dialog", true );
1869 QLineEdit lab ( &dia ); 1869 QLineEdit lab ( &dia );
1870 lab.setEchoMode( QLineEdit::Password ); 1870 lab.setEchoMode( QLineEdit::Password );
1871 QVBoxLayout lay( &dia ); 1871 QVBoxLayout lay( &dia );
1872 lay.setMargin(7); 1872 lay.setMargin(7);
1873 lay.setSpacing(7); 1873 lay.setSpacing(7);
1874 lay.addWidget( &lab); 1874 lay.addWidget( &lab);
1875 dia.setFixedSize( 230,50 ); 1875 dia.setFixedSize( 230,50 );
1876 dia.setCaption( i18n("Enter password") ); 1876 dia.setCaption( i18n("Enter password") );
1877 QPushButton pb ( "OK", &dia); 1877 QPushButton pb ( "OK", &dia);
1878 lay.addWidget( &pb ); 1878 lay.addWidget( &pb );
1879 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1879 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1880 dia.show(); 1880 dia.show();
1881 int res = dia.exec(); 1881 int res = dia.exec();
1882 if ( res ) 1882 if ( res )
1883 retfile = lab.text(); 1883 retfile = lab.text();
1884 dia.hide(); 1884 dia.hide();
1885 qApp->processEvents(); 1885 qApp->processEvents();
1886 return retfile; 1886 return retfile;
1887 1887
1888} 1888}
1889 1889
1890void MainWindow::enableQuick() 1890void MainWindow::enableQuick()
1891{ 1891{
1892 QString retfile = ""; 1892 QString retfile = "";
1893 QDialog dia ( this, "input-dialog", true ); 1893 QDialog dia ( this, "input-dialog", true );
1894 QLineEdit lab ( &dia ); 1894 QLineEdit lab ( &dia );
1895 QVBoxLayout lay( &dia ); 1895 QVBoxLayout lay( &dia );
1896 lab.setText( KOPrefs::instance()->mPassiveSyncPort ); 1896 lab.setText( KOPrefs::instance()->mPassiveSyncPort );
1897 lay.setMargin(7); 1897 lay.setMargin(7);
1898 lay.setSpacing(7); 1898 lay.setSpacing(7);
1899 QLabel label ( i18n("Port number (Default: 9197)"), &dia ); 1899 QLabel label ( i18n("Port number (Default: 9197)"), &dia );
1900 lay.addWidget( &label); 1900 lay.addWidget( &label);
1901 lay.addWidget( &lab); 1901 lay.addWidget( &lab);
1902 dia.setFixedSize( 230,80 ); 1902 dia.setFixedSize( 230,80 );
1903 dia.setCaption( i18n("Enter port for Easy-Pi-Sync") ); 1903 dia.setCaption( i18n("Enter port for Easy-Pi-Sync") );
1904 QPushButton pb ( "OK", &dia); 1904 QPushButton pb ( "OK", &dia);
1905 lay.addWidget( &pb ); 1905 lay.addWidget( &pb );
1906 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1906 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1907 dia.show(); 1907 dia.show();
1908 int res = dia.exec(); 1908 int res = dia.exec();
1909 if ( res ) 1909 if ( res )
1910 retfile = lab.text(); 1910 retfile = lab.text();
1911 else 1911 else
1912 return; 1912 return;
1913 dia.hide(); 1913 dia.hide();
1914 qApp->processEvents(); 1914 qApp->processEvents();
1915 KOPrefs::instance()->mPassiveSyncPort = retfile; 1915 KOPrefs::instance()->mPassiveSyncPort = retfile;
1916 bool ok; 1916 bool ok;
1917 Q_UINT16 port = retfile.toUInt(&ok); 1917 Q_UINT16 port = retfile.toUInt(&ok);
1918 if ( ! ok ) { 1918 if ( ! ok ) {
1919 qDebug("no valid port "); 1919 qDebug("no valid port ");
1920 return; 1920 return;
1921 } 1921 }
1922 qDebug("port %d ", port); 1922 qDebug("port %d ", port);
1923 mServerSocket = new KServerSocket ( port ,1 ); 1923 mServerSocket = new KServerSocket ( port ,1 );
1924 qDebug("connected "); 1924 qDebug("connected ");
1925 if ( !mServerSocket->ok() ) { 1925 if ( !mServerSocket->ok() ) {
1926 qWarning("Failed to bind to port %d", port); 1926 qWarning("Failed to bind to port %d", port);
1927 delete mServerSocket; 1927 delete mServerSocket;
1928 mServerSocket = 0; 1928 mServerSocket = 0;
1929 return; 1929 return;
1930 } 1930 }
1931 connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); 1931 connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) );
1932 connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); 1932 connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) );
1933} 1933}
1934void MainWindow::sendFile(QSocket* socket) 1934void MainWindow::sendFile(QSocket* socket)
1935{ 1935{
1936 setCaption( i18n("Received request for file") ); 1936 setCaption( i18n("Received request for file") );
1937 qDebug("MainWindow::sendFile(QSocket* s) "); 1937 qDebug("MainWindow::sendFile(QSocket* s) ");
1938 if ( mSyncActionDialog ) 1938 if ( mSyncActionDialog )
1939 delete mSyncActionDialog; 1939 delete mSyncActionDialog;
1940 mSyncActionDialog = new QDialog ( this, "input-dialog", true ); 1940 mSyncActionDialog = new QDialog ( this, "input-dialog", true );
1941 mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING")); 1941 mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING"));
1942 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog ); 1942 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog );
1943 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1943 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1944 lay->addWidget( label); 1944 lay->addWidget( label);
1945 lay->setMargin(7); 1945 lay->setMargin(7);
1946 lay->setSpacing(7); 1946 lay->setSpacing(7);
1947 mSyncActionDialog->setFixedSize( 200,100 ); 1947 mSyncActionDialog->setFixedSize( 200,100 );
1948 mSyncActionDialog->show(); 1948 mSyncActionDialog->show();
1949 qApp->processEvents(); 1949 qApp->processEvents();
1950 qDebug("saving ... "); 1950 qDebug("saving ... ");
1951 save(); 1951 save();
1952 QString fileName = defaultFileName(); 1952 QString fileName = defaultFileName();
1953 QFile file( fileName ); 1953 QFile file( fileName );
1954 if (!file.open( IO_ReadOnly ) ) { 1954 if (!file.open( IO_ReadOnly ) ) {
1955 setCaption( i18n("Error open file") ); 1955 setCaption( i18n("Error open file") );
1956 delete mSyncActionDialog; 1956 delete mSyncActionDialog;
1957 mSyncActionDialog = 0; 1957 mSyncActionDialog = 0;
1958 qDebug("error open cal file "); 1958 qDebug("error open cal file ");
1959 return ; 1959 return ;
1960 1960
1961 } 1961 }
1962 setCaption( i18n("Sending file...") ); 1962 setCaption( i18n("Sending file...") );
1963 QTextStream ts( &file ); 1963 QTextStream ts( &file );
1964 ts.setCodec( QTextCodec::codecForName("utf8") ); 1964 ts.setCodec( QTextCodec::codecForName("utf8") );
1965 QTextStream os( socket ); 1965 QTextStream os( socket );
1966 os.setCodec( QTextCodec::codecForName("utf8") ); 1966 os.setCodec( QTextCodec::codecForName("utf8") );
1967 //os.setEncoding( QTextStream::UnicodeUTF8 ); 1967 //os.setEncoding( QTextStream::UnicodeUTF8 );
1968 while ( ! ts.atEnd() ) { 1968 while ( ! ts.atEnd() ) {
1969 os << ts.readLine() << "\n"; 1969 os << ts.readLine() << "\n";
1970 } 1970 }
1971 //os << ts.read(); 1971 //os << ts.read();
1972 socket->close(); 1972 socket->close();
1973 file.close(); 1973 file.close();
1974 setCaption( i18n("File sent. Waiting to get back synced file") ); 1974 setCaption( i18n("File sent. Waiting to get back synced file") );
1975 qDebug("file sent "); 1975 qDebug("file sent ");
1976} 1976}
1977void MainWindow::getFile(QSocket* socket) 1977void MainWindow::getFile(QSocket* socket)
1978{ 1978{
1979 setCaption( i18n("Receiving synced file...") ); 1979 setCaption( i18n("Receiving synced file...") );
1980 1980
1981 QString fileName = defaultFileName(); 1981 QString fileName = defaultFileName();
1982 QFile file( fileName ); 1982 QFile file( fileName );
1983 if (!file.open( IO_WriteOnly ) ) { 1983 if (!file.open( IO_WriteOnly ) ) {
1984 setCaption( i18n("Error open file") ); 1984 setCaption( i18n("Error open file") );
1985 delete mSyncActionDialog; 1985 delete mSyncActionDialog;
1986 mSyncActionDialog = 0; 1986 mSyncActionDialog = 0;
1987 qDebug("error open cal file "); 1987 qDebug("error open cal file ");
1988 return ; 1988 return ;
1989 1989
1990 } 1990 }
1991 1991
1992 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1992 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1993 QTextStream ts( &file ); 1993 QTextStream ts( &file );
1994 ts.setCodec( QTextCodec::codecForName("utf8") ); 1994 ts.setCodec( QTextCodec::codecForName("utf8") );
1995 bool first = true; 1995 bool first = true;
1996 while ( socket->canReadLine () || first ) { 1996 while ( socket->canReadLine () || first ) {
1997 first = false; 1997 first = false;
1998 while ( socket->canReadLine () ) { 1998 while ( socket->canReadLine () ) {
1999 qDebug("avail %d ", socket->bytesAvailable () ); 1999 qDebug("avail %d ", socket->bytesAvailable () );
2000 ts << socket->readLine (); 2000 ts << socket->readLine ();
2001 } 2001 }
2002 QTime ti; 2002 QTime ti;
2003 ti.start(); 2003 ti.start();
2004 while ( ti.elapsed () < 5000 && !socket->canReadLine () ) { 2004 while ( ti.elapsed () < 5000 && !socket->canReadLine () ) {
2005 qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () ); 2005 qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () );
2006 //qApp->processEvents(); 2006 //qApp->processEvents();
2007 qDebug("waiting1b %d ",ti.elapsed () ); 2007 qDebug("waiting1b %d ",ti.elapsed () );
2008 if ( !socket->canReadLine () ) { 2008 if ( !socket->canReadLine () ) {
2009 qDebug("waiting1c %d ",ti.elapsed () ); 2009 qDebug("waiting1c %d ",ti.elapsed () );
2010#ifndef _WIN32_
2010 usleep( 100000); 2011 usleep( 100000);
2012#endif
2011 } 2013 }
2012 //socket->waitForMore ( 100 ); 2014 //socket->waitForMore ( 100 );
2013 } 2015 }
2014 ts << socket->readLine (); 2016 ts << socket->readLine ();
2015#if 0 2017#if 0
2016#ifdef DESKTOP_VERSION 2018#ifdef DESKTOP_VERSION
2017 socket->waitForMore ( 5000 ); 2019 socket->waitForMore ( 5000 );
2018#else 2020#else
2019 // socket->waitForMore ( 5000 ); 2021 // socket->waitForMore ( 5000 );
2020 // seems to be broken in qt2 2022 // seems to be broken in qt2
2021 bool stop = false; 2023 bool stop = false;
2022 QTime ti; 2024 QTime ti;
2023 ti.start(); 2025 ti.start();
2024 while ( ti.elapsed < 5000 && !stop ) { 2026 while ( ti.elapsed < 5000 && !stop ) {
2025 qApp->processEvents(); 2027 qApp->processEvents();
2026 if ( socket->canReadLine () ) 2028 if ( socket->canReadLine () )
2027 stop = true ; 2029 stop = true ;
2028 else { 2030 else {
2029 usleep( 100000 ); 2031 usleep( 100000 );
2030 2032
2031 } 2033 }
2032 } 2034 }
2033#endif 2035#endif
2034#endif 2036#endif
2035 } 2037 }
2036 setCaption( i18n("File received - reloading calendar...") ); 2038 setCaption( i18n("File received - reloading calendar...") );
2037 socket->close(); 2039 socket->close();
2038 file.close(); 2040 file.close();
2039 mView->watchSavedFile(); 2041 mView->watchSavedFile();
2040 mView->openCalendar( defaultFileName() ); 2042 mView->openCalendar( defaultFileName() );
2041 setCaption( i18n("Easy-Pi-Sync successful!") ); 2043 setCaption( i18n("Easy-Pi-Sync successful!") );
2042 delete mSyncActionDialog; 2044 delete mSyncActionDialog;
2043 mSyncActionDialog = 0; 2045 mSyncActionDialog = 0;
2044 2046
2045 2047
2046} 2048}
2047void MainWindow::endConnect() 2049void MainWindow::endConnect()
2048{ 2050{
2049 setCaption( i18n("No file received - syncing successful") ); 2051 setCaption( i18n("No file received - syncing successful") );
2050 delete mSyncActionDialog; 2052 delete mSyncActionDialog;
2051 mSyncActionDialog = 0; 2053 mSyncActionDialog = 0;
2052} 2054}
2053void MainWindow::performQuick() 2055void MainWindow::performQuick()
2054{ 2056{
2055 setCaption( i18n("Please input connection settings") ); 2057 setCaption( i18n("Please input connection settings") );
2056 QString retfile = ""; 2058 QString retfile = "";
2057 QDialog dia ( this, "input-dialog", true ); 2059 QDialog dia ( this, "input-dialog", true );
2058 QLineEdit lab ( &dia ); 2060 QLineEdit lab ( &dia );
2059 QVBoxLayout lay( &dia ); 2061 QVBoxLayout lay( &dia );
2060 QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); 2062 QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia );
2061 lay.addWidget( &label); 2063 lay.addWidget( &label);
2062 lab.setText( KOPrefs::instance()->mActiveSyncIP ); 2064 lab.setText( KOPrefs::instance()->mActiveSyncIP );
2063 lay.setMargin(7); 2065 lay.setMargin(7);
2064 lay.setSpacing(7); 2066 lay.setSpacing(7);
2065 lay.addWidget( &lab); 2067 lay.addWidget( &lab);
2066 QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); 2068 QLabel label2 ( i18n("Port number (Default: 9197)"), &dia );
2067 lay.addWidget( &label2); 2069 lay.addWidget( &label2);
2068 QLineEdit lab2 ( &dia ); 2070 QLineEdit lab2 ( &dia );
2069 lab2.setText( KOPrefs::instance()->mActiveSyncPort ); 2071 lab2.setText( KOPrefs::instance()->mActiveSyncPort );
2070 lay.addWidget( &lab2); 2072 lay.addWidget( &lab2);
2071 dia.setFixedSize( 230,200 ); 2073 dia.setFixedSize( 230,200 );
2072 dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") ); 2074 dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") );
2073 QPushButton pb ( "OK", &dia); 2075 QPushButton pb ( "OK", &dia);
2074 lay.addWidget( &pb ); 2076 lay.addWidget( &pb );
2075 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2077 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2076 dia.show(); 2078 dia.show();
2077 int res = dia.exec(); 2079 int res = dia.exec();
2078 if ( !res ) { 2080 if ( !res ) {
2079 setCaption( i18n("Syncing cancelled!") ); 2081 setCaption( i18n("Syncing cancelled!") );
2080 return; 2082 return;
2081 } 2083 }
2082 dia.hide(); 2084 dia.hide();
2083 KOPrefs::instance()->mActiveSyncPort = lab2.text(); 2085 KOPrefs::instance()->mActiveSyncPort = lab2.text();
2084 KOPrefs::instance()->mActiveSyncIP = lab.text(); 2086 KOPrefs::instance()->mActiveSyncIP = lab.text();
2085 qApp->processEvents(); 2087 qApp->processEvents();
2086 performQuickQuick(); 2088 performQuickQuick();
2087} 2089}
2088 2090
2089void MainWindow::performQuickQuick() 2091void MainWindow::performQuickQuick()
2090{ 2092{
2091 // setCaption( i18n("") ); 2093 // setCaption( i18n("") );
2092 2094
2093 bool ok; 2095 bool ok;
2094 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); 2096 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
2095 if ( ! ok ) { 2097 if ( ! ok ) {
2096 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 2098 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
2097 return; 2099 return;
2098 } 2100 }
2099 if ( !mCommandSocket ) { 2101 if ( !mCommandSocket ) {
2100 mCommandSocket = new QSocket( this ); 2102 mCommandSocket = new QSocket( this );
2101 // delete mCommandSocket; 2103 // delete mCommandSocket;
2102 //mCommandSocket = new QSocket( this ); 2104 //mCommandSocket = new QSocket( this );
2103 connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); 2105 connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) );
2104 } 2106 }
2105 QString host = KOPrefs::instance()->mActiveSyncIP; 2107 QString host = KOPrefs::instance()->mActiveSyncIP;
2106 mCommandSocket->connectToHost( host, port ); 2108 mCommandSocket->connectToHost( host, port );
2107 QTextStream os( mCommandSocket ); 2109 QTextStream os( mCommandSocket );
2108 os.setEncoding( QTextStream::UnicodeUTF8 ); 2110 os.setEncoding( QTextStream::UnicodeUTF8 );
2109 os << "GET\r\n"; 2111 os << "GET\r\n";
2110 setCaption( i18n("Sending request for remote file ...") ); 2112 setCaption( i18n("Sending request for remote file ...") );
2111 2113
2112} 2114}
2113void MainWindow::readFileFromSocket() 2115void MainWindow::readFileFromSocket()
2114{ 2116{
2115 setCaption( i18n("Receiving remote file ...") ); 2117 setCaption( i18n("Receiving remote file ...") );
2116 qDebug("MainWindow::readFileFromSocket() "); 2118 qDebug("MainWindow::readFileFromSocket() ");
2117 QString fileName; 2119 QString fileName;
2118#ifdef _WIN32_ 2120#ifdef _WIN32_
2119 fileName = defaultFileName() +"sync"; 2121 fileName = defaultFileName() +"sync";
2120#else 2122#else
2121 fileName = "/tmp/kopitempfile.ics"; 2123 fileName = "/tmp/kopitempfile.ics";
2122#endif 2124#endif
2123 QFile file( fileName ); 2125 QFile file( fileName );
2124 if (!file.open( IO_WriteOnly ) ) { 2126 if (!file.open( IO_WriteOnly ) ) {
2125 setCaption( i18n("Error: Cannot open temp file for write.") ); 2127 setCaption( i18n("Error: Cannot open temp file for write.") );
2126 qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); 2128 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
2127 return ; 2129 return ;
2128 } 2130 }
2129 2131
2130 //QTextStream os2( mCommandSocket ); 2132 //QTextStream os2( mCommandSocket );
2131 //os2.setEncoding( QTextStream::UnicodeUTF8 ); 2133 //os2.setEncoding( QTextStream::UnicodeUTF8 );
2132 2134
2133 QTextStream ts( &file ); 2135 QTextStream ts( &file );
2134 ts.setCodec( QTextCodec::codecForName("utf8") ); 2136 ts.setCodec( QTextCodec::codecForName("utf8") );
2135 bool first = true; 2137 bool first = true;
2136 while ( mCommandSocket->canReadLine () || first) { 2138 while ( mCommandSocket->canReadLine () || first) {
2137 first = false; 2139 first = false;
2138 while ( mCommandSocket->canReadLine () ) { 2140 while ( mCommandSocket->canReadLine () ) {
2139 ts << mCommandSocket->readLine (); 2141 ts << mCommandSocket->readLine ();
2140 } 2142 }
2141 QTime ti; 2143 QTime ti;
2142 ti.start(); 2144 ti.start();
2143 while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) { 2145 while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) {
2144 qApp->processEvents(); 2146 qApp->processEvents();
2145 qDebug("waiting2 %d ",ti.elapsed () ); 2147 qDebug("waiting2 %d ",ti.elapsed () );
2146 if ( !mCommandSocket->canReadLine () ) 2148 if ( !mCommandSocket->canReadLine () )
2147 mCommandSocket->waitForMore ( 100 ); 2149 mCommandSocket->waitForMore ( 100 );
2148 } 2150 }
2149 //mCommandSocket->waitForMore ( 5000 ); 2151 //mCommandSocket->waitForMore ( 5000 );
2150 } 2152 }
2151 file.close(); 2153 file.close();
2152 mCommandSocket->close(); 2154 mCommandSocket->close();
2153 // pending: deleting after signal SIGNAL(delayedCloseFinished()) 2155 // pending: deleting after signal SIGNAL(delayedCloseFinished())
2154 //delete mCommandSocket; 2156 //delete mCommandSocket;
2155 setCaption( i18n("Remote file saved to temp file.") ); 2157 setCaption( i18n("Remote file saved to temp file.") );
2156 //mCommandSocket = 0; 2158 //mCommandSocket = 0;
2157 mCurrentSyncProfile = 2 ; // last file 2159 mCurrentSyncProfile = 2 ; // last file
2158 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 2160 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
2159 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 2161 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
2160 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2162 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2161 KSyncProfile* temp = new KSyncProfile (); 2163 KSyncProfile* temp = new KSyncProfile ();
2162 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2164 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2163 temp->readConfig(&config); 2165 temp->readConfig(&config);
2164 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2166 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2165 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 2167 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2166 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2168 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2167 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2169 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2168 KOPrefs::instance()->mWriteBackInFuture = 0; 2170 KOPrefs::instance()->mWriteBackInFuture = 0;
2169 if ( temp->getWriteBackFuture() ) 2171 if ( temp->getWriteBackFuture() )
2170 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2172 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2171 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 2173 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2172 2174
2173 setCaption( i18n("Remote file saved to temp file.") ); 2175 setCaption( i18n("Remote file saved to temp file.") );
2174 if ( ! syncWithFile( fileName , true ) ) { 2176 if ( ! syncWithFile( fileName , true ) ) {
2175 setCaption( i18n("Syncing failed.") ); 2177 setCaption( i18n("Syncing failed.") );
2176 qDebug("Syncing failed "); 2178 qDebug("Syncing failed ");
2177 return; 2179 return;
2178 } 2180 }
2179 2181
2180 if ( !mCommandSocketFinish ) { 2182 if ( !mCommandSocketFinish ) {
2181 mCommandSocketFinish = new QSocket( this ); 2183 mCommandSocketFinish = new QSocket( this );
2182 } 2184 }
2183 mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); 2185 mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() );
2184 2186
2185 // pending connect signals connected () and error to new slots 2187 // pending connect signals connected () and error to new slots
2186 QString host = KOPrefs::instance()->mActiveSyncIP; 2188 QString host = KOPrefs::instance()->mActiveSyncIP;
2187 QFile file2( fileName ); 2189 QFile file2( fileName );
2188 if (!file2.open( IO_ReadOnly ) ) { 2190 if (!file2.open( IO_ReadOnly ) ) {
2189 setCaption( i18n("Error: Cannot open temp file for read.") ); 2191 setCaption( i18n("Error: Cannot open temp file for read.") );
2190 qDebug("error open cal file "); 2192 qDebug("error open cal file ");
2191 return ; 2193 return ;
2192 2194
2193 } 2195 }
2194 setCaption( i18n("Sending back synced file...") ); 2196 setCaption( i18n("Sending back synced file...") );
2195 QTextStream ts2( &file2 ); 2197 QTextStream ts2( &file2 );
2196 ts2.setCodec( QTextCodec::codecForName("utf8") ); 2198 ts2.setCodec( QTextCodec::codecForName("utf8") );
2197 QTextStream os2( mCommandSocketFinish ); 2199 QTextStream os2( mCommandSocketFinish );
2198 os2.setCodec( QTextCodec::codecForName("utf8") ); 2200 os2.setCodec( QTextCodec::codecForName("utf8") );
2199 //os.setEncoding( QTextStream::UnicodeUTF8 ); 2201 //os.setEncoding( QTextStream::UnicodeUTF8 );
2200 if ( KOPrefs::instance()->mWriteBackFile ) { 2202 if ( KOPrefs::instance()->mWriteBackFile ) {
2201 os2 << "PUT\r\n"; 2203 os2 << "PUT\r\n";
2202 while ( ! ts2.atEnd() ) { 2204 while ( ! ts2.atEnd() ) {
2203 os2 << ts2.readLine() << "\n"; 2205 os2 << ts2.readLine() << "\n";
2204 } 2206 }
2205 } else { 2207 } else {
2206 os2 << "STOP\r\n"; 2208 os2 << "STOP\r\n";
2207 } 2209 }
2208 mCommandSocketFinish->close(); 2210 mCommandSocketFinish->close();
2209 file.close(); 2211 file.close();
2210 // pending: deleting after signal SIGNAL(delayedCloseFinished()) 2212 // pending: deleting after signal SIGNAL(delayedCloseFinished())
2211 //delete ( mCommandSocket); 2213 //delete ( mCommandSocket);
2212 //mCommandSocket = 0; 2214 //mCommandSocket = 0;
2213 qDebug("Syncing succesful! "); 2215 qDebug("Syncing succesful! ");
2214 setCaption( i18n("Easy-Pi-Sync succesful!") ); 2216 setCaption( i18n("Easy-Pi-Sync succesful!") );
2215 2217
2216 2218
2217} 2219}
2218 2220
2219void MainWindow::syncLocalFile() 2221void MainWindow::syncLocalFile()
2220{ 2222{
2221 2223
2222 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 2224 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
2223 2225
2224 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2226 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2225 if ( fn == "" ) 2227 if ( fn == "" )
2226 return; 2228 return;
2227 //mView->setSyncDevice("local-file" ); 2229 //mView->setSyncDevice("local-file" );
2228 if ( syncWithFile( fn, false ) ) { 2230 if ( syncWithFile( fn, false ) ) {
2229 // Event* e = mView->getLastSyncEvent(); 2231 // Event* e = mView->getLastSyncEvent();
2230// e->setReadOnly( false ); 2232// e->setReadOnly( false );
2231// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2233// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2232// e->setReadOnly( true ); 2234// e->setReadOnly( true );
2233 } 2235 }
2234 2236
2235} 2237}
2236 2238
2237bool MainWindow::syncWithFile( QString fn , bool quick ) 2239bool MainWindow::syncWithFile( QString fn , bool quick )
2238{ 2240{
2239 bool ret = false; 2241 bool ret = false;
2240 QFileInfo info; 2242 QFileInfo info;
2241 info.setFile( fn ); 2243 info.setFile( fn );
2242 QString mess; 2244 QString mess;
2243 bool loadbup = true; 2245 bool loadbup = true;
2244 if ( !info. exists() ) { 2246 if ( !info. exists() ) {
2245 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2247 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2246 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2248 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2247 mess ); 2249 mess );
2248 return ret; 2250 return ret;
2249 } 2251 }
2250 int result = 0; 2252 int result = 0;
2251 if ( !quick ) { 2253 if ( !quick ) {
2252 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2254 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2253 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2255 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2254 mess, 2256 mess,
2255 i18n("Sync"), i18n("Cancel"), 0, 2257 i18n("Sync"), i18n("Cancel"), 0,
2256 0, 1 ); 2258 0, 1 );
2257 if ( result ) 2259 if ( result )
2258 return false; 2260 return false;
2259 } 2261 }
2260 if ( KOPrefs::instance()->mAskForPreferences ) 2262 if ( KOPrefs::instance()->mAskForPreferences )
2261 mView->edit_sync_options(); 2263 mView->edit_sync_options();
2262 if ( result == 0 ) { 2264 if ( result == 0 ) {
2263 //qDebug("Now sycing ... "); 2265 //qDebug("Now sycing ... ");
2264 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 2266 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
2265 setCaption( i18n("Synchronization successful") ); 2267 setCaption( i18n("Synchronization successful") );
2266 else 2268 else
2267 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 2269 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2268 if ( ! quick ) 2270 if ( ! quick )
2269 KOPrefs::instance()->mLastSyncedLocalFile = fn; 2271 KOPrefs::instance()->mLastSyncedLocalFile = fn;
2270 slotModifiedChanged( true ); 2272 slotModifiedChanged( true );
2271 } 2273 }
2272 return ret; 2274 return ret;
2273} 2275}
2274void MainWindow::quickSyncLocalFile() 2276void MainWindow::quickSyncLocalFile()
2275{ 2277{
2276 //mView->setSyncDevice("local-file" ); 2278 //mView->setSyncDevice("local-file" );
2277 //qDebug("quickSyncLocalFile() "); 2279 //qDebug("quickSyncLocalFile() ");
2278 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 2280 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2279 // Event* e = mView->getLastSyncEvent(); 2281 // Event* e = mView->getLastSyncEvent();
2280// e->setReadOnly( false ); 2282// e->setReadOnly( false );
2281// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2283// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2282// e->setReadOnly( true ); 2284// e->setReadOnly( true );
2283 2285
2284 } 2286 }
2285} 2287}
2286 2288
2287void MainWindow::confSync() 2289void MainWindow::confSync()
2288{ 2290{
2289 mView->confSync(); 2291 mView->confSync();
2290 fillSyncMenu(); 2292 fillSyncMenu();
2291} 2293}
2292void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 2294void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
2293{ 2295{
2294 QString question; 2296 QString question;
2295 if ( ask ) { 2297 if ( ask ) {
2296 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 2298 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
2297 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2299 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2298 question, 2300 question,
2299 i18n("Yes"), i18n("No"), 2301 i18n("Yes"), i18n("No"),
2300 0, 0 ) != 0 ) 2302 0, 0 ) != 0 )
2301 return; 2303 return;
2302 } 2304 }
2303 QString command = prof->getPreSyncCommand(); 2305 QString command = prof->getPreSyncCommand();
2304 int fi; 2306 int fi;
2305 if ( (fi = command.find("$PWD$")) > 0 ) { 2307 if ( (fi = command.find("$PWD$")) > 0 ) {
2306 QString pwd = getPassword(); 2308 QString pwd = getPassword();
2307 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2309 command = command.left( fi )+ pwd + command.mid( fi+5 );
2308 2310
2309 } 2311 }
2310 int maxlen = 30; 2312 int maxlen = 30;
2311 if ( QApplication::desktop()->width() > 320 ) 2313 if ( QApplication::desktop()->width() > 320 )
2312 maxlen += 25; 2314 maxlen += 25;
2313 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2315 setCaption ( i18n( "Copy remote file to local machine..." ) );
2314 int fileSize = 0; 2316 int fileSize = 0;
2315 int result = system ( command ); 2317 int result = system ( command );
2316 // 0 : okay 2318 // 0 : okay
2317 // 256: no such file or dir 2319 // 256: no such file or dir
2318 // 2320 //
2319 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2321 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2320 if ( result != 0 ) { 2322 if ( result != 0 ) {
2321 int len = maxlen; 2323 int len = maxlen;
2322 while ( len < command.length() ) { 2324 while ( len < command.length() ) {
2323 command.insert( len , "\n" ); 2325 command.insert( len , "\n" );
2324 len += maxlen +2; 2326 len += maxlen +2;
2325 } 2327 }
2326 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 (command) ; 2328 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 (command) ;
2327 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2329 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2328 question, 2330 question,
2329 i18n("Okay!")) ; 2331 i18n("Okay!")) ;
2330 setCaption ("KO/Pi"); 2332 setCaption ("KO/Pi");
2331 return; 2333 return;
2332 } 2334 }
2333 setCaption ( i18n( "Copying succeed." ) ); 2335 setCaption ( i18n( "Copying succeed." ) );
2334 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 2336 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
2335 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 2337 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
2336// Event* e = mView->getLastSyncEvent(); 2338// Event* e = mView->getLastSyncEvent();
2337// e->setReadOnly( false ); 2339// e->setReadOnly( false );
2338// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2340// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2339// e->setReadOnly( true ); 2341// e->setReadOnly( true );
2340 if ( KOPrefs::instance()->mWriteBackFile ) { 2342 if ( KOPrefs::instance()->mWriteBackFile ) {
2341 command = prof->getPostSyncCommand(); 2343 command = prof->getPostSyncCommand();
2342 int fi; 2344 int fi;
2343 if ( (fi = command.find("$PWD$")) > 0 ) { 2345 if ( (fi = command.find("$PWD$")) > 0 ) {
2344 QString pwd = getPassword(); 2346 QString pwd = getPassword();
2345 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2347 command = command.left( fi )+ pwd + command.mid( fi+5 );
2346 2348
2347 } 2349 }
2348 setCaption ( i18n( "Writing back file ..." ) ); 2350 setCaption ( i18n( "Writing back file ..." ) );
2349 result = system ( command ); 2351 result = system ( command );
2350 qDebug("KO: Writing back file result: %d ", result); 2352 qDebug("KO: Writing back file result: %d ", result);
2351 if ( result != 0 ) { 2353 if ( result != 0 ) {
2352 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 2354 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
2353 return; 2355 return;
2354 } else { 2356 } else {
2355 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2357 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2356 } 2358 }
2357 } 2359 }
2358 } 2360 }
2359 return; 2361 return;
2360} 2362}
2361void MainWindow::syncSSH() 2363void MainWindow::syncSSH()
2362{ 2364{
2363 // not used anymore 2365 // not used anymore
2364 QTime timer; 2366 QTime timer;
2365 timer.start(); 2367 timer.start();
2366 //qDebug("MainWindow::syncssh() "); 2368 //qDebug("MainWindow::syncssh() ");
2367 KOPrefs *p = KOPrefs::instance(); 2369 KOPrefs *p = KOPrefs::instance();
2368 QString localFile = p->mLocalTempFile; 2370 QString localFile = p->mLocalTempFile;
2369 QString remoteIP = p->mRemoteIP; 2371 QString remoteIP = p->mRemoteIP;
2370 QString remoteUser = p->mRemoteUser; 2372 QString remoteUser = p->mRemoteUser;
2371 QString remoteFile = p->mRemoteFile; 2373 QString remoteFile = p->mRemoteFile;
2372 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 2374 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
2373 remoteUser += ":" + p->mRemotePassWd; 2375 remoteUser += ":" + p->mRemotePassWd;
2374 2376
2375 QString question = i18n("Do you really want\nto remote sync?\n \n") + 2377 QString question = i18n("Do you really want\nto remote sync?\n \n") +
2376 i18n("IP: " ) +remoteIP +"\n" + 2378 i18n("IP: " ) +remoteIP +"\n" +
2377 i18n("User: " ) + remoteUser +"\n" ; 2379 i18n("User: " ) + remoteUser +"\n" ;
2378 int maxlen = 30; 2380 int maxlen = 30;
2379 if ( QApplication::desktop()->width() > 320 ) 2381 if ( QApplication::desktop()->width() > 320 )
2380 maxlen += 25; 2382 maxlen += 25;
2381 if ( remoteFile.length() > maxlen ) 2383 if ( remoteFile.length() > maxlen )
2382 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 2384 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
2383 else 2385 else
2384 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 2386 question += i18n("Remote file:\n " ) + remoteFile +"\n";
2385 if ( localFile.length() > maxlen ) 2387 if ( localFile.length() > maxlen )
2386 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 2388 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
2387 else 2389 else
2388 question += i18n("Local temp file:\n " ) + localFile +"\n"; 2390 question += i18n("Local temp file:\n " ) + localFile +"\n";
2389 2391
2390 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2392 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2391 question, 2393 question,
2392 i18n("Yes"), i18n("No"), 2394 i18n("Yes"), i18n("No"),
2393 0, 0 ) != 0 ) 2395 0, 0 ) != 0 )
2394 return; 2396 return;
2395 // if ( !p->mUsePassWd ) { 2397 // if ( !p->mUsePassWd ) {
2396 // QString pass = getPassword(); 2398 // QString pass = getPassword();
2397 // if ( pass.length() > 0 ) 2399 // if ( pass.length() > 0 )
2398 // remoteUser += ":" + pass; 2400 // remoteUser += ":" + pass;
2399 // } 2401 // }
2400 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 2402 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
2401 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2403 setCaption ( i18n( "Copy remote file to local machine..." ) );
2402 int fileSize = 0; 2404 int fileSize = 0;
2403 int result = system ( command ); 2405 int result = system ( command );
2404 // 0 : okay 2406 // 0 : okay
2405 // 256: no such file or dir 2407 // 256: no such file or dir
2406 // 2408 //
2407 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2409 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2408 if ( result != 0 ) { 2410 if ( result != 0 ) {
2409 int len = maxlen; 2411 int len = maxlen;
2410 while ( len < command.length() ) { 2412 while ( len < command.length() ) {
2411 command.insert( len , "\n" ); 2413 command.insert( len , "\n" );
2412 len += maxlen +2; 2414 len += maxlen +2;
2413 } 2415 }
2414 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 (command) ; 2416 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 (command) ;
2415 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2417 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2416 question, 2418 question,
2417 i18n("Okay!")) ; 2419 i18n("Okay!")) ;
2418 setCaption ("KO/Pi"); 2420 setCaption ("KO/Pi");
2419 return; 2421 return;
2420 } 2422 }
2421 2423
2422 2424
2423 setCaption ( i18n( "Copying succeed." ) ); 2425 setCaption ( i18n( "Copying succeed." ) );
2424 //mView->setSyncDevice("ssh-scp" ); 2426 //mView->setSyncDevice("ssh-scp" );
2425 if ( syncWithFile(localFile , true ) ) { 2427 if ( syncWithFile(localFile , true ) ) {
2426// Event* e = mView->getLastSyncEvent(); 2428// Event* e = mView->getLastSyncEvent();
2427// e->setReadOnly( false ); 2429// e->setReadOnly( false );
2428// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2430// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2429// e->setReadOnly( true ); 2431// e->setReadOnly( true );
2430 if ( KOPrefs::instance()->mWriteBackFile ) { 2432 if ( KOPrefs::instance()->mWriteBackFile ) {
2431 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 2433 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
2432 setCaption ( i18n( "Writing back file ..." ) ); 2434 setCaption ( i18n( "Writing back file ..." ) );
2433 result = system ( command ); 2435 result = system ( command );
2434 if ( result != 0 ) { 2436 if ( result != 0 ) {
2435 int len = maxlen; 2437 int len = maxlen;
2436 while ( len < command.length() ) { 2438 while ( len < command.length() ) {
2437 command.insert( len , "\n" ); 2439 command.insert( len , "\n" );
2438 len += maxlen +2; 2440 len += maxlen +2;
2439 } 2441 }
2440 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2442 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2441 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2443 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2442 question, 2444 question,
2443 i18n("Okay!")) ; 2445 i18n("Okay!")) ;
2444 setCaption ("KO/Pi"); 2446 setCaption ("KO/Pi");
2445 return; 2447 return;
2446 } else { 2448 } else {
2447 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2449 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2448 } 2450 }
2449 } 2451 }
2450 } 2452 }
2451 return; 2453 return;
2452#if 0 2454#if 0
2453 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 2455 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
2454 while ( timer.elapsed() < 5000 ) 2456 while ( timer.elapsed() < 5000 )
2455 qApp->processEvents(); 2457 qApp->processEvents();
2456 2458
2457 qDebug("MainWindow::merging) "); 2459 qDebug("MainWindow::merging) ");
2458 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 2460 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
2459 while ( mBlockSaveFlag ) 2461 while ( mBlockSaveFlag )
2460 qApp->processEvents(); 2462 qApp->processEvents();
2461 save(); 2463 save();
2462 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 2464 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
2463#endif 2465#endif
2464 2466
2465} 2467}
2466 2468
2467 2469
2468void MainWindow::syncSharp() 2470void MainWindow::syncSharp()
2469{ 2471{
2470 if ( mCalendarModifiedFlag ) 2472 if ( mCalendarModifiedFlag )
2471 save(); 2473 save();
2472 mView->syncSharp(); 2474 mView->syncSharp();
2473 slotModifiedChanged( true ); 2475 slotModifiedChanged( true );
2474 2476
2475} 2477}
2476void MainWindow::syncPhone() 2478void MainWindow::syncPhone()
2477{ 2479{
2478 if ( mCalendarModifiedFlag ) 2480 if ( mCalendarModifiedFlag )
2479 save(); 2481 save();
2480 mView->syncPhone(); 2482 mView->syncPhone();
2481 slotModifiedChanged( true ); 2483 slotModifiedChanged( true );
2482 2484
2483} 2485}
2484 2486
2485void MainWindow::printSel( ) 2487void MainWindow::printSel( )
2486{ 2488{
2487 mView->viewManager()->agendaView()->agenda()->printSelection(); 2489 mView->viewManager()->agendaView()->agenda()->printSelection();
2488} 2490}
2489 2491
2490void MainWindow::printCal() 2492void MainWindow::printCal()
2491{ 2493{
2492 mView->print();//mCp->showDialog(); 2494 mView->print();//mCp->showDialog();
2493} 2495}
2494 2496
2495 2497
2496 2498
2497KServerSocket:: KServerSocket ( Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 2499KServerSocket:: KServerSocket ( Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
2498{ 2500{
2499 2501
2500 mSocket = 0; 2502 mSocket = 0;
2501}; 2503};
2502 2504
2503void KServerSocket::newConnection ( int socket ) 2505void KServerSocket::newConnection ( int socket )
2504{ 2506{
2505 qDebug("KServerSocket:New connection %d ", socket); 2507 qDebug("KServerSocket:New connection %d ", socket);
2506 if ( mSocket ) { 2508 if ( mSocket ) {
2507 qDebug("KServerSocket::newConnection Socket deleted! "); 2509 qDebug("KServerSocket::newConnection Socket deleted! ");
2508 delete mSocket; 2510 delete mSocket;
2509 mSocket = 0; 2511 mSocket = 0;
2510 } 2512 }
2511 mSocket = new QSocket( this ); 2513 mSocket = new QSocket( this );
2512 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 2514 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
2513 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 2515 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
2514 mSocket->setSocket( socket ); 2516 mSocket->setSocket( socket );
2515} 2517}
2516 2518
2517void KServerSocket::discardClient() 2519void KServerSocket::discardClient()
2518{ 2520{
2519 qDebug(" KServerSocket::discardClient()"); 2521 qDebug(" KServerSocket::discardClient()");
2520 if ( mSocket ) { 2522 if ( mSocket ) {
2521 qDebug("delete "); 2523 qDebug("delete ");
2522 delete mSocket; 2524 delete mSocket;
2523 mSocket = 0; 2525 mSocket = 0;
2524 } 2526 }
2525 //emit endConnect(); 2527 //emit endConnect();
2526} 2528}
2527void KServerSocket::readClient() 2529void KServerSocket::readClient()
2528{ 2530{
2529 if ( mSocket == 0 ) { 2531 if ( mSocket == 0 ) {
2530 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 2532 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
2531 return; 2533 return;
2532 } 2534 }
2533 qDebug("KServerSocket readClient()"); 2535 qDebug("KServerSocket readClient()");
2534 if ( mSocket->canReadLine() ) { 2536 if ( mSocket->canReadLine() ) {
2535 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); 2537 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() );
2536 qDebug("KServerSocket socket->canReadLine()"); 2538 qDebug("KServerSocket socket->canReadLine()");
2537 if ( tokens[0] == "GET" ) { 2539 if ( tokens[0] == "GET" ) {
2538 emit sendFile( mSocket ); 2540 emit sendFile( mSocket );
2539 } 2541 }
2540 if ( tokens[0] == "PUT" ) { 2542 if ( tokens[0] == "PUT" ) {
2541 emit getFile( mSocket ); 2543 emit getFile( mSocket );
2542 } 2544 }
2543 if ( tokens[0] == "STOP" ) { 2545 if ( tokens[0] == "STOP" ) {
2544 emit endConnect(); 2546 emit endConnect();
2545 } 2547 }
2546 } 2548 }
2547} 2549}
2548 2550
2549 2551
2550 2552
2551 2553
2552 2554
2553 2555
2554 2556
2555 2557
2556 2558
2557 2559
2558 2560
2559 2561
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro
index 7231842..eac19ea 100644
--- a/libkdepim/libkdepim.pro
+++ b/libkdepim/libkdepim.pro
@@ -1,57 +1,59 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3DEFINES +=KORG_NOKABC 3DEFINES +=KORG_NOKABC
4TARGET = microkdepim 4TARGET = microkdepim
5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. 5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . ..
6DESTDIR=../bin 6DESTDIR=../bin
7 7
8DEFINES += DESKTOP_VERSION 8DEFINES += DESKTOP_VERSION
9include( ../variables.pri ) 9include( ../variables.pri )
10unix : { 10unix : {
11OBJECTS_DIR = obj/unix 11OBJECTS_DIR = obj/unix
12MOC_DIR = moc/unix 12MOC_DIR = moc/unix
13} 13}
14win32: { 14win32: {
15DEFINES += _WIN32_ 15DEFINES += _WIN32_
16OBJECTS_DIR = obj/win 16OBJECTS_DIR = obj/win
17MOC_DIR = moc/win 17MOC_DIR = moc/win
18} 18}
19INTERFACES = \ 19INTERFACES = \
20 20
21HEADERS = \ 21HEADERS = \
22 categoryeditdialog.h \ 22 categoryeditdialog.h \
23 categoryeditdialog_base.h \ 23 categoryeditdialog_base.h \
24 categoryselectdialog.h \ 24 categoryselectdialog.h \
25 categoryselectdialog_base.h \ 25 categoryselectdialog_base.h \
26 externalapphandler.h \ 26 externalapphandler.h \
27 kdateedit.h \ 27 kdateedit.h \
28 kdatepicker.h \ 28 kdatepicker.h \
29 kinputdialog.h \ 29 kinputdialog.h \
30 kpimprefs.h \ 30 kpimprefs.h \
31 kpimglobalprefs.h \ 31 kpimglobalprefs.h \
32 kprefsdialog.h \ 32 kprefsdialog.h \
33 kprefswidget.h \ 33 kprefswidget.h \
34 ksyncmanager.h \
34 ksyncprofile.h \ 35 ksyncprofile.h \
35 ksyncprefsdialog.h \ 36 ksyncprefsdialog.h \
36 kcmconfigs/kcmkdepimconfig.h \ 37 kcmconfigs/kcmkdepimconfig.h \
37 kcmconfigs/kdepimconfigwidget.h 38 kcmconfigs/kdepimconfigwidget.h
38 39
39SOURCES = \ 40SOURCES = \
40 categoryeditdialog.cpp \ 41 categoryeditdialog.cpp \
41 categoryeditdialog_base.cpp \ 42 categoryeditdialog_base.cpp \
42 categoryselectdialog.cpp \ 43 categoryselectdialog.cpp \
43 categoryselectdialog_base.cpp \ 44 categoryselectdialog_base.cpp \
44 externalapphandler.cpp \ 45 externalapphandler.cpp \
45 kdateedit.cpp \ 46 kdateedit.cpp \
46 kdatepicker.cpp \ 47 kdatepicker.cpp \
47 kinputdialog.cpp \ 48 kinputdialog.cpp \
48 kpimprefs.cpp \ 49 kpimprefs.cpp \
49 kpimglobalprefs.cpp \ 50 kpimglobalprefs.cpp \
50 kprefsdialog.cpp \ 51 kprefsdialog.cpp \
51 kprefswidget.cpp \ 52 kprefswidget.cpp \
53 ksyncmanager.cpp \
52 ksyncprofile.cpp \ 54 ksyncprofile.cpp \
53 ksyncprefsdialog.cpp \ 55 ksyncprefsdialog.cpp \
54 kcmconfigs/kcmkdepimconfig.cpp \ 56 kcmconfigs/kcmkdepimconfig.cpp \
55 kcmconfigs/kdepimconfigwidget.cpp 57 kcmconfigs/kdepimconfigwidget.cpp
56 58
57 59
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp
index 7f2a326..1c3e0ae 100644
--- a/microkde/kdecore/kstandarddirs.cpp
+++ b/microkde/kdecore/kstandarddirs.cpp
@@ -1,1651 +1,1662 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> 2 Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org>
3 Copyright (C) 1999 Stephan Kulow <coolo@kde.org> 3 Copyright (C) 1999 Stephan Kulow <coolo@kde.org>
4 Copyright (C) 1999 Waldo Bastian <bastian@kde.org> 4 Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation. 8 License version 2 as published by the Free Software Foundation.
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/* 21/*
22 * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> 22 * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org>
23 * Version:$Id$ 23 * Version:$Id$
24 * Generated:Thu Mar 5 16:05:28 EST 1998 24 * Generated:Thu Mar 5 16:05:28 EST 1998
25 */ 25 */
26 26
27//US #include "config.h" 27//US #include "config.h"
28 28
29#include <stdlib.h> 29#include <stdlib.h>
30#include <assert.h> 30#include <assert.h>
31//US#include <errno.h> 31//US#include <errno.h>
32//US #ifdef HAVE_SYS_STAT_H 32//US #ifdef HAVE_SYS_STAT_H
33//US #include <sys/stat.h> 33//US #include <sys/stat.h>
34//US #endif 34//US #endif
35//US#include <sys/types.h> 35//US#include <sys/types.h>
36//US#include <dirent.h> 36//US#include <dirent.h>
37//US#include <pwd.h> 37//US#include <pwd.h>
38 38
39#include <qregexp.h> 39#include <qregexp.h>
40#include <qasciidict.h> 40#include <qasciidict.h>
41#include <qdict.h> 41#include <qdict.h>
42#include <qdir.h> 42#include <qdir.h>
43#include <qfileinfo.h> 43#include <qfileinfo.h>
44#include <qstring.h> 44#include <qstring.h>
45#include <qmessagebox.h>
45#include <qapplication.h> 46#include <qapplication.h>
46 47
47#include <qstringlist.h> 48#include <qstringlist.h>
48 49
49#include "kstandarddirs.h" 50#include "kstandarddirs.h"
50#include "kconfig.h" 51#include "kconfig.h"
51#include "kdebug.h" 52#include "kdebug.h"
52//US #include "kinstance.h" 53//US #include "kinstance.h"
53#include "kshell.h" 54#include "kshell.h"
54//US#include <sys/param.h> 55//US#include <sys/param.h>
55//US#include <unistd.h> 56//US#include <unistd.h>
56 57
57//US 58//US
58QString KStandardDirs::mAppDir = QString::null; 59QString KStandardDirs::mAppDir = QString::null;
59 60
60 61
61template class QDict<QStringList>; 62template class QDict<QStringList>;
62 63
63#if 0 64#if 0
64#include <qtextedit.h> 65#include <qtextedit.h>
65void ddd( QString op ) 66void ddd( QString op )
66{ 67{
67 static QTextEdit * dot = 0; 68 static QTextEdit * dot = 0;
68 if ( ! dot ) 69 if ( ! dot )
69 dot = new QTextEdit(); 70 dot = new QTextEdit();
70 71
71 dot->show(); 72 dot->show();
72 73
73 dot->append( op ); 74 dot->append( op );
74 75
75} 76}
76#endif 77#endif
77class KStandardDirs::KStandardDirsPrivate 78class KStandardDirs::KStandardDirsPrivate
78{ 79{
79public: 80public:
80 KStandardDirsPrivate() 81 KStandardDirsPrivate()
81 : restrictionsActive(false), 82 : restrictionsActive(false),
82 dataRestrictionActive(false) 83 dataRestrictionActive(false)
83 { } 84 { }
84 85
85 bool restrictionsActive; 86 bool restrictionsActive;
86 bool dataRestrictionActive; 87 bool dataRestrictionActive;
87 QAsciiDict<bool> restrictions; 88 QAsciiDict<bool> restrictions;
88 QStringList xdgdata_prefixes; 89 QStringList xdgdata_prefixes;
89 QStringList xdgconf_prefixes; 90 QStringList xdgconf_prefixes;
90}; 91};
91 92
92static const char* const types[] = {"html", "icon", "apps", "sound", 93static const char* const types[] = {"html", "icon", "apps", "sound",
93 "data", "locale", "services", "mime", 94 "data", "locale", "services", "mime",
94 "servicetypes", "config", "exe", "tmp", 95 "servicetypes", "config", "exe", "tmp",
95 "wallpaper", "lib", "pixmap", "templates", 96 "wallpaper", "lib", "pixmap", "templates",
96 "module", "qtplugins", 97 "module", "qtplugins",
97 "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; 98 "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 };
98 99
99static int tokenize( QStringList& token, const QString& str, 100static int tokenize( QStringList& token, const QString& str,
100 const QString& delim ); 101 const QString& delim );
101 102
102KStandardDirs::KStandardDirs( ) : addedCustoms(false) 103KStandardDirs::KStandardDirs( ) : addedCustoms(false)
103{ 104{
104 d = new KStandardDirsPrivate; 105 d = new KStandardDirsPrivate;
105 dircache.setAutoDelete(true); 106 dircache.setAutoDelete(true);
106 relatives.setAutoDelete(true); 107 relatives.setAutoDelete(true);
107 absolutes.setAutoDelete(true); 108 absolutes.setAutoDelete(true);
108 savelocations.setAutoDelete(true); 109 savelocations.setAutoDelete(true);
109 addKDEDefaults(); 110 addKDEDefaults();
110} 111}
111 112
112KStandardDirs::~KStandardDirs() 113KStandardDirs::~KStandardDirs()
113{ 114{
114 delete d; 115 delete d;
115} 116}
116 117
117bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const 118bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const
118{ 119{
119 if (!d || !d->restrictionsActive) 120 if (!d || !d->restrictionsActive)
120 return false; 121 return false;
121 122
122 if (d->restrictions[type]) 123 if (d->restrictions[type])
123 return true; 124 return true;
124 125
125 if (strcmp(type, "data")==0) 126 if (strcmp(type, "data")==0)
126 { 127 {
127 applyDataRestrictions(relPath); 128 applyDataRestrictions(relPath);
128 if (d->dataRestrictionActive) 129 if (d->dataRestrictionActive)
129 { 130 {
130 d->dataRestrictionActive = false; 131 d->dataRestrictionActive = false;
131 return true; 132 return true;
132 } 133 }
133 } 134 }
134 return false; 135 return false;
135} 136}
136 137
137void KStandardDirs::applyDataRestrictions(const QString &relPath) const 138void KStandardDirs::applyDataRestrictions(const QString &relPath) const
138{ 139{
139 QString key; 140 QString key;
140 int i = relPath.find('/'); 141 int i = relPath.find('/');
141 if (i != -1) 142 if (i != -1)
142 key = "data_"+relPath.left(i); 143 key = "data_"+relPath.left(i);
143 else 144 else
144 key = "data_"+relPath; 145 key = "data_"+relPath;
145 146
146 if (d && d->restrictions[key.latin1()]) 147 if (d && d->restrictions[key.latin1()])
147 d->dataRestrictionActive = true; 148 d->dataRestrictionActive = true;
148} 149}
149 150
150 151
151QStringList KStandardDirs::allTypes() const 152QStringList KStandardDirs::allTypes() const
152{ 153{
153 QStringList list; 154 QStringList list;
154 for (int i = 0; types[i] != 0; ++i) 155 for (int i = 0; types[i] != 0; ++i)
155 list.append(QString::fromLatin1(types[i])); 156 list.append(QString::fromLatin1(types[i]));
156 return list; 157 return list;
157} 158}
158 159
159void KStandardDirs::addPrefix( const QString& _dir ) 160void KStandardDirs::addPrefix( const QString& _dir )
160{ 161{
161 if (_dir.isNull()) 162 if (_dir.isNull())
162 return; 163 return;
163 164
164 QString dir = _dir; 165 QString dir = _dir;
165 if (dir.at(dir.length() - 1) != '/') 166 if (dir.at(dir.length() - 1) != '/')
166 dir += '/'; 167 dir += '/';
167 168
168 if (!prefixes.contains(dir)) { 169 if (!prefixes.contains(dir)) {
169 prefixes.append(dir); 170 prefixes.append(dir);
170 dircache.clear(); 171 dircache.clear();
171 } 172 }
172} 173}
173 174
174void KStandardDirs::addXdgConfigPrefix( const QString& _dir ) 175void KStandardDirs::addXdgConfigPrefix( const QString& _dir )
175{ 176{
176 if (_dir.isNull()) 177 if (_dir.isNull())
177 return; 178 return;
178 179
179 QString dir = _dir; 180 QString dir = _dir;
180 if (dir.at(dir.length() - 1) != '/') 181 if (dir.at(dir.length() - 1) != '/')
181 dir += '/'; 182 dir += '/';
182 183
183 if (!d->xdgconf_prefixes.contains(dir)) { 184 if (!d->xdgconf_prefixes.contains(dir)) {
184 d->xdgconf_prefixes.append(dir); 185 d->xdgconf_prefixes.append(dir);
185 dircache.clear(); 186 dircache.clear();
186 } 187 }
187} 188}
188 189
189void KStandardDirs::addXdgDataPrefix( const QString& _dir ) 190void KStandardDirs::addXdgDataPrefix( const QString& _dir )
190{ 191{
191 if (_dir.isNull()) 192 if (_dir.isNull())
192 return; 193 return;
193 194
194 QString dir = _dir; 195 QString dir = _dir;
195 if (dir.at(dir.length() - 1) != '/') 196 if (dir.at(dir.length() - 1) != '/')
196 dir += '/'; 197 dir += '/';
197 198
198 if (!d->xdgdata_prefixes.contains(dir)) { 199 if (!d->xdgdata_prefixes.contains(dir)) {
199 d->xdgdata_prefixes.append(dir); 200 d->xdgdata_prefixes.append(dir);
200 dircache.clear(); 201 dircache.clear();
201 } 202 }
202} 203}
203 204
204 205
205QString KStandardDirs::kfsstnd_prefixes() 206QString KStandardDirs::kfsstnd_prefixes()
206{ 207{
207 return prefixes.join(":"); 208 return prefixes.join(":");
208} 209}
209 210
210bool KStandardDirs::addResourceType( const char *type, 211bool KStandardDirs::addResourceType( const char *type,
211 const QString& relativename ) 212 const QString& relativename )
212{ 213{
213 if (relativename.isNull()) 214 if (relativename.isNull())
214 return false; 215 return false;
215 216
216 QStringList *rels = relatives.find(type); 217 QStringList *rels = relatives.find(type);
217 if (!rels) { 218 if (!rels) {
218 rels = new QStringList(); 219 rels = new QStringList();
219 relatives.insert(type, rels); 220 relatives.insert(type, rels);
220 } 221 }
221 QString copy = relativename; 222 QString copy = relativename;
222 if (copy.at(copy.length() - 1) != '/') 223 if (copy.at(copy.length() - 1) != '/')
223 copy += '/'; 224 copy += '/';
224 if (!rels->contains(copy)) { 225 if (!rels->contains(copy)) {
225 rels->prepend(copy); 226 rels->prepend(copy);
226 dircache.remove(type); // clean the cache 227 dircache.remove(type); // clean the cache
227 return true; 228 return true;
228 } 229 }
229 return false; 230 return false;
230} 231}
231 232
232bool KStandardDirs::addResourceDir( const char *type, 233bool KStandardDirs::addResourceDir( const char *type,
233 const QString& absdir) 234 const QString& absdir)
234{ 235{
235 QStringList *paths = absolutes.find(type); 236 QStringList *paths = absolutes.find(type);
236 if (!paths) { 237 if (!paths) {
237 paths = new QStringList(); 238 paths = new QStringList();
238 absolutes.insert(type, paths); 239 absolutes.insert(type, paths);
239 } 240 }
240 QString copy = absdir; 241 QString copy = absdir;
241 if (copy.at(copy.length() - 1) != '/') 242 if (copy.at(copy.length() - 1) != '/')
242 copy += '/'; 243 copy += '/';
243 244
244 if (!paths->contains(copy)) { 245 if (!paths->contains(copy)) {
245 paths->append(copy); 246 paths->append(copy);
246 dircache.remove(type); // clean the cache 247 dircache.remove(type); // clean the cache
247 return true; 248 return true;
248 } 249 }
249 return false; 250 return false;
250} 251}
251 252
252QString KStandardDirs::findResource( const char *type, 253QString KStandardDirs::findResource( const char *type,
253 const QString& filename ) const 254 const QString& filename ) const
254{ 255{
255 if (filename.at(0) == '/') 256 if (filename.at(0) == '/')
256 return filename; // absolute dirs are absolute dirs, right? :-/ 257 return filename; // absolute dirs are absolute dirs, right? :-/
257 258
258#if 0 259#if 0
259kdDebug() << "Find resource: " << type << endl; 260kdDebug() << "Find resource: " << type << endl;
260for (QStringList::ConstIterator pit = prefixes.begin(); 261for (QStringList::ConstIterator pit = prefixes.begin();
261 pit != prefixes.end(); 262 pit != prefixes.end();
262 pit++) 263 pit++)
263{ 264{
264 kdDebug() << "Prefix: " << *pit << endl; 265 kdDebug() << "Prefix: " << *pit << endl;
265} 266}
266#endif 267#endif
267 268
268 QString dir = findResourceDir(type, filename); 269 QString dir = findResourceDir(type, filename);
269 if (dir.isNull()) 270 if (dir.isNull())
270 return dir; 271 return dir;
271 else return dir + filename; 272 else return dir + filename;
272} 273}
273/*US 274/*US
274static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash) 275static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash)
275{ 276{
276 QCString cFile = QFile::encodeName(file); 277 QCString cFile = QFile::encodeName(file);
277//US struct stat buff; 278//US struct stat buff;
278//US if ((access(cFile, R_OK) == 0) && 279//US if ((access(cFile, R_OK) == 0) &&
279//US (stat( cFile, &buff ) == 0) && 280//US (stat( cFile, &buff ) == 0) &&
280//US (S_ISREG( buff.st_mode ))) 281//US (S_ISREG( buff.st_mode )))
281 QFileInfo pathfnInfo(cFile); 282 QFileInfo pathfnInfo(cFile);
282 if (( pathfnInfo.isReadable() == true ) && 283 if (( pathfnInfo.isReadable() == true ) &&
283 ( pathfnInfo.isFile()) ) 284 ( pathfnInfo.isFile()) )
284 { 285 {
285//US hash = hash + (Q_UINT32) buff.st_ctime; 286//US hash = hash + (Q_UINT32) buff.st_ctime;
286 hash = hash + (Q_UINT32) pathfnInfo.lastModified(); 287 hash = hash + (Q_UINT32) pathfnInfo.lastModified();
287 } 288 }
288 return hash; 289 return hash;
289} 290}
290*/ 291*/
291/*US 292/*US
292Q_UINT32 KStandardDirs::calcResourceHash( const char *type, 293Q_UINT32 KStandardDirs::calcResourceHash( const char *type,
293 const QString& filename, bool deep) const 294 const QString& filename, bool deep) const
294{ 295{
295 Q_UINT32 hash = 0; 296 Q_UINT32 hash = 0;
296 297
297 if (filename.at(0) == '/') 298 if (filename.at(0) == '/')
298 { 299 {
299 // absolute dirs are absolute dirs, right? :-/ 300 // absolute dirs are absolute dirs, right? :-/
300 return updateHash(filename, hash); 301 return updateHash(filename, hash);
301 } 302 }
302 if (d && d->restrictionsActive && (strcmp(type, "data")==0)) 303 if (d && d->restrictionsActive && (strcmp(type, "data")==0))
303 applyDataRestrictions(filename); 304 applyDataRestrictions(filename);
304 QStringList candidates = resourceDirs(type); 305 QStringList candidates = resourceDirs(type);
305 QString fullPath; 306 QString fullPath;
306 307
307 for (QStringList::ConstIterator it = candidates.begin(); 308 for (QStringList::ConstIterator it = candidates.begin();
308 it != candidates.end(); it++) 309 it != candidates.end(); it++)
309 { 310 {
310 hash = updateHash(*it + filename, hash); 311 hash = updateHash(*it + filename, hash);
311 if (!deep && hash) 312 if (!deep && hash)
312 return hash; 313 return hash;
313 } 314 }
314 return hash; 315 return hash;
315} 316}
316*/ 317*/
317 318
318QStringList KStandardDirs::findDirs( const char *type, 319QStringList KStandardDirs::findDirs( const char *type,
319 const QString& reldir ) const 320 const QString& reldir ) const
320{ 321{
321 QStringList list; 322 QStringList list;
322 323
323 checkConfig(); 324 checkConfig();
324 325
325 if (d && d->restrictionsActive && (strcmp(type, "data")==0)) 326 if (d && d->restrictionsActive && (strcmp(type, "data")==0))
326 applyDataRestrictions(reldir); 327 applyDataRestrictions(reldir);
327 QStringList candidates = resourceDirs(type); 328 QStringList candidates = resourceDirs(type);
328 QDir testdir; 329 QDir testdir;
329 330
330 for (QStringList::ConstIterator it = candidates.begin(); 331 for (QStringList::ConstIterator it = candidates.begin();
331 it != candidates.end(); it++) { 332 it != candidates.end(); it++) {
332 testdir.setPath(*it + reldir); 333 testdir.setPath(*it + reldir);
333 if (testdir.exists()) 334 if (testdir.exists())
334 list.append(testdir.absPath() + '/'); 335 list.append(testdir.absPath() + '/');
335 } 336 }
336 337
337 return list; 338 return list;
338} 339}
339 340
340QString KStandardDirs::findResourceDir( const char *type, 341QString KStandardDirs::findResourceDir( const char *type,
341 const QString& filename) const 342 const QString& filename) const
342{ 343{
343#ifndef NDEBUG 344#ifndef NDEBUG
344 if (filename.isEmpty()) { 345 if (filename.isEmpty()) {
345 kdWarning() << "filename for type " << type << " in KStandardDirs::findResourceDir is not supposed to be empty!!" << endl; 346 kdWarning() << "filename for type " << type << " in KStandardDirs::findResourceDir is not supposed to be empty!!" << endl;
346 return QString::null; 347 return QString::null;
347 } 348 }
348#endif 349#endif
349 350
350 if (d && d->restrictionsActive && (strcmp(type, "data")==0)) 351 if (d && d->restrictionsActive && (strcmp(type, "data")==0))
351 applyDataRestrictions(filename); 352 applyDataRestrictions(filename);
352 QStringList candidates = resourceDirs(type); 353 QStringList candidates = resourceDirs(type);
353 QString fullPath; 354 QString fullPath;
354#ifdef DESKTOP_VERSION 355#ifdef DESKTOP_VERSION
355#ifdef _WIN32_ 356#ifdef _WIN32_
356 candidates.prepend( qApp->applicationDirPath () +"\\"); 357 candidates.prepend( qApp->applicationDirPath () +"\\");
357#else 358#else
358 candidates.prepend( qApp->applicationDirPath () +"/"); 359 candidates.prepend( qApp->applicationDirPath () +"/");
359#endif 360#endif
360#endif 361#endif
361 for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) 362 for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++)
362 { 363 {
363 //qDebug("looking for dir %s - file %s", (*it).latin1(), filename.latin1()); 364 //qDebug("looking for dir %s - file %s", (*it).latin1(), filename.latin1());
364 if (exists(*it + filename)) 365 if (exists(*it + filename))
365 return *it; 366 return *it;
366 } 367 }
367 368
368#ifndef NDEBUG 369#ifndef NDEBUG
369 if(false && type != "locale") 370 if(false && type != "locale")
370 qDebug("KStdDirs::findResDir(): can't find %s ", filename.latin1()); 371 qDebug("KStdDirs::findResDir(): can't find %s ", filename.latin1());
371 372
372#endif 373#endif
373 374
374 return QString::null; 375 return QString::null;
375} 376}
376 377
377bool KStandardDirs::exists(const QString &fullPath) 378bool KStandardDirs::exists(const QString &fullPath)
378{ 379{
379//US struct stat buff; 380//US struct stat buff;
380 QFileInfo fullPathInfo(QFile::encodeName(fullPath)); 381 QFileInfo fullPathInfo(QFile::encodeName(fullPath));
381 382
382//US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable()) 383//US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable())
383 if (fullPathInfo.isReadable()) 384 if (fullPathInfo.isReadable())
384 { 385 {
385 if (fullPath.at(fullPath.length() - 1) != '/') { 386 if (fullPath.at(fullPath.length() - 1) != '/') {
386 //US if (S_ISREG( buff.st_mode )) 387 //US if (S_ISREG( buff.st_mode ))
387 if (fullPathInfo.isFile()) 388 if (fullPathInfo.isFile())
388 return true; 389 return true;
389 } 390 }
390 else { 391 else {
391 //US if (S_ISDIR( buff.st_mode )) 392 //US if (S_ISDIR( buff.st_mode ))
392 if (fullPathInfo.isDir()) 393 if (fullPathInfo.isDir())
393 return true; 394 return true;
394 } 395 }
395 } 396 }
396 return false; 397 return false;
397} 398}
398 399
399static void lookupDirectory(const QString& path, const QString &relPart, 400static void lookupDirectory(const QString& path, const QString &relPart,
400 const QRegExp &regexp, 401 const QRegExp &regexp,
401 QStringList& list, 402 QStringList& list,
402 QStringList& relList, 403 QStringList& relList,
403 bool recursive, bool uniq) 404 bool recursive, bool uniq)
404{ 405{
405 QString pattern = regexp.pattern(); 406 QString pattern = regexp.pattern();
406 if (recursive || pattern.contains('?') || pattern.contains('*')) 407 if (recursive || pattern.contains('?') || pattern.contains('*'))
407 { 408 {
408 // We look for a set of files. 409 // We look for a set of files.
409//US DIR *dp = opendir( QFile::encodeName(path)); 410//US DIR *dp = opendir( QFile::encodeName(path));
410 QDir dp(QFile::encodeName(path)); 411 QDir dp(QFile::encodeName(path));
411 412
412 if (!dp.exists()) 413 if (!dp.exists())
413 return; 414 return;
414 static int iii = 0; 415 static int iii = 0;
415 ++iii; 416 ++iii;
416 if ( iii == 5 ) 417 if ( iii == 5 )
417 abort(); 418 abort();
418 assert(path.at(path.length() - 1) == '/'); 419 assert(path.at(path.length() - 1) == '/');
419 420
420//US struct dirent *ep; 421//US struct dirent *ep;
421//US struct stat buff; 422//US struct stat buff;
422 423
423 QString _dot("."); 424 QString _dot(".");
424 QString _dotdot(".."); 425 QString _dotdot("..");
425 426
426//US while( ( ep = readdir( dp ) ) != 0L ) 427//US while( ( ep = readdir( dp ) ) != 0L )
427 QStringList direntries = dp.entryList(); 428 QStringList direntries = dp.entryList();
428 QStringList::Iterator it = direntries.begin(); 429 QStringList::Iterator it = direntries.begin();
429 430
430 while ( it != list.end() ) // for each file... 431 while ( it != list.end() ) // for each file...
431 { 432 {
432 433
433//US QString fn( QFile::decodeName(ep->d_name)); 434//US QString fn( QFile::decodeName(ep->d_name));
434 QString fn = (*it); // dp.entryList already decodes 435 QString fn = (*it); // dp.entryList already decodes
435 it++; 436 it++;
436 if ( fn.isNull() ) 437 if ( fn.isNull() )
437 break; 438 break;
438 439
439 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' ) 440 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' )
440 continue; 441 continue;
441 442
442/*US 443/*US
443 if (!recursive && !regexp.exactMatch(fn)) 444 if (!recursive && !regexp.exactMatch(fn))
444 continue; // No match 445 continue; // No match
445*/ 446*/
446//US this should do the same: 447//US this should do the same:
447 int pos = regexp.match(fn); 448 int pos = regexp.match(fn);
448 if (!recursive && !pos == 0) 449 if (!recursive && !pos == 0)
449 continue; // No match 450 continue; // No match
450 451
451 QString pathfn = path + fn; 452 QString pathfn = path + fn;
452/*US 453/*US
453 if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) { 454 if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) {
454 kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; 455 kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl;
455 continue; // Couldn't stat (e.g. no read permissions) 456 continue; // Couldn't stat (e.g. no read permissions)
456 } 457 }
457 458
458 if ( recursive ) 459 if ( recursive )
459 { 460 {
460 if ( S_ISDIR( buff.st_mode )) { 461 if ( S_ISDIR( buff.st_mode )) {
461 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); 462 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq);
462 } 463 }
463*/ 464*/
464//US replacement: 465//US replacement:
465 QFileInfo pathfnInfo(QFile::encodeName(pathfn)); 466 QFileInfo pathfnInfo(QFile::encodeName(pathfn));
466 if ( pathfnInfo.isReadable() == false ) 467 if ( pathfnInfo.isReadable() == false )
467 { 468 {
468//US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; 469//US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl;
469 continue; // Couldn't stat (e.g. no read permissions) 470 continue; // Couldn't stat (e.g. no read permissions)
470 } 471 }
471 472
472 if ( recursive ) 473 if ( recursive )
473 { 474 {
474 if ( pathfnInfo.isDir()) { 475 if ( pathfnInfo.isDir()) {
475 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); 476 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq);
476 } 477 }
477 478
478 479
479/*US 480/*US
480 if (!regexp.exactMatch(fn)) 481 if (!regexp.exactMatch(fn))
481 continue; // No match 482 continue; // No match
482*/ 483*/
483//US this should do the same: 484//US this should do the same:
484 pos = regexp.match(fn); 485 pos = regexp.match(fn);
485 if (!pos == 0) 486 if (!pos == 0)
486 continue; // No match 487 continue; // No match
487 } 488 }
488 489
489//US if ( S_ISREG( buff.st_mode)) 490//US if ( S_ISREG( buff.st_mode))
490 if ( pathfnInfo.isFile()) 491 if ( pathfnInfo.isFile())
491 { 492 {
492 if (!uniq || !relList.contains(relPart + fn)) 493 if (!uniq || !relList.contains(relPart + fn))
493 { 494 {
494 list.append( pathfn ); 495 list.append( pathfn );
495 relList.append( relPart + fn ); 496 relList.append( relPart + fn );
496 } 497 }
497 } 498 }
498 } 499 }
499//US closedir( dp ); 500//US closedir( dp );
500 } 501 }
501 else 502 else
502 { 503 {
503 // We look for a single file. 504 // We look for a single file.
504 QString fn = pattern; 505 QString fn = pattern;
505 QString pathfn = path + fn; 506 QString pathfn = path + fn;
506//US struct stat buff; 507//US struct stat buff;
507 QFileInfo pathfnInfo(QFile::encodeName(pathfn)); 508 QFileInfo pathfnInfo(QFile::encodeName(pathfn));
508 509
509 510
510//US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) 511//US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 )
511 if ( pathfnInfo.isReadable() == false ) 512 if ( pathfnInfo.isReadable() == false )
512 return; // File not found 513 return; // File not found
513 514
514//US if ( S_ISREG( buff.st_mode)) 515//US if ( S_ISREG( buff.st_mode))
515 if ( pathfnInfo.isFile()) 516 if ( pathfnInfo.isFile())
516 { 517 {
517 if (!uniq || !relList.contains(relPart + fn)) 518 if (!uniq || !relList.contains(relPart + fn))
518 { 519 {
519 list.append( pathfn ); 520 list.append( pathfn );
520 relList.append( relPart + fn ); 521 relList.append( relPart + fn );
521 } 522 }
522 } 523 }
523 } 524 }
524} 525}
525 526
526static void lookupPrefix(const QString& prefix, const QString& relpath, 527static void lookupPrefix(const QString& prefix, const QString& relpath,
527 const QString& relPart, 528 const QString& relPart,
528 const QRegExp &regexp, 529 const QRegExp &regexp,
529 QStringList& list, 530 QStringList& list,
530 QStringList& relList, 531 QStringList& relList,
531 bool recursive, bool uniq) 532 bool recursive, bool uniq)
532{ 533{
533 if (relpath.isNull()) { 534 if (relpath.isNull()) {
534 lookupDirectory(prefix, relPart, regexp, list, 535 lookupDirectory(prefix, relPart, regexp, list,
535 relList, recursive, uniq); 536 relList, recursive, uniq);
536 return; 537 return;
537 } 538 }
538 QString path; 539 QString path;
539 QString rest; 540 QString rest;
540 541
541 if (relpath.length()) 542 if (relpath.length())
542 { 543 {
543 int slash = relpath.find('/'); 544 int slash = relpath.find('/');
544 if (slash < 0) 545 if (slash < 0)
545 rest = relpath.left(relpath.length() - 1); 546 rest = relpath.left(relpath.length() - 1);
546 else { 547 else {
547 path = relpath.left(slash); 548 path = relpath.left(slash);
548 rest = relpath.mid(slash + 1); 549 rest = relpath.mid(slash + 1);
549 } 550 }
550 } 551 }
551 assert(prefix.at(prefix.length() - 1) == '/'); 552 assert(prefix.at(prefix.length() - 1) == '/');
552 553
553//US struct stat buff; 554//US struct stat buff;
554 555
555 if (path.contains('*') || path.contains('?')) { 556 if (path.contains('*') || path.contains('?')) {
556 QRegExp pathExp(path, true, true); 557 QRegExp pathExp(path, true, true);
557 //USDIR *dp = opendir( QFile::encodeName(prefix) ); 558 //USDIR *dp = opendir( QFile::encodeName(prefix) );
558 QDir dp(QFile::encodeName(prefix)); 559 QDir dp(QFile::encodeName(prefix));
559 560
560 //USif (!dp) 561 //USif (!dp)
561 if (!dp.exists()) 562 if (!dp.exists())
562 { 563 {
563 return; 564 return;
564 } 565 }
565 566
566 //USstruct dirent *ep; 567 //USstruct dirent *ep;
567 568
568 QString _dot("."); 569 QString _dot(".");
569 QString _dotdot(".."); 570 QString _dotdot("..");
570 571
571 //USwhile( ( ep = readdir( dp ) ) != 0L ) 572 //USwhile( ( ep = readdir( dp ) ) != 0L )
572 QStringList direntries = dp.entryList(); 573 QStringList direntries = dp.entryList();
573 QStringList::Iterator it = direntries.begin(); 574 QStringList::Iterator it = direntries.begin();
574 575
575 while ( it != list.end() ) // for each file... 576 while ( it != list.end() ) // for each file...
576 { 577 {
577//US QString fn( QFile::decodeName(ep->d_name)); 578//US QString fn( QFile::decodeName(ep->d_name));
578 QString fn = (*it); // dp.entryList() already encodes the strings 579 QString fn = (*it); // dp.entryList() already encodes the strings
579 it++; 580 it++;
580 581
581 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1) == '~') 582 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1) == '~')
582 continue; 583 continue;
583 584
584#ifdef DESKTOP_VERSION 585#ifdef DESKTOP_VERSION
585 586
586 if (pathExp.search(fn) == -1) 587 if (pathExp.search(fn) == -1)
587 continue; // No match 588 continue; // No match
588 589
589#else 590#else
590//US this should do the same: 591//US this should do the same:
591 if (pathExp.find(fn, 0) == -1) 592 if (pathExp.find(fn, 0) == -1)
592 continue; // No match 593 continue; // No match
593#endif 594#endif
594 QString rfn = relPart+fn; 595 QString rfn = relPart+fn;
595 fn = prefix + fn; 596 fn = prefix + fn;
596//US if ( stat( QFile::encodeName(fn), &buff ) != 0 ) 597//US if ( stat( QFile::encodeName(fn), &buff ) != 0 )
597 QFileInfo fnInfo(QFile::encodeName(fn)); 598 QFileInfo fnInfo(QFile::encodeName(fn));
598 if ( fnInfo.isReadable() == false ) 599 if ( fnInfo.isReadable() == false )
599 { 600 {
600//US kdDebug() << "Error statting " << fn << " : " << perror << endl; 601//US kdDebug() << "Error statting " << fn << " : " << perror << endl;
601 continue; // Couldn't stat (e.g. no permissions) 602 continue; // Couldn't stat (e.g. no permissions)
602 } 603 }
603 //US if ( S_ISDIR( buff.st_mode )) 604 //US if ( S_ISDIR( buff.st_mode ))
604 if ( fnInfo.isDir() ) 605 if ( fnInfo.isDir() )
605 606
606 lookupPrefix(fn + '/', rest, rfn + '/', regexp, list, relList, recursive, uniq); 607 lookupPrefix(fn + '/', rest, rfn + '/', regexp, list, relList, recursive, uniq);
607 } 608 }
608 609
609 //USclosedir( dp ); 610 //USclosedir( dp );
610 } else { 611 } else {
611 // Don't stat, if the dir doesn't exist we will find out 612 // Don't stat, if the dir doesn't exist we will find out
612 // when we try to open it. 613 // when we try to open it.
613 lookupPrefix(prefix + path + '/', rest, 614 lookupPrefix(prefix + path + '/', rest,
614 relPart + path + '/', regexp, list, 615 relPart + path + '/', regexp, list,
615 relList, recursive, uniq); 616 relList, recursive, uniq);
616 } 617 }
617} 618}
618 619
619QStringList 620QStringList
620KStandardDirs::findAllResources( const char *type, 621KStandardDirs::findAllResources( const char *type,
621 const QString& filter, 622 const QString& filter,
622 bool recursive, 623 bool recursive,
623 bool uniq, 624 bool uniq,
624 QStringList &relList) const 625 QStringList &relList) const
625{ 626{
626 QStringList list; 627 QStringList list;
627 if (filter.at(0) == '/') // absolute paths we return 628 if (filter.at(0) == '/') // absolute paths we return
628 { 629 {
629 list.append( filter); 630 list.append( filter);
630 return list; 631 return list;
631 } 632 }
632 633
633 QString filterPath; 634 QString filterPath;
634 QString filterFile; 635 QString filterFile;
635 636
636 if (filter.length()) 637 if (filter.length())
637 { 638 {
638 int slash = filter.findRev('/'); 639 int slash = filter.findRev('/');
639 if (slash < 0) 640 if (slash < 0)
640 filterFile = filter; 641 filterFile = filter;
641 else { 642 else {
642 filterPath = filter.left(slash + 1); 643 filterPath = filter.left(slash + 1);
643 filterFile = filter.mid(slash + 1); 644 filterFile = filter.mid(slash + 1);
644 } 645 }
645 } 646 }
646 checkConfig(); 647 checkConfig();
647 648
648 if (d && d->restrictionsActive && (strcmp(type, "data")==0)) 649 if (d && d->restrictionsActive && (strcmp(type, "data")==0))
649 applyDataRestrictions(filter); 650 applyDataRestrictions(filter);
650 QStringList candidates = resourceDirs(type); 651 QStringList candidates = resourceDirs(type);
651 if (filterFile.isEmpty()) 652 if (filterFile.isEmpty())
652 filterFile = "*"; 653 filterFile = "*";
653 654
654 QRegExp regExp(filterFile, true, true); 655 QRegExp regExp(filterFile, true, true);
655 for (QStringList::ConstIterator it = candidates.begin(); 656 for (QStringList::ConstIterator it = candidates.begin();
656 it != candidates.end(); it++) 657 it != candidates.end(); it++)
657 { 658 {
658 lookupPrefix(*it, filterPath, "", regExp, list, 659 lookupPrefix(*it, filterPath, "", regExp, list,
659 relList, recursive, uniq); 660 relList, recursive, uniq);
660 } 661 }
661 return list; 662 return list;
662} 663}
663 664
664QStringList 665QStringList
665KStandardDirs::findAllResources( const char *type, 666KStandardDirs::findAllResources( const char *type,
666 const QString& filter, 667 const QString& filter,
667 bool recursive, 668 bool recursive,
668 bool uniq) const 669 bool uniq) const
669{ 670{
670 QStringList relList; 671 QStringList relList;
671 return findAllResources(type, filter, recursive, uniq, relList); 672 return findAllResources(type, filter, recursive, uniq, relList);
672} 673}
673 674
674QString 675QString
675KStandardDirs::realPath(const QString &dirname) 676KStandardDirs::realPath(const QString &dirname)
676{ 677{
677#ifdef _WIN32_ 678#ifdef _WIN32_
678 return dirname; 679 return dirname;
679#else 680#else
680//US char realpath_buffer[MAXPATHLEN + 1]; 681//US char realpath_buffer[MAXPATHLEN + 1];
681//US memset(realpath_buffer, 0, MAXPATHLEN + 1); 682//US memset(realpath_buffer, 0, MAXPATHLEN + 1);
682 char realpath_buffer[250 + 1]; 683 char realpath_buffer[250 + 1];
683 memset(realpath_buffer, 0, 250 + 1); 684 memset(realpath_buffer, 0, 250 + 1);
684 685
685 /* If the path contains symlinks, get the real name */ 686 /* If the path contains symlinks, get the real name */
686 if (realpath( QFile::encodeName(dirname).data(), realpath_buffer) != 0) { 687 if (realpath( QFile::encodeName(dirname).data(), realpath_buffer) != 0) {
687 // succes, use result from realpath 688 // succes, use result from realpath
688 int len = strlen(realpath_buffer); 689 int len = strlen(realpath_buffer);
689 realpath_buffer[len] = '/'; 690 realpath_buffer[len] = '/';
690 realpath_buffer[len+1] = 0; 691 realpath_buffer[len+1] = 0;
691 return QFile::decodeName(realpath_buffer); 692 return QFile::decodeName(realpath_buffer);
692 } 693 }
693 694
694 return dirname; 695 return dirname;
695#endif 696#endif
696} 697}
697/*US 698/*US
698void KStandardDirs::createSpecialResource(const char *type) 699void KStandardDirs::createSpecialResource(const char *type)
699{ 700{
700 char hostname[256]; 701 char hostname[256];
701 hostname[0] = 0; 702 hostname[0] = 0;
702 gethostname(hostname, 255); 703 gethostname(hostname, 255);
703 QString dir = QString("%1%2-%3").arg(localkdedir()).arg(type).arg(hostname); 704 QString dir = QString("%1%2-%3").arg(localkdedir()).arg(type).arg(hostname);
704 char link[1024]; 705 char link[1024];
705 link[1023] = 0; 706 link[1023] = 0;
706 int result = readlink(QFile::encodeName(dir).data(), link, 1023); 707 int result = readlink(QFile::encodeName(dir).data(), link, 1023);
707 if ((result == -1) && (errno == ENOENT)) 708 if ((result == -1) && (errno == ENOENT))
708 { 709 {
709 QString srv = findExe(QString::fromLatin1("lnusertemp"), KDEDIR+QString::fromLatin1("/bin")); 710 QString srv = findExe(QString::fromLatin1("lnusertemp"), KDEDIR+QString::fromLatin1("/bin"));
710 if (srv.isEmpty()) 711 if (srv.isEmpty())
711 srv = findExe(QString::fromLatin1("lnusertemp")); 712 srv = findExe(QString::fromLatin1("lnusertemp"));
712 if (!srv.isEmpty()) 713 if (!srv.isEmpty())
713 { 714 {
714 system(QFile::encodeName(srv)+" "+type); 715 system(QFile::encodeName(srv)+" "+type);
715 result = readlink(QFile::encodeName(dir).data(), link, 1023); 716 result = readlink(QFile::encodeName(dir).data(), link, 1023);
716 } 717 }
717 } 718 }
718 if (result > 0) 719 if (result > 0)
719 { 720 {
720 link[result] = 0; 721 link[result] = 0;
721 if (link[0] == '/') 722 if (link[0] == '/')
722 dir = QFile::decodeName(link); 723 dir = QFile::decodeName(link);
723 else 724 else
724 dir = QDir::cleanDirPath(dir+QFile::decodeName(link)); 725 dir = QDir::cleanDirPath(dir+QFile::decodeName(link));
725 } 726 }
726 addResourceDir(type, dir+'/'); 727 addResourceDir(type, dir+'/');
727} 728}
728*/ 729*/
729 730
730QStringList KStandardDirs::resourceDirs(const char *type) const 731QStringList KStandardDirs::resourceDirs(const char *type) const
731{ 732{
732 QStringList *candidates = dircache.find(type); 733 QStringList *candidates = dircache.find(type);
733 734
734 if (!candidates) { // filling cache 735 if (!candidates) { // filling cache
735/*US 736/*US
736 if (strcmp(type, "socket") == 0) 737 if (strcmp(type, "socket") == 0)
737 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 738 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
738 else if (strcmp(type, "tmp") == 0) 739 else if (strcmp(type, "tmp") == 0)
739 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 740 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
740 else if (strcmp(type, "cache") == 0) 741 else if (strcmp(type, "cache") == 0)
741 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 742 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
742*/ 743*/
743 QDir testdir; 744 QDir testdir;
744 745
745 candidates = new QStringList(); 746 candidates = new QStringList();
746 QStringList *dirs; 747 QStringList *dirs;
747 748
748 bool restrictionActive = false; 749 bool restrictionActive = false;
749 if (d && d->restrictionsActive) 750 if (d && d->restrictionsActive)
750 { 751 {
751 if (d->dataRestrictionActive) 752 if (d->dataRestrictionActive)
752 restrictionActive = true; 753 restrictionActive = true;
753 else if (d->restrictions["all"]) 754 else if (d->restrictions["all"])
754 restrictionActive = true; 755 restrictionActive = true;
755 else if (d->restrictions[type]) 756 else if (d->restrictions[type])
756 restrictionActive = true; 757 restrictionActive = true;
757 d->dataRestrictionActive = false; // Reset 758 d->dataRestrictionActive = false; // Reset
758 } 759 }
759 760
760 dirs = relatives.find(type); 761 dirs = relatives.find(type);
761 if (dirs) 762 if (dirs)
762 { 763 {
763 bool local = true; 764 bool local = true;
764 const QStringList *prefixList = 0; 765 const QStringList *prefixList = 0;
765 if (strncmp(type, "xdgdata-", 8) == 0) 766 if (strncmp(type, "xdgdata-", 8) == 0)
766 prefixList = &(d->xdgdata_prefixes); 767 prefixList = &(d->xdgdata_prefixes);
767 else if (strncmp(type, "xdgconf-", 8) == 0) 768 else if (strncmp(type, "xdgconf-", 8) == 0)
768 prefixList = &(d->xdgconf_prefixes); 769 prefixList = &(d->xdgconf_prefixes);
769 else 770 else
770 prefixList = &prefixes; 771 prefixList = &prefixes;
771 772
772 for (QStringList::ConstIterator pit = prefixList->begin(); 773 for (QStringList::ConstIterator pit = prefixList->begin();
773 pit != prefixList->end(); 774 pit != prefixList->end();
774 pit++) 775 pit++)
775 { 776 {
776 for (QStringList::ConstIterator it = dirs->begin(); 777 for (QStringList::ConstIterator it = dirs->begin();
777 it != dirs->end(); ++it) { 778 it != dirs->end(); ++it) {
778 QString path = realPath(*pit + *it); 779 QString path = realPath(*pit + *it);
779 testdir.setPath(path); 780 testdir.setPath(path);
780 if (local && restrictionActive) 781 if (local && restrictionActive)
781 continue; 782 continue;
782 if ((local || testdir.exists()) && !candidates->contains(path)) 783 if ((local || testdir.exists()) && !candidates->contains(path))
783 candidates->append(path); 784 candidates->append(path);
784 } 785 }
785 local = false; 786 local = false;
786 } 787 }
787 } 788 }
788 dirs = absolutes.find(type); 789 dirs = absolutes.find(type);
789 if (dirs) 790 if (dirs)
790 for (QStringList::ConstIterator it = dirs->begin(); 791 for (QStringList::ConstIterator it = dirs->begin();
791 it != dirs->end(); ++it) 792 it != dirs->end(); ++it)
792 { 793 {
793 testdir.setPath(*it); 794 testdir.setPath(*it);
794 if (testdir.exists()) 795 if (testdir.exists())
795 { 796 {
796 QString filename = realPath(*it); 797 QString filename = realPath(*it);
797 if (!candidates->contains(filename)) 798 if (!candidates->contains(filename))
798 candidates->append(filename); 799 candidates->append(filename);
799 } 800 }
800 } 801 }
801 dircache.insert(type, candidates); 802 dircache.insert(type, candidates);
802 } 803 }
803 804
804#if 0 805#if 0
805 kdDebug() << "found dirs for resource " << type << ":" << endl; 806 kdDebug() << "found dirs for resource " << type << ":" << endl;
806 for (QStringList::ConstIterator pit = candidates->begin(); 807 for (QStringList::ConstIterator pit = candidates->begin();
807 pit != candidates->end(); 808 pit != candidates->end();
808 pit++) 809 pit++)
809 { 810 {
810 fprintf(stderr, "%s\n", (*pit).latin1()); 811 fprintf(stderr, "%s\n", (*pit).latin1());
811 } 812 }
812#endif 813#endif
813 814
814 815
815 return *candidates; 816 return *candidates;
816} 817}
817 818
818/*US 819/*US
819QString KStandardDirs::findExe( const QString& appname, 820QString KStandardDirs::findExe( const QString& appname,
820 const QString& pstr, bool ignore) 821 const QString& pstr, bool ignore)
821{ 822{
822 QFileInfo info; 823 QFileInfo info;
823 824
824 // absolute path ? 825 // absolute path ?
825 if (appname.startsWith(QString::fromLatin1("/"))) 826 if (appname.startsWith(QString::fromLatin1("/")))
826 { 827 {
827 info.setFile( appname ); 828 info.setFile( appname );
828 if( info.exists() && ( ignore || info.isExecutable() ) 829 if( info.exists() && ( ignore || info.isExecutable() )
829 && info.isFile() ) { 830 && info.isFile() ) {
830 return appname; 831 return appname;
831 } 832 }
832 return QString::null; 833 return QString::null;
833 } 834 }
834 835
835//US QString p = QString("%1/%2").arg(__KDE_BINDIR).arg(appname); 836//US QString p = QString("%1/%2").arg(__KDE_BINDIR).arg(appname);
836 QString p = QString("%1/%2").arg(appname).arg(appname); 837 QString p = QString("%1/%2").arg(appname).arg(appname);
837 qDebug("KStandardDirs::findExe this is probably wrong"); 838 qDebug("KStandardDirs::findExe this is probably wrong");
838 839
839 info.setFile( p ); 840 info.setFile( p );
840 if( info.exists() && ( ignore || info.isExecutable() ) 841 if( info.exists() && ( ignore || info.isExecutable() )
841 && ( info.isFile() || info.isSymLink() ) ) { 842 && ( info.isFile() || info.isSymLink() ) ) {
842 return p; 843 return p;
843 } 844 }
844 845
845 QStringList tokens; 846 QStringList tokens;
846 p = pstr; 847 p = pstr;
847 848
848 if( p.isNull() ) { 849 if( p.isNull() ) {
849 p = getenv( "PATH" ); 850 p = getenv( "PATH" );
850 } 851 }
851 852
852 tokenize( tokens, p, ":\b" ); 853 tokenize( tokens, p, ":\b" );
853 854
854 // split path using : or \b as delimiters 855 // split path using : or \b as delimiters
855 for( unsigned i = 0; i < tokens.count(); i++ ) { 856 for( unsigned i = 0; i < tokens.count(); i++ ) {
856 p = tokens[ i ]; 857 p = tokens[ i ];
857 858
858 if ( p[ 0 ] == '~' ) 859 if ( p[ 0 ] == '~' )
859 { 860 {
860 int len = p.find( '/' ); 861 int len = p.find( '/' );
861 if ( len == -1 ) 862 if ( len == -1 )
862 len = p.length(); 863 len = p.length();
863 if ( len == 1 ) 864 if ( len == 1 )
864 p.replace( 0, 1, QDir::homeDirPath() ); 865 p.replace( 0, 1, QDir::homeDirPath() );
865 else 866 else
866 { 867 {
867 QString user = p.mid( 1, len - 1 ); 868 QString user = p.mid( 1, len - 1 );
868 struct passwd *dir = getpwnam( user.local8Bit().data() ); 869 struct passwd *dir = getpwnam( user.local8Bit().data() );
869 if ( dir && strlen( dir->pw_dir ) ) 870 if ( dir && strlen( dir->pw_dir ) )
870 p.replace( 0, len, QString::fromLocal8Bit( dir->pw_dir ) ); 871 p.replace( 0, len, QString::fromLocal8Bit( dir->pw_dir ) );
871 } 872 }
872 } 873 }
873 874
874 p += "/"; 875 p += "/";
875 p += appname; 876 p += appname;
876 877
877 // Check for executable in this tokenized path 878 // Check for executable in this tokenized path
878 info.setFile( p ); 879 info.setFile( p );
879 880
880 if( info.exists() && ( ignore || info.isExecutable() ) 881 if( info.exists() && ( ignore || info.isExecutable() )
881 && ( info.isFile() || info.isSymLink() ) ) { 882 && ( info.isFile() || info.isSymLink() ) ) {
882 return p; 883 return p;
883 } 884 }
884 } 885 }
885 886
886 // If we reach here, the executable wasn't found. 887 // If we reach here, the executable wasn't found.
887 // So return empty string. 888 // So return empty string.
888 889
889 return QString::null; 890 return QString::null;
890} 891}
891 892
892int KStandardDirs::findAllExe( QStringList& list, const QString& appname, 893int KStandardDirs::findAllExe( QStringList& list, const QString& appname,
893 const QString& pstr, bool ignore ) 894 const QString& pstr, bool ignore )
894{ 895{
895 QString p = pstr; 896 QString p = pstr;
896 QFileInfo info; 897 QFileInfo info;
897 QStringList tokens; 898 QStringList tokens;
898 899
899 if( p.isNull() ) { 900 if( p.isNull() ) {
900 p = getenv( "PATH" ); 901 p = getenv( "PATH" );
901 } 902 }
902 903
903 list.clear(); 904 list.clear();
904 tokenize( tokens, p, ":\b" ); 905 tokenize( tokens, p, ":\b" );
905 906
906 for ( unsigned i = 0; i < tokens.count(); i++ ) { 907 for ( unsigned i = 0; i < tokens.count(); i++ ) {
907 p = tokens[ i ]; 908 p = tokens[ i ];
908 p += "/"; 909 p += "/";
909 p += appname; 910 p += appname;
910 911
911 info.setFile( p ); 912 info.setFile( p );
912 913
913 if( info.exists() && (ignore || info.isExecutable()) 914 if( info.exists() && (ignore || info.isExecutable())
914 && info.isFile() ) { 915 && info.isFile() ) {
915 list.append( p ); 916 list.append( p );
916 } 917 }
917 918
918 } 919 }
919 920
920 return list.count(); 921 return list.count();
921} 922}
922*/ 923*/
923 924
924static int tokenize( QStringList& tokens, const QString& str, 925static int tokenize( QStringList& tokens, const QString& str,
925 const QString& delim ) 926 const QString& delim )
926{ 927{
927 int len = str.length(); 928 int len = str.length();
928 QString token = ""; 929 QString token = "";
929 930
930 for( int index = 0; index < len; index++) 931 for( int index = 0; index < len; index++)
931 { 932 {
932 if ( delim.find( str[ index ] ) >= 0 ) 933 if ( delim.find( str[ index ] ) >= 0 )
933 { 934 {
934 tokens.append( token ); 935 tokens.append( token );
935 token = ""; 936 token = "";
936 } 937 }
937 else 938 else
938 { 939 {
939 token += str[ index ]; 940 token += str[ index ];
940 } 941 }
941 } 942 }
942 if ( token.length() > 0 ) 943 if ( token.length() > 0 )
943 { 944 {
944 tokens.append( token ); 945 tokens.append( token );
945 } 946 }
946 947
947 return tokens.count(); 948 return tokens.count();
948} 949}
949 950
950QString KStandardDirs::kde_default(const char *type) { 951QString KStandardDirs::kde_default(const char *type) {
951 if (!strcmp(type, "data")) 952 if (!strcmp(type, "data"))
952 return "apps/"; 953 return "apps/";
953 if (!strcmp(type, "html")) 954 if (!strcmp(type, "html"))
954 return "share/doc/HTML/"; 955 return "share/doc/HTML/";
955 if (!strcmp(type, "icon")) 956 if (!strcmp(type, "icon"))
956 return "share/icons/"; 957 return "share/icons/";
957 if (!strcmp(type, "config")) 958 if (!strcmp(type, "config"))
958 return "config/"; 959 return "config/";
959 if (!strcmp(type, "pixmap")) 960 if (!strcmp(type, "pixmap"))
960 return "share/pixmaps/"; 961 return "share/pixmaps/";
961 if (!strcmp(type, "apps")) 962 if (!strcmp(type, "apps"))
962 return "share/applnk/"; 963 return "share/applnk/";
963 if (!strcmp(type, "sound")) 964 if (!strcmp(type, "sound"))
964 return "share/sounds/"; 965 return "share/sounds/";
965 if (!strcmp(type, "locale")) 966 if (!strcmp(type, "locale"))
966 return "share/locale/"; 967 return "share/locale/";
967 if (!strcmp(type, "services")) 968 if (!strcmp(type, "services"))
968 return "share/services/"; 969 return "share/services/";
969 if (!strcmp(type, "servicetypes")) 970 if (!strcmp(type, "servicetypes"))
970 return "share/servicetypes/"; 971 return "share/servicetypes/";
971 if (!strcmp(type, "mime")) 972 if (!strcmp(type, "mime"))
972 return "share/mimelnk/"; 973 return "share/mimelnk/";
973 if (!strcmp(type, "cgi")) 974 if (!strcmp(type, "cgi"))
974 return "cgi-bin/"; 975 return "cgi-bin/";
975 if (!strcmp(type, "wallpaper")) 976 if (!strcmp(type, "wallpaper"))
976 return "share/wallpapers/"; 977 return "share/wallpapers/";
977 if (!strcmp(type, "templates")) 978 if (!strcmp(type, "templates"))
978 return "share/templates/"; 979 return "share/templates/";
979 if (!strcmp(type, "exe")) 980 if (!strcmp(type, "exe"))
980 return "bin/"; 981 return "bin/";
981 if (!strcmp(type, "lib")) 982 if (!strcmp(type, "lib"))
982 return "lib/"; 983 return "lib/";
983 if (!strcmp(type, "module")) 984 if (!strcmp(type, "module"))
984 return "lib/kde3/"; 985 return "lib/kde3/";
985 if (!strcmp(type, "qtplugins")) 986 if (!strcmp(type, "qtplugins"))
986 return "lib/kde3/plugins"; 987 return "lib/kde3/plugins";
987 if (!strcmp(type, "xdgdata-apps")) 988 if (!strcmp(type, "xdgdata-apps"))
988 return "applications/"; 989 return "applications/";
989 if (!strcmp(type, "xdgdata-dirs")) 990 if (!strcmp(type, "xdgdata-dirs"))
990 return "desktop-directories/"; 991 return "desktop-directories/";
991 if (!strcmp(type, "xdgconf-menu")) 992 if (!strcmp(type, "xdgconf-menu"))
992 return "menus/"; 993 return "menus/";
993 if (!strcmp(type, "tmp")) 994 if (!strcmp(type, "tmp"))
994 return "tmp/"; 995 return "tmp/";
995 996
996 qFatal("unknown resource type %s", type); 997 qFatal("unknown resource type %s", type);
997 return QString::null; 998 return QString::null;
998} 999}
999 1000
1000QString KStandardDirs::saveLocation(const char *type, 1001QString KStandardDirs::saveLocation(const char *type,
1001 const QString& suffix, 1002 const QString& suffix,
1002 bool create) const 1003 bool create) const
1003{ 1004{
1004 //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() ); 1005 //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() );
1005 //return ""; 1006 //return "";
1006 checkConfig(); 1007 checkConfig();
1007 1008
1008 QString *pPath = savelocations.find(type); 1009 QString *pPath = savelocations.find(type);
1009 if (!pPath) 1010 if (!pPath)
1010 { 1011 {
1011 QStringList *dirs = relatives.find(type); 1012 QStringList *dirs = relatives.find(type);
1012 if (!dirs && ( 1013 if (!dirs && (
1013 (strcmp(type, "socket") == 0) || 1014 (strcmp(type, "socket") == 0) ||
1014 (strcmp(type, "tmp") == 0) || 1015 (strcmp(type, "tmp") == 0) ||
1015 (strcmp(type, "cache") == 0) )) 1016 (strcmp(type, "cache") == 0) ))
1016 { 1017 {
1017 (void) resourceDirs(type); // Generate socket|tmp|cache resource. 1018 (void) resourceDirs(type); // Generate socket|tmp|cache resource.
1018 dirs = relatives.find(type); // Search again. 1019 dirs = relatives.find(type); // Search again.
1019 } 1020 }
1020 if (dirs) 1021 if (dirs)
1021 { 1022 {
1022 // Check for existance of typed directory + suffix 1023 // Check for existance of typed directory + suffix
1023 if (strncmp(type, "xdgdata-", 8) == 0) 1024 if (strncmp(type, "xdgdata-", 8) == 0)
1024 pPath = new QString(realPath(localxdgdatadir() + dirs->last())); 1025 pPath = new QString(realPath(localxdgdatadir() + dirs->last()));
1025 else if (strncmp(type, "xdgconf-", 8) == 0) 1026 else if (strncmp(type, "xdgconf-", 8) == 0)
1026 pPath = new QString(realPath(localxdgconfdir() + dirs->last())); 1027 pPath = new QString(realPath(localxdgconfdir() + dirs->last()));
1027 else 1028 else
1028 pPath = new QString(realPath(localkdedir() + dirs->last())); 1029 pPath = new QString(realPath(localkdedir() + dirs->last()));
1029 } 1030 }
1030 else { 1031 else {
1031 dirs = absolutes.find(type); 1032 dirs = absolutes.find(type);
1032 if (!dirs) 1033 if (!dirs)
1033 qFatal("KStandardDirs: The resource type %s is not registered", type); 1034 qFatal("KStandardDirs: The resource type %s is not registered", type);
1034 pPath = new QString(realPath(dirs->last())); 1035 pPath = new QString(realPath(dirs->last()));
1035 } 1036 }
1036 1037
1037 savelocations.insert(type, pPath); 1038 savelocations.insert(type, pPath);
1038 } 1039 }
1039 1040
1040 QString fullPath = *pPath + suffix; 1041 QString fullPath = *pPath + suffix;
1041//US struct stat st; 1042//US struct stat st;
1042//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) 1043//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode)))
1043 QFileInfo fullPathInfo(QFile::encodeName(fullPath)); 1044 QFileInfo fullPathInfo(QFile::encodeName(fullPath));
1044 if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) 1045 if (fullPathInfo.isReadable() || !fullPathInfo.isDir())
1045 1046
1046 1047
1047 { 1048 {
1048 if(!create) { 1049 if(!create) {
1049#ifndef NDEBUG 1050#ifndef NDEBUG
1050 qDebug("save location %s doesn't exist", fullPath.latin1()); 1051 qDebug("save location %s doesn't exist", fullPath.latin1());
1051#endif 1052#endif
1052 return fullPath; 1053 return fullPath;
1053 } 1054 }
1054 if(!makeDir(fullPath, 0700)) { 1055 if(!makeDir(fullPath, 0700)) {
1055 qWarning("failed to create %s", fullPath.latin1()); 1056 qWarning("failed to create %s", fullPath.latin1());
1056 return fullPath; 1057 return fullPath;
1057 } 1058 }
1058 dircache.remove(type); 1059 dircache.remove(type);
1059 } 1060 }
1060 return fullPath; 1061 return fullPath;
1061} 1062}
1062 1063
1063QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) 1064QString KStandardDirs::relativeLocation(const char *type, const QString &absPath)
1064{ 1065{
1065 QString fullPath = absPath; 1066 QString fullPath = absPath;
1066 int i = absPath.findRev('/'); 1067 int i = absPath.findRev('/');
1067 if (i != -1) 1068 if (i != -1)
1068 { 1069 {
1069 fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize 1070 fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize
1070 } 1071 }
1071 1072
1072 QStringList candidates = resourceDirs(type); 1073 QStringList candidates = resourceDirs(type);
1073 1074
1074 for (QStringList::ConstIterator it = candidates.begin(); 1075 for (QStringList::ConstIterator it = candidates.begin();
1075 it != candidates.end(); it++) 1076 it != candidates.end(); it++)
1076 if (fullPath.startsWith(*it)) 1077 if (fullPath.startsWith(*it))
1077 { 1078 {
1078 return fullPath.mid((*it).length()); 1079 return fullPath.mid((*it).length());
1079 } 1080 }
1080 1081
1081 return absPath; 1082 return absPath;
1082} 1083}
1083 1084
1084 1085
1085bool KStandardDirs::makeDir(const QString& dir2, int mode) 1086bool KStandardDirs::makeDir(const QString& dir2, int mode)
1086{ 1087{
1087 QString dir = QDir::convertSeparators( dir2 ); 1088 QString dir = QDir::convertSeparators( dir2 );
1088#if 0 1089#if 0
1089 //LR 1090 //LR
1090 1091
1091 // we want an absolute path 1092 // we want an absolute path
1092 if (dir.at(0) != '/') 1093 if (dir.at(0) != '/')
1093 return false; 1094 return false;
1094 1095
1095 QString target = dir; 1096 QString target = dir;
1096 uint len = target.length(); 1097 uint len = target.length();
1097 1098
1098 // append trailing slash if missing 1099 // append trailing slash if missing
1099 if (dir.at(len - 1) != '/') 1100 if (dir.at(len - 1) != '/')
1100 target += '/'; 1101 target += '/';
1101 1102
1102 QString base(""); 1103 QString base("");
1103 uint i = 1; 1104 uint i = 1;
1104 1105
1105 while( i < len ) 1106 while( i < len )
1106 { 1107 {
1107//US struct stat st; 1108//US struct stat st;
1108 int pos = target.find('/', i); 1109 int pos = target.find('/', i);
1109 base += target.mid(i - 1, pos - i + 1); 1110 base += target.mid(i - 1, pos - i + 1);
1110 QCString baseEncoded = QFile::encodeName(base); 1111 QCString baseEncoded = QFile::encodeName(base);
1111 // bail out if we encountered a problem 1112 // bail out if we encountered a problem
1112//US if (stat(baseEncoded, &st) != 0) 1113//US if (stat(baseEncoded, &st) != 0)
1113 QFileInfo baseEncodedInfo(baseEncoded); 1114 QFileInfo baseEncodedInfo(baseEncoded);
1114 if (!baseEncodedInfo.exists()) 1115 if (!baseEncodedInfo.exists())
1115 { 1116 {
1116 // Directory does not exist.... 1117 // Directory does not exist....
1117 // Or maybe a dangling symlink ? 1118 // Or maybe a dangling symlink ?
1118//US if (lstat(baseEncoded, &st) == 0) 1119//US if (lstat(baseEncoded, &st) == 0)
1119 if (baseEncodedInfo.isSymLink()) { 1120 if (baseEncodedInfo.isSymLink()) {
1120//US (void)unlink(baseEncoded); // try removing 1121//US (void)unlink(baseEncoded); // try removing
1121 QFile(baseEncoded).remove(); 1122 QFile(baseEncoded).remove();
1122 } 1123 }
1123 1124
1124 //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) 1125 //US if ( mkdir(baseEncoded, (mode_t) mode) != 0)
1125 QDir dirObj; 1126 QDir dirObj;
1126 if ( dirObj.mkdir(baseEncoded) != true ) 1127 if ( dirObj.mkdir(baseEncoded) != true )
1127 { 1128 {
1128 //US perror("trying to create local folder"); 1129 //US perror("trying to create local folder");
1129 return false; // Couldn't create it :-( 1130 return false; // Couldn't create it :-(
1130 } 1131 }
1131 } 1132 }
1132 i = pos + 1; 1133 i = pos + 1;
1133 } 1134 }
1134 return true; 1135 return true;
1135#endif 1136#endif
1136 1137
1137 // ******************************************** 1138 // ********************************************
1138 // new code for WIN32 1139 // new code for WIN32
1139 QDir dirObj; 1140 QDir dirObj;
1140 1141
1141 1142
1142 // we want an absolute path 1143 // we want an absolute path
1143#ifndef _WIN32_ 1144#ifndef _WIN32_
1144 if (dir.at(0) != '/') 1145 if (dir.at(0) != '/')
1145 return false; 1146 return false;
1146#endif 1147#endif
1147 1148
1148 QString target = dir; 1149 QString target = dir;
1149 uint len = target.length(); 1150 uint len = target.length();
1150#ifndef _WIN32_ 1151#ifndef _WIN32_
1151 // append trailing slash if missing 1152 // append trailing slash if missing
1152 if (dir.at(len - 1) != '/') 1153 if (dir.at(len - 1) != '/')
1153 target += '/'; 1154 target += '/';
1154#endif 1155#endif
1155 1156
1156 QString base(""); 1157 QString base("");
1157 uint i = 1; 1158 uint i = 1;
1158 1159
1159 while( i < len ) 1160 while( i < len )
1160 { 1161 {
1161//US struct stat st; 1162//US struct stat st;
1162#ifndef _WIN32_ 1163#ifndef _WIN32_
1163 int pos = target.find('/', i); 1164 int pos = target.find('/', i);
1164#else 1165#else
1165 int pos = target.find('\\', i); 1166 int pos = target.find('\\', i);
1166#endif 1167#endif
1167 if ( pos < 0 ) 1168 if ( pos < 0 )
1168 return true; 1169 return true;
1169 base += target.mid(i - 1, pos - i + 1); 1170 base += target.mid(i - 1, pos - i + 1);
1170 //QMessageBox::information( 0,"cap111", base, 1 ); 1171 //QMessageBox::information( 0,"cap111", base, 1 );
1171/*US 1172/*US
1172 QCString baseEncoded = QFile::encodeName(base); 1173 QCString baseEncoded = QFile::encodeName(base);
1173 // bail out if we encountered a problem 1174 // bail out if we encountered a problem
1174 if (stat(baseEncoded, &st) != 0) 1175 if (stat(baseEncoded, &st) != 0)
1175 { 1176 {
1176 // Directory does not exist.... 1177 // Directory does not exist....
1177 // Or maybe a dangling symlink ? 1178 // Or maybe a dangling symlink ?
1178 if (lstat(baseEncoded, &st) == 0) 1179 if (lstat(baseEncoded, &st) == 0)
1179 (void)unlink(baseEncoded); // try removing 1180 (void)unlink(baseEncoded); // try removing
1180 1181
1181 1182
1182 if ( mkdir(baseEncoded, (mode_t) mode) != 0) { 1183 if ( mkdir(baseEncoded, (mode_t) mode) != 0) {
1183 perror("trying to create local folder"); 1184 perror("trying to create local folder");
1184 return false; // Couldn't create it :-( 1185 return false; // Couldn't create it :-(
1185 } 1186 }
1186 } 1187 }
1187*/ 1188*/
1188 1189
1189 if (dirObj.exists(base) == false) 1190 if (dirObj.exists(base) == false)
1190 { 1191 {
1191 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); 1192 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1());
1192 if (dirObj.mkdir(base) != true) 1193 if (dirObj.mkdir(base) != true)
1193 { 1194 {
1194 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); 1195 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1());
1195 return false; 1196 return false;
1196 } 1197 }
1197 } 1198 }
1198 1199
1199 i = pos + 1; 1200 i = pos + 1;
1200 } 1201 }
1201 return true; 1202 return true;
1202 1203
1203} 1204}
1204 1205
1205static QString readEnvPath(const char *env) 1206static QString readEnvPath(const char *env)
1206{ 1207{
1207#ifdef _WIN32_ 1208 //#ifdef _WIN32_
1208 return ""; 1209 // return "";
1209#else 1210 //#else
1210 QCString c_path = getenv(env); 1211 QCString c_path;
1211 if (c_path.isEmpty()) 1212 if ( getenv(env) != NULL )
1212 return QString::null; 1213 c_path = QString ( getenv(env) );
1213 return QFile::decodeName(c_path); 1214 if (c_path.isEmpty())
1214#endif 1215 return QString::null;
1216 return QFile::decodeName(c_path);
1217 //#endif
1218
1215} 1219}
1216 1220
1217void KStandardDirs::addKDEDefaults() 1221void KStandardDirs::addKDEDefaults()
1218{ 1222{
1223
1219 //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); 1224 //qDebug("ERROR: KStandardDirs::addKDEDefaults() called ");
1220 //return; 1225 //return;
1221 QStringList kdedirList; 1226 QStringList kdedirList;
1222 1227
1223 // begin KDEDIRS 1228 // begin KDEDIRS
1224 QString kdedirs = readEnvPath("MICROKDEDIRS"); 1229 QString kdedirs = readEnvPath("MICROKDEDIRS");
1225 if (!kdedirs.isEmpty()) 1230 if (!kdedirs.isEmpty())
1226 { 1231 {
1227 tokenize(kdedirList, kdedirs, ":"); 1232 tokenize(kdedirList, kdedirs, ":");
1228 } 1233 }
1229 else 1234 else
1230 { 1235 {
1231 QString kdedir = readEnvPath("MICROKDEDIR"); 1236 QString kdedir = readEnvPath("MICROKDEDIR");
1232 if (!kdedir.isEmpty()) 1237 if (!kdedir.isEmpty())
1233 { 1238 {
1234 kdedir = KShell::tildeExpand(kdedir); 1239 kdedir = KShell::tildeExpand(kdedir);
1235 kdedirList.append(kdedir); 1240 kdedirList.append(kdedir);
1236 } 1241 }
1237 } 1242 }
1238//US kdedirList.append(KDEDIR); 1243//US kdedirList.append(KDEDIR);
1239//US for embedded, add qtopia dir as kdedir 1244//US for embedded, add qtopia dir as kdedir
1240 1245
1241#ifndef DESKTOP_VERSION 1246#ifndef DESKTOP_VERSION
1242 QString tmp = readEnvPath("QPEDIR"); 1247 QString tmp = readEnvPath("QPEDIR");
1243 if (!tmp.isEmpty()) 1248 if (!tmp.isEmpty())
1244 kdedirList.append(tmp); 1249 kdedirList.append(tmp);
1245 1250
1246 tmp = readEnvPath("QTDIR"); 1251 tmp = readEnvPath("QTDIR");
1247 if (!tmp.isEmpty()) 1252 if (!tmp.isEmpty())
1248 kdedirList.append(tmp); 1253 kdedirList.append(tmp);
1249 1254
1250 tmp = readEnvPath("OPIEDIR"); 1255 tmp = readEnvPath("OPIEDIR");
1251 if (!tmp.isEmpty()) 1256 if (!tmp.isEmpty())
1252 kdedirList.append(tmp); 1257 kdedirList.append(tmp);
1253 1258
1254#endif 1259#endif
1255 1260
1256#ifdef __KDE_EXECPREFIX 1261#ifdef __KDE_EXECPREFIX
1257 QString execPrefix(__KDE_EXECPREFIX); 1262 QString execPrefix(__KDE_EXECPREFIX);
1258 if (execPrefix!="NONE") 1263 if (execPrefix!="NONE")
1259 kdedirList.append(execPrefix); 1264 kdedirList.append(execPrefix);
1260#endif 1265#endif
1261 1266
1262 QString localKdeDir; 1267 QString localKdeDir;
1263 1268
1264//US if (getuid()) 1269//US if (getuid())
1265 if (true) 1270 if (true)
1266 { 1271 {
1267 localKdeDir = readEnvPath("MICROKDEHOME"); 1272 localKdeDir = readEnvPath("MICROKDEHOME");
1268 if (!localKdeDir.isEmpty()) 1273 if (!localKdeDir.isEmpty())
1269 { 1274 {
1275#ifdef _WIN32_
1276 if (localKdeDir.at(localKdeDir.length()-1) != '\\')
1277 localKdeDir += '\\';
1278#else
1270 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1279 if (localKdeDir.at(localKdeDir.length()-1) != '/')
1271 localKdeDir += '/'; 1280 localKdeDir += '/';
1281#endif
1282 //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 );
1272 } 1283 }
1273 else 1284 else
1274 { 1285 {
1275 localKdeDir = QDir::homeDirPath() + "/kdepim/"; 1286 localKdeDir = QDir::homeDirPath() + "/kdepim/";
1276 } 1287 }
1277 } 1288 }
1278 else 1289 else
1279 { 1290 {
1280 // We treat root different to prevent root messing up the 1291 // We treat root different to prevent root messing up the
1281 // file permissions in the users home directory. 1292 // file permissions in the users home directory.
1282 localKdeDir = readEnvPath("MICROKDEROOTHOME"); 1293 localKdeDir = readEnvPath("MICROKDEROOTHOME");
1283 if (!localKdeDir.isEmpty()) 1294 if (!localKdeDir.isEmpty())
1284 { 1295 {
1285 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1296 if (localKdeDir.at(localKdeDir.length()-1) != '/')
1286 localKdeDir += '/'; 1297 localKdeDir += '/';
1287 } 1298 }
1288 else 1299 else
1289 { 1300 {
1290//US struct passwd *pw = getpwuid(0); 1301//US struct passwd *pw = getpwuid(0);
1291//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; 1302//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/";
1292 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); 1303 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed");
1293 } 1304 }
1294 1305
1295 } 1306 }
1296 1307
1297//US localKdeDir = appDir(); 1308//US localKdeDir = appDir();
1298 1309
1299//US 1310//US
1300// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); 1311// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1());
1301 if (localKdeDir != "-/") 1312 if (localKdeDir != "-/")
1302 { 1313 {
1303 localKdeDir = KShell::tildeExpand(localKdeDir); 1314 localKdeDir = KShell::tildeExpand(localKdeDir);
1304 addPrefix(localKdeDir); 1315 addPrefix(localKdeDir);
1305 } 1316 }
1306 1317
1307 for (QStringList::ConstIterator it = kdedirList.begin(); 1318 for (QStringList::ConstIterator it = kdedirList.begin();
1308 it != kdedirList.end(); it++) 1319 it != kdedirList.end(); it++)
1309 { 1320 {
1310 QString dir = KShell::tildeExpand(*it); 1321 QString dir = KShell::tildeExpand(*it);
1311 addPrefix(dir); 1322 addPrefix(dir);
1312 } 1323 }
1313 // end KDEDIRS 1324 // end KDEDIRS
1314 1325
1315 // begin XDG_CONFIG_XXX 1326 // begin XDG_CONFIG_XXX
1316 QStringList xdgdirList; 1327 QStringList xdgdirList;
1317 QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); 1328 QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS");
1318 if (!xdgdirs.isEmpty()) 1329 if (!xdgdirs.isEmpty())
1319 { 1330 {
1320 tokenize(xdgdirList, xdgdirs, ":"); 1331 tokenize(xdgdirList, xdgdirs, ":");
1321 } 1332 }
1322 else 1333 else
1323 { 1334 {
1324 xdgdirList.clear(); 1335 xdgdirList.clear();
1325 xdgdirList.append("/etc/xdg"); 1336 xdgdirList.append("/etc/xdg");
1326 } 1337 }
1327 1338
1328 QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); 1339 QString localXdgDir = readEnvPath("XDG_CONFIG_HOME");
1329 if (!localXdgDir.isEmpty()) 1340 if (!localXdgDir.isEmpty())
1330 { 1341 {
1331 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1342 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1332 localXdgDir += '/'; 1343 localXdgDir += '/';
1333 } 1344 }
1334 else 1345 else
1335 { 1346 {
1336//US if (getuid()) 1347//US if (getuid())
1337 if (true) 1348 if (true)
1338 { 1349 {
1339 localXdgDir = QDir::homeDirPath() + "/.config/"; 1350 localXdgDir = QDir::homeDirPath() + "/.config/";
1340 } 1351 }
1341 else 1352 else
1342 { 1353 {
1343//US struct passwd *pw = getpwuid(0); 1354//US struct passwd *pw = getpwuid(0);
1344//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; 1355//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/";
1345 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); 1356 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed");
1346 } 1357 }
1347 } 1358 }
1348 1359
1349 localXdgDir = KShell::tildeExpand(localXdgDir); 1360 localXdgDir = KShell::tildeExpand(localXdgDir);
1350 addXdgConfigPrefix(localXdgDir); 1361 addXdgConfigPrefix(localXdgDir);
1351 1362
1352 for (QStringList::ConstIterator it = xdgdirList.begin(); 1363 for (QStringList::ConstIterator it = xdgdirList.begin();
1353 it != xdgdirList.end(); it++) 1364 it != xdgdirList.end(); it++)
1354 { 1365 {
1355 QString dir = KShell::tildeExpand(*it); 1366 QString dir = KShell::tildeExpand(*it);
1356 addXdgConfigPrefix(dir); 1367 addXdgConfigPrefix(dir);
1357 } 1368 }
1358 // end XDG_CONFIG_XXX 1369 // end XDG_CONFIG_XXX
1359 1370
1360 // begin XDG_DATA_XXX 1371 // begin XDG_DATA_XXX
1361 xdgdirs = readEnvPath("XDG_DATA_DIRS"); 1372 xdgdirs = readEnvPath("XDG_DATA_DIRS");
1362 if (!xdgdirs.isEmpty()) 1373 if (!xdgdirs.isEmpty())
1363 { 1374 {
1364 tokenize(xdgdirList, xdgdirs, ":"); 1375 tokenize(xdgdirList, xdgdirs, ":");
1365 } 1376 }
1366 else 1377 else
1367 { 1378 {
1368 xdgdirList.clear(); 1379 xdgdirList.clear();
1369 for (QStringList::ConstIterator it = kdedirList.begin(); 1380 for (QStringList::ConstIterator it = kdedirList.begin();
1370 it != kdedirList.end(); it++) 1381 it != kdedirList.end(); it++)
1371 { 1382 {
1372 QString dir = *it; 1383 QString dir = *it;
1373 if (dir.at(dir.length()-1) != '/') 1384 if (dir.at(dir.length()-1) != '/')
1374 dir += '/'; 1385 dir += '/';
1375 xdgdirList.append(dir+"share/"); 1386 xdgdirList.append(dir+"share/");
1376 } 1387 }
1377 1388
1378 xdgdirList.append("/usr/local/share/"); 1389 xdgdirList.append("/usr/local/share/");
1379 xdgdirList.append("/usr/share/"); 1390 xdgdirList.append("/usr/share/");
1380 } 1391 }
1381 1392
1382 localXdgDir = readEnvPath("XDG_DATA_HOME"); 1393 localXdgDir = readEnvPath("XDG_DATA_HOME");
1383 if (!localXdgDir.isEmpty()) 1394 if (!localXdgDir.isEmpty())
1384 { 1395 {
1385 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1396 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1386 localXdgDir += '/'; 1397 localXdgDir += '/';
1387 } 1398 }
1388 else 1399 else
1389 { 1400 {
1390//US if (getuid()) 1401//US if (getuid())
1391 if (true) 1402 if (true)
1392 { 1403 {
1393 localXdgDir = QDir::homeDirPath() + "/.local/share/"; 1404 localXdgDir = QDir::homeDirPath() + "/.local/share/";
1394 } 1405 }
1395 else 1406 else
1396 { 1407 {
1397//US struct passwd *pw = getpwuid(0); 1408//US struct passwd *pw = getpwuid(0);
1398//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; 1409//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/";
1399 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); 1410 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed");
1400 } 1411 }
1401 } 1412 }
1402 1413
1403 localXdgDir = KShell::tildeExpand(localXdgDir); 1414 localXdgDir = KShell::tildeExpand(localXdgDir);
1404 addXdgDataPrefix(localXdgDir); 1415 addXdgDataPrefix(localXdgDir);
1405 1416
1406 for (QStringList::ConstIterator it = xdgdirList.begin(); 1417 for (QStringList::ConstIterator it = xdgdirList.begin();
1407 it != xdgdirList.end(); it++) 1418 it != xdgdirList.end(); it++)
1408 { 1419 {
1409 QString dir = KShell::tildeExpand(*it); 1420 QString dir = KShell::tildeExpand(*it);
1410 1421
1411 addXdgDataPrefix(dir); 1422 addXdgDataPrefix(dir);
1412 } 1423 }
1413 // end XDG_DATA_XXX 1424 // end XDG_DATA_XXX
1414 1425
1415 1426
1416 uint index = 0; 1427 uint index = 0;
1417 while (types[index] != 0) { 1428 while (types[index] != 0) {
1418 addResourceType(types[index], kde_default(types[index])); 1429 addResourceType(types[index], kde_default(types[index]));
1419 index++; 1430 index++;
1420 } 1431 }
1421 1432
1422 addResourceDir("home", QDir::homeDirPath()); 1433 addResourceDir("home", QDir::homeDirPath());
1423} 1434}
1424 1435
1425void KStandardDirs::checkConfig() const 1436void KStandardDirs::checkConfig() const
1426{ 1437{
1427/*US 1438/*US
1428 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) 1439 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config)
1429 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); 1440 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config);
1430*/ 1441*/
1431 if (!addedCustoms && KGlobal::config()) 1442 if (!addedCustoms && KGlobal::config())
1432 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); 1443 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config());
1433} 1444}
1434 1445
1435bool KStandardDirs::addCustomized(KConfig *config) 1446bool KStandardDirs::addCustomized(KConfig *config)
1436{ 1447{
1437 if (addedCustoms) // there are already customized entries 1448 if (addedCustoms) // there are already customized entries
1438 return false; // we just quite and hope they are the right ones 1449 return false; // we just quite and hope they are the right ones
1439 1450
1440 // save the numbers of config directories. If this changes, 1451 // save the numbers of config directories. If this changes,
1441 // we will return true to give KConfig a chance to reparse 1452 // we will return true to give KConfig a chance to reparse
1442 uint configdirs = resourceDirs("config").count(); 1453 uint configdirs = resourceDirs("config").count();
1443 1454
1444 // reading the prefixes in 1455 // reading the prefixes in
1445 QString oldGroup = config->group(); 1456 QString oldGroup = config->group();
1446 config->setGroup("Directories"); 1457 config->setGroup("Directories");
1447 1458
1448 QStringList list; 1459 QStringList list;
1449 QStringList::ConstIterator it; 1460 QStringList::ConstIterator it;
1450 list = config->readListEntry("prefixes"); 1461 list = config->readListEntry("prefixes");
1451 for (it = list.begin(); it != list.end(); it++) 1462 for (it = list.begin(); it != list.end(); it++)
1452 addPrefix(*it); 1463 addPrefix(*it);
1453 1464
1454 // iterating over all entries in the group Directories 1465 // iterating over all entries in the group Directories
1455 // to find entries that start with dir_$type 1466 // to find entries that start with dir_$type
1456/*US 1467/*US
1457 QMap<QString, QString> entries = config->entryMap("Directories"); 1468 QMap<QString, QString> entries = config->entryMap("Directories");
1458 1469
1459 QMap<QString, QString>::ConstIterator it2; 1470 QMap<QString, QString>::ConstIterator it2;
1460 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1471 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1461 { 1472 {
1462 QString key = it2.key(); 1473 QString key = it2.key();
1463 if (key.left(4) == "dir_") { 1474 if (key.left(4) == "dir_") {
1464 // generate directory list, there may be more than 1. 1475 // generate directory list, there may be more than 1.
1465 QStringList dirs = QStringList::split(',', *it2); 1476 QStringList dirs = QStringList::split(',', *it2);
1466 QStringList::Iterator sIt(dirs.begin()); 1477 QStringList::Iterator sIt(dirs.begin());
1467 QString resType = key.mid(4, key.length()); 1478 QString resType = key.mid(4, key.length());
1468 for (; sIt != dirs.end(); ++sIt) { 1479 for (; sIt != dirs.end(); ++sIt) {
1469 addResourceDir(resType.latin1(), *sIt); 1480 addResourceDir(resType.latin1(), *sIt);
1470 } 1481 }
1471 } 1482 }
1472 } 1483 }
1473 1484
1474 // Process KIOSK restrictions. 1485 // Process KIOSK restrictions.
1475 config->setGroup("KDE Resource Restrictions"); 1486 config->setGroup("KDE Resource Restrictions");
1476 entries = config->entryMap("KDE Resource Restrictions"); 1487 entries = config->entryMap("KDE Resource Restrictions");
1477 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1488 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1478 { 1489 {
1479 QString key = it2.key(); 1490 QString key = it2.key();
1480 if (!config->readBoolEntry(key, true)) 1491 if (!config->readBoolEntry(key, true))
1481 { 1492 {
1482 d->restrictionsActive = true; 1493 d->restrictionsActive = true;
1483 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do 1494 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do
1484 dircache.remove(key.latin1()); 1495 dircache.remove(key.latin1());
1485 } 1496 }
1486 } 1497 }
1487*/ 1498*/
1488 // save it for future calls - that will return 1499 // save it for future calls - that will return
1489 addedCustoms = true; 1500 addedCustoms = true;
1490 config->setGroup(oldGroup); 1501 config->setGroup(oldGroup);
1491 1502
1492 // return true if the number of config dirs changed 1503 // return true if the number of config dirs changed
1493 return (resourceDirs("config").count() != configdirs); 1504 return (resourceDirs("config").count() != configdirs);
1494} 1505}
1495 1506
1496QString KStandardDirs::localkdedir() const 1507QString KStandardDirs::localkdedir() const
1497{ 1508{
1498 // Return the prefix to use for saving 1509 // Return the prefix to use for saving
1499 return prefixes.first(); 1510 return prefixes.first();
1500} 1511}
1501 1512
1502QString KStandardDirs::localxdgdatadir() const 1513QString KStandardDirs::localxdgdatadir() const
1503{ 1514{
1504 // Return the prefix to use for saving 1515 // Return the prefix to use for saving
1505 return d->xdgdata_prefixes.first(); 1516 return d->xdgdata_prefixes.first();
1506} 1517}
1507 1518
1508QString KStandardDirs::localxdgconfdir() const 1519QString KStandardDirs::localxdgconfdir() const
1509{ 1520{
1510 // Return the prefix to use for saving 1521 // Return the prefix to use for saving
1511 return d->xdgconf_prefixes.first(); 1522 return d->xdgconf_prefixes.first();
1512} 1523}
1513 1524
1514void KStandardDirs::setAppDir( const QString &appDir ) 1525void KStandardDirs::setAppDir( const QString &appDir )
1515{ 1526{
1516 mAppDir = appDir; 1527 mAppDir = appDir;
1517 1528
1518 if ( mAppDir.right( 1 ) != "/" ) 1529 if ( mAppDir.right( 1 ) != "/" )
1519 mAppDir += "/"; 1530 mAppDir += "/";
1520} 1531}
1521 1532
1522QString KStandardDirs::appDir() 1533QString KStandardDirs::appDir()
1523{ 1534{
1524 return mAppDir; 1535 return mAppDir;
1525} 1536}
1526 1537
1527// just to make code more readable without macros 1538// just to make code more readable without macros
1528QString locate( const char *type, 1539QString locate( const char *type,
1529 const QString& filename/*US , const KInstance* inst*/ ) 1540 const QString& filename/*US , const KInstance* inst*/ )
1530{ 1541{
1531//US return inst->dirs()->findResource(type, filename); 1542//US return inst->dirs()->findResource(type, filename);
1532 return KGlobal::dirs()->findResource(type, filename); 1543 return KGlobal::dirs()->findResource(type, filename);
1533} 1544}
1534 1545
1535QString locateLocal( const char *type, 1546QString locateLocal( const char *type,
1536 const QString& filename/*US , const KInstance* inst*/ ) 1547 const QString& filename/*US , const KInstance* inst*/ )
1537{ 1548{
1538 1549
1539 QString path = locateLocal(type, filename, true /*US, inst*/); 1550 QString path = locateLocal(type, filename, true /*US, inst*/);
1540 1551
1541 1552
1542/* 1553/*
1543 static int ccc = 0; 1554 static int ccc = 0;
1544 ++ccc; 1555 ++ccc;
1545 if ( ccc > 13 ) 1556 if ( ccc > 13 )
1546 abort(); 1557 abort();
1547*/ 1558*/
1548 qDebug("locatelocal: %s" , path.latin1()); 1559 qDebug("locatelocal: %s" , path.latin1());
1549 return path; 1560 return path;
1550 1561
1551/*US why do we put all files into one directory. It is quit complicated. 1562/*US why do we put all files into one directory. It is quit complicated.
1552why not staying with the original directorystructure ? 1563why not staying with the original directorystructure ?
1553 1564
1554 1565
1555 QString escapedFilename = filename; 1566 QString escapedFilename = filename;
1556 escapedFilename.replace( QRegExp( "/" ), "_" ); 1567 escapedFilename.replace( QRegExp( "/" ), "_" );
1557 1568
1558 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename; 1569 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename;
1559 1570
1560 kdDebug() << "locate: '" << path << "'" << endl; 1571 kdDebug() << "locate: '" << path << "'" << endl;
1561 qDebug("locate: %s" , path.latin1()); 1572 qDebug("locate: %s" , path.latin1());
1562 return path; 1573 return path;
1563*/ 1574*/
1564//US so my proposal is this: 1575//US so my proposal is this:
1565 1576
1566// QString escapedFilename = filename; 1577// QString escapedFilename = filename;
1567// escapedFilename.replace( QRegExp( "/" ), "_" ); 1578// escapedFilename.replace( QRegExp( "/" ), "_" );
1568 1579
1569#if 0 1580#if 0
1570#ifdef _WIN32_ 1581#ifdef _WIN32_
1571 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename); 1582 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename);
1572#else 1583#else
1573 QString path = KStandardDirs::appDir() + type + "/" + filename; 1584 QString path = KStandardDirs::appDir() + type + "/" + filename;
1574#endif 1585#endif
1575 1586
1576 //US Create the containing dir if needed 1587 //US Create the containing dir if needed
1577 QFileInfo fi ( path ); 1588 QFileInfo fi ( path );
1578 1589
1579 // QString dir=pathurl.directory(); 1590 // QString dir=pathurl.directory();
1580 //QMessageBox::information( 0,"path", path, 1 ); 1591 //QMessageBox::information( 0,"path", path, 1 );
1581 1592
1582#ifdef _WIN32_ 1593#ifdef _WIN32_
1583 KStandardDirs::makeDir(path); 1594 KStandardDirs::makeDir(path);
1584#else 1595#else
1585 KStandardDirs::makeDir(fi.dirPath( true )); 1596 KStandardDirs::makeDir(fi.dirPath( true ));
1586#endif 1597#endif
1587 1598
1588 qDebug("locate22: %s" , path.latin1()); 1599 qDebug("locate22: %s" , path.latin1());
1589 return path; 1600 return path;
1590 1601
1591#endif 1602#endif
1592 1603
1593} 1604}
1594 1605
1595QString locateLocal( const char *type, 1606QString locateLocal( const char *type,
1596 const QString& filename, bool createDir/*US , const KInstance* inst*/ ) 1607 const QString& filename, bool createDir/*US , const KInstance* inst*/ )
1597{ 1608{
1598 // try to find slashes. If there are some, we have to 1609 // try to find slashes. If there are some, we have to
1599 // create the subdir first 1610 // create the subdir first
1600 int slash = filename.findRev('/')+1; 1611 int slash = filename.findRev('/')+1;
1601 if (!slash) // only one filename 1612 if (!slash) // only one filename
1602 //USreturn inst->dirs()->saveLocation(type, QString::null, createDir) + filename; 1613 //USreturn inst->dirs()->saveLocation(type, QString::null, createDir) + filename;
1603 return KGlobal::dirs()->saveLocation(type, QString::null, createDir) + filename; 1614 return KGlobal::dirs()->saveLocation(type, QString::null, createDir) + filename;
1604 1615
1605 // split path from filename 1616 // split path from filename
1606 QString dir = filename.left(slash); 1617 QString dir = filename.left(slash);
1607 QString file = filename.mid(slash); 1618 QString file = filename.mid(slash);
1608//US return inst->dirs()->saveLocation(type, dir, createDir) + file; 1619//US return inst->dirs()->saveLocation(type, dir, createDir) + file;
1609 return KGlobal::dirs()->saveLocation(type, dir, createDir) + file; 1620 return KGlobal::dirs()->saveLocation(type, dir, createDir) + file;
1610 1621
1611 // *************************************************************** 1622 // ***************************************************************
1612#if 0 1623#if 0
1613 1624
1614/*US why do we put all files into one directory. It is quit complicated. 1625/*US why do we put all files into one directory. It is quit complicated.
1615why not staying with the original directorystructure ? 1626why not staying with the original directorystructure ?
1616 1627
1617 1628
1618 QString escapedFilename = filename; 1629 QString escapedFilename = filename;
1619 escapedFilename.replace( QRegExp( "/" ), "_" ); 1630 escapedFilename.replace( QRegExp( "/" ), "_" );
1620 1631
1621 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename; 1632 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename;
1622 1633
1623 kdDebug() << "locate: '" << path << "'" << endl; 1634 kdDebug() << "locate: '" << path << "'" << endl;
1624 qDebug("locate: %s" , path.latin1()); 1635 qDebug("locate: %s" , path.latin1());
1625 return path; 1636 return path;
1626*/ 1637*/
1627//US so my proposal is this: 1638//US so my proposal is this:
1628 1639
1629// QString escapedFilename = filename; 1640// QString escapedFilename = filename;
1630// escapedFilename.replace( QRegExp( "/" ), "_" ); 1641// escapedFilename.replace( QRegExp( "/" ), "_" );
1631 1642
1632#ifdef _WIN32_ 1643#ifdef _WIN32_
1633 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename); 1644 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename);
1634#else 1645#else
1635 QString path = KStandardDirs::appDir() + type + "/" + filename; 1646 QString path = KStandardDirs::appDir() + type + "/" + filename;
1636#endif 1647#endif
1637 1648
1638 //US Create the containing dir if needed 1649 //US Create the containing dir if needed
1639 KURL pathurl; 1650 KURL pathurl;
1640 pathurl.setPath(path); 1651 pathurl.setPath(path);
1641 QString dir=pathurl.directory(); 1652 QString dir=pathurl.directory();
1642 //QMessageBox::information( 0,"path", path, 1 ); 1653 //QMessageBox::information( 0,"path", path, 1 );
1643#ifdef _WIN32_ 1654#ifdef _WIN32_
1644 KStandardDirs::makeDir(path); 1655 KStandardDirs::makeDir(path);
1645#else 1656#else
1646 KStandardDirs::makeDir(dir); 1657 KStandardDirs::makeDir(dir);
1647#endif 1658#endif
1648 1659
1649 return path; 1660 return path;
1650#endif 1661#endif
1651} 1662}