author | zautrix <zautrix> | 2004-10-09 02:17:06 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-09 02:17:06 (UTC) |
commit | c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d (patch) (unidiff) | |
tree | b83f7cfe5d4bb681b756fe95446e5e3fc193bc36 /kaddressbook | |
parent | 07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861 (diff) | |
download | kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.zip kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.gz kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.bz2 |
import ir fixes
-rw-r--r-- | kaddressbook/kabcore.cpp | 22 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 1 | ||||
-rw-r--r-- | kaddressbook/kaddressbookmain.cpp | 12 | ||||
-rw-r--r-- | kaddressbook/kaddressbookmain.h | 2 | ||||
-rw-r--r-- | kaddressbook/mainembedded.cpp | 8 |
5 files changed, 28 insertions, 17 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 9b059d3..3a542ba 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,1095 +1,1101 @@ | |||
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 | bool pasteWithNewUid = true; | 207 | bool pasteWithNewUid = true; |
208 | 208 | ||
209 | #ifdef KAB_EMBEDDED | 209 | #ifdef KAB_EMBEDDED |
210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
214 | #else //KAB_EMBEDDED | 214 | #else //KAB_EMBEDDED |
215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
218 | mReadWrite( readWrite ), mModified( false ) | 218 | mReadWrite( readWrite ), mModified( false ) |
219 | #endif //KAB_EMBEDDED | 219 | #endif //KAB_EMBEDDED |
220 | { | 220 | { |
221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
222 | // syncManager->setBlockSave(false); | 222 | // syncManager->setBlockSave(false); |
223 | mExtensionBarSplitter = 0; | 223 | mExtensionBarSplitter = 0; |
224 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 224 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
225 | 225 | ||
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 | mEditorDialog = 0; | 310 | mEditorDialog = 0; |
311 | createAddresseeEditorDialog( this ); | 311 | createAddresseeEditorDialog( this ); |
312 | setModified( false ); | 312 | setModified( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | KABCore::~KABCore() | 315 | KABCore::~KABCore() |
316 | { | 316 | { |
317 | // save(); | 317 | // save(); |
318 | //saveSettings(); | 318 | //saveSettings(); |
319 | //KABPrefs::instance()->writeConfig(); | 319 | //KABPrefs::instance()->writeConfig(); |
320 | delete AddresseeConfig::instance(); | 320 | delete AddresseeConfig::instance(); |
321 | mAddressBook = 0; | 321 | mAddressBook = 0; |
322 | KABC::StdAddressBook::close(); | 322 | KABC::StdAddressBook::close(); |
323 | 323 | ||
324 | delete syncManager; | 324 | delete syncManager; |
325 | 325 | ||
326 | } | 326 | } |
327 | 327 | ||
328 | void KABCore::recieve( QString fn ) | ||
329 | { | ||
330 | qDebug("KABCore::recieve "); | ||
331 | mAddressBook->importFromFile( fn, true ); | ||
332 | topLevelWidget()->raise(); | ||
333 | } | ||
328 | void KABCore::restoreSettings() | 334 | void KABCore::restoreSettings() |
329 | { | 335 | { |
330 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 336 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
331 | 337 | ||
332 | bool state; | 338 | bool state; |
333 | 339 | ||
334 | if (mMultipleViewsAtOnce) | 340 | if (mMultipleViewsAtOnce) |
335 | state = KABPrefs::instance()->mDetailsPageVisible; | 341 | state = KABPrefs::instance()->mDetailsPageVisible; |
336 | else | 342 | else |
337 | state = false; | 343 | state = false; |
338 | 344 | ||
339 | mActionDetails->setChecked( state ); | 345 | mActionDetails->setChecked( state ); |
340 | setDetailsVisible( state ); | 346 | setDetailsVisible( state ); |
341 | 347 | ||
342 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 348 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
343 | 349 | ||
344 | mActionJumpBar->setChecked( state ); | 350 | mActionJumpBar->setChecked( state ); |
345 | setJumpButtonBarVisible( state ); | 351 | setJumpButtonBarVisible( state ); |
346 | /*US | 352 | /*US |
347 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 353 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
348 | if ( splitterSize.count() == 0 ) { | 354 | if ( splitterSize.count() == 0 ) { |
349 | splitterSize.append( width() / 2 ); | 355 | splitterSize.append( width() / 2 ); |
350 | splitterSize.append( width() / 2 ); | 356 | splitterSize.append( width() / 2 ); |
351 | } | 357 | } |
352 | mMiniSplitter->setSizes( splitterSize ); | 358 | mMiniSplitter->setSizes( splitterSize ); |
353 | if ( mExtensionBarSplitter ) { | 359 | if ( mExtensionBarSplitter ) { |
354 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 360 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
355 | if ( splitterSize.count() == 0 ) { | 361 | if ( splitterSize.count() == 0 ) { |
356 | splitterSize.append( width() / 2 ); | 362 | splitterSize.append( width() / 2 ); |
357 | splitterSize.append( width() / 2 ); | 363 | splitterSize.append( width() / 2 ); |
358 | } | 364 | } |
359 | mExtensionBarSplitter->setSizes( splitterSize ); | 365 | mExtensionBarSplitter->setSizes( splitterSize ); |
360 | 366 | ||
361 | } | 367 | } |
362 | */ | 368 | */ |
363 | mViewManager->restoreSettings(); | 369 | mViewManager->restoreSettings(); |
364 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 370 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
365 | mExtensionManager->restoreSettings(); | 371 | mExtensionManager->restoreSettings(); |
366 | #ifdef DESKTOP_VERSION | 372 | #ifdef DESKTOP_VERSION |
367 | int wid = width(); | 373 | int wid = width(); |
368 | if ( wid < 10 ) | 374 | if ( wid < 10 ) |
369 | wid = 400; | 375 | wid = 400; |
370 | #else | 376 | #else |
371 | int wid = QApplication::desktop()->width(); | 377 | int wid = QApplication::desktop()->width(); |
372 | if ( wid < 640 ) | 378 | if ( wid < 640 ) |
373 | wid = QApplication::desktop()->height(); | 379 | wid = QApplication::desktop()->height(); |
374 | #endif | 380 | #endif |
375 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 381 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
376 | if ( true /*splitterSize.count() == 0*/ ) { | 382 | if ( true /*splitterSize.count() == 0*/ ) { |
377 | splitterSize.append( wid / 2 ); | 383 | splitterSize.append( wid / 2 ); |
378 | splitterSize.append( wid / 2 ); | 384 | splitterSize.append( wid / 2 ); |
379 | } | 385 | } |
380 | mMiniSplitter->setSizes( splitterSize ); | 386 | mMiniSplitter->setSizes( splitterSize ); |
381 | if ( mExtensionBarSplitter ) { | 387 | if ( mExtensionBarSplitter ) { |
382 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 388 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
383 | if ( true /*splitterSize.count() == 0*/ ) { | 389 | if ( true /*splitterSize.count() == 0*/ ) { |
384 | splitterSize.append( wid / 2 ); | 390 | splitterSize.append( wid / 2 ); |
385 | splitterSize.append( wid / 2 ); | 391 | splitterSize.append( wid / 2 ); |
386 | } | 392 | } |
387 | mExtensionBarSplitter->setSizes( splitterSize ); | 393 | mExtensionBarSplitter->setSizes( splitterSize ); |
388 | 394 | ||
389 | } | 395 | } |
390 | 396 | ||
391 | 397 | ||
392 | } | 398 | } |
393 | 399 | ||
394 | void KABCore::saveSettings() | 400 | void KABCore::saveSettings() |
395 | { | 401 | { |
396 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 402 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
397 | if ( mExtensionBarSplitter ) | 403 | if ( mExtensionBarSplitter ) |
398 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 404 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
399 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 405 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
400 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 406 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
401 | #ifndef KAB_EMBEDDED | 407 | #ifndef KAB_EMBEDDED |
402 | 408 | ||
403 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 409 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
404 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 410 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
405 | #endif //KAB_EMBEDDED | 411 | #endif //KAB_EMBEDDED |
406 | mExtensionManager->saveSettings(); | 412 | mExtensionManager->saveSettings(); |
407 | mViewManager->saveSettings(); | 413 | mViewManager->saveSettings(); |
408 | 414 | ||
409 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 415 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
410 | } | 416 | } |
411 | 417 | ||
412 | KABC::AddressBook *KABCore::addressBook() const | 418 | KABC::AddressBook *KABCore::addressBook() const |
413 | { | 419 | { |
414 | return mAddressBook; | 420 | return mAddressBook; |
415 | } | 421 | } |
416 | 422 | ||
417 | KConfig *KABCore::config() | 423 | KConfig *KABCore::config() |
418 | { | 424 | { |
419 | #ifndef KAB_EMBEDDED | 425 | #ifndef KAB_EMBEDDED |
420 | return KABPrefs::instance()->config(); | 426 | return KABPrefs::instance()->config(); |
421 | #else //KAB_EMBEDDED | 427 | #else //KAB_EMBEDDED |
422 | return KABPrefs::instance()->getConfig(); | 428 | return KABPrefs::instance()->getConfig(); |
423 | #endif //KAB_EMBEDDED | 429 | #endif //KAB_EMBEDDED |
424 | } | 430 | } |
425 | 431 | ||
426 | KActionCollection *KABCore::actionCollection() const | 432 | KActionCollection *KABCore::actionCollection() const |
427 | { | 433 | { |
428 | return mGUIClient->actionCollection(); | 434 | return mGUIClient->actionCollection(); |
429 | } | 435 | } |
430 | 436 | ||
431 | KABC::Field *KABCore::currentSearchField() const | 437 | KABC::Field *KABCore::currentSearchField() const |
432 | { | 438 | { |
433 | if (mIncSearchWidget) | 439 | if (mIncSearchWidget) |
434 | return mIncSearchWidget->currentField(); | 440 | return mIncSearchWidget->currentField(); |
435 | else | 441 | else |
436 | return 0; | 442 | return 0; |
437 | } | 443 | } |
438 | 444 | ||
439 | QStringList KABCore::selectedUIDs() const | 445 | QStringList KABCore::selectedUIDs() const |
440 | { | 446 | { |
441 | return mViewManager->selectedUids(); | 447 | return mViewManager->selectedUids(); |
442 | } | 448 | } |
443 | 449 | ||
444 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 450 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
445 | { | 451 | { |
446 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 452 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
447 | 453 | ||
448 | QPtrList<KRES::Resource> kresResources; | 454 | QPtrList<KRES::Resource> kresResources; |
449 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 455 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
450 | KABC::Resource *resource; | 456 | KABC::Resource *resource; |
451 | while ( ( resource = resIt.current() ) != 0 ) { | 457 | while ( ( resource = resIt.current() ) != 0 ) { |
452 | ++resIt; | 458 | ++resIt; |
453 | if ( !resource->readOnly() ) { | 459 | if ( !resource->readOnly() ) { |
454 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 460 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
455 | if ( res ) | 461 | if ( res ) |
456 | kresResources.append( res ); | 462 | kresResources.append( res ); |
457 | } | 463 | } |
458 | } | 464 | } |
459 | 465 | ||
460 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 466 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
461 | return static_cast<KABC::Resource*>( res ); | 467 | return static_cast<KABC::Resource*>( res ); |
462 | } | 468 | } |
463 | 469 | ||
464 | #ifndef KAB_EMBEDDED | 470 | #ifndef KAB_EMBEDDED |
465 | KAboutData *KABCore::createAboutData() | 471 | KAboutData *KABCore::createAboutData() |
466 | #else //KAB_EMBEDDED | 472 | #else //KAB_EMBEDDED |
467 | void KABCore::createAboutData() | 473 | void KABCore::createAboutData() |
468 | #endif //KAB_EMBEDDED | 474 | #endif //KAB_EMBEDDED |
469 | { | 475 | { |
470 | #ifndef KAB_EMBEDDED | 476 | #ifndef KAB_EMBEDDED |
471 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 477 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
472 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 478 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
473 | KAboutData::License_GPL_V2, | 479 | KAboutData::License_GPL_V2, |
474 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 480 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
475 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 481 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
476 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 482 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
477 | about->addAuthor( "Cornelius Schumacher", | 483 | about->addAuthor( "Cornelius Schumacher", |
478 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 484 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
479 | "schumacher@kde.org" ); | 485 | "schumacher@kde.org" ); |
480 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 486 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
481 | "mpilone@slac.com" ); | 487 | "mpilone@slac.com" ); |
482 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 488 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
483 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 489 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
484 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 490 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
485 | "michel@klaralvdalens-datakonsult.se" ); | 491 | "michel@klaralvdalens-datakonsult.se" ); |
486 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 492 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
487 | "hansen@kde.org" ); | 493 | "hansen@kde.org" ); |
488 | 494 | ||
489 | return about; | 495 | return about; |
490 | #endif //KAB_EMBEDDED | 496 | #endif //KAB_EMBEDDED |
491 | 497 | ||
492 | QString version; | 498 | QString version; |
493 | #include <../version> | 499 | #include <../version> |
494 | QMessageBox::about( this, "About KAddressbook/Pi", | 500 | QMessageBox::about( this, "About KAddressbook/Pi", |
495 | "KAddressbook/Platform-independent\n" | 501 | "KAddressbook/Platform-independent\n" |
496 | "(KA/Pi) " +version + " - " + | 502 | "(KA/Pi) " +version + " - " + |
497 | #ifdef DESKTOP_VERSION | 503 | #ifdef DESKTOP_VERSION |
498 | "Desktop Edition\n" | 504 | "Desktop Edition\n" |
499 | #else | 505 | #else |
500 | "PDA-Edition\n" | 506 | "PDA-Edition\n" |
501 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 507 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
502 | #endif | 508 | #endif |
503 | 509 | ||
504 | "(c) 2004 Ulf Schenk\n" | 510 | "(c) 2004 Ulf Schenk\n" |
505 | "(c) 2004 Lutz Rogowski\n" | 511 | "(c) 2004 Lutz Rogowski\n" |
506 | "(c) 1997-2003, The KDE PIM Team\n" | 512 | "(c) 1997-2003, The KDE PIM Team\n" |
507 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 513 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
508 | "Don Sanders Original author\n" | 514 | "Don Sanders Original author\n" |
509 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 515 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
510 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 516 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
511 | "Greg Stern DCOP interface\n" | 517 | "Greg Stern DCOP interface\n" |
512 | "Mark Westcot Contact pinning\n" | 518 | "Mark Westcot Contact pinning\n" |
513 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 519 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
514 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 520 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
515 | #ifdef _WIN32_ | 521 | #ifdef _WIN32_ |
516 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 522 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
517 | #endif | 523 | #endif |
518 | ); | 524 | ); |
519 | } | 525 | } |
520 | 526 | ||
521 | void KABCore::setContactSelected( const QString &uid ) | 527 | void KABCore::setContactSelected( const QString &uid ) |
522 | { | 528 | { |
523 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 529 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
524 | if ( !mDetails->isHidden() ) | 530 | if ( !mDetails->isHidden() ) |
525 | mDetails->setAddressee( addr ); | 531 | mDetails->setAddressee( addr ); |
526 | 532 | ||
527 | if ( !addr.isEmpty() ) { | 533 | if ( !addr.isEmpty() ) { |
528 | emit contactSelected( addr.formattedName() ); | 534 | emit contactSelected( addr.formattedName() ); |
529 | KABC::Picture pic = addr.photo(); | 535 | KABC::Picture pic = addr.photo(); |
530 | if ( pic.isIntern() ) { | 536 | if ( pic.isIntern() ) { |
531 | //US emit contactSelected( pic.data() ); | 537 | //US emit contactSelected( pic.data() ); |
532 | //US instead use: | 538 | //US instead use: |
533 | QPixmap px; | 539 | QPixmap px; |
534 | if (pic.data().isNull() != true) | 540 | if (pic.data().isNull() != true) |
535 | { | 541 | { |
536 | px.convertFromImage(pic.data()); | 542 | px.convertFromImage(pic.data()); |
537 | } | 543 | } |
538 | 544 | ||
539 | emit contactSelected( px ); | 545 | emit contactSelected( px ); |
540 | } | 546 | } |
541 | } | 547 | } |
542 | 548 | ||
543 | 549 | ||
544 | mExtensionManager->setSelectionChanged(); | 550 | mExtensionManager->setSelectionChanged(); |
545 | 551 | ||
546 | // update the actions | 552 | // update the actions |
547 | bool selected = !uid.isEmpty(); | 553 | bool selected = !uid.isEmpty(); |
548 | 554 | ||
549 | if ( mReadWrite ) { | 555 | if ( mReadWrite ) { |
550 | mActionCut->setEnabled( selected ); | 556 | mActionCut->setEnabled( selected ); |
551 | mActionPaste->setEnabled( selected ); | 557 | mActionPaste->setEnabled( selected ); |
552 | } | 558 | } |
553 | 559 | ||
554 | mActionCopy->setEnabled( selected ); | 560 | mActionCopy->setEnabled( selected ); |
555 | mActionDelete->setEnabled( selected ); | 561 | mActionDelete->setEnabled( selected ); |
556 | mActionEditAddressee->setEnabled( selected ); | 562 | mActionEditAddressee->setEnabled( selected ); |
557 | mActionMail->setEnabled( selected ); | 563 | mActionMail->setEnabled( selected ); |
558 | mActionMailVCard->setEnabled( selected ); | 564 | mActionMailVCard->setEnabled( selected ); |
559 | //if (mActionBeam) | 565 | //if (mActionBeam) |
560 | //mActionBeam->setEnabled( selected ); | 566 | //mActionBeam->setEnabled( selected ); |
561 | 567 | ||
562 | if (mActionBeamVCard) | 568 | if (mActionBeamVCard) |
563 | mActionBeamVCard->setEnabled( selected ); | 569 | mActionBeamVCard->setEnabled( selected ); |
564 | 570 | ||
565 | mActionExport2phone->setEnabled( selected ); | 571 | mActionExport2phone->setEnabled( selected ); |
566 | mActionWhoAmI->setEnabled( selected ); | 572 | mActionWhoAmI->setEnabled( selected ); |
567 | mActionCategories->setEnabled( selected ); | 573 | mActionCategories->setEnabled( selected ); |
568 | } | 574 | } |
569 | 575 | ||
570 | void KABCore::sendMail() | 576 | void KABCore::sendMail() |
571 | { | 577 | { |
572 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 578 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
573 | } | 579 | } |
574 | 580 | ||
575 | void KABCore::sendMail( const QString& emaillist ) | 581 | void KABCore::sendMail( const QString& emaillist ) |
576 | { | 582 | { |
577 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 583 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
578 | if (emaillist.contains(",") > 0) | 584 | if (emaillist.contains(",") > 0) |
579 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 585 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
580 | else | 586 | else |
581 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 587 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
582 | } | 588 | } |
583 | 589 | ||
584 | 590 | ||
585 | 591 | ||
586 | void KABCore::mailVCard() | 592 | void KABCore::mailVCard() |
587 | { | 593 | { |
588 | QStringList uids = mViewManager->selectedUids(); | 594 | QStringList uids = mViewManager->selectedUids(); |
589 | if ( !uids.isEmpty() ) | 595 | if ( !uids.isEmpty() ) |
590 | mailVCard( uids ); | 596 | mailVCard( uids ); |
591 | } | 597 | } |
592 | 598 | ||
593 | void KABCore::mailVCard( const QStringList& uids ) | 599 | void KABCore::mailVCard( const QStringList& uids ) |
594 | { | 600 | { |
595 | QStringList urls; | 601 | QStringList urls; |
596 | 602 | ||
597 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 603 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
598 | 604 | ||
599 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 605 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
600 | 606 | ||
601 | 607 | ||
602 | 608 | ||
603 | QDir().mkdir( dirName, true ); | 609 | QDir().mkdir( dirName, true ); |
604 | 610 | ||
605 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 611 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
606 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 612 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
607 | 613 | ||
608 | if ( a.isEmpty() ) | 614 | if ( a.isEmpty() ) |
609 | continue; | 615 | continue; |
610 | 616 | ||
611 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 617 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
612 | 618 | ||
613 | QString fileName = dirName + "/" + name; | 619 | QString fileName = dirName + "/" + name; |
614 | 620 | ||
615 | QFile outFile(fileName); | 621 | QFile outFile(fileName); |
616 | 622 | ||
617 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 623 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
618 | KABC::VCardConverter converter; | 624 | KABC::VCardConverter converter; |
619 | QString vcard; | 625 | QString vcard; |
620 | 626 | ||
621 | converter.addresseeToVCard( a, vcard ); | 627 | converter.addresseeToVCard( a, vcard ); |
622 | 628 | ||
623 | QTextStream t( &outFile ); // use a text stream | 629 | QTextStream t( &outFile ); // use a text stream |
624 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 630 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
625 | t << vcard; | 631 | t << vcard; |
626 | 632 | ||
627 | outFile.close(); | 633 | outFile.close(); |
628 | 634 | ||
629 | urls.append( fileName ); | 635 | urls.append( fileName ); |
630 | } | 636 | } |
631 | } | 637 | } |
632 | 638 | ||
633 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 639 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
634 | 640 | ||
635 | 641 | ||
636 | /*US | 642 | /*US |
637 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 643 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
638 | QString::null, // subject | 644 | QString::null, // subject |
639 | QString::null, // body | 645 | QString::null, // body |
640 | QString::null, | 646 | QString::null, |
641 | urls ); // attachments | 647 | urls ); // attachments |
642 | */ | 648 | */ |
643 | 649 | ||
644 | } | 650 | } |
645 | 651 | ||
646 | /** | 652 | /** |
647 | Beams the "WhoAmI contact. | 653 | Beams the "WhoAmI contact. |
648 | */ | 654 | */ |
649 | void KABCore::beamMySelf() | 655 | void KABCore::beamMySelf() |
650 | { | 656 | { |
651 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 657 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
652 | if (!a.isEmpty()) | 658 | if (!a.isEmpty()) |
653 | { | 659 | { |
654 | QStringList uids; | 660 | QStringList uids; |
655 | uids << a.uid(); | 661 | uids << a.uid(); |
656 | 662 | ||
657 | beamVCard(uids); | 663 | beamVCard(uids); |
658 | } else { | 664 | } else { |
659 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 665 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
660 | 666 | ||
661 | 667 | ||
662 | } | 668 | } |
663 | } | 669 | } |
664 | 670 | ||
665 | void KABCore::export2phone() | 671 | void KABCore::export2phone() |
666 | { | 672 | { |
667 | 673 | ||
668 | KAex2phonePrefs ex2phone; | 674 | KAex2phonePrefs ex2phone; |
669 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 675 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
670 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 676 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
671 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 677 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
672 | 678 | ||
673 | if ( !ex2phone.exec() ) { | 679 | if ( !ex2phone.exec() ) { |
674 | return; | 680 | return; |
675 | } | 681 | } |
676 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 682 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
677 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 683 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
678 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 684 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
679 | 685 | ||
680 | 686 | ||
681 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 687 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
682 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 688 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
683 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 689 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
684 | 690 | ||
685 | QStringList uids = mViewManager->selectedUids(); | 691 | QStringList uids = mViewManager->selectedUids(); |
686 | if ( uids.isEmpty() ) | 692 | if ( uids.isEmpty() ) |
687 | return; | 693 | return; |
688 | 694 | ||
689 | #ifdef _WIN32_ | 695 | #ifdef _WIN32_ |
690 | QString fileName = locateLocal("tmp", "tempfile.vcf"); | 696 | QString fileName = locateLocal("tmp", "tempfile.vcf"); |
691 | #else | 697 | #else |
692 | QString fileName = "/tmp/kdepimtemp.vcf"; | 698 | QString fileName = "/tmp/kdepimtemp.vcf"; |
693 | #endif | 699 | #endif |
694 | 700 | ||
695 | KABC::VCardConverter converter; | 701 | KABC::VCardConverter converter; |
696 | QString description; | 702 | QString description; |
697 | QString datastream; | 703 | QString datastream; |
698 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 704 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
699 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 705 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
700 | 706 | ||
701 | if ( a.isEmpty() ) | 707 | if ( a.isEmpty() ) |
702 | continue; | 708 | continue; |
703 | a.simplifyEmails(); | 709 | a.simplifyEmails(); |
704 | a.simplifyPhoneNumbers(); | 710 | a.simplifyPhoneNumbers(); |
705 | a.simplifyPhoneNumberTypes(); | 711 | a.simplifyPhoneNumberTypes(); |
706 | a.simplifyAddresses(); | 712 | a.simplifyAddresses(); |
707 | 713 | ||
708 | if (description.isEmpty()) | 714 | if (description.isEmpty()) |
709 | description = a.formattedName(); | 715 | description = a.formattedName(); |
710 | QString vcard; | 716 | QString vcard; |
711 | QString vcardnew; | 717 | QString vcardnew; |
712 | converter.addresseeToVCard( a, vcard ); | 718 | converter.addresseeToVCard( a, vcard ); |
713 | int start = 0; | 719 | int start = 0; |
714 | int next; | 720 | int next; |
715 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 721 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
716 | int semi = vcard.find(";", next); | 722 | int semi = vcard.find(";", next); |
717 | int dopp = vcard.find(":", next); | 723 | int dopp = vcard.find(":", next); |
718 | int sep; | 724 | int sep; |
719 | if ( semi < dopp && semi >= 0 ) | 725 | if ( semi < dopp && semi >= 0 ) |
720 | sep = semi ; | 726 | sep = semi ; |
721 | else | 727 | else |
722 | sep = dopp; | 728 | sep = dopp; |
723 | vcardnew +=vcard.mid( start, next - start); | 729 | vcardnew +=vcard.mid( start, next - start); |
724 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); | 730 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); |
725 | start = sep; | 731 | start = sep; |
726 | } | 732 | } |
727 | vcardnew += vcard.mid( start,vcard.length() ); | 733 | vcardnew += vcard.mid( start,vcard.length() ); |
728 | vcard = ""; | 734 | vcard = ""; |
729 | start = 0; | 735 | start = 0; |
730 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { | 736 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { |
731 | int sep = vcardnew.find(":", next); | 737 | int sep = vcardnew.find(":", next); |
732 | vcard +=vcardnew.mid( start, next - start+3); | 738 | vcard +=vcardnew.mid( start, next - start+3); |
733 | start = sep; | 739 | start = sep; |
734 | } | 740 | } |
735 | vcard += vcardnew.mid( start,vcardnew.length() ); | 741 | vcard += vcardnew.mid( start,vcardnew.length() ); |
736 | vcard.replace ( QRegExp(";;;") , "" ); | 742 | vcard.replace ( QRegExp(";;;") , "" ); |
737 | vcard.replace ( QRegExp(";;") , "" ); | 743 | vcard.replace ( QRegExp(";;") , "" ); |
738 | datastream += vcard; | 744 | datastream += vcard; |
739 | 745 | ||
740 | } | 746 | } |
741 | QFile outFile(fileName); | 747 | QFile outFile(fileName); |
742 | if ( outFile.open(IO_WriteOnly) ) { | 748 | if ( outFile.open(IO_WriteOnly) ) { |
743 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 749 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
744 | QTextStream t( &outFile ); // use a text stream | 750 | QTextStream t( &outFile ); // use a text stream |
745 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 751 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
746 | t <<datastream; | 752 | t <<datastream; |
747 | outFile.close(); | 753 | outFile.close(); |
748 | if ( PhoneAccess::writeToPhone( fileName ) ) | 754 | if ( PhoneAccess::writeToPhone( fileName ) ) |
749 | qDebug("Export okay "); | 755 | qDebug("Export okay "); |
750 | else | 756 | else |
751 | qDebug("Error export contacts "); | 757 | qDebug("Error export contacts "); |
752 | 758 | ||
753 | } else { | 759 | } else { |
754 | qDebug("Error open temp file "); | 760 | qDebug("Error open temp file "); |
755 | return; | 761 | return; |
756 | } | 762 | } |
757 | 763 | ||
758 | 764 | ||
759 | #if 0 | 765 | #if 0 |
760 | 766 | ||
761 | setCaption( i18n("Writing to phone...")); | 767 | setCaption( i18n("Writing to phone...")); |
762 | if ( PhoneFormat::writeToPhone( cal ) ) | 768 | if ( PhoneFormat::writeToPhone( cal ) ) |
763 | setCaption( i18n("Export to phone successful!")); | 769 | setCaption( i18n("Export to phone successful!")); |
764 | else | 770 | else |
765 | setCaption( i18n("Error exporting to phone!")); | 771 | setCaption( i18n("Error exporting to phone!")); |
766 | #endif | 772 | #endif |
767 | 773 | ||
768 | 774 | ||
769 | } | 775 | } |
770 | void KABCore::beamVCard() | 776 | void KABCore::beamVCard() |
771 | { | 777 | { |
772 | QStringList uids = mViewManager->selectedUids(); | 778 | QStringList uids = mViewManager->selectedUids(); |
773 | if ( !uids.isEmpty() ) | 779 | if ( !uids.isEmpty() ) |
774 | beamVCard( uids ); | 780 | beamVCard( uids ); |
775 | } | 781 | } |
776 | 782 | ||
777 | 783 | ||
778 | void KABCore::beamVCard(const QStringList& uids) | 784 | void KABCore::beamVCard(const QStringList& uids) |
779 | { | 785 | { |
780 | /*US | 786 | /*US |
781 | QString beamFilename; | 787 | QString beamFilename; |
782 | Opie::OPimContact c; | 788 | Opie::OPimContact c; |
783 | if ( actionPersonal->isOn() ) { | 789 | if ( actionPersonal->isOn() ) { |
784 | beamFilename = addressbookPersonalVCardName(); | 790 | beamFilename = addressbookPersonalVCardName(); |
785 | if ( !QFile::exists( beamFilename ) ) | 791 | if ( !QFile::exists( beamFilename ) ) |
786 | return; // can't beam a non-existent file | 792 | return; // can't beam a non-existent file |
787 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 793 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
788 | beamFilename ); | 794 | beamFilename ); |
789 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 795 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
790 | Opie::OPimContactAccess::List allList = access->allRecords(); | 796 | Opie::OPimContactAccess::List allList = access->allRecords(); |
791 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 797 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
792 | c = *it; | 798 | c = *it; |
793 | 799 | ||
794 | delete access; | 800 | delete access; |
795 | } else { | 801 | } else { |
796 | unlink( beamfile ); // delete if exists | 802 | unlink( beamfile ); // delete if exists |
797 | mkdir("/tmp/obex/", 0755); | 803 | mkdir("/tmp/obex/", 0755); |
798 | c = m_abView -> currentEntry(); | 804 | c = m_abView -> currentEntry(); |
799 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 805 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
800 | beamfile ); | 806 | beamfile ); |
801 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 807 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
802 | access->add( c ); | 808 | access->add( c ); |
803 | access->save(); | 809 | access->save(); |
804 | delete access; | 810 | delete access; |
805 | 811 | ||
806 | beamFilename = beamfile; | 812 | beamFilename = beamfile; |
807 | } | 813 | } |
808 | 814 | ||
809 | owarn << "Beaming: " << beamFilename << oendl; | 815 | owarn << "Beaming: " << beamFilename << oendl; |
810 | */ | 816 | */ |
811 | 817 | ||
812 | #if 0 | 818 | #if 0 |
813 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 819 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
814 | 820 | ||
815 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 821 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
816 | 822 | ||
817 | QString name = "contact.vcf"; | 823 | QString name = "contact.vcf"; |
818 | 824 | ||
819 | QString fileName = dirName + "/" + name; | 825 | QString fileName = dirName + "/" + name; |
820 | #endif | 826 | #endif |
821 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 827 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
822 | // | 828 | // |
823 | QString fileName = "/tmp/kapibeamfile.vcf"; | 829 | QString fileName = "/tmp/kapibeamfile.vcf"; |
824 | 830 | ||
825 | 831 | ||
826 | //QDir().mkdir( dirName, true ); | 832 | //QDir().mkdir( dirName, true ); |
827 | 833 | ||
828 | 834 | ||
829 | KABC::VCardConverter converter; | 835 | KABC::VCardConverter converter; |
830 | QString description; | 836 | QString description; |
831 | QString datastream; | 837 | QString datastream; |
832 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 838 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
833 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 839 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
834 | 840 | ||
835 | if ( a.isEmpty() ) | 841 | if ( a.isEmpty() ) |
836 | continue; | 842 | continue; |
837 | 843 | ||
838 | if (description.isEmpty()) | 844 | if (description.isEmpty()) |
839 | description = a.formattedName(); | 845 | description = a.formattedName(); |
840 | 846 | ||
841 | QString vcard; | 847 | QString vcard; |
842 | converter.addresseeToVCard( a, vcard ); | 848 | converter.addresseeToVCard( a, vcard ); |
843 | int start = 0; | 849 | int start = 0; |
844 | int next; | 850 | int next; |
845 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 851 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
846 | int semi = vcard.find(";", next); | 852 | int semi = vcard.find(";", next); |
847 | int dopp = vcard.find(":", next); | 853 | int dopp = vcard.find(":", next); |
848 | int sep; | 854 | int sep; |
849 | if ( semi < dopp && semi >= 0 ) | 855 | if ( semi < dopp && semi >= 0 ) |
850 | sep = semi ; | 856 | sep = semi ; |
851 | else | 857 | else |
852 | sep = dopp; | 858 | sep = dopp; |
853 | datastream +=vcard.mid( start, next - start); | 859 | datastream +=vcard.mid( start, next - start); |
854 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 860 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
855 | start = sep; | 861 | start = sep; |
856 | } | 862 | } |
857 | datastream += vcard.mid( start,vcard.length() ); | 863 | datastream += vcard.mid( start,vcard.length() ); |
858 | } | 864 | } |
859 | #ifndef DESKTOP_VERSION | 865 | #ifndef DESKTOP_VERSION |
860 | QFile outFile(fileName); | 866 | QFile outFile(fileName); |
861 | if ( outFile.open(IO_WriteOnly) ) { | 867 | if ( outFile.open(IO_WriteOnly) ) { |
862 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 868 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
863 | QTextStream t( &outFile ); // use a text stream | 869 | QTextStream t( &outFile ); // use a text stream |
864 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 870 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
865 | t <<datastream; | 871 | t <<datastream; |
866 | outFile.close(); | 872 | outFile.close(); |
867 | Ir *ir = new Ir( this ); | 873 | Ir *ir = new Ir( this ); |
868 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 874 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
869 | ir->send( fileName, description, "text/x-vCard" ); | 875 | ir->send( fileName, description, "text/x-vCard" ); |
870 | } else { | 876 | } else { |
871 | qDebug("Error open temp beam file "); | 877 | qDebug("Error open temp beam file "); |
872 | return; | 878 | return; |
873 | } | 879 | } |
874 | #endif | 880 | #endif |
875 | 881 | ||
876 | } | 882 | } |
877 | 883 | ||
878 | void KABCore::beamDone( Ir *ir ) | 884 | void KABCore::beamDone( Ir *ir ) |
879 | { | 885 | { |
880 | #ifndef DESKTOP_VERSION | 886 | #ifndef DESKTOP_VERSION |
881 | delete ir; | 887 | delete ir; |
882 | #endif | 888 | #endif |
883 | } | 889 | } |
884 | 890 | ||
885 | 891 | ||
886 | void KABCore::browse( const QString& url ) | 892 | void KABCore::browse( const QString& url ) |
887 | { | 893 | { |
888 | #ifndef KAB_EMBEDDED | 894 | #ifndef KAB_EMBEDDED |
889 | kapp->invokeBrowser( url ); | 895 | kapp->invokeBrowser( url ); |
890 | #else //KAB_EMBEDDED | 896 | #else //KAB_EMBEDDED |
891 | qDebug("KABCore::browse must be fixed"); | 897 | qDebug("KABCore::browse must be fixed"); |
892 | #endif //KAB_EMBEDDED | 898 | #endif //KAB_EMBEDDED |
893 | } | 899 | } |
894 | 900 | ||
895 | void KABCore::selectAllContacts() | 901 | void KABCore::selectAllContacts() |
896 | { | 902 | { |
897 | mViewManager->setSelected( QString::null, true ); | 903 | mViewManager->setSelected( QString::null, true ); |
898 | } | 904 | } |
899 | 905 | ||
900 | void KABCore::deleteContacts() | 906 | void KABCore::deleteContacts() |
901 | { | 907 | { |
902 | QStringList uidList = mViewManager->selectedUids(); | 908 | QStringList uidList = mViewManager->selectedUids(); |
903 | deleteContacts( uidList ); | 909 | deleteContacts( uidList ); |
904 | } | 910 | } |
905 | 911 | ||
906 | void KABCore::deleteContacts( const QStringList &uids ) | 912 | void KABCore::deleteContacts( const QStringList &uids ) |
907 | { | 913 | { |
908 | if ( uids.count() > 0 ) { | 914 | if ( uids.count() > 0 ) { |
909 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 915 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
910 | UndoStack::instance()->push( command ); | 916 | UndoStack::instance()->push( command ); |
911 | RedoStack::instance()->clear(); | 917 | RedoStack::instance()->clear(); |
912 | 918 | ||
913 | // now if we deleted anything, refresh | 919 | // now if we deleted anything, refresh |
914 | setContactSelected( QString::null ); | 920 | setContactSelected( QString::null ); |
915 | setModified( true ); | 921 | setModified( true ); |
916 | } | 922 | } |
917 | } | 923 | } |
918 | 924 | ||
919 | void KABCore::copyContacts() | 925 | void KABCore::copyContacts() |
920 | { | 926 | { |
921 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 927 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
922 | 928 | ||
923 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 929 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
924 | 930 | ||
925 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 931 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
926 | 932 | ||
927 | QClipboard *cb = QApplication::clipboard(); | 933 | QClipboard *cb = QApplication::clipboard(); |
928 | cb->setText( clipText ); | 934 | cb->setText( clipText ); |
929 | } | 935 | } |
930 | 936 | ||
931 | void KABCore::cutContacts() | 937 | void KABCore::cutContacts() |
932 | { | 938 | { |
933 | QStringList uidList = mViewManager->selectedUids(); | 939 | QStringList uidList = mViewManager->selectedUids(); |
934 | 940 | ||
935 | //US if ( uidList.size() > 0 ) { | 941 | //US if ( uidList.size() > 0 ) { |
936 | if ( uidList.count() > 0 ) { | 942 | if ( uidList.count() > 0 ) { |
937 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 943 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
938 | UndoStack::instance()->push( command ); | 944 | UndoStack::instance()->push( command ); |
939 | RedoStack::instance()->clear(); | 945 | RedoStack::instance()->clear(); |
940 | 946 | ||
941 | setModified( true ); | 947 | setModified( true ); |
942 | } | 948 | } |
943 | } | 949 | } |
944 | 950 | ||
945 | void KABCore::pasteContacts() | 951 | void KABCore::pasteContacts() |
946 | { | 952 | { |
947 | QClipboard *cb = QApplication::clipboard(); | 953 | QClipboard *cb = QApplication::clipboard(); |
948 | 954 | ||
949 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 955 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
950 | 956 | ||
951 | pasteContacts( list ); | 957 | pasteContacts( list ); |
952 | } | 958 | } |
953 | 959 | ||
954 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 960 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
955 | { | 961 | { |
956 | KABC::Resource *resource = requestResource( this ); | 962 | KABC::Resource *resource = requestResource( this ); |
957 | KABC::Addressee::List::Iterator it; | 963 | KABC::Addressee::List::Iterator it; |
958 | for ( it = list.begin(); it != list.end(); ++it ) | 964 | for ( it = list.begin(); it != list.end(); ++it ) |
959 | (*it).setResource( resource ); | 965 | (*it).setResource( resource ); |
960 | 966 | ||
961 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 967 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
962 | UndoStack::instance()->push( command ); | 968 | UndoStack::instance()->push( command ); |
963 | RedoStack::instance()->clear(); | 969 | RedoStack::instance()->clear(); |
964 | 970 | ||
965 | setModified( true ); | 971 | setModified( true ); |
966 | } | 972 | } |
967 | 973 | ||
968 | void KABCore::setWhoAmI() | 974 | void KABCore::setWhoAmI() |
969 | { | 975 | { |
970 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 976 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
971 | 977 | ||
972 | if ( addrList.count() > 1 ) { | 978 | if ( addrList.count() > 1 ) { |
973 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 979 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
974 | return; | 980 | return; |
975 | } | 981 | } |
976 | 982 | ||
977 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 983 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
978 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 984 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
979 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 985 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
980 | } | 986 | } |
981 | 987 | ||
982 | void KABCore::setCategories() | 988 | void KABCore::setCategories() |
983 | { | 989 | { |
984 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 990 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
985 | if ( !dlg.exec() ) | 991 | if ( !dlg.exec() ) |
986 | return; | 992 | return; |
987 | 993 | ||
988 | bool merge = false; | 994 | bool merge = false; |
989 | QString msg = i18n( "Merge with existing categories?" ); | 995 | QString msg = i18n( "Merge with existing categories?" ); |
990 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 996 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
991 | merge = true; | 997 | merge = true; |
992 | 998 | ||
993 | QStringList categories = dlg.selectedCategories(); | 999 | QStringList categories = dlg.selectedCategories(); |
994 | 1000 | ||
995 | QStringList uids = mViewManager->selectedUids(); | 1001 | QStringList uids = mViewManager->selectedUids(); |
996 | QStringList::Iterator it; | 1002 | QStringList::Iterator it; |
997 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1003 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
998 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1004 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
999 | if ( !addr.isEmpty() ) { | 1005 | if ( !addr.isEmpty() ) { |
1000 | if ( !merge ) | 1006 | if ( !merge ) |
1001 | addr.setCategories( categories ); | 1007 | addr.setCategories( categories ); |
1002 | else { | 1008 | else { |
1003 | QStringList addrCategories = addr.categories(); | 1009 | QStringList addrCategories = addr.categories(); |
1004 | QStringList::Iterator catIt; | 1010 | QStringList::Iterator catIt; |
1005 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1011 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1006 | if ( !addrCategories.contains( *catIt ) ) | 1012 | if ( !addrCategories.contains( *catIt ) ) |
1007 | addrCategories.append( *catIt ); | 1013 | addrCategories.append( *catIt ); |
1008 | } | 1014 | } |
1009 | addr.setCategories( addrCategories ); | 1015 | addr.setCategories( addrCategories ); |
1010 | } | 1016 | } |
1011 | 1017 | ||
1012 | mAddressBook->insertAddressee( addr ); | 1018 | mAddressBook->insertAddressee( addr ); |
1013 | } | 1019 | } |
1014 | } | 1020 | } |
1015 | 1021 | ||
1016 | if ( uids.count() > 0 ) | 1022 | if ( uids.count() > 0 ) |
1017 | setModified( true ); | 1023 | setModified( true ); |
1018 | } | 1024 | } |
1019 | 1025 | ||
1020 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1026 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1021 | { | 1027 | { |
1022 | mIncSearchWidget->setFields( fields ); | 1028 | mIncSearchWidget->setFields( fields ); |
1023 | } | 1029 | } |
1024 | 1030 | ||
1025 | void KABCore::incrementalSearch( const QString& text ) | 1031 | void KABCore::incrementalSearch( const QString& text ) |
1026 | { | 1032 | { |
1027 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1033 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1028 | } | 1034 | } |
1029 | 1035 | ||
1030 | void KABCore::setModified() | 1036 | void KABCore::setModified() |
1031 | { | 1037 | { |
1032 | setModified( true ); | 1038 | setModified( true ); |
1033 | } | 1039 | } |
1034 | 1040 | ||
1035 | void KABCore::setModifiedWOrefresh() | 1041 | void KABCore::setModifiedWOrefresh() |
1036 | { | 1042 | { |
1037 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1043 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1038 | mModified = true; | 1044 | mModified = true; |
1039 | mActionSave->setEnabled( mModified ); | 1045 | mActionSave->setEnabled( mModified ); |
1040 | #ifdef DESKTOP_VERSION | 1046 | #ifdef DESKTOP_VERSION |
1041 | mDetails->refreshView(); | 1047 | mDetails->refreshView(); |
1042 | #endif | 1048 | #endif |
1043 | 1049 | ||
1044 | } | 1050 | } |
1045 | void KABCore::setModified( bool modified ) | 1051 | void KABCore::setModified( bool modified ) |
1046 | { | 1052 | { |
1047 | mModified = modified; | 1053 | mModified = modified; |
1048 | mActionSave->setEnabled( mModified ); | 1054 | mActionSave->setEnabled( mModified ); |
1049 | 1055 | ||
1050 | if ( modified ) | 1056 | if ( modified ) |
1051 | mJumpButtonBar->recreateButtons(); | 1057 | mJumpButtonBar->recreateButtons(); |
1052 | 1058 | ||
1053 | mViewManager->refreshView(); | 1059 | mViewManager->refreshView(); |
1054 | mDetails->refreshView(); | 1060 | mDetails->refreshView(); |
1055 | 1061 | ||
1056 | } | 1062 | } |
1057 | 1063 | ||
1058 | bool KABCore::modified() const | 1064 | bool KABCore::modified() const |
1059 | { | 1065 | { |
1060 | return mModified; | 1066 | return mModified; |
1061 | } | 1067 | } |
1062 | 1068 | ||
1063 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1069 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1064 | { | 1070 | { |
1065 | 1071 | ||
1066 | Command *command = 0; | 1072 | Command *command = 0; |
1067 | QString uid; | 1073 | QString uid; |
1068 | 1074 | ||
1069 | // check if it exists already | 1075 | // check if it exists already |
1070 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1076 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1071 | if ( origAddr.isEmpty() ) | 1077 | if ( origAddr.isEmpty() ) |
1072 | command = new PwNewCommand( mAddressBook, addr ); | 1078 | command = new PwNewCommand( mAddressBook, addr ); |
1073 | else { | 1079 | else { |
1074 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1080 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1075 | uid = addr.uid(); | 1081 | uid = addr.uid(); |
1076 | } | 1082 | } |
1077 | 1083 | ||
1078 | UndoStack::instance()->push( command ); | 1084 | UndoStack::instance()->push( command ); |
1079 | RedoStack::instance()->clear(); | 1085 | RedoStack::instance()->clear(); |
1080 | 1086 | ||
1081 | setModified( true ); | 1087 | setModified( true ); |
1082 | } | 1088 | } |
1083 | 1089 | ||
1084 | void KABCore::newContact() | 1090 | void KABCore::newContact() |
1085 | { | 1091 | { |
1086 | 1092 | ||
1087 | 1093 | ||
1088 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1094 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1089 | 1095 | ||
1090 | QPtrList<KRES::Resource> kresResources; | 1096 | QPtrList<KRES::Resource> kresResources; |
1091 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1097 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1092 | KABC::Resource *resource; | 1098 | KABC::Resource *resource; |
1093 | while ( ( resource = it.current() ) != 0 ) { | 1099 | while ( ( resource = it.current() ) != 0 ) { |
1094 | ++it; | 1100 | ++it; |
1095 | if ( !resource->readOnly() ) { | 1101 | if ( !resource->readOnly() ) { |
@@ -1321,1550 +1327,1538 @@ void KABCore::setDetailsVisible( bool visible ) | |||
1321 | if (visible && mDetails->isHidden()) | 1327 | if (visible && mDetails->isHidden()) |
1322 | { | 1328 | { |
1323 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1329 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1324 | if ( addrList.count() > 0 ) | 1330 | if ( addrList.count() > 0 ) |
1325 | mDetails->setAddressee( addrList[ 0 ] ); | 1331 | mDetails->setAddressee( addrList[ 0 ] ); |
1326 | } | 1332 | } |
1327 | 1333 | ||
1328 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1334 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1329 | // the listview and the detailview. We do that by changing the splitbar size. | 1335 | // the listview and the detailview. We do that by changing the splitbar size. |
1330 | if (mMultipleViewsAtOnce) | 1336 | if (mMultipleViewsAtOnce) |
1331 | { | 1337 | { |
1332 | if ( visible ) | 1338 | if ( visible ) |
1333 | mDetails->show(); | 1339 | mDetails->show(); |
1334 | else | 1340 | else |
1335 | mDetails->hide(); | 1341 | mDetails->hide(); |
1336 | } | 1342 | } |
1337 | else | 1343 | else |
1338 | { | 1344 | { |
1339 | if ( visible ) { | 1345 | if ( visible ) { |
1340 | mViewManager->hide(); | 1346 | mViewManager->hide(); |
1341 | mDetails->show(); | 1347 | mDetails->show(); |
1342 | } | 1348 | } |
1343 | else { | 1349 | else { |
1344 | mViewManager->show(); | 1350 | mViewManager->show(); |
1345 | mDetails->hide(); | 1351 | mDetails->hide(); |
1346 | } | 1352 | } |
1347 | setJumpButtonBarVisible( !visible ); | 1353 | setJumpButtonBarVisible( !visible ); |
1348 | } | 1354 | } |
1349 | 1355 | ||
1350 | } | 1356 | } |
1351 | 1357 | ||
1352 | void KABCore::extensionChanged( int id ) | 1358 | void KABCore::extensionChanged( int id ) |
1353 | { | 1359 | { |
1354 | //change the details view only for non desktop systems | 1360 | //change the details view only for non desktop systems |
1355 | #ifndef DESKTOP_VERSION | 1361 | #ifndef DESKTOP_VERSION |
1356 | 1362 | ||
1357 | if (id == 0) | 1363 | if (id == 0) |
1358 | { | 1364 | { |
1359 | //the user disabled the extension. | 1365 | //the user disabled the extension. |
1360 | 1366 | ||
1361 | if (mMultipleViewsAtOnce) | 1367 | if (mMultipleViewsAtOnce) |
1362 | { // enable detailsview again | 1368 | { // enable detailsview again |
1363 | setDetailsVisible( true ); | 1369 | setDetailsVisible( true ); |
1364 | mActionDetails->setChecked( true ); | 1370 | mActionDetails->setChecked( true ); |
1365 | } | 1371 | } |
1366 | else | 1372 | else |
1367 | { //go back to the listview | 1373 | { //go back to the listview |
1368 | setDetailsVisible( false ); | 1374 | setDetailsVisible( false ); |
1369 | mActionDetails->setChecked( false ); | 1375 | mActionDetails->setChecked( false ); |
1370 | mActionDetails->setEnabled(true); | 1376 | mActionDetails->setEnabled(true); |
1371 | } | 1377 | } |
1372 | 1378 | ||
1373 | } | 1379 | } |
1374 | else | 1380 | else |
1375 | { | 1381 | { |
1376 | //the user enabled the extension. | 1382 | //the user enabled the extension. |
1377 | setDetailsVisible( false ); | 1383 | setDetailsVisible( false ); |
1378 | mActionDetails->setChecked( false ); | 1384 | mActionDetails->setChecked( false ); |
1379 | 1385 | ||
1380 | if (!mMultipleViewsAtOnce) | 1386 | if (!mMultipleViewsAtOnce) |
1381 | { | 1387 | { |
1382 | mActionDetails->setEnabled(false); | 1388 | mActionDetails->setEnabled(false); |
1383 | } | 1389 | } |
1384 | 1390 | ||
1385 | mExtensionManager->setSelectionChanged(); | 1391 | mExtensionManager->setSelectionChanged(); |
1386 | 1392 | ||
1387 | } | 1393 | } |
1388 | 1394 | ||
1389 | #endif// DESKTOP_VERSION | 1395 | #endif// DESKTOP_VERSION |
1390 | 1396 | ||
1391 | } | 1397 | } |
1392 | 1398 | ||
1393 | 1399 | ||
1394 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1400 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1395 | { | 1401 | { |
1396 | 1402 | ||
1397 | if ( list.count() != 0 ) { | 1403 | if ( list.count() != 0 ) { |
1398 | KABC::Addressee::List::ConstIterator it; | 1404 | KABC::Addressee::List::ConstIterator it; |
1399 | for ( it = list.begin(); it != list.end(); ++it ) | 1405 | for ( it = list.begin(); it != list.end(); ++it ) |
1400 | mAddressBook->insertAddressee( *it ); | 1406 | mAddressBook->insertAddressee( *it ); |
1401 | if ( list.count() > 1 ) | 1407 | if ( list.count() > 1 ) |
1402 | setModified(); | 1408 | setModified(); |
1403 | else | 1409 | else |
1404 | setModifiedWOrefresh(); | 1410 | setModifiedWOrefresh(); |
1405 | } | 1411 | } |
1406 | if ( list.count() == 0 ) | 1412 | if ( list.count() == 0 ) |
1407 | mViewManager->refreshView(); | 1413 | mViewManager->refreshView(); |
1408 | else | 1414 | else |
1409 | mViewManager->refreshView( list[ 0 ].uid() ); | 1415 | mViewManager->refreshView( list[ 0 ].uid() ); |
1410 | 1416 | ||
1411 | 1417 | ||
1412 | 1418 | ||
1413 | } | 1419 | } |
1414 | 1420 | ||
1415 | QString KABCore::getNameByPhone( const QString &phone ) | 1421 | QString KABCore::getNameByPhone( const QString &phone ) |
1416 | { | 1422 | { |
1417 | #ifndef KAB_EMBEDDED | 1423 | #ifndef KAB_EMBEDDED |
1418 | QRegExp r( "[/*/-/ ]" ); | 1424 | QRegExp r( "[/*/-/ ]" ); |
1419 | QString localPhone( phone ); | 1425 | QString localPhone( phone ); |
1420 | 1426 | ||
1421 | bool found = false; | 1427 | bool found = false; |
1422 | QString ownerName = ""; | 1428 | QString ownerName = ""; |
1423 | KABC::AddressBook::Iterator iter; | 1429 | KABC::AddressBook::Iterator iter; |
1424 | KABC::PhoneNumber::List::Iterator phoneIter; | 1430 | KABC::PhoneNumber::List::Iterator phoneIter; |
1425 | KABC::PhoneNumber::List phoneList; | 1431 | KABC::PhoneNumber::List phoneList; |
1426 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1432 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1427 | phoneList = (*iter).phoneNumbers(); | 1433 | phoneList = (*iter).phoneNumbers(); |
1428 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1434 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1429 | ++phoneIter) { | 1435 | ++phoneIter) { |
1430 | // Get rid of separator chars so just the numbers are compared. | 1436 | // Get rid of separator chars so just the numbers are compared. |
1431 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1437 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1432 | ownerName = (*iter).formattedName(); | 1438 | ownerName = (*iter).formattedName(); |
1433 | found = true; | 1439 | found = true; |
1434 | } | 1440 | } |
1435 | } | 1441 | } |
1436 | } | 1442 | } |
1437 | 1443 | ||
1438 | return ownerName; | 1444 | return ownerName; |
1439 | #else //KAB_EMBEDDED | 1445 | #else //KAB_EMBEDDED |
1440 | qDebug("KABCore::getNameByPhone finsih method"); | 1446 | qDebug("KABCore::getNameByPhone finsih method"); |
1441 | return ""; | 1447 | return ""; |
1442 | #endif //KAB_EMBEDDED | 1448 | #endif //KAB_EMBEDDED |
1443 | 1449 | ||
1444 | } | 1450 | } |
1445 | 1451 | ||
1446 | void KABCore::openConfigDialog() | 1452 | void KABCore::openConfigDialog() |
1447 | { | 1453 | { |
1448 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1454 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1449 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1455 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1450 | ConfigureDialog->addModule(kabcfg ); | 1456 | ConfigureDialog->addModule(kabcfg ); |
1451 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1457 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1452 | ConfigureDialog->addModule(kdelibcfg ); | 1458 | ConfigureDialog->addModule(kdelibcfg ); |
1453 | 1459 | ||
1454 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1460 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1455 | this, SLOT( configurationChanged() ) ); | 1461 | this, SLOT( configurationChanged() ) ); |
1456 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1462 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1457 | this, SLOT( configurationChanged() ) ); | 1463 | this, SLOT( configurationChanged() ) ); |
1458 | saveSettings(); | 1464 | saveSettings(); |
1459 | #ifndef DESKTOP_VERSION | 1465 | #ifndef DESKTOP_VERSION |
1460 | ConfigureDialog->showMaximized(); | 1466 | ConfigureDialog->showMaximized(); |
1461 | #endif | 1467 | #endif |
1462 | if ( ConfigureDialog->exec() ) | 1468 | if ( ConfigureDialog->exec() ) |
1463 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1469 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1464 | delete ConfigureDialog; | 1470 | delete ConfigureDialog; |
1465 | } | 1471 | } |
1466 | 1472 | ||
1467 | void KABCore::openLDAPDialog() | 1473 | void KABCore::openLDAPDialog() |
1468 | { | 1474 | { |
1469 | #ifndef KAB_EMBEDDED | 1475 | #ifndef KAB_EMBEDDED |
1470 | if ( !mLdapSearchDialog ) { | 1476 | if ( !mLdapSearchDialog ) { |
1471 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1477 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1472 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1478 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1473 | SLOT( refreshView() ) ); | 1479 | SLOT( refreshView() ) ); |
1474 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1480 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1475 | SLOT( setModified() ) ); | 1481 | SLOT( setModified() ) ); |
1476 | } else | 1482 | } else |
1477 | mLdapSearchDialog->restoreSettings(); | 1483 | mLdapSearchDialog->restoreSettings(); |
1478 | 1484 | ||
1479 | if ( mLdapSearchDialog->isOK() ) | 1485 | if ( mLdapSearchDialog->isOK() ) |
1480 | mLdapSearchDialog->exec(); | 1486 | mLdapSearchDialog->exec(); |
1481 | #else //KAB_EMBEDDED | 1487 | #else //KAB_EMBEDDED |
1482 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1488 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1483 | #endif //KAB_EMBEDDED | 1489 | #endif //KAB_EMBEDDED |
1484 | } | 1490 | } |
1485 | 1491 | ||
1486 | void KABCore::print() | 1492 | void KABCore::print() |
1487 | { | 1493 | { |
1488 | #ifndef KAB_EMBEDDED | 1494 | #ifndef KAB_EMBEDDED |
1489 | KPrinter printer; | 1495 | KPrinter printer; |
1490 | if ( !printer.setup( this ) ) | 1496 | if ( !printer.setup( this ) ) |
1491 | return; | 1497 | return; |
1492 | 1498 | ||
1493 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1499 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1494 | mViewManager->selectedUids(), this ); | 1500 | mViewManager->selectedUids(), this ); |
1495 | 1501 | ||
1496 | wizard.exec(); | 1502 | wizard.exec(); |
1497 | #else //KAB_EMBEDDED | 1503 | #else //KAB_EMBEDDED |
1498 | qDebug("KABCore::print() finsih method"); | 1504 | qDebug("KABCore::print() finsih method"); |
1499 | #endif //KAB_EMBEDDED | 1505 | #endif //KAB_EMBEDDED |
1500 | 1506 | ||
1501 | } | 1507 | } |
1502 | 1508 | ||
1503 | 1509 | ||
1504 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1510 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1505 | { | 1511 | { |
1506 | if ( mGUIClient ) | 1512 | if ( mGUIClient ) |
1507 | mGUIClient->insertChildClient( client ); | 1513 | mGUIClient->insertChildClient( client ); |
1508 | else | 1514 | else |
1509 | KMessageBox::error( this, "no KXMLGUICLient"); | 1515 | KMessageBox::error( this, "no KXMLGUICLient"); |
1510 | } | 1516 | } |
1511 | 1517 | ||
1512 | 1518 | ||
1513 | void KABCore::configurationChanged() | 1519 | void KABCore::configurationChanged() |
1514 | { | 1520 | { |
1515 | mExtensionManager->reconfigure(); | 1521 | mExtensionManager->reconfigure(); |
1516 | } | 1522 | } |
1517 | 1523 | ||
1518 | void KABCore::addressBookChanged() | 1524 | void KABCore::addressBookChanged() |
1519 | { | 1525 | { |
1520 | /*US | 1526 | /*US |
1521 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1527 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1522 | while ( it.current() ) { | 1528 | while ( it.current() ) { |
1523 | if ( it.current()->dirty() ) { | 1529 | if ( it.current()->dirty() ) { |
1524 | QString text = i18n( "Data has been changed externally. Unsaved " | 1530 | QString text = i18n( "Data has been changed externally. Unsaved " |
1525 | "changes will be lost." ); | 1531 | "changes will be lost." ); |
1526 | KMessageBox::information( this, text ); | 1532 | KMessageBox::information( this, text ); |
1527 | } | 1533 | } |
1528 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1534 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1529 | ++it; | 1535 | ++it; |
1530 | } | 1536 | } |
1531 | */ | 1537 | */ |
1532 | if (mEditorDialog) | 1538 | if (mEditorDialog) |
1533 | { | 1539 | { |
1534 | if (mEditorDialog->dirty()) | 1540 | if (mEditorDialog->dirty()) |
1535 | { | 1541 | { |
1536 | QString text = i18n( "Data has been changed externally. Unsaved " | 1542 | QString text = i18n( "Data has been changed externally. Unsaved " |
1537 | "changes will be lost." ); | 1543 | "changes will be lost." ); |
1538 | KMessageBox::information( this, text ); | 1544 | KMessageBox::information( this, text ); |
1539 | } | 1545 | } |
1540 | QString currentuid = mEditorDialog->addressee().uid(); | 1546 | QString currentuid = mEditorDialog->addressee().uid(); |
1541 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1547 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1542 | } | 1548 | } |
1543 | mViewManager->refreshView(); | 1549 | mViewManager->refreshView(); |
1544 | // mDetails->refreshView(); | 1550 | // mDetails->refreshView(); |
1545 | 1551 | ||
1546 | 1552 | ||
1547 | } | 1553 | } |
1548 | 1554 | ||
1549 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1555 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1550 | const char *name ) | 1556 | const char *name ) |
1551 | { | 1557 | { |
1552 | 1558 | ||
1553 | if ( mEditorDialog == 0 ) { | 1559 | if ( mEditorDialog == 0 ) { |
1554 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1560 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1555 | name ? name : "editorDialog" ); | 1561 | name ? name : "editorDialog" ); |
1556 | 1562 | ||
1557 | 1563 | ||
1558 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1564 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1559 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1565 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1560 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1566 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1561 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1567 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1562 | } | 1568 | } |
1563 | 1569 | ||
1564 | return mEditorDialog; | 1570 | return mEditorDialog; |
1565 | } | 1571 | } |
1566 | 1572 | ||
1567 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1573 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1568 | { | 1574 | { |
1569 | //mEditorDict.remove( uid ); | 1575 | //mEditorDict.remove( uid ); |
1570 | } | 1576 | } |
1571 | 1577 | ||
1572 | void KABCore::initGUI() | 1578 | void KABCore::initGUI() |
1573 | { | 1579 | { |
1574 | #ifndef KAB_EMBEDDED | 1580 | #ifndef KAB_EMBEDDED |
1575 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1581 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1576 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1582 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1577 | 1583 | ||
1578 | mExtensionBarSplitter = new QSplitter( this ); | 1584 | mExtensionBarSplitter = new QSplitter( this ); |
1579 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1585 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1580 | 1586 | ||
1581 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1587 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1582 | 1588 | ||
1583 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1589 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1584 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1590 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1585 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1591 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1586 | SLOT( incrementalSearch( const QString& ) ) ); | 1592 | SLOT( incrementalSearch( const QString& ) ) ); |
1587 | 1593 | ||
1588 | mViewManager = new ViewManager( this, viewSpace ); | 1594 | mViewManager = new ViewManager( this, viewSpace ); |
1589 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1595 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1590 | 1596 | ||
1591 | mDetails = new ViewContainer( mDetailsSplitter ); | 1597 | mDetails = new ViewContainer( mDetailsSplitter ); |
1592 | 1598 | ||
1593 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1599 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1594 | 1600 | ||
1595 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1601 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1596 | 1602 | ||
1597 | topLayout->addWidget( mExtensionBarSplitter ); | 1603 | topLayout->addWidget( mExtensionBarSplitter ); |
1598 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1604 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1599 | topLayout->addWidget( mJumpButtonBar ); | 1605 | topLayout->addWidget( mJumpButtonBar ); |
1600 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1606 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1601 | 1607 | ||
1602 | mXXPortManager = new XXPortManager( this, this ); | 1608 | mXXPortManager = new XXPortManager( this, this ); |
1603 | 1609 | ||
1604 | #else //KAB_EMBEDDED | 1610 | #else //KAB_EMBEDDED |
1605 | //US initialize viewMenu before settingup viewmanager. | 1611 | //US initialize viewMenu before settingup viewmanager. |
1606 | // Viewmanager needs this menu to plugin submenues. | 1612 | // Viewmanager needs this menu to plugin submenues. |
1607 | viewMenu = new QPopupMenu( this ); | 1613 | viewMenu = new QPopupMenu( this ); |
1608 | settingsMenu = new QPopupMenu( this ); | 1614 | settingsMenu = new QPopupMenu( this ); |
1609 | //filterMenu = new QPopupMenu( this ); | 1615 | //filterMenu = new QPopupMenu( this ); |
1610 | ImportMenu = new QPopupMenu( this ); | 1616 | ImportMenu = new QPopupMenu( this ); |
1611 | ExportMenu = new QPopupMenu( this ); | 1617 | ExportMenu = new QPopupMenu( this ); |
1612 | syncMenu = new QPopupMenu( this ); | 1618 | syncMenu = new QPopupMenu( this ); |
1613 | changeMenu= new QPopupMenu( this ); | 1619 | changeMenu= new QPopupMenu( this ); |
1614 | 1620 | ||
1615 | //US since we have no splitter for the embedded system, setup | 1621 | //US since we have no splitter for the embedded system, setup |
1616 | // a layout with two frames. One left and one right. | 1622 | // a layout with two frames. One left and one right. |
1617 | 1623 | ||
1618 | QBoxLayout *topLayout; | 1624 | QBoxLayout *topLayout; |
1619 | 1625 | ||
1620 | // = new QHBoxLayout( this ); | 1626 | // = new QHBoxLayout( this ); |
1621 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1627 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1622 | 1628 | ||
1623 | // QWidget *mainBox = new QWidget( this ); | 1629 | // QWidget *mainBox = new QWidget( this ); |
1624 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1630 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1625 | 1631 | ||
1626 | #ifdef DESKTOP_VERSION | 1632 | #ifdef DESKTOP_VERSION |
1627 | topLayout = new QHBoxLayout( this ); | 1633 | topLayout = new QHBoxLayout( this ); |
1628 | 1634 | ||
1629 | 1635 | ||
1630 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1636 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1631 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1637 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1632 | 1638 | ||
1633 | topLayout->addWidget(mMiniSplitter ); | 1639 | topLayout->addWidget(mMiniSplitter ); |
1634 | 1640 | ||
1635 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1641 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1636 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1642 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1637 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1643 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1638 | mDetails = new ViewContainer( mMiniSplitter ); | 1644 | mDetails = new ViewContainer( mMiniSplitter ); |
1639 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1645 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1640 | #else | 1646 | #else |
1641 | if ( QApplication::desktop()->width() > 480 ) { | 1647 | if ( QApplication::desktop()->width() > 480 ) { |
1642 | topLayout = new QHBoxLayout( this ); | 1648 | topLayout = new QHBoxLayout( this ); |
1643 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1649 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1644 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1650 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1645 | } else { | 1651 | } else { |
1646 | 1652 | ||
1647 | topLayout = new QHBoxLayout( this ); | 1653 | topLayout = new QHBoxLayout( this ); |
1648 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1654 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1649 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1655 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1650 | } | 1656 | } |
1651 | 1657 | ||
1652 | topLayout->addWidget(mMiniSplitter ); | 1658 | topLayout->addWidget(mMiniSplitter ); |
1653 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1659 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1654 | mDetails = new ViewContainer( mMiniSplitter ); | 1660 | mDetails = new ViewContainer( mMiniSplitter ); |
1655 | 1661 | ||
1656 | 1662 | ||
1657 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1663 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1658 | #endif | 1664 | #endif |
1659 | //eh->hide(); | 1665 | //eh->hide(); |
1660 | // topLayout->addWidget(mExtensionManager ); | 1666 | // topLayout->addWidget(mExtensionManager ); |
1661 | 1667 | ||
1662 | 1668 | ||
1663 | /*US | 1669 | /*US |
1664 | #ifndef KAB_NOSPLITTER | 1670 | #ifndef KAB_NOSPLITTER |
1665 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1671 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1666 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1672 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1667 | topLayout->setSpacing( 10 ); | 1673 | topLayout->setSpacing( 10 ); |
1668 | 1674 | ||
1669 | mDetailsSplitter = new QSplitter( this ); | 1675 | mDetailsSplitter = new QSplitter( this ); |
1670 | 1676 | ||
1671 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1677 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1672 | 1678 | ||
1673 | mViewManager = new ViewManager( this, viewSpace ); | 1679 | mViewManager = new ViewManager( this, viewSpace ); |
1674 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1680 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1675 | 1681 | ||
1676 | mDetails = new ViewContainer( mDetailsSplitter ); | 1682 | mDetails = new ViewContainer( mDetailsSplitter ); |
1677 | 1683 | ||
1678 | topLayout->addWidget( mDetailsSplitter ); | 1684 | topLayout->addWidget( mDetailsSplitter ); |
1679 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1685 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1680 | #else //KAB_NOSPLITTER | 1686 | #else //KAB_NOSPLITTER |
1681 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1687 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1682 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1688 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1683 | topLayout->setSpacing( 10 ); | 1689 | topLayout->setSpacing( 10 ); |
1684 | 1690 | ||
1685 | // mDetailsSplitter = new QSplitter( this ); | 1691 | // mDetailsSplitter = new QSplitter( this ); |
1686 | 1692 | ||
1687 | QVBox *viewSpace = new QVBox( this ); | 1693 | QVBox *viewSpace = new QVBox( this ); |
1688 | 1694 | ||
1689 | mViewManager = new ViewManager( this, viewSpace ); | 1695 | mViewManager = new ViewManager( this, viewSpace ); |
1690 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1696 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1691 | 1697 | ||
1692 | mDetails = new ViewContainer( this ); | 1698 | mDetails = new ViewContainer( this ); |
1693 | 1699 | ||
1694 | topLayout->addWidget( viewSpace ); | 1700 | topLayout->addWidget( viewSpace ); |
1695 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1701 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1696 | topLayout->addWidget( mDetails ); | 1702 | topLayout->addWidget( mDetails ); |
1697 | #endif //KAB_NOSPLITTER | 1703 | #endif //KAB_NOSPLITTER |
1698 | */ | 1704 | */ |
1699 | 1705 | ||
1700 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1706 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1701 | syncManager->setBlockSave(false); | 1707 | syncManager->setBlockSave(false); |
1702 | 1708 | ||
1703 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1709 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1704 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1710 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1705 | syncManager->setDefaultFileName( sentSyncFile()); | 1711 | syncManager->setDefaultFileName( sentSyncFile()); |
1706 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1712 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1707 | 1713 | ||
1708 | #endif //KAB_EMBEDDED | 1714 | #endif //KAB_EMBEDDED |
1709 | initActions(); | 1715 | initActions(); |
1710 | 1716 | ||
1711 | #ifdef KAB_EMBEDDED | 1717 | #ifdef KAB_EMBEDDED |
1712 | addActionsManually(); | 1718 | addActionsManually(); |
1713 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1719 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1714 | mXXPortManager = new XXPortManager( this, this ); | 1720 | mXXPortManager = new XXPortManager( this, this ); |
1715 | 1721 | ||
1716 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1722 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1717 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1723 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1718 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1724 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1719 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1725 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1720 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1726 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1721 | // mIncSearchWidget->hide(); | 1727 | // mIncSearchWidget->hide(); |
1722 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1728 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1723 | SLOT( incrementalSearch( const QString& ) ) ); | 1729 | SLOT( incrementalSearch( const QString& ) ) ); |
1724 | 1730 | ||
1725 | 1731 | ||
1726 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1732 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1727 | 1733 | ||
1728 | topLayout->addWidget( mJumpButtonBar ); | 1734 | topLayout->addWidget( mJumpButtonBar ); |
1729 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1735 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1730 | 1736 | ||
1731 | // mMainWindow->getIconToolBar()->raise(); | 1737 | // mMainWindow->getIconToolBar()->raise(); |
1732 | 1738 | ||
1733 | #endif //KAB_EMBEDDED | 1739 | #endif //KAB_EMBEDDED |
1734 | 1740 | ||
1735 | } | 1741 | } |
1736 | void KABCore::initActions() | 1742 | void KABCore::initActions() |
1737 | { | 1743 | { |
1738 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1744 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1739 | 1745 | ||
1740 | #ifndef KAB_EMBEDDED | 1746 | #ifndef KAB_EMBEDDED |
1741 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1747 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1742 | SLOT( clipboardDataChanged() ) ); | 1748 | SLOT( clipboardDataChanged() ) ); |
1743 | #endif //KAB_EMBEDDED | 1749 | #endif //KAB_EMBEDDED |
1744 | 1750 | ||
1745 | // file menu | 1751 | // file menu |
1746 | if ( mIsPart ) { | 1752 | if ( mIsPart ) { |
1747 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1753 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1748 | SLOT( sendMail() ), actionCollection(), | 1754 | SLOT( sendMail() ), actionCollection(), |
1749 | "kaddressbook_mail" ); | 1755 | "kaddressbook_mail" ); |
1750 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1756 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1751 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1757 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1752 | 1758 | ||
1753 | } else { | 1759 | } else { |
1754 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1760 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1755 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1761 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1756 | } | 1762 | } |
1757 | 1763 | ||
1758 | 1764 | ||
1759 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1765 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1760 | SLOT( save() ), actionCollection(), "file_sync" ); | 1766 | SLOT( save() ), actionCollection(), "file_sync" ); |
1761 | 1767 | ||
1762 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1768 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1763 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1769 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1764 | 1770 | ||
1765 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1771 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1766 | this, SLOT( mailVCard() ), | 1772 | this, SLOT( mailVCard() ), |
1767 | actionCollection(), "file_mail_vcard"); | 1773 | actionCollection(), "file_mail_vcard"); |
1768 | 1774 | ||
1769 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1775 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1770 | SLOT( export2phone() ), actionCollection(), | 1776 | SLOT( export2phone() ), actionCollection(), |
1771 | "kaddressbook_ex2phone" ); | 1777 | "kaddressbook_ex2phone" ); |
1772 | 1778 | ||
1773 | mActionBeamVCard = 0; | 1779 | mActionBeamVCard = 0; |
1774 | mActionBeam = 0; | 1780 | mActionBeam = 0; |
1775 | 1781 | ||
1776 | #ifndef DESKTOP_VERSION | 1782 | #ifndef DESKTOP_VERSION |
1777 | if ( Ir::supported() ) { | 1783 | if ( Ir::supported() ) { |
1778 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1784 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1779 | SLOT( beamVCard() ), actionCollection(), | 1785 | SLOT( beamVCard() ), actionCollection(), |
1780 | "kaddressbook_beam_vcard" ); | 1786 | "kaddressbook_beam_vcard" ); |
1781 | 1787 | ||
1782 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1788 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1783 | SLOT( beamMySelf() ), actionCollection(), | 1789 | SLOT( beamMySelf() ), actionCollection(), |
1784 | "kaddressbook_beam_myself" ); | 1790 | "kaddressbook_beam_myself" ); |
1785 | } | 1791 | } |
1786 | #endif | 1792 | #endif |
1787 | 1793 | ||
1788 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1794 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1789 | this, SLOT( editContact2() ), | 1795 | this, SLOT( editContact2() ), |
1790 | actionCollection(), "file_properties" ); | 1796 | actionCollection(), "file_properties" ); |
1791 | 1797 | ||
1792 | #ifdef KAB_EMBEDDED | 1798 | #ifdef KAB_EMBEDDED |
1793 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1799 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1794 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1800 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1795 | mMainWindow, SLOT( exit() ), | 1801 | mMainWindow, SLOT( exit() ), |
1796 | actionCollection(), "quit" ); | 1802 | actionCollection(), "quit" ); |
1797 | #endif //KAB_EMBEDDED | 1803 | #endif //KAB_EMBEDDED |
1798 | 1804 | ||
1799 | // edit menu | 1805 | // edit menu |
1800 | if ( mIsPart ) { | 1806 | if ( mIsPart ) { |
1801 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1807 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1802 | SLOT( copyContacts() ), actionCollection(), | 1808 | SLOT( copyContacts() ), actionCollection(), |
1803 | "kaddressbook_copy" ); | 1809 | "kaddressbook_copy" ); |
1804 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1810 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1805 | SLOT( cutContacts() ), actionCollection(), | 1811 | SLOT( cutContacts() ), actionCollection(), |
1806 | "kaddressbook_cut" ); | 1812 | "kaddressbook_cut" ); |
1807 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1813 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1808 | SLOT( pasteContacts() ), actionCollection(), | 1814 | SLOT( pasteContacts() ), actionCollection(), |
1809 | "kaddressbook_paste" ); | 1815 | "kaddressbook_paste" ); |
1810 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1816 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1811 | SLOT( selectAllContacts() ), actionCollection(), | 1817 | SLOT( selectAllContacts() ), actionCollection(), |
1812 | "kaddressbook_select_all" ); | 1818 | "kaddressbook_select_all" ); |
1813 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1819 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1814 | SLOT( undo() ), actionCollection(), | 1820 | SLOT( undo() ), actionCollection(), |
1815 | "kaddressbook_undo" ); | 1821 | "kaddressbook_undo" ); |
1816 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1822 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1817 | this, SLOT( redo() ), actionCollection(), | 1823 | this, SLOT( redo() ), actionCollection(), |
1818 | "kaddressbook_redo" ); | 1824 | "kaddressbook_redo" ); |
1819 | } else { | 1825 | } else { |
1820 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1826 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1821 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1827 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1822 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1828 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1823 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1829 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1824 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1830 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1825 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1831 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1826 | } | 1832 | } |
1827 | 1833 | ||
1828 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1834 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1829 | Key_Delete, this, SLOT( deleteContacts() ), | 1835 | Key_Delete, this, SLOT( deleteContacts() ), |
1830 | actionCollection(), "edit_delete" ); | 1836 | actionCollection(), "edit_delete" ); |
1831 | 1837 | ||
1832 | mActionUndo->setEnabled( false ); | 1838 | mActionUndo->setEnabled( false ); |
1833 | mActionRedo->setEnabled( false ); | 1839 | mActionRedo->setEnabled( false ); |
1834 | 1840 | ||
1835 | // settings menu | 1841 | // settings menu |
1836 | #ifdef KAB_EMBEDDED | 1842 | #ifdef KAB_EMBEDDED |
1837 | //US special menuentry to configure the addressbook resources. On KDE | 1843 | //US special menuentry to configure the addressbook resources. On KDE |
1838 | // you do that through the control center !!! | 1844 | // you do that through the control center !!! |
1839 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1845 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1840 | SLOT( configureResources() ), actionCollection(), | 1846 | SLOT( configureResources() ), actionCollection(), |
1841 | "kaddressbook_configure_resources" ); | 1847 | "kaddressbook_configure_resources" ); |
1842 | #endif //KAB_EMBEDDED | 1848 | #endif //KAB_EMBEDDED |
1843 | 1849 | ||
1844 | if ( mIsPart ) { | 1850 | if ( mIsPart ) { |
1845 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1851 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1846 | SLOT( openConfigDialog() ), actionCollection(), | 1852 | SLOT( openConfigDialog() ), actionCollection(), |
1847 | "kaddressbook_configure" ); | 1853 | "kaddressbook_configure" ); |
1848 | 1854 | ||
1849 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1855 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1850 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1856 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1851 | "kaddressbook_configure_shortcuts" ); | 1857 | "kaddressbook_configure_shortcuts" ); |
1852 | #ifdef KAB_EMBEDDED | 1858 | #ifdef KAB_EMBEDDED |
1853 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1859 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1854 | mActionConfigureToolbars->setEnabled( false ); | 1860 | mActionConfigureToolbars->setEnabled( false ); |
1855 | #endif //KAB_EMBEDDED | 1861 | #endif //KAB_EMBEDDED |
1856 | 1862 | ||
1857 | } else { | 1863 | } else { |
1858 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1864 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1859 | 1865 | ||
1860 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1866 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1861 | } | 1867 | } |
1862 | 1868 | ||
1863 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1869 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1864 | actionCollection(), "options_show_jump_bar" ); | 1870 | actionCollection(), "options_show_jump_bar" ); |
1865 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1871 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1866 | 1872 | ||
1867 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1873 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1868 | actionCollection(), "options_show_details" ); | 1874 | actionCollection(), "options_show_details" ); |
1869 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1875 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1870 | 1876 | ||
1871 | // misc | 1877 | // misc |
1872 | // only enable LDAP lookup if we can handle the protocol | 1878 | // only enable LDAP lookup if we can handle the protocol |
1873 | #ifndef KAB_EMBEDDED | 1879 | #ifndef KAB_EMBEDDED |
1874 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1880 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1875 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1881 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1876 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1882 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1877 | "ldap_lookup" ); | 1883 | "ldap_lookup" ); |
1878 | } | 1884 | } |
1879 | #else //KAB_EMBEDDED | 1885 | #else //KAB_EMBEDDED |
1880 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1886 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1881 | #endif //KAB_EMBEDDED | 1887 | #endif //KAB_EMBEDDED |
1882 | 1888 | ||
1883 | 1889 | ||
1884 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1890 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1885 | SLOT( setWhoAmI() ), actionCollection(), | 1891 | SLOT( setWhoAmI() ), actionCollection(), |
1886 | "set_personal" ); | 1892 | "set_personal" ); |
1887 | 1893 | ||
1888 | 1894 | ||
1889 | 1895 | ||
1890 | 1896 | ||
1891 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1897 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1892 | SLOT( setCategories() ), actionCollection(), | 1898 | SLOT( setCategories() ), actionCollection(), |
1893 | "edit_set_categories" ); | 1899 | "edit_set_categories" ); |
1894 | 1900 | ||
1895 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1901 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1896 | SLOT( removeVoice() ), actionCollection(), | 1902 | SLOT( removeVoice() ), actionCollection(), |
1897 | "remove_voice" ); | 1903 | "remove_voice" ); |
1898 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1904 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1899 | SLOT( importFromOL() ), actionCollection(), | 1905 | SLOT( importFromOL() ), actionCollection(), |
1900 | "import_OL" ); | 1906 | "import_OL" ); |
1901 | #ifdef KAB_EMBEDDED | 1907 | #ifdef KAB_EMBEDDED |
1902 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1908 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1903 | this, SLOT( showLicence() ), actionCollection(), | 1909 | this, SLOT( showLicence() ), actionCollection(), |
1904 | "licence_about_data" ); | 1910 | "licence_about_data" ); |
1905 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1911 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1906 | this, SLOT( faq() ), actionCollection(), | 1912 | this, SLOT( faq() ), actionCollection(), |
1907 | "faq_about_data" ); | 1913 | "faq_about_data" ); |
1908 | 1914 | ||
1909 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1915 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1910 | this, SLOT( createAboutData() ), actionCollection(), | 1916 | this, SLOT( createAboutData() ), actionCollection(), |
1911 | "kaddressbook_about_data" ); | 1917 | "kaddressbook_about_data" ); |
1912 | #endif //KAB_EMBEDDED | 1918 | #endif //KAB_EMBEDDED |
1913 | 1919 | ||
1914 | clipboardDataChanged(); | 1920 | clipboardDataChanged(); |
1915 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1921 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1916 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1922 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1917 | } | 1923 | } |
1918 | 1924 | ||
1919 | //US we need this function, to plug all actions into the correct menues. | 1925 | //US we need this function, to plug all actions into the correct menues. |
1920 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1926 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1921 | void KABCore::addActionsManually() | 1927 | void KABCore::addActionsManually() |
1922 | { | 1928 | { |
1923 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1929 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1924 | 1930 | ||
1925 | #ifdef KAB_EMBEDDED | 1931 | #ifdef KAB_EMBEDDED |
1926 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1932 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1927 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1933 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1928 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1934 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1929 | 1935 | ||
1930 | KToolBar* tb = mMainWindow->toolBar(); | 1936 | KToolBar* tb = mMainWindow->toolBar(); |
1931 | 1937 | ||
1932 | #ifdef DESKTOP_VERSION | 1938 | #ifdef DESKTOP_VERSION |
1933 | QMenuBar* mb = mMainWindow->menuBar(); | 1939 | QMenuBar* mb = mMainWindow->menuBar(); |
1934 | 1940 | ||
1935 | //US setup menubar. | 1941 | //US setup menubar. |
1936 | //Disable the following block if you do not want to have a menubar. | 1942 | //Disable the following block if you do not want to have a menubar. |
1937 | mb->insertItem( "&File", fileMenu ); | 1943 | mb->insertItem( "&File", fileMenu ); |
1938 | mb->insertItem( "&Edit", editMenu ); | 1944 | mb->insertItem( "&Edit", editMenu ); |
1939 | mb->insertItem( "&View", viewMenu ); | 1945 | mb->insertItem( "&View", viewMenu ); |
1940 | mb->insertItem( "&Settings", settingsMenu ); | 1946 | mb->insertItem( "&Settings", settingsMenu ); |
1941 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1947 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1942 | mb->insertItem( "&Change selected", changeMenu ); | 1948 | mb->insertItem( "&Change selected", changeMenu ); |
1943 | mb->insertItem( "&Help", helpMenu ); | 1949 | mb->insertItem( "&Help", helpMenu ); |
1944 | mIncSearchWidget = new IncSearchWidget( tb ); | 1950 | mIncSearchWidget = new IncSearchWidget( tb ); |
1945 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1951 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1946 | 1952 | ||
1947 | #else | 1953 | #else |
1948 | //US setup toolbar | 1954 | //US setup toolbar |
1949 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1955 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1950 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1956 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1951 | menuBarTB->insertItem( "ME", popupBarTB); | 1957 | menuBarTB->insertItem( "ME", popupBarTB); |
1952 | tb->insertWidget(-1, 0, menuBarTB); | 1958 | tb->insertWidget(-1, 0, menuBarTB); |
1953 | mIncSearchWidget = new IncSearchWidget( tb ); | 1959 | mIncSearchWidget = new IncSearchWidget( tb ); |
1954 | 1960 | ||
1955 | tb->enableMoving(false); | 1961 | tb->enableMoving(false); |
1956 | popupBarTB->insertItem( "&File", fileMenu ); | 1962 | popupBarTB->insertItem( "&File", fileMenu ); |
1957 | popupBarTB->insertItem( "&Edit", editMenu ); | 1963 | popupBarTB->insertItem( "&Edit", editMenu ); |
1958 | popupBarTB->insertItem( "&View", viewMenu ); | 1964 | popupBarTB->insertItem( "&View", viewMenu ); |
1959 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1965 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1960 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1966 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1961 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1967 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1962 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1968 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1963 | popupBarTB->insertItem( "&Help", helpMenu ); | 1969 | popupBarTB->insertItem( "&Help", helpMenu ); |
1964 | if (QApplication::desktop()->width() > 320 ) { | 1970 | if (QApplication::desktop()->width() > 320 ) { |
1965 | // mViewManager->getFilterAction()->plug ( tb); | 1971 | // mViewManager->getFilterAction()->plug ( tb); |
1966 | } | 1972 | } |
1967 | #endif | 1973 | #endif |
1968 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1974 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1969 | 1975 | ||
1970 | 1976 | ||
1971 | 1977 | ||
1972 | //US Now connect the actions with the menue entries. | 1978 | //US Now connect the actions with the menue entries. |
1973 | mActionPrint->plug( fileMenu ); | 1979 | mActionPrint->plug( fileMenu ); |
1974 | mActionMail->plug( fileMenu ); | 1980 | mActionMail->plug( fileMenu ); |
1975 | fileMenu->insertSeparator(); | 1981 | fileMenu->insertSeparator(); |
1976 | 1982 | ||
1977 | mActionNewContact->plug( fileMenu ); | 1983 | mActionNewContact->plug( fileMenu ); |
1978 | mActionNewContact->plug( tb ); | 1984 | mActionNewContact->plug( tb ); |
1979 | 1985 | ||
1980 | mActionEditAddressee->plug( fileMenu ); | 1986 | mActionEditAddressee->plug( fileMenu ); |
1981 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1987 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1982 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1988 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1983 | mActionEditAddressee->plug( tb ); | 1989 | mActionEditAddressee->plug( tb ); |
1984 | 1990 | ||
1985 | fileMenu->insertSeparator(); | 1991 | fileMenu->insertSeparator(); |
1986 | mActionSave->plug( fileMenu ); | 1992 | mActionSave->plug( fileMenu ); |
1987 | fileMenu->insertItem( "&Import", ImportMenu ); | 1993 | fileMenu->insertItem( "&Import", ImportMenu ); |
1988 | fileMenu->insertItem( "&Export", ExportMenu ); | 1994 | fileMenu->insertItem( "&Export", ExportMenu ); |
1989 | fileMenu->insertSeparator(); | 1995 | fileMenu->insertSeparator(); |
1990 | mActionMailVCard->plug( fileMenu ); | 1996 | mActionMailVCard->plug( fileMenu ); |
1991 | #ifndef DESKTOP_VERSION | 1997 | #ifndef DESKTOP_VERSION |
1992 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1998 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1993 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1999 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1994 | #endif | 2000 | #endif |
1995 | fileMenu->insertSeparator(); | 2001 | fileMenu->insertSeparator(); |
1996 | mActionQuit->plug( fileMenu ); | 2002 | mActionQuit->plug( fileMenu ); |
1997 | #ifdef _WIN32_ | 2003 | #ifdef _WIN32_ |
1998 | mActionImportOL->plug( ImportMenu ); | 2004 | mActionImportOL->plug( ImportMenu ); |
1999 | #endif | 2005 | #endif |
2000 | // edit menu | 2006 | // edit menu |
2001 | mActionUndo->plug( editMenu ); | 2007 | mActionUndo->plug( editMenu ); |
2002 | mActionRedo->plug( editMenu ); | 2008 | mActionRedo->plug( editMenu ); |
2003 | editMenu->insertSeparator(); | 2009 | editMenu->insertSeparator(); |
2004 | mActionCut->plug( editMenu ); | 2010 | mActionCut->plug( editMenu ); |
2005 | mActionCopy->plug( editMenu ); | 2011 | mActionCopy->plug( editMenu ); |
2006 | mActionPaste->plug( editMenu ); | 2012 | mActionPaste->plug( editMenu ); |
2007 | mActionDelete->plug( editMenu ); | 2013 | mActionDelete->plug( editMenu ); |
2008 | editMenu->insertSeparator(); | 2014 | editMenu->insertSeparator(); |
2009 | mActionSelectAll->plug( editMenu ); | 2015 | mActionSelectAll->plug( editMenu ); |
2010 | 2016 | ||
2011 | mActionRemoveVoice->plug( changeMenu ); | 2017 | mActionRemoveVoice->plug( changeMenu ); |
2012 | // settings menu | 2018 | // settings menu |
2013 | //US special menuentry to configure the addressbook resources. On KDE | 2019 | //US special menuentry to configure the addressbook resources. On KDE |
2014 | // you do that through the control center !!! | 2020 | // you do that through the control center !!! |
2015 | mActionConfigResources->plug( settingsMenu ); | 2021 | mActionConfigResources->plug( settingsMenu ); |
2016 | settingsMenu->insertSeparator(); | 2022 | settingsMenu->insertSeparator(); |
2017 | 2023 | ||
2018 | mActionConfigKAddressbook->plug( settingsMenu ); | 2024 | mActionConfigKAddressbook->plug( settingsMenu ); |
2019 | 2025 | ||
2020 | if ( mIsPart ) { | 2026 | if ( mIsPart ) { |
2021 | mActionConfigShortcuts->plug( settingsMenu ); | 2027 | mActionConfigShortcuts->plug( settingsMenu ); |
2022 | mActionConfigureToolbars->plug( settingsMenu ); | 2028 | mActionConfigureToolbars->plug( settingsMenu ); |
2023 | 2029 | ||
2024 | } else { | 2030 | } else { |
2025 | mActionKeyBindings->plug( settingsMenu ); | 2031 | mActionKeyBindings->plug( settingsMenu ); |
2026 | } | 2032 | } |
2027 | 2033 | ||
2028 | settingsMenu->insertSeparator(); | 2034 | settingsMenu->insertSeparator(); |
2029 | 2035 | ||
2030 | mActionJumpBar->plug( settingsMenu ); | 2036 | mActionJumpBar->plug( settingsMenu ); |
2031 | mActionDetails->plug( settingsMenu ); | 2037 | mActionDetails->plug( settingsMenu ); |
2032 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2038 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2033 | mActionDetails->plug( tb ); | 2039 | mActionDetails->plug( tb ); |
2034 | settingsMenu->insertSeparator(); | 2040 | settingsMenu->insertSeparator(); |
2035 | 2041 | ||
2036 | mActionWhoAmI->plug( settingsMenu ); | 2042 | mActionWhoAmI->plug( settingsMenu ); |
2037 | mActionCategories->plug( settingsMenu ); | 2043 | mActionCategories->plug( settingsMenu ); |
2038 | 2044 | ||
2039 | mActionLicence->plug( helpMenu ); | 2045 | mActionLicence->plug( helpMenu ); |
2040 | mActionFaq->plug( helpMenu ); | 2046 | mActionFaq->plug( helpMenu ); |
2041 | mActionAboutKAddressbook->plug( helpMenu ); | 2047 | mActionAboutKAddressbook->plug( helpMenu ); |
2042 | 2048 | ||
2043 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2049 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2044 | 2050 | ||
2045 | mActionSave->plug( tb ); | 2051 | mActionSave->plug( tb ); |
2046 | mViewManager->getFilterAction()->plug ( tb); | 2052 | mViewManager->getFilterAction()->plug ( tb); |
2047 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2053 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2048 | mActionUndo->plug( tb ); | 2054 | mActionUndo->plug( tb ); |
2049 | mActionDelete->plug( tb ); | 2055 | mActionDelete->plug( tb ); |
2050 | mActionRedo->plug( tb ); | 2056 | mActionRedo->plug( tb ); |
2051 | } | 2057 | } |
2052 | } | 2058 | } |
2053 | //mActionQuit->plug ( tb ); | 2059 | //mActionQuit->plug ( tb ); |
2054 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2060 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2055 | 2061 | ||
2056 | //US link the searchwidget first to this. | 2062 | //US link the searchwidget first to this. |
2057 | // The real linkage to the toolbar happens later. | 2063 | // The real linkage to the toolbar happens later. |
2058 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2064 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2059 | //US tb->insertItem( mIncSearchWidget ); | 2065 | //US tb->insertItem( mIncSearchWidget ); |
2060 | /*US | 2066 | /*US |
2061 | mIncSearchWidget = new IncSearchWidget( tb ); | 2067 | mIncSearchWidget = new IncSearchWidget( tb ); |
2062 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2068 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2063 | SLOT( incrementalSearch( const QString& ) ) ); | 2069 | SLOT( incrementalSearch( const QString& ) ) ); |
2064 | 2070 | ||
2065 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2071 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2066 | 2072 | ||
2067 | //US topLayout->addWidget( mJumpButtonBar ); | 2073 | //US topLayout->addWidget( mJumpButtonBar ); |
2068 | this->layout()->add( mJumpButtonBar ); | 2074 | this->layout()->add( mJumpButtonBar ); |
2069 | */ | 2075 | */ |
2070 | 2076 | ||
2071 | #endif //KAB_EMBEDDED | 2077 | #endif //KAB_EMBEDDED |
2072 | 2078 | ||
2073 | mActionExport2phone->plug( ExportMenu ); | 2079 | mActionExport2phone->plug( ExportMenu ); |
2074 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2080 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2075 | syncManager->fillSyncMenu(); | 2081 | syncManager->fillSyncMenu(); |
2076 | 2082 | ||
2077 | } | 2083 | } |
2078 | void KABCore::showLicence() | 2084 | void KABCore::showLicence() |
2079 | { | 2085 | { |
2080 | KApplication::showLicence(); | 2086 | KApplication::showLicence(); |
2081 | } | 2087 | } |
2082 | void KABCore::removeVoice() | 2088 | void KABCore::removeVoice() |
2083 | { | 2089 | { |
2084 | 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 ) | 2090 | 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 ) |
2085 | return; | 2091 | return; |
2086 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2092 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2087 | KABC::Addressee::List::Iterator it; | 2093 | KABC::Addressee::List::Iterator it; |
2088 | for ( it = list.begin(); it != list.end(); ++it ) { | 2094 | for ( it = list.begin(); it != list.end(); ++it ) { |
2089 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 2095 | |
2090 | PhoneNumber::List::Iterator phoneIt; | 2096 | if ( (*it).removeVoice() ) |
2091 | bool found = false; | ||
2092 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | ||
2093 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | ||
2094 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | ||
2095 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | ||
2096 | (*it).insertPhoneNumber( (*phoneIt) ); | ||
2097 | found = true; | ||
2098 | } | ||
2099 | } | ||
2100 | |||
2101 | } | ||
2102 | if ( found ) | ||
2103 | contactModified((*it) ); | 2097 | contactModified((*it) ); |
2104 | } | 2098 | } |
2105 | } | 2099 | } |
2106 | 2100 | ||
2107 | 2101 | ||
2108 | 2102 | ||
2109 | void KABCore::clipboardDataChanged() | 2103 | void KABCore::clipboardDataChanged() |
2110 | { | 2104 | { |
2111 | 2105 | ||
2112 | if ( mReadWrite ) | 2106 | if ( mReadWrite ) |
2113 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2107 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2114 | 2108 | ||
2115 | } | 2109 | } |
2116 | 2110 | ||
2117 | void KABCore::updateActionMenu() | 2111 | void KABCore::updateActionMenu() |
2118 | { | 2112 | { |
2119 | UndoStack *undo = UndoStack::instance(); | 2113 | UndoStack *undo = UndoStack::instance(); |
2120 | RedoStack *redo = RedoStack::instance(); | 2114 | RedoStack *redo = RedoStack::instance(); |
2121 | 2115 | ||
2122 | if ( undo->isEmpty() ) | 2116 | if ( undo->isEmpty() ) |
2123 | mActionUndo->setText( i18n( "Undo" ) ); | 2117 | mActionUndo->setText( i18n( "Undo" ) ); |
2124 | else | 2118 | else |
2125 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2119 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2126 | 2120 | ||
2127 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2121 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2128 | 2122 | ||
2129 | if ( !redo->top() ) | 2123 | if ( !redo->top() ) |
2130 | mActionRedo->setText( i18n( "Redo" ) ); | 2124 | mActionRedo->setText( i18n( "Redo" ) ); |
2131 | else | 2125 | else |
2132 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2126 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2133 | 2127 | ||
2134 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2128 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2135 | } | 2129 | } |
2136 | 2130 | ||
2137 | void KABCore::configureKeyBindings() | 2131 | void KABCore::configureKeyBindings() |
2138 | { | 2132 | { |
2139 | #ifndef KAB_EMBEDDED | 2133 | #ifndef KAB_EMBEDDED |
2140 | KKeyDialog::configure( actionCollection(), true ); | 2134 | KKeyDialog::configure( actionCollection(), true ); |
2141 | #else //KAB_EMBEDDED | 2135 | #else //KAB_EMBEDDED |
2142 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2136 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2143 | #endif //KAB_EMBEDDED | 2137 | #endif //KAB_EMBEDDED |
2144 | } | 2138 | } |
2145 | 2139 | ||
2146 | #ifdef KAB_EMBEDDED | 2140 | #ifdef KAB_EMBEDDED |
2147 | void KABCore::configureResources() | 2141 | void KABCore::configureResources() |
2148 | { | 2142 | { |
2149 | KRES::KCMKResources dlg( this, "" , 0 ); | 2143 | KRES::KCMKResources dlg( this, "" , 0 ); |
2150 | 2144 | ||
2151 | if ( !dlg.exec() ) | 2145 | if ( !dlg.exec() ) |
2152 | return; | 2146 | return; |
2153 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2147 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2154 | } | 2148 | } |
2155 | #endif //KAB_EMBEDDED | 2149 | #endif //KAB_EMBEDDED |
2156 | 2150 | ||
2157 | 2151 | ||
2158 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2152 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2159 | * for the attendees list of an event. | 2153 | * for the attendees list of an event. |
2160 | */ | 2154 | */ |
2161 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2155 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2162 | { | 2156 | { |
2163 | QStringList nameList; | 2157 | QStringList nameList; |
2164 | QStringList emailList; | 2158 | QStringList emailList; |
2165 | QStringList uidList; | 2159 | QStringList uidList; |
2166 | 2160 | ||
2167 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2161 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2168 | uint i=0; | 2162 | uint i=0; |
2169 | for (i=0; i < list.count(); i++) | 2163 | for (i=0; i < list.count(); i++) |
2170 | { | 2164 | { |
2171 | nameList.append(list[i].realName()); | 2165 | nameList.append(list[i].realName()); |
2172 | emailList.append(list[i].preferredEmail()); | 2166 | emailList.append(list[i].preferredEmail()); |
2173 | uidList.append(list[i].uid()); | 2167 | uidList.append(list[i].uid()); |
2174 | } | 2168 | } |
2175 | 2169 | ||
2176 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2170 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2177 | 2171 | ||
2178 | } | 2172 | } |
2179 | 2173 | ||
2180 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2174 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2181 | * to put them into the calendar. | 2175 | * to put them into the calendar. |
2182 | */ | 2176 | */ |
2183 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2177 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2184 | { | 2178 | { |
2185 | // qDebug("KABCore::requestForBirthdayList"); | 2179 | // qDebug("KABCore::requestForBirthdayList"); |
2186 | QStringList birthdayList; | 2180 | QStringList birthdayList; |
2187 | QStringList anniversaryList; | 2181 | QStringList anniversaryList; |
2188 | QStringList realNameList; | 2182 | QStringList realNameList; |
2189 | QStringList preferredEmailList; | 2183 | QStringList preferredEmailList; |
2190 | QStringList assembledNameList; | 2184 | QStringList assembledNameList; |
2191 | QStringList uidList; | 2185 | QStringList uidList; |
2192 | 2186 | ||
2193 | KABC::AddressBook::Iterator it; | 2187 | KABC::AddressBook::Iterator it; |
2194 | 2188 | ||
2195 | int count = 0; | 2189 | int count = 0; |
2196 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2190 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2197 | ++count; | 2191 | ++count; |
2198 | } | 2192 | } |
2199 | QProgressBar bar(count,0 ); | 2193 | QProgressBar bar(count,0 ); |
2200 | int w = 300; | 2194 | int w = 300; |
2201 | if ( QApplication::desktop()->width() < 320 ) | 2195 | if ( QApplication::desktop()->width() < 320 ) |
2202 | w = 220; | 2196 | w = 220; |
2203 | int h = bar.sizeHint().height() ; | 2197 | int h = bar.sizeHint().height() ; |
2204 | int dw = QApplication::desktop()->width(); | 2198 | int dw = QApplication::desktop()->width(); |
2205 | int dh = QApplication::desktop()->height(); | 2199 | int dh = QApplication::desktop()->height(); |
2206 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2200 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2207 | bar.show(); | 2201 | bar.show(); |
2208 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); | 2202 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); |
2209 | qApp->processEvents(); | 2203 | qApp->processEvents(); |
2210 | 2204 | ||
2211 | QDate bday; | 2205 | QDate bday; |
2212 | QString anni; | 2206 | QString anni; |
2213 | QString formattedbday; | 2207 | QString formattedbday; |
2214 | 2208 | ||
2215 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2209 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2216 | { | 2210 | { |
2217 | if ( ! bar.isVisible() ) | 2211 | if ( ! bar.isVisible() ) |
2218 | return; | 2212 | return; |
2219 | bar.setProgress( count++ ); | 2213 | bar.setProgress( count++ ); |
2220 | qApp->processEvents(); | 2214 | qApp->processEvents(); |
2221 | bday = (*it).birthday().date(); | 2215 | bday = (*it).birthday().date(); |
2222 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2216 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2223 | 2217 | ||
2224 | if ( bday.isValid() || !anni.isEmpty()) | 2218 | if ( bday.isValid() || !anni.isEmpty()) |
2225 | { | 2219 | { |
2226 | if (bday.isValid()) | 2220 | if (bday.isValid()) |
2227 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2221 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2228 | else | 2222 | else |
2229 | formattedbday = "NOTVALID"; | 2223 | formattedbday = "NOTVALID"; |
2230 | if (anni.isEmpty()) | 2224 | if (anni.isEmpty()) |
2231 | anni = "INVALID"; | 2225 | anni = "INVALID"; |
2232 | 2226 | ||
2233 | birthdayList.append(formattedbday); | 2227 | birthdayList.append(formattedbday); |
2234 | anniversaryList.append(anni); //should be ISODate | 2228 | anniversaryList.append(anni); //should be ISODate |
2235 | realNameList.append((*it).realName()); | 2229 | realNameList.append((*it).realName()); |
2236 | preferredEmailList.append((*it).preferredEmail()); | 2230 | preferredEmailList.append((*it).preferredEmail()); |
2237 | assembledNameList.append((*it).assembledName()); | 2231 | assembledNameList.append((*it).assembledName()); |
2238 | uidList.append((*it).uid()); | 2232 | uidList.append((*it).uid()); |
2239 | 2233 | ||
2240 | 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() ); | 2234 | 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() ); |
2241 | } | 2235 | } |
2242 | } | 2236 | } |
2243 | 2237 | ||
2244 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2238 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2245 | 2239 | ||
2246 | } | 2240 | } |
2247 | 2241 | ||
2248 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2242 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2249 | */ | 2243 | */ |
2250 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2244 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2251 | { | 2245 | { |
2252 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2246 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2253 | 2247 | ||
2254 | QString foundUid = QString::null; | 2248 | QString foundUid = QString::null; |
2255 | if ( ! uid.isEmpty() ) { | 2249 | if ( ! uid.isEmpty() ) { |
2256 | Addressee adrr = mAddressBook->findByUid( uid ); | 2250 | Addressee adrr = mAddressBook->findByUid( uid ); |
2257 | if ( !adrr.isEmpty() ) { | 2251 | if ( !adrr.isEmpty() ) { |
2258 | foundUid = uid; | 2252 | foundUid = uid; |
2259 | } | 2253 | } |
2260 | if ( email == "sendbacklist" ) { | 2254 | if ( email == "sendbacklist" ) { |
2261 | //qDebug("ssssssssssssssssssssssend "); | 2255 | //qDebug("ssssssssssssssssssssssend "); |
2262 | QStringList nameList; | 2256 | QStringList nameList; |
2263 | QStringList emailList; | 2257 | QStringList emailList; |
2264 | QStringList uidList; | 2258 | QStringList uidList; |
2265 | nameList.append(adrr.realName()); | 2259 | nameList.append(adrr.realName()); |
2266 | emailList = adrr.emails(); | 2260 | emailList = adrr.emails(); |
2267 | uidList.append( adrr.preferredEmail()); | 2261 | uidList.append( adrr.preferredEmail()); |
2268 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2262 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2269 | return; | 2263 | return; |
2270 | } | 2264 | } |
2271 | 2265 | ||
2272 | } | 2266 | } |
2273 | 2267 | ||
2274 | if ( email == "sendbacklist" ) | 2268 | if ( email == "sendbacklist" ) |
2275 | return; | 2269 | return; |
2276 | if (foundUid.isEmpty()) | 2270 | if (foundUid.isEmpty()) |
2277 | { | 2271 | { |
2278 | //find the uid of the person first | 2272 | //find the uid of the person first |
2279 | Addressee::List namelist; | 2273 | Addressee::List namelist; |
2280 | Addressee::List emaillist; | 2274 | Addressee::List emaillist; |
2281 | 2275 | ||
2282 | if (!name.isEmpty()) | 2276 | if (!name.isEmpty()) |
2283 | namelist = mAddressBook->findByName( name ); | 2277 | namelist = mAddressBook->findByName( name ); |
2284 | 2278 | ||
2285 | if (!email.isEmpty()) | 2279 | if (!email.isEmpty()) |
2286 | emaillist = mAddressBook->findByEmail( email ); | 2280 | emaillist = mAddressBook->findByEmail( email ); |
2287 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2281 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2288 | //check if we have a match in Namelist and Emaillist | 2282 | //check if we have a match in Namelist and Emaillist |
2289 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2283 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2290 | foundUid = emaillist[0].uid(); | 2284 | foundUid = emaillist[0].uid(); |
2291 | } | 2285 | } |
2292 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2286 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2293 | foundUid = namelist[0].uid(); | 2287 | foundUid = namelist[0].uid(); |
2294 | else | 2288 | else |
2295 | { | 2289 | { |
2296 | for (int i = 0; i < namelist.count(); i++) | 2290 | for (int i = 0; i < namelist.count(); i++) |
2297 | { | 2291 | { |
2298 | for (int j = 0; j < emaillist.count(); j++) | 2292 | for (int j = 0; j < emaillist.count(); j++) |
2299 | { | 2293 | { |
2300 | if (namelist[i] == emaillist[j]) | 2294 | if (namelist[i] == emaillist[j]) |
2301 | { | 2295 | { |
2302 | foundUid = namelist[i].uid(); | 2296 | foundUid = namelist[i].uid(); |
2303 | } | 2297 | } |
2304 | } | 2298 | } |
2305 | } | 2299 | } |
2306 | } | 2300 | } |
2307 | } | 2301 | } |
2308 | else | 2302 | else |
2309 | { | 2303 | { |
2310 | foundUid = uid; | 2304 | foundUid = uid; |
2311 | } | 2305 | } |
2312 | 2306 | ||
2313 | if (!foundUid.isEmpty()) | 2307 | if (!foundUid.isEmpty()) |
2314 | { | 2308 | { |
2315 | 2309 | ||
2316 | // raise Ka/Pi if it is in the background | 2310 | // raise Ka/Pi if it is in the background |
2317 | #ifndef DESKTOP_VERSION | 2311 | #ifndef DESKTOP_VERSION |
2318 | #ifndef KORG_NODCOP | 2312 | #ifndef KORG_NODCOP |
2319 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2313 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2320 | #endif | 2314 | #endif |
2321 | #endif | 2315 | #endif |
2322 | 2316 | ||
2323 | mMainWindow->showMaximized(); | 2317 | mMainWindow->showMaximized(); |
2324 | mMainWindow-> raise(); | 2318 | mMainWindow-> raise(); |
2325 | 2319 | ||
2326 | mViewManager->setSelected( "", false); | 2320 | mViewManager->setSelected( "", false); |
2327 | mViewManager->refreshView( "" ); | 2321 | mViewManager->refreshView( "" ); |
2328 | mViewManager->setSelected( foundUid, true ); | 2322 | mViewManager->setSelected( foundUid, true ); |
2329 | mViewManager->refreshView( foundUid ); | 2323 | mViewManager->refreshView( foundUid ); |
2330 | 2324 | ||
2331 | if ( !mMultipleViewsAtOnce ) | 2325 | if ( !mMultipleViewsAtOnce ) |
2332 | { | 2326 | { |
2333 | setDetailsVisible( true ); | 2327 | setDetailsVisible( true ); |
2334 | mActionDetails->setChecked(true); | 2328 | mActionDetails->setChecked(true); |
2335 | } | 2329 | } |
2336 | } | 2330 | } |
2337 | } | 2331 | } |
2338 | 2332 | ||
2339 | 2333 | ||
2340 | void KABCore::faq() | 2334 | void KABCore::faq() |
2341 | { | 2335 | { |
2342 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2336 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2343 | } | 2337 | } |
2344 | 2338 | ||
2345 | #include <libkcal/syncdefines.h> | 2339 | #include <libkcal/syncdefines.h> |
2346 | 2340 | ||
2347 | KABC::Addressee KABCore::getLastSyncAddressee() | 2341 | KABC::Addressee KABCore::getLastSyncAddressee() |
2348 | { | 2342 | { |
2349 | Addressee lse; | 2343 | Addressee lse; |
2350 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2344 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2351 | 2345 | ||
2352 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2346 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2353 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2347 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2354 | if (lse.isEmpty()) { | 2348 | if (lse.isEmpty()) { |
2355 | qDebug("Creating new last-syncAddressee "); | 2349 | qDebug("Creating new last-syncAddressee "); |
2356 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2350 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2357 | QString sum = ""; | 2351 | QString sum = ""; |
2358 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2352 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2359 | sum = "E: "; | 2353 | sum = "E: "; |
2360 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2354 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2361 | lse.setRevision( mLastAddressbookSync ); | 2355 | lse.setRevision( mLastAddressbookSync ); |
2362 | lse.setCategories( i18n("SyncEvent") ); | 2356 | lse.setCategories( i18n("SyncEvent") ); |
2363 | mAddressBook->insertAddressee( lse ); | 2357 | mAddressBook->insertAddressee( lse ); |
2364 | } | 2358 | } |
2365 | return lse; | 2359 | return lse; |
2366 | } | 2360 | } |
2367 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2361 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2368 | { | 2362 | { |
2369 | 2363 | ||
2370 | //void setZaurusId(int id); | 2364 | //void setZaurusId(int id); |
2371 | // int zaurusId() const; | 2365 | // int zaurusId() const; |
2372 | // void setZaurusUid(int id); | 2366 | // void setZaurusUid(int id); |
2373 | // int zaurusUid() const; | 2367 | // int zaurusUid() const; |
2374 | // void setZaurusStat(int id); | 2368 | // void setZaurusStat(int id); |
2375 | // int zaurusStat() const; | 2369 | // int zaurusStat() const; |
2376 | // 0 equal | 2370 | // 0 equal |
2377 | // 1 take local | 2371 | // 1 take local |
2378 | // 2 take remote | 2372 | // 2 take remote |
2379 | // 3 cancel | 2373 | // 3 cancel |
2380 | QDateTime lastSync = mLastAddressbookSync; | 2374 | QDateTime lastSync = mLastAddressbookSync; |
2381 | QDateTime localMod = local->revision(); | 2375 | QDateTime localMod = local->revision(); |
2382 | QDateTime remoteMod = remote->revision(); | 2376 | QDateTime remoteMod = remote->revision(); |
2383 | 2377 | ||
2384 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2378 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2385 | 2379 | ||
2386 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2380 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2387 | bool remCh, locCh; | 2381 | bool remCh, locCh; |
2388 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2382 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2389 | 2383 | ||
2390 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2384 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2391 | locCh = ( localMod > mLastAddressbookSync ); | 2385 | locCh = ( localMod > mLastAddressbookSync ); |
2392 | if ( !remCh && ! locCh ) { | 2386 | if ( !remCh && ! locCh ) { |
2393 | //qDebug("both not changed "); | 2387 | //qDebug("both not changed "); |
2394 | lastSync = localMod.addDays(1); | 2388 | lastSync = localMod.addDays(1); |
2395 | if ( mode <= SYNC_PREF_ASK ) | 2389 | if ( mode <= SYNC_PREF_ASK ) |
2396 | return 0; | 2390 | return 0; |
2397 | } else { | 2391 | } else { |
2398 | if ( locCh ) { | 2392 | if ( locCh ) { |
2399 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2393 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2400 | lastSync = localMod.addDays( -1 ); | 2394 | lastSync = localMod.addDays( -1 ); |
2401 | if ( !remCh ) | 2395 | if ( !remCh ) |
2402 | remoteMod =( lastSync.addDays( -1 ) ); | 2396 | remoteMod =( lastSync.addDays( -1 ) ); |
2403 | } else { | 2397 | } else { |
2404 | //qDebug(" not loc changed "); | 2398 | //qDebug(" not loc changed "); |
2405 | lastSync = localMod.addDays( 1 ); | 2399 | lastSync = localMod.addDays( 1 ); |
2406 | if ( remCh ) | 2400 | if ( remCh ) |
2407 | remoteMod =( lastSync.addDays( 1 ) ); | 2401 | remoteMod =( lastSync.addDays( 1 ) ); |
2408 | 2402 | ||
2409 | } | 2403 | } |
2410 | } | 2404 | } |
2411 | full = true; | 2405 | full = true; |
2412 | if ( mode < SYNC_PREF_ASK ) | 2406 | if ( mode < SYNC_PREF_ASK ) |
2413 | mode = SYNC_PREF_ASK; | 2407 | mode = SYNC_PREF_ASK; |
2414 | } else { | 2408 | } else { |
2415 | if ( localMod == remoteMod ) | 2409 | if ( localMod == remoteMod ) |
2416 | return 0; | 2410 | return 0; |
2417 | 2411 | ||
2418 | } | 2412 | } |
2419 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2413 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2420 | 2414 | ||
2421 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2415 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2422 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2416 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2423 | //full = true; //debug only | 2417 | //full = true; //debug only |
2424 | if ( full ) { | 2418 | if ( full ) { |
2425 | bool equ = ( (*local) == (*remote) ); | 2419 | bool equ = ( (*local) == (*remote) ); |
2426 | if ( equ ) { | 2420 | if ( equ ) { |
2427 | //qDebug("equal "); | 2421 | //qDebug("equal "); |
2428 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2422 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2429 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2423 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2430 | } | 2424 | } |
2431 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2425 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2432 | return 0; | 2426 | return 0; |
2433 | 2427 | ||
2434 | }//else //debug only | 2428 | }//else //debug only |
2435 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2429 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2436 | } | 2430 | } |
2437 | int result; | 2431 | int result; |
2438 | bool localIsNew; | 2432 | bool localIsNew; |
2439 | //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() ); | 2433 | //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() ); |
2440 | 2434 | ||
2441 | if ( full && mode < SYNC_PREF_NEWEST ) | 2435 | if ( full && mode < SYNC_PREF_NEWEST ) |
2442 | mode = SYNC_PREF_ASK; | 2436 | mode = SYNC_PREF_ASK; |
2443 | 2437 | ||
2444 | switch( mode ) { | 2438 | switch( mode ) { |
2445 | case SYNC_PREF_LOCAL: | 2439 | case SYNC_PREF_LOCAL: |
2446 | if ( lastSync > remoteMod ) | 2440 | if ( lastSync > remoteMod ) |
2447 | return 1; | 2441 | return 1; |
2448 | if ( lastSync > localMod ) | 2442 | if ( lastSync > localMod ) |
2449 | return 2; | 2443 | return 2; |
2450 | return 1; | 2444 | return 1; |
2451 | break; | 2445 | break; |
2452 | case SYNC_PREF_REMOTE: | 2446 | case SYNC_PREF_REMOTE: |
2453 | if ( lastSync > remoteMod ) | 2447 | if ( lastSync > remoteMod ) |
2454 | return 1; | 2448 | return 1; |
2455 | if ( lastSync > localMod ) | 2449 | if ( lastSync > localMod ) |
2456 | return 2; | 2450 | return 2; |
2457 | return 2; | 2451 | return 2; |
2458 | break; | 2452 | break; |
2459 | case SYNC_PREF_NEWEST: | 2453 | case SYNC_PREF_NEWEST: |
2460 | if ( localMod > remoteMod ) | 2454 | if ( localMod > remoteMod ) |
2461 | return 1; | 2455 | return 1; |
2462 | else | 2456 | else |
2463 | return 2; | 2457 | return 2; |
2464 | break; | 2458 | break; |
2465 | case SYNC_PREF_ASK: | 2459 | case SYNC_PREF_ASK: |
2466 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2460 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2467 | if ( lastSync > remoteMod ) | 2461 | if ( lastSync > remoteMod ) |
2468 | return 1; | 2462 | return 1; |
2469 | if ( lastSync > localMod ) | 2463 | if ( lastSync > localMod ) |
2470 | return 2; | 2464 | return 2; |
2471 | localIsNew = localMod >= remoteMod; | 2465 | localIsNew = localMod >= remoteMod; |
2472 | //qDebug("conflict! ************************************** "); | 2466 | //qDebug("conflict! ************************************** "); |
2473 | { | 2467 | { |
2474 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2468 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2475 | result = acd.executeD(localIsNew); | 2469 | result = acd.executeD(localIsNew); |
2476 | return result; | 2470 | return result; |
2477 | } | 2471 | } |
2478 | break; | 2472 | break; |
2479 | case SYNC_PREF_FORCE_LOCAL: | 2473 | case SYNC_PREF_FORCE_LOCAL: |
2480 | return 1; | 2474 | return 1; |
2481 | break; | 2475 | break; |
2482 | case SYNC_PREF_FORCE_REMOTE: | 2476 | case SYNC_PREF_FORCE_REMOTE: |
2483 | return 2; | 2477 | return 2; |
2484 | break; | 2478 | break; |
2485 | 2479 | ||
2486 | default: | 2480 | default: |
2487 | // SYNC_PREF_TAKE_BOTH not implemented | 2481 | // SYNC_PREF_TAKE_BOTH not implemented |
2488 | break; | 2482 | break; |
2489 | } | 2483 | } |
2490 | return 0; | 2484 | return 0; |
2491 | } | 2485 | } |
2492 | 2486 | ||
2493 | 2487 | ||
2494 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2488 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2495 | { | 2489 | { |
2496 | bool syncOK = true; | 2490 | bool syncOK = true; |
2497 | int addedAddressee = 0; | 2491 | int addedAddressee = 0; |
2498 | int addedAddresseeR = 0; | 2492 | int addedAddresseeR = 0; |
2499 | int deletedAddresseeR = 0; | 2493 | int deletedAddresseeR = 0; |
2500 | int deletedAddresseeL = 0; | 2494 | int deletedAddresseeL = 0; |
2501 | int changedLocal = 0; | 2495 | int changedLocal = 0; |
2502 | int changedRemote = 0; | 2496 | int changedRemote = 0; |
2503 | 2497 | ||
2504 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2498 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2505 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2499 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2506 | 2500 | ||
2507 | //QPtrList<Addressee> el = local->rawAddressees(); | 2501 | //QPtrList<Addressee> el = local->rawAddressees(); |
2508 | Addressee addresseeR; | 2502 | Addressee addresseeR; |
2509 | QString uid; | 2503 | QString uid; |
2510 | int take; | 2504 | int take; |
2511 | Addressee addresseeL; | 2505 | Addressee addresseeL; |
2512 | Addressee addresseeRSync; | 2506 | Addressee addresseeRSync; |
2513 | Addressee addresseeLSync; | 2507 | Addressee addresseeLSync; |
2514 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2508 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2515 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2509 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2516 | bool fullDateRange = false; | 2510 | bool fullDateRange = false; |
2517 | local->resetTempSyncStat(); | 2511 | local->resetTempSyncStat(); |
2518 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2512 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2519 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2513 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2520 | addresseeLSync = getLastSyncAddressee(); | 2514 | addresseeLSync = getLastSyncAddressee(); |
2521 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2515 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2522 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2516 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2523 | if ( !addresseeR.isEmpty() ) { | 2517 | if ( !addresseeR.isEmpty() ) { |
2524 | addresseeRSync = addresseeR; | 2518 | addresseeRSync = addresseeR; |
2525 | remote->removeAddressee(addresseeR ); | 2519 | remote->removeAddressee(addresseeR ); |
2526 | 2520 | ||
2527 | } else { | 2521 | } else { |
2528 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2522 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2529 | addresseeRSync = addresseeLSync ; | 2523 | addresseeRSync = addresseeLSync ; |
2530 | } else { | 2524 | } else { |
2531 | qDebug("FULLDATE 1"); | 2525 | qDebug("FULLDATE 1"); |
2532 | fullDateRange = true; | 2526 | fullDateRange = true; |
2533 | Addressee newAdd; | 2527 | Addressee newAdd; |
2534 | addresseeRSync = newAdd; | 2528 | addresseeRSync = newAdd; |
2535 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2529 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2536 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2530 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2537 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2531 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2538 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2532 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2539 | } | 2533 | } |
2540 | } | 2534 | } |
2541 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2535 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2542 | qDebug("FULLDATE 2"); | 2536 | qDebug("FULLDATE 2"); |
2543 | fullDateRange = true; | 2537 | fullDateRange = true; |
2544 | } | 2538 | } |
2545 | if ( ! fullDateRange ) { | 2539 | if ( ! fullDateRange ) { |
2546 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2540 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2547 | 2541 | ||
2548 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2542 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2549 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2543 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2550 | fullDateRange = true; | 2544 | fullDateRange = true; |
2551 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2545 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2552 | } | 2546 | } |
2553 | } | 2547 | } |
2554 | // fullDateRange = true; // debug only! | 2548 | // fullDateRange = true; // debug only! |
2555 | if ( fullDateRange ) | 2549 | if ( fullDateRange ) |
2556 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2550 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2557 | else | 2551 | else |
2558 | mLastAddressbookSync = addresseeLSync.revision(); | 2552 | mLastAddressbookSync = addresseeLSync.revision(); |
2559 | // for resyncing if own file has changed | 2553 | // for resyncing if own file has changed |
2560 | // PENDING fixme later when implemented | 2554 | // PENDING fixme later when implemented |
2561 | #if 0 | 2555 | #if 0 |
2562 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2556 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2563 | mLastAddressbookSync = loadedFileVersion; | 2557 | mLastAddressbookSync = loadedFileVersion; |
2564 | qDebug("setting mLastAddressbookSync "); | 2558 | qDebug("setting mLastAddressbookSync "); |
2565 | } | 2559 | } |
2566 | #endif | 2560 | #endif |
2567 | 2561 | ||
2568 | //qDebug("*************************** "); | 2562 | //qDebug("*************************** "); |
2569 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2563 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2570 | QStringList er = remote->uidList(); | 2564 | QStringList er = remote->uidList(); |
2571 | Addressee inR ;//= er.first(); | 2565 | Addressee inR ;//= er.first(); |
2572 | Addressee inL; | 2566 | Addressee inL; |
2573 | 2567 | ||
2574 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2568 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2575 | 2569 | ||
2576 | int modulo = (er.count()/10)+1; | 2570 | int modulo = (er.count()/10)+1; |
2577 | int incCounter = 0; | 2571 | int incCounter = 0; |
2578 | while ( incCounter < er.count()) { | 2572 | while ( incCounter < er.count()) { |
2579 | if (syncManager->isProgressBarCanceled()) | 2573 | if (syncManager->isProgressBarCanceled()) |
2580 | return false; | 2574 | return false; |
2581 | if ( incCounter % modulo == 0 ) | 2575 | if ( incCounter % modulo == 0 ) |
2582 | syncManager->showProgressBar(incCounter); | 2576 | syncManager->showProgressBar(incCounter); |
2583 | 2577 | ||
2584 | uid = er[ incCounter ]; | 2578 | uid = er[ incCounter ]; |
2585 | bool skipIncidence = false; | 2579 | bool skipIncidence = false; |
2586 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2580 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2587 | skipIncidence = true; | 2581 | skipIncidence = true; |
2588 | QString idS,OidS; | 2582 | QString idS,OidS; |
2589 | qApp->processEvents(); | 2583 | qApp->processEvents(); |
2590 | if ( !skipIncidence ) { | 2584 | if ( !skipIncidence ) { |
2591 | inL = local->findByUid( uid ); | 2585 | inL = local->findByUid( uid ); |
2592 | inR = remote->findByUid( uid ); | 2586 | inR = remote->findByUid( uid ); |
2593 | //inL.setResource( 0 ); | 2587 | //inL.setResource( 0 ); |
2594 | //inR.setResource( 0 ); | 2588 | //inR.setResource( 0 ); |
2595 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2589 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2596 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2590 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2597 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2591 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2598 | if ( take == 3 ) | 2592 | if ( take == 3 ) |
2599 | return false; | 2593 | return false; |
2600 | if ( take == 1 ) {// take local | 2594 | if ( take == 1 ) {// take local |
2601 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2595 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2602 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2596 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2603 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2597 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2604 | local->insertAddressee( inL, false ); | 2598 | local->insertAddressee( inL, false ); |
2605 | idS = inR.externalUID(); | 2599 | idS = inR.externalUID(); |
2606 | OidS = inR.originalExternalUID(); | 2600 | OidS = inR.originalExternalUID(); |
2607 | } | 2601 | } |
2608 | else | 2602 | else |
2609 | idS = inR.IDStr(); | 2603 | idS = inR.IDStr(); |
2610 | remote->removeAddressee( inR ); | 2604 | remote->removeAddressee( inR ); |
2611 | inR = inL; | 2605 | inR = inL; |
2612 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2606 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2613 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2607 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2614 | inR.setOriginalExternalUID( OidS ); | 2608 | inR.setOriginalExternalUID( OidS ); |
2615 | inR.setExternalUID( idS ); | 2609 | inR.setExternalUID( idS ); |
2616 | } else { | 2610 | } else { |
2617 | inR.setIDStr( idS ); | 2611 | inR.setIDStr( idS ); |
2618 | } | 2612 | } |
2619 | inR.setResource( 0 ); | 2613 | inR.setResource( 0 ); |
2620 | remote->insertAddressee( inR , false); | 2614 | remote->insertAddressee( inR , false); |
2621 | ++changedRemote; | 2615 | ++changedRemote; |
2622 | } else { // take == 2 take remote | 2616 | } else { // take == 2 take remote |
2623 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2617 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2624 | if ( inR.revision().date().year() < 2004 ) | 2618 | if ( inR.revision().date().year() < 2004 ) |
2625 | inR.setRevision( modifiedCalendar ); | 2619 | inR.setRevision( modifiedCalendar ); |
2626 | } | 2620 | } |
2627 | idS = inL.IDStr(); | 2621 | idS = inL.IDStr(); |
2628 | local->removeAddressee( inL ); | 2622 | local->removeAddressee( inL ); |
2629 | inL = inR; | 2623 | inL = inR; |
2630 | inL.setIDStr( idS ); | 2624 | inL.setIDStr( idS ); |
2631 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2625 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2632 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2626 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2633 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2627 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2634 | } | 2628 | } |
2635 | inL.setResource( 0 ); | 2629 | inL.setResource( 0 ); |
2636 | local->insertAddressee( inL , false ); | 2630 | local->insertAddressee( inL , false ); |
2637 | ++changedLocal; | 2631 | ++changedLocal; |
2638 | } | 2632 | } |
2639 | } | 2633 | } |
2640 | } else { // no conflict | 2634 | } else { // no conflict |
2641 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2635 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2642 | QString des = addresseeLSync.note(); | 2636 | QString des = addresseeLSync.note(); |
2643 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2637 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2644 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2638 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2645 | remote->insertAddressee( inR, false ); | 2639 | remote->insertAddressee( inR, false ); |
2646 | ++deletedAddresseeR; | 2640 | ++deletedAddresseeR; |
2647 | } else { | 2641 | } else { |
2648 | inR.setRevision( modifiedCalendar ); | 2642 | inR.setRevision( modifiedCalendar ); |
2649 | remote->insertAddressee( inR, false ); | 2643 | remote->insertAddressee( inR, false ); |
2650 | inL = inR; | 2644 | inL = inR; |
2651 | inL.setResource( 0 ); | 2645 | inL.setResource( 0 ); |
2652 | local->insertAddressee( inL , false); | 2646 | local->insertAddressee( inL , false); |
2653 | ++addedAddressee; | 2647 | ++addedAddressee; |
2654 | } | 2648 | } |
2655 | } else { | 2649 | } else { |
2656 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2650 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2657 | inR.setRevision( modifiedCalendar ); | 2651 | inR.setRevision( modifiedCalendar ); |
2658 | remote->insertAddressee( inR, false ); | 2652 | remote->insertAddressee( inR, false ); |
2659 | inR.setResource( 0 ); | 2653 | inR.setResource( 0 ); |
2660 | local->insertAddressee( inR, false ); | 2654 | local->insertAddressee( inR, false ); |
2661 | ++addedAddressee; | 2655 | ++addedAddressee; |
2662 | } else { | 2656 | } else { |
2663 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2657 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2664 | remote->removeAddressee( inR ); | 2658 | remote->removeAddressee( inR ); |
2665 | ++deletedAddresseeR; | 2659 | ++deletedAddresseeR; |
2666 | } | 2660 | } |
2667 | } | 2661 | } |
2668 | } | 2662 | } |
2669 | } | 2663 | } |
2670 | ++incCounter; | 2664 | ++incCounter; |
2671 | } | 2665 | } |
2672 | er.clear(); | 2666 | er.clear(); |
2673 | QStringList el = local->uidList(); | 2667 | QStringList el = local->uidList(); |
2674 | modulo = (el.count()/10)+1; | 2668 | modulo = (el.count()/10)+1; |
2675 | 2669 | ||
2676 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2670 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2677 | incCounter = 0; | 2671 | incCounter = 0; |
2678 | while ( incCounter < el.count()) { | 2672 | while ( incCounter < el.count()) { |
2679 | qApp->processEvents(); | 2673 | qApp->processEvents(); |
2680 | if (syncManager->isProgressBarCanceled()) | 2674 | if (syncManager->isProgressBarCanceled()) |
2681 | return false; | 2675 | return false; |
2682 | if ( incCounter % modulo == 0 ) | 2676 | if ( incCounter % modulo == 0 ) |
2683 | syncManager->showProgressBar(incCounter); | 2677 | syncManager->showProgressBar(incCounter); |
2684 | uid = el[ incCounter ]; | 2678 | uid = el[ incCounter ]; |
2685 | bool skipIncidence = false; | 2679 | bool skipIncidence = false; |
2686 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2680 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2687 | skipIncidence = true; | 2681 | skipIncidence = true; |
2688 | if ( !skipIncidence ) { | 2682 | if ( !skipIncidence ) { |
2689 | inL = local->findByUid( uid ); | 2683 | inL = local->findByUid( uid ); |
2690 | inR = remote->findByUid( uid ); | 2684 | inR = remote->findByUid( uid ); |
2691 | if ( inR.isEmpty() ) { | 2685 | if ( inR.isEmpty() ) { |
2692 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2686 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2693 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2687 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2694 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2688 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2695 | local->removeAddressee( inL ); | 2689 | local->removeAddressee( inL ); |
2696 | ++deletedAddresseeL; | 2690 | ++deletedAddresseeL; |
2697 | } else { | 2691 | } else { |
2698 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2692 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2699 | inL.removeID(mCurrentSyncDevice ); | 2693 | inL.removeID(mCurrentSyncDevice ); |
2700 | ++addedAddresseeR; | 2694 | ++addedAddresseeR; |
2701 | inL.setRevision( modifiedCalendar ); | 2695 | inL.setRevision( modifiedCalendar ); |
2702 | local->insertAddressee( inL, false ); | 2696 | local->insertAddressee( inL, false ); |
2703 | inR = inL; | 2697 | inR = inL; |
2704 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2698 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2705 | inR.setResource( 0 ); | 2699 | inR.setResource( 0 ); |
2706 | remote->insertAddressee( inR, false ); | 2700 | remote->insertAddressee( inR, false ); |
2707 | } | 2701 | } |
2708 | } | 2702 | } |
2709 | } else { | 2703 | } else { |
2710 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2704 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2711 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2705 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2712 | local->removeAddressee( inL ); | 2706 | local->removeAddressee( inL ); |
2713 | ++deletedAddresseeL; | 2707 | ++deletedAddresseeL; |
2714 | } else { | 2708 | } else { |
2715 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2709 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2716 | ++addedAddresseeR; | 2710 | ++addedAddresseeR; |
2717 | inL.setRevision( modifiedCalendar ); | 2711 | inL.setRevision( modifiedCalendar ); |
2718 | local->insertAddressee( inL, false ); | 2712 | local->insertAddressee( inL, false ); |
2719 | inR = inL; | 2713 | inR = inL; |
2720 | inR.setResource( 0 ); | 2714 | inR.setResource( 0 ); |
2721 | remote->insertAddressee( inR, false ); | 2715 | remote->insertAddressee( inR, false ); |
2722 | } | 2716 | } |
2723 | } | 2717 | } |
2724 | } | 2718 | } |
2725 | } | 2719 | } |
2726 | } | 2720 | } |
2727 | ++incCounter; | 2721 | ++incCounter; |
2728 | } | 2722 | } |
2729 | el.clear(); | 2723 | el.clear(); |
2730 | syncManager->hideProgressBar(); | 2724 | syncManager->hideProgressBar(); |
2731 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2725 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2732 | // get rid of micro seconds | 2726 | // get rid of micro seconds |
2733 | QTime t = mLastAddressbookSync.time(); | 2727 | QTime t = mLastAddressbookSync.time(); |
2734 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2728 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2735 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2729 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2736 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2730 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2737 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2731 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2738 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2732 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2739 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2733 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2740 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2734 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2741 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2735 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2742 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2736 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2743 | addresseeRSync.setNote( "" ) ; | 2737 | addresseeRSync.setNote( "" ) ; |
2744 | addresseeLSync.setNote( "" ); | 2738 | addresseeLSync.setNote( "" ); |
2745 | 2739 | ||
2746 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2740 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2747 | remote->insertAddressee( addresseeRSync, false ); | 2741 | remote->insertAddressee( addresseeRSync, false ); |
2748 | local->insertAddressee( addresseeLSync, false ); | 2742 | local->insertAddressee( addresseeLSync, false ); |
2749 | QString mes; | 2743 | QString mes; |
2750 | 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 ); | 2744 | 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 ); |
2751 | if ( syncManager->mShowSyncSummary ) { | 2745 | if ( syncManager->mShowSyncSummary ) { |
2752 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2746 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2753 | } | 2747 | } |
2754 | qDebug( mes ); | 2748 | qDebug( mes ); |
2755 | return syncOK; | 2749 | return syncOK; |
2756 | } | 2750 | } |
2757 | 2751 | ||
2758 | 2752 | ||
2759 | //this is a overwritten callbackmethods from the syncinterface | 2753 | //this is a overwritten callbackmethods from the syncinterface |
2760 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2754 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2761 | { | 2755 | { |
2762 | 2756 | ||
2763 | //pending prepare addresseeview for output | 2757 | //pending prepare addresseeview for output |
2764 | //pending detect, if remote file has REV field. if not switch to external sync | 2758 | //pending detect, if remote file has REV field. if not switch to external sync |
2765 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2759 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2766 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2760 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2767 | 2761 | ||
2768 | AddressBook abLocal(filename,"syncContact"); | 2762 | AddressBook abLocal(filename,"syncContact"); |
2769 | bool syncOK = false; | 2763 | bool syncOK = false; |
2770 | if ( abLocal.load() ) { | 2764 | if ( abLocal.load() ) { |
2771 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2765 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2772 | bool external = false; | 2766 | bool external = false; |
2773 | bool isXML = false; | 2767 | bool isXML = false; |
2774 | if ( filename.right(4) == ".xml") { | 2768 | if ( filename.right(4) == ".xml") { |
2775 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2769 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2776 | isXML = true; | 2770 | isXML = true; |
2777 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2771 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2778 | } else { | 2772 | } else { |
2779 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2773 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2780 | if ( ! lse.isEmpty() ) { | 2774 | if ( ! lse.isEmpty() ) { |
2781 | if ( lse.familyName().left(4) == "!E: " ) | 2775 | if ( lse.familyName().left(4) == "!E: " ) |
2782 | external = true; | 2776 | external = true; |
2783 | } else { | 2777 | } else { |
2784 | bool found = false; | 2778 | bool found = false; |
2785 | AddressBook::Iterator it; | 2779 | AddressBook::Iterator it; |
2786 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2780 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2787 | if ( (*it).revision().date().year() > 2003 ) { | 2781 | if ( (*it).revision().date().year() > 2003 ) { |
2788 | found = true; | 2782 | found = true; |
2789 | break; | 2783 | break; |
2790 | } | 2784 | } |
2791 | } | 2785 | } |
2792 | external = ! found; | 2786 | external = ! found; |
2793 | } | 2787 | } |
2794 | 2788 | ||
2795 | if ( external ) { | 2789 | if ( external ) { |
2796 | qDebug("Setting vcf mode to external "); | 2790 | qDebug("Setting vcf mode to external "); |
2797 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2791 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2798 | AddressBook::Iterator it; | 2792 | AddressBook::Iterator it; |
2799 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2793 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2800 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2794 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2801 | (*it).computeCsum( mCurrentSyncDevice ); | 2795 | (*it).computeCsum( mCurrentSyncDevice ); |
2802 | } | 2796 | } |
2803 | } | 2797 | } |
2804 | } | 2798 | } |
2805 | //AddressBook::Iterator it; | 2799 | //AddressBook::Iterator it; |
2806 | //QStringList vcards; | 2800 | //QStringList vcards; |
2807 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2801 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2808 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2802 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2809 | //} | 2803 | //} |
2810 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2804 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2811 | if ( syncOK ) { | 2805 | if ( syncOK ) { |
2812 | if ( syncManager->mWriteBackFile ) | 2806 | if ( syncManager->mWriteBackFile ) |
2813 | { | 2807 | { |
2814 | if ( external ) | 2808 | if ( external ) |
2815 | abLocal.removeSyncAddressees( !isXML); | 2809 | abLocal.removeSyncAddressees( !isXML); |
2816 | qDebug("Saving remote AB "); | 2810 | qDebug("Saving remote AB "); |
2817 | abLocal.saveAB(); | 2811 | abLocal.saveAB(); |
2818 | if ( isXML ) { | 2812 | if ( isXML ) { |
2819 | // afterwrite processing | 2813 | // afterwrite processing |
2820 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2814 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2821 | } | 2815 | } |
2822 | } | 2816 | } |
2823 | } | 2817 | } |
2824 | setModified(); | 2818 | setModified(); |
2825 | 2819 | ||
2826 | } | 2820 | } |
2827 | if ( syncOK ) | 2821 | if ( syncOK ) |
2828 | mViewManager->refreshView(); | 2822 | mViewManager->refreshView(); |
2829 | return syncOK; | 2823 | return syncOK; |
2830 | #if 0 | 2824 | #if 0 |
2831 | 2825 | ||
2832 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2826 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2833 | getEventViewerDialog()->setSyncMode( true ); | 2827 | getEventViewerDialog()->setSyncMode( true ); |
2834 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2828 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2835 | getEventViewerDialog()->setSyncMode( false ); | 2829 | getEventViewerDialog()->setSyncMode( false ); |
2836 | if ( syncOK ) { | 2830 | if ( syncOK ) { |
2837 | if ( KOPrefs::instance()->mWriteBackFile ) | 2831 | if ( KOPrefs::instance()->mWriteBackFile ) |
2838 | { | 2832 | { |
2839 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2833 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2840 | storage->save(); | 2834 | storage->save(); |
2841 | } | 2835 | } |
2842 | } | 2836 | } |
2843 | setModified(); | 2837 | setModified(); |
2844 | } | 2838 | } |
2845 | 2839 | ||
2846 | #endif | 2840 | #endif |
2847 | } | 2841 | } |
2848 | 2842 | ||
2849 | 2843 | ||
2850 | //this is a overwritten callbackmethods from the syncinterface | 2844 | //this is a overwritten callbackmethods from the syncinterface |
2851 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2845 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2852 | { | 2846 | { |
2853 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2847 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2854 | 2848 | ||
2855 | AddressBook abLocal( resource,"syncContact"); | 2849 | AddressBook abLocal( resource,"syncContact"); |
2856 | bool syncOK = false; | 2850 | bool syncOK = false; |
2857 | if ( abLocal.load() ) { | 2851 | if ( abLocal.load() ) { |
2858 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2852 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2859 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2853 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2860 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2854 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2861 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2855 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2862 | if ( syncOK ) { | 2856 | if ( syncOK ) { |
2863 | if ( syncManager->mWriteBackFile ) { | 2857 | if ( syncManager->mWriteBackFile ) { |
2864 | abLocal.saveAB(); | 2858 | abLocal.saveAB(); |
2865 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2859 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2866 | } | 2860 | } |
2867 | } | 2861 | } |
2868 | setModified(); | 2862 | setModified(); |
2869 | } | 2863 | } |
2870 | if ( syncOK ) | 2864 | if ( syncOK ) |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index c628399..43c5f99 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,482 +1,483 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KABCORE_H | 24 | #ifndef KABCORE_H |
25 | #define KABCORE_H | 25 | #define KABCORE_H |
26 | 26 | ||
27 | #include <kabc/field.h> | 27 | #include <kabc/field.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | 32 | ||
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <ksyncmanager.h> | 35 | #include <ksyncmanager.h> |
36 | 36 | ||
37 | namespace KABC { | 37 | namespace KABC { |
38 | class AddressBook; | 38 | class AddressBook; |
39 | } | 39 | } |
40 | 40 | ||
41 | #ifndef KAB_EMBEDDED | 41 | #ifndef KAB_EMBEDDED |
42 | class KAboutData; | 42 | class KAboutData; |
43 | class KConfig; | 43 | class KConfig; |
44 | 44 | ||
45 | class KAddressBookService; | 45 | class KAddressBookService; |
46 | class LDAPSearchDialog; | 46 | class LDAPSearchDialog; |
47 | #else //KAB_EMBEDDED | 47 | #else //KAB_EMBEDDED |
48 | class KAddressBookMain; | 48 | class KAddressBookMain; |
49 | //US class QAction; | 49 | //US class QAction; |
50 | #endif //KAB_EMBEDDED | 50 | #endif //KAB_EMBEDDED |
51 | class KCMultiDialog; | 51 | class KCMultiDialog; |
52 | class KXMLGUIClient; | 52 | class KXMLGUIClient; |
53 | class ExtensionManager; | 53 | class ExtensionManager; |
54 | class XXPortManager; | 54 | class XXPortManager; |
55 | class JumpButtonBar; | 55 | class JumpButtonBar; |
56 | class IncSearchWidget; | 56 | class IncSearchWidget; |
57 | class KDGanttMinimizeSplitter; | 57 | class KDGanttMinimizeSplitter; |
58 | class KAction; | 58 | class KAction; |
59 | class KActionCollection; | 59 | class KActionCollection; |
60 | class KToggleAction; | 60 | class KToggleAction; |
61 | class KSyncProfile; | 61 | class KSyncProfile; |
62 | 62 | ||
63 | class QAction; | 63 | class QAction; |
64 | class QMenuBar; | 64 | class QMenuBar; |
65 | class QSplitter; | 65 | class QSplitter; |
66 | class ViewContainer; | 66 | class ViewContainer; |
67 | class ViewManager; | 67 | class ViewManager; |
68 | class AddresseeEditorDialog; | 68 | class AddresseeEditorDialog; |
69 | class Ir; | 69 | class Ir; |
70 | 70 | ||
71 | class KABCore : public QWidget, public KSyncInterface | 71 | class KABCore : public QWidget, public KSyncInterface |
72 | { | 72 | { |
73 | Q_OBJECT | 73 | Q_OBJECT |
74 | 74 | ||
75 | public: | 75 | public: |
76 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 76 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
77 | 77 | ||
78 | 78 | ||
79 | ~KABCore(); | 79 | ~KABCore(); |
80 | 80 | ||
81 | 81 | ||
82 | #ifdef KAB_EMBEDDED | 82 | #ifdef KAB_EMBEDDED |
83 | //US added functionality | 83 | //US added functionality |
84 | QPopupMenu* getViewMenu() {return viewMenu;} | 84 | QPopupMenu* getViewMenu() {return viewMenu;} |
85 | QPopupMenu* getFilterMenu() {return filterMenu;} | 85 | QPopupMenu* getFilterMenu() {return filterMenu;} |
86 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 86 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
87 | void addActionsManually(); | 87 | void addActionsManually(); |
88 | #endif //KAB_EMBEDDED | 88 | #endif //KAB_EMBEDDED |
89 | /** | 89 | /** |
90 | Restores the global settings. | 90 | Restores the global settings. |
91 | */ | 91 | */ |
92 | void restoreSettings(); | 92 | void restoreSettings(); |
93 | 93 | ||
94 | /** | 94 | /** |
95 | Saves the global settings. | 95 | Saves the global settings. |
96 | */ | 96 | */ |
97 | void saveSettings(); | 97 | void saveSettings(); |
98 | 98 | ||
99 | /** | 99 | /** |
100 | Returns a pointer to the StdAddressBook of the application. | 100 | Returns a pointer to the StdAddressBook of the application. |
101 | */ | 101 | */ |
102 | KABC::AddressBook *addressBook() const; | 102 | KABC::AddressBook *addressBook() const; |
103 | 103 | ||
104 | /** | 104 | /** |
105 | Returns a pointer to the KConfig object of the application. | 105 | Returns a pointer to the KConfig object of the application. |
106 | */ | 106 | */ |
107 | static KConfig *config(); | 107 | static KConfig *config(); |
108 | 108 | ||
109 | /** | 109 | /** |
110 | Returns a pointer to the global KActionCollection object. So | 110 | Returns a pointer to the global KActionCollection object. So |
111 | other classes can register their actions easily. | 111 | other classes can register their actions easily. |
112 | */ | 112 | */ |
113 | KActionCollection *actionCollection() const; | 113 | KActionCollection *actionCollection() const; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | Returns the current search field of the Incremental Search Widget. | 116 | Returns the current search field of the Incremental Search Widget. |
117 | */ | 117 | */ |
118 | KABC::Field *currentSearchField() const; | 118 | KABC::Field *currentSearchField() const; |
119 | 119 | ||
120 | /** | 120 | /** |
121 | Returns the uid list of the currently selected contacts. | 121 | Returns the uid list of the currently selected contacts. |
122 | */ | 122 | */ |
123 | QStringList selectedUIDs() const; | 123 | QStringList selectedUIDs() const; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | Displays the ResourceSelectDialog and returns the selected | 126 | Displays the ResourceSelectDialog and returns the selected |
127 | resource or a null pointer if no resource was selected by | 127 | resource or a null pointer if no resource was selected by |
128 | the user. | 128 | the user. |
129 | */ | 129 | */ |
130 | KABC::Resource *requestResource( QWidget *parent ); | 130 | KABC::Resource *requestResource( QWidget *parent ); |
131 | 131 | ||
132 | #ifndef KAB_EMBEDDED | 132 | #ifndef KAB_EMBEDDED |
133 | static KAboutData *createAboutData(); | 133 | static KAboutData *createAboutData(); |
134 | #endif //KAB_EMBEDDED | 134 | #endif //KAB_EMBEDDED |
135 | 135 | ||
136 | #ifdef KAB_EMBEDDED | 136 | #ifdef KAB_EMBEDDED |
137 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 137 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
138 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 138 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
139 | #endif //KAB_EMBEDDED | 139 | #endif //KAB_EMBEDDED |
140 | 140 | ||
141 | public slots: | 141 | public slots: |
142 | #ifdef KAB_EMBEDDED | 142 | #ifdef KAB_EMBEDDED |
143 | void createAboutData(); | 143 | void createAboutData(); |
144 | #endif //KAB_EMBEDDED | 144 | #endif //KAB_EMBEDDED |
145 | 145 | ||
146 | void statusMessage(QString, int time = 0 ); | 146 | void statusMessage(QString, int time = 0 ); |
147 | void showLicence(); | 147 | void showLicence(); |
148 | void faq(); | 148 | void faq(); |
149 | 149 | ||
150 | /** | 150 | /** |
151 | Is called whenever a contact is selected in the view. | 151 | Is called whenever a contact is selected in the view. |
152 | */ | 152 | */ |
153 | void setContactSelected( const QString &uid ); | 153 | void setContactSelected( const QString &uid ); |
154 | 154 | ||
155 | /** | 155 | /** |
156 | Opens the preferred mail composer with all selected contacts as | 156 | Opens the preferred mail composer with all selected contacts as |
157 | arguments. | 157 | arguments. |
158 | */ | 158 | */ |
159 | void sendMail(); | 159 | void sendMail(); |
160 | 160 | ||
161 | /** | 161 | /** |
162 | Opens the preferred mail composer with the given contacts as | 162 | Opens the preferred mail composer with the given contacts as |
163 | arguments. | 163 | arguments. |
164 | */ | 164 | */ |
165 | void sendMail( const QString& email ); | 165 | void sendMail( const QString& email ); |
166 | 166 | ||
167 | 167 | ||
168 | void mailVCard(); | 168 | void mailVCard(); |
169 | void mailVCard(const QStringList& uids); | 169 | void mailVCard(const QStringList& uids); |
170 | 170 | ||
171 | /** | 171 | /** |
172 | Beams the "WhoAmI contact. | 172 | Beams the "WhoAmI contact. |
173 | */ | 173 | */ |
174 | void beamMySelf(); | 174 | void beamMySelf(); |
175 | 175 | ||
176 | void beamVCard(); | 176 | void beamVCard(); |
177 | void export2phone(); | 177 | void export2phone(); |
178 | void beamVCard(const QStringList& uids); | 178 | void beamVCard(const QStringList& uids); |
179 | void beamDone( Ir *ir ); | 179 | void beamDone( Ir *ir ); |
180 | 180 | ||
181 | 181 | ||
182 | /** | 182 | /** |
183 | Starts the preferred web browser with the given URL as argument. | 183 | Starts the preferred web browser with the given URL as argument. |
184 | */ | 184 | */ |
185 | void browse( const QString& url ); | 185 | void browse( const QString& url ); |
186 | 186 | ||
187 | /** | 187 | /** |
188 | Select all contacts in the view. | 188 | Select all contacts in the view. |
189 | */ | 189 | */ |
190 | void selectAllContacts(); | 190 | void selectAllContacts(); |
191 | 191 | ||
192 | /** | 192 | /** |
193 | Deletes all selected contacts from the address book. | 193 | Deletes all selected contacts from the address book. |
194 | */ | 194 | */ |
195 | void deleteContacts(); | 195 | void deleteContacts(); |
196 | 196 | ||
197 | /** | 197 | /** |
198 | Deletes given contacts from the address book. | 198 | Deletes given contacts from the address book. |
199 | 199 | ||
200 | @param uids The uids of the contacts, which shall be deleted. | 200 | @param uids The uids of the contacts, which shall be deleted. |
201 | */ | 201 | */ |
202 | void deleteContacts( const QStringList &uids ); | 202 | void deleteContacts( const QStringList &uids ); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | Copys the selected contacts into clipboard for later pasting. | 205 | Copys the selected contacts into clipboard for later pasting. |
206 | */ | 206 | */ |
207 | void copyContacts(); | 207 | void copyContacts(); |
208 | 208 | ||
209 | /** | 209 | /** |
210 | Cuts the selected contacts and stores them for later pasting. | 210 | Cuts the selected contacts and stores them for later pasting. |
211 | */ | 211 | */ |
212 | void cutContacts(); | 212 | void cutContacts(); |
213 | 213 | ||
214 | /** | 214 | /** |
215 | Paste contacts from clipboard into the address book. | 215 | Paste contacts from clipboard into the address book. |
216 | */ | 216 | */ |
217 | void pasteContacts(); | 217 | void pasteContacts(); |
218 | 218 | ||
219 | /** | 219 | /** |
220 | Paste given contacts into the address book. | 220 | Paste given contacts into the address book. |
221 | 221 | ||
222 | @param list The list of addressee, which shall be pasted. | 222 | @param list The list of addressee, which shall be pasted. |
223 | */ | 223 | */ |
224 | void pasteContacts( KABC::Addressee::List &list ); | 224 | void pasteContacts( KABC::Addressee::List &list ); |
225 | 225 | ||
226 | /** | 226 | /** |
227 | Sets the whoAmI contact, that is used by many other programs to | 227 | Sets the whoAmI contact, that is used by many other programs to |
228 | get personal information about the current user. | 228 | get personal information about the current user. |
229 | */ | 229 | */ |
230 | void setWhoAmI(); | 230 | void setWhoAmI(); |
231 | 231 | ||
232 | /** | 232 | /** |
233 | Displays the category dialog and applies the result to all | 233 | Displays the category dialog and applies the result to all |
234 | selected contacts. | 234 | selected contacts. |
235 | */ | 235 | */ |
236 | void setCategories(); | 236 | void setCategories(); |
237 | 237 | ||
238 | /** | 238 | /** |
239 | Sets the field list of the Incremental Search Widget. | 239 | Sets the field list of the Incremental Search Widget. |
240 | */ | 240 | */ |
241 | void setSearchFields( const KABC::Field::List &fields ); | 241 | void setSearchFields( const KABC::Field::List &fields ); |
242 | 242 | ||
243 | /** | 243 | /** |
244 | Search with the current search field for a contact, that matches | 244 | Search with the current search field for a contact, that matches |
245 | the given text, and selects it in the view. | 245 | the given text, and selects it in the view. |
246 | */ | 246 | */ |
247 | void incrementalSearch( const QString& text ); | 247 | void incrementalSearch( const QString& text ); |
248 | 248 | ||
249 | /** | 249 | /** |
250 | Marks the address book as modified. | 250 | Marks the address book as modified. |
251 | */ | 251 | */ |
252 | void setModified(); | 252 | void setModified(); |
253 | /** | 253 | /** |
254 | Marks the address book as modified without refreshing the view. | 254 | Marks the address book as modified without refreshing the view. |
255 | */ | 255 | */ |
256 | void setModifiedWOrefresh(); | 256 | void setModifiedWOrefresh(); |
257 | 257 | ||
258 | /** | 258 | /** |
259 | Marks the address book as modified concerning the argument. | 259 | Marks the address book as modified concerning the argument. |
260 | */ | 260 | */ |
261 | void setModified( bool modified ); | 261 | void setModified( bool modified ); |
262 | 262 | ||
263 | /** | 263 | /** |
264 | Returns whether the address book is modified. | 264 | Returns whether the address book is modified. |
265 | */ | 265 | */ |
266 | bool modified() const; | 266 | bool modified() const; |
267 | 267 | ||
268 | /** | 268 | /** |
269 | Called whenever an contact is modified in the contact editor | 269 | Called whenever an contact is modified in the contact editor |
270 | dialog or the quick edit. | 270 | dialog or the quick edit. |
271 | */ | 271 | */ |
272 | void contactModified( const KABC::Addressee &addr ); | 272 | void contactModified( const KABC::Addressee &addr ); |
273 | 273 | ||
274 | /** | 274 | /** |
275 | DCOP METHODS. | 275 | DCOP METHODS. |
276 | */ | 276 | */ |
277 | void addEmail( QString addr ); | 277 | void addEmail( QString addr ); |
278 | void importVCard( const KURL& url, bool showPreview ); | 278 | void importVCard( const KURL& url, bool showPreview ); |
279 | void importVCard( const QString& vCard, bool showPreview ); | 279 | void importVCard( const QString& vCard, bool showPreview ); |
280 | void newContact(); | 280 | void newContact(); |
281 | QString getNameByPhone( const QString& phone ); | 281 | QString getNameByPhone( const QString& phone ); |
282 | /** | 282 | /** |
283 | END DCOP METHODS | 283 | END DCOP METHODS |
284 | */ | 284 | */ |
285 | 285 | ||
286 | /** | 286 | /** |
287 | Saves the contents of the AddressBook back to disk. | 287 | Saves the contents of the AddressBook back to disk. |
288 | */ | 288 | */ |
289 | void save(); | 289 | void save(); |
290 | 290 | ||
291 | /** | 291 | /** |
292 | Undos the last command using the undo stack. | 292 | Undos the last command using the undo stack. |
293 | */ | 293 | */ |
294 | void undo(); | 294 | void undo(); |
295 | 295 | ||
296 | /** | 296 | /** |
297 | Redos the last command that was undone, using the redo stack. | 297 | Redos the last command that was undone, using the redo stack. |
298 | */ | 298 | */ |
299 | void redo(); | 299 | void redo(); |
300 | 300 | ||
301 | /** | 301 | /** |
302 | Shows the edit dialog for the given uid. If the uid is QString::null, | 302 | Shows the edit dialog for the given uid. If the uid is QString::null, |
303 | the method will try to find a selected addressee in the view. | 303 | the method will try to find a selected addressee in the view. |
304 | */ | 304 | */ |
305 | void editContact( const QString &uid /*US = QString::null*/ ); | 305 | void editContact( const QString &uid /*US = QString::null*/ ); |
306 | //US added a second method without defaultparameter | 306 | //US added a second method without defaultparameter |
307 | void editContact2(); | 307 | void editContact2(); |
308 | 308 | ||
309 | /** | 309 | /** |
310 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 310 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
311 | the method will try to find a selected addressee in the view. | 311 | the method will try to find a selected addressee in the view. |
312 | */ | 312 | */ |
313 | void executeContact( const QString &uid /*US = QString::null*/ ); | 313 | void executeContact( const QString &uid /*US = QString::null*/ ); |
314 | 314 | ||
315 | /** | 315 | /** |
316 | Launches the configuration dialog. | 316 | Launches the configuration dialog. |
317 | */ | 317 | */ |
318 | void openConfigDialog(); | 318 | void openConfigDialog(); |
319 | 319 | ||
320 | /** | 320 | /** |
321 | Launches the ldap search dialog. | 321 | Launches the ldap search dialog. |
322 | */ | 322 | */ |
323 | void openLDAPDialog(); | 323 | void openLDAPDialog(); |
324 | 324 | ||
325 | /** | 325 | /** |
326 | Creates a KAddressBookPrinter, which will display the print | 326 | Creates a KAddressBookPrinter, which will display the print |
327 | dialog and do the printing. | 327 | dialog and do the printing. |
328 | */ | 328 | */ |
329 | void print(); | 329 | void print(); |
330 | 330 | ||
331 | /** | 331 | /** |
332 | Registers a new GUI client, so plugins can register its actions. | 332 | Registers a new GUI client, so plugins can register its actions. |
333 | */ | 333 | */ |
334 | void addGUIClient( KXMLGUIClient *client ); | 334 | void addGUIClient( KXMLGUIClient *client ); |
335 | 335 | ||
336 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 336 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
337 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 337 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
338 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); | 338 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |
339 | 339 | ||
340 | 340 | ||
341 | signals: | 341 | signals: |
342 | void contactSelected( const QString &name ); | 342 | void contactSelected( const QString &name ); |
343 | void contactSelected( const QPixmap &pixmap ); | 343 | void contactSelected( const QPixmap &pixmap ); |
344 | public slots: | 344 | public slots: |
345 | void recieve(QString cmsg ); | ||
345 | void getFile( bool success ); | 346 | void getFile( bool success ); |
346 | void syncFileRequest(); | 347 | void syncFileRequest(); |
347 | void setDetailsVisible( bool visible ); | 348 | void setDetailsVisible( bool visible ); |
348 | void setDetailsToState(); | 349 | void setDetailsToState(); |
349 | // void slotSyncMenu( int ); | 350 | // void slotSyncMenu( int ); |
350 | private slots: | 351 | private slots: |
351 | void setJumpButtonBarVisible( bool visible ); | 352 | void setJumpButtonBarVisible( bool visible ); |
352 | void setCaptionBack(); | 353 | void setCaptionBack(); |
353 | void importFromOL(); | 354 | void importFromOL(); |
354 | void extensionModified( const KABC::Addressee::List &list ); | 355 | void extensionModified( const KABC::Addressee::List &list ); |
355 | void extensionChanged( int id ); | 356 | void extensionChanged( int id ); |
356 | void clipboardDataChanged(); | 357 | void clipboardDataChanged(); |
357 | void updateActionMenu(); | 358 | void updateActionMenu(); |
358 | void configureKeyBindings(); | 359 | void configureKeyBindings(); |
359 | void removeVoice(); | 360 | void removeVoice(); |
360 | #ifdef KAB_EMBEDDED | 361 | #ifdef KAB_EMBEDDED |
361 | void configureResources(); | 362 | void configureResources(); |
362 | #endif //KAB_EMBEDDED | 363 | #endif //KAB_EMBEDDED |
363 | 364 | ||
364 | void slotEditorDestroyed( const QString &uid ); | 365 | void slotEditorDestroyed( const QString &uid ); |
365 | void configurationChanged(); | 366 | void configurationChanged(); |
366 | void addressBookChanged(); | 367 | void addressBookChanged(); |
367 | 368 | ||
368 | private: | 369 | private: |
369 | void initGUI(); | 370 | void initGUI(); |
370 | void initActions(); | 371 | void initActions(); |
371 | 372 | ||
372 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 373 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
373 | const char *name = 0 ); | 374 | const char *name = 0 ); |
374 | 375 | ||
375 | KXMLGUIClient *mGUIClient; | 376 | KXMLGUIClient *mGUIClient; |
376 | 377 | ||
377 | KABC::AddressBook *mAddressBook; | 378 | KABC::AddressBook *mAddressBook; |
378 | 379 | ||
379 | ViewManager *mViewManager; | 380 | ViewManager *mViewManager; |
380 | // QSplitter *mDetailsSplitter; | 381 | // QSplitter *mDetailsSplitter; |
381 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 382 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
382 | ViewContainer *mDetails; | 383 | ViewContainer *mDetails; |
383 | KDGanttMinimizeSplitter* mMiniSplitter; | 384 | KDGanttMinimizeSplitter* mMiniSplitter; |
384 | XXPortManager *mXXPortManager; | 385 | XXPortManager *mXXPortManager; |
385 | JumpButtonBar *mJumpButtonBar; | 386 | JumpButtonBar *mJumpButtonBar; |
386 | IncSearchWidget *mIncSearchWidget; | 387 | IncSearchWidget *mIncSearchWidget; |
387 | ExtensionManager *mExtensionManager; | 388 | ExtensionManager *mExtensionManager; |
388 | 389 | ||
389 | KCMultiDialog *mConfigureDialog; | 390 | KCMultiDialog *mConfigureDialog; |
390 | 391 | ||
391 | #ifndef KAB_EMBEDDED | 392 | #ifndef KAB_EMBEDDED |
392 | LDAPSearchDialog *mLdapSearchDialog; | 393 | LDAPSearchDialog *mLdapSearchDialog; |
393 | #endif //KAB_EMBEDDED | 394 | #endif //KAB_EMBEDDED |
394 | // QDict<AddresseeEditorDialog> mEditorDict; | 395 | // QDict<AddresseeEditorDialog> mEditorDict; |
395 | AddresseeEditorDialog *mEditorDialog; | 396 | AddresseeEditorDialog *mEditorDialog; |
396 | bool mReadWrite; | 397 | bool mReadWrite; |
397 | bool mModified; | 398 | bool mModified; |
398 | bool mIsPart; | 399 | bool mIsPart; |
399 | bool mMultipleViewsAtOnce; | 400 | bool mMultipleViewsAtOnce; |
400 | 401 | ||
401 | 402 | ||
402 | //US file menu | 403 | //US file menu |
403 | KAction *mActionMail; | 404 | KAction *mActionMail; |
404 | KAction *mActionBeam; | 405 | KAction *mActionBeam; |
405 | KAction *mActionExport2phone; | 406 | KAction *mActionExport2phone; |
406 | KAction* mActionPrint; | 407 | KAction* mActionPrint; |
407 | KAction* mActionNewContact; | 408 | KAction* mActionNewContact; |
408 | KAction *mActionSave; | 409 | KAction *mActionSave; |
409 | KAction *mActionEditAddressee; | 410 | KAction *mActionEditAddressee; |
410 | KAction *mActionMailVCard; | 411 | KAction *mActionMailVCard; |
411 | KAction *mActionBeamVCard; | 412 | KAction *mActionBeamVCard; |
412 | 413 | ||
413 | KAction *mActionQuit; | 414 | KAction *mActionQuit; |
414 | 415 | ||
415 | //US edit menu | 416 | //US edit menu |
416 | KAction *mActionCopy; | 417 | KAction *mActionCopy; |
417 | KAction *mActionCut; | 418 | KAction *mActionCut; |
418 | KAction *mActionPaste; | 419 | KAction *mActionPaste; |
419 | KAction *mActionSelectAll; | 420 | KAction *mActionSelectAll; |
420 | KAction *mActionUndo; | 421 | KAction *mActionUndo; |
421 | KAction *mActionRedo; | 422 | KAction *mActionRedo; |
422 | KAction *mActionDelete; | 423 | KAction *mActionDelete; |
423 | 424 | ||
424 | //US settings menu | 425 | //US settings menu |
425 | KAction *mActionConfigResources; | 426 | KAction *mActionConfigResources; |
426 | KAction *mActionConfigKAddressbook; | 427 | KAction *mActionConfigKAddressbook; |
427 | KAction *mActionConfigShortcuts; | 428 | KAction *mActionConfigShortcuts; |
428 | KAction *mActionConfigureToolbars; | 429 | KAction *mActionConfigureToolbars; |
429 | KAction *mActionKeyBindings; | 430 | KAction *mActionKeyBindings; |
430 | KToggleAction *mActionJumpBar; | 431 | KToggleAction *mActionJumpBar; |
431 | KToggleAction *mActionDetails; | 432 | KToggleAction *mActionDetails; |
432 | KAction *mActionWhoAmI; | 433 | KAction *mActionWhoAmI; |
433 | KAction *mActionCategories; | 434 | KAction *mActionCategories; |
434 | KAction *mActionAboutKAddressbook; | 435 | KAction *mActionAboutKAddressbook; |
435 | KAction *mActionLicence; | 436 | KAction *mActionLicence; |
436 | KAction *mActionFaq; | 437 | KAction *mActionFaq; |
437 | 438 | ||
438 | KAction *mActionDeleteView; | 439 | KAction *mActionDeleteView; |
439 | 440 | ||
440 | QPopupMenu *viewMenu; | 441 | QPopupMenu *viewMenu; |
441 | QPopupMenu *filterMenu; | 442 | QPopupMenu *filterMenu; |
442 | QPopupMenu *settingsMenu; | 443 | QPopupMenu *settingsMenu; |
443 | QPopupMenu *changeMenu; | 444 | QPopupMenu *changeMenu; |
444 | //US QAction *mActionSave; | 445 | //US QAction *mActionSave; |
445 | QPopupMenu *ImportMenu; | 446 | QPopupMenu *ImportMenu; |
446 | QPopupMenu *ExportMenu; | 447 | QPopupMenu *ExportMenu; |
447 | //LR additional methods | 448 | //LR additional methods |
448 | KAction *mActionRemoveVoice; | 449 | KAction *mActionRemoveVoice; |
449 | KAction * mActionImportOL; | 450 | KAction * mActionImportOL; |
450 | 451 | ||
451 | #ifndef KAB_EMBEDDED | 452 | #ifndef KAB_EMBEDDED |
452 | KAddressBookService *mAddressBookService; | 453 | KAddressBookService *mAddressBookService; |
453 | #endif //KAB_EMBEDDED | 454 | #endif //KAB_EMBEDDED |
454 | 455 | ||
455 | class KABCorePrivate; | 456 | class KABCorePrivate; |
456 | KABCorePrivate *d; | 457 | KABCorePrivate *d; |
457 | //US bool mBlockSaveFlag; | 458 | //US bool mBlockSaveFlag; |
458 | 459 | ||
459 | #ifdef KAB_EMBEDDED | 460 | #ifdef KAB_EMBEDDED |
460 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 461 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
461 | #endif //KAB_EMBEDDED | 462 | #endif //KAB_EMBEDDED |
462 | 463 | ||
463 | //this are the overwritten callbackmethods from the syncinterface | 464 | //this are the overwritten callbackmethods from the syncinterface |
464 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
465 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 466 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
466 | 467 | ||
467 | 468 | ||
468 | // LR ******************************* | 469 | // LR ******************************* |
469 | // sync stuff! | 470 | // sync stuff! |
470 | QString sentSyncFile(); | 471 | QString sentSyncFile(); |
471 | QPopupMenu *syncMenu; | 472 | QPopupMenu *syncMenu; |
472 | KSyncManager* syncManager; | 473 | KSyncManager* syncManager; |
473 | int mGlobalSyncMode; | 474 | int mGlobalSyncMode; |
474 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 475 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
475 | KABC::Addressee getLastSyncAddressee(); | 476 | KABC::Addressee getLastSyncAddressee(); |
476 | QDateTime mLastAddressbookSync; | 477 | QDateTime mLastAddressbookSync; |
477 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 478 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
478 | // ********************* | 479 | // ********************* |
479 | 480 | ||
480 | }; | 481 | }; |
481 | 482 | ||
482 | #endif | 483 | #endif |
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index f48f214..8c4ca09 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp | |||
@@ -1,240 +1,250 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 1999 Don Sanders <dsanders@kde.org> | 3 | Copyright (c) 1999 Don Sanders <dsanders@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 | #ifdef KAB_EMBEDDED | 24 | #ifdef KAB_EMBEDDED |
25 | #include "kabprefs.h" | 25 | #include "kabprefs.h" |
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtoolbar.h> | 28 | #include <qtoolbar.h> |
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | #else //KAB_EMBEDDED | 30 | #else //KAB_EMBEDDED |
31 | #include <kedittoolbar.h> | 31 | #include <kedittoolbar.h> |
32 | #include <kkeydialog.h> | 32 | #include <kkeydialog.h> |
33 | #include <kmessagebox.h> | 33 | #include <kmessagebox.h> |
34 | #include <kstatusbar.h> | 34 | #include <kstatusbar.h> |
35 | #endif //KAB_EMBEDDED | 35 | #endif //KAB_EMBEDDED |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | 37 | ||
38 | #include "kabcore.h" | 38 | #include "kabcore.h" |
39 | #include "kaddressbookmain.h" | 39 | #include "kaddressbookmain.h" |
40 | #include "kactioncollection.h" | 40 | #include "kactioncollection.h" |
41 | 41 | ||
42 | #ifdef KAB_EMBEDDED | 42 | #ifdef KAB_EMBEDDED |
43 | KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) | 43 | KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) |
44 | #else //KAB_EMBEDDED | 44 | #else //KAB_EMBEDDED |
45 | //MOC_SKIP_BEGIN | 45 | //MOC_SKIP_BEGIN |
46 | KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) | 46 | KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) |
47 | //MOC_SKIP_END | 47 | //MOC_SKIP_END |
48 | #endif //KAB_EMBEDDED | 48 | #endif //KAB_EMBEDDED |
49 | { | 49 | { |
50 | 50 | ||
51 | setIcon(SmallIcon( "ka24" ) ); | 51 | setIcon(SmallIcon( "ka24" ) ); |
52 | #if 0 | 52 | #if 0 |
53 | //US for embedded systems, create the toolbar before we initiate KABCore. | 53 | //US for embedded systems, create the toolbar before we initiate KABCore. |
54 | // KABCore will fill the toolbar with menues and icons | 54 | // KABCore will fill the toolbar with menues and icons |
55 | QMainWindow::ToolBarDock tbd; | 55 | QMainWindow::ToolBarDock tbd; |
56 | tbd = Top; | 56 | tbd = Top; |
57 | iconToolBar = new QToolBar( this ); | 57 | iconToolBar = new QToolBar( this ); |
58 | addToolBar (iconToolBar , tbd ); | 58 | addToolBar (iconToolBar , tbd ); |
59 | iconToolBar->setHorizontalStretchable(true); | 59 | iconToolBar->setHorizontalStretchable(true); |
60 | //US iconToolBar->setWidth(300); | 60 | //US iconToolBar->setWidth(300); |
61 | #endif // 0 | 61 | #endif // 0 |
62 | 62 | ||
63 | mCore = new KABCore( this, true, this ); | 63 | mCore = new KABCore( this, true, this ); |
64 | 64 | ||
65 | #ifdef KAB_EMBEDDED | 65 | #ifdef KAB_EMBEDDED |
66 | setCaption( i18n( "KAddressbook/Pi" ) ); | 66 | setCaption( i18n( "KAddressbook/Pi" ) ); |
67 | #else //KAB_EMBEDDED | 67 | #else //KAB_EMBEDDED |
68 | setCaption( i18n( "Address Book Browser" ) ); | 68 | setCaption( i18n( "Address Book Browser" ) ); |
69 | #endif //KAB_EMBEDDED | 69 | #endif //KAB_EMBEDDED |
70 | 70 | ||
71 | //mCore->restoreSettings(); | 71 | //mCore->restoreSettings(); |
72 | 72 | ||
73 | initActions(); | 73 | initActions(); |
74 | 74 | ||
75 | setCentralWidget( mCore ); | 75 | setCentralWidget( mCore ); |
76 | 76 | ||
77 | //US statusBar()->show(); | 77 | //US statusBar()->show(); |
78 | 78 | ||
79 | #ifndef KAB_EMBEDDED | 79 | #ifndef KAB_EMBEDDED |
80 | setStandardToolBarMenuEnabled(true); | 80 | setStandardToolBarMenuEnabled(true); |
81 | 81 | ||
82 | createGUI( "kaddressbookui.rc", false ); | 82 | createGUI( "kaddressbookui.rc", false ); |
83 | 83 | ||
84 | 84 | ||
85 | #endif //KAB_EMBEDDED | 85 | #endif //KAB_EMBEDDED |
86 | setAutoSaveSettings(); | 86 | setAutoSaveSettings(); |
87 | qApp->processEvents(); | 87 | qApp->processEvents(); |
88 | mCore->restoreSettings(); | 88 | mCore->restoreSettings(); |
89 | } | 89 | } |
90 | 90 | ||
91 | KAddressBookMain::~KAddressBookMain() | 91 | KAddressBookMain::~KAddressBookMain() |
92 | { | 92 | { |
93 | // mCore->saveSettings(); | 93 | // mCore->saveSettings(); |
94 | } | 94 | } |
95 | 95 | void KAddressBookMain::recieve( const QCString& cmsg, const QByteArray& data ) | |
96 | { | ||
97 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); | ||
98 | if ( cmsg == "setDocument(QString)" ) { | ||
99 | QDataStream stream( data, IO_ReadOnly ); | ||
100 | QString fileName; | ||
101 | stream >> fileName; | ||
102 | mCore->recieve( fileName ); | ||
103 | return; | ||
104 | } | ||
105 | } | ||
96 | void KAddressBookMain::showMinimized () | 106 | void KAddressBookMain::showMinimized () |
97 | { | 107 | { |
98 | QWidget::showMinimized () ; | 108 | QWidget::showMinimized () ; |
99 | } | 109 | } |
100 | void KAddressBookMain::addEmail( QString addr ) | 110 | void KAddressBookMain::addEmail( QString addr ) |
101 | { | 111 | { |
102 | mCore->addEmail( addr ); | 112 | mCore->addEmail( addr ); |
103 | } | 113 | } |
104 | 114 | ||
105 | #ifndef KAB_EMBEDDED | 115 | #ifndef KAB_EMBEDDED |
106 | ASYNC KAddressBookMain::showContactEditor( QString uid ) | 116 | ASYNC KAddressBookMain::showContactEditor( QString uid ) |
107 | { | 117 | { |
108 | mCore->editContact( uid ); | 118 | mCore->editContact( uid ); |
109 | } | 119 | } |
110 | #endif //KAB_EMBEDDED | 120 | #endif //KAB_EMBEDDED |
111 | void KAddressBookMain::newContact() | 121 | void KAddressBookMain::newContact() |
112 | { | 122 | { |
113 | mCore->newContact(); | 123 | mCore->newContact(); |
114 | } | 124 | } |
115 | 125 | ||
116 | QString KAddressBookMain::getNameByPhone( QString phone ) | 126 | QString KAddressBookMain::getNameByPhone( QString phone ) |
117 | { | 127 | { |
118 | return mCore->getNameByPhone( phone ); | 128 | return mCore->getNameByPhone( phone ); |
119 | } | 129 | } |
120 | 130 | ||
121 | void KAddressBookMain::save() | 131 | void KAddressBookMain::save() |
122 | { | 132 | { |
123 | mCore->save(); | 133 | mCore->save(); |
124 | } | 134 | } |
125 | 135 | ||
126 | void KAddressBookMain::exit() | 136 | void KAddressBookMain::exit() |
127 | { | 137 | { |
128 | close( ); | 138 | close( ); |
129 | } | 139 | } |
130 | 140 | ||
131 | void KAddressBookMain::saveProperties( KConfig* ) | 141 | void KAddressBookMain::saveProperties( KConfig* ) |
132 | { | 142 | { |
133 | } | 143 | } |
134 | 144 | ||
135 | void KAddressBookMain::readProperties( KConfig* ) | 145 | void KAddressBookMain::readProperties( KConfig* ) |
136 | { | 146 | { |
137 | } | 147 | } |
138 | 148 | ||
139 | void KAddressBookMain::initActions() | 149 | void KAddressBookMain::initActions() |
140 | { | 150 | { |
141 | #ifndef KAB_EMBEDDED | 151 | #ifndef KAB_EMBEDDED |
142 | KStdAction::quit( this, SLOT( close() ), actionCollection() ); | 152 | KStdAction::quit( this, SLOT( close() ), actionCollection() ); |
143 | KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); | 153 | KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); |
144 | #else //KAB_EMBEDDED | 154 | #else //KAB_EMBEDDED |
145 | //US: transfered the setup of the actions into KABCore | 155 | //US: transfered the setup of the actions into KABCore |
146 | #endif //KAB_EMBEDDED | 156 | #endif //KAB_EMBEDDED |
147 | 157 | ||
148 | 158 | ||
149 | } | 159 | } |
150 | 160 | ||
151 | //US new method to setup menues and toolbars on embedded systems | 161 | //US new method to setup menues and toolbars on embedded systems |
152 | #ifdef KAB_EMBEDDED | 162 | #ifdef KAB_EMBEDDED |
153 | /* | 163 | /* |
154 | QToolBar * KAddressBookMain::getIconToolBar() | 164 | QToolBar * KAddressBookMain::getIconToolBar() |
155 | { | 165 | { |
156 | return iconToolBar; | 166 | return iconToolBar; |
157 | } | 167 | } |
158 | */ | 168 | */ |
159 | 169 | ||
160 | void KAddressBookMain::createGUI() | 170 | void KAddressBookMain::createGUI() |
161 | { | 171 | { |
162 | 172 | ||
163 | 173 | ||
164 | 174 | ||
165 | } | 175 | } |
166 | #endif //KAB_EMBEDDED | 176 | #endif //KAB_EMBEDDED |
167 | 177 | ||
168 | void KAddressBookMain::configureToolbars() | 178 | void KAddressBookMain::configureToolbars() |
169 | { | 179 | { |
170 | #ifndef KAB_EMBEDDED | 180 | #ifndef KAB_EMBEDDED |
171 | saveMainWindowSettings( KGlobal::config(), "MainWindow" ); | 181 | saveMainWindowSettings( KGlobal::config(), "MainWindow" ); |
172 | 182 | ||
173 | KEditToolbar dlg( factory() ); | 183 | KEditToolbar dlg( factory() ); |
174 | connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); | 184 | connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); |
175 | 185 | ||
176 | dlg.exec(); | 186 | dlg.exec(); |
177 | #else //KAB_EMBEDDED | 187 | #else //KAB_EMBEDDED |
178 | qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); | 188 | qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); |
179 | #endif //KAB_EMBEDDED | 189 | #endif //KAB_EMBEDDED |
180 | } | 190 | } |
181 | 191 | ||
182 | void KAddressBookMain::slotNewToolbarConfig() | 192 | void KAddressBookMain::slotNewToolbarConfig() |
183 | { | 193 | { |
184 | #ifndef KAB_EMBEDDED | 194 | #ifndef KAB_EMBEDDED |
185 | applyMainWindowSettings( KGlobal::config(), "MainWindow" ); | 195 | applyMainWindowSettings( KGlobal::config(), "MainWindow" ); |
186 | #else //KAB_EMBEDDED | 196 | #else //KAB_EMBEDDED |
187 | qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); | 197 | qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); |
188 | #endif //KAB_EMBEDDED | 198 | #endif //KAB_EMBEDDED |
189 | } | 199 | } |
190 | 200 | ||
191 | void KAddressBookMain::configureKeys() | 201 | void KAddressBookMain::configureKeys() |
192 | { | 202 | { |
193 | #ifndef KAB_EMBEDDED | 203 | #ifndef KAB_EMBEDDED |
194 | KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); | 204 | KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); |
195 | #else //KAB_EMBEDDED | 205 | #else //KAB_EMBEDDED |
196 | qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); | 206 | qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); |
197 | #endif //KAB_EMBEDDED | 207 | #endif //KAB_EMBEDDED |
198 | } | 208 | } |
199 | 209 | ||
200 | void KAddressBookMain::closeEvent( QCloseEvent* ce ) | 210 | void KAddressBookMain::closeEvent( QCloseEvent* ce ) |
201 | { | 211 | { |
202 | bool mModified = mCore->modified(); | 212 | bool mModified = mCore->modified(); |
203 | bool mAskForQuit = KABPrefs::instance()->mAskForQuit; | 213 | bool mAskForQuit = KABPrefs::instance()->mAskForQuit; |
204 | 214 | ||
205 | QString mess = i18n( "Close KA/Pi?"); | 215 | QString mess = i18n( "Close KA/Pi?"); |
206 | if ( mModified == true ) | 216 | if ( mModified == true ) |
207 | mess += i18n( "\nChanges will be saved!"); | 217 | mess += i18n( "\nChanges will be saved!"); |
208 | else | 218 | else |
209 | mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); | 219 | mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); |
210 | 220 | ||
211 | bool mQuit = true; | 221 | bool mQuit = true; |
212 | 222 | ||
213 | 223 | ||
214 | if (mAskForQuit) | 224 | if (mAskForQuit) |
215 | { | 225 | { |
216 | 226 | ||
217 | int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); | 227 | int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); |
218 | if (res == 0) | 228 | if (res == 0) |
219 | mQuit = true; | 229 | mQuit = true; |
220 | else | 230 | else |
221 | mQuit = false; | 231 | mQuit = false; |
222 | } | 232 | } |
223 | 233 | ||
224 | if (mQuit == false) | 234 | if (mQuit == false) |
225 | return; | 235 | return; |
226 | 236 | ||
227 | if (mModified == true) | 237 | if (mModified == true) |
228 | { | 238 | { |
229 | save(); | 239 | save(); |
230 | mCore->saveSettings(); | 240 | mCore->saveSettings(); |
231 | KABPrefs::instance()->writeConfig(); | 241 | KABPrefs::instance()->writeConfig(); |
232 | } | 242 | } |
233 | 243 | ||
234 | ce->accept(); | 244 | ce->accept(); |
235 | } | 245 | } |
236 | 246 | ||
237 | #ifndef KAB_EMBEDDED | 247 | #ifndef KAB_EMBEDDED |
238 | #include "kaddressbookmain.moc" | 248 | #include "kaddressbookmain.moc" |
239 | #endif //KAB_EMBEDDED | 249 | #endif //KAB_EMBEDDED |
240 | 250 | ||
diff --git a/kaddressbook/kaddressbookmain.h b/kaddressbook/kaddressbookmain.h index cf6f899..40d2bdd 100644 --- a/kaddressbook/kaddressbookmain.h +++ b/kaddressbook/kaddressbookmain.h | |||
@@ -1,122 +1,122 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 1999 Don Sanders <dsanders@kde.org> | 3 | Copyright (c) 1999 Don Sanders <dsanders@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KADDRESSBOOKMAIN_H | 24 | #ifndef KADDRESSBOOKMAIN_H |
25 | #define KADDRESSBOOKMAIN_H | 25 | #define KADDRESSBOOKMAIN_H |
26 | 26 | ||
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | 28 | ||
29 | #ifdef KAB_EMBEDDED | 29 | #ifdef KAB_EMBEDDED |
30 | class QToolBar; | 30 | class QToolBar; |
31 | #include <qaction.h> | 31 | #include <qaction.h> |
32 | //#include <qmainwindow.h> | 32 | //#include <qmainwindow.h> |
33 | #include <kmainwindow.h> | 33 | #include <kmainwindow.h> |
34 | #else //KAB_EMBEDDED | 34 | #else //KAB_EMBEDDED |
35 | #include <kaction.h> | 35 | #include <kaction.h> |
36 | #include <kapplication.h> | 36 | #include <kapplication.h> |
37 | #include <kmainwindow.h> | 37 | #include <kmainwindow.h> |
38 | #include "kaddressbookiface.h" | 38 | #include "kaddressbookiface.h" |
39 | #endif //KAB_EMBEDDED | 39 | #endif //KAB_EMBEDDED |
40 | 40 | ||
41 | class KABCore; | 41 | class KABCore; |
42 | class KConfig; | 42 | class KConfig; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | This class serves as the main window for KAddressBook. It handles the | 45 | This class serves as the main window for KAddressBook. It handles the |
46 | menus, toolbars, and status bars. | 46 | menus, toolbars, and status bars. |
47 | 47 | ||
48 | @short Main window class | 48 | @short Main window class |
49 | @author Don Sanders <dsanders@kde.org> | 49 | @author Don Sanders <dsanders@kde.org> |
50 | @version 0.1 | 50 | @version 0.1 |
51 | */ | 51 | */ |
52 | #ifdef KAB_EMBEDDED | 52 | #ifdef KAB_EMBEDDED |
53 | class KAddressBookMain : public KMainWindow | 53 | class KAddressBookMain : public KMainWindow |
54 | #else //KAB_EMBEDDED | 54 | #else //KAB_EMBEDDED |
55 | //MOC_SKIP_BEGIN | 55 | //MOC_SKIP_BEGIN |
56 | class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface | 56 | class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface |
57 | //MOC_SKIP_END | 57 | //MOC_SKIP_END |
58 | #endif //KAB_EMBEDDED | 58 | #endif //KAB_EMBEDDED |
59 | { | 59 | { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | 61 | ||
62 | public: | 62 | public: |
63 | KAddressBookMain(); | 63 | KAddressBookMain(); |
64 | virtual ~KAddressBookMain(); | 64 | virtual ~KAddressBookMain(); |
65 | 65 | ||
66 | #ifdef KAB_EMBEDDED | 66 | #ifdef KAB_EMBEDDED |
67 | // QPEToolBar * getIconToolBar(); | 67 | // QPEToolBar * getIconToolBar(); |
68 | // QToolBar * getIconToolBar(); | 68 | // QToolBar * getIconToolBar(); |
69 | #endif //KAB_EMBEDDED | 69 | #endif //KAB_EMBEDDED |
70 | 70 | ||
71 | 71 | ||
72 | public slots: | 72 | public slots: |
73 | void showMinimized () ; | 73 | void showMinimized () ; |
74 | virtual void addEmail( QString addr ); | 74 | virtual void addEmail( QString addr ); |
75 | #ifndef KAB_EMBEDDED | 75 | #ifndef KAB_EMBEDDED |
76 | //MOC_SKIP_BEGIN | 76 | //MOC_SKIP_BEGIN |
77 | virtual ASYNC showContactEditor( QString uid ); | 77 | virtual ASYNC showContactEditor( QString uid ); |
78 | //MOC_SKIP_END | 78 | //MOC_SKIP_END |
79 | #endif //KAB_EMBEDDED | 79 | #endif //KAB_EMBEDDED |
80 | virtual void newContact(); | 80 | virtual void newContact(); |
81 | virtual QString getNameByPhone( QString phone ); | 81 | virtual QString getNameByPhone( QString phone ); |
82 | virtual void save(); | 82 | virtual void save(); |
83 | virtual void exit(); | 83 | virtual void exit(); |
84 | 84 | void recieve( const QCString& cmsg, const QByteArray& data ); | |
85 | protected: | 85 | protected: |
86 | void initActions(); | 86 | void initActions(); |
87 | #ifdef KAB_EMBEDDED | 87 | #ifdef KAB_EMBEDDED |
88 | //US new method to setup menues and toolbars on embedded systems | 88 | //US new method to setup menues and toolbars on embedded systems |
89 | void createGUI(); | 89 | void createGUI(); |
90 | #endif //KAB_EMBEDDED | 90 | #endif //KAB_EMBEDDED |
91 | 91 | ||
92 | /** | 92 | /** |
93 | This function is called when it is time for the app to save its | 93 | This function is called when it is time for the app to save its |
94 | properties for session management purposes. | 94 | properties for session management purposes. |
95 | */ | 95 | */ |
96 | void saveProperties( KConfig* ); | 96 | void saveProperties( KConfig* ); |
97 | 97 | ||
98 | /** | 98 | /** |
99 | This function is called when this app is restored. The KConfig | 99 | This function is called when this app is restored. The KConfig |
100 | object points to the session management config file that was saved | 100 | object points to the session management config file that was saved |
101 | with @ref saveProperties | 101 | with @ref saveProperties |
102 | */ | 102 | */ |
103 | void readProperties( KConfig* ); | 103 | void readProperties( KConfig* ); |
104 | 104 | ||
105 | void closeEvent( QCloseEvent* ce ); | 105 | void closeEvent( QCloseEvent* ce ); |
106 | 106 | ||
107 | protected slots: | 107 | protected slots: |
108 | void configureToolbars(); | 108 | void configureToolbars(); |
109 | void configureKeys(); | 109 | void configureKeys(); |
110 | 110 | ||
111 | void slotNewToolbarConfig(); | 111 | void slotNewToolbarConfig(); |
112 | 112 | ||
113 | private: | 113 | private: |
114 | KABCore *mCore; | 114 | KABCore *mCore; |
115 | 115 | ||
116 | #ifdef KAB_EMBEDDED | 116 | #ifdef KAB_EMBEDDED |
117 | // QToolBar *iconToolBar; | 117 | // QToolBar *iconToolBar; |
118 | #endif //KAB_EMBEDDED | 118 | #endif //KAB_EMBEDDED |
119 | 119 | ||
120 | }; | 120 | }; |
121 | 121 | ||
122 | #endif | 122 | #endif |
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index 965fb06..6dd97b8 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp | |||
@@ -1,212 +1,218 @@ | |||
1 | #ifndef DESKTOP_VERSION | 1 | #ifndef DESKTOP_VERSION |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <qcopchannel_qws.h> | ||
3 | #include <stdlib.h> | 4 | #include <stdlib.h> |
4 | #else | 5 | #else |
5 | #include <qapplication.h> | 6 | #include <qapplication.h> |
6 | #include <qwindowsstyle.h> | 7 | #include <qwindowsstyle.h> |
7 | #include <qplatinumstyle.h> | 8 | #include <qplatinumstyle.h> |
8 | #include <qmainwindow.h> | 9 | #include <qmainwindow.h> |
9 | #endif | 10 | #endif |
10 | 11 | ||
11 | #include <kstandarddirs.h> | 12 | #include <kstandarddirs.h> |
12 | #include <qregexp.h> | 13 | #include <qregexp.h> |
13 | #include <kglobal.h> | 14 | #include <kglobal.h> |
14 | #include <stdio.h> | 15 | #include <stdio.h> |
15 | #include <qdir.h> | 16 | #include <qdir.h> |
16 | #include "kaddressbookmain.h" | 17 | #include "kaddressbookmain.h" |
17 | #include "externalapphandler.h" | 18 | #include "externalapphandler.h" |
18 | #include <libkdepim/kpimglobalprefs.h> | 19 | #include <libkdepim/kpimglobalprefs.h> |
19 | 20 | ||
20 | int main( int argc, char **argv ) | 21 | int main( int argc, char **argv ) |
21 | { | 22 | { |
22 | #ifndef DESKTOP_VERSION | 23 | #ifndef DESKTOP_VERSION |
23 | QPEApplication a( argc, argv ); | 24 | QPEApplication a( argc, argv ); |
24 | a.setKeepRunning (); | 25 | a.setKeepRunning (); |
25 | #else | 26 | #else |
26 | QApplication a( argc, argv ); | 27 | QApplication a( argc, argv ); |
27 | QApplication::setStyle( new QPlatinumStyle ()); | 28 | QApplication::setStyle( new QPlatinumStyle ()); |
28 | QString hdir = QDir::homeDirPath(); | 29 | QString hdir = QDir::homeDirPath(); |
29 | // there is a bug when creating dirs for WIN 98 | 30 | // there is a bug when creating dirs for WIN 98 |
30 | // it is difficult to fix, because we have no WIN 98 runnung | 31 | // it is difficult to fix, because we have no WIN 98 runnung |
31 | // such that we try it to create the dirs at startup here | 32 | // such that we try it to create the dirs at startup here |
32 | if ( hdir == "C:\\" ) { // win 98 or ME | 33 | if ( hdir == "C:\\" ) { // win 98 or ME |
33 | QDir app_dir; | 34 | QDir app_dir; |
34 | if ( !app_dir.exists("C:\\kdepim") ) | 35 | if ( !app_dir.exists("C:\\kdepim") ) |
35 | app_dir.mkdir ("C:\\kdepim"); | 36 | app_dir.mkdir ("C:\\kdepim"); |
36 | if ( !app_dir.exists("C:\\kdepim\\apps") ) | 37 | if ( !app_dir.exists("C:\\kdepim\\apps") ) |
37 | app_dir.mkdir ("C:\\kdepim\\apps"); | 38 | app_dir.mkdir ("C:\\kdepim\\apps"); |
38 | if ( !app_dir.exists("C:\\kdepim\\config") ) | 39 | if ( !app_dir.exists("C:\\kdepim\\config") ) |
39 | app_dir.mkdir ("C:\\kdepim\\config"); | 40 | app_dir.mkdir ("C:\\kdepim\\config"); |
40 | if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) | 41 | if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) |
41 | app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); | 42 | app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); |
42 | } | 43 | } |
43 | #endif | 44 | #endif |
44 | 45 | ||
45 | bool exitHelp = false; | 46 | bool exitHelp = false; |
46 | if ( argc > 1 ) { | 47 | if ( argc > 1 ) { |
47 | QString command = argv[1]; | 48 | QString command = argv[1]; |
48 | if ( command == "-help" ){ | 49 | if ( command == "-help" ){ |
49 | printf("KA/E command line commands:\n"); | 50 | printf("KA/E command line commands:\n"); |
50 | printf(" no command: Start KA/E in usual way\n"); | 51 | printf(" no command: Start KA/E in usual way\n"); |
51 | printf(" -help: This output\n"); | 52 | printf(" -help: This output\n"); |
52 | printf(" KA/E is exiting now. Bye!\n"); | 53 | printf(" KA/E is exiting now. Bye!\n"); |
53 | exitHelp = true; | 54 | exitHelp = true; |
54 | } | 55 | } |
55 | } | 56 | } |
56 | if ( ! exitHelp ) { | 57 | if ( ! exitHelp ) { |
57 | 58 | ||
58 | KGlobal::setAppName( "kaddressbook" ); | 59 | KGlobal::setAppName( "kaddressbook" ); |
59 | #ifndef DESKTOP_VERSION | 60 | #ifndef DESKTOP_VERSION |
60 | if ( QApplication::desktop()->width() > 320 ) | 61 | if ( QApplication::desktop()->width() > 320 ) |
61 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); | 62 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); |
62 | else | 63 | else |
63 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); | 64 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); |
64 | #else | 65 | #else |
65 | QString fileName ; | 66 | QString fileName ; |
66 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; | 67 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; |
67 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 68 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
68 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); | 69 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); |
69 | 70 | ||
70 | #endif | 71 | #endif |
71 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); | 72 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); |
72 | KAddressBookMain m ; | 73 | KAddressBookMain m ; |
73 | //US MainWindow m; | 74 | //US MainWindow m; |
74 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 75 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
75 | 76 | ||
76 | { | 77 | { |
77 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 78 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
78 | } | 79 | } |
79 | #ifndef DESKTOP_VERSION | 80 | #ifndef DESKTOP_VERSION |
80 | a.showMainWidget( &m ); | 81 | a.showMainWidget( &m ); |
82 | QCopChannel* c1 = new QCopChannel("QPE/Application/addressbook",&m, "channelAB" ) ; | ||
83 | QObject::connect( c1, SIGNAL (received ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); | ||
81 | #else | 84 | #else |
82 | a.setMainWidget( &m ); | 85 | a.setMainWidget( &m ); |
83 | m.resize (640, 480 ); | 86 | m.resize (640, 480 ); |
84 | m.show(); | 87 | m.show(); |
85 | #endif | 88 | #endif |
86 | a.exec(); | 89 | a.exec(); |
90 | #ifndef DESKTOP_VERSION | ||
91 | delete c1; | ||
92 | #endif | ||
87 | 93 | ||
88 | } | 94 | } |
89 | qDebug("KA: Bye! "); | 95 | qDebug("KA: Bye! "); |
90 | } | 96 | } |
91 | 97 | ||
92 | /* | 98 | /* |
93 | #include <stdlib.h> | 99 | #include <stdlib.h> |
94 | 100 | ||
95 | #include <qstring.h> | 101 | #include <qstring.h> |
96 | 102 | ||
97 | #include <kabc/stdaddressbook.h> | 103 | #include <kabc/stdaddressbook.h> |
98 | #include <kaboutdata.h> | 104 | #include <kaboutdata.h> |
99 | #include <kcmdlineargs.h> | 105 | #include <kcmdlineargs.h> |
100 | #include <kcrash.h> | 106 | #include <kcrash.h> |
101 | #include <kdebug.h> | 107 | #include <kdebug.h> |
102 | #include <klocale.h> | 108 | #include <klocale.h> |
103 | #include <kstartupinfo.h> | 109 | #include <kstartupinfo.h> |
104 | #include <kuniqueapplication.h> | 110 | #include <kuniqueapplication.h> |
105 | #include <kwin.h> | 111 | #include <kwin.h> |
106 | 112 | ||
107 | #include "kaddressbookmain.h" | 113 | #include "kaddressbookmain.h" |
108 | #include "kabcore.h" | 114 | #include "kabcore.h" |
109 | 115 | ||
110 | extern "C" { | 116 | extern "C" { |
111 | 117 | ||
112 | void crashHandler( int ) | 118 | void crashHandler( int ) |
113 | { | 119 | { |
114 | KABC::StdAddressBook::handleCrash(); | 120 | KABC::StdAddressBook::handleCrash(); |
115 | ::exit( 0 ); | 121 | ::exit( 0 ); |
116 | } | 122 | } |
117 | 123 | ||
118 | } | 124 | } |
119 | 125 | ||
120 | class KAddressBookApp : public KUniqueApplication { | 126 | class KAddressBookApp : public KUniqueApplication { |
121 | public: | 127 | public: |
122 | KAddressBookApp() : mMainWin( 0 ) {} | 128 | KAddressBookApp() : mMainWin( 0 ) {} |
123 | ~KAddressBookApp() {} | 129 | ~KAddressBookApp() {} |
124 | 130 | ||
125 | int newInstance(); | 131 | int newInstance(); |
126 | 132 | ||
127 | private: | 133 | private: |
128 | KAddressBookMain *mMainWin; | 134 | KAddressBookMain *mMainWin; |
129 | }; | 135 | }; |
130 | 136 | ||
131 | int KAddressBookApp::newInstance() | 137 | int KAddressBookApp::newInstance() |
132 | { | 138 | { |
133 | if ( isRestored() ) { | 139 | if ( isRestored() ) { |
134 | // There can only be one main window | 140 | // There can only be one main window |
135 | if ( KMainWindow::canBeRestored( 1 ) ) { | 141 | if ( KMainWindow::canBeRestored( 1 ) ) { |
136 | mMainWin = new KAddressBookMain; | 142 | mMainWin = new KAddressBookMain; |
137 | mMainWin->show(); | 143 | mMainWin->show(); |
138 | mMainWin->restore( 1 ); | 144 | mMainWin->restore( 1 ); |
139 | } | 145 | } |
140 | } else { | 146 | } else { |
141 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 147 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
142 | 148 | ||
143 | QCString addrStr = args->getOption( "addr" ); | 149 | QCString addrStr = args->getOption( "addr" ); |
144 | QCString uidStr = args->getOption( "uid" ); | 150 | QCString uidStr = args->getOption( "uid" ); |
145 | QString addr; | 151 | QString addr; |
146 | QString uid; | 152 | QString uid; |
147 | if ( !addrStr.isEmpty() ) | 153 | if ( !addrStr.isEmpty() ) |
148 | addr = QString::fromLocal8Bit( addrStr ); | 154 | addr = QString::fromLocal8Bit( addrStr ); |
149 | if ( !uidStr.isEmpty() ) | 155 | if ( !uidStr.isEmpty() ) |
150 | uid = QString::fromLocal8Bit( uidStr ); | 156 | uid = QString::fromLocal8Bit( uidStr ); |
151 | 157 | ||
152 | 158 | ||
153 | if ( args->isSet( "editor-only" ) ) { | 159 | if ( args->isSet( "editor-only" ) ) { |
154 | if ( !mMainWin ) | 160 | if ( !mMainWin ) |
155 | mMainWin = new KAddressBookMain; | 161 | mMainWin = new KAddressBookMain; |
156 | KStartupInfo::appStarted(); | 162 | KStartupInfo::appStarted(); |
157 | mMainWin->hide(); | 163 | mMainWin->hide(); |
158 | } else { | 164 | } else { |
159 | if ( mMainWin ) { | 165 | if ( mMainWin ) { |
160 | mMainWin->show(); | 166 | mMainWin->show(); |
161 | KWin::setActiveWindow( mMainWin->winId() ); | 167 | KWin::setActiveWindow( mMainWin->winId() ); |
162 | } else { | 168 | } else { |
163 | mMainWin = new KAddressBookMain; | 169 | mMainWin = new KAddressBookMain; |
164 | mMainWin->show(); | 170 | mMainWin->show(); |
165 | } | 171 | } |
166 | } | 172 | } |
167 | // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do | 173 | // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do |
168 | if ( !addr.isEmpty() ) | 174 | if ( !addr.isEmpty() ) |
169 | mMainWin->addEmail( addr ); | 175 | mMainWin->addEmail( addr ); |
170 | 176 | ||
171 | if ( !uid.isEmpty() ) | 177 | if ( !uid.isEmpty() ) |
172 | mMainWin->showContactEditor( uid ); | 178 | mMainWin->showContactEditor( uid ); |
173 | if ( args->isSet( "new-contact" ) ) { | 179 | if ( args->isSet( "new-contact" ) ) { |
174 | mMainWin->newContact(); | 180 | mMainWin->newContact(); |
175 | } | 181 | } |
176 | } | 182 | } |
177 | 183 | ||
178 | KCrash::setEmergencySaveFunction( crashHandler ); | 184 | KCrash::setEmergencySaveFunction( crashHandler ); |
179 | 185 | ||
180 | return 0; | 186 | return 0; |
181 | } | 187 | } |
182 | 188 | ||
183 | // the dummy argument is required, because KMail apparently sends an empty | 189 | // the dummy argument is required, because KMail apparently sends an empty |
184 | // argument. | 190 | // argument. |
185 | static KCmdLineOptions kmoptions[] = | 191 | static KCmdLineOptions kmoptions[] = |
186 | { | 192 | { |
187 | { "a", 0 , 0 }, | 193 | { "a", 0 , 0 }, |
188 | { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, | 194 | { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, |
189 | { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, | 195 | { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, |
190 | { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, | 196 | { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, |
191 | { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, | 197 | { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, |
192 | { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, | 198 | { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, |
193 | { 0, 0, 0} | 199 | { 0, 0, 0} |
194 | }; | 200 | }; |
195 | 201 | ||
196 | int main( int argc, char *argv[] ) | 202 | int main( int argc, char *argv[] ) |
197 | { | 203 | { |
198 | KLocale::setMainCatalogue( "kaddressbook" ); | 204 | KLocale::setMainCatalogue( "kaddressbook" ); |
199 | 205 | ||
200 | KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); | 206 | KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); |
201 | KCmdLineArgs::addCmdLineOptions( kmoptions ); | 207 | KCmdLineArgs::addCmdLineOptions( kmoptions ); |
202 | KUniqueApplication::addCmdLineOptions(); | 208 | KUniqueApplication::addCmdLineOptions(); |
203 | 209 | ||
204 | if ( !KAddressBookApp::start() ) | 210 | if ( !KAddressBookApp::start() ) |
205 | exit( 0 ); | 211 | exit( 0 ); |
206 | 212 | ||
207 | KAddressBookApp app; | 213 | KAddressBookApp app; |
208 | KGlobal::locale()->insertCatalogue( "libkdepim" ); | 214 | KGlobal::locale()->insertCatalogue( "libkdepim" ); |
209 | 215 | ||
210 | return app.exec(); | 216 | return app.exec(); |
211 | } | 217 | } |
212 | */ | 218 | */ |