author | zautrix <zautrix> | 2005-01-26 00:32:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-26 00:32:18 (UTC) |
commit | c3ec0a5a43fb328f2d190b8adee1ef662746fb41 (patch) (unidiff) | |
tree | dd34f587205f8567a59bf7abb6161e1ba6667444 | |
parent | eeb9059d1cbf2ffb13300d0491b4b61126507373 (diff) | |
download | kdepimpi-c3ec0a5a43fb328f2d190b8adee1ef662746fb41.zip kdepimpi-c3ec0a5a43fb328f2d190b8adee1ef662746fb41.tar.gz kdepimpi-c3ec0a5a43fb328f2d190b8adee1ef662746fb41.tar.bz2 |
debug fixes
-rw-r--r-- | bin/kdepim/korganizer/allday.png | bin | 0 -> 279 bytes | |||
-rw-r--r-- | bin/kdepim/korganizer/icons16/allday.png | bin | 0 -> 271 bytes | |||
-rw-r--r-- | bin/kdepim/korganizer/iconsmini/allday.png | bin | 0 -> 273 bytes | |||
-rw-r--r-- | bin/kdepim/korganizer/iconsmini/configure.png | bin | 0 -> 763 bytes | |||
-rw-r--r-- | kaddressbook/kabcore.cpp | 40 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 21 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 3 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 34 |
8 files changed, 50 insertions, 48 deletions
diff --git a/bin/kdepim/korganizer/allday.png b/bin/kdepim/korganizer/allday.png new file mode 100644 index 0000000..735eae2 --- a/dev/null +++ b/bin/kdepim/korganizer/allday.png | |||
Binary files differ | |||
diff --git a/bin/kdepim/korganizer/icons16/allday.png b/bin/kdepim/korganizer/icons16/allday.png new file mode 100644 index 0000000..426d250 --- a/dev/null +++ b/bin/kdepim/korganizer/icons16/allday.png | |||
Binary files differ | |||
diff --git a/bin/kdepim/korganizer/iconsmini/allday.png b/bin/kdepim/korganizer/iconsmini/allday.png new file mode 100644 index 0000000..be9a2ba --- a/dev/null +++ b/bin/kdepim/korganizer/iconsmini/allday.png | |||
Binary files differ | |||
diff --git a/bin/kdepim/korganizer/iconsmini/configure.png b/bin/kdepim/korganizer/iconsmini/configure.png new file mode 100644 index 0000000..ad965e2 --- a/dev/null +++ b/bin/kdepim/korganizer/iconsmini/configure.png | |||
Binary files differ | |||
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 590cc82..ae0a068 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,3321 +1,3321 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /*s | 24 | /*s |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kfiledialog.h> | 35 | #include <kfiledialog.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
43 | #include <libkdepim/phoneaccess.h> | 43 | #include <libkdepim/phoneaccess.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | #include <qapplicaton.h> | 49 | #include <qapplicaton.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qvbox.h> | 53 | #include <qvbox.h> |
54 | #include <kabc/addresseelist.h> | 54 | #include <kabc/addresseelist.h> |
55 | #include <kabc/errorhandler.h> | 55 | #include <kabc/errorhandler.h> |
56 | #include <kabc/resource.h> | 56 | #include <kabc/resource.h> |
57 | #include <kabc/vcardconverter.h> | 57 | #include <kabc/vcardconverter.h> |
58 | #include <kapplication.h> | 58 | #include <kapplication.h> |
59 | #include <kactionclasses.h> | 59 | #include <kactionclasses.h> |
60 | #include <kcmultidialog.h> | 60 | #include <kcmultidialog.h> |
61 | #include <kdebug.h> | 61 | #include <kdebug.h> |
62 | #include <kdeversion.h> | 62 | #include <kdeversion.h> |
63 | #include <kkeydialog.h> | 63 | #include <kkeydialog.h> |
64 | #include <kmessagebox.h> | 64 | #include <kmessagebox.h> |
65 | #include <kprinter.h> | 65 | #include <kprinter.h> |
66 | #include <kprotocolinfo.h> | 66 | #include <kprotocolinfo.h> |
67 | #include <kresources/selectdialog.h> | 67 | #include <kresources/selectdialog.h> |
68 | #include <kstandarddirs.h> | 68 | #include <kstandarddirs.h> |
69 | #include <ktempfile.h> | 69 | #include <ktempfile.h> |
70 | #include <kxmlguiclient.h> | 70 | #include <kxmlguiclient.h> |
71 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> |
72 | #include <libkdepim/categoryselectdialog.h> | 72 | #include <libkdepim/categoryselectdialog.h> |
73 | 73 | ||
74 | #include "addresseeutil.h" | 74 | #include "addresseeutil.h" |
75 | #include "addresseeeditordialog.h" | 75 | #include "addresseeeditordialog.h" |
76 | #include "extensionmanager.h" | 76 | #include "extensionmanager.h" |
77 | #include "kstdaction.h" | 77 | #include "kstdaction.h" |
78 | #include "kaddressbookservice.h" | 78 | #include "kaddressbookservice.h" |
79 | #include "ldapsearchdialog.h" | 79 | #include "ldapsearchdialog.h" |
80 | #include "printing/printingwizard.h" | 80 | #include "printing/printingwizard.h" |
81 | #else // KAB_EMBEDDED | 81 | #else // KAB_EMBEDDED |
82 | 82 | ||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | 99 | ||
100 | 100 | ||
101 | //#include <qlabel.h> | 101 | //#include <qlabel.h> |
102 | 102 | ||
103 | 103 | ||
104 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
105 | #include <qpe/ir.h> | 105 | #include <qpe/ir.h> |
106 | #include <qpe/qpemenubar.h> | 106 | #include <qpe/qpemenubar.h> |
107 | #include <qtopia/qcopenvelope_qws.h> | 107 | #include <qtopia/qcopenvelope_qws.h> |
108 | #else | 108 | #else |
109 | 109 | ||
110 | #include <qmenubar.h> | 110 | #include <qmenubar.h> |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #endif // KAB_EMBEDDED | 113 | #endif // KAB_EMBEDDED |
114 | #include "kcmconfigs/kcmkabconfig.h" | 114 | #include "kcmconfigs/kcmkabconfig.h" |
115 | #include "kcmconfigs/kcmkdepimconfig.h" | 115 | #include "kcmconfigs/kcmkdepimconfig.h" |
116 | #include "kpimglobalprefs.h" | 116 | #include "kpimglobalprefs.h" |
117 | #include "externalapphandler.h" | 117 | #include "externalapphandler.h" |
118 | #include "xxportselectdialog.h" | 118 | #include "xxportselectdialog.h" |
119 | 119 | ||
120 | 120 | ||
121 | #include <kresources/selectdialog.h> | 121 | #include <kresources/selectdialog.h> |
122 | #include <kmessagebox.h> | 122 | #include <kmessagebox.h> |
123 | 123 | ||
124 | #include <picture.h> | 124 | #include <picture.h> |
125 | #include <resource.h> | 125 | #include <resource.h> |
126 | 126 | ||
127 | //US#include <qsplitter.h> | 127 | //US#include <qsplitter.h> |
128 | #include <qmap.h> | 128 | #include <qmap.h> |
129 | #include <qdir.h> | 129 | #include <qdir.h> |
130 | #include <qfile.h> | 130 | #include <qfile.h> |
131 | #include <qvbox.h> | 131 | #include <qvbox.h> |
132 | #include <qlayout.h> | 132 | #include <qlayout.h> |
133 | #include <qclipboard.h> | 133 | #include <qclipboard.h> |
134 | #include <qtextstream.h> | 134 | #include <qtextstream.h> |
135 | #include <qradiobutton.h> | 135 | #include <qradiobutton.h> |
136 | #include <qbuttongroup.h> | 136 | #include <qbuttongroup.h> |
137 | 137 | ||
138 | #include <libkdepim/categoryselectdialog.h> | 138 | #include <libkdepim/categoryselectdialog.h> |
139 | #include <libkdepim/categoryeditdialog.h> | 139 | #include <libkdepim/categoryeditdialog.h> |
140 | #include <kabc/vcardconverter.h> | 140 | #include <kabc/vcardconverter.h> |
141 | 141 | ||
142 | 142 | ||
143 | #include "addresseeutil.h" | 143 | #include "addresseeutil.h" |
144 | #include "undocmds.h" | 144 | #include "undocmds.h" |
145 | #include "addresseeeditordialog.h" | 145 | #include "addresseeeditordialog.h" |
146 | #include "viewmanager.h" | 146 | #include "viewmanager.h" |
147 | #include "details/detailsviewcontainer.h" | 147 | #include "details/detailsviewcontainer.h" |
148 | #include "kabprefs.h" | 148 | #include "kabprefs.h" |
149 | #include "xxportmanager.h" | 149 | #include "xxportmanager.h" |
150 | #include "incsearchwidget.h" | 150 | #include "incsearchwidget.h" |
151 | #include "jumpbuttonbar.h" | 151 | #include "jumpbuttonbar.h" |
152 | #include "extensionmanager.h" | 152 | #include "extensionmanager.h" |
153 | #include "addresseeconfig.h" | 153 | #include "addresseeconfig.h" |
154 | #include "nameeditdialog.h" | 154 | #include "nameeditdialog.h" |
155 | #include <kcmultidialog.h> | 155 | #include <kcmultidialog.h> |
156 | 156 | ||
157 | #ifdef _WIN32_ | 157 | #ifdef _WIN32_ |
158 | #ifdef _OL_IMPORT_ | 158 | #ifdef _OL_IMPORT_ |
159 | #include "kaimportoldialog.h" | 159 | #include "kaimportoldialog.h" |
160 | #endif | 160 | #endif |
161 | #else | 161 | #else |
162 | #include <unistd.h> | 162 | #include <unistd.h> |
163 | #endif | 163 | #endif |
164 | // sync includes | 164 | // sync includes |
165 | #include <libkdepim/ksyncprofile.h> | 165 | #include <libkdepim/ksyncprofile.h> |
166 | #include <libkdepim/ksyncprefsdialog.h> | 166 | #include <libkdepim/ksyncprefsdialog.h> |
167 | 167 | ||
168 | 168 | ||
169 | class KABCatPrefs : public QDialog | 169 | class KABCatPrefs : public QDialog |
170 | { | 170 | { |
171 | public: | 171 | public: |
172 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : | 172 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : |
173 | QDialog( parent, name, true ) | 173 | QDialog( parent, name, true ) |
174 | { | 174 | { |
175 | setCaption( i18n("Manage new Categories") ); | 175 | setCaption( i18n("Manage new Categories") ); |
176 | QVBoxLayout* lay = new QVBoxLayout( this ); | 176 | QVBoxLayout* lay = new QVBoxLayout( this ); |
177 | lay->setSpacing( 3 ); | 177 | lay->setSpacing( 3 ); |
178 | lay->setMargin( 3 ); | 178 | lay->setMargin( 3 ); |
179 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 179 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
180 | lay->addWidget( lab ); | 180 | lay->addWidget( lab ); |
181 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 181 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
182 | lay->addWidget( format ); | 182 | lay->addWidget( format ); |
183 | format->setExclusive ( true ) ; | 183 | format->setExclusive ( true ) ; |
184 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 184 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
185 | new QRadioButton(i18n("Remove from addressees"), format ); | 185 | new QRadioButton(i18n("Remove from addressees"), format ); |
186 | addCatBut->setChecked( true ); | 186 | addCatBut->setChecked( true ); |
187 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 187 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
188 | lay->addWidget( ok ); | 188 | lay->addWidget( ok ); |
189 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 189 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
190 | lay->addWidget( cancel ); | 190 | lay->addWidget( cancel ); |
191 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 191 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
192 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 192 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
193 | resize( 200, 200 ); | 193 | resize( 200, 200 ); |
194 | } | 194 | } |
195 | 195 | ||
196 | bool addCat() { return addCatBut->isChecked(); } | 196 | bool addCat() { return addCatBut->isChecked(); } |
197 | private: | 197 | private: |
198 | QRadioButton* addCatBut; | 198 | QRadioButton* addCatBut; |
199 | }; | 199 | }; |
200 | 200 | ||
201 | class KABFormatPrefs : public QDialog | 201 | class KABFormatPrefs : public QDialog |
202 | { | 202 | { |
203 | public: | 203 | public: |
204 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : | 204 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : |
205 | QDialog( parent, name, true ) | 205 | QDialog( parent, name, true ) |
206 | { | 206 | { |
207 | setCaption( i18n("Set formatted name") ); | 207 | setCaption( i18n("Set formatted name") ); |
208 | QVBoxLayout* lay = new QVBoxLayout( this ); | 208 | QVBoxLayout* lay = new QVBoxLayout( this ); |
209 | lay->setSpacing( 3 ); | 209 | lay->setSpacing( 3 ); |
210 | lay->setMargin( 3 ); | 210 | lay->setMargin( 3 ); |
211 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); | 211 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); |
212 | lay->addWidget( lab ); | 212 | lay->addWidget( lab ); |
213 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); | 213 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); |
214 | lay->addWidget( format ); | 214 | lay->addWidget( format ); |
215 | format->setExclusive ( true ) ; | 215 | format->setExclusive ( true ) ; |
216 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); | 216 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); |
217 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); | 217 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); |
218 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); | 218 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); |
219 | company = new QRadioButton(i18n("Organization: MI6"), format ); | 219 | company = new QRadioButton(i18n("Organization: MI6"), format ); |
220 | simple->setChecked( true ); | 220 | simple->setChecked( true ); |
221 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); | 221 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); |
222 | lay->addWidget( setCompany ); | 222 | lay->addWidget( setCompany ); |
223 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); | 223 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); |
224 | lay->addWidget( ok ); | 224 | lay->addWidget( ok ); |
225 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 225 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
226 | lay->addWidget( cancel ); | 226 | lay->addWidget( cancel ); |
227 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 227 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
228 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 228 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
229 | //resize( 200, 200 ); | 229 | //resize( 200, 200 ); |
230 | 230 | ||
231 | } | 231 | } |
232 | public: | 232 | public: |
233 | QRadioButton* simple, *full, *reverse, *company; | 233 | QRadioButton* simple, *full, *reverse, *company; |
234 | QCheckBox* setCompany; | 234 | QCheckBox* setCompany; |
235 | }; | 235 | }; |
236 | 236 | ||
237 | 237 | ||
238 | 238 | ||
239 | class KAex2phonePrefs : public QDialog | 239 | class KAex2phonePrefs : public QDialog |
240 | { | 240 | { |
241 | public: | 241 | public: |
242 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 242 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
243 | QDialog( parent, name, true ) | 243 | QDialog( parent, name, true ) |
244 | { | 244 | { |
245 | setCaption( i18n("Export to phone options") ); | 245 | setCaption( i18n("Export to phone options") ); |
246 | QVBoxLayout* lay = new QVBoxLayout( this ); | 246 | QVBoxLayout* lay = new QVBoxLayout( this ); |
247 | lay->setSpacing( 3 ); | 247 | lay->setSpacing( 3 ); |
248 | lay->setMargin( 3 ); | 248 | lay->setMargin( 3 ); |
249 | QLabel *lab; | 249 | QLabel *lab; |
250 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 250 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
251 | lab->setAlignment (AlignHCenter ); | 251 | lab->setAlignment (AlignHCenter ); |
252 | QHBox* temphb; | 252 | QHBox* temphb; |
253 | temphb = new QHBox( this ); | 253 | temphb = new QHBox( this ); |
254 | new QLabel( i18n("I/O device: "), temphb ); | 254 | new QLabel( i18n("I/O device: "), temphb ); |
255 | mPhoneDevice = new QLineEdit( temphb); | 255 | mPhoneDevice = new QLineEdit( temphb); |
256 | lay->addWidget( temphb ); | 256 | lay->addWidget( temphb ); |
257 | temphb = new QHBox( this ); | 257 | temphb = new QHBox( this ); |
258 | new QLabel( i18n("Connection: "), temphb ); | 258 | new QLabel( i18n("Connection: "), temphb ); |
259 | mPhoneConnection = new QLineEdit( temphb); | 259 | mPhoneConnection = new QLineEdit( temphb); |
260 | lay->addWidget( temphb ); | 260 | lay->addWidget( temphb ); |
261 | temphb = new QHBox( this ); | 261 | temphb = new QHBox( this ); |
262 | new QLabel( i18n("Model(opt.): "), temphb ); | 262 | new QLabel( i18n("Model(opt.): "), temphb ); |
263 | mPhoneModel = new QLineEdit( temphb); | 263 | mPhoneModel = new QLineEdit( temphb); |
264 | lay->addWidget( temphb ); | 264 | lay->addWidget( temphb ); |
265 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 265 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
266 | // lay->addWidget( mWriteToSim ); | 266 | // lay->addWidget( mWriteToSim ); |
267 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 267 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
268 | lab->setAlignment (AlignHCenter); | 268 | lab->setAlignment (AlignHCenter); |
269 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 269 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
270 | lay->addWidget( ok ); | 270 | lay->addWidget( ok ); |
271 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 271 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
272 | lay->addWidget( cancel ); | 272 | lay->addWidget( cancel ); |
273 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 273 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
274 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 274 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
275 | resize( 220, 240 ); | 275 | resize( 220, 240 ); |
276 | 276 | ||
277 | } | 277 | } |
278 | 278 | ||
279 | public: | 279 | public: |
280 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 280 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
281 | QCheckBox* mWriteToSim; | 281 | QCheckBox* mWriteToSim; |
282 | }; | 282 | }; |
283 | 283 | ||
284 | 284 | ||
285 | bool pasteWithNewUid = true; | 285 | bool pasteWithNewUid = true; |
286 | 286 | ||
287 | #ifdef KAB_EMBEDDED | 287 | #ifdef KAB_EMBEDDED |
288 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 288 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
289 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 289 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
290 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 290 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
291 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 291 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
292 | #else //KAB_EMBEDDED | 292 | #else //KAB_EMBEDDED |
293 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 293 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
294 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 294 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
295 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 295 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
296 | mReadWrite( readWrite ), mModified( false ) | 296 | mReadWrite( readWrite ), mModified( false ) |
297 | #endif //KAB_EMBEDDED | 297 | #endif //KAB_EMBEDDED |
298 | { | 298 | { |
299 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 299 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
300 | // syncManager->setBlockSave(false); | 300 | // syncManager->setBlockSave(false); |
301 | mMiniSplitter = 0; | 301 | mMiniSplitter = 0; |
302 | mExtensionBarSplitter = 0; | 302 | mExtensionBarSplitter = 0; |
303 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 303 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
304 | mAddressBook = KABC::StdAddressBook::self(); | 304 | mAddressBook = KABC::StdAddressBook::self(); |
305 | KABC::StdAddressBook::setAutomaticSave( false ); | 305 | KABC::StdAddressBook::setAutomaticSave( false ); |
306 | 306 | ||
307 | #ifndef KAB_EMBEDDED | 307 | #ifndef KAB_EMBEDDED |
308 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 308 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
309 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
310 | 310 | ||
311 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 311 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
312 | SLOT( addressBookChanged() ) ); | 312 | SLOT( addressBookChanged() ) ); |
313 | 313 | ||
314 | #if 0 | 314 | #if 0 |
315 | // LP moved to addressbook init method | 315 | // LP moved to addressbook init method |
316 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 316 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
317 | "X-Department", "KADDRESSBOOK" ); | 317 | "X-Department", "KADDRESSBOOK" ); |
318 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 318 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
319 | "X-Profession", "KADDRESSBOOK" ); | 319 | "X-Profession", "KADDRESSBOOK" ); |
320 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 320 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
321 | "X-AssistantsName", "KADDRESSBOOK" ); | 321 | "X-AssistantsName", "KADDRESSBOOK" ); |
322 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 322 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
323 | "X-ManagersName", "KADDRESSBOOK" ); | 323 | "X-ManagersName", "KADDRESSBOOK" ); |
324 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 324 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
325 | "X-SpousesName", "KADDRESSBOOK" ); | 325 | "X-SpousesName", "KADDRESSBOOK" ); |
326 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 326 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
327 | "X-Office", "KADDRESSBOOK" ); | 327 | "X-Office", "KADDRESSBOOK" ); |
328 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 328 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
329 | "X-IMAddress", "KADDRESSBOOK" ); | 329 | "X-IMAddress", "KADDRESSBOOK" ); |
330 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 330 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
331 | "X-Anniversary", "KADDRESSBOOK" ); | 331 | "X-Anniversary", "KADDRESSBOOK" ); |
332 | 332 | ||
333 | //US added this field to become compatible with Opie/qtopia addressbook | 333 | //US added this field to become compatible with Opie/qtopia addressbook |
334 | // values can be "female" or "male" or "". An empty field represents undefined. | 334 | // values can be "female" or "male" or "". An empty field represents undefined. |
335 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 335 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
336 | "X-Gender", "KADDRESSBOOK" ); | 336 | "X-Gender", "KADDRESSBOOK" ); |
337 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 337 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
338 | "X-Children", "KADDRESSBOOK" ); | 338 | "X-Children", "KADDRESSBOOK" ); |
339 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 339 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
340 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 340 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
341 | #endif | 341 | #endif |
342 | initGUI(); | 342 | initGUI(); |
343 | 343 | ||
344 | mIncSearchWidget->setFocus(); | 344 | mIncSearchWidget->setFocus(); |
345 | 345 | ||
346 | 346 | ||
347 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 347 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
348 | SLOT( setContactSelected( const QString& ) ) ); | 348 | SLOT( setContactSelected( const QString& ) ) ); |
349 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 349 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
350 | SLOT( executeContact( const QString& ) ) ); | 350 | SLOT( executeContact( const QString& ) ) ); |
351 | 351 | ||
352 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 352 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
353 | SLOT( deleteContacts( ) ) ); | 353 | SLOT( deleteContacts( ) ) ); |
354 | connect( mViewManager, SIGNAL( modified() ), | 354 | connect( mViewManager, SIGNAL( modified() ), |
355 | SLOT( setModified() ) ); | 355 | SLOT( setModified() ) ); |
356 | 356 | ||
357 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 357 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
358 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 358 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
359 | 359 | ||
360 | connect( mXXPortManager, SIGNAL( modified() ), | 360 | connect( mXXPortManager, SIGNAL( modified() ), |
361 | SLOT( setModified() ) ); | 361 | SLOT( setModified() ) ); |
362 | 362 | ||
363 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 363 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
364 | SLOT( incrementalSearch( const QString& ) ) ); | 364 | SLOT( incrementalSearch( const QString& ) ) ); |
365 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 365 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
366 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 366 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
367 | 367 | ||
368 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 368 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
369 | SLOT( sendMail( const QString& ) ) ); | 369 | SLOT( sendMail( const QString& ) ) ); |
370 | 370 | ||
371 | 371 | ||
372 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 372 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
373 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 373 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
374 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 374 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
375 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); | 375 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); |
376 | 376 | ||
377 | 377 | ||
378 | #ifndef KAB_EMBEDDED | 378 | #ifndef KAB_EMBEDDED |
379 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 379 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
380 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 380 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
381 | 381 | ||
382 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 382 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
383 | SLOT( browse( const QString& ) ) ); | 383 | SLOT( browse( const QString& ) ) ); |
384 | 384 | ||
385 | 385 | ||
386 | mAddressBookService = new KAddressBookService( this ); | 386 | mAddressBookService = new KAddressBookService( this ); |
387 | 387 | ||
388 | #endif //KAB_EMBEDDED | 388 | #endif //KAB_EMBEDDED |
389 | 389 | ||
390 | mMessageTimer = new QTimer( this ); | 390 | mMessageTimer = new QTimer( this ); |
391 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 391 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
392 | mEditorDialog = 0; | 392 | mEditorDialog = 0; |
393 | createAddresseeEditorDialog( this ); | 393 | createAddresseeEditorDialog( this ); |
394 | setModified( false ); | 394 | setModified( false ); |
395 | mBRdisabled = false; | 395 | mBRdisabled = false; |
396 | #ifndef DESKTOP_VERSION | 396 | #ifndef DESKTOP_VERSION |
397 | infrared = 0; | 397 | infrared = 0; |
398 | #endif | 398 | #endif |
399 | //toggleBeamReceive( ); | 399 | //toggleBeamReceive( ); |
400 | //mMainWindow->toolBar()->show(); | 400 | //mMainWindow->toolBar()->show(); |
401 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi | 401 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi |
402 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 402 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
403 | } | 403 | } |
404 | 404 | ||
405 | void KABCore::updateToolBar() | 405 | void KABCore::updateToolBar() |
406 | { | 406 | { |
407 | static int iii = 0; | 407 | static int iii = 0; |
408 | ++iii; | 408 | ++iii; |
409 | mMainWindow->toolBar()->repaintMe(); | 409 | mMainWindow->toolBar()->repaintMe(); |
410 | if ( iii < 3 ) | 410 | if ( iii < 3 ) |
411 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 411 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
412 | } | 412 | } |
413 | KABCore::~KABCore() | 413 | KABCore::~KABCore() |
414 | { | 414 | { |
415 | // save(); | 415 | // save(); |
416 | //saveSettings(); | 416 | //saveSettings(); |
417 | //KABPrefs::instance()->writeConfig(); | 417 | //KABPrefs::instance()->writeConfig(); |
418 | delete AddresseeConfig::instance(); | 418 | delete AddresseeConfig::instance(); |
419 | mAddressBook = 0; | 419 | mAddressBook = 0; |
420 | KABC::StdAddressBook::close(); | 420 | KABC::StdAddressBook::close(); |
421 | 421 | ||
422 | delete syncManager; | 422 | delete syncManager; |
423 | #ifndef DESKTOP_VERSION | 423 | #ifndef DESKTOP_VERSION |
424 | if ( infrared ) | 424 | if ( infrared ) |
425 | delete infrared; | 425 | delete infrared; |
426 | #endif | 426 | #endif |
427 | } | 427 | } |
428 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 428 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
429 | { | 429 | { |
430 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 430 | //qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
431 | if ( cmsg == "setDocument(QString)" ) { | 431 | if ( cmsg == "setDocument(QString)" ) { |
432 | QDataStream stream( data, IO_ReadOnly ); | 432 | QDataStream stream( data, IO_ReadOnly ); |
433 | QString fileName; | 433 | QString fileName; |
434 | stream >> fileName; | 434 | stream >> fileName; |
435 | recieve( fileName ); | 435 | recieve( fileName ); |
436 | return; | 436 | return; |
437 | } | 437 | } |
438 | } | 438 | } |
439 | void KABCore::toggleBeamReceive( ) | 439 | void KABCore::toggleBeamReceive( ) |
440 | { | 440 | { |
441 | if ( mBRdisabled ) | 441 | if ( mBRdisabled ) |
442 | return; | 442 | return; |
443 | #ifndef DESKTOP_VERSION | 443 | #ifndef DESKTOP_VERSION |
444 | if ( infrared ) { | 444 | if ( infrared ) { |
445 | qDebug("AB disable BeamReceive "); | 445 | qDebug("KA: AB disable BeamReceive "); |
446 | delete infrared; | 446 | delete infrared; |
447 | infrared = 0; | 447 | infrared = 0; |
448 | mActionBR->setChecked(false); | 448 | mActionBR->setChecked(false); |
449 | return; | 449 | return; |
450 | } | 450 | } |
451 | qDebug("AB enable BeamReceive "); | 451 | qDebug("KA: AB enable BeamReceive "); |
452 | mActionBR->setChecked(true); | 452 | mActionBR->setChecked(true); |
453 | 453 | ||
454 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 454 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
455 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 455 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
456 | #endif | 456 | #endif |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | void KABCore::disableBR(bool b) | 460 | void KABCore::disableBR(bool b) |
461 | { | 461 | { |
462 | #ifndef DESKTOP_VERSION | 462 | #ifndef DESKTOP_VERSION |
463 | if ( b ) { | 463 | if ( b ) { |
464 | if ( infrared ) { | 464 | if ( infrared ) { |
465 | toggleBeamReceive( ); | 465 | toggleBeamReceive( ); |
466 | } | 466 | } |
467 | mBRdisabled = true; | 467 | mBRdisabled = true; |
468 | } else { | 468 | } else { |
469 | if ( mBRdisabled ) { | 469 | if ( mBRdisabled ) { |
470 | mBRdisabled = false; | 470 | mBRdisabled = false; |
471 | //toggleBeamReceive( ); | 471 | //toggleBeamReceive( ); |
472 | } | 472 | } |
473 | } | 473 | } |
474 | #endif | 474 | #endif |
475 | 475 | ||
476 | } | 476 | } |
477 | void KABCore::recieve( QString fn ) | 477 | void KABCore::recieve( QString fn ) |
478 | { | 478 | { |
479 | //qDebug("KABCore::recieve "); | 479 | //qDebug("KABCore::recieve "); |
480 | int count = mAddressBook->importFromFile( fn, true ); | 480 | int count = mAddressBook->importFromFile( fn, true ); |
481 | if ( count ) | 481 | if ( count ) |
482 | setModified( true ); | 482 | setModified( true ); |
483 | mViewManager->refreshView(); | 483 | mViewManager->refreshView(); |
484 | message(i18n("%1 contact(s) received!").arg( count )); | 484 | message(i18n("%1 contact(s) received!").arg( count )); |
485 | topLevelWidget()->showMaximized(); | 485 | topLevelWidget()->showMaximized(); |
486 | topLevelWidget()->raise(); | 486 | topLevelWidget()->raise(); |
487 | } | 487 | } |
488 | void KABCore::restoreSettings() | 488 | void KABCore::restoreSettings() |
489 | { | 489 | { |
490 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 490 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
491 | 491 | ||
492 | bool state; | 492 | bool state; |
493 | 493 | ||
494 | if (mMultipleViewsAtOnce) | 494 | if (mMultipleViewsAtOnce) |
495 | state = KABPrefs::instance()->mDetailsPageVisible; | 495 | state = KABPrefs::instance()->mDetailsPageVisible; |
496 | else | 496 | else |
497 | state = false; | 497 | state = false; |
498 | 498 | ||
499 | mActionDetails->setChecked( state ); | 499 | mActionDetails->setChecked( state ); |
500 | setDetailsVisible( state ); | 500 | setDetailsVisible( state ); |
501 | 501 | ||
502 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 502 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
503 | 503 | ||
504 | mActionJumpBar->setChecked( state ); | 504 | mActionJumpBar->setChecked( state ); |
505 | setJumpButtonBarVisible( state ); | 505 | setJumpButtonBarVisible( state ); |
506 | /*US | 506 | /*US |
507 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 507 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
508 | if ( splitterSize.count() == 0 ) { | 508 | if ( splitterSize.count() == 0 ) { |
509 | splitterSize.append( width() / 2 ); | 509 | splitterSize.append( width() / 2 ); |
510 | splitterSize.append( width() / 2 ); | 510 | splitterSize.append( width() / 2 ); |
511 | } | 511 | } |
512 | mMiniSplitter->setSizes( splitterSize ); | 512 | mMiniSplitter->setSizes( splitterSize ); |
513 | if ( mExtensionBarSplitter ) { | 513 | if ( mExtensionBarSplitter ) { |
514 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 514 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
515 | if ( splitterSize.count() == 0 ) { | 515 | if ( splitterSize.count() == 0 ) { |
516 | splitterSize.append( width() / 2 ); | 516 | splitterSize.append( width() / 2 ); |
517 | splitterSize.append( width() / 2 ); | 517 | splitterSize.append( width() / 2 ); |
518 | } | 518 | } |
519 | mExtensionBarSplitter->setSizes( splitterSize ); | 519 | mExtensionBarSplitter->setSizes( splitterSize ); |
520 | 520 | ||
521 | } | 521 | } |
522 | */ | 522 | */ |
523 | mViewManager->restoreSettings(); | 523 | mViewManager->restoreSettings(); |
524 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 524 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
525 | mExtensionManager->restoreSettings(); | 525 | mExtensionManager->restoreSettings(); |
526 | #ifdef DESKTOP_VERSION | 526 | #ifdef DESKTOP_VERSION |
527 | int wid = width(); | 527 | int wid = width(); |
528 | if ( wid < 10 ) | 528 | if ( wid < 10 ) |
529 | wid = 400; | 529 | wid = 400; |
530 | #else | 530 | #else |
531 | int wid = QApplication::desktop()->width(); | 531 | int wid = QApplication::desktop()->width(); |
532 | if ( wid < 640 ) | 532 | if ( wid < 640 ) |
533 | wid = QApplication::desktop()->height(); | 533 | wid = QApplication::desktop()->height(); |
534 | #endif | 534 | #endif |
535 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 535 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
536 | if ( true /*splitterSize.count() == 0*/ ) { | 536 | if ( true /*splitterSize.count() == 0*/ ) { |
537 | splitterSize.append( wid / 2 ); | 537 | splitterSize.append( wid / 2 ); |
538 | splitterSize.append( wid / 2 ); | 538 | splitterSize.append( wid / 2 ); |
539 | } | 539 | } |
540 | mMiniSplitter->setSizes( splitterSize ); | 540 | mMiniSplitter->setSizes( splitterSize ); |
541 | if ( mExtensionBarSplitter ) { | 541 | if ( mExtensionBarSplitter ) { |
542 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 542 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
543 | if ( true /*splitterSize.count() == 0*/ ) { | 543 | if ( true /*splitterSize.count() == 0*/ ) { |
544 | splitterSize.append( wid / 2 ); | 544 | splitterSize.append( wid / 2 ); |
545 | splitterSize.append( wid / 2 ); | 545 | splitterSize.append( wid / 2 ); |
546 | } | 546 | } |
547 | mExtensionBarSplitter->setSizes( splitterSize ); | 547 | mExtensionBarSplitter->setSizes( splitterSize ); |
548 | 548 | ||
549 | } | 549 | } |
550 | 550 | ||
551 | 551 | ||
552 | } | 552 | } |
553 | 553 | ||
554 | void KABCore::saveSettings() | 554 | void KABCore::saveSettings() |
555 | { | 555 | { |
556 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 556 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
557 | if ( mExtensionBarSplitter ) | 557 | if ( mExtensionBarSplitter ) |
558 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 558 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
559 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 559 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
560 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 560 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
561 | #ifndef KAB_EMBEDDED | 561 | #ifndef KAB_EMBEDDED |
562 | 562 | ||
563 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 563 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
564 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 564 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
565 | #endif //KAB_EMBEDDED | 565 | #endif //KAB_EMBEDDED |
566 | mExtensionManager->saveSettings(); | 566 | mExtensionManager->saveSettings(); |
567 | mViewManager->saveSettings(); | 567 | mViewManager->saveSettings(); |
568 | 568 | ||
569 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 569 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
570 | KABPrefs::instance()->writeConfig(); | 570 | KABPrefs::instance()->writeConfig(); |
571 | qDebug("KABCore::saveSettings() "); | 571 | qDebug("KA: KABCore::saveSettings() "); |
572 | } | 572 | } |
573 | 573 | ||
574 | KABC::AddressBook *KABCore::addressBook() const | 574 | KABC::AddressBook *KABCore::addressBook() const |
575 | { | 575 | { |
576 | return mAddressBook; | 576 | return mAddressBook; |
577 | } | 577 | } |
578 | 578 | ||
579 | KConfig *KABCore::config() | 579 | KConfig *KABCore::config() |
580 | { | 580 | { |
581 | #ifndef KAB_EMBEDDED | 581 | #ifndef KAB_EMBEDDED |
582 | return KABPrefs::instance()->config(); | 582 | return KABPrefs::instance()->config(); |
583 | #else //KAB_EMBEDDED | 583 | #else //KAB_EMBEDDED |
584 | return KABPrefs::instance()->getConfig(); | 584 | return KABPrefs::instance()->getConfig(); |
585 | #endif //KAB_EMBEDDED | 585 | #endif //KAB_EMBEDDED |
586 | } | 586 | } |
587 | 587 | ||
588 | KActionCollection *KABCore::actionCollection() const | 588 | KActionCollection *KABCore::actionCollection() const |
589 | { | 589 | { |
590 | return mGUIClient->actionCollection(); | 590 | return mGUIClient->actionCollection(); |
591 | } | 591 | } |
592 | 592 | ||
593 | KABC::Field *KABCore::currentSearchField() const | 593 | KABC::Field *KABCore::currentSearchField() const |
594 | { | 594 | { |
595 | if (mIncSearchWidget) | 595 | if (mIncSearchWidget) |
596 | return mIncSearchWidget->currentField(); | 596 | return mIncSearchWidget->currentField(); |
597 | else | 597 | else |
598 | return 0; | 598 | return 0; |
599 | } | 599 | } |
600 | 600 | ||
601 | QStringList KABCore::selectedUIDs() const | 601 | QStringList KABCore::selectedUIDs() const |
602 | { | 602 | { |
603 | return mViewManager->selectedUids(); | 603 | return mViewManager->selectedUids(); |
604 | } | 604 | } |
605 | 605 | ||
606 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 606 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
607 | { | 607 | { |
608 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 608 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
609 | 609 | ||
610 | QPtrList<KRES::Resource> kresResources; | 610 | QPtrList<KRES::Resource> kresResources; |
611 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 611 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
612 | KABC::Resource *resource; | 612 | KABC::Resource *resource; |
613 | while ( ( resource = resIt.current() ) != 0 ) { | 613 | while ( ( resource = resIt.current() ) != 0 ) { |
614 | ++resIt; | 614 | ++resIt; |
615 | if ( !resource->readOnly() ) { | 615 | if ( !resource->readOnly() ) { |
616 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 616 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
617 | if ( res ) | 617 | if ( res ) |
618 | kresResources.append( res ); | 618 | kresResources.append( res ); |
619 | } | 619 | } |
620 | } | 620 | } |
621 | 621 | ||
622 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 622 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
623 | return static_cast<KABC::Resource*>( res ); | 623 | return static_cast<KABC::Resource*>( res ); |
624 | } | 624 | } |
625 | 625 | ||
626 | #ifndef KAB_EMBEDDED | 626 | #ifndef KAB_EMBEDDED |
627 | KAboutData *KABCore::createAboutData() | 627 | KAboutData *KABCore::createAboutData() |
628 | #else //KAB_EMBEDDED | 628 | #else //KAB_EMBEDDED |
629 | void KABCore::createAboutData() | 629 | void KABCore::createAboutData() |
630 | #endif //KAB_EMBEDDED | 630 | #endif //KAB_EMBEDDED |
631 | { | 631 | { |
632 | #ifndef KAB_EMBEDDED | 632 | #ifndef KAB_EMBEDDED |
633 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 633 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
634 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 634 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
635 | KAboutData::License_GPL_V2, | 635 | KAboutData::License_GPL_V2, |
636 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 636 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
637 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 637 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
638 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 638 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
639 | about->addAuthor( "Cornelius Schumacher", | 639 | about->addAuthor( "Cornelius Schumacher", |
640 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 640 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
641 | "schumacher@kde.org" ); | 641 | "schumacher@kde.org" ); |
642 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 642 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
643 | "mpilone@slac.com" ); | 643 | "mpilone@slac.com" ); |
644 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 644 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
645 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 645 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
646 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 646 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
647 | "michel@klaralvdalens-datakonsult.se" ); | 647 | "michel@klaralvdalens-datakonsult.se" ); |
648 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 648 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
649 | "hansen@kde.org" ); | 649 | "hansen@kde.org" ); |
650 | 650 | ||
651 | return about; | 651 | return about; |
652 | #endif //KAB_EMBEDDED | 652 | #endif //KAB_EMBEDDED |
653 | 653 | ||
654 | QString version; | 654 | QString version; |
655 | #include <../version> | 655 | #include <../version> |
656 | QMessageBox::about( this, "About KAddressbook/Pi", | 656 | QMessageBox::about( this, "About KAddressbook/Pi", |
657 | "KAddressbook/Platform-independent\n" | 657 | "KAddressbook/Platform-independent\n" |
658 | "(KA/Pi) " +version + " - " + | 658 | "(KA/Pi) " +version + " - " + |
659 | #ifdef DESKTOP_VERSION | 659 | #ifdef DESKTOP_VERSION |
660 | "Desktop Edition\n" | 660 | "Desktop Edition\n" |
661 | #else | 661 | #else |
662 | "PDA-Edition\n" | 662 | "PDA-Edition\n" |
663 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 663 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
664 | #endif | 664 | #endif |
665 | 665 | ||
666 | "(c) 2004 Ulf Schenk\n" | 666 | "(c) 2004 Ulf Schenk\n" |
667 | "(c) 2004 Lutz Rogowski\n" | 667 | "(c) 2004 Lutz Rogowski\n" |
668 | "(c) 1997-2003, The KDE PIM Team\n" | 668 | "(c) 1997-2003, The KDE PIM Team\n" |
669 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 669 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
670 | "Don Sanders Original author\n" | 670 | "Don Sanders Original author\n" |
671 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 671 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
672 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 672 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
673 | "Greg Stern DCOP interface\n" | 673 | "Greg Stern DCOP interface\n" |
674 | "Mark Westcot Contact pinning\n" | 674 | "Mark Westcot Contact pinning\n" |
675 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 675 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
676 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 676 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
677 | #ifdef _WIN32_ | 677 | #ifdef _WIN32_ |
678 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 678 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
679 | #endif | 679 | #endif |
680 | ); | 680 | ); |
681 | } | 681 | } |
682 | 682 | ||
683 | void KABCore::setContactSelected( const QString &uid ) | 683 | void KABCore::setContactSelected( const QString &uid ) |
684 | { | 684 | { |
685 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 685 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
686 | if ( !mDetails->isHidden() ) | 686 | if ( !mDetails->isHidden() ) |
687 | mDetails->setAddressee( addr ); | 687 | mDetails->setAddressee( addr ); |
688 | 688 | ||
689 | if ( !addr.isEmpty() ) { | 689 | if ( !addr.isEmpty() ) { |
690 | emit contactSelected( addr.formattedName() ); | 690 | emit contactSelected( addr.formattedName() ); |
691 | KABC::Picture pic = addr.photo(); | 691 | KABC::Picture pic = addr.photo(); |
692 | if ( pic.isIntern() ) { | 692 | if ( pic.isIntern() ) { |
693 | //US emit contactSelected( pic.data() ); | 693 | //US emit contactSelected( pic.data() ); |
694 | //US instead use: | 694 | //US instead use: |
695 | QPixmap px; | 695 | QPixmap px; |
696 | if (pic.data().isNull() != true) | 696 | if (pic.data().isNull() != true) |
697 | { | 697 | { |
698 | px.convertFromImage(pic.data()); | 698 | px.convertFromImage(pic.data()); |
699 | } | 699 | } |
700 | 700 | ||
701 | emit contactSelected( px ); | 701 | emit contactSelected( px ); |
702 | } | 702 | } |
703 | } | 703 | } |
704 | 704 | ||
705 | 705 | ||
706 | mExtensionManager->setSelectionChanged(); | 706 | mExtensionManager->setSelectionChanged(); |
707 | 707 | ||
708 | // update the actions | 708 | // update the actions |
709 | bool selected = !uid.isEmpty(); | 709 | bool selected = !uid.isEmpty(); |
710 | 710 | ||
711 | if ( mReadWrite ) { | 711 | if ( mReadWrite ) { |
712 | mActionCut->setEnabled( selected ); | 712 | mActionCut->setEnabled( selected ); |
713 | mActionPaste->setEnabled( selected ); | 713 | mActionPaste->setEnabled( selected ); |
714 | } | 714 | } |
715 | 715 | ||
716 | mActionCopy->setEnabled( selected ); | 716 | mActionCopy->setEnabled( selected ); |
717 | mActionDelete->setEnabled( selected ); | 717 | mActionDelete->setEnabled( selected ); |
718 | mActionEditAddressee->setEnabled( selected ); | 718 | mActionEditAddressee->setEnabled( selected ); |
719 | mActionMail->setEnabled( selected ); | 719 | mActionMail->setEnabled( selected ); |
720 | mActionMailVCard->setEnabled( selected ); | 720 | mActionMailVCard->setEnabled( selected ); |
721 | //if (mActionBeam) | 721 | //if (mActionBeam) |
722 | //mActionBeam->setEnabled( selected ); | 722 | //mActionBeam->setEnabled( selected ); |
723 | mActionWhoAmI->setEnabled( selected ); | 723 | mActionWhoAmI->setEnabled( selected ); |
724 | } | 724 | } |
725 | 725 | ||
726 | void KABCore::sendMail() | 726 | void KABCore::sendMail() |
727 | { | 727 | { |
728 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 728 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
729 | } | 729 | } |
730 | 730 | ||
731 | void KABCore::sendMail( const QString& emaillist ) | 731 | void KABCore::sendMail( const QString& emaillist ) |
732 | { | 732 | { |
733 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 733 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
734 | if (emaillist.contains(",") > 0) | 734 | if (emaillist.contains(",") > 0) |
735 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 735 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
736 | else | 736 | else |
737 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 737 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
738 | } | 738 | } |
739 | 739 | ||
740 | 740 | ||
741 | 741 | ||
742 | void KABCore::mailVCard() | 742 | void KABCore::mailVCard() |
743 | { | 743 | { |
744 | QStringList uids = mViewManager->selectedUids(); | 744 | QStringList uids = mViewManager->selectedUids(); |
745 | if ( !uids.isEmpty() ) | 745 | if ( !uids.isEmpty() ) |
746 | mailVCard( uids ); | 746 | mailVCard( uids ); |
747 | } | 747 | } |
748 | 748 | ||
749 | void KABCore::mailVCard( const QStringList& uids ) | 749 | void KABCore::mailVCard( const QStringList& uids ) |
750 | { | 750 | { |
751 | QStringList urls; | 751 | QStringList urls; |
752 | 752 | ||
753 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 753 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
754 | 754 | ||
755 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 755 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
756 | 756 | ||
757 | 757 | ||
758 | 758 | ||
759 | QDir().mkdir( dirName, true ); | 759 | QDir().mkdir( dirName, true ); |
760 | 760 | ||
761 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 761 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
762 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 762 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
763 | 763 | ||
764 | if ( a.isEmpty() ) | 764 | if ( a.isEmpty() ) |
765 | continue; | 765 | continue; |
766 | 766 | ||
767 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 767 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
768 | 768 | ||
769 | QString fileName = dirName + "/" + name; | 769 | QString fileName = dirName + "/" + name; |
770 | 770 | ||
771 | QFile outFile(fileName); | 771 | QFile outFile(fileName); |
772 | 772 | ||
773 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 773 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
774 | KABC::VCardConverter converter; | 774 | KABC::VCardConverter converter; |
775 | QString vcard; | 775 | QString vcard; |
776 | 776 | ||
777 | converter.addresseeToVCard( a, vcard ); | 777 | converter.addresseeToVCard( a, vcard ); |
778 | 778 | ||
779 | QTextStream t( &outFile ); // use a text stream | 779 | QTextStream t( &outFile ); // use a text stream |
780 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 780 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
781 | t << vcard; | 781 | t << vcard; |
782 | 782 | ||
783 | outFile.close(); | 783 | outFile.close(); |
784 | 784 | ||
785 | urls.append( fileName ); | 785 | urls.append( fileName ); |
786 | } | 786 | } |
787 | } | 787 | } |
788 | 788 | ||
789 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 789 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
790 | 790 | ||
791 | 791 | ||
792 | /*US | 792 | /*US |
793 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 793 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
794 | QString::null, // subject | 794 | QString::null, // subject |
795 | QString::null, // body | 795 | QString::null, // body |
796 | QString::null, | 796 | QString::null, |
797 | urls ); // attachments | 797 | urls ); // attachments |
798 | */ | 798 | */ |
799 | 799 | ||
800 | } | 800 | } |
801 | 801 | ||
802 | /** | 802 | /** |
803 | Beams the "WhoAmI contact. | 803 | Beams the "WhoAmI contact. |
804 | */ | 804 | */ |
805 | void KABCore::beamMySelf() | 805 | void KABCore::beamMySelf() |
806 | { | 806 | { |
807 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 807 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
808 | if (!a.isEmpty()) | 808 | if (!a.isEmpty()) |
809 | { | 809 | { |
810 | QStringList uids; | 810 | QStringList uids; |
811 | uids << a.uid(); | 811 | uids << a.uid(); |
812 | 812 | ||
813 | beamVCard(uids); | 813 | beamVCard(uids); |
814 | } else { | 814 | } else { |
815 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 815 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
816 | 816 | ||
817 | 817 | ||
818 | } | 818 | } |
819 | } | 819 | } |
820 | void KABCore::updateMainWindow() | 820 | void KABCore::updateMainWindow() |
821 | { | 821 | { |
822 | 822 | ||
823 | mMainWindow->showMaximized(); | 823 | mMainWindow->showMaximized(); |
824 | mMainWindow->update(); | 824 | mMainWindow->update(); |
825 | } | 825 | } |
826 | void KABCore::resizeEvent(QResizeEvent* e ) | 826 | void KABCore::resizeEvent(QResizeEvent* e ) |
827 | { | 827 | { |
828 | if ( !mMiniSplitter ) | 828 | if ( !mMiniSplitter ) |
829 | return; | 829 | return; |
830 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); | 830 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); |
831 | if ( QApplication::desktop()->width() >= 480 ) { | 831 | if ( QApplication::desktop()->width() >= 480 ) { |
832 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 832 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
833 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 833 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
834 | mMiniSplitter->setOrientation( Qt::Horizontal); | 834 | mMiniSplitter->setOrientation( Qt::Horizontal); |
835 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 835 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
836 | if ( QApplication::desktop()->width() <= 640 ) { | 836 | if ( QApplication::desktop()->width() <= 640 ) { |
837 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 837 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
838 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 838 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
839 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 839 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
840 | } | 840 | } |
841 | } | 841 | } |
842 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 842 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
843 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 843 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
844 | mMiniSplitter->setOrientation( Qt::Vertical ); | 844 | mMiniSplitter->setOrientation( Qt::Vertical ); |
845 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 845 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
846 | if ( QApplication::desktop()->width() <= 640 ) { | 846 | if ( QApplication::desktop()->width() <= 640 ) { |
847 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 847 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
848 | mMainWindow->showMinimized(); | 848 | mMainWindow->showMinimized(); |
849 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 849 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
850 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 850 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
851 | } | 851 | } |
852 | } | 852 | } |
853 | } | 853 | } |
854 | } | 854 | } |
855 | 855 | ||
856 | } | 856 | } |
857 | void KABCore::export2phone() | 857 | void KABCore::export2phone() |
858 | { | 858 | { |
859 | 859 | ||
860 | QStringList uids; | 860 | QStringList uids; |
861 | XXPortSelectDialog dlg( this, false, this ); | 861 | XXPortSelectDialog dlg( this, false, this ); |
862 | if ( dlg.exec() ) | 862 | if ( dlg.exec() ) |
863 | uids = dlg.uids(); | 863 | uids = dlg.uids(); |
864 | else | 864 | else |
865 | return; | 865 | return; |
866 | if ( uids.isEmpty() ) | 866 | if ( uids.isEmpty() ) |
867 | return; | 867 | return; |
868 | // qDebug("count %d ", uids.count()); | 868 | // qDebug("count %d ", uids.count()); |
869 | 869 | ||
870 | KAex2phonePrefs ex2phone; | 870 | KAex2phonePrefs ex2phone; |
871 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 871 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
872 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 872 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
873 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 873 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
874 | 874 | ||
875 | if ( !ex2phone.exec() ) { | 875 | if ( !ex2phone.exec() ) { |
876 | return; | 876 | return; |
877 | } | 877 | } |
878 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 878 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
879 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 879 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
880 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 880 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
881 | 881 | ||
882 | 882 | ||
883 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 883 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
884 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 884 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
885 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 885 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
886 | 886 | ||
887 | QString fileName = getPhoneFile(); | 887 | QString fileName = getPhoneFile(); |
888 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 888 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
889 | return; | 889 | return; |
890 | 890 | ||
891 | message(i18n("Exporting to phone...")); | 891 | message(i18n("Exporting to phone...")); |
892 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 892 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
893 | 893 | ||
894 | } | 894 | } |
895 | QString KABCore::getPhoneFile() | 895 | QString KABCore::getPhoneFile() |
896 | { | 896 | { |
897 | #ifdef DESKTOP_VERSION | 897 | #ifdef DESKTOP_VERSION |
898 | return locateLocal("tmp", "phonefile.vcf"); | 898 | return locateLocal("tmp", "phonefile.vcf"); |
899 | #else | 899 | #else |
900 | return "/tmp/phonefile.vcf"; | 900 | return "/tmp/phonefile.vcf"; |
901 | #endif | 901 | #endif |
902 | 902 | ||
903 | } | 903 | } |
904 | void KABCore::writeToPhone( ) | 904 | void KABCore::writeToPhone( ) |
905 | { | 905 | { |
906 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 906 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
907 | message(i18n("Export to phone finished!")); | 907 | message(i18n("Export to phone finished!")); |
908 | else | 908 | else |
909 | qDebug(i18n("Error exporting to phone")); | 909 | qDebug(i18n("KA: Error exporting to phone")); |
910 | } | 910 | } |
911 | void KABCore::beamVCard() | 911 | void KABCore::beamVCard() |
912 | { | 912 | { |
913 | QStringList uids; | 913 | QStringList uids; |
914 | XXPortSelectDialog dlg( this, false, this ); | 914 | XXPortSelectDialog dlg( this, false, this ); |
915 | if ( dlg.exec() ) | 915 | if ( dlg.exec() ) |
916 | uids = dlg.uids(); | 916 | uids = dlg.uids(); |
917 | else | 917 | else |
918 | return; | 918 | return; |
919 | if ( uids.isEmpty() ) | 919 | if ( uids.isEmpty() ) |
920 | return; | 920 | return; |
921 | beamVCard( uids ); | 921 | beamVCard( uids ); |
922 | } | 922 | } |
923 | 923 | ||
924 | 924 | ||
925 | void KABCore::beamVCard(const QStringList& uids) | 925 | void KABCore::beamVCard(const QStringList& uids) |
926 | { | 926 | { |
927 | 927 | ||
928 | // LR: we should use the /tmp dir on the Zaurus, | 928 | // LR: we should use the /tmp dir on the Zaurus, |
929 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 929 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
930 | 930 | ||
931 | #ifdef DESKTOP_VERSION | 931 | #ifdef DESKTOP_VERSION |
932 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 932 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
933 | #else | 933 | #else |
934 | QString fileName = "/tmp/kapibeamfile.vcf"; | 934 | QString fileName = "/tmp/kapibeamfile.vcf"; |
935 | #endif | 935 | #endif |
936 | 936 | ||
937 | KABC::VCardConverter converter; | 937 | KABC::VCardConverter converter; |
938 | QString description; | 938 | QString description; |
939 | QString datastream; | 939 | QString datastream; |
940 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 940 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
941 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 941 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
942 | 942 | ||
943 | if ( a.isEmpty() ) | 943 | if ( a.isEmpty() ) |
944 | continue; | 944 | continue; |
945 | 945 | ||
946 | if (description.isEmpty()) | 946 | if (description.isEmpty()) |
947 | description = a.formattedName(); | 947 | description = a.formattedName(); |
948 | 948 | ||
949 | QString vcard; | 949 | QString vcard; |
950 | converter.addresseeToVCard( a, vcard ); | 950 | converter.addresseeToVCard( a, vcard ); |
951 | int start = 0; | 951 | int start = 0; |
952 | int next; | 952 | int next; |
953 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 953 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
954 | int semi = vcard.find(";", next); | 954 | int semi = vcard.find(";", next); |
955 | int dopp = vcard.find(":", next); | 955 | int dopp = vcard.find(":", next); |
956 | int sep; | 956 | int sep; |
957 | if ( semi < dopp && semi >= 0 ) | 957 | if ( semi < dopp && semi >= 0 ) |
958 | sep = semi ; | 958 | sep = semi ; |
959 | else | 959 | else |
960 | sep = dopp; | 960 | sep = dopp; |
961 | datastream +=vcard.mid( start, next - start); | 961 | datastream +=vcard.mid( start, next - start); |
962 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 962 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
963 | start = sep; | 963 | start = sep; |
964 | } | 964 | } |
965 | datastream += vcard.mid( start,vcard.length() ); | 965 | datastream += vcard.mid( start,vcard.length() ); |
966 | } | 966 | } |
967 | #ifndef DESKTOP_VERSION | 967 | #ifndef DESKTOP_VERSION |
968 | QFile outFile(fileName); | 968 | QFile outFile(fileName); |
969 | if ( outFile.open(IO_WriteOnly) ) { | 969 | if ( outFile.open(IO_WriteOnly) ) { |
970 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 970 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
971 | QTextStream t( &outFile ); // use a text stream | 971 | QTextStream t( &outFile ); // use a text stream |
972 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 972 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
973 | t.setEncoding( QTextStream::Latin1 ); | 973 | t.setEncoding( QTextStream::Latin1 ); |
974 | t <<datastream.latin1(); | 974 | t <<datastream.latin1(); |
975 | outFile.close(); | 975 | outFile.close(); |
976 | Ir *ir = new Ir( this ); | 976 | Ir *ir = new Ir( this ); |
977 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 977 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
978 | ir->send( fileName, description, "text/x-vCard" ); | 978 | ir->send( fileName, description, "text/x-vCard" ); |
979 | } else { | 979 | } else { |
980 | qDebug("Error open temp beam file "); | 980 | qDebug("KA: Error open temp beam file "); |
981 | return; | 981 | return; |
982 | } | 982 | } |
983 | #endif | 983 | #endif |
984 | 984 | ||
985 | } | 985 | } |
986 | 986 | ||
987 | void KABCore::beamDone( Ir *ir ) | 987 | void KABCore::beamDone( Ir *ir ) |
988 | { | 988 | { |
989 | #ifndef DESKTOP_VERSION | 989 | #ifndef DESKTOP_VERSION |
990 | delete ir; | 990 | delete ir; |
991 | #endif | 991 | #endif |
992 | topLevelWidget()->raise(); | 992 | topLevelWidget()->raise(); |
993 | message( i18n("Beaming finished!") ); | 993 | message( i18n("Beaming finished!") ); |
994 | } | 994 | } |
995 | 995 | ||
996 | 996 | ||
997 | void KABCore::browse( const QString& url ) | 997 | void KABCore::browse( const QString& url ) |
998 | { | 998 | { |
999 | #ifndef KAB_EMBEDDED | 999 | #ifndef KAB_EMBEDDED |
1000 | kapp->invokeBrowser( url ); | 1000 | kapp->invokeBrowser( url ); |
1001 | #else //KAB_EMBEDDED | 1001 | #else //KAB_EMBEDDED |
1002 | qDebug("KABCore::browse must be fixed"); | 1002 | qDebug("KABCore::browse must be fixed"); |
1003 | #endif //KAB_EMBEDDED | 1003 | #endif //KAB_EMBEDDED |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | void KABCore::selectAllContacts() | 1006 | void KABCore::selectAllContacts() |
1007 | { | 1007 | { |
1008 | mViewManager->setSelected( QString::null, true ); | 1008 | mViewManager->setSelected( QString::null, true ); |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | void KABCore::deleteContacts() | 1011 | void KABCore::deleteContacts() |
1012 | { | 1012 | { |
1013 | QStringList uidList = mViewManager->selectedUids(); | 1013 | QStringList uidList = mViewManager->selectedUids(); |
1014 | deleteContacts( uidList ); | 1014 | deleteContacts( uidList ); |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | void KABCore::deleteContacts( const QStringList &uids ) | 1017 | void KABCore::deleteContacts( const QStringList &uids ) |
1018 | { | 1018 | { |
1019 | if ( uids.count() > 0 ) { | 1019 | if ( uids.count() > 0 ) { |
1020 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 1020 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
1021 | UndoStack::instance()->push( command ); | 1021 | UndoStack::instance()->push( command ); |
1022 | RedoStack::instance()->clear(); | 1022 | RedoStack::instance()->clear(); |
1023 | 1023 | ||
1024 | // now if we deleted anything, refresh | 1024 | // now if we deleted anything, refresh |
1025 | setContactSelected( QString::null ); | 1025 | setContactSelected( QString::null ); |
1026 | setModified( true ); | 1026 | setModified( true ); |
1027 | } | 1027 | } |
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | void KABCore::copyContacts() | 1030 | void KABCore::copyContacts() |
1031 | { | 1031 | { |
1032 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1032 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1033 | 1033 | ||
1034 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 1034 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
1035 | 1035 | ||
1036 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 1036 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
1037 | 1037 | ||
1038 | QClipboard *cb = QApplication::clipboard(); | 1038 | QClipboard *cb = QApplication::clipboard(); |
1039 | cb->setText( clipText ); | 1039 | cb->setText( clipText ); |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | void KABCore::cutContacts() | 1042 | void KABCore::cutContacts() |
1043 | { | 1043 | { |
1044 | QStringList uidList = mViewManager->selectedUids(); | 1044 | QStringList uidList = mViewManager->selectedUids(); |
1045 | 1045 | ||
1046 | //US if ( uidList.size() > 0 ) { | 1046 | //US if ( uidList.size() > 0 ) { |
1047 | if ( uidList.count() > 0 ) { | 1047 | if ( uidList.count() > 0 ) { |
1048 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 1048 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
1049 | UndoStack::instance()->push( command ); | 1049 | UndoStack::instance()->push( command ); |
1050 | RedoStack::instance()->clear(); | 1050 | RedoStack::instance()->clear(); |
1051 | 1051 | ||
1052 | setModified( true ); | 1052 | setModified( true ); |
1053 | } | 1053 | } |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | void KABCore::pasteContacts() | 1056 | void KABCore::pasteContacts() |
1057 | { | 1057 | { |
1058 | QClipboard *cb = QApplication::clipboard(); | 1058 | QClipboard *cb = QApplication::clipboard(); |
1059 | 1059 | ||
1060 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 1060 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
1061 | 1061 | ||
1062 | pasteContacts( list ); | 1062 | pasteContacts( list ); |
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 1065 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
1066 | { | 1066 | { |
1067 | KABC::Resource *resource = requestResource( this ); | 1067 | KABC::Resource *resource = requestResource( this ); |
1068 | KABC::Addressee::List::Iterator it; | 1068 | KABC::Addressee::List::Iterator it; |
1069 | for ( it = list.begin(); it != list.end(); ++it ) | 1069 | for ( it = list.begin(); it != list.end(); ++it ) |
1070 | (*it).setResource( resource ); | 1070 | (*it).setResource( resource ); |
1071 | 1071 | ||
1072 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 1072 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
1073 | UndoStack::instance()->push( command ); | 1073 | UndoStack::instance()->push( command ); |
1074 | RedoStack::instance()->clear(); | 1074 | RedoStack::instance()->clear(); |
1075 | 1075 | ||
1076 | setModified( true ); | 1076 | setModified( true ); |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | void KABCore::setWhoAmI() | 1079 | void KABCore::setWhoAmI() |
1080 | { | 1080 | { |
1081 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1081 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1082 | 1082 | ||
1083 | if ( addrList.count() > 1 ) { | 1083 | if ( addrList.count() > 1 ) { |
1084 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 1084 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
1085 | return; | 1085 | return; |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 1088 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
1089 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 1089 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
1090 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 1090 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
1091 | } | 1091 | } |
1092 | void KABCore::editCategories() | 1092 | void KABCore::editCategories() |
1093 | { | 1093 | { |
1094 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); | 1094 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); |
1095 | dlg.exec(); | 1095 | dlg.exec(); |
1096 | } | 1096 | } |
1097 | void KABCore::setCategories() | 1097 | void KABCore::setCategories() |
1098 | { | 1098 | { |
1099 | 1099 | ||
1100 | QStringList uids; | 1100 | QStringList uids; |
1101 | XXPortSelectDialog dlgx( this, false, this ); | 1101 | XXPortSelectDialog dlgx( this, false, this ); |
1102 | if ( dlgx.exec() ) | 1102 | if ( dlgx.exec() ) |
1103 | uids = dlgx.uids(); | 1103 | uids = dlgx.uids(); |
1104 | else | 1104 | else |
1105 | return; | 1105 | return; |
1106 | if ( uids.isEmpty() ) | 1106 | if ( uids.isEmpty() ) |
1107 | return; | 1107 | return; |
1108 | // qDebug("count %d ", uids.count()); | 1108 | // qDebug("count %d ", uids.count()); |
1109 | 1109 | ||
1110 | 1110 | ||
1111 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 1111 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
1112 | if ( !dlg.exec() ) { | 1112 | if ( !dlg.exec() ) { |
1113 | message( i18n("Setting categories cancelled") ); | 1113 | message( i18n("Setting categories cancelled") ); |
1114 | return; | 1114 | return; |
1115 | } | 1115 | } |
1116 | bool merge = false; | 1116 | bool merge = false; |
1117 | QString msg = i18n( "Merge with existing categories?" ); | 1117 | QString msg = i18n( "Merge with existing categories?" ); |
1118 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 1118 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
1119 | merge = true; | 1119 | merge = true; |
1120 | 1120 | ||
1121 | message( i18n("Setting categories ... please wait!") ); | 1121 | message( i18n("Setting categories ... please wait!") ); |
1122 | QStringList categories = dlg.selectedCategories(); | 1122 | QStringList categories = dlg.selectedCategories(); |
1123 | 1123 | ||
1124 | //QStringList uids = mViewManager->selectedUids(); | 1124 | //QStringList uids = mViewManager->selectedUids(); |
1125 | QStringList::Iterator it; | 1125 | QStringList::Iterator it; |
1126 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1126 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1127 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1127 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1128 | if ( !addr.isEmpty() ) { | 1128 | if ( !addr.isEmpty() ) { |
1129 | if ( !merge ) | 1129 | if ( !merge ) |
1130 | addr.setCategories( categories ); | 1130 | addr.setCategories( categories ); |
1131 | else { | 1131 | else { |
1132 | QStringList addrCategories = addr.categories(); | 1132 | QStringList addrCategories = addr.categories(); |
1133 | QStringList::Iterator catIt; | 1133 | QStringList::Iterator catIt; |
1134 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1134 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1135 | if ( !addrCategories.contains( *catIt ) ) | 1135 | if ( !addrCategories.contains( *catIt ) ) |
1136 | addrCategories.append( *catIt ); | 1136 | addrCategories.append( *catIt ); |
1137 | } | 1137 | } |
1138 | addr.setCategories( addrCategories ); | 1138 | addr.setCategories( addrCategories ); |
1139 | } | 1139 | } |
1140 | mAddressBook->insertAddressee( addr ); | 1140 | mAddressBook->insertAddressee( addr ); |
1141 | } | 1141 | } |
1142 | } | 1142 | } |
1143 | 1143 | ||
1144 | if ( uids.count() > 0 ) | 1144 | if ( uids.count() > 0 ) |
1145 | setModified( true ); | 1145 | setModified( true ); |
1146 | message( i18n("Setting categories completed!") ); | 1146 | message( i18n("Setting categories completed!") ); |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1149 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1150 | { | 1150 | { |
1151 | mIncSearchWidget->setFields( fields ); | 1151 | mIncSearchWidget->setFields( fields ); |
1152 | } | 1152 | } |
1153 | 1153 | ||
1154 | void KABCore::incrementalSearch( const QString& text ) | 1154 | void KABCore::incrementalSearch( const QString& text ) |
1155 | { | 1155 | { |
1156 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1156 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1157 | } | 1157 | } |
1158 | 1158 | ||
1159 | void KABCore::setModified() | 1159 | void KABCore::setModified() |
1160 | { | 1160 | { |
1161 | setModified( true ); | 1161 | setModified( true ); |
1162 | } | 1162 | } |
1163 | 1163 | ||
1164 | void KABCore::setModifiedWOrefresh() | 1164 | void KABCore::setModifiedWOrefresh() |
1165 | { | 1165 | { |
1166 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1166 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1167 | mModified = true; | 1167 | mModified = true; |
1168 | mActionSave->setEnabled( mModified ); | 1168 | mActionSave->setEnabled( mModified ); |
1169 | 1169 | ||
1170 | 1170 | ||
1171 | } | 1171 | } |
1172 | void KABCore::setModified( bool modified ) | 1172 | void KABCore::setModified( bool modified ) |
1173 | { | 1173 | { |
1174 | mModified = modified; | 1174 | mModified = modified; |
1175 | mActionSave->setEnabled( mModified ); | 1175 | mActionSave->setEnabled( mModified ); |
1176 | 1176 | ||
1177 | if ( modified ) | 1177 | if ( modified ) |
1178 | mJumpButtonBar->recreateButtons(); | 1178 | mJumpButtonBar->recreateButtons(); |
1179 | 1179 | ||
1180 | mViewManager->refreshView(); | 1180 | mViewManager->refreshView(); |
1181 | 1181 | ||
1182 | } | 1182 | } |
1183 | 1183 | ||
1184 | bool KABCore::modified() const | 1184 | bool KABCore::modified() const |
1185 | { | 1185 | { |
1186 | return mModified; | 1186 | return mModified; |
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1189 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1190 | { | 1190 | { |
1191 | addrModified( addr ); | 1191 | addrModified( addr ); |
1192 | #if 0 // debug only | 1192 | #if 0 // debug only |
1193 | KABC::Addressee ad = addr; | 1193 | KABC::Addressee ad = addr; |
1194 | ad.computeCsum( "123"); | 1194 | ad.computeCsum( "123"); |
1195 | #endif | 1195 | #endif |
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | 1198 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) |
1199 | { | 1199 | { |
1200 | 1200 | ||
1201 | Command *command = 0; | 1201 | Command *command = 0; |
1202 | QString uid; | 1202 | QString uid; |
1203 | 1203 | ||
1204 | // check if it exists already | 1204 | // check if it exists already |
1205 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1205 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1206 | if ( origAddr.isEmpty() ) | 1206 | if ( origAddr.isEmpty() ) |
1207 | command = new PwNewCommand( mAddressBook, addr ); | 1207 | command = new PwNewCommand( mAddressBook, addr ); |
1208 | else { | 1208 | else { |
1209 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1209 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1210 | uid = addr.uid(); | 1210 | uid = addr.uid(); |
1211 | } | 1211 | } |
1212 | 1212 | ||
1213 | UndoStack::instance()->push( command ); | 1213 | UndoStack::instance()->push( command ); |
1214 | RedoStack::instance()->clear(); | 1214 | RedoStack::instance()->clear(); |
1215 | if ( updateDetails ) | 1215 | if ( updateDetails ) |
1216 | mDetails->setAddressee( addr ); | 1216 | mDetails->setAddressee( addr ); |
1217 | setModified( true ); | 1217 | setModified( true ); |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | void KABCore::newContact() | 1220 | void KABCore::newContact() |
1221 | { | 1221 | { |
1222 | 1222 | ||
1223 | 1223 | ||
1224 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1224 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1225 | 1225 | ||
1226 | QPtrList<KRES::Resource> kresResources; | 1226 | QPtrList<KRES::Resource> kresResources; |
1227 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1227 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1228 | KABC::Resource *resource; | 1228 | KABC::Resource *resource; |
1229 | while ( ( resource = it.current() ) != 0 ) { | 1229 | while ( ( resource = it.current() ) != 0 ) { |
1230 | ++it; | 1230 | ++it; |
1231 | if ( !resource->readOnly() ) { | 1231 | if ( !resource->readOnly() ) { |
1232 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1232 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1233 | if ( res ) | 1233 | if ( res ) |
1234 | kresResources.append( res ); | 1234 | kresResources.append( res ); |
1235 | } | 1235 | } |
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1238 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1239 | resource = static_cast<KABC::Resource*>( res ); | 1239 | resource = static_cast<KABC::Resource*>( res ); |
1240 | 1240 | ||
1241 | if ( resource ) { | 1241 | if ( resource ) { |
1242 | KABC::Addressee addr; | 1242 | KABC::Addressee addr; |
1243 | addr.setResource( resource ); | 1243 | addr.setResource( resource ); |
1244 | mEditorDialog->setAddressee( addr ); | 1244 | mEditorDialog->setAddressee( addr ); |
1245 | KApplication::execDialog ( mEditorDialog ); | 1245 | KApplication::execDialog ( mEditorDialog ); |
1246 | 1246 | ||
1247 | } else | 1247 | } else |
1248 | return; | 1248 | return; |
1249 | 1249 | ||
1250 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1250 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1251 | 1251 | ||
1252 | 1252 | ||
1253 | } | 1253 | } |
1254 | 1254 | ||
1255 | void KABCore::addEmail( QString aStr ) | 1255 | void KABCore::addEmail( QString aStr ) |
1256 | { | 1256 | { |
1257 | #ifndef KAB_EMBEDDED | 1257 | #ifndef KAB_EMBEDDED |
1258 | QString fullName, email; | 1258 | QString fullName, email; |
1259 | 1259 | ||
1260 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1260 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1261 | 1261 | ||
1262 | // Try to lookup the addressee matching the email address | 1262 | // Try to lookup the addressee matching the email address |
1263 | bool found = false; | 1263 | bool found = false; |
1264 | QStringList emailList; | 1264 | QStringList emailList; |
1265 | KABC::AddressBook::Iterator it; | 1265 | KABC::AddressBook::Iterator it; |
1266 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1266 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1267 | emailList = (*it).emails(); | 1267 | emailList = (*it).emails(); |
1268 | if ( emailList.contains( email ) > 0 ) { | 1268 | if ( emailList.contains( email ) > 0 ) { |
1269 | found = true; | 1269 | found = true; |
1270 | (*it).setNameFromString( fullName ); | 1270 | (*it).setNameFromString( fullName ); |
1271 | editContact( (*it).uid() ); | 1271 | editContact( (*it).uid() ); |
1272 | } | 1272 | } |
1273 | } | 1273 | } |
1274 | 1274 | ||
1275 | if ( !found ) { | 1275 | if ( !found ) { |
1276 | KABC::Addressee addr; | 1276 | KABC::Addressee addr; |
1277 | addr.setNameFromString( fullName ); | 1277 | addr.setNameFromString( fullName ); |
1278 | addr.insertEmail( email, true ); | 1278 | addr.insertEmail( email, true ); |
1279 | 1279 | ||
1280 | mAddressBook->insertAddressee( addr ); | 1280 | mAddressBook->insertAddressee( addr ); |
1281 | mViewManager->refreshView( addr.uid() ); | 1281 | mViewManager->refreshView( addr.uid() ); |
1282 | editContact( addr.uid() ); | 1282 | editContact( addr.uid() ); |
1283 | } | 1283 | } |
1284 | #else //KAB_EMBEDDED | 1284 | #else //KAB_EMBEDDED |
1285 | qDebug("KABCore::addEmail finsih method"); | 1285 | qDebug("KABCore::addEmail finsih method"); |
1286 | #endif //KAB_EMBEDDED | 1286 | #endif //KAB_EMBEDDED |
1287 | } | 1287 | } |
1288 | 1288 | ||
1289 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1289 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1290 | { | 1290 | { |
1291 | mXXPortManager->importVCard( url, showPreview ); | 1291 | mXXPortManager->importVCard( url, showPreview ); |
1292 | } | 1292 | } |
1293 | void KABCore::importFromOL() | 1293 | void KABCore::importFromOL() |
1294 | { | 1294 | { |
1295 | #ifdef _OL_IMPORT_ | 1295 | #ifdef _OL_IMPORT_ |
1296 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1296 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1297 | idgl->exec(); | 1297 | idgl->exec(); |
1298 | KABC::Addressee::List list = idgl->getAddressList(); | 1298 | KABC::Addressee::List list = idgl->getAddressList(); |
1299 | if ( list.count() > 0 ) { | 1299 | if ( list.count() > 0 ) { |
1300 | KABC::Addressee::List listNew; | 1300 | KABC::Addressee::List listNew; |
1301 | KABC::Addressee::List listExisting; | 1301 | KABC::Addressee::List listExisting; |
1302 | KABC::Addressee::List::Iterator it; | 1302 | KABC::Addressee::List::Iterator it; |
1303 | KABC::AddressBook::Iterator iter; | 1303 | KABC::AddressBook::Iterator iter; |
1304 | for ( it = list.begin(); it != list.end(); ++it ) { | 1304 | for ( it = list.begin(); it != list.end(); ++it ) { |
1305 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1305 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1306 | listNew.append( (*it) ); | 1306 | listNew.append( (*it) ); |
1307 | else | 1307 | else |
1308 | listExisting.append( (*it) ); | 1308 | listExisting.append( (*it) ); |
1309 | } | 1309 | } |
1310 | if ( listExisting.count() > 0 ) | 1310 | if ( listExisting.count() > 0 ) |
1311 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1311 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1312 | if ( listNew.count() > 0 ) { | 1312 | if ( listNew.count() > 0 ) { |
1313 | pasteWithNewUid = false; | 1313 | pasteWithNewUid = false; |
1314 | pasteContacts( listNew ); | 1314 | pasteContacts( listNew ); |
1315 | pasteWithNewUid = true; | 1315 | pasteWithNewUid = true; |
1316 | } | 1316 | } |
1317 | } | 1317 | } |
1318 | delete idgl; | 1318 | delete idgl; |
1319 | #endif | 1319 | #endif |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1322 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1323 | { | 1323 | { |
1324 | mXXPortManager->importVCard( vCard, showPreview ); | 1324 | mXXPortManager->importVCard( vCard, showPreview ); |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | //US added a second method without defaultparameter | 1327 | //US added a second method without defaultparameter |
1328 | void KABCore::editContact2() { | 1328 | void KABCore::editContact2() { |
1329 | editContact( QString::null ); | 1329 | editContact( QString::null ); |
1330 | } | 1330 | } |
1331 | 1331 | ||
1332 | void KABCore::editContact( const QString &uid ) | 1332 | void KABCore::editContact( const QString &uid ) |
1333 | { | 1333 | { |
1334 | 1334 | ||
1335 | if ( mExtensionManager->isQuickEditVisible() ) | 1335 | if ( mExtensionManager->isQuickEditVisible() ) |
1336 | return; | 1336 | return; |
1337 | 1337 | ||
1338 | // First, locate the contact entry | 1338 | // First, locate the contact entry |
1339 | QString localUID = uid; | 1339 | QString localUID = uid; |
1340 | if ( localUID.isNull() ) { | 1340 | if ( localUID.isNull() ) { |
1341 | QStringList uidList = mViewManager->selectedUids(); | 1341 | QStringList uidList = mViewManager->selectedUids(); |
1342 | if ( uidList.count() > 0 ) | 1342 | if ( uidList.count() > 0 ) |
1343 | localUID = *( uidList.at( 0 ) ); | 1343 | localUID = *( uidList.at( 0 ) ); |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1346 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1347 | if ( !addr.isEmpty() ) { | 1347 | if ( !addr.isEmpty() ) { |
1348 | mEditorDialog->setAddressee( addr ); | 1348 | mEditorDialog->setAddressee( addr ); |
1349 | KApplication::execDialog ( mEditorDialog ); | 1349 | KApplication::execDialog ( mEditorDialog ); |
1350 | } | 1350 | } |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | /** | 1353 | /** |
1354 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1354 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1355 | the method will try to find a selected addressee in the view. | 1355 | the method will try to find a selected addressee in the view. |
1356 | */ | 1356 | */ |
1357 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1357 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1358 | { | 1358 | { |
1359 | if ( mMultipleViewsAtOnce ) | 1359 | if ( mMultipleViewsAtOnce ) |
1360 | { | 1360 | { |
1361 | editContact( uid ); | 1361 | editContact( uid ); |
1362 | } | 1362 | } |
1363 | else | 1363 | else |
1364 | { | 1364 | { |
1365 | setDetailsVisible( true ); | 1365 | setDetailsVisible( true ); |
1366 | mActionDetails->setChecked(true); | 1366 | mActionDetails->setChecked(true); |
1367 | } | 1367 | } |
1368 | 1368 | ||
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | void KABCore::save() | 1371 | void KABCore::save() |
1372 | { | 1372 | { |
1373 | if (syncManager->blockSave()) | 1373 | if (syncManager->blockSave()) |
1374 | return; | 1374 | return; |
1375 | if ( !mModified ) | 1375 | if ( !mModified ) |
1376 | return; | 1376 | return; |
1377 | 1377 | ||
1378 | syncManager->setBlockSave(true); | 1378 | syncManager->setBlockSave(true); |
1379 | QString text = i18n( "There was an error while attempting to save\n the " | 1379 | QString text = i18n( "There was an error while attempting to save\n the " |
1380 | "address book. Please check that some \nother application is " | 1380 | "address book. Please check that some \nother application is " |
1381 | "not using it. " ); | 1381 | "not using it. " ); |
1382 | message(i18n("Saving ... please wait! "), false); | 1382 | message(i18n("Saving ... please wait! "), false); |
1383 | //qApp->processEvents(); | 1383 | //qApp->processEvents(); |
1384 | #ifndef KAB_EMBEDDED | 1384 | #ifndef KAB_EMBEDDED |
1385 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1385 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1386 | if ( !b || !b->save() ) { | 1386 | if ( !b || !b->save() ) { |
1387 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1387 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1388 | } | 1388 | } |
1389 | #else //KAB_EMBEDDED | 1389 | #else //KAB_EMBEDDED |
1390 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1390 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1391 | if ( !b || !b->save() ) { | 1391 | if ( !b || !b->save() ) { |
1392 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1392 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1393 | } | 1393 | } |
1394 | #endif //KAB_EMBEDDED | 1394 | #endif //KAB_EMBEDDED |
1395 | 1395 | ||
1396 | message(i18n("Addressbook saved!")); | 1396 | message(i18n("Addressbook saved!")); |
1397 | setModified( false ); | 1397 | setModified( false ); |
1398 | syncManager->setBlockSave(false); | 1398 | syncManager->setBlockSave(false); |
1399 | } | 1399 | } |
1400 | 1400 | ||
1401 | 1401 | ||
1402 | void KABCore::undo() | 1402 | void KABCore::undo() |
1403 | { | 1403 | { |
1404 | UndoStack::instance()->undo(); | 1404 | UndoStack::instance()->undo(); |
1405 | 1405 | ||
1406 | // Refresh the view | 1406 | // Refresh the view |
1407 | mViewManager->refreshView(); | 1407 | mViewManager->refreshView(); |
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | void KABCore::redo() | 1410 | void KABCore::redo() |
1411 | { | 1411 | { |
1412 | RedoStack::instance()->redo(); | 1412 | RedoStack::instance()->redo(); |
1413 | 1413 | ||
1414 | // Refresh the view | 1414 | // Refresh the view |
1415 | mViewManager->refreshView(); | 1415 | mViewManager->refreshView(); |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1418 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1419 | { | 1419 | { |
1420 | if (mMultipleViewsAtOnce) | 1420 | if (mMultipleViewsAtOnce) |
1421 | { | 1421 | { |
1422 | if ( visible ) | 1422 | if ( visible ) |
1423 | mJumpButtonBar->show(); | 1423 | mJumpButtonBar->show(); |
1424 | else | 1424 | else |
1425 | mJumpButtonBar->hide(); | 1425 | mJumpButtonBar->hide(); |
1426 | } | 1426 | } |
1427 | else | 1427 | else |
1428 | { | 1428 | { |
1429 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1429 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1430 | if (mViewManager->isVisible()) | 1430 | if (mViewManager->isVisible()) |
1431 | { | 1431 | { |
1432 | if ( visible ) | 1432 | if ( visible ) |
1433 | mJumpButtonBar->show(); | 1433 | mJumpButtonBar->show(); |
1434 | else | 1434 | else |
1435 | mJumpButtonBar->hide(); | 1435 | mJumpButtonBar->hide(); |
1436 | } | 1436 | } |
1437 | else | 1437 | else |
1438 | { | 1438 | { |
1439 | mJumpButtonBar->hide(); | 1439 | mJumpButtonBar->hide(); |
1440 | } | 1440 | } |
1441 | } | 1441 | } |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | 1444 | ||
1445 | void KABCore::setDetailsToState() | 1445 | void KABCore::setDetailsToState() |
1446 | { | 1446 | { |
1447 | setDetailsVisible( mActionDetails->isChecked() ); | 1447 | setDetailsVisible( mActionDetails->isChecked() ); |
1448 | } | 1448 | } |
1449 | void KABCore::setDetailsToggle() | 1449 | void KABCore::setDetailsToggle() |
1450 | { | 1450 | { |
1451 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1451 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1452 | setDetailsToState(); | 1452 | setDetailsToState(); |
1453 | } | 1453 | } |
1454 | 1454 | ||
1455 | 1455 | ||
1456 | 1456 | ||
1457 | void KABCore::setDetailsVisible( bool visible ) | 1457 | void KABCore::setDetailsVisible( bool visible ) |
1458 | { | 1458 | { |
1459 | if (visible && mDetails->isHidden()) | 1459 | if (visible && mDetails->isHidden()) |
1460 | { | 1460 | { |
1461 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1461 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1462 | if ( addrList.count() > 0 ) | 1462 | if ( addrList.count() > 0 ) |
1463 | mDetails->setAddressee( addrList[ 0 ] ); | 1463 | mDetails->setAddressee( addrList[ 0 ] ); |
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1466 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1467 | // the listview and the detailview. We do that by changing the splitbar size. | 1467 | // the listview and the detailview. We do that by changing the splitbar size. |
1468 | if (mMultipleViewsAtOnce) | 1468 | if (mMultipleViewsAtOnce) |
1469 | { | 1469 | { |
1470 | if ( visible ) | 1470 | if ( visible ) |
1471 | mDetails->show(); | 1471 | mDetails->show(); |
1472 | else | 1472 | else |
1473 | mDetails->hide(); | 1473 | mDetails->hide(); |
1474 | } | 1474 | } |
1475 | else | 1475 | else |
1476 | { | 1476 | { |
1477 | if ( visible ) { | 1477 | if ( visible ) { |
1478 | mViewManager->hide(); | 1478 | mViewManager->hide(); |
1479 | mDetails->show(); | 1479 | mDetails->show(); |
1480 | mIncSearchWidget->setFocus(); | 1480 | mIncSearchWidget->setFocus(); |
1481 | } | 1481 | } |
1482 | else { | 1482 | else { |
1483 | mViewManager->show(); | 1483 | mViewManager->show(); |
1484 | mDetails->hide(); | 1484 | mDetails->hide(); |
1485 | mViewManager->setFocusAV(); | 1485 | mViewManager->setFocusAV(); |
1486 | } | 1486 | } |
1487 | setJumpButtonBarVisible( !visible ); | 1487 | setJumpButtonBarVisible( !visible ); |
1488 | } | 1488 | } |
1489 | 1489 | ||
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | void KABCore::extensionChanged( int id ) | 1492 | void KABCore::extensionChanged( int id ) |
1493 | { | 1493 | { |
1494 | //change the details view only for non desktop systems | 1494 | //change the details view only for non desktop systems |
1495 | #ifndef DESKTOP_VERSION | 1495 | #ifndef DESKTOP_VERSION |
1496 | 1496 | ||
1497 | if (id == 0) | 1497 | if (id == 0) |
1498 | { | 1498 | { |
1499 | //the user disabled the extension. | 1499 | //the user disabled the extension. |
1500 | 1500 | ||
1501 | if (mMultipleViewsAtOnce) | 1501 | if (mMultipleViewsAtOnce) |
1502 | { // enable detailsview again | 1502 | { // enable detailsview again |
1503 | setDetailsVisible( true ); | 1503 | setDetailsVisible( true ); |
1504 | mActionDetails->setChecked( true ); | 1504 | mActionDetails->setChecked( true ); |
1505 | } | 1505 | } |
1506 | else | 1506 | else |
1507 | { //go back to the listview | 1507 | { //go back to the listview |
1508 | setDetailsVisible( false ); | 1508 | setDetailsVisible( false ); |
1509 | mActionDetails->setChecked( false ); | 1509 | mActionDetails->setChecked( false ); |
1510 | mActionDetails->setEnabled(true); | 1510 | mActionDetails->setEnabled(true); |
1511 | } | 1511 | } |
1512 | 1512 | ||
1513 | } | 1513 | } |
1514 | else | 1514 | else |
1515 | { | 1515 | { |
1516 | //the user enabled the extension. | 1516 | //the user enabled the extension. |
1517 | setDetailsVisible( false ); | 1517 | setDetailsVisible( false ); |
1518 | mActionDetails->setChecked( false ); | 1518 | mActionDetails->setChecked( false ); |
1519 | 1519 | ||
1520 | if (!mMultipleViewsAtOnce) | 1520 | if (!mMultipleViewsAtOnce) |
1521 | { | 1521 | { |
1522 | mActionDetails->setEnabled(false); | 1522 | mActionDetails->setEnabled(false); |
1523 | } | 1523 | } |
1524 | 1524 | ||
1525 | mExtensionManager->setSelectionChanged(); | 1525 | mExtensionManager->setSelectionChanged(); |
1526 | 1526 | ||
1527 | } | 1527 | } |
1528 | 1528 | ||
1529 | #endif// DESKTOP_VERSION | 1529 | #endif// DESKTOP_VERSION |
1530 | 1530 | ||
1531 | } | 1531 | } |
1532 | 1532 | ||
1533 | 1533 | ||
1534 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1534 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1535 | { | 1535 | { |
1536 | 1536 | ||
1537 | if ( list.count() != 0 ) { | 1537 | if ( list.count() != 0 ) { |
1538 | KABC::Addressee::List::ConstIterator it; | 1538 | KABC::Addressee::List::ConstIterator it; |
1539 | for ( it = list.begin(); it != list.end(); ++it ) | 1539 | for ( it = list.begin(); it != list.end(); ++it ) |
1540 | mAddressBook->insertAddressee( *it ); | 1540 | mAddressBook->insertAddressee( *it ); |
1541 | if ( list.count() > 1 ) | 1541 | if ( list.count() > 1 ) |
1542 | setModified(); | 1542 | setModified(); |
1543 | else | 1543 | else |
1544 | setModifiedWOrefresh(); | 1544 | setModifiedWOrefresh(); |
1545 | } | 1545 | } |
1546 | if ( list.count() == 0 ) | 1546 | if ( list.count() == 0 ) |
1547 | mViewManager->refreshView(); | 1547 | mViewManager->refreshView(); |
1548 | else | 1548 | else |
1549 | mViewManager->refreshView( list[ 0 ].uid() ); | 1549 | mViewManager->refreshView( list[ 0 ].uid() ); |
1550 | 1550 | ||
1551 | 1551 | ||
1552 | 1552 | ||
1553 | } | 1553 | } |
1554 | 1554 | ||
1555 | QString KABCore::getNameByPhone( const QString &phone ) | 1555 | QString KABCore::getNameByPhone( const QString &phone ) |
1556 | { | 1556 | { |
1557 | #ifndef KAB_EMBEDDED | 1557 | #ifndef KAB_EMBEDDED |
1558 | QRegExp r( "[/*/-/ ]" ); | 1558 | QRegExp r( "[/*/-/ ]" ); |
1559 | QString localPhone( phone ); | 1559 | QString localPhone( phone ); |
1560 | 1560 | ||
1561 | bool found = false; | 1561 | bool found = false; |
1562 | QString ownerName = ""; | 1562 | QString ownerName = ""; |
1563 | KABC::AddressBook::Iterator iter; | 1563 | KABC::AddressBook::Iterator iter; |
1564 | KABC::PhoneNumber::List::Iterator phoneIter; | 1564 | KABC::PhoneNumber::List::Iterator phoneIter; |
1565 | KABC::PhoneNumber::List phoneList; | 1565 | KABC::PhoneNumber::List phoneList; |
1566 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1566 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1567 | phoneList = (*iter).phoneNumbers(); | 1567 | phoneList = (*iter).phoneNumbers(); |
1568 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1568 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1569 | ++phoneIter) { | 1569 | ++phoneIter) { |
1570 | // Get rid of separator chars so just the numbers are compared. | 1570 | // Get rid of separator chars so just the numbers are compared. |
1571 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1571 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1572 | ownerName = (*iter).formattedName(); | 1572 | ownerName = (*iter).formattedName(); |
1573 | found = true; | 1573 | found = true; |
1574 | } | 1574 | } |
1575 | } | 1575 | } |
1576 | } | 1576 | } |
1577 | 1577 | ||
1578 | return ownerName; | 1578 | return ownerName; |
1579 | #else //KAB_EMBEDDED | 1579 | #else //KAB_EMBEDDED |
1580 | qDebug("KABCore::getNameByPhone finsih method"); | 1580 | qDebug("KABCore::getNameByPhone finsih method"); |
1581 | return ""; | 1581 | return ""; |
1582 | #endif //KAB_EMBEDDED | 1582 | #endif //KAB_EMBEDDED |
1583 | 1583 | ||
1584 | } | 1584 | } |
1585 | 1585 | ||
1586 | void KABCore::openConfigDialog() | 1586 | void KABCore::openConfigDialog() |
1587 | { | 1587 | { |
1588 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1588 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1589 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1589 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1590 | ConfigureDialog->addModule(kabcfg ); | 1590 | ConfigureDialog->addModule(kabcfg ); |
1591 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1591 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1592 | ConfigureDialog->addModule(kdelibcfg ); | 1592 | ConfigureDialog->addModule(kdelibcfg ); |
1593 | 1593 | ||
1594 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1594 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1595 | this, SLOT( configurationChanged() ) ); | 1595 | this, SLOT( configurationChanged() ) ); |
1596 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1596 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1597 | this, SLOT( configurationChanged() ) ); | 1597 | this, SLOT( configurationChanged() ) ); |
1598 | saveSettings(); | 1598 | saveSettings(); |
1599 | #ifndef DESKTOP_VERSION | 1599 | #ifndef DESKTOP_VERSION |
1600 | ConfigureDialog->showMaximized(); | 1600 | ConfigureDialog->showMaximized(); |
1601 | #endif | 1601 | #endif |
1602 | if ( ConfigureDialog->exec() ) | 1602 | if ( ConfigureDialog->exec() ) |
1603 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1603 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1604 | delete ConfigureDialog; | 1604 | delete ConfigureDialog; |
1605 | } | 1605 | } |
1606 | 1606 | ||
1607 | void KABCore::openLDAPDialog() | 1607 | void KABCore::openLDAPDialog() |
1608 | { | 1608 | { |
1609 | #ifndef KAB_EMBEDDED | 1609 | #ifndef KAB_EMBEDDED |
1610 | if ( !mLdapSearchDialog ) { | 1610 | if ( !mLdapSearchDialog ) { |
1611 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1611 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1612 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1612 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1613 | SLOT( refreshView() ) ); | 1613 | SLOT( refreshView() ) ); |
1614 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1614 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1615 | SLOT( setModified() ) ); | 1615 | SLOT( setModified() ) ); |
1616 | } else | 1616 | } else |
1617 | mLdapSearchDialog->restoreSettings(); | 1617 | mLdapSearchDialog->restoreSettings(); |
1618 | 1618 | ||
1619 | if ( mLdapSearchDialog->isOK() ) | 1619 | if ( mLdapSearchDialog->isOK() ) |
1620 | mLdapSearchDialog->exec(); | 1620 | mLdapSearchDialog->exec(); |
1621 | #else //KAB_EMBEDDED | 1621 | #else //KAB_EMBEDDED |
1622 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1622 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1623 | #endif //KAB_EMBEDDED | 1623 | #endif //KAB_EMBEDDED |
1624 | } | 1624 | } |
1625 | 1625 | ||
1626 | void KABCore::print() | 1626 | void KABCore::print() |
1627 | { | 1627 | { |
1628 | #ifndef KAB_EMBEDDED | 1628 | #ifndef KAB_EMBEDDED |
1629 | KPrinter printer; | 1629 | KPrinter printer; |
1630 | if ( !printer.setup( this ) ) | 1630 | if ( !printer.setup( this ) ) |
1631 | return; | 1631 | return; |
1632 | 1632 | ||
1633 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1633 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1634 | mViewManager->selectedUids(), this ); | 1634 | mViewManager->selectedUids(), this ); |
1635 | 1635 | ||
1636 | wizard.exec(); | 1636 | wizard.exec(); |
1637 | #else //KAB_EMBEDDED | 1637 | #else //KAB_EMBEDDED |
1638 | qDebug("KABCore::print() finsih method"); | 1638 | qDebug("KABCore::print() finsih method"); |
1639 | #endif //KAB_EMBEDDED | 1639 | #endif //KAB_EMBEDDED |
1640 | 1640 | ||
1641 | } | 1641 | } |
1642 | 1642 | ||
1643 | 1643 | ||
1644 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1644 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1645 | { | 1645 | { |
1646 | if ( mGUIClient ) | 1646 | if ( mGUIClient ) |
1647 | mGUIClient->insertChildClient( client ); | 1647 | mGUIClient->insertChildClient( client ); |
1648 | else | 1648 | else |
1649 | KMessageBox::error( this, "no KXMLGUICLient"); | 1649 | KMessageBox::error( this, "no KXMLGUICLient"); |
1650 | } | 1650 | } |
1651 | 1651 | ||
1652 | 1652 | ||
1653 | void KABCore::configurationChanged() | 1653 | void KABCore::configurationChanged() |
1654 | { | 1654 | { |
1655 | mExtensionManager->reconfigure(); | 1655 | mExtensionManager->reconfigure(); |
1656 | } | 1656 | } |
1657 | 1657 | ||
1658 | void KABCore::addressBookChanged() | 1658 | void KABCore::addressBookChanged() |
1659 | { | 1659 | { |
1660 | /*US | 1660 | /*US |
1661 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1661 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1662 | while ( it.current() ) { | 1662 | while ( it.current() ) { |
1663 | if ( it.current()->dirty() ) { | 1663 | if ( it.current()->dirty() ) { |
1664 | QString text = i18n( "Data has been changed externally. Unsaved " | 1664 | QString text = i18n( "Data has been changed externally. Unsaved " |
1665 | "changes will be lost." ); | 1665 | "changes will be lost." ); |
1666 | KMessageBox::information( this, text ); | 1666 | KMessageBox::information( this, text ); |
1667 | } | 1667 | } |
1668 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1668 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1669 | ++it; | 1669 | ++it; |
1670 | } | 1670 | } |
1671 | */ | 1671 | */ |
1672 | if (mEditorDialog) | 1672 | if (mEditorDialog) |
1673 | { | 1673 | { |
1674 | if (mEditorDialog->dirty()) | 1674 | if (mEditorDialog->dirty()) |
1675 | { | 1675 | { |
1676 | QString text = i18n( "Data has been changed externally. Unsaved " | 1676 | QString text = i18n( "Data has been changed externally. Unsaved " |
1677 | "changes will be lost." ); | 1677 | "changes will be lost." ); |
1678 | KMessageBox::information( this, text ); | 1678 | KMessageBox::information( this, text ); |
1679 | } | 1679 | } |
1680 | QString currentuid = mEditorDialog->addressee().uid(); | 1680 | QString currentuid = mEditorDialog->addressee().uid(); |
1681 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1681 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1682 | } | 1682 | } |
1683 | mViewManager->refreshView(); | 1683 | mViewManager->refreshView(); |
1684 | 1684 | ||
1685 | 1685 | ||
1686 | } | 1686 | } |
1687 | 1687 | ||
1688 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1688 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1689 | const char *name ) | 1689 | const char *name ) |
1690 | { | 1690 | { |
1691 | 1691 | ||
1692 | if ( mEditorDialog == 0 ) { | 1692 | if ( mEditorDialog == 0 ) { |
1693 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1693 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1694 | name ? name : "editorDialog" ); | 1694 | name ? name : "editorDialog" ); |
1695 | 1695 | ||
1696 | 1696 | ||
1697 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1697 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1698 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1698 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1699 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1699 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1700 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1700 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1701 | } | 1701 | } |
1702 | 1702 | ||
1703 | return mEditorDialog; | 1703 | return mEditorDialog; |
1704 | } | 1704 | } |
1705 | 1705 | ||
1706 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1706 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1707 | { | 1707 | { |
1708 | //mEditorDict.remove( uid ); | 1708 | //mEditorDict.remove( uid ); |
1709 | } | 1709 | } |
1710 | 1710 | ||
1711 | void KABCore::initGUI() | 1711 | void KABCore::initGUI() |
1712 | { | 1712 | { |
1713 | #ifndef KAB_EMBEDDED | 1713 | #ifndef KAB_EMBEDDED |
1714 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1714 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1715 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1715 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1716 | 1716 | ||
1717 | mExtensionBarSplitter = new QSplitter( this ); | 1717 | mExtensionBarSplitter = new QSplitter( this ); |
1718 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1718 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1719 | 1719 | ||
1720 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1720 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1721 | 1721 | ||
1722 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1722 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1723 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1723 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1724 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1724 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1725 | SLOT( incrementalSearch( const QString& ) ) ); | 1725 | SLOT( incrementalSearch( const QString& ) ) ); |
1726 | 1726 | ||
1727 | mViewManager = new ViewManager( this, viewSpace ); | 1727 | mViewManager = new ViewManager( this, viewSpace ); |
1728 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1728 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1729 | 1729 | ||
1730 | mDetails = new ViewContainer( mDetailsSplitter ); | 1730 | mDetails = new ViewContainer( mDetailsSplitter ); |
1731 | 1731 | ||
1732 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1732 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1733 | 1733 | ||
1734 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1734 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1735 | 1735 | ||
1736 | topLayout->addWidget( mExtensionBarSplitter ); | 1736 | topLayout->addWidget( mExtensionBarSplitter ); |
1737 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1737 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1738 | topLayout->addWidget( mJumpButtonBar ); | 1738 | topLayout->addWidget( mJumpButtonBar ); |
1739 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1739 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1740 | 1740 | ||
1741 | mXXPortManager = new XXPortManager( this, this ); | 1741 | mXXPortManager = new XXPortManager( this, this ); |
1742 | 1742 | ||
1743 | #else //KAB_EMBEDDED | 1743 | #else //KAB_EMBEDDED |
1744 | //US initialize viewMenu before settingup viewmanager. | 1744 | //US initialize viewMenu before settingup viewmanager. |
1745 | // Viewmanager needs this menu to plugin submenues. | 1745 | // Viewmanager needs this menu to plugin submenues. |
1746 | viewMenu = new QPopupMenu( this ); | 1746 | viewMenu = new QPopupMenu( this ); |
1747 | settingsMenu = new QPopupMenu( this ); | 1747 | settingsMenu = new QPopupMenu( this ); |
1748 | //filterMenu = new QPopupMenu( this ); | 1748 | //filterMenu = new QPopupMenu( this ); |
1749 | ImportMenu = new QPopupMenu( this ); | 1749 | ImportMenu = new QPopupMenu( this ); |
1750 | ExportMenu = new QPopupMenu( this ); | 1750 | ExportMenu = new QPopupMenu( this ); |
1751 | syncMenu = new QPopupMenu( this ); | 1751 | syncMenu = new QPopupMenu( this ); |
1752 | changeMenu= new QPopupMenu( this ); | 1752 | changeMenu= new QPopupMenu( this ); |
1753 | beamMenu= new QPopupMenu( this ); | 1753 | beamMenu= new QPopupMenu( this ); |
1754 | 1754 | ||
1755 | //US since we have no splitter for the embedded system, setup | 1755 | //US since we have no splitter for the embedded system, setup |
1756 | // a layout with two frames. One left and one right. | 1756 | // a layout with two frames. One left and one right. |
1757 | 1757 | ||
1758 | QBoxLayout *topLayout; | 1758 | QBoxLayout *topLayout; |
1759 | 1759 | ||
1760 | // = new QHBoxLayout( this ); | 1760 | // = new QHBoxLayout( this ); |
1761 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1761 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1762 | 1762 | ||
1763 | // QWidget *mainBox = new QWidget( this ); | 1763 | // QWidget *mainBox = new QWidget( this ); |
1764 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1764 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1765 | 1765 | ||
1766 | #ifdef DESKTOP_VERSION | 1766 | #ifdef DESKTOP_VERSION |
1767 | topLayout = new QHBoxLayout( this ); | 1767 | topLayout = new QHBoxLayout( this ); |
1768 | 1768 | ||
1769 | 1769 | ||
1770 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1770 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1771 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1771 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1772 | 1772 | ||
1773 | topLayout->addWidget(mMiniSplitter ); | 1773 | topLayout->addWidget(mMiniSplitter ); |
1774 | 1774 | ||
1775 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1775 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1776 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1776 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1777 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1777 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1778 | mDetails = new ViewContainer( mMiniSplitter ); | 1778 | mDetails = new ViewContainer( mMiniSplitter ); |
1779 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1779 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1780 | #else | 1780 | #else |
1781 | if ( QApplication::desktop()->width() > 480 ) { | 1781 | if ( QApplication::desktop()->width() > 480 ) { |
1782 | topLayout = new QHBoxLayout( this ); | 1782 | topLayout = new QHBoxLayout( this ); |
1783 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1783 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1784 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1784 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1785 | } else { | 1785 | } else { |
1786 | 1786 | ||
1787 | topLayout = new QHBoxLayout( this ); | 1787 | topLayout = new QHBoxLayout( this ); |
1788 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1788 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1789 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1789 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1790 | } | 1790 | } |
1791 | 1791 | ||
1792 | topLayout->addWidget(mMiniSplitter ); | 1792 | topLayout->addWidget(mMiniSplitter ); |
1793 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1793 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1794 | mDetails = new ViewContainer( mMiniSplitter ); | 1794 | mDetails = new ViewContainer( mMiniSplitter ); |
1795 | 1795 | ||
1796 | 1796 | ||
1797 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1797 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1798 | #endif | 1798 | #endif |
1799 | //eh->hide(); | 1799 | //eh->hide(); |
1800 | // topLayout->addWidget(mExtensionManager ); | 1800 | // topLayout->addWidget(mExtensionManager ); |
1801 | 1801 | ||
1802 | 1802 | ||
1803 | /*US | 1803 | /*US |
1804 | #ifndef KAB_NOSPLITTER | 1804 | #ifndef KAB_NOSPLITTER |
1805 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1805 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1806 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1806 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1807 | topLayout->setSpacing( 10 ); | 1807 | topLayout->setSpacing( 10 ); |
1808 | 1808 | ||
1809 | mDetailsSplitter = new QSplitter( this ); | 1809 | mDetailsSplitter = new QSplitter( this ); |
1810 | 1810 | ||
1811 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1811 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1812 | 1812 | ||
1813 | mViewManager = new ViewManager( this, viewSpace ); | 1813 | mViewManager = new ViewManager( this, viewSpace ); |
1814 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1814 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1815 | 1815 | ||
1816 | mDetails = new ViewContainer( mDetailsSplitter ); | 1816 | mDetails = new ViewContainer( mDetailsSplitter ); |
1817 | 1817 | ||
1818 | topLayout->addWidget( mDetailsSplitter ); | 1818 | topLayout->addWidget( mDetailsSplitter ); |
1819 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1819 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1820 | #else //KAB_NOSPLITTER | 1820 | #else //KAB_NOSPLITTER |
1821 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1821 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1822 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1822 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1823 | topLayout->setSpacing( 10 ); | 1823 | topLayout->setSpacing( 10 ); |
1824 | 1824 | ||
1825 | // mDetailsSplitter = new QSplitter( this ); | 1825 | // mDetailsSplitter = new QSplitter( this ); |
1826 | 1826 | ||
1827 | QVBox *viewSpace = new QVBox( this ); | 1827 | QVBox *viewSpace = new QVBox( this ); |
1828 | 1828 | ||
1829 | mViewManager = new ViewManager( this, viewSpace ); | 1829 | mViewManager = new ViewManager( this, viewSpace ); |
1830 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1830 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1831 | 1831 | ||
1832 | mDetails = new ViewContainer( this ); | 1832 | mDetails = new ViewContainer( this ); |
1833 | 1833 | ||
1834 | topLayout->addWidget( viewSpace ); | 1834 | topLayout->addWidget( viewSpace ); |
1835 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1835 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1836 | topLayout->addWidget( mDetails ); | 1836 | topLayout->addWidget( mDetails ); |
1837 | #endif //KAB_NOSPLITTER | 1837 | #endif //KAB_NOSPLITTER |
1838 | */ | 1838 | */ |
1839 | 1839 | ||
1840 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1840 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1841 | syncManager->setBlockSave(false); | 1841 | syncManager->setBlockSave(false); |
1842 | 1842 | ||
1843 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1843 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1844 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1844 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1845 | QString sync_file = sentSyncFile(); | 1845 | QString sync_file = sentSyncFile(); |
1846 | //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); | 1846 | //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); |
1847 | syncManager->setDefaultFileName( sync_file ); | 1847 | syncManager->setDefaultFileName( sync_file ); |
1848 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1848 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1849 | 1849 | ||
1850 | #endif //KAB_EMBEDDED | 1850 | #endif //KAB_EMBEDDED |
1851 | initActions(); | 1851 | initActions(); |
1852 | 1852 | ||
1853 | #ifdef KAB_EMBEDDED | 1853 | #ifdef KAB_EMBEDDED |
1854 | addActionsManually(); | 1854 | addActionsManually(); |
1855 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1855 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1856 | mXXPortManager = new XXPortManager( this, this ); | 1856 | mXXPortManager = new XXPortManager( this, this ); |
1857 | 1857 | ||
1858 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1858 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1859 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1859 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1860 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1860 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1861 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1861 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1862 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1862 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1863 | // mIncSearchWidget->hide(); | 1863 | // mIncSearchWidget->hide(); |
1864 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1864 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1865 | SLOT( incrementalSearch( const QString& ) ) ); | 1865 | SLOT( incrementalSearch( const QString& ) ) ); |
1866 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1866 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1867 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1867 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1868 | 1868 | ||
1869 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1869 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1870 | 1870 | ||
1871 | topLayout->addWidget( mJumpButtonBar ); | 1871 | topLayout->addWidget( mJumpButtonBar ); |
1872 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1872 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1873 | 1873 | ||
1874 | // mMainWindow->getIconToolBar()->raise(); | 1874 | // mMainWindow->getIconToolBar()->raise(); |
1875 | 1875 | ||
1876 | #endif //KAB_EMBEDDED | 1876 | #endif //KAB_EMBEDDED |
1877 | 1877 | ||
1878 | } | 1878 | } |
1879 | void KABCore::initActions() | 1879 | void KABCore::initActions() |
1880 | { | 1880 | { |
1881 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1881 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1882 | 1882 | ||
1883 | #ifndef KAB_EMBEDDED | 1883 | #ifndef KAB_EMBEDDED |
1884 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1884 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1885 | SLOT( clipboardDataChanged() ) ); | 1885 | SLOT( clipboardDataChanged() ) ); |
1886 | #endif //KAB_EMBEDDED | 1886 | #endif //KAB_EMBEDDED |
1887 | 1887 | ||
1888 | // file menu | 1888 | // file menu |
1889 | 1889 | ||
1890 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1890 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1891 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1891 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1892 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, | 1892 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, |
1893 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); | 1893 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); |
1894 | 1894 | ||
1895 | 1895 | ||
1896 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, | 1896 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, |
1897 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); | 1897 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); |
1898 | 1898 | ||
1899 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1899 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1900 | SLOT( save() ), actionCollection(), "file_sync" ); | 1900 | SLOT( save() ), actionCollection(), "file_sync" ); |
1901 | 1901 | ||
1902 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1902 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1903 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1903 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1904 | 1904 | ||
1905 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1905 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1906 | this, SLOT( mailVCard() ), | 1906 | this, SLOT( mailVCard() ), |
1907 | actionCollection(), "file_mail_vcard"); | 1907 | actionCollection(), "file_mail_vcard"); |
1908 | 1908 | ||
1909 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, | 1909 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, |
1910 | SLOT( export2phone() ), actionCollection(), | 1910 | SLOT( export2phone() ), actionCollection(), |
1911 | "kaddressbook_ex2phone" ); | 1911 | "kaddressbook_ex2phone" ); |
1912 | 1912 | ||
1913 | mActionBeamVCard = 0; | 1913 | mActionBeamVCard = 0; |
1914 | mActionBeam = 0; | 1914 | mActionBeam = 0; |
1915 | 1915 | ||
1916 | #ifndef DESKTOP_VERSION | 1916 | #ifndef DESKTOP_VERSION |
1917 | if ( Ir::supported() ) { | 1917 | if ( Ir::supported() ) { |
1918 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, | 1918 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, |
1919 | SLOT( beamVCard() ), actionCollection(), | 1919 | SLOT( beamVCard() ), actionCollection(), |
1920 | "kaddressbook_beam_vcard" ); | 1920 | "kaddressbook_beam_vcard" ); |
1921 | 1921 | ||
1922 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1922 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1923 | SLOT( beamMySelf() ), actionCollection(), | 1923 | SLOT( beamMySelf() ), actionCollection(), |
1924 | "kaddressbook_beam_myself" ); | 1924 | "kaddressbook_beam_myself" ); |
1925 | } | 1925 | } |
1926 | #endif | 1926 | #endif |
1927 | 1927 | ||
1928 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1928 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1929 | this, SLOT( editContact2() ), | 1929 | this, SLOT( editContact2() ), |
1930 | actionCollection(), "file_properties" ); | 1930 | actionCollection(), "file_properties" ); |
1931 | 1931 | ||
1932 | #ifdef KAB_EMBEDDED | 1932 | #ifdef KAB_EMBEDDED |
1933 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1933 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1934 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1934 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1935 | mMainWindow, SLOT( exit() ), | 1935 | mMainWindow, SLOT( exit() ), |
1936 | actionCollection(), "quit" ); | 1936 | actionCollection(), "quit" ); |
1937 | #endif //KAB_EMBEDDED | 1937 | #endif //KAB_EMBEDDED |
1938 | 1938 | ||
1939 | // edit menu | 1939 | // edit menu |
1940 | if ( mIsPart ) { | 1940 | if ( mIsPart ) { |
1941 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1941 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1942 | SLOT( copyContacts() ), actionCollection(), | 1942 | SLOT( copyContacts() ), actionCollection(), |
1943 | "kaddressbook_copy" ); | 1943 | "kaddressbook_copy" ); |
1944 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1944 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1945 | SLOT( cutContacts() ), actionCollection(), | 1945 | SLOT( cutContacts() ), actionCollection(), |
1946 | "kaddressbook_cut" ); | 1946 | "kaddressbook_cut" ); |
1947 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1947 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1948 | SLOT( pasteContacts() ), actionCollection(), | 1948 | SLOT( pasteContacts() ), actionCollection(), |
1949 | "kaddressbook_paste" ); | 1949 | "kaddressbook_paste" ); |
1950 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1950 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1951 | SLOT( selectAllContacts() ), actionCollection(), | 1951 | SLOT( selectAllContacts() ), actionCollection(), |
1952 | "kaddressbook_select_all" ); | 1952 | "kaddressbook_select_all" ); |
1953 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1953 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1954 | SLOT( undo() ), actionCollection(), | 1954 | SLOT( undo() ), actionCollection(), |
1955 | "kaddressbook_undo" ); | 1955 | "kaddressbook_undo" ); |
1956 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1956 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1957 | this, SLOT( redo() ), actionCollection(), | 1957 | this, SLOT( redo() ), actionCollection(), |
1958 | "kaddressbook_redo" ); | 1958 | "kaddressbook_redo" ); |
1959 | } else { | 1959 | } else { |
1960 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1960 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1961 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1961 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1962 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1962 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1963 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1963 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1964 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1964 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1965 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1965 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1966 | } | 1966 | } |
1967 | 1967 | ||
1968 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1968 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1969 | Key_Delete, this, SLOT( deleteContacts() ), | 1969 | Key_Delete, this, SLOT( deleteContacts() ), |
1970 | actionCollection(), "edit_delete" ); | 1970 | actionCollection(), "edit_delete" ); |
1971 | 1971 | ||
1972 | mActionUndo->setEnabled( false ); | 1972 | mActionUndo->setEnabled( false ); |
1973 | mActionRedo->setEnabled( false ); | 1973 | mActionRedo->setEnabled( false ); |
1974 | 1974 | ||
1975 | // settings menu | 1975 | // settings menu |
1976 | #ifdef KAB_EMBEDDED | 1976 | #ifdef KAB_EMBEDDED |
1977 | //US special menuentry to configure the addressbook resources. On KDE | 1977 | //US special menuentry to configure the addressbook resources. On KDE |
1978 | // you do that through the control center !!! | 1978 | // you do that through the control center !!! |
1979 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1979 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1980 | SLOT( configureResources() ), actionCollection(), | 1980 | SLOT( configureResources() ), actionCollection(), |
1981 | "kaddressbook_configure_resources" ); | 1981 | "kaddressbook_configure_resources" ); |
1982 | #endif //KAB_EMBEDDED | 1982 | #endif //KAB_EMBEDDED |
1983 | 1983 | ||
1984 | if ( mIsPart ) { | 1984 | if ( mIsPart ) { |
1985 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1985 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1986 | SLOT( openConfigDialog() ), actionCollection(), | 1986 | SLOT( openConfigDialog() ), actionCollection(), |
1987 | "kaddressbook_configure" ); | 1987 | "kaddressbook_configure" ); |
1988 | 1988 | ||
1989 | //US not implemented yet | 1989 | //US not implemented yet |
1990 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1990 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1991 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1991 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1992 | // "kaddressbook_configure_shortcuts" ); | 1992 | // "kaddressbook_configure_shortcuts" ); |
1993 | #ifdef KAB_EMBEDDED | 1993 | #ifdef KAB_EMBEDDED |
1994 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1994 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1995 | mActionConfigureToolbars->setEnabled( false ); | 1995 | mActionConfigureToolbars->setEnabled( false ); |
1996 | #endif //KAB_EMBEDDED | 1996 | #endif //KAB_EMBEDDED |
1997 | 1997 | ||
1998 | } else { | 1998 | } else { |
1999 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1999 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
2000 | 2000 | ||
2001 | //US not implemented yet | 2001 | //US not implemented yet |
2002 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 2002 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
2003 | } | 2003 | } |
2004 | 2004 | ||
2005 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 2005 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
2006 | actionCollection(), "options_show_jump_bar" ); | 2006 | actionCollection(), "options_show_jump_bar" ); |
2007 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 2007 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
2008 | 2008 | ||
2009 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 2009 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
2010 | actionCollection(), "options_show_details" ); | 2010 | actionCollection(), "options_show_details" ); |
2011 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 2011 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
2012 | 2012 | ||
2013 | 2013 | ||
2014 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 2014 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
2015 | SLOT( toggleBeamReceive() ), actionCollection(), | 2015 | SLOT( toggleBeamReceive() ), actionCollection(), |
2016 | "kaddressbook_beam_rec" ); | 2016 | "kaddressbook_beam_rec" ); |
2017 | 2017 | ||
2018 | 2018 | ||
2019 | // misc | 2019 | // misc |
2020 | // only enable LDAP lookup if we can handle the protocol | 2020 | // only enable LDAP lookup if we can handle the protocol |
2021 | #ifndef KAB_EMBEDDED | 2021 | #ifndef KAB_EMBEDDED |
2022 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 2022 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
2023 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 2023 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
2024 | this, SLOT( openLDAPDialog() ), actionCollection(), | 2024 | this, SLOT( openLDAPDialog() ), actionCollection(), |
2025 | "ldap_lookup" ); | 2025 | "ldap_lookup" ); |
2026 | } | 2026 | } |
2027 | #else //KAB_EMBEDDED | 2027 | #else //KAB_EMBEDDED |
2028 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 2028 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
2029 | #endif //KAB_EMBEDDED | 2029 | #endif //KAB_EMBEDDED |
2030 | 2030 | ||
2031 | 2031 | ||
2032 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 2032 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
2033 | SLOT( setWhoAmI() ), actionCollection(), | 2033 | SLOT( setWhoAmI() ), actionCollection(), |
2034 | "set_personal" ); | 2034 | "set_personal" ); |
2035 | 2035 | ||
2036 | 2036 | ||
2037 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 2037 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
2038 | SLOT( setCategories() ), actionCollection(), | 2038 | SLOT( setCategories() ), actionCollection(), |
2039 | "edit_set_categories" ); | 2039 | "edit_set_categories" ); |
2040 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, | 2040 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, |
2041 | SLOT( editCategories() ), actionCollection(), | 2041 | SLOT( editCategories() ), actionCollection(), |
2042 | "edit__categories" ); | 2042 | "edit__categories" ); |
2043 | 2043 | ||
2044 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 2044 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
2045 | SLOT( removeVoice() ), actionCollection(), | 2045 | SLOT( removeVoice() ), actionCollection(), |
2046 | "remove_voice" ); | 2046 | "remove_voice" ); |
2047 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, | 2047 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, |
2048 | SLOT( setFormattedName() ), actionCollection(), | 2048 | SLOT( setFormattedName() ), actionCollection(), |
2049 | "set_formatted" ); | 2049 | "set_formatted" ); |
2050 | 2050 | ||
2051 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 2051 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
2052 | SLOT( manageCategories() ), actionCollection(), | 2052 | SLOT( manageCategories() ), actionCollection(), |
2053 | "remove_voice" ); | 2053 | "remove_voice" ); |
2054 | 2054 | ||
2055 | 2055 | ||
2056 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 2056 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
2057 | SLOT( importFromOL() ), actionCollection(), | 2057 | SLOT( importFromOL() ), actionCollection(), |
2058 | "import_OL" ); | 2058 | "import_OL" ); |
2059 | #ifdef KAB_EMBEDDED | 2059 | #ifdef KAB_EMBEDDED |
2060 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 2060 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
2061 | this, SLOT( showLicence() ), actionCollection(), | 2061 | this, SLOT( showLicence() ), actionCollection(), |
2062 | "licence_about_data" ); | 2062 | "licence_about_data" ); |
2063 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 2063 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
2064 | this, SLOT( faq() ), actionCollection(), | 2064 | this, SLOT( faq() ), actionCollection(), |
2065 | "faq_about_data" ); | 2065 | "faq_about_data" ); |
2066 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 2066 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
2067 | this, SLOT( whatsnew() ), actionCollection(), | 2067 | this, SLOT( whatsnew() ), actionCollection(), |
2068 | "wn" ); | 2068 | "wn" ); |
2069 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2069 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2070 | this, SLOT( synchowto() ), actionCollection(), | 2070 | this, SLOT( synchowto() ), actionCollection(), |
2071 | "sync" ); | 2071 | "sync" ); |
2072 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2072 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2073 | this, SLOT( kdesynchowto() ), actionCollection(), | 2073 | this, SLOT( kdesynchowto() ), actionCollection(), |
2074 | "kdesync" ); | 2074 | "kdesync" ); |
2075 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2075 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2076 | this, SLOT( multisynchowto() ), actionCollection(), | 2076 | this, SLOT( multisynchowto() ), actionCollection(), |
2077 | "multisync" ); | 2077 | "multisync" ); |
2078 | 2078 | ||
2079 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2079 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2080 | this, SLOT( createAboutData() ), actionCollection(), | 2080 | this, SLOT( createAboutData() ), actionCollection(), |
2081 | "kaddressbook_about_data" ); | 2081 | "kaddressbook_about_data" ); |
2082 | #endif //KAB_EMBEDDED | 2082 | #endif //KAB_EMBEDDED |
2083 | 2083 | ||
2084 | clipboardDataChanged(); | 2084 | clipboardDataChanged(); |
2085 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2085 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2086 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2086 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2087 | } | 2087 | } |
2088 | 2088 | ||
2089 | //US we need this function, to plug all actions into the correct menues. | 2089 | //US we need this function, to plug all actions into the correct menues. |
2090 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2090 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2091 | void KABCore::addActionsManually() | 2091 | void KABCore::addActionsManually() |
2092 | { | 2092 | { |
2093 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2093 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
2094 | 2094 | ||
2095 | #ifdef KAB_EMBEDDED | 2095 | #ifdef KAB_EMBEDDED |
2096 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 2096 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
2097 | QPopupMenu *editMenu = new QPopupMenu( this ); | 2097 | QPopupMenu *editMenu = new QPopupMenu( this ); |
2098 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 2098 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
2099 | 2099 | ||
2100 | KToolBar* tb = mMainWindow->toolBar(); | 2100 | KToolBar* tb = mMainWindow->toolBar(); |
2101 | 2101 | ||
2102 | #ifndef DESKTOP_VERSION | 2102 | #ifndef DESKTOP_VERSION |
2103 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 2103 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
2104 | #endif | 2104 | #endif |
2105 | QMenuBar* mb = mMainWindow->menuBar(); | 2105 | QMenuBar* mb = mMainWindow->menuBar(); |
2106 | 2106 | ||
2107 | //US setup menubar. | 2107 | //US setup menubar. |
2108 | //Disable the following block if you do not want to have a menubar. | 2108 | //Disable the following block if you do not want to have a menubar. |
2109 | mb->insertItem( i18n("&File"), fileMenu ); | 2109 | mb->insertItem( i18n("&File"), fileMenu ); |
2110 | mb->insertItem( i18n("&Edit"), editMenu ); | 2110 | mb->insertItem( i18n("&Edit"), editMenu ); |
2111 | mb->insertItem( i18n("&View"), viewMenu ); | 2111 | mb->insertItem( i18n("&View"), viewMenu ); |
2112 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2112 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2113 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2113 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2114 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2114 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2115 | mb->insertItem( i18n("&Help"), helpMenu ); | 2115 | mb->insertItem( i18n("&Help"), helpMenu ); |
2116 | mIncSearchWidget = new IncSearchWidget( tb ); | 2116 | mIncSearchWidget = new IncSearchWidget( tb ); |
2117 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2117 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2118 | #ifndef DESKTOP_VERSION | 2118 | #ifndef DESKTOP_VERSION |
2119 | } else { | 2119 | } else { |
2120 | //US setup toolbar | 2120 | //US setup toolbar |
2121 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2121 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2122 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2122 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2123 | menuBarTB->insertItem( "ME", popupBarTB); | 2123 | menuBarTB->insertItem( "ME", popupBarTB); |
2124 | tb->insertWidget(-1, 0, menuBarTB); | 2124 | tb->insertWidget(-1, 0, menuBarTB); |
2125 | mIncSearchWidget = new IncSearchWidget( tb ); | 2125 | mIncSearchWidget = new IncSearchWidget( tb ); |
2126 | 2126 | ||
2127 | tb->enableMoving(false); | 2127 | tb->enableMoving(false); |
2128 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2128 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2129 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2129 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2130 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2130 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2131 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2131 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2132 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2132 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2133 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2133 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2134 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2134 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2135 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2135 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2136 | if (QApplication::desktop()->width() > 320 ) { | 2136 | if (QApplication::desktop()->width() > 320 ) { |
2137 | // mViewManager->getFilterAction()->plug ( tb); | 2137 | // mViewManager->getFilterAction()->plug ( tb); |
2138 | } | 2138 | } |
2139 | } | 2139 | } |
2140 | #endif | 2140 | #endif |
2141 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2141 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2142 | 2142 | ||
2143 | 2143 | ||
2144 | 2144 | ||
2145 | //US Now connect the actions with the menue entries. | 2145 | //US Now connect the actions with the menue entries. |
2146 | #ifdef DESKTOP_VERSION | 2146 | #ifdef DESKTOP_VERSION |
2147 | mActionPrint->plug( fileMenu ); | 2147 | mActionPrint->plug( fileMenu ); |
2148 | mActionPrintDetails->plug( fileMenu ); | 2148 | mActionPrintDetails->plug( fileMenu ); |
2149 | fileMenu->insertSeparator(); | 2149 | fileMenu->insertSeparator(); |
2150 | #endif | 2150 | #endif |
2151 | mActionMail->plug( fileMenu ); | 2151 | mActionMail->plug( fileMenu ); |
2152 | fileMenu->insertSeparator(); | 2152 | fileMenu->insertSeparator(); |
2153 | 2153 | ||
2154 | mActionNewContact->plug( fileMenu ); | 2154 | mActionNewContact->plug( fileMenu ); |
2155 | mActionNewContact->plug( tb ); | 2155 | mActionNewContact->plug( tb ); |
2156 | 2156 | ||
2157 | mActionEditAddressee->plug( fileMenu ); | 2157 | mActionEditAddressee->plug( fileMenu ); |
2158 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2158 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2159 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2159 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2160 | mActionEditAddressee->plug( tb ); | 2160 | mActionEditAddressee->plug( tb ); |
2161 | 2161 | ||
2162 | fileMenu->insertSeparator(); | 2162 | fileMenu->insertSeparator(); |
2163 | mActionSave->plug( fileMenu ); | 2163 | mActionSave->plug( fileMenu ); |
2164 | fileMenu->insertItem( "&Import", ImportMenu ); | 2164 | fileMenu->insertItem( "&Import", ImportMenu ); |
2165 | fileMenu->insertItem( "&Export", ExportMenu ); | 2165 | fileMenu->insertItem( "&Export", ExportMenu ); |
2166 | fileMenu->insertItem( i18n("&Change"), changeMenu ); | 2166 | fileMenu->insertItem( i18n("&Change"), changeMenu ); |
2167 | #ifndef DESKTOP_VERSION | 2167 | #ifndef DESKTOP_VERSION |
2168 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2168 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2169 | #endif | 2169 | #endif |
2170 | #if 0 | 2170 | #if 0 |
2171 | // PENDING fix MailVCard | 2171 | // PENDING fix MailVCard |
2172 | fileMenu->insertSeparator(); | 2172 | fileMenu->insertSeparator(); |
2173 | mActionMailVCard->plug( fileMenu ); | 2173 | mActionMailVCard->plug( fileMenu ); |
2174 | #endif | 2174 | #endif |
2175 | #ifndef DESKTOP_VERSION | 2175 | #ifndef DESKTOP_VERSION |
2176 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2176 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2177 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2177 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2178 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2178 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2179 | #endif | 2179 | #endif |
2180 | fileMenu->insertSeparator(); | 2180 | fileMenu->insertSeparator(); |
2181 | mActionQuit->plug( fileMenu ); | 2181 | mActionQuit->plug( fileMenu ); |
2182 | #ifdef _OL_IMPORT_ | 2182 | #ifdef _OL_IMPORT_ |
2183 | mActionImportOL->plug( ImportMenu ); | 2183 | mActionImportOL->plug( ImportMenu ); |
2184 | #endif | 2184 | #endif |
2185 | // edit menu | 2185 | // edit menu |
2186 | mActionUndo->plug( editMenu ); | 2186 | mActionUndo->plug( editMenu ); |
2187 | mActionRedo->plug( editMenu ); | 2187 | mActionRedo->plug( editMenu ); |
2188 | editMenu->insertSeparator(); | 2188 | editMenu->insertSeparator(); |
2189 | mActionCut->plug( editMenu ); | 2189 | mActionCut->plug( editMenu ); |
2190 | mActionCopy->plug( editMenu ); | 2190 | mActionCopy->plug( editMenu ); |
2191 | mActionPaste->plug( editMenu ); | 2191 | mActionPaste->plug( editMenu ); |
2192 | mActionDelete->plug( editMenu ); | 2192 | mActionDelete->plug( editMenu ); |
2193 | editMenu->insertSeparator(); | 2193 | editMenu->insertSeparator(); |
2194 | mActionSelectAll->plug( editMenu ); | 2194 | mActionSelectAll->plug( editMenu ); |
2195 | 2195 | ||
2196 | mActionSetFormattedName->plug( changeMenu ); | 2196 | mActionSetFormattedName->plug( changeMenu ); |
2197 | mActionRemoveVoice->plug( changeMenu ); | 2197 | mActionRemoveVoice->plug( changeMenu ); |
2198 | // settings menu | 2198 | // settings menu |
2199 | //US special menuentry to configure the addressbook resources. On KDE | 2199 | //US special menuentry to configure the addressbook resources. On KDE |
2200 | // you do that through the control center !!! | 2200 | // you do that through the control center !!! |
2201 | mActionConfigResources->plug( settingsMenu ); | 2201 | mActionConfigResources->plug( settingsMenu ); |
2202 | settingsMenu->insertSeparator(); | 2202 | settingsMenu->insertSeparator(); |
2203 | 2203 | ||
2204 | mActionConfigKAddressbook->plug( settingsMenu ); | 2204 | mActionConfigKAddressbook->plug( settingsMenu ); |
2205 | 2205 | ||
2206 | if ( mIsPart ) { | 2206 | if ( mIsPart ) { |
2207 | //US not implemented yet | 2207 | //US not implemented yet |
2208 | //mActionConfigShortcuts->plug( settingsMenu ); | 2208 | //mActionConfigShortcuts->plug( settingsMenu ); |
2209 | //mActionConfigureToolbars->plug( settingsMenu ); | 2209 | //mActionConfigureToolbars->plug( settingsMenu ); |
2210 | 2210 | ||
2211 | } else { | 2211 | } else { |
2212 | //US not implemented yet | 2212 | //US not implemented yet |
2213 | //mActionKeyBindings->plug( settingsMenu ); | 2213 | //mActionKeyBindings->plug( settingsMenu ); |
2214 | } | 2214 | } |
2215 | 2215 | ||
2216 | settingsMenu->insertSeparator(); | 2216 | settingsMenu->insertSeparator(); |
2217 | 2217 | ||
2218 | mActionJumpBar->plug( settingsMenu ); | 2218 | mActionJumpBar->plug( settingsMenu ); |
2219 | mActionDetails->plug( settingsMenu ); | 2219 | mActionDetails->plug( settingsMenu ); |
2220 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2220 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2221 | mActionDetails->plug( tb ); | 2221 | mActionDetails->plug( tb ); |
2222 | settingsMenu->insertSeparator(); | 2222 | settingsMenu->insertSeparator(); |
2223 | #ifndef DESKTOP_VERSION | 2223 | #ifndef DESKTOP_VERSION |
2224 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2224 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2225 | settingsMenu->insertSeparator(); | 2225 | settingsMenu->insertSeparator(); |
2226 | #endif | 2226 | #endif |
2227 | 2227 | ||
2228 | mActionWhoAmI->plug( settingsMenu ); | 2228 | mActionWhoAmI->plug( settingsMenu ); |
2229 | mActionEditCategories->plug( settingsMenu ); | 2229 | mActionEditCategories->plug( settingsMenu ); |
2230 | mActionEditCategories->plug( changeMenu ); | 2230 | mActionEditCategories->plug( changeMenu ); |
2231 | mActionCategories->plug( changeMenu ); | 2231 | mActionCategories->plug( changeMenu ); |
2232 | mActionManageCategories->plug( changeMenu ); | 2232 | mActionManageCategories->plug( changeMenu ); |
2233 | 2233 | ||
2234 | mActionCategories->plug( settingsMenu ); | 2234 | mActionCategories->plug( settingsMenu ); |
2235 | mActionManageCategories->plug( settingsMenu ); | 2235 | mActionManageCategories->plug( settingsMenu ); |
2236 | 2236 | ||
2237 | 2237 | ||
2238 | mActionWN->plug( helpMenu ); | 2238 | mActionWN->plug( helpMenu ); |
2239 | mActionSyncHowto->plug( helpMenu ); | 2239 | mActionSyncHowto->plug( helpMenu ); |
2240 | mActionKdeSyncHowto->plug( helpMenu ); | 2240 | mActionKdeSyncHowto->plug( helpMenu ); |
2241 | mActionMultiSyncHowto->plug( helpMenu ); | 2241 | mActionMultiSyncHowto->plug( helpMenu ); |
2242 | mActionFaq->plug( helpMenu ); | 2242 | mActionFaq->plug( helpMenu ); |
2243 | mActionLicence->plug( helpMenu ); | 2243 | mActionLicence->plug( helpMenu ); |
2244 | mActionAboutKAddressbook->plug( helpMenu ); | 2244 | mActionAboutKAddressbook->plug( helpMenu ); |
2245 | 2245 | ||
2246 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2246 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2247 | 2247 | ||
2248 | mActionSave->plug( tb ); | 2248 | mActionSave->plug( tb ); |
2249 | mViewManager->getFilterAction()->plug ( tb); | 2249 | mViewManager->getFilterAction()->plug ( tb); |
2250 | //LR hide filteraction on started in 480x640 | 2250 | //LR hide filteraction on started in 480x640 |
2251 | if (QApplication::desktop()->width() == 480 ) { | 2251 | if (QApplication::desktop()->width() == 480 ) { |
2252 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 2252 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2253 | } | 2253 | } |
2254 | mActionUndo->plug( tb ); | 2254 | mActionUndo->plug( tb ); |
2255 | mActionDelete->plug( tb ); | 2255 | mActionDelete->plug( tb ); |
2256 | mActionRedo->plug( tb ); | 2256 | mActionRedo->plug( tb ); |
2257 | } else { | 2257 | } else { |
2258 | mActionSave->plug( tb ); | 2258 | mActionSave->plug( tb ); |
2259 | tb->enableMoving(false); | 2259 | tb->enableMoving(false); |
2260 | } | 2260 | } |
2261 | //mActionQuit->plug ( tb ); | 2261 | //mActionQuit->plug ( tb ); |
2262 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2262 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2263 | 2263 | ||
2264 | //US link the searchwidget first to this. | 2264 | //US link the searchwidget first to this. |
2265 | // The real linkage to the toolbar happens later. | 2265 | // The real linkage to the toolbar happens later. |
2266 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2266 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2267 | //US tb->insertItem( mIncSearchWidget ); | 2267 | //US tb->insertItem( mIncSearchWidget ); |
2268 | /*US | 2268 | /*US |
2269 | mIncSearchWidget = new IncSearchWidget( tb ); | 2269 | mIncSearchWidget = new IncSearchWidget( tb ); |
2270 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2270 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2271 | SLOT( incrementalSearch( const QString& ) ) ); | 2271 | SLOT( incrementalSearch( const QString& ) ) ); |
2272 | 2272 | ||
2273 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2273 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2274 | 2274 | ||
2275 | //US topLayout->addWidget( mJumpButtonBar ); | 2275 | //US topLayout->addWidget( mJumpButtonBar ); |
2276 | this->layout()->add( mJumpButtonBar ); | 2276 | this->layout()->add( mJumpButtonBar ); |
2277 | */ | 2277 | */ |
2278 | 2278 | ||
2279 | #endif //KAB_EMBEDDED | 2279 | #endif //KAB_EMBEDDED |
2280 | 2280 | ||
2281 | mActionExport2phone->plug( ExportMenu ); | 2281 | mActionExport2phone->plug( ExportMenu ); |
2282 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2282 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2283 | syncManager->fillSyncMenu(); | 2283 | syncManager->fillSyncMenu(); |
2284 | 2284 | ||
2285 | } | 2285 | } |
2286 | void KABCore::showLicence() | 2286 | void KABCore::showLicence() |
2287 | { | 2287 | { |
2288 | KApplication::showLicence(); | 2288 | KApplication::showLicence(); |
2289 | } | 2289 | } |
2290 | 2290 | ||
2291 | void KABCore::manageCategories( ) | 2291 | void KABCore::manageCategories( ) |
2292 | { | 2292 | { |
2293 | KABCatPrefs* cp = new KABCatPrefs(); | 2293 | KABCatPrefs* cp = new KABCatPrefs(); |
2294 | cp->show(); | 2294 | cp->show(); |
2295 | int w =cp->sizeHint().width() ; | 2295 | int w =cp->sizeHint().width() ; |
2296 | int h = cp->sizeHint().height() ; | 2296 | int h = cp->sizeHint().height() ; |
2297 | int dw = QApplication::desktop()->width(); | 2297 | int dw = QApplication::desktop()->width(); |
2298 | int dh = QApplication::desktop()->height(); | 2298 | int dh = QApplication::desktop()->height(); |
2299 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2299 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2300 | if ( !cp->exec() ) { | 2300 | if ( !cp->exec() ) { |
2301 | delete cp; | 2301 | delete cp; |
2302 | return; | 2302 | return; |
2303 | } | 2303 | } |
2304 | int count = 0; | 2304 | int count = 0; |
2305 | int cc = 0; | 2305 | int cc = 0; |
2306 | message( i18n("Please wait, processing categories...")); | 2306 | message( i18n("Please wait, processing categories...")); |
2307 | if ( cp->addCat() ) { | 2307 | if ( cp->addCat() ) { |
2308 | KABC::AddressBook::Iterator it; | 2308 | KABC::AddressBook::Iterator it; |
2309 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2309 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2310 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2310 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2311 | ++cc; | 2311 | ++cc; |
2312 | if ( cc %10 == 0) | 2312 | if ( cc %10 == 0) |
2313 | message(i18n("Processing contact #%1").arg(cc)); | 2313 | message(i18n("Processing contact #%1").arg(cc)); |
2314 | QStringList catIncList = (*it).categories(); | 2314 | QStringList catIncList = (*it).categories(); |
2315 | int i; | 2315 | int i; |
2316 | for( i = 0; i< catIncList.count(); ++i ) { | 2316 | for( i = 0; i< catIncList.count(); ++i ) { |
2317 | if ( !catList.contains (catIncList[i])) { | 2317 | if ( !catList.contains (catIncList[i])) { |
2318 | catList.append( catIncList[i] ); | 2318 | catList.append( catIncList[i] ); |
2319 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2319 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2320 | ++count; | 2320 | ++count; |
2321 | } | 2321 | } |
2322 | } | 2322 | } |
2323 | } | 2323 | } |
2324 | catList.sort(); | 2324 | catList.sort(); |
2325 | KABPrefs::instance()->mCustomCategories = catList; | 2325 | KABPrefs::instance()->mCustomCategories = catList; |
2326 | KABPrefs::instance()->writeConfig(); | 2326 | KABPrefs::instance()->writeConfig(); |
2327 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2327 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2328 | } else { | 2328 | } else { |
2329 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2329 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2330 | QStringList catIncList; | 2330 | QStringList catIncList; |
2331 | QStringList newCatList; | 2331 | QStringList newCatList; |
2332 | KABC::AddressBook::Iterator it; | 2332 | KABC::AddressBook::Iterator it; |
2333 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2333 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2334 | ++cc; | 2334 | ++cc; |
2335 | if ( cc %10 == 0) | 2335 | if ( cc %10 == 0) |
2336 | message(i18n("Processing contact #%1").arg(cc)); | 2336 | message(i18n("Processing contact #%1").arg(cc)); |
2337 | QStringList catIncList = (*it).categories(); | 2337 | QStringList catIncList = (*it).categories(); |
2338 | int i; | 2338 | int i; |
2339 | if ( catIncList.count() ) { | 2339 | if ( catIncList.count() ) { |
2340 | newCatList.clear(); | 2340 | newCatList.clear(); |
2341 | for( i = 0; i< catIncList.count(); ++i ) { | 2341 | for( i = 0; i< catIncList.count(); ++i ) { |
2342 | if ( catList.contains (catIncList[i])) { | 2342 | if ( catList.contains (catIncList[i])) { |
2343 | newCatList.append( catIncList[i] ); | 2343 | newCatList.append( catIncList[i] ); |
2344 | } | 2344 | } |
2345 | } | 2345 | } |
2346 | newCatList.sort(); | 2346 | newCatList.sort(); |
2347 | (*it).setCategories( newCatList ); | 2347 | (*it).setCategories( newCatList ); |
2348 | mAddressBook->insertAddressee( (*it) ); | 2348 | mAddressBook->insertAddressee( (*it) ); |
2349 | } | 2349 | } |
2350 | } | 2350 | } |
2351 | setModified( true ); | 2351 | setModified( true ); |
2352 | mViewManager->refreshView(); | 2352 | mViewManager->refreshView(); |
2353 | message( i18n("Removing categories done!")); | 2353 | message( i18n("Removing categories done!")); |
2354 | } | 2354 | } |
2355 | delete cp; | 2355 | delete cp; |
2356 | } | 2356 | } |
2357 | void KABCore::removeVoice() | 2357 | void KABCore::removeVoice() |
2358 | { | 2358 | { |
2359 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2359 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2360 | return; | 2360 | return; |
2361 | XXPortSelectDialog dlg( this, false, this ); | 2361 | XXPortSelectDialog dlg( this, false, this ); |
2362 | if ( !dlg.exec() ) | 2362 | if ( !dlg.exec() ) |
2363 | return; | 2363 | return; |
2364 | mAddressBook->setUntagged(); | 2364 | mAddressBook->setUntagged(); |
2365 | dlg.tagSelected(); | 2365 | dlg.tagSelected(); |
2366 | message(i18n("Removing voice..."), false ); | 2366 | message(i18n("Removing voice..."), false ); |
2367 | KABC::AddressBook::Iterator it; | 2367 | KABC::AddressBook::Iterator it; |
2368 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2368 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2369 | if ( (*it).tagged() ) { | 2369 | if ( (*it).tagged() ) { |
2370 | (*it).removeVoice(); | 2370 | (*it).removeVoice(); |
2371 | } | 2371 | } |
2372 | } | 2372 | } |
2373 | message(i18n("Refreshing view...") ); | 2373 | message(i18n("Refreshing view...") ); |
2374 | qApp->processEvents(); | 2374 | qApp->processEvents(); |
2375 | mViewManager->refreshView( "" ); | 2375 | mViewManager->refreshView( "" ); |
2376 | Addressee add; | 2376 | Addressee add; |
2377 | mDetails->setAddressee( add ); | 2377 | mDetails->setAddressee( add ); |
2378 | message(i18n("Remove voice completed!") ); | 2378 | message(i18n("Remove voice completed!") ); |
2379 | 2379 | ||
2380 | 2380 | ||
2381 | 2381 | ||
2382 | } | 2382 | } |
2383 | 2383 | ||
2384 | void KABCore::setFormattedName() | 2384 | void KABCore::setFormattedName() |
2385 | { | 2385 | { |
2386 | KABFormatPrefs setpref; | 2386 | KABFormatPrefs setpref; |
2387 | if ( !setpref.exec() ) { | 2387 | if ( !setpref.exec() ) { |
2388 | return; | 2388 | return; |
2389 | } | 2389 | } |
2390 | XXPortSelectDialog dlg( this, false, this ); | 2390 | XXPortSelectDialog dlg( this, false, this ); |
2391 | if ( !dlg.exec() ) | 2391 | if ( !dlg.exec() ) |
2392 | return; | 2392 | return; |
2393 | mAddressBook->setUntagged(); | 2393 | mAddressBook->setUntagged(); |
2394 | dlg.tagSelected(); | 2394 | dlg.tagSelected(); |
2395 | int count = 0; | 2395 | int count = 0; |
2396 | KABC::AddressBook::Iterator it; | 2396 | KABC::AddressBook::Iterator it; |
2397 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2397 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2398 | if ( (*it).tagged() ) { | 2398 | if ( (*it).tagged() ) { |
2399 | ++count; | 2399 | ++count; |
2400 | if ( count %10 == 0 ) | 2400 | if ( count %10 == 0 ) |
2401 | message(i18n("Changing contact #%1").arg( count ) ); | 2401 | message(i18n("Changing contact #%1").arg( count ) ); |
2402 | qApp->processEvents(); | 2402 | qApp->processEvents(); |
2403 | QString fName; | 2403 | QString fName; |
2404 | if ( setpref.simple->isChecked() ) | 2404 | if ( setpref.simple->isChecked() ) |
2405 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2405 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2406 | else if ( setpref.full->isChecked() ) | 2406 | else if ( setpref.full->isChecked() ) |
2407 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2407 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2408 | else if ( setpref.reverse->isChecked() ) | 2408 | else if ( setpref.reverse->isChecked() ) |
2409 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2409 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2410 | else | 2410 | else |
2411 | fName = (*it).organization(); | 2411 | fName = (*it).organization(); |
2412 | if ( setpref.setCompany->isChecked() ) | 2412 | if ( setpref.setCompany->isChecked() ) |
2413 | if ( fName.isEmpty() || fName =="," ) | 2413 | if ( fName.isEmpty() || fName =="," ) |
2414 | fName = (*it).organization(); | 2414 | fName = (*it).organization(); |
2415 | (*it).setFormattedName( fName ); | 2415 | (*it).setFormattedName( fName ); |
2416 | } | 2416 | } |
2417 | } | 2417 | } |
2418 | message(i18n("Refreshing view...") ); | 2418 | message(i18n("Refreshing view...") ); |
2419 | qApp->processEvents(); | 2419 | qApp->processEvents(); |
2420 | mViewManager->refreshView( "" ); | 2420 | mViewManager->refreshView( "" ); |
2421 | Addressee add; | 2421 | Addressee add; |
2422 | mDetails->setAddressee( add ); | 2422 | mDetails->setAddressee( add ); |
2423 | message(i18n("Setting formatted name completed!") ); | 2423 | message(i18n("Setting formatted name completed!") ); |
2424 | } | 2424 | } |
2425 | 2425 | ||
2426 | void KABCore::clipboardDataChanged() | 2426 | void KABCore::clipboardDataChanged() |
2427 | { | 2427 | { |
2428 | 2428 | ||
2429 | if ( mReadWrite ) | 2429 | if ( mReadWrite ) |
2430 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2430 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2431 | 2431 | ||
2432 | } | 2432 | } |
2433 | 2433 | ||
2434 | void KABCore::updateActionMenu() | 2434 | void KABCore::updateActionMenu() |
2435 | { | 2435 | { |
2436 | UndoStack *undo = UndoStack::instance(); | 2436 | UndoStack *undo = UndoStack::instance(); |
2437 | RedoStack *redo = RedoStack::instance(); | 2437 | RedoStack *redo = RedoStack::instance(); |
2438 | 2438 | ||
2439 | if ( undo->isEmpty() ) | 2439 | if ( undo->isEmpty() ) |
2440 | mActionUndo->setText( i18n( "Undo" ) ); | 2440 | mActionUndo->setText( i18n( "Undo" ) ); |
2441 | else | 2441 | else |
2442 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2442 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2443 | 2443 | ||
2444 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2444 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2445 | 2445 | ||
2446 | if ( !redo->top() ) | 2446 | if ( !redo->top() ) |
2447 | mActionRedo->setText( i18n( "Redo" ) ); | 2447 | mActionRedo->setText( i18n( "Redo" ) ); |
2448 | else | 2448 | else |
2449 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2449 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2450 | 2450 | ||
2451 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2451 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2452 | } | 2452 | } |
2453 | 2453 | ||
2454 | void KABCore::configureKeyBindings() | 2454 | void KABCore::configureKeyBindings() |
2455 | { | 2455 | { |
2456 | #ifndef KAB_EMBEDDED | 2456 | #ifndef KAB_EMBEDDED |
2457 | KKeyDialog::configure( actionCollection(), true ); | 2457 | KKeyDialog::configure( actionCollection(), true ); |
2458 | #else //KAB_EMBEDDED | 2458 | #else //KAB_EMBEDDED |
2459 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2459 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2460 | #endif //KAB_EMBEDDED | 2460 | #endif //KAB_EMBEDDED |
2461 | } | 2461 | } |
2462 | 2462 | ||
2463 | #ifdef KAB_EMBEDDED | 2463 | #ifdef KAB_EMBEDDED |
2464 | void KABCore::configureResources() | 2464 | void KABCore::configureResources() |
2465 | { | 2465 | { |
2466 | KRES::KCMKResources dlg( this, "" , 0 ); | 2466 | KRES::KCMKResources dlg( this, "" , 0 ); |
2467 | 2467 | ||
2468 | if ( !dlg.exec() ) | 2468 | if ( !dlg.exec() ) |
2469 | return; | 2469 | return; |
2470 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2470 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2471 | } | 2471 | } |
2472 | #endif //KAB_EMBEDDED | 2472 | #endif //KAB_EMBEDDED |
2473 | 2473 | ||
2474 | 2474 | ||
2475 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2475 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2476 | * for the attendees list of an event. | 2476 | * for the attendees list of an event. |
2477 | */ | 2477 | */ |
2478 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2478 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2479 | { | 2479 | { |
2480 | QStringList nameList; | 2480 | QStringList nameList; |
2481 | QStringList emailList; | 2481 | QStringList emailList; |
2482 | QStringList uidList; | 2482 | QStringList uidList; |
2483 | 2483 | ||
2484 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2484 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2485 | uint i=0; | 2485 | uint i=0; |
2486 | for (i=0; i < list.count(); i++) | 2486 | for (i=0; i < list.count(); i++) |
2487 | { | 2487 | { |
2488 | nameList.append(list[i].realName()); | 2488 | nameList.append(list[i].realName()); |
2489 | emailList.append(list[i].preferredEmail()); | 2489 | emailList.append(list[i].preferredEmail()); |
2490 | uidList.append(list[i].uid()); | 2490 | uidList.append(list[i].uid()); |
2491 | } | 2491 | } |
2492 | 2492 | ||
2493 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2493 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2494 | 2494 | ||
2495 | } | 2495 | } |
2496 | 2496 | ||
2497 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2497 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2498 | * to put them into the calendar. | 2498 | * to put them into the calendar. |
2499 | */ | 2499 | */ |
2500 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2500 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2501 | { | 2501 | { |
2502 | // qDebug("KABCore::requestForBirthdayList"); | 2502 | // qDebug("KABCore::requestForBirthdayList"); |
2503 | QStringList birthdayList; | 2503 | QStringList birthdayList; |
2504 | QStringList anniversaryList; | 2504 | QStringList anniversaryList; |
2505 | QStringList realNameList; | 2505 | QStringList realNameList; |
2506 | QStringList preferredEmailList; | 2506 | QStringList preferredEmailList; |
2507 | QStringList assembledNameList; | 2507 | QStringList assembledNameList; |
2508 | QStringList uidList; | 2508 | QStringList uidList; |
2509 | 2509 | ||
2510 | KABC::AddressBook::Iterator it; | 2510 | KABC::AddressBook::Iterator it; |
2511 | 2511 | ||
2512 | int count = 0; | 2512 | int count = 0; |
2513 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2513 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2514 | ++count; | 2514 | ++count; |
2515 | } | 2515 | } |
2516 | QProgressBar bar(count,0 ); | 2516 | QProgressBar bar(count,0 ); |
2517 | int w = 300; | 2517 | int w = 300; |
2518 | if ( QApplication::desktop()->width() < 320 ) | 2518 | if ( QApplication::desktop()->width() < 320 ) |
2519 | w = 220; | 2519 | w = 220; |
2520 | int h = bar.sizeHint().height() ; | 2520 | int h = bar.sizeHint().height() ; |
2521 | int dw = QApplication::desktop()->width(); | 2521 | int dw = QApplication::desktop()->width(); |
2522 | int dh = QApplication::desktop()->height(); | 2522 | int dh = QApplication::desktop()->height(); |
2523 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2523 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2524 | bar.show(); | 2524 | bar.show(); |
2525 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2525 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2526 | qApp->processEvents(); | 2526 | qApp->processEvents(); |
2527 | 2527 | ||
2528 | QDate bday; | 2528 | QDate bday; |
2529 | QString anni; | 2529 | QString anni; |
2530 | QString formattedbday; | 2530 | QString formattedbday; |
2531 | 2531 | ||
2532 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2532 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2533 | { | 2533 | { |
2534 | if ( ! bar.isVisible() ) | 2534 | if ( ! bar.isVisible() ) |
2535 | return; | 2535 | return; |
2536 | bar.setProgress( count++ ); | 2536 | bar.setProgress( count++ ); |
2537 | qApp->processEvents(); | 2537 | qApp->processEvents(); |
2538 | bday = (*it).birthday().date(); | 2538 | bday = (*it).birthday().date(); |
2539 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2539 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2540 | 2540 | ||
2541 | if ( bday.isValid() || !anni.isEmpty()) | 2541 | if ( bday.isValid() || !anni.isEmpty()) |
2542 | { | 2542 | { |
2543 | if (bday.isValid()) | 2543 | if (bday.isValid()) |
2544 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2544 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2545 | else | 2545 | else |
2546 | formattedbday = "NOTVALID"; | 2546 | formattedbday = "NOTVALID"; |
2547 | if (anni.isEmpty()) | 2547 | if (anni.isEmpty()) |
2548 | anni = "INVALID"; | 2548 | anni = "INVALID"; |
2549 | 2549 | ||
2550 | birthdayList.append(formattedbday); | 2550 | birthdayList.append(formattedbday); |
2551 | anniversaryList.append(anni); //should be ISODate | 2551 | anniversaryList.append(anni); //should be ISODate |
2552 | realNameList.append((*it).realName()); | 2552 | realNameList.append((*it).realName()); |
2553 | preferredEmailList.append((*it).preferredEmail()); | 2553 | preferredEmailList.append((*it).preferredEmail()); |
2554 | assembledNameList.append((*it).assembledName()); | 2554 | assembledNameList.append((*it).assembledName()); |
2555 | uidList.append((*it).uid()); | 2555 | uidList.append((*it).uid()); |
2556 | 2556 | ||
2557 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2557 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2558 | } | 2558 | } |
2559 | } | 2559 | } |
2560 | 2560 | ||
2561 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2561 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2562 | 2562 | ||
2563 | } | 2563 | } |
2564 | 2564 | ||
2565 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2565 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2566 | */ | 2566 | */ |
2567 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2567 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2568 | { | 2568 | { |
2569 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2569 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2570 | 2570 | ||
2571 | QString foundUid = QString::null; | 2571 | QString foundUid = QString::null; |
2572 | if ( ! uid.isEmpty() ) { | 2572 | if ( ! uid.isEmpty() ) { |
2573 | Addressee adrr = mAddressBook->findByUid( uid ); | 2573 | Addressee adrr = mAddressBook->findByUid( uid ); |
2574 | if ( !adrr.isEmpty() ) { | 2574 | if ( !adrr.isEmpty() ) { |
2575 | foundUid = uid; | 2575 | foundUid = uid; |
2576 | } | 2576 | } |
2577 | if ( email == "sendbacklist" ) { | 2577 | if ( email == "sendbacklist" ) { |
2578 | //qDebug("ssssssssssssssssssssssend "); | 2578 | //qDebug("ssssssssssssssssssssssend "); |
2579 | QStringList nameList; | 2579 | QStringList nameList; |
2580 | QStringList emailList; | 2580 | QStringList emailList; |
2581 | QStringList uidList; | 2581 | QStringList uidList; |
2582 | nameList.append(adrr.realName()); | 2582 | nameList.append(adrr.realName()); |
2583 | emailList = adrr.emails(); | 2583 | emailList = adrr.emails(); |
2584 | uidList.append( adrr.preferredEmail()); | 2584 | uidList.append( adrr.preferredEmail()); |
2585 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2585 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2586 | return; | 2586 | return; |
2587 | } | 2587 | } |
2588 | 2588 | ||
2589 | } | 2589 | } |
2590 | 2590 | ||
2591 | if ( email == "sendbacklist" ) | 2591 | if ( email == "sendbacklist" ) |
2592 | return; | 2592 | return; |
2593 | if (foundUid.isEmpty()) | 2593 | if (foundUid.isEmpty()) |
2594 | { | 2594 | { |
2595 | //find the uid of the person first | 2595 | //find the uid of the person first |
2596 | Addressee::List namelist; | 2596 | Addressee::List namelist; |
2597 | Addressee::List emaillist; | 2597 | Addressee::List emaillist; |
2598 | 2598 | ||
2599 | if (!name.isEmpty()) | 2599 | if (!name.isEmpty()) |
2600 | namelist = mAddressBook->findByName( name ); | 2600 | namelist = mAddressBook->findByName( name ); |
2601 | 2601 | ||
2602 | if (!email.isEmpty()) | 2602 | if (!email.isEmpty()) |
2603 | emaillist = mAddressBook->findByEmail( email ); | 2603 | emaillist = mAddressBook->findByEmail( email ); |
2604 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2604 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2605 | //check if we have a match in Namelist and Emaillist | 2605 | //check if we have a match in Namelist and Emaillist |
2606 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2606 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2607 | foundUid = emaillist[0].uid(); | 2607 | foundUid = emaillist[0].uid(); |
2608 | } | 2608 | } |
2609 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2609 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2610 | foundUid = namelist[0].uid(); | 2610 | foundUid = namelist[0].uid(); |
2611 | else | 2611 | else |
2612 | { | 2612 | { |
2613 | for (int i = 0; i < namelist.count(); i++) | 2613 | for (int i = 0; i < namelist.count(); i++) |
2614 | { | 2614 | { |
2615 | for (int j = 0; j < emaillist.count(); j++) | 2615 | for (int j = 0; j < emaillist.count(); j++) |
2616 | { | 2616 | { |
2617 | if (namelist[i] == emaillist[j]) | 2617 | if (namelist[i] == emaillist[j]) |
2618 | { | 2618 | { |
2619 | foundUid = namelist[i].uid(); | 2619 | foundUid = namelist[i].uid(); |
2620 | } | 2620 | } |
2621 | } | 2621 | } |
2622 | } | 2622 | } |
2623 | } | 2623 | } |
2624 | } | 2624 | } |
2625 | else | 2625 | else |
2626 | { | 2626 | { |
2627 | foundUid = uid; | 2627 | foundUid = uid; |
2628 | } | 2628 | } |
2629 | 2629 | ||
2630 | if (!foundUid.isEmpty()) | 2630 | if (!foundUid.isEmpty()) |
2631 | { | 2631 | { |
2632 | 2632 | ||
2633 | // raise Ka/Pi if it is in the background | 2633 | // raise Ka/Pi if it is in the background |
2634 | #ifndef DESKTOP_VERSION | 2634 | #ifndef DESKTOP_VERSION |
2635 | #ifndef KORG_NODCOP | 2635 | #ifndef KORG_NODCOP |
2636 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2636 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2637 | #endif | 2637 | #endif |
2638 | #endif | 2638 | #endif |
2639 | 2639 | ||
2640 | mMainWindow->showMaximized(); | 2640 | mMainWindow->showMaximized(); |
2641 | mMainWindow-> raise(); | 2641 | mMainWindow-> raise(); |
2642 | 2642 | ||
2643 | mViewManager->setSelected( "", false); | 2643 | mViewManager->setSelected( "", false); |
2644 | mViewManager->refreshView( "" ); | 2644 | mViewManager->refreshView( "" ); |
2645 | mViewManager->setSelected( foundUid, true ); | 2645 | mViewManager->setSelected( foundUid, true ); |
2646 | mViewManager->refreshView( foundUid ); | 2646 | mViewManager->refreshView( foundUid ); |
2647 | 2647 | ||
2648 | if ( !mMultipleViewsAtOnce ) | 2648 | if ( !mMultipleViewsAtOnce ) |
2649 | { | 2649 | { |
2650 | setDetailsVisible( true ); | 2650 | setDetailsVisible( true ); |
2651 | mActionDetails->setChecked(true); | 2651 | mActionDetails->setChecked(true); |
2652 | } | 2652 | } |
2653 | } | 2653 | } |
2654 | } | 2654 | } |
2655 | 2655 | ||
2656 | void KABCore::whatsnew() | 2656 | void KABCore::whatsnew() |
2657 | { | 2657 | { |
2658 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2658 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2659 | } | 2659 | } |
2660 | void KABCore::synchowto() | 2660 | void KABCore::synchowto() |
2661 | { | 2661 | { |
2662 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2662 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2663 | } | 2663 | } |
2664 | void KABCore::kdesynchowto() | 2664 | void KABCore::kdesynchowto() |
2665 | { | 2665 | { |
2666 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2666 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2667 | } | 2667 | } |
2668 | void KABCore::multisynchowto() | 2668 | void KABCore::multisynchowto() |
2669 | { | 2669 | { |
2670 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2670 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2671 | } | 2671 | } |
2672 | void KABCore::faq() | 2672 | void KABCore::faq() |
2673 | { | 2673 | { |
2674 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2674 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2675 | } | 2675 | } |
2676 | 2676 | ||
2677 | #include <libkcal/syncdefines.h> | 2677 | #include <libkcal/syncdefines.h> |
2678 | 2678 | ||
2679 | KABC::Addressee KABCore::getLastSyncAddressee() | 2679 | KABC::Addressee KABCore::getLastSyncAddressee() |
2680 | { | 2680 | { |
2681 | Addressee lse; | 2681 | Addressee lse; |
2682 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2682 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2683 | 2683 | ||
2684 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2684 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2685 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2685 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2686 | if (lse.isEmpty()) { | 2686 | if (lse.isEmpty()) { |
2687 | qDebug("Creating new last-syncAddressee "); | 2687 | qDebug("KA: Creating new last-syncAddressee "); |
2688 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2688 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2689 | QString sum = ""; | 2689 | QString sum = ""; |
2690 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2690 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2691 | sum = "E: "; | 2691 | sum = "E: "; |
2692 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2692 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2693 | lse.setRevision( mLastAddressbookSync ); | 2693 | lse.setRevision( mLastAddressbookSync ); |
2694 | lse.setCategories( i18n("SyncEvent") ); | 2694 | lse.setCategories( i18n("SyncEvent") ); |
2695 | mAddressBook->insertAddressee( lse ); | 2695 | mAddressBook->insertAddressee( lse ); |
2696 | } | 2696 | } |
2697 | return lse; | 2697 | return lse; |
2698 | } | 2698 | } |
2699 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2699 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2700 | { | 2700 | { |
2701 | 2701 | ||
2702 | //void setZaurusId(int id); | 2702 | //void setZaurusId(int id); |
2703 | // int zaurusId() const; | 2703 | // int zaurusId() const; |
2704 | // void setZaurusUid(int id); | 2704 | // void setZaurusUid(int id); |
2705 | // int zaurusUid() const; | 2705 | // int zaurusUid() const; |
2706 | // void setZaurusStat(int id); | 2706 | // void setZaurusStat(int id); |
2707 | // int zaurusStat() const; | 2707 | // int zaurusStat() const; |
2708 | // 0 equal | 2708 | // 0 equal |
2709 | // 1 take local | 2709 | // 1 take local |
2710 | // 2 take remote | 2710 | // 2 take remote |
2711 | // 3 cancel | 2711 | // 3 cancel |
2712 | QDateTime lastSync = mLastAddressbookSync; | 2712 | QDateTime lastSync = mLastAddressbookSync; |
2713 | QDateTime localMod = local->revision(); | 2713 | QDateTime localMod = local->revision(); |
2714 | QDateTime remoteMod = remote->revision(); | 2714 | QDateTime remoteMod = remote->revision(); |
2715 | 2715 | ||
2716 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2716 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2717 | 2717 | ||
2718 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2718 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2719 | bool remCh, locCh; | 2719 | bool remCh, locCh; |
2720 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2720 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2721 | if ( remCh ) | 2721 | //if ( remCh ) |
2722 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2722 | // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2723 | locCh = ( localMod > mLastAddressbookSync ); | 2723 | locCh = ( localMod > mLastAddressbookSync ); |
2724 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); | 2724 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); |
2725 | if ( !remCh && ! locCh ) { | 2725 | if ( !remCh && ! locCh ) { |
2726 | //qDebug("both not changed "); | 2726 | //qDebug("both not changed "); |
2727 | lastSync = localMod.addDays(1); | 2727 | lastSync = localMod.addDays(1); |
2728 | if ( mode <= SYNC_PREF_ASK ) | 2728 | if ( mode <= SYNC_PREF_ASK ) |
2729 | return 0; | 2729 | return 0; |
2730 | } else { | 2730 | } else { |
2731 | if ( locCh ) { | 2731 | if ( locCh ) { |
2732 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2732 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2733 | lastSync = localMod.addDays( -1 ); | 2733 | lastSync = localMod.addDays( -1 ); |
2734 | if ( !remCh ) | 2734 | if ( !remCh ) |
2735 | remoteMod =( lastSync.addDays( -1 ) ); | 2735 | remoteMod =( lastSync.addDays( -1 ) ); |
2736 | } else { | 2736 | } else { |
2737 | //qDebug(" not loc changed "); | 2737 | //qDebug(" not loc changed "); |
2738 | lastSync = localMod.addDays( 1 ); | 2738 | lastSync = localMod.addDays( 1 ); |
2739 | if ( remCh ) { | 2739 | if ( remCh ) { |
2740 | //qDebug("rem changed "); | 2740 | //qDebug("rem changed "); |
2741 | remoteMod =( lastSync.addDays( 1 ) ); | 2741 | remoteMod =( lastSync.addDays( 1 ) ); |
2742 | } | 2742 | } |
2743 | 2743 | ||
2744 | } | 2744 | } |
2745 | } | 2745 | } |
2746 | full = true; | 2746 | full = true; |
2747 | if ( mode < SYNC_PREF_ASK ) | 2747 | if ( mode < SYNC_PREF_ASK ) |
2748 | mode = SYNC_PREF_ASK; | 2748 | mode = SYNC_PREF_ASK; |
2749 | } else { | 2749 | } else { |
2750 | if ( localMod == remoteMod ) | 2750 | if ( localMod == remoteMod ) |
2751 | return 0; | 2751 | return 0; |
2752 | 2752 | ||
2753 | } | 2753 | } |
2754 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2754 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2755 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2755 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2756 | //full = true; //debug only | 2756 | //full = true; //debug only |
2757 | if ( full ) { | 2757 | if ( full ) { |
2758 | bool equ = ( (*local) == (*remote) ); | 2758 | bool equ = ( (*local) == (*remote) ); |
2759 | if ( equ ) { | 2759 | if ( equ ) { |
2760 | //qDebug("equal "); | 2760 | //qDebug("equal "); |
2761 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2761 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2762 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2762 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2763 | } | 2763 | } |
2764 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2764 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2765 | return 0; | 2765 | return 0; |
2766 | 2766 | ||
2767 | }//else //debug only | 2767 | }//else //debug only |
2768 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2768 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2769 | } | 2769 | } |
2770 | int result; | 2770 | int result; |
2771 | bool localIsNew; | 2771 | bool localIsNew; |
2772 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2772 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2773 | 2773 | ||
2774 | if ( full && mode < SYNC_PREF_NEWEST ) | 2774 | if ( full && mode < SYNC_PREF_NEWEST ) |
2775 | mode = SYNC_PREF_ASK; | 2775 | mode = SYNC_PREF_ASK; |
2776 | 2776 | ||
2777 | switch( mode ) { | 2777 | switch( mode ) { |
2778 | case SYNC_PREF_LOCAL: | 2778 | case SYNC_PREF_LOCAL: |
2779 | if ( lastSync > remoteMod ) | 2779 | if ( lastSync > remoteMod ) |
2780 | return 1; | 2780 | return 1; |
2781 | if ( lastSync > localMod ) | 2781 | if ( lastSync > localMod ) |
2782 | return 2; | 2782 | return 2; |
2783 | return 1; | 2783 | return 1; |
2784 | break; | 2784 | break; |
2785 | case SYNC_PREF_REMOTE: | 2785 | case SYNC_PREF_REMOTE: |
2786 | if ( lastSync > remoteMod ) | 2786 | if ( lastSync > remoteMod ) |
2787 | return 1; | 2787 | return 1; |
2788 | if ( lastSync > localMod ) | 2788 | if ( lastSync > localMod ) |
2789 | return 2; | 2789 | return 2; |
2790 | return 2; | 2790 | return 2; |
2791 | break; | 2791 | break; |
2792 | case SYNC_PREF_NEWEST: | 2792 | case SYNC_PREF_NEWEST: |
2793 | if ( localMod > remoteMod ) | 2793 | if ( localMod > remoteMod ) |
2794 | return 1; | 2794 | return 1; |
2795 | else | 2795 | else |
2796 | return 2; | 2796 | return 2; |
2797 | break; | 2797 | break; |
2798 | case SYNC_PREF_ASK: | 2798 | case SYNC_PREF_ASK: |
2799 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2799 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2800 | if ( lastSync > remoteMod ) | 2800 | if ( lastSync > remoteMod ) |
2801 | return 1; | 2801 | return 1; |
2802 | if ( lastSync > localMod ) { | 2802 | if ( lastSync > localMod ) { |
2803 | return 2; | 2803 | return 2; |
2804 | } | 2804 | } |
2805 | localIsNew = localMod >= remoteMod; | 2805 | localIsNew = localMod >= remoteMod; |
2806 | //qDebug("conflict! ************************************** "); | 2806 | //qDebug("conflict! ************************************** "); |
2807 | { | 2807 | { |
2808 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2808 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2809 | result = acd.executeD(localIsNew); | 2809 | result = acd.executeD(localIsNew); |
2810 | return result; | 2810 | return result; |
2811 | } | 2811 | } |
2812 | break; | 2812 | break; |
2813 | case SYNC_PREF_FORCE_LOCAL: | 2813 | case SYNC_PREF_FORCE_LOCAL: |
2814 | return 1; | 2814 | return 1; |
2815 | break; | 2815 | break; |
2816 | case SYNC_PREF_FORCE_REMOTE: | 2816 | case SYNC_PREF_FORCE_REMOTE: |
2817 | return 2; | 2817 | return 2; |
2818 | break; | 2818 | break; |
2819 | 2819 | ||
2820 | default: | 2820 | default: |
2821 | // SYNC_PREF_TAKE_BOTH not implemented | 2821 | // SYNC_PREF_TAKE_BOTH not implemented |
2822 | break; | 2822 | break; |
2823 | } | 2823 | } |
2824 | return 0; | 2824 | return 0; |
2825 | } | 2825 | } |
2826 | 2826 | ||
2827 | 2827 | ||
2828 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2828 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2829 | { | 2829 | { |
2830 | bool syncOK = true; | 2830 | bool syncOK = true; |
2831 | int addedAddressee = 0; | 2831 | int addedAddressee = 0; |
2832 | int addedAddresseeR = 0; | 2832 | int addedAddresseeR = 0; |
2833 | int deletedAddresseeR = 0; | 2833 | int deletedAddresseeR = 0; |
2834 | int deletedAddresseeL = 0; | 2834 | int deletedAddresseeL = 0; |
2835 | int changedLocal = 0; | 2835 | int changedLocal = 0; |
2836 | int changedRemote = 0; | 2836 | int changedRemote = 0; |
2837 | int filteredIN = 0; | 2837 | int filteredIN = 0; |
2838 | int filteredOUT = 0; | 2838 | int filteredOUT = 0; |
2839 | 2839 | ||
2840 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2840 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2841 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2841 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2842 | 2842 | ||
2843 | //QPtrList<Addressee> el = local->rawAddressees(); | 2843 | //QPtrList<Addressee> el = local->rawAddressees(); |
2844 | Addressee addresseeR; | 2844 | Addressee addresseeR; |
2845 | QString uid; | 2845 | QString uid; |
2846 | int take; | 2846 | int take; |
2847 | Addressee addresseeL; | 2847 | Addressee addresseeL; |
2848 | Addressee addresseeRSync; | 2848 | Addressee addresseeRSync; |
2849 | Addressee addresseeLSync; | 2849 | Addressee addresseeLSync; |
2850 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2850 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2851 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2851 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2852 | bool fullDateRange = false; | 2852 | bool fullDateRange = false; |
2853 | local->resetTempSyncStat(); | 2853 | local->resetTempSyncStat(); |
2854 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2854 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2855 | if ( syncManager->syncWithDesktop() ) { | 2855 | if ( syncManager->syncWithDesktop() ) { |
2856 | // remote->removeSyncInfo( QString());//remove all info | 2856 | // remote->removeSyncInfo( QString());//remove all info |
2857 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2857 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2858 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2858 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2859 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2859 | qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2860 | } else { | 2860 | } else { |
2861 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2861 | qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2862 | } | 2862 | } |
2863 | } | 2863 | } |
2864 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2864 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2865 | addresseeLSync = getLastSyncAddressee(); | 2865 | addresseeLSync = getLastSyncAddressee(); |
2866 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2866 | qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2867 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2867 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2868 | if ( !addresseeR.isEmpty() ) { | 2868 | if ( !addresseeR.isEmpty() ) { |
2869 | addresseeRSync = addresseeR; | 2869 | addresseeRSync = addresseeR; |
2870 | remote->removeAddressee(addresseeR ); | 2870 | remote->removeAddressee(addresseeR ); |
2871 | 2871 | ||
2872 | } else { | 2872 | } else { |
2873 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2873 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2874 | addresseeRSync = addresseeLSync ; | 2874 | addresseeRSync = addresseeLSync ; |
2875 | } else { | 2875 | } else { |
2876 | //qDebug("FULLDATE 1"); | 2876 | //qDebug("FULLDATE 1"); |
2877 | fullDateRange = true; | 2877 | fullDateRange = true; |
2878 | Addressee newAdd; | 2878 | Addressee newAdd; |
2879 | addresseeRSync = newAdd; | 2879 | addresseeRSync = newAdd; |
2880 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2880 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2881 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2881 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2882 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2882 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2883 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2883 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2884 | } | 2884 | } |
2885 | } | 2885 | } |
2886 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2886 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2887 | // qDebug("FULLDATE 2"); | 2887 | // qDebug("FULLDATE 2"); |
2888 | fullDateRange = true; | 2888 | fullDateRange = true; |
2889 | } | 2889 | } |
2890 | if ( ! fullDateRange ) { | 2890 | if ( ! fullDateRange ) { |
2891 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2891 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2892 | 2892 | ||
2893 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2893 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2894 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2894 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2895 | fullDateRange = true; | 2895 | fullDateRange = true; |
2896 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2896 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2897 | } | 2897 | } |
2898 | } | 2898 | } |
2899 | // fullDateRange = true; // debug only! | 2899 | // fullDateRange = true; // debug only! |
2900 | if ( fullDateRange ) | 2900 | if ( fullDateRange ) |
2901 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2901 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2902 | else | 2902 | else |
2903 | mLastAddressbookSync = addresseeLSync.revision(); | 2903 | mLastAddressbookSync = addresseeLSync.revision(); |
2904 | // for resyncing if own file has changed | 2904 | // for resyncing if own file has changed |
2905 | // PENDING fixme later when implemented | 2905 | // PENDING fixme later when implemented |
2906 | #if 0 | 2906 | #if 0 |
2907 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2907 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2908 | mLastAddressbookSync = loadedFileVersion; | 2908 | mLastAddressbookSync = loadedFileVersion; |
2909 | qDebug("setting mLastAddressbookSync "); | 2909 | qDebug("setting mLastAddressbookSync "); |
2910 | } | 2910 | } |
2911 | #endif | 2911 | #endif |
2912 | 2912 | ||
2913 | 2913 | ||
2914 | // ********** setting filters **************** | 2914 | // ********** setting filters **************** |
2915 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); | 2915 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); |
2916 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); | 2916 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); |
2917 | 2917 | ||
2918 | //qDebug("*************************** "); | 2918 | //qDebug("*************************** "); |
2919 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2919 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2920 | QStringList er = remote->uidList(); | 2920 | QStringList er = remote->uidList(); |
2921 | Addressee inR ;//= er.first(); | 2921 | Addressee inR ;//= er.first(); |
2922 | Addressee inL; | 2922 | Addressee inL; |
2923 | 2923 | ||
2924 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2924 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2925 | 2925 | ||
2926 | int modulo = (er.count()/10)+1; | 2926 | int modulo = (er.count()/10)+1; |
2927 | int incCounter = 0; | 2927 | int incCounter = 0; |
2928 | while ( incCounter < er.count()) { | 2928 | while ( incCounter < er.count()) { |
2929 | if (syncManager->isProgressBarCanceled()) | 2929 | if (syncManager->isProgressBarCanceled()) |
2930 | return false; | 2930 | return false; |
2931 | if ( incCounter % modulo == 0 ) | 2931 | if ( incCounter % modulo == 0 ) |
2932 | syncManager->showProgressBar(incCounter); | 2932 | syncManager->showProgressBar(incCounter); |
2933 | 2933 | ||
2934 | uid = er[ incCounter ]; | 2934 | uid = er[ incCounter ]; |
2935 | bool skipIncidence = false; | 2935 | bool skipIncidence = false; |
2936 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2936 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2937 | skipIncidence = true; | 2937 | skipIncidence = true; |
2938 | QString idS,OidS; | 2938 | QString idS,OidS; |
2939 | qApp->processEvents(); | 2939 | qApp->processEvents(); |
2940 | if ( !skipIncidence ) { | 2940 | if ( !skipIncidence ) { |
2941 | inL = local->findByUid( uid ); | 2941 | inL = local->findByUid( uid ); |
2942 | inR = remote->findByUid( uid ); | 2942 | inR = remote->findByUid( uid ); |
2943 | //inL.setResource( 0 ); | 2943 | //inL.setResource( 0 ); |
2944 | //inR.setResource( 0 ); | 2944 | //inR.setResource( 0 ); |
2945 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2945 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2946 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2946 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2947 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { | 2947 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
2948 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2948 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2949 | if ( take == 3 ) | 2949 | if ( take == 3 ) |
2950 | return false; | 2950 | return false; |
2951 | if ( take == 1 ) {// take local ********************** | 2951 | if ( take == 1 ) {// take local ********************** |
2952 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2952 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2953 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2953 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2954 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2954 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2955 | local->insertAddressee( inL, false ); | 2955 | local->insertAddressee( inL, false ); |
2956 | idS = inR.externalUID(); | 2956 | idS = inR.externalUID(); |
2957 | OidS = inR.originalExternalUID(); | 2957 | OidS = inR.originalExternalUID(); |
2958 | } | 2958 | } |
2959 | else | 2959 | else |
2960 | idS = inR.IDStr(); | 2960 | idS = inR.IDStr(); |
2961 | remote->removeAddressee( inR ); | 2961 | remote->removeAddressee( inR ); |
2962 | inR = inL; | 2962 | inR = inL; |
2963 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2963 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2964 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2964 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2965 | inR.setOriginalExternalUID( OidS ); | 2965 | inR.setOriginalExternalUID( OidS ); |
2966 | inR.setExternalUID( idS ); | 2966 | inR.setExternalUID( idS ); |
2967 | if ( syncManager->syncWithDesktop() ) { | 2967 | if ( syncManager->syncWithDesktop() ) { |
2968 | inR.setIDStr("changed" ); | 2968 | inR.setIDStr("changed" ); |
2969 | } | 2969 | } |
2970 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 2970 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2971 | } else { | 2971 | } else { |
2972 | inR.setIDStr( idS ); | 2972 | inR.setIDStr( idS ); |
2973 | } | 2973 | } |
2974 | inR.setResource( 0 ); | 2974 | inR.setResource( 0 ); |
2975 | remote->insertAddressee( inR , false); | 2975 | remote->insertAddressee( inR , false); |
2976 | ++changedRemote; | 2976 | ++changedRemote; |
2977 | } else { // take == 2 take remote ********************** | 2977 | } else { // take == 2 take remote ********************** |
2978 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2978 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2979 | if ( inR.revision().date().year() < 2004 ) | 2979 | if ( inR.revision().date().year() < 2004 ) |
2980 | inR.setRevision( modifiedCalendar ); | 2980 | inR.setRevision( modifiedCalendar ); |
2981 | } | 2981 | } |
2982 | idS = inL.IDStr(); | 2982 | idS = inL.IDStr(); |
2983 | local->removeAddressee( inL ); | 2983 | local->removeAddressee( inL ); |
2984 | inL = inR; | 2984 | inL = inR; |
2985 | inL.setIDStr( idS ); | 2985 | inL.setIDStr( idS ); |
2986 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2986 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2987 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2987 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2988 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2988 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2989 | } | 2989 | } |
2990 | inL.setResource( 0 ); | 2990 | inL.setResource( 0 ); |
2991 | local->insertAddressee( inL , false ); | 2991 | local->insertAddressee( inL , false ); |
2992 | ++changedLocal; | 2992 | ++changedLocal; |
2993 | } | 2993 | } |
2994 | } | 2994 | } |
2995 | } | 2995 | } |
2996 | } else { // no conflict ********** add or delete remote | 2996 | } else { // no conflict ********** add or delete remote |
2997 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { | 2997 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { |
2998 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2998 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2999 | QString des = addresseeLSync.note(); | 2999 | QString des = addresseeLSync.note(); |
3000 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 3000 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
3001 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 3001 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
3002 | remote->insertAddressee( inR, false ); | 3002 | remote->insertAddressee( inR, false ); |
3003 | ++deletedAddresseeR; | 3003 | ++deletedAddresseeR; |
3004 | } else { | 3004 | } else { |
3005 | inR.setRevision( modifiedCalendar ); | 3005 | inR.setRevision( modifiedCalendar ); |
3006 | remote->insertAddressee( inR, false ); | 3006 | remote->insertAddressee( inR, false ); |
3007 | inL = inR; | 3007 | inL = inR; |
3008 | inL.setIDStr( ":" ); | 3008 | inL.setIDStr( ":" ); |
3009 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3009 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3010 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3010 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3011 | inL.setResource( 0 ); | 3011 | inL.setResource( 0 ); |
3012 | local->insertAddressee( inL , false); | 3012 | local->insertAddressee( inL , false); |
3013 | ++addedAddressee; | 3013 | ++addedAddressee; |
3014 | } | 3014 | } |
3015 | } else { | 3015 | } else { |
3016 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 3016 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
3017 | inR.setRevision( modifiedCalendar ); | 3017 | inR.setRevision( modifiedCalendar ); |
3018 | remote->insertAddressee( inR, false ); | 3018 | remote->insertAddressee( inR, false ); |
3019 | inR.setResource( 0 ); | 3019 | inR.setResource( 0 ); |
3020 | local->insertAddressee( inR, false ); | 3020 | local->insertAddressee( inR, false ); |
3021 | ++addedAddressee; | 3021 | ++addedAddressee; |
3022 | } else { | 3022 | } else { |
3023 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 3023 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
3024 | remote->removeAddressee( inR ); | 3024 | remote->removeAddressee( inR ); |
3025 | ++deletedAddresseeR; | 3025 | ++deletedAddresseeR; |
3026 | } | 3026 | } |
3027 | } | 3027 | } |
3028 | } else { | 3028 | } else { |
3029 | ++filteredIN; | 3029 | ++filteredIN; |
3030 | } | 3030 | } |
3031 | } | 3031 | } |
3032 | } | 3032 | } |
3033 | ++incCounter; | 3033 | ++incCounter; |
3034 | } | 3034 | } |
3035 | er.clear(); | 3035 | er.clear(); |
3036 | QStringList el = local->uidList(); | 3036 | QStringList el = local->uidList(); |
3037 | modulo = (el.count()/10)+1; | 3037 | modulo = (el.count()/10)+1; |
3038 | 3038 | ||
3039 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3039 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
3040 | incCounter = 0; | 3040 | incCounter = 0; |
3041 | while ( incCounter < el.count()) { | 3041 | while ( incCounter < el.count()) { |
3042 | qApp->processEvents(); | 3042 | qApp->processEvents(); |
3043 | if (syncManager->isProgressBarCanceled()) | 3043 | if (syncManager->isProgressBarCanceled()) |
3044 | return false; | 3044 | return false; |
3045 | if ( incCounter % modulo == 0 ) | 3045 | if ( incCounter % modulo == 0 ) |
3046 | syncManager->showProgressBar(incCounter); | 3046 | syncManager->showProgressBar(incCounter); |
3047 | uid = el[ incCounter ]; | 3047 | uid = el[ incCounter ]; |
3048 | bool skipIncidence = false; | 3048 | bool skipIncidence = false; |
3049 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3049 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3050 | skipIncidence = true; | 3050 | skipIncidence = true; |
3051 | if ( !skipIncidence ) { | 3051 | if ( !skipIncidence ) { |
3052 | inL = local->findByUid( uid ); | 3052 | inL = local->findByUid( uid ); |
3053 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3053 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3054 | inR = remote->findByUid( uid ); | 3054 | inR = remote->findByUid( uid ); |
3055 | if ( inR.isEmpty() ){ | 3055 | if ( inR.isEmpty() ){ |
3056 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { | 3056 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { |
3057 | // no conflict ********** add or delete local | 3057 | // no conflict ********** add or delete local |
3058 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3058 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3059 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3059 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3060 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3060 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3061 | local->removeAddressee( inL ); | 3061 | local->removeAddressee( inL ); |
3062 | ++deletedAddresseeL; | 3062 | ++deletedAddresseeL; |
3063 | } else { | 3063 | } else { |
3064 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3064 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3065 | inL.removeID(mCurrentSyncDevice ); | 3065 | inL.removeID(mCurrentSyncDevice ); |
3066 | ++addedAddresseeR; | 3066 | ++addedAddresseeR; |
3067 | inL.setRevision( modifiedCalendar ); | 3067 | inL.setRevision( modifiedCalendar ); |
3068 | local->insertAddressee( inL, false ); | 3068 | local->insertAddressee( inL, false ); |
3069 | inR = inL; | 3069 | inR = inL; |
3070 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3070 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3071 | inR.setResource( 0 ); | 3071 | inR.setResource( 0 ); |
3072 | remote->insertAddressee( inR, false ); | 3072 | remote->insertAddressee( inR, false ); |
3073 | } | 3073 | } |
3074 | } | 3074 | } |
3075 | } else { | 3075 | } else { |
3076 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3076 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3077 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3077 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3078 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3078 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3079 | local->removeAddressee( inL ); | 3079 | local->removeAddressee( inL ); |
3080 | ++deletedAddresseeL; | 3080 | ++deletedAddresseeL; |
3081 | } else { | 3081 | } else { |
3082 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3082 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3083 | ++addedAddresseeR; | 3083 | ++addedAddresseeR; |
3084 | inL.setRevision( modifiedCalendar ); | 3084 | inL.setRevision( modifiedCalendar ); |
3085 | local->insertAddressee( inL, false ); | 3085 | local->insertAddressee( inL, false ); |
3086 | inR = inL; | 3086 | inR = inL; |
3087 | inR.setIDStr( ":" ); | 3087 | inR.setIDStr( ":" ); |
3088 | inR.setResource( 0 ); | 3088 | inR.setResource( 0 ); |
3089 | remote->insertAddressee( inR, false ); | 3089 | remote->insertAddressee( inR, false ); |
3090 | } | 3090 | } |
3091 | } | 3091 | } |
3092 | } | 3092 | } |
3093 | } else { | 3093 | } else { |
3094 | ++filteredOUT; | 3094 | ++filteredOUT; |
3095 | } | 3095 | } |
3096 | } | 3096 | } |
3097 | } | 3097 | } |
3098 | } | 3098 | } |
3099 | ++incCounter; | 3099 | ++incCounter; |
3100 | } | 3100 | } |
3101 | el.clear(); | 3101 | el.clear(); |
3102 | syncManager->hideProgressBar(); | 3102 | syncManager->hideProgressBar(); |
3103 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3103 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3104 | // get rid of micro seconds | 3104 | // get rid of micro seconds |
3105 | QTime t = mLastAddressbookSync.time(); | 3105 | QTime t = mLastAddressbookSync.time(); |
3106 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3106 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3107 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3107 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3108 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3108 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3109 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3109 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3110 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3110 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3111 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3111 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3112 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3112 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3113 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3113 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3114 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3114 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3115 | addresseeRSync.setNote( "" ) ; | 3115 | addresseeRSync.setNote( "" ) ; |
3116 | addresseeLSync.setNote( "" ); | 3116 | addresseeLSync.setNote( "" ); |
3117 | 3117 | ||
3118 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3118 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3119 | remote->insertAddressee( addresseeRSync, false ); | 3119 | remote->insertAddressee( addresseeRSync, false ); |
3120 | local->insertAddressee( addresseeLSync, false ); | 3120 | local->insertAddressee( addresseeLSync, false ); |
3121 | QString mes; | 3121 | QString mes; |
3122 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); | 3122 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); |
3123 | qDebug( mes ); | 3123 | qDebug( mes ); |
3124 | mes = i18n("Local addressbook changed!\n") +mes; | 3124 | mes = i18n("Local addressbook changed!\n") +mes; |
3125 | if ( syncManager->mShowSyncSummary ) { | 3125 | if ( syncManager->mShowSyncSummary ) { |
3126 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3126 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3127 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3127 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3128 | qDebug("cancelled "); | 3128 | qDebug("KA: WB cancelled "); |
3129 | return false; | 3129 | return false; |
3130 | } | 3130 | } |
3131 | } | 3131 | } |
3132 | return syncOK; | 3132 | return syncOK; |
3133 | } | 3133 | } |
3134 | 3134 | ||
3135 | 3135 | ||
3136 | //this is a overwritten callbackmethods from the syncinterface | 3136 | //this is a overwritten callbackmethods from the syncinterface |
3137 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3137 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
3138 | { | 3138 | { |
3139 | 3139 | ||
3140 | //pending prepare addresseeview for output | 3140 | //pending prepare addresseeview for output |
3141 | //pending detect, if remote file has REV field. if not switch to external sync | 3141 | //pending detect, if remote file has REV field. if not switch to external sync |
3142 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3142 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3143 | if ( manager != syncManager ) | 3143 | if ( manager != syncManager ) |
3144 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3144 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3145 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3145 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3146 | 3146 | ||
3147 | AddressBook abLocal(filename,"syncContact"); | 3147 | AddressBook abLocal(filename,"syncContact"); |
3148 | bool syncOK = false; | 3148 | bool syncOK = false; |
3149 | if ( abLocal.load() ) { | 3149 | if ( abLocal.load() ) { |
3150 | qDebug("Sync:AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3150 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3151 | bool external = false; | 3151 | bool external = false; |
3152 | bool isXML = false; | 3152 | bool isXML = false; |
3153 | if ( filename.right(4) == ".xml") { | 3153 | if ( filename.right(4) == ".xml") { |
3154 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3154 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3155 | isXML = true; | 3155 | isXML = true; |
3156 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3156 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3157 | } else { | 3157 | } else { |
3158 | external = !manager->mIsKapiFile; | 3158 | external = !manager->mIsKapiFile; |
3159 | if ( external ) { | 3159 | if ( external ) { |
3160 | qDebug("Sync:Setting vcf mode to external "); | 3160 | qDebug("KA: Sync::Setting vcf mode to external "); |
3161 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3161 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3162 | AddressBook::Iterator it; | 3162 | AddressBook::Iterator it; |
3163 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3163 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3164 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3164 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3165 | (*it).computeCsum( mCurrentSyncDevice ); | 3165 | (*it).computeCsum( mCurrentSyncDevice ); |
3166 | } | 3166 | } |
3167 | } | 3167 | } |
3168 | } | 3168 | } |
3169 | //AddressBook::Iterator it; | 3169 | //AddressBook::Iterator it; |
3170 | //QStringList vcards; | 3170 | //QStringList vcards; |
3171 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3171 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3172 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3172 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3173 | //} | 3173 | //} |
3174 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3174 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3175 | if ( syncOK ) { | 3175 | if ( syncOK ) { |
3176 | if ( syncManager->mWriteBackFile ) | 3176 | if ( syncManager->mWriteBackFile ) |
3177 | { | 3177 | { |
3178 | if ( external ) | 3178 | if ( external ) |
3179 | abLocal.removeSyncAddressees( !isXML); | 3179 | abLocal.removeSyncAddressees( !isXML); |
3180 | qDebug("Sync:Saving remote AB "); | 3180 | qDebug("KA: Sync::Saving remote AB "); |
3181 | if ( ! abLocal.saveAB()) | 3181 | if ( ! abLocal.saveAB()) |
3182 | qDebug("Error writing back AB to file "); | 3182 | qDebug("KA: sync::Error writing back AB to file "); |
3183 | if ( external ) { | 3183 | if ( external ) { |
3184 | // afterwrite processing | 3184 | // afterwrite processing |
3185 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3185 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3186 | } | 3186 | } |
3187 | } | 3187 | } |
3188 | } | 3188 | } |
3189 | setModified(); | 3189 | setModified(); |
3190 | 3190 | ||
3191 | } | 3191 | } |
3192 | abLocal.removeResources(); | 3192 | abLocal.removeResources(); |
3193 | if ( syncOK ) | 3193 | if ( syncOK ) |
3194 | mViewManager->refreshView(); | 3194 | mViewManager->refreshView(); |
3195 | return syncOK; | 3195 | return syncOK; |
3196 | 3196 | ||
3197 | } | 3197 | } |
3198 | void KABCore::removeSyncInfo( QString syncProfile) | 3198 | void KABCore::removeSyncInfo( QString syncProfile) |
3199 | { | 3199 | { |
3200 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3200 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3201 | mAddressBook->removeSyncInfo( syncProfile ); | 3201 | mAddressBook->removeSyncInfo( syncProfile ); |
3202 | setModified(); | 3202 | setModified(); |
3203 | } | 3203 | } |
3204 | 3204 | ||
3205 | 3205 | ||
3206 | //this is a overwritten callbackmethods from the syncinterface | 3206 | //this is a overwritten callbackmethods from the syncinterface |
3207 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3207 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3208 | { | 3208 | { |
3209 | if ( resource == "phone" ) | 3209 | if ( resource == "phone" ) |
3210 | return syncPhone(); | 3210 | return syncPhone(); |
3211 | disableBR( true ); | 3211 | disableBR( true ); |
3212 | if ( manager != syncManager ) | 3212 | if ( manager != syncManager ) |
3213 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3213 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3214 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3214 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3215 | 3215 | ||
3216 | AddressBook abLocal( resource,"syncContact"); | 3216 | AddressBook abLocal( resource,"syncContact"); |
3217 | bool syncOK = false; | 3217 | bool syncOK = false; |
3218 | message(i18n("Loading DTM address data..."), false); | 3218 | message(i18n("Loading DTM address data..."), false); |
3219 | if ( abLocal.load() ) { | 3219 | if ( abLocal.load() ) { |
3220 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3220 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3221 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3221 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3222 | message(i18n("Sync preprocessing..."),false); | 3222 | message(i18n("Sync preprocessing..."),false); |
3223 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3223 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3224 | message(i18n("Synchronizing..."),false); | 3224 | message(i18n("Synchronizing..."),false); |
3225 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3225 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3226 | if ( syncOK ) { | 3226 | if ( syncOK ) { |
3227 | if ( syncManager->mWriteBackFile ) { | 3227 | if ( syncManager->mWriteBackFile ) { |
3228 | abLocal.removeSyncAddressees( false ); | 3228 | abLocal.removeSyncAddressees( false ); |
3229 | message(i18n("Saving DTM address data..."),false); | 3229 | message(i18n("Saving DTM address data..."),false); |
3230 | abLocal.saveAB(); | 3230 | abLocal.saveAB(); |
3231 | message(i18n("Sync postprocessing..."),false); | 3231 | message(i18n("Sync postprocessing..."),false); |
3232 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3232 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3233 | } | 3233 | } |
3234 | } else | 3234 | } else |
3235 | message( i18n("Sync cancelled or failed.") ); | 3235 | message( i18n("Sync cancelled or failed.") ); |
3236 | setModified(); | 3236 | setModified(); |
3237 | } | 3237 | } |
3238 | abLocal.removeResources(); | 3238 | abLocal.removeResources(); |
3239 | if ( syncOK ) { | 3239 | if ( syncOK ) { |
3240 | mViewManager->refreshView(); | 3240 | mViewManager->refreshView(); |
3241 | message(i18n("DTM syncing finished.")); | 3241 | message(i18n("DTM syncing finished.")); |
3242 | } | 3242 | } |
3243 | disableBR( false ); | 3243 | disableBR( false ); |
3244 | return syncOK; | 3244 | return syncOK; |
3245 | 3245 | ||
3246 | } | 3246 | } |
3247 | void KABCore::message( QString m, bool startTimer) | 3247 | void KABCore::message( QString m, bool startTimer) |
3248 | { | 3248 | { |
3249 | topLevelWidget()->setCaption( m ); | 3249 | topLevelWidget()->setCaption( m ); |
3250 | qApp->processEvents(); | 3250 | qApp->processEvents(); |
3251 | if ( startTimer ) | 3251 | if ( startTimer ) |
3252 | mMessageTimer->start( 15000, true ); | 3252 | mMessageTimer->start( 15000, true ); |
3253 | else | 3253 | else |
3254 | mMessageTimer->stop(); | 3254 | mMessageTimer->stop(); |
3255 | } | 3255 | } |
3256 | bool KABCore::syncPhone() | 3256 | bool KABCore::syncPhone() |
3257 | { | 3257 | { |
3258 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3258 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3259 | QString fileName = getPhoneFile(); | 3259 | QString fileName = getPhoneFile(); |
3260 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3260 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3261 | message(i18n("Phone access failed!")); | 3261 | message(i18n("Phone access failed!")); |
3262 | return false; | 3262 | return false; |
3263 | } | 3263 | } |
3264 | AddressBook abLocal( fileName,"syncContact"); | 3264 | AddressBook abLocal( fileName,"syncContact"); |
3265 | bool syncOK = false; | 3265 | bool syncOK = false; |
3266 | { | 3266 | { |
3267 | abLocal.importFromFile( fileName ); | 3267 | abLocal.importFromFile( fileName ); |
3268 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3268 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3269 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3269 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3270 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3270 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3271 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3271 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3272 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3272 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3273 | if ( syncOK ) { | 3273 | if ( syncOK ) { |
3274 | if ( syncManager->mWriteBackFile ) { | 3274 | if ( syncManager->mWriteBackFile ) { |
3275 | abLocal.removeSyncAddressees( true ); | 3275 | abLocal.removeSyncAddressees( true ); |
3276 | abLocal.saveABphone( fileName ); | 3276 | abLocal.saveABphone( fileName ); |
3277 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3277 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3278 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3278 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3279 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3279 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3280 | } | 3280 | } |
3281 | } | 3281 | } |
3282 | setModified(); | 3282 | setModified(); |
3283 | } | 3283 | } |
3284 | abLocal.removeResources(); | 3284 | abLocal.removeResources(); |
3285 | if ( syncOK ) | 3285 | if ( syncOK ) |
3286 | mViewManager->refreshView(); | 3286 | mViewManager->refreshView(); |
3287 | return syncOK; | 3287 | return syncOK; |
3288 | } | 3288 | } |
3289 | void KABCore::getFile( bool success ) | 3289 | void KABCore::getFile( bool success ) |
3290 | { | 3290 | { |
3291 | if ( ! success ) { | 3291 | if ( ! success ) { |
3292 | message( i18n("Error receiving file. Nothing changed!") ); | 3292 | message( i18n("Error receiving file. Nothing changed!") ); |
3293 | return; | 3293 | return; |
3294 | } | 3294 | } |
3295 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3295 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
3296 | if ( count ) | 3296 | if ( count ) |
3297 | setModified( true ); | 3297 | setModified( true ); |
3298 | message( i18n("Pi-Sync successful!") ); | 3298 | message( i18n("Pi-Sync successful!") ); |
3299 | mViewManager->refreshView(); | 3299 | mViewManager->refreshView(); |
3300 | } | 3300 | } |
3301 | void KABCore::syncFileRequest() | 3301 | void KABCore::syncFileRequest() |
3302 | { | 3302 | { |
3303 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3303 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3304 | syncManager->slotSyncMenu( 999 ); | 3304 | syncManager->slotSyncMenu( 999 ); |
3305 | } | 3305 | } |
3306 | mAddressBook->export2File( sentSyncFile() ); | 3306 | mAddressBook->export2File( sentSyncFile() ); |
3307 | } | 3307 | } |
3308 | QString KABCore::sentSyncFile() | 3308 | QString KABCore::sentSyncFile() |
3309 | { | 3309 | { |
3310 | #ifdef DESKTOP_VERSION | 3310 | #ifdef DESKTOP_VERSION |
3311 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3311 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3312 | #else | 3312 | #else |
3313 | return QString( "/tmp/copysyncab.vcf" ); | 3313 | return QString( "/tmp/copysyncab.vcf" ); |
3314 | #endif | 3314 | #endif |
3315 | } | 3315 | } |
3316 | 3316 | ||
3317 | void KABCore::setCaptionBack() | 3317 | void KABCore::setCaptionBack() |
3318 | { | 3318 | { |
3319 | mMessageTimer->stop(); | 3319 | mMessageTimer->stop(); |
3320 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 3320 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
3321 | } | 3321 | } |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 038da54..06454c2 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3905 +1,3906 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "statusdialog.h" | 110 | #include "statusdialog.h" |
111 | #include "kdatenavigator.h" | 111 | #include "kdatenavigator.h" |
112 | #include "kotodoview.h" | 112 | #include "kotodoview.h" |
113 | #include "datenavigator.h" | 113 | #include "datenavigator.h" |
114 | #include "resourceview.h" | 114 | #include "resourceview.h" |
115 | #include "navigatorbar.h" | 115 | #include "navigatorbar.h" |
116 | #include "searchdialog.h" | 116 | #include "searchdialog.h" |
117 | #include "mainwindow.h" | 117 | #include "mainwindow.h" |
118 | 118 | ||
119 | #include "calendarview.h" | 119 | #include "calendarview.h" |
120 | #ifndef DESKTOP_VERSION | 120 | #ifndef DESKTOP_VERSION |
121 | #include <qtopia/alarmserver.h> | 121 | #include <qtopia/alarmserver.h> |
122 | #endif | 122 | #endif |
123 | #ifndef _WIN32_ | 123 | #ifndef _WIN32_ |
124 | #include <stdlib.h> | 124 | #include <stdlib.h> |
125 | #include <stdio.h> | 125 | #include <stdio.h> |
126 | #include <unistd.h> | 126 | #include <unistd.h> |
127 | #else | 127 | #else |
128 | #include <qprocess.h> | 128 | #include <qprocess.h> |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | #include <kabc/stdaddressbook.h> | 132 | #include <kabc/stdaddressbook.h> |
133 | #endif | 133 | #endif |
134 | using namespace KOrg; | 134 | using namespace KOrg; |
135 | using namespace KCal; | 135 | using namespace KCal; |
136 | extern int globalFlagBlockAgenda; | 136 | extern int globalFlagBlockAgenda; |
137 | extern int globalFlagBlockStartup; | 137 | extern int globalFlagBlockStartup; |
138 | 138 | ||
139 | 139 | ||
140 | 140 | ||
141 | class KOBeamPrefs : public QDialog | 141 | class KOBeamPrefs : public QDialog |
142 | { | 142 | { |
143 | public: | 143 | public: |
144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
145 | QDialog( parent, name, true ) | 145 | QDialog( parent, name, true ) |
146 | { | 146 | { |
147 | setCaption( i18n("Beam Options") ); | 147 | setCaption( i18n("Beam Options") ); |
148 | QVBoxLayout* lay = new QVBoxLayout( this ); | 148 | QVBoxLayout* lay = new QVBoxLayout( this ); |
149 | lay->setSpacing( 3 ); | 149 | lay->setSpacing( 3 ); |
150 | lay->setMargin( 3 ); | 150 | lay->setMargin( 3 ); |
151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
152 | lay->addWidget( format ); | 152 | lay->addWidget( format ); |
153 | format->setExclusive ( true ) ; | 153 | format->setExclusive ( true ) ; |
154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
155 | lay->addWidget( time ); time->setExclusive ( true ) ; | 155 | lay->addWidget( time ); time->setExclusive ( true ) ; |
156 | vcal = new QRadioButton(" vCalendar ", format ); | 156 | vcal = new QRadioButton(" vCalendar ", format ); |
157 | ical = new QRadioButton(" iCalendar ", format ); | 157 | ical = new QRadioButton(" iCalendar ", format ); |
158 | vcal->setChecked( true ); | 158 | vcal->setChecked( true ); |
159 | tz = new QRadioButton(i18n(" With timezone "), time ); | 159 | tz = new QRadioButton(i18n(" With timezone "), time ); |
160 | local = new QRadioButton(i18n(" Local time "), time ); | 160 | local = new QRadioButton(i18n(" Local time "), time ); |
161 | tz->setChecked( true ); | 161 | tz->setChecked( true ); |
162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
163 | lay->addWidget( ok ); | 163 | lay->addWidget( ok ); |
164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
165 | lay->addWidget( cancel ); | 165 | lay->addWidget( cancel ); |
166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
168 | resize( 200, 200 ); | 168 | resize( 200, 200 ); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool beamVcal() { return vcal->isChecked(); } | 171 | bool beamVcal() { return vcal->isChecked(); } |
172 | bool beamLocal() { return local->isChecked(); } | 172 | bool beamLocal() { return local->isChecked(); } |
173 | private: | 173 | private: |
174 | QRadioButton* vcal, *ical, *local, *tz; | 174 | QRadioButton* vcal, *ical, *local, *tz; |
175 | }; | 175 | }; |
176 | class KOCatPrefs : public QDialog | 176 | class KOCatPrefs : public QDialog |
177 | { | 177 | { |
178 | public: | 178 | public: |
179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
180 | QDialog( parent, name, true ) | 180 | QDialog( parent, name, true ) |
181 | { | 181 | { |
182 | setCaption( i18n("Manage new Categories") ); | 182 | setCaption( i18n("Manage new Categories") ); |
183 | QVBoxLayout* lay = new QVBoxLayout( this ); | 183 | QVBoxLayout* lay = new QVBoxLayout( this ); |
184 | lay->setSpacing( 3 ); | 184 | lay->setSpacing( 3 ); |
185 | lay->setMargin( 3 ); | 185 | lay->setMargin( 3 ); |
186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
187 | lay->addWidget( lab ); | 187 | lay->addWidget( lab ); |
188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
189 | lay->addWidget( format ); | 189 | lay->addWidget( format ); |
190 | format->setExclusive ( true ) ; | 190 | format->setExclusive ( true ) ; |
191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
193 | addCatBut->setChecked( true ); | 193 | addCatBut->setChecked( true ); |
194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
195 | lay->addWidget( ok ); | 195 | lay->addWidget( ok ); |
196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
197 | lay->addWidget( cancel ); | 197 | lay->addWidget( cancel ); |
198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
200 | resize( 200, 200 ); | 200 | resize( 200, 200 ); |
201 | } | 201 | } |
202 | 202 | ||
203 | bool addCat() { return addCatBut->isChecked(); } | 203 | bool addCat() { return addCatBut->isChecked(); } |
204 | private: | 204 | private: |
205 | QRadioButton* addCatBut; | 205 | QRadioButton* addCatBut; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | CalendarView::CalendarView( CalendarResources *calendar, | 210 | CalendarView::CalendarView( CalendarResources *calendar, |
211 | QWidget *parent, const char *name ) | 211 | QWidget *parent, const char *name ) |
212 | : CalendarViewBase( parent, name ), | 212 | : CalendarViewBase( parent, name ), |
213 | mCalendar( calendar ), | 213 | mCalendar( calendar ), |
214 | mResourceManager( calendar->resourceManager() ) | 214 | mResourceManager( calendar->resourceManager() ) |
215 | { | 215 | { |
216 | 216 | ||
217 | mEventEditor = 0; | 217 | mEventEditor = 0; |
218 | mTodoEditor = 0; | 218 | mTodoEditor = 0; |
219 | 219 | ||
220 | init(); | 220 | init(); |
221 | } | 221 | } |
222 | 222 | ||
223 | CalendarView::CalendarView( Calendar *calendar, | 223 | CalendarView::CalendarView( Calendar *calendar, |
224 | QWidget *parent, const char *name ) | 224 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 225 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 226 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 227 | mResourceManager( 0 ) |
228 | { | 228 | { |
229 | 229 | ||
230 | mEventEditor = 0; | 230 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 231 | mTodoEditor = 0; |
232 | init();} | 232 | init();} |
233 | 233 | ||
234 | void CalendarView::init() | 234 | void CalendarView::init() |
235 | { | 235 | { |
236 | mBlockShowDates = false; | 236 | mBlockShowDates = false; |
237 | beamDialog = new KOBeamPrefs(); | 237 | beamDialog = new KOBeamPrefs(); |
238 | mDatePickerMode = 0; | 238 | mDatePickerMode = 0; |
239 | mCurrentSyncDevice = ""; | 239 | mCurrentSyncDevice = ""; |
240 | writeLocale(); | 240 | writeLocale(); |
241 | mViewManager = new KOViewManager( this ); | 241 | mViewManager = new KOViewManager( this ); |
242 | mDialogManager = new KODialogManager( this ); | 242 | mDialogManager = new KODialogManager( this ); |
243 | mEventViewerDialog = 0; | 243 | mEventViewerDialog = 0; |
244 | mModified = false; | 244 | mModified = false; |
245 | mReadOnly = false; | 245 | mReadOnly = false; |
246 | mSelectedIncidence = 0; | 246 | mSelectedIncidence = 0; |
247 | mCalPrinter = 0; | 247 | mCalPrinter = 0; |
248 | mFilters.setAutoDelete(true); | 248 | mFilters.setAutoDelete(true); |
249 | 249 | ||
250 | mCalendar->registerObserver( this ); | 250 | mCalendar->registerObserver( this ); |
251 | // TODO: Make sure that view is updated, when calendar is changed. | 251 | // TODO: Make sure that view is updated, when calendar is changed. |
252 | 252 | ||
253 | mStorage = new FileStorage( mCalendar ); | 253 | mStorage = new FileStorage( mCalendar ); |
254 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 254 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
255 | 255 | ||
256 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 256 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
257 | #ifndef KORG_NOSPLITTER | 257 | #ifndef KORG_NOSPLITTER |
258 | // create the main layout frames. | 258 | // create the main layout frames. |
259 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 259 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
260 | topLayout->addWidget(mPanner); | 260 | topLayout->addWidget(mPanner); |
261 | 261 | ||
262 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 262 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
263 | "CalendarView::LeftFrame"); | 263 | "CalendarView::LeftFrame"); |
264 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 264 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
265 | 265 | ||
266 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 266 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
267 | "CalendarView::DateNavigator", QDate::currentDate() ); | 267 | "CalendarView::DateNavigator", QDate::currentDate() ); |
268 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 268 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
269 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 269 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
270 | mTodoList->setNavigator( mNavigator ); | 270 | mTodoList->setNavigator( mNavigator ); |
271 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 271 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
272 | 272 | ||
273 | #ifdef KORG_NORESOURCEVIEW | 273 | #ifdef KORG_NORESOURCEVIEW |
274 | mResourceView = 0; | 274 | mResourceView = 0; |
275 | #else | 275 | #else |
276 | if ( mResourceManager ) { | 276 | if ( mResourceManager ) { |
277 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 277 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
278 | mResourceView->updateView(); | 278 | mResourceView->updateView(); |
279 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 279 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
280 | SLOT( updateView() ) ); | 280 | SLOT( updateView() ) ); |
281 | } else { | 281 | } else { |
282 | mResourceView = 0; | 282 | mResourceView = 0; |
283 | } | 283 | } |
284 | #endif | 284 | #endif |
285 | QWidget *rightBox = new QWidget( mPanner ); | 285 | QWidget *rightBox = new QWidget( mPanner ); |
286 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 286 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
287 | 287 | ||
288 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 288 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
289 | rightLayout->addWidget( mNavigatorBar ); | 289 | rightLayout->addWidget( mNavigatorBar ); |
290 | 290 | ||
291 | mRightFrame = new QWidgetStack( rightBox ); | 291 | mRightFrame = new QWidgetStack( rightBox ); |
292 | rightLayout->addWidget( mRightFrame, 1 ); | 292 | rightLayout->addWidget( mRightFrame, 1 ); |
293 | 293 | ||
294 | mLeftFrame = mLeftSplitter; | 294 | mLeftFrame = mLeftSplitter; |
295 | #else | 295 | #else |
296 | QWidget *mainBox = new QWidget( this ); | 296 | QWidget *mainBox = new QWidget( this ); |
297 | QWidget *leftFrame = new QWidget( mainBox ); | 297 | QWidget *leftFrame = new QWidget( mainBox ); |
298 | 298 | ||
299 | QBoxLayout * mainBoxLayout; | 299 | QBoxLayout * mainBoxLayout; |
300 | QBoxLayout * leftFrameLayout; | 300 | QBoxLayout * leftFrameLayout; |
301 | if ( KOPrefs::instance()->mVerticalScreen ) { | 301 | if ( KOPrefs::instance()->mVerticalScreen ) { |
302 | mainBoxLayout = new QVBoxLayout(mainBox); | 302 | mainBoxLayout = new QVBoxLayout(mainBox); |
303 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 303 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
304 | } else { | 304 | } else { |
305 | mainBoxLayout = new QHBoxLayout(mainBox); | 305 | mainBoxLayout = new QHBoxLayout(mainBox); |
306 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 306 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
307 | } | 307 | } |
308 | topLayout->addWidget( mainBox ); | 308 | topLayout->addWidget( mainBox ); |
309 | mainBoxLayout->addWidget (leftFrame); | 309 | mainBoxLayout->addWidget (leftFrame); |
310 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 310 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
311 | "CalendarView::DateNavigator", QDate::currentDate()); | 311 | "CalendarView::DateNavigator", QDate::currentDate()); |
312 | // mDateNavigator->blockSignals( true ); | 312 | // mDateNavigator->blockSignals( true ); |
313 | leftFrameLayout->addWidget( mDateNavigator ); | 313 | leftFrameLayout->addWidget( mDateNavigator ); |
314 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 314 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
315 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 315 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
316 | mTodoList->setNavigator( mNavigator ); | 316 | mTodoList->setNavigator( mNavigator ); |
317 | 317 | ||
318 | if ( QApplication::desktop()->width() < 480 ) { | 318 | if ( QApplication::desktop()->width() < 480 ) { |
319 | leftFrameLayout->addWidget(mFilterView); | 319 | leftFrameLayout->addWidget(mFilterView); |
320 | leftFrameLayout->addWidget(mTodoList, 2 ); | 320 | leftFrameLayout->addWidget(mTodoList, 2 ); |
321 | 321 | ||
322 | } else { | 322 | } else { |
323 | leftFrameLayout->addWidget(mTodoList,2 ); | 323 | leftFrameLayout->addWidget(mTodoList,2 ); |
324 | leftFrameLayout->addWidget(mFilterView ); | 324 | leftFrameLayout->addWidget(mFilterView ); |
325 | } | 325 | } |
326 | mFilterView->hide(); | 326 | mFilterView->hide(); |
327 | QWidget *rightBox = new QWidget( mainBox ); | 327 | QWidget *rightBox = new QWidget( mainBox ); |
328 | mainBoxLayout->addWidget ( rightBox, 10 ); | 328 | mainBoxLayout->addWidget ( rightBox, 10 ); |
329 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 329 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
330 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 330 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
331 | mRightFrame = new QWidgetStack( rightBox ); | 331 | mRightFrame = new QWidgetStack( rightBox ); |
332 | rightLayout->addWidget( mNavigatorBar ); | 332 | rightLayout->addWidget( mNavigatorBar ); |
333 | rightLayout->addWidget( mRightFrame, 10 ); | 333 | rightLayout->addWidget( mRightFrame, 10 ); |
334 | 334 | ||
335 | mLeftFrame = leftFrame; | 335 | mLeftFrame = leftFrame; |
336 | if ( KOPrefs::instance()->mVerticalScreen ) { | 336 | if ( KOPrefs::instance()->mVerticalScreen ) { |
337 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 337 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
338 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 338 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
339 | } else { | 339 | } else { |
340 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 340 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
341 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 341 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
342 | } | 342 | } |
343 | if ( !KOPrefs::instance()->mShowDateNavigator) | 343 | if ( !KOPrefs::instance()->mShowDateNavigator) |
344 | mDateNavigator->hide(); | 344 | mDateNavigator->hide(); |
345 | //qDebug("Calendarview Size %d %d ", width(), height()); | 345 | //qDebug("Calendarview Size %d %d ", width(), height()); |
346 | #endif | 346 | #endif |
347 | 347 | ||
348 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 348 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
349 | SLOT( showDates( const KCal::DateList & ) ) ); | 349 | SLOT( showDates( const KCal::DateList & ) ) ); |
350 | 350 | ||
351 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 351 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
352 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 352 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
353 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 353 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
354 | mNavigator, SLOT( selectPreviousYear() ) ); | 354 | mNavigator, SLOT( selectPreviousYear() ) ); |
355 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 355 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
356 | mNavigator, SLOT( selectNextYear() ) ); | 356 | mNavigator, SLOT( selectNextYear() ) ); |
357 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 357 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
358 | mNavigator, SLOT( selectPreviousMonth() ) ); | 358 | mNavigator, SLOT( selectPreviousMonth() ) ); |
359 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 359 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
360 | mNavigator, SLOT( selectNextMonth() ) ); | 360 | mNavigator, SLOT( selectNextMonth() ) ); |
361 | 361 | ||
362 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 362 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
363 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 363 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
364 | 364 | ||
365 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 365 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
366 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 366 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
367 | 367 | ||
368 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 368 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
369 | mNavigator, SLOT( selectPreviousYear() ) ); | 369 | mNavigator, SLOT( selectPreviousYear() ) ); |
370 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 370 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
371 | mNavigator, SLOT( selectNextYear() ) ); | 371 | mNavigator, SLOT( selectNextYear() ) ); |
372 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 372 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
373 | mNavigator, SLOT( selectPreviousMonth() ) ); | 373 | mNavigator, SLOT( selectPreviousMonth() ) ); |
374 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 374 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
375 | mNavigator, SLOT( selectNextMonth() ) ); | 375 | mNavigator, SLOT( selectNextMonth() ) ); |
376 | 376 | ||
377 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 377 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
378 | mNavigator, SLOT( selectPrevious() ) ); | 378 | mNavigator, SLOT( selectPrevious() ) ); |
379 | connect( mDateNavigator, SIGNAL( goNext() ), | 379 | connect( mDateNavigator, SIGNAL( goNext() ), |
380 | mNavigator, SLOT( selectNext() ) ); | 380 | mNavigator, SLOT( selectNext() ) ); |
381 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 381 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
382 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 382 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
383 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 383 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
384 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 384 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
385 | 385 | ||
386 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 386 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
387 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 387 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
388 | 388 | ||
389 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 389 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
390 | SLOT( eventAdded( Event *) ) ); | 390 | SLOT( eventAdded( Event *) ) ); |
391 | 391 | ||
392 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 392 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
393 | 393 | ||
394 | connect( this, SIGNAL( configChanged() ), | 394 | connect( this, SIGNAL( configChanged() ), |
395 | mDateNavigator, SLOT( updateConfig() ) ); | 395 | mDateNavigator, SLOT( updateConfig() ) ); |
396 | 396 | ||
397 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 397 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
398 | SLOT( newTodo() ) ); | 398 | SLOT( newTodo() ) ); |
399 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 399 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
400 | SLOT( newSubTodo( Todo * ) ) ); | 400 | SLOT( newSubTodo( Todo * ) ) ); |
401 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 401 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
402 | SLOT( editTodo( Todo * ) ) ); | 402 | SLOT( editTodo( Todo * ) ) ); |
403 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 403 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
404 | SLOT( showTodo( Todo *) ) ); | 404 | SLOT( showTodo( Todo *) ) ); |
405 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 405 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
406 | SLOT( deleteTodo( Todo *) ) ); | 406 | SLOT( deleteTodo( Todo *) ) ); |
407 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 407 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
408 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 408 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
409 | SLOT( purgeCompleted() ) ); | 409 | SLOT( purgeCompleted() ) ); |
410 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 410 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
411 | SIGNAL( todoModified( Todo *, int ) ) ); | 411 | SIGNAL( todoModified( Todo *, int ) ) ); |
412 | 412 | ||
413 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 413 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
414 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 414 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
415 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 415 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
416 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 416 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
417 | 417 | ||
418 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 418 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
419 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 419 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
420 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 420 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
421 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 421 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
422 | 422 | ||
423 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 423 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
424 | this, SLOT ( todo_unsub( Todo * ) ) ); | 424 | this, SLOT ( todo_unsub( Todo * ) ) ); |
425 | 425 | ||
426 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 426 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
427 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 427 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
428 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 428 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
429 | SLOT( updateTodo( Todo *, int ) ) ); | 429 | SLOT( updateTodo( Todo *, int ) ) ); |
430 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 430 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
431 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 431 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
432 | 432 | ||
433 | 433 | ||
434 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 434 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
435 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 435 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
436 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 436 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
437 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 437 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
438 | 438 | ||
439 | 439 | ||
440 | 440 | ||
441 | 441 | ||
442 | 442 | ||
443 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 443 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
444 | SLOT(checkClipboard())); | 444 | SLOT(checkClipboard())); |
445 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 445 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
446 | SLOT( processTodoListSelection( Incidence * ) ) ); | 446 | SLOT( processTodoListSelection( Incidence * ) ) ); |
447 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 447 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
448 | 448 | ||
449 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 449 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
450 | 450 | ||
451 | mDateFrame = new QVBox(0,0,WType_Popup); | 451 | mDateFrame = new QVBox(0,0,WType_Popup); |
452 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 452 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
453 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 453 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
454 | mDateFrame->setLineWidth(3); | 454 | mDateFrame->setLineWidth(3); |
455 | mDateFrame->hide(); | 455 | mDateFrame->hide(); |
456 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 456 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
457 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 457 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
458 | 458 | ||
459 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 459 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
460 | 460 | ||
461 | mEventEditor = mDialogManager->getEventEditor(); | 461 | mEventEditor = mDialogManager->getEventEditor(); |
462 | mTodoEditor = mDialogManager->getTodoEditor(); | 462 | mTodoEditor = mDialogManager->getTodoEditor(); |
463 | 463 | ||
464 | mFlagEditDescription = false; | 464 | mFlagEditDescription = false; |
465 | 465 | ||
466 | mSuspendTimer = new QTimer( this ); | 466 | mSuspendTimer = new QTimer( this ); |
467 | mAlarmTimer = new QTimer( this ); | 467 | mAlarmTimer = new QTimer( this ); |
468 | mRecheckAlarmTimer = new QTimer( this ); | 468 | mRecheckAlarmTimer = new QTimer( this ); |
469 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 469 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
470 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 470 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
471 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 471 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
472 | mAlarmDialog = new AlarmDialog( this ); | 472 | mAlarmDialog = new AlarmDialog( this ); |
473 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 473 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
474 | mAlarmDialog->setServerNotification( false ); | 474 | mAlarmDialog->setServerNotification( false ); |
475 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 475 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
476 | 476 | ||
477 | 477 | ||
478 | #ifndef DESKTOP_VERSION | 478 | #ifndef DESKTOP_VERSION |
479 | //US listen for arriving address resultsets | 479 | //US listen for arriving address resultsets |
480 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 480 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
481 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 481 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
482 | #endif | 482 | #endif |
483 | 483 | ||
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | CalendarView::~CalendarView() | 487 | CalendarView::~CalendarView() |
488 | { | 488 | { |
489 | // kdDebug() << "~CalendarView()" << endl; | 489 | // kdDebug() << "~CalendarView()" << endl; |
490 | //qDebug("CalendarView::~CalendarView() "); | 490 | //qDebug("CalendarView::~CalendarView() "); |
491 | delete mDialogManager; | 491 | delete mDialogManager; |
492 | delete mViewManager; | 492 | delete mViewManager; |
493 | delete mStorage; | 493 | delete mStorage; |
494 | delete mDateFrame ; | 494 | delete mDateFrame ; |
495 | delete beamDialog; | 495 | delete beamDialog; |
496 | //kdDebug() << "~CalendarView() done" << endl; | 496 | //kdDebug() << "~CalendarView() done" << endl; |
497 | } | 497 | } |
498 | 498 | ||
499 | void CalendarView::showDay( QDate d ) | 499 | void CalendarView::showDay( QDate d ) |
500 | { | 500 | { |
501 | dateNavigator()->blockSignals( true ); | 501 | dateNavigator()->blockSignals( true ); |
502 | dateNavigator()->selectDate( d ); | 502 | dateNavigator()->selectDate( d ); |
503 | dateNavigator()->blockSignals( false ); | 503 | dateNavigator()->blockSignals( false ); |
504 | mViewManager->showDayView(); | 504 | mViewManager->showDayView(); |
505 | //dateNavigator()->selectDate( d ); | 505 | //dateNavigator()->selectDate( d ); |
506 | } | 506 | } |
507 | void CalendarView::timerAlarm() | 507 | void CalendarView::timerAlarm() |
508 | { | 508 | { |
509 | //qDebug("CalendarView::timerAlarm() "); | 509 | //qDebug("CalendarView::timerAlarm() "); |
510 | computeAlarm(mAlarmNotification ); | 510 | computeAlarm(mAlarmNotification ); |
511 | } | 511 | } |
512 | 512 | ||
513 | void CalendarView::suspendAlarm() | 513 | void CalendarView::suspendAlarm() |
514 | { | 514 | { |
515 | //qDebug(" CalendarView::suspendAlarm() "); | 515 | //qDebug(" CalendarView::suspendAlarm() "); |
516 | computeAlarm(mSuspendAlarmNotification ); | 516 | computeAlarm(mSuspendAlarmNotification ); |
517 | 517 | ||
518 | } | 518 | } |
519 | 519 | ||
520 | void CalendarView::startAlarm( QString mess , QString filename) | 520 | void CalendarView::startAlarm( QString mess , QString filename) |
521 | { | 521 | { |
522 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 522 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
523 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 523 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
524 | 524 | ||
525 | } | 525 | } |
526 | 526 | ||
527 | void CalendarView::checkNextTimerAlarm() | 527 | void CalendarView::checkNextTimerAlarm() |
528 | { | 528 | { |
529 | mCalendar->checkAlarmForIncidence( 0, true ); | 529 | mCalendar->checkAlarmForIncidence( 0, true ); |
530 | } | 530 | } |
531 | 531 | ||
532 | void CalendarView::computeAlarm( QString msg ) | 532 | void CalendarView::computeAlarm( QString msg ) |
533 | { | 533 | { |
534 | 534 | ||
535 | QString mess = msg; | 535 | QString mess = msg; |
536 | QString mAlarmMessage = mess.mid( 9 ); | 536 | QString mAlarmMessage = mess.mid( 9 ); |
537 | QString filename = MainWindow::resourcePath(); | 537 | QString filename = MainWindow::resourcePath(); |
538 | filename += "koalarm.wav"; | 538 | filename += "koalarm.wav"; |
539 | QString tempfilename; | 539 | QString tempfilename; |
540 | if ( mess.left( 13 ) == "suspend_alarm") { | 540 | if ( mess.left( 13 ) == "suspend_alarm") { |
541 | bool error = false; | 541 | bool error = false; |
542 | int len = mess.mid( 13 ).find("+++"); | 542 | int len = mess.mid( 13 ).find("+++"); |
543 | if ( len < 2 ) | 543 | if ( len < 2 ) |
544 | error = true; | 544 | error = true; |
545 | else { | 545 | else { |
546 | tempfilename = mess.mid( 13, len ); | 546 | tempfilename = mess.mid( 13, len ); |
547 | if ( !QFile::exists( tempfilename ) ) | 547 | if ( !QFile::exists( tempfilename ) ) |
548 | error = true; | 548 | error = true; |
549 | } | 549 | } |
550 | if ( ! error ) { | 550 | if ( ! error ) { |
551 | filename = tempfilename; | 551 | filename = tempfilename; |
552 | } | 552 | } |
553 | mAlarmMessage = mess.mid( 13+len+3 ); | 553 | mAlarmMessage = mess.mid( 13+len+3 ); |
554 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 554 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
555 | startAlarm( mAlarmMessage, filename); | 555 | startAlarm( mAlarmMessage, filename); |
556 | return; | 556 | return; |
557 | } | 557 | } |
558 | if ( mess.left( 11 ) == "timer_alarm") { | 558 | if ( mess.left( 11 ) == "timer_alarm") { |
559 | //mTimerTime = 0; | 559 | //mTimerTime = 0; |
560 | startAlarm( mess.mid( 11 ), filename ); | 560 | startAlarm( mess.mid( 11 ), filename ); |
561 | return; | 561 | return; |
562 | } | 562 | } |
563 | if ( mess.left( 10 ) == "proc_alarm") { | 563 | if ( mess.left( 10 ) == "proc_alarm") { |
564 | bool error = false; | 564 | bool error = false; |
565 | int len = mess.mid( 10 ).find("+++"); | 565 | int len = mess.mid( 10 ).find("+++"); |
566 | if ( len < 2 ) | 566 | if ( len < 2 ) |
567 | error = true; | 567 | error = true; |
568 | else { | 568 | else { |
569 | tempfilename = mess.mid( 10, len ); | 569 | tempfilename = mess.mid( 10, len ); |
570 | if ( !QFile::exists( tempfilename ) ) | 570 | if ( !QFile::exists( tempfilename ) ) |
571 | error = true; | 571 | error = true; |
572 | } | 572 | } |
573 | if ( error ) { | 573 | if ( error ) { |
574 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 574 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
575 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 575 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
576 | } else { | 576 | } else { |
577 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 577 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
578 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 578 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
579 | #ifndef _WIN32_ | 579 | #ifndef _WIN32_ |
580 | if ( vfork () == 0 ) { | 580 | if ( vfork () == 0 ) { |
581 | execl ( tempfilename.latin1(), 0 ); | 581 | execl ( tempfilename.latin1(), 0 ); |
582 | return; | 582 | return; |
583 | } | 583 | } |
584 | #else | 584 | #else |
585 | QProcess* p = new QProcess(); | 585 | QProcess* p = new QProcess(); |
586 | p->addArgument( tempfilename.latin1() ); | 586 | p->addArgument( tempfilename.latin1() ); |
587 | p->start(); | 587 | p->start(); |
588 | return; | 588 | return; |
589 | #endif | 589 | #endif |
590 | 590 | ||
591 | return; | 591 | return; |
592 | } | 592 | } |
593 | 593 | ||
594 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 594 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
595 | } | 595 | } |
596 | if ( mess.left( 11 ) == "audio_alarm") { | 596 | if ( mess.left( 11 ) == "audio_alarm") { |
597 | bool error = false; | 597 | bool error = false; |
598 | int len = mess.mid( 11 ).find("+++"); | 598 | int len = mess.mid( 11 ).find("+++"); |
599 | if ( len < 2 ) | 599 | if ( len < 2 ) |
600 | error = true; | 600 | error = true; |
601 | else { | 601 | else { |
602 | tempfilename = mess.mid( 11, len ); | 602 | tempfilename = mess.mid( 11, len ); |
603 | if ( !QFile::exists( tempfilename ) ) | 603 | if ( !QFile::exists( tempfilename ) ) |
604 | error = true; | 604 | error = true; |
605 | } | 605 | } |
606 | if ( ! error ) { | 606 | if ( ! error ) { |
607 | filename = tempfilename; | 607 | filename = tempfilename; |
608 | } | 608 | } |
609 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 609 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
610 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 610 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
611 | } | 611 | } |
612 | if ( mess.left( 9 ) == "cal_alarm") { | 612 | if ( mess.left( 9 ) == "cal_alarm") { |
613 | mAlarmMessage = mess.mid( 9 ) ; | 613 | mAlarmMessage = mess.mid( 9 ) ; |
614 | } | 614 | } |
615 | 615 | ||
616 | startAlarm( mAlarmMessage, filename ); | 616 | startAlarm( mAlarmMessage, filename ); |
617 | 617 | ||
618 | 618 | ||
619 | } | 619 | } |
620 | 620 | ||
621 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 621 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
622 | { | 622 | { |
623 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 623 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
624 | 624 | ||
625 | mSuspendAlarmNotification = noti; | 625 | mSuspendAlarmNotification = noti; |
626 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 626 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
627 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 627 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
628 | mSuspendTimer->start( ms , true ); | 628 | mSuspendTimer->start( ms , true ); |
629 | 629 | ||
630 | } | 630 | } |
631 | 631 | ||
632 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 632 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
633 | { | 633 | { |
634 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 634 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
635 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 635 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
636 | #ifndef DESKTOP_VERSION | 636 | #ifndef DESKTOP_VERSION |
637 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 637 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
638 | #endif | 638 | #endif |
639 | return; | 639 | return; |
640 | } | 640 | } |
641 | int maxSec; | 641 | int maxSec; |
642 | //maxSec = 5; //testing only | 642 | //maxSec = 5; //testing only |
643 | maxSec = 86400+3600; // one day+1hour | 643 | maxSec = 86400+3600; // one day+1hour |
644 | mAlarmNotification = noti; | 644 | mAlarmNotification = noti; |
645 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 645 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
646 | if ( sec > maxSec ) { | 646 | if ( sec > maxSec ) { |
647 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 647 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
648 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 648 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
649 | return; | 649 | return; |
650 | } else { | 650 | } else { |
651 | mRecheckAlarmTimer->stop(); | 651 | mRecheckAlarmTimer->stop(); |
652 | } | 652 | } |
653 | //qDebug("Alarm timer started with secs: %d ", sec); | 653 | //qDebug("Alarm timer started with secs: %d ", sec); |
654 | mAlarmTimer->start( sec *1000 , true ); | 654 | mAlarmTimer->start( sec *1000 , true ); |
655 | 655 | ||
656 | } | 656 | } |
657 | // called by mRecheckAlarmTimer to get next alarm | 657 | // called by mRecheckAlarmTimer to get next alarm |
658 | // we need this, because a QTimer has only a max range of 25 days | 658 | // we need this, because a QTimer has only a max range of 25 days |
659 | void CalendarView::recheckTimerAlarm() | 659 | void CalendarView::recheckTimerAlarm() |
660 | { | 660 | { |
661 | mAlarmTimer->stop(); | 661 | mAlarmTimer->stop(); |
662 | mRecheckAlarmTimer->stop(); | 662 | mRecheckAlarmTimer->stop(); |
663 | mCalendar->checkAlarmForIncidence( 0, true ); | 663 | mCalendar->checkAlarmForIncidence( 0, true ); |
664 | } | 664 | } |
665 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 665 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
666 | { | 666 | { |
667 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 667 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
668 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 668 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
669 | #ifndef DESKTOP_VERSION | 669 | #ifndef DESKTOP_VERSION |
670 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 670 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
671 | #endif | 671 | #endif |
672 | return; | 672 | return; |
673 | } | 673 | } |
674 | mAlarmTimer->stop(); | 674 | mAlarmTimer->stop(); |
675 | } | 675 | } |
676 | void CalendarView::selectWeekNum ( int num ) | 676 | void CalendarView::selectWeekNum ( int num ) |
677 | { | 677 | { |
678 | dateNavigator()->blockSignals( true ); | 678 | dateNavigator()->blockSignals( true ); |
679 | dateNavigator()->selectWeek( num ); | 679 | dateNavigator()->selectWeek( num ); |
680 | dateNavigator()->blockSignals( false ); | 680 | dateNavigator()->blockSignals( false ); |
681 | mViewManager->showWeekView(); | 681 | mViewManager->showWeekView(); |
682 | } | 682 | } |
683 | KOViewManager *CalendarView::viewManager() | 683 | KOViewManager *CalendarView::viewManager() |
684 | { | 684 | { |
685 | return mViewManager; | 685 | return mViewManager; |
686 | } | 686 | } |
687 | 687 | ||
688 | KODialogManager *CalendarView::dialogManager() | 688 | KODialogManager *CalendarView::dialogManager() |
689 | { | 689 | { |
690 | return mDialogManager; | 690 | return mDialogManager; |
691 | } | 691 | } |
692 | 692 | ||
693 | QDate CalendarView::startDate() | 693 | QDate CalendarView::startDate() |
694 | { | 694 | { |
695 | DateList dates = mNavigator->selectedDates(); | 695 | DateList dates = mNavigator->selectedDates(); |
696 | 696 | ||
697 | return dates.first(); | 697 | return dates.first(); |
698 | } | 698 | } |
699 | 699 | ||
700 | QDate CalendarView::endDate() | 700 | QDate CalendarView::endDate() |
701 | { | 701 | { |
702 | DateList dates = mNavigator->selectedDates(); | 702 | DateList dates = mNavigator->selectedDates(); |
703 | 703 | ||
704 | return dates.last(); | 704 | return dates.last(); |
705 | } | 705 | } |
706 | 706 | ||
707 | 707 | ||
708 | void CalendarView::createPrinter() | 708 | void CalendarView::createPrinter() |
709 | { | 709 | { |
710 | #ifndef KORG_NOPRINTER | 710 | #ifndef KORG_NOPRINTER |
711 | if (!mCalPrinter) { | 711 | if (!mCalPrinter) { |
712 | mCalPrinter = new CalPrinter(this, mCalendar); | 712 | mCalPrinter = new CalPrinter(this, mCalendar); |
713 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 713 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
714 | } | 714 | } |
715 | #endif | 715 | #endif |
716 | } | 716 | } |
717 | 717 | ||
718 | 718 | ||
719 | //KOPrefs::instance()->mWriteBackFile | 719 | //KOPrefs::instance()->mWriteBackFile |
720 | //KOPrefs::instance()->mWriteBackExistingOnly | 720 | //KOPrefs::instance()->mWriteBackExistingOnly |
721 | 721 | ||
722 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 722 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
723 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 723 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
724 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 724 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
725 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 725 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
726 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 726 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
727 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 727 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
728 | 728 | ||
729 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 729 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
730 | { | 730 | { |
731 | 731 | ||
732 | // 0 equal | 732 | // 0 equal |
733 | // 1 take local | 733 | // 1 take local |
734 | // 2 take remote | 734 | // 2 take remote |
735 | // 3 cancel | 735 | // 3 cancel |
736 | QDateTime lastSync = mLastCalendarSync; | 736 | QDateTime lastSync = mLastCalendarSync; |
737 | QDateTime localMod = local->lastModified(); | 737 | QDateTime localMod = local->lastModified(); |
738 | QDateTime remoteMod = remote->lastModified(); | 738 | QDateTime remoteMod = remote->lastModified(); |
739 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 739 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
740 | bool remCh, locCh; | 740 | bool remCh, locCh; |
741 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 741 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
742 | //if ( remCh ) | 742 | //if ( remCh ) |
743 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 743 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
744 | locCh = ( localMod > mLastCalendarSync ); | 744 | locCh = ( localMod > mLastCalendarSync ); |
745 | if ( !remCh && ! locCh ) { | 745 | if ( !remCh && ! locCh ) { |
746 | //qDebug("both not changed "); | 746 | //qDebug("both not changed "); |
747 | lastSync = localMod.addDays(1); | 747 | lastSync = localMod.addDays(1); |
748 | if ( mode <= SYNC_PREF_ASK ) | 748 | if ( mode <= SYNC_PREF_ASK ) |
749 | return 0; | 749 | return 0; |
750 | } else { | 750 | } else { |
751 | if ( locCh ) { | 751 | if ( locCh ) { |
752 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 752 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
753 | lastSync = localMod.addDays( -1 ); | 753 | lastSync = localMod.addDays( -1 ); |
754 | if ( !remCh ) | 754 | if ( !remCh ) |
755 | remoteMod = ( lastSync.addDays( -1 ) ); | 755 | remoteMod = ( lastSync.addDays( -1 ) ); |
756 | } else { | 756 | } else { |
757 | //qDebug(" not loc changed "); | 757 | //qDebug(" not loc changed "); |
758 | lastSync = localMod.addDays( 1 ); | 758 | lastSync = localMod.addDays( 1 ); |
759 | if ( remCh ) | 759 | if ( remCh ) |
760 | remoteMod =( lastSync.addDays( 1 ) ); | 760 | remoteMod =( lastSync.addDays( 1 ) ); |
761 | 761 | ||
762 | } | 762 | } |
763 | } | 763 | } |
764 | full = true; | 764 | full = true; |
765 | if ( mode < SYNC_PREF_ASK ) | 765 | if ( mode < SYNC_PREF_ASK ) |
766 | mode = SYNC_PREF_ASK; | 766 | mode = SYNC_PREF_ASK; |
767 | } else { | 767 | } else { |
768 | if ( localMod == remoteMod ) | 768 | if ( localMod == remoteMod ) |
769 | // if ( local->revision() == remote->revision() ) | 769 | // if ( local->revision() == remote->revision() ) |
770 | return 0; | 770 | return 0; |
771 | 771 | ||
772 | } | 772 | } |
773 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 773 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
774 | 774 | ||
775 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 775 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
776 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 776 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
777 | //full = true; //debug only | 777 | //full = true; //debug only |
778 | if ( full ) { | 778 | if ( full ) { |
779 | bool equ = false; | 779 | bool equ = false; |
780 | if ( local->type() == "Event" ) { | 780 | if ( local->type() == "Event" ) { |
781 | equ = (*((Event*) local) == *((Event*) remote)); | 781 | equ = (*((Event*) local) == *((Event*) remote)); |
782 | } | 782 | } |
783 | else if ( local->type() =="Todo" ) | 783 | else if ( local->type() =="Todo" ) |
784 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 784 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
785 | else if ( local->type() =="Journal" ) | 785 | else if ( local->type() =="Journal" ) |
786 | equ = (*((Journal*) local) == *((Journal*) remote)); | 786 | equ = (*((Journal*) local) == *((Journal*) remote)); |
787 | if ( equ ) { | 787 | if ( equ ) { |
788 | //qDebug("equal "); | 788 | //qDebug("equal "); |
789 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 789 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
790 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 790 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
791 | } | 791 | } |
792 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 792 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
793 | return 0; | 793 | return 0; |
794 | 794 | ||
795 | }//else //debug only | 795 | }//else //debug only |
796 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 796 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
797 | } | 797 | } |
798 | int result; | 798 | int result; |
799 | bool localIsNew; | 799 | bool localIsNew; |
800 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 800 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
801 | 801 | ||
802 | if ( full && mode < SYNC_PREF_NEWEST ) | 802 | if ( full && mode < SYNC_PREF_NEWEST ) |
803 | mode = SYNC_PREF_ASK; | 803 | mode = SYNC_PREF_ASK; |
804 | 804 | ||
805 | switch( mode ) { | 805 | switch( mode ) { |
806 | case SYNC_PREF_LOCAL: | 806 | case SYNC_PREF_LOCAL: |
807 | if ( lastSync > remoteMod ) | 807 | if ( lastSync > remoteMod ) |
808 | return 1; | 808 | return 1; |
809 | if ( lastSync > localMod ) | 809 | if ( lastSync > localMod ) |
810 | return 2; | 810 | return 2; |
811 | return 1; | 811 | return 1; |
812 | break; | 812 | break; |
813 | case SYNC_PREF_REMOTE: | 813 | case SYNC_PREF_REMOTE: |
814 | if ( lastSync > remoteMod ) | 814 | if ( lastSync > remoteMod ) |
815 | return 1; | 815 | return 1; |
816 | if ( lastSync > localMod ) | 816 | if ( lastSync > localMod ) |
817 | return 2; | 817 | return 2; |
818 | return 2; | 818 | return 2; |
819 | break; | 819 | break; |
820 | case SYNC_PREF_NEWEST: | 820 | case SYNC_PREF_NEWEST: |
821 | if ( localMod > remoteMod ) | 821 | if ( localMod > remoteMod ) |
822 | return 1; | 822 | return 1; |
823 | else | 823 | else |
824 | return 2; | 824 | return 2; |
825 | break; | 825 | break; |
826 | case SYNC_PREF_ASK: | 826 | case SYNC_PREF_ASK: |
827 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 827 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
828 | if ( lastSync > remoteMod ) | 828 | if ( lastSync > remoteMod ) |
829 | return 1; | 829 | return 1; |
830 | if ( lastSync > localMod ) | 830 | if ( lastSync > localMod ) |
831 | return 2; | 831 | return 2; |
832 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 832 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
833 | localIsNew = localMod >= remoteMod; | 833 | localIsNew = localMod >= remoteMod; |
834 | if ( localIsNew ) | 834 | if ( localIsNew ) |
835 | getEventViewerDialog()->setColorMode( 1 ); | 835 | getEventViewerDialog()->setColorMode( 1 ); |
836 | else | 836 | else |
837 | getEventViewerDialog()->setColorMode( 2 ); | 837 | getEventViewerDialog()->setColorMode( 2 ); |
838 | getEventViewerDialog()->setIncidence(local); | 838 | getEventViewerDialog()->setIncidence(local); |
839 | if ( localIsNew ) | 839 | if ( localIsNew ) |
840 | getEventViewerDialog()->setColorMode( 2 ); | 840 | getEventViewerDialog()->setColorMode( 2 ); |
841 | else | 841 | else |
842 | getEventViewerDialog()->setColorMode( 1 ); | 842 | getEventViewerDialog()->setColorMode( 1 ); |
843 | getEventViewerDialog()->addIncidence(remote); | 843 | getEventViewerDialog()->addIncidence(remote); |
844 | getEventViewerDialog()->setColorMode( 0 ); | 844 | getEventViewerDialog()->setColorMode( 0 ); |
845 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 845 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
846 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 846 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
847 | getEventViewerDialog()->showMe(); | 847 | getEventViewerDialog()->showMe(); |
848 | result = getEventViewerDialog()->executeS( localIsNew ); | 848 | result = getEventViewerDialog()->executeS( localIsNew ); |
849 | return result; | 849 | return result; |
850 | 850 | ||
851 | break; | 851 | break; |
852 | case SYNC_PREF_FORCE_LOCAL: | 852 | case SYNC_PREF_FORCE_LOCAL: |
853 | return 1; | 853 | return 1; |
854 | break; | 854 | break; |
855 | case SYNC_PREF_FORCE_REMOTE: | 855 | case SYNC_PREF_FORCE_REMOTE: |
856 | return 2; | 856 | return 2; |
857 | break; | 857 | break; |
858 | 858 | ||
859 | default: | 859 | default: |
860 | // SYNC_PREF_TAKE_BOTH not implemented | 860 | // SYNC_PREF_TAKE_BOTH not implemented |
861 | break; | 861 | break; |
862 | } | 862 | } |
863 | return 0; | 863 | return 0; |
864 | } | 864 | } |
865 | Event* CalendarView::getLastSyncEvent() | 865 | Event* CalendarView::getLastSyncEvent() |
866 | { | 866 | { |
867 | Event* lse; | 867 | Event* lse; |
868 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 868 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
869 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 869 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
870 | if (!lse) { | 870 | if (!lse) { |
871 | lse = new Event(); | 871 | lse = new Event(); |
872 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 872 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
873 | QString sum = ""; | 873 | QString sum = ""; |
874 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 874 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
875 | sum = "E: "; | 875 | sum = "E: "; |
876 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 876 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
877 | lse->setDtStart( mLastCalendarSync ); | 877 | lse->setDtStart( mLastCalendarSync ); |
878 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 878 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
879 | lse->setCategories( i18n("SyncEvent") ); | 879 | lse->setCategories( i18n("SyncEvent") ); |
880 | lse->setReadOnly( true ); | 880 | lse->setReadOnly( true ); |
881 | mCalendar->addEvent( lse ); | 881 | mCalendar->addEvent( lse ); |
882 | } | 882 | } |
883 | 883 | ||
884 | return lse; | 884 | return lse; |
885 | 885 | ||
886 | } | 886 | } |
887 | 887 | ||
888 | // we check, if the to delete event has a id for a profile | 888 | // we check, if the to delete event has a id for a profile |
889 | // if yes, we set this id in the profile to delete | 889 | // if yes, we set this id in the profile to delete |
890 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 890 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
891 | { | 891 | { |
892 | if ( lastSync.count() == 0 ) { | 892 | if ( lastSync.count() == 0 ) { |
893 | //qDebug(" lastSync.count() == 0"); | 893 | //qDebug(" lastSync.count() == 0"); |
894 | return; | 894 | return; |
895 | } | 895 | } |
896 | if ( toDelete->type() == "Journal" ) | 896 | if ( toDelete->type() == "Journal" ) |
897 | return; | 897 | return; |
898 | 898 | ||
899 | Event* eve = lastSync.first(); | 899 | Event* eve = lastSync.first(); |
900 | 900 | ||
901 | while ( eve ) { | 901 | while ( eve ) { |
902 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 902 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
903 | if ( !id.isEmpty() ) { | 903 | if ( !id.isEmpty() ) { |
904 | QString des = eve->description(); | 904 | QString des = eve->description(); |
905 | QString pref = "e"; | 905 | QString pref = "e"; |
906 | if ( toDelete->type() == "Todo" ) | 906 | if ( toDelete->type() == "Todo" ) |
907 | pref = "t"; | 907 | pref = "t"; |
908 | des += pref+ id + ","; | 908 | des += pref+ id + ","; |
909 | eve->setReadOnly( false ); | 909 | eve->setReadOnly( false ); |
910 | eve->setDescription( des ); | 910 | eve->setDescription( des ); |
911 | //qDebug("setdes %s ", des.latin1()); | 911 | //qDebug("setdes %s ", des.latin1()); |
912 | eve->setReadOnly( true ); | 912 | eve->setReadOnly( true ); |
913 | } | 913 | } |
914 | eve = lastSync.next(); | 914 | eve = lastSync.next(); |
915 | } | 915 | } |
916 | 916 | ||
917 | } | 917 | } |
918 | void CalendarView::checkExternalId( Incidence * inc ) | 918 | void CalendarView::checkExternalId( Incidence * inc ) |
919 | { | 919 | { |
920 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 920 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
921 | checkExternSyncEvent( lastSync, inc ); | 921 | checkExternSyncEvent( lastSync, inc ); |
922 | 922 | ||
923 | } | 923 | } |
924 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 924 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
925 | { | 925 | { |
926 | bool syncOK = true; | 926 | bool syncOK = true; |
927 | int addedEvent = 0; | 927 | int addedEvent = 0; |
928 | int addedEventR = 0; | 928 | int addedEventR = 0; |
929 | int deletedEventR = 0; | 929 | int deletedEventR = 0; |
930 | int deletedEventL = 0; | 930 | int deletedEventL = 0; |
931 | int changedLocal = 0; | 931 | int changedLocal = 0; |
932 | int changedRemote = 0; | 932 | int changedRemote = 0; |
933 | int filteredIN = 0; | 933 | int filteredIN = 0; |
934 | int filteredOUT = 0; | 934 | int filteredOUT = 0; |
935 | //QPtrList<Event> el = local->rawEvents(); | 935 | //QPtrList<Event> el = local->rawEvents(); |
936 | Event* eventR; | 936 | Event* eventR; |
937 | QString uid; | 937 | QString uid; |
938 | int take; | 938 | int take; |
939 | Event* eventL; | 939 | Event* eventL; |
940 | Event* eventRSync; | 940 | Event* eventRSync; |
941 | Event* eventLSync; | 941 | Event* eventLSync; |
942 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 942 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
943 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 943 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
944 | bool fullDateRange = false; | 944 | bool fullDateRange = false; |
945 | local->resetTempSyncStat(); | 945 | local->resetTempSyncStat(); |
946 | mLastCalendarSync = QDateTime::currentDateTime(); | 946 | mLastCalendarSync = QDateTime::currentDateTime(); |
947 | if ( mSyncManager->syncWithDesktop() ) { | 947 | if ( mSyncManager->syncWithDesktop() ) { |
948 | remote->resetPilotStat(1); | 948 | remote->resetPilotStat(1); |
949 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 949 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
950 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 950 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
951 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 951 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
952 | } else { | 952 | } else { |
953 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 953 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
954 | } | 954 | } |
955 | } | 955 | } |
956 | QDateTime modifiedCalendar = mLastCalendarSync; | 956 | QDateTime modifiedCalendar = mLastCalendarSync; |
957 | eventLSync = getLastSyncEvent(); | 957 | eventLSync = getLastSyncEvent(); |
958 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 958 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
959 | if ( eventR ) { | 959 | if ( eventR ) { |
960 | eventRSync = (Event*) eventR->clone(); | 960 | eventRSync = (Event*) eventR->clone(); |
961 | remote->deleteEvent(eventR ); | 961 | remote->deleteEvent(eventR ); |
962 | 962 | ||
963 | } else { | 963 | } else { |
964 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 964 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
965 | eventRSync = (Event*)eventLSync->clone(); | 965 | eventRSync = (Event*)eventLSync->clone(); |
966 | } else { | 966 | } else { |
967 | fullDateRange = true; | 967 | fullDateRange = true; |
968 | eventRSync = new Event(); | 968 | eventRSync = new Event(); |
969 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 969 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
970 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 970 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
971 | eventRSync->setDtStart( mLastCalendarSync ); | 971 | eventRSync->setDtStart( mLastCalendarSync ); |
972 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 972 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
973 | eventRSync->setCategories( i18n("SyncEvent") ); | 973 | eventRSync->setCategories( i18n("SyncEvent") ); |
974 | } | 974 | } |
975 | } | 975 | } |
976 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 976 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
977 | fullDateRange = true; | 977 | fullDateRange = true; |
978 | 978 | ||
979 | if ( ! fullDateRange ) { | 979 | if ( ! fullDateRange ) { |
980 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 980 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
981 | 981 | ||
982 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 982 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
983 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 983 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
984 | fullDateRange = true; | 984 | fullDateRange = true; |
985 | } | 985 | } |
986 | } | 986 | } |
987 | if ( mSyncManager->syncWithDesktop() ) { | 987 | if ( mSyncManager->syncWithDesktop() ) { |
988 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 988 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
989 | } | 989 | } |
990 | if ( fullDateRange ) | 990 | if ( fullDateRange ) |
991 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 991 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
992 | else | 992 | else |
993 | mLastCalendarSync = eventLSync->dtStart(); | 993 | mLastCalendarSync = eventLSync->dtStart(); |
994 | // for resyncing if own file has changed | 994 | // for resyncing if own file has changed |
995 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 995 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
996 | mLastCalendarSync = loadedFileVersion; | 996 | mLastCalendarSync = loadedFileVersion; |
997 | //qDebug("setting mLastCalendarSync "); | 997 | //qDebug("setting mLastCalendarSync "); |
998 | } | 998 | } |
999 | //qDebug("*************************** "); | 999 | //qDebug("*************************** "); |
1000 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1000 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1001 | QPtrList<Incidence> er = remote->rawIncidences(); | 1001 | QPtrList<Incidence> er = remote->rawIncidences(); |
1002 | Incidence* inR = er.first(); | 1002 | Incidence* inR = er.first(); |
1003 | Incidence* inL; | 1003 | Incidence* inL; |
1004 | QProgressBar bar( er.count(),0 ); | 1004 | QProgressBar bar( er.count(),0 ); |
1005 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1005 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1006 | 1006 | ||
1007 | // ************** setting up filter ************* | 1007 | // ************** setting up filter ************* |
1008 | CalFilter *filterIN = 0; | 1008 | CalFilter *filterIN = 0; |
1009 | CalFilter *filterOUT = 0; | 1009 | CalFilter *filterOUT = 0; |
1010 | CalFilter *filter = mFilters.first(); | 1010 | CalFilter *filter = mFilters.first(); |
1011 | while(filter) { | 1011 | while(filter) { |
1012 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1012 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1013 | filterIN = filter; | 1013 | filterIN = filter; |
1014 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1014 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1015 | filterOUT = filter; | 1015 | filterOUT = filter; |
1016 | filter = mFilters.next(); | 1016 | filter = mFilters.next(); |
1017 | } | 1017 | } |
1018 | int w = 300; | 1018 | int w = 300; |
1019 | if ( QApplication::desktop()->width() < 320 ) | 1019 | if ( QApplication::desktop()->width() < 320 ) |
1020 | w = 220; | 1020 | w = 220; |
1021 | int h = bar.sizeHint().height() ; | 1021 | int h = bar.sizeHint().height() ; |
1022 | int dw = QApplication::desktop()->width(); | 1022 | int dw = QApplication::desktop()->width(); |
1023 | int dh = QApplication::desktop()->height(); | 1023 | int dh = QApplication::desktop()->height(); |
1024 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1024 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1025 | bar.show(); | 1025 | bar.show(); |
1026 | int modulo = (er.count()/10)+1; | 1026 | int modulo = (er.count()/10)+1; |
1027 | int incCounter = 0; | 1027 | int incCounter = 0; |
1028 | while ( inR ) { | 1028 | while ( inR ) { |
1029 | if ( ! bar.isVisible() ) | 1029 | if ( ! bar.isVisible() ) |
1030 | return false; | 1030 | return false; |
1031 | if ( incCounter % modulo == 0 ) | 1031 | if ( incCounter % modulo == 0 ) |
1032 | bar.setProgress( incCounter ); | 1032 | bar.setProgress( incCounter ); |
1033 | ++incCounter; | 1033 | ++incCounter; |
1034 | uid = inR->uid(); | 1034 | uid = inR->uid(); |
1035 | bool skipIncidence = false; | 1035 | bool skipIncidence = false; |
1036 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1036 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1037 | skipIncidence = true; | 1037 | skipIncidence = true; |
1038 | QString idS; | 1038 | QString idS; |
1039 | qApp->processEvents(); | 1039 | qApp->processEvents(); |
1040 | if ( !skipIncidence ) { | 1040 | if ( !skipIncidence ) { |
1041 | inL = local->incidence( uid ); | 1041 | inL = local->incidence( uid ); |
1042 | if ( inL ) { // maybe conflict - same uid in both calendars | 1042 | if ( inL ) { // maybe conflict - same uid in both calendars |
1043 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1043 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1044 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1044 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1045 | if ( take == 3 ) | 1045 | if ( take == 3 ) |
1046 | return false; | 1046 | return false; |
1047 | if ( take == 1 ) {// take local ********************** | 1047 | if ( take == 1 ) {// take local ********************** |
1048 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1048 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1049 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1049 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1050 | else | 1050 | else |
1051 | idS = inR->IDStr(); | 1051 | idS = inR->IDStr(); |
1052 | remote->deleteIncidence( inR ); | 1052 | remote->deleteIncidence( inR ); |
1053 | inR = inL->clone(); | 1053 | inR = inL->clone(); |
1054 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1054 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1055 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1055 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1056 | inR->setIDStr( idS ); | 1056 | inR->setIDStr( idS ); |
1057 | remote->addIncidence( inR ); | 1057 | remote->addIncidence( inR ); |
1058 | if ( mSyncManager->syncWithDesktop() ) | 1058 | if ( mSyncManager->syncWithDesktop() ) |
1059 | inR->setPilotId( 2 ); | 1059 | inR->setPilotId( 2 ); |
1060 | ++changedRemote; | 1060 | ++changedRemote; |
1061 | } else {// take remote ********************** | 1061 | } else {// take remote ********************** |
1062 | idS = inL->IDStr(); | 1062 | idS = inL->IDStr(); |
1063 | int pid = inL->pilotId(); | 1063 | int pid = inL->pilotId(); |
1064 | local->deleteIncidence( inL ); | 1064 | local->deleteIncidence( inL ); |
1065 | inL = inR->clone(); | 1065 | inL = inR->clone(); |
1066 | if ( mSyncManager->syncWithDesktop() ) | 1066 | if ( mSyncManager->syncWithDesktop() ) |
1067 | inL->setPilotId( pid ); | 1067 | inL->setPilotId( pid ); |
1068 | inL->setIDStr( idS ); | 1068 | inL->setIDStr( idS ); |
1069 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1069 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1070 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1070 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1071 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1071 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1072 | } | 1072 | } |
1073 | local->addIncidence( inL ); | 1073 | local->addIncidence( inL ); |
1074 | ++changedLocal; | 1074 | ++changedLocal; |
1075 | } | 1075 | } |
1076 | } | 1076 | } |
1077 | } else { // no conflict ********** add or delete remote | 1077 | } else { // no conflict ********** add or delete remote |
1078 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1078 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1079 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1079 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1080 | QString des = eventLSync->description(); | 1080 | QString des = eventLSync->description(); |
1081 | QString pref = "e"; | 1081 | QString pref = "e"; |
1082 | if ( inR->type() == "Todo" ) | 1082 | if ( inR->type() == "Todo" ) |
1083 | pref = "t"; | 1083 | pref = "t"; |
1084 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1084 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1085 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1085 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1086 | //remote->deleteIncidence( inR ); | 1086 | //remote->deleteIncidence( inR ); |
1087 | ++deletedEventR; | 1087 | ++deletedEventR; |
1088 | } else { | 1088 | } else { |
1089 | inR->setLastModified( modifiedCalendar ); | 1089 | inR->setLastModified( modifiedCalendar ); |
1090 | inL = inR->clone(); | 1090 | inL = inR->clone(); |
1091 | inL->setIDStr( ":" ); | 1091 | inL->setIDStr( ":" ); |
1092 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1092 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1093 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1093 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1094 | local->addIncidence( inL ); | 1094 | local->addIncidence( inL ); |
1095 | ++addedEvent; | 1095 | ++addedEvent; |
1096 | 1096 | ||
1097 | } | 1097 | } |
1098 | } else { | 1098 | } else { |
1099 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1099 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1100 | inR->setLastModified( modifiedCalendar ); | 1100 | inR->setLastModified( modifiedCalendar ); |
1101 | inL = inR->clone(); | 1101 | inL = inR->clone(); |
1102 | inL->setIDStr( ":" ); | 1102 | inL->setIDStr( ":" ); |
1103 | local->addIncidence( inL ); | 1103 | local->addIncidence( inL ); |
1104 | ++addedEvent; | 1104 | ++addedEvent; |
1105 | 1105 | ||
1106 | } else { | 1106 | } else { |
1107 | checkExternSyncEvent(eventRSyncSharp, inR); | 1107 | checkExternSyncEvent(eventRSyncSharp, inR); |
1108 | remote->deleteIncidence( inR ); | 1108 | remote->deleteIncidence( inR ); |
1109 | ++deletedEventR; | 1109 | ++deletedEventR; |
1110 | } | 1110 | } |
1111 | } | 1111 | } |
1112 | } else { | 1112 | } else { |
1113 | ++filteredIN; | 1113 | ++filteredIN; |
1114 | } | 1114 | } |
1115 | } | 1115 | } |
1116 | } | 1116 | } |
1117 | inR = er.next(); | 1117 | inR = er.next(); |
1118 | } | 1118 | } |
1119 | QPtrList<Incidence> el = local->rawIncidences(); | 1119 | QPtrList<Incidence> el = local->rawIncidences(); |
1120 | inL = el.first(); | 1120 | inL = el.first(); |
1121 | modulo = (el.count()/10)+1; | 1121 | modulo = (el.count()/10)+1; |
1122 | bar.setCaption (i18n("Add / remove events") ); | 1122 | bar.setCaption (i18n("Add / remove events") ); |
1123 | bar.setTotalSteps ( el.count() ) ; | 1123 | bar.setTotalSteps ( el.count() ) ; |
1124 | bar.show(); | 1124 | bar.show(); |
1125 | incCounter = 0; | 1125 | incCounter = 0; |
1126 | 1126 | ||
1127 | while ( inL ) { | 1127 | while ( inL ) { |
1128 | 1128 | ||
1129 | qApp->processEvents(); | 1129 | qApp->processEvents(); |
1130 | if ( ! bar.isVisible() ) | 1130 | if ( ! bar.isVisible() ) |
1131 | return false; | 1131 | return false; |
1132 | if ( incCounter % modulo == 0 ) | 1132 | if ( incCounter % modulo == 0 ) |
1133 | bar.setProgress( incCounter ); | 1133 | bar.setProgress( incCounter ); |
1134 | ++incCounter; | 1134 | ++incCounter; |
1135 | uid = inL->uid(); | 1135 | uid = inL->uid(); |
1136 | bool skipIncidence = false; | 1136 | bool skipIncidence = false; |
1137 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1137 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1138 | skipIncidence = true; | 1138 | skipIncidence = true; |
1139 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1139 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1140 | skipIncidence = true; | 1140 | skipIncidence = true; |
1141 | if ( !skipIncidence ) { | 1141 | if ( !skipIncidence ) { |
1142 | inR = remote->incidence( uid ); | 1142 | inR = remote->incidence( uid ); |
1143 | if ( ! inR ) { | 1143 | if ( ! inR ) { |
1144 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1144 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1145 | // no conflict ********** add or delete local | 1145 | // no conflict ********** add or delete local |
1146 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1146 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1147 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1147 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1148 | checkExternSyncEvent(eventLSyncSharp, inL); | 1148 | checkExternSyncEvent(eventLSyncSharp, inL); |
1149 | local->deleteIncidence( inL ); | 1149 | local->deleteIncidence( inL ); |
1150 | ++deletedEventL; | 1150 | ++deletedEventL; |
1151 | } else { | 1151 | } else { |
1152 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1152 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1153 | inL->removeID(mCurrentSyncDevice ); | 1153 | inL->removeID(mCurrentSyncDevice ); |
1154 | ++addedEventR; | 1154 | ++addedEventR; |
1155 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1155 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1156 | inL->setLastModified( modifiedCalendar ); | 1156 | inL->setLastModified( modifiedCalendar ); |
1157 | inR = inL->clone(); | 1157 | inR = inL->clone(); |
1158 | inR->setIDStr( ":" ); | 1158 | inR->setIDStr( ":" ); |
1159 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1159 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1160 | remote->addIncidence( inR ); | 1160 | remote->addIncidence( inR ); |
1161 | } | 1161 | } |
1162 | } | 1162 | } |
1163 | } else { | 1163 | } else { |
1164 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1164 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1165 | checkExternSyncEvent(eventLSyncSharp, inL); | 1165 | checkExternSyncEvent(eventLSyncSharp, inL); |
1166 | local->deleteIncidence( inL ); | 1166 | local->deleteIncidence( inL ); |
1167 | ++deletedEventL; | 1167 | ++deletedEventL; |
1168 | } else { | 1168 | } else { |
1169 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1169 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1170 | ++addedEventR; | 1170 | ++addedEventR; |
1171 | inL->setLastModified( modifiedCalendar ); | 1171 | inL->setLastModified( modifiedCalendar ); |
1172 | inR = inL->clone(); | 1172 | inR = inL->clone(); |
1173 | inR->setIDStr( ":" ); | 1173 | inR->setIDStr( ":" ); |
1174 | remote->addIncidence( inR ); | 1174 | remote->addIncidence( inR ); |
1175 | } | 1175 | } |
1176 | } | 1176 | } |
1177 | } | 1177 | } |
1178 | } else { | 1178 | } else { |
1179 | ++filteredOUT; | 1179 | ++filteredOUT; |
1180 | } | 1180 | } |
1181 | } | 1181 | } |
1182 | } | 1182 | } |
1183 | inL = el.next(); | 1183 | inL = el.next(); |
1184 | } | 1184 | } |
1185 | int delFut = 0; | 1185 | int delFut = 0; |
1186 | int remRem = 0; | 1186 | int remRem = 0; |
1187 | if ( mSyncManager->mWriteBackInFuture ) { | 1187 | if ( mSyncManager->mWriteBackInFuture ) { |
1188 | er = remote->rawIncidences(); | 1188 | er = remote->rawIncidences(); |
1189 | remRem = er.count(); | 1189 | remRem = er.count(); |
1190 | inR = er.first(); | 1190 | inR = er.first(); |
1191 | QDateTime dt; | 1191 | QDateTime dt; |
1192 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1192 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1193 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1193 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1194 | while ( inR ) { | 1194 | while ( inR ) { |
1195 | if ( inR->type() == "Todo" ) { | 1195 | if ( inR->type() == "Todo" ) { |
1196 | Todo * t = (Todo*)inR; | 1196 | Todo * t = (Todo*)inR; |
1197 | if ( t->hasDueDate() ) | 1197 | if ( t->hasDueDate() ) |
1198 | dt = t->dtDue(); | 1198 | dt = t->dtDue(); |
1199 | else | 1199 | else |
1200 | dt = cur.addSecs( 62 ); | 1200 | dt = cur.addSecs( 62 ); |
1201 | } | 1201 | } |
1202 | else if (inR->type() == "Event" ) { | 1202 | else if (inR->type() == "Event" ) { |
1203 | bool ok; | 1203 | bool ok; |
1204 | dt = inR->getNextOccurence( cur, &ok ); | 1204 | dt = inR->getNextOccurence( cur, &ok ); |
1205 | if ( !ok ) | 1205 | if ( !ok ) |
1206 | dt = cur.addSecs( -62 ); | 1206 | dt = cur.addSecs( -62 ); |
1207 | } | 1207 | } |
1208 | else | 1208 | else |
1209 | dt = inR->dtStart(); | 1209 | dt = inR->dtStart(); |
1210 | if ( dt < cur || dt > end ) { | 1210 | if ( dt < cur || dt > end ) { |
1211 | remote->deleteIncidence( inR ); | 1211 | remote->deleteIncidence( inR ); |
1212 | ++delFut; | 1212 | ++delFut; |
1213 | } | 1213 | } |
1214 | inR = er.next(); | 1214 | inR = er.next(); |
1215 | } | 1215 | } |
1216 | } | 1216 | } |
1217 | bar.hide(); | 1217 | bar.hide(); |
1218 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1218 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1219 | eventLSync->setReadOnly( false ); | 1219 | eventLSync->setReadOnly( false ); |
1220 | eventLSync->setDtStart( mLastCalendarSync ); | 1220 | eventLSync->setDtStart( mLastCalendarSync ); |
1221 | eventRSync->setDtStart( mLastCalendarSync ); | 1221 | eventRSync->setDtStart( mLastCalendarSync ); |
1222 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1222 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1223 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1223 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1224 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1224 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1225 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1225 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1226 | eventLSync->setReadOnly( true ); | 1226 | eventLSync->setReadOnly( true ); |
1227 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); | 1227 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1228 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1228 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1229 | remote->addEvent( eventRSync ); | 1229 | remote->addEvent( eventRSync ); |
1230 | else | 1230 | else |
1231 | delete eventRSync; | 1231 | delete eventRSync; |
1232 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | ||
1232 | QString mes; | 1233 | QString mes; |
1233 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1234 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1234 | QString delmess; | 1235 | QString delmess; |
1235 | if ( delFut ) { | 1236 | if ( delFut ) { |
1236 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1237 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1237 | mes += delmess; | 1238 | mes += delmess; |
1238 | } | 1239 | } |
1239 | mes = i18n("Local calendar changed!\n") +mes; | 1240 | mes = i18n("Local calendar changed!\n") +mes; |
1240 | mCalendar->checkAlarmForIncidence( 0, true ); | 1241 | mCalendar->checkAlarmForIncidence( 0, true ); |
1241 | qDebug( mes ); | 1242 | qDebug( mes ); |
1242 | if ( mSyncManager->mShowSyncSummary ) { | 1243 | if ( mSyncManager->mShowSyncSummary ) { |
1243 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1244 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1244 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1245 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1245 | qDebug("cancelled "); | 1246 | qDebug("KO: WB cancelled "); |
1246 | return false; | 1247 | return false; |
1247 | } | 1248 | } |
1248 | } | 1249 | } |
1249 | return syncOK; | 1250 | return syncOK; |
1250 | } | 1251 | } |
1251 | 1252 | ||
1252 | void CalendarView::setSyncDevice( QString s ) | 1253 | void CalendarView::setSyncDevice( QString s ) |
1253 | { | 1254 | { |
1254 | mCurrentSyncDevice= s; | 1255 | mCurrentSyncDevice= s; |
1255 | } | 1256 | } |
1256 | void CalendarView::setSyncName( QString s ) | 1257 | void CalendarView::setSyncName( QString s ) |
1257 | { | 1258 | { |
1258 | mCurrentSyncName= s; | 1259 | mCurrentSyncName= s; |
1259 | } | 1260 | } |
1260 | bool CalendarView::syncCalendar(QString filename, int mode) | 1261 | bool CalendarView::syncCalendar(QString filename, int mode) |
1261 | { | 1262 | { |
1262 | //qDebug("syncCalendar %s ", filename.latin1()); | 1263 | //qDebug("syncCalendar %s ", filename.latin1()); |
1263 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1264 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1264 | CalendarLocal* calendar = new CalendarLocal(); | 1265 | CalendarLocal* calendar = new CalendarLocal(); |
1265 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1266 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1266 | FileStorage* storage = new FileStorage( calendar ); | 1267 | FileStorage* storage = new FileStorage( calendar ); |
1267 | bool syncOK = false; | 1268 | bool syncOK = false; |
1268 | storage->setFileName( filename ); | 1269 | storage->setFileName( filename ); |
1269 | // qDebug("loading ... "); | 1270 | // qDebug("loading ... "); |
1270 | if ( storage->load() ) { | 1271 | if ( storage->load() ) { |
1271 | getEventViewerDialog()->setSyncMode( true ); | 1272 | getEventViewerDialog()->setSyncMode( true ); |
1272 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1273 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1273 | getEventViewerDialog()->setSyncMode( false ); | 1274 | getEventViewerDialog()->setSyncMode( false ); |
1274 | if ( syncOK ) { | 1275 | if ( syncOK ) { |
1275 | if ( mSyncManager->mWriteBackFile ) | 1276 | if ( mSyncManager->mWriteBackFile ) |
1276 | { | 1277 | { |
1277 | storage->setSaveFormat( new ICalFormat() ); | 1278 | storage->setSaveFormat( new ICalFormat() ); |
1278 | storage->save(); | 1279 | storage->save(); |
1279 | } | 1280 | } |
1280 | } | 1281 | } |
1281 | setModified( true ); | 1282 | setModified( true ); |
1282 | } | 1283 | } |
1283 | delete storage; | 1284 | delete storage; |
1284 | delete calendar; | 1285 | delete calendar; |
1285 | if ( syncOK ) | 1286 | if ( syncOK ) |
1286 | updateView(); | 1287 | updateView(); |
1287 | return syncOK; | 1288 | return syncOK; |
1288 | } | 1289 | } |
1289 | 1290 | ||
1290 | void CalendarView::syncExternal( int mode ) | 1291 | void CalendarView::syncExternal( int mode ) |
1291 | { | 1292 | { |
1292 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1293 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1293 | 1294 | ||
1294 | qApp->processEvents(); | 1295 | qApp->processEvents(); |
1295 | CalendarLocal* calendar = new CalendarLocal(); | 1296 | CalendarLocal* calendar = new CalendarLocal(); |
1296 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1297 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1297 | bool syncOK = false; | 1298 | bool syncOK = false; |
1298 | bool loadSuccess = false; | 1299 | bool loadSuccess = false; |
1299 | PhoneFormat* phoneFormat = 0; | 1300 | PhoneFormat* phoneFormat = 0; |
1300 | emit tempDisableBR(true); | 1301 | emit tempDisableBR(true); |
1301 | #ifndef DESKTOP_VERSION | 1302 | #ifndef DESKTOP_VERSION |
1302 | SharpFormat* sharpFormat = 0; | 1303 | SharpFormat* sharpFormat = 0; |
1303 | if ( mode == 0 ) { // sharp | 1304 | if ( mode == 0 ) { // sharp |
1304 | sharpFormat = new SharpFormat () ; | 1305 | sharpFormat = new SharpFormat () ; |
1305 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1306 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1306 | 1307 | ||
1307 | } else | 1308 | } else |
1308 | #endif | 1309 | #endif |
1309 | if ( mode == 1 ) { // phone | 1310 | if ( mode == 1 ) { // phone |
1310 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1311 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1311 | mSyncManager->mPhoneDevice, | 1312 | mSyncManager->mPhoneDevice, |
1312 | mSyncManager->mPhoneConnection, | 1313 | mSyncManager->mPhoneConnection, |
1313 | mSyncManager->mPhoneModel); | 1314 | mSyncManager->mPhoneModel); |
1314 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1315 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1315 | 1316 | ||
1316 | } else { | 1317 | } else { |
1317 | emit tempDisableBR(false); | 1318 | emit tempDisableBR(false); |
1318 | return; | 1319 | return; |
1319 | } | 1320 | } |
1320 | if ( loadSuccess ) { | 1321 | if ( loadSuccess ) { |
1321 | getEventViewerDialog()->setSyncMode( true ); | 1322 | getEventViewerDialog()->setSyncMode( true ); |
1322 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1323 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1323 | getEventViewerDialog()->setSyncMode( false ); | 1324 | getEventViewerDialog()->setSyncMode( false ); |
1324 | qApp->processEvents(); | 1325 | qApp->processEvents(); |
1325 | if ( syncOK ) { | 1326 | if ( syncOK ) { |
1326 | if ( mSyncManager->mWriteBackFile ) | 1327 | if ( mSyncManager->mWriteBackFile ) |
1327 | { | 1328 | { |
1328 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1329 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1329 | Incidence* inc = iL.first(); | 1330 | Incidence* inc = iL.first(); |
1330 | if ( phoneFormat ) { | 1331 | if ( phoneFormat ) { |
1331 | while ( inc ) { | 1332 | while ( inc ) { |
1332 | inc->removeID(mCurrentSyncDevice); | 1333 | inc->removeID(mCurrentSyncDevice); |
1333 | inc = iL.next(); | 1334 | inc = iL.next(); |
1334 | } | 1335 | } |
1335 | } | 1336 | } |
1336 | #ifndef DESKTOP_VERSION | 1337 | #ifndef DESKTOP_VERSION |
1337 | if ( sharpFormat ) | 1338 | if ( sharpFormat ) |
1338 | sharpFormat->save(calendar); | 1339 | sharpFormat->save(calendar); |
1339 | #endif | 1340 | #endif |
1340 | if ( phoneFormat ) | 1341 | if ( phoneFormat ) |
1341 | phoneFormat->save(calendar); | 1342 | phoneFormat->save(calendar); |
1342 | iL = calendar->rawIncidences(); | 1343 | iL = calendar->rawIncidences(); |
1343 | inc = iL.first(); | 1344 | inc = iL.first(); |
1344 | Incidence* loc; | 1345 | Incidence* loc; |
1345 | while ( inc ) { | 1346 | while ( inc ) { |
1346 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1347 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1347 | loc = mCalendar->incidence(inc->uid() ); | 1348 | loc = mCalendar->incidence(inc->uid() ); |
1348 | if ( loc ) { | 1349 | if ( loc ) { |
1349 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1350 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1350 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1351 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1351 | } | 1352 | } |
1352 | } | 1353 | } |
1353 | inc = iL.next(); | 1354 | inc = iL.next(); |
1354 | } | 1355 | } |
1355 | Incidence* lse = getLastSyncEvent(); | 1356 | Incidence* lse = getLastSyncEvent(); |
1356 | if ( lse ) { | 1357 | if ( lse ) { |
1357 | lse->setReadOnly( false ); | 1358 | lse->setReadOnly( false ); |
1358 | lse->setDescription( "" ); | 1359 | lse->setDescription( "" ); |
1359 | lse->setReadOnly( true ); | 1360 | lse->setReadOnly( true ); |
1360 | } | 1361 | } |
1361 | } | 1362 | } |
1362 | } else { | 1363 | } else { |
1363 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1364 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1364 | } | 1365 | } |
1365 | setModified( true ); | 1366 | setModified( true ); |
1366 | } else { | 1367 | } else { |
1367 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1368 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1368 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1369 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1369 | question, i18n("Ok")) ; | 1370 | question, i18n("Ok")) ; |
1370 | 1371 | ||
1371 | } | 1372 | } |
1372 | delete calendar; | 1373 | delete calendar; |
1373 | updateView(); | 1374 | updateView(); |
1374 | emit tempDisableBR(false); | 1375 | emit tempDisableBR(false); |
1375 | return ;//syncOK; | 1376 | return ;//syncOK; |
1376 | 1377 | ||
1377 | } | 1378 | } |
1378 | 1379 | ||
1379 | bool CalendarView::importBday() | 1380 | bool CalendarView::importBday() |
1380 | { | 1381 | { |
1381 | #ifndef KORG_NOKABC | 1382 | #ifndef KORG_NOKABC |
1382 | 1383 | ||
1383 | #ifdef DESKTOP_VERSION | 1384 | #ifdef DESKTOP_VERSION |
1384 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1385 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1385 | KABC::AddressBook::Iterator it; | 1386 | KABC::AddressBook::Iterator it; |
1386 | int count = 0; | 1387 | int count = 0; |
1387 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1388 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1388 | ++count; | 1389 | ++count; |
1389 | } | 1390 | } |
1390 | QProgressBar bar(count,0 ); | 1391 | QProgressBar bar(count,0 ); |
1391 | int w = 300; | 1392 | int w = 300; |
1392 | if ( QApplication::desktop()->width() < 320 ) | 1393 | if ( QApplication::desktop()->width() < 320 ) |
1393 | w = 220; | 1394 | w = 220; |
1394 | int h = bar.sizeHint().height() ; | 1395 | int h = bar.sizeHint().height() ; |
1395 | int dw = QApplication::desktop()->width(); | 1396 | int dw = QApplication::desktop()->width(); |
1396 | int dh = QApplication::desktop()->height(); | 1397 | int dh = QApplication::desktop()->height(); |
1397 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1398 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1398 | bar.show(); | 1399 | bar.show(); |
1399 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1400 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1400 | qApp->processEvents(); | 1401 | qApp->processEvents(); |
1401 | count = 0; | 1402 | count = 0; |
1402 | int addCount = 0; | 1403 | int addCount = 0; |
1403 | KCal::Attendee* a = 0; | 1404 | KCal::Attendee* a = 0; |
1404 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1405 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1405 | if ( ! bar.isVisible() ) | 1406 | if ( ! bar.isVisible() ) |
1406 | return false; | 1407 | return false; |
1407 | bar.setProgress( count++ ); | 1408 | bar.setProgress( count++ ); |
1408 | qApp->processEvents(); | 1409 | qApp->processEvents(); |
1409 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1410 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1410 | if ( (*it).birthday().date().isValid() ){ | 1411 | if ( (*it).birthday().date().isValid() ){ |
1411 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1412 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1412 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1413 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1413 | ++addCount; | 1414 | ++addCount; |
1414 | } | 1415 | } |
1415 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1416 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1416 | if ( anni.isValid() ){ | 1417 | if ( anni.isValid() ){ |
1417 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1418 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1418 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1419 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1419 | ++addCount; | 1420 | ++addCount; |
1420 | } | 1421 | } |
1421 | } | 1422 | } |
1422 | updateView(); | 1423 | updateView(); |
1423 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1424 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1424 | #else //DESKTOP_VERSION | 1425 | #else //DESKTOP_VERSION |
1425 | 1426 | ||
1426 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1427 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1427 | // the result should now arrive through method insertBirthdays | 1428 | // the result should now arrive through method insertBirthdays |
1428 | 1429 | ||
1429 | #endif //DESKTOP_VERSION | 1430 | #endif //DESKTOP_VERSION |
1430 | 1431 | ||
1431 | #endif //KORG_NOKABC | 1432 | #endif //KORG_NOKABC |
1432 | 1433 | ||
1433 | 1434 | ||
1434 | return true; | 1435 | return true; |
1435 | } | 1436 | } |
1436 | 1437 | ||
1437 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1438 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1438 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1439 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1439 | const QStringList& anniversaryList, const QStringList& realNameList, | 1440 | const QStringList& anniversaryList, const QStringList& realNameList, |
1440 | const QStringList& emailList, const QStringList& assembledNameList, | 1441 | const QStringList& emailList, const QStringList& assembledNameList, |
1441 | const QStringList& uidList) | 1442 | const QStringList& uidList) |
1442 | { | 1443 | { |
1443 | qDebug("CalendarView::insertBirthdays"); | 1444 | //qDebug("KO::CalendarView::insertBirthdays"); |
1444 | if (uid == this->name()) | 1445 | if (uid == this->name()) |
1445 | { | 1446 | { |
1446 | int count = birthdayList.count(); | 1447 | int count = birthdayList.count(); |
1447 | int addCount = 0; | 1448 | int addCount = 0; |
1448 | KCal::Attendee* a = 0; | 1449 | KCal::Attendee* a = 0; |
1449 | 1450 | ||
1450 | qDebug("CalView 1 %i", count); | 1451 | //qDebug("CalView 1 %i", count); |
1451 | 1452 | ||
1452 | QProgressBar bar(count,0 ); | 1453 | QProgressBar bar(count,0 ); |
1453 | int w = 300; | 1454 | int w = 300; |
1454 | if ( QApplication::desktop()->width() < 320 ) | 1455 | if ( QApplication::desktop()->width() < 320 ) |
1455 | w = 220; | 1456 | w = 220; |
1456 | int h = bar.sizeHint().height() ; | 1457 | int h = bar.sizeHint().height() ; |
1457 | int dw = QApplication::desktop()->width(); | 1458 | int dw = QApplication::desktop()->width(); |
1458 | int dh = QApplication::desktop()->height(); | 1459 | int dh = QApplication::desktop()->height(); |
1459 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1460 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1460 | bar.show(); | 1461 | bar.show(); |
1461 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1462 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1462 | qApp->processEvents(); | 1463 | qApp->processEvents(); |
1463 | 1464 | ||
1464 | QDate birthday; | 1465 | QDate birthday; |
1465 | QDate anniversary; | 1466 | QDate anniversary; |
1466 | QString realName; | 1467 | QString realName; |
1467 | QString email; | 1468 | QString email; |
1468 | QString assembledName; | 1469 | QString assembledName; |
1469 | QString uid; | 1470 | QString uid; |
1470 | bool ok = true; | 1471 | bool ok = true; |
1471 | for ( int i = 0; i < count; i++) | 1472 | for ( int i = 0; i < count; i++) |
1472 | { | 1473 | { |
1473 | if ( ! bar.isVisible() ) | 1474 | if ( ! bar.isVisible() ) |
1474 | return; | 1475 | return; |
1475 | bar.setProgress( i ); | 1476 | bar.setProgress( i ); |
1476 | qApp->processEvents(); | 1477 | qApp->processEvents(); |
1477 | 1478 | ||
1478 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1479 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1479 | if (!ok) { | 1480 | if (!ok) { |
1480 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1481 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1481 | } | 1482 | } |
1482 | 1483 | ||
1483 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1484 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1484 | if (!ok) { | 1485 | if (!ok) { |
1485 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1486 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1486 | } | 1487 | } |
1487 | realName = realNameList[i]; | 1488 | realName = realNameList[i]; |
1488 | email = emailList[i]; | 1489 | email = emailList[i]; |
1489 | assembledName = assembledNameList[i]; | 1490 | assembledName = assembledNameList[i]; |
1490 | uid = uidList[i]; | 1491 | uid = uidList[i]; |
1491 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1492 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1492 | 1493 | ||
1493 | if ( birthday.isValid() ){ | 1494 | if ( birthday.isValid() ){ |
1494 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1495 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1495 | KCal::Attendee::ReqParticipant,uid) ; | 1496 | KCal::Attendee::ReqParticipant,uid) ; |
1496 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1497 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1497 | ++addCount; | 1498 | ++addCount; |
1498 | } | 1499 | } |
1499 | 1500 | ||
1500 | if ( anniversary.isValid() ){ | 1501 | if ( anniversary.isValid() ){ |
1501 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1502 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1502 | KCal::Attendee::ReqParticipant,uid) ; | 1503 | KCal::Attendee::ReqParticipant,uid) ; |
1503 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1504 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1504 | ++addCount; | 1505 | ++addCount; |
1505 | } | 1506 | } |
1506 | } | 1507 | } |
1507 | 1508 | ||
1508 | updateView(); | 1509 | updateView(); |
1509 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1510 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1510 | 1511 | ||
1511 | } | 1512 | } |
1512 | 1513 | ||
1513 | } | 1514 | } |
1514 | 1515 | ||
1515 | 1516 | ||
1516 | 1517 | ||
1517 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1518 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1518 | { | 1519 | { |
1519 | //qDebug("addAnni "); | 1520 | //qDebug("addAnni "); |
1520 | Event * ev = new Event(); | 1521 | Event * ev = new Event(); |
1521 | if ( a ) { | 1522 | if ( a ) { |
1522 | ev->addAttendee( a ); | 1523 | ev->addAttendee( a ); |
1523 | } | 1524 | } |
1524 | QString kind; | 1525 | QString kind; |
1525 | if ( birthday ) | 1526 | if ( birthday ) |
1526 | kind = i18n( "Birthday" ); | 1527 | kind = i18n( "Birthday" ); |
1527 | else | 1528 | else |
1528 | kind = i18n( "Anniversary" ); | 1529 | kind = i18n( "Anniversary" ); |
1529 | ev->setSummary( name + " - " + kind ); | 1530 | ev->setSummary( name + " - " + kind ); |
1530 | ev->setOrganizer(a->email()); | 1531 | ev->setOrganizer(a->email()); |
1531 | ev->setCategories( kind ); | 1532 | ev->setCategories( kind ); |
1532 | ev->setDtStart( QDateTime(date) ); | 1533 | ev->setDtStart( QDateTime(date) ); |
1533 | ev->setDtEnd( QDateTime(date) ); | 1534 | ev->setDtEnd( QDateTime(date) ); |
1534 | ev->setFloats( true ); | 1535 | ev->setFloats( true ); |
1535 | Recurrence * rec = ev->recurrence(); | 1536 | Recurrence * rec = ev->recurrence(); |
1536 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1537 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1537 | rec->addYearlyNum( date.month() ); | 1538 | rec->addYearlyNum( date.month() ); |
1538 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1539 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1539 | delete ev; | 1540 | delete ev; |
1540 | return false; | 1541 | return false; |
1541 | } | 1542 | } |
1542 | return true; | 1543 | return true; |
1543 | 1544 | ||
1544 | } | 1545 | } |
1545 | bool CalendarView::importQtopia( const QString &categories, | 1546 | bool CalendarView::importQtopia( const QString &categories, |
1546 | const QString &datebook, | 1547 | const QString &datebook, |
1547 | const QString &todolist ) | 1548 | const QString &todolist ) |
1548 | { | 1549 | { |
1549 | 1550 | ||
1550 | QtopiaFormat qtopiaFormat; | 1551 | QtopiaFormat qtopiaFormat; |
1551 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1552 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1552 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1553 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1553 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1554 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1554 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1555 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1555 | 1556 | ||
1556 | updateView(); | 1557 | updateView(); |
1557 | return true; | 1558 | return true; |
1558 | 1559 | ||
1559 | #if 0 | 1560 | #if 0 |
1560 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1561 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1561 | mCurrentSyncDevice = "qtopia-XML"; | 1562 | mCurrentSyncDevice = "qtopia-XML"; |
1562 | if ( mSyncManager->mAskForPreferences ) | 1563 | if ( mSyncManager->mAskForPreferences ) |
1563 | edit_sync_options(); | 1564 | edit_sync_options(); |
1564 | qApp->processEvents(); | 1565 | qApp->processEvents(); |
1565 | CalendarLocal* calendar = new CalendarLocal(); | 1566 | CalendarLocal* calendar = new CalendarLocal(); |
1566 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1567 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1567 | bool syncOK = false; | 1568 | bool syncOK = false; |
1568 | QtopiaFormat qtopiaFormat; | 1569 | QtopiaFormat qtopiaFormat; |
1569 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1570 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1570 | bool loadOk = true; | 1571 | bool loadOk = true; |
1571 | if ( !categories.isEmpty() ) | 1572 | if ( !categories.isEmpty() ) |
1572 | loadOk = qtopiaFormat.load( calendar, categories ); | 1573 | loadOk = qtopiaFormat.load( calendar, categories ); |
1573 | if ( loadOk && !datebook.isEmpty() ) | 1574 | if ( loadOk && !datebook.isEmpty() ) |
1574 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1575 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1575 | if ( loadOk && !todolist.isEmpty() ) | 1576 | if ( loadOk && !todolist.isEmpty() ) |
1576 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1577 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1577 | 1578 | ||
1578 | if ( loadOk ) { | 1579 | if ( loadOk ) { |
1579 | getEventViewerDialog()->setSyncMode( true ); | 1580 | getEventViewerDialog()->setSyncMode( true ); |
1580 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1581 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1581 | getEventViewerDialog()->setSyncMode( false ); | 1582 | getEventViewerDialog()->setSyncMode( false ); |
1582 | qApp->processEvents(); | 1583 | qApp->processEvents(); |
1583 | if ( syncOK ) { | 1584 | if ( syncOK ) { |
1584 | if ( mSyncManager->mWriteBackFile ) | 1585 | if ( mSyncManager->mWriteBackFile ) |
1585 | { | 1586 | { |
1586 | // write back XML file | 1587 | // write back XML file |
1587 | 1588 | ||
1588 | } | 1589 | } |
1589 | setModified( true ); | 1590 | setModified( true ); |
1590 | } | 1591 | } |
1591 | } else { | 1592 | } else { |
1592 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1593 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1593 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1594 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1594 | question, i18n("Ok")) ; | 1595 | question, i18n("Ok")) ; |
1595 | } | 1596 | } |
1596 | delete calendar; | 1597 | delete calendar; |
1597 | updateView(); | 1598 | updateView(); |
1598 | return syncOK; | 1599 | return syncOK; |
1599 | 1600 | ||
1600 | 1601 | ||
1601 | #endif | 1602 | #endif |
1602 | 1603 | ||
1603 | } | 1604 | } |
1604 | 1605 | ||
1605 | void CalendarView::setSyncEventsReadOnly() | 1606 | void CalendarView::setSyncEventsReadOnly() |
1606 | { | 1607 | { |
1607 | Event * ev; | 1608 | Event * ev; |
1608 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1609 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1609 | ev = eL.first(); | 1610 | ev = eL.first(); |
1610 | while ( ev ) { | 1611 | while ( ev ) { |
1611 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1612 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1612 | ev->setReadOnly( true ); | 1613 | ev->setReadOnly( true ); |
1613 | ev = eL.next(); | 1614 | ev = eL.next(); |
1614 | } | 1615 | } |
1615 | } | 1616 | } |
1616 | bool CalendarView::openCalendar(QString filename, bool merge) | 1617 | bool CalendarView::openCalendar(QString filename, bool merge) |
1617 | { | 1618 | { |
1618 | 1619 | ||
1619 | if (filename.isEmpty()) { | 1620 | if (filename.isEmpty()) { |
1620 | return false; | 1621 | return false; |
1621 | } | 1622 | } |
1622 | 1623 | ||
1623 | if (!QFile::exists(filename)) { | 1624 | if (!QFile::exists(filename)) { |
1624 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1625 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1625 | return false; | 1626 | return false; |
1626 | } | 1627 | } |
1627 | 1628 | ||
1628 | globalFlagBlockAgenda = 1; | 1629 | globalFlagBlockAgenda = 1; |
1629 | if (!merge) mCalendar->close(); | 1630 | if (!merge) mCalendar->close(); |
1630 | 1631 | ||
1631 | mStorage->setFileName( filename ); | 1632 | mStorage->setFileName( filename ); |
1632 | 1633 | ||
1633 | if ( mStorage->load() ) { | 1634 | if ( mStorage->load() ) { |
1634 | if ( merge ) ;//setModified( true ); | 1635 | if ( merge ) ;//setModified( true ); |
1635 | else { | 1636 | else { |
1636 | //setModified( true ); | 1637 | //setModified( true ); |
1637 | mViewManager->setDocumentId( filename ); | 1638 | mViewManager->setDocumentId( filename ); |
1638 | mDialogManager->setDocumentId( filename ); | 1639 | mDialogManager->setDocumentId( filename ); |
1639 | mTodoList->setDocumentId( filename ); | 1640 | mTodoList->setDocumentId( filename ); |
1640 | } | 1641 | } |
1641 | globalFlagBlockAgenda = 2; | 1642 | globalFlagBlockAgenda = 2; |
1642 | // if ( getLastSyncEvent() ) | 1643 | // if ( getLastSyncEvent() ) |
1643 | // getLastSyncEvent()->setReadOnly( true ); | 1644 | // getLastSyncEvent()->setReadOnly( true ); |
1644 | mCalendar->reInitAlarmSettings(); | 1645 | mCalendar->reInitAlarmSettings(); |
1645 | setSyncEventsReadOnly(); | 1646 | setSyncEventsReadOnly(); |
1646 | updateUnmanagedViews(); | 1647 | updateUnmanagedViews(); |
1647 | updateView(); | 1648 | updateView(); |
1648 | if ( filename != MainWindow::defaultFileName() ) { | 1649 | if ( filename != MainWindow::defaultFileName() ) { |
1649 | saveCalendar( MainWindow::defaultFileName() ); | 1650 | saveCalendar( MainWindow::defaultFileName() ); |
1650 | } else { | 1651 | } else { |
1651 | QFileInfo finf ( MainWindow::defaultFileName()); | 1652 | QFileInfo finf ( MainWindow::defaultFileName()); |
1652 | if ( finf.exists() ) { | 1653 | if ( finf.exists() ) { |
1653 | setLoadedFileVersion( finf.lastModified () ); | 1654 | setLoadedFileVersion( finf.lastModified () ); |
1654 | } | 1655 | } |
1655 | } | 1656 | } |
1656 | return true; | 1657 | return true; |
1657 | } else { | 1658 | } else { |
1658 | // while failing to load, the calendar object could | 1659 | // while failing to load, the calendar object could |
1659 | // have become partially populated. Clear it out. | 1660 | // have become partially populated. Clear it out. |
1660 | if ( !merge ) { | 1661 | if ( !merge ) { |
1661 | mCalendar->close(); | 1662 | mCalendar->close(); |
1662 | mViewManager->setDocumentId( filename ); | 1663 | mViewManager->setDocumentId( filename ); |
1663 | mDialogManager->setDocumentId( filename ); | 1664 | mDialogManager->setDocumentId( filename ); |
1664 | mTodoList->setDocumentId( filename ); | 1665 | mTodoList->setDocumentId( filename ); |
1665 | } | 1666 | } |
1666 | 1667 | ||
1667 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1668 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1668 | 1669 | ||
1669 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1670 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1670 | globalFlagBlockAgenda = 2; | 1671 | globalFlagBlockAgenda = 2; |
1671 | mCalendar->reInitAlarmSettings(); | 1672 | mCalendar->reInitAlarmSettings(); |
1672 | setSyncEventsReadOnly(); | 1673 | setSyncEventsReadOnly(); |
1673 | updateUnmanagedViews(); | 1674 | updateUnmanagedViews(); |
1674 | updateView(); | 1675 | updateView(); |
1675 | } | 1676 | } |
1676 | return false; | 1677 | return false; |
1677 | } | 1678 | } |
1678 | void CalendarView::showOpenError() | 1679 | void CalendarView::showOpenError() |
1679 | { | 1680 | { |
1680 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1681 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1681 | } | 1682 | } |
1682 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1683 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1683 | { | 1684 | { |
1684 | loadedFileVersion = dt; | 1685 | loadedFileVersion = dt; |
1685 | } | 1686 | } |
1686 | bool CalendarView::checkFileChanged(QString fn) | 1687 | bool CalendarView::checkFileChanged(QString fn) |
1687 | { | 1688 | { |
1688 | QFileInfo finf ( fn ); | 1689 | QFileInfo finf ( fn ); |
1689 | if ( !finf.exists() ) | 1690 | if ( !finf.exists() ) |
1690 | return true; | 1691 | return true; |
1691 | QDateTime dt = finf.lastModified (); | 1692 | QDateTime dt = finf.lastModified (); |
1692 | if ( dt <= loadedFileVersion ) | 1693 | if ( dt <= loadedFileVersion ) |
1693 | return false; | 1694 | return false; |
1694 | return true; | 1695 | return true; |
1695 | 1696 | ||
1696 | } | 1697 | } |
1697 | void CalendarView::watchSavedFile() | 1698 | void CalendarView::watchSavedFile() |
1698 | { | 1699 | { |
1699 | QFileInfo finf ( MainWindow::defaultFileName()); | 1700 | QFileInfo finf ( MainWindow::defaultFileName()); |
1700 | if ( !finf.exists() ) | 1701 | if ( !finf.exists() ) |
1701 | return; | 1702 | return; |
1702 | QDateTime dt = finf.lastModified (); | 1703 | QDateTime dt = finf.lastModified (); |
1703 | if ( dt < loadedFileVersion ) { | 1704 | if ( dt < loadedFileVersion ) { |
1704 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1705 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1705 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1706 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1706 | return; | 1707 | return; |
1707 | } | 1708 | } |
1708 | loadedFileVersion = dt; | 1709 | loadedFileVersion = dt; |
1709 | } | 1710 | } |
1710 | 1711 | ||
1711 | bool CalendarView::checkFileVersion(QString fn) | 1712 | bool CalendarView::checkFileVersion(QString fn) |
1712 | { | 1713 | { |
1713 | QFileInfo finf ( fn ); | 1714 | QFileInfo finf ( fn ); |
1714 | if ( !finf.exists() ) | 1715 | if ( !finf.exists() ) |
1715 | return true; | 1716 | return true; |
1716 | QDateTime dt = finf.lastModified (); | 1717 | QDateTime dt = finf.lastModified (); |
1717 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1718 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1718 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1719 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1719 | if ( dt <= loadedFileVersion ) | 1720 | if ( dt <= loadedFileVersion ) |
1720 | return true; | 1721 | return true; |
1721 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1722 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1722 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1723 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1723 | i18n("Sync+save")); | 1724 | i18n("Sync+save")); |
1724 | 1725 | ||
1725 | if ( km == KMessageBox::Cancel ) | 1726 | if ( km == KMessageBox::Cancel ) |
1726 | return false; | 1727 | return false; |
1727 | if ( km == KMessageBox::Yes ) | 1728 | if ( km == KMessageBox::Yes ) |
1728 | return true; | 1729 | return true; |
1729 | 1730 | ||
1730 | setSyncDevice("deleteaftersync" ); | 1731 | setSyncDevice("deleteaftersync" ); |
1731 | mSyncManager->mAskForPreferences = true; | 1732 | mSyncManager->mAskForPreferences = true; |
1732 | mSyncManager->mSyncAlgoPrefs = 3; | 1733 | mSyncManager->mSyncAlgoPrefs = 3; |
1733 | mSyncManager->mWriteBackFile = false; | 1734 | mSyncManager->mWriteBackFile = false; |
1734 | mSyncManager->mWriteBackExistingOnly = false; | 1735 | mSyncManager->mWriteBackExistingOnly = false; |
1735 | mSyncManager->mShowSyncSummary = false; | 1736 | mSyncManager->mShowSyncSummary = false; |
1736 | syncCalendar( fn, 3 ); | 1737 | syncCalendar( fn, 3 ); |
1737 | Event * e = getLastSyncEvent(); | 1738 | Event * e = getLastSyncEvent(); |
1738 | mCalendar->deleteEvent ( e ); | 1739 | mCalendar->deleteEvent ( e ); |
1739 | updateView(); | 1740 | updateView(); |
1740 | return true; | 1741 | return true; |
1741 | } | 1742 | } |
1742 | 1743 | ||
1743 | bool CalendarView::saveCalendar( QString filename ) | 1744 | bool CalendarView::saveCalendar( QString filename ) |
1744 | { | 1745 | { |
1745 | 1746 | ||
1746 | // Store back all unsaved data into calendar object | 1747 | // Store back all unsaved data into calendar object |
1747 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1748 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1748 | if ( mViewManager->currentView() ) | 1749 | if ( mViewManager->currentView() ) |
1749 | mViewManager->currentView()->flushView(); | 1750 | mViewManager->currentView()->flushView(); |
1750 | 1751 | ||
1751 | 1752 | ||
1752 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1753 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1753 | mStorage->setSaveFormat( new ICalFormat() ); | 1754 | mStorage->setSaveFormat( new ICalFormat() ); |
1754 | mStorage->setFileName( filename ); | 1755 | mStorage->setFileName( filename ); |
1755 | bool success; | 1756 | bool success; |
1756 | success = mStorage->save(); | 1757 | success = mStorage->save(); |
1757 | if ( !success ) { | 1758 | if ( !success ) { |
1758 | return false; | 1759 | return false; |
1759 | } | 1760 | } |
1760 | if ( filename == MainWindow::defaultFileName() ) { | 1761 | if ( filename == MainWindow::defaultFileName() ) { |
1761 | setLoadedFileVersion( lfv ); | 1762 | setLoadedFileVersion( lfv ); |
1762 | watchSavedFile(); | 1763 | watchSavedFile(); |
1763 | } | 1764 | } |
1764 | return true; | 1765 | return true; |
1765 | } | 1766 | } |
1766 | 1767 | ||
1767 | void CalendarView::closeCalendar() | 1768 | void CalendarView::closeCalendar() |
1768 | { | 1769 | { |
1769 | 1770 | ||
1770 | // child windows no longer valid | 1771 | // child windows no longer valid |
1771 | emit closingDown(); | 1772 | emit closingDown(); |
1772 | 1773 | ||
1773 | mCalendar->close(); | 1774 | mCalendar->close(); |
1774 | setModified(false); | 1775 | setModified(false); |
1775 | updateView(); | 1776 | updateView(); |
1776 | } | 1777 | } |
1777 | 1778 | ||
1778 | void CalendarView::archiveCalendar() | 1779 | void CalendarView::archiveCalendar() |
1779 | { | 1780 | { |
1780 | mDialogManager->showArchiveDialog(); | 1781 | mDialogManager->showArchiveDialog(); |
1781 | } | 1782 | } |
1782 | 1783 | ||
1783 | 1784 | ||
1784 | void CalendarView::readSettings() | 1785 | void CalendarView::readSettings() |
1785 | { | 1786 | { |
1786 | 1787 | ||
1787 | 1788 | ||
1788 | // mViewManager->showAgendaView(); | 1789 | // mViewManager->showAgendaView(); |
1789 | QString str; | 1790 | QString str; |
1790 | //qDebug("CalendarView::readSettings() "); | 1791 | //qDebug("CalendarView::readSettings() "); |
1791 | // read settings from the KConfig, supplying reasonable | 1792 | // read settings from the KConfig, supplying reasonable |
1792 | // defaults where none are to be found | 1793 | // defaults where none are to be found |
1793 | KConfig *config = KOGlobals::config(); | 1794 | KConfig *config = KOGlobals::config(); |
1794 | #ifndef KORG_NOSPLITTER | 1795 | #ifndef KORG_NOSPLITTER |
1795 | config->setGroup("KOrganizer Geometry"); | 1796 | config->setGroup("KOrganizer Geometry"); |
1796 | 1797 | ||
1797 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1798 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1798 | if (sizes.count() != 2) { | 1799 | if (sizes.count() != 2) { |
1799 | sizes << mDateNavigator->minimumSizeHint().width(); | 1800 | sizes << mDateNavigator->minimumSizeHint().width(); |
1800 | sizes << 300; | 1801 | sizes << 300; |
1801 | } | 1802 | } |
1802 | mPanner->setSizes(sizes); | 1803 | mPanner->setSizes(sizes); |
1803 | 1804 | ||
1804 | sizes = config->readIntListEntry("Separator2"); | 1805 | sizes = config->readIntListEntry("Separator2"); |
1805 | if ( ( mResourceView && sizes.count() == 4 ) || | 1806 | if ( ( mResourceView && sizes.count() == 4 ) || |
1806 | ( !mResourceView && sizes.count() == 3 ) ) { | 1807 | ( !mResourceView && sizes.count() == 3 ) ) { |
1807 | mLeftSplitter->setSizes(sizes); | 1808 | mLeftSplitter->setSizes(sizes); |
1808 | } | 1809 | } |
1809 | #endif | 1810 | #endif |
1810 | globalFlagBlockAgenda = 1; | 1811 | globalFlagBlockAgenda = 1; |
1811 | mViewManager->showAgendaView(); | 1812 | mViewManager->showAgendaView(); |
1812 | //mViewManager->readSettings( config ); | 1813 | //mViewManager->readSettings( config ); |
1813 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1814 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1814 | readFilterSettings(config); | 1815 | readFilterSettings(config); |
1815 | config->setGroup( "Views" ); | 1816 | config->setGroup( "Views" ); |
1816 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1817 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1817 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1818 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1818 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1819 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1819 | else mNavigator->selectDates( dateCount ); | 1820 | else mNavigator->selectDates( dateCount ); |
1820 | // mViewManager->readSettings( config ); | 1821 | // mViewManager->readSettings( config ); |
1821 | updateConfig(); | 1822 | updateConfig(); |
1822 | globalFlagBlockAgenda = 2; | 1823 | globalFlagBlockAgenda = 2; |
1823 | mViewManager->readSettings( config ); | 1824 | mViewManager->readSettings( config ); |
1824 | #ifdef DESKTOP_VERSION | 1825 | #ifdef DESKTOP_VERSION |
1825 | config->setGroup("WidgetLayout"); | 1826 | config->setGroup("WidgetLayout"); |
1826 | QStringList list; | 1827 | QStringList list; |
1827 | list = config->readListEntry("MainLayout"); | 1828 | list = config->readListEntry("MainLayout"); |
1828 | int x,y,w,h; | 1829 | int x,y,w,h; |
1829 | if ( ! list.isEmpty() ) { | 1830 | if ( ! list.isEmpty() ) { |
1830 | x = list[0].toInt(); | 1831 | x = list[0].toInt(); |
1831 | y = list[1].toInt(); | 1832 | y = list[1].toInt(); |
1832 | w = list[2].toInt(); | 1833 | w = list[2].toInt(); |
1833 | h = list[3].toInt(); | 1834 | h = list[3].toInt(); |
1834 | topLevelWidget()->setGeometry(x,y,w,h); | 1835 | topLevelWidget()->setGeometry(x,y,w,h); |
1835 | 1836 | ||
1836 | } else { | 1837 | } else { |
1837 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1838 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1838 | } | 1839 | } |
1839 | list = config->readListEntry("EditEventLayout"); | 1840 | list = config->readListEntry("EditEventLayout"); |
1840 | if ( ! list.isEmpty() ) { | 1841 | if ( ! list.isEmpty() ) { |
1841 | x = list[0].toInt(); | 1842 | x = list[0].toInt(); |
1842 | y = list[1].toInt(); | 1843 | y = list[1].toInt(); |
1843 | w = list[2].toInt(); | 1844 | w = list[2].toInt(); |
1844 | h = list[3].toInt(); | 1845 | h = list[3].toInt(); |
1845 | mEventEditor->setGeometry(x,y,w,h); | 1846 | mEventEditor->setGeometry(x,y,w,h); |
1846 | 1847 | ||
1847 | } | 1848 | } |
1848 | list = config->readListEntry("EditTodoLayout"); | 1849 | list = config->readListEntry("EditTodoLayout"); |
1849 | if ( ! list.isEmpty() ) { | 1850 | if ( ! list.isEmpty() ) { |
1850 | x = list[0].toInt(); | 1851 | x = list[0].toInt(); |
1851 | y = list[1].toInt(); | 1852 | y = list[1].toInt(); |
1852 | w = list[2].toInt(); | 1853 | w = list[2].toInt(); |
1853 | h = list[3].toInt(); | 1854 | h = list[3].toInt(); |
1854 | mTodoEditor->setGeometry(x,y,w,h); | 1855 | mTodoEditor->setGeometry(x,y,w,h); |
1855 | 1856 | ||
1856 | } | 1857 | } |
1857 | list = config->readListEntry("ViewerLayout"); | 1858 | list = config->readListEntry("ViewerLayout"); |
1858 | if ( ! list.isEmpty() ) { | 1859 | if ( ! list.isEmpty() ) { |
1859 | x = list[0].toInt(); | 1860 | x = list[0].toInt(); |
1860 | y = list[1].toInt(); | 1861 | y = list[1].toInt(); |
1861 | w = list[2].toInt(); | 1862 | w = list[2].toInt(); |
1862 | h = list[3].toInt(); | 1863 | h = list[3].toInt(); |
1863 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1864 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1864 | } | 1865 | } |
1865 | #endif | 1866 | #endif |
1866 | 1867 | ||
1867 | } | 1868 | } |
1868 | 1869 | ||
1869 | 1870 | ||
1870 | void CalendarView::writeSettings() | 1871 | void CalendarView::writeSettings() |
1871 | { | 1872 | { |
1872 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1873 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1873 | 1874 | ||
1874 | KConfig *config = KOGlobals::config(); | 1875 | KConfig *config = KOGlobals::config(); |
1875 | 1876 | ||
1876 | #ifndef KORG_NOSPLITTER | 1877 | #ifndef KORG_NOSPLITTER |
1877 | config->setGroup("KOrganizer Geometry"); | 1878 | config->setGroup("KOrganizer Geometry"); |
1878 | 1879 | ||
1879 | QValueList<int> list = mPanner->sizes(); | 1880 | QValueList<int> list = mPanner->sizes(); |
1880 | config->writeEntry("Separator1",list); | 1881 | config->writeEntry("Separator1",list); |
1881 | 1882 | ||
1882 | list = mLeftSplitter->sizes(); | 1883 | list = mLeftSplitter->sizes(); |
1883 | config->writeEntry("Separator2",list); | 1884 | config->writeEntry("Separator2",list); |
1884 | #endif | 1885 | #endif |
1885 | 1886 | ||
1886 | mViewManager->writeSettings( config ); | 1887 | mViewManager->writeSettings( config ); |
1887 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1888 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1888 | mDialogManager->writeSettings( config ); | 1889 | mDialogManager->writeSettings( config ); |
1889 | //KOPrefs::instance()->usrWriteConfig(); | 1890 | //KOPrefs::instance()->usrWriteConfig(); |
1890 | KOPrefs::instance()->writeConfig(); | 1891 | KOPrefs::instance()->writeConfig(); |
1891 | 1892 | ||
1892 | writeFilterSettings(config); | 1893 | writeFilterSettings(config); |
1893 | 1894 | ||
1894 | config->setGroup( "Views" ); | 1895 | config->setGroup( "Views" ); |
1895 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1896 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1896 | 1897 | ||
1897 | #ifdef DESKTOP_VERSION | 1898 | #ifdef DESKTOP_VERSION |
1898 | config->setGroup("WidgetLayout"); | 1899 | config->setGroup("WidgetLayout"); |
1899 | QStringList list ;//= config->readListEntry("MainLayout"); | 1900 | QStringList list ;//= config->readListEntry("MainLayout"); |
1900 | int x,y,w,h; | 1901 | int x,y,w,h; |
1901 | QWidget* wid; | 1902 | QWidget* wid; |
1902 | wid = topLevelWidget(); | 1903 | wid = topLevelWidget(); |
1903 | x = wid->geometry().x(); | 1904 | x = wid->geometry().x(); |
1904 | y = wid->geometry().y(); | 1905 | y = wid->geometry().y(); |
1905 | w = wid->width(); | 1906 | w = wid->width(); |
1906 | h = wid->height(); | 1907 | h = wid->height(); |
1907 | list.clear(); | 1908 | list.clear(); |
1908 | list << QString::number( x ); | 1909 | list << QString::number( x ); |
1909 | list << QString::number( y ); | 1910 | list << QString::number( y ); |
1910 | list << QString::number( w ); | 1911 | list << QString::number( w ); |
1911 | list << QString::number( h ); | 1912 | list << QString::number( h ); |
1912 | config->writeEntry("MainLayout",list ); | 1913 | config->writeEntry("MainLayout",list ); |
1913 | 1914 | ||
1914 | wid = mEventEditor; | 1915 | wid = mEventEditor; |
1915 | x = wid->geometry().x(); | 1916 | x = wid->geometry().x(); |
1916 | y = wid->geometry().y(); | 1917 | y = wid->geometry().y(); |
1917 | w = wid->width(); | 1918 | w = wid->width(); |
1918 | h = wid->height(); | 1919 | h = wid->height(); |
1919 | list.clear(); | 1920 | list.clear(); |
1920 | list << QString::number( x ); | 1921 | list << QString::number( x ); |
1921 | list << QString::number( y ); | 1922 | list << QString::number( y ); |
1922 | list << QString::number( w ); | 1923 | list << QString::number( w ); |
1923 | list << QString::number( h ); | 1924 | list << QString::number( h ); |
1924 | config->writeEntry("EditEventLayout",list ); | 1925 | config->writeEntry("EditEventLayout",list ); |
1925 | 1926 | ||
1926 | wid = mTodoEditor; | 1927 | wid = mTodoEditor; |
1927 | x = wid->geometry().x(); | 1928 | x = wid->geometry().x(); |
1928 | y = wid->geometry().y(); | 1929 | y = wid->geometry().y(); |
1929 | w = wid->width(); | 1930 | w = wid->width(); |
1930 | h = wid->height(); | 1931 | h = wid->height(); |
1931 | list.clear(); | 1932 | list.clear(); |
1932 | list << QString::number( x ); | 1933 | list << QString::number( x ); |
1933 | list << QString::number( y ); | 1934 | list << QString::number( y ); |
1934 | list << QString::number( w ); | 1935 | list << QString::number( w ); |
1935 | list << QString::number( h ); | 1936 | list << QString::number( h ); |
1936 | config->writeEntry("EditTodoLayout",list ); | 1937 | config->writeEntry("EditTodoLayout",list ); |
1937 | wid = getEventViewerDialog(); | 1938 | wid = getEventViewerDialog(); |
1938 | x = wid->geometry().x(); | 1939 | x = wid->geometry().x(); |
1939 | y = wid->geometry().y(); | 1940 | y = wid->geometry().y(); |
1940 | w = wid->width(); | 1941 | w = wid->width(); |
1941 | h = wid->height(); | 1942 | h = wid->height(); |
1942 | list.clear(); | 1943 | list.clear(); |
1943 | list << QString::number( x ); | 1944 | list << QString::number( x ); |
1944 | list << QString::number( y ); | 1945 | list << QString::number( y ); |
1945 | list << QString::number( w ); | 1946 | list << QString::number( w ); |
1946 | list << QString::number( h ); | 1947 | list << QString::number( h ); |
1947 | config->writeEntry("ViewerLayout",list ); | 1948 | config->writeEntry("ViewerLayout",list ); |
1948 | wid = mDialogManager->getSearchDialog(); | 1949 | wid = mDialogManager->getSearchDialog(); |
1949 | if ( wid ) { | 1950 | if ( wid ) { |
1950 | x = wid->geometry().x(); | 1951 | x = wid->geometry().x(); |
1951 | y = wid->geometry().y(); | 1952 | y = wid->geometry().y(); |
1952 | w = wid->width(); | 1953 | w = wid->width(); |
1953 | h = wid->height(); | 1954 | h = wid->height(); |
1954 | list.clear(); | 1955 | list.clear(); |
1955 | list << QString::number( x ); | 1956 | list << QString::number( x ); |
1956 | list << QString::number( y ); | 1957 | list << QString::number( y ); |
1957 | list << QString::number( w ); | 1958 | list << QString::number( w ); |
1958 | list << QString::number( h ); | 1959 | list << QString::number( h ); |
1959 | config->writeEntry("SearchLayout",list ); | 1960 | config->writeEntry("SearchLayout",list ); |
1960 | } | 1961 | } |
1961 | #endif | 1962 | #endif |
1962 | 1963 | ||
1963 | 1964 | ||
1964 | config->sync(); | 1965 | config->sync(); |
1965 | } | 1966 | } |
1966 | 1967 | ||
1967 | void CalendarView::readFilterSettings(KConfig *config) | 1968 | void CalendarView::readFilterSettings(KConfig *config) |
1968 | { | 1969 | { |
1969 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1970 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1970 | 1971 | ||
1971 | mFilters.clear(); | 1972 | mFilters.clear(); |
1972 | 1973 | ||
1973 | config->setGroup("General"); | 1974 | config->setGroup("General"); |
1974 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1975 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1975 | 1976 | ||
1976 | QStringList::ConstIterator it = filterList.begin(); | 1977 | QStringList::ConstIterator it = filterList.begin(); |
1977 | QStringList::ConstIterator end = filterList.end(); | 1978 | QStringList::ConstIterator end = filterList.end(); |
1978 | while(it != end) { | 1979 | while(it != end) { |
1979 | // kdDebug() << " filter: " << (*it) << endl; | 1980 | // kdDebug() << " filter: " << (*it) << endl; |
1980 | 1981 | ||
1981 | CalFilter *filter; | 1982 | CalFilter *filter; |
1982 | filter = new CalFilter(*it); | 1983 | filter = new CalFilter(*it); |
1983 | config->setGroup("Filter_" + (*it)); | 1984 | config->setGroup("Filter_" + (*it)); |
1984 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1985 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1985 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1986 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1986 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1987 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1987 | mFilters.append(filter); | 1988 | mFilters.append(filter); |
1988 | 1989 | ||
1989 | ++it; | 1990 | ++it; |
1990 | } | 1991 | } |
1991 | 1992 | ||
1992 | if (mFilters.count() == 0) { | 1993 | if (mFilters.count() == 0) { |
1993 | CalFilter *filter = new CalFilter(i18n("Default")); | 1994 | CalFilter *filter = new CalFilter(i18n("Default")); |
1994 | mFilters.append(filter); | 1995 | mFilters.append(filter); |
1995 | } | 1996 | } |
1996 | mFilterView->updateFilters(); | 1997 | mFilterView->updateFilters(); |
1997 | config->setGroup("FilterView"); | 1998 | config->setGroup("FilterView"); |
1998 | 1999 | ||
1999 | mFilterView->blockSignals(true); | 2000 | mFilterView->blockSignals(true); |
2000 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2001 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2001 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2002 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2002 | mFilterView->blockSignals(false); | 2003 | mFilterView->blockSignals(false); |
2003 | // We do it manually to avoid it being done twice by the above calls | 2004 | // We do it manually to avoid it being done twice by the above calls |
2004 | updateFilter(); | 2005 | updateFilter(); |
2005 | } | 2006 | } |
2006 | 2007 | ||
2007 | void CalendarView::writeFilterSettings(KConfig *config) | 2008 | void CalendarView::writeFilterSettings(KConfig *config) |
2008 | { | 2009 | { |
2009 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2010 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2010 | 2011 | ||
2011 | QStringList filterList; | 2012 | QStringList filterList; |
2012 | 2013 | ||
2013 | CalFilter *filter = mFilters.first(); | 2014 | CalFilter *filter = mFilters.first(); |
2014 | while(filter) { | 2015 | while(filter) { |
2015 | // kdDebug() << " fn: " << filter->name() << endl; | 2016 | // kdDebug() << " fn: " << filter->name() << endl; |
2016 | filterList << filter->name(); | 2017 | filterList << filter->name(); |
2017 | config->setGroup("Filter_" + filter->name()); | 2018 | config->setGroup("Filter_" + filter->name()); |
2018 | config->writeEntry("Criteria",filter->criteria()); | 2019 | config->writeEntry("Criteria",filter->criteria()); |
2019 | config->writeEntry("CategoryList",filter->categoryList()); | 2020 | config->writeEntry("CategoryList",filter->categoryList()); |
2020 | filter = mFilters.next(); | 2021 | filter = mFilters.next(); |
2021 | } | 2022 | } |
2022 | config->setGroup("General"); | 2023 | config->setGroup("General"); |
2023 | config->writeEntry("CalendarFilters",filterList); | 2024 | config->writeEntry("CalendarFilters",filterList); |
2024 | 2025 | ||
2025 | config->setGroup("FilterView"); | 2026 | config->setGroup("FilterView"); |
2026 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2027 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2027 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2028 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2028 | } | 2029 | } |
2029 | 2030 | ||
2030 | 2031 | ||
2031 | void CalendarView::goToday() | 2032 | void CalendarView::goToday() |
2032 | { | 2033 | { |
2033 | if ( mViewManager->currentView()->isMonthView() ) | 2034 | if ( mViewManager->currentView()->isMonthView() ) |
2034 | mNavigator->selectTodayMonth(); | 2035 | mNavigator->selectTodayMonth(); |
2035 | else | 2036 | else |
2036 | mNavigator->selectToday(); | 2037 | mNavigator->selectToday(); |
2037 | } | 2038 | } |
2038 | 2039 | ||
2039 | void CalendarView::goNext() | 2040 | void CalendarView::goNext() |
2040 | { | 2041 | { |
2041 | mNavigator->selectNext(); | 2042 | mNavigator->selectNext(); |
2042 | } | 2043 | } |
2043 | 2044 | ||
2044 | void CalendarView::goPrevious() | 2045 | void CalendarView::goPrevious() |
2045 | { | 2046 | { |
2046 | mNavigator->selectPrevious(); | 2047 | mNavigator->selectPrevious(); |
2047 | } | 2048 | } |
2048 | void CalendarView::goNextMonth() | 2049 | void CalendarView::goNextMonth() |
2049 | { | 2050 | { |
2050 | mNavigator->selectNextMonth(); | 2051 | mNavigator->selectNextMonth(); |
2051 | } | 2052 | } |
2052 | 2053 | ||
2053 | void CalendarView::goPreviousMonth() | 2054 | void CalendarView::goPreviousMonth() |
2054 | { | 2055 | { |
2055 | mNavigator->selectPreviousMonth(); | 2056 | mNavigator->selectPreviousMonth(); |
2056 | } | 2057 | } |
2057 | void CalendarView::writeLocale() | 2058 | void CalendarView::writeLocale() |
2058 | { | 2059 | { |
2059 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2060 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2060 | #if 0 | 2061 | #if 0 |
2061 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2062 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2062 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2063 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2063 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2064 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2064 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2065 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2065 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2066 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2066 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2067 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2067 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2068 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2068 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2069 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2069 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2070 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2070 | KOPrefs::instance()->mDaylightsavingStart, | 2071 | KOPrefs::instance()->mDaylightsavingStart, |
2071 | KOPrefs::instance()->mDaylightsavingEnd ); | 2072 | KOPrefs::instance()->mDaylightsavingEnd ); |
2072 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2073 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2073 | #endif | 2074 | #endif |
2074 | } | 2075 | } |
2075 | void CalendarView::updateConfig() | 2076 | void CalendarView::updateConfig() |
2076 | { | 2077 | { |
2077 | writeLocale(); | 2078 | writeLocale(); |
2078 | if ( KOPrefs::instance()->mUseAppColors ) | 2079 | if ( KOPrefs::instance()->mUseAppColors ) |
2079 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2080 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2080 | emit configChanged(); | 2081 | emit configChanged(); |
2081 | mTodoList->updateConfig(); | 2082 | mTodoList->updateConfig(); |
2082 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2083 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2083 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2084 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2084 | // To make the "fill window" configurations work | 2085 | // To make the "fill window" configurations work |
2085 | //mViewManager->raiseCurrentView(); | 2086 | //mViewManager->raiseCurrentView(); |
2086 | } | 2087 | } |
2087 | 2088 | ||
2088 | 2089 | ||
2089 | void CalendarView::eventChanged(Event *event) | 2090 | void CalendarView::eventChanged(Event *event) |
2090 | { | 2091 | { |
2091 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2092 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2092 | //updateUnmanagedViews(); | 2093 | //updateUnmanagedViews(); |
2093 | } | 2094 | } |
2094 | 2095 | ||
2095 | void CalendarView::eventAdded(Event *event) | 2096 | void CalendarView::eventAdded(Event *event) |
2096 | { | 2097 | { |
2097 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2098 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2098 | } | 2099 | } |
2099 | 2100 | ||
2100 | void CalendarView::eventToBeDeleted(Event *) | 2101 | void CalendarView::eventToBeDeleted(Event *) |
2101 | { | 2102 | { |
2102 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2103 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2103 | } | 2104 | } |
2104 | 2105 | ||
2105 | void CalendarView::eventDeleted() | 2106 | void CalendarView::eventDeleted() |
2106 | { | 2107 | { |
2107 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2108 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2108 | } | 2109 | } |
2109 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2110 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2110 | { | 2111 | { |
2111 | changeIncidenceDisplay((Incidence *)which, action); | 2112 | changeIncidenceDisplay((Incidence *)which, action); |
2112 | mDateNavigator->updateView(); //LR | 2113 | mDateNavigator->updateView(); //LR |
2113 | //mDialogManager->updateSearchDialog(); | 2114 | //mDialogManager->updateSearchDialog(); |
2114 | 2115 | ||
2115 | if (which) { | 2116 | if (which) { |
2116 | mViewManager->updateWNview(); | 2117 | mViewManager->updateWNview(); |
2117 | //mTodoList->updateView(); | 2118 | //mTodoList->updateView(); |
2118 | } | 2119 | } |
2119 | 2120 | ||
2120 | } | 2121 | } |
2121 | 2122 | ||
2122 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2123 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2123 | { | 2124 | { |
2124 | updateUnmanagedViews(); | 2125 | updateUnmanagedViews(); |
2125 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2126 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2126 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2127 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2127 | mCalendar->checkAlarmForIncidence( 0, true ); | 2128 | mCalendar->checkAlarmForIncidence( 0, true ); |
2128 | if ( mEventViewerDialog ) | 2129 | if ( mEventViewerDialog ) |
2129 | mEventViewerDialog->hide(); | 2130 | mEventViewerDialog->hide(); |
2130 | } | 2131 | } |
2131 | else | 2132 | else |
2132 | mCalendar->checkAlarmForIncidence( which , false ); | 2133 | mCalendar->checkAlarmForIncidence( which , false ); |
2133 | } | 2134 | } |
2134 | 2135 | ||
2135 | // most of the changeEventDisplays() right now just call the view's | 2136 | // most of the changeEventDisplays() right now just call the view's |
2136 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2137 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2137 | void CalendarView::changeEventDisplay(Event *which, int action) | 2138 | void CalendarView::changeEventDisplay(Event *which, int action) |
2138 | { | 2139 | { |
2139 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2140 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2140 | changeIncidenceDisplay((Incidence *)which, action); | 2141 | changeIncidenceDisplay((Incidence *)which, action); |
2141 | mDateNavigator->updateView(); | 2142 | mDateNavigator->updateView(); |
2142 | //mDialogManager->updateSearchDialog(); | 2143 | //mDialogManager->updateSearchDialog(); |
2143 | 2144 | ||
2144 | if (which) { | 2145 | if (which) { |
2145 | // If there is an event view visible update the display | 2146 | // If there is an event view visible update the display |
2146 | mViewManager->currentView()->changeEventDisplay(which,action); | 2147 | mViewManager->currentView()->changeEventDisplay(which,action); |
2147 | // TODO: check, if update needed | 2148 | // TODO: check, if update needed |
2148 | // if (which->getTodoStatus()) { | 2149 | // if (which->getTodoStatus()) { |
2149 | mTodoList->updateView(); | 2150 | mTodoList->updateView(); |
2150 | // } | 2151 | // } |
2151 | } else { | 2152 | } else { |
2152 | mViewManager->currentView()->updateView(); | 2153 | mViewManager->currentView()->updateView(); |
2153 | } | 2154 | } |
2154 | } | 2155 | } |
2155 | 2156 | ||
2156 | 2157 | ||
2157 | void CalendarView::updateTodoViews() | 2158 | void CalendarView::updateTodoViews() |
2158 | { | 2159 | { |
2159 | 2160 | ||
2160 | mTodoList->updateView(); | 2161 | mTodoList->updateView(); |
2161 | mViewManager->currentView()->updateView(); | 2162 | mViewManager->currentView()->updateView(); |
2162 | 2163 | ||
2163 | } | 2164 | } |
2164 | 2165 | ||
2165 | 2166 | ||
2166 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2167 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2167 | { | 2168 | { |
2168 | mTodoList->updateView(); | 2169 | mTodoList->updateView(); |
2169 | mViewManager->updateView(start, end); | 2170 | mViewManager->updateView(start, end); |
2170 | //mDateNavigator->updateView(); | 2171 | //mDateNavigator->updateView(); |
2171 | } | 2172 | } |
2172 | 2173 | ||
2173 | void CalendarView::updateView() | 2174 | void CalendarView::updateView() |
2174 | { | 2175 | { |
2175 | DateList tmpList = mNavigator->selectedDates(); | 2176 | DateList tmpList = mNavigator->selectedDates(); |
2176 | 2177 | ||
2177 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2178 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2178 | mTodoList->updateView(); | 2179 | mTodoList->updateView(); |
2179 | // We assume that the navigator only selects consecutive days. | 2180 | // We assume that the navigator only selects consecutive days. |
2180 | updateView( tmpList.first(), tmpList.last() ); | 2181 | updateView( tmpList.first(), tmpList.last() ); |
2181 | } | 2182 | } |
2182 | 2183 | ||
2183 | void CalendarView::updateUnmanagedViews() | 2184 | void CalendarView::updateUnmanagedViews() |
2184 | { | 2185 | { |
2185 | mDateNavigator->updateDayMatrix(); | 2186 | mDateNavigator->updateDayMatrix(); |
2186 | } | 2187 | } |
2187 | 2188 | ||
2188 | int CalendarView::msgItemDelete(const QString name) | 2189 | int CalendarView::msgItemDelete(const QString name) |
2189 | { | 2190 | { |
2190 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2191 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2191 | i18n("This item will be\npermanently deleted."), | 2192 | i18n("This item will be\npermanently deleted."), |
2192 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2193 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2193 | } | 2194 | } |
2194 | 2195 | ||
2195 | 2196 | ||
2196 | void CalendarView::edit_cut() | 2197 | void CalendarView::edit_cut() |
2197 | { | 2198 | { |
2198 | Event *anEvent=0; | 2199 | Event *anEvent=0; |
2199 | 2200 | ||
2200 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2201 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2201 | 2202 | ||
2202 | if (mViewManager->currentView()->isEventView()) { | 2203 | if (mViewManager->currentView()->isEventView()) { |
2203 | if ( incidence && incidence->type() == "Event" ) { | 2204 | if ( incidence && incidence->type() == "Event" ) { |
2204 | anEvent = static_cast<Event *>(incidence); | 2205 | anEvent = static_cast<Event *>(incidence); |
2205 | } | 2206 | } |
2206 | } | 2207 | } |
2207 | 2208 | ||
2208 | if (!anEvent) { | 2209 | if (!anEvent) { |
2209 | KNotifyClient::beep(); | 2210 | KNotifyClient::beep(); |
2210 | return; | 2211 | return; |
2211 | } | 2212 | } |
2212 | DndFactory factory( mCalendar ); | 2213 | DndFactory factory( mCalendar ); |
2213 | factory.cutEvent(anEvent); | 2214 | factory.cutEvent(anEvent); |
2214 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2215 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2215 | } | 2216 | } |
2216 | 2217 | ||
2217 | void CalendarView::edit_copy() | 2218 | void CalendarView::edit_copy() |
2218 | { | 2219 | { |
2219 | Event *anEvent=0; | 2220 | Event *anEvent=0; |
2220 | 2221 | ||
2221 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2222 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2222 | 2223 | ||
2223 | if (mViewManager->currentView()->isEventView()) { | 2224 | if (mViewManager->currentView()->isEventView()) { |
2224 | if ( incidence && incidence->type() == "Event" ) { | 2225 | if ( incidence && incidence->type() == "Event" ) { |
2225 | anEvent = static_cast<Event *>(incidence); | 2226 | anEvent = static_cast<Event *>(incidence); |
2226 | } | 2227 | } |
2227 | } | 2228 | } |
2228 | 2229 | ||
2229 | if (!anEvent) { | 2230 | if (!anEvent) { |
2230 | KNotifyClient::beep(); | 2231 | KNotifyClient::beep(); |
2231 | return; | 2232 | return; |
2232 | } | 2233 | } |
2233 | DndFactory factory( mCalendar ); | 2234 | DndFactory factory( mCalendar ); |
2234 | factory.copyEvent(anEvent); | 2235 | factory.copyEvent(anEvent); |
2235 | } | 2236 | } |
2236 | 2237 | ||
2237 | void CalendarView::edit_paste() | 2238 | void CalendarView::edit_paste() |
2238 | { | 2239 | { |
2239 | QDate date = mNavigator->selectedDates().first(); | 2240 | QDate date = mNavigator->selectedDates().first(); |
2240 | 2241 | ||
2241 | DndFactory factory( mCalendar ); | 2242 | DndFactory factory( mCalendar ); |
2242 | Event *pastedEvent = factory.pasteEvent( date ); | 2243 | Event *pastedEvent = factory.pasteEvent( date ); |
2243 | 2244 | ||
2244 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2245 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2245 | } | 2246 | } |
2246 | 2247 | ||
2247 | void CalendarView::edit_options() | 2248 | void CalendarView::edit_options() |
2248 | { | 2249 | { |
2249 | mDialogManager->showOptionsDialog(); | 2250 | mDialogManager->showOptionsDialog(); |
2250 | //writeSettings(); | 2251 | //writeSettings(); |
2251 | } | 2252 | } |
2252 | 2253 | ||
2253 | 2254 | ||
2254 | void CalendarView::slotSelectPickerDate( QDate d) | 2255 | void CalendarView::slotSelectPickerDate( QDate d) |
2255 | { | 2256 | { |
2256 | mDateFrame->hide(); | 2257 | mDateFrame->hide(); |
2257 | if ( mDatePickerMode == 1 ) { | 2258 | if ( mDatePickerMode == 1 ) { |
2258 | mNavigator->slotDaySelect( d ); | 2259 | mNavigator->slotDaySelect( d ); |
2259 | } else if ( mDatePickerMode == 2 ) { | 2260 | } else if ( mDatePickerMode == 2 ) { |
2260 | if ( mMoveIncidence->type() == "Todo" ) { | 2261 | if ( mMoveIncidence->type() == "Todo" ) { |
2261 | Todo * to = (Todo *) mMoveIncidence; | 2262 | Todo * to = (Todo *) mMoveIncidence; |
2262 | QTime tim; | 2263 | QTime tim; |
2263 | if ( to->hasDueDate() ) | 2264 | if ( to->hasDueDate() ) |
2264 | tim = to->dtDue().time(); | 2265 | tim = to->dtDue().time(); |
2265 | else { | 2266 | else { |
2266 | tim = QTime ( 0,0,0 ); | 2267 | tim = QTime ( 0,0,0 ); |
2267 | to->setFloats( true ); | 2268 | to->setFloats( true ); |
2268 | to->setHasDueDate( true ); | 2269 | to->setHasDueDate( true ); |
2269 | } | 2270 | } |
2270 | QDateTime dt ( d,tim ); | 2271 | QDateTime dt ( d,tim ); |
2271 | to->setDtDue( dt ); | 2272 | to->setDtDue( dt ); |
2272 | todoChanged( to ); | 2273 | todoChanged( to ); |
2273 | } else { | 2274 | } else { |
2274 | if ( mMoveIncidence->doesRecur() ) { | 2275 | if ( mMoveIncidence->doesRecur() ) { |
2275 | #if 0 | 2276 | #if 0 |
2276 | // PENDING implement this | 2277 | // PENDING implement this |
2277 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2278 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2278 | mCalendar()->addIncidence( newInc ); | 2279 | mCalendar()->addIncidence( newInc ); |
2279 | if ( mMoveIncidence->type() == "Todo" ) | 2280 | if ( mMoveIncidence->type() == "Todo" ) |
2280 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2281 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2281 | else | 2282 | else |
2282 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2283 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2283 | mMoveIncidence = newInc; | 2284 | mMoveIncidence = newInc; |
2284 | 2285 | ||
2285 | #endif | 2286 | #endif |
2286 | } | 2287 | } |
2287 | QTime tim = mMoveIncidence->dtStart().time(); | 2288 | QTime tim = mMoveIncidence->dtStart().time(); |
2288 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2289 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2289 | QDateTime dt ( d,tim ); | 2290 | QDateTime dt ( d,tim ); |
2290 | mMoveIncidence->setDtStart( dt ); | 2291 | mMoveIncidence->setDtStart( dt ); |
2291 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2292 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2292 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2293 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2293 | } | 2294 | } |
2294 | 2295 | ||
2295 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2296 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2296 | } | 2297 | } |
2297 | } | 2298 | } |
2298 | 2299 | ||
2299 | void CalendarView::removeCategories() | 2300 | void CalendarView::removeCategories() |
2300 | { | 2301 | { |
2301 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2302 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2302 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2303 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2303 | QStringList catIncList; | 2304 | QStringList catIncList; |
2304 | QStringList newCatList; | 2305 | QStringList newCatList; |
2305 | Incidence* inc = incList.first(); | 2306 | Incidence* inc = incList.first(); |
2306 | int i; | 2307 | int i; |
2307 | int count = 0; | 2308 | int count = 0; |
2308 | while ( inc ) { | 2309 | while ( inc ) { |
2309 | newCatList.clear(); | 2310 | newCatList.clear(); |
2310 | catIncList = inc->categories() ; | 2311 | catIncList = inc->categories() ; |
2311 | for( i = 0; i< catIncList.count(); ++i ) { | 2312 | for( i = 0; i< catIncList.count(); ++i ) { |
2312 | if ( catList.contains (catIncList[i])) | 2313 | if ( catList.contains (catIncList[i])) |
2313 | newCatList.append( catIncList[i] ); | 2314 | newCatList.append( catIncList[i] ); |
2314 | } | 2315 | } |
2315 | newCatList.sort(); | 2316 | newCatList.sort(); |
2316 | inc->setCategories( newCatList.join(",") ); | 2317 | inc->setCategories( newCatList.join(",") ); |
2317 | inc = incList.next(); | 2318 | inc = incList.next(); |
2318 | } | 2319 | } |
2319 | } | 2320 | } |
2320 | 2321 | ||
2321 | int CalendarView::addCategories() | 2322 | int CalendarView::addCategories() |
2322 | { | 2323 | { |
2323 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2324 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2324 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2325 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2325 | QStringList catIncList; | 2326 | QStringList catIncList; |
2326 | Incidence* inc = incList.first(); | 2327 | Incidence* inc = incList.first(); |
2327 | int i; | 2328 | int i; |
2328 | int count = 0; | 2329 | int count = 0; |
2329 | while ( inc ) { | 2330 | while ( inc ) { |
2330 | catIncList = inc->categories() ; | 2331 | catIncList = inc->categories() ; |
2331 | for( i = 0; i< catIncList.count(); ++i ) { | 2332 | for( i = 0; i< catIncList.count(); ++i ) { |
2332 | if ( !catList.contains (catIncList[i])) { | 2333 | if ( !catList.contains (catIncList[i])) { |
2333 | catList.append( catIncList[i] ); | 2334 | catList.append( catIncList[i] ); |
2334 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2335 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2335 | ++count; | 2336 | ++count; |
2336 | } | 2337 | } |
2337 | } | 2338 | } |
2338 | inc = incList.next(); | 2339 | inc = incList.next(); |
2339 | } | 2340 | } |
2340 | catList.sort(); | 2341 | catList.sort(); |
2341 | KOPrefs::instance()->mCustomCategories = catList; | 2342 | KOPrefs::instance()->mCustomCategories = catList; |
2342 | return count; | 2343 | return count; |
2343 | } | 2344 | } |
2344 | 2345 | ||
2345 | void CalendarView::manageCategories() | 2346 | void CalendarView::manageCategories() |
2346 | { | 2347 | { |
2347 | KOCatPrefs* cp = new KOCatPrefs(); | 2348 | KOCatPrefs* cp = new KOCatPrefs(); |
2348 | cp->show(); | 2349 | cp->show(); |
2349 | int w =cp->sizeHint().width() ; | 2350 | int w =cp->sizeHint().width() ; |
2350 | int h = cp->sizeHint().height() ; | 2351 | int h = cp->sizeHint().height() ; |
2351 | int dw = QApplication::desktop()->width(); | 2352 | int dw = QApplication::desktop()->width(); |
2352 | int dh = QApplication::desktop()->height(); | 2353 | int dh = QApplication::desktop()->height(); |
2353 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2354 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2354 | if ( !cp->exec() ) { | 2355 | if ( !cp->exec() ) { |
2355 | delete cp; | 2356 | delete cp; |
2356 | return; | 2357 | return; |
2357 | } | 2358 | } |
2358 | int count = 0; | 2359 | int count = 0; |
2359 | if ( cp->addCat() ) { | 2360 | if ( cp->addCat() ) { |
2360 | count = addCategories(); | 2361 | count = addCategories(); |
2361 | if ( count ) { | 2362 | if ( count ) { |
2362 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2363 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2363 | writeSettings(); | 2364 | writeSettings(); |
2364 | } else | 2365 | } else |
2365 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2366 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2366 | } else { | 2367 | } else { |
2367 | removeCategories(); | 2368 | removeCategories(); |
2368 | updateView(); | 2369 | updateView(); |
2369 | } | 2370 | } |
2370 | delete cp; | 2371 | delete cp; |
2371 | } | 2372 | } |
2372 | 2373 | ||
2373 | void CalendarView::beamIncidence(Incidence * Inc) | 2374 | void CalendarView::beamIncidence(Incidence * Inc) |
2374 | { | 2375 | { |
2375 | QPtrList<Incidence> delSel ; | 2376 | QPtrList<Incidence> delSel ; |
2376 | delSel.append(Inc); | 2377 | delSel.append(Inc); |
2377 | beamIncidenceList( delSel ); | 2378 | beamIncidenceList( delSel ); |
2378 | } | 2379 | } |
2379 | void CalendarView::beamCalendar() | 2380 | void CalendarView::beamCalendar() |
2380 | { | 2381 | { |
2381 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2382 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2382 | //qDebug("beamCalendar() "); | 2383 | //qDebug("beamCalendar() "); |
2383 | beamIncidenceList( delSel ); | 2384 | beamIncidenceList( delSel ); |
2384 | } | 2385 | } |
2385 | void CalendarView::beamFilteredCalendar() | 2386 | void CalendarView::beamFilteredCalendar() |
2386 | { | 2387 | { |
2387 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2388 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2388 | //qDebug("beamFilteredCalendar() "); | 2389 | //qDebug("beamFilteredCalendar() "); |
2389 | beamIncidenceList( delSel ); | 2390 | beamIncidenceList( delSel ); |
2390 | } | 2391 | } |
2391 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2392 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2392 | { | 2393 | { |
2393 | if ( beamDialog->exec () == QDialog::Rejected ) | 2394 | if ( beamDialog->exec () == QDialog::Rejected ) |
2394 | return; | 2395 | return; |
2395 | #ifdef DESKTOP_VERSION | 2396 | #ifdef DESKTOP_VERSION |
2396 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2397 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2397 | #else | 2398 | #else |
2398 | QString fn = "/tmp/kopibeamfile"; | 2399 | QString fn = "/tmp/kopibeamfile"; |
2399 | #endif | 2400 | #endif |
2400 | QString mes; | 2401 | QString mes; |
2401 | bool createbup = true; | 2402 | bool createbup = true; |
2402 | if ( createbup ) { | 2403 | if ( createbup ) { |
2403 | QString description = "\n"; | 2404 | QString description = "\n"; |
2404 | CalendarLocal* cal = new CalendarLocal(); | 2405 | CalendarLocal* cal = new CalendarLocal(); |
2405 | if ( beamDialog->beamLocal() ) | 2406 | if ( beamDialog->beamLocal() ) |
2406 | cal->setLocalTime(); | 2407 | cal->setLocalTime(); |
2407 | else | 2408 | else |
2408 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2409 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2409 | Incidence *incidence = delSel.first(); | 2410 | Incidence *incidence = delSel.first(); |
2410 | bool addText = false; | 2411 | bool addText = false; |
2411 | if ( delSel.count() < 10 ) | 2412 | if ( delSel.count() < 10 ) |
2412 | addText = true; | 2413 | addText = true; |
2413 | else { | 2414 | else { |
2414 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2415 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2415 | } | 2416 | } |
2416 | while ( incidence ) { | 2417 | while ( incidence ) { |
2417 | Incidence *in = incidence->clone(); | 2418 | Incidence *in = incidence->clone(); |
2418 | if ( ! in->summary().isEmpty() ) { | 2419 | if ( ! in->summary().isEmpty() ) { |
2419 | in->setDescription(""); | 2420 | in->setDescription(""); |
2420 | } else { | 2421 | } else { |
2421 | in->setSummary( in->description().left(20)); | 2422 | in->setSummary( in->description().left(20)); |
2422 | in->setDescription(""); | 2423 | in->setDescription(""); |
2423 | } | 2424 | } |
2424 | if ( addText ) | 2425 | if ( addText ) |
2425 | description += in->summary() + "\n"; | 2426 | description += in->summary() + "\n"; |
2426 | cal->addIncidence( in ); | 2427 | cal->addIncidence( in ); |
2427 | incidence = delSel.next(); | 2428 | incidence = delSel.next(); |
2428 | } | 2429 | } |
2429 | if ( beamDialog->beamVcal() ) { | 2430 | if ( beamDialog->beamVcal() ) { |
2430 | fn += ".vcs"; | 2431 | fn += ".vcs"; |
2431 | FileStorage storage( cal, fn, new VCalFormat ); | 2432 | FileStorage storage( cal, fn, new VCalFormat ); |
2432 | storage.save(); | 2433 | storage.save(); |
2433 | } else { | 2434 | } else { |
2434 | fn += ".ics"; | 2435 | fn += ".ics"; |
2435 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2436 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2436 | storage.save(); | 2437 | storage.save(); |
2437 | } | 2438 | } |
2438 | delete cal; | 2439 | delete cal; |
2439 | mes = i18n("KO/Pi: Ready for beaming"); | 2440 | mes = i18n("KO/Pi: Ready for beaming"); |
2440 | topLevelWidget()->setCaption(mes); | 2441 | topLevelWidget()->setCaption(mes); |
2441 | KApplication::convert2latin1( fn ); | 2442 | KApplication::convert2latin1( fn ); |
2442 | #ifndef DESKTOP_VERSION | 2443 | #ifndef DESKTOP_VERSION |
2443 | Ir *ir = new Ir( this ); | 2444 | Ir *ir = new Ir( this ); |
2444 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2445 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2445 | ir->send( fn, description, "text/x-vCalendar" ); | 2446 | ir->send( fn, description, "text/x-vCalendar" ); |
2446 | #endif | 2447 | #endif |
2447 | } | 2448 | } |
2448 | } | 2449 | } |
2449 | void CalendarView::beamDone( Ir *ir ) | 2450 | void CalendarView::beamDone( Ir *ir ) |
2450 | { | 2451 | { |
2451 | #ifndef DESKTOP_VERSION | 2452 | #ifndef DESKTOP_VERSION |
2452 | delete ir; | 2453 | delete ir; |
2453 | #endif | 2454 | #endif |
2454 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2455 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2455 | topLevelWidget()->raise(); | 2456 | topLevelWidget()->raise(); |
2456 | } | 2457 | } |
2457 | 2458 | ||
2458 | void CalendarView::moveIncidence(Incidence * inc ) | 2459 | void CalendarView::moveIncidence(Incidence * inc ) |
2459 | { | 2460 | { |
2460 | if ( !inc ) return; | 2461 | if ( !inc ) return; |
2461 | // qDebug("showDatePickerForIncidence( ) "); | 2462 | // qDebug("showDatePickerForIncidence( ) "); |
2462 | if ( mDateFrame->isVisible() ) | 2463 | if ( mDateFrame->isVisible() ) |
2463 | mDateFrame->hide(); | 2464 | mDateFrame->hide(); |
2464 | else { | 2465 | else { |
2465 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2466 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2466 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2467 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2467 | int dw = QApplication::desktop()->width(); | 2468 | int dw = QApplication::desktop()->width(); |
2468 | int dh = QApplication::desktop()->height(); | 2469 | int dh = QApplication::desktop()->height(); |
2469 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2470 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2470 | mDateFrame->show(); | 2471 | mDateFrame->show(); |
2471 | } | 2472 | } |
2472 | mDatePickerMode = 2; | 2473 | mDatePickerMode = 2; |
2473 | mMoveIncidence = inc ; | 2474 | mMoveIncidence = inc ; |
2474 | QDate da; | 2475 | QDate da; |
2475 | if ( mMoveIncidence->type() == "Todo" ) { | 2476 | if ( mMoveIncidence->type() == "Todo" ) { |
2476 | Todo * to = (Todo *) mMoveIncidence; | 2477 | Todo * to = (Todo *) mMoveIncidence; |
2477 | if ( to->hasDueDate() ) | 2478 | if ( to->hasDueDate() ) |
2478 | da = to->dtDue().date(); | 2479 | da = to->dtDue().date(); |
2479 | else | 2480 | else |
2480 | da = QDate::currentDate(); | 2481 | da = QDate::currentDate(); |
2481 | } else { | 2482 | } else { |
2482 | da = mMoveIncidence->dtStart().date(); | 2483 | da = mMoveIncidence->dtStart().date(); |
2483 | } | 2484 | } |
2484 | //PENDING set date for recurring incidence to date of recurrence | 2485 | //PENDING set date for recurring incidence to date of recurrence |
2485 | //mMoveIncidenceOldDate; | 2486 | //mMoveIncidenceOldDate; |
2486 | mDatePicker->setDate( da ); | 2487 | mDatePicker->setDate( da ); |
2487 | } | 2488 | } |
2488 | void CalendarView::showDatePicker( ) | 2489 | void CalendarView::showDatePicker( ) |
2489 | { | 2490 | { |
2490 | //qDebug("CalendarView::showDatePicker( ) "); | 2491 | //qDebug("CalendarView::showDatePicker( ) "); |
2491 | if ( mDateFrame->isVisible() ) | 2492 | if ( mDateFrame->isVisible() ) |
2492 | mDateFrame->hide(); | 2493 | mDateFrame->hide(); |
2493 | else { | 2494 | else { |
2494 | int w =mDatePicker->sizeHint().width() ; | 2495 | int w =mDatePicker->sizeHint().width() ; |
2495 | int h = mDatePicker->sizeHint().height() ; | 2496 | int h = mDatePicker->sizeHint().height() ; |
2496 | int dw = QApplication::desktop()->width(); | 2497 | int dw = QApplication::desktop()->width(); |
2497 | int dh = QApplication::desktop()->height(); | 2498 | int dh = QApplication::desktop()->height(); |
2498 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2499 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2499 | mDateFrame->show(); | 2500 | mDateFrame->show(); |
2500 | } | 2501 | } |
2501 | mDatePickerMode = 1; | 2502 | mDatePickerMode = 1; |
2502 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2503 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2503 | } | 2504 | } |
2504 | 2505 | ||
2505 | void CalendarView::showEventEditor() | 2506 | void CalendarView::showEventEditor() |
2506 | { | 2507 | { |
2507 | #ifdef DESKTOP_VERSION | 2508 | #ifdef DESKTOP_VERSION |
2508 | mEventEditor->show(); | 2509 | mEventEditor->show(); |
2509 | #else | 2510 | #else |
2510 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2511 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2511 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2512 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2512 | qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2513 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2513 | delete mEventEditor; | 2514 | delete mEventEditor; |
2514 | mEventEditor = mDialogManager->getEventEditor(); | 2515 | mEventEditor = mDialogManager->getEventEditor(); |
2515 | } | 2516 | } |
2516 | mEventEditor->showMaximized(); | 2517 | mEventEditor->showMaximized(); |
2517 | topLevelWidget()->setCaption( i18n("") ); | 2518 | topLevelWidget()->setCaption( i18n("") ); |
2518 | #endif | 2519 | #endif |
2519 | } | 2520 | } |
2520 | void CalendarView::showTodoEditor() | 2521 | void CalendarView::showTodoEditor() |
2521 | { | 2522 | { |
2522 | #ifdef DESKTOP_VERSION | 2523 | #ifdef DESKTOP_VERSION |
2523 | mTodoEditor->show(); | 2524 | mTodoEditor->show(); |
2524 | #else | 2525 | #else |
2525 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2526 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2526 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2527 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2527 | qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2528 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2528 | delete mTodoEditor; | 2529 | delete mTodoEditor; |
2529 | mTodoEditor = mDialogManager->getTodoEditor(); | 2530 | mTodoEditor = mDialogManager->getTodoEditor(); |
2530 | } | 2531 | } |
2531 | mTodoEditor->showMaximized(); | 2532 | mTodoEditor->showMaximized(); |
2532 | topLevelWidget()->setCaption( i18n("") ); | 2533 | topLevelWidget()->setCaption( i18n("") ); |
2533 | #endif | 2534 | #endif |
2534 | } | 2535 | } |
2535 | 2536 | ||
2536 | void CalendarView::cloneIncidence() | 2537 | void CalendarView::cloneIncidence() |
2537 | { | 2538 | { |
2538 | Incidence *incidence = currentSelection(); | 2539 | Incidence *incidence = currentSelection(); |
2539 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2540 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2540 | if ( incidence ) { | 2541 | if ( incidence ) { |
2541 | cloneIncidence(incidence); | 2542 | cloneIncidence(incidence); |
2542 | } | 2543 | } |
2543 | } | 2544 | } |
2544 | void CalendarView::moveIncidence() | 2545 | void CalendarView::moveIncidence() |
2545 | { | 2546 | { |
2546 | Incidence *incidence = currentSelection(); | 2547 | Incidence *incidence = currentSelection(); |
2547 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2548 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2548 | if ( incidence ) { | 2549 | if ( incidence ) { |
2549 | moveIncidence(incidence); | 2550 | moveIncidence(incidence); |
2550 | } | 2551 | } |
2551 | } | 2552 | } |
2552 | void CalendarView::beamIncidence() | 2553 | void CalendarView::beamIncidence() |
2553 | { | 2554 | { |
2554 | Incidence *incidence = currentSelection(); | 2555 | Incidence *incidence = currentSelection(); |
2555 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2556 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2556 | if ( incidence ) { | 2557 | if ( incidence ) { |
2557 | beamIncidence(incidence); | 2558 | beamIncidence(incidence); |
2558 | } | 2559 | } |
2559 | } | 2560 | } |
2560 | void CalendarView::toggleCancelIncidence() | 2561 | void CalendarView::toggleCancelIncidence() |
2561 | { | 2562 | { |
2562 | Incidence *incidence = currentSelection(); | 2563 | Incidence *incidence = currentSelection(); |
2563 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2564 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2564 | if ( incidence ) { | 2565 | if ( incidence ) { |
2565 | cancelIncidence(incidence); | 2566 | cancelIncidence(incidence); |
2566 | } | 2567 | } |
2567 | } | 2568 | } |
2568 | 2569 | ||
2569 | 2570 | ||
2570 | void CalendarView::cancelIncidence(Incidence * inc ) | 2571 | void CalendarView::cancelIncidence(Incidence * inc ) |
2571 | { | 2572 | { |
2572 | inc->setCancelled( ! inc->cancelled() ); | 2573 | inc->setCancelled( ! inc->cancelled() ); |
2573 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2574 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2574 | updateView(); | 2575 | updateView(); |
2575 | } | 2576 | } |
2576 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2577 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2577 | { | 2578 | { |
2578 | Incidence * newInc = orgInc->clone(); | 2579 | Incidence * newInc = orgInc->clone(); |
2579 | newInc->recreate(); | 2580 | newInc->recreate(); |
2580 | 2581 | ||
2581 | if ( newInc->type() == "Todo" ) { | 2582 | if ( newInc->type() == "Todo" ) { |
2582 | Todo* t = (Todo*) newInc; | 2583 | Todo* t = (Todo*) newInc; |
2583 | showTodoEditor(); | 2584 | showTodoEditor(); |
2584 | mTodoEditor->editTodo( t ); | 2585 | mTodoEditor->editTodo( t ); |
2585 | if ( mTodoEditor->exec() ) { | 2586 | if ( mTodoEditor->exec() ) { |
2586 | mCalendar->addTodo( t ); | 2587 | mCalendar->addTodo( t ); |
2587 | updateView(); | 2588 | updateView(); |
2588 | } else { | 2589 | } else { |
2589 | delete t; | 2590 | delete t; |
2590 | } | 2591 | } |
2591 | } | 2592 | } |
2592 | else { | 2593 | else { |
2593 | Event* e = (Event*) newInc; | 2594 | Event* e = (Event*) newInc; |
2594 | showEventEditor(); | 2595 | showEventEditor(); |
2595 | mEventEditor->editEvent( e ); | 2596 | mEventEditor->editEvent( e ); |
2596 | if ( mEventEditor->exec() ) { | 2597 | if ( mEventEditor->exec() ) { |
2597 | mCalendar->addEvent( e ); | 2598 | mCalendar->addEvent( e ); |
2598 | updateView(); | 2599 | updateView(); |
2599 | } else { | 2600 | } else { |
2600 | delete e; | 2601 | delete e; |
2601 | } | 2602 | } |
2602 | } | 2603 | } |
2603 | } | 2604 | } |
2604 | 2605 | ||
2605 | void CalendarView::newEvent() | 2606 | void CalendarView::newEvent() |
2606 | { | 2607 | { |
2607 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2608 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2608 | KOAgendaView *aView = mViewManager->agendaView(); | 2609 | KOAgendaView *aView = mViewManager->agendaView(); |
2609 | if (aView) { | 2610 | if (aView) { |
2610 | if (aView->selectionStart().isValid()) { | 2611 | if (aView->selectionStart().isValid()) { |
2611 | if (aView->selectedIsAllDay()) { | 2612 | if (aView->selectedIsAllDay()) { |
2612 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2613 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2613 | } else { | 2614 | } else { |
2614 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2615 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2615 | } | 2616 | } |
2616 | return; | 2617 | return; |
2617 | } | 2618 | } |
2618 | } | 2619 | } |
2619 | 2620 | ||
2620 | QDate date = mNavigator->selectedDates().first(); | 2621 | QDate date = mNavigator->selectedDates().first(); |
2621 | QDateTime current = QDateTime::currentDateTime(); | 2622 | QDateTime current = QDateTime::currentDateTime(); |
2622 | if ( date <= current.date() ) { | 2623 | if ( date <= current.date() ) { |
2623 | int hour = current.time().hour() +1; | 2624 | int hour = current.time().hour() +1; |
2624 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2625 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2625 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2626 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2626 | } else | 2627 | } else |
2627 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2628 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2628 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2629 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2629 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2630 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2630 | } | 2631 | } |
2631 | 2632 | ||
2632 | void CalendarView::newEvent(QDateTime fh) | 2633 | void CalendarView::newEvent(QDateTime fh) |
2633 | { | 2634 | { |
2634 | newEvent(fh, | 2635 | newEvent(fh, |
2635 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2636 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2636 | } | 2637 | } |
2637 | 2638 | ||
2638 | void CalendarView::newEvent(QDate dt) | 2639 | void CalendarView::newEvent(QDate dt) |
2639 | { | 2640 | { |
2640 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2641 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2641 | QDateTime(dt, QTime(0,0,0)), true); | 2642 | QDateTime(dt, QTime(0,0,0)), true); |
2642 | } | 2643 | } |
2643 | 2644 | ||
2644 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2645 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2645 | { | 2646 | { |
2646 | 2647 | ||
2647 | showEventEditor(); | 2648 | showEventEditor(); |
2648 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2649 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2649 | if ( mFilterView->filtersEnabled() ) { | 2650 | if ( mFilterView->filtersEnabled() ) { |
2650 | CalFilter *filter = mFilterView->selectedFilter(); | 2651 | CalFilter *filter = mFilterView->selectedFilter(); |
2651 | if (filter && filter->showCategories()) { | 2652 | if (filter && filter->showCategories()) { |
2652 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2653 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2653 | } | 2654 | } |
2654 | if ( filter ) | 2655 | if ( filter ) |
2655 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2656 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2656 | } | 2657 | } |
2657 | } | 2658 | } |
2658 | void CalendarView::todoAdded(Todo * t) | 2659 | void CalendarView::todoAdded(Todo * t) |
2659 | { | 2660 | { |
2660 | 2661 | ||
2661 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2662 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2662 | updateTodoViews(); | 2663 | updateTodoViews(); |
2663 | } | 2664 | } |
2664 | void CalendarView::todoChanged(Todo * t) | 2665 | void CalendarView::todoChanged(Todo * t) |
2665 | { | 2666 | { |
2666 | emit todoModified( t, 4 ); | 2667 | emit todoModified( t, 4 ); |
2667 | // updateTodoViews(); | 2668 | // updateTodoViews(); |
2668 | } | 2669 | } |
2669 | void CalendarView::todoToBeDeleted(Todo *) | 2670 | void CalendarView::todoToBeDeleted(Todo *) |
2670 | { | 2671 | { |
2671 | //qDebug("todoToBeDeleted(Todo *) "); | 2672 | //qDebug("todoToBeDeleted(Todo *) "); |
2672 | updateTodoViews(); | 2673 | updateTodoViews(); |
2673 | } | 2674 | } |
2674 | void CalendarView::todoDeleted() | 2675 | void CalendarView::todoDeleted() |
2675 | { | 2676 | { |
2676 | //qDebug(" todoDeleted()"); | 2677 | //qDebug(" todoDeleted()"); |
2677 | updateTodoViews(); | 2678 | updateTodoViews(); |
2678 | } | 2679 | } |
2679 | 2680 | ||
2680 | 2681 | ||
2681 | 2682 | ||
2682 | void CalendarView::newTodo() | 2683 | void CalendarView::newTodo() |
2683 | { | 2684 | { |
2684 | 2685 | ||
2685 | showTodoEditor(); | 2686 | showTodoEditor(); |
2686 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2687 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2687 | if ( mFilterView->filtersEnabled() ) { | 2688 | if ( mFilterView->filtersEnabled() ) { |
2688 | CalFilter *filter = mFilterView->selectedFilter(); | 2689 | CalFilter *filter = mFilterView->selectedFilter(); |
2689 | if (filter && filter->showCategories()) { | 2690 | if (filter && filter->showCategories()) { |
2690 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2691 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2691 | } | 2692 | } |
2692 | if ( filter ) | 2693 | if ( filter ) |
2693 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2694 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2694 | } | 2695 | } |
2695 | } | 2696 | } |
2696 | 2697 | ||
2697 | void CalendarView::newSubTodo() | 2698 | void CalendarView::newSubTodo() |
2698 | { | 2699 | { |
2699 | Todo *todo = selectedTodo(); | 2700 | Todo *todo = selectedTodo(); |
2700 | if ( todo ) newSubTodo( todo ); | 2701 | if ( todo ) newSubTodo( todo ); |
2701 | } | 2702 | } |
2702 | 2703 | ||
2703 | void CalendarView::newSubTodo(Todo *parentEvent) | 2704 | void CalendarView::newSubTodo(Todo *parentEvent) |
2704 | { | 2705 | { |
2705 | 2706 | ||
2706 | showTodoEditor(); | 2707 | showTodoEditor(); |
2707 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2708 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2708 | } | 2709 | } |
2709 | 2710 | ||
2710 | void CalendarView::newFloatingEvent() | 2711 | void CalendarView::newFloatingEvent() |
2711 | { | 2712 | { |
2712 | DateList tmpList = mNavigator->selectedDates(); | 2713 | DateList tmpList = mNavigator->selectedDates(); |
2713 | QDate date = tmpList.first(); | 2714 | QDate date = tmpList.first(); |
2714 | 2715 | ||
2715 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2716 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2716 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2717 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2717 | } | 2718 | } |
2718 | 2719 | ||
2719 | 2720 | ||
2720 | void CalendarView::editEvent( Event *event ) | 2721 | void CalendarView::editEvent( Event *event ) |
2721 | { | 2722 | { |
2722 | 2723 | ||
2723 | if ( !event ) return; | 2724 | if ( !event ) return; |
2724 | if ( event->isReadOnly() ) { | 2725 | if ( event->isReadOnly() ) { |
2725 | showEvent( event ); | 2726 | showEvent( event ); |
2726 | return; | 2727 | return; |
2727 | } | 2728 | } |
2728 | showEventEditor(); | 2729 | showEventEditor(); |
2729 | mEventEditor->editEvent( event , mFlagEditDescription); | 2730 | mEventEditor->editEvent( event , mFlagEditDescription); |
2730 | } | 2731 | } |
2731 | void CalendarView::editJournal( Journal *jour ) | 2732 | void CalendarView::editJournal( Journal *jour ) |
2732 | { | 2733 | { |
2733 | if ( !jour ) return; | 2734 | if ( !jour ) return; |
2734 | mDialogManager->hideSearchDialog(); | 2735 | mDialogManager->hideSearchDialog(); |
2735 | mViewManager->showJournalView(); | 2736 | mViewManager->showJournalView(); |
2736 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2737 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2737 | } | 2738 | } |
2738 | void CalendarView::editTodo( Todo *todo ) | 2739 | void CalendarView::editTodo( Todo *todo ) |
2739 | { | 2740 | { |
2740 | if ( !todo ) return; | 2741 | if ( !todo ) return; |
2741 | 2742 | ||
2742 | if ( todo->isReadOnly() ) { | 2743 | if ( todo->isReadOnly() ) { |
2743 | showTodo( todo ); | 2744 | showTodo( todo ); |
2744 | return; | 2745 | return; |
2745 | } | 2746 | } |
2746 | showTodoEditor(); | 2747 | showTodoEditor(); |
2747 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2748 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2748 | 2749 | ||
2749 | } | 2750 | } |
2750 | 2751 | ||
2751 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2752 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2752 | { | 2753 | { |
2753 | if ( !mEventViewerDialog ) { | 2754 | if ( !mEventViewerDialog ) { |
2754 | mEventViewerDialog = new KOEventViewerDialog(this); | 2755 | mEventViewerDialog = new KOEventViewerDialog(this); |
2755 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2756 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2756 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2757 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2757 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2758 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2758 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2759 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2759 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2760 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2760 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2761 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2761 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2762 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2762 | this, SLOT( todoChanged(Todo *) ) ); | 2763 | this, SLOT( todoChanged(Todo *) ) ); |
2763 | mEventViewerDialog->resize( 640, 480 ); | 2764 | mEventViewerDialog->resize( 640, 480 ); |
2764 | 2765 | ||
2765 | } | 2766 | } |
2766 | return mEventViewerDialog; | 2767 | return mEventViewerDialog; |
2767 | } | 2768 | } |
2768 | void CalendarView::showEvent(Event *event) | 2769 | void CalendarView::showEvent(Event *event) |
2769 | { | 2770 | { |
2770 | getEventViewerDialog()->setEvent(event); | 2771 | getEventViewerDialog()->setEvent(event); |
2771 | getEventViewerDialog()->showMe(); | 2772 | getEventViewerDialog()->showMe(); |
2772 | } | 2773 | } |
2773 | 2774 | ||
2774 | void CalendarView::showTodo(Todo *event) | 2775 | void CalendarView::showTodo(Todo *event) |
2775 | { | 2776 | { |
2776 | getEventViewerDialog()->setTodo(event); | 2777 | getEventViewerDialog()->setTodo(event); |
2777 | getEventViewerDialog()->showMe(); | 2778 | getEventViewerDialog()->showMe(); |
2778 | } | 2779 | } |
2779 | void CalendarView::showJournal( Journal *jour ) | 2780 | void CalendarView::showJournal( Journal *jour ) |
2780 | { | 2781 | { |
2781 | getEventViewerDialog()->setJournal(jour); | 2782 | getEventViewerDialog()->setJournal(jour); |
2782 | getEventViewerDialog()->showMe(); | 2783 | getEventViewerDialog()->showMe(); |
2783 | 2784 | ||
2784 | } | 2785 | } |
2785 | // void CalendarView::todoModified (Todo *event, int changed) | 2786 | // void CalendarView::todoModified (Todo *event, int changed) |
2786 | // { | 2787 | // { |
2787 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2788 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2788 | // // kdDebug() << "Todo modified and open" << endl; | 2789 | // // kdDebug() << "Todo modified and open" << endl; |
2789 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2790 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2790 | // // temp->modified (changed); | 2791 | // // temp->modified (changed); |
2791 | 2792 | ||
2792 | // // } | 2793 | // // } |
2793 | 2794 | ||
2794 | // mViewManager->updateView(); | 2795 | // mViewManager->updateView(); |
2795 | // } | 2796 | // } |
2796 | 2797 | ||
2797 | void CalendarView::appointment_show() | 2798 | void CalendarView::appointment_show() |
2798 | { | 2799 | { |
2799 | Event *anEvent = 0; | 2800 | Event *anEvent = 0; |
2800 | 2801 | ||
2801 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2802 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2802 | 2803 | ||
2803 | if (mViewManager->currentView()->isEventView()) { | 2804 | if (mViewManager->currentView()->isEventView()) { |
2804 | if ( incidence && incidence->type() == "Event" ) { | 2805 | if ( incidence && incidence->type() == "Event" ) { |
2805 | anEvent = static_cast<Event *>(incidence); | 2806 | anEvent = static_cast<Event *>(incidence); |
2806 | } | 2807 | } |
2807 | } | 2808 | } |
2808 | 2809 | ||
2809 | if (!anEvent) { | 2810 | if (!anEvent) { |
2810 | KNotifyClient::beep(); | 2811 | KNotifyClient::beep(); |
2811 | return; | 2812 | return; |
2812 | } | 2813 | } |
2813 | 2814 | ||
2814 | showEvent(anEvent); | 2815 | showEvent(anEvent); |
2815 | } | 2816 | } |
2816 | 2817 | ||
2817 | void CalendarView::appointment_edit() | 2818 | void CalendarView::appointment_edit() |
2818 | { | 2819 | { |
2819 | Event *anEvent = 0; | 2820 | Event *anEvent = 0; |
2820 | 2821 | ||
2821 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2822 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2822 | 2823 | ||
2823 | if (mViewManager->currentView()->isEventView()) { | 2824 | if (mViewManager->currentView()->isEventView()) { |
2824 | if ( incidence && incidence->type() == "Event" ) { | 2825 | if ( incidence && incidence->type() == "Event" ) { |
2825 | anEvent = static_cast<Event *>(incidence); | 2826 | anEvent = static_cast<Event *>(incidence); |
2826 | } | 2827 | } |
2827 | } | 2828 | } |
2828 | 2829 | ||
2829 | if (!anEvent) { | 2830 | if (!anEvent) { |
2830 | KNotifyClient::beep(); | 2831 | KNotifyClient::beep(); |
2831 | return; | 2832 | return; |
2832 | } | 2833 | } |
2833 | 2834 | ||
2834 | editEvent(anEvent); | 2835 | editEvent(anEvent); |
2835 | } | 2836 | } |
2836 | 2837 | ||
2837 | void CalendarView::appointment_delete() | 2838 | void CalendarView::appointment_delete() |
2838 | { | 2839 | { |
2839 | Event *anEvent = 0; | 2840 | Event *anEvent = 0; |
2840 | 2841 | ||
2841 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2842 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2842 | 2843 | ||
2843 | if (mViewManager->currentView()->isEventView()) { | 2844 | if (mViewManager->currentView()->isEventView()) { |
2844 | if ( incidence && incidence->type() == "Event" ) { | 2845 | if ( incidence && incidence->type() == "Event" ) { |
2845 | anEvent = static_cast<Event *>(incidence); | 2846 | anEvent = static_cast<Event *>(incidence); |
2846 | } | 2847 | } |
2847 | } | 2848 | } |
2848 | 2849 | ||
2849 | if (!anEvent) { | 2850 | if (!anEvent) { |
2850 | KNotifyClient::beep(); | 2851 | KNotifyClient::beep(); |
2851 | return; | 2852 | return; |
2852 | } | 2853 | } |
2853 | 2854 | ||
2854 | deleteEvent(anEvent); | 2855 | deleteEvent(anEvent); |
2855 | } | 2856 | } |
2856 | 2857 | ||
2857 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2858 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2858 | { | 2859 | { |
2859 | if (!sub) return; | 2860 | if (!sub) return; |
2860 | if (!parent) return; | 2861 | if (!parent) return; |
2861 | if ( sub->relatedTo() ) | 2862 | if ( sub->relatedTo() ) |
2862 | sub->relatedTo()->removeRelation(sub); | 2863 | sub->relatedTo()->removeRelation(sub); |
2863 | sub->setRelatedTo(parent); | 2864 | sub->setRelatedTo(parent); |
2864 | sub->setRelatedToUid(parent->uid()); | 2865 | sub->setRelatedToUid(parent->uid()); |
2865 | parent->addRelation(sub); | 2866 | parent->addRelation(sub); |
2866 | sub->updated(); | 2867 | sub->updated(); |
2867 | parent->updated(); | 2868 | parent->updated(); |
2868 | setModified(true); | 2869 | setModified(true); |
2869 | updateView(); | 2870 | updateView(); |
2870 | } | 2871 | } |
2871 | void CalendarView::todo_unsub(Todo *anTodo ) | 2872 | void CalendarView::todo_unsub(Todo *anTodo ) |
2872 | { | 2873 | { |
2873 | // Todo *anTodo = selectedTodo(); | 2874 | // Todo *anTodo = selectedTodo(); |
2874 | if (!anTodo) return; | 2875 | if (!anTodo) return; |
2875 | if (!anTodo->relatedTo()) return; | 2876 | if (!anTodo->relatedTo()) return; |
2876 | anTodo->relatedTo()->removeRelation(anTodo); | 2877 | anTodo->relatedTo()->removeRelation(anTodo); |
2877 | anTodo->setRelatedTo(0); | 2878 | anTodo->setRelatedTo(0); |
2878 | anTodo->updated(); | 2879 | anTodo->updated(); |
2879 | anTodo->setRelatedToUid(""); | 2880 | anTodo->setRelatedToUid(""); |
2880 | setModified(true); | 2881 | setModified(true); |
2881 | updateView(); | 2882 | updateView(); |
2882 | } | 2883 | } |
2883 | 2884 | ||
2884 | void CalendarView::deleteTodo(Todo *todo) | 2885 | void CalendarView::deleteTodo(Todo *todo) |
2885 | { | 2886 | { |
2886 | if (!todo) { | 2887 | if (!todo) { |
2887 | KNotifyClient::beep(); | 2888 | KNotifyClient::beep(); |
2888 | return; | 2889 | return; |
2889 | } | 2890 | } |
2890 | if (KOPrefs::instance()->mConfirm) { | 2891 | if (KOPrefs::instance()->mConfirm) { |
2891 | QString text = todo->summary().left(20); | 2892 | QString text = todo->summary().left(20); |
2892 | if (!todo->relations().isEmpty()) { | 2893 | if (!todo->relations().isEmpty()) { |
2893 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 2894 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
2894 | 2895 | ||
2895 | } | 2896 | } |
2896 | switch (msgItemDelete(text)) { | 2897 | switch (msgItemDelete(text)) { |
2897 | case KMessageBox::Continue: // OK | 2898 | case KMessageBox::Continue: // OK |
2898 | bool deleteT = false; | 2899 | bool deleteT = false; |
2899 | if (!todo->relations().isEmpty()) { | 2900 | if (!todo->relations().isEmpty()) { |
2900 | deleteT = removeCompletedSubTodos( todo ); | 2901 | deleteT = removeCompletedSubTodos( todo ); |
2901 | } | 2902 | } |
2902 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 2903 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
2903 | if ( !deleteT ) { | 2904 | if ( !deleteT ) { |
2904 | checkExternalId( todo ); | 2905 | checkExternalId( todo ); |
2905 | calendar()->deleteTodo(todo); | 2906 | calendar()->deleteTodo(todo); |
2906 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2907 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2907 | updateView(); | 2908 | updateView(); |
2908 | } | 2909 | } |
2909 | break; | 2910 | break; |
2910 | } // switch | 2911 | } // switch |
2911 | } else { | 2912 | } else { |
2912 | checkExternalId( todo ); | 2913 | checkExternalId( todo ); |
2913 | mCalendar->deleteTodo(todo); | 2914 | mCalendar->deleteTodo(todo); |
2914 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2915 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2915 | updateView(); | 2916 | updateView(); |
2916 | } | 2917 | } |
2917 | 2918 | ||
2918 | emit updateSearchDialog(); | 2919 | emit updateSearchDialog(); |
2919 | } | 2920 | } |
2920 | void CalendarView::deleteJournal(Journal *jour) | 2921 | void CalendarView::deleteJournal(Journal *jour) |
2921 | { | 2922 | { |
2922 | if (!jour) { | 2923 | if (!jour) { |
2923 | KNotifyClient::beep(); | 2924 | KNotifyClient::beep(); |
2924 | return; | 2925 | return; |
2925 | } | 2926 | } |
2926 | if (KOPrefs::instance()->mConfirm) { | 2927 | if (KOPrefs::instance()->mConfirm) { |
2927 | switch (msgItemDelete( jour->description().left(20))) { | 2928 | switch (msgItemDelete( jour->description().left(20))) { |
2928 | case KMessageBox::Continue: // OK | 2929 | case KMessageBox::Continue: // OK |
2929 | calendar()->deleteJournal(jour); | 2930 | calendar()->deleteJournal(jour); |
2930 | updateView(); | 2931 | updateView(); |
2931 | break; | 2932 | break; |
2932 | } // switch | 2933 | } // switch |
2933 | } else { | 2934 | } else { |
2934 | calendar()->deleteJournal(jour);; | 2935 | calendar()->deleteJournal(jour);; |
2935 | updateView(); | 2936 | updateView(); |
2936 | } | 2937 | } |
2937 | emit updateSearchDialog(); | 2938 | emit updateSearchDialog(); |
2938 | } | 2939 | } |
2939 | 2940 | ||
2940 | void CalendarView::deleteEvent(Event *anEvent) | 2941 | void CalendarView::deleteEvent(Event *anEvent) |
2941 | { | 2942 | { |
2942 | if (!anEvent) { | 2943 | if (!anEvent) { |
2943 | KNotifyClient::beep(); | 2944 | KNotifyClient::beep(); |
2944 | return; | 2945 | return; |
2945 | } | 2946 | } |
2946 | 2947 | ||
2947 | if (anEvent->recurrence()->doesRecur()) { | 2948 | if (anEvent->recurrence()->doesRecur()) { |
2948 | QDate itemDate = mViewManager->currentSelectionDate(); | 2949 | QDate itemDate = mViewManager->currentSelectionDate(); |
2949 | int km; | 2950 | int km; |
2950 | if (!itemDate.isValid()) { | 2951 | if (!itemDate.isValid()) { |
2951 | //kdDebug() << "Date Not Valid" << endl; | 2952 | //kdDebug() << "Date Not Valid" << endl; |
2952 | if (KOPrefs::instance()->mConfirm) { | 2953 | if (KOPrefs::instance()->mConfirm) { |
2953 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 2954 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2954 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2955 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2955 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2956 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2956 | if ( km == KMessageBox::Continue ) | 2957 | if ( km == KMessageBox::Continue ) |
2957 | km = KMessageBox::No; // No = all below | 2958 | km = KMessageBox::No; // No = all below |
2958 | } else | 2959 | } else |
2959 | km = KMessageBox::No; | 2960 | km = KMessageBox::No; |
2960 | } else { | 2961 | } else { |
2961 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 2962 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
2962 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2963 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2963 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2964 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2964 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2965 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2965 | i18n("All")); | 2966 | i18n("All")); |
2966 | } | 2967 | } |
2967 | switch(km) { | 2968 | switch(km) { |
2968 | 2969 | ||
2969 | case KMessageBox::No: // Continue // all | 2970 | case KMessageBox::No: // Continue // all |
2970 | //qDebug("KMessageBox::No "); | 2971 | //qDebug("KMessageBox::No "); |
2971 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2972 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2972 | schedule(Scheduler::Cancel,anEvent); | 2973 | schedule(Scheduler::Cancel,anEvent); |
2973 | 2974 | ||
2974 | checkExternalId( anEvent); | 2975 | checkExternalId( anEvent); |
2975 | mCalendar->deleteEvent(anEvent); | 2976 | mCalendar->deleteEvent(anEvent); |
2976 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2977 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2977 | break; | 2978 | break; |
2978 | 2979 | ||
2979 | // Disabled because it does not work | 2980 | // Disabled because it does not work |
2980 | //#if 0 | 2981 | //#if 0 |
2981 | case KMessageBox::Yes: // just this one | 2982 | case KMessageBox::Yes: // just this one |
2982 | //QDate qd = mNavigator->selectedDates().first(); | 2983 | //QDate qd = mNavigator->selectedDates().first(); |
2983 | //if (!qd.isValid()) { | 2984 | //if (!qd.isValid()) { |
2984 | // kdDebug() << "no date selected, or invalid date" << endl; | 2985 | // kdDebug() << "no date selected, or invalid date" << endl; |
2985 | // KNotifyClient::beep(); | 2986 | // KNotifyClient::beep(); |
2986 | // return; | 2987 | // return; |
2987 | //} | 2988 | //} |
2988 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2989 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2989 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2990 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2990 | anEvent->addExDate(itemDate); | 2991 | anEvent->addExDate(itemDate); |
2991 | int duration = anEvent->recurrence()->duration(); | 2992 | int duration = anEvent->recurrence()->duration(); |
2992 | if ( duration > 0 ) { | 2993 | if ( duration > 0 ) { |
2993 | anEvent->recurrence()->setDuration( duration - 1 ); | 2994 | anEvent->recurrence()->setDuration( duration - 1 ); |
2994 | } | 2995 | } |
2995 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2996 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2996 | } | 2997 | } |
2997 | break; | 2998 | break; |
2998 | //#endif | 2999 | //#endif |
2999 | } // switch | 3000 | } // switch |
3000 | } else { | 3001 | } else { |
3001 | if (KOPrefs::instance()->mConfirm) { | 3002 | if (KOPrefs::instance()->mConfirm) { |
3002 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3003 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3003 | i18n("\nAre you sure you want\nto delete this event?"), | 3004 | i18n("\nAre you sure you want\nto delete this event?"), |
3004 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3005 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3005 | case KMessageBox::Continue: // OK | 3006 | case KMessageBox::Continue: // OK |
3006 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3007 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3007 | schedule(Scheduler::Cancel,anEvent); | 3008 | schedule(Scheduler::Cancel,anEvent); |
3008 | checkExternalId( anEvent); | 3009 | checkExternalId( anEvent); |
3009 | mCalendar->deleteEvent(anEvent); | 3010 | mCalendar->deleteEvent(anEvent); |
3010 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3011 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3011 | break; | 3012 | break; |
3012 | } // switch | 3013 | } // switch |
3013 | } else { | 3014 | } else { |
3014 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3015 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3015 | schedule(Scheduler::Cancel,anEvent); | 3016 | schedule(Scheduler::Cancel,anEvent); |
3016 | checkExternalId( anEvent); | 3017 | checkExternalId( anEvent); |
3017 | mCalendar->deleteEvent(anEvent); | 3018 | mCalendar->deleteEvent(anEvent); |
3018 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3019 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3019 | } | 3020 | } |
3020 | } // if-else | 3021 | } // if-else |
3021 | emit updateSearchDialog(); | 3022 | emit updateSearchDialog(); |
3022 | } | 3023 | } |
3023 | 3024 | ||
3024 | bool CalendarView::deleteEvent(const QString &uid) | 3025 | bool CalendarView::deleteEvent(const QString &uid) |
3025 | { | 3026 | { |
3026 | Event *ev = mCalendar->event(uid); | 3027 | Event *ev = mCalendar->event(uid); |
3027 | if (ev) { | 3028 | if (ev) { |
3028 | deleteEvent(ev); | 3029 | deleteEvent(ev); |
3029 | return true; | 3030 | return true; |
3030 | } else { | 3031 | } else { |
3031 | return false; | 3032 | return false; |
3032 | } | 3033 | } |
3033 | } | 3034 | } |
3034 | 3035 | ||
3035 | /*****************************************************************************/ | 3036 | /*****************************************************************************/ |
3036 | 3037 | ||
3037 | void CalendarView::action_mail() | 3038 | void CalendarView::action_mail() |
3038 | { | 3039 | { |
3039 | #ifndef KORG_NOMAIL | 3040 | #ifndef KORG_NOMAIL |
3040 | KOMailClient mailClient; | 3041 | KOMailClient mailClient; |
3041 | 3042 | ||
3042 | Incidence *incidence = currentSelection(); | 3043 | Incidence *incidence = currentSelection(); |
3043 | 3044 | ||
3044 | if (!incidence) { | 3045 | if (!incidence) { |
3045 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3046 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3046 | return; | 3047 | return; |
3047 | } | 3048 | } |
3048 | if(incidence->attendeeCount() == 0 ) { | 3049 | if(incidence->attendeeCount() == 0 ) { |
3049 | KMessageBox::sorry(this, | 3050 | KMessageBox::sorry(this, |
3050 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3051 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3051 | return; | 3052 | return; |
3052 | } | 3053 | } |
3053 | 3054 | ||
3054 | CalendarLocal cal_tmp; | 3055 | CalendarLocal cal_tmp; |
3055 | Event *event = 0; | 3056 | Event *event = 0; |
3056 | Event *ev = 0; | 3057 | Event *ev = 0; |
3057 | if ( incidence && incidence->type() == "Event" ) { | 3058 | if ( incidence && incidence->type() == "Event" ) { |
3058 | event = static_cast<Event *>(incidence); | 3059 | event = static_cast<Event *>(incidence); |
3059 | ev = new Event(*event); | 3060 | ev = new Event(*event); |
3060 | cal_tmp.addEvent(ev); | 3061 | cal_tmp.addEvent(ev); |
3061 | } | 3062 | } |
3062 | ICalFormat mForm(); | 3063 | ICalFormat mForm(); |
3063 | QString attachment = mForm.toString( &cal_tmp ); | 3064 | QString attachment = mForm.toString( &cal_tmp ); |
3064 | if (ev) delete(ev); | 3065 | if (ev) delete(ev); |
3065 | 3066 | ||
3066 | mailClient.mailAttendees(currentSelection(), attachment); | 3067 | mailClient.mailAttendees(currentSelection(), attachment); |
3067 | 3068 | ||
3068 | #endif | 3069 | #endif |
3069 | 3070 | ||
3070 | #if 0 | 3071 | #if 0 |
3071 | Event *anEvent = 0; | 3072 | Event *anEvent = 0; |
3072 | if (mViewManager->currentView()->isEventView()) { | 3073 | if (mViewManager->currentView()->isEventView()) { |
3073 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3074 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3074 | } | 3075 | } |
3075 | 3076 | ||
3076 | if (!anEvent) { | 3077 | if (!anEvent) { |
3077 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3078 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3078 | return; | 3079 | return; |
3079 | } | 3080 | } |
3080 | if(anEvent->attendeeCount() == 0 ) { | 3081 | if(anEvent->attendeeCount() == 0 ) { |
3081 | KMessageBox::sorry(this, | 3082 | KMessageBox::sorry(this, |
3082 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3083 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3083 | return; | 3084 | return; |
3084 | } | 3085 | } |
3085 | 3086 | ||
3086 | mailobject.emailEvent(anEvent); | 3087 | mailobject.emailEvent(anEvent); |
3087 | #endif | 3088 | #endif |
3088 | } | 3089 | } |
3089 | 3090 | ||
3090 | 3091 | ||
3091 | void CalendarView::schedule_publish(Incidence *incidence) | 3092 | void CalendarView::schedule_publish(Incidence *incidence) |
3092 | { | 3093 | { |
3093 | Event *event = 0; | 3094 | Event *event = 0; |
3094 | Todo *todo = 0; | 3095 | Todo *todo = 0; |
3095 | 3096 | ||
3096 | if (incidence == 0) { | 3097 | if (incidence == 0) { |
3097 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3098 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3098 | if (incidence == 0) { | 3099 | if (incidence == 0) { |
3099 | incidence = mTodoList->selectedIncidences().first(); | 3100 | incidence = mTodoList->selectedIncidences().first(); |
3100 | } | 3101 | } |
3101 | } | 3102 | } |
3102 | if ( incidence && incidence->type() == "Event" ) { | 3103 | if ( incidence && incidence->type() == "Event" ) { |
3103 | event = static_cast<Event *>(incidence); | 3104 | event = static_cast<Event *>(incidence); |
3104 | } else { | 3105 | } else { |
3105 | if ( incidence && incidence->type() == "Todo" ) { | 3106 | if ( incidence && incidence->type() == "Todo" ) { |
3106 | todo = static_cast<Todo *>(incidence); | 3107 | todo = static_cast<Todo *>(incidence); |
3107 | } | 3108 | } |
3108 | } | 3109 | } |
3109 | 3110 | ||
3110 | if (!event && !todo) { | 3111 | if (!event && !todo) { |
3111 | KMessageBox::sorry(this,i18n("No event selected.")); | 3112 | KMessageBox::sorry(this,i18n("No event selected.")); |
3112 | return; | 3113 | return; |
3113 | } | 3114 | } |
3114 | 3115 | ||
3115 | PublishDialog *publishdlg = new PublishDialog(); | 3116 | PublishDialog *publishdlg = new PublishDialog(); |
3116 | if (incidence->attendeeCount()>0) { | 3117 | if (incidence->attendeeCount()>0) { |
3117 | QPtrList<Attendee> attendees = incidence->attendees(); | 3118 | QPtrList<Attendee> attendees = incidence->attendees(); |
3118 | attendees.first(); | 3119 | attendees.first(); |
3119 | while ( attendees.current()!=0 ) { | 3120 | while ( attendees.current()!=0 ) { |
3120 | publishdlg->addAttendee(attendees.current()); | 3121 | publishdlg->addAttendee(attendees.current()); |
3121 | attendees.next(); | 3122 | attendees.next(); |
3122 | } | 3123 | } |
3123 | } | 3124 | } |
3124 | bool send = true; | 3125 | bool send = true; |
3125 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3126 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3126 | if ( publishdlg->exec() != QDialog::Accepted ) | 3127 | if ( publishdlg->exec() != QDialog::Accepted ) |
3127 | send = false; | 3128 | send = false; |
3128 | } | 3129 | } |
3129 | if ( send ) { | 3130 | if ( send ) { |
3130 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3131 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3131 | if ( event ) { | 3132 | if ( event ) { |
3132 | Event *ev = new Event(*event); | 3133 | Event *ev = new Event(*event); |
3133 | ev->registerObserver(0); | 3134 | ev->registerObserver(0); |
3134 | ev->clearAttendees(); | 3135 | ev->clearAttendees(); |
3135 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3136 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3136 | delete(ev); | 3137 | delete(ev); |
3137 | } | 3138 | } |
3138 | } else { | 3139 | } else { |
3139 | if ( todo ) { | 3140 | if ( todo ) { |
3140 | Todo *ev = new Todo(*todo); | 3141 | Todo *ev = new Todo(*todo); |
3141 | ev->registerObserver(0); | 3142 | ev->registerObserver(0); |
3142 | ev->clearAttendees(); | 3143 | ev->clearAttendees(); |
3143 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3144 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3144 | delete(ev); | 3145 | delete(ev); |
3145 | } | 3146 | } |
3146 | } | 3147 | } |
3147 | } | 3148 | } |
3148 | } | 3149 | } |
3149 | delete publishdlg; | 3150 | delete publishdlg; |
3150 | } | 3151 | } |
3151 | 3152 | ||
3152 | void CalendarView::schedule_request(Incidence *incidence) | 3153 | void CalendarView::schedule_request(Incidence *incidence) |
3153 | { | 3154 | { |
3154 | schedule(Scheduler::Request,incidence); | 3155 | schedule(Scheduler::Request,incidence); |
3155 | } | 3156 | } |
3156 | 3157 | ||
3157 | void CalendarView::schedule_refresh(Incidence *incidence) | 3158 | void CalendarView::schedule_refresh(Incidence *incidence) |
3158 | { | 3159 | { |
3159 | schedule(Scheduler::Refresh,incidence); | 3160 | schedule(Scheduler::Refresh,incidence); |
3160 | } | 3161 | } |
3161 | 3162 | ||
3162 | void CalendarView::schedule_cancel(Incidence *incidence) | 3163 | void CalendarView::schedule_cancel(Incidence *incidence) |
3163 | { | 3164 | { |
3164 | schedule(Scheduler::Cancel,incidence); | 3165 | schedule(Scheduler::Cancel,incidence); |
3165 | } | 3166 | } |
3166 | 3167 | ||
3167 | void CalendarView::schedule_add(Incidence *incidence) | 3168 | void CalendarView::schedule_add(Incidence *incidence) |
3168 | { | 3169 | { |
3169 | schedule(Scheduler::Add,incidence); | 3170 | schedule(Scheduler::Add,incidence); |
3170 | } | 3171 | } |
3171 | 3172 | ||
3172 | void CalendarView::schedule_reply(Incidence *incidence) | 3173 | void CalendarView::schedule_reply(Incidence *incidence) |
3173 | { | 3174 | { |
3174 | schedule(Scheduler::Reply,incidence); | 3175 | schedule(Scheduler::Reply,incidence); |
3175 | } | 3176 | } |
3176 | 3177 | ||
3177 | void CalendarView::schedule_counter(Incidence *incidence) | 3178 | void CalendarView::schedule_counter(Incidence *incidence) |
3178 | { | 3179 | { |
3179 | schedule(Scheduler::Counter,incidence); | 3180 | schedule(Scheduler::Counter,incidence); |
3180 | } | 3181 | } |
3181 | 3182 | ||
3182 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3183 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3183 | { | 3184 | { |
3184 | schedule(Scheduler::Declinecounter,incidence); | 3185 | schedule(Scheduler::Declinecounter,incidence); |
3185 | } | 3186 | } |
3186 | 3187 | ||
3187 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3188 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3188 | { | 3189 | { |
3189 | QDateTime start = QDateTime::currentDateTime(); | 3190 | QDateTime start = QDateTime::currentDateTime(); |
3190 | QDateTime end = start.addDays(daysToPublish); | 3191 | QDateTime end = start.addDays(daysToPublish); |
3191 | 3192 | ||
3192 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3193 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3193 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3194 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3194 | 3195 | ||
3195 | 3196 | ||
3196 | PublishDialog *publishdlg = new PublishDialog(); | 3197 | PublishDialog *publishdlg = new PublishDialog(); |
3197 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3198 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3198 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3199 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3199 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3200 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3200 | delete(freebusy); | 3201 | delete(freebusy); |
3201 | } | 3202 | } |
3202 | } | 3203 | } |
3203 | delete publishdlg; | 3204 | delete publishdlg; |
3204 | } | 3205 | } |
3205 | 3206 | ||
3206 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3207 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3207 | { | 3208 | { |
3208 | Event *event = 0; | 3209 | Event *event = 0; |
3209 | Todo *todo = 0; | 3210 | Todo *todo = 0; |
3210 | 3211 | ||
3211 | if (incidence == 0) { | 3212 | if (incidence == 0) { |
3212 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3213 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3213 | if (incidence == 0) { | 3214 | if (incidence == 0) { |
3214 | incidence = mTodoList->selectedIncidences().first(); | 3215 | incidence = mTodoList->selectedIncidences().first(); |
3215 | } | 3216 | } |
3216 | } | 3217 | } |
3217 | if ( incidence && incidence->type() == "Event" ) { | 3218 | if ( incidence && incidence->type() == "Event" ) { |
3218 | event = static_cast<Event *>(incidence); | 3219 | event = static_cast<Event *>(incidence); |
3219 | } | 3220 | } |
3220 | if ( incidence && incidence->type() == "Todo" ) { | 3221 | if ( incidence && incidence->type() == "Todo" ) { |
3221 | todo = static_cast<Todo *>(incidence); | 3222 | todo = static_cast<Todo *>(incidence); |
3222 | } | 3223 | } |
3223 | 3224 | ||
3224 | if (!event && !todo) { | 3225 | if (!event && !todo) { |
3225 | KMessageBox::sorry(this,i18n("No event selected.")); | 3226 | KMessageBox::sorry(this,i18n("No event selected.")); |
3226 | return; | 3227 | return; |
3227 | } | 3228 | } |
3228 | 3229 | ||
3229 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3230 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3230 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3231 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3231 | return; | 3232 | return; |
3232 | } | 3233 | } |
3233 | 3234 | ||
3234 | Event *ev = 0; | 3235 | Event *ev = 0; |
3235 | if (event) ev = new Event(*event); | 3236 | if (event) ev = new Event(*event); |
3236 | Todo *to = 0; | 3237 | Todo *to = 0; |
3237 | if (todo) to = new Todo(*todo); | 3238 | if (todo) to = new Todo(*todo); |
3238 | 3239 | ||
3239 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3240 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3240 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3241 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3241 | if (!me) { | 3242 | if (!me) { |
3242 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3243 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3243 | return; | 3244 | return; |
3244 | } | 3245 | } |
3245 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3246 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3246 | StatusDialog *statdlg = new StatusDialog(this); | 3247 | StatusDialog *statdlg = new StatusDialog(this); |
3247 | if (!statdlg->exec()==QDialog::Accepted) return; | 3248 | if (!statdlg->exec()==QDialog::Accepted) return; |
3248 | me->setStatus( statdlg->status() ); | 3249 | me->setStatus( statdlg->status() ); |
3249 | delete(statdlg); | 3250 | delete(statdlg); |
3250 | } | 3251 | } |
3251 | Attendee *menew = new Attendee(*me); | 3252 | Attendee *menew = new Attendee(*me); |
3252 | if (ev) { | 3253 | if (ev) { |
3253 | ev->clearAttendees(); | 3254 | ev->clearAttendees(); |
3254 | ev->addAttendee(menew,false); | 3255 | ev->addAttendee(menew,false); |
3255 | } else { | 3256 | } else { |
3256 | if (to) { | 3257 | if (to) { |
3257 | todo->clearAttendees(); | 3258 | todo->clearAttendees(); |
3258 | todo->addAttendee(menew,false); | 3259 | todo->addAttendee(menew,false); |
3259 | } | 3260 | } |
3260 | } | 3261 | } |
3261 | } | 3262 | } |
3262 | 3263 | ||
3263 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3264 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3264 | if (ev) { | 3265 | if (ev) { |
3265 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3266 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3266 | } else { | 3267 | } else { |
3267 | if (to) { | 3268 | if (to) { |
3268 | if ( !dlg->addMessage(to,method) ) delete(to); | 3269 | if ( !dlg->addMessage(to,method) ) delete(to); |
3269 | } | 3270 | } |
3270 | } | 3271 | } |
3271 | } | 3272 | } |
3272 | 3273 | ||
3273 | void CalendarView::openAddressbook() | 3274 | void CalendarView::openAddressbook() |
3274 | { | 3275 | { |
3275 | KRun::runCommand("kaddressbook"); | 3276 | KRun::runCommand("kaddressbook"); |
3276 | } | 3277 | } |
3277 | 3278 | ||
3278 | void CalendarView::setModified(bool modified) | 3279 | void CalendarView::setModified(bool modified) |
3279 | { | 3280 | { |
3280 | if ( modified ) | 3281 | if ( modified ) |
3281 | emit signalmodified(); | 3282 | emit signalmodified(); |
3282 | if (mModified != modified) { | 3283 | if (mModified != modified) { |
3283 | mModified = modified; | 3284 | mModified = modified; |
3284 | emit modifiedChanged(mModified); | 3285 | emit modifiedChanged(mModified); |
3285 | } | 3286 | } |
3286 | } | 3287 | } |
3287 | 3288 | ||
3288 | bool CalendarView::isReadOnly() | 3289 | bool CalendarView::isReadOnly() |
3289 | { | 3290 | { |
3290 | return mReadOnly; | 3291 | return mReadOnly; |
3291 | } | 3292 | } |
3292 | 3293 | ||
3293 | void CalendarView::setReadOnly(bool readOnly) | 3294 | void CalendarView::setReadOnly(bool readOnly) |
3294 | { | 3295 | { |
3295 | if (mReadOnly != readOnly) { | 3296 | if (mReadOnly != readOnly) { |
3296 | mReadOnly = readOnly; | 3297 | mReadOnly = readOnly; |
3297 | emit readOnlyChanged(mReadOnly); | 3298 | emit readOnlyChanged(mReadOnly); |
3298 | } | 3299 | } |
3299 | } | 3300 | } |
3300 | 3301 | ||
3301 | bool CalendarView::isModified() | 3302 | bool CalendarView::isModified() |
3302 | { | 3303 | { |
3303 | return mModified; | 3304 | return mModified; |
3304 | } | 3305 | } |
3305 | 3306 | ||
3306 | void CalendarView::printSetup() | 3307 | void CalendarView::printSetup() |
3307 | { | 3308 | { |
3308 | #ifndef KORG_NOPRINTER | 3309 | #ifndef KORG_NOPRINTER |
3309 | createPrinter(); | 3310 | createPrinter(); |
3310 | 3311 | ||
3311 | mCalPrinter->setupPrinter(); | 3312 | mCalPrinter->setupPrinter(); |
3312 | #endif | 3313 | #endif |
3313 | } | 3314 | } |
3314 | 3315 | ||
3315 | void CalendarView::print() | 3316 | void CalendarView::print() |
3316 | { | 3317 | { |
3317 | #ifndef KORG_NOPRINTER | 3318 | #ifndef KORG_NOPRINTER |
3318 | createPrinter(); | 3319 | createPrinter(); |
3319 | 3320 | ||
3320 | DateList tmpDateList = mNavigator->selectedDates(); | 3321 | DateList tmpDateList = mNavigator->selectedDates(); |
3321 | mCalPrinter->print(CalPrinter::Month, | 3322 | mCalPrinter->print(CalPrinter::Month, |
3322 | tmpDateList.first(), tmpDateList.last()); | 3323 | tmpDateList.first(), tmpDateList.last()); |
3323 | #endif | 3324 | #endif |
3324 | } | 3325 | } |
3325 | 3326 | ||
3326 | void CalendarView::printPreview() | 3327 | void CalendarView::printPreview() |
3327 | { | 3328 | { |
3328 | #ifndef KORG_NOPRINTER | 3329 | #ifndef KORG_NOPRINTER |
3329 | kdDebug() << "CalendarView::printPreview()" << endl; | 3330 | kdDebug() << "CalendarView::printPreview()" << endl; |
3330 | 3331 | ||
3331 | createPrinter(); | 3332 | createPrinter(); |
3332 | 3333 | ||
3333 | DateList tmpDateList = mNavigator->selectedDates(); | 3334 | DateList tmpDateList = mNavigator->selectedDates(); |
3334 | 3335 | ||
3335 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3336 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3336 | tmpDateList.last()); | 3337 | tmpDateList.last()); |
3337 | #endif | 3338 | #endif |
3338 | } | 3339 | } |
3339 | 3340 | ||
3340 | void CalendarView::exportICalendar() | 3341 | void CalendarView::exportICalendar() |
3341 | { | 3342 | { |
3342 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3343 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3343 | 3344 | ||
3344 | // Force correct extension | 3345 | // Force correct extension |
3345 | if (filename.right(4) != ".ics") filename += ".ics"; | 3346 | if (filename.right(4) != ".ics") filename += ".ics"; |
3346 | 3347 | ||
3347 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3348 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3348 | storage.save(); | 3349 | storage.save(); |
3349 | } | 3350 | } |
3350 | 3351 | ||
3351 | bool CalendarView::exportVCalendar( QString filename ) | 3352 | bool CalendarView::exportVCalendar( QString filename ) |
3352 | { | 3353 | { |
3353 | if (mCalendar->journals().count() > 0) { | 3354 | if (mCalendar->journals().count() > 0) { |
3354 | int result = KMessageBox::warningContinueCancel(this, | 3355 | int result = KMessageBox::warningContinueCancel(this, |
3355 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3356 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3356 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3357 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3357 | true); | 3358 | true); |
3358 | if (result != KMessageBox::Continue) return false; | 3359 | if (result != KMessageBox::Continue) return false; |
3359 | } | 3360 | } |
3360 | 3361 | ||
3361 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3362 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3362 | 3363 | ||
3363 | // Force correct extension | 3364 | // Force correct extension |
3364 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3365 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3365 | 3366 | ||
3366 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3367 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3367 | return storage.save(); | 3368 | return storage.save(); |
3368 | 3369 | ||
3369 | } | 3370 | } |
3370 | 3371 | ||
3371 | void CalendarView::eventUpdated(Incidence *) | 3372 | void CalendarView::eventUpdated(Incidence *) |
3372 | { | 3373 | { |
3373 | setModified(); | 3374 | setModified(); |
3374 | // Don't call updateView here. The code, which has caused the update of the | 3375 | // Don't call updateView here. The code, which has caused the update of the |
3375 | // event is responsible for updating the view. | 3376 | // event is responsible for updating the view. |
3376 | // updateView(); | 3377 | // updateView(); |
3377 | } | 3378 | } |
3378 | 3379 | ||
3379 | void CalendarView::adaptNavigationUnits() | 3380 | void CalendarView::adaptNavigationUnits() |
3380 | { | 3381 | { |
3381 | if (mViewManager->currentView()->isEventView()) { | 3382 | if (mViewManager->currentView()->isEventView()) { |
3382 | int days = mViewManager->currentView()->currentDateCount(); | 3383 | int days = mViewManager->currentView()->currentDateCount(); |
3383 | if (days == 1) { | 3384 | if (days == 1) { |
3384 | emit changeNavStringPrev(i18n("&Previous Day")); | 3385 | emit changeNavStringPrev(i18n("&Previous Day")); |
3385 | emit changeNavStringNext(i18n("&Next Day")); | 3386 | emit changeNavStringNext(i18n("&Next Day")); |
3386 | } else { | 3387 | } else { |
3387 | emit changeNavStringPrev(i18n("&Previous Week")); | 3388 | emit changeNavStringPrev(i18n("&Previous Week")); |
3388 | emit changeNavStringNext(i18n("&Next Week")); | 3389 | emit changeNavStringNext(i18n("&Next Week")); |
3389 | } | 3390 | } |
3390 | } | 3391 | } |
3391 | } | 3392 | } |
3392 | 3393 | ||
3393 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3394 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3394 | { | 3395 | { |
3395 | if ( incidence ) mTodoList->clearSelection(); | 3396 | if ( incidence ) mTodoList->clearSelection(); |
3396 | processIncidenceSelection( incidence ); | 3397 | processIncidenceSelection( incidence ); |
3397 | } | 3398 | } |
3398 | 3399 | ||
3399 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3400 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3400 | { | 3401 | { |
3401 | if ( incidence && mViewManager->currentView() ) { | 3402 | if ( incidence && mViewManager->currentView() ) { |
3402 | mViewManager->currentView()->clearSelection(); | 3403 | mViewManager->currentView()->clearSelection(); |
3403 | } | 3404 | } |
3404 | processIncidenceSelection( incidence ); | 3405 | processIncidenceSelection( incidence ); |
3405 | } | 3406 | } |
3406 | 3407 | ||
3407 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3408 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3408 | { | 3409 | { |
3409 | if ( incidence == mSelectedIncidence ) return; | 3410 | if ( incidence == mSelectedIncidence ) return; |
3410 | 3411 | ||
3411 | mSelectedIncidence = incidence; | 3412 | mSelectedIncidence = incidence; |
3412 | 3413 | ||
3413 | emit incidenceSelected( mSelectedIncidence ); | 3414 | emit incidenceSelected( mSelectedIncidence ); |
3414 | 3415 | ||
3415 | if ( incidence && incidence->type() == "Event" ) { | 3416 | if ( incidence && incidence->type() == "Event" ) { |
3416 | Event *event = static_cast<Event *>( incidence ); | 3417 | Event *event = static_cast<Event *>( incidence ); |
3417 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3418 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3418 | emit organizerEventsSelected( true ); | 3419 | emit organizerEventsSelected( true ); |
3419 | } else { | 3420 | } else { |
3420 | emit organizerEventsSelected(false); | 3421 | emit organizerEventsSelected(false); |
3421 | } | 3422 | } |
3422 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3423 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3423 | KOPrefs::instance()->email() ) ) { | 3424 | KOPrefs::instance()->email() ) ) { |
3424 | emit groupEventsSelected( true ); | 3425 | emit groupEventsSelected( true ); |
3425 | } else { | 3426 | } else { |
3426 | emit groupEventsSelected(false); | 3427 | emit groupEventsSelected(false); |
3427 | } | 3428 | } |
3428 | return; | 3429 | return; |
3429 | } else { | 3430 | } else { |
3430 | if ( incidence && incidence->type() == "Todo" ) { | 3431 | if ( incidence && incidence->type() == "Todo" ) { |
3431 | emit todoSelected( true ); | 3432 | emit todoSelected( true ); |
3432 | Todo *event = static_cast<Todo *>( incidence ); | 3433 | Todo *event = static_cast<Todo *>( incidence ); |
3433 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3434 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3434 | emit organizerEventsSelected( true ); | 3435 | emit organizerEventsSelected( true ); |
3435 | } else { | 3436 | } else { |
3436 | emit organizerEventsSelected(false); | 3437 | emit organizerEventsSelected(false); |
3437 | } | 3438 | } |
3438 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3439 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3439 | KOPrefs::instance()->email() ) ) { | 3440 | KOPrefs::instance()->email() ) ) { |
3440 | emit groupEventsSelected( true ); | 3441 | emit groupEventsSelected( true ); |
3441 | } else { | 3442 | } else { |
3442 | emit groupEventsSelected(false); | 3443 | emit groupEventsSelected(false); |
3443 | } | 3444 | } |
3444 | return; | 3445 | return; |
3445 | } else { | 3446 | } else { |
3446 | emit todoSelected( false ); | 3447 | emit todoSelected( false ); |
3447 | emit organizerEventsSelected(false); | 3448 | emit organizerEventsSelected(false); |
3448 | emit groupEventsSelected(false); | 3449 | emit groupEventsSelected(false); |
3449 | } | 3450 | } |
3450 | return; | 3451 | return; |
3451 | } | 3452 | } |
3452 | 3453 | ||
3453 | /* if ( incidence && incidence->type() == "Todo" ) { | 3454 | /* if ( incidence && incidence->type() == "Todo" ) { |
3454 | emit todoSelected( true ); | 3455 | emit todoSelected( true ); |
3455 | } else { | 3456 | } else { |
3456 | emit todoSelected( false ); | 3457 | emit todoSelected( false ); |
3457 | }*/ | 3458 | }*/ |
3458 | } | 3459 | } |
3459 | 3460 | ||
3460 | 3461 | ||
3461 | void CalendarView::checkClipboard() | 3462 | void CalendarView::checkClipboard() |
3462 | { | 3463 | { |
3463 | #ifndef KORG_NODND | 3464 | #ifndef KORG_NODND |
3464 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3465 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3465 | emit pasteEnabled(true); | 3466 | emit pasteEnabled(true); |
3466 | } else { | 3467 | } else { |
3467 | emit pasteEnabled(false); | 3468 | emit pasteEnabled(false); |
3468 | } | 3469 | } |
3469 | #endif | 3470 | #endif |
3470 | } | 3471 | } |
3471 | 3472 | ||
3472 | void CalendarView::showDates(const DateList &selectedDates) | 3473 | void CalendarView::showDates(const DateList &selectedDates) |
3473 | { | 3474 | { |
3474 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3475 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3475 | 3476 | ||
3476 | 3477 | ||
3477 | if ( !mBlockShowDates ) { | 3478 | if ( !mBlockShowDates ) { |
3478 | if ( mViewManager->currentView() ) { | 3479 | if ( mViewManager->currentView() ) { |
3479 | updateView( selectedDates.first(), selectedDates.last() ); | 3480 | updateView( selectedDates.first(), selectedDates.last() ); |
3480 | } else { | 3481 | } else { |
3481 | mViewManager->showAgendaView(); | 3482 | mViewManager->showAgendaView(); |
3482 | } | 3483 | } |
3483 | } | 3484 | } |
3484 | 3485 | ||
3485 | QString selDates; | 3486 | QString selDates; |
3486 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3487 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3487 | if (selectedDates.first() < selectedDates.last() ) | 3488 | if (selectedDates.first() < selectedDates.last() ) |
3488 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3489 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3489 | else { | 3490 | else { |
3490 | QString addString; | 3491 | QString addString; |
3491 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) | 3492 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) |
3492 | addString = i18n("Today"); | 3493 | addString = i18n("Today"); |
3493 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 3494 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
3494 | addString = i18n("Tomorrow"); | 3495 | addString = i18n("Tomorrow"); |
3495 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 3496 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
3496 | addString = i18n("Yesterday"); | 3497 | addString = i18n("Yesterday"); |
3497 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 3498 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
3498 | addString = i18n("Day before yesterday"); | 3499 | addString = i18n("Day before yesterday"); |
3499 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 3500 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
3500 | addString = i18n("Day after tomorrow"); | 3501 | addString = i18n("Day after tomorrow"); |
3501 | if ( !addString.isEmpty() ) { | 3502 | if ( !addString.isEmpty() ) { |
3502 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3503 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3503 | return; | 3504 | return; |
3504 | } | 3505 | } |
3505 | } | 3506 | } |
3506 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3507 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3507 | 3508 | ||
3508 | } | 3509 | } |
3509 | 3510 | ||
3510 | QPtrList<CalFilter> CalendarView::filters() | 3511 | QPtrList<CalFilter> CalendarView::filters() |
3511 | { | 3512 | { |
3512 | return mFilters; | 3513 | return mFilters; |
3513 | 3514 | ||
3514 | } | 3515 | } |
3515 | void CalendarView::editFilters() | 3516 | void CalendarView::editFilters() |
3516 | { | 3517 | { |
3517 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3518 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3518 | 3519 | ||
3519 | CalFilter *filter = mFilters.first(); | 3520 | CalFilter *filter = mFilters.first(); |
3520 | while(filter) { | 3521 | while(filter) { |
3521 | kdDebug() << " Filter: " << filter->name() << endl; | 3522 | kdDebug() << " Filter: " << filter->name() << endl; |
3522 | filter = mFilters.next(); | 3523 | filter = mFilters.next(); |
3523 | } | 3524 | } |
3524 | 3525 | ||
3525 | mDialogManager->showFilterEditDialog(&mFilters); | 3526 | mDialogManager->showFilterEditDialog(&mFilters); |
3526 | } | 3527 | } |
3527 | void CalendarView::toggleFilter() | 3528 | void CalendarView::toggleFilter() |
3528 | { | 3529 | { |
3529 | showFilter(! mFilterView->isVisible()); | 3530 | showFilter(! mFilterView->isVisible()); |
3530 | } | 3531 | } |
3531 | 3532 | ||
3532 | KOFilterView *CalendarView::filterView() | 3533 | KOFilterView *CalendarView::filterView() |
3533 | { | 3534 | { |
3534 | return mFilterView; | 3535 | return mFilterView; |
3535 | } | 3536 | } |
3536 | void CalendarView::selectFilter( int fil ) | 3537 | void CalendarView::selectFilter( int fil ) |
3537 | { | 3538 | { |
3538 | mFilterView->setSelectedFilter( fil ); | 3539 | mFilterView->setSelectedFilter( fil ); |
3539 | } | 3540 | } |
3540 | void CalendarView::showFilter(bool visible) | 3541 | void CalendarView::showFilter(bool visible) |
3541 | { | 3542 | { |
3542 | if (visible) mFilterView->show(); | 3543 | if (visible) mFilterView->show(); |
3543 | else mFilterView->hide(); | 3544 | else mFilterView->hide(); |
3544 | } | 3545 | } |
3545 | void CalendarView::toggleFilerEnabled( ) | 3546 | void CalendarView::toggleFilerEnabled( ) |
3546 | { | 3547 | { |
3547 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3548 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3548 | if ( !mFilterView->filtersEnabled() ) | 3549 | if ( !mFilterView->filtersEnabled() ) |
3549 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3550 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3550 | 3551 | ||
3551 | } | 3552 | } |
3552 | void CalendarView::updateFilter() | 3553 | void CalendarView::updateFilter() |
3553 | { | 3554 | { |
3554 | CalFilter *filter = mFilterView->selectedFilter(); | 3555 | CalFilter *filter = mFilterView->selectedFilter(); |
3555 | if (filter) { | 3556 | if (filter) { |
3556 | if (mFilterView->filtersEnabled()) { | 3557 | if (mFilterView->filtersEnabled()) { |
3557 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3558 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3558 | filter->setEnabled(true); | 3559 | filter->setEnabled(true); |
3559 | } | 3560 | } |
3560 | else filter->setEnabled(false); | 3561 | else filter->setEnabled(false); |
3561 | mCalendar->setFilter(filter); | 3562 | mCalendar->setFilter(filter); |
3562 | updateView(); | 3563 | updateView(); |
3563 | } | 3564 | } |
3564 | } | 3565 | } |
3565 | 3566 | ||
3566 | void CalendarView::filterEdited() | 3567 | void CalendarView::filterEdited() |
3567 | { | 3568 | { |
3568 | mFilterView->updateFilters(); | 3569 | mFilterView->updateFilters(); |
3569 | updateFilter(); | 3570 | updateFilter(); |
3570 | writeSettings(); | 3571 | writeSettings(); |
3571 | } | 3572 | } |
3572 | 3573 | ||
3573 | 3574 | ||
3574 | void CalendarView::takeOverEvent() | 3575 | void CalendarView::takeOverEvent() |
3575 | { | 3576 | { |
3576 | Incidence *incidence = currentSelection(); | 3577 | Incidence *incidence = currentSelection(); |
3577 | 3578 | ||
3578 | if (!incidence) return; | 3579 | if (!incidence) return; |
3579 | 3580 | ||
3580 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3581 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3581 | incidence->recreate(); | 3582 | incidence->recreate(); |
3582 | incidence->setReadOnly(false); | 3583 | incidence->setReadOnly(false); |
3583 | 3584 | ||
3584 | updateView(); | 3585 | updateView(); |
3585 | } | 3586 | } |
3586 | 3587 | ||
3587 | void CalendarView::takeOverCalendar() | 3588 | void CalendarView::takeOverCalendar() |
3588 | { | 3589 | { |
3589 | // TODO: Create Calendar::allIncidences() function and use it here | 3590 | // TODO: Create Calendar::allIncidences() function and use it here |
3590 | 3591 | ||
3591 | QPtrList<Event> events = mCalendar->events(); | 3592 | QPtrList<Event> events = mCalendar->events(); |
3592 | for(uint i=0; i<events.count(); ++i) { | 3593 | for(uint i=0; i<events.count(); ++i) { |
3593 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3594 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3594 | events.at(i)->recreate(); | 3595 | events.at(i)->recreate(); |
3595 | events.at(i)->setReadOnly(false); | 3596 | events.at(i)->setReadOnly(false); |
3596 | } | 3597 | } |
3597 | 3598 | ||
3598 | QPtrList<Todo> todos = mCalendar->todos(); | 3599 | QPtrList<Todo> todos = mCalendar->todos(); |
3599 | for(uint i=0; i<todos.count(); ++i) { | 3600 | for(uint i=0; i<todos.count(); ++i) { |
3600 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3601 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3601 | todos.at(i)->recreate(); | 3602 | todos.at(i)->recreate(); |
3602 | todos.at(i)->setReadOnly(false); | 3603 | todos.at(i)->setReadOnly(false); |
3603 | } | 3604 | } |
3604 | 3605 | ||
3605 | QPtrList<Journal> journals = mCalendar->journals(); | 3606 | QPtrList<Journal> journals = mCalendar->journals(); |
3606 | for(uint i=0; i<journals.count(); ++i) { | 3607 | for(uint i=0; i<journals.count(); ++i) { |
3607 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3608 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3608 | journals.at(i)->recreate(); | 3609 | journals.at(i)->recreate(); |
3609 | journals.at(i)->setReadOnly(false); | 3610 | journals.at(i)->setReadOnly(false); |
3610 | } | 3611 | } |
3611 | 3612 | ||
3612 | updateView(); | 3613 | updateView(); |
3613 | } | 3614 | } |
3614 | 3615 | ||
3615 | void CalendarView::showIntro() | 3616 | void CalendarView::showIntro() |
3616 | { | 3617 | { |
3617 | kdDebug() << "To be implemented." << endl; | 3618 | kdDebug() << "To be implemented." << endl; |
3618 | } | 3619 | } |
3619 | 3620 | ||
3620 | QWidgetStack *CalendarView::viewStack() | 3621 | QWidgetStack *CalendarView::viewStack() |
3621 | { | 3622 | { |
3622 | return mRightFrame; | 3623 | return mRightFrame; |
3623 | } | 3624 | } |
3624 | 3625 | ||
3625 | QWidget *CalendarView::leftFrame() | 3626 | QWidget *CalendarView::leftFrame() |
3626 | { | 3627 | { |
3627 | return mLeftFrame; | 3628 | return mLeftFrame; |
3628 | } | 3629 | } |
3629 | 3630 | ||
3630 | DateNavigator *CalendarView::dateNavigator() | 3631 | DateNavigator *CalendarView::dateNavigator() |
3631 | { | 3632 | { |
3632 | return mNavigator; | 3633 | return mNavigator; |
3633 | } | 3634 | } |
3634 | 3635 | ||
3635 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3636 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3636 | { | 3637 | { |
3637 | return mDateNavigator; | 3638 | return mDateNavigator; |
3638 | } | 3639 | } |
3639 | void CalendarView::toggleDateNavigatorWidget() | 3640 | void CalendarView::toggleDateNavigatorWidget() |
3640 | { | 3641 | { |
3641 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3642 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3642 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3643 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3643 | mDateNavigator->hide(); | 3644 | mDateNavigator->hide(); |
3644 | else | 3645 | else |
3645 | mDateNavigator->show(); | 3646 | mDateNavigator->show(); |
3646 | } | 3647 | } |
3647 | void CalendarView::addView(KOrg::BaseView *view) | 3648 | void CalendarView::addView(KOrg::BaseView *view) |
3648 | { | 3649 | { |
3649 | mViewManager->addView(view); | 3650 | mViewManager->addView(view); |
3650 | } | 3651 | } |
3651 | 3652 | ||
3652 | void CalendarView::showView(KOrg::BaseView *view) | 3653 | void CalendarView::showView(KOrg::BaseView *view) |
3653 | { | 3654 | { |
3654 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3655 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3655 | } | 3656 | } |
3656 | 3657 | ||
3657 | Incidence *CalendarView::currentSelection() | 3658 | Incidence *CalendarView::currentSelection() |
3658 | { | 3659 | { |
3659 | return mViewManager->currentSelection(); | 3660 | return mViewManager->currentSelection(); |
3660 | } | 3661 | } |
3661 | void CalendarView::toggleAllDaySize() | 3662 | void CalendarView::toggleAllDaySize() |
3662 | { | 3663 | { |
3663 | /* | 3664 | /* |
3664 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3665 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3665 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3666 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3666 | else | 3667 | else |
3667 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3668 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3668 | */ | 3669 | */ |
3669 | viewManager()->agendaView()->toggleAllDay(); | 3670 | viewManager()->agendaView()->toggleAllDay(); |
3670 | } | 3671 | } |
3671 | void CalendarView::toggleExpand() | 3672 | void CalendarView::toggleExpand() |
3672 | { | 3673 | { |
3673 | // if ( mLeftFrame->isHidden() ) { | 3674 | // if ( mLeftFrame->isHidden() ) { |
3674 | // mLeftFrame->show(); | 3675 | // mLeftFrame->show(); |
3675 | // emit calendarViewExpanded( false ); | 3676 | // emit calendarViewExpanded( false ); |
3676 | // } else { | 3677 | // } else { |
3677 | // mLeftFrame->hide(); | 3678 | // mLeftFrame->hide(); |
3678 | // emit calendarViewExpanded( true ); | 3679 | // emit calendarViewExpanded( true ); |
3679 | // } | 3680 | // } |
3680 | 3681 | ||
3681 | globalFlagBlockAgenda = 1; | 3682 | globalFlagBlockAgenda = 1; |
3682 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3683 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3683 | globalFlagBlockAgenda = 5; | 3684 | globalFlagBlockAgenda = 5; |
3684 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3685 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3685 | //mViewManager->showView( 0, true ); | 3686 | //mViewManager->showView( 0, true ); |
3686 | } | 3687 | } |
3687 | 3688 | ||
3688 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3689 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3689 | { | 3690 | { |
3690 | setModified( modified ); | 3691 | setModified( modified ); |
3691 | } | 3692 | } |
3692 | 3693 | ||
3693 | Todo *CalendarView::selectedTodo() | 3694 | Todo *CalendarView::selectedTodo() |
3694 | { | 3695 | { |
3695 | Incidence *incidence = currentSelection(); | 3696 | Incidence *incidence = currentSelection(); |
3696 | if ( incidence && incidence->type() == "Todo" ) { | 3697 | if ( incidence && incidence->type() == "Todo" ) { |
3697 | return static_cast<Todo *>( incidence ); | 3698 | return static_cast<Todo *>( incidence ); |
3698 | } | 3699 | } |
3699 | 3700 | ||
3700 | incidence = mTodoList->selectedIncidences().first(); | 3701 | incidence = mTodoList->selectedIncidences().first(); |
3701 | if ( incidence && incidence->type() == "Todo" ) { | 3702 | if ( incidence && incidence->type() == "Todo" ) { |
3702 | return static_cast<Todo *>( incidence ); | 3703 | return static_cast<Todo *>( incidence ); |
3703 | } | 3704 | } |
3704 | 3705 | ||
3705 | return 0; | 3706 | return 0; |
3706 | } | 3707 | } |
3707 | 3708 | ||
3708 | void CalendarView::dialogClosing(Incidence *in) | 3709 | void CalendarView::dialogClosing(Incidence *in) |
3709 | { | 3710 | { |
3710 | // mDialogList.remove(in); | 3711 | // mDialogList.remove(in); |
3711 | } | 3712 | } |
3712 | 3713 | ||
3713 | void CalendarView::showIncidence() | 3714 | void CalendarView::showIncidence() |
3714 | { | 3715 | { |
3715 | Incidence *incidence = currentSelection(); | 3716 | Incidence *incidence = currentSelection(); |
3716 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3717 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3717 | if ( incidence ) { | 3718 | if ( incidence ) { |
3718 | ShowIncidenceVisitor v; | 3719 | ShowIncidenceVisitor v; |
3719 | v.act( incidence, this ); | 3720 | v.act( incidence, this ); |
3720 | } | 3721 | } |
3721 | } | 3722 | } |
3722 | void CalendarView::editIncidenceDescription() | 3723 | void CalendarView::editIncidenceDescription() |
3723 | { | 3724 | { |
3724 | mFlagEditDescription = true; | 3725 | mFlagEditDescription = true; |
3725 | editIncidence(); | 3726 | editIncidence(); |
3726 | mFlagEditDescription = false; | 3727 | mFlagEditDescription = false; |
3727 | } | 3728 | } |
3728 | void CalendarView::editIncidence() | 3729 | void CalendarView::editIncidence() |
3729 | { | 3730 | { |
3730 | // qDebug("editIncidence() "); | 3731 | // qDebug("editIncidence() "); |
3731 | Incidence *incidence = currentSelection(); | 3732 | Incidence *incidence = currentSelection(); |
3732 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3733 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3733 | if ( incidence ) { | 3734 | if ( incidence ) { |
3734 | EditIncidenceVisitor v; | 3735 | EditIncidenceVisitor v; |
3735 | v.act( incidence, this ); | 3736 | v.act( incidence, this ); |
3736 | } | 3737 | } |
3737 | } | 3738 | } |
3738 | 3739 | ||
3739 | void CalendarView::deleteIncidence() | 3740 | void CalendarView::deleteIncidence() |
3740 | { | 3741 | { |
3741 | Incidence *incidence = currentSelection(); | 3742 | Incidence *incidence = currentSelection(); |
3742 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3743 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3743 | if ( incidence ) { | 3744 | if ( incidence ) { |
3744 | deleteIncidence(incidence); | 3745 | deleteIncidence(incidence); |
3745 | } | 3746 | } |
3746 | } | 3747 | } |
3747 | 3748 | ||
3748 | void CalendarView::showIncidence(Incidence *incidence) | 3749 | void CalendarView::showIncidence(Incidence *incidence) |
3749 | { | 3750 | { |
3750 | if ( incidence ) { | 3751 | if ( incidence ) { |
3751 | ShowIncidenceVisitor v; | 3752 | ShowIncidenceVisitor v; |
3752 | v.act( incidence, this ); | 3753 | v.act( incidence, this ); |
3753 | } | 3754 | } |
3754 | } | 3755 | } |
3755 | 3756 | ||
3756 | void CalendarView::editIncidence(Incidence *incidence) | 3757 | void CalendarView::editIncidence(Incidence *incidence) |
3757 | { | 3758 | { |
3758 | if ( incidence ) { | 3759 | if ( incidence ) { |
3759 | 3760 | ||
3760 | EditIncidenceVisitor v; | 3761 | EditIncidenceVisitor v; |
3761 | v.act( incidence, this ); | 3762 | v.act( incidence, this ); |
3762 | 3763 | ||
3763 | } | 3764 | } |
3764 | } | 3765 | } |
3765 | 3766 | ||
3766 | void CalendarView::deleteIncidence(Incidence *incidence) | 3767 | void CalendarView::deleteIncidence(Incidence *incidence) |
3767 | { | 3768 | { |
3768 | //qDebug(" CalendarView::deleteIncidence "); | 3769 | //qDebug(" CalendarView::deleteIncidence "); |
3769 | if ( incidence ) { | 3770 | if ( incidence ) { |
3770 | DeleteIncidenceVisitor v; | 3771 | DeleteIncidenceVisitor v; |
3771 | v.act( incidence, this ); | 3772 | v.act( incidence, this ); |
3772 | } | 3773 | } |
3773 | } | 3774 | } |
3774 | 3775 | ||
3775 | 3776 | ||
3776 | void CalendarView::lookForOutgoingMessages() | 3777 | void CalendarView::lookForOutgoingMessages() |
3777 | { | 3778 | { |
3778 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3779 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3779 | ogd->loadMessages(); | 3780 | ogd->loadMessages(); |
3780 | } | 3781 | } |
3781 | 3782 | ||
3782 | void CalendarView::lookForIncomingMessages() | 3783 | void CalendarView::lookForIncomingMessages() |
3783 | { | 3784 | { |
3784 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3785 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3785 | icd->retrieve(); | 3786 | icd->retrieve(); |
3786 | } | 3787 | } |
3787 | 3788 | ||
3788 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3789 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3789 | { | 3790 | { |
3790 | bool deleteTodo = true; | 3791 | bool deleteTodo = true; |
3791 | QPtrList<Incidence> subTodos; | 3792 | QPtrList<Incidence> subTodos; |
3792 | Incidence *aTodo; | 3793 | Incidence *aTodo; |
3793 | subTodos = t->relations(); | 3794 | subTodos = t->relations(); |
3794 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3795 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3795 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3796 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3796 | deleteTodo = false; | 3797 | deleteTodo = false; |
3797 | } | 3798 | } |
3798 | if ( deleteTodo ) { | 3799 | if ( deleteTodo ) { |
3799 | if ( t->isCompleted() ) { | 3800 | if ( t->isCompleted() ) { |
3800 | checkExternalId( t ); | 3801 | checkExternalId( t ); |
3801 | mCalendar->deleteTodo( t ); | 3802 | mCalendar->deleteTodo( t ); |
3802 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3803 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3803 | } | 3804 | } |
3804 | else | 3805 | else |
3805 | deleteTodo = false; | 3806 | deleteTodo = false; |
3806 | } | 3807 | } |
3807 | return deleteTodo; | 3808 | return deleteTodo; |
3808 | 3809 | ||
3809 | } | 3810 | } |
3810 | void CalendarView::purgeCompleted() | 3811 | void CalendarView::purgeCompleted() |
3811 | { | 3812 | { |
3812 | int result = KMessageBox::warningContinueCancel(this, | 3813 | int result = KMessageBox::warningContinueCancel(this, |
3813 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3814 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3814 | 3815 | ||
3815 | if (result == KMessageBox::Continue) { | 3816 | if (result == KMessageBox::Continue) { |
3816 | 3817 | ||
3817 | QPtrList<Todo> todoCal; | 3818 | QPtrList<Todo> todoCal; |
3818 | QPtrList<Todo> rootTodos; | 3819 | QPtrList<Todo> rootTodos; |
3819 | //QPtrList<Incidence> rel; | 3820 | //QPtrList<Incidence> rel; |
3820 | Todo *aTodo;//, *rTodo; | 3821 | Todo *aTodo;//, *rTodo; |
3821 | Incidence *rIncidence; | 3822 | Incidence *rIncidence; |
3822 | bool childDelete = false; | 3823 | bool childDelete = false; |
3823 | bool deletedOne = true; | 3824 | bool deletedOne = true; |
3824 | todoCal = calendar()->todos(); | 3825 | todoCal = calendar()->todos(); |
3825 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3826 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3826 | if ( !aTodo->relatedTo() ) | 3827 | if ( !aTodo->relatedTo() ) |
3827 | rootTodos.append( aTodo ); | 3828 | rootTodos.append( aTodo ); |
3828 | } | 3829 | } |
3829 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3830 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3830 | removeCompletedSubTodos( aTodo ); | 3831 | removeCompletedSubTodos( aTodo ); |
3831 | } | 3832 | } |
3832 | 3833 | ||
3833 | updateView(); | 3834 | updateView(); |
3834 | } | 3835 | } |
3835 | } | 3836 | } |
3836 | 3837 | ||
3837 | void CalendarView::slotCalendarChanged() | 3838 | void CalendarView::slotCalendarChanged() |
3838 | { | 3839 | { |
3839 | ; | 3840 | ; |
3840 | } | 3841 | } |
3841 | 3842 | ||
3842 | NavigatorBar *CalendarView::navigatorBar() | 3843 | NavigatorBar *CalendarView::navigatorBar() |
3843 | { | 3844 | { |
3844 | return mNavigatorBar; | 3845 | return mNavigatorBar; |
3845 | } | 3846 | } |
3846 | 3847 | ||
3847 | 3848 | ||
3848 | 3849 | ||
3849 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3850 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3850 | { | 3851 | { |
3851 | //qDebug(" alendarView::keyPressEvent "); | 3852 | //qDebug(" alendarView::keyPressEvent "); |
3852 | e->ignore(); | 3853 | e->ignore(); |
3853 | } | 3854 | } |
3854 | 3855 | ||
3855 | 3856 | ||
3856 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3857 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3857 | { | 3858 | { |
3858 | // mSyncManager = manager; | 3859 | // mSyncManager = manager; |
3859 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3860 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3860 | qDebug("SyncKDE request detected!"); | 3861 | qDebug("KO: SyncKDE request detected!"); |
3861 | } | 3862 | } |
3862 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3863 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3863 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3864 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3864 | return syncCalendar( filename, mode ); | 3865 | return syncCalendar( filename, mode ); |
3865 | } | 3866 | } |
3866 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3867 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3867 | { | 3868 | { |
3868 | //mSyncManager = manager; | 3869 | //mSyncManager = manager; |
3869 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3870 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3870 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3871 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3871 | if ( resource == "sharp" ) | 3872 | if ( resource == "sharp" ) |
3872 | syncExternal( 0 ); | 3873 | syncExternal( 0 ); |
3873 | if ( resource == "phone" ) | 3874 | if ( resource == "phone" ) |
3874 | syncExternal( 1 ); | 3875 | syncExternal( 1 ); |
3875 | // pending setmodified | 3876 | // pending setmodified |
3876 | return true; | 3877 | return true; |
3877 | } | 3878 | } |
3878 | void CalendarView::setSyncManager(KSyncManager* manager) | 3879 | void CalendarView::setSyncManager(KSyncManager* manager) |
3879 | { | 3880 | { |
3880 | mSyncManager = manager; | 3881 | mSyncManager = manager; |
3881 | } | 3882 | } |
3882 | 3883 | ||
3883 | void CalendarView::removeSyncInfo( QString syncProfile) | 3884 | void CalendarView::removeSyncInfo( QString syncProfile) |
3884 | { | 3885 | { |
3885 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | 3886 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
3886 | mCalendar->removeSyncInfo( syncProfile ); | 3887 | mCalendar->removeSyncInfo( syncProfile ); |
3887 | 3888 | ||
3888 | } | 3889 | } |
3889 | 3890 | ||
3890 | void CalendarView::undo_delete() | 3891 | void CalendarView::undo_delete() |
3891 | { | 3892 | { |
3892 | //qDebug("undo_delete() "); | 3893 | //qDebug("undo_delete() "); |
3893 | Incidence* undo = mCalendar->undoIncidence(); | 3894 | Incidence* undo = mCalendar->undoIncidence(); |
3894 | if ( !undo ) { | 3895 | if ( !undo ) { |
3895 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 3896 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
3896 | i18n("KO/Pi")); | 3897 | i18n("KO/Pi")); |
3897 | return; | 3898 | return; |
3898 | } | 3899 | } |
3899 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 3900 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
3900 | i18n("\nAre you sure you want\nto restore this?"), | 3901 | i18n("\nAre you sure you want\nto restore this?"), |
3901 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 3902 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
3902 | mCalendar->undoDeleteIncidence(); | 3903 | mCalendar->undoDeleteIncidence(); |
3903 | updateView(); | 3904 | updateView(); |
3904 | } | 3905 | } |
3905 | } | 3906 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 26ea1e2..877b6f2 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,1913 +1,1914 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qtopia/alarmserver.h> | 28 | #include <qtopia/alarmserver.h> |
29 | #include <qtopia/qcopenvelope_qws.h> | 29 | #include <qtopia/qcopenvelope_qws.h> |
30 | #include <unistd.h> // for sleep | 30 | #include <unistd.h> // for sleep |
31 | #else | 31 | #else |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | //#include <resource.h> | 35 | //#include <resource.h> |
36 | 36 | ||
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendarlocal.h> | 38 | #include <libkcal/calendarlocal.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | #include <libkcal/phoneformat.h> | 40 | #include <libkcal/phoneformat.h> |
41 | #include <libkdepim/ksyncprofile.h> | 41 | #include <libkdepim/ksyncprofile.h> |
42 | #include <libkdepim/phoneaccess.h> | 42 | #include <libkdepim/phoneaccess.h> |
43 | #include <libkcal/kincidenceformatter.h> | 43 | #include <libkcal/kincidenceformatter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "calendarview.h" | 46 | #include "calendarview.h" |
47 | #include "koviewmanager.h" | 47 | #include "koviewmanager.h" |
48 | #include "datenavigator.h" | 48 | #include "datenavigator.h" |
49 | #include "koagendaview.h" | 49 | #include "koagendaview.h" |
50 | #include "koagenda.h" | 50 | #include "koagenda.h" |
51 | #include "kodialogmanager.h" | 51 | #include "kodialogmanager.h" |
52 | #include "kdialogbase.h" | 52 | #include "kdialogbase.h" |
53 | #include "kapplication.h" | 53 | #include "kapplication.h" |
54 | #include "kofilterview.h" | 54 | #include "kofilterview.h" |
55 | #include "kstandarddirs.h" | 55 | #include "kstandarddirs.h" |
56 | #include "koprefs.h" | 56 | #include "koprefs.h" |
57 | #include "kfiledialog.h" | 57 | #include "kfiledialog.h" |
58 | #include "koglobals.h" | 58 | #include "koglobals.h" |
59 | #include "kglobal.h" | 59 | #include "kglobal.h" |
60 | #include "klocale.h" | 60 | #include "klocale.h" |
61 | #include "kconfig.h" | 61 | #include "kconfig.h" |
62 | #include "simplealarmclient.h" | 62 | #include "simplealarmclient.h" |
63 | #include "externalapphandler.h" | 63 | #include "externalapphandler.h" |
64 | 64 | ||
65 | using namespace KCal; | 65 | using namespace KCal; |
66 | #ifndef _WIN32_ | 66 | #ifndef _WIN32_ |
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #else | 68 | #else |
69 | #ifdef _OL_IMPORT_ | 69 | #ifdef _OL_IMPORT_ |
70 | #include "koimportoldialog.h" | 70 | #include "koimportoldialog.h" |
71 | #endif | 71 | #endif |
72 | #endif | 72 | #endif |
73 | #include "mainwindow.h" | 73 | #include "mainwindow.h" |
74 | 74 | ||
75 | class KOex2phonePrefs : public QDialog | 75 | class KOex2phonePrefs : public QDialog |
76 | { | 76 | { |
77 | public: | 77 | public: |
78 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 78 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
79 | QDialog( parent, name, true ) | 79 | QDialog( parent, name, true ) |
80 | { | 80 | { |
81 | setCaption( i18n("Export to phone options") ); | 81 | setCaption( i18n("Export to phone options") ); |
82 | QVBoxLayout* lay = new QVBoxLayout( this ); | 82 | QVBoxLayout* lay = new QVBoxLayout( this ); |
83 | lay->setSpacing( 3 ); | 83 | lay->setSpacing( 3 ); |
84 | lay->setMargin( 3 ); | 84 | lay->setMargin( 3 ); |
85 | QLabel *lab; | 85 | QLabel *lab; |
86 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 86 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
87 | lab->setAlignment (AlignHCenter ); | 87 | lab->setAlignment (AlignHCenter ); |
88 | QHBox* temphb; | 88 | QHBox* temphb; |
89 | temphb = new QHBox( this ); | 89 | temphb = new QHBox( this ); |
90 | new QLabel( i18n("I/O device: "), temphb ); | 90 | new QLabel( i18n("I/O device: "), temphb ); |
91 | mPhoneDevice = new QLineEdit( temphb); | 91 | mPhoneDevice = new QLineEdit( temphb); |
92 | lay->addWidget( temphb ); | 92 | lay->addWidget( temphb ); |
93 | temphb = new QHBox( this ); | 93 | temphb = new QHBox( this ); |
94 | new QLabel( i18n("Connection: "), temphb ); | 94 | new QLabel( i18n("Connection: "), temphb ); |
95 | mPhoneConnection = new QLineEdit( temphb); | 95 | mPhoneConnection = new QLineEdit( temphb); |
96 | lay->addWidget( temphb ); | 96 | lay->addWidget( temphb ); |
97 | temphb = new QHBox( this ); | 97 | temphb = new QHBox( this ); |
98 | new QLabel( i18n("Model(opt.): "), temphb ); | 98 | new QLabel( i18n("Model(opt.): "), temphb ); |
99 | mPhoneModel = new QLineEdit( temphb); | 99 | mPhoneModel = new QLineEdit( temphb); |
100 | lay->addWidget( temphb ); | 100 | lay->addWidget( temphb ); |
101 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 101 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
102 | mWriteBackFuture->setChecked( true ); | 102 | mWriteBackFuture->setChecked( true ); |
103 | lay->addWidget( mWriteBackFuture ); | 103 | lay->addWidget( mWriteBackFuture ); |
104 | temphb = new QHBox( this ); | 104 | temphb = new QHBox( this ); |
105 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 105 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
106 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 106 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
107 | mWriteBackFutureWeeks->setValue( 8 ); | 107 | mWriteBackFutureWeeks->setValue( 8 ); |
108 | lay->addWidget( temphb ); | 108 | lay->addWidget( temphb ); |
109 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 109 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
110 | lab->setAlignment (AlignHCenter ); | 110 | lab->setAlignment (AlignHCenter ); |
111 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 111 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
112 | lay->addWidget( ok ); | 112 | lay->addWidget( ok ); |
113 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 113 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
114 | lay->addWidget( cancel ); | 114 | lay->addWidget( cancel ); |
115 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 115 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
116 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 116 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
117 | resize( 220, 240 ); | 117 | resize( 220, 240 ); |
118 | qApp->processEvents(); | 118 | qApp->processEvents(); |
119 | int dw = QApplication::desktop()->width(); | 119 | int dw = QApplication::desktop()->width(); |
120 | int dh = QApplication::desktop()->height(); | 120 | int dh = QApplication::desktop()->height(); |
121 | move( (dw-width())/2, (dh - height() )/2 ); | 121 | move( (dw-width())/2, (dh - height() )/2 ); |
122 | } | 122 | } |
123 | 123 | ||
124 | public: | 124 | public: |
125 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 125 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
126 | QCheckBox* mWriteBackFuture; | 126 | QCheckBox* mWriteBackFuture; |
127 | QSpinBox* mWriteBackFutureWeeks; | 127 | QSpinBox* mWriteBackFutureWeeks; |
128 | }; | 128 | }; |
129 | 129 | ||
130 | int globalFlagBlockStartup; | 130 | int globalFlagBlockStartup; |
131 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 131 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
132 | QMainWindow( parent, name ) | 132 | QMainWindow( parent, name ) |
133 | { | 133 | { |
134 | 134 | ||
135 | #ifdef DESKTOP_VERSION | 135 | #ifdef DESKTOP_VERSION |
136 | setFont( QFont("Arial"), 14 ); | 136 | setFont( QFont("Arial"), 14 ); |
137 | #endif | 137 | #endif |
138 | mClosed = false; | 138 | mClosed = false; |
139 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 139 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
140 | QString confFile = locateLocal("config","korganizerrc"); | 140 | QString confFile = locateLocal("config","korganizerrc"); |
141 | QFileInfo finf ( confFile ); | 141 | QFileInfo finf ( confFile ); |
142 | bool showWarning = !finf.exists(); | 142 | bool showWarning = !finf.exists(); |
143 | setIcon(SmallIcon( "ko24" ) ); | 143 | setIcon(SmallIcon( "ko24" ) ); |
144 | mBlockAtStartup = true; | 144 | mBlockAtStartup = true; |
145 | mFlagKeyPressed = false; | 145 | mFlagKeyPressed = false; |
146 | setCaption("KOrganizer/Pi"); | 146 | setCaption("KOrganizer/Pi"); |
147 | KOPrefs *p = KOPrefs::instance(); | 147 | KOPrefs *p = KOPrefs::instance(); |
148 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 148 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
149 | if ( p->mHourSize > 18 ) | 149 | if ( p->mHourSize > 18 ) |
150 | p->mHourSize = 18; | 150 | p->mHourSize = 18; |
151 | QMainWindow::ToolBarDock tbd; | 151 | QMainWindow::ToolBarDock tbd; |
152 | if ( p->mToolBarHor ) { | 152 | if ( p->mToolBarHor ) { |
153 | if ( p->mToolBarUp ) | 153 | if ( p->mToolBarUp ) |
154 | tbd = Bottom; | 154 | tbd = Bottom; |
155 | else | 155 | else |
156 | tbd = Top; | 156 | tbd = Top; |
157 | } | 157 | } |
158 | else { | 158 | else { |
159 | if ( p->mToolBarUp ) | 159 | if ( p->mToolBarUp ) |
160 | tbd = Right; | 160 | tbd = Right; |
161 | else | 161 | else |
162 | tbd = Left; | 162 | tbd = Left; |
163 | } | 163 | } |
164 | if ( KOPrefs::instance()->mUseAppColors ) | 164 | if ( KOPrefs::instance()->mUseAppColors ) |
165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
166 | globalFlagBlockStartup = 1; | 166 | globalFlagBlockStartup = 1; |
167 | iconToolBar = new QPEToolBar( this ); | 167 | iconToolBar = new QPEToolBar( this ); |
168 | addToolBar (iconToolBar , tbd ); | 168 | addToolBar (iconToolBar , tbd ); |
169 | mCalendarModifiedFlag = false; | 169 | mCalendarModifiedFlag = false; |
170 | 170 | ||
171 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 171 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
172 | splash->setAlignment ( AlignCenter ); | 172 | splash->setAlignment ( AlignCenter ); |
173 | setCentralWidget( splash ); | 173 | setCentralWidget( splash ); |
174 | #ifndef DESKTOP_VERSION | 174 | #ifndef DESKTOP_VERSION |
175 | showMaximized(); | 175 | showMaximized(); |
176 | #endif | 176 | #endif |
177 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 177 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
178 | setDefaultPreferences(); | 178 | setDefaultPreferences(); |
179 | mCalendar = new CalendarLocal(); | 179 | mCalendar = new CalendarLocal(); |
180 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 180 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
181 | mView->hide(); | 181 | mView->hide(); |
182 | //mView->resize(splash->size() ); | 182 | //mView->resize(splash->size() ); |
183 | initActions(); | 183 | initActions(); |
184 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 184 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
185 | mSyncManager->setBlockSave(false); | 185 | mSyncManager->setBlockSave(false); |
186 | mView->setSyncManager(mSyncManager); | 186 | mView->setSyncManager(mSyncManager); |
187 | #ifndef DESKTOP_VERSION | 187 | #ifndef DESKTOP_VERSION |
188 | iconToolBar->show(); | 188 | iconToolBar->show(); |
189 | qApp->processEvents(); | 189 | qApp->processEvents(); |
190 | #endif | 190 | #endif |
191 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 191 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
192 | int vh = height() ; | 192 | int vh = height() ; |
193 | int vw = width(); | 193 | int vw = width(); |
194 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 194 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
195 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 195 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
196 | vh -= iconToolBar->height(); | 196 | vh -= iconToolBar->height(); |
197 | } else { | 197 | } else { |
198 | vw -= iconToolBar->height(); | 198 | vw -= iconToolBar->height(); |
199 | } | 199 | } |
200 | //mView->setMaximumSize( splash->size() ); | 200 | //mView->setMaximumSize( splash->size() ); |
201 | //mView->resize( splash->size() ); | 201 | //mView->resize( splash->size() ); |
202 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 202 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
203 | mView->readSettings(); | 203 | mView->readSettings(); |
204 | bool newFile = false; | 204 | bool newFile = false; |
205 | if( !QFile::exists( defaultFileName() ) ) { | 205 | if( !QFile::exists( defaultFileName() ) ) { |
206 | QFileInfo finfo ( defaultFileName() ); | 206 | QFileInfo finfo ( defaultFileName() ); |
207 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 207 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
208 | qDebug("oldfile %s ", oldFile.latin1()); | 208 | qDebug("oldfile %s ", oldFile.latin1()); |
209 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 209 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
210 | finfo.setFile( oldFile ); | 210 | finfo.setFile( oldFile ); |
211 | if (finfo.exists() ) { | 211 | if (finfo.exists() ) { |
212 | KMessageBox::information( this, message); | 212 | KMessageBox::information( this, message); |
213 | mView->openCalendar( oldFile ); | 213 | mView->openCalendar( oldFile ); |
214 | qApp->processEvents(); | 214 | qApp->processEvents(); |
215 | } else { | 215 | } else { |
216 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 216 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
217 | finfo.setFile( oldFile ); | 217 | finfo.setFile( oldFile ); |
218 | if (finfo.exists() ) { | 218 | if (finfo.exists() ) { |
219 | KMessageBox::information( this, message); | 219 | KMessageBox::information( this, message); |
220 | mView->openCalendar( oldFile ); | 220 | mView->openCalendar( oldFile ); |
221 | qApp->processEvents(); | 221 | qApp->processEvents(); |
222 | } | 222 | } |
223 | } | 223 | } |
224 | mView->saveCalendar( defaultFileName() ); | 224 | mView->saveCalendar( defaultFileName() ); |
225 | newFile = true; | 225 | newFile = true; |
226 | } | 226 | } |
227 | 227 | ||
228 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 228 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
229 | mView->openCalendar( defaultFileName() ); | 229 | mView->openCalendar( defaultFileName() ); |
230 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 230 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
231 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 231 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
232 | 232 | ||
233 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 233 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
234 | KOPrefs::instance()->setCategoryDefaults(); | 234 | KOPrefs::instance()->setCategoryDefaults(); |
235 | int count = mView->addCategories(); | 235 | int count = mView->addCategories(); |
236 | } | 236 | } |
237 | processIncidenceSelection( 0 ); | 237 | processIncidenceSelection( 0 ); |
238 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 238 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
239 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 239 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
240 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 240 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
241 | SLOT( slotModifiedChanged( bool ) ) ); | 241 | SLOT( slotModifiedChanged( bool ) ) ); |
242 | 242 | ||
243 | 243 | ||
244 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 244 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
245 | SLOT( disableBR(bool) ) ); | 245 | SLOT( disableBR(bool) ) ); |
246 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 246 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
247 | mView->setModified( false ); | 247 | mView->setModified( false ); |
248 | mBlockAtStartup = false; | 248 | mBlockAtStartup = false; |
249 | mView->setModified( false ); | 249 | mView->setModified( false ); |
250 | setCentralWidget( mView ); | 250 | setCentralWidget( mView ); |
251 | globalFlagBlockStartup = 0; | 251 | globalFlagBlockStartup = 0; |
252 | mView->show(); | 252 | mView->show(); |
253 | delete splash; | 253 | delete splash; |
254 | if ( newFile ) | 254 | if ( newFile ) |
255 | mView->updateConfig(); | 255 | mView->updateConfig(); |
256 | // qApp->processEvents(); | 256 | // qApp->processEvents(); |
257 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 257 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
258 | //fillSyncMenu(); | 258 | //fillSyncMenu(); |
259 | 259 | ||
260 | 260 | ||
261 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 261 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
262 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 262 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
263 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 263 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
264 | mSyncManager->setDefaultFileName( defaultFileName()); | 264 | mSyncManager->setDefaultFileName( defaultFileName()); |
265 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 265 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
266 | mSyncManager->fillSyncMenu(); | 266 | mSyncManager->fillSyncMenu(); |
267 | 267 | ||
268 | 268 | ||
269 | 269 | ||
270 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 270 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
271 | if ( showWarning ) { | 271 | if ( showWarning ) { |
272 | KMessageBox::information( this, | 272 | KMessageBox::information( this, |
273 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 273 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
274 | qApp->processEvents(); | 274 | qApp->processEvents(); |
275 | mView->dialogManager()->showSyncOptions(); | 275 | mView->dialogManager()->showSyncOptions(); |
276 | } | 276 | } |
277 | 277 | ||
278 | //US listen for result adressed from Ka/Pi | 278 | //US listen for result adressed from Ka/Pi |
279 | #ifndef DESKTOP_VERSION | 279 | #ifndef DESKTOP_VERSION |
280 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 280 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
281 | #endif | 281 | #endif |
282 | #ifndef DESKTOP_VERSION | 282 | #ifndef DESKTOP_VERSION |
283 | infrared = 0; | 283 | infrared = 0; |
284 | #endif | 284 | #endif |
285 | 285 | ||
286 | mBRdisabled = false; | 286 | mBRdisabled = false; |
287 | //toggleBeamReceive(); | 287 | //toggleBeamReceive(); |
288 | } | 288 | } |
289 | MainWindow::~MainWindow() | 289 | MainWindow::~MainWindow() |
290 | { | 290 | { |
291 | //qDebug("MainWindow::~MainWindow() "); | 291 | //qDebug("MainWindow::~MainWindow() "); |
292 | //save toolbar location | 292 | //save toolbar location |
293 | delete mCalendar; | 293 | delete mCalendar; |
294 | delete mSyncManager; | 294 | delete mSyncManager; |
295 | #ifndef DESKTOP_VERSION | 295 | #ifndef DESKTOP_VERSION |
296 | if ( infrared ) | 296 | if ( infrared ) |
297 | delete infrared; | 297 | delete infrared; |
298 | #endif | 298 | #endif |
299 | 299 | ||
300 | 300 | ||
301 | } | 301 | } |
302 | 302 | ||
303 | void MainWindow::disableBR(bool b) | 303 | void MainWindow::disableBR(bool b) |
304 | { | 304 | { |
305 | #ifndef DESKTOP_VERSION | 305 | #ifndef DESKTOP_VERSION |
306 | if ( b ) { | 306 | if ( b ) { |
307 | if ( infrared ) { | 307 | if ( infrared ) { |
308 | toggleBeamReceive(); | 308 | toggleBeamReceive(); |
309 | mBRdisabled = true; | 309 | mBRdisabled = true; |
310 | } | 310 | } |
311 | mBRdisabled = true; | 311 | mBRdisabled = true; |
312 | } else { | 312 | } else { |
313 | if ( mBRdisabled ) { | 313 | if ( mBRdisabled ) { |
314 | mBRdisabled = false; | 314 | mBRdisabled = false; |
315 | //makes no sense,because other cal ap is probably running | 315 | //makes no sense,because other cal ap is probably running |
316 | // toggleBeamReceive(); | 316 | // toggleBeamReceive(); |
317 | } | 317 | } |
318 | } | 318 | } |
319 | #endif | 319 | #endif |
320 | 320 | ||
321 | } | 321 | } |
322 | bool MainWindow::beamReceiveEnabled() | 322 | bool MainWindow::beamReceiveEnabled() |
323 | { | 323 | { |
324 | #ifndef DESKTOP_VERSION | 324 | #ifndef DESKTOP_VERSION |
325 | return ( infrared != 0 ); | 325 | return ( infrared != 0 ); |
326 | #endif | 326 | #endif |
327 | return false; | 327 | return false; |
328 | } | 328 | } |
329 | 329 | ||
330 | void MainWindow::toggleBeamReceive() | 330 | void MainWindow::toggleBeamReceive() |
331 | { | 331 | { |
332 | if ( mBRdisabled ) | 332 | if ( mBRdisabled ) |
333 | return; | 333 | return; |
334 | #ifndef DESKTOP_VERSION | 334 | #ifndef DESKTOP_VERSION |
335 | if ( infrared ) { | 335 | if ( infrared ) { |
336 | qDebug("disable BeamReceive "); | 336 | qDebug("disable BeamReceive "); |
337 | delete infrared; | 337 | delete infrared; |
338 | infrared = 0; | 338 | infrared = 0; |
339 | brAction->setOn(false); | 339 | brAction->setOn(false); |
340 | return; | 340 | return; |
341 | } | 341 | } |
342 | qDebug("enable BeamReceive "); | 342 | qDebug("enable BeamReceive "); |
343 | brAction->setOn(true); | 343 | brAction->setOn(true); |
344 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; | 344 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; |
345 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); | 345 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); |
346 | #endif | 346 | #endif |
347 | } | 347 | } |
348 | void MainWindow::showMaximized () | 348 | void MainWindow::showMaximized () |
349 | { | 349 | { |
350 | #ifndef DESKTOP_VERSION | 350 | #ifndef DESKTOP_VERSION |
351 | if ( ! globalFlagBlockStartup ) | 351 | if ( ! globalFlagBlockStartup ) |
352 | if ( mClosed ) | 352 | if ( mClosed ) |
353 | mView->goToday(); | 353 | mView->goToday(); |
354 | #endif | 354 | #endif |
355 | QWidget::showMaximized () ; | 355 | QWidget::showMaximized () ; |
356 | mClosed = false; | 356 | mClosed = false; |
357 | } | 357 | } |
358 | void MainWindow::closeEvent( QCloseEvent* ce ) | 358 | void MainWindow::closeEvent( QCloseEvent* ce ) |
359 | { | 359 | { |
360 | 360 | ||
361 | 361 | ||
362 | 362 | ||
363 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 363 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
364 | saveOnClose(); | 364 | saveOnClose(); |
365 | mClosed = true; | 365 | mClosed = true; |
366 | ce->accept(); | 366 | ce->accept(); |
367 | return; | 367 | return; |
368 | 368 | ||
369 | } | 369 | } |
370 | 370 | ||
371 | switch( QMessageBox::information( this, "KO/Pi", | 371 | switch( QMessageBox::information( this, "KO/Pi", |
372 | i18n("Do you really want\nto close KO/Pi?"), | 372 | i18n("Do you really want\nto close KO/Pi?"), |
373 | i18n("Close"), i18n("No"), | 373 | i18n("Close"), i18n("No"), |
374 | 0, 0 ) ) { | 374 | 0, 0 ) ) { |
375 | case 0: | 375 | case 0: |
376 | saveOnClose(); | 376 | saveOnClose(); |
377 | mClosed = true; | 377 | mClosed = true; |
378 | ce->accept(); | 378 | ce->accept(); |
379 | break; | 379 | break; |
380 | case 1: | 380 | case 1: |
381 | ce->ignore(); | 381 | ce->ignore(); |
382 | break; | 382 | break; |
383 | case 2: | 383 | case 2: |
384 | 384 | ||
385 | default: | 385 | default: |
386 | break; | 386 | break; |
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | } | 390 | } |
391 | 391 | ||
392 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 392 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
393 | { | 393 | { |
394 | QDataStream stream( data, IO_ReadOnly ); | 394 | QDataStream stream( data, IO_ReadOnly ); |
395 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 395 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
396 | //QString datamess; | 396 | //QString datamess; |
397 | //qDebug("message "); | 397 | //qDebug("message "); |
398 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 398 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
399 | 399 | ||
400 | if ( cmsg == "setDocument(QString)" ) { | 400 | if ( cmsg == "setDocument(QString)" ) { |
401 | QDataStream stream( data, IO_ReadOnly ); | 401 | QDataStream stream( data, IO_ReadOnly ); |
402 | QString fileName; | 402 | QString fileName; |
403 | stream >> fileName; | 403 | stream >> fileName; |
404 | //qDebug("filename %s ", fileName.latin1()); | 404 | //qDebug("filename %s ", fileName.latin1()); |
405 | showMaximized(); | 405 | showMaximized(); |
406 | raise(); | 406 | raise(); |
407 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 407 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
408 | mSyncManager->slotSyncMenu( 1002 ); | 408 | mSyncManager->slotSyncMenu( 1002 ); |
409 | return; | 409 | return; |
410 | } | 410 | } |
411 | 411 | ||
412 | if ( cmsg == "-writeFile" ) { | 412 | if ( cmsg == "-writeFile" ) { |
413 | // I made from the "-writeFile" an "-writeAlarm" | 413 | // I made from the "-writeFile" an "-writeAlarm" |
414 | mView->viewManager()->showWhatsNextView(); | 414 | mView->viewManager()->showWhatsNextView(); |
415 | mCalendar->checkAlarmForIncidence( 0, true); | 415 | mCalendar->checkAlarmForIncidence( 0, true); |
416 | showMaximized(); | 416 | showMaximized(); |
417 | raise(); | 417 | raise(); |
418 | return; | 418 | return; |
419 | 419 | ||
420 | } | 420 | } |
421 | if ( cmsg == "-writeFileSilent" ) { | 421 | if ( cmsg == "-writeFileSilent" ) { |
422 | // I made from the "-writeFile" an "-writeAlarm" | 422 | // I made from the "-writeFile" an "-writeAlarm" |
423 | // mView->viewManager()->showWhatsNextView(); | 423 | // mView->viewManager()->showWhatsNextView(); |
424 | mCalendar->checkAlarmForIncidence( 0, true); | 424 | mCalendar->checkAlarmForIncidence( 0, true); |
425 | //showMaximized(); | 425 | //showMaximized(); |
426 | //raise(); | 426 | //raise(); |
427 | hide(); | 427 | hide(); |
428 | return; | 428 | return; |
429 | } | 429 | } |
430 | if ( cmsg == "-newCountdown" ) { | 430 | if ( cmsg == "-newCountdown" ) { |
431 | qDebug("newCountdown "); | 431 | qDebug("newCountdown "); |
432 | 432 | ||
433 | } | 433 | } |
434 | QString msg ; | 434 | QString msg ; |
435 | QString allmsg = cmsg; | 435 | QString allmsg = cmsg; |
436 | while ( allmsg.length() > 0 ) { | 436 | while ( allmsg.length() > 0 ) { |
437 | int nextC = allmsg.find( "-", 1 ); | 437 | int nextC = allmsg.find( "-", 1 ); |
438 | if ( nextC == -1 ) { | 438 | if ( nextC == -1 ) { |
439 | msg = allmsg; | 439 | msg = allmsg; |
440 | allmsg = ""; | 440 | allmsg = ""; |
441 | } else{ | 441 | } else{ |
442 | msg = allmsg.left( nextC ); | 442 | msg = allmsg.left( nextC ); |
443 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 443 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
444 | } | 444 | } |
445 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 445 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
446 | if ( msg == "-newEvent" ) { | 446 | if ( msg == "-newEvent" ) { |
447 | mView->newEvent(); | 447 | mView->newEvent(); |
448 | } | 448 | } |
449 | if ( msg == "-newTodo" ) { | 449 | if ( msg == "-newTodo" ) { |
450 | mView->newTodo(); | 450 | mView->newTodo(); |
451 | 451 | ||
452 | } | 452 | } |
453 | if ( msg == "-showWN" ) { | 453 | if ( msg == "-showWN" ) { |
454 | mView->viewManager()->showWhatsNextView(); | 454 | mView->viewManager()->showWhatsNextView(); |
455 | } | 455 | } |
456 | if ( msg == "-showTodo" ) { | 456 | if ( msg == "-showTodo" ) { |
457 | mView->viewManager()->showTodoView(); | 457 | mView->viewManager()->showTodoView(); |
458 | } | 458 | } |
459 | if ( msg == "-showList" ) { | 459 | if ( msg == "-showList" ) { |
460 | mView->viewManager()->showListView(); | 460 | mView->viewManager()->showListView(); |
461 | } | 461 | } |
462 | else if ( msg == "-showDay" ) { | 462 | else if ( msg == "-showDay" ) { |
463 | mView->viewManager()->showDayView(); | 463 | mView->viewManager()->showDayView(); |
464 | } | 464 | } |
465 | else if ( msg == "-showWWeek" ) { | 465 | else if ( msg == "-showWWeek" ) { |
466 | mView->viewManager()->showWorkWeekView(); | 466 | mView->viewManager()->showWorkWeekView(); |
467 | } | 467 | } |
468 | else if ( msg == "-ringSync" ) { | 468 | else if ( msg == "-ringSync" ) { |
469 | mSyncManager->multiSync( false ); | 469 | mSyncManager->multiSync( false ); |
470 | } | 470 | } |
471 | else if ( msg == "-showWeek" ) { | 471 | else if ( msg == "-showWeek" ) { |
472 | mView->viewManager()->showWeekView(); | 472 | mView->viewManager()->showWeekView(); |
473 | } | 473 | } |
474 | else if ( msg == "-showTodo" ) { | 474 | else if ( msg == "-showTodo" ) { |
475 | mView->viewManager()->showTodoView(); | 475 | mView->viewManager()->showTodoView(); |
476 | } | 476 | } |
477 | else if ( msg == "-showJournal" ) { | 477 | else if ( msg == "-showJournal" ) { |
478 | mView->dateNavigator()->selectDates( 1 ); | 478 | mView->dateNavigator()->selectDates( 1 ); |
479 | mView->dateNavigator()->selectToday(); | 479 | mView->dateNavigator()->selectToday(); |
480 | mView->viewManager()->showJournalView(); | 480 | mView->viewManager()->showJournalView(); |
481 | } | 481 | } |
482 | else if ( msg == "-showKO" ) { | 482 | else if ( msg == "-showKO" ) { |
483 | mView->viewManager()->showNextXView(); | 483 | mView->viewManager()->showNextXView(); |
484 | } | 484 | } |
485 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 485 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
486 | mView->viewManager()->showWhatsNextView(); | 486 | mView->viewManager()->showWhatsNextView(); |
487 | } | 487 | } |
488 | else if ( msg == "-showNextXView" ) { | 488 | else if ( msg == "-showNextXView" ) { |
489 | mView->viewManager()->showNextXView(); | 489 | mView->viewManager()->showNextXView(); |
490 | } | 490 | } |
491 | 491 | ||
492 | 492 | ||
493 | } | 493 | } |
494 | 494 | ||
495 | showMaximized(); | 495 | showMaximized(); |
496 | raise(); | 496 | raise(); |
497 | } | 497 | } |
498 | 498 | ||
499 | QPixmap MainWindow::loadPixmap( QString name ) | 499 | QPixmap MainWindow::loadPixmap( QString name ) |
500 | { | 500 | { |
501 | return SmallIcon( name ); | 501 | return SmallIcon( name ); |
502 | 502 | ||
503 | } | 503 | } |
504 | void MainWindow::initActions() | 504 | void MainWindow::initActions() |
505 | { | 505 | { |
506 | //KOPrefs::instance()->mShowFullMenu | 506 | //KOPrefs::instance()->mShowFullMenu |
507 | iconToolBar->clear(); | 507 | iconToolBar->clear(); |
508 | KOPrefs *p = KOPrefs::instance(); | 508 | KOPrefs *p = KOPrefs::instance(); |
509 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 509 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
510 | 510 | ||
511 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 511 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
512 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 512 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
513 | QPopupMenu *importMenu = new QPopupMenu( this ); | 513 | QPopupMenu *importMenu = new QPopupMenu( this ); |
514 | selectFilterMenu = new QPopupMenu( this ); | 514 | selectFilterMenu = new QPopupMenu( this ); |
515 | selectFilterMenu->setCheckable( true ); | 515 | selectFilterMenu->setCheckable( true ); |
516 | syncMenu = new QPopupMenu( this ); | 516 | syncMenu = new QPopupMenu( this ); |
517 | configureAgendaMenu = new QPopupMenu( this ); | 517 | configureAgendaMenu = new QPopupMenu( this ); |
518 | configureToolBarMenu = new QPopupMenu( this ); | 518 | configureToolBarMenu = new QPopupMenu( this ); |
519 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 519 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
520 | if ( KOPrefs::instance()->mShowFullMenu ) { | 520 | if ( KOPrefs::instance()->mShowFullMenu ) { |
521 | QMenuBar *menuBar1; | 521 | QMenuBar *menuBar1; |
522 | menuBar1 = menuBar(); | 522 | menuBar1 = menuBar(); |
523 | menuBar1->insertItem( i18n("File"), importMenu ); | 523 | menuBar1->insertItem( i18n("File"), importMenu ); |
524 | menuBar1->insertItem( i18n("View"), viewMenu ); | 524 | menuBar1->insertItem( i18n("View"), viewMenu ); |
525 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 525 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
526 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 526 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
527 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 527 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
528 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 528 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
529 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 529 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
530 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 530 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
531 | } else { | 531 | } else { |
532 | QPEMenuBar *menuBar1; | 532 | QPEMenuBar *menuBar1; |
533 | menuBar1 = new QPEMenuBar( iconToolBar ); | 533 | menuBar1 = new QPEMenuBar( iconToolBar ); |
534 | QPopupMenu *menuBar = new QPopupMenu( this ); | 534 | QPopupMenu *menuBar = new QPopupMenu( this ); |
535 | menuBar1->insertItem( i18n("ME"), menuBar); | 535 | menuBar1->insertItem( i18n("ME"), menuBar); |
536 | menuBar->insertItem( i18n("File"), importMenu ); | 536 | menuBar->insertItem( i18n("File"), importMenu ); |
537 | menuBar->insertItem( i18n("View"), viewMenu ); | 537 | menuBar->insertItem( i18n("View"), viewMenu ); |
538 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 538 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
539 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 539 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
540 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 540 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
541 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 541 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
542 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 542 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
543 | menuBar->insertItem( i18n("Help"), helpMenu ); | 543 | menuBar->insertItem( i18n("Help"), helpMenu ); |
544 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 544 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
545 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 545 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
546 | } | 546 | } |
547 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 547 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
548 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); | 548 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); |
549 | 549 | ||
550 | // ****************** | 550 | // ****************** |
551 | QAction *action; | 551 | QAction *action; |
552 | QIconSet icon; | 552 | QIconSet icon; |
553 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 553 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
554 | configureToolBarMenu->setCheckable( true ); | 554 | configureToolBarMenu->setCheckable( true ); |
555 | 555 | ||
556 | QString pathString = ""; | 556 | QString pathString = ""; |
557 | if ( !p->mToolBarMiniIcons ) { | 557 | if ( !p->mToolBarMiniIcons ) { |
558 | if ( QApplication::desktop()->width() < 480 ) | 558 | if ( QApplication::desktop()->width() < 480 ) |
559 | pathString += "icons16/"; | 559 | pathString += "icons16/"; |
560 | } else | 560 | } else |
561 | pathString += "iconsmini/"; | 561 | pathString += "iconsmini/"; |
562 | configureAgendaMenu->setCheckable( true ); | 562 | configureAgendaMenu->setCheckable( true ); |
563 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); | 563 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); |
564 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); | 564 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); |
565 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); | 565 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); |
566 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); | 566 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); |
567 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); | 567 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); |
568 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); | 568 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); |
569 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); | 569 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); |
570 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); | 570 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); |
571 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 571 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
572 | 572 | ||
573 | icon = loadPixmap( pathString + "configure" ); | 573 | icon = loadPixmap( pathString + "configure" ); |
574 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 574 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
575 | action->addTo( actionMenu ); | 575 | action->addTo( actionMenu ); |
576 | connect( action, SIGNAL( activated() ), | 576 | connect( action, SIGNAL( activated() ), |
577 | mView, SLOT( edit_options() ) ); | 577 | mView, SLOT( edit_options() ) ); |
578 | actionMenu->insertSeparator(); | 578 | actionMenu->insertSeparator(); |
579 | 579 | ||
580 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); | 580 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); |
581 | action->addTo( actionMenu ); | 581 | action->addTo( actionMenu ); |
582 | connect( action, SIGNAL( activated() ), | 582 | connect( action, SIGNAL( activated() ), |
583 | mView, SLOT( undo_delete() ) ); | 583 | mView, SLOT( undo_delete() ) ); |
584 | actionMenu->insertSeparator(); | 584 | actionMenu->insertSeparator(); |
585 | 585 | ||
586 | icon = loadPixmap( pathString + "newevent" ); | 586 | icon = loadPixmap( pathString + "newevent" ); |
587 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 587 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
588 | configureToolBarMenu->insertSeparator(); | 588 | configureToolBarMenu->insertSeparator(); |
589 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 589 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
590 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 590 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
591 | ne_action->addTo( actionMenu ); | 591 | ne_action->addTo( actionMenu ); |
592 | connect( ne_action, SIGNAL( activated() ), | 592 | connect( ne_action, SIGNAL( activated() ), |
593 | mView, SLOT( newEvent() ) ); | 593 | mView, SLOT( newEvent() ) ); |
594 | icon = loadPixmap( pathString + "newtodo" ); | 594 | icon = loadPixmap( pathString + "newtodo" ); |
595 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 595 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
596 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 596 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
597 | nt_action->addTo( actionMenu ); | 597 | nt_action->addTo( actionMenu ); |
598 | connect( nt_action, SIGNAL( activated() ), | 598 | connect( nt_action, SIGNAL( activated() ), |
599 | mView, SLOT( newTodo() ) ); | 599 | mView, SLOT( newTodo() ) ); |
600 | icon = loadPixmap( pathString + "navi" ); | 600 | icon = loadPixmap( pathString + "navi" ); |
601 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 601 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
602 | action->addTo( viewMenu ); | 602 | action->addTo( viewMenu ); |
603 | connect( action, SIGNAL( activated() ), | 603 | connect( action, SIGNAL( activated() ), |
604 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 604 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
605 | icon = loadPixmap( pathString + "filter" ); | 605 | icon = loadPixmap( pathString + "filter" ); |
606 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 606 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
607 | action->addTo( viewMenu ); | 607 | action->addTo( viewMenu ); |
608 | connect( action, SIGNAL( activated() ), | 608 | connect( action, SIGNAL( activated() ), |
609 | mView, SLOT( toggleFilter() ) ); | 609 | mView, SLOT( toggleFilter() ) ); |
610 | action = new QAction( i18n("Toggle Allday"), i18n("Toggle Allday"), 0, this ); | 610 | icon = loadPixmap( pathString + "allday" ); |
611 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); | ||
611 | action->addTo( viewMenu ); | 612 | action->addTo( viewMenu ); |
612 | connect( action, SIGNAL( activated() ), | 613 | connect( action, SIGNAL( activated() ), |
613 | mView, SLOT( toggleAllDaySize() ) ); | 614 | mView, SLOT( toggleAllDaySize() ) ); |
614 | 615 | ||
615 | viewMenu->insertSeparator(); | 616 | viewMenu->insertSeparator(); |
616 | icon = loadPixmap( pathString + "picker" ); | 617 | icon = loadPixmap( pathString + "picker" ); |
617 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 618 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
618 | action->addTo( viewMenu ); | 619 | action->addTo( viewMenu ); |
619 | connect( action, SIGNAL( activated() ), | 620 | connect( action, SIGNAL( activated() ), |
620 | mView, SLOT( showDatePicker() ) ); | 621 | mView, SLOT( showDatePicker() ) ); |
621 | action->addTo( iconToolBar ); | 622 | action->addTo( iconToolBar ); |
622 | viewMenu->insertSeparator(); | 623 | viewMenu->insertSeparator(); |
623 | icon = loadPixmap( pathString + "list" ); | 624 | icon = loadPixmap( pathString + "list" ); |
624 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 625 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
625 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 626 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
626 | showlist_action->addTo( viewMenu ); | 627 | showlist_action->addTo( viewMenu ); |
627 | connect( showlist_action, SIGNAL( activated() ), | 628 | connect( showlist_action, SIGNAL( activated() ), |
628 | mView->viewManager(), SLOT( showListView() ) ); | 629 | mView->viewManager(), SLOT( showListView() ) ); |
629 | 630 | ||
630 | 631 | ||
631 | icon = loadPixmap( pathString + "day" ); | 632 | icon = loadPixmap( pathString + "day" ); |
632 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 633 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
633 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 634 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
634 | day1_action->addTo( viewMenu ); | 635 | day1_action->addTo( viewMenu ); |
635 | // action->addTo( toolBar ); | 636 | // action->addTo( toolBar ); |
636 | connect( day1_action, SIGNAL( activated() ), | 637 | connect( day1_action, SIGNAL( activated() ), |
637 | mView->viewManager(), SLOT( showDayView() ) ); | 638 | mView->viewManager(), SLOT( showDayView() ) ); |
638 | 639 | ||
639 | icon = loadPixmap( pathString + "workweek" ); | 640 | icon = loadPixmap( pathString + "workweek" ); |
640 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 641 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
641 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 642 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
642 | day5_action->addTo( viewMenu ); | 643 | day5_action->addTo( viewMenu ); |
643 | connect( day5_action, SIGNAL( activated() ), | 644 | connect( day5_action, SIGNAL( activated() ), |
644 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 645 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
645 | 646 | ||
646 | icon = loadPixmap( pathString + "week" ); | 647 | icon = loadPixmap( pathString + "week" ); |
647 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 648 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
648 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 649 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
649 | day7_action->addTo( viewMenu ); | 650 | day7_action->addTo( viewMenu ); |
650 | connect( day7_action, SIGNAL( activated() ), | 651 | connect( day7_action, SIGNAL( activated() ), |
651 | mView->viewManager(), SLOT( showWeekView() ) ); | 652 | mView->viewManager(), SLOT( showWeekView() ) ); |
652 | 653 | ||
653 | icon = loadPixmap( pathString + "month" ); | 654 | icon = loadPixmap( pathString + "month" ); |
654 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 655 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
655 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 656 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
656 | month_action->addTo( viewMenu ); | 657 | month_action->addTo( viewMenu ); |
657 | connect( month_action, SIGNAL( activated() ), | 658 | connect( month_action, SIGNAL( activated() ), |
658 | mView->viewManager(), SLOT( showMonthView() ) ); | 659 | mView->viewManager(), SLOT( showMonthView() ) ); |
659 | 660 | ||
660 | icon = loadPixmap( pathString + "todo" ); | 661 | icon = loadPixmap( pathString + "todo" ); |
661 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 662 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
662 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 663 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
663 | todoview_action->addTo( viewMenu ); | 664 | todoview_action->addTo( viewMenu ); |
664 | connect( todoview_action, SIGNAL( activated() ), | 665 | connect( todoview_action, SIGNAL( activated() ), |
665 | mView->viewManager(), SLOT( showTodoView() ) ); | 666 | mView->viewManager(), SLOT( showTodoView() ) ); |
666 | 667 | ||
667 | icon = loadPixmap( pathString + "journal" ); | 668 | icon = loadPixmap( pathString + "journal" ); |
668 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 669 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
669 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 670 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
670 | viewjournal_action->addTo( viewMenu ); | 671 | viewjournal_action->addTo( viewMenu ); |
671 | connect( viewjournal_action, SIGNAL( activated() ), | 672 | connect( viewjournal_action, SIGNAL( activated() ), |
672 | mView->viewManager(), SLOT( showJournalView() ) ); | 673 | mView->viewManager(), SLOT( showJournalView() ) ); |
673 | 674 | ||
674 | icon = loadPixmap( pathString + "xdays" ); | 675 | icon = loadPixmap( pathString + "xdays" ); |
675 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | 676 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); |
676 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 677 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
677 | xdays_action->addTo( viewMenu ); | 678 | xdays_action->addTo( viewMenu ); |
678 | connect( xdays_action, SIGNAL( activated() ), | 679 | connect( xdays_action, SIGNAL( activated() ), |
679 | mView->viewManager(), SLOT( showNextXView() ) ); | 680 | mView->viewManager(), SLOT( showNextXView() ) ); |
680 | 681 | ||
681 | icon = loadPixmap( pathString + "whatsnext" ); | 682 | icon = loadPixmap( pathString + "whatsnext" ); |
682 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | 683 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); |
683 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 684 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
684 | whatsnext_action->addTo( viewMenu ); | 685 | whatsnext_action->addTo( viewMenu ); |
685 | connect( whatsnext_action, SIGNAL( activated() ), | 686 | connect( whatsnext_action, SIGNAL( activated() ), |
686 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 687 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
687 | 688 | ||
688 | #if 0 | 689 | #if 0 |
689 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 690 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
690 | action->addTo( viewMenu ); | 691 | action->addTo( viewMenu ); |
691 | connect( action, SIGNAL( activated() ), | 692 | connect( action, SIGNAL( activated() ), |
692 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 693 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
693 | #endif | 694 | #endif |
694 | 695 | ||
695 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 696 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
696 | this ); | 697 | this ); |
697 | mNewSubTodoAction->addTo( actionMenu ); | 698 | mNewSubTodoAction->addTo( actionMenu ); |
698 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 699 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
699 | mView, SLOT( newSubTodo() ) ); | 700 | mView, SLOT( newSubTodo() ) ); |
700 | 701 | ||
701 | actionMenu->insertSeparator(); | 702 | actionMenu->insertSeparator(); |
702 | 703 | ||
703 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 704 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
704 | mShowAction->addTo( actionMenu ); | 705 | mShowAction->addTo( actionMenu ); |
705 | connect( mShowAction, SIGNAL( activated() ), | 706 | connect( mShowAction, SIGNAL( activated() ), |
706 | mView, SLOT( showIncidence() ) ); | 707 | mView, SLOT( showIncidence() ) ); |
707 | 708 | ||
708 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 709 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
709 | mEditAction->addTo( actionMenu ); | 710 | mEditAction->addTo( actionMenu ); |
710 | connect( mEditAction, SIGNAL( activated() ), | 711 | connect( mEditAction, SIGNAL( activated() ), |
711 | mView, SLOT( editIncidence() ) ); | 712 | mView, SLOT( editIncidence() ) ); |
712 | 713 | ||
713 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 714 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
714 | mDeleteAction->addTo( actionMenu ); | 715 | mDeleteAction->addTo( actionMenu ); |
715 | connect( mDeleteAction, SIGNAL( activated() ), | 716 | connect( mDeleteAction, SIGNAL( activated() ), |
716 | mView, SLOT( deleteIncidence() ) ); | 717 | mView, SLOT( deleteIncidence() ) ); |
717 | 718 | ||
718 | 719 | ||
719 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 720 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
720 | mCloneAction->addTo( actionMenu ); | 721 | mCloneAction->addTo( actionMenu ); |
721 | connect( mCloneAction, SIGNAL( activated() ), | 722 | connect( mCloneAction, SIGNAL( activated() ), |
722 | mView, SLOT( cloneIncidence() ) ); | 723 | mView, SLOT( cloneIncidence() ) ); |
723 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 724 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
724 | mMoveAction->addTo( actionMenu ); | 725 | mMoveAction->addTo( actionMenu ); |
725 | connect( mMoveAction, SIGNAL( activated() ), | 726 | connect( mMoveAction, SIGNAL( activated() ), |
726 | mView, SLOT( moveIncidence() ) ); | 727 | mView, SLOT( moveIncidence() ) ); |
727 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 728 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
728 | mBeamAction->addTo( actionMenu ); | 729 | mBeamAction->addTo( actionMenu ); |
729 | connect( mBeamAction, SIGNAL( activated() ), | 730 | connect( mBeamAction, SIGNAL( activated() ), |
730 | mView, SLOT( beamIncidence() ) ); | 731 | mView, SLOT( beamIncidence() ) ); |
731 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 732 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
732 | mCancelAction->addTo( actionMenu ); | 733 | mCancelAction->addTo( actionMenu ); |
733 | connect( mCancelAction, SIGNAL( activated() ), | 734 | connect( mCancelAction, SIGNAL( activated() ), |
734 | mView, SLOT( toggleCancelIncidence() ) ); | 735 | mView, SLOT( toggleCancelIncidence() ) ); |
735 | 736 | ||
736 | actionMenu->insertSeparator(); | 737 | actionMenu->insertSeparator(); |
737 | 738 | ||
738 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 739 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
739 | this ); | 740 | this ); |
740 | action->addTo( actionMenu ); | 741 | action->addTo( actionMenu ); |
741 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 742 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
742 | 743 | ||
743 | icon = loadPixmap( pathString + "search" ); | 744 | icon = loadPixmap( pathString + "search" ); |
744 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 745 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
745 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | 746 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); |
746 | search_action->addTo( actionMenu ); | 747 | search_action->addTo( actionMenu ); |
747 | connect( search_action, SIGNAL( activated() ), | 748 | connect( search_action, SIGNAL( activated() ), |
748 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 749 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
749 | 750 | ||
750 | icon = loadPixmap( pathString + "today" ); | 751 | icon = loadPixmap( pathString + "today" ); |
751 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 752 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
752 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 753 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
753 | today_action->addTo( actionMenu ); | 754 | today_action->addTo( actionMenu ); |
754 | connect( today_action, SIGNAL( activated() ), | 755 | connect( today_action, SIGNAL( activated() ), |
755 | mView, SLOT( goToday() ) ); | 756 | mView, SLOT( goToday() ) ); |
756 | 757 | ||
757 | if ( KOPrefs::instance()->mShowFullMenu ) { | 758 | if ( KOPrefs::instance()->mShowFullMenu ) { |
758 | actionMenu->insertSeparator(); | 759 | actionMenu->insertSeparator(); |
759 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 760 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
760 | 761 | ||
761 | } | 762 | } |
762 | // actionMenu->insertSeparator(); | 763 | // actionMenu->insertSeparator(); |
763 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 764 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
764 | this ); | 765 | this ); |
765 | action->addTo( importMenu ); | 766 | action->addTo( importMenu ); |
766 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 767 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
767 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 768 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
768 | this ); | 769 | this ); |
769 | action->addTo( importMenu ); | 770 | action->addTo( importMenu ); |
770 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 771 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
771 | importMenu->insertSeparator(); | 772 | importMenu->insertSeparator(); |
772 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 773 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
773 | this ); | 774 | this ); |
774 | action->addTo( importMenu ); | 775 | action->addTo( importMenu ); |
775 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 776 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
776 | #ifndef DESKTOP_VERSION | 777 | #ifndef DESKTOP_VERSION |
777 | importMenu->insertSeparator(); | 778 | importMenu->insertSeparator(); |
778 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 779 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
779 | this ); | 780 | this ); |
780 | action->addTo( importMenu ); | 781 | action->addTo( importMenu ); |
781 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 782 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
782 | #else | 783 | #else |
783 | #ifdef _OL_IMPORT_ | 784 | #ifdef _OL_IMPORT_ |
784 | importMenu->insertSeparator(); | 785 | importMenu->insertSeparator(); |
785 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 786 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
786 | this ); | 787 | this ); |
787 | action->addTo( importMenu ); | 788 | action->addTo( importMenu ); |
788 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 789 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
789 | #endif | 790 | #endif |
790 | #endif | 791 | #endif |
791 | 792 | ||
792 | importMenu->insertSeparator(); | 793 | importMenu->insertSeparator(); |
793 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 794 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
794 | this ); | 795 | this ); |
795 | action->addTo( importMenu ); | 796 | action->addTo( importMenu ); |
796 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 797 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
797 | 798 | ||
798 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 799 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
799 | this ); | 800 | this ); |
800 | action->addTo( importMenu ); | 801 | action->addTo( importMenu ); |
801 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 802 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
802 | 803 | ||
803 | importMenu->insertSeparator(); | 804 | importMenu->insertSeparator(); |
804 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 805 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
805 | this ); | 806 | this ); |
806 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 807 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
807 | 808 | ||
808 | 809 | ||
809 | //LR | 810 | //LR |
810 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 811 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
811 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 812 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
812 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 813 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
813 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 814 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
814 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); | 815 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); |
815 | 816 | ||
816 | importMenu->insertSeparator(); | 817 | importMenu->insertSeparator(); |
817 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 818 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
818 | this ); | 819 | this ); |
819 | action->addTo( importMenu ); | 820 | action->addTo( importMenu ); |
820 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 821 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
821 | #ifndef DESKTOP_VERSION | 822 | #ifndef DESKTOP_VERSION |
822 | importMenu->insertSeparator(); | 823 | importMenu->insertSeparator(); |
823 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, | 824 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, |
824 | this ); | 825 | this ); |
825 | brAction->addTo( importMenu ); | 826 | brAction->addTo( importMenu ); |
826 | brAction->setToggleAction (true ) ; | 827 | brAction->setToggleAction (true ) ; |
827 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); | 828 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); |
828 | 829 | ||
829 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 830 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
830 | this ); | 831 | this ); |
831 | action->addTo( importMenu ); | 832 | action->addTo( importMenu ); |
832 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 833 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
833 | 834 | ||
834 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 835 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
835 | this ); | 836 | this ); |
836 | action->addTo( importMenu ); | 837 | action->addTo( importMenu ); |
837 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 838 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
838 | #else | 839 | #else |
839 | importMenu->insertSeparator(); | 840 | importMenu->insertSeparator(); |
840 | icon = loadPixmap( pathString + "print" ); | 841 | icon = loadPixmap( pathString + "print" ); |
841 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 842 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
842 | action->addTo( importMenu ); | 843 | action->addTo( importMenu ); |
843 | connect( action, SIGNAL( activated() ), | 844 | connect( action, SIGNAL( activated() ), |
844 | this, SLOT( printCal() ) ); | 845 | this, SLOT( printCal() ) ); |
845 | 846 | ||
846 | icon = loadPixmap( pathString + "print" ); | 847 | icon = loadPixmap( pathString + "print" ); |
847 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 848 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
848 | action->addTo( importMenu ); | 849 | action->addTo( importMenu ); |
849 | connect( action, SIGNAL( activated() ), | 850 | connect( action, SIGNAL( activated() ), |
850 | this, SLOT( printSel() ) ); | 851 | this, SLOT( printSel() ) ); |
851 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); | 852 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); |
852 | action->addTo( importMenu ); | 853 | action->addTo( importMenu ); |
853 | connect( action, SIGNAL( activated() ), | 854 | connect( action, SIGNAL( activated() ), |
854 | mView->viewManager(), SIGNAL( printWNV() ) ); | 855 | mView->viewManager(), SIGNAL( printWNV() ) ); |
855 | #endif | 856 | #endif |
856 | importMenu->insertSeparator(); | 857 | importMenu->insertSeparator(); |
857 | action = new QAction( "beam all", i18n("Save"), 0, | 858 | action = new QAction( "beam all", i18n("Save"), 0, |
858 | this ); | 859 | this ); |
859 | action->addTo( importMenu ); | 860 | action->addTo( importMenu ); |
860 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 861 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
861 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 862 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
862 | this ); | 863 | this ); |
863 | action->addTo( importMenu ); | 864 | action->addTo( importMenu ); |
864 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 865 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
865 | 866 | ||
866 | //menuBar->insertItem( "Configure",configureMenu ); | 867 | //menuBar->insertItem( "Configure",configureMenu ); |
867 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 868 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
868 | icon = loadPixmap( "korganizer/korganizer" ); | 869 | icon = loadPixmap( "korganizer/korganizer" ); |
869 | 870 | ||
870 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 871 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
871 | action->addTo( helpMenu ); | 872 | action->addTo( helpMenu ); |
872 | connect( action, SIGNAL( activated() ), | 873 | connect( action, SIGNAL( activated() ), |
873 | SLOT( whatsNew() ) ); | 874 | SLOT( whatsNew() ) ); |
874 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 875 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
875 | action->addTo( helpMenu ); | 876 | action->addTo( helpMenu ); |
876 | connect( action, SIGNAL( activated() ), | 877 | connect( action, SIGNAL( activated() ), |
877 | SLOT( features() ) ); | 878 | SLOT( features() ) ); |
878 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 879 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
879 | action->addTo( helpMenu ); | 880 | action->addTo( helpMenu ); |
880 | connect( action, SIGNAL( activated() ), | 881 | connect( action, SIGNAL( activated() ), |
881 | SLOT( keyBindings() ) ); | 882 | SLOT( keyBindings() ) ); |
882 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 883 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
883 | action->addTo( helpMenu ); | 884 | action->addTo( helpMenu ); |
884 | connect( action, SIGNAL( activated() ), | 885 | connect( action, SIGNAL( activated() ), |
885 | SLOT( synchowto() ) ); | 886 | SLOT( synchowto() ) ); |
886 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); | 887 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); |
887 | action->addTo( helpMenu ); | 888 | action->addTo( helpMenu ); |
888 | connect( action, SIGNAL( activated() ), | 889 | connect( action, SIGNAL( activated() ), |
889 | SLOT( kdesynchowto() ) ); | 890 | SLOT( kdesynchowto() ) ); |
890 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); | 891 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); |
891 | action->addTo( helpMenu ); | 892 | action->addTo( helpMenu ); |
892 | connect( action, SIGNAL( activated() ), | 893 | connect( action, SIGNAL( activated() ), |
893 | SLOT( multisynchowto() ) ); | 894 | SLOT( multisynchowto() ) ); |
894 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 895 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
895 | action->addTo( helpMenu ); | 896 | action->addTo( helpMenu ); |
896 | connect( action, SIGNAL( activated() ), | 897 | connect( action, SIGNAL( activated() ), |
897 | SLOT( aboutAutoSaving() ) ); | 898 | SLOT( aboutAutoSaving() ) ); |
898 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 899 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
899 | action->addTo( helpMenu ); | 900 | action->addTo( helpMenu ); |
900 | connect( action, SIGNAL( activated() ), | 901 | connect( action, SIGNAL( activated() ), |
901 | SLOT( aboutKnownBugs() ) ); | 902 | SLOT( aboutKnownBugs() ) ); |
902 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 903 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
903 | action->addTo( helpMenu ); | 904 | action->addTo( helpMenu ); |
904 | connect( action, SIGNAL( activated() ), | 905 | connect( action, SIGNAL( activated() ), |
905 | SLOT( usertrans() ) ); | 906 | SLOT( usertrans() ) ); |
906 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 907 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
907 | action->addTo( helpMenu ); | 908 | action->addTo( helpMenu ); |
908 | connect( action, SIGNAL( activated() ), | 909 | connect( action, SIGNAL( activated() ), |
909 | SLOT( faq() ) ); | 910 | SLOT( faq() ) ); |
910 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 911 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
911 | action->addTo( helpMenu ); | 912 | action->addTo( helpMenu ); |
912 | connect( action, SIGNAL( activated() ), | 913 | connect( action, SIGNAL( activated() ), |
913 | SLOT( licence() ) ); | 914 | SLOT( licence() ) ); |
914 | action = new QAction( "about", i18n("About..."), 0, this ); | 915 | action = new QAction( "about", i18n("About..."), 0, this ); |
915 | action->addTo( helpMenu ); | 916 | action->addTo( helpMenu ); |
916 | connect( action, SIGNAL( activated() ), | 917 | connect( action, SIGNAL( activated() ), |
917 | SLOT( about() ) ); | 918 | SLOT( about() ) ); |
918 | //menuBar->insertSeparator(); | 919 | //menuBar->insertSeparator(); |
919 | 920 | ||
920 | // ****************************************************** | 921 | // ****************************************************** |
921 | // menubar icons | 922 | // menubar icons |
922 | 923 | ||
923 | 924 | ||
924 | iconToolBar->setHorizontalStretchable (true ); | 925 | iconToolBar->setHorizontalStretchable (true ); |
925 | //menuBar->insertItem( iconToolBar ); | 926 | //menuBar->insertItem( iconToolBar ); |
926 | //xdays_action | 927 | //xdays_action |
927 | if (p-> mShowIconNewEvent) | 928 | if (p-> mShowIconNewEvent) |
928 | ne_action->addTo( iconToolBar ); | 929 | ne_action->addTo( iconToolBar ); |
929 | if (p->mShowIconNewTodo ) | 930 | if (p->mShowIconNewTodo ) |
930 | nt_action->addTo( iconToolBar ); | 931 | nt_action->addTo( iconToolBar ); |
931 | if (p-> mShowIconSearch) | 932 | if (p-> mShowIconSearch) |
932 | search_action->addTo( iconToolBar ); | 933 | search_action->addTo( iconToolBar ); |
933 | if (p-> mShowIconNext) | 934 | if (p-> mShowIconNext) |
934 | whatsnext_action->addTo( iconToolBar ); | 935 | whatsnext_action->addTo( iconToolBar ); |
935 | if (p-> mShowIconNextDays) | 936 | if (p-> mShowIconNextDays) |
936 | xdays_action->addTo( iconToolBar ); | 937 | xdays_action->addTo( iconToolBar ); |
937 | if (p-> mShowIconList) | 938 | if (p-> mShowIconList) |
938 | showlist_action->addTo( iconToolBar ); | 939 | showlist_action->addTo( iconToolBar ); |
939 | if (p-> mShowIconDay1) | 940 | if (p-> mShowIconDay1) |
940 | day1_action->addTo( iconToolBar ); | 941 | day1_action->addTo( iconToolBar ); |
941 | if (p-> mShowIconDay5) | 942 | if (p-> mShowIconDay5) |
942 | day5_action->addTo( iconToolBar ); | 943 | day5_action->addTo( iconToolBar ); |
943 | if (p-> mShowIconDay7) | 944 | if (p-> mShowIconDay7) |
944 | day7_action->addTo( iconToolBar ); | 945 | day7_action->addTo( iconToolBar ); |
945 | if (p-> mShowIconMonth) | 946 | if (p-> mShowIconMonth) |
946 | month_action->addTo( iconToolBar ); | 947 | month_action->addTo( iconToolBar ); |
947 | if (p-> mShowIconTodoview) | 948 | if (p-> mShowIconTodoview) |
948 | todoview_action->addTo( iconToolBar ); | 949 | todoview_action->addTo( iconToolBar ); |
949 | if (p-> mShowIconJournal) | 950 | if (p-> mShowIconJournal) |
950 | viewjournal_action->addTo( iconToolBar ); | 951 | viewjournal_action->addTo( iconToolBar ); |
951 | icon = loadPixmap( pathString + "2leftarrowB" ); | 952 | icon = loadPixmap( pathString + "2leftarrowB" ); |
952 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 953 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
953 | if (p-> mShowIconBackFast) { | 954 | if (p-> mShowIconBackFast) { |
954 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 955 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
955 | connect( action, SIGNAL( activated() ), | 956 | connect( action, SIGNAL( activated() ), |
956 | mView, SLOT( goPreviousMonth() ) ); | 957 | mView, SLOT( goPreviousMonth() ) ); |
957 | action->addTo( iconToolBar ); | 958 | action->addTo( iconToolBar ); |
958 | } | 959 | } |
959 | icon = loadPixmap( pathString + "1leftarrowB" ); | 960 | icon = loadPixmap( pathString + "1leftarrowB" ); |
960 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 961 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
961 | if (p-> mShowIconBack) { | 962 | if (p-> mShowIconBack) { |
962 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 963 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
963 | connect( action, SIGNAL( activated() ), | 964 | connect( action, SIGNAL( activated() ), |
964 | mView, SLOT( goPrevious() ) ); | 965 | mView, SLOT( goPrevious() ) ); |
965 | action->addTo( iconToolBar ); | 966 | action->addTo( iconToolBar ); |
966 | } | 967 | } |
967 | if (p-> mShowIconToday) | 968 | if (p-> mShowIconToday) |
968 | today_action->addTo( iconToolBar ); | 969 | today_action->addTo( iconToolBar ); |
969 | icon = loadPixmap( pathString + "1rightarrowB" ); | 970 | icon = loadPixmap( pathString + "1rightarrowB" ); |
970 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 971 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
971 | if (p-> mShowIconForward) { | 972 | if (p-> mShowIconForward) { |
972 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 973 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
973 | connect( action, SIGNAL( activated() ), | 974 | connect( action, SIGNAL( activated() ), |
974 | mView, SLOT( goNext() ) ); | 975 | mView, SLOT( goNext() ) ); |
975 | action->addTo( iconToolBar ); | 976 | action->addTo( iconToolBar ); |
976 | } | 977 | } |
977 | icon = loadPixmap( pathString + "2rightarrowB" ); | 978 | icon = loadPixmap( pathString + "2rightarrowB" ); |
978 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 979 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
979 | if (p-> mShowIconForwardFast) { | 980 | if (p-> mShowIconForwardFast) { |
980 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 981 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
981 | connect( action, SIGNAL( activated() ), | 982 | connect( action, SIGNAL( activated() ), |
982 | mView, SLOT( goNextMonth() ) ); | 983 | mView, SLOT( goNextMonth() ) ); |
983 | action->addTo( iconToolBar ); | 984 | action->addTo( iconToolBar ); |
984 | } | 985 | } |
985 | 986 | ||
986 | 987 | ||
987 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 988 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
988 | 989 | ||
989 | if (p-> mShowIconNewEvent) | 990 | if (p-> mShowIconNewEvent) |
990 | configureToolBarMenu->setItemChecked( 10, true ); | 991 | configureToolBarMenu->setItemChecked( 10, true ); |
991 | if (p->mShowIconNewTodo ) | 992 | if (p->mShowIconNewTodo ) |
992 | configureToolBarMenu->setItemChecked( 20, true ); | 993 | configureToolBarMenu->setItemChecked( 20, true ); |
993 | if (p-> mShowIconSearch) | 994 | if (p-> mShowIconSearch) |
994 | configureToolBarMenu->setItemChecked( 120, true ); | 995 | configureToolBarMenu->setItemChecked( 120, true ); |
995 | if (p-> mShowIconList) | 996 | if (p-> mShowIconList) |
996 | configureToolBarMenu->setItemChecked( 30, true ); | 997 | configureToolBarMenu->setItemChecked( 30, true ); |
997 | if (p-> mShowIconDay1) | 998 | if (p-> mShowIconDay1) |
998 | configureToolBarMenu->setItemChecked( 40, true ); | 999 | configureToolBarMenu->setItemChecked( 40, true ); |
999 | if (p-> mShowIconDay5) | 1000 | if (p-> mShowIconDay5) |
1000 | configureToolBarMenu->setItemChecked( 50, true ); | 1001 | configureToolBarMenu->setItemChecked( 50, true ); |
1001 | if (p-> mShowIconDay7) | 1002 | if (p-> mShowIconDay7) |
1002 | configureToolBarMenu->setItemChecked( 60, true ); | 1003 | configureToolBarMenu->setItemChecked( 60, true ); |
1003 | if (p-> mShowIconMonth) | 1004 | if (p-> mShowIconMonth) |
1004 | configureToolBarMenu->setItemChecked( 70, true ); | 1005 | configureToolBarMenu->setItemChecked( 70, true ); |
1005 | if (p-> mShowIconTodoview) | 1006 | if (p-> mShowIconTodoview) |
1006 | configureToolBarMenu->setItemChecked( 80, true ); | 1007 | configureToolBarMenu->setItemChecked( 80, true ); |
1007 | if (p-> mShowIconBackFast) | 1008 | if (p-> mShowIconBackFast) |
1008 | configureToolBarMenu->setItemChecked( 200, true ); | 1009 | configureToolBarMenu->setItemChecked( 200, true ); |
1009 | if (p-> mShowIconBack) | 1010 | if (p-> mShowIconBack) |
1010 | configureToolBarMenu->setItemChecked( 210, true ); | 1011 | configureToolBarMenu->setItemChecked( 210, true ); |
1011 | if (p-> mShowIconToday) | 1012 | if (p-> mShowIconToday) |
1012 | configureToolBarMenu->setItemChecked( 130, true ); | 1013 | configureToolBarMenu->setItemChecked( 130, true ); |
1013 | if (p-> mShowIconForward) | 1014 | if (p-> mShowIconForward) |
1014 | configureToolBarMenu->setItemChecked( 220, true ); | 1015 | configureToolBarMenu->setItemChecked( 220, true ); |
1015 | if (p-> mShowIconForwardFast) | 1016 | if (p-> mShowIconForwardFast) |
1016 | configureToolBarMenu->setItemChecked( 230, true ); | 1017 | configureToolBarMenu->setItemChecked( 230, true ); |
1017 | if (p-> mShowIconNextDays) | 1018 | if (p-> mShowIconNextDays) |
1018 | configureToolBarMenu->setItemChecked( 100, true ); | 1019 | configureToolBarMenu->setItemChecked( 100, true ); |
1019 | if (p-> mShowIconNext) | 1020 | if (p-> mShowIconNext) |
1020 | configureToolBarMenu->setItemChecked( 110, true ); | 1021 | configureToolBarMenu->setItemChecked( 110, true ); |
1021 | if (p-> mShowIconJournal) | 1022 | if (p-> mShowIconJournal) |
1022 | configureToolBarMenu->setItemChecked( 90, true ); | 1023 | configureToolBarMenu->setItemChecked( 90, true ); |
1023 | if (p-> mShowIconWhatsThis) | 1024 | if (p-> mShowIconWhatsThis) |
1024 | configureToolBarMenu->setItemChecked( 300, true ); | 1025 | configureToolBarMenu->setItemChecked( 300, true ); |
1025 | 1026 | ||
1026 | QLabel* dummy = new QLabel( iconToolBar ); | 1027 | QLabel* dummy = new QLabel( iconToolBar ); |
1027 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 1028 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
1028 | if (!p-> mShowIconStretch) | 1029 | if (!p-> mShowIconStretch) |
1029 | iconToolBar->setStretchableWidget ( dummy ) ; | 1030 | iconToolBar->setStretchableWidget ( dummy ) ; |
1030 | else | 1031 | else |
1031 | configureToolBarMenu->setItemChecked( 5, true ); | 1032 | configureToolBarMenu->setItemChecked( 5, true ); |
1032 | if (p-> mShowIconWhatsThis) | 1033 | if (p-> mShowIconWhatsThis) |
1033 | QWhatsThis::whatsThisButton ( iconToolBar ); | 1034 | QWhatsThis::whatsThisButton ( iconToolBar ); |
1034 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 1035 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
1035 | configureAgenda( p->mHourSize ); | 1036 | configureAgenda( p->mHourSize ); |
1036 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 1037 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
1037 | } | 1038 | } |
1038 | 1039 | ||
1039 | void MainWindow::exportToPhone( int mode ) | 1040 | void MainWindow::exportToPhone( int mode ) |
1040 | { | 1041 | { |
1041 | 1042 | ||
1042 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1043 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1043 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1044 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1044 | KOex2phonePrefs ex2phone; | 1045 | KOex2phonePrefs ex2phone; |
1045 | 1046 | ||
1046 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 1047 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1047 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 1048 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1048 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1049 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1049 | if ( mode == 1 ) | 1050 | if ( mode == 1 ) |
1050 | ex2phone.setCaption(i18n("Export complete calendar")); | 1051 | ex2phone.setCaption(i18n("Export complete calendar")); |
1051 | if ( mode == 2 ) | 1052 | if ( mode == 2 ) |
1052 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1053 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1053 | 1054 | ||
1054 | if ( !ex2phone.exec() ) { | 1055 | if ( !ex2phone.exec() ) { |
1055 | return; | 1056 | return; |
1056 | } | 1057 | } |
1057 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1058 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1058 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1059 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1059 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1060 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1060 | 1061 | ||
1061 | int inFuture = 0; | 1062 | int inFuture = 0; |
1062 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1063 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1063 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1064 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1064 | QPtrList<Incidence> delSel; | 1065 | QPtrList<Incidence> delSel; |
1065 | if ( mode == 1 ) | 1066 | if ( mode == 1 ) |
1066 | delSel = mCalendar->rawIncidences(); | 1067 | delSel = mCalendar->rawIncidences(); |
1067 | if ( mode == 2 ) | 1068 | if ( mode == 2 ) |
1068 | delSel = mCalendar->incidences(); | 1069 | delSel = mCalendar->incidences(); |
1069 | CalendarLocal* cal = new CalendarLocal(); | 1070 | CalendarLocal* cal = new CalendarLocal(); |
1070 | cal->setLocalTime(); | 1071 | cal->setLocalTime(); |
1071 | Incidence *incidence = delSel.first(); | 1072 | Incidence *incidence = delSel.first(); |
1072 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1073 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1073 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1074 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1074 | while ( incidence ) { | 1075 | while ( incidence ) { |
1075 | if ( incidence->type() != "Journal" ) { | 1076 | if ( incidence->type() != "Journal" ) { |
1076 | bool add = true; | 1077 | bool add = true; |
1077 | if ( inFuture ) { | 1078 | if ( inFuture ) { |
1078 | QDateTime dt; | 1079 | QDateTime dt; |
1079 | if ( incidence->type() == "Todo" ) { | 1080 | if ( incidence->type() == "Todo" ) { |
1080 | Todo * t = (Todo*)incidence; | 1081 | Todo * t = (Todo*)incidence; |
1081 | if ( t->hasDueDate() ) | 1082 | if ( t->hasDueDate() ) |
1082 | dt = t->dtDue(); | 1083 | dt = t->dtDue(); |
1083 | else | 1084 | else |
1084 | dt = cur.addSecs( 62 ); | 1085 | dt = cur.addSecs( 62 ); |
1085 | } | 1086 | } |
1086 | else { | 1087 | else { |
1087 | bool ok; | 1088 | bool ok; |
1088 | dt = incidence->getNextOccurence( cur, &ok ); | 1089 | dt = incidence->getNextOccurence( cur, &ok ); |
1089 | if ( !ok ) | 1090 | if ( !ok ) |
1090 | dt = cur.addSecs( -62 ); | 1091 | dt = cur.addSecs( -62 ); |
1091 | } | 1092 | } |
1092 | if ( dt < cur || dt > end ) { | 1093 | if ( dt < cur || dt > end ) { |
1093 | add = false; | 1094 | add = false; |
1094 | } | 1095 | } |
1095 | } | 1096 | } |
1096 | if ( add ) { | 1097 | if ( add ) { |
1097 | Incidence *in = incidence->clone(); | 1098 | Incidence *in = incidence->clone(); |
1098 | cal->addIncidence( in ); | 1099 | cal->addIncidence( in ); |
1099 | } | 1100 | } |
1100 | } | 1101 | } |
1101 | incidence = delSel.next(); | 1102 | incidence = delSel.next(); |
1102 | } | 1103 | } |
1103 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1104 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1104 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1105 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1105 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1106 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1106 | 1107 | ||
1107 | setCaption( i18n("Writing to phone...")); | 1108 | setCaption( i18n("Writing to phone...")); |
1108 | if ( PhoneFormat::writeToPhone( cal ) ) | 1109 | if ( PhoneFormat::writeToPhone( cal ) ) |
1109 | setCaption( i18n("Export to phone successful!")); | 1110 | setCaption( i18n("Export to phone successful!")); |
1110 | else | 1111 | else |
1111 | setCaption( i18n("Error exporting to phone!")); | 1112 | setCaption( i18n("Error exporting to phone!")); |
1112 | delete cal; | 1113 | delete cal; |
1113 | } | 1114 | } |
1114 | 1115 | ||
1115 | 1116 | ||
1116 | void MainWindow::setDefaultPreferences() | 1117 | void MainWindow::setDefaultPreferences() |
1117 | { | 1118 | { |
1118 | KOPrefs *p = KOPrefs::instance(); | 1119 | KOPrefs *p = KOPrefs::instance(); |
1119 | 1120 | ||
1120 | p->mCompactDialogs = true; | 1121 | p->mCompactDialogs = true; |
1121 | p->mConfirm = true; | 1122 | p->mConfirm = true; |
1122 | // p->mEnableQuickTodo = false; | 1123 | // p->mEnableQuickTodo = false; |
1123 | 1124 | ||
1124 | } | 1125 | } |
1125 | 1126 | ||
1126 | QString MainWindow::resourcePath() | 1127 | QString MainWindow::resourcePath() |
1127 | { | 1128 | { |
1128 | return KGlobal::iconLoader()->iconPath(); | 1129 | return KGlobal::iconLoader()->iconPath(); |
1129 | } | 1130 | } |
1130 | 1131 | ||
1131 | void MainWindow::displayText( QString text ,QString cap ) | 1132 | void MainWindow::displayText( QString text ,QString cap ) |
1132 | { | 1133 | { |
1133 | QDialog dia( this, "name", true ); ; | 1134 | QDialog dia( this, "name", true ); ; |
1134 | dia.setCaption( cap ); | 1135 | dia.setCaption( cap ); |
1135 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1136 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1136 | lay->setSpacing( 3 ); | 1137 | lay->setSpacing( 3 ); |
1137 | lay->setMargin( 3 ); | 1138 | lay->setMargin( 3 ); |
1138 | QTextBrowser tb ( &dia ); | 1139 | QTextBrowser tb ( &dia ); |
1139 | lay->addWidget( &tb ); | 1140 | lay->addWidget( &tb ); |
1140 | tb.setText( text ); | 1141 | tb.setText( text ); |
1141 | #ifdef DESKTOP_VERSION | 1142 | #ifdef DESKTOP_VERSION |
1142 | dia.resize( 640, 480); | 1143 | dia.resize( 640, 480); |
1143 | #else | 1144 | #else |
1144 | dia.showMaximized(); | 1145 | dia.showMaximized(); |
1145 | #endif | 1146 | #endif |
1146 | dia.exec(); | 1147 | dia.exec(); |
1147 | } | 1148 | } |
1148 | 1149 | ||
1149 | void MainWindow::features() | 1150 | void MainWindow::features() |
1150 | { | 1151 | { |
1151 | 1152 | ||
1152 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); | 1153 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); |
1153 | } | 1154 | } |
1154 | 1155 | ||
1155 | void MainWindow::usertrans() | 1156 | void MainWindow::usertrans() |
1156 | { | 1157 | { |
1157 | 1158 | ||
1158 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); | 1159 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); |
1159 | } | 1160 | } |
1160 | 1161 | ||
1161 | void MainWindow::kdesynchowto() | 1162 | void MainWindow::kdesynchowto() |
1162 | { | 1163 | { |
1163 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 1164 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
1164 | } | 1165 | } |
1165 | void MainWindow::multisynchowto() | 1166 | void MainWindow::multisynchowto() |
1166 | { | 1167 | { |
1167 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 1168 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
1168 | } | 1169 | } |
1169 | void MainWindow::synchowto() | 1170 | void MainWindow::synchowto() |
1170 | { | 1171 | { |
1171 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1172 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1172 | } | 1173 | } |
1173 | void MainWindow::faq() | 1174 | void MainWindow::faq() |
1174 | { | 1175 | { |
1175 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); | 1176 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); |
1176 | 1177 | ||
1177 | } | 1178 | } |
1178 | void MainWindow::whatsNew() | 1179 | void MainWindow::whatsNew() |
1179 | { | 1180 | { |
1180 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1181 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1181 | 1182 | ||
1182 | } | 1183 | } |
1183 | void MainWindow::licence() | 1184 | void MainWindow::licence() |
1184 | { | 1185 | { |
1185 | KApplication::showLicence(); | 1186 | KApplication::showLicence(); |
1186 | 1187 | ||
1187 | } | 1188 | } |
1188 | void MainWindow::about() | 1189 | void MainWindow::about() |
1189 | { | 1190 | { |
1190 | QString version; | 1191 | QString version; |
1191 | #include <../version> | 1192 | #include <../version> |
1192 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1193 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1193 | i18n("KOrganizer/Platform-independent\n") + | 1194 | i18n("KOrganizer/Platform-independent\n") + |
1194 | "(KO/Pi) " + version + " - " + | 1195 | "(KO/Pi) " + version + " - " + |
1195 | 1196 | ||
1196 | #ifdef DESKTOP_VERSION | 1197 | #ifdef DESKTOP_VERSION |
1197 | i18n("Desktop Edition\n") + | 1198 | i18n("Desktop Edition\n") + |
1198 | #else | 1199 | #else |
1199 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1200 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1200 | #endif | 1201 | #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") ); | 1202 | 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 | } | 1203 | } |
1203 | void MainWindow::keyBindings() | 1204 | void MainWindow::keyBindings() |
1204 | { | 1205 | { |
1205 | QString cap = i18n("KO/Pi Keys + Colors"); | 1206 | QString cap = i18n("KO/Pi Keys + Colors"); |
1206 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1207 | 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")+ | 1208 | 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") + | 1209 | 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")+ | 1210 | 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")+ | 1211 | 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")+ | 1212 | 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")+ | 1213 | 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 ")+ | 1214 | 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")+ | 1215 | 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")+ | 1216 | 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")+ | 1217 | 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")+ | 1218 | 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")+ | 1219 | 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")+ | 1220 | 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")+ | 1221 | 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")+ | 1222 | 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")+ | 1223 | 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")+ | 1224 | 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")+ | 1225 | 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")+ | 1226 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1226 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1227 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1227 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1228 | 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")+ | 1229 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1229 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1230 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1230 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1231 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1231 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1232 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1232 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1233 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1233 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1234 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1234 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1235 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1235 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1236 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1236 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1237 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1237 | i18n("<p><h3>In list view:</h3></p>\n") + | 1238 | i18n("<p><h3>In list view:</h3></p>\n") + |
1238 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1239 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1239 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1240 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1240 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1241 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1241 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1242 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1242 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1243 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1243 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1244 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1244 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1245 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1245 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1246 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1246 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1247 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1247 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1248 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1248 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1249 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1249 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1250 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1250 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1251 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1251 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1252 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1252 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1253 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1253 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1254 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1254 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1255 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1255 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1256 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1256 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1257 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1257 | displayText( text, cap); | 1258 | displayText( text, cap); |
1258 | } | 1259 | } |
1259 | void MainWindow::aboutAutoSaving() | 1260 | void MainWindow::aboutAutoSaving() |
1260 | { | 1261 | { |
1261 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) 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"); | 1262 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) 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"); |
1262 | 1263 | ||
1263 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); | 1264 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); |
1264 | 1265 | ||
1265 | } | 1266 | } |
1266 | void MainWindow::aboutKnownBugs() | 1267 | void MainWindow::aboutKnownBugs() |
1267 | { | 1268 | { |
1268 | QMessageBox* msg; | 1269 | QMessageBox* msg; |
1269 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1270 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1270 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1271 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1271 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1272 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1272 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1273 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1273 | i18n("\nor report them in the bugtracker on\n") + | 1274 | i18n("\nor report them in the bugtracker on\n") + |
1274 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1275 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1275 | QMessageBox::NoIcon, | 1276 | QMessageBox::NoIcon, |
1276 | QMessageBox::Ok, | 1277 | QMessageBox::Ok, |
1277 | QMessageBox::NoButton, | 1278 | QMessageBox::NoButton, |
1278 | QMessageBox::NoButton); | 1279 | QMessageBox::NoButton); |
1279 | msg->exec(); | 1280 | msg->exec(); |
1280 | delete msg; | 1281 | delete msg; |
1281 | 1282 | ||
1282 | } | 1283 | } |
1283 | 1284 | ||
1284 | QString MainWindow::defaultFileName() | 1285 | QString MainWindow::defaultFileName() |
1285 | { | 1286 | { |
1286 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1287 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1287 | } | 1288 | } |
1288 | QString MainWindow::syncFileName() | 1289 | QString MainWindow::syncFileName() |
1289 | { | 1290 | { |
1290 | #ifdef DESKTOP_VERSION | 1291 | #ifdef DESKTOP_VERSION |
1291 | return locateLocal( "tmp", "synccalendar.ics" ); | 1292 | return locateLocal( "tmp", "synccalendar.ics" ); |
1292 | #else | 1293 | #else |
1293 | return QString( "/tmp/synccalendar.ics" ); | 1294 | return QString( "/tmp/synccalendar.ics" ); |
1294 | #endif | 1295 | #endif |
1295 | } | 1296 | } |
1296 | 1297 | ||
1297 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1298 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1298 | { | 1299 | { |
1299 | if ( !incidence ) { | 1300 | if ( !incidence ) { |
1300 | enableIncidenceActions( false ); | 1301 | enableIncidenceActions( false ); |
1301 | 1302 | ||
1302 | mNewSubTodoAction->setEnabled( false ); | 1303 | mNewSubTodoAction->setEnabled( false ); |
1303 | setCaptionToDates(); | 1304 | setCaptionToDates(); |
1304 | return; | 1305 | return; |
1305 | 1306 | ||
1306 | } | 1307 | } |
1307 | 1308 | ||
1308 | //KGlobal::locale()->formatDateTime(nextA, true); | 1309 | //KGlobal::locale()->formatDateTime(nextA, true); |
1309 | QString startString = ""; | 1310 | QString startString = ""; |
1310 | if ( incidence->type() != "Todo" ) { | 1311 | if ( incidence->type() != "Todo" ) { |
1311 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1312 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1312 | if ( incidence->doesFloat() ) { | 1313 | if ( incidence->doesFloat() ) { |
1313 | startString += ": "+incidence->dtStartDateStr( true ); | 1314 | startString += ": "+incidence->dtStartDateStr( true ); |
1314 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1315 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1315 | 1316 | ||
1316 | } else { | 1317 | } else { |
1317 | startString = ": "+incidence->dtStartStr(true); | 1318 | startString = ": "+incidence->dtStartStr(true); |
1318 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1319 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1319 | 1320 | ||
1320 | } | 1321 | } |
1321 | 1322 | ||
1322 | } else { | 1323 | } else { |
1323 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1324 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1324 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1325 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1325 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1326 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1326 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1327 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1327 | } | 1328 | } |
1328 | 1329 | ||
1329 | } | 1330 | } |
1330 | else | 1331 | else |
1331 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1332 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1332 | if ( !incidence->location().isEmpty() ) | 1333 | if ( !incidence->location().isEmpty() ) |
1333 | startString += " (" +incidence->location()+")"; | 1334 | startString += " (" +incidence->location()+")"; |
1334 | setCaption( incidence->summary()+startString); | 1335 | setCaption( incidence->summary()+startString); |
1335 | 1336 | ||
1336 | enableIncidenceActions( true ); | 1337 | enableIncidenceActions( true ); |
1337 | 1338 | ||
1338 | if ( incidence->type() == "Event" ) { | 1339 | if ( incidence->type() == "Event" ) { |
1339 | mShowAction->setText( i18n("Show Event...") ); | 1340 | mShowAction->setText( i18n("Show Event...") ); |
1340 | mEditAction->setText( i18n("Edit Event...") ); | 1341 | mEditAction->setText( i18n("Edit Event...") ); |
1341 | mDeleteAction->setText( i18n("Delete Event...") ); | 1342 | mDeleteAction->setText( i18n("Delete Event...") ); |
1342 | 1343 | ||
1343 | mNewSubTodoAction->setEnabled( false ); | 1344 | mNewSubTodoAction->setEnabled( false ); |
1344 | } else if ( incidence->type() == "Todo" ) { | 1345 | } else if ( incidence->type() == "Todo" ) { |
1345 | mShowAction->setText( i18n("Show Todo...") ); | 1346 | mShowAction->setText( i18n("Show Todo...") ); |
1346 | mEditAction->setText( i18n("Edit Todo...") ); | 1347 | mEditAction->setText( i18n("Edit Todo...") ); |
1347 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1348 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1348 | 1349 | ||
1349 | mNewSubTodoAction->setEnabled( true ); | 1350 | mNewSubTodoAction->setEnabled( true ); |
1350 | } else { | 1351 | } else { |
1351 | mShowAction->setText( i18n("Show...") ); | 1352 | mShowAction->setText( i18n("Show...") ); |
1352 | mShowAction->setText( i18n("Edit...") ); | 1353 | mShowAction->setText( i18n("Edit...") ); |
1353 | mShowAction->setText( i18n("Delete...") ); | 1354 | mShowAction->setText( i18n("Delete...") ); |
1354 | 1355 | ||
1355 | mNewSubTodoAction->setEnabled( false ); | 1356 | mNewSubTodoAction->setEnabled( false ); |
1356 | } | 1357 | } |
1357 | } | 1358 | } |
1358 | 1359 | ||
1359 | void MainWindow::enableIncidenceActions( bool enabled ) | 1360 | void MainWindow::enableIncidenceActions( bool enabled ) |
1360 | { | 1361 | { |
1361 | mShowAction->setEnabled( enabled ); | 1362 | mShowAction->setEnabled( enabled ); |
1362 | mEditAction->setEnabled( enabled ); | 1363 | mEditAction->setEnabled( enabled ); |
1363 | mDeleteAction->setEnabled( enabled ); | 1364 | mDeleteAction->setEnabled( enabled ); |
1364 | 1365 | ||
1365 | mCloneAction->setEnabled( enabled ); | 1366 | mCloneAction->setEnabled( enabled ); |
1366 | mMoveAction->setEnabled( enabled ); | 1367 | mMoveAction->setEnabled( enabled ); |
1367 | mBeamAction->setEnabled( enabled ); | 1368 | mBeamAction->setEnabled( enabled ); |
1368 | mCancelAction->setEnabled( enabled ); | 1369 | mCancelAction->setEnabled( enabled ); |
1369 | } | 1370 | } |
1370 | 1371 | ||
1371 | void MainWindow::importOL() | 1372 | void MainWindow::importOL() |
1372 | { | 1373 | { |
1373 | #ifdef _OL_IMPORT_ | 1374 | #ifdef _OL_IMPORT_ |
1374 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1375 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1375 | id->exec(); | 1376 | id->exec(); |
1376 | delete id; | 1377 | delete id; |
1377 | mView->updateView(); | 1378 | mView->updateView(); |
1378 | #endif | 1379 | #endif |
1379 | } | 1380 | } |
1380 | void MainWindow::importBday() | 1381 | void MainWindow::importBday() |
1381 | { | 1382 | { |
1382 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1383 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1383 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1384 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1384 | i18n("Import!"), i18n("Cancel"), 0, | 1385 | i18n("Import!"), i18n("Cancel"), 0, |
1385 | 0, 1 ); | 1386 | 0, 1 ); |
1386 | if ( result == 0 ) { | 1387 | if ( result == 0 ) { |
1387 | mView->importBday(); | 1388 | mView->importBday(); |
1388 | 1389 | ||
1389 | } | 1390 | } |
1390 | 1391 | ||
1391 | 1392 | ||
1392 | } | 1393 | } |
1393 | void MainWindow::importQtopia() | 1394 | void MainWindow::importQtopia() |
1394 | { | 1395 | { |
1395 | #ifndef DESKTOP_VERSION | 1396 | #ifndef DESKTOP_VERSION |
1396 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1397 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1397 | 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"), | 1398 | 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"), |
1398 | i18n("Import!"), i18n("Cancel"), 0, | 1399 | i18n("Import!"), i18n("Cancel"), 0, |
1399 | 0, 1 ); | 1400 | 0, 1 ); |
1400 | if ( result == 0 ) { | 1401 | if ( result == 0 ) { |
1401 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1402 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1402 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1403 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1403 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1404 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1404 | mView->importQtopia( categories, datebook, todolist ); | 1405 | mView->importQtopia( categories, datebook, todolist ); |
1405 | } | 1406 | } |
1406 | #else | 1407 | #else |
1407 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1408 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1408 | i18n("Not supported \non desktop!\n"), | 1409 | i18n("Not supported \non desktop!\n"), |
1409 | i18n("Ok"), i18n("Cancel"), 0, | 1410 | i18n("Ok"), i18n("Cancel"), 0, |
1410 | 0, 1 ); | 1411 | 0, 1 ); |
1411 | 1412 | ||
1412 | #endif | 1413 | #endif |
1413 | } | 1414 | } |
1414 | 1415 | ||
1415 | void MainWindow::saveOnClose() | 1416 | void MainWindow::saveOnClose() |
1416 | { | 1417 | { |
1417 | KOPrefs *p = KOPrefs::instance(); | 1418 | KOPrefs *p = KOPrefs::instance(); |
1418 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1419 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1419 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1420 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1420 | iconToolBar->y() > height()/2; | 1421 | iconToolBar->y() > height()/2; |
1421 | mView->writeSettings(); | 1422 | mView->writeSettings(); |
1422 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1423 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1423 | save(); | 1424 | save(); |
1424 | } | 1425 | } |
1425 | void MainWindow::slotModifiedChanged( bool changed ) | 1426 | void MainWindow::slotModifiedChanged( bool changed ) |
1426 | { | 1427 | { |
1427 | if ( mBlockAtStartup ) | 1428 | if ( mBlockAtStartup ) |
1428 | return; | 1429 | return; |
1429 | int msec; | 1430 | int msec; |
1430 | // we store the changes after 1 minute, | 1431 | // we store the changes after 1 minute, |
1431 | // and for safety reasons after 10 minutes again | 1432 | // and for safety reasons after 10 minutes again |
1432 | if ( !mSyncManager->blockSave() ) | 1433 | if ( !mSyncManager->blockSave() ) |
1433 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1434 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1434 | else | 1435 | else |
1435 | msec = 1000 * 600; | 1436 | msec = 1000 * 600; |
1436 | mSaveTimer.start( msec, true ); // 1 minute | 1437 | mSaveTimer.start( msec, true ); // 1 minute |
1437 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1438 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1438 | mCalendarModifiedFlag = true; | 1439 | mCalendarModifiedFlag = true; |
1439 | } | 1440 | } |
1440 | void MainWindow::save() | 1441 | void MainWindow::save() |
1441 | { | 1442 | { |
1442 | if ( mSyncManager->blockSave() ) | 1443 | if ( mSyncManager->blockSave() ) |
1443 | return; | 1444 | return; |
1444 | mSyncManager->setBlockSave(true); | 1445 | mSyncManager->setBlockSave(true); |
1445 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1446 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1446 | 1447 | ||
1447 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1448 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1448 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1449 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1449 | qDebug("KO: Start saving data to file!"); | 1450 | qDebug("KO: Start saving data to file!"); |
1450 | mView->saveCalendar( defaultFileName() ); | 1451 | mView->saveCalendar( defaultFileName() ); |
1451 | 1452 | ||
1452 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1453 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1453 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1454 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1454 | QString savemes; | 1455 | QString savemes; |
1455 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1456 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1456 | setCaption(savemes); | 1457 | setCaption(savemes); |
1457 | } else | 1458 | } else |
1458 | setCaption(i18n("Saving cancelled!")); | 1459 | setCaption(i18n("Saving cancelled!")); |
1459 | mCalendarModifiedFlag = false; | 1460 | mCalendarModifiedFlag = false; |
1460 | mSyncManager->setBlockSave( false ); | 1461 | mSyncManager->setBlockSave( false ); |
1461 | } | 1462 | } |
1462 | 1463 | ||
1463 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1464 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1464 | { | 1465 | { |
1465 | if ( !e->isAutoRepeat() ) { | 1466 | if ( !e->isAutoRepeat() ) { |
1466 | mFlagKeyPressed = false; | 1467 | mFlagKeyPressed = false; |
1467 | } | 1468 | } |
1468 | } | 1469 | } |
1469 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1470 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1470 | { | 1471 | { |
1471 | qApp->processEvents(); | 1472 | qApp->processEvents(); |
1472 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1473 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1473 | e->ignore(); | 1474 | e->ignore(); |
1474 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1475 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1475 | return; | 1476 | return; |
1476 | } | 1477 | } |
1477 | if (! e->isAutoRepeat() ) | 1478 | if (! e->isAutoRepeat() ) |
1478 | mFlagKeyPressed = true; | 1479 | mFlagKeyPressed = true; |
1479 | KOPrefs *p = KOPrefs::instance(); | 1480 | KOPrefs *p = KOPrefs::instance(); |
1480 | bool showSelectedDates = false; | 1481 | bool showSelectedDates = false; |
1481 | int size; | 1482 | int size; |
1482 | int pro = 0; | 1483 | int pro = 0; |
1483 | //qDebug("MainWindow::keyPressEvent "); | 1484 | //qDebug("MainWindow::keyPressEvent "); |
1484 | switch ( e->key() ) { | 1485 | switch ( e->key() ) { |
1485 | case Qt::Key_Right: | 1486 | case Qt::Key_Right: |
1486 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1487 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1487 | mView->goNextMonth(); | 1488 | mView->goNextMonth(); |
1488 | else | 1489 | else |
1489 | mView->goNext(); | 1490 | mView->goNext(); |
1490 | showSelectedDates = true; | 1491 | showSelectedDates = true; |
1491 | break; | 1492 | break; |
1492 | case Qt::Key_Left: | 1493 | case Qt::Key_Left: |
1493 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1494 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1494 | mView->goPreviousMonth(); | 1495 | mView->goPreviousMonth(); |
1495 | else | 1496 | else |
1496 | mView->goPrevious(); | 1497 | mView->goPrevious(); |
1497 | showSelectedDates = true; | 1498 | showSelectedDates = true; |
1498 | break; | 1499 | break; |
1499 | case Qt::Key_Down: | 1500 | case Qt::Key_Down: |
1500 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1501 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1501 | break; | 1502 | break; |
1502 | case Qt::Key_Up: | 1503 | case Qt::Key_Up: |
1503 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1504 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1504 | break; | 1505 | break; |
1505 | case Qt::Key_I: | 1506 | case Qt::Key_I: |
1506 | mView->showIncidence(); | 1507 | mView->showIncidence(); |
1507 | break; | 1508 | break; |
1508 | case Qt::Key_Delete: | 1509 | case Qt::Key_Delete: |
1509 | case Qt::Key_Backspace: | 1510 | case Qt::Key_Backspace: |
1510 | mView->deleteIncidence(); | 1511 | mView->deleteIncidence(); |
1511 | break; | 1512 | break; |
1512 | case Qt::Key_D: | 1513 | case Qt::Key_D: |
1513 | mView->viewManager()->showDayView(); | 1514 | mView->viewManager()->showDayView(); |
1514 | showSelectedDates = true; | 1515 | showSelectedDates = true; |
1515 | break; | 1516 | break; |
1516 | case Qt::Key_O: | 1517 | case Qt::Key_O: |
1517 | mView->toggleFilerEnabled( ); | 1518 | mView->toggleFilerEnabled( ); |
1518 | break; | 1519 | break; |
1519 | case Qt::Key_0: | 1520 | case Qt::Key_0: |
1520 | case Qt::Key_1: | 1521 | case Qt::Key_1: |
1521 | case Qt::Key_2: | 1522 | case Qt::Key_2: |
1522 | case Qt::Key_3: | 1523 | case Qt::Key_3: |
1523 | case Qt::Key_4: | 1524 | case Qt::Key_4: |
1524 | case Qt::Key_5: | 1525 | case Qt::Key_5: |
1525 | case Qt::Key_6: | 1526 | case Qt::Key_6: |
1526 | case Qt::Key_7: | 1527 | case Qt::Key_7: |
1527 | case Qt::Key_8: | 1528 | case Qt::Key_8: |
1528 | case Qt::Key_9: | 1529 | case Qt::Key_9: |
1529 | pro = e->key()-48; | 1530 | pro = e->key()-48; |
1530 | if ( pro == 0 ) | 1531 | if ( pro == 0 ) |
1531 | pro = 10; | 1532 | pro = 10; |
1532 | if ( e->state() == Qt::ControlButton) | 1533 | if ( e->state() == Qt::ControlButton) |
1533 | pro += 10; | 1534 | pro += 10; |
1534 | break; | 1535 | break; |
1535 | case Qt::Key_M: | 1536 | case Qt::Key_M: |
1536 | mView->viewManager()->showMonthView(); | 1537 | mView->viewManager()->showMonthView(); |
1537 | showSelectedDates = true; | 1538 | showSelectedDates = true; |
1538 | break; | 1539 | break; |
1539 | case Qt::Key_Insert: | 1540 | case Qt::Key_Insert: |
1540 | mView->newEvent(); | 1541 | mView->newEvent(); |
1541 | break; | 1542 | break; |
1542 | case Qt::Key_S : | 1543 | case Qt::Key_S : |
1543 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1544 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1544 | mView->newSubTodo(); | 1545 | mView->newSubTodo(); |
1545 | else | 1546 | else |
1546 | mView->dialogManager()->showSearchDialog(); | 1547 | mView->dialogManager()->showSearchDialog(); |
1547 | break; | 1548 | break; |
1548 | case Qt::Key_Y : | 1549 | case Qt::Key_Y : |
1549 | case Qt::Key_Z : | 1550 | case Qt::Key_Z : |
1550 | mView->viewManager()->showWorkWeekView(); | 1551 | mView->viewManager()->showWorkWeekView(); |
1551 | showSelectedDates = true; | 1552 | showSelectedDates = true; |
1552 | break; | 1553 | break; |
1553 | case Qt::Key_U : | 1554 | case Qt::Key_U : |
1554 | mView->viewManager()->showWeekView(); | 1555 | mView->viewManager()->showWeekView(); |
1555 | showSelectedDates = true; | 1556 | showSelectedDates = true; |
1556 | break; | 1557 | break; |
1557 | case Qt::Key_H : | 1558 | case Qt::Key_H : |
1558 | keyBindings(); | 1559 | keyBindings(); |
1559 | break; | 1560 | break; |
1560 | case Qt::Key_W: | 1561 | case Qt::Key_W: |
1561 | mView->viewManager()->showWhatsNextView(); | 1562 | mView->viewManager()->showWhatsNextView(); |
1562 | break; | 1563 | break; |
1563 | case Qt::Key_L: | 1564 | case Qt::Key_L: |
1564 | mView->viewManager()->showListView(); | 1565 | mView->viewManager()->showListView(); |
1565 | break; | 1566 | break; |
1566 | case Qt::Key_N: | 1567 | case Qt::Key_N: |
1567 | mView->viewManager()->showNextXView(); | 1568 | mView->viewManager()->showNextXView(); |
1568 | showSelectedDates = true; | 1569 | showSelectedDates = true; |
1569 | break; | 1570 | break; |
1570 | case Qt::Key_V: | 1571 | case Qt::Key_V: |
1571 | mView->viewManager()->showTodoView(); | 1572 | mView->viewManager()->showTodoView(); |
1572 | break; | 1573 | break; |
1573 | case Qt::Key_C: | 1574 | case Qt::Key_C: |
1574 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1575 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1575 | break; | 1576 | break; |
1576 | case Qt::Key_P: | 1577 | case Qt::Key_P: |
1577 | mView->showDatePicker( ); | 1578 | mView->showDatePicker( ); |
1578 | break; | 1579 | break; |
1579 | case Qt::Key_F: | 1580 | case Qt::Key_F: |
1580 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1581 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1581 | mView->editFilters(); | 1582 | mView->editFilters(); |
1582 | else | 1583 | else |
1583 | mView->toggleFilter(); | 1584 | mView->toggleFilter(); |
1584 | break; | 1585 | break; |
1585 | case Qt::Key_X: | 1586 | case Qt::Key_X: |
1586 | mView->toggleDateNavigatorWidget(); | 1587 | mView->toggleDateNavigatorWidget(); |
1587 | break; | 1588 | break; |
1588 | case Qt::Key_Space: | 1589 | case Qt::Key_Space: |
1589 | mView->toggleExpand(); | 1590 | mView->toggleExpand(); |
1590 | break; | 1591 | break; |
1591 | case Qt::Key_A: | 1592 | case Qt::Key_A: |
1592 | mView->toggleAllDaySize(); | 1593 | mView->toggleAllDaySize(); |
1593 | break; | 1594 | break; |
1594 | case Qt::Key_T: | 1595 | case Qt::Key_T: |
1595 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1596 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1596 | mView->newTodo(); | 1597 | mView->newTodo(); |
1597 | else { | 1598 | else { |
1598 | mView->goToday(); | 1599 | mView->goToday(); |
1599 | showSelectedDates = true; | 1600 | showSelectedDates = true; |
1600 | } | 1601 | } |
1601 | break; | 1602 | break; |
1602 | case Qt::Key_J: | 1603 | case Qt::Key_J: |
1603 | mView->viewManager()->showJournalView(); | 1604 | mView->viewManager()->showJournalView(); |
1604 | break; | 1605 | break; |
1605 | case Qt::Key_B: | 1606 | case Qt::Key_B: |
1606 | mView->editIncidenceDescription();; | 1607 | mView->editIncidenceDescription();; |
1607 | break; | 1608 | break; |
1608 | // case Qt::Key_Return: | 1609 | // case Qt::Key_Return: |
1609 | case Qt::Key_E: | 1610 | case Qt::Key_E: |
1610 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1611 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1611 | mView->newEvent(); | 1612 | mView->newEvent(); |
1612 | else | 1613 | else |
1613 | mView->editIncidence(); | 1614 | mView->editIncidence(); |
1614 | break; | 1615 | break; |
1615 | case Qt::Key_Plus: | 1616 | case Qt::Key_Plus: |
1616 | size = p->mHourSize +2; | 1617 | size = p->mHourSize +2; |
1617 | if ( size <= 18 ) | 1618 | if ( size <= 18 ) |
1618 | configureAgenda( size ); | 1619 | configureAgenda( size ); |
1619 | break; | 1620 | break; |
1620 | case Qt::Key_Minus: | 1621 | case Qt::Key_Minus: |
1621 | size = p->mHourSize - 2; | 1622 | size = p->mHourSize - 2; |
1622 | if ( size >= 4 ) | 1623 | if ( size >= 4 ) |
1623 | configureAgenda( size ); | 1624 | configureAgenda( size ); |
1624 | break; | 1625 | break; |
1625 | 1626 | ||
1626 | 1627 | ||
1627 | default: | 1628 | default: |
1628 | e->ignore(); | 1629 | e->ignore(); |
1629 | } | 1630 | } |
1630 | if ( pro > 0 ) { | 1631 | if ( pro > 0 ) { |
1631 | mView->selectFilter( pro-1 ); | 1632 | mView->selectFilter( pro-1 ); |
1632 | } | 1633 | } |
1633 | if ( showSelectedDates ) { | 1634 | if ( showSelectedDates ) { |
1634 | ;// setCaptionToDates(); | 1635 | ;// setCaptionToDates(); |
1635 | } | 1636 | } |
1636 | 1637 | ||
1637 | } | 1638 | } |
1638 | 1639 | ||
1639 | void MainWindow::fillFilterMenu() | 1640 | void MainWindow::fillFilterMenu() |
1640 | { | 1641 | { |
1641 | selectFilterMenu->clear(); | 1642 | selectFilterMenu->clear(); |
1642 | bool disable = false; | 1643 | bool disable = false; |
1643 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); | 1644 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); |
1644 | selectFilterMenu->insertSeparator(); | 1645 | selectFilterMenu->insertSeparator(); |
1645 | if ( mView->filterView()->filtersEnabled() ) { | 1646 | if ( mView->filterView()->filtersEnabled() ) { |
1646 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); | 1647 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); |
1647 | } | 1648 | } |
1648 | else { | 1649 | else { |
1649 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); | 1650 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); |
1650 | disable = true; | 1651 | disable = true; |
1651 | } | 1652 | } |
1652 | selectFilterMenu->insertSeparator(); | 1653 | selectFilterMenu->insertSeparator(); |
1653 | QPtrList<CalFilter> fili = mView->filters(); | 1654 | QPtrList<CalFilter> fili = mView->filters(); |
1654 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1655 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1655 | CalFilter *filter = fili.first(); | 1656 | CalFilter *filter = fili.first(); |
1656 | int iii = 2; | 1657 | int iii = 2; |
1657 | while(filter) { | 1658 | while(filter) { |
1658 | selectFilterMenu->insertItem( filter->name(), iii ); | 1659 | selectFilterMenu->insertItem( filter->name(), iii ); |
1659 | if ( filter == curfilter) | 1660 | if ( filter == curfilter) |
1660 | selectFilterMenu->setItemChecked( iii, true ); | 1661 | selectFilterMenu->setItemChecked( iii, true ); |
1661 | if ( disable ) | 1662 | if ( disable ) |
1662 | selectFilterMenu->setItemEnabled( iii, false ); | 1663 | selectFilterMenu->setItemEnabled( iii, false ); |
1663 | filter = fili.next(); | 1664 | filter = fili.next(); |
1664 | ++iii; | 1665 | ++iii; |
1665 | } | 1666 | } |
1666 | } | 1667 | } |
1667 | void MainWindow::selectFilter( int fil ) | 1668 | void MainWindow::selectFilter( int fil ) |
1668 | { | 1669 | { |
1669 | if ( fil == 0 ) { | 1670 | if ( fil == 0 ) { |
1670 | mView->editFilters( ); | 1671 | mView->editFilters( ); |
1671 | } else if ( fil == 1 ){ | 1672 | } else if ( fil == 1 ){ |
1672 | mView->toggleFilerEnabled( ); | 1673 | mView->toggleFilerEnabled( ); |
1673 | } else { | 1674 | } else { |
1674 | mView->selectFilter( fil-2 ); | 1675 | mView->selectFilter( fil-2 ); |
1675 | } | 1676 | } |
1676 | } | 1677 | } |
1677 | void MainWindow::configureToolBar( int item ) | 1678 | void MainWindow::configureToolBar( int item ) |
1678 | { | 1679 | { |
1679 | 1680 | ||
1680 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1681 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1681 | KOPrefs *p = KOPrefs::instance(); | 1682 | KOPrefs *p = KOPrefs::instance(); |
1682 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1683 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1683 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1684 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1684 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1685 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1685 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1686 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1686 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1687 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1687 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1688 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1688 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1689 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1689 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1690 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1690 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1691 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1691 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1692 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1692 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1693 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1693 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1694 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1694 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1695 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1695 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1696 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1696 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1697 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1697 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1698 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1698 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1699 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1699 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1700 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1700 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1701 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1701 | // initActions(); | 1702 | // initActions(); |
1702 | } | 1703 | } |
1703 | 1704 | ||
1704 | void MainWindow::setCaptionToDates() | 1705 | void MainWindow::setCaptionToDates() |
1705 | { | 1706 | { |
1706 | QString selDates; | 1707 | QString selDates; |
1707 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1708 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1708 | if (mView->startDate() < mView->endDate() ) | 1709 | if (mView->startDate() < mView->endDate() ) |
1709 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1710 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1710 | else { | 1711 | else { |
1711 | QString addString; | 1712 | QString addString; |
1712 | if ( mView->startDate() == QDateTime::currentDateTime().date() ) | 1713 | if ( mView->startDate() == QDateTime::currentDateTime().date() ) |
1713 | addString = i18n("Today"); | 1714 | addString = i18n("Today"); |
1714 | else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) | 1715 | else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) |
1715 | addString = i18n("Tomorrow"); | 1716 | addString = i18n("Tomorrow"); |
1716 | if ( !addString.isEmpty() ) | 1717 | if ( !addString.isEmpty() ) |
1717 | selDates = addString+", "+selDates ; | 1718 | selDates = addString+", "+selDates ; |
1718 | } | 1719 | } |
1719 | setCaption( i18n("Dates: ") + selDates ); | 1720 | setCaption( i18n("Dates: ") + selDates ); |
1720 | 1721 | ||
1721 | } | 1722 | } |
1722 | // parameter item == 0: reinit | 1723 | // parameter item == 0: reinit |
1723 | void MainWindow::configureAgenda( int item ) | 1724 | void MainWindow::configureAgenda( int item ) |
1724 | { | 1725 | { |
1725 | 1726 | ||
1726 | KOPrefs *p = KOPrefs::instance(); | 1727 | KOPrefs *p = KOPrefs::instance(); |
1727 | 1728 | ||
1728 | int i; | 1729 | int i; |
1729 | // do not allow 4 for widgets higher than 480 | 1730 | // do not allow 4 for widgets higher than 480 |
1730 | // if ( QApplication::desktop()->height() > 480 ) { | 1731 | // if ( QApplication::desktop()->height() > 480 ) { |
1731 | // if ( item == 4 ) | 1732 | // if ( item == 4 ) |
1732 | // item = 6; | 1733 | // item = 6; |
1733 | // } | 1734 | // } |
1734 | for ( i = 4; i <= 18; i= i+2 ) | 1735 | for ( i = 4; i <= 18; i= i+2 ) |
1735 | configureAgendaMenu->setItemChecked( i, false ); | 1736 | configureAgendaMenu->setItemChecked( i, false ); |
1736 | configureAgendaMenu->setItemChecked( item, true ); | 1737 | configureAgendaMenu->setItemChecked( item, true ); |
1737 | if ( p->mHourSize == item ) | 1738 | if ( p->mHourSize == item ) |
1738 | return; | 1739 | return; |
1739 | p->mHourSize=item; | 1740 | p->mHourSize=item; |
1740 | mView->viewManager()->agendaView()->updateConfig(); | 1741 | mView->viewManager()->agendaView()->updateConfig(); |
1741 | } | 1742 | } |
1742 | 1743 | ||
1743 | void MainWindow::saveCalendar() | 1744 | void MainWindow::saveCalendar() |
1744 | { | 1745 | { |
1745 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1746 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1746 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1747 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1747 | 1748 | ||
1748 | if ( fn == "" ) | 1749 | if ( fn == "" ) |
1749 | return; | 1750 | return; |
1750 | QFileInfo info; | 1751 | QFileInfo info; |
1751 | info.setFile( fn ); | 1752 | info.setFile( fn ); |
1752 | QString mes; | 1753 | QString mes; |
1753 | bool createbup = true; | 1754 | bool createbup = true; |
1754 | if ( info. exists() ) { | 1755 | if ( info. exists() ) { |
1755 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1756 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1756 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1757 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1757 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1758 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1758 | 0, 1 ); | 1759 | 0, 1 ); |
1759 | if ( result != 0 ) { | 1760 | if ( result != 0 ) { |
1760 | createbup = false; | 1761 | createbup = false; |
1761 | } | 1762 | } |
1762 | } | 1763 | } |
1763 | if ( createbup ) { | 1764 | if ( createbup ) { |
1764 | mView->saveCalendar( fn ); | 1765 | mView->saveCalendar( fn ); |
1765 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1766 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1766 | KOPrefs::instance()->mLastSaveFile = fn; | 1767 | KOPrefs::instance()->mLastSaveFile = fn; |
1767 | setCaption(mes); | 1768 | setCaption(mes); |
1768 | } | 1769 | } |
1769 | } | 1770 | } |
1770 | void MainWindow::loadCalendar() | 1771 | void MainWindow::loadCalendar() |
1771 | { | 1772 | { |
1772 | 1773 | ||
1773 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1774 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1774 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1775 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1775 | 1776 | ||
1776 | if ( fn == "" ) | 1777 | if ( fn == "" ) |
1777 | return; | 1778 | return; |
1778 | QFileInfo info; | 1779 | QFileInfo info; |
1779 | info.setFile( fn ); | 1780 | info.setFile( fn ); |
1780 | QString mess; | 1781 | QString mess; |
1781 | bool loadbup = true; | 1782 | bool loadbup = true; |
1782 | if ( info. exists() ) { | 1783 | if ( info. exists() ) { |
1783 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1784 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1784 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1785 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1785 | mess, | 1786 | mess, |
1786 | i18n("Load!"), i18n("Cancel"), 0, | 1787 | i18n("Load!"), i18n("Cancel"), 0, |
1787 | 0, 1 ); | 1788 | 0, 1 ); |
1788 | if ( result != 0 ) { | 1789 | if ( result != 0 ) { |
1789 | loadbup = false; | 1790 | loadbup = false; |
1790 | } | 1791 | } |
1791 | } else { | 1792 | } else { |
1792 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1793 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1793 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1794 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1794 | 0, 1 ); | 1795 | 0, 1 ); |
1795 | 1796 | ||
1796 | return; | 1797 | return; |
1797 | } | 1798 | } |
1798 | if ( loadbup ) { | 1799 | if ( loadbup ) { |
1799 | mView->openCalendar( fn ); | 1800 | mView->openCalendar( fn ); |
1800 | KOPrefs::instance()->mLastLoadFile = fn; | 1801 | KOPrefs::instance()->mLastLoadFile = fn; |
1801 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1802 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1802 | setCaption(mess); | 1803 | setCaption(mess); |
1803 | } | 1804 | } |
1804 | 1805 | ||
1805 | } | 1806 | } |
1806 | void MainWindow::quickImportIcal() | 1807 | void MainWindow::quickImportIcal() |
1807 | { | 1808 | { |
1808 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1809 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1809 | } | 1810 | } |
1810 | void MainWindow::importFile( QString fn, bool quick ) | 1811 | void MainWindow::importFile( QString fn, bool quick ) |
1811 | { | 1812 | { |
1812 | QFileInfo info; | 1813 | QFileInfo info; |
1813 | info.setFile( fn ); | 1814 | info.setFile( fn ); |
1814 | QString mess; | 1815 | QString mess; |
1815 | bool loadbup = true; | 1816 | bool loadbup = true; |
1816 | if ( !info. exists() ) { | 1817 | if ( !info. exists() ) { |
1817 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1818 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1818 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1819 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1819 | mess ); | 1820 | mess ); |
1820 | return; | 1821 | return; |
1821 | } | 1822 | } |
1822 | int result = 0; | 1823 | int result = 0; |
1823 | if ( !quick ) { | 1824 | if ( !quick ) { |
1824 | 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 )); | 1825 | 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 )); |
1825 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1826 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1826 | mess, | 1827 | mess, |
1827 | "Import", "Cancel", 0, | 1828 | "Import", "Cancel", 0, |
1828 | 0, 1 ); | 1829 | 0, 1 ); |
1829 | } | 1830 | } |
1830 | if ( result == 0 ) { | 1831 | if ( result == 0 ) { |
1831 | if ( mView->openCalendar( fn, true )) { | 1832 | if ( mView->openCalendar( fn, true )) { |
1832 | KOPrefs::instance()->mLastImportFile = fn; | 1833 | KOPrefs::instance()->mLastImportFile = fn; |
1833 | setCaption(i18n("Imported file successfully")); | 1834 | setCaption(i18n("Imported file successfully")); |
1834 | } else { | 1835 | } else { |
1835 | setCaption(i18n("Error importing file")); | 1836 | setCaption(i18n("Error importing file")); |
1836 | } | 1837 | } |
1837 | } | 1838 | } |
1838 | } | 1839 | } |
1839 | 1840 | ||
1840 | void MainWindow::importIcal() | 1841 | void MainWindow::importIcal() |
1841 | { | 1842 | { |
1842 | 1843 | ||
1843 | QString fn =KOPrefs::instance()->mLastImportFile; | 1844 | QString fn =KOPrefs::instance()->mLastImportFile; |
1844 | 1845 | ||
1845 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1846 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1846 | if ( fn == "" ) | 1847 | if ( fn == "" ) |
1847 | return; | 1848 | return; |
1848 | importFile( fn, true ); | 1849 | importFile( fn, true ); |
1849 | 1850 | ||
1850 | } | 1851 | } |
1851 | 1852 | ||
1852 | void MainWindow::exportVCalendar() | 1853 | void MainWindow::exportVCalendar() |
1853 | { | 1854 | { |
1854 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1855 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1855 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1856 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1856 | if ( fn == "" ) | 1857 | if ( fn == "" ) |
1857 | return; | 1858 | return; |
1858 | QFileInfo info; | 1859 | QFileInfo info; |
1859 | info.setFile( fn ); | 1860 | info.setFile( fn ); |
1860 | QString mes; | 1861 | QString mes; |
1861 | bool createbup = true; | 1862 | bool createbup = true; |
1862 | if ( info. exists() ) { | 1863 | if ( info. exists() ) { |
1863 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1864 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1864 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1865 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1865 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1866 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1866 | 0, 1 ); | 1867 | 0, 1 ); |
1867 | if ( result != 0 ) { | 1868 | if ( result != 0 ) { |
1868 | createbup = false; | 1869 | createbup = false; |
1869 | } | 1870 | } |
1870 | } | 1871 | } |
1871 | if ( createbup ) { | 1872 | if ( createbup ) { |
1872 | if ( mView->exportVCalendar( fn ) ) { | 1873 | if ( mView->exportVCalendar( fn ) ) { |
1873 | KOPrefs::instance()->mLastVcalFile = fn; | 1874 | KOPrefs::instance()->mLastVcalFile = fn; |
1874 | if ( fn.length() > 20 ) | 1875 | if ( fn.length() > 20 ) |
1875 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1876 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1876 | else | 1877 | else |
1877 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1878 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1878 | setCaption(mes); | 1879 | setCaption(mes); |
1879 | } | 1880 | } |
1880 | } | 1881 | } |
1881 | 1882 | ||
1882 | } | 1883 | } |
1883 | 1884 | ||
1884 | void MainWindow::syncFileRequest() | 1885 | void MainWindow::syncFileRequest() |
1885 | { | 1886 | { |
1886 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 1887 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
1887 | mSyncManager->slotSyncMenu( 999 ); | 1888 | mSyncManager->slotSyncMenu( 999 ); |
1888 | } | 1889 | } |
1889 | save(); | 1890 | save(); |
1890 | } | 1891 | } |
1891 | void MainWindow::getFile( bool success ) | 1892 | void MainWindow::getFile( bool success ) |
1892 | { | 1893 | { |
1893 | if ( ! success ) { | 1894 | if ( ! success ) { |
1894 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 1895 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
1895 | return; | 1896 | return; |
1896 | } | 1897 | } |
1897 | mView->openCalendar( defaultFileName() ); | 1898 | mView->openCalendar( defaultFileName() ); |
1898 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 1899 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
1899 | mSyncManager->slotSyncMenu( 999 ); | 1900 | mSyncManager->slotSyncMenu( 999 ); |
1900 | } | 1901 | } |
1901 | setCaption( i18n("Pi-Sync successful!") ); | 1902 | setCaption( i18n("Pi-Sync successful!") ); |
1902 | } | 1903 | } |
1903 | 1904 | ||
1904 | void MainWindow::printSel( ) | 1905 | void MainWindow::printSel( ) |
1905 | { | 1906 | { |
1906 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 1907 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
1907 | } | 1908 | } |
1908 | 1909 | ||
1909 | void MainWindow::printCal() | 1910 | void MainWindow::printCal() |
1910 | { | 1911 | { |
1911 | mView->print();//mCp->showDialog(); | 1912 | mView->print();//mCp->showDialog(); |
1912 | } | 1913 | } |
1913 | 1914 | ||
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index f488a07..3adbf61 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,1485 +1,1485 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | 52 | ||
53 | #include <klocale.h> | 53 | #include <klocale.h> |
54 | #include <kglobal.h> | 54 | #include <kglobal.h> |
55 | #include <kconfig.h> | 55 | #include <kconfig.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | 57 | ||
58 | QDateTime KSyncManager::mRequestedSyncEvent; | 58 | QDateTime KSyncManager::mRequestedSyncEvent; |
59 | 59 | ||
60 | 60 | ||
61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
62 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) | 62 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) |
63 | { | 63 | { |
64 | mServerSocket = 0; | 64 | mServerSocket = 0; |
65 | bar = new QProgressBar ( 1, 0 ); | 65 | bar = new QProgressBar ( 1, 0 ); |
66 | bar->setCaption (""); | 66 | bar->setCaption (""); |
67 | mWriteBackInPast = 2; | 67 | mWriteBackInPast = 2; |
68 | int w = 300; | 68 | int w = 300; |
69 | if ( QApplication::desktop()->width() < 320 ) | 69 | if ( QApplication::desktop()->width() < 320 ) |
70 | w = 220; | 70 | w = 220; |
71 | int h = bar->sizeHint().height() ; | 71 | int h = bar->sizeHint().height() ; |
72 | int dw = QApplication::desktop()->width(); | 72 | int dw = QApplication::desktop()->width(); |
73 | int dh = QApplication::desktop()->height(); | 73 | int dh = QApplication::desktop()->height(); |
74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
75 | if ( mPrefs->mPassiveSyncAutoStart ) | 75 | if ( mPrefs->mPassiveSyncAutoStart ) |
76 | enableQuick( false ); | 76 | enableQuick( false ); |
77 | 77 | ||
78 | } | 78 | } |
79 | 79 | ||
80 | KSyncManager::~KSyncManager() | 80 | KSyncManager::~KSyncManager() |
81 | { | 81 | { |
82 | delete bar; | 82 | delete bar; |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | void KSyncManager::fillSyncMenu() | 86 | void KSyncManager::fillSyncMenu() |
87 | { | 87 | { |
88 | if ( mSyncMenu->count() ) | 88 | if ( mSyncMenu->count() ) |
89 | mSyncMenu->clear(); | 89 | mSyncMenu->clear(); |
90 | 90 | ||
91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
92 | mSyncMenu->insertSeparator(); | 92 | mSyncMenu->insertSeparator(); |
93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
95 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | 95 | clearMenu->insertItem( i18n("For all profiles"), 1 ); |
96 | clearMenu->insertSeparator(); | 96 | clearMenu->insertSeparator(); |
97 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | 97 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); |
98 | mSyncMenu->insertSeparator(); | 98 | mSyncMenu->insertSeparator(); |
99 | if ( mServerSocket == 0 ) { | 99 | if ( mServerSocket == 0 ) { |
100 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 100 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
101 | } else { | 101 | } else { |
102 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 102 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
103 | } | 103 | } |
104 | mSyncMenu->insertSeparator(); | 104 | mSyncMenu->insertSeparator(); |
105 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 105 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
106 | mSyncMenu->insertSeparator(); | 106 | mSyncMenu->insertSeparator(); |
107 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 107 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
108 | config.setGroup("General"); | 108 | config.setGroup("General"); |
109 | QStringList prof = config.readListEntry("SyncProfileNames"); | 109 | QStringList prof = config.readListEntry("SyncProfileNames"); |
110 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 110 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
111 | if ( prof.count() < 2 ) { | 111 | if ( prof.count() < 2 ) { |
112 | prof.clear(); | 112 | prof.clear(); |
113 | QString externalName; | 113 | QString externalName; |
114 | #ifdef DESKTOP_VERSION | 114 | #ifdef DESKTOP_VERSION |
115 | #ifdef _WIN32_ | 115 | #ifdef _WIN32_ |
116 | externalName = "OutLook(not_implemented)"; | 116 | externalName = "OutLook(not_implemented)"; |
117 | #else | 117 | #else |
118 | externalName = "KDE_Desktop"; | 118 | externalName = "KDE_Desktop"; |
119 | #endif | 119 | #endif |
120 | #else | 120 | #else |
121 | externalName = "Sharp_DTM"; | 121 | externalName = "Sharp_DTM"; |
122 | #endif | 122 | #endif |
123 | prof << externalName; | 123 | prof << externalName; |
124 | prof << i18n("Local_file"); | 124 | prof << i18n("Local_file"); |
125 | prof << i18n("Last_file"); | 125 | prof << i18n("Last_file"); |
126 | KSyncProfile* temp = new KSyncProfile (); | 126 | KSyncProfile* temp = new KSyncProfile (); |
127 | temp->setName( prof[0] ); | 127 | temp->setName( prof[0] ); |
128 | temp->writeConfig(&config); | 128 | temp->writeConfig(&config); |
129 | temp->setName( prof[1] ); | 129 | temp->setName( prof[1] ); |
130 | temp->writeConfig(&config); | 130 | temp->writeConfig(&config); |
131 | temp->setName( prof[2] ); | 131 | temp->setName( prof[2] ); |
132 | temp->writeConfig(&config); | 132 | temp->writeConfig(&config); |
133 | config.setGroup("General"); | 133 | config.setGroup("General"); |
134 | config.writeEntry("SyncProfileNames",prof); | 134 | config.writeEntry("SyncProfileNames",prof); |
135 | config.writeEntry("ExternSyncProfiles",externalName); | 135 | config.writeEntry("ExternSyncProfiles",externalName); |
136 | config.sync(); | 136 | config.sync(); |
137 | delete temp; | 137 | delete temp; |
138 | } | 138 | } |
139 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 139 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
140 | mSyncProfileNames = prof; | 140 | mSyncProfileNames = prof; |
141 | unsigned int i; | 141 | unsigned int i; |
142 | for ( i = 0; i < prof.count(); ++i ) { | 142 | for ( i = 0; i < prof.count(); ++i ) { |
143 | mSyncMenu->insertItem( prof[i], 1000+i ); | 143 | mSyncMenu->insertItem( prof[i], 1000+i ); |
144 | clearMenu->insertItem( prof[i], 1000+i ); | 144 | clearMenu->insertItem( prof[i], 1000+i ); |
145 | if ( i == 2 ) | 145 | if ( i == 2 ) |
146 | mSyncMenu->insertSeparator(); | 146 | mSyncMenu->insertSeparator(); |
147 | } | 147 | } |
148 | QDir app_dir; | 148 | QDir app_dir; |
149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
150 | if ( mTargetApp == PWMPI) { | 150 | if ( mTargetApp == PWMPI) { |
151 | mSyncMenu->removeItem( 1000 ); | 151 | mSyncMenu->removeItem( 1000 ); |
152 | clearMenu->removeItem( 1000 ); | 152 | clearMenu->removeItem( 1000 ); |
153 | } | 153 | } |
154 | #ifndef DESKTOP_VERSION | 154 | #ifndef DESKTOP_VERSION |
155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
156 | mSyncMenu->removeItem( 1000 ); | 156 | mSyncMenu->removeItem( 1000 ); |
157 | clearMenu->removeItem( 1000 ); | 157 | clearMenu->removeItem( 1000 ); |
158 | } | 158 | } |
159 | #endif | 159 | #endif |
160 | mSyncMenu->removeItem( 1002 ); | 160 | mSyncMenu->removeItem( 1002 ); |
161 | clearMenu->removeItem( 1002 ); | 161 | clearMenu->removeItem( 1002 ); |
162 | } | 162 | } |
163 | void KSyncManager::slotClearMenu( int action ) | 163 | void KSyncManager::slotClearMenu( int action ) |
164 | { | 164 | { |
165 | QString syncDevice; | 165 | QString syncDevice; |
166 | if ( action > 999 ) { | 166 | if ( action > 999 ) { |
167 | syncDevice = mSyncProfileNames[action - 1000] ; | 167 | syncDevice = mSyncProfileNames[action - 1000] ; |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | 171 | ||
172 | int result = 0; | 172 | int result = 0; |
173 | QString sd; | 173 | QString sd; |
174 | if ( syncDevice.isEmpty() ) | 174 | if ( syncDevice.isEmpty() ) |
175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
176 | else | 176 | else |
177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
178 | 178 | ||
179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
180 | 0, 1 ); | 180 | 0, 1 ); |
181 | if ( result ) | 181 | if ( result ) |
182 | return; | 182 | return; |
183 | mImplementation->removeSyncInfo( syncDevice ); | 183 | mImplementation->removeSyncInfo( syncDevice ); |
184 | } | 184 | } |
185 | void KSyncManager::slotSyncMenu( int action ) | 185 | void KSyncManager::slotSyncMenu( int action ) |
186 | { | 186 | { |
187 | qDebug("syncaction %d ", action); | 187 | qDebug("KSM::syncaction %d ", action); |
188 | if ( action == 5000 ) | 188 | if ( action == 5000 ) |
189 | return; | 189 | return; |
190 | mSyncWithDesktop = false; | 190 | mSyncWithDesktop = false; |
191 | if ( action == 0 ) { | 191 | if ( action == 0 ) { |
192 | 192 | ||
193 | // seems to be a Qt2 event handling bug | 193 | // seems to be a Qt2 event handling bug |
194 | // syncmenu.clear causes a segfault at first time | 194 | // syncmenu.clear causes a segfault at first time |
195 | // when we call it after the main event loop, it is ok | 195 | // when we call it after the main event loop, it is ok |
196 | // same behaviour when calling OM/Pi via QCOP for the first time | 196 | // same behaviour when calling OM/Pi via QCOP for the first time |
197 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 197 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
198 | //confSync(); | 198 | //confSync(); |
199 | 199 | ||
200 | return; | 200 | return; |
201 | } | 201 | } |
202 | if ( action == 1 ) { | 202 | if ( action == 1 ) { |
203 | multiSync( true ); | 203 | multiSync( true ); |
204 | return; | 204 | return; |
205 | } | 205 | } |
206 | if ( action == 2 ) { | 206 | if ( action == 2 ) { |
207 | enableQuick(); | 207 | enableQuick(); |
208 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 208 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
209 | return; | 209 | return; |
210 | } | 210 | } |
211 | if ( action == 3 ) { | 211 | if ( action == 3 ) { |
212 | delete mServerSocket; | 212 | delete mServerSocket; |
213 | mServerSocket = 0; | 213 | mServerSocket = 0; |
214 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 214 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | 217 | ||
218 | if (blockSave()) | 218 | if (blockSave()) |
219 | return; | 219 | return; |
220 | 220 | ||
221 | setBlockSave(true); | 221 | setBlockSave(true); |
222 | bool silent = false; | 222 | bool silent = false; |
223 | if ( action == 999 ) { | 223 | if ( action == 999 ) { |
224 | //special mode for silent syncing | 224 | //special mode for silent syncing |
225 | action = 1000; | 225 | action = 1000; |
226 | silent = true; | 226 | silent = true; |
227 | } | 227 | } |
228 | 228 | ||
229 | mCurrentSyncProfile = action - 1000 ; | 229 | mCurrentSyncProfile = action - 1000 ; |
230 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 230 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
231 | mCurrentSyncName = mLocalMachineName ; | 231 | mCurrentSyncName = mLocalMachineName ; |
232 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 232 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
233 | KSyncProfile* temp = new KSyncProfile (); | 233 | KSyncProfile* temp = new KSyncProfile (); |
234 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 234 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
235 | temp->readConfig(&config); | 235 | temp->readConfig(&config); |
236 | if (silent) { | 236 | if (silent) { |
237 | mAskForPreferences = false; | 237 | mAskForPreferences = false; |
238 | mShowSyncSummary = false; | 238 | mShowSyncSummary = false; |
239 | mWriteBackFile = true; | 239 | mWriteBackFile = true; |
240 | mSyncAlgoPrefs = 2;// take newest | 240 | mSyncAlgoPrefs = 2;// take newest |
241 | } | 241 | } |
242 | else { | 242 | else { |
243 | mAskForPreferences = temp->getAskForPreferences(); | 243 | mAskForPreferences = temp->getAskForPreferences(); |
244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
245 | mWriteBackFile = temp->getWriteBackFile(); | 245 | mWriteBackFile = temp->getWriteBackFile(); |
246 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 246 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
247 | } | 247 | } |
248 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 248 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
249 | mIsKapiFile = temp->getIsKapiFile(); | 249 | mIsKapiFile = temp->getIsKapiFile(); |
250 | mWriteBackInFuture = 0; | 250 | mWriteBackInFuture = 0; |
251 | if ( temp->getWriteBackFuture() ) { | 251 | if ( temp->getWriteBackFuture() ) { |
252 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 252 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
253 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 253 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
254 | } | 254 | } |
255 | mFilterInCal = temp->getFilterInCal(); | 255 | mFilterInCal = temp->getFilterInCal(); |
256 | mFilterOutCal = temp->getFilterOutCal(); | 256 | mFilterOutCal = temp->getFilterOutCal(); |
257 | mFilterInAB = temp->getFilterInAB(); | 257 | mFilterInAB = temp->getFilterInAB(); |
258 | mFilterOutAB = temp->getFilterOutAB(); | 258 | mFilterOutAB = temp->getFilterOutAB(); |
259 | 259 | ||
260 | if ( action == 1000 ) { | 260 | if ( action == 1000 ) { |
261 | mIsKapiFile = false; | 261 | mIsKapiFile = false; |
262 | #ifdef DESKTOP_VERSION | 262 | #ifdef DESKTOP_VERSION |
263 | syncKDE(); | 263 | syncKDE(); |
264 | #else | 264 | #else |
265 | syncSharp(); | 265 | syncSharp(); |
266 | #endif | 266 | #endif |
267 | 267 | ||
268 | } else if ( action == 1001 ) { | 268 | } else if ( action == 1001 ) { |
269 | syncLocalFile(); | 269 | syncLocalFile(); |
270 | 270 | ||
271 | } else if ( action == 1002 ) { | 271 | } else if ( action == 1002 ) { |
272 | mWriteBackFile = false; | 272 | mWriteBackFile = false; |
273 | mAskForPreferences = false; | 273 | mAskForPreferences = false; |
274 | mShowSyncSummary = false; | 274 | mShowSyncSummary = false; |
275 | mSyncAlgoPrefs = 3; | 275 | mSyncAlgoPrefs = 3; |
276 | quickSyncLocalFile(); | 276 | quickSyncLocalFile(); |
277 | 277 | ||
278 | } else if ( action >= 1003 ) { | 278 | } else if ( action >= 1003 ) { |
279 | if ( temp->getIsLocalFileSync() ) { | 279 | if ( temp->getIsLocalFileSync() ) { |
280 | switch(mTargetApp) | 280 | switch(mTargetApp) |
281 | { | 281 | { |
282 | case (KAPI): | 282 | case (KAPI): |
283 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 283 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
284 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 284 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
285 | break; | 285 | break; |
286 | case (KOPI): | 286 | case (KOPI): |
287 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 287 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
288 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 288 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
289 | break; | 289 | break; |
290 | case (PWMPI): | 290 | case (PWMPI): |
291 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 291 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
292 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 292 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
293 | break; | 293 | break; |
294 | default: | 294 | default: |
295 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 295 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
296 | break; | 296 | break; |
297 | 297 | ||
298 | } | 298 | } |
299 | } else { | 299 | } else { |
300 | if ( temp->getIsPhoneSync() ) { | 300 | if ( temp->getIsPhoneSync() ) { |
301 | mPhoneDevice = temp->getPhoneDevice( ) ; | 301 | mPhoneDevice = temp->getPhoneDevice( ) ; |
302 | mPhoneConnection = temp->getPhoneConnection( ); | 302 | mPhoneConnection = temp->getPhoneConnection( ); |
303 | mPhoneModel = temp->getPhoneModel( ); | 303 | mPhoneModel = temp->getPhoneModel( ); |
304 | syncPhone(); | 304 | syncPhone(); |
305 | } else if ( temp->getIsPiSync() ) { | 305 | } else if ( temp->getIsPiSync() ) { |
306 | if ( mTargetApp == KAPI ) { | 306 | if ( mTargetApp == KAPI ) { |
307 | mPassWordPiSync = temp->getRemotePwAB(); | 307 | mPassWordPiSync = temp->getRemotePwAB(); |
308 | mActiveSyncPort = temp->getRemotePortAB(); | 308 | mActiveSyncPort = temp->getRemotePortAB(); |
309 | mActiveSyncIP = temp->getRemoteIPAB(); | 309 | mActiveSyncIP = temp->getRemoteIPAB(); |
310 | } else if ( mTargetApp == KOPI ) { | 310 | } else if ( mTargetApp == KOPI ) { |
311 | mPassWordPiSync = temp->getRemotePw(); | 311 | mPassWordPiSync = temp->getRemotePw(); |
312 | mActiveSyncPort = temp->getRemotePort(); | 312 | mActiveSyncPort = temp->getRemotePort(); |
313 | mActiveSyncIP = temp->getRemoteIP(); | 313 | mActiveSyncIP = temp->getRemoteIP(); |
314 | } else { | 314 | } else { |
315 | mPassWordPiSync = temp->getRemotePwPWM(); | 315 | mPassWordPiSync = temp->getRemotePwPWM(); |
316 | mActiveSyncPort = temp->getRemotePortPWM(); | 316 | mActiveSyncPort = temp->getRemotePortPWM(); |
317 | mActiveSyncIP = temp->getRemoteIPPWM(); | 317 | mActiveSyncIP = temp->getRemoteIPPWM(); |
318 | } | 318 | } |
319 | syncPi(); | 319 | syncPi(); |
320 | while ( !mPisyncFinished ) { | 320 | while ( !mPisyncFinished ) { |
321 | //qDebug("waiting "); | 321 | //qDebug("waiting "); |
322 | qApp->processEvents(); | 322 | qApp->processEvents(); |
323 | } | 323 | } |
324 | } else | 324 | } else |
325 | syncRemote( temp ); | 325 | syncRemote( temp ); |
326 | 326 | ||
327 | } | 327 | } |
328 | } | 328 | } |
329 | delete temp; | 329 | delete temp; |
330 | setBlockSave(false); | 330 | setBlockSave(false); |
331 | } | 331 | } |
332 | 332 | ||
333 | void KSyncManager::enableQuick( bool ask ) | 333 | void KSyncManager::enableQuick( bool ask ) |
334 | { | 334 | { |
335 | bool autoStart; | 335 | bool autoStart; |
336 | bool changed = false; | 336 | bool changed = false; |
337 | if ( ask ) { | 337 | if ( ask ) { |
338 | QDialog dia ( 0, "input-dialog", true ); | 338 | QDialog dia ( 0, "input-dialog", true ); |
339 | QLineEdit lab ( &dia ); | 339 | QLineEdit lab ( &dia ); |
340 | QVBoxLayout lay( &dia ); | 340 | QVBoxLayout lay( &dia ); |
341 | lab.setText( mPrefs->mPassiveSyncPort ); | 341 | lab.setText( mPrefs->mPassiveSyncPort ); |
342 | lay.setMargin(7); | 342 | lay.setMargin(7); |
343 | lay.setSpacing(7); | 343 | lay.setSpacing(7); |
344 | int po = 9197+mTargetApp; | 344 | int po = 9197+mTargetApp; |
345 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 345 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
346 | lay.addWidget( &label); | 346 | lay.addWidget( &label); |
347 | lay.addWidget( &lab); | 347 | lay.addWidget( &lab); |
348 | 348 | ||
349 | QLineEdit lepw ( &dia ); | 349 | QLineEdit lepw ( &dia ); |
350 | lepw.setText( mPrefs->mPassiveSyncPw ); | 350 | lepw.setText( mPrefs->mPassiveSyncPw ); |
351 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 351 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
352 | lay.addWidget( &label2); | 352 | lay.addWidget( &label2); |
353 | lay.addWidget( &lepw); | 353 | lay.addWidget( &lepw); |
354 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 354 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
355 | lay.addWidget( &autostart); | 355 | lay.addWidget( &autostart); |
356 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 356 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
357 | #ifdef DESKTOP_VERSION | 357 | #ifdef DESKTOP_VERSION |
358 | #ifdef _WIN32_ | 358 | #ifdef _WIN32_ |
359 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 359 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
360 | syncdesktop.hide();// not implemented! | 360 | syncdesktop.hide();// not implemented! |
361 | #else | 361 | #else |
362 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 362 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
363 | #endif | 363 | #endif |
364 | lay.addWidget( &syncdesktop); | 364 | lay.addWidget( &syncdesktop); |
365 | #else | 365 | #else |
366 | mPrefs->mPassiveSyncWithDesktop = false; | 366 | mPrefs->mPassiveSyncWithDesktop = false; |
367 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 367 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
368 | syncdesktop.hide(); | 368 | syncdesktop.hide(); |
369 | #endif | 369 | #endif |
370 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 370 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
371 | 371 | ||
372 | dia.setFixedSize( 230,120 ); | 372 | dia.setFixedSize( 230,120 ); |
373 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 373 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
374 | QPushButton pb ( "OK", &dia); | 374 | QPushButton pb ( "OK", &dia); |
375 | lay.addWidget( &pb ); | 375 | lay.addWidget( &pb ); |
376 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 376 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
377 | dia.show(); | 377 | dia.show(); |
378 | if ( ! dia.exec() ) | 378 | if ( ! dia.exec() ) |
379 | return; | 379 | return; |
380 | dia.hide(); | 380 | dia.hide(); |
381 | qApp->processEvents(); | 381 | qApp->processEvents(); |
382 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 382 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
383 | changed = true; | 383 | changed = true; |
384 | mPrefs->mPassiveSyncPw = lepw.text(); | 384 | mPrefs->mPassiveSyncPw = lepw.text(); |
385 | } | 385 | } |
386 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 386 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
387 | mPrefs->mPassiveSyncPort = lab.text(); | 387 | mPrefs->mPassiveSyncPort = lab.text(); |
388 | changed = true; | 388 | changed = true; |
389 | } | 389 | } |
390 | autoStart = autostart.isChecked(); | 390 | autoStart = autostart.isChecked(); |
391 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 391 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
392 | changed = true; | 392 | changed = true; |
393 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 393 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | else | 396 | else |
397 | autoStart = mPrefs->mPassiveSyncAutoStart; | 397 | autoStart = mPrefs->mPassiveSyncAutoStart; |
398 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 398 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
399 | changed = true; | 399 | changed = true; |
400 | bool ok; | 400 | bool ok; |
401 | mPrefs->mPassiveSyncAutoStart = false; | 401 | mPrefs->mPassiveSyncAutoStart = false; |
402 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | 402 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); |
403 | if ( ! ok ) { | 403 | if ( ! ok ) { |
404 | KMessageBox::information( 0, i18n("No valid port")); | 404 | KMessageBox::information( 0, i18n("No valid port")); |
405 | return; | 405 | return; |
406 | } | 406 | } |
407 | //qDebug("port %d ", port); | 407 | //qDebug("port %d ", port); |
408 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 408 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
409 | mServerSocket->setFileName( defaultFileName() );//bbb | 409 | mServerSocket->setFileName( defaultFileName() );//bbb |
410 | //qDebug("connected "); | 410 | //qDebug("connected "); |
411 | if ( !mServerSocket->ok() ) { | 411 | if ( !mServerSocket->ok() ) { |
412 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 412 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
413 | delete mServerSocket; | 413 | delete mServerSocket; |
414 | mServerSocket = 0; | 414 | mServerSocket = 0; |
415 | return; | 415 | return; |
416 | } | 416 | } |
417 | mPrefs->mPassiveSyncAutoStart = autoStart; | 417 | mPrefs->mPassiveSyncAutoStart = autoStart; |
418 | if ( changed ) { | 418 | if ( changed ) { |
419 | mPrefs->writeConfig(); | 419 | mPrefs->writeConfig(); |
420 | } | 420 | } |
421 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 421 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
422 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 422 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
423 | } | 423 | } |
424 | 424 | ||
425 | void KSyncManager::syncLocalFile() | 425 | void KSyncManager::syncLocalFile() |
426 | { | 426 | { |
427 | 427 | ||
428 | QString fn =mPrefs->mLastSyncedLocalFile; | 428 | QString fn =mPrefs->mLastSyncedLocalFile; |
429 | QString ext; | 429 | QString ext; |
430 | 430 | ||
431 | switch(mTargetApp) | 431 | switch(mTargetApp) |
432 | { | 432 | { |
433 | case (KAPI): | 433 | case (KAPI): |
434 | ext = "(*.vcf)"; | 434 | ext = "(*.vcf)"; |
435 | break; | 435 | break; |
436 | case (KOPI): | 436 | case (KOPI): |
437 | ext = "(*.ics/*.vcs)"; | 437 | ext = "(*.ics/*.vcs)"; |
438 | break; | 438 | break; |
439 | case (PWMPI): | 439 | case (PWMPI): |
440 | ext = "(*.pwm)"; | 440 | ext = "(*.pwm)"; |
441 | break; | 441 | break; |
442 | default: | 442 | default: |
443 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 443 | qDebug("KSM::syncLocalFile: invalid apptype selected"); |
444 | break; | 444 | break; |
445 | 445 | ||
446 | } | 446 | } |
447 | 447 | ||
448 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 448 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
449 | if ( fn == "" ) | 449 | if ( fn == "" ) |
450 | return; | 450 | return; |
451 | if ( syncWithFile( fn, false ) ) { | 451 | if ( syncWithFile( fn, false ) ) { |
452 | qDebug("syncLocalFile() successful "); | 452 | qDebug("KSM::syncLocalFile() successful "); |
453 | } | 453 | } |
454 | 454 | ||
455 | } | 455 | } |
456 | 456 | ||
457 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 457 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
458 | { | 458 | { |
459 | bool ret = false; | 459 | bool ret = false; |
460 | QFileInfo info; | 460 | QFileInfo info; |
461 | info.setFile( fn ); | 461 | info.setFile( fn ); |
462 | QString mess; | 462 | QString mess; |
463 | bool loadbup = true; | 463 | bool loadbup = true; |
464 | if ( !info. exists() ) { | 464 | if ( !info. exists() ) { |
465 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 465 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
466 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 466 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
467 | mess ); | 467 | mess ); |
468 | return ret; | 468 | return ret; |
469 | } | 469 | } |
470 | int result = 0; | 470 | int result = 0; |
471 | if ( !quick ) { | 471 | if ( !quick ) { |
472 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 472 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
473 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 473 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
474 | mess, | 474 | mess, |
475 | i18n("Sync"), i18n("Cancel"), 0, | 475 | i18n("Sync"), i18n("Cancel"), 0, |
476 | 0, 1 ); | 476 | 0, 1 ); |
477 | if ( result ) | 477 | if ( result ) |
478 | return false; | 478 | return false; |
479 | } | 479 | } |
480 | if ( mAskForPreferences ) | 480 | if ( mAskForPreferences ) |
481 | if ( !edit_sync_options()) { | 481 | if ( !edit_sync_options()) { |
482 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 482 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
483 | return false; | 483 | return false; |
484 | } | 484 | } |
485 | if ( result == 0 ) { | 485 | if ( result == 0 ) { |
486 | //qDebug("Now sycing ... "); | 486 | //qDebug("Now sycing ... "); |
487 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 487 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
488 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 488 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
489 | else | 489 | else |
490 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 490 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
491 | if ( ! quick ) | 491 | if ( ! quick ) |
492 | mPrefs->mLastSyncedLocalFile = fn; | 492 | mPrefs->mLastSyncedLocalFile = fn; |
493 | } | 493 | } |
494 | return ret; | 494 | return ret; |
495 | } | 495 | } |
496 | 496 | ||
497 | void KSyncManager::quickSyncLocalFile() | 497 | void KSyncManager::quickSyncLocalFile() |
498 | { | 498 | { |
499 | 499 | ||
500 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 500 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
501 | qDebug("quick syncLocalFile() successful "); | 501 | qDebug("KSM::quick syncLocalFile() successful "); |
502 | 502 | ||
503 | } | 503 | } |
504 | } | 504 | } |
505 | 505 | ||
506 | void KSyncManager::multiSync( bool askforPrefs ) | 506 | void KSyncManager::multiSync( bool askforPrefs ) |
507 | { | 507 | { |
508 | if (blockSave()) | 508 | if (blockSave()) |
509 | return; | 509 | return; |
510 | setBlockSave(true); | 510 | setBlockSave(true); |
511 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 511 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
512 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 512 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
513 | question, | 513 | question, |
514 | i18n("Yes"), i18n("No"), | 514 | i18n("Yes"), i18n("No"), |
515 | 0, 0 ) != 0 ) { | 515 | 0, 0 ) != 0 ) { |
516 | setBlockSave(false); | 516 | setBlockSave(false); |
517 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 517 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
518 | return; | 518 | return; |
519 | } | 519 | } |
520 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 520 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
521 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 521 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
522 | if ( askforPrefs ) { | 522 | if ( askforPrefs ) { |
523 | if ( !edit_sync_options()) { | 523 | if ( !edit_sync_options()) { |
524 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); | 524 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
525 | return; | 525 | return; |
526 | } | 526 | } |
527 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 527 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
528 | } | 528 | } |
529 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 529 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
530 | qApp->processEvents(); | 530 | qApp->processEvents(); |
531 | int num = ringSync() ; | 531 | int num = ringSync() ; |
532 | if ( num > 1 ) | 532 | if ( num > 1 ) |
533 | ringSync(); | 533 | ringSync(); |
534 | setBlockSave(false); | 534 | setBlockSave(false); |
535 | if ( num ) | 535 | if ( num ) |
536 | emit save(); | 536 | emit save(); |
537 | if ( num ) | 537 | if ( num ) |
538 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 538 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
539 | else | 539 | else |
540 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 540 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
541 | return; | 541 | return; |
542 | } | 542 | } |
543 | 543 | ||
544 | int KSyncManager::ringSync() | 544 | int KSyncManager::ringSync() |
545 | { | 545 | { |
546 | 546 | ||
547 | int syncedProfiles = 0; | 547 | int syncedProfiles = 0; |
548 | unsigned int i; | 548 | unsigned int i; |
549 | QTime timer; | 549 | QTime timer; |
550 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 550 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
551 | QStringList syncProfileNames = mSyncProfileNames; | 551 | QStringList syncProfileNames = mSyncProfileNames; |
552 | KSyncProfile* temp = new KSyncProfile (); | 552 | KSyncProfile* temp = new KSyncProfile (); |
553 | mAskForPreferences = false; | 553 | mAskForPreferences = false; |
554 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 554 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
555 | mCurrentSyncProfile = i; | 555 | mCurrentSyncProfile = i; |
556 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 556 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
557 | temp->readConfig(&config); | 557 | temp->readConfig(&config); |
558 | 558 | ||
559 | bool includeInRingSync; | 559 | bool includeInRingSync; |
560 | switch(mTargetApp) | 560 | switch(mTargetApp) |
561 | { | 561 | { |
562 | case (KAPI): | 562 | case (KAPI): |
563 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 563 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
564 | break; | 564 | break; |
565 | case (KOPI): | 565 | case (KOPI): |
566 | includeInRingSync = temp->getIncludeInRingSync(); | 566 | includeInRingSync = temp->getIncludeInRingSync(); |
567 | break; | 567 | break; |
568 | case (PWMPI): | 568 | case (PWMPI): |
569 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 569 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
570 | break; | 570 | break; |
571 | default: | 571 | default: |
572 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 572 | qDebug("KSM::ringSync: invalid apptype selected"); |
573 | break; | 573 | break; |
574 | 574 | ||
575 | } | 575 | } |
576 | 576 | ||
577 | 577 | ||
578 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 578 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
579 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 579 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
580 | ++syncedProfiles; | 580 | ++syncedProfiles; |
581 | mSyncWithDesktop = false; | 581 | mSyncWithDesktop = false; |
582 | // mAskForPreferences = temp->getAskForPreferences(); | 582 | // mAskForPreferences = temp->getAskForPreferences(); |
583 | mWriteBackFile = temp->getWriteBackFile(); | 583 | mWriteBackFile = temp->getWriteBackFile(); |
584 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 584 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
585 | mIsKapiFile = temp->getIsKapiFile(); | 585 | mIsKapiFile = temp->getIsKapiFile(); |
586 | mWriteBackInFuture = 0; | 586 | mWriteBackInFuture = 0; |
587 | if ( temp->getWriteBackFuture() ) { | 587 | if ( temp->getWriteBackFuture() ) { |
588 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 588 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
589 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 589 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
590 | } | 590 | } |
591 | mFilterInCal = temp->getFilterInCal(); | 591 | mFilterInCal = temp->getFilterInCal(); |
592 | mFilterOutCal = temp->getFilterOutCal(); | 592 | mFilterOutCal = temp->getFilterOutCal(); |
593 | mFilterInAB = temp->getFilterInAB(); | 593 | mFilterInAB = temp->getFilterInAB(); |
594 | mFilterOutAB = temp->getFilterOutAB(); | 594 | mFilterOutAB = temp->getFilterOutAB(); |
595 | mShowSyncSummary = false; | 595 | mShowSyncSummary = false; |
596 | mCurrentSyncDevice = syncProfileNames[i] ; | 596 | mCurrentSyncDevice = syncProfileNames[i] ; |
597 | mCurrentSyncName = mLocalMachineName; | 597 | mCurrentSyncName = mLocalMachineName; |
598 | if ( i == 0 ) { | 598 | if ( i == 0 ) { |
599 | mIsKapiFile = false; | 599 | mIsKapiFile = false; |
600 | #ifdef DESKTOP_VERSION | 600 | #ifdef DESKTOP_VERSION |
601 | syncKDE(); | 601 | syncKDE(); |
602 | #else | 602 | #else |
603 | syncSharp(); | 603 | syncSharp(); |
604 | #endif | 604 | #endif |
605 | } else { | 605 | } else { |
606 | if ( temp->getIsLocalFileSync() ) { | 606 | if ( temp->getIsLocalFileSync() ) { |
607 | switch(mTargetApp) | 607 | switch(mTargetApp) |
608 | { | 608 | { |
609 | case (KAPI): | 609 | case (KAPI): |
610 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 610 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
611 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 611 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
612 | break; | 612 | break; |
613 | case (KOPI): | 613 | case (KOPI): |
614 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 614 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
615 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 615 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
616 | break; | 616 | break; |
617 | case (PWMPI): | 617 | case (PWMPI): |
618 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 618 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
619 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 619 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
620 | break; | 620 | break; |
621 | default: | 621 | default: |
622 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 622 | qDebug("KSM: invalid apptype selected"); |
623 | break; | 623 | break; |
624 | } | 624 | } |
625 | } else { | 625 | } else { |
626 | if ( temp->getIsPhoneSync() ) { | 626 | if ( temp->getIsPhoneSync() ) { |
627 | mPhoneDevice = temp->getPhoneDevice( ) ; | 627 | mPhoneDevice = temp->getPhoneDevice( ) ; |
628 | mPhoneConnection = temp->getPhoneConnection( ); | 628 | mPhoneConnection = temp->getPhoneConnection( ); |
629 | mPhoneModel = temp->getPhoneModel( ); | 629 | mPhoneModel = temp->getPhoneModel( ); |
630 | syncPhone(); | 630 | syncPhone(); |
631 | } else if ( temp->getIsPiSync() ) { | 631 | } else if ( temp->getIsPiSync() ) { |
632 | if ( mTargetApp == KAPI ) { | 632 | if ( mTargetApp == KAPI ) { |
633 | mPassWordPiSync = temp->getRemotePwAB(); | 633 | mPassWordPiSync = temp->getRemotePwAB(); |
634 | mActiveSyncPort = temp->getRemotePortAB(); | 634 | mActiveSyncPort = temp->getRemotePortAB(); |
635 | mActiveSyncIP = temp->getRemoteIPAB(); | 635 | mActiveSyncIP = temp->getRemoteIPAB(); |
636 | } else if ( mTargetApp == KOPI ) { | 636 | } else if ( mTargetApp == KOPI ) { |
637 | mPassWordPiSync = temp->getRemotePw(); | 637 | mPassWordPiSync = temp->getRemotePw(); |
638 | mActiveSyncPort = temp->getRemotePort(); | 638 | mActiveSyncPort = temp->getRemotePort(); |
639 | mActiveSyncIP = temp->getRemoteIP(); | 639 | mActiveSyncIP = temp->getRemoteIP(); |
640 | } else { | 640 | } else { |
641 | mPassWordPiSync = temp->getRemotePwPWM(); | 641 | mPassWordPiSync = temp->getRemotePwPWM(); |
642 | mActiveSyncPort = temp->getRemotePortPWM(); | 642 | mActiveSyncPort = temp->getRemotePortPWM(); |
643 | mActiveSyncIP = temp->getRemoteIPPWM(); | 643 | mActiveSyncIP = temp->getRemoteIPPWM(); |
644 | } | 644 | } |
645 | syncPi(); | 645 | syncPi(); |
646 | while ( !mPisyncFinished ) { | 646 | while ( !mPisyncFinished ) { |
647 | //qDebug("waiting "); | 647 | //qDebug("waiting "); |
648 | qApp->processEvents(); | 648 | qApp->processEvents(); |
649 | } | 649 | } |
650 | timer.start(); | 650 | timer.start(); |
651 | while ( timer.elapsed () < 2000 ) { | 651 | while ( timer.elapsed () < 2000 ) { |
652 | qApp->processEvents(); | 652 | qApp->processEvents(); |
653 | } | 653 | } |
654 | } else | 654 | } else |
655 | syncRemote( temp, false ); | 655 | syncRemote( temp, false ); |
656 | 656 | ||
657 | } | 657 | } |
658 | } | 658 | } |
659 | timer.start(); | 659 | timer.start(); |
660 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 660 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
661 | while ( timer.elapsed () < 2000 ) { | 661 | while ( timer.elapsed () < 2000 ) { |
662 | qApp->processEvents(); | 662 | qApp->processEvents(); |
663 | #ifndef _WIN32_ | 663 | #ifndef _WIN32_ |
664 | sleep (1); | 664 | sleep (1); |
665 | #endif | 665 | #endif |
666 | } | 666 | } |
667 | 667 | ||
668 | } | 668 | } |
669 | 669 | ||
670 | } | 670 | } |
671 | delete temp; | 671 | delete temp; |
672 | return syncedProfiles; | 672 | return syncedProfiles; |
673 | } | 673 | } |
674 | 674 | ||
675 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 675 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
676 | { | 676 | { |
677 | QString question; | 677 | QString question; |
678 | if ( ask ) { | 678 | if ( ask ) { |
679 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 679 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
680 | if ( QMessageBox::information( mParent, i18n("Sync"), | 680 | if ( QMessageBox::information( mParent, i18n("Sync"), |
681 | question, | 681 | question, |
682 | i18n("Yes"), i18n("No"), | 682 | i18n("Yes"), i18n("No"), |
683 | 0, 0 ) != 0 ) | 683 | 0, 0 ) != 0 ) |
684 | return; | 684 | return; |
685 | } | 685 | } |
686 | 686 | ||
687 | QString preCommand; | 687 | QString preCommand; |
688 | QString localTempFile; | 688 | QString localTempFile; |
689 | QString postCommand; | 689 | QString postCommand; |
690 | 690 | ||
691 | switch(mTargetApp) | 691 | switch(mTargetApp) |
692 | { | 692 | { |
693 | case (KAPI): | 693 | case (KAPI): |
694 | preCommand = prof->getPreSyncCommandAB(); | 694 | preCommand = prof->getPreSyncCommandAB(); |
695 | postCommand = prof->getPostSyncCommandAB(); | 695 | postCommand = prof->getPostSyncCommandAB(); |
696 | localTempFile = prof->getLocalTempFileAB(); | 696 | localTempFile = prof->getLocalTempFileAB(); |
697 | break; | 697 | break; |
698 | case (KOPI): | 698 | case (KOPI): |
699 | preCommand = prof->getPreSyncCommand(); | 699 | preCommand = prof->getPreSyncCommand(); |
700 | postCommand = prof->getPostSyncCommand(); | 700 | postCommand = prof->getPostSyncCommand(); |
701 | localTempFile = prof->getLocalTempFile(); | 701 | localTempFile = prof->getLocalTempFile(); |
702 | break; | 702 | break; |
703 | case (PWMPI): | 703 | case (PWMPI): |
704 | preCommand = prof->getPreSyncCommandPWM(); | 704 | preCommand = prof->getPreSyncCommandPWM(); |
705 | postCommand = prof->getPostSyncCommandPWM(); | 705 | postCommand = prof->getPostSyncCommandPWM(); |
706 | localTempFile = prof->getLocalTempFilePWM(); | 706 | localTempFile = prof->getLocalTempFilePWM(); |
707 | break; | 707 | break; |
708 | default: | 708 | default: |
709 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); | 709 | qDebug("KSM::syncRemote: invalid apptype selected"); |
710 | break; | 710 | break; |
711 | } | 711 | } |
712 | 712 | ||
713 | 713 | ||
714 | int fi; | 714 | int fi; |
715 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 715 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
716 | QString pwd = getPassword(); | 716 | QString pwd = getPassword(); |
717 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 717 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
718 | 718 | ||
719 | } | 719 | } |
720 | int maxlen = 30; | 720 | int maxlen = 30; |
721 | if ( QApplication::desktop()->width() > 320 ) | 721 | if ( QApplication::desktop()->width() > 320 ) |
722 | maxlen += 25; | 722 | maxlen += 25; |
723 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 723 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
724 | int fileSize = 0; | 724 | int fileSize = 0; |
725 | int result = system ( preCommand ); | 725 | int result = system ( preCommand ); |
726 | // 0 : okay | 726 | // 0 : okay |
727 | // 256: no such file or dir | 727 | // 256: no such file or dir |
728 | // | 728 | // |
729 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); | 729 | qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); |
730 | if ( result != 0 ) { | 730 | if ( result != 0 ) { |
731 | unsigned int len = maxlen; | 731 | unsigned int len = maxlen; |
732 | while ( len < preCommand.length() ) { | 732 | while ( len < preCommand.length() ) { |
733 | preCommand.insert( len , "\n" ); | 733 | preCommand.insert( len , "\n" ); |
734 | len += maxlen +2; | 734 | len += maxlen +2; |
735 | } | 735 | } |
736 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; | 736 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; |
737 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 737 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
738 | question, | 738 | question, |
739 | i18n("Okay!")) ; | 739 | i18n("Okay!")) ; |
740 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 740 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
741 | return; | 741 | return; |
742 | } | 742 | } |
743 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 743 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
744 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 744 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
745 | 745 | ||
746 | if ( syncWithFile( localTempFile, true ) ) { | 746 | if ( syncWithFile( localTempFile, true ) ) { |
747 | 747 | ||
748 | if ( mWriteBackFile ) { | 748 | if ( mWriteBackFile ) { |
749 | int fi; | 749 | int fi; |
750 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 750 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
751 | QString pwd = getPassword(); | 751 | QString pwd = getPassword(); |
752 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 752 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
753 | 753 | ||
754 | } | 754 | } |
755 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 755 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
756 | result = system ( postCommand ); | 756 | result = system ( postCommand ); |
757 | qDebug("Sync:Writing back file result: %d ", result); | 757 | qDebug("KSM::Sync:Writing back file result: %d ", result); |
758 | if ( result != 0 ) { | 758 | if ( result != 0 ) { |
759 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 759 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
760 | return; | 760 | return; |
761 | } else { | 761 | } else { |
762 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 762 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
763 | } | 763 | } |
764 | } | 764 | } |
765 | } | 765 | } |
766 | return; | 766 | return; |
767 | } | 767 | } |
768 | bool KSyncManager::edit_pisync_options() | 768 | bool KSyncManager::edit_pisync_options() |
769 | { | 769 | { |
770 | QDialog dia( mParent, "dia", true ); | 770 | QDialog dia( mParent, "dia", true ); |
771 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 771 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
772 | QVBoxLayout lay ( &dia ); | 772 | QVBoxLayout lay ( &dia ); |
773 | lay.setSpacing( 5 ); | 773 | lay.setSpacing( 5 ); |
774 | lay.setMargin( 3 ); | 774 | lay.setMargin( 3 ); |
775 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 775 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
776 | lay.addWidget( &lab1 ); | 776 | lay.addWidget( &lab1 ); |
777 | QLineEdit le1 (&dia ); | 777 | QLineEdit le1 (&dia ); |
778 | lay.addWidget( &le1 ); | 778 | lay.addWidget( &le1 ); |
779 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 779 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
780 | lay.addWidget( &lab2 ); | 780 | lay.addWidget( &lab2 ); |
781 | QLineEdit le2 (&dia ); | 781 | QLineEdit le2 (&dia ); |
782 | lay.addWidget( &le2 ); | 782 | lay.addWidget( &le2 ); |
783 | QLabel lab3 ( i18n("Remote port number:"), &dia); | 783 | QLabel lab3 ( i18n("Remote port number:"), &dia); |
784 | lay.addWidget( &lab3 ); | 784 | lay.addWidget( &lab3 ); |
785 | QLineEdit le3 (&dia ); | 785 | QLineEdit le3 (&dia ); |
786 | lay.addWidget( &le3 ); | 786 | lay.addWidget( &le3 ); |
787 | QPushButton pb ( "OK", &dia); | 787 | QPushButton pb ( "OK", &dia); |
788 | lay.addWidget( &pb ); | 788 | lay.addWidget( &pb ); |
789 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 789 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
790 | le1.setText( mPassWordPiSync ); | 790 | le1.setText( mPassWordPiSync ); |
791 | le2.setText( mActiveSyncIP ); | 791 | le2.setText( mActiveSyncIP ); |
792 | le3.setText( mActiveSyncPort ); | 792 | le3.setText( mActiveSyncPort ); |
793 | if ( dia.exec() ) { | 793 | if ( dia.exec() ) { |
794 | mPassWordPiSync = le1.text(); | 794 | mPassWordPiSync = le1.text(); |
795 | mActiveSyncPort = le3.text(); | 795 | mActiveSyncPort = le3.text(); |
796 | mActiveSyncIP = le2.text(); | 796 | mActiveSyncIP = le2.text(); |
797 | return true; | 797 | return true; |
798 | } | 798 | } |
799 | return false; | 799 | return false; |
800 | } | 800 | } |
801 | bool KSyncManager::edit_sync_options() | 801 | bool KSyncManager::edit_sync_options() |
802 | { | 802 | { |
803 | 803 | ||
804 | QDialog dia( mParent, "dia", true ); | 804 | QDialog dia( mParent, "dia", true ); |
805 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 805 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
806 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 806 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
807 | QVBoxLayout lay ( &dia ); | 807 | QVBoxLayout lay ( &dia ); |
808 | lay.setSpacing( 2 ); | 808 | lay.setSpacing( 2 ); |
809 | lay.setMargin( 3 ); | 809 | lay.setMargin( 3 ); |
810 | lay.addWidget(&gr); | 810 | lay.addWidget(&gr); |
811 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 811 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
812 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 812 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
813 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 813 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
814 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 814 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
815 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 815 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
816 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 816 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
817 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 817 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
818 | QPushButton pb ( "OK", &dia); | 818 | QPushButton pb ( "OK", &dia); |
819 | lay.addWidget( &pb ); | 819 | lay.addWidget( &pb ); |
820 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 820 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
821 | switch ( mSyncAlgoPrefs ) { | 821 | switch ( mSyncAlgoPrefs ) { |
822 | case 0: | 822 | case 0: |
823 | loc.setChecked( true); | 823 | loc.setChecked( true); |
824 | break; | 824 | break; |
825 | case 1: | 825 | case 1: |
826 | rem.setChecked( true ); | 826 | rem.setChecked( true ); |
827 | break; | 827 | break; |
828 | case 2: | 828 | case 2: |
829 | newest.setChecked( true); | 829 | newest.setChecked( true); |
830 | break; | 830 | break; |
831 | case 3: | 831 | case 3: |
832 | ask.setChecked( true); | 832 | ask.setChecked( true); |
833 | break; | 833 | break; |
834 | case 4: | 834 | case 4: |
835 | f_loc.setChecked( true); | 835 | f_loc.setChecked( true); |
836 | break; | 836 | break; |
837 | case 5: | 837 | case 5: |
838 | f_rem.setChecked( true); | 838 | f_rem.setChecked( true); |
839 | break; | 839 | break; |
840 | case 6: | 840 | case 6: |
841 | // both.setChecked( true); | 841 | // both.setChecked( true); |
842 | break; | 842 | break; |
843 | default: | 843 | default: |
844 | break; | 844 | break; |
845 | } | 845 | } |
846 | if ( dia.exec() ) { | 846 | if ( dia.exec() ) { |
847 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 847 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
848 | return true; | 848 | return true; |
849 | } | 849 | } |
850 | return false; | 850 | return false; |
851 | } | 851 | } |
852 | 852 | ||
853 | QString KSyncManager::getPassword( ) | 853 | QString KSyncManager::getPassword( ) |
854 | { | 854 | { |
855 | QString retfile = ""; | 855 | QString retfile = ""; |
856 | QDialog dia ( mParent, "input-dialog", true ); | 856 | QDialog dia ( mParent, "input-dialog", true ); |
857 | QLineEdit lab ( &dia ); | 857 | QLineEdit lab ( &dia ); |
858 | lab.setEchoMode( QLineEdit::Password ); | 858 | lab.setEchoMode( QLineEdit::Password ); |
859 | QVBoxLayout lay( &dia ); | 859 | QVBoxLayout lay( &dia ); |
860 | lay.setMargin(7); | 860 | lay.setMargin(7); |
861 | lay.setSpacing(7); | 861 | lay.setSpacing(7); |
862 | lay.addWidget( &lab); | 862 | lay.addWidget( &lab); |
863 | dia.setFixedSize( 230,50 ); | 863 | dia.setFixedSize( 230,50 ); |
864 | dia.setCaption( i18n("Enter password") ); | 864 | dia.setCaption( i18n("Enter password") ); |
865 | QPushButton pb ( "OK", &dia); | 865 | QPushButton pb ( "OK", &dia); |
866 | lay.addWidget( &pb ); | 866 | lay.addWidget( &pb ); |
867 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 867 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
868 | dia.show(); | 868 | dia.show(); |
869 | int res = dia.exec(); | 869 | int res = dia.exec(); |
870 | if ( res ) | 870 | if ( res ) |
871 | retfile = lab.text(); | 871 | retfile = lab.text(); |
872 | dia.hide(); | 872 | dia.hide(); |
873 | qApp->processEvents(); | 873 | qApp->processEvents(); |
874 | return retfile; | 874 | return retfile; |
875 | 875 | ||
876 | } | 876 | } |
877 | 877 | ||
878 | 878 | ||
879 | void KSyncManager::confSync() | 879 | void KSyncManager::confSync() |
880 | { | 880 | { |
881 | static KSyncPrefsDialog* sp = 0; | 881 | static KSyncPrefsDialog* sp = 0; |
882 | if ( ! sp ) { | 882 | if ( ! sp ) { |
883 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 883 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
884 | } | 884 | } |
885 | sp->usrReadConfig(); | 885 | sp->usrReadConfig(); |
886 | #ifndef DESKTOP_VERSION | 886 | #ifndef DESKTOP_VERSION |
887 | sp->showMaximized(); | 887 | sp->showMaximized(); |
888 | #else | 888 | #else |
889 | sp->show(); | 889 | sp->show(); |
890 | #endif | 890 | #endif |
891 | sp->exec(); | 891 | sp->exec(); |
892 | QStringList oldSyncProfileNames = mSyncProfileNames; | 892 | QStringList oldSyncProfileNames = mSyncProfileNames; |
893 | mSyncProfileNames = sp->getSyncProfileNames(); | 893 | mSyncProfileNames = sp->getSyncProfileNames(); |
894 | mLocalMachineName = sp->getLocalMachineName (); | 894 | mLocalMachineName = sp->getLocalMachineName (); |
895 | int ii; | 895 | int ii; |
896 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 896 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
897 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 897 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
898 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 898 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
899 | } | 899 | } |
900 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 900 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
901 | } | 901 | } |
902 | void KSyncManager::syncKDE() | 902 | void KSyncManager::syncKDE() |
903 | { | 903 | { |
904 | mSyncWithDesktop = true; | 904 | mSyncWithDesktop = true; |
905 | emit save(); | 905 | emit save(); |
906 | switch(mTargetApp) | 906 | switch(mTargetApp) |
907 | { | 907 | { |
908 | case (KAPI): | 908 | case (KAPI): |
909 | { | 909 | { |
910 | #ifdef DESKTOP_VERSION | 910 | #ifdef DESKTOP_VERSION |
911 | QString command = qApp->applicationDirPath () + "/kdeabdump"; | 911 | QString command = qApp->applicationDirPath () + "/kdeabdump"; |
912 | #else | 912 | #else |
913 | QString command = "kdeabdump"; | 913 | QString command = "kdeabdump"; |
914 | #endif | 914 | #endif |
915 | if ( ! QFile::exists ( command ) ) | 915 | if ( ! QFile::exists ( command ) ) |
916 | command = "kdeabdump"; | 916 | command = "kdeabdump"; |
917 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 917 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
918 | system ( command.latin1()); | 918 | system ( command.latin1()); |
919 | if ( syncWithFile( fileName,true ) ) { | 919 | if ( syncWithFile( fileName,true ) ) { |
920 | if ( mWriteBackFile ) { | 920 | if ( mWriteBackFile ) { |
921 | command += " --read"; | 921 | command += " --read"; |
922 | system ( command.latin1()); | 922 | system ( command.latin1()); |
923 | } | 923 | } |
924 | } | 924 | } |
925 | 925 | ||
926 | } | 926 | } |
927 | break; | 927 | break; |
928 | case (KOPI): | 928 | case (KOPI): |
929 | { | 929 | { |
930 | #ifdef DESKTOP_VERSION | 930 | #ifdef DESKTOP_VERSION |
931 | QString command = qApp->applicationDirPath () + "/kdecaldump"; | 931 | QString command = qApp->applicationDirPath () + "/kdecaldump"; |
932 | #else | 932 | #else |
933 | QString command = "kdecaldump"; | 933 | QString command = "kdecaldump"; |
934 | #endif | 934 | #endif |
935 | if ( ! QFile::exists ( command ) ) | 935 | if ( ! QFile::exists ( command ) ) |
936 | command = "kdecaldump"; | 936 | command = "kdecaldump"; |
937 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 937 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
938 | system ( command.latin1()); | 938 | system ( command.latin1()); |
939 | if ( syncWithFile( fileName,true ) ) { | 939 | if ( syncWithFile( fileName,true ) ) { |
940 | if ( mWriteBackFile ) { | 940 | if ( mWriteBackFile ) { |
941 | command += " --read"; | 941 | command += " --read"; |
942 | system ( command.latin1()); | 942 | system ( command.latin1()); |
943 | } | 943 | } |
944 | } | 944 | } |
945 | 945 | ||
946 | } | 946 | } |
947 | break; | 947 | break; |
948 | case (PWMPI): | 948 | case (PWMPI): |
949 | 949 | ||
950 | break; | 950 | break; |
951 | default: | 951 | default: |
952 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 952 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
953 | break; | 953 | break; |
954 | 954 | ||
955 | } | 955 | } |
956 | } | 956 | } |
957 | 957 | ||
958 | void KSyncManager::syncSharp() | 958 | void KSyncManager::syncSharp() |
959 | { | 959 | { |
960 | 960 | ||
961 | if ( ! syncExternalApplication("sharp") ) | 961 | if ( ! syncExternalApplication("sharp") ) |
962 | qDebug("ERROR sync sharp "); | 962 | qDebug("KSM::ERROR sync sharp "); |
963 | } | 963 | } |
964 | 964 | ||
965 | bool KSyncManager::syncExternalApplication(QString resource) | 965 | bool KSyncManager::syncExternalApplication(QString resource) |
966 | { | 966 | { |
967 | 967 | ||
968 | emit save(); | 968 | emit save(); |
969 | 969 | ||
970 | if ( mAskForPreferences ) | 970 | if ( mAskForPreferences ) |
971 | if ( !edit_sync_options()) { | 971 | if ( !edit_sync_options()) { |
972 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 972 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
973 | return false; | 973 | return false; |
974 | } | 974 | } |
975 | 975 | ||
976 | qDebug("Sync extern %s", resource.latin1()); | 976 | qDebug("KSM::Sync extern %s", resource.latin1()); |
977 | 977 | ||
978 | bool syncOK = mImplementation->syncExternal(this, resource); | 978 | bool syncOK = mImplementation->syncExternal(this, resource); |
979 | 979 | ||
980 | return syncOK; | 980 | return syncOK; |
981 | 981 | ||
982 | } | 982 | } |
983 | 983 | ||
984 | void KSyncManager::syncPhone() | 984 | void KSyncManager::syncPhone() |
985 | { | 985 | { |
986 | 986 | ||
987 | syncExternalApplication("phone"); | 987 | syncExternalApplication("phone"); |
988 | 988 | ||
989 | } | 989 | } |
990 | 990 | ||
991 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 991 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
992 | { | 992 | { |
993 | if (!bar->isVisible()) | 993 | if (!bar->isVisible()) |
994 | { | 994 | { |
995 | bar->setCaption (caption); | 995 | bar->setCaption (caption); |
996 | bar->setTotalSteps ( total ) ; | 996 | bar->setTotalSteps ( total ) ; |
997 | bar->show(); | 997 | bar->show(); |
998 | } | 998 | } |
999 | bar->raise(); | 999 | bar->raise(); |
1000 | bar->setProgress( percentage ); | 1000 | bar->setProgress( percentage ); |
1001 | qApp->processEvents(); | 1001 | qApp->processEvents(); |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | void KSyncManager::hideProgressBar() | 1004 | void KSyncManager::hideProgressBar() |
1005 | { | 1005 | { |
1006 | bar->hide(); | 1006 | bar->hide(); |
1007 | qApp->processEvents(); | 1007 | qApp->processEvents(); |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | bool KSyncManager::isProgressBarCanceled() | 1010 | bool KSyncManager::isProgressBarCanceled() |
1011 | { | 1011 | { |
1012 | return !bar->isVisible(); | 1012 | return !bar->isVisible(); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | QString KSyncManager::syncFileName() | 1015 | QString KSyncManager::syncFileName() |
1016 | { | 1016 | { |
1017 | 1017 | ||
1018 | QString fn = "tempfile"; | 1018 | QString fn = "tempfile"; |
1019 | switch(mTargetApp) | 1019 | switch(mTargetApp) |
1020 | { | 1020 | { |
1021 | case (KAPI): | 1021 | case (KAPI): |
1022 | fn = "tempsyncab.vcf"; | 1022 | fn = "tempsyncab.vcf"; |
1023 | break; | 1023 | break; |
1024 | case (KOPI): | 1024 | case (KOPI): |
1025 | fn = "tempsynccal.ics"; | 1025 | fn = "tempsynccal.ics"; |
1026 | break; | 1026 | break; |
1027 | case (PWMPI): | 1027 | case (PWMPI): |
1028 | fn = "tempsyncpw.pwm"; | 1028 | fn = "tempsyncpw.pwm"; |
1029 | break; | 1029 | break; |
1030 | default: | 1030 | default: |
1031 | break; | 1031 | break; |
1032 | } | 1032 | } |
1033 | #ifdef _WIN32_ | 1033 | #ifdef _WIN32_ |
1034 | return locateLocal( "tmp", fn ); | 1034 | return locateLocal( "tmp", fn ); |
1035 | #else | 1035 | #else |
1036 | return (QString( "/tmp/" )+ fn ); | 1036 | return (QString( "/tmp/" )+ fn ); |
1037 | #endif | 1037 | #endif |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | void KSyncManager::syncPi() | 1040 | void KSyncManager::syncPi() |
1041 | { | 1041 | { |
1042 | mIsKapiFile = true; | 1042 | mIsKapiFile = true; |
1043 | mPisyncFinished = false; | 1043 | mPisyncFinished = false; |
1044 | qApp->processEvents(); | 1044 | qApp->processEvents(); |
1045 | if ( mAskForPreferences ) | 1045 | if ( mAskForPreferences ) |
1046 | if ( !edit_pisync_options()) { | 1046 | if ( !edit_pisync_options()) { |
1047 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1047 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1048 | return; | 1048 | return; |
1049 | } | 1049 | } |
1050 | bool ok; | 1050 | bool ok; |
1051 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1051 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1052 | if ( ! ok ) { | 1052 | if ( ! ok ) { |
1053 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1053 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1054 | return; | 1054 | return; |
1055 | } | 1055 | } |
1056 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 1056 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
1057 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1057 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1058 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 1058 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
1059 | commandSocket->readFile( syncFileName() ); | 1059 | commandSocket->readFile( syncFileName() ); |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1062 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1063 | { | 1063 | { |
1064 | //enum { success, errorW, errorR, quiet }; | 1064 | //enum { success, errorW, errorR, quiet }; |
1065 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 1065 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
1066 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1066 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1067 | delete s; | 1067 | delete s; |
1068 | if ( state == KCommandSocket::errorR ) { | 1068 | if ( state == KCommandSocket::errorR ) { |
1069 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1069 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1070 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1070 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1071 | commandSocket->sendStop(); | 1071 | commandSocket->sendStop(); |
1072 | } | 1072 | } |
1073 | mPisyncFinished = true; | 1073 | mPisyncFinished = true; |
1074 | return; | 1074 | return; |
1075 | 1075 | ||
1076 | } else if ( state == KCommandSocket::errorW ) { | 1076 | } else if ( state == KCommandSocket::errorW ) { |
1077 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1077 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1078 | mPisyncFinished = true; | 1078 | mPisyncFinished = true; |
1079 | 1079 | ||
1080 | } else if ( state == KCommandSocket::successR ) { | 1080 | } else if ( state == KCommandSocket::successR ) { |
1081 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1081 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1082 | 1082 | ||
1083 | } else if ( state == KCommandSocket::successW ) { | 1083 | } else if ( state == KCommandSocket::successW ) { |
1084 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1084 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1085 | mPisyncFinished = true; | 1085 | mPisyncFinished = true; |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | delete s; | 1088 | delete s; |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | void KSyncManager::readFileFromSocket() | 1091 | void KSyncManager::readFileFromSocket() |
1092 | { | 1092 | { |
1093 | QString fileName = syncFileName(); | 1093 | QString fileName = syncFileName(); |
1094 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1094 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1095 | if ( ! syncWithFile( fileName , true ) ) { | 1095 | if ( ! syncWithFile( fileName , true ) ) { |
1096 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 1096 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
1097 | mPisyncFinished = true; | 1097 | mPisyncFinished = true; |
1098 | return; | 1098 | return; |
1099 | } | 1099 | } |
1100 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1100 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1101 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1101 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1102 | if ( mWriteBackFile ) | 1102 | if ( mWriteBackFile ) |
1103 | commandSocket->writeFile( fileName ); | 1103 | commandSocket->writeFile( fileName ); |
1104 | else { | 1104 | else { |
1105 | commandSocket->sendStop(); | 1105 | commandSocket->sendStop(); |
1106 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1106 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1107 | mPisyncFinished = true; | 1107 | mPisyncFinished = true; |
1108 | } | 1108 | } |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1111 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1112 | { | 1112 | { |
1113 | mPassWord = pw; | 1113 | mPassWord = pw; |
1114 | mSocket = 0; | 1114 | mSocket = 0; |
1115 | mSyncActionDialog = 0; | 1115 | mSyncActionDialog = 0; |
1116 | blockRC = false; | 1116 | blockRC = false; |
1117 | }; | 1117 | }; |
1118 | 1118 | ||
1119 | void KServerSocket::newConnection ( int socket ) | 1119 | void KServerSocket::newConnection ( int socket ) |
1120 | { | 1120 | { |
1121 | // qDebug("KServerSocket:New connection %d ", socket); | 1121 | // qDebug("KServerSocket:New connection %d ", socket); |
1122 | if ( mSocket ) { | 1122 | if ( mSocket ) { |
1123 | qDebug("KServerSocket::newConnection Socket deleted! "); | 1123 | qDebug("KSS::newConnection Socket deleted! "); |
1124 | delete mSocket; | 1124 | delete mSocket; |
1125 | mSocket = 0; | 1125 | mSocket = 0; |
1126 | } | 1126 | } |
1127 | mSocket = new QSocket( this ); | 1127 | mSocket = new QSocket( this ); |
1128 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1128 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1129 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1129 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1130 | mSocket->setSocket( socket ); | 1130 | mSocket->setSocket( socket ); |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | void KServerSocket::discardClient() | 1133 | void KServerSocket::discardClient() |
1134 | { | 1134 | { |
1135 | //qDebug(" KServerSocket::discardClient()"); | 1135 | //qDebug(" KServerSocket::discardClient()"); |
1136 | if ( mSocket ) { | 1136 | if ( mSocket ) { |
1137 | delete mSocket; | 1137 | delete mSocket; |
1138 | mSocket = 0; | 1138 | mSocket = 0; |
1139 | } | 1139 | } |
1140 | //emit endConnect(); | 1140 | //emit endConnect(); |
1141 | } | 1141 | } |
1142 | void KServerSocket::readClient() | 1142 | void KServerSocket::readClient() |
1143 | { | 1143 | { |
1144 | if ( blockRC ) | 1144 | if ( blockRC ) |
1145 | return; | 1145 | return; |
1146 | if ( mSocket == 0 ) { | 1146 | if ( mSocket == 0 ) { |
1147 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 1147 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); |
1148 | return; | 1148 | return; |
1149 | } | 1149 | } |
1150 | //qDebug("KServerSocket::readClient()"); | 1150 | //qDebug("KServerSocket::readClient()"); |
1151 | if ( mSocket->canReadLine() ) { | 1151 | if ( mSocket->canReadLine() ) { |
1152 | QString line = mSocket->readLine(); | 1152 | QString line = mSocket->readLine(); |
1153 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 1153 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
1154 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 1154 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
1155 | if ( tokens[0] == "GET" ) { | 1155 | if ( tokens[0] == "GET" ) { |
1156 | if ( tokens[1] == mPassWord ) { | 1156 | if ( tokens[1] == mPassWord ) { |
1157 | //emit sendFile( mSocket ); | 1157 | //emit sendFile( mSocket ); |
1158 | bool ok = false; | 1158 | bool ok = false; |
1159 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); | 1159 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); |
1160 | if ( ok ) { | 1160 | if ( ok ) { |
1161 | KSyncManager::mRequestedSyncEvent = dt; | 1161 | KSyncManager::mRequestedSyncEvent = dt; |
1162 | } | 1162 | } |
1163 | else | 1163 | else |
1164 | KSyncManager::mRequestedSyncEvent = QDateTime(); | 1164 | KSyncManager::mRequestedSyncEvent = QDateTime(); |
1165 | send_file(); | 1165 | send_file(); |
1166 | } | 1166 | } |
1167 | else { | 1167 | else { |
1168 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); | 1168 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); |
1169 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1169 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1170 | } | 1170 | } |
1171 | } | 1171 | } |
1172 | if ( tokens[0] == "PUT" ) { | 1172 | if ( tokens[0] == "PUT" ) { |
1173 | if ( tokens[1] == mPassWord ) { | 1173 | if ( tokens[1] == mPassWord ) { |
1174 | //emit getFile( mSocket ); | 1174 | //emit getFile( mSocket ); |
1175 | blockRC = true; | 1175 | blockRC = true; |
1176 | get_file(); | 1176 | get_file(); |
1177 | } | 1177 | } |
1178 | else { | 1178 | else { |
1179 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); | 1179 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); |
1180 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1180 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1181 | } | 1181 | } |
1182 | } | 1182 | } |
1183 | if ( tokens[0] == "STOP" ) { | 1183 | if ( tokens[0] == "STOP" ) { |
1184 | //emit endConnect(); | 1184 | //emit endConnect(); |
1185 | end_connect(); | 1185 | end_connect(); |
1186 | } | 1186 | } |
1187 | } | 1187 | } |
1188 | } | 1188 | } |
1189 | void KServerSocket::end_connect() | 1189 | void KServerSocket::end_connect() |
1190 | { | 1190 | { |
1191 | delete mSyncActionDialog; | 1191 | delete mSyncActionDialog; |
1192 | mSyncActionDialog = 0; | 1192 | mSyncActionDialog = 0; |
1193 | } | 1193 | } |
1194 | void KServerSocket::send_file() | 1194 | void KServerSocket::send_file() |
1195 | { | 1195 | { |
1196 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 1196 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
1197 | if ( mSyncActionDialog ) | 1197 | if ( mSyncActionDialog ) |
1198 | delete mSyncActionDialog; | 1198 | delete mSyncActionDialog; |
1199 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 1199 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
1200 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 1200 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
1201 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 1201 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
1202 | label->setAlignment ( Qt::AlignHCenter ); | 1202 | label->setAlignment ( Qt::AlignHCenter ); |
1203 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1203 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1204 | lay->addWidget( label); | 1204 | lay->addWidget( label); |
1205 | lay->setMargin(7); | 1205 | lay->setMargin(7); |
1206 | lay->setSpacing(7); | 1206 | lay->setSpacing(7); |
1207 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1207 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1208 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); | 1208 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); |
1209 | if ( secs < 0 ) | 1209 | if ( secs < 0 ) |
1210 | secs = secs * (-1); | 1210 | secs = secs * (-1); |
1211 | if ( secs > 30 ) | 1211 | if ( secs > 30 ) |
1212 | //if ( true ) | 1212 | //if ( true ) |
1213 | { | 1213 | { |
1214 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); | 1214 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); |
1215 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1215 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1216 | label->setAlignment ( Qt::AlignHCenter ); | 1216 | label->setAlignment ( Qt::AlignHCenter ); |
1217 | lay->addWidget( label); | 1217 | lay->addWidget( label); |
1218 | if ( secs > 180 ) | 1218 | if ( secs > 180 ) |
1219 | { | 1219 | { |
1220 | if ( secs > 300 ) { | 1220 | if ( secs > 300 ) { |
1221 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { | 1221 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { |
1222 | qDebug("cancelled "); | 1222 | qDebug("KSS::Sync cancelled ,cs"); |
1223 | return ; | 1223 | return ; |
1224 | } | 1224 | } |
1225 | } | 1225 | } |
1226 | QFont f = label->font(); | 1226 | QFont f = label->font(); |
1227 | f.setPointSize ( f.pointSize() *2 ); | 1227 | f.setPointSize ( f.pointSize() *2 ); |
1228 | f. setBold (true ); | 1228 | f. setBold (true ); |
1229 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1229 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1230 | label->setFont( f ); | 1230 | label->setFont( f ); |
1231 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); | 1231 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); |
1232 | label->setText( warning ); | 1232 | label->setText( warning ); |
1233 | label->setAlignment ( Qt::AlignHCenter ); | 1233 | label->setAlignment ( Qt::AlignHCenter ); |
1234 | lay->addWidget( label); | 1234 | lay->addWidget( label); |
1235 | mSyncActionDialog->setFixedSize( 230, 300); | 1235 | mSyncActionDialog->setFixedSize( 230, 300); |
1236 | } else { | 1236 | } else { |
1237 | mSyncActionDialog->setFixedSize( 230, 200); | 1237 | mSyncActionDialog->setFixedSize( 230, 200); |
1238 | } | 1238 | } |
1239 | } else { | 1239 | } else { |
1240 | mSyncActionDialog->setFixedSize( 230, 120); | 1240 | mSyncActionDialog->setFixedSize( 230, 120); |
1241 | } | 1241 | } |
1242 | } else | 1242 | } else |
1243 | mSyncActionDialog->setFixedSize( 230, 120); | 1243 | mSyncActionDialog->setFixedSize( 230, 120); |
1244 | mSyncActionDialog->show(); | 1244 | mSyncActionDialog->show(); |
1245 | mSyncActionDialog->raise(); | 1245 | mSyncActionDialog->raise(); |
1246 | emit request_file(); | 1246 | emit request_file(); |
1247 | qApp->processEvents(); | 1247 | qApp->processEvents(); |
1248 | QString fileName = mFileName; | 1248 | QString fileName = mFileName; |
1249 | QFile file( fileName ); | 1249 | QFile file( fileName ); |
1250 | if (!file.open( IO_ReadOnly ) ) { | 1250 | if (!file.open( IO_ReadOnly ) ) { |
1251 | delete mSyncActionDialog; | 1251 | delete mSyncActionDialog; |
1252 | mSyncActionDialog = 0; | 1252 | mSyncActionDialog = 0; |
1253 | qDebug("KSS::error open sync file: %s ", fileName.latin1()); | 1253 | qDebug("KSS::error open sync file: %s ", fileName.latin1()); |
1254 | mSocket->close(); | 1254 | mSocket->close(); |
1255 | if ( mSocket->state() == QSocket::Idle ) | 1255 | if ( mSocket->state() == QSocket::Idle ) |
1256 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1256 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1257 | return ; | 1257 | return ; |
1258 | 1258 | ||
1259 | } | 1259 | } |
1260 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 1260 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
1261 | QTextStream ts( &file ); | 1261 | QTextStream ts( &file ); |
1262 | ts.setEncoding( QTextStream::Latin1 ); | 1262 | ts.setEncoding( QTextStream::Latin1 ); |
1263 | 1263 | ||
1264 | QTextStream os( mSocket ); | 1264 | QTextStream os( mSocket ); |
1265 | os.setEncoding( QTextStream::Latin1 ); | 1265 | os.setEncoding( QTextStream::Latin1 ); |
1266 | while ( ! ts.atEnd() ) { | 1266 | while ( ! ts.atEnd() ) { |
1267 | os << ts.readLine() << "\r\n"; | 1267 | os << ts.readLine() << "\r\n"; |
1268 | } | 1268 | } |
1269 | //os << ts.read(); | 1269 | //os << ts.read(); |
1270 | file.close(); | 1270 | file.close(); |
1271 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 1271 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
1272 | mSocket->close(); | 1272 | mSocket->close(); |
1273 | if ( mSocket->state() == QSocket::Idle ) | 1273 | if ( mSocket->state() == QSocket::Idle ) |
1274 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1274 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1275 | } | 1275 | } |
1276 | void KServerSocket::get_file() | 1276 | void KServerSocket::get_file() |
1277 | { | 1277 | { |
1278 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1278 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1279 | 1279 | ||
1280 | piTime.start(); | 1280 | piTime.start(); |
1281 | piFileString = ""; | 1281 | piFileString = ""; |
1282 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1282 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | 1285 | ||
1286 | void KServerSocket::readBackFileFromSocket() | 1286 | void KServerSocket::readBackFileFromSocket() |
1287 | { | 1287 | { |
1288 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1288 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
1289 | while ( mSocket->canReadLine () ) { | 1289 | while ( mSocket->canReadLine () ) { |
1290 | piTime.restart(); | 1290 | piTime.restart(); |
1291 | QString line = mSocket->readLine (); | 1291 | QString line = mSocket->readLine (); |
1292 | piFileString += line; | 1292 | piFileString += line; |
1293 | //qDebug("readline: %s ", line.latin1()); | 1293 | //qDebug("readline: %s ", line.latin1()); |
1294 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1294 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
1295 | 1295 | ||
1296 | } | 1296 | } |
1297 | if ( piTime.elapsed () < 3000 ) { | 1297 | if ( piTime.elapsed () < 3000 ) { |
1298 | // wait for more | 1298 | // wait for more |
1299 | //qDebug("waitformore "); | 1299 | //qDebug("waitformore "); |
1300 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1300 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
1301 | return; | 1301 | return; |
1302 | } | 1302 | } |
1303 | QString fileName = mFileName; | 1303 | QString fileName = mFileName; |
1304 | QFile file ( fileName ); | 1304 | QFile file ( fileName ); |
1305 | if (!file.open( IO_WriteOnly ) ) { | 1305 | if (!file.open( IO_WriteOnly ) ) { |
1306 | delete mSyncActionDialog; | 1306 | delete mSyncActionDialog; |
1307 | mSyncActionDialog = 0; | 1307 | mSyncActionDialog = 0; |
1308 | qDebug("KSS:Error open read back file "); | 1308 | qDebug("KSS:Error open read back file "); |
1309 | piFileString = ""; | 1309 | piFileString = ""; |
1310 | emit file_received( false ); | 1310 | emit file_received( false ); |
1311 | blockRC = false; | 1311 | blockRC = false; |
1312 | return ; | 1312 | return ; |
1313 | 1313 | ||
1314 | } | 1314 | } |
1315 | 1315 | ||
1316 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1316 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1317 | QTextStream ts ( &file ); | 1317 | QTextStream ts ( &file ); |
1318 | ts.setEncoding( QTextStream::Latin1 ); | 1318 | ts.setEncoding( QTextStream::Latin1 ); |
1319 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1319 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1320 | ts << piFileString; | 1320 | ts << piFileString; |
1321 | mSocket->close(); | 1321 | mSocket->close(); |
1322 | if ( mSocket->state() == QSocket::Idle ) | 1322 | if ( mSocket->state() == QSocket::Idle ) |
1323 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1323 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1324 | file.close(); | 1324 | file.close(); |
1325 | piFileString = ""; | 1325 | piFileString = ""; |
1326 | emit file_received( true ); | 1326 | emit file_received( true ); |
1327 | delete mSyncActionDialog; | 1327 | delete mSyncActionDialog; |
1328 | mSyncActionDialog = 0; | 1328 | mSyncActionDialog = 0; |
1329 | blockRC = false; | 1329 | blockRC = false; |
1330 | 1330 | ||
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 1333 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
1334 | { | 1334 | { |
1335 | mPassWord = password; | 1335 | mPassWord = password; |
1336 | mSocket = 0; | 1336 | mSocket = 0; |
1337 | mPort = port; | 1337 | mPort = port; |
1338 | mHost = host; | 1338 | mHost = host; |
1339 | 1339 | ||
1340 | mRetVal = quiet; | 1340 | mRetVal = quiet; |
1341 | mTimerSocket = new QTimer ( this ); | 1341 | mTimerSocket = new QTimer ( this ); |
1342 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 1342 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
1343 | } | 1343 | } |
1344 | void KCommandSocket::readFile( QString fn ) | 1344 | void KCommandSocket::readFile( QString fn ) |
1345 | { | 1345 | { |
1346 | if ( !mSocket ) { | 1346 | if ( !mSocket ) { |
1347 | mSocket = new QSocket( this ); | 1347 | mSocket = new QSocket( this ); |
1348 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1348 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1349 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1349 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1350 | } | 1350 | } |
1351 | mFileString = ""; | 1351 | mFileString = ""; |
1352 | mFileName = fn; | 1352 | mFileName = fn; |
1353 | mFirst = true; | 1353 | mFirst = true; |
1354 | mSocket->connectToHost( mHost, mPort ); | 1354 | mSocket->connectToHost( mHost, mPort ); |
1355 | QTextStream os( mSocket ); | 1355 | QTextStream os( mSocket ); |
1356 | os.setEncoding( QTextStream::Latin1 ); | 1356 | os.setEncoding( QTextStream::Latin1 ); |
1357 | 1357 | ||
1358 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); | 1358 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); |
1359 | os << "GET " << mPassWord << curDt <<"\r\n"; | 1359 | os << "GET " << mPassWord << curDt <<"\r\n"; |
1360 | mTimerSocket->start( 300000 ); | 1360 | mTimerSocket->start( 300000 ); |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | void KCommandSocket::writeFile( QString fileName ) | 1363 | void KCommandSocket::writeFile( QString fileName ) |
1364 | { | 1364 | { |
1365 | if ( !mSocket ) { | 1365 | if ( !mSocket ) { |
1366 | mSocket = new QSocket( this ); | 1366 | mSocket = new QSocket( this ); |
1367 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1367 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1368 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1368 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1369 | } | 1369 | } |
1370 | mFileName = fileName ; | 1370 | mFileName = fileName ; |
1371 | mSocket->connectToHost( mHost, mPort ); | 1371 | mSocket->connectToHost( mHost, mPort ); |
1372 | } | 1372 | } |
1373 | void KCommandSocket::writeFileToSocket() | 1373 | void KCommandSocket::writeFileToSocket() |
1374 | { | 1374 | { |
1375 | QFile file2( mFileName ); | 1375 | QFile file2( mFileName ); |
1376 | if (!file2.open( IO_ReadOnly ) ) { | 1376 | if (!file2.open( IO_ReadOnly ) ) { |
1377 | mRetVal= errorW; | 1377 | mRetVal= errorW; |
1378 | mSocket->close(); | 1378 | mSocket->close(); |
1379 | if ( mSocket->state() == QSocket::Idle ) | 1379 | if ( mSocket->state() == QSocket::Idle ) |
1380 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1380 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1381 | return ; | 1381 | return ; |
1382 | } | 1382 | } |
1383 | QTextStream ts2( &file2 ); | 1383 | QTextStream ts2( &file2 ); |
1384 | ts2.setEncoding( QTextStream::Latin1 ); | 1384 | ts2.setEncoding( QTextStream::Latin1 ); |
1385 | QTextStream os2( mSocket ); | 1385 | QTextStream os2( mSocket ); |
1386 | os2.setEncoding( QTextStream::Latin1 ); | 1386 | os2.setEncoding( QTextStream::Latin1 ); |
1387 | os2 << "PUT " << mPassWord << "\r\n";; | 1387 | os2 << "PUT " << mPassWord << "\r\n";; |
1388 | while ( ! ts2.atEnd() ) { | 1388 | while ( ! ts2.atEnd() ) { |
1389 | os2 << ts2.readLine() << "\r\n"; | 1389 | os2 << ts2.readLine() << "\r\n"; |
1390 | } | 1390 | } |
1391 | mRetVal= successW; | 1391 | mRetVal= successW; |
1392 | file2.close(); | 1392 | file2.close(); |
1393 | mSocket->close(); | 1393 | mSocket->close(); |
1394 | if ( mSocket->state() == QSocket::Idle ) | 1394 | if ( mSocket->state() == QSocket::Idle ) |
1395 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1395 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1396 | } | 1396 | } |
1397 | void KCommandSocket::sendStop() | 1397 | void KCommandSocket::sendStop() |
1398 | { | 1398 | { |
1399 | if ( !mSocket ) { | 1399 | if ( !mSocket ) { |
1400 | mSocket = new QSocket( this ); | 1400 | mSocket = new QSocket( this ); |
1401 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1401 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1402 | } | 1402 | } |
1403 | mSocket->connectToHost( mHost, mPort ); | 1403 | mSocket->connectToHost( mHost, mPort ); |
1404 | QTextStream os2( mSocket ); | 1404 | QTextStream os2( mSocket ); |
1405 | os2.setEncoding( QTextStream::Latin1 ); | 1405 | os2.setEncoding( QTextStream::Latin1 ); |
1406 | os2 << "STOP\r\n"; | 1406 | os2 << "STOP\r\n"; |
1407 | mSocket->close(); | 1407 | mSocket->close(); |
1408 | if ( mSocket->state() == QSocket::Idle ) | 1408 | if ( mSocket->state() == QSocket::Idle ) |
1409 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1409 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1410 | } | 1410 | } |
1411 | 1411 | ||
1412 | void KCommandSocket::startReadFileFromSocket() | 1412 | void KCommandSocket::startReadFileFromSocket() |
1413 | { | 1413 | { |
1414 | if ( ! mFirst ) | 1414 | if ( ! mFirst ) |
1415 | return; | 1415 | return; |
1416 | mFirst = false; | 1416 | mFirst = false; |
1417 | mTimerSocket->stop(); | 1417 | mTimerSocket->stop(); |
1418 | mFileString = ""; | 1418 | mFileString = ""; |
1419 | mTime.start(); | 1419 | mTime.start(); |
1420 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1420 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1421 | 1421 | ||
1422 | } | 1422 | } |
1423 | void KCommandSocket::readFileFromSocket() | 1423 | void KCommandSocket::readFileFromSocket() |
1424 | { | 1424 | { |
1425 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1425 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1426 | while ( mSocket->canReadLine () ) { | 1426 | while ( mSocket->canReadLine () ) { |
1427 | mTime.restart(); | 1427 | mTime.restart(); |
1428 | QString line = mSocket->readLine (); | 1428 | QString line = mSocket->readLine (); |
1429 | mFileString += line; | 1429 | mFileString += line; |
1430 | //qDebug("readline: %s ", line.latin1()); | 1430 | //qDebug("readline: %s ", line.latin1()); |
1431 | } | 1431 | } |
1432 | if ( mTime.elapsed () < 3000 ) { | 1432 | if ( mTime.elapsed () < 3000 ) { |
1433 | // wait for more | 1433 | // wait for more |
1434 | //qDebug("waitformore "); | 1434 | //qDebug("waitformore "); |
1435 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1435 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1436 | return; | 1436 | return; |
1437 | } | 1437 | } |
1438 | QString fileName = mFileName; | 1438 | QString fileName = mFileName; |
1439 | QFile file ( fileName ); | 1439 | QFile file ( fileName ); |
1440 | if (!file.open( IO_WriteOnly ) ) { | 1440 | if (!file.open( IO_WriteOnly ) ) { |
1441 | mFileString = ""; | 1441 | mFileString = ""; |
1442 | mRetVal = errorR; | 1442 | mRetVal = errorR; |
1443 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); | 1443 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); |
1444 | deleteSocket(); | 1444 | deleteSocket(); |
1445 | return ; | 1445 | return ; |
1446 | 1446 | ||
1447 | } | 1447 | } |
1448 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1448 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1449 | QTextStream ts ( &file ); | 1449 | QTextStream ts ( &file ); |
1450 | ts.setEncoding( QTextStream::Latin1 ); | 1450 | ts.setEncoding( QTextStream::Latin1 ); |
1451 | ts << mFileString; | 1451 | ts << mFileString; |
1452 | file.close(); | 1452 | file.close(); |
1453 | mFileString = ""; | 1453 | mFileString = ""; |
1454 | mRetVal = successR; | 1454 | mRetVal = successR; |
1455 | mSocket->close(); | 1455 | mSocket->close(); |
1456 | // if state is not idle, deleteSocket(); is called via | 1456 | // if state is not idle, deleteSocket(); is called via |
1457 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1457 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1458 | if ( mSocket->state() == QSocket::Idle ) | 1458 | if ( mSocket->state() == QSocket::Idle ) |
1459 | deleteSocket(); | 1459 | deleteSocket(); |
1460 | } | 1460 | } |
1461 | 1461 | ||
1462 | void KCommandSocket::deleteSocket() | 1462 | void KCommandSocket::deleteSocket() |
1463 | { | 1463 | { |
1464 | //qDebug("KCommandSocket::deleteSocket() "); | 1464 | //qDebug("KCommandSocket::deleteSocket() "); |
1465 | if ( mTimerSocket->isActive () ) { | 1465 | if ( mTimerSocket->isActive () ) { |
1466 | mTimerSocket->stop(); | 1466 | mTimerSocket->stop(); |
1467 | mRetVal = errorTO; | 1467 | mRetVal = errorTO; |
1468 | qDebug("Connection to remote host timed out"); | 1468 | qDebug("KCS::Connection to remote host timed out"); |
1469 | if ( mSocket ) { | 1469 | if ( mSocket ) { |
1470 | mSocket->close(); | 1470 | mSocket->close(); |
1471 | //if ( mSocket->state() == QSocket::Idle ) | 1471 | //if ( mSocket->state() == QSocket::Idle ) |
1472 | // deleteSocket(); | 1472 | // deleteSocket(); |
1473 | delete mSocket; | 1473 | delete mSocket; |
1474 | mSocket = 0; | 1474 | mSocket = 0; |
1475 | } | 1475 | } |
1476 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 1476 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
1477 | emit commandFinished( this, mRetVal ); | 1477 | emit commandFinished( this, mRetVal ); |
1478 | return; | 1478 | return; |
1479 | } | 1479 | } |
1480 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1480 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1481 | if ( mSocket) | 1481 | if ( mSocket) |
1482 | delete mSocket; | 1482 | delete mSocket; |
1483 | mSocket = 0; | 1483 | mSocket = 0; |
1484 | emit commandFinished( this, mRetVal ); | 1484 | emit commandFinished( this, mRetVal ); |
1485 | } | 1485 | } |