author | zautrix <zautrix> | 2004-07-12 12:43:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-12 12:43:54 (UTC) |
commit | cbc789907408fa3359444c464ba5a86be892f301 (patch) (unidiff) | |
tree | 82d02fc50134c1e64acf4ea9f5388ac3396602b3 | |
parent | a55fa40fa32b115c7f7803fb6af0da5184cd7dff (diff) | |
download | kdepimpi-cbc789907408fa3359444c464ba5a86be892f301.zip kdepimpi-cbc789907408fa3359444c464ba5a86be892f301.tar.gz kdepimpi-cbc789907408fa3359444c464ba5a86be892f301.tar.bz2 |
Windows import fixes
-rw-r--r-- | kaddressbook/kabcore.cpp | 30 | ||||
-rw-r--r-- | kaddressbook/kaimportoldialog.cpp | 10 | ||||
-rw-r--r-- | kaddressbook/undocmds.cpp | 5 |
3 files changed, 36 insertions, 9 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index f4263c4..1a34e4d 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,1626 +1,1648 @@ | |||
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 | #include "kabcore.h" | 24 | #include "kabcore.h" |
25 | 25 | ||
26 | #include <stdaddressbook.h> | 26 | #include <stdaddressbook.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #include <qclipboard.h> | 30 | #include <qclipboard.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qapplicaton.h> | 33 | #include <qapplicaton.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | #include <qvbox.h> | 36 | #include <qvbox.h> |
37 | #include <kabc/addresseelist.h> | 37 | #include <kabc/addresseelist.h> |
38 | #include <kabc/errorhandler.h> | 38 | #include <kabc/errorhandler.h> |
39 | #include <kabc/resource.h> | 39 | #include <kabc/resource.h> |
40 | #include <kabc/vcardconverter.h> | 40 | #include <kabc/vcardconverter.h> |
41 | #include <kapplication.h> | 41 | #include <kapplication.h> |
42 | #include <kactionclasses.h> | 42 | #include <kactionclasses.h> |
43 | #include <kcmultidialog.h> | 43 | #include <kcmultidialog.h> |
44 | #include <kdebug.h> | 44 | #include <kdebug.h> |
45 | #include <kdeversion.h> | 45 | #include <kdeversion.h> |
46 | #include <kkeydialog.h> | 46 | #include <kkeydialog.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | #include <kprinter.h> | 48 | #include <kprinter.h> |
49 | #include <kprotocolinfo.h> | 49 | #include <kprotocolinfo.h> |
50 | #include <kresources/selectdialog.h> | 50 | #include <kresources/selectdialog.h> |
51 | #include <kstandarddirs.h> | 51 | #include <kstandarddirs.h> |
52 | #include <ktempfile.h> | 52 | #include <ktempfile.h> |
53 | #include <kxmlguiclient.h> | 53 | #include <kxmlguiclient.h> |
54 | #include <kaboutdata.h> | 54 | #include <kaboutdata.h> |
55 | #include <libkdepim/categoryselectdialog.h> | 55 | #include <libkdepim/categoryselectdialog.h> |
56 | 56 | ||
57 | #include "addresseeutil.h" | 57 | #include "addresseeutil.h" |
58 | #include "addresseeeditordialog.h" | 58 | #include "addresseeeditordialog.h" |
59 | #include "extensionmanager.h" | 59 | #include "extensionmanager.h" |
60 | #include "kstdaction.h" | 60 | #include "kstdaction.h" |
61 | #include "kaddressbookservice.h" | 61 | #include "kaddressbookservice.h" |
62 | #include "ldapsearchdialog.h" | 62 | #include "ldapsearchdialog.h" |
63 | #include "printing/printingwizard.h" | 63 | #include "printing/printingwizard.h" |
64 | #else // KAB_EMBEDDED | 64 | #else // KAB_EMBEDDED |
65 | 65 | ||
66 | #include <kapplication.h> | 66 | #include <kapplication.h> |
67 | #include "KDGanttMinimizeSplitter.h" | 67 | #include "KDGanttMinimizeSplitter.h" |
68 | #include "kaddressbookmain.h" | 68 | #include "kaddressbookmain.h" |
69 | #include "kactioncollection.h" | 69 | #include "kactioncollection.h" |
70 | #include <qapp.h> | 70 | #include <qapp.h> |
71 | #include <qmenubar.h> | 71 | #include <qmenubar.h> |
72 | //#include <qtoolbar.h> | 72 | //#include <qtoolbar.h> |
73 | #include <qmessagebox.h> | 73 | #include <qmessagebox.h> |
74 | #include <kdebug.h> | 74 | #include <kdebug.h> |
75 | #include <kiconloader.h> // needed for SmallIcon | 75 | #include <kiconloader.h> // needed for SmallIcon |
76 | #include <kresources/kcmkresources.h> | 76 | #include <kresources/kcmkresources.h> |
77 | #include <ktoolbar.h> | 77 | #include <ktoolbar.h> |
78 | 78 | ||
79 | #include <kcmkabconfig.h> | 79 | #include <kcmkabconfig.h> |
80 | 80 | ||
81 | //US#include <qpe/resource.h> // needed for Resource::loadPixmap | 81 | //US#include <qpe/resource.h> // needed for Resource::loadPixmap |
82 | //#include <qlabel.h> | 82 | //#include <qlabel.h> |
83 | #endif // KAB_EMBEDDED | 83 | #endif // KAB_EMBEDDED |
84 | #include <kcmkabconfig.h> | 84 | #include <kcmkabconfig.h> |
85 | 85 | ||
86 | 86 | ||
87 | #include <kresources/selectdialog.h> | 87 | #include <kresources/selectdialog.h> |
88 | #include <kmessagebox.h> | 88 | #include <kmessagebox.h> |
89 | 89 | ||
90 | #include <picture.h> | 90 | #include <picture.h> |
91 | #include <resource.h> | 91 | #include <resource.h> |
92 | 92 | ||
93 | //US#include <qsplitter.h> | 93 | //US#include <qsplitter.h> |
94 | #include <qvbox.h> | 94 | #include <qvbox.h> |
95 | #include <qlayout.h> | 95 | #include <qlayout.h> |
96 | #include <qclipboard.h> | 96 | #include <qclipboard.h> |
97 | 97 | ||
98 | #include <libkdepim/categoryselectdialog.h> | 98 | #include <libkdepim/categoryselectdialog.h> |
99 | 99 | ||
100 | #include "addresseeutil.h" | 100 | #include "addresseeutil.h" |
101 | #include "undocmds.h" | 101 | #include "undocmds.h" |
102 | #include "addresseeeditordialog.h" | 102 | #include "addresseeeditordialog.h" |
103 | #include "viewmanager.h" | 103 | #include "viewmanager.h" |
104 | #include "details/detailsviewcontainer.h" | 104 | #include "details/detailsviewcontainer.h" |
105 | #include "kabprefs.h" | 105 | #include "kabprefs.h" |
106 | #include "xxportmanager.h" | 106 | #include "xxportmanager.h" |
107 | #include "incsearchwidget.h" | 107 | #include "incsearchwidget.h" |
108 | #include "jumpbuttonbar.h" | 108 | #include "jumpbuttonbar.h" |
109 | #include "extensionmanager.h" | 109 | #include "extensionmanager.h" |
110 | #include "addresseeconfig.h" | 110 | #include "addresseeconfig.h" |
111 | #include <kcmultidialog.h> | 111 | #include <kcmultidialog.h> |
112 | 112 | ||
113 | #ifdef _WIN32_ | 113 | #ifdef _WIN32_ |
114 | 114 | ||
115 | #include "kaimportoldialog.h" | 115 | #include "kaimportoldialog.h" |
116 | #endif | 116 | #endif |
117 | 117 | ||
118 | bool pasteWithNewUid = true; | ||
118 | 119 | ||
119 | #ifdef KAB_EMBEDDED | 120 | #ifdef KAB_EMBEDDED |
120 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 121 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
121 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 122 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
122 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 123 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
123 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 124 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
124 | #else //KAB_EMBEDDED | 125 | #else //KAB_EMBEDDED |
125 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 126 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
126 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 127 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
127 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 128 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
128 | mReadWrite( readWrite ), mModified( false ) | 129 | mReadWrite( readWrite ), mModified( false ) |
129 | #endif //KAB_EMBEDDED | 130 | #endif //KAB_EMBEDDED |
130 | { | 131 | { |
131 | #ifdef KAB_EMBEDDED | 132 | #ifdef KAB_EMBEDDED |
132 | //US we define here our own global actioncollection. | 133 | //US we define here our own global actioncollection. |
133 | //mActionCollection = new KActionCollection(this); | 134 | //mActionCollection = new KActionCollection(this); |
134 | #endif //KAB_EMBEDDED | 135 | #endif //KAB_EMBEDDED |
135 | mExtensionBarSplitter = 0; | 136 | mExtensionBarSplitter = 0; |
136 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 137 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
137 | 138 | ||
138 | mAddressBook = KABC::StdAddressBook::self(); | 139 | mAddressBook = KABC::StdAddressBook::self(); |
139 | KABC::StdAddressBook::setAutomaticSave( false ); | 140 | KABC::StdAddressBook::setAutomaticSave( false ); |
140 | 141 | ||
141 | #ifndef KAB_EMBEDDED | 142 | #ifndef KAB_EMBEDDED |
142 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 143 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
143 | #endif //KAB_EMBEDDED | 144 | #endif //KAB_EMBEDDED |
144 | 145 | ||
145 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 146 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
146 | SLOT( addressBookChanged() ) ); | 147 | SLOT( addressBookChanged() ) ); |
147 | 148 | ||
148 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 149 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
149 | "X-Department", "KADDRESSBOOK" ); | 150 | "X-Department", "KADDRESSBOOK" ); |
150 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 151 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
151 | "X-Profession", "KADDRESSBOOK" ); | 152 | "X-Profession", "KADDRESSBOOK" ); |
152 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 153 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
153 | "X-AssistantsName", "KADDRESSBOOK" ); | 154 | "X-AssistantsName", "KADDRESSBOOK" ); |
154 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 155 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
155 | "X-ManagersName", "KADDRESSBOOK" ); | 156 | "X-ManagersName", "KADDRESSBOOK" ); |
156 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 157 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
157 | "X-SpousesName", "KADDRESSBOOK" ); | 158 | "X-SpousesName", "KADDRESSBOOK" ); |
158 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 159 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
159 | "X-Office", "KADDRESSBOOK" ); | 160 | "X-Office", "KADDRESSBOOK" ); |
160 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 161 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
161 | "X-IMAddress", "KADDRESSBOOK" ); | 162 | "X-IMAddress", "KADDRESSBOOK" ); |
162 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 163 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
163 | "X-Anniversary", "KADDRESSBOOK" ); | 164 | "X-Anniversary", "KADDRESSBOOK" ); |
164 | 165 | ||
165 | //US added this field to become compatible with Opie addressbook | 166 | //US added this field to become compatible with Opie addressbook |
166 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 167 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
167 | "X-Gender", "KADDRESSBOOK" ); | 168 | "X-Gender", "KADDRESSBOOK" ); |
168 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 169 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
169 | "X-Children", "KADDRESSBOOK" ); | 170 | "X-Children", "KADDRESSBOOK" ); |
170 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 171 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
171 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 172 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
172 | 173 | ||
173 | initGUI(); | 174 | initGUI(); |
174 | 175 | ||
175 | mIncSearchWidget->setFocus(); | 176 | mIncSearchWidget->setFocus(); |
176 | 177 | ||
177 | 178 | ||
178 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 179 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
179 | SLOT( setContactSelected( const QString& ) ) ); | 180 | SLOT( setContactSelected( const QString& ) ) ); |
180 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 181 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
181 | SLOT( editContact( const QString& ) ) ); | 182 | SLOT( editContact( const QString& ) ) ); |
182 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 183 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
183 | SLOT( deleteContacts( ) ) ); | 184 | SLOT( deleteContacts( ) ) ); |
184 | connect( mViewManager, SIGNAL( modified() ), | 185 | connect( mViewManager, SIGNAL( modified() ), |
185 | SLOT( setModified() ) ); | 186 | SLOT( setModified() ) ); |
186 | 187 | ||
187 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 188 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
188 | 189 | ||
189 | connect( mXXPortManager, SIGNAL( modified() ), | 190 | connect( mXXPortManager, SIGNAL( modified() ), |
190 | SLOT( setModified() ) ); | 191 | SLOT( setModified() ) ); |
191 | 192 | ||
192 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 193 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
193 | SLOT( incrementalSearch( const QString& ) ) ); | 194 | SLOT( incrementalSearch( const QString& ) ) ); |
194 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 195 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
195 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 196 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
196 | 197 | ||
197 | #ifndef KAB_EMBEDDED | 198 | #ifndef KAB_EMBEDDED |
198 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 199 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
199 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 200 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
200 | 201 | ||
201 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 202 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
202 | SLOT( sendMail( const QString& ) ) ); | 203 | SLOT( sendMail( const QString& ) ) ); |
203 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 204 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
204 | SLOT( browse( const QString& ) ) ); | 205 | SLOT( browse( const QString& ) ) ); |
205 | 206 | ||
206 | mAddressBookService = new KAddressBookService( this ); | 207 | mAddressBookService = new KAddressBookService( this ); |
207 | 208 | ||
208 | #endif //KAB_EMBEDDED | 209 | #endif //KAB_EMBEDDED |
209 | mEditorDialog = 0; | 210 | mEditorDialog = 0; |
210 | createAddresseeEditorDialog( this ); | 211 | createAddresseeEditorDialog( this ); |
211 | setModified( false ); | 212 | setModified( false ); |
212 | } | 213 | } |
213 | 214 | ||
214 | KABCore::~KABCore() | 215 | KABCore::~KABCore() |
215 | { | 216 | { |
216 | // save(); | 217 | // save(); |
217 | //saveSettings(); | 218 | //saveSettings(); |
218 | //KABPrefs::instance()->writeConfig(); | 219 | //KABPrefs::instance()->writeConfig(); |
219 | delete AddresseeConfig::instance(); | 220 | delete AddresseeConfig::instance(); |
220 | mAddressBook = 0; | 221 | mAddressBook = 0; |
221 | KABC::StdAddressBook::close(); | 222 | KABC::StdAddressBook::close(); |
222 | 223 | ||
223 | #ifdef KAB_EMBEDDED | 224 | #ifdef KAB_EMBEDDED |
224 | //US we define here our own global actioncollection. | 225 | //US we define here our own global actioncollection. |
225 | // delete mActionCollection; | 226 | // delete mActionCollection; |
226 | #endif //KAB_EMBEDDED | 227 | #endif //KAB_EMBEDDED |
227 | 228 | ||
228 | } | 229 | } |
229 | 230 | ||
230 | void KABCore::restoreSettings() | 231 | void KABCore::restoreSettings() |
231 | { | 232 | { |
232 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; | 233 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; |
233 | 234 | ||
234 | mActionJumpBar->setChecked( state ); | 235 | mActionJumpBar->setChecked( state ); |
235 | setJumpButtonBarVisible( state ); | 236 | setJumpButtonBarVisible( state ); |
236 | 237 | ||
237 | state = KABPrefs::instance()->mDetailsPageVisible; | 238 | state = KABPrefs::instance()->mDetailsPageVisible; |
238 | 239 | ||
239 | mActionDetails->setChecked( state ); | 240 | mActionDetails->setChecked( state ); |
240 | setDetailsVisible( state ); | 241 | setDetailsVisible( state ); |
241 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 242 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
242 | if ( splitterSize.count() == 0 ) { | 243 | if ( splitterSize.count() == 0 ) { |
243 | splitterSize.append( width() / 2 ); | 244 | splitterSize.append( width() / 2 ); |
244 | splitterSize.append( width() / 2 ); | 245 | splitterSize.append( width() / 2 ); |
245 | } | 246 | } |
246 | mMiniSplitter->setSizes( splitterSize ); | 247 | mMiniSplitter->setSizes( splitterSize ); |
247 | if ( mExtensionBarSplitter ) { | 248 | if ( mExtensionBarSplitter ) { |
248 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 249 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
249 | if ( splitterSize.count() == 0 ) { | 250 | if ( splitterSize.count() == 0 ) { |
250 | splitterSize.append( width() / 2 ); | 251 | splitterSize.append( width() / 2 ); |
251 | splitterSize.append( width() / 2 ); | 252 | splitterSize.append( width() / 2 ); |
252 | } | 253 | } |
253 | mExtensionBarSplitter->setSizes( splitterSize ); | 254 | mExtensionBarSplitter->setSizes( splitterSize ); |
254 | 255 | ||
255 | } | 256 | } |
256 | #ifndef KAB_EMBEDDED | 257 | #ifndef KAB_EMBEDDED |
257 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 258 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
258 | if ( splitterSize.count() == 0 ) { | 259 | if ( splitterSize.count() == 0 ) { |
259 | splitterSize.append( width() / 2 ); | 260 | splitterSize.append( width() / 2 ); |
260 | splitterSize.append( width() / 2 ); | 261 | splitterSize.append( width() / 2 ); |
261 | } | 262 | } |
262 | mExtensionBarSplitter->setSizes( splitterSize ); | 263 | mExtensionBarSplitter->setSizes( splitterSize ); |
263 | 264 | ||
264 | splitterSize = KABPrefs::instance()->mDetailsSplitter; | 265 | splitterSize = KABPrefs::instance()->mDetailsSplitter; |
265 | if ( splitterSize.count() == 0 ) { | 266 | if ( splitterSize.count() == 0 ) { |
266 | splitterSize.append( height() / 2 ); | 267 | splitterSize.append( height() / 2 ); |
267 | splitterSize.append( height() / 2 ); | 268 | splitterSize.append( height() / 2 ); |
268 | } | 269 | } |
269 | mDetailsSplitter->setSizes( splitterSize ); | 270 | mDetailsSplitter->setSizes( splitterSize ); |
270 | 271 | ||
271 | mExtensionManager->restoreSettings(); | 272 | mExtensionManager->restoreSettings(); |
272 | 273 | ||
273 | #endif //KAB_EMBEDDED | 274 | #endif //KAB_EMBEDDED |
274 | 275 | ||
275 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 276 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
276 | 277 | ||
277 | mViewManager->restoreSettings(); | 278 | mViewManager->restoreSettings(); |
278 | mExtensionManager->restoreSettings(); | 279 | mExtensionManager->restoreSettings(); |
279 | } | 280 | } |
280 | 281 | ||
281 | void KABCore::saveSettings() | 282 | void KABCore::saveSettings() |
282 | { | 283 | { |
283 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 284 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
284 | if ( mExtensionBarSplitter ) | 285 | if ( mExtensionBarSplitter ) |
285 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 286 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
286 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 287 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
287 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 288 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
288 | #ifndef KAB_EMBEDDED | 289 | #ifndef KAB_EMBEDDED |
289 | 290 | ||
290 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 291 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
291 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 292 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
292 | #endif //KAB_EMBEDDED | 293 | #endif //KAB_EMBEDDED |
293 | mExtensionManager->saveSettings(); | 294 | mExtensionManager->saveSettings(); |
294 | mViewManager->saveSettings(); | 295 | mViewManager->saveSettings(); |
295 | 296 | ||
296 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 297 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
297 | 298 | ||
298 | } | 299 | } |
299 | 300 | ||
300 | KABC::AddressBook *KABCore::addressBook() const | 301 | KABC::AddressBook *KABCore::addressBook() const |
301 | { | 302 | { |
302 | return mAddressBook; | 303 | return mAddressBook; |
303 | } | 304 | } |
304 | 305 | ||
305 | KConfig *KABCore::config() | 306 | KConfig *KABCore::config() |
306 | { | 307 | { |
307 | #ifndef KAB_EMBEDDED | 308 | #ifndef KAB_EMBEDDED |
308 | return KABPrefs::instance()->config(); | 309 | return KABPrefs::instance()->config(); |
309 | #else //KAB_EMBEDDED | 310 | #else //KAB_EMBEDDED |
310 | return KABPrefs::instance()->getConfig(); | 311 | return KABPrefs::instance()->getConfig(); |
311 | #endif //KAB_EMBEDDED | 312 | #endif //KAB_EMBEDDED |
312 | } | 313 | } |
313 | 314 | ||
314 | KActionCollection *KABCore::actionCollection() const | 315 | KActionCollection *KABCore::actionCollection() const |
315 | { | 316 | { |
316 | return mGUIClient->actionCollection(); | 317 | return mGUIClient->actionCollection(); |
317 | } | 318 | } |
318 | 319 | ||
319 | KABC::Field *KABCore::currentSearchField() const | 320 | KABC::Field *KABCore::currentSearchField() const |
320 | { | 321 | { |
321 | if (mIncSearchWidget) | 322 | if (mIncSearchWidget) |
322 | return mIncSearchWidget->currentField(); | 323 | return mIncSearchWidget->currentField(); |
323 | else | 324 | else |
324 | return 0; | 325 | return 0; |
325 | } | 326 | } |
326 | 327 | ||
327 | QStringList KABCore::selectedUIDs() const | 328 | QStringList KABCore::selectedUIDs() const |
328 | { | 329 | { |
329 | return mViewManager->selectedUids(); | 330 | return mViewManager->selectedUids(); |
330 | } | 331 | } |
331 | 332 | ||
332 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 333 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
333 | { | 334 | { |
334 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 335 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
335 | 336 | ||
336 | QPtrList<KRES::Resource> kresResources; | 337 | QPtrList<KRES::Resource> kresResources; |
337 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 338 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
338 | KABC::Resource *resource; | 339 | KABC::Resource *resource; |
339 | while ( ( resource = resIt.current() ) != 0 ) { | 340 | while ( ( resource = resIt.current() ) != 0 ) { |
340 | ++resIt; | 341 | ++resIt; |
341 | if ( !resource->readOnly() ) { | 342 | if ( !resource->readOnly() ) { |
342 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 343 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
343 | if ( res ) | 344 | if ( res ) |
344 | kresResources.append( res ); | 345 | kresResources.append( res ); |
345 | } | 346 | } |
346 | } | 347 | } |
347 | 348 | ||
348 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 349 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
349 | return static_cast<KABC::Resource*>( res ); | 350 | return static_cast<KABC::Resource*>( res ); |
350 | } | 351 | } |
351 | 352 | ||
352 | #ifndef KAB_EMBEDDED | 353 | #ifndef KAB_EMBEDDED |
353 | KAboutData *KABCore::createAboutData() | 354 | KAboutData *KABCore::createAboutData() |
354 | #else //KAB_EMBEDDED | 355 | #else //KAB_EMBEDDED |
355 | void KABCore::createAboutData() | 356 | void KABCore::createAboutData() |
356 | #endif //KAB_EMBEDDED | 357 | #endif //KAB_EMBEDDED |
357 | { | 358 | { |
358 | #ifndef KAB_EMBEDDED | 359 | #ifndef KAB_EMBEDDED |
359 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 360 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
360 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 361 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
361 | KAboutData::License_GPL_V2, | 362 | KAboutData::License_GPL_V2, |
362 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 363 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
363 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 364 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
364 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 365 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
365 | about->addAuthor( "Cornelius Schumacher", | 366 | about->addAuthor( "Cornelius Schumacher", |
366 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 367 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
367 | "schumacher@kde.org" ); | 368 | "schumacher@kde.org" ); |
368 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 369 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
369 | "mpilone@slac.com" ); | 370 | "mpilone@slac.com" ); |
370 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 371 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
371 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 372 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
372 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 373 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
373 | "michel@klaralvdalens-datakonsult.se" ); | 374 | "michel@klaralvdalens-datakonsult.se" ); |
374 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 375 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
375 | "hansen@kde.org" ); | 376 | "hansen@kde.org" ); |
376 | 377 | ||
377 | return about; | 378 | return about; |
378 | #endif //KAB_EMBEDDED | 379 | #endif //KAB_EMBEDDED |
379 | 380 | ||
380 | QString version; | 381 | QString version; |
381 | #include <../version> | 382 | #include <../version> |
382 | QMessageBox::about( this, "About KAddressbook/Pi", | 383 | QMessageBox::about( this, "About KAddressbook/Pi", |
383 | "KAddressbook/Platform-independent\n" | 384 | "KAddressbook/Platform-independent\n" |
384 | "(KA/Pi) " +version + " - " + | 385 | "(KA/Pi) " +version + " - " + |
385 | #ifdef DESKTOP_VERSION | 386 | #ifdef DESKTOP_VERSION |
386 | "Desktop Edition\n" | 387 | "Desktop Edition\n" |
387 | #else | 388 | #else |
388 | "PDA-Edition\n" | 389 | "PDA-Edition\n" |
389 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 390 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
390 | #endif | 391 | #endif |
391 | 392 | ||
392 | "(c) 2004 Ulf Schenk\n" | 393 | "(c) 2004 Ulf Schenk\n" |
393 | "(c) 1997-2003, The KDE PIM Team\n" | 394 | "(c) 1997-2003, The KDE PIM Team\n" |
394 | "Tobias Koenig Current maintainer tokoe@kde.org\n" | 395 | "Tobias Koenig Current maintainer tokoe@kde.org\n" |
395 | "Don Sanders Original author\n" | 396 | "Don Sanders Original author\n" |
396 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" | 397 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" |
397 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" | 398 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" |
398 | "Greg Stern DCOP interface\n" | 399 | "Greg Stern DCOP interface\n" |
399 | "Mark Westcot Contact pinning\n" | 400 | "Mark Westcot Contact pinning\n" |
400 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 401 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
401 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); | 402 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" |
403 | #ifdef _WIN32_ | ||
404 | "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n" | ||
405 | #endif | ||
406 | ); | ||
402 | } | 407 | } |
403 | 408 | ||
404 | void KABCore::setContactSelected( const QString &uid ) | 409 | void KABCore::setContactSelected( const QString &uid ) |
405 | { | 410 | { |
406 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 411 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
407 | if ( !mDetails->isHidden() ) | 412 | if ( !mDetails->isHidden() ) |
408 | mDetails->setAddressee( addr ); | 413 | mDetails->setAddressee( addr ); |
409 | 414 | ||
410 | if ( !addr.isEmpty() ) { | 415 | if ( !addr.isEmpty() ) { |
411 | emit contactSelected( addr.formattedName() ); | 416 | emit contactSelected( addr.formattedName() ); |
412 | KABC::Picture pic = addr.photo(); | 417 | KABC::Picture pic = addr.photo(); |
413 | if ( pic.isIntern() ) { | 418 | if ( pic.isIntern() ) { |
414 | //US emit contactSelected( pic.data() ); | 419 | //US emit contactSelected( pic.data() ); |
415 | //US instead use: | 420 | //US instead use: |
416 | QPixmap px; | 421 | QPixmap px; |
417 | if (pic.data().isNull() != true) | 422 | if (pic.data().isNull() != true) |
418 | { | 423 | { |
419 | px.convertFromImage(pic.data()); | 424 | px.convertFromImage(pic.data()); |
420 | } | 425 | } |
421 | 426 | ||
422 | emit contactSelected( px ); | 427 | emit contactSelected( px ); |
423 | } | 428 | } |
424 | } | 429 | } |
425 | 430 | ||
426 | 431 | ||
427 | mExtensionManager->setSelectionChanged(); | 432 | mExtensionManager->setSelectionChanged(); |
428 | 433 | ||
429 | // update the actions | 434 | // update the actions |
430 | bool selected = !uid.isEmpty(); | 435 | bool selected = !uid.isEmpty(); |
431 | 436 | ||
432 | if ( mReadWrite ) { | 437 | if ( mReadWrite ) { |
433 | mActionCut->setEnabled( selected ); | 438 | mActionCut->setEnabled( selected ); |
434 | mActionPaste->setEnabled( selected ); | 439 | mActionPaste->setEnabled( selected ); |
435 | } | 440 | } |
436 | 441 | ||
437 | mActionCopy->setEnabled( selected ); | 442 | mActionCopy->setEnabled( selected ); |
438 | mActionDelete->setEnabled( selected ); | 443 | mActionDelete->setEnabled( selected ); |
439 | mActionEditAddressee->setEnabled( selected ); | 444 | mActionEditAddressee->setEnabled( selected ); |
440 | mActionMail->setEnabled( selected ); | 445 | mActionMail->setEnabled( selected ); |
441 | mActionMailVCard->setEnabled( selected ); | 446 | mActionMailVCard->setEnabled( selected ); |
442 | mActionWhoAmI->setEnabled( selected ); | 447 | mActionWhoAmI->setEnabled( selected ); |
443 | mActionCategories->setEnabled( selected ); | 448 | mActionCategories->setEnabled( selected ); |
444 | } | 449 | } |
445 | 450 | ||
446 | void KABCore::sendMail() | 451 | void KABCore::sendMail() |
447 | { | 452 | { |
448 | #ifndef KAB_EMBEDDED | 453 | #ifndef KAB_EMBEDDED |
449 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 454 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
450 | #else //KAB_EMBEDDED | 455 | #else //KAB_EMBEDDED |
451 | qDebug("KABCore::sendMail() ust be fixed"); | 456 | qDebug("KABCore::sendMail() ust be fixed"); |
452 | #endif //KAB_EMBEDDED | 457 | #endif //KAB_EMBEDDED |
453 | } | 458 | } |
454 | 459 | ||
455 | void KABCore::sendMail( const QString& email ) | 460 | void KABCore::sendMail( const QString& email ) |
456 | { | 461 | { |
457 | #ifndef KAB_EMBEDDED | 462 | #ifndef KAB_EMBEDDED |
458 | kapp->invokeMailer( email, "" ); | 463 | kapp->invokeMailer( email, "" ); |
459 | #else //KAB_EMBEDDED | 464 | #else //KAB_EMBEDDED |
460 | qDebug("KABCore::sendMail(const QString& email) ust be fixed"); | 465 | qDebug("KABCore::sendMail(const QString& email) ust be fixed"); |
461 | #endif //KAB_EMBEDDED | 466 | #endif //KAB_EMBEDDED |
462 | } | 467 | } |
463 | 468 | ||
464 | void KABCore::mailVCard() | 469 | void KABCore::mailVCard() |
465 | { | 470 | { |
466 | #ifndef KAB_EMBEDDED | 471 | #ifndef KAB_EMBEDDED |
467 | QStringList uids = mViewManager->selectedUids(); | 472 | QStringList uids = mViewManager->selectedUids(); |
468 | if ( !uids.isEmpty() ) | 473 | if ( !uids.isEmpty() ) |
469 | mailVCard( uids ); | 474 | mailVCard( uids ); |
470 | #else //KAB_EMBEDDED | 475 | #else //KAB_EMBEDDED |
471 | qDebug("KABCore::mailVCard() must be fixed"); | 476 | qDebug("KABCore::mailVCard() must be fixed"); |
472 | #endif //KAB_EMBEDDED | 477 | #endif //KAB_EMBEDDED |
473 | } | 478 | } |
474 | 479 | ||
475 | void KABCore::mailVCard( const QStringList& uids ) | 480 | void KABCore::mailVCard( const QStringList& uids ) |
476 | { | 481 | { |
477 | #ifndef KAB_EMBEDDED | 482 | #ifndef KAB_EMBEDDED |
478 | QStringList urls; | 483 | QStringList urls; |
479 | 484 | ||
480 | // Create a temp dir, so that we can put the files in it with proper names | 485 | // Create a temp dir, so that we can put the files in it with proper names |
481 | KTempFile tempDir; | 486 | KTempFile tempDir; |
482 | if ( tempDir.status() != 0 ) { | 487 | if ( tempDir.status() != 0 ) { |
483 | kdWarning() << strerror( tempDir.status() ) << endl; | 488 | kdWarning() << strerror( tempDir.status() ) << endl; |
484 | return; | 489 | return; |
485 | } | 490 | } |
486 | 491 | ||
487 | QString dirName = tempDir.name(); | 492 | QString dirName = tempDir.name(); |
488 | tempDir.unlink(); | 493 | tempDir.unlink(); |
489 | QDir().mkdir( dirName, true ); | 494 | QDir().mkdir( dirName, true ); |
490 | 495 | ||
491 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 496 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
492 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 497 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
493 | 498 | ||
494 | if ( a.isEmpty() ) | 499 | if ( a.isEmpty() ) |
495 | continue; | 500 | continue; |
496 | 501 | ||
497 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 502 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
498 | 503 | ||
499 | QString fileName = dirName + "/" + name; | 504 | QString fileName = dirName + "/" + name; |
500 | 505 | ||
501 | QFile outFile(fileName); | 506 | QFile outFile(fileName); |
502 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 507 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
503 | KABC::VCardConverter converter; | 508 | KABC::VCardConverter converter; |
504 | QString vcard; | 509 | QString vcard; |
505 | 510 | ||
506 | converter.addresseeToVCard( a, vcard ); | 511 | converter.addresseeToVCard( a, vcard ); |
507 | 512 | ||
508 | QTextStream t( &outFile ); // use a text stream | 513 | QTextStream t( &outFile ); // use a text stream |
509 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 514 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
510 | t << vcard; | 515 | t << vcard; |
511 | 516 | ||
512 | outFile.close(); | 517 | outFile.close(); |
513 | 518 | ||
514 | urls.append( fileName ); | 519 | urls.append( fileName ); |
515 | } | 520 | } |
516 | } | 521 | } |
517 | 522 | ||
518 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 523 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
519 | QString::null, // subject | 524 | QString::null, // subject |
520 | QString::null, // body | 525 | QString::null, // body |
521 | QString::null, | 526 | QString::null, |
522 | urls ); // attachments | 527 | urls ); // attachments |
523 | #else //KAB_EMBEDDED | 528 | #else //KAB_EMBEDDED |
524 | qDebug("KABCore::mailVCard( must be fixed"); | 529 | qDebug("KABCore::mailVCard( must be fixed"); |
525 | #endif //KAB_EMBEDDED | 530 | #endif //KAB_EMBEDDED |
526 | 531 | ||
527 | } | 532 | } |
528 | 533 | ||
529 | void KABCore::browse( const QString& url ) | 534 | void KABCore::browse( const QString& url ) |
530 | { | 535 | { |
531 | #ifndef KAB_EMBEDDED | 536 | #ifndef KAB_EMBEDDED |
532 | kapp->invokeBrowser( url ); | 537 | kapp->invokeBrowser( url ); |
533 | #else //KAB_EMBEDDED | 538 | #else //KAB_EMBEDDED |
534 | qDebug("KABCore::browse must be fixed"); | 539 | qDebug("KABCore::browse must be fixed"); |
535 | #endif //KAB_EMBEDDED | 540 | #endif //KAB_EMBEDDED |
536 | } | 541 | } |
537 | 542 | ||
538 | void KABCore::selectAllContacts() | 543 | void KABCore::selectAllContacts() |
539 | { | 544 | { |
540 | mViewManager->setSelected( QString::null, true ); | 545 | mViewManager->setSelected( QString::null, true ); |
541 | } | 546 | } |
542 | 547 | ||
543 | void KABCore::deleteContacts() | 548 | void KABCore::deleteContacts() |
544 | { | 549 | { |
545 | QStringList uidList = mViewManager->selectedUids(); | 550 | QStringList uidList = mViewManager->selectedUids(); |
546 | deleteContacts( uidList ); | 551 | deleteContacts( uidList ); |
547 | } | 552 | } |
548 | 553 | ||
549 | void KABCore::deleteContacts( const QStringList &uids ) | 554 | void KABCore::deleteContacts( const QStringList &uids ) |
550 | { | 555 | { |
551 | if ( uids.count() > 0 ) { | 556 | if ( uids.count() > 0 ) { |
552 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 557 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
553 | UndoStack::instance()->push( command ); | 558 | UndoStack::instance()->push( command ); |
554 | RedoStack::instance()->clear(); | 559 | RedoStack::instance()->clear(); |
555 | 560 | ||
556 | // now if we deleted anything, refresh | 561 | // now if we deleted anything, refresh |
557 | setContactSelected( QString::null ); | 562 | setContactSelected( QString::null ); |
558 | setModified( true ); | 563 | setModified( true ); |
559 | } | 564 | } |
560 | } | 565 | } |
561 | 566 | ||
562 | void KABCore::copyContacts() | 567 | void KABCore::copyContacts() |
563 | { | 568 | { |
564 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 569 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
565 | 570 | ||
566 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 571 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
567 | 572 | ||
568 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 573 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
569 | 574 | ||
570 | QClipboard *cb = QApplication::clipboard(); | 575 | QClipboard *cb = QApplication::clipboard(); |
571 | cb->setText( clipText ); | 576 | cb->setText( clipText ); |
572 | } | 577 | } |
573 | 578 | ||
574 | void KABCore::cutContacts() | 579 | void KABCore::cutContacts() |
575 | { | 580 | { |
576 | QStringList uidList = mViewManager->selectedUids(); | 581 | QStringList uidList = mViewManager->selectedUids(); |
577 | 582 | ||
578 | //US if ( uidList.size() > 0 ) { | 583 | //US if ( uidList.size() > 0 ) { |
579 | if ( uidList.count() > 0 ) { | 584 | if ( uidList.count() > 0 ) { |
580 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 585 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
581 | UndoStack::instance()->push( command ); | 586 | UndoStack::instance()->push( command ); |
582 | RedoStack::instance()->clear(); | 587 | RedoStack::instance()->clear(); |
583 | 588 | ||
584 | setModified( true ); | 589 | setModified( true ); |
585 | } | 590 | } |
586 | } | 591 | } |
587 | 592 | ||
588 | void KABCore::pasteContacts() | 593 | void KABCore::pasteContacts() |
589 | { | 594 | { |
590 | QClipboard *cb = QApplication::clipboard(); | 595 | QClipboard *cb = QApplication::clipboard(); |
591 | 596 | ||
592 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 597 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
593 | 598 | ||
594 | pasteContacts( list ); | 599 | pasteContacts( list ); |
595 | } | 600 | } |
596 | 601 | ||
597 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 602 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
598 | { | 603 | { |
599 | KABC::Resource *resource = requestResource( this ); | 604 | KABC::Resource *resource = requestResource( this ); |
600 | KABC::Addressee::List::Iterator it; | 605 | KABC::Addressee::List::Iterator it; |
601 | for ( it = list.begin(); it != list.end(); ++it ) | 606 | for ( it = list.begin(); it != list.end(); ++it ) |
602 | (*it).setResource( resource ); | 607 | (*it).setResource( resource ); |
603 | 608 | ||
604 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 609 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
605 | UndoStack::instance()->push( command ); | 610 | UndoStack::instance()->push( command ); |
606 | RedoStack::instance()->clear(); | 611 | RedoStack::instance()->clear(); |
607 | 612 | ||
608 | setModified( true ); | 613 | setModified( true ); |
609 | } | 614 | } |
610 | 615 | ||
611 | void KABCore::setWhoAmI() | 616 | void KABCore::setWhoAmI() |
612 | { | 617 | { |
613 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 618 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
614 | 619 | ||
615 | if ( addrList.count() > 1 ) { | 620 | if ( addrList.count() > 1 ) { |
616 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 621 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
617 | return; | 622 | return; |
618 | } | 623 | } |
619 | 624 | ||
620 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 625 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
621 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 626 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
622 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 627 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
623 | } | 628 | } |
624 | 629 | ||
625 | void KABCore::setCategories() | 630 | void KABCore::setCategories() |
626 | { | 631 | { |
627 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 632 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
628 | if ( !dlg.exec() ) | 633 | if ( !dlg.exec() ) |
629 | return; | 634 | return; |
630 | 635 | ||
631 | bool merge = false; | 636 | bool merge = false; |
632 | QString msg = i18n( "Merge with existing categories?" ); | 637 | QString msg = i18n( "Merge with existing categories?" ); |
633 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 638 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
634 | merge = true; | 639 | merge = true; |
635 | 640 | ||
636 | QStringList categories = dlg.selectedCategories(); | 641 | QStringList categories = dlg.selectedCategories(); |
637 | 642 | ||
638 | QStringList uids = mViewManager->selectedUids(); | 643 | QStringList uids = mViewManager->selectedUids(); |
639 | QStringList::Iterator it; | 644 | QStringList::Iterator it; |
640 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 645 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
641 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 646 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
642 | if ( !addr.isEmpty() ) { | 647 | if ( !addr.isEmpty() ) { |
643 | if ( !merge ) | 648 | if ( !merge ) |
644 | addr.setCategories( categories ); | 649 | addr.setCategories( categories ); |
645 | else { | 650 | else { |
646 | QStringList addrCategories = addr.categories(); | 651 | QStringList addrCategories = addr.categories(); |
647 | QStringList::Iterator catIt; | 652 | QStringList::Iterator catIt; |
648 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 653 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
649 | if ( !addrCategories.contains( *catIt ) ) | 654 | if ( !addrCategories.contains( *catIt ) ) |
650 | addrCategories.append( *catIt ); | 655 | addrCategories.append( *catIt ); |
651 | } | 656 | } |
652 | addr.setCategories( addrCategories ); | 657 | addr.setCategories( addrCategories ); |
653 | } | 658 | } |
654 | 659 | ||
655 | mAddressBook->insertAddressee( addr ); | 660 | mAddressBook->insertAddressee( addr ); |
656 | } | 661 | } |
657 | } | 662 | } |
658 | 663 | ||
659 | if ( uids.count() > 0 ) | 664 | if ( uids.count() > 0 ) |
660 | setModified( true ); | 665 | setModified( true ); |
661 | } | 666 | } |
662 | 667 | ||
663 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 668 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
664 | { | 669 | { |
665 | mIncSearchWidget->setFields( fields ); | 670 | mIncSearchWidget->setFields( fields ); |
666 | } | 671 | } |
667 | 672 | ||
668 | void KABCore::incrementalSearch( const QString& text ) | 673 | void KABCore::incrementalSearch( const QString& text ) |
669 | { | 674 | { |
670 | mViewManager->setSelected( QString::null, false ); | 675 | mViewManager->setSelected( QString::null, false ); |
671 | 676 | ||
672 | if ( !text.isEmpty() ) { | 677 | if ( !text.isEmpty() ) { |
673 | KABC::Field *field = mIncSearchWidget->currentField(); | 678 | KABC::Field *field = mIncSearchWidget->currentField(); |
674 | 679 | ||
675 | QString pattern = text.lower(); | 680 | QString pattern = text.lower(); |
676 | 681 | ||
677 | #if 1 //KDE_VERSION >= 319 | 682 | #if 1 //KDE_VERSION >= 319 |
678 | KABC::AddresseeList list( mAddressBook->allAddressees() ); | 683 | KABC::AddresseeList list( mAddressBook->allAddressees() ); |
679 | if ( field ) { | 684 | if ( field ) { |
680 | list.sortByField( field ); | 685 | list.sortByField( field ); |
681 | KABC::AddresseeList::Iterator it; | 686 | KABC::AddresseeList::Iterator it; |
682 | for ( it = list.begin(); it != list.end(); ++it ) { | 687 | for ( it = list.begin(); it != list.end(); ++it ) { |
683 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 688 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
684 | mViewManager->setSelected( (*it).uid(), true ); | 689 | mViewManager->setSelected( (*it).uid(), true ); |
685 | return; | 690 | return; |
686 | } | 691 | } |
687 | } | 692 | } |
688 | } else { | 693 | } else { |
689 | KABC::AddresseeList::Iterator it; | 694 | KABC::AddresseeList::Iterator it; |
690 | for ( it = list.begin(); it != list.end(); ++it ) { | 695 | for ( it = list.begin(); it != list.end(); ++it ) { |
691 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 696 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
692 | KABC::Field::List::ConstIterator fieldIt; | 697 | KABC::Field::List::ConstIterator fieldIt; |
693 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 698 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
694 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | 699 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { |
695 | mViewManager->setSelected( (*it).uid(), true ); | 700 | mViewManager->setSelected( (*it).uid(), true ); |
696 | return; | 701 | return; |
697 | } | 702 | } |
698 | } | 703 | } |
699 | } | 704 | } |
700 | } | 705 | } |
701 | #else | 706 | #else |
702 | KABC::AddressBook::Iterator it; | 707 | KABC::AddressBook::Iterator it; |
703 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 708 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
704 | if ( field ) { | 709 | if ( field ) { |
705 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 710 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
706 | mViewManager->setSelected( (*it).uid(), true ); | 711 | mViewManager->setSelected( (*it).uid(), true ); |
707 | return; | 712 | return; |
708 | } | 713 | } |
709 | } else { | 714 | } else { |
710 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 715 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
711 | KABC::Field::List::ConstIterator fieldIt; | 716 | KABC::Field::List::ConstIterator fieldIt; |
712 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 717 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
713 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | 718 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { |
714 | mViewManager->setSelected( (*it).uid(), true ); | 719 | mViewManager->setSelected( (*it).uid(), true ); |
715 | return; | 720 | return; |
716 | } | 721 | } |
717 | } | 722 | } |
718 | } | 723 | } |
719 | } | 724 | } |
720 | #endif | 725 | #endif |
721 | } | 726 | } |
722 | } | 727 | } |
723 | 728 | ||
724 | void KABCore::setModified() | 729 | void KABCore::setModified() |
725 | { | 730 | { |
726 | setModified( true ); | 731 | setModified( true ); |
727 | } | 732 | } |
728 | 733 | ||
729 | void KABCore::setModifiedWOrefresh() | 734 | void KABCore::setModifiedWOrefresh() |
730 | { | 735 | { |
731 | // qDebug("KABCore::setModifiedWOrefresh() "); | 736 | // qDebug("KABCore::setModifiedWOrefresh() "); |
732 | mModified = true; | 737 | mModified = true; |
733 | mActionSave->setEnabled( mModified ); | 738 | mActionSave->setEnabled( mModified ); |
734 | #ifdef DESKTOP_VERSION | 739 | #ifdef DESKTOP_VERSION |
735 | mDetails->refreshView(); | 740 | mDetails->refreshView(); |
736 | #endif | 741 | #endif |
737 | 742 | ||
738 | } | 743 | } |
739 | void KABCore::setModified( bool modified ) | 744 | void KABCore::setModified( bool modified ) |
740 | { | 745 | { |
741 | mModified = modified; | 746 | mModified = modified; |
742 | mActionSave->setEnabled( mModified ); | 747 | mActionSave->setEnabled( mModified ); |
743 | 748 | ||
744 | if ( modified ) | 749 | if ( modified ) |
745 | mJumpButtonBar->recreateButtons(); | 750 | mJumpButtonBar->recreateButtons(); |
746 | 751 | ||
747 | mViewManager->refreshView(); | 752 | mViewManager->refreshView(); |
748 | mDetails->refreshView(); | 753 | mDetails->refreshView(); |
749 | 754 | ||
750 | } | 755 | } |
751 | 756 | ||
752 | bool KABCore::modified() const | 757 | bool KABCore::modified() const |
753 | { | 758 | { |
754 | return mModified; | 759 | return mModified; |
755 | } | 760 | } |
756 | 761 | ||
757 | void KABCore::contactModified( const KABC::Addressee &addr ) | 762 | void KABCore::contactModified( const KABC::Addressee &addr ) |
758 | { | 763 | { |
759 | 764 | ||
760 | Command *command = 0; | 765 | Command *command = 0; |
761 | QString uid; | 766 | QString uid; |
762 | 767 | ||
763 | // check if it exists already | 768 | // check if it exists already |
764 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 769 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
765 | if ( origAddr.isEmpty() ) | 770 | if ( origAddr.isEmpty() ) |
766 | command = new PwNewCommand( mAddressBook, addr ); | 771 | command = new PwNewCommand( mAddressBook, addr ); |
767 | else { | 772 | else { |
768 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 773 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
769 | uid = addr.uid(); | 774 | uid = addr.uid(); |
770 | } | 775 | } |
771 | 776 | ||
772 | UndoStack::instance()->push( command ); | 777 | UndoStack::instance()->push( command ); |
773 | RedoStack::instance()->clear(); | 778 | RedoStack::instance()->clear(); |
774 | 779 | ||
775 | setModified( true ); | 780 | setModified( true ); |
776 | } | 781 | } |
777 | 782 | ||
778 | void KABCore::newContact() | 783 | void KABCore::newContact() |
779 | { | 784 | { |
780 | 785 | ||
781 | 786 | ||
782 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 787 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
783 | 788 | ||
784 | QPtrList<KRES::Resource> kresResources; | 789 | QPtrList<KRES::Resource> kresResources; |
785 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 790 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
786 | KABC::Resource *resource; | 791 | KABC::Resource *resource; |
787 | while ( ( resource = it.current() ) != 0 ) { | 792 | while ( ( resource = it.current() ) != 0 ) { |
788 | ++it; | 793 | ++it; |
789 | if ( !resource->readOnly() ) { | 794 | if ( !resource->readOnly() ) { |
790 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 795 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
791 | if ( res ) | 796 | if ( res ) |
792 | kresResources.append( res ); | 797 | kresResources.append( res ); |
793 | } | 798 | } |
794 | } | 799 | } |
795 | 800 | ||
796 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 801 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
797 | resource = static_cast<KABC::Resource*>( res ); | 802 | resource = static_cast<KABC::Resource*>( res ); |
798 | 803 | ||
799 | if ( resource ) { | 804 | if ( resource ) { |
800 | KABC::Addressee addr; | 805 | KABC::Addressee addr; |
801 | addr.setResource( resource ); | 806 | addr.setResource( resource ); |
802 | mEditorDialog->setAddressee( addr ); | 807 | mEditorDialog->setAddressee( addr ); |
803 | KApplication::execDialog ( mEditorDialog ); | 808 | KApplication::execDialog ( mEditorDialog ); |
804 | 809 | ||
805 | } else | 810 | } else |
806 | return; | 811 | return; |
807 | 812 | ||
808 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 813 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
809 | 814 | ||
810 | 815 | ||
811 | } | 816 | } |
812 | 817 | ||
813 | void KABCore::addEmail( QString aStr ) | 818 | void KABCore::addEmail( QString aStr ) |
814 | { | 819 | { |
815 | #ifndef KAB_EMBEDDED | 820 | #ifndef KAB_EMBEDDED |
816 | QString fullName, email; | 821 | QString fullName, email; |
817 | 822 | ||
818 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 823 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
819 | 824 | ||
820 | // Try to lookup the addressee matching the email address | 825 | // Try to lookup the addressee matching the email address |
821 | bool found = false; | 826 | bool found = false; |
822 | QStringList emailList; | 827 | QStringList emailList; |
823 | KABC::AddressBook::Iterator it; | 828 | KABC::AddressBook::Iterator it; |
824 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 829 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
825 | emailList = (*it).emails(); | 830 | emailList = (*it).emails(); |
826 | if ( emailList.contains( email ) > 0 ) { | 831 | if ( emailList.contains( email ) > 0 ) { |
827 | found = true; | 832 | found = true; |
828 | (*it).setNameFromString( fullName ); | 833 | (*it).setNameFromString( fullName ); |
829 | editContact( (*it).uid() ); | 834 | editContact( (*it).uid() ); |
830 | } | 835 | } |
831 | } | 836 | } |
832 | 837 | ||
833 | if ( !found ) { | 838 | if ( !found ) { |
834 | KABC::Addressee addr; | 839 | KABC::Addressee addr; |
835 | addr.setNameFromString( fullName ); | 840 | addr.setNameFromString( fullName ); |
836 | addr.insertEmail( email, true ); | 841 | addr.insertEmail( email, true ); |
837 | 842 | ||
838 | mAddressBook->insertAddressee( addr ); | 843 | mAddressBook->insertAddressee( addr ); |
839 | mViewManager->refreshView( addr.uid() ); | 844 | mViewManager->refreshView( addr.uid() ); |
840 | editContact( addr.uid() ); | 845 | editContact( addr.uid() ); |
841 | } | 846 | } |
842 | #else //KAB_EMBEDDED | 847 | #else //KAB_EMBEDDED |
843 | qDebug("KABCore::addEmail finsih method"); | 848 | qDebug("KABCore::addEmail finsih method"); |
844 | #endif //KAB_EMBEDDED | 849 | #endif //KAB_EMBEDDED |
845 | } | 850 | } |
846 | 851 | ||
847 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 852 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
848 | { | 853 | { |
849 | mXXPortManager->importVCard( url, showPreview ); | 854 | mXXPortManager->importVCard( url, showPreview ); |
850 | } | 855 | } |
851 | void KABCore::importFromOL() | 856 | void KABCore::importFromOL() |
852 | { | 857 | { |
853 | #ifdef _WIN32_ | 858 | #ifdef _WIN32_ |
854 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 859 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
855 | idgl->exec(); | 860 | idgl->exec(); |
856 | KABC::Addressee::List list = idgl->getAddressList(); | 861 | KABC::Addressee::List list = idgl->getAddressList(); |
857 | if ( list.count() > 0 ) | 862 | if ( list.count() > 0 ) { |
858 | pasteContacts( list ); | 863 | KABC::Addressee::List listNew; |
864 | KABC::Addressee::List listExisting; | ||
865 | KABC::Addressee::List::Iterator it; | ||
866 | KABC::AddressBook::Iterator iter; | ||
867 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
868 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | ||
869 | listNew.append( (*it) ); | ||
870 | else | ||
871 | listExisting.append( (*it) ); | ||
872 | } | ||
873 | if ( listExisting.count() > 0 ) | ||
874 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | ||
875 | if ( listNew.count() > 0 ) { | ||
876 | pasteWithNewUid = false; | ||
877 | pasteContacts( listNew ); | ||
878 | pasteWithNewUid = true; | ||
879 | } | ||
880 | } | ||
859 | delete idgl; | 881 | delete idgl; |
860 | #endif | 882 | #endif |
861 | } | 883 | } |
862 | 884 | ||
863 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 885 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
864 | { | 886 | { |
865 | mXXPortManager->importVCard( vCard, showPreview ); | 887 | mXXPortManager->importVCard( vCard, showPreview ); |
866 | } | 888 | } |
867 | 889 | ||
868 | //US added a second method without defaultparameter | 890 | //US added a second method without defaultparameter |
869 | void KABCore::editContact2() { | 891 | void KABCore::editContact2() { |
870 | editContact( QString::null ); | 892 | editContact( QString::null ); |
871 | } | 893 | } |
872 | 894 | ||
873 | void KABCore::editContact( const QString &uid ) | 895 | void KABCore::editContact( const QString &uid ) |
874 | { | 896 | { |
875 | 897 | ||
876 | if ( mExtensionManager->isQuickEditVisible() ) | 898 | if ( mExtensionManager->isQuickEditVisible() ) |
877 | return; | 899 | return; |
878 | 900 | ||
879 | // First, locate the contact entry | 901 | // First, locate the contact entry |
880 | QString localUID = uid; | 902 | QString localUID = uid; |
881 | if ( localUID.isNull() ) { | 903 | if ( localUID.isNull() ) { |
882 | QStringList uidList = mViewManager->selectedUids(); | 904 | QStringList uidList = mViewManager->selectedUids(); |
883 | if ( uidList.count() > 0 ) | 905 | if ( uidList.count() > 0 ) |
884 | localUID = *( uidList.at( 0 ) ); | 906 | localUID = *( uidList.at( 0 ) ); |
885 | } | 907 | } |
886 | 908 | ||
887 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 909 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
888 | if ( !addr.isEmpty() ) { | 910 | if ( !addr.isEmpty() ) { |
889 | mEditorDialog->setAddressee( addr ); | 911 | mEditorDialog->setAddressee( addr ); |
890 | KApplication::execDialog ( mEditorDialog ); | 912 | KApplication::execDialog ( mEditorDialog ); |
891 | } | 913 | } |
892 | } | 914 | } |
893 | 915 | ||
894 | void KABCore::save() | 916 | void KABCore::save() |
895 | { | 917 | { |
896 | if ( !mModified ) | 918 | if ( !mModified ) |
897 | return; | 919 | return; |
898 | QString text = i18n( "There was an error while attempting to save\n the " | 920 | QString text = i18n( "There was an error while attempting to save\n the " |
899 | "address book. Please check that some \nother application is " | 921 | "address book. Please check that some \nother application is " |
900 | "not using it. " ); | 922 | "not using it. " ); |
901 | statusMessage(i18n("Saving addressbook ... ")); | 923 | statusMessage(i18n("Saving addressbook ... ")); |
902 | #ifndef KAB_EMBEDDED | 924 | #ifndef KAB_EMBEDDED |
903 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 925 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
904 | if ( !b || !b->save() ) { | 926 | if ( !b || !b->save() ) { |
905 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 927 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
906 | } | 928 | } |
907 | #else //KAB_EMBEDDED | 929 | #else //KAB_EMBEDDED |
908 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 930 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
909 | if ( !b || !b->save() ) { | 931 | if ( !b || !b->save() ) { |
910 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 932 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
911 | } | 933 | } |
912 | #endif //KAB_EMBEDDED | 934 | #endif //KAB_EMBEDDED |
913 | 935 | ||
914 | statusMessage(i18n("Addressbook saved!")); | 936 | statusMessage(i18n("Addressbook saved!")); |
915 | setModified( false ); | 937 | setModified( false ); |
916 | } | 938 | } |
917 | 939 | ||
918 | void KABCore::statusMessage(QString mess , int time ) | 940 | void KABCore::statusMessage(QString mess , int time ) |
919 | { | 941 | { |
920 | //topLevelWidget()->setCaption( mess ); | 942 | //topLevelWidget()->setCaption( mess ); |
921 | // pending setting timer to revome message | 943 | // pending setting timer to revome message |
922 | } | 944 | } |
923 | void KABCore::undo() | 945 | void KABCore::undo() |
924 | { | 946 | { |
925 | UndoStack::instance()->undo(); | 947 | UndoStack::instance()->undo(); |
926 | 948 | ||
927 | // Refresh the view | 949 | // Refresh the view |
928 | mViewManager->refreshView(); | 950 | mViewManager->refreshView(); |
929 | } | 951 | } |
930 | 952 | ||
931 | void KABCore::redo() | 953 | void KABCore::redo() |
932 | { | 954 | { |
933 | RedoStack::instance()->redo(); | 955 | RedoStack::instance()->redo(); |
934 | 956 | ||
935 | // Refresh the view | 957 | // Refresh the view |
936 | mViewManager->refreshView(); | 958 | mViewManager->refreshView(); |
937 | } | 959 | } |
938 | 960 | ||
939 | void KABCore::setJumpButtonBarVisible( bool visible ) | 961 | void KABCore::setJumpButtonBarVisible( bool visible ) |
940 | { | 962 | { |
941 | if ( visible ) | 963 | if ( visible ) |
942 | mJumpButtonBar->show(); | 964 | mJumpButtonBar->show(); |
943 | else | 965 | else |
944 | mJumpButtonBar->hide(); | 966 | mJumpButtonBar->hide(); |
945 | } | 967 | } |
946 | void KABCore::setDetailsToState() | 968 | void KABCore::setDetailsToState() |
947 | { | 969 | { |
948 | setDetailsVisible( mActionDetails->isChecked() ); | 970 | setDetailsVisible( mActionDetails->isChecked() ); |
949 | } | 971 | } |
950 | 972 | ||
951 | void KABCore::setDetailsVisible( bool visible ) | 973 | void KABCore::setDetailsVisible( bool visible ) |
952 | { | 974 | { |
953 | if ( visible ) | 975 | if ( visible ) |
954 | mDetails->show(); | 976 | mDetails->show(); |
955 | else | 977 | else |
956 | mDetails->hide(); | 978 | mDetails->hide(); |
957 | } | 979 | } |
958 | 980 | ||
959 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 981 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
960 | { | 982 | { |
961 | 983 | ||
962 | if ( list.count() != 0 ) { | 984 | if ( list.count() != 0 ) { |
963 | KABC::Addressee::List::ConstIterator it; | 985 | KABC::Addressee::List::ConstIterator it; |
964 | for ( it = list.begin(); it != list.end(); ++it ) | 986 | for ( it = list.begin(); it != list.end(); ++it ) |
965 | mAddressBook->insertAddressee( *it ); | 987 | mAddressBook->insertAddressee( *it ); |
966 | if ( list.count() > 1 ) | 988 | if ( list.count() > 1 ) |
967 | setModified(); | 989 | setModified(); |
968 | else | 990 | else |
969 | setModifiedWOrefresh(); | 991 | setModifiedWOrefresh(); |
970 | } | 992 | } |
971 | if ( list.count() == 0 ) | 993 | if ( list.count() == 0 ) |
972 | mViewManager->refreshView(); | 994 | mViewManager->refreshView(); |
973 | else | 995 | else |
974 | mViewManager->refreshView( list[ 0 ].uid() ); | 996 | mViewManager->refreshView( list[ 0 ].uid() ); |
975 | 997 | ||
976 | 998 | ||
977 | 999 | ||
978 | } | 1000 | } |
979 | 1001 | ||
980 | QString KABCore::getNameByPhone( const QString &phone ) | 1002 | QString KABCore::getNameByPhone( const QString &phone ) |
981 | { | 1003 | { |
982 | #ifndef KAB_EMBEDDED | 1004 | #ifndef KAB_EMBEDDED |
983 | QRegExp r( "[/*/-/ ]" ); | 1005 | QRegExp r( "[/*/-/ ]" ); |
984 | QString localPhone( phone ); | 1006 | QString localPhone( phone ); |
985 | 1007 | ||
986 | bool found = false; | 1008 | bool found = false; |
987 | QString ownerName = ""; | 1009 | QString ownerName = ""; |
988 | KABC::AddressBook::Iterator iter; | 1010 | KABC::AddressBook::Iterator iter; |
989 | KABC::PhoneNumber::List::Iterator phoneIter; | 1011 | KABC::PhoneNumber::List::Iterator phoneIter; |
990 | KABC::PhoneNumber::List phoneList; | 1012 | KABC::PhoneNumber::List phoneList; |
991 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1013 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
992 | phoneList = (*iter).phoneNumbers(); | 1014 | phoneList = (*iter).phoneNumbers(); |
993 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1015 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
994 | ++phoneIter) { | 1016 | ++phoneIter) { |
995 | // Get rid of separator chars so just the numbers are compared. | 1017 | // Get rid of separator chars so just the numbers are compared. |
996 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1018 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
997 | ownerName = (*iter).formattedName(); | 1019 | ownerName = (*iter).formattedName(); |
998 | found = true; | 1020 | found = true; |
999 | } | 1021 | } |
1000 | } | 1022 | } |
1001 | } | 1023 | } |
1002 | 1024 | ||
1003 | return ownerName; | 1025 | return ownerName; |
1004 | #else //KAB_EMBEDDED | 1026 | #else //KAB_EMBEDDED |
1005 | qDebug("KABCore::getNameByPhone finsih method"); | 1027 | qDebug("KABCore::getNameByPhone finsih method"); |
1006 | return ""; | 1028 | return ""; |
1007 | #endif //KAB_EMBEDDED | 1029 | #endif //KAB_EMBEDDED |
1008 | 1030 | ||
1009 | } | 1031 | } |
1010 | 1032 | ||
1011 | void KABCore::openConfigDialog() | 1033 | void KABCore::openConfigDialog() |
1012 | { | 1034 | { |
1013 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1035 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1014 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1036 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1015 | ConfigureDialog->addModule(kabcfg ); | 1037 | ConfigureDialog->addModule(kabcfg ); |
1016 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1038 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1017 | this, SLOT( configurationChanged() ) ); | 1039 | this, SLOT( configurationChanged() ) ); |
1018 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1040 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1019 | this, SLOT( configurationChanged() ) ); | 1041 | this, SLOT( configurationChanged() ) ); |
1020 | saveSettings(); | 1042 | saveSettings(); |
1021 | ConfigureDialog->showMaximized(); | 1043 | ConfigureDialog->showMaximized(); |
1022 | if ( ConfigureDialog->exec() ) | 1044 | if ( ConfigureDialog->exec() ) |
1023 | KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") ); | 1045 | KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") ); |
1024 | delete ConfigureDialog; | 1046 | delete ConfigureDialog; |
1025 | } | 1047 | } |
1026 | 1048 | ||
1027 | void KABCore::openLDAPDialog() | 1049 | void KABCore::openLDAPDialog() |
1028 | { | 1050 | { |
1029 | #ifndef KAB_EMBEDDED | 1051 | #ifndef KAB_EMBEDDED |
1030 | if ( !mLdapSearchDialog ) { | 1052 | if ( !mLdapSearchDialog ) { |
1031 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1053 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1032 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1054 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1033 | SLOT( refreshView() ) ); | 1055 | SLOT( refreshView() ) ); |
1034 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1056 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1035 | SLOT( setModified() ) ); | 1057 | SLOT( setModified() ) ); |
1036 | } else | 1058 | } else |
1037 | mLdapSearchDialog->restoreSettings(); | 1059 | mLdapSearchDialog->restoreSettings(); |
1038 | 1060 | ||
1039 | if ( mLdapSearchDialog->isOK() ) | 1061 | if ( mLdapSearchDialog->isOK() ) |
1040 | mLdapSearchDialog->exec(); | 1062 | mLdapSearchDialog->exec(); |
1041 | #else //KAB_EMBEDDED | 1063 | #else //KAB_EMBEDDED |
1042 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1064 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1043 | #endif //KAB_EMBEDDED | 1065 | #endif //KAB_EMBEDDED |
1044 | } | 1066 | } |
1045 | 1067 | ||
1046 | void KABCore::print() | 1068 | void KABCore::print() |
1047 | { | 1069 | { |
1048 | #ifndef KAB_EMBEDDED | 1070 | #ifndef KAB_EMBEDDED |
1049 | KPrinter printer; | 1071 | KPrinter printer; |
1050 | if ( !printer.setup( this ) ) | 1072 | if ( !printer.setup( this ) ) |
1051 | return; | 1073 | return; |
1052 | 1074 | ||
1053 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1075 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1054 | mViewManager->selectedUids(), this ); | 1076 | mViewManager->selectedUids(), this ); |
1055 | 1077 | ||
1056 | wizard.exec(); | 1078 | wizard.exec(); |
1057 | #else //KAB_EMBEDDED | 1079 | #else //KAB_EMBEDDED |
1058 | qDebug("KABCore::print() finsih method"); | 1080 | qDebug("KABCore::print() finsih method"); |
1059 | #endif //KAB_EMBEDDED | 1081 | #endif //KAB_EMBEDDED |
1060 | 1082 | ||
1061 | } | 1083 | } |
1062 | 1084 | ||
1063 | 1085 | ||
1064 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1086 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1065 | { | 1087 | { |
1066 | if ( mGUIClient ) | 1088 | if ( mGUIClient ) |
1067 | mGUIClient->insertChildClient( client ); | 1089 | mGUIClient->insertChildClient( client ); |
1068 | else | 1090 | else |
1069 | KMessageBox::error( this, "no KXMLGUICLient"); | 1091 | KMessageBox::error( this, "no KXMLGUICLient"); |
1070 | } | 1092 | } |
1071 | 1093 | ||
1072 | 1094 | ||
1073 | void KABCore::configurationChanged() | 1095 | void KABCore::configurationChanged() |
1074 | { | 1096 | { |
1075 | mExtensionManager->reconfigure(); | 1097 | mExtensionManager->reconfigure(); |
1076 | } | 1098 | } |
1077 | 1099 | ||
1078 | void KABCore::addressBookChanged() | 1100 | void KABCore::addressBookChanged() |
1079 | { | 1101 | { |
1080 | #ifndef KAB_EMBEDDED | 1102 | #ifndef KAB_EMBEDDED |
1081 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1103 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1082 | while ( it.current() ) { | 1104 | while ( it.current() ) { |
1083 | if ( it.current()->dirty() ) { | 1105 | if ( it.current()->dirty() ) { |
1084 | QString text = i18n( "Data has been changed externally. Unsaved " | 1106 | QString text = i18n( "Data has been changed externally. Unsaved " |
1085 | "changes will be lost." ); | 1107 | "changes will be lost." ); |
1086 | KMessageBox::information( this, text ); | 1108 | KMessageBox::information( this, text ); |
1087 | } | 1109 | } |
1088 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1110 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1089 | ++it; | 1111 | ++it; |
1090 | } | 1112 | } |
1091 | 1113 | ||
1092 | mViewManager->refreshView(); | 1114 | mViewManager->refreshView(); |
1093 | #else //KAB_EMBEDDED | 1115 | #else //KAB_EMBEDDED |
1094 | qDebug("KABCore::addressBookChanged() finsih method"); | 1116 | qDebug("KABCore::addressBookChanged() finsih method"); |
1095 | #endif //KAB_EMBEDDED | 1117 | #endif //KAB_EMBEDDED |
1096 | } | 1118 | } |
1097 | 1119 | ||
1098 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1120 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1099 | const char *name ) | 1121 | const char *name ) |
1100 | { | 1122 | { |
1101 | 1123 | ||
1102 | if ( mEditorDialog == 0 ) { | 1124 | if ( mEditorDialog == 0 ) { |
1103 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1125 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1104 | name ? name : "editorDialog" ); | 1126 | name ? name : "editorDialog" ); |
1105 | 1127 | ||
1106 | 1128 | ||
1107 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1129 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1108 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1130 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1109 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1131 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1110 | // SLOT( slotEditorDestroyed( const QString& ) ) ); | 1132 | // SLOT( slotEditorDestroyed( const QString& ) ) ); |
1111 | } | 1133 | } |
1112 | 1134 | ||
1113 | return mEditorDialog; | 1135 | return mEditorDialog; |
1114 | } | 1136 | } |
1115 | 1137 | ||
1116 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1138 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1117 | { | 1139 | { |
1118 | qDebug("KABCore::slotEditorDestroyed called. maybe a problem! "); | 1140 | qDebug("KABCore::slotEditorDestroyed called. maybe a problem! "); |
1119 | //mEditorDict.remove( uid ); | 1141 | //mEditorDict.remove( uid ); |
1120 | } | 1142 | } |
1121 | 1143 | ||
1122 | void KABCore::initGUI() | 1144 | void KABCore::initGUI() |
1123 | { | 1145 | { |
1124 | #ifndef KAB_EMBEDDED | 1146 | #ifndef KAB_EMBEDDED |
1125 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1147 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1126 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1148 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1127 | 1149 | ||
1128 | mExtensionBarSplitter = new QSplitter( this ); | 1150 | mExtensionBarSplitter = new QSplitter( this ); |
1129 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1151 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1130 | 1152 | ||
1131 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1153 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1132 | 1154 | ||
1133 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1155 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1134 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1156 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1135 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1157 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1136 | SLOT( incrementalSearch( const QString& ) ) ); | 1158 | SLOT( incrementalSearch( const QString& ) ) ); |
1137 | 1159 | ||
1138 | mViewManager = new ViewManager( this, viewSpace ); | 1160 | mViewManager = new ViewManager( this, viewSpace ); |
1139 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1161 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1140 | 1162 | ||
1141 | mDetails = new ViewContainer( mDetailsSplitter ); | 1163 | mDetails = new ViewContainer( mDetailsSplitter ); |
1142 | 1164 | ||
1143 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1165 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1144 | 1166 | ||
1145 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1167 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1146 | 1168 | ||
1147 | topLayout->addWidget( mExtensionBarSplitter ); | 1169 | topLayout->addWidget( mExtensionBarSplitter ); |
1148 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1170 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1149 | topLayout->addWidget( mJumpButtonBar ); | 1171 | topLayout->addWidget( mJumpButtonBar ); |
1150 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1172 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1151 | 1173 | ||
1152 | mXXPortManager = new XXPortManager( this, this ); | 1174 | mXXPortManager = new XXPortManager( this, this ); |
1153 | 1175 | ||
1154 | #else //KAB_EMBEDDED | 1176 | #else //KAB_EMBEDDED |
1155 | //US initialize viewMenu before settingup viewmanager. | 1177 | //US initialize viewMenu before settingup viewmanager. |
1156 | // Viewmanager needs this menu to plugin submenues. | 1178 | // Viewmanager needs this menu to plugin submenues. |
1157 | viewMenu = new QPopupMenu( this ); | 1179 | viewMenu = new QPopupMenu( this ); |
1158 | settingsMenu = new QPopupMenu( this ); | 1180 | settingsMenu = new QPopupMenu( this ); |
1159 | //filterMenu = new QPopupMenu( this ); | 1181 | //filterMenu = new QPopupMenu( this ); |
1160 | ImportMenu = new QPopupMenu( this ); | 1182 | ImportMenu = new QPopupMenu( this ); |
1161 | ExportMenu = new QPopupMenu( this ); | 1183 | ExportMenu = new QPopupMenu( this ); |
1162 | 1184 | ||
1163 | changeMenu= new QPopupMenu( this ); | 1185 | changeMenu= new QPopupMenu( this ); |
1164 | 1186 | ||
1165 | //US since we have no splitter for the embedded system, setup | 1187 | //US since we have no splitter for the embedded system, setup |
1166 | // a layout with two frames. One left and one right. | 1188 | // a layout with two frames. One left and one right. |
1167 | 1189 | ||
1168 | QBoxLayout *topLayout; | 1190 | QBoxLayout *topLayout; |
1169 | 1191 | ||
1170 | // = new QHBoxLayout( this ); | 1192 | // = new QHBoxLayout( this ); |
1171 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1193 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1172 | 1194 | ||
1173 | // QWidget *mainBox = new QWidget( this ); | 1195 | // QWidget *mainBox = new QWidget( this ); |
1174 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1196 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1175 | 1197 | ||
1176 | #ifdef DESKTOP_VERSION | 1198 | #ifdef DESKTOP_VERSION |
1177 | topLayout = new QHBoxLayout( this ); | 1199 | topLayout = new QHBoxLayout( this ); |
1178 | 1200 | ||
1179 | 1201 | ||
1180 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1202 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1181 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1203 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1182 | 1204 | ||
1183 | topLayout->addWidget(mMiniSplitter ); | 1205 | topLayout->addWidget(mMiniSplitter ); |
1184 | 1206 | ||
1185 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1207 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1186 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1208 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1187 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1209 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1188 | mDetails = new ViewContainer( mMiniSplitter ); | 1210 | mDetails = new ViewContainer( mMiniSplitter ); |
1189 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1211 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1190 | #else | 1212 | #else |
1191 | if ( QApplication::desktop()->width() > 480 ) { | 1213 | if ( QApplication::desktop()->width() > 480 ) { |
1192 | topLayout = new QHBoxLayout( this ); | 1214 | topLayout = new QHBoxLayout( this ); |
1193 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1215 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1194 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1216 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1195 | } else { | 1217 | } else { |
1196 | 1218 | ||
1197 | topLayout = new QHBoxLayout( this ); | 1219 | topLayout = new QHBoxLayout( this ); |
1198 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1220 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1199 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1221 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1200 | } | 1222 | } |
1201 | 1223 | ||
1202 | topLayout->addWidget(mMiniSplitter ); | 1224 | topLayout->addWidget(mMiniSplitter ); |
1203 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1225 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1204 | mDetails = new ViewContainer( mMiniSplitter ); | 1226 | mDetails = new ViewContainer( mMiniSplitter ); |
1205 | 1227 | ||
1206 | 1228 | ||
1207 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1229 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1208 | #endif | 1230 | #endif |
1209 | //eh->hide(); | 1231 | //eh->hide(); |
1210 | // topLayout->addWidget(mExtensionManager ); | 1232 | // topLayout->addWidget(mExtensionManager ); |
1211 | 1233 | ||
1212 | 1234 | ||
1213 | /*US | 1235 | /*US |
1214 | #ifndef KAB_NOSPLITTER | 1236 | #ifndef KAB_NOSPLITTER |
1215 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1237 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1216 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1238 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1217 | topLayout->setSpacing( 10 ); | 1239 | topLayout->setSpacing( 10 ); |
1218 | 1240 | ||
1219 | mDetailsSplitter = new QSplitter( this ); | 1241 | mDetailsSplitter = new QSplitter( this ); |
1220 | 1242 | ||
1221 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1243 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1222 | 1244 | ||
1223 | mViewManager = new ViewManager( this, viewSpace ); | 1245 | mViewManager = new ViewManager( this, viewSpace ); |
1224 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1246 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1225 | 1247 | ||
1226 | mDetails = new ViewContainer( mDetailsSplitter ); | 1248 | mDetails = new ViewContainer( mDetailsSplitter ); |
1227 | 1249 | ||
1228 | topLayout->addWidget( mDetailsSplitter ); | 1250 | topLayout->addWidget( mDetailsSplitter ); |
1229 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1251 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1230 | #else //KAB_NOSPLITTER | 1252 | #else //KAB_NOSPLITTER |
1231 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1253 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1232 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1254 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1233 | topLayout->setSpacing( 10 ); | 1255 | topLayout->setSpacing( 10 ); |
1234 | 1256 | ||
1235 | // mDetailsSplitter = new QSplitter( this ); | 1257 | // mDetailsSplitter = new QSplitter( this ); |
1236 | 1258 | ||
1237 | QVBox *viewSpace = new QVBox( this ); | 1259 | QVBox *viewSpace = new QVBox( this ); |
1238 | 1260 | ||
1239 | mViewManager = new ViewManager( this, viewSpace ); | 1261 | mViewManager = new ViewManager( this, viewSpace ); |
1240 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1262 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1241 | 1263 | ||
1242 | mDetails = new ViewContainer( this ); | 1264 | mDetails = new ViewContainer( this ); |
1243 | 1265 | ||
1244 | topLayout->addWidget( viewSpace ); | 1266 | topLayout->addWidget( viewSpace ); |
1245 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1267 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1246 | topLayout->addWidget( mDetails ); | 1268 | topLayout->addWidget( mDetails ); |
1247 | #endif //KAB_NOSPLITTER | 1269 | #endif //KAB_NOSPLITTER |
1248 | */ | 1270 | */ |
1249 | 1271 | ||
1250 | 1272 | ||
1251 | #endif //KAB_EMBEDDED | 1273 | #endif //KAB_EMBEDDED |
1252 | initActions(); | 1274 | initActions(); |
1253 | 1275 | ||
1254 | #ifdef KAB_EMBEDDED | 1276 | #ifdef KAB_EMBEDDED |
1255 | addActionsManually(); | 1277 | addActionsManually(); |
1256 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1278 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1257 | mXXPortManager = new XXPortManager( this, this ); | 1279 | mXXPortManager = new XXPortManager( this, this ); |
1258 | 1280 | ||
1259 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1281 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1260 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1282 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1261 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1283 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1262 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1284 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1263 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1285 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1264 | // mIncSearchWidget->hide(); | 1286 | // mIncSearchWidget->hide(); |
1265 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1287 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1266 | SLOT( incrementalSearch( const QString& ) ) ); | 1288 | SLOT( incrementalSearch( const QString& ) ) ); |
1267 | 1289 | ||
1268 | 1290 | ||
1269 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1291 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1270 | 1292 | ||
1271 | topLayout->addWidget( mJumpButtonBar ); | 1293 | topLayout->addWidget( mJumpButtonBar ); |
1272 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1294 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1273 | 1295 | ||
1274 | // mMainWindow->getIconToolBar()->raise(); | 1296 | // mMainWindow->getIconToolBar()->raise(); |
1275 | 1297 | ||
1276 | #endif //KAB_EMBEDDED | 1298 | #endif //KAB_EMBEDDED |
1277 | 1299 | ||
1278 | } | 1300 | } |
1279 | void KABCore::initActions() | 1301 | void KABCore::initActions() |
1280 | { | 1302 | { |
1281 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1303 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1282 | 1304 | ||
1283 | #ifndef KAB_EMBEDDED | 1305 | #ifndef KAB_EMBEDDED |
1284 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1306 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1285 | SLOT( clipboardDataChanged() ) ); | 1307 | SLOT( clipboardDataChanged() ) ); |
1286 | #endif //KAB_EMBEDDED | 1308 | #endif //KAB_EMBEDDED |
1287 | 1309 | ||
1288 | // file menu | 1310 | // file menu |
1289 | if ( mIsPart ) { | 1311 | if ( mIsPart ) { |
1290 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1312 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1291 | SLOT( sendMail() ), actionCollection(), | 1313 | SLOT( sendMail() ), actionCollection(), |
1292 | "kaddressbook_mail" ); | 1314 | "kaddressbook_mail" ); |
1293 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1315 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1294 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1316 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1295 | 1317 | ||
1296 | } else { | 1318 | } else { |
1297 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1319 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1298 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1320 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1299 | } | 1321 | } |
1300 | 1322 | ||
1301 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1323 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1302 | SLOT( save() ), actionCollection(), "file_sync" ); | 1324 | SLOT( save() ), actionCollection(), "file_sync" ); |
1303 | 1325 | ||
1304 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1326 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1305 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1327 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1306 | 1328 | ||
1307 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1329 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1308 | this, SLOT( mailVCard() ), | 1330 | this, SLOT( mailVCard() ), |
1309 | actionCollection(), "file_mail_vcard"); | 1331 | actionCollection(), "file_mail_vcard"); |
1310 | 1332 | ||
1311 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1333 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1312 | this, SLOT( editContact2() ), | 1334 | this, SLOT( editContact2() ), |
1313 | actionCollection(), "file_properties" ); | 1335 | actionCollection(), "file_properties" ); |
1314 | 1336 | ||
1315 | #ifdef KAB_EMBEDDED | 1337 | #ifdef KAB_EMBEDDED |
1316 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1338 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1317 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1339 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1318 | mMainWindow, SLOT( exit() ), | 1340 | mMainWindow, SLOT( exit() ), |
1319 | actionCollection(), "quit" ); | 1341 | actionCollection(), "quit" ); |
1320 | #endif //KAB_EMBEDDED | 1342 | #endif //KAB_EMBEDDED |
1321 | 1343 | ||
1322 | // edit menu | 1344 | // edit menu |
1323 | if ( mIsPart ) { | 1345 | if ( mIsPart ) { |
1324 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1346 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1325 | SLOT( copyContacts() ), actionCollection(), | 1347 | SLOT( copyContacts() ), actionCollection(), |
1326 | "kaddressbook_copy" ); | 1348 | "kaddressbook_copy" ); |
1327 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1349 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1328 | SLOT( cutContacts() ), actionCollection(), | 1350 | SLOT( cutContacts() ), actionCollection(), |
1329 | "kaddressbook_cut" ); | 1351 | "kaddressbook_cut" ); |
1330 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1352 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1331 | SLOT( pasteContacts() ), actionCollection(), | 1353 | SLOT( pasteContacts() ), actionCollection(), |
1332 | "kaddressbook_paste" ); | 1354 | "kaddressbook_paste" ); |
1333 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1355 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1334 | SLOT( selectAllContacts() ), actionCollection(), | 1356 | SLOT( selectAllContacts() ), actionCollection(), |
1335 | "kaddressbook_select_all" ); | 1357 | "kaddressbook_select_all" ); |
1336 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1358 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1337 | SLOT( undo() ), actionCollection(), | 1359 | SLOT( undo() ), actionCollection(), |
1338 | "kaddressbook_undo" ); | 1360 | "kaddressbook_undo" ); |
1339 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1361 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1340 | this, SLOT( redo() ), actionCollection(), | 1362 | this, SLOT( redo() ), actionCollection(), |
1341 | "kaddressbook_redo" ); | 1363 | "kaddressbook_redo" ); |
1342 | } else { | 1364 | } else { |
1343 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1365 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1344 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1366 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1345 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1367 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1346 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1368 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1347 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1369 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1348 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1370 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1349 | } | 1371 | } |
1350 | 1372 | ||
1351 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1373 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1352 | Key_Delete, this, SLOT( deleteContacts() ), | 1374 | Key_Delete, this, SLOT( deleteContacts() ), |
1353 | actionCollection(), "edit_delete" ); | 1375 | actionCollection(), "edit_delete" ); |
1354 | 1376 | ||
1355 | mActionUndo->setEnabled( false ); | 1377 | mActionUndo->setEnabled( false ); |
1356 | mActionRedo->setEnabled( false ); | 1378 | mActionRedo->setEnabled( false ); |
1357 | 1379 | ||
1358 | // settings menu | 1380 | // settings menu |
1359 | #ifdef KAB_EMBEDDED | 1381 | #ifdef KAB_EMBEDDED |
1360 | //US special menuentry to configure the addressbook resources. On KDE | 1382 | //US special menuentry to configure the addressbook resources. On KDE |
1361 | // you do that through the control center !!! | 1383 | // you do that through the control center !!! |
1362 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1384 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1363 | SLOT( configureResources() ), actionCollection(), | 1385 | SLOT( configureResources() ), actionCollection(), |
1364 | "kaddressbook_configure_resources" ); | 1386 | "kaddressbook_configure_resources" ); |
1365 | #endif //KAB_EMBEDDED | 1387 | #endif //KAB_EMBEDDED |
1366 | 1388 | ||
1367 | if ( mIsPart ) { | 1389 | if ( mIsPart ) { |
1368 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1390 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1369 | SLOT( openConfigDialog() ), actionCollection(), | 1391 | SLOT( openConfigDialog() ), actionCollection(), |
1370 | "kaddressbook_configure" ); | 1392 | "kaddressbook_configure" ); |
1371 | 1393 | ||
1372 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1394 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1373 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1395 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1374 | "kaddressbook_configure_shortcuts" ); | 1396 | "kaddressbook_configure_shortcuts" ); |
1375 | #ifdef KAB_EMBEDDED | 1397 | #ifdef KAB_EMBEDDED |
1376 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1398 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1377 | mActionConfigureToolbars->setEnabled( false ); | 1399 | mActionConfigureToolbars->setEnabled( false ); |
1378 | #endif //KAB_EMBEDDED | 1400 | #endif //KAB_EMBEDDED |
1379 | 1401 | ||
1380 | } else { | 1402 | } else { |
1381 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1403 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1382 | 1404 | ||
1383 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1405 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1384 | } | 1406 | } |
1385 | 1407 | ||
1386 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1408 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1387 | actionCollection(), "options_show_jump_bar" ); | 1409 | actionCollection(), "options_show_jump_bar" ); |
1388 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1410 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1389 | 1411 | ||
1390 | mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0, | 1412 | mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0, |
1391 | actionCollection(), "options_show_details" ); | 1413 | actionCollection(), "options_show_details" ); |
1392 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1414 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1393 | 1415 | ||
1394 | // misc | 1416 | // misc |
1395 | // only enable LDAP lookup if we can handle the protocol | 1417 | // only enable LDAP lookup if we can handle the protocol |
1396 | #ifndef KAB_EMBEDDED | 1418 | #ifndef KAB_EMBEDDED |
1397 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1419 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1398 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1420 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1399 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1421 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1400 | "ldap_lookup" ); | 1422 | "ldap_lookup" ); |
1401 | } | 1423 | } |
1402 | #else //KAB_EMBEDDED | 1424 | #else //KAB_EMBEDDED |
1403 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1425 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1404 | #endif //KAB_EMBEDDED | 1426 | #endif //KAB_EMBEDDED |
1405 | 1427 | ||
1406 | 1428 | ||
1407 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1429 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1408 | SLOT( setWhoAmI() ), actionCollection(), | 1430 | SLOT( setWhoAmI() ), actionCollection(), |
1409 | "set_personal" ); | 1431 | "set_personal" ); |
1410 | 1432 | ||
1411 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1433 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1412 | SLOT( setCategories() ), actionCollection(), | 1434 | SLOT( setCategories() ), actionCollection(), |
1413 | "edit_set_categories" ); | 1435 | "edit_set_categories" ); |
1414 | 1436 | ||
1415 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1437 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1416 | SLOT( removeVoice() ), actionCollection(), | 1438 | SLOT( removeVoice() ), actionCollection(), |
1417 | "remove_voice" ); | 1439 | "remove_voice" ); |
1418 | mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, | 1440 | mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, |
1419 | SLOT( importFromOL() ), actionCollection(), | 1441 | SLOT( importFromOL() ), actionCollection(), |
1420 | "import_OL" ); | 1442 | "import_OL" ); |
1421 | #ifdef KAB_EMBEDDED | 1443 | #ifdef KAB_EMBEDDED |
1422 | 1444 | ||
1423 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1445 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1424 | this, SLOT( createAboutData() ), actionCollection(), | 1446 | this, SLOT( createAboutData() ), actionCollection(), |
1425 | "kaddressbook_about_data" ); | 1447 | "kaddressbook_about_data" ); |
1426 | #endif //KAB_EMBEDDED | 1448 | #endif //KAB_EMBEDDED |
1427 | 1449 | ||
1428 | clipboardDataChanged(); | 1450 | clipboardDataChanged(); |
1429 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1451 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1430 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1452 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1431 | } | 1453 | } |
1432 | 1454 | ||
1433 | //US we need this function, to plug all actions into the correct menues. | 1455 | //US we need this function, to plug all actions into the correct menues. |
1434 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1456 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1435 | void KABCore::addActionsManually() | 1457 | void KABCore::addActionsManually() |
1436 | { | 1458 | { |
1437 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1459 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1438 | 1460 | ||
1439 | #ifdef KAB_EMBEDDED | 1461 | #ifdef KAB_EMBEDDED |
1440 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1462 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1441 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1463 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1442 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1464 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1443 | 1465 | ||
1444 | KToolBar* tb = mMainWindow->toolBar(); | 1466 | KToolBar* tb = mMainWindow->toolBar(); |
1445 | 1467 | ||
1446 | #ifdef DESKTOP_VERSION | 1468 | #ifdef DESKTOP_VERSION |
1447 | QMenuBar* mb = mMainWindow->menuBar(); | 1469 | QMenuBar* mb = mMainWindow->menuBar(); |
1448 | 1470 | ||
1449 | //US setup menubar. | 1471 | //US setup menubar. |
1450 | //Disable the following block if you do not want to have a menubar. | 1472 | //Disable the following block if you do not want to have a menubar. |
1451 | mb->insertItem( "&File", fileMenu ); | 1473 | mb->insertItem( "&File", fileMenu ); |
1452 | mb->insertItem( "&Edit", editMenu ); | 1474 | mb->insertItem( "&Edit", editMenu ); |
1453 | mb->insertItem( "&View", viewMenu ); | 1475 | mb->insertItem( "&View", viewMenu ); |
1454 | mb->insertItem( "&Settings", settingsMenu ); | 1476 | mb->insertItem( "&Settings", settingsMenu ); |
1455 | mb->insertItem( "&Change selected", changeMenu ); | 1477 | mb->insertItem( "&Change selected", changeMenu ); |
1456 | mb->insertItem( "&Help", helpMenu ); | 1478 | mb->insertItem( "&Help", helpMenu ); |
1457 | mIncSearchWidget = new IncSearchWidget( tb ); | 1479 | mIncSearchWidget = new IncSearchWidget( tb ); |
1458 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1480 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1459 | 1481 | ||
1460 | #else | 1482 | #else |
1461 | //US setup toolbar | 1483 | //US setup toolbar |
1462 | QMenuBar *menuBarTB = new QMenuBar( tb ); | 1484 | QMenuBar *menuBarTB = new QMenuBar( tb ); |
1463 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1485 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1464 | menuBarTB->insertItem( "ME", popupBarTB); | 1486 | menuBarTB->insertItem( "ME", popupBarTB); |
1465 | tb->insertWidget(-1, 0, menuBarTB); | 1487 | tb->insertWidget(-1, 0, menuBarTB); |
1466 | mIncSearchWidget = new IncSearchWidget( tb ); | 1488 | mIncSearchWidget = new IncSearchWidget( tb ); |
1467 | 1489 | ||
1468 | tb->enableMoving(false); | 1490 | tb->enableMoving(false); |
1469 | popupBarTB->insertItem( "&File", fileMenu ); | 1491 | popupBarTB->insertItem( "&File", fileMenu ); |
1470 | popupBarTB->insertItem( "&Edit", editMenu ); | 1492 | popupBarTB->insertItem( "&Edit", editMenu ); |
1471 | popupBarTB->insertItem( "&View", viewMenu ); | 1493 | popupBarTB->insertItem( "&View", viewMenu ); |
1472 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1494 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1473 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1495 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1474 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1496 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1475 | popupBarTB->insertItem( "&Help", helpMenu ); | 1497 | popupBarTB->insertItem( "&Help", helpMenu ); |
1476 | if (QApplication::desktop()->width() > 320 ) { | 1498 | if (QApplication::desktop()->width() > 320 ) { |
1477 | // mViewManager->getFilterAction()->plug ( tb); | 1499 | // mViewManager->getFilterAction()->plug ( tb); |
1478 | } | 1500 | } |
1479 | #endif | 1501 | #endif |
1480 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1502 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1481 | 1503 | ||
1482 | 1504 | ||
1483 | 1505 | ||
1484 | //US Now connect the actions with the menue entries. | 1506 | //US Now connect the actions with the menue entries. |
1485 | mActionPrint->plug( fileMenu ); | 1507 | mActionPrint->plug( fileMenu ); |
1486 | mActionMail->plug( fileMenu ); | 1508 | mActionMail->plug( fileMenu ); |
1487 | fileMenu->insertSeparator(); | 1509 | fileMenu->insertSeparator(); |
1488 | 1510 | ||
1489 | mActionNewContact->plug( fileMenu ); | 1511 | mActionNewContact->plug( fileMenu ); |
1490 | mActionNewContact->plug( tb ); | 1512 | mActionNewContact->plug( tb ); |
1491 | 1513 | ||
1492 | mActionEditAddressee->plug( fileMenu ); | 1514 | mActionEditAddressee->plug( fileMenu ); |
1493 | fileMenu->insertSeparator(); | 1515 | fileMenu->insertSeparator(); |
1494 | mActionSave->plug( fileMenu ); | 1516 | mActionSave->plug( fileMenu ); |
1495 | fileMenu->insertItem( "&Import", ImportMenu ); | 1517 | fileMenu->insertItem( "&Import", ImportMenu ); |
1496 | fileMenu->insertItem( "&Emport", ExportMenu ); | 1518 | fileMenu->insertItem( "&Emport", ExportMenu ); |
1497 | fileMenu->insertSeparator(); | 1519 | fileMenu->insertSeparator(); |
1498 | mActionMailVCard->plug( fileMenu ); | 1520 | mActionMailVCard->plug( fileMenu ); |
1499 | fileMenu->insertSeparator(); | 1521 | fileMenu->insertSeparator(); |
1500 | mActionQuit->plug( fileMenu ); | 1522 | mActionQuit->plug( fileMenu ); |
1501 | #ifdef _WIN32_ | 1523 | #ifdef _WIN32_ |
1502 | mActionImportOL->plug( ImportMenu ); | 1524 | mActionImportOL->plug( ImportMenu ); |
1503 | #endif | 1525 | #endif |
1504 | // edit menu | 1526 | // edit menu |
1505 | mActionUndo->plug( editMenu ); | 1527 | mActionUndo->plug( editMenu ); |
1506 | mActionRedo->plug( editMenu ); | 1528 | mActionRedo->plug( editMenu ); |
1507 | editMenu->insertSeparator(); | 1529 | editMenu->insertSeparator(); |
1508 | mActionCut->plug( editMenu ); | 1530 | mActionCut->plug( editMenu ); |
1509 | mActionCopy->plug( editMenu ); | 1531 | mActionCopy->plug( editMenu ); |
1510 | mActionPaste->plug( editMenu ); | 1532 | mActionPaste->plug( editMenu ); |
1511 | mActionDelete->plug( editMenu ); | 1533 | mActionDelete->plug( editMenu ); |
1512 | editMenu->insertSeparator(); | 1534 | editMenu->insertSeparator(); |
1513 | mActionSelectAll->plug( editMenu ); | 1535 | mActionSelectAll->plug( editMenu ); |
1514 | 1536 | ||
1515 | mActionRemoveVoice->plug( changeMenu ); | 1537 | mActionRemoveVoice->plug( changeMenu ); |
1516 | // settings menu | 1538 | // settings menu |
1517 | //US special menuentry to configure the addressbook resources. On KDE | 1539 | //US special menuentry to configure the addressbook resources. On KDE |
1518 | // you do that through the control center !!! | 1540 | // you do that through the control center !!! |
1519 | mActionConfigResources->plug( settingsMenu ); | 1541 | mActionConfigResources->plug( settingsMenu ); |
1520 | settingsMenu->insertSeparator(); | 1542 | settingsMenu->insertSeparator(); |
1521 | 1543 | ||
1522 | mActionConfigKAddressbook->plug( settingsMenu ); | 1544 | mActionConfigKAddressbook->plug( settingsMenu ); |
1523 | 1545 | ||
1524 | if ( mIsPart ) { | 1546 | if ( mIsPart ) { |
1525 | mActionConfigShortcuts->plug( settingsMenu ); | 1547 | mActionConfigShortcuts->plug( settingsMenu ); |
1526 | mActionConfigureToolbars->plug( settingsMenu ); | 1548 | mActionConfigureToolbars->plug( settingsMenu ); |
1527 | 1549 | ||
1528 | } else { | 1550 | } else { |
1529 | mActionKeyBindings->plug( settingsMenu ); | 1551 | mActionKeyBindings->plug( settingsMenu ); |
1530 | } | 1552 | } |
1531 | 1553 | ||
1532 | settingsMenu->insertSeparator(); | 1554 | settingsMenu->insertSeparator(); |
1533 | 1555 | ||
1534 | mActionJumpBar->plug( settingsMenu ); | 1556 | mActionJumpBar->plug( settingsMenu ); |
1535 | mActionDetails->plug( settingsMenu ); | 1557 | mActionDetails->plug( settingsMenu ); |
1536 | settingsMenu->insertSeparator(); | 1558 | settingsMenu->insertSeparator(); |
1537 | 1559 | ||
1538 | mActionWhoAmI->plug( settingsMenu ); | 1560 | mActionWhoAmI->plug( settingsMenu ); |
1539 | mActionCategories->plug( settingsMenu ); | 1561 | mActionCategories->plug( settingsMenu ); |
1540 | 1562 | ||
1541 | mActionAboutKAddressbook->plug( helpMenu ); | 1563 | mActionAboutKAddressbook->plug( helpMenu ); |
1542 | 1564 | ||
1543 | 1565 | ||
1544 | if (QApplication::desktop()->width() > 320 ) { | 1566 | if (QApplication::desktop()->width() > 320 ) { |
1545 | 1567 | ||
1546 | mActionEditAddressee->plug( tb ); | 1568 | mActionEditAddressee->plug( tb ); |
1547 | mActionSave->plug( tb ); | 1569 | mActionSave->plug( tb ); |
1548 | mViewManager->getFilterAction()->plug ( tb); | 1570 | mViewManager->getFilterAction()->plug ( tb); |
1549 | if (QApplication::desktop()->width() > 480 ) { | 1571 | if (QApplication::desktop()->width() > 480 ) { |
1550 | mActionUndo->plug( tb ); | 1572 | mActionUndo->plug( tb ); |
1551 | mActionDelete->plug( tb ); | 1573 | mActionDelete->plug( tb ); |
1552 | mActionRedo->plug( tb ); | 1574 | mActionRedo->plug( tb ); |
1553 | } | 1575 | } |
1554 | } | 1576 | } |
1555 | //mActionQuit->plug ( tb ); | 1577 | //mActionQuit->plug ( tb ); |
1556 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1578 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1557 | 1579 | ||
1558 | //US link the searchwidget first to this. | 1580 | //US link the searchwidget first to this. |
1559 | // The real linkage to the toolbar happens later. | 1581 | // The real linkage to the toolbar happens later. |
1560 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1582 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1561 | //US tb->insertItem( mIncSearchWidget ); | 1583 | //US tb->insertItem( mIncSearchWidget ); |
1562 | /*US | 1584 | /*US |
1563 | mIncSearchWidget = new IncSearchWidget( tb ); | 1585 | mIncSearchWidget = new IncSearchWidget( tb ); |
1564 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1586 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1565 | SLOT( incrementalSearch( const QString& ) ) ); | 1587 | SLOT( incrementalSearch( const QString& ) ) ); |
1566 | 1588 | ||
1567 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1589 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1568 | 1590 | ||
1569 | //US topLayout->addWidget( mJumpButtonBar ); | 1591 | //US topLayout->addWidget( mJumpButtonBar ); |
1570 | this->layout()->add( mJumpButtonBar ); | 1592 | this->layout()->add( mJumpButtonBar ); |
1571 | */ | 1593 | */ |
1572 | 1594 | ||
1573 | #endif //KAB_EMBEDDED | 1595 | #endif //KAB_EMBEDDED |
1574 | } | 1596 | } |
1575 | void KABCore::removeVoice() | 1597 | void KABCore::removeVoice() |
1576 | { | 1598 | { |
1577 | 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 ) | 1599 | 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 ) |
1578 | return; | 1600 | return; |
1579 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 1601 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
1580 | KABC::Addressee::List::Iterator it; | 1602 | KABC::Addressee::List::Iterator it; |
1581 | for ( it = list.begin(); it != list.end(); ++it ) { | 1603 | for ( it = list.begin(); it != list.end(); ++it ) { |
1582 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 1604 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
1583 | PhoneNumber::List::Iterator phoneIt; | 1605 | PhoneNumber::List::Iterator phoneIt; |
1584 | bool found = false; | 1606 | bool found = false; |
1585 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 1607 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
1586 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 1608 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
1587 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 1609 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
1588 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 1610 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
1589 | (*it).insertPhoneNumber( (*phoneIt) ); | 1611 | (*it).insertPhoneNumber( (*phoneIt) ); |
1590 | found = true; | 1612 | found = true; |
1591 | } | 1613 | } |
1592 | } | 1614 | } |
1593 | 1615 | ||
1594 | } | 1616 | } |
1595 | if ( found ) | 1617 | if ( found ) |
1596 | contactModified((*it) ); | 1618 | contactModified((*it) ); |
1597 | } | 1619 | } |
1598 | } | 1620 | } |
1599 | 1621 | ||
1600 | 1622 | ||
1601 | 1623 | ||
1602 | void KABCore::clipboardDataChanged() | 1624 | void KABCore::clipboardDataChanged() |
1603 | { | 1625 | { |
1604 | 1626 | ||
1605 | if ( mReadWrite ) | 1627 | if ( mReadWrite ) |
1606 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 1628 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
1607 | 1629 | ||
1608 | } | 1630 | } |
1609 | 1631 | ||
1610 | void KABCore::updateActionMenu() | 1632 | void KABCore::updateActionMenu() |
1611 | { | 1633 | { |
1612 | UndoStack *undo = UndoStack::instance(); | 1634 | UndoStack *undo = UndoStack::instance(); |
1613 | RedoStack *redo = RedoStack::instance(); | 1635 | RedoStack *redo = RedoStack::instance(); |
1614 | 1636 | ||
1615 | if ( undo->isEmpty() ) | 1637 | if ( undo->isEmpty() ) |
1616 | mActionUndo->setText( i18n( "Undo" ) ); | 1638 | mActionUndo->setText( i18n( "Undo" ) ); |
1617 | else | 1639 | else |
1618 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 1640 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
1619 | 1641 | ||
1620 | mActionUndo->setEnabled( !undo->isEmpty() ); | 1642 | mActionUndo->setEnabled( !undo->isEmpty() ); |
1621 | 1643 | ||
1622 | if ( !redo->top() ) | 1644 | if ( !redo->top() ) |
1623 | mActionRedo->setText( i18n( "Redo" ) ); | 1645 | mActionRedo->setText( i18n( "Redo" ) ); |
1624 | else | 1646 | else |
1625 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 1647 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
1626 | 1648 | ||
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp index 5e7d7c4..ef949e7 100644 --- a/kaddressbook/kaimportoldialog.cpp +++ b/kaddressbook/kaimportoldialog.cpp | |||
@@ -1,635 +1,639 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook/Pi. | 2 | This file is part of KAddressbook/Pi. |
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qframe.h> | 25 | #include <qframe.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qprogressbar.h> | 28 | #include <qprogressbar.h> |
29 | #include <qwidgetstack.h> | 29 | #include <qwidgetstack.h> |
30 | #include <qdatetime.h> | 30 | #include <qdatetime.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | #include <qhbox.h> | 33 | #include <qhbox.h> |
34 | #include <qheader.h> | 34 | #include <qheader.h> |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include <qlistview.h> | 36 | #include <qlistview.h> |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <klocale.h> | 39 | #include <klocale.h> |
40 | #include <kstandarddirs.h> | 40 | #include <kstandarddirs.h> |
41 | #include <kmessagebox.h> | 41 | #include <kmessagebox.h> |
42 | #include <kfiledialog.h> | 42 | #include <kfiledialog.h> |
43 | 43 | ||
44 | #include <libkdepim/categoryselectdialog.h> | 44 | #include <libkdepim/categoryselectdialog.h> |
45 | #include <libkdepim/kinputdialog.h> | 45 | #include <libkdepim/kinputdialog.h> |
46 | 46 | ||
47 | #include <libkcal/calendarlocal.h> | 47 | #include <libkcal/calendarlocal.h> |
48 | #include <libkcal/icalformat.h> | 48 | #include <libkcal/icalformat.h> |
49 | 49 | ||
50 | #include <kabc/addresseelist.h> | 50 | #include <kabc/addresseelist.h> |
51 | #include <kabc/phonenumber.h> | 51 | #include <kabc/phonenumber.h> |
52 | 52 | ||
53 | #include "kaimportoldialog.h" | 53 | #include "kaimportoldialog.h" |
54 | 54 | ||
55 | #include "../outport/msoutl9.h" | 55 | #include "../outport/msoutl9.h" |
56 | #include <ole2.h> | 56 | #include <ole2.h> |
57 | #include <comutil.h> | 57 | #include <comutil.h> |
58 | _Application gOlAppAB; | 58 | _Application gOlAppAB; |
59 | 59 | ||
60 | QDateTime mDdate2Qdtr( DATE dt) | 60 | QDateTime mDdate2Qdtr( DATE dt) |
61 | { | 61 | { |
62 | COleDateTime odt; | 62 | COleDateTime odt; |
63 | SYSTEMTIME st; | 63 | SYSTEMTIME st; |
64 | odt = dt; | 64 | odt = dt; |
65 | if ( odt.GetStatus() != 0 ) | 65 | if ( odt.GetStatus() != 0 ) |
66 | return QDateTime(); | 66 | return QDateTime(); |
67 | odt.GetAsSystemTime(st); | 67 | odt.GetAsSystemTime(st); |
68 | if ( st.wYear > 4000 ) // this program as a year 4000 bug! | 68 | if ( st.wYear > 4000 ) // this program as a year 4000 bug! |
69 | return QDateTime(); | 69 | return QDateTime(); |
70 | // it seems so, that 1.1.4501 indicates: DATE invalid | 70 | // it seems so, that 1.1.4501 indicates: DATE invalid |
71 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); | 71 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); |
72 | return qdt; | 72 | return qdt; |
73 | } | 73 | } |
74 | 74 | ||
75 | class OLEListViewItem : public QCheckListItem | 75 | class OLEListViewItem : public QCheckListItem |
76 | { | 76 | { |
77 | public: | 77 | public: |
78 | OLEListViewItem( QListView *parent, QString text ) : | 78 | OLEListViewItem( QListView *parent, QString text ) : |
79 | QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; | 79 | QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; |
80 | OLEListViewItem( QListViewItem *after, QString text ) : | 80 | OLEListViewItem( QListViewItem *after, QString text ) : |
81 | QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; | 81 | QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; |
82 | ~OLEListViewItem() {}; | 82 | ~OLEListViewItem() {}; |
83 | void setData( DWORD data ) {mData= data; }; | 83 | void setData( DWORD data ) {mData= data; }; |
84 | DWORD data() { return mData ;}; | 84 | DWORD data() { return mData ;}; |
85 | private: | 85 | private: |
86 | DWORD mData; | 86 | DWORD mData; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | KAImportOLdialog::KAImportOLdialog( const QString &caption, | 89 | KAImportOLdialog::KAImportOLdialog( const QString &caption, |
90 | KABC::AddressBook * aBook, QWidget *parent ) : | 90 | KABC::AddressBook * aBook, QWidget *parent ) : |
91 | KDialogBase( Plain, caption, User1 | Close, Ok, | 91 | KDialogBase( Plain, caption, User1 | Close, Ok, |
92 | parent, caption, true, false, i18n("Import!") ) | 92 | parent, caption, true, false, i18n("Import!") ) |
93 | { | 93 | { |
94 | QHBox * mw = new QHBox( this ); | 94 | QHBox * mw = new QHBox( this ); |
95 | setMainWidget( mw ); | 95 | setMainWidget( mw ); |
96 | mListView = new QListView( mw ); | 96 | mListView = new QListView( mw ); |
97 | mListView->addColumn(i18n("Select Folder to import")); | 97 | mListView->addColumn(i18n("Select Folder to import")); |
98 | mListView->addColumn(i18n("Content Type")); | 98 | mListView->addColumn(i18n("Content Type")); |
99 | mABook = aBook; | 99 | mABook = aBook; |
100 | connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); | 100 | connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); |
101 | setupFolderView(); | 101 | setupFolderView(); |
102 | resize( sizeHint().width()+50, sizeHint().height()+50 ); | 102 | resize( sizeHint().width()+50, sizeHint().height()+50 ); |
103 | } | 103 | } |
104 | 104 | ||
105 | KAImportOLdialog::~KAImportOLdialog() | 105 | KAImportOLdialog::~KAImportOLdialog() |
106 | { | 106 | { |
107 | 107 | ||
108 | } | 108 | } |
109 | 109 | ||
110 | KABC::Addressee::List KAImportOLdialog::getAddressList() | 110 | KABC::Addressee::List KAImportOLdialog::getAddressList() |
111 | { | 111 | { |
112 | return mAList; | 112 | return mAList; |
113 | } | 113 | } |
114 | void KAImportOLdialog::setupFolderView() | 114 | void KAImportOLdialog::setupFolderView() |
115 | { | 115 | { |
116 | SCODE sc = ::OleInitialize(NULL); | 116 | SCODE sc = ::OleInitialize(NULL); |
117 | if ( FAILED ( sc ) ) { | 117 | if ( FAILED ( sc ) ) { |
118 | KMessageBox::information(this,"OLE initialisation failed"); | 118 | KMessageBox::information(this,"OLE initialisation failed"); |
119 | return; | 119 | return; |
120 | } | 120 | } |
121 | 121 | ||
122 | if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ | 122 | if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ |
123 | KMessageBox::information(this,"Sorry, cannot access Outlook"); | 123 | KMessageBox::information(this,"Sorry, cannot access Outlook"); |
124 | return ; | 124 | return ; |
125 | } | 125 | } |
126 | MAPIFolder mfInbox; | 126 | MAPIFolder mfInbox; |
127 | MAPIFolder mfRoot; | 127 | MAPIFolder mfRoot; |
128 | CString szName; | 128 | CString szName; |
129 | _NameSpace olNS; | 129 | _NameSpace olNS; |
130 | olNS = gOlAppAB.GetNamespace(_T("MAPI")); | 130 | olNS = gOlAppAB.GetNamespace(_T("MAPI")); |
131 | mfInbox = olNS.GetDefaultFolder(6); | 131 | mfInbox = olNS.GetDefaultFolder(6); |
132 | mfRoot = mfInbox.GetParent(); | 132 | mfRoot = mfInbox.GetParent(); |
133 | szName = mfRoot.GetName(); | 133 | szName = mfRoot.GetName(); |
134 | long iType = mfRoot.GetDefaultItemType(); | 134 | long iType = mfRoot.GetDefaultItemType(); |
135 | QString mes; | 135 | QString mes; |
136 | mes = QString::fromUcs2( szName.GetBuffer() ); | 136 | mes = QString::fromUcs2( szName.GetBuffer() ); |
137 | OLEListViewItem * root = new OLEListViewItem( mListView, mes ); | 137 | OLEListViewItem * root = new OLEListViewItem( mListView, mes ); |
138 | mfRoot.m_lpDispatch->AddRef(); | 138 | mfRoot.m_lpDispatch->AddRef(); |
139 | addFolder( root, mfRoot.m_lpDispatch ); | 139 | addFolder( root, mfRoot.m_lpDispatch ); |
140 | root->setOpen( true ); | 140 | root->setOpen( true ); |
141 | mListView->setSortColumn( 0 ); | 141 | mListView->setSortColumn( 0 ); |
142 | mListView->sort( ); | 142 | mListView->sort( ); |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent) | 146 | void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent) |
147 | { | 147 | { |
148 | MAPIFolder mfParent(dispParent), mfChild; | 148 | MAPIFolder mfParent(dispParent), mfChild; |
149 | _Folders folders; | 149 | _Folders folders; |
150 | _variant_t fndx((long)0); | 150 | _variant_t fndx((long)0); |
151 | CString szName; | 151 | CString szName; |
152 | long iType; | 152 | long iType; |
153 | OLEListViewItem* hChild; | 153 | OLEListViewItem* hChild; |
154 | 154 | ||
155 | folders = mfParent.GetFolders(); | 155 | folders = mfParent.GetFolders(); |
156 | for(int i=1; i <= folders.GetCount(); ++i) | 156 | for(int i=1; i <= folders.GetCount(); ++i) |
157 | { | 157 | { |
158 | fndx = (long)i; | 158 | fndx = (long)i; |
159 | mfChild = folders.Item(fndx.Detach()); | 159 | mfChild = folders.Item(fndx.Detach()); |
160 | mfChild.m_lpDispatch->AddRef(); | 160 | mfChild.m_lpDispatch->AddRef(); |
161 | szName = mfChild.GetName(); | 161 | szName = mfChild.GetName(); |
162 | iType = mfChild.GetDefaultItemType(); | 162 | iType = mfChild.GetDefaultItemType(); |
163 | hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); | 163 | hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); |
164 | if ( iType != 2) | 164 | if ( iType != 2) |
165 | hChild->setEnabled( false ); | 165 | hChild->setEnabled( false ); |
166 | QString ts; | 166 | QString ts; |
167 | switch( iType ) { | 167 | switch( iType ) { |
168 | case 0: | 168 | case 0: |
169 | ts = i18n("Mail"); | 169 | ts = i18n("Mail"); |
170 | break; | 170 | break; |
171 | case 1: | 171 | case 1: |
172 | ts = i18n("Calendar"); | 172 | ts = i18n("Calendar"); |
173 | break; | 173 | break; |
174 | case 2: | 174 | case 2: |
175 | ts = i18n("Contacts"); | 175 | ts = i18n("Contacts"); |
176 | break; | 176 | break; |
177 | case 3: | 177 | case 3: |
178 | ts = i18n("Todos"); | 178 | ts = i18n("Todos"); |
179 | break; | 179 | break; |
180 | case 4: | 180 | case 4: |
181 | ts = i18n("Journals"); | 181 | ts = i18n("Journals"); |
182 | break; | 182 | break; |
183 | case 5: | 183 | case 5: |
184 | ts = i18n("Notes"); | 184 | ts = i18n("Notes"); |
185 | break; | 185 | break; |
186 | default: | 186 | default: |
187 | ts = i18n("Unknown"); | 187 | ts = i18n("Unknown"); |
188 | } | 188 | } |
189 | hChild->setText( 1,ts); | 189 | hChild->setText( 1,ts); |
190 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); | 190 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); |
191 | mfChild.m_lpDispatch->AddRef(); | 191 | mfChild.m_lpDispatch->AddRef(); |
192 | addFolder(hChild, mfChild.m_lpDispatch); | 192 | addFolder(hChild, mfChild.m_lpDispatch); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | void KAImportOLdialog::slotApply() | 196 | void KAImportOLdialog::slotApply() |
197 | { | 197 | { |
198 | importedItems = 0; | 198 | importedItems = 0; |
199 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); | 199 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); |
200 | while ( child ) { | 200 | while ( child ) { |
201 | if ( child->isOn() ) | 201 | if ( child->isOn() ) |
202 | readContactData( child->data() ); | 202 | readContactData( child->data() ); |
203 | child = (OLEListViewItem*) child->itemBelow(); | 203 | child = (OLEListViewItem*) child->itemBelow(); |
204 | } | 204 | } |
205 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); | 205 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); |
206 | KMessageBox::information(this,mes); | 206 | KMessageBox::information(this,mes); |
207 | } | 207 | } |
208 | void KAImportOLdialog::readContactData( DWORD folder ) | 208 | void KAImportOLdialog::readContactData( DWORD folder ) |
209 | { | 209 | { |
210 | 210 | ||
211 | LPDISPATCH dispItem = (LPDISPATCH)folder; | 211 | LPDISPATCH dispItem = (LPDISPATCH)folder; |
212 | dispItem->AddRef(); | 212 | dispItem->AddRef(); |
213 | MAPIFolder mf(dispItem); | 213 | MAPIFolder mf(dispItem); |
214 | mf.m_lpDispatch->AddRef(); | 214 | mf.m_lpDispatch->AddRef(); |
215 | _Items folderItems; | 215 | _Items folderItems; |
216 | _variant_t indx((long)0); | 216 | _variant_t indx((long)0); |
217 | LPDISPATCH itm; | 217 | LPDISPATCH itm; |
218 | int i; | 218 | int i; |
219 | folderItems = mf.GetItems(); | 219 | folderItems = mf.GetItems(); |
220 | QProgressBar bar( folderItems.GetCount(),0 ); | 220 | QProgressBar bar( folderItems.GetCount(),0 ); |
221 | bar.setCaption (i18n("Importing - close to abort!") ); | 221 | bar.setCaption (i18n("Importing - close to abort!") ); |
222 | int h = bar.sizeHint().height() ; | 222 | int h = bar.sizeHint().height() ; |
223 | int w = 300; | 223 | int w = 300; |
224 | int dw = QApplication::desktop()->width(); | 224 | int dw = QApplication::desktop()->width(); |
225 | int dh = QApplication::desktop()->height(); | 225 | int dh = QApplication::desktop()->height(); |
226 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 226 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
227 | bar.show(); | 227 | bar.show(); |
228 | for(i=1; i <= folderItems.GetCount(); ++i) | 228 | for(i=1; i <= folderItems.GetCount(); ++i) |
229 | { | 229 | { |
230 | qApp->processEvents(); | 230 | qApp->processEvents(); |
231 | if ( ! bar.isVisible() ) | 231 | if ( ! bar.isVisible() ) |
232 | return ; | 232 | return ; |
233 | bar.setProgress( i ); | 233 | bar.setProgress( i ); |
234 | indx = (long)i; | 234 | indx = (long)i; |
235 | itm = folderItems.Item(indx.Detach()); | 235 | itm = folderItems.Item(indx.Detach()); |
236 | _ContactItem * pItem = (_ContactItem *)&itm; | 236 | _ContactItem * pItem = (_ContactItem *)&itm; |
237 | ol2kapiContact( pItem ); | 237 | ol2kapiContact( pItem ); |
238 | itm->Release(); | 238 | itm->Release(); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | void KAImportOLdialog::slotOk() | 241 | void KAImportOLdialog::slotOk() |
242 | { | 242 | { |
243 | QDialog::accept(); | 243 | QDialog::accept(); |
244 | } | 244 | } |
245 | 245 | ||
246 | void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) | 246 | void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) |
247 | { | 247 | { |
248 | KABC::Addressee addressee; | 248 | KABC::Addressee addressee; |
249 | 249 | ||
250 | addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); | 250 | addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); |
251 | 251 | //GetLastModificationTime() | |
252 | //addressee.setName( const QString &name ); | 252 | //addressee.setName( const QString &name ); |
253 | //addressee.setFormattedName( const QString &formattedName ); | 253 | //addressee.setFormattedName( const QString &formattedName ); |
254 | addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); | 254 | addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); |
255 | addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); | 255 | addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); |
256 | addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); | 256 | addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); |
257 | addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); | 257 | addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); |
258 | addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); | 258 | addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); |
259 | addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); | 259 | addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); |
260 | QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); | 260 | QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); |
261 | if ( dtb.isValid() ) | 261 | if ( dtb.isValid() ) |
262 | addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); | 262 | addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); |
263 | 263 | ||
264 | //QString::fromUcs2(aItem->.GetBuffer()) | 264 | //QString::fromUcs2(aItem->.GetBuffer()) |
265 | //addressee.setMailer( const QString &mailer ); | 265 | //addressee.setMailer( const QString &mailer ); |
266 | //addressee.setTimeZone( const TimeZone &timeZone ); | 266 | //addressee.setTimeZone( const TimeZone &timeZone ); |
267 | //addressee.setGeo( const Geo &geo ); | 267 | //addressee.setGeo( const Geo &geo ); |
268 | //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix | 268 | //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix |
269 | addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); | 269 | addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); |
270 | addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()) ); | 270 | addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()) ); |
271 | addressee.setNote( QString::fromUcs2(aItem->GetBody().GetBuffer()) ); | 271 | addressee.setNote( QString::fromUcs2(aItem->GetBody().GetBuffer()) ); |
272 | 272 | ||
273 | addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); | 273 | addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); |
274 | //addressee.setRevision( const QDateTime &revision ); | 274 | //addressee.setRevision( const QDateTime &revision ); |
275 | // addressee.setSortString( const QString &sortString ); | 275 | // addressee.setSortString( const QString &sortString ); |
276 | addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); | 276 | addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); |
277 | 277 | ||
278 | QString tempS; | 278 | QString tempS; |
279 | tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); | 279 | tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); |
280 | if ( tempS.length() > 12 ) | 280 | if ( tempS.length() > 12 ) |
281 | addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); | 281 | addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); |
282 | tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); | 282 | tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); |
283 | if ( !tempS.isEmpty() ) | 283 | if ( !tempS.isEmpty() ) |
284 | addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); | 284 | addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); |
285 | tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); | 285 | tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); |
286 | if ( !tempS.isEmpty() ) | 286 | if ( !tempS.isEmpty() ) |
287 | addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); | 287 | addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); |
288 | tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); | 288 | tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); |
289 | if ( !tempS.isEmpty() ) | 289 | if ( !tempS.isEmpty() ) |
290 | addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); | 290 | addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); |
291 | tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); | 291 | tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); |
292 | if ( !tempS.isEmpty() ) | 292 | if ( !tempS.isEmpty() ) |
293 | addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); | 293 | addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); |
294 | tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()); | 294 | tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()); |
295 | if ( !tempS.isEmpty() ) | 295 | if ( !tempS.isEmpty() ) |
296 | addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); | 296 | addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); |
297 | tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); | 297 | tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); |
298 | if ( !tempS.isEmpty() ) | 298 | if ( !tempS.isEmpty() ) |
299 | addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); | 299 | addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); |
300 | dtb = mDdate2Qdtr(aItem->GetAnniversary()); | 300 | dtb = mDdate2Qdtr(aItem->GetAnniversary()); |
301 | if (dtb.isValid() ) { | 301 | if (dtb.isValid() ) { |
302 | QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); | 302 | QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); |
303 | addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 303 | addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
304 | } | 304 | } |
305 | int sec = aItem->GetSensitivity() ; | 305 | int sec = aItem->GetSensitivity() ; |
306 | if ( sec > 1 )// mapping pers -> private | 306 | if ( sec > 1 )// mapping pers -> private |
307 | --sec; | 307 | --sec; |
308 | addressee.setSecrecy( sec ); | 308 | addressee.setSecrecy( sec ); |
309 | //addressee.setLogo( const Picture &logo ); | 309 | //addressee.setLogo( const Picture &logo ); |
310 | //addressee.setPhoto( const Picture &photo ); | 310 | //addressee.setPhoto( const Picture &photo ); |
311 | //addressee.setSound( const Sound &sound ); | 311 | //addressee.setSound( const Sound &sound ); |
312 | //addressee.setAgent( const Agent &agent ); | 312 | //addressee.setAgent( const Agent &agent ); |
313 | QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()); | 313 | QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()); |
314 | addressee.setCategories( QStringList::split( ";", cat )); | 314 | addressee.setCategories( QStringList::split( ";", cat )); |
315 | 315 | ||
316 | QString phoneS; | 316 | QString phoneS; |
317 | 317 | ||
318 | phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer()); | 318 | phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer()); |
319 | if ( ! phoneS.isEmpty()) | 319 | if ( ! phoneS.isEmpty()) |
320 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Voice ) ); | 320 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Voice ) ); |
321 | phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer()); | 321 | phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer()); |
322 | if ( ! phoneS.isEmpty()) | 322 | if ( ! phoneS.isEmpty()) |
323 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); | 323 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); |
324 | phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer()); | 324 | phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer()); |
325 | if ( ! phoneS.isEmpty()) | 325 | if ( ! phoneS.isEmpty()) |
326 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); | 326 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) ); |
327 | phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer()); | 327 | phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer()); |
328 | if ( ! phoneS.isEmpty()) | 328 | if ( ! phoneS.isEmpty()) |
329 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Fax ) ); | 329 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Fax ) ); |
330 | phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer()); | 330 | phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer()); |
331 | if ( ! phoneS.isEmpty()) | 331 | if ( ! phoneS.isEmpty()) |
332 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Car ) ); | 332 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Car ) ); |
333 | phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer()); | 333 | phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer()); |
334 | if ( ! phoneS.isEmpty()) | 334 | if ( ! phoneS.isEmpty()) |
335 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); | 335 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); |
336 | phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer()); | 336 | phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer()); |
337 | if ( ! phoneS.isEmpty()) | 337 | if ( ! phoneS.isEmpty()) |
338 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); | 338 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) ); |
339 | phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer()); | 339 | phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer()); |
340 | if ( ! phoneS.isEmpty()) | 340 | if ( ! phoneS.isEmpty()) |
341 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home + KABC::PhoneNumber::Fax ) ); | 341 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home + KABC::PhoneNumber::Fax ) ); |
342 | phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer()); | 342 | phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer()); |
343 | if ( ! phoneS.isEmpty()) | 343 | if ( ! phoneS.isEmpty()) |
344 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Isdn ) ); | 344 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Isdn ) ); |
345 | phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer()); | 345 | phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer()); |
346 | if ( ! phoneS.isEmpty()) | 346 | if ( ! phoneS.isEmpty()) |
347 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Cell ) ); | 347 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Cell ) ); |
348 | phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer()); | 348 | phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer()); |
349 | if ( ! phoneS.isEmpty()) | 349 | if ( ! phoneS.isEmpty()) |
350 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax ) ); | 350 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax ) ); |
351 | phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer()); | 351 | phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer()); |
352 | if ( ! phoneS.isEmpty()) | 352 | if ( ! phoneS.isEmpty()) |
353 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice ) ); | 353 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice ) ); |
354 | phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer()); | 354 | phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer()); |
355 | if ( ! phoneS.isEmpty()) | 355 | if ( ! phoneS.isEmpty()) |
356 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pager ) ); | 356 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pager ) ); |
357 | phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer()); | 357 | phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer()); |
358 | if ( ! phoneS.isEmpty()) | 358 | if ( ! phoneS.isEmpty()) |
359 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pref ) ); | 359 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pref ) ); |
360 | phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer()); | 360 | phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer()); |
361 | if ( ! phoneS.isEmpty()) | 361 | if ( ! phoneS.isEmpty()) |
362 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Modem ) ); | 362 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Modem ) ); |
363 | phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer()); | 363 | phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer()); |
364 | if ( ! phoneS.isEmpty()) | 364 | if ( ! phoneS.isEmpty()) |
365 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax + KABC::PhoneNumber::Bbs ) ); | 365 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax + KABC::PhoneNumber::Bbs ) ); |
366 | phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer()); | 366 | phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer()); |
367 | if ( ! phoneS.isEmpty()) | 367 | if ( ! phoneS.isEmpty()) |
368 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Pref ) ); | 368 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Pref ) ); |
369 | phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer()); | 369 | phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer()); |
370 | if ( ! phoneS.isEmpty()) | 370 | if ( ! phoneS.isEmpty()) |
371 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Video ) ); | 371 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Video ) ); |
372 | phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer()); | 372 | phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer()); |
373 | if ( ! phoneS.isEmpty()) | 373 | if ( ! phoneS.isEmpty()) |
374 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice + KABC::PhoneNumber::Pref ) ); | 374 | addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice + KABC::PhoneNumber::Pref ) ); |
375 | 375 | ||
376 | bool preferred = true; | 376 | bool preferred = true; |
377 | phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer()); | 377 | phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer()); |
378 | if ( ! phoneS.isEmpty()) { | 378 | if ( ! phoneS.isEmpty()) { |
379 | addressee.insertEmail(phoneS , preferred ); | 379 | addressee.insertEmail(phoneS , preferred ); |
380 | preferred = false; | 380 | preferred = false; |
381 | } | 381 | } |
382 | phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer()); | 382 | phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer()); |
383 | if ( ! phoneS.isEmpty()) { | 383 | if ( ! phoneS.isEmpty()) { |
384 | addressee.insertEmail(phoneS , preferred ); | 384 | addressee.insertEmail(phoneS , preferred ); |
385 | preferred = false; | 385 | preferred = false; |
386 | } | 386 | } |
387 | phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer()); | 387 | phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer()); |
388 | if ( ! phoneS.isEmpty()) { | 388 | if ( ! phoneS.isEmpty()) { |
389 | addressee.insertEmail(phoneS , preferred ); | 389 | addressee.insertEmail(phoneS , preferred ); |
390 | preferred = false; | 390 | preferred = false; |
391 | } | 391 | } |
392 | // is this the number of the preferred email? | 392 | // is this the number of the preferred email? |
393 | //long GetSelectedMailingAddress();??? | 393 | //long GetSelectedMailingAddress();??? |
394 | 394 | ||
395 | KABC::Address addressHome; | 395 | KABC::Address addressHome; |
396 | KABC::Address* addressAdd = &addressHome; | 396 | KABC::Address* addressAdd = &addressHome; |
397 | bool insert = false; | 397 | bool insert = false; |
398 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer()); | 398 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer()); |
399 | if ( ! phoneS.isEmpty()) { | 399 | if ( ! phoneS.isEmpty()) { |
400 | addressAdd->setCountry(phoneS ); | 400 | addressAdd->setCountry(phoneS ); |
401 | insert = true; | 401 | insert = true; |
402 | } | 402 | } |
403 | phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer()); | 403 | phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer()); |
404 | if ( ! phoneS.isEmpty()) { | 404 | if ( ! phoneS.isEmpty()) { |
405 | addressAdd->setRegion(phoneS ); | 405 | addressAdd->setRegion(phoneS ); |
406 | insert = true; | 406 | insert = true; |
407 | } | 407 | } |
408 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer()); | 408 | phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer()); |
409 | if ( ! phoneS.isEmpty()) { | 409 | if ( ! phoneS.isEmpty()) { |
410 | addressAdd->setLocality(phoneS ); | 410 | addressAdd->setLocality(phoneS ); |
411 | insert = true; | 411 | insert = true; |
412 | } | 412 | } |
413 | phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer()); | 413 | phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer()); |
414 | if ( ! phoneS.isEmpty()) { | 414 | if ( ! phoneS.isEmpty()) { |
415 | addressAdd->setPostalCode(phoneS ); | 415 | addressAdd->setPostalCode(phoneS ); |
416 | insert = true; | 416 | insert = true; |
417 | } | 417 | } |
418 | phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer()); | 418 | phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer()); |
419 | if ( ! phoneS.isEmpty()) { | 419 | if ( ! phoneS.isEmpty()) { |
420 | addressAdd->setPostOfficeBox(phoneS ); | 420 | addressAdd->setPostOfficeBox(phoneS ); |
421 | insert = true; | 421 | insert = true; |
422 | } | 422 | } |
423 | phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer()); | 423 | phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer()); |
424 | if ( ! phoneS.isEmpty()) { | 424 | if ( ! phoneS.isEmpty()) { |
425 | addressAdd->setStreet(phoneS ); | 425 | addressAdd->setStreet(phoneS ); |
426 | insert = true; | 426 | insert = true; |
427 | } | 427 | } |
428 | phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer()); | 428 | phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer()); |
429 | if ( ! phoneS.isEmpty()) { | 429 | if ( ! phoneS.isEmpty()) { |
430 | // redundant !addressAdd->setExtended(phoneS ); | 430 | // redundant !addressAdd->setExtended(phoneS ); |
431 | // insert = true; | 431 | // insert = true; |
432 | } | 432 | } |
433 | addressAdd->setType( KABC::Address::Home ); | 433 | addressAdd->setType( KABC::Address::Home ); |
434 | if ( insert ) | 434 | if ( insert ) |
435 | addressee.insertAddress( *addressAdd ); | 435 | addressee.insertAddress( *addressAdd ); |
436 | // ++++++++++++++++++++++ end of address | 436 | // ++++++++++++++++++++++ end of address |
437 | 437 | ||
438 | KABC::Address addressWork; | 438 | KABC::Address addressWork; |
439 | addressAdd = &addressWork; | 439 | addressAdd = &addressWork; |
440 | insert = false; | 440 | insert = false; |
441 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer()); | 441 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer()); |
442 | if ( ! phoneS.isEmpty()) { | 442 | if ( ! phoneS.isEmpty()) { |
443 | addressAdd->setCountry(phoneS ); | 443 | addressAdd->setCountry(phoneS ); |
444 | insert = true; | 444 | insert = true; |
445 | } | 445 | } |
446 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer()); | 446 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer()); |
447 | if ( ! phoneS.isEmpty()) { | 447 | if ( ! phoneS.isEmpty()) { |
448 | addressAdd->setRegion(phoneS ); | 448 | addressAdd->setRegion(phoneS ); |
449 | insert = true; | 449 | insert = true; |
450 | } | 450 | } |
451 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer()); | 451 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer()); |
452 | if ( ! phoneS.isEmpty()) { | 452 | if ( ! phoneS.isEmpty()) { |
453 | addressAdd->setLocality(phoneS ); | 453 | addressAdd->setLocality(phoneS ); |
454 | insert = true; | 454 | insert = true; |
455 | } | 455 | } |
456 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer()); | 456 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer()); |
457 | if ( ! phoneS.isEmpty()) { | 457 | if ( ! phoneS.isEmpty()) { |
458 | addressAdd->setPostalCode(phoneS ); | 458 | addressAdd->setPostalCode(phoneS ); |
459 | insert = true; | 459 | insert = true; |
460 | } | 460 | } |
461 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer()); | 461 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer()); |
462 | if ( ! phoneS.isEmpty()) { | 462 | if ( ! phoneS.isEmpty()) { |
463 | addressAdd->setPostOfficeBox(phoneS ); | 463 | addressAdd->setPostOfficeBox(phoneS ); |
464 | insert = true; | 464 | insert = true; |
465 | } | 465 | } |
466 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer()); | 466 | phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer()); |
467 | if ( ! phoneS.isEmpty()) { | 467 | if ( ! phoneS.isEmpty()) { |
468 | addressAdd->setStreet(phoneS ); | 468 | addressAdd->setStreet(phoneS ); |
469 | insert = true; | 469 | insert = true; |
470 | } | 470 | } |
471 | phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer()); | 471 | phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer()); |
472 | if ( ! phoneS.isEmpty()) { | 472 | if ( ! phoneS.isEmpty()) { |
473 | // redundant !addressAdd->setExtended(phoneS ); | 473 | // redundant !addressAdd->setExtended(phoneS ); |
474 | // insert = true; | 474 | // insert = true; |
475 | } | 475 | } |
476 | addressAdd->setType( KABC::Address::Work ); | 476 | addressAdd->setType( KABC::Address::Work ); |
477 | if ( insert ) | 477 | if ( insert ) |
478 | addressee.insertAddress( *addressAdd ); | 478 | addressee.insertAddress( *addressAdd ); |
479 | // ++++++++++++++++++++++ end of address | 479 | // ++++++++++++++++++++++ end of address |
480 | 480 | ||
481 | KABC::Address addressOther; | 481 | KABC::Address addressOther; |
482 | addressAdd = &addressOther; | 482 | addressAdd = &addressOther; |
483 | insert = false; | 483 | insert = false; |
484 | phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer()); | 484 | phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer()); |
485 | if ( ! phoneS.isEmpty()) { | 485 | if ( ! phoneS.isEmpty()) { |
486 | addressAdd->setCountry(phoneS ); | 486 | addressAdd->setCountry(phoneS ); |
487 | insert = true; | 487 | insert = true; |
488 | } | 488 | } |
489 | phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer()); | 489 | phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer()); |
490 | if ( ! phoneS.isEmpty()) { | 490 | if ( ! phoneS.isEmpty()) { |
491 | addressAdd->setRegion(phoneS ); | 491 | addressAdd->setRegion(phoneS ); |
492 | insert = true; | 492 | insert = true; |
493 | } | 493 | } |
494 | phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer()); | 494 | phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer()); |
495 | if ( ! phoneS.isEmpty()) { | 495 | if ( ! phoneS.isEmpty()) { |
496 | addressAdd->setLocality(phoneS ); | 496 | addressAdd->setLocality(phoneS ); |
497 | insert = true; | 497 | insert = true; |
498 | } | 498 | } |
499 | phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer()); | 499 | phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer()); |
500 | if ( ! phoneS.isEmpty()) { | 500 | if ( ! phoneS.isEmpty()) { |
501 | addressAdd->setPostalCode(phoneS ); | 501 | addressAdd->setPostalCode(phoneS ); |
502 | insert = true; | 502 | insert = true; |
503 | } | 503 | } |
504 | phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer()); | 504 | phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer()); |
505 | if ( ! phoneS.isEmpty()) { | 505 | if ( ! phoneS.isEmpty()) { |
506 | addressAdd->setPostOfficeBox(phoneS ); | 506 | addressAdd->setPostOfficeBox(phoneS ); |
507 | insert = true; | 507 | insert = true; |
508 | } | 508 | } |
509 | phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer()); | 509 | phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer()); |
510 | if ( ! phoneS.isEmpty()) { | 510 | if ( ! phoneS.isEmpty()) { |
511 | addressAdd->setStreet(phoneS ); | 511 | addressAdd->setStreet(phoneS ); |
512 | insert = true; | 512 | insert = true; |
513 | } | 513 | } |
514 | phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer()); | 514 | phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer()); |
515 | if ( ! phoneS.isEmpty()) { | 515 | if ( ! phoneS.isEmpty()) { |
516 | // redundant !addressAdd->setExtended(phoneS ); | 516 | // redundant !addressAdd->setExtended(phoneS ); |
517 | //insert = true; | 517 | //insert = true; |
518 | } | 518 | } |
519 | //addressAdd->setId( ); | 519 | //addressAdd->setId( ); |
520 | if ( insert ) | 520 | if ( insert ) |
521 | addressee.insertAddress( *addressAdd ); | 521 | addressee.insertAddress( *addressAdd ); |
522 | // ++++++++++++++++++++++ end of address | 522 | // ++++++++++++++++++++++ end of address |
523 | KABC::Address addressMail; | 523 | KABC::Address addressMail; |
524 | addressAdd = &addressMail; | 524 | addressAdd = &addressMail; |
525 | insert = false; | 525 | insert = false; |
526 | phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer()); | 526 | phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer()); |
527 | if ( ! phoneS.isEmpty()) { | 527 | if ( ! phoneS.isEmpty()) { |
528 | addressAdd->setCountry(phoneS ); | 528 | addressAdd->setCountry(phoneS ); |
529 | insert = true; | 529 | insert = true; |
530 | } | 530 | } |
531 | phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer()); | 531 | phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer()); |
532 | if ( ! phoneS.isEmpty()) { | 532 | if ( ! phoneS.isEmpty()) { |
533 | addressAdd->setRegion(phoneS ); | 533 | addressAdd->setRegion(phoneS ); |
534 | insert = true; | 534 | insert = true; |
535 | } | 535 | } |
536 | phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer()); | 536 | phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer()); |
537 | if ( ! phoneS.isEmpty()) { | 537 | if ( ! phoneS.isEmpty()) { |
538 | addressAdd->setLocality(phoneS ); | 538 | addressAdd->setLocality(phoneS ); |
539 | insert = true; | 539 | insert = true; |
540 | } | 540 | } |
541 | phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer()); | 541 | phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer()); |
542 | if ( ! phoneS.isEmpty()) { | 542 | if ( ! phoneS.isEmpty()) { |
543 | addressAdd->setPostalCode(phoneS ); | 543 | addressAdd->setPostalCode(phoneS ); |
544 | insert = true; | 544 | insert = true; |
545 | } | 545 | } |
546 | phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer()); | 546 | phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer()); |
547 | if ( ! phoneS.isEmpty()) { | 547 | if ( ! phoneS.isEmpty()) { |
548 | addressAdd->setPostOfficeBox(phoneS ); | 548 | addressAdd->setPostOfficeBox(phoneS ); |
549 | insert = true; | 549 | insert = true; |
550 | } | 550 | } |
551 | phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer()); | 551 | phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer()); |
552 | if ( ! phoneS.isEmpty()) { | 552 | if ( ! phoneS.isEmpty()) { |
553 | addressAdd->setStreet(phoneS ); | 553 | addressAdd->setStreet(phoneS ); |
554 | insert = true; | 554 | insert = true; |
555 | } | 555 | } |
556 | phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer()); | 556 | phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer()); |
557 | if ( ! phoneS.isEmpty()) { | 557 | if ( ! phoneS.isEmpty()) { |
558 | // redundant ! addressAdd->setExtended(phoneS ); | 558 | // redundant ! addressAdd->setExtended(phoneS ); |
559 | // insert = true; | 559 | // insert = true; |
560 | } | 560 | } |
561 | addressAdd->setType( KABC::Address::Postal ); | 561 | addressAdd->setType( KABC::Address::Postal ); |
562 | if ( insert ) { | 562 | if ( insert ) { |
563 | addressee.insertAddress( *addressAdd ); | 563 | addressee.insertAddress( *addressAdd ); |
564 | } | 564 | } |
565 | // the following code is disabled | 565 | // the following code is disabled |
566 | // it does not seem to be useful | 566 | // it does not seem to be useful |
567 | #if 0 | 567 | #if 0 |
568 | if ( insert ) { | 568 | if ( insert ) { |
569 | addressAdd->setType( KABC::Address::Home ); | 569 | addressAdd->setType( KABC::Address::Home ); |
570 | if ( addressMail == addressHome ) { | 570 | if ( addressMail == addressHome ) { |
571 | addressHome.setType( KABC::Address::Postal+ KABC::Address::Home ); | 571 | addressHome.setType( KABC::Address::Postal+ KABC::Address::Home ); |
572 | addressee.insertAddress( addressHome ); | 572 | addressee.insertAddress( addressHome ); |
573 | } else { | 573 | } else { |
574 | addressAdd->setType( KABC::Address::Work ); | 574 | addressAdd->setType( KABC::Address::Work ); |
575 | if ( addressMail == addressWork ){ | 575 | if ( addressMail == addressWork ){ |
576 | addressWork.setType( KABC::Address::Postal+ KABC::Address::Work ); | 576 | addressWork.setType( KABC::Address::Postal+ KABC::Address::Work ); |
577 | addressee.insertAddress( addressWork ); | 577 | addressee.insertAddress( addressWork ); |
578 | 578 | ||
579 | } else { | 579 | } else { |
580 | addressAdd->setType( 0 ); | 580 | addressAdd->setType( 0 ); |
581 | if ( addressOther == addressMail ){ | 581 | if ( addressOther == addressMail ){ |
582 | addressOther.setType( KABC::Address::Postal ); | 582 | addressOther.setType( KABC::Address::Postal ); |
583 | addressee.insertAddress( addressOther ); | 583 | addressee.insertAddress( addressOther ); |
584 | } else { | 584 | } else { |
585 | addressee.insertAddress( *addressAdd ); | 585 | addressee.insertAddress( *addressAdd ); |
586 | } | 586 | } |
587 | } | 587 | } |
588 | } | 588 | } |
589 | } | 589 | } |
590 | #endif | 590 | #endif |
591 | // ++++++++++++++++++++++ end of ALL addresses | 591 | // ++++++++++++++++++++++ end of ALL addresses |
592 | //GetUserProperties(); | 592 | //GetUserProperties(); |
593 | tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer()); | 593 | tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer()); |
594 | if ( !tempS.isEmpty() ) | 594 | if ( !tempS.isEmpty() ) |
595 | addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS ); | 595 | addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS ); |
596 | tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer()); | 596 | tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer()); |
597 | if ( !tempS.isEmpty() ) | 597 | if ( !tempS.isEmpty() ) |
598 | addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS ); | 598 | addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS ); |
599 | int gen = aItem->GetGender(); | 599 | int gen = aItem->GetGender(); |
600 | if ( gen != 0 ) { // 0 undef - 1 female - 2 male | 600 | if ( gen != 0 ) { // 0 undef - 1 female - 2 male |
601 | if ( gen == 1 ) | 601 | if ( gen == 1 ) |
602 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); | 602 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); |
603 | else | 603 | else |
604 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); | 604 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); |
605 | } | 605 | } |
606 | 606 | ||
607 | #if 0 | 607 | #if 0 |
608 | // pending | 608 | // pending |
609 | - IM address: no clue where to get info about the helper ID | 609 | - IM address: no clue where to get info about the helper ID |
610 | -custom fields: difficult to implement - not implemented | 610 | -custom fields: difficult to implement - not implemented |
611 | -keys: makes no sense | 611 | -keys: makes no sense |
612 | #endif | 612 | #endif |
613 | 613 | ||
614 | if ( addAddressee( addressee )) | 614 | if ( addAddressee( addressee )) |
615 | ++importedItems; | 615 | ++importedItems; |
616 | } | 616 | } |
617 | void KAImportOLdialog::slotCancel() | 617 | void KAImportOLdialog::slotCancel() |
618 | { | 618 | { |
619 | reject(); | 619 | reject(); |
620 | } | 620 | } |
621 | 621 | ||
622 | bool KAImportOLdialog::addAddressee( KABC::Addressee a ) | 622 | bool KAImportOLdialog::addAddressee( KABC::Addressee a ) |
623 | { | 623 | { |
624 | bool add = true; | 624 | bool add = true; |
625 | KABC::Addressee::List::Iterator it; | 625 | KABC::Addressee::List::Iterator it; |
626 | for ( it = mAList.begin(); it != mAList.end(); ++it ) { | 626 | for ( it = mAList.begin(); it != mAList.end(); ++it ) { |
627 | if ( (*it).uid() == a.uid() ) { | 627 | if ( (*it).uid() == a.uid() ) { |
628 | add = false; | 628 | add = false; |
629 | break; | 629 | break; |
630 | } | 630 | } |
631 | } | 631 | } |
632 | if ( add ) | 632 | if ( add ) { |
633 | mAList.append ( a ); | 633 | if ( mABook->findByUid(a.uid() ).isEmpty()) |
634 | mAList.append ( a ); | ||
635 | else | ||
636 | add = false; | ||
637 | } | ||
634 | return add; | 638 | return add; |
635 | } | 639 | } |
diff --git a/kaddressbook/undocmds.cpp b/kaddressbook/undocmds.cpp index 5fbeec3..5807dc0 100644 --- a/kaddressbook/undocmds.cpp +++ b/kaddressbook/undocmds.cpp | |||
@@ -1,241 +1,242 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (C) 1999 Don Sanders <sanders@kde.org> | 3 | Copyright (C) 1999 Don Sanders <sanders@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qtextstream.h> | 24 | #include <qtextstream.h> |
25 | 25 | ||
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #include <qclipboard.h> | 27 | #include <qclipboard.h> |
28 | 28 | ||
29 | #include <klocale.h> | 29 | #include <klocale.h> |
30 | #include <kdebug.h> | 30 | #include <kdebug.h> |
31 | #include <kapplication.h> | 31 | #include <kapplication.h> |
32 | #include <kabc/addressbook.h> | 32 | #include <kabc/addressbook.h> |
33 | 33 | ||
34 | #include "addresseeutil.h" | 34 | #include "addresseeutil.h" |
35 | #include "addresseeconfig.h" | 35 | #include "addresseeconfig.h" |
36 | #include "kabcore.h" | 36 | #include "kabcore.h" |
37 | 37 | ||
38 | #include "undocmds.h" | 38 | #include "undocmds.h" |
39 | 39 | extern bool pasteWithNewUid; | |
40 | ///////////////////////////////// | 40 | ///////////////////////////////// |
41 | // PwDelete Methods | 41 | // PwDelete Methods |
42 | 42 | ||
43 | PwDeleteCommand::PwDeleteCommand(KABC::AddressBook *doc, | 43 | PwDeleteCommand::PwDeleteCommand(KABC::AddressBook *doc, |
44 | const QStringList &uidList) | 44 | const QStringList &uidList) |
45 | : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList) | 45 | : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList) |
46 | { | 46 | { |
47 | redo(); | 47 | redo(); |
48 | } | 48 | } |
49 | 49 | ||
50 | PwDeleteCommand::~PwDeleteCommand() | 50 | PwDeleteCommand::~PwDeleteCommand() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | QString PwDeleteCommand::name() | 54 | QString PwDeleteCommand::name() |
55 | { | 55 | { |
56 | return i18n( "Delete" ); | 56 | return i18n( "Delete" ); |
57 | } | 57 | } |
58 | 58 | ||
59 | void PwDeleteCommand::undo() | 59 | void PwDeleteCommand::undo() |
60 | { | 60 | { |
61 | // Put it back in the document | 61 | // Put it back in the document |
62 | KABC::Addressee::List::Iterator iter; | 62 | KABC::Addressee::List::Iterator iter; |
63 | for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter) | 63 | for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter) |
64 | { | 64 | { |
65 | mDocument->insertAddressee(*iter); | 65 | mDocument->insertAddressee(*iter); |
66 | } | 66 | } |
67 | 67 | ||
68 | mAddresseeList.clear(); | 68 | mAddresseeList.clear(); |
69 | } | 69 | } |
70 | 70 | ||
71 | void PwDeleteCommand::redo() | 71 | void PwDeleteCommand::redo() |
72 | { | 72 | { |
73 | // Just remove it from the document. This is enough to make the user | 73 | // Just remove it from the document. This is enough to make the user |
74 | // Think the item has been deleted | 74 | // Think the item has been deleted |
75 | KABC::Addressee a; | 75 | KABC::Addressee a; |
76 | QStringList::Iterator iter; | 76 | QStringList::Iterator iter; |
77 | for (iter = mUidList.begin(); iter != mUidList.end(); ++iter) | 77 | for (iter = mUidList.begin(); iter != mUidList.end(); ++iter) |
78 | { | 78 | { |
79 | a = mDocument->findByUid(*iter); | 79 | a = mDocument->findByUid(*iter); |
80 | mDocument->removeAddressee(a); | 80 | mDocument->removeAddressee(a); |
81 | mAddresseeList.append(a); | 81 | mAddresseeList.append(a); |
82 | AddresseeConfig::instance()->remove(a.uid()); | 82 | AddresseeConfig::instance()->remove(a.uid()); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | ///////////////////////////////// | 86 | ///////////////////////////////// |
87 | // PwPaste Methods | 87 | // PwPaste Methods |
88 | 88 | ||
89 | PwPasteCommand::PwPasteCommand( KABCore *core, const KABC::Addressee::List &list ) | 89 | PwPasteCommand::PwPasteCommand( KABCore *core, const KABC::Addressee::List &list ) |
90 | : Command(), mCore( core ), mAddresseeList( list ) | 90 | : Command(), mCore( core ), mAddresseeList( list ) |
91 | { | 91 | { |
92 | redo(); | 92 | redo(); |
93 | } | 93 | } |
94 | 94 | ||
95 | QString PwPasteCommand::name() | 95 | QString PwPasteCommand::name() |
96 | { | 96 | { |
97 | return i18n( "Paste" ); | 97 | return i18n( "Paste" ); |
98 | } | 98 | } |
99 | 99 | ||
100 | void PwPasteCommand::undo() | 100 | void PwPasteCommand::undo() |
101 | { | 101 | { |
102 | KABC::Addressee::List::Iterator it; | 102 | KABC::Addressee::List::Iterator it; |
103 | for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) | 103 | for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) |
104 | mCore->addressBook()->removeAddressee( *it ); | 104 | mCore->addressBook()->removeAddressee( *it ); |
105 | } | 105 | } |
106 | 106 | ||
107 | void PwPasteCommand::redo() | 107 | void PwPasteCommand::redo() |
108 | { | 108 | { |
109 | QStringList uids; | 109 | QStringList uids; |
110 | KABC::Addressee::List::Iterator it; | 110 | KABC::Addressee::List::Iterator it; |
111 | for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) { | 111 | for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) { |
112 | /* we have to set a new uid for the contact, otherwise insertAddressee() | 112 | /* we have to set a new uid for the contact, otherwise insertAddressee() |
113 | ignore it. | 113 | ignore it. |
114 | */ | 114 | */ |
115 | (*it).setUid( KApplication::randomString( 10 ) ); | 115 | if ( pasteWithNewUid ) |
116 | (*it).setUid( KApplication::randomString( 10 ) ); | ||
116 | uids.append( (*it).uid() ); | 117 | uids.append( (*it).uid() ); |
117 | mCore->addressBook()->insertAddressee( *it ); | 118 | mCore->addressBook()->insertAddressee( *it ); |
118 | } | 119 | } |
119 | if ( uids.count() < 4 ) { | 120 | if ( uids.count() < 4 ) { |
120 | QStringList::Iterator uidIt; | 121 | QStringList::Iterator uidIt; |
121 | for ( uidIt = uids.begin(); uidIt != uids.end(); ++uidIt ) | 122 | for ( uidIt = uids.begin(); uidIt != uids.end(); ++uidIt ) |
122 | mCore->editContact( *uidIt ); | 123 | mCore->editContact( *uidIt ); |
123 | } | 124 | } |
124 | } | 125 | } |
125 | 126 | ||
126 | ///////////////////////////////// | 127 | ///////////////////////////////// |
127 | // PwNew Methods | 128 | // PwNew Methods |
128 | 129 | ||
129 | PwNewCommand::PwNewCommand( KABC::AddressBook *doc, const KABC::Addressee &a ) | 130 | PwNewCommand::PwNewCommand( KABC::AddressBook *doc, const KABC::Addressee &a ) |
130 | : Command(), mDocument( doc ), mA( a ) | 131 | : Command(), mDocument( doc ), mA( a ) |
131 | { | 132 | { |
132 | mDocument->insertAddressee(mA); | 133 | mDocument->insertAddressee(mA); |
133 | } | 134 | } |
134 | 135 | ||
135 | PwNewCommand::~PwNewCommand() | 136 | PwNewCommand::~PwNewCommand() |
136 | { | 137 | { |
137 | } | 138 | } |
138 | 139 | ||
139 | QString PwNewCommand::name() | 140 | QString PwNewCommand::name() |
140 | { | 141 | { |
141 | return i18n( "New Contact" ); | 142 | return i18n( "New Contact" ); |
142 | } | 143 | } |
143 | 144 | ||
144 | void PwNewCommand::undo() | 145 | void PwNewCommand::undo() |
145 | { | 146 | { |
146 | mDocument->removeAddressee( mA ); | 147 | mDocument->removeAddressee( mA ); |
147 | } | 148 | } |
148 | 149 | ||
149 | void PwNewCommand::redo() | 150 | void PwNewCommand::redo() |
150 | { | 151 | { |
151 | mDocument->insertAddressee( mA ); | 152 | mDocument->insertAddressee( mA ); |
152 | } | 153 | } |
153 | 154 | ||
154 | ///////////////////////////////// | 155 | ///////////////////////////////// |
155 | // PwEdit Methods | 156 | // PwEdit Methods |
156 | 157 | ||
157 | PwEditCommand::PwEditCommand(KABC::AddressBook *doc, | 158 | PwEditCommand::PwEditCommand(KABC::AddressBook *doc, |
158 | const KABC::Addressee &oldA, | 159 | const KABC::Addressee &oldA, |
159 | const KABC::Addressee &newA ) | 160 | const KABC::Addressee &newA ) |
160 | : Command(), mDocument(doc), mOldA(oldA), mNewA(newA) | 161 | : Command(), mDocument(doc), mOldA(oldA), mNewA(newA) |
161 | { | 162 | { |
162 | redo(); | 163 | redo(); |
163 | } | 164 | } |
164 | 165 | ||
165 | PwEditCommand::~PwEditCommand() | 166 | PwEditCommand::~PwEditCommand() |
166 | { | 167 | { |
167 | } | 168 | } |
168 | 169 | ||
169 | QString PwEditCommand::name() | 170 | QString PwEditCommand::name() |
170 | { | 171 | { |
171 | return i18n( "Entry Edit" ); | 172 | return i18n( "Entry Edit" ); |
172 | } | 173 | } |
173 | 174 | ||
174 | void PwEditCommand::undo() | 175 | void PwEditCommand::undo() |
175 | { | 176 | { |
176 | mDocument->insertAddressee(mOldA); | 177 | mDocument->insertAddressee(mOldA); |
177 | } | 178 | } |
178 | 179 | ||
179 | void PwEditCommand::redo() | 180 | void PwEditCommand::redo() |
180 | { | 181 | { |
181 | mDocument->insertAddressee(mNewA); | 182 | mDocument->insertAddressee(mNewA); |
182 | } | 183 | } |
183 | 184 | ||
184 | ///////////////////////////////// | 185 | ///////////////////////////////// |
185 | // PwCut Methods | 186 | // PwCut Methods |
186 | 187 | ||
187 | PwCutCommand::PwCutCommand(KABC::AddressBook *doc, const QStringList &uidList) | 188 | PwCutCommand::PwCutCommand(KABC::AddressBook *doc, const QStringList &uidList) |
188 | : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList), | 189 | : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList), |
189 | mClipText(), mOldText() | 190 | mClipText(), mOldText() |
190 | { | 191 | { |
191 | redo(); | 192 | redo(); |
192 | } | 193 | } |
193 | 194 | ||
194 | QString PwCutCommand::name() | 195 | QString PwCutCommand::name() |
195 | { | 196 | { |
196 | return i18n( "Cut" ); | 197 | return i18n( "Cut" ); |
197 | } | 198 | } |
198 | 199 | ||
199 | void PwCutCommand::undo() | 200 | void PwCutCommand::undo() |
200 | { | 201 | { |
201 | KABC::Addressee::List::Iterator iter; | 202 | KABC::Addressee::List::Iterator iter; |
202 | for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter) | 203 | for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter) |
203 | { | 204 | { |
204 | mDocument->insertAddressee(*iter); | 205 | mDocument->insertAddressee(*iter); |
205 | } | 206 | } |
206 | mAddresseeList.clear(); | 207 | mAddresseeList.clear(); |
207 | 208 | ||
208 | QClipboard *cb = QApplication::clipboard(); | 209 | QClipboard *cb = QApplication::clipboard(); |
209 | //US | 210 | //US |
210 | #ifndef KAB_EMBEDDED | 211 | #ifndef KAB_EMBEDDED |
211 | kapp->processEvents(); | 212 | kapp->processEvents(); |
212 | #else //KAB_EMBEDDED | 213 | #else //KAB_EMBEDDED |
213 | qApp->processEvents(); | 214 | qApp->processEvents(); |
214 | #endif //KAB_EMBEDDED | 215 | #endif //KAB_EMBEDDED |
215 | cb->setText( mOldText ); | 216 | cb->setText( mOldText ); |
216 | } | 217 | } |
217 | 218 | ||
218 | void PwCutCommand::redo() | 219 | void PwCutCommand::redo() |
219 | { | 220 | { |
220 | KABC::Addressee a; | 221 | KABC::Addressee a; |
221 | QStringList::Iterator iter; | 222 | QStringList::Iterator iter; |
222 | for (iter = mUidList.begin(); iter != mUidList.end(); ++iter) | 223 | for (iter = mUidList.begin(); iter != mUidList.end(); ++iter) |
223 | { | 224 | { |
224 | a = mDocument->findByUid(*iter); | 225 | a = mDocument->findByUid(*iter); |
225 | mDocument->removeAddressee(a); | 226 | mDocument->removeAddressee(a); |
226 | mAddresseeList.append(a); | 227 | mAddresseeList.append(a); |
227 | } | 228 | } |
228 | 229 | ||
229 | // Convert to clipboard | 230 | // Convert to clipboard |
230 | mClipText = AddresseeUtil::addresseesToClipboard(mAddresseeList); | 231 | mClipText = AddresseeUtil::addresseesToClipboard(mAddresseeList); |
231 | 232 | ||
232 | QClipboard *cb = QApplication::clipboard(); | 233 | QClipboard *cb = QApplication::clipboard(); |
233 | mOldText = cb->text(); | 234 | mOldText = cb->text(); |
234 | //US | 235 | //US |
235 | #ifndef KAB_EMBEDDED | 236 | #ifndef KAB_EMBEDDED |
236 | kapp->processEvents(); | 237 | kapp->processEvents(); |
237 | #else //KAB_EMBEDDED | 238 | #else //KAB_EMBEDDED |
238 | qApp->processEvents(); | 239 | qApp->processEvents(); |
239 | #endif //KAB_EMBEDDED | 240 | #endif //KAB_EMBEDDED |
240 | cb->setText( mClipText ); | 241 | cb->setText( mClipText ); |
241 | } | 242 | } |