author | zautrix <zautrix> | 2004-10-18 09:08:13 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-18 09:08:13 (UTC) |
commit | 56990d318b15eacf7d3cc7425ab62f68da099ddf (patch) (unidiff) | |
tree | b2f021bd75bc6a08fa8fc51a07ce1755b8e4a95e | |
parent | 1712d92ea25b220273859d985bc7211fa7a97a39 (diff) | |
download | kdepimpi-56990d318b15eacf7d3cc7425ab62f68da099ddf.zip kdepimpi-56990d318b15eacf7d3cc7425ab62f68da099ddf.tar.gz kdepimpi-56990d318b15eacf7d3cc7425ab62f68da099ddf.tar.bz2 |
fix of tmp file path for desktop version
-rw-r--r-- | kaddressbook/kabcore.cpp | 57 | ||||
-rw-r--r-- | kmicromail/viewmail.cpp | 4 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 5 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 6 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 4 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 4 | ||||
-rw-r--r-- | version | 2 |
7 files changed, 22 insertions, 60 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 2e408b7..11eeabc 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2876 +1,2837 @@ | |||
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 | 297 | ||
298 | 298 | ||
299 | #ifndef KAB_EMBEDDED | 299 | #ifndef KAB_EMBEDDED |
300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
302 | 302 | ||
303 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 303 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
304 | SLOT( browse( const QString& ) ) ); | 304 | SLOT( browse( const QString& ) ) ); |
305 | 305 | ||
306 | 306 | ||
307 | mAddressBookService = new KAddressBookService( this ); | 307 | mAddressBookService = new KAddressBookService( this ); |
308 | 308 | ||
309 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
310 | 310 | ||
311 | mMessageTimer = new QTimer( this ); | 311 | mMessageTimer = new QTimer( this ); |
312 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 312 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
313 | mEditorDialog = 0; | 313 | mEditorDialog = 0; |
314 | createAddresseeEditorDialog( this ); | 314 | createAddresseeEditorDialog( this ); |
315 | setModified( false ); | 315 | setModified( false ); |
316 | } | 316 | } |
317 | 317 | ||
318 | KABCore::~KABCore() | 318 | KABCore::~KABCore() |
319 | { | 319 | { |
320 | // save(); | 320 | // save(); |
321 | //saveSettings(); | 321 | //saveSettings(); |
322 | //KABPrefs::instance()->writeConfig(); | 322 | //KABPrefs::instance()->writeConfig(); |
323 | delete AddresseeConfig::instance(); | 323 | delete AddresseeConfig::instance(); |
324 | mAddressBook = 0; | 324 | mAddressBook = 0; |
325 | KABC::StdAddressBook::close(); | 325 | KABC::StdAddressBook::close(); |
326 | 326 | ||
327 | delete syncManager; | 327 | delete syncManager; |
328 | 328 | ||
329 | } | 329 | } |
330 | 330 | ||
331 | void KABCore::recieve( QString fn ) | 331 | void KABCore::recieve( QString fn ) |
332 | { | 332 | { |
333 | //qDebug("KABCore::recieve "); | 333 | //qDebug("KABCore::recieve "); |
334 | int count = mAddressBook->importFromFile( fn, true ); | 334 | int count = mAddressBook->importFromFile( fn, true ); |
335 | mViewManager->refreshView(); | 335 | mViewManager->refreshView(); |
336 | message(i18n("%1 contact(s) received!").arg( count )); | 336 | message(i18n("%1 contact(s) received!").arg( count )); |
337 | topLevelWidget()->showMaximized(); | 337 | topLevelWidget()->showMaximized(); |
338 | topLevelWidget()->raise(); | 338 | topLevelWidget()->raise(); |
339 | } | 339 | } |
340 | void KABCore::restoreSettings() | 340 | void KABCore::restoreSettings() |
341 | { | 341 | { |
342 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 342 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
343 | 343 | ||
344 | bool state; | 344 | bool state; |
345 | 345 | ||
346 | if (mMultipleViewsAtOnce) | 346 | if (mMultipleViewsAtOnce) |
347 | state = KABPrefs::instance()->mDetailsPageVisible; | 347 | state = KABPrefs::instance()->mDetailsPageVisible; |
348 | else | 348 | else |
349 | state = false; | 349 | state = false; |
350 | 350 | ||
351 | mActionDetails->setChecked( state ); | 351 | mActionDetails->setChecked( state ); |
352 | setDetailsVisible( state ); | 352 | setDetailsVisible( state ); |
353 | 353 | ||
354 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 354 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
355 | 355 | ||
356 | mActionJumpBar->setChecked( state ); | 356 | mActionJumpBar->setChecked( state ); |
357 | setJumpButtonBarVisible( state ); | 357 | setJumpButtonBarVisible( state ); |
358 | /*US | 358 | /*US |
359 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 359 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
360 | if ( splitterSize.count() == 0 ) { | 360 | if ( splitterSize.count() == 0 ) { |
361 | splitterSize.append( width() / 2 ); | 361 | splitterSize.append( width() / 2 ); |
362 | splitterSize.append( width() / 2 ); | 362 | splitterSize.append( width() / 2 ); |
363 | } | 363 | } |
364 | mMiniSplitter->setSizes( splitterSize ); | 364 | mMiniSplitter->setSizes( splitterSize ); |
365 | if ( mExtensionBarSplitter ) { | 365 | if ( mExtensionBarSplitter ) { |
366 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 366 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
367 | if ( splitterSize.count() == 0 ) { | 367 | if ( splitterSize.count() == 0 ) { |
368 | splitterSize.append( width() / 2 ); | 368 | splitterSize.append( width() / 2 ); |
369 | splitterSize.append( width() / 2 ); | 369 | splitterSize.append( width() / 2 ); |
370 | } | 370 | } |
371 | mExtensionBarSplitter->setSizes( splitterSize ); | 371 | mExtensionBarSplitter->setSizes( splitterSize ); |
372 | 372 | ||
373 | } | 373 | } |
374 | */ | 374 | */ |
375 | mViewManager->restoreSettings(); | 375 | mViewManager->restoreSettings(); |
376 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 376 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
377 | mExtensionManager->restoreSettings(); | 377 | mExtensionManager->restoreSettings(); |
378 | #ifdef DESKTOP_VERSION | 378 | #ifdef DESKTOP_VERSION |
379 | int wid = width(); | 379 | int wid = width(); |
380 | if ( wid < 10 ) | 380 | if ( wid < 10 ) |
381 | wid = 400; | 381 | wid = 400; |
382 | #else | 382 | #else |
383 | int wid = QApplication::desktop()->width(); | 383 | int wid = QApplication::desktop()->width(); |
384 | if ( wid < 640 ) | 384 | if ( wid < 640 ) |
385 | wid = QApplication::desktop()->height(); | 385 | wid = QApplication::desktop()->height(); |
386 | #endif | 386 | #endif |
387 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 387 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
388 | if ( true /*splitterSize.count() == 0*/ ) { | 388 | if ( true /*splitterSize.count() == 0*/ ) { |
389 | splitterSize.append( wid / 2 ); | 389 | splitterSize.append( wid / 2 ); |
390 | splitterSize.append( wid / 2 ); | 390 | splitterSize.append( wid / 2 ); |
391 | } | 391 | } |
392 | mMiniSplitter->setSizes( splitterSize ); | 392 | mMiniSplitter->setSizes( splitterSize ); |
393 | if ( mExtensionBarSplitter ) { | 393 | if ( mExtensionBarSplitter ) { |
394 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 394 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
395 | if ( true /*splitterSize.count() == 0*/ ) { | 395 | if ( true /*splitterSize.count() == 0*/ ) { |
396 | splitterSize.append( wid / 2 ); | 396 | splitterSize.append( wid / 2 ); |
397 | splitterSize.append( wid / 2 ); | 397 | splitterSize.append( wid / 2 ); |
398 | } | 398 | } |
399 | mExtensionBarSplitter->setSizes( splitterSize ); | 399 | mExtensionBarSplitter->setSizes( splitterSize ); |
400 | 400 | ||
401 | } | 401 | } |
402 | 402 | ||
403 | 403 | ||
404 | } | 404 | } |
405 | 405 | ||
406 | void KABCore::saveSettings() | 406 | void KABCore::saveSettings() |
407 | { | 407 | { |
408 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 408 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
409 | if ( mExtensionBarSplitter ) | 409 | if ( mExtensionBarSplitter ) |
410 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 410 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
411 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 411 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
412 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 412 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
413 | #ifndef KAB_EMBEDDED | 413 | #ifndef KAB_EMBEDDED |
414 | 414 | ||
415 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 415 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
416 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 416 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
417 | #endif //KAB_EMBEDDED | 417 | #endif //KAB_EMBEDDED |
418 | mExtensionManager->saveSettings(); | 418 | mExtensionManager->saveSettings(); |
419 | mViewManager->saveSettings(); | 419 | mViewManager->saveSettings(); |
420 | 420 | ||
421 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 421 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
422 | } | 422 | } |
423 | 423 | ||
424 | KABC::AddressBook *KABCore::addressBook() const | 424 | KABC::AddressBook *KABCore::addressBook() const |
425 | { | 425 | { |
426 | return mAddressBook; | 426 | return mAddressBook; |
427 | } | 427 | } |
428 | 428 | ||
429 | KConfig *KABCore::config() | 429 | KConfig *KABCore::config() |
430 | { | 430 | { |
431 | #ifndef KAB_EMBEDDED | 431 | #ifndef KAB_EMBEDDED |
432 | return KABPrefs::instance()->config(); | 432 | return KABPrefs::instance()->config(); |
433 | #else //KAB_EMBEDDED | 433 | #else //KAB_EMBEDDED |
434 | return KABPrefs::instance()->getConfig(); | 434 | return KABPrefs::instance()->getConfig(); |
435 | #endif //KAB_EMBEDDED | 435 | #endif //KAB_EMBEDDED |
436 | } | 436 | } |
437 | 437 | ||
438 | KActionCollection *KABCore::actionCollection() const | 438 | KActionCollection *KABCore::actionCollection() const |
439 | { | 439 | { |
440 | return mGUIClient->actionCollection(); | 440 | return mGUIClient->actionCollection(); |
441 | } | 441 | } |
442 | 442 | ||
443 | KABC::Field *KABCore::currentSearchField() const | 443 | KABC::Field *KABCore::currentSearchField() const |
444 | { | 444 | { |
445 | if (mIncSearchWidget) | 445 | if (mIncSearchWidget) |
446 | return mIncSearchWidget->currentField(); | 446 | return mIncSearchWidget->currentField(); |
447 | else | 447 | else |
448 | return 0; | 448 | return 0; |
449 | } | 449 | } |
450 | 450 | ||
451 | QStringList KABCore::selectedUIDs() const | 451 | QStringList KABCore::selectedUIDs() const |
452 | { | 452 | { |
453 | return mViewManager->selectedUids(); | 453 | return mViewManager->selectedUids(); |
454 | } | 454 | } |
455 | 455 | ||
456 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 456 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
457 | { | 457 | { |
458 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 458 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
459 | 459 | ||
460 | QPtrList<KRES::Resource> kresResources; | 460 | QPtrList<KRES::Resource> kresResources; |
461 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 461 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
462 | KABC::Resource *resource; | 462 | KABC::Resource *resource; |
463 | while ( ( resource = resIt.current() ) != 0 ) { | 463 | while ( ( resource = resIt.current() ) != 0 ) { |
464 | ++resIt; | 464 | ++resIt; |
465 | if ( !resource->readOnly() ) { | 465 | if ( !resource->readOnly() ) { |
466 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 466 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
467 | if ( res ) | 467 | if ( res ) |
468 | kresResources.append( res ); | 468 | kresResources.append( res ); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | 471 | ||
472 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 472 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
473 | return static_cast<KABC::Resource*>( res ); | 473 | return static_cast<KABC::Resource*>( res ); |
474 | } | 474 | } |
475 | 475 | ||
476 | #ifndef KAB_EMBEDDED | 476 | #ifndef KAB_EMBEDDED |
477 | KAboutData *KABCore::createAboutData() | 477 | KAboutData *KABCore::createAboutData() |
478 | #else //KAB_EMBEDDED | 478 | #else //KAB_EMBEDDED |
479 | void KABCore::createAboutData() | 479 | void KABCore::createAboutData() |
480 | #endif //KAB_EMBEDDED | 480 | #endif //KAB_EMBEDDED |
481 | { | 481 | { |
482 | #ifndef KAB_EMBEDDED | 482 | #ifndef KAB_EMBEDDED |
483 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 483 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
484 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 484 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
485 | KAboutData::License_GPL_V2, | 485 | KAboutData::License_GPL_V2, |
486 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 486 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
487 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 487 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
488 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 488 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
489 | about->addAuthor( "Cornelius Schumacher", | 489 | about->addAuthor( "Cornelius Schumacher", |
490 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 490 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
491 | "schumacher@kde.org" ); | 491 | "schumacher@kde.org" ); |
492 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 492 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
493 | "mpilone@slac.com" ); | 493 | "mpilone@slac.com" ); |
494 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 494 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
495 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 495 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
496 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 496 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
497 | "michel@klaralvdalens-datakonsult.se" ); | 497 | "michel@klaralvdalens-datakonsult.se" ); |
498 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 498 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
499 | "hansen@kde.org" ); | 499 | "hansen@kde.org" ); |
500 | 500 | ||
501 | return about; | 501 | return about; |
502 | #endif //KAB_EMBEDDED | 502 | #endif //KAB_EMBEDDED |
503 | 503 | ||
504 | QString version; | 504 | QString version; |
505 | #include <../version> | 505 | #include <../version> |
506 | QMessageBox::about( this, "About KAddressbook/Pi", | 506 | QMessageBox::about( this, "About KAddressbook/Pi", |
507 | "KAddressbook/Platform-independent\n" | 507 | "KAddressbook/Platform-independent\n" |
508 | "(KA/Pi) " +version + " - " + | 508 | "(KA/Pi) " +version + " - " + |
509 | #ifdef DESKTOP_VERSION | 509 | #ifdef DESKTOP_VERSION |
510 | "Desktop Edition\n" | 510 | "Desktop Edition\n" |
511 | #else | 511 | #else |
512 | "PDA-Edition\n" | 512 | "PDA-Edition\n" |
513 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 513 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
514 | #endif | 514 | #endif |
515 | 515 | ||
516 | "(c) 2004 Ulf Schenk\n" | 516 | "(c) 2004 Ulf Schenk\n" |
517 | "(c) 2004 Lutz Rogowski\n" | 517 | "(c) 2004 Lutz Rogowski\n" |
518 | "(c) 1997-2003, The KDE PIM Team\n" | 518 | "(c) 1997-2003, The KDE PIM Team\n" |
519 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 519 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
520 | "Don Sanders Original author\n" | 520 | "Don Sanders Original author\n" |
521 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 521 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
522 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 522 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
523 | "Greg Stern DCOP interface\n" | 523 | "Greg Stern DCOP interface\n" |
524 | "Mark Westcot Contact pinning\n" | 524 | "Mark Westcot Contact pinning\n" |
525 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 525 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
526 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 526 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
527 | #ifdef _WIN32_ | 527 | #ifdef _WIN32_ |
528 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 528 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
529 | #endif | 529 | #endif |
530 | ); | 530 | ); |
531 | } | 531 | } |
532 | 532 | ||
533 | void KABCore::setContactSelected( const QString &uid ) | 533 | void KABCore::setContactSelected( const QString &uid ) |
534 | { | 534 | { |
535 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 535 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
536 | if ( !mDetails->isHidden() ) | 536 | if ( !mDetails->isHidden() ) |
537 | mDetails->setAddressee( addr ); | 537 | mDetails->setAddressee( addr ); |
538 | 538 | ||
539 | if ( !addr.isEmpty() ) { | 539 | if ( !addr.isEmpty() ) { |
540 | emit contactSelected( addr.formattedName() ); | 540 | emit contactSelected( addr.formattedName() ); |
541 | KABC::Picture pic = addr.photo(); | 541 | KABC::Picture pic = addr.photo(); |
542 | if ( pic.isIntern() ) { | 542 | if ( pic.isIntern() ) { |
543 | //US emit contactSelected( pic.data() ); | 543 | //US emit contactSelected( pic.data() ); |
544 | //US instead use: | 544 | //US instead use: |
545 | QPixmap px; | 545 | QPixmap px; |
546 | if (pic.data().isNull() != true) | 546 | if (pic.data().isNull() != true) |
547 | { | 547 | { |
548 | px.convertFromImage(pic.data()); | 548 | px.convertFromImage(pic.data()); |
549 | } | 549 | } |
550 | 550 | ||
551 | emit contactSelected( px ); | 551 | emit contactSelected( px ); |
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | 555 | ||
556 | mExtensionManager->setSelectionChanged(); | 556 | mExtensionManager->setSelectionChanged(); |
557 | 557 | ||
558 | // update the actions | 558 | // update the actions |
559 | bool selected = !uid.isEmpty(); | 559 | bool selected = !uid.isEmpty(); |
560 | 560 | ||
561 | if ( mReadWrite ) { | 561 | if ( mReadWrite ) { |
562 | mActionCut->setEnabled( selected ); | 562 | mActionCut->setEnabled( selected ); |
563 | mActionPaste->setEnabled( selected ); | 563 | mActionPaste->setEnabled( selected ); |
564 | } | 564 | } |
565 | 565 | ||
566 | mActionCopy->setEnabled( selected ); | 566 | mActionCopy->setEnabled( selected ); |
567 | mActionDelete->setEnabled( selected ); | 567 | mActionDelete->setEnabled( selected ); |
568 | mActionEditAddressee->setEnabled( selected ); | 568 | mActionEditAddressee->setEnabled( selected ); |
569 | mActionMail->setEnabled( selected ); | 569 | mActionMail->setEnabled( selected ); |
570 | mActionMailVCard->setEnabled( selected ); | 570 | mActionMailVCard->setEnabled( selected ); |
571 | //if (mActionBeam) | 571 | //if (mActionBeam) |
572 | //mActionBeam->setEnabled( selected ); | 572 | //mActionBeam->setEnabled( selected ); |
573 | 573 | ||
574 | if (mActionBeamVCard) | 574 | if (mActionBeamVCard) |
575 | mActionBeamVCard->setEnabled( selected ); | 575 | mActionBeamVCard->setEnabled( selected ); |
576 | 576 | ||
577 | mActionExport2phone->setEnabled( selected ); | 577 | mActionExport2phone->setEnabled( selected ); |
578 | mActionWhoAmI->setEnabled( selected ); | 578 | mActionWhoAmI->setEnabled( selected ); |
579 | mActionCategories->setEnabled( selected ); | 579 | mActionCategories->setEnabled( selected ); |
580 | } | 580 | } |
581 | 581 | ||
582 | void KABCore::sendMail() | 582 | void KABCore::sendMail() |
583 | { | 583 | { |
584 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 584 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
585 | } | 585 | } |
586 | 586 | ||
587 | void KABCore::sendMail( const QString& emaillist ) | 587 | void KABCore::sendMail( const QString& emaillist ) |
588 | { | 588 | { |
589 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 589 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
590 | if (emaillist.contains(",") > 0) | 590 | if (emaillist.contains(",") > 0) |
591 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 591 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
592 | else | 592 | else |
593 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 593 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
594 | } | 594 | } |
595 | 595 | ||
596 | 596 | ||
597 | 597 | ||
598 | void KABCore::mailVCard() | 598 | void KABCore::mailVCard() |
599 | { | 599 | { |
600 | QStringList uids = mViewManager->selectedUids(); | 600 | QStringList uids = mViewManager->selectedUids(); |
601 | if ( !uids.isEmpty() ) | 601 | if ( !uids.isEmpty() ) |
602 | mailVCard( uids ); | 602 | mailVCard( uids ); |
603 | } | 603 | } |
604 | 604 | ||
605 | void KABCore::mailVCard( const QStringList& uids ) | 605 | void KABCore::mailVCard( const QStringList& uids ) |
606 | { | 606 | { |
607 | QStringList urls; | 607 | QStringList urls; |
608 | 608 | ||
609 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 609 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
610 | 610 | ||
611 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 611 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
612 | 612 | ||
613 | 613 | ||
614 | 614 | ||
615 | QDir().mkdir( dirName, true ); | 615 | QDir().mkdir( dirName, true ); |
616 | 616 | ||
617 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 617 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
618 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 618 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
619 | 619 | ||
620 | if ( a.isEmpty() ) | 620 | if ( a.isEmpty() ) |
621 | continue; | 621 | continue; |
622 | 622 | ||
623 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 623 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
624 | 624 | ||
625 | QString fileName = dirName + "/" + name; | 625 | QString fileName = dirName + "/" + name; |
626 | 626 | ||
627 | QFile outFile(fileName); | 627 | QFile outFile(fileName); |
628 | 628 | ||
629 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 629 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
630 | KABC::VCardConverter converter; | 630 | KABC::VCardConverter converter; |
631 | QString vcard; | 631 | QString vcard; |
632 | 632 | ||
633 | converter.addresseeToVCard( a, vcard ); | 633 | converter.addresseeToVCard( a, vcard ); |
634 | 634 | ||
635 | QTextStream t( &outFile ); // use a text stream | 635 | QTextStream t( &outFile ); // use a text stream |
636 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 636 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
637 | t << vcard; | 637 | t << vcard; |
638 | 638 | ||
639 | outFile.close(); | 639 | outFile.close(); |
640 | 640 | ||
641 | urls.append( fileName ); | 641 | urls.append( fileName ); |
642 | } | 642 | } |
643 | } | 643 | } |
644 | 644 | ||
645 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 645 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
646 | 646 | ||
647 | 647 | ||
648 | /*US | 648 | /*US |
649 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 649 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
650 | QString::null, // subject | 650 | QString::null, // subject |
651 | QString::null, // body | 651 | QString::null, // body |
652 | QString::null, | 652 | QString::null, |
653 | urls ); // attachments | 653 | urls ); // attachments |
654 | */ | 654 | */ |
655 | 655 | ||
656 | } | 656 | } |
657 | 657 | ||
658 | /** | 658 | /** |
659 | Beams the "WhoAmI contact. | 659 | Beams the "WhoAmI contact. |
660 | */ | 660 | */ |
661 | void KABCore::beamMySelf() | 661 | void KABCore::beamMySelf() |
662 | { | 662 | { |
663 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 663 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
664 | if (!a.isEmpty()) | 664 | if (!a.isEmpty()) |
665 | { | 665 | { |
666 | QStringList uids; | 666 | QStringList uids; |
667 | uids << a.uid(); | 667 | uids << a.uid(); |
668 | 668 | ||
669 | beamVCard(uids); | 669 | beamVCard(uids); |
670 | } else { | 670 | } else { |
671 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 671 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
672 | 672 | ||
673 | 673 | ||
674 | } | 674 | } |
675 | } | 675 | } |
676 | 676 | ||
677 | void KABCore::export2phone() | 677 | void KABCore::export2phone() |
678 | { | 678 | { |
679 | 679 | ||
680 | KAex2phonePrefs ex2phone; | 680 | KAex2phonePrefs ex2phone; |
681 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 681 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
682 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 682 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
683 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 683 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
684 | 684 | ||
685 | if ( !ex2phone.exec() ) { | 685 | if ( !ex2phone.exec() ) { |
686 | return; | 686 | return; |
687 | } | 687 | } |
688 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 688 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
689 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 689 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
690 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 690 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
691 | 691 | ||
692 | 692 | ||
693 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 693 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
694 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 694 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
695 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 695 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
696 | 696 | ||
697 | QStringList uids = mViewManager->selectedUids(); | 697 | QStringList uids = mViewManager->selectedUids(); |
698 | if ( uids.isEmpty() ) | 698 | if ( uids.isEmpty() ) |
699 | return; | 699 | return; |
700 | 700 | ||
701 | QString fileName = getPhoneFile(); | 701 | QString fileName = getPhoneFile(); |
702 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 702 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
703 | return; | 703 | return; |
704 | 704 | ||
705 | message(i18n("Exporting to phone...")); | 705 | message(i18n("Exporting to phone...")); |
706 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 706 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
707 | 707 | ||
708 | } | 708 | } |
709 | QString KABCore::getPhoneFile() | 709 | QString KABCore::getPhoneFile() |
710 | { | 710 | { |
711 | #ifdef _WIN32_ | 711 | #ifdef DESKTOP_VERSION |
712 | return locateLocal("tmp", "phonefile.vcf"); | 712 | return locateLocal("tmp", "phonefile.vcf"); |
713 | #else | 713 | #else |
714 | return "/tmp/phonefile.vcf"; | 714 | return "/tmp/phonefile.vcf"; |
715 | #endif | 715 | #endif |
716 | 716 | ||
717 | } | 717 | } |
718 | void KABCore::writeToPhone( ) | 718 | void KABCore::writeToPhone( ) |
719 | { | 719 | { |
720 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 720 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
721 | message(i18n("Export to phone finished!")); | 721 | message(i18n("Export to phone finished!")); |
722 | else | 722 | else |
723 | qDebug(i18n("Error exporting to phone")); | 723 | qDebug(i18n("Error exporting to phone")); |
724 | } | 724 | } |
725 | void KABCore::beamVCard() | 725 | void KABCore::beamVCard() |
726 | { | 726 | { |
727 | QStringList uids = mViewManager->selectedUids(); | 727 | QStringList uids = mViewManager->selectedUids(); |
728 | if ( !uids.isEmpty() ) | 728 | if ( !uids.isEmpty() ) |
729 | beamVCard( uids ); | 729 | beamVCard( uids ); |
730 | } | 730 | } |
731 | 731 | ||
732 | 732 | ||
733 | void KABCore::beamVCard(const QStringList& uids) | 733 | void KABCore::beamVCard(const QStringList& uids) |
734 | { | 734 | { |
735 | /*US | ||
736 | QString beamFilename; | ||
737 | Opie::OPimContact c; | ||
738 | if ( actionPersonal->isOn() ) { | ||
739 | beamFilename = addressbookPersonalVCardName(); | ||
740 | if ( !QFile::exists( beamFilename ) ) | ||
741 | return; // can't beam a non-existent file | ||
742 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | ||
743 | beamFilename ); | ||
744 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | ||
745 | Opie::OPimContactAccess::List allList = access->allRecords(); | ||
746 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | ||
747 | c = *it; | ||
748 | |||
749 | delete access; | ||
750 | } else { | ||
751 | unlink( beamfile ); // delete if exists | ||
752 | mkdir("/tmp/obex/", 0755); | ||
753 | c = m_abView -> currentEntry(); | ||
754 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | ||
755 | beamfile ); | ||
756 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | ||
757 | access->add( c ); | ||
758 | access->save(); | ||
759 | delete access; | ||
760 | |||
761 | beamFilename = beamfile; | ||
762 | } | ||
763 | |||
764 | owarn << "Beaming: " << beamFilename << oendl; | ||
765 | */ | ||
766 | |||
767 | #if 0 | ||
768 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | ||
769 | |||
770 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | ||
771 | |||
772 | QString name = "contact.vcf"; | ||
773 | 735 | ||
774 | QString fileName = dirName + "/" + name; | 736 | // LR: we should use the /tmp dir on the Zaurus, |
775 | #endif | 737 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
776 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 738 | |
777 | // | 739 | #ifdef DESKTOP_VERSION |
740 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | ||
741 | #else | ||
778 | QString fileName = "/tmp/kapibeamfile.vcf"; | 742 | QString fileName = "/tmp/kapibeamfile.vcf"; |
743 | #endif | ||
779 | 744 | ||
780 | |||
781 | //QDir().mkdir( dirName, true ); | ||
782 | |||
783 | |||
784 | KABC::VCardConverter converter; | 745 | KABC::VCardConverter converter; |
785 | QString description; | 746 | QString description; |
786 | QString datastream; | 747 | QString datastream; |
787 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 748 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
788 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 749 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
789 | 750 | ||
790 | if ( a.isEmpty() ) | 751 | if ( a.isEmpty() ) |
791 | continue; | 752 | continue; |
792 | 753 | ||
793 | if (description.isEmpty()) | 754 | if (description.isEmpty()) |
794 | description = a.formattedName(); | 755 | description = a.formattedName(); |
795 | 756 | ||
796 | QString vcard; | 757 | QString vcard; |
797 | converter.addresseeToVCard( a, vcard ); | 758 | converter.addresseeToVCard( a, vcard ); |
798 | int start = 0; | 759 | int start = 0; |
799 | int next; | 760 | int next; |
800 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 761 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
801 | int semi = vcard.find(";", next); | 762 | int semi = vcard.find(";", next); |
802 | int dopp = vcard.find(":", next); | 763 | int dopp = vcard.find(":", next); |
803 | int sep; | 764 | int sep; |
804 | if ( semi < dopp && semi >= 0 ) | 765 | if ( semi < dopp && semi >= 0 ) |
805 | sep = semi ; | 766 | sep = semi ; |
806 | else | 767 | else |
807 | sep = dopp; | 768 | sep = dopp; |
808 | datastream +=vcard.mid( start, next - start); | 769 | datastream +=vcard.mid( start, next - start); |
809 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 770 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
810 | start = sep; | 771 | start = sep; |
811 | } | 772 | } |
812 | datastream += vcard.mid( start,vcard.length() ); | 773 | datastream += vcard.mid( start,vcard.length() ); |
813 | } | 774 | } |
814 | #ifndef DESKTOP_VERSION | 775 | #ifndef DESKTOP_VERSION |
815 | QFile outFile(fileName); | 776 | QFile outFile(fileName); |
816 | if ( outFile.open(IO_WriteOnly) ) { | 777 | if ( outFile.open(IO_WriteOnly) ) { |
817 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 778 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
818 | QTextStream t( &outFile ); // use a text stream | 779 | QTextStream t( &outFile ); // use a text stream |
819 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 780 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
820 | t.setEncoding( QTextStream::Latin1 ); | 781 | t.setEncoding( QTextStream::Latin1 ); |
821 | t <<datastream.latin1(); | 782 | t <<datastream.latin1(); |
822 | outFile.close(); | 783 | outFile.close(); |
823 | Ir *ir = new Ir( this ); | 784 | Ir *ir = new Ir( this ); |
824 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 785 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
825 | ir->send( fileName, description, "text/x-vCard" ); | 786 | ir->send( fileName, description, "text/x-vCard" ); |
826 | } else { | 787 | } else { |
827 | qDebug("Error open temp beam file "); | 788 | qDebug("Error open temp beam file "); |
828 | return; | 789 | return; |
829 | } | 790 | } |
830 | #endif | 791 | #endif |
831 | 792 | ||
832 | } | 793 | } |
833 | 794 | ||
834 | void KABCore::beamDone( Ir *ir ) | 795 | void KABCore::beamDone( Ir *ir ) |
835 | { | 796 | { |
836 | #ifndef DESKTOP_VERSION | 797 | #ifndef DESKTOP_VERSION |
837 | delete ir; | 798 | delete ir; |
838 | #endif | 799 | #endif |
839 | topLevelWidget()->raise(); | 800 | topLevelWidget()->raise(); |
840 | message( i18n("Beaming finished!") ); | 801 | message( i18n("Beaming finished!") ); |
841 | } | 802 | } |
842 | 803 | ||
843 | 804 | ||
844 | void KABCore::browse( const QString& url ) | 805 | void KABCore::browse( const QString& url ) |
845 | { | 806 | { |
846 | #ifndef KAB_EMBEDDED | 807 | #ifndef KAB_EMBEDDED |
847 | kapp->invokeBrowser( url ); | 808 | kapp->invokeBrowser( url ); |
848 | #else //KAB_EMBEDDED | 809 | #else //KAB_EMBEDDED |
849 | qDebug("KABCore::browse must be fixed"); | 810 | qDebug("KABCore::browse must be fixed"); |
850 | #endif //KAB_EMBEDDED | 811 | #endif //KAB_EMBEDDED |
851 | } | 812 | } |
852 | 813 | ||
853 | void KABCore::selectAllContacts() | 814 | void KABCore::selectAllContacts() |
854 | { | 815 | { |
855 | mViewManager->setSelected( QString::null, true ); | 816 | mViewManager->setSelected( QString::null, true ); |
856 | } | 817 | } |
857 | 818 | ||
858 | void KABCore::deleteContacts() | 819 | void KABCore::deleteContacts() |
859 | { | 820 | { |
860 | QStringList uidList = mViewManager->selectedUids(); | 821 | QStringList uidList = mViewManager->selectedUids(); |
861 | deleteContacts( uidList ); | 822 | deleteContacts( uidList ); |
862 | } | 823 | } |
863 | 824 | ||
864 | void KABCore::deleteContacts( const QStringList &uids ) | 825 | void KABCore::deleteContacts( const QStringList &uids ) |
865 | { | 826 | { |
866 | if ( uids.count() > 0 ) { | 827 | if ( uids.count() > 0 ) { |
867 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 828 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
868 | UndoStack::instance()->push( command ); | 829 | UndoStack::instance()->push( command ); |
869 | RedoStack::instance()->clear(); | 830 | RedoStack::instance()->clear(); |
870 | 831 | ||
871 | // now if we deleted anything, refresh | 832 | // now if we deleted anything, refresh |
872 | setContactSelected( QString::null ); | 833 | setContactSelected( QString::null ); |
873 | setModified( true ); | 834 | setModified( true ); |
874 | } | 835 | } |
875 | } | 836 | } |
876 | 837 | ||
877 | void KABCore::copyContacts() | 838 | void KABCore::copyContacts() |
878 | { | 839 | { |
879 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 840 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
880 | 841 | ||
881 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 842 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
882 | 843 | ||
883 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 844 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
884 | 845 | ||
885 | QClipboard *cb = QApplication::clipboard(); | 846 | QClipboard *cb = QApplication::clipboard(); |
886 | cb->setText( clipText ); | 847 | cb->setText( clipText ); |
887 | } | 848 | } |
888 | 849 | ||
889 | void KABCore::cutContacts() | 850 | void KABCore::cutContacts() |
890 | { | 851 | { |
891 | QStringList uidList = mViewManager->selectedUids(); | 852 | QStringList uidList = mViewManager->selectedUids(); |
892 | 853 | ||
893 | //US if ( uidList.size() > 0 ) { | 854 | //US if ( uidList.size() > 0 ) { |
894 | if ( uidList.count() > 0 ) { | 855 | if ( uidList.count() > 0 ) { |
895 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 856 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
896 | UndoStack::instance()->push( command ); | 857 | UndoStack::instance()->push( command ); |
897 | RedoStack::instance()->clear(); | 858 | RedoStack::instance()->clear(); |
898 | 859 | ||
899 | setModified( true ); | 860 | setModified( true ); |
900 | } | 861 | } |
901 | } | 862 | } |
902 | 863 | ||
903 | void KABCore::pasteContacts() | 864 | void KABCore::pasteContacts() |
904 | { | 865 | { |
905 | QClipboard *cb = QApplication::clipboard(); | 866 | QClipboard *cb = QApplication::clipboard(); |
906 | 867 | ||
907 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 868 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
908 | 869 | ||
909 | pasteContacts( list ); | 870 | pasteContacts( list ); |
910 | } | 871 | } |
911 | 872 | ||
912 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 873 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
913 | { | 874 | { |
914 | KABC::Resource *resource = requestResource( this ); | 875 | KABC::Resource *resource = requestResource( this ); |
915 | KABC::Addressee::List::Iterator it; | 876 | KABC::Addressee::List::Iterator it; |
916 | for ( it = list.begin(); it != list.end(); ++it ) | 877 | for ( it = list.begin(); it != list.end(); ++it ) |
917 | (*it).setResource( resource ); | 878 | (*it).setResource( resource ); |
918 | 879 | ||
919 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 880 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
920 | UndoStack::instance()->push( command ); | 881 | UndoStack::instance()->push( command ); |
921 | RedoStack::instance()->clear(); | 882 | RedoStack::instance()->clear(); |
922 | 883 | ||
923 | setModified( true ); | 884 | setModified( true ); |
924 | } | 885 | } |
925 | 886 | ||
926 | void KABCore::setWhoAmI() | 887 | void KABCore::setWhoAmI() |
927 | { | 888 | { |
928 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 889 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
929 | 890 | ||
930 | if ( addrList.count() > 1 ) { | 891 | if ( addrList.count() > 1 ) { |
931 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 892 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
932 | return; | 893 | return; |
933 | } | 894 | } |
934 | 895 | ||
935 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 896 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
936 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 897 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
937 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 898 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
938 | } | 899 | } |
939 | 900 | ||
940 | void KABCore::setCategories() | 901 | void KABCore::setCategories() |
941 | { | 902 | { |
942 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 903 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
943 | if ( !dlg.exec() ) | 904 | if ( !dlg.exec() ) |
944 | return; | 905 | return; |
945 | 906 | ||
946 | bool merge = false; | 907 | bool merge = false; |
947 | QString msg = i18n( "Merge with existing categories?" ); | 908 | QString msg = i18n( "Merge with existing categories?" ); |
948 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 909 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
949 | merge = true; | 910 | merge = true; |
950 | 911 | ||
951 | QStringList categories = dlg.selectedCategories(); | 912 | QStringList categories = dlg.selectedCategories(); |
952 | 913 | ||
953 | QStringList uids = mViewManager->selectedUids(); | 914 | QStringList uids = mViewManager->selectedUids(); |
954 | QStringList::Iterator it; | 915 | QStringList::Iterator it; |
955 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 916 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
956 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 917 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
957 | if ( !addr.isEmpty() ) { | 918 | if ( !addr.isEmpty() ) { |
958 | if ( !merge ) | 919 | if ( !merge ) |
959 | addr.setCategories( categories ); | 920 | addr.setCategories( categories ); |
960 | else { | 921 | else { |
961 | QStringList addrCategories = addr.categories(); | 922 | QStringList addrCategories = addr.categories(); |
962 | QStringList::Iterator catIt; | 923 | QStringList::Iterator catIt; |
963 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 924 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
964 | if ( !addrCategories.contains( *catIt ) ) | 925 | if ( !addrCategories.contains( *catIt ) ) |
965 | addrCategories.append( *catIt ); | 926 | addrCategories.append( *catIt ); |
966 | } | 927 | } |
967 | addr.setCategories( addrCategories ); | 928 | addr.setCategories( addrCategories ); |
968 | } | 929 | } |
969 | 930 | ||
970 | mAddressBook->insertAddressee( addr ); | 931 | mAddressBook->insertAddressee( addr ); |
971 | } | 932 | } |
972 | } | 933 | } |
973 | 934 | ||
974 | if ( uids.count() > 0 ) | 935 | if ( uids.count() > 0 ) |
975 | setModified( true ); | 936 | setModified( true ); |
976 | } | 937 | } |
977 | 938 | ||
978 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 939 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
979 | { | 940 | { |
980 | mIncSearchWidget->setFields( fields ); | 941 | mIncSearchWidget->setFields( fields ); |
981 | } | 942 | } |
982 | 943 | ||
983 | void KABCore::incrementalSearch( const QString& text ) | 944 | void KABCore::incrementalSearch( const QString& text ) |
984 | { | 945 | { |
985 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 946 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
986 | } | 947 | } |
987 | 948 | ||
988 | void KABCore::setModified() | 949 | void KABCore::setModified() |
989 | { | 950 | { |
990 | setModified( true ); | 951 | setModified( true ); |
991 | } | 952 | } |
992 | 953 | ||
993 | void KABCore::setModifiedWOrefresh() | 954 | void KABCore::setModifiedWOrefresh() |
994 | { | 955 | { |
995 | // qDebug("KABCore::setModifiedWOrefresh() "); | 956 | // qDebug("KABCore::setModifiedWOrefresh() "); |
996 | mModified = true; | 957 | mModified = true; |
997 | mActionSave->setEnabled( mModified ); | 958 | mActionSave->setEnabled( mModified ); |
998 | #ifdef DESKTOP_VERSION | 959 | #ifdef DESKTOP_VERSION |
999 | mDetails->refreshView(); | 960 | mDetails->refreshView(); |
1000 | #endif | 961 | #endif |
1001 | 962 | ||
1002 | } | 963 | } |
1003 | void KABCore::setModified( bool modified ) | 964 | void KABCore::setModified( bool modified ) |
1004 | { | 965 | { |
1005 | mModified = modified; | 966 | mModified = modified; |
1006 | mActionSave->setEnabled( mModified ); | 967 | mActionSave->setEnabled( mModified ); |
1007 | 968 | ||
1008 | if ( modified ) | 969 | if ( modified ) |
1009 | mJumpButtonBar->recreateButtons(); | 970 | mJumpButtonBar->recreateButtons(); |
1010 | 971 | ||
1011 | mViewManager->refreshView(); | 972 | mViewManager->refreshView(); |
1012 | mDetails->refreshView(); | 973 | mDetails->refreshView(); |
1013 | 974 | ||
1014 | } | 975 | } |
1015 | 976 | ||
1016 | bool KABCore::modified() const | 977 | bool KABCore::modified() const |
1017 | { | 978 | { |
1018 | return mModified; | 979 | return mModified; |
1019 | } | 980 | } |
1020 | 981 | ||
1021 | void KABCore::contactModified( const KABC::Addressee &addr ) | 982 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1022 | { | 983 | { |
1023 | 984 | ||
1024 | Command *command = 0; | 985 | Command *command = 0; |
1025 | QString uid; | 986 | QString uid; |
1026 | 987 | ||
1027 | // check if it exists already | 988 | // check if it exists already |
1028 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 989 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1029 | if ( origAddr.isEmpty() ) | 990 | if ( origAddr.isEmpty() ) |
1030 | command = new PwNewCommand( mAddressBook, addr ); | 991 | command = new PwNewCommand( mAddressBook, addr ); |
1031 | else { | 992 | else { |
1032 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 993 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1033 | uid = addr.uid(); | 994 | uid = addr.uid(); |
1034 | } | 995 | } |
1035 | 996 | ||
1036 | UndoStack::instance()->push( command ); | 997 | UndoStack::instance()->push( command ); |
1037 | RedoStack::instance()->clear(); | 998 | RedoStack::instance()->clear(); |
1038 | 999 | ||
1039 | setModified( true ); | 1000 | setModified( true ); |
1040 | } | 1001 | } |
1041 | 1002 | ||
1042 | void KABCore::newContact() | 1003 | void KABCore::newContact() |
1043 | { | 1004 | { |
1044 | 1005 | ||
1045 | 1006 | ||
1046 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1007 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1047 | 1008 | ||
1048 | QPtrList<KRES::Resource> kresResources; | 1009 | QPtrList<KRES::Resource> kresResources; |
1049 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1010 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1050 | KABC::Resource *resource; | 1011 | KABC::Resource *resource; |
1051 | while ( ( resource = it.current() ) != 0 ) { | 1012 | while ( ( resource = it.current() ) != 0 ) { |
1052 | ++it; | 1013 | ++it; |
1053 | if ( !resource->readOnly() ) { | 1014 | if ( !resource->readOnly() ) { |
1054 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1015 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1055 | if ( res ) | 1016 | if ( res ) |
1056 | kresResources.append( res ); | 1017 | kresResources.append( res ); |
1057 | } | 1018 | } |
1058 | } | 1019 | } |
1059 | 1020 | ||
1060 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1021 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1061 | resource = static_cast<KABC::Resource*>( res ); | 1022 | resource = static_cast<KABC::Resource*>( res ); |
1062 | 1023 | ||
1063 | if ( resource ) { | 1024 | if ( resource ) { |
1064 | KABC::Addressee addr; | 1025 | KABC::Addressee addr; |
1065 | addr.setResource( resource ); | 1026 | addr.setResource( resource ); |
1066 | mEditorDialog->setAddressee( addr ); | 1027 | mEditorDialog->setAddressee( addr ); |
1067 | KApplication::execDialog ( mEditorDialog ); | 1028 | KApplication::execDialog ( mEditorDialog ); |
1068 | 1029 | ||
1069 | } else | 1030 | } else |
1070 | return; | 1031 | return; |
1071 | 1032 | ||
1072 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1033 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1073 | 1034 | ||
1074 | 1035 | ||
1075 | } | 1036 | } |
1076 | 1037 | ||
1077 | void KABCore::addEmail( QString aStr ) | 1038 | void KABCore::addEmail( QString aStr ) |
1078 | { | 1039 | { |
1079 | #ifndef KAB_EMBEDDED | 1040 | #ifndef KAB_EMBEDDED |
1080 | QString fullName, email; | 1041 | QString fullName, email; |
1081 | 1042 | ||
1082 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1043 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1083 | 1044 | ||
1084 | // Try to lookup the addressee matching the email address | 1045 | // Try to lookup the addressee matching the email address |
1085 | bool found = false; | 1046 | bool found = false; |
1086 | QStringList emailList; | 1047 | QStringList emailList; |
1087 | KABC::AddressBook::Iterator it; | 1048 | KABC::AddressBook::Iterator it; |
1088 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1049 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1089 | emailList = (*it).emails(); | 1050 | emailList = (*it).emails(); |
1090 | if ( emailList.contains( email ) > 0 ) { | 1051 | if ( emailList.contains( email ) > 0 ) { |
1091 | found = true; | 1052 | found = true; |
1092 | (*it).setNameFromString( fullName ); | 1053 | (*it).setNameFromString( fullName ); |
1093 | editContact( (*it).uid() ); | 1054 | editContact( (*it).uid() ); |
1094 | } | 1055 | } |
1095 | } | 1056 | } |
1096 | 1057 | ||
1097 | if ( !found ) { | 1058 | if ( !found ) { |
1098 | KABC::Addressee addr; | 1059 | KABC::Addressee addr; |
1099 | addr.setNameFromString( fullName ); | 1060 | addr.setNameFromString( fullName ); |
1100 | addr.insertEmail( email, true ); | 1061 | addr.insertEmail( email, true ); |
1101 | 1062 | ||
1102 | mAddressBook->insertAddressee( addr ); | 1063 | mAddressBook->insertAddressee( addr ); |
1103 | mViewManager->refreshView( addr.uid() ); | 1064 | mViewManager->refreshView( addr.uid() ); |
1104 | editContact( addr.uid() ); | 1065 | editContact( addr.uid() ); |
1105 | } | 1066 | } |
1106 | #else //KAB_EMBEDDED | 1067 | #else //KAB_EMBEDDED |
1107 | qDebug("KABCore::addEmail finsih method"); | 1068 | qDebug("KABCore::addEmail finsih method"); |
1108 | #endif //KAB_EMBEDDED | 1069 | #endif //KAB_EMBEDDED |
1109 | } | 1070 | } |
1110 | 1071 | ||
1111 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1072 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1112 | { | 1073 | { |
1113 | mXXPortManager->importVCard( url, showPreview ); | 1074 | mXXPortManager->importVCard( url, showPreview ); |
1114 | } | 1075 | } |
1115 | void KABCore::importFromOL() | 1076 | void KABCore::importFromOL() |
1116 | { | 1077 | { |
1117 | #ifdef _WIN32_ | 1078 | #ifdef _WIN32_ |
1118 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1079 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1119 | idgl->exec(); | 1080 | idgl->exec(); |
1120 | KABC::Addressee::List list = idgl->getAddressList(); | 1081 | KABC::Addressee::List list = idgl->getAddressList(); |
1121 | if ( list.count() > 0 ) { | 1082 | if ( list.count() > 0 ) { |
1122 | KABC::Addressee::List listNew; | 1083 | KABC::Addressee::List listNew; |
1123 | KABC::Addressee::List listExisting; | 1084 | KABC::Addressee::List listExisting; |
1124 | KABC::Addressee::List::Iterator it; | 1085 | KABC::Addressee::List::Iterator it; |
1125 | KABC::AddressBook::Iterator iter; | 1086 | KABC::AddressBook::Iterator iter; |
1126 | for ( it = list.begin(); it != list.end(); ++it ) { | 1087 | for ( it = list.begin(); it != list.end(); ++it ) { |
1127 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1088 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1128 | listNew.append( (*it) ); | 1089 | listNew.append( (*it) ); |
1129 | else | 1090 | else |
1130 | listExisting.append( (*it) ); | 1091 | listExisting.append( (*it) ); |
1131 | } | 1092 | } |
1132 | if ( listExisting.count() > 0 ) | 1093 | if ( listExisting.count() > 0 ) |
1133 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1094 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1134 | if ( listNew.count() > 0 ) { | 1095 | if ( listNew.count() > 0 ) { |
1135 | pasteWithNewUid = false; | 1096 | pasteWithNewUid = false; |
1136 | pasteContacts( listNew ); | 1097 | pasteContacts( listNew ); |
1137 | pasteWithNewUid = true; | 1098 | pasteWithNewUid = true; |
1138 | } | 1099 | } |
1139 | } | 1100 | } |
1140 | delete idgl; | 1101 | delete idgl; |
1141 | #endif | 1102 | #endif |
1142 | } | 1103 | } |
1143 | 1104 | ||
1144 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1105 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1145 | { | 1106 | { |
1146 | mXXPortManager->importVCard( vCard, showPreview ); | 1107 | mXXPortManager->importVCard( vCard, showPreview ); |
1147 | } | 1108 | } |
1148 | 1109 | ||
1149 | //US added a second method without defaultparameter | 1110 | //US added a second method without defaultparameter |
1150 | void KABCore::editContact2() { | 1111 | void KABCore::editContact2() { |
1151 | editContact( QString::null ); | 1112 | editContact( QString::null ); |
1152 | } | 1113 | } |
1153 | 1114 | ||
1154 | void KABCore::editContact( const QString &uid ) | 1115 | void KABCore::editContact( const QString &uid ) |
1155 | { | 1116 | { |
1156 | 1117 | ||
1157 | if ( mExtensionManager->isQuickEditVisible() ) | 1118 | if ( mExtensionManager->isQuickEditVisible() ) |
1158 | return; | 1119 | return; |
1159 | 1120 | ||
1160 | // First, locate the contact entry | 1121 | // First, locate the contact entry |
1161 | QString localUID = uid; | 1122 | QString localUID = uid; |
1162 | if ( localUID.isNull() ) { | 1123 | if ( localUID.isNull() ) { |
1163 | QStringList uidList = mViewManager->selectedUids(); | 1124 | QStringList uidList = mViewManager->selectedUids(); |
1164 | if ( uidList.count() > 0 ) | 1125 | if ( uidList.count() > 0 ) |
1165 | localUID = *( uidList.at( 0 ) ); | 1126 | localUID = *( uidList.at( 0 ) ); |
1166 | } | 1127 | } |
1167 | 1128 | ||
1168 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1129 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1169 | if ( !addr.isEmpty() ) { | 1130 | if ( !addr.isEmpty() ) { |
1170 | mEditorDialog->setAddressee( addr ); | 1131 | mEditorDialog->setAddressee( addr ); |
1171 | KApplication::execDialog ( mEditorDialog ); | 1132 | KApplication::execDialog ( mEditorDialog ); |
1172 | } | 1133 | } |
1173 | } | 1134 | } |
1174 | 1135 | ||
1175 | /** | 1136 | /** |
1176 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1137 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1177 | the method will try to find a selected addressee in the view. | 1138 | the method will try to find a selected addressee in the view. |
1178 | */ | 1139 | */ |
1179 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1140 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1180 | { | 1141 | { |
1181 | if ( mMultipleViewsAtOnce ) | 1142 | if ( mMultipleViewsAtOnce ) |
1182 | { | 1143 | { |
1183 | editContact( uid ); | 1144 | editContact( uid ); |
1184 | } | 1145 | } |
1185 | else | 1146 | else |
1186 | { | 1147 | { |
1187 | setDetailsVisible( true ); | 1148 | setDetailsVisible( true ); |
1188 | mActionDetails->setChecked(true); | 1149 | mActionDetails->setChecked(true); |
1189 | } | 1150 | } |
1190 | 1151 | ||
1191 | } | 1152 | } |
1192 | 1153 | ||
1193 | void KABCore::save() | 1154 | void KABCore::save() |
1194 | { | 1155 | { |
1195 | if (syncManager->blockSave()) | 1156 | if (syncManager->blockSave()) |
1196 | return; | 1157 | return; |
1197 | if ( !mModified ) | 1158 | if ( !mModified ) |
1198 | return; | 1159 | return; |
1199 | 1160 | ||
1200 | syncManager->setBlockSave(true); | 1161 | syncManager->setBlockSave(true); |
1201 | QString text = i18n( "There was an error while attempting to save\n the " | 1162 | QString text = i18n( "There was an error while attempting to save\n the " |
1202 | "address book. Please check that some \nother application is " | 1163 | "address book. Please check that some \nother application is " |
1203 | "not using it. " ); | 1164 | "not using it. " ); |
1204 | message(i18n("Saving addressbook ... ")); | 1165 | message(i18n("Saving addressbook ... ")); |
1205 | #ifndef KAB_EMBEDDED | 1166 | #ifndef KAB_EMBEDDED |
1206 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1167 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1207 | if ( !b || !b->save() ) { | 1168 | if ( !b || !b->save() ) { |
1208 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1169 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1209 | } | 1170 | } |
1210 | #else //KAB_EMBEDDED | 1171 | #else //KAB_EMBEDDED |
1211 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1172 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1212 | if ( !b || !b->save() ) { | 1173 | if ( !b || !b->save() ) { |
1213 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1174 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1214 | } | 1175 | } |
1215 | #endif //KAB_EMBEDDED | 1176 | #endif //KAB_EMBEDDED |
1216 | 1177 | ||
1217 | message(i18n("Addressbook saved!")); | 1178 | message(i18n("Addressbook saved!")); |
1218 | setModified( false ); | 1179 | setModified( false ); |
1219 | syncManager->setBlockSave(false); | 1180 | syncManager->setBlockSave(false); |
1220 | } | 1181 | } |
1221 | 1182 | ||
1222 | 1183 | ||
1223 | void KABCore::undo() | 1184 | void KABCore::undo() |
1224 | { | 1185 | { |
1225 | UndoStack::instance()->undo(); | 1186 | UndoStack::instance()->undo(); |
1226 | 1187 | ||
1227 | // Refresh the view | 1188 | // Refresh the view |
1228 | mViewManager->refreshView(); | 1189 | mViewManager->refreshView(); |
1229 | } | 1190 | } |
1230 | 1191 | ||
1231 | void KABCore::redo() | 1192 | void KABCore::redo() |
1232 | { | 1193 | { |
1233 | RedoStack::instance()->redo(); | 1194 | RedoStack::instance()->redo(); |
1234 | 1195 | ||
1235 | // Refresh the view | 1196 | // Refresh the view |
1236 | mViewManager->refreshView(); | 1197 | mViewManager->refreshView(); |
1237 | } | 1198 | } |
1238 | 1199 | ||
1239 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1200 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1240 | { | 1201 | { |
1241 | if (mMultipleViewsAtOnce) | 1202 | if (mMultipleViewsAtOnce) |
1242 | { | 1203 | { |
1243 | if ( visible ) | 1204 | if ( visible ) |
1244 | mJumpButtonBar->show(); | 1205 | mJumpButtonBar->show(); |
1245 | else | 1206 | else |
1246 | mJumpButtonBar->hide(); | 1207 | mJumpButtonBar->hide(); |
1247 | } | 1208 | } |
1248 | else | 1209 | else |
1249 | { | 1210 | { |
1250 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1211 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1251 | if (mViewManager->isVisible()) | 1212 | if (mViewManager->isVisible()) |
1252 | { | 1213 | { |
1253 | if ( visible ) | 1214 | if ( visible ) |
1254 | mJumpButtonBar->show(); | 1215 | mJumpButtonBar->show(); |
1255 | else | 1216 | else |
1256 | mJumpButtonBar->hide(); | 1217 | mJumpButtonBar->hide(); |
1257 | } | 1218 | } |
1258 | else | 1219 | else |
1259 | { | 1220 | { |
1260 | mJumpButtonBar->hide(); | 1221 | mJumpButtonBar->hide(); |
1261 | } | 1222 | } |
1262 | } | 1223 | } |
1263 | } | 1224 | } |
1264 | 1225 | ||
1265 | 1226 | ||
1266 | void KABCore::setDetailsToState() | 1227 | void KABCore::setDetailsToState() |
1267 | { | 1228 | { |
1268 | setDetailsVisible( mActionDetails->isChecked() ); | 1229 | setDetailsVisible( mActionDetails->isChecked() ); |
1269 | } | 1230 | } |
1270 | 1231 | ||
1271 | 1232 | ||
1272 | 1233 | ||
1273 | void KABCore::setDetailsVisible( bool visible ) | 1234 | void KABCore::setDetailsVisible( bool visible ) |
1274 | { | 1235 | { |
1275 | if (visible && mDetails->isHidden()) | 1236 | if (visible && mDetails->isHidden()) |
1276 | { | 1237 | { |
1277 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1238 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1278 | if ( addrList.count() > 0 ) | 1239 | if ( addrList.count() > 0 ) |
1279 | mDetails->setAddressee( addrList[ 0 ] ); | 1240 | mDetails->setAddressee( addrList[ 0 ] ); |
1280 | } | 1241 | } |
1281 | 1242 | ||
1282 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1243 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1283 | // the listview and the detailview. We do that by changing the splitbar size. | 1244 | // the listview and the detailview. We do that by changing the splitbar size. |
1284 | if (mMultipleViewsAtOnce) | 1245 | if (mMultipleViewsAtOnce) |
1285 | { | 1246 | { |
1286 | if ( visible ) | 1247 | if ( visible ) |
1287 | mDetails->show(); | 1248 | mDetails->show(); |
1288 | else | 1249 | else |
1289 | mDetails->hide(); | 1250 | mDetails->hide(); |
1290 | } | 1251 | } |
1291 | else | 1252 | else |
1292 | { | 1253 | { |
1293 | if ( visible ) { | 1254 | if ( visible ) { |
1294 | mViewManager->hide(); | 1255 | mViewManager->hide(); |
1295 | mDetails->show(); | 1256 | mDetails->show(); |
1296 | } | 1257 | } |
1297 | else { | 1258 | else { |
1298 | mViewManager->show(); | 1259 | mViewManager->show(); |
1299 | mDetails->hide(); | 1260 | mDetails->hide(); |
1300 | } | 1261 | } |
1301 | setJumpButtonBarVisible( !visible ); | 1262 | setJumpButtonBarVisible( !visible ); |
1302 | } | 1263 | } |
1303 | 1264 | ||
1304 | } | 1265 | } |
1305 | 1266 | ||
1306 | void KABCore::extensionChanged( int id ) | 1267 | void KABCore::extensionChanged( int id ) |
1307 | { | 1268 | { |
1308 | //change the details view only for non desktop systems | 1269 | //change the details view only for non desktop systems |
1309 | #ifndef DESKTOP_VERSION | 1270 | #ifndef DESKTOP_VERSION |
1310 | 1271 | ||
1311 | if (id == 0) | 1272 | if (id == 0) |
1312 | { | 1273 | { |
1313 | //the user disabled the extension. | 1274 | //the user disabled the extension. |
1314 | 1275 | ||
1315 | if (mMultipleViewsAtOnce) | 1276 | if (mMultipleViewsAtOnce) |
1316 | { // enable detailsview again | 1277 | { // enable detailsview again |
1317 | setDetailsVisible( true ); | 1278 | setDetailsVisible( true ); |
1318 | mActionDetails->setChecked( true ); | 1279 | mActionDetails->setChecked( true ); |
1319 | } | 1280 | } |
1320 | else | 1281 | else |
1321 | { //go back to the listview | 1282 | { //go back to the listview |
1322 | setDetailsVisible( false ); | 1283 | setDetailsVisible( false ); |
1323 | mActionDetails->setChecked( false ); | 1284 | mActionDetails->setChecked( false ); |
1324 | mActionDetails->setEnabled(true); | 1285 | mActionDetails->setEnabled(true); |
1325 | } | 1286 | } |
1326 | 1287 | ||
1327 | } | 1288 | } |
1328 | else | 1289 | else |
1329 | { | 1290 | { |
1330 | //the user enabled the extension. | 1291 | //the user enabled the extension. |
1331 | setDetailsVisible( false ); | 1292 | setDetailsVisible( false ); |
1332 | mActionDetails->setChecked( false ); | 1293 | mActionDetails->setChecked( false ); |
1333 | 1294 | ||
1334 | if (!mMultipleViewsAtOnce) | 1295 | if (!mMultipleViewsAtOnce) |
1335 | { | 1296 | { |
1336 | mActionDetails->setEnabled(false); | 1297 | mActionDetails->setEnabled(false); |
1337 | } | 1298 | } |
1338 | 1299 | ||
1339 | mExtensionManager->setSelectionChanged(); | 1300 | mExtensionManager->setSelectionChanged(); |
1340 | 1301 | ||
1341 | } | 1302 | } |
1342 | 1303 | ||
1343 | #endif// DESKTOP_VERSION | 1304 | #endif// DESKTOP_VERSION |
1344 | 1305 | ||
1345 | } | 1306 | } |
1346 | 1307 | ||
1347 | 1308 | ||
1348 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1309 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1349 | { | 1310 | { |
1350 | 1311 | ||
1351 | if ( list.count() != 0 ) { | 1312 | if ( list.count() != 0 ) { |
1352 | KABC::Addressee::List::ConstIterator it; | 1313 | KABC::Addressee::List::ConstIterator it; |
1353 | for ( it = list.begin(); it != list.end(); ++it ) | 1314 | for ( it = list.begin(); it != list.end(); ++it ) |
1354 | mAddressBook->insertAddressee( *it ); | 1315 | mAddressBook->insertAddressee( *it ); |
1355 | if ( list.count() > 1 ) | 1316 | if ( list.count() > 1 ) |
1356 | setModified(); | 1317 | setModified(); |
1357 | else | 1318 | else |
1358 | setModifiedWOrefresh(); | 1319 | setModifiedWOrefresh(); |
1359 | } | 1320 | } |
1360 | if ( list.count() == 0 ) | 1321 | if ( list.count() == 0 ) |
1361 | mViewManager->refreshView(); | 1322 | mViewManager->refreshView(); |
1362 | else | 1323 | else |
1363 | mViewManager->refreshView( list[ 0 ].uid() ); | 1324 | mViewManager->refreshView( list[ 0 ].uid() ); |
1364 | 1325 | ||
1365 | 1326 | ||
1366 | 1327 | ||
1367 | } | 1328 | } |
1368 | 1329 | ||
1369 | QString KABCore::getNameByPhone( const QString &phone ) | 1330 | QString KABCore::getNameByPhone( const QString &phone ) |
1370 | { | 1331 | { |
1371 | #ifndef KAB_EMBEDDED | 1332 | #ifndef KAB_EMBEDDED |
1372 | QRegExp r( "[/*/-/ ]" ); | 1333 | QRegExp r( "[/*/-/ ]" ); |
1373 | QString localPhone( phone ); | 1334 | QString localPhone( phone ); |
1374 | 1335 | ||
1375 | bool found = false; | 1336 | bool found = false; |
1376 | QString ownerName = ""; | 1337 | QString ownerName = ""; |
1377 | KABC::AddressBook::Iterator iter; | 1338 | KABC::AddressBook::Iterator iter; |
1378 | KABC::PhoneNumber::List::Iterator phoneIter; | 1339 | KABC::PhoneNumber::List::Iterator phoneIter; |
1379 | KABC::PhoneNumber::List phoneList; | 1340 | KABC::PhoneNumber::List phoneList; |
1380 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1341 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1381 | phoneList = (*iter).phoneNumbers(); | 1342 | phoneList = (*iter).phoneNumbers(); |
1382 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1343 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1383 | ++phoneIter) { | 1344 | ++phoneIter) { |
1384 | // Get rid of separator chars so just the numbers are compared. | 1345 | // Get rid of separator chars so just the numbers are compared. |
1385 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1346 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1386 | ownerName = (*iter).formattedName(); | 1347 | ownerName = (*iter).formattedName(); |
1387 | found = true; | 1348 | found = true; |
1388 | } | 1349 | } |
1389 | } | 1350 | } |
1390 | } | 1351 | } |
1391 | 1352 | ||
1392 | return ownerName; | 1353 | return ownerName; |
1393 | #else //KAB_EMBEDDED | 1354 | #else //KAB_EMBEDDED |
1394 | qDebug("KABCore::getNameByPhone finsih method"); | 1355 | qDebug("KABCore::getNameByPhone finsih method"); |
1395 | return ""; | 1356 | return ""; |
1396 | #endif //KAB_EMBEDDED | 1357 | #endif //KAB_EMBEDDED |
1397 | 1358 | ||
1398 | } | 1359 | } |
1399 | 1360 | ||
1400 | void KABCore::openConfigDialog() | 1361 | void KABCore::openConfigDialog() |
1401 | { | 1362 | { |
1402 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1363 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1403 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1364 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1404 | ConfigureDialog->addModule(kabcfg ); | 1365 | ConfigureDialog->addModule(kabcfg ); |
1405 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1366 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1406 | ConfigureDialog->addModule(kdelibcfg ); | 1367 | ConfigureDialog->addModule(kdelibcfg ); |
1407 | 1368 | ||
1408 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1369 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1409 | this, SLOT( configurationChanged() ) ); | 1370 | this, SLOT( configurationChanged() ) ); |
1410 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1371 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1411 | this, SLOT( configurationChanged() ) ); | 1372 | this, SLOT( configurationChanged() ) ); |
1412 | saveSettings(); | 1373 | saveSettings(); |
1413 | #ifndef DESKTOP_VERSION | 1374 | #ifndef DESKTOP_VERSION |
1414 | ConfigureDialog->showMaximized(); | 1375 | ConfigureDialog->showMaximized(); |
1415 | #endif | 1376 | #endif |
1416 | if ( ConfigureDialog->exec() ) | 1377 | if ( ConfigureDialog->exec() ) |
1417 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1378 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1418 | delete ConfigureDialog; | 1379 | delete ConfigureDialog; |
1419 | } | 1380 | } |
1420 | 1381 | ||
1421 | void KABCore::openLDAPDialog() | 1382 | void KABCore::openLDAPDialog() |
1422 | { | 1383 | { |
1423 | #ifndef KAB_EMBEDDED | 1384 | #ifndef KAB_EMBEDDED |
1424 | if ( !mLdapSearchDialog ) { | 1385 | if ( !mLdapSearchDialog ) { |
1425 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1386 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1426 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1387 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1427 | SLOT( refreshView() ) ); | 1388 | SLOT( refreshView() ) ); |
1428 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1389 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1429 | SLOT( setModified() ) ); | 1390 | SLOT( setModified() ) ); |
1430 | } else | 1391 | } else |
1431 | mLdapSearchDialog->restoreSettings(); | 1392 | mLdapSearchDialog->restoreSettings(); |
1432 | 1393 | ||
1433 | if ( mLdapSearchDialog->isOK() ) | 1394 | if ( mLdapSearchDialog->isOK() ) |
1434 | mLdapSearchDialog->exec(); | 1395 | mLdapSearchDialog->exec(); |
1435 | #else //KAB_EMBEDDED | 1396 | #else //KAB_EMBEDDED |
1436 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1397 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1437 | #endif //KAB_EMBEDDED | 1398 | #endif //KAB_EMBEDDED |
1438 | } | 1399 | } |
1439 | 1400 | ||
1440 | void KABCore::print() | 1401 | void KABCore::print() |
1441 | { | 1402 | { |
1442 | #ifndef KAB_EMBEDDED | 1403 | #ifndef KAB_EMBEDDED |
1443 | KPrinter printer; | 1404 | KPrinter printer; |
1444 | if ( !printer.setup( this ) ) | 1405 | if ( !printer.setup( this ) ) |
1445 | return; | 1406 | return; |
1446 | 1407 | ||
1447 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1408 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1448 | mViewManager->selectedUids(), this ); | 1409 | mViewManager->selectedUids(), this ); |
1449 | 1410 | ||
1450 | wizard.exec(); | 1411 | wizard.exec(); |
1451 | #else //KAB_EMBEDDED | 1412 | #else //KAB_EMBEDDED |
1452 | qDebug("KABCore::print() finsih method"); | 1413 | qDebug("KABCore::print() finsih method"); |
1453 | #endif //KAB_EMBEDDED | 1414 | #endif //KAB_EMBEDDED |
1454 | 1415 | ||
1455 | } | 1416 | } |
1456 | 1417 | ||
1457 | 1418 | ||
1458 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1419 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1459 | { | 1420 | { |
1460 | if ( mGUIClient ) | 1421 | if ( mGUIClient ) |
1461 | mGUIClient->insertChildClient( client ); | 1422 | mGUIClient->insertChildClient( client ); |
1462 | else | 1423 | else |
1463 | KMessageBox::error( this, "no KXMLGUICLient"); | 1424 | KMessageBox::error( this, "no KXMLGUICLient"); |
1464 | } | 1425 | } |
1465 | 1426 | ||
1466 | 1427 | ||
1467 | void KABCore::configurationChanged() | 1428 | void KABCore::configurationChanged() |
1468 | { | 1429 | { |
1469 | mExtensionManager->reconfigure(); | 1430 | mExtensionManager->reconfigure(); |
1470 | } | 1431 | } |
1471 | 1432 | ||
1472 | void KABCore::addressBookChanged() | 1433 | void KABCore::addressBookChanged() |
1473 | { | 1434 | { |
1474 | /*US | 1435 | /*US |
1475 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1436 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1476 | while ( it.current() ) { | 1437 | while ( it.current() ) { |
1477 | if ( it.current()->dirty() ) { | 1438 | if ( it.current()->dirty() ) { |
1478 | QString text = i18n( "Data has been changed externally. Unsaved " | 1439 | QString text = i18n( "Data has been changed externally. Unsaved " |
1479 | "changes will be lost." ); | 1440 | "changes will be lost." ); |
1480 | KMessageBox::information( this, text ); | 1441 | KMessageBox::information( this, text ); |
1481 | } | 1442 | } |
1482 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1443 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1483 | ++it; | 1444 | ++it; |
1484 | } | 1445 | } |
1485 | */ | 1446 | */ |
1486 | if (mEditorDialog) | 1447 | if (mEditorDialog) |
1487 | { | 1448 | { |
1488 | if (mEditorDialog->dirty()) | 1449 | if (mEditorDialog->dirty()) |
1489 | { | 1450 | { |
1490 | QString text = i18n( "Data has been changed externally. Unsaved " | 1451 | QString text = i18n( "Data has been changed externally. Unsaved " |
1491 | "changes will be lost." ); | 1452 | "changes will be lost." ); |
1492 | KMessageBox::information( this, text ); | 1453 | KMessageBox::information( this, text ); |
1493 | } | 1454 | } |
1494 | QString currentuid = mEditorDialog->addressee().uid(); | 1455 | QString currentuid = mEditorDialog->addressee().uid(); |
1495 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1456 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1496 | } | 1457 | } |
1497 | mViewManager->refreshView(); | 1458 | mViewManager->refreshView(); |
1498 | // mDetails->refreshView(); | 1459 | // mDetails->refreshView(); |
1499 | 1460 | ||
1500 | 1461 | ||
1501 | } | 1462 | } |
1502 | 1463 | ||
1503 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1464 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1504 | const char *name ) | 1465 | const char *name ) |
1505 | { | 1466 | { |
1506 | 1467 | ||
1507 | if ( mEditorDialog == 0 ) { | 1468 | if ( mEditorDialog == 0 ) { |
1508 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1469 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1509 | name ? name : "editorDialog" ); | 1470 | name ? name : "editorDialog" ); |
1510 | 1471 | ||
1511 | 1472 | ||
1512 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1473 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1513 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1474 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1514 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1475 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1515 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1476 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1516 | } | 1477 | } |
1517 | 1478 | ||
1518 | return mEditorDialog; | 1479 | return mEditorDialog; |
1519 | } | 1480 | } |
1520 | 1481 | ||
1521 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1482 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1522 | { | 1483 | { |
1523 | //mEditorDict.remove( uid ); | 1484 | //mEditorDict.remove( uid ); |
1524 | } | 1485 | } |
1525 | 1486 | ||
1526 | void KABCore::initGUI() | 1487 | void KABCore::initGUI() |
1527 | { | 1488 | { |
1528 | #ifndef KAB_EMBEDDED | 1489 | #ifndef KAB_EMBEDDED |
1529 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1490 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1530 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1491 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1531 | 1492 | ||
1532 | mExtensionBarSplitter = new QSplitter( this ); | 1493 | mExtensionBarSplitter = new QSplitter( this ); |
1533 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1494 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1534 | 1495 | ||
1535 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1496 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1536 | 1497 | ||
1537 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1498 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1538 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1499 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1539 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1500 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1540 | SLOT( incrementalSearch( const QString& ) ) ); | 1501 | SLOT( incrementalSearch( const QString& ) ) ); |
1541 | 1502 | ||
1542 | mViewManager = new ViewManager( this, viewSpace ); | 1503 | mViewManager = new ViewManager( this, viewSpace ); |
1543 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1504 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1544 | 1505 | ||
1545 | mDetails = new ViewContainer( mDetailsSplitter ); | 1506 | mDetails = new ViewContainer( mDetailsSplitter ); |
1546 | 1507 | ||
1547 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1508 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1548 | 1509 | ||
1549 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1510 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1550 | 1511 | ||
1551 | topLayout->addWidget( mExtensionBarSplitter ); | 1512 | topLayout->addWidget( mExtensionBarSplitter ); |
1552 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1513 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1553 | topLayout->addWidget( mJumpButtonBar ); | 1514 | topLayout->addWidget( mJumpButtonBar ); |
1554 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1515 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1555 | 1516 | ||
1556 | mXXPortManager = new XXPortManager( this, this ); | 1517 | mXXPortManager = new XXPortManager( this, this ); |
1557 | 1518 | ||
1558 | #else //KAB_EMBEDDED | 1519 | #else //KAB_EMBEDDED |
1559 | //US initialize viewMenu before settingup viewmanager. | 1520 | //US initialize viewMenu before settingup viewmanager. |
1560 | // Viewmanager needs this menu to plugin submenues. | 1521 | // Viewmanager needs this menu to plugin submenues. |
1561 | viewMenu = new QPopupMenu( this ); | 1522 | viewMenu = new QPopupMenu( this ); |
1562 | settingsMenu = new QPopupMenu( this ); | 1523 | settingsMenu = new QPopupMenu( this ); |
1563 | //filterMenu = new QPopupMenu( this ); | 1524 | //filterMenu = new QPopupMenu( this ); |
1564 | ImportMenu = new QPopupMenu( this ); | 1525 | ImportMenu = new QPopupMenu( this ); |
1565 | ExportMenu = new QPopupMenu( this ); | 1526 | ExportMenu = new QPopupMenu( this ); |
1566 | syncMenu = new QPopupMenu( this ); | 1527 | syncMenu = new QPopupMenu( this ); |
1567 | changeMenu= new QPopupMenu( this ); | 1528 | changeMenu= new QPopupMenu( this ); |
1568 | 1529 | ||
1569 | //US since we have no splitter for the embedded system, setup | 1530 | //US since we have no splitter for the embedded system, setup |
1570 | // a layout with two frames. One left and one right. | 1531 | // a layout with two frames. One left and one right. |
1571 | 1532 | ||
1572 | QBoxLayout *topLayout; | 1533 | QBoxLayout *topLayout; |
1573 | 1534 | ||
1574 | // = new QHBoxLayout( this ); | 1535 | // = new QHBoxLayout( this ); |
1575 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1536 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1576 | 1537 | ||
1577 | // QWidget *mainBox = new QWidget( this ); | 1538 | // QWidget *mainBox = new QWidget( this ); |
1578 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1539 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1579 | 1540 | ||
1580 | #ifdef DESKTOP_VERSION | 1541 | #ifdef DESKTOP_VERSION |
1581 | topLayout = new QHBoxLayout( this ); | 1542 | topLayout = new QHBoxLayout( this ); |
1582 | 1543 | ||
1583 | 1544 | ||
1584 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1545 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1585 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1546 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1586 | 1547 | ||
1587 | topLayout->addWidget(mMiniSplitter ); | 1548 | topLayout->addWidget(mMiniSplitter ); |
1588 | 1549 | ||
1589 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1550 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1590 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1551 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1591 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1552 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1592 | mDetails = new ViewContainer( mMiniSplitter ); | 1553 | mDetails = new ViewContainer( mMiniSplitter ); |
1593 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1554 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1594 | #else | 1555 | #else |
1595 | if ( QApplication::desktop()->width() > 480 ) { | 1556 | if ( QApplication::desktop()->width() > 480 ) { |
1596 | topLayout = new QHBoxLayout( this ); | 1557 | topLayout = new QHBoxLayout( this ); |
1597 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1558 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1598 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1559 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1599 | } else { | 1560 | } else { |
1600 | 1561 | ||
1601 | topLayout = new QHBoxLayout( this ); | 1562 | topLayout = new QHBoxLayout( this ); |
1602 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1563 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1603 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1564 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1604 | } | 1565 | } |
1605 | 1566 | ||
1606 | topLayout->addWidget(mMiniSplitter ); | 1567 | topLayout->addWidget(mMiniSplitter ); |
1607 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1568 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1608 | mDetails = new ViewContainer( mMiniSplitter ); | 1569 | mDetails = new ViewContainer( mMiniSplitter ); |
1609 | 1570 | ||
1610 | 1571 | ||
1611 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1572 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1612 | #endif | 1573 | #endif |
1613 | //eh->hide(); | 1574 | //eh->hide(); |
1614 | // topLayout->addWidget(mExtensionManager ); | 1575 | // topLayout->addWidget(mExtensionManager ); |
1615 | 1576 | ||
1616 | 1577 | ||
1617 | /*US | 1578 | /*US |
1618 | #ifndef KAB_NOSPLITTER | 1579 | #ifndef KAB_NOSPLITTER |
1619 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1580 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1620 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1581 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1621 | topLayout->setSpacing( 10 ); | 1582 | topLayout->setSpacing( 10 ); |
1622 | 1583 | ||
1623 | mDetailsSplitter = new QSplitter( this ); | 1584 | mDetailsSplitter = new QSplitter( this ); |
1624 | 1585 | ||
1625 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1586 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1626 | 1587 | ||
1627 | mViewManager = new ViewManager( this, viewSpace ); | 1588 | mViewManager = new ViewManager( this, viewSpace ); |
1628 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1589 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1629 | 1590 | ||
1630 | mDetails = new ViewContainer( mDetailsSplitter ); | 1591 | mDetails = new ViewContainer( mDetailsSplitter ); |
1631 | 1592 | ||
1632 | topLayout->addWidget( mDetailsSplitter ); | 1593 | topLayout->addWidget( mDetailsSplitter ); |
1633 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1594 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1634 | #else //KAB_NOSPLITTER | 1595 | #else //KAB_NOSPLITTER |
1635 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1596 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1636 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1597 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1637 | topLayout->setSpacing( 10 ); | 1598 | topLayout->setSpacing( 10 ); |
1638 | 1599 | ||
1639 | // mDetailsSplitter = new QSplitter( this ); | 1600 | // mDetailsSplitter = new QSplitter( this ); |
1640 | 1601 | ||
1641 | QVBox *viewSpace = new QVBox( this ); | 1602 | QVBox *viewSpace = new QVBox( this ); |
1642 | 1603 | ||
1643 | mViewManager = new ViewManager( this, viewSpace ); | 1604 | mViewManager = new ViewManager( this, viewSpace ); |
1644 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1605 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1645 | 1606 | ||
1646 | mDetails = new ViewContainer( this ); | 1607 | mDetails = new ViewContainer( this ); |
1647 | 1608 | ||
1648 | topLayout->addWidget( viewSpace ); | 1609 | topLayout->addWidget( viewSpace ); |
1649 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1610 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1650 | topLayout->addWidget( mDetails ); | 1611 | topLayout->addWidget( mDetails ); |
1651 | #endif //KAB_NOSPLITTER | 1612 | #endif //KAB_NOSPLITTER |
1652 | */ | 1613 | */ |
1653 | 1614 | ||
1654 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1615 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1655 | syncManager->setBlockSave(false); | 1616 | syncManager->setBlockSave(false); |
1656 | 1617 | ||
1657 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1618 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1658 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1619 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1659 | syncManager->setDefaultFileName( sentSyncFile()); | 1620 | syncManager->setDefaultFileName( sentSyncFile()); |
1660 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1621 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1661 | 1622 | ||
1662 | #endif //KAB_EMBEDDED | 1623 | #endif //KAB_EMBEDDED |
1663 | initActions(); | 1624 | initActions(); |
1664 | 1625 | ||
1665 | #ifdef KAB_EMBEDDED | 1626 | #ifdef KAB_EMBEDDED |
1666 | addActionsManually(); | 1627 | addActionsManually(); |
1667 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1628 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1668 | mXXPortManager = new XXPortManager( this, this ); | 1629 | mXXPortManager = new XXPortManager( this, this ); |
1669 | 1630 | ||
1670 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1631 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1671 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1632 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1672 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1633 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1673 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1634 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1674 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1635 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1675 | // mIncSearchWidget->hide(); | 1636 | // mIncSearchWidget->hide(); |
1676 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1637 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1677 | SLOT( incrementalSearch( const QString& ) ) ); | 1638 | SLOT( incrementalSearch( const QString& ) ) ); |
1678 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1639 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1679 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1640 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1680 | 1641 | ||
1681 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1642 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1682 | 1643 | ||
1683 | topLayout->addWidget( mJumpButtonBar ); | 1644 | topLayout->addWidget( mJumpButtonBar ); |
1684 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1645 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1685 | 1646 | ||
1686 | // mMainWindow->getIconToolBar()->raise(); | 1647 | // mMainWindow->getIconToolBar()->raise(); |
1687 | 1648 | ||
1688 | #endif //KAB_EMBEDDED | 1649 | #endif //KAB_EMBEDDED |
1689 | 1650 | ||
1690 | } | 1651 | } |
1691 | void KABCore::initActions() | 1652 | void KABCore::initActions() |
1692 | { | 1653 | { |
1693 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1654 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1694 | 1655 | ||
1695 | #ifndef KAB_EMBEDDED | 1656 | #ifndef KAB_EMBEDDED |
1696 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1657 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1697 | SLOT( clipboardDataChanged() ) ); | 1658 | SLOT( clipboardDataChanged() ) ); |
1698 | #endif //KAB_EMBEDDED | 1659 | #endif //KAB_EMBEDDED |
1699 | 1660 | ||
1700 | // file menu | 1661 | // file menu |
1701 | if ( mIsPart ) { | 1662 | if ( mIsPart ) { |
1702 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1663 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1703 | SLOT( sendMail() ), actionCollection(), | 1664 | SLOT( sendMail() ), actionCollection(), |
1704 | "kaddressbook_mail" ); | 1665 | "kaddressbook_mail" ); |
1705 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1666 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1706 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1667 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1707 | 1668 | ||
1708 | } else { | 1669 | } else { |
1709 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1670 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1710 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1671 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1711 | } | 1672 | } |
1712 | 1673 | ||
1713 | 1674 | ||
1714 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1675 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1715 | SLOT( save() ), actionCollection(), "file_sync" ); | 1676 | SLOT( save() ), actionCollection(), "file_sync" ); |
1716 | 1677 | ||
1717 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1678 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1718 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1679 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1719 | 1680 | ||
1720 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1681 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1721 | this, SLOT( mailVCard() ), | 1682 | this, SLOT( mailVCard() ), |
1722 | actionCollection(), "file_mail_vcard"); | 1683 | actionCollection(), "file_mail_vcard"); |
1723 | 1684 | ||
1724 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1685 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1725 | SLOT( export2phone() ), actionCollection(), | 1686 | SLOT( export2phone() ), actionCollection(), |
1726 | "kaddressbook_ex2phone" ); | 1687 | "kaddressbook_ex2phone" ); |
1727 | 1688 | ||
1728 | mActionBeamVCard = 0; | 1689 | mActionBeamVCard = 0; |
1729 | mActionBeam = 0; | 1690 | mActionBeam = 0; |
1730 | 1691 | ||
1731 | #ifndef DESKTOP_VERSION | 1692 | #ifndef DESKTOP_VERSION |
1732 | if ( Ir::supported() ) { | 1693 | if ( Ir::supported() ) { |
1733 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1694 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1734 | SLOT( beamVCard() ), actionCollection(), | 1695 | SLOT( beamVCard() ), actionCollection(), |
1735 | "kaddressbook_beam_vcard" ); | 1696 | "kaddressbook_beam_vcard" ); |
1736 | 1697 | ||
1737 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1698 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1738 | SLOT( beamMySelf() ), actionCollection(), | 1699 | SLOT( beamMySelf() ), actionCollection(), |
1739 | "kaddressbook_beam_myself" ); | 1700 | "kaddressbook_beam_myself" ); |
1740 | } | 1701 | } |
1741 | #endif | 1702 | #endif |
1742 | 1703 | ||
1743 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1704 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1744 | this, SLOT( editContact2() ), | 1705 | this, SLOT( editContact2() ), |
1745 | actionCollection(), "file_properties" ); | 1706 | actionCollection(), "file_properties" ); |
1746 | 1707 | ||
1747 | #ifdef KAB_EMBEDDED | 1708 | #ifdef KAB_EMBEDDED |
1748 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1709 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1749 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1710 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1750 | mMainWindow, SLOT( exit() ), | 1711 | mMainWindow, SLOT( exit() ), |
1751 | actionCollection(), "quit" ); | 1712 | actionCollection(), "quit" ); |
1752 | #endif //KAB_EMBEDDED | 1713 | #endif //KAB_EMBEDDED |
1753 | 1714 | ||
1754 | // edit menu | 1715 | // edit menu |
1755 | if ( mIsPart ) { | 1716 | if ( mIsPart ) { |
1756 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1717 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1757 | SLOT( copyContacts() ), actionCollection(), | 1718 | SLOT( copyContacts() ), actionCollection(), |
1758 | "kaddressbook_copy" ); | 1719 | "kaddressbook_copy" ); |
1759 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1720 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1760 | SLOT( cutContacts() ), actionCollection(), | 1721 | SLOT( cutContacts() ), actionCollection(), |
1761 | "kaddressbook_cut" ); | 1722 | "kaddressbook_cut" ); |
1762 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1723 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1763 | SLOT( pasteContacts() ), actionCollection(), | 1724 | SLOT( pasteContacts() ), actionCollection(), |
1764 | "kaddressbook_paste" ); | 1725 | "kaddressbook_paste" ); |
1765 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1726 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1766 | SLOT( selectAllContacts() ), actionCollection(), | 1727 | SLOT( selectAllContacts() ), actionCollection(), |
1767 | "kaddressbook_select_all" ); | 1728 | "kaddressbook_select_all" ); |
1768 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1729 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1769 | SLOT( undo() ), actionCollection(), | 1730 | SLOT( undo() ), actionCollection(), |
1770 | "kaddressbook_undo" ); | 1731 | "kaddressbook_undo" ); |
1771 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1732 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1772 | this, SLOT( redo() ), actionCollection(), | 1733 | this, SLOT( redo() ), actionCollection(), |
1773 | "kaddressbook_redo" ); | 1734 | "kaddressbook_redo" ); |
1774 | } else { | 1735 | } else { |
1775 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1736 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1776 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1737 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1777 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1738 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1778 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1739 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1779 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1740 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1780 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1741 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1781 | } | 1742 | } |
1782 | 1743 | ||
1783 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1744 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1784 | Key_Delete, this, SLOT( deleteContacts() ), | 1745 | Key_Delete, this, SLOT( deleteContacts() ), |
1785 | actionCollection(), "edit_delete" ); | 1746 | actionCollection(), "edit_delete" ); |
1786 | 1747 | ||
1787 | mActionUndo->setEnabled( false ); | 1748 | mActionUndo->setEnabled( false ); |
1788 | mActionRedo->setEnabled( false ); | 1749 | mActionRedo->setEnabled( false ); |
1789 | 1750 | ||
1790 | // settings menu | 1751 | // settings menu |
1791 | #ifdef KAB_EMBEDDED | 1752 | #ifdef KAB_EMBEDDED |
1792 | //US special menuentry to configure the addressbook resources. On KDE | 1753 | //US special menuentry to configure the addressbook resources. On KDE |
1793 | // you do that through the control center !!! | 1754 | // you do that through the control center !!! |
1794 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1755 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1795 | SLOT( configureResources() ), actionCollection(), | 1756 | SLOT( configureResources() ), actionCollection(), |
1796 | "kaddressbook_configure_resources" ); | 1757 | "kaddressbook_configure_resources" ); |
1797 | #endif //KAB_EMBEDDED | 1758 | #endif //KAB_EMBEDDED |
1798 | 1759 | ||
1799 | if ( mIsPart ) { | 1760 | if ( mIsPart ) { |
1800 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1761 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1801 | SLOT( openConfigDialog() ), actionCollection(), | 1762 | SLOT( openConfigDialog() ), actionCollection(), |
1802 | "kaddressbook_configure" ); | 1763 | "kaddressbook_configure" ); |
1803 | 1764 | ||
1804 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1765 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1805 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1766 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1806 | "kaddressbook_configure_shortcuts" ); | 1767 | "kaddressbook_configure_shortcuts" ); |
1807 | #ifdef KAB_EMBEDDED | 1768 | #ifdef KAB_EMBEDDED |
1808 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1769 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1809 | mActionConfigureToolbars->setEnabled( false ); | 1770 | mActionConfigureToolbars->setEnabled( false ); |
1810 | #endif //KAB_EMBEDDED | 1771 | #endif //KAB_EMBEDDED |
1811 | 1772 | ||
1812 | } else { | 1773 | } else { |
1813 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1774 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1814 | 1775 | ||
1815 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1776 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1816 | } | 1777 | } |
1817 | 1778 | ||
1818 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1779 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1819 | actionCollection(), "options_show_jump_bar" ); | 1780 | actionCollection(), "options_show_jump_bar" ); |
1820 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1781 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1821 | 1782 | ||
1822 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1783 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1823 | actionCollection(), "options_show_details" ); | 1784 | actionCollection(), "options_show_details" ); |
1824 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1785 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1825 | 1786 | ||
1826 | // misc | 1787 | // misc |
1827 | // only enable LDAP lookup if we can handle the protocol | 1788 | // only enable LDAP lookup if we can handle the protocol |
1828 | #ifndef KAB_EMBEDDED | 1789 | #ifndef KAB_EMBEDDED |
1829 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1790 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1830 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1791 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1831 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1792 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1832 | "ldap_lookup" ); | 1793 | "ldap_lookup" ); |
1833 | } | 1794 | } |
1834 | #else //KAB_EMBEDDED | 1795 | #else //KAB_EMBEDDED |
1835 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1796 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1836 | #endif //KAB_EMBEDDED | 1797 | #endif //KAB_EMBEDDED |
1837 | 1798 | ||
1838 | 1799 | ||
1839 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1800 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1840 | SLOT( setWhoAmI() ), actionCollection(), | 1801 | SLOT( setWhoAmI() ), actionCollection(), |
1841 | "set_personal" ); | 1802 | "set_personal" ); |
1842 | 1803 | ||
1843 | 1804 | ||
1844 | 1805 | ||
1845 | 1806 | ||
1846 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1807 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1847 | SLOT( setCategories() ), actionCollection(), | 1808 | SLOT( setCategories() ), actionCollection(), |
1848 | "edit_set_categories" ); | 1809 | "edit_set_categories" ); |
1849 | 1810 | ||
1850 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1811 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1851 | SLOT( removeVoice() ), actionCollection(), | 1812 | SLOT( removeVoice() ), actionCollection(), |
1852 | "remove_voice" ); | 1813 | "remove_voice" ); |
1853 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1814 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1854 | SLOT( importFromOL() ), actionCollection(), | 1815 | SLOT( importFromOL() ), actionCollection(), |
1855 | "import_OL" ); | 1816 | "import_OL" ); |
1856 | #ifdef KAB_EMBEDDED | 1817 | #ifdef KAB_EMBEDDED |
1857 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1818 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1858 | this, SLOT( showLicence() ), actionCollection(), | 1819 | this, SLOT( showLicence() ), actionCollection(), |
1859 | "licence_about_data" ); | 1820 | "licence_about_data" ); |
1860 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1821 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1861 | this, SLOT( faq() ), actionCollection(), | 1822 | this, SLOT( faq() ), actionCollection(), |
1862 | "faq_about_data" ); | 1823 | "faq_about_data" ); |
1863 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 1824 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
1864 | this, SLOT( whatsnew() ), actionCollection(), | 1825 | this, SLOT( whatsnew() ), actionCollection(), |
1865 | "wn" ); | 1826 | "wn" ); |
1866 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 1827 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
1867 | this, SLOT( synchowto() ), actionCollection(), | 1828 | this, SLOT( synchowto() ), actionCollection(), |
1868 | "sync" ); | 1829 | "sync" ); |
1869 | 1830 | ||
1870 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1831 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1871 | this, SLOT( createAboutData() ), actionCollection(), | 1832 | this, SLOT( createAboutData() ), actionCollection(), |
1872 | "kaddressbook_about_data" ); | 1833 | "kaddressbook_about_data" ); |
1873 | #endif //KAB_EMBEDDED | 1834 | #endif //KAB_EMBEDDED |
1874 | 1835 | ||
1875 | clipboardDataChanged(); | 1836 | clipboardDataChanged(); |
1876 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1837 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1877 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1838 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1878 | } | 1839 | } |
1879 | 1840 | ||
1880 | //US we need this function, to plug all actions into the correct menues. | 1841 | //US we need this function, to plug all actions into the correct menues. |
1881 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1842 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1882 | void KABCore::addActionsManually() | 1843 | void KABCore::addActionsManually() |
1883 | { | 1844 | { |
1884 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1845 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1885 | 1846 | ||
1886 | #ifdef KAB_EMBEDDED | 1847 | #ifdef KAB_EMBEDDED |
1887 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1848 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1888 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1849 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1889 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1850 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1890 | 1851 | ||
1891 | KToolBar* tb = mMainWindow->toolBar(); | 1852 | KToolBar* tb = mMainWindow->toolBar(); |
1892 | 1853 | ||
1893 | #ifdef DESKTOP_VERSION | 1854 | #ifdef DESKTOP_VERSION |
1894 | QMenuBar* mb = mMainWindow->menuBar(); | 1855 | QMenuBar* mb = mMainWindow->menuBar(); |
1895 | 1856 | ||
1896 | //US setup menubar. | 1857 | //US setup menubar. |
1897 | //Disable the following block if you do not want to have a menubar. | 1858 | //Disable the following block if you do not want to have a menubar. |
1898 | mb->insertItem( "&File", fileMenu ); | 1859 | mb->insertItem( "&File", fileMenu ); |
1899 | mb->insertItem( "&Edit", editMenu ); | 1860 | mb->insertItem( "&Edit", editMenu ); |
1900 | mb->insertItem( "&View", viewMenu ); | 1861 | mb->insertItem( "&View", viewMenu ); |
1901 | mb->insertItem( "&Settings", settingsMenu ); | 1862 | mb->insertItem( "&Settings", settingsMenu ); |
1902 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1863 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1903 | mb->insertItem( "&Change selected", changeMenu ); | 1864 | mb->insertItem( "&Change selected", changeMenu ); |
1904 | mb->insertItem( "&Help", helpMenu ); | 1865 | mb->insertItem( "&Help", helpMenu ); |
1905 | mIncSearchWidget = new IncSearchWidget( tb ); | 1866 | mIncSearchWidget = new IncSearchWidget( tb ); |
1906 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1867 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1907 | 1868 | ||
1908 | #else | 1869 | #else |
1909 | //US setup toolbar | 1870 | //US setup toolbar |
1910 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1871 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1911 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1872 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1912 | menuBarTB->insertItem( "ME", popupBarTB); | 1873 | menuBarTB->insertItem( "ME", popupBarTB); |
1913 | tb->insertWidget(-1, 0, menuBarTB); | 1874 | tb->insertWidget(-1, 0, menuBarTB); |
1914 | mIncSearchWidget = new IncSearchWidget( tb ); | 1875 | mIncSearchWidget = new IncSearchWidget( tb ); |
1915 | 1876 | ||
1916 | tb->enableMoving(false); | 1877 | tb->enableMoving(false); |
1917 | popupBarTB->insertItem( "&File", fileMenu ); | 1878 | popupBarTB->insertItem( "&File", fileMenu ); |
1918 | popupBarTB->insertItem( "&Edit", editMenu ); | 1879 | popupBarTB->insertItem( "&Edit", editMenu ); |
1919 | popupBarTB->insertItem( "&View", viewMenu ); | 1880 | popupBarTB->insertItem( "&View", viewMenu ); |
1920 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1881 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1921 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1882 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1922 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1883 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1923 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1884 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1924 | popupBarTB->insertItem( "&Help", helpMenu ); | 1885 | popupBarTB->insertItem( "&Help", helpMenu ); |
1925 | if (QApplication::desktop()->width() > 320 ) { | 1886 | if (QApplication::desktop()->width() > 320 ) { |
1926 | // mViewManager->getFilterAction()->plug ( tb); | 1887 | // mViewManager->getFilterAction()->plug ( tb); |
1927 | } | 1888 | } |
1928 | #endif | 1889 | #endif |
1929 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1890 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1930 | 1891 | ||
1931 | 1892 | ||
1932 | 1893 | ||
1933 | //US Now connect the actions with the menue entries. | 1894 | //US Now connect the actions with the menue entries. |
1934 | mActionPrint->plug( fileMenu ); | 1895 | mActionPrint->plug( fileMenu ); |
1935 | mActionMail->plug( fileMenu ); | 1896 | mActionMail->plug( fileMenu ); |
1936 | fileMenu->insertSeparator(); | 1897 | fileMenu->insertSeparator(); |
1937 | 1898 | ||
1938 | mActionNewContact->plug( fileMenu ); | 1899 | mActionNewContact->plug( fileMenu ); |
1939 | mActionNewContact->plug( tb ); | 1900 | mActionNewContact->plug( tb ); |
1940 | 1901 | ||
1941 | mActionEditAddressee->plug( fileMenu ); | 1902 | mActionEditAddressee->plug( fileMenu ); |
1942 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1903 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1943 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1904 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1944 | mActionEditAddressee->plug( tb ); | 1905 | mActionEditAddressee->plug( tb ); |
1945 | 1906 | ||
1946 | fileMenu->insertSeparator(); | 1907 | fileMenu->insertSeparator(); |
1947 | mActionSave->plug( fileMenu ); | 1908 | mActionSave->plug( fileMenu ); |
1948 | fileMenu->insertItem( "&Import", ImportMenu ); | 1909 | fileMenu->insertItem( "&Import", ImportMenu ); |
1949 | fileMenu->insertItem( "&Export", ExportMenu ); | 1910 | fileMenu->insertItem( "&Export", ExportMenu ); |
1950 | fileMenu->insertSeparator(); | 1911 | fileMenu->insertSeparator(); |
1951 | mActionMailVCard->plug( fileMenu ); | 1912 | mActionMailVCard->plug( fileMenu ); |
1952 | #ifndef DESKTOP_VERSION | 1913 | #ifndef DESKTOP_VERSION |
1953 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1914 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1954 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1915 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1955 | #endif | 1916 | #endif |
1956 | fileMenu->insertSeparator(); | 1917 | fileMenu->insertSeparator(); |
1957 | mActionQuit->plug( fileMenu ); | 1918 | mActionQuit->plug( fileMenu ); |
1958 | #ifdef _WIN32_ | 1919 | #ifdef _WIN32_ |
1959 | mActionImportOL->plug( ImportMenu ); | 1920 | mActionImportOL->plug( ImportMenu ); |
1960 | #endif | 1921 | #endif |
1961 | // edit menu | 1922 | // edit menu |
1962 | mActionUndo->plug( editMenu ); | 1923 | mActionUndo->plug( editMenu ); |
1963 | mActionRedo->plug( editMenu ); | 1924 | mActionRedo->plug( editMenu ); |
1964 | editMenu->insertSeparator(); | 1925 | editMenu->insertSeparator(); |
1965 | mActionCut->plug( editMenu ); | 1926 | mActionCut->plug( editMenu ); |
1966 | mActionCopy->plug( editMenu ); | 1927 | mActionCopy->plug( editMenu ); |
1967 | mActionPaste->plug( editMenu ); | 1928 | mActionPaste->plug( editMenu ); |
1968 | mActionDelete->plug( editMenu ); | 1929 | mActionDelete->plug( editMenu ); |
1969 | editMenu->insertSeparator(); | 1930 | editMenu->insertSeparator(); |
1970 | mActionSelectAll->plug( editMenu ); | 1931 | mActionSelectAll->plug( editMenu ); |
1971 | 1932 | ||
1972 | mActionRemoveVoice->plug( changeMenu ); | 1933 | mActionRemoveVoice->plug( changeMenu ); |
1973 | // settings menu | 1934 | // settings menu |
1974 | //US special menuentry to configure the addressbook resources. On KDE | 1935 | //US special menuentry to configure the addressbook resources. On KDE |
1975 | // you do that through the control center !!! | 1936 | // you do that through the control center !!! |
1976 | mActionConfigResources->plug( settingsMenu ); | 1937 | mActionConfigResources->plug( settingsMenu ); |
1977 | settingsMenu->insertSeparator(); | 1938 | settingsMenu->insertSeparator(); |
1978 | 1939 | ||
1979 | mActionConfigKAddressbook->plug( settingsMenu ); | 1940 | mActionConfigKAddressbook->plug( settingsMenu ); |
1980 | 1941 | ||
1981 | if ( mIsPart ) { | 1942 | if ( mIsPart ) { |
1982 | mActionConfigShortcuts->plug( settingsMenu ); | 1943 | mActionConfigShortcuts->plug( settingsMenu ); |
1983 | mActionConfigureToolbars->plug( settingsMenu ); | 1944 | mActionConfigureToolbars->plug( settingsMenu ); |
1984 | 1945 | ||
1985 | } else { | 1946 | } else { |
1986 | mActionKeyBindings->plug( settingsMenu ); | 1947 | mActionKeyBindings->plug( settingsMenu ); |
1987 | } | 1948 | } |
1988 | 1949 | ||
1989 | settingsMenu->insertSeparator(); | 1950 | settingsMenu->insertSeparator(); |
1990 | 1951 | ||
1991 | mActionJumpBar->plug( settingsMenu ); | 1952 | mActionJumpBar->plug( settingsMenu ); |
1992 | mActionDetails->plug( settingsMenu ); | 1953 | mActionDetails->plug( settingsMenu ); |
1993 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 1954 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
1994 | mActionDetails->plug( tb ); | 1955 | mActionDetails->plug( tb ); |
1995 | settingsMenu->insertSeparator(); | 1956 | settingsMenu->insertSeparator(); |
1996 | 1957 | ||
1997 | mActionWhoAmI->plug( settingsMenu ); | 1958 | mActionWhoAmI->plug( settingsMenu ); |
1998 | mActionCategories->plug( settingsMenu ); | 1959 | mActionCategories->plug( settingsMenu ); |
1999 | 1960 | ||
2000 | 1961 | ||
2001 | mActionWN->plug( helpMenu ); | 1962 | mActionWN->plug( helpMenu ); |
2002 | mActionSyncHowto->plug( helpMenu ); | 1963 | mActionSyncHowto->plug( helpMenu ); |
2003 | mActionLicence->plug( helpMenu ); | 1964 | mActionLicence->plug( helpMenu ); |
2004 | mActionFaq->plug( helpMenu ); | 1965 | mActionFaq->plug( helpMenu ); |
2005 | mActionAboutKAddressbook->plug( helpMenu ); | 1966 | mActionAboutKAddressbook->plug( helpMenu ); |
2006 | 1967 | ||
2007 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1968 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2008 | 1969 | ||
2009 | mActionSave->plug( tb ); | 1970 | mActionSave->plug( tb ); |
2010 | mViewManager->getFilterAction()->plug ( tb); | 1971 | mViewManager->getFilterAction()->plug ( tb); |
2011 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 1972 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2012 | mActionUndo->plug( tb ); | 1973 | mActionUndo->plug( tb ); |
2013 | mActionDelete->plug( tb ); | 1974 | mActionDelete->plug( tb ); |
2014 | mActionRedo->plug( tb ); | 1975 | mActionRedo->plug( tb ); |
2015 | } | 1976 | } |
2016 | } | 1977 | } |
2017 | //mActionQuit->plug ( tb ); | 1978 | //mActionQuit->plug ( tb ); |
2018 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1979 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2019 | 1980 | ||
2020 | //US link the searchwidget first to this. | 1981 | //US link the searchwidget first to this. |
2021 | // The real linkage to the toolbar happens later. | 1982 | // The real linkage to the toolbar happens later. |
2022 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1983 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2023 | //US tb->insertItem( mIncSearchWidget ); | 1984 | //US tb->insertItem( mIncSearchWidget ); |
2024 | /*US | 1985 | /*US |
2025 | mIncSearchWidget = new IncSearchWidget( tb ); | 1986 | mIncSearchWidget = new IncSearchWidget( tb ); |
2026 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1987 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2027 | SLOT( incrementalSearch( const QString& ) ) ); | 1988 | SLOT( incrementalSearch( const QString& ) ) ); |
2028 | 1989 | ||
2029 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1990 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2030 | 1991 | ||
2031 | //US topLayout->addWidget( mJumpButtonBar ); | 1992 | //US topLayout->addWidget( mJumpButtonBar ); |
2032 | this->layout()->add( mJumpButtonBar ); | 1993 | this->layout()->add( mJumpButtonBar ); |
2033 | */ | 1994 | */ |
2034 | 1995 | ||
2035 | #endif //KAB_EMBEDDED | 1996 | #endif //KAB_EMBEDDED |
2036 | 1997 | ||
2037 | mActionExport2phone->plug( ExportMenu ); | 1998 | mActionExport2phone->plug( ExportMenu ); |
2038 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 1999 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2039 | syncManager->fillSyncMenu(); | 2000 | syncManager->fillSyncMenu(); |
2040 | 2001 | ||
2041 | } | 2002 | } |
2042 | void KABCore::showLicence() | 2003 | void KABCore::showLicence() |
2043 | { | 2004 | { |
2044 | KApplication::showLicence(); | 2005 | KApplication::showLicence(); |
2045 | } | 2006 | } |
2046 | void KABCore::removeVoice() | 2007 | void KABCore::removeVoice() |
2047 | { | 2008 | { |
2048 | 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 ) | 2009 | 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 ) |
2049 | return; | 2010 | return; |
2050 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2011 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2051 | KABC::Addressee::List::Iterator it; | 2012 | KABC::Addressee::List::Iterator it; |
2052 | for ( it = list.begin(); it != list.end(); ++it ) { | 2013 | for ( it = list.begin(); it != list.end(); ++it ) { |
2053 | 2014 | ||
2054 | if ( (*it).removeVoice() ) | 2015 | if ( (*it).removeVoice() ) |
2055 | contactModified((*it) ); | 2016 | contactModified((*it) ); |
2056 | } | 2017 | } |
2057 | } | 2018 | } |
2058 | 2019 | ||
2059 | 2020 | ||
2060 | 2021 | ||
2061 | void KABCore::clipboardDataChanged() | 2022 | void KABCore::clipboardDataChanged() |
2062 | { | 2023 | { |
2063 | 2024 | ||
2064 | if ( mReadWrite ) | 2025 | if ( mReadWrite ) |
2065 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2026 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2066 | 2027 | ||
2067 | } | 2028 | } |
2068 | 2029 | ||
2069 | void KABCore::updateActionMenu() | 2030 | void KABCore::updateActionMenu() |
2070 | { | 2031 | { |
2071 | UndoStack *undo = UndoStack::instance(); | 2032 | UndoStack *undo = UndoStack::instance(); |
2072 | RedoStack *redo = RedoStack::instance(); | 2033 | RedoStack *redo = RedoStack::instance(); |
2073 | 2034 | ||
2074 | if ( undo->isEmpty() ) | 2035 | if ( undo->isEmpty() ) |
2075 | mActionUndo->setText( i18n( "Undo" ) ); | 2036 | mActionUndo->setText( i18n( "Undo" ) ); |
2076 | else | 2037 | else |
2077 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2038 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2078 | 2039 | ||
2079 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2040 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2080 | 2041 | ||
2081 | if ( !redo->top() ) | 2042 | if ( !redo->top() ) |
2082 | mActionRedo->setText( i18n( "Redo" ) ); | 2043 | mActionRedo->setText( i18n( "Redo" ) ); |
2083 | else | 2044 | else |
2084 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2045 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2085 | 2046 | ||
2086 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2047 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2087 | } | 2048 | } |
2088 | 2049 | ||
2089 | void KABCore::configureKeyBindings() | 2050 | void KABCore::configureKeyBindings() |
2090 | { | 2051 | { |
2091 | #ifndef KAB_EMBEDDED | 2052 | #ifndef KAB_EMBEDDED |
2092 | KKeyDialog::configure( actionCollection(), true ); | 2053 | KKeyDialog::configure( actionCollection(), true ); |
2093 | #else //KAB_EMBEDDED | 2054 | #else //KAB_EMBEDDED |
2094 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2055 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2095 | #endif //KAB_EMBEDDED | 2056 | #endif //KAB_EMBEDDED |
2096 | } | 2057 | } |
2097 | 2058 | ||
2098 | #ifdef KAB_EMBEDDED | 2059 | #ifdef KAB_EMBEDDED |
2099 | void KABCore::configureResources() | 2060 | void KABCore::configureResources() |
2100 | { | 2061 | { |
2101 | KRES::KCMKResources dlg( this, "" , 0 ); | 2062 | KRES::KCMKResources dlg( this, "" , 0 ); |
2102 | 2063 | ||
2103 | if ( !dlg.exec() ) | 2064 | if ( !dlg.exec() ) |
2104 | return; | 2065 | return; |
2105 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2066 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2106 | } | 2067 | } |
2107 | #endif //KAB_EMBEDDED | 2068 | #endif //KAB_EMBEDDED |
2108 | 2069 | ||
2109 | 2070 | ||
2110 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2071 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2111 | * for the attendees list of an event. | 2072 | * for the attendees list of an event. |
2112 | */ | 2073 | */ |
2113 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2074 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2114 | { | 2075 | { |
2115 | QStringList nameList; | 2076 | QStringList nameList; |
2116 | QStringList emailList; | 2077 | QStringList emailList; |
2117 | QStringList uidList; | 2078 | QStringList uidList; |
2118 | 2079 | ||
2119 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2080 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2120 | uint i=0; | 2081 | uint i=0; |
2121 | for (i=0; i < list.count(); i++) | 2082 | for (i=0; i < list.count(); i++) |
2122 | { | 2083 | { |
2123 | nameList.append(list[i].realName()); | 2084 | nameList.append(list[i].realName()); |
2124 | emailList.append(list[i].preferredEmail()); | 2085 | emailList.append(list[i].preferredEmail()); |
2125 | uidList.append(list[i].uid()); | 2086 | uidList.append(list[i].uid()); |
2126 | } | 2087 | } |
2127 | 2088 | ||
2128 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2089 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2129 | 2090 | ||
2130 | } | 2091 | } |
2131 | 2092 | ||
2132 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2093 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2133 | * to put them into the calendar. | 2094 | * to put them into the calendar. |
2134 | */ | 2095 | */ |
2135 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2096 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2136 | { | 2097 | { |
2137 | // qDebug("KABCore::requestForBirthdayList"); | 2098 | // qDebug("KABCore::requestForBirthdayList"); |
2138 | QStringList birthdayList; | 2099 | QStringList birthdayList; |
2139 | QStringList anniversaryList; | 2100 | QStringList anniversaryList; |
2140 | QStringList realNameList; | 2101 | QStringList realNameList; |
2141 | QStringList preferredEmailList; | 2102 | QStringList preferredEmailList; |
2142 | QStringList assembledNameList; | 2103 | QStringList assembledNameList; |
2143 | QStringList uidList; | 2104 | QStringList uidList; |
2144 | 2105 | ||
2145 | KABC::AddressBook::Iterator it; | 2106 | KABC::AddressBook::Iterator it; |
2146 | 2107 | ||
2147 | int count = 0; | 2108 | int count = 0; |
2148 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2109 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2149 | ++count; | 2110 | ++count; |
2150 | } | 2111 | } |
2151 | QProgressBar bar(count,0 ); | 2112 | QProgressBar bar(count,0 ); |
2152 | int w = 300; | 2113 | int w = 300; |
2153 | if ( QApplication::desktop()->width() < 320 ) | 2114 | if ( QApplication::desktop()->width() < 320 ) |
2154 | w = 220; | 2115 | w = 220; |
2155 | int h = bar.sizeHint().height() ; | 2116 | int h = bar.sizeHint().height() ; |
2156 | int dw = QApplication::desktop()->width(); | 2117 | int dw = QApplication::desktop()->width(); |
2157 | int dh = QApplication::desktop()->height(); | 2118 | int dh = QApplication::desktop()->height(); |
2158 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2119 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2159 | bar.show(); | 2120 | bar.show(); |
2160 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2121 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2161 | qApp->processEvents(); | 2122 | qApp->processEvents(); |
2162 | 2123 | ||
2163 | QDate bday; | 2124 | QDate bday; |
2164 | QString anni; | 2125 | QString anni; |
2165 | QString formattedbday; | 2126 | QString formattedbday; |
2166 | 2127 | ||
2167 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2128 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2168 | { | 2129 | { |
2169 | if ( ! bar.isVisible() ) | 2130 | if ( ! bar.isVisible() ) |
2170 | return; | 2131 | return; |
2171 | bar.setProgress( count++ ); | 2132 | bar.setProgress( count++ ); |
2172 | qApp->processEvents(); | 2133 | qApp->processEvents(); |
2173 | bday = (*it).birthday().date(); | 2134 | bday = (*it).birthday().date(); |
2174 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2135 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2175 | 2136 | ||
2176 | if ( bday.isValid() || !anni.isEmpty()) | 2137 | if ( bday.isValid() || !anni.isEmpty()) |
2177 | { | 2138 | { |
2178 | if (bday.isValid()) | 2139 | if (bday.isValid()) |
2179 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2140 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2180 | else | 2141 | else |
2181 | formattedbday = "NOTVALID"; | 2142 | formattedbday = "NOTVALID"; |
2182 | if (anni.isEmpty()) | 2143 | if (anni.isEmpty()) |
2183 | anni = "INVALID"; | 2144 | anni = "INVALID"; |
2184 | 2145 | ||
2185 | birthdayList.append(formattedbday); | 2146 | birthdayList.append(formattedbday); |
2186 | anniversaryList.append(anni); //should be ISODate | 2147 | anniversaryList.append(anni); //should be ISODate |
2187 | realNameList.append((*it).realName()); | 2148 | realNameList.append((*it).realName()); |
2188 | preferredEmailList.append((*it).preferredEmail()); | 2149 | preferredEmailList.append((*it).preferredEmail()); |
2189 | assembledNameList.append((*it).assembledName()); | 2150 | assembledNameList.append((*it).assembledName()); |
2190 | uidList.append((*it).uid()); | 2151 | uidList.append((*it).uid()); |
2191 | 2152 | ||
2192 | 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() ); | 2153 | 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() ); |
2193 | } | 2154 | } |
2194 | } | 2155 | } |
2195 | 2156 | ||
2196 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2157 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2197 | 2158 | ||
2198 | } | 2159 | } |
2199 | 2160 | ||
2200 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2161 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2201 | */ | 2162 | */ |
2202 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2163 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2203 | { | 2164 | { |
2204 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2165 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2205 | 2166 | ||
2206 | QString foundUid = QString::null; | 2167 | QString foundUid = QString::null; |
2207 | if ( ! uid.isEmpty() ) { | 2168 | if ( ! uid.isEmpty() ) { |
2208 | Addressee adrr = mAddressBook->findByUid( uid ); | 2169 | Addressee adrr = mAddressBook->findByUid( uid ); |
2209 | if ( !adrr.isEmpty() ) { | 2170 | if ( !adrr.isEmpty() ) { |
2210 | foundUid = uid; | 2171 | foundUid = uid; |
2211 | } | 2172 | } |
2212 | if ( email == "sendbacklist" ) { | 2173 | if ( email == "sendbacklist" ) { |
2213 | //qDebug("ssssssssssssssssssssssend "); | 2174 | //qDebug("ssssssssssssssssssssssend "); |
2214 | QStringList nameList; | 2175 | QStringList nameList; |
2215 | QStringList emailList; | 2176 | QStringList emailList; |
2216 | QStringList uidList; | 2177 | QStringList uidList; |
2217 | nameList.append(adrr.realName()); | 2178 | nameList.append(adrr.realName()); |
2218 | emailList = adrr.emails(); | 2179 | emailList = adrr.emails(); |
2219 | uidList.append( adrr.preferredEmail()); | 2180 | uidList.append( adrr.preferredEmail()); |
2220 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2181 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2221 | return; | 2182 | return; |
2222 | } | 2183 | } |
2223 | 2184 | ||
2224 | } | 2185 | } |
2225 | 2186 | ||
2226 | if ( email == "sendbacklist" ) | 2187 | if ( email == "sendbacklist" ) |
2227 | return; | 2188 | return; |
2228 | if (foundUid.isEmpty()) | 2189 | if (foundUid.isEmpty()) |
2229 | { | 2190 | { |
2230 | //find the uid of the person first | 2191 | //find the uid of the person first |
2231 | Addressee::List namelist; | 2192 | Addressee::List namelist; |
2232 | Addressee::List emaillist; | 2193 | Addressee::List emaillist; |
2233 | 2194 | ||
2234 | if (!name.isEmpty()) | 2195 | if (!name.isEmpty()) |
2235 | namelist = mAddressBook->findByName( name ); | 2196 | namelist = mAddressBook->findByName( name ); |
2236 | 2197 | ||
2237 | if (!email.isEmpty()) | 2198 | if (!email.isEmpty()) |
2238 | emaillist = mAddressBook->findByEmail( email ); | 2199 | emaillist = mAddressBook->findByEmail( email ); |
2239 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2200 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2240 | //check if we have a match in Namelist and Emaillist | 2201 | //check if we have a match in Namelist and Emaillist |
2241 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2202 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2242 | foundUid = emaillist[0].uid(); | 2203 | foundUid = emaillist[0].uid(); |
2243 | } | 2204 | } |
2244 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2205 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2245 | foundUid = namelist[0].uid(); | 2206 | foundUid = namelist[0].uid(); |
2246 | else | 2207 | else |
2247 | { | 2208 | { |
2248 | for (int i = 0; i < namelist.count(); i++) | 2209 | for (int i = 0; i < namelist.count(); i++) |
2249 | { | 2210 | { |
2250 | for (int j = 0; j < emaillist.count(); j++) | 2211 | for (int j = 0; j < emaillist.count(); j++) |
2251 | { | 2212 | { |
2252 | if (namelist[i] == emaillist[j]) | 2213 | if (namelist[i] == emaillist[j]) |
2253 | { | 2214 | { |
2254 | foundUid = namelist[i].uid(); | 2215 | foundUid = namelist[i].uid(); |
2255 | } | 2216 | } |
2256 | } | 2217 | } |
2257 | } | 2218 | } |
2258 | } | 2219 | } |
2259 | } | 2220 | } |
2260 | else | 2221 | else |
2261 | { | 2222 | { |
2262 | foundUid = uid; | 2223 | foundUid = uid; |
2263 | } | 2224 | } |
2264 | 2225 | ||
2265 | if (!foundUid.isEmpty()) | 2226 | if (!foundUid.isEmpty()) |
2266 | { | 2227 | { |
2267 | 2228 | ||
2268 | // raise Ka/Pi if it is in the background | 2229 | // raise Ka/Pi if it is in the background |
2269 | #ifndef DESKTOP_VERSION | 2230 | #ifndef DESKTOP_VERSION |
2270 | #ifndef KORG_NODCOP | 2231 | #ifndef KORG_NODCOP |
2271 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2232 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2272 | #endif | 2233 | #endif |
2273 | #endif | 2234 | #endif |
2274 | 2235 | ||
2275 | mMainWindow->showMaximized(); | 2236 | mMainWindow->showMaximized(); |
2276 | mMainWindow-> raise(); | 2237 | mMainWindow-> raise(); |
2277 | 2238 | ||
2278 | mViewManager->setSelected( "", false); | 2239 | mViewManager->setSelected( "", false); |
2279 | mViewManager->refreshView( "" ); | 2240 | mViewManager->refreshView( "" ); |
2280 | mViewManager->setSelected( foundUid, true ); | 2241 | mViewManager->setSelected( foundUid, true ); |
2281 | mViewManager->refreshView( foundUid ); | 2242 | mViewManager->refreshView( foundUid ); |
2282 | 2243 | ||
2283 | if ( !mMultipleViewsAtOnce ) | 2244 | if ( !mMultipleViewsAtOnce ) |
2284 | { | 2245 | { |
2285 | setDetailsVisible( true ); | 2246 | setDetailsVisible( true ); |
2286 | mActionDetails->setChecked(true); | 2247 | mActionDetails->setChecked(true); |
2287 | } | 2248 | } |
2288 | } | 2249 | } |
2289 | } | 2250 | } |
2290 | 2251 | ||
2291 | void KABCore::whatsnew() | 2252 | void KABCore::whatsnew() |
2292 | { | 2253 | { |
2293 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2254 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2294 | } | 2255 | } |
2295 | void KABCore::synchowto() | 2256 | void KABCore::synchowto() |
2296 | { | 2257 | { |
2297 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2258 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2298 | } | 2259 | } |
2299 | 2260 | ||
2300 | void KABCore::faq() | 2261 | void KABCore::faq() |
2301 | { | 2262 | { |
2302 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2263 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2303 | } | 2264 | } |
2304 | 2265 | ||
2305 | #include <libkcal/syncdefines.h> | 2266 | #include <libkcal/syncdefines.h> |
2306 | 2267 | ||
2307 | KABC::Addressee KABCore::getLastSyncAddressee() | 2268 | KABC::Addressee KABCore::getLastSyncAddressee() |
2308 | { | 2269 | { |
2309 | Addressee lse; | 2270 | Addressee lse; |
2310 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2271 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2311 | 2272 | ||
2312 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2273 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2313 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2274 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2314 | if (lse.isEmpty()) { | 2275 | if (lse.isEmpty()) { |
2315 | qDebug("Creating new last-syncAddressee "); | 2276 | qDebug("Creating new last-syncAddressee "); |
2316 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2277 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2317 | QString sum = ""; | 2278 | QString sum = ""; |
2318 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2279 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2319 | sum = "E: "; | 2280 | sum = "E: "; |
2320 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2281 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2321 | lse.setRevision( mLastAddressbookSync ); | 2282 | lse.setRevision( mLastAddressbookSync ); |
2322 | lse.setCategories( i18n("SyncEvent") ); | 2283 | lse.setCategories( i18n("SyncEvent") ); |
2323 | mAddressBook->insertAddressee( lse ); | 2284 | mAddressBook->insertAddressee( lse ); |
2324 | } | 2285 | } |
2325 | return lse; | 2286 | return lse; |
2326 | } | 2287 | } |
2327 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2288 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2328 | { | 2289 | { |
2329 | 2290 | ||
2330 | //void setZaurusId(int id); | 2291 | //void setZaurusId(int id); |
2331 | // int zaurusId() const; | 2292 | // int zaurusId() const; |
2332 | // void setZaurusUid(int id); | 2293 | // void setZaurusUid(int id); |
2333 | // int zaurusUid() const; | 2294 | // int zaurusUid() const; |
2334 | // void setZaurusStat(int id); | 2295 | // void setZaurusStat(int id); |
2335 | // int zaurusStat() const; | 2296 | // int zaurusStat() const; |
2336 | // 0 equal | 2297 | // 0 equal |
2337 | // 1 take local | 2298 | // 1 take local |
2338 | // 2 take remote | 2299 | // 2 take remote |
2339 | // 3 cancel | 2300 | // 3 cancel |
2340 | QDateTime lastSync = mLastAddressbookSync; | 2301 | QDateTime lastSync = mLastAddressbookSync; |
2341 | QDateTime localMod = local->revision(); | 2302 | QDateTime localMod = local->revision(); |
2342 | QDateTime remoteMod = remote->revision(); | 2303 | QDateTime remoteMod = remote->revision(); |
2343 | 2304 | ||
2344 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2305 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2345 | 2306 | ||
2346 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2307 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2347 | bool remCh, locCh; | 2308 | bool remCh, locCh; |
2348 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2309 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2349 | 2310 | ||
2350 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2311 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2351 | locCh = ( localMod > mLastAddressbookSync ); | 2312 | locCh = ( localMod > mLastAddressbookSync ); |
2352 | if ( !remCh && ! locCh ) { | 2313 | if ( !remCh && ! locCh ) { |
2353 | //qDebug("both not changed "); | 2314 | //qDebug("both not changed "); |
2354 | lastSync = localMod.addDays(1); | 2315 | lastSync = localMod.addDays(1); |
2355 | if ( mode <= SYNC_PREF_ASK ) | 2316 | if ( mode <= SYNC_PREF_ASK ) |
2356 | return 0; | 2317 | return 0; |
2357 | } else { | 2318 | } else { |
2358 | if ( locCh ) { | 2319 | if ( locCh ) { |
2359 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2320 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2360 | lastSync = localMod.addDays( -1 ); | 2321 | lastSync = localMod.addDays( -1 ); |
2361 | if ( !remCh ) | 2322 | if ( !remCh ) |
2362 | remoteMod =( lastSync.addDays( -1 ) ); | 2323 | remoteMod =( lastSync.addDays( -1 ) ); |
2363 | } else { | 2324 | } else { |
2364 | //qDebug(" not loc changed "); | 2325 | //qDebug(" not loc changed "); |
2365 | lastSync = localMod.addDays( 1 ); | 2326 | lastSync = localMod.addDays( 1 ); |
2366 | if ( remCh ) | 2327 | if ( remCh ) |
2367 | remoteMod =( lastSync.addDays( 1 ) ); | 2328 | remoteMod =( lastSync.addDays( 1 ) ); |
2368 | 2329 | ||
2369 | } | 2330 | } |
2370 | } | 2331 | } |
2371 | full = true; | 2332 | full = true; |
2372 | if ( mode < SYNC_PREF_ASK ) | 2333 | if ( mode < SYNC_PREF_ASK ) |
2373 | mode = SYNC_PREF_ASK; | 2334 | mode = SYNC_PREF_ASK; |
2374 | } else { | 2335 | } else { |
2375 | if ( localMod == remoteMod ) | 2336 | if ( localMod == remoteMod ) |
2376 | return 0; | 2337 | return 0; |
2377 | 2338 | ||
2378 | } | 2339 | } |
2379 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2340 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2380 | 2341 | ||
2381 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2342 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2382 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2343 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2383 | //full = true; //debug only | 2344 | //full = true; //debug only |
2384 | if ( full ) { | 2345 | if ( full ) { |
2385 | bool equ = ( (*local) == (*remote) ); | 2346 | bool equ = ( (*local) == (*remote) ); |
2386 | if ( equ ) { | 2347 | if ( equ ) { |
2387 | //qDebug("equal "); | 2348 | //qDebug("equal "); |
2388 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2349 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2389 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2350 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2390 | } | 2351 | } |
2391 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2352 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2392 | return 0; | 2353 | return 0; |
2393 | 2354 | ||
2394 | }//else //debug only | 2355 | }//else //debug only |
2395 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2356 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2396 | } | 2357 | } |
2397 | int result; | 2358 | int result; |
2398 | bool localIsNew; | 2359 | bool localIsNew; |
2399 | //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() ); | 2360 | //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() ); |
2400 | 2361 | ||
2401 | if ( full && mode < SYNC_PREF_NEWEST ) | 2362 | if ( full && mode < SYNC_PREF_NEWEST ) |
2402 | mode = SYNC_PREF_ASK; | 2363 | mode = SYNC_PREF_ASK; |
2403 | 2364 | ||
2404 | switch( mode ) { | 2365 | switch( mode ) { |
2405 | case SYNC_PREF_LOCAL: | 2366 | case SYNC_PREF_LOCAL: |
2406 | if ( lastSync > remoteMod ) | 2367 | if ( lastSync > remoteMod ) |
2407 | return 1; | 2368 | return 1; |
2408 | if ( lastSync > localMod ) | 2369 | if ( lastSync > localMod ) |
2409 | return 2; | 2370 | return 2; |
2410 | return 1; | 2371 | return 1; |
2411 | break; | 2372 | break; |
2412 | case SYNC_PREF_REMOTE: | 2373 | case SYNC_PREF_REMOTE: |
2413 | if ( lastSync > remoteMod ) | 2374 | if ( lastSync > remoteMod ) |
2414 | return 1; | 2375 | return 1; |
2415 | if ( lastSync > localMod ) | 2376 | if ( lastSync > localMod ) |
2416 | return 2; | 2377 | return 2; |
2417 | return 2; | 2378 | return 2; |
2418 | break; | 2379 | break; |
2419 | case SYNC_PREF_NEWEST: | 2380 | case SYNC_PREF_NEWEST: |
2420 | if ( localMod > remoteMod ) | 2381 | if ( localMod > remoteMod ) |
2421 | return 1; | 2382 | return 1; |
2422 | else | 2383 | else |
2423 | return 2; | 2384 | return 2; |
2424 | break; | 2385 | break; |
2425 | case SYNC_PREF_ASK: | 2386 | case SYNC_PREF_ASK: |
2426 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2387 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2427 | if ( lastSync > remoteMod ) | 2388 | if ( lastSync > remoteMod ) |
2428 | return 1; | 2389 | return 1; |
2429 | if ( lastSync > localMod ) | 2390 | if ( lastSync > localMod ) |
2430 | return 2; | 2391 | return 2; |
2431 | localIsNew = localMod >= remoteMod; | 2392 | localIsNew = localMod >= remoteMod; |
2432 | //qDebug("conflict! ************************************** "); | 2393 | //qDebug("conflict! ************************************** "); |
2433 | { | 2394 | { |
2434 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2395 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2435 | result = acd.executeD(localIsNew); | 2396 | result = acd.executeD(localIsNew); |
2436 | return result; | 2397 | return result; |
2437 | } | 2398 | } |
2438 | break; | 2399 | break; |
2439 | case SYNC_PREF_FORCE_LOCAL: | 2400 | case SYNC_PREF_FORCE_LOCAL: |
2440 | return 1; | 2401 | return 1; |
2441 | break; | 2402 | break; |
2442 | case SYNC_PREF_FORCE_REMOTE: | 2403 | case SYNC_PREF_FORCE_REMOTE: |
2443 | return 2; | 2404 | return 2; |
2444 | break; | 2405 | break; |
2445 | 2406 | ||
2446 | default: | 2407 | default: |
2447 | // SYNC_PREF_TAKE_BOTH not implemented | 2408 | // SYNC_PREF_TAKE_BOTH not implemented |
2448 | break; | 2409 | break; |
2449 | } | 2410 | } |
2450 | return 0; | 2411 | return 0; |
2451 | } | 2412 | } |
2452 | 2413 | ||
2453 | 2414 | ||
2454 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2415 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2455 | { | 2416 | { |
2456 | bool syncOK = true; | 2417 | bool syncOK = true; |
2457 | int addedAddressee = 0; | 2418 | int addedAddressee = 0; |
2458 | int addedAddresseeR = 0; | 2419 | int addedAddresseeR = 0; |
2459 | int deletedAddresseeR = 0; | 2420 | int deletedAddresseeR = 0; |
2460 | int deletedAddresseeL = 0; | 2421 | int deletedAddresseeL = 0; |
2461 | int changedLocal = 0; | 2422 | int changedLocal = 0; |
2462 | int changedRemote = 0; | 2423 | int changedRemote = 0; |
2463 | 2424 | ||
2464 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2425 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2465 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2426 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2466 | 2427 | ||
2467 | //QPtrList<Addressee> el = local->rawAddressees(); | 2428 | //QPtrList<Addressee> el = local->rawAddressees(); |
2468 | Addressee addresseeR; | 2429 | Addressee addresseeR; |
2469 | QString uid; | 2430 | QString uid; |
2470 | int take; | 2431 | int take; |
2471 | Addressee addresseeL; | 2432 | Addressee addresseeL; |
2472 | Addressee addresseeRSync; | 2433 | Addressee addresseeRSync; |
2473 | Addressee addresseeLSync; | 2434 | Addressee addresseeLSync; |
2474 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2435 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2475 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2436 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2476 | bool fullDateRange = false; | 2437 | bool fullDateRange = false; |
2477 | local->resetTempSyncStat(); | 2438 | local->resetTempSyncStat(); |
2478 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2439 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2479 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2440 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2480 | addresseeLSync = getLastSyncAddressee(); | 2441 | addresseeLSync = getLastSyncAddressee(); |
2481 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2442 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2482 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2443 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2483 | if ( !addresseeR.isEmpty() ) { | 2444 | if ( !addresseeR.isEmpty() ) { |
2484 | addresseeRSync = addresseeR; | 2445 | addresseeRSync = addresseeR; |
2485 | remote->removeAddressee(addresseeR ); | 2446 | remote->removeAddressee(addresseeR ); |
2486 | 2447 | ||
2487 | } else { | 2448 | } else { |
2488 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2449 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2489 | addresseeRSync = addresseeLSync ; | 2450 | addresseeRSync = addresseeLSync ; |
2490 | } else { | 2451 | } else { |
2491 | qDebug("FULLDATE 1"); | 2452 | qDebug("FULLDATE 1"); |
2492 | fullDateRange = true; | 2453 | fullDateRange = true; |
2493 | Addressee newAdd; | 2454 | Addressee newAdd; |
2494 | addresseeRSync = newAdd; | 2455 | addresseeRSync = newAdd; |
2495 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2456 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2496 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2457 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2497 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2458 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2498 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2459 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2499 | } | 2460 | } |
2500 | } | 2461 | } |
2501 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2462 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2502 | qDebug("FULLDATE 2"); | 2463 | qDebug("FULLDATE 2"); |
2503 | fullDateRange = true; | 2464 | fullDateRange = true; |
2504 | } | 2465 | } |
2505 | if ( ! fullDateRange ) { | 2466 | if ( ! fullDateRange ) { |
2506 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2467 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2507 | 2468 | ||
2508 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2469 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2509 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2470 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2510 | fullDateRange = true; | 2471 | fullDateRange = true; |
2511 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2472 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2512 | } | 2473 | } |
2513 | } | 2474 | } |
2514 | // fullDateRange = true; // debug only! | 2475 | // fullDateRange = true; // debug only! |
2515 | if ( fullDateRange ) | 2476 | if ( fullDateRange ) |
2516 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2477 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2517 | else | 2478 | else |
2518 | mLastAddressbookSync = addresseeLSync.revision(); | 2479 | mLastAddressbookSync = addresseeLSync.revision(); |
2519 | // for resyncing if own file has changed | 2480 | // for resyncing if own file has changed |
2520 | // PENDING fixme later when implemented | 2481 | // PENDING fixme later when implemented |
2521 | #if 0 | 2482 | #if 0 |
2522 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2483 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2523 | mLastAddressbookSync = loadedFileVersion; | 2484 | mLastAddressbookSync = loadedFileVersion; |
2524 | qDebug("setting mLastAddressbookSync "); | 2485 | qDebug("setting mLastAddressbookSync "); |
2525 | } | 2486 | } |
2526 | #endif | 2487 | #endif |
2527 | 2488 | ||
2528 | //qDebug("*************************** "); | 2489 | //qDebug("*************************** "); |
2529 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2490 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2530 | QStringList er = remote->uidList(); | 2491 | QStringList er = remote->uidList(); |
2531 | Addressee inR ;//= er.first(); | 2492 | Addressee inR ;//= er.first(); |
2532 | Addressee inL; | 2493 | Addressee inL; |
2533 | 2494 | ||
2534 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2495 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2535 | 2496 | ||
2536 | int modulo = (er.count()/10)+1; | 2497 | int modulo = (er.count()/10)+1; |
2537 | int incCounter = 0; | 2498 | int incCounter = 0; |
2538 | while ( incCounter < er.count()) { | 2499 | while ( incCounter < er.count()) { |
2539 | if (syncManager->isProgressBarCanceled()) | 2500 | if (syncManager->isProgressBarCanceled()) |
2540 | return false; | 2501 | return false; |
2541 | if ( incCounter % modulo == 0 ) | 2502 | if ( incCounter % modulo == 0 ) |
2542 | syncManager->showProgressBar(incCounter); | 2503 | syncManager->showProgressBar(incCounter); |
2543 | 2504 | ||
2544 | uid = er[ incCounter ]; | 2505 | uid = er[ incCounter ]; |
2545 | bool skipIncidence = false; | 2506 | bool skipIncidence = false; |
2546 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2507 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2547 | skipIncidence = true; | 2508 | skipIncidence = true; |
2548 | QString idS,OidS; | 2509 | QString idS,OidS; |
2549 | qApp->processEvents(); | 2510 | qApp->processEvents(); |
2550 | if ( !skipIncidence ) { | 2511 | if ( !skipIncidence ) { |
2551 | inL = local->findByUid( uid ); | 2512 | inL = local->findByUid( uid ); |
2552 | inR = remote->findByUid( uid ); | 2513 | inR = remote->findByUid( uid ); |
2553 | //inL.setResource( 0 ); | 2514 | //inL.setResource( 0 ); |
2554 | //inR.setResource( 0 ); | 2515 | //inR.setResource( 0 ); |
2555 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2516 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2556 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2517 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2557 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2518 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2558 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2519 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2559 | if ( take == 3 ) | 2520 | if ( take == 3 ) |
2560 | return false; | 2521 | return false; |
2561 | if ( take == 1 ) {// take local | 2522 | if ( take == 1 ) {// take local |
2562 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2523 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2563 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2524 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2564 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2525 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2565 | local->insertAddressee( inL, false ); | 2526 | local->insertAddressee( inL, false ); |
2566 | idS = inR.externalUID(); | 2527 | idS = inR.externalUID(); |
2567 | OidS = inR.originalExternalUID(); | 2528 | OidS = inR.originalExternalUID(); |
2568 | } | 2529 | } |
2569 | else | 2530 | else |
2570 | idS = inR.IDStr(); | 2531 | idS = inR.IDStr(); |
2571 | remote->removeAddressee( inR ); | 2532 | remote->removeAddressee( inR ); |
2572 | inR = inL; | 2533 | inR = inL; |
2573 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2534 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2574 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2535 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2575 | inR.setOriginalExternalUID( OidS ); | 2536 | inR.setOriginalExternalUID( OidS ); |
2576 | inR.setExternalUID( idS ); | 2537 | inR.setExternalUID( idS ); |
2577 | } else { | 2538 | } else { |
2578 | inR.setIDStr( idS ); | 2539 | inR.setIDStr( idS ); |
2579 | } | 2540 | } |
2580 | inR.setResource( 0 ); | 2541 | inR.setResource( 0 ); |
2581 | remote->insertAddressee( inR , false); | 2542 | remote->insertAddressee( inR , false); |
2582 | ++changedRemote; | 2543 | ++changedRemote; |
2583 | } else { // take == 2 take remote | 2544 | } else { // take == 2 take remote |
2584 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2545 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2585 | if ( inR.revision().date().year() < 2004 ) | 2546 | if ( inR.revision().date().year() < 2004 ) |
2586 | inR.setRevision( modifiedCalendar ); | 2547 | inR.setRevision( modifiedCalendar ); |
2587 | } | 2548 | } |
2588 | idS = inL.IDStr(); | 2549 | idS = inL.IDStr(); |
2589 | local->removeAddressee( inL ); | 2550 | local->removeAddressee( inL ); |
2590 | inL = inR; | 2551 | inL = inR; |
2591 | inL.setIDStr( idS ); | 2552 | inL.setIDStr( idS ); |
2592 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2553 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2593 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2554 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2594 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2555 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2595 | } | 2556 | } |
2596 | inL.setResource( 0 ); | 2557 | inL.setResource( 0 ); |
2597 | local->insertAddressee( inL , false ); | 2558 | local->insertAddressee( inL , false ); |
2598 | ++changedLocal; | 2559 | ++changedLocal; |
2599 | } | 2560 | } |
2600 | } | 2561 | } |
2601 | } | 2562 | } |
2602 | } else { // no conflict | 2563 | } else { // no conflict |
2603 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2564 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2604 | QString des = addresseeLSync.note(); | 2565 | QString des = addresseeLSync.note(); |
2605 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2566 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2606 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2567 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2607 | remote->insertAddressee( inR, false ); | 2568 | remote->insertAddressee( inR, false ); |
2608 | ++deletedAddresseeR; | 2569 | ++deletedAddresseeR; |
2609 | } else { | 2570 | } else { |
2610 | inR.setRevision( modifiedCalendar ); | 2571 | inR.setRevision( modifiedCalendar ); |
2611 | remote->insertAddressee( inR, false ); | 2572 | remote->insertAddressee( inR, false ); |
2612 | inL = inR; | 2573 | inL = inR; |
2613 | inL.setResource( 0 ); | 2574 | inL.setResource( 0 ); |
2614 | local->insertAddressee( inL , false); | 2575 | local->insertAddressee( inL , false); |
2615 | ++addedAddressee; | 2576 | ++addedAddressee; |
2616 | } | 2577 | } |
2617 | } else { | 2578 | } else { |
2618 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2579 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2619 | inR.setRevision( modifiedCalendar ); | 2580 | inR.setRevision( modifiedCalendar ); |
2620 | remote->insertAddressee( inR, false ); | 2581 | remote->insertAddressee( inR, false ); |
2621 | inR.setResource( 0 ); | 2582 | inR.setResource( 0 ); |
2622 | local->insertAddressee( inR, false ); | 2583 | local->insertAddressee( inR, false ); |
2623 | ++addedAddressee; | 2584 | ++addedAddressee; |
2624 | } else { | 2585 | } else { |
2625 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2586 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2626 | remote->removeAddressee( inR ); | 2587 | remote->removeAddressee( inR ); |
2627 | ++deletedAddresseeR; | 2588 | ++deletedAddresseeR; |
2628 | } | 2589 | } |
2629 | } | 2590 | } |
2630 | } | 2591 | } |
2631 | } | 2592 | } |
2632 | ++incCounter; | 2593 | ++incCounter; |
2633 | } | 2594 | } |
2634 | er.clear(); | 2595 | er.clear(); |
2635 | QStringList el = local->uidList(); | 2596 | QStringList el = local->uidList(); |
2636 | modulo = (el.count()/10)+1; | 2597 | modulo = (el.count()/10)+1; |
2637 | 2598 | ||
2638 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2599 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2639 | incCounter = 0; | 2600 | incCounter = 0; |
2640 | while ( incCounter < el.count()) { | 2601 | while ( incCounter < el.count()) { |
2641 | qApp->processEvents(); | 2602 | qApp->processEvents(); |
2642 | if (syncManager->isProgressBarCanceled()) | 2603 | if (syncManager->isProgressBarCanceled()) |
2643 | return false; | 2604 | return false; |
2644 | if ( incCounter % modulo == 0 ) | 2605 | if ( incCounter % modulo == 0 ) |
2645 | syncManager->showProgressBar(incCounter); | 2606 | syncManager->showProgressBar(incCounter); |
2646 | uid = el[ incCounter ]; | 2607 | uid = el[ incCounter ]; |
2647 | bool skipIncidence = false; | 2608 | bool skipIncidence = false; |
2648 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2609 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2649 | skipIncidence = true; | 2610 | skipIncidence = true; |
2650 | if ( !skipIncidence ) { | 2611 | if ( !skipIncidence ) { |
2651 | inL = local->findByUid( uid ); | 2612 | inL = local->findByUid( uid ); |
2652 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2613 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2653 | inR = remote->findByUid( uid ); | 2614 | inR = remote->findByUid( uid ); |
2654 | if ( inR.isEmpty() ) { | 2615 | if ( inR.isEmpty() ) { |
2655 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2616 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2656 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2617 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2657 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2618 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2658 | local->removeAddressee( inL ); | 2619 | local->removeAddressee( inL ); |
2659 | ++deletedAddresseeL; | 2620 | ++deletedAddresseeL; |
2660 | } else { | 2621 | } else { |
2661 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2622 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2662 | inL.removeID(mCurrentSyncDevice ); | 2623 | inL.removeID(mCurrentSyncDevice ); |
2663 | ++addedAddresseeR; | 2624 | ++addedAddresseeR; |
2664 | inL.setRevision( modifiedCalendar ); | 2625 | inL.setRevision( modifiedCalendar ); |
2665 | local->insertAddressee( inL, false ); | 2626 | local->insertAddressee( inL, false ); |
2666 | inR = inL; | 2627 | inR = inL; |
2667 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2628 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2668 | inR.setResource( 0 ); | 2629 | inR.setResource( 0 ); |
2669 | remote->insertAddressee( inR, false ); | 2630 | remote->insertAddressee( inR, false ); |
2670 | } | 2631 | } |
2671 | } | 2632 | } |
2672 | } else { | 2633 | } else { |
2673 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2634 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2674 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2635 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2675 | local->removeAddressee( inL ); | 2636 | local->removeAddressee( inL ); |
2676 | ++deletedAddresseeL; | 2637 | ++deletedAddresseeL; |
2677 | } else { | 2638 | } else { |
2678 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2639 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2679 | ++addedAddresseeR; | 2640 | ++addedAddresseeR; |
2680 | inL.setRevision( modifiedCalendar ); | 2641 | inL.setRevision( modifiedCalendar ); |
2681 | local->insertAddressee( inL, false ); | 2642 | local->insertAddressee( inL, false ); |
2682 | inR = inL; | 2643 | inR = inL; |
2683 | inR.setResource( 0 ); | 2644 | inR.setResource( 0 ); |
2684 | remote->insertAddressee( inR, false ); | 2645 | remote->insertAddressee( inR, false ); |
2685 | } | 2646 | } |
2686 | } | 2647 | } |
2687 | } | 2648 | } |
2688 | } | 2649 | } |
2689 | } | 2650 | } |
2690 | } | 2651 | } |
2691 | ++incCounter; | 2652 | ++incCounter; |
2692 | } | 2653 | } |
2693 | el.clear(); | 2654 | el.clear(); |
2694 | syncManager->hideProgressBar(); | 2655 | syncManager->hideProgressBar(); |
2695 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2656 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2696 | // get rid of micro seconds | 2657 | // get rid of micro seconds |
2697 | QTime t = mLastAddressbookSync.time(); | 2658 | QTime t = mLastAddressbookSync.time(); |
2698 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2659 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2699 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2660 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2700 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2661 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2701 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2662 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2702 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2663 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2703 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2664 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2704 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2665 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2705 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2666 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2706 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2667 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2707 | addresseeRSync.setNote( "" ) ; | 2668 | addresseeRSync.setNote( "" ) ; |
2708 | addresseeLSync.setNote( "" ); | 2669 | addresseeLSync.setNote( "" ); |
2709 | 2670 | ||
2710 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2671 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2711 | remote->insertAddressee( addresseeRSync, false ); | 2672 | remote->insertAddressee( addresseeRSync, false ); |
2712 | local->insertAddressee( addresseeLSync, false ); | 2673 | local->insertAddressee( addresseeLSync, false ); |
2713 | QString mes; | 2674 | QString mes; |
2714 | 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 ); | 2675 | 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 ); |
2715 | if ( syncManager->mShowSyncSummary ) { | 2676 | if ( syncManager->mShowSyncSummary ) { |
2716 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2677 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2717 | } | 2678 | } |
2718 | qDebug( mes ); | 2679 | qDebug( mes ); |
2719 | return syncOK; | 2680 | return syncOK; |
2720 | } | 2681 | } |
2721 | 2682 | ||
2722 | 2683 | ||
2723 | //this is a overwritten callbackmethods from the syncinterface | 2684 | //this is a overwritten callbackmethods from the syncinterface |
2724 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2685 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2725 | { | 2686 | { |
2726 | 2687 | ||
2727 | //pending prepare addresseeview for output | 2688 | //pending prepare addresseeview for output |
2728 | //pending detect, if remote file has REV field. if not switch to external sync | 2689 | //pending detect, if remote file has REV field. if not switch to external sync |
2729 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2690 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2730 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2691 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2731 | 2692 | ||
2732 | AddressBook abLocal(filename,"syncContact"); | 2693 | AddressBook abLocal(filename,"syncContact"); |
2733 | bool syncOK = false; | 2694 | bool syncOK = false; |
2734 | if ( abLocal.load() ) { | 2695 | if ( abLocal.load() ) { |
2735 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2696 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2736 | bool external = false; | 2697 | bool external = false; |
2737 | bool isXML = false; | 2698 | bool isXML = false; |
2738 | if ( filename.right(4) == ".xml") { | 2699 | if ( filename.right(4) == ".xml") { |
2739 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2700 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2740 | isXML = true; | 2701 | isXML = true; |
2741 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2702 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2742 | } else { | 2703 | } else { |
2743 | external = !manager->mIsKapiFile; | 2704 | external = !manager->mIsKapiFile; |
2744 | if ( external ) { | 2705 | if ( external ) { |
2745 | qDebug("Setting vcf mode to external "); | 2706 | qDebug("Setting vcf mode to external "); |
2746 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2707 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2747 | AddressBook::Iterator it; | 2708 | AddressBook::Iterator it; |
2748 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2709 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2749 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2710 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2750 | (*it).computeCsum( mCurrentSyncDevice ); | 2711 | (*it).computeCsum( mCurrentSyncDevice ); |
2751 | } | 2712 | } |
2752 | } | 2713 | } |
2753 | } | 2714 | } |
2754 | //AddressBook::Iterator it; | 2715 | //AddressBook::Iterator it; |
2755 | //QStringList vcards; | 2716 | //QStringList vcards; |
2756 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2717 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2757 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2718 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2758 | //} | 2719 | //} |
2759 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2720 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2760 | if ( syncOK ) { | 2721 | if ( syncOK ) { |
2761 | if ( syncManager->mWriteBackFile ) | 2722 | if ( syncManager->mWriteBackFile ) |
2762 | { | 2723 | { |
2763 | if ( external ) | 2724 | if ( external ) |
2764 | abLocal.removeSyncAddressees( !isXML); | 2725 | abLocal.removeSyncAddressees( !isXML); |
2765 | qDebug("Saving remote AB "); | 2726 | qDebug("Saving remote AB "); |
2766 | if ( ! abLocal.saveAB()) | 2727 | if ( ! abLocal.saveAB()) |
2767 | qDebug("Error writing back AB to file "); | 2728 | qDebug("Error writing back AB to file "); |
2768 | if ( isXML ) { | 2729 | if ( isXML ) { |
2769 | // afterwrite processing | 2730 | // afterwrite processing |
2770 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2731 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2771 | } | 2732 | } |
2772 | } | 2733 | } |
2773 | } | 2734 | } |
2774 | setModified(); | 2735 | setModified(); |
2775 | 2736 | ||
2776 | } | 2737 | } |
2777 | if ( syncOK ) | 2738 | if ( syncOK ) |
2778 | mViewManager->refreshView(); | 2739 | mViewManager->refreshView(); |
2779 | return syncOK; | 2740 | return syncOK; |
2780 | 2741 | ||
2781 | } | 2742 | } |
2782 | 2743 | ||
2783 | 2744 | ||
2784 | //this is a overwritten callbackmethods from the syncinterface | 2745 | //this is a overwritten callbackmethods from the syncinterface |
2785 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2746 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2786 | { | 2747 | { |
2787 | if ( resource == "phone" ) | 2748 | if ( resource == "phone" ) |
2788 | return syncPhone(); | 2749 | return syncPhone(); |
2789 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2750 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2790 | 2751 | ||
2791 | AddressBook abLocal( resource,"syncContact"); | 2752 | AddressBook abLocal( resource,"syncContact"); |
2792 | bool syncOK = false; | 2753 | bool syncOK = false; |
2793 | if ( abLocal.load() ) { | 2754 | if ( abLocal.load() ) { |
2794 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2755 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2795 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2756 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2796 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2757 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2797 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2758 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2798 | if ( syncOK ) { | 2759 | if ( syncOK ) { |
2799 | if ( syncManager->mWriteBackFile ) { | 2760 | if ( syncManager->mWriteBackFile ) { |
2800 | abLocal.removeSyncAddressees( false ); | 2761 | abLocal.removeSyncAddressees( false ); |
2801 | abLocal.saveAB(); | 2762 | abLocal.saveAB(); |
2802 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2763 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2803 | } | 2764 | } |
2804 | } | 2765 | } |
2805 | setModified(); | 2766 | setModified(); |
2806 | } | 2767 | } |
2807 | if ( syncOK ) | 2768 | if ( syncOK ) |
2808 | mViewManager->refreshView(); | 2769 | mViewManager->refreshView(); |
2809 | return syncOK; | 2770 | return syncOK; |
2810 | 2771 | ||
2811 | } | 2772 | } |
2812 | void KABCore::message( QString m ) | 2773 | void KABCore::message( QString m ) |
2813 | { | 2774 | { |
2814 | topLevelWidget()->setCaption( m ); | 2775 | topLevelWidget()->setCaption( m ); |
2815 | mMessageTimer->start( 15000, true ); | 2776 | mMessageTimer->start( 15000, true ); |
2816 | } | 2777 | } |
2817 | bool KABCore::syncPhone() | 2778 | bool KABCore::syncPhone() |
2818 | { | 2779 | { |
2819 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2780 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2820 | QString fileName = getPhoneFile(); | 2781 | QString fileName = getPhoneFile(); |
2821 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2782 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2822 | message(i18n("Phone access failed!")); | 2783 | message(i18n("Phone access failed!")); |
2823 | return false; | 2784 | return false; |
2824 | } | 2785 | } |
2825 | AddressBook abLocal( fileName,"syncContact"); | 2786 | AddressBook abLocal( fileName,"syncContact"); |
2826 | bool syncOK = false; | 2787 | bool syncOK = false; |
2827 | { | 2788 | { |
2828 | abLocal.importFromFile( fileName ); | 2789 | abLocal.importFromFile( fileName ); |
2829 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2790 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2830 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2791 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2831 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2792 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2832 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2793 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2833 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2794 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2834 | if ( syncOK ) { | 2795 | if ( syncOK ) { |
2835 | if ( syncManager->mWriteBackFile ) { | 2796 | if ( syncManager->mWriteBackFile ) { |
2836 | abLocal.removeSyncAddressees( true ); | 2797 | abLocal.removeSyncAddressees( true ); |
2837 | abLocal.saveABphone( fileName ); | 2798 | abLocal.saveABphone( fileName ); |
2838 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2799 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2839 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2800 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2840 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2801 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2841 | } | 2802 | } |
2842 | } | 2803 | } |
2843 | setModified(); | 2804 | setModified(); |
2844 | } | 2805 | } |
2845 | if ( syncOK ) | 2806 | if ( syncOK ) |
2846 | mViewManager->refreshView(); | 2807 | mViewManager->refreshView(); |
2847 | return syncOK; | 2808 | return syncOK; |
2848 | } | 2809 | } |
2849 | void KABCore::getFile( bool success ) | 2810 | void KABCore::getFile( bool success ) |
2850 | { | 2811 | { |
2851 | if ( ! success ) { | 2812 | if ( ! success ) { |
2852 | message( i18n("Error receiving file. Nothing changed!") ); | 2813 | message( i18n("Error receiving file. Nothing changed!") ); |
2853 | return; | 2814 | return; |
2854 | } | 2815 | } |
2855 | mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2816 | mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2856 | message( i18n("Pi-Sync successful!") ); | 2817 | message( i18n("Pi-Sync successful!") ); |
2857 | mViewManager->refreshView(); | 2818 | mViewManager->refreshView(); |
2858 | } | 2819 | } |
2859 | void KABCore::syncFileRequest() | 2820 | void KABCore::syncFileRequest() |
2860 | { | 2821 | { |
2861 | mAddressBook->export2File( sentSyncFile() ); | 2822 | mAddressBook->export2File( sentSyncFile() ); |
2862 | } | 2823 | } |
2863 | QString KABCore::sentSyncFile() | 2824 | QString KABCore::sentSyncFile() |
2864 | { | 2825 | { |
2865 | #ifdef _WIN32_ | 2826 | #ifdef DESKTOP_VERSION |
2866 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2827 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2867 | #else | 2828 | #else |
2868 | return QString( "/tmp/copysyncab.vcf" ); | 2829 | return QString( "/tmp/copysyncab.vcf" ); |
2869 | #endif | 2830 | #endif |
2870 | } | 2831 | } |
2871 | 2832 | ||
2872 | void KABCore::setCaptionBack() | 2833 | void KABCore::setCaptionBack() |
2873 | { | 2834 | { |
2874 | mMessageTimer->stop(); | 2835 | mMessageTimer->stop(); |
2875 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2836 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2876 | } | 2837 | } |
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 6e560d7..32a3b7c 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp | |||
@@ -1,527 +1,531 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | #include "composemail.h" | 2 | #include "composemail.h" |
3 | #include "viewmail.h" | 3 | #include "viewmail.h" |
4 | 4 | ||
5 | #include <libmailwrapper/settings.h> | 5 | #include <libmailwrapper/settings.h> |
6 | #include <libmailwrapper/abstractmail.h> | 6 | #include <libmailwrapper/abstractmail.h> |
7 | #include <libmailwrapper/mailtypes.h> | 7 | #include <libmailwrapper/mailtypes.h> |
8 | #include <kapplication.h> | 8 | #include <kapplication.h> |
9 | 9 | ||
10 | /* OPIE */ | 10 | /* OPIE */ |
11 | //#include <opie2/odebug.h> | 11 | //#include <opie2/odebug.h> |
12 | //#include <opie2/ofiledialog.h> | 12 | //#include <opie2/ofiledialog.h> |
13 | //#include <opie2/oimagescrollview.h> | 13 | //#include <opie2/oimagescrollview.h> |
14 | 14 | ||
15 | #include <kfiledialog.h> | 15 | #include <kfiledialog.h> |
16 | #include <kdialog.h> | 16 | #include <kdialog.h> |
17 | 17 | ||
18 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
19 | 19 | ||
20 | /* QT */ | 20 | /* QT */ |
21 | #include <qtextbrowser.h> | 21 | #include <qtextbrowser.h> |
22 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
23 | #include <qtextstream.h> | 23 | #include <qtextstream.h> |
24 | #include <qaction.h> | 24 | #include <qaction.h> |
25 | #include <qpopupmenu.h> | 25 | #include <qpopupmenu.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include "koprefs.h" | 28 | #include "koprefs.h" |
29 | 29 | ||
30 | //using namespace Opie::Ui; | 30 | //using namespace Opie::Ui; |
31 | //using namespace Opie::Core; | 31 | //using namespace Opie::Core; |
32 | 32 | ||
33 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 33 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
34 | const QString&fsize,int num,const QValueList<int>&path) | 34 | const QString&fsize,int num,const QValueList<int>&path) |
35 | : QListViewItem(parent,after),_partNum(num) | 35 | : QListViewItem(parent,after),_partNum(num) |
36 | { | 36 | { |
37 | _path=path; | 37 | _path=path; |
38 | setText(0, mime); | 38 | setText(0, mime); |
39 | setText(1, desc); | 39 | setText(1, desc); |
40 | setText(2, file); | 40 | setText(2, file); |
41 | setText(3, fsize); | 41 | setText(3, fsize); |
42 | } | 42 | } |
43 | 43 | ||
44 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 44 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
45 | const QString&fsize,int num,const QValueList<int>&path) | 45 | const QString&fsize,int num,const QValueList<int>&path) |
46 | : QListViewItem(parent,after),_partNum(num) | 46 | : QListViewItem(parent,after),_partNum(num) |
47 | { | 47 | { |
48 | _path=path; | 48 | _path=path; |
49 | setText(0, mime); | 49 | setText(0, mime); |
50 | setText(1, desc); | 50 | setText(1, desc); |
51 | setText(2, file); | 51 | setText(2, file); |
52 | setText(3, fsize); | 52 | setText(3, fsize); |
53 | } | 53 | } |
54 | 54 | ||
55 | bool AttachItem::isParentof(const QValueList<int>&path) | 55 | bool AttachItem::isParentof(const QValueList<int>&path) |
56 | { | 56 | { |
57 | /* if not set, then no parent */ | 57 | /* if not set, then no parent */ |
58 | if (path.count()==0||_path.count()==0) return false; | 58 | if (path.count()==0||_path.count()==0) return false; |
59 | /* the parent must have one digit less then a child */ | 59 | /* the parent must have one digit less then a child */ |
60 | if (path.count()!=_path.count()+1) return false; | 60 | if (path.count()!=_path.count()+1) return false; |
61 | for (unsigned int i=0; i < _path.count();++i) | 61 | for (unsigned int i=0; i < _path.count();++i) |
62 | { | 62 | { |
63 | if (_path[i]!=path[i]) return false; | 63 | if (_path[i]!=path[i]) return false; |
64 | } | 64 | } |
65 | return true; | 65 | return true; |
66 | } | 66 | } |
67 | 67 | ||
68 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 68 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
69 | { | 69 | { |
70 | QListViewItemIterator it( attachments ); | 70 | QListViewItemIterator it( attachments ); |
71 | for ( ; it.current(); ++it ) | 71 | for ( ; it.current(); ++it ) |
72 | { | 72 | { |
73 | AttachItem*ati = (AttachItem*)it.current(); | 73 | AttachItem*ati = (AttachItem*)it.current(); |
74 | if (ati->isParentof(path)) return ati; | 74 | if (ati->isParentof(path)) return ati; |
75 | } | 75 | } |
76 | return 0; | 76 | return 0; |
77 | } | 77 | } |
78 | 78 | ||
79 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 79 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
80 | { | 80 | { |
81 | if (!parent) return 0; | 81 | if (!parent) return 0; |
82 | AttachItem* item = (AttachItem*)parent->firstChild(); | 82 | AttachItem* item = (AttachItem*)parent->firstChild(); |
83 | if (!item) return item; | 83 | if (!item) return item; |
84 | AttachItem*temp=0; | 84 | AttachItem*temp=0; |
85 | while( (temp=(AttachItem*)item->nextSibling())) | 85 | while( (temp=(AttachItem*)item->nextSibling())) |
86 | { | 86 | { |
87 | item = temp; | 87 | item = temp; |
88 | } | 88 | } |
89 | return item; | 89 | return item; |
90 | } | 90 | } |
91 | 91 | ||
92 | void ViewMail::setBody(const RecBodyP&body ) | 92 | void ViewMail::setBody(const RecBodyP&body ) |
93 | { | 93 | { |
94 | 94 | ||
95 | m_body = body; | 95 | m_body = body; |
96 | m_mail[2] = body->Bodytext(); | 96 | m_mail[2] = body->Bodytext(); |
97 | attachbutton->setEnabled(body->Parts().count()>0); | 97 | attachbutton->setEnabled(body->Parts().count()>0); |
98 | attachments->setEnabled(body->Parts().count()>0); | 98 | attachments->setEnabled(body->Parts().count()>0); |
99 | if (body->Parts().count()==0) | 99 | if (body->Parts().count()==0) |
100 | { | 100 | { |
101 | return; | 101 | return; |
102 | } | 102 | } |
103 | AttachItem * curItem=0; | 103 | AttachItem * curItem=0; |
104 | AttachItem * parentItem = 0; | 104 | AttachItem * parentItem = 0; |
105 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); | 105 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); |
106 | QString desc,fsize; | 106 | QString desc,fsize; |
107 | double s = body->Description()->Size(); | 107 | double s = body->Description()->Size(); |
108 | int w; | 108 | int w; |
109 | w=0; | 109 | w=0; |
110 | 110 | ||
111 | while (s>1024) | 111 | while (s>1024) |
112 | { | 112 | { |
113 | s/=1024; | 113 | s/=1024; |
114 | ++w; | 114 | ++w; |
115 | if (w>=2) break; | 115 | if (w>=2) break; |
116 | } | 116 | } |
117 | 117 | ||
118 | QString q=""; | 118 | QString q=""; |
119 | switch(w) | 119 | switch(w) |
120 | { | 120 | { |
121 | case 1: | 121 | case 1: |
122 | q="k"; | 122 | q="k"; |
123 | break; | 123 | break; |
124 | case 2: | 124 | case 2: |
125 | q="M"; | 125 | q="M"; |
126 | break; | 126 | break; |
127 | default: | 127 | default: |
128 | break; | 128 | break; |
129 | } | 129 | } |
130 | 130 | ||
131 | { | 131 | { |
132 | /* I did not found a method to make a CONTENT reset on a QTextStream | 132 | /* I did not found a method to make a CONTENT reset on a QTextStream |
133 | so I use this construct that the stream will re-constructed in each | 133 | so I use this construct that the stream will re-constructed in each |
134 | loop. To let it work, the textstream is packed into a own area of | 134 | loop. To let it work, the textstream is packed into a own area of |
135 | code is it will be destructed after finishing its small job. | 135 | code is it will be destructed after finishing its small job. |
136 | */ | 136 | */ |
137 | QTextOStream o(&fsize); | 137 | QTextOStream o(&fsize); |
138 | if (w>0) o.precision(2); else o.precision(0); | 138 | if (w>0) o.precision(2); else o.precision(0); |
139 | o.setf(QTextStream::fixed); | 139 | o.setf(QTextStream::fixed); |
140 | o << s << " " << q << "Byte"; | 140 | o << s << " " << q << "Byte"; |
141 | } | 141 | } |
142 | 142 | ||
143 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); | 143 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); |
144 | QString filename = ""; | 144 | QString filename = ""; |
145 | 145 | ||
146 | for (unsigned int i = 0; i < body->Parts().count();++i) | 146 | for (unsigned int i = 0; i < body->Parts().count();++i) |
147 | { | 147 | { |
148 | filename = ""; | 148 | filename = ""; |
149 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); | 149 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); |
150 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); | 150 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); |
151 | for (;it!=body->Parts()[i]->Parameters().end();++it) | 151 | for (;it!=body->Parts()[i]->Parameters().end();++it) |
152 | { | 152 | { |
153 | if (it.key().lower()=="name") | 153 | if (it.key().lower()=="name") |
154 | { | 154 | { |
155 | filename=it.data(); | 155 | filename=it.data(); |
156 | } | 156 | } |
157 | } | 157 | } |
158 | s = body->Parts()[i]->Size(); | 158 | s = body->Parts()[i]->Size(); |
159 | w = 0; | 159 | w = 0; |
160 | while (s>1024) | 160 | while (s>1024) |
161 | { | 161 | { |
162 | s/=1024; | 162 | s/=1024; |
163 | ++w; | 163 | ++w; |
164 | if (w>=2) break; | 164 | if (w>=2) break; |
165 | } | 165 | } |
166 | switch(w) | 166 | switch(w) |
167 | { | 167 | { |
168 | case 1: | 168 | case 1: |
169 | q="k"; | 169 | q="k"; |
170 | break; | 170 | break; |
171 | case 2: | 171 | case 2: |
172 | q="M"; | 172 | q="M"; |
173 | break; | 173 | break; |
174 | default: | 174 | default: |
175 | q=""; | 175 | q=""; |
176 | break; | 176 | break; |
177 | } | 177 | } |
178 | QTextOStream o(&fsize); | 178 | QTextOStream o(&fsize); |
179 | if (w>0) o.precision(2); else o.precision(0); | 179 | if (w>0) o.precision(2); else o.precision(0); |
180 | o.setf(QTextStream::fixed); | 180 | o.setf(QTextStream::fixed); |
181 | o << s << " " << q << "Byte"; | 181 | o << s << " " << q << "Byte"; |
182 | desc = body->Parts()[i]->Description(); | 182 | desc = body->Parts()[i]->Description(); |
183 | parentItem = searchParent(body->Parts()[i]->Positionlist()); | 183 | parentItem = searchParent(body->Parts()[i]->Positionlist()); |
184 | if (parentItem) | 184 | if (parentItem) |
185 | { | 185 | { |
186 | AttachItem*temp = lastChild(parentItem); | 186 | AttachItem*temp = lastChild(parentItem); |
187 | if (temp) curItem = temp; | 187 | if (temp) curItem = temp; |
188 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 188 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
189 | attachments->setRootIsDecorated(true); | 189 | attachments->setRootIsDecorated(true); |
190 | curItem = parentItem; | 190 | curItem = parentItem; |
191 | } | 191 | } |
192 | else | 192 | else |
193 | { | 193 | { |
194 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 194 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | 199 | ||
200 | void ViewMail::slotShowHtml( bool state ) | 200 | void ViewMail::slotShowHtml( bool state ) |
201 | { | 201 | { |
202 | m_showHtml = state; | 202 | m_showHtml = state; |
203 | setText(); | 203 | setText(); |
204 | } | 204 | } |
205 | 205 | ||
206 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 206 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
207 | { | 207 | { |
208 | if (!item ) | 208 | if (!item ) |
209 | return; | 209 | return; |
210 | 210 | ||
211 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 211 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
212 | { | 212 | { |
213 | setText(); | 213 | setText(); |
214 | return; | 214 | return; |
215 | } | 215 | } |
216 | QPopupMenu *menu = new QPopupMenu(); | 216 | QPopupMenu *menu = new QPopupMenu(); |
217 | int ret=0; | 217 | int ret=0; |
218 | 218 | ||
219 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 219 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
220 | { | 220 | { |
221 | menu->insertItem( tr( "Show Text" ), 1 ); | 221 | menu->insertItem( tr( "Show Text" ), 1 ); |
222 | } | 222 | } |
223 | if (item->text(0).left(6)=="image/") { | 223 | if (item->text(0).left(6)=="image/") { |
224 | menu->insertItem(tr("Display image preview"),2); | 224 | menu->insertItem(tr("Display image preview"),2); |
225 | } | 225 | } |
226 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 226 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
227 | menu->insertSeparator(1); | 227 | menu->insertSeparator(1); |
228 | 228 | ||
229 | ret = menu->exec( point, 0 ); | 229 | ret = menu->exec( point, 0 ); |
230 | 230 | ||
231 | switch(ret) | 231 | switch(ret) |
232 | { | 232 | { |
233 | case 0: | 233 | case 0: |
234 | { | 234 | { |
235 | //MimeTypes types; | 235 | //MimeTypes types; |
236 | //types.insert( "all", "*" ); | 236 | //types.insert( "all", "*" ); |
237 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); | 237 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); |
238 | 238 | ||
239 | if( !str.isEmpty() ) | 239 | if( !str.isEmpty() ) |
240 | { | 240 | { |
241 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 241 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
242 | if (content) | 242 | if (content) |
243 | { | 243 | { |
244 | QFile output(str); | 244 | QFile output(str); |
245 | output.open(IO_WriteOnly); | 245 | output.open(IO_WriteOnly); |
246 | output.writeBlock(content->Content(),content->Length()); | 246 | output.writeBlock(content->Content(),content->Length()); |
247 | output.close(); | 247 | output.close(); |
248 | delete content; | 248 | delete content; |
249 | } | 249 | } |
250 | } | 250 | } |
251 | } | 251 | } |
252 | break ; | 252 | break ; |
253 | 253 | ||
254 | case 2: | 254 | case 2: |
255 | { | 255 | { |
256 | #ifdef DESKTOP_VERSION | ||
257 | QString tmpfile = locateLocal( "tmp", "opiemail-image"); | ||
258 | #else | ||
256 | QString tmpfile = "/tmp/opiemail-image"; | 259 | QString tmpfile = "/tmp/opiemail-image"; |
260 | #endif | ||
257 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 261 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
258 | if (content) { | 262 | if (content) { |
259 | QFile output(tmpfile); | 263 | QFile output(tmpfile); |
260 | output.open(IO_WriteOnly); | 264 | output.open(IO_WriteOnly); |
261 | output.writeBlock(content->Content(),content->Length()); | 265 | output.writeBlock(content->Content(),content->Length()); |
262 | output.close(); | 266 | output.close(); |
263 | delete content; | 267 | delete content; |
264 | MailImageDlg iview(""); | 268 | MailImageDlg iview(""); |
265 | iview.setName(tmpfile); | 269 | iview.setName(tmpfile); |
266 | KApplication::execDialog(&iview); | 270 | KApplication::execDialog(&iview); |
267 | output.remove(); | 271 | output.remove(); |
268 | } | 272 | } |
269 | } | 273 | } |
270 | break; | 274 | break; |
271 | case 1: | 275 | case 1: |
272 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 276 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
273 | { | 277 | { |
274 | setText(); | 278 | setText(); |
275 | } | 279 | } |
276 | else | 280 | else |
277 | { | 281 | { |
278 | if ( m_recMail->Wrapper() != 0l ) | 282 | if ( m_recMail->Wrapper() != 0l ) |
279 | { // make sure that there is a wrapper , even after delete or simular actions | 283 | { // make sure that there is a wrapper , even after delete or simular actions |
280 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 284 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
281 | } | 285 | } |
282 | } | 286 | } |
283 | break; | 287 | break; |
284 | } | 288 | } |
285 | delete menu; | 289 | delete menu; |
286 | } | 290 | } |
287 | 291 | ||
288 | 292 | ||
289 | void ViewMail::setMail(const RecMailP&mail ) | 293 | void ViewMail::setMail(const RecMailP&mail ) |
290 | { | 294 | { |
291 | 295 | ||
292 | m_recMail = mail; | 296 | m_recMail = mail; |
293 | 297 | ||
294 | m_mail[0] = mail->getFrom(); | 298 | m_mail[0] = mail->getFrom(); |
295 | m_mail[1] = mail->getSubject(); | 299 | m_mail[1] = mail->getSubject(); |
296 | m_mail[3] = mail->getDate(); | 300 | m_mail[3] = mail->getDate(); |
297 | m_mail[4] = mail->Msgid(); | 301 | m_mail[4] = mail->Msgid(); |
298 | 302 | ||
299 | m_mail2[0] = mail->To(); | 303 | m_mail2[0] = mail->To(); |
300 | m_mail2[1] = mail->CC(); | 304 | m_mail2[1] = mail->CC(); |
301 | m_mail2[2] = mail->Bcc(); | 305 | m_mail2[2] = mail->Bcc(); |
302 | 306 | ||
303 | setText(); | 307 | setText(); |
304 | } | 308 | } |
305 | 309 | ||
306 | 310 | ||
307 | 311 | ||
308 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 312 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
309 | : ViewMailBase(parent, name, fl), _inLoop(false) | 313 | : ViewMailBase(parent, name, fl), _inLoop(false) |
310 | { | 314 | { |
311 | m_gotBody = false; | 315 | m_gotBody = false; |
312 | deleted = false; | 316 | deleted = false; |
313 | 317 | ||
314 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 318 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
315 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 319 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
316 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 320 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
317 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 321 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
318 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); | 322 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); |
319 | 323 | ||
320 | attachments->setEnabled(m_gotBody); | 324 | attachments->setEnabled(m_gotBody); |
321 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 325 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
322 | 326 | ||
323 | readConfig(); | 327 | readConfig(); |
324 | attachments->setSorting(-1); | 328 | attachments->setSorting(-1); |
325 | } | 329 | } |
326 | 330 | ||
327 | void ViewMail::readConfig() | 331 | void ViewMail::readConfig() |
328 | { | 332 | { |
329 | 333 | ||
330 | setFont ( KOPrefs::instance()->mReadFont ); | 334 | setFont ( KOPrefs::instance()->mReadFont ); |
331 | m_showHtml = KOPrefs::instance()->mViewAsHtml; | 335 | m_showHtml = KOPrefs::instance()->mViewAsHtml; |
332 | showHtml->setOn( m_showHtml ); | 336 | showHtml->setOn( m_showHtml ); |
333 | } | 337 | } |
334 | 338 | ||
335 | void ViewMail::setText() | 339 | void ViewMail::setText() |
336 | { | 340 | { |
337 | 341 | ||
338 | QString toString; | 342 | QString toString; |
339 | QString ccString; | 343 | QString ccString; |
340 | QString bccString; | 344 | QString bccString; |
341 | 345 | ||
342 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 346 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
343 | { | 347 | { |
344 | toString += (*it); | 348 | toString += (*it); |
345 | } | 349 | } |
346 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 350 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
347 | { | 351 | { |
348 | ccString += (*it); | 352 | ccString += (*it); |
349 | } | 353 | } |
350 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 354 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
351 | { | 355 | { |
352 | bccString += (*it); | 356 | bccString += (*it); |
353 | } | 357 | } |
354 | 358 | ||
355 | setCaption( tr("E-Mail by %1").arg( m_mail[0] ) ); | 359 | setCaption( tr("E-Mail by %1").arg( m_mail[0] ) ); |
356 | 360 | ||
357 | m_mailHtml = "<html><body>" | 361 | m_mailHtml = "<html><body>" |
358 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 362 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
359 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 363 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
360 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 364 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
361 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 365 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
362 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 366 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
363 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 367 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
364 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 368 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
365 | "</td></tr></table><font>"; | 369 | "</td></tr></table><font>"; |
366 | 370 | ||
367 | if ( !m_showHtml ) | 371 | if ( !m_showHtml ) |
368 | { | 372 | { |
369 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 373 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
370 | } | 374 | } |
371 | else | 375 | else |
372 | { | 376 | { |
373 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 377 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
374 | } | 378 | } |
375 | // remove later in favor of a real handling | 379 | // remove later in favor of a real handling |
376 | m_gotBody = true; | 380 | m_gotBody = true; |
377 | } | 381 | } |
378 | 382 | ||
379 | 383 | ||
380 | ViewMail::~ViewMail() | 384 | ViewMail::~ViewMail() |
381 | { | 385 | { |
382 | m_recMail->Wrapper()->cleanMimeCache(); | 386 | m_recMail->Wrapper()->cleanMimeCache(); |
383 | hide(); | 387 | hide(); |
384 | } | 388 | } |
385 | 389 | ||
386 | void ViewMail::hide() | 390 | void ViewMail::hide() |
387 | { | 391 | { |
388 | QWidget::hide(); | 392 | QWidget::hide(); |
389 | 393 | ||
390 | if (_inLoop) | 394 | if (_inLoop) |
391 | { | 395 | { |
392 | _inLoop = false; | 396 | _inLoop = false; |
393 | qApp->exit_loop(); | 397 | qApp->exit_loop(); |
394 | 398 | ||
395 | } | 399 | } |
396 | 400 | ||
397 | } | 401 | } |
398 | 402 | ||
399 | void ViewMail::exec() | 403 | void ViewMail::exec() |
400 | { | 404 | { |
401 | show(); | 405 | show(); |
402 | 406 | ||
403 | if (!_inLoop) | 407 | if (!_inLoop) |
404 | { | 408 | { |
405 | _inLoop = true; | 409 | _inLoop = true; |
406 | qApp->enter_loop(); | 410 | qApp->enter_loop(); |
407 | } | 411 | } |
408 | 412 | ||
409 | } | 413 | } |
410 | 414 | ||
411 | QString ViewMail::deHtml(const QString &string) | 415 | QString ViewMail::deHtml(const QString &string) |
412 | { | 416 | { |
413 | QString string_ = string; | 417 | QString string_ = string; |
414 | string_.replace(QRegExp("&"), "&"); | 418 | string_.replace(QRegExp("&"), "&"); |
415 | string_.replace(QRegExp("<"), "<"); | 419 | string_.replace(QRegExp("<"), "<"); |
416 | string_.replace(QRegExp(">"), ">"); | 420 | string_.replace(QRegExp(">"), ">"); |
417 | string_.replace(QRegExp("\\n"), "<br>"); | 421 | string_.replace(QRegExp("\\n"), "<br>"); |
418 | return string_; | 422 | return string_; |
419 | } | 423 | } |
420 | 424 | ||
421 | void ViewMail::slotReply() | 425 | void ViewMail::slotReply() |
422 | { | 426 | { |
423 | if (!m_gotBody) | 427 | if (!m_gotBody) |
424 | { | 428 | { |
425 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 429 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
426 | return; | 430 | return; |
427 | } | 431 | } |
428 | 432 | ||
429 | QString rtext; | 433 | QString rtext; |
430 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 434 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
431 | .arg( m_mail[0] ) | 435 | .arg( m_mail[0] ) |
432 | .arg( m_mail[3] ); | 436 | .arg( m_mail[3] ); |
433 | 437 | ||
434 | QString text = m_mail[2]; | 438 | QString text = m_mail[2]; |
435 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 439 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
436 | QStringList::Iterator it; | 440 | QStringList::Iterator it; |
437 | for (it = lines.begin(); it != lines.end(); it++) | 441 | for (it = lines.begin(); it != lines.end(); it++) |
438 | { | 442 | { |
439 | rtext += "> " + *it + "\n"; | 443 | rtext += "> " + *it + "\n"; |
440 | } | 444 | } |
441 | rtext += "\n"; | 445 | rtext += "\n"; |
442 | 446 | ||
443 | QString prefix; | 447 | QString prefix; |
444 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 448 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
445 | else prefix = "Re: "; // no i18n on purpose | 449 | else prefix = "Re: "; // no i18n on purpose |
446 | 450 | ||
447 | Settings *settings = new Settings(); | 451 | Settings *settings = new Settings(); |
448 | ComposeMail composer( settings ,this, 0, true); | 452 | ComposeMail composer( settings ,this, 0, true); |
449 | if (m_recMail->Replyto().isEmpty()) { | 453 | if (m_recMail->Replyto().isEmpty()) { |
450 | composer.setTo( m_recMail->getFrom()); | 454 | composer.setTo( m_recMail->getFrom()); |
451 | } else { | 455 | } else { |
452 | composer.setTo( m_recMail->Replyto()); | 456 | composer.setTo( m_recMail->Replyto()); |
453 | } | 457 | } |
454 | composer.setSubject( prefix + m_mail[1] ); | 458 | composer.setSubject( prefix + m_mail[1] ); |
455 | composer.setMessage( rtext ); | 459 | composer.setMessage( rtext ); |
456 | composer.setInReplyTo(m_recMail->Msgid()); | 460 | composer.setInReplyTo(m_recMail->Msgid()); |
457 | 461 | ||
458 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 462 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
459 | { | 463 | { |
460 | m_recMail->Wrapper()->answeredMail(m_recMail); | 464 | m_recMail->Wrapper()->answeredMail(m_recMail); |
461 | } | 465 | } |
462 | } | 466 | } |
463 | 467 | ||
464 | void ViewMail::slotForward() | 468 | void ViewMail::slotForward() |
465 | { | 469 | { |
466 | if (!m_gotBody) | 470 | if (!m_gotBody) |
467 | { | 471 | { |
468 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 472 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
469 | return; | 473 | return; |
470 | } | 474 | } |
471 | 475 | ||
472 | QString ftext; | 476 | QString ftext; |
473 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 477 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
474 | .arg( m_mail[0] ); | 478 | .arg( m_mail[0] ); |
475 | if (!m_mail[3].isNull()) | 479 | if (!m_mail[3].isNull()) |
476 | ftext += QString("Date: %1\n") | 480 | ftext += QString("Date: %1\n") |
477 | .arg( m_mail[3] ); | 481 | .arg( m_mail[3] ); |
478 | if (!m_mail[0].isNull()) | 482 | if (!m_mail[0].isNull()) |
479 | ftext += QString("From: %1\n") | 483 | ftext += QString("From: %1\n") |
480 | .arg( m_mail[0] ); | 484 | .arg( m_mail[0] ); |
481 | if (!m_mail[1].isNull()) | 485 | if (!m_mail[1].isNull()) |
482 | ftext += QString("Subject: %1\n") | 486 | ftext += QString("Subject: %1\n") |
483 | .arg( m_mail[1] ); | 487 | .arg( m_mail[1] ); |
484 | 488 | ||
485 | ftext += QString("\n%1\n") | 489 | ftext += QString("\n%1\n") |
486 | .arg( m_mail[2]); | 490 | .arg( m_mail[2]); |
487 | 491 | ||
488 | ftext += QString("----- End forwarded message -----\n"); | 492 | ftext += QString("----- End forwarded message -----\n"); |
489 | 493 | ||
490 | Settings *settings = new Settings(); | 494 | Settings *settings = new Settings(); |
491 | ComposeMail composer( settings ,this, 0, true); | 495 | ComposeMail composer( settings ,this, 0, true); |
492 | composer.setSubject( "Fwd: " + m_mail[1] ); | 496 | composer.setSubject( "Fwd: " + m_mail[1] ); |
493 | composer.setMessage( ftext ); | 497 | composer.setMessage( ftext ); |
494 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) | 498 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) |
495 | { | 499 | { |
496 | } | 500 | } |
497 | } | 501 | } |
498 | 502 | ||
499 | void ViewMail::slotDeleteMail( ) | 503 | void ViewMail::slotDeleteMail( ) |
500 | { | 504 | { |
501 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 505 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
502 | { | 506 | { |
503 | m_recMail->Wrapper()->deleteMail( m_recMail ); | 507 | m_recMail->Wrapper()->deleteMail( m_recMail ); |
504 | hide(); | 508 | hide(); |
505 | deleted = true; | 509 | deleted = true; |
506 | } | 510 | } |
507 | } | 511 | } |
508 | 512 | ||
509 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) | 513 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) |
510 | : KDialog(parent,name,modal) | 514 | : KDialog(parent,name,modal) |
511 | { | 515 | { |
512 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 516 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
513 | dlglayout->setSpacing(2); | 517 | dlglayout->setSpacing(2); |
514 | dlglayout->setMargin(1); | 518 | dlglayout->setMargin(1); |
515 | //m_imageview = new Opie::MM::OImageScrollView(this); | 519 | //m_imageview = new Opie::MM::OImageScrollView(this); |
516 | //dlglayout->addWidget(m_imageview); | 520 | //dlglayout->addWidget(m_imageview); |
517 | } | 521 | } |
518 | 522 | ||
519 | MailImageDlg::~MailImageDlg() | 523 | MailImageDlg::~MailImageDlg() |
520 | { | 524 | { |
521 | } | 525 | } |
522 | 526 | ||
523 | void MailImageDlg::setName(const QString&fname) | 527 | void MailImageDlg::setName(const QString&fname) |
524 | { | 528 | { |
525 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); | 529 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); |
526 | // m_imageview->setImage(fname); | 530 | // m_imageview->setImage(fname); |
527 | } | 531 | } |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 290c0b9..884c61a 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -770,2981 +770,2984 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
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 | if ( mSyncKDE ) | 929 | if ( mSyncKDE ) |
930 | remote->resetPilotStat(1); | 930 | remote->resetPilotStat(1); |
931 | mLastCalendarSync = QDateTime::currentDateTime(); | 931 | mLastCalendarSync = QDateTime::currentDateTime(); |
932 | QDateTime modifiedCalendar = mLastCalendarSync;; | 932 | QDateTime modifiedCalendar = mLastCalendarSync;; |
933 | eventLSync = getLastSyncEvent(); | 933 | eventLSync = getLastSyncEvent(); |
934 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 934 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
935 | if ( eventR ) { | 935 | if ( eventR ) { |
936 | eventRSync = (Event*) eventR->clone(); | 936 | eventRSync = (Event*) eventR->clone(); |
937 | remote->deleteEvent(eventR ); | 937 | remote->deleteEvent(eventR ); |
938 | 938 | ||
939 | } else { | 939 | } else { |
940 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { | 940 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { |
941 | eventRSync = (Event*)eventLSync->clone(); | 941 | eventRSync = (Event*)eventLSync->clone(); |
942 | } else { | 942 | } else { |
943 | fullDateRange = true; | 943 | fullDateRange = true; |
944 | eventRSync = new Event(); | 944 | eventRSync = new Event(); |
945 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 945 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
946 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 946 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
947 | eventRSync->setDtStart( mLastCalendarSync ); | 947 | eventRSync->setDtStart( mLastCalendarSync ); |
948 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 948 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
949 | eventRSync->setCategories( i18n("SyncEvent") ); | 949 | eventRSync->setCategories( i18n("SyncEvent") ); |
950 | } | 950 | } |
951 | } | 951 | } |
952 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 952 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
953 | fullDateRange = true; | 953 | fullDateRange = true; |
954 | 954 | ||
955 | if ( ! fullDateRange ) { | 955 | if ( ! fullDateRange ) { |
956 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 956 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
957 | 957 | ||
958 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 958 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
959 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 959 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | } | 961 | } |
962 | } | 962 | } |
963 | if ( fullDateRange && !mSyncKDE ) | 963 | if ( fullDateRange && !mSyncKDE ) |
964 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 964 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
965 | else | 965 | else |
966 | mLastCalendarSync = eventLSync->dtStart(); | 966 | mLastCalendarSync = eventLSync->dtStart(); |
967 | // for resyncing if own file has changed | 967 | // for resyncing if own file has changed |
968 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 968 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
969 | mLastCalendarSync = loadedFileVersion; | 969 | mLastCalendarSync = loadedFileVersion; |
970 | //qDebug("setting mLastCalendarSync "); | 970 | //qDebug("setting mLastCalendarSync "); |
971 | } | 971 | } |
972 | //qDebug("*************************** "); | 972 | //qDebug("*************************** "); |
973 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 973 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
974 | QPtrList<Incidence> er = remote->rawIncidences(); | 974 | QPtrList<Incidence> er = remote->rawIncidences(); |
975 | Incidence* inR = er.first(); | 975 | Incidence* inR = er.first(); |
976 | Incidence* inL; | 976 | Incidence* inL; |
977 | QProgressBar bar( er.count(),0 ); | 977 | QProgressBar bar( er.count(),0 ); |
978 | bar.setCaption (i18n("Syncing - close to abort!") ); | 978 | bar.setCaption (i18n("Syncing - close to abort!") ); |
979 | 979 | ||
980 | int w = 300; | 980 | int w = 300; |
981 | if ( QApplication::desktop()->width() < 320 ) | 981 | if ( QApplication::desktop()->width() < 320 ) |
982 | w = 220; | 982 | w = 220; |
983 | int h = bar.sizeHint().height() ; | 983 | int h = bar.sizeHint().height() ; |
984 | int dw = QApplication::desktop()->width(); | 984 | int dw = QApplication::desktop()->width(); |
985 | int dh = QApplication::desktop()->height(); | 985 | int dh = QApplication::desktop()->height(); |
986 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 986 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
987 | bar.show(); | 987 | bar.show(); |
988 | int modulo = (er.count()/10)+1; | 988 | int modulo = (er.count()/10)+1; |
989 | int incCounter = 0; | 989 | int incCounter = 0; |
990 | while ( inR ) { | 990 | while ( inR ) { |
991 | if ( ! bar.isVisible() ) | 991 | if ( ! bar.isVisible() ) |
992 | return false; | 992 | return false; |
993 | if ( incCounter % modulo == 0 ) | 993 | if ( incCounter % modulo == 0 ) |
994 | bar.setProgress( incCounter ); | 994 | bar.setProgress( incCounter ); |
995 | ++incCounter; | 995 | ++incCounter; |
996 | uid = inR->uid(); | 996 | uid = inR->uid(); |
997 | bool skipIncidence = false; | 997 | bool skipIncidence = false; |
998 | if ( uid.left(15) == QString("last-syncEvent-") ) | 998 | if ( uid.left(15) == QString("last-syncEvent-") ) |
999 | skipIncidence = true; | 999 | skipIncidence = true; |
1000 | QString idS; | 1000 | QString idS; |
1001 | qApp->processEvents(); | 1001 | qApp->processEvents(); |
1002 | if ( !skipIncidence ) { | 1002 | if ( !skipIncidence ) { |
1003 | inL = local->incidence( uid ); | 1003 | inL = local->incidence( uid ); |
1004 | if ( inL ) { // maybe conflict - same uid in both calendars | 1004 | if ( inL ) { // maybe conflict - same uid in both calendars |
1005 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1005 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1006 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1006 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1007 | if ( take == 3 ) | 1007 | if ( take == 3 ) |
1008 | return false; | 1008 | return false; |
1009 | if ( take == 1 ) {// take local | 1009 | if ( take == 1 ) {// take local |
1010 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1010 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1011 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1011 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1012 | else | 1012 | else |
1013 | idS = inR->IDStr(); | 1013 | idS = inR->IDStr(); |
1014 | remote->deleteIncidence( inR ); | 1014 | remote->deleteIncidence( inR ); |
1015 | inR = inL->clone(); | 1015 | inR = inL->clone(); |
1016 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1016 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1017 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1017 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1018 | inR->setIDStr( idS ); | 1018 | inR->setIDStr( idS ); |
1019 | remote->addIncidence( inR ); | 1019 | remote->addIncidence( inR ); |
1020 | if ( mSyncKDE ) | 1020 | if ( mSyncKDE ) |
1021 | inR->setPilotId( 2 ); | 1021 | inR->setPilotId( 2 ); |
1022 | ++changedRemote; | 1022 | ++changedRemote; |
1023 | } else { | 1023 | } else { |
1024 | idS = inL->IDStr(); | 1024 | idS = inL->IDStr(); |
1025 | int pid = inL->pilotId(); | 1025 | int pid = inL->pilotId(); |
1026 | local->deleteIncidence( inL ); | 1026 | local->deleteIncidence( inL ); |
1027 | inL = inR->clone(); | 1027 | inL = inR->clone(); |
1028 | if ( mSyncKDE ) | 1028 | if ( mSyncKDE ) |
1029 | inL->setPilotId( pid ); | 1029 | inL->setPilotId( pid ); |
1030 | inL->setIDStr( idS ); | 1030 | inL->setIDStr( idS ); |
1031 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1031 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1032 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1032 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1033 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1033 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1034 | } | 1034 | } |
1035 | local->addIncidence( inL ); | 1035 | local->addIncidence( inL ); |
1036 | ++changedLocal; | 1036 | ++changedLocal; |
1037 | } | 1037 | } |
1038 | } | 1038 | } |
1039 | } else { // no conflict | 1039 | } else { // no conflict |
1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1041 | QString des = eventLSync->description(); | 1041 | QString des = eventLSync->description(); |
1042 | QString pref = "e"; | 1042 | QString pref = "e"; |
1043 | if ( inR->type() == "Todo" ) | 1043 | if ( inR->type() == "Todo" ) |
1044 | pref = "t"; | 1044 | pref = "t"; |
1045 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1045 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1047 | //remote->deleteIncidence( inR ); | 1047 | //remote->deleteIncidence( inR ); |
1048 | ++deletedEventR; | 1048 | ++deletedEventR; |
1049 | } else { | 1049 | } else { |
1050 | inR->setLastModified( modifiedCalendar ); | 1050 | inR->setLastModified( modifiedCalendar ); |
1051 | inL = inR->clone(); | 1051 | inL = inR->clone(); |
1052 | local->addIncidence( inL ); | 1052 | local->addIncidence( inL ); |
1053 | ++addedEvent; | 1053 | ++addedEvent; |
1054 | } | 1054 | } |
1055 | } else { | 1055 | } else { |
1056 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1056 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1057 | inR->setLastModified( modifiedCalendar ); | 1057 | inR->setLastModified( modifiedCalendar ); |
1058 | local->addIncidence( inR->clone() ); | 1058 | local->addIncidence( inR->clone() ); |
1059 | ++addedEvent; | 1059 | ++addedEvent; |
1060 | } else { | 1060 | } else { |
1061 | checkExternSyncEvent(eventRSyncSharp, inR); | 1061 | checkExternSyncEvent(eventRSyncSharp, inR); |
1062 | remote->deleteIncidence( inR ); | 1062 | remote->deleteIncidence( inR ); |
1063 | ++deletedEventR; | 1063 | ++deletedEventR; |
1064 | } | 1064 | } |
1065 | } | 1065 | } |
1066 | } | 1066 | } |
1067 | } | 1067 | } |
1068 | inR = er.next(); | 1068 | inR = er.next(); |
1069 | } | 1069 | } |
1070 | QPtrList<Incidence> el = local->rawIncidences(); | 1070 | QPtrList<Incidence> el = local->rawIncidences(); |
1071 | inL = el.first(); | 1071 | inL = el.first(); |
1072 | modulo = (el.count()/10)+1; | 1072 | modulo = (el.count()/10)+1; |
1073 | bar.setCaption (i18n("Add / remove events") ); | 1073 | bar.setCaption (i18n("Add / remove events") ); |
1074 | bar.setTotalSteps ( el.count() ) ; | 1074 | bar.setTotalSteps ( el.count() ) ; |
1075 | bar.show(); | 1075 | bar.show(); |
1076 | incCounter = 0; | 1076 | incCounter = 0; |
1077 | 1077 | ||
1078 | while ( inL ) { | 1078 | while ( inL ) { |
1079 | 1079 | ||
1080 | qApp->processEvents(); | 1080 | qApp->processEvents(); |
1081 | if ( ! bar.isVisible() ) | 1081 | if ( ! bar.isVisible() ) |
1082 | return false; | 1082 | return false; |
1083 | if ( incCounter % modulo == 0 ) | 1083 | if ( incCounter % modulo == 0 ) |
1084 | bar.setProgress( incCounter ); | 1084 | bar.setProgress( incCounter ); |
1085 | ++incCounter; | 1085 | ++incCounter; |
1086 | uid = inL->uid(); | 1086 | uid = inL->uid(); |
1087 | bool skipIncidence = false; | 1087 | bool skipIncidence = false; |
1088 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1088 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1089 | skipIncidence = true; | 1089 | skipIncidence = true; |
1090 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1090 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1091 | skipIncidence = true; | 1091 | skipIncidence = true; |
1092 | if ( !skipIncidence ) { | 1092 | if ( !skipIncidence ) { |
1093 | inR = remote->incidence( uid ); | 1093 | inR = remote->incidence( uid ); |
1094 | if ( ! inR ) { | 1094 | if ( ! inR ) { |
1095 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1095 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1096 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1096 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1097 | checkExternSyncEvent(eventLSyncSharp, inL); | 1097 | checkExternSyncEvent(eventLSyncSharp, inL); |
1098 | local->deleteIncidence( inL ); | 1098 | local->deleteIncidence( inL ); |
1099 | ++deletedEventL; | 1099 | ++deletedEventL; |
1100 | } else { | 1100 | } else { |
1101 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1101 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1102 | inL->removeID(mCurrentSyncDevice ); | 1102 | inL->removeID(mCurrentSyncDevice ); |
1103 | ++addedEventR; | 1103 | ++addedEventR; |
1104 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1104 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1105 | inL->setLastModified( modifiedCalendar ); | 1105 | inL->setLastModified( modifiedCalendar ); |
1106 | inR = inL->clone(); | 1106 | inR = inL->clone(); |
1107 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1107 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1108 | remote->addIncidence( inR ); | 1108 | remote->addIncidence( inR ); |
1109 | } | 1109 | } |
1110 | } | 1110 | } |
1111 | } else { | 1111 | } else { |
1112 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1112 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1113 | checkExternSyncEvent(eventLSyncSharp, inL); | 1113 | checkExternSyncEvent(eventLSyncSharp, inL); |
1114 | local->deleteIncidence( inL ); | 1114 | local->deleteIncidence( inL ); |
1115 | ++deletedEventL; | 1115 | ++deletedEventL; |
1116 | } else { | 1116 | } else { |
1117 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1117 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1118 | ++addedEventR; | 1118 | ++addedEventR; |
1119 | inL->setLastModified( modifiedCalendar ); | 1119 | inL->setLastModified( modifiedCalendar ); |
1120 | remote->addIncidence( inL->clone() ); | 1120 | remote->addIncidence( inL->clone() ); |
1121 | } | 1121 | } |
1122 | } | 1122 | } |
1123 | } | 1123 | } |
1124 | } | 1124 | } |
1125 | } | 1125 | } |
1126 | inL = el.next(); | 1126 | inL = el.next(); |
1127 | } | 1127 | } |
1128 | int delFut = 0; | 1128 | int delFut = 0; |
1129 | int remRem = 0; | 1129 | int remRem = 0; |
1130 | if ( mSyncManager->mWriteBackInFuture ) { | 1130 | if ( mSyncManager->mWriteBackInFuture ) { |
1131 | er = remote->rawIncidences(); | 1131 | er = remote->rawIncidences(); |
1132 | remRem = er.count(); | 1132 | remRem = er.count(); |
1133 | inR = er.first(); | 1133 | inR = er.first(); |
1134 | QDateTime dt; | 1134 | QDateTime dt; |
1135 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1135 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1136 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1136 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1137 | while ( inR ) { | 1137 | while ( inR ) { |
1138 | if ( inR->type() == "Todo" ) { | 1138 | if ( inR->type() == "Todo" ) { |
1139 | Todo * t = (Todo*)inR; | 1139 | Todo * t = (Todo*)inR; |
1140 | if ( t->hasDueDate() ) | 1140 | if ( t->hasDueDate() ) |
1141 | dt = t->dtDue(); | 1141 | dt = t->dtDue(); |
1142 | else | 1142 | else |
1143 | dt = cur.addSecs( 62 ); | 1143 | dt = cur.addSecs( 62 ); |
1144 | } | 1144 | } |
1145 | else if (inR->type() == "Event" ) { | 1145 | else if (inR->type() == "Event" ) { |
1146 | bool ok; | 1146 | bool ok; |
1147 | dt = inR->getNextOccurence( cur, &ok ); | 1147 | dt = inR->getNextOccurence( cur, &ok ); |
1148 | if ( !ok ) | 1148 | if ( !ok ) |
1149 | dt = cur.addSecs( -62 ); | 1149 | dt = cur.addSecs( -62 ); |
1150 | } | 1150 | } |
1151 | else | 1151 | else |
1152 | dt = inR->dtStart(); | 1152 | dt = inR->dtStart(); |
1153 | if ( dt < cur || dt > end ) { | 1153 | if ( dt < cur || dt > end ) { |
1154 | remote->deleteIncidence( inR ); | 1154 | remote->deleteIncidence( inR ); |
1155 | ++delFut; | 1155 | ++delFut; |
1156 | } | 1156 | } |
1157 | inR = er.next(); | 1157 | inR = er.next(); |
1158 | } | 1158 | } |
1159 | } | 1159 | } |
1160 | bar.hide(); | 1160 | bar.hide(); |
1161 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1161 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1162 | eventLSync->setReadOnly( false ); | 1162 | eventLSync->setReadOnly( false ); |
1163 | eventLSync->setDtStart( mLastCalendarSync ); | 1163 | eventLSync->setDtStart( mLastCalendarSync ); |
1164 | eventRSync->setDtStart( mLastCalendarSync ); | 1164 | eventRSync->setDtStart( mLastCalendarSync ); |
1165 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1165 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1166 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1166 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1167 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1167 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1168 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1168 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1169 | eventLSync->setReadOnly( true ); | 1169 | eventLSync->setReadOnly( true ); |
1170 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... | 1170 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... |
1171 | remote->addEvent( eventRSync ); | 1171 | remote->addEvent( eventRSync ); |
1172 | else | 1172 | else |
1173 | delete eventRSync; | 1173 | delete eventRSync; |
1174 | QString mes; | 1174 | QString mes; |
1175 | 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 ); | 1175 | 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 ); |
1176 | QString delmess; | 1176 | QString delmess; |
1177 | if ( delFut ) { | 1177 | if ( delFut ) { |
1178 | 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); | 1178 | 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); |
1179 | mes += delmess; | 1179 | mes += delmess; |
1180 | } | 1180 | } |
1181 | if ( mSyncManager->mShowSyncSummary ) { | 1181 | if ( mSyncManager->mShowSyncSummary ) { |
1182 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1182 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1183 | } | 1183 | } |
1184 | qDebug( mes ); | 1184 | qDebug( mes ); |
1185 | mCalendar->checkAlarmForIncidence( 0, true ); | 1185 | mCalendar->checkAlarmForIncidence( 0, true ); |
1186 | return syncOK; | 1186 | return syncOK; |
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | void CalendarView::setSyncDevice( QString s ) | 1189 | void CalendarView::setSyncDevice( QString s ) |
1190 | { | 1190 | { |
1191 | mCurrentSyncDevice= s; | 1191 | mCurrentSyncDevice= s; |
1192 | } | 1192 | } |
1193 | void CalendarView::setSyncName( QString s ) | 1193 | void CalendarView::setSyncName( QString s ) |
1194 | { | 1194 | { |
1195 | mCurrentSyncName= s; | 1195 | mCurrentSyncName= s; |
1196 | } | 1196 | } |
1197 | bool CalendarView::syncCalendar(QString filename, int mode) | 1197 | bool CalendarView::syncCalendar(QString filename, int mode) |
1198 | { | 1198 | { |
1199 | //qDebug("syncCalendar %s ", filename.latin1()); | 1199 | //qDebug("syncCalendar %s ", filename.latin1()); |
1200 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1200 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1201 | CalendarLocal* calendar = new CalendarLocal(); | 1201 | CalendarLocal* calendar = new CalendarLocal(); |
1202 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1202 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1203 | FileStorage* storage = new FileStorage( calendar ); | 1203 | FileStorage* storage = new FileStorage( calendar ); |
1204 | bool syncOK = false; | 1204 | bool syncOK = false; |
1205 | storage->setFileName( filename ); | 1205 | storage->setFileName( filename ); |
1206 | // qDebug("loading ... "); | 1206 | // qDebug("loading ... "); |
1207 | if ( storage->load() ) { | 1207 | if ( storage->load() ) { |
1208 | getEventViewerDialog()->setSyncMode( true ); | 1208 | getEventViewerDialog()->setSyncMode( true ); |
1209 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1209 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1210 | getEventViewerDialog()->setSyncMode( false ); | 1210 | getEventViewerDialog()->setSyncMode( false ); |
1211 | if ( syncOK ) { | 1211 | if ( syncOK ) { |
1212 | if ( mSyncManager->mWriteBackFile ) | 1212 | if ( mSyncManager->mWriteBackFile ) |
1213 | { | 1213 | { |
1214 | storage->setSaveFormat( new ICalFormat() ); | 1214 | storage->setSaveFormat( new ICalFormat() ); |
1215 | storage->save(); | 1215 | storage->save(); |
1216 | } | 1216 | } |
1217 | } | 1217 | } |
1218 | setModified( true ); | 1218 | setModified( true ); |
1219 | } | 1219 | } |
1220 | delete storage; | 1220 | delete storage; |
1221 | delete calendar; | 1221 | delete calendar; |
1222 | if ( syncOK ) | 1222 | if ( syncOK ) |
1223 | updateView(); | 1223 | updateView(); |
1224 | return syncOK; | 1224 | return syncOK; |
1225 | } | 1225 | } |
1226 | 1226 | ||
1227 | void CalendarView::syncExternal( int mode ) | 1227 | void CalendarView::syncExternal( int mode ) |
1228 | { | 1228 | { |
1229 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1229 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1230 | 1230 | ||
1231 | qApp->processEvents(); | 1231 | qApp->processEvents(); |
1232 | CalendarLocal* calendar = new CalendarLocal(); | 1232 | CalendarLocal* calendar = new CalendarLocal(); |
1233 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1233 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1234 | bool syncOK = false; | 1234 | bool syncOK = false; |
1235 | bool loadSuccess = false; | 1235 | bool loadSuccess = false; |
1236 | PhoneFormat* phoneFormat = 0; | 1236 | PhoneFormat* phoneFormat = 0; |
1237 | #ifndef DESKTOP_VERSION | 1237 | #ifndef DESKTOP_VERSION |
1238 | SharpFormat* sharpFormat = 0; | 1238 | SharpFormat* sharpFormat = 0; |
1239 | if ( mode == 0 ) { // sharp | 1239 | if ( mode == 0 ) { // sharp |
1240 | sharpFormat = new SharpFormat () ; | 1240 | sharpFormat = new SharpFormat () ; |
1241 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1241 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1242 | 1242 | ||
1243 | } else | 1243 | } else |
1244 | #endif | 1244 | #endif |
1245 | if ( mode == 1 ) { // phone | 1245 | if ( mode == 1 ) { // phone |
1246 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1246 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1247 | mSyncManager->mPhoneDevice, | 1247 | mSyncManager->mPhoneDevice, |
1248 | mSyncManager->mPhoneConnection, | 1248 | mSyncManager->mPhoneConnection, |
1249 | mSyncManager->mPhoneModel); | 1249 | mSyncManager->mPhoneModel); |
1250 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1250 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1251 | 1251 | ||
1252 | } else | 1252 | } else |
1253 | return; | 1253 | return; |
1254 | if ( loadSuccess ) { | 1254 | if ( loadSuccess ) { |
1255 | getEventViewerDialog()->setSyncMode( true ); | 1255 | getEventViewerDialog()->setSyncMode( true ); |
1256 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1256 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1257 | getEventViewerDialog()->setSyncMode( false ); | 1257 | getEventViewerDialog()->setSyncMode( false ); |
1258 | qApp->processEvents(); | 1258 | qApp->processEvents(); |
1259 | if ( syncOK ) { | 1259 | if ( syncOK ) { |
1260 | if ( mSyncManager->mWriteBackFile ) | 1260 | if ( mSyncManager->mWriteBackFile ) |
1261 | { | 1261 | { |
1262 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1262 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1263 | Incidence* inc = iL.first(); | 1263 | Incidence* inc = iL.first(); |
1264 | if ( phoneFormat ) { | 1264 | if ( phoneFormat ) { |
1265 | while ( inc ) { | 1265 | while ( inc ) { |
1266 | inc->removeID(mCurrentSyncDevice); | 1266 | inc->removeID(mCurrentSyncDevice); |
1267 | inc = iL.next(); | 1267 | inc = iL.next(); |
1268 | } | 1268 | } |
1269 | } | 1269 | } |
1270 | #ifndef DESKTOP_VERSION | 1270 | #ifndef DESKTOP_VERSION |
1271 | if ( sharpFormat ) | 1271 | if ( sharpFormat ) |
1272 | sharpFormat->save(calendar); | 1272 | sharpFormat->save(calendar); |
1273 | #endif | 1273 | #endif |
1274 | if ( phoneFormat ) | 1274 | if ( phoneFormat ) |
1275 | phoneFormat->save(calendar); | 1275 | phoneFormat->save(calendar); |
1276 | iL = calendar->rawIncidences(); | 1276 | iL = calendar->rawIncidences(); |
1277 | inc = iL.first(); | 1277 | inc = iL.first(); |
1278 | Incidence* loc; | 1278 | Incidence* loc; |
1279 | while ( inc ) { | 1279 | while ( inc ) { |
1280 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1280 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1281 | loc = mCalendar->incidence(inc->uid() ); | 1281 | loc = mCalendar->incidence(inc->uid() ); |
1282 | if ( loc ) { | 1282 | if ( loc ) { |
1283 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1283 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1284 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1284 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1285 | } | 1285 | } |
1286 | } | 1286 | } |
1287 | inc = iL.next(); | 1287 | inc = iL.next(); |
1288 | } | 1288 | } |
1289 | Incidence* lse = getLastSyncEvent(); | 1289 | Incidence* lse = getLastSyncEvent(); |
1290 | if ( lse ) { | 1290 | if ( lse ) { |
1291 | lse->setReadOnly( false ); | 1291 | lse->setReadOnly( false ); |
1292 | lse->setDescription( "" ); | 1292 | lse->setDescription( "" ); |
1293 | lse->setReadOnly( true ); | 1293 | lse->setReadOnly( true ); |
1294 | } | 1294 | } |
1295 | } | 1295 | } |
1296 | } | 1296 | } |
1297 | setModified( true ); | 1297 | setModified( true ); |
1298 | } else { | 1298 | } else { |
1299 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1299 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1300 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1300 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1301 | question, i18n("Ok")) ; | 1301 | question, i18n("Ok")) ; |
1302 | 1302 | ||
1303 | } | 1303 | } |
1304 | delete calendar; | 1304 | delete calendar; |
1305 | updateView(); | 1305 | updateView(); |
1306 | return ;//syncOK; | 1306 | return ;//syncOK; |
1307 | 1307 | ||
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | bool CalendarView::importBday() | 1310 | bool CalendarView::importBday() |
1311 | { | 1311 | { |
1312 | #ifndef KORG_NOKABC | 1312 | #ifndef KORG_NOKABC |
1313 | 1313 | ||
1314 | #ifdef DESKTOP_VERSION | 1314 | #ifdef DESKTOP_VERSION |
1315 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1315 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1316 | KABC::AddressBook::Iterator it; | 1316 | KABC::AddressBook::Iterator it; |
1317 | int count = 0; | 1317 | int count = 0; |
1318 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1318 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1319 | ++count; | 1319 | ++count; |
1320 | } | 1320 | } |
1321 | QProgressBar bar(count,0 ); | 1321 | QProgressBar bar(count,0 ); |
1322 | int w = 300; | 1322 | int w = 300; |
1323 | if ( QApplication::desktop()->width() < 320 ) | 1323 | if ( QApplication::desktop()->width() < 320 ) |
1324 | w = 220; | 1324 | w = 220; |
1325 | int h = bar.sizeHint().height() ; | 1325 | int h = bar.sizeHint().height() ; |
1326 | int dw = QApplication::desktop()->width(); | 1326 | int dw = QApplication::desktop()->width(); |
1327 | int dh = QApplication::desktop()->height(); | 1327 | int dh = QApplication::desktop()->height(); |
1328 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1328 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1329 | bar.show(); | 1329 | bar.show(); |
1330 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1330 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1331 | qApp->processEvents(); | 1331 | qApp->processEvents(); |
1332 | count = 0; | 1332 | count = 0; |
1333 | int addCount = 0; | 1333 | int addCount = 0; |
1334 | KCal::Attendee* a = 0; | 1334 | KCal::Attendee* a = 0; |
1335 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1335 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1336 | if ( ! bar.isVisible() ) | 1336 | if ( ! bar.isVisible() ) |
1337 | return false; | 1337 | return false; |
1338 | bar.setProgress( count++ ); | 1338 | bar.setProgress( count++ ); |
1339 | qApp->processEvents(); | 1339 | qApp->processEvents(); |
1340 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1340 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1341 | if ( (*it).birthday().date().isValid() ){ | 1341 | if ( (*it).birthday().date().isValid() ){ |
1342 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1342 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1343 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1343 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1344 | ++addCount; | 1344 | ++addCount; |
1345 | } | 1345 | } |
1346 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1346 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1347 | if ( anni.isValid() ){ | 1347 | if ( anni.isValid() ){ |
1348 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1348 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1349 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1349 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1350 | ++addCount; | 1350 | ++addCount; |
1351 | } | 1351 | } |
1352 | } | 1352 | } |
1353 | updateView(); | 1353 | updateView(); |
1354 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1354 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1355 | #else //DESKTOP_VERSION | 1355 | #else //DESKTOP_VERSION |
1356 | 1356 | ||
1357 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1357 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1358 | // the result should now arrive through method insertBirthdays | 1358 | // the result should now arrive through method insertBirthdays |
1359 | 1359 | ||
1360 | #endif //DESKTOP_VERSION | 1360 | #endif //DESKTOP_VERSION |
1361 | 1361 | ||
1362 | #endif //KORG_NOKABC | 1362 | #endif //KORG_NOKABC |
1363 | 1363 | ||
1364 | 1364 | ||
1365 | return true; | 1365 | return true; |
1366 | } | 1366 | } |
1367 | 1367 | ||
1368 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1368 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1369 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1369 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1370 | const QStringList& anniversaryList, const QStringList& realNameList, | 1370 | const QStringList& anniversaryList, const QStringList& realNameList, |
1371 | const QStringList& emailList, const QStringList& assembledNameList, | 1371 | const QStringList& emailList, const QStringList& assembledNameList, |
1372 | const QStringList& uidList) | 1372 | const QStringList& uidList) |
1373 | { | 1373 | { |
1374 | qDebug("CalendarView::insertBirthdays"); | 1374 | qDebug("CalendarView::insertBirthdays"); |
1375 | if (uid == this->name()) | 1375 | if (uid == this->name()) |
1376 | { | 1376 | { |
1377 | int count = birthdayList.count(); | 1377 | int count = birthdayList.count(); |
1378 | int addCount = 0; | 1378 | int addCount = 0; |
1379 | KCal::Attendee* a = 0; | 1379 | KCal::Attendee* a = 0; |
1380 | 1380 | ||
1381 | qDebug("CalView 1 %i", count); | 1381 | qDebug("CalView 1 %i", count); |
1382 | 1382 | ||
1383 | QProgressBar bar(count,0 ); | 1383 | QProgressBar bar(count,0 ); |
1384 | int w = 300; | 1384 | int w = 300; |
1385 | if ( QApplication::desktop()->width() < 320 ) | 1385 | if ( QApplication::desktop()->width() < 320 ) |
1386 | w = 220; | 1386 | w = 220; |
1387 | int h = bar.sizeHint().height() ; | 1387 | int h = bar.sizeHint().height() ; |
1388 | int dw = QApplication::desktop()->width(); | 1388 | int dw = QApplication::desktop()->width(); |
1389 | int dh = QApplication::desktop()->height(); | 1389 | int dh = QApplication::desktop()->height(); |
1390 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1390 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1391 | bar.show(); | 1391 | bar.show(); |
1392 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1392 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1393 | qApp->processEvents(); | 1393 | qApp->processEvents(); |
1394 | 1394 | ||
1395 | QDate birthday; | 1395 | QDate birthday; |
1396 | QDate anniversary; | 1396 | QDate anniversary; |
1397 | QString realName; | 1397 | QString realName; |
1398 | QString email; | 1398 | QString email; |
1399 | QString assembledName; | 1399 | QString assembledName; |
1400 | QString uid; | 1400 | QString uid; |
1401 | bool ok = true; | 1401 | bool ok = true; |
1402 | for ( int i = 0; i < count; i++) | 1402 | for ( int i = 0; i < count; i++) |
1403 | { | 1403 | { |
1404 | if ( ! bar.isVisible() ) | 1404 | if ( ! bar.isVisible() ) |
1405 | return; | 1405 | return; |
1406 | bar.setProgress( i ); | 1406 | bar.setProgress( i ); |
1407 | qApp->processEvents(); | 1407 | qApp->processEvents(); |
1408 | 1408 | ||
1409 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1409 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1410 | if (!ok) { | 1410 | if (!ok) { |
1411 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1411 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1412 | } | 1412 | } |
1413 | 1413 | ||
1414 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1414 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1415 | if (!ok) { | 1415 | if (!ok) { |
1416 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1416 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1417 | } | 1417 | } |
1418 | realName = realNameList[i]; | 1418 | realName = realNameList[i]; |
1419 | email = emailList[i]; | 1419 | email = emailList[i]; |
1420 | assembledName = assembledNameList[i]; | 1420 | assembledName = assembledNameList[i]; |
1421 | uid = uidList[i]; | 1421 | uid = uidList[i]; |
1422 | //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() ); | 1422 | //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() ); |
1423 | 1423 | ||
1424 | if ( birthday.isValid() ){ | 1424 | if ( birthday.isValid() ){ |
1425 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1425 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1426 | KCal::Attendee::ReqParticipant,uid) ; | 1426 | KCal::Attendee::ReqParticipant,uid) ; |
1427 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1427 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1428 | ++addCount; | 1428 | ++addCount; |
1429 | } | 1429 | } |
1430 | 1430 | ||
1431 | if ( anniversary.isValid() ){ | 1431 | if ( anniversary.isValid() ){ |
1432 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1432 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1433 | KCal::Attendee::ReqParticipant,uid) ; | 1433 | KCal::Attendee::ReqParticipant,uid) ; |
1434 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1434 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1435 | ++addCount; | 1435 | ++addCount; |
1436 | } | 1436 | } |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | updateView(); | 1439 | updateView(); |
1440 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1440 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1441 | 1441 | ||
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | } | 1444 | } |
1445 | 1445 | ||
1446 | 1446 | ||
1447 | 1447 | ||
1448 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1448 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1449 | { | 1449 | { |
1450 | //qDebug("addAnni "); | 1450 | //qDebug("addAnni "); |
1451 | Event * ev = new Event(); | 1451 | Event * ev = new Event(); |
1452 | if ( a ) { | 1452 | if ( a ) { |
1453 | ev->addAttendee( a ); | 1453 | ev->addAttendee( a ); |
1454 | } | 1454 | } |
1455 | QString kind; | 1455 | QString kind; |
1456 | if ( birthday ) | 1456 | if ( birthday ) |
1457 | kind = i18n( "Birthday" ); | 1457 | kind = i18n( "Birthday" ); |
1458 | else | 1458 | else |
1459 | kind = i18n( "Anniversary" ); | 1459 | kind = i18n( "Anniversary" ); |
1460 | ev->setSummary( name + " - " + kind ); | 1460 | ev->setSummary( name + " - " + kind ); |
1461 | ev->setOrganizer( "nobody@nowhere" ); | 1461 | ev->setOrganizer( "nobody@nowhere" ); |
1462 | ev->setCategories( kind ); | 1462 | ev->setCategories( kind ); |
1463 | ev->setDtStart( QDateTime(date) ); | 1463 | ev->setDtStart( QDateTime(date) ); |
1464 | ev->setDtEnd( QDateTime(date) ); | 1464 | ev->setDtEnd( QDateTime(date) ); |
1465 | ev->setFloats( true ); | 1465 | ev->setFloats( true ); |
1466 | Recurrence * rec = ev->recurrence(); | 1466 | Recurrence * rec = ev->recurrence(); |
1467 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1467 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1468 | rec->addYearlyNum( date.month() ); | 1468 | rec->addYearlyNum( date.month() ); |
1469 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1469 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1470 | delete ev; | 1470 | delete ev; |
1471 | return false; | 1471 | return false; |
1472 | } | 1472 | } |
1473 | return true; | 1473 | return true; |
1474 | 1474 | ||
1475 | } | 1475 | } |
1476 | bool CalendarView::importQtopia( const QString &categories, | 1476 | bool CalendarView::importQtopia( const QString &categories, |
1477 | const QString &datebook, | 1477 | const QString &datebook, |
1478 | const QString &todolist ) | 1478 | const QString &todolist ) |
1479 | { | 1479 | { |
1480 | 1480 | ||
1481 | QtopiaFormat qtopiaFormat; | 1481 | QtopiaFormat qtopiaFormat; |
1482 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1482 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1483 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1483 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1484 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1484 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1485 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1485 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1486 | 1486 | ||
1487 | updateView(); | 1487 | updateView(); |
1488 | return true; | 1488 | return true; |
1489 | 1489 | ||
1490 | #if 0 | 1490 | #if 0 |
1491 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1491 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1492 | mCurrentSyncDevice = "qtopia-XML"; | 1492 | mCurrentSyncDevice = "qtopia-XML"; |
1493 | if ( mSyncManager->mAskForPreferences ) | 1493 | if ( mSyncManager->mAskForPreferences ) |
1494 | edit_sync_options(); | 1494 | edit_sync_options(); |
1495 | qApp->processEvents(); | 1495 | qApp->processEvents(); |
1496 | CalendarLocal* calendar = new CalendarLocal(); | 1496 | CalendarLocal* calendar = new CalendarLocal(); |
1497 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1497 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1498 | bool syncOK = false; | 1498 | bool syncOK = false; |
1499 | QtopiaFormat qtopiaFormat; | 1499 | QtopiaFormat qtopiaFormat; |
1500 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1500 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1501 | bool loadOk = true; | 1501 | bool loadOk = true; |
1502 | if ( !categories.isEmpty() ) | 1502 | if ( !categories.isEmpty() ) |
1503 | loadOk = qtopiaFormat.load( calendar, categories ); | 1503 | loadOk = qtopiaFormat.load( calendar, categories ); |
1504 | if ( loadOk && !datebook.isEmpty() ) | 1504 | if ( loadOk && !datebook.isEmpty() ) |
1505 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1505 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1506 | if ( loadOk && !todolist.isEmpty() ) | 1506 | if ( loadOk && !todolist.isEmpty() ) |
1507 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1507 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1508 | 1508 | ||
1509 | if ( loadOk ) { | 1509 | if ( loadOk ) { |
1510 | getEventViewerDialog()->setSyncMode( true ); | 1510 | getEventViewerDialog()->setSyncMode( true ); |
1511 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1511 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1512 | getEventViewerDialog()->setSyncMode( false ); | 1512 | getEventViewerDialog()->setSyncMode( false ); |
1513 | qApp->processEvents(); | 1513 | qApp->processEvents(); |
1514 | if ( syncOK ) { | 1514 | if ( syncOK ) { |
1515 | if ( mSyncManager->mWriteBackFile ) | 1515 | if ( mSyncManager->mWriteBackFile ) |
1516 | { | 1516 | { |
1517 | // write back XML file | 1517 | // write back XML file |
1518 | 1518 | ||
1519 | } | 1519 | } |
1520 | setModified( true ); | 1520 | setModified( true ); |
1521 | } | 1521 | } |
1522 | } else { | 1522 | } else { |
1523 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1523 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1524 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1524 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1525 | question, i18n("Ok")) ; | 1525 | question, i18n("Ok")) ; |
1526 | } | 1526 | } |
1527 | delete calendar; | 1527 | delete calendar; |
1528 | updateView(); | 1528 | updateView(); |
1529 | return syncOK; | 1529 | return syncOK; |
1530 | 1530 | ||
1531 | 1531 | ||
1532 | #endif | 1532 | #endif |
1533 | 1533 | ||
1534 | } | 1534 | } |
1535 | 1535 | ||
1536 | void CalendarView::setSyncEventsReadOnly() | 1536 | void CalendarView::setSyncEventsReadOnly() |
1537 | { | 1537 | { |
1538 | Event * ev; | 1538 | Event * ev; |
1539 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1539 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1540 | ev = eL.first(); | 1540 | ev = eL.first(); |
1541 | while ( ev ) { | 1541 | while ( ev ) { |
1542 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1542 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1543 | ev->setReadOnly( true ); | 1543 | ev->setReadOnly( true ); |
1544 | ev = eL.next(); | 1544 | ev = eL.next(); |
1545 | } | 1545 | } |
1546 | } | 1546 | } |
1547 | bool CalendarView::openCalendar(QString filename, bool merge) | 1547 | bool CalendarView::openCalendar(QString filename, bool merge) |
1548 | { | 1548 | { |
1549 | 1549 | ||
1550 | if (filename.isEmpty()) { | 1550 | if (filename.isEmpty()) { |
1551 | return false; | 1551 | return false; |
1552 | } | 1552 | } |
1553 | 1553 | ||
1554 | if (!QFile::exists(filename)) { | 1554 | if (!QFile::exists(filename)) { |
1555 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1555 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1556 | return false; | 1556 | return false; |
1557 | } | 1557 | } |
1558 | 1558 | ||
1559 | globalFlagBlockAgenda = 1; | 1559 | globalFlagBlockAgenda = 1; |
1560 | if (!merge) mCalendar->close(); | 1560 | if (!merge) mCalendar->close(); |
1561 | 1561 | ||
1562 | mStorage->setFileName( filename ); | 1562 | mStorage->setFileName( filename ); |
1563 | 1563 | ||
1564 | if ( mStorage->load() ) { | 1564 | if ( mStorage->load() ) { |
1565 | if ( merge ) ;//setModified( true ); | 1565 | if ( merge ) ;//setModified( true ); |
1566 | else { | 1566 | else { |
1567 | //setModified( true ); | 1567 | //setModified( true ); |
1568 | mViewManager->setDocumentId( filename ); | 1568 | mViewManager->setDocumentId( filename ); |
1569 | mDialogManager->setDocumentId( filename ); | 1569 | mDialogManager->setDocumentId( filename ); |
1570 | mTodoList->setDocumentId( filename ); | 1570 | mTodoList->setDocumentId( filename ); |
1571 | } | 1571 | } |
1572 | globalFlagBlockAgenda = 2; | 1572 | globalFlagBlockAgenda = 2; |
1573 | // if ( getLastSyncEvent() ) | 1573 | // if ( getLastSyncEvent() ) |
1574 | // getLastSyncEvent()->setReadOnly( true ); | 1574 | // getLastSyncEvent()->setReadOnly( true ); |
1575 | mCalendar->reInitAlarmSettings(); | 1575 | mCalendar->reInitAlarmSettings(); |
1576 | setSyncEventsReadOnly(); | 1576 | setSyncEventsReadOnly(); |
1577 | updateUnmanagedViews(); | 1577 | updateUnmanagedViews(); |
1578 | updateView(); | 1578 | updateView(); |
1579 | if ( filename != MainWindow::defaultFileName() ) { | 1579 | if ( filename != MainWindow::defaultFileName() ) { |
1580 | saveCalendar( MainWindow::defaultFileName() ); | 1580 | saveCalendar( MainWindow::defaultFileName() ); |
1581 | } else { | 1581 | } else { |
1582 | QFileInfo finf ( MainWindow::defaultFileName()); | 1582 | QFileInfo finf ( MainWindow::defaultFileName()); |
1583 | if ( finf.exists() ) { | 1583 | if ( finf.exists() ) { |
1584 | setLoadedFileVersion( finf.lastModified () ); | 1584 | setLoadedFileVersion( finf.lastModified () ); |
1585 | } | 1585 | } |
1586 | } | 1586 | } |
1587 | return true; | 1587 | return true; |
1588 | } else { | 1588 | } else { |
1589 | // while failing to load, the calendar object could | 1589 | // while failing to load, the calendar object could |
1590 | // have become partially populated. Clear it out. | 1590 | // have become partially populated. Clear it out. |
1591 | if ( !merge ) { | 1591 | if ( !merge ) { |
1592 | mCalendar->close(); | 1592 | mCalendar->close(); |
1593 | mViewManager->setDocumentId( filename ); | 1593 | mViewManager->setDocumentId( filename ); |
1594 | mDialogManager->setDocumentId( filename ); | 1594 | mDialogManager->setDocumentId( filename ); |
1595 | mTodoList->setDocumentId( filename ); | 1595 | mTodoList->setDocumentId( filename ); |
1596 | } | 1596 | } |
1597 | 1597 | ||
1598 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1598 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1599 | 1599 | ||
1600 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1600 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1601 | globalFlagBlockAgenda = 2; | 1601 | globalFlagBlockAgenda = 2; |
1602 | mCalendar->reInitAlarmSettings(); | 1602 | mCalendar->reInitAlarmSettings(); |
1603 | setSyncEventsReadOnly(); | 1603 | setSyncEventsReadOnly(); |
1604 | updateUnmanagedViews(); | 1604 | updateUnmanagedViews(); |
1605 | updateView(); | 1605 | updateView(); |
1606 | } | 1606 | } |
1607 | return false; | 1607 | return false; |
1608 | } | 1608 | } |
1609 | void CalendarView::showOpenError() | 1609 | void CalendarView::showOpenError() |
1610 | { | 1610 | { |
1611 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1611 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1612 | } | 1612 | } |
1613 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1613 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1614 | { | 1614 | { |
1615 | loadedFileVersion = dt; | 1615 | loadedFileVersion = dt; |
1616 | } | 1616 | } |
1617 | bool CalendarView::checkFileChanged(QString fn) | 1617 | bool CalendarView::checkFileChanged(QString fn) |
1618 | { | 1618 | { |
1619 | QFileInfo finf ( fn ); | 1619 | QFileInfo finf ( fn ); |
1620 | if ( !finf.exists() ) | 1620 | if ( !finf.exists() ) |
1621 | return true; | 1621 | return true; |
1622 | QDateTime dt = finf.lastModified (); | 1622 | QDateTime dt = finf.lastModified (); |
1623 | if ( dt <= loadedFileVersion ) | 1623 | if ( dt <= loadedFileVersion ) |
1624 | return false; | 1624 | return false; |
1625 | return true; | 1625 | return true; |
1626 | 1626 | ||
1627 | } | 1627 | } |
1628 | void CalendarView::watchSavedFile() | 1628 | void CalendarView::watchSavedFile() |
1629 | { | 1629 | { |
1630 | QFileInfo finf ( MainWindow::defaultFileName()); | 1630 | QFileInfo finf ( MainWindow::defaultFileName()); |
1631 | if ( !finf.exists() ) | 1631 | if ( !finf.exists() ) |
1632 | return; | 1632 | return; |
1633 | QDateTime dt = finf.lastModified (); | 1633 | QDateTime dt = finf.lastModified (); |
1634 | if ( dt < loadedFileVersion ) { | 1634 | if ( dt < loadedFileVersion ) { |
1635 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1635 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1636 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1636 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1637 | return; | 1637 | return; |
1638 | } | 1638 | } |
1639 | loadedFileVersion = dt; | 1639 | loadedFileVersion = dt; |
1640 | } | 1640 | } |
1641 | 1641 | ||
1642 | bool CalendarView::checkFileVersion(QString fn) | 1642 | bool CalendarView::checkFileVersion(QString fn) |
1643 | { | 1643 | { |
1644 | QFileInfo finf ( fn ); | 1644 | QFileInfo finf ( fn ); |
1645 | if ( !finf.exists() ) | 1645 | if ( !finf.exists() ) |
1646 | return true; | 1646 | return true; |
1647 | QDateTime dt = finf.lastModified (); | 1647 | QDateTime dt = finf.lastModified (); |
1648 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1648 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1649 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1649 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1650 | if ( dt <= loadedFileVersion ) | 1650 | if ( dt <= loadedFileVersion ) |
1651 | return true; | 1651 | return true; |
1652 | 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)) , | 1652 | 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)) , |
1653 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1653 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1654 | i18n("Sync+save")); | 1654 | i18n("Sync+save")); |
1655 | 1655 | ||
1656 | if ( km == KMessageBox::Cancel ) | 1656 | if ( km == KMessageBox::Cancel ) |
1657 | return false; | 1657 | return false; |
1658 | if ( km == KMessageBox::Yes ) | 1658 | if ( km == KMessageBox::Yes ) |
1659 | return true; | 1659 | return true; |
1660 | 1660 | ||
1661 | setSyncDevice("deleteaftersync" ); | 1661 | setSyncDevice("deleteaftersync" ); |
1662 | mSyncManager->mAskForPreferences = true; | 1662 | mSyncManager->mAskForPreferences = true; |
1663 | mSyncManager->mSyncAlgoPrefs = 3; | 1663 | mSyncManager->mSyncAlgoPrefs = 3; |
1664 | mSyncManager->mWriteBackFile = false; | 1664 | mSyncManager->mWriteBackFile = false; |
1665 | mSyncManager->mWriteBackExistingOnly = false; | 1665 | mSyncManager->mWriteBackExistingOnly = false; |
1666 | mSyncManager->mShowSyncSummary = false; | 1666 | mSyncManager->mShowSyncSummary = false; |
1667 | syncCalendar( fn, 3 ); | 1667 | syncCalendar( fn, 3 ); |
1668 | Event * e = getLastSyncEvent(); | 1668 | Event * e = getLastSyncEvent(); |
1669 | mCalendar->deleteEvent ( e ); | 1669 | mCalendar->deleteEvent ( e ); |
1670 | updateView(); | 1670 | updateView(); |
1671 | return true; | 1671 | return true; |
1672 | } | 1672 | } |
1673 | 1673 | ||
1674 | bool CalendarView::saveCalendar( QString filename ) | 1674 | bool CalendarView::saveCalendar( QString filename ) |
1675 | { | 1675 | { |
1676 | 1676 | ||
1677 | // Store back all unsaved data into calendar object | 1677 | // Store back all unsaved data into calendar object |
1678 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1678 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1679 | if ( mViewManager->currentView() ) | 1679 | if ( mViewManager->currentView() ) |
1680 | mViewManager->currentView()->flushView(); | 1680 | mViewManager->currentView()->flushView(); |
1681 | 1681 | ||
1682 | 1682 | ||
1683 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1683 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1684 | mStorage->setSaveFormat( new ICalFormat() ); | 1684 | mStorage->setSaveFormat( new ICalFormat() ); |
1685 | mStorage->setFileName( filename ); | 1685 | mStorage->setFileName( filename ); |
1686 | bool success; | 1686 | bool success; |
1687 | success = mStorage->save(); | 1687 | success = mStorage->save(); |
1688 | if ( !success ) { | 1688 | if ( !success ) { |
1689 | return false; | 1689 | return false; |
1690 | } | 1690 | } |
1691 | if ( filename == MainWindow::defaultFileName() ) { | 1691 | if ( filename == MainWindow::defaultFileName() ) { |
1692 | setLoadedFileVersion( lfv ); | 1692 | setLoadedFileVersion( lfv ); |
1693 | watchSavedFile(); | 1693 | watchSavedFile(); |
1694 | } | 1694 | } |
1695 | return true; | 1695 | return true; |
1696 | } | 1696 | } |
1697 | 1697 | ||
1698 | void CalendarView::closeCalendar() | 1698 | void CalendarView::closeCalendar() |
1699 | { | 1699 | { |
1700 | 1700 | ||
1701 | // child windows no longer valid | 1701 | // child windows no longer valid |
1702 | emit closingDown(); | 1702 | emit closingDown(); |
1703 | 1703 | ||
1704 | mCalendar->close(); | 1704 | mCalendar->close(); |
1705 | setModified(false); | 1705 | setModified(false); |
1706 | updateView(); | 1706 | updateView(); |
1707 | } | 1707 | } |
1708 | 1708 | ||
1709 | void CalendarView::archiveCalendar() | 1709 | void CalendarView::archiveCalendar() |
1710 | { | 1710 | { |
1711 | mDialogManager->showArchiveDialog(); | 1711 | mDialogManager->showArchiveDialog(); |
1712 | } | 1712 | } |
1713 | 1713 | ||
1714 | 1714 | ||
1715 | void CalendarView::readSettings() | 1715 | void CalendarView::readSettings() |
1716 | { | 1716 | { |
1717 | 1717 | ||
1718 | 1718 | ||
1719 | // mViewManager->showAgendaView(); | 1719 | // mViewManager->showAgendaView(); |
1720 | QString str; | 1720 | QString str; |
1721 | //qDebug("CalendarView::readSettings() "); | 1721 | //qDebug("CalendarView::readSettings() "); |
1722 | // read settings from the KConfig, supplying reasonable | 1722 | // read settings from the KConfig, supplying reasonable |
1723 | // defaults where none are to be found | 1723 | // defaults where none are to be found |
1724 | KConfig *config = KOGlobals::config(); | 1724 | KConfig *config = KOGlobals::config(); |
1725 | #ifndef KORG_NOSPLITTER | 1725 | #ifndef KORG_NOSPLITTER |
1726 | config->setGroup("KOrganizer Geometry"); | 1726 | config->setGroup("KOrganizer Geometry"); |
1727 | 1727 | ||
1728 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1728 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1729 | if (sizes.count() != 2) { | 1729 | if (sizes.count() != 2) { |
1730 | sizes << mDateNavigator->minimumSizeHint().width(); | 1730 | sizes << mDateNavigator->minimumSizeHint().width(); |
1731 | sizes << 300; | 1731 | sizes << 300; |
1732 | } | 1732 | } |
1733 | mPanner->setSizes(sizes); | 1733 | mPanner->setSizes(sizes); |
1734 | 1734 | ||
1735 | sizes = config->readIntListEntry("Separator2"); | 1735 | sizes = config->readIntListEntry("Separator2"); |
1736 | if ( ( mResourceView && sizes.count() == 4 ) || | 1736 | if ( ( mResourceView && sizes.count() == 4 ) || |
1737 | ( !mResourceView && sizes.count() == 3 ) ) { | 1737 | ( !mResourceView && sizes.count() == 3 ) ) { |
1738 | mLeftSplitter->setSizes(sizes); | 1738 | mLeftSplitter->setSizes(sizes); |
1739 | } | 1739 | } |
1740 | #endif | 1740 | #endif |
1741 | globalFlagBlockAgenda = 1; | 1741 | globalFlagBlockAgenda = 1; |
1742 | mViewManager->showAgendaView(); | 1742 | mViewManager->showAgendaView(); |
1743 | //mViewManager->readSettings( config ); | 1743 | //mViewManager->readSettings( config ); |
1744 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1744 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1745 | readFilterSettings(config); | 1745 | readFilterSettings(config); |
1746 | config->setGroup( "Views" ); | 1746 | config->setGroup( "Views" ); |
1747 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1747 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1748 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1748 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1749 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1749 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1750 | else mNavigator->selectDates( dateCount ); | 1750 | else mNavigator->selectDates( dateCount ); |
1751 | // mViewManager->readSettings( config ); | 1751 | // mViewManager->readSettings( config ); |
1752 | updateConfig(); | 1752 | updateConfig(); |
1753 | globalFlagBlockAgenda = 2; | 1753 | globalFlagBlockAgenda = 2; |
1754 | mViewManager->readSettings( config ); | 1754 | mViewManager->readSettings( config ); |
1755 | #ifdef DESKTOP_VERSION | 1755 | #ifdef DESKTOP_VERSION |
1756 | config->setGroup("WidgetLayout"); | 1756 | config->setGroup("WidgetLayout"); |
1757 | QStringList list; | 1757 | QStringList list; |
1758 | list = config->readListEntry("MainLayout"); | 1758 | list = config->readListEntry("MainLayout"); |
1759 | int x,y,w,h; | 1759 | int x,y,w,h; |
1760 | if ( ! list.isEmpty() ) { | 1760 | if ( ! list.isEmpty() ) { |
1761 | x = list[0].toInt(); | 1761 | x = list[0].toInt(); |
1762 | y = list[1].toInt(); | 1762 | y = list[1].toInt(); |
1763 | w = list[2].toInt(); | 1763 | w = list[2].toInt(); |
1764 | h = list[3].toInt(); | 1764 | h = list[3].toInt(); |
1765 | topLevelWidget()->setGeometry(x,y,w,h); | 1765 | topLevelWidget()->setGeometry(x,y,w,h); |
1766 | 1766 | ||
1767 | } else { | 1767 | } else { |
1768 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1768 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1769 | } | 1769 | } |
1770 | list = config->readListEntry("EditEventLayout"); | 1770 | list = config->readListEntry("EditEventLayout"); |
1771 | if ( ! list.isEmpty() ) { | 1771 | if ( ! list.isEmpty() ) { |
1772 | x = list[0].toInt(); | 1772 | x = list[0].toInt(); |
1773 | y = list[1].toInt(); | 1773 | y = list[1].toInt(); |
1774 | w = list[2].toInt(); | 1774 | w = list[2].toInt(); |
1775 | h = list[3].toInt(); | 1775 | h = list[3].toInt(); |
1776 | mEventEditor->setGeometry(x,y,w,h); | 1776 | mEventEditor->setGeometry(x,y,w,h); |
1777 | 1777 | ||
1778 | } | 1778 | } |
1779 | list = config->readListEntry("EditTodoLayout"); | 1779 | list = config->readListEntry("EditTodoLayout"); |
1780 | if ( ! list.isEmpty() ) { | 1780 | if ( ! list.isEmpty() ) { |
1781 | x = list[0].toInt(); | 1781 | x = list[0].toInt(); |
1782 | y = list[1].toInt(); | 1782 | y = list[1].toInt(); |
1783 | w = list[2].toInt(); | 1783 | w = list[2].toInt(); |
1784 | h = list[3].toInt(); | 1784 | h = list[3].toInt(); |
1785 | mTodoEditor->setGeometry(x,y,w,h); | 1785 | mTodoEditor->setGeometry(x,y,w,h); |
1786 | 1786 | ||
1787 | } | 1787 | } |
1788 | list = config->readListEntry("ViewerLayout"); | 1788 | list = config->readListEntry("ViewerLayout"); |
1789 | if ( ! list.isEmpty() ) { | 1789 | if ( ! list.isEmpty() ) { |
1790 | x = list[0].toInt(); | 1790 | x = list[0].toInt(); |
1791 | y = list[1].toInt(); | 1791 | y = list[1].toInt(); |
1792 | w = list[2].toInt(); | 1792 | w = list[2].toInt(); |
1793 | h = list[3].toInt(); | 1793 | h = list[3].toInt(); |
1794 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1794 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1795 | } | 1795 | } |
1796 | #endif | 1796 | #endif |
1797 | 1797 | ||
1798 | } | 1798 | } |
1799 | 1799 | ||
1800 | 1800 | ||
1801 | void CalendarView::writeSettings() | 1801 | void CalendarView::writeSettings() |
1802 | { | 1802 | { |
1803 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1803 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1804 | 1804 | ||
1805 | KConfig *config = KOGlobals::config(); | 1805 | KConfig *config = KOGlobals::config(); |
1806 | 1806 | ||
1807 | #ifndef KORG_NOSPLITTER | 1807 | #ifndef KORG_NOSPLITTER |
1808 | config->setGroup("KOrganizer Geometry"); | 1808 | config->setGroup("KOrganizer Geometry"); |
1809 | 1809 | ||
1810 | QValueList<int> list = mPanner->sizes(); | 1810 | QValueList<int> list = mPanner->sizes(); |
1811 | config->writeEntry("Separator1",list); | 1811 | config->writeEntry("Separator1",list); |
1812 | 1812 | ||
1813 | list = mLeftSplitter->sizes(); | 1813 | list = mLeftSplitter->sizes(); |
1814 | config->writeEntry("Separator2",list); | 1814 | config->writeEntry("Separator2",list); |
1815 | #endif | 1815 | #endif |
1816 | 1816 | ||
1817 | mViewManager->writeSettings( config ); | 1817 | mViewManager->writeSettings( config ); |
1818 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1818 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1819 | mDialogManager->writeSettings( config ); | 1819 | mDialogManager->writeSettings( config ); |
1820 | //KOPrefs::instance()->usrWriteConfig(); | 1820 | //KOPrefs::instance()->usrWriteConfig(); |
1821 | KOPrefs::instance()->writeConfig(); | 1821 | KOPrefs::instance()->writeConfig(); |
1822 | 1822 | ||
1823 | writeFilterSettings(config); | 1823 | writeFilterSettings(config); |
1824 | 1824 | ||
1825 | config->setGroup( "Views" ); | 1825 | config->setGroup( "Views" ); |
1826 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1826 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1827 | 1827 | ||
1828 | #ifdef DESKTOP_VERSION | 1828 | #ifdef DESKTOP_VERSION |
1829 | config->setGroup("WidgetLayout"); | 1829 | config->setGroup("WidgetLayout"); |
1830 | QStringList list ;//= config->readListEntry("MainLayout"); | 1830 | QStringList list ;//= config->readListEntry("MainLayout"); |
1831 | int x,y,w,h; | 1831 | int x,y,w,h; |
1832 | QWidget* wid; | 1832 | QWidget* wid; |
1833 | wid = topLevelWidget(); | 1833 | wid = topLevelWidget(); |
1834 | x = wid->geometry().x(); | 1834 | x = wid->geometry().x(); |
1835 | y = wid->geometry().y(); | 1835 | y = wid->geometry().y(); |
1836 | w = wid->width(); | 1836 | w = wid->width(); |
1837 | h = wid->height(); | 1837 | h = wid->height(); |
1838 | list.clear(); | 1838 | list.clear(); |
1839 | list << QString::number( x ); | 1839 | list << QString::number( x ); |
1840 | list << QString::number( y ); | 1840 | list << QString::number( y ); |
1841 | list << QString::number( w ); | 1841 | list << QString::number( w ); |
1842 | list << QString::number( h ); | 1842 | list << QString::number( h ); |
1843 | config->writeEntry("MainLayout",list ); | 1843 | config->writeEntry("MainLayout",list ); |
1844 | 1844 | ||
1845 | wid = mEventEditor; | 1845 | wid = mEventEditor; |
1846 | x = wid->geometry().x(); | 1846 | x = wid->geometry().x(); |
1847 | y = wid->geometry().y(); | 1847 | y = wid->geometry().y(); |
1848 | w = wid->width(); | 1848 | w = wid->width(); |
1849 | h = wid->height(); | 1849 | h = wid->height(); |
1850 | list.clear(); | 1850 | list.clear(); |
1851 | list << QString::number( x ); | 1851 | list << QString::number( x ); |
1852 | list << QString::number( y ); | 1852 | list << QString::number( y ); |
1853 | list << QString::number( w ); | 1853 | list << QString::number( w ); |
1854 | list << QString::number( h ); | 1854 | list << QString::number( h ); |
1855 | config->writeEntry("EditEventLayout",list ); | 1855 | config->writeEntry("EditEventLayout",list ); |
1856 | 1856 | ||
1857 | wid = mTodoEditor; | 1857 | wid = mTodoEditor; |
1858 | x = wid->geometry().x(); | 1858 | x = wid->geometry().x(); |
1859 | y = wid->geometry().y(); | 1859 | y = wid->geometry().y(); |
1860 | w = wid->width(); | 1860 | w = wid->width(); |
1861 | h = wid->height(); | 1861 | h = wid->height(); |
1862 | list.clear(); | 1862 | list.clear(); |
1863 | list << QString::number( x ); | 1863 | list << QString::number( x ); |
1864 | list << QString::number( y ); | 1864 | list << QString::number( y ); |
1865 | list << QString::number( w ); | 1865 | list << QString::number( w ); |
1866 | list << QString::number( h ); | 1866 | list << QString::number( h ); |
1867 | config->writeEntry("EditTodoLayout",list ); | 1867 | config->writeEntry("EditTodoLayout",list ); |
1868 | wid = getEventViewerDialog(); | 1868 | wid = getEventViewerDialog(); |
1869 | x = wid->geometry().x(); | 1869 | x = wid->geometry().x(); |
1870 | y = wid->geometry().y(); | 1870 | y = wid->geometry().y(); |
1871 | w = wid->width(); | 1871 | w = wid->width(); |
1872 | h = wid->height(); | 1872 | h = wid->height(); |
1873 | list.clear(); | 1873 | list.clear(); |
1874 | list << QString::number( x ); | 1874 | list << QString::number( x ); |
1875 | list << QString::number( y ); | 1875 | list << QString::number( y ); |
1876 | list << QString::number( w ); | 1876 | list << QString::number( w ); |
1877 | list << QString::number( h ); | 1877 | list << QString::number( h ); |
1878 | config->writeEntry("ViewerLayout",list ); | 1878 | config->writeEntry("ViewerLayout",list ); |
1879 | wid = mDialogManager->getSearchDialog(); | 1879 | wid = mDialogManager->getSearchDialog(); |
1880 | if ( wid ) { | 1880 | if ( wid ) { |
1881 | x = wid->geometry().x(); | 1881 | x = wid->geometry().x(); |
1882 | y = wid->geometry().y(); | 1882 | y = wid->geometry().y(); |
1883 | w = wid->width(); | 1883 | w = wid->width(); |
1884 | h = wid->height(); | 1884 | h = wid->height(); |
1885 | list.clear(); | 1885 | list.clear(); |
1886 | list << QString::number( x ); | 1886 | list << QString::number( x ); |
1887 | list << QString::number( y ); | 1887 | list << QString::number( y ); |
1888 | list << QString::number( w ); | 1888 | list << QString::number( w ); |
1889 | list << QString::number( h ); | 1889 | list << QString::number( h ); |
1890 | config->writeEntry("SearchLayout",list ); | 1890 | config->writeEntry("SearchLayout",list ); |
1891 | } | 1891 | } |
1892 | #endif | 1892 | #endif |
1893 | 1893 | ||
1894 | 1894 | ||
1895 | config->sync(); | 1895 | config->sync(); |
1896 | } | 1896 | } |
1897 | 1897 | ||
1898 | void CalendarView::readFilterSettings(KConfig *config) | 1898 | void CalendarView::readFilterSettings(KConfig *config) |
1899 | { | 1899 | { |
1900 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1900 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1901 | 1901 | ||
1902 | mFilters.clear(); | 1902 | mFilters.clear(); |
1903 | 1903 | ||
1904 | config->setGroup("General"); | 1904 | config->setGroup("General"); |
1905 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1905 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1906 | 1906 | ||
1907 | QStringList::ConstIterator it = filterList.begin(); | 1907 | QStringList::ConstIterator it = filterList.begin(); |
1908 | QStringList::ConstIterator end = filterList.end(); | 1908 | QStringList::ConstIterator end = filterList.end(); |
1909 | while(it != end) { | 1909 | while(it != end) { |
1910 | // kdDebug() << " filter: " << (*it) << endl; | 1910 | // kdDebug() << " filter: " << (*it) << endl; |
1911 | 1911 | ||
1912 | CalFilter *filter; | 1912 | CalFilter *filter; |
1913 | filter = new CalFilter(*it); | 1913 | filter = new CalFilter(*it); |
1914 | config->setGroup("Filter_" + (*it)); | 1914 | config->setGroup("Filter_" + (*it)); |
1915 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1915 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1916 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1916 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1917 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1917 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1918 | mFilters.append(filter); | 1918 | mFilters.append(filter); |
1919 | 1919 | ||
1920 | ++it; | 1920 | ++it; |
1921 | } | 1921 | } |
1922 | 1922 | ||
1923 | if (mFilters.count() == 0) { | 1923 | if (mFilters.count() == 0) { |
1924 | CalFilter *filter = new CalFilter(i18n("Default")); | 1924 | CalFilter *filter = new CalFilter(i18n("Default")); |
1925 | mFilters.append(filter); | 1925 | mFilters.append(filter); |
1926 | } | 1926 | } |
1927 | mFilterView->updateFilters(); | 1927 | mFilterView->updateFilters(); |
1928 | config->setGroup("FilterView"); | 1928 | config->setGroup("FilterView"); |
1929 | 1929 | ||
1930 | mFilterView->blockSignals(true); | 1930 | mFilterView->blockSignals(true); |
1931 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1931 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1932 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1932 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1933 | mFilterView->blockSignals(false); | 1933 | mFilterView->blockSignals(false); |
1934 | // We do it manually to avoid it being done twice by the above calls | 1934 | // We do it manually to avoid it being done twice by the above calls |
1935 | updateFilter(); | 1935 | updateFilter(); |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | void CalendarView::writeFilterSettings(KConfig *config) | 1938 | void CalendarView::writeFilterSettings(KConfig *config) |
1939 | { | 1939 | { |
1940 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1940 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1941 | 1941 | ||
1942 | QStringList filterList; | 1942 | QStringList filterList; |
1943 | 1943 | ||
1944 | CalFilter *filter = mFilters.first(); | 1944 | CalFilter *filter = mFilters.first(); |
1945 | while(filter) { | 1945 | while(filter) { |
1946 | // kdDebug() << " fn: " << filter->name() << endl; | 1946 | // kdDebug() << " fn: " << filter->name() << endl; |
1947 | filterList << filter->name(); | 1947 | filterList << filter->name(); |
1948 | config->setGroup("Filter_" + filter->name()); | 1948 | config->setGroup("Filter_" + filter->name()); |
1949 | config->writeEntry("Criteria",filter->criteria()); | 1949 | config->writeEntry("Criteria",filter->criteria()); |
1950 | config->writeEntry("CategoryList",filter->categoryList()); | 1950 | config->writeEntry("CategoryList",filter->categoryList()); |
1951 | filter = mFilters.next(); | 1951 | filter = mFilters.next(); |
1952 | } | 1952 | } |
1953 | config->setGroup("General"); | 1953 | config->setGroup("General"); |
1954 | config->writeEntry("CalendarFilters",filterList); | 1954 | config->writeEntry("CalendarFilters",filterList); |
1955 | 1955 | ||
1956 | config->setGroup("FilterView"); | 1956 | config->setGroup("FilterView"); |
1957 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1957 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1958 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1958 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1959 | } | 1959 | } |
1960 | 1960 | ||
1961 | 1961 | ||
1962 | void CalendarView::goToday() | 1962 | void CalendarView::goToday() |
1963 | { | 1963 | { |
1964 | mNavigator->selectToday(); | 1964 | mNavigator->selectToday(); |
1965 | } | 1965 | } |
1966 | 1966 | ||
1967 | void CalendarView::goNext() | 1967 | void CalendarView::goNext() |
1968 | { | 1968 | { |
1969 | mNavigator->selectNext(); | 1969 | mNavigator->selectNext(); |
1970 | } | 1970 | } |
1971 | 1971 | ||
1972 | void CalendarView::goPrevious() | 1972 | void CalendarView::goPrevious() |
1973 | { | 1973 | { |
1974 | mNavigator->selectPrevious(); | 1974 | mNavigator->selectPrevious(); |
1975 | } | 1975 | } |
1976 | void CalendarView::goNextMonth() | 1976 | void CalendarView::goNextMonth() |
1977 | { | 1977 | { |
1978 | mNavigator->selectNextMonth(); | 1978 | mNavigator->selectNextMonth(); |
1979 | } | 1979 | } |
1980 | 1980 | ||
1981 | void CalendarView::goPreviousMonth() | 1981 | void CalendarView::goPreviousMonth() |
1982 | { | 1982 | { |
1983 | mNavigator->selectPreviousMonth(); | 1983 | mNavigator->selectPreviousMonth(); |
1984 | } | 1984 | } |
1985 | void CalendarView::writeLocale() | 1985 | void CalendarView::writeLocale() |
1986 | { | 1986 | { |
1987 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 1987 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
1988 | #if 0 | 1988 | #if 0 |
1989 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1989 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1990 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1990 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1991 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1991 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1992 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1992 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1993 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1993 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1994 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1994 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1995 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1995 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1996 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1996 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1997 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1997 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1998 | KOPrefs::instance()->mDaylightsavingStart, | 1998 | KOPrefs::instance()->mDaylightsavingStart, |
1999 | KOPrefs::instance()->mDaylightsavingEnd ); | 1999 | KOPrefs::instance()->mDaylightsavingEnd ); |
2000 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 2000 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
2001 | #endif | 2001 | #endif |
2002 | } | 2002 | } |
2003 | void CalendarView::updateConfig() | 2003 | void CalendarView::updateConfig() |
2004 | { | 2004 | { |
2005 | writeLocale(); | 2005 | writeLocale(); |
2006 | if ( KOPrefs::instance()->mUseAppColors ) | 2006 | if ( KOPrefs::instance()->mUseAppColors ) |
2007 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2007 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2008 | emit configChanged(); | 2008 | emit configChanged(); |
2009 | mTodoList->updateConfig(); | 2009 | mTodoList->updateConfig(); |
2010 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2010 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2011 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2011 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2012 | // To make the "fill window" configurations work | 2012 | // To make the "fill window" configurations work |
2013 | //mViewManager->raiseCurrentView(); | 2013 | //mViewManager->raiseCurrentView(); |
2014 | } | 2014 | } |
2015 | 2015 | ||
2016 | 2016 | ||
2017 | void CalendarView::eventChanged(Event *event) | 2017 | void CalendarView::eventChanged(Event *event) |
2018 | { | 2018 | { |
2019 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2019 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2020 | //updateUnmanagedViews(); | 2020 | //updateUnmanagedViews(); |
2021 | } | 2021 | } |
2022 | 2022 | ||
2023 | void CalendarView::eventAdded(Event *event) | 2023 | void CalendarView::eventAdded(Event *event) |
2024 | { | 2024 | { |
2025 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2025 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2026 | } | 2026 | } |
2027 | 2027 | ||
2028 | void CalendarView::eventToBeDeleted(Event *) | 2028 | void CalendarView::eventToBeDeleted(Event *) |
2029 | { | 2029 | { |
2030 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2030 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2031 | } | 2031 | } |
2032 | 2032 | ||
2033 | void CalendarView::eventDeleted() | 2033 | void CalendarView::eventDeleted() |
2034 | { | 2034 | { |
2035 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2035 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2036 | } | 2036 | } |
2037 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2037 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2038 | { | 2038 | { |
2039 | changeIncidenceDisplay((Incidence *)which, action); | 2039 | changeIncidenceDisplay((Incidence *)which, action); |
2040 | mDateNavigator->updateView(); //LR | 2040 | mDateNavigator->updateView(); //LR |
2041 | //mDialogManager->updateSearchDialog(); | 2041 | //mDialogManager->updateSearchDialog(); |
2042 | 2042 | ||
2043 | if (which) { | 2043 | if (which) { |
2044 | mViewManager->updateWNview(); | 2044 | mViewManager->updateWNview(); |
2045 | //mTodoList->updateView(); | 2045 | //mTodoList->updateView(); |
2046 | } | 2046 | } |
2047 | 2047 | ||
2048 | } | 2048 | } |
2049 | 2049 | ||
2050 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2050 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2051 | { | 2051 | { |
2052 | updateUnmanagedViews(); | 2052 | updateUnmanagedViews(); |
2053 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2053 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2054 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2054 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2055 | mCalendar->checkAlarmForIncidence( 0, true ); | 2055 | mCalendar->checkAlarmForIncidence( 0, true ); |
2056 | if ( mEventViewerDialog ) | 2056 | if ( mEventViewerDialog ) |
2057 | mEventViewerDialog->hide(); | 2057 | mEventViewerDialog->hide(); |
2058 | } | 2058 | } |
2059 | else | 2059 | else |
2060 | mCalendar->checkAlarmForIncidence( which , false ); | 2060 | mCalendar->checkAlarmForIncidence( which , false ); |
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | // most of the changeEventDisplays() right now just call the view's | 2063 | // most of the changeEventDisplays() right now just call the view's |
2064 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2064 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2065 | void CalendarView::changeEventDisplay(Event *which, int action) | 2065 | void CalendarView::changeEventDisplay(Event *which, int action) |
2066 | { | 2066 | { |
2067 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2067 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2068 | changeIncidenceDisplay((Incidence *)which, action); | 2068 | changeIncidenceDisplay((Incidence *)which, action); |
2069 | mDateNavigator->updateView(); | 2069 | mDateNavigator->updateView(); |
2070 | //mDialogManager->updateSearchDialog(); | 2070 | //mDialogManager->updateSearchDialog(); |
2071 | 2071 | ||
2072 | if (which) { | 2072 | if (which) { |
2073 | // If there is an event view visible update the display | 2073 | // If there is an event view visible update the display |
2074 | mViewManager->currentView()->changeEventDisplay(which,action); | 2074 | mViewManager->currentView()->changeEventDisplay(which,action); |
2075 | // TODO: check, if update needed | 2075 | // TODO: check, if update needed |
2076 | // if (which->getTodoStatus()) { | 2076 | // if (which->getTodoStatus()) { |
2077 | mTodoList->updateView(); | 2077 | mTodoList->updateView(); |
2078 | // } | 2078 | // } |
2079 | } else { | 2079 | } else { |
2080 | mViewManager->currentView()->updateView(); | 2080 | mViewManager->currentView()->updateView(); |
2081 | } | 2081 | } |
2082 | } | 2082 | } |
2083 | 2083 | ||
2084 | 2084 | ||
2085 | void CalendarView::updateTodoViews() | 2085 | void CalendarView::updateTodoViews() |
2086 | { | 2086 | { |
2087 | 2087 | ||
2088 | mTodoList->updateView(); | 2088 | mTodoList->updateView(); |
2089 | mViewManager->currentView()->updateView(); | 2089 | mViewManager->currentView()->updateView(); |
2090 | 2090 | ||
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | 2093 | ||
2094 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2094 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2095 | { | 2095 | { |
2096 | mTodoList->updateView(); | 2096 | mTodoList->updateView(); |
2097 | mViewManager->updateView(start, end); | 2097 | mViewManager->updateView(start, end); |
2098 | //mDateNavigator->updateView(); | 2098 | //mDateNavigator->updateView(); |
2099 | } | 2099 | } |
2100 | 2100 | ||
2101 | void CalendarView::updateView() | 2101 | void CalendarView::updateView() |
2102 | { | 2102 | { |
2103 | DateList tmpList = mNavigator->selectedDates(); | 2103 | DateList tmpList = mNavigator->selectedDates(); |
2104 | 2104 | ||
2105 | // We assume that the navigator only selects consecutive days. | 2105 | // We assume that the navigator only selects consecutive days. |
2106 | updateView( tmpList.first(), tmpList.last() ); | 2106 | updateView( tmpList.first(), tmpList.last() ); |
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | void CalendarView::updateUnmanagedViews() | 2109 | void CalendarView::updateUnmanagedViews() |
2110 | { | 2110 | { |
2111 | mDateNavigator->updateDayMatrix(); | 2111 | mDateNavigator->updateDayMatrix(); |
2112 | } | 2112 | } |
2113 | 2113 | ||
2114 | int CalendarView::msgItemDelete() | 2114 | int CalendarView::msgItemDelete() |
2115 | { | 2115 | { |
2116 | return KMessageBox::warningContinueCancel(this, | 2116 | return KMessageBox::warningContinueCancel(this, |
2117 | i18n("This item will be\npermanently deleted."), | 2117 | i18n("This item will be\npermanently deleted."), |
2118 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2118 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2119 | } | 2119 | } |
2120 | 2120 | ||
2121 | 2121 | ||
2122 | void CalendarView::edit_cut() | 2122 | void CalendarView::edit_cut() |
2123 | { | 2123 | { |
2124 | Event *anEvent=0; | 2124 | Event *anEvent=0; |
2125 | 2125 | ||
2126 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2126 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2127 | 2127 | ||
2128 | if (mViewManager->currentView()->isEventView()) { | 2128 | if (mViewManager->currentView()->isEventView()) { |
2129 | if ( incidence && incidence->type() == "Event" ) { | 2129 | if ( incidence && incidence->type() == "Event" ) { |
2130 | anEvent = static_cast<Event *>(incidence); | 2130 | anEvent = static_cast<Event *>(incidence); |
2131 | } | 2131 | } |
2132 | } | 2132 | } |
2133 | 2133 | ||
2134 | if (!anEvent) { | 2134 | if (!anEvent) { |
2135 | KNotifyClient::beep(); | 2135 | KNotifyClient::beep(); |
2136 | return; | 2136 | return; |
2137 | } | 2137 | } |
2138 | DndFactory factory( mCalendar ); | 2138 | DndFactory factory( mCalendar ); |
2139 | factory.cutEvent(anEvent); | 2139 | factory.cutEvent(anEvent); |
2140 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2140 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2141 | } | 2141 | } |
2142 | 2142 | ||
2143 | void CalendarView::edit_copy() | 2143 | void CalendarView::edit_copy() |
2144 | { | 2144 | { |
2145 | Event *anEvent=0; | 2145 | Event *anEvent=0; |
2146 | 2146 | ||
2147 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2147 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2148 | 2148 | ||
2149 | if (mViewManager->currentView()->isEventView()) { | 2149 | if (mViewManager->currentView()->isEventView()) { |
2150 | if ( incidence && incidence->type() == "Event" ) { | 2150 | if ( incidence && incidence->type() == "Event" ) { |
2151 | anEvent = static_cast<Event *>(incidence); | 2151 | anEvent = static_cast<Event *>(incidence); |
2152 | } | 2152 | } |
2153 | } | 2153 | } |
2154 | 2154 | ||
2155 | if (!anEvent) { | 2155 | if (!anEvent) { |
2156 | KNotifyClient::beep(); | 2156 | KNotifyClient::beep(); |
2157 | return; | 2157 | return; |
2158 | } | 2158 | } |
2159 | DndFactory factory( mCalendar ); | 2159 | DndFactory factory( mCalendar ); |
2160 | factory.copyEvent(anEvent); | 2160 | factory.copyEvent(anEvent); |
2161 | } | 2161 | } |
2162 | 2162 | ||
2163 | void CalendarView::edit_paste() | 2163 | void CalendarView::edit_paste() |
2164 | { | 2164 | { |
2165 | QDate date = mNavigator->selectedDates().first(); | 2165 | QDate date = mNavigator->selectedDates().first(); |
2166 | 2166 | ||
2167 | DndFactory factory( mCalendar ); | 2167 | DndFactory factory( mCalendar ); |
2168 | Event *pastedEvent = factory.pasteEvent( date ); | 2168 | Event *pastedEvent = factory.pasteEvent( date ); |
2169 | 2169 | ||
2170 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2170 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2171 | } | 2171 | } |
2172 | 2172 | ||
2173 | void CalendarView::edit_options() | 2173 | void CalendarView::edit_options() |
2174 | { | 2174 | { |
2175 | mDialogManager->showOptionsDialog(); | 2175 | mDialogManager->showOptionsDialog(); |
2176 | //writeSettings(); | 2176 | //writeSettings(); |
2177 | } | 2177 | } |
2178 | 2178 | ||
2179 | void CalendarView::slotSelectPickerDate( QDate d) | 2179 | void CalendarView::slotSelectPickerDate( QDate d) |
2180 | { | 2180 | { |
2181 | mDateFrame->hide(); | 2181 | mDateFrame->hide(); |
2182 | if ( mDatePickerMode == 1 ) { | 2182 | if ( mDatePickerMode == 1 ) { |
2183 | mNavigator->slotDaySelect( d ); | 2183 | mNavigator->slotDaySelect( d ); |
2184 | } else if ( mDatePickerMode == 2 ) { | 2184 | } else if ( mDatePickerMode == 2 ) { |
2185 | if ( mMoveIncidence->type() == "Todo" ) { | 2185 | if ( mMoveIncidence->type() == "Todo" ) { |
2186 | Todo * to = (Todo *) mMoveIncidence; | 2186 | Todo * to = (Todo *) mMoveIncidence; |
2187 | QTime tim; | 2187 | QTime tim; |
2188 | if ( to->hasDueDate() ) | 2188 | if ( to->hasDueDate() ) |
2189 | tim = to->dtDue().time(); | 2189 | tim = to->dtDue().time(); |
2190 | else { | 2190 | else { |
2191 | tim = QTime ( 0,0,0 ); | 2191 | tim = QTime ( 0,0,0 ); |
2192 | to->setFloats( true ); | 2192 | to->setFloats( true ); |
2193 | to->setHasDueDate( true ); | 2193 | to->setHasDueDate( true ); |
2194 | } | 2194 | } |
2195 | QDateTime dt ( d,tim ); | 2195 | QDateTime dt ( d,tim ); |
2196 | to->setDtDue( dt ); | 2196 | to->setDtDue( dt ); |
2197 | todoChanged( to ); | 2197 | todoChanged( to ); |
2198 | } else { | 2198 | } else { |
2199 | QTime tim = mMoveIncidence->dtStart().time(); | 2199 | QTime tim = mMoveIncidence->dtStart().time(); |
2200 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2200 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2201 | QDateTime dt ( d,tim ); | 2201 | QDateTime dt ( d,tim ); |
2202 | mMoveIncidence->setDtStart( dt ); | 2202 | mMoveIncidence->setDtStart( dt ); |
2203 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2203 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2204 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2204 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2205 | } | 2205 | } |
2206 | 2206 | ||
2207 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2207 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2208 | } | 2208 | } |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | void CalendarView::removeCategories() | 2211 | void CalendarView::removeCategories() |
2212 | { | 2212 | { |
2213 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2213 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2214 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2214 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2215 | QStringList catIncList; | 2215 | QStringList catIncList; |
2216 | QStringList newCatList; | 2216 | QStringList newCatList; |
2217 | Incidence* inc = incList.first(); | 2217 | Incidence* inc = incList.first(); |
2218 | int i; | 2218 | int i; |
2219 | int count = 0; | 2219 | int count = 0; |
2220 | while ( inc ) { | 2220 | while ( inc ) { |
2221 | newCatList.clear(); | 2221 | newCatList.clear(); |
2222 | catIncList = inc->categories() ; | 2222 | catIncList = inc->categories() ; |
2223 | for( i = 0; i< catIncList.count(); ++i ) { | 2223 | for( i = 0; i< catIncList.count(); ++i ) { |
2224 | if ( catList.contains (catIncList[i])) | 2224 | if ( catList.contains (catIncList[i])) |
2225 | newCatList.append( catIncList[i] ); | 2225 | newCatList.append( catIncList[i] ); |
2226 | } | 2226 | } |
2227 | newCatList.sort(); | 2227 | newCatList.sort(); |
2228 | inc->setCategories( newCatList.join(",") ); | 2228 | inc->setCategories( newCatList.join(",") ); |
2229 | inc = incList.next(); | 2229 | inc = incList.next(); |
2230 | } | 2230 | } |
2231 | } | 2231 | } |
2232 | 2232 | ||
2233 | int CalendarView::addCategories() | 2233 | int CalendarView::addCategories() |
2234 | { | 2234 | { |
2235 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2235 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2236 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2236 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2237 | QStringList catIncList; | 2237 | QStringList catIncList; |
2238 | Incidence* inc = incList.first(); | 2238 | Incidence* inc = incList.first(); |
2239 | int i; | 2239 | int i; |
2240 | int count = 0; | 2240 | int count = 0; |
2241 | while ( inc ) { | 2241 | while ( inc ) { |
2242 | catIncList = inc->categories() ; | 2242 | catIncList = inc->categories() ; |
2243 | for( i = 0; i< catIncList.count(); ++i ) { | 2243 | for( i = 0; i< catIncList.count(); ++i ) { |
2244 | if ( !catList.contains (catIncList[i])) { | 2244 | if ( !catList.contains (catIncList[i])) { |
2245 | catList.append( catIncList[i] ); | 2245 | catList.append( catIncList[i] ); |
2246 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2246 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2247 | ++count; | 2247 | ++count; |
2248 | } | 2248 | } |
2249 | } | 2249 | } |
2250 | inc = incList.next(); | 2250 | inc = incList.next(); |
2251 | } | 2251 | } |
2252 | catList.sort(); | 2252 | catList.sort(); |
2253 | KOPrefs::instance()->mCustomCategories = catList; | 2253 | KOPrefs::instance()->mCustomCategories = catList; |
2254 | return count; | 2254 | return count; |
2255 | } | 2255 | } |
2256 | 2256 | ||
2257 | void CalendarView::manageCategories() | 2257 | void CalendarView::manageCategories() |
2258 | { | 2258 | { |
2259 | KOCatPrefs* cp = new KOCatPrefs(); | 2259 | KOCatPrefs* cp = new KOCatPrefs(); |
2260 | cp->show(); | 2260 | cp->show(); |
2261 | int w =cp->sizeHint().width() ; | 2261 | int w =cp->sizeHint().width() ; |
2262 | int h = cp->sizeHint().height() ; | 2262 | int h = cp->sizeHint().height() ; |
2263 | int dw = QApplication::desktop()->width(); | 2263 | int dw = QApplication::desktop()->width(); |
2264 | int dh = QApplication::desktop()->height(); | 2264 | int dh = QApplication::desktop()->height(); |
2265 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2265 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2266 | if ( !cp->exec() ) { | 2266 | if ( !cp->exec() ) { |
2267 | delete cp; | 2267 | delete cp; |
2268 | return; | 2268 | return; |
2269 | } | 2269 | } |
2270 | int count = 0; | 2270 | int count = 0; |
2271 | if ( cp->addCat() ) { | 2271 | if ( cp->addCat() ) { |
2272 | count = addCategories(); | 2272 | count = addCategories(); |
2273 | if ( count ) { | 2273 | if ( count ) { |
2274 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2274 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2275 | writeSettings(); | 2275 | writeSettings(); |
2276 | } | 2276 | } |
2277 | } else { | 2277 | } else { |
2278 | removeCategories(); | 2278 | removeCategories(); |
2279 | updateView(); | 2279 | updateView(); |
2280 | } | 2280 | } |
2281 | delete cp; | 2281 | delete cp; |
2282 | } | 2282 | } |
2283 | 2283 | ||
2284 | void CalendarView::beamIncidence(Incidence * Inc) | 2284 | void CalendarView::beamIncidence(Incidence * Inc) |
2285 | { | 2285 | { |
2286 | QPtrList<Incidence> delSel ; | 2286 | QPtrList<Incidence> delSel ; |
2287 | delSel.append(Inc); | 2287 | delSel.append(Inc); |
2288 | beamIncidenceList( delSel ); | 2288 | beamIncidenceList( delSel ); |
2289 | } | 2289 | } |
2290 | void CalendarView::beamCalendar() | 2290 | void CalendarView::beamCalendar() |
2291 | { | 2291 | { |
2292 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2292 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2293 | //qDebug("beamCalendar() "); | 2293 | //qDebug("beamCalendar() "); |
2294 | beamIncidenceList( delSel ); | 2294 | beamIncidenceList( delSel ); |
2295 | } | 2295 | } |
2296 | void CalendarView::beamFilteredCalendar() | 2296 | void CalendarView::beamFilteredCalendar() |
2297 | { | 2297 | { |
2298 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2298 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2299 | //qDebug("beamFilteredCalendar() "); | 2299 | //qDebug("beamFilteredCalendar() "); |
2300 | beamIncidenceList( delSel ); | 2300 | beamIncidenceList( delSel ); |
2301 | } | 2301 | } |
2302 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2302 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2303 | { | 2303 | { |
2304 | if ( beamDialog->exec () == QDialog::Rejected ) | 2304 | if ( beamDialog->exec () == QDialog::Rejected ) |
2305 | return; | 2305 | return; |
2306 | 2306 | #ifdef DESKTOP_VERSION | |
2307 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | ||
2308 | #else | ||
2307 | QString fn = "/tmp/kopibeamfile"; | 2309 | QString fn = "/tmp/kopibeamfile"; |
2310 | #endif | ||
2308 | QString mes; | 2311 | QString mes; |
2309 | bool createbup = true; | 2312 | bool createbup = true; |
2310 | if ( createbup ) { | 2313 | if ( createbup ) { |
2311 | QString description = "\n"; | 2314 | QString description = "\n"; |
2312 | CalendarLocal* cal = new CalendarLocal(); | 2315 | CalendarLocal* cal = new CalendarLocal(); |
2313 | if ( beamDialog->beamLocal() ) | 2316 | if ( beamDialog->beamLocal() ) |
2314 | cal->setLocalTime(); | 2317 | cal->setLocalTime(); |
2315 | else | 2318 | else |
2316 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2319 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2317 | Incidence *incidence = delSel.first(); | 2320 | Incidence *incidence = delSel.first(); |
2318 | bool addText = false; | 2321 | bool addText = false; |
2319 | if ( delSel.count() < 10 ) | 2322 | if ( delSel.count() < 10 ) |
2320 | addText = true; | 2323 | addText = true; |
2321 | else { | 2324 | else { |
2322 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2325 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2323 | } | 2326 | } |
2324 | while ( incidence ) { | 2327 | while ( incidence ) { |
2325 | Incidence *in = incidence->clone(); | 2328 | Incidence *in = incidence->clone(); |
2326 | if ( ! in->summary().isEmpty() ) { | 2329 | if ( ! in->summary().isEmpty() ) { |
2327 | in->setDescription(""); | 2330 | in->setDescription(""); |
2328 | } else { | 2331 | } else { |
2329 | in->setSummary( in->description().left(20)); | 2332 | in->setSummary( in->description().left(20)); |
2330 | in->setDescription(""); | 2333 | in->setDescription(""); |
2331 | } | 2334 | } |
2332 | if ( addText ) | 2335 | if ( addText ) |
2333 | description += in->summary() + "\n"; | 2336 | description += in->summary() + "\n"; |
2334 | cal->addIncidence( in ); | 2337 | cal->addIncidence( in ); |
2335 | incidence = delSel.next(); | 2338 | incidence = delSel.next(); |
2336 | } | 2339 | } |
2337 | if ( beamDialog->beamVcal() ) { | 2340 | if ( beamDialog->beamVcal() ) { |
2338 | fn += ".vcs"; | 2341 | fn += ".vcs"; |
2339 | FileStorage storage( cal, fn, new VCalFormat ); | 2342 | FileStorage storage( cal, fn, new VCalFormat ); |
2340 | storage.save(); | 2343 | storage.save(); |
2341 | } else { | 2344 | } else { |
2342 | fn += ".ics"; | 2345 | fn += ".ics"; |
2343 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2346 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2344 | storage.save(); | 2347 | storage.save(); |
2345 | } | 2348 | } |
2346 | delete cal; | 2349 | delete cal; |
2347 | mes = i18n("KO/Pi: Ready for beaming"); | 2350 | mes = i18n("KO/Pi: Ready for beaming"); |
2348 | topLevelWidget()->setCaption(mes); | 2351 | topLevelWidget()->setCaption(mes); |
2349 | KApplication::convert2latin1( fn ); | 2352 | KApplication::convert2latin1( fn ); |
2350 | #ifndef DESKTOP_VERSION | 2353 | #ifndef DESKTOP_VERSION |
2351 | Ir *ir = new Ir( this ); | 2354 | Ir *ir = new Ir( this ); |
2352 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2355 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2353 | ir->send( fn, description, "text/x-vCalendar" ); | 2356 | ir->send( fn, description, "text/x-vCalendar" ); |
2354 | #endif | 2357 | #endif |
2355 | } | 2358 | } |
2356 | } | 2359 | } |
2357 | void CalendarView::beamDone( Ir *ir ) | 2360 | void CalendarView::beamDone( Ir *ir ) |
2358 | { | 2361 | { |
2359 | #ifndef DESKTOP_VERSION | 2362 | #ifndef DESKTOP_VERSION |
2360 | delete ir; | 2363 | delete ir; |
2361 | #endif | 2364 | #endif |
2362 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2365 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2363 | topLevelWidget()->raise(); | 2366 | topLevelWidget()->raise(); |
2364 | } | 2367 | } |
2365 | 2368 | ||
2366 | void CalendarView::moveIncidence(Incidence * inc ) | 2369 | void CalendarView::moveIncidence(Incidence * inc ) |
2367 | { | 2370 | { |
2368 | if ( !inc ) return; | 2371 | if ( !inc ) return; |
2369 | // qDebug("showDatePickerForIncidence( ) "); | 2372 | // qDebug("showDatePickerForIncidence( ) "); |
2370 | if ( mDateFrame->isVisible() ) | 2373 | if ( mDateFrame->isVisible() ) |
2371 | mDateFrame->hide(); | 2374 | mDateFrame->hide(); |
2372 | else { | 2375 | else { |
2373 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2376 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2374 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2377 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2375 | int dw = QApplication::desktop()->width(); | 2378 | int dw = QApplication::desktop()->width(); |
2376 | int dh = QApplication::desktop()->height(); | 2379 | int dh = QApplication::desktop()->height(); |
2377 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2380 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2378 | mDateFrame->show(); | 2381 | mDateFrame->show(); |
2379 | } | 2382 | } |
2380 | mDatePickerMode = 2; | 2383 | mDatePickerMode = 2; |
2381 | mMoveIncidence = inc ; | 2384 | mMoveIncidence = inc ; |
2382 | QDate da; | 2385 | QDate da; |
2383 | if ( mMoveIncidence->type() == "Todo" ) { | 2386 | if ( mMoveIncidence->type() == "Todo" ) { |
2384 | Todo * to = (Todo *) mMoveIncidence; | 2387 | Todo * to = (Todo *) mMoveIncidence; |
2385 | if ( to->hasDueDate() ) | 2388 | if ( to->hasDueDate() ) |
2386 | da = to->dtDue().date(); | 2389 | da = to->dtDue().date(); |
2387 | else | 2390 | else |
2388 | da = QDate::currentDate(); | 2391 | da = QDate::currentDate(); |
2389 | } else { | 2392 | } else { |
2390 | da = mMoveIncidence->dtStart().date(); | 2393 | da = mMoveIncidence->dtStart().date(); |
2391 | } | 2394 | } |
2392 | mDatePicker->setDate( da ); | 2395 | mDatePicker->setDate( da ); |
2393 | } | 2396 | } |
2394 | void CalendarView::showDatePicker( ) | 2397 | void CalendarView::showDatePicker( ) |
2395 | { | 2398 | { |
2396 | //qDebug("CalendarView::showDatePicker( ) "); | 2399 | //qDebug("CalendarView::showDatePicker( ) "); |
2397 | if ( mDateFrame->isVisible() ) | 2400 | if ( mDateFrame->isVisible() ) |
2398 | mDateFrame->hide(); | 2401 | mDateFrame->hide(); |
2399 | else { | 2402 | else { |
2400 | int w =mDatePicker->sizeHint().width() ; | 2403 | int w =mDatePicker->sizeHint().width() ; |
2401 | int h = mDatePicker->sizeHint().height() ; | 2404 | int h = mDatePicker->sizeHint().height() ; |
2402 | int dw = QApplication::desktop()->width(); | 2405 | int dw = QApplication::desktop()->width(); |
2403 | int dh = QApplication::desktop()->height(); | 2406 | int dh = QApplication::desktop()->height(); |
2404 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2407 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2405 | mDateFrame->show(); | 2408 | mDateFrame->show(); |
2406 | } | 2409 | } |
2407 | mDatePickerMode = 1; | 2410 | mDatePickerMode = 1; |
2408 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2411 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2409 | } | 2412 | } |
2410 | 2413 | ||
2411 | void CalendarView::showEventEditor() | 2414 | void CalendarView::showEventEditor() |
2412 | { | 2415 | { |
2413 | #ifdef DESKTOP_VERSION | 2416 | #ifdef DESKTOP_VERSION |
2414 | mEventEditor->show(); | 2417 | mEventEditor->show(); |
2415 | #else | 2418 | #else |
2416 | mEventEditor->showMaximized(); | 2419 | mEventEditor->showMaximized(); |
2417 | #endif | 2420 | #endif |
2418 | } | 2421 | } |
2419 | void CalendarView::showTodoEditor() | 2422 | void CalendarView::showTodoEditor() |
2420 | { | 2423 | { |
2421 | #ifdef DESKTOP_VERSION | 2424 | #ifdef DESKTOP_VERSION |
2422 | mTodoEditor->show(); | 2425 | mTodoEditor->show(); |
2423 | #else | 2426 | #else |
2424 | mTodoEditor->showMaximized(); | 2427 | mTodoEditor->showMaximized(); |
2425 | #endif | 2428 | #endif |
2426 | } | 2429 | } |
2427 | 2430 | ||
2428 | void CalendarView::cloneIncidence() | 2431 | void CalendarView::cloneIncidence() |
2429 | { | 2432 | { |
2430 | Incidence *incidence = currentSelection(); | 2433 | Incidence *incidence = currentSelection(); |
2431 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2434 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2432 | if ( incidence ) { | 2435 | if ( incidence ) { |
2433 | cloneIncidence(incidence); | 2436 | cloneIncidence(incidence); |
2434 | } | 2437 | } |
2435 | } | 2438 | } |
2436 | void CalendarView::moveIncidence() | 2439 | void CalendarView::moveIncidence() |
2437 | { | 2440 | { |
2438 | Incidence *incidence = currentSelection(); | 2441 | Incidence *incidence = currentSelection(); |
2439 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2442 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2440 | if ( incidence ) { | 2443 | if ( incidence ) { |
2441 | moveIncidence(incidence); | 2444 | moveIncidence(incidence); |
2442 | } | 2445 | } |
2443 | } | 2446 | } |
2444 | void CalendarView::beamIncidence() | 2447 | void CalendarView::beamIncidence() |
2445 | { | 2448 | { |
2446 | Incidence *incidence = currentSelection(); | 2449 | Incidence *incidence = currentSelection(); |
2447 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2450 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2448 | if ( incidence ) { | 2451 | if ( incidence ) { |
2449 | beamIncidence(incidence); | 2452 | beamIncidence(incidence); |
2450 | } | 2453 | } |
2451 | } | 2454 | } |
2452 | void CalendarView::toggleCancelIncidence() | 2455 | void CalendarView::toggleCancelIncidence() |
2453 | { | 2456 | { |
2454 | Incidence *incidence = currentSelection(); | 2457 | Incidence *incidence = currentSelection(); |
2455 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2458 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2456 | if ( incidence ) { | 2459 | if ( incidence ) { |
2457 | cancelIncidence(incidence); | 2460 | cancelIncidence(incidence); |
2458 | } | 2461 | } |
2459 | } | 2462 | } |
2460 | 2463 | ||
2461 | 2464 | ||
2462 | void CalendarView::cancelIncidence(Incidence * inc ) | 2465 | void CalendarView::cancelIncidence(Incidence * inc ) |
2463 | { | 2466 | { |
2464 | inc->setCancelled( ! inc->cancelled() ); | 2467 | inc->setCancelled( ! inc->cancelled() ); |
2465 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2468 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2466 | updateView(); | 2469 | updateView(); |
2467 | } | 2470 | } |
2468 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2471 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2469 | { | 2472 | { |
2470 | Incidence * newInc = orgInc->clone(); | 2473 | Incidence * newInc = orgInc->clone(); |
2471 | newInc->recreate(); | 2474 | newInc->recreate(); |
2472 | 2475 | ||
2473 | if ( newInc->type() == "Todo" ) { | 2476 | if ( newInc->type() == "Todo" ) { |
2474 | Todo* t = (Todo*) newInc; | 2477 | Todo* t = (Todo*) newInc; |
2475 | mTodoEditor->editTodo( t ); | 2478 | mTodoEditor->editTodo( t ); |
2476 | showTodoEditor(); | 2479 | showTodoEditor(); |
2477 | if ( mTodoEditor->exec() ) { | 2480 | if ( mTodoEditor->exec() ) { |
2478 | mCalendar->addTodo( t ); | 2481 | mCalendar->addTodo( t ); |
2479 | updateView(); | 2482 | updateView(); |
2480 | } else { | 2483 | } else { |
2481 | delete t; | 2484 | delete t; |
2482 | } | 2485 | } |
2483 | } | 2486 | } |
2484 | else { | 2487 | else { |
2485 | Event* e = (Event*) newInc; | 2488 | Event* e = (Event*) newInc; |
2486 | mEventEditor->editEvent( e ); | 2489 | mEventEditor->editEvent( e ); |
2487 | showEventEditor(); | 2490 | showEventEditor(); |
2488 | if ( mEventEditor->exec() ) { | 2491 | if ( mEventEditor->exec() ) { |
2489 | mCalendar->addEvent( e ); | 2492 | mCalendar->addEvent( e ); |
2490 | updateView(); | 2493 | updateView(); |
2491 | } else { | 2494 | } else { |
2492 | delete e; | 2495 | delete e; |
2493 | } | 2496 | } |
2494 | } | 2497 | } |
2495 | } | 2498 | } |
2496 | 2499 | ||
2497 | void CalendarView::newEvent() | 2500 | void CalendarView::newEvent() |
2498 | { | 2501 | { |
2499 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2502 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2500 | KOAgendaView *aView = mViewManager->agendaView(); | 2503 | KOAgendaView *aView = mViewManager->agendaView(); |
2501 | if (aView) { | 2504 | if (aView) { |
2502 | if (aView->selectionStart().isValid()) { | 2505 | if (aView->selectionStart().isValid()) { |
2503 | if (aView->selectedIsAllDay()) { | 2506 | if (aView->selectedIsAllDay()) { |
2504 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2507 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2505 | } else { | 2508 | } else { |
2506 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2509 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2507 | } | 2510 | } |
2508 | return; | 2511 | return; |
2509 | } | 2512 | } |
2510 | } | 2513 | } |
2511 | 2514 | ||
2512 | QDate date = mNavigator->selectedDates().first(); | 2515 | QDate date = mNavigator->selectedDates().first(); |
2513 | QDateTime current = QDateTime::currentDateTime(); | 2516 | QDateTime current = QDateTime::currentDateTime(); |
2514 | if ( date <= current.date() ) { | 2517 | if ( date <= current.date() ) { |
2515 | int hour = current.time().hour() +1; | 2518 | int hour = current.time().hour() +1; |
2516 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2519 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2517 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2520 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2518 | } else | 2521 | } else |
2519 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2522 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2520 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2523 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2521 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2524 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2522 | } | 2525 | } |
2523 | 2526 | ||
2524 | void CalendarView::newEvent(QDateTime fh) | 2527 | void CalendarView::newEvent(QDateTime fh) |
2525 | { | 2528 | { |
2526 | newEvent(fh, | 2529 | newEvent(fh, |
2527 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2530 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2528 | } | 2531 | } |
2529 | 2532 | ||
2530 | void CalendarView::newEvent(QDate dt) | 2533 | void CalendarView::newEvent(QDate dt) |
2531 | { | 2534 | { |
2532 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2535 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2533 | QDateTime(dt, QTime(0,0,0)), true); | 2536 | QDateTime(dt, QTime(0,0,0)), true); |
2534 | } | 2537 | } |
2535 | 2538 | ||
2536 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2539 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2537 | { | 2540 | { |
2538 | 2541 | ||
2539 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2542 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2540 | if ( mFilterView->filtersEnabled() ) { | 2543 | if ( mFilterView->filtersEnabled() ) { |
2541 | CalFilter *filter = mFilterView->selectedFilter(); | 2544 | CalFilter *filter = mFilterView->selectedFilter(); |
2542 | if (filter && filter->showCategories()) { | 2545 | if (filter && filter->showCategories()) { |
2543 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2546 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2544 | } | 2547 | } |
2545 | if ( filter ) | 2548 | if ( filter ) |
2546 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2549 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2547 | } | 2550 | } |
2548 | showEventEditor(); | 2551 | showEventEditor(); |
2549 | } | 2552 | } |
2550 | void CalendarView::todoAdded(Todo * t) | 2553 | void CalendarView::todoAdded(Todo * t) |
2551 | { | 2554 | { |
2552 | 2555 | ||
2553 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2556 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2554 | updateTodoViews(); | 2557 | updateTodoViews(); |
2555 | } | 2558 | } |
2556 | void CalendarView::todoChanged(Todo * t) | 2559 | void CalendarView::todoChanged(Todo * t) |
2557 | { | 2560 | { |
2558 | emit todoModified( t, 4 ); | 2561 | emit todoModified( t, 4 ); |
2559 | // updateTodoViews(); | 2562 | // updateTodoViews(); |
2560 | } | 2563 | } |
2561 | void CalendarView::todoToBeDeleted(Todo *) | 2564 | void CalendarView::todoToBeDeleted(Todo *) |
2562 | { | 2565 | { |
2563 | //qDebug("todoToBeDeleted(Todo *) "); | 2566 | //qDebug("todoToBeDeleted(Todo *) "); |
2564 | updateTodoViews(); | 2567 | updateTodoViews(); |
2565 | } | 2568 | } |
2566 | void CalendarView::todoDeleted() | 2569 | void CalendarView::todoDeleted() |
2567 | { | 2570 | { |
2568 | //qDebug(" todoDeleted()"); | 2571 | //qDebug(" todoDeleted()"); |
2569 | updateTodoViews(); | 2572 | updateTodoViews(); |
2570 | } | 2573 | } |
2571 | 2574 | ||
2572 | 2575 | ||
2573 | 2576 | ||
2574 | void CalendarView::newTodo() | 2577 | void CalendarView::newTodo() |
2575 | { | 2578 | { |
2576 | 2579 | ||
2577 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2580 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2578 | if ( mFilterView->filtersEnabled() ) { | 2581 | if ( mFilterView->filtersEnabled() ) { |
2579 | CalFilter *filter = mFilterView->selectedFilter(); | 2582 | CalFilter *filter = mFilterView->selectedFilter(); |
2580 | if (filter && filter->showCategories()) { | 2583 | if (filter && filter->showCategories()) { |
2581 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2584 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2582 | } | 2585 | } |
2583 | if ( filter ) | 2586 | if ( filter ) |
2584 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2587 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2585 | } | 2588 | } |
2586 | showTodoEditor(); | 2589 | showTodoEditor(); |
2587 | } | 2590 | } |
2588 | 2591 | ||
2589 | void CalendarView::newSubTodo() | 2592 | void CalendarView::newSubTodo() |
2590 | { | 2593 | { |
2591 | Todo *todo = selectedTodo(); | 2594 | Todo *todo = selectedTodo(); |
2592 | if ( todo ) newSubTodo( todo ); | 2595 | if ( todo ) newSubTodo( todo ); |
2593 | } | 2596 | } |
2594 | 2597 | ||
2595 | void CalendarView::newSubTodo(Todo *parentEvent) | 2598 | void CalendarView::newSubTodo(Todo *parentEvent) |
2596 | { | 2599 | { |
2597 | 2600 | ||
2598 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2601 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2599 | showTodoEditor(); | 2602 | showTodoEditor(); |
2600 | } | 2603 | } |
2601 | 2604 | ||
2602 | void CalendarView::newFloatingEvent() | 2605 | void CalendarView::newFloatingEvent() |
2603 | { | 2606 | { |
2604 | DateList tmpList = mNavigator->selectedDates(); | 2607 | DateList tmpList = mNavigator->selectedDates(); |
2605 | QDate date = tmpList.first(); | 2608 | QDate date = tmpList.first(); |
2606 | 2609 | ||
2607 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2610 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2608 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2611 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2609 | } | 2612 | } |
2610 | 2613 | ||
2611 | 2614 | ||
2612 | void CalendarView::editEvent( Event *event ) | 2615 | void CalendarView::editEvent( Event *event ) |
2613 | { | 2616 | { |
2614 | 2617 | ||
2615 | if ( !event ) return; | 2618 | if ( !event ) return; |
2616 | if ( event->isReadOnly() ) { | 2619 | if ( event->isReadOnly() ) { |
2617 | showEvent( event ); | 2620 | showEvent( event ); |
2618 | return; | 2621 | return; |
2619 | } | 2622 | } |
2620 | mEventEditor->editEvent( event , mFlagEditDescription); | 2623 | mEventEditor->editEvent( event , mFlagEditDescription); |
2621 | showEventEditor(); | 2624 | showEventEditor(); |
2622 | } | 2625 | } |
2623 | void CalendarView::editJournal( Journal *jour ) | 2626 | void CalendarView::editJournal( Journal *jour ) |
2624 | { | 2627 | { |
2625 | if ( !jour ) return; | 2628 | if ( !jour ) return; |
2626 | mDialogManager->hideSearchDialog(); | 2629 | mDialogManager->hideSearchDialog(); |
2627 | mViewManager->showJournalView(); | 2630 | mViewManager->showJournalView(); |
2628 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2631 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2629 | } | 2632 | } |
2630 | void CalendarView::editTodo( Todo *todo ) | 2633 | void CalendarView::editTodo( Todo *todo ) |
2631 | { | 2634 | { |
2632 | if ( !todo ) return; | 2635 | if ( !todo ) return; |
2633 | 2636 | ||
2634 | if ( todo->isReadOnly() ) { | 2637 | if ( todo->isReadOnly() ) { |
2635 | showTodo( todo ); | 2638 | showTodo( todo ); |
2636 | return; | 2639 | return; |
2637 | } | 2640 | } |
2638 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2641 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2639 | showTodoEditor(); | 2642 | showTodoEditor(); |
2640 | 2643 | ||
2641 | } | 2644 | } |
2642 | 2645 | ||
2643 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2646 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2644 | { | 2647 | { |
2645 | if ( !mEventViewerDialog ) { | 2648 | if ( !mEventViewerDialog ) { |
2646 | mEventViewerDialog = new KOEventViewerDialog(this); | 2649 | mEventViewerDialog = new KOEventViewerDialog(this); |
2647 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2650 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2648 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2651 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2649 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2652 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2650 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2653 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2651 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2654 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2652 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2655 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2653 | mEventViewerDialog->resize( 640, 480 ); | 2656 | mEventViewerDialog->resize( 640, 480 ); |
2654 | 2657 | ||
2655 | } | 2658 | } |
2656 | return mEventViewerDialog; | 2659 | return mEventViewerDialog; |
2657 | } | 2660 | } |
2658 | void CalendarView::showEvent(Event *event) | 2661 | void CalendarView::showEvent(Event *event) |
2659 | { | 2662 | { |
2660 | getEventViewerDialog()->setEvent(event); | 2663 | getEventViewerDialog()->setEvent(event); |
2661 | getEventViewerDialog()->showMe(); | 2664 | getEventViewerDialog()->showMe(); |
2662 | } | 2665 | } |
2663 | 2666 | ||
2664 | void CalendarView::showTodo(Todo *event) | 2667 | void CalendarView::showTodo(Todo *event) |
2665 | { | 2668 | { |
2666 | getEventViewerDialog()->setTodo(event); | 2669 | getEventViewerDialog()->setTodo(event); |
2667 | getEventViewerDialog()->showMe(); | 2670 | getEventViewerDialog()->showMe(); |
2668 | } | 2671 | } |
2669 | void CalendarView::showJournal( Journal *jour ) | 2672 | void CalendarView::showJournal( Journal *jour ) |
2670 | { | 2673 | { |
2671 | getEventViewerDialog()->setJournal(jour); | 2674 | getEventViewerDialog()->setJournal(jour); |
2672 | getEventViewerDialog()->showMe(); | 2675 | getEventViewerDialog()->showMe(); |
2673 | 2676 | ||
2674 | } | 2677 | } |
2675 | // void CalendarView::todoModified (Todo *event, int changed) | 2678 | // void CalendarView::todoModified (Todo *event, int changed) |
2676 | // { | 2679 | // { |
2677 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2680 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2678 | // // kdDebug() << "Todo modified and open" << endl; | 2681 | // // kdDebug() << "Todo modified and open" << endl; |
2679 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2682 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2680 | // // temp->modified (changed); | 2683 | // // temp->modified (changed); |
2681 | 2684 | ||
2682 | // // } | 2685 | // // } |
2683 | 2686 | ||
2684 | // mViewManager->updateView(); | 2687 | // mViewManager->updateView(); |
2685 | // } | 2688 | // } |
2686 | 2689 | ||
2687 | void CalendarView::appointment_show() | 2690 | void CalendarView::appointment_show() |
2688 | { | 2691 | { |
2689 | Event *anEvent = 0; | 2692 | Event *anEvent = 0; |
2690 | 2693 | ||
2691 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2694 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2692 | 2695 | ||
2693 | if (mViewManager->currentView()->isEventView()) { | 2696 | if (mViewManager->currentView()->isEventView()) { |
2694 | if ( incidence && incidence->type() == "Event" ) { | 2697 | if ( incidence && incidence->type() == "Event" ) { |
2695 | anEvent = static_cast<Event *>(incidence); | 2698 | anEvent = static_cast<Event *>(incidence); |
2696 | } | 2699 | } |
2697 | } | 2700 | } |
2698 | 2701 | ||
2699 | if (!anEvent) { | 2702 | if (!anEvent) { |
2700 | KNotifyClient::beep(); | 2703 | KNotifyClient::beep(); |
2701 | return; | 2704 | return; |
2702 | } | 2705 | } |
2703 | 2706 | ||
2704 | showEvent(anEvent); | 2707 | showEvent(anEvent); |
2705 | } | 2708 | } |
2706 | 2709 | ||
2707 | void CalendarView::appointment_edit() | 2710 | void CalendarView::appointment_edit() |
2708 | { | 2711 | { |
2709 | Event *anEvent = 0; | 2712 | Event *anEvent = 0; |
2710 | 2713 | ||
2711 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2714 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2712 | 2715 | ||
2713 | if (mViewManager->currentView()->isEventView()) { | 2716 | if (mViewManager->currentView()->isEventView()) { |
2714 | if ( incidence && incidence->type() == "Event" ) { | 2717 | if ( incidence && incidence->type() == "Event" ) { |
2715 | anEvent = static_cast<Event *>(incidence); | 2718 | anEvent = static_cast<Event *>(incidence); |
2716 | } | 2719 | } |
2717 | } | 2720 | } |
2718 | 2721 | ||
2719 | if (!anEvent) { | 2722 | if (!anEvent) { |
2720 | KNotifyClient::beep(); | 2723 | KNotifyClient::beep(); |
2721 | return; | 2724 | return; |
2722 | } | 2725 | } |
2723 | 2726 | ||
2724 | editEvent(anEvent); | 2727 | editEvent(anEvent); |
2725 | } | 2728 | } |
2726 | 2729 | ||
2727 | void CalendarView::appointment_delete() | 2730 | void CalendarView::appointment_delete() |
2728 | { | 2731 | { |
2729 | Event *anEvent = 0; | 2732 | Event *anEvent = 0; |
2730 | 2733 | ||
2731 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2734 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2732 | 2735 | ||
2733 | if (mViewManager->currentView()->isEventView()) { | 2736 | if (mViewManager->currentView()->isEventView()) { |
2734 | if ( incidence && incidence->type() == "Event" ) { | 2737 | if ( incidence && incidence->type() == "Event" ) { |
2735 | anEvent = static_cast<Event *>(incidence); | 2738 | anEvent = static_cast<Event *>(incidence); |
2736 | } | 2739 | } |
2737 | } | 2740 | } |
2738 | 2741 | ||
2739 | if (!anEvent) { | 2742 | if (!anEvent) { |
2740 | KNotifyClient::beep(); | 2743 | KNotifyClient::beep(); |
2741 | return; | 2744 | return; |
2742 | } | 2745 | } |
2743 | 2746 | ||
2744 | deleteEvent(anEvent); | 2747 | deleteEvent(anEvent); |
2745 | } | 2748 | } |
2746 | 2749 | ||
2747 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2750 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2748 | { | 2751 | { |
2749 | if (!sub) return; | 2752 | if (!sub) return; |
2750 | if (!parent) return; | 2753 | if (!parent) return; |
2751 | if ( sub->relatedTo() ) | 2754 | if ( sub->relatedTo() ) |
2752 | sub->relatedTo()->removeRelation(sub); | 2755 | sub->relatedTo()->removeRelation(sub); |
2753 | sub->setRelatedTo(parent); | 2756 | sub->setRelatedTo(parent); |
2754 | sub->setRelatedToUid(parent->uid()); | 2757 | sub->setRelatedToUid(parent->uid()); |
2755 | parent->addRelation(sub); | 2758 | parent->addRelation(sub); |
2756 | sub->updated(); | 2759 | sub->updated(); |
2757 | parent->updated(); | 2760 | parent->updated(); |
2758 | setModified(true); | 2761 | setModified(true); |
2759 | updateView(); | 2762 | updateView(); |
2760 | } | 2763 | } |
2761 | void CalendarView::todo_unsub(Todo *anTodo ) | 2764 | void CalendarView::todo_unsub(Todo *anTodo ) |
2762 | { | 2765 | { |
2763 | // Todo *anTodo = selectedTodo(); | 2766 | // Todo *anTodo = selectedTodo(); |
2764 | if (!anTodo) return; | 2767 | if (!anTodo) return; |
2765 | if (!anTodo->relatedTo()) return; | 2768 | if (!anTodo->relatedTo()) return; |
2766 | anTodo->relatedTo()->removeRelation(anTodo); | 2769 | anTodo->relatedTo()->removeRelation(anTodo); |
2767 | anTodo->setRelatedTo(0); | 2770 | anTodo->setRelatedTo(0); |
2768 | anTodo->updated(); | 2771 | anTodo->updated(); |
2769 | anTodo->setRelatedToUid(""); | 2772 | anTodo->setRelatedToUid(""); |
2770 | setModified(true); | 2773 | setModified(true); |
2771 | updateView(); | 2774 | updateView(); |
2772 | } | 2775 | } |
2773 | 2776 | ||
2774 | void CalendarView::deleteTodo(Todo *todo) | 2777 | void CalendarView::deleteTodo(Todo *todo) |
2775 | { | 2778 | { |
2776 | if (!todo) { | 2779 | if (!todo) { |
2777 | KNotifyClient::beep(); | 2780 | KNotifyClient::beep(); |
2778 | return; | 2781 | return; |
2779 | } | 2782 | } |
2780 | if (KOPrefs::instance()->mConfirm) { | 2783 | if (KOPrefs::instance()->mConfirm) { |
2781 | switch (msgItemDelete()) { | 2784 | switch (msgItemDelete()) { |
2782 | case KMessageBox::Continue: // OK | 2785 | case KMessageBox::Continue: // OK |
2783 | if (!todo->relations().isEmpty()) { | 2786 | if (!todo->relations().isEmpty()) { |
2784 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2787 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2785 | i18n("Delete To-Do")); | 2788 | i18n("Delete To-Do")); |
2786 | } else { | 2789 | } else { |
2787 | checkExternalId( todo ); | 2790 | checkExternalId( todo ); |
2788 | calendar()->deleteTodo(todo); | 2791 | calendar()->deleteTodo(todo); |
2789 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2792 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2790 | updateView(); | 2793 | updateView(); |
2791 | } | 2794 | } |
2792 | break; | 2795 | break; |
2793 | } // switch | 2796 | } // switch |
2794 | } else { | 2797 | } else { |
2795 | if (!todo->relations().isEmpty()) { | 2798 | if (!todo->relations().isEmpty()) { |
2796 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2799 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2797 | i18n("Delete To-Do")); | 2800 | i18n("Delete To-Do")); |
2798 | } else { | 2801 | } else { |
2799 | checkExternalId( todo ); | 2802 | checkExternalId( todo ); |
2800 | mCalendar->deleteTodo(todo); | 2803 | mCalendar->deleteTodo(todo); |
2801 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2804 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2802 | updateView(); | 2805 | updateView(); |
2803 | } | 2806 | } |
2804 | } | 2807 | } |
2805 | emit updateSearchDialog(); | 2808 | emit updateSearchDialog(); |
2806 | } | 2809 | } |
2807 | void CalendarView::deleteJournal(Journal *jour) | 2810 | void CalendarView::deleteJournal(Journal *jour) |
2808 | { | 2811 | { |
2809 | if (!jour) { | 2812 | if (!jour) { |
2810 | KNotifyClient::beep(); | 2813 | KNotifyClient::beep(); |
2811 | return; | 2814 | return; |
2812 | } | 2815 | } |
2813 | if (KOPrefs::instance()->mConfirm) { | 2816 | if (KOPrefs::instance()->mConfirm) { |
2814 | switch (msgItemDelete()) { | 2817 | switch (msgItemDelete()) { |
2815 | case KMessageBox::Continue: // OK | 2818 | case KMessageBox::Continue: // OK |
2816 | calendar()->deleteJournal(jour); | 2819 | calendar()->deleteJournal(jour); |
2817 | updateView(); | 2820 | updateView(); |
2818 | break; | 2821 | break; |
2819 | } // switch | 2822 | } // switch |
2820 | } else { | 2823 | } else { |
2821 | calendar()->deleteJournal(jour);; | 2824 | calendar()->deleteJournal(jour);; |
2822 | updateView(); | 2825 | updateView(); |
2823 | } | 2826 | } |
2824 | emit updateSearchDialog(); | 2827 | emit updateSearchDialog(); |
2825 | } | 2828 | } |
2826 | 2829 | ||
2827 | void CalendarView::deleteEvent(Event *anEvent) | 2830 | void CalendarView::deleteEvent(Event *anEvent) |
2828 | { | 2831 | { |
2829 | if (!anEvent) { | 2832 | if (!anEvent) { |
2830 | KNotifyClient::beep(); | 2833 | KNotifyClient::beep(); |
2831 | return; | 2834 | return; |
2832 | } | 2835 | } |
2833 | 2836 | ||
2834 | if (anEvent->recurrence()->doesRecur()) { | 2837 | if (anEvent->recurrence()->doesRecur()) { |
2835 | QDate itemDate = mViewManager->currentSelectionDate(); | 2838 | QDate itemDate = mViewManager->currentSelectionDate(); |
2836 | int km; | 2839 | int km; |
2837 | if (!itemDate.isValid()) { | 2840 | if (!itemDate.isValid()) { |
2838 | //kdDebug() << "Date Not Valid" << endl; | 2841 | //kdDebug() << "Date Not Valid" << endl; |
2839 | if (KOPrefs::instance()->mConfirm) { | 2842 | if (KOPrefs::instance()->mConfirm) { |
2840 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2843 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2841 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2844 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2842 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2845 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2843 | if ( km == KMessageBox::Continue ) | 2846 | if ( km == KMessageBox::Continue ) |
2844 | km = KMessageBox::No; // No = all below | 2847 | km = KMessageBox::No; // No = all below |
2845 | } else | 2848 | } else |
2846 | km = KMessageBox::No; | 2849 | km = KMessageBox::No; |
2847 | } else { | 2850 | } else { |
2848 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2851 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2849 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2852 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2850 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2853 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2851 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2854 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2852 | i18n("All")); | 2855 | i18n("All")); |
2853 | } | 2856 | } |
2854 | switch(km) { | 2857 | switch(km) { |
2855 | 2858 | ||
2856 | case KMessageBox::No: // Continue // all | 2859 | case KMessageBox::No: // Continue // all |
2857 | //qDebug("KMessageBox::No "); | 2860 | //qDebug("KMessageBox::No "); |
2858 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2861 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2859 | schedule(Scheduler::Cancel,anEvent); | 2862 | schedule(Scheduler::Cancel,anEvent); |
2860 | 2863 | ||
2861 | checkExternalId( anEvent); | 2864 | checkExternalId( anEvent); |
2862 | mCalendar->deleteEvent(anEvent); | 2865 | mCalendar->deleteEvent(anEvent); |
2863 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2866 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2864 | break; | 2867 | break; |
2865 | 2868 | ||
2866 | // Disabled because it does not work | 2869 | // Disabled because it does not work |
2867 | //#if 0 | 2870 | //#if 0 |
2868 | case KMessageBox::Yes: // just this one | 2871 | case KMessageBox::Yes: // just this one |
2869 | //QDate qd = mNavigator->selectedDates().first(); | 2872 | //QDate qd = mNavigator->selectedDates().first(); |
2870 | //if (!qd.isValid()) { | 2873 | //if (!qd.isValid()) { |
2871 | // kdDebug() << "no date selected, or invalid date" << endl; | 2874 | // kdDebug() << "no date selected, or invalid date" << endl; |
2872 | // KNotifyClient::beep(); | 2875 | // KNotifyClient::beep(); |
2873 | // return; | 2876 | // return; |
2874 | //} | 2877 | //} |
2875 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2878 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2876 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2879 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2877 | anEvent->addExDate(itemDate); | 2880 | anEvent->addExDate(itemDate); |
2878 | int duration = anEvent->recurrence()->duration(); | 2881 | int duration = anEvent->recurrence()->duration(); |
2879 | if ( duration > 0 ) { | 2882 | if ( duration > 0 ) { |
2880 | anEvent->recurrence()->setDuration( duration - 1 ); | 2883 | anEvent->recurrence()->setDuration( duration - 1 ); |
2881 | } | 2884 | } |
2882 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2885 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2883 | } | 2886 | } |
2884 | break; | 2887 | break; |
2885 | //#endif | 2888 | //#endif |
2886 | } // switch | 2889 | } // switch |
2887 | } else { | 2890 | } else { |
2888 | if (KOPrefs::instance()->mConfirm) { | 2891 | if (KOPrefs::instance()->mConfirm) { |
2889 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2892 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2890 | i18n("\nAre you sure you want\nto delete this event?"), | 2893 | i18n("\nAre you sure you want\nto delete this event?"), |
2891 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2894 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2892 | case KMessageBox::Continue: // OK | 2895 | case KMessageBox::Continue: // OK |
2893 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2896 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2894 | schedule(Scheduler::Cancel,anEvent); | 2897 | schedule(Scheduler::Cancel,anEvent); |
2895 | checkExternalId( anEvent); | 2898 | checkExternalId( anEvent); |
2896 | mCalendar->deleteEvent(anEvent); | 2899 | mCalendar->deleteEvent(anEvent); |
2897 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2900 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2898 | break; | 2901 | break; |
2899 | } // switch | 2902 | } // switch |
2900 | } else { | 2903 | } else { |
2901 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2904 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2902 | schedule(Scheduler::Cancel,anEvent); | 2905 | schedule(Scheduler::Cancel,anEvent); |
2903 | checkExternalId( anEvent); | 2906 | checkExternalId( anEvent); |
2904 | mCalendar->deleteEvent(anEvent); | 2907 | mCalendar->deleteEvent(anEvent); |
2905 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2908 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2906 | } | 2909 | } |
2907 | } // if-else | 2910 | } // if-else |
2908 | emit updateSearchDialog(); | 2911 | emit updateSearchDialog(); |
2909 | } | 2912 | } |
2910 | 2913 | ||
2911 | bool CalendarView::deleteEvent(const QString &uid) | 2914 | bool CalendarView::deleteEvent(const QString &uid) |
2912 | { | 2915 | { |
2913 | Event *ev = mCalendar->event(uid); | 2916 | Event *ev = mCalendar->event(uid); |
2914 | if (ev) { | 2917 | if (ev) { |
2915 | deleteEvent(ev); | 2918 | deleteEvent(ev); |
2916 | return true; | 2919 | return true; |
2917 | } else { | 2920 | } else { |
2918 | return false; | 2921 | return false; |
2919 | } | 2922 | } |
2920 | } | 2923 | } |
2921 | 2924 | ||
2922 | /*****************************************************************************/ | 2925 | /*****************************************************************************/ |
2923 | 2926 | ||
2924 | void CalendarView::action_mail() | 2927 | void CalendarView::action_mail() |
2925 | { | 2928 | { |
2926 | #ifndef KORG_NOMAIL | 2929 | #ifndef KORG_NOMAIL |
2927 | KOMailClient mailClient; | 2930 | KOMailClient mailClient; |
2928 | 2931 | ||
2929 | Incidence *incidence = currentSelection(); | 2932 | Incidence *incidence = currentSelection(); |
2930 | 2933 | ||
2931 | if (!incidence) { | 2934 | if (!incidence) { |
2932 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2935 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2933 | return; | 2936 | return; |
2934 | } | 2937 | } |
2935 | if(incidence->attendeeCount() == 0 ) { | 2938 | if(incidence->attendeeCount() == 0 ) { |
2936 | KMessageBox::sorry(this, | 2939 | KMessageBox::sorry(this, |
2937 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2940 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2938 | return; | 2941 | return; |
2939 | } | 2942 | } |
2940 | 2943 | ||
2941 | CalendarLocal cal_tmp; | 2944 | CalendarLocal cal_tmp; |
2942 | Event *event = 0; | 2945 | Event *event = 0; |
2943 | Event *ev = 0; | 2946 | Event *ev = 0; |
2944 | if ( incidence && incidence->type() == "Event" ) { | 2947 | if ( incidence && incidence->type() == "Event" ) { |
2945 | event = static_cast<Event *>(incidence); | 2948 | event = static_cast<Event *>(incidence); |
2946 | ev = new Event(*event); | 2949 | ev = new Event(*event); |
2947 | cal_tmp.addEvent(ev); | 2950 | cal_tmp.addEvent(ev); |
2948 | } | 2951 | } |
2949 | ICalFormat mForm(); | 2952 | ICalFormat mForm(); |
2950 | QString attachment = mForm.toString( &cal_tmp ); | 2953 | QString attachment = mForm.toString( &cal_tmp ); |
2951 | if (ev) delete(ev); | 2954 | if (ev) delete(ev); |
2952 | 2955 | ||
2953 | mailClient.mailAttendees(currentSelection(), attachment); | 2956 | mailClient.mailAttendees(currentSelection(), attachment); |
2954 | 2957 | ||
2955 | #endif | 2958 | #endif |
2956 | 2959 | ||
2957 | #if 0 | 2960 | #if 0 |
2958 | Event *anEvent = 0; | 2961 | Event *anEvent = 0; |
2959 | if (mViewManager->currentView()->isEventView()) { | 2962 | if (mViewManager->currentView()->isEventView()) { |
2960 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2963 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2961 | } | 2964 | } |
2962 | 2965 | ||
2963 | if (!anEvent) { | 2966 | if (!anEvent) { |
2964 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2967 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2965 | return; | 2968 | return; |
2966 | } | 2969 | } |
2967 | if(anEvent->attendeeCount() == 0 ) { | 2970 | if(anEvent->attendeeCount() == 0 ) { |
2968 | KMessageBox::sorry(this, | 2971 | KMessageBox::sorry(this, |
2969 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2972 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2970 | return; | 2973 | return; |
2971 | } | 2974 | } |
2972 | 2975 | ||
2973 | mailobject.emailEvent(anEvent); | 2976 | mailobject.emailEvent(anEvent); |
2974 | #endif | 2977 | #endif |
2975 | } | 2978 | } |
2976 | 2979 | ||
2977 | 2980 | ||
2978 | void CalendarView::schedule_publish(Incidence *incidence) | 2981 | void CalendarView::schedule_publish(Incidence *incidence) |
2979 | { | 2982 | { |
2980 | Event *event = 0; | 2983 | Event *event = 0; |
2981 | Todo *todo = 0; | 2984 | Todo *todo = 0; |
2982 | 2985 | ||
2983 | if (incidence == 0) { | 2986 | if (incidence == 0) { |
2984 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 2987 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
2985 | if (incidence == 0) { | 2988 | if (incidence == 0) { |
2986 | incidence = mTodoList->selectedIncidences().first(); | 2989 | incidence = mTodoList->selectedIncidences().first(); |
2987 | } | 2990 | } |
2988 | } | 2991 | } |
2989 | if ( incidence && incidence->type() == "Event" ) { | 2992 | if ( incidence && incidence->type() == "Event" ) { |
2990 | event = static_cast<Event *>(incidence); | 2993 | event = static_cast<Event *>(incidence); |
2991 | } else { | 2994 | } else { |
2992 | if ( incidence && incidence->type() == "Todo" ) { | 2995 | if ( incidence && incidence->type() == "Todo" ) { |
2993 | todo = static_cast<Todo *>(incidence); | 2996 | todo = static_cast<Todo *>(incidence); |
2994 | } | 2997 | } |
2995 | } | 2998 | } |
2996 | 2999 | ||
2997 | if (!event && !todo) { | 3000 | if (!event && !todo) { |
2998 | KMessageBox::sorry(this,i18n("No event selected.")); | 3001 | KMessageBox::sorry(this,i18n("No event selected.")); |
2999 | return; | 3002 | return; |
3000 | } | 3003 | } |
3001 | 3004 | ||
3002 | PublishDialog *publishdlg = new PublishDialog(); | 3005 | PublishDialog *publishdlg = new PublishDialog(); |
3003 | if (incidence->attendeeCount()>0) { | 3006 | if (incidence->attendeeCount()>0) { |
3004 | QPtrList<Attendee> attendees = incidence->attendees(); | 3007 | QPtrList<Attendee> attendees = incidence->attendees(); |
3005 | attendees.first(); | 3008 | attendees.first(); |
3006 | while ( attendees.current()!=0 ) { | 3009 | while ( attendees.current()!=0 ) { |
3007 | publishdlg->addAttendee(attendees.current()); | 3010 | publishdlg->addAttendee(attendees.current()); |
3008 | attendees.next(); | 3011 | attendees.next(); |
3009 | } | 3012 | } |
3010 | } | 3013 | } |
3011 | bool send = true; | 3014 | bool send = true; |
3012 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3015 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3013 | if ( publishdlg->exec() != QDialog::Accepted ) | 3016 | if ( publishdlg->exec() != QDialog::Accepted ) |
3014 | send = false; | 3017 | send = false; |
3015 | } | 3018 | } |
3016 | if ( send ) { | 3019 | if ( send ) { |
3017 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3020 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3018 | if ( event ) { | 3021 | if ( event ) { |
3019 | Event *ev = new Event(*event); | 3022 | Event *ev = new Event(*event); |
3020 | ev->registerObserver(0); | 3023 | ev->registerObserver(0); |
3021 | ev->clearAttendees(); | 3024 | ev->clearAttendees(); |
3022 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3025 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3023 | delete(ev); | 3026 | delete(ev); |
3024 | } | 3027 | } |
3025 | } else { | 3028 | } else { |
3026 | if ( todo ) { | 3029 | if ( todo ) { |
3027 | Todo *ev = new Todo(*todo); | 3030 | Todo *ev = new Todo(*todo); |
3028 | ev->registerObserver(0); | 3031 | ev->registerObserver(0); |
3029 | ev->clearAttendees(); | 3032 | ev->clearAttendees(); |
3030 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3033 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3031 | delete(ev); | 3034 | delete(ev); |
3032 | } | 3035 | } |
3033 | } | 3036 | } |
3034 | } | 3037 | } |
3035 | } | 3038 | } |
3036 | delete publishdlg; | 3039 | delete publishdlg; |
3037 | } | 3040 | } |
3038 | 3041 | ||
3039 | void CalendarView::schedule_request(Incidence *incidence) | 3042 | void CalendarView::schedule_request(Incidence *incidence) |
3040 | { | 3043 | { |
3041 | schedule(Scheduler::Request,incidence); | 3044 | schedule(Scheduler::Request,incidence); |
3042 | } | 3045 | } |
3043 | 3046 | ||
3044 | void CalendarView::schedule_refresh(Incidence *incidence) | 3047 | void CalendarView::schedule_refresh(Incidence *incidence) |
3045 | { | 3048 | { |
3046 | schedule(Scheduler::Refresh,incidence); | 3049 | schedule(Scheduler::Refresh,incidence); |
3047 | } | 3050 | } |
3048 | 3051 | ||
3049 | void CalendarView::schedule_cancel(Incidence *incidence) | 3052 | void CalendarView::schedule_cancel(Incidence *incidence) |
3050 | { | 3053 | { |
3051 | schedule(Scheduler::Cancel,incidence); | 3054 | schedule(Scheduler::Cancel,incidence); |
3052 | } | 3055 | } |
3053 | 3056 | ||
3054 | void CalendarView::schedule_add(Incidence *incidence) | 3057 | void CalendarView::schedule_add(Incidence *incidence) |
3055 | { | 3058 | { |
3056 | schedule(Scheduler::Add,incidence); | 3059 | schedule(Scheduler::Add,incidence); |
3057 | } | 3060 | } |
3058 | 3061 | ||
3059 | void CalendarView::schedule_reply(Incidence *incidence) | 3062 | void CalendarView::schedule_reply(Incidence *incidence) |
3060 | { | 3063 | { |
3061 | schedule(Scheduler::Reply,incidence); | 3064 | schedule(Scheduler::Reply,incidence); |
3062 | } | 3065 | } |
3063 | 3066 | ||
3064 | void CalendarView::schedule_counter(Incidence *incidence) | 3067 | void CalendarView::schedule_counter(Incidence *incidence) |
3065 | { | 3068 | { |
3066 | schedule(Scheduler::Counter,incidence); | 3069 | schedule(Scheduler::Counter,incidence); |
3067 | } | 3070 | } |
3068 | 3071 | ||
3069 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3072 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3070 | { | 3073 | { |
3071 | schedule(Scheduler::Declinecounter,incidence); | 3074 | schedule(Scheduler::Declinecounter,incidence); |
3072 | } | 3075 | } |
3073 | 3076 | ||
3074 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3077 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3075 | { | 3078 | { |
3076 | QDateTime start = QDateTime::currentDateTime(); | 3079 | QDateTime start = QDateTime::currentDateTime(); |
3077 | QDateTime end = start.addDays(daysToPublish); | 3080 | QDateTime end = start.addDays(daysToPublish); |
3078 | 3081 | ||
3079 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3082 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3080 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3083 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3081 | 3084 | ||
3082 | 3085 | ||
3083 | PublishDialog *publishdlg = new PublishDialog(); | 3086 | PublishDialog *publishdlg = new PublishDialog(); |
3084 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3087 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3085 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3088 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3086 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3089 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3087 | delete(freebusy); | 3090 | delete(freebusy); |
3088 | } | 3091 | } |
3089 | } | 3092 | } |
3090 | delete publishdlg; | 3093 | delete publishdlg; |
3091 | } | 3094 | } |
3092 | 3095 | ||
3093 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3096 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3094 | { | 3097 | { |
3095 | Event *event = 0; | 3098 | Event *event = 0; |
3096 | Todo *todo = 0; | 3099 | Todo *todo = 0; |
3097 | 3100 | ||
3098 | if (incidence == 0) { | 3101 | if (incidence == 0) { |
3099 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3102 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3100 | if (incidence == 0) { | 3103 | if (incidence == 0) { |
3101 | incidence = mTodoList->selectedIncidences().first(); | 3104 | incidence = mTodoList->selectedIncidences().first(); |
3102 | } | 3105 | } |
3103 | } | 3106 | } |
3104 | if ( incidence && incidence->type() == "Event" ) { | 3107 | if ( incidence && incidence->type() == "Event" ) { |
3105 | event = static_cast<Event *>(incidence); | 3108 | event = static_cast<Event *>(incidence); |
3106 | } | 3109 | } |
3107 | if ( incidence && incidence->type() == "Todo" ) { | 3110 | if ( incidence && incidence->type() == "Todo" ) { |
3108 | todo = static_cast<Todo *>(incidence); | 3111 | todo = static_cast<Todo *>(incidence); |
3109 | } | 3112 | } |
3110 | 3113 | ||
3111 | if (!event && !todo) { | 3114 | if (!event && !todo) { |
3112 | KMessageBox::sorry(this,i18n("No event selected.")); | 3115 | KMessageBox::sorry(this,i18n("No event selected.")); |
3113 | return; | 3116 | return; |
3114 | } | 3117 | } |
3115 | 3118 | ||
3116 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3119 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3117 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3120 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3118 | return; | 3121 | return; |
3119 | } | 3122 | } |
3120 | 3123 | ||
3121 | Event *ev = 0; | 3124 | Event *ev = 0; |
3122 | if (event) ev = new Event(*event); | 3125 | if (event) ev = new Event(*event); |
3123 | Todo *to = 0; | 3126 | Todo *to = 0; |
3124 | if (todo) to = new Todo(*todo); | 3127 | if (todo) to = new Todo(*todo); |
3125 | 3128 | ||
3126 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3129 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3127 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3130 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3128 | if (!me) { | 3131 | if (!me) { |
3129 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3132 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3130 | return; | 3133 | return; |
3131 | } | 3134 | } |
3132 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3135 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3133 | StatusDialog *statdlg = new StatusDialog(this); | 3136 | StatusDialog *statdlg = new StatusDialog(this); |
3134 | if (!statdlg->exec()==QDialog::Accepted) return; | 3137 | if (!statdlg->exec()==QDialog::Accepted) return; |
3135 | me->setStatus( statdlg->status() ); | 3138 | me->setStatus( statdlg->status() ); |
3136 | delete(statdlg); | 3139 | delete(statdlg); |
3137 | } | 3140 | } |
3138 | Attendee *menew = new Attendee(*me); | 3141 | Attendee *menew = new Attendee(*me); |
3139 | if (ev) { | 3142 | if (ev) { |
3140 | ev->clearAttendees(); | 3143 | ev->clearAttendees(); |
3141 | ev->addAttendee(menew,false); | 3144 | ev->addAttendee(menew,false); |
3142 | } else { | 3145 | } else { |
3143 | if (to) { | 3146 | if (to) { |
3144 | todo->clearAttendees(); | 3147 | todo->clearAttendees(); |
3145 | todo->addAttendee(menew,false); | 3148 | todo->addAttendee(menew,false); |
3146 | } | 3149 | } |
3147 | } | 3150 | } |
3148 | } | 3151 | } |
3149 | 3152 | ||
3150 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3153 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3151 | if (ev) { | 3154 | if (ev) { |
3152 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3155 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3153 | } else { | 3156 | } else { |
3154 | if (to) { | 3157 | if (to) { |
3155 | if ( !dlg->addMessage(to,method) ) delete(to); | 3158 | if ( !dlg->addMessage(to,method) ) delete(to); |
3156 | } | 3159 | } |
3157 | } | 3160 | } |
3158 | } | 3161 | } |
3159 | 3162 | ||
3160 | void CalendarView::openAddressbook() | 3163 | void CalendarView::openAddressbook() |
3161 | { | 3164 | { |
3162 | KRun::runCommand("kaddressbook"); | 3165 | KRun::runCommand("kaddressbook"); |
3163 | } | 3166 | } |
3164 | 3167 | ||
3165 | void CalendarView::setModified(bool modified) | 3168 | void CalendarView::setModified(bool modified) |
3166 | { | 3169 | { |
3167 | if ( modified ) | 3170 | if ( modified ) |
3168 | emit signalmodified(); | 3171 | emit signalmodified(); |
3169 | if (mModified != modified) { | 3172 | if (mModified != modified) { |
3170 | mModified = modified; | 3173 | mModified = modified; |
3171 | emit modifiedChanged(mModified); | 3174 | emit modifiedChanged(mModified); |
3172 | } | 3175 | } |
3173 | } | 3176 | } |
3174 | 3177 | ||
3175 | bool CalendarView::isReadOnly() | 3178 | bool CalendarView::isReadOnly() |
3176 | { | 3179 | { |
3177 | return mReadOnly; | 3180 | return mReadOnly; |
3178 | } | 3181 | } |
3179 | 3182 | ||
3180 | void CalendarView::setReadOnly(bool readOnly) | 3183 | void CalendarView::setReadOnly(bool readOnly) |
3181 | { | 3184 | { |
3182 | if (mReadOnly != readOnly) { | 3185 | if (mReadOnly != readOnly) { |
3183 | mReadOnly = readOnly; | 3186 | mReadOnly = readOnly; |
3184 | emit readOnlyChanged(mReadOnly); | 3187 | emit readOnlyChanged(mReadOnly); |
3185 | } | 3188 | } |
3186 | } | 3189 | } |
3187 | 3190 | ||
3188 | bool CalendarView::isModified() | 3191 | bool CalendarView::isModified() |
3189 | { | 3192 | { |
3190 | return mModified; | 3193 | return mModified; |
3191 | } | 3194 | } |
3192 | 3195 | ||
3193 | void CalendarView::printSetup() | 3196 | void CalendarView::printSetup() |
3194 | { | 3197 | { |
3195 | #ifndef KORG_NOPRINTER | 3198 | #ifndef KORG_NOPRINTER |
3196 | createPrinter(); | 3199 | createPrinter(); |
3197 | 3200 | ||
3198 | mCalPrinter->setupPrinter(); | 3201 | mCalPrinter->setupPrinter(); |
3199 | #endif | 3202 | #endif |
3200 | } | 3203 | } |
3201 | 3204 | ||
3202 | void CalendarView::print() | 3205 | void CalendarView::print() |
3203 | { | 3206 | { |
3204 | #ifndef KORG_NOPRINTER | 3207 | #ifndef KORG_NOPRINTER |
3205 | createPrinter(); | 3208 | createPrinter(); |
3206 | 3209 | ||
3207 | DateList tmpDateList = mNavigator->selectedDates(); | 3210 | DateList tmpDateList = mNavigator->selectedDates(); |
3208 | mCalPrinter->print(CalPrinter::Month, | 3211 | mCalPrinter->print(CalPrinter::Month, |
3209 | tmpDateList.first(), tmpDateList.last()); | 3212 | tmpDateList.first(), tmpDateList.last()); |
3210 | #endif | 3213 | #endif |
3211 | } | 3214 | } |
3212 | 3215 | ||
3213 | void CalendarView::printPreview() | 3216 | void CalendarView::printPreview() |
3214 | { | 3217 | { |
3215 | #ifndef KORG_NOPRINTER | 3218 | #ifndef KORG_NOPRINTER |
3216 | kdDebug() << "CalendarView::printPreview()" << endl; | 3219 | kdDebug() << "CalendarView::printPreview()" << endl; |
3217 | 3220 | ||
3218 | createPrinter(); | 3221 | createPrinter(); |
3219 | 3222 | ||
3220 | DateList tmpDateList = mNavigator->selectedDates(); | 3223 | DateList tmpDateList = mNavigator->selectedDates(); |
3221 | 3224 | ||
3222 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3225 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3223 | tmpDateList.last()); | 3226 | tmpDateList.last()); |
3224 | #endif | 3227 | #endif |
3225 | } | 3228 | } |
3226 | 3229 | ||
3227 | void CalendarView::exportICalendar() | 3230 | void CalendarView::exportICalendar() |
3228 | { | 3231 | { |
3229 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3232 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3230 | 3233 | ||
3231 | // Force correct extension | 3234 | // Force correct extension |
3232 | if (filename.right(4) != ".ics") filename += ".ics"; | 3235 | if (filename.right(4) != ".ics") filename += ".ics"; |
3233 | 3236 | ||
3234 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3237 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3235 | storage.save(); | 3238 | storage.save(); |
3236 | } | 3239 | } |
3237 | 3240 | ||
3238 | bool CalendarView::exportVCalendar( QString filename ) | 3241 | bool CalendarView::exportVCalendar( QString filename ) |
3239 | { | 3242 | { |
3240 | if (mCalendar->journals().count() > 0) { | 3243 | if (mCalendar->journals().count() > 0) { |
3241 | int result = KMessageBox::warningContinueCancel(this, | 3244 | int result = KMessageBox::warningContinueCancel(this, |
3242 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3245 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3243 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3246 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3244 | true); | 3247 | true); |
3245 | if (result != KMessageBox::Continue) return false; | 3248 | if (result != KMessageBox::Continue) return false; |
3246 | } | 3249 | } |
3247 | 3250 | ||
3248 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3251 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3249 | 3252 | ||
3250 | // Force correct extension | 3253 | // Force correct extension |
3251 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3254 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3252 | 3255 | ||
3253 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3256 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3254 | return storage.save(); | 3257 | return storage.save(); |
3255 | 3258 | ||
3256 | } | 3259 | } |
3257 | 3260 | ||
3258 | void CalendarView::eventUpdated(Incidence *) | 3261 | void CalendarView::eventUpdated(Incidence *) |
3259 | { | 3262 | { |
3260 | setModified(); | 3263 | setModified(); |
3261 | // Don't call updateView here. The code, which has caused the update of the | 3264 | // Don't call updateView here. The code, which has caused the update of the |
3262 | // event is responsible for updating the view. | 3265 | // event is responsible for updating the view. |
3263 | // updateView(); | 3266 | // updateView(); |
3264 | } | 3267 | } |
3265 | 3268 | ||
3266 | void CalendarView::adaptNavigationUnits() | 3269 | void CalendarView::adaptNavigationUnits() |
3267 | { | 3270 | { |
3268 | if (mViewManager->currentView()->isEventView()) { | 3271 | if (mViewManager->currentView()->isEventView()) { |
3269 | int days = mViewManager->currentView()->currentDateCount(); | 3272 | int days = mViewManager->currentView()->currentDateCount(); |
3270 | if (days == 1) { | 3273 | if (days == 1) { |
3271 | emit changeNavStringPrev(i18n("&Previous Day")); | 3274 | emit changeNavStringPrev(i18n("&Previous Day")); |
3272 | emit changeNavStringNext(i18n("&Next Day")); | 3275 | emit changeNavStringNext(i18n("&Next Day")); |
3273 | } else { | 3276 | } else { |
3274 | emit changeNavStringPrev(i18n("&Previous Week")); | 3277 | emit changeNavStringPrev(i18n("&Previous Week")); |
3275 | emit changeNavStringNext(i18n("&Next Week")); | 3278 | emit changeNavStringNext(i18n("&Next Week")); |
3276 | } | 3279 | } |
3277 | } | 3280 | } |
3278 | } | 3281 | } |
3279 | 3282 | ||
3280 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3283 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3281 | { | 3284 | { |
3282 | if ( incidence ) mTodoList->clearSelection(); | 3285 | if ( incidence ) mTodoList->clearSelection(); |
3283 | processIncidenceSelection( incidence ); | 3286 | processIncidenceSelection( incidence ); |
3284 | } | 3287 | } |
3285 | 3288 | ||
3286 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3289 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3287 | { | 3290 | { |
3288 | if ( incidence && mViewManager->currentView() ) { | 3291 | if ( incidence && mViewManager->currentView() ) { |
3289 | mViewManager->currentView()->clearSelection(); | 3292 | mViewManager->currentView()->clearSelection(); |
3290 | } | 3293 | } |
3291 | processIncidenceSelection( incidence ); | 3294 | processIncidenceSelection( incidence ); |
3292 | } | 3295 | } |
3293 | 3296 | ||
3294 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3297 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3295 | { | 3298 | { |
3296 | if ( incidence == mSelectedIncidence ) return; | 3299 | if ( incidence == mSelectedIncidence ) return; |
3297 | 3300 | ||
3298 | mSelectedIncidence = incidence; | 3301 | mSelectedIncidence = incidence; |
3299 | 3302 | ||
3300 | emit incidenceSelected( mSelectedIncidence ); | 3303 | emit incidenceSelected( mSelectedIncidence ); |
3301 | 3304 | ||
3302 | if ( incidence && incidence->type() == "Event" ) { | 3305 | if ( incidence && incidence->type() == "Event" ) { |
3303 | Event *event = static_cast<Event *>( incidence ); | 3306 | Event *event = static_cast<Event *>( incidence ); |
3304 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3307 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3305 | emit organizerEventsSelected( true ); | 3308 | emit organizerEventsSelected( true ); |
3306 | } else { | 3309 | } else { |
3307 | emit organizerEventsSelected(false); | 3310 | emit organizerEventsSelected(false); |
3308 | } | 3311 | } |
3309 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3312 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3310 | KOPrefs::instance()->email() ) ) { | 3313 | KOPrefs::instance()->email() ) ) { |
3311 | emit groupEventsSelected( true ); | 3314 | emit groupEventsSelected( true ); |
3312 | } else { | 3315 | } else { |
3313 | emit groupEventsSelected(false); | 3316 | emit groupEventsSelected(false); |
3314 | } | 3317 | } |
3315 | return; | 3318 | return; |
3316 | } else { | 3319 | } else { |
3317 | if ( incidence && incidence->type() == "Todo" ) { | 3320 | if ( incidence && incidence->type() == "Todo" ) { |
3318 | emit todoSelected( true ); | 3321 | emit todoSelected( true ); |
3319 | Todo *event = static_cast<Todo *>( incidence ); | 3322 | Todo *event = static_cast<Todo *>( incidence ); |
3320 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3323 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3321 | emit organizerEventsSelected( true ); | 3324 | emit organizerEventsSelected( true ); |
3322 | } else { | 3325 | } else { |
3323 | emit organizerEventsSelected(false); | 3326 | emit organizerEventsSelected(false); |
3324 | } | 3327 | } |
3325 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3328 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3326 | KOPrefs::instance()->email() ) ) { | 3329 | KOPrefs::instance()->email() ) ) { |
3327 | emit groupEventsSelected( true ); | 3330 | emit groupEventsSelected( true ); |
3328 | } else { | 3331 | } else { |
3329 | emit groupEventsSelected(false); | 3332 | emit groupEventsSelected(false); |
3330 | } | 3333 | } |
3331 | return; | 3334 | return; |
3332 | } else { | 3335 | } else { |
3333 | emit todoSelected( false ); | 3336 | emit todoSelected( false ); |
3334 | emit organizerEventsSelected(false); | 3337 | emit organizerEventsSelected(false); |
3335 | emit groupEventsSelected(false); | 3338 | emit groupEventsSelected(false); |
3336 | } | 3339 | } |
3337 | return; | 3340 | return; |
3338 | } | 3341 | } |
3339 | 3342 | ||
3340 | /* if ( incidence && incidence->type() == "Todo" ) { | 3343 | /* if ( incidence && incidence->type() == "Todo" ) { |
3341 | emit todoSelected( true ); | 3344 | emit todoSelected( true ); |
3342 | } else { | 3345 | } else { |
3343 | emit todoSelected( false ); | 3346 | emit todoSelected( false ); |
3344 | }*/ | 3347 | }*/ |
3345 | } | 3348 | } |
3346 | 3349 | ||
3347 | 3350 | ||
3348 | void CalendarView::checkClipboard() | 3351 | void CalendarView::checkClipboard() |
3349 | { | 3352 | { |
3350 | #ifndef KORG_NODND | 3353 | #ifndef KORG_NODND |
3351 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3354 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3352 | emit pasteEnabled(true); | 3355 | emit pasteEnabled(true); |
3353 | } else { | 3356 | } else { |
3354 | emit pasteEnabled(false); | 3357 | emit pasteEnabled(false); |
3355 | } | 3358 | } |
3356 | #endif | 3359 | #endif |
3357 | } | 3360 | } |
3358 | 3361 | ||
3359 | void CalendarView::showDates(const DateList &selectedDates) | 3362 | void CalendarView::showDates(const DateList &selectedDates) |
3360 | { | 3363 | { |
3361 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3364 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3362 | 3365 | ||
3363 | if ( mViewManager->currentView() ) { | 3366 | if ( mViewManager->currentView() ) { |
3364 | updateView( selectedDates.first(), selectedDates.last() ); | 3367 | updateView( selectedDates.first(), selectedDates.last() ); |
3365 | } else { | 3368 | } else { |
3366 | mViewManager->showAgendaView(); | 3369 | mViewManager->showAgendaView(); |
3367 | } | 3370 | } |
3368 | 3371 | ||
3369 | QString selDates; | 3372 | QString selDates; |
3370 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3373 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3371 | if (selectedDates.first() < selectedDates.last() ) | 3374 | if (selectedDates.first() < selectedDates.last() ) |
3372 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3375 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3373 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3376 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3374 | 3377 | ||
3375 | } | 3378 | } |
3376 | 3379 | ||
3377 | QPtrList<CalFilter> CalendarView::filters() | 3380 | QPtrList<CalFilter> CalendarView::filters() |
3378 | { | 3381 | { |
3379 | return mFilters; | 3382 | return mFilters; |
3380 | 3383 | ||
3381 | } | 3384 | } |
3382 | void CalendarView::editFilters() | 3385 | void CalendarView::editFilters() |
3383 | { | 3386 | { |
3384 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3387 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3385 | 3388 | ||
3386 | CalFilter *filter = mFilters.first(); | 3389 | CalFilter *filter = mFilters.first(); |
3387 | while(filter) { | 3390 | while(filter) { |
3388 | kdDebug() << " Filter: " << filter->name() << endl; | 3391 | kdDebug() << " Filter: " << filter->name() << endl; |
3389 | filter = mFilters.next(); | 3392 | filter = mFilters.next(); |
3390 | } | 3393 | } |
3391 | 3394 | ||
3392 | mDialogManager->showFilterEditDialog(&mFilters); | 3395 | mDialogManager->showFilterEditDialog(&mFilters); |
3393 | } | 3396 | } |
3394 | void CalendarView::toggleFilter() | 3397 | void CalendarView::toggleFilter() |
3395 | { | 3398 | { |
3396 | showFilter(! mFilterView->isVisible()); | 3399 | showFilter(! mFilterView->isVisible()); |
3397 | } | 3400 | } |
3398 | 3401 | ||
3399 | KOFilterView *CalendarView::filterView() | 3402 | KOFilterView *CalendarView::filterView() |
3400 | { | 3403 | { |
3401 | return mFilterView; | 3404 | return mFilterView; |
3402 | } | 3405 | } |
3403 | void CalendarView::selectFilter( int fil ) | 3406 | void CalendarView::selectFilter( int fil ) |
3404 | { | 3407 | { |
3405 | mFilterView->setSelectedFilter( fil ); | 3408 | mFilterView->setSelectedFilter( fil ); |
3406 | } | 3409 | } |
3407 | void CalendarView::showFilter(bool visible) | 3410 | void CalendarView::showFilter(bool visible) |
3408 | { | 3411 | { |
3409 | if (visible) mFilterView->show(); | 3412 | if (visible) mFilterView->show(); |
3410 | else mFilterView->hide(); | 3413 | else mFilterView->hide(); |
3411 | } | 3414 | } |
3412 | void CalendarView::toggleFilerEnabled( ) | 3415 | void CalendarView::toggleFilerEnabled( ) |
3413 | { | 3416 | { |
3414 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3417 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3415 | if ( !mFilterView->filtersEnabled() ) | 3418 | if ( !mFilterView->filtersEnabled() ) |
3416 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3419 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3417 | 3420 | ||
3418 | } | 3421 | } |
3419 | void CalendarView::updateFilter() | 3422 | void CalendarView::updateFilter() |
3420 | { | 3423 | { |
3421 | CalFilter *filter = mFilterView->selectedFilter(); | 3424 | CalFilter *filter = mFilterView->selectedFilter(); |
3422 | if (filter) { | 3425 | if (filter) { |
3423 | if (mFilterView->filtersEnabled()) { | 3426 | if (mFilterView->filtersEnabled()) { |
3424 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3427 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3425 | filter->setEnabled(true); | 3428 | filter->setEnabled(true); |
3426 | } | 3429 | } |
3427 | else filter->setEnabled(false); | 3430 | else filter->setEnabled(false); |
3428 | mCalendar->setFilter(filter); | 3431 | mCalendar->setFilter(filter); |
3429 | updateView(); | 3432 | updateView(); |
3430 | } | 3433 | } |
3431 | } | 3434 | } |
3432 | 3435 | ||
3433 | void CalendarView::filterEdited() | 3436 | void CalendarView::filterEdited() |
3434 | { | 3437 | { |
3435 | mFilterView->updateFilters(); | 3438 | mFilterView->updateFilters(); |
3436 | updateFilter(); | 3439 | updateFilter(); |
3437 | writeSettings(); | 3440 | writeSettings(); |
3438 | } | 3441 | } |
3439 | 3442 | ||
3440 | 3443 | ||
3441 | void CalendarView::takeOverEvent() | 3444 | void CalendarView::takeOverEvent() |
3442 | { | 3445 | { |
3443 | Incidence *incidence = currentSelection(); | 3446 | Incidence *incidence = currentSelection(); |
3444 | 3447 | ||
3445 | if (!incidence) return; | 3448 | if (!incidence) return; |
3446 | 3449 | ||
3447 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3450 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3448 | incidence->recreate(); | 3451 | incidence->recreate(); |
3449 | incidence->setReadOnly(false); | 3452 | incidence->setReadOnly(false); |
3450 | 3453 | ||
3451 | updateView(); | 3454 | updateView(); |
3452 | } | 3455 | } |
3453 | 3456 | ||
3454 | void CalendarView::takeOverCalendar() | 3457 | void CalendarView::takeOverCalendar() |
3455 | { | 3458 | { |
3456 | // TODO: Create Calendar::allIncidences() function and use it here | 3459 | // TODO: Create Calendar::allIncidences() function and use it here |
3457 | 3460 | ||
3458 | QPtrList<Event> events = mCalendar->events(); | 3461 | QPtrList<Event> events = mCalendar->events(); |
3459 | for(uint i=0; i<events.count(); ++i) { | 3462 | for(uint i=0; i<events.count(); ++i) { |
3460 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3463 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3461 | events.at(i)->recreate(); | 3464 | events.at(i)->recreate(); |
3462 | events.at(i)->setReadOnly(false); | 3465 | events.at(i)->setReadOnly(false); |
3463 | } | 3466 | } |
3464 | 3467 | ||
3465 | QPtrList<Todo> todos = mCalendar->todos(); | 3468 | QPtrList<Todo> todos = mCalendar->todos(); |
3466 | for(uint i=0; i<todos.count(); ++i) { | 3469 | for(uint i=0; i<todos.count(); ++i) { |
3467 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3470 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3468 | todos.at(i)->recreate(); | 3471 | todos.at(i)->recreate(); |
3469 | todos.at(i)->setReadOnly(false); | 3472 | todos.at(i)->setReadOnly(false); |
3470 | } | 3473 | } |
3471 | 3474 | ||
3472 | QPtrList<Journal> journals = mCalendar->journals(); | 3475 | QPtrList<Journal> journals = mCalendar->journals(); |
3473 | for(uint i=0; i<journals.count(); ++i) { | 3476 | for(uint i=0; i<journals.count(); ++i) { |
3474 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3477 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3475 | journals.at(i)->recreate(); | 3478 | journals.at(i)->recreate(); |
3476 | journals.at(i)->setReadOnly(false); | 3479 | journals.at(i)->setReadOnly(false); |
3477 | } | 3480 | } |
3478 | 3481 | ||
3479 | updateView(); | 3482 | updateView(); |
3480 | } | 3483 | } |
3481 | 3484 | ||
3482 | void CalendarView::showIntro() | 3485 | void CalendarView::showIntro() |
3483 | { | 3486 | { |
3484 | kdDebug() << "To be implemented." << endl; | 3487 | kdDebug() << "To be implemented." << endl; |
3485 | } | 3488 | } |
3486 | 3489 | ||
3487 | QWidgetStack *CalendarView::viewStack() | 3490 | QWidgetStack *CalendarView::viewStack() |
3488 | { | 3491 | { |
3489 | return mRightFrame; | 3492 | return mRightFrame; |
3490 | } | 3493 | } |
3491 | 3494 | ||
3492 | QWidget *CalendarView::leftFrame() | 3495 | QWidget *CalendarView::leftFrame() |
3493 | { | 3496 | { |
3494 | return mLeftFrame; | 3497 | return mLeftFrame; |
3495 | } | 3498 | } |
3496 | 3499 | ||
3497 | DateNavigator *CalendarView::dateNavigator() | 3500 | DateNavigator *CalendarView::dateNavigator() |
3498 | { | 3501 | { |
3499 | return mNavigator; | 3502 | return mNavigator; |
3500 | } | 3503 | } |
3501 | 3504 | ||
3502 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3505 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3503 | { | 3506 | { |
3504 | return mDateNavigator; | 3507 | return mDateNavigator; |
3505 | } | 3508 | } |
3506 | void CalendarView::toggleDateNavigatorWidget() | 3509 | void CalendarView::toggleDateNavigatorWidget() |
3507 | { | 3510 | { |
3508 | if (mDateNavigator->isVisible()) | 3511 | if (mDateNavigator->isVisible()) |
3509 | mDateNavigator->hide(); | 3512 | mDateNavigator->hide(); |
3510 | else | 3513 | else |
3511 | mDateNavigator->show(); | 3514 | mDateNavigator->show(); |
3512 | } | 3515 | } |
3513 | void CalendarView::addView(KOrg::BaseView *view) | 3516 | void CalendarView::addView(KOrg::BaseView *view) |
3514 | { | 3517 | { |
3515 | mViewManager->addView(view); | 3518 | mViewManager->addView(view); |
3516 | } | 3519 | } |
3517 | 3520 | ||
3518 | void CalendarView::showView(KOrg::BaseView *view) | 3521 | void CalendarView::showView(KOrg::BaseView *view) |
3519 | { | 3522 | { |
3520 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3523 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3521 | } | 3524 | } |
3522 | 3525 | ||
3523 | Incidence *CalendarView::currentSelection() | 3526 | Incidence *CalendarView::currentSelection() |
3524 | { | 3527 | { |
3525 | return mViewManager->currentSelection(); | 3528 | return mViewManager->currentSelection(); |
3526 | } | 3529 | } |
3527 | void CalendarView::toggleAllDaySize() | 3530 | void CalendarView::toggleAllDaySize() |
3528 | { | 3531 | { |
3529 | /* | 3532 | /* |
3530 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3533 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3531 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3534 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3532 | else | 3535 | else |
3533 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3536 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3534 | */ | 3537 | */ |
3535 | viewManager()->agendaView()->toggleAllDay(); | 3538 | viewManager()->agendaView()->toggleAllDay(); |
3536 | } | 3539 | } |
3537 | void CalendarView::toggleExpand() | 3540 | void CalendarView::toggleExpand() |
3538 | { | 3541 | { |
3539 | // if ( mLeftFrame->isHidden() ) { | 3542 | // if ( mLeftFrame->isHidden() ) { |
3540 | // mLeftFrame->show(); | 3543 | // mLeftFrame->show(); |
3541 | // emit calendarViewExpanded( false ); | 3544 | // emit calendarViewExpanded( false ); |
3542 | // } else { | 3545 | // } else { |
3543 | // mLeftFrame->hide(); | 3546 | // mLeftFrame->hide(); |
3544 | // emit calendarViewExpanded( true ); | 3547 | // emit calendarViewExpanded( true ); |
3545 | // } | 3548 | // } |
3546 | 3549 | ||
3547 | globalFlagBlockAgenda = 1; | 3550 | globalFlagBlockAgenda = 1; |
3548 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3551 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3549 | globalFlagBlockAgenda = 5; | 3552 | globalFlagBlockAgenda = 5; |
3550 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3553 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3551 | //mViewManager->showView( 0, true ); | 3554 | //mViewManager->showView( 0, true ); |
3552 | } | 3555 | } |
3553 | 3556 | ||
3554 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3557 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3555 | { | 3558 | { |
3556 | setModified( modified ); | 3559 | setModified( modified ); |
3557 | } | 3560 | } |
3558 | 3561 | ||
3559 | Todo *CalendarView::selectedTodo() | 3562 | Todo *CalendarView::selectedTodo() |
3560 | { | 3563 | { |
3561 | Incidence *incidence = currentSelection(); | 3564 | Incidence *incidence = currentSelection(); |
3562 | if ( incidence && incidence->type() == "Todo" ) { | 3565 | if ( incidence && incidence->type() == "Todo" ) { |
3563 | return static_cast<Todo *>( incidence ); | 3566 | return static_cast<Todo *>( incidence ); |
3564 | } | 3567 | } |
3565 | 3568 | ||
3566 | incidence = mTodoList->selectedIncidences().first(); | 3569 | incidence = mTodoList->selectedIncidences().first(); |
3567 | if ( incidence && incidence->type() == "Todo" ) { | 3570 | if ( incidence && incidence->type() == "Todo" ) { |
3568 | return static_cast<Todo *>( incidence ); | 3571 | return static_cast<Todo *>( incidence ); |
3569 | } | 3572 | } |
3570 | 3573 | ||
3571 | return 0; | 3574 | return 0; |
3572 | } | 3575 | } |
3573 | 3576 | ||
3574 | void CalendarView::dialogClosing(Incidence *in) | 3577 | void CalendarView::dialogClosing(Incidence *in) |
3575 | { | 3578 | { |
3576 | // mDialogList.remove(in); | 3579 | // mDialogList.remove(in); |
3577 | } | 3580 | } |
3578 | 3581 | ||
3579 | void CalendarView::showIncidence() | 3582 | void CalendarView::showIncidence() |
3580 | { | 3583 | { |
3581 | Incidence *incidence = currentSelection(); | 3584 | Incidence *incidence = currentSelection(); |
3582 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3585 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3583 | if ( incidence ) { | 3586 | if ( incidence ) { |
3584 | ShowIncidenceVisitor v; | 3587 | ShowIncidenceVisitor v; |
3585 | v.act( incidence, this ); | 3588 | v.act( incidence, this ); |
3586 | } | 3589 | } |
3587 | } | 3590 | } |
3588 | void CalendarView::editIncidenceDescription() | 3591 | void CalendarView::editIncidenceDescription() |
3589 | { | 3592 | { |
3590 | mFlagEditDescription = true; | 3593 | mFlagEditDescription = true; |
3591 | editIncidence(); | 3594 | editIncidence(); |
3592 | mFlagEditDescription = false; | 3595 | mFlagEditDescription = false; |
3593 | } | 3596 | } |
3594 | void CalendarView::editIncidence() | 3597 | void CalendarView::editIncidence() |
3595 | { | 3598 | { |
3596 | // qDebug("editIncidence() "); | 3599 | // qDebug("editIncidence() "); |
3597 | Incidence *incidence = currentSelection(); | 3600 | Incidence *incidence = currentSelection(); |
3598 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3601 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3599 | if ( incidence ) { | 3602 | if ( incidence ) { |
3600 | EditIncidenceVisitor v; | 3603 | EditIncidenceVisitor v; |
3601 | v.act( incidence, this ); | 3604 | v.act( incidence, this ); |
3602 | } | 3605 | } |
3603 | } | 3606 | } |
3604 | 3607 | ||
3605 | void CalendarView::deleteIncidence() | 3608 | void CalendarView::deleteIncidence() |
3606 | { | 3609 | { |
3607 | Incidence *incidence = currentSelection(); | 3610 | Incidence *incidence = currentSelection(); |
3608 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3611 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3609 | if ( incidence ) { | 3612 | if ( incidence ) { |
3610 | deleteIncidence(incidence); | 3613 | deleteIncidence(incidence); |
3611 | } | 3614 | } |
3612 | } | 3615 | } |
3613 | 3616 | ||
3614 | void CalendarView::showIncidence(Incidence *incidence) | 3617 | void CalendarView::showIncidence(Incidence *incidence) |
3615 | { | 3618 | { |
3616 | if ( incidence ) { | 3619 | if ( incidence ) { |
3617 | ShowIncidenceVisitor v; | 3620 | ShowIncidenceVisitor v; |
3618 | v.act( incidence, this ); | 3621 | v.act( incidence, this ); |
3619 | } | 3622 | } |
3620 | } | 3623 | } |
3621 | 3624 | ||
3622 | void CalendarView::editIncidence(Incidence *incidence) | 3625 | void CalendarView::editIncidence(Incidence *incidence) |
3623 | { | 3626 | { |
3624 | if ( incidence ) { | 3627 | if ( incidence ) { |
3625 | 3628 | ||
3626 | EditIncidenceVisitor v; | 3629 | EditIncidenceVisitor v; |
3627 | v.act( incidence, this ); | 3630 | v.act( incidence, this ); |
3628 | 3631 | ||
3629 | } | 3632 | } |
3630 | } | 3633 | } |
3631 | 3634 | ||
3632 | void CalendarView::deleteIncidence(Incidence *incidence) | 3635 | void CalendarView::deleteIncidence(Incidence *incidence) |
3633 | { | 3636 | { |
3634 | //qDebug(" CalendarView::deleteIncidence "); | 3637 | //qDebug(" CalendarView::deleteIncidence "); |
3635 | if ( incidence ) { | 3638 | if ( incidence ) { |
3636 | DeleteIncidenceVisitor v; | 3639 | DeleteIncidenceVisitor v; |
3637 | v.act( incidence, this ); | 3640 | v.act( incidence, this ); |
3638 | } | 3641 | } |
3639 | } | 3642 | } |
3640 | 3643 | ||
3641 | 3644 | ||
3642 | void CalendarView::lookForOutgoingMessages() | 3645 | void CalendarView::lookForOutgoingMessages() |
3643 | { | 3646 | { |
3644 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3647 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3645 | ogd->loadMessages(); | 3648 | ogd->loadMessages(); |
3646 | } | 3649 | } |
3647 | 3650 | ||
3648 | void CalendarView::lookForIncomingMessages() | 3651 | void CalendarView::lookForIncomingMessages() |
3649 | { | 3652 | { |
3650 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3653 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3651 | icd->retrieve(); | 3654 | icd->retrieve(); |
3652 | } | 3655 | } |
3653 | 3656 | ||
3654 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3657 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3655 | { | 3658 | { |
3656 | bool deleteTodo = true; | 3659 | bool deleteTodo = true; |
3657 | QPtrList<Incidence> subTodos; | 3660 | QPtrList<Incidence> subTodos; |
3658 | Incidence *aTodo; | 3661 | Incidence *aTodo; |
3659 | subTodos = t->relations(); | 3662 | subTodos = t->relations(); |
3660 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3663 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3661 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3664 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3662 | deleteTodo = false; | 3665 | deleteTodo = false; |
3663 | } | 3666 | } |
3664 | if ( deleteTodo ) { | 3667 | if ( deleteTodo ) { |
3665 | if ( t->isCompleted() ) { | 3668 | if ( t->isCompleted() ) { |
3666 | checkExternalId( t ); | 3669 | checkExternalId( t ); |
3667 | mCalendar->deleteTodo( t ); | 3670 | mCalendar->deleteTodo( t ); |
3668 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3671 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3669 | } | 3672 | } |
3670 | else | 3673 | else |
3671 | deleteTodo = false; | 3674 | deleteTodo = false; |
3672 | } | 3675 | } |
3673 | return deleteTodo; | 3676 | return deleteTodo; |
3674 | 3677 | ||
3675 | } | 3678 | } |
3676 | void CalendarView::purgeCompleted() | 3679 | void CalendarView::purgeCompleted() |
3677 | { | 3680 | { |
3678 | int result = KMessageBox::warningContinueCancel(this, | 3681 | int result = KMessageBox::warningContinueCancel(this, |
3679 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3682 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3680 | 3683 | ||
3681 | if (result == KMessageBox::Continue) { | 3684 | if (result == KMessageBox::Continue) { |
3682 | 3685 | ||
3683 | QPtrList<Todo> todoCal; | 3686 | QPtrList<Todo> todoCal; |
3684 | QPtrList<Todo> rootTodos; | 3687 | QPtrList<Todo> rootTodos; |
3685 | //QPtrList<Incidence> rel; | 3688 | //QPtrList<Incidence> rel; |
3686 | Todo *aTodo;//, *rTodo; | 3689 | Todo *aTodo;//, *rTodo; |
3687 | Incidence *rIncidence; | 3690 | Incidence *rIncidence; |
3688 | bool childDelete = false; | 3691 | bool childDelete = false; |
3689 | bool deletedOne = true; | 3692 | bool deletedOne = true; |
3690 | todoCal = calendar()->todos(); | 3693 | todoCal = calendar()->todos(); |
3691 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3694 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3692 | if ( !aTodo->relatedTo() ) | 3695 | if ( !aTodo->relatedTo() ) |
3693 | rootTodos.append( aTodo ); | 3696 | rootTodos.append( aTodo ); |
3694 | } | 3697 | } |
3695 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3698 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3696 | removeCompletedSubTodos( aTodo ); | 3699 | removeCompletedSubTodos( aTodo ); |
3697 | } | 3700 | } |
3698 | 3701 | ||
3699 | updateView(); | 3702 | updateView(); |
3700 | } | 3703 | } |
3701 | } | 3704 | } |
3702 | 3705 | ||
3703 | void CalendarView::slotCalendarChanged() | 3706 | void CalendarView::slotCalendarChanged() |
3704 | { | 3707 | { |
3705 | ; | 3708 | ; |
3706 | } | 3709 | } |
3707 | 3710 | ||
3708 | NavigatorBar *CalendarView::navigatorBar() | 3711 | NavigatorBar *CalendarView::navigatorBar() |
3709 | { | 3712 | { |
3710 | return mNavigatorBar; | 3713 | return mNavigatorBar; |
3711 | } | 3714 | } |
3712 | 3715 | ||
3713 | 3716 | ||
3714 | 3717 | ||
3715 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3718 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3716 | { | 3719 | { |
3717 | //qDebug(" alendarView::keyPressEvent "); | 3720 | //qDebug(" alendarView::keyPressEvent "); |
3718 | e->ignore(); | 3721 | e->ignore(); |
3719 | } | 3722 | } |
3720 | 3723 | ||
3721 | 3724 | ||
3722 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3725 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3723 | { | 3726 | { |
3724 | // mSyncManager = manager; | 3727 | // mSyncManager = manager; |
3725 | mSyncKDE = false; | 3728 | mSyncKDE = false; |
3726 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3729 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3727 | qDebug("SyncKDE request detected!"); | 3730 | qDebug("SyncKDE request detected!"); |
3728 | mSyncKDE = true; | 3731 | mSyncKDE = true; |
3729 | } | 3732 | } |
3730 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3733 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3731 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3734 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3732 | return syncCalendar( filename, mode ); | 3735 | return syncCalendar( filename, mode ); |
3733 | } | 3736 | } |
3734 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3737 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3735 | { | 3738 | { |
3736 | mSyncKDE = false; | 3739 | mSyncKDE = false; |
3737 | //mSyncManager = manager; | 3740 | //mSyncManager = manager; |
3738 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3741 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3739 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3742 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3740 | if ( resource == "sharp" ) | 3743 | if ( resource == "sharp" ) |
3741 | syncExternal( 0 ); | 3744 | syncExternal( 0 ); |
3742 | if ( resource == "phone" ) | 3745 | if ( resource == "phone" ) |
3743 | syncExternal( 1 ); | 3746 | syncExternal( 1 ); |
3744 | // pending setmodified | 3747 | // pending setmodified |
3745 | return true; | 3748 | return true; |
3746 | } | 3749 | } |
3747 | void CalendarView::setSyncManager(KSyncManager* manager) | 3750 | void CalendarView::setSyncManager(KSyncManager* manager) |
3748 | { | 3751 | { |
3749 | mSyncManager = manager; | 3752 | mSyncManager = manager; |
3750 | } | 3753 | } |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 651442b..258f738 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,572 +1,566 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@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 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kemailsettings.h> | 42 | #include <kemailsettings.h> |
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "mainwindow.h" | 47 | #include "mainwindow.h" |
48 | 48 | ||
49 | const char *germanwords[][2] = { | 49 | const char *germanwords[][2] = { |
50 | #include "wordsgerman.h" | 50 | #include "wordsgerman.h" |
51 | "", "" | 51 | "", "" |
52 | }; | 52 | }; |
53 | 53 | ||
54 | KOPrefs *KOPrefs::mInstance = 0; | 54 | KOPrefs *KOPrefs::mInstance = 0; |
55 | static KStaticDeleter<KOPrefs> insd; | 55 | static KStaticDeleter<KOPrefs> insd; |
56 | 56 | ||
57 | KOPrefs::KOPrefs() : | 57 | KOPrefs::KOPrefs() : |
58 | KPimPrefs("korganizerrc") | 58 | KPimPrefs("korganizerrc") |
59 | { | 59 | { |
60 | mCategoryColors.setAutoDelete(true); | 60 | mCategoryColors.setAutoDelete(true); |
61 | mLocaleDict = 0; | 61 | mLocaleDict = 0; |
62 | fillMailDefaults(); | 62 | fillMailDefaults(); |
63 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 63 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
64 | QColor defaultHolidayColor = QColor(255,0,0); | 64 | QColor defaultHolidayColor = QColor(255,0,0); |
65 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 65 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
66 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 66 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
67 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 67 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
68 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 68 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
69 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 69 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
70 | 70 | ||
71 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); | 71 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); |
72 | mDefaultViewFont = QFont("helvetica",10); | 72 | mDefaultViewFont = QFont("helvetica",10); |
73 | mDefaultMonthViewFont = QFont("helvetica",8); | 73 | mDefaultMonthViewFont = QFont("helvetica",8); |
74 | mMarcusBainsFont= QFont("helvetica",10); | 74 | mMarcusBainsFont= QFont("helvetica",10); |
75 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); | 75 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); |
76 | mEditBoxFont = QFont("helvetica",12); | 76 | mEditBoxFont = QFont("helvetica",12); |
77 | mJornalViewFont = QFont("helvetica",12); | 77 | mJornalViewFont = QFont("helvetica",12); |
78 | 78 | ||
79 | KPrefs::setCurrentGroup("General"); | 79 | KPrefs::setCurrentGroup("General"); |
80 | 80 | ||
81 | 81 | ||
82 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 82 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
83 | 83 | ||
84 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 84 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
85 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 85 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
86 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 86 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
87 | addItemBool("ShowIconList",&mShowIconList,true); | 87 | addItemBool("ShowIconList",&mShowIconList,true); |
88 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 88 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
89 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 89 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
90 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 90 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
91 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 91 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
92 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 92 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
93 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 93 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
94 | addItemBool("ShowIconBack",&mShowIconBack,true); | 94 | addItemBool("ShowIconBack",&mShowIconBack,true); |
95 | addItemBool("ShowIconToday",&mShowIconToday,true); | 95 | addItemBool("ShowIconToday",&mShowIconToday,true); |
96 | addItemBool("ShowIconForward",&mShowIconForward,true); | 96 | addItemBool("ShowIconForward",&mShowIconForward,true); |
97 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 97 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
98 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); | 98 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); |
99 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 99 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
100 | addItemBool("ShowIconNext",&mShowIconNext,true); | 100 | addItemBool("ShowIconNext",&mShowIconNext,true); |
101 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 101 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
102 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 102 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
103 | addItemBool("LanguageChanged",&mLanguageChanged,false); | 103 | addItemBool("LanguageChanged",&mLanguageChanged,false); |
104 | 104 | ||
105 | addItemBool("AskForQuit",&mAskForQuit,false); | 105 | addItemBool("AskForQuit",&mAskForQuit,false); |
106 | 106 | ||
107 | #ifndef DESKTOP_VERSION | 107 | #ifndef DESKTOP_VERSION |
108 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 108 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
109 | #else | 109 | #else |
110 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 110 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
111 | #endif | 111 | #endif |
112 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 112 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
113 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 113 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
114 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 114 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
115 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 115 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
116 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 116 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
117 | 117 | ||
118 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 118 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
119 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 119 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
120 | addItemInt("AllDay Size",&mAllDaySize,28); | 120 | addItemInt("AllDay Size",&mAllDaySize,28); |
121 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 121 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
122 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 122 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
123 | 123 | ||
124 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 124 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
125 | addItemStringList("EventSummary User",&mEventSummaryUser); | 125 | addItemStringList("EventSummary User",&mEventSummaryUser); |
126 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 126 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
127 | 127 | ||
128 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 128 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
129 | addItemBool("Enable Project View",&mEnableProjectView,false); | 129 | addItemBool("Enable Project View",&mEnableProjectView,false); |
130 | addItemBool("Auto Save",&mAutoSave,false); | 130 | addItemBool("Auto Save",&mAutoSave,false); |
131 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 131 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
132 | addItemBool("Confirm Deletes",&mConfirm,true); | 132 | addItemBool("Confirm Deletes",&mConfirm,true); |
133 | addItemString("Archive File",&mArchiveFile); | 133 | addItemString("Archive File",&mArchiveFile); |
134 | addItemString("Html Export File",&mHtmlExportFile, | 134 | addItemString("Html Export File",&mHtmlExportFile, |
135 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 135 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
136 | addItemBool("Html With Save",&mHtmlWithSave,false); | 136 | addItemBool("Html With Save",&mHtmlWithSave,false); |
137 | 137 | ||
138 | KPrefs::setCurrentGroup("Personal Settings"); | 138 | KPrefs::setCurrentGroup("Personal Settings"); |
139 | 139 | ||
140 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 140 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
141 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 141 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
142 | addItemBool("Bcc",&mBcc,false); | 142 | addItemBool("Bcc",&mBcc,false); |
143 | 143 | ||
144 | KPrefs::setCurrentGroup("Time & Date"); | 144 | KPrefs::setCurrentGroup("Time & Date"); |
145 | 145 | ||
146 | // addItemString("Time Zone",&mTimeZone,"+0100"); | 146 | // addItemString("Time Zone",&mTimeZone,"+0100"); |
147 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); | 147 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); |
148 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); | 148 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); |
149 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | 149 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); |
150 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | 150 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); |
151 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | 151 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); |
152 | 152 | ||
153 | 153 | ||
154 | addItemInt("Default Start Time",&mStartTime,10); | 154 | addItemInt("Default Start Time",&mStartTime,10); |
155 | addItemInt("Default Duration",&mDefaultDuration,2); | 155 | addItemInt("Default Duration",&mDefaultDuration,2); |
156 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 156 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
157 | addItemInt("Daylight Savings",&mDaylightSavings,0); | 157 | addItemInt("Daylight Savings",&mDaylightSavings,0); |
158 | KPrefs::setCurrentGroup("AlarmSettings"); | 158 | KPrefs::setCurrentGroup("AlarmSettings"); |
159 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 159 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
160 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 160 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
161 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 161 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
162 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 162 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
163 | 163 | ||
164 | 164 | ||
165 | KPrefs::setCurrentGroup("Calendar"); | 165 | KPrefs::setCurrentGroup("Calendar"); |
166 | 166 | ||
167 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 167 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
168 | 168 | ||
169 | KPrefs::setCurrentGroup("Fonts"); | 169 | KPrefs::setCurrentGroup("Fonts"); |
170 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 170 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
171 | addItemFont("TimeBar Font",&mTimeBarFont); | 171 | addItemFont("TimeBar Font",&mTimeBarFont); |
172 | addItemFont("MonthView Font",&mMonthViewFont); | 172 | addItemFont("MonthView Font",&mMonthViewFont); |
173 | addItemFont("AgendaView Font",&mAgendaViewFont); | 173 | addItemFont("AgendaView Font",&mAgendaViewFont); |
174 | addItemFont("MarcusBains Font",&mMarcusBainsFont); | 174 | addItemFont("MarcusBains Font",&mMarcusBainsFont); |
175 | addItemFont("TimeLabels Font",&mTimeLabelsFont); | 175 | addItemFont("TimeLabels Font",&mTimeLabelsFont); |
176 | addItemFont("TodoView Font",&mTodoViewFont); | 176 | addItemFont("TodoView Font",&mTodoViewFont); |
177 | addItemFont("ListView Font",&mListViewFont); | 177 | addItemFont("ListView Font",&mListViewFont); |
178 | addItemFont("DateNavigator Font",&mDateNavigatorFont); | 178 | addItemFont("DateNavigator Font",&mDateNavigatorFont); |
179 | addItemFont("EditBox Font",&mEditBoxFont); | 179 | addItemFont("EditBox Font",&mEditBoxFont); |
180 | addItemFont("JournalView Font",&mJornalViewFont); | 180 | addItemFont("JournalView Font",&mJornalViewFont); |
181 | addItemFont("WhatsNextView Font",&mWhatsNextFont); | 181 | addItemFont("WhatsNextView Font",&mWhatsNextFont); |
182 | addItemFont("EventView Font",&mEventViewFont); | 182 | addItemFont("EventView Font",&mEventViewFont); |
183 | 183 | ||
184 | // KPrefs::setCurrentGroup("SyncProfiles"); | 184 | // KPrefs::setCurrentGroup("SyncProfiles"); |
185 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); | 185 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); |
186 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); | 186 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); |
187 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); | 187 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); |
188 | 188 | ||
189 | KPrefs::setCurrentGroup("RemoteSyncing"); | 189 | KPrefs::setCurrentGroup("RemoteSyncing"); |
190 | // addItemBool("UsePasswd",&mUsePassWd,false); | 190 | // addItemBool("UsePasswd",&mUsePassWd,false); |
191 | // addItemBool("WriteBackFile",&mWriteBackFile,true); | 191 | // addItemBool("WriteBackFile",&mWriteBackFile,true); |
192 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); | 192 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); |
193 | // addItemBool("AskForPreferences",&mAskForPreferences,true); | 193 | // addItemBool("AskForPreferences",&mAskForPreferences,true); |
194 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); | 194 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); |
195 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 195 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
196 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 196 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
197 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 197 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
198 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 198 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
199 | 199 | ||
200 | #ifdef _WIN32_ | 200 | #ifdef _WIN32_ |
201 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 201 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
202 | #else | 202 | #else |
203 | QString hdp= locateLocal("data","korganizer")+"/"; | 203 | QString hdp= locateLocal("data","korganizer")+"/"; |
204 | #endif | 204 | #endif |
205 | // addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); | ||
206 | // addItemString("RemoteUser",&mRemoteUser, "zaurus"); | ||
207 | // addItemString("RemotePassWd",&mRemotePassWd, ""); | ||
208 | // addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); | ||
209 | // addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); | ||
210 | |||
211 | 205 | ||
212 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 206 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
213 | 207 | ||
214 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 208 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
215 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 209 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
216 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 210 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
217 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 211 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
218 | 212 | ||
219 | 213 | ||
220 | KPrefs::setCurrentGroup("Locale"); | 214 | KPrefs::setCurrentGroup("Locale"); |
221 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); | 215 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); |
222 | addItemInt("PreferredTime",&mPreferredTime,0); | 216 | addItemInt("PreferredTime",&mPreferredTime,0); |
223 | addItemInt("PreferredDate",&mPreferredDate,0); | 217 | addItemInt("PreferredDate",&mPreferredDate,0); |
224 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); | 218 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); |
225 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 219 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
226 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); | 220 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); |
227 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); | 221 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); |
228 | 222 | ||
229 | 223 | ||
230 | KPrefs::setCurrentGroup("Colors"); | 224 | KPrefs::setCurrentGroup("Colors"); |
231 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 225 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
232 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 226 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
233 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 227 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
234 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 228 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
235 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 229 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
236 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 230 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
237 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 231 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
238 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 232 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
239 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 233 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
240 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 234 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
241 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 235 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
242 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 236 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
243 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 237 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
244 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 238 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
245 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 239 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
246 | addItemBool("UseAppColors",&mUseAppColors,false); | 240 | addItemBool("UseAppColors",&mUseAppColors,false); |
247 | 241 | ||
248 | 242 | ||
249 | 243 | ||
250 | KPrefs::setCurrentGroup("Views"); | 244 | KPrefs::setCurrentGroup("Views"); |
251 | addItemInt("Hour Size",&mHourSize,8); | 245 | addItemInt("Hour Size",&mHourSize,8); |
252 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 246 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
253 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 247 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
254 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 248 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
255 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 249 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
256 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 250 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
257 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 251 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
258 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 252 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
259 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 253 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
260 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 254 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
261 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 255 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
262 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 256 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
263 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); | 257 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); |
264 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 258 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
265 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 259 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
266 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 260 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
267 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 261 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
268 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); | 262 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); |
269 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 263 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
270 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 264 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
271 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 265 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
272 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 266 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
273 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 267 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
274 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); | 268 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); |
275 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 269 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
276 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 270 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
277 | #ifdef DESKTOP_VERSION | 271 | #ifdef DESKTOP_VERSION |
278 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 272 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
279 | #else | 273 | #else |
280 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 274 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
281 | #endif | 275 | #endif |
282 | addItemInt("Day Begins",&mDayBegins,7); | 276 | addItemInt("Day Begins",&mDayBegins,7); |
283 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 277 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
284 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 278 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
285 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 279 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
286 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 280 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
287 | 281 | ||
288 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 282 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
289 | addItemBool("Full View Month",&mFullViewMonth,true); | 283 | addItemBool("Full View Month",&mFullViewMonth,true); |
290 | addItemBool("Full View Todo",&mFullViewTodo,true); | 284 | addItemBool("Full View Todo",&mFullViewTodo,true); |
291 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 285 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
292 | 286 | ||
293 | addItemInt("Next X Days",&mNextXDays,3); | 287 | addItemInt("Next X Days",&mNextXDays,3); |
294 | 288 | ||
295 | KPrefs::setCurrentGroup("Printer"); | 289 | KPrefs::setCurrentGroup("Printer"); |
296 | 290 | ||
297 | KPrefs::setCurrentGroup("Layout"); | 291 | KPrefs::setCurrentGroup("Layout"); |
298 | 292 | ||
299 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 293 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
300 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 294 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
301 | 295 | ||
302 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 296 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
303 | 297 | ||
304 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 298 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
305 | 299 | ||
306 | KPrefs::setCurrentGroup("Group Scheduling"); | 300 | KPrefs::setCurrentGroup("Group Scheduling"); |
307 | 301 | ||
308 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 302 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
309 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 303 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
310 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 304 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
311 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 305 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
312 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 306 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
313 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 307 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
314 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 308 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
315 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 309 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
316 | 310 | ||
317 | KPrefs::setCurrentGroup( "Editors" ); | 311 | KPrefs::setCurrentGroup( "Editors" ); |
318 | 312 | ||
319 | addItemStringList( "EventTemplates", &mEventTemplates ); | 313 | addItemStringList( "EventTemplates", &mEventTemplates ); |
320 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 314 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
321 | 315 | ||
322 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 316 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
323 | 317 | ||
324 | 318 | ||
325 | 319 | ||
326 | } | 320 | } |
327 | 321 | ||
328 | 322 | ||
329 | KOPrefs::~KOPrefs() | 323 | KOPrefs::~KOPrefs() |
330 | { | 324 | { |
331 | if (mInstance == this) | 325 | if (mInstance == this) |
332 | mInstance = insd.setObject(0); | 326 | mInstance = insd.setObject(0); |
333 | setLocaleDict( 0 ); | 327 | setLocaleDict( 0 ); |
334 | if ( mLocaleDict ) | 328 | if ( mLocaleDict ) |
335 | delete mLocaleDict; | 329 | delete mLocaleDict; |
336 | //qDebug("KOPrefs::~KOPrefs() "); | 330 | //qDebug("KOPrefs::~KOPrefs() "); |
337 | } | 331 | } |
338 | 332 | ||
339 | 333 | ||
340 | KOPrefs *KOPrefs::instance() | 334 | KOPrefs *KOPrefs::instance() |
341 | { | 335 | { |
342 | if (!mInstance) { | 336 | if (!mInstance) { |
343 | mInstance = insd.setObject(new KOPrefs()); | 337 | mInstance = insd.setObject(new KOPrefs()); |
344 | mInstance->readConfig(); | 338 | mInstance->readConfig(); |
345 | } | 339 | } |
346 | 340 | ||
347 | return mInstance; | 341 | return mInstance; |
348 | } | 342 | } |
349 | 343 | ||
350 | void KOPrefs::usrSetDefaults() | 344 | void KOPrefs::usrSetDefaults() |
351 | { | 345 | { |
352 | 346 | ||
353 | } | 347 | } |
354 | 348 | ||
355 | void KOPrefs::fillMailDefaults() | 349 | void KOPrefs::fillMailDefaults() |
356 | { | 350 | { |
357 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 351 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
358 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 352 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
359 | } | 353 | } |
360 | 354 | ||
361 | void KOPrefs::setTimeZoneIdDefault() | 355 | void KOPrefs::setTimeZoneIdDefault() |
362 | { | 356 | { |
363 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); | 357 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); |
364 | } | 358 | } |
365 | 359 | ||
366 | void KOPrefs::setCategoryDefaults() | 360 | void KOPrefs::setCategoryDefaults() |
367 | { | 361 | { |
368 | mCustomCategories.clear(); | 362 | mCustomCategories.clear(); |
369 | mCustomCategories = getDefaultList(); | 363 | mCustomCategories = getDefaultList(); |
370 | 364 | ||
371 | QStringList::Iterator it; | 365 | QStringList::Iterator it; |
372 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 366 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
373 | setCategoryColor(*it,mDefaultCategoryColor); | 367 | setCategoryColor(*it,mDefaultCategoryColor); |
374 | } | 368 | } |
375 | } | 369 | } |
376 | 370 | ||
377 | QStringList KOPrefs::getDefaultList() | 371 | QStringList KOPrefs::getDefaultList() |
378 | { | 372 | { |
379 | QStringList retval ; | 373 | QStringList retval ; |
380 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") | 374 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") |
381 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") | 375 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") |
382 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") | 376 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") |
383 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") | 377 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") |
384 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") | 378 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") |
385 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") | 379 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") |
386 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") | 380 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") |
387 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; | 381 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; |
388 | retval.sort(); | 382 | retval.sort(); |
389 | return retval; | 383 | return retval; |
390 | } | 384 | } |
391 | 385 | ||
392 | void KOPrefs::usrReadConfig() | 386 | void KOPrefs::usrReadConfig() |
393 | { | 387 | { |
394 | mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 388 | mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
395 | mLocaleDict = 0; | 389 | mLocaleDict = 0; |
396 | // pending LR fix translation | 390 | // pending LR fix translation |
397 | // qDebug("KOPrefs::usrReadConfig() fix translation "); | 391 | // qDebug("KOPrefs::usrReadConfig() fix translation "); |
398 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { | 392 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { |
399 | if ( mPreferredLanguage == 1 ) { | 393 | if ( mPreferredLanguage == 1 ) { |
400 | mLocaleDict = new QDict<QString>; | 394 | mLocaleDict = new QDict<QString>; |
401 | int i = 0; | 395 | int i = 0; |
402 | QString fw ( germanwords[i] [0]); | 396 | QString fw ( germanwords[i] [0]); |
403 | while ( !fw.isEmpty() ) { | 397 | while ( !fw.isEmpty() ) { |
404 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); | 398 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); |
405 | ++i; | 399 | ++i; |
406 | fw = germanwords[i] [0]; | 400 | fw = germanwords[i] [0]; |
407 | } | 401 | } |
408 | 402 | ||
409 | setLocaleDict( mLocaleDict ); | 403 | setLocaleDict( mLocaleDict ); |
410 | } else { | 404 | } else { |
411 | QString fileName ; | 405 | QString fileName ; |
412 | if ( mPreferredLanguage == 4 ) | 406 | if ( mPreferredLanguage == 4 ) |
413 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; | 407 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; |
414 | else if ( mPreferredLanguage == 2 ) | 408 | else if ( mPreferredLanguage == 2 ) |
415 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; | 409 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; |
416 | else if ( mPreferredLanguage == 3 ) | 410 | else if ( mPreferredLanguage == 3 ) |
417 | fileName = MainWindow::resourcePath()+"italiantranslation.txt"; | 411 | fileName = MainWindow::resourcePath()+"italiantranslation.txt"; |
418 | QFile file( fileName ); | 412 | QFile file( fileName ); |
419 | if (file.open( IO_ReadOnly ) ) { | 413 | if (file.open( IO_ReadOnly ) ) { |
420 | QTextStream ts( &file ); | 414 | QTextStream ts( &file ); |
421 | ts.setEncoding( QTextStream::Latin1 ); | 415 | ts.setEncoding( QTextStream::Latin1 ); |
422 | //ts.setCodec( QTextCodec::latin1 ); | 416 | //ts.setCodec( QTextCodec::latin1 ); |
423 | QString text = ts.read(); | 417 | QString text = ts.read(); |
424 | file.close(); | 418 | file.close(); |
425 | text.replace( QRegExp("\\\\n"), "\n" ); | 419 | text.replace( QRegExp("\\\\n"), "\n" ); |
426 | QString line; | 420 | QString line; |
427 | QString we; | 421 | QString we; |
428 | QString wt; | 422 | QString wt; |
429 | int br = 0; | 423 | int br = 0; |
430 | int nbr; | 424 | int nbr; |
431 | nbr = text.find ( "},", br ); | 425 | nbr = text.find ( "},", br ); |
432 | line = text.mid( br, nbr - br ); | 426 | line = text.mid( br, nbr - br ); |
433 | br = nbr+1; | 427 | br = nbr+1; |
434 | int se, ee, st, et; | 428 | int se, ee, st, et; |
435 | mLocaleDict = new QDict<QString>; | 429 | mLocaleDict = new QDict<QString>; |
436 | QString end = "{ \"\",\"\" }"; | 430 | QString end = "{ \"\",\"\" }"; |
437 | while ( (line != end) && (br > 1) ) { | 431 | while ( (line != end) && (br > 1) ) { |
438 | //qDebug("%d *%s* ", br, line.latin1()); | 432 | //qDebug("%d *%s* ", br, line.latin1()); |
439 | se = line.find("\"")+1; | 433 | se = line.find("\"")+1; |
440 | et = line.findRev("\"",-1); | 434 | et = line.findRev("\"",-1); |
441 | ee = line.find("\",\""); | 435 | ee = line.find("\",\""); |
442 | st = ee+3; | 436 | st = ee+3; |
443 | we = line.mid( se, ee-se ); | 437 | we = line.mid( se, ee-se ); |
444 | wt = line.mid( st, et-st ); | 438 | wt = line.mid( st, et-st ); |
445 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | 439 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); |
446 | mLocaleDict->insert( we, new QString (wt) ); | 440 | mLocaleDict->insert( we, new QString (wt) ); |
447 | nbr = text.find ( "}", br ); | 441 | nbr = text.find ( "}", br ); |
448 | line = text.mid( br, nbr - br ); | 442 | line = text.mid( br, nbr - br ); |
449 | br = nbr+1; | 443 | br = nbr+1; |
450 | } | 444 | } |
451 | //qDebug("end *%s* ", end.latin1()); | 445 | //qDebug("end *%s* ", end.latin1()); |
452 | 446 | ||
453 | setLocaleDict( mLocaleDict ); | 447 | setLocaleDict( mLocaleDict ); |
454 | } else { | 448 | } else { |
455 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | 449 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); |
456 | } | 450 | } |
457 | 451 | ||
458 | } | 452 | } |
459 | } | 453 | } |
460 | config()->setGroup("General"); | 454 | config()->setGroup("General"); |
461 | 455 | ||
462 | mCustomCategories = config()->readListEntry("Custom Categories"); | 456 | mCustomCategories = config()->readListEntry("Custom Categories"); |
463 | if ( KOPrefs::instance()->mLanguageChanged ) { | 457 | if ( KOPrefs::instance()->mLanguageChanged ) { |
464 | mLocationDefaults.clear(); | 458 | mLocationDefaults.clear(); |
465 | mEventSummaryUser.clear(); | 459 | mEventSummaryUser.clear(); |
466 | mTodoSummaryUser.clear(); | 460 | mTodoSummaryUser.clear(); |
467 | } | 461 | } |
468 | if (mLocationDefaults.isEmpty()) { | 462 | if (mLocationDefaults.isEmpty()) { |
469 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 463 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
470 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 464 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
471 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 465 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
472 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 466 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
473 | mLocationDefaults.sort(); | 467 | mLocationDefaults.sort(); |
474 | } | 468 | } |
475 | 469 | ||
476 | if (mEventSummaryUser.isEmpty()) { | 470 | if (mEventSummaryUser.isEmpty()) { |
477 | mEventSummaryUser = getDefaultList() ; | 471 | mEventSummaryUser = getDefaultList() ; |
478 | } | 472 | } |
479 | if (mTodoSummaryUser.isEmpty()) { | 473 | if (mTodoSummaryUser.isEmpty()) { |
480 | mTodoSummaryUser = getDefaultList() ; | 474 | mTodoSummaryUser = getDefaultList() ; |
481 | } | 475 | } |
482 | 476 | ||
483 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 477 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
484 | 478 | ||
485 | config()->setGroup("Personal Settings"); | 479 | config()->setGroup("Personal Settings"); |
486 | mName = config()->readEntry("user_name",""); | 480 | mName = config()->readEntry("user_name",""); |
487 | mEmail = config()->readEntry("user_email",""); | 481 | mEmail = config()->readEntry("user_email",""); |
488 | fillMailDefaults(); | 482 | fillMailDefaults(); |
489 | 483 | ||
490 | config()->setGroup("Category Colors"); | 484 | config()->setGroup("Category Colors"); |
491 | QStringList::Iterator it; | 485 | QStringList::Iterator it; |
492 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 486 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
493 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 487 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
494 | 488 | ||
495 | } | 489 | } |
496 | 490 | ||
497 | if (mTimeZoneId.isEmpty()) { | 491 | if (mTimeZoneId.isEmpty()) { |
498 | setTimeZoneIdDefault(); | 492 | setTimeZoneIdDefault(); |
499 | } | 493 | } |
500 | KPimPrefs::usrReadConfig(); | 494 | KPimPrefs::usrReadConfig(); |
501 | } | 495 | } |
502 | 496 | ||
503 | 497 | ||
504 | void KOPrefs::usrWriteConfig() | 498 | void KOPrefs::usrWriteConfig() |
505 | { | 499 | { |
506 | config()->setGroup("General"); | 500 | config()->setGroup("General"); |
507 | config()->writeEntry("Custom Categories",mCustomCategories); | 501 | config()->writeEntry("Custom Categories",mCustomCategories); |
508 | 502 | ||
509 | config()->setGroup("Personal Settings"); | 503 | config()->setGroup("Personal Settings"); |
510 | config()->writeEntry("user_name",mName); | 504 | config()->writeEntry("user_name",mName); |
511 | config()->writeEntry("user_email",mEmail); | 505 | config()->writeEntry("user_email",mEmail); |
512 | 506 | ||
513 | config()->setGroup("Category Colors"); | 507 | config()->setGroup("Category Colors"); |
514 | QDictIterator<QColor> it(mCategoryColors); | 508 | QDictIterator<QColor> it(mCategoryColors); |
515 | while (it.current()) { | 509 | while (it.current()) { |
516 | config()->writeEntry(it.currentKey(),*(it.current())); | 510 | config()->writeEntry(it.currentKey(),*(it.current())); |
517 | ++it; | 511 | ++it; |
518 | } | 512 | } |
519 | 513 | ||
520 | 514 | ||
521 | KPimPrefs::usrWriteConfig(); | 515 | KPimPrefs::usrWriteConfig(); |
522 | } | 516 | } |
523 | 517 | ||
524 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 518 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
525 | { | 519 | { |
526 | mCategoryColors.replace(cat,new QColor(color)); | 520 | mCategoryColors.replace(cat,new QColor(color)); |
527 | } | 521 | } |
528 | 522 | ||
529 | QColor *KOPrefs::categoryColor(QString cat) | 523 | QColor *KOPrefs::categoryColor(QString cat) |
530 | { | 524 | { |
531 | QColor *color = 0; | 525 | QColor *color = 0; |
532 | 526 | ||
533 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 527 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
534 | 528 | ||
535 | if (color) return color; | 529 | if (color) return color; |
536 | else return &mDefaultCategoryColor; | 530 | else return &mDefaultCategoryColor; |
537 | } | 531 | } |
538 | 532 | ||
539 | void KOPrefs::setFullName(const QString &name) | 533 | void KOPrefs::setFullName(const QString &name) |
540 | { | 534 | { |
541 | mName = name; | 535 | mName = name; |
542 | } | 536 | } |
543 | 537 | ||
544 | void KOPrefs::setEmail(const QString &email) | 538 | void KOPrefs::setEmail(const QString &email) |
545 | { | 539 | { |
546 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 540 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
547 | mEmail = email; | 541 | mEmail = email; |
548 | } | 542 | } |
549 | 543 | ||
550 | QString KOPrefs::fullName() | 544 | QString KOPrefs::fullName() |
551 | { | 545 | { |
552 | if (mEmailControlCenter) { | 546 | if (mEmailControlCenter) { |
553 | KEMailSettings settings; | 547 | KEMailSettings settings; |
554 | return settings.getSetting(KEMailSettings::RealName); | 548 | return settings.getSetting(KEMailSettings::RealName); |
555 | } else { | 549 | } else { |
556 | return mName; | 550 | return mName; |
557 | } | 551 | } |
558 | } | 552 | } |
559 | 553 | ||
560 | QString KOPrefs::email() | 554 | QString KOPrefs::email() |
561 | { | 555 | { |
562 | if (mEmailControlCenter) { | 556 | if (mEmailControlCenter) { |
563 | KEMailSettings settings; | 557 | KEMailSettings settings; |
564 | return settings.getSetting(KEMailSettings::EmailAddress); | 558 | return settings.getSetting(KEMailSettings::EmailAddress); |
565 | } else { | 559 | } else { |
566 | return mEmail; | 560 | return mEmail; |
567 | } | 561 | } |
568 | } | 562 | } |
569 | KConfig* KOPrefs::getConfig() | 563 | KConfig* KOPrefs::getConfig() |
570 | { | 564 | { |
571 | return config(); | 565 | return config(); |
572 | } | 566 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 06470b8..c3e9f75 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,1825 +1,1825 @@ | |||
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 ( KOPrefs::instance()->mLanguageChanged ) { | 228 | if ( KOPrefs::instance()->mLanguageChanged ) { |
229 | KOPrefs::instance()->setCategoryDefaults(); | 229 | KOPrefs::instance()->setCategoryDefaults(); |
230 | int count = mView->addCategories(); | 230 | int count = mView->addCategories(); |
231 | KOPrefs::instance()->mLanguageChanged = false; | 231 | KOPrefs::instance()->mLanguageChanged = false; |
232 | } | 232 | } |
233 | processIncidenceSelection( 0 ); | 233 | processIncidenceSelection( 0 ); |
234 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 234 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
235 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 235 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
236 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 236 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
237 | SLOT( slotModifiedChanged( bool ) ) ); | 237 | SLOT( slotModifiedChanged( bool ) ) ); |
238 | 238 | ||
239 | 239 | ||
240 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 240 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
241 | mView->setModified( false ); | 241 | mView->setModified( false ); |
242 | mBlockAtStartup = false; | 242 | mBlockAtStartup = false; |
243 | mView->setModified( false ); | 243 | mView->setModified( false ); |
244 | setCentralWidget( mView ); | 244 | setCentralWidget( mView ); |
245 | globalFlagBlockStartup = 0; | 245 | globalFlagBlockStartup = 0; |
246 | mView->show(); | 246 | mView->show(); |
247 | delete splash; | 247 | delete splash; |
248 | if ( newFile ) | 248 | if ( newFile ) |
249 | mView->updateConfig(); | 249 | mView->updateConfig(); |
250 | // qApp->processEvents(); | 250 | // qApp->processEvents(); |
251 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 251 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
252 | //fillSyncMenu(); | 252 | //fillSyncMenu(); |
253 | 253 | ||
254 | 254 | ||
255 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 255 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
256 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 256 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
257 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 257 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
258 | mSyncManager->setDefaultFileName( defaultFileName()); | 258 | mSyncManager->setDefaultFileName( defaultFileName()); |
259 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 259 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
260 | mSyncManager->fillSyncMenu(); | 260 | mSyncManager->fillSyncMenu(); |
261 | 261 | ||
262 | 262 | ||
263 | 263 | ||
264 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 264 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
265 | if ( showWarning ) { | 265 | if ( showWarning ) { |
266 | KMessageBox::information( this, | 266 | KMessageBox::information( this, |
267 | "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"); | 267 | "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 | qApp->processEvents(); | 268 | qApp->processEvents(); |
269 | mView->dialogManager()->showSyncOptions(); | 269 | mView->dialogManager()->showSyncOptions(); |
270 | } | 270 | } |
271 | 271 | ||
272 | //US listen for result adressed from Ka/Pi | 272 | //US listen for result adressed from Ka/Pi |
273 | #ifndef DESKTOP_VERSION | 273 | #ifndef DESKTOP_VERSION |
274 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 274 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
275 | #endif | 275 | #endif |
276 | 276 | ||
277 | } | 277 | } |
278 | MainWindow::~MainWindow() | 278 | MainWindow::~MainWindow() |
279 | { | 279 | { |
280 | //qDebug("MainWindow::~MainWindow() "); | 280 | //qDebug("MainWindow::~MainWindow() "); |
281 | //save toolbar location | 281 | //save toolbar location |
282 | delete mCalendar; | 282 | delete mCalendar; |
283 | delete mSyncManager; | 283 | delete mSyncManager; |
284 | 284 | ||
285 | 285 | ||
286 | } | 286 | } |
287 | void MainWindow::showMaximized () | 287 | void MainWindow::showMaximized () |
288 | { | 288 | { |
289 | #ifndef DESKTOP_VERSION | 289 | #ifndef DESKTOP_VERSION |
290 | if ( ! globalFlagBlockStartup ) | 290 | if ( ! globalFlagBlockStartup ) |
291 | if ( mClosed ) | 291 | if ( mClosed ) |
292 | mView->goToday(); | 292 | mView->goToday(); |
293 | #endif | 293 | #endif |
294 | QWidget::showMaximized () ; | 294 | QWidget::showMaximized () ; |
295 | mClosed = false; | 295 | mClosed = false; |
296 | } | 296 | } |
297 | void MainWindow::closeEvent( QCloseEvent* ce ) | 297 | void MainWindow::closeEvent( QCloseEvent* ce ) |
298 | { | 298 | { |
299 | 299 | ||
300 | 300 | ||
301 | 301 | ||
302 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 302 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
303 | saveOnClose(); | 303 | saveOnClose(); |
304 | mClosed = true; | 304 | mClosed = true; |
305 | ce->accept(); | 305 | ce->accept(); |
306 | return; | 306 | return; |
307 | 307 | ||
308 | } | 308 | } |
309 | 309 | ||
310 | switch( QMessageBox::information( this, "KO/Pi", | 310 | switch( QMessageBox::information( this, "KO/Pi", |
311 | i18n("Do you really want\nto close KO/Pi?"), | 311 | i18n("Do you really want\nto close KO/Pi?"), |
312 | i18n("Close"), i18n("No"), | 312 | i18n("Close"), i18n("No"), |
313 | 0, 0 ) ) { | 313 | 0, 0 ) ) { |
314 | case 0: | 314 | case 0: |
315 | saveOnClose(); | 315 | saveOnClose(); |
316 | mClosed = true; | 316 | mClosed = true; |
317 | ce->accept(); | 317 | ce->accept(); |
318 | break; | 318 | break; |
319 | case 1: | 319 | case 1: |
320 | ce->ignore(); | 320 | ce->ignore(); |
321 | break; | 321 | break; |
322 | case 2: | 322 | case 2: |
323 | 323 | ||
324 | default: | 324 | default: |
325 | break; | 325 | break; |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | } | 329 | } |
330 | 330 | ||
331 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 331 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
332 | { | 332 | { |
333 | QDataStream stream( data, IO_ReadOnly ); | 333 | QDataStream stream( data, IO_ReadOnly ); |
334 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 334 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
335 | //QString datamess; | 335 | //QString datamess; |
336 | //qDebug("message "); | 336 | //qDebug("message "); |
337 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 337 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
338 | 338 | ||
339 | if ( cmsg == "setDocument(QString)" ) { | 339 | if ( cmsg == "setDocument(QString)" ) { |
340 | QDataStream stream( data, IO_ReadOnly ); | 340 | QDataStream stream( data, IO_ReadOnly ); |
341 | QString fileName; | 341 | QString fileName; |
342 | stream >> fileName; | 342 | stream >> fileName; |
343 | //qDebug("filename %s ", fileName.latin1()); | 343 | //qDebug("filename %s ", fileName.latin1()); |
344 | showMaximized(); | 344 | showMaximized(); |
345 | raise(); | 345 | raise(); |
346 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 346 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
347 | mSyncManager->slotSyncMenu( 1002 ); | 347 | mSyncManager->slotSyncMenu( 1002 ); |
348 | return; | 348 | return; |
349 | } | 349 | } |
350 | 350 | ||
351 | if ( cmsg == "-writeFile" ) { | 351 | if ( cmsg == "-writeFile" ) { |
352 | // I made from the "-writeFile" an "-writeAlarm" | 352 | // I made from the "-writeFile" an "-writeAlarm" |
353 | mView->viewManager()->showWhatsNextView(); | 353 | mView->viewManager()->showWhatsNextView(); |
354 | mCalendar->checkAlarmForIncidence( 0, true); | 354 | mCalendar->checkAlarmForIncidence( 0, true); |
355 | showMaximized(); | 355 | showMaximized(); |
356 | raise(); | 356 | raise(); |
357 | return; | 357 | return; |
358 | 358 | ||
359 | } | 359 | } |
360 | if ( cmsg == "-writeFileSilent" ) { | 360 | if ( cmsg == "-writeFileSilent" ) { |
361 | // I made from the "-writeFile" an "-writeAlarm" | 361 | // I made from the "-writeFile" an "-writeAlarm" |
362 | // mView->viewManager()->showWhatsNextView(); | 362 | // mView->viewManager()->showWhatsNextView(); |
363 | mCalendar->checkAlarmForIncidence( 0, true); | 363 | mCalendar->checkAlarmForIncidence( 0, true); |
364 | //showMaximized(); | 364 | //showMaximized(); |
365 | //raise(); | 365 | //raise(); |
366 | hide(); | 366 | hide(); |
367 | return; | 367 | return; |
368 | } | 368 | } |
369 | if ( cmsg == "-newCountdown" ) { | 369 | if ( cmsg == "-newCountdown" ) { |
370 | qDebug("newCountdown "); | 370 | qDebug("newCountdown "); |
371 | 371 | ||
372 | } | 372 | } |
373 | QString msg ; | 373 | QString msg ; |
374 | QString allmsg = cmsg; | 374 | QString allmsg = cmsg; |
375 | while ( allmsg.length() > 0 ) { | 375 | while ( allmsg.length() > 0 ) { |
376 | int nextC = allmsg.find( "-", 1 ); | 376 | int nextC = allmsg.find( "-", 1 ); |
377 | if ( nextC == -1 ) { | 377 | if ( nextC == -1 ) { |
378 | msg = allmsg; | 378 | msg = allmsg; |
379 | allmsg = ""; | 379 | allmsg = ""; |
380 | } else{ | 380 | } else{ |
381 | msg = allmsg.left( nextC ); | 381 | msg = allmsg.left( nextC ); |
382 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 382 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
383 | } | 383 | } |
384 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 384 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
385 | if ( msg == "-newEvent" ) { | 385 | if ( msg == "-newEvent" ) { |
386 | mView->newEvent(); | 386 | mView->newEvent(); |
387 | } | 387 | } |
388 | if ( msg == "-newTodo" ) { | 388 | if ( msg == "-newTodo" ) { |
389 | mView->newTodo(); | 389 | mView->newTodo(); |
390 | 390 | ||
391 | } | 391 | } |
392 | if ( msg == "-showWN" ) { | 392 | if ( msg == "-showWN" ) { |
393 | mView->viewManager()->showWhatsNextView(); | 393 | mView->viewManager()->showWhatsNextView(); |
394 | } | 394 | } |
395 | if ( msg == "-showTodo" ) { | 395 | if ( msg == "-showTodo" ) { |
396 | mView->viewManager()->showTodoView(); | 396 | mView->viewManager()->showTodoView(); |
397 | } | 397 | } |
398 | if ( msg == "-showList" ) { | 398 | if ( msg == "-showList" ) { |
399 | mView->viewManager()->showListView(); | 399 | mView->viewManager()->showListView(); |
400 | } | 400 | } |
401 | else if ( msg == "-showDay" ) { | 401 | else if ( msg == "-showDay" ) { |
402 | mView->viewManager()->showDayView(); | 402 | mView->viewManager()->showDayView(); |
403 | } | 403 | } |
404 | else if ( msg == "-showWWeek" ) { | 404 | else if ( msg == "-showWWeek" ) { |
405 | mView->viewManager()->showWorkWeekView(); | 405 | mView->viewManager()->showWorkWeekView(); |
406 | } | 406 | } |
407 | else if ( msg == "-ringSync" ) { | 407 | else if ( msg == "-ringSync" ) { |
408 | mSyncManager->multiSync( false ); | 408 | mSyncManager->multiSync( false ); |
409 | } | 409 | } |
410 | else if ( msg == "-showWeek" ) { | 410 | else if ( msg == "-showWeek" ) { |
411 | mView->viewManager()->showWeekView(); | 411 | mView->viewManager()->showWeekView(); |
412 | } | 412 | } |
413 | else if ( msg == "-showTodo" ) { | 413 | else if ( msg == "-showTodo" ) { |
414 | mView->viewManager()->showTodoView(); | 414 | mView->viewManager()->showTodoView(); |
415 | } | 415 | } |
416 | else if ( msg == "-showJournal" ) { | 416 | else if ( msg == "-showJournal" ) { |
417 | mView->dateNavigator()->selectDates( 1 ); | 417 | mView->dateNavigator()->selectDates( 1 ); |
418 | mView->dateNavigator()->selectToday(); | 418 | mView->dateNavigator()->selectToday(); |
419 | mView->viewManager()->showJournalView(); | 419 | mView->viewManager()->showJournalView(); |
420 | } | 420 | } |
421 | else if ( msg == "-showKO" ) { | 421 | else if ( msg == "-showKO" ) { |
422 | mView->viewManager()->showNextXView(); | 422 | mView->viewManager()->showNextXView(); |
423 | } | 423 | } |
424 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 424 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
425 | mView->viewManager()->showWhatsNextView(); | 425 | mView->viewManager()->showWhatsNextView(); |
426 | } | 426 | } |
427 | else if ( msg == "-showNextXView" ) { | 427 | else if ( msg == "-showNextXView" ) { |
428 | mView->viewManager()->showNextXView(); | 428 | mView->viewManager()->showNextXView(); |
429 | } | 429 | } |
430 | 430 | ||
431 | 431 | ||
432 | } | 432 | } |
433 | 433 | ||
434 | showMaximized(); | 434 | showMaximized(); |
435 | raise(); | 435 | raise(); |
436 | } | 436 | } |
437 | 437 | ||
438 | QPixmap MainWindow::loadPixmap( QString name ) | 438 | QPixmap MainWindow::loadPixmap( QString name ) |
439 | { | 439 | { |
440 | return SmallIcon( name ); | 440 | return SmallIcon( name ); |
441 | 441 | ||
442 | } | 442 | } |
443 | void MainWindow::initActions() | 443 | void MainWindow::initActions() |
444 | { | 444 | { |
445 | //KOPrefs::instance()->mShowFullMenu | 445 | //KOPrefs::instance()->mShowFullMenu |
446 | iconToolBar->clear(); | 446 | iconToolBar->clear(); |
447 | KOPrefs *p = KOPrefs::instance(); | 447 | KOPrefs *p = KOPrefs::instance(); |
448 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 448 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
449 | 449 | ||
450 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 450 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
451 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 451 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
452 | QPopupMenu *importMenu = new QPopupMenu( this ); | 452 | QPopupMenu *importMenu = new QPopupMenu( this ); |
453 | selectFilterMenu = new QPopupMenu( this ); | 453 | selectFilterMenu = new QPopupMenu( this ); |
454 | selectFilterMenu->setCheckable( true ); | 454 | selectFilterMenu->setCheckable( true ); |
455 | syncMenu = new QPopupMenu( this ); | 455 | syncMenu = new QPopupMenu( this ); |
456 | configureAgendaMenu = new QPopupMenu( this ); | 456 | configureAgendaMenu = new QPopupMenu( this ); |
457 | configureToolBarMenu = new QPopupMenu( this ); | 457 | configureToolBarMenu = new QPopupMenu( this ); |
458 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 458 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
459 | if ( KOPrefs::instance()->mShowFullMenu ) { | 459 | if ( KOPrefs::instance()->mShowFullMenu ) { |
460 | QMenuBar *menuBar1; | 460 | QMenuBar *menuBar1; |
461 | menuBar1 = menuBar(); | 461 | menuBar1 = menuBar(); |
462 | menuBar1->insertItem( i18n("File"), importMenu ); | 462 | menuBar1->insertItem( i18n("File"), importMenu ); |
463 | menuBar1->insertItem( i18n("View"), viewMenu ); | 463 | menuBar1->insertItem( i18n("View"), viewMenu ); |
464 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 464 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
465 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 465 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
466 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 466 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
467 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 467 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
468 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 468 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
469 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 469 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
470 | } else { | 470 | } else { |
471 | QPEMenuBar *menuBar1; | 471 | QPEMenuBar *menuBar1; |
472 | menuBar1 = new QPEMenuBar( iconToolBar ); | 472 | menuBar1 = new QPEMenuBar( iconToolBar ); |
473 | QPopupMenu *menuBar = new QPopupMenu( this ); | 473 | QPopupMenu *menuBar = new QPopupMenu( this ); |
474 | menuBar1->insertItem( i18n("ME"), menuBar); | 474 | menuBar1->insertItem( i18n("ME"), menuBar); |
475 | menuBar->insertItem( i18n("File"), importMenu ); | 475 | menuBar->insertItem( i18n("File"), importMenu ); |
476 | menuBar->insertItem( i18n("View"), viewMenu ); | 476 | menuBar->insertItem( i18n("View"), viewMenu ); |
477 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 477 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
478 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 478 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
479 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 479 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
480 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 480 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
481 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 481 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
482 | menuBar->insertItem( i18n("Help"), helpMenu ); | 482 | menuBar->insertItem( i18n("Help"), helpMenu ); |
483 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 483 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
484 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 484 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
485 | } | 485 | } |
486 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 486 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
487 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); | 487 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); |
488 | 488 | ||
489 | // ****************** | 489 | // ****************** |
490 | QAction *action; | 490 | QAction *action; |
491 | QIconSet icon; | 491 | QIconSet icon; |
492 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 492 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
493 | configureToolBarMenu->setCheckable( true ); | 493 | configureToolBarMenu->setCheckable( true ); |
494 | 494 | ||
495 | QString pathString = ""; | 495 | QString pathString = ""; |
496 | if ( !p->mToolBarMiniIcons ) { | 496 | if ( !p->mToolBarMiniIcons ) { |
497 | if ( QApplication::desktop()->width() < 480 ) | 497 | if ( QApplication::desktop()->width() < 480 ) |
498 | pathString += "icons16/"; | 498 | pathString += "icons16/"; |
499 | } else | 499 | } else |
500 | pathString += "iconsmini/"; | 500 | pathString += "iconsmini/"; |
501 | configureAgendaMenu->setCheckable( true ); | 501 | configureAgendaMenu->setCheckable( true ); |
502 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); | 502 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); |
503 | configureAgendaMenu->insertSeparator(); | 503 | configureAgendaMenu->insertSeparator(); |
504 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); | 504 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); |
505 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); | 505 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); |
506 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); | 506 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); |
507 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); | 507 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); |
508 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); | 508 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); |
509 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); | 509 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); |
510 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); | 510 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); |
511 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); | 511 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); |
512 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 512 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
513 | 513 | ||
514 | icon = loadPixmap( pathString + "configure" ); | 514 | icon = loadPixmap( pathString + "configure" ); |
515 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 515 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
516 | action->addTo( actionMenu ); | 516 | action->addTo( actionMenu ); |
517 | connect( action, SIGNAL( activated() ), | 517 | connect( action, SIGNAL( activated() ), |
518 | mView, SLOT( edit_options() ) ); | 518 | mView, SLOT( edit_options() ) ); |
519 | actionMenu->insertSeparator(); | 519 | actionMenu->insertSeparator(); |
520 | icon = loadPixmap( pathString + "newevent" ); | 520 | icon = loadPixmap( pathString + "newevent" ); |
521 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 521 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
522 | configureToolBarMenu->insertSeparator(); | 522 | configureToolBarMenu->insertSeparator(); |
523 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 523 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
524 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 524 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
525 | ne_action->addTo( actionMenu ); | 525 | ne_action->addTo( actionMenu ); |
526 | connect( ne_action, SIGNAL( activated() ), | 526 | connect( ne_action, SIGNAL( activated() ), |
527 | mView, SLOT( newEvent() ) ); | 527 | mView, SLOT( newEvent() ) ); |
528 | icon = loadPixmap( pathString + "newtodo" ); | 528 | icon = loadPixmap( pathString + "newtodo" ); |
529 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 529 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
530 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 530 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
531 | nt_action->addTo( actionMenu ); | 531 | nt_action->addTo( actionMenu ); |
532 | connect( nt_action, SIGNAL( activated() ), | 532 | connect( nt_action, SIGNAL( activated() ), |
533 | mView, SLOT( newTodo() ) ); | 533 | mView, SLOT( newTodo() ) ); |
534 | icon = loadPixmap( pathString + "navi" ); | 534 | icon = loadPixmap( pathString + "navi" ); |
535 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 535 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
536 | action->addTo( viewMenu ); | 536 | action->addTo( viewMenu ); |
537 | connect( action, SIGNAL( activated() ), | 537 | connect( action, SIGNAL( activated() ), |
538 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 538 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
539 | icon = loadPixmap( pathString + "filter" ); | 539 | icon = loadPixmap( pathString + "filter" ); |
540 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 540 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
541 | action->addTo( viewMenu ); | 541 | action->addTo( viewMenu ); |
542 | connect( action, SIGNAL( activated() ), | 542 | connect( action, SIGNAL( activated() ), |
543 | mView, SLOT( toggleFilter() ) ); | 543 | mView, SLOT( toggleFilter() ) ); |
544 | 544 | ||
545 | 545 | ||
546 | viewMenu->insertSeparator(); | 546 | viewMenu->insertSeparator(); |
547 | icon = loadPixmap( pathString + "picker" ); | 547 | icon = loadPixmap( pathString + "picker" ); |
548 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 548 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
549 | action->addTo( viewMenu ); | 549 | action->addTo( viewMenu ); |
550 | connect( action, SIGNAL( activated() ), | 550 | connect( action, SIGNAL( activated() ), |
551 | mView, SLOT( showDatePicker() ) ); | 551 | mView, SLOT( showDatePicker() ) ); |
552 | action->addTo( iconToolBar ); | 552 | action->addTo( iconToolBar ); |
553 | viewMenu->insertSeparator(); | 553 | viewMenu->insertSeparator(); |
554 | icon = loadPixmap( pathString + "list" ); | 554 | icon = loadPixmap( pathString + "list" ); |
555 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 555 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
556 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 556 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
557 | showlist_action->addTo( viewMenu ); | 557 | showlist_action->addTo( viewMenu ); |
558 | connect( showlist_action, SIGNAL( activated() ), | 558 | connect( showlist_action, SIGNAL( activated() ), |
559 | mView->viewManager(), SLOT( showListView() ) ); | 559 | mView->viewManager(), SLOT( showListView() ) ); |
560 | 560 | ||
561 | 561 | ||
562 | icon = loadPixmap( pathString + "day" ); | 562 | icon = loadPixmap( pathString + "day" ); |
563 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 563 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
564 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 564 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
565 | day1_action->addTo( viewMenu ); | 565 | day1_action->addTo( viewMenu ); |
566 | // action->addTo( toolBar ); | 566 | // action->addTo( toolBar ); |
567 | connect( day1_action, SIGNAL( activated() ), | 567 | connect( day1_action, SIGNAL( activated() ), |
568 | mView->viewManager(), SLOT( showDayView() ) ); | 568 | mView->viewManager(), SLOT( showDayView() ) ); |
569 | 569 | ||
570 | icon = loadPixmap( pathString + "workweek" ); | 570 | icon = loadPixmap( pathString + "workweek" ); |
571 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 571 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
572 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 572 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
573 | day5_action->addTo( viewMenu ); | 573 | day5_action->addTo( viewMenu ); |
574 | connect( day5_action, SIGNAL( activated() ), | 574 | connect( day5_action, SIGNAL( activated() ), |
575 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 575 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
576 | 576 | ||
577 | icon = loadPixmap( pathString + "week" ); | 577 | icon = loadPixmap( pathString + "week" ); |
578 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 578 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
579 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 579 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
580 | day7_action->addTo( viewMenu ); | 580 | day7_action->addTo( viewMenu ); |
581 | connect( day7_action, SIGNAL( activated() ), | 581 | connect( day7_action, SIGNAL( activated() ), |
582 | mView->viewManager(), SLOT( showWeekView() ) ); | 582 | mView->viewManager(), SLOT( showWeekView() ) ); |
583 | 583 | ||
584 | icon = loadPixmap( pathString + "month" ); | 584 | icon = loadPixmap( pathString + "month" ); |
585 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 585 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
586 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 586 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
587 | month_action->addTo( viewMenu ); | 587 | month_action->addTo( viewMenu ); |
588 | connect( month_action, SIGNAL( activated() ), | 588 | connect( month_action, SIGNAL( activated() ), |
589 | mView->viewManager(), SLOT( showMonthView() ) ); | 589 | mView->viewManager(), SLOT( showMonthView() ) ); |
590 | 590 | ||
591 | icon = loadPixmap( pathString + "todo" ); | 591 | icon = loadPixmap( pathString + "todo" ); |
592 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 592 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
593 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 593 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
594 | todoview_action->addTo( viewMenu ); | 594 | todoview_action->addTo( viewMenu ); |
595 | connect( todoview_action, SIGNAL( activated() ), | 595 | connect( todoview_action, SIGNAL( activated() ), |
596 | mView->viewManager(), SLOT( showTodoView() ) ); | 596 | mView->viewManager(), SLOT( showTodoView() ) ); |
597 | 597 | ||
598 | icon = loadPixmap( pathString + "journal" ); | 598 | icon = loadPixmap( pathString + "journal" ); |
599 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 599 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
600 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 600 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
601 | viewjournal_action->addTo( viewMenu ); | 601 | viewjournal_action->addTo( viewMenu ); |
602 | connect( viewjournal_action, SIGNAL( activated() ), | 602 | connect( viewjournal_action, SIGNAL( activated() ), |
603 | mView->viewManager(), SLOT( showJournalView() ) ); | 603 | mView->viewManager(), SLOT( showJournalView() ) ); |
604 | 604 | ||
605 | icon = loadPixmap( pathString + "xdays" ); | 605 | icon = loadPixmap( pathString + "xdays" ); |
606 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | 606 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); |
607 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 607 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
608 | xdays_action->addTo( viewMenu ); | 608 | xdays_action->addTo( viewMenu ); |
609 | connect( xdays_action, SIGNAL( activated() ), | 609 | connect( xdays_action, SIGNAL( activated() ), |
610 | mView->viewManager(), SLOT( showNextXView() ) ); | 610 | mView->viewManager(), SLOT( showNextXView() ) ); |
611 | 611 | ||
612 | icon = loadPixmap( pathString + "whatsnext" ); | 612 | icon = loadPixmap( pathString + "whatsnext" ); |
613 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | 613 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); |
614 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 614 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
615 | whatsnext_action->addTo( viewMenu ); | 615 | whatsnext_action->addTo( viewMenu ); |
616 | connect( whatsnext_action, SIGNAL( activated() ), | 616 | connect( whatsnext_action, SIGNAL( activated() ), |
617 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 617 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
618 | 618 | ||
619 | #if 0 | 619 | #if 0 |
620 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 620 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
621 | action->addTo( viewMenu ); | 621 | action->addTo( viewMenu ); |
622 | connect( action, SIGNAL( activated() ), | 622 | connect( action, SIGNAL( activated() ), |
623 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 623 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
624 | #endif | 624 | #endif |
625 | 625 | ||
626 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 626 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
627 | this ); | 627 | this ); |
628 | mNewSubTodoAction->addTo( actionMenu ); | 628 | mNewSubTodoAction->addTo( actionMenu ); |
629 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 629 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
630 | mView, SLOT( newSubTodo() ) ); | 630 | mView, SLOT( newSubTodo() ) ); |
631 | 631 | ||
632 | actionMenu->insertSeparator(); | 632 | actionMenu->insertSeparator(); |
633 | 633 | ||
634 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 634 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
635 | mShowAction->addTo( actionMenu ); | 635 | mShowAction->addTo( actionMenu ); |
636 | connect( mShowAction, SIGNAL( activated() ), | 636 | connect( mShowAction, SIGNAL( activated() ), |
637 | mView, SLOT( showIncidence() ) ); | 637 | mView, SLOT( showIncidence() ) ); |
638 | 638 | ||
639 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 639 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
640 | mEditAction->addTo( actionMenu ); | 640 | mEditAction->addTo( actionMenu ); |
641 | connect( mEditAction, SIGNAL( activated() ), | 641 | connect( mEditAction, SIGNAL( activated() ), |
642 | mView, SLOT( editIncidence() ) ); | 642 | mView, SLOT( editIncidence() ) ); |
643 | 643 | ||
644 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 644 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
645 | mDeleteAction->addTo( actionMenu ); | 645 | mDeleteAction->addTo( actionMenu ); |
646 | connect( mDeleteAction, SIGNAL( activated() ), | 646 | connect( mDeleteAction, SIGNAL( activated() ), |
647 | mView, SLOT( deleteIncidence() ) ); | 647 | mView, SLOT( deleteIncidence() ) ); |
648 | 648 | ||
649 | 649 | ||
650 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 650 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
651 | mCloneAction->addTo( actionMenu ); | 651 | mCloneAction->addTo( actionMenu ); |
652 | connect( mCloneAction, SIGNAL( activated() ), | 652 | connect( mCloneAction, SIGNAL( activated() ), |
653 | mView, SLOT( cloneIncidence() ) ); | 653 | mView, SLOT( cloneIncidence() ) ); |
654 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 654 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
655 | mMoveAction->addTo( actionMenu ); | 655 | mMoveAction->addTo( actionMenu ); |
656 | connect( mMoveAction, SIGNAL( activated() ), | 656 | connect( mMoveAction, SIGNAL( activated() ), |
657 | mView, SLOT( moveIncidence() ) ); | 657 | mView, SLOT( moveIncidence() ) ); |
658 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 658 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
659 | mBeamAction->addTo( actionMenu ); | 659 | mBeamAction->addTo( actionMenu ); |
660 | connect( mBeamAction, SIGNAL( activated() ), | 660 | connect( mBeamAction, SIGNAL( activated() ), |
661 | mView, SLOT( beamIncidence() ) ); | 661 | mView, SLOT( beamIncidence() ) ); |
662 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 662 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
663 | mCancelAction->addTo( actionMenu ); | 663 | mCancelAction->addTo( actionMenu ); |
664 | connect( mCancelAction, SIGNAL( activated() ), | 664 | connect( mCancelAction, SIGNAL( activated() ), |
665 | mView, SLOT( toggleCancelIncidence() ) ); | 665 | mView, SLOT( toggleCancelIncidence() ) ); |
666 | 666 | ||
667 | actionMenu->insertSeparator(); | 667 | actionMenu->insertSeparator(); |
668 | 668 | ||
669 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 669 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
670 | this ); | 670 | this ); |
671 | action->addTo( actionMenu ); | 671 | action->addTo( actionMenu ); |
672 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 672 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
673 | 673 | ||
674 | icon = loadPixmap( pathString + "search" ); | 674 | icon = loadPixmap( pathString + "search" ); |
675 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 675 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
676 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | 676 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); |
677 | search_action->addTo( actionMenu ); | 677 | search_action->addTo( actionMenu ); |
678 | connect( search_action, SIGNAL( activated() ), | 678 | connect( search_action, SIGNAL( activated() ), |
679 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 679 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
680 | 680 | ||
681 | icon = loadPixmap( pathString + "today" ); | 681 | icon = loadPixmap( pathString + "today" ); |
682 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 682 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
683 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 683 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
684 | today_action->addTo( actionMenu ); | 684 | today_action->addTo( actionMenu ); |
685 | connect( today_action, SIGNAL( activated() ), | 685 | connect( today_action, SIGNAL( activated() ), |
686 | mView, SLOT( goToday() ) ); | 686 | mView, SLOT( goToday() ) ); |
687 | 687 | ||
688 | if ( KOPrefs::instance()->mShowFullMenu ) { | 688 | if ( KOPrefs::instance()->mShowFullMenu ) { |
689 | actionMenu->insertSeparator(); | 689 | actionMenu->insertSeparator(); |
690 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 690 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
691 | 691 | ||
692 | } | 692 | } |
693 | // actionMenu->insertSeparator(); | 693 | // actionMenu->insertSeparator(); |
694 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 694 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
695 | this ); | 695 | this ); |
696 | action->addTo( importMenu ); | 696 | action->addTo( importMenu ); |
697 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 697 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
698 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 698 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
699 | this ); | 699 | this ); |
700 | action->addTo( importMenu ); | 700 | action->addTo( importMenu ); |
701 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 701 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
702 | importMenu->insertSeparator(); | 702 | importMenu->insertSeparator(); |
703 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 703 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
704 | this ); | 704 | this ); |
705 | action->addTo( importMenu ); | 705 | action->addTo( importMenu ); |
706 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 706 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
707 | #ifndef DESKTOP_VERSION | 707 | #ifndef DESKTOP_VERSION |
708 | importMenu->insertSeparator(); | 708 | importMenu->insertSeparator(); |
709 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 709 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
710 | this ); | 710 | this ); |
711 | action->addTo( importMenu ); | 711 | action->addTo( importMenu ); |
712 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 712 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
713 | #else | 713 | #else |
714 | #ifdef _WIN32_ | 714 | #ifdef _WIN32_ |
715 | importMenu->insertSeparator(); | 715 | importMenu->insertSeparator(); |
716 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 716 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
717 | this ); | 717 | this ); |
718 | action->addTo( importMenu ); | 718 | action->addTo( importMenu ); |
719 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 719 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
720 | #endif | 720 | #endif |
721 | #endif | 721 | #endif |
722 | 722 | ||
723 | importMenu->insertSeparator(); | 723 | importMenu->insertSeparator(); |
724 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 724 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
725 | this ); | 725 | this ); |
726 | action->addTo( importMenu ); | 726 | action->addTo( importMenu ); |
727 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 727 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
728 | 728 | ||
729 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 729 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
730 | this ); | 730 | this ); |
731 | action->addTo( importMenu ); | 731 | action->addTo( importMenu ); |
732 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 732 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
733 | 733 | ||
734 | importMenu->insertSeparator(); | 734 | importMenu->insertSeparator(); |
735 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 735 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
736 | this ); | 736 | this ); |
737 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 737 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
738 | 738 | ||
739 | 739 | ||
740 | //LR | 740 | //LR |
741 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 741 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
742 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 742 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
743 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 743 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
744 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 744 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
745 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); | 745 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); |
746 | 746 | ||
747 | importMenu->insertSeparator(); | 747 | importMenu->insertSeparator(); |
748 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 748 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
749 | this ); | 749 | this ); |
750 | action->addTo( importMenu ); | 750 | action->addTo( importMenu ); |
751 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 751 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
752 | #ifndef DESKTOP_VERSION | 752 | #ifndef DESKTOP_VERSION |
753 | importMenu->insertSeparator(); | 753 | importMenu->insertSeparator(); |
754 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 754 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
755 | this ); | 755 | this ); |
756 | action->addTo( importMenu ); | 756 | action->addTo( importMenu ); |
757 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 757 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
758 | 758 | ||
759 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 759 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
760 | this ); | 760 | this ); |
761 | action->addTo( importMenu ); | 761 | action->addTo( importMenu ); |
762 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 762 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
763 | #else | 763 | #else |
764 | importMenu->insertSeparator(); | 764 | importMenu->insertSeparator(); |
765 | icon = loadPixmap( pathString + "print" ); | 765 | icon = loadPixmap( pathString + "print" ); |
766 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 766 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
767 | action->addTo( importMenu ); | 767 | action->addTo( importMenu ); |
768 | connect( action, SIGNAL( activated() ), | 768 | connect( action, SIGNAL( activated() ), |
769 | this, SLOT( printCal() ) ); | 769 | this, SLOT( printCal() ) ); |
770 | 770 | ||
771 | icon = loadPixmap( pathString + "print" ); | 771 | icon = loadPixmap( pathString + "print" ); |
772 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 772 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
773 | action->addTo( importMenu ); | 773 | action->addTo( importMenu ); |
774 | connect( action, SIGNAL( activated() ), | 774 | connect( action, SIGNAL( activated() ), |
775 | this, SLOT( printSel() ) ); | 775 | this, SLOT( printSel() ) ); |
776 | #endif | 776 | #endif |
777 | importMenu->insertSeparator(); | 777 | importMenu->insertSeparator(); |
778 | action = new QAction( "beam all", i18n("Save"), 0, | 778 | action = new QAction( "beam all", i18n("Save"), 0, |
779 | this ); | 779 | this ); |
780 | action->addTo( importMenu ); | 780 | action->addTo( importMenu ); |
781 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 781 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
782 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 782 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
783 | this ); | 783 | this ); |
784 | action->addTo( importMenu ); | 784 | action->addTo( importMenu ); |
785 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 785 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
786 | 786 | ||
787 | //menuBar->insertItem( "Configure",configureMenu ); | 787 | //menuBar->insertItem( "Configure",configureMenu ); |
788 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 788 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
789 | icon = loadPixmap( "korganizer/korganizer" ); | 789 | icon = loadPixmap( "korganizer/korganizer" ); |
790 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 790 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
791 | action->addTo( helpMenu ); | 791 | action->addTo( helpMenu ); |
792 | connect( action, SIGNAL( activated() ), | 792 | connect( action, SIGNAL( activated() ), |
793 | SLOT( keyBindings() ) ); | 793 | SLOT( keyBindings() ) ); |
794 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 794 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
795 | action->addTo( helpMenu ); | 795 | action->addTo( helpMenu ); |
796 | connect( action, SIGNAL( activated() ), | 796 | connect( action, SIGNAL( activated() ), |
797 | SLOT( features() ) ); | 797 | SLOT( features() ) ); |
798 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 798 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
799 | action->addTo( helpMenu ); | 799 | action->addTo( helpMenu ); |
800 | connect( action, SIGNAL( activated() ), | 800 | connect( action, SIGNAL( activated() ), |
801 | SLOT( aboutAutoSaving() ) ); | 801 | SLOT( aboutAutoSaving() ) ); |
802 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 802 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
803 | action->addTo( helpMenu ); | 803 | action->addTo( helpMenu ); |
804 | connect( action, SIGNAL( activated() ), | 804 | connect( action, SIGNAL( activated() ), |
805 | SLOT( aboutKnownBugs() ) ); | 805 | SLOT( aboutKnownBugs() ) ); |
806 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 806 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
807 | action->addTo( helpMenu ); | 807 | action->addTo( helpMenu ); |
808 | connect( action, SIGNAL( activated() ), | 808 | connect( action, SIGNAL( activated() ), |
809 | SLOT( usertrans() ) ); | 809 | SLOT( usertrans() ) ); |
810 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 810 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
811 | action->addTo( helpMenu ); | 811 | action->addTo( helpMenu ); |
812 | connect( action, SIGNAL( activated() ), | 812 | connect( action, SIGNAL( activated() ), |
813 | SLOT( synchowto() ) ); | 813 | SLOT( synchowto() ) ); |
814 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 814 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
815 | action->addTo( helpMenu ); | 815 | action->addTo( helpMenu ); |
816 | connect( action, SIGNAL( activated() ), | 816 | connect( action, SIGNAL( activated() ), |
817 | SLOT( whatsNew() ) ); | 817 | SLOT( whatsNew() ) ); |
818 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 818 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
819 | action->addTo( helpMenu ); | 819 | action->addTo( helpMenu ); |
820 | connect( action, SIGNAL( activated() ), | 820 | connect( action, SIGNAL( activated() ), |
821 | SLOT( faq() ) ); | 821 | SLOT( faq() ) ); |
822 | 822 | ||
823 | 823 | ||
824 | action = new QAction( "about", i18n("About..."), 0, this ); | 824 | action = new QAction( "about", i18n("About..."), 0, this ); |
825 | action->addTo( helpMenu ); | 825 | action->addTo( helpMenu ); |
826 | connect( action, SIGNAL( activated() ), | 826 | connect( action, SIGNAL( activated() ), |
827 | SLOT( about() ) ); | 827 | SLOT( about() ) ); |
828 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 828 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
829 | action->addTo( helpMenu ); | 829 | action->addTo( helpMenu ); |
830 | connect( action, SIGNAL( activated() ), | 830 | connect( action, SIGNAL( activated() ), |
831 | SLOT( licence() ) ); | 831 | SLOT( licence() ) ); |
832 | //menuBar->insertSeparator(); | 832 | //menuBar->insertSeparator(); |
833 | 833 | ||
834 | // ****************************************************** | 834 | // ****************************************************** |
835 | // menubar icons | 835 | // menubar icons |
836 | 836 | ||
837 | 837 | ||
838 | iconToolBar->setHorizontalStretchable (true ); | 838 | iconToolBar->setHorizontalStretchable (true ); |
839 | //menuBar->insertItem( iconToolBar ); | 839 | //menuBar->insertItem( iconToolBar ); |
840 | //xdays_action | 840 | //xdays_action |
841 | if (p-> mShowIconNewEvent) | 841 | if (p-> mShowIconNewEvent) |
842 | ne_action->addTo( iconToolBar ); | 842 | ne_action->addTo( iconToolBar ); |
843 | if (p->mShowIconNewTodo ) | 843 | if (p->mShowIconNewTodo ) |
844 | nt_action->addTo( iconToolBar ); | 844 | nt_action->addTo( iconToolBar ); |
845 | if (p-> mShowIconSearch) | 845 | if (p-> mShowIconSearch) |
846 | search_action->addTo( iconToolBar ); | 846 | search_action->addTo( iconToolBar ); |
847 | if (p-> mShowIconNext) | 847 | if (p-> mShowIconNext) |
848 | whatsnext_action->addTo( iconToolBar ); | 848 | whatsnext_action->addTo( iconToolBar ); |
849 | if (p-> mShowIconNextDays) | 849 | if (p-> mShowIconNextDays) |
850 | xdays_action->addTo( iconToolBar ); | 850 | xdays_action->addTo( iconToolBar ); |
851 | if (p-> mShowIconList) | 851 | if (p-> mShowIconList) |
852 | showlist_action->addTo( iconToolBar ); | 852 | showlist_action->addTo( iconToolBar ); |
853 | if (p-> mShowIconDay1) | 853 | if (p-> mShowIconDay1) |
854 | day1_action->addTo( iconToolBar ); | 854 | day1_action->addTo( iconToolBar ); |
855 | if (p-> mShowIconDay5) | 855 | if (p-> mShowIconDay5) |
856 | day5_action->addTo( iconToolBar ); | 856 | day5_action->addTo( iconToolBar ); |
857 | if (p-> mShowIconDay7) | 857 | if (p-> mShowIconDay7) |
858 | day7_action->addTo( iconToolBar ); | 858 | day7_action->addTo( iconToolBar ); |
859 | if (p-> mShowIconMonth) | 859 | if (p-> mShowIconMonth) |
860 | month_action->addTo( iconToolBar ); | 860 | month_action->addTo( iconToolBar ); |
861 | if (p-> mShowIconTodoview) | 861 | if (p-> mShowIconTodoview) |
862 | todoview_action->addTo( iconToolBar ); | 862 | todoview_action->addTo( iconToolBar ); |
863 | if (p-> mShowIconJournal) | 863 | if (p-> mShowIconJournal) |
864 | viewjournal_action->addTo( iconToolBar ); | 864 | viewjournal_action->addTo( iconToolBar ); |
865 | icon = loadPixmap( pathString + "2leftarrowB" ); | 865 | icon = loadPixmap( pathString + "2leftarrowB" ); |
866 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 866 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
867 | if (p-> mShowIconBackFast) { | 867 | if (p-> mShowIconBackFast) { |
868 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 868 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
869 | connect( action, SIGNAL( activated() ), | 869 | connect( action, SIGNAL( activated() ), |
870 | mView, SLOT( goPreviousMonth() ) ); | 870 | mView, SLOT( goPreviousMonth() ) ); |
871 | action->addTo( iconToolBar ); | 871 | action->addTo( iconToolBar ); |
872 | } | 872 | } |
873 | icon = loadPixmap( pathString + "1leftarrowB" ); | 873 | icon = loadPixmap( pathString + "1leftarrowB" ); |
874 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 874 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
875 | if (p-> mShowIconBack) { | 875 | if (p-> mShowIconBack) { |
876 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 876 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
877 | connect( action, SIGNAL( activated() ), | 877 | connect( action, SIGNAL( activated() ), |
878 | mView, SLOT( goPrevious() ) ); | 878 | mView, SLOT( goPrevious() ) ); |
879 | action->addTo( iconToolBar ); | 879 | action->addTo( iconToolBar ); |
880 | } | 880 | } |
881 | if (p-> mShowIconToday) | 881 | if (p-> mShowIconToday) |
882 | today_action->addTo( iconToolBar ); | 882 | today_action->addTo( iconToolBar ); |
883 | icon = loadPixmap( pathString + "1rightarrowB" ); | 883 | icon = loadPixmap( pathString + "1rightarrowB" ); |
884 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 884 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
885 | if (p-> mShowIconForward) { | 885 | if (p-> mShowIconForward) { |
886 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 886 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
887 | connect( action, SIGNAL( activated() ), | 887 | connect( action, SIGNAL( activated() ), |
888 | mView, SLOT( goNext() ) ); | 888 | mView, SLOT( goNext() ) ); |
889 | action->addTo( iconToolBar ); | 889 | action->addTo( iconToolBar ); |
890 | } | 890 | } |
891 | icon = loadPixmap( pathString + "2rightarrowB" ); | 891 | icon = loadPixmap( pathString + "2rightarrowB" ); |
892 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 892 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
893 | if (p-> mShowIconForwardFast) { | 893 | if (p-> mShowIconForwardFast) { |
894 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 894 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
895 | connect( action, SIGNAL( activated() ), | 895 | connect( action, SIGNAL( activated() ), |
896 | mView, SLOT( goNextMonth() ) ); | 896 | mView, SLOT( goNextMonth() ) ); |
897 | action->addTo( iconToolBar ); | 897 | action->addTo( iconToolBar ); |
898 | } | 898 | } |
899 | 899 | ||
900 | 900 | ||
901 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 901 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
902 | 902 | ||
903 | if (p-> mShowIconNewEvent) | 903 | if (p-> mShowIconNewEvent) |
904 | configureToolBarMenu->setItemChecked( 10, true ); | 904 | configureToolBarMenu->setItemChecked( 10, true ); |
905 | if (p->mShowIconNewTodo ) | 905 | if (p->mShowIconNewTodo ) |
906 | configureToolBarMenu->setItemChecked( 20, true ); | 906 | configureToolBarMenu->setItemChecked( 20, true ); |
907 | if (p-> mShowIconSearch) | 907 | if (p-> mShowIconSearch) |
908 | configureToolBarMenu->setItemChecked( 120, true ); | 908 | configureToolBarMenu->setItemChecked( 120, true ); |
909 | if (p-> mShowIconList) | 909 | if (p-> mShowIconList) |
910 | configureToolBarMenu->setItemChecked( 30, true ); | 910 | configureToolBarMenu->setItemChecked( 30, true ); |
911 | if (p-> mShowIconDay1) | 911 | if (p-> mShowIconDay1) |
912 | configureToolBarMenu->setItemChecked( 40, true ); | 912 | configureToolBarMenu->setItemChecked( 40, true ); |
913 | if (p-> mShowIconDay5) | 913 | if (p-> mShowIconDay5) |
914 | configureToolBarMenu->setItemChecked( 50, true ); | 914 | configureToolBarMenu->setItemChecked( 50, true ); |
915 | if (p-> mShowIconDay7) | 915 | if (p-> mShowIconDay7) |
916 | configureToolBarMenu->setItemChecked( 60, true ); | 916 | configureToolBarMenu->setItemChecked( 60, true ); |
917 | if (p-> mShowIconMonth) | 917 | if (p-> mShowIconMonth) |
918 | configureToolBarMenu->setItemChecked( 70, true ); | 918 | configureToolBarMenu->setItemChecked( 70, true ); |
919 | if (p-> mShowIconTodoview) | 919 | if (p-> mShowIconTodoview) |
920 | configureToolBarMenu->setItemChecked( 80, true ); | 920 | configureToolBarMenu->setItemChecked( 80, true ); |
921 | if (p-> mShowIconBackFast) | 921 | if (p-> mShowIconBackFast) |
922 | configureToolBarMenu->setItemChecked( 200, true ); | 922 | configureToolBarMenu->setItemChecked( 200, true ); |
923 | if (p-> mShowIconBack) | 923 | if (p-> mShowIconBack) |
924 | configureToolBarMenu->setItemChecked( 210, true ); | 924 | configureToolBarMenu->setItemChecked( 210, true ); |
925 | if (p-> mShowIconToday) | 925 | if (p-> mShowIconToday) |
926 | configureToolBarMenu->setItemChecked( 130, true ); | 926 | configureToolBarMenu->setItemChecked( 130, true ); |
927 | if (p-> mShowIconForward) | 927 | if (p-> mShowIconForward) |
928 | configureToolBarMenu->setItemChecked( 220, true ); | 928 | configureToolBarMenu->setItemChecked( 220, true ); |
929 | if (p-> mShowIconForwardFast) | 929 | if (p-> mShowIconForwardFast) |
930 | configureToolBarMenu->setItemChecked( 230, true ); | 930 | configureToolBarMenu->setItemChecked( 230, true ); |
931 | if (p-> mShowIconNextDays) | 931 | if (p-> mShowIconNextDays) |
932 | configureToolBarMenu->setItemChecked( 100, true ); | 932 | configureToolBarMenu->setItemChecked( 100, true ); |
933 | if (p-> mShowIconNext) | 933 | if (p-> mShowIconNext) |
934 | configureToolBarMenu->setItemChecked( 110, true ); | 934 | configureToolBarMenu->setItemChecked( 110, true ); |
935 | if (p-> mShowIconJournal) | 935 | if (p-> mShowIconJournal) |
936 | configureToolBarMenu->setItemChecked( 90, true ); | 936 | configureToolBarMenu->setItemChecked( 90, true ); |
937 | if (p-> mShowIconWhatsThis) | 937 | if (p-> mShowIconWhatsThis) |
938 | configureToolBarMenu->setItemChecked( 300, true ); | 938 | configureToolBarMenu->setItemChecked( 300, true ); |
939 | 939 | ||
940 | QLabel* dummy = new QLabel( iconToolBar ); | 940 | QLabel* dummy = new QLabel( iconToolBar ); |
941 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 941 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
942 | if (!p-> mShowIconStretch) | 942 | if (!p-> mShowIconStretch) |
943 | iconToolBar->setStretchableWidget ( dummy ) ; | 943 | iconToolBar->setStretchableWidget ( dummy ) ; |
944 | else | 944 | else |
945 | configureToolBarMenu->setItemChecked( 5, true ); | 945 | configureToolBarMenu->setItemChecked( 5, true ); |
946 | if (p-> mShowIconWhatsThis) | 946 | if (p-> mShowIconWhatsThis) |
947 | QWhatsThis::whatsThisButton ( iconToolBar ); | 947 | QWhatsThis::whatsThisButton ( iconToolBar ); |
948 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 948 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
949 | configureAgenda( p->mHourSize ); | 949 | configureAgenda( p->mHourSize ); |
950 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 950 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
951 | } | 951 | } |
952 | 952 | ||
953 | void MainWindow::exportToPhone( int mode ) | 953 | void MainWindow::exportToPhone( int mode ) |
954 | { | 954 | { |
955 | 955 | ||
956 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 956 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
957 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 957 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
958 | KOex2phonePrefs ex2phone; | 958 | KOex2phonePrefs ex2phone; |
959 | 959 | ||
960 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 960 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
961 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 961 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
962 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 962 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
963 | if ( mode == 1 ) | 963 | if ( mode == 1 ) |
964 | ex2phone.setCaption(i18n("Export complete calendar")); | 964 | ex2phone.setCaption(i18n("Export complete calendar")); |
965 | if ( mode == 2 ) | 965 | if ( mode == 2 ) |
966 | ex2phone.setCaption(i18n("Export filtered calendar")); | 966 | ex2phone.setCaption(i18n("Export filtered calendar")); |
967 | 967 | ||
968 | if ( !ex2phone.exec() ) { | 968 | if ( !ex2phone.exec() ) { |
969 | return; | 969 | return; |
970 | } | 970 | } |
971 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 971 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
972 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 972 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
973 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 973 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
974 | 974 | ||
975 | int inFuture = 0; | 975 | int inFuture = 0; |
976 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 976 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
977 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 977 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
978 | QPtrList<Incidence> delSel; | 978 | QPtrList<Incidence> delSel; |
979 | if ( mode == 1 ) | 979 | if ( mode == 1 ) |
980 | delSel = mCalendar->rawIncidences(); | 980 | delSel = mCalendar->rawIncidences(); |
981 | if ( mode == 2 ) | 981 | if ( mode == 2 ) |
982 | delSel = mCalendar->incidences(); | 982 | delSel = mCalendar->incidences(); |
983 | CalendarLocal* cal = new CalendarLocal(); | 983 | CalendarLocal* cal = new CalendarLocal(); |
984 | cal->setLocalTime(); | 984 | cal->setLocalTime(); |
985 | Incidence *incidence = delSel.first(); | 985 | Incidence *incidence = delSel.first(); |
986 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 986 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
987 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 987 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
988 | while ( incidence ) { | 988 | while ( incidence ) { |
989 | if ( incidence->type() != "Journal" ) { | 989 | if ( incidence->type() != "Journal" ) { |
990 | bool add = true; | 990 | bool add = true; |
991 | if ( inFuture ) { | 991 | if ( inFuture ) { |
992 | QDateTime dt; | 992 | QDateTime dt; |
993 | if ( incidence->type() == "Todo" ) { | 993 | if ( incidence->type() == "Todo" ) { |
994 | Todo * t = (Todo*)incidence; | 994 | Todo * t = (Todo*)incidence; |
995 | if ( t->hasDueDate() ) | 995 | if ( t->hasDueDate() ) |
996 | dt = t->dtDue(); | 996 | dt = t->dtDue(); |
997 | else | 997 | else |
998 | dt = cur.addSecs( 62 ); | 998 | dt = cur.addSecs( 62 ); |
999 | } | 999 | } |
1000 | else { | 1000 | else { |
1001 | bool ok; | 1001 | bool ok; |
1002 | dt = incidence->getNextOccurence( cur, &ok ); | 1002 | dt = incidence->getNextOccurence( cur, &ok ); |
1003 | if ( !ok ) | 1003 | if ( !ok ) |
1004 | dt = cur.addSecs( -62 ); | 1004 | dt = cur.addSecs( -62 ); |
1005 | } | 1005 | } |
1006 | if ( dt < cur || dt > end ) { | 1006 | if ( dt < cur || dt > end ) { |
1007 | add = false; | 1007 | add = false; |
1008 | } | 1008 | } |
1009 | } | 1009 | } |
1010 | if ( add ) { | 1010 | if ( add ) { |
1011 | Incidence *in = incidence->clone(); | 1011 | Incidence *in = incidence->clone(); |
1012 | cal->addIncidence( in ); | 1012 | cal->addIncidence( in ); |
1013 | } | 1013 | } |
1014 | } | 1014 | } |
1015 | incidence = delSel.next(); | 1015 | incidence = delSel.next(); |
1016 | } | 1016 | } |
1017 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1017 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1018 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1018 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1019 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1019 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1020 | 1020 | ||
1021 | setCaption( i18n("Writing to phone...")); | 1021 | setCaption( i18n("Writing to phone...")); |
1022 | if ( PhoneFormat::writeToPhone( cal ) ) | 1022 | if ( PhoneFormat::writeToPhone( cal ) ) |
1023 | setCaption( i18n("Export to phone successful!")); | 1023 | setCaption( i18n("Export to phone successful!")); |
1024 | else | 1024 | else |
1025 | setCaption( i18n("Error exporting to phone!")); | 1025 | setCaption( i18n("Error exporting to phone!")); |
1026 | delete cal; | 1026 | delete cal; |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | 1029 | ||
1030 | void MainWindow::setDefaultPreferences() | 1030 | void MainWindow::setDefaultPreferences() |
1031 | { | 1031 | { |
1032 | KOPrefs *p = KOPrefs::instance(); | 1032 | KOPrefs *p = KOPrefs::instance(); |
1033 | 1033 | ||
1034 | p->mCompactDialogs = true; | 1034 | p->mCompactDialogs = true; |
1035 | p->mConfirm = true; | 1035 | p->mConfirm = true; |
1036 | // p->mEnableQuickTodo = false; | 1036 | // p->mEnableQuickTodo = false; |
1037 | 1037 | ||
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | QString MainWindow::resourcePath() | 1040 | QString MainWindow::resourcePath() |
1041 | { | 1041 | { |
1042 | return KGlobal::iconLoader()->iconPath(); | 1042 | return KGlobal::iconLoader()->iconPath(); |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | void MainWindow::displayText( QString text ,QString cap ) | 1045 | void MainWindow::displayText( QString text ,QString cap ) |
1046 | { | 1046 | { |
1047 | QDialog dia( this, "name", true ); ; | 1047 | QDialog dia( this, "name", true ); ; |
1048 | dia.setCaption( cap ); | 1048 | dia.setCaption( cap ); |
1049 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1049 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1050 | lay->setSpacing( 3 ); | 1050 | lay->setSpacing( 3 ); |
1051 | lay->setMargin( 3 ); | 1051 | lay->setMargin( 3 ); |
1052 | QTextBrowser tb ( &dia ); | 1052 | QTextBrowser tb ( &dia ); |
1053 | lay->addWidget( &tb ); | 1053 | lay->addWidget( &tb ); |
1054 | tb.setText( text ); | 1054 | tb.setText( text ); |
1055 | #ifdef DESKTOP_VERSION | 1055 | #ifdef DESKTOP_VERSION |
1056 | dia.resize( 640, 480); | 1056 | dia.resize( 640, 480); |
1057 | #else | 1057 | #else |
1058 | dia.showMaximized(); | 1058 | dia.showMaximized(); |
1059 | #endif | 1059 | #endif |
1060 | dia.exec(); | 1060 | dia.exec(); |
1061 | } | 1061 | } |
1062 | void MainWindow::displayFile( QString fn, QString cap ) | 1062 | void MainWindow::displayFile( QString fn, QString cap ) |
1063 | { | 1063 | { |
1064 | QString fileName = resourcePath() + fn; | 1064 | QString fileName = resourcePath() + fn; |
1065 | QString text; | 1065 | QString text; |
1066 | QFile file( fileName ); | 1066 | QFile file( fileName ); |
1067 | if (!file.open( IO_ReadOnly ) ) { | 1067 | if (!file.open( IO_ReadOnly ) ) { |
1068 | return ; | 1068 | return ; |
1069 | 1069 | ||
1070 | } | 1070 | } |
1071 | QTextStream ts( &file ); | 1071 | QTextStream ts( &file ); |
1072 | text = ts.read(); | 1072 | text = ts.read(); |
1073 | file.close(); | 1073 | file.close(); |
1074 | displayText( text, cap); | 1074 | displayText( text, cap); |
1075 | } | 1075 | } |
1076 | void MainWindow::features() | 1076 | void MainWindow::features() |
1077 | { | 1077 | { |
1078 | 1078 | ||
1079 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1079 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | void MainWindow::usertrans() | 1082 | void MainWindow::usertrans() |
1083 | { | 1083 | { |
1084 | 1084 | ||
1085 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1085 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | void MainWindow::synchowto() | 1088 | void MainWindow::synchowto() |
1089 | { | 1089 | { |
1090 | 1090 | ||
1091 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1091 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1092 | } | 1092 | } |
1093 | void MainWindow::faq() | 1093 | void MainWindow::faq() |
1094 | { | 1094 | { |
1095 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1095 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1096 | 1096 | ||
1097 | } | 1097 | } |
1098 | void MainWindow::whatsNew() | 1098 | void MainWindow::whatsNew() |
1099 | { | 1099 | { |
1100 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1100 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1101 | 1101 | ||
1102 | } | 1102 | } |
1103 | void MainWindow::licence() | 1103 | void MainWindow::licence() |
1104 | { | 1104 | { |
1105 | KApplication::showLicence(); | 1105 | KApplication::showLicence(); |
1106 | 1106 | ||
1107 | } | 1107 | } |
1108 | void MainWindow::about() | 1108 | void MainWindow::about() |
1109 | { | 1109 | { |
1110 | QString version; | 1110 | QString version; |
1111 | #include <../version> | 1111 | #include <../version> |
1112 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1112 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1113 | i18n("KOrganizer/Platform-independent\n") + | 1113 | i18n("KOrganizer/Platform-independent\n") + |
1114 | "(KO/Pi) " + version + " - " + | 1114 | "(KO/Pi) " + version + " - " + |
1115 | 1115 | ||
1116 | #ifdef DESKTOP_VERSION | 1116 | #ifdef DESKTOP_VERSION |
1117 | i18n("Desktop Edition\n") + | 1117 | i18n("Desktop Edition\n") + |
1118 | #else | 1118 | #else |
1119 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1119 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1120 | #endif | 1120 | #endif |
1121 | 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") ); | 1121 | 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") ); |
1122 | } | 1122 | } |
1123 | void MainWindow::keyBindings() | 1123 | void MainWindow::keyBindings() |
1124 | { | 1124 | { |
1125 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1125 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1126 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1126 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1127 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1127 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1128 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1128 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1129 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1129 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1130 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1130 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1131 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1131 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1132 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1132 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1133 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1133 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1134 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1134 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1135 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1135 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1136 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1136 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1137 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1137 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1138 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1138 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1139 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1139 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1140 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1140 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1141 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1141 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1142 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1142 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1143 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1143 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1144 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1144 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1145 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1145 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1146 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1146 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1147 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1147 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1148 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1148 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1149 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1149 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1150 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1150 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1151 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1151 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1152 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1152 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1153 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1153 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1154 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1154 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1155 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1155 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1156 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1156 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1157 | i18n("<p><h3>In list view:</h3></p>\n") + | 1157 | i18n("<p><h3>In list view:</h3></p>\n") + |
1158 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1158 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1159 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1159 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1160 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1160 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1161 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1161 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1162 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1162 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1163 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1163 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1164 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1164 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1165 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1165 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1166 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1166 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1167 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1167 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1168 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1168 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1169 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1169 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1170 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1170 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1171 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1171 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1172 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1172 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1173 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1173 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1174 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1174 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1175 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1175 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1176 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1176 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1177 | displayText( text, cap); | 1177 | displayText( text, cap); |
1178 | 1178 | ||
1179 | } | 1179 | } |
1180 | void MainWindow::aboutAutoSaving() | 1180 | void MainWindow::aboutAutoSaving() |
1181 | { | 1181 | { |
1182 | QMessageBox* msg; | 1182 | QMessageBox* msg; |
1183 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1183 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1184 | 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, | 1184 | 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, |
1185 | QMessageBox::Ok, | 1185 | QMessageBox::Ok, |
1186 | QMessageBox::NoButton, | 1186 | QMessageBox::NoButton, |
1187 | QMessageBox::NoButton); | 1187 | QMessageBox::NoButton); |
1188 | msg->exec(); | 1188 | msg->exec(); |
1189 | delete msg; | 1189 | delete msg; |
1190 | 1190 | ||
1191 | 1191 | ||
1192 | } | 1192 | } |
1193 | void MainWindow::aboutKnownBugs() | 1193 | void MainWindow::aboutKnownBugs() |
1194 | { | 1194 | { |
1195 | QMessageBox* msg; | 1195 | QMessageBox* msg; |
1196 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1196 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1197 | 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")+ | 1197 | 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")+ |
1198 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1198 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1199 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1199 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1200 | i18n("\nor report them in the bugtracker on\n") + | 1200 | i18n("\nor report them in the bugtracker on\n") + |
1201 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1201 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1202 | QMessageBox::NoIcon, | 1202 | QMessageBox::NoIcon, |
1203 | QMessageBox::Ok, | 1203 | QMessageBox::Ok, |
1204 | QMessageBox::NoButton, | 1204 | QMessageBox::NoButton, |
1205 | QMessageBox::NoButton); | 1205 | QMessageBox::NoButton); |
1206 | msg->exec(); | 1206 | msg->exec(); |
1207 | delete msg; | 1207 | delete msg; |
1208 | 1208 | ||
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | QString MainWindow::defaultFileName() | 1211 | QString MainWindow::defaultFileName() |
1212 | { | 1212 | { |
1213 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1213 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1214 | } | 1214 | } |
1215 | QString MainWindow::syncFileName() | 1215 | QString MainWindow::syncFileName() |
1216 | { | 1216 | { |
1217 | #ifdef _WIN32_ | 1217 | #ifdef DESKTOP_VERSION |
1218 | return locateLocal( "tmp", "synccalendar.ics" ); | 1218 | return locateLocal( "tmp", "synccalendar.ics" ); |
1219 | #else | 1219 | #else |
1220 | return QString( "/tmp/kopitempfile.ics" ); | 1220 | return QString( "/tmp/synccalendar.ics" ); |
1221 | #endif | 1221 | #endif |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1224 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1225 | { | 1225 | { |
1226 | if ( !incidence ) { | 1226 | if ( !incidence ) { |
1227 | enableIncidenceActions( false ); | 1227 | enableIncidenceActions( false ); |
1228 | 1228 | ||
1229 | mNewSubTodoAction->setEnabled( false ); | 1229 | mNewSubTodoAction->setEnabled( false ); |
1230 | setCaptionToDates(); | 1230 | setCaptionToDates(); |
1231 | return; | 1231 | return; |
1232 | 1232 | ||
1233 | } | 1233 | } |
1234 | 1234 | ||
1235 | //KGlobal::locale()->formatDateTime(nextA, true); | 1235 | //KGlobal::locale()->formatDateTime(nextA, true); |
1236 | QString startString = ""; | 1236 | QString startString = ""; |
1237 | if ( incidence->type() != "Todo" ) { | 1237 | if ( incidence->type() != "Todo" ) { |
1238 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1238 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1239 | if ( incidence->doesFloat() ) { | 1239 | if ( incidence->doesFloat() ) { |
1240 | startString += ": "+incidence->dtStartDateStr( true ); | 1240 | startString += ": "+incidence->dtStartDateStr( true ); |
1241 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1241 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1242 | 1242 | ||
1243 | } else { | 1243 | } else { |
1244 | startString = ": "+incidence->dtStartStr(true); | 1244 | startString = ": "+incidence->dtStartStr(true); |
1245 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1245 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1246 | 1246 | ||
1247 | } | 1247 | } |
1248 | 1248 | ||
1249 | } else { | 1249 | } else { |
1250 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1250 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1251 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1251 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1252 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1252 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1253 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1253 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | } | 1256 | } |
1257 | else | 1257 | else |
1258 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1258 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1259 | if ( !incidence->location().isEmpty() ) | 1259 | if ( !incidence->location().isEmpty() ) |
1260 | startString += " (" +incidence->location()+")"; | 1260 | startString += " (" +incidence->location()+")"; |
1261 | setCaption( incidence->summary()+startString); | 1261 | setCaption( incidence->summary()+startString); |
1262 | 1262 | ||
1263 | enableIncidenceActions( true ); | 1263 | enableIncidenceActions( true ); |
1264 | 1264 | ||
1265 | if ( incidence->type() == "Event" ) { | 1265 | if ( incidence->type() == "Event" ) { |
1266 | mShowAction->setText( i18n("Show Event...") ); | 1266 | mShowAction->setText( i18n("Show Event...") ); |
1267 | mEditAction->setText( i18n("Edit Event...") ); | 1267 | mEditAction->setText( i18n("Edit Event...") ); |
1268 | mDeleteAction->setText( i18n("Delete Event...") ); | 1268 | mDeleteAction->setText( i18n("Delete Event...") ); |
1269 | 1269 | ||
1270 | mNewSubTodoAction->setEnabled( false ); | 1270 | mNewSubTodoAction->setEnabled( false ); |
1271 | } else if ( incidence->type() == "Todo" ) { | 1271 | } else if ( incidence->type() == "Todo" ) { |
1272 | mShowAction->setText( i18n("Show Todo...") ); | 1272 | mShowAction->setText( i18n("Show Todo...") ); |
1273 | mEditAction->setText( i18n("Edit Todo...") ); | 1273 | mEditAction->setText( i18n("Edit Todo...") ); |
1274 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1274 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1275 | 1275 | ||
1276 | mNewSubTodoAction->setEnabled( true ); | 1276 | mNewSubTodoAction->setEnabled( true ); |
1277 | } else { | 1277 | } else { |
1278 | mShowAction->setText( i18n("Show...") ); | 1278 | mShowAction->setText( i18n("Show...") ); |
1279 | mShowAction->setText( i18n("Edit...") ); | 1279 | mShowAction->setText( i18n("Edit...") ); |
1280 | mShowAction->setText( i18n("Delete...") ); | 1280 | mShowAction->setText( i18n("Delete...") ); |
1281 | 1281 | ||
1282 | mNewSubTodoAction->setEnabled( false ); | 1282 | mNewSubTodoAction->setEnabled( false ); |
1283 | } | 1283 | } |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | void MainWindow::enableIncidenceActions( bool enabled ) | 1286 | void MainWindow::enableIncidenceActions( bool enabled ) |
1287 | { | 1287 | { |
1288 | mShowAction->setEnabled( enabled ); | 1288 | mShowAction->setEnabled( enabled ); |
1289 | mEditAction->setEnabled( enabled ); | 1289 | mEditAction->setEnabled( enabled ); |
1290 | mDeleteAction->setEnabled( enabled ); | 1290 | mDeleteAction->setEnabled( enabled ); |
1291 | 1291 | ||
1292 | mCloneAction->setEnabled( enabled ); | 1292 | mCloneAction->setEnabled( enabled ); |
1293 | mMoveAction->setEnabled( enabled ); | 1293 | mMoveAction->setEnabled( enabled ); |
1294 | mBeamAction->setEnabled( enabled ); | 1294 | mBeamAction->setEnabled( enabled ); |
1295 | mCancelAction->setEnabled( enabled ); | 1295 | mCancelAction->setEnabled( enabled ); |
1296 | } | 1296 | } |
1297 | 1297 | ||
1298 | void MainWindow::importOL() | 1298 | void MainWindow::importOL() |
1299 | { | 1299 | { |
1300 | #ifdef _WIN32_ | 1300 | #ifdef _WIN32_ |
1301 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1301 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1302 | id->exec(); | 1302 | id->exec(); |
1303 | delete id; | 1303 | delete id; |
1304 | mView->updateView(); | 1304 | mView->updateView(); |
1305 | #endif | 1305 | #endif |
1306 | } | 1306 | } |
1307 | void MainWindow::importBday() | 1307 | void MainWindow::importBday() |
1308 | { | 1308 | { |
1309 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1309 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1310 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1310 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1311 | i18n("Import!"), i18n("Cancel"), 0, | 1311 | i18n("Import!"), i18n("Cancel"), 0, |
1312 | 0, 1 ); | 1312 | 0, 1 ); |
1313 | if ( result == 0 ) { | 1313 | if ( result == 0 ) { |
1314 | mView->importBday(); | 1314 | mView->importBday(); |
1315 | 1315 | ||
1316 | } | 1316 | } |
1317 | 1317 | ||
1318 | 1318 | ||
1319 | } | 1319 | } |
1320 | void MainWindow::importQtopia() | 1320 | void MainWindow::importQtopia() |
1321 | { | 1321 | { |
1322 | #ifndef DESKTOP_VERSION | 1322 | #ifndef DESKTOP_VERSION |
1323 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1323 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1324 | 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"), | 1324 | 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"), |
1325 | i18n("Import!"), i18n("Cancel"), 0, | 1325 | i18n("Import!"), i18n("Cancel"), 0, |
1326 | 0, 1 ); | 1326 | 0, 1 ); |
1327 | if ( result == 0 ) { | 1327 | if ( result == 0 ) { |
1328 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1328 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1329 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1329 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1330 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1330 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1331 | mView->importQtopia( categories, datebook, todolist ); | 1331 | mView->importQtopia( categories, datebook, todolist ); |
1332 | } | 1332 | } |
1333 | #else | 1333 | #else |
1334 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1334 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1335 | i18n("Not supported \non desktop!\n"), | 1335 | i18n("Not supported \non desktop!\n"), |
1336 | i18n("Ok"), i18n("Cancel"), 0, | 1336 | i18n("Ok"), i18n("Cancel"), 0, |
1337 | 0, 1 ); | 1337 | 0, 1 ); |
1338 | 1338 | ||
1339 | #endif | 1339 | #endif |
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | void MainWindow::saveOnClose() | 1342 | void MainWindow::saveOnClose() |
1343 | { | 1343 | { |
1344 | KOPrefs *p = KOPrefs::instance(); | 1344 | KOPrefs *p = KOPrefs::instance(); |
1345 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1345 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1346 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1346 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1347 | iconToolBar->y() > height()/2; | 1347 | iconToolBar->y() > height()/2; |
1348 | mView->writeSettings(); | 1348 | mView->writeSettings(); |
1349 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1349 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1350 | save(); | 1350 | save(); |
1351 | } | 1351 | } |
1352 | void MainWindow::slotModifiedChanged( bool changed ) | 1352 | void MainWindow::slotModifiedChanged( bool changed ) |
1353 | { | 1353 | { |
1354 | if ( mBlockAtStartup ) | 1354 | if ( mBlockAtStartup ) |
1355 | return; | 1355 | return; |
1356 | int msec; | 1356 | int msec; |
1357 | // we store the changes after 1 minute, | 1357 | // we store the changes after 1 minute, |
1358 | // and for safety reasons after 10 minutes again | 1358 | // and for safety reasons after 10 minutes again |
1359 | if ( !mSyncManager->blockSave() ) | 1359 | if ( !mSyncManager->blockSave() ) |
1360 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1360 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1361 | else | 1361 | else |
1362 | msec = 1000 * 600; | 1362 | msec = 1000 * 600; |
1363 | mSaveTimer.start( msec, true ); // 1 minute | 1363 | mSaveTimer.start( msec, true ); // 1 minute |
1364 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1364 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1365 | mCalendarModifiedFlag = true; | 1365 | mCalendarModifiedFlag = true; |
1366 | } | 1366 | } |
1367 | void MainWindow::save() | 1367 | void MainWindow::save() |
1368 | { | 1368 | { |
1369 | if ( mSyncManager->blockSave() ) | 1369 | if ( mSyncManager->blockSave() ) |
1370 | return; | 1370 | return; |
1371 | mSyncManager->setBlockSave(true); | 1371 | mSyncManager->setBlockSave(true); |
1372 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1372 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1373 | 1373 | ||
1374 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1374 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1375 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1375 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1376 | qDebug("KO: Start saving data to file!"); | 1376 | qDebug("KO: Start saving data to file!"); |
1377 | mView->saveCalendar( defaultFileName() ); | 1377 | mView->saveCalendar( defaultFileName() ); |
1378 | 1378 | ||
1379 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1379 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1380 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1380 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1381 | QString savemes; | 1381 | QString savemes; |
1382 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1382 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1383 | setCaption(savemes); | 1383 | setCaption(savemes); |
1384 | } else | 1384 | } else |
1385 | setCaption(i18n("Saving cancelled!")); | 1385 | setCaption(i18n("Saving cancelled!")); |
1386 | mCalendarModifiedFlag = false; | 1386 | mCalendarModifiedFlag = false; |
1387 | mSyncManager->setBlockSave( false ); | 1387 | mSyncManager->setBlockSave( false ); |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1390 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1391 | { | 1391 | { |
1392 | if ( !e->isAutoRepeat() ) { | 1392 | if ( !e->isAutoRepeat() ) { |
1393 | mFlagKeyPressed = false; | 1393 | mFlagKeyPressed = false; |
1394 | } | 1394 | } |
1395 | } | 1395 | } |
1396 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1396 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1397 | { | 1397 | { |
1398 | qApp->processEvents(); | 1398 | qApp->processEvents(); |
1399 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1399 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1400 | e->ignore(); | 1400 | e->ignore(); |
1401 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1401 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1402 | return; | 1402 | return; |
1403 | } | 1403 | } |
1404 | if (! e->isAutoRepeat() ) | 1404 | if (! e->isAutoRepeat() ) |
1405 | mFlagKeyPressed = true; | 1405 | mFlagKeyPressed = true; |
1406 | KOPrefs *p = KOPrefs::instance(); | 1406 | KOPrefs *p = KOPrefs::instance(); |
1407 | bool showSelectedDates = false; | 1407 | bool showSelectedDates = false; |
1408 | int size; | 1408 | int size; |
1409 | int pro = 0; | 1409 | int pro = 0; |
1410 | //qDebug("MainWindow::keyPressEvent "); | 1410 | //qDebug("MainWindow::keyPressEvent "); |
1411 | switch ( e->key() ) { | 1411 | switch ( e->key() ) { |
1412 | case Qt::Key_Right: | 1412 | case Qt::Key_Right: |
1413 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1413 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1414 | mView->goNextMonth(); | 1414 | mView->goNextMonth(); |
1415 | else | 1415 | else |
1416 | mView->goNext(); | 1416 | mView->goNext(); |
1417 | showSelectedDates = true; | 1417 | showSelectedDates = true; |
1418 | break; | 1418 | break; |
1419 | case Qt::Key_Left: | 1419 | case Qt::Key_Left: |
1420 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1420 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1421 | mView->goPreviousMonth(); | 1421 | mView->goPreviousMonth(); |
1422 | else | 1422 | else |
1423 | mView->goPrevious(); | 1423 | mView->goPrevious(); |
1424 | showSelectedDates = true; | 1424 | showSelectedDates = true; |
1425 | break; | 1425 | break; |
1426 | case Qt::Key_Down: | 1426 | case Qt::Key_Down: |
1427 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1427 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1428 | break; | 1428 | break; |
1429 | case Qt::Key_Up: | 1429 | case Qt::Key_Up: |
1430 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1430 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1431 | break; | 1431 | break; |
1432 | case Qt::Key_I: | 1432 | case Qt::Key_I: |
1433 | mView->showIncidence(); | 1433 | mView->showIncidence(); |
1434 | break; | 1434 | break; |
1435 | case Qt::Key_Delete: | 1435 | case Qt::Key_Delete: |
1436 | case Qt::Key_Backspace: | 1436 | case Qt::Key_Backspace: |
1437 | mView->deleteIncidence(); | 1437 | mView->deleteIncidence(); |
1438 | break; | 1438 | break; |
1439 | case Qt::Key_D: | 1439 | case Qt::Key_D: |
1440 | mView->viewManager()->showDayView(); | 1440 | mView->viewManager()->showDayView(); |
1441 | showSelectedDates = true; | 1441 | showSelectedDates = true; |
1442 | break; | 1442 | break; |
1443 | case Qt::Key_O: | 1443 | case Qt::Key_O: |
1444 | mView->toggleFilerEnabled( ); | 1444 | mView->toggleFilerEnabled( ); |
1445 | break; | 1445 | break; |
1446 | case Qt::Key_0: | 1446 | case Qt::Key_0: |
1447 | case Qt::Key_1: | 1447 | case Qt::Key_1: |
1448 | case Qt::Key_2: | 1448 | case Qt::Key_2: |
1449 | case Qt::Key_3: | 1449 | case Qt::Key_3: |
1450 | case Qt::Key_4: | 1450 | case Qt::Key_4: |
1451 | case Qt::Key_5: | 1451 | case Qt::Key_5: |
1452 | case Qt::Key_6: | 1452 | case Qt::Key_6: |
1453 | case Qt::Key_7: | 1453 | case Qt::Key_7: |
1454 | case Qt::Key_8: | 1454 | case Qt::Key_8: |
1455 | case Qt::Key_9: | 1455 | case Qt::Key_9: |
1456 | pro = e->key()-48; | 1456 | pro = e->key()-48; |
1457 | if ( pro == 0 ) | 1457 | if ( pro == 0 ) |
1458 | pro = 10; | 1458 | pro = 10; |
1459 | if ( e->state() == Qt::ControlButton) | 1459 | if ( e->state() == Qt::ControlButton) |
1460 | pro += 10; | 1460 | pro += 10; |
1461 | break; | 1461 | break; |
1462 | case Qt::Key_M: | 1462 | case Qt::Key_M: |
1463 | mView->viewManager()->showMonthView(); | 1463 | mView->viewManager()->showMonthView(); |
1464 | showSelectedDates = true; | 1464 | showSelectedDates = true; |
1465 | break; | 1465 | break; |
1466 | case Qt::Key_Insert: | 1466 | case Qt::Key_Insert: |
1467 | mView->newEvent(); | 1467 | mView->newEvent(); |
1468 | break; | 1468 | break; |
1469 | case Qt::Key_S : | 1469 | case Qt::Key_S : |
1470 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1470 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1471 | mView->newSubTodo(); | 1471 | mView->newSubTodo(); |
1472 | else | 1472 | else |
1473 | mView->dialogManager()->showSearchDialog(); | 1473 | mView->dialogManager()->showSearchDialog(); |
1474 | break; | 1474 | break; |
1475 | case Qt::Key_Y : | 1475 | case Qt::Key_Y : |
1476 | case Qt::Key_Z : | 1476 | case Qt::Key_Z : |
1477 | mView->viewManager()->showWorkWeekView(); | 1477 | mView->viewManager()->showWorkWeekView(); |
1478 | showSelectedDates = true; | 1478 | showSelectedDates = true; |
1479 | break; | 1479 | break; |
1480 | case Qt::Key_U : | 1480 | case Qt::Key_U : |
1481 | mView->viewManager()->showWeekView(); | 1481 | mView->viewManager()->showWeekView(); |
1482 | showSelectedDates = true; | 1482 | showSelectedDates = true; |
1483 | break; | 1483 | break; |
1484 | case Qt::Key_H : | 1484 | case Qt::Key_H : |
1485 | keyBindings(); | 1485 | keyBindings(); |
1486 | break; | 1486 | break; |
1487 | case Qt::Key_W: | 1487 | case Qt::Key_W: |
1488 | mView->viewManager()->showWhatsNextView(); | 1488 | mView->viewManager()->showWhatsNextView(); |
1489 | break; | 1489 | break; |
1490 | case Qt::Key_L: | 1490 | case Qt::Key_L: |
1491 | mView->viewManager()->showListView(); | 1491 | mView->viewManager()->showListView(); |
1492 | break; | 1492 | break; |
1493 | case Qt::Key_N: | 1493 | case Qt::Key_N: |
1494 | mView->viewManager()->showNextXView(); | 1494 | mView->viewManager()->showNextXView(); |
1495 | showSelectedDates = true; | 1495 | showSelectedDates = true; |
1496 | break; | 1496 | break; |
1497 | case Qt::Key_V: | 1497 | case Qt::Key_V: |
1498 | mView->viewManager()->showTodoView(); | 1498 | mView->viewManager()->showTodoView(); |
1499 | break; | 1499 | break; |
1500 | case Qt::Key_C: | 1500 | case Qt::Key_C: |
1501 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1501 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1502 | break; | 1502 | break; |
1503 | case Qt::Key_P: | 1503 | case Qt::Key_P: |
1504 | mView->showDatePicker( ); | 1504 | mView->showDatePicker( ); |
1505 | break; | 1505 | break; |
1506 | case Qt::Key_F: | 1506 | case Qt::Key_F: |
1507 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1507 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1508 | mView->editFilters(); | 1508 | mView->editFilters(); |
1509 | else | 1509 | else |
1510 | mView->toggleFilter(); | 1510 | mView->toggleFilter(); |
1511 | break; | 1511 | break; |
1512 | case Qt::Key_X: | 1512 | case Qt::Key_X: |
1513 | mView->toggleDateNavigatorWidget(); | 1513 | mView->toggleDateNavigatorWidget(); |
1514 | break; | 1514 | break; |
1515 | case Qt::Key_Space: | 1515 | case Qt::Key_Space: |
1516 | mView->toggleExpand(); | 1516 | mView->toggleExpand(); |
1517 | break; | 1517 | break; |
1518 | case Qt::Key_A: | 1518 | case Qt::Key_A: |
1519 | mView->toggleAllDaySize(); | 1519 | mView->toggleAllDaySize(); |
1520 | break; | 1520 | break; |
1521 | case Qt::Key_T: | 1521 | case Qt::Key_T: |
1522 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1522 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1523 | mView->newTodo(); | 1523 | mView->newTodo(); |
1524 | else { | 1524 | else { |
1525 | mView->goToday(); | 1525 | mView->goToday(); |
1526 | showSelectedDates = true; | 1526 | showSelectedDates = true; |
1527 | } | 1527 | } |
1528 | break; | 1528 | break; |
1529 | case Qt::Key_J: | 1529 | case Qt::Key_J: |
1530 | mView->viewManager()->showJournalView(); | 1530 | mView->viewManager()->showJournalView(); |
1531 | break; | 1531 | break; |
1532 | case Qt::Key_B: | 1532 | case Qt::Key_B: |
1533 | mView->editIncidenceDescription();; | 1533 | mView->editIncidenceDescription();; |
1534 | break; | 1534 | break; |
1535 | // case Qt::Key_Return: | 1535 | // case Qt::Key_Return: |
1536 | case Qt::Key_E: | 1536 | case Qt::Key_E: |
1537 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1537 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1538 | mView->newEvent(); | 1538 | mView->newEvent(); |
1539 | else | 1539 | else |
1540 | mView->editIncidence(); | 1540 | mView->editIncidence(); |
1541 | break; | 1541 | break; |
1542 | case Qt::Key_Plus: | 1542 | case Qt::Key_Plus: |
1543 | size = p->mHourSize +2; | 1543 | size = p->mHourSize +2; |
1544 | if ( size <= 18 ) | 1544 | if ( size <= 18 ) |
1545 | configureAgenda( size ); | 1545 | configureAgenda( size ); |
1546 | break; | 1546 | break; |
1547 | case Qt::Key_Minus: | 1547 | case Qt::Key_Minus: |
1548 | size = p->mHourSize - 2; | 1548 | size = p->mHourSize - 2; |
1549 | if ( size >= 4 ) | 1549 | if ( size >= 4 ) |
1550 | configureAgenda( size ); | 1550 | configureAgenda( size ); |
1551 | break; | 1551 | break; |
1552 | 1552 | ||
1553 | 1553 | ||
1554 | default: | 1554 | default: |
1555 | e->ignore(); | 1555 | e->ignore(); |
1556 | } | 1556 | } |
1557 | if ( pro > 0 ) { | 1557 | if ( pro > 0 ) { |
1558 | mView->selectFilter( pro-1 ); | 1558 | mView->selectFilter( pro-1 ); |
1559 | } | 1559 | } |
1560 | if ( showSelectedDates ) { | 1560 | if ( showSelectedDates ) { |
1561 | ;// setCaptionToDates(); | 1561 | ;// setCaptionToDates(); |
1562 | } | 1562 | } |
1563 | 1563 | ||
1564 | } | 1564 | } |
1565 | 1565 | ||
1566 | void MainWindow::fillFilterMenu() | 1566 | void MainWindow::fillFilterMenu() |
1567 | { | 1567 | { |
1568 | selectFilterMenu->clear(); | 1568 | selectFilterMenu->clear(); |
1569 | bool disable = false; | 1569 | bool disable = false; |
1570 | if ( mView->filterView()->filtersEnabled() ) { | 1570 | if ( mView->filterView()->filtersEnabled() ) { |
1571 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1571 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1572 | } | 1572 | } |
1573 | else { | 1573 | else { |
1574 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1574 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1575 | disable = true; | 1575 | disable = true; |
1576 | } | 1576 | } |
1577 | selectFilterMenu->insertSeparator(); | 1577 | selectFilterMenu->insertSeparator(); |
1578 | QPtrList<CalFilter> fili = mView->filters(); | 1578 | QPtrList<CalFilter> fili = mView->filters(); |
1579 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1579 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1580 | CalFilter *filter = fili.first(); | 1580 | CalFilter *filter = fili.first(); |
1581 | int iii = 1; | 1581 | int iii = 1; |
1582 | while(filter) { | 1582 | while(filter) { |
1583 | selectFilterMenu->insertItem( filter->name(), iii ); | 1583 | selectFilterMenu->insertItem( filter->name(), iii ); |
1584 | if ( filter == curfilter) | 1584 | if ( filter == curfilter) |
1585 | selectFilterMenu->setItemChecked( iii, true ); | 1585 | selectFilterMenu->setItemChecked( iii, true ); |
1586 | if ( disable ) | 1586 | if ( disable ) |
1587 | selectFilterMenu->setItemEnabled( iii, false ); | 1587 | selectFilterMenu->setItemEnabled( iii, false ); |
1588 | filter = fili.next(); | 1588 | filter = fili.next(); |
1589 | ++iii; | 1589 | ++iii; |
1590 | } | 1590 | } |
1591 | } | 1591 | } |
1592 | void MainWindow::selectFilter( int fil ) | 1592 | void MainWindow::selectFilter( int fil ) |
1593 | { | 1593 | { |
1594 | if ( fil == 0 ) { | 1594 | if ( fil == 0 ) { |
1595 | mView->toggleFilerEnabled( ); | 1595 | mView->toggleFilerEnabled( ); |
1596 | } else { | 1596 | } else { |
1597 | mView->selectFilter( fil-1 ); | 1597 | mView->selectFilter( fil-1 ); |
1598 | } | 1598 | } |
1599 | } | 1599 | } |
1600 | void MainWindow::configureToolBar( int item ) | 1600 | void MainWindow::configureToolBar( int item ) |
1601 | { | 1601 | { |
1602 | 1602 | ||
1603 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1603 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1604 | KOPrefs *p = KOPrefs::instance(); | 1604 | KOPrefs *p = KOPrefs::instance(); |
1605 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1605 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1606 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1606 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1607 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1607 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1608 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1608 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1609 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1609 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1610 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1610 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1611 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1611 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1612 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1612 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1613 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1613 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1614 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1614 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1615 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1615 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1616 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1616 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1617 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1617 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1618 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1618 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1619 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1619 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1620 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1620 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1621 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1621 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1622 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1622 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1623 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1623 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1624 | // initActions(); | 1624 | // initActions(); |
1625 | } | 1625 | } |
1626 | 1626 | ||
1627 | void MainWindow::setCaptionToDates() | 1627 | void MainWindow::setCaptionToDates() |
1628 | { | 1628 | { |
1629 | QString selDates; | 1629 | QString selDates; |
1630 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1630 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1631 | if (mView->startDate() < mView->endDate() ) | 1631 | if (mView->startDate() < mView->endDate() ) |
1632 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1632 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1633 | setCaption( i18n("Dates: ") + selDates ); | 1633 | setCaption( i18n("Dates: ") + selDates ); |
1634 | 1634 | ||
1635 | } | 1635 | } |
1636 | // parameter item == 0: reinit | 1636 | // parameter item == 0: reinit |
1637 | void MainWindow::configureAgenda( int item ) | 1637 | void MainWindow::configureAgenda( int item ) |
1638 | { | 1638 | { |
1639 | 1639 | ||
1640 | KOPrefs *p = KOPrefs::instance(); | 1640 | KOPrefs *p = KOPrefs::instance(); |
1641 | 1641 | ||
1642 | int i; | 1642 | int i; |
1643 | if ( item == 1 ) { | 1643 | if ( item == 1 ) { |
1644 | mView->toggleAllDaySize(); | 1644 | mView->toggleAllDaySize(); |
1645 | return; | 1645 | return; |
1646 | } | 1646 | } |
1647 | // do not allow 4 for widgets higher than 480 | 1647 | // do not allow 4 for widgets higher than 480 |
1648 | // if ( QApplication::desktop()->height() > 480 ) { | 1648 | // if ( QApplication::desktop()->height() > 480 ) { |
1649 | // if ( item == 4 ) | 1649 | // if ( item == 4 ) |
1650 | // item = 6; | 1650 | // item = 6; |
1651 | // } | 1651 | // } |
1652 | for ( i = 4; i <= 18; i= i+2 ) | 1652 | for ( i = 4; i <= 18; i= i+2 ) |
1653 | configureAgendaMenu->setItemChecked( i, false ); | 1653 | configureAgendaMenu->setItemChecked( i, false ); |
1654 | configureAgendaMenu->setItemChecked( item, true ); | 1654 | configureAgendaMenu->setItemChecked( item, true ); |
1655 | if ( p->mHourSize == item ) | 1655 | if ( p->mHourSize == item ) |
1656 | return; | 1656 | return; |
1657 | p->mHourSize=item; | 1657 | p->mHourSize=item; |
1658 | mView->viewManager()->agendaView()->updateConfig(); | 1658 | mView->viewManager()->agendaView()->updateConfig(); |
1659 | } | 1659 | } |
1660 | 1660 | ||
1661 | void MainWindow::saveCalendar() | 1661 | void MainWindow::saveCalendar() |
1662 | { | 1662 | { |
1663 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1663 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1664 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1664 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1665 | 1665 | ||
1666 | if ( fn == "" ) | 1666 | if ( fn == "" ) |
1667 | return; | 1667 | return; |
1668 | QFileInfo info; | 1668 | QFileInfo info; |
1669 | info.setFile( fn ); | 1669 | info.setFile( fn ); |
1670 | QString mes; | 1670 | QString mes; |
1671 | bool createbup = true; | 1671 | bool createbup = true; |
1672 | if ( info. exists() ) { | 1672 | if ( info. exists() ) { |
1673 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1673 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1674 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1674 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1675 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1675 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1676 | 0, 1 ); | 1676 | 0, 1 ); |
1677 | if ( result != 0 ) { | 1677 | if ( result != 0 ) { |
1678 | createbup = false; | 1678 | createbup = false; |
1679 | } | 1679 | } |
1680 | } | 1680 | } |
1681 | if ( createbup ) { | 1681 | if ( createbup ) { |
1682 | mView->saveCalendar( fn ); | 1682 | mView->saveCalendar( fn ); |
1683 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1683 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1684 | KOPrefs::instance()->mLastSaveFile = fn; | 1684 | KOPrefs::instance()->mLastSaveFile = fn; |
1685 | setCaption(mes); | 1685 | setCaption(mes); |
1686 | } | 1686 | } |
1687 | } | 1687 | } |
1688 | void MainWindow::loadCalendar() | 1688 | void MainWindow::loadCalendar() |
1689 | { | 1689 | { |
1690 | 1690 | ||
1691 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1691 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1692 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1692 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1693 | 1693 | ||
1694 | if ( fn == "" ) | 1694 | if ( fn == "" ) |
1695 | return; | 1695 | return; |
1696 | QFileInfo info; | 1696 | QFileInfo info; |
1697 | info.setFile( fn ); | 1697 | info.setFile( fn ); |
1698 | QString mess; | 1698 | QString mess; |
1699 | bool loadbup = true; | 1699 | bool loadbup = true; |
1700 | if ( info. exists() ) { | 1700 | if ( info. exists() ) { |
1701 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1701 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1702 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1702 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1703 | mess, | 1703 | mess, |
1704 | i18n("Load!"), i18n("Cancel"), 0, | 1704 | i18n("Load!"), i18n("Cancel"), 0, |
1705 | 0, 1 ); | 1705 | 0, 1 ); |
1706 | if ( result != 0 ) { | 1706 | if ( result != 0 ) { |
1707 | loadbup = false; | 1707 | loadbup = false; |
1708 | } | 1708 | } |
1709 | } else { | 1709 | } else { |
1710 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1710 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1711 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1711 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1712 | 0, 1 ); | 1712 | 0, 1 ); |
1713 | 1713 | ||
1714 | return; | 1714 | return; |
1715 | } | 1715 | } |
1716 | if ( loadbup ) { | 1716 | if ( loadbup ) { |
1717 | mView->openCalendar( fn ); | 1717 | mView->openCalendar( fn ); |
1718 | KOPrefs::instance()->mLastLoadFile = fn; | 1718 | KOPrefs::instance()->mLastLoadFile = fn; |
1719 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1719 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1720 | setCaption(mess); | 1720 | setCaption(mess); |
1721 | } | 1721 | } |
1722 | 1722 | ||
1723 | } | 1723 | } |
1724 | void MainWindow::quickImportIcal() | 1724 | void MainWindow::quickImportIcal() |
1725 | { | 1725 | { |
1726 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1726 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1727 | } | 1727 | } |
1728 | void MainWindow::importFile( QString fn, bool quick ) | 1728 | void MainWindow::importFile( QString fn, bool quick ) |
1729 | { | 1729 | { |
1730 | QFileInfo info; | 1730 | QFileInfo info; |
1731 | info.setFile( fn ); | 1731 | info.setFile( fn ); |
1732 | QString mess; | 1732 | QString mess; |
1733 | bool loadbup = true; | 1733 | bool loadbup = true; |
1734 | if ( !info. exists() ) { | 1734 | if ( !info. exists() ) { |
1735 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1735 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1736 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1736 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1737 | mess ); | 1737 | mess ); |
1738 | return; | 1738 | return; |
1739 | } | 1739 | } |
1740 | int result = 0; | 1740 | int result = 0; |
1741 | if ( !quick ) { | 1741 | if ( !quick ) { |
1742 | 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 )); | 1742 | 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 )); |
1743 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1743 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1744 | mess, | 1744 | mess, |
1745 | "Import", "Cancel", 0, | 1745 | "Import", "Cancel", 0, |
1746 | 0, 1 ); | 1746 | 0, 1 ); |
1747 | } | 1747 | } |
1748 | if ( result == 0 ) { | 1748 | if ( result == 0 ) { |
1749 | if ( mView->openCalendar( fn, true )) { | 1749 | if ( mView->openCalendar( fn, true )) { |
1750 | KOPrefs::instance()->mLastImportFile = fn; | 1750 | KOPrefs::instance()->mLastImportFile = fn; |
1751 | setCaption(i18n("Imported file successfully")); | 1751 | setCaption(i18n("Imported file successfully")); |
1752 | } else { | 1752 | } else { |
1753 | setCaption(i18n("Error importing file")); | 1753 | setCaption(i18n("Error importing file")); |
1754 | } | 1754 | } |
1755 | } | 1755 | } |
1756 | } | 1756 | } |
1757 | 1757 | ||
1758 | void MainWindow::importIcal() | 1758 | void MainWindow::importIcal() |
1759 | { | 1759 | { |
1760 | 1760 | ||
1761 | QString fn =KOPrefs::instance()->mLastImportFile; | 1761 | QString fn =KOPrefs::instance()->mLastImportFile; |
1762 | 1762 | ||
1763 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1763 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1764 | if ( fn == "" ) | 1764 | if ( fn == "" ) |
1765 | return; | 1765 | return; |
1766 | importFile( fn, true ); | 1766 | importFile( fn, true ); |
1767 | 1767 | ||
1768 | } | 1768 | } |
1769 | 1769 | ||
1770 | void MainWindow::exportVCalendar() | 1770 | void MainWindow::exportVCalendar() |
1771 | { | 1771 | { |
1772 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1772 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1773 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1773 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1774 | if ( fn == "" ) | 1774 | if ( fn == "" ) |
1775 | return; | 1775 | return; |
1776 | QFileInfo info; | 1776 | QFileInfo info; |
1777 | info.setFile( fn ); | 1777 | info.setFile( fn ); |
1778 | QString mes; | 1778 | QString mes; |
1779 | bool createbup = true; | 1779 | bool createbup = true; |
1780 | if ( info. exists() ) { | 1780 | if ( info. exists() ) { |
1781 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1781 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1782 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1782 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1783 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1783 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1784 | 0, 1 ); | 1784 | 0, 1 ); |
1785 | if ( result != 0 ) { | 1785 | if ( result != 0 ) { |
1786 | createbup = false; | 1786 | createbup = false; |
1787 | } | 1787 | } |
1788 | } | 1788 | } |
1789 | if ( createbup ) { | 1789 | if ( createbup ) { |
1790 | if ( mView->exportVCalendar( fn ) ) { | 1790 | if ( mView->exportVCalendar( fn ) ) { |
1791 | KOPrefs::instance()->mLastVcalFile = fn; | 1791 | KOPrefs::instance()->mLastVcalFile = fn; |
1792 | if ( fn.length() > 20 ) | 1792 | if ( fn.length() > 20 ) |
1793 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1793 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1794 | else | 1794 | else |
1795 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1795 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1796 | setCaption(mes); | 1796 | setCaption(mes); |
1797 | } | 1797 | } |
1798 | } | 1798 | } |
1799 | 1799 | ||
1800 | } | 1800 | } |
1801 | 1801 | ||
1802 | void MainWindow::syncFileRequest() | 1802 | void MainWindow::syncFileRequest() |
1803 | { | 1803 | { |
1804 | save(); | 1804 | save(); |
1805 | } | 1805 | } |
1806 | void MainWindow::getFile( bool success ) | 1806 | void MainWindow::getFile( bool success ) |
1807 | { | 1807 | { |
1808 | if ( ! success ) { | 1808 | if ( ! success ) { |
1809 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 1809 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
1810 | return; | 1810 | return; |
1811 | } | 1811 | } |
1812 | mView->openCalendar( defaultFileName() ); | 1812 | mView->openCalendar( defaultFileName() ); |
1813 | setCaption( i18n("Pi-Sync successful!") ); | 1813 | setCaption( i18n("Pi-Sync successful!") ); |
1814 | } | 1814 | } |
1815 | 1815 | ||
1816 | void MainWindow::printSel( ) | 1816 | void MainWindow::printSel( ) |
1817 | { | 1817 | { |
1818 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 1818 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
1819 | } | 1819 | } |
1820 | 1820 | ||
1821 | void MainWindow::printCal() | 1821 | void MainWindow::printCal() |
1822 | { | 1822 | { |
1823 | mView->print();//mCp->showDialog(); | 1823 | mView->print();//mCp->showDialog(); |
1824 | } | 1824 | } |
1825 | 1825 | ||
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 101db57..900fc04 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -1,620 +1,620 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qclipboard.h> | 28 | #include <qclipboard.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | 34 | ||
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
39 | #include <phoneaccess.h> | 39 | #include <phoneaccess.h> |
40 | 40 | ||
41 | #include "calendar.h" | 41 | #include "calendar.h" |
42 | #include "alarm.h" | 42 | #include "alarm.h" |
43 | #include "recurrence.h" | 43 | #include "recurrence.h" |
44 | #include "calendarlocal.h" | 44 | #include "calendarlocal.h" |
45 | 45 | ||
46 | #include "phoneformat.h" | 46 | #include "phoneformat.h" |
47 | #include "syncdefines.h" | 47 | #include "syncdefines.h" |
48 | 48 | ||
49 | using namespace KCal; | 49 | using namespace KCal; |
50 | class PhoneParser : public QObject | 50 | class PhoneParser : public QObject |
51 | { | 51 | { |
52 | public: | 52 | public: |
53 | PhoneParser( ) { | 53 | PhoneParser( ) { |
54 | ; | 54 | ; |
55 | } | 55 | } |
56 | 56 | ||
57 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) | 57 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) |
58 | { | 58 | { |
59 | QString datestr; | 59 | QString datestr; |
60 | QString timestr; | 60 | QString timestr; |
61 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 61 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
62 | QDateTime dt; | 62 | QDateTime dt; |
63 | if (useTZ) | 63 | if (useTZ) |
64 | dt = dti.addSecs ( -(offset*60)); | 64 | dt = dti.addSecs ( -(offset*60)); |
65 | else | 65 | else |
66 | dt = dti; | 66 | dt = dti; |
67 | if(dt.date().isValid()){ | 67 | if(dt.date().isValid()){ |
68 | const QDate& date = dt.date(); | 68 | const QDate& date = dt.date(); |
69 | datestr.sprintf("%04d%02d%02d", | 69 | datestr.sprintf("%04d%02d%02d", |
70 | date.year(), date.month(), date.day()); | 70 | date.year(), date.month(), date.day()); |
71 | } | 71 | } |
72 | if(dt.time().isValid()){ | 72 | if(dt.time().isValid()){ |
73 | const QTime& time = dt.time(); | 73 | const QTime& time = dt.time(); |
74 | timestr.sprintf("T%02d%02d%02d", | 74 | timestr.sprintf("T%02d%02d%02d", |
75 | time.hour(), time.minute(), time.second()); | 75 | time.hour(), time.minute(), time.second()); |
76 | } | 76 | } |
77 | return datestr + timestr; | 77 | return datestr + timestr; |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | }; | 81 | }; |
82 | 82 | ||
83 | 83 | ||
84 | 84 | ||
85 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) | 85 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) |
86 | { | 86 | { |
87 | mProfileName = profileName; | 87 | mProfileName = profileName; |
88 | PhoneAccess::writeConfig( device, connection, model ); | 88 | PhoneAccess::writeConfig( device, connection, model ); |
89 | } | 89 | } |
90 | 90 | ||
91 | PhoneFormat::~PhoneFormat() | 91 | PhoneFormat::~PhoneFormat() |
92 | { | 92 | { |
93 | } | 93 | } |
94 | 94 | ||
95 | #if 0 | 95 | #if 0 |
96 | int PhoneFormat::initDevice(GSM_StateMachine *s) | 96 | int PhoneFormat::initDevice(GSM_StateMachine *s) |
97 | { | 97 | { |
98 | GSM_ReadConfig(NULL, &s->Config[0], 0); | 98 | GSM_ReadConfig(NULL, &s->Config[0], 0); |
99 | s->ConfigNum = 1; | 99 | s->ConfigNum = 1; |
100 | GSM_Config *cfg = &s->Config[0]; | 100 | GSM_Config *cfg = &s->Config[0]; |
101 | if ( ! mConnection.isEmpty() ) { | 101 | if ( ! mConnection.isEmpty() ) { |
102 | cfg->Connection = strdup(mConnection.latin1()); | 102 | cfg->Connection = strdup(mConnection.latin1()); |
103 | cfg->DefaultConnection = false; | 103 | cfg->DefaultConnection = false; |
104 | qDebug("Connection set %s ", cfg->Connection ); | 104 | qDebug("Connection set %s ", cfg->Connection ); |
105 | 105 | ||
106 | } | 106 | } |
107 | if ( ! mDevice.isEmpty() ) { | 107 | if ( ! mDevice.isEmpty() ) { |
108 | cfg->Device = strdup(mDevice.latin1()); | 108 | cfg->Device = strdup(mDevice.latin1()); |
109 | cfg->DefaultDevice = false; | 109 | cfg->DefaultDevice = false; |
110 | qDebug("Device set %s ", cfg->Device); | 110 | qDebug("Device set %s ", cfg->Device); |
111 | 111 | ||
112 | } | 112 | } |
113 | if ( ! mModel.isEmpty() ) { | 113 | if ( ! mModel.isEmpty() ) { |
114 | strcpy(cfg->Model,mModel.latin1() ); | 114 | strcpy(cfg->Model,mModel.latin1() ); |
115 | cfg->DefaultModel = false; | 115 | cfg->DefaultModel = false; |
116 | qDebug("Model set %s ",cfg->Model ); | 116 | qDebug("Model set %s ",cfg->Model ); |
117 | } | 117 | } |
118 | int error=GSM_InitConnection(s,3); | 118 | int error=GSM_InitConnection(s,3); |
119 | return error; | 119 | return error; |
120 | } | 120 | } |
121 | #endif | 121 | #endif |
122 | ulong PhoneFormat::getCsumTodo( Todo* todo ) | 122 | ulong PhoneFormat::getCsumTodo( Todo* todo ) |
123 | { | 123 | { |
124 | QStringList attList; | 124 | QStringList attList; |
125 | if ( todo->hasDueDate() ) | 125 | if ( todo->hasDueDate() ) |
126 | attList << PhoneParser::dtToString ( todo->dtDue() ); | 126 | attList << PhoneParser::dtToString ( todo->dtDue() ); |
127 | attList << todo->summary(); | 127 | attList << todo->summary(); |
128 | QString completedString = "no"; | 128 | QString completedString = "no"; |
129 | if ( todo->isCompleted() ) | 129 | if ( todo->isCompleted() ) |
130 | completedString = "yes"; | 130 | completedString = "yes"; |
131 | attList << completedString; | 131 | attList << completedString; |
132 | int prio = todo->priority(); | 132 | int prio = todo->priority(); |
133 | if( prio == 2 ) prio = 1; | 133 | if( prio == 2 ) prio = 1; |
134 | if (prio == 4 ) prio = 5 ; | 134 | if (prio == 4 ) prio = 5 ; |
135 | attList << QString::number( prio ); | 135 | attList << QString::number( prio ); |
136 | QString alarmString = "na"; | 136 | QString alarmString = "na"; |
137 | Alarm *alarm; | 137 | Alarm *alarm; |
138 | if ( todo->alarms().count() > 0 ) { | 138 | if ( todo->alarms().count() > 0 ) { |
139 | alarm = todo->alarms().first(); | 139 | alarm = todo->alarms().first(); |
140 | if ( alarm->enabled() ) { | 140 | if ( alarm->enabled() ) { |
141 | alarmString = QString::number(alarm->offset() ); | 141 | alarmString = QString::number(alarm->offset() ); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | attList << alarmString; | 144 | attList << alarmString; |
145 | attList << todo->categoriesStr(); | 145 | attList << todo->categoriesStr(); |
146 | attList << todo->secrecyStr(); | 146 | attList << todo->secrecyStr(); |
147 | return PhoneFormat::getCsum(attList ); | 147 | return PhoneFormat::getCsum(attList ); |
148 | 148 | ||
149 | } | 149 | } |
150 | ulong PhoneFormat::getCsumEvent( Event* event ) | 150 | ulong PhoneFormat::getCsumEvent( Event* event ) |
151 | { | 151 | { |
152 | QStringList attList; | 152 | QStringList attList; |
153 | attList << PhoneParser::dtToString ( event->dtStart() ); | 153 | attList << PhoneParser::dtToString ( event->dtStart() ); |
154 | attList << PhoneParser::dtToString ( event->dtEnd() ); | 154 | attList << PhoneParser::dtToString ( event->dtEnd() ); |
155 | attList << event->summary(); | 155 | attList << event->summary(); |
156 | attList << event->location(); | 156 | attList << event->location(); |
157 | QString alarmString = "na"; | 157 | QString alarmString = "na"; |
158 | Alarm *alarm; | 158 | Alarm *alarm; |
159 | if ( event->alarms().count() > 0 ) { | 159 | if ( event->alarms().count() > 0 ) { |
160 | alarm = event->alarms().first(); | 160 | alarm = event->alarms().first(); |
161 | if ( alarm->enabled() ) { | 161 | if ( alarm->enabled() ) { |
162 | alarmString = QString::number( alarm->offset() ); | 162 | alarmString = QString::number( alarm->offset() ); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | attList << alarmString; | 165 | attList << alarmString; |
166 | Recurrence* rec = event->recurrence(); | 166 | Recurrence* rec = event->recurrence(); |
167 | QStringList list; | 167 | QStringList list; |
168 | bool writeEndDate = false; | 168 | bool writeEndDate = false; |
169 | switch ( rec->doesRecur() ) | 169 | switch ( rec->doesRecur() ) |
170 | { | 170 | { |
171 | case Recurrence::rDaily: // 0 | 171 | case Recurrence::rDaily: // 0 |
172 | list.append( "0" ); | 172 | list.append( "0" ); |
173 | list.append( QString::number( rec->frequency() ));//12 | 173 | list.append( QString::number( rec->frequency() ));//12 |
174 | list.append( "0" ); | 174 | list.append( "0" ); |
175 | list.append( "0" ); | 175 | list.append( "0" ); |
176 | writeEndDate = true; | 176 | writeEndDate = true; |
177 | break; | 177 | break; |
178 | case Recurrence::rWeekly:// 1 | 178 | case Recurrence::rWeekly:// 1 |
179 | list.append( "1" ); | 179 | list.append( "1" ); |
180 | list.append( QString::number( rec->frequency()) );//12 | 180 | list.append( QString::number( rec->frequency()) );//12 |
181 | list.append( "0" ); | 181 | list.append( "0" ); |
182 | { | 182 | { |
183 | int days = 0; | 183 | int days = 0; |
184 | QBitArray weekDays = rec->days(); | 184 | QBitArray weekDays = rec->days(); |
185 | int i; | 185 | int i; |
186 | for( i = 1; i <= 7; ++i ) { | 186 | for( i = 1; i <= 7; ++i ) { |
187 | if ( weekDays[i-1] ) { | 187 | if ( weekDays[i-1] ) { |
188 | days += 1 << (i-1); | 188 | days += 1 << (i-1); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | list.append( QString::number( days ) ); | 191 | list.append( QString::number( days ) ); |
192 | } | 192 | } |
193 | //pending weekdays | 193 | //pending weekdays |
194 | writeEndDate = true; | 194 | writeEndDate = true; |
195 | 195 | ||
196 | break; | 196 | break; |
197 | case Recurrence::rMonthlyPos:// 2 | 197 | case Recurrence::rMonthlyPos:// 2 |
198 | list.append( "2" ); | 198 | list.append( "2" ); |
199 | list.append( QString::number( rec->frequency()) );//12 | 199 | list.append( QString::number( rec->frequency()) );//12 |
200 | 200 | ||
201 | writeEndDate = true; | 201 | writeEndDate = true; |
202 | { | 202 | { |
203 | int count = 1; | 203 | int count = 1; |
204 | QPtrList<Recurrence::rMonthPos> rmp; | 204 | QPtrList<Recurrence::rMonthPos> rmp; |
205 | rmp = rec->monthPositions(); | 205 | rmp = rec->monthPositions(); |
206 | if ( rmp.first()->negative ) | 206 | if ( rmp.first()->negative ) |
207 | count = 5 - rmp.first()->rPos - 1; | 207 | count = 5 - rmp.first()->rPos - 1; |
208 | else | 208 | else |
209 | count = rmp.first()->rPos - 1; | 209 | count = rmp.first()->rPos - 1; |
210 | list.append( QString::number( count ) ); | 210 | list.append( QString::number( count ) ); |
211 | 211 | ||
212 | } | 212 | } |
213 | 213 | ||
214 | list.append( "0" ); | 214 | list.append( "0" ); |
215 | break; | 215 | break; |
216 | case Recurrence::rMonthlyDay:// 3 | 216 | case Recurrence::rMonthlyDay:// 3 |
217 | list.append( "3" ); | 217 | list.append( "3" ); |
218 | list.append( QString::number( rec->frequency()) );//12 | 218 | list.append( QString::number( rec->frequency()) );//12 |
219 | list.append( "0" ); | 219 | list.append( "0" ); |
220 | list.append( "0" ); | 220 | list.append( "0" ); |
221 | writeEndDate = true; | 221 | writeEndDate = true; |
222 | break; | 222 | break; |
223 | case Recurrence::rYearlyMonth://4 | 223 | case Recurrence::rYearlyMonth://4 |
224 | list.append( "4" ); | 224 | list.append( "4" ); |
225 | list.append( QString::number( rec->frequency()) );//12 | 225 | list.append( QString::number( rec->frequency()) );//12 |
226 | list.append( "0" ); | 226 | list.append( "0" ); |
227 | list.append( "0" ); | 227 | list.append( "0" ); |
228 | writeEndDate = true; | 228 | writeEndDate = true; |
229 | break; | 229 | break; |
230 | 230 | ||
231 | default: | 231 | default: |
232 | list.append( "255" ); | 232 | list.append( "255" ); |
233 | list.append( QString() ); | 233 | list.append( QString() ); |
234 | list.append( "0" ); | 234 | list.append( "0" ); |
235 | list.append( QString() ); | 235 | list.append( QString() ); |
236 | list.append( "0" ); | 236 | list.append( "0" ); |
237 | list.append( "20991231T000000" ); | 237 | list.append( "20991231T000000" ); |
238 | break; | 238 | break; |
239 | } | 239 | } |
240 | if ( writeEndDate ) { | 240 | if ( writeEndDate ) { |
241 | 241 | ||
242 | if ( rec->endDate().isValid() ) { // 15 + 16 | 242 | if ( rec->endDate().isValid() ) { // 15 + 16 |
243 | list.append( "1" ); | 243 | list.append( "1" ); |
244 | list.append( PhoneParser::dtToString( rec->endDate()) ); | 244 | list.append( PhoneParser::dtToString( rec->endDate()) ); |
245 | } else { | 245 | } else { |
246 | list.append( "0" ); | 246 | list.append( "0" ); |
247 | list.append( "20991231T000000" ); | 247 | list.append( "20991231T000000" ); |
248 | } | 248 | } |
249 | 249 | ||
250 | } | 250 | } |
251 | attList << list.join(""); | 251 | attList << list.join(""); |
252 | attList << event->categoriesStr(); | 252 | attList << event->categoriesStr(); |
253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); | 253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); |
254 | 254 | ||
255 | attList << event->secrecyStr(); | 255 | attList << event->secrecyStr(); |
256 | return PhoneFormat::getCsum(attList ); | 256 | return PhoneFormat::getCsum(attList ); |
257 | } | 257 | } |
258 | ulong PhoneFormat::getCsum( const QStringList & attList) | 258 | ulong PhoneFormat::getCsum( const QStringList & attList) |
259 | { | 259 | { |
260 | int max = attList.count(); | 260 | int max = attList.count(); |
261 | ulong cSum = 0; | 261 | ulong cSum = 0; |
262 | int j,k,i; | 262 | int j,k,i; |
263 | int add; | 263 | int add; |
264 | for ( i = 0; i < max ; ++i ) { | 264 | for ( i = 0; i < max ; ++i ) { |
265 | QString s = attList[i]; | 265 | QString s = attList[i]; |
266 | if ( ! s.isEmpty() ){ | 266 | if ( ! s.isEmpty() ){ |
267 | j = s.length(); | 267 | j = s.length(); |
268 | for ( k = 0; k < j; ++k ) { | 268 | for ( k = 0; k < j; ++k ) { |
269 | int mul = k +1; | 269 | int mul = k +1; |
270 | add = s[k].unicode (); | 270 | add = s[k].unicode (); |
271 | if ( k < 16 ) | 271 | if ( k < 16 ) |
272 | mul = mul * mul; | 272 | mul = mul * mul; |
273 | int ii = i+1; | 273 | int ii = i+1; |
274 | add = add * mul *ii*ii*ii; | 274 | add = add * mul *ii*ii*ii; |
275 | cSum += add; | 275 | cSum += add; |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | } | 279 | } |
280 | //QString dump = attList.join(","); | 280 | //QString dump = attList.join(","); |
281 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 281 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
282 | 282 | ||
283 | return cSum; | 283 | return cSum; |
284 | 284 | ||
285 | } | 285 | } |
286 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 286 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
287 | #include <stdlib.h> | 287 | #include <stdlib.h> |
288 | #define DEBUGMODE false | 288 | #define DEBUGMODE false |
289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
290 | { | 290 | { |
291 | 291 | ||
292 | QString fileName; | 292 | QString fileName; |
293 | #ifdef _WIN32_ | 293 | #ifdef DESKTOP_VERSION |
294 | fileName = locateLocal("tmp", "phonefile.vcs"); | 294 | fileName = locateLocal("tmp", "phonefile.vcs"); |
295 | #else | 295 | #else |
296 | fileName = "/tmp/phonefile.vcs"; | 296 | fileName = "/tmp/phonefile.vcs"; |
297 | #endif | 297 | #endif |
298 | QString command; | 298 | QString command; |
299 | if ( ! PhoneAccess::readFromPhone( fileName )) { | 299 | if ( ! PhoneAccess::readFromPhone( fileName )) { |
300 | return false; | 300 | return false; |
301 | } | 301 | } |
302 | VCalFormat vfload; | 302 | VCalFormat vfload; |
303 | vfload.setLocalTime ( true ); | 303 | vfload.setLocalTime ( true ); |
304 | qDebug("loading file ..."); | 304 | qDebug("loading file ..."); |
305 | 305 | ||
306 | if ( ! vfload.load( calendar, fileName ) ) | 306 | if ( ! vfload.load( calendar, fileName ) ) |
307 | return false; | 307 | return false; |
308 | QPtrList<Event> er = calendar->rawEvents(); | 308 | QPtrList<Event> er = calendar->rawEvents(); |
309 | Event* ev = er.first(); | 309 | Event* ev = er.first(); |
310 | qDebug("reading events... "); | 310 | qDebug("reading events... "); |
311 | while ( ev ) { | 311 | while ( ev ) { |
312 | QStringList cat = ev->categories(); | 312 | QStringList cat = ev->categories(); |
313 | if ( cat.contains( "MeetingDEF" )) { | 313 | if ( cat.contains( "MeetingDEF" )) { |
314 | ev->setCategories( QStringList() ); | 314 | ev->setCategories( QStringList() ); |
315 | } else | 315 | } else |
316 | if ( cat.contains( "Birthday" )) { | 316 | if ( cat.contains( "Birthday" )) { |
317 | ev->setFloats( true ); | 317 | ev->setFloats( true ); |
318 | QDate da = ev->dtStart().date(); | 318 | QDate da = ev->dtStart().date(); |
319 | ev->setDtStart( QDateTime( da) ); | 319 | ev->setDtStart( QDateTime( da) ); |
320 | ev->setDtEnd( QDateTime( da.addDays(1)) ); | 320 | ev->setDtEnd( QDateTime( da.addDays(1)) ); |
321 | 321 | ||
322 | } | 322 | } |
323 | uint cSum; | 323 | uint cSum; |
324 | cSum = PhoneFormat::getCsumEvent( ev ); | 324 | cSum = PhoneFormat::getCsumEvent( ev ); |
325 | int id = ev->pilotId(); | 325 | int id = ev->pilotId(); |
326 | Event *event; | 326 | Event *event; |
327 | event = existingCal->event( mProfileName ,QString::number( id ) ); | 327 | event = existingCal->event( mProfileName ,QString::number( id ) ); |
328 | if ( event ) { | 328 | if ( event ) { |
329 | event = (Event*)event->clone(); | 329 | event = (Event*)event->clone(); |
330 | copyEvent( event, ev ); | 330 | copyEvent( event, ev ); |
331 | calendar->deleteEvent( ev ); | 331 | calendar->deleteEvent( ev ); |
332 | calendar->addEvent( event); | 332 | calendar->addEvent( event); |
333 | } | 333 | } |
334 | else | 334 | else |
335 | event = ev; | 335 | event = ev; |
336 | event->setCsum( mProfileName, QString::number( cSum )); | 336 | event->setCsum( mProfileName, QString::number( cSum )); |
337 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 337 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
338 | event->setID( mProfileName,QString::number( id ) ); | 338 | event->setID( mProfileName,QString::number( id ) ); |
339 | ev = er.next(); | 339 | ev = er.next(); |
340 | } | 340 | } |
341 | { | 341 | { |
342 | qDebug("reading todos... "); | 342 | qDebug("reading todos... "); |
343 | QPtrList<Todo> tr = calendar->rawTodos(); | 343 | QPtrList<Todo> tr = calendar->rawTodos(); |
344 | Todo* ev = tr.first(); | 344 | Todo* ev = tr.first(); |
345 | while ( ev ) { | 345 | while ( ev ) { |
346 | 346 | ||
347 | QStringList cat = ev->categories(); | 347 | QStringList cat = ev->categories(); |
348 | if ( cat.contains( "MeetingDEF" )) { | 348 | if ( cat.contains( "MeetingDEF" )) { |
349 | ev->setCategories( QStringList() ); | 349 | ev->setCategories( QStringList() ); |
350 | } | 350 | } |
351 | int id = ev->pilotId(); | 351 | int id = ev->pilotId(); |
352 | uint cSum; | 352 | uint cSum; |
353 | cSum = PhoneFormat::getCsumTodo( ev ); | 353 | cSum = PhoneFormat::getCsumTodo( ev ); |
354 | Todo *event; | 354 | Todo *event; |
355 | event = existingCal->todo( mProfileName ,QString::number( id ) ); | 355 | event = existingCal->todo( mProfileName ,QString::number( id ) ); |
356 | if ( event ) { | 356 | if ( event ) { |
357 | //qDebug("copy todo %s ", event->summary().latin1()); | 357 | //qDebug("copy todo %s ", event->summary().latin1()); |
358 | 358 | ||
359 | event = (Todo*)event->clone(); | 359 | event = (Todo*)event->clone(); |
360 | copyTodo( event, ev ); | 360 | copyTodo( event, ev ); |
361 | calendar->deleteTodo( ev ); | 361 | calendar->deleteTodo( ev ); |
362 | calendar->addTodo( event); | 362 | calendar->addTodo( event); |
363 | } | 363 | } |
364 | else | 364 | else |
365 | event = ev; | 365 | event = ev; |
366 | event->setCsum( mProfileName, QString::number( cSum )); | 366 | event->setCsum( mProfileName, QString::number( cSum )); |
367 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 367 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
368 | event->setID( mProfileName,QString::number( id ) ); | 368 | event->setID( mProfileName,QString::number( id ) ); |
369 | ev = tr.next(); | 369 | ev = tr.next(); |
370 | } | 370 | } |
371 | } | 371 | } |
372 | return true; | 372 | return true; |
373 | } | 373 | } |
374 | void PhoneFormat::copyEvent( Event* to, Event* from ) | 374 | void PhoneFormat::copyEvent( Event* to, Event* from ) |
375 | { | 375 | { |
376 | if ( from->dtStart().isValid() ) | 376 | if ( from->dtStart().isValid() ) |
377 | to->setDtStart( from->dtStart() ); | 377 | to->setDtStart( from->dtStart() ); |
378 | if ( from->dtEnd().isValid() ) | 378 | if ( from->dtEnd().isValid() ) |
379 | to->setDtEnd( from->dtEnd() ); | 379 | to->setDtEnd( from->dtEnd() ); |
380 | if ( !from->location().isEmpty() ) | 380 | if ( !from->location().isEmpty() ) |
381 | to->setLocation( from->location() ); | 381 | to->setLocation( from->location() ); |
382 | if ( !from->description().isEmpty() ) | 382 | if ( !from->description().isEmpty() ) |
383 | to->setDescription( from->description() ); | 383 | to->setDescription( from->description() ); |
384 | if ( !from->summary().isEmpty() ) | 384 | if ( !from->summary().isEmpty() ) |
385 | to->setSummary( from->summary() ); | 385 | to->setSummary( from->summary() ); |
386 | 386 | ||
387 | if ( from->alarms().count() ) { | 387 | if ( from->alarms().count() ) { |
388 | to->clearAlarms(); | 388 | to->clearAlarms(); |
389 | Alarm *a = from->alarms().first(); | 389 | Alarm *a = from->alarms().first(); |
390 | Alarm *b = to->newAlarm( ); | 390 | Alarm *b = to->newAlarm( ); |
391 | b->setEnabled( a->enabled() ); | 391 | b->setEnabled( a->enabled() ); |
392 | b->setStartOffset(Duration( a->offset() ) ); | 392 | b->setStartOffset(Duration( a->offset() ) ); |
393 | 393 | ||
394 | } | 394 | } |
395 | QStringList cat = to->categories(); | 395 | QStringList cat = to->categories(); |
396 | QStringList catFrom = from->categories(); | 396 | QStringList catFrom = from->categories(); |
397 | QString nCat; | 397 | QString nCat; |
398 | int iii; | 398 | int iii; |
399 | for ( iii = 0; iii < catFrom.count();++iii ) { | 399 | for ( iii = 0; iii < catFrom.count();++iii ) { |
400 | nCat = catFrom[iii]; | 400 | nCat = catFrom[iii]; |
401 | if ( !nCat.isEmpty() ) | 401 | if ( !nCat.isEmpty() ) |
402 | if ( !cat.contains( nCat )) { | 402 | if ( !cat.contains( nCat )) { |
403 | cat << nCat; | 403 | cat << nCat; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | to->setCategories( cat ); | 406 | to->setCategories( cat ); |
407 | if ( from->doesRecur() ) { | 407 | if ( from->doesRecur() ) { |
408 | Recurrence * r = new Recurrence( *from->recurrence(),to); | 408 | Recurrence * r = new Recurrence( *from->recurrence(),to); |
409 | to->setRecurrence( r ) ; | 409 | to->setRecurrence( r ) ; |
410 | } | 410 | } |
411 | 411 | ||
412 | 412 | ||
413 | } | 413 | } |
414 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) | 414 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) |
415 | { | 415 | { |
416 | if ( from->hasStartDate() ) { | 416 | if ( from->hasStartDate() ) { |
417 | to->setHasStartDate( true ); | 417 | to->setHasStartDate( true ); |
418 | to->setDtStart( from->dtStart() ); | 418 | to->setDtStart( from->dtStart() ); |
419 | } | 419 | } |
420 | if ( from->hasDueDate() ){ | 420 | if ( from->hasDueDate() ){ |
421 | to->setHasDueDate( true ); | 421 | to->setHasDueDate( true ); |
422 | to->setDtDue( from->dtDue() ); | 422 | to->setDtDue( from->dtDue() ); |
423 | } | 423 | } |
424 | if ( !from->location().isEmpty() ) | 424 | if ( !from->location().isEmpty() ) |
425 | to->setLocation( from->location() ); | 425 | to->setLocation( from->location() ); |
426 | if ( !from->description().isEmpty() ) | 426 | if ( !from->description().isEmpty() ) |
427 | to->setDescription( from->description() ); | 427 | to->setDescription( from->description() ); |
428 | if ( !from->summary().isEmpty() ) | 428 | if ( !from->summary().isEmpty() ) |
429 | to->setSummary( from->summary() ); | 429 | to->setSummary( from->summary() ); |
430 | 430 | ||
431 | if ( from->alarms().count() ) { | 431 | if ( from->alarms().count() ) { |
432 | to->clearAlarms(); | 432 | to->clearAlarms(); |
433 | Alarm *a = from->alarms().first(); | 433 | Alarm *a = from->alarms().first(); |
434 | Alarm *b = to->newAlarm( ); | 434 | Alarm *b = to->newAlarm( ); |
435 | b->setEnabled( a->enabled() ); | 435 | b->setEnabled( a->enabled() ); |
436 | b->setStartOffset(Duration( a->offset() ) ); | 436 | b->setStartOffset(Duration( a->offset() ) ); |
437 | } | 437 | } |
438 | 438 | ||
439 | QStringList cat = to->categories(); | 439 | QStringList cat = to->categories(); |
440 | QStringList catFrom = from->categories(); | 440 | QStringList catFrom = from->categories(); |
441 | QString nCat; | 441 | QString nCat; |
442 | int iii; | 442 | int iii; |
443 | for ( iii = 0; iii < catFrom.count();++iii ) { | 443 | for ( iii = 0; iii < catFrom.count();++iii ) { |
444 | nCat = catFrom[iii]; | 444 | nCat = catFrom[iii]; |
445 | if ( !nCat.isEmpty() ) | 445 | if ( !nCat.isEmpty() ) |
446 | if ( !cat.contains( nCat )) { | 446 | if ( !cat.contains( nCat )) { |
447 | cat << nCat; | 447 | cat << nCat; |
448 | } | 448 | } |
449 | } | 449 | } |
450 | to->setCategories( cat ); | 450 | to->setCategories( cat ); |
451 | if ( from->isCompleted() ) { | 451 | if ( from->isCompleted() ) { |
452 | to->setCompleted( true ); | 452 | to->setCompleted( true ); |
453 | if( from->completed().isValid() ) | 453 | if( from->completed().isValid() ) |
454 | to->setCompleted( from->completed() ); | 454 | to->setCompleted( from->completed() ); |
455 | } else { | 455 | } else { |
456 | // set percentcomplete only, if to->isCompleted() | 456 | // set percentcomplete only, if to->isCompleted() |
457 | if ( to->isCompleted() ) | 457 | if ( to->isCompleted() ) |
458 | to->setPercentComplete(from->percentComplete()); | 458 | to->setPercentComplete(from->percentComplete()); |
459 | } | 459 | } |
460 | if( to->priority() == 2 && from->priority() == 1 ) | 460 | if( to->priority() == 2 && from->priority() == 1 ) |
461 | ; //skip | 461 | ; //skip |
462 | else if (to->priority() == 4 && from->priority() == 5 ) | 462 | else if (to->priority() == 4 && from->priority() == 5 ) |
463 | ; | 463 | ; |
464 | else | 464 | else |
465 | to->setPriority(from->priority()); | 465 | to->setPriority(from->priority()); |
466 | 466 | ||
467 | } | 467 | } |
468 | #include <qcstring.h> | 468 | #include <qcstring.h> |
469 | 469 | ||
470 | void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum) | 470 | void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum) |
471 | { | 471 | { |
472 | inc->setID( mProfileName, id ); | 472 | inc->setID( mProfileName, id ); |
473 | inc->setCsum( mProfileName, csum); | 473 | inc->setCsum( mProfileName, csum); |
474 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 474 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
475 | 475 | ||
476 | } | 476 | } |
477 | 477 | ||
478 | bool PhoneFormat::writeToPhone( Calendar * calendar) | 478 | bool PhoneFormat::writeToPhone( Calendar * calendar) |
479 | { | 479 | { |
480 | #ifdef _WIN32_ | 480 | #ifdef DESKTOP_VERSION |
481 | QString fileName = locateLocal("tmp", "phonefile.vcs"); | 481 | QString fileName = locateLocal("tmp", "phonefile.vcs"); |
482 | #else | 482 | #else |
483 | QString fileName = "/tmp/phonefile.vcs"; | 483 | QString fileName = "/tmp/phonefile.vcs"; |
484 | #endif | 484 | #endif |
485 | 485 | ||
486 | VCalFormat vfsave; | 486 | VCalFormat vfsave; |
487 | vfsave.setLocalTime ( true ); | 487 | vfsave.setLocalTime ( true ); |
488 | QString id = calendar->timeZoneId(); | 488 | QString id = calendar->timeZoneId(); |
489 | calendar->setLocalTime(); | 489 | calendar->setLocalTime(); |
490 | if ( ! vfsave.save( calendar, fileName ) ) | 490 | if ( ! vfsave.save( calendar, fileName ) ) |
491 | return false; | 491 | return false; |
492 | calendar->setTimeZoneId( id ); | 492 | calendar->setTimeZoneId( id ); |
493 | return PhoneAccess::writeToPhone( fileName ); | 493 | return PhoneAccess::writeToPhone( fileName ); |
494 | } | 494 | } |
495 | bool PhoneFormat::save( Calendar *calendar) | 495 | bool PhoneFormat::save( Calendar *calendar) |
496 | { | 496 | { |
497 | 497 | ||
498 | 498 | ||
499 | // 1 remove events which should be deleted | 499 | // 1 remove events which should be deleted |
500 | QPtrList<Event> er = calendar->rawEvents(); | 500 | QPtrList<Event> er = calendar->rawEvents(); |
501 | Event* ev = er.first(); | 501 | Event* ev = er.first(); |
502 | while ( ev ) { | 502 | while ( ev ) { |
503 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 503 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
504 | calendar->deleteEvent( ev ); | 504 | calendar->deleteEvent( ev ); |
505 | } else { | 505 | } else { |
506 | 506 | ||
507 | } | 507 | } |
508 | ev = er.next(); | 508 | ev = er.next(); |
509 | } | 509 | } |
510 | // 2 remove todos which should be deleted | 510 | // 2 remove todos which should be deleted |
511 | QPtrList<Todo> tl = calendar->rawTodos(); | 511 | QPtrList<Todo> tl = calendar->rawTodos(); |
512 | Todo* to = tl.first(); | 512 | Todo* to = tl.first(); |
513 | while ( to ) { | 513 | while ( to ) { |
514 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 514 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
515 | calendar->deleteTodo( to ); | 515 | calendar->deleteTodo( to ); |
516 | } else { | 516 | } else { |
517 | if ( to->isCompleted()) { | 517 | if ( to->isCompleted()) { |
518 | calendar->deleteTodo( to ); | 518 | calendar->deleteTodo( to ); |
519 | } | 519 | } |
520 | } | 520 | } |
521 | to = tl.next(); | 521 | to = tl.next(); |
522 | } | 522 | } |
523 | // 3 save file | 523 | // 3 save file |
524 | if ( !writeToPhone( calendar ) ) | 524 | if ( !writeToPhone( calendar ) ) |
525 | return false; | 525 | return false; |
526 | QLabel status ( i18n(" Opening device ..."), 0 ); | 526 | QLabel status ( i18n(" Opening device ..."), 0 ); |
527 | int w = status.sizeHint().width()+20 ; | 527 | int w = status.sizeHint().width()+20 ; |
528 | if ( w < 200 ) w = 230; | 528 | if ( w < 200 ) w = 230; |
529 | int h = status.sizeHint().height()+20 ; | 529 | int h = status.sizeHint().height()+20 ; |
530 | int dw = QApplication::desktop()->width(); | 530 | int dw = QApplication::desktop()->width(); |
531 | int dh = QApplication::desktop()->height(); | 531 | int dh = QApplication::desktop()->height(); |
532 | status.setCaption(i18n("Writing to phone...") ); | 532 | status.setCaption(i18n("Writing to phone...") ); |
533 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 533 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
534 | QString message; | 534 | QString message; |
535 | status.show(); | 535 | status.show(); |
536 | status.raise(); | 536 | status.raise(); |
537 | qApp->processEvents(); | 537 | qApp->processEvents(); |
538 | // 5 reread data | 538 | // 5 reread data |
539 | message = i18n(" Rereading all data ... "); | 539 | message = i18n(" Rereading all data ... "); |
540 | status.setText ( message ); | 540 | status.setText ( message ); |
541 | qApp->processEvents(); | 541 | qApp->processEvents(); |
542 | CalendarLocal* calendarTemp = new CalendarLocal(); | 542 | CalendarLocal* calendarTemp = new CalendarLocal(); |
543 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); | 543 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); |
544 | if ( ! load( calendarTemp,calendar) ){ | 544 | if ( ! load( calendarTemp,calendar) ){ |
545 | qDebug("error reloading calendar "); | 545 | qDebug("error reloading calendar "); |
546 | delete calendarTemp; | 546 | delete calendarTemp; |
547 | return false; | 547 | return false; |
548 | } | 548 | } |
549 | // 6 compare data | 549 | // 6 compare data |
550 | 550 | ||
551 | //algo 6 compare event | 551 | //algo 6 compare event |
552 | er = calendar->rawEvents(); | 552 | er = calendar->rawEvents(); |
553 | ev = er.first(); | 553 | ev = er.first(); |
554 | message = i18n(" Comparing event # "); | 554 | message = i18n(" Comparing event # "); |
555 | QPtrList<Event> er1 = calendarTemp->rawEvents(); | 555 | QPtrList<Event> er1 = calendarTemp->rawEvents(); |
556 | Event* ev1; | 556 | Event* ev1; |
557 | int procCount = 0; | 557 | int procCount = 0; |
558 | while ( ev ) { | 558 | while ( ev ) { |
559 | //qDebug("event new ID %s",ev->summary().latin1()); | 559 | //qDebug("event new ID %s",ev->summary().latin1()); |
560 | status.setText ( message + QString::number ( ++procCount ) ); | 560 | status.setText ( message + QString::number ( ++procCount ) ); |
561 | qApp->processEvents(); | 561 | qApp->processEvents(); |
562 | ev1 = er1.first(); | 562 | ev1 = er1.first(); |
563 | while ( ev1 ) { | 563 | while ( ev1 ) { |
564 | if ( ev->contains( ev1 ) ) { | 564 | if ( ev->contains( ev1 ) ) { |
565 | afterSave( ev ,ev1->getID(mProfileName),ev1->getCsum(mProfileName)); | 565 | afterSave( ev ,ev1->getID(mProfileName),ev1->getCsum(mProfileName)); |
566 | er1.remove( ev1 ); | 566 | er1.remove( ev1 ); |
567 | break; | 567 | break; |
568 | } | 568 | } |
569 | ev1 = er1.next(); | 569 | ev1 = er1.next(); |
570 | } | 570 | } |
571 | if ( ! ev1 ) { | 571 | if ( ! ev1 ) { |
572 | // ev->removeID(mProfileName); | 572 | // ev->removeID(mProfileName); |
573 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); | 573 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); |
574 | } | 574 | } |
575 | 575 | ||
576 | 576 | ||
577 | ev = er.next(); | 577 | ev = er.next(); |
578 | } | 578 | } |
579 | //algo 6 compare todo | 579 | //algo 6 compare todo |
580 | tl = calendar->rawTodos(); | 580 | tl = calendar->rawTodos(); |
581 | to = tl.first(); | 581 | to = tl.first(); |
582 | procCount = 0; | 582 | procCount = 0; |
583 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); | 583 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); |
584 | Todo* to1 ; | 584 | Todo* to1 ; |
585 | message = i18n(" Comparing todo # "); | 585 | message = i18n(" Comparing todo # "); |
586 | while ( to ) { | 586 | while ( to ) { |
587 | status.setText ( message + QString::number ( ++procCount ) ); | 587 | status.setText ( message + QString::number ( ++procCount ) ); |
588 | qApp->processEvents(); | 588 | qApp->processEvents(); |
589 | Todo* to1 = tl1.first(); | 589 | Todo* to1 = tl1.first(); |
590 | while ( to1 ) { | 590 | while ( to1 ) { |
591 | if ( to->contains( to1 ) ) { | 591 | if ( to->contains( to1 ) ) { |
592 | afterSave( to ,to1->getID(mProfileName),to1->getCsum(mProfileName)); | 592 | afterSave( to ,to1->getID(mProfileName),to1->getCsum(mProfileName)); |
593 | tl1.remove( to1 ); | 593 | tl1.remove( to1 ); |
594 | break; | 594 | break; |
595 | } | 595 | } |
596 | to1 = tl1.next(); | 596 | to1 = tl1.next(); |
597 | } | 597 | } |
598 | if ( ! to1 ) { | 598 | if ( ! to1 ) { |
599 | //to->removeID(mProfileName); | 599 | //to->removeID(mProfileName); |
600 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); | 600 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); |
601 | } | 601 | } |
602 | 602 | ||
603 | to = tl.next(); | 603 | to = tl.next(); |
604 | } | 604 | } |
605 | delete calendarTemp; | 605 | delete calendarTemp; |
606 | return true; | 606 | return true; |
607 | 607 | ||
608 | 608 | ||
609 | 609 | ||
610 | } | 610 | } |
611 | 611 | ||
612 | 612 | ||
613 | QString PhoneFormat::toString( Calendar * ) | 613 | QString PhoneFormat::toString( Calendar * ) |
614 | { | 614 | { |
615 | return QString::null; | 615 | return QString::null; |
616 | } | 616 | } |
617 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) | 617 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) |
618 | { | 618 | { |
619 | return false; | 619 | return false; |
620 | } | 620 | } |
@@ -1 +1 @@ | |||
version = "1.9.8"; | version = "1.9.9"; | ||