summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-04 10:38:45 (UTC)
committer zautrix <zautrix>2004-10-04 10:38:45 (UTC)
commit01b5806c61deb8368f8f454fdec1c4767c73a840 (patch) (unidiff)
treef2546296a50444d02d2a74f6bf55fd57b0504ebc /korganizer
parent743f44c45534a6e1df17ddc7b5f3c62b73921455 (diff)
downloadkdepimpi-01b5806c61deb8368f8f454fdec1c4767c73a840.zip
kdepimpi-01b5806c61deb8368f8f454fdec1c4767c73a840.tar.gz
kdepimpi-01b5806c61deb8368f8f454fdec1c4767c73a840.tar.bz2
sync fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 8e2f956..10cb2a2 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1095,1508 +1095,1510 @@ void MainWindow::slotSyncMenu( int action )
1095 mBlockSaveFlag = false; 1095 mBlockSaveFlag = false;
1096} 1096}
1097void MainWindow::setDefaultPreferences() 1097void MainWindow::setDefaultPreferences()
1098{ 1098{
1099 KOPrefs *p = KOPrefs::instance(); 1099 KOPrefs *p = KOPrefs::instance();
1100 1100
1101 p->mCompactDialogs = true; 1101 p->mCompactDialogs = true;
1102 p->mConfirm = true; 1102 p->mConfirm = true;
1103 // p->mEnableQuickTodo = false; 1103 // p->mEnableQuickTodo = false;
1104} 1104}
1105 1105
1106QString MainWindow::resourcePath() 1106QString MainWindow::resourcePath()
1107{ 1107{
1108 return KGlobal::iconLoader()->iconPath(); 1108 return KGlobal::iconLoader()->iconPath();
1109} 1109}
1110 1110
1111void MainWindow::displayText( QString text ,QString cap ) 1111void MainWindow::displayText( QString text ,QString cap )
1112{ 1112{
1113 QDialog dia( this, "name", true ); ; 1113 QDialog dia( this, "name", true ); ;
1114 dia.setCaption( cap ); 1114 dia.setCaption( cap );
1115 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1115 QVBoxLayout* lay = new QVBoxLayout( &dia );
1116 lay->setSpacing( 3 ); 1116 lay->setSpacing( 3 );
1117 lay->setMargin( 3 ); 1117 lay->setMargin( 3 );
1118 QTextBrowser tb ( &dia ); 1118 QTextBrowser tb ( &dia );
1119 lay->addWidget( &tb ); 1119 lay->addWidget( &tb );
1120 tb.setText( text ); 1120 tb.setText( text );
1121#ifdef DESKTOP_VERSION 1121#ifdef DESKTOP_VERSION
1122 dia.resize( 640, 480); 1122 dia.resize( 640, 480);
1123#else 1123#else
1124 dia.showMaximized(); 1124 dia.showMaximized();
1125#endif 1125#endif
1126 dia.exec(); 1126 dia.exec();
1127} 1127}
1128void MainWindow::displayFile( QString fn, QString cap ) 1128void MainWindow::displayFile( QString fn, QString cap )
1129{ 1129{
1130 QString fileName = resourcePath() + fn; 1130 QString fileName = resourcePath() + fn;
1131 QString text; 1131 QString text;
1132 QFile file( fileName ); 1132 QFile file( fileName );
1133 if (!file.open( IO_ReadOnly ) ) { 1133 if (!file.open( IO_ReadOnly ) ) {
1134 return ; 1134 return ;
1135 1135
1136 } 1136 }
1137 QTextStream ts( &file ); 1137 QTextStream ts( &file );
1138 text = ts.read(); 1138 text = ts.read();
1139 file.close(); 1139 file.close();
1140 displayText( text, cap); 1140 displayText( text, cap);
1141} 1141}
1142void MainWindow::features() 1142void MainWindow::features()
1143{ 1143{
1144 1144
1145 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1145 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1146} 1146}
1147 1147
1148void MainWindow::usertrans() 1148void MainWindow::usertrans()
1149{ 1149{
1150 1150
1151 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1151 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1152} 1152}
1153 1153
1154void MainWindow::synchowto() 1154void MainWindow::synchowto()
1155{ 1155{
1156#if 0 1156#if 0
1157 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1157 QPtrList<Incidence> er = mCalendar->rawIncidences();
1158 Incidence* inR = er.first(); 1158 Incidence* inR = er.first();
1159 VCalFormat vf; 1159 VCalFormat vf;
1160 QString strout; 1160 QString strout;
1161 while ( inR ) { 1161 while ( inR ) {
1162 if ( inR->type() == "Todo" ) 1162 if ( inR->type() == "Todo" )
1163 strout = vf.todoToString( (Todo *) inR ); 1163 strout = vf.todoToString( (Todo *) inR );
1164 if ( inR->type() == "Event" ) 1164 if ( inR->type() == "Event" )
1165 strout = vf.eventToString( (Event *) inR ); 1165 strout = vf.eventToString( (Event *) inR );
1166 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1166 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1167 inR = er.next(); 1167 inR = er.next();
1168 } 1168 }
1169#endif 1169#endif
1170 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1170 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1171} 1171}
1172void MainWindow::faq() 1172void MainWindow::faq()
1173{ 1173{
1174 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1174 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1175 1175
1176} 1176}
1177void MainWindow::whatsNew() 1177void MainWindow::whatsNew()
1178{ 1178{
1179 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1179 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1180 1180
1181} 1181}
1182void MainWindow::licence() 1182void MainWindow::licence()
1183{ 1183{
1184 KApplication::showLicence(); 1184 KApplication::showLicence();
1185 1185
1186} 1186}
1187void MainWindow::about() 1187void MainWindow::about()
1188{ 1188{
1189 QString version; 1189 QString version;
1190#include <../version> 1190#include <../version>
1191 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1191 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1192 i18n("KOrganizer/Platform-independent\n") + 1192 i18n("KOrganizer/Platform-independent\n") +
1193 "(KO/Pi) " + version + " - " + 1193 "(KO/Pi) " + version + " - " +
1194 1194
1195#ifdef DESKTOP_VERSION 1195#ifdef DESKTOP_VERSION
1196 i18n("Desktop Edition\n") + 1196 i18n("Desktop Edition\n") +
1197#else 1197#else
1198 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1198 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1199#endif 1199#endif
1200 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") ); 1200 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") );
1201} 1201}
1202void MainWindow::keyBindings() 1202void MainWindow::keyBindings()
1203{ 1203{
1204 QString cap = i18n("Key bindings KOrganizer/Pi"); 1204 QString cap = i18n("Key bindings KOrganizer/Pi");
1205 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1205 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1206 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1206 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1207 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1207 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1208 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1208 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1209 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1209 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1210 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1210 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1211 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1211 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1212 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1212 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1213 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1213 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1214 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1214 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1215 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1215 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1216 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1216 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1217 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1217 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1218 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1218 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1219 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1219 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1220 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1220 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1221 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1221 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1222 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1222 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1223 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1223 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1224 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1224 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1225 i18n("<p><h3>In agenda view:</h3></p>\n") + 1225 i18n("<p><h3>In agenda view:</h3></p>\n") +
1226 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1226 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1227 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1227 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1228 i18n("<p><h3>In todo view:</h3></p>\n") + 1228 i18n("<p><h3>In todo view:</h3></p>\n") +
1229 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1229 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1230 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1230 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1231 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1231 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1232 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1232 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1233 i18n("<p><h3>In list view:</h3></p>\n") + 1233 i18n("<p><h3>In list view:</h3></p>\n") +
1234 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1234 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1235 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1235 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1236 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1236 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1237 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1237 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1238 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1238 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1239 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1239 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1240 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1240 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1241 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1241 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1242 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1242 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1243 i18n("<p><b>E</b>: Edit item</p>\n") + 1243 i18n("<p><b>E</b>: Edit item</p>\n") +
1244 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1244 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1245 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1245 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1246 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1246 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1247 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1247 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1248 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1248 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1249 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1249 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1250 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1250 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1251 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1251 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1252 i18n("<p><b>White</b>: Item readonly</p>\n"); 1252 i18n("<p><b>White</b>: Item readonly</p>\n");
1253 displayText( text, cap); 1253 displayText( text, cap);
1254 1254
1255} 1255}
1256void MainWindow::aboutAutoSaving() 1256void MainWindow::aboutAutoSaving()
1257{ 1257{
1258 QMessageBox* msg; 1258 QMessageBox* msg;
1259 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1259 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1260 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, 1260 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,
1261 QMessageBox::Ok, 1261 QMessageBox::Ok,
1262 QMessageBox::NoButton, 1262 QMessageBox::NoButton,
1263 QMessageBox::NoButton); 1263 QMessageBox::NoButton);
1264 msg->exec(); 1264 msg->exec();
1265 delete msg; 1265 delete msg;
1266 1266
1267 1267
1268} 1268}
1269void MainWindow::aboutKnownBugs() 1269void MainWindow::aboutKnownBugs()
1270{ 1270{
1271 QMessageBox* msg; 1271 QMessageBox* msg;
1272 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1272 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1273 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")+ 1273 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")+
1274 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1274 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1275 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1275 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1276 i18n("\nor report them in the bugtracker on\n") + 1276 i18n("\nor report them in the bugtracker on\n") +
1277 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1277 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1278 QMessageBox::NoIcon, 1278 QMessageBox::NoIcon,
1279 QMessageBox::Ok, 1279 QMessageBox::Ok,
1280 QMessageBox::NoButton, 1280 QMessageBox::NoButton,
1281 QMessageBox::NoButton); 1281 QMessageBox::NoButton);
1282 msg->exec(); 1282 msg->exec();
1283 delete msg; 1283 delete msg;
1284 1284
1285} 1285}
1286 1286
1287QString MainWindow::defaultFileName() 1287QString MainWindow::defaultFileName()
1288{ 1288{
1289 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1289 return locateLocal( "data", "korganizer/mycalendar.ics" );
1290} 1290}
1291 1291
1292void MainWindow::processIncidenceSelection( Incidence *incidence ) 1292void MainWindow::processIncidenceSelection( Incidence *incidence )
1293{ 1293{
1294 if ( !incidence ) { 1294 if ( !incidence ) {
1295 enableIncidenceActions( false ); 1295 enableIncidenceActions( false );
1296 1296
1297 mNewSubTodoAction->setEnabled( false ); 1297 mNewSubTodoAction->setEnabled( false );
1298 setCaptionToDates(); 1298 setCaptionToDates();
1299 return; 1299 return;
1300 1300
1301 } 1301 }
1302 1302
1303 //KGlobal::locale()->formatDateTime(nextA, true); 1303 //KGlobal::locale()->formatDateTime(nextA, true);
1304 QString startString = ""; 1304 QString startString = "";
1305 if ( incidence->type() != "Todo" ) { 1305 if ( incidence->type() != "Todo" ) {
1306 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1306 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1307 if ( incidence->doesFloat() ) { 1307 if ( incidence->doesFloat() ) {
1308 startString += ": "+incidence->dtStartDateStr( true ); 1308 startString += ": "+incidence->dtStartDateStr( true );
1309 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1309 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1310 1310
1311 } else { 1311 } else {
1312 startString = ": "+incidence->dtStartStr(true); 1312 startString = ": "+incidence->dtStartStr(true);
1313 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1313 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1314 1314
1315 } 1315 }
1316 1316
1317 } else { 1317 } else {
1318 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1318 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1319 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1319 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1320 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1320 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1321 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1321 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1322 } 1322 }
1323 1323
1324 } 1324 }
1325 else 1325 else
1326 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1326 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1327 if ( !incidence->location().isEmpty() ) 1327 if ( !incidence->location().isEmpty() )
1328 startString += " (" +incidence->location()+")"; 1328 startString += " (" +incidence->location()+")";
1329 setCaption( incidence->summary()+startString); 1329 setCaption( incidence->summary()+startString);
1330 1330
1331 enableIncidenceActions( true ); 1331 enableIncidenceActions( true );
1332 1332
1333 if ( incidence->type() == "Event" ) { 1333 if ( incidence->type() == "Event" ) {
1334 mShowAction->setText( i18n("Show Event...") ); 1334 mShowAction->setText( i18n("Show Event...") );
1335 mEditAction->setText( i18n("Edit Event...") ); 1335 mEditAction->setText( i18n("Edit Event...") );
1336 mDeleteAction->setText( i18n("Delete Event...") ); 1336 mDeleteAction->setText( i18n("Delete Event...") );
1337 1337
1338 mNewSubTodoAction->setEnabled( false ); 1338 mNewSubTodoAction->setEnabled( false );
1339 } else if ( incidence->type() == "Todo" ) { 1339 } else if ( incidence->type() == "Todo" ) {
1340 mShowAction->setText( i18n("Show Todo...") ); 1340 mShowAction->setText( i18n("Show Todo...") );
1341 mEditAction->setText( i18n("Edit Todo...") ); 1341 mEditAction->setText( i18n("Edit Todo...") );
1342 mDeleteAction->setText( i18n("Delete Todo...") ); 1342 mDeleteAction->setText( i18n("Delete Todo...") );
1343 1343
1344 mNewSubTodoAction->setEnabled( true ); 1344 mNewSubTodoAction->setEnabled( true );
1345 } else { 1345 } else {
1346 mShowAction->setText( i18n("Show...") ); 1346 mShowAction->setText( i18n("Show...") );
1347 mShowAction->setText( i18n("Edit...") ); 1347 mShowAction->setText( i18n("Edit...") );
1348 mShowAction->setText( i18n("Delete...") ); 1348 mShowAction->setText( i18n("Delete...") );
1349 1349
1350 mNewSubTodoAction->setEnabled( false ); 1350 mNewSubTodoAction->setEnabled( false );
1351 } 1351 }
1352} 1352}
1353 1353
1354void MainWindow::enableIncidenceActions( bool enabled ) 1354void MainWindow::enableIncidenceActions( bool enabled )
1355{ 1355{
1356 mShowAction->setEnabled( enabled ); 1356 mShowAction->setEnabled( enabled );
1357 mEditAction->setEnabled( enabled ); 1357 mEditAction->setEnabled( enabled );
1358 mDeleteAction->setEnabled( enabled ); 1358 mDeleteAction->setEnabled( enabled );
1359} 1359}
1360 1360
1361void MainWindow::importOL() 1361void MainWindow::importOL()
1362{ 1362{
1363#ifdef _WIN32_ 1363#ifdef _WIN32_
1364 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1364 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1365 id->exec(); 1365 id->exec();
1366 delete id; 1366 delete id;
1367 mView->updateView(); 1367 mView->updateView();
1368#endif 1368#endif
1369} 1369}
1370void MainWindow::importBday() 1370void MainWindow::importBday()
1371{ 1371{
1372 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1372 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1373 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1373 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1374 i18n("Import!"), i18n("Cancel"), 0, 1374 i18n("Import!"), i18n("Cancel"), 0,
1375 0, 1 ); 1375 0, 1 );
1376 if ( result == 0 ) { 1376 if ( result == 0 ) {
1377 mView->importBday(); 1377 mView->importBday();
1378 1378
1379 } 1379 }
1380 1380
1381 1381
1382} 1382}
1383void MainWindow::importQtopia() 1383void MainWindow::importQtopia()
1384{ 1384{
1385#ifndef DESKTOP_VERSION 1385#ifndef DESKTOP_VERSION
1386 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1386 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1387 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"), 1387 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"),
1388 i18n("Import!"), i18n("Cancel"), 0, 1388 i18n("Import!"), i18n("Cancel"), 0,
1389 0, 1 ); 1389 0, 1 );
1390 if ( result == 0 ) { 1390 if ( result == 0 ) {
1391 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1391 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1392 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1392 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1393 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1393 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1394 mView->importQtopia( categories, datebook, todolist ); 1394 mView->importQtopia( categories, datebook, todolist );
1395 } 1395 }
1396#else 1396#else
1397 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1397 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1398 i18n("Not supported \non desktop!\n"), 1398 i18n("Not supported \non desktop!\n"),
1399 i18n("Ok"), i18n("Cancel"), 0, 1399 i18n("Ok"), i18n("Cancel"), 0,
1400 0, 1 ); 1400 0, 1 );
1401 1401
1402#endif 1402#endif
1403} 1403}
1404 1404
1405void MainWindow::saveOnClose() 1405void MainWindow::saveOnClose()
1406{ 1406{
1407 KOPrefs *p = KOPrefs::instance(); 1407 KOPrefs *p = KOPrefs::instance();
1408 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1408 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1409 p->mToolBarUp = iconToolBar->x() > width()/2 || 1409 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1410 iconToolBar->y() > height()/2; 1410 iconToolBar->y() > height()/2;
1411 mView->writeSettings(); 1411 mView->writeSettings();
1412 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1412 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1413 save(); 1413 save();
1414} 1414}
1415void MainWindow::slotModifiedChanged( bool changed ) 1415void MainWindow::slotModifiedChanged( bool changed )
1416{ 1416{
1417 if ( mBlockAtStartup ) 1417 if ( mBlockAtStartup )
1418 return; 1418 return;
1419 int msec; 1419 int msec;
1420 // we store the changes after 1 minute, 1420 // we store the changes after 1 minute,
1421 // and for safety reasons after 10 minutes again 1421 // and for safety reasons after 10 minutes again
1422 if ( !mBlockSaveFlag ) 1422 if ( !mBlockSaveFlag )
1423 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1423 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1424 else 1424 else
1425 msec = 1000 * 600; 1425 msec = 1000 * 600;
1426 mSaveTimer.start( msec, true ); // 1 minute 1426 mSaveTimer.start( msec, true ); // 1 minute
1427 qDebug("KO: Saving File in %d secs!", msec/1000); 1427 qDebug("KO: Saving File in %d secs!", msec/1000);
1428 mCalendarModifiedFlag = true; 1428 mCalendarModifiedFlag = true;
1429} 1429}
1430void MainWindow::save() 1430void MainWindow::save()
1431{ 1431{
1432 if ( mBlockSaveFlag ) 1432 if ( mBlockSaveFlag )
1433 return; 1433 return;
1434 bool store = mBlockSaveFlag; 1434 bool store = mBlockSaveFlag;
1435 mBlockSaveFlag = true; 1435 mBlockSaveFlag = true;
1436 if ( mView->checkFileVersion( defaultFileName()) ) { 1436 if ( mView->checkFileVersion( defaultFileName()) ) {
1437 1437
1438 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1438 QTime neededSaveTime = QDateTime::currentDateTime().time();
1439 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1439 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1440 qDebug("KO: Start saving data to file!"); 1440 qDebug("KO: Start saving data to file!");
1441 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1441 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1442 mView->saveCalendar( defaultFileName() ); 1442 mView->saveCalendar( defaultFileName() );
1443 1443
1444 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1444 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1445 mView->watchSavedFile(); 1445 mView->watchSavedFile();
1446 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1446 qDebug("KO: Needed %d ms for saving.",msNeeded );
1447 QString savemes; 1447 QString savemes;
1448 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1448 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1449 setCaption(savemes); 1449 setCaption(savemes);
1450 } else 1450 } else
1451 setCaption(i18n("Saving cancelled!")); 1451 setCaption(i18n("Saving cancelled!"));
1452 mCalendarModifiedFlag = false; 1452 mCalendarModifiedFlag = false;
1453 mBlockSaveFlag = store; 1453 mBlockSaveFlag = store;
1454} 1454}
1455 1455
1456void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1456void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1457{ 1457{
1458 if ( !e->isAutoRepeat() ) { 1458 if ( !e->isAutoRepeat() ) {
1459 mFlagKeyPressed = false; 1459 mFlagKeyPressed = false;
1460 } 1460 }
1461} 1461}
1462void MainWindow::keyPressEvent ( QKeyEvent * e ) 1462void MainWindow::keyPressEvent ( QKeyEvent * e )
1463{ 1463{
1464 qApp->processEvents(); 1464 qApp->processEvents();
1465 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1465 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1466 e->ignore(); 1466 e->ignore();
1467 // qDebug(" ignore %d",e->isAutoRepeat() ); 1467 // qDebug(" ignore %d",e->isAutoRepeat() );
1468 return; 1468 return;
1469 } 1469 }
1470 if (! e->isAutoRepeat() ) 1470 if (! e->isAutoRepeat() )
1471 mFlagKeyPressed = true; 1471 mFlagKeyPressed = true;
1472 KOPrefs *p = KOPrefs::instance(); 1472 KOPrefs *p = KOPrefs::instance();
1473 bool showSelectedDates = false; 1473 bool showSelectedDates = false;
1474 int size; 1474 int size;
1475 int pro = 0; 1475 int pro = 0;
1476 //qDebug("MainWindow::keyPressEvent "); 1476 //qDebug("MainWindow::keyPressEvent ");
1477 switch ( e->key() ) { 1477 switch ( e->key() ) {
1478 case Qt::Key_Right: 1478 case Qt::Key_Right:
1479 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1479 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1480 mView->goNextMonth(); 1480 mView->goNextMonth();
1481 else 1481 else
1482 mView->goNext(); 1482 mView->goNext();
1483 showSelectedDates = true; 1483 showSelectedDates = true;
1484 break; 1484 break;
1485 case Qt::Key_Left: 1485 case Qt::Key_Left:
1486 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1486 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1487 mView->goPreviousMonth(); 1487 mView->goPreviousMonth();
1488 else 1488 else
1489 mView->goPrevious(); 1489 mView->goPrevious();
1490 showSelectedDates = true; 1490 showSelectedDates = true;
1491 break; 1491 break;
1492 case Qt::Key_Down: 1492 case Qt::Key_Down:
1493 mView->viewManager()->agendaView()->scrollOneHourDown(); 1493 mView->viewManager()->agendaView()->scrollOneHourDown();
1494 break; 1494 break;
1495 case Qt::Key_Up: 1495 case Qt::Key_Up:
1496 mView->viewManager()->agendaView()->scrollOneHourUp(); 1496 mView->viewManager()->agendaView()->scrollOneHourUp();
1497 break; 1497 break;
1498 case Qt::Key_I: 1498 case Qt::Key_I:
1499 mView->showIncidence(); 1499 mView->showIncidence();
1500 break; 1500 break;
1501 case Qt::Key_Delete: 1501 case Qt::Key_Delete:
1502 case Qt::Key_Backspace: 1502 case Qt::Key_Backspace:
1503 mView->deleteIncidence(); 1503 mView->deleteIncidence();
1504 break; 1504 break;
1505 case Qt::Key_D: 1505 case Qt::Key_D:
1506 mView->viewManager()->showDayView(); 1506 mView->viewManager()->showDayView();
1507 showSelectedDates = true; 1507 showSelectedDates = true;
1508 break; 1508 break;
1509 case Qt::Key_O: 1509 case Qt::Key_O:
1510 mView->toggleFilerEnabled( ); 1510 mView->toggleFilerEnabled( );
1511 break; 1511 break;
1512 case Qt::Key_0: 1512 case Qt::Key_0:
1513 case Qt::Key_1: 1513 case Qt::Key_1:
1514 case Qt::Key_2: 1514 case Qt::Key_2:
1515 case Qt::Key_3: 1515 case Qt::Key_3:
1516 case Qt::Key_4: 1516 case Qt::Key_4:
1517 case Qt::Key_5: 1517 case Qt::Key_5:
1518 case Qt::Key_6: 1518 case Qt::Key_6:
1519 case Qt::Key_7: 1519 case Qt::Key_7:
1520 case Qt::Key_8: 1520 case Qt::Key_8:
1521 case Qt::Key_9: 1521 case Qt::Key_9:
1522 pro = e->key()-48; 1522 pro = e->key()-48;
1523 if ( pro == 0 ) 1523 if ( pro == 0 )
1524 pro = 10; 1524 pro = 10;
1525 if ( e->state() == Qt::ControlButton) 1525 if ( e->state() == Qt::ControlButton)
1526 pro += 10; 1526 pro += 10;
1527 break; 1527 break;
1528 case Qt::Key_M: 1528 case Qt::Key_M:
1529 mView->viewManager()->showMonthView(); 1529 mView->viewManager()->showMonthView();
1530 showSelectedDates = true; 1530 showSelectedDates = true;
1531 break; 1531 break;
1532 case Qt::Key_Insert: 1532 case Qt::Key_Insert:
1533 mView->newEvent(); 1533 mView->newEvent();
1534 break; 1534 break;
1535 case Qt::Key_S : 1535 case Qt::Key_S :
1536 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1536 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1537 mView->newSubTodo(); 1537 mView->newSubTodo();
1538 else 1538 else
1539 mView->dialogManager()->showSearchDialog(); 1539 mView->dialogManager()->showSearchDialog();
1540 break; 1540 break;
1541 case Qt::Key_Y : 1541 case Qt::Key_Y :
1542 case Qt::Key_Z : 1542 case Qt::Key_Z :
1543 mView->viewManager()->showWorkWeekView(); 1543 mView->viewManager()->showWorkWeekView();
1544 showSelectedDates = true; 1544 showSelectedDates = true;
1545 break; 1545 break;
1546 case Qt::Key_U : 1546 case Qt::Key_U :
1547 mView->viewManager()->showWeekView(); 1547 mView->viewManager()->showWeekView();
1548 showSelectedDates = true; 1548 showSelectedDates = true;
1549 break; 1549 break;
1550 case Qt::Key_H : 1550 case Qt::Key_H :
1551 keyBindings(); 1551 keyBindings();
1552 break; 1552 break;
1553 case Qt::Key_W: 1553 case Qt::Key_W:
1554 mView->viewManager()->showWhatsNextView(); 1554 mView->viewManager()->showWhatsNextView();
1555 break; 1555 break;
1556 case Qt::Key_L: 1556 case Qt::Key_L:
1557 mView->viewManager()->showListView(); 1557 mView->viewManager()->showListView();
1558 break; 1558 break;
1559 case Qt::Key_N: 1559 case Qt::Key_N:
1560 mView->viewManager()->showNextXView(); 1560 mView->viewManager()->showNextXView();
1561 showSelectedDates = true; 1561 showSelectedDates = true;
1562 break; 1562 break;
1563 case Qt::Key_V: 1563 case Qt::Key_V:
1564 mView->viewManager()->showTodoView(); 1564 mView->viewManager()->showTodoView();
1565 break; 1565 break;
1566 case Qt::Key_C: 1566 case Qt::Key_C:
1567 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1567 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1568 break; 1568 break;
1569 case Qt::Key_P: 1569 case Qt::Key_P:
1570 mView->showDatePicker( ); 1570 mView->showDatePicker( );
1571 break; 1571 break;
1572 case Qt::Key_F: 1572 case Qt::Key_F:
1573 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1573 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1574 mView->editFilters(); 1574 mView->editFilters();
1575 else 1575 else
1576 mView->toggleFilter(); 1576 mView->toggleFilter();
1577 break; 1577 break;
1578 case Qt::Key_X: 1578 case Qt::Key_X:
1579 mView->toggleDateNavigatorWidget(); 1579 mView->toggleDateNavigatorWidget();
1580 break; 1580 break;
1581 case Qt::Key_Space: 1581 case Qt::Key_Space:
1582 mView->toggleExpand(); 1582 mView->toggleExpand();
1583 break; 1583 break;
1584 case Qt::Key_A: 1584 case Qt::Key_A:
1585 mView->toggleAllDaySize(); 1585 mView->toggleAllDaySize();
1586 break; 1586 break;
1587 case Qt::Key_T: 1587 case Qt::Key_T:
1588 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1588 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1589 mView->newTodo(); 1589 mView->newTodo();
1590 else { 1590 else {
1591 mView->goToday(); 1591 mView->goToday();
1592 showSelectedDates = true; 1592 showSelectedDates = true;
1593 } 1593 }
1594 break; 1594 break;
1595 case Qt::Key_J: 1595 case Qt::Key_J:
1596 mView->viewManager()->showJournalView(); 1596 mView->viewManager()->showJournalView();
1597 break; 1597 break;
1598 case Qt::Key_B: 1598 case Qt::Key_B:
1599 mView->editIncidenceDescription();; 1599 mView->editIncidenceDescription();;
1600 break; 1600 break;
1601 // case Qt::Key_Return: 1601 // case Qt::Key_Return:
1602 case Qt::Key_E: 1602 case Qt::Key_E:
1603 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1603 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1604 mView->newEvent(); 1604 mView->newEvent();
1605 else 1605 else
1606 mView->editIncidence(); 1606 mView->editIncidence();
1607 break; 1607 break;
1608 case Qt::Key_Plus: 1608 case Qt::Key_Plus:
1609 size = p->mHourSize +2; 1609 size = p->mHourSize +2;
1610 if ( size <= 18 ) 1610 if ( size <= 18 )
1611 configureAgenda( size ); 1611 configureAgenda( size );
1612 break; 1612 break;
1613 case Qt::Key_Minus: 1613 case Qt::Key_Minus:
1614 size = p->mHourSize - 2; 1614 size = p->mHourSize - 2;
1615 if ( size >= 4 ) 1615 if ( size >= 4 )
1616 configureAgenda( size ); 1616 configureAgenda( size );
1617 break; 1617 break;
1618 1618
1619 1619
1620 default: 1620 default:
1621 e->ignore(); 1621 e->ignore();
1622 } 1622 }
1623 if ( pro > 0 ) { 1623 if ( pro > 0 ) {
1624 mView->selectFilter( pro-1 ); 1624 mView->selectFilter( pro-1 );
1625 } 1625 }
1626 if ( showSelectedDates ) { 1626 if ( showSelectedDates ) {
1627 ;// setCaptionToDates(); 1627 ;// setCaptionToDates();
1628 } 1628 }
1629 1629
1630} 1630}
1631 1631
1632void MainWindow::fillFilterMenu() 1632void MainWindow::fillFilterMenu()
1633{ 1633{
1634 selectFilterMenu->clear(); 1634 selectFilterMenu->clear();
1635 bool disable = false; 1635 bool disable = false;
1636 if ( mView->filterView()->filtersEnabled() ) { 1636 if ( mView->filterView()->filtersEnabled() ) {
1637 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1637 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1638 } 1638 }
1639 else { 1639 else {
1640 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1640 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1641 disable = true; 1641 disable = true;
1642 } 1642 }
1643 selectFilterMenu->insertSeparator(); 1643 selectFilterMenu->insertSeparator();
1644 QPtrList<CalFilter> fili = mView->filters(); 1644 QPtrList<CalFilter> fili = mView->filters();
1645 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1645 CalFilter *curfilter = mView->filterView()->selectedFilter();
1646 CalFilter *filter = fili.first(); 1646 CalFilter *filter = fili.first();
1647 int iii = 1; 1647 int iii = 1;
1648 while(filter) { 1648 while(filter) {
1649 selectFilterMenu->insertItem( filter->name(), iii ); 1649 selectFilterMenu->insertItem( filter->name(), iii );
1650 if ( filter == curfilter) 1650 if ( filter == curfilter)
1651 selectFilterMenu->setItemChecked( iii, true ); 1651 selectFilterMenu->setItemChecked( iii, true );
1652 if ( disable ) 1652 if ( disable )
1653 selectFilterMenu->setItemEnabled( iii, false ); 1653 selectFilterMenu->setItemEnabled( iii, false );
1654 filter = fili.next(); 1654 filter = fili.next();
1655 ++iii; 1655 ++iii;
1656 } 1656 }
1657} 1657}
1658void MainWindow::selectFilter( int fil ) 1658void MainWindow::selectFilter( int fil )
1659{ 1659{
1660 if ( fil == 0 ) { 1660 if ( fil == 0 ) {
1661 mView->toggleFilerEnabled( ); 1661 mView->toggleFilerEnabled( );
1662 } else { 1662 } else {
1663 mView->selectFilter( fil-1 ); 1663 mView->selectFilter( fil-1 );
1664 } 1664 }
1665} 1665}
1666void MainWindow::configureToolBar( int item ) 1666void MainWindow::configureToolBar( int item )
1667{ 1667{
1668 1668
1669 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1669 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1670 KOPrefs *p = KOPrefs::instance(); 1670 KOPrefs *p = KOPrefs::instance();
1671 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1671 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1672 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1672 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1673 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1673 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1674 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1674 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1675 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1675 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1676 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1676 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1677 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1677 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1678 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1678 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1679 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1679 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1680 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1680 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1681 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1681 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1682 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1682 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1683 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1683 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1684 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1684 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1685 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1685 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1686 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1686 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1687 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1687 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1688 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1688 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1689 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1689 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1690 // initActions(); 1690 // initActions();
1691} 1691}
1692 1692
1693void MainWindow::setCaptionToDates() 1693void MainWindow::setCaptionToDates()
1694{ 1694{
1695 QString selDates; 1695 QString selDates;
1696 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1696 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1697 if (mView->startDate() < mView->endDate() ) 1697 if (mView->startDate() < mView->endDate() )
1698 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1698 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1699 setCaption( i18n("Dates: ") + selDates ); 1699 setCaption( i18n("Dates: ") + selDates );
1700 1700
1701} 1701}
1702// parameter item == 0: reinit 1702// parameter item == 0: reinit
1703void MainWindow::configureAgenda( int item ) 1703void MainWindow::configureAgenda( int item )
1704{ 1704{
1705 1705
1706 KOPrefs *p = KOPrefs::instance(); 1706 KOPrefs *p = KOPrefs::instance();
1707 1707
1708 int i; 1708 int i;
1709 if ( item == 1 ) { 1709 if ( item == 1 ) {
1710 mView->toggleAllDaySize(); 1710 mView->toggleAllDaySize();
1711 return; 1711 return;
1712 } 1712 }
1713 // do not allow 4 for widgets higher than 480 1713 // do not allow 4 for widgets higher than 480
1714 // if ( QApplication::desktop()->height() > 480 ) { 1714 // if ( QApplication::desktop()->height() > 480 ) {
1715// if ( item == 4 ) 1715// if ( item == 4 )
1716// item = 6; 1716// item = 6;
1717// } 1717// }
1718 for ( i = 4; i <= 18; i= i+2 ) 1718 for ( i = 4; i <= 18; i= i+2 )
1719 configureAgendaMenu->setItemChecked( i, false ); 1719 configureAgendaMenu->setItemChecked( i, false );
1720 configureAgendaMenu->setItemChecked( item, true ); 1720 configureAgendaMenu->setItemChecked( item, true );
1721 if ( p->mHourSize == item ) 1721 if ( p->mHourSize == item )
1722 return; 1722 return;
1723 p->mHourSize=item; 1723 p->mHourSize=item;
1724 mView->viewManager()->agendaView()->updateConfig(); 1724 mView->viewManager()->agendaView()->updateConfig();
1725} 1725}
1726 1726
1727void MainWindow::saveCalendar() 1727void MainWindow::saveCalendar()
1728{ 1728{
1729 QString fn = KOPrefs::instance()->mLastSaveFile; 1729 QString fn = KOPrefs::instance()->mLastSaveFile;
1730 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1730 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1731 1731
1732 if ( fn == "" ) 1732 if ( fn == "" )
1733 return; 1733 return;
1734 QFileInfo info; 1734 QFileInfo info;
1735 info.setFile( fn ); 1735 info.setFile( fn );
1736 QString mes; 1736 QString mes;
1737 bool createbup = true; 1737 bool createbup = true;
1738 if ( info. exists() ) { 1738 if ( info. exists() ) {
1739 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1739 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1740 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1740 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1741 i18n("Overwrite!"), i18n("Cancel"), 0, 1741 i18n("Overwrite!"), i18n("Cancel"), 0,
1742 0, 1 ); 1742 0, 1 );
1743 if ( result != 0 ) { 1743 if ( result != 0 ) {
1744 createbup = false; 1744 createbup = false;
1745 } 1745 }
1746 } 1746 }
1747 if ( createbup ) { 1747 if ( createbup ) {
1748 mView->saveCalendar( fn ); 1748 mView->saveCalendar( fn );
1749 mes = i18n("KO/Pi:Saved %1").arg(fn); 1749 mes = i18n("KO/Pi:Saved %1").arg(fn);
1750 KOPrefs::instance()->mLastSaveFile = fn; 1750 KOPrefs::instance()->mLastSaveFile = fn;
1751 setCaption(mes); 1751 setCaption(mes);
1752 } 1752 }
1753} 1753}
1754void MainWindow::loadCalendar() 1754void MainWindow::loadCalendar()
1755{ 1755{
1756 1756
1757 QString fn = KOPrefs::instance()->mLastLoadFile; 1757 QString fn = KOPrefs::instance()->mLastLoadFile;
1758 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1758 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1759 1759
1760 if ( fn == "" ) 1760 if ( fn == "" )
1761 return; 1761 return;
1762 QFileInfo info; 1762 QFileInfo info;
1763 info.setFile( fn ); 1763 info.setFile( fn );
1764 QString mess; 1764 QString mess;
1765 bool loadbup = true; 1765 bool loadbup = true;
1766 if ( info. exists() ) { 1766 if ( info. exists() ) {
1767 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1767 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1768 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1768 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1769 mess, 1769 mess,
1770 i18n("Load!"), i18n("Cancel"), 0, 1770 i18n("Load!"), i18n("Cancel"), 0,
1771 0, 1 ); 1771 0, 1 );
1772 if ( result != 0 ) { 1772 if ( result != 0 ) {
1773 loadbup = false; 1773 loadbup = false;
1774 } 1774 }
1775 } else { 1775 } else {
1776 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1776 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1777 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1777 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1778 0, 1 ); 1778 0, 1 );
1779 1779
1780 return; 1780 return;
1781 } 1781 }
1782 if ( loadbup ) { 1782 if ( loadbup ) {
1783 mView->openCalendar( fn ); 1783 mView->openCalendar( fn );
1784 KOPrefs::instance()->mLastLoadFile = fn; 1784 KOPrefs::instance()->mLastLoadFile = fn;
1785 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1785 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1786 setCaption(mess); 1786 setCaption(mess);
1787 } 1787 }
1788 1788
1789} 1789}
1790void MainWindow::quickImportIcal() 1790void MainWindow::quickImportIcal()
1791{ 1791{
1792 importFile( KOPrefs::instance()->mLastImportFile, false ); 1792 importFile( KOPrefs::instance()->mLastImportFile, false );
1793} 1793}
1794void MainWindow::importFile( QString fn, bool quick ) 1794void MainWindow::importFile( QString fn, bool quick )
1795{ 1795{
1796 QFileInfo info; 1796 QFileInfo info;
1797 info.setFile( fn ); 1797 info.setFile( fn );
1798 QString mess; 1798 QString mess;
1799 bool loadbup = true; 1799 bool loadbup = true;
1800 if ( !info. exists() ) { 1800 if ( !info. exists() ) {
1801 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1801 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1802 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1802 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1803 mess ); 1803 mess );
1804 return; 1804 return;
1805 } 1805 }
1806 int result = 0; 1806 int result = 0;
1807 if ( !quick ) { 1807 if ( !quick ) {
1808 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 )); 1808 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 ));
1809 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1809 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1810 mess, 1810 mess,
1811 "Import", "Cancel", 0, 1811 "Import", "Cancel", 0,
1812 0, 1 ); 1812 0, 1 );
1813 } 1813 }
1814 if ( result == 0 ) { 1814 if ( result == 0 ) {
1815 if ( mView->openCalendar( fn, true )) { 1815 if ( mView->openCalendar( fn, true )) {
1816 KOPrefs::instance()->mLastImportFile = fn; 1816 KOPrefs::instance()->mLastImportFile = fn;
1817 setCaption(i18n("Imported file successfully")); 1817 setCaption(i18n("Imported file successfully"));
1818 } else { 1818 } else {
1819 setCaption(i18n("Error importing file")); 1819 setCaption(i18n("Error importing file"));
1820 } 1820 }
1821 } 1821 }
1822} 1822}
1823 1823
1824void MainWindow::importIcal() 1824void MainWindow::importIcal()
1825{ 1825{
1826 1826
1827 QString fn =KOPrefs::instance()->mLastImportFile; 1827 QString fn =KOPrefs::instance()->mLastImportFile;
1828 1828
1829 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1829 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1830 if ( fn == "" ) 1830 if ( fn == "" )
1831 return; 1831 return;
1832 importFile( fn, true ); 1832 importFile( fn, true );
1833 1833
1834} 1834}
1835 1835
1836void MainWindow::exportVCalendar() 1836void MainWindow::exportVCalendar()
1837{ 1837{
1838 QString fn = KOPrefs::instance()->mLastVcalFile; 1838 QString fn = KOPrefs::instance()->mLastVcalFile;
1839 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1839 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1840 if ( fn == "" ) 1840 if ( fn == "" )
1841 return; 1841 return;
1842 QFileInfo info; 1842 QFileInfo info;
1843 info.setFile( fn ); 1843 info.setFile( fn );
1844 QString mes; 1844 QString mes;
1845 bool createbup = true; 1845 bool createbup = true;
1846 if ( info. exists() ) { 1846 if ( info. exists() ) {
1847 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1847 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1848 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1848 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1849 i18n("Overwrite!"), i18n("Cancel"), 0, 1849 i18n("Overwrite!"), i18n("Cancel"), 0,
1850 0, 1 ); 1850 0, 1 );
1851 if ( result != 0 ) { 1851 if ( result != 0 ) {
1852 createbup = false; 1852 createbup = false;
1853 } 1853 }
1854 } 1854 }
1855 if ( createbup ) { 1855 if ( createbup ) {
1856 if ( mView->exportVCalendar( fn ) ) { 1856 if ( mView->exportVCalendar( fn ) ) {
1857 KOPrefs::instance()->mLastVcalFile = fn; 1857 KOPrefs::instance()->mLastVcalFile = fn;
1858 if ( fn.length() > 20 ) 1858 if ( fn.length() > 20 )
1859 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1859 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1860 else 1860 else
1861 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1861 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1862 setCaption(mes); 1862 setCaption(mes);
1863 } 1863 }
1864 } 1864 }
1865 1865
1866} 1866}
1867QString MainWindow::getPassword( ) 1867QString MainWindow::getPassword( )
1868{ 1868{
1869 QString retfile = ""; 1869 QString retfile = "";
1870 QDialog dia ( this, "input-dialog", true ); 1870 QDialog dia ( this, "input-dialog", true );
1871 QLineEdit lab ( &dia ); 1871 QLineEdit lab ( &dia );
1872 lab.setEchoMode( QLineEdit::Password ); 1872 lab.setEchoMode( QLineEdit::Password );
1873 QVBoxLayout lay( &dia ); 1873 QVBoxLayout lay( &dia );
1874 lay.setMargin(7); 1874 lay.setMargin(7);
1875 lay.setSpacing(7); 1875 lay.setSpacing(7);
1876 lay.addWidget( &lab); 1876 lay.addWidget( &lab);
1877 dia.setFixedSize( 230,50 ); 1877 dia.setFixedSize( 230,50 );
1878 dia.setCaption( i18n("Enter password") ); 1878 dia.setCaption( i18n("Enter password") );
1879 QPushButton pb ( "OK", &dia); 1879 QPushButton pb ( "OK", &dia);
1880 lay.addWidget( &pb ); 1880 lay.addWidget( &pb );
1881 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1881 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1882 dia.show(); 1882 dia.show();
1883 int res = dia.exec(); 1883 int res = dia.exec();
1884 if ( res ) 1884 if ( res )
1885 retfile = lab.text(); 1885 retfile = lab.text();
1886 dia.hide(); 1886 dia.hide();
1887 qApp->processEvents(); 1887 qApp->processEvents();
1888 return retfile; 1888 return retfile;
1889 1889
1890} 1890}
1891 1891
1892void MainWindow::enableQuick() 1892void MainWindow::enableQuick()
1893{ 1893{
1894 QString passWordPiSync = "bhdrvmk"; 1894 QString passWordPiSync = "bhdrvmk";
1895 QString retfile = ""; 1895 QString retfile = "";
1896 QDialog dia ( this, "input-dialog", true ); 1896 QDialog dia ( this, "input-dialog", true );
1897 QLineEdit lab ( &dia ); 1897 QLineEdit lab ( &dia );
1898 QVBoxLayout lay( &dia ); 1898 QVBoxLayout lay( &dia );
1899 lab.setText( KOPrefs::instance()->mPassiveSyncPort ); 1899 lab.setText( KOPrefs::instance()->mPassiveSyncPort );
1900 lay.setMargin(7); 1900 lay.setMargin(7);
1901 lay.setSpacing(7); 1901 lay.setSpacing(7);
1902 QLabel label ( i18n("Port number (Default: 9197)"), &dia ); 1902 QLabel label ( i18n("Port number (Default: 9197)"), &dia );
1903 lay.addWidget( &label); 1903 lay.addWidget( &label);
1904 lay.addWidget( &lab); 1904 lay.addWidget( &lab);
1905 1905
1906 QLineEdit lepw ( &dia ); 1906 QLineEdit lepw ( &dia );
1907 lepw.setText( "abc" ); 1907 lepw.setText( "abc" );
1908 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 1908 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
1909 lay.addWidget( &label2); 1909 lay.addWidget( &label2);
1910 lay.addWidget( &lepw); 1910 lay.addWidget( &lepw);
1911 dia.setFixedSize( 230,80 ); 1911 dia.setFixedSize( 230,80 );
1912 dia.setCaption( i18n("Enter port for Pi-Sync") ); 1912 dia.setCaption( i18n("Enter port for Pi-Sync") );
1913 QPushButton pb ( "OK", &dia); 1913 QPushButton pb ( "OK", &dia);
1914 lay.addWidget( &pb ); 1914 lay.addWidget( &pb );
1915 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1915 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1916 dia.show(); 1916 dia.show();
1917 int res = dia.exec(); 1917 int res = dia.exec();
1918 if ( res ) 1918 if ( res )
1919 retfile = lab.text(); 1919 retfile = lab.text();
1920 else 1920 else
1921 return; 1921 return;
1922 dia.hide(); 1922 dia.hide();
1923 passWordPiSync = lepw.text(); 1923 passWordPiSync = lepw.text();
1924 qApp->processEvents(); 1924 qApp->processEvents();
1925 KOPrefs::instance()->mPassiveSyncPort = retfile; 1925 KOPrefs::instance()->mPassiveSyncPort = retfile;
1926 bool ok; 1926 bool ok;
1927 Q_UINT16 port = retfile.toUInt(&ok); 1927 Q_UINT16 port = retfile.toUInt(&ok);
1928 if ( ! ok ) { 1928 if ( ! ok ) {
1929 KMessageBox::information( this, i18n("No valid port")); 1929 KMessageBox::information( this, i18n("No valid port"));
1930 return; 1930 return;
1931 } 1931 }
1932 qDebug("port %d ", port); 1932 qDebug("port %d ", port);
1933 mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); 1933 mServerSocket = new KServerSocket ( passWordPiSync, port ,1 );
1934 qDebug("connected "); 1934 qDebug("connected ");
1935 if ( !mServerSocket->ok() ) { 1935 if ( !mServerSocket->ok() ) {
1936 qWarning("Failed to bind to port %d", port); 1936 qWarning("Failed to bind to port %d", port);
1937 delete mServerSocket; 1937 delete mServerSocket;
1938 mServerSocket = 0; 1938 mServerSocket = 0;
1939 return; 1939 return;
1940 } 1940 }
1941 connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); 1941 connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) );
1942 connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); 1942 connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) );
1943} 1943}
1944void MainWindow::sendFile(QSocket* socket) 1944void MainWindow::sendFile(QSocket* socket)
1945{ 1945{
1946 setCaption( i18n("Received request for file") ); 1946 setCaption( i18n("Received request for file") );
1947 qDebug("MainWindow::sendFile(QSocket* s) "); 1947 qDebug("MainWindow::sendFile(QSocket* s) ");
1948 if ( mSyncActionDialog ) 1948 if ( mSyncActionDialog )
1949 delete mSyncActionDialog; 1949 delete mSyncActionDialog;
1950 mSyncActionDialog = new QDialog ( this, "input-dialog", true ); 1950 mSyncActionDialog = new QDialog ( this, "input-dialog", true );
1951 mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING")); 1951 mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING"));
1952 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog ); 1952 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog );
1953 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1953 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1954 lay->addWidget( label); 1954 lay->addWidget( label);
1955 lay->setMargin(7); 1955 lay->setMargin(7);
1956 lay->setSpacing(7); 1956 lay->setSpacing(7);
1957 mSyncActionDialog->setFixedSize( 200,100 ); 1957 mSyncActionDialog->setFixedSize( 200,100 );
1958 mSyncActionDialog->show(); 1958 mSyncActionDialog->show();
1959 qDebug("saving ... "); 1959 qDebug("saving ... ");
1960 save(); 1960 save();
1961 qApp->processEvents(); 1961 qApp->processEvents();
1962 QString fileName = defaultFileName(); 1962 QString fileName = defaultFileName();
1963 QFile file( fileName ); 1963 QFile file( fileName );
1964 if (!file.open( IO_ReadOnly ) ) { 1964 if (!file.open( IO_ReadOnly ) ) {
1965 setCaption( i18n("Error open file") ); 1965 setCaption( i18n("Error open file") );
1966 delete mSyncActionDialog; 1966 delete mSyncActionDialog;
1967 mSyncActionDialog = 0; 1967 mSyncActionDialog = 0;
1968 qDebug("error open cal file "); 1968 qDebug("error open cal file ");
1969 return ; 1969 return ;
1970 1970
1971 } 1971 }
1972 setCaption( i18n("Sending file...") ); 1972 setCaption( i18n("Sending file...") );
1973 QTextStream ts( &file ); 1973 QTextStream ts( &file );
1974 ts.setCodec( QTextCodec::codecForName("utf8") ); 1974 ts.setCodec( QTextCodec::codecForName("utf8") );
1975 QTextStream os( socket ); 1975 QTextStream os( socket );
1976 os.setCodec( QTextCodec::codecForName("utf8") ); 1976 os.setCodec( QTextCodec::codecForName("utf8") );
1977 //os.setEncoding( QTextStream::UnicodeUTF8 ); 1977 //os.setEncoding( QTextStream::UnicodeUTF8 );
1978 while ( ! ts.atEnd() ) { 1978 while ( ! ts.atEnd() ) {
1979 os << ts.readLine() << "\n"; 1979 os << ts.readLine() << "\n";
1980 } 1980 }
1981 //os << ts.read(); 1981 //os << ts.read();
1982 socket->close(); 1982 socket->close();
1983 file.close(); 1983 file.close();
1984 setCaption( i18n("File sent. Waiting to get back synced file") ); 1984 setCaption( i18n("File sent. Waiting to get back synced file") );
1985 qDebug("file sent "); 1985 qDebug("file sent ");
1986} 1986}
1987void MainWindow::getFile(QSocket* socket) 1987void MainWindow::getFile(QSocket* socket)
1988{ 1988{
1989 setCaption( i18n("Receiving synced file...") ); 1989 setCaption( i18n("Receiving synced file...") );
1990 1990
1991 piTime.start(); 1991 piTime.start();
1992 piSocket = socket; 1992 piSocket = socket;
1993 piFileString = ""; 1993 piFileString = "";
1994 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1994 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1995 1995
1996 1996
1997} 1997}
1998void MainWindow::readBackFileFromSocket() 1998void MainWindow::readBackFileFromSocket()
1999{ 1999{
2000 qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 2000 qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
2001 while ( piSocket->canReadLine () ) { 2001 while ( piSocket->canReadLine () ) {
2002 piTime.restart(); 2002 piTime.restart();
2003 QString line = piSocket->readLine (); 2003 QString line = piSocket->readLine ();
2004 piFileString += line; 2004 piFileString += line;
2005 qDebug("readline: %s ", line.latin1()); 2005 qDebug("readline: %s ", line.latin1());
2006 setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 2006 setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
2007 2007
2008 } 2008 }
2009 if ( piTime.elapsed () < 3000 ) { 2009 if ( piTime.elapsed () < 3000 ) {
2010 // wait for more 2010 // wait for more
2011 qDebug("waitformore "); 2011 qDebug("waitformore ");
2012 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 2012 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
2013 return; 2013 return;
2014 } 2014 }
2015 QString fileName = defaultFileName(); 2015 QString fileName = defaultFileName();
2016 QFile file ( fileName ); 2016 QFile file ( fileName );
2017 if (!file.open( IO_WriteOnly ) ) { 2017 if (!file.open( IO_WriteOnly ) ) {
2018 setCaption( i18n("Error open file for writing!") ); 2018 setCaption( i18n("Error open file for writing!") );
2019 delete mSyncActionDialog; 2019 delete mSyncActionDialog;
2020 mSyncActionDialog = 0; 2020 mSyncActionDialog = 0;
2021 qDebug("error open cal file "); 2021 qDebug("error open cal file ");
2022 piFileString = ""; 2022 piFileString = "";
2023 return ; 2023 return ;
2024 2024
2025 } 2025 }
2026 2026
2027 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 2027 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2028 QTextStream ts ( &file ); 2028 QTextStream ts ( &file );
2029 ts.setCodec( QTextCodec::codecForName("utf8") ); 2029 ts.setCodec( QTextCodec::codecForName("utf8") );
2030 qDebug("finish "); 2030 qDebug("finish ");
2031 setCaption( i18n("Writing file to disk...") ); 2031 setCaption( i18n("Writing file to disk...") );
2032 ts << piFileString; 2032 ts << piFileString;
2033 setCaption( i18n("File received - reloading calendar...") ); 2033 setCaption( i18n("File received - reloading calendar...") );
2034 piSocket->close(); 2034 piSocket->close();
2035 file.close(); 2035 file.close();
2036 mView->watchSavedFile(); 2036 mView->watchSavedFile();
2037 mView->openCalendar( defaultFileName() ); 2037 mView->openCalendar( defaultFileName() );
2038 setCaption( i18n("Pi-Sync successful!") ); 2038 setCaption( i18n("Pi-Sync successful!") );
2039 delete mSyncActionDialog; 2039 delete mSyncActionDialog;
2040 mSyncActionDialog = 0; 2040 mSyncActionDialog = 0;
2041 piFileString = ""; 2041 piFileString = "";
2042 2042
2043 2043
2044} 2044}
2045void MainWindow::endConnect() 2045void MainWindow::endConnect()
2046{ 2046{
2047 setCaption( i18n("No file received - syncing successful") ); 2047 setCaption( i18n("No file received - syncing successful") );
2048 delete mSyncActionDialog; 2048 delete mSyncActionDialog;
2049 mSyncActionDialog = 0; 2049 mSyncActionDialog = 0;
2050} 2050}
2051void MainWindow::performQuick() 2051void MainWindow::performQuick()
2052{ 2052{
2053 2053
2054 setCaption( i18n("Please input connection settings") ); 2054 setCaption( i18n("Please input connection settings") );
2055 QString retfile = ""; 2055 QString retfile = "";
2056 QDialog dia ( this, "input-dialog", true ); 2056 QDialog dia ( this, "input-dialog", true );
2057 QLineEdit lab ( &dia ); 2057 QLineEdit lab ( &dia );
2058 QVBoxLayout lay( &dia ); 2058 QVBoxLayout lay( &dia );
2059 QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); 2059 QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia );
2060 lay.addWidget( &label); 2060 lay.addWidget( &label);
2061 lab.setText( KOPrefs::instance()->mActiveSyncIP ); 2061 lab.setText( KOPrefs::instance()->mActiveSyncIP );
2062 lay.setMargin(7); 2062 lay.setMargin(7);
2063 lay.setSpacing(7); 2063 lay.setSpacing(7);
2064 lay.addWidget( &lab); 2064 lay.addWidget( &lab);
2065 QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); 2065 QLabel label2 ( i18n("Port number (Default: 9197)"), &dia );
2066 lay.addWidget( &label2); 2066 lay.addWidget( &label2);
2067 QLineEdit lab2 ( &dia ); 2067 QLineEdit lab2 ( &dia );
2068 lab2.setText( KOPrefs::instance()->mActiveSyncPort ); 2068 lab2.setText( KOPrefs::instance()->mActiveSyncPort );
2069 lay.addWidget( &lab2); 2069 lay.addWidget( &lab2);
2070 2070
2071 QLineEdit lepw ( &dia ); 2071 QLineEdit lepw ( &dia );
2072 lepw.setText( mPassWordPiSync ); 2072 lepw.setText( mPassWordPiSync );
2073 QLabel label3 ( i18n("Password to enable\naccess to remote:"), &dia ); 2073 QLabel label3 ( i18n("Password to enable\naccess to remote:"), &dia );
2074 lay.addWidget( &label3); 2074 lay.addWidget( &label3);
2075 lay.addWidget( &lepw); 2075 lay.addWidget( &lepw);
2076 2076
2077 dia.setFixedSize( 230,200 ); 2077 dia.setFixedSize( 230,200 );
2078 dia.setCaption( i18n("Enter port for Pi-Sync ") ); 2078 dia.setCaption( i18n("Enter port for Pi-Sync ") );
2079 QPushButton pb ( "OK", &dia); 2079 QPushButton pb ( "OK", &dia);
2080 lay.addWidget( &pb ); 2080 lay.addWidget( &pb );
2081 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2081 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2082 dia.show(); 2082 dia.show();
2083 int res = dia.exec(); 2083 int res = dia.exec();
2084 if ( !res ) { 2084 if ( !res ) {
2085 setCaption( i18n("Syncing cancelled!") ); 2085 setCaption( i18n("Syncing cancelled!") );
2086 return; 2086 return;
2087 } 2087 }
2088 mPassWordPiSync = lepw.text(); 2088 mPassWordPiSync = lepw.text();
2089 dia.hide(); 2089 dia.hide();
2090 KOPrefs::instance()->mActiveSyncPort = lab2.text(); 2090 KOPrefs::instance()->mActiveSyncPort = lab2.text();
2091 KOPrefs::instance()->mActiveSyncIP = lab.text(); 2091 KOPrefs::instance()->mActiveSyncIP = lab.text();
2092 qApp->processEvents(); 2092 qApp->processEvents();
2093 performQuickQuick(); 2093 performQuickQuick();
2094} 2094}
2095 2095
2096void MainWindow::performQuickQuick() 2096void MainWindow::performQuickQuick()
2097{ 2097{
2098 // setCaption( i18n("") ); 2098 // setCaption( i18n("") );
2099 2099
2100 bool ok; 2100 bool ok;
2101 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); 2101 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
2102 if ( ! ok ) { 2102 if ( ! ok ) {
2103 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 2103 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
2104 return; 2104 return;
2105 } 2105 }
2106 if ( !mCommandSocket ) { 2106 if ( !mCommandSocket ) {
2107 mCommandSocket = new QSocket( this ); 2107 mCommandSocket = new QSocket( this );
2108 // delete mCommandSocket; 2108 // delete mCommandSocket;
2109 //mCommandSocket = new QSocket( this ); 2109 //mCommandSocket = new QSocket( this );
2110 connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); 2110 connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) );
2111 connect( mCommandSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocket()) ); 2111 connect( mCommandSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocket()) );
2112 } 2112 }
2113 QString host = KOPrefs::instance()->mActiveSyncIP; 2113 QString host = KOPrefs::instance()->mActiveSyncIP;
2114 mCommandSocket->connectToHost( host, port ); 2114 mCommandSocket->connectToHost( host, port );
2115 QTextStream os( mCommandSocket ); 2115 QTextStream os( mCommandSocket );
2116 os.setEncoding( QTextStream::UnicodeUTF8 ); 2116 os.setEncoding( QTextStream::UnicodeUTF8 );
2117 os << "GET " << mPassWordPiSync << "\r\n"; 2117 os << "GET " << mPassWordPiSync << "\r\n";
2118 setCaption( i18n("Sending request for remote file ...") ); 2118 setCaption( i18n("Sending request for remote file ...") );
2119 mTimerCommandSocket->start( 15000 ); 2119 mTimerCommandSocket->start( 10000 );
2120 2120
2121} 2121}
2122void MainWindow::deleteCommandSocket() 2122void MainWindow::deleteCommandSocket()
2123{ 2123{
2124 if ( !mCommandSocket) 2124 if ( !mCommandSocket)
2125 return; 2125 return;
2126 if ( mTimerCommandSocket->isActive () ) { 2126 if ( mTimerCommandSocket->isActive () ) {
2127 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out ")); 2127 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out "));
2128 mTimerCommandSocket->stop(); 2128 mTimerCommandSocket->stop();
2129 } 2129 }
2130 //KMessageBox::information( 0, i18n("MainWindow::deleteCommandSocket "));
2130 qDebug("MainWindow::deletemCommandSocket() "); 2131 qDebug("MainWindow::deletemCommandSocket() ");
2131 delete mCommandSocket; 2132 delete mCommandSocket;
2132 mCommandSocket = 0; 2133 mCommandSocket = 0;
2133} 2134}
2134void MainWindow::deleteCommandSocketFinish() 2135void MainWindow::deleteCommandSocketFinish()
2135{ 2136{
2136 if ( ! mCommandSocketFinish) 2137 if ( ! mCommandSocketFinish)
2137 return; 2138 return;
2138 //KMessageBox::information( 0, i18n("MainWindow::deleteCommandSocketFinish() ")); 2139 // KMessageBox::information( 0, i18n("MainWindow::deleteCommandSocketFinish() "));
2139 qDebug("MainWindow::deletemCommandSocketFinish() "); 2140 qDebug("MainWindow::deletemCommandSocketFinish() ");
2140 delete mCommandSocketFinish; 2141 delete mCommandSocketFinish;
2141 mCommandSocketFinish = 0; 2142 mCommandSocketFinish = 0;
2142} 2143}
2143void MainWindow::readFileFromSocket() 2144void MainWindow::readFileFromSocket()
2144{ 2145{
2145 mTimerCommandSocket->stop(); 2146 mTimerCommandSocket->stop();
2146 setCaption( i18n("Receiving remote file ...") ); 2147 setCaption( i18n("Receiving remote file ...") );
2147 qDebug("MainWindow::readFileFromSocket() "); 2148 qDebug("MainWindow::readFileFromSocket() ");
2148 QString fileName; 2149 QString fileName;
2149#ifdef _WIN32_ 2150#ifdef _WIN32_
2150 fileName = defaultFileName() +"sync"; 2151 fileName = defaultFileName() +"sync";
2151#else 2152#else
2152 fileName = "/tmp/kopitempfile.ics"; 2153 fileName = "/tmp/kopitempfile.ics";
2153#endif 2154#endif
2154 QFile file( fileName ); 2155 QFile file( fileName );
2155 if (!file.open( IO_WriteOnly ) ) { 2156 if (!file.open( IO_WriteOnly ) ) {
2156 setCaption( i18n("Error: Cannot open temp file for write.") ); 2157 setCaption( i18n("Error: Cannot open temp file for write.") );
2157 qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); 2158 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
2158 return ; 2159 return ;
2159 } 2160 }
2160 2161
2161 //QTextStream os2( mCommandSocket ); 2162 //QTextStream os2( mCommandSocket );
2162 //os2.setEncoding( QTextStream::UnicodeUTF8 ); 2163 //os2.setEncoding( QTextStream::UnicodeUTF8 );
2163 2164
2164 QTextStream ts( &file ); 2165 QTextStream ts( &file );
2165 ts.setCodec( QTextCodec::codecForName("utf8") ); 2166 ts.setCodec( QTextCodec::codecForName("utf8") );
2166 bool first = true; 2167 bool first = true;
2167 while ( mCommandSocket->canReadLine () || first) { 2168 while ( mCommandSocket->canReadLine () || first) {
2168 first = false; 2169 first = false;
2169 while ( mCommandSocket->canReadLine () ) { 2170 while ( mCommandSocket->canReadLine () ) {
2170 ts << mCommandSocket->readLine (); 2171 ts << mCommandSocket->readLine ();
2171 } 2172 }
2172 QTime ti; 2173 QTime ti;
2173 ti.start(); 2174 ti.start();
2174 while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) { 2175 while ( ti.elapsed () < 3000 && !mCommandSocket->canReadLine () ) {
2175 qApp->processEvents(); 2176 qApp->processEvents();
2176 qDebug("waiting2 %d ",ti.elapsed () ); 2177 qDebug("waiting2 %d ",ti.elapsed () );
2177 if ( !mCommandSocket->canReadLine () ) 2178 if ( !mCommandSocket->canReadLine () )
2178 mCommandSocket->waitForMore ( 100 ); 2179 mCommandSocket->waitForMore ( 100 );
2179 } 2180 }
2180 //mCommandSocket->waitForMore ( 5000 ); 2181 //mCommandSocket->waitForMore ( 5000 );
2181 } 2182 }
2182 file.close(); 2183 file.close();
2183 mCommandSocket->close(); 2184 mCommandSocket->close();
2184 if ( mCommandSocket->state() == QSocket::Idle ) 2185 if ( mCommandSocket->state() == QSocket::Idle )
2185 deleteCommandSocket(); 2186 deleteCommandSocket();
2186 // pending: deleting after signal SIGNAL(delayedCloseFinished()) 2187 // pending: deleting after signal SIGNAL(delayedCloseFinished())
2187 //delete mCommandSocket; 2188 //delete mCommandSocket;
2188 setCaption( i18n("Remote file saved to temp file.") ); 2189 setCaption( i18n("Remote file saved to temp file.") );
2189 //mCommandSocket = 0; 2190 //mCommandSocket = 0;
2190 mCurrentSyncProfile = 2 ; // last file 2191 mCurrentSyncProfile = 2 ; // last file
2191 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 2192 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
2192 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 2193 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
2193 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2194 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2194 KSyncProfile* temp = new KSyncProfile (); 2195 KSyncProfile* temp = new KSyncProfile ();
2195 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2196 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2196 temp->readConfig(&config); 2197 temp->readConfig(&config);
2197 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2198 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2198 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 2199 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2199 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2200 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2200 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2201 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2201 KOPrefs::instance()->mWriteBackInFuture = 0; 2202 KOPrefs::instance()->mWriteBackInFuture = 0;
2202 if ( temp->getWriteBackFuture() ) 2203 if ( temp->getWriteBackFuture() )
2203 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2204 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2204 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 2205 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2205 delete temp; 2206 delete temp;
2206 setCaption( i18n("Remote file saved to temp file.") ); 2207 setCaption( i18n("Remote file saved to temp file.") );
2207 if ( ! syncWithFile( fileName , true ) ) { 2208 if ( ! syncWithFile( fileName , true ) ) {
2208 setCaption( i18n("Syncing failed.") ); 2209 setCaption( i18n("Syncing failed.") );
2209 qDebug("Syncing failed "); 2210 qDebug("Syncing failed ");
2210 return; 2211 return;
2211 } 2212 }
2212 2213
2213 if ( !mCommandSocketFinish ) { 2214 if ( !mCommandSocketFinish ) {
2214 mCommandSocketFinish = new QSocket( this ); 2215 mCommandSocketFinish = new QSocket( this );
2215 connect( mCommandSocketFinish, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocketFinish()) ); 2216 connect( mCommandSocketFinish, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocketFinish()) );
2216 } 2217 }
2217 mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); 2218 mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() );
2218 2219
2219 // pending connect signals connected () and error to new slots 2220 // pending connect signals connected () and error to new slots
2220 QString host = KOPrefs::instance()->mActiveSyncIP; 2221 QString host = KOPrefs::instance()->mActiveSyncIP;
2221 QFile file2( fileName ); 2222 QFile file2( fileName );
2222 if (!file2.open( IO_ReadOnly ) ) { 2223 if (!file2.open( IO_ReadOnly ) ) {
2223 setCaption( i18n("Error: Cannot open temp file for read.") ); 2224 setCaption( i18n("Error: Cannot open temp file for read.") );
2224 qDebug("error open cal file "); 2225 qDebug("error open cal file ");
2225 return ; 2226 return ;
2226 2227
2227 } 2228 }
2228 setCaption( i18n("Sending back synced file...") );
2229 QTextStream ts2( &file2 ); 2229 QTextStream ts2( &file2 );
2230 ts2.setCodec( QTextCodec::codecForName("utf8") ); 2230 ts2.setCodec( QTextCodec::codecForName("utf8") );
2231 QTextStream os2( mCommandSocketFinish ); 2231 QTextStream os2( mCommandSocketFinish );
2232 os2.setCodec( QTextCodec::codecForName("utf8") ); 2232 os2.setCodec( QTextCodec::codecForName("utf8") );
2233 //os.setEncoding( QTextStream::UnicodeUTF8 ); 2233 //os.setEncoding( QTextStream::UnicodeUTF8 );
2234 if ( KOPrefs::instance()->mWriteBackFile ) { 2234 if ( KOPrefs::instance()->mWriteBackFile ) {
2235 setCaption( i18n("Sending back synced file...") );
2235 os2 << "PUT " << mPassWordPiSync << "\r\n";; 2236 os2 << "PUT " << mPassWordPiSync << "\r\n";;
2236 while ( ! ts2.atEnd() ) { 2237 while ( ! ts2.atEnd() ) {
2237 os2 << ts2.readLine() << "\n"; 2238 os2 << ts2.readLine() << "\n";
2238 } 2239 }
2239 } else { 2240 } else {
2240 os2 << "STOP\r\n"; 2241 os2 << "STOP\r\n";
2241 } 2242 }
2242 mCommandSocketFinish->close(); 2243 mCommandSocketFinish->close();
2243 if ( mCommandSocketFinish->state() == QSocket::Idle ) 2244 if ( mCommandSocketFinish->state() == QSocket::Idle )
2244 deleteCommandSocketFinish(); 2245 QTimer::singleShot( 10, this , SLOT ( deleteCommandSocketFinish()));
2245 file.close(); 2246 file.close();
2246 qDebug("Syncing succesful! "); 2247 qDebug("Syncing succesful! ");
2247 setCaption( i18n("Pi-Sync succesful!") ); 2248 setCaption( i18n("Pi-Sync succesful!") );
2248 2249
2250 // KMessageBox::information( 0, i18n(" Pi-Sync succesful! "));
2249 2251
2250} 2252}
2251 2253
2252void MainWindow::syncLocalFile() 2254void MainWindow::syncLocalFile()
2253{ 2255{
2254 2256
2255 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 2257 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
2256 2258
2257 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2259 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2258 if ( fn == "" ) 2260 if ( fn == "" )
2259 return; 2261 return;
2260 //mView->setSyncDevice("local-file" ); 2262 //mView->setSyncDevice("local-file" );
2261 if ( syncWithFile( fn, false ) ) { 2263 if ( syncWithFile( fn, false ) ) {
2262 // Event* e = mView->getLastSyncEvent(); 2264 // Event* e = mView->getLastSyncEvent();
2263// e->setReadOnly( false ); 2265// e->setReadOnly( false );
2264// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2266// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2265// e->setReadOnly( true ); 2267// e->setReadOnly( true );
2266 } 2268 }
2267 2269
2268} 2270}
2269 2271
2270bool MainWindow::syncWithFile( QString fn , bool quick ) 2272bool MainWindow::syncWithFile( QString fn , bool quick )
2271{ 2273{
2272 bool ret = false; 2274 bool ret = false;
2273 QFileInfo info; 2275 QFileInfo info;
2274 info.setFile( fn ); 2276 info.setFile( fn );
2275 QString mess; 2277 QString mess;
2276 bool loadbup = true; 2278 bool loadbup = true;
2277 if ( !info. exists() ) { 2279 if ( !info. exists() ) {
2278 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2280 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2279 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2281 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2280 mess ); 2282 mess );
2281 return ret; 2283 return ret;
2282 } 2284 }
2283 int result = 0; 2285 int result = 0;
2284 if ( !quick ) { 2286 if ( !quick ) {
2285 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2287 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2286 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2288 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2287 mess, 2289 mess,
2288 i18n("Sync"), i18n("Cancel"), 0, 2290 i18n("Sync"), i18n("Cancel"), 0,
2289 0, 1 ); 2291 0, 1 );
2290 if ( result ) 2292 if ( result )
2291 return false; 2293 return false;
2292 } 2294 }
2293 if ( KOPrefs::instance()->mAskForPreferences ) 2295 if ( KOPrefs::instance()->mAskForPreferences )
2294 mView->edit_sync_options(); 2296 mView->edit_sync_options();
2295 if ( result == 0 ) { 2297 if ( result == 0 ) {
2296 //qDebug("Now sycing ... "); 2298 //qDebug("Now sycing ... ");
2297 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 2299 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
2298 setCaption( i18n("Synchronization successful") ); 2300 setCaption( i18n("Synchronization successful") );
2299 else 2301 else
2300 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 2302 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2301 if ( ! quick ) 2303 if ( ! quick )
2302 KOPrefs::instance()->mLastSyncedLocalFile = fn; 2304 KOPrefs::instance()->mLastSyncedLocalFile = fn;
2303 slotModifiedChanged( true ); 2305 slotModifiedChanged( true );
2304 } 2306 }
2305 return ret; 2307 return ret;
2306} 2308}
2307void MainWindow::quickSyncLocalFile() 2309void MainWindow::quickSyncLocalFile()
2308{ 2310{
2309 //mView->setSyncDevice("local-file" ); 2311 //mView->setSyncDevice("local-file" );
2310 //qDebug("quickSyncLocalFile() "); 2312 //qDebug("quickSyncLocalFile() ");
2311 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 2313 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2312 // Event* e = mView->getLastSyncEvent(); 2314 // Event* e = mView->getLastSyncEvent();
2313// e->setReadOnly( false ); 2315// e->setReadOnly( false );
2314// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2316// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2315// e->setReadOnly( true ); 2317// e->setReadOnly( true );
2316 2318
2317 } 2319 }
2318} 2320}
2319 2321
2320void MainWindow::confSync() 2322void MainWindow::confSync()
2321{ 2323{
2322 mView->confSync(); 2324 mView->confSync();
2323 fillSyncMenu(); 2325 fillSyncMenu();
2324} 2326}
2325void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 2327void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
2326{ 2328{
2327 QString question; 2329 QString question;
2328 if ( ask ) { 2330 if ( ask ) {
2329 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 2331 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
2330 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2332 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2331 question, 2333 question,
2332 i18n("Yes"), i18n("No"), 2334 i18n("Yes"), i18n("No"),
2333 0, 0 ) != 0 ) 2335 0, 0 ) != 0 )
2334 return; 2336 return;
2335 } 2337 }
2336 QString command = prof->getPreSyncCommand(); 2338 QString command = prof->getPreSyncCommand();
2337 int fi; 2339 int fi;
2338 if ( (fi = command.find("$PWD$")) > 0 ) { 2340 if ( (fi = command.find("$PWD$")) > 0 ) {
2339 QString pwd = getPassword(); 2341 QString pwd = getPassword();
2340 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2342 command = command.left( fi )+ pwd + command.mid( fi+5 );
2341 2343
2342 } 2344 }
2343 int maxlen = 30; 2345 int maxlen = 30;
2344 if ( QApplication::desktop()->width() > 320 ) 2346 if ( QApplication::desktop()->width() > 320 )
2345 maxlen += 25; 2347 maxlen += 25;
2346 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2348 setCaption ( i18n( "Copy remote file to local machine..." ) );
2347 int fileSize = 0; 2349 int fileSize = 0;
2348 int result = system ( command ); 2350 int result = system ( command );
2349 // 0 : okay 2351 // 0 : okay
2350 // 256: no such file or dir 2352 // 256: no such file or dir
2351 // 2353 //
2352 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2354 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2353 if ( result != 0 ) { 2355 if ( result != 0 ) {
2354 int len = maxlen; 2356 int len = maxlen;
2355 while ( len < command.length() ) { 2357 while ( len < command.length() ) {
2356 command.insert( len , "\n" ); 2358 command.insert( len , "\n" );
2357 len += maxlen +2; 2359 len += maxlen +2;
2358 } 2360 }
2359 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) ; 2361 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) ;
2360 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2362 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2361 question, 2363 question,
2362 i18n("Okay!")) ; 2364 i18n("Okay!")) ;
2363 setCaption ("KO/Pi"); 2365 setCaption ("KO/Pi");
2364 return; 2366 return;
2365 } 2367 }
2366 setCaption ( i18n( "Copying succeed." ) ); 2368 setCaption ( i18n( "Copying succeed." ) );
2367 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 2369 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
2368 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 2370 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
2369// Event* e = mView->getLastSyncEvent(); 2371// Event* e = mView->getLastSyncEvent();
2370// e->setReadOnly( false ); 2372// e->setReadOnly( false );
2371// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2373// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2372// e->setReadOnly( true ); 2374// e->setReadOnly( true );
2373 if ( KOPrefs::instance()->mWriteBackFile ) { 2375 if ( KOPrefs::instance()->mWriteBackFile ) {
2374 command = prof->getPostSyncCommand(); 2376 command = prof->getPostSyncCommand();
2375 int fi; 2377 int fi;
2376 if ( (fi = command.find("$PWD$")) > 0 ) { 2378 if ( (fi = command.find("$PWD$")) > 0 ) {
2377 QString pwd = getPassword(); 2379 QString pwd = getPassword();
2378 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2380 command = command.left( fi )+ pwd + command.mid( fi+5 );
2379 2381
2380 } 2382 }
2381 setCaption ( i18n( "Writing back file ..." ) ); 2383 setCaption ( i18n( "Writing back file ..." ) );
2382 result = system ( command ); 2384 result = system ( command );
2383 qDebug("KO: Writing back file result: %d ", result); 2385 qDebug("KO: Writing back file result: %d ", result);
2384 if ( result != 0 ) { 2386 if ( result != 0 ) {
2385 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 2387 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
2386 return; 2388 return;
2387 } else { 2389 } else {
2388 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2390 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2389 } 2391 }
2390 } 2392 }
2391 } 2393 }
2392 return; 2394 return;
2393} 2395}
2394void MainWindow::syncSSH() 2396void MainWindow::syncSSH()
2395{ 2397{
2396 // not used anymore 2398 // not used anymore
2397 QTime timer; 2399 QTime timer;
2398 timer.start(); 2400 timer.start();
2399 //qDebug("MainWindow::syncssh() "); 2401 //qDebug("MainWindow::syncssh() ");
2400 KOPrefs *p = KOPrefs::instance(); 2402 KOPrefs *p = KOPrefs::instance();
2401 QString localFile = p->mLocalTempFile; 2403 QString localFile = p->mLocalTempFile;
2402 QString remoteIP = p->mRemoteIP; 2404 QString remoteIP = p->mRemoteIP;
2403 QString remoteUser = p->mRemoteUser; 2405 QString remoteUser = p->mRemoteUser;
2404 QString remoteFile = p->mRemoteFile; 2406 QString remoteFile = p->mRemoteFile;
2405 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 2407 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
2406 remoteUser += ":" + p->mRemotePassWd; 2408 remoteUser += ":" + p->mRemotePassWd;
2407 2409
2408 QString question = i18n("Do you really want\nto remote sync?\n \n") + 2410 QString question = i18n("Do you really want\nto remote sync?\n \n") +
2409 i18n("IP: " ) +remoteIP +"\n" + 2411 i18n("IP: " ) +remoteIP +"\n" +
2410 i18n("User: " ) + remoteUser +"\n" ; 2412 i18n("User: " ) + remoteUser +"\n" ;
2411 int maxlen = 30; 2413 int maxlen = 30;
2412 if ( QApplication::desktop()->width() > 320 ) 2414 if ( QApplication::desktop()->width() > 320 )
2413 maxlen += 25; 2415 maxlen += 25;
2414 if ( remoteFile.length() > maxlen ) 2416 if ( remoteFile.length() > maxlen )
2415 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 2417 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
2416 else 2418 else
2417 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 2419 question += i18n("Remote file:\n " ) + remoteFile +"\n";
2418 if ( localFile.length() > maxlen ) 2420 if ( localFile.length() > maxlen )
2419 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 2421 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
2420 else 2422 else
2421 question += i18n("Local temp file:\n " ) + localFile +"\n"; 2423 question += i18n("Local temp file:\n " ) + localFile +"\n";
2422 2424
2423 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2425 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2424 question, 2426 question,
2425 i18n("Yes"), i18n("No"), 2427 i18n("Yes"), i18n("No"),
2426 0, 0 ) != 0 ) 2428 0, 0 ) != 0 )
2427 return; 2429 return;
2428 // if ( !p->mUsePassWd ) { 2430 // if ( !p->mUsePassWd ) {
2429 // QString pass = getPassword(); 2431 // QString pass = getPassword();
2430 // if ( pass.length() > 0 ) 2432 // if ( pass.length() > 0 )
2431 // remoteUser += ":" + pass; 2433 // remoteUser += ":" + pass;
2432 // } 2434 // }
2433 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 2435 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
2434 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2436 setCaption ( i18n( "Copy remote file to local machine..." ) );
2435 int fileSize = 0; 2437 int fileSize = 0;
2436 int result = system ( command ); 2438 int result = system ( command );
2437 // 0 : okay 2439 // 0 : okay
2438 // 256: no such file or dir 2440 // 256: no such file or dir
2439 // 2441 //
2440 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2442 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2441 if ( result != 0 ) { 2443 if ( result != 0 ) {
2442 int len = maxlen; 2444 int len = maxlen;
2443 while ( len < command.length() ) { 2445 while ( len < command.length() ) {
2444 command.insert( len , "\n" ); 2446 command.insert( len , "\n" );
2445 len += maxlen +2; 2447 len += maxlen +2;
2446 } 2448 }
2447 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) ; 2449 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) ;
2448 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2450 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2449 question, 2451 question,
2450 i18n("Okay!")) ; 2452 i18n("Okay!")) ;
2451 setCaption ("KO/Pi"); 2453 setCaption ("KO/Pi");
2452 return; 2454 return;
2453 } 2455 }
2454 2456
2455 2457
2456 setCaption ( i18n( "Copying succeed." ) ); 2458 setCaption ( i18n( "Copying succeed." ) );
2457 //mView->setSyncDevice("ssh-scp" ); 2459 //mView->setSyncDevice("ssh-scp" );
2458 if ( syncWithFile(localFile , true ) ) { 2460 if ( syncWithFile(localFile , true ) ) {
2459// Event* e = mView->getLastSyncEvent(); 2461// Event* e = mView->getLastSyncEvent();
2460// e->setReadOnly( false ); 2462// e->setReadOnly( false );
2461// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2463// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2462// e->setReadOnly( true ); 2464// e->setReadOnly( true );
2463 if ( KOPrefs::instance()->mWriteBackFile ) { 2465 if ( KOPrefs::instance()->mWriteBackFile ) {
2464 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 2466 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
2465 setCaption ( i18n( "Writing back file ..." ) ); 2467 setCaption ( i18n( "Writing back file ..." ) );
2466 result = system ( command ); 2468 result = system ( command );
2467 if ( result != 0 ) { 2469 if ( result != 0 ) {
2468 int len = maxlen; 2470 int len = maxlen;
2469 while ( len < command.length() ) { 2471 while ( len < command.length() ) {
2470 command.insert( len , "\n" ); 2472 command.insert( len , "\n" );
2471 len += maxlen +2; 2473 len += maxlen +2;
2472 } 2474 }
2473 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) ; 2475 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) ;
2474 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2476 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2475 question, 2477 question,
2476 i18n("Okay!")) ; 2478 i18n("Okay!")) ;
2477 setCaption ("KO/Pi"); 2479 setCaption ("KO/Pi");
2478 return; 2480 return;
2479 } else { 2481 } else {
2480 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2482 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2481 } 2483 }
2482 } 2484 }
2483 } 2485 }
2484 return; 2486 return;
2485#if 0 2487#if 0
2486 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 2488 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
2487 while ( timer.elapsed() < 5000 ) 2489 while ( timer.elapsed() < 5000 )
2488 qApp->processEvents(); 2490 qApp->processEvents();
2489 2491
2490 qDebug("MainWindow::merging) "); 2492 qDebug("MainWindow::merging) ");
2491 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 2493 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
2492 while ( mBlockSaveFlag ) 2494 while ( mBlockSaveFlag )
2493 qApp->processEvents(); 2495 qApp->processEvents();
2494 save(); 2496 save();
2495 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 2497 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
2496#endif 2498#endif
2497 2499
2498} 2500}
2499 2501
2500 2502
2501void MainWindow::syncSharp() 2503void MainWindow::syncSharp()
2502{ 2504{
2503 if ( mCalendarModifiedFlag ) 2505 if ( mCalendarModifiedFlag )
2504 save(); 2506 save();
2505 mView->syncSharp(); 2507 mView->syncSharp();
2506 slotModifiedChanged( true ); 2508 slotModifiedChanged( true );
2507 2509
2508} 2510}
2509void MainWindow::syncPhone() 2511void MainWindow::syncPhone()
2510{ 2512{
2511 if ( mCalendarModifiedFlag ) 2513 if ( mCalendarModifiedFlag )
2512 save(); 2514 save();
2513 mView->syncPhone(); 2515 mView->syncPhone();
2514 slotModifiedChanged( true ); 2516 slotModifiedChanged( true );
2515 2517
2516} 2518}
2517 2519
2518void MainWindow::printSel( ) 2520void MainWindow::printSel( )
2519{ 2521{
2520 mView->viewManager()->agendaView()->agenda()->printSelection(); 2522 mView->viewManager()->agendaView()->agenda()->printSelection();
2521} 2523}
2522 2524
2523void MainWindow::printCal() 2525void MainWindow::printCal()
2524{ 2526{
2525 mView->print();//mCp->showDialog(); 2527 mView->print();//mCp->showDialog();
2526} 2528}
2527 2529
2528 2530
2529 2531
2530KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 2532KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
2531{ 2533{
2532 mPassWord = pw; 2534 mPassWord = pw;
2533 mSocket = 0; 2535 mSocket = 0;
2534}; 2536};
2535 2537
2536void KServerSocket::newConnection ( int socket ) 2538void KServerSocket::newConnection ( int socket )
2537{ 2539{
2538 qDebug("KServerSocket:New connection %d ", socket); 2540 qDebug("KServerSocket:New connection %d ", socket);
2539 if ( mSocket ) { 2541 if ( mSocket ) {
2540 qDebug("KServerSocket::newConnection Socket deleted! "); 2542 qDebug("KServerSocket::newConnection Socket deleted! ");
2541 delete mSocket; 2543 delete mSocket;
2542 mSocket = 0; 2544 mSocket = 0;
2543 } 2545 }
2544 mSocket = new QSocket( this ); 2546 mSocket = new QSocket( this );
2545 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 2547 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
2546 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 2548 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
2547 mSocket->setSocket( socket ); 2549 mSocket->setSocket( socket );
2548} 2550}
2549 2551
2550void KServerSocket::discardClient() 2552void KServerSocket::discardClient()
2551{ 2553{
2552 qDebug(" KServerSocket::discardClient()"); 2554 qDebug(" KServerSocket::discardClient()");
2553 if ( mSocket ) { 2555 if ( mSocket ) {
2554 qDebug("delete "); 2556 qDebug("delete ");
2555 delete mSocket; 2557 delete mSocket;
2556 mSocket = 0; 2558 mSocket = 0;
2557 } 2559 }
2558 //emit endConnect(); 2560 //emit endConnect();
2559} 2561}
2560void KServerSocket::readClient() 2562void KServerSocket::readClient()
2561{ 2563{
2562 if ( mSocket == 0 ) { 2564 if ( mSocket == 0 ) {
2563 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 2565 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
2564 return; 2566 return;
2565 } 2567 }
2566 qDebug("KServerSocket readClient()"); 2568 qDebug("KServerSocket readClient()");
2567 if ( mSocket->canReadLine() ) { 2569 if ( mSocket->canReadLine() ) {
2568 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); 2570 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() );
2569 qDebug("KServerSocket socket->canReadLine()"); 2571 qDebug("KServerSocket socket->canReadLine()");
2570 if ( tokens[0] == "GET" ) { 2572 if ( tokens[0] == "GET" ) {
2571 if ( tokens[1] == mPassWord ) 2573 if ( tokens[1] == mPassWord )
2572 emit sendFile( mSocket ); 2574 emit sendFile( mSocket );
2573 else { 2575 else {
2574 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); 2576 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password"));
2575 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 2577 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2576 } 2578 }
2577 } 2579 }
2578 if ( tokens[0] == "PUT" ) { 2580 if ( tokens[0] == "PUT" ) {
2579 if ( tokens[1] == mPassWord ) 2581 if ( tokens[1] == mPassWord )
2580 emit getFile( mSocket ); 2582 emit getFile( mSocket );
2581 else { 2583 else {
2582 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); 2584 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
2583 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 2585 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2584 } 2586 }
2585 } 2587 }
2586 if ( tokens[0] == "STOP" ) { 2588 if ( tokens[0] == "STOP" ) {
2587 emit endConnect(); 2589 emit endConnect();
2588 } 2590 }
2589 } 2591 }
2590} 2592}
2591 2593
2592 2594
2593 2595
2594 2596
2595 2597
2596 2598
2597 2599
2598 2600
2599 2601
2600 2602
2601 2603
2602 2604