author | zautrix <zautrix> | 2004-09-23 07:35:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-23 07:35:02 (UTC) |
commit | e395b9a15f5047582c17665de85d28dad64b8a8e (patch) (unidiff) | |
tree | 141b178531d66bfeb810cf9b6f2ba1cd54a7fce5 | |
parent | e2bc785d2f98d2aeac6ab6a5e39ff4f6e679517b (diff) | |
download | kdepimpi-e395b9a15f5047582c17665de85d28dad64b8a8e.zip kdepimpi-e395b9a15f5047582c17665de85d28dad64b8a8e.tar.gz kdepimpi-e395b9a15f5047582c17665de85d28dad64b8a8e.tar.bz2 |
fixes in kopi
-rw-r--r-- | korganizer/mainwindow.cpp | 105 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 38 |
2 files changed, 101 insertions, 42 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 2e6b5c8..460bbdc 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,122 +1,124 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | ||
7 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
8 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
9 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
10 | #include <qfile.h> | 11 | #include <qfile.h> |
11 | #include <qdir.h> | 12 | #include <qdir.h> |
12 | #include <qapp.h> | 13 | #include <qapp.h> |
13 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
14 | #include <qlabel.h> | 15 | #include <qlabel.h> |
15 | #include <qmap.h> | 16 | #include <qmap.h> |
16 | #include <qwmatrix.h> | 17 | #include <qwmatrix.h> |
17 | #include <qtextbrowser.h> | 18 | #include <qtextbrowser.h> |
18 | #include <qtextstream.h> | 19 | #include <qtextstream.h> |
19 | #ifndef DESKTOP_VERSION | 20 | #ifndef DESKTOP_VERSION |
20 | #include <qpe/global.h> | 21 | #include <qpe/global.h> |
21 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
24 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
25 | #include <qtopia/alarmserver.h> | 26 | #include <qtopia/alarmserver.h> |
26 | #include <qtopia/qcopenvelope_qws.h> | 27 | #include <qtopia/qcopenvelope_qws.h> |
28 | #include <unistd.h> // for sleep | ||
27 | #else | 29 | #else |
28 | #include <qmenubar.h> | 30 | #include <qmenubar.h> |
29 | #include <qtoolbar.h> | 31 | #include <qtoolbar.h> |
30 | #include <qapplication.h> | 32 | #include <qapplication.h> |
31 | //#include <resource.h> | 33 | //#include <resource.h> |
32 | 34 | ||
33 | #endif | 35 | #endif |
34 | #include <libkcal/calendarlocal.h> | 36 | #include <libkcal/calendarlocal.h> |
35 | #include <libkcal/todo.h> | 37 | #include <libkcal/todo.h> |
36 | #include <libkdepim/ksyncprofile.h> | 38 | #include <libkdepim/ksyncprofile.h> |
37 | #include <libkcal/kincidenceformatter.h> | 39 | #include <libkcal/kincidenceformatter.h> |
38 | #include <libkdepim/kpimglobalprefs.h> | 40 | #include <libkdepim/kpimglobalprefs.h> |
39 | 41 | ||
40 | #include "calendarview.h" | 42 | #include "calendarview.h" |
41 | #include "koviewmanager.h" | 43 | #include "koviewmanager.h" |
42 | #include "datenavigator.h" | 44 | #include "datenavigator.h" |
43 | #include "koagendaview.h" | 45 | #include "koagendaview.h" |
44 | #include "koagenda.h" | 46 | #include "koagenda.h" |
45 | #include "kodialogmanager.h" | 47 | #include "kodialogmanager.h" |
46 | #include "kdialogbase.h" | 48 | #include "kdialogbase.h" |
47 | #include "kapplication.h" | 49 | #include "kapplication.h" |
48 | #include "kofilterview.h" | 50 | #include "kofilterview.h" |
49 | #include "kstandarddirs.h" | 51 | #include "kstandarddirs.h" |
50 | #include "koprefs.h" | 52 | #include "koprefs.h" |
51 | #include "kfiledialog.h" | 53 | #include "kfiledialog.h" |
52 | #include "koglobals.h" | 54 | #include "koglobals.h" |
53 | #include "kglobal.h" | 55 | #include "kglobal.h" |
54 | #include "klocale.h" | 56 | #include "klocale.h" |
55 | #include "kconfig.h" | 57 | #include "kconfig.h" |
56 | #include "simplealarmclient.h" | 58 | #include "simplealarmclient.h" |
57 | #include "externalapphandler.h" | 59 | #include "externalapphandler.h" |
58 | 60 | ||
59 | using namespace KCal; | 61 | using namespace KCal; |
60 | #ifndef _WIN32_ | 62 | #ifndef _WIN32_ |
61 | #include <unistd.h> | 63 | #include <unistd.h> |
62 | #else | 64 | #else |
63 | #include "koimportoldialog.h" | 65 | #include "koimportoldialog.h" |
64 | #endif | 66 | #endif |
65 | #include "mainwindow.h" | 67 | #include "mainwindow.h" |
66 | 68 | ||
67 | int globalFlagBlockStartup; | 69 | int globalFlagBlockStartup; |
68 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 70 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
69 | QMainWindow( parent, name ) | 71 | QMainWindow( parent, name ) |
70 | { | 72 | { |
71 | 73 | ||
72 | #ifdef DESKTOP_VERSION | 74 | #ifdef DESKTOP_VERSION |
73 | setFont( QFont("Arial"), 14 ); | 75 | setFont( QFont("Arial"), 14 ); |
74 | #endif | 76 | #endif |
75 | mCommandSocket = 0; | 77 | mCommandSocket = 0; |
76 | mCommandSocketFinish = 0; | 78 | mCommandSocketFinish = 0; |
77 | mSyncActionDialog = 0; | 79 | mSyncActionDialog = 0; |
78 | mServerSocket = 0; | 80 | mServerSocket = 0; |
79 | mClosed = false; | 81 | mClosed = false; |
80 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 82 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
81 | QString confFile = locateLocal("config","korganizerrc"); | 83 | QString confFile = locateLocal("config","korganizerrc"); |
82 | QFileInfo finf ( confFile ); | 84 | QFileInfo finf ( confFile ); |
83 | bool showWarning = !finf.exists(); | 85 | bool showWarning = !finf.exists(); |
84 | setIcon(SmallIcon( "ko24" ) ); | 86 | setIcon(SmallIcon( "ko24" ) ); |
85 | mBlockAtStartup = true; | 87 | mBlockAtStartup = true; |
86 | mFlagKeyPressed = false; | 88 | mFlagKeyPressed = false; |
87 | setCaption("KOrganizer/Pi"); | 89 | setCaption("KOrganizer/Pi"); |
88 | KOPrefs *p = KOPrefs::instance(); | 90 | KOPrefs *p = KOPrefs::instance(); |
89 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 91 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
90 | // if ( QApplication::desktop()->height() > 480 ) { | 92 | // if ( QApplication::desktop()->height() > 480 ) { |
91 | // if ( p->mHourSize == 4 ) | 93 | // if ( p->mHourSize == 4 ) |
92 | // p->mHourSize = 6; | 94 | // p->mHourSize = 6; |
93 | // } | 95 | // } |
94 | if ( p->mHourSize > 18 ) | 96 | if ( p->mHourSize > 18 ) |
95 | p->mHourSize = 18; | 97 | p->mHourSize = 18; |
96 | QMainWindow::ToolBarDock tbd; | 98 | QMainWindow::ToolBarDock tbd; |
97 | if ( p->mToolBarHor ) { | 99 | if ( p->mToolBarHor ) { |
98 | if ( p->mToolBarUp ) | 100 | if ( p->mToolBarUp ) |
99 | tbd = Bottom; | 101 | tbd = Bottom; |
100 | else | 102 | else |
101 | tbd = Top; | 103 | tbd = Top; |
102 | } | 104 | } |
103 | else { | 105 | else { |
104 | if ( p->mToolBarUp ) | 106 | if ( p->mToolBarUp ) |
105 | tbd = Right; | 107 | tbd = Right; |
106 | else | 108 | else |
107 | tbd = Left; | 109 | tbd = Left; |
108 | } | 110 | } |
109 | if ( KOPrefs::instance()->mUseAppColors ) | 111 | if ( KOPrefs::instance()->mUseAppColors ) |
110 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 112 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
111 | globalFlagBlockStartup = 1; | 113 | globalFlagBlockStartup = 1; |
112 | iconToolBar = new QPEToolBar( this ); | 114 | iconToolBar = new QPEToolBar( this ); |
113 | addToolBar (iconToolBar , tbd ); | 115 | addToolBar (iconToolBar , tbd ); |
114 | mBlockSaveFlag = false; | 116 | mBlockSaveFlag = false; |
115 | mCalendarModifiedFlag = false; | 117 | mCalendarModifiedFlag = false; |
116 | 118 | ||
117 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 119 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
118 | splash->setAlignment ( AlignCenter ); | 120 | splash->setAlignment ( AlignCenter ); |
119 | setCentralWidget( splash ); | 121 | setCentralWidget( splash ); |
120 | #ifndef DESKTOP_VERSION | 122 | #ifndef DESKTOP_VERSION |
121 | showMaximized(); | 123 | showMaximized(); |
122 | #endif | 124 | #endif |
@@ -1053,198 +1055,193 @@ void MainWindow::slotSyncMenu( int action ) | |||
1053 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 1055 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
1054 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 1056 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
1055 | KSyncProfile* temp = new KSyncProfile (); | 1057 | KSyncProfile* temp = new KSyncProfile (); |
1056 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 1058 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
1057 | temp->readConfig(&config); | 1059 | temp->readConfig(&config); |
1058 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1060 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
1059 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 1061 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
1060 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1062 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1061 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1063 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1062 | KOPrefs::instance()->mWriteBackInFuture = 0; | 1064 | KOPrefs::instance()->mWriteBackInFuture = 0; |
1063 | if ( temp->getWriteBackFuture() ) | 1065 | if ( temp->getWriteBackFuture() ) |
1064 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 1066 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
1065 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 1067 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
1066 | if ( action == 1000 ) { | 1068 | if ( action == 1000 ) { |
1067 | syncSharp(); | 1069 | syncSharp(); |
1068 | 1070 | ||
1069 | } else if ( action == 1001 ) { | 1071 | } else if ( action == 1001 ) { |
1070 | syncLocalFile(); | 1072 | syncLocalFile(); |
1071 | 1073 | ||
1072 | } else if ( action == 1002 ) { | 1074 | } else if ( action == 1002 ) { |
1073 | quickSyncLocalFile(); | 1075 | quickSyncLocalFile(); |
1074 | 1076 | ||
1075 | } else if ( action >= 1003 ) { | 1077 | } else if ( action >= 1003 ) { |
1076 | if ( temp->getIsLocalFileSync() ) { | 1078 | if ( temp->getIsLocalFileSync() ) { |
1077 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 1079 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
1078 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1080 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1079 | } else { | 1081 | } else { |
1080 | if ( temp->getIsPhoneSync() ) { | 1082 | if ( temp->getIsPhoneSync() ) { |
1081 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1083 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1082 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1084 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1083 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1085 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1084 | syncPhone(); | 1086 | syncPhone(); |
1085 | } else | 1087 | } else |
1086 | syncRemote( temp ); | 1088 | syncRemote( temp ); |
1087 | 1089 | ||
1088 | } | 1090 | } |
1089 | } | 1091 | } |
1090 | delete temp; | 1092 | delete temp; |
1091 | mBlockSaveFlag = false; | 1093 | mBlockSaveFlag = false; |
1092 | } | 1094 | } |
1093 | void MainWindow::setDefaultPreferences() | 1095 | void MainWindow::setDefaultPreferences() |
1094 | { | 1096 | { |
1095 | KOPrefs *p = KOPrefs::instance(); | 1097 | KOPrefs *p = KOPrefs::instance(); |
1096 | 1098 | ||
1097 | p->mCompactDialogs = true; | 1099 | p->mCompactDialogs = true; |
1098 | p->mConfirm = true; | 1100 | p->mConfirm = true; |
1099 | // p->mEnableQuickTodo = false; | 1101 | // p->mEnableQuickTodo = false; |
1100 | } | 1102 | } |
1101 | 1103 | ||
1102 | QString MainWindow::resourcePath() | 1104 | QString MainWindow::resourcePath() |
1103 | { | 1105 | { |
1104 | return KGlobal::iconLoader()->iconPath(); | 1106 | return KGlobal::iconLoader()->iconPath(); |
1105 | } | 1107 | } |
1106 | 1108 | ||
1107 | void MainWindow::displayText( QString text ,QString cap ) | 1109 | void MainWindow::displayText( QString text ,QString cap ) |
1108 | { | 1110 | { |
1109 | QDialog dia( this, "name", true ); ; | 1111 | QDialog dia( this, "name", true ); ; |
1110 | dia.setCaption( cap ); | 1112 | dia.setCaption( cap ); |
1111 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1113 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1112 | lay->setSpacing( 3 ); | 1114 | lay->setSpacing( 3 ); |
1113 | lay->setMargin( 3 ); | 1115 | lay->setMargin( 3 ); |
1114 | QTextBrowser tb ( &dia ); | 1116 | QTextBrowser tb ( &dia ); |
1115 | lay->addWidget( &tb ); | 1117 | lay->addWidget( &tb ); |
1116 | tb.setText( text ); | 1118 | tb.setText( text ); |
1117 | #ifdef DESKTOP_VERSION | 1119 | #ifdef DESKTOP_VERSION |
1118 | dia.resize( 640, 480); | 1120 | dia.resize( 640, 480); |
1119 | #else | 1121 | #else |
1120 | dia.showMaximized(); | 1122 | dia.showMaximized(); |
1121 | #endif | 1123 | #endif |
1122 | dia.exec(); | 1124 | dia.exec(); |
1123 | } | 1125 | } |
1124 | void MainWindow::displayFile( QString fn, QString cap ) | 1126 | void MainWindow::displayFile( QString fn, QString cap ) |
1125 | { | 1127 | { |
1126 | QString fileName = resourcePath() + fn; | 1128 | QString fileName = resourcePath() + fn; |
1127 | QString text; | 1129 | QString text; |
1128 | QFile file( fileName ); | 1130 | QFile file( fileName ); |
1129 | if (!file.open( IO_ReadOnly ) ) { | 1131 | if (!file.open( IO_ReadOnly ) ) { |
1130 | return ; | 1132 | return ; |
1131 | 1133 | ||
1132 | } | 1134 | } |
1133 | QTextStream ts( &file ); | 1135 | QTextStream ts( &file ); |
1134 | text = ts.read(); | 1136 | text = ts.read(); |
1135 | file.close(); | 1137 | file.close(); |
1136 | displayText( text, cap); | 1138 | displayText( text, cap); |
1137 | } | 1139 | } |
1138 | void MainWindow::features() | 1140 | void MainWindow::features() |
1139 | { | 1141 | { |
1140 | 1142 | ||
1141 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1143 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1142 | } | 1144 | } |
1143 | 1145 | ||
1144 | void MainWindow::usertrans() | 1146 | void MainWindow::usertrans() |
1145 | { | 1147 | { |
1146 | 1148 | ||
1147 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1149 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1148 | } | 1150 | } |
1149 | #if 0 | 1151 | |
1150 | #include <libkcal/vcalformat.h> | ||
1151 | #include <libkcal/event.h> | ||
1152 | #include <libkcal/todo.h> | ||
1153 | #include <libkcal/incidence.h> | ||
1154 | #endif | ||
1155 | void MainWindow::synchowto() | 1152 | void MainWindow::synchowto() |
1156 | { | 1153 | { |
1157 | #if 0 | 1154 | #if 0 |
1158 | QPtrList<Incidence> er = mCalendar->rawIncidences(); | 1155 | QPtrList<Incidence> er = mCalendar->rawIncidences(); |
1159 | Incidence* inR = er.first(); | 1156 | Incidence* inR = er.first(); |
1160 | VCalFormat vf; | 1157 | VCalFormat vf; |
1161 | QString strout; | 1158 | QString strout; |
1162 | while ( inR ) { | 1159 | while ( inR ) { |
1163 | if ( inR->type() == "Todo" ) | 1160 | if ( inR->type() == "Todo" ) |
1164 | strout = vf.todoToString( (Todo *) inR ); | 1161 | strout = vf.todoToString( (Todo *) inR ); |
1165 | if ( inR->type() == "Event" ) | 1162 | if ( inR->type() == "Event" ) |
1166 | strout = vf.eventToString( (Event *) inR ); | 1163 | strout = vf.eventToString( (Event *) inR ); |
1167 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); | 1164 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); |
1168 | inR = er.next(); | 1165 | inR = er.next(); |
1169 | } | 1166 | } |
1170 | #endif | 1167 | #endif |
1171 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); | 1168 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); |
1172 | } | 1169 | } |
1173 | void MainWindow::faq() | 1170 | void MainWindow::faq() |
1174 | { | 1171 | { |
1175 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1172 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1176 | 1173 | ||
1177 | } | 1174 | } |
1178 | void MainWindow::whatsNew() | 1175 | void MainWindow::whatsNew() |
1179 | { | 1176 | { |
1180 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); | 1177 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); |
1181 | 1178 | ||
1182 | } | 1179 | } |
1183 | void MainWindow::licence() | 1180 | void MainWindow::licence() |
1184 | { | 1181 | { |
1185 | KApplication::showLicence(); | 1182 | KApplication::showLicence(); |
1186 | 1183 | ||
1187 | } | 1184 | } |
1188 | void MainWindow::about() | 1185 | void MainWindow::about() |
1189 | { | 1186 | { |
1190 | QString version; | 1187 | QString version; |
1191 | #include <../version> | 1188 | #include <../version> |
1192 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1189 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1193 | i18n("KOrganizer/Platform-independent\n") + | 1190 | i18n("KOrganizer/Platform-independent\n") + |
1194 | "(KO/Pi) " + version + " - " + | 1191 | "(KO/Pi) " + version + " - " + |
1195 | 1192 | ||
1196 | #ifdef DESKTOP_VERSION | 1193 | #ifdef DESKTOP_VERSION |
1197 | i18n("Desktop Edition\n") + | 1194 | i18n("Desktop Edition\n") + |
1198 | #else | 1195 | #else |
1199 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1196 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1200 | #endif | 1197 | #endif |
1201 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); | 1198 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); |
1202 | } | 1199 | } |
1203 | void MainWindow::keyBindings() | 1200 | void MainWindow::keyBindings() |
1204 | { | 1201 | { |
1205 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1202 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1206 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1203 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1207 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1204 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1208 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1205 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1209 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1206 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1210 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1207 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1211 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1208 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1212 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1209 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1213 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1210 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1214 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1211 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1215 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1212 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1216 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1213 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1217 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1214 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1218 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1215 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1219 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1216 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1220 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1217 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1221 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1218 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1222 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1219 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1223 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1220 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1224 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1221 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1225 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1222 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1226 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1223 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1227 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1224 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1228 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1225 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1229 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1226 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1230 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1227 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1231 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1228 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1232 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1229 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1233 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1230 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1234 | i18n("<p><h3>In list view:</h3></p>\n") + | 1231 | i18n("<p><h3>In list view:</h3></p>\n") + |
1235 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1232 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1236 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1233 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1237 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1234 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1238 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1235 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1239 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1236 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1240 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1237 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1241 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1238 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1242 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1239 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1243 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1240 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1244 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1241 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1245 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1242 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1246 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1243 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1247 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1244 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1248 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1245 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1249 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1246 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1250 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1247 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
@@ -1335,193 +1332,192 @@ void MainWindow::processIncidenceSelection( Incidence *incidence ) | |||
1335 | mShowAction->setText( i18n("Show Event...") ); | 1332 | mShowAction->setText( i18n("Show Event...") ); |
1336 | mEditAction->setText( i18n("Edit Event...") ); | 1333 | mEditAction->setText( i18n("Edit Event...") ); |
1337 | mDeleteAction->setText( i18n("Delete Event...") ); | 1334 | mDeleteAction->setText( i18n("Delete Event...") ); |
1338 | 1335 | ||
1339 | mNewSubTodoAction->setEnabled( false ); | 1336 | mNewSubTodoAction->setEnabled( false ); |
1340 | } else if ( incidence->type() == "Todo" ) { | 1337 | } else if ( incidence->type() == "Todo" ) { |
1341 | mShowAction->setText( i18n("Show Todo...") ); | 1338 | mShowAction->setText( i18n("Show Todo...") ); |
1342 | mEditAction->setText( i18n("Edit Todo...") ); | 1339 | mEditAction->setText( i18n("Edit Todo...") ); |
1343 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1340 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1344 | 1341 | ||
1345 | mNewSubTodoAction->setEnabled( true ); | 1342 | mNewSubTodoAction->setEnabled( true ); |
1346 | } else { | 1343 | } else { |
1347 | mShowAction->setText( i18n("Show...") ); | 1344 | mShowAction->setText( i18n("Show...") ); |
1348 | mShowAction->setText( i18n("Edit...") ); | 1345 | mShowAction->setText( i18n("Edit...") ); |
1349 | mShowAction->setText( i18n("Delete...") ); | 1346 | mShowAction->setText( i18n("Delete...") ); |
1350 | 1347 | ||
1351 | mNewSubTodoAction->setEnabled( false ); | 1348 | mNewSubTodoAction->setEnabled( false ); |
1352 | } | 1349 | } |
1353 | } | 1350 | } |
1354 | 1351 | ||
1355 | void MainWindow::enableIncidenceActions( bool enabled ) | 1352 | void MainWindow::enableIncidenceActions( bool enabled ) |
1356 | { | 1353 | { |
1357 | mShowAction->setEnabled( enabled ); | 1354 | mShowAction->setEnabled( enabled ); |
1358 | mEditAction->setEnabled( enabled ); | 1355 | mEditAction->setEnabled( enabled ); |
1359 | mDeleteAction->setEnabled( enabled ); | 1356 | mDeleteAction->setEnabled( enabled ); |
1360 | } | 1357 | } |
1361 | 1358 | ||
1362 | void MainWindow::importOL() | 1359 | void MainWindow::importOL() |
1363 | { | 1360 | { |
1364 | #ifdef _WIN32_ | 1361 | #ifdef _WIN32_ |
1365 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1362 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1366 | id->exec(); | 1363 | id->exec(); |
1367 | delete id; | 1364 | delete id; |
1368 | mView->updateView(); | 1365 | mView->updateView(); |
1369 | #endif | 1366 | #endif |
1370 | } | 1367 | } |
1371 | void MainWindow::importBday() | 1368 | void MainWindow::importBday() |
1372 | { | 1369 | { |
1373 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1370 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1374 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1371 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1375 | i18n("Import!"), i18n("Cancel"), 0, | 1372 | i18n("Import!"), i18n("Cancel"), 0, |
1376 | 0, 1 ); | 1373 | 0, 1 ); |
1377 | if ( result == 0 ) { | 1374 | if ( result == 0 ) { |
1378 | mView->importBday(); | 1375 | mView->importBday(); |
1379 | 1376 | ||
1380 | } | 1377 | } |
1381 | 1378 | ||
1382 | 1379 | ||
1383 | } | 1380 | } |
1384 | void MainWindow::importQtopia() | 1381 | void MainWindow::importQtopia() |
1385 | { | 1382 | { |
1386 | #ifndef DESKTOP_VERSION | 1383 | #ifndef DESKTOP_VERSION |
1387 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1384 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1388 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1385 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1389 | i18n("Import!"), i18n("Cancel"), 0, | 1386 | i18n("Import!"), i18n("Cancel"), 0, |
1390 | 0, 1 ); | 1387 | 0, 1 ); |
1391 | if ( result == 0 ) { | 1388 | if ( result == 0 ) { |
1392 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1389 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1393 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1390 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1394 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1391 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1395 | mView->importQtopia( categories, datebook, todolist ); | 1392 | mView->importQtopia( categories, datebook, todolist ); |
1396 | } | 1393 | } |
1397 | #else | 1394 | #else |
1398 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1395 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1399 | i18n("Not supported \non desktop!\n"), | 1396 | i18n("Not supported \non desktop!\n"), |
1400 | i18n("Ok"), i18n("Cancel"), 0, | 1397 | i18n("Ok"), i18n("Cancel"), 0, |
1401 | 0, 1 ); | 1398 | 0, 1 ); |
1402 | 1399 | ||
1403 | #endif | 1400 | #endif |
1404 | } | 1401 | } |
1405 | 1402 | ||
1406 | void MainWindow::saveOnClose() | 1403 | void MainWindow::saveOnClose() |
1407 | { | 1404 | { |
1408 | KOPrefs *p = KOPrefs::instance(); | 1405 | KOPrefs *p = KOPrefs::instance(); |
1409 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1406 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1410 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1407 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1411 | iconToolBar->y() > height()/2; | 1408 | iconToolBar->y() > height()/2; |
1412 | mView->writeSettings(); | 1409 | mView->writeSettings(); |
1413 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1410 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1414 | save(); | 1411 | save(); |
1415 | } | 1412 | } |
1416 | void MainWindow::slotModifiedChanged( bool changed ) | 1413 | void MainWindow::slotModifiedChanged( bool changed ) |
1417 | { | 1414 | { |
1418 | if ( mBlockAtStartup ) | 1415 | if ( mBlockAtStartup ) |
1419 | return; | 1416 | return; |
1420 | int msec; | 1417 | int msec; |
1421 | // we store the changes after 1 minute, | 1418 | // we store the changes after 1 minute, |
1422 | // and for safety reasons after 10 minutes again | 1419 | // and for safety reasons after 10 minutes again |
1423 | if ( !mBlockSaveFlag ) | 1420 | if ( !mBlockSaveFlag ) |
1424 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1421 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1425 | else | 1422 | else |
1426 | msec = 1000 * 600; | 1423 | msec = 1000 * 600; |
1427 | mSaveTimer.start( msec, true ); // 1 minute | 1424 | mSaveTimer.start( msec, true ); // 1 minute |
1428 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1425 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1429 | mCalendarModifiedFlag = true; | 1426 | mCalendarModifiedFlag = true; |
1430 | } | 1427 | } |
1431 | #include <qfileinfo.h> | ||
1432 | void MainWindow::save() | 1428 | void MainWindow::save() |
1433 | { | 1429 | { |
1434 | if ( mBlockSaveFlag ) | 1430 | if ( mBlockSaveFlag ) |
1435 | return; | 1431 | return; |
1436 | bool store = mBlockSaveFlag; | 1432 | bool store = mBlockSaveFlag; |
1437 | mBlockSaveFlag = true; | 1433 | mBlockSaveFlag = true; |
1438 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1434 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1439 | 1435 | ||
1440 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1436 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1441 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1437 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1442 | qDebug("KO: Start saving data to file!"); | 1438 | qDebug("KO: Start saving data to file!"); |
1443 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1439 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1444 | mView->saveCalendar( defaultFileName() ); | 1440 | mView->saveCalendar( defaultFileName() ); |
1445 | 1441 | ||
1446 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1442 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1447 | mView->watchSavedFile(); | 1443 | mView->watchSavedFile(); |
1448 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1444 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1449 | QString savemes; | 1445 | QString savemes; |
1450 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1446 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1451 | setCaption(savemes); | 1447 | setCaption(savemes); |
1452 | } else | 1448 | } else |
1453 | setCaption(i18n("Saving cancelled!")); | 1449 | setCaption(i18n("Saving cancelled!")); |
1454 | mCalendarModifiedFlag = false; | 1450 | mCalendarModifiedFlag = false; |
1455 | mBlockSaveFlag = store; | 1451 | mBlockSaveFlag = store; |
1456 | } | 1452 | } |
1457 | 1453 | ||
1458 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1454 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1459 | { | 1455 | { |
1460 | if ( !e->isAutoRepeat() ) { | 1456 | if ( !e->isAutoRepeat() ) { |
1461 | mFlagKeyPressed = false; | 1457 | mFlagKeyPressed = false; |
1462 | } | 1458 | } |
1463 | } | 1459 | } |
1464 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1460 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1465 | { | 1461 | { |
1466 | qApp->processEvents(); | 1462 | qApp->processEvents(); |
1467 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1463 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1468 | e->ignore(); | 1464 | e->ignore(); |
1469 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1465 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1470 | return; | 1466 | return; |
1471 | } | 1467 | } |
1472 | if (! e->isAutoRepeat() ) | 1468 | if (! e->isAutoRepeat() ) |
1473 | mFlagKeyPressed = true; | 1469 | mFlagKeyPressed = true; |
1474 | KOPrefs *p = KOPrefs::instance(); | 1470 | KOPrefs *p = KOPrefs::instance(); |
1475 | bool showSelectedDates = false; | 1471 | bool showSelectedDates = false; |
1476 | int size; | 1472 | int size; |
1477 | int pro = 0; | 1473 | int pro = 0; |
1478 | //qDebug("MainWindow::keyPressEvent "); | 1474 | //qDebug("MainWindow::keyPressEvent "); |
1479 | switch ( e->key() ) { | 1475 | switch ( e->key() ) { |
1480 | case Qt::Key_Right: | 1476 | case Qt::Key_Right: |
1481 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1477 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1482 | mView->goNextMonth(); | 1478 | mView->goNextMonth(); |
1483 | else | 1479 | else |
1484 | mView->goNext(); | 1480 | mView->goNext(); |
1485 | showSelectedDates = true; | 1481 | showSelectedDates = true; |
1486 | break; | 1482 | break; |
1487 | case Qt::Key_Left: | 1483 | case Qt::Key_Left: |
1488 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1484 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1489 | mView->goPreviousMonth(); | 1485 | mView->goPreviousMonth(); |
1490 | else | 1486 | else |
1491 | mView->goPrevious(); | 1487 | mView->goPrevious(); |
1492 | showSelectedDates = true; | 1488 | showSelectedDates = true; |
1493 | break; | 1489 | break; |
1494 | case Qt::Key_Down: | 1490 | case Qt::Key_Down: |
1495 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1491 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1496 | break; | 1492 | break; |
1497 | case Qt::Key_Up: | 1493 | case Qt::Key_Up: |
1498 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1494 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1499 | break; | 1495 | break; |
1500 | case Qt::Key_I: | 1496 | case Qt::Key_I: |
1501 | mView->showIncidence(); | 1497 | mView->showIncidence(); |
1502 | break; | 1498 | break; |
1503 | case Qt::Key_Delete: | 1499 | case Qt::Key_Delete: |
1504 | case Qt::Key_Backspace: | 1500 | case Qt::Key_Backspace: |
1505 | mView->deleteIncidence(); | 1501 | mView->deleteIncidence(); |
1506 | break; | 1502 | break; |
1507 | case Qt::Key_D: | 1503 | case Qt::Key_D: |
1508 | mView->viewManager()->showDayView(); | 1504 | mView->viewManager()->showDayView(); |
1509 | showSelectedDates = true; | 1505 | showSelectedDates = true; |
1510 | break; | 1506 | break; |
1511 | case Qt::Key_O: | 1507 | case Qt::Key_O: |
1512 | mView->toggleFilerEnabled( ); | 1508 | mView->toggleFilerEnabled( ); |
1513 | break; | 1509 | break; |
1514 | case Qt::Key_0: | 1510 | case Qt::Key_0: |
1515 | case Qt::Key_1: | 1511 | case Qt::Key_1: |
1516 | case Qt::Key_2: | 1512 | case Qt::Key_2: |
1517 | case Qt::Key_3: | 1513 | case Qt::Key_3: |
1518 | case Qt::Key_4: | 1514 | case Qt::Key_4: |
1519 | case Qt::Key_5: | 1515 | case Qt::Key_5: |
1520 | case Qt::Key_6: | 1516 | case Qt::Key_6: |
1521 | case Qt::Key_7: | 1517 | case Qt::Key_7: |
1522 | case Qt::Key_8: | 1518 | case Qt::Key_8: |
1523 | case Qt::Key_9: | 1519 | case Qt::Key_9: |
1524 | pro = e->key()-48; | 1520 | pro = e->key()-48; |
1525 | if ( pro == 0 ) | 1521 | if ( pro == 0 ) |
1526 | pro = 10; | 1522 | pro = 10; |
1527 | if ( e->state() == Qt::ControlButton) | 1523 | if ( e->state() == Qt::ControlButton) |
@@ -1773,437 +1769,477 @@ void MainWindow::loadCalendar() | |||
1773 | 0, 1 ); | 1769 | 0, 1 ); |
1774 | if ( result != 0 ) { | 1770 | if ( result != 0 ) { |
1775 | loadbup = false; | 1771 | loadbup = false; |
1776 | } | 1772 | } |
1777 | } else { | 1773 | } else { |
1778 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1774 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1779 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1775 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1780 | 0, 1 ); | 1776 | 0, 1 ); |
1781 | 1777 | ||
1782 | return; | 1778 | return; |
1783 | } | 1779 | } |
1784 | if ( loadbup ) { | 1780 | if ( loadbup ) { |
1785 | mView->openCalendar( fn ); | 1781 | mView->openCalendar( fn ); |
1786 | KOPrefs::instance()->mLastLoadFile = fn; | 1782 | KOPrefs::instance()->mLastLoadFile = fn; |
1787 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1783 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1788 | setCaption(mess); | 1784 | setCaption(mess); |
1789 | } | 1785 | } |
1790 | 1786 | ||
1791 | } | 1787 | } |
1792 | void MainWindow::quickImportIcal() | 1788 | void MainWindow::quickImportIcal() |
1793 | { | 1789 | { |
1794 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1790 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1795 | } | 1791 | } |
1796 | void MainWindow::importFile( QString fn, bool quick ) | 1792 | void MainWindow::importFile( QString fn, bool quick ) |
1797 | { | 1793 | { |
1798 | QFileInfo info; | 1794 | QFileInfo info; |
1799 | info.setFile( fn ); | 1795 | info.setFile( fn ); |
1800 | QString mess; | 1796 | QString mess; |
1801 | bool loadbup = true; | 1797 | bool loadbup = true; |
1802 | if ( !info. exists() ) { | 1798 | if ( !info. exists() ) { |
1803 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1799 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1804 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1800 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1805 | mess ); | 1801 | mess ); |
1806 | return; | 1802 | return; |
1807 | } | 1803 | } |
1808 | int result = 0; | 1804 | int result = 0; |
1809 | if ( !quick ) { | 1805 | if ( !quick ) { |
1810 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1806 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1811 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1807 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1812 | mess, | 1808 | mess, |
1813 | "Import", "Cancel", 0, | 1809 | "Import", "Cancel", 0, |
1814 | 0, 1 ); | 1810 | 0, 1 ); |
1815 | } | 1811 | } |
1816 | if ( result == 0 ) { | 1812 | if ( result == 0 ) { |
1817 | if ( mView->openCalendar( fn, true )) { | 1813 | if ( mView->openCalendar( fn, true )) { |
1818 | KOPrefs::instance()->mLastImportFile = fn; | 1814 | KOPrefs::instance()->mLastImportFile = fn; |
1819 | setCaption(i18n("Imported file successfully")); | 1815 | setCaption(i18n("Imported file successfully")); |
1820 | } else { | 1816 | } else { |
1821 | setCaption(i18n("Error importing file")); | 1817 | setCaption(i18n("Error importing file")); |
1822 | } | 1818 | } |
1823 | } | 1819 | } |
1824 | } | 1820 | } |
1825 | 1821 | ||
1826 | void MainWindow::importIcal() | 1822 | void MainWindow::importIcal() |
1827 | { | 1823 | { |
1828 | 1824 | ||
1829 | QString fn =KOPrefs::instance()->mLastImportFile; | 1825 | QString fn =KOPrefs::instance()->mLastImportFile; |
1830 | 1826 | ||
1831 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1827 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1832 | if ( fn == "" ) | 1828 | if ( fn == "" ) |
1833 | return; | 1829 | return; |
1834 | importFile( fn, true ); | 1830 | importFile( fn, true ); |
1835 | 1831 | ||
1836 | } | 1832 | } |
1837 | 1833 | ||
1838 | void MainWindow::exportVCalendar() | 1834 | void MainWindow::exportVCalendar() |
1839 | { | 1835 | { |
1840 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1836 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1841 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1837 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1842 | if ( fn == "" ) | 1838 | if ( fn == "" ) |
1843 | return; | 1839 | return; |
1844 | QFileInfo info; | 1840 | QFileInfo info; |
1845 | info.setFile( fn ); | 1841 | info.setFile( fn ); |
1846 | QString mes; | 1842 | QString mes; |
1847 | bool createbup = true; | 1843 | bool createbup = true; |
1848 | if ( info. exists() ) { | 1844 | if ( info. exists() ) { |
1849 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1845 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1850 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1846 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1851 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1847 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1852 | 0, 1 ); | 1848 | 0, 1 ); |
1853 | if ( result != 0 ) { | 1849 | if ( result != 0 ) { |
1854 | createbup = false; | 1850 | createbup = false; |
1855 | } | 1851 | } |
1856 | } | 1852 | } |
1857 | if ( createbup ) { | 1853 | if ( createbup ) { |
1858 | if ( mView->exportVCalendar( fn ) ) { | 1854 | if ( mView->exportVCalendar( fn ) ) { |
1859 | KOPrefs::instance()->mLastVcalFile = fn; | 1855 | KOPrefs::instance()->mLastVcalFile = fn; |
1860 | if ( fn.length() > 20 ) | 1856 | if ( fn.length() > 20 ) |
1861 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1857 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1862 | else | 1858 | else |
1863 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1859 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1864 | setCaption(mes); | 1860 | setCaption(mes); |
1865 | } | 1861 | } |
1866 | } | 1862 | } |
1867 | 1863 | ||
1868 | } | 1864 | } |
1869 | #include <qpushbutton.h> | ||
1870 | QString MainWindow::getPassword( ) | 1865 | QString MainWindow::getPassword( ) |
1871 | { | 1866 | { |
1872 | QString retfile = ""; | 1867 | QString retfile = ""; |
1873 | QDialog dia ( this, "input-dialog", true ); | 1868 | QDialog dia ( this, "input-dialog", true ); |
1874 | QLineEdit lab ( &dia ); | 1869 | QLineEdit lab ( &dia ); |
1875 | lab.setEchoMode( QLineEdit::Password ); | 1870 | lab.setEchoMode( QLineEdit::Password ); |
1876 | QVBoxLayout lay( &dia ); | 1871 | QVBoxLayout lay( &dia ); |
1877 | lay.setMargin(7); | 1872 | lay.setMargin(7); |
1878 | lay.setSpacing(7); | 1873 | lay.setSpacing(7); |
1879 | lay.addWidget( &lab); | 1874 | lay.addWidget( &lab); |
1880 | dia.setFixedSize( 230,50 ); | 1875 | dia.setFixedSize( 230,50 ); |
1881 | dia.setCaption( i18n("Enter password") ); | 1876 | dia.setCaption( i18n("Enter password") ); |
1882 | QPushButton pb ( "OK", &dia); | 1877 | QPushButton pb ( "OK", &dia); |
1883 | lay.addWidget( &pb ); | 1878 | lay.addWidget( &pb ); |
1884 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1879 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1885 | dia.show(); | 1880 | dia.show(); |
1886 | int res = dia.exec(); | 1881 | int res = dia.exec(); |
1887 | if ( res ) | 1882 | if ( res ) |
1888 | retfile = lab.text(); | 1883 | retfile = lab.text(); |
1889 | dia.hide(); | 1884 | dia.hide(); |
1890 | qApp->processEvents(); | 1885 | qApp->processEvents(); |
1891 | return retfile; | 1886 | return retfile; |
1892 | 1887 | ||
1893 | } | 1888 | } |
1894 | 1889 | ||
1895 | void MainWindow::enableQuick() | 1890 | void MainWindow::enableQuick() |
1896 | { | 1891 | { |
1897 | QString retfile = ""; | 1892 | QString retfile = ""; |
1898 | QDialog dia ( this, "input-dialog", true ); | 1893 | QDialog dia ( this, "input-dialog", true ); |
1899 | QLineEdit lab ( &dia ); | 1894 | QLineEdit lab ( &dia ); |
1900 | QVBoxLayout lay( &dia ); | 1895 | QVBoxLayout lay( &dia ); |
1901 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); | 1896 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); |
1902 | lay.setMargin(7); | 1897 | lay.setMargin(7); |
1903 | lay.setSpacing(7); | 1898 | lay.setSpacing(7); |
1904 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); | 1899 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); |
1905 | lay.addWidget( &label); | 1900 | lay.addWidget( &label); |
1906 | lay.addWidget( &lab); | 1901 | lay.addWidget( &lab); |
1907 | dia.setFixedSize( 230,80 ); | 1902 | dia.setFixedSize( 230,80 ); |
1908 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync") ); | 1903 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync") ); |
1909 | QPushButton pb ( "OK", &dia); | 1904 | QPushButton pb ( "OK", &dia); |
1910 | lay.addWidget( &pb ); | 1905 | lay.addWidget( &pb ); |
1911 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1906 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1912 | dia.show(); | 1907 | dia.show(); |
1913 | int res = dia.exec(); | 1908 | int res = dia.exec(); |
1914 | if ( res ) | 1909 | if ( res ) |
1915 | retfile = lab.text(); | 1910 | retfile = lab.text(); |
1916 | else | 1911 | else |
1917 | return; | 1912 | return; |
1918 | dia.hide(); | 1913 | dia.hide(); |
1919 | qApp->processEvents(); | 1914 | qApp->processEvents(); |
1920 | KOPrefs::instance()->mPassiveSyncPort = retfile; | 1915 | KOPrefs::instance()->mPassiveSyncPort = retfile; |
1921 | bool ok; | 1916 | bool ok; |
1922 | Q_UINT16 port = retfile.toUInt(&ok); | 1917 | Q_UINT16 port = retfile.toUInt(&ok); |
1923 | if ( ! ok ) { | 1918 | if ( ! ok ) { |
1924 | qDebug("no valid port "); | 1919 | qDebug("no valid port "); |
1925 | return; | 1920 | return; |
1926 | } | 1921 | } |
1927 | qDebug("port %d ", port); | 1922 | qDebug("port %d ", port); |
1928 | mServerSocket = new KServerSocket ( port ,1 ); | 1923 | mServerSocket = new KServerSocket ( port ,1 ); |
1929 | qDebug("connected "); | 1924 | qDebug("connected "); |
1930 | if ( !mServerSocket->ok() ) { | 1925 | if ( !mServerSocket->ok() ) { |
1931 | qWarning("Failed to bind to port %d", port); | 1926 | qWarning("Failed to bind to port %d", port); |
1932 | delete mServerSocket; | 1927 | delete mServerSocket; |
1933 | mServerSocket = 0; | 1928 | mServerSocket = 0; |
1934 | return; | 1929 | return; |
1935 | } | 1930 | } |
1936 | connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); | 1931 | connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); |
1937 | connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); | 1932 | connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); |
1938 | } | 1933 | } |
1939 | void MainWindow::sendFile(QSocket* socket) | 1934 | void MainWindow::sendFile(QSocket* socket) |
1940 | { | 1935 | { |
1941 | setCaption( i18n("Received request for file") ); | 1936 | setCaption( i18n("Received request for file") ); |
1942 | qDebug("MainWindow::sendFile(QSocket* s) "); | 1937 | qDebug("MainWindow::sendFile(QSocket* s) "); |
1943 | if ( mSyncActionDialog ) | 1938 | if ( mSyncActionDialog ) |
1944 | delete mSyncActionDialog; | 1939 | delete mSyncActionDialog; |
1945 | mSyncActionDialog = new QDialog ( this, "input-dialog", true ); | 1940 | mSyncActionDialog = new QDialog ( this, "input-dialog", true ); |
1946 | mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING")); | 1941 | mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING")); |
1947 | QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog ); | 1942 | QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog ); |
1948 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1943 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1949 | lay->addWidget( label); | 1944 | lay->addWidget( label); |
1950 | lay->setMargin(7); | 1945 | lay->setMargin(7); |
1951 | lay->setSpacing(7); | 1946 | lay->setSpacing(7); |
1952 | mSyncActionDialog->setFixedSize( 200,100 ); | 1947 | mSyncActionDialog->setFixedSize( 200,100 ); |
1953 | mSyncActionDialog->show(); | 1948 | mSyncActionDialog->show(); |
1954 | qApp->processEvents(); | 1949 | qApp->processEvents(); |
1955 | qDebug("saving ... "); | 1950 | qDebug("saving ... "); |
1956 | save(); | 1951 | save(); |
1957 | QString fileName = defaultFileName(); | 1952 | QString fileName = defaultFileName(); |
1958 | QFile file( fileName ); | 1953 | QFile file( fileName ); |
1959 | if (!file.open( IO_ReadOnly ) ) { | 1954 | if (!file.open( IO_ReadOnly ) ) { |
1960 | setCaption( i18n("Error open file") ); | 1955 | setCaption( i18n("Error open file") ); |
1961 | delete mSyncActionDialog; | 1956 | delete mSyncActionDialog; |
1962 | mSyncActionDialog = 0; | 1957 | mSyncActionDialog = 0; |
1963 | qDebug("error open cal file "); | 1958 | qDebug("error open cal file "); |
1964 | return ; | 1959 | return ; |
1965 | 1960 | ||
1966 | } | 1961 | } |
1967 | setCaption( i18n("Sending file...") ); | 1962 | setCaption( i18n("Sending file...") ); |
1968 | QTextStream ts( &file ); | 1963 | QTextStream ts( &file ); |
1969 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 1964 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
1970 | QTextStream os( socket ); | 1965 | QTextStream os( socket ); |
1971 | os.setCodec( QTextCodec::codecForName("utf8") ); | 1966 | os.setCodec( QTextCodec::codecForName("utf8") ); |
1972 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 1967 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
1973 | while ( ! ts.atEnd() ) { | 1968 | while ( ! ts.atEnd() ) { |
1974 | os << ts.readLine() << "\n"; | 1969 | os << ts.readLine() << "\n"; |
1975 | } | 1970 | } |
1976 | //os << ts.read(); | 1971 | //os << ts.read(); |
1977 | socket->close(); | 1972 | socket->close(); |
1978 | file.close(); | 1973 | file.close(); |
1979 | setCaption( i18n("File sent. Waiting to get back synced file") ); | 1974 | setCaption( i18n("File sent. Waiting to get back synced file") ); |
1980 | qDebug("file sent "); | 1975 | qDebug("file sent "); |
1981 | } | 1976 | } |
1982 | void MainWindow::getFile(QSocket* socket) | 1977 | void MainWindow::getFile(QSocket* socket) |
1983 | { | 1978 | { |
1984 | setCaption( i18n("Receiving synced file...") ); | 1979 | setCaption( i18n("Receiving synced file...") ); |
1985 | 1980 | ||
1986 | QString fileName = defaultFileName(); | 1981 | QString fileName = defaultFileName(); |
1987 | QFile file( fileName ); | 1982 | QFile file( fileName ); |
1988 | if (!file.open( IO_WriteOnly ) ) { | 1983 | if (!file.open( IO_WriteOnly ) ) { |
1989 | setCaption( i18n("Error open file") ); | 1984 | setCaption( i18n("Error open file") ); |
1990 | delete mSyncActionDialog; | 1985 | delete mSyncActionDialog; |
1991 | mSyncActionDialog = 0; | 1986 | mSyncActionDialog = 0; |
1992 | qDebug("error open cal file "); | 1987 | qDebug("error open cal file "); |
1993 | return ; | 1988 | return ; |
1994 | 1989 | ||
1995 | } | 1990 | } |
1996 | 1991 | ||
1997 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1992 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1998 | QTextStream ts( &file ); | 1993 | QTextStream ts( &file ); |
1999 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 1994 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2000 | bool first = true; | 1995 | bool first = true; |
2001 | while ( socket->canReadLine () || first ) { | 1996 | while ( socket->canReadLine () || first ) { |
2002 | first = false; | 1997 | first = false; |
2003 | while ( socket->canReadLine () ) { | 1998 | while ( socket->canReadLine () ) { |
1999 | qDebug("avail %d ", socket->bytesAvailable () ); | ||
2004 | ts << socket->readLine (); | 2000 | ts << socket->readLine (); |
2005 | } | 2001 | } |
2002 | QTime ti; | ||
2003 | ti.start(); | ||
2004 | while ( ti.elapsed () < 5000 && !socket->canReadLine () ) { | ||
2005 | qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () ); | ||
2006 | //qApp->processEvents(); | ||
2007 | qDebug("waiting1b %d ",ti.elapsed () ); | ||
2008 | if ( !socket->canReadLine () ) { | ||
2009 | qDebug("waiting1c %d ",ti.elapsed () ); | ||
2010 | usleep( 100000); | ||
2011 | } | ||
2012 | //socket->waitForMore ( 100 ); | ||
2013 | } | ||
2014 | ts << socket->readLine (); | ||
2015 | #if 0 | ||
2016 | #ifdef DESKTOP_VERSION | ||
2006 | socket->waitForMore ( 5000 ); | 2017 | socket->waitForMore ( 5000 ); |
2018 | #else | ||
2019 | // socket->waitForMore ( 5000 ); | ||
2020 | // seems to be broken in qt2 | ||
2021 | bool stop = false; | ||
2022 | QTime ti; | ||
2023 | ti.start(); | ||
2024 | while ( ti.elapsed < 5000 && !stop ) { | ||
2025 | qApp->processEvents(); | ||
2026 | if ( socket->canReadLine () ) | ||
2027 | stop = true ; | ||
2028 | else { | ||
2029 | usleep( 100000 ); | ||
2030 | |||
2031 | } | ||
2032 | } | ||
2033 | #endif | ||
2034 | #endif | ||
2007 | } | 2035 | } |
2008 | setCaption( i18n("File received - reloading calendar...") ); | 2036 | setCaption( i18n("File received - reloading calendar...") ); |
2009 | file.close(); | 2037 | file.close(); |
2010 | socket->close(); | 2038 | socket->close(); |
2011 | mView->watchSavedFile(); | 2039 | mView->watchSavedFile(); |
2012 | mView->openCalendar( defaultFileName() ); | 2040 | mView->openCalendar( defaultFileName() ); |
2013 | setCaption( i18n("Easy-Pi-Sync successful!") ); | 2041 | setCaption( i18n("Easy-Pi-Sync successful!") ); |
2014 | delete mSyncActionDialog; | 2042 | delete mSyncActionDialog; |
2015 | mSyncActionDialog = 0; | 2043 | mSyncActionDialog = 0; |
2016 | 2044 | ||
2017 | 2045 | ||
2018 | } | 2046 | } |
2019 | void MainWindow::endConnect() | 2047 | void MainWindow::endConnect() |
2020 | { | 2048 | { |
2021 | setCaption( i18n("No file received - syncing successful") ); | 2049 | setCaption( i18n("No file received - syncing successful") ); |
2022 | delete mSyncActionDialog; | 2050 | delete mSyncActionDialog; |
2023 | mSyncActionDialog = 0; | 2051 | mSyncActionDialog = 0; |
2024 | } | 2052 | } |
2025 | void MainWindow::performQuick() | 2053 | void MainWindow::performQuick() |
2026 | { | 2054 | { |
2027 | setCaption( i18n("Please input connection settings") ); | 2055 | setCaption( i18n("Please input connection settings") ); |
2028 | QString retfile = ""; | 2056 | QString retfile = ""; |
2029 | QDialog dia ( this, "input-dialog", true ); | 2057 | QDialog dia ( this, "input-dialog", true ); |
2030 | QLineEdit lab ( &dia ); | 2058 | QLineEdit lab ( &dia ); |
2031 | QVBoxLayout lay( &dia ); | 2059 | QVBoxLayout lay( &dia ); |
2032 | QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); | 2060 | QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); |
2033 | lay.addWidget( &label); | 2061 | lay.addWidget( &label); |
2034 | lab.setText( KOPrefs::instance()->mActiveSyncIP ); | 2062 | lab.setText( KOPrefs::instance()->mActiveSyncIP ); |
2035 | lay.setMargin(7); | 2063 | lay.setMargin(7); |
2036 | lay.setSpacing(7); | 2064 | lay.setSpacing(7); |
2037 | lay.addWidget( &lab); | 2065 | lay.addWidget( &lab); |
2038 | QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); | 2066 | QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); |
2039 | lay.addWidget( &label2); | 2067 | lay.addWidget( &label2); |
2040 | QLineEdit lab2 ( &dia ); | 2068 | QLineEdit lab2 ( &dia ); |
2041 | lab2.setText( KOPrefs::instance()->mActiveSyncPort ); | 2069 | lab2.setText( KOPrefs::instance()->mActiveSyncPort ); |
2042 | lay.addWidget( &lab2); | 2070 | lay.addWidget( &lab2); |
2043 | dia.setFixedSize( 230,200 ); | 2071 | dia.setFixedSize( 230,200 ); |
2044 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") ); | 2072 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") ); |
2045 | QPushButton pb ( "OK", &dia); | 2073 | QPushButton pb ( "OK", &dia); |
2046 | lay.addWidget( &pb ); | 2074 | lay.addWidget( &pb ); |
2047 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2075 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2048 | dia.show(); | 2076 | dia.show(); |
2049 | int res = dia.exec(); | 2077 | int res = dia.exec(); |
2050 | if ( !res ) { | 2078 | if ( !res ) { |
2051 | setCaption( i18n("Syncing cancelled!") ); | 2079 | setCaption( i18n("Syncing cancelled!") ); |
2052 | return; | 2080 | return; |
2053 | } | 2081 | } |
2054 | dia.hide(); | 2082 | dia.hide(); |
2055 | KOPrefs::instance()->mActiveSyncPort = lab2.text(); | 2083 | KOPrefs::instance()->mActiveSyncPort = lab2.text(); |
2056 | KOPrefs::instance()->mActiveSyncIP = lab.text(); | 2084 | KOPrefs::instance()->mActiveSyncIP = lab.text(); |
2057 | qApp->processEvents(); | 2085 | qApp->processEvents(); |
2058 | performQuickQuick(); | 2086 | performQuickQuick(); |
2059 | } | 2087 | } |
2060 | 2088 | ||
2061 | void MainWindow::performQuickQuick() | 2089 | void MainWindow::performQuickQuick() |
2062 | { | 2090 | { |
2063 | // setCaption( i18n("") ); | 2091 | // setCaption( i18n("") ); |
2064 | 2092 | ||
2065 | bool ok; | 2093 | bool ok; |
2066 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | 2094 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); |
2067 | if ( ! ok ) { | 2095 | if ( ! ok ) { |
2068 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 2096 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
2069 | return; | 2097 | return; |
2070 | } | 2098 | } |
2071 | if ( !mCommandSocket ) { | 2099 | if ( !mCommandSocket ) { |
2072 | mCommandSocket = new QSocket( this ); | 2100 | mCommandSocket = new QSocket( this ); |
2073 | // delete mCommandSocket; | 2101 | // delete mCommandSocket; |
2074 | //mCommandSocket = new QSocket( this ); | 2102 | //mCommandSocket = new QSocket( this ); |
2075 | connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); | 2103 | connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); |
2076 | } | 2104 | } |
2077 | QString host = KOPrefs::instance()->mActiveSyncIP; | 2105 | QString host = KOPrefs::instance()->mActiveSyncIP; |
2078 | mCommandSocket->connectToHost( host, port ); | 2106 | mCommandSocket->connectToHost( host, port ); |
2079 | QTextStream os( mCommandSocket ); | 2107 | QTextStream os( mCommandSocket ); |
2080 | os.setEncoding( QTextStream::UnicodeUTF8 ); | 2108 | os.setEncoding( QTextStream::UnicodeUTF8 ); |
2081 | os << "GET\r\n"; | 2109 | os << "GET\r\n"; |
2082 | setCaption( i18n("Sending request for remote file ...") ); | 2110 | setCaption( i18n("Sending request for remote file ...") ); |
2083 | 2111 | ||
2084 | } | 2112 | } |
2085 | void MainWindow::readFileFromSocket() | 2113 | void MainWindow::readFileFromSocket() |
2086 | { | 2114 | { |
2087 | setCaption( i18n("Receiving remote file ...") ); | 2115 | setCaption( i18n("Receiving remote file ...") ); |
2088 | qDebug("MainWindow::readFileFromSocket() "); | 2116 | qDebug("MainWindow::readFileFromSocket() "); |
2089 | QString fileName; | 2117 | QString fileName; |
2090 | #ifdef _WIN32_ | 2118 | #ifdef _WIN32_ |
2091 | fileName = defaultFileName() +"sync"; | 2119 | fileName = defaultFileName() +"sync"; |
2092 | #else | 2120 | #else |
2093 | fileName = "/tmp/kopitempfile.ics"; | 2121 | fileName = "/tmp/kopitempfile.ics"; |
2094 | #endif | 2122 | #endif |
2095 | QFile file( fileName ); | 2123 | QFile file( fileName ); |
2096 | if (!file.open( IO_WriteOnly ) ) { | 2124 | if (!file.open( IO_WriteOnly ) ) { |
2097 | setCaption( i18n("Error: Cannot open temp file for write.") ); | 2125 | setCaption( i18n("Error: Cannot open temp file for write.") ); |
2098 | qDebug("Error open calender file for writing: %s",fileName.latin1() ); | 2126 | qDebug("Error open calender file for writing: %s",fileName.latin1() ); |
2099 | return ; | 2127 | return ; |
2100 | } | 2128 | } |
2101 | 2129 | ||
2102 | //QTextStream os2( mCommandSocket ); | 2130 | //QTextStream os2( mCommandSocket ); |
2103 | //os2.setEncoding( QTextStream::UnicodeUTF8 ); | 2131 | //os2.setEncoding( QTextStream::UnicodeUTF8 ); |
2104 | 2132 | ||
2105 | QTextStream ts( &file ); | 2133 | QTextStream ts( &file ); |
2106 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2134 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2107 | bool first = true; | 2135 | bool first = true; |
2108 | while ( mCommandSocket->canReadLine () || first) { | 2136 | while ( mCommandSocket->canReadLine () || first) { |
2109 | first = false; | 2137 | first = false; |
2110 | while ( mCommandSocket->canReadLine () ) { | 2138 | while ( mCommandSocket->canReadLine () ) { |
2111 | ts << mCommandSocket->readLine (); | 2139 | ts << mCommandSocket->readLine (); |
2140 | } | ||
2141 | QTime ti; | ||
2142 | ti.start(); | ||
2143 | while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) { | ||
2144 | qApp->processEvents(); | ||
2145 | qDebug("waiting2 %d ",ti.elapsed () ); | ||
2146 | if ( !mCommandSocket->canReadLine () ) | ||
2147 | mCommandSocket->waitForMore ( 100 ); | ||
2112 | } | 2148 | } |
2113 | mCommandSocket->waitForMore ( 5000 ); | 2149 | //mCommandSocket->waitForMore ( 5000 ); |
2114 | } | 2150 | } |
2115 | file.close(); | 2151 | file.close(); |
2116 | mCommandSocket->close(); | 2152 | mCommandSocket->close(); |
2117 | //delete mCommandSocket; | 2153 | //delete mCommandSocket; |
2118 | setCaption( i18n("Remote file saved to temp file.") ); | 2154 | setCaption( i18n("Remote file saved to temp file.") ); |
2119 | //mCommandSocket = 0; | 2155 | //mCommandSocket = 0; |
2120 | mCurrentSyncProfile = 2 ; // last file | 2156 | mCurrentSyncProfile = 2 ; // last file |
2121 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 2157 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
2122 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 2158 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
2123 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2159 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2124 | KSyncProfile* temp = new KSyncProfile (); | 2160 | KSyncProfile* temp = new KSyncProfile (); |
2125 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2161 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2126 | temp->readConfig(&config); | 2162 | temp->readConfig(&config); |
2127 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2163 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2128 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2164 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2129 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2165 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2130 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2166 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2131 | KOPrefs::instance()->mWriteBackInFuture = 0; | 2167 | KOPrefs::instance()->mWriteBackInFuture = 0; |
2132 | if ( temp->getWriteBackFuture() ) | 2168 | if ( temp->getWriteBackFuture() ) |
2133 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2169 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2134 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2170 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2135 | 2171 | ||
2136 | setCaption( i18n("Remote file saved to temp file.") ); | 2172 | setCaption( i18n("Remote file saved to temp file.") ); |
2137 | if ( ! syncWithFile( fileName , true ) ) { | 2173 | if ( ! syncWithFile( fileName , true ) ) { |
2138 | setCaption( i18n("Syncing failed.") ); | 2174 | setCaption( i18n("Syncing failed.") ); |
2139 | qDebug("Syncing failed "); | 2175 | qDebug("Syncing failed "); |
2140 | return; | 2176 | return; |
2141 | } | 2177 | } |
2142 | 2178 | ||
2143 | if ( !mCommandSocketFinish ) { | 2179 | if ( !mCommandSocketFinish ) { |
2144 | mCommandSocketFinish = new QSocket( this ); | 2180 | mCommandSocketFinish = new QSocket( this ); |
2145 | } | 2181 | } |
2146 | mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); | 2182 | mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); |
2147 | 2183 | ||
2148 | QString host = KOPrefs::instance()->mActiveSyncIP; | 2184 | QString host = KOPrefs::instance()->mActiveSyncIP; |
2149 | QFile file2( fileName ); | 2185 | QFile file2( fileName ); |
2150 | if (!file2.open( IO_ReadOnly ) ) { | 2186 | if (!file2.open( IO_ReadOnly ) ) { |
2151 | setCaption( i18n("Error: Cannot open temp file for read.") ); | 2187 | setCaption( i18n("Error: Cannot open temp file for read.") ); |
2152 | qDebug("error open cal file "); | 2188 | qDebug("error open cal file "); |
2153 | return ; | 2189 | return ; |
2154 | 2190 | ||
2155 | } | 2191 | } |
2156 | setCaption( i18n("Sending back synced file...") ); | 2192 | setCaption( i18n("Sending back synced file...") ); |
2157 | QTextStream ts2( &file2 ); | 2193 | QTextStream ts2( &file2 ); |
2158 | ts2.setCodec( QTextCodec::codecForName("utf8") ); | 2194 | ts2.setCodec( QTextCodec::codecForName("utf8") ); |
2159 | QTextStream os2( mCommandSocketFinish ); | 2195 | QTextStream os2( mCommandSocketFinish ); |
2160 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2196 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2161 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 2197 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
2162 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2198 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2163 | os2 << "PUT\r\n"; | 2199 | os2 << "PUT\r\n"; |
2164 | while ( ! ts2.atEnd() ) { | 2200 | while ( ! ts2.atEnd() ) { |
2165 | os2 << ts2.readLine() << "\n"; | 2201 | os2 << ts2.readLine() << "\n"; |
2166 | } | 2202 | } |
2167 | } else { | 2203 | } else { |
2168 | os2 << "STOP\r\n"; | 2204 | os2 << "STOP\r\n"; |
2169 | } | 2205 | } |
2170 | mCommandSocketFinish->close(); | 2206 | mCommandSocketFinish->close(); |
2171 | file.close(); | 2207 | file.close(); |
2172 | //delete ( mCommandSocket); | 2208 | //delete ( mCommandSocket); |
2173 | //mCommandSocket = 0; | 2209 | //mCommandSocket = 0; |
2174 | qDebug("Syncing succesful! "); | 2210 | qDebug("Syncing succesful! "); |
2175 | setCaption( i18n("Easy-Pi-Sync succesful!") ); | 2211 | setCaption( i18n("Easy-Pi-Sync succesful!") ); |
2176 | 2212 | ||
2177 | 2213 | ||
2178 | } | 2214 | } |
2179 | 2215 | ||
2180 | void MainWindow::syncLocalFile() | 2216 | void MainWindow::syncLocalFile() |
2181 | { | 2217 | { |
2182 | 2218 | ||
2183 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 2219 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; |
2184 | 2220 | ||
2185 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2221 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2186 | if ( fn == "" ) | 2222 | if ( fn == "" ) |
2187 | return; | 2223 | return; |
2188 | //mView->setSyncDevice("local-file" ); | 2224 | //mView->setSyncDevice("local-file" ); |
2189 | if ( syncWithFile( fn, false ) ) { | 2225 | if ( syncWithFile( fn, false ) ) { |
2190 | // Event* e = mView->getLastSyncEvent(); | 2226 | // Event* e = mView->getLastSyncEvent(); |
2191 | // e->setReadOnly( false ); | 2227 | // e->setReadOnly( false ); |
2192 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2228 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2193 | // e->setReadOnly( true ); | 2229 | // e->setReadOnly( true ); |
2194 | } | 2230 | } |
2195 | 2231 | ||
2196 | } | 2232 | } |
2197 | 2233 | ||
2198 | bool MainWindow::syncWithFile( QString fn , bool quick ) | 2234 | bool MainWindow::syncWithFile( QString fn , bool quick ) |
2199 | { | 2235 | { |
2200 | bool ret = false; | 2236 | bool ret = false; |
2201 | QFileInfo info; | 2237 | QFileInfo info; |
2202 | info.setFile( fn ); | 2238 | info.setFile( fn ); |
2203 | QString mess; | 2239 | QString mess; |
2204 | bool loadbup = true; | 2240 | bool loadbup = true; |
2205 | if ( !info. exists() ) { | 2241 | if ( !info. exists() ) { |
2206 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2242 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2207 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2243 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2208 | mess ); | 2244 | mess ); |
2209 | return ret; | 2245 | return ret; |
@@ -2359,96 +2395,147 @@ void MainWindow::syncSSH() | |||
2359 | // remoteUser += ":" + pass; | 2395 | // remoteUser += ":" + pass; |
2360 | // } | 2396 | // } |
2361 | QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; | 2397 | QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; |
2362 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2398 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2363 | int fileSize = 0; | 2399 | int fileSize = 0; |
2364 | int result = system ( command ); | 2400 | int result = system ( command ); |
2365 | // 0 : okay | 2401 | // 0 : okay |
2366 | // 256: no such file or dir | 2402 | // 256: no such file or dir |
2367 | // | 2403 | // |
2368 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2404 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2369 | if ( result != 0 ) { | 2405 | if ( result != 0 ) { |
2370 | int len = maxlen; | 2406 | int len = maxlen; |
2371 | while ( len < command.length() ) { | 2407 | while ( len < command.length() ) { |
2372 | command.insert( len , "\n" ); | 2408 | command.insert( len , "\n" ); |
2373 | len += maxlen +2; | 2409 | len += maxlen +2; |
2374 | } | 2410 | } |
2375 | 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) ; | 2411 | 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) ; |
2376 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2412 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2377 | question, | 2413 | question, |
2378 | i18n("Okay!")) ; | 2414 | i18n("Okay!")) ; |
2379 | setCaption ("KO/Pi"); | 2415 | setCaption ("KO/Pi"); |
2380 | return; | 2416 | return; |
2381 | } | 2417 | } |
2382 | 2418 | ||
2383 | 2419 | ||
2384 | setCaption ( i18n( "Copying succeed." ) ); | 2420 | setCaption ( i18n( "Copying succeed." ) ); |
2385 | //mView->setSyncDevice("ssh-scp" ); | 2421 | //mView->setSyncDevice("ssh-scp" ); |
2386 | if ( syncWithFile(localFile , true ) ) { | 2422 | if ( syncWithFile(localFile , true ) ) { |
2387 | // Event* e = mView->getLastSyncEvent(); | 2423 | // Event* e = mView->getLastSyncEvent(); |
2388 | // e->setReadOnly( false ); | 2424 | // e->setReadOnly( false ); |
2389 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2425 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2390 | // e->setReadOnly( true ); | 2426 | // e->setReadOnly( true ); |
2391 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2427 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2392 | command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; | 2428 | command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; |
2393 | setCaption ( i18n( "Writing back file ..." ) ); | 2429 | setCaption ( i18n( "Writing back file ..." ) ); |
2394 | result = system ( command ); | 2430 | result = system ( command ); |
2395 | if ( result != 0 ) { | 2431 | if ( result != 0 ) { |
2396 | int len = maxlen; | 2432 | int len = maxlen; |
2397 | while ( len < command.length() ) { | 2433 | while ( len < command.length() ) { |
2398 | command.insert( len , "\n" ); | 2434 | command.insert( len , "\n" ); |
2399 | len += maxlen +2; | 2435 | len += maxlen +2; |
2400 | } | 2436 | } |
2401 | 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) ; | 2437 | 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) ; |
2402 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2438 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2403 | question, | 2439 | question, |
2404 | i18n("Okay!")) ; | 2440 | i18n("Okay!")) ; |
2405 | setCaption ("KO/Pi"); | 2441 | setCaption ("KO/Pi"); |
2406 | return; | 2442 | return; |
2407 | } else { | 2443 | } else { |
2408 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2444 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2409 | } | 2445 | } |
2410 | } | 2446 | } |
2411 | } | 2447 | } |
2412 | return; | 2448 | return; |
2413 | #if 0 | 2449 | #if 0 |
2414 | system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); | 2450 | system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); |
2415 | while ( timer.elapsed() < 5000 ) | 2451 | while ( timer.elapsed() < 5000 ) |
2416 | qApp->processEvents(); | 2452 | qApp->processEvents(); |
2417 | 2453 | ||
2418 | qDebug("MainWindow::merging) "); | 2454 | qDebug("MainWindow::merging) "); |
2419 | mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); | 2455 | mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); |
2420 | while ( mBlockSaveFlag ) | 2456 | while ( mBlockSaveFlag ) |
2421 | qApp->processEvents(); | 2457 | qApp->processEvents(); |
2422 | save(); | 2458 | save(); |
2423 | system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); | 2459 | system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); |
2424 | #endif | 2460 | #endif |
2425 | 2461 | ||
2426 | } | 2462 | } |
2427 | 2463 | ||
2428 | 2464 | ||
2429 | void MainWindow::syncSharp() | 2465 | void MainWindow::syncSharp() |
2430 | { | 2466 | { |
2431 | if ( mCalendarModifiedFlag ) | 2467 | if ( mCalendarModifiedFlag ) |
2432 | save(); | 2468 | save(); |
2433 | mView->syncSharp(); | 2469 | mView->syncSharp(); |
2434 | slotModifiedChanged( true ); | 2470 | slotModifiedChanged( true ); |
2435 | 2471 | ||
2436 | } | 2472 | } |
2437 | void MainWindow::syncPhone() | 2473 | void MainWindow::syncPhone() |
2438 | { | 2474 | { |
2439 | if ( mCalendarModifiedFlag ) | 2475 | if ( mCalendarModifiedFlag ) |
2440 | save(); | 2476 | save(); |
2441 | mView->syncPhone(); | 2477 | mView->syncPhone(); |
2442 | slotModifiedChanged( true ); | 2478 | slotModifiedChanged( true ); |
2443 | 2479 | ||
2444 | } | 2480 | } |
2445 | 2481 | ||
2446 | void MainWindow::printSel( ) | 2482 | void MainWindow::printSel( ) |
2447 | { | 2483 | { |
2448 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2484 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2449 | } | 2485 | } |
2450 | 2486 | ||
2451 | void MainWindow::printCal() | 2487 | void MainWindow::printCal() |
2452 | { | 2488 | { |
2453 | mView->print();//mCp->showDialog(); | 2489 | mView->print();//mCp->showDialog(); |
2454 | } | 2490 | } |
2491 | |||
2492 | |||
2493 | |||
2494 | KServerSocket:: KServerSocket ( Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ){;}; | ||
2495 | |||
2496 | void KServerSocket::newConnection ( int socket ) | ||
2497 | { | ||
2498 | qDebug("KServerSocket:New connection %d ", socket); | ||
2499 | QSocket* s = new QSocket( this ); | ||
2500 | connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) ); | ||
2501 | connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | ||
2502 | s->setSocket( socket ); | ||
2503 | } | ||
2504 | |||
2505 | void KServerSocket::discardClient() | ||
2506 | { | ||
2507 | qDebug(" KServerSocket::discardClient()"); | ||
2508 | QSocket* socket = (QSocket*)sender(); | ||
2509 | delete socket; | ||
2510 | //emit endConnect(); | ||
2511 | } | ||
2512 | void KServerSocket::readClient() | ||
2513 | { | ||
2514 | qDebug("KServerSocket readClient()"); | ||
2515 | QSocket* socket = (QSocket*)sender(); | ||
2516 | if ( socket->canReadLine() ) { | ||
2517 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() ); | ||
2518 | qDebug("KServerSocket socket->canReadLine()"); | ||
2519 | if ( tokens[0] == "GET" ) { | ||
2520 | emit sendFile( socket ); | ||
2521 | } | ||
2522 | if ( tokens[0] == "PUT" ) { | ||
2523 | emit getFile( socket ); | ||
2524 | } | ||
2525 | if ( tokens[0] == "STOP" ) { | ||
2526 | emit endConnect(); | ||
2527 | } | ||
2528 | } | ||
2529 | } | ||
2530 | |||
2531 | |||
2532 | |||
2533 | |||
2534 | |||
2535 | |||
2536 | |||
2537 | |||
2538 | |||
2539 | |||
2540 | |||
2541 | |||
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 5985d56..7b4fd27 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,164 +1,136 @@ | |||
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 <qregexp.h> | 7 | #include <qregexp.h> |
8 | 8 | ||
9 | #include <libkcal/incidence.h> | 9 | #include <libkcal/incidence.h> |
10 | #include "simplealarmclient.h" | 10 | #include "simplealarmclient.h" |
11 | 11 | ||
12 | class QAction; | 12 | class QAction; |
13 | class CalendarView; | 13 | class CalendarView; |
14 | class KSyncProfile; | 14 | class KSyncProfile; |
15 | #ifdef DESKTOP_VERSION | 15 | #ifdef DESKTOP_VERSION |
16 | 16 | ||
17 | #define QPEToolBar QToolBar | 17 | #define QPEToolBar QToolBar |
18 | #define QPEMenuBar QMenuBar | 18 | #define QPEMenuBar QMenuBar |
19 | #endif | 19 | #endif |
20 | class QPEToolBar; | 20 | class QPEToolBar; |
21 | #include <qserversocket.h> | 21 | #include <qserversocket.h> |
22 | #include <qsocket.h> | 22 | #include <qsocket.h> |
23 | #include <qnetworkprotocol.h> | 23 | #include <qnetworkprotocol.h> |
24 | 24 | ||
25 | class KServerSocket : public QServerSocket | 25 | class KServerSocket : public QServerSocket |
26 | { | 26 | { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | 28 | ||
29 | public: | 29 | public: |
30 | KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ) : | 30 | KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
31 | QServerSocket( port, backlog, parent, name ){;}; | 31 | |
32 | void newConnection ( int socket ) | 32 | void newConnection ( int socket ) ; |
33 | { | ||
34 | qDebug("KServerSocket:New connection %d ", socket); | ||
35 | QSocket* s = new QSocket( this ); | ||
36 | connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) ); | ||
37 | connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | ||
38 | s->setSocket( socket ); | ||
39 | } | ||
40 | 33 | ||
41 | signals: | 34 | signals: |
42 | void sendFile(QSocket*); | 35 | void sendFile(QSocket*); |
43 | void getFile(QSocket*); | 36 | void getFile(QSocket*); |
44 | void endConnect(); | 37 | void endConnect(); |
45 | private slots: | 38 | private slots: |
46 | void discardClient() | 39 | void discardClient(); |
47 | { | 40 | void readClient(); |
48 | QSocket* socket = (QSocket*)sender(); | ||
49 | delete socket; | ||
50 | //emit endConnect(); | ||
51 | } | ||
52 | void readClient() | ||
53 | { | ||
54 | qDebug("readClient() "); | ||
55 | QSocket* socket = (QSocket*)sender(); | ||
56 | if ( socket->canReadLine() ) { | ||
57 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() ); | ||
58 | if ( tokens[0] == "GET" ) { | ||
59 | emit sendFile( socket ); | ||
60 | } | ||
61 | if ( tokens[0] == "PUT" ) { | ||
62 | emit getFile( socket ); | ||
63 | } | ||
64 | if ( tokens[0] == "STOP" ) { | ||
65 | emit endConnect(); | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | }; | 41 | }; |
70 | 42 | ||
71 | 43 | ||
72 | namespace KCal { | 44 | namespace KCal { |
73 | class CalendarLocal; | 45 | class CalendarLocal; |
74 | } | 46 | } |
75 | 47 | ||
76 | using namespace KCal; | 48 | using namespace KCal; |
77 | 49 | ||
78 | class MainWindow : public QMainWindow | 50 | class MainWindow : public QMainWindow |
79 | { | 51 | { |
80 | Q_OBJECT | 52 | Q_OBJECT |
81 | public: | 53 | public: |
82 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 54 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
83 | ~MainWindow(); | 55 | ~MainWindow(); |
84 | public slots: | 56 | public slots: |
85 | virtual void showMaximized (); | 57 | virtual void showMaximized (); |
86 | void configureAgenda( int ); | 58 | void configureAgenda( int ); |
87 | void recieve( const QCString& msg, const QByteArray& data ); | 59 | void recieve( const QCString& msg, const QByteArray& data ); |
88 | static QString defaultFileName(); | 60 | static QString defaultFileName(); |
89 | static QString resourcePath(); | 61 | static QString resourcePath(); |
90 | protected slots: | 62 | protected slots: |
91 | void setCaptionToDates(); | 63 | void setCaptionToDates(); |
92 | int ringSync(); | 64 | int ringSync(); |
93 | void multiSync( bool askforPrefs = false ); | 65 | void multiSync( bool askforPrefs = false ); |
94 | void about(); | 66 | void about(); |
95 | void licence(); | 67 | void licence(); |
96 | void faq(); | 68 | void faq(); |
97 | void usertrans(); | 69 | void usertrans(); |
98 | void features(); | 70 | void features(); |
99 | void synchowto(); | 71 | void synchowto(); |
100 | void whatsNew(); | 72 | void whatsNew(); |
101 | void keyBindings(); | 73 | void keyBindings(); |
102 | void aboutAutoSaving();; | 74 | void aboutAutoSaving();; |
103 | void aboutKnownBugs(); | 75 | void aboutKnownBugs(); |
104 | 76 | ||
105 | void processIncidenceSelection( Incidence * ); | 77 | void processIncidenceSelection( Incidence * ); |
106 | 78 | ||
107 | void importQtopia(); | 79 | void importQtopia(); |
108 | void importBday(); | 80 | void importBday(); |
109 | void importOL(); | 81 | void importOL(); |
110 | void importIcal(); | 82 | void importIcal(); |
111 | void importFile( QString, bool ); | 83 | void importFile( QString, bool ); |
112 | void quickImportIcal(); | 84 | void quickImportIcal(); |
113 | 85 | ||
114 | void slotModifiedChanged( bool ); | 86 | void slotModifiedChanged( bool ); |
115 | 87 | ||
116 | void save(); | 88 | void save(); |
117 | void configureToolBar( int ); | 89 | void configureToolBar( int ); |
118 | void printSel(); | 90 | void printSel(); |
119 | void printCal(); | 91 | void printCal(); |
120 | void saveCalendar(); | 92 | void saveCalendar(); |
121 | void loadCalendar(); | 93 | void loadCalendar(); |
122 | void exportVCalendar(); | 94 | void exportVCalendar(); |
123 | void fillFilterMenu(); | 95 | void fillFilterMenu(); |
124 | void selectFilter( int ); | 96 | void selectFilter( int ); |
125 | 97 | ||
126 | void slotSyncMenu( int ); | 98 | void slotSyncMenu( int ); |
127 | void syncSSH(); | 99 | void syncSSH(); |
128 | void confSync(); | 100 | void confSync(); |
129 | void syncSharp(); | 101 | void syncSharp(); |
130 | void syncPhone(); | 102 | void syncPhone(); |
131 | void syncLocalFile(); | 103 | void syncLocalFile(); |
132 | bool syncWithFile( QString, bool ); | 104 | bool syncWithFile( QString, bool ); |
133 | void quickSyncLocalFile(); | 105 | void quickSyncLocalFile(); |
134 | 106 | ||
135 | 107 | ||
136 | protected: | 108 | protected: |
137 | void displayText( QString, QString); | 109 | void displayText( QString, QString); |
138 | void displayFile( QString, QString); | 110 | void displayFile( QString, QString); |
139 | 111 | ||
140 | void enableIncidenceActions( bool ); | 112 | void enableIncidenceActions( bool ); |
141 | 113 | ||
142 | private slots: | 114 | private slots: |
143 | void fillSyncMenu(); | 115 | void fillSyncMenu(); |
144 | void sendFile(QSocket* s); | 116 | void sendFile(QSocket* s); |
145 | void getFile(QSocket* socket); | 117 | void getFile(QSocket* socket); |
146 | void readFileFromSocket(); | 118 | void readFileFromSocket(); |
147 | void endConnect(); | 119 | void endConnect(); |
148 | private: | 120 | private: |
149 | QSocket* mCommandSocket; | 121 | QSocket* mCommandSocket; |
150 | QSocket* mCommandSocketFinish; | 122 | QSocket* mCommandSocketFinish; |
151 | KServerSocket * mServerSocket; | 123 | KServerSocket * mServerSocket; |
152 | bool mClosed; | 124 | bool mClosed; |
153 | void saveOnClose(); | 125 | void saveOnClose(); |
154 | int mCurrentSyncProfile; | 126 | int mCurrentSyncProfile; |
155 | void enableQuick(); | 127 | void enableQuick(); |
156 | void performQuick(); | 128 | void performQuick(); |
157 | void performQuickQuick(); | 129 | void performQuickQuick(); |
158 | void syncRemote( KSyncProfile* , bool ask = true); | 130 | void syncRemote( KSyncProfile* , bool ask = true); |
159 | bool mFlagKeyPressed; | 131 | bool mFlagKeyPressed; |
160 | bool mBlockAtStartup; | 132 | bool mBlockAtStartup; |
161 | QPEToolBar *iconToolBar; | 133 | QPEToolBar *iconToolBar; |
162 | void initActions(); | 134 | void initActions(); |
163 | void setDefaultPreferences(); | 135 | void setDefaultPreferences(); |
164 | void keyPressEvent ( QKeyEvent * ) ; | 136 | void keyPressEvent ( QKeyEvent * ) ; |