author | zautrix <zautrix> | 2004-10-28 11:03:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-28 11:03:42 (UTC) |
commit | 01cd4ef94b8604532181c390e9abd560aebaf372 (patch) (unidiff) | |
tree | 96ca1a524512ae2e2868f0bd3df03e4da5c445f9 | |
parent | 61d9eb436349a841410559f51e2601a34ceb5794 (diff) | |
download | kdepimpi-01cd4ef94b8604532181c390e9abd560aebaf372.zip kdepimpi-01cd4ef94b8604532181c390e9abd560aebaf372.tar.gz kdepimpi-01cd4ef94b8604532181c390e9abd560aebaf372.tar.bz2 |
added howto to menus
-rw-r--r-- | kaddressbook/kabcore.cpp | 32 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 4 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 12 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 48 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 2 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 4 |
6 files changed, 74 insertions, 28 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 5ebd3a4..bdc5bd8 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2955 +1,2975 @@ | |||
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 | 118 | ||
119 | 119 | ||
120 | #include <kresources/selectdialog.h> | 120 | #include <kresources/selectdialog.h> |
121 | #include <kmessagebox.h> | 121 | #include <kmessagebox.h> |
122 | 122 | ||
123 | #include <picture.h> | 123 | #include <picture.h> |
124 | #include <resource.h> | 124 | #include <resource.h> |
125 | 125 | ||
126 | //US#include <qsplitter.h> | 126 | //US#include <qsplitter.h> |
127 | #include <qmap.h> | 127 | #include <qmap.h> |
128 | #include <qdir.h> | 128 | #include <qdir.h> |
129 | #include <qfile.h> | 129 | #include <qfile.h> |
130 | #include <qvbox.h> | 130 | #include <qvbox.h> |
131 | #include <qlayout.h> | 131 | #include <qlayout.h> |
132 | #include <qclipboard.h> | 132 | #include <qclipboard.h> |
133 | #include <qtextstream.h> | 133 | #include <qtextstream.h> |
134 | 134 | ||
135 | #include <libkdepim/categoryselectdialog.h> | 135 | #include <libkdepim/categoryselectdialog.h> |
136 | #include <kabc/vcardconverter.h> | 136 | #include <kabc/vcardconverter.h> |
137 | 137 | ||
138 | 138 | ||
139 | #include "addresseeutil.h" | 139 | #include "addresseeutil.h" |
140 | #include "undocmds.h" | 140 | #include "undocmds.h" |
141 | #include "addresseeeditordialog.h" | 141 | #include "addresseeeditordialog.h" |
142 | #include "viewmanager.h" | 142 | #include "viewmanager.h" |
143 | #include "details/detailsviewcontainer.h" | 143 | #include "details/detailsviewcontainer.h" |
144 | #include "kabprefs.h" | 144 | #include "kabprefs.h" |
145 | #include "xxportmanager.h" | 145 | #include "xxportmanager.h" |
146 | #include "incsearchwidget.h" | 146 | #include "incsearchwidget.h" |
147 | #include "jumpbuttonbar.h" | 147 | #include "jumpbuttonbar.h" |
148 | #include "extensionmanager.h" | 148 | #include "extensionmanager.h" |
149 | #include "addresseeconfig.h" | 149 | #include "addresseeconfig.h" |
150 | #include <kcmultidialog.h> | 150 | #include <kcmultidialog.h> |
151 | 151 | ||
152 | #ifdef _WIN32_ | 152 | #ifdef _WIN32_ |
153 | 153 | ||
154 | #include "kaimportoldialog.h" | 154 | #include "kaimportoldialog.h" |
155 | #else | 155 | #else |
156 | #include <unistd.h> | 156 | #include <unistd.h> |
157 | #endif | 157 | #endif |
158 | // sync includes | 158 | // sync includes |
159 | #include <libkdepim/ksyncprofile.h> | 159 | #include <libkdepim/ksyncprofile.h> |
160 | #include <libkdepim/ksyncprefsdialog.h> | 160 | #include <libkdepim/ksyncprefsdialog.h> |
161 | 161 | ||
162 | class KAex2phonePrefs : public QDialog | 162 | class KAex2phonePrefs : public QDialog |
163 | { | 163 | { |
164 | public: | 164 | public: |
165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
166 | QDialog( parent, name, true ) | 166 | QDialog( parent, name, true ) |
167 | { | 167 | { |
168 | setCaption( i18n("Export to phone options") ); | 168 | setCaption( i18n("Export to phone options") ); |
169 | QVBoxLayout* lay = new QVBoxLayout( this ); | 169 | QVBoxLayout* lay = new QVBoxLayout( this ); |
170 | lay->setSpacing( 3 ); | 170 | lay->setSpacing( 3 ); |
171 | lay->setMargin( 3 ); | 171 | lay->setMargin( 3 ); |
172 | QLabel *lab; | 172 | QLabel *lab; |
173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
174 | lab->setAlignment (AlignHCenter ); | 174 | lab->setAlignment (AlignHCenter ); |
175 | QHBox* temphb; | 175 | QHBox* temphb; |
176 | temphb = new QHBox( this ); | 176 | temphb = new QHBox( this ); |
177 | new QLabel( i18n("I/O device: "), temphb ); | 177 | new QLabel( i18n("I/O device: "), temphb ); |
178 | mPhoneDevice = new QLineEdit( temphb); | 178 | mPhoneDevice = new QLineEdit( temphb); |
179 | lay->addWidget( temphb ); | 179 | lay->addWidget( temphb ); |
180 | temphb = new QHBox( this ); | 180 | temphb = new QHBox( this ); |
181 | new QLabel( i18n("Connection: "), temphb ); | 181 | new QLabel( i18n("Connection: "), temphb ); |
182 | mPhoneConnection = new QLineEdit( temphb); | 182 | mPhoneConnection = new QLineEdit( temphb); |
183 | lay->addWidget( temphb ); | 183 | lay->addWidget( temphb ); |
184 | temphb = new QHBox( this ); | 184 | temphb = new QHBox( this ); |
185 | new QLabel( i18n("Model(opt.): "), temphb ); | 185 | new QLabel( i18n("Model(opt.): "), temphb ); |
186 | mPhoneModel = new QLineEdit( temphb); | 186 | mPhoneModel = new QLineEdit( temphb); |
187 | lay->addWidget( temphb ); | 187 | lay->addWidget( temphb ); |
188 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 188 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
189 | // lay->addWidget( mWriteToSim ); | 189 | // lay->addWidget( mWriteToSim ); |
190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
191 | lab->setAlignment (AlignHCenter ); | 191 | lab->setAlignment (AlignHCenter ); |
192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
193 | lay->addWidget( ok ); | 193 | lay->addWidget( ok ); |
194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
195 | lay->addWidget( cancel ); | 195 | lay->addWidget( cancel ); |
196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
198 | resize( 220, 240 ); | 198 | resize( 220, 240 ); |
199 | 199 | ||
200 | } | 200 | } |
201 | 201 | ||
202 | public: | 202 | public: |
203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
204 | QCheckBox* mWriteToSim; | 204 | QCheckBox* mWriteToSim; |
205 | }; | 205 | }; |
206 | 206 | ||
207 | 207 | ||
208 | bool pasteWithNewUid = true; | 208 | bool pasteWithNewUid = true; |
209 | 209 | ||
210 | #ifdef KAB_EMBEDDED | 210 | #ifdef KAB_EMBEDDED |
211 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 211 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
212 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 212 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
213 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 213 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
214 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 214 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
215 | #else //KAB_EMBEDDED | 215 | #else //KAB_EMBEDDED |
216 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 216 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
217 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 217 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
218 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 218 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
219 | mReadWrite( readWrite ), mModified( false ) | 219 | mReadWrite( readWrite ), mModified( false ) |
220 | #endif //KAB_EMBEDDED | 220 | #endif //KAB_EMBEDDED |
221 | { | 221 | { |
222 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 222 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
223 | // syncManager->setBlockSave(false); | 223 | // syncManager->setBlockSave(false); |
224 | mExtensionBarSplitter = 0; | 224 | mExtensionBarSplitter = 0; |
225 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 225 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
226 | mAddressBook = KABC::StdAddressBook::self(); | 226 | mAddressBook = KABC::StdAddressBook::self(); |
227 | KABC::StdAddressBook::setAutomaticSave( false ); | 227 | KABC::StdAddressBook::setAutomaticSave( false ); |
228 | 228 | ||
229 | #ifndef KAB_EMBEDDED | 229 | #ifndef KAB_EMBEDDED |
230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
231 | #endif //KAB_EMBEDDED | 231 | #endif //KAB_EMBEDDED |
232 | 232 | ||
233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
234 | SLOT( addressBookChanged() ) ); | 234 | SLOT( addressBookChanged() ) ); |
235 | 235 | ||
236 | #if 0 | 236 | #if 0 |
237 | // LP moved to addressbook init method | 237 | // LP moved to addressbook init method |
238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
239 | "X-Department", "KADDRESSBOOK" ); | 239 | "X-Department", "KADDRESSBOOK" ); |
240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
241 | "X-Profession", "KADDRESSBOOK" ); | 241 | "X-Profession", "KADDRESSBOOK" ); |
242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
243 | "X-AssistantsName", "KADDRESSBOOK" ); | 243 | "X-AssistantsName", "KADDRESSBOOK" ); |
244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
245 | "X-ManagersName", "KADDRESSBOOK" ); | 245 | "X-ManagersName", "KADDRESSBOOK" ); |
246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
247 | "X-SpousesName", "KADDRESSBOOK" ); | 247 | "X-SpousesName", "KADDRESSBOOK" ); |
248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
249 | "X-Office", "KADDRESSBOOK" ); | 249 | "X-Office", "KADDRESSBOOK" ); |
250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
251 | "X-IMAddress", "KADDRESSBOOK" ); | 251 | "X-IMAddress", "KADDRESSBOOK" ); |
252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
253 | "X-Anniversary", "KADDRESSBOOK" ); | 253 | "X-Anniversary", "KADDRESSBOOK" ); |
254 | 254 | ||
255 | //US added this field to become compatible with Opie/qtopia addressbook | 255 | //US added this field to become compatible with Opie/qtopia addressbook |
256 | // values can be "female" or "male" or "". An empty field represents undefined. | 256 | // values can be "female" or "male" or "". An empty field represents undefined. |
257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
258 | "X-Gender", "KADDRESSBOOK" ); | 258 | "X-Gender", "KADDRESSBOOK" ); |
259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
260 | "X-Children", "KADDRESSBOOK" ); | 260 | "X-Children", "KADDRESSBOOK" ); |
261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
263 | #endif | 263 | #endif |
264 | initGUI(); | 264 | initGUI(); |
265 | 265 | ||
266 | mIncSearchWidget->setFocus(); | 266 | mIncSearchWidget->setFocus(); |
267 | 267 | ||
268 | 268 | ||
269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
270 | SLOT( setContactSelected( const QString& ) ) ); | 270 | SLOT( setContactSelected( const QString& ) ) ); |
271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
272 | SLOT( executeContact( const QString& ) ) ); | 272 | SLOT( executeContact( const QString& ) ) ); |
273 | 273 | ||
274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
275 | SLOT( deleteContacts( ) ) ); | 275 | SLOT( deleteContacts( ) ) ); |
276 | connect( mViewManager, SIGNAL( modified() ), | 276 | connect( mViewManager, SIGNAL( modified() ), |
277 | SLOT( setModified() ) ); | 277 | SLOT( setModified() ) ); |
278 | 278 | ||
279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
281 | 281 | ||
282 | connect( mXXPortManager, SIGNAL( modified() ), | 282 | connect( mXXPortManager, SIGNAL( modified() ), |
283 | SLOT( setModified() ) ); | 283 | SLOT( setModified() ) ); |
284 | 284 | ||
285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
286 | SLOT( incrementalSearch( const QString& ) ) ); | 286 | SLOT( incrementalSearch( const QString& ) ) ); |
287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
288 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 288 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
289 | 289 | ||
290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
291 | SLOT( sendMail( const QString& ) ) ); | 291 | SLOT( sendMail( const QString& ) ) ); |
292 | 292 | ||
293 | 293 | ||
294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
295 | 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&))); | 295 | 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&))); |
296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
297 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); | 297 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); |
298 | 298 | ||
299 | 299 | ||
300 | #ifndef KAB_EMBEDDED | 300 | #ifndef KAB_EMBEDDED |
301 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 301 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
302 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 302 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
303 | 303 | ||
304 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 304 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
305 | SLOT( browse( const QString& ) ) ); | 305 | SLOT( browse( const QString& ) ) ); |
306 | 306 | ||
307 | 307 | ||
308 | mAddressBookService = new KAddressBookService( this ); | 308 | mAddressBookService = new KAddressBookService( this ); |
309 | 309 | ||
310 | #endif //KAB_EMBEDDED | 310 | #endif //KAB_EMBEDDED |
311 | 311 | ||
312 | mMessageTimer = new QTimer( this ); | 312 | mMessageTimer = new QTimer( this ); |
313 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 313 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
314 | mEditorDialog = 0; | 314 | mEditorDialog = 0; |
315 | createAddresseeEditorDialog( this ); | 315 | createAddresseeEditorDialog( this ); |
316 | setModified( false ); | 316 | setModified( false ); |
317 | mBRdisabled = false; | 317 | mBRdisabled = false; |
318 | #ifndef DESKTOP_VERSION | 318 | #ifndef DESKTOP_VERSION |
319 | infrared = 0; | 319 | infrared = 0; |
320 | #endif | 320 | #endif |
321 | //toggleBeamReceive( ); | 321 | //toggleBeamReceive( ); |
322 | } | 322 | } |
323 | 323 | ||
324 | KABCore::~KABCore() | 324 | KABCore::~KABCore() |
325 | { | 325 | { |
326 | // save(); | 326 | // save(); |
327 | //saveSettings(); | 327 | //saveSettings(); |
328 | //KABPrefs::instance()->writeConfig(); | 328 | //KABPrefs::instance()->writeConfig(); |
329 | delete AddresseeConfig::instance(); | 329 | delete AddresseeConfig::instance(); |
330 | mAddressBook = 0; | 330 | mAddressBook = 0; |
331 | KABC::StdAddressBook::close(); | 331 | KABC::StdAddressBook::close(); |
332 | 332 | ||
333 | delete syncManager; | 333 | delete syncManager; |
334 | #ifndef DESKTOP_VERSION | 334 | #ifndef DESKTOP_VERSION |
335 | if ( infrared ) | 335 | if ( infrared ) |
336 | delete infrared; | 336 | delete infrared; |
337 | #endif | 337 | #endif |
338 | } | 338 | } |
339 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 339 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
340 | { | 340 | { |
341 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 341 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
342 | if ( cmsg == "setDocument(QString)" ) { | 342 | if ( cmsg == "setDocument(QString)" ) { |
343 | QDataStream stream( data, IO_ReadOnly ); | 343 | QDataStream stream( data, IO_ReadOnly ); |
344 | QString fileName; | 344 | QString fileName; |
345 | stream >> fileName; | 345 | stream >> fileName; |
346 | recieve( fileName ); | 346 | recieve( fileName ); |
347 | return; | 347 | return; |
348 | } | 348 | } |
349 | else if ( cmsg == "nextView()" ) | 349 | else if ( cmsg == "nextView()" ) |
350 | { | 350 | { |
351 | //toggle between details/ no details | 351 | //toggle between details/ no details |
352 | bool b = !mActionDetails->isChecked(); | 352 | bool b = !mActionDetails->isChecked(); |
353 | setDetailsVisible( b ); | 353 | setDetailsVisible( b ); |
354 | mActionDetails->setChecked( b ); | 354 | mActionDetails->setChecked( b ); |
355 | } | 355 | } |
356 | 356 | ||
357 | 357 | ||
358 | } | 358 | } |
359 | void KABCore::toggleBeamReceive( ) | 359 | void KABCore::toggleBeamReceive( ) |
360 | { | 360 | { |
361 | if ( mBRdisabled ) | 361 | if ( mBRdisabled ) |
362 | return; | 362 | return; |
363 | #ifndef DESKTOP_VERSION | 363 | #ifndef DESKTOP_VERSION |
364 | if ( infrared ) { | 364 | if ( infrared ) { |
365 | qDebug("AB disable BeamReceive "); | 365 | qDebug("AB disable BeamReceive "); |
366 | delete infrared; | 366 | delete infrared; |
367 | infrared = 0; | 367 | infrared = 0; |
368 | mActionBR->setChecked(false); | 368 | mActionBR->setChecked(false); |
369 | return; | 369 | return; |
370 | } | 370 | } |
371 | qDebug("AB enable BeamReceive "); | 371 | qDebug("AB enable BeamReceive "); |
372 | mActionBR->setChecked(true); | 372 | mActionBR->setChecked(true); |
373 | 373 | ||
374 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 374 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
375 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 375 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
376 | #endif | 376 | #endif |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | void KABCore::disableBR(bool b) | 380 | void KABCore::disableBR(bool b) |
381 | { | 381 | { |
382 | #ifndef DESKTOP_VERSION | 382 | #ifndef DESKTOP_VERSION |
383 | if ( b ) { | 383 | if ( b ) { |
384 | if ( infrared ) { | 384 | if ( infrared ) { |
385 | toggleBeamReceive( ); | 385 | toggleBeamReceive( ); |
386 | } | 386 | } |
387 | mBRdisabled = true; | 387 | mBRdisabled = true; |
388 | } else { | 388 | } else { |
389 | if ( mBRdisabled ) { | 389 | if ( mBRdisabled ) { |
390 | mBRdisabled = false; | 390 | mBRdisabled = false; |
391 | //toggleBeamReceive( ); | 391 | //toggleBeamReceive( ); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | #endif | 394 | #endif |
395 | 395 | ||
396 | } | 396 | } |
397 | void KABCore::recieve( QString fn ) | 397 | void KABCore::recieve( QString fn ) |
398 | { | 398 | { |
399 | //qDebug("KABCore::recieve "); | 399 | //qDebug("KABCore::recieve "); |
400 | int count = mAddressBook->importFromFile( fn, true ); | 400 | int count = mAddressBook->importFromFile( fn, true ); |
401 | if ( count ) | 401 | if ( count ) |
402 | setModified( true ); | 402 | setModified( true ); |
403 | mViewManager->refreshView(); | 403 | mViewManager->refreshView(); |
404 | message(i18n("%1 contact(s) received!").arg( count )); | 404 | message(i18n("%1 contact(s) received!").arg( count )); |
405 | topLevelWidget()->showMaximized(); | 405 | topLevelWidget()->showMaximized(); |
406 | topLevelWidget()->raise(); | 406 | topLevelWidget()->raise(); |
407 | } | 407 | } |
408 | void KABCore::restoreSettings() | 408 | void KABCore::restoreSettings() |
409 | { | 409 | { |
410 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 410 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
411 | 411 | ||
412 | bool state; | 412 | bool state; |
413 | 413 | ||
414 | if (mMultipleViewsAtOnce) | 414 | if (mMultipleViewsAtOnce) |
415 | state = KABPrefs::instance()->mDetailsPageVisible; | 415 | state = KABPrefs::instance()->mDetailsPageVisible; |
416 | else | 416 | else |
417 | state = false; | 417 | state = false; |
418 | 418 | ||
419 | mActionDetails->setChecked( state ); | 419 | mActionDetails->setChecked( state ); |
420 | setDetailsVisible( state ); | 420 | setDetailsVisible( state ); |
421 | 421 | ||
422 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 422 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
423 | 423 | ||
424 | mActionJumpBar->setChecked( state ); | 424 | mActionJumpBar->setChecked( state ); |
425 | setJumpButtonBarVisible( state ); | 425 | setJumpButtonBarVisible( state ); |
426 | /*US | 426 | /*US |
427 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 427 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
428 | if ( splitterSize.count() == 0 ) { | 428 | if ( splitterSize.count() == 0 ) { |
429 | splitterSize.append( width() / 2 ); | 429 | splitterSize.append( width() / 2 ); |
430 | splitterSize.append( width() / 2 ); | 430 | splitterSize.append( width() / 2 ); |
431 | } | 431 | } |
432 | mMiniSplitter->setSizes( splitterSize ); | 432 | mMiniSplitter->setSizes( splitterSize ); |
433 | if ( mExtensionBarSplitter ) { | 433 | if ( mExtensionBarSplitter ) { |
434 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 434 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
435 | if ( splitterSize.count() == 0 ) { | 435 | if ( splitterSize.count() == 0 ) { |
436 | splitterSize.append( width() / 2 ); | 436 | splitterSize.append( width() / 2 ); |
437 | splitterSize.append( width() / 2 ); | 437 | splitterSize.append( width() / 2 ); |
438 | } | 438 | } |
439 | mExtensionBarSplitter->setSizes( splitterSize ); | 439 | mExtensionBarSplitter->setSizes( splitterSize ); |
440 | 440 | ||
441 | } | 441 | } |
442 | */ | 442 | */ |
443 | mViewManager->restoreSettings(); | 443 | mViewManager->restoreSettings(); |
444 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 444 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
445 | mExtensionManager->restoreSettings(); | 445 | mExtensionManager->restoreSettings(); |
446 | #ifdef DESKTOP_VERSION | 446 | #ifdef DESKTOP_VERSION |
447 | int wid = width(); | 447 | int wid = width(); |
448 | if ( wid < 10 ) | 448 | if ( wid < 10 ) |
449 | wid = 400; | 449 | wid = 400; |
450 | #else | 450 | #else |
451 | int wid = QApplication::desktop()->width(); | 451 | int wid = QApplication::desktop()->width(); |
452 | if ( wid < 640 ) | 452 | if ( wid < 640 ) |
453 | wid = QApplication::desktop()->height(); | 453 | wid = QApplication::desktop()->height(); |
454 | #endif | 454 | #endif |
455 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 455 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
456 | if ( true /*splitterSize.count() == 0*/ ) { | 456 | if ( true /*splitterSize.count() == 0*/ ) { |
457 | splitterSize.append( wid / 2 ); | 457 | splitterSize.append( wid / 2 ); |
458 | splitterSize.append( wid / 2 ); | 458 | splitterSize.append( wid / 2 ); |
459 | } | 459 | } |
460 | mMiniSplitter->setSizes( splitterSize ); | 460 | mMiniSplitter->setSizes( splitterSize ); |
461 | if ( mExtensionBarSplitter ) { | 461 | if ( mExtensionBarSplitter ) { |
462 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 462 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
463 | if ( true /*splitterSize.count() == 0*/ ) { | 463 | if ( true /*splitterSize.count() == 0*/ ) { |
464 | splitterSize.append( wid / 2 ); | 464 | splitterSize.append( wid / 2 ); |
465 | splitterSize.append( wid / 2 ); | 465 | splitterSize.append( wid / 2 ); |
466 | } | 466 | } |
467 | mExtensionBarSplitter->setSizes( splitterSize ); | 467 | mExtensionBarSplitter->setSizes( splitterSize ); |
468 | 468 | ||
469 | } | 469 | } |
470 | 470 | ||
471 | 471 | ||
472 | } | 472 | } |
473 | 473 | ||
474 | void KABCore::saveSettings() | 474 | void KABCore::saveSettings() |
475 | { | 475 | { |
476 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 476 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
477 | if ( mExtensionBarSplitter ) | 477 | if ( mExtensionBarSplitter ) |
478 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 478 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
479 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 479 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
480 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 480 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
481 | #ifndef KAB_EMBEDDED | 481 | #ifndef KAB_EMBEDDED |
482 | 482 | ||
483 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 483 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
484 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 484 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
485 | #endif //KAB_EMBEDDED | 485 | #endif //KAB_EMBEDDED |
486 | mExtensionManager->saveSettings(); | 486 | mExtensionManager->saveSettings(); |
487 | mViewManager->saveSettings(); | 487 | mViewManager->saveSettings(); |
488 | 488 | ||
489 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 489 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
490 | } | 490 | } |
491 | 491 | ||
492 | KABC::AddressBook *KABCore::addressBook() const | 492 | KABC::AddressBook *KABCore::addressBook() const |
493 | { | 493 | { |
494 | return mAddressBook; | 494 | return mAddressBook; |
495 | } | 495 | } |
496 | 496 | ||
497 | KConfig *KABCore::config() | 497 | KConfig *KABCore::config() |
498 | { | 498 | { |
499 | #ifndef KAB_EMBEDDED | 499 | #ifndef KAB_EMBEDDED |
500 | return KABPrefs::instance()->config(); | 500 | return KABPrefs::instance()->config(); |
501 | #else //KAB_EMBEDDED | 501 | #else //KAB_EMBEDDED |
502 | return KABPrefs::instance()->getConfig(); | 502 | return KABPrefs::instance()->getConfig(); |
503 | #endif //KAB_EMBEDDED | 503 | #endif //KAB_EMBEDDED |
504 | } | 504 | } |
505 | 505 | ||
506 | KActionCollection *KABCore::actionCollection() const | 506 | KActionCollection *KABCore::actionCollection() const |
507 | { | 507 | { |
508 | return mGUIClient->actionCollection(); | 508 | return mGUIClient->actionCollection(); |
509 | } | 509 | } |
510 | 510 | ||
511 | KABC::Field *KABCore::currentSearchField() const | 511 | KABC::Field *KABCore::currentSearchField() const |
512 | { | 512 | { |
513 | if (mIncSearchWidget) | 513 | if (mIncSearchWidget) |
514 | return mIncSearchWidget->currentField(); | 514 | return mIncSearchWidget->currentField(); |
515 | else | 515 | else |
516 | return 0; | 516 | return 0; |
517 | } | 517 | } |
518 | 518 | ||
519 | QStringList KABCore::selectedUIDs() const | 519 | QStringList KABCore::selectedUIDs() const |
520 | { | 520 | { |
521 | return mViewManager->selectedUids(); | 521 | return mViewManager->selectedUids(); |
522 | } | 522 | } |
523 | 523 | ||
524 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 524 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
525 | { | 525 | { |
526 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 526 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
527 | 527 | ||
528 | QPtrList<KRES::Resource> kresResources; | 528 | QPtrList<KRES::Resource> kresResources; |
529 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 529 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
530 | KABC::Resource *resource; | 530 | KABC::Resource *resource; |
531 | while ( ( resource = resIt.current() ) != 0 ) { | 531 | while ( ( resource = resIt.current() ) != 0 ) { |
532 | ++resIt; | 532 | ++resIt; |
533 | if ( !resource->readOnly() ) { | 533 | if ( !resource->readOnly() ) { |
534 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 534 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
535 | if ( res ) | 535 | if ( res ) |
536 | kresResources.append( res ); | 536 | kresResources.append( res ); |
537 | } | 537 | } |
538 | } | 538 | } |
539 | 539 | ||
540 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 540 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
541 | return static_cast<KABC::Resource*>( res ); | 541 | return static_cast<KABC::Resource*>( res ); |
542 | } | 542 | } |
543 | 543 | ||
544 | #ifndef KAB_EMBEDDED | 544 | #ifndef KAB_EMBEDDED |
545 | KAboutData *KABCore::createAboutData() | 545 | KAboutData *KABCore::createAboutData() |
546 | #else //KAB_EMBEDDED | 546 | #else //KAB_EMBEDDED |
547 | void KABCore::createAboutData() | 547 | void KABCore::createAboutData() |
548 | #endif //KAB_EMBEDDED | 548 | #endif //KAB_EMBEDDED |
549 | { | 549 | { |
550 | #ifndef KAB_EMBEDDED | 550 | #ifndef KAB_EMBEDDED |
551 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 551 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
552 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 552 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
553 | KAboutData::License_GPL_V2, | 553 | KAboutData::License_GPL_V2, |
554 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 554 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
555 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 555 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
556 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 556 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
557 | about->addAuthor( "Cornelius Schumacher", | 557 | about->addAuthor( "Cornelius Schumacher", |
558 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 558 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
559 | "schumacher@kde.org" ); | 559 | "schumacher@kde.org" ); |
560 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 560 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
561 | "mpilone@slac.com" ); | 561 | "mpilone@slac.com" ); |
562 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 562 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
563 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 563 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
564 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 564 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
565 | "michel@klaralvdalens-datakonsult.se" ); | 565 | "michel@klaralvdalens-datakonsult.se" ); |
566 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 566 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
567 | "hansen@kde.org" ); | 567 | "hansen@kde.org" ); |
568 | 568 | ||
569 | return about; | 569 | return about; |
570 | #endif //KAB_EMBEDDED | 570 | #endif //KAB_EMBEDDED |
571 | 571 | ||
572 | QString version; | 572 | QString version; |
573 | #include <../version> | 573 | #include <../version> |
574 | QMessageBox::about( this, "About KAddressbook/Pi", | 574 | QMessageBox::about( this, "About KAddressbook/Pi", |
575 | "KAddressbook/Platform-independent\n" | 575 | "KAddressbook/Platform-independent\n" |
576 | "(KA/Pi) " +version + " - " + | 576 | "(KA/Pi) " +version + " - " + |
577 | #ifdef DESKTOP_VERSION | 577 | #ifdef DESKTOP_VERSION |
578 | "Desktop Edition\n" | 578 | "Desktop Edition\n" |
579 | #else | 579 | #else |
580 | "PDA-Edition\n" | 580 | "PDA-Edition\n" |
581 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 581 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
582 | #endif | 582 | #endif |
583 | 583 | ||
584 | "(c) 2004 Ulf Schenk\n" | 584 | "(c) 2004 Ulf Schenk\n" |
585 | "(c) 2004 Lutz Rogowski\n" | 585 | "(c) 2004 Lutz Rogowski\n" |
586 | "(c) 1997-2003, The KDE PIM Team\n" | 586 | "(c) 1997-2003, The KDE PIM Team\n" |
587 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 587 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
588 | "Don Sanders Original author\n" | 588 | "Don Sanders Original author\n" |
589 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 589 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
590 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 590 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
591 | "Greg Stern DCOP interface\n" | 591 | "Greg Stern DCOP interface\n" |
592 | "Mark Westcot Contact pinning\n" | 592 | "Mark Westcot Contact pinning\n" |
593 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 593 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
594 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 594 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
595 | #ifdef _WIN32_ | 595 | #ifdef _WIN32_ |
596 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 596 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
597 | #endif | 597 | #endif |
598 | ); | 598 | ); |
599 | } | 599 | } |
600 | 600 | ||
601 | void KABCore::setContactSelected( const QString &uid ) | 601 | void KABCore::setContactSelected( const QString &uid ) |
602 | { | 602 | { |
603 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 603 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
604 | if ( !mDetails->isHidden() ) | 604 | if ( !mDetails->isHidden() ) |
605 | mDetails->setAddressee( addr ); | 605 | mDetails->setAddressee( addr ); |
606 | 606 | ||
607 | if ( !addr.isEmpty() ) { | 607 | if ( !addr.isEmpty() ) { |
608 | emit contactSelected( addr.formattedName() ); | 608 | emit contactSelected( addr.formattedName() ); |
609 | KABC::Picture pic = addr.photo(); | 609 | KABC::Picture pic = addr.photo(); |
610 | if ( pic.isIntern() ) { | 610 | if ( pic.isIntern() ) { |
611 | //US emit contactSelected( pic.data() ); | 611 | //US emit contactSelected( pic.data() ); |
612 | //US instead use: | 612 | //US instead use: |
613 | QPixmap px; | 613 | QPixmap px; |
614 | if (pic.data().isNull() != true) | 614 | if (pic.data().isNull() != true) |
615 | { | 615 | { |
616 | px.convertFromImage(pic.data()); | 616 | px.convertFromImage(pic.data()); |
617 | } | 617 | } |
618 | 618 | ||
619 | emit contactSelected( px ); | 619 | emit contactSelected( px ); |
620 | } | 620 | } |
621 | } | 621 | } |
622 | 622 | ||
623 | 623 | ||
624 | mExtensionManager->setSelectionChanged(); | 624 | mExtensionManager->setSelectionChanged(); |
625 | 625 | ||
626 | // update the actions | 626 | // update the actions |
627 | bool selected = !uid.isEmpty(); | 627 | bool selected = !uid.isEmpty(); |
628 | 628 | ||
629 | if ( mReadWrite ) { | 629 | if ( mReadWrite ) { |
630 | mActionCut->setEnabled( selected ); | 630 | mActionCut->setEnabled( selected ); |
631 | mActionPaste->setEnabled( selected ); | 631 | mActionPaste->setEnabled( selected ); |
632 | } | 632 | } |
633 | 633 | ||
634 | mActionCopy->setEnabled( selected ); | 634 | mActionCopy->setEnabled( selected ); |
635 | mActionDelete->setEnabled( selected ); | 635 | mActionDelete->setEnabled( selected ); |
636 | mActionEditAddressee->setEnabled( selected ); | 636 | mActionEditAddressee->setEnabled( selected ); |
637 | mActionMail->setEnabled( selected ); | 637 | mActionMail->setEnabled( selected ); |
638 | mActionMailVCard->setEnabled( selected ); | 638 | mActionMailVCard->setEnabled( selected ); |
639 | //if (mActionBeam) | 639 | //if (mActionBeam) |
640 | //mActionBeam->setEnabled( selected ); | 640 | //mActionBeam->setEnabled( selected ); |
641 | 641 | ||
642 | if (mActionBeamVCard) | 642 | if (mActionBeamVCard) |
643 | mActionBeamVCard->setEnabled( selected ); | 643 | mActionBeamVCard->setEnabled( selected ); |
644 | 644 | ||
645 | mActionExport2phone->setEnabled( selected ); | 645 | mActionExport2phone->setEnabled( selected ); |
646 | mActionWhoAmI->setEnabled( selected ); | 646 | mActionWhoAmI->setEnabled( selected ); |
647 | mActionCategories->setEnabled( selected ); | 647 | mActionCategories->setEnabled( selected ); |
648 | } | 648 | } |
649 | 649 | ||
650 | void KABCore::sendMail() | 650 | void KABCore::sendMail() |
651 | { | 651 | { |
652 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 652 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
653 | } | 653 | } |
654 | 654 | ||
655 | void KABCore::sendMail( const QString& emaillist ) | 655 | void KABCore::sendMail( const QString& emaillist ) |
656 | { | 656 | { |
657 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 657 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
658 | if (emaillist.contains(",") > 0) | 658 | if (emaillist.contains(",") > 0) |
659 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 659 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
660 | else | 660 | else |
661 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 661 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
662 | } | 662 | } |
663 | 663 | ||
664 | 664 | ||
665 | 665 | ||
666 | void KABCore::mailVCard() | 666 | void KABCore::mailVCard() |
667 | { | 667 | { |
668 | QStringList uids = mViewManager->selectedUids(); | 668 | QStringList uids = mViewManager->selectedUids(); |
669 | if ( !uids.isEmpty() ) | 669 | if ( !uids.isEmpty() ) |
670 | mailVCard( uids ); | 670 | mailVCard( uids ); |
671 | } | 671 | } |
672 | 672 | ||
673 | void KABCore::mailVCard( const QStringList& uids ) | 673 | void KABCore::mailVCard( const QStringList& uids ) |
674 | { | 674 | { |
675 | QStringList urls; | 675 | QStringList urls; |
676 | 676 | ||
677 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 677 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
678 | 678 | ||
679 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 679 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
680 | 680 | ||
681 | 681 | ||
682 | 682 | ||
683 | QDir().mkdir( dirName, true ); | 683 | QDir().mkdir( dirName, true ); |
684 | 684 | ||
685 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 685 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
686 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 686 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
687 | 687 | ||
688 | if ( a.isEmpty() ) | 688 | if ( a.isEmpty() ) |
689 | continue; | 689 | continue; |
690 | 690 | ||
691 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 691 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
692 | 692 | ||
693 | QString fileName = dirName + "/" + name; | 693 | QString fileName = dirName + "/" + name; |
694 | 694 | ||
695 | QFile outFile(fileName); | 695 | QFile outFile(fileName); |
696 | 696 | ||
697 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 697 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
698 | KABC::VCardConverter converter; | 698 | KABC::VCardConverter converter; |
699 | QString vcard; | 699 | QString vcard; |
700 | 700 | ||
701 | converter.addresseeToVCard( a, vcard ); | 701 | converter.addresseeToVCard( a, vcard ); |
702 | 702 | ||
703 | QTextStream t( &outFile ); // use a text stream | 703 | QTextStream t( &outFile ); // use a text stream |
704 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 704 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
705 | t << vcard; | 705 | t << vcard; |
706 | 706 | ||
707 | outFile.close(); | 707 | outFile.close(); |
708 | 708 | ||
709 | urls.append( fileName ); | 709 | urls.append( fileName ); |
710 | } | 710 | } |
711 | } | 711 | } |
712 | 712 | ||
713 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 713 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
714 | 714 | ||
715 | 715 | ||
716 | /*US | 716 | /*US |
717 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 717 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
718 | QString::null, // subject | 718 | QString::null, // subject |
719 | QString::null, // body | 719 | QString::null, // body |
720 | QString::null, | 720 | QString::null, |
721 | urls ); // attachments | 721 | urls ); // attachments |
722 | */ | 722 | */ |
723 | 723 | ||
724 | } | 724 | } |
725 | 725 | ||
726 | /** | 726 | /** |
727 | Beams the "WhoAmI contact. | 727 | Beams the "WhoAmI contact. |
728 | */ | 728 | */ |
729 | void KABCore::beamMySelf() | 729 | void KABCore::beamMySelf() |
730 | { | 730 | { |
731 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 731 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
732 | if (!a.isEmpty()) | 732 | if (!a.isEmpty()) |
733 | { | 733 | { |
734 | QStringList uids; | 734 | QStringList uids; |
735 | uids << a.uid(); | 735 | uids << a.uid(); |
736 | 736 | ||
737 | beamVCard(uids); | 737 | beamVCard(uids); |
738 | } else { | 738 | } else { |
739 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 739 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
740 | 740 | ||
741 | 741 | ||
742 | } | 742 | } |
743 | } | 743 | } |
744 | 744 | ||
745 | void KABCore::export2phone() | 745 | void KABCore::export2phone() |
746 | { | 746 | { |
747 | 747 | ||
748 | KAex2phonePrefs ex2phone; | 748 | KAex2phonePrefs ex2phone; |
749 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 749 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
750 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 750 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
751 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 751 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
752 | 752 | ||
753 | if ( !ex2phone.exec() ) { | 753 | if ( !ex2phone.exec() ) { |
754 | return; | 754 | return; |
755 | } | 755 | } |
756 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 756 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
757 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 757 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
758 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 758 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
759 | 759 | ||
760 | 760 | ||
761 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 761 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
762 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 762 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
763 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 763 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
764 | 764 | ||
765 | QStringList uids = mViewManager->selectedUids(); | 765 | QStringList uids = mViewManager->selectedUids(); |
766 | if ( uids.isEmpty() ) | 766 | if ( uids.isEmpty() ) |
767 | return; | 767 | return; |
768 | 768 | ||
769 | QString fileName = getPhoneFile(); | 769 | QString fileName = getPhoneFile(); |
770 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 770 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
771 | return; | 771 | return; |
772 | 772 | ||
773 | message(i18n("Exporting to phone...")); | 773 | message(i18n("Exporting to phone...")); |
774 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 774 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
775 | 775 | ||
776 | } | 776 | } |
777 | QString KABCore::getPhoneFile() | 777 | QString KABCore::getPhoneFile() |
778 | { | 778 | { |
779 | #ifdef DESKTOP_VERSION | 779 | #ifdef DESKTOP_VERSION |
780 | return locateLocal("tmp", "phonefile.vcf"); | 780 | return locateLocal("tmp", "phonefile.vcf"); |
781 | #else | 781 | #else |
782 | return "/tmp/phonefile.vcf"; | 782 | return "/tmp/phonefile.vcf"; |
783 | #endif | 783 | #endif |
784 | 784 | ||
785 | } | 785 | } |
786 | void KABCore::writeToPhone( ) | 786 | void KABCore::writeToPhone( ) |
787 | { | 787 | { |
788 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 788 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
789 | message(i18n("Export to phone finished!")); | 789 | message(i18n("Export to phone finished!")); |
790 | else | 790 | else |
791 | qDebug(i18n("Error exporting to phone")); | 791 | qDebug(i18n("Error exporting to phone")); |
792 | } | 792 | } |
793 | void KABCore::beamVCard() | 793 | void KABCore::beamVCard() |
794 | { | 794 | { |
795 | QStringList uids = mViewManager->selectedUids(); | 795 | QStringList uids = mViewManager->selectedUids(); |
796 | if ( !uids.isEmpty() ) | 796 | if ( !uids.isEmpty() ) |
797 | beamVCard( uids ); | 797 | beamVCard( uids ); |
798 | } | 798 | } |
799 | 799 | ||
800 | 800 | ||
801 | void KABCore::beamVCard(const QStringList& uids) | 801 | void KABCore::beamVCard(const QStringList& uids) |
802 | { | 802 | { |
803 | 803 | ||
804 | // LR: we should use the /tmp dir on the Zaurus, | 804 | // LR: we should use the /tmp dir on the Zaurus, |
805 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 805 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
806 | 806 | ||
807 | #ifdef DESKTOP_VERSION | 807 | #ifdef DESKTOP_VERSION |
808 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 808 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
809 | #else | 809 | #else |
810 | QString fileName = "/tmp/kapibeamfile.vcf"; | 810 | QString fileName = "/tmp/kapibeamfile.vcf"; |
811 | #endif | 811 | #endif |
812 | 812 | ||
813 | KABC::VCardConverter converter; | 813 | KABC::VCardConverter converter; |
814 | QString description; | 814 | QString description; |
815 | QString datastream; | 815 | QString datastream; |
816 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 816 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
817 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 817 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
818 | 818 | ||
819 | if ( a.isEmpty() ) | 819 | if ( a.isEmpty() ) |
820 | continue; | 820 | continue; |
821 | 821 | ||
822 | if (description.isEmpty()) | 822 | if (description.isEmpty()) |
823 | description = a.formattedName(); | 823 | description = a.formattedName(); |
824 | 824 | ||
825 | QString vcard; | 825 | QString vcard; |
826 | converter.addresseeToVCard( a, vcard ); | 826 | converter.addresseeToVCard( a, vcard ); |
827 | int start = 0; | 827 | int start = 0; |
828 | int next; | 828 | int next; |
829 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 829 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
830 | int semi = vcard.find(";", next); | 830 | int semi = vcard.find(";", next); |
831 | int dopp = vcard.find(":", next); | 831 | int dopp = vcard.find(":", next); |
832 | int sep; | 832 | int sep; |
833 | if ( semi < dopp && semi >= 0 ) | 833 | if ( semi < dopp && semi >= 0 ) |
834 | sep = semi ; | 834 | sep = semi ; |
835 | else | 835 | else |
836 | sep = dopp; | 836 | sep = dopp; |
837 | datastream +=vcard.mid( start, next - start); | 837 | datastream +=vcard.mid( start, next - start); |
838 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 838 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
839 | start = sep; | 839 | start = sep; |
840 | } | 840 | } |
841 | datastream += vcard.mid( start,vcard.length() ); | 841 | datastream += vcard.mid( start,vcard.length() ); |
842 | } | 842 | } |
843 | #ifndef DESKTOP_VERSION | 843 | #ifndef DESKTOP_VERSION |
844 | QFile outFile(fileName); | 844 | QFile outFile(fileName); |
845 | if ( outFile.open(IO_WriteOnly) ) { | 845 | if ( outFile.open(IO_WriteOnly) ) { |
846 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 846 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
847 | QTextStream t( &outFile ); // use a text stream | 847 | QTextStream t( &outFile ); // use a text stream |
848 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 848 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
849 | t.setEncoding( QTextStream::Latin1 ); | 849 | t.setEncoding( QTextStream::Latin1 ); |
850 | t <<datastream.latin1(); | 850 | t <<datastream.latin1(); |
851 | outFile.close(); | 851 | outFile.close(); |
852 | Ir *ir = new Ir( this ); | 852 | Ir *ir = new Ir( this ); |
853 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 853 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
854 | ir->send( fileName, description, "text/x-vCard" ); | 854 | ir->send( fileName, description, "text/x-vCard" ); |
855 | } else { | 855 | } else { |
856 | qDebug("Error open temp beam file "); | 856 | qDebug("Error open temp beam file "); |
857 | return; | 857 | return; |
858 | } | 858 | } |
859 | #endif | 859 | #endif |
860 | 860 | ||
861 | } | 861 | } |
862 | 862 | ||
863 | void KABCore::beamDone( Ir *ir ) | 863 | void KABCore::beamDone( Ir *ir ) |
864 | { | 864 | { |
865 | #ifndef DESKTOP_VERSION | 865 | #ifndef DESKTOP_VERSION |
866 | delete ir; | 866 | delete ir; |
867 | #endif | 867 | #endif |
868 | topLevelWidget()->raise(); | 868 | topLevelWidget()->raise(); |
869 | message( i18n("Beaming finished!") ); | 869 | message( i18n("Beaming finished!") ); |
870 | } | 870 | } |
871 | 871 | ||
872 | 872 | ||
873 | void KABCore::browse( const QString& url ) | 873 | void KABCore::browse( const QString& url ) |
874 | { | 874 | { |
875 | #ifndef KAB_EMBEDDED | 875 | #ifndef KAB_EMBEDDED |
876 | kapp->invokeBrowser( url ); | 876 | kapp->invokeBrowser( url ); |
877 | #else //KAB_EMBEDDED | 877 | #else //KAB_EMBEDDED |
878 | qDebug("KABCore::browse must be fixed"); | 878 | qDebug("KABCore::browse must be fixed"); |
879 | #endif //KAB_EMBEDDED | 879 | #endif //KAB_EMBEDDED |
880 | } | 880 | } |
881 | 881 | ||
882 | void KABCore::selectAllContacts() | 882 | void KABCore::selectAllContacts() |
883 | { | 883 | { |
884 | mViewManager->setSelected( QString::null, true ); | 884 | mViewManager->setSelected( QString::null, true ); |
885 | } | 885 | } |
886 | 886 | ||
887 | void KABCore::deleteContacts() | 887 | void KABCore::deleteContacts() |
888 | { | 888 | { |
889 | QStringList uidList = mViewManager->selectedUids(); | 889 | QStringList uidList = mViewManager->selectedUids(); |
890 | deleteContacts( uidList ); | 890 | deleteContacts( uidList ); |
891 | } | 891 | } |
892 | 892 | ||
893 | void KABCore::deleteContacts( const QStringList &uids ) | 893 | void KABCore::deleteContacts( const QStringList &uids ) |
894 | { | 894 | { |
895 | if ( uids.count() > 0 ) { | 895 | if ( uids.count() > 0 ) { |
896 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 896 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
897 | UndoStack::instance()->push( command ); | 897 | UndoStack::instance()->push( command ); |
898 | RedoStack::instance()->clear(); | 898 | RedoStack::instance()->clear(); |
899 | 899 | ||
900 | // now if we deleted anything, refresh | 900 | // now if we deleted anything, refresh |
901 | setContactSelected( QString::null ); | 901 | setContactSelected( QString::null ); |
902 | setModified( true ); | 902 | setModified( true ); |
903 | } | 903 | } |
904 | } | 904 | } |
905 | 905 | ||
906 | void KABCore::copyContacts() | 906 | void KABCore::copyContacts() |
907 | { | 907 | { |
908 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 908 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
909 | 909 | ||
910 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 910 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
911 | 911 | ||
912 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 912 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
913 | 913 | ||
914 | QClipboard *cb = QApplication::clipboard(); | 914 | QClipboard *cb = QApplication::clipboard(); |
915 | cb->setText( clipText ); | 915 | cb->setText( clipText ); |
916 | } | 916 | } |
917 | 917 | ||
918 | void KABCore::cutContacts() | 918 | void KABCore::cutContacts() |
919 | { | 919 | { |
920 | QStringList uidList = mViewManager->selectedUids(); | 920 | QStringList uidList = mViewManager->selectedUids(); |
921 | 921 | ||
922 | //US if ( uidList.size() > 0 ) { | 922 | //US if ( uidList.size() > 0 ) { |
923 | if ( uidList.count() > 0 ) { | 923 | if ( uidList.count() > 0 ) { |
924 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 924 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
925 | UndoStack::instance()->push( command ); | 925 | UndoStack::instance()->push( command ); |
926 | RedoStack::instance()->clear(); | 926 | RedoStack::instance()->clear(); |
927 | 927 | ||
928 | setModified( true ); | 928 | setModified( true ); |
929 | } | 929 | } |
930 | } | 930 | } |
931 | 931 | ||
932 | void KABCore::pasteContacts() | 932 | void KABCore::pasteContacts() |
933 | { | 933 | { |
934 | QClipboard *cb = QApplication::clipboard(); | 934 | QClipboard *cb = QApplication::clipboard(); |
935 | 935 | ||
936 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 936 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
937 | 937 | ||
938 | pasteContacts( list ); | 938 | pasteContacts( list ); |
939 | } | 939 | } |
940 | 940 | ||
941 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 941 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
942 | { | 942 | { |
943 | KABC::Resource *resource = requestResource( this ); | 943 | KABC::Resource *resource = requestResource( this ); |
944 | KABC::Addressee::List::Iterator it; | 944 | KABC::Addressee::List::Iterator it; |
945 | for ( it = list.begin(); it != list.end(); ++it ) | 945 | for ( it = list.begin(); it != list.end(); ++it ) |
946 | (*it).setResource( resource ); | 946 | (*it).setResource( resource ); |
947 | 947 | ||
948 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 948 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
949 | UndoStack::instance()->push( command ); | 949 | UndoStack::instance()->push( command ); |
950 | RedoStack::instance()->clear(); | 950 | RedoStack::instance()->clear(); |
951 | 951 | ||
952 | setModified( true ); | 952 | setModified( true ); |
953 | } | 953 | } |
954 | 954 | ||
955 | void KABCore::setWhoAmI() | 955 | void KABCore::setWhoAmI() |
956 | { | 956 | { |
957 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 957 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
958 | 958 | ||
959 | if ( addrList.count() > 1 ) { | 959 | if ( addrList.count() > 1 ) { |
960 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 960 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
961 | return; | 961 | return; |
962 | } | 962 | } |
963 | 963 | ||
964 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 964 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
965 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 965 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
966 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 966 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
967 | } | 967 | } |
968 | 968 | ||
969 | void KABCore::setCategories() | 969 | void KABCore::setCategories() |
970 | { | 970 | { |
971 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 971 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
972 | if ( !dlg.exec() ) | 972 | if ( !dlg.exec() ) |
973 | return; | 973 | return; |
974 | 974 | ||
975 | bool merge = false; | 975 | bool merge = false; |
976 | QString msg = i18n( "Merge with existing categories?" ); | 976 | QString msg = i18n( "Merge with existing categories?" ); |
977 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 977 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
978 | merge = true; | 978 | merge = true; |
979 | 979 | ||
980 | QStringList categories = dlg.selectedCategories(); | 980 | QStringList categories = dlg.selectedCategories(); |
981 | 981 | ||
982 | QStringList uids = mViewManager->selectedUids(); | 982 | QStringList uids = mViewManager->selectedUids(); |
983 | QStringList::Iterator it; | 983 | QStringList::Iterator it; |
984 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 984 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
985 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 985 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
986 | if ( !addr.isEmpty() ) { | 986 | if ( !addr.isEmpty() ) { |
987 | if ( !merge ) | 987 | if ( !merge ) |
988 | addr.setCategories( categories ); | 988 | addr.setCategories( categories ); |
989 | else { | 989 | else { |
990 | QStringList addrCategories = addr.categories(); | 990 | QStringList addrCategories = addr.categories(); |
991 | QStringList::Iterator catIt; | 991 | QStringList::Iterator catIt; |
992 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 992 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
993 | if ( !addrCategories.contains( *catIt ) ) | 993 | if ( !addrCategories.contains( *catIt ) ) |
994 | addrCategories.append( *catIt ); | 994 | addrCategories.append( *catIt ); |
995 | } | 995 | } |
996 | addr.setCategories( addrCategories ); | 996 | addr.setCategories( addrCategories ); |
997 | } | 997 | } |
998 | 998 | ||
999 | mAddressBook->insertAddressee( addr ); | 999 | mAddressBook->insertAddressee( addr ); |
1000 | } | 1000 | } |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | if ( uids.count() > 0 ) | 1003 | if ( uids.count() > 0 ) |
1004 | setModified( true ); | 1004 | setModified( true ); |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1007 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1008 | { | 1008 | { |
1009 | mIncSearchWidget->setFields( fields ); | 1009 | mIncSearchWidget->setFields( fields ); |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | void KABCore::incrementalSearch( const QString& text ) | 1012 | void KABCore::incrementalSearch( const QString& text ) |
1013 | { | 1013 | { |
1014 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1014 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | void KABCore::setModified() | 1017 | void KABCore::setModified() |
1018 | { | 1018 | { |
1019 | setModified( true ); | 1019 | setModified( true ); |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | void KABCore::setModifiedWOrefresh() | 1022 | void KABCore::setModifiedWOrefresh() |
1023 | { | 1023 | { |
1024 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1024 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1025 | mModified = true; | 1025 | mModified = true; |
1026 | mActionSave->setEnabled( mModified ); | 1026 | mActionSave->setEnabled( mModified ); |
1027 | #ifdef DESKTOP_VERSION | 1027 | #ifdef DESKTOP_VERSION |
1028 | mDetails->refreshView(); | 1028 | mDetails->refreshView(); |
1029 | #endif | 1029 | #endif |
1030 | 1030 | ||
1031 | } | 1031 | } |
1032 | void KABCore::setModified( bool modified ) | 1032 | void KABCore::setModified( bool modified ) |
1033 | { | 1033 | { |
1034 | mModified = modified; | 1034 | mModified = modified; |
1035 | mActionSave->setEnabled( mModified ); | 1035 | mActionSave->setEnabled( mModified ); |
1036 | 1036 | ||
1037 | if ( modified ) | 1037 | if ( modified ) |
1038 | mJumpButtonBar->recreateButtons(); | 1038 | mJumpButtonBar->recreateButtons(); |
1039 | 1039 | ||
1040 | mViewManager->refreshView(); | 1040 | mViewManager->refreshView(); |
1041 | mDetails->refreshView(); | 1041 | mDetails->refreshView(); |
1042 | 1042 | ||
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | bool KABCore::modified() const | 1045 | bool KABCore::modified() const |
1046 | { | 1046 | { |
1047 | return mModified; | 1047 | return mModified; |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1050 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1051 | { | 1051 | { |
1052 | 1052 | ||
1053 | Command *command = 0; | 1053 | Command *command = 0; |
1054 | QString uid; | 1054 | QString uid; |
1055 | 1055 | ||
1056 | // check if it exists already | 1056 | // check if it exists already |
1057 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1057 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1058 | if ( origAddr.isEmpty() ) | 1058 | if ( origAddr.isEmpty() ) |
1059 | command = new PwNewCommand( mAddressBook, addr ); | 1059 | command = new PwNewCommand( mAddressBook, addr ); |
1060 | else { | 1060 | else { |
1061 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1061 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1062 | uid = addr.uid(); | 1062 | uid = addr.uid(); |
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | UndoStack::instance()->push( command ); | 1065 | UndoStack::instance()->push( command ); |
1066 | RedoStack::instance()->clear(); | 1066 | RedoStack::instance()->clear(); |
1067 | 1067 | ||
1068 | setModified( true ); | 1068 | setModified( true ); |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | void KABCore::newContact() | 1071 | void KABCore::newContact() |
1072 | { | 1072 | { |
1073 | 1073 | ||
1074 | 1074 | ||
1075 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1075 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1076 | 1076 | ||
1077 | QPtrList<KRES::Resource> kresResources; | 1077 | QPtrList<KRES::Resource> kresResources; |
1078 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1078 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1079 | KABC::Resource *resource; | 1079 | KABC::Resource *resource; |
1080 | while ( ( resource = it.current() ) != 0 ) { | 1080 | while ( ( resource = it.current() ) != 0 ) { |
1081 | ++it; | 1081 | ++it; |
1082 | if ( !resource->readOnly() ) { | 1082 | if ( !resource->readOnly() ) { |
1083 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1083 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1084 | if ( res ) | 1084 | if ( res ) |
1085 | kresResources.append( res ); | 1085 | kresResources.append( res ); |
1086 | } | 1086 | } |
1087 | } | 1087 | } |
1088 | 1088 | ||
1089 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1089 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1090 | resource = static_cast<KABC::Resource*>( res ); | 1090 | resource = static_cast<KABC::Resource*>( res ); |
1091 | 1091 | ||
1092 | if ( resource ) { | 1092 | if ( resource ) { |
1093 | KABC::Addressee addr; | 1093 | KABC::Addressee addr; |
1094 | addr.setResource( resource ); | 1094 | addr.setResource( resource ); |
1095 | mEditorDialog->setAddressee( addr ); | 1095 | mEditorDialog->setAddressee( addr ); |
1096 | KApplication::execDialog ( mEditorDialog ); | 1096 | KApplication::execDialog ( mEditorDialog ); |
1097 | 1097 | ||
1098 | } else | 1098 | } else |
1099 | return; | 1099 | return; |
1100 | 1100 | ||
1101 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1101 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1102 | 1102 | ||
1103 | 1103 | ||
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | void KABCore::addEmail( QString aStr ) | 1106 | void KABCore::addEmail( QString aStr ) |
1107 | { | 1107 | { |
1108 | #ifndef KAB_EMBEDDED | 1108 | #ifndef KAB_EMBEDDED |
1109 | QString fullName, email; | 1109 | QString fullName, email; |
1110 | 1110 | ||
1111 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1111 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1112 | 1112 | ||
1113 | // Try to lookup the addressee matching the email address | 1113 | // Try to lookup the addressee matching the email address |
1114 | bool found = false; | 1114 | bool found = false; |
1115 | QStringList emailList; | 1115 | QStringList emailList; |
1116 | KABC::AddressBook::Iterator it; | 1116 | KABC::AddressBook::Iterator it; |
1117 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1117 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1118 | emailList = (*it).emails(); | 1118 | emailList = (*it).emails(); |
1119 | if ( emailList.contains( email ) > 0 ) { | 1119 | if ( emailList.contains( email ) > 0 ) { |
1120 | found = true; | 1120 | found = true; |
1121 | (*it).setNameFromString( fullName ); | 1121 | (*it).setNameFromString( fullName ); |
1122 | editContact( (*it).uid() ); | 1122 | editContact( (*it).uid() ); |
1123 | } | 1123 | } |
1124 | } | 1124 | } |
1125 | 1125 | ||
1126 | if ( !found ) { | 1126 | if ( !found ) { |
1127 | KABC::Addressee addr; | 1127 | KABC::Addressee addr; |
1128 | addr.setNameFromString( fullName ); | 1128 | addr.setNameFromString( fullName ); |
1129 | addr.insertEmail( email, true ); | 1129 | addr.insertEmail( email, true ); |
1130 | 1130 | ||
1131 | mAddressBook->insertAddressee( addr ); | 1131 | mAddressBook->insertAddressee( addr ); |
1132 | mViewManager->refreshView( addr.uid() ); | 1132 | mViewManager->refreshView( addr.uid() ); |
1133 | editContact( addr.uid() ); | 1133 | editContact( addr.uid() ); |
1134 | } | 1134 | } |
1135 | #else //KAB_EMBEDDED | 1135 | #else //KAB_EMBEDDED |
1136 | qDebug("KABCore::addEmail finsih method"); | 1136 | qDebug("KABCore::addEmail finsih method"); |
1137 | #endif //KAB_EMBEDDED | 1137 | #endif //KAB_EMBEDDED |
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1140 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1141 | { | 1141 | { |
1142 | mXXPortManager->importVCard( url, showPreview ); | 1142 | mXXPortManager->importVCard( url, showPreview ); |
1143 | } | 1143 | } |
1144 | void KABCore::importFromOL() | 1144 | void KABCore::importFromOL() |
1145 | { | 1145 | { |
1146 | #ifdef _WIN32_ | 1146 | #ifdef _WIN32_ |
1147 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1147 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1148 | idgl->exec(); | 1148 | idgl->exec(); |
1149 | KABC::Addressee::List list = idgl->getAddressList(); | 1149 | KABC::Addressee::List list = idgl->getAddressList(); |
1150 | if ( list.count() > 0 ) { | 1150 | if ( list.count() > 0 ) { |
1151 | KABC::Addressee::List listNew; | 1151 | KABC::Addressee::List listNew; |
1152 | KABC::Addressee::List listExisting; | 1152 | KABC::Addressee::List listExisting; |
1153 | KABC::Addressee::List::Iterator it; | 1153 | KABC::Addressee::List::Iterator it; |
1154 | KABC::AddressBook::Iterator iter; | 1154 | KABC::AddressBook::Iterator iter; |
1155 | for ( it = list.begin(); it != list.end(); ++it ) { | 1155 | for ( it = list.begin(); it != list.end(); ++it ) { |
1156 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1156 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1157 | listNew.append( (*it) ); | 1157 | listNew.append( (*it) ); |
1158 | else | 1158 | else |
1159 | listExisting.append( (*it) ); | 1159 | listExisting.append( (*it) ); |
1160 | } | 1160 | } |
1161 | if ( listExisting.count() > 0 ) | 1161 | if ( listExisting.count() > 0 ) |
1162 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1162 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1163 | if ( listNew.count() > 0 ) { | 1163 | if ( listNew.count() > 0 ) { |
1164 | pasteWithNewUid = false; | 1164 | pasteWithNewUid = false; |
1165 | pasteContacts( listNew ); | 1165 | pasteContacts( listNew ); |
1166 | pasteWithNewUid = true; | 1166 | pasteWithNewUid = true; |
1167 | } | 1167 | } |
1168 | } | 1168 | } |
1169 | delete idgl; | 1169 | delete idgl; |
1170 | #endif | 1170 | #endif |
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1173 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1174 | { | 1174 | { |
1175 | mXXPortManager->importVCard( vCard, showPreview ); | 1175 | mXXPortManager->importVCard( vCard, showPreview ); |
1176 | } | 1176 | } |
1177 | 1177 | ||
1178 | //US added a second method without defaultparameter | 1178 | //US added a second method without defaultparameter |
1179 | void KABCore::editContact2() { | 1179 | void KABCore::editContact2() { |
1180 | editContact( QString::null ); | 1180 | editContact( QString::null ); |
1181 | } | 1181 | } |
1182 | 1182 | ||
1183 | void KABCore::editContact( const QString &uid ) | 1183 | void KABCore::editContact( const QString &uid ) |
1184 | { | 1184 | { |
1185 | 1185 | ||
1186 | if ( mExtensionManager->isQuickEditVisible() ) | 1186 | if ( mExtensionManager->isQuickEditVisible() ) |
1187 | return; | 1187 | return; |
1188 | 1188 | ||
1189 | // First, locate the contact entry | 1189 | // First, locate the contact entry |
1190 | QString localUID = uid; | 1190 | QString localUID = uid; |
1191 | if ( localUID.isNull() ) { | 1191 | if ( localUID.isNull() ) { |
1192 | QStringList uidList = mViewManager->selectedUids(); | 1192 | QStringList uidList = mViewManager->selectedUids(); |
1193 | if ( uidList.count() > 0 ) | 1193 | if ( uidList.count() > 0 ) |
1194 | localUID = *( uidList.at( 0 ) ); | 1194 | localUID = *( uidList.at( 0 ) ); |
1195 | } | 1195 | } |
1196 | 1196 | ||
1197 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1197 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1198 | if ( !addr.isEmpty() ) { | 1198 | if ( !addr.isEmpty() ) { |
1199 | mEditorDialog->setAddressee( addr ); | 1199 | mEditorDialog->setAddressee( addr ); |
1200 | KApplication::execDialog ( mEditorDialog ); | 1200 | KApplication::execDialog ( mEditorDialog ); |
1201 | } | 1201 | } |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | /** | 1204 | /** |
1205 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1205 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1206 | the method will try to find a selected addressee in the view. | 1206 | the method will try to find a selected addressee in the view. |
1207 | */ | 1207 | */ |
1208 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1208 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1209 | { | 1209 | { |
1210 | if ( mMultipleViewsAtOnce ) | 1210 | if ( mMultipleViewsAtOnce ) |
1211 | { | 1211 | { |
1212 | editContact( uid ); | 1212 | editContact( uid ); |
1213 | } | 1213 | } |
1214 | else | 1214 | else |
1215 | { | 1215 | { |
1216 | setDetailsVisible( true ); | 1216 | setDetailsVisible( true ); |
1217 | mActionDetails->setChecked(true); | 1217 | mActionDetails->setChecked(true); |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | } | 1220 | } |
1221 | 1221 | ||
1222 | void KABCore::save() | 1222 | void KABCore::save() |
1223 | { | 1223 | { |
1224 | if (syncManager->blockSave()) | 1224 | if (syncManager->blockSave()) |
1225 | return; | 1225 | return; |
1226 | if ( !mModified ) | 1226 | if ( !mModified ) |
1227 | return; | 1227 | return; |
1228 | 1228 | ||
1229 | syncManager->setBlockSave(true); | 1229 | syncManager->setBlockSave(true); |
1230 | QString text = i18n( "There was an error while attempting to save\n the " | 1230 | QString text = i18n( "There was an error while attempting to save\n the " |
1231 | "address book. Please check that some \nother application is " | 1231 | "address book. Please check that some \nother application is " |
1232 | "not using it. " ); | 1232 | "not using it. " ); |
1233 | message(i18n("Saving addressbook ... ")); | 1233 | message(i18n("Saving addressbook ... ")); |
1234 | #ifndef KAB_EMBEDDED | 1234 | #ifndef KAB_EMBEDDED |
1235 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1235 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1236 | if ( !b || !b->save() ) { | 1236 | if ( !b || !b->save() ) { |
1237 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1237 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1238 | } | 1238 | } |
1239 | #else //KAB_EMBEDDED | 1239 | #else //KAB_EMBEDDED |
1240 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1240 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1241 | if ( !b || !b->save() ) { | 1241 | if ( !b || !b->save() ) { |
1242 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1242 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1243 | } | 1243 | } |
1244 | #endif //KAB_EMBEDDED | 1244 | #endif //KAB_EMBEDDED |
1245 | 1245 | ||
1246 | message(i18n("Addressbook saved!")); | 1246 | message(i18n("Addressbook saved!")); |
1247 | setModified( false ); | 1247 | setModified( false ); |
1248 | syncManager->setBlockSave(false); | 1248 | syncManager->setBlockSave(false); |
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | 1251 | ||
1252 | void KABCore::undo() | 1252 | void KABCore::undo() |
1253 | { | 1253 | { |
1254 | UndoStack::instance()->undo(); | 1254 | UndoStack::instance()->undo(); |
1255 | 1255 | ||
1256 | // Refresh the view | 1256 | // Refresh the view |
1257 | mViewManager->refreshView(); | 1257 | mViewManager->refreshView(); |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | void KABCore::redo() | 1260 | void KABCore::redo() |
1261 | { | 1261 | { |
1262 | RedoStack::instance()->redo(); | 1262 | RedoStack::instance()->redo(); |
1263 | 1263 | ||
1264 | // Refresh the view | 1264 | // Refresh the view |
1265 | mViewManager->refreshView(); | 1265 | mViewManager->refreshView(); |
1266 | } | 1266 | } |
1267 | 1267 | ||
1268 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1268 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1269 | { | 1269 | { |
1270 | if (mMultipleViewsAtOnce) | 1270 | if (mMultipleViewsAtOnce) |
1271 | { | 1271 | { |
1272 | if ( visible ) | 1272 | if ( visible ) |
1273 | mJumpButtonBar->show(); | 1273 | mJumpButtonBar->show(); |
1274 | else | 1274 | else |
1275 | mJumpButtonBar->hide(); | 1275 | mJumpButtonBar->hide(); |
1276 | } | 1276 | } |
1277 | else | 1277 | else |
1278 | { | 1278 | { |
1279 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1279 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1280 | if (mViewManager->isVisible()) | 1280 | if (mViewManager->isVisible()) |
1281 | { | 1281 | { |
1282 | if ( visible ) | 1282 | if ( visible ) |
1283 | mJumpButtonBar->show(); | 1283 | mJumpButtonBar->show(); |
1284 | else | 1284 | else |
1285 | mJumpButtonBar->hide(); | 1285 | mJumpButtonBar->hide(); |
1286 | } | 1286 | } |
1287 | else | 1287 | else |
1288 | { | 1288 | { |
1289 | mJumpButtonBar->hide(); | 1289 | mJumpButtonBar->hide(); |
1290 | } | 1290 | } |
1291 | } | 1291 | } |
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | 1294 | ||
1295 | void KABCore::setDetailsToState() | 1295 | void KABCore::setDetailsToState() |
1296 | { | 1296 | { |
1297 | setDetailsVisible( mActionDetails->isChecked() ); | 1297 | setDetailsVisible( mActionDetails->isChecked() ); |
1298 | } | 1298 | } |
1299 | void KABCore::setDetailsToggle() | 1299 | void KABCore::setDetailsToggle() |
1300 | { | 1300 | { |
1301 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1301 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1302 | setDetailsToState(); | 1302 | setDetailsToState(); |
1303 | } | 1303 | } |
1304 | 1304 | ||
1305 | 1305 | ||
1306 | 1306 | ||
1307 | void KABCore::setDetailsVisible( bool visible ) | 1307 | void KABCore::setDetailsVisible( bool visible ) |
1308 | { | 1308 | { |
1309 | if (visible && mDetails->isHidden()) | 1309 | if (visible && mDetails->isHidden()) |
1310 | { | 1310 | { |
1311 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1311 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1312 | if ( addrList.count() > 0 ) | 1312 | if ( addrList.count() > 0 ) |
1313 | mDetails->setAddressee( addrList[ 0 ] ); | 1313 | mDetails->setAddressee( addrList[ 0 ] ); |
1314 | } | 1314 | } |
1315 | 1315 | ||
1316 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1316 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1317 | // the listview and the detailview. We do that by changing the splitbar size. | 1317 | // the listview and the detailview. We do that by changing the splitbar size. |
1318 | if (mMultipleViewsAtOnce) | 1318 | if (mMultipleViewsAtOnce) |
1319 | { | 1319 | { |
1320 | if ( visible ) | 1320 | if ( visible ) |
1321 | mDetails->show(); | 1321 | mDetails->show(); |
1322 | else | 1322 | else |
1323 | mDetails->hide(); | 1323 | mDetails->hide(); |
1324 | } | 1324 | } |
1325 | else | 1325 | else |
1326 | { | 1326 | { |
1327 | if ( visible ) { | 1327 | if ( visible ) { |
1328 | mViewManager->hide(); | 1328 | mViewManager->hide(); |
1329 | mDetails->show(); | 1329 | mDetails->show(); |
1330 | mIncSearchWidget->setFocus(); | 1330 | mIncSearchWidget->setFocus(); |
1331 | } | 1331 | } |
1332 | else { | 1332 | else { |
1333 | mViewManager->show(); | 1333 | mViewManager->show(); |
1334 | mDetails->hide(); | 1334 | mDetails->hide(); |
1335 | mViewManager->setFocusAV(); | 1335 | mViewManager->setFocusAV(); |
1336 | } | 1336 | } |
1337 | setJumpButtonBarVisible( !visible ); | 1337 | setJumpButtonBarVisible( !visible ); |
1338 | } | 1338 | } |
1339 | 1339 | ||
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | void KABCore::extensionChanged( int id ) | 1342 | void KABCore::extensionChanged( int id ) |
1343 | { | 1343 | { |
1344 | //change the details view only for non desktop systems | 1344 | //change the details view only for non desktop systems |
1345 | #ifndef DESKTOP_VERSION | 1345 | #ifndef DESKTOP_VERSION |
1346 | 1346 | ||
1347 | if (id == 0) | 1347 | if (id == 0) |
1348 | { | 1348 | { |
1349 | //the user disabled the extension. | 1349 | //the user disabled the extension. |
1350 | 1350 | ||
1351 | if (mMultipleViewsAtOnce) | 1351 | if (mMultipleViewsAtOnce) |
1352 | { // enable detailsview again | 1352 | { // enable detailsview again |
1353 | setDetailsVisible( true ); | 1353 | setDetailsVisible( true ); |
1354 | mActionDetails->setChecked( true ); | 1354 | mActionDetails->setChecked( true ); |
1355 | } | 1355 | } |
1356 | else | 1356 | else |
1357 | { //go back to the listview | 1357 | { //go back to the listview |
1358 | setDetailsVisible( false ); | 1358 | setDetailsVisible( false ); |
1359 | mActionDetails->setChecked( false ); | 1359 | mActionDetails->setChecked( false ); |
1360 | mActionDetails->setEnabled(true); | 1360 | mActionDetails->setEnabled(true); |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | } | 1363 | } |
1364 | else | 1364 | else |
1365 | { | 1365 | { |
1366 | //the user enabled the extension. | 1366 | //the user enabled the extension. |
1367 | setDetailsVisible( false ); | 1367 | setDetailsVisible( false ); |
1368 | mActionDetails->setChecked( false ); | 1368 | mActionDetails->setChecked( false ); |
1369 | 1369 | ||
1370 | if (!mMultipleViewsAtOnce) | 1370 | if (!mMultipleViewsAtOnce) |
1371 | { | 1371 | { |
1372 | mActionDetails->setEnabled(false); | 1372 | mActionDetails->setEnabled(false); |
1373 | } | 1373 | } |
1374 | 1374 | ||
1375 | mExtensionManager->setSelectionChanged(); | 1375 | mExtensionManager->setSelectionChanged(); |
1376 | 1376 | ||
1377 | } | 1377 | } |
1378 | 1378 | ||
1379 | #endif// DESKTOP_VERSION | 1379 | #endif// DESKTOP_VERSION |
1380 | 1380 | ||
1381 | } | 1381 | } |
1382 | 1382 | ||
1383 | 1383 | ||
1384 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1384 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1385 | { | 1385 | { |
1386 | 1386 | ||
1387 | if ( list.count() != 0 ) { | 1387 | if ( list.count() != 0 ) { |
1388 | KABC::Addressee::List::ConstIterator it; | 1388 | KABC::Addressee::List::ConstIterator it; |
1389 | for ( it = list.begin(); it != list.end(); ++it ) | 1389 | for ( it = list.begin(); it != list.end(); ++it ) |
1390 | mAddressBook->insertAddressee( *it ); | 1390 | mAddressBook->insertAddressee( *it ); |
1391 | if ( list.count() > 1 ) | 1391 | if ( list.count() > 1 ) |
1392 | setModified(); | 1392 | setModified(); |
1393 | else | 1393 | else |
1394 | setModifiedWOrefresh(); | 1394 | setModifiedWOrefresh(); |
1395 | } | 1395 | } |
1396 | if ( list.count() == 0 ) | 1396 | if ( list.count() == 0 ) |
1397 | mViewManager->refreshView(); | 1397 | mViewManager->refreshView(); |
1398 | else | 1398 | else |
1399 | mViewManager->refreshView( list[ 0 ].uid() ); | 1399 | mViewManager->refreshView( list[ 0 ].uid() ); |
1400 | 1400 | ||
1401 | 1401 | ||
1402 | 1402 | ||
1403 | } | 1403 | } |
1404 | 1404 | ||
1405 | QString KABCore::getNameByPhone( const QString &phone ) | 1405 | QString KABCore::getNameByPhone( const QString &phone ) |
1406 | { | 1406 | { |
1407 | #ifndef KAB_EMBEDDED | 1407 | #ifndef KAB_EMBEDDED |
1408 | QRegExp r( "[/*/-/ ]" ); | 1408 | QRegExp r( "[/*/-/ ]" ); |
1409 | QString localPhone( phone ); | 1409 | QString localPhone( phone ); |
1410 | 1410 | ||
1411 | bool found = false; | 1411 | bool found = false; |
1412 | QString ownerName = ""; | 1412 | QString ownerName = ""; |
1413 | KABC::AddressBook::Iterator iter; | 1413 | KABC::AddressBook::Iterator iter; |
1414 | KABC::PhoneNumber::List::Iterator phoneIter; | 1414 | KABC::PhoneNumber::List::Iterator phoneIter; |
1415 | KABC::PhoneNumber::List phoneList; | 1415 | KABC::PhoneNumber::List phoneList; |
1416 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1416 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1417 | phoneList = (*iter).phoneNumbers(); | 1417 | phoneList = (*iter).phoneNumbers(); |
1418 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1418 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1419 | ++phoneIter) { | 1419 | ++phoneIter) { |
1420 | // Get rid of separator chars so just the numbers are compared. | 1420 | // Get rid of separator chars so just the numbers are compared. |
1421 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1421 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1422 | ownerName = (*iter).formattedName(); | 1422 | ownerName = (*iter).formattedName(); |
1423 | found = true; | 1423 | found = true; |
1424 | } | 1424 | } |
1425 | } | 1425 | } |
1426 | } | 1426 | } |
1427 | 1427 | ||
1428 | return ownerName; | 1428 | return ownerName; |
1429 | #else //KAB_EMBEDDED | 1429 | #else //KAB_EMBEDDED |
1430 | qDebug("KABCore::getNameByPhone finsih method"); | 1430 | qDebug("KABCore::getNameByPhone finsih method"); |
1431 | return ""; | 1431 | return ""; |
1432 | #endif //KAB_EMBEDDED | 1432 | #endif //KAB_EMBEDDED |
1433 | 1433 | ||
1434 | } | 1434 | } |
1435 | 1435 | ||
1436 | void KABCore::openConfigDialog() | 1436 | void KABCore::openConfigDialog() |
1437 | { | 1437 | { |
1438 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1438 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1439 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1439 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1440 | ConfigureDialog->addModule(kabcfg ); | 1440 | ConfigureDialog->addModule(kabcfg ); |
1441 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1441 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1442 | ConfigureDialog->addModule(kdelibcfg ); | 1442 | ConfigureDialog->addModule(kdelibcfg ); |
1443 | 1443 | ||
1444 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1444 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1445 | this, SLOT( configurationChanged() ) ); | 1445 | this, SLOT( configurationChanged() ) ); |
1446 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1446 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1447 | this, SLOT( configurationChanged() ) ); | 1447 | this, SLOT( configurationChanged() ) ); |
1448 | saveSettings(); | 1448 | saveSettings(); |
1449 | #ifndef DESKTOP_VERSION | 1449 | #ifndef DESKTOP_VERSION |
1450 | ConfigureDialog->showMaximized(); | 1450 | ConfigureDialog->showMaximized(); |
1451 | #endif | 1451 | #endif |
1452 | if ( ConfigureDialog->exec() ) | 1452 | if ( ConfigureDialog->exec() ) |
1453 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1453 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1454 | delete ConfigureDialog; | 1454 | delete ConfigureDialog; |
1455 | } | 1455 | } |
1456 | 1456 | ||
1457 | void KABCore::openLDAPDialog() | 1457 | void KABCore::openLDAPDialog() |
1458 | { | 1458 | { |
1459 | #ifndef KAB_EMBEDDED | 1459 | #ifndef KAB_EMBEDDED |
1460 | if ( !mLdapSearchDialog ) { | 1460 | if ( !mLdapSearchDialog ) { |
1461 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1461 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1462 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1462 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1463 | SLOT( refreshView() ) ); | 1463 | SLOT( refreshView() ) ); |
1464 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1464 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1465 | SLOT( setModified() ) ); | 1465 | SLOT( setModified() ) ); |
1466 | } else | 1466 | } else |
1467 | mLdapSearchDialog->restoreSettings(); | 1467 | mLdapSearchDialog->restoreSettings(); |
1468 | 1468 | ||
1469 | if ( mLdapSearchDialog->isOK() ) | 1469 | if ( mLdapSearchDialog->isOK() ) |
1470 | mLdapSearchDialog->exec(); | 1470 | mLdapSearchDialog->exec(); |
1471 | #else //KAB_EMBEDDED | 1471 | #else //KAB_EMBEDDED |
1472 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1472 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1473 | #endif //KAB_EMBEDDED | 1473 | #endif //KAB_EMBEDDED |
1474 | } | 1474 | } |
1475 | 1475 | ||
1476 | void KABCore::print() | 1476 | void KABCore::print() |
1477 | { | 1477 | { |
1478 | #ifndef KAB_EMBEDDED | 1478 | #ifndef KAB_EMBEDDED |
1479 | KPrinter printer; | 1479 | KPrinter printer; |
1480 | if ( !printer.setup( this ) ) | 1480 | if ( !printer.setup( this ) ) |
1481 | return; | 1481 | return; |
1482 | 1482 | ||
1483 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1483 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1484 | mViewManager->selectedUids(), this ); | 1484 | mViewManager->selectedUids(), this ); |
1485 | 1485 | ||
1486 | wizard.exec(); | 1486 | wizard.exec(); |
1487 | #else //KAB_EMBEDDED | 1487 | #else //KAB_EMBEDDED |
1488 | qDebug("KABCore::print() finsih method"); | 1488 | qDebug("KABCore::print() finsih method"); |
1489 | #endif //KAB_EMBEDDED | 1489 | #endif //KAB_EMBEDDED |
1490 | 1490 | ||
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | 1493 | ||
1494 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1494 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1495 | { | 1495 | { |
1496 | if ( mGUIClient ) | 1496 | if ( mGUIClient ) |
1497 | mGUIClient->insertChildClient( client ); | 1497 | mGUIClient->insertChildClient( client ); |
1498 | else | 1498 | else |
1499 | KMessageBox::error( this, "no KXMLGUICLient"); | 1499 | KMessageBox::error( this, "no KXMLGUICLient"); |
1500 | } | 1500 | } |
1501 | 1501 | ||
1502 | 1502 | ||
1503 | void KABCore::configurationChanged() | 1503 | void KABCore::configurationChanged() |
1504 | { | 1504 | { |
1505 | mExtensionManager->reconfigure(); | 1505 | mExtensionManager->reconfigure(); |
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | void KABCore::addressBookChanged() | 1508 | void KABCore::addressBookChanged() |
1509 | { | 1509 | { |
1510 | /*US | 1510 | /*US |
1511 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1511 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1512 | while ( it.current() ) { | 1512 | while ( it.current() ) { |
1513 | if ( it.current()->dirty() ) { | 1513 | if ( it.current()->dirty() ) { |
1514 | QString text = i18n( "Data has been changed externally. Unsaved " | 1514 | QString text = i18n( "Data has been changed externally. Unsaved " |
1515 | "changes will be lost." ); | 1515 | "changes will be lost." ); |
1516 | KMessageBox::information( this, text ); | 1516 | KMessageBox::information( this, text ); |
1517 | } | 1517 | } |
1518 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1518 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1519 | ++it; | 1519 | ++it; |
1520 | } | 1520 | } |
1521 | */ | 1521 | */ |
1522 | if (mEditorDialog) | 1522 | if (mEditorDialog) |
1523 | { | 1523 | { |
1524 | if (mEditorDialog->dirty()) | 1524 | if (mEditorDialog->dirty()) |
1525 | { | 1525 | { |
1526 | QString text = i18n( "Data has been changed externally. Unsaved " | 1526 | QString text = i18n( "Data has been changed externally. Unsaved " |
1527 | "changes will be lost." ); | 1527 | "changes will be lost." ); |
1528 | KMessageBox::information( this, text ); | 1528 | KMessageBox::information( this, text ); |
1529 | } | 1529 | } |
1530 | QString currentuid = mEditorDialog->addressee().uid(); | 1530 | QString currentuid = mEditorDialog->addressee().uid(); |
1531 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1531 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1532 | } | 1532 | } |
1533 | mViewManager->refreshView(); | 1533 | mViewManager->refreshView(); |
1534 | // mDetails->refreshView(); | 1534 | // mDetails->refreshView(); |
1535 | 1535 | ||
1536 | 1536 | ||
1537 | } | 1537 | } |
1538 | 1538 | ||
1539 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1539 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1540 | const char *name ) | 1540 | const char *name ) |
1541 | { | 1541 | { |
1542 | 1542 | ||
1543 | if ( mEditorDialog == 0 ) { | 1543 | if ( mEditorDialog == 0 ) { |
1544 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1544 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1545 | name ? name : "editorDialog" ); | 1545 | name ? name : "editorDialog" ); |
1546 | 1546 | ||
1547 | 1547 | ||
1548 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1548 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1549 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1549 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1550 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1550 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1551 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1551 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1552 | } | 1552 | } |
1553 | 1553 | ||
1554 | return mEditorDialog; | 1554 | return mEditorDialog; |
1555 | } | 1555 | } |
1556 | 1556 | ||
1557 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1557 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1558 | { | 1558 | { |
1559 | //mEditorDict.remove( uid ); | 1559 | //mEditorDict.remove( uid ); |
1560 | } | 1560 | } |
1561 | 1561 | ||
1562 | void KABCore::initGUI() | 1562 | void KABCore::initGUI() |
1563 | { | 1563 | { |
1564 | #ifndef KAB_EMBEDDED | 1564 | #ifndef KAB_EMBEDDED |
1565 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1565 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1566 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1566 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1567 | 1567 | ||
1568 | mExtensionBarSplitter = new QSplitter( this ); | 1568 | mExtensionBarSplitter = new QSplitter( this ); |
1569 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1569 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1570 | 1570 | ||
1571 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1571 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1572 | 1572 | ||
1573 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1573 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1574 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1574 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1575 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1575 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1576 | SLOT( incrementalSearch( const QString& ) ) ); | 1576 | SLOT( incrementalSearch( const QString& ) ) ); |
1577 | 1577 | ||
1578 | mViewManager = new ViewManager( this, viewSpace ); | 1578 | mViewManager = new ViewManager( this, viewSpace ); |
1579 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1579 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1580 | 1580 | ||
1581 | mDetails = new ViewContainer( mDetailsSplitter ); | 1581 | mDetails = new ViewContainer( mDetailsSplitter ); |
1582 | 1582 | ||
1583 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1583 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1584 | 1584 | ||
1585 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1585 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1586 | 1586 | ||
1587 | topLayout->addWidget( mExtensionBarSplitter ); | 1587 | topLayout->addWidget( mExtensionBarSplitter ); |
1588 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1588 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1589 | topLayout->addWidget( mJumpButtonBar ); | 1589 | topLayout->addWidget( mJumpButtonBar ); |
1590 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1590 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1591 | 1591 | ||
1592 | mXXPortManager = new XXPortManager( this, this ); | 1592 | mXXPortManager = new XXPortManager( this, this ); |
1593 | 1593 | ||
1594 | #else //KAB_EMBEDDED | 1594 | #else //KAB_EMBEDDED |
1595 | //US initialize viewMenu before settingup viewmanager. | 1595 | //US initialize viewMenu before settingup viewmanager. |
1596 | // Viewmanager needs this menu to plugin submenues. | 1596 | // Viewmanager needs this menu to plugin submenues. |
1597 | viewMenu = new QPopupMenu( this ); | 1597 | viewMenu = new QPopupMenu( this ); |
1598 | settingsMenu = new QPopupMenu( this ); | 1598 | settingsMenu = new QPopupMenu( this ); |
1599 | //filterMenu = new QPopupMenu( this ); | 1599 | //filterMenu = new QPopupMenu( this ); |
1600 | ImportMenu = new QPopupMenu( this ); | 1600 | ImportMenu = new QPopupMenu( this ); |
1601 | ExportMenu = new QPopupMenu( this ); | 1601 | ExportMenu = new QPopupMenu( this ); |
1602 | syncMenu = new QPopupMenu( this ); | 1602 | syncMenu = new QPopupMenu( this ); |
1603 | changeMenu= new QPopupMenu( this ); | 1603 | changeMenu= new QPopupMenu( this ); |
1604 | 1604 | ||
1605 | //US since we have no splitter for the embedded system, setup | 1605 | //US since we have no splitter for the embedded system, setup |
1606 | // a layout with two frames. One left and one right. | 1606 | // a layout with two frames. One left and one right. |
1607 | 1607 | ||
1608 | QBoxLayout *topLayout; | 1608 | QBoxLayout *topLayout; |
1609 | 1609 | ||
1610 | // = new QHBoxLayout( this ); | 1610 | // = new QHBoxLayout( this ); |
1611 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1611 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1612 | 1612 | ||
1613 | // QWidget *mainBox = new QWidget( this ); | 1613 | // QWidget *mainBox = new QWidget( this ); |
1614 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1614 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1615 | 1615 | ||
1616 | #ifdef DESKTOP_VERSION | 1616 | #ifdef DESKTOP_VERSION |
1617 | topLayout = new QHBoxLayout( this ); | 1617 | topLayout = new QHBoxLayout( this ); |
1618 | 1618 | ||
1619 | 1619 | ||
1620 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1620 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1621 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1621 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1622 | 1622 | ||
1623 | topLayout->addWidget(mMiniSplitter ); | 1623 | topLayout->addWidget(mMiniSplitter ); |
1624 | 1624 | ||
1625 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1625 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1626 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1626 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1627 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1627 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1628 | mDetails = new ViewContainer( mMiniSplitter ); | 1628 | mDetails = new ViewContainer( mMiniSplitter ); |
1629 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1629 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1630 | #else | 1630 | #else |
1631 | if ( QApplication::desktop()->width() > 480 ) { | 1631 | if ( QApplication::desktop()->width() > 480 ) { |
1632 | topLayout = new QHBoxLayout( this ); | 1632 | topLayout = new QHBoxLayout( this ); |
1633 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1633 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1634 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1634 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1635 | } else { | 1635 | } else { |
1636 | 1636 | ||
1637 | topLayout = new QHBoxLayout( this ); | 1637 | topLayout = new QHBoxLayout( this ); |
1638 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1638 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1639 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1639 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1640 | } | 1640 | } |
1641 | 1641 | ||
1642 | topLayout->addWidget(mMiniSplitter ); | 1642 | topLayout->addWidget(mMiniSplitter ); |
1643 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1643 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1644 | mDetails = new ViewContainer( mMiniSplitter ); | 1644 | mDetails = new ViewContainer( mMiniSplitter ); |
1645 | 1645 | ||
1646 | 1646 | ||
1647 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1647 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1648 | #endif | 1648 | #endif |
1649 | //eh->hide(); | 1649 | //eh->hide(); |
1650 | // topLayout->addWidget(mExtensionManager ); | 1650 | // topLayout->addWidget(mExtensionManager ); |
1651 | 1651 | ||
1652 | 1652 | ||
1653 | /*US | 1653 | /*US |
1654 | #ifndef KAB_NOSPLITTER | 1654 | #ifndef KAB_NOSPLITTER |
1655 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1655 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1656 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1656 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1657 | topLayout->setSpacing( 10 ); | 1657 | topLayout->setSpacing( 10 ); |
1658 | 1658 | ||
1659 | mDetailsSplitter = new QSplitter( this ); | 1659 | mDetailsSplitter = new QSplitter( this ); |
1660 | 1660 | ||
1661 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1661 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1662 | 1662 | ||
1663 | mViewManager = new ViewManager( this, viewSpace ); | 1663 | mViewManager = new ViewManager( this, viewSpace ); |
1664 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1664 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1665 | 1665 | ||
1666 | mDetails = new ViewContainer( mDetailsSplitter ); | 1666 | mDetails = new ViewContainer( mDetailsSplitter ); |
1667 | 1667 | ||
1668 | topLayout->addWidget( mDetailsSplitter ); | 1668 | topLayout->addWidget( mDetailsSplitter ); |
1669 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1669 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1670 | #else //KAB_NOSPLITTER | 1670 | #else //KAB_NOSPLITTER |
1671 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1671 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1672 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1672 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1673 | topLayout->setSpacing( 10 ); | 1673 | topLayout->setSpacing( 10 ); |
1674 | 1674 | ||
1675 | // mDetailsSplitter = new QSplitter( this ); | 1675 | // mDetailsSplitter = new QSplitter( this ); |
1676 | 1676 | ||
1677 | QVBox *viewSpace = new QVBox( this ); | 1677 | QVBox *viewSpace = new QVBox( this ); |
1678 | 1678 | ||
1679 | mViewManager = new ViewManager( this, viewSpace ); | 1679 | mViewManager = new ViewManager( this, viewSpace ); |
1680 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1680 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1681 | 1681 | ||
1682 | mDetails = new ViewContainer( this ); | 1682 | mDetails = new ViewContainer( this ); |
1683 | 1683 | ||
1684 | topLayout->addWidget( viewSpace ); | 1684 | topLayout->addWidget( viewSpace ); |
1685 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1685 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1686 | topLayout->addWidget( mDetails ); | 1686 | topLayout->addWidget( mDetails ); |
1687 | #endif //KAB_NOSPLITTER | 1687 | #endif //KAB_NOSPLITTER |
1688 | */ | 1688 | */ |
1689 | 1689 | ||
1690 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1690 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1691 | syncManager->setBlockSave(false); | 1691 | syncManager->setBlockSave(false); |
1692 | 1692 | ||
1693 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1693 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1694 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1694 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1695 | syncManager->setDefaultFileName( sentSyncFile()); | 1695 | syncManager->setDefaultFileName( sentSyncFile()); |
1696 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1696 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1697 | 1697 | ||
1698 | #endif //KAB_EMBEDDED | 1698 | #endif //KAB_EMBEDDED |
1699 | initActions(); | 1699 | initActions(); |
1700 | 1700 | ||
1701 | #ifdef KAB_EMBEDDED | 1701 | #ifdef KAB_EMBEDDED |
1702 | addActionsManually(); | 1702 | addActionsManually(); |
1703 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1703 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1704 | mXXPortManager = new XXPortManager( this, this ); | 1704 | mXXPortManager = new XXPortManager( this, this ); |
1705 | 1705 | ||
1706 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1706 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1707 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1707 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1708 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1708 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1709 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1709 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1710 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1710 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1711 | // mIncSearchWidget->hide(); | 1711 | // mIncSearchWidget->hide(); |
1712 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1712 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1713 | SLOT( incrementalSearch( const QString& ) ) ); | 1713 | SLOT( incrementalSearch( const QString& ) ) ); |
1714 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1714 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1715 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1715 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1716 | 1716 | ||
1717 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1717 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1718 | 1718 | ||
1719 | topLayout->addWidget( mJumpButtonBar ); | 1719 | topLayout->addWidget( mJumpButtonBar ); |
1720 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1720 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1721 | 1721 | ||
1722 | // mMainWindow->getIconToolBar()->raise(); | 1722 | // mMainWindow->getIconToolBar()->raise(); |
1723 | 1723 | ||
1724 | #endif //KAB_EMBEDDED | 1724 | #endif //KAB_EMBEDDED |
1725 | 1725 | ||
1726 | } | 1726 | } |
1727 | void KABCore::initActions() | 1727 | void KABCore::initActions() |
1728 | { | 1728 | { |
1729 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1729 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1730 | 1730 | ||
1731 | #ifndef KAB_EMBEDDED | 1731 | #ifndef KAB_EMBEDDED |
1732 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1732 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1733 | SLOT( clipboardDataChanged() ) ); | 1733 | SLOT( clipboardDataChanged() ) ); |
1734 | #endif //KAB_EMBEDDED | 1734 | #endif //KAB_EMBEDDED |
1735 | 1735 | ||
1736 | // file menu | 1736 | // file menu |
1737 | if ( mIsPart ) { | 1737 | if ( mIsPart ) { |
1738 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1738 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1739 | SLOT( sendMail() ), actionCollection(), | 1739 | SLOT( sendMail() ), actionCollection(), |
1740 | "kaddressbook_mail" ); | 1740 | "kaddressbook_mail" ); |
1741 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1741 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1742 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1742 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1743 | 1743 | ||
1744 | } else { | 1744 | } else { |
1745 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1745 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1746 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1746 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1747 | } | 1747 | } |
1748 | 1748 | ||
1749 | 1749 | ||
1750 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1750 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1751 | SLOT( save() ), actionCollection(), "file_sync" ); | 1751 | SLOT( save() ), actionCollection(), "file_sync" ); |
1752 | 1752 | ||
1753 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1753 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1754 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1754 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1755 | 1755 | ||
1756 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1756 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1757 | this, SLOT( mailVCard() ), | 1757 | this, SLOT( mailVCard() ), |
1758 | actionCollection(), "file_mail_vcard"); | 1758 | actionCollection(), "file_mail_vcard"); |
1759 | 1759 | ||
1760 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1760 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1761 | SLOT( export2phone() ), actionCollection(), | 1761 | SLOT( export2phone() ), actionCollection(), |
1762 | "kaddressbook_ex2phone" ); | 1762 | "kaddressbook_ex2phone" ); |
1763 | 1763 | ||
1764 | mActionBeamVCard = 0; | 1764 | mActionBeamVCard = 0; |
1765 | mActionBeam = 0; | 1765 | mActionBeam = 0; |
1766 | 1766 | ||
1767 | #ifndef DESKTOP_VERSION | 1767 | #ifndef DESKTOP_VERSION |
1768 | if ( Ir::supported() ) { | 1768 | if ( Ir::supported() ) { |
1769 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1769 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1770 | SLOT( beamVCard() ), actionCollection(), | 1770 | SLOT( beamVCard() ), actionCollection(), |
1771 | "kaddressbook_beam_vcard" ); | 1771 | "kaddressbook_beam_vcard" ); |
1772 | 1772 | ||
1773 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1773 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1774 | SLOT( beamMySelf() ), actionCollection(), | 1774 | SLOT( beamMySelf() ), actionCollection(), |
1775 | "kaddressbook_beam_myself" ); | 1775 | "kaddressbook_beam_myself" ); |
1776 | } | 1776 | } |
1777 | #endif | 1777 | #endif |
1778 | 1778 | ||
1779 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1779 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1780 | this, SLOT( editContact2() ), | 1780 | this, SLOT( editContact2() ), |
1781 | actionCollection(), "file_properties" ); | 1781 | actionCollection(), "file_properties" ); |
1782 | 1782 | ||
1783 | #ifdef KAB_EMBEDDED | 1783 | #ifdef KAB_EMBEDDED |
1784 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1784 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1785 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1785 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1786 | mMainWindow, SLOT( exit() ), | 1786 | mMainWindow, SLOT( exit() ), |
1787 | actionCollection(), "quit" ); | 1787 | actionCollection(), "quit" ); |
1788 | #endif //KAB_EMBEDDED | 1788 | #endif //KAB_EMBEDDED |
1789 | 1789 | ||
1790 | // edit menu | 1790 | // edit menu |
1791 | if ( mIsPart ) { | 1791 | if ( mIsPart ) { |
1792 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1792 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1793 | SLOT( copyContacts() ), actionCollection(), | 1793 | SLOT( copyContacts() ), actionCollection(), |
1794 | "kaddressbook_copy" ); | 1794 | "kaddressbook_copy" ); |
1795 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1795 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1796 | SLOT( cutContacts() ), actionCollection(), | 1796 | SLOT( cutContacts() ), actionCollection(), |
1797 | "kaddressbook_cut" ); | 1797 | "kaddressbook_cut" ); |
1798 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1798 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1799 | SLOT( pasteContacts() ), actionCollection(), | 1799 | SLOT( pasteContacts() ), actionCollection(), |
1800 | "kaddressbook_paste" ); | 1800 | "kaddressbook_paste" ); |
1801 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1801 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1802 | SLOT( selectAllContacts() ), actionCollection(), | 1802 | SLOT( selectAllContacts() ), actionCollection(), |
1803 | "kaddressbook_select_all" ); | 1803 | "kaddressbook_select_all" ); |
1804 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1804 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1805 | SLOT( undo() ), actionCollection(), | 1805 | SLOT( undo() ), actionCollection(), |
1806 | "kaddressbook_undo" ); | 1806 | "kaddressbook_undo" ); |
1807 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1807 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1808 | this, SLOT( redo() ), actionCollection(), | 1808 | this, SLOT( redo() ), actionCollection(), |
1809 | "kaddressbook_redo" ); | 1809 | "kaddressbook_redo" ); |
1810 | } else { | 1810 | } else { |
1811 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1811 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1812 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1812 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1813 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1813 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1814 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1814 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1815 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1815 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1816 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1816 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1817 | } | 1817 | } |
1818 | 1818 | ||
1819 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1819 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1820 | Key_Delete, this, SLOT( deleteContacts() ), | 1820 | Key_Delete, this, SLOT( deleteContacts() ), |
1821 | actionCollection(), "edit_delete" ); | 1821 | actionCollection(), "edit_delete" ); |
1822 | 1822 | ||
1823 | mActionUndo->setEnabled( false ); | 1823 | mActionUndo->setEnabled( false ); |
1824 | mActionRedo->setEnabled( false ); | 1824 | mActionRedo->setEnabled( false ); |
1825 | 1825 | ||
1826 | // settings menu | 1826 | // settings menu |
1827 | #ifdef KAB_EMBEDDED | 1827 | #ifdef KAB_EMBEDDED |
1828 | //US special menuentry to configure the addressbook resources. On KDE | 1828 | //US special menuentry to configure the addressbook resources. On KDE |
1829 | // you do that through the control center !!! | 1829 | // you do that through the control center !!! |
1830 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1830 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1831 | SLOT( configureResources() ), actionCollection(), | 1831 | SLOT( configureResources() ), actionCollection(), |
1832 | "kaddressbook_configure_resources" ); | 1832 | "kaddressbook_configure_resources" ); |
1833 | #endif //KAB_EMBEDDED | 1833 | #endif //KAB_EMBEDDED |
1834 | 1834 | ||
1835 | if ( mIsPart ) { | 1835 | if ( mIsPart ) { |
1836 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1836 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1837 | SLOT( openConfigDialog() ), actionCollection(), | 1837 | SLOT( openConfigDialog() ), actionCollection(), |
1838 | "kaddressbook_configure" ); | 1838 | "kaddressbook_configure" ); |
1839 | 1839 | ||
1840 | //US not implemented yet | 1840 | //US not implemented yet |
1841 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1841 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1842 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1842 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1843 | // "kaddressbook_configure_shortcuts" ); | 1843 | // "kaddressbook_configure_shortcuts" ); |
1844 | #ifdef KAB_EMBEDDED | 1844 | #ifdef KAB_EMBEDDED |
1845 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1845 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1846 | mActionConfigureToolbars->setEnabled( false ); | 1846 | mActionConfigureToolbars->setEnabled( false ); |
1847 | #endif //KAB_EMBEDDED | 1847 | #endif //KAB_EMBEDDED |
1848 | 1848 | ||
1849 | } else { | 1849 | } else { |
1850 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1850 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1851 | 1851 | ||
1852 | //US not implemented yet | 1852 | //US not implemented yet |
1853 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1853 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1854 | } | 1854 | } |
1855 | 1855 | ||
1856 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1856 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1857 | actionCollection(), "options_show_jump_bar" ); | 1857 | actionCollection(), "options_show_jump_bar" ); |
1858 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1858 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1859 | 1859 | ||
1860 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1860 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1861 | actionCollection(), "options_show_details" ); | 1861 | actionCollection(), "options_show_details" ); |
1862 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1862 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1863 | 1863 | ||
1864 | 1864 | ||
1865 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 1865 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
1866 | SLOT( toggleBeamReceive() ), actionCollection(), | 1866 | SLOT( toggleBeamReceive() ), actionCollection(), |
1867 | "kaddressbook_beam_rec" ); | 1867 | "kaddressbook_beam_rec" ); |
1868 | 1868 | ||
1869 | 1869 | ||
1870 | // misc | 1870 | // misc |
1871 | // only enable LDAP lookup if we can handle the protocol | 1871 | // only enable LDAP lookup if we can handle the protocol |
1872 | #ifndef KAB_EMBEDDED | 1872 | #ifndef KAB_EMBEDDED |
1873 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1873 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1874 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1874 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1875 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1875 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1876 | "ldap_lookup" ); | 1876 | "ldap_lookup" ); |
1877 | } | 1877 | } |
1878 | #else //KAB_EMBEDDED | 1878 | #else //KAB_EMBEDDED |
1879 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1879 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1880 | #endif //KAB_EMBEDDED | 1880 | #endif //KAB_EMBEDDED |
1881 | 1881 | ||
1882 | 1882 | ||
1883 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1883 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1884 | SLOT( setWhoAmI() ), actionCollection(), | 1884 | SLOT( setWhoAmI() ), actionCollection(), |
1885 | "set_personal" ); | 1885 | "set_personal" ); |
1886 | 1886 | ||
1887 | 1887 | ||
1888 | 1888 | ||
1889 | 1889 | ||
1890 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1890 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1891 | SLOT( setCategories() ), actionCollection(), | 1891 | SLOT( setCategories() ), actionCollection(), |
1892 | "edit_set_categories" ); | 1892 | "edit_set_categories" ); |
1893 | 1893 | ||
1894 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1894 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1895 | SLOT( removeVoice() ), actionCollection(), | 1895 | SLOT( removeVoice() ), actionCollection(), |
1896 | "remove_voice" ); | 1896 | "remove_voice" ); |
1897 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1897 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1898 | SLOT( importFromOL() ), actionCollection(), | 1898 | SLOT( importFromOL() ), actionCollection(), |
1899 | "import_OL" ); | 1899 | "import_OL" ); |
1900 | #ifdef KAB_EMBEDDED | 1900 | #ifdef KAB_EMBEDDED |
1901 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1901 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1902 | this, SLOT( showLicence() ), actionCollection(), | 1902 | this, SLOT( showLicence() ), actionCollection(), |
1903 | "licence_about_data" ); | 1903 | "licence_about_data" ); |
1904 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1904 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1905 | this, SLOT( faq() ), actionCollection(), | 1905 | this, SLOT( faq() ), actionCollection(), |
1906 | "faq_about_data" ); | 1906 | "faq_about_data" ); |
1907 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 1907 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
1908 | this, SLOT( whatsnew() ), actionCollection(), | 1908 | this, SLOT( whatsnew() ), actionCollection(), |
1909 | "wn" ); | 1909 | "wn" ); |
1910 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 1910 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
1911 | this, SLOT( synchowto() ), actionCollection(), | 1911 | this, SLOT( synchowto() ), actionCollection(), |
1912 | "sync" ); | 1912 | "sync" ); |
1913 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | ||
1914 | this, SLOT( kdesynchowto() ), actionCollection(), | ||
1915 | "kdesync" ); | ||
1916 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | ||
1917 | this, SLOT( multisynchowto() ), actionCollection(), | ||
1918 | "multisync" ); | ||
1913 | 1919 | ||
1914 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1920 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1915 | this, SLOT( createAboutData() ), actionCollection(), | 1921 | this, SLOT( createAboutData() ), actionCollection(), |
1916 | "kaddressbook_about_data" ); | 1922 | "kaddressbook_about_data" ); |
1917 | #endif //KAB_EMBEDDED | 1923 | #endif //KAB_EMBEDDED |
1918 | 1924 | ||
1919 | clipboardDataChanged(); | 1925 | clipboardDataChanged(); |
1920 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1926 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1921 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1927 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1922 | } | 1928 | } |
1923 | 1929 | ||
1924 | //US we need this function, to plug all actions into the correct menues. | 1930 | //US we need this function, to plug all actions into the correct menues. |
1925 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1931 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1926 | void KABCore::addActionsManually() | 1932 | void KABCore::addActionsManually() |
1927 | { | 1933 | { |
1928 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1934 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1929 | 1935 | ||
1930 | #ifdef KAB_EMBEDDED | 1936 | #ifdef KAB_EMBEDDED |
1931 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1937 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1932 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1938 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1933 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1939 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1934 | 1940 | ||
1935 | KToolBar* tb = mMainWindow->toolBar(); | 1941 | KToolBar* tb = mMainWindow->toolBar(); |
1936 | 1942 | ||
1937 | #ifndef DESKTOP_VERSION | 1943 | #ifndef DESKTOP_VERSION |
1938 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 1944 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
1939 | #endif | 1945 | #endif |
1940 | QMenuBar* mb = mMainWindow->menuBar(); | 1946 | QMenuBar* mb = mMainWindow->menuBar(); |
1941 | 1947 | ||
1942 | //US setup menubar. | 1948 | //US setup menubar. |
1943 | //Disable the following block if you do not want to have a menubar. | 1949 | //Disable the following block if you do not want to have a menubar. |
1944 | mb->insertItem( "&File", fileMenu ); | 1950 | mb->insertItem( "&File", fileMenu ); |
1945 | mb->insertItem( "&Edit", editMenu ); | 1951 | mb->insertItem( "&Edit", editMenu ); |
1946 | mb->insertItem( "&View", viewMenu ); | 1952 | mb->insertItem( "&View", viewMenu ); |
1947 | mb->insertItem( "&Settings", settingsMenu ); | 1953 | mb->insertItem( "&Settings", settingsMenu ); |
1948 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1954 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1949 | mb->insertItem( "&Change selected", changeMenu ); | 1955 | mb->insertItem( "&Change selected", changeMenu ); |
1950 | mb->insertItem( "&Help", helpMenu ); | 1956 | mb->insertItem( "&Help", helpMenu ); |
1951 | mIncSearchWidget = new IncSearchWidget( tb ); | 1957 | mIncSearchWidget = new IncSearchWidget( tb ); |
1952 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1958 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1953 | #ifndef DESKTOP_VERSION | 1959 | #ifndef DESKTOP_VERSION |
1954 | } else { | 1960 | } else { |
1955 | //US setup toolbar | 1961 | //US setup toolbar |
1956 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1962 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1957 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1963 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1958 | menuBarTB->insertItem( "ME", popupBarTB); | 1964 | menuBarTB->insertItem( "ME", popupBarTB); |
1959 | tb->insertWidget(-1, 0, menuBarTB); | 1965 | tb->insertWidget(-1, 0, menuBarTB); |
1960 | mIncSearchWidget = new IncSearchWidget( tb ); | 1966 | mIncSearchWidget = new IncSearchWidget( tb ); |
1961 | 1967 | ||
1962 | tb->enableMoving(false); | 1968 | tb->enableMoving(false); |
1963 | popupBarTB->insertItem( "&File", fileMenu ); | 1969 | popupBarTB->insertItem( "&File", fileMenu ); |
1964 | popupBarTB->insertItem( "&Edit", editMenu ); | 1970 | popupBarTB->insertItem( "&Edit", editMenu ); |
1965 | popupBarTB->insertItem( "&View", viewMenu ); | 1971 | popupBarTB->insertItem( "&View", viewMenu ); |
1966 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1972 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1967 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1973 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1968 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1974 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1969 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1975 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1970 | popupBarTB->insertItem( "&Help", helpMenu ); | 1976 | popupBarTB->insertItem( "&Help", helpMenu ); |
1971 | if (QApplication::desktop()->width() > 320 ) { | 1977 | if (QApplication::desktop()->width() > 320 ) { |
1972 | // mViewManager->getFilterAction()->plug ( tb); | 1978 | // mViewManager->getFilterAction()->plug ( tb); |
1973 | } | 1979 | } |
1974 | } | 1980 | } |
1975 | #endif | 1981 | #endif |
1976 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1982 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1977 | 1983 | ||
1978 | 1984 | ||
1979 | 1985 | ||
1980 | //US Now connect the actions with the menue entries. | 1986 | //US Now connect the actions with the menue entries. |
1981 | mActionPrint->plug( fileMenu ); | 1987 | mActionPrint->plug( fileMenu ); |
1982 | mActionMail->plug( fileMenu ); | 1988 | mActionMail->plug( fileMenu ); |
1983 | fileMenu->insertSeparator(); | 1989 | fileMenu->insertSeparator(); |
1984 | 1990 | ||
1985 | mActionNewContact->plug( fileMenu ); | 1991 | mActionNewContact->plug( fileMenu ); |
1986 | mActionNewContact->plug( tb ); | 1992 | mActionNewContact->plug( tb ); |
1987 | 1993 | ||
1988 | mActionEditAddressee->plug( fileMenu ); | 1994 | mActionEditAddressee->plug( fileMenu ); |
1989 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1995 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1990 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1996 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1991 | mActionEditAddressee->plug( tb ); | 1997 | mActionEditAddressee->plug( tb ); |
1992 | 1998 | ||
1993 | fileMenu->insertSeparator(); | 1999 | fileMenu->insertSeparator(); |
1994 | mActionSave->plug( fileMenu ); | 2000 | mActionSave->plug( fileMenu ); |
1995 | fileMenu->insertItem( "&Import", ImportMenu ); | 2001 | fileMenu->insertItem( "&Import", ImportMenu ); |
1996 | fileMenu->insertItem( "&Export", ExportMenu ); | 2002 | fileMenu->insertItem( "&Export", ExportMenu ); |
1997 | fileMenu->insertSeparator(); | 2003 | fileMenu->insertSeparator(); |
1998 | mActionMailVCard->plug( fileMenu ); | 2004 | mActionMailVCard->plug( fileMenu ); |
1999 | #ifndef DESKTOP_VERSION | 2005 | #ifndef DESKTOP_VERSION |
2000 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 2006 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
2001 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 2007 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
2002 | #endif | 2008 | #endif |
2003 | fileMenu->insertSeparator(); | 2009 | fileMenu->insertSeparator(); |
2004 | mActionQuit->plug( fileMenu ); | 2010 | mActionQuit->plug( fileMenu ); |
2005 | #ifdef _WIN32_ | 2011 | #ifdef _WIN32_ |
2006 | mActionImportOL->plug( ImportMenu ); | 2012 | mActionImportOL->plug( ImportMenu ); |
2007 | #endif | 2013 | #endif |
2008 | // edit menu | 2014 | // edit menu |
2009 | mActionUndo->plug( editMenu ); | 2015 | mActionUndo->plug( editMenu ); |
2010 | mActionRedo->plug( editMenu ); | 2016 | mActionRedo->plug( editMenu ); |
2011 | editMenu->insertSeparator(); | 2017 | editMenu->insertSeparator(); |
2012 | mActionCut->plug( editMenu ); | 2018 | mActionCut->plug( editMenu ); |
2013 | mActionCopy->plug( editMenu ); | 2019 | mActionCopy->plug( editMenu ); |
2014 | mActionPaste->plug( editMenu ); | 2020 | mActionPaste->plug( editMenu ); |
2015 | mActionDelete->plug( editMenu ); | 2021 | mActionDelete->plug( editMenu ); |
2016 | editMenu->insertSeparator(); | 2022 | editMenu->insertSeparator(); |
2017 | mActionSelectAll->plug( editMenu ); | 2023 | mActionSelectAll->plug( editMenu ); |
2018 | 2024 | ||
2019 | mActionRemoveVoice->plug( changeMenu ); | 2025 | mActionRemoveVoice->plug( changeMenu ); |
2020 | // settings menu | 2026 | // settings menu |
2021 | //US special menuentry to configure the addressbook resources. On KDE | 2027 | //US special menuentry to configure the addressbook resources. On KDE |
2022 | // you do that through the control center !!! | 2028 | // you do that through the control center !!! |
2023 | mActionConfigResources->plug( settingsMenu ); | 2029 | mActionConfigResources->plug( settingsMenu ); |
2024 | settingsMenu->insertSeparator(); | 2030 | settingsMenu->insertSeparator(); |
2025 | 2031 | ||
2026 | mActionConfigKAddressbook->plug( settingsMenu ); | 2032 | mActionConfigKAddressbook->plug( settingsMenu ); |
2027 | 2033 | ||
2028 | if ( mIsPart ) { | 2034 | if ( mIsPart ) { |
2029 | //US not implemented yet | 2035 | //US not implemented yet |
2030 | //mActionConfigShortcuts->plug( settingsMenu ); | 2036 | //mActionConfigShortcuts->plug( settingsMenu ); |
2031 | //mActionConfigureToolbars->plug( settingsMenu ); | 2037 | //mActionConfigureToolbars->plug( settingsMenu ); |
2032 | 2038 | ||
2033 | } else { | 2039 | } else { |
2034 | //US not implemented yet | 2040 | //US not implemented yet |
2035 | //mActionKeyBindings->plug( settingsMenu ); | 2041 | //mActionKeyBindings->plug( settingsMenu ); |
2036 | } | 2042 | } |
2037 | 2043 | ||
2038 | settingsMenu->insertSeparator(); | 2044 | settingsMenu->insertSeparator(); |
2039 | 2045 | ||
2040 | mActionJumpBar->plug( settingsMenu ); | 2046 | mActionJumpBar->plug( settingsMenu ); |
2041 | mActionDetails->plug( settingsMenu ); | 2047 | mActionDetails->plug( settingsMenu ); |
2042 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2048 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2043 | mActionDetails->plug( tb ); | 2049 | mActionDetails->plug( tb ); |
2044 | settingsMenu->insertSeparator(); | 2050 | settingsMenu->insertSeparator(); |
2045 | mActionBR->plug(settingsMenu ); | 2051 | mActionBR->plug(settingsMenu ); |
2046 | settingsMenu->insertSeparator(); | 2052 | settingsMenu->insertSeparator(); |
2047 | 2053 | ||
2048 | mActionWhoAmI->plug( settingsMenu ); | 2054 | mActionWhoAmI->plug( settingsMenu ); |
2049 | mActionCategories->plug( settingsMenu ); | 2055 | mActionCategories->plug( settingsMenu ); |
2050 | 2056 | ||
2051 | 2057 | ||
2052 | mActionWN->plug( helpMenu ); | 2058 | mActionWN->plug( helpMenu ); |
2053 | mActionSyncHowto->plug( helpMenu ); | 2059 | mActionSyncHowto->plug( helpMenu ); |
2054 | mActionLicence->plug( helpMenu ); | 2060 | mActionKdeSyncHowto->plug( helpMenu ); |
2061 | mActionMultiSyncHowto->plug( helpMenu ); | ||
2055 | mActionFaq->plug( helpMenu ); | 2062 | mActionFaq->plug( helpMenu ); |
2063 | mActionLicence->plug( helpMenu ); | ||
2056 | mActionAboutKAddressbook->plug( helpMenu ); | 2064 | mActionAboutKAddressbook->plug( helpMenu ); |
2057 | 2065 | ||
2058 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2066 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2059 | 2067 | ||
2060 | mActionSave->plug( tb ); | 2068 | mActionSave->plug( tb ); |
2061 | mViewManager->getFilterAction()->plug ( tb); | 2069 | mViewManager->getFilterAction()->plug ( tb); |
2062 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2070 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2063 | mActionUndo->plug( tb ); | 2071 | mActionUndo->plug( tb ); |
2064 | mActionDelete->plug( tb ); | 2072 | mActionDelete->plug( tb ); |
2065 | mActionRedo->plug( tb ); | 2073 | mActionRedo->plug( tb ); |
2066 | } | 2074 | } |
2067 | } else { | 2075 | } else { |
2068 | mActionSave->plug( tb ); | 2076 | mActionSave->plug( tb ); |
2069 | tb->enableMoving(false); | 2077 | tb->enableMoving(false); |
2070 | } | 2078 | } |
2071 | //mActionQuit->plug ( tb ); | 2079 | //mActionQuit->plug ( tb ); |
2072 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2080 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2073 | 2081 | ||
2074 | //US link the searchwidget first to this. | 2082 | //US link the searchwidget first to this. |
2075 | // The real linkage to the toolbar happens later. | 2083 | // The real linkage to the toolbar happens later. |
2076 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2084 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2077 | //US tb->insertItem( mIncSearchWidget ); | 2085 | //US tb->insertItem( mIncSearchWidget ); |
2078 | /*US | 2086 | /*US |
2079 | mIncSearchWidget = new IncSearchWidget( tb ); | 2087 | mIncSearchWidget = new IncSearchWidget( tb ); |
2080 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2088 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2081 | SLOT( incrementalSearch( const QString& ) ) ); | 2089 | SLOT( incrementalSearch( const QString& ) ) ); |
2082 | 2090 | ||
2083 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2091 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2084 | 2092 | ||
2085 | //US topLayout->addWidget( mJumpButtonBar ); | 2093 | //US topLayout->addWidget( mJumpButtonBar ); |
2086 | this->layout()->add( mJumpButtonBar ); | 2094 | this->layout()->add( mJumpButtonBar ); |
2087 | */ | 2095 | */ |
2088 | 2096 | ||
2089 | #endif //KAB_EMBEDDED | 2097 | #endif //KAB_EMBEDDED |
2090 | 2098 | ||
2091 | mActionExport2phone->plug( ExportMenu ); | 2099 | mActionExport2phone->plug( ExportMenu ); |
2092 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2100 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2093 | syncManager->fillSyncMenu(); | 2101 | syncManager->fillSyncMenu(); |
2094 | 2102 | ||
2095 | } | 2103 | } |
2096 | void KABCore::showLicence() | 2104 | void KABCore::showLicence() |
2097 | { | 2105 | { |
2098 | KApplication::showLicence(); | 2106 | KApplication::showLicence(); |
2099 | } | 2107 | } |
2100 | void KABCore::removeVoice() | 2108 | void KABCore::removeVoice() |
2101 | { | 2109 | { |
2102 | 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 ) | 2110 | 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 ) |
2103 | return; | 2111 | return; |
2104 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2112 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2105 | KABC::Addressee::List::Iterator it; | 2113 | KABC::Addressee::List::Iterator it; |
2106 | for ( it = list.begin(); it != list.end(); ++it ) { | 2114 | for ( it = list.begin(); it != list.end(); ++it ) { |
2107 | 2115 | ||
2108 | if ( (*it).removeVoice() ) | 2116 | if ( (*it).removeVoice() ) |
2109 | contactModified((*it) ); | 2117 | contactModified((*it) ); |
2110 | } | 2118 | } |
2111 | } | 2119 | } |
2112 | 2120 | ||
2113 | 2121 | ||
2114 | 2122 | ||
2115 | void KABCore::clipboardDataChanged() | 2123 | void KABCore::clipboardDataChanged() |
2116 | { | 2124 | { |
2117 | 2125 | ||
2118 | if ( mReadWrite ) | 2126 | if ( mReadWrite ) |
2119 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2127 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2120 | 2128 | ||
2121 | } | 2129 | } |
2122 | 2130 | ||
2123 | void KABCore::updateActionMenu() | 2131 | void KABCore::updateActionMenu() |
2124 | { | 2132 | { |
2125 | UndoStack *undo = UndoStack::instance(); | 2133 | UndoStack *undo = UndoStack::instance(); |
2126 | RedoStack *redo = RedoStack::instance(); | 2134 | RedoStack *redo = RedoStack::instance(); |
2127 | 2135 | ||
2128 | if ( undo->isEmpty() ) | 2136 | if ( undo->isEmpty() ) |
2129 | mActionUndo->setText( i18n( "Undo" ) ); | 2137 | mActionUndo->setText( i18n( "Undo" ) ); |
2130 | else | 2138 | else |
2131 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2139 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2132 | 2140 | ||
2133 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2141 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2134 | 2142 | ||
2135 | if ( !redo->top() ) | 2143 | if ( !redo->top() ) |
2136 | mActionRedo->setText( i18n( "Redo" ) ); | 2144 | mActionRedo->setText( i18n( "Redo" ) ); |
2137 | else | 2145 | else |
2138 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2146 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2139 | 2147 | ||
2140 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2148 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2141 | } | 2149 | } |
2142 | 2150 | ||
2143 | void KABCore::configureKeyBindings() | 2151 | void KABCore::configureKeyBindings() |
2144 | { | 2152 | { |
2145 | #ifndef KAB_EMBEDDED | 2153 | #ifndef KAB_EMBEDDED |
2146 | KKeyDialog::configure( actionCollection(), true ); | 2154 | KKeyDialog::configure( actionCollection(), true ); |
2147 | #else //KAB_EMBEDDED | 2155 | #else //KAB_EMBEDDED |
2148 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2156 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2149 | #endif //KAB_EMBEDDED | 2157 | #endif //KAB_EMBEDDED |
2150 | } | 2158 | } |
2151 | 2159 | ||
2152 | #ifdef KAB_EMBEDDED | 2160 | #ifdef KAB_EMBEDDED |
2153 | void KABCore::configureResources() | 2161 | void KABCore::configureResources() |
2154 | { | 2162 | { |
2155 | KRES::KCMKResources dlg( this, "" , 0 ); | 2163 | KRES::KCMKResources dlg( this, "" , 0 ); |
2156 | 2164 | ||
2157 | if ( !dlg.exec() ) | 2165 | if ( !dlg.exec() ) |
2158 | return; | 2166 | return; |
2159 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2167 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2160 | } | 2168 | } |
2161 | #endif //KAB_EMBEDDED | 2169 | #endif //KAB_EMBEDDED |
2162 | 2170 | ||
2163 | 2171 | ||
2164 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2172 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2165 | * for the attendees list of an event. | 2173 | * for the attendees list of an event. |
2166 | */ | 2174 | */ |
2167 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2175 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2168 | { | 2176 | { |
2169 | QStringList nameList; | 2177 | QStringList nameList; |
2170 | QStringList emailList; | 2178 | QStringList emailList; |
2171 | QStringList uidList; | 2179 | QStringList uidList; |
2172 | 2180 | ||
2173 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2181 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2174 | uint i=0; | 2182 | uint i=0; |
2175 | for (i=0; i < list.count(); i++) | 2183 | for (i=0; i < list.count(); i++) |
2176 | { | 2184 | { |
2177 | nameList.append(list[i].realName()); | 2185 | nameList.append(list[i].realName()); |
2178 | emailList.append(list[i].preferredEmail()); | 2186 | emailList.append(list[i].preferredEmail()); |
2179 | uidList.append(list[i].uid()); | 2187 | uidList.append(list[i].uid()); |
2180 | } | 2188 | } |
2181 | 2189 | ||
2182 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2190 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2183 | 2191 | ||
2184 | } | 2192 | } |
2185 | 2193 | ||
2186 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2194 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2187 | * to put them into the calendar. | 2195 | * to put them into the calendar. |
2188 | */ | 2196 | */ |
2189 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2197 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2190 | { | 2198 | { |
2191 | // qDebug("KABCore::requestForBirthdayList"); | 2199 | // qDebug("KABCore::requestForBirthdayList"); |
2192 | QStringList birthdayList; | 2200 | QStringList birthdayList; |
2193 | QStringList anniversaryList; | 2201 | QStringList anniversaryList; |
2194 | QStringList realNameList; | 2202 | QStringList realNameList; |
2195 | QStringList preferredEmailList; | 2203 | QStringList preferredEmailList; |
2196 | QStringList assembledNameList; | 2204 | QStringList assembledNameList; |
2197 | QStringList uidList; | 2205 | QStringList uidList; |
2198 | 2206 | ||
2199 | KABC::AddressBook::Iterator it; | 2207 | KABC::AddressBook::Iterator it; |
2200 | 2208 | ||
2201 | int count = 0; | 2209 | int count = 0; |
2202 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2210 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2203 | ++count; | 2211 | ++count; |
2204 | } | 2212 | } |
2205 | QProgressBar bar(count,0 ); | 2213 | QProgressBar bar(count,0 ); |
2206 | int w = 300; | 2214 | int w = 300; |
2207 | if ( QApplication::desktop()->width() < 320 ) | 2215 | if ( QApplication::desktop()->width() < 320 ) |
2208 | w = 220; | 2216 | w = 220; |
2209 | int h = bar.sizeHint().height() ; | 2217 | int h = bar.sizeHint().height() ; |
2210 | int dw = QApplication::desktop()->width(); | 2218 | int dw = QApplication::desktop()->width(); |
2211 | int dh = QApplication::desktop()->height(); | 2219 | int dh = QApplication::desktop()->height(); |
2212 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2220 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2213 | bar.show(); | 2221 | bar.show(); |
2214 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2222 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2215 | qApp->processEvents(); | 2223 | qApp->processEvents(); |
2216 | 2224 | ||
2217 | QDate bday; | 2225 | QDate bday; |
2218 | QString anni; | 2226 | QString anni; |
2219 | QString formattedbday; | 2227 | QString formattedbday; |
2220 | 2228 | ||
2221 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2229 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2222 | { | 2230 | { |
2223 | if ( ! bar.isVisible() ) | 2231 | if ( ! bar.isVisible() ) |
2224 | return; | 2232 | return; |
2225 | bar.setProgress( count++ ); | 2233 | bar.setProgress( count++ ); |
2226 | qApp->processEvents(); | 2234 | qApp->processEvents(); |
2227 | bday = (*it).birthday().date(); | 2235 | bday = (*it).birthday().date(); |
2228 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2236 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2229 | 2237 | ||
2230 | if ( bday.isValid() || !anni.isEmpty()) | 2238 | if ( bday.isValid() || !anni.isEmpty()) |
2231 | { | 2239 | { |
2232 | if (bday.isValid()) | 2240 | if (bday.isValid()) |
2233 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2241 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2234 | else | 2242 | else |
2235 | formattedbday = "NOTVALID"; | 2243 | formattedbday = "NOTVALID"; |
2236 | if (anni.isEmpty()) | 2244 | if (anni.isEmpty()) |
2237 | anni = "INVALID"; | 2245 | anni = "INVALID"; |
2238 | 2246 | ||
2239 | birthdayList.append(formattedbday); | 2247 | birthdayList.append(formattedbday); |
2240 | anniversaryList.append(anni); //should be ISODate | 2248 | anniversaryList.append(anni); //should be ISODate |
2241 | realNameList.append((*it).realName()); | 2249 | realNameList.append((*it).realName()); |
2242 | preferredEmailList.append((*it).preferredEmail()); | 2250 | preferredEmailList.append((*it).preferredEmail()); |
2243 | assembledNameList.append((*it).assembledName()); | 2251 | assembledNameList.append((*it).assembledName()); |
2244 | uidList.append((*it).uid()); | 2252 | uidList.append((*it).uid()); |
2245 | 2253 | ||
2246 | 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() ); | 2254 | 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() ); |
2247 | } | 2255 | } |
2248 | } | 2256 | } |
2249 | 2257 | ||
2250 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2258 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2251 | 2259 | ||
2252 | } | 2260 | } |
2253 | 2261 | ||
2254 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2262 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2255 | */ | 2263 | */ |
2256 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2264 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2257 | { | 2265 | { |
2258 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2266 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2259 | 2267 | ||
2260 | QString foundUid = QString::null; | 2268 | QString foundUid = QString::null; |
2261 | if ( ! uid.isEmpty() ) { | 2269 | if ( ! uid.isEmpty() ) { |
2262 | Addressee adrr = mAddressBook->findByUid( uid ); | 2270 | Addressee adrr = mAddressBook->findByUid( uid ); |
2263 | if ( !adrr.isEmpty() ) { | 2271 | if ( !adrr.isEmpty() ) { |
2264 | foundUid = uid; | 2272 | foundUid = uid; |
2265 | } | 2273 | } |
2266 | if ( email == "sendbacklist" ) { | 2274 | if ( email == "sendbacklist" ) { |
2267 | //qDebug("ssssssssssssssssssssssend "); | 2275 | //qDebug("ssssssssssssssssssssssend "); |
2268 | QStringList nameList; | 2276 | QStringList nameList; |
2269 | QStringList emailList; | 2277 | QStringList emailList; |
2270 | QStringList uidList; | 2278 | QStringList uidList; |
2271 | nameList.append(adrr.realName()); | 2279 | nameList.append(adrr.realName()); |
2272 | emailList = adrr.emails(); | 2280 | emailList = adrr.emails(); |
2273 | uidList.append( adrr.preferredEmail()); | 2281 | uidList.append( adrr.preferredEmail()); |
2274 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2282 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2275 | return; | 2283 | return; |
2276 | } | 2284 | } |
2277 | 2285 | ||
2278 | } | 2286 | } |
2279 | 2287 | ||
2280 | if ( email == "sendbacklist" ) | 2288 | if ( email == "sendbacklist" ) |
2281 | return; | 2289 | return; |
2282 | if (foundUid.isEmpty()) | 2290 | if (foundUid.isEmpty()) |
2283 | { | 2291 | { |
2284 | //find the uid of the person first | 2292 | //find the uid of the person first |
2285 | Addressee::List namelist; | 2293 | Addressee::List namelist; |
2286 | Addressee::List emaillist; | 2294 | Addressee::List emaillist; |
2287 | 2295 | ||
2288 | if (!name.isEmpty()) | 2296 | if (!name.isEmpty()) |
2289 | namelist = mAddressBook->findByName( name ); | 2297 | namelist = mAddressBook->findByName( name ); |
2290 | 2298 | ||
2291 | if (!email.isEmpty()) | 2299 | if (!email.isEmpty()) |
2292 | emaillist = mAddressBook->findByEmail( email ); | 2300 | emaillist = mAddressBook->findByEmail( email ); |
2293 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2301 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2294 | //check if we have a match in Namelist and Emaillist | 2302 | //check if we have a match in Namelist and Emaillist |
2295 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2303 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2296 | foundUid = emaillist[0].uid(); | 2304 | foundUid = emaillist[0].uid(); |
2297 | } | 2305 | } |
2298 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2306 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2299 | foundUid = namelist[0].uid(); | 2307 | foundUid = namelist[0].uid(); |
2300 | else | 2308 | else |
2301 | { | 2309 | { |
2302 | for (int i = 0; i < namelist.count(); i++) | 2310 | for (int i = 0; i < namelist.count(); i++) |
2303 | { | 2311 | { |
2304 | for (int j = 0; j < emaillist.count(); j++) | 2312 | for (int j = 0; j < emaillist.count(); j++) |
2305 | { | 2313 | { |
2306 | if (namelist[i] == emaillist[j]) | 2314 | if (namelist[i] == emaillist[j]) |
2307 | { | 2315 | { |
2308 | foundUid = namelist[i].uid(); | 2316 | foundUid = namelist[i].uid(); |
2309 | } | 2317 | } |
2310 | } | 2318 | } |
2311 | } | 2319 | } |
2312 | } | 2320 | } |
2313 | } | 2321 | } |
2314 | else | 2322 | else |
2315 | { | 2323 | { |
2316 | foundUid = uid; | 2324 | foundUid = uid; |
2317 | } | 2325 | } |
2318 | 2326 | ||
2319 | if (!foundUid.isEmpty()) | 2327 | if (!foundUid.isEmpty()) |
2320 | { | 2328 | { |
2321 | 2329 | ||
2322 | // raise Ka/Pi if it is in the background | 2330 | // raise Ka/Pi if it is in the background |
2323 | #ifndef DESKTOP_VERSION | 2331 | #ifndef DESKTOP_VERSION |
2324 | #ifndef KORG_NODCOP | 2332 | #ifndef KORG_NODCOP |
2325 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2333 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2326 | #endif | 2334 | #endif |
2327 | #endif | 2335 | #endif |
2328 | 2336 | ||
2329 | mMainWindow->showMaximized(); | 2337 | mMainWindow->showMaximized(); |
2330 | mMainWindow-> raise(); | 2338 | mMainWindow-> raise(); |
2331 | 2339 | ||
2332 | mViewManager->setSelected( "", false); | 2340 | mViewManager->setSelected( "", false); |
2333 | mViewManager->refreshView( "" ); | 2341 | mViewManager->refreshView( "" ); |
2334 | mViewManager->setSelected( foundUid, true ); | 2342 | mViewManager->setSelected( foundUid, true ); |
2335 | mViewManager->refreshView( foundUid ); | 2343 | mViewManager->refreshView( foundUid ); |
2336 | 2344 | ||
2337 | if ( !mMultipleViewsAtOnce ) | 2345 | if ( !mMultipleViewsAtOnce ) |
2338 | { | 2346 | { |
2339 | setDetailsVisible( true ); | 2347 | setDetailsVisible( true ); |
2340 | mActionDetails->setChecked(true); | 2348 | mActionDetails->setChecked(true); |
2341 | } | 2349 | } |
2342 | } | 2350 | } |
2343 | } | 2351 | } |
2344 | 2352 | ||
2345 | void KABCore::whatsnew() | 2353 | void KABCore::whatsnew() |
2346 | { | 2354 | { |
2347 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2355 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2348 | } | 2356 | } |
2349 | void KABCore::synchowto() | 2357 | void KABCore::synchowto() |
2350 | { | 2358 | { |
2351 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2359 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2352 | } | 2360 | } |
2353 | 2361 | void KABCore::kdesynchowto() | |
2362 | { | ||
2363 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | ||
2364 | } | ||
2365 | void KABCore::multisynchowto() | ||
2366 | { | ||
2367 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | ||
2368 | } | ||
2354 | void KABCore::faq() | 2369 | void KABCore::faq() |
2355 | { | 2370 | { |
2356 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2371 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2357 | } | 2372 | } |
2358 | 2373 | ||
2359 | #include <libkcal/syncdefines.h> | 2374 | #include <libkcal/syncdefines.h> |
2360 | 2375 | ||
2361 | KABC::Addressee KABCore::getLastSyncAddressee() | 2376 | KABC::Addressee KABCore::getLastSyncAddressee() |
2362 | { | 2377 | { |
2363 | Addressee lse; | 2378 | Addressee lse; |
2364 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2379 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2365 | 2380 | ||
2366 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2381 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2367 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2382 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2368 | if (lse.isEmpty()) { | 2383 | if (lse.isEmpty()) { |
2369 | qDebug("Creating new last-syncAddressee "); | 2384 | qDebug("Creating new last-syncAddressee "); |
2370 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2385 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2371 | QString sum = ""; | 2386 | QString sum = ""; |
2372 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2387 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2373 | sum = "E: "; | 2388 | sum = "E: "; |
2374 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2389 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2375 | lse.setRevision( mLastAddressbookSync ); | 2390 | lse.setRevision( mLastAddressbookSync ); |
2376 | lse.setCategories( i18n("SyncEvent") ); | 2391 | lse.setCategories( i18n("SyncEvent") ); |
2377 | mAddressBook->insertAddressee( lse ); | 2392 | mAddressBook->insertAddressee( lse ); |
2378 | } | 2393 | } |
2379 | return lse; | 2394 | return lse; |
2380 | } | 2395 | } |
2381 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2396 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2382 | { | 2397 | { |
2383 | 2398 | ||
2384 | //void setZaurusId(int id); | 2399 | //void setZaurusId(int id); |
2385 | // int zaurusId() const; | 2400 | // int zaurusId() const; |
2386 | // void setZaurusUid(int id); | 2401 | // void setZaurusUid(int id); |
2387 | // int zaurusUid() const; | 2402 | // int zaurusUid() const; |
2388 | // void setZaurusStat(int id); | 2403 | // void setZaurusStat(int id); |
2389 | // int zaurusStat() const; | 2404 | // int zaurusStat() const; |
2390 | // 0 equal | 2405 | // 0 equal |
2391 | // 1 take local | 2406 | // 1 take local |
2392 | // 2 take remote | 2407 | // 2 take remote |
2393 | // 3 cancel | 2408 | // 3 cancel |
2394 | QDateTime lastSync = mLastAddressbookSync; | 2409 | QDateTime lastSync = mLastAddressbookSync; |
2395 | QDateTime localMod = local->revision(); | 2410 | QDateTime localMod = local->revision(); |
2396 | QDateTime remoteMod = remote->revision(); | 2411 | QDateTime remoteMod = remote->revision(); |
2397 | 2412 | ||
2398 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2413 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2399 | 2414 | ||
2400 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2415 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2401 | bool remCh, locCh; | 2416 | bool remCh, locCh; |
2402 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2417 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2403 | 2418 | ||
2404 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2419 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2405 | locCh = ( localMod > mLastAddressbookSync ); | 2420 | locCh = ( localMod > mLastAddressbookSync ); |
2406 | if ( !remCh && ! locCh ) { | 2421 | if ( !remCh && ! locCh ) { |
2407 | //qDebug("both not changed "); | 2422 | //qDebug("both not changed "); |
2408 | lastSync = localMod.addDays(1); | 2423 | lastSync = localMod.addDays(1); |
2409 | if ( mode <= SYNC_PREF_ASK ) | 2424 | if ( mode <= SYNC_PREF_ASK ) |
2410 | return 0; | 2425 | return 0; |
2411 | } else { | 2426 | } else { |
2412 | if ( locCh ) { | 2427 | if ( locCh ) { |
2413 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2428 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2414 | lastSync = localMod.addDays( -1 ); | 2429 | lastSync = localMod.addDays( -1 ); |
2415 | if ( !remCh ) | 2430 | if ( !remCh ) |
2416 | remoteMod =( lastSync.addDays( -1 ) ); | 2431 | remoteMod =( lastSync.addDays( -1 ) ); |
2417 | } else { | 2432 | } else { |
2418 | //qDebug(" not loc changed "); | 2433 | //qDebug(" not loc changed "); |
2419 | lastSync = localMod.addDays( 1 ); | 2434 | lastSync = localMod.addDays( 1 ); |
2420 | if ( remCh ) | 2435 | if ( remCh ) |
2421 | remoteMod =( lastSync.addDays( 1 ) ); | 2436 | remoteMod =( lastSync.addDays( 1 ) ); |
2422 | 2437 | ||
2423 | } | 2438 | } |
2424 | } | 2439 | } |
2425 | full = true; | 2440 | full = true; |
2426 | if ( mode < SYNC_PREF_ASK ) | 2441 | if ( mode < SYNC_PREF_ASK ) |
2427 | mode = SYNC_PREF_ASK; | 2442 | mode = SYNC_PREF_ASK; |
2428 | } else { | 2443 | } else { |
2429 | if ( localMod == remoteMod ) | 2444 | if ( localMod == remoteMod ) |
2430 | return 0; | 2445 | return 0; |
2431 | 2446 | ||
2432 | } | 2447 | } |
2433 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2448 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2434 | 2449 | ||
2435 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2450 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2436 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2451 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2437 | //full = true; //debug only | 2452 | //full = true; //debug only |
2438 | if ( full ) { | 2453 | if ( full ) { |
2439 | bool equ = ( (*local) == (*remote) ); | 2454 | bool equ = ( (*local) == (*remote) ); |
2440 | if ( equ ) { | 2455 | if ( equ ) { |
2441 | //qDebug("equal "); | 2456 | //qDebug("equal "); |
2442 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2457 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2443 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2458 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2444 | } | 2459 | } |
2445 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2460 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2446 | return 0; | 2461 | return 0; |
2447 | 2462 | ||
2448 | }//else //debug only | 2463 | }//else //debug only |
2449 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2464 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2450 | } | 2465 | } |
2451 | int result; | 2466 | int result; |
2452 | bool localIsNew; | 2467 | bool localIsNew; |
2453 | //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() ); | 2468 | //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() ); |
2454 | 2469 | ||
2455 | if ( full && mode < SYNC_PREF_NEWEST ) | 2470 | if ( full && mode < SYNC_PREF_NEWEST ) |
2456 | mode = SYNC_PREF_ASK; | 2471 | mode = SYNC_PREF_ASK; |
2457 | 2472 | ||
2458 | switch( mode ) { | 2473 | switch( mode ) { |
2459 | case SYNC_PREF_LOCAL: | 2474 | case SYNC_PREF_LOCAL: |
2460 | if ( lastSync > remoteMod ) | 2475 | if ( lastSync > remoteMod ) |
2461 | return 1; | 2476 | return 1; |
2462 | if ( lastSync > localMod ) | 2477 | if ( lastSync > localMod ) |
2463 | return 2; | 2478 | return 2; |
2464 | return 1; | 2479 | return 1; |
2465 | break; | 2480 | break; |
2466 | case SYNC_PREF_REMOTE: | 2481 | case SYNC_PREF_REMOTE: |
2467 | if ( lastSync > remoteMod ) | 2482 | if ( lastSync > remoteMod ) |
2468 | return 1; | 2483 | return 1; |
2469 | if ( lastSync > localMod ) | 2484 | if ( lastSync > localMod ) |
2470 | return 2; | 2485 | return 2; |
2471 | return 2; | 2486 | return 2; |
2472 | break; | 2487 | break; |
2473 | case SYNC_PREF_NEWEST: | 2488 | case SYNC_PREF_NEWEST: |
2474 | if ( localMod > remoteMod ) | 2489 | if ( localMod > remoteMod ) |
2475 | return 1; | 2490 | return 1; |
2476 | else | 2491 | else |
2477 | return 2; | 2492 | return 2; |
2478 | break; | 2493 | break; |
2479 | case SYNC_PREF_ASK: | 2494 | case SYNC_PREF_ASK: |
2480 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2495 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2481 | if ( lastSync > remoteMod ) | 2496 | if ( lastSync > remoteMod ) |
2482 | return 1; | 2497 | return 1; |
2483 | if ( lastSync > localMod ) | 2498 | if ( lastSync > localMod ) |
2484 | return 2; | 2499 | return 2; |
2485 | localIsNew = localMod >= remoteMod; | 2500 | localIsNew = localMod >= remoteMod; |
2486 | //qDebug("conflict! ************************************** "); | 2501 | //qDebug("conflict! ************************************** "); |
2487 | { | 2502 | { |
2488 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2503 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2489 | result = acd.executeD(localIsNew); | 2504 | result = acd.executeD(localIsNew); |
2490 | return result; | 2505 | return result; |
2491 | } | 2506 | } |
2492 | break; | 2507 | break; |
2493 | case SYNC_PREF_FORCE_LOCAL: | 2508 | case SYNC_PREF_FORCE_LOCAL: |
2494 | return 1; | 2509 | return 1; |
2495 | break; | 2510 | break; |
2496 | case SYNC_PREF_FORCE_REMOTE: | 2511 | case SYNC_PREF_FORCE_REMOTE: |
2497 | return 2; | 2512 | return 2; |
2498 | break; | 2513 | break; |
2499 | 2514 | ||
2500 | default: | 2515 | default: |
2501 | // SYNC_PREF_TAKE_BOTH not implemented | 2516 | // SYNC_PREF_TAKE_BOTH not implemented |
2502 | break; | 2517 | break; |
2503 | } | 2518 | } |
2504 | return 0; | 2519 | return 0; |
2505 | } | 2520 | } |
2506 | 2521 | ||
2507 | 2522 | ||
2508 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2523 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2509 | { | 2524 | { |
2510 | bool syncOK = true; | 2525 | bool syncOK = true; |
2511 | int addedAddressee = 0; | 2526 | int addedAddressee = 0; |
2512 | int addedAddresseeR = 0; | 2527 | int addedAddresseeR = 0; |
2513 | int deletedAddresseeR = 0; | 2528 | int deletedAddresseeR = 0; |
2514 | int deletedAddresseeL = 0; | 2529 | int deletedAddresseeL = 0; |
2515 | int changedLocal = 0; | 2530 | int changedLocal = 0; |
2516 | int changedRemote = 0; | 2531 | int changedRemote = 0; |
2517 | 2532 | ||
2518 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2533 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2519 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2534 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2520 | 2535 | ||
2521 | //QPtrList<Addressee> el = local->rawAddressees(); | 2536 | //QPtrList<Addressee> el = local->rawAddressees(); |
2522 | Addressee addresseeR; | 2537 | Addressee addresseeR; |
2523 | QString uid; | 2538 | QString uid; |
2524 | int take; | 2539 | int take; |
2525 | Addressee addresseeL; | 2540 | Addressee addresseeL; |
2526 | Addressee addresseeRSync; | 2541 | Addressee addresseeRSync; |
2527 | Addressee addresseeLSync; | 2542 | Addressee addresseeLSync; |
2528 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2543 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2529 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2544 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2530 | bool fullDateRange = false; | 2545 | bool fullDateRange = false; |
2531 | local->resetTempSyncStat(); | 2546 | local->resetTempSyncStat(); |
2532 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2547 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2533 | if ( syncManager->syncWithDesktop() ) { | 2548 | if ( syncManager->syncWithDesktop() ) { |
2534 | // remote->removeSyncInfo( QString());//remove all info | 2549 | // remote->removeSyncInfo( QString());//remove all info |
2535 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2550 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2536 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2551 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2537 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2552 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2538 | } else { | 2553 | } else { |
2539 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2554 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2540 | } | 2555 | } |
2541 | } | 2556 | } |
2542 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2557 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2543 | addresseeLSync = getLastSyncAddressee(); | 2558 | addresseeLSync = getLastSyncAddressee(); |
2544 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2559 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2545 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2560 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2546 | if ( !addresseeR.isEmpty() ) { | 2561 | if ( !addresseeR.isEmpty() ) { |
2547 | addresseeRSync = addresseeR; | 2562 | addresseeRSync = addresseeR; |
2548 | remote->removeAddressee(addresseeR ); | 2563 | remote->removeAddressee(addresseeR ); |
2549 | 2564 | ||
2550 | } else { | 2565 | } else { |
2551 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2566 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2552 | addresseeRSync = addresseeLSync ; | 2567 | addresseeRSync = addresseeLSync ; |
2553 | } else { | 2568 | } else { |
2554 | qDebug("FULLDATE 1"); | 2569 | qDebug("FULLDATE 1"); |
2555 | fullDateRange = true; | 2570 | fullDateRange = true; |
2556 | Addressee newAdd; | 2571 | Addressee newAdd; |
2557 | addresseeRSync = newAdd; | 2572 | addresseeRSync = newAdd; |
2558 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2573 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2559 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2574 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2560 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2575 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2561 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2576 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2562 | } | 2577 | } |
2563 | } | 2578 | } |
2564 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2579 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2565 | qDebug("FULLDATE 2"); | 2580 | qDebug("FULLDATE 2"); |
2566 | fullDateRange = true; | 2581 | fullDateRange = true; |
2567 | } | 2582 | } |
2568 | if ( ! fullDateRange ) { | 2583 | if ( ! fullDateRange ) { |
2569 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2584 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2570 | 2585 | ||
2571 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2586 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2572 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2587 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2573 | fullDateRange = true; | 2588 | fullDateRange = true; |
2574 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2589 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2575 | } | 2590 | } |
2576 | } | 2591 | } |
2577 | // fullDateRange = true; // debug only! | 2592 | // fullDateRange = true; // debug only! |
2578 | if ( fullDateRange ) | 2593 | if ( fullDateRange ) |
2579 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2594 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2580 | else | 2595 | else |
2581 | mLastAddressbookSync = addresseeLSync.revision(); | 2596 | mLastAddressbookSync = addresseeLSync.revision(); |
2582 | // for resyncing if own file has changed | 2597 | // for resyncing if own file has changed |
2583 | // PENDING fixme later when implemented | 2598 | // PENDING fixme later when implemented |
2584 | #if 0 | 2599 | #if 0 |
2585 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2600 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2586 | mLastAddressbookSync = loadedFileVersion; | 2601 | mLastAddressbookSync = loadedFileVersion; |
2587 | qDebug("setting mLastAddressbookSync "); | 2602 | qDebug("setting mLastAddressbookSync "); |
2588 | } | 2603 | } |
2589 | #endif | 2604 | #endif |
2590 | 2605 | ||
2591 | //qDebug("*************************** "); | 2606 | //qDebug("*************************** "); |
2592 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2607 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2593 | QStringList er = remote->uidList(); | 2608 | QStringList er = remote->uidList(); |
2594 | Addressee inR ;//= er.first(); | 2609 | Addressee inR ;//= er.first(); |
2595 | Addressee inL; | 2610 | Addressee inL; |
2596 | 2611 | ||
2597 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2612 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2598 | 2613 | ||
2599 | int modulo = (er.count()/10)+1; | 2614 | int modulo = (er.count()/10)+1; |
2600 | int incCounter = 0; | 2615 | int incCounter = 0; |
2601 | while ( incCounter < er.count()) { | 2616 | while ( incCounter < er.count()) { |
2602 | if (syncManager->isProgressBarCanceled()) | 2617 | if (syncManager->isProgressBarCanceled()) |
2603 | return false; | 2618 | return false; |
2604 | if ( incCounter % modulo == 0 ) | 2619 | if ( incCounter % modulo == 0 ) |
2605 | syncManager->showProgressBar(incCounter); | 2620 | syncManager->showProgressBar(incCounter); |
2606 | 2621 | ||
2607 | uid = er[ incCounter ]; | 2622 | uid = er[ incCounter ]; |
2608 | bool skipIncidence = false; | 2623 | bool skipIncidence = false; |
2609 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2624 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2610 | skipIncidence = true; | 2625 | skipIncidence = true; |
2611 | QString idS,OidS; | 2626 | QString idS,OidS; |
2612 | qApp->processEvents(); | 2627 | qApp->processEvents(); |
2613 | if ( !skipIncidence ) { | 2628 | if ( !skipIncidence ) { |
2614 | inL = local->findByUid( uid ); | 2629 | inL = local->findByUid( uid ); |
2615 | inR = remote->findByUid( uid ); | 2630 | inR = remote->findByUid( uid ); |
2616 | //inL.setResource( 0 ); | 2631 | //inL.setResource( 0 ); |
2617 | //inR.setResource( 0 ); | 2632 | //inR.setResource( 0 ); |
2618 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2633 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2619 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2634 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2620 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2635 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2621 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2636 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2622 | if ( take == 3 ) | 2637 | if ( take == 3 ) |
2623 | return false; | 2638 | return false; |
2624 | if ( take == 1 ) {// take local | 2639 | if ( take == 1 ) {// take local |
2625 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2640 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2626 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2641 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2627 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2642 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2628 | local->insertAddressee( inL, false ); | 2643 | local->insertAddressee( inL, false ); |
2629 | idS = inR.externalUID(); | 2644 | idS = inR.externalUID(); |
2630 | OidS = inR.originalExternalUID(); | 2645 | OidS = inR.originalExternalUID(); |
2631 | } | 2646 | } |
2632 | else | 2647 | else |
2633 | idS = inR.IDStr(); | 2648 | idS = inR.IDStr(); |
2634 | remote->removeAddressee( inR ); | 2649 | remote->removeAddressee( inR ); |
2635 | inR = inL; | 2650 | inR = inL; |
2636 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2651 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2637 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2652 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2638 | inR.setOriginalExternalUID( OidS ); | 2653 | inR.setOriginalExternalUID( OidS ); |
2639 | inR.setExternalUID( idS ); | 2654 | inR.setExternalUID( idS ); |
2640 | if ( syncManager->syncWithDesktop() ) | 2655 | if ( syncManager->syncWithDesktop() ) |
2641 | inR.setIDStr("changed" ); | 2656 | inR.setIDStr("changed" ); |
2642 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 2657 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2643 | } else { | 2658 | } else { |
2644 | inR.setIDStr( idS ); | 2659 | inR.setIDStr( idS ); |
2645 | } | 2660 | } |
2646 | inR.setResource( 0 ); | 2661 | inR.setResource( 0 ); |
2647 | remote->insertAddressee( inR , false); | 2662 | remote->insertAddressee( inR , false); |
2648 | ++changedRemote; | 2663 | ++changedRemote; |
2649 | } else { // take == 2 take remote | 2664 | } else { // take == 2 take remote |
2650 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2665 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2651 | if ( inR.revision().date().year() < 2004 ) | 2666 | if ( inR.revision().date().year() < 2004 ) |
2652 | inR.setRevision( modifiedCalendar ); | 2667 | inR.setRevision( modifiedCalendar ); |
2653 | } | 2668 | } |
2654 | idS = inL.IDStr(); | 2669 | idS = inL.IDStr(); |
2655 | local->removeAddressee( inL ); | 2670 | local->removeAddressee( inL ); |
2656 | inL = inR; | 2671 | inL = inR; |
2657 | inL.setIDStr( idS ); | 2672 | inL.setIDStr( idS ); |
2658 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2673 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2659 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2674 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2660 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2675 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2661 | } | 2676 | } |
2662 | inL.setResource( 0 ); | 2677 | inL.setResource( 0 ); |
2663 | local->insertAddressee( inL , false ); | 2678 | local->insertAddressee( inL , false ); |
2664 | ++changedLocal; | 2679 | ++changedLocal; |
2665 | } | 2680 | } |
2666 | } | 2681 | } |
2667 | } | 2682 | } |
2668 | } else { // no conflict | 2683 | } else { // no conflict |
2669 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2684 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2670 | QString des = addresseeLSync.note(); | 2685 | QString des = addresseeLSync.note(); |
2671 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2686 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2672 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2687 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2673 | remote->insertAddressee( inR, false ); | 2688 | remote->insertAddressee( inR, false ); |
2674 | ++deletedAddresseeR; | 2689 | ++deletedAddresseeR; |
2675 | } else { | 2690 | } else { |
2676 | inR.setRevision( modifiedCalendar ); | 2691 | inR.setRevision( modifiedCalendar ); |
2677 | remote->insertAddressee( inR, false ); | 2692 | remote->insertAddressee( inR, false ); |
2678 | inL = inR; | 2693 | inL = inR; |
2679 | inL.setResource( 0 ); | 2694 | inL.setResource( 0 ); |
2680 | local->insertAddressee( inL , false); | 2695 | local->insertAddressee( inL , false); |
2681 | ++addedAddressee; | 2696 | ++addedAddressee; |
2682 | } | 2697 | } |
2683 | } else { | 2698 | } else { |
2684 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2699 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2685 | inR.setRevision( modifiedCalendar ); | 2700 | inR.setRevision( modifiedCalendar ); |
2686 | remote->insertAddressee( inR, false ); | 2701 | remote->insertAddressee( inR, false ); |
2687 | inR.setResource( 0 ); | 2702 | inR.setResource( 0 ); |
2688 | local->insertAddressee( inR, false ); | 2703 | local->insertAddressee( inR, false ); |
2689 | ++addedAddressee; | 2704 | ++addedAddressee; |
2690 | } else { | 2705 | } else { |
2691 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2706 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2692 | remote->removeAddressee( inR ); | 2707 | remote->removeAddressee( inR ); |
2693 | ++deletedAddresseeR; | 2708 | ++deletedAddresseeR; |
2694 | } | 2709 | } |
2695 | } | 2710 | } |
2696 | } | 2711 | } |
2697 | } | 2712 | } |
2698 | ++incCounter; | 2713 | ++incCounter; |
2699 | } | 2714 | } |
2700 | er.clear(); | 2715 | er.clear(); |
2701 | QStringList el = local->uidList(); | 2716 | QStringList el = local->uidList(); |
2702 | modulo = (el.count()/10)+1; | 2717 | modulo = (el.count()/10)+1; |
2703 | 2718 | ||
2704 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2719 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2705 | incCounter = 0; | 2720 | incCounter = 0; |
2706 | while ( incCounter < el.count()) { | 2721 | while ( incCounter < el.count()) { |
2707 | qApp->processEvents(); | 2722 | qApp->processEvents(); |
2708 | if (syncManager->isProgressBarCanceled()) | 2723 | if (syncManager->isProgressBarCanceled()) |
2709 | return false; | 2724 | return false; |
2710 | if ( incCounter % modulo == 0 ) | 2725 | if ( incCounter % modulo == 0 ) |
2711 | syncManager->showProgressBar(incCounter); | 2726 | syncManager->showProgressBar(incCounter); |
2712 | uid = el[ incCounter ]; | 2727 | uid = el[ incCounter ]; |
2713 | bool skipIncidence = false; | 2728 | bool skipIncidence = false; |
2714 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2729 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2715 | skipIncidence = true; | 2730 | skipIncidence = true; |
2716 | if ( !skipIncidence ) { | 2731 | if ( !skipIncidence ) { |
2717 | inL = local->findByUid( uid ); | 2732 | inL = local->findByUid( uid ); |
2718 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2733 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2719 | inR = remote->findByUid( uid ); | 2734 | inR = remote->findByUid( uid ); |
2720 | if ( inR.isEmpty() ) { | 2735 | if ( inR.isEmpty() ) { |
2721 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2736 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2722 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2737 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2723 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2738 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2724 | local->removeAddressee( inL ); | 2739 | local->removeAddressee( inL ); |
2725 | ++deletedAddresseeL; | 2740 | ++deletedAddresseeL; |
2726 | } else { | 2741 | } else { |
2727 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2742 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2728 | inL.removeID(mCurrentSyncDevice ); | 2743 | inL.removeID(mCurrentSyncDevice ); |
2729 | ++addedAddresseeR; | 2744 | ++addedAddresseeR; |
2730 | inL.setRevision( modifiedCalendar ); | 2745 | inL.setRevision( modifiedCalendar ); |
2731 | local->insertAddressee( inL, false ); | 2746 | local->insertAddressee( inL, false ); |
2732 | inR = inL; | 2747 | inR = inL; |
2733 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2748 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2734 | inR.setResource( 0 ); | 2749 | inR.setResource( 0 ); |
2735 | remote->insertAddressee( inR, false ); | 2750 | remote->insertAddressee( inR, false ); |
2736 | } | 2751 | } |
2737 | } | 2752 | } |
2738 | } else { | 2753 | } else { |
2739 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2754 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2740 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2755 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2741 | local->removeAddressee( inL ); | 2756 | local->removeAddressee( inL ); |
2742 | ++deletedAddresseeL; | 2757 | ++deletedAddresseeL; |
2743 | } else { | 2758 | } else { |
2744 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2759 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2745 | ++addedAddresseeR; | 2760 | ++addedAddresseeR; |
2746 | inL.setRevision( modifiedCalendar ); | 2761 | inL.setRevision( modifiedCalendar ); |
2747 | local->insertAddressee( inL, false ); | 2762 | local->insertAddressee( inL, false ); |
2748 | inR = inL; | 2763 | inR = inL; |
2749 | inR.setResource( 0 ); | 2764 | inR.setResource( 0 ); |
2750 | remote->insertAddressee( inR, false ); | 2765 | remote->insertAddressee( inR, false ); |
2751 | } | 2766 | } |
2752 | } | 2767 | } |
2753 | } | 2768 | } |
2754 | } | 2769 | } |
2755 | } | 2770 | } |
2756 | } | 2771 | } |
2757 | ++incCounter; | 2772 | ++incCounter; |
2758 | } | 2773 | } |
2759 | el.clear(); | 2774 | el.clear(); |
2760 | syncManager->hideProgressBar(); | 2775 | syncManager->hideProgressBar(); |
2761 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2776 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2762 | // get rid of micro seconds | 2777 | // get rid of micro seconds |
2763 | QTime t = mLastAddressbookSync.time(); | 2778 | QTime t = mLastAddressbookSync.time(); |
2764 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2779 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2765 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2780 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2766 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2781 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2767 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2782 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2768 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2783 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2769 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2784 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2770 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2785 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2771 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2786 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2772 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2787 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2773 | addresseeRSync.setNote( "" ) ; | 2788 | addresseeRSync.setNote( "" ) ; |
2774 | addresseeLSync.setNote( "" ); | 2789 | addresseeLSync.setNote( "" ); |
2775 | 2790 | ||
2776 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2791 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2777 | remote->insertAddressee( addresseeRSync, false ); | 2792 | remote->insertAddressee( addresseeRSync, false ); |
2778 | local->insertAddressee( addresseeLSync, false ); | 2793 | local->insertAddressee( addresseeLSync, false ); |
2779 | QString mes; | 2794 | QString mes; |
2780 | 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2795 | 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2781 | if ( syncManager->mShowSyncSummary ) { | ||
2782 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | ||
2783 | } | ||
2784 | qDebug( mes ); | 2796 | qDebug( mes ); |
2797 | if ( syncManager->mShowSyncSummary ) { | ||
2798 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | ||
2799 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | ||
2800 | qDebug("cancelled "); | ||
2801 | return false; | ||
2802 | } | ||
2803 | } | ||
2785 | return syncOK; | 2804 | return syncOK; |
2786 | } | 2805 | } |
2787 | 2806 | ||
2788 | 2807 | ||
2789 | //this is a overwritten callbackmethods from the syncinterface | 2808 | //this is a overwritten callbackmethods from the syncinterface |
2790 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2809 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2791 | { | 2810 | { |
2792 | 2811 | ||
2793 | //pending prepare addresseeview for output | 2812 | //pending prepare addresseeview for output |
2794 | //pending detect, if remote file has REV field. if not switch to external sync | 2813 | //pending detect, if remote file has REV field. if not switch to external sync |
2795 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2814 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2796 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2815 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2797 | 2816 | ||
2798 | AddressBook abLocal(filename,"syncContact"); | 2817 | AddressBook abLocal(filename,"syncContact"); |
2799 | bool syncOK = false; | 2818 | bool syncOK = false; |
2800 | if ( abLocal.load() ) { | 2819 | if ( abLocal.load() ) { |
2801 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2820 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2802 | bool external = false; | 2821 | bool external = false; |
2803 | bool isXML = false; | 2822 | bool isXML = false; |
2804 | if ( filename.right(4) == ".xml") { | 2823 | if ( filename.right(4) == ".xml") { |
2805 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2824 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2806 | isXML = true; | 2825 | isXML = true; |
2807 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2826 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2808 | } else { | 2827 | } else { |
2809 | external = !manager->mIsKapiFile; | 2828 | external = !manager->mIsKapiFile; |
2810 | if ( external ) { | 2829 | if ( external ) { |
2811 | qDebug("Setting vcf mode to external "); | 2830 | qDebug("Setting vcf mode to external "); |
2812 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2831 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2813 | AddressBook::Iterator it; | 2832 | AddressBook::Iterator it; |
2814 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2833 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2815 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2834 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2816 | (*it).computeCsum( mCurrentSyncDevice ); | 2835 | (*it).computeCsum( mCurrentSyncDevice ); |
2817 | } | 2836 | } |
2818 | } | 2837 | } |
2819 | } | 2838 | } |
2820 | //AddressBook::Iterator it; | 2839 | //AddressBook::Iterator it; |
2821 | //QStringList vcards; | 2840 | //QStringList vcards; |
2822 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2841 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2823 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2842 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2824 | //} | 2843 | //} |
2825 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2844 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2826 | if ( syncOK ) { | 2845 | if ( syncOK ) { |
2827 | if ( syncManager->mWriteBackFile ) | 2846 | if ( syncManager->mWriteBackFile ) |
2828 | { | 2847 | { |
2829 | if ( external ) | 2848 | if ( external ) |
2830 | abLocal.removeSyncAddressees( !isXML); | 2849 | abLocal.removeSyncAddressees( !isXML); |
2831 | qDebug("Saving remote AB "); | 2850 | qDebug("Saving remote AB "); |
2832 | if ( ! abLocal.saveAB()) | 2851 | if ( ! abLocal.saveAB()) |
2833 | qDebug("Error writing back AB to file "); | 2852 | qDebug("Error writing back AB to file "); |
2834 | if ( external ) { | 2853 | if ( external ) { |
2835 | // afterwrite processing | 2854 | // afterwrite processing |
2836 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 2855 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
2837 | } | 2856 | } |
2838 | } | 2857 | } |
2839 | } | 2858 | } |
2840 | setModified(); | 2859 | setModified(); |
2841 | 2860 | ||
2842 | } | 2861 | } |
2843 | if ( syncOK ) | 2862 | if ( syncOK ) |
2844 | mViewManager->refreshView(); | 2863 | mViewManager->refreshView(); |
2845 | return syncOK; | 2864 | return syncOK; |
2846 | 2865 | ||
2847 | } | 2866 | } |
2848 | void KABCore::removeSyncInfo( QString syncProfile) | 2867 | void KABCore::removeSyncInfo( QString syncProfile) |
2849 | { | 2868 | { |
2850 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 2869 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
2851 | mAddressBook->removeSyncInfo( syncProfile ); | 2870 | mAddressBook->removeSyncInfo( syncProfile ); |
2852 | setModified(); | 2871 | setModified(); |
2853 | } | 2872 | } |
2854 | 2873 | ||
2855 | 2874 | ||
2856 | //this is a overwritten callbackmethods from the syncinterface | 2875 | //this is a overwritten callbackmethods from the syncinterface |
2857 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2876 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2858 | { | 2877 | { |
2859 | if ( resource == "phone" ) | 2878 | if ( resource == "phone" ) |
2860 | return syncPhone(); | 2879 | return syncPhone(); |
2861 | disableBR( true ); | 2880 | disableBR( true ); |
2862 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2881 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2863 | 2882 | ||
2864 | AddressBook abLocal( resource,"syncContact"); | 2883 | AddressBook abLocal( resource,"syncContact"); |
2865 | bool syncOK = false; | 2884 | bool syncOK = false; |
2866 | if ( abLocal.load() ) { | 2885 | if ( abLocal.load() ) { |
2867 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2886 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2868 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2887 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2869 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2888 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2870 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2889 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2871 | if ( syncOK ) { | 2890 | if ( syncOK ) { |
2872 | if ( syncManager->mWriteBackFile ) { | 2891 | if ( syncManager->mWriteBackFile ) { |
2873 | abLocal.removeSyncAddressees( false ); | 2892 | abLocal.removeSyncAddressees( false ); |
2874 | abLocal.saveAB(); | 2893 | abLocal.saveAB(); |
2875 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 2894 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
2876 | } | 2895 | } |
2877 | } | 2896 | } else |
2897 | message( i18n("Sync cancelled or failed.") ); | ||
2878 | setModified(); | 2898 | setModified(); |
2879 | } | 2899 | } |
2880 | if ( syncOK ) | 2900 | if ( syncOK ) |
2881 | mViewManager->refreshView(); | 2901 | mViewManager->refreshView(); |
2882 | disableBR( false ); | 2902 | disableBR( false ); |
2883 | return syncOK; | 2903 | return syncOK; |
2884 | 2904 | ||
2885 | } | 2905 | } |
2886 | void KABCore::message( QString m ) | 2906 | void KABCore::message( QString m ) |
2887 | { | 2907 | { |
2888 | topLevelWidget()->setCaption( m ); | 2908 | topLevelWidget()->setCaption( m ); |
2889 | mMessageTimer->start( 15000, true ); | 2909 | mMessageTimer->start( 15000, true ); |
2890 | } | 2910 | } |
2891 | bool KABCore::syncPhone() | 2911 | bool KABCore::syncPhone() |
2892 | { | 2912 | { |
2893 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2913 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2894 | QString fileName = getPhoneFile(); | 2914 | QString fileName = getPhoneFile(); |
2895 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2915 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2896 | message(i18n("Phone access failed!")); | 2916 | message(i18n("Phone access failed!")); |
2897 | return false; | 2917 | return false; |
2898 | } | 2918 | } |
2899 | AddressBook abLocal( fileName,"syncContact"); | 2919 | AddressBook abLocal( fileName,"syncContact"); |
2900 | bool syncOK = false; | 2920 | bool syncOK = false; |
2901 | { | 2921 | { |
2902 | abLocal.importFromFile( fileName ); | 2922 | abLocal.importFromFile( fileName ); |
2903 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2923 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2904 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2924 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2905 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2925 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2906 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2926 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2907 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2927 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2908 | if ( syncOK ) { | 2928 | if ( syncOK ) { |
2909 | if ( syncManager->mWriteBackFile ) { | 2929 | if ( syncManager->mWriteBackFile ) { |
2910 | abLocal.removeSyncAddressees( true ); | 2930 | abLocal.removeSyncAddressees( true ); |
2911 | abLocal.saveABphone( fileName ); | 2931 | abLocal.saveABphone( fileName ); |
2912 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2932 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2913 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2933 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2914 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 2934 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
2915 | } | 2935 | } |
2916 | } | 2936 | } |
2917 | setModified(); | 2937 | setModified(); |
2918 | } | 2938 | } |
2919 | if ( syncOK ) | 2939 | if ( syncOK ) |
2920 | mViewManager->refreshView(); | 2940 | mViewManager->refreshView(); |
2921 | return syncOK; | 2941 | return syncOK; |
2922 | } | 2942 | } |
2923 | void KABCore::getFile( bool success ) | 2943 | void KABCore::getFile( bool success ) |
2924 | { | 2944 | { |
2925 | if ( ! success ) { | 2945 | if ( ! success ) { |
2926 | message( i18n("Error receiving file. Nothing changed!") ); | 2946 | message( i18n("Error receiving file. Nothing changed!") ); |
2927 | return; | 2947 | return; |
2928 | } | 2948 | } |
2929 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2949 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2930 | if ( count ) | 2950 | if ( count ) |
2931 | setModified( true ); | 2951 | setModified( true ); |
2932 | message( i18n("Pi-Sync successful!") ); | 2952 | message( i18n("Pi-Sync successful!") ); |
2933 | mViewManager->refreshView(); | 2953 | mViewManager->refreshView(); |
2934 | } | 2954 | } |
2935 | void KABCore::syncFileRequest() | 2955 | void KABCore::syncFileRequest() |
2936 | { | 2956 | { |
2937 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 2957 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
2938 | syncManager->slotSyncMenu( 999 ); | 2958 | syncManager->slotSyncMenu( 999 ); |
2939 | } | 2959 | } |
2940 | mAddressBook->export2File( sentSyncFile() ); | 2960 | mAddressBook->export2File( sentSyncFile() ); |
2941 | } | 2961 | } |
2942 | QString KABCore::sentSyncFile() | 2962 | QString KABCore::sentSyncFile() |
2943 | { | 2963 | { |
2944 | #ifdef DESKTOP_VERSION | 2964 | #ifdef DESKTOP_VERSION |
2945 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2965 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2946 | #else | 2966 | #else |
2947 | return QString( "/tmp/copysyncab.vcf" ); | 2967 | return QString( "/tmp/copysyncab.vcf" ); |
2948 | #endif | 2968 | #endif |
2949 | } | 2969 | } |
2950 | 2970 | ||
2951 | void KABCore::setCaptionBack() | 2971 | void KABCore::setCaptionBack() |
2952 | { | 2972 | { |
2953 | mMessageTimer->stop(); | 2973 | mMessageTimer->stop(); |
2954 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2974 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2955 | } | 2975 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 6831ec9..c01d598 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,504 +1,508 @@ | |||
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 | #ifndef KABCORE_H | 24 | #ifndef KABCORE_H |
25 | #define KABCORE_H | 25 | #define KABCORE_H |
26 | 26 | ||
27 | #include <kabc/field.h> | 27 | #include <kabc/field.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <qwidget.h> | 34 | #include <qwidget.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <ksyncmanager.h> | 36 | #include <ksyncmanager.h> |
37 | #ifndef DESKTOP_VERSION | 37 | #ifndef DESKTOP_VERSION |
38 | #include <qcopchannel_qws.h> | 38 | #include <qcopchannel_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | namespace KABC { | 41 | namespace KABC { |
42 | class AddressBook; | 42 | class AddressBook; |
43 | } | 43 | } |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | class KAboutData; | 46 | class KAboutData; |
47 | class KConfig; | 47 | class KConfig; |
48 | 48 | ||
49 | class KAddressBookService; | 49 | class KAddressBookService; |
50 | class LDAPSearchDialog; | 50 | class LDAPSearchDialog; |
51 | #else //KAB_EMBEDDED | 51 | #else //KAB_EMBEDDED |
52 | class KAddressBookMain; | 52 | class KAddressBookMain; |
53 | //US class QAction; | 53 | //US class QAction; |
54 | #endif //KAB_EMBEDDED | 54 | #endif //KAB_EMBEDDED |
55 | class KCMultiDialog; | 55 | class KCMultiDialog; |
56 | class KXMLGUIClient; | 56 | class KXMLGUIClient; |
57 | class ExtensionManager; | 57 | class ExtensionManager; |
58 | class XXPortManager; | 58 | class XXPortManager; |
59 | class JumpButtonBar; | 59 | class JumpButtonBar; |
60 | class IncSearchWidget; | 60 | class IncSearchWidget; |
61 | class KDGanttMinimizeSplitter; | 61 | class KDGanttMinimizeSplitter; |
62 | class KAction; | 62 | class KAction; |
63 | class KActionCollection; | 63 | class KActionCollection; |
64 | class KToggleAction; | 64 | class KToggleAction; |
65 | class KSyncProfile; | 65 | class KSyncProfile; |
66 | 66 | ||
67 | class QAction; | 67 | class QAction; |
68 | class QMenuBar; | 68 | class QMenuBar; |
69 | class QSplitter; | 69 | class QSplitter; |
70 | class ViewContainer; | 70 | class ViewContainer; |
71 | class ViewManager; | 71 | class ViewManager; |
72 | class AddresseeEditorDialog; | 72 | class AddresseeEditorDialog; |
73 | class Ir; | 73 | class Ir; |
74 | 74 | ||
75 | class KABCore : public QWidget, public KSyncInterface | 75 | class KABCore : public QWidget, public KSyncInterface |
76 | { | 76 | { |
77 | Q_OBJECT | 77 | Q_OBJECT |
78 | 78 | ||
79 | public: | 79 | public: |
80 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 80 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
81 | 81 | ||
82 | 82 | ||
83 | ~KABCore(); | 83 | ~KABCore(); |
84 | 84 | ||
85 | 85 | ||
86 | #ifdef KAB_EMBEDDED | 86 | #ifdef KAB_EMBEDDED |
87 | //US added functionality | 87 | //US added functionality |
88 | QPopupMenu* getViewMenu() {return viewMenu;} | 88 | QPopupMenu* getViewMenu() {return viewMenu;} |
89 | QPopupMenu* getFilterMenu() {return filterMenu;} | 89 | QPopupMenu* getFilterMenu() {return filterMenu;} |
90 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 90 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
91 | void addActionsManually(); | 91 | void addActionsManually(); |
92 | #endif //KAB_EMBEDDED | 92 | #endif //KAB_EMBEDDED |
93 | /** | 93 | /** |
94 | Restores the global settings. | 94 | Restores the global settings. |
95 | */ | 95 | */ |
96 | void restoreSettings(); | 96 | void restoreSettings(); |
97 | 97 | ||
98 | /** | 98 | /** |
99 | Saves the global settings. | 99 | Saves the global settings. |
100 | */ | 100 | */ |
101 | void saveSettings(); | 101 | void saveSettings(); |
102 | 102 | ||
103 | /** | 103 | /** |
104 | Returns a pointer to the StdAddressBook of the application. | 104 | Returns a pointer to the StdAddressBook of the application. |
105 | */ | 105 | */ |
106 | KABC::AddressBook *addressBook() const; | 106 | KABC::AddressBook *addressBook() const; |
107 | 107 | ||
108 | /** | 108 | /** |
109 | Returns a pointer to the KConfig object of the application. | 109 | Returns a pointer to the KConfig object of the application. |
110 | */ | 110 | */ |
111 | static KConfig *config(); | 111 | static KConfig *config(); |
112 | 112 | ||
113 | /** | 113 | /** |
114 | Returns a pointer to the global KActionCollection object. So | 114 | Returns a pointer to the global KActionCollection object. So |
115 | other classes can register their actions easily. | 115 | other classes can register their actions easily. |
116 | */ | 116 | */ |
117 | KActionCollection *actionCollection() const; | 117 | KActionCollection *actionCollection() const; |
118 | 118 | ||
119 | /** | 119 | /** |
120 | Returns the current search field of the Incremental Search Widget. | 120 | Returns the current search field of the Incremental Search Widget. |
121 | */ | 121 | */ |
122 | KABC::Field *currentSearchField() const; | 122 | KABC::Field *currentSearchField() const; |
123 | 123 | ||
124 | /** | 124 | /** |
125 | Returns the uid list of the currently selected contacts. | 125 | Returns the uid list of the currently selected contacts. |
126 | */ | 126 | */ |
127 | QStringList selectedUIDs() const; | 127 | QStringList selectedUIDs() const; |
128 | 128 | ||
129 | /** | 129 | /** |
130 | Displays the ResourceSelectDialog and returns the selected | 130 | Displays the ResourceSelectDialog and returns the selected |
131 | resource or a null pointer if no resource was selected by | 131 | resource or a null pointer if no resource was selected by |
132 | the user. | 132 | the user. |
133 | */ | 133 | */ |
134 | KABC::Resource *requestResource( QWidget *parent ); | 134 | KABC::Resource *requestResource( QWidget *parent ); |
135 | 135 | ||
136 | #ifndef KAB_EMBEDDED | 136 | #ifndef KAB_EMBEDDED |
137 | static KAboutData *createAboutData(); | 137 | static KAboutData *createAboutData(); |
138 | #endif //KAB_EMBEDDED | 138 | #endif //KAB_EMBEDDED |
139 | 139 | ||
140 | #ifdef KAB_EMBEDDED | 140 | #ifdef KAB_EMBEDDED |
141 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 141 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
142 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 142 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
143 | #endif //KAB_EMBEDDED | 143 | #endif //KAB_EMBEDDED |
144 | 144 | ||
145 | public slots: | 145 | public slots: |
146 | #ifdef KAB_EMBEDDED | 146 | #ifdef KAB_EMBEDDED |
147 | void createAboutData(); | 147 | void createAboutData(); |
148 | #endif //KAB_EMBEDDED | 148 | #endif //KAB_EMBEDDED |
149 | void setDetailsToggle(); | 149 | void setDetailsToggle(); |
150 | 150 | ||
151 | void showLicence(); | 151 | void showLicence(); |
152 | void faq(); | 152 | void faq(); |
153 | void whatsnew() ; | 153 | void whatsnew() ; |
154 | void synchowto() ; | 154 | void synchowto() ; |
155 | void multisynchowto() ; | ||
156 | void kdesynchowto() ; | ||
155 | void writeToPhone(); | 157 | void writeToPhone(); |
156 | 158 | ||
157 | /** | 159 | /** |
158 | Is called whenever a contact is selected in the view. | 160 | Is called whenever a contact is selected in the view. |
159 | */ | 161 | */ |
160 | void setContactSelected( const QString &uid ); | 162 | void setContactSelected( const QString &uid ); |
161 | 163 | ||
162 | /** | 164 | /** |
163 | Opens the preferred mail composer with all selected contacts as | 165 | Opens the preferred mail composer with all selected contacts as |
164 | arguments. | 166 | arguments. |
165 | */ | 167 | */ |
166 | void sendMail(); | 168 | void sendMail(); |
167 | 169 | ||
168 | /** | 170 | /** |
169 | Opens the preferred mail composer with the given contacts as | 171 | Opens the preferred mail composer with the given contacts as |
170 | arguments. | 172 | arguments. |
171 | */ | 173 | */ |
172 | void sendMail( const QString& email ); | 174 | void sendMail( const QString& email ); |
173 | 175 | ||
174 | 176 | ||
175 | void mailVCard(); | 177 | void mailVCard(); |
176 | void mailVCard(const QStringList& uids); | 178 | void mailVCard(const QStringList& uids); |
177 | 179 | ||
178 | /** | 180 | /** |
179 | Beams the "WhoAmI contact. | 181 | Beams the "WhoAmI contact. |
180 | */ | 182 | */ |
181 | void beamMySelf(); | 183 | void beamMySelf(); |
182 | 184 | ||
183 | void beamVCard(); | 185 | void beamVCard(); |
184 | void export2phone(); | 186 | void export2phone(); |
185 | void beamVCard(const QStringList& uids); | 187 | void beamVCard(const QStringList& uids); |
186 | void beamDone( Ir *ir ); | 188 | void beamDone( Ir *ir ); |
187 | 189 | ||
188 | 190 | ||
189 | /** | 191 | /** |
190 | Starts the preferred web browser with the given URL as argument. | 192 | Starts the preferred web browser with the given URL as argument. |
191 | */ | 193 | */ |
192 | void browse( const QString& url ); | 194 | void browse( const QString& url ); |
193 | 195 | ||
194 | /** | 196 | /** |
195 | Select all contacts in the view. | 197 | Select all contacts in the view. |
196 | */ | 198 | */ |
197 | void selectAllContacts(); | 199 | void selectAllContacts(); |
198 | 200 | ||
199 | /** | 201 | /** |
200 | Deletes all selected contacts from the address book. | 202 | Deletes all selected contacts from the address book. |
201 | */ | 203 | */ |
202 | void deleteContacts(); | 204 | void deleteContacts(); |
203 | 205 | ||
204 | /** | 206 | /** |
205 | Deletes given contacts from the address book. | 207 | Deletes given contacts from the address book. |
206 | 208 | ||
207 | @param uids The uids of the contacts, which shall be deleted. | 209 | @param uids The uids of the contacts, which shall be deleted. |
208 | */ | 210 | */ |
209 | void deleteContacts( const QStringList &uids ); | 211 | void deleteContacts( const QStringList &uids ); |
210 | 212 | ||
211 | /** | 213 | /** |
212 | Copys the selected contacts into clipboard for later pasting. | 214 | Copys the selected contacts into clipboard for later pasting. |
213 | */ | 215 | */ |
214 | void copyContacts(); | 216 | void copyContacts(); |
215 | 217 | ||
216 | /** | 218 | /** |
217 | Cuts the selected contacts and stores them for later pasting. | 219 | Cuts the selected contacts and stores them for later pasting. |
218 | */ | 220 | */ |
219 | void cutContacts(); | 221 | void cutContacts(); |
220 | 222 | ||
221 | /** | 223 | /** |
222 | Paste contacts from clipboard into the address book. | 224 | Paste contacts from clipboard into the address book. |
223 | */ | 225 | */ |
224 | void pasteContacts(); | 226 | void pasteContacts(); |
225 | 227 | ||
226 | /** | 228 | /** |
227 | Paste given contacts into the address book. | 229 | Paste given contacts into the address book. |
228 | 230 | ||
229 | @param list The list of addressee, which shall be pasted. | 231 | @param list The list of addressee, which shall be pasted. |
230 | */ | 232 | */ |
231 | void pasteContacts( KABC::Addressee::List &list ); | 233 | void pasteContacts( KABC::Addressee::List &list ); |
232 | 234 | ||
233 | /** | 235 | /** |
234 | Sets the whoAmI contact, that is used by many other programs to | 236 | Sets the whoAmI contact, that is used by many other programs to |
235 | get personal information about the current user. | 237 | get personal information about the current user. |
236 | */ | 238 | */ |
237 | void setWhoAmI(); | 239 | void setWhoAmI(); |
238 | 240 | ||
239 | /** | 241 | /** |
240 | Displays the category dialog and applies the result to all | 242 | Displays the category dialog and applies the result to all |
241 | selected contacts. | 243 | selected contacts. |
242 | */ | 244 | */ |
243 | void setCategories(); | 245 | void setCategories(); |
244 | 246 | ||
245 | /** | 247 | /** |
246 | Sets the field list of the Incremental Search Widget. | 248 | Sets the field list of the Incremental Search Widget. |
247 | */ | 249 | */ |
248 | void setSearchFields( const KABC::Field::List &fields ); | 250 | void setSearchFields( const KABC::Field::List &fields ); |
249 | 251 | ||
250 | /** | 252 | /** |
251 | Search with the current search field for a contact, that matches | 253 | Search with the current search field for a contact, that matches |
252 | the given text, and selects it in the view. | 254 | the given text, and selects it in the view. |
253 | */ | 255 | */ |
254 | void incrementalSearch( const QString& text ); | 256 | void incrementalSearch( const QString& text ); |
255 | 257 | ||
256 | /** | 258 | /** |
257 | Marks the address book as modified. | 259 | Marks the address book as modified. |
258 | */ | 260 | */ |
259 | void setModified(); | 261 | void setModified(); |
260 | /** | 262 | /** |
261 | Marks the address book as modified without refreshing the view. | 263 | Marks the address book as modified without refreshing the view. |
262 | */ | 264 | */ |
263 | void setModifiedWOrefresh(); | 265 | void setModifiedWOrefresh(); |
264 | 266 | ||
265 | /** | 267 | /** |
266 | Marks the address book as modified concerning the argument. | 268 | Marks the address book as modified concerning the argument. |
267 | */ | 269 | */ |
268 | void setModified( bool modified ); | 270 | void setModified( bool modified ); |
269 | 271 | ||
270 | /** | 272 | /** |
271 | Returns whether the address book is modified. | 273 | Returns whether the address book is modified. |
272 | */ | 274 | */ |
273 | bool modified() const; | 275 | bool modified() const; |
274 | 276 | ||
275 | /** | 277 | /** |
276 | Called whenever an contact is modified in the contact editor | 278 | Called whenever an contact is modified in the contact editor |
277 | dialog or the quick edit. | 279 | dialog or the quick edit. |
278 | */ | 280 | */ |
279 | void contactModified( const KABC::Addressee &addr ); | 281 | void contactModified( const KABC::Addressee &addr ); |
280 | 282 | ||
281 | /** | 283 | /** |
282 | DCOP METHODS. | 284 | DCOP METHODS. |
283 | */ | 285 | */ |
284 | void addEmail( QString addr ); | 286 | void addEmail( QString addr ); |
285 | void importVCard( const KURL& url, bool showPreview ); | 287 | void importVCard( const KURL& url, bool showPreview ); |
286 | void importVCard( const QString& vCard, bool showPreview ); | 288 | void importVCard( const QString& vCard, bool showPreview ); |
287 | void newContact(); | 289 | void newContact(); |
288 | QString getNameByPhone( const QString& phone ); | 290 | QString getNameByPhone( const QString& phone ); |
289 | /** | 291 | /** |
290 | END DCOP METHODS | 292 | END DCOP METHODS |
291 | */ | 293 | */ |
292 | 294 | ||
293 | /** | 295 | /** |
294 | Saves the contents of the AddressBook back to disk. | 296 | Saves the contents of the AddressBook back to disk. |
295 | */ | 297 | */ |
296 | void save(); | 298 | void save(); |
297 | 299 | ||
298 | /** | 300 | /** |
299 | Undos the last command using the undo stack. | 301 | Undos the last command using the undo stack. |
300 | */ | 302 | */ |
301 | void undo(); | 303 | void undo(); |
302 | 304 | ||
303 | /** | 305 | /** |
304 | Redos the last command that was undone, using the redo stack. | 306 | Redos the last command that was undone, using the redo stack. |
305 | */ | 307 | */ |
306 | void redo(); | 308 | void redo(); |
307 | 309 | ||
308 | /** | 310 | /** |
309 | Shows the edit dialog for the given uid. If the uid is QString::null, | 311 | Shows the edit dialog for the given uid. If the uid is QString::null, |
310 | the method will try to find a selected addressee in the view. | 312 | the method will try to find a selected addressee in the view. |
311 | */ | 313 | */ |
312 | void editContact( const QString &uid /*US = QString::null*/ ); | 314 | void editContact( const QString &uid /*US = QString::null*/ ); |
313 | //US added a second method without defaultparameter | 315 | //US added a second method without defaultparameter |
314 | void editContact2(); | 316 | void editContact2(); |
315 | 317 | ||
316 | /** | 318 | /** |
317 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 319 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
318 | the method will try to find a selected addressee in the view. | 320 | the method will try to find a selected addressee in the view. |
319 | */ | 321 | */ |
320 | void executeContact( const QString &uid /*US = QString::null*/ ); | 322 | void executeContact( const QString &uid /*US = QString::null*/ ); |
321 | 323 | ||
322 | /** | 324 | /** |
323 | Launches the configuration dialog. | 325 | Launches the configuration dialog. |
324 | */ | 326 | */ |
325 | void openConfigDialog(); | 327 | void openConfigDialog(); |
326 | 328 | ||
327 | /** | 329 | /** |
328 | Launches the ldap search dialog. | 330 | Launches the ldap search dialog. |
329 | */ | 331 | */ |
330 | void openLDAPDialog(); | 332 | void openLDAPDialog(); |
331 | 333 | ||
332 | /** | 334 | /** |
333 | Creates a KAddressBookPrinter, which will display the print | 335 | Creates a KAddressBookPrinter, which will display the print |
334 | dialog and do the printing. | 336 | dialog and do the printing. |
335 | */ | 337 | */ |
336 | void print(); | 338 | void print(); |
337 | 339 | ||
338 | /** | 340 | /** |
339 | Registers a new GUI client, so plugins can register its actions. | 341 | Registers a new GUI client, so plugins can register its actions. |
340 | */ | 342 | */ |
341 | void addGUIClient( KXMLGUIClient *client ); | 343 | void addGUIClient( KXMLGUIClient *client ); |
342 | 344 | ||
343 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 345 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
344 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 346 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
345 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); | 347 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |
346 | 348 | ||
347 | 349 | ||
348 | signals: | 350 | signals: |
349 | void contactSelected( const QString &name ); | 351 | void contactSelected( const QString &name ); |
350 | void contactSelected( const QPixmap &pixmap ); | 352 | void contactSelected( const QPixmap &pixmap ); |
351 | public slots: | 353 | public slots: |
352 | void recieve(QString cmsg ); | 354 | void recieve(QString cmsg ); |
353 | void getFile( bool success ); | 355 | void getFile( bool success ); |
354 | void syncFileRequest(); | 356 | void syncFileRequest(); |
355 | void setDetailsVisible( bool visible ); | 357 | void setDetailsVisible( bool visible ); |
356 | void setDetailsToState(); | 358 | void setDetailsToState(); |
357 | // void slotSyncMenu( int ); | 359 | // void slotSyncMenu( int ); |
358 | private slots: | 360 | private slots: |
359 | void receive( const QCString& cmsg, const QByteArray& data ); | 361 | void receive( const QCString& cmsg, const QByteArray& data ); |
360 | void toggleBeamReceive( ); | 362 | void toggleBeamReceive( ); |
361 | void disableBR(bool); | 363 | void disableBR(bool); |
362 | void setJumpButtonBarVisible( bool visible ); | 364 | void setJumpButtonBarVisible( bool visible ); |
363 | void setCaptionBack(); | 365 | void setCaptionBack(); |
364 | void importFromOL(); | 366 | void importFromOL(); |
365 | void extensionModified( const KABC::Addressee::List &list ); | 367 | void extensionModified( const KABC::Addressee::List &list ); |
366 | void extensionChanged( int id ); | 368 | void extensionChanged( int id ); |
367 | void clipboardDataChanged(); | 369 | void clipboardDataChanged(); |
368 | void updateActionMenu(); | 370 | void updateActionMenu(); |
369 | void configureKeyBindings(); | 371 | void configureKeyBindings(); |
370 | void removeVoice(); | 372 | void removeVoice(); |
371 | #ifdef KAB_EMBEDDED | 373 | #ifdef KAB_EMBEDDED |
372 | void configureResources(); | 374 | void configureResources(); |
373 | #endif //KAB_EMBEDDED | 375 | #endif //KAB_EMBEDDED |
374 | 376 | ||
375 | void slotEditorDestroyed( const QString &uid ); | 377 | void slotEditorDestroyed( const QString &uid ); |
376 | void configurationChanged(); | 378 | void configurationChanged(); |
377 | void addressBookChanged(); | 379 | void addressBookChanged(); |
378 | 380 | ||
379 | private: | 381 | private: |
380 | bool mBRdisabled; | 382 | bool mBRdisabled; |
381 | #ifndef DESKTOP_VERSION | 383 | #ifndef DESKTOP_VERSION |
382 | QCopChannel* infrared; | 384 | QCopChannel* infrared; |
383 | #endif | 385 | #endif |
384 | QTimer *mMessageTimer; | 386 | QTimer *mMessageTimer; |
385 | void initGUI(); | 387 | void initGUI(); |
386 | void initActions(); | 388 | void initActions(); |
387 | QString getPhoneFile(); | 389 | QString getPhoneFile(); |
388 | 390 | ||
389 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 391 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
390 | const char *name = 0 ); | 392 | const char *name = 0 ); |
391 | 393 | ||
392 | KXMLGUIClient *mGUIClient; | 394 | KXMLGUIClient *mGUIClient; |
393 | 395 | ||
394 | KABC::AddressBook *mAddressBook; | 396 | KABC::AddressBook *mAddressBook; |
395 | 397 | ||
396 | ViewManager *mViewManager; | 398 | ViewManager *mViewManager; |
397 | // QSplitter *mDetailsSplitter; | 399 | // QSplitter *mDetailsSplitter; |
398 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 400 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
399 | ViewContainer *mDetails; | 401 | ViewContainer *mDetails; |
400 | KDGanttMinimizeSplitter* mMiniSplitter; | 402 | KDGanttMinimizeSplitter* mMiniSplitter; |
401 | XXPortManager *mXXPortManager; | 403 | XXPortManager *mXXPortManager; |
402 | JumpButtonBar *mJumpButtonBar; | 404 | JumpButtonBar *mJumpButtonBar; |
403 | IncSearchWidget *mIncSearchWidget; | 405 | IncSearchWidget *mIncSearchWidget; |
404 | ExtensionManager *mExtensionManager; | 406 | ExtensionManager *mExtensionManager; |
405 | 407 | ||
406 | KCMultiDialog *mConfigureDialog; | 408 | KCMultiDialog *mConfigureDialog; |
407 | 409 | ||
408 | #ifndef KAB_EMBEDDED | 410 | #ifndef KAB_EMBEDDED |
409 | LDAPSearchDialog *mLdapSearchDialog; | 411 | LDAPSearchDialog *mLdapSearchDialog; |
410 | #endif //KAB_EMBEDDED | 412 | #endif //KAB_EMBEDDED |
411 | // QDict<AddresseeEditorDialog> mEditorDict; | 413 | // QDict<AddresseeEditorDialog> mEditorDict; |
412 | AddresseeEditorDialog *mEditorDialog; | 414 | AddresseeEditorDialog *mEditorDialog; |
413 | bool mReadWrite; | 415 | bool mReadWrite; |
414 | bool mModified; | 416 | bool mModified; |
415 | bool mIsPart; | 417 | bool mIsPart; |
416 | bool mMultipleViewsAtOnce; | 418 | bool mMultipleViewsAtOnce; |
417 | 419 | ||
418 | 420 | ||
419 | //US file menu | 421 | //US file menu |
420 | KAction *mActionMail; | 422 | KAction *mActionMail; |
421 | KAction *mActionBeam; | 423 | KAction *mActionBeam; |
422 | KToggleAction *mActionBR; | 424 | KToggleAction *mActionBR; |
423 | KAction *mActionExport2phone; | 425 | KAction *mActionExport2phone; |
424 | KAction* mActionPrint; | 426 | KAction* mActionPrint; |
425 | KAction* mActionNewContact; | 427 | KAction* mActionNewContact; |
426 | KAction *mActionSave; | 428 | KAction *mActionSave; |
427 | KAction *mActionEditAddressee; | 429 | KAction *mActionEditAddressee; |
428 | KAction *mActionMailVCard; | 430 | KAction *mActionMailVCard; |
429 | KAction *mActionBeamVCard; | 431 | KAction *mActionBeamVCard; |
430 | 432 | ||
431 | KAction *mActionQuit; | 433 | KAction *mActionQuit; |
432 | 434 | ||
433 | //US edit menu | 435 | //US edit menu |
434 | KAction *mActionCopy; | 436 | KAction *mActionCopy; |
435 | KAction *mActionCut; | 437 | KAction *mActionCut; |
436 | KAction *mActionPaste; | 438 | KAction *mActionPaste; |
437 | KAction *mActionSelectAll; | 439 | KAction *mActionSelectAll; |
438 | KAction *mActionUndo; | 440 | KAction *mActionUndo; |
439 | KAction *mActionRedo; | 441 | KAction *mActionRedo; |
440 | KAction *mActionDelete; | 442 | KAction *mActionDelete; |
441 | 443 | ||
442 | //US settings menu | 444 | //US settings menu |
443 | KAction *mActionConfigResources; | 445 | KAction *mActionConfigResources; |
444 | KAction *mActionConfigKAddressbook; | 446 | KAction *mActionConfigKAddressbook; |
445 | KAction *mActionConfigShortcuts; | 447 | KAction *mActionConfigShortcuts; |
446 | KAction *mActionConfigureToolbars; | 448 | KAction *mActionConfigureToolbars; |
447 | KAction *mActionKeyBindings; | 449 | KAction *mActionKeyBindings; |
448 | KToggleAction *mActionJumpBar; | 450 | KToggleAction *mActionJumpBar; |
449 | KToggleAction *mActionDetails; | 451 | KToggleAction *mActionDetails; |
450 | KAction *mActionWhoAmI; | 452 | KAction *mActionWhoAmI; |
451 | KAction *mActionCategories; | 453 | KAction *mActionCategories; |
452 | KAction *mActionAboutKAddressbook; | 454 | KAction *mActionAboutKAddressbook; |
453 | KAction *mActionLicence; | 455 | KAction *mActionLicence; |
454 | KAction *mActionFaq; | 456 | KAction *mActionFaq; |
455 | KAction *mActionWN; | 457 | KAction *mActionWN; |
456 | KAction *mActionSyncHowto; | 458 | KAction *mActionSyncHowto; |
459 | KAction *mActionKdeSyncHowto; | ||
460 | KAction *mActionMultiSyncHowto; | ||
457 | 461 | ||
458 | KAction *mActionDeleteView; | 462 | KAction *mActionDeleteView; |
459 | 463 | ||
460 | QPopupMenu *viewMenu; | 464 | QPopupMenu *viewMenu; |
461 | QPopupMenu *filterMenu; | 465 | QPopupMenu *filterMenu; |
462 | QPopupMenu *settingsMenu; | 466 | QPopupMenu *settingsMenu; |
463 | QPopupMenu *changeMenu; | 467 | QPopupMenu *changeMenu; |
464 | //US QAction *mActionSave; | 468 | //US QAction *mActionSave; |
465 | QPopupMenu *ImportMenu; | 469 | QPopupMenu *ImportMenu; |
466 | QPopupMenu *ExportMenu; | 470 | QPopupMenu *ExportMenu; |
467 | //LR additional methods | 471 | //LR additional methods |
468 | KAction *mActionRemoveVoice; | 472 | KAction *mActionRemoveVoice; |
469 | KAction * mActionImportOL; | 473 | KAction * mActionImportOL; |
470 | 474 | ||
471 | #ifndef KAB_EMBEDDED | 475 | #ifndef KAB_EMBEDDED |
472 | KAddressBookService *mAddressBookService; | 476 | KAddressBookService *mAddressBookService; |
473 | #endif //KAB_EMBEDDED | 477 | #endif //KAB_EMBEDDED |
474 | 478 | ||
475 | class KABCorePrivate; | 479 | class KABCorePrivate; |
476 | KABCorePrivate *d; | 480 | KABCorePrivate *d; |
477 | //US bool mBlockSaveFlag; | 481 | //US bool mBlockSaveFlag; |
478 | 482 | ||
479 | #ifdef KAB_EMBEDDED | 483 | #ifdef KAB_EMBEDDED |
480 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 484 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
481 | #endif //KAB_EMBEDDED | 485 | #endif //KAB_EMBEDDED |
482 | 486 | ||
483 | //this are the overwritten callbackmethods from the syncinterface | 487 | //this are the overwritten callbackmethods from the syncinterface |
484 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 488 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
485 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 489 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
486 | virtual void removeSyncInfo( QString syncProfile); | 490 | virtual void removeSyncInfo( QString syncProfile); |
487 | bool syncPhone(); | 491 | bool syncPhone(); |
488 | void message( QString m ); | 492 | void message( QString m ); |
489 | 493 | ||
490 | // LR ******************************* | 494 | // LR ******************************* |
491 | // sync stuff! | 495 | // sync stuff! |
492 | QString sentSyncFile(); | 496 | QString sentSyncFile(); |
493 | QPopupMenu *syncMenu; | 497 | QPopupMenu *syncMenu; |
494 | KSyncManager* syncManager; | 498 | KSyncManager* syncManager; |
495 | int mGlobalSyncMode; | 499 | int mGlobalSyncMode; |
496 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 500 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
497 | KABC::Addressee getLastSyncAddressee(); | 501 | KABC::Addressee getLastSyncAddressee(); |
498 | QDateTime mLastAddressbookSync; | 502 | QDateTime mLastAddressbookSync; |
499 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 503 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
500 | // ********************* | 504 | // ********************* |
501 | 505 | ||
502 | }; | 506 | }; |
503 | 507 | ||
504 | #endif | 508 | #endif |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 6e61351..4667918 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3777 +1,3783 @@ | |||
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 | beamDialog = new KOBeamPrefs(); | 236 | beamDialog = new KOBeamPrefs(); |
237 | mDatePickerMode = 0; | 237 | mDatePickerMode = 0; |
238 | mCurrentSyncDevice = ""; | 238 | mCurrentSyncDevice = ""; |
239 | writeLocale(); | 239 | writeLocale(); |
240 | mViewManager = new KOViewManager( this ); | 240 | mViewManager = new KOViewManager( this ); |
241 | mDialogManager = new KODialogManager( this ); | 241 | mDialogManager = new KODialogManager( this ); |
242 | mEventViewerDialog = 0; | 242 | mEventViewerDialog = 0; |
243 | mModified = false; | 243 | mModified = false; |
244 | mReadOnly = false; | 244 | mReadOnly = false; |
245 | mSelectedIncidence = 0; | 245 | mSelectedIncidence = 0; |
246 | mCalPrinter = 0; | 246 | mCalPrinter = 0; |
247 | mFilters.setAutoDelete(true); | 247 | mFilters.setAutoDelete(true); |
248 | 248 | ||
249 | mCalendar->registerObserver( this ); | 249 | mCalendar->registerObserver( this ); |
250 | // TODO: Make sure that view is updated, when calendar is changed. | 250 | // TODO: Make sure that view is updated, when calendar is changed. |
251 | 251 | ||
252 | mStorage = new FileStorage( mCalendar ); | 252 | mStorage = new FileStorage( mCalendar ); |
253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
254 | 254 | ||
255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
256 | #ifndef KORG_NOSPLITTER | 256 | #ifndef KORG_NOSPLITTER |
257 | // create the main layout frames. | 257 | // create the main layout frames. |
258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
259 | topLayout->addWidget(mPanner); | 259 | topLayout->addWidget(mPanner); |
260 | 260 | ||
261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
262 | "CalendarView::LeftFrame"); | 262 | "CalendarView::LeftFrame"); |
263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
264 | 264 | ||
265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
266 | "CalendarView::DateNavigator", QDate::currentDate() ); | 266 | "CalendarView::DateNavigator", QDate::currentDate() ); |
267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
270 | 270 | ||
271 | #ifdef KORG_NORESOURCEVIEW | 271 | #ifdef KORG_NORESOURCEVIEW |
272 | mResourceView = 0; | 272 | mResourceView = 0; |
273 | #else | 273 | #else |
274 | if ( mResourceManager ) { | 274 | if ( mResourceManager ) { |
275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
276 | mResourceView->updateView(); | 276 | mResourceView->updateView(); |
277 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 277 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
278 | SLOT( updateView() ) ); | 278 | SLOT( updateView() ) ); |
279 | } else { | 279 | } else { |
280 | mResourceView = 0; | 280 | mResourceView = 0; |
281 | } | 281 | } |
282 | #endif | 282 | #endif |
283 | QWidget *rightBox = new QWidget( mPanner ); | 283 | QWidget *rightBox = new QWidget( mPanner ); |
284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
285 | 285 | ||
286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
287 | rightLayout->addWidget( mNavigatorBar ); | 287 | rightLayout->addWidget( mNavigatorBar ); |
288 | 288 | ||
289 | mRightFrame = new QWidgetStack( rightBox ); | 289 | mRightFrame = new QWidgetStack( rightBox ); |
290 | rightLayout->addWidget( mRightFrame, 1 ); | 290 | rightLayout->addWidget( mRightFrame, 1 ); |
291 | 291 | ||
292 | mLeftFrame = mLeftSplitter; | 292 | mLeftFrame = mLeftSplitter; |
293 | #else | 293 | #else |
294 | QWidget *mainBox = new QWidget( this ); | 294 | QWidget *mainBox = new QWidget( this ); |
295 | QWidget *leftFrame = new QWidget( mainBox ); | 295 | QWidget *leftFrame = new QWidget( mainBox ); |
296 | 296 | ||
297 | QBoxLayout * mainBoxLayout; | 297 | QBoxLayout * mainBoxLayout; |
298 | QBoxLayout * leftFrameLayout; | 298 | QBoxLayout * leftFrameLayout; |
299 | if ( KOPrefs::instance()->mVerticalScreen ) { | 299 | if ( KOPrefs::instance()->mVerticalScreen ) { |
300 | mainBoxLayout = new QVBoxLayout(mainBox); | 300 | mainBoxLayout = new QVBoxLayout(mainBox); |
301 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 301 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
302 | } else { | 302 | } else { |
303 | mainBoxLayout = new QHBoxLayout(mainBox); | 303 | mainBoxLayout = new QHBoxLayout(mainBox); |
304 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 304 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
305 | } | 305 | } |
306 | topLayout->addWidget( mainBox ); | 306 | topLayout->addWidget( mainBox ); |
307 | mainBoxLayout->addWidget (leftFrame); | 307 | mainBoxLayout->addWidget (leftFrame); |
308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
309 | "CalendarView::DateNavigator", QDate::currentDate()); | 309 | "CalendarView::DateNavigator", QDate::currentDate()); |
310 | // mDateNavigator->blockSignals( true ); | 310 | // mDateNavigator->blockSignals( true ); |
311 | leftFrameLayout->addWidget( mDateNavigator ); | 311 | leftFrameLayout->addWidget( mDateNavigator ); |
312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
314 | 314 | ||
315 | if ( QApplication::desktop()->width() < 480 ) { | 315 | if ( QApplication::desktop()->width() < 480 ) { |
316 | leftFrameLayout->addWidget(mFilterView); | 316 | leftFrameLayout->addWidget(mFilterView); |
317 | leftFrameLayout->addWidget(mTodoList, 2 ); | 317 | leftFrameLayout->addWidget(mTodoList, 2 ); |
318 | 318 | ||
319 | } else { | 319 | } else { |
320 | leftFrameLayout->addWidget(mTodoList,2 ); | 320 | leftFrameLayout->addWidget(mTodoList,2 ); |
321 | leftFrameLayout->addWidget(mFilterView ); | 321 | leftFrameLayout->addWidget(mFilterView ); |
322 | } | 322 | } |
323 | mFilterView->hide(); | 323 | mFilterView->hide(); |
324 | QWidget *rightBox = new QWidget( mainBox ); | 324 | QWidget *rightBox = new QWidget( mainBox ); |
325 | mainBoxLayout->addWidget ( rightBox, 10 ); | 325 | mainBoxLayout->addWidget ( rightBox, 10 ); |
326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
328 | mRightFrame = new QWidgetStack( rightBox ); | 328 | mRightFrame = new QWidgetStack( rightBox ); |
329 | rightLayout->addWidget( mNavigatorBar ); | 329 | rightLayout->addWidget( mNavigatorBar ); |
330 | rightLayout->addWidget( mRightFrame, 10 ); | 330 | rightLayout->addWidget( mRightFrame, 10 ); |
331 | 331 | ||
332 | mLeftFrame = leftFrame; | 332 | mLeftFrame = leftFrame; |
333 | if ( KOPrefs::instance()->mVerticalScreen ) { | 333 | if ( KOPrefs::instance()->mVerticalScreen ) { |
334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
336 | } else { | 336 | } else { |
337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
339 | } | 339 | } |
340 | 340 | ||
341 | //qDebug("Calendarview Size %d %d ", width(), height()); | 341 | //qDebug("Calendarview Size %d %d ", width(), height()); |
342 | #endif | 342 | #endif |
343 | 343 | ||
344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
345 | SLOT( showDates( const KCal::DateList & ) ) ); | 345 | SLOT( showDates( const KCal::DateList & ) ) ); |
346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
348 | 348 | ||
349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
350 | mNavigator, SLOT( selectPreviousYear() ) ); | 350 | mNavigator, SLOT( selectPreviousYear() ) ); |
351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
352 | mNavigator, SLOT( selectNextYear() ) ); | 352 | mNavigator, SLOT( selectNextYear() ) ); |
353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
354 | mNavigator, SLOT( selectPreviousMonth() ) ); | 354 | mNavigator, SLOT( selectPreviousMonth() ) ); |
355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
356 | mNavigator, SLOT( selectNextMonth() ) ); | 356 | mNavigator, SLOT( selectNextMonth() ) ); |
357 | 357 | ||
358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
360 | 360 | ||
361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
363 | 363 | ||
364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
365 | mNavigator, SLOT( selectPreviousYear() ) ); | 365 | mNavigator, SLOT( selectPreviousYear() ) ); |
366 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 366 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
367 | mNavigator, SLOT( selectNextYear() ) ); | 367 | mNavigator, SLOT( selectNextYear() ) ); |
368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
369 | mNavigator, SLOT( selectPreviousMonth() ) ); | 369 | mNavigator, SLOT( selectPreviousMonth() ) ); |
370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
371 | mNavigator, SLOT( selectNextMonth() ) ); | 371 | mNavigator, SLOT( selectNextMonth() ) ); |
372 | 372 | ||
373 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 373 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
374 | mNavigator, SLOT( selectPrevious() ) ); | 374 | mNavigator, SLOT( selectPrevious() ) ); |
375 | connect( mDateNavigator, SIGNAL( goNext() ), | 375 | connect( mDateNavigator, SIGNAL( goNext() ), |
376 | mNavigator, SLOT( selectNext() ) ); | 376 | mNavigator, SLOT( selectNext() ) ); |
377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
381 | 381 | ||
382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
384 | 384 | ||
385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
386 | SLOT( eventAdded( Event *) ) ); | 386 | SLOT( eventAdded( Event *) ) ); |
387 | 387 | ||
388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
389 | 389 | ||
390 | connect( this, SIGNAL( configChanged() ), | 390 | connect( this, SIGNAL( configChanged() ), |
391 | mDateNavigator, SLOT( updateConfig() ) ); | 391 | mDateNavigator, SLOT( updateConfig() ) ); |
392 | 392 | ||
393 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 393 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
394 | SLOT( newTodo() ) ); | 394 | SLOT( newTodo() ) ); |
395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
396 | SLOT( newSubTodo( Todo * ) ) ); | 396 | SLOT( newSubTodo( Todo * ) ) ); |
397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
398 | SLOT( editTodo( Todo * ) ) ); | 398 | SLOT( editTodo( Todo * ) ) ); |
399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
400 | SLOT( showTodo( Todo *) ) ); | 400 | SLOT( showTodo( Todo *) ) ); |
401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
402 | SLOT( deleteTodo( Todo *) ) ); | 402 | SLOT( deleteTodo( Todo *) ) ); |
403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
405 | SLOT( purgeCompleted() ) ); | 405 | SLOT( purgeCompleted() ) ); |
406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
407 | SIGNAL( todoModified( Todo *, int ) ) ); | 407 | SIGNAL( todoModified( Todo *, int ) ) ); |
408 | 408 | ||
409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
412 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 412 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
415 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 415 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
417 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 417 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
418 | 418 | ||
419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
420 | this, SLOT ( todo_unsub( Todo * ) ) ); | 420 | this, SLOT ( todo_unsub( Todo * ) ) ); |
421 | 421 | ||
422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
425 | SLOT( updateTodo( Todo *, int ) ) ); | 425 | SLOT( updateTodo( Todo *, int ) ) ); |
426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
428 | 428 | ||
429 | 429 | ||
430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
434 | 434 | ||
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
440 | SLOT(checkClipboard())); | 440 | SLOT(checkClipboard())); |
441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
442 | SLOT( processTodoListSelection( Incidence * ) ) ); | 442 | SLOT( processTodoListSelection( Incidence * ) ) ); |
443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
444 | 444 | ||
445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
446 | 446 | ||
447 | mDateFrame = new QVBox(0,0,WType_Popup); | 447 | mDateFrame = new QVBox(0,0,WType_Popup); |
448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
450 | mDateFrame->setLineWidth(3); | 450 | mDateFrame->setLineWidth(3); |
451 | mDateFrame->hide(); | 451 | mDateFrame->hide(); |
452 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 452 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
454 | 454 | ||
455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
456 | 456 | ||
457 | mEventEditor = mDialogManager->getEventEditor(); | 457 | mEventEditor = mDialogManager->getEventEditor(); |
458 | mTodoEditor = mDialogManager->getTodoEditor(); | 458 | mTodoEditor = mDialogManager->getTodoEditor(); |
459 | 459 | ||
460 | mFlagEditDescription = false; | 460 | mFlagEditDescription = false; |
461 | 461 | ||
462 | mSuspendTimer = new QTimer( this ); | 462 | mSuspendTimer = new QTimer( this ); |
463 | mAlarmTimer = new QTimer( this ); | 463 | mAlarmTimer = new QTimer( this ); |
464 | mRecheckAlarmTimer = new QTimer( this ); | 464 | mRecheckAlarmTimer = new QTimer( this ); |
465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
468 | mAlarmDialog = new AlarmDialog( this ); | 468 | mAlarmDialog = new AlarmDialog( this ); |
469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
470 | mAlarmDialog->setServerNotification( false ); | 470 | mAlarmDialog->setServerNotification( false ); |
471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
472 | 472 | ||
473 | 473 | ||
474 | #ifndef DESKTOP_VERSION | 474 | #ifndef DESKTOP_VERSION |
475 | //US listen for arriving address resultsets | 475 | //US listen for arriving address resultsets |
476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
478 | #endif | 478 | #endif |
479 | 479 | ||
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | CalendarView::~CalendarView() | 483 | CalendarView::~CalendarView() |
484 | { | 484 | { |
485 | // kdDebug() << "~CalendarView()" << endl; | 485 | // kdDebug() << "~CalendarView()" << endl; |
486 | //qDebug("CalendarView::~CalendarView() "); | 486 | //qDebug("CalendarView::~CalendarView() "); |
487 | delete mDialogManager; | 487 | delete mDialogManager; |
488 | delete mViewManager; | 488 | delete mViewManager; |
489 | delete mStorage; | 489 | delete mStorage; |
490 | delete mDateFrame ; | 490 | delete mDateFrame ; |
491 | delete beamDialog; | 491 | delete beamDialog; |
492 | //kdDebug() << "~CalendarView() done" << endl; | 492 | //kdDebug() << "~CalendarView() done" << endl; |
493 | } | 493 | } |
494 | void CalendarView::timerAlarm() | 494 | void CalendarView::timerAlarm() |
495 | { | 495 | { |
496 | //qDebug("CalendarView::timerAlarm() "); | 496 | //qDebug("CalendarView::timerAlarm() "); |
497 | computeAlarm(mAlarmNotification ); | 497 | computeAlarm(mAlarmNotification ); |
498 | } | 498 | } |
499 | 499 | ||
500 | void CalendarView::suspendAlarm() | 500 | void CalendarView::suspendAlarm() |
501 | { | 501 | { |
502 | //qDebug(" CalendarView::suspendAlarm() "); | 502 | //qDebug(" CalendarView::suspendAlarm() "); |
503 | computeAlarm(mSuspendAlarmNotification ); | 503 | computeAlarm(mSuspendAlarmNotification ); |
504 | 504 | ||
505 | } | 505 | } |
506 | 506 | ||
507 | void CalendarView::startAlarm( QString mess , QString filename) | 507 | void CalendarView::startAlarm( QString mess , QString filename) |
508 | { | 508 | { |
509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
511 | 511 | ||
512 | } | 512 | } |
513 | 513 | ||
514 | void CalendarView::checkNextTimerAlarm() | 514 | void CalendarView::checkNextTimerAlarm() |
515 | { | 515 | { |
516 | mCalendar->checkAlarmForIncidence( 0, true ); | 516 | mCalendar->checkAlarmForIncidence( 0, true ); |
517 | } | 517 | } |
518 | 518 | ||
519 | void CalendarView::computeAlarm( QString msg ) | 519 | void CalendarView::computeAlarm( QString msg ) |
520 | { | 520 | { |
521 | 521 | ||
522 | QString mess = msg; | 522 | QString mess = msg; |
523 | QString mAlarmMessage = mess.mid( 9 ); | 523 | QString mAlarmMessage = mess.mid( 9 ); |
524 | QString filename = MainWindow::resourcePath(); | 524 | QString filename = MainWindow::resourcePath(); |
525 | filename += "koalarm.wav"; | 525 | filename += "koalarm.wav"; |
526 | QString tempfilename; | 526 | QString tempfilename; |
527 | if ( mess.left( 13 ) == "suspend_alarm") { | 527 | if ( mess.left( 13 ) == "suspend_alarm") { |
528 | bool error = false; | 528 | bool error = false; |
529 | int len = mess.mid( 13 ).find("+++"); | 529 | int len = mess.mid( 13 ).find("+++"); |
530 | if ( len < 2 ) | 530 | if ( len < 2 ) |
531 | error = true; | 531 | error = true; |
532 | else { | 532 | else { |
533 | tempfilename = mess.mid( 13, len ); | 533 | tempfilename = mess.mid( 13, len ); |
534 | if ( !QFile::exists( tempfilename ) ) | 534 | if ( !QFile::exists( tempfilename ) ) |
535 | error = true; | 535 | error = true; |
536 | } | 536 | } |
537 | if ( ! error ) { | 537 | if ( ! error ) { |
538 | filename = tempfilename; | 538 | filename = tempfilename; |
539 | } | 539 | } |
540 | mAlarmMessage = mess.mid( 13+len+3 ); | 540 | mAlarmMessage = mess.mid( 13+len+3 ); |
541 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 541 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
542 | startAlarm( mAlarmMessage, filename); | 542 | startAlarm( mAlarmMessage, filename); |
543 | return; | 543 | return; |
544 | } | 544 | } |
545 | if ( mess.left( 11 ) == "timer_alarm") { | 545 | if ( mess.left( 11 ) == "timer_alarm") { |
546 | //mTimerTime = 0; | 546 | //mTimerTime = 0; |
547 | startAlarm( mess.mid( 11 ), filename ); | 547 | startAlarm( mess.mid( 11 ), filename ); |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | if ( mess.left( 10 ) == "proc_alarm") { | 550 | if ( mess.left( 10 ) == "proc_alarm") { |
551 | bool error = false; | 551 | bool error = false; |
552 | int len = mess.mid( 10 ).find("+++"); | 552 | int len = mess.mid( 10 ).find("+++"); |
553 | if ( len < 2 ) | 553 | if ( len < 2 ) |
554 | error = true; | 554 | error = true; |
555 | else { | 555 | else { |
556 | tempfilename = mess.mid( 10, len ); | 556 | tempfilename = mess.mid( 10, len ); |
557 | if ( !QFile::exists( tempfilename ) ) | 557 | if ( !QFile::exists( tempfilename ) ) |
558 | error = true; | 558 | error = true; |
559 | } | 559 | } |
560 | if ( error ) { | 560 | if ( error ) { |
561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
562 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 562 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
563 | } else { | 563 | } else { |
564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
565 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 565 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
566 | #ifndef _WIN32_ | 566 | #ifndef _WIN32_ |
567 | if ( vfork () == 0 ) { | 567 | if ( vfork () == 0 ) { |
568 | execl ( tempfilename.latin1(), 0 ); | 568 | execl ( tempfilename.latin1(), 0 ); |
569 | return; | 569 | return; |
570 | } | 570 | } |
571 | #else | 571 | #else |
572 | QProcess* p = new QProcess(); | 572 | QProcess* p = new QProcess(); |
573 | p->addArgument( tempfilename.latin1() ); | 573 | p->addArgument( tempfilename.latin1() ); |
574 | p->start(); | 574 | p->start(); |
575 | return; | 575 | return; |
576 | #endif | 576 | #endif |
577 | 577 | ||
578 | return; | 578 | return; |
579 | } | 579 | } |
580 | 580 | ||
581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 11 ) == "audio_alarm") { | 583 | if ( mess.left( 11 ) == "audio_alarm") { |
584 | bool error = false; | 584 | bool error = false; |
585 | int len = mess.mid( 11 ).find("+++"); | 585 | int len = mess.mid( 11 ).find("+++"); |
586 | if ( len < 2 ) | 586 | if ( len < 2 ) |
587 | error = true; | 587 | error = true; |
588 | else { | 588 | else { |
589 | tempfilename = mess.mid( 11, len ); | 589 | tempfilename = mess.mid( 11, len ); |
590 | if ( !QFile::exists( tempfilename ) ) | 590 | if ( !QFile::exists( tempfilename ) ) |
591 | error = true; | 591 | error = true; |
592 | } | 592 | } |
593 | if ( ! error ) { | 593 | if ( ! error ) { |
594 | filename = tempfilename; | 594 | filename = tempfilename; |
595 | } | 595 | } |
596 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 596 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
597 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 597 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
598 | } | 598 | } |
599 | if ( mess.left( 9 ) == "cal_alarm") { | 599 | if ( mess.left( 9 ) == "cal_alarm") { |
600 | mAlarmMessage = mess.mid( 9 ) ; | 600 | mAlarmMessage = mess.mid( 9 ) ; |
601 | } | 601 | } |
602 | 602 | ||
603 | startAlarm( mAlarmMessage, filename ); | 603 | startAlarm( mAlarmMessage, filename ); |
604 | 604 | ||
605 | 605 | ||
606 | } | 606 | } |
607 | 607 | ||
608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
609 | { | 609 | { |
610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
611 | 611 | ||
612 | mSuspendAlarmNotification = noti; | 612 | mSuspendAlarmNotification = noti; |
613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
615 | mSuspendTimer->start( ms , true ); | 615 | mSuspendTimer->start( ms , true ); |
616 | 616 | ||
617 | } | 617 | } |
618 | 618 | ||
619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
620 | { | 620 | { |
621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
623 | #ifndef DESKTOP_VERSION | 623 | #ifndef DESKTOP_VERSION |
624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
625 | #endif | 625 | #endif |
626 | return; | 626 | return; |
627 | } | 627 | } |
628 | int maxSec; | 628 | int maxSec; |
629 | //maxSec = 5; //testing only | 629 | //maxSec = 5; //testing only |
630 | maxSec = 86400+3600; // one day+1hour | 630 | maxSec = 86400+3600; // one day+1hour |
631 | mAlarmNotification = noti; | 631 | mAlarmNotification = noti; |
632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
633 | if ( sec > maxSec ) { | 633 | if ( sec > maxSec ) { |
634 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 634 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
636 | return; | 636 | return; |
637 | } else { | 637 | } else { |
638 | mRecheckAlarmTimer->stop(); | 638 | mRecheckAlarmTimer->stop(); |
639 | } | 639 | } |
640 | //qDebug("Alarm timer started with secs: %d ", sec); | 640 | //qDebug("Alarm timer started with secs: %d ", sec); |
641 | mAlarmTimer->start( sec *1000 , true ); | 641 | mAlarmTimer->start( sec *1000 , true ); |
642 | 642 | ||
643 | } | 643 | } |
644 | // called by mRecheckAlarmTimer to get next alarm | 644 | // called by mRecheckAlarmTimer to get next alarm |
645 | // we need this, because a QTimer has only a max range of 25 days | 645 | // we need this, because a QTimer has only a max range of 25 days |
646 | void CalendarView::recheckTimerAlarm() | 646 | void CalendarView::recheckTimerAlarm() |
647 | { | 647 | { |
648 | mAlarmTimer->stop(); | 648 | mAlarmTimer->stop(); |
649 | mRecheckAlarmTimer->stop(); | 649 | mRecheckAlarmTimer->stop(); |
650 | mCalendar->checkAlarmForIncidence( 0, true ); | 650 | mCalendar->checkAlarmForIncidence( 0, true ); |
651 | } | 651 | } |
652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
653 | { | 653 | { |
654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
656 | #ifndef DESKTOP_VERSION | 656 | #ifndef DESKTOP_VERSION |
657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
658 | #endif | 658 | #endif |
659 | return; | 659 | return; |
660 | } | 660 | } |
661 | mAlarmTimer->stop(); | 661 | mAlarmTimer->stop(); |
662 | } | 662 | } |
663 | void CalendarView::selectWeekNum ( int num ) | 663 | void CalendarView::selectWeekNum ( int num ) |
664 | { | 664 | { |
665 | dateNavigator()->selectWeek( num ); | 665 | dateNavigator()->selectWeek( num ); |
666 | mViewManager->showWeekView(); | 666 | mViewManager->showWeekView(); |
667 | } | 667 | } |
668 | KOViewManager *CalendarView::viewManager() | 668 | KOViewManager *CalendarView::viewManager() |
669 | { | 669 | { |
670 | return mViewManager; | 670 | return mViewManager; |
671 | } | 671 | } |
672 | 672 | ||
673 | KODialogManager *CalendarView::dialogManager() | 673 | KODialogManager *CalendarView::dialogManager() |
674 | { | 674 | { |
675 | return mDialogManager; | 675 | return mDialogManager; |
676 | } | 676 | } |
677 | 677 | ||
678 | QDate CalendarView::startDate() | 678 | QDate CalendarView::startDate() |
679 | { | 679 | { |
680 | DateList dates = mNavigator->selectedDates(); | 680 | DateList dates = mNavigator->selectedDates(); |
681 | 681 | ||
682 | return dates.first(); | 682 | return dates.first(); |
683 | } | 683 | } |
684 | 684 | ||
685 | QDate CalendarView::endDate() | 685 | QDate CalendarView::endDate() |
686 | { | 686 | { |
687 | DateList dates = mNavigator->selectedDates(); | 687 | DateList dates = mNavigator->selectedDates(); |
688 | 688 | ||
689 | return dates.last(); | 689 | return dates.last(); |
690 | } | 690 | } |
691 | 691 | ||
692 | 692 | ||
693 | void CalendarView::createPrinter() | 693 | void CalendarView::createPrinter() |
694 | { | 694 | { |
695 | #ifndef KORG_NOPRINTER | 695 | #ifndef KORG_NOPRINTER |
696 | if (!mCalPrinter) { | 696 | if (!mCalPrinter) { |
697 | mCalPrinter = new CalPrinter(this, mCalendar); | 697 | mCalPrinter = new CalPrinter(this, mCalendar); |
698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
699 | } | 699 | } |
700 | #endif | 700 | #endif |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | //KOPrefs::instance()->mWriteBackFile | 704 | //KOPrefs::instance()->mWriteBackFile |
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 705 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 706 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 713 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 715 | { |
716 | 716 | ||
717 | // 0 equal | 717 | // 0 equal |
718 | // 1 take local | 718 | // 1 take local |
719 | // 2 take remote | 719 | // 2 take remote |
720 | // 3 cancel | 720 | // 3 cancel |
721 | QDateTime lastSync = mLastCalendarSync; | 721 | QDateTime lastSync = mLastCalendarSync; |
722 | QDateTime localMod = local->lastModified(); | 722 | QDateTime localMod = local->lastModified(); |
723 | QDateTime remoteMod = remote->lastModified(); | 723 | QDateTime remoteMod = remote->lastModified(); |
724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
725 | bool remCh, locCh; | 725 | bool remCh, locCh; |
726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
727 | //if ( remCh ) | 727 | //if ( remCh ) |
728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
729 | locCh = ( localMod > mLastCalendarSync ); | 729 | locCh = ( localMod > mLastCalendarSync ); |
730 | if ( !remCh && ! locCh ) { | 730 | if ( !remCh && ! locCh ) { |
731 | //qDebug("both not changed "); | 731 | //qDebug("both not changed "); |
732 | lastSync = localMod.addDays(1); | 732 | lastSync = localMod.addDays(1); |
733 | if ( mode <= SYNC_PREF_ASK ) | 733 | if ( mode <= SYNC_PREF_ASK ) |
734 | return 0; | 734 | return 0; |
735 | } else { | 735 | } else { |
736 | if ( locCh ) { | 736 | if ( locCh ) { |
737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
738 | lastSync = localMod.addDays( -1 ); | 738 | lastSync = localMod.addDays( -1 ); |
739 | if ( !remCh ) | 739 | if ( !remCh ) |
740 | remoteMod = ( lastSync.addDays( -1 ) ); | 740 | remoteMod = ( lastSync.addDays( -1 ) ); |
741 | } else { | 741 | } else { |
742 | //qDebug(" not loc changed "); | 742 | //qDebug(" not loc changed "); |
743 | lastSync = localMod.addDays( 1 ); | 743 | lastSync = localMod.addDays( 1 ); |
744 | if ( remCh ) | 744 | if ( remCh ) |
745 | remoteMod =( lastSync.addDays( 1 ) ); | 745 | remoteMod =( lastSync.addDays( 1 ) ); |
746 | 746 | ||
747 | } | 747 | } |
748 | } | 748 | } |
749 | full = true; | 749 | full = true; |
750 | if ( mode < SYNC_PREF_ASK ) | 750 | if ( mode < SYNC_PREF_ASK ) |
751 | mode = SYNC_PREF_ASK; | 751 | mode = SYNC_PREF_ASK; |
752 | } else { | 752 | } else { |
753 | if ( localMod == remoteMod ) | 753 | if ( localMod == remoteMod ) |
754 | // if ( local->revision() == remote->revision() ) | 754 | // if ( local->revision() == remote->revision() ) |
755 | return 0; | 755 | return 0; |
756 | 756 | ||
757 | } | 757 | } |
758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
759 | 759 | ||
760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
762 | //full = true; //debug only | 762 | //full = true; //debug only |
763 | if ( full ) { | 763 | if ( full ) { |
764 | bool equ = false; | 764 | bool equ = false; |
765 | if ( local->type() == "Event" ) { | 765 | if ( local->type() == "Event" ) { |
766 | equ = (*((Event*) local) == *((Event*) remote)); | 766 | equ = (*((Event*) local) == *((Event*) remote)); |
767 | } | 767 | } |
768 | else if ( local->type() =="Todo" ) | 768 | else if ( local->type() =="Todo" ) |
769 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 769 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
770 | else if ( local->type() =="Journal" ) | 770 | else if ( local->type() =="Journal" ) |
771 | equ = (*((Journal*) local) == *((Journal*) remote)); | 771 | equ = (*((Journal*) local) == *((Journal*) remote)); |
772 | if ( equ ) { | 772 | if ( equ ) { |
773 | //qDebug("equal "); | 773 | //qDebug("equal "); |
774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
776 | } | 776 | } |
777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
778 | return 0; | 778 | return 0; |
779 | 779 | ||
780 | }//else //debug only | 780 | }//else //debug only |
781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
782 | } | 782 | } |
783 | int result; | 783 | int result; |
784 | bool localIsNew; | 784 | bool localIsNew; |
785 | //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() ); | 785 | //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() ); |
786 | 786 | ||
787 | if ( full && mode < SYNC_PREF_NEWEST ) | 787 | if ( full && mode < SYNC_PREF_NEWEST ) |
788 | mode = SYNC_PREF_ASK; | 788 | mode = SYNC_PREF_ASK; |
789 | 789 | ||
790 | switch( mode ) { | 790 | switch( mode ) { |
791 | case SYNC_PREF_LOCAL: | 791 | case SYNC_PREF_LOCAL: |
792 | if ( lastSync > remoteMod ) | 792 | if ( lastSync > remoteMod ) |
793 | return 1; | 793 | return 1; |
794 | if ( lastSync > localMod ) | 794 | if ( lastSync > localMod ) |
795 | return 2; | 795 | return 2; |
796 | return 1; | 796 | return 1; |
797 | break; | 797 | break; |
798 | case SYNC_PREF_REMOTE: | 798 | case SYNC_PREF_REMOTE: |
799 | if ( lastSync > remoteMod ) | 799 | if ( lastSync > remoteMod ) |
800 | return 1; | 800 | return 1; |
801 | if ( lastSync > localMod ) | 801 | if ( lastSync > localMod ) |
802 | return 2; | 802 | return 2; |
803 | return 2; | 803 | return 2; |
804 | break; | 804 | break; |
805 | case SYNC_PREF_NEWEST: | 805 | case SYNC_PREF_NEWEST: |
806 | if ( localMod > remoteMod ) | 806 | if ( localMod > remoteMod ) |
807 | return 1; | 807 | return 1; |
808 | else | 808 | else |
809 | return 2; | 809 | return 2; |
810 | break; | 810 | break; |
811 | case SYNC_PREF_ASK: | 811 | case SYNC_PREF_ASK: |
812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
813 | if ( lastSync > remoteMod ) | 813 | if ( lastSync > remoteMod ) |
814 | return 1; | 814 | return 1; |
815 | if ( lastSync > localMod ) | 815 | if ( lastSync > localMod ) |
816 | return 2; | 816 | return 2; |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
818 | localIsNew = localMod >= remoteMod; | 818 | localIsNew = localMod >= remoteMod; |
819 | if ( localIsNew ) | 819 | if ( localIsNew ) |
820 | getEventViewerDialog()->setColorMode( 1 ); | 820 | getEventViewerDialog()->setColorMode( 1 ); |
821 | else | 821 | else |
822 | getEventViewerDialog()->setColorMode( 2 ); | 822 | getEventViewerDialog()->setColorMode( 2 ); |
823 | getEventViewerDialog()->setIncidence(local); | 823 | getEventViewerDialog()->setIncidence(local); |
824 | if ( localIsNew ) | 824 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 2 ); | 825 | getEventViewerDialog()->setColorMode( 2 ); |
826 | else | 826 | else |
827 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
828 | getEventViewerDialog()->addIncidence(remote); | 828 | getEventViewerDialog()->addIncidence(remote); |
829 | getEventViewerDialog()->setColorMode( 0 ); | 829 | getEventViewerDialog()->setColorMode( 0 ); |
830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
832 | getEventViewerDialog()->showMe(); | 832 | getEventViewerDialog()->showMe(); |
833 | result = getEventViewerDialog()->executeS( localIsNew ); | 833 | result = getEventViewerDialog()->executeS( localIsNew ); |
834 | return result; | 834 | return result; |
835 | 835 | ||
836 | break; | 836 | break; |
837 | case SYNC_PREF_FORCE_LOCAL: | 837 | case SYNC_PREF_FORCE_LOCAL: |
838 | return 1; | 838 | return 1; |
839 | break; | 839 | break; |
840 | case SYNC_PREF_FORCE_REMOTE: | 840 | case SYNC_PREF_FORCE_REMOTE: |
841 | return 2; | 841 | return 2; |
842 | break; | 842 | break; |
843 | 843 | ||
844 | default: | 844 | default: |
845 | // SYNC_PREF_TAKE_BOTH not implemented | 845 | // SYNC_PREF_TAKE_BOTH not implemented |
846 | break; | 846 | break; |
847 | } | 847 | } |
848 | return 0; | 848 | return 0; |
849 | } | 849 | } |
850 | Event* CalendarView::getLastSyncEvent() | 850 | Event* CalendarView::getLastSyncEvent() |
851 | { | 851 | { |
852 | Event* lse; | 852 | Event* lse; |
853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
855 | if (!lse) { | 855 | if (!lse) { |
856 | lse = new Event(); | 856 | lse = new Event(); |
857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
858 | QString sum = ""; | 858 | QString sum = ""; |
859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
860 | sum = "E: "; | 860 | sum = "E: "; |
861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
862 | lse->setDtStart( mLastCalendarSync ); | 862 | lse->setDtStart( mLastCalendarSync ); |
863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
864 | lse->setCategories( i18n("SyncEvent") ); | 864 | lse->setCategories( i18n("SyncEvent") ); |
865 | lse->setReadOnly( true ); | 865 | lse->setReadOnly( true ); |
866 | mCalendar->addEvent( lse ); | 866 | mCalendar->addEvent( lse ); |
867 | } | 867 | } |
868 | 868 | ||
869 | return lse; | 869 | return lse; |
870 | 870 | ||
871 | } | 871 | } |
872 | 872 | ||
873 | // we check, if the to delete event has a id for a profile | 873 | // we check, if the to delete event has a id for a profile |
874 | // if yes, we set this id in the profile to delete | 874 | // if yes, we set this id in the profile to delete |
875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
876 | { | 876 | { |
877 | if ( lastSync.count() == 0 ) { | 877 | if ( lastSync.count() == 0 ) { |
878 | //qDebug(" lastSync.count() == 0"); | 878 | //qDebug(" lastSync.count() == 0"); |
879 | return; | 879 | return; |
880 | } | 880 | } |
881 | if ( toDelete->type() == "Journal" ) | 881 | if ( toDelete->type() == "Journal" ) |
882 | return; | 882 | return; |
883 | 883 | ||
884 | Event* eve = lastSync.first(); | 884 | Event* eve = lastSync.first(); |
885 | 885 | ||
886 | while ( eve ) { | 886 | while ( eve ) { |
887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
888 | if ( !id.isEmpty() ) { | 888 | if ( !id.isEmpty() ) { |
889 | QString des = eve->description(); | 889 | QString des = eve->description(); |
890 | QString pref = "e"; | 890 | QString pref = "e"; |
891 | if ( toDelete->type() == "Todo" ) | 891 | if ( toDelete->type() == "Todo" ) |
892 | pref = "t"; | 892 | pref = "t"; |
893 | des += pref+ id + ","; | 893 | des += pref+ id + ","; |
894 | eve->setReadOnly( false ); | 894 | eve->setReadOnly( false ); |
895 | eve->setDescription( des ); | 895 | eve->setDescription( des ); |
896 | //qDebug("setdes %s ", des.latin1()); | 896 | //qDebug("setdes %s ", des.latin1()); |
897 | eve->setReadOnly( true ); | 897 | eve->setReadOnly( true ); |
898 | } | 898 | } |
899 | eve = lastSync.next(); | 899 | eve = lastSync.next(); |
900 | } | 900 | } |
901 | 901 | ||
902 | } | 902 | } |
903 | void CalendarView::checkExternalId( Incidence * inc ) | 903 | void CalendarView::checkExternalId( Incidence * inc ) |
904 | { | 904 | { |
905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
906 | checkExternSyncEvent( lastSync, inc ); | 906 | checkExternSyncEvent( lastSync, inc ); |
907 | 907 | ||
908 | } | 908 | } |
909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
910 | { | 910 | { |
911 | bool syncOK = true; | 911 | bool syncOK = true; |
912 | int addedEvent = 0; | 912 | int addedEvent = 0; |
913 | int addedEventR = 0; | 913 | int addedEventR = 0; |
914 | int deletedEventR = 0; | 914 | int deletedEventR = 0; |
915 | int deletedEventL = 0; | 915 | int deletedEventL = 0; |
916 | int changedLocal = 0; | 916 | int changedLocal = 0; |
917 | int changedRemote = 0; | 917 | int changedRemote = 0; |
918 | //QPtrList<Event> el = local->rawEvents(); | 918 | //QPtrList<Event> el = local->rawEvents(); |
919 | Event* eventR; | 919 | Event* eventR; |
920 | QString uid; | 920 | QString uid; |
921 | int take; | 921 | int take; |
922 | Event* eventL; | 922 | Event* eventL; |
923 | Event* eventRSync; | 923 | Event* eventRSync; |
924 | Event* eventLSync; | 924 | Event* eventLSync; |
925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
927 | bool fullDateRange = false; | 927 | bool fullDateRange = false; |
928 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
929 | mLastCalendarSync = QDateTime::currentDateTime(); | 929 | mLastCalendarSync = QDateTime::currentDateTime(); |
930 | if ( mSyncManager->syncWithDesktop() ) { | 930 | if ( mSyncManager->syncWithDesktop() ) { |
931 | remote->resetPilotStat(1); | 931 | remote->resetPilotStat(1); |
932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
935 | } else { | 935 | } else { |
936 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); | 936 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); |
937 | } | 937 | } |
938 | } | 938 | } |
939 | QDateTime modifiedCalendar = mLastCalendarSync;; | 939 | QDateTime modifiedCalendar = mLastCalendarSync;; |
940 | eventLSync = getLastSyncEvent(); | 940 | eventLSync = getLastSyncEvent(); |
941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
942 | if ( eventR ) { | 942 | if ( eventR ) { |
943 | eventRSync = (Event*) eventR->clone(); | 943 | eventRSync = (Event*) eventR->clone(); |
944 | remote->deleteEvent(eventR ); | 944 | remote->deleteEvent(eventR ); |
945 | 945 | ||
946 | } else { | 946 | } else { |
947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
948 | eventRSync = (Event*)eventLSync->clone(); | 948 | eventRSync = (Event*)eventLSync->clone(); |
949 | } else { | 949 | } else { |
950 | fullDateRange = true; | 950 | fullDateRange = true; |
951 | eventRSync = new Event(); | 951 | eventRSync = new Event(); |
952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
954 | eventRSync->setDtStart( mLastCalendarSync ); | 954 | eventRSync->setDtStart( mLastCalendarSync ); |
955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
956 | eventRSync->setCategories( i18n("SyncEvent") ); | 956 | eventRSync->setCategories( i18n("SyncEvent") ); |
957 | } | 957 | } |
958 | } | 958 | } |
959 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 959 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | 961 | ||
962 | if ( ! fullDateRange ) { | 962 | if ( ! fullDateRange ) { |
963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
964 | 964 | ||
965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
967 | fullDateRange = true; | 967 | fullDateRange = true; |
968 | } | 968 | } |
969 | } | 969 | } |
970 | if ( mSyncManager->syncWithDesktop() ) { | 970 | if ( mSyncManager->syncWithDesktop() ) { |
971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); | 971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); |
972 | } | 972 | } |
973 | if ( fullDateRange ) | 973 | if ( fullDateRange ) |
974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
975 | else | 975 | else |
976 | mLastCalendarSync = eventLSync->dtStart(); | 976 | mLastCalendarSync = eventLSync->dtStart(); |
977 | // for resyncing if own file has changed | 977 | // for resyncing if own file has changed |
978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
979 | mLastCalendarSync = loadedFileVersion; | 979 | mLastCalendarSync = loadedFileVersion; |
980 | //qDebug("setting mLastCalendarSync "); | 980 | //qDebug("setting mLastCalendarSync "); |
981 | } | 981 | } |
982 | //qDebug("*************************** "); | 982 | //qDebug("*************************** "); |
983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
984 | QPtrList<Incidence> er = remote->rawIncidences(); | 984 | QPtrList<Incidence> er = remote->rawIncidences(); |
985 | Incidence* inR = er.first(); | 985 | Incidence* inR = er.first(); |
986 | Incidence* inL; | 986 | Incidence* inL; |
987 | QProgressBar bar( er.count(),0 ); | 987 | QProgressBar bar( er.count(),0 ); |
988 | bar.setCaption (i18n("Syncing - close to abort!") ); | 988 | bar.setCaption (i18n("Syncing - close to abort!") ); |
989 | 989 | ||
990 | int w = 300; | 990 | int w = 300; |
991 | if ( QApplication::desktop()->width() < 320 ) | 991 | if ( QApplication::desktop()->width() < 320 ) |
992 | w = 220; | 992 | w = 220; |
993 | int h = bar.sizeHint().height() ; | 993 | int h = bar.sizeHint().height() ; |
994 | int dw = QApplication::desktop()->width(); | 994 | int dw = QApplication::desktop()->width(); |
995 | int dh = QApplication::desktop()->height(); | 995 | int dh = QApplication::desktop()->height(); |
996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
997 | bar.show(); | 997 | bar.show(); |
998 | int modulo = (er.count()/10)+1; | 998 | int modulo = (er.count()/10)+1; |
999 | int incCounter = 0; | 999 | int incCounter = 0; |
1000 | while ( inR ) { | 1000 | while ( inR ) { |
1001 | if ( ! bar.isVisible() ) | 1001 | if ( ! bar.isVisible() ) |
1002 | return false; | 1002 | return false; |
1003 | if ( incCounter % modulo == 0 ) | 1003 | if ( incCounter % modulo == 0 ) |
1004 | bar.setProgress( incCounter ); | 1004 | bar.setProgress( incCounter ); |
1005 | ++incCounter; | 1005 | ++incCounter; |
1006 | uid = inR->uid(); | 1006 | uid = inR->uid(); |
1007 | bool skipIncidence = false; | 1007 | bool skipIncidence = false; |
1008 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1008 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1009 | skipIncidence = true; | 1009 | skipIncidence = true; |
1010 | QString idS; | 1010 | QString idS; |
1011 | qApp->processEvents(); | 1011 | qApp->processEvents(); |
1012 | if ( !skipIncidence ) { | 1012 | if ( !skipIncidence ) { |
1013 | inL = local->incidence( uid ); | 1013 | inL = local->incidence( uid ); |
1014 | if ( inL ) { // maybe conflict - same uid in both calendars | 1014 | if ( inL ) { // maybe conflict - same uid in both calendars |
1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1017 | if ( take == 3 ) | 1017 | if ( take == 3 ) |
1018 | return false; | 1018 | return false; |
1019 | if ( take == 1 ) {// take local | 1019 | if ( take == 1 ) {// take local |
1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1022 | else | 1022 | else |
1023 | idS = inR->IDStr(); | 1023 | idS = inR->IDStr(); |
1024 | remote->deleteIncidence( inR ); | 1024 | remote->deleteIncidence( inR ); |
1025 | inR = inL->clone(); | 1025 | inR = inL->clone(); |
1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1028 | inR->setIDStr( idS ); | 1028 | inR->setIDStr( idS ); |
1029 | remote->addIncidence( inR ); | 1029 | remote->addIncidence( inR ); |
1030 | if ( mSyncManager->syncWithDesktop() ) | 1030 | if ( mSyncManager->syncWithDesktop() ) |
1031 | inR->setPilotId( 2 ); | 1031 | inR->setPilotId( 2 ); |
1032 | ++changedRemote; | 1032 | ++changedRemote; |
1033 | } else { | 1033 | } else { |
1034 | idS = inL->IDStr(); | 1034 | idS = inL->IDStr(); |
1035 | int pid = inL->pilotId(); | 1035 | int pid = inL->pilotId(); |
1036 | local->deleteIncidence( inL ); | 1036 | local->deleteIncidence( inL ); |
1037 | inL = inR->clone(); | 1037 | inL = inR->clone(); |
1038 | if ( mSyncManager->syncWithDesktop() ) | 1038 | if ( mSyncManager->syncWithDesktop() ) |
1039 | inL->setPilotId( pid ); | 1039 | inL->setPilotId( pid ); |
1040 | inL->setIDStr( idS ); | 1040 | inL->setIDStr( idS ); |
1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1044 | } | 1044 | } |
1045 | local->addIncidence( inL ); | 1045 | local->addIncidence( inL ); |
1046 | ++changedLocal; | 1046 | ++changedLocal; |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | } else { // no conflict | 1049 | } else { // no conflict |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1051 | QString des = eventLSync->description(); | 1051 | QString des = eventLSync->description(); |
1052 | QString pref = "e"; | 1052 | QString pref = "e"; |
1053 | if ( inR->type() == "Todo" ) | 1053 | if ( inR->type() == "Todo" ) |
1054 | pref = "t"; | 1054 | pref = "t"; |
1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1057 | //remote->deleteIncidence( inR ); | 1057 | //remote->deleteIncidence( inR ); |
1058 | ++deletedEventR; | 1058 | ++deletedEventR; |
1059 | } else { | 1059 | } else { |
1060 | inR->setLastModified( modifiedCalendar ); | 1060 | inR->setLastModified( modifiedCalendar ); |
1061 | inL = inR->clone(); | 1061 | inL = inR->clone(); |
1062 | inL->setIDStr( ":" ); | 1062 | inL->setIDStr( ":" ); |
1063 | local->addIncidence( inL ); | 1063 | local->addIncidence( inL ); |
1064 | ++addedEvent; | 1064 | ++addedEvent; |
1065 | } | 1065 | } |
1066 | } else { | 1066 | } else { |
1067 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1067 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1068 | inR->setLastModified( modifiedCalendar ); | 1068 | inR->setLastModified( modifiedCalendar ); |
1069 | inL = inR->clone(); | 1069 | inL = inR->clone(); |
1070 | inL->setIDStr( ":" ); | 1070 | inL->setIDStr( ":" ); |
1071 | local->addIncidence( inL ); | 1071 | local->addIncidence( inL ); |
1072 | ++addedEvent; | 1072 | ++addedEvent; |
1073 | } else { | 1073 | } else { |
1074 | checkExternSyncEvent(eventRSyncSharp, inR); | 1074 | checkExternSyncEvent(eventRSyncSharp, inR); |
1075 | remote->deleteIncidence( inR ); | 1075 | remote->deleteIncidence( inR ); |
1076 | ++deletedEventR; | 1076 | ++deletedEventR; |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | } | 1079 | } |
1080 | } | 1080 | } |
1081 | inR = er.next(); | 1081 | inR = er.next(); |
1082 | } | 1082 | } |
1083 | QPtrList<Incidence> el = local->rawIncidences(); | 1083 | QPtrList<Incidence> el = local->rawIncidences(); |
1084 | inL = el.first(); | 1084 | inL = el.first(); |
1085 | modulo = (el.count()/10)+1; | 1085 | modulo = (el.count()/10)+1; |
1086 | bar.setCaption (i18n("Add / remove events") ); | 1086 | bar.setCaption (i18n("Add / remove events") ); |
1087 | bar.setTotalSteps ( el.count() ) ; | 1087 | bar.setTotalSteps ( el.count() ) ; |
1088 | bar.show(); | 1088 | bar.show(); |
1089 | incCounter = 0; | 1089 | incCounter = 0; |
1090 | 1090 | ||
1091 | while ( inL ) { | 1091 | while ( inL ) { |
1092 | 1092 | ||
1093 | qApp->processEvents(); | 1093 | qApp->processEvents(); |
1094 | if ( ! bar.isVisible() ) | 1094 | if ( ! bar.isVisible() ) |
1095 | return false; | 1095 | return false; |
1096 | if ( incCounter % modulo == 0 ) | 1096 | if ( incCounter % modulo == 0 ) |
1097 | bar.setProgress( incCounter ); | 1097 | bar.setProgress( incCounter ); |
1098 | ++incCounter; | 1098 | ++incCounter; |
1099 | uid = inL->uid(); | 1099 | uid = inL->uid(); |
1100 | bool skipIncidence = false; | 1100 | bool skipIncidence = false; |
1101 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1101 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1102 | skipIncidence = true; | 1102 | skipIncidence = true; |
1103 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1103 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1104 | skipIncidence = true; | 1104 | skipIncidence = true; |
1105 | if ( !skipIncidence ) { | 1105 | if ( !skipIncidence ) { |
1106 | inR = remote->incidence( uid ); | 1106 | inR = remote->incidence( uid ); |
1107 | if ( ! inR ) { | 1107 | if ( ! inR ) { |
1108 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1108 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1109 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1109 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1110 | checkExternSyncEvent(eventLSyncSharp, inL); | 1110 | checkExternSyncEvent(eventLSyncSharp, inL); |
1111 | local->deleteIncidence( inL ); | 1111 | local->deleteIncidence( inL ); |
1112 | ++deletedEventL; | 1112 | ++deletedEventL; |
1113 | } else { | 1113 | } else { |
1114 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1114 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1115 | inL->removeID(mCurrentSyncDevice ); | 1115 | inL->removeID(mCurrentSyncDevice ); |
1116 | ++addedEventR; | 1116 | ++addedEventR; |
1117 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1117 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1118 | inL->setLastModified( modifiedCalendar ); | 1118 | inL->setLastModified( modifiedCalendar ); |
1119 | inR = inL->clone(); | 1119 | inR = inL->clone(); |
1120 | inR->setIDStr( ":" ); | 1120 | inR->setIDStr( ":" ); |
1121 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1121 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1122 | remote->addIncidence( inR ); | 1122 | remote->addIncidence( inR ); |
1123 | } | 1123 | } |
1124 | } | 1124 | } |
1125 | } else { | 1125 | } else { |
1126 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1126 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1127 | checkExternSyncEvent(eventLSyncSharp, inL); | 1127 | checkExternSyncEvent(eventLSyncSharp, inL); |
1128 | local->deleteIncidence( inL ); | 1128 | local->deleteIncidence( inL ); |
1129 | ++deletedEventL; | 1129 | ++deletedEventL; |
1130 | } else { | 1130 | } else { |
1131 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1131 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1132 | ++addedEventR; | 1132 | ++addedEventR; |
1133 | inL->setLastModified( modifiedCalendar ); | 1133 | inL->setLastModified( modifiedCalendar ); |
1134 | inR = inL->clone(); | 1134 | inR = inL->clone(); |
1135 | inR->setIDStr( ":" ); | 1135 | inR->setIDStr( ":" ); |
1136 | remote->addIncidence( inR ); | 1136 | remote->addIncidence( inR ); |
1137 | } | 1137 | } |
1138 | } | 1138 | } |
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | } | 1141 | } |
1142 | inL = el.next(); | 1142 | inL = el.next(); |
1143 | } | 1143 | } |
1144 | int delFut = 0; | 1144 | int delFut = 0; |
1145 | int remRem = 0; | 1145 | int remRem = 0; |
1146 | if ( mSyncManager->mWriteBackInFuture ) { | 1146 | if ( mSyncManager->mWriteBackInFuture ) { |
1147 | er = remote->rawIncidences(); | 1147 | er = remote->rawIncidences(); |
1148 | remRem = er.count(); | 1148 | remRem = er.count(); |
1149 | inR = er.first(); | 1149 | inR = er.first(); |
1150 | QDateTime dt; | 1150 | QDateTime dt; |
1151 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1151 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1152 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1152 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1153 | while ( inR ) { | 1153 | while ( inR ) { |
1154 | if ( inR->type() == "Todo" ) { | 1154 | if ( inR->type() == "Todo" ) { |
1155 | Todo * t = (Todo*)inR; | 1155 | Todo * t = (Todo*)inR; |
1156 | if ( t->hasDueDate() ) | 1156 | if ( t->hasDueDate() ) |
1157 | dt = t->dtDue(); | 1157 | dt = t->dtDue(); |
1158 | else | 1158 | else |
1159 | dt = cur.addSecs( 62 ); | 1159 | dt = cur.addSecs( 62 ); |
1160 | } | 1160 | } |
1161 | else if (inR->type() == "Event" ) { | 1161 | else if (inR->type() == "Event" ) { |
1162 | bool ok; | 1162 | bool ok; |
1163 | dt = inR->getNextOccurence( cur, &ok ); | 1163 | dt = inR->getNextOccurence( cur, &ok ); |
1164 | if ( !ok ) | 1164 | if ( !ok ) |
1165 | dt = cur.addSecs( -62 ); | 1165 | dt = cur.addSecs( -62 ); |
1166 | } | 1166 | } |
1167 | else | 1167 | else |
1168 | dt = inR->dtStart(); | 1168 | dt = inR->dtStart(); |
1169 | if ( dt < cur || dt > end ) { | 1169 | if ( dt < cur || dt > end ) { |
1170 | remote->deleteIncidence( inR ); | 1170 | remote->deleteIncidence( inR ); |
1171 | ++delFut; | 1171 | ++delFut; |
1172 | } | 1172 | } |
1173 | inR = er.next(); | 1173 | inR = er.next(); |
1174 | } | 1174 | } |
1175 | } | 1175 | } |
1176 | bar.hide(); | 1176 | bar.hide(); |
1177 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1177 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1178 | eventLSync->setReadOnly( false ); | 1178 | eventLSync->setReadOnly( false ); |
1179 | eventLSync->setDtStart( mLastCalendarSync ); | 1179 | eventLSync->setDtStart( mLastCalendarSync ); |
1180 | eventRSync->setDtStart( mLastCalendarSync ); | 1180 | eventRSync->setDtStart( mLastCalendarSync ); |
1181 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1181 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1182 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1182 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1183 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1183 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1184 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1184 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1185 | eventLSync->setReadOnly( true ); | 1185 | eventLSync->setReadOnly( true ); |
1186 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1186 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1187 | remote->addEvent( eventRSync ); | 1187 | remote->addEvent( eventRSync ); |
1188 | else | 1188 | else |
1189 | delete eventRSync; | 1189 | delete eventRSync; |
1190 | QString mes; | 1190 | QString mes; |
1191 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1191 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1192 | QString delmess; | 1192 | QString delmess; |
1193 | if ( delFut ) { | 1193 | if ( delFut ) { |
1194 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1194 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1195 | mes += delmess; | 1195 | mes += delmess; |
1196 | } | 1196 | } |
1197 | mCalendar->checkAlarmForIncidence( 0, true ); | ||
1198 | qDebug( mes ); | ||
1197 | if ( mSyncManager->mShowSyncSummary ) { | 1199 | if ( mSyncManager->mShowSyncSummary ) { |
1198 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1200 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1201 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | ||
1202 | qDebug("cancelled "); | ||
1203 | return false; | ||
1204 | } | ||
1199 | } | 1205 | } |
1200 | qDebug( mes ); | ||
1201 | mCalendar->checkAlarmForIncidence( 0, true ); | ||
1202 | return syncOK; | 1206 | return syncOK; |
1203 | } | 1207 | } |
1204 | 1208 | ||
1205 | void CalendarView::setSyncDevice( QString s ) | 1209 | void CalendarView::setSyncDevice( QString s ) |
1206 | { | 1210 | { |
1207 | mCurrentSyncDevice= s; | 1211 | mCurrentSyncDevice= s; |
1208 | } | 1212 | } |
1209 | void CalendarView::setSyncName( QString s ) | 1213 | void CalendarView::setSyncName( QString s ) |
1210 | { | 1214 | { |
1211 | mCurrentSyncName= s; | 1215 | mCurrentSyncName= s; |
1212 | } | 1216 | } |
1213 | bool CalendarView::syncCalendar(QString filename, int mode) | 1217 | bool CalendarView::syncCalendar(QString filename, int mode) |
1214 | { | 1218 | { |
1215 | //qDebug("syncCalendar %s ", filename.latin1()); | 1219 | //qDebug("syncCalendar %s ", filename.latin1()); |
1216 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1220 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1217 | CalendarLocal* calendar = new CalendarLocal(); | 1221 | CalendarLocal* calendar = new CalendarLocal(); |
1218 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1222 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1219 | FileStorage* storage = new FileStorage( calendar ); | 1223 | FileStorage* storage = new FileStorage( calendar ); |
1220 | bool syncOK = false; | 1224 | bool syncOK = false; |
1221 | storage->setFileName( filename ); | 1225 | storage->setFileName( filename ); |
1222 | // qDebug("loading ... "); | 1226 | // qDebug("loading ... "); |
1223 | if ( storage->load() ) { | 1227 | if ( storage->load() ) { |
1224 | getEventViewerDialog()->setSyncMode( true ); | 1228 | getEventViewerDialog()->setSyncMode( true ); |
1225 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1229 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1226 | getEventViewerDialog()->setSyncMode( false ); | 1230 | getEventViewerDialog()->setSyncMode( false ); |
1227 | if ( syncOK ) { | 1231 | if ( syncOK ) { |
1228 | if ( mSyncManager->mWriteBackFile ) | 1232 | if ( mSyncManager->mWriteBackFile ) |
1229 | { | 1233 | { |
1230 | storage->setSaveFormat( new ICalFormat() ); | 1234 | storage->setSaveFormat( new ICalFormat() ); |
1231 | storage->save(); | 1235 | storage->save(); |
1232 | } | 1236 | } |
1233 | } | 1237 | } |
1234 | setModified( true ); | 1238 | setModified( true ); |
1235 | } | 1239 | } |
1236 | delete storage; | 1240 | delete storage; |
1237 | delete calendar; | 1241 | delete calendar; |
1238 | if ( syncOK ) | 1242 | if ( syncOK ) |
1239 | updateView(); | 1243 | updateView(); |
1240 | return syncOK; | 1244 | return syncOK; |
1241 | } | 1245 | } |
1242 | 1246 | ||
1243 | void CalendarView::syncExternal( int mode ) | 1247 | void CalendarView::syncExternal( int mode ) |
1244 | { | 1248 | { |
1245 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1249 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1246 | 1250 | ||
1247 | qApp->processEvents(); | 1251 | qApp->processEvents(); |
1248 | CalendarLocal* calendar = new CalendarLocal(); | 1252 | CalendarLocal* calendar = new CalendarLocal(); |
1249 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1253 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1250 | bool syncOK = false; | 1254 | bool syncOK = false; |
1251 | bool loadSuccess = false; | 1255 | bool loadSuccess = false; |
1252 | PhoneFormat* phoneFormat = 0; | 1256 | PhoneFormat* phoneFormat = 0; |
1253 | emit tempDisableBR(true); | 1257 | emit tempDisableBR(true); |
1254 | #ifndef DESKTOP_VERSION | 1258 | #ifndef DESKTOP_VERSION |
1255 | SharpFormat* sharpFormat = 0; | 1259 | SharpFormat* sharpFormat = 0; |
1256 | if ( mode == 0 ) { // sharp | 1260 | if ( mode == 0 ) { // sharp |
1257 | sharpFormat = new SharpFormat () ; | 1261 | sharpFormat = new SharpFormat () ; |
1258 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1262 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1259 | 1263 | ||
1260 | } else | 1264 | } else |
1261 | #endif | 1265 | #endif |
1262 | if ( mode == 1 ) { // phone | 1266 | if ( mode == 1 ) { // phone |
1263 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1267 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1264 | mSyncManager->mPhoneDevice, | 1268 | mSyncManager->mPhoneDevice, |
1265 | mSyncManager->mPhoneConnection, | 1269 | mSyncManager->mPhoneConnection, |
1266 | mSyncManager->mPhoneModel); | 1270 | mSyncManager->mPhoneModel); |
1267 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1271 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1268 | 1272 | ||
1269 | } else { | 1273 | } else { |
1270 | emit tempDisableBR(false); | 1274 | emit tempDisableBR(false); |
1271 | return; | 1275 | return; |
1272 | } | 1276 | } |
1273 | if ( loadSuccess ) { | 1277 | if ( loadSuccess ) { |
1274 | getEventViewerDialog()->setSyncMode( true ); | 1278 | getEventViewerDialog()->setSyncMode( true ); |
1275 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1279 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1276 | getEventViewerDialog()->setSyncMode( false ); | 1280 | getEventViewerDialog()->setSyncMode( false ); |
1277 | qApp->processEvents(); | 1281 | qApp->processEvents(); |
1278 | if ( syncOK ) { | 1282 | if ( syncOK ) { |
1279 | if ( mSyncManager->mWriteBackFile ) | 1283 | if ( mSyncManager->mWriteBackFile ) |
1280 | { | 1284 | { |
1281 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1285 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1282 | Incidence* inc = iL.first(); | 1286 | Incidence* inc = iL.first(); |
1283 | if ( phoneFormat ) { | 1287 | if ( phoneFormat ) { |
1284 | while ( inc ) { | 1288 | while ( inc ) { |
1285 | inc->removeID(mCurrentSyncDevice); | 1289 | inc->removeID(mCurrentSyncDevice); |
1286 | inc = iL.next(); | 1290 | inc = iL.next(); |
1287 | } | 1291 | } |
1288 | } | 1292 | } |
1289 | #ifndef DESKTOP_VERSION | 1293 | #ifndef DESKTOP_VERSION |
1290 | if ( sharpFormat ) | 1294 | if ( sharpFormat ) |
1291 | sharpFormat->save(calendar); | 1295 | sharpFormat->save(calendar); |
1292 | #endif | 1296 | #endif |
1293 | if ( phoneFormat ) | 1297 | if ( phoneFormat ) |
1294 | phoneFormat->save(calendar); | 1298 | phoneFormat->save(calendar); |
1295 | iL = calendar->rawIncidences(); | 1299 | iL = calendar->rawIncidences(); |
1296 | inc = iL.first(); | 1300 | inc = iL.first(); |
1297 | Incidence* loc; | 1301 | Incidence* loc; |
1298 | while ( inc ) { | 1302 | while ( inc ) { |
1299 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1303 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1300 | loc = mCalendar->incidence(inc->uid() ); | 1304 | loc = mCalendar->incidence(inc->uid() ); |
1301 | if ( loc ) { | 1305 | if ( loc ) { |
1302 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1306 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1303 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1307 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1304 | } | 1308 | } |
1305 | } | 1309 | } |
1306 | inc = iL.next(); | 1310 | inc = iL.next(); |
1307 | } | 1311 | } |
1308 | Incidence* lse = getLastSyncEvent(); | 1312 | Incidence* lse = getLastSyncEvent(); |
1309 | if ( lse ) { | 1313 | if ( lse ) { |
1310 | lse->setReadOnly( false ); | 1314 | lse->setReadOnly( false ); |
1311 | lse->setDescription( "" ); | 1315 | lse->setDescription( "" ); |
1312 | lse->setReadOnly( true ); | 1316 | lse->setReadOnly( true ); |
1313 | } | 1317 | } |
1314 | } | 1318 | } |
1319 | } else { | ||
1320 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | ||
1315 | } | 1321 | } |
1316 | setModified( true ); | 1322 | setModified( true ); |
1317 | } else { | 1323 | } else { |
1318 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1324 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1319 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1325 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1320 | question, i18n("Ok")) ; | 1326 | question, i18n("Ok")) ; |
1321 | 1327 | ||
1322 | } | 1328 | } |
1323 | delete calendar; | 1329 | delete calendar; |
1324 | updateView(); | 1330 | updateView(); |
1325 | emit tempDisableBR(false); | 1331 | emit tempDisableBR(false); |
1326 | return ;//syncOK; | 1332 | return ;//syncOK; |
1327 | 1333 | ||
1328 | } | 1334 | } |
1329 | 1335 | ||
1330 | bool CalendarView::importBday() | 1336 | bool CalendarView::importBday() |
1331 | { | 1337 | { |
1332 | #ifndef KORG_NOKABC | 1338 | #ifndef KORG_NOKABC |
1333 | 1339 | ||
1334 | #ifdef DESKTOP_VERSION | 1340 | #ifdef DESKTOP_VERSION |
1335 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1341 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1336 | KABC::AddressBook::Iterator it; | 1342 | KABC::AddressBook::Iterator it; |
1337 | int count = 0; | 1343 | int count = 0; |
1338 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1344 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1339 | ++count; | 1345 | ++count; |
1340 | } | 1346 | } |
1341 | QProgressBar bar(count,0 ); | 1347 | QProgressBar bar(count,0 ); |
1342 | int w = 300; | 1348 | int w = 300; |
1343 | if ( QApplication::desktop()->width() < 320 ) | 1349 | if ( QApplication::desktop()->width() < 320 ) |
1344 | w = 220; | 1350 | w = 220; |
1345 | int h = bar.sizeHint().height() ; | 1351 | int h = bar.sizeHint().height() ; |
1346 | int dw = QApplication::desktop()->width(); | 1352 | int dw = QApplication::desktop()->width(); |
1347 | int dh = QApplication::desktop()->height(); | 1353 | int dh = QApplication::desktop()->height(); |
1348 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1354 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1349 | bar.show(); | 1355 | bar.show(); |
1350 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1356 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1351 | qApp->processEvents(); | 1357 | qApp->processEvents(); |
1352 | count = 0; | 1358 | count = 0; |
1353 | int addCount = 0; | 1359 | int addCount = 0; |
1354 | KCal::Attendee* a = 0; | 1360 | KCal::Attendee* a = 0; |
1355 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1361 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1356 | if ( ! bar.isVisible() ) | 1362 | if ( ! bar.isVisible() ) |
1357 | return false; | 1363 | return false; |
1358 | bar.setProgress( count++ ); | 1364 | bar.setProgress( count++ ); |
1359 | qApp->processEvents(); | 1365 | qApp->processEvents(); |
1360 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1366 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1361 | if ( (*it).birthday().date().isValid() ){ | 1367 | if ( (*it).birthday().date().isValid() ){ |
1362 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1368 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1363 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1369 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1364 | ++addCount; | 1370 | ++addCount; |
1365 | } | 1371 | } |
1366 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1372 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1367 | if ( anni.isValid() ){ | 1373 | if ( anni.isValid() ){ |
1368 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1374 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1369 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1375 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1370 | ++addCount; | 1376 | ++addCount; |
1371 | } | 1377 | } |
1372 | } | 1378 | } |
1373 | updateView(); | 1379 | updateView(); |
1374 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1380 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1375 | #else //DESKTOP_VERSION | 1381 | #else //DESKTOP_VERSION |
1376 | 1382 | ||
1377 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1383 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1378 | // the result should now arrive through method insertBirthdays | 1384 | // the result should now arrive through method insertBirthdays |
1379 | 1385 | ||
1380 | #endif //DESKTOP_VERSION | 1386 | #endif //DESKTOP_VERSION |
1381 | 1387 | ||
1382 | #endif //KORG_NOKABC | 1388 | #endif //KORG_NOKABC |
1383 | 1389 | ||
1384 | 1390 | ||
1385 | return true; | 1391 | return true; |
1386 | } | 1392 | } |
1387 | 1393 | ||
1388 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1394 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1389 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1395 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1390 | const QStringList& anniversaryList, const QStringList& realNameList, | 1396 | const QStringList& anniversaryList, const QStringList& realNameList, |
1391 | const QStringList& emailList, const QStringList& assembledNameList, | 1397 | const QStringList& emailList, const QStringList& assembledNameList, |
1392 | const QStringList& uidList) | 1398 | const QStringList& uidList) |
1393 | { | 1399 | { |
1394 | qDebug("CalendarView::insertBirthdays"); | 1400 | qDebug("CalendarView::insertBirthdays"); |
1395 | if (uid == this->name()) | 1401 | if (uid == this->name()) |
1396 | { | 1402 | { |
1397 | int count = birthdayList.count(); | 1403 | int count = birthdayList.count(); |
1398 | int addCount = 0; | 1404 | int addCount = 0; |
1399 | KCal::Attendee* a = 0; | 1405 | KCal::Attendee* a = 0; |
1400 | 1406 | ||
1401 | qDebug("CalView 1 %i", count); | 1407 | qDebug("CalView 1 %i", count); |
1402 | 1408 | ||
1403 | QProgressBar bar(count,0 ); | 1409 | QProgressBar bar(count,0 ); |
1404 | int w = 300; | 1410 | int w = 300; |
1405 | if ( QApplication::desktop()->width() < 320 ) | 1411 | if ( QApplication::desktop()->width() < 320 ) |
1406 | w = 220; | 1412 | w = 220; |
1407 | int h = bar.sizeHint().height() ; | 1413 | int h = bar.sizeHint().height() ; |
1408 | int dw = QApplication::desktop()->width(); | 1414 | int dw = QApplication::desktop()->width(); |
1409 | int dh = QApplication::desktop()->height(); | 1415 | int dh = QApplication::desktop()->height(); |
1410 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1416 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1411 | bar.show(); | 1417 | bar.show(); |
1412 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1418 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1413 | qApp->processEvents(); | 1419 | qApp->processEvents(); |
1414 | 1420 | ||
1415 | QDate birthday; | 1421 | QDate birthday; |
1416 | QDate anniversary; | 1422 | QDate anniversary; |
1417 | QString realName; | 1423 | QString realName; |
1418 | QString email; | 1424 | QString email; |
1419 | QString assembledName; | 1425 | QString assembledName; |
1420 | QString uid; | 1426 | QString uid; |
1421 | bool ok = true; | 1427 | bool ok = true; |
1422 | for ( int i = 0; i < count; i++) | 1428 | for ( int i = 0; i < count; i++) |
1423 | { | 1429 | { |
1424 | if ( ! bar.isVisible() ) | 1430 | if ( ! bar.isVisible() ) |
1425 | return; | 1431 | return; |
1426 | bar.setProgress( i ); | 1432 | bar.setProgress( i ); |
1427 | qApp->processEvents(); | 1433 | qApp->processEvents(); |
1428 | 1434 | ||
1429 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1435 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1430 | if (!ok) { | 1436 | if (!ok) { |
1431 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1437 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1432 | } | 1438 | } |
1433 | 1439 | ||
1434 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1440 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1435 | if (!ok) { | 1441 | if (!ok) { |
1436 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1442 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1437 | } | 1443 | } |
1438 | realName = realNameList[i]; | 1444 | realName = realNameList[i]; |
1439 | email = emailList[i]; | 1445 | email = emailList[i]; |
1440 | assembledName = assembledNameList[i]; | 1446 | assembledName = assembledNameList[i]; |
1441 | uid = uidList[i]; | 1447 | uid = uidList[i]; |
1442 | //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() ); | 1448 | //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() ); |
1443 | 1449 | ||
1444 | if ( birthday.isValid() ){ | 1450 | if ( birthday.isValid() ){ |
1445 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1451 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1446 | KCal::Attendee::ReqParticipant,uid) ; | 1452 | KCal::Attendee::ReqParticipant,uid) ; |
1447 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1453 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1448 | ++addCount; | 1454 | ++addCount; |
1449 | } | 1455 | } |
1450 | 1456 | ||
1451 | if ( anniversary.isValid() ){ | 1457 | if ( anniversary.isValid() ){ |
1452 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1458 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1453 | KCal::Attendee::ReqParticipant,uid) ; | 1459 | KCal::Attendee::ReqParticipant,uid) ; |
1454 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1460 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1455 | ++addCount; | 1461 | ++addCount; |
1456 | } | 1462 | } |
1457 | } | 1463 | } |
1458 | 1464 | ||
1459 | updateView(); | 1465 | updateView(); |
1460 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1466 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1461 | 1467 | ||
1462 | } | 1468 | } |
1463 | 1469 | ||
1464 | } | 1470 | } |
1465 | 1471 | ||
1466 | 1472 | ||
1467 | 1473 | ||
1468 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1474 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1469 | { | 1475 | { |
1470 | //qDebug("addAnni "); | 1476 | //qDebug("addAnni "); |
1471 | Event * ev = new Event(); | 1477 | Event * ev = new Event(); |
1472 | if ( a ) { | 1478 | if ( a ) { |
1473 | ev->addAttendee( a ); | 1479 | ev->addAttendee( a ); |
1474 | } | 1480 | } |
1475 | QString kind; | 1481 | QString kind; |
1476 | if ( birthday ) | 1482 | if ( birthday ) |
1477 | kind = i18n( "Birthday" ); | 1483 | kind = i18n( "Birthday" ); |
1478 | else | 1484 | else |
1479 | kind = i18n( "Anniversary" ); | 1485 | kind = i18n( "Anniversary" ); |
1480 | ev->setSummary( name + " - " + kind ); | 1486 | ev->setSummary( name + " - " + kind ); |
1481 | ev->setOrganizer(a->email()); | 1487 | ev->setOrganizer(a->email()); |
1482 | ev->setCategories( kind ); | 1488 | ev->setCategories( kind ); |
1483 | ev->setDtStart( QDateTime(date) ); | 1489 | ev->setDtStart( QDateTime(date) ); |
1484 | ev->setDtEnd( QDateTime(date) ); | 1490 | ev->setDtEnd( QDateTime(date) ); |
1485 | ev->setFloats( true ); | 1491 | ev->setFloats( true ); |
1486 | Recurrence * rec = ev->recurrence(); | 1492 | Recurrence * rec = ev->recurrence(); |
1487 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1493 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1488 | rec->addYearlyNum( date.month() ); | 1494 | rec->addYearlyNum( date.month() ); |
1489 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1495 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1490 | delete ev; | 1496 | delete ev; |
1491 | return false; | 1497 | return false; |
1492 | } | 1498 | } |
1493 | return true; | 1499 | return true; |
1494 | 1500 | ||
1495 | } | 1501 | } |
1496 | bool CalendarView::importQtopia( const QString &categories, | 1502 | bool CalendarView::importQtopia( const QString &categories, |
1497 | const QString &datebook, | 1503 | const QString &datebook, |
1498 | const QString &todolist ) | 1504 | const QString &todolist ) |
1499 | { | 1505 | { |
1500 | 1506 | ||
1501 | QtopiaFormat qtopiaFormat; | 1507 | QtopiaFormat qtopiaFormat; |
1502 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1508 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1503 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1509 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1504 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1510 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1505 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1511 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1506 | 1512 | ||
1507 | updateView(); | 1513 | updateView(); |
1508 | return true; | 1514 | return true; |
1509 | 1515 | ||
1510 | #if 0 | 1516 | #if 0 |
1511 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1517 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1512 | mCurrentSyncDevice = "qtopia-XML"; | 1518 | mCurrentSyncDevice = "qtopia-XML"; |
1513 | if ( mSyncManager->mAskForPreferences ) | 1519 | if ( mSyncManager->mAskForPreferences ) |
1514 | edit_sync_options(); | 1520 | edit_sync_options(); |
1515 | qApp->processEvents(); | 1521 | qApp->processEvents(); |
1516 | CalendarLocal* calendar = new CalendarLocal(); | 1522 | CalendarLocal* calendar = new CalendarLocal(); |
1517 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1523 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1518 | bool syncOK = false; | 1524 | bool syncOK = false; |
1519 | QtopiaFormat qtopiaFormat; | 1525 | QtopiaFormat qtopiaFormat; |
1520 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1526 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1521 | bool loadOk = true; | 1527 | bool loadOk = true; |
1522 | if ( !categories.isEmpty() ) | 1528 | if ( !categories.isEmpty() ) |
1523 | loadOk = qtopiaFormat.load( calendar, categories ); | 1529 | loadOk = qtopiaFormat.load( calendar, categories ); |
1524 | if ( loadOk && !datebook.isEmpty() ) | 1530 | if ( loadOk && !datebook.isEmpty() ) |
1525 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1531 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1526 | if ( loadOk && !todolist.isEmpty() ) | 1532 | if ( loadOk && !todolist.isEmpty() ) |
1527 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1533 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1528 | 1534 | ||
1529 | if ( loadOk ) { | 1535 | if ( loadOk ) { |
1530 | getEventViewerDialog()->setSyncMode( true ); | 1536 | getEventViewerDialog()->setSyncMode( true ); |
1531 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1537 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1532 | getEventViewerDialog()->setSyncMode( false ); | 1538 | getEventViewerDialog()->setSyncMode( false ); |
1533 | qApp->processEvents(); | 1539 | qApp->processEvents(); |
1534 | if ( syncOK ) { | 1540 | if ( syncOK ) { |
1535 | if ( mSyncManager->mWriteBackFile ) | 1541 | if ( mSyncManager->mWriteBackFile ) |
1536 | { | 1542 | { |
1537 | // write back XML file | 1543 | // write back XML file |
1538 | 1544 | ||
1539 | } | 1545 | } |
1540 | setModified( true ); | 1546 | setModified( true ); |
1541 | } | 1547 | } |
1542 | } else { | 1548 | } else { |
1543 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1549 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1544 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1550 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1545 | question, i18n("Ok")) ; | 1551 | question, i18n("Ok")) ; |
1546 | } | 1552 | } |
1547 | delete calendar; | 1553 | delete calendar; |
1548 | updateView(); | 1554 | updateView(); |
1549 | return syncOK; | 1555 | return syncOK; |
1550 | 1556 | ||
1551 | 1557 | ||
1552 | #endif | 1558 | #endif |
1553 | 1559 | ||
1554 | } | 1560 | } |
1555 | 1561 | ||
1556 | void CalendarView::setSyncEventsReadOnly() | 1562 | void CalendarView::setSyncEventsReadOnly() |
1557 | { | 1563 | { |
1558 | Event * ev; | 1564 | Event * ev; |
1559 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1565 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1560 | ev = eL.first(); | 1566 | ev = eL.first(); |
1561 | while ( ev ) { | 1567 | while ( ev ) { |
1562 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1568 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1563 | ev->setReadOnly( true ); | 1569 | ev->setReadOnly( true ); |
1564 | ev = eL.next(); | 1570 | ev = eL.next(); |
1565 | } | 1571 | } |
1566 | } | 1572 | } |
1567 | bool CalendarView::openCalendar(QString filename, bool merge) | 1573 | bool CalendarView::openCalendar(QString filename, bool merge) |
1568 | { | 1574 | { |
1569 | 1575 | ||
1570 | if (filename.isEmpty()) { | 1576 | if (filename.isEmpty()) { |
1571 | return false; | 1577 | return false; |
1572 | } | 1578 | } |
1573 | 1579 | ||
1574 | if (!QFile::exists(filename)) { | 1580 | if (!QFile::exists(filename)) { |
1575 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1581 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1576 | return false; | 1582 | return false; |
1577 | } | 1583 | } |
1578 | 1584 | ||
1579 | globalFlagBlockAgenda = 1; | 1585 | globalFlagBlockAgenda = 1; |
1580 | if (!merge) mCalendar->close(); | 1586 | if (!merge) mCalendar->close(); |
1581 | 1587 | ||
1582 | mStorage->setFileName( filename ); | 1588 | mStorage->setFileName( filename ); |
1583 | 1589 | ||
1584 | if ( mStorage->load() ) { | 1590 | if ( mStorage->load() ) { |
1585 | if ( merge ) ;//setModified( true ); | 1591 | if ( merge ) ;//setModified( true ); |
1586 | else { | 1592 | else { |
1587 | //setModified( true ); | 1593 | //setModified( true ); |
1588 | mViewManager->setDocumentId( filename ); | 1594 | mViewManager->setDocumentId( filename ); |
1589 | mDialogManager->setDocumentId( filename ); | 1595 | mDialogManager->setDocumentId( filename ); |
1590 | mTodoList->setDocumentId( filename ); | 1596 | mTodoList->setDocumentId( filename ); |
1591 | } | 1597 | } |
1592 | globalFlagBlockAgenda = 2; | 1598 | globalFlagBlockAgenda = 2; |
1593 | // if ( getLastSyncEvent() ) | 1599 | // if ( getLastSyncEvent() ) |
1594 | // getLastSyncEvent()->setReadOnly( true ); | 1600 | // getLastSyncEvent()->setReadOnly( true ); |
1595 | mCalendar->reInitAlarmSettings(); | 1601 | mCalendar->reInitAlarmSettings(); |
1596 | setSyncEventsReadOnly(); | 1602 | setSyncEventsReadOnly(); |
1597 | updateUnmanagedViews(); | 1603 | updateUnmanagedViews(); |
1598 | updateView(); | 1604 | updateView(); |
1599 | if ( filename != MainWindow::defaultFileName() ) { | 1605 | if ( filename != MainWindow::defaultFileName() ) { |
1600 | saveCalendar( MainWindow::defaultFileName() ); | 1606 | saveCalendar( MainWindow::defaultFileName() ); |
1601 | } else { | 1607 | } else { |
1602 | QFileInfo finf ( MainWindow::defaultFileName()); | 1608 | QFileInfo finf ( MainWindow::defaultFileName()); |
1603 | if ( finf.exists() ) { | 1609 | if ( finf.exists() ) { |
1604 | setLoadedFileVersion( finf.lastModified () ); | 1610 | setLoadedFileVersion( finf.lastModified () ); |
1605 | } | 1611 | } |
1606 | } | 1612 | } |
1607 | return true; | 1613 | return true; |
1608 | } else { | 1614 | } else { |
1609 | // while failing to load, the calendar object could | 1615 | // while failing to load, the calendar object could |
1610 | // have become partially populated. Clear it out. | 1616 | // have become partially populated. Clear it out. |
1611 | if ( !merge ) { | 1617 | if ( !merge ) { |
1612 | mCalendar->close(); | 1618 | mCalendar->close(); |
1613 | mViewManager->setDocumentId( filename ); | 1619 | mViewManager->setDocumentId( filename ); |
1614 | mDialogManager->setDocumentId( filename ); | 1620 | mDialogManager->setDocumentId( filename ); |
1615 | mTodoList->setDocumentId( filename ); | 1621 | mTodoList->setDocumentId( filename ); |
1616 | } | 1622 | } |
1617 | 1623 | ||
1618 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1624 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1619 | 1625 | ||
1620 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1626 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1621 | globalFlagBlockAgenda = 2; | 1627 | globalFlagBlockAgenda = 2; |
1622 | mCalendar->reInitAlarmSettings(); | 1628 | mCalendar->reInitAlarmSettings(); |
1623 | setSyncEventsReadOnly(); | 1629 | setSyncEventsReadOnly(); |
1624 | updateUnmanagedViews(); | 1630 | updateUnmanagedViews(); |
1625 | updateView(); | 1631 | updateView(); |
1626 | } | 1632 | } |
1627 | return false; | 1633 | return false; |
1628 | } | 1634 | } |
1629 | void CalendarView::showOpenError() | 1635 | void CalendarView::showOpenError() |
1630 | { | 1636 | { |
1631 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1637 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1632 | } | 1638 | } |
1633 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1639 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1634 | { | 1640 | { |
1635 | loadedFileVersion = dt; | 1641 | loadedFileVersion = dt; |
1636 | } | 1642 | } |
1637 | bool CalendarView::checkFileChanged(QString fn) | 1643 | bool CalendarView::checkFileChanged(QString fn) |
1638 | { | 1644 | { |
1639 | QFileInfo finf ( fn ); | 1645 | QFileInfo finf ( fn ); |
1640 | if ( !finf.exists() ) | 1646 | if ( !finf.exists() ) |
1641 | return true; | 1647 | return true; |
1642 | QDateTime dt = finf.lastModified (); | 1648 | QDateTime dt = finf.lastModified (); |
1643 | if ( dt <= loadedFileVersion ) | 1649 | if ( dt <= loadedFileVersion ) |
1644 | return false; | 1650 | return false; |
1645 | return true; | 1651 | return true; |
1646 | 1652 | ||
1647 | } | 1653 | } |
1648 | void CalendarView::watchSavedFile() | 1654 | void CalendarView::watchSavedFile() |
1649 | { | 1655 | { |
1650 | QFileInfo finf ( MainWindow::defaultFileName()); | 1656 | QFileInfo finf ( MainWindow::defaultFileName()); |
1651 | if ( !finf.exists() ) | 1657 | if ( !finf.exists() ) |
1652 | return; | 1658 | return; |
1653 | QDateTime dt = finf.lastModified (); | 1659 | QDateTime dt = finf.lastModified (); |
1654 | if ( dt < loadedFileVersion ) { | 1660 | if ( dt < loadedFileVersion ) { |
1655 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1661 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1656 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1662 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1657 | return; | 1663 | return; |
1658 | } | 1664 | } |
1659 | loadedFileVersion = dt; | 1665 | loadedFileVersion = dt; |
1660 | } | 1666 | } |
1661 | 1667 | ||
1662 | bool CalendarView::checkFileVersion(QString fn) | 1668 | bool CalendarView::checkFileVersion(QString fn) |
1663 | { | 1669 | { |
1664 | QFileInfo finf ( fn ); | 1670 | QFileInfo finf ( fn ); |
1665 | if ( !finf.exists() ) | 1671 | if ( !finf.exists() ) |
1666 | return true; | 1672 | return true; |
1667 | QDateTime dt = finf.lastModified (); | 1673 | QDateTime dt = finf.lastModified (); |
1668 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1674 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1669 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1675 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1670 | if ( dt <= loadedFileVersion ) | 1676 | if ( dt <= loadedFileVersion ) |
1671 | return true; | 1677 | return true; |
1672 | 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)) , | 1678 | 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)) , |
1673 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1679 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1674 | i18n("Sync+save")); | 1680 | i18n("Sync+save")); |
1675 | 1681 | ||
1676 | if ( km == KMessageBox::Cancel ) | 1682 | if ( km == KMessageBox::Cancel ) |
1677 | return false; | 1683 | return false; |
1678 | if ( km == KMessageBox::Yes ) | 1684 | if ( km == KMessageBox::Yes ) |
1679 | return true; | 1685 | return true; |
1680 | 1686 | ||
1681 | setSyncDevice("deleteaftersync" ); | 1687 | setSyncDevice("deleteaftersync" ); |
1682 | mSyncManager->mAskForPreferences = true; | 1688 | mSyncManager->mAskForPreferences = true; |
1683 | mSyncManager->mSyncAlgoPrefs = 3; | 1689 | mSyncManager->mSyncAlgoPrefs = 3; |
1684 | mSyncManager->mWriteBackFile = false; | 1690 | mSyncManager->mWriteBackFile = false; |
1685 | mSyncManager->mWriteBackExistingOnly = false; | 1691 | mSyncManager->mWriteBackExistingOnly = false; |
1686 | mSyncManager->mShowSyncSummary = false; | 1692 | mSyncManager->mShowSyncSummary = false; |
1687 | syncCalendar( fn, 3 ); | 1693 | syncCalendar( fn, 3 ); |
1688 | Event * e = getLastSyncEvent(); | 1694 | Event * e = getLastSyncEvent(); |
1689 | mCalendar->deleteEvent ( e ); | 1695 | mCalendar->deleteEvent ( e ); |
1690 | updateView(); | 1696 | updateView(); |
1691 | return true; | 1697 | return true; |
1692 | } | 1698 | } |
1693 | 1699 | ||
1694 | bool CalendarView::saveCalendar( QString filename ) | 1700 | bool CalendarView::saveCalendar( QString filename ) |
1695 | { | 1701 | { |
1696 | 1702 | ||
1697 | // Store back all unsaved data into calendar object | 1703 | // Store back all unsaved data into calendar object |
1698 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1704 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1699 | if ( mViewManager->currentView() ) | 1705 | if ( mViewManager->currentView() ) |
1700 | mViewManager->currentView()->flushView(); | 1706 | mViewManager->currentView()->flushView(); |
1701 | 1707 | ||
1702 | 1708 | ||
1703 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1709 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1704 | mStorage->setSaveFormat( new ICalFormat() ); | 1710 | mStorage->setSaveFormat( new ICalFormat() ); |
1705 | mStorage->setFileName( filename ); | 1711 | mStorage->setFileName( filename ); |
1706 | bool success; | 1712 | bool success; |
1707 | success = mStorage->save(); | 1713 | success = mStorage->save(); |
1708 | if ( !success ) { | 1714 | if ( !success ) { |
1709 | return false; | 1715 | return false; |
1710 | } | 1716 | } |
1711 | if ( filename == MainWindow::defaultFileName() ) { | 1717 | if ( filename == MainWindow::defaultFileName() ) { |
1712 | setLoadedFileVersion( lfv ); | 1718 | setLoadedFileVersion( lfv ); |
1713 | watchSavedFile(); | 1719 | watchSavedFile(); |
1714 | } | 1720 | } |
1715 | return true; | 1721 | return true; |
1716 | } | 1722 | } |
1717 | 1723 | ||
1718 | void CalendarView::closeCalendar() | 1724 | void CalendarView::closeCalendar() |
1719 | { | 1725 | { |
1720 | 1726 | ||
1721 | // child windows no longer valid | 1727 | // child windows no longer valid |
1722 | emit closingDown(); | 1728 | emit closingDown(); |
1723 | 1729 | ||
1724 | mCalendar->close(); | 1730 | mCalendar->close(); |
1725 | setModified(false); | 1731 | setModified(false); |
1726 | updateView(); | 1732 | updateView(); |
1727 | } | 1733 | } |
1728 | 1734 | ||
1729 | void CalendarView::archiveCalendar() | 1735 | void CalendarView::archiveCalendar() |
1730 | { | 1736 | { |
1731 | mDialogManager->showArchiveDialog(); | 1737 | mDialogManager->showArchiveDialog(); |
1732 | } | 1738 | } |
1733 | 1739 | ||
1734 | 1740 | ||
1735 | void CalendarView::readSettings() | 1741 | void CalendarView::readSettings() |
1736 | { | 1742 | { |
1737 | 1743 | ||
1738 | 1744 | ||
1739 | // mViewManager->showAgendaView(); | 1745 | // mViewManager->showAgendaView(); |
1740 | QString str; | 1746 | QString str; |
1741 | //qDebug("CalendarView::readSettings() "); | 1747 | //qDebug("CalendarView::readSettings() "); |
1742 | // read settings from the KConfig, supplying reasonable | 1748 | // read settings from the KConfig, supplying reasonable |
1743 | // defaults where none are to be found | 1749 | // defaults where none are to be found |
1744 | KConfig *config = KOGlobals::config(); | 1750 | KConfig *config = KOGlobals::config(); |
1745 | #ifndef KORG_NOSPLITTER | 1751 | #ifndef KORG_NOSPLITTER |
1746 | config->setGroup("KOrganizer Geometry"); | 1752 | config->setGroup("KOrganizer Geometry"); |
1747 | 1753 | ||
1748 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1754 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1749 | if (sizes.count() != 2) { | 1755 | if (sizes.count() != 2) { |
1750 | sizes << mDateNavigator->minimumSizeHint().width(); | 1756 | sizes << mDateNavigator->minimumSizeHint().width(); |
1751 | sizes << 300; | 1757 | sizes << 300; |
1752 | } | 1758 | } |
1753 | mPanner->setSizes(sizes); | 1759 | mPanner->setSizes(sizes); |
1754 | 1760 | ||
1755 | sizes = config->readIntListEntry("Separator2"); | 1761 | sizes = config->readIntListEntry("Separator2"); |
1756 | if ( ( mResourceView && sizes.count() == 4 ) || | 1762 | if ( ( mResourceView && sizes.count() == 4 ) || |
1757 | ( !mResourceView && sizes.count() == 3 ) ) { | 1763 | ( !mResourceView && sizes.count() == 3 ) ) { |
1758 | mLeftSplitter->setSizes(sizes); | 1764 | mLeftSplitter->setSizes(sizes); |
1759 | } | 1765 | } |
1760 | #endif | 1766 | #endif |
1761 | globalFlagBlockAgenda = 1; | 1767 | globalFlagBlockAgenda = 1; |
1762 | mViewManager->showAgendaView(); | 1768 | mViewManager->showAgendaView(); |
1763 | //mViewManager->readSettings( config ); | 1769 | //mViewManager->readSettings( config ); |
1764 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1770 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1765 | readFilterSettings(config); | 1771 | readFilterSettings(config); |
1766 | config->setGroup( "Views" ); | 1772 | config->setGroup( "Views" ); |
1767 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1773 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1768 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1774 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1769 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1775 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1770 | else mNavigator->selectDates( dateCount ); | 1776 | else mNavigator->selectDates( dateCount ); |
1771 | // mViewManager->readSettings( config ); | 1777 | // mViewManager->readSettings( config ); |
1772 | updateConfig(); | 1778 | updateConfig(); |
1773 | globalFlagBlockAgenda = 2; | 1779 | globalFlagBlockAgenda = 2; |
1774 | mViewManager->readSettings( config ); | 1780 | mViewManager->readSettings( config ); |
1775 | #ifdef DESKTOP_VERSION | 1781 | #ifdef DESKTOP_VERSION |
1776 | config->setGroup("WidgetLayout"); | 1782 | config->setGroup("WidgetLayout"); |
1777 | QStringList list; | 1783 | QStringList list; |
1778 | list = config->readListEntry("MainLayout"); | 1784 | list = config->readListEntry("MainLayout"); |
1779 | int x,y,w,h; | 1785 | int x,y,w,h; |
1780 | if ( ! list.isEmpty() ) { | 1786 | if ( ! list.isEmpty() ) { |
1781 | x = list[0].toInt(); | 1787 | x = list[0].toInt(); |
1782 | y = list[1].toInt(); | 1788 | y = list[1].toInt(); |
1783 | w = list[2].toInt(); | 1789 | w = list[2].toInt(); |
1784 | h = list[3].toInt(); | 1790 | h = list[3].toInt(); |
1785 | topLevelWidget()->setGeometry(x,y,w,h); | 1791 | topLevelWidget()->setGeometry(x,y,w,h); |
1786 | 1792 | ||
1787 | } else { | 1793 | } else { |
1788 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1794 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1789 | } | 1795 | } |
1790 | list = config->readListEntry("EditEventLayout"); | 1796 | list = config->readListEntry("EditEventLayout"); |
1791 | if ( ! list.isEmpty() ) { | 1797 | if ( ! list.isEmpty() ) { |
1792 | x = list[0].toInt(); | 1798 | x = list[0].toInt(); |
1793 | y = list[1].toInt(); | 1799 | y = list[1].toInt(); |
1794 | w = list[2].toInt(); | 1800 | w = list[2].toInt(); |
1795 | h = list[3].toInt(); | 1801 | h = list[3].toInt(); |
1796 | mEventEditor->setGeometry(x,y,w,h); | 1802 | mEventEditor->setGeometry(x,y,w,h); |
1797 | 1803 | ||
1798 | } | 1804 | } |
1799 | list = config->readListEntry("EditTodoLayout"); | 1805 | list = config->readListEntry("EditTodoLayout"); |
1800 | if ( ! list.isEmpty() ) { | 1806 | if ( ! list.isEmpty() ) { |
1801 | x = list[0].toInt(); | 1807 | x = list[0].toInt(); |
1802 | y = list[1].toInt(); | 1808 | y = list[1].toInt(); |
1803 | w = list[2].toInt(); | 1809 | w = list[2].toInt(); |
1804 | h = list[3].toInt(); | 1810 | h = list[3].toInt(); |
1805 | mTodoEditor->setGeometry(x,y,w,h); | 1811 | mTodoEditor->setGeometry(x,y,w,h); |
1806 | 1812 | ||
1807 | } | 1813 | } |
1808 | list = config->readListEntry("ViewerLayout"); | 1814 | list = config->readListEntry("ViewerLayout"); |
1809 | if ( ! list.isEmpty() ) { | 1815 | if ( ! list.isEmpty() ) { |
1810 | x = list[0].toInt(); | 1816 | x = list[0].toInt(); |
1811 | y = list[1].toInt(); | 1817 | y = list[1].toInt(); |
1812 | w = list[2].toInt(); | 1818 | w = list[2].toInt(); |
1813 | h = list[3].toInt(); | 1819 | h = list[3].toInt(); |
1814 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1820 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1815 | } | 1821 | } |
1816 | #endif | 1822 | #endif |
1817 | 1823 | ||
1818 | } | 1824 | } |
1819 | 1825 | ||
1820 | 1826 | ||
1821 | void CalendarView::writeSettings() | 1827 | void CalendarView::writeSettings() |
1822 | { | 1828 | { |
1823 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1829 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1824 | 1830 | ||
1825 | KConfig *config = KOGlobals::config(); | 1831 | KConfig *config = KOGlobals::config(); |
1826 | 1832 | ||
1827 | #ifndef KORG_NOSPLITTER | 1833 | #ifndef KORG_NOSPLITTER |
1828 | config->setGroup("KOrganizer Geometry"); | 1834 | config->setGroup("KOrganizer Geometry"); |
1829 | 1835 | ||
1830 | QValueList<int> list = mPanner->sizes(); | 1836 | QValueList<int> list = mPanner->sizes(); |
1831 | config->writeEntry("Separator1",list); | 1837 | config->writeEntry("Separator1",list); |
1832 | 1838 | ||
1833 | list = mLeftSplitter->sizes(); | 1839 | list = mLeftSplitter->sizes(); |
1834 | config->writeEntry("Separator2",list); | 1840 | config->writeEntry("Separator2",list); |
1835 | #endif | 1841 | #endif |
1836 | 1842 | ||
1837 | mViewManager->writeSettings( config ); | 1843 | mViewManager->writeSettings( config ); |
1838 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1844 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1839 | mDialogManager->writeSettings( config ); | 1845 | mDialogManager->writeSettings( config ); |
1840 | //KOPrefs::instance()->usrWriteConfig(); | 1846 | //KOPrefs::instance()->usrWriteConfig(); |
1841 | KOPrefs::instance()->writeConfig(); | 1847 | KOPrefs::instance()->writeConfig(); |
1842 | 1848 | ||
1843 | writeFilterSettings(config); | 1849 | writeFilterSettings(config); |
1844 | 1850 | ||
1845 | config->setGroup( "Views" ); | 1851 | config->setGroup( "Views" ); |
1846 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1852 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1847 | 1853 | ||
1848 | #ifdef DESKTOP_VERSION | 1854 | #ifdef DESKTOP_VERSION |
1849 | config->setGroup("WidgetLayout"); | 1855 | config->setGroup("WidgetLayout"); |
1850 | QStringList list ;//= config->readListEntry("MainLayout"); | 1856 | QStringList list ;//= config->readListEntry("MainLayout"); |
1851 | int x,y,w,h; | 1857 | int x,y,w,h; |
1852 | QWidget* wid; | 1858 | QWidget* wid; |
1853 | wid = topLevelWidget(); | 1859 | wid = topLevelWidget(); |
1854 | x = wid->geometry().x(); | 1860 | x = wid->geometry().x(); |
1855 | y = wid->geometry().y(); | 1861 | y = wid->geometry().y(); |
1856 | w = wid->width(); | 1862 | w = wid->width(); |
1857 | h = wid->height(); | 1863 | h = wid->height(); |
1858 | list.clear(); | 1864 | list.clear(); |
1859 | list << QString::number( x ); | 1865 | list << QString::number( x ); |
1860 | list << QString::number( y ); | 1866 | list << QString::number( y ); |
1861 | list << QString::number( w ); | 1867 | list << QString::number( w ); |
1862 | list << QString::number( h ); | 1868 | list << QString::number( h ); |
1863 | config->writeEntry("MainLayout",list ); | 1869 | config->writeEntry("MainLayout",list ); |
1864 | 1870 | ||
1865 | wid = mEventEditor; | 1871 | wid = mEventEditor; |
1866 | x = wid->geometry().x(); | 1872 | x = wid->geometry().x(); |
1867 | y = wid->geometry().y(); | 1873 | y = wid->geometry().y(); |
1868 | w = wid->width(); | 1874 | w = wid->width(); |
1869 | h = wid->height(); | 1875 | h = wid->height(); |
1870 | list.clear(); | 1876 | list.clear(); |
1871 | list << QString::number( x ); | 1877 | list << QString::number( x ); |
1872 | list << QString::number( y ); | 1878 | list << QString::number( y ); |
1873 | list << QString::number( w ); | 1879 | list << QString::number( w ); |
1874 | list << QString::number( h ); | 1880 | list << QString::number( h ); |
1875 | config->writeEntry("EditEventLayout",list ); | 1881 | config->writeEntry("EditEventLayout",list ); |
1876 | 1882 | ||
1877 | wid = mTodoEditor; | 1883 | wid = mTodoEditor; |
1878 | x = wid->geometry().x(); | 1884 | x = wid->geometry().x(); |
1879 | y = wid->geometry().y(); | 1885 | y = wid->geometry().y(); |
1880 | w = wid->width(); | 1886 | w = wid->width(); |
1881 | h = wid->height(); | 1887 | h = wid->height(); |
1882 | list.clear(); | 1888 | list.clear(); |
1883 | list << QString::number( x ); | 1889 | list << QString::number( x ); |
1884 | list << QString::number( y ); | 1890 | list << QString::number( y ); |
1885 | list << QString::number( w ); | 1891 | list << QString::number( w ); |
1886 | list << QString::number( h ); | 1892 | list << QString::number( h ); |
1887 | config->writeEntry("EditTodoLayout",list ); | 1893 | config->writeEntry("EditTodoLayout",list ); |
1888 | wid = getEventViewerDialog(); | 1894 | wid = getEventViewerDialog(); |
1889 | x = wid->geometry().x(); | 1895 | x = wid->geometry().x(); |
1890 | y = wid->geometry().y(); | 1896 | y = wid->geometry().y(); |
1891 | w = wid->width(); | 1897 | w = wid->width(); |
1892 | h = wid->height(); | 1898 | h = wid->height(); |
1893 | list.clear(); | 1899 | list.clear(); |
1894 | list << QString::number( x ); | 1900 | list << QString::number( x ); |
1895 | list << QString::number( y ); | 1901 | list << QString::number( y ); |
1896 | list << QString::number( w ); | 1902 | list << QString::number( w ); |
1897 | list << QString::number( h ); | 1903 | list << QString::number( h ); |
1898 | config->writeEntry("ViewerLayout",list ); | 1904 | config->writeEntry("ViewerLayout",list ); |
1899 | wid = mDialogManager->getSearchDialog(); | 1905 | wid = mDialogManager->getSearchDialog(); |
1900 | if ( wid ) { | 1906 | if ( wid ) { |
1901 | x = wid->geometry().x(); | 1907 | x = wid->geometry().x(); |
1902 | y = wid->geometry().y(); | 1908 | y = wid->geometry().y(); |
1903 | w = wid->width(); | 1909 | w = wid->width(); |
1904 | h = wid->height(); | 1910 | h = wid->height(); |
1905 | list.clear(); | 1911 | list.clear(); |
1906 | list << QString::number( x ); | 1912 | list << QString::number( x ); |
1907 | list << QString::number( y ); | 1913 | list << QString::number( y ); |
1908 | list << QString::number( w ); | 1914 | list << QString::number( w ); |
1909 | list << QString::number( h ); | 1915 | list << QString::number( h ); |
1910 | config->writeEntry("SearchLayout",list ); | 1916 | config->writeEntry("SearchLayout",list ); |
1911 | } | 1917 | } |
1912 | #endif | 1918 | #endif |
1913 | 1919 | ||
1914 | 1920 | ||
1915 | config->sync(); | 1921 | config->sync(); |
1916 | } | 1922 | } |
1917 | 1923 | ||
1918 | void CalendarView::readFilterSettings(KConfig *config) | 1924 | void CalendarView::readFilterSettings(KConfig *config) |
1919 | { | 1925 | { |
1920 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1926 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1921 | 1927 | ||
1922 | mFilters.clear(); | 1928 | mFilters.clear(); |
1923 | 1929 | ||
1924 | config->setGroup("General"); | 1930 | config->setGroup("General"); |
1925 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1931 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1926 | 1932 | ||
1927 | QStringList::ConstIterator it = filterList.begin(); | 1933 | QStringList::ConstIterator it = filterList.begin(); |
1928 | QStringList::ConstIterator end = filterList.end(); | 1934 | QStringList::ConstIterator end = filterList.end(); |
1929 | while(it != end) { | 1935 | while(it != end) { |
1930 | // kdDebug() << " filter: " << (*it) << endl; | 1936 | // kdDebug() << " filter: " << (*it) << endl; |
1931 | 1937 | ||
1932 | CalFilter *filter; | 1938 | CalFilter *filter; |
1933 | filter = new CalFilter(*it); | 1939 | filter = new CalFilter(*it); |
1934 | config->setGroup("Filter_" + (*it)); | 1940 | config->setGroup("Filter_" + (*it)); |
1935 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1941 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1936 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1942 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1937 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1943 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1938 | mFilters.append(filter); | 1944 | mFilters.append(filter); |
1939 | 1945 | ||
1940 | ++it; | 1946 | ++it; |
1941 | } | 1947 | } |
1942 | 1948 | ||
1943 | if (mFilters.count() == 0) { | 1949 | if (mFilters.count() == 0) { |
1944 | CalFilter *filter = new CalFilter(i18n("Default")); | 1950 | CalFilter *filter = new CalFilter(i18n("Default")); |
1945 | mFilters.append(filter); | 1951 | mFilters.append(filter); |
1946 | } | 1952 | } |
1947 | mFilterView->updateFilters(); | 1953 | mFilterView->updateFilters(); |
1948 | config->setGroup("FilterView"); | 1954 | config->setGroup("FilterView"); |
1949 | 1955 | ||
1950 | mFilterView->blockSignals(true); | 1956 | mFilterView->blockSignals(true); |
1951 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1957 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1952 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1958 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1953 | mFilterView->blockSignals(false); | 1959 | mFilterView->blockSignals(false); |
1954 | // We do it manually to avoid it being done twice by the above calls | 1960 | // We do it manually to avoid it being done twice by the above calls |
1955 | updateFilter(); | 1961 | updateFilter(); |
1956 | } | 1962 | } |
1957 | 1963 | ||
1958 | void CalendarView::writeFilterSettings(KConfig *config) | 1964 | void CalendarView::writeFilterSettings(KConfig *config) |
1959 | { | 1965 | { |
1960 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1966 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1961 | 1967 | ||
1962 | QStringList filterList; | 1968 | QStringList filterList; |
1963 | 1969 | ||
1964 | CalFilter *filter = mFilters.first(); | 1970 | CalFilter *filter = mFilters.first(); |
1965 | while(filter) { | 1971 | while(filter) { |
1966 | // kdDebug() << " fn: " << filter->name() << endl; | 1972 | // kdDebug() << " fn: " << filter->name() << endl; |
1967 | filterList << filter->name(); | 1973 | filterList << filter->name(); |
1968 | config->setGroup("Filter_" + filter->name()); | 1974 | config->setGroup("Filter_" + filter->name()); |
1969 | config->writeEntry("Criteria",filter->criteria()); | 1975 | config->writeEntry("Criteria",filter->criteria()); |
1970 | config->writeEntry("CategoryList",filter->categoryList()); | 1976 | config->writeEntry("CategoryList",filter->categoryList()); |
1971 | filter = mFilters.next(); | 1977 | filter = mFilters.next(); |
1972 | } | 1978 | } |
1973 | config->setGroup("General"); | 1979 | config->setGroup("General"); |
1974 | config->writeEntry("CalendarFilters",filterList); | 1980 | config->writeEntry("CalendarFilters",filterList); |
1975 | 1981 | ||
1976 | config->setGroup("FilterView"); | 1982 | config->setGroup("FilterView"); |
1977 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1983 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1978 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1984 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1979 | } | 1985 | } |
1980 | 1986 | ||
1981 | 1987 | ||
1982 | void CalendarView::goToday() | 1988 | void CalendarView::goToday() |
1983 | { | 1989 | { |
1984 | mNavigator->selectToday(); | 1990 | mNavigator->selectToday(); |
1985 | } | 1991 | } |
1986 | 1992 | ||
1987 | void CalendarView::goNext() | 1993 | void CalendarView::goNext() |
1988 | { | 1994 | { |
1989 | mNavigator->selectNext(); | 1995 | mNavigator->selectNext(); |
1990 | } | 1996 | } |
1991 | 1997 | ||
1992 | void CalendarView::goPrevious() | 1998 | void CalendarView::goPrevious() |
1993 | { | 1999 | { |
1994 | mNavigator->selectPrevious(); | 2000 | mNavigator->selectPrevious(); |
1995 | } | 2001 | } |
1996 | void CalendarView::goNextMonth() | 2002 | void CalendarView::goNextMonth() |
1997 | { | 2003 | { |
1998 | mNavigator->selectNextMonth(); | 2004 | mNavigator->selectNextMonth(); |
1999 | } | 2005 | } |
2000 | 2006 | ||
2001 | void CalendarView::goPreviousMonth() | 2007 | void CalendarView::goPreviousMonth() |
2002 | { | 2008 | { |
2003 | mNavigator->selectPreviousMonth(); | 2009 | mNavigator->selectPreviousMonth(); |
2004 | } | 2010 | } |
2005 | void CalendarView::writeLocale() | 2011 | void CalendarView::writeLocale() |
2006 | { | 2012 | { |
2007 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2013 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2008 | #if 0 | 2014 | #if 0 |
2009 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2015 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2010 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2016 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2011 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2017 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2012 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2018 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2013 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2019 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2014 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2020 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2015 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2021 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2016 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2022 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2017 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2023 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2018 | KOPrefs::instance()->mDaylightsavingStart, | 2024 | KOPrefs::instance()->mDaylightsavingStart, |
2019 | KOPrefs::instance()->mDaylightsavingEnd ); | 2025 | KOPrefs::instance()->mDaylightsavingEnd ); |
2020 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2026 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2021 | #endif | 2027 | #endif |
2022 | } | 2028 | } |
2023 | void CalendarView::updateConfig() | 2029 | void CalendarView::updateConfig() |
2024 | { | 2030 | { |
2025 | writeLocale(); | 2031 | writeLocale(); |
2026 | if ( KOPrefs::instance()->mUseAppColors ) | 2032 | if ( KOPrefs::instance()->mUseAppColors ) |
2027 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2033 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2028 | emit configChanged(); | 2034 | emit configChanged(); |
2029 | mTodoList->updateConfig(); | 2035 | mTodoList->updateConfig(); |
2030 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2036 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2031 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2037 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2032 | // To make the "fill window" configurations work | 2038 | // To make the "fill window" configurations work |
2033 | //mViewManager->raiseCurrentView(); | 2039 | //mViewManager->raiseCurrentView(); |
2034 | } | 2040 | } |
2035 | 2041 | ||
2036 | 2042 | ||
2037 | void CalendarView::eventChanged(Event *event) | 2043 | void CalendarView::eventChanged(Event *event) |
2038 | { | 2044 | { |
2039 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2045 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2040 | //updateUnmanagedViews(); | 2046 | //updateUnmanagedViews(); |
2041 | } | 2047 | } |
2042 | 2048 | ||
2043 | void CalendarView::eventAdded(Event *event) | 2049 | void CalendarView::eventAdded(Event *event) |
2044 | { | 2050 | { |
2045 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2051 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2046 | } | 2052 | } |
2047 | 2053 | ||
2048 | void CalendarView::eventToBeDeleted(Event *) | 2054 | void CalendarView::eventToBeDeleted(Event *) |
2049 | { | 2055 | { |
2050 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2056 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2051 | } | 2057 | } |
2052 | 2058 | ||
2053 | void CalendarView::eventDeleted() | 2059 | void CalendarView::eventDeleted() |
2054 | { | 2060 | { |
2055 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2061 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2056 | } | 2062 | } |
2057 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2063 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2058 | { | 2064 | { |
2059 | changeIncidenceDisplay((Incidence *)which, action); | 2065 | changeIncidenceDisplay((Incidence *)which, action); |
2060 | mDateNavigator->updateView(); //LR | 2066 | mDateNavigator->updateView(); //LR |
2061 | //mDialogManager->updateSearchDialog(); | 2067 | //mDialogManager->updateSearchDialog(); |
2062 | 2068 | ||
2063 | if (which) { | 2069 | if (which) { |
2064 | mViewManager->updateWNview(); | 2070 | mViewManager->updateWNview(); |
2065 | //mTodoList->updateView(); | 2071 | //mTodoList->updateView(); |
2066 | } | 2072 | } |
2067 | 2073 | ||
2068 | } | 2074 | } |
2069 | 2075 | ||
2070 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2076 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2071 | { | 2077 | { |
2072 | updateUnmanagedViews(); | 2078 | updateUnmanagedViews(); |
2073 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2079 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2074 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2080 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2075 | mCalendar->checkAlarmForIncidence( 0, true ); | 2081 | mCalendar->checkAlarmForIncidence( 0, true ); |
2076 | if ( mEventViewerDialog ) | 2082 | if ( mEventViewerDialog ) |
2077 | mEventViewerDialog->hide(); | 2083 | mEventViewerDialog->hide(); |
2078 | } | 2084 | } |
2079 | else | 2085 | else |
2080 | mCalendar->checkAlarmForIncidence( which , false ); | 2086 | mCalendar->checkAlarmForIncidence( which , false ); |
2081 | } | 2087 | } |
2082 | 2088 | ||
2083 | // most of the changeEventDisplays() right now just call the view's | 2089 | // most of the changeEventDisplays() right now just call the view's |
2084 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2090 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2085 | void CalendarView::changeEventDisplay(Event *which, int action) | 2091 | void CalendarView::changeEventDisplay(Event *which, int action) |
2086 | { | 2092 | { |
2087 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2093 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2088 | changeIncidenceDisplay((Incidence *)which, action); | 2094 | changeIncidenceDisplay((Incidence *)which, action); |
2089 | mDateNavigator->updateView(); | 2095 | mDateNavigator->updateView(); |
2090 | //mDialogManager->updateSearchDialog(); | 2096 | //mDialogManager->updateSearchDialog(); |
2091 | 2097 | ||
2092 | if (which) { | 2098 | if (which) { |
2093 | // If there is an event view visible update the display | 2099 | // If there is an event view visible update the display |
2094 | mViewManager->currentView()->changeEventDisplay(which,action); | 2100 | mViewManager->currentView()->changeEventDisplay(which,action); |
2095 | // TODO: check, if update needed | 2101 | // TODO: check, if update needed |
2096 | // if (which->getTodoStatus()) { | 2102 | // if (which->getTodoStatus()) { |
2097 | mTodoList->updateView(); | 2103 | mTodoList->updateView(); |
2098 | // } | 2104 | // } |
2099 | } else { | 2105 | } else { |
2100 | mViewManager->currentView()->updateView(); | 2106 | mViewManager->currentView()->updateView(); |
2101 | } | 2107 | } |
2102 | } | 2108 | } |
2103 | 2109 | ||
2104 | 2110 | ||
2105 | void CalendarView::updateTodoViews() | 2111 | void CalendarView::updateTodoViews() |
2106 | { | 2112 | { |
2107 | 2113 | ||
2108 | mTodoList->updateView(); | 2114 | mTodoList->updateView(); |
2109 | mViewManager->currentView()->updateView(); | 2115 | mViewManager->currentView()->updateView(); |
2110 | 2116 | ||
2111 | } | 2117 | } |
2112 | 2118 | ||
2113 | 2119 | ||
2114 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2120 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2115 | { | 2121 | { |
2116 | mTodoList->updateView(); | 2122 | mTodoList->updateView(); |
2117 | mViewManager->updateView(start, end); | 2123 | mViewManager->updateView(start, end); |
2118 | //mDateNavigator->updateView(); | 2124 | //mDateNavigator->updateView(); |
2119 | } | 2125 | } |
2120 | 2126 | ||
2121 | void CalendarView::updateView() | 2127 | void CalendarView::updateView() |
2122 | { | 2128 | { |
2123 | DateList tmpList = mNavigator->selectedDates(); | 2129 | DateList tmpList = mNavigator->selectedDates(); |
2124 | 2130 | ||
2125 | // We assume that the navigator only selects consecutive days. | 2131 | // We assume that the navigator only selects consecutive days. |
2126 | updateView( tmpList.first(), tmpList.last() ); | 2132 | updateView( tmpList.first(), tmpList.last() ); |
2127 | } | 2133 | } |
2128 | 2134 | ||
2129 | void CalendarView::updateUnmanagedViews() | 2135 | void CalendarView::updateUnmanagedViews() |
2130 | { | 2136 | { |
2131 | mDateNavigator->updateDayMatrix(); | 2137 | mDateNavigator->updateDayMatrix(); |
2132 | } | 2138 | } |
2133 | 2139 | ||
2134 | int CalendarView::msgItemDelete() | 2140 | int CalendarView::msgItemDelete() |
2135 | { | 2141 | { |
2136 | return KMessageBox::warningContinueCancel(this, | 2142 | return KMessageBox::warningContinueCancel(this, |
2137 | i18n("This item will be\npermanently deleted."), | 2143 | i18n("This item will be\npermanently deleted."), |
2138 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2144 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2139 | } | 2145 | } |
2140 | 2146 | ||
2141 | 2147 | ||
2142 | void CalendarView::edit_cut() | 2148 | void CalendarView::edit_cut() |
2143 | { | 2149 | { |
2144 | Event *anEvent=0; | 2150 | Event *anEvent=0; |
2145 | 2151 | ||
2146 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2152 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2147 | 2153 | ||
2148 | if (mViewManager->currentView()->isEventView()) { | 2154 | if (mViewManager->currentView()->isEventView()) { |
2149 | if ( incidence && incidence->type() == "Event" ) { | 2155 | if ( incidence && incidence->type() == "Event" ) { |
2150 | anEvent = static_cast<Event *>(incidence); | 2156 | anEvent = static_cast<Event *>(incidence); |
2151 | } | 2157 | } |
2152 | } | 2158 | } |
2153 | 2159 | ||
2154 | if (!anEvent) { | 2160 | if (!anEvent) { |
2155 | KNotifyClient::beep(); | 2161 | KNotifyClient::beep(); |
2156 | return; | 2162 | return; |
2157 | } | 2163 | } |
2158 | DndFactory factory( mCalendar ); | 2164 | DndFactory factory( mCalendar ); |
2159 | factory.cutEvent(anEvent); | 2165 | factory.cutEvent(anEvent); |
2160 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2166 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2161 | } | 2167 | } |
2162 | 2168 | ||
2163 | void CalendarView::edit_copy() | 2169 | void CalendarView::edit_copy() |
2164 | { | 2170 | { |
2165 | Event *anEvent=0; | 2171 | Event *anEvent=0; |
2166 | 2172 | ||
2167 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2173 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2168 | 2174 | ||
2169 | if (mViewManager->currentView()->isEventView()) { | 2175 | if (mViewManager->currentView()->isEventView()) { |
2170 | if ( incidence && incidence->type() == "Event" ) { | 2176 | if ( incidence && incidence->type() == "Event" ) { |
2171 | anEvent = static_cast<Event *>(incidence); | 2177 | anEvent = static_cast<Event *>(incidence); |
2172 | } | 2178 | } |
2173 | } | 2179 | } |
2174 | 2180 | ||
2175 | if (!anEvent) { | 2181 | if (!anEvent) { |
2176 | KNotifyClient::beep(); | 2182 | KNotifyClient::beep(); |
2177 | return; | 2183 | return; |
2178 | } | 2184 | } |
2179 | DndFactory factory( mCalendar ); | 2185 | DndFactory factory( mCalendar ); |
2180 | factory.copyEvent(anEvent); | 2186 | factory.copyEvent(anEvent); |
2181 | } | 2187 | } |
2182 | 2188 | ||
2183 | void CalendarView::edit_paste() | 2189 | void CalendarView::edit_paste() |
2184 | { | 2190 | { |
2185 | QDate date = mNavigator->selectedDates().first(); | 2191 | QDate date = mNavigator->selectedDates().first(); |
2186 | 2192 | ||
2187 | DndFactory factory( mCalendar ); | 2193 | DndFactory factory( mCalendar ); |
2188 | Event *pastedEvent = factory.pasteEvent( date ); | 2194 | Event *pastedEvent = factory.pasteEvent( date ); |
2189 | 2195 | ||
2190 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2196 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2191 | } | 2197 | } |
2192 | 2198 | ||
2193 | void CalendarView::edit_options() | 2199 | void CalendarView::edit_options() |
2194 | { | 2200 | { |
2195 | mDialogManager->showOptionsDialog(); | 2201 | mDialogManager->showOptionsDialog(); |
2196 | //writeSettings(); | 2202 | //writeSettings(); |
2197 | } | 2203 | } |
2198 | 2204 | ||
2199 | void CalendarView::slotSelectPickerDate( QDate d) | 2205 | void CalendarView::slotSelectPickerDate( QDate d) |
2200 | { | 2206 | { |
2201 | mDateFrame->hide(); | 2207 | mDateFrame->hide(); |
2202 | if ( mDatePickerMode == 1 ) { | 2208 | if ( mDatePickerMode == 1 ) { |
2203 | mNavigator->slotDaySelect( d ); | 2209 | mNavigator->slotDaySelect( d ); |
2204 | } else if ( mDatePickerMode == 2 ) { | 2210 | } else if ( mDatePickerMode == 2 ) { |
2205 | if ( mMoveIncidence->type() == "Todo" ) { | 2211 | if ( mMoveIncidence->type() == "Todo" ) { |
2206 | Todo * to = (Todo *) mMoveIncidence; | 2212 | Todo * to = (Todo *) mMoveIncidence; |
2207 | QTime tim; | 2213 | QTime tim; |
2208 | if ( to->hasDueDate() ) | 2214 | if ( to->hasDueDate() ) |
2209 | tim = to->dtDue().time(); | 2215 | tim = to->dtDue().time(); |
2210 | else { | 2216 | else { |
2211 | tim = QTime ( 0,0,0 ); | 2217 | tim = QTime ( 0,0,0 ); |
2212 | to->setFloats( true ); | 2218 | to->setFloats( true ); |
2213 | to->setHasDueDate( true ); | 2219 | to->setHasDueDate( true ); |
2214 | } | 2220 | } |
2215 | QDateTime dt ( d,tim ); | 2221 | QDateTime dt ( d,tim ); |
2216 | to->setDtDue( dt ); | 2222 | to->setDtDue( dt ); |
2217 | todoChanged( to ); | 2223 | todoChanged( to ); |
2218 | } else { | 2224 | } else { |
2219 | QTime tim = mMoveIncidence->dtStart().time(); | 2225 | QTime tim = mMoveIncidence->dtStart().time(); |
2220 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2226 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2221 | QDateTime dt ( d,tim ); | 2227 | QDateTime dt ( d,tim ); |
2222 | mMoveIncidence->setDtStart( dt ); | 2228 | mMoveIncidence->setDtStart( dt ); |
2223 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2229 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2224 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2230 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2225 | } | 2231 | } |
2226 | 2232 | ||
2227 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2233 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2228 | } | 2234 | } |
2229 | } | 2235 | } |
2230 | 2236 | ||
2231 | void CalendarView::removeCategories() | 2237 | void CalendarView::removeCategories() |
2232 | { | 2238 | { |
2233 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2239 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2234 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2240 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2235 | QStringList catIncList; | 2241 | QStringList catIncList; |
2236 | QStringList newCatList; | 2242 | QStringList newCatList; |
2237 | Incidence* inc = incList.first(); | 2243 | Incidence* inc = incList.first(); |
2238 | int i; | 2244 | int i; |
2239 | int count = 0; | 2245 | int count = 0; |
2240 | while ( inc ) { | 2246 | while ( inc ) { |
2241 | newCatList.clear(); | 2247 | newCatList.clear(); |
2242 | catIncList = inc->categories() ; | 2248 | catIncList = inc->categories() ; |
2243 | for( i = 0; i< catIncList.count(); ++i ) { | 2249 | for( i = 0; i< catIncList.count(); ++i ) { |
2244 | if ( catList.contains (catIncList[i])) | 2250 | if ( catList.contains (catIncList[i])) |
2245 | newCatList.append( catIncList[i] ); | 2251 | newCatList.append( catIncList[i] ); |
2246 | } | 2252 | } |
2247 | newCatList.sort(); | 2253 | newCatList.sort(); |
2248 | inc->setCategories( newCatList.join(",") ); | 2254 | inc->setCategories( newCatList.join(",") ); |
2249 | inc = incList.next(); | 2255 | inc = incList.next(); |
2250 | } | 2256 | } |
2251 | } | 2257 | } |
2252 | 2258 | ||
2253 | int CalendarView::addCategories() | 2259 | int CalendarView::addCategories() |
2254 | { | 2260 | { |
2255 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2261 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2256 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2262 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2257 | QStringList catIncList; | 2263 | QStringList catIncList; |
2258 | Incidence* inc = incList.first(); | 2264 | Incidence* inc = incList.first(); |
2259 | int i; | 2265 | int i; |
2260 | int count = 0; | 2266 | int count = 0; |
2261 | while ( inc ) { | 2267 | while ( inc ) { |
2262 | catIncList = inc->categories() ; | 2268 | catIncList = inc->categories() ; |
2263 | for( i = 0; i< catIncList.count(); ++i ) { | 2269 | for( i = 0; i< catIncList.count(); ++i ) { |
2264 | if ( !catList.contains (catIncList[i])) { | 2270 | if ( !catList.contains (catIncList[i])) { |
2265 | catList.append( catIncList[i] ); | 2271 | catList.append( catIncList[i] ); |
2266 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2272 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2267 | ++count; | 2273 | ++count; |
2268 | } | 2274 | } |
2269 | } | 2275 | } |
2270 | inc = incList.next(); | 2276 | inc = incList.next(); |
2271 | } | 2277 | } |
2272 | catList.sort(); | 2278 | catList.sort(); |
2273 | KOPrefs::instance()->mCustomCategories = catList; | 2279 | KOPrefs::instance()->mCustomCategories = catList; |
2274 | return count; | 2280 | return count; |
2275 | } | 2281 | } |
2276 | 2282 | ||
2277 | void CalendarView::manageCategories() | 2283 | void CalendarView::manageCategories() |
2278 | { | 2284 | { |
2279 | KOCatPrefs* cp = new KOCatPrefs(); | 2285 | KOCatPrefs* cp = new KOCatPrefs(); |
2280 | cp->show(); | 2286 | cp->show(); |
2281 | int w =cp->sizeHint().width() ; | 2287 | int w =cp->sizeHint().width() ; |
2282 | int h = cp->sizeHint().height() ; | 2288 | int h = cp->sizeHint().height() ; |
2283 | int dw = QApplication::desktop()->width(); | 2289 | int dw = QApplication::desktop()->width(); |
2284 | int dh = QApplication::desktop()->height(); | 2290 | int dh = QApplication::desktop()->height(); |
2285 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2291 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2286 | if ( !cp->exec() ) { | 2292 | if ( !cp->exec() ) { |
2287 | delete cp; | 2293 | delete cp; |
2288 | return; | 2294 | return; |
2289 | } | 2295 | } |
2290 | int count = 0; | 2296 | int count = 0; |
2291 | if ( cp->addCat() ) { | 2297 | if ( cp->addCat() ) { |
2292 | count = addCategories(); | 2298 | count = addCategories(); |
2293 | if ( count ) { | 2299 | if ( count ) { |
2294 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2300 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2295 | writeSettings(); | 2301 | writeSettings(); |
2296 | } | 2302 | } |
2297 | } else { | 2303 | } else { |
2298 | removeCategories(); | 2304 | removeCategories(); |
2299 | updateView(); | 2305 | updateView(); |
2300 | } | 2306 | } |
2301 | delete cp; | 2307 | delete cp; |
2302 | } | 2308 | } |
2303 | 2309 | ||
2304 | void CalendarView::beamIncidence(Incidence * Inc) | 2310 | void CalendarView::beamIncidence(Incidence * Inc) |
2305 | { | 2311 | { |
2306 | QPtrList<Incidence> delSel ; | 2312 | QPtrList<Incidence> delSel ; |
2307 | delSel.append(Inc); | 2313 | delSel.append(Inc); |
2308 | beamIncidenceList( delSel ); | 2314 | beamIncidenceList( delSel ); |
2309 | } | 2315 | } |
2310 | void CalendarView::beamCalendar() | 2316 | void CalendarView::beamCalendar() |
2311 | { | 2317 | { |
2312 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2318 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2313 | //qDebug("beamCalendar() "); | 2319 | //qDebug("beamCalendar() "); |
2314 | beamIncidenceList( delSel ); | 2320 | beamIncidenceList( delSel ); |
2315 | } | 2321 | } |
2316 | void CalendarView::beamFilteredCalendar() | 2322 | void CalendarView::beamFilteredCalendar() |
2317 | { | 2323 | { |
2318 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2324 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2319 | //qDebug("beamFilteredCalendar() "); | 2325 | //qDebug("beamFilteredCalendar() "); |
2320 | beamIncidenceList( delSel ); | 2326 | beamIncidenceList( delSel ); |
2321 | } | 2327 | } |
2322 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2328 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2323 | { | 2329 | { |
2324 | if ( beamDialog->exec () == QDialog::Rejected ) | 2330 | if ( beamDialog->exec () == QDialog::Rejected ) |
2325 | return; | 2331 | return; |
2326 | #ifdef DESKTOP_VERSION | 2332 | #ifdef DESKTOP_VERSION |
2327 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2333 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2328 | #else | 2334 | #else |
2329 | QString fn = "/tmp/kopibeamfile"; | 2335 | QString fn = "/tmp/kopibeamfile"; |
2330 | #endif | 2336 | #endif |
2331 | QString mes; | 2337 | QString mes; |
2332 | bool createbup = true; | 2338 | bool createbup = true; |
2333 | if ( createbup ) { | 2339 | if ( createbup ) { |
2334 | QString description = "\n"; | 2340 | QString description = "\n"; |
2335 | CalendarLocal* cal = new CalendarLocal(); | 2341 | CalendarLocal* cal = new CalendarLocal(); |
2336 | if ( beamDialog->beamLocal() ) | 2342 | if ( beamDialog->beamLocal() ) |
2337 | cal->setLocalTime(); | 2343 | cal->setLocalTime(); |
2338 | else | 2344 | else |
2339 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2345 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2340 | Incidence *incidence = delSel.first(); | 2346 | Incidence *incidence = delSel.first(); |
2341 | bool addText = false; | 2347 | bool addText = false; |
2342 | if ( delSel.count() < 10 ) | 2348 | if ( delSel.count() < 10 ) |
2343 | addText = true; | 2349 | addText = true; |
2344 | else { | 2350 | else { |
2345 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2351 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2346 | } | 2352 | } |
2347 | while ( incidence ) { | 2353 | while ( incidence ) { |
2348 | Incidence *in = incidence->clone(); | 2354 | Incidence *in = incidence->clone(); |
2349 | if ( ! in->summary().isEmpty() ) { | 2355 | if ( ! in->summary().isEmpty() ) { |
2350 | in->setDescription(""); | 2356 | in->setDescription(""); |
2351 | } else { | 2357 | } else { |
2352 | in->setSummary( in->description().left(20)); | 2358 | in->setSummary( in->description().left(20)); |
2353 | in->setDescription(""); | 2359 | in->setDescription(""); |
2354 | } | 2360 | } |
2355 | if ( addText ) | 2361 | if ( addText ) |
2356 | description += in->summary() + "\n"; | 2362 | description += in->summary() + "\n"; |
2357 | cal->addIncidence( in ); | 2363 | cal->addIncidence( in ); |
2358 | incidence = delSel.next(); | 2364 | incidence = delSel.next(); |
2359 | } | 2365 | } |
2360 | if ( beamDialog->beamVcal() ) { | 2366 | if ( beamDialog->beamVcal() ) { |
2361 | fn += ".vcs"; | 2367 | fn += ".vcs"; |
2362 | FileStorage storage( cal, fn, new VCalFormat ); | 2368 | FileStorage storage( cal, fn, new VCalFormat ); |
2363 | storage.save(); | 2369 | storage.save(); |
2364 | } else { | 2370 | } else { |
2365 | fn += ".ics"; | 2371 | fn += ".ics"; |
2366 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2372 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2367 | storage.save(); | 2373 | storage.save(); |
2368 | } | 2374 | } |
2369 | delete cal; | 2375 | delete cal; |
2370 | mes = i18n("KO/Pi: Ready for beaming"); | 2376 | mes = i18n("KO/Pi: Ready for beaming"); |
2371 | topLevelWidget()->setCaption(mes); | 2377 | topLevelWidget()->setCaption(mes); |
2372 | KApplication::convert2latin1( fn ); | 2378 | KApplication::convert2latin1( fn ); |
2373 | #ifndef DESKTOP_VERSION | 2379 | #ifndef DESKTOP_VERSION |
2374 | Ir *ir = new Ir( this ); | 2380 | Ir *ir = new Ir( this ); |
2375 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2381 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2376 | ir->send( fn, description, "text/x-vCalendar" ); | 2382 | ir->send( fn, description, "text/x-vCalendar" ); |
2377 | #endif | 2383 | #endif |
2378 | } | 2384 | } |
2379 | } | 2385 | } |
2380 | void CalendarView::beamDone( Ir *ir ) | 2386 | void CalendarView::beamDone( Ir *ir ) |
2381 | { | 2387 | { |
2382 | #ifndef DESKTOP_VERSION | 2388 | #ifndef DESKTOP_VERSION |
2383 | delete ir; | 2389 | delete ir; |
2384 | #endif | 2390 | #endif |
2385 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2391 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2386 | topLevelWidget()->raise(); | 2392 | topLevelWidget()->raise(); |
2387 | } | 2393 | } |
2388 | 2394 | ||
2389 | void CalendarView::moveIncidence(Incidence * inc ) | 2395 | void CalendarView::moveIncidence(Incidence * inc ) |
2390 | { | 2396 | { |
2391 | if ( !inc ) return; | 2397 | if ( !inc ) return; |
2392 | // qDebug("showDatePickerForIncidence( ) "); | 2398 | // qDebug("showDatePickerForIncidence( ) "); |
2393 | if ( mDateFrame->isVisible() ) | 2399 | if ( mDateFrame->isVisible() ) |
2394 | mDateFrame->hide(); | 2400 | mDateFrame->hide(); |
2395 | else { | 2401 | else { |
2396 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2402 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2397 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2403 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2398 | int dw = QApplication::desktop()->width(); | 2404 | int dw = QApplication::desktop()->width(); |
2399 | int dh = QApplication::desktop()->height(); | 2405 | int dh = QApplication::desktop()->height(); |
2400 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2406 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2401 | mDateFrame->show(); | 2407 | mDateFrame->show(); |
2402 | } | 2408 | } |
2403 | mDatePickerMode = 2; | 2409 | mDatePickerMode = 2; |
2404 | mMoveIncidence = inc ; | 2410 | mMoveIncidence = inc ; |
2405 | QDate da; | 2411 | QDate da; |
2406 | if ( mMoveIncidence->type() == "Todo" ) { | 2412 | if ( mMoveIncidence->type() == "Todo" ) { |
2407 | Todo * to = (Todo *) mMoveIncidence; | 2413 | Todo * to = (Todo *) mMoveIncidence; |
2408 | if ( to->hasDueDate() ) | 2414 | if ( to->hasDueDate() ) |
2409 | da = to->dtDue().date(); | 2415 | da = to->dtDue().date(); |
2410 | else | 2416 | else |
2411 | da = QDate::currentDate(); | 2417 | da = QDate::currentDate(); |
2412 | } else { | 2418 | } else { |
2413 | da = mMoveIncidence->dtStart().date(); | 2419 | da = mMoveIncidence->dtStart().date(); |
2414 | } | 2420 | } |
2415 | mDatePicker->setDate( da ); | 2421 | mDatePicker->setDate( da ); |
2416 | } | 2422 | } |
2417 | void CalendarView::showDatePicker( ) | 2423 | void CalendarView::showDatePicker( ) |
2418 | { | 2424 | { |
2419 | //qDebug("CalendarView::showDatePicker( ) "); | 2425 | //qDebug("CalendarView::showDatePicker( ) "); |
2420 | if ( mDateFrame->isVisible() ) | 2426 | if ( mDateFrame->isVisible() ) |
2421 | mDateFrame->hide(); | 2427 | mDateFrame->hide(); |
2422 | else { | 2428 | else { |
2423 | int w =mDatePicker->sizeHint().width() ; | 2429 | int w =mDatePicker->sizeHint().width() ; |
2424 | int h = mDatePicker->sizeHint().height() ; | 2430 | int h = mDatePicker->sizeHint().height() ; |
2425 | int dw = QApplication::desktop()->width(); | 2431 | int dw = QApplication::desktop()->width(); |
2426 | int dh = QApplication::desktop()->height(); | 2432 | int dh = QApplication::desktop()->height(); |
2427 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2433 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2428 | mDateFrame->show(); | 2434 | mDateFrame->show(); |
2429 | } | 2435 | } |
2430 | mDatePickerMode = 1; | 2436 | mDatePickerMode = 1; |
2431 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2437 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2432 | } | 2438 | } |
2433 | 2439 | ||
2434 | void CalendarView::showEventEditor() | 2440 | void CalendarView::showEventEditor() |
2435 | { | 2441 | { |
2436 | #ifdef DESKTOP_VERSION | 2442 | #ifdef DESKTOP_VERSION |
2437 | mEventEditor->show(); | 2443 | mEventEditor->show(); |
2438 | #else | 2444 | #else |
2439 | mEventEditor->showMaximized(); | 2445 | mEventEditor->showMaximized(); |
2440 | #endif | 2446 | #endif |
2441 | } | 2447 | } |
2442 | void CalendarView::showTodoEditor() | 2448 | void CalendarView::showTodoEditor() |
2443 | { | 2449 | { |
2444 | #ifdef DESKTOP_VERSION | 2450 | #ifdef DESKTOP_VERSION |
2445 | mTodoEditor->show(); | 2451 | mTodoEditor->show(); |
2446 | #else | 2452 | #else |
2447 | mTodoEditor->showMaximized(); | 2453 | mTodoEditor->showMaximized(); |
2448 | #endif | 2454 | #endif |
2449 | } | 2455 | } |
2450 | 2456 | ||
2451 | void CalendarView::cloneIncidence() | 2457 | void CalendarView::cloneIncidence() |
2452 | { | 2458 | { |
2453 | Incidence *incidence = currentSelection(); | 2459 | Incidence *incidence = currentSelection(); |
2454 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2460 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2455 | if ( incidence ) { | 2461 | if ( incidence ) { |
2456 | cloneIncidence(incidence); | 2462 | cloneIncidence(incidence); |
2457 | } | 2463 | } |
2458 | } | 2464 | } |
2459 | void CalendarView::moveIncidence() | 2465 | void CalendarView::moveIncidence() |
2460 | { | 2466 | { |
2461 | Incidence *incidence = currentSelection(); | 2467 | Incidence *incidence = currentSelection(); |
2462 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2468 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2463 | if ( incidence ) { | 2469 | if ( incidence ) { |
2464 | moveIncidence(incidence); | 2470 | moveIncidence(incidence); |
2465 | } | 2471 | } |
2466 | } | 2472 | } |
2467 | void CalendarView::beamIncidence() | 2473 | void CalendarView::beamIncidence() |
2468 | { | 2474 | { |
2469 | Incidence *incidence = currentSelection(); | 2475 | Incidence *incidence = currentSelection(); |
2470 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2476 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2471 | if ( incidence ) { | 2477 | if ( incidence ) { |
2472 | beamIncidence(incidence); | 2478 | beamIncidence(incidence); |
2473 | } | 2479 | } |
2474 | } | 2480 | } |
2475 | void CalendarView::toggleCancelIncidence() | 2481 | void CalendarView::toggleCancelIncidence() |
2476 | { | 2482 | { |
2477 | Incidence *incidence = currentSelection(); | 2483 | Incidence *incidence = currentSelection(); |
2478 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2484 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2479 | if ( incidence ) { | 2485 | if ( incidence ) { |
2480 | cancelIncidence(incidence); | 2486 | cancelIncidence(incidence); |
2481 | } | 2487 | } |
2482 | } | 2488 | } |
2483 | 2489 | ||
2484 | 2490 | ||
2485 | void CalendarView::cancelIncidence(Incidence * inc ) | 2491 | void CalendarView::cancelIncidence(Incidence * inc ) |
2486 | { | 2492 | { |
2487 | inc->setCancelled( ! inc->cancelled() ); | 2493 | inc->setCancelled( ! inc->cancelled() ); |
2488 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2494 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2489 | updateView(); | 2495 | updateView(); |
2490 | } | 2496 | } |
2491 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2497 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2492 | { | 2498 | { |
2493 | Incidence * newInc = orgInc->clone(); | 2499 | Incidence * newInc = orgInc->clone(); |
2494 | newInc->recreate(); | 2500 | newInc->recreate(); |
2495 | 2501 | ||
2496 | if ( newInc->type() == "Todo" ) { | 2502 | if ( newInc->type() == "Todo" ) { |
2497 | Todo* t = (Todo*) newInc; | 2503 | Todo* t = (Todo*) newInc; |
2498 | mTodoEditor->editTodo( t ); | 2504 | mTodoEditor->editTodo( t ); |
2499 | showTodoEditor(); | 2505 | showTodoEditor(); |
2500 | if ( mTodoEditor->exec() ) { | 2506 | if ( mTodoEditor->exec() ) { |
2501 | mCalendar->addTodo( t ); | 2507 | mCalendar->addTodo( t ); |
2502 | updateView(); | 2508 | updateView(); |
2503 | } else { | 2509 | } else { |
2504 | delete t; | 2510 | delete t; |
2505 | } | 2511 | } |
2506 | } | 2512 | } |
2507 | else { | 2513 | else { |
2508 | Event* e = (Event*) newInc; | 2514 | Event* e = (Event*) newInc; |
2509 | mEventEditor->editEvent( e ); | 2515 | mEventEditor->editEvent( e ); |
2510 | showEventEditor(); | 2516 | showEventEditor(); |
2511 | if ( mEventEditor->exec() ) { | 2517 | if ( mEventEditor->exec() ) { |
2512 | mCalendar->addEvent( e ); | 2518 | mCalendar->addEvent( e ); |
2513 | updateView(); | 2519 | updateView(); |
2514 | } else { | 2520 | } else { |
2515 | delete e; | 2521 | delete e; |
2516 | } | 2522 | } |
2517 | } | 2523 | } |
2518 | } | 2524 | } |
2519 | 2525 | ||
2520 | void CalendarView::newEvent() | 2526 | void CalendarView::newEvent() |
2521 | { | 2527 | { |
2522 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2528 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2523 | KOAgendaView *aView = mViewManager->agendaView(); | 2529 | KOAgendaView *aView = mViewManager->agendaView(); |
2524 | if (aView) { | 2530 | if (aView) { |
2525 | if (aView->selectionStart().isValid()) { | 2531 | if (aView->selectionStart().isValid()) { |
2526 | if (aView->selectedIsAllDay()) { | 2532 | if (aView->selectedIsAllDay()) { |
2527 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2533 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2528 | } else { | 2534 | } else { |
2529 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2535 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2530 | } | 2536 | } |
2531 | return; | 2537 | return; |
2532 | } | 2538 | } |
2533 | } | 2539 | } |
2534 | 2540 | ||
2535 | QDate date = mNavigator->selectedDates().first(); | 2541 | QDate date = mNavigator->selectedDates().first(); |
2536 | QDateTime current = QDateTime::currentDateTime(); | 2542 | QDateTime current = QDateTime::currentDateTime(); |
2537 | if ( date <= current.date() ) { | 2543 | if ( date <= current.date() ) { |
2538 | int hour = current.time().hour() +1; | 2544 | int hour = current.time().hour() +1; |
2539 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2545 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2540 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2546 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2541 | } else | 2547 | } else |
2542 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2548 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2543 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2549 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2544 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2550 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2545 | } | 2551 | } |
2546 | 2552 | ||
2547 | void CalendarView::newEvent(QDateTime fh) | 2553 | void CalendarView::newEvent(QDateTime fh) |
2548 | { | 2554 | { |
2549 | newEvent(fh, | 2555 | newEvent(fh, |
2550 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2556 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2551 | } | 2557 | } |
2552 | 2558 | ||
2553 | void CalendarView::newEvent(QDate dt) | 2559 | void CalendarView::newEvent(QDate dt) |
2554 | { | 2560 | { |
2555 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2561 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2556 | QDateTime(dt, QTime(0,0,0)), true); | 2562 | QDateTime(dt, QTime(0,0,0)), true); |
2557 | } | 2563 | } |
2558 | 2564 | ||
2559 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2565 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2560 | { | 2566 | { |
2561 | 2567 | ||
2562 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2568 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2563 | if ( mFilterView->filtersEnabled() ) { | 2569 | if ( mFilterView->filtersEnabled() ) { |
2564 | CalFilter *filter = mFilterView->selectedFilter(); | 2570 | CalFilter *filter = mFilterView->selectedFilter(); |
2565 | if (filter && filter->showCategories()) { | 2571 | if (filter && filter->showCategories()) { |
2566 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2572 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2567 | } | 2573 | } |
2568 | if ( filter ) | 2574 | if ( filter ) |
2569 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2575 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2570 | } | 2576 | } |
2571 | showEventEditor(); | 2577 | showEventEditor(); |
2572 | } | 2578 | } |
2573 | void CalendarView::todoAdded(Todo * t) | 2579 | void CalendarView::todoAdded(Todo * t) |
2574 | { | 2580 | { |
2575 | 2581 | ||
2576 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2582 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2577 | updateTodoViews(); | 2583 | updateTodoViews(); |
2578 | } | 2584 | } |
2579 | void CalendarView::todoChanged(Todo * t) | 2585 | void CalendarView::todoChanged(Todo * t) |
2580 | { | 2586 | { |
2581 | emit todoModified( t, 4 ); | 2587 | emit todoModified( t, 4 ); |
2582 | // updateTodoViews(); | 2588 | // updateTodoViews(); |
2583 | } | 2589 | } |
2584 | void CalendarView::todoToBeDeleted(Todo *) | 2590 | void CalendarView::todoToBeDeleted(Todo *) |
2585 | { | 2591 | { |
2586 | //qDebug("todoToBeDeleted(Todo *) "); | 2592 | //qDebug("todoToBeDeleted(Todo *) "); |
2587 | updateTodoViews(); | 2593 | updateTodoViews(); |
2588 | } | 2594 | } |
2589 | void CalendarView::todoDeleted() | 2595 | void CalendarView::todoDeleted() |
2590 | { | 2596 | { |
2591 | //qDebug(" todoDeleted()"); | 2597 | //qDebug(" todoDeleted()"); |
2592 | updateTodoViews(); | 2598 | updateTodoViews(); |
2593 | } | 2599 | } |
2594 | 2600 | ||
2595 | 2601 | ||
2596 | 2602 | ||
2597 | void CalendarView::newTodo() | 2603 | void CalendarView::newTodo() |
2598 | { | 2604 | { |
2599 | 2605 | ||
2600 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2606 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2601 | if ( mFilterView->filtersEnabled() ) { | 2607 | if ( mFilterView->filtersEnabled() ) { |
2602 | CalFilter *filter = mFilterView->selectedFilter(); | 2608 | CalFilter *filter = mFilterView->selectedFilter(); |
2603 | if (filter && filter->showCategories()) { | 2609 | if (filter && filter->showCategories()) { |
2604 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2610 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2605 | } | 2611 | } |
2606 | if ( filter ) | 2612 | if ( filter ) |
2607 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2613 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2608 | } | 2614 | } |
2609 | showTodoEditor(); | 2615 | showTodoEditor(); |
2610 | } | 2616 | } |
2611 | 2617 | ||
2612 | void CalendarView::newSubTodo() | 2618 | void CalendarView::newSubTodo() |
2613 | { | 2619 | { |
2614 | Todo *todo = selectedTodo(); | 2620 | Todo *todo = selectedTodo(); |
2615 | if ( todo ) newSubTodo( todo ); | 2621 | if ( todo ) newSubTodo( todo ); |
2616 | } | 2622 | } |
2617 | 2623 | ||
2618 | void CalendarView::newSubTodo(Todo *parentEvent) | 2624 | void CalendarView::newSubTodo(Todo *parentEvent) |
2619 | { | 2625 | { |
2620 | 2626 | ||
2621 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2627 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2622 | showTodoEditor(); | 2628 | showTodoEditor(); |
2623 | } | 2629 | } |
2624 | 2630 | ||
2625 | void CalendarView::newFloatingEvent() | 2631 | void CalendarView::newFloatingEvent() |
2626 | { | 2632 | { |
2627 | DateList tmpList = mNavigator->selectedDates(); | 2633 | DateList tmpList = mNavigator->selectedDates(); |
2628 | QDate date = tmpList.first(); | 2634 | QDate date = tmpList.first(); |
2629 | 2635 | ||
2630 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2636 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2631 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2637 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2632 | } | 2638 | } |
2633 | 2639 | ||
2634 | 2640 | ||
2635 | void CalendarView::editEvent( Event *event ) | 2641 | void CalendarView::editEvent( Event *event ) |
2636 | { | 2642 | { |
2637 | 2643 | ||
2638 | if ( !event ) return; | 2644 | if ( !event ) return; |
2639 | if ( event->isReadOnly() ) { | 2645 | if ( event->isReadOnly() ) { |
2640 | showEvent( event ); | 2646 | showEvent( event ); |
2641 | return; | 2647 | return; |
2642 | } | 2648 | } |
2643 | mEventEditor->editEvent( event , mFlagEditDescription); | 2649 | mEventEditor->editEvent( event , mFlagEditDescription); |
2644 | showEventEditor(); | 2650 | showEventEditor(); |
2645 | } | 2651 | } |
2646 | void CalendarView::editJournal( Journal *jour ) | 2652 | void CalendarView::editJournal( Journal *jour ) |
2647 | { | 2653 | { |
2648 | if ( !jour ) return; | 2654 | if ( !jour ) return; |
2649 | mDialogManager->hideSearchDialog(); | 2655 | mDialogManager->hideSearchDialog(); |
2650 | mViewManager->showJournalView(); | 2656 | mViewManager->showJournalView(); |
2651 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2657 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2652 | } | 2658 | } |
2653 | void CalendarView::editTodo( Todo *todo ) | 2659 | void CalendarView::editTodo( Todo *todo ) |
2654 | { | 2660 | { |
2655 | if ( !todo ) return; | 2661 | if ( !todo ) return; |
2656 | 2662 | ||
2657 | if ( todo->isReadOnly() ) { | 2663 | if ( todo->isReadOnly() ) { |
2658 | showTodo( todo ); | 2664 | showTodo( todo ); |
2659 | return; | 2665 | return; |
2660 | } | 2666 | } |
2661 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2667 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2662 | showTodoEditor(); | 2668 | showTodoEditor(); |
2663 | 2669 | ||
2664 | } | 2670 | } |
2665 | 2671 | ||
2666 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2672 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2667 | { | 2673 | { |
2668 | if ( !mEventViewerDialog ) { | 2674 | if ( !mEventViewerDialog ) { |
2669 | mEventViewerDialog = new KOEventViewerDialog(this); | 2675 | mEventViewerDialog = new KOEventViewerDialog(this); |
2670 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2676 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2671 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2677 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2672 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2678 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2673 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2679 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2674 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2680 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2675 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2681 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2676 | mEventViewerDialog->resize( 640, 480 ); | 2682 | mEventViewerDialog->resize( 640, 480 ); |
2677 | 2683 | ||
2678 | } | 2684 | } |
2679 | return mEventViewerDialog; | 2685 | return mEventViewerDialog; |
2680 | } | 2686 | } |
2681 | void CalendarView::showEvent(Event *event) | 2687 | void CalendarView::showEvent(Event *event) |
2682 | { | 2688 | { |
2683 | getEventViewerDialog()->setEvent(event); | 2689 | getEventViewerDialog()->setEvent(event); |
2684 | getEventViewerDialog()->showMe(); | 2690 | getEventViewerDialog()->showMe(); |
2685 | } | 2691 | } |
2686 | 2692 | ||
2687 | void CalendarView::showTodo(Todo *event) | 2693 | void CalendarView::showTodo(Todo *event) |
2688 | { | 2694 | { |
2689 | getEventViewerDialog()->setTodo(event); | 2695 | getEventViewerDialog()->setTodo(event); |
2690 | getEventViewerDialog()->showMe(); | 2696 | getEventViewerDialog()->showMe(); |
2691 | } | 2697 | } |
2692 | void CalendarView::showJournal( Journal *jour ) | 2698 | void CalendarView::showJournal( Journal *jour ) |
2693 | { | 2699 | { |
2694 | getEventViewerDialog()->setJournal(jour); | 2700 | getEventViewerDialog()->setJournal(jour); |
2695 | getEventViewerDialog()->showMe(); | 2701 | getEventViewerDialog()->showMe(); |
2696 | 2702 | ||
2697 | } | 2703 | } |
2698 | // void CalendarView::todoModified (Todo *event, int changed) | 2704 | // void CalendarView::todoModified (Todo *event, int changed) |
2699 | // { | 2705 | // { |
2700 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2706 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2701 | // // kdDebug() << "Todo modified and open" << endl; | 2707 | // // kdDebug() << "Todo modified and open" << endl; |
2702 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2708 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2703 | // // temp->modified (changed); | 2709 | // // temp->modified (changed); |
2704 | 2710 | ||
2705 | // // } | 2711 | // // } |
2706 | 2712 | ||
2707 | // mViewManager->updateView(); | 2713 | // mViewManager->updateView(); |
2708 | // } | 2714 | // } |
2709 | 2715 | ||
2710 | void CalendarView::appointment_show() | 2716 | void CalendarView::appointment_show() |
2711 | { | 2717 | { |
2712 | Event *anEvent = 0; | 2718 | Event *anEvent = 0; |
2713 | 2719 | ||
2714 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2720 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2715 | 2721 | ||
2716 | if (mViewManager->currentView()->isEventView()) { | 2722 | if (mViewManager->currentView()->isEventView()) { |
2717 | if ( incidence && incidence->type() == "Event" ) { | 2723 | if ( incidence && incidence->type() == "Event" ) { |
2718 | anEvent = static_cast<Event *>(incidence); | 2724 | anEvent = static_cast<Event *>(incidence); |
2719 | } | 2725 | } |
2720 | } | 2726 | } |
2721 | 2727 | ||
2722 | if (!anEvent) { | 2728 | if (!anEvent) { |
2723 | KNotifyClient::beep(); | 2729 | KNotifyClient::beep(); |
2724 | return; | 2730 | return; |
2725 | } | 2731 | } |
2726 | 2732 | ||
2727 | showEvent(anEvent); | 2733 | showEvent(anEvent); |
2728 | } | 2734 | } |
2729 | 2735 | ||
2730 | void CalendarView::appointment_edit() | 2736 | void CalendarView::appointment_edit() |
2731 | { | 2737 | { |
2732 | Event *anEvent = 0; | 2738 | Event *anEvent = 0; |
2733 | 2739 | ||
2734 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2740 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2735 | 2741 | ||
2736 | if (mViewManager->currentView()->isEventView()) { | 2742 | if (mViewManager->currentView()->isEventView()) { |
2737 | if ( incidence && incidence->type() == "Event" ) { | 2743 | if ( incidence && incidence->type() == "Event" ) { |
2738 | anEvent = static_cast<Event *>(incidence); | 2744 | anEvent = static_cast<Event *>(incidence); |
2739 | } | 2745 | } |
2740 | } | 2746 | } |
2741 | 2747 | ||
2742 | if (!anEvent) { | 2748 | if (!anEvent) { |
2743 | KNotifyClient::beep(); | 2749 | KNotifyClient::beep(); |
2744 | return; | 2750 | return; |
2745 | } | 2751 | } |
2746 | 2752 | ||
2747 | editEvent(anEvent); | 2753 | editEvent(anEvent); |
2748 | } | 2754 | } |
2749 | 2755 | ||
2750 | void CalendarView::appointment_delete() | 2756 | void CalendarView::appointment_delete() |
2751 | { | 2757 | { |
2752 | Event *anEvent = 0; | 2758 | Event *anEvent = 0; |
2753 | 2759 | ||
2754 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2760 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2755 | 2761 | ||
2756 | if (mViewManager->currentView()->isEventView()) { | 2762 | if (mViewManager->currentView()->isEventView()) { |
2757 | if ( incidence && incidence->type() == "Event" ) { | 2763 | if ( incidence && incidence->type() == "Event" ) { |
2758 | anEvent = static_cast<Event *>(incidence); | 2764 | anEvent = static_cast<Event *>(incidence); |
2759 | } | 2765 | } |
2760 | } | 2766 | } |
2761 | 2767 | ||
2762 | if (!anEvent) { | 2768 | if (!anEvent) { |
2763 | KNotifyClient::beep(); | 2769 | KNotifyClient::beep(); |
2764 | return; | 2770 | return; |
2765 | } | 2771 | } |
2766 | 2772 | ||
2767 | deleteEvent(anEvent); | 2773 | deleteEvent(anEvent); |
2768 | } | 2774 | } |
2769 | 2775 | ||
2770 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2776 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2771 | { | 2777 | { |
2772 | if (!sub) return; | 2778 | if (!sub) return; |
2773 | if (!parent) return; | 2779 | if (!parent) return; |
2774 | if ( sub->relatedTo() ) | 2780 | if ( sub->relatedTo() ) |
2775 | sub->relatedTo()->removeRelation(sub); | 2781 | sub->relatedTo()->removeRelation(sub); |
2776 | sub->setRelatedTo(parent); | 2782 | sub->setRelatedTo(parent); |
2777 | sub->setRelatedToUid(parent->uid()); | 2783 | sub->setRelatedToUid(parent->uid()); |
2778 | parent->addRelation(sub); | 2784 | parent->addRelation(sub); |
2779 | sub->updated(); | 2785 | sub->updated(); |
2780 | parent->updated(); | 2786 | parent->updated(); |
2781 | setModified(true); | 2787 | setModified(true); |
2782 | updateView(); | 2788 | updateView(); |
2783 | } | 2789 | } |
2784 | void CalendarView::todo_unsub(Todo *anTodo ) | 2790 | void CalendarView::todo_unsub(Todo *anTodo ) |
2785 | { | 2791 | { |
2786 | // Todo *anTodo = selectedTodo(); | 2792 | // Todo *anTodo = selectedTodo(); |
2787 | if (!anTodo) return; | 2793 | if (!anTodo) return; |
2788 | if (!anTodo->relatedTo()) return; | 2794 | if (!anTodo->relatedTo()) return; |
2789 | anTodo->relatedTo()->removeRelation(anTodo); | 2795 | anTodo->relatedTo()->removeRelation(anTodo); |
2790 | anTodo->setRelatedTo(0); | 2796 | anTodo->setRelatedTo(0); |
2791 | anTodo->updated(); | 2797 | anTodo->updated(); |
2792 | anTodo->setRelatedToUid(""); | 2798 | anTodo->setRelatedToUid(""); |
2793 | setModified(true); | 2799 | setModified(true); |
2794 | updateView(); | 2800 | updateView(); |
2795 | } | 2801 | } |
2796 | 2802 | ||
2797 | void CalendarView::deleteTodo(Todo *todo) | 2803 | void CalendarView::deleteTodo(Todo *todo) |
2798 | { | 2804 | { |
2799 | if (!todo) { | 2805 | if (!todo) { |
2800 | KNotifyClient::beep(); | 2806 | KNotifyClient::beep(); |
2801 | return; | 2807 | return; |
2802 | } | 2808 | } |
2803 | if (KOPrefs::instance()->mConfirm) { | 2809 | if (KOPrefs::instance()->mConfirm) { |
2804 | switch (msgItemDelete()) { | 2810 | switch (msgItemDelete()) { |
2805 | case KMessageBox::Continue: // OK | 2811 | case KMessageBox::Continue: // OK |
2806 | if (!todo->relations().isEmpty()) { | 2812 | if (!todo->relations().isEmpty()) { |
2807 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2813 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2808 | i18n("Delete To-Do")); | 2814 | i18n("Delete To-Do")); |
2809 | } else { | 2815 | } else { |
2810 | checkExternalId( todo ); | 2816 | checkExternalId( todo ); |
2811 | calendar()->deleteTodo(todo); | 2817 | calendar()->deleteTodo(todo); |
2812 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2818 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2813 | updateView(); | 2819 | updateView(); |
2814 | } | 2820 | } |
2815 | break; | 2821 | break; |
2816 | } // switch | 2822 | } // switch |
2817 | } else { | 2823 | } else { |
2818 | if (!todo->relations().isEmpty()) { | 2824 | if (!todo->relations().isEmpty()) { |
2819 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2825 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2820 | i18n("Delete To-Do")); | 2826 | i18n("Delete To-Do")); |
2821 | } else { | 2827 | } else { |
2822 | checkExternalId( todo ); | 2828 | checkExternalId( todo ); |
2823 | mCalendar->deleteTodo(todo); | 2829 | mCalendar->deleteTodo(todo); |
2824 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2830 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2825 | updateView(); | 2831 | updateView(); |
2826 | } | 2832 | } |
2827 | } | 2833 | } |
2828 | emit updateSearchDialog(); | 2834 | emit updateSearchDialog(); |
2829 | } | 2835 | } |
2830 | void CalendarView::deleteJournal(Journal *jour) | 2836 | void CalendarView::deleteJournal(Journal *jour) |
2831 | { | 2837 | { |
2832 | if (!jour) { | 2838 | if (!jour) { |
2833 | KNotifyClient::beep(); | 2839 | KNotifyClient::beep(); |
2834 | return; | 2840 | return; |
2835 | } | 2841 | } |
2836 | if (KOPrefs::instance()->mConfirm) { | 2842 | if (KOPrefs::instance()->mConfirm) { |
2837 | switch (msgItemDelete()) { | 2843 | switch (msgItemDelete()) { |
2838 | case KMessageBox::Continue: // OK | 2844 | case KMessageBox::Continue: // OK |
2839 | calendar()->deleteJournal(jour); | 2845 | calendar()->deleteJournal(jour); |
2840 | updateView(); | 2846 | updateView(); |
2841 | break; | 2847 | break; |
2842 | } // switch | 2848 | } // switch |
2843 | } else { | 2849 | } else { |
2844 | calendar()->deleteJournal(jour);; | 2850 | calendar()->deleteJournal(jour);; |
2845 | updateView(); | 2851 | updateView(); |
2846 | } | 2852 | } |
2847 | emit updateSearchDialog(); | 2853 | emit updateSearchDialog(); |
2848 | } | 2854 | } |
2849 | 2855 | ||
2850 | void CalendarView::deleteEvent(Event *anEvent) | 2856 | void CalendarView::deleteEvent(Event *anEvent) |
2851 | { | 2857 | { |
2852 | if (!anEvent) { | 2858 | if (!anEvent) { |
2853 | KNotifyClient::beep(); | 2859 | KNotifyClient::beep(); |
2854 | return; | 2860 | return; |
2855 | } | 2861 | } |
2856 | 2862 | ||
2857 | if (anEvent->recurrence()->doesRecur()) { | 2863 | if (anEvent->recurrence()->doesRecur()) { |
2858 | QDate itemDate = mViewManager->currentSelectionDate(); | 2864 | QDate itemDate = mViewManager->currentSelectionDate(); |
2859 | int km; | 2865 | int km; |
2860 | if (!itemDate.isValid()) { | 2866 | if (!itemDate.isValid()) { |
2861 | //kdDebug() << "Date Not Valid" << endl; | 2867 | //kdDebug() << "Date Not Valid" << endl; |
2862 | if (KOPrefs::instance()->mConfirm) { | 2868 | if (KOPrefs::instance()->mConfirm) { |
2863 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2869 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2864 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2870 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2865 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2871 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2866 | if ( km == KMessageBox::Continue ) | 2872 | if ( km == KMessageBox::Continue ) |
2867 | km = KMessageBox::No; // No = all below | 2873 | km = KMessageBox::No; // No = all below |
2868 | } else | 2874 | } else |
2869 | km = KMessageBox::No; | 2875 | km = KMessageBox::No; |
2870 | } else { | 2876 | } else { |
2871 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2877 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2872 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2878 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2873 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2879 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2874 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2880 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2875 | i18n("All")); | 2881 | i18n("All")); |
2876 | } | 2882 | } |
2877 | switch(km) { | 2883 | switch(km) { |
2878 | 2884 | ||
2879 | case KMessageBox::No: // Continue // all | 2885 | case KMessageBox::No: // Continue // all |
2880 | //qDebug("KMessageBox::No "); | 2886 | //qDebug("KMessageBox::No "); |
2881 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2887 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2882 | schedule(Scheduler::Cancel,anEvent); | 2888 | schedule(Scheduler::Cancel,anEvent); |
2883 | 2889 | ||
2884 | checkExternalId( anEvent); | 2890 | checkExternalId( anEvent); |
2885 | mCalendar->deleteEvent(anEvent); | 2891 | mCalendar->deleteEvent(anEvent); |
2886 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2892 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2887 | break; | 2893 | break; |
2888 | 2894 | ||
2889 | // Disabled because it does not work | 2895 | // Disabled because it does not work |
2890 | //#if 0 | 2896 | //#if 0 |
2891 | case KMessageBox::Yes: // just this one | 2897 | case KMessageBox::Yes: // just this one |
2892 | //QDate qd = mNavigator->selectedDates().first(); | 2898 | //QDate qd = mNavigator->selectedDates().first(); |
2893 | //if (!qd.isValid()) { | 2899 | //if (!qd.isValid()) { |
2894 | // kdDebug() << "no date selected, or invalid date" << endl; | 2900 | // kdDebug() << "no date selected, or invalid date" << endl; |
2895 | // KNotifyClient::beep(); | 2901 | // KNotifyClient::beep(); |
2896 | // return; | 2902 | // return; |
2897 | //} | 2903 | //} |
2898 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2904 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2899 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2905 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2900 | anEvent->addExDate(itemDate); | 2906 | anEvent->addExDate(itemDate); |
2901 | int duration = anEvent->recurrence()->duration(); | 2907 | int duration = anEvent->recurrence()->duration(); |
2902 | if ( duration > 0 ) { | 2908 | if ( duration > 0 ) { |
2903 | anEvent->recurrence()->setDuration( duration - 1 ); | 2909 | anEvent->recurrence()->setDuration( duration - 1 ); |
2904 | } | 2910 | } |
2905 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2911 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2906 | } | 2912 | } |
2907 | break; | 2913 | break; |
2908 | //#endif | 2914 | //#endif |
2909 | } // switch | 2915 | } // switch |
2910 | } else { | 2916 | } else { |
2911 | if (KOPrefs::instance()->mConfirm) { | 2917 | if (KOPrefs::instance()->mConfirm) { |
2912 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2918 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2913 | i18n("\nAre you sure you want\nto delete this event?"), | 2919 | i18n("\nAre you sure you want\nto delete this event?"), |
2914 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2920 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2915 | case KMessageBox::Continue: // OK | 2921 | case KMessageBox::Continue: // OK |
2916 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2922 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2917 | schedule(Scheduler::Cancel,anEvent); | 2923 | schedule(Scheduler::Cancel,anEvent); |
2918 | checkExternalId( anEvent); | 2924 | checkExternalId( anEvent); |
2919 | mCalendar->deleteEvent(anEvent); | 2925 | mCalendar->deleteEvent(anEvent); |
2920 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2926 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2921 | break; | 2927 | break; |
2922 | } // switch | 2928 | } // switch |
2923 | } else { | 2929 | } else { |
2924 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2930 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2925 | schedule(Scheduler::Cancel,anEvent); | 2931 | schedule(Scheduler::Cancel,anEvent); |
2926 | checkExternalId( anEvent); | 2932 | checkExternalId( anEvent); |
2927 | mCalendar->deleteEvent(anEvent); | 2933 | mCalendar->deleteEvent(anEvent); |
2928 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2934 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2929 | } | 2935 | } |
2930 | } // if-else | 2936 | } // if-else |
2931 | emit updateSearchDialog(); | 2937 | emit updateSearchDialog(); |
2932 | } | 2938 | } |
2933 | 2939 | ||
2934 | bool CalendarView::deleteEvent(const QString &uid) | 2940 | bool CalendarView::deleteEvent(const QString &uid) |
2935 | { | 2941 | { |
2936 | Event *ev = mCalendar->event(uid); | 2942 | Event *ev = mCalendar->event(uid); |
2937 | if (ev) { | 2943 | if (ev) { |
2938 | deleteEvent(ev); | 2944 | deleteEvent(ev); |
2939 | return true; | 2945 | return true; |
2940 | } else { | 2946 | } else { |
2941 | return false; | 2947 | return false; |
2942 | } | 2948 | } |
2943 | } | 2949 | } |
2944 | 2950 | ||
2945 | /*****************************************************************************/ | 2951 | /*****************************************************************************/ |
2946 | 2952 | ||
2947 | void CalendarView::action_mail() | 2953 | void CalendarView::action_mail() |
2948 | { | 2954 | { |
2949 | #ifndef KORG_NOMAIL | 2955 | #ifndef KORG_NOMAIL |
2950 | KOMailClient mailClient; | 2956 | KOMailClient mailClient; |
2951 | 2957 | ||
2952 | Incidence *incidence = currentSelection(); | 2958 | Incidence *incidence = currentSelection(); |
2953 | 2959 | ||
2954 | if (!incidence) { | 2960 | if (!incidence) { |
2955 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2961 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2956 | return; | 2962 | return; |
2957 | } | 2963 | } |
2958 | if(incidence->attendeeCount() == 0 ) { | 2964 | if(incidence->attendeeCount() == 0 ) { |
2959 | KMessageBox::sorry(this, | 2965 | KMessageBox::sorry(this, |
2960 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2966 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2961 | return; | 2967 | return; |
2962 | } | 2968 | } |
2963 | 2969 | ||
2964 | CalendarLocal cal_tmp; | 2970 | CalendarLocal cal_tmp; |
2965 | Event *event = 0; | 2971 | Event *event = 0; |
2966 | Event *ev = 0; | 2972 | Event *ev = 0; |
2967 | if ( incidence && incidence->type() == "Event" ) { | 2973 | if ( incidence && incidence->type() == "Event" ) { |
2968 | event = static_cast<Event *>(incidence); | 2974 | event = static_cast<Event *>(incidence); |
2969 | ev = new Event(*event); | 2975 | ev = new Event(*event); |
2970 | cal_tmp.addEvent(ev); | 2976 | cal_tmp.addEvent(ev); |
2971 | } | 2977 | } |
2972 | ICalFormat mForm(); | 2978 | ICalFormat mForm(); |
2973 | QString attachment = mForm.toString( &cal_tmp ); | 2979 | QString attachment = mForm.toString( &cal_tmp ); |
2974 | if (ev) delete(ev); | 2980 | if (ev) delete(ev); |
2975 | 2981 | ||
2976 | mailClient.mailAttendees(currentSelection(), attachment); | 2982 | mailClient.mailAttendees(currentSelection(), attachment); |
2977 | 2983 | ||
2978 | #endif | 2984 | #endif |
2979 | 2985 | ||
2980 | #if 0 | 2986 | #if 0 |
2981 | Event *anEvent = 0; | 2987 | Event *anEvent = 0; |
2982 | if (mViewManager->currentView()->isEventView()) { | 2988 | if (mViewManager->currentView()->isEventView()) { |
2983 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2989 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2984 | } | 2990 | } |
2985 | 2991 | ||
2986 | if (!anEvent) { | 2992 | if (!anEvent) { |
2987 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2993 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2988 | return; | 2994 | return; |
2989 | } | 2995 | } |
2990 | if(anEvent->attendeeCount() == 0 ) { | 2996 | if(anEvent->attendeeCount() == 0 ) { |
2991 | KMessageBox::sorry(this, | 2997 | KMessageBox::sorry(this, |
2992 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2998 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2993 | return; | 2999 | return; |
2994 | } | 3000 | } |
2995 | 3001 | ||
2996 | mailobject.emailEvent(anEvent); | 3002 | mailobject.emailEvent(anEvent); |
2997 | #endif | 3003 | #endif |
2998 | } | 3004 | } |
2999 | 3005 | ||
3000 | 3006 | ||
3001 | void CalendarView::schedule_publish(Incidence *incidence) | 3007 | void CalendarView::schedule_publish(Incidence *incidence) |
3002 | { | 3008 | { |
3003 | Event *event = 0; | 3009 | Event *event = 0; |
3004 | Todo *todo = 0; | 3010 | Todo *todo = 0; |
3005 | 3011 | ||
3006 | if (incidence == 0) { | 3012 | if (incidence == 0) { |
3007 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3013 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3008 | if (incidence == 0) { | 3014 | if (incidence == 0) { |
3009 | incidence = mTodoList->selectedIncidences().first(); | 3015 | incidence = mTodoList->selectedIncidences().first(); |
3010 | } | 3016 | } |
3011 | } | 3017 | } |
3012 | if ( incidence && incidence->type() == "Event" ) { | 3018 | if ( incidence && incidence->type() == "Event" ) { |
3013 | event = static_cast<Event *>(incidence); | 3019 | event = static_cast<Event *>(incidence); |
3014 | } else { | 3020 | } else { |
3015 | if ( incidence && incidence->type() == "Todo" ) { | 3021 | if ( incidence && incidence->type() == "Todo" ) { |
3016 | todo = static_cast<Todo *>(incidence); | 3022 | todo = static_cast<Todo *>(incidence); |
3017 | } | 3023 | } |
3018 | } | 3024 | } |
3019 | 3025 | ||
3020 | if (!event && !todo) { | 3026 | if (!event && !todo) { |
3021 | KMessageBox::sorry(this,i18n("No event selected.")); | 3027 | KMessageBox::sorry(this,i18n("No event selected.")); |
3022 | return; | 3028 | return; |
3023 | } | 3029 | } |
3024 | 3030 | ||
3025 | PublishDialog *publishdlg = new PublishDialog(); | 3031 | PublishDialog *publishdlg = new PublishDialog(); |
3026 | if (incidence->attendeeCount()>0) { | 3032 | if (incidence->attendeeCount()>0) { |
3027 | QPtrList<Attendee> attendees = incidence->attendees(); | 3033 | QPtrList<Attendee> attendees = incidence->attendees(); |
3028 | attendees.first(); | 3034 | attendees.first(); |
3029 | while ( attendees.current()!=0 ) { | 3035 | while ( attendees.current()!=0 ) { |
3030 | publishdlg->addAttendee(attendees.current()); | 3036 | publishdlg->addAttendee(attendees.current()); |
3031 | attendees.next(); | 3037 | attendees.next(); |
3032 | } | 3038 | } |
3033 | } | 3039 | } |
3034 | bool send = true; | 3040 | bool send = true; |
3035 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3041 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3036 | if ( publishdlg->exec() != QDialog::Accepted ) | 3042 | if ( publishdlg->exec() != QDialog::Accepted ) |
3037 | send = false; | 3043 | send = false; |
3038 | } | 3044 | } |
3039 | if ( send ) { | 3045 | if ( send ) { |
3040 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3046 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3041 | if ( event ) { | 3047 | if ( event ) { |
3042 | Event *ev = new Event(*event); | 3048 | Event *ev = new Event(*event); |
3043 | ev->registerObserver(0); | 3049 | ev->registerObserver(0); |
3044 | ev->clearAttendees(); | 3050 | ev->clearAttendees(); |
3045 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3051 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3046 | delete(ev); | 3052 | delete(ev); |
3047 | } | 3053 | } |
3048 | } else { | 3054 | } else { |
3049 | if ( todo ) { | 3055 | if ( todo ) { |
3050 | Todo *ev = new Todo(*todo); | 3056 | Todo *ev = new Todo(*todo); |
3051 | ev->registerObserver(0); | 3057 | ev->registerObserver(0); |
3052 | ev->clearAttendees(); | 3058 | ev->clearAttendees(); |
3053 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3059 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3054 | delete(ev); | 3060 | delete(ev); |
3055 | } | 3061 | } |
3056 | } | 3062 | } |
3057 | } | 3063 | } |
3058 | } | 3064 | } |
3059 | delete publishdlg; | 3065 | delete publishdlg; |
3060 | } | 3066 | } |
3061 | 3067 | ||
3062 | void CalendarView::schedule_request(Incidence *incidence) | 3068 | void CalendarView::schedule_request(Incidence *incidence) |
3063 | { | 3069 | { |
3064 | schedule(Scheduler::Request,incidence); | 3070 | schedule(Scheduler::Request,incidence); |
3065 | } | 3071 | } |
3066 | 3072 | ||
3067 | void CalendarView::schedule_refresh(Incidence *incidence) | 3073 | void CalendarView::schedule_refresh(Incidence *incidence) |
3068 | { | 3074 | { |
3069 | schedule(Scheduler::Refresh,incidence); | 3075 | schedule(Scheduler::Refresh,incidence); |
3070 | } | 3076 | } |
3071 | 3077 | ||
3072 | void CalendarView::schedule_cancel(Incidence *incidence) | 3078 | void CalendarView::schedule_cancel(Incidence *incidence) |
3073 | { | 3079 | { |
3074 | schedule(Scheduler::Cancel,incidence); | 3080 | schedule(Scheduler::Cancel,incidence); |
3075 | } | 3081 | } |
3076 | 3082 | ||
3077 | void CalendarView::schedule_add(Incidence *incidence) | 3083 | void CalendarView::schedule_add(Incidence *incidence) |
3078 | { | 3084 | { |
3079 | schedule(Scheduler::Add,incidence); | 3085 | schedule(Scheduler::Add,incidence); |
3080 | } | 3086 | } |
3081 | 3087 | ||
3082 | void CalendarView::schedule_reply(Incidence *incidence) | 3088 | void CalendarView::schedule_reply(Incidence *incidence) |
3083 | { | 3089 | { |
3084 | schedule(Scheduler::Reply,incidence); | 3090 | schedule(Scheduler::Reply,incidence); |
3085 | } | 3091 | } |
3086 | 3092 | ||
3087 | void CalendarView::schedule_counter(Incidence *incidence) | 3093 | void CalendarView::schedule_counter(Incidence *incidence) |
3088 | { | 3094 | { |
3089 | schedule(Scheduler::Counter,incidence); | 3095 | schedule(Scheduler::Counter,incidence); |
3090 | } | 3096 | } |
3091 | 3097 | ||
3092 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3098 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3093 | { | 3099 | { |
3094 | schedule(Scheduler::Declinecounter,incidence); | 3100 | schedule(Scheduler::Declinecounter,incidence); |
3095 | } | 3101 | } |
3096 | 3102 | ||
3097 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3103 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3098 | { | 3104 | { |
3099 | QDateTime start = QDateTime::currentDateTime(); | 3105 | QDateTime start = QDateTime::currentDateTime(); |
3100 | QDateTime end = start.addDays(daysToPublish); | 3106 | QDateTime end = start.addDays(daysToPublish); |
3101 | 3107 | ||
3102 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3108 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3103 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3109 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3104 | 3110 | ||
3105 | 3111 | ||
3106 | PublishDialog *publishdlg = new PublishDialog(); | 3112 | PublishDialog *publishdlg = new PublishDialog(); |
3107 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3113 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3108 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3114 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3109 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3115 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3110 | delete(freebusy); | 3116 | delete(freebusy); |
3111 | } | 3117 | } |
3112 | } | 3118 | } |
3113 | delete publishdlg; | 3119 | delete publishdlg; |
3114 | } | 3120 | } |
3115 | 3121 | ||
3116 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3122 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3117 | { | 3123 | { |
3118 | Event *event = 0; | 3124 | Event *event = 0; |
3119 | Todo *todo = 0; | 3125 | Todo *todo = 0; |
3120 | 3126 | ||
3121 | if (incidence == 0) { | 3127 | if (incidence == 0) { |
3122 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3128 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3123 | if (incidence == 0) { | 3129 | if (incidence == 0) { |
3124 | incidence = mTodoList->selectedIncidences().first(); | 3130 | incidence = mTodoList->selectedIncidences().first(); |
3125 | } | 3131 | } |
3126 | } | 3132 | } |
3127 | if ( incidence && incidence->type() == "Event" ) { | 3133 | if ( incidence && incidence->type() == "Event" ) { |
3128 | event = static_cast<Event *>(incidence); | 3134 | event = static_cast<Event *>(incidence); |
3129 | } | 3135 | } |
3130 | if ( incidence && incidence->type() == "Todo" ) { | 3136 | if ( incidence && incidence->type() == "Todo" ) { |
3131 | todo = static_cast<Todo *>(incidence); | 3137 | todo = static_cast<Todo *>(incidence); |
3132 | } | 3138 | } |
3133 | 3139 | ||
3134 | if (!event && !todo) { | 3140 | if (!event && !todo) { |
3135 | KMessageBox::sorry(this,i18n("No event selected.")); | 3141 | KMessageBox::sorry(this,i18n("No event selected.")); |
3136 | return; | 3142 | return; |
3137 | } | 3143 | } |
3138 | 3144 | ||
3139 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3145 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3140 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3146 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3141 | return; | 3147 | return; |
3142 | } | 3148 | } |
3143 | 3149 | ||
3144 | Event *ev = 0; | 3150 | Event *ev = 0; |
3145 | if (event) ev = new Event(*event); | 3151 | if (event) ev = new Event(*event); |
3146 | Todo *to = 0; | 3152 | Todo *to = 0; |
3147 | if (todo) to = new Todo(*todo); | 3153 | if (todo) to = new Todo(*todo); |
3148 | 3154 | ||
3149 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3155 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3150 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3156 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3151 | if (!me) { | 3157 | if (!me) { |
3152 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3158 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3153 | return; | 3159 | return; |
3154 | } | 3160 | } |
3155 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3161 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3156 | StatusDialog *statdlg = new StatusDialog(this); | 3162 | StatusDialog *statdlg = new StatusDialog(this); |
3157 | if (!statdlg->exec()==QDialog::Accepted) return; | 3163 | if (!statdlg->exec()==QDialog::Accepted) return; |
3158 | me->setStatus( statdlg->status() ); | 3164 | me->setStatus( statdlg->status() ); |
3159 | delete(statdlg); | 3165 | delete(statdlg); |
3160 | } | 3166 | } |
3161 | Attendee *menew = new Attendee(*me); | 3167 | Attendee *menew = new Attendee(*me); |
3162 | if (ev) { | 3168 | if (ev) { |
3163 | ev->clearAttendees(); | 3169 | ev->clearAttendees(); |
3164 | ev->addAttendee(menew,false); | 3170 | ev->addAttendee(menew,false); |
3165 | } else { | 3171 | } else { |
3166 | if (to) { | 3172 | if (to) { |
3167 | todo->clearAttendees(); | 3173 | todo->clearAttendees(); |
3168 | todo->addAttendee(menew,false); | 3174 | todo->addAttendee(menew,false); |
3169 | } | 3175 | } |
3170 | } | 3176 | } |
3171 | } | 3177 | } |
3172 | 3178 | ||
3173 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3179 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3174 | if (ev) { | 3180 | if (ev) { |
3175 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3181 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3176 | } else { | 3182 | } else { |
3177 | if (to) { | 3183 | if (to) { |
3178 | if ( !dlg->addMessage(to,method) ) delete(to); | 3184 | if ( !dlg->addMessage(to,method) ) delete(to); |
3179 | } | 3185 | } |
3180 | } | 3186 | } |
3181 | } | 3187 | } |
3182 | 3188 | ||
3183 | void CalendarView::openAddressbook() | 3189 | void CalendarView::openAddressbook() |
3184 | { | 3190 | { |
3185 | KRun::runCommand("kaddressbook"); | 3191 | KRun::runCommand("kaddressbook"); |
3186 | } | 3192 | } |
3187 | 3193 | ||
3188 | void CalendarView::setModified(bool modified) | 3194 | void CalendarView::setModified(bool modified) |
3189 | { | 3195 | { |
3190 | if ( modified ) | 3196 | if ( modified ) |
3191 | emit signalmodified(); | 3197 | emit signalmodified(); |
3192 | if (mModified != modified) { | 3198 | if (mModified != modified) { |
3193 | mModified = modified; | 3199 | mModified = modified; |
3194 | emit modifiedChanged(mModified); | 3200 | emit modifiedChanged(mModified); |
3195 | } | 3201 | } |
3196 | } | 3202 | } |
3197 | 3203 | ||
3198 | bool CalendarView::isReadOnly() | 3204 | bool CalendarView::isReadOnly() |
3199 | { | 3205 | { |
3200 | return mReadOnly; | 3206 | return mReadOnly; |
3201 | } | 3207 | } |
3202 | 3208 | ||
3203 | void CalendarView::setReadOnly(bool readOnly) | 3209 | void CalendarView::setReadOnly(bool readOnly) |
3204 | { | 3210 | { |
3205 | if (mReadOnly != readOnly) { | 3211 | if (mReadOnly != readOnly) { |
3206 | mReadOnly = readOnly; | 3212 | mReadOnly = readOnly; |
3207 | emit readOnlyChanged(mReadOnly); | 3213 | emit readOnlyChanged(mReadOnly); |
3208 | } | 3214 | } |
3209 | } | 3215 | } |
3210 | 3216 | ||
3211 | bool CalendarView::isModified() | 3217 | bool CalendarView::isModified() |
3212 | { | 3218 | { |
3213 | return mModified; | 3219 | return mModified; |
3214 | } | 3220 | } |
3215 | 3221 | ||
3216 | void CalendarView::printSetup() | 3222 | void CalendarView::printSetup() |
3217 | { | 3223 | { |
3218 | #ifndef KORG_NOPRINTER | 3224 | #ifndef KORG_NOPRINTER |
3219 | createPrinter(); | 3225 | createPrinter(); |
3220 | 3226 | ||
3221 | mCalPrinter->setupPrinter(); | 3227 | mCalPrinter->setupPrinter(); |
3222 | #endif | 3228 | #endif |
3223 | } | 3229 | } |
3224 | 3230 | ||
3225 | void CalendarView::print() | 3231 | void CalendarView::print() |
3226 | { | 3232 | { |
3227 | #ifndef KORG_NOPRINTER | 3233 | #ifndef KORG_NOPRINTER |
3228 | createPrinter(); | 3234 | createPrinter(); |
3229 | 3235 | ||
3230 | DateList tmpDateList = mNavigator->selectedDates(); | 3236 | DateList tmpDateList = mNavigator->selectedDates(); |
3231 | mCalPrinter->print(CalPrinter::Month, | 3237 | mCalPrinter->print(CalPrinter::Month, |
3232 | tmpDateList.first(), tmpDateList.last()); | 3238 | tmpDateList.first(), tmpDateList.last()); |
3233 | #endif | 3239 | #endif |
3234 | } | 3240 | } |
3235 | 3241 | ||
3236 | void CalendarView::printPreview() | 3242 | void CalendarView::printPreview() |
3237 | { | 3243 | { |
3238 | #ifndef KORG_NOPRINTER | 3244 | #ifndef KORG_NOPRINTER |
3239 | kdDebug() << "CalendarView::printPreview()" << endl; | 3245 | kdDebug() << "CalendarView::printPreview()" << endl; |
3240 | 3246 | ||
3241 | createPrinter(); | 3247 | createPrinter(); |
3242 | 3248 | ||
3243 | DateList tmpDateList = mNavigator->selectedDates(); | 3249 | DateList tmpDateList = mNavigator->selectedDates(); |
3244 | 3250 | ||
3245 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3251 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3246 | tmpDateList.last()); | 3252 | tmpDateList.last()); |
3247 | #endif | 3253 | #endif |
3248 | } | 3254 | } |
3249 | 3255 | ||
3250 | void CalendarView::exportICalendar() | 3256 | void CalendarView::exportICalendar() |
3251 | { | 3257 | { |
3252 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3258 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3253 | 3259 | ||
3254 | // Force correct extension | 3260 | // Force correct extension |
3255 | if (filename.right(4) != ".ics") filename += ".ics"; | 3261 | if (filename.right(4) != ".ics") filename += ".ics"; |
3256 | 3262 | ||
3257 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3263 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3258 | storage.save(); | 3264 | storage.save(); |
3259 | } | 3265 | } |
3260 | 3266 | ||
3261 | bool CalendarView::exportVCalendar( QString filename ) | 3267 | bool CalendarView::exportVCalendar( QString filename ) |
3262 | { | 3268 | { |
3263 | if (mCalendar->journals().count() > 0) { | 3269 | if (mCalendar->journals().count() > 0) { |
3264 | int result = KMessageBox::warningContinueCancel(this, | 3270 | int result = KMessageBox::warningContinueCancel(this, |
3265 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3271 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3266 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3272 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3267 | true); | 3273 | true); |
3268 | if (result != KMessageBox::Continue) return false; | 3274 | if (result != KMessageBox::Continue) return false; |
3269 | } | 3275 | } |
3270 | 3276 | ||
3271 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3277 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3272 | 3278 | ||
3273 | // Force correct extension | 3279 | // Force correct extension |
3274 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3280 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3275 | 3281 | ||
3276 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3282 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3277 | return storage.save(); | 3283 | return storage.save(); |
3278 | 3284 | ||
3279 | } | 3285 | } |
3280 | 3286 | ||
3281 | void CalendarView::eventUpdated(Incidence *) | 3287 | void CalendarView::eventUpdated(Incidence *) |
3282 | { | 3288 | { |
3283 | setModified(); | 3289 | setModified(); |
3284 | // Don't call updateView here. The code, which has caused the update of the | 3290 | // Don't call updateView here. The code, which has caused the update of the |
3285 | // event is responsible for updating the view. | 3291 | // event is responsible for updating the view. |
3286 | // updateView(); | 3292 | // updateView(); |
3287 | } | 3293 | } |
3288 | 3294 | ||
3289 | void CalendarView::adaptNavigationUnits() | 3295 | void CalendarView::adaptNavigationUnits() |
3290 | { | 3296 | { |
3291 | if (mViewManager->currentView()->isEventView()) { | 3297 | if (mViewManager->currentView()->isEventView()) { |
3292 | int days = mViewManager->currentView()->currentDateCount(); | 3298 | int days = mViewManager->currentView()->currentDateCount(); |
3293 | if (days == 1) { | 3299 | if (days == 1) { |
3294 | emit changeNavStringPrev(i18n("&Previous Day")); | 3300 | emit changeNavStringPrev(i18n("&Previous Day")); |
3295 | emit changeNavStringNext(i18n("&Next Day")); | 3301 | emit changeNavStringNext(i18n("&Next Day")); |
3296 | } else { | 3302 | } else { |
3297 | emit changeNavStringPrev(i18n("&Previous Week")); | 3303 | emit changeNavStringPrev(i18n("&Previous Week")); |
3298 | emit changeNavStringNext(i18n("&Next Week")); | 3304 | emit changeNavStringNext(i18n("&Next Week")); |
3299 | } | 3305 | } |
3300 | } | 3306 | } |
3301 | } | 3307 | } |
3302 | 3308 | ||
3303 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3309 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3304 | { | 3310 | { |
3305 | if ( incidence ) mTodoList->clearSelection(); | 3311 | if ( incidence ) mTodoList->clearSelection(); |
3306 | processIncidenceSelection( incidence ); | 3312 | processIncidenceSelection( incidence ); |
3307 | } | 3313 | } |
3308 | 3314 | ||
3309 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3315 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3310 | { | 3316 | { |
3311 | if ( incidence && mViewManager->currentView() ) { | 3317 | if ( incidence && mViewManager->currentView() ) { |
3312 | mViewManager->currentView()->clearSelection(); | 3318 | mViewManager->currentView()->clearSelection(); |
3313 | } | 3319 | } |
3314 | processIncidenceSelection( incidence ); | 3320 | processIncidenceSelection( incidence ); |
3315 | } | 3321 | } |
3316 | 3322 | ||
3317 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3323 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3318 | { | 3324 | { |
3319 | if ( incidence == mSelectedIncidence ) return; | 3325 | if ( incidence == mSelectedIncidence ) return; |
3320 | 3326 | ||
3321 | mSelectedIncidence = incidence; | 3327 | mSelectedIncidence = incidence; |
3322 | 3328 | ||
3323 | emit incidenceSelected( mSelectedIncidence ); | 3329 | emit incidenceSelected( mSelectedIncidence ); |
3324 | 3330 | ||
3325 | if ( incidence && incidence->type() == "Event" ) { | 3331 | if ( incidence && incidence->type() == "Event" ) { |
3326 | Event *event = static_cast<Event *>( incidence ); | 3332 | Event *event = static_cast<Event *>( incidence ); |
3327 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3333 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3328 | emit organizerEventsSelected( true ); | 3334 | emit organizerEventsSelected( true ); |
3329 | } else { | 3335 | } else { |
3330 | emit organizerEventsSelected(false); | 3336 | emit organizerEventsSelected(false); |
3331 | } | 3337 | } |
3332 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3338 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3333 | KOPrefs::instance()->email() ) ) { | 3339 | KOPrefs::instance()->email() ) ) { |
3334 | emit groupEventsSelected( true ); | 3340 | emit groupEventsSelected( true ); |
3335 | } else { | 3341 | } else { |
3336 | emit groupEventsSelected(false); | 3342 | emit groupEventsSelected(false); |
3337 | } | 3343 | } |
3338 | return; | 3344 | return; |
3339 | } else { | 3345 | } else { |
3340 | if ( incidence && incidence->type() == "Todo" ) { | 3346 | if ( incidence && incidence->type() == "Todo" ) { |
3341 | emit todoSelected( true ); | 3347 | emit todoSelected( true ); |
3342 | Todo *event = static_cast<Todo *>( incidence ); | 3348 | Todo *event = static_cast<Todo *>( incidence ); |
3343 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3349 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3344 | emit organizerEventsSelected( true ); | 3350 | emit organizerEventsSelected( true ); |
3345 | } else { | 3351 | } else { |
3346 | emit organizerEventsSelected(false); | 3352 | emit organizerEventsSelected(false); |
3347 | } | 3353 | } |
3348 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3354 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3349 | KOPrefs::instance()->email() ) ) { | 3355 | KOPrefs::instance()->email() ) ) { |
3350 | emit groupEventsSelected( true ); | 3356 | emit groupEventsSelected( true ); |
3351 | } else { | 3357 | } else { |
3352 | emit groupEventsSelected(false); | 3358 | emit groupEventsSelected(false); |
3353 | } | 3359 | } |
3354 | return; | 3360 | return; |
3355 | } else { | 3361 | } else { |
3356 | emit todoSelected( false ); | 3362 | emit todoSelected( false ); |
3357 | emit organizerEventsSelected(false); | 3363 | emit organizerEventsSelected(false); |
3358 | emit groupEventsSelected(false); | 3364 | emit groupEventsSelected(false); |
3359 | } | 3365 | } |
3360 | return; | 3366 | return; |
3361 | } | 3367 | } |
3362 | 3368 | ||
3363 | /* if ( incidence && incidence->type() == "Todo" ) { | 3369 | /* if ( incidence && incidence->type() == "Todo" ) { |
3364 | emit todoSelected( true ); | 3370 | emit todoSelected( true ); |
3365 | } else { | 3371 | } else { |
3366 | emit todoSelected( false ); | 3372 | emit todoSelected( false ); |
3367 | }*/ | 3373 | }*/ |
3368 | } | 3374 | } |
3369 | 3375 | ||
3370 | 3376 | ||
3371 | void CalendarView::checkClipboard() | 3377 | void CalendarView::checkClipboard() |
3372 | { | 3378 | { |
3373 | #ifndef KORG_NODND | 3379 | #ifndef KORG_NODND |
3374 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3380 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3375 | emit pasteEnabled(true); | 3381 | emit pasteEnabled(true); |
3376 | } else { | 3382 | } else { |
3377 | emit pasteEnabled(false); | 3383 | emit pasteEnabled(false); |
3378 | } | 3384 | } |
3379 | #endif | 3385 | #endif |
3380 | } | 3386 | } |
3381 | 3387 | ||
3382 | void CalendarView::showDates(const DateList &selectedDates) | 3388 | void CalendarView::showDates(const DateList &selectedDates) |
3383 | { | 3389 | { |
3384 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3390 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3385 | 3391 | ||
3386 | if ( mViewManager->currentView() ) { | 3392 | if ( mViewManager->currentView() ) { |
3387 | updateView( selectedDates.first(), selectedDates.last() ); | 3393 | updateView( selectedDates.first(), selectedDates.last() ); |
3388 | } else { | 3394 | } else { |
3389 | mViewManager->showAgendaView(); | 3395 | mViewManager->showAgendaView(); |
3390 | } | 3396 | } |
3391 | 3397 | ||
3392 | QString selDates; | 3398 | QString selDates; |
3393 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3399 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3394 | if (selectedDates.first() < selectedDates.last() ) | 3400 | if (selectedDates.first() < selectedDates.last() ) |
3395 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3401 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3396 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3402 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3397 | 3403 | ||
3398 | } | 3404 | } |
3399 | 3405 | ||
3400 | QPtrList<CalFilter> CalendarView::filters() | 3406 | QPtrList<CalFilter> CalendarView::filters() |
3401 | { | 3407 | { |
3402 | return mFilters; | 3408 | return mFilters; |
3403 | 3409 | ||
3404 | } | 3410 | } |
3405 | void CalendarView::editFilters() | 3411 | void CalendarView::editFilters() |
3406 | { | 3412 | { |
3407 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3413 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3408 | 3414 | ||
3409 | CalFilter *filter = mFilters.first(); | 3415 | CalFilter *filter = mFilters.first(); |
3410 | while(filter) { | 3416 | while(filter) { |
3411 | kdDebug() << " Filter: " << filter->name() << endl; | 3417 | kdDebug() << " Filter: " << filter->name() << endl; |
3412 | filter = mFilters.next(); | 3418 | filter = mFilters.next(); |
3413 | } | 3419 | } |
3414 | 3420 | ||
3415 | mDialogManager->showFilterEditDialog(&mFilters); | 3421 | mDialogManager->showFilterEditDialog(&mFilters); |
3416 | } | 3422 | } |
3417 | void CalendarView::toggleFilter() | 3423 | void CalendarView::toggleFilter() |
3418 | { | 3424 | { |
3419 | showFilter(! mFilterView->isVisible()); | 3425 | showFilter(! mFilterView->isVisible()); |
3420 | } | 3426 | } |
3421 | 3427 | ||
3422 | KOFilterView *CalendarView::filterView() | 3428 | KOFilterView *CalendarView::filterView() |
3423 | { | 3429 | { |
3424 | return mFilterView; | 3430 | return mFilterView; |
3425 | } | 3431 | } |
3426 | void CalendarView::selectFilter( int fil ) | 3432 | void CalendarView::selectFilter( int fil ) |
3427 | { | 3433 | { |
3428 | mFilterView->setSelectedFilter( fil ); | 3434 | mFilterView->setSelectedFilter( fil ); |
3429 | } | 3435 | } |
3430 | void CalendarView::showFilter(bool visible) | 3436 | void CalendarView::showFilter(bool visible) |
3431 | { | 3437 | { |
3432 | if (visible) mFilterView->show(); | 3438 | if (visible) mFilterView->show(); |
3433 | else mFilterView->hide(); | 3439 | else mFilterView->hide(); |
3434 | } | 3440 | } |
3435 | void CalendarView::toggleFilerEnabled( ) | 3441 | void CalendarView::toggleFilerEnabled( ) |
3436 | { | 3442 | { |
3437 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3443 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3438 | if ( !mFilterView->filtersEnabled() ) | 3444 | if ( !mFilterView->filtersEnabled() ) |
3439 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3445 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3440 | 3446 | ||
3441 | } | 3447 | } |
3442 | void CalendarView::updateFilter() | 3448 | void CalendarView::updateFilter() |
3443 | { | 3449 | { |
3444 | CalFilter *filter = mFilterView->selectedFilter(); | 3450 | CalFilter *filter = mFilterView->selectedFilter(); |
3445 | if (filter) { | 3451 | if (filter) { |
3446 | if (mFilterView->filtersEnabled()) { | 3452 | if (mFilterView->filtersEnabled()) { |
3447 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3453 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3448 | filter->setEnabled(true); | 3454 | filter->setEnabled(true); |
3449 | } | 3455 | } |
3450 | else filter->setEnabled(false); | 3456 | else filter->setEnabled(false); |
3451 | mCalendar->setFilter(filter); | 3457 | mCalendar->setFilter(filter); |
3452 | updateView(); | 3458 | updateView(); |
3453 | } | 3459 | } |
3454 | } | 3460 | } |
3455 | 3461 | ||
3456 | void CalendarView::filterEdited() | 3462 | void CalendarView::filterEdited() |
3457 | { | 3463 | { |
3458 | mFilterView->updateFilters(); | 3464 | mFilterView->updateFilters(); |
3459 | updateFilter(); | 3465 | updateFilter(); |
3460 | writeSettings(); | 3466 | writeSettings(); |
3461 | } | 3467 | } |
3462 | 3468 | ||
3463 | 3469 | ||
3464 | void CalendarView::takeOverEvent() | 3470 | void CalendarView::takeOverEvent() |
3465 | { | 3471 | { |
3466 | Incidence *incidence = currentSelection(); | 3472 | Incidence *incidence = currentSelection(); |
3467 | 3473 | ||
3468 | if (!incidence) return; | 3474 | if (!incidence) return; |
3469 | 3475 | ||
3470 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3476 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3471 | incidence->recreate(); | 3477 | incidence->recreate(); |
3472 | incidence->setReadOnly(false); | 3478 | incidence->setReadOnly(false); |
3473 | 3479 | ||
3474 | updateView(); | 3480 | updateView(); |
3475 | } | 3481 | } |
3476 | 3482 | ||
3477 | void CalendarView::takeOverCalendar() | 3483 | void CalendarView::takeOverCalendar() |
3478 | { | 3484 | { |
3479 | // TODO: Create Calendar::allIncidences() function and use it here | 3485 | // TODO: Create Calendar::allIncidences() function and use it here |
3480 | 3486 | ||
3481 | QPtrList<Event> events = mCalendar->events(); | 3487 | QPtrList<Event> events = mCalendar->events(); |
3482 | for(uint i=0; i<events.count(); ++i) { | 3488 | for(uint i=0; i<events.count(); ++i) { |
3483 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3489 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3484 | events.at(i)->recreate(); | 3490 | events.at(i)->recreate(); |
3485 | events.at(i)->setReadOnly(false); | 3491 | events.at(i)->setReadOnly(false); |
3486 | } | 3492 | } |
3487 | 3493 | ||
3488 | QPtrList<Todo> todos = mCalendar->todos(); | 3494 | QPtrList<Todo> todos = mCalendar->todos(); |
3489 | for(uint i=0; i<todos.count(); ++i) { | 3495 | for(uint i=0; i<todos.count(); ++i) { |
3490 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3496 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3491 | todos.at(i)->recreate(); | 3497 | todos.at(i)->recreate(); |
3492 | todos.at(i)->setReadOnly(false); | 3498 | todos.at(i)->setReadOnly(false); |
3493 | } | 3499 | } |
3494 | 3500 | ||
3495 | QPtrList<Journal> journals = mCalendar->journals(); | 3501 | QPtrList<Journal> journals = mCalendar->journals(); |
3496 | for(uint i=0; i<journals.count(); ++i) { | 3502 | for(uint i=0; i<journals.count(); ++i) { |
3497 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3503 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3498 | journals.at(i)->recreate(); | 3504 | journals.at(i)->recreate(); |
3499 | journals.at(i)->setReadOnly(false); | 3505 | journals.at(i)->setReadOnly(false); |
3500 | } | 3506 | } |
3501 | 3507 | ||
3502 | updateView(); | 3508 | updateView(); |
3503 | } | 3509 | } |
3504 | 3510 | ||
3505 | void CalendarView::showIntro() | 3511 | void CalendarView::showIntro() |
3506 | { | 3512 | { |
3507 | kdDebug() << "To be implemented." << endl; | 3513 | kdDebug() << "To be implemented." << endl; |
3508 | } | 3514 | } |
3509 | 3515 | ||
3510 | QWidgetStack *CalendarView::viewStack() | 3516 | QWidgetStack *CalendarView::viewStack() |
3511 | { | 3517 | { |
3512 | return mRightFrame; | 3518 | return mRightFrame; |
3513 | } | 3519 | } |
3514 | 3520 | ||
3515 | QWidget *CalendarView::leftFrame() | 3521 | QWidget *CalendarView::leftFrame() |
3516 | { | 3522 | { |
3517 | return mLeftFrame; | 3523 | return mLeftFrame; |
3518 | } | 3524 | } |
3519 | 3525 | ||
3520 | DateNavigator *CalendarView::dateNavigator() | 3526 | DateNavigator *CalendarView::dateNavigator() |
3521 | { | 3527 | { |
3522 | return mNavigator; | 3528 | return mNavigator; |
3523 | } | 3529 | } |
3524 | 3530 | ||
3525 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3531 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3526 | { | 3532 | { |
3527 | return mDateNavigator; | 3533 | return mDateNavigator; |
3528 | } | 3534 | } |
3529 | void CalendarView::toggleDateNavigatorWidget() | 3535 | void CalendarView::toggleDateNavigatorWidget() |
3530 | { | 3536 | { |
3531 | if (mDateNavigator->isVisible()) | 3537 | if (mDateNavigator->isVisible()) |
3532 | mDateNavigator->hide(); | 3538 | mDateNavigator->hide(); |
3533 | else | 3539 | else |
3534 | mDateNavigator->show(); | 3540 | mDateNavigator->show(); |
3535 | } | 3541 | } |
3536 | void CalendarView::addView(KOrg::BaseView *view) | 3542 | void CalendarView::addView(KOrg::BaseView *view) |
3537 | { | 3543 | { |
3538 | mViewManager->addView(view); | 3544 | mViewManager->addView(view); |
3539 | } | 3545 | } |
3540 | 3546 | ||
3541 | void CalendarView::showView(KOrg::BaseView *view) | 3547 | void CalendarView::showView(KOrg::BaseView *view) |
3542 | { | 3548 | { |
3543 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3549 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3544 | } | 3550 | } |
3545 | 3551 | ||
3546 | Incidence *CalendarView::currentSelection() | 3552 | Incidence *CalendarView::currentSelection() |
3547 | { | 3553 | { |
3548 | return mViewManager->currentSelection(); | 3554 | return mViewManager->currentSelection(); |
3549 | } | 3555 | } |
3550 | void CalendarView::toggleAllDaySize() | 3556 | void CalendarView::toggleAllDaySize() |
3551 | { | 3557 | { |
3552 | /* | 3558 | /* |
3553 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3559 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3554 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3560 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3555 | else | 3561 | else |
3556 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3562 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3557 | */ | 3563 | */ |
3558 | viewManager()->agendaView()->toggleAllDay(); | 3564 | viewManager()->agendaView()->toggleAllDay(); |
3559 | } | 3565 | } |
3560 | void CalendarView::toggleExpand() | 3566 | void CalendarView::toggleExpand() |
3561 | { | 3567 | { |
3562 | // if ( mLeftFrame->isHidden() ) { | 3568 | // if ( mLeftFrame->isHidden() ) { |
3563 | // mLeftFrame->show(); | 3569 | // mLeftFrame->show(); |
3564 | // emit calendarViewExpanded( false ); | 3570 | // emit calendarViewExpanded( false ); |
3565 | // } else { | 3571 | // } else { |
3566 | // mLeftFrame->hide(); | 3572 | // mLeftFrame->hide(); |
3567 | // emit calendarViewExpanded( true ); | 3573 | // emit calendarViewExpanded( true ); |
3568 | // } | 3574 | // } |
3569 | 3575 | ||
3570 | globalFlagBlockAgenda = 1; | 3576 | globalFlagBlockAgenda = 1; |
3571 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3577 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3572 | globalFlagBlockAgenda = 5; | 3578 | globalFlagBlockAgenda = 5; |
3573 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3579 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3574 | //mViewManager->showView( 0, true ); | 3580 | //mViewManager->showView( 0, true ); |
3575 | } | 3581 | } |
3576 | 3582 | ||
3577 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3583 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3578 | { | 3584 | { |
3579 | setModified( modified ); | 3585 | setModified( modified ); |
3580 | } | 3586 | } |
3581 | 3587 | ||
3582 | Todo *CalendarView::selectedTodo() | 3588 | Todo *CalendarView::selectedTodo() |
3583 | { | 3589 | { |
3584 | Incidence *incidence = currentSelection(); | 3590 | Incidence *incidence = currentSelection(); |
3585 | if ( incidence && incidence->type() == "Todo" ) { | 3591 | if ( incidence && incidence->type() == "Todo" ) { |
3586 | return static_cast<Todo *>( incidence ); | 3592 | return static_cast<Todo *>( incidence ); |
3587 | } | 3593 | } |
3588 | 3594 | ||
3589 | incidence = mTodoList->selectedIncidences().first(); | 3595 | incidence = mTodoList->selectedIncidences().first(); |
3590 | if ( incidence && incidence->type() == "Todo" ) { | 3596 | if ( incidence && incidence->type() == "Todo" ) { |
3591 | return static_cast<Todo *>( incidence ); | 3597 | return static_cast<Todo *>( incidence ); |
3592 | } | 3598 | } |
3593 | 3599 | ||
3594 | return 0; | 3600 | return 0; |
3595 | } | 3601 | } |
3596 | 3602 | ||
3597 | void CalendarView::dialogClosing(Incidence *in) | 3603 | void CalendarView::dialogClosing(Incidence *in) |
3598 | { | 3604 | { |
3599 | // mDialogList.remove(in); | 3605 | // mDialogList.remove(in); |
3600 | } | 3606 | } |
3601 | 3607 | ||
3602 | void CalendarView::showIncidence() | 3608 | void CalendarView::showIncidence() |
3603 | { | 3609 | { |
3604 | Incidence *incidence = currentSelection(); | 3610 | Incidence *incidence = currentSelection(); |
3605 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3611 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3606 | if ( incidence ) { | 3612 | if ( incidence ) { |
3607 | ShowIncidenceVisitor v; | 3613 | ShowIncidenceVisitor v; |
3608 | v.act( incidence, this ); | 3614 | v.act( incidence, this ); |
3609 | } | 3615 | } |
3610 | } | 3616 | } |
3611 | void CalendarView::editIncidenceDescription() | 3617 | void CalendarView::editIncidenceDescription() |
3612 | { | 3618 | { |
3613 | mFlagEditDescription = true; | 3619 | mFlagEditDescription = true; |
3614 | editIncidence(); | 3620 | editIncidence(); |
3615 | mFlagEditDescription = false; | 3621 | mFlagEditDescription = false; |
3616 | } | 3622 | } |
3617 | void CalendarView::editIncidence() | 3623 | void CalendarView::editIncidence() |
3618 | { | 3624 | { |
3619 | // qDebug("editIncidence() "); | 3625 | // qDebug("editIncidence() "); |
3620 | Incidence *incidence = currentSelection(); | 3626 | Incidence *incidence = currentSelection(); |
3621 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3627 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3622 | if ( incidence ) { | 3628 | if ( incidence ) { |
3623 | EditIncidenceVisitor v; | 3629 | EditIncidenceVisitor v; |
3624 | v.act( incidence, this ); | 3630 | v.act( incidence, this ); |
3625 | } | 3631 | } |
3626 | } | 3632 | } |
3627 | 3633 | ||
3628 | void CalendarView::deleteIncidence() | 3634 | void CalendarView::deleteIncidence() |
3629 | { | 3635 | { |
3630 | Incidence *incidence = currentSelection(); | 3636 | Incidence *incidence = currentSelection(); |
3631 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3637 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3632 | if ( incidence ) { | 3638 | if ( incidence ) { |
3633 | deleteIncidence(incidence); | 3639 | deleteIncidence(incidence); |
3634 | } | 3640 | } |
3635 | } | 3641 | } |
3636 | 3642 | ||
3637 | void CalendarView::showIncidence(Incidence *incidence) | 3643 | void CalendarView::showIncidence(Incidence *incidence) |
3638 | { | 3644 | { |
3639 | if ( incidence ) { | 3645 | if ( incidence ) { |
3640 | ShowIncidenceVisitor v; | 3646 | ShowIncidenceVisitor v; |
3641 | v.act( incidence, this ); | 3647 | v.act( incidence, this ); |
3642 | } | 3648 | } |
3643 | } | 3649 | } |
3644 | 3650 | ||
3645 | void CalendarView::editIncidence(Incidence *incidence) | 3651 | void CalendarView::editIncidence(Incidence *incidence) |
3646 | { | 3652 | { |
3647 | if ( incidence ) { | 3653 | if ( incidence ) { |
3648 | 3654 | ||
3649 | EditIncidenceVisitor v; | 3655 | EditIncidenceVisitor v; |
3650 | v.act( incidence, this ); | 3656 | v.act( incidence, this ); |
3651 | 3657 | ||
3652 | } | 3658 | } |
3653 | } | 3659 | } |
3654 | 3660 | ||
3655 | void CalendarView::deleteIncidence(Incidence *incidence) | 3661 | void CalendarView::deleteIncidence(Incidence *incidence) |
3656 | { | 3662 | { |
3657 | //qDebug(" CalendarView::deleteIncidence "); | 3663 | //qDebug(" CalendarView::deleteIncidence "); |
3658 | if ( incidence ) { | 3664 | if ( incidence ) { |
3659 | DeleteIncidenceVisitor v; | 3665 | DeleteIncidenceVisitor v; |
3660 | v.act( incidence, this ); | 3666 | v.act( incidence, this ); |
3661 | } | 3667 | } |
3662 | } | 3668 | } |
3663 | 3669 | ||
3664 | 3670 | ||
3665 | void CalendarView::lookForOutgoingMessages() | 3671 | void CalendarView::lookForOutgoingMessages() |
3666 | { | 3672 | { |
3667 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3673 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3668 | ogd->loadMessages(); | 3674 | ogd->loadMessages(); |
3669 | } | 3675 | } |
3670 | 3676 | ||
3671 | void CalendarView::lookForIncomingMessages() | 3677 | void CalendarView::lookForIncomingMessages() |
3672 | { | 3678 | { |
3673 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3679 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3674 | icd->retrieve(); | 3680 | icd->retrieve(); |
3675 | } | 3681 | } |
3676 | 3682 | ||
3677 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3683 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3678 | { | 3684 | { |
3679 | bool deleteTodo = true; | 3685 | bool deleteTodo = true; |
3680 | QPtrList<Incidence> subTodos; | 3686 | QPtrList<Incidence> subTodos; |
3681 | Incidence *aTodo; | 3687 | Incidence *aTodo; |
3682 | subTodos = t->relations(); | 3688 | subTodos = t->relations(); |
3683 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3689 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3684 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3690 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3685 | deleteTodo = false; | 3691 | deleteTodo = false; |
3686 | } | 3692 | } |
3687 | if ( deleteTodo ) { | 3693 | if ( deleteTodo ) { |
3688 | if ( t->isCompleted() ) { | 3694 | if ( t->isCompleted() ) { |
3689 | checkExternalId( t ); | 3695 | checkExternalId( t ); |
3690 | mCalendar->deleteTodo( t ); | 3696 | mCalendar->deleteTodo( t ); |
3691 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3697 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3692 | } | 3698 | } |
3693 | else | 3699 | else |
3694 | deleteTodo = false; | 3700 | deleteTodo = false; |
3695 | } | 3701 | } |
3696 | return deleteTodo; | 3702 | return deleteTodo; |
3697 | 3703 | ||
3698 | } | 3704 | } |
3699 | void CalendarView::purgeCompleted() | 3705 | void CalendarView::purgeCompleted() |
3700 | { | 3706 | { |
3701 | int result = KMessageBox::warningContinueCancel(this, | 3707 | int result = KMessageBox::warningContinueCancel(this, |
3702 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3708 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3703 | 3709 | ||
3704 | if (result == KMessageBox::Continue) { | 3710 | if (result == KMessageBox::Continue) { |
3705 | 3711 | ||
3706 | QPtrList<Todo> todoCal; | 3712 | QPtrList<Todo> todoCal; |
3707 | QPtrList<Todo> rootTodos; | 3713 | QPtrList<Todo> rootTodos; |
3708 | //QPtrList<Incidence> rel; | 3714 | //QPtrList<Incidence> rel; |
3709 | Todo *aTodo;//, *rTodo; | 3715 | Todo *aTodo;//, *rTodo; |
3710 | Incidence *rIncidence; | 3716 | Incidence *rIncidence; |
3711 | bool childDelete = false; | 3717 | bool childDelete = false; |
3712 | bool deletedOne = true; | 3718 | bool deletedOne = true; |
3713 | todoCal = calendar()->todos(); | 3719 | todoCal = calendar()->todos(); |
3714 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3720 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3715 | if ( !aTodo->relatedTo() ) | 3721 | if ( !aTodo->relatedTo() ) |
3716 | rootTodos.append( aTodo ); | 3722 | rootTodos.append( aTodo ); |
3717 | } | 3723 | } |
3718 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3724 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3719 | removeCompletedSubTodos( aTodo ); | 3725 | removeCompletedSubTodos( aTodo ); |
3720 | } | 3726 | } |
3721 | 3727 | ||
3722 | updateView(); | 3728 | updateView(); |
3723 | } | 3729 | } |
3724 | } | 3730 | } |
3725 | 3731 | ||
3726 | void CalendarView::slotCalendarChanged() | 3732 | void CalendarView::slotCalendarChanged() |
3727 | { | 3733 | { |
3728 | ; | 3734 | ; |
3729 | } | 3735 | } |
3730 | 3736 | ||
3731 | NavigatorBar *CalendarView::navigatorBar() | 3737 | NavigatorBar *CalendarView::navigatorBar() |
3732 | { | 3738 | { |
3733 | return mNavigatorBar; | 3739 | return mNavigatorBar; |
3734 | } | 3740 | } |
3735 | 3741 | ||
3736 | 3742 | ||
3737 | 3743 | ||
3738 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3744 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3739 | { | 3745 | { |
3740 | //qDebug(" alendarView::keyPressEvent "); | 3746 | //qDebug(" alendarView::keyPressEvent "); |
3741 | e->ignore(); | 3747 | e->ignore(); |
3742 | } | 3748 | } |
3743 | 3749 | ||
3744 | 3750 | ||
3745 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3751 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3746 | { | 3752 | { |
3747 | // mSyncManager = manager; | 3753 | // mSyncManager = manager; |
3748 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3754 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3749 | qDebug("SyncKDE request detected!"); | 3755 | qDebug("SyncKDE request detected!"); |
3750 | } | 3756 | } |
3751 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3757 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3752 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3758 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3753 | return syncCalendar( filename, mode ); | 3759 | return syncCalendar( filename, mode ); |
3754 | } | 3760 | } |
3755 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3761 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3756 | { | 3762 | { |
3757 | //mSyncManager = manager; | 3763 | //mSyncManager = manager; |
3758 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3764 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3759 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3765 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3760 | if ( resource == "sharp" ) | 3766 | if ( resource == "sharp" ) |
3761 | syncExternal( 0 ); | 3767 | syncExternal( 0 ); |
3762 | if ( resource == "phone" ) | 3768 | if ( resource == "phone" ) |
3763 | syncExternal( 1 ); | 3769 | syncExternal( 1 ); |
3764 | // pending setmodified | 3770 | // pending setmodified |
3765 | return true; | 3771 | return true; |
3766 | } | 3772 | } |
3767 | void CalendarView::setSyncManager(KSyncManager* manager) | 3773 | void CalendarView::setSyncManager(KSyncManager* manager) |
3768 | { | 3774 | { |
3769 | mSyncManager = manager; | 3775 | mSyncManager = manager; |
3770 | } | 3776 | } |
3771 | 3777 | ||
3772 | void CalendarView::removeSyncInfo( QString syncProfile) | 3778 | void CalendarView::removeSyncInfo( QString syncProfile) |
3773 | { | 3779 | { |
3774 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | 3780 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); |
3775 | mCalendar->removeSyncInfo( syncProfile ); | 3781 | mCalendar->removeSyncInfo( syncProfile ); |
3776 | 3782 | ||
3777 | } | 3783 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index fc2d59b..65566b5 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,1893 +1,1907 @@ | |||
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 | #include "koimportoldialog.h" | 69 | #include "koimportoldialog.h" |
70 | #endif | 70 | #endif |
71 | #include "mainwindow.h" | 71 | #include "mainwindow.h" |
72 | 72 | ||
73 | class KOex2phonePrefs : public QDialog | 73 | class KOex2phonePrefs : public QDialog |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 76 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
77 | QDialog( parent, name, true ) | 77 | QDialog( parent, name, true ) |
78 | { | 78 | { |
79 | setCaption( i18n("Export to phone options") ); | 79 | setCaption( i18n("Export to phone options") ); |
80 | QVBoxLayout* lay = new QVBoxLayout( this ); | 80 | QVBoxLayout* lay = new QVBoxLayout( this ); |
81 | lay->setSpacing( 3 ); | 81 | lay->setSpacing( 3 ); |
82 | lay->setMargin( 3 ); | 82 | lay->setMargin( 3 ); |
83 | QLabel *lab; | 83 | QLabel *lab; |
84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
85 | lab->setAlignment (AlignHCenter ); | 85 | lab->setAlignment (AlignHCenter ); |
86 | QHBox* temphb; | 86 | QHBox* temphb; |
87 | temphb = new QHBox( this ); | 87 | temphb = new QHBox( this ); |
88 | new QLabel( i18n("I/O device: "), temphb ); | 88 | new QLabel( i18n("I/O device: "), temphb ); |
89 | mPhoneDevice = new QLineEdit( temphb); | 89 | mPhoneDevice = new QLineEdit( temphb); |
90 | lay->addWidget( temphb ); | 90 | lay->addWidget( temphb ); |
91 | temphb = new QHBox( this ); | 91 | temphb = new QHBox( this ); |
92 | new QLabel( i18n("Connection: "), temphb ); | 92 | new QLabel( i18n("Connection: "), temphb ); |
93 | mPhoneConnection = new QLineEdit( temphb); | 93 | mPhoneConnection = new QLineEdit( temphb); |
94 | lay->addWidget( temphb ); | 94 | lay->addWidget( temphb ); |
95 | temphb = new QHBox( this ); | 95 | temphb = new QHBox( this ); |
96 | new QLabel( i18n("Model(opt.): "), temphb ); | 96 | new QLabel( i18n("Model(opt.): "), temphb ); |
97 | mPhoneModel = new QLineEdit( temphb); | 97 | mPhoneModel = new QLineEdit( temphb); |
98 | lay->addWidget( temphb ); | 98 | lay->addWidget( temphb ); |
99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
100 | mWriteBackFuture->setChecked( true ); | 100 | mWriteBackFuture->setChecked( true ); |
101 | lay->addWidget( mWriteBackFuture ); | 101 | lay->addWidget( mWriteBackFuture ); |
102 | temphb = new QHBox( this ); | 102 | temphb = new QHBox( this ); |
103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
105 | mWriteBackFutureWeeks->setValue( 8 ); | 105 | mWriteBackFutureWeeks->setValue( 8 ); |
106 | lay->addWidget( temphb ); | 106 | lay->addWidget( temphb ); |
107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
108 | lab->setAlignment (AlignHCenter ); | 108 | lab->setAlignment (AlignHCenter ); |
109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
110 | lay->addWidget( ok ); | 110 | lay->addWidget( ok ); |
111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
112 | lay->addWidget( cancel ); | 112 | lay->addWidget( cancel ); |
113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
115 | resize( 220, 240 ); | 115 | resize( 220, 240 ); |
116 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | public: | 119 | public: |
120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
121 | QCheckBox* mWriteBackFuture; | 121 | QCheckBox* mWriteBackFuture; |
122 | QSpinBox* mWriteBackFutureWeeks; | 122 | QSpinBox* mWriteBackFutureWeeks; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | int globalFlagBlockStartup; | 125 | int globalFlagBlockStartup; |
126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
127 | QMainWindow( parent, name ) | 127 | QMainWindow( parent, name ) |
128 | { | 128 | { |
129 | 129 | ||
130 | #ifdef DESKTOP_VERSION | 130 | #ifdef DESKTOP_VERSION |
131 | setFont( QFont("Arial"), 14 ); | 131 | setFont( QFont("Arial"), 14 ); |
132 | #endif | 132 | #endif |
133 | mClosed = false; | 133 | mClosed = false; |
134 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 134 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
135 | QString confFile = locateLocal("config","korganizerrc"); | 135 | QString confFile = locateLocal("config","korganizerrc"); |
136 | QFileInfo finf ( confFile ); | 136 | QFileInfo finf ( confFile ); |
137 | bool showWarning = !finf.exists(); | 137 | bool showWarning = !finf.exists(); |
138 | setIcon(SmallIcon( "ko24" ) ); | 138 | setIcon(SmallIcon( "ko24" ) ); |
139 | mBlockAtStartup = true; | 139 | mBlockAtStartup = true; |
140 | mFlagKeyPressed = false; | 140 | mFlagKeyPressed = false; |
141 | setCaption("KOrganizer/Pi"); | 141 | setCaption("KOrganizer/Pi"); |
142 | KOPrefs *p = KOPrefs::instance(); | 142 | KOPrefs *p = KOPrefs::instance(); |
143 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 143 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
144 | if ( p->mHourSize > 18 ) | 144 | if ( p->mHourSize > 18 ) |
145 | p->mHourSize = 18; | 145 | p->mHourSize = 18; |
146 | QMainWindow::ToolBarDock tbd; | 146 | QMainWindow::ToolBarDock tbd; |
147 | if ( p->mToolBarHor ) { | 147 | if ( p->mToolBarHor ) { |
148 | if ( p->mToolBarUp ) | 148 | if ( p->mToolBarUp ) |
149 | tbd = Bottom; | 149 | tbd = Bottom; |
150 | else | 150 | else |
151 | tbd = Top; | 151 | tbd = Top; |
152 | } | 152 | } |
153 | else { | 153 | else { |
154 | if ( p->mToolBarUp ) | 154 | if ( p->mToolBarUp ) |
155 | tbd = Right; | 155 | tbd = Right; |
156 | else | 156 | else |
157 | tbd = Left; | 157 | tbd = Left; |
158 | } | 158 | } |
159 | if ( KOPrefs::instance()->mUseAppColors ) | 159 | if ( KOPrefs::instance()->mUseAppColors ) |
160 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 160 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
161 | globalFlagBlockStartup = 1; | 161 | globalFlagBlockStartup = 1; |
162 | iconToolBar = new QPEToolBar( this ); | 162 | iconToolBar = new QPEToolBar( this ); |
163 | addToolBar (iconToolBar , tbd ); | 163 | addToolBar (iconToolBar , tbd ); |
164 | mCalendarModifiedFlag = false; | 164 | mCalendarModifiedFlag = false; |
165 | 165 | ||
166 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 166 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
167 | splash->setAlignment ( AlignCenter ); | 167 | splash->setAlignment ( AlignCenter ); |
168 | setCentralWidget( splash ); | 168 | setCentralWidget( splash ); |
169 | #ifndef DESKTOP_VERSION | 169 | #ifndef DESKTOP_VERSION |
170 | showMaximized(); | 170 | showMaximized(); |
171 | #endif | 171 | #endif |
172 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 172 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
173 | setDefaultPreferences(); | 173 | setDefaultPreferences(); |
174 | mCalendar = new CalendarLocal(); | 174 | mCalendar = new CalendarLocal(); |
175 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 175 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
176 | mView->hide(); | 176 | mView->hide(); |
177 | //mView->resize(splash->size() ); | 177 | //mView->resize(splash->size() ); |
178 | initActions(); | 178 | initActions(); |
179 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 179 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
180 | mSyncManager->setBlockSave(false); | 180 | mSyncManager->setBlockSave(false); |
181 | mView->setSyncManager(mSyncManager); | 181 | mView->setSyncManager(mSyncManager); |
182 | #ifndef DESKTOP_VERSION | 182 | #ifndef DESKTOP_VERSION |
183 | iconToolBar->show(); | 183 | iconToolBar->show(); |
184 | qApp->processEvents(); | 184 | qApp->processEvents(); |
185 | #endif | 185 | #endif |
186 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 186 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
187 | int vh = height() ; | 187 | int vh = height() ; |
188 | int vw = width(); | 188 | int vw = width(); |
189 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 189 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
190 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 190 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
191 | vh -= iconToolBar->height(); | 191 | vh -= iconToolBar->height(); |
192 | } else { | 192 | } else { |
193 | vw -= iconToolBar->height(); | 193 | vw -= iconToolBar->height(); |
194 | } | 194 | } |
195 | //mView->setMaximumSize( splash->size() ); | 195 | //mView->setMaximumSize( splash->size() ); |
196 | //mView->resize( splash->size() ); | 196 | //mView->resize( splash->size() ); |
197 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 197 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
198 | mView->readSettings(); | 198 | mView->readSettings(); |
199 | bool newFile = false; | 199 | bool newFile = false; |
200 | if( !QFile::exists( defaultFileName() ) ) { | 200 | if( !QFile::exists( defaultFileName() ) ) { |
201 | QFileInfo finfo ( defaultFileName() ); | 201 | QFileInfo finfo ( defaultFileName() ); |
202 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 202 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
203 | qDebug("oldfile %s ", oldFile.latin1()); | 203 | qDebug("oldfile %s ", oldFile.latin1()); |
204 | 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"; | 204 | 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"; |
205 | finfo.setFile( oldFile ); | 205 | finfo.setFile( oldFile ); |
206 | if (finfo.exists() ) { | 206 | if (finfo.exists() ) { |
207 | KMessageBox::information( this, message); | 207 | KMessageBox::information( this, message); |
208 | mView->openCalendar( oldFile ); | 208 | mView->openCalendar( oldFile ); |
209 | qApp->processEvents(); | 209 | qApp->processEvents(); |
210 | } else { | 210 | } else { |
211 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 211 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
212 | finfo.setFile( oldFile ); | 212 | finfo.setFile( oldFile ); |
213 | if (finfo.exists() ) { | 213 | if (finfo.exists() ) { |
214 | KMessageBox::information( this, message); | 214 | KMessageBox::information( this, message); |
215 | mView->openCalendar( oldFile ); | 215 | mView->openCalendar( oldFile ); |
216 | qApp->processEvents(); | 216 | qApp->processEvents(); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | mView->saveCalendar( defaultFileName() ); | 219 | mView->saveCalendar( defaultFileName() ); |
220 | newFile = true; | 220 | newFile = true; |
221 | } | 221 | } |
222 | 222 | ||
223 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 223 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
224 | mView->openCalendar( defaultFileName() ); | 224 | mView->openCalendar( defaultFileName() ); |
225 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 225 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
226 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 226 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
227 | 227 | ||
228 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 228 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
229 | KOPrefs::instance()->setCategoryDefaults(); | 229 | KOPrefs::instance()->setCategoryDefaults(); |
230 | int count = mView->addCategories(); | 230 | int count = mView->addCategories(); |
231 | } | 231 | } |
232 | processIncidenceSelection( 0 ); | 232 | processIncidenceSelection( 0 ); |
233 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 233 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
234 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 234 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
235 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 235 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
236 | SLOT( slotModifiedChanged( bool ) ) ); | 236 | SLOT( slotModifiedChanged( bool ) ) ); |
237 | 237 | ||
238 | 238 | ||
239 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 239 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
240 | SLOT( disableBR(bool) ) ); | 240 | SLOT( disableBR(bool) ) ); |
241 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 241 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
242 | mView->setModified( false ); | 242 | mView->setModified( false ); |
243 | mBlockAtStartup = false; | 243 | mBlockAtStartup = false; |
244 | mView->setModified( false ); | 244 | mView->setModified( false ); |
245 | setCentralWidget( mView ); | 245 | setCentralWidget( mView ); |
246 | globalFlagBlockStartup = 0; | 246 | globalFlagBlockStartup = 0; |
247 | mView->show(); | 247 | mView->show(); |
248 | delete splash; | 248 | delete splash; |
249 | if ( newFile ) | 249 | if ( newFile ) |
250 | mView->updateConfig(); | 250 | mView->updateConfig(); |
251 | // qApp->processEvents(); | 251 | // qApp->processEvents(); |
252 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 252 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
253 | //fillSyncMenu(); | 253 | //fillSyncMenu(); |
254 | 254 | ||
255 | 255 | ||
256 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 256 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
257 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 257 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
258 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 258 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
259 | mSyncManager->setDefaultFileName( defaultFileName()); | 259 | mSyncManager->setDefaultFileName( defaultFileName()); |
260 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 260 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
261 | mSyncManager->fillSyncMenu(); | 261 | mSyncManager->fillSyncMenu(); |
262 | 262 | ||
263 | 263 | ||
264 | 264 | ||
265 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 265 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
266 | if ( showWarning ) { | 266 | if ( showWarning ) { |
267 | KMessageBox::information( this, | 267 | KMessageBox::information( this, |
268 | "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"); | 268 | "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"); |
269 | qApp->processEvents(); | 269 | qApp->processEvents(); |
270 | mView->dialogManager()->showSyncOptions(); | 270 | mView->dialogManager()->showSyncOptions(); |
271 | } | 271 | } |
272 | 272 | ||
273 | //US listen for result adressed from Ka/Pi | 273 | //US listen for result adressed from Ka/Pi |
274 | #ifndef DESKTOP_VERSION | 274 | #ifndef DESKTOP_VERSION |
275 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 275 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
276 | #endif | 276 | #endif |
277 | #ifndef DESKTOP_VERSION | 277 | #ifndef DESKTOP_VERSION |
278 | infrared = 0; | 278 | infrared = 0; |
279 | #endif | 279 | #endif |
280 | 280 | ||
281 | mBRdisabled = false; | 281 | mBRdisabled = false; |
282 | //toggleBeamReceive(); | 282 | //toggleBeamReceive(); |
283 | } | 283 | } |
284 | MainWindow::~MainWindow() | 284 | MainWindow::~MainWindow() |
285 | { | 285 | { |
286 | //qDebug("MainWindow::~MainWindow() "); | 286 | //qDebug("MainWindow::~MainWindow() "); |
287 | //save toolbar location | 287 | //save toolbar location |
288 | delete mCalendar; | 288 | delete mCalendar; |
289 | delete mSyncManager; | 289 | delete mSyncManager; |
290 | #ifndef DESKTOP_VERSION | 290 | #ifndef DESKTOP_VERSION |
291 | if ( infrared ) | 291 | if ( infrared ) |
292 | delete infrared; | 292 | delete infrared; |
293 | #endif | 293 | #endif |
294 | 294 | ||
295 | 295 | ||
296 | } | 296 | } |
297 | 297 | ||
298 | void MainWindow::disableBR(bool b) | 298 | void MainWindow::disableBR(bool b) |
299 | { | 299 | { |
300 | #ifndef DESKTOP_VERSION | 300 | #ifndef DESKTOP_VERSION |
301 | if ( b ) { | 301 | if ( b ) { |
302 | if ( infrared ) { | 302 | if ( infrared ) { |
303 | toggleBeamReceive(); | 303 | toggleBeamReceive(); |
304 | mBRdisabled = true; | 304 | mBRdisabled = true; |
305 | } | 305 | } |
306 | mBRdisabled = true; | 306 | mBRdisabled = true; |
307 | } else { | 307 | } else { |
308 | if ( mBRdisabled ) { | 308 | if ( mBRdisabled ) { |
309 | mBRdisabled = false; | 309 | mBRdisabled = false; |
310 | //makes no sense,because other cal ap is probably running | 310 | //makes no sense,because other cal ap is probably running |
311 | // toggleBeamReceive(); | 311 | // toggleBeamReceive(); |
312 | } | 312 | } |
313 | } | 313 | } |
314 | #endif | 314 | #endif |
315 | 315 | ||
316 | } | 316 | } |
317 | bool MainWindow::beamReceiveEnabled() | 317 | bool MainWindow::beamReceiveEnabled() |
318 | { | 318 | { |
319 | #ifndef DESKTOP_VERSION | 319 | #ifndef DESKTOP_VERSION |
320 | return ( infrared != 0 ); | 320 | return ( infrared != 0 ); |
321 | #endif | 321 | #endif |
322 | return false; | 322 | return false; |
323 | } | 323 | } |
324 | 324 | ||
325 | void MainWindow::toggleBeamReceive() | 325 | void MainWindow::toggleBeamReceive() |
326 | { | 326 | { |
327 | if ( mBRdisabled ) | 327 | if ( mBRdisabled ) |
328 | return; | 328 | return; |
329 | #ifndef DESKTOP_VERSION | 329 | #ifndef DESKTOP_VERSION |
330 | if ( infrared ) { | 330 | if ( infrared ) { |
331 | qDebug("disable BeamReceive "); | 331 | qDebug("disable BeamReceive "); |
332 | delete infrared; | 332 | delete infrared; |
333 | infrared = 0; | 333 | infrared = 0; |
334 | brAction->setOn(false); | 334 | brAction->setOn(false); |
335 | return; | 335 | return; |
336 | } | 336 | } |
337 | qDebug("enable BeamReceive "); | 337 | qDebug("enable BeamReceive "); |
338 | brAction->setOn(true); | 338 | brAction->setOn(true); |
339 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; | 339 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; |
340 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); | 340 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); |
341 | #endif | 341 | #endif |
342 | } | 342 | } |
343 | void MainWindow::showMaximized () | 343 | void MainWindow::showMaximized () |
344 | { | 344 | { |
345 | #ifndef DESKTOP_VERSION | 345 | #ifndef DESKTOP_VERSION |
346 | if ( ! globalFlagBlockStartup ) | 346 | if ( ! globalFlagBlockStartup ) |
347 | if ( mClosed ) | 347 | if ( mClosed ) |
348 | mView->goToday(); | 348 | mView->goToday(); |
349 | #endif | 349 | #endif |
350 | QWidget::showMaximized () ; | 350 | QWidget::showMaximized () ; |
351 | mClosed = false; | 351 | mClosed = false; |
352 | } | 352 | } |
353 | void MainWindow::closeEvent( QCloseEvent* ce ) | 353 | void MainWindow::closeEvent( QCloseEvent* ce ) |
354 | { | 354 | { |
355 | 355 | ||
356 | 356 | ||
357 | 357 | ||
358 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 358 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
359 | saveOnClose(); | 359 | saveOnClose(); |
360 | mClosed = true; | 360 | mClosed = true; |
361 | ce->accept(); | 361 | ce->accept(); |
362 | return; | 362 | return; |
363 | 363 | ||
364 | } | 364 | } |
365 | 365 | ||
366 | switch( QMessageBox::information( this, "KO/Pi", | 366 | switch( QMessageBox::information( this, "KO/Pi", |
367 | i18n("Do you really want\nto close KO/Pi?"), | 367 | i18n("Do you really want\nto close KO/Pi?"), |
368 | i18n("Close"), i18n("No"), | 368 | i18n("Close"), i18n("No"), |
369 | 0, 0 ) ) { | 369 | 0, 0 ) ) { |
370 | case 0: | 370 | case 0: |
371 | saveOnClose(); | 371 | saveOnClose(); |
372 | mClosed = true; | 372 | mClosed = true; |
373 | ce->accept(); | 373 | ce->accept(); |
374 | break; | 374 | break; |
375 | case 1: | 375 | case 1: |
376 | ce->ignore(); | 376 | ce->ignore(); |
377 | break; | 377 | break; |
378 | case 2: | 378 | case 2: |
379 | 379 | ||
380 | default: | 380 | default: |
381 | break; | 381 | break; |
382 | } | 382 | } |
383 | 383 | ||
384 | 384 | ||
385 | } | 385 | } |
386 | 386 | ||
387 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 387 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
388 | { | 388 | { |
389 | QDataStream stream( data, IO_ReadOnly ); | 389 | QDataStream stream( data, IO_ReadOnly ); |
390 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 390 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
391 | //QString datamess; | 391 | //QString datamess; |
392 | //qDebug("message "); | 392 | //qDebug("message "); |
393 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 393 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
394 | 394 | ||
395 | if ( cmsg == "setDocument(QString)" ) { | 395 | if ( cmsg == "setDocument(QString)" ) { |
396 | QDataStream stream( data, IO_ReadOnly ); | 396 | QDataStream stream( data, IO_ReadOnly ); |
397 | QString fileName; | 397 | QString fileName; |
398 | stream >> fileName; | 398 | stream >> fileName; |
399 | //qDebug("filename %s ", fileName.latin1()); | 399 | //qDebug("filename %s ", fileName.latin1()); |
400 | showMaximized(); | 400 | showMaximized(); |
401 | raise(); | 401 | raise(); |
402 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 402 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
403 | mSyncManager->slotSyncMenu( 1002 ); | 403 | mSyncManager->slotSyncMenu( 1002 ); |
404 | return; | 404 | return; |
405 | } | 405 | } |
406 | 406 | ||
407 | if ( cmsg == "-writeFile" ) { | 407 | if ( cmsg == "-writeFile" ) { |
408 | // I made from the "-writeFile" an "-writeAlarm" | 408 | // I made from the "-writeFile" an "-writeAlarm" |
409 | mView->viewManager()->showWhatsNextView(); | 409 | mView->viewManager()->showWhatsNextView(); |
410 | mCalendar->checkAlarmForIncidence( 0, true); | 410 | mCalendar->checkAlarmForIncidence( 0, true); |
411 | showMaximized(); | 411 | showMaximized(); |
412 | raise(); | 412 | raise(); |
413 | return; | 413 | return; |
414 | 414 | ||
415 | } | 415 | } |
416 | if ( cmsg == "-writeFileSilent" ) { | 416 | if ( cmsg == "-writeFileSilent" ) { |
417 | // I made from the "-writeFile" an "-writeAlarm" | 417 | // I made from the "-writeFile" an "-writeAlarm" |
418 | // mView->viewManager()->showWhatsNextView(); | 418 | // mView->viewManager()->showWhatsNextView(); |
419 | mCalendar->checkAlarmForIncidence( 0, true); | 419 | mCalendar->checkAlarmForIncidence( 0, true); |
420 | //showMaximized(); | 420 | //showMaximized(); |
421 | //raise(); | 421 | //raise(); |
422 | hide(); | 422 | hide(); |
423 | return; | 423 | return; |
424 | } | 424 | } |
425 | if ( cmsg == "-newCountdown" ) { | 425 | if ( cmsg == "-newCountdown" ) { |
426 | qDebug("newCountdown "); | 426 | qDebug("newCountdown "); |
427 | 427 | ||
428 | } | 428 | } |
429 | QString msg ; | 429 | QString msg ; |
430 | QString allmsg = cmsg; | 430 | QString allmsg = cmsg; |
431 | while ( allmsg.length() > 0 ) { | 431 | while ( allmsg.length() > 0 ) { |
432 | int nextC = allmsg.find( "-", 1 ); | 432 | int nextC = allmsg.find( "-", 1 ); |
433 | if ( nextC == -1 ) { | 433 | if ( nextC == -1 ) { |
434 | msg = allmsg; | 434 | msg = allmsg; |
435 | allmsg = ""; | 435 | allmsg = ""; |
436 | } else{ | 436 | } else{ |
437 | msg = allmsg.left( nextC ); | 437 | msg = allmsg.left( nextC ); |
438 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 438 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
439 | } | 439 | } |
440 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 440 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
441 | if ( msg == "-newEvent" ) { | 441 | if ( msg == "-newEvent" ) { |
442 | mView->newEvent(); | 442 | mView->newEvent(); |
443 | } | 443 | } |
444 | if ( msg == "-newTodo" ) { | 444 | if ( msg == "-newTodo" ) { |
445 | mView->newTodo(); | 445 | mView->newTodo(); |
446 | 446 | ||
447 | } | 447 | } |
448 | if ( msg == "-showWN" ) { | 448 | if ( msg == "-showWN" ) { |
449 | mView->viewManager()->showWhatsNextView(); | 449 | mView->viewManager()->showWhatsNextView(); |
450 | } | 450 | } |
451 | if ( msg == "-showTodo" ) { | 451 | if ( msg == "-showTodo" ) { |
452 | mView->viewManager()->showTodoView(); | 452 | mView->viewManager()->showTodoView(); |
453 | } | 453 | } |
454 | if ( msg == "-showList" ) { | 454 | if ( msg == "-showList" ) { |
455 | mView->viewManager()->showListView(); | 455 | mView->viewManager()->showListView(); |
456 | } | 456 | } |
457 | else if ( msg == "-showDay" ) { | 457 | else if ( msg == "-showDay" ) { |
458 | mView->viewManager()->showDayView(); | 458 | mView->viewManager()->showDayView(); |
459 | } | 459 | } |
460 | else if ( msg == "-showWWeek" ) { | 460 | else if ( msg == "-showWWeek" ) { |
461 | mView->viewManager()->showWorkWeekView(); | 461 | mView->viewManager()->showWorkWeekView(); |
462 | } | 462 | } |
463 | else if ( msg == "-ringSync" ) { | 463 | else if ( msg == "-ringSync" ) { |
464 | mSyncManager->multiSync( false ); | 464 | mSyncManager->multiSync( false ); |
465 | } | 465 | } |
466 | else if ( msg == "-showWeek" ) { | 466 | else if ( msg == "-showWeek" ) { |
467 | mView->viewManager()->showWeekView(); | 467 | mView->viewManager()->showWeekView(); |
468 | } | 468 | } |
469 | else if ( msg == "-showTodo" ) { | 469 | else if ( msg == "-showTodo" ) { |
470 | mView->viewManager()->showTodoView(); | 470 | mView->viewManager()->showTodoView(); |
471 | } | 471 | } |
472 | else if ( msg == "-showJournal" ) { | 472 | else if ( msg == "-showJournal" ) { |
473 | mView->dateNavigator()->selectDates( 1 ); | 473 | mView->dateNavigator()->selectDates( 1 ); |
474 | mView->dateNavigator()->selectToday(); | 474 | mView->dateNavigator()->selectToday(); |
475 | mView->viewManager()->showJournalView(); | 475 | mView->viewManager()->showJournalView(); |
476 | } | 476 | } |
477 | else if ( msg == "-showKO" ) { | 477 | else if ( msg == "-showKO" ) { |
478 | mView->viewManager()->showNextXView(); | 478 | mView->viewManager()->showNextXView(); |
479 | } | 479 | } |
480 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 480 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
481 | mView->viewManager()->showWhatsNextView(); | 481 | mView->viewManager()->showWhatsNextView(); |
482 | } | 482 | } |
483 | else if ( msg == "-showNextXView" ) { | 483 | else if ( msg == "-showNextXView" ) { |
484 | mView->viewManager()->showNextXView(); | 484 | mView->viewManager()->showNextXView(); |
485 | } | 485 | } |
486 | 486 | ||
487 | 487 | ||
488 | } | 488 | } |
489 | 489 | ||
490 | showMaximized(); | 490 | showMaximized(); |
491 | raise(); | 491 | raise(); |
492 | } | 492 | } |
493 | 493 | ||
494 | QPixmap MainWindow::loadPixmap( QString name ) | 494 | QPixmap MainWindow::loadPixmap( QString name ) |
495 | { | 495 | { |
496 | return SmallIcon( name ); | 496 | return SmallIcon( name ); |
497 | 497 | ||
498 | } | 498 | } |
499 | void MainWindow::initActions() | 499 | void MainWindow::initActions() |
500 | { | 500 | { |
501 | //KOPrefs::instance()->mShowFullMenu | 501 | //KOPrefs::instance()->mShowFullMenu |
502 | iconToolBar->clear(); | 502 | iconToolBar->clear(); |
503 | KOPrefs *p = KOPrefs::instance(); | 503 | KOPrefs *p = KOPrefs::instance(); |
504 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 504 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
505 | 505 | ||
506 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 506 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
507 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 507 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
508 | QPopupMenu *importMenu = new QPopupMenu( this ); | 508 | QPopupMenu *importMenu = new QPopupMenu( this ); |
509 | selectFilterMenu = new QPopupMenu( this ); | 509 | selectFilterMenu = new QPopupMenu( this ); |
510 | selectFilterMenu->setCheckable( true ); | 510 | selectFilterMenu->setCheckable( true ); |
511 | syncMenu = new QPopupMenu( this ); | 511 | syncMenu = new QPopupMenu( this ); |
512 | configureAgendaMenu = new QPopupMenu( this ); | 512 | configureAgendaMenu = new QPopupMenu( this ); |
513 | configureToolBarMenu = new QPopupMenu( this ); | 513 | configureToolBarMenu = new QPopupMenu( this ); |
514 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 514 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
515 | if ( KOPrefs::instance()->mShowFullMenu ) { | 515 | if ( KOPrefs::instance()->mShowFullMenu ) { |
516 | QMenuBar *menuBar1; | 516 | QMenuBar *menuBar1; |
517 | menuBar1 = menuBar(); | 517 | menuBar1 = menuBar(); |
518 | menuBar1->insertItem( i18n("File"), importMenu ); | 518 | menuBar1->insertItem( i18n("File"), importMenu ); |
519 | menuBar1->insertItem( i18n("View"), viewMenu ); | 519 | menuBar1->insertItem( i18n("View"), viewMenu ); |
520 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 520 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
521 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 521 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
522 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 522 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
523 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 523 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
524 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 524 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
525 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 525 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
526 | } else { | 526 | } else { |
527 | QPEMenuBar *menuBar1; | 527 | QPEMenuBar *menuBar1; |
528 | menuBar1 = new QPEMenuBar( iconToolBar ); | 528 | menuBar1 = new QPEMenuBar( iconToolBar ); |
529 | QPopupMenu *menuBar = new QPopupMenu( this ); | 529 | QPopupMenu *menuBar = new QPopupMenu( this ); |
530 | menuBar1->insertItem( i18n("ME"), menuBar); | 530 | menuBar1->insertItem( i18n("ME"), menuBar); |
531 | menuBar->insertItem( i18n("File"), importMenu ); | 531 | menuBar->insertItem( i18n("File"), importMenu ); |
532 | menuBar->insertItem( i18n("View"), viewMenu ); | 532 | menuBar->insertItem( i18n("View"), viewMenu ); |
533 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 533 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
534 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 534 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
535 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 535 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
536 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 536 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
537 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 537 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
538 | menuBar->insertItem( i18n("Help"), helpMenu ); | 538 | menuBar->insertItem( i18n("Help"), helpMenu ); |
539 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 539 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
540 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 540 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
541 | } | 541 | } |
542 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 542 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
543 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); | 543 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); |
544 | 544 | ||
545 | // ****************** | 545 | // ****************** |
546 | QAction *action; | 546 | QAction *action; |
547 | QIconSet icon; | 547 | QIconSet icon; |
548 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 548 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
549 | configureToolBarMenu->setCheckable( true ); | 549 | configureToolBarMenu->setCheckable( true ); |
550 | 550 | ||
551 | QString pathString = ""; | 551 | QString pathString = ""; |
552 | if ( !p->mToolBarMiniIcons ) { | 552 | if ( !p->mToolBarMiniIcons ) { |
553 | if ( QApplication::desktop()->width() < 480 ) | 553 | if ( QApplication::desktop()->width() < 480 ) |
554 | pathString += "icons16/"; | 554 | pathString += "icons16/"; |
555 | } else | 555 | } else |
556 | pathString += "iconsmini/"; | 556 | pathString += "iconsmini/"; |
557 | configureAgendaMenu->setCheckable( true ); | 557 | configureAgendaMenu->setCheckable( true ); |
558 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); | 558 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); |
559 | configureAgendaMenu->insertSeparator(); | 559 | configureAgendaMenu->insertSeparator(); |
560 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); | 560 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); |
561 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); | 561 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); |
562 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); | 562 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); |
563 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); | 563 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); |
564 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); | 564 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); |
565 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); | 565 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); |
566 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); | 566 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); |
567 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); | 567 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); |
568 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 568 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
569 | 569 | ||
570 | icon = loadPixmap( pathString + "configure" ); | 570 | icon = loadPixmap( pathString + "configure" ); |
571 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 571 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
572 | action->addTo( actionMenu ); | 572 | action->addTo( actionMenu ); |
573 | connect( action, SIGNAL( activated() ), | 573 | connect( action, SIGNAL( activated() ), |
574 | mView, SLOT( edit_options() ) ); | 574 | mView, SLOT( edit_options() ) ); |
575 | actionMenu->insertSeparator(); | 575 | actionMenu->insertSeparator(); |
576 | icon = loadPixmap( pathString + "newevent" ); | 576 | icon = loadPixmap( pathString + "newevent" ); |
577 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 577 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
578 | configureToolBarMenu->insertSeparator(); | 578 | configureToolBarMenu->insertSeparator(); |
579 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 579 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
580 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 580 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
581 | ne_action->addTo( actionMenu ); | 581 | ne_action->addTo( actionMenu ); |
582 | connect( ne_action, SIGNAL( activated() ), | 582 | connect( ne_action, SIGNAL( activated() ), |
583 | mView, SLOT( newEvent() ) ); | 583 | mView, SLOT( newEvent() ) ); |
584 | icon = loadPixmap( pathString + "newtodo" ); | 584 | icon = loadPixmap( pathString + "newtodo" ); |
585 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 585 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
586 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 586 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
587 | nt_action->addTo( actionMenu ); | 587 | nt_action->addTo( actionMenu ); |
588 | connect( nt_action, SIGNAL( activated() ), | 588 | connect( nt_action, SIGNAL( activated() ), |
589 | mView, SLOT( newTodo() ) ); | 589 | mView, SLOT( newTodo() ) ); |
590 | icon = loadPixmap( pathString + "navi" ); | 590 | icon = loadPixmap( pathString + "navi" ); |
591 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 591 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
592 | action->addTo( viewMenu ); | 592 | action->addTo( viewMenu ); |
593 | connect( action, SIGNAL( activated() ), | 593 | connect( action, SIGNAL( activated() ), |
594 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 594 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
595 | icon = loadPixmap( pathString + "filter" ); | 595 | icon = loadPixmap( pathString + "filter" ); |
596 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 596 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
597 | action->addTo( viewMenu ); | 597 | action->addTo( viewMenu ); |
598 | connect( action, SIGNAL( activated() ), | 598 | connect( action, SIGNAL( activated() ), |
599 | mView, SLOT( toggleFilter() ) ); | 599 | mView, SLOT( toggleFilter() ) ); |
600 | 600 | ||
601 | 601 | ||
602 | viewMenu->insertSeparator(); | 602 | viewMenu->insertSeparator(); |
603 | icon = loadPixmap( pathString + "picker" ); | 603 | icon = loadPixmap( pathString + "picker" ); |
604 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 604 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
605 | action->addTo( viewMenu ); | 605 | action->addTo( viewMenu ); |
606 | connect( action, SIGNAL( activated() ), | 606 | connect( action, SIGNAL( activated() ), |
607 | mView, SLOT( showDatePicker() ) ); | 607 | mView, SLOT( showDatePicker() ) ); |
608 | action->addTo( iconToolBar ); | 608 | action->addTo( iconToolBar ); |
609 | viewMenu->insertSeparator(); | 609 | viewMenu->insertSeparator(); |
610 | icon = loadPixmap( pathString + "list" ); | 610 | icon = loadPixmap( pathString + "list" ); |
611 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 611 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
612 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 612 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
613 | showlist_action->addTo( viewMenu ); | 613 | showlist_action->addTo( viewMenu ); |
614 | connect( showlist_action, SIGNAL( activated() ), | 614 | connect( showlist_action, SIGNAL( activated() ), |
615 | mView->viewManager(), SLOT( showListView() ) ); | 615 | mView->viewManager(), SLOT( showListView() ) ); |
616 | 616 | ||
617 | 617 | ||
618 | icon = loadPixmap( pathString + "day" ); | 618 | icon = loadPixmap( pathString + "day" ); |
619 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 619 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
620 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 620 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
621 | day1_action->addTo( viewMenu ); | 621 | day1_action->addTo( viewMenu ); |
622 | // action->addTo( toolBar ); | 622 | // action->addTo( toolBar ); |
623 | connect( day1_action, SIGNAL( activated() ), | 623 | connect( day1_action, SIGNAL( activated() ), |
624 | mView->viewManager(), SLOT( showDayView() ) ); | 624 | mView->viewManager(), SLOT( showDayView() ) ); |
625 | 625 | ||
626 | icon = loadPixmap( pathString + "workweek" ); | 626 | icon = loadPixmap( pathString + "workweek" ); |
627 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 627 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
628 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 628 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
629 | day5_action->addTo( viewMenu ); | 629 | day5_action->addTo( viewMenu ); |
630 | connect( day5_action, SIGNAL( activated() ), | 630 | connect( day5_action, SIGNAL( activated() ), |
631 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 631 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
632 | 632 | ||
633 | icon = loadPixmap( pathString + "week" ); | 633 | icon = loadPixmap( pathString + "week" ); |
634 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 634 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
635 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 635 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
636 | day7_action->addTo( viewMenu ); | 636 | day7_action->addTo( viewMenu ); |
637 | connect( day7_action, SIGNAL( activated() ), | 637 | connect( day7_action, SIGNAL( activated() ), |
638 | mView->viewManager(), SLOT( showWeekView() ) ); | 638 | mView->viewManager(), SLOT( showWeekView() ) ); |
639 | 639 | ||
640 | icon = loadPixmap( pathString + "month" ); | 640 | icon = loadPixmap( pathString + "month" ); |
641 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 641 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
642 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 642 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
643 | month_action->addTo( viewMenu ); | 643 | month_action->addTo( viewMenu ); |
644 | connect( month_action, SIGNAL( activated() ), | 644 | connect( month_action, SIGNAL( activated() ), |
645 | mView->viewManager(), SLOT( showMonthView() ) ); | 645 | mView->viewManager(), SLOT( showMonthView() ) ); |
646 | 646 | ||
647 | icon = loadPixmap( pathString + "todo" ); | 647 | icon = loadPixmap( pathString + "todo" ); |
648 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 648 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
649 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 649 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
650 | todoview_action->addTo( viewMenu ); | 650 | todoview_action->addTo( viewMenu ); |
651 | connect( todoview_action, SIGNAL( activated() ), | 651 | connect( todoview_action, SIGNAL( activated() ), |
652 | mView->viewManager(), SLOT( showTodoView() ) ); | 652 | mView->viewManager(), SLOT( showTodoView() ) ); |
653 | 653 | ||
654 | icon = loadPixmap( pathString + "journal" ); | 654 | icon = loadPixmap( pathString + "journal" ); |
655 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 655 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
656 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 656 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
657 | viewjournal_action->addTo( viewMenu ); | 657 | viewjournal_action->addTo( viewMenu ); |
658 | connect( viewjournal_action, SIGNAL( activated() ), | 658 | connect( viewjournal_action, SIGNAL( activated() ), |
659 | mView->viewManager(), SLOT( showJournalView() ) ); | 659 | mView->viewManager(), SLOT( showJournalView() ) ); |
660 | 660 | ||
661 | icon = loadPixmap( pathString + "xdays" ); | 661 | icon = loadPixmap( pathString + "xdays" ); |
662 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | 662 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); |
663 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 663 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
664 | xdays_action->addTo( viewMenu ); | 664 | xdays_action->addTo( viewMenu ); |
665 | connect( xdays_action, SIGNAL( activated() ), | 665 | connect( xdays_action, SIGNAL( activated() ), |
666 | mView->viewManager(), SLOT( showNextXView() ) ); | 666 | mView->viewManager(), SLOT( showNextXView() ) ); |
667 | 667 | ||
668 | icon = loadPixmap( pathString + "whatsnext" ); | 668 | icon = loadPixmap( pathString + "whatsnext" ); |
669 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | 669 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); |
670 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 670 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
671 | whatsnext_action->addTo( viewMenu ); | 671 | whatsnext_action->addTo( viewMenu ); |
672 | connect( whatsnext_action, SIGNAL( activated() ), | 672 | connect( whatsnext_action, SIGNAL( activated() ), |
673 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 673 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
674 | 674 | ||
675 | #if 0 | 675 | #if 0 |
676 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 676 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
677 | action->addTo( viewMenu ); | 677 | action->addTo( viewMenu ); |
678 | connect( action, SIGNAL( activated() ), | 678 | connect( action, SIGNAL( activated() ), |
679 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 679 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
680 | #endif | 680 | #endif |
681 | 681 | ||
682 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 682 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
683 | this ); | 683 | this ); |
684 | mNewSubTodoAction->addTo( actionMenu ); | 684 | mNewSubTodoAction->addTo( actionMenu ); |
685 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 685 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
686 | mView, SLOT( newSubTodo() ) ); | 686 | mView, SLOT( newSubTodo() ) ); |
687 | 687 | ||
688 | actionMenu->insertSeparator(); | 688 | actionMenu->insertSeparator(); |
689 | 689 | ||
690 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 690 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
691 | mShowAction->addTo( actionMenu ); | 691 | mShowAction->addTo( actionMenu ); |
692 | connect( mShowAction, SIGNAL( activated() ), | 692 | connect( mShowAction, SIGNAL( activated() ), |
693 | mView, SLOT( showIncidence() ) ); | 693 | mView, SLOT( showIncidence() ) ); |
694 | 694 | ||
695 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 695 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
696 | mEditAction->addTo( actionMenu ); | 696 | mEditAction->addTo( actionMenu ); |
697 | connect( mEditAction, SIGNAL( activated() ), | 697 | connect( mEditAction, SIGNAL( activated() ), |
698 | mView, SLOT( editIncidence() ) ); | 698 | mView, SLOT( editIncidence() ) ); |
699 | 699 | ||
700 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 700 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
701 | mDeleteAction->addTo( actionMenu ); | 701 | mDeleteAction->addTo( actionMenu ); |
702 | connect( mDeleteAction, SIGNAL( activated() ), | 702 | connect( mDeleteAction, SIGNAL( activated() ), |
703 | mView, SLOT( deleteIncidence() ) ); | 703 | mView, SLOT( deleteIncidence() ) ); |
704 | 704 | ||
705 | 705 | ||
706 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 706 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
707 | mCloneAction->addTo( actionMenu ); | 707 | mCloneAction->addTo( actionMenu ); |
708 | connect( mCloneAction, SIGNAL( activated() ), | 708 | connect( mCloneAction, SIGNAL( activated() ), |
709 | mView, SLOT( cloneIncidence() ) ); | 709 | mView, SLOT( cloneIncidence() ) ); |
710 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 710 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
711 | mMoveAction->addTo( actionMenu ); | 711 | mMoveAction->addTo( actionMenu ); |
712 | connect( mMoveAction, SIGNAL( activated() ), | 712 | connect( mMoveAction, SIGNAL( activated() ), |
713 | mView, SLOT( moveIncidence() ) ); | 713 | mView, SLOT( moveIncidence() ) ); |
714 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 714 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
715 | mBeamAction->addTo( actionMenu ); | 715 | mBeamAction->addTo( actionMenu ); |
716 | connect( mBeamAction, SIGNAL( activated() ), | 716 | connect( mBeamAction, SIGNAL( activated() ), |
717 | mView, SLOT( beamIncidence() ) ); | 717 | mView, SLOT( beamIncidence() ) ); |
718 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 718 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
719 | mCancelAction->addTo( actionMenu ); | 719 | mCancelAction->addTo( actionMenu ); |
720 | connect( mCancelAction, SIGNAL( activated() ), | 720 | connect( mCancelAction, SIGNAL( activated() ), |
721 | mView, SLOT( toggleCancelIncidence() ) ); | 721 | mView, SLOT( toggleCancelIncidence() ) ); |
722 | 722 | ||
723 | actionMenu->insertSeparator(); | 723 | actionMenu->insertSeparator(); |
724 | 724 | ||
725 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 725 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
726 | this ); | 726 | this ); |
727 | action->addTo( actionMenu ); | 727 | action->addTo( actionMenu ); |
728 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 728 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
729 | 729 | ||
730 | icon = loadPixmap( pathString + "search" ); | 730 | icon = loadPixmap( pathString + "search" ); |
731 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 731 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
732 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | 732 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); |
733 | search_action->addTo( actionMenu ); | 733 | search_action->addTo( actionMenu ); |
734 | connect( search_action, SIGNAL( activated() ), | 734 | connect( search_action, SIGNAL( activated() ), |
735 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 735 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
736 | 736 | ||
737 | icon = loadPixmap( pathString + "today" ); | 737 | icon = loadPixmap( pathString + "today" ); |
738 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 738 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
739 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 739 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
740 | today_action->addTo( actionMenu ); | 740 | today_action->addTo( actionMenu ); |
741 | connect( today_action, SIGNAL( activated() ), | 741 | connect( today_action, SIGNAL( activated() ), |
742 | mView, SLOT( goToday() ) ); | 742 | mView, SLOT( goToday() ) ); |
743 | 743 | ||
744 | if ( KOPrefs::instance()->mShowFullMenu ) { | 744 | if ( KOPrefs::instance()->mShowFullMenu ) { |
745 | actionMenu->insertSeparator(); | 745 | actionMenu->insertSeparator(); |
746 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 746 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
747 | 747 | ||
748 | } | 748 | } |
749 | // actionMenu->insertSeparator(); | 749 | // actionMenu->insertSeparator(); |
750 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 750 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
751 | this ); | 751 | this ); |
752 | action->addTo( importMenu ); | 752 | action->addTo( importMenu ); |
753 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 753 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
754 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 754 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
755 | this ); | 755 | this ); |
756 | action->addTo( importMenu ); | 756 | action->addTo( importMenu ); |
757 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 757 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
758 | importMenu->insertSeparator(); | 758 | importMenu->insertSeparator(); |
759 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 759 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
760 | this ); | 760 | this ); |
761 | action->addTo( importMenu ); | 761 | action->addTo( importMenu ); |
762 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 762 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
763 | #ifndef DESKTOP_VERSION | 763 | #ifndef DESKTOP_VERSION |
764 | importMenu->insertSeparator(); | 764 | importMenu->insertSeparator(); |
765 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 765 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
766 | this ); | 766 | this ); |
767 | action->addTo( importMenu ); | 767 | action->addTo( importMenu ); |
768 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 768 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
769 | #else | 769 | #else |
770 | #ifdef _WIN32_ | 770 | #ifdef _WIN32_ |
771 | importMenu->insertSeparator(); | 771 | importMenu->insertSeparator(); |
772 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 772 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
773 | this ); | 773 | this ); |
774 | action->addTo( importMenu ); | 774 | action->addTo( importMenu ); |
775 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 775 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
776 | #endif | 776 | #endif |
777 | #endif | 777 | #endif |
778 | 778 | ||
779 | importMenu->insertSeparator(); | 779 | importMenu->insertSeparator(); |
780 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 780 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
781 | this ); | 781 | this ); |
782 | action->addTo( importMenu ); | 782 | action->addTo( importMenu ); |
783 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 783 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
784 | 784 | ||
785 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 785 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
786 | this ); | 786 | this ); |
787 | action->addTo( importMenu ); | 787 | action->addTo( importMenu ); |
788 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 788 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
789 | 789 | ||
790 | importMenu->insertSeparator(); | 790 | importMenu->insertSeparator(); |
791 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 791 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
792 | this ); | 792 | this ); |
793 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 793 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
794 | 794 | ||
795 | 795 | ||
796 | //LR | 796 | //LR |
797 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 797 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
798 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 798 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
799 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 799 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
800 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 800 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
801 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); | 801 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); |
802 | 802 | ||
803 | importMenu->insertSeparator(); | 803 | importMenu->insertSeparator(); |
804 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 804 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
805 | this ); | 805 | this ); |
806 | action->addTo( importMenu ); | 806 | action->addTo( importMenu ); |
807 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 807 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
808 | #ifndef DESKTOP_VERSION | 808 | #ifndef DESKTOP_VERSION |
809 | importMenu->insertSeparator(); | 809 | importMenu->insertSeparator(); |
810 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, | 810 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, |
811 | this ); | 811 | this ); |
812 | brAction->addTo( importMenu ); | 812 | brAction->addTo( importMenu ); |
813 | brAction->setToggleAction (true ) ; | 813 | brAction->setToggleAction (true ) ; |
814 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); | 814 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); |
815 | 815 | ||
816 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 816 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
817 | this ); | 817 | this ); |
818 | action->addTo( importMenu ); | 818 | action->addTo( importMenu ); |
819 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 819 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
820 | 820 | ||
821 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 821 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
822 | this ); | 822 | this ); |
823 | action->addTo( importMenu ); | 823 | action->addTo( importMenu ); |
824 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 824 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
825 | #else | 825 | #else |
826 | importMenu->insertSeparator(); | 826 | importMenu->insertSeparator(); |
827 | icon = loadPixmap( pathString + "print" ); | 827 | icon = loadPixmap( pathString + "print" ); |
828 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 828 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
829 | action->addTo( importMenu ); | 829 | action->addTo( importMenu ); |
830 | connect( action, SIGNAL( activated() ), | 830 | connect( action, SIGNAL( activated() ), |
831 | this, SLOT( printCal() ) ); | 831 | this, SLOT( printCal() ) ); |
832 | 832 | ||
833 | icon = loadPixmap( pathString + "print" ); | 833 | icon = loadPixmap( pathString + "print" ); |
834 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 834 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
835 | action->addTo( importMenu ); | 835 | action->addTo( importMenu ); |
836 | connect( action, SIGNAL( activated() ), | 836 | connect( action, SIGNAL( activated() ), |
837 | this, SLOT( printSel() ) ); | 837 | this, SLOT( printSel() ) ); |
838 | #endif | 838 | #endif |
839 | importMenu->insertSeparator(); | 839 | importMenu->insertSeparator(); |
840 | action = new QAction( "beam all", i18n("Save"), 0, | 840 | action = new QAction( "beam all", i18n("Save"), 0, |
841 | this ); | 841 | this ); |
842 | action->addTo( importMenu ); | 842 | action->addTo( importMenu ); |
843 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 843 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
844 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 844 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
845 | this ); | 845 | this ); |
846 | action->addTo( importMenu ); | 846 | action->addTo( importMenu ); |
847 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 847 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
848 | 848 | ||
849 | //menuBar->insertItem( "Configure",configureMenu ); | 849 | //menuBar->insertItem( "Configure",configureMenu ); |
850 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 850 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
851 | icon = loadPixmap( "korganizer/korganizer" ); | 851 | icon = loadPixmap( "korganizer/korganizer" ); |
852 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 852 | |
853 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | ||
853 | action->addTo( helpMenu ); | 854 | action->addTo( helpMenu ); |
854 | connect( action, SIGNAL( activated() ), | 855 | connect( action, SIGNAL( activated() ), |
855 | SLOT( keyBindings() ) ); | 856 | SLOT( whatsNew() ) ); |
856 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 857 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
857 | action->addTo( helpMenu ); | 858 | action->addTo( helpMenu ); |
858 | connect( action, SIGNAL( activated() ), | 859 | connect( action, SIGNAL( activated() ), |
859 | SLOT( features() ) ); | 860 | SLOT( features() ) ); |
861 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | ||
862 | action->addTo( helpMenu ); | ||
863 | connect( action, SIGNAL( activated() ), | ||
864 | SLOT( keyBindings() ) ); | ||
865 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | ||
866 | action->addTo( helpMenu ); | ||
867 | connect( action, SIGNAL( activated() ), | ||
868 | SLOT( synchowto() ) ); | ||
869 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); | ||
870 | action->addTo( helpMenu ); | ||
871 | connect( action, SIGNAL( activated() ), | ||
872 | SLOT( kdesynchowto() ) ); | ||
873 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); | ||
874 | action->addTo( helpMenu ); | ||
875 | connect( action, SIGNAL( activated() ), | ||
876 | SLOT( multisynchowto() ) ); | ||
860 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 877 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
861 | action->addTo( helpMenu ); | 878 | action->addTo( helpMenu ); |
862 | connect( action, SIGNAL( activated() ), | 879 | connect( action, SIGNAL( activated() ), |
863 | SLOT( aboutAutoSaving() ) ); | 880 | SLOT( aboutAutoSaving() ) ); |
864 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 881 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
865 | action->addTo( helpMenu ); | 882 | action->addTo( helpMenu ); |
866 | connect( action, SIGNAL( activated() ), | 883 | connect( action, SIGNAL( activated() ), |
867 | SLOT( aboutKnownBugs() ) ); | 884 | SLOT( aboutKnownBugs() ) ); |
868 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 885 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
869 | action->addTo( helpMenu ); | 886 | action->addTo( helpMenu ); |
870 | connect( action, SIGNAL( activated() ), | 887 | connect( action, SIGNAL( activated() ), |
871 | SLOT( usertrans() ) ); | 888 | SLOT( usertrans() ) ); |
872 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | ||
873 | action->addTo( helpMenu ); | ||
874 | connect( action, SIGNAL( activated() ), | ||
875 | SLOT( synchowto() ) ); | ||
876 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | ||
877 | action->addTo( helpMenu ); | ||
878 | connect( action, SIGNAL( activated() ), | ||
879 | SLOT( whatsNew() ) ); | ||
880 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 889 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
881 | action->addTo( helpMenu ); | 890 | action->addTo( helpMenu ); |
882 | connect( action, SIGNAL( activated() ), | 891 | connect( action, SIGNAL( activated() ), |
883 | SLOT( faq() ) ); | 892 | SLOT( faq() ) ); |
884 | |||
885 | |||
886 | action = new QAction( "about", i18n("About..."), 0, this ); | ||
887 | action->addTo( helpMenu ); | ||
888 | connect( action, SIGNAL( activated() ), | ||
889 | SLOT( about() ) ); | ||
890 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 893 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
891 | action->addTo( helpMenu ); | 894 | action->addTo( helpMenu ); |
892 | connect( action, SIGNAL( activated() ), | 895 | connect( action, SIGNAL( activated() ), |
893 | SLOT( licence() ) ); | 896 | SLOT( licence() ) ); |
897 | action = new QAction( "about", i18n("About..."), 0, this ); | ||
898 | action->addTo( helpMenu ); | ||
899 | connect( action, SIGNAL( activated() ), | ||
900 | SLOT( about() ) ); | ||
894 | //menuBar->insertSeparator(); | 901 | //menuBar->insertSeparator(); |
895 | 902 | ||
896 | // ****************************************************** | 903 | // ****************************************************** |
897 | // menubar icons | 904 | // menubar icons |
898 | 905 | ||
899 | 906 | ||
900 | iconToolBar->setHorizontalStretchable (true ); | 907 | iconToolBar->setHorizontalStretchable (true ); |
901 | //menuBar->insertItem( iconToolBar ); | 908 | //menuBar->insertItem( iconToolBar ); |
902 | //xdays_action | 909 | //xdays_action |
903 | if (p-> mShowIconNewEvent) | 910 | if (p-> mShowIconNewEvent) |
904 | ne_action->addTo( iconToolBar ); | 911 | ne_action->addTo( iconToolBar ); |
905 | if (p->mShowIconNewTodo ) | 912 | if (p->mShowIconNewTodo ) |
906 | nt_action->addTo( iconToolBar ); | 913 | nt_action->addTo( iconToolBar ); |
907 | if (p-> mShowIconSearch) | 914 | if (p-> mShowIconSearch) |
908 | search_action->addTo( iconToolBar ); | 915 | search_action->addTo( iconToolBar ); |
909 | if (p-> mShowIconNext) | 916 | if (p-> mShowIconNext) |
910 | whatsnext_action->addTo( iconToolBar ); | 917 | whatsnext_action->addTo( iconToolBar ); |
911 | if (p-> mShowIconNextDays) | 918 | if (p-> mShowIconNextDays) |
912 | xdays_action->addTo( iconToolBar ); | 919 | xdays_action->addTo( iconToolBar ); |
913 | if (p-> mShowIconList) | 920 | if (p-> mShowIconList) |
914 | showlist_action->addTo( iconToolBar ); | 921 | showlist_action->addTo( iconToolBar ); |
915 | if (p-> mShowIconDay1) | 922 | if (p-> mShowIconDay1) |
916 | day1_action->addTo( iconToolBar ); | 923 | day1_action->addTo( iconToolBar ); |
917 | if (p-> mShowIconDay5) | 924 | if (p-> mShowIconDay5) |
918 | day5_action->addTo( iconToolBar ); | 925 | day5_action->addTo( iconToolBar ); |
919 | if (p-> mShowIconDay7) | 926 | if (p-> mShowIconDay7) |
920 | day7_action->addTo( iconToolBar ); | 927 | day7_action->addTo( iconToolBar ); |
921 | if (p-> mShowIconMonth) | 928 | if (p-> mShowIconMonth) |
922 | month_action->addTo( iconToolBar ); | 929 | month_action->addTo( iconToolBar ); |
923 | if (p-> mShowIconTodoview) | 930 | if (p-> mShowIconTodoview) |
924 | todoview_action->addTo( iconToolBar ); | 931 | todoview_action->addTo( iconToolBar ); |
925 | if (p-> mShowIconJournal) | 932 | if (p-> mShowIconJournal) |
926 | viewjournal_action->addTo( iconToolBar ); | 933 | viewjournal_action->addTo( iconToolBar ); |
927 | icon = loadPixmap( pathString + "2leftarrowB" ); | 934 | icon = loadPixmap( pathString + "2leftarrowB" ); |
928 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 935 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
929 | if (p-> mShowIconBackFast) { | 936 | if (p-> mShowIconBackFast) { |
930 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 937 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
931 | connect( action, SIGNAL( activated() ), | 938 | connect( action, SIGNAL( activated() ), |
932 | mView, SLOT( goPreviousMonth() ) ); | 939 | mView, SLOT( goPreviousMonth() ) ); |
933 | action->addTo( iconToolBar ); | 940 | action->addTo( iconToolBar ); |
934 | } | 941 | } |
935 | icon = loadPixmap( pathString + "1leftarrowB" ); | 942 | icon = loadPixmap( pathString + "1leftarrowB" ); |
936 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 943 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
937 | if (p-> mShowIconBack) { | 944 | if (p-> mShowIconBack) { |
938 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 945 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
939 | connect( action, SIGNAL( activated() ), | 946 | connect( action, SIGNAL( activated() ), |
940 | mView, SLOT( goPrevious() ) ); | 947 | mView, SLOT( goPrevious() ) ); |
941 | action->addTo( iconToolBar ); | 948 | action->addTo( iconToolBar ); |
942 | } | 949 | } |
943 | if (p-> mShowIconToday) | 950 | if (p-> mShowIconToday) |
944 | today_action->addTo( iconToolBar ); | 951 | today_action->addTo( iconToolBar ); |
945 | icon = loadPixmap( pathString + "1rightarrowB" ); | 952 | icon = loadPixmap( pathString + "1rightarrowB" ); |
946 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 953 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
947 | if (p-> mShowIconForward) { | 954 | if (p-> mShowIconForward) { |
948 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 955 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
949 | connect( action, SIGNAL( activated() ), | 956 | connect( action, SIGNAL( activated() ), |
950 | mView, SLOT( goNext() ) ); | 957 | mView, SLOT( goNext() ) ); |
951 | action->addTo( iconToolBar ); | 958 | action->addTo( iconToolBar ); |
952 | } | 959 | } |
953 | icon = loadPixmap( pathString + "2rightarrowB" ); | 960 | icon = loadPixmap( pathString + "2rightarrowB" ); |
954 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 961 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
955 | if (p-> mShowIconForwardFast) { | 962 | if (p-> mShowIconForwardFast) { |
956 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 963 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
957 | connect( action, SIGNAL( activated() ), | 964 | connect( action, SIGNAL( activated() ), |
958 | mView, SLOT( goNextMonth() ) ); | 965 | mView, SLOT( goNextMonth() ) ); |
959 | action->addTo( iconToolBar ); | 966 | action->addTo( iconToolBar ); |
960 | } | 967 | } |
961 | 968 | ||
962 | 969 | ||
963 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 970 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
964 | 971 | ||
965 | if (p-> mShowIconNewEvent) | 972 | if (p-> mShowIconNewEvent) |
966 | configureToolBarMenu->setItemChecked( 10, true ); | 973 | configureToolBarMenu->setItemChecked( 10, true ); |
967 | if (p->mShowIconNewTodo ) | 974 | if (p->mShowIconNewTodo ) |
968 | configureToolBarMenu->setItemChecked( 20, true ); | 975 | configureToolBarMenu->setItemChecked( 20, true ); |
969 | if (p-> mShowIconSearch) | 976 | if (p-> mShowIconSearch) |
970 | configureToolBarMenu->setItemChecked( 120, true ); | 977 | configureToolBarMenu->setItemChecked( 120, true ); |
971 | if (p-> mShowIconList) | 978 | if (p-> mShowIconList) |
972 | configureToolBarMenu->setItemChecked( 30, true ); | 979 | configureToolBarMenu->setItemChecked( 30, true ); |
973 | if (p-> mShowIconDay1) | 980 | if (p-> mShowIconDay1) |
974 | configureToolBarMenu->setItemChecked( 40, true ); | 981 | configureToolBarMenu->setItemChecked( 40, true ); |
975 | if (p-> mShowIconDay5) | 982 | if (p-> mShowIconDay5) |
976 | configureToolBarMenu->setItemChecked( 50, true ); | 983 | configureToolBarMenu->setItemChecked( 50, true ); |
977 | if (p-> mShowIconDay7) | 984 | if (p-> mShowIconDay7) |
978 | configureToolBarMenu->setItemChecked( 60, true ); | 985 | configureToolBarMenu->setItemChecked( 60, true ); |
979 | if (p-> mShowIconMonth) | 986 | if (p-> mShowIconMonth) |
980 | configureToolBarMenu->setItemChecked( 70, true ); | 987 | configureToolBarMenu->setItemChecked( 70, true ); |
981 | if (p-> mShowIconTodoview) | 988 | if (p-> mShowIconTodoview) |
982 | configureToolBarMenu->setItemChecked( 80, true ); | 989 | configureToolBarMenu->setItemChecked( 80, true ); |
983 | if (p-> mShowIconBackFast) | 990 | if (p-> mShowIconBackFast) |
984 | configureToolBarMenu->setItemChecked( 200, true ); | 991 | configureToolBarMenu->setItemChecked( 200, true ); |
985 | if (p-> mShowIconBack) | 992 | if (p-> mShowIconBack) |
986 | configureToolBarMenu->setItemChecked( 210, true ); | 993 | configureToolBarMenu->setItemChecked( 210, true ); |
987 | if (p-> mShowIconToday) | 994 | if (p-> mShowIconToday) |
988 | configureToolBarMenu->setItemChecked( 130, true ); | 995 | configureToolBarMenu->setItemChecked( 130, true ); |
989 | if (p-> mShowIconForward) | 996 | if (p-> mShowIconForward) |
990 | configureToolBarMenu->setItemChecked( 220, true ); | 997 | configureToolBarMenu->setItemChecked( 220, true ); |
991 | if (p-> mShowIconForwardFast) | 998 | if (p-> mShowIconForwardFast) |
992 | configureToolBarMenu->setItemChecked( 230, true ); | 999 | configureToolBarMenu->setItemChecked( 230, true ); |
993 | if (p-> mShowIconNextDays) | 1000 | if (p-> mShowIconNextDays) |
994 | configureToolBarMenu->setItemChecked( 100, true ); | 1001 | configureToolBarMenu->setItemChecked( 100, true ); |
995 | if (p-> mShowIconNext) | 1002 | if (p-> mShowIconNext) |
996 | configureToolBarMenu->setItemChecked( 110, true ); | 1003 | configureToolBarMenu->setItemChecked( 110, true ); |
997 | if (p-> mShowIconJournal) | 1004 | if (p-> mShowIconJournal) |
998 | configureToolBarMenu->setItemChecked( 90, true ); | 1005 | configureToolBarMenu->setItemChecked( 90, true ); |
999 | if (p-> mShowIconWhatsThis) | 1006 | if (p-> mShowIconWhatsThis) |
1000 | configureToolBarMenu->setItemChecked( 300, true ); | 1007 | configureToolBarMenu->setItemChecked( 300, true ); |
1001 | 1008 | ||
1002 | QLabel* dummy = new QLabel( iconToolBar ); | 1009 | QLabel* dummy = new QLabel( iconToolBar ); |
1003 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 1010 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
1004 | if (!p-> mShowIconStretch) | 1011 | if (!p-> mShowIconStretch) |
1005 | iconToolBar->setStretchableWidget ( dummy ) ; | 1012 | iconToolBar->setStretchableWidget ( dummy ) ; |
1006 | else | 1013 | else |
1007 | configureToolBarMenu->setItemChecked( 5, true ); | 1014 | configureToolBarMenu->setItemChecked( 5, true ); |
1008 | if (p-> mShowIconWhatsThis) | 1015 | if (p-> mShowIconWhatsThis) |
1009 | QWhatsThis::whatsThisButton ( iconToolBar ); | 1016 | QWhatsThis::whatsThisButton ( iconToolBar ); |
1010 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 1017 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
1011 | configureAgenda( p->mHourSize ); | 1018 | configureAgenda( p->mHourSize ); |
1012 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 1019 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
1013 | } | 1020 | } |
1014 | 1021 | ||
1015 | void MainWindow::exportToPhone( int mode ) | 1022 | void MainWindow::exportToPhone( int mode ) |
1016 | { | 1023 | { |
1017 | 1024 | ||
1018 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1025 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1019 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1026 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1020 | KOex2phonePrefs ex2phone; | 1027 | KOex2phonePrefs ex2phone; |
1021 | 1028 | ||
1022 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 1029 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1023 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 1030 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1024 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1031 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1025 | if ( mode == 1 ) | 1032 | if ( mode == 1 ) |
1026 | ex2phone.setCaption(i18n("Export complete calendar")); | 1033 | ex2phone.setCaption(i18n("Export complete calendar")); |
1027 | if ( mode == 2 ) | 1034 | if ( mode == 2 ) |
1028 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1035 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1029 | 1036 | ||
1030 | if ( !ex2phone.exec() ) { | 1037 | if ( !ex2phone.exec() ) { |
1031 | return; | 1038 | return; |
1032 | } | 1039 | } |
1033 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1040 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1034 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1041 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1035 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1042 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1036 | 1043 | ||
1037 | int inFuture = 0; | 1044 | int inFuture = 0; |
1038 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1045 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1039 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1046 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1040 | QPtrList<Incidence> delSel; | 1047 | QPtrList<Incidence> delSel; |
1041 | if ( mode == 1 ) | 1048 | if ( mode == 1 ) |
1042 | delSel = mCalendar->rawIncidences(); | 1049 | delSel = mCalendar->rawIncidences(); |
1043 | if ( mode == 2 ) | 1050 | if ( mode == 2 ) |
1044 | delSel = mCalendar->incidences(); | 1051 | delSel = mCalendar->incidences(); |
1045 | CalendarLocal* cal = new CalendarLocal(); | 1052 | CalendarLocal* cal = new CalendarLocal(); |
1046 | cal->setLocalTime(); | 1053 | cal->setLocalTime(); |
1047 | Incidence *incidence = delSel.first(); | 1054 | Incidence *incidence = delSel.first(); |
1048 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1055 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1049 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1056 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1050 | while ( incidence ) { | 1057 | while ( incidence ) { |
1051 | if ( incidence->type() != "Journal" ) { | 1058 | if ( incidence->type() != "Journal" ) { |
1052 | bool add = true; | 1059 | bool add = true; |
1053 | if ( inFuture ) { | 1060 | if ( inFuture ) { |
1054 | QDateTime dt; | 1061 | QDateTime dt; |
1055 | if ( incidence->type() == "Todo" ) { | 1062 | if ( incidence->type() == "Todo" ) { |
1056 | Todo * t = (Todo*)incidence; | 1063 | Todo * t = (Todo*)incidence; |
1057 | if ( t->hasDueDate() ) | 1064 | if ( t->hasDueDate() ) |
1058 | dt = t->dtDue(); | 1065 | dt = t->dtDue(); |
1059 | else | 1066 | else |
1060 | dt = cur.addSecs( 62 ); | 1067 | dt = cur.addSecs( 62 ); |
1061 | } | 1068 | } |
1062 | else { | 1069 | else { |
1063 | bool ok; | 1070 | bool ok; |
1064 | dt = incidence->getNextOccurence( cur, &ok ); | 1071 | dt = incidence->getNextOccurence( cur, &ok ); |
1065 | if ( !ok ) | 1072 | if ( !ok ) |
1066 | dt = cur.addSecs( -62 ); | 1073 | dt = cur.addSecs( -62 ); |
1067 | } | 1074 | } |
1068 | if ( dt < cur || dt > end ) { | 1075 | if ( dt < cur || dt > end ) { |
1069 | add = false; | 1076 | add = false; |
1070 | } | 1077 | } |
1071 | } | 1078 | } |
1072 | if ( add ) { | 1079 | if ( add ) { |
1073 | Incidence *in = incidence->clone(); | 1080 | Incidence *in = incidence->clone(); |
1074 | cal->addIncidence( in ); | 1081 | cal->addIncidence( in ); |
1075 | } | 1082 | } |
1076 | } | 1083 | } |
1077 | incidence = delSel.next(); | 1084 | incidence = delSel.next(); |
1078 | } | 1085 | } |
1079 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1086 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1080 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1087 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1081 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1088 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1082 | 1089 | ||
1083 | setCaption( i18n("Writing to phone...")); | 1090 | setCaption( i18n("Writing to phone...")); |
1084 | if ( PhoneFormat::writeToPhone( cal ) ) | 1091 | if ( PhoneFormat::writeToPhone( cal ) ) |
1085 | setCaption( i18n("Export to phone successful!")); | 1092 | setCaption( i18n("Export to phone successful!")); |
1086 | else | 1093 | else |
1087 | setCaption( i18n("Error exporting to phone!")); | 1094 | setCaption( i18n("Error exporting to phone!")); |
1088 | delete cal; | 1095 | delete cal; |
1089 | } | 1096 | } |
1090 | 1097 | ||
1091 | 1098 | ||
1092 | void MainWindow::setDefaultPreferences() | 1099 | void MainWindow::setDefaultPreferences() |
1093 | { | 1100 | { |
1094 | KOPrefs *p = KOPrefs::instance(); | 1101 | KOPrefs *p = KOPrefs::instance(); |
1095 | 1102 | ||
1096 | p->mCompactDialogs = true; | 1103 | p->mCompactDialogs = true; |
1097 | p->mConfirm = true; | 1104 | p->mConfirm = true; |
1098 | // p->mEnableQuickTodo = false; | 1105 | // p->mEnableQuickTodo = false; |
1099 | 1106 | ||
1100 | } | 1107 | } |
1101 | 1108 | ||
1102 | QString MainWindow::resourcePath() | 1109 | QString MainWindow::resourcePath() |
1103 | { | 1110 | { |
1104 | return KGlobal::iconLoader()->iconPath(); | 1111 | return KGlobal::iconLoader()->iconPath(); |
1105 | } | 1112 | } |
1106 | 1113 | ||
1107 | void MainWindow::displayText( QString text ,QString cap ) | 1114 | void MainWindow::displayText( QString text ,QString cap ) |
1108 | { | 1115 | { |
1109 | QDialog dia( this, "name", true ); ; | 1116 | QDialog dia( this, "name", true ); ; |
1110 | dia.setCaption( cap ); | 1117 | dia.setCaption( cap ); |
1111 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1118 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1112 | lay->setSpacing( 3 ); | 1119 | lay->setSpacing( 3 ); |
1113 | lay->setMargin( 3 ); | 1120 | lay->setMargin( 3 ); |
1114 | QTextBrowser tb ( &dia ); | 1121 | QTextBrowser tb ( &dia ); |
1115 | lay->addWidget( &tb ); | 1122 | lay->addWidget( &tb ); |
1116 | tb.setText( text ); | 1123 | tb.setText( text ); |
1117 | #ifdef DESKTOP_VERSION | 1124 | #ifdef DESKTOP_VERSION |
1118 | dia.resize( 640, 480); | 1125 | dia.resize( 640, 480); |
1119 | #else | 1126 | #else |
1120 | dia.showMaximized(); | 1127 | dia.showMaximized(); |
1121 | #endif | 1128 | #endif |
1122 | dia.exec(); | 1129 | dia.exec(); |
1123 | } | 1130 | } |
1124 | void MainWindow::displayFile( QString fn, QString cap ) | 1131 | void MainWindow::displayFile( QString fn, QString cap ) |
1125 | { | 1132 | { |
1126 | QString fileName = resourcePath() + fn; | 1133 | QString fileName = resourcePath() + fn; |
1127 | QString text; | 1134 | QString text; |
1128 | QFile file( fileName ); | 1135 | QFile file( fileName ); |
1129 | if (!file.open( IO_ReadOnly ) ) { | 1136 | if (!file.open( IO_ReadOnly ) ) { |
1130 | return ; | 1137 | return ; |
1131 | 1138 | ||
1132 | } | 1139 | } |
1133 | QTextStream ts( &file ); | 1140 | QTextStream ts( &file ); |
1134 | text = ts.read(); | 1141 | text = ts.read(); |
1135 | file.close(); | 1142 | file.close(); |
1136 | displayText( text, cap); | 1143 | displayText( text, cap); |
1137 | } | 1144 | } |
1138 | void MainWindow::features() | 1145 | void MainWindow::features() |
1139 | { | 1146 | { |
1140 | 1147 | ||
1141 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1148 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1142 | } | 1149 | } |
1143 | 1150 | ||
1144 | void MainWindow::usertrans() | 1151 | void MainWindow::usertrans() |
1145 | { | 1152 | { |
1146 | 1153 | ||
1147 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1154 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1148 | } | 1155 | } |
1149 | 1156 | ||
1157 | void MainWindow::kdesynchowto() | ||
1158 | { | ||
1159 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | ||
1160 | } | ||
1161 | void MainWindow::multisynchowto() | ||
1162 | { | ||
1163 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | ||
1164 | } | ||
1150 | void MainWindow::synchowto() | 1165 | void MainWindow::synchowto() |
1151 | { | 1166 | { |
1152 | |||
1153 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1167 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1154 | } | 1168 | } |
1155 | void MainWindow::faq() | 1169 | void MainWindow::faq() |
1156 | { | 1170 | { |
1157 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1171 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1158 | 1172 | ||
1159 | } | 1173 | } |
1160 | void MainWindow::whatsNew() | 1174 | void MainWindow::whatsNew() |
1161 | { | 1175 | { |
1162 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1176 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1163 | 1177 | ||
1164 | } | 1178 | } |
1165 | void MainWindow::licence() | 1179 | void MainWindow::licence() |
1166 | { | 1180 | { |
1167 | KApplication::showLicence(); | 1181 | KApplication::showLicence(); |
1168 | 1182 | ||
1169 | } | 1183 | } |
1170 | void MainWindow::about() | 1184 | void MainWindow::about() |
1171 | { | 1185 | { |
1172 | QString version; | 1186 | QString version; |
1173 | #include <../version> | 1187 | #include <../version> |
1174 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1188 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1175 | i18n("KOrganizer/Platform-independent\n") + | 1189 | i18n("KOrganizer/Platform-independent\n") + |
1176 | "(KO/Pi) " + version + " - " + | 1190 | "(KO/Pi) " + version + " - " + |
1177 | 1191 | ||
1178 | #ifdef DESKTOP_VERSION | 1192 | #ifdef DESKTOP_VERSION |
1179 | i18n("Desktop Edition\n") + | 1193 | i18n("Desktop Edition\n") + |
1180 | #else | 1194 | #else |
1181 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1195 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1182 | #endif | 1196 | #endif |
1183 | 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") ); | 1197 | 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") ); |
1184 | } | 1198 | } |
1185 | void MainWindow::keyBindings() | 1199 | void MainWindow::keyBindings() |
1186 | { | 1200 | { |
1187 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1201 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1188 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1202 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1189 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1203 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1190 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1204 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1191 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1205 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1192 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1206 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1193 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1207 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1194 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1208 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1195 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1209 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1196 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1210 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1197 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1211 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1198 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1212 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1199 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1213 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1200 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1214 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1201 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1215 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1202 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1216 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1203 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1217 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1204 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1218 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1205 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1219 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1206 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1220 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1207 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1221 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1208 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1222 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1209 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1223 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1210 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1224 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1211 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1225 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1212 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1226 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1213 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1227 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1214 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1228 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1215 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1229 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1216 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1230 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1217 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1231 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1218 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1232 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1219 | i18n("<p><h3>In list view:</h3></p>\n") + | 1233 | i18n("<p><h3>In list view:</h3></p>\n") + |
1220 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1234 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1221 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1235 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1222 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1236 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1223 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1237 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1224 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1238 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1225 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1239 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1226 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1240 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1227 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1241 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1228 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1242 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1229 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1243 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1230 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1244 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1231 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1245 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1232 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1246 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1233 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1247 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1234 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1248 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1235 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1249 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1236 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1250 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1237 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1251 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1238 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1252 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1239 | displayText( text, cap); | 1253 | displayText( text, cap); |
1240 | 1254 | ||
1241 | } | 1255 | } |
1242 | void MainWindow::aboutAutoSaving() | 1256 | void MainWindow::aboutAutoSaving() |
1243 | { | 1257 | { |
1244 | QMessageBox* msg; | 1258 | QMessageBox* msg; |
1245 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1259 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1246 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, | 1260 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, |
1247 | QMessageBox::Ok, | 1261 | QMessageBox::Ok, |
1248 | QMessageBox::NoButton, | 1262 | QMessageBox::NoButton, |
1249 | QMessageBox::NoButton); | 1263 | QMessageBox::NoButton); |
1250 | msg->exec(); | 1264 | msg->exec(); |
1251 | delete msg; | 1265 | delete msg; |
1252 | 1266 | ||
1253 | 1267 | ||
1254 | } | 1268 | } |
1255 | void MainWindow::aboutKnownBugs() | 1269 | void MainWindow::aboutKnownBugs() |
1256 | { | 1270 | { |
1257 | QMessageBox* msg; | 1271 | QMessageBox* msg; |
1258 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1272 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1259 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1273 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1260 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1274 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1261 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1275 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1262 | i18n("\nor report them in the bugtracker on\n") + | 1276 | i18n("\nor report them in the bugtracker on\n") + |
1263 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1277 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1264 | QMessageBox::NoIcon, | 1278 | QMessageBox::NoIcon, |
1265 | QMessageBox::Ok, | 1279 | QMessageBox::Ok, |
1266 | QMessageBox::NoButton, | 1280 | QMessageBox::NoButton, |
1267 | QMessageBox::NoButton); | 1281 | QMessageBox::NoButton); |
1268 | msg->exec(); | 1282 | msg->exec(); |
1269 | delete msg; | 1283 | delete msg; |
1270 | 1284 | ||
1271 | } | 1285 | } |
1272 | 1286 | ||
1273 | QString MainWindow::defaultFileName() | 1287 | QString MainWindow::defaultFileName() |
1274 | { | 1288 | { |
1275 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1289 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1276 | } | 1290 | } |
1277 | QString MainWindow::syncFileName() | 1291 | QString MainWindow::syncFileName() |
1278 | { | 1292 | { |
1279 | #ifdef DESKTOP_VERSION | 1293 | #ifdef DESKTOP_VERSION |
1280 | return locateLocal( "tmp", "synccalendar.ics" ); | 1294 | return locateLocal( "tmp", "synccalendar.ics" ); |
1281 | #else | 1295 | #else |
1282 | return QString( "/tmp/synccalendar.ics" ); | 1296 | return QString( "/tmp/synccalendar.ics" ); |
1283 | #endif | 1297 | #endif |
1284 | } | 1298 | } |
1285 | 1299 | ||
1286 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1300 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1287 | { | 1301 | { |
1288 | if ( !incidence ) { | 1302 | if ( !incidence ) { |
1289 | enableIncidenceActions( false ); | 1303 | enableIncidenceActions( false ); |
1290 | 1304 | ||
1291 | mNewSubTodoAction->setEnabled( false ); | 1305 | mNewSubTodoAction->setEnabled( false ); |
1292 | setCaptionToDates(); | 1306 | setCaptionToDates(); |
1293 | return; | 1307 | return; |
1294 | 1308 | ||
1295 | } | 1309 | } |
1296 | 1310 | ||
1297 | //KGlobal::locale()->formatDateTime(nextA, true); | 1311 | //KGlobal::locale()->formatDateTime(nextA, true); |
1298 | QString startString = ""; | 1312 | QString startString = ""; |
1299 | if ( incidence->type() != "Todo" ) { | 1313 | if ( incidence->type() != "Todo" ) { |
1300 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1314 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1301 | if ( incidence->doesFloat() ) { | 1315 | if ( incidence->doesFloat() ) { |
1302 | startString += ": "+incidence->dtStartDateStr( true ); | 1316 | startString += ": "+incidence->dtStartDateStr( true ); |
1303 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1317 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1304 | 1318 | ||
1305 | } else { | 1319 | } else { |
1306 | startString = ": "+incidence->dtStartStr(true); | 1320 | startString = ": "+incidence->dtStartStr(true); |
1307 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1321 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1308 | 1322 | ||
1309 | } | 1323 | } |
1310 | 1324 | ||
1311 | } else { | 1325 | } else { |
1312 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1326 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1313 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1327 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1314 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1328 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1315 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1329 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1316 | } | 1330 | } |
1317 | 1331 | ||
1318 | } | 1332 | } |
1319 | else | 1333 | else |
1320 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1334 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1321 | if ( !incidence->location().isEmpty() ) | 1335 | if ( !incidence->location().isEmpty() ) |
1322 | startString += " (" +incidence->location()+")"; | 1336 | startString += " (" +incidence->location()+")"; |
1323 | setCaption( incidence->summary()+startString); | 1337 | setCaption( incidence->summary()+startString); |
1324 | 1338 | ||
1325 | enableIncidenceActions( true ); | 1339 | enableIncidenceActions( true ); |
1326 | 1340 | ||
1327 | if ( incidence->type() == "Event" ) { | 1341 | if ( incidence->type() == "Event" ) { |
1328 | mShowAction->setText( i18n("Show Event...") ); | 1342 | mShowAction->setText( i18n("Show Event...") ); |
1329 | mEditAction->setText( i18n("Edit Event...") ); | 1343 | mEditAction->setText( i18n("Edit Event...") ); |
1330 | mDeleteAction->setText( i18n("Delete Event...") ); | 1344 | mDeleteAction->setText( i18n("Delete Event...") ); |
1331 | 1345 | ||
1332 | mNewSubTodoAction->setEnabled( false ); | 1346 | mNewSubTodoAction->setEnabled( false ); |
1333 | } else if ( incidence->type() == "Todo" ) { | 1347 | } else if ( incidence->type() == "Todo" ) { |
1334 | mShowAction->setText( i18n("Show Todo...") ); | 1348 | mShowAction->setText( i18n("Show Todo...") ); |
1335 | mEditAction->setText( i18n("Edit Todo...") ); | 1349 | mEditAction->setText( i18n("Edit Todo...") ); |
1336 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1350 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1337 | 1351 | ||
1338 | mNewSubTodoAction->setEnabled( true ); | 1352 | mNewSubTodoAction->setEnabled( true ); |
1339 | } else { | 1353 | } else { |
1340 | mShowAction->setText( i18n("Show...") ); | 1354 | mShowAction->setText( i18n("Show...") ); |
1341 | mShowAction->setText( i18n("Edit...") ); | 1355 | mShowAction->setText( i18n("Edit...") ); |
1342 | mShowAction->setText( i18n("Delete...") ); | 1356 | mShowAction->setText( i18n("Delete...") ); |
1343 | 1357 | ||
1344 | mNewSubTodoAction->setEnabled( false ); | 1358 | mNewSubTodoAction->setEnabled( false ); |
1345 | } | 1359 | } |
1346 | } | 1360 | } |
1347 | 1361 | ||
1348 | void MainWindow::enableIncidenceActions( bool enabled ) | 1362 | void MainWindow::enableIncidenceActions( bool enabled ) |
1349 | { | 1363 | { |
1350 | mShowAction->setEnabled( enabled ); | 1364 | mShowAction->setEnabled( enabled ); |
1351 | mEditAction->setEnabled( enabled ); | 1365 | mEditAction->setEnabled( enabled ); |
1352 | mDeleteAction->setEnabled( enabled ); | 1366 | mDeleteAction->setEnabled( enabled ); |
1353 | 1367 | ||
1354 | mCloneAction->setEnabled( enabled ); | 1368 | mCloneAction->setEnabled( enabled ); |
1355 | mMoveAction->setEnabled( enabled ); | 1369 | mMoveAction->setEnabled( enabled ); |
1356 | mBeamAction->setEnabled( enabled ); | 1370 | mBeamAction->setEnabled( enabled ); |
1357 | mCancelAction->setEnabled( enabled ); | 1371 | mCancelAction->setEnabled( enabled ); |
1358 | } | 1372 | } |
1359 | 1373 | ||
1360 | void MainWindow::importOL() | 1374 | void MainWindow::importOL() |
1361 | { | 1375 | { |
1362 | #ifdef _WIN32_ | 1376 | #ifdef _WIN32_ |
1363 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1377 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1364 | id->exec(); | 1378 | id->exec(); |
1365 | delete id; | 1379 | delete id; |
1366 | mView->updateView(); | 1380 | mView->updateView(); |
1367 | #endif | 1381 | #endif |
1368 | } | 1382 | } |
1369 | void MainWindow::importBday() | 1383 | void MainWindow::importBday() |
1370 | { | 1384 | { |
1371 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1385 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1372 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1386 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1373 | i18n("Import!"), i18n("Cancel"), 0, | 1387 | i18n("Import!"), i18n("Cancel"), 0, |
1374 | 0, 1 ); | 1388 | 0, 1 ); |
1375 | if ( result == 0 ) { | 1389 | if ( result == 0 ) { |
1376 | mView->importBday(); | 1390 | mView->importBday(); |
1377 | 1391 | ||
1378 | } | 1392 | } |
1379 | 1393 | ||
1380 | 1394 | ||
1381 | } | 1395 | } |
1382 | void MainWindow::importQtopia() | 1396 | void MainWindow::importQtopia() |
1383 | { | 1397 | { |
1384 | #ifndef DESKTOP_VERSION | 1398 | #ifndef DESKTOP_VERSION |
1385 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1399 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1386 | 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"), | 1400 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1387 | i18n("Import!"), i18n("Cancel"), 0, | 1401 | i18n("Import!"), i18n("Cancel"), 0, |
1388 | 0, 1 ); | 1402 | 0, 1 ); |
1389 | if ( result == 0 ) { | 1403 | if ( result == 0 ) { |
1390 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1404 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1391 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1405 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1392 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1406 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1393 | mView->importQtopia( categories, datebook, todolist ); | 1407 | mView->importQtopia( categories, datebook, todolist ); |
1394 | } | 1408 | } |
1395 | #else | 1409 | #else |
1396 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1410 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1397 | i18n("Not supported \non desktop!\n"), | 1411 | i18n("Not supported \non desktop!\n"), |
1398 | i18n("Ok"), i18n("Cancel"), 0, | 1412 | i18n("Ok"), i18n("Cancel"), 0, |
1399 | 0, 1 ); | 1413 | 0, 1 ); |
1400 | 1414 | ||
1401 | #endif | 1415 | #endif |
1402 | } | 1416 | } |
1403 | 1417 | ||
1404 | void MainWindow::saveOnClose() | 1418 | void MainWindow::saveOnClose() |
1405 | { | 1419 | { |
1406 | KOPrefs *p = KOPrefs::instance(); | 1420 | KOPrefs *p = KOPrefs::instance(); |
1407 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1421 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1408 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1422 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1409 | iconToolBar->y() > height()/2; | 1423 | iconToolBar->y() > height()/2; |
1410 | mView->writeSettings(); | 1424 | mView->writeSettings(); |
1411 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1425 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1412 | save(); | 1426 | save(); |
1413 | } | 1427 | } |
1414 | void MainWindow::slotModifiedChanged( bool changed ) | 1428 | void MainWindow::slotModifiedChanged( bool changed ) |
1415 | { | 1429 | { |
1416 | if ( mBlockAtStartup ) | 1430 | if ( mBlockAtStartup ) |
1417 | return; | 1431 | return; |
1418 | int msec; | 1432 | int msec; |
1419 | // we store the changes after 1 minute, | 1433 | // we store the changes after 1 minute, |
1420 | // and for safety reasons after 10 minutes again | 1434 | // and for safety reasons after 10 minutes again |
1421 | if ( !mSyncManager->blockSave() ) | 1435 | if ( !mSyncManager->blockSave() ) |
1422 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1436 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1423 | else | 1437 | else |
1424 | msec = 1000 * 600; | 1438 | msec = 1000 * 600; |
1425 | mSaveTimer.start( msec, true ); // 1 minute | 1439 | mSaveTimer.start( msec, true ); // 1 minute |
1426 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1440 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1427 | mCalendarModifiedFlag = true; | 1441 | mCalendarModifiedFlag = true; |
1428 | } | 1442 | } |
1429 | void MainWindow::save() | 1443 | void MainWindow::save() |
1430 | { | 1444 | { |
1431 | if ( mSyncManager->blockSave() ) | 1445 | if ( mSyncManager->blockSave() ) |
1432 | return; | 1446 | return; |
1433 | mSyncManager->setBlockSave(true); | 1447 | mSyncManager->setBlockSave(true); |
1434 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1448 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1435 | 1449 | ||
1436 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1450 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1437 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1451 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1438 | qDebug("KO: Start saving data to file!"); | 1452 | qDebug("KO: Start saving data to file!"); |
1439 | mView->saveCalendar( defaultFileName() ); | 1453 | mView->saveCalendar( defaultFileName() ); |
1440 | 1454 | ||
1441 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1455 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1442 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1456 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1443 | QString savemes; | 1457 | QString savemes; |
1444 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1458 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1445 | setCaption(savemes); | 1459 | setCaption(savemes); |
1446 | } else | 1460 | } else |
1447 | setCaption(i18n("Saving cancelled!")); | 1461 | setCaption(i18n("Saving cancelled!")); |
1448 | mCalendarModifiedFlag = false; | 1462 | mCalendarModifiedFlag = false; |
1449 | mSyncManager->setBlockSave( false ); | 1463 | mSyncManager->setBlockSave( false ); |
1450 | } | 1464 | } |
1451 | 1465 | ||
1452 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1466 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1453 | { | 1467 | { |
1454 | if ( !e->isAutoRepeat() ) { | 1468 | if ( !e->isAutoRepeat() ) { |
1455 | mFlagKeyPressed = false; | 1469 | mFlagKeyPressed = false; |
1456 | } | 1470 | } |
1457 | } | 1471 | } |
1458 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1472 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1459 | { | 1473 | { |
1460 | qApp->processEvents(); | 1474 | qApp->processEvents(); |
1461 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1475 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1462 | e->ignore(); | 1476 | e->ignore(); |
1463 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1477 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1464 | return; | 1478 | return; |
1465 | } | 1479 | } |
1466 | if (! e->isAutoRepeat() ) | 1480 | if (! e->isAutoRepeat() ) |
1467 | mFlagKeyPressed = true; | 1481 | mFlagKeyPressed = true; |
1468 | KOPrefs *p = KOPrefs::instance(); | 1482 | KOPrefs *p = KOPrefs::instance(); |
1469 | bool showSelectedDates = false; | 1483 | bool showSelectedDates = false; |
1470 | int size; | 1484 | int size; |
1471 | int pro = 0; | 1485 | int pro = 0; |
1472 | //qDebug("MainWindow::keyPressEvent "); | 1486 | //qDebug("MainWindow::keyPressEvent "); |
1473 | switch ( e->key() ) { | 1487 | switch ( e->key() ) { |
1474 | case Qt::Key_Right: | 1488 | case Qt::Key_Right: |
1475 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1489 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1476 | mView->goNextMonth(); | 1490 | mView->goNextMonth(); |
1477 | else | 1491 | else |
1478 | mView->goNext(); | 1492 | mView->goNext(); |
1479 | showSelectedDates = true; | 1493 | showSelectedDates = true; |
1480 | break; | 1494 | break; |
1481 | case Qt::Key_Left: | 1495 | case Qt::Key_Left: |
1482 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1496 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1483 | mView->goPreviousMonth(); | 1497 | mView->goPreviousMonth(); |
1484 | else | 1498 | else |
1485 | mView->goPrevious(); | 1499 | mView->goPrevious(); |
1486 | showSelectedDates = true; | 1500 | showSelectedDates = true; |
1487 | break; | 1501 | break; |
1488 | case Qt::Key_Down: | 1502 | case Qt::Key_Down: |
1489 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1503 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1490 | break; | 1504 | break; |
1491 | case Qt::Key_Up: | 1505 | case Qt::Key_Up: |
1492 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1506 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1493 | break; | 1507 | break; |
1494 | case Qt::Key_I: | 1508 | case Qt::Key_I: |
1495 | mView->showIncidence(); | 1509 | mView->showIncidence(); |
1496 | break; | 1510 | break; |
1497 | case Qt::Key_Delete: | 1511 | case Qt::Key_Delete: |
1498 | case Qt::Key_Backspace: | 1512 | case Qt::Key_Backspace: |
1499 | mView->deleteIncidence(); | 1513 | mView->deleteIncidence(); |
1500 | break; | 1514 | break; |
1501 | case Qt::Key_D: | 1515 | case Qt::Key_D: |
1502 | mView->viewManager()->showDayView(); | 1516 | mView->viewManager()->showDayView(); |
1503 | showSelectedDates = true; | 1517 | showSelectedDates = true; |
1504 | break; | 1518 | break; |
1505 | case Qt::Key_O: | 1519 | case Qt::Key_O: |
1506 | mView->toggleFilerEnabled( ); | 1520 | mView->toggleFilerEnabled( ); |
1507 | break; | 1521 | break; |
1508 | case Qt::Key_0: | 1522 | case Qt::Key_0: |
1509 | case Qt::Key_1: | 1523 | case Qt::Key_1: |
1510 | case Qt::Key_2: | 1524 | case Qt::Key_2: |
1511 | case Qt::Key_3: | 1525 | case Qt::Key_3: |
1512 | case Qt::Key_4: | 1526 | case Qt::Key_4: |
1513 | case Qt::Key_5: | 1527 | case Qt::Key_5: |
1514 | case Qt::Key_6: | 1528 | case Qt::Key_6: |
1515 | case Qt::Key_7: | 1529 | case Qt::Key_7: |
1516 | case Qt::Key_8: | 1530 | case Qt::Key_8: |
1517 | case Qt::Key_9: | 1531 | case Qt::Key_9: |
1518 | pro = e->key()-48; | 1532 | pro = e->key()-48; |
1519 | if ( pro == 0 ) | 1533 | if ( pro == 0 ) |
1520 | pro = 10; | 1534 | pro = 10; |
1521 | if ( e->state() == Qt::ControlButton) | 1535 | if ( e->state() == Qt::ControlButton) |
1522 | pro += 10; | 1536 | pro += 10; |
1523 | break; | 1537 | break; |
1524 | case Qt::Key_M: | 1538 | case Qt::Key_M: |
1525 | mView->viewManager()->showMonthView(); | 1539 | mView->viewManager()->showMonthView(); |
1526 | showSelectedDates = true; | 1540 | showSelectedDates = true; |
1527 | break; | 1541 | break; |
1528 | case Qt::Key_Insert: | 1542 | case Qt::Key_Insert: |
1529 | mView->newEvent(); | 1543 | mView->newEvent(); |
1530 | break; | 1544 | break; |
1531 | case Qt::Key_S : | 1545 | case Qt::Key_S : |
1532 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1546 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1533 | mView->newSubTodo(); | 1547 | mView->newSubTodo(); |
1534 | else | 1548 | else |
1535 | mView->dialogManager()->showSearchDialog(); | 1549 | mView->dialogManager()->showSearchDialog(); |
1536 | break; | 1550 | break; |
1537 | case Qt::Key_Y : | 1551 | case Qt::Key_Y : |
1538 | case Qt::Key_Z : | 1552 | case Qt::Key_Z : |
1539 | mView->viewManager()->showWorkWeekView(); | 1553 | mView->viewManager()->showWorkWeekView(); |
1540 | showSelectedDates = true; | 1554 | showSelectedDates = true; |
1541 | break; | 1555 | break; |
1542 | case Qt::Key_U : | 1556 | case Qt::Key_U : |
1543 | mView->viewManager()->showWeekView(); | 1557 | mView->viewManager()->showWeekView(); |
1544 | showSelectedDates = true; | 1558 | showSelectedDates = true; |
1545 | break; | 1559 | break; |
1546 | case Qt::Key_H : | 1560 | case Qt::Key_H : |
1547 | keyBindings(); | 1561 | keyBindings(); |
1548 | break; | 1562 | break; |
1549 | case Qt::Key_W: | 1563 | case Qt::Key_W: |
1550 | mView->viewManager()->showWhatsNextView(); | 1564 | mView->viewManager()->showWhatsNextView(); |
1551 | break; | 1565 | break; |
1552 | case Qt::Key_L: | 1566 | case Qt::Key_L: |
1553 | mView->viewManager()->showListView(); | 1567 | mView->viewManager()->showListView(); |
1554 | break; | 1568 | break; |
1555 | case Qt::Key_N: | 1569 | case Qt::Key_N: |
1556 | mView->viewManager()->showNextXView(); | 1570 | mView->viewManager()->showNextXView(); |
1557 | showSelectedDates = true; | 1571 | showSelectedDates = true; |
1558 | break; | 1572 | break; |
1559 | case Qt::Key_V: | 1573 | case Qt::Key_V: |
1560 | mView->viewManager()->showTodoView(); | 1574 | mView->viewManager()->showTodoView(); |
1561 | break; | 1575 | break; |
1562 | case Qt::Key_C: | 1576 | case Qt::Key_C: |
1563 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1577 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1564 | break; | 1578 | break; |
1565 | case Qt::Key_P: | 1579 | case Qt::Key_P: |
1566 | mView->showDatePicker( ); | 1580 | mView->showDatePicker( ); |
1567 | break; | 1581 | break; |
1568 | case Qt::Key_F: | 1582 | case Qt::Key_F: |
1569 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1583 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1570 | mView->editFilters(); | 1584 | mView->editFilters(); |
1571 | else | 1585 | else |
1572 | mView->toggleFilter(); | 1586 | mView->toggleFilter(); |
1573 | break; | 1587 | break; |
1574 | case Qt::Key_X: | 1588 | case Qt::Key_X: |
1575 | mView->toggleDateNavigatorWidget(); | 1589 | mView->toggleDateNavigatorWidget(); |
1576 | break; | 1590 | break; |
1577 | case Qt::Key_Space: | 1591 | case Qt::Key_Space: |
1578 | mView->toggleExpand(); | 1592 | mView->toggleExpand(); |
1579 | break; | 1593 | break; |
1580 | case Qt::Key_A: | 1594 | case Qt::Key_A: |
1581 | mView->toggleAllDaySize(); | 1595 | mView->toggleAllDaySize(); |
1582 | break; | 1596 | break; |
1583 | case Qt::Key_T: | 1597 | case Qt::Key_T: |
1584 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1598 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1585 | mView->newTodo(); | 1599 | mView->newTodo(); |
1586 | else { | 1600 | else { |
1587 | mView->goToday(); | 1601 | mView->goToday(); |
1588 | showSelectedDates = true; | 1602 | showSelectedDates = true; |
1589 | } | 1603 | } |
1590 | break; | 1604 | break; |
1591 | case Qt::Key_J: | 1605 | case Qt::Key_J: |
1592 | mView->viewManager()->showJournalView(); | 1606 | mView->viewManager()->showJournalView(); |
1593 | break; | 1607 | break; |
1594 | case Qt::Key_B: | 1608 | case Qt::Key_B: |
1595 | mView->editIncidenceDescription();; | 1609 | mView->editIncidenceDescription();; |
1596 | break; | 1610 | break; |
1597 | // case Qt::Key_Return: | 1611 | // case Qt::Key_Return: |
1598 | case Qt::Key_E: | 1612 | case Qt::Key_E: |
1599 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1613 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1600 | mView->newEvent(); | 1614 | mView->newEvent(); |
1601 | else | 1615 | else |
1602 | mView->editIncidence(); | 1616 | mView->editIncidence(); |
1603 | break; | 1617 | break; |
1604 | case Qt::Key_Plus: | 1618 | case Qt::Key_Plus: |
1605 | size = p->mHourSize +2; | 1619 | size = p->mHourSize +2; |
1606 | if ( size <= 18 ) | 1620 | if ( size <= 18 ) |
1607 | configureAgenda( size ); | 1621 | configureAgenda( size ); |
1608 | break; | 1622 | break; |
1609 | case Qt::Key_Minus: | 1623 | case Qt::Key_Minus: |
1610 | size = p->mHourSize - 2; | 1624 | size = p->mHourSize - 2; |
1611 | if ( size >= 4 ) | 1625 | if ( size >= 4 ) |
1612 | configureAgenda( size ); | 1626 | configureAgenda( size ); |
1613 | break; | 1627 | break; |
1614 | 1628 | ||
1615 | 1629 | ||
1616 | default: | 1630 | default: |
1617 | e->ignore(); | 1631 | e->ignore(); |
1618 | } | 1632 | } |
1619 | if ( pro > 0 ) { | 1633 | if ( pro > 0 ) { |
1620 | mView->selectFilter( pro-1 ); | 1634 | mView->selectFilter( pro-1 ); |
1621 | } | 1635 | } |
1622 | if ( showSelectedDates ) { | 1636 | if ( showSelectedDates ) { |
1623 | ;// setCaptionToDates(); | 1637 | ;// setCaptionToDates(); |
1624 | } | 1638 | } |
1625 | 1639 | ||
1626 | } | 1640 | } |
1627 | 1641 | ||
1628 | void MainWindow::fillFilterMenu() | 1642 | void MainWindow::fillFilterMenu() |
1629 | { | 1643 | { |
1630 | selectFilterMenu->clear(); | 1644 | selectFilterMenu->clear(); |
1631 | bool disable = false; | 1645 | bool disable = false; |
1632 | if ( mView->filterView()->filtersEnabled() ) { | 1646 | if ( mView->filterView()->filtersEnabled() ) { |
1633 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1647 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1634 | } | 1648 | } |
1635 | else { | 1649 | else { |
1636 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1650 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1637 | disable = true; | 1651 | disable = true; |
1638 | } | 1652 | } |
1639 | selectFilterMenu->insertSeparator(); | 1653 | selectFilterMenu->insertSeparator(); |
1640 | QPtrList<CalFilter> fili = mView->filters(); | 1654 | QPtrList<CalFilter> fili = mView->filters(); |
1641 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1655 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1642 | CalFilter *filter = fili.first(); | 1656 | CalFilter *filter = fili.first(); |
1643 | int iii = 1; | 1657 | int iii = 1; |
1644 | while(filter) { | 1658 | while(filter) { |
1645 | selectFilterMenu->insertItem( filter->name(), iii ); | 1659 | selectFilterMenu->insertItem( filter->name(), iii ); |
1646 | if ( filter == curfilter) | 1660 | if ( filter == curfilter) |
1647 | selectFilterMenu->setItemChecked( iii, true ); | 1661 | selectFilterMenu->setItemChecked( iii, true ); |
1648 | if ( disable ) | 1662 | if ( disable ) |
1649 | selectFilterMenu->setItemEnabled( iii, false ); | 1663 | selectFilterMenu->setItemEnabled( iii, false ); |
1650 | filter = fili.next(); | 1664 | filter = fili.next(); |
1651 | ++iii; | 1665 | ++iii; |
1652 | } | 1666 | } |
1653 | } | 1667 | } |
1654 | void MainWindow::selectFilter( int fil ) | 1668 | void MainWindow::selectFilter( int fil ) |
1655 | { | 1669 | { |
1656 | if ( fil == 0 ) { | 1670 | if ( fil == 0 ) { |
1657 | mView->toggleFilerEnabled( ); | 1671 | mView->toggleFilerEnabled( ); |
1658 | } else { | 1672 | } else { |
1659 | mView->selectFilter( fil-1 ); | 1673 | mView->selectFilter( fil-1 ); |
1660 | } | 1674 | } |
1661 | } | 1675 | } |
1662 | void MainWindow::configureToolBar( int item ) | 1676 | void MainWindow::configureToolBar( int item ) |
1663 | { | 1677 | { |
1664 | 1678 | ||
1665 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1679 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1666 | KOPrefs *p = KOPrefs::instance(); | 1680 | KOPrefs *p = KOPrefs::instance(); |
1667 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1681 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1668 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1682 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1669 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1683 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1670 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1684 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1671 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1685 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1672 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1686 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1673 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1687 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1674 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1688 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1675 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1689 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1676 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1690 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1677 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1691 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1678 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1692 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1679 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1693 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1680 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1694 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1681 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1695 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1682 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1696 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1683 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1697 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1684 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1698 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1685 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1699 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1686 | // initActions(); | 1700 | // initActions(); |
1687 | } | 1701 | } |
1688 | 1702 | ||
1689 | void MainWindow::setCaptionToDates() | 1703 | void MainWindow::setCaptionToDates() |
1690 | { | 1704 | { |
1691 | QString selDates; | 1705 | QString selDates; |
1692 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1706 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1693 | if (mView->startDate() < mView->endDate() ) | 1707 | if (mView->startDate() < mView->endDate() ) |
1694 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1708 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1695 | setCaption( i18n("Dates: ") + selDates ); | 1709 | setCaption( i18n("Dates: ") + selDates ); |
1696 | 1710 | ||
1697 | } | 1711 | } |
1698 | // parameter item == 0: reinit | 1712 | // parameter item == 0: reinit |
1699 | void MainWindow::configureAgenda( int item ) | 1713 | void MainWindow::configureAgenda( int item ) |
1700 | { | 1714 | { |
1701 | 1715 | ||
1702 | KOPrefs *p = KOPrefs::instance(); | 1716 | KOPrefs *p = KOPrefs::instance(); |
1703 | 1717 | ||
1704 | int i; | 1718 | int i; |
1705 | if ( item == 1 ) { | 1719 | if ( item == 1 ) { |
1706 | mView->toggleAllDaySize(); | 1720 | mView->toggleAllDaySize(); |
1707 | return; | 1721 | return; |
1708 | } | 1722 | } |
1709 | // do not allow 4 for widgets higher than 480 | 1723 | // do not allow 4 for widgets higher than 480 |
1710 | // if ( QApplication::desktop()->height() > 480 ) { | 1724 | // if ( QApplication::desktop()->height() > 480 ) { |
1711 | // if ( item == 4 ) | 1725 | // if ( item == 4 ) |
1712 | // item = 6; | 1726 | // item = 6; |
1713 | // } | 1727 | // } |
1714 | for ( i = 4; i <= 18; i= i+2 ) | 1728 | for ( i = 4; i <= 18; i= i+2 ) |
1715 | configureAgendaMenu->setItemChecked( i, false ); | 1729 | configureAgendaMenu->setItemChecked( i, false ); |
1716 | configureAgendaMenu->setItemChecked( item, true ); | 1730 | configureAgendaMenu->setItemChecked( item, true ); |
1717 | if ( p->mHourSize == item ) | 1731 | if ( p->mHourSize == item ) |
1718 | return; | 1732 | return; |
1719 | p->mHourSize=item; | 1733 | p->mHourSize=item; |
1720 | mView->viewManager()->agendaView()->updateConfig(); | 1734 | mView->viewManager()->agendaView()->updateConfig(); |
1721 | } | 1735 | } |
1722 | 1736 | ||
1723 | void MainWindow::saveCalendar() | 1737 | void MainWindow::saveCalendar() |
1724 | { | 1738 | { |
1725 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1739 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1726 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1740 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1727 | 1741 | ||
1728 | if ( fn == "" ) | 1742 | if ( fn == "" ) |
1729 | return; | 1743 | return; |
1730 | QFileInfo info; | 1744 | QFileInfo info; |
1731 | info.setFile( fn ); | 1745 | info.setFile( fn ); |
1732 | QString mes; | 1746 | QString mes; |
1733 | bool createbup = true; | 1747 | bool createbup = true; |
1734 | if ( info. exists() ) { | 1748 | if ( info. exists() ) { |
1735 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1749 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1736 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1750 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1737 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1751 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1738 | 0, 1 ); | 1752 | 0, 1 ); |
1739 | if ( result != 0 ) { | 1753 | if ( result != 0 ) { |
1740 | createbup = false; | 1754 | createbup = false; |
1741 | } | 1755 | } |
1742 | } | 1756 | } |
1743 | if ( createbup ) { | 1757 | if ( createbup ) { |
1744 | mView->saveCalendar( fn ); | 1758 | mView->saveCalendar( fn ); |
1745 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1759 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1746 | KOPrefs::instance()->mLastSaveFile = fn; | 1760 | KOPrefs::instance()->mLastSaveFile = fn; |
1747 | setCaption(mes); | 1761 | setCaption(mes); |
1748 | } | 1762 | } |
1749 | } | 1763 | } |
1750 | void MainWindow::loadCalendar() | 1764 | void MainWindow::loadCalendar() |
1751 | { | 1765 | { |
1752 | 1766 | ||
1753 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1767 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1754 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1768 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1755 | 1769 | ||
1756 | if ( fn == "" ) | 1770 | if ( fn == "" ) |
1757 | return; | 1771 | return; |
1758 | QFileInfo info; | 1772 | QFileInfo info; |
1759 | info.setFile( fn ); | 1773 | info.setFile( fn ); |
1760 | QString mess; | 1774 | QString mess; |
1761 | bool loadbup = true; | 1775 | bool loadbup = true; |
1762 | if ( info. exists() ) { | 1776 | if ( info. exists() ) { |
1763 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1777 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1764 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1778 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1765 | mess, | 1779 | mess, |
1766 | i18n("Load!"), i18n("Cancel"), 0, | 1780 | i18n("Load!"), i18n("Cancel"), 0, |
1767 | 0, 1 ); | 1781 | 0, 1 ); |
1768 | if ( result != 0 ) { | 1782 | if ( result != 0 ) { |
1769 | loadbup = false; | 1783 | loadbup = false; |
1770 | } | 1784 | } |
1771 | } else { | 1785 | } else { |
1772 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1786 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1773 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1787 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1774 | 0, 1 ); | 1788 | 0, 1 ); |
1775 | 1789 | ||
1776 | return; | 1790 | return; |
1777 | } | 1791 | } |
1778 | if ( loadbup ) { | 1792 | if ( loadbup ) { |
1779 | mView->openCalendar( fn ); | 1793 | mView->openCalendar( fn ); |
1780 | KOPrefs::instance()->mLastLoadFile = fn; | 1794 | KOPrefs::instance()->mLastLoadFile = fn; |
1781 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1795 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1782 | setCaption(mess); | 1796 | setCaption(mess); |
1783 | } | 1797 | } |
1784 | 1798 | ||
1785 | } | 1799 | } |
1786 | void MainWindow::quickImportIcal() | 1800 | void MainWindow::quickImportIcal() |
1787 | { | 1801 | { |
1788 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1802 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1789 | } | 1803 | } |
1790 | void MainWindow::importFile( QString fn, bool quick ) | 1804 | void MainWindow::importFile( QString fn, bool quick ) |
1791 | { | 1805 | { |
1792 | QFileInfo info; | 1806 | QFileInfo info; |
1793 | info.setFile( fn ); | 1807 | info.setFile( fn ); |
1794 | QString mess; | 1808 | QString mess; |
1795 | bool loadbup = true; | 1809 | bool loadbup = true; |
1796 | if ( !info. exists() ) { | 1810 | if ( !info. exists() ) { |
1797 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1811 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1798 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1812 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1799 | mess ); | 1813 | mess ); |
1800 | return; | 1814 | return; |
1801 | } | 1815 | } |
1802 | int result = 0; | 1816 | int result = 0; |
1803 | if ( !quick ) { | 1817 | if ( !quick ) { |
1804 | 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 )); | 1818 | 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 )); |
1805 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1819 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1806 | mess, | 1820 | mess, |
1807 | "Import", "Cancel", 0, | 1821 | "Import", "Cancel", 0, |
1808 | 0, 1 ); | 1822 | 0, 1 ); |
1809 | } | 1823 | } |
1810 | if ( result == 0 ) { | 1824 | if ( result == 0 ) { |
1811 | if ( mView->openCalendar( fn, true )) { | 1825 | if ( mView->openCalendar( fn, true )) { |
1812 | KOPrefs::instance()->mLastImportFile = fn; | 1826 | KOPrefs::instance()->mLastImportFile = fn; |
1813 | setCaption(i18n("Imported file successfully")); | 1827 | setCaption(i18n("Imported file successfully")); |
1814 | } else { | 1828 | } else { |
1815 | setCaption(i18n("Error importing file")); | 1829 | setCaption(i18n("Error importing file")); |
1816 | } | 1830 | } |
1817 | } | 1831 | } |
1818 | } | 1832 | } |
1819 | 1833 | ||
1820 | void MainWindow::importIcal() | 1834 | void MainWindow::importIcal() |
1821 | { | 1835 | { |
1822 | 1836 | ||
1823 | QString fn =KOPrefs::instance()->mLastImportFile; | 1837 | QString fn =KOPrefs::instance()->mLastImportFile; |
1824 | 1838 | ||
1825 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1839 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1826 | if ( fn == "" ) | 1840 | if ( fn == "" ) |
1827 | return; | 1841 | return; |
1828 | importFile( fn, true ); | 1842 | importFile( fn, true ); |
1829 | 1843 | ||
1830 | } | 1844 | } |
1831 | 1845 | ||
1832 | void MainWindow::exportVCalendar() | 1846 | void MainWindow::exportVCalendar() |
1833 | { | 1847 | { |
1834 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1848 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1835 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1849 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1836 | if ( fn == "" ) | 1850 | if ( fn == "" ) |
1837 | return; | 1851 | return; |
1838 | QFileInfo info; | 1852 | QFileInfo info; |
1839 | info.setFile( fn ); | 1853 | info.setFile( fn ); |
1840 | QString mes; | 1854 | QString mes; |
1841 | bool createbup = true; | 1855 | bool createbup = true; |
1842 | if ( info. exists() ) { | 1856 | if ( info. exists() ) { |
1843 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1857 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1844 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1858 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1845 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1859 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1846 | 0, 1 ); | 1860 | 0, 1 ); |
1847 | if ( result != 0 ) { | 1861 | if ( result != 0 ) { |
1848 | createbup = false; | 1862 | createbup = false; |
1849 | } | 1863 | } |
1850 | } | 1864 | } |
1851 | if ( createbup ) { | 1865 | if ( createbup ) { |
1852 | if ( mView->exportVCalendar( fn ) ) { | 1866 | if ( mView->exportVCalendar( fn ) ) { |
1853 | KOPrefs::instance()->mLastVcalFile = fn; | 1867 | KOPrefs::instance()->mLastVcalFile = fn; |
1854 | if ( fn.length() > 20 ) | 1868 | if ( fn.length() > 20 ) |
1855 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1869 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1856 | else | 1870 | else |
1857 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1871 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1858 | setCaption(mes); | 1872 | setCaption(mes); |
1859 | } | 1873 | } |
1860 | } | 1874 | } |
1861 | 1875 | ||
1862 | } | 1876 | } |
1863 | 1877 | ||
1864 | void MainWindow::syncFileRequest() | 1878 | void MainWindow::syncFileRequest() |
1865 | { | 1879 | { |
1866 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 1880 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
1867 | mSyncManager->slotSyncMenu( 999 ); | 1881 | mSyncManager->slotSyncMenu( 999 ); |
1868 | } | 1882 | } |
1869 | save(); | 1883 | save(); |
1870 | } | 1884 | } |
1871 | void MainWindow::getFile( bool success ) | 1885 | void MainWindow::getFile( bool success ) |
1872 | { | 1886 | { |
1873 | if ( ! success ) { | 1887 | if ( ! success ) { |
1874 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 1888 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
1875 | return; | 1889 | return; |
1876 | } | 1890 | } |
1877 | mView->openCalendar( defaultFileName() ); | 1891 | mView->openCalendar( defaultFileName() ); |
1878 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 1892 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
1879 | mSyncManager->slotSyncMenu( 999 ); | 1893 | mSyncManager->slotSyncMenu( 999 ); |
1880 | } | 1894 | } |
1881 | setCaption( i18n("Pi-Sync successful!") ); | 1895 | setCaption( i18n("Pi-Sync successful!") ); |
1882 | } | 1896 | } |
1883 | 1897 | ||
1884 | void MainWindow::printSel( ) | 1898 | void MainWindow::printSel( ) |
1885 | { | 1899 | { |
1886 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 1900 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
1887 | } | 1901 | } |
1888 | 1902 | ||
1889 | void MainWindow::printCal() | 1903 | void MainWindow::printCal() |
1890 | { | 1904 | { |
1891 | mView->print();//mCp->showDialog(); | 1905 | mView->print();//mCp->showDialog(); |
1892 | } | 1906 | } |
1893 | 1907 | ||
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 0926313..ed65d36 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,138 +1,140 @@ | |||
1 | #ifndef KORGE_MAINWINDOW_H | 1 | #ifndef KORGE_MAINWINDOW_H |
2 | #define KORGE_MAINWINDOW_H | 2 | #define KORGE_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qtextstream.h> | 8 | #include <qtextstream.h> |
9 | #include <qregexp.h> | 9 | #include <qregexp.h> |
10 | 10 | ||
11 | #include <libkcal/incidence.h> | 11 | #include <libkcal/incidence.h> |
12 | #include "simplealarmclient.h" | 12 | #include "simplealarmclient.h" |
13 | #include <ksyncmanager.h> | 13 | #include <ksyncmanager.h> |
14 | #ifndef DESKTOP_VERSION | 14 | #ifndef DESKTOP_VERSION |
15 | #include <qcopchannel_qws.h> | 15 | #include <qcopchannel_qws.h> |
16 | #endif | 16 | #endif |
17 | class QAction; | 17 | class QAction; |
18 | class CalendarView; | 18 | class CalendarView; |
19 | class KSyncProfile; | 19 | class KSyncProfile; |
20 | #ifdef DESKTOP_VERSION | 20 | #ifdef DESKTOP_VERSION |
21 | 21 | ||
22 | #define QPEToolBar QToolBar | 22 | #define QPEToolBar QToolBar |
23 | #define QPEMenuBar QMenuBar | 23 | #define QPEMenuBar QMenuBar |
24 | #endif | 24 | #endif |
25 | class QPEToolBar; | 25 | class QPEToolBar; |
26 | 26 | ||
27 | 27 | ||
28 | namespace KCal { | 28 | namespace KCal { |
29 | class CalendarLocal; | 29 | class CalendarLocal; |
30 | } | 30 | } |
31 | 31 | ||
32 | using namespace KCal; | 32 | using namespace KCal; |
33 | 33 | ||
34 | class MainWindow : public QMainWindow | 34 | class MainWindow : public QMainWindow |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 38 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
39 | ~MainWindow(); | 39 | ~MainWindow(); |
40 | bool beamReceiveEnabled(); | 40 | bool beamReceiveEnabled(); |
41 | public slots: | 41 | public slots: |
42 | virtual void showMaximized (); | 42 | virtual void showMaximized (); |
43 | void configureAgenda( int ); | 43 | void configureAgenda( int ); |
44 | void recieve( const QCString& msg, const QByteArray& data ); | 44 | void recieve( const QCString& msg, const QByteArray& data ); |
45 | static QString defaultFileName(); | 45 | static QString defaultFileName(); |
46 | static QString syncFileName(); | 46 | static QString syncFileName(); |
47 | static QString resourcePath(); | 47 | static QString resourcePath(); |
48 | protected slots: | 48 | protected slots: |
49 | void setCaptionToDates(); | 49 | void setCaptionToDates(); |
50 | void about(); | 50 | void about(); |
51 | void licence(); | 51 | void licence(); |
52 | void faq(); | 52 | void faq(); |
53 | void usertrans(); | 53 | void usertrans(); |
54 | void features(); | 54 | void features(); |
55 | void synchowto(); | 55 | void synchowto(); |
56 | void kdesynchowto(); | ||
57 | void multisynchowto(); | ||
56 | void whatsNew(); | 58 | void whatsNew(); |
57 | void keyBindings(); | 59 | void keyBindings(); |
58 | void aboutAutoSaving();; | 60 | void aboutAutoSaving();; |
59 | void aboutKnownBugs(); | 61 | void aboutKnownBugs(); |
60 | 62 | ||
61 | void processIncidenceSelection( Incidence * ); | 63 | void processIncidenceSelection( Incidence * ); |
62 | 64 | ||
63 | void importQtopia(); | 65 | void importQtopia(); |
64 | void importBday(); | 66 | void importBday(); |
65 | void importOL(); | 67 | void importOL(); |
66 | void importIcal(); | 68 | void importIcal(); |
67 | void importFile( QString, bool ); | 69 | void importFile( QString, bool ); |
68 | void quickImportIcal(); | 70 | void quickImportIcal(); |
69 | 71 | ||
70 | void slotModifiedChanged( bool ); | 72 | void slotModifiedChanged( bool ); |
71 | 73 | ||
72 | void save(); | 74 | void save(); |
73 | void configureToolBar( int ); | 75 | void configureToolBar( int ); |
74 | void printSel(); | 76 | void printSel(); |
75 | void printCal(); | 77 | void printCal(); |
76 | void saveCalendar(); | 78 | void saveCalendar(); |
77 | void loadCalendar(); | 79 | void loadCalendar(); |
78 | void exportVCalendar(); | 80 | void exportVCalendar(); |
79 | void fillFilterMenu(); | 81 | void fillFilterMenu(); |
80 | void selectFilter( int ); | 82 | void selectFilter( int ); |
81 | void exportToPhone( int ); | 83 | void exportToPhone( int ); |
82 | void toggleBeamReceive(); | 84 | void toggleBeamReceive(); |
83 | void disableBR(bool); | 85 | void disableBR(bool); |
84 | 86 | ||
85 | 87 | ||
86 | protected: | 88 | protected: |
87 | void displayText( QString, QString); | 89 | void displayText( QString, QString); |
88 | void displayFile( QString, QString); | 90 | void displayFile( QString, QString); |
89 | 91 | ||
90 | void enableIncidenceActions( bool ); | 92 | void enableIncidenceActions( bool ); |
91 | 93 | ||
92 | private slots: | 94 | private slots: |
93 | QSocket* piSocket; | 95 | QSocket* piSocket; |
94 | QString piFileString; | 96 | QString piFileString; |
95 | QTime piTime; | 97 | QTime piTime; |
96 | void getFile( bool ); | 98 | void getFile( bool ); |
97 | void syncFileRequest(); | 99 | void syncFileRequest(); |
98 | private: | 100 | private: |
99 | bool mBRdisabled; | 101 | bool mBRdisabled; |
100 | #ifndef DESKTOP_VERSION | 102 | #ifndef DESKTOP_VERSION |
101 | QCopChannel* infrared; | 103 | QCopChannel* infrared; |
102 | #endif | 104 | #endif |
103 | QAction* brAction; | 105 | QAction* brAction; |
104 | KSyncManager* mSyncManager; | 106 | KSyncManager* mSyncManager; |
105 | bool mClosed; | 107 | bool mClosed; |
106 | void saveOnClose(); | 108 | void saveOnClose(); |
107 | bool mFlagKeyPressed; | 109 | bool mFlagKeyPressed; |
108 | bool mBlockAtStartup; | 110 | bool mBlockAtStartup; |
109 | QPEToolBar *iconToolBar; | 111 | QPEToolBar *iconToolBar; |
110 | void initActions(); | 112 | void initActions(); |
111 | void setDefaultPreferences(); | 113 | void setDefaultPreferences(); |
112 | void keyPressEvent ( QKeyEvent * ) ; | 114 | void keyPressEvent ( QKeyEvent * ) ; |
113 | void keyReleaseEvent ( QKeyEvent * ) ; | 115 | void keyReleaseEvent ( QKeyEvent * ) ; |
114 | QPopupMenu *configureToolBarMenu; | 116 | QPopupMenu *configureToolBarMenu; |
115 | QPopupMenu *selectFilterMenu; | 117 | QPopupMenu *selectFilterMenu; |
116 | QPopupMenu *configureAgendaMenu, *syncMenu; | 118 | QPopupMenu *configureAgendaMenu, *syncMenu; |
117 | CalendarLocal *mCalendar; | 119 | CalendarLocal *mCalendar; |
118 | CalendarView *mView; | 120 | CalendarView *mView; |
119 | QAction *mNewSubTodoAction; | 121 | QAction *mNewSubTodoAction; |
120 | 122 | ||
121 | QAction *mShowAction; | 123 | QAction *mShowAction; |
122 | QAction *mEditAction; | 124 | QAction *mEditAction; |
123 | QAction *mDeleteAction; | 125 | QAction *mDeleteAction; |
124 | QAction *mCloneAction; | 126 | QAction *mCloneAction; |
125 | QAction *mMoveAction; | 127 | QAction *mMoveAction; |
126 | QAction *mBeamAction; | 128 | QAction *mBeamAction; |
127 | QAction *mCancelAction; | 129 | QAction *mCancelAction; |
128 | 130 | ||
129 | void closeEvent( QCloseEvent* ce ); | 131 | void closeEvent( QCloseEvent* ce ); |
130 | SimpleAlarmClient mAlarmClient; | 132 | SimpleAlarmClient mAlarmClient; |
131 | QTimer mSaveTimer; | 133 | QTimer mSaveTimer; |
132 | //bool mBlockSaveFlag; | 134 | //bool mBlockSaveFlag; |
133 | bool mCalendarModifiedFlag; | 135 | bool mCalendarModifiedFlag; |
134 | QPixmap loadPixmap( QString ); | 136 | QPixmap loadPixmap( QString ); |
135 | }; | 137 | }; |
136 | 138 | ||
137 | 139 | ||
138 | #endif | 140 | #endif |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 17e6c75..9857e3e 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,1428 +1,1428 @@ | |||
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 | 67 | ||
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("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 | 253 | ||
254 | if ( action == 1000 ) { | 254 | if ( action == 1000 ) { |
255 | mIsKapiFile = false; | 255 | mIsKapiFile = false; |
256 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
257 | syncKDE(); | 257 | syncKDE(); |
258 | #else | 258 | #else |
259 | syncSharp(); | 259 | syncSharp(); |
260 | #endif | 260 | #endif |
261 | 261 | ||
262 | } else if ( action == 1001 ) { | 262 | } else if ( action == 1001 ) { |
263 | syncLocalFile(); | 263 | syncLocalFile(); |
264 | 264 | ||
265 | } else if ( action == 1002 ) { | 265 | } else if ( action == 1002 ) { |
266 | mWriteBackFile = false; | 266 | mWriteBackFile = false; |
267 | mAskForPreferences = false; | 267 | mAskForPreferences = false; |
268 | mShowSyncSummary = false; | 268 | mShowSyncSummary = false; |
269 | mSyncAlgoPrefs = 3; | 269 | mSyncAlgoPrefs = 3; |
270 | quickSyncLocalFile(); | 270 | quickSyncLocalFile(); |
271 | 271 | ||
272 | } else if ( action >= 1003 ) { | 272 | } else if ( action >= 1003 ) { |
273 | if ( temp->getIsLocalFileSync() ) { | 273 | if ( temp->getIsLocalFileSync() ) { |
274 | switch(mTargetApp) | 274 | switch(mTargetApp) |
275 | { | 275 | { |
276 | case (KAPI): | 276 | case (KAPI): |
277 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 277 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
278 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 278 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
279 | break; | 279 | break; |
280 | case (KOPI): | 280 | case (KOPI): |
281 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 281 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
282 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 282 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
283 | break; | 283 | break; |
284 | case (PWMPI): | 284 | case (PWMPI): |
285 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 285 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
286 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 286 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
287 | break; | 287 | break; |
288 | default: | 288 | default: |
289 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 289 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
290 | break; | 290 | break; |
291 | 291 | ||
292 | } | 292 | } |
293 | } else { | 293 | } else { |
294 | if ( temp->getIsPhoneSync() ) { | 294 | if ( temp->getIsPhoneSync() ) { |
295 | mPhoneDevice = temp->getPhoneDevice( ) ; | 295 | mPhoneDevice = temp->getPhoneDevice( ) ; |
296 | mPhoneConnection = temp->getPhoneConnection( ); | 296 | mPhoneConnection = temp->getPhoneConnection( ); |
297 | mPhoneModel = temp->getPhoneModel( ); | 297 | mPhoneModel = temp->getPhoneModel( ); |
298 | syncPhone(); | 298 | syncPhone(); |
299 | } else if ( temp->getIsPiSync() ) { | 299 | } else if ( temp->getIsPiSync() ) { |
300 | if ( mTargetApp == KAPI ) { | 300 | if ( mTargetApp == KAPI ) { |
301 | mPassWordPiSync = temp->getRemotePwAB(); | 301 | mPassWordPiSync = temp->getRemotePwAB(); |
302 | mActiveSyncPort = temp->getRemotePortAB(); | 302 | mActiveSyncPort = temp->getRemotePortAB(); |
303 | mActiveSyncIP = temp->getRemoteIPAB(); | 303 | mActiveSyncIP = temp->getRemoteIPAB(); |
304 | } else if ( mTargetApp == KOPI ) { | 304 | } else if ( mTargetApp == KOPI ) { |
305 | mPassWordPiSync = temp->getRemotePw(); | 305 | mPassWordPiSync = temp->getRemotePw(); |
306 | mActiveSyncPort = temp->getRemotePort(); | 306 | mActiveSyncPort = temp->getRemotePort(); |
307 | mActiveSyncIP = temp->getRemoteIP(); | 307 | mActiveSyncIP = temp->getRemoteIP(); |
308 | } else { | 308 | } else { |
309 | mPassWordPiSync = temp->getRemotePwPWM(); | 309 | mPassWordPiSync = temp->getRemotePwPWM(); |
310 | mActiveSyncPort = temp->getRemotePortPWM(); | 310 | mActiveSyncPort = temp->getRemotePortPWM(); |
311 | mActiveSyncIP = temp->getRemoteIPPWM(); | 311 | mActiveSyncIP = temp->getRemoteIPPWM(); |
312 | } | 312 | } |
313 | syncPi(); | 313 | syncPi(); |
314 | while ( !mPisyncFinished ) { | 314 | while ( !mPisyncFinished ) { |
315 | //qDebug("waiting "); | 315 | //qDebug("waiting "); |
316 | qApp->processEvents(); | 316 | qApp->processEvents(); |
317 | } | 317 | } |
318 | } else | 318 | } else |
319 | syncRemote( temp ); | 319 | syncRemote( temp ); |
320 | 320 | ||
321 | } | 321 | } |
322 | } | 322 | } |
323 | delete temp; | 323 | delete temp; |
324 | setBlockSave(false); | 324 | setBlockSave(false); |
325 | } | 325 | } |
326 | 326 | ||
327 | void KSyncManager::enableQuick( bool ask ) | 327 | void KSyncManager::enableQuick( bool ask ) |
328 | { | 328 | { |
329 | bool autoStart; | 329 | bool autoStart; |
330 | bool changed = false; | 330 | bool changed = false; |
331 | if ( ask ) { | 331 | if ( ask ) { |
332 | QDialog dia ( 0, "input-dialog", true ); | 332 | QDialog dia ( 0, "input-dialog", true ); |
333 | QLineEdit lab ( &dia ); | 333 | QLineEdit lab ( &dia ); |
334 | QVBoxLayout lay( &dia ); | 334 | QVBoxLayout lay( &dia ); |
335 | lab.setText( mPrefs->mPassiveSyncPort ); | 335 | lab.setText( mPrefs->mPassiveSyncPort ); |
336 | lay.setMargin(7); | 336 | lay.setMargin(7); |
337 | lay.setSpacing(7); | 337 | lay.setSpacing(7); |
338 | int po = 9197+mTargetApp; | 338 | int po = 9197+mTargetApp; |
339 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 339 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
340 | lay.addWidget( &label); | 340 | lay.addWidget( &label); |
341 | lay.addWidget( &lab); | 341 | lay.addWidget( &lab); |
342 | 342 | ||
343 | QLineEdit lepw ( &dia ); | 343 | QLineEdit lepw ( &dia ); |
344 | lepw.setText( mPrefs->mPassiveSyncPw ); | 344 | lepw.setText( mPrefs->mPassiveSyncPw ); |
345 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 345 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
346 | lay.addWidget( &label2); | 346 | lay.addWidget( &label2); |
347 | lay.addWidget( &lepw); | 347 | lay.addWidget( &lepw); |
348 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 348 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
349 | lay.addWidget( &autostart); | 349 | lay.addWidget( &autostart); |
350 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 350 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
351 | #ifdef DESKTOP_VERSION | 351 | #ifdef DESKTOP_VERSION |
352 | #ifdef _WIN32_ | 352 | #ifdef _WIN32_ |
353 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 353 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
354 | #else | 354 | #else |
355 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 355 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
356 | #endif | 356 | #endif |
357 | lay.addWidget( &syncdesktop); | 357 | lay.addWidget( &syncdesktop); |
358 | #else | 358 | #else |
359 | mPrefs->mPassiveSyncWithDesktop = false; | 359 | mPrefs->mPassiveSyncWithDesktop = false; |
360 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 360 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
361 | syncdesktop.hide(); | 361 | syncdesktop.hide(); |
362 | #endif | 362 | #endif |
363 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 363 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
364 | 364 | ||
365 | dia.setFixedSize( 230,120 ); | 365 | dia.setFixedSize( 230,120 ); |
366 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 366 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
367 | QPushButton pb ( "OK", &dia); | 367 | QPushButton pb ( "OK", &dia); |
368 | lay.addWidget( &pb ); | 368 | lay.addWidget( &pb ); |
369 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 369 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
370 | dia.show(); | 370 | dia.show(); |
371 | if ( ! dia.exec() ) | 371 | if ( ! dia.exec() ) |
372 | return; | 372 | return; |
373 | dia.hide(); | 373 | dia.hide(); |
374 | qApp->processEvents(); | 374 | qApp->processEvents(); |
375 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 375 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
376 | changed = true; | 376 | changed = true; |
377 | mPrefs->mPassiveSyncPw = lepw.text(); | 377 | mPrefs->mPassiveSyncPw = lepw.text(); |
378 | } | 378 | } |
379 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 379 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
380 | mPrefs->mPassiveSyncPort = lab.text(); | 380 | mPrefs->mPassiveSyncPort = lab.text(); |
381 | changed = true; | 381 | changed = true; |
382 | } | 382 | } |
383 | autoStart = autostart.isChecked(); | 383 | autoStart = autostart.isChecked(); |
384 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 384 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
385 | changed = true; | 385 | changed = true; |
386 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 386 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
387 | } | 387 | } |
388 | } | 388 | } |
389 | else | 389 | else |
390 | autoStart = mPrefs->mPassiveSyncAutoStart; | 390 | autoStart = mPrefs->mPassiveSyncAutoStart; |
391 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 391 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
392 | changed = true; | 392 | changed = true; |
393 | bool ok; | 393 | bool ok; |
394 | mPrefs->mPassiveSyncAutoStart = false; | 394 | mPrefs->mPassiveSyncAutoStart = false; |
395 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | 395 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); |
396 | if ( ! ok ) { | 396 | if ( ! ok ) { |
397 | KMessageBox::information( 0, i18n("No valid port")); | 397 | KMessageBox::information( 0, i18n("No valid port")); |
398 | return; | 398 | return; |
399 | } | 399 | } |
400 | //qDebug("port %d ", port); | 400 | //qDebug("port %d ", port); |
401 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 401 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
402 | mServerSocket->setFileName( defaultFileName() ); | 402 | mServerSocket->setFileName( defaultFileName() ); |
403 | //qDebug("connected "); | 403 | //qDebug("connected "); |
404 | if ( !mServerSocket->ok() ) { | 404 | if ( !mServerSocket->ok() ) { |
405 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 405 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
406 | delete mServerSocket; | 406 | delete mServerSocket; |
407 | mServerSocket = 0; | 407 | mServerSocket = 0; |
408 | return; | 408 | return; |
409 | } | 409 | } |
410 | mPrefs->mPassiveSyncAutoStart = autoStart; | 410 | mPrefs->mPassiveSyncAutoStart = autoStart; |
411 | if ( changed ) { | 411 | if ( changed ) { |
412 | mPrefs->writeConfig(); | 412 | mPrefs->writeConfig(); |
413 | } | 413 | } |
414 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 414 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
415 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 415 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
416 | } | 416 | } |
417 | 417 | ||
418 | void KSyncManager::syncLocalFile() | 418 | void KSyncManager::syncLocalFile() |
419 | { | 419 | { |
420 | 420 | ||
421 | QString fn =mPrefs->mLastSyncedLocalFile; | 421 | QString fn =mPrefs->mLastSyncedLocalFile; |
422 | QString ext; | 422 | QString ext; |
423 | 423 | ||
424 | switch(mTargetApp) | 424 | switch(mTargetApp) |
425 | { | 425 | { |
426 | case (KAPI): | 426 | case (KAPI): |
427 | ext = "(*.vcf)"; | 427 | ext = "(*.vcf)"; |
428 | break; | 428 | break; |
429 | case (KOPI): | 429 | case (KOPI): |
430 | ext = "(*.ics/*.vcs)"; | 430 | ext = "(*.ics/*.vcs)"; |
431 | break; | 431 | break; |
432 | case (PWMPI): | 432 | case (PWMPI): |
433 | ext = "(*.pwm)"; | 433 | ext = "(*.pwm)"; |
434 | break; | 434 | break; |
435 | default: | 435 | default: |
436 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 436 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
437 | break; | 437 | break; |
438 | 438 | ||
439 | } | 439 | } |
440 | 440 | ||
441 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 441 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
442 | if ( fn == "" ) | 442 | if ( fn == "" ) |
443 | return; | 443 | return; |
444 | if ( syncWithFile( fn, false ) ) { | 444 | if ( syncWithFile( fn, false ) ) { |
445 | qDebug("syncLocalFile() successful "); | 445 | qDebug("syncLocalFile() successful "); |
446 | } | 446 | } |
447 | 447 | ||
448 | } | 448 | } |
449 | 449 | ||
450 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 450 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
451 | { | 451 | { |
452 | bool ret = false; | 452 | bool ret = false; |
453 | QFileInfo info; | 453 | QFileInfo info; |
454 | info.setFile( fn ); | 454 | info.setFile( fn ); |
455 | QString mess; | 455 | QString mess; |
456 | bool loadbup = true; | 456 | bool loadbup = true; |
457 | if ( !info. exists() ) { | 457 | if ( !info. exists() ) { |
458 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 458 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
459 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 459 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
460 | mess ); | 460 | mess ); |
461 | return ret; | 461 | return ret; |
462 | } | 462 | } |
463 | int result = 0; | 463 | int result = 0; |
464 | if ( !quick ) { | 464 | if ( !quick ) { |
465 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 465 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
466 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 466 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
467 | mess, | 467 | mess, |
468 | i18n("Sync"), i18n("Cancel"), 0, | 468 | i18n("Sync"), i18n("Cancel"), 0, |
469 | 0, 1 ); | 469 | 0, 1 ); |
470 | if ( result ) | 470 | if ( result ) |
471 | return false; | 471 | return false; |
472 | } | 472 | } |
473 | if ( mAskForPreferences ) | 473 | if ( mAskForPreferences ) |
474 | if ( !edit_sync_options()) { | 474 | if ( !edit_sync_options()) { |
475 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 475 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
476 | return false; | 476 | return false; |
477 | } | 477 | } |
478 | if ( result == 0 ) { | 478 | if ( result == 0 ) { |
479 | //qDebug("Now sycing ... "); | 479 | //qDebug("Now sycing ... "); |
480 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 480 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
481 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 481 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
482 | else | 482 | else |
483 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 483 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
484 | if ( ! quick ) | 484 | if ( ! quick ) |
485 | mPrefs->mLastSyncedLocalFile = fn; | 485 | mPrefs->mLastSyncedLocalFile = fn; |
486 | } | 486 | } |
487 | return ret; | 487 | return ret; |
488 | } | 488 | } |
489 | 489 | ||
490 | void KSyncManager::quickSyncLocalFile() | 490 | void KSyncManager::quickSyncLocalFile() |
491 | { | 491 | { |
492 | 492 | ||
493 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 493 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
494 | qDebug("quick syncLocalFile() successful "); | 494 | qDebug("quick syncLocalFile() successful "); |
495 | 495 | ||
496 | } | 496 | } |
497 | } | 497 | } |
498 | 498 | ||
499 | void KSyncManager::multiSync( bool askforPrefs ) | 499 | void KSyncManager::multiSync( bool askforPrefs ) |
500 | { | 500 | { |
501 | if (blockSave()) | 501 | if (blockSave()) |
502 | return; | 502 | return; |
503 | setBlockSave(true); | 503 | setBlockSave(true); |
504 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 504 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
505 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 505 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
506 | question, | 506 | question, |
507 | i18n("Yes"), i18n("No"), | 507 | i18n("Yes"), i18n("No"), |
508 | 0, 0 ) != 0 ) { | 508 | 0, 0 ) != 0 ) { |
509 | setBlockSave(false); | 509 | setBlockSave(false); |
510 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 510 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
511 | return; | 511 | return; |
512 | } | 512 | } |
513 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 513 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
514 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 514 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
515 | if ( askforPrefs ) { | 515 | if ( askforPrefs ) { |
516 | if ( !edit_sync_options()) { | 516 | if ( !edit_sync_options()) { |
517 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 517 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
518 | return; | 518 | return; |
519 | } | 519 | } |
520 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 520 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
521 | } | 521 | } |
522 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 522 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
523 | qApp->processEvents(); | 523 | qApp->processEvents(); |
524 | int num = ringSync() ; | 524 | int num = ringSync() ; |
525 | if ( num > 1 ) | 525 | if ( num > 1 ) |
526 | ringSync(); | 526 | ringSync(); |
527 | setBlockSave(false); | 527 | setBlockSave(false); |
528 | if ( num ) | 528 | if ( num ) |
529 | emit save(); | 529 | emit save(); |
530 | if ( num ) | 530 | if ( num ) |
531 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 531 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
532 | else | 532 | else |
533 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 533 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
534 | return; | 534 | return; |
535 | } | 535 | } |
536 | 536 | ||
537 | int KSyncManager::ringSync() | 537 | int KSyncManager::ringSync() |
538 | { | 538 | { |
539 | int syncedProfiles = 0; | 539 | int syncedProfiles = 0; |
540 | unsigned int i; | 540 | unsigned int i; |
541 | QTime timer; | 541 | QTime timer; |
542 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 542 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
543 | QStringList syncProfileNames = mSyncProfileNames; | 543 | QStringList syncProfileNames = mSyncProfileNames; |
544 | KSyncProfile* temp = new KSyncProfile (); | 544 | KSyncProfile* temp = new KSyncProfile (); |
545 | mAskForPreferences = false; | 545 | mAskForPreferences = false; |
546 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 546 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
547 | mCurrentSyncProfile = i; | 547 | mCurrentSyncProfile = i; |
548 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 548 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
549 | temp->readConfig(&config); | 549 | temp->readConfig(&config); |
550 | 550 | ||
551 | bool includeInRingSync; | 551 | bool includeInRingSync; |
552 | switch(mTargetApp) | 552 | switch(mTargetApp) |
553 | { | 553 | { |
554 | case (KAPI): | 554 | case (KAPI): |
555 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 555 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
556 | break; | 556 | break; |
557 | case (KOPI): | 557 | case (KOPI): |
558 | includeInRingSync = temp->getIncludeInRingSync(); | 558 | includeInRingSync = temp->getIncludeInRingSync(); |
559 | break; | 559 | break; |
560 | case (PWMPI): | 560 | case (PWMPI): |
561 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 561 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
562 | break; | 562 | break; |
563 | default: | 563 | default: |
564 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 564 | qDebug("KSyncManager::ringSync: invalid apptype selected"); |
565 | break; | 565 | break; |
566 | 566 | ||
567 | } | 567 | } |
568 | 568 | ||
569 | 569 | ||
570 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 570 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
571 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 571 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
572 | ++syncedProfiles; | 572 | ++syncedProfiles; |
573 | // mAskForPreferences = temp->getAskForPreferences(); | 573 | // mAskForPreferences = temp->getAskForPreferences(); |
574 | mWriteBackFile = temp->getWriteBackFile(); | 574 | mWriteBackFile = temp->getWriteBackFile(); |
575 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 575 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
576 | mWriteBackInFuture = 0; | 576 | mWriteBackInFuture = 0; |
577 | if ( temp->getWriteBackFuture() ) | 577 | if ( temp->getWriteBackFuture() ) |
578 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 578 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
579 | mShowSyncSummary = false; | 579 | mShowSyncSummary = false; |
580 | mCurrentSyncDevice = syncProfileNames[i] ; | 580 | mCurrentSyncDevice = syncProfileNames[i] ; |
581 | mCurrentSyncName = mLocalMachineName; | 581 | mCurrentSyncName = mLocalMachineName; |
582 | if ( i == 0 ) { | 582 | if ( i == 0 ) { |
583 | #ifdef DESKTOP_VERSION | 583 | #ifdef DESKTOP_VERSION |
584 | syncKDE(); | 584 | syncKDE(); |
585 | #else | 585 | #else |
586 | syncSharp(); | 586 | syncSharp(); |
587 | #endif | 587 | #endif |
588 | } else { | 588 | } else { |
589 | if ( temp->getIsLocalFileSync() ) { | 589 | if ( temp->getIsLocalFileSync() ) { |
590 | switch(mTargetApp) | 590 | switch(mTargetApp) |
591 | { | 591 | { |
592 | case (KAPI): | 592 | case (KAPI): |
593 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 593 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
594 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 594 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
595 | break; | 595 | break; |
596 | case (KOPI): | 596 | case (KOPI): |
597 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 597 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
598 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 598 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
599 | break; | 599 | break; |
600 | case (PWMPI): | 600 | case (PWMPI): |
601 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 601 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
602 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 602 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
603 | break; | 603 | break; |
604 | default: | 604 | default: |
605 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 605 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
606 | break; | 606 | break; |
607 | } | 607 | } |
608 | } else { | 608 | } else { |
609 | if ( temp->getIsPhoneSync() ) { | 609 | if ( temp->getIsPhoneSync() ) { |
610 | mPhoneDevice = temp->getPhoneDevice( ) ; | 610 | mPhoneDevice = temp->getPhoneDevice( ) ; |
611 | mPhoneConnection = temp->getPhoneConnection( ); | 611 | mPhoneConnection = temp->getPhoneConnection( ); |
612 | mPhoneModel = temp->getPhoneModel( ); | 612 | mPhoneModel = temp->getPhoneModel( ); |
613 | syncPhone(); | 613 | syncPhone(); |
614 | } else if ( temp->getIsPiSync() ) { | 614 | } else if ( temp->getIsPiSync() ) { |
615 | if ( mTargetApp == KAPI ) { | 615 | if ( mTargetApp == KAPI ) { |
616 | mPassWordPiSync = temp->getRemotePwAB(); | 616 | mPassWordPiSync = temp->getRemotePwAB(); |
617 | mActiveSyncPort = temp->getRemotePortAB(); | 617 | mActiveSyncPort = temp->getRemotePortAB(); |
618 | mActiveSyncIP = temp->getRemoteIPAB(); | 618 | mActiveSyncIP = temp->getRemoteIPAB(); |
619 | } else if ( mTargetApp == KOPI ) { | 619 | } else if ( mTargetApp == KOPI ) { |
620 | mPassWordPiSync = temp->getRemotePw(); | 620 | mPassWordPiSync = temp->getRemotePw(); |
621 | mActiveSyncPort = temp->getRemotePort(); | 621 | mActiveSyncPort = temp->getRemotePort(); |
622 | mActiveSyncIP = temp->getRemoteIP(); | 622 | mActiveSyncIP = temp->getRemoteIP(); |
623 | } else { | 623 | } else { |
624 | mPassWordPiSync = temp->getRemotePwPWM(); | 624 | mPassWordPiSync = temp->getRemotePwPWM(); |
625 | mActiveSyncPort = temp->getRemotePortPWM(); | 625 | mActiveSyncPort = temp->getRemotePortPWM(); |
626 | mActiveSyncIP = temp->getRemoteIPPWM(); | 626 | mActiveSyncIP = temp->getRemoteIPPWM(); |
627 | } | 627 | } |
628 | syncPi(); | 628 | syncPi(); |
629 | while ( !mPisyncFinished ) { | 629 | while ( !mPisyncFinished ) { |
630 | //qDebug("waiting "); | 630 | //qDebug("waiting "); |
631 | qApp->processEvents(); | 631 | qApp->processEvents(); |
632 | } | 632 | } |
633 | timer.start(); | 633 | timer.start(); |
634 | while ( timer.elapsed () < 2000 ) { | 634 | while ( timer.elapsed () < 2000 ) { |
635 | qApp->processEvents(); | 635 | qApp->processEvents(); |
636 | } | 636 | } |
637 | } else | 637 | } else |
638 | syncRemote( temp, false ); | 638 | syncRemote( temp, false ); |
639 | 639 | ||
640 | } | 640 | } |
641 | } | 641 | } |
642 | timer.start(); | 642 | timer.start(); |
643 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 643 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
644 | while ( timer.elapsed () < 2000 ) { | 644 | while ( timer.elapsed () < 2000 ) { |
645 | qApp->processEvents(); | 645 | qApp->processEvents(); |
646 | #ifndef _WIN32_ | 646 | #ifndef _WIN32_ |
647 | sleep (1); | 647 | sleep (1); |
648 | #endif | 648 | #endif |
649 | } | 649 | } |
650 | 650 | ||
651 | } | 651 | } |
652 | 652 | ||
653 | } | 653 | } |
654 | delete temp; | 654 | delete temp; |
655 | return syncedProfiles; | 655 | return syncedProfiles; |
656 | } | 656 | } |
657 | 657 | ||
658 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 658 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
659 | { | 659 | { |
660 | QString question; | 660 | QString question; |
661 | if ( ask ) { | 661 | if ( ask ) { |
662 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 662 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
663 | if ( QMessageBox::information( mParent, i18n("Sync"), | 663 | if ( QMessageBox::information( mParent, i18n("Sync"), |
664 | question, | 664 | question, |
665 | i18n("Yes"), i18n("No"), | 665 | i18n("Yes"), i18n("No"), |
666 | 0, 0 ) != 0 ) | 666 | 0, 0 ) != 0 ) |
667 | return; | 667 | return; |
668 | } | 668 | } |
669 | 669 | ||
670 | QString preCommand; | 670 | QString preCommand; |
671 | QString localTempFile; | 671 | QString localTempFile; |
672 | QString postCommand; | 672 | QString postCommand; |
673 | 673 | ||
674 | switch(mTargetApp) | 674 | switch(mTargetApp) |
675 | { | 675 | { |
676 | case (KAPI): | 676 | case (KAPI): |
677 | preCommand = prof->getPreSyncCommandAB(); | 677 | preCommand = prof->getPreSyncCommandAB(); |
678 | postCommand = prof->getPostSyncCommandAB(); | 678 | postCommand = prof->getPostSyncCommandAB(); |
679 | localTempFile = prof->getLocalTempFileAB(); | 679 | localTempFile = prof->getLocalTempFileAB(); |
680 | break; | 680 | break; |
681 | case (KOPI): | 681 | case (KOPI): |
682 | preCommand = prof->getPreSyncCommand(); | 682 | preCommand = prof->getPreSyncCommand(); |
683 | postCommand = prof->getPostSyncCommand(); | 683 | postCommand = prof->getPostSyncCommand(); |
684 | localTempFile = prof->getLocalTempFile(); | 684 | localTempFile = prof->getLocalTempFile(); |
685 | break; | 685 | break; |
686 | case (PWMPI): | 686 | case (PWMPI): |
687 | preCommand = prof->getPreSyncCommandPWM(); | 687 | preCommand = prof->getPreSyncCommandPWM(); |
688 | postCommand = prof->getPostSyncCommandPWM(); | 688 | postCommand = prof->getPostSyncCommandPWM(); |
689 | localTempFile = prof->getLocalTempFilePWM(); | 689 | localTempFile = prof->getLocalTempFilePWM(); |
690 | break; | 690 | break; |
691 | default: | 691 | default: |
692 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); | 692 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); |
693 | break; | 693 | break; |
694 | } | 694 | } |
695 | 695 | ||
696 | 696 | ||
697 | int fi; | 697 | int fi; |
698 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 698 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
699 | QString pwd = getPassword(); | 699 | QString pwd = getPassword(); |
700 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 700 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
701 | 701 | ||
702 | } | 702 | } |
703 | int maxlen = 30; | 703 | int maxlen = 30; |
704 | if ( QApplication::desktop()->width() > 320 ) | 704 | if ( QApplication::desktop()->width() > 320 ) |
705 | maxlen += 25; | 705 | maxlen += 25; |
706 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 706 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
707 | int fileSize = 0; | 707 | int fileSize = 0; |
708 | int result = system ( preCommand ); | 708 | int result = system ( preCommand ); |
709 | // 0 : okay | 709 | // 0 : okay |
710 | // 256: no such file or dir | 710 | // 256: no such file or dir |
711 | // | 711 | // |
712 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); | 712 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); |
713 | if ( result != 0 ) { | 713 | if ( result != 0 ) { |
714 | unsigned int len = maxlen; | 714 | unsigned int len = maxlen; |
715 | while ( len < preCommand.length() ) { | 715 | while ( len < preCommand.length() ) { |
716 | preCommand.insert( len , "\n" ); | 716 | preCommand.insert( len , "\n" ); |
717 | len += maxlen +2; | 717 | len += maxlen +2; |
718 | } | 718 | } |
719 | 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) ; | 719 | 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) ; |
720 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 720 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
721 | question, | 721 | question, |
722 | i18n("Okay!")) ; | 722 | i18n("Okay!")) ; |
723 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 723 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
724 | return; | 724 | return; |
725 | } | 725 | } |
726 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 726 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
727 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 727 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
728 | 728 | ||
729 | if ( syncWithFile( localTempFile, true ) ) { | 729 | if ( syncWithFile( localTempFile, true ) ) { |
730 | 730 | ||
731 | if ( mWriteBackFile ) { | 731 | if ( mWriteBackFile ) { |
732 | int fi; | 732 | int fi; |
733 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 733 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
734 | QString pwd = getPassword(); | 734 | QString pwd = getPassword(); |
735 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 735 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
736 | 736 | ||
737 | } | 737 | } |
738 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 738 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
739 | result = system ( postCommand ); | 739 | result = system ( postCommand ); |
740 | qDebug("Sync:Writing back file result: %d ", result); | 740 | qDebug("Sync:Writing back file result: %d ", result); |
741 | if ( result != 0 ) { | 741 | if ( result != 0 ) { |
742 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 742 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
743 | return; | 743 | return; |
744 | } else { | 744 | } else { |
745 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 745 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
746 | } | 746 | } |
747 | } | 747 | } |
748 | } | 748 | } |
749 | return; | 749 | return; |
750 | } | 750 | } |
751 | bool KSyncManager::edit_pisync_options() | 751 | bool KSyncManager::edit_pisync_options() |
752 | { | 752 | { |
753 | QDialog dia( mParent, "dia", true ); | 753 | QDialog dia( mParent, "dia", true ); |
754 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 754 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
755 | QVBoxLayout lay ( &dia ); | 755 | QVBoxLayout lay ( &dia ); |
756 | lay.setSpacing( 5 ); | 756 | lay.setSpacing( 5 ); |
757 | lay.setMargin( 3 ); | 757 | lay.setMargin( 3 ); |
758 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 758 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
759 | lay.addWidget( &lab1 ); | 759 | lay.addWidget( &lab1 ); |
760 | QLineEdit le1 (&dia ); | 760 | QLineEdit le1 (&dia ); |
761 | lay.addWidget( &le1 ); | 761 | lay.addWidget( &le1 ); |
762 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 762 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
763 | lay.addWidget( &lab2 ); | 763 | lay.addWidget( &lab2 ); |
764 | QLineEdit le2 (&dia ); | 764 | QLineEdit le2 (&dia ); |
765 | lay.addWidget( &le2 ); | 765 | lay.addWidget( &le2 ); |
766 | QLabel lab3 ( i18n("Remote port number:"), &dia); | 766 | QLabel lab3 ( i18n("Remote port number:"), &dia); |
767 | lay.addWidget( &lab3 ); | 767 | lay.addWidget( &lab3 ); |
768 | QLineEdit le3 (&dia ); | 768 | QLineEdit le3 (&dia ); |
769 | lay.addWidget( &le3 ); | 769 | lay.addWidget( &le3 ); |
770 | QPushButton pb ( "OK", &dia); | 770 | QPushButton pb ( "OK", &dia); |
771 | lay.addWidget( &pb ); | 771 | lay.addWidget( &pb ); |
772 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 772 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
773 | le1.setText( mPassWordPiSync ); | 773 | le1.setText( mPassWordPiSync ); |
774 | le2.setText( mActiveSyncIP ); | 774 | le2.setText( mActiveSyncIP ); |
775 | le3.setText( mActiveSyncPort ); | 775 | le3.setText( mActiveSyncPort ); |
776 | if ( dia.exec() ) { | 776 | if ( dia.exec() ) { |
777 | mPassWordPiSync = le1.text(); | 777 | mPassWordPiSync = le1.text(); |
778 | mActiveSyncPort = le3.text(); | 778 | mActiveSyncPort = le3.text(); |
779 | mActiveSyncIP = le2.text(); | 779 | mActiveSyncIP = le2.text(); |
780 | return true; | 780 | return true; |
781 | } | 781 | } |
782 | return false; | 782 | return false; |
783 | } | 783 | } |
784 | bool KSyncManager::edit_sync_options() | 784 | bool KSyncManager::edit_sync_options() |
785 | { | 785 | { |
786 | 786 | ||
787 | QDialog dia( mParent, "dia", true ); | 787 | QDialog dia( mParent, "dia", true ); |
788 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 788 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
789 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 789 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
790 | QVBoxLayout lay ( &dia ); | 790 | QVBoxLayout lay ( &dia ); |
791 | lay.setSpacing( 2 ); | 791 | lay.setSpacing( 2 ); |
792 | lay.setMargin( 3 ); | 792 | lay.setMargin( 3 ); |
793 | lay.addWidget(&gr); | 793 | lay.addWidget(&gr); |
794 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 794 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
795 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 795 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
796 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 796 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
797 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 797 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
798 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 798 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
799 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 799 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
800 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 800 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
801 | QPushButton pb ( "OK", &dia); | 801 | QPushButton pb ( "OK", &dia); |
802 | lay.addWidget( &pb ); | 802 | lay.addWidget( &pb ); |
803 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 803 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
804 | switch ( mSyncAlgoPrefs ) { | 804 | switch ( mSyncAlgoPrefs ) { |
805 | case 0: | 805 | case 0: |
806 | loc.setChecked( true); | 806 | loc.setChecked( true); |
807 | break; | 807 | break; |
808 | case 1: | 808 | case 1: |
809 | rem.setChecked( true ); | 809 | rem.setChecked( true ); |
810 | break; | 810 | break; |
811 | case 2: | 811 | case 2: |
812 | newest.setChecked( true); | 812 | newest.setChecked( true); |
813 | break; | 813 | break; |
814 | case 3: | 814 | case 3: |
815 | ask.setChecked( true); | 815 | ask.setChecked( true); |
816 | break; | 816 | break; |
817 | case 4: | 817 | case 4: |
818 | f_loc.setChecked( true); | 818 | f_loc.setChecked( true); |
819 | break; | 819 | break; |
820 | case 5: | 820 | case 5: |
821 | f_rem.setChecked( true); | 821 | f_rem.setChecked( true); |
822 | break; | 822 | break; |
823 | case 6: | 823 | case 6: |
824 | // both.setChecked( true); | 824 | // both.setChecked( true); |
825 | break; | 825 | break; |
826 | default: | 826 | default: |
827 | break; | 827 | break; |
828 | } | 828 | } |
829 | if ( dia.exec() ) { | 829 | if ( dia.exec() ) { |
830 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 830 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
831 | return true; | 831 | return true; |
832 | } | 832 | } |
833 | return false; | 833 | return false; |
834 | } | 834 | } |
835 | 835 | ||
836 | QString KSyncManager::getPassword( ) | 836 | QString KSyncManager::getPassword( ) |
837 | { | 837 | { |
838 | QString retfile = ""; | 838 | QString retfile = ""; |
839 | QDialog dia ( mParent, "input-dialog", true ); | 839 | QDialog dia ( mParent, "input-dialog", true ); |
840 | QLineEdit lab ( &dia ); | 840 | QLineEdit lab ( &dia ); |
841 | lab.setEchoMode( QLineEdit::Password ); | 841 | lab.setEchoMode( QLineEdit::Password ); |
842 | QVBoxLayout lay( &dia ); | 842 | QVBoxLayout lay( &dia ); |
843 | lay.setMargin(7); | 843 | lay.setMargin(7); |
844 | lay.setSpacing(7); | 844 | lay.setSpacing(7); |
845 | lay.addWidget( &lab); | 845 | lay.addWidget( &lab); |
846 | dia.setFixedSize( 230,50 ); | 846 | dia.setFixedSize( 230,50 ); |
847 | dia.setCaption( i18n("Enter password") ); | 847 | dia.setCaption( i18n("Enter password") ); |
848 | QPushButton pb ( "OK", &dia); | 848 | QPushButton pb ( "OK", &dia); |
849 | lay.addWidget( &pb ); | 849 | lay.addWidget( &pb ); |
850 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 850 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
851 | dia.show(); | 851 | dia.show(); |
852 | int res = dia.exec(); | 852 | int res = dia.exec(); |
853 | if ( res ) | 853 | if ( res ) |
854 | retfile = lab.text(); | 854 | retfile = lab.text(); |
855 | dia.hide(); | 855 | dia.hide(); |
856 | qApp->processEvents(); | 856 | qApp->processEvents(); |
857 | return retfile; | 857 | return retfile; |
858 | 858 | ||
859 | } | 859 | } |
860 | 860 | ||
861 | 861 | ||
862 | void KSyncManager::confSync() | 862 | void KSyncManager::confSync() |
863 | { | 863 | { |
864 | static KSyncPrefsDialog* sp = 0; | 864 | static KSyncPrefsDialog* sp = 0; |
865 | if ( ! sp ) { | 865 | if ( ! sp ) { |
866 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 866 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
867 | } | 867 | } |
868 | sp->usrReadConfig(); | 868 | sp->usrReadConfig(); |
869 | #ifndef DESKTOP_VERSION | 869 | #ifndef DESKTOP_VERSION |
870 | sp->showMaximized(); | 870 | sp->showMaximized(); |
871 | #else | 871 | #else |
872 | sp->show(); | 872 | sp->show(); |
873 | #endif | 873 | #endif |
874 | sp->exec(); | 874 | sp->exec(); |
875 | QStringList oldSyncProfileNames = mSyncProfileNames; | 875 | QStringList oldSyncProfileNames = mSyncProfileNames; |
876 | mSyncProfileNames = sp->getSyncProfileNames(); | 876 | mSyncProfileNames = sp->getSyncProfileNames(); |
877 | mLocalMachineName = sp->getLocalMachineName (); | 877 | mLocalMachineName = sp->getLocalMachineName (); |
878 | int ii; | 878 | int ii; |
879 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 879 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
880 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 880 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
881 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 881 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
882 | } | 882 | } |
883 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 883 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
884 | } | 884 | } |
885 | void KSyncManager::syncKDE() | 885 | void KSyncManager::syncKDE() |
886 | { | 886 | { |
887 | mSyncWithDesktop = true; | 887 | mSyncWithDesktop = true; |
888 | emit save(); | 888 | emit save(); |
889 | switch(mTargetApp) | 889 | switch(mTargetApp) |
890 | { | 890 | { |
891 | case (KAPI): | 891 | case (KAPI): |
892 | { | 892 | { |
893 | #ifdef DESKTOP_VERSION | 893 | #ifdef DESKTOP_VERSION |
894 | QString command = qApp->applicationDirPath () + "/kdeabdump"; | 894 | QString command = qApp->applicationDirPath () + "/kdeabdump"; |
895 | #else | 895 | #else |
896 | QString command = "kdeabdump"; | 896 | QString command = "kdeabdump"; |
897 | #endif | 897 | #endif |
898 | if ( ! QFile::exists ( command ) ) | 898 | if ( ! QFile::exists ( command ) ) |
899 | command = "kdeabdump"; | 899 | command = "kdeabdump"; |
900 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 900 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
901 | system ( command.latin1()); | 901 | system ( command.latin1()); |
902 | if ( syncWithFile( fileName,true ) ) { | 902 | if ( syncWithFile( fileName,true ) ) { |
903 | if ( mWriteBackFile ) { | 903 | if ( mWriteBackFile ) { |
904 | command += " --read"; | 904 | command += " --read"; |
905 | system ( command.latin1()); | 905 | system ( command.latin1()); |
906 | } | 906 | } |
907 | } | 907 | } |
908 | 908 | ||
909 | } | 909 | } |
910 | break; | 910 | break; |
911 | case (KOPI): | 911 | case (KOPI): |
912 | { | 912 | { |
913 | #ifdef DESKTOP_VERSION | 913 | #ifdef DESKTOP_VERSION |
914 | QString command = qApp->applicationDirPath () + "/kdecaldump"; | 914 | QString command = qApp->applicationDirPath () + "/kdecaldump"; |
915 | #else | 915 | #else |
916 | QString command = "kdecaldump"; | 916 | QString command = "kdecaldump"; |
917 | #endif | 917 | #endif |
918 | if ( ! QFile::exists ( command ) ) | 918 | if ( ! QFile::exists ( command ) ) |
919 | command = "kdecaldump"; | 919 | command = "kdecaldump"; |
920 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 920 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
921 | system ( command.latin1()); | 921 | system ( command.latin1()); |
922 | if ( syncWithFile( fileName,true ) ) { | 922 | if ( syncWithFile( fileName,true ) ) { |
923 | if ( mWriteBackFile ) { | 923 | if ( mWriteBackFile ) { |
924 | command += " --read"; | 924 | command += " --read"; |
925 | system ( command.latin1()); | 925 | system ( command.latin1()); |
926 | } | 926 | } |
927 | } | 927 | } |
928 | 928 | ||
929 | } | 929 | } |
930 | break; | 930 | break; |
931 | case (PWMPI): | 931 | case (PWMPI): |
932 | 932 | ||
933 | break; | 933 | break; |
934 | default: | 934 | default: |
935 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 935 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
936 | break; | 936 | break; |
937 | 937 | ||
938 | } | 938 | } |
939 | } | 939 | } |
940 | 940 | ||
941 | void KSyncManager::syncSharp() | 941 | void KSyncManager::syncSharp() |
942 | { | 942 | { |
943 | 943 | ||
944 | if ( ! syncExternalApplication("sharp") ) | 944 | if ( ! syncExternalApplication("sharp") ) |
945 | qDebug("ERROR sync sharp "); | 945 | qDebug("ERROR sync sharp "); |
946 | } | 946 | } |
947 | 947 | ||
948 | bool KSyncManager::syncExternalApplication(QString resource) | 948 | bool KSyncManager::syncExternalApplication(QString resource) |
949 | { | 949 | { |
950 | 950 | ||
951 | emit save(); | 951 | emit save(); |
952 | 952 | ||
953 | if ( mAskForPreferences ) | 953 | if ( mAskForPreferences ) |
954 | if ( !edit_sync_options()) { | 954 | if ( !edit_sync_options()) { |
955 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 955 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
956 | return false; | 956 | return false; |
957 | } | 957 | } |
958 | 958 | ||
959 | qDebug("Sync extern %s", resource.latin1()); | 959 | qDebug("Sync extern %s", resource.latin1()); |
960 | 960 | ||
961 | bool syncOK = mImplementation->syncExternal(this, resource); | 961 | bool syncOK = mImplementation->syncExternal(this, resource); |
962 | 962 | ||
963 | return syncOK; | 963 | return syncOK; |
964 | 964 | ||
965 | } | 965 | } |
966 | 966 | ||
967 | void KSyncManager::syncPhone() | 967 | void KSyncManager::syncPhone() |
968 | { | 968 | { |
969 | 969 | ||
970 | syncExternalApplication("phone"); | 970 | syncExternalApplication("phone"); |
971 | 971 | ||
972 | } | 972 | } |
973 | 973 | ||
974 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 974 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
975 | { | 975 | { |
976 | if (!bar->isVisible()) | 976 | if (!bar->isVisible()) |
977 | { | 977 | { |
978 | bar->setCaption (caption); | 978 | bar->setCaption (caption); |
979 | bar->setTotalSteps ( total ) ; | 979 | bar->setTotalSteps ( total ) ; |
980 | 980 | ||
981 | bar->show(); | 981 | bar->show(); |
982 | } | 982 | } |
983 | 983 | ||
984 | bar->setProgress( percentage ); | 984 | bar->setProgress( percentage ); |
985 | } | 985 | } |
986 | 986 | ||
987 | void KSyncManager::hideProgressBar() | 987 | void KSyncManager::hideProgressBar() |
988 | { | 988 | { |
989 | bar->hide(); | 989 | bar->hide(); |
990 | } | 990 | } |
991 | 991 | ||
992 | bool KSyncManager::isProgressBarCanceled() | 992 | bool KSyncManager::isProgressBarCanceled() |
993 | { | 993 | { |
994 | return !bar->isVisible(); | 994 | return !bar->isVisible(); |
995 | } | 995 | } |
996 | 996 | ||
997 | QString KSyncManager::syncFileName() | 997 | QString KSyncManager::syncFileName() |
998 | { | 998 | { |
999 | 999 | ||
1000 | QString fn = "tempfile"; | 1000 | QString fn = "tempfile"; |
1001 | switch(mTargetApp) | 1001 | switch(mTargetApp) |
1002 | { | 1002 | { |
1003 | case (KAPI): | 1003 | case (KAPI): |
1004 | fn = "tempsyncab.vcf"; | 1004 | fn = "tempsyncab.vcf"; |
1005 | break; | 1005 | break; |
1006 | case (KOPI): | 1006 | case (KOPI): |
1007 | fn = "tempsynccal.ics"; | 1007 | fn = "tempsynccal.ics"; |
1008 | break; | 1008 | break; |
1009 | case (PWMPI): | 1009 | case (PWMPI): |
1010 | fn = "tempsyncpw.pwm"; | 1010 | fn = "tempsyncpw.pwm"; |
1011 | break; | 1011 | break; |
1012 | default: | 1012 | default: |
1013 | break; | 1013 | break; |
1014 | } | 1014 | } |
1015 | #ifdef _WIN32_ | 1015 | #ifdef _WIN32_ |
1016 | return locateLocal( "tmp", fn ); | 1016 | return locateLocal( "tmp", fn ); |
1017 | #else | 1017 | #else |
1018 | return (QString( "/tmp/" )+ fn ); | 1018 | return (QString( "/tmp/" )+ fn ); |
1019 | #endif | 1019 | #endif |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | void KSyncManager::syncPi() | 1022 | void KSyncManager::syncPi() |
1023 | { | 1023 | { |
1024 | mPisyncFinished = false; | 1024 | mPisyncFinished = false; |
1025 | qApp->processEvents(); | 1025 | qApp->processEvents(); |
1026 | if ( mAskForPreferences ) | 1026 | if ( mAskForPreferences ) |
1027 | if ( !edit_pisync_options()) { | 1027 | if ( !edit_pisync_options()) { |
1028 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1028 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1029 | return; | 1029 | return; |
1030 | } | 1030 | } |
1031 | bool ok; | 1031 | bool ok; |
1032 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1032 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1033 | if ( ! ok ) { | 1033 | if ( ! ok ) { |
1034 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1034 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1035 | return; | 1035 | return; |
1036 | } | 1036 | } |
1037 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 1037 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
1038 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1038 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1039 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 1039 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
1040 | commandSocket->readFile( syncFileName() ); | 1040 | commandSocket->readFile( syncFileName() ); |
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1043 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1044 | { | 1044 | { |
1045 | //enum { success, errorW, errorR, quiet }; | 1045 | //enum { success, errorW, errorR, quiet }; |
1046 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 1046 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
1047 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1047 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1048 | delete s; | 1048 | delete s; |
1049 | if ( state == KCommandSocket::errorR ) { | 1049 | if ( state == KCommandSocket::errorR ) { |
1050 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1050 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1051 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1051 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1052 | commandSocket->sendStop(); | 1052 | commandSocket->sendStop(); |
1053 | } | 1053 | } |
1054 | mPisyncFinished = true; | 1054 | mPisyncFinished = true; |
1055 | return; | 1055 | return; |
1056 | 1056 | ||
1057 | } else if ( state == KCommandSocket::errorW ) { | 1057 | } else if ( state == KCommandSocket::errorW ) { |
1058 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1058 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1059 | mPisyncFinished = true; | 1059 | mPisyncFinished = true; |
1060 | 1060 | ||
1061 | } else if ( state == KCommandSocket::successR ) { | 1061 | } else if ( state == KCommandSocket::successR ) { |
1062 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1062 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1063 | 1063 | ||
1064 | } else if ( state == KCommandSocket::successW ) { | 1064 | } else if ( state == KCommandSocket::successW ) { |
1065 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1065 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1066 | mPisyncFinished = true; | 1066 | mPisyncFinished = true; |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | delete s; | 1069 | delete s; |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | void KSyncManager::readFileFromSocket() | 1072 | void KSyncManager::readFileFromSocket() |
1073 | { | 1073 | { |
1074 | QString fileName = syncFileName(); | 1074 | QString fileName = syncFileName(); |
1075 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1075 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1076 | if ( ! syncWithFile( fileName , true ) ) { | 1076 | if ( ! syncWithFile( fileName , true ) ) { |
1077 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 1077 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
1078 | mPisyncFinished = true; | 1078 | mPisyncFinished = true; |
1079 | return; | 1079 | return; |
1080 | } | 1080 | } |
1081 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1081 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1082 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1082 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1083 | if ( mWriteBackFile ) | 1083 | if ( mWriteBackFile ) |
1084 | commandSocket->writeFile( fileName ); | 1084 | commandSocket->writeFile( fileName ); |
1085 | else { | 1085 | else { |
1086 | commandSocket->sendStop(); | 1086 | commandSocket->sendStop(); |
1087 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1087 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1088 | mPisyncFinished = true; | 1088 | mPisyncFinished = true; |
1089 | } | 1089 | } |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1092 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1093 | { | 1093 | { |
1094 | mPassWord = pw; | 1094 | mPassWord = pw; |
1095 | mSocket = 0; | 1095 | mSocket = 0; |
1096 | mSyncActionDialog = 0; | 1096 | mSyncActionDialog = 0; |
1097 | blockRC = false; | 1097 | blockRC = false; |
1098 | }; | 1098 | }; |
1099 | 1099 | ||
1100 | void KServerSocket::newConnection ( int socket ) | 1100 | void KServerSocket::newConnection ( int socket ) |
1101 | { | 1101 | { |
1102 | // qDebug("KServerSocket:New connection %d ", socket); | 1102 | // qDebug("KServerSocket:New connection %d ", socket); |
1103 | if ( mSocket ) { | 1103 | if ( mSocket ) { |
1104 | qDebug("KServerSocket::newConnection Socket deleted! "); | 1104 | qDebug("KServerSocket::newConnection Socket deleted! "); |
1105 | delete mSocket; | 1105 | delete mSocket; |
1106 | mSocket = 0; | 1106 | mSocket = 0; |
1107 | } | 1107 | } |
1108 | mSocket = new QSocket( this ); | 1108 | mSocket = new QSocket( this ); |
1109 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1109 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1110 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1110 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1111 | mSocket->setSocket( socket ); | 1111 | mSocket->setSocket( socket ); |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | void KServerSocket::discardClient() | 1114 | void KServerSocket::discardClient() |
1115 | { | 1115 | { |
1116 | //qDebug(" KServerSocket::discardClient()"); | 1116 | //qDebug(" KServerSocket::discardClient()"); |
1117 | if ( mSocket ) { | 1117 | if ( mSocket ) { |
1118 | delete mSocket; | 1118 | delete mSocket; |
1119 | mSocket = 0; | 1119 | mSocket = 0; |
1120 | } | 1120 | } |
1121 | //emit endConnect(); | 1121 | //emit endConnect(); |
1122 | } | 1122 | } |
1123 | void KServerSocket::readClient() | 1123 | void KServerSocket::readClient() |
1124 | { | 1124 | { |
1125 | if ( blockRC ) | 1125 | if ( blockRC ) |
1126 | return; | 1126 | return; |
1127 | if ( mSocket == 0 ) { | 1127 | if ( mSocket == 0 ) { |
1128 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 1128 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
1129 | return; | 1129 | return; |
1130 | } | 1130 | } |
1131 | //qDebug("KServerSocket::readClient()"); | 1131 | //qDebug("KServerSocket::readClient()"); |
1132 | if ( mSocket->canReadLine() ) { | 1132 | if ( mSocket->canReadLine() ) { |
1133 | QString line = mSocket->readLine(); | 1133 | QString line = mSocket->readLine(); |
1134 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 1134 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
1135 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 1135 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
1136 | if ( tokens[0] == "GET" ) { | 1136 | if ( tokens[0] == "GET" ) { |
1137 | if ( tokens[1] == mPassWord ) { | 1137 | if ( tokens[1] == mPassWord ) { |
1138 | //emit sendFile( mSocket ); | 1138 | //emit sendFile( mSocket ); |
1139 | bool ok = false; | 1139 | bool ok = false; |
1140 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); | 1140 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); |
1141 | if ( ok ) | 1141 | if ( ok ) |
1142 | KSyncManager::mRequestedSyncEvent = dt; | 1142 | KSyncManager::mRequestedSyncEvent = dt; |
1143 | else | 1143 | else |
1144 | KSyncManager::mRequestedSyncEvent = QDateTime(); | 1144 | KSyncManager::mRequestedSyncEvent = QDateTime(); |
1145 | send_file(); | 1145 | send_file(); |
1146 | } | 1146 | } |
1147 | else { | 1147 | else { |
1148 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); | 1148 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); |
1149 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1149 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1150 | } | 1150 | } |
1151 | } | 1151 | } |
1152 | if ( tokens[0] == "PUT" ) { | 1152 | if ( tokens[0] == "PUT" ) { |
1153 | if ( tokens[1] == mPassWord ) { | 1153 | if ( tokens[1] == mPassWord ) { |
1154 | //emit getFile( mSocket ); | 1154 | //emit getFile( mSocket ); |
1155 | blockRC = true; | 1155 | blockRC = true; |
1156 | get_file(); | 1156 | get_file(); |
1157 | } | 1157 | } |
1158 | else { | 1158 | else { |
1159 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); | 1159 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); |
1160 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1160 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1161 | } | 1161 | } |
1162 | } | 1162 | } |
1163 | if ( tokens[0] == "STOP" ) { | 1163 | if ( tokens[0] == "STOP" ) { |
1164 | //emit endConnect(); | 1164 | //emit endConnect(); |
1165 | end_connect(); | 1165 | end_connect(); |
1166 | } | 1166 | } |
1167 | } | 1167 | } |
1168 | } | 1168 | } |
1169 | void KServerSocket::end_connect() | 1169 | void KServerSocket::end_connect() |
1170 | { | 1170 | { |
1171 | delete mSyncActionDialog; | 1171 | delete mSyncActionDialog; |
1172 | mSyncActionDialog = 0; | 1172 | mSyncActionDialog = 0; |
1173 | } | 1173 | } |
1174 | void KServerSocket::send_file() | 1174 | void KServerSocket::send_file() |
1175 | { | 1175 | { |
1176 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 1176 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
1177 | if ( mSyncActionDialog ) | 1177 | if ( mSyncActionDialog ) |
1178 | delete mSyncActionDialog; | 1178 | delete mSyncActionDialog; |
1179 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 1179 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
1180 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 1180 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
1181 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 1181 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
1182 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1182 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1183 | lay->addWidget( label); | 1183 | lay->addWidget( label); |
1184 | lay->setMargin(7); | 1184 | lay->setMargin(7); |
1185 | lay->setSpacing(7); | 1185 | lay->setSpacing(7); |
1186 | mSyncActionDialog->setFixedSize( 230, 120); | 1186 | mSyncActionDialog->setFixedSize( 230, 120); |
1187 | mSyncActionDialog->show(); | 1187 | mSyncActionDialog->show(); |
1188 | mSyncActionDialog->raise(); | 1188 | mSyncActionDialog->raise(); |
1189 | emit request_file(); | 1189 | emit request_file(); |
1190 | qApp->processEvents(); | 1190 | qApp->processEvents(); |
1191 | QString fileName = mFileName; | 1191 | QString fileName = mFileName; |
1192 | QFile file( fileName ); | 1192 | QFile file( fileName ); |
1193 | if (!file.open( IO_ReadOnly ) ) { | 1193 | if (!file.open( IO_ReadOnly ) ) { |
1194 | delete mSyncActionDialog; | 1194 | delete mSyncActionDialog; |
1195 | mSyncActionDialog = 0; | 1195 | mSyncActionDialog = 0; |
1196 | qDebug("KSS::error open file "); | 1196 | qDebug("KSS::error open file "); |
1197 | mSocket->close(); | 1197 | mSocket->close(); |
1198 | if ( mSocket->state() == QSocket::Idle ) | 1198 | if ( mSocket->state() == QSocket::Idle ) |
1199 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1199 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1200 | return ; | 1200 | return ; |
1201 | 1201 | ||
1202 | } | 1202 | } |
1203 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 1203 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
1204 | QTextStream ts( &file ); | 1204 | QTextStream ts( &file ); |
1205 | ts.setEncoding( QTextStream::Latin1 ); | 1205 | ts.setEncoding( QTextStream::Latin1 ); |
1206 | 1206 | ||
1207 | QTextStream os( mSocket ); | 1207 | QTextStream os( mSocket ); |
1208 | os.setEncoding( QTextStream::Latin1 ); | 1208 | os.setEncoding( QTextStream::Latin1 ); |
1209 | while ( ! ts.atEnd() ) { | 1209 | while ( ! ts.atEnd() ) { |
1210 | os << ts.readLine() << "\r\n"; | 1210 | os << ts.readLine() << "\r\n"; |
1211 | } | 1211 | } |
1212 | //os << ts.read(); | 1212 | //os << ts.read(); |
1213 | file.close(); | 1213 | file.close(); |
1214 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 1214 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
1215 | mSocket->close(); | 1215 | mSocket->close(); |
1216 | if ( mSocket->state() == QSocket::Idle ) | 1216 | if ( mSocket->state() == QSocket::Idle ) |
1217 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1217 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1218 | } | 1218 | } |
1219 | void KServerSocket::get_file() | 1219 | void KServerSocket::get_file() |
1220 | { | 1220 | { |
1221 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1221 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1222 | 1222 | ||
1223 | piTime.start(); | 1223 | piTime.start(); |
1224 | piFileString = ""; | 1224 | piFileString = ""; |
1225 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1225 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1226 | } | 1226 | } |
1227 | 1227 | ||
1228 | 1228 | ||
1229 | void KServerSocket::readBackFileFromSocket() | 1229 | void KServerSocket::readBackFileFromSocket() |
1230 | { | 1230 | { |
1231 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1231 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
1232 | while ( mSocket->canReadLine () ) { | 1232 | while ( mSocket->canReadLine () ) { |
1233 | piTime.restart(); | 1233 | piTime.restart(); |
1234 | QString line = mSocket->readLine (); | 1234 | QString line = mSocket->readLine (); |
1235 | piFileString += line; | 1235 | piFileString += line; |
1236 | //qDebug("readline: %s ", line.latin1()); | 1236 | //qDebug("readline: %s ", line.latin1()); |
1237 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1237 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
1238 | 1238 | ||
1239 | } | 1239 | } |
1240 | if ( piTime.elapsed () < 3000 ) { | 1240 | if ( piTime.elapsed () < 3000 ) { |
1241 | // wait for more | 1241 | // wait for more |
1242 | //qDebug("waitformore "); | 1242 | //qDebug("waitformore "); |
1243 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1243 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
1244 | return; | 1244 | return; |
1245 | } | 1245 | } |
1246 | QString fileName = mFileName; | 1246 | QString fileName = mFileName; |
1247 | QFile file ( fileName ); | 1247 | QFile file ( fileName ); |
1248 | if (!file.open( IO_WriteOnly ) ) { | 1248 | if (!file.open( IO_WriteOnly ) ) { |
1249 | delete mSyncActionDialog; | 1249 | delete mSyncActionDialog; |
1250 | mSyncActionDialog = 0; | 1250 | mSyncActionDialog = 0; |
1251 | qDebug("KSS:Error open read back file "); | 1251 | qDebug("KSS:Error open read back file "); |
1252 | piFileString = ""; | 1252 | piFileString = ""; |
1253 | emit file_received( false ); | 1253 | emit file_received( false ); |
1254 | blockRC = false; | 1254 | blockRC = false; |
1255 | return ; | 1255 | return ; |
1256 | 1256 | ||
1257 | } | 1257 | } |
1258 | 1258 | ||
1259 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1259 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1260 | QTextStream ts ( &file ); | 1260 | QTextStream ts ( &file ); |
1261 | ts.setEncoding( QTextStream::Latin1 ); | 1261 | ts.setEncoding( QTextStream::Latin1 ); |
1262 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1262 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1263 | ts << piFileString; | 1263 | ts << piFileString; |
1264 | mSocket->close(); | 1264 | mSocket->close(); |
1265 | if ( mSocket->state() == QSocket::Idle ) | 1265 | if ( mSocket->state() == QSocket::Idle ) |
1266 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1266 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1267 | file.close(); | 1267 | file.close(); |
1268 | piFileString = ""; | 1268 | piFileString = ""; |
1269 | emit file_received( true ); | 1269 | emit file_received( true ); |
1270 | delete mSyncActionDialog; | 1270 | delete mSyncActionDialog; |
1271 | mSyncActionDialog = 0; | 1271 | mSyncActionDialog = 0; |
1272 | blockRC = false; | 1272 | blockRC = false; |
1273 | 1273 | ||
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 1276 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
1277 | { | 1277 | { |
1278 | mPassWord = password; | 1278 | mPassWord = password; |
1279 | mSocket = 0; | 1279 | mSocket = 0; |
1280 | mPort = port; | 1280 | mPort = port; |
1281 | mHost = host; | 1281 | mHost = host; |
1282 | 1282 | ||
1283 | mRetVal = quiet; | 1283 | mRetVal = quiet; |
1284 | mTimerSocket = new QTimer ( this ); | 1284 | mTimerSocket = new QTimer ( this ); |
1285 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 1285 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
1286 | } | 1286 | } |
1287 | void KCommandSocket::readFile( QString fn ) | 1287 | void KCommandSocket::readFile( QString fn ) |
1288 | { | 1288 | { |
1289 | if ( !mSocket ) { | 1289 | if ( !mSocket ) { |
1290 | mSocket = new QSocket( this ); | 1290 | mSocket = new QSocket( this ); |
1291 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1291 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1292 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1292 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1293 | } | 1293 | } |
1294 | mFileString = ""; | 1294 | mFileString = ""; |
1295 | mFileName = fn; | 1295 | mFileName = fn; |
1296 | mFirst = true; | 1296 | mFirst = true; |
1297 | mSocket->connectToHost( mHost, mPort ); | 1297 | mSocket->connectToHost( mHost, mPort ); |
1298 | QTextStream os( mSocket ); | 1298 | QTextStream os( mSocket ); |
1299 | os.setEncoding( QTextStream::Latin1 ); | 1299 | os.setEncoding( QTextStream::Latin1 ); |
1300 | 1300 | ||
1301 | QString curDt = KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); | 1301 | QString curDt = KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); |
1302 | os << "GET " << mPassWord << curDt <<"\r\n"; | 1302 | os << "GET " << mPassWord << curDt <<"\r\n"; |
1303 | mTimerSocket->start( 20000 ); | 1303 | mTimerSocket->start( 20000 ); |
1304 | } | 1304 | } |
1305 | 1305 | ||
1306 | void KCommandSocket::writeFile( QString fileName ) | 1306 | void KCommandSocket::writeFile( QString fileName ) |
1307 | { | 1307 | { |
1308 | if ( !mSocket ) { | 1308 | if ( !mSocket ) { |
1309 | mSocket = new QSocket( this ); | 1309 | mSocket = new QSocket( this ); |
1310 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1310 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1311 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1311 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1312 | } | 1312 | } |
1313 | mFileName = fileName ; | 1313 | mFileName = fileName ; |
1314 | mSocket->connectToHost( mHost, mPort ); | 1314 | mSocket->connectToHost( mHost, mPort ); |
1315 | } | 1315 | } |
1316 | void KCommandSocket::writeFileToSocket() | 1316 | void KCommandSocket::writeFileToSocket() |
1317 | { | 1317 | { |
1318 | QFile file2( mFileName ); | 1318 | QFile file2( mFileName ); |
1319 | if (!file2.open( IO_ReadOnly ) ) { | 1319 | if (!file2.open( IO_ReadOnly ) ) { |
1320 | mRetVal= errorW; | 1320 | mRetVal= errorW; |
1321 | mSocket->close(); | 1321 | mSocket->close(); |
1322 | if ( mSocket->state() == QSocket::Idle ) | 1322 | if ( mSocket->state() == QSocket::Idle ) |
1323 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1323 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1324 | return ; | 1324 | return ; |
1325 | } | 1325 | } |
1326 | QTextStream ts2( &file2 ); | 1326 | QTextStream ts2( &file2 ); |
1327 | ts2.setEncoding( QTextStream::Latin1 ); | 1327 | ts2.setEncoding( QTextStream::Latin1 ); |
1328 | QTextStream os2( mSocket ); | 1328 | QTextStream os2( mSocket ); |
1329 | os2.setEncoding( QTextStream::Latin1 ); | 1329 | os2.setEncoding( QTextStream::Latin1 ); |
1330 | os2 << "PUT " << mPassWord << "\r\n";; | 1330 | os2 << "PUT " << mPassWord << "\r\n";; |
1331 | while ( ! ts2.atEnd() ) { | 1331 | while ( ! ts2.atEnd() ) { |
1332 | os2 << ts2.readLine() << "\r\n"; | 1332 | os2 << ts2.readLine() << "\r\n"; |
1333 | } | 1333 | } |
1334 | mRetVal= successW; | 1334 | mRetVal= successW; |
1335 | file2.close(); | 1335 | file2.close(); |
1336 | mSocket->close(); | 1336 | mSocket->close(); |
1337 | if ( mSocket->state() == QSocket::Idle ) | 1337 | if ( mSocket->state() == QSocket::Idle ) |
1338 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1338 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1339 | } | 1339 | } |
1340 | void KCommandSocket::sendStop() | 1340 | void KCommandSocket::sendStop() |
1341 | { | 1341 | { |
1342 | if ( !mSocket ) { | 1342 | if ( !mSocket ) { |
1343 | mSocket = new QSocket( this ); | 1343 | mSocket = new QSocket( this ); |
1344 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1344 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1345 | } | 1345 | } |
1346 | mSocket->connectToHost( mHost, mPort ); | 1346 | mSocket->connectToHost( mHost, mPort ); |
1347 | QTextStream os2( mSocket ); | 1347 | QTextStream os2( mSocket ); |
1348 | os2.setEncoding( QTextStream::Latin1 ); | 1348 | os2.setEncoding( QTextStream::Latin1 ); |
1349 | os2 << "STOP\r\n"; | 1349 | os2 << "STOP\r\n"; |
1350 | mSocket->close(); | 1350 | mSocket->close(); |
1351 | if ( mSocket->state() == QSocket::Idle ) | 1351 | if ( mSocket->state() == QSocket::Idle ) |
1352 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1352 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | void KCommandSocket::startReadFileFromSocket() | 1355 | void KCommandSocket::startReadFileFromSocket() |
1356 | { | 1356 | { |
1357 | if ( ! mFirst ) | 1357 | if ( ! mFirst ) |
1358 | return; | 1358 | return; |
1359 | mFirst = false; | 1359 | mFirst = false; |
1360 | mTimerSocket->stop(); | 1360 | mTimerSocket->stop(); |
1361 | mFileString = ""; | 1361 | mFileString = ""; |
1362 | mTime.start(); | 1362 | mTime.start(); |
1363 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1363 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1364 | 1364 | ||
1365 | } | 1365 | } |
1366 | void KCommandSocket::readFileFromSocket() | 1366 | void KCommandSocket::readFileFromSocket() |
1367 | { | 1367 | { |
1368 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1368 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1369 | while ( mSocket->canReadLine () ) { | 1369 | while ( mSocket->canReadLine () ) { |
1370 | mTime.restart(); | 1370 | mTime.restart(); |
1371 | QString line = mSocket->readLine (); | 1371 | QString line = mSocket->readLine (); |
1372 | mFileString += line; | 1372 | mFileString += line; |
1373 | //qDebug("readline: %s ", line.latin1()); | 1373 | //qDebug("readline: %s ", line.latin1()); |
1374 | } | 1374 | } |
1375 | if ( mTime.elapsed () < 3000 ) { | 1375 | if ( mTime.elapsed () < 3000 ) { |
1376 | // wait for more | 1376 | // wait for more |
1377 | //qDebug("waitformore "); | 1377 | //qDebug("waitformore "); |
1378 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1378 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1379 | return; | 1379 | return; |
1380 | } | 1380 | } |
1381 | QString fileName = mFileName; | 1381 | QString fileName = mFileName; |
1382 | QFile file ( fileName ); | 1382 | QFile file ( fileName ); |
1383 | if (!file.open( IO_WriteOnly ) ) { | 1383 | if (!file.open( IO_WriteOnly ) ) { |
1384 | mFileString = ""; | 1384 | mFileString = ""; |
1385 | mRetVal = errorR; | 1385 | mRetVal = errorR; |
1386 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); | 1386 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); |
1387 | deleteSocket(); | 1387 | deleteSocket(); |
1388 | return ; | 1388 | return ; |
1389 | 1389 | ||
1390 | } | 1390 | } |
1391 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1391 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1392 | QTextStream ts ( &file ); | 1392 | QTextStream ts ( &file ); |
1393 | ts.setEncoding( QTextStream::Latin1 ); | 1393 | ts.setEncoding( QTextStream::Latin1 ); |
1394 | ts << mFileString; | 1394 | ts << mFileString; |
1395 | file.close(); | 1395 | file.close(); |
1396 | mFileString = ""; | 1396 | mFileString = ""; |
1397 | mRetVal = successR; | 1397 | mRetVal = successR; |
1398 | mSocket->close(); | 1398 | mSocket->close(); |
1399 | // if state is not idle, deleteSocket(); is called via | 1399 | // if state is not idle, deleteSocket(); is called via |
1400 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1400 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1401 | if ( mSocket->state() == QSocket::Idle ) | 1401 | if ( mSocket->state() == QSocket::Idle ) |
1402 | deleteSocket(); | 1402 | deleteSocket(); |
1403 | } | 1403 | } |
1404 | 1404 | ||
1405 | void KCommandSocket::deleteSocket() | 1405 | void KCommandSocket::deleteSocket() |
1406 | { | 1406 | { |
1407 | //qDebug("KCommandSocket::deleteSocket() "); | 1407 | //qDebug("KCommandSocket::deleteSocket() "); |
1408 | if ( mTimerSocket->isActive () ) { | 1408 | if ( mTimerSocket->isActive () ) { |
1409 | mTimerSocket->stop(); | 1409 | mTimerSocket->stop(); |
1410 | mRetVal = errorTO; | 1410 | mRetVal = errorTO; |
1411 | qDebug("Connection to remote host timed out"); | 1411 | qDebug("Connection to remote host timed out"); |
1412 | if ( mSocket ) { | 1412 | if ( mSocket ) { |
1413 | mSocket->close(); | 1413 | mSocket->close(); |
1414 | //if ( mSocket->state() == QSocket::Idle ) | 1414 | //if ( mSocket->state() == QSocket::Idle ) |
1415 | // deleteSocket(); | 1415 | // deleteSocket(); |
1416 | delete mSocket; | 1416 | delete mSocket; |
1417 | mSocket = 0; | 1417 | mSocket = 0; |
1418 | } | 1418 | } |
1419 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 1419 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
1420 | emit commandFinished( this, mRetVal ); | 1420 | emit commandFinished( this, mRetVal ); |
1421 | return; | 1421 | return; |
1422 | } | 1422 | } |
1423 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1423 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1424 | if ( mSocket) | 1424 | if ( mSocket) |
1425 | delete mSocket; | 1425 | delete mSocket; |
1426 | mSocket = 0; | 1426 | mSocket = 0; |
1427 | emit commandFinished( this, mRetVal ); | 1427 | emit commandFinished( this, mRetVal ); |
1428 | } | 1428 | } |