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