author | ulf69 <ulf69> | 2004-08-10 16:25:06 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-10 16:25:06 (UTC) |
commit | 972b441aa3435f4f9df6de2a36ba2d03a7de5bbc (patch) (unidiff) | |
tree | 62ba0f85b223a10ec82cee5d7ddcfda84a0af21a /kaddressbook | |
parent | c56c4729e32a9c8ba8709493b3ea11cf7cf229d3 (diff) | |
download | kdepimpi-972b441aa3435f4f9df6de2a36ba2d03a7de5bbc.zip kdepimpi-972b441aa3435f4f9df6de2a36ba2d03a7de5bbc.tar.gz kdepimpi-972b441aa3435f4f9df6de2a36ba2d03a7de5bbc.tar.bz2 |
removed unneedded references to qtopia/services.h
-rw-r--r-- | kaddressbook/kabcore.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index fe4841a..d6f0cee 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,853 +1,851 @@ | |||
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 | 79 | ||
80 | //#include <qlabel.h> | 80 | //#include <qlabel.h> |
81 | 81 | ||
82 | 82 | ||
83 | #ifndef DESKTOP_VERSION | 83 | #ifndef DESKTOP_VERSION |
84 | #include <qtopia/services.h> | ||
85 | #include <qtopia/qcopenvelope_qws.h> | ||
86 | #include <qpe/ir.h> | 84 | #include <qpe/ir.h> |
87 | #endif | 85 | #endif |
88 | 86 | ||
89 | #endif // KAB_EMBEDDED | 87 | #endif // KAB_EMBEDDED |
90 | #include "kcmconfigs/kcmkabconfig.h" | 88 | #include "kcmconfigs/kcmkabconfig.h" |
91 | #include "kcmconfigs/kcmkdepimconfig.h" | 89 | #include "kcmconfigs/kcmkdepimconfig.h" |
92 | #include "kpimglobalprefs.h" | 90 | #include "kpimglobalprefs.h" |
93 | #include "externalapphandler.h" | 91 | #include "externalapphandler.h" |
94 | 92 | ||
95 | 93 | ||
96 | #include <kresources/selectdialog.h> | 94 | #include <kresources/selectdialog.h> |
97 | #include <kmessagebox.h> | 95 | #include <kmessagebox.h> |
98 | 96 | ||
99 | #include <picture.h> | 97 | #include <picture.h> |
100 | #include <resource.h> | 98 | #include <resource.h> |
101 | 99 | ||
102 | //US#include <qsplitter.h> | 100 | //US#include <qsplitter.h> |
103 | #include <qmap.h> | 101 | #include <qmap.h> |
104 | #include <qdir.h> | 102 | #include <qdir.h> |
105 | #include <qfile.h> | 103 | #include <qfile.h> |
106 | #include <qvbox.h> | 104 | #include <qvbox.h> |
107 | #include <qlayout.h> | 105 | #include <qlayout.h> |
108 | #include <qclipboard.h> | 106 | #include <qclipboard.h> |
109 | #include <qtextstream.h> | 107 | #include <qtextstream.h> |
110 | 108 | ||
111 | #include <libkdepim/categoryselectdialog.h> | 109 | #include <libkdepim/categoryselectdialog.h> |
112 | #include <kabc/vcardconverter.h> | 110 | #include <kabc/vcardconverter.h> |
113 | 111 | ||
114 | 112 | ||
115 | #include "addresseeutil.h" | 113 | #include "addresseeutil.h" |
116 | #include "undocmds.h" | 114 | #include "undocmds.h" |
117 | #include "addresseeeditordialog.h" | 115 | #include "addresseeeditordialog.h" |
118 | #include "viewmanager.h" | 116 | #include "viewmanager.h" |
119 | #include "details/detailsviewcontainer.h" | 117 | #include "details/detailsviewcontainer.h" |
120 | #include "kabprefs.h" | 118 | #include "kabprefs.h" |
121 | #include "xxportmanager.h" | 119 | #include "xxportmanager.h" |
122 | #include "incsearchwidget.h" | 120 | #include "incsearchwidget.h" |
123 | #include "jumpbuttonbar.h" | 121 | #include "jumpbuttonbar.h" |
124 | #include "extensionmanager.h" | 122 | #include "extensionmanager.h" |
125 | #include "addresseeconfig.h" | 123 | #include "addresseeconfig.h" |
126 | #include <kcmultidialog.h> | 124 | #include <kcmultidialog.h> |
127 | 125 | ||
128 | #ifdef _WIN32_ | 126 | #ifdef _WIN32_ |
129 | 127 | ||
130 | #include "kaimportoldialog.h" | 128 | #include "kaimportoldialog.h" |
131 | #endif | 129 | #endif |
132 | 130 | ||
133 | bool pasteWithNewUid = true; | 131 | bool pasteWithNewUid = true; |
134 | 132 | ||
135 | #ifdef KAB_EMBEDDED | 133 | #ifdef KAB_EMBEDDED |
136 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 134 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
137 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 135 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
138 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 136 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
139 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 137 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
140 | #else //KAB_EMBEDDED | 138 | #else //KAB_EMBEDDED |
141 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 139 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
142 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 140 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
143 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 141 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
144 | mReadWrite( readWrite ), mModified( false ) | 142 | mReadWrite( readWrite ), mModified( false ) |
145 | #endif //KAB_EMBEDDED | 143 | #endif //KAB_EMBEDDED |
146 | { | 144 | { |
147 | 145 | ||
148 | mExtensionBarSplitter = 0; | 146 | mExtensionBarSplitter = 0; |
149 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 147 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
150 | 148 | ||
151 | mAddressBook = KABC::StdAddressBook::self(); | 149 | mAddressBook = KABC::StdAddressBook::self(); |
152 | KABC::StdAddressBook::setAutomaticSave( false ); | 150 | KABC::StdAddressBook::setAutomaticSave( false ); |
153 | 151 | ||
154 | #ifndef KAB_EMBEDDED | 152 | #ifndef KAB_EMBEDDED |
155 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 153 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
156 | #endif //KAB_EMBEDDED | 154 | #endif //KAB_EMBEDDED |
157 | 155 | ||
158 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 156 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
159 | SLOT( addressBookChanged() ) ); | 157 | SLOT( addressBookChanged() ) ); |
160 | 158 | ||
161 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 159 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
162 | "X-Department", "KADDRESSBOOK" ); | 160 | "X-Department", "KADDRESSBOOK" ); |
163 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 161 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
164 | "X-Profession", "KADDRESSBOOK" ); | 162 | "X-Profession", "KADDRESSBOOK" ); |
165 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 163 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
166 | "X-AssistantsName", "KADDRESSBOOK" ); | 164 | "X-AssistantsName", "KADDRESSBOOK" ); |
167 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 165 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
168 | "X-ManagersName", "KADDRESSBOOK" ); | 166 | "X-ManagersName", "KADDRESSBOOK" ); |
169 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 167 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
170 | "X-SpousesName", "KADDRESSBOOK" ); | 168 | "X-SpousesName", "KADDRESSBOOK" ); |
171 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 169 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
172 | "X-Office", "KADDRESSBOOK" ); | 170 | "X-Office", "KADDRESSBOOK" ); |
173 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 171 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
174 | "X-IMAddress", "KADDRESSBOOK" ); | 172 | "X-IMAddress", "KADDRESSBOOK" ); |
175 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 173 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
176 | "X-Anniversary", "KADDRESSBOOK" ); | 174 | "X-Anniversary", "KADDRESSBOOK" ); |
177 | 175 | ||
178 | //US added this field to become compatible with Opie/qtopia addressbook | 176 | //US added this field to become compatible with Opie/qtopia addressbook |
179 | // values can be "female" or "male" or "". An empty field represents undefined. | 177 | // values can be "female" or "male" or "". An empty field represents undefined. |
180 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 178 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
181 | "X-Gender", "KADDRESSBOOK" ); | 179 | "X-Gender", "KADDRESSBOOK" ); |
182 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 180 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
183 | "X-Children", "KADDRESSBOOK" ); | 181 | "X-Children", "KADDRESSBOOK" ); |
184 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 182 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
185 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 183 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
186 | 184 | ||
187 | initGUI(); | 185 | initGUI(); |
188 | 186 | ||
189 | mIncSearchWidget->setFocus(); | 187 | mIncSearchWidget->setFocus(); |
190 | 188 | ||
191 | 189 | ||
192 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 190 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
193 | SLOT( setContactSelected( const QString& ) ) ); | 191 | SLOT( setContactSelected( const QString& ) ) ); |
194 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 192 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
195 | SLOT( editContact( const QString& ) ) ); | 193 | SLOT( editContact( const QString& ) ) ); |
196 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 194 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
197 | SLOT( deleteContacts( ) ) ); | 195 | SLOT( deleteContacts( ) ) ); |
198 | connect( mViewManager, SIGNAL( modified() ), | 196 | connect( mViewManager, SIGNAL( modified() ), |
199 | SLOT( setModified() ) ); | 197 | SLOT( setModified() ) ); |
200 | 198 | ||
201 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 199 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
202 | 200 | ||
203 | connect( mXXPortManager, SIGNAL( modified() ), | 201 | connect( mXXPortManager, SIGNAL( modified() ), |
204 | SLOT( setModified() ) ); | 202 | SLOT( setModified() ) ); |
205 | 203 | ||
206 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 204 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
207 | SLOT( incrementalSearch( const QString& ) ) ); | 205 | SLOT( incrementalSearch( const QString& ) ) ); |
208 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 206 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
209 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 207 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
210 | 208 | ||
211 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 209 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
212 | SLOT( sendMail( const QString& ) ) ); | 210 | SLOT( sendMail( const QString& ) ) ); |
213 | 211 | ||
214 | #ifndef KAB_EMBEDDED | 212 | #ifndef KAB_EMBEDDED |
215 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 213 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
216 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 214 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
217 | 215 | ||
218 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 216 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
219 | SLOT( browse( const QString& ) ) ); | 217 | SLOT( browse( const QString& ) ) ); |
220 | 218 | ||
221 | mAddressBookService = new KAddressBookService( this ); | 219 | mAddressBookService = new KAddressBookService( this ); |
222 | 220 | ||
223 | #endif //KAB_EMBEDDED | 221 | #endif //KAB_EMBEDDED |
224 | mEditorDialog = 0; | 222 | mEditorDialog = 0; |
225 | createAddresseeEditorDialog( this ); | 223 | createAddresseeEditorDialog( this ); |
226 | setModified( false ); | 224 | setModified( false ); |
227 | } | 225 | } |
228 | 226 | ||
229 | KABCore::~KABCore() | 227 | KABCore::~KABCore() |
230 | { | 228 | { |
231 | // save(); | 229 | // save(); |
232 | //saveSettings(); | 230 | //saveSettings(); |
233 | //KABPrefs::instance()->writeConfig(); | 231 | //KABPrefs::instance()->writeConfig(); |
234 | delete AddresseeConfig::instance(); | 232 | delete AddresseeConfig::instance(); |
235 | mAddressBook = 0; | 233 | mAddressBook = 0; |
236 | KABC::StdAddressBook::close(); | 234 | KABC::StdAddressBook::close(); |
237 | } | 235 | } |
238 | 236 | ||
239 | void KABCore::restoreSettings() | 237 | void KABCore::restoreSettings() |
240 | { | 238 | { |
241 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; | 239 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; |
242 | 240 | ||
243 | mActionJumpBar->setChecked( state ); | 241 | mActionJumpBar->setChecked( state ); |
244 | setJumpButtonBarVisible( state ); | 242 | setJumpButtonBarVisible( state ); |
245 | 243 | ||
246 | state = KABPrefs::instance()->mDetailsPageVisible; | 244 | state = KABPrefs::instance()->mDetailsPageVisible; |
247 | 245 | ||
248 | mActionDetails->setChecked( state ); | 246 | mActionDetails->setChecked( state ); |
249 | setDetailsVisible( state ); | 247 | setDetailsVisible( state ); |
250 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 248 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
251 | if ( splitterSize.count() == 0 ) { | 249 | if ( splitterSize.count() == 0 ) { |
252 | splitterSize.append( width() / 2 ); | 250 | splitterSize.append( width() / 2 ); |
253 | splitterSize.append( width() / 2 ); | 251 | splitterSize.append( width() / 2 ); |
254 | } | 252 | } |
255 | mMiniSplitter->setSizes( splitterSize ); | 253 | mMiniSplitter->setSizes( splitterSize ); |
256 | if ( mExtensionBarSplitter ) { | 254 | if ( mExtensionBarSplitter ) { |
257 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 255 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
258 | if ( splitterSize.count() == 0 ) { | 256 | if ( splitterSize.count() == 0 ) { |
259 | splitterSize.append( width() / 2 ); | 257 | splitterSize.append( width() / 2 ); |
260 | splitterSize.append( width() / 2 ); | 258 | splitterSize.append( width() / 2 ); |
261 | } | 259 | } |
262 | mExtensionBarSplitter->setSizes( splitterSize ); | 260 | mExtensionBarSplitter->setSizes( splitterSize ); |
263 | 261 | ||
264 | } | 262 | } |
265 | #ifndef KAB_EMBEDDED | 263 | #ifndef KAB_EMBEDDED |
266 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 264 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
267 | if ( splitterSize.count() == 0 ) { | 265 | if ( splitterSize.count() == 0 ) { |
268 | splitterSize.append( width() / 2 ); | 266 | splitterSize.append( width() / 2 ); |
269 | splitterSize.append( width() / 2 ); | 267 | splitterSize.append( width() / 2 ); |
270 | } | 268 | } |
271 | mExtensionBarSplitter->setSizes( splitterSize ); | 269 | mExtensionBarSplitter->setSizes( splitterSize ); |
272 | 270 | ||
273 | splitterSize = KABPrefs::instance()->mDetailsSplitter; | 271 | splitterSize = KABPrefs::instance()->mDetailsSplitter; |
274 | if ( splitterSize.count() == 0 ) { | 272 | if ( splitterSize.count() == 0 ) { |
275 | splitterSize.append( height() / 2 ); | 273 | splitterSize.append( height() / 2 ); |
276 | splitterSize.append( height() / 2 ); | 274 | splitterSize.append( height() / 2 ); |
277 | } | 275 | } |
278 | mDetailsSplitter->setSizes( splitterSize ); | 276 | mDetailsSplitter->setSizes( splitterSize ); |
279 | 277 | ||
280 | mExtensionManager->restoreSettings(); | 278 | mExtensionManager->restoreSettings(); |
281 | 279 | ||
282 | #endif //KAB_EMBEDDED | 280 | #endif //KAB_EMBEDDED |
283 | 281 | ||
284 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 282 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
285 | 283 | ||
286 | mViewManager->restoreSettings(); | 284 | mViewManager->restoreSettings(); |
287 | mExtensionManager->restoreSettings(); | 285 | mExtensionManager->restoreSettings(); |
288 | } | 286 | } |
289 | 287 | ||
290 | void KABCore::saveSettings() | 288 | void KABCore::saveSettings() |
291 | { | 289 | { |
292 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 290 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
293 | if ( mExtensionBarSplitter ) | 291 | if ( mExtensionBarSplitter ) |
294 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 292 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
295 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 293 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
296 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 294 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
297 | #ifndef KAB_EMBEDDED | 295 | #ifndef KAB_EMBEDDED |
298 | 296 | ||
299 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 297 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
300 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 298 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
301 | #endif //KAB_EMBEDDED | 299 | #endif //KAB_EMBEDDED |
302 | mExtensionManager->saveSettings(); | 300 | mExtensionManager->saveSettings(); |
303 | mViewManager->saveSettings(); | 301 | mViewManager->saveSettings(); |
304 | 302 | ||
305 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 303 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
306 | 304 | ||
307 | } | 305 | } |
308 | 306 | ||
309 | KABC::AddressBook *KABCore::addressBook() const | 307 | KABC::AddressBook *KABCore::addressBook() const |
310 | { | 308 | { |
311 | return mAddressBook; | 309 | return mAddressBook; |
312 | } | 310 | } |
313 | 311 | ||
314 | KConfig *KABCore::config() | 312 | KConfig *KABCore::config() |
315 | { | 313 | { |
316 | #ifndef KAB_EMBEDDED | 314 | #ifndef KAB_EMBEDDED |
317 | return KABPrefs::instance()->config(); | 315 | return KABPrefs::instance()->config(); |
318 | #else //KAB_EMBEDDED | 316 | #else //KAB_EMBEDDED |
319 | return KABPrefs::instance()->getConfig(); | 317 | return KABPrefs::instance()->getConfig(); |
320 | #endif //KAB_EMBEDDED | 318 | #endif //KAB_EMBEDDED |
321 | } | 319 | } |
322 | 320 | ||
323 | KActionCollection *KABCore::actionCollection() const | 321 | KActionCollection *KABCore::actionCollection() const |
324 | { | 322 | { |
325 | return mGUIClient->actionCollection(); | 323 | return mGUIClient->actionCollection(); |
326 | } | 324 | } |
327 | 325 | ||
328 | KABC::Field *KABCore::currentSearchField() const | 326 | KABC::Field *KABCore::currentSearchField() const |
329 | { | 327 | { |
330 | if (mIncSearchWidget) | 328 | if (mIncSearchWidget) |
331 | return mIncSearchWidget->currentField(); | 329 | return mIncSearchWidget->currentField(); |
332 | else | 330 | else |
333 | return 0; | 331 | return 0; |
334 | } | 332 | } |
335 | 333 | ||
336 | QStringList KABCore::selectedUIDs() const | 334 | QStringList KABCore::selectedUIDs() const |
337 | { | 335 | { |
338 | return mViewManager->selectedUids(); | 336 | return mViewManager->selectedUids(); |
339 | } | 337 | } |
340 | 338 | ||
341 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 339 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
342 | { | 340 | { |
343 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 341 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
344 | 342 | ||
345 | QPtrList<KRES::Resource> kresResources; | 343 | QPtrList<KRES::Resource> kresResources; |
346 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 344 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
347 | KABC::Resource *resource; | 345 | KABC::Resource *resource; |
348 | while ( ( resource = resIt.current() ) != 0 ) { | 346 | while ( ( resource = resIt.current() ) != 0 ) { |
349 | ++resIt; | 347 | ++resIt; |
350 | if ( !resource->readOnly() ) { | 348 | if ( !resource->readOnly() ) { |
351 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 349 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
352 | if ( res ) | 350 | if ( res ) |
353 | kresResources.append( res ); | 351 | kresResources.append( res ); |
354 | } | 352 | } |
355 | } | 353 | } |
356 | 354 | ||
357 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 355 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
358 | return static_cast<KABC::Resource*>( res ); | 356 | return static_cast<KABC::Resource*>( res ); |
359 | } | 357 | } |
360 | 358 | ||
361 | #ifndef KAB_EMBEDDED | 359 | #ifndef KAB_EMBEDDED |
362 | KAboutData *KABCore::createAboutData() | 360 | KAboutData *KABCore::createAboutData() |
363 | #else //KAB_EMBEDDED | 361 | #else //KAB_EMBEDDED |
364 | void KABCore::createAboutData() | 362 | void KABCore::createAboutData() |
365 | #endif //KAB_EMBEDDED | 363 | #endif //KAB_EMBEDDED |
366 | { | 364 | { |
367 | #ifndef KAB_EMBEDDED | 365 | #ifndef KAB_EMBEDDED |
368 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 366 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
369 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 367 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
370 | KAboutData::License_GPL_V2, | 368 | KAboutData::License_GPL_V2, |
371 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 369 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
372 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 370 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
373 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 371 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
374 | about->addAuthor( "Cornelius Schumacher", | 372 | about->addAuthor( "Cornelius Schumacher", |
375 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 373 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
376 | "schumacher@kde.org" ); | 374 | "schumacher@kde.org" ); |
377 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 375 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
378 | "mpilone@slac.com" ); | 376 | "mpilone@slac.com" ); |
379 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 377 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
380 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 378 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
381 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 379 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
382 | "michel@klaralvdalens-datakonsult.se" ); | 380 | "michel@klaralvdalens-datakonsult.se" ); |
383 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 381 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
384 | "hansen@kde.org" ); | 382 | "hansen@kde.org" ); |
385 | 383 | ||
386 | return about; | 384 | return about; |
387 | #endif //KAB_EMBEDDED | 385 | #endif //KAB_EMBEDDED |
388 | 386 | ||
389 | QString version; | 387 | QString version; |
390 | #include <../version> | 388 | #include <../version> |
391 | QMessageBox::about( this, "About KAddressbook/Pi", | 389 | QMessageBox::about( this, "About KAddressbook/Pi", |
392 | "KAddressbook/Platform-independent\n" | 390 | "KAddressbook/Platform-independent\n" |
393 | "(KA/Pi) " +version + " - " + | 391 | "(KA/Pi) " +version + " - " + |
394 | #ifdef DESKTOP_VERSION | 392 | #ifdef DESKTOP_VERSION |
395 | "Desktop Edition\n" | 393 | "Desktop Edition\n" |
396 | #else | 394 | #else |
397 | "PDA-Edition\n" | 395 | "PDA-Edition\n" |
398 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 396 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
399 | #endif | 397 | #endif |
400 | 398 | ||
401 | "(c) 2004 Ulf Schenk\n" | 399 | "(c) 2004 Ulf Schenk\n" |
402 | "(c) 1997-2003, The KDE PIM Team\n" | 400 | "(c) 1997-2003, The KDE PIM Team\n" |
403 | "Tobias Koenig Current maintainer tokoe@kde.org\n" | 401 | "Tobias Koenig Current maintainer tokoe@kde.org\n" |
404 | "Don Sanders Original author\n" | 402 | "Don Sanders Original author\n" |
405 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" | 403 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" |
406 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" | 404 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" |
407 | "Greg Stern DCOP interface\n" | 405 | "Greg Stern DCOP interface\n" |
408 | "Mark Westcot Contact pinning\n" | 406 | "Mark Westcot Contact pinning\n" |
409 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 407 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
410 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" | 408 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" |
411 | #ifdef _WIN32_ | 409 | #ifdef _WIN32_ |
412 | "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n" | 410 | "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n" |
413 | #endif | 411 | #endif |
414 | ); | 412 | ); |
415 | } | 413 | } |
416 | 414 | ||
417 | void KABCore::setContactSelected( const QString &uid ) | 415 | void KABCore::setContactSelected( const QString &uid ) |
418 | { | 416 | { |
419 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 417 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
420 | if ( !mDetails->isHidden() ) | 418 | if ( !mDetails->isHidden() ) |
421 | mDetails->setAddressee( addr ); | 419 | mDetails->setAddressee( addr ); |
422 | 420 | ||
423 | if ( !addr.isEmpty() ) { | 421 | if ( !addr.isEmpty() ) { |
424 | emit contactSelected( addr.formattedName() ); | 422 | emit contactSelected( addr.formattedName() ); |
425 | KABC::Picture pic = addr.photo(); | 423 | KABC::Picture pic = addr.photo(); |
426 | if ( pic.isIntern() ) { | 424 | if ( pic.isIntern() ) { |
427 | //US emit contactSelected( pic.data() ); | 425 | //US emit contactSelected( pic.data() ); |
428 | //US instead use: | 426 | //US instead use: |
429 | QPixmap px; | 427 | QPixmap px; |
430 | if (pic.data().isNull() != true) | 428 | if (pic.data().isNull() != true) |
431 | { | 429 | { |
432 | px.convertFromImage(pic.data()); | 430 | px.convertFromImage(pic.data()); |
433 | } | 431 | } |
434 | 432 | ||
435 | emit contactSelected( px ); | 433 | emit contactSelected( px ); |
436 | } | 434 | } |
437 | } | 435 | } |
438 | 436 | ||
439 | 437 | ||
440 | mExtensionManager->setSelectionChanged(); | 438 | mExtensionManager->setSelectionChanged(); |
441 | 439 | ||
442 | // update the actions | 440 | // update the actions |
443 | bool selected = !uid.isEmpty(); | 441 | bool selected = !uid.isEmpty(); |
444 | 442 | ||
445 | if ( mReadWrite ) { | 443 | if ( mReadWrite ) { |
446 | mActionCut->setEnabled( selected ); | 444 | mActionCut->setEnabled( selected ); |
447 | mActionPaste->setEnabled( selected ); | 445 | mActionPaste->setEnabled( selected ); |
448 | } | 446 | } |
449 | 447 | ||
450 | mActionCopy->setEnabled( selected ); | 448 | mActionCopy->setEnabled( selected ); |
451 | mActionDelete->setEnabled( selected ); | 449 | mActionDelete->setEnabled( selected ); |
452 | mActionEditAddressee->setEnabled( selected ); | 450 | mActionEditAddressee->setEnabled( selected ); |
453 | mActionMail->setEnabled( selected ); | 451 | mActionMail->setEnabled( selected ); |
454 | mActionMailVCard->setEnabled( selected ); | 452 | mActionMailVCard->setEnabled( selected ); |
455 | //if (mActionBeam) | 453 | //if (mActionBeam) |
456 | //mActionBeam->setEnabled( selected ); | 454 | //mActionBeam->setEnabled( selected ); |
457 | 455 | ||
458 | if (mActionBeamVCard) | 456 | if (mActionBeamVCard) |
459 | mActionBeamVCard->setEnabled( selected ); | 457 | mActionBeamVCard->setEnabled( selected ); |
460 | 458 | ||
461 | mActionWhoAmI->setEnabled( selected ); | 459 | mActionWhoAmI->setEnabled( selected ); |
462 | mActionCategories->setEnabled( selected ); | 460 | mActionCategories->setEnabled( selected ); |
463 | } | 461 | } |
464 | 462 | ||
465 | void KABCore::sendMail() | 463 | void KABCore::sendMail() |
466 | { | 464 | { |
467 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 465 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
468 | } | 466 | } |
469 | 467 | ||
470 | void KABCore::sendMail( const QString& email ) | 468 | void KABCore::sendMail( const QString& email ) |
471 | { | 469 | { |
472 | bool result = ExternalAppHandler::instance()->mailToContacts(email); | 470 | bool result = ExternalAppHandler::instance()->mailToContacts(email); |
473 | } | 471 | } |
474 | 472 | ||
475 | 473 | ||
476 | 474 | ||
477 | void KABCore::mailVCard() | 475 | void KABCore::mailVCard() |
478 | { | 476 | { |
479 | QStringList uids = mViewManager->selectedUids(); | 477 | QStringList uids = mViewManager->selectedUids(); |
480 | if ( !uids.isEmpty() ) | 478 | if ( !uids.isEmpty() ) |
481 | mailVCard( uids ); | 479 | mailVCard( uids ); |
482 | } | 480 | } |
483 | 481 | ||
484 | void KABCore::mailVCard( const QStringList& uids ) | 482 | void KABCore::mailVCard( const QStringList& uids ) |
485 | { | 483 | { |
486 | QStringList urls; | 484 | QStringList urls; |
487 | 485 | ||
488 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 486 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
489 | 487 | ||
490 | /*US | 488 | /*US |
491 | // Create a temp dir, so that we can put the files in it with proper names | 489 | // Create a temp dir, so that we can put the files in it with proper names |
492 | KTempFile tempDir; | 490 | KTempFile tempDir; |
493 | if ( tempDir.status() != 0 ) { | 491 | if ( tempDir.status() != 0 ) { |
494 | kdWarning() << strerror( tempDir.status() ) << endl; | 492 | kdWarning() << strerror( tempDir.status() ) << endl; |
495 | return; | 493 | return; |
496 | } | 494 | } |
497 | 495 | ||
498 | QString dirName = tempDir.name(); | 496 | QString dirName = tempDir.name(); |
499 | tempDir.unlink(); | 497 | tempDir.unlink(); |
500 | */ | 498 | */ |
501 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 499 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
502 | 500 | ||
503 | 501 | ||
504 | 502 | ||
505 | QDir().mkdir( dirName, true ); | 503 | QDir().mkdir( dirName, true ); |
506 | 504 | ||
507 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 505 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
508 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 506 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
509 | 507 | ||
510 | if ( a.isEmpty() ) | 508 | if ( a.isEmpty() ) |
511 | continue; | 509 | continue; |
512 | 510 | ||
513 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 511 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
514 | 512 | ||
515 | QString fileName = dirName + "/" + name; | 513 | QString fileName = dirName + "/" + name; |
516 | 514 | ||
517 | QFile outFile(fileName); | 515 | QFile outFile(fileName); |
518 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 516 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
519 | KABC::VCardConverter converter; | 517 | KABC::VCardConverter converter; |
520 | QString vcard; | 518 | QString vcard; |
521 | 519 | ||
522 | converter.addresseeToVCard( a, vcard ); | 520 | converter.addresseeToVCard( a, vcard ); |
523 | 521 | ||
524 | QTextStream t( &outFile ); // use a text stream | 522 | QTextStream t( &outFile ); // use a text stream |
525 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 523 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
526 | t << vcard; | 524 | t << vcard; |
527 | 525 | ||
528 | outFile.close(); | 526 | outFile.close(); |
529 | 527 | ||
530 | urls.append( fileName ); | 528 | urls.append( fileName ); |
531 | } | 529 | } |
532 | } | 530 | } |
533 | 531 | ||
534 | bool result = ExternalAppHandler::instance()->mailAttachments(urls.join(", ")); | 532 | bool result = ExternalAppHandler::instance()->mailAttachments(urls.join(", ")); |
535 | 533 | ||
536 | 534 | ||
537 | /*US | 535 | /*US |
538 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 536 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
539 | QString::null, // subject | 537 | QString::null, // subject |
540 | QString::null, // body | 538 | QString::null, // body |
541 | QString::null, | 539 | QString::null, |
542 | urls ); // attachments | 540 | urls ); // attachments |
543 | */ | 541 | */ |
544 | 542 | ||
545 | } | 543 | } |
546 | 544 | ||
547 | /** | 545 | /** |
548 | Beams the "WhoAmI contact. | 546 | Beams the "WhoAmI contact. |
549 | */ | 547 | */ |
550 | void KABCore::beamMySelf() | 548 | void KABCore::beamMySelf() |
551 | { | 549 | { |
552 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 550 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
553 | if (!a.isEmpty()) | 551 | if (!a.isEmpty()) |
554 | { | 552 | { |
555 | QStringList uids; | 553 | QStringList uids; |
556 | uids << a.uid(); | 554 | uids << a.uid(); |
557 | 555 | ||
558 | beamVCard(uids); | 556 | beamVCard(uids); |
559 | } else { | 557 | } else { |
560 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 558 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
561 | 559 | ||
562 | 560 | ||
563 | } | 561 | } |
564 | } | 562 | } |
565 | 563 | ||
566 | void KABCore::beamVCard() | 564 | void KABCore::beamVCard() |
567 | { | 565 | { |
568 | QStringList uids = mViewManager->selectedUids(); | 566 | QStringList uids = mViewManager->selectedUids(); |
569 | if ( !uids.isEmpty() ) | 567 | if ( !uids.isEmpty() ) |
570 | beamVCard( uids ); | 568 | beamVCard( uids ); |
571 | } | 569 | } |
572 | 570 | ||
573 | 571 | ||
574 | void KABCore::beamVCard(const QStringList& uids) | 572 | void KABCore::beamVCard(const QStringList& uids) |
575 | { | 573 | { |
576 | /*US | 574 | /*US |
577 | QString beamFilename; | 575 | QString beamFilename; |
578 | Opie::OPimContact c; | 576 | Opie::OPimContact c; |
579 | if ( actionPersonal->isOn() ) { | 577 | if ( actionPersonal->isOn() ) { |
580 | beamFilename = addressbookPersonalVCardName(); | 578 | beamFilename = addressbookPersonalVCardName(); |
581 | if ( !QFile::exists( beamFilename ) ) | 579 | if ( !QFile::exists( beamFilename ) ) |
582 | return; // can't beam a non-existent file | 580 | return; // can't beam a non-existent file |
583 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 581 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
584 | beamFilename ); | 582 | beamFilename ); |
585 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 583 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
586 | Opie::OPimContactAccess::List allList = access->allRecords(); | 584 | Opie::OPimContactAccess::List allList = access->allRecords(); |
587 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 585 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
588 | c = *it; | 586 | c = *it; |
589 | 587 | ||
590 | delete access; | 588 | delete access; |
591 | } else { | 589 | } else { |
592 | unlink( beamfile ); // delete if exists | 590 | unlink( beamfile ); // delete if exists |
593 | mkdir("/tmp/obex/", 0755); | 591 | mkdir("/tmp/obex/", 0755); |
594 | c = m_abView -> currentEntry(); | 592 | c = m_abView -> currentEntry(); |
595 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 593 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
596 | beamfile ); | 594 | beamfile ); |
597 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 595 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
598 | access->add( c ); | 596 | access->add( c ); |
599 | access->save(); | 597 | access->save(); |
600 | delete access; | 598 | delete access; |
601 | 599 | ||
602 | beamFilename = beamfile; | 600 | beamFilename = beamfile; |
603 | } | 601 | } |
604 | 602 | ||
605 | owarn << "Beaming: " << beamFilename << oendl; | 603 | owarn << "Beaming: " << beamFilename << oendl; |
606 | */ | 604 | */ |
607 | 605 | ||
608 | #if 0 | 606 | #if 0 |
609 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 607 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
610 | 608 | ||
611 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 609 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
612 | 610 | ||
613 | QString name = "contact.vcf"; | 611 | QString name = "contact.vcf"; |
614 | 612 | ||
615 | QString fileName = dirName + "/" + name; | 613 | QString fileName = dirName + "/" + name; |
616 | #endif | 614 | #endif |
617 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 615 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
618 | // | 616 | // |
619 | QString fileName = "/tmp/kdepimbeamfile"; | 617 | QString fileName = "/tmp/kdepimbeamfile"; |
620 | 618 | ||
621 | 619 | ||
622 | //QDir().mkdir( dirName, true ); | 620 | //QDir().mkdir( dirName, true ); |
623 | 621 | ||
624 | QFile outFile(fileName); | 622 | QFile outFile(fileName); |
625 | KABC::VCardConverter converter; | 623 | KABC::VCardConverter converter; |
626 | QString description; | 624 | QString description; |
627 | 625 | ||
628 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 626 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
629 | 627 | ||
630 | QTextStream t( &outFile ); // use a text stream | 628 | QTextStream t( &outFile ); // use a text stream |
631 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 629 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
632 | 630 | ||
633 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 631 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
634 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 632 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
635 | 633 | ||
636 | if ( a.isEmpty() ) | 634 | if ( a.isEmpty() ) |
637 | continue; | 635 | continue; |
638 | 636 | ||
639 | if (description.isEmpty()) | 637 | if (description.isEmpty()) |
640 | description = a.formattedName(); | 638 | description = a.formattedName(); |
641 | 639 | ||
642 | QString vcard; | 640 | QString vcard; |
643 | converter.addresseeToVCard( a, vcard ); | 641 | converter.addresseeToVCard( a, vcard ); |
644 | t << vcard; | 642 | t << vcard; |
645 | 643 | ||
646 | } | 644 | } |
647 | } else { | 645 | } else { |
648 | qDebug("Error open temp beam file "); | 646 | qDebug("Error open temp beam file "); |
649 | return; | 647 | return; |
650 | } | 648 | } |
651 | 649 | ||
652 | outFile.close(); | 650 | outFile.close(); |
653 | 651 | ||
654 | #ifndef DESKTOP_VERSION | 652 | #ifndef DESKTOP_VERSION |
655 | Ir *ir = new Ir( this ); | 653 | Ir *ir = new Ir( this ); |
656 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 654 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
657 | ir->send( fileName, description, "text/x-vCard" ); | 655 | ir->send( fileName, description, "text/x-vCard" ); |
658 | #endif | 656 | #endif |
659 | 657 | ||
660 | } | 658 | } |
661 | 659 | ||
662 | void KABCore::beamDone( Ir *ir ) | 660 | void KABCore::beamDone( Ir *ir ) |
663 | { | 661 | { |
664 | #ifndef DESKTOP_VERSION | 662 | #ifndef DESKTOP_VERSION |
665 | delete ir; | 663 | delete ir; |
666 | #endif | 664 | #endif |
667 | } | 665 | } |
668 | 666 | ||
669 | 667 | ||
670 | void KABCore::browse( const QString& url ) | 668 | void KABCore::browse( const QString& url ) |
671 | { | 669 | { |
672 | #ifndef KAB_EMBEDDED | 670 | #ifndef KAB_EMBEDDED |
673 | kapp->invokeBrowser( url ); | 671 | kapp->invokeBrowser( url ); |
674 | #else //KAB_EMBEDDED | 672 | #else //KAB_EMBEDDED |
675 | qDebug("KABCore::browse must be fixed"); | 673 | qDebug("KABCore::browse must be fixed"); |
676 | #endif //KAB_EMBEDDED | 674 | #endif //KAB_EMBEDDED |
677 | } | 675 | } |
678 | 676 | ||
679 | void KABCore::selectAllContacts() | 677 | void KABCore::selectAllContacts() |
680 | { | 678 | { |
681 | mViewManager->setSelected( QString::null, true ); | 679 | mViewManager->setSelected( QString::null, true ); |
682 | } | 680 | } |
683 | 681 | ||
684 | void KABCore::deleteContacts() | 682 | void KABCore::deleteContacts() |
685 | { | 683 | { |
686 | QStringList uidList = mViewManager->selectedUids(); | 684 | QStringList uidList = mViewManager->selectedUids(); |
687 | deleteContacts( uidList ); | 685 | deleteContacts( uidList ); |
688 | } | 686 | } |
689 | 687 | ||
690 | void KABCore::deleteContacts( const QStringList &uids ) | 688 | void KABCore::deleteContacts( const QStringList &uids ) |
691 | { | 689 | { |
692 | if ( uids.count() > 0 ) { | 690 | if ( uids.count() > 0 ) { |
693 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 691 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
694 | UndoStack::instance()->push( command ); | 692 | UndoStack::instance()->push( command ); |
695 | RedoStack::instance()->clear(); | 693 | RedoStack::instance()->clear(); |
696 | 694 | ||
697 | // now if we deleted anything, refresh | 695 | // now if we deleted anything, refresh |
698 | setContactSelected( QString::null ); | 696 | setContactSelected( QString::null ); |
699 | setModified( true ); | 697 | setModified( true ); |
700 | } | 698 | } |
701 | } | 699 | } |
702 | 700 | ||
703 | void KABCore::copyContacts() | 701 | void KABCore::copyContacts() |
704 | { | 702 | { |
705 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 703 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
706 | 704 | ||
707 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 705 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
708 | 706 | ||
709 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 707 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
710 | 708 | ||
711 | QClipboard *cb = QApplication::clipboard(); | 709 | QClipboard *cb = QApplication::clipboard(); |
712 | cb->setText( clipText ); | 710 | cb->setText( clipText ); |
713 | } | 711 | } |
714 | 712 | ||
715 | void KABCore::cutContacts() | 713 | void KABCore::cutContacts() |
716 | { | 714 | { |
717 | QStringList uidList = mViewManager->selectedUids(); | 715 | QStringList uidList = mViewManager->selectedUids(); |
718 | 716 | ||
719 | //US if ( uidList.size() > 0 ) { | 717 | //US if ( uidList.size() > 0 ) { |
720 | if ( uidList.count() > 0 ) { | 718 | if ( uidList.count() > 0 ) { |
721 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 719 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
722 | UndoStack::instance()->push( command ); | 720 | UndoStack::instance()->push( command ); |
723 | RedoStack::instance()->clear(); | 721 | RedoStack::instance()->clear(); |
724 | 722 | ||
725 | setModified( true ); | 723 | setModified( true ); |
726 | } | 724 | } |
727 | } | 725 | } |
728 | 726 | ||
729 | void KABCore::pasteContacts() | 727 | void KABCore::pasteContacts() |
730 | { | 728 | { |
731 | QClipboard *cb = QApplication::clipboard(); | 729 | QClipboard *cb = QApplication::clipboard(); |
732 | 730 | ||
733 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 731 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
734 | 732 | ||
735 | pasteContacts( list ); | 733 | pasteContacts( list ); |
736 | } | 734 | } |
737 | 735 | ||
738 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 736 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
739 | { | 737 | { |
740 | KABC::Resource *resource = requestResource( this ); | 738 | KABC::Resource *resource = requestResource( this ); |
741 | KABC::Addressee::List::Iterator it; | 739 | KABC::Addressee::List::Iterator it; |
742 | for ( it = list.begin(); it != list.end(); ++it ) | 740 | for ( it = list.begin(); it != list.end(); ++it ) |
743 | (*it).setResource( resource ); | 741 | (*it).setResource( resource ); |
744 | 742 | ||
745 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 743 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
746 | UndoStack::instance()->push( command ); | 744 | UndoStack::instance()->push( command ); |
747 | RedoStack::instance()->clear(); | 745 | RedoStack::instance()->clear(); |
748 | 746 | ||
749 | setModified( true ); | 747 | setModified( true ); |
750 | } | 748 | } |
751 | 749 | ||
752 | void KABCore::setWhoAmI() | 750 | void KABCore::setWhoAmI() |
753 | { | 751 | { |
754 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 752 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
755 | 753 | ||
756 | if ( addrList.count() > 1 ) { | 754 | if ( addrList.count() > 1 ) { |
757 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 755 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
758 | return; | 756 | return; |
759 | } | 757 | } |
760 | 758 | ||
761 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 759 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
762 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 760 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
763 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 761 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
764 | } | 762 | } |
765 | 763 | ||
766 | void KABCore::setCategories() | 764 | void KABCore::setCategories() |
767 | { | 765 | { |
768 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 766 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
769 | if ( !dlg.exec() ) | 767 | if ( !dlg.exec() ) |
770 | return; | 768 | return; |
771 | 769 | ||
772 | bool merge = false; | 770 | bool merge = false; |
773 | QString msg = i18n( "Merge with existing categories?" ); | 771 | QString msg = i18n( "Merge with existing categories?" ); |
774 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 772 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
775 | merge = true; | 773 | merge = true; |
776 | 774 | ||
777 | QStringList categories = dlg.selectedCategories(); | 775 | QStringList categories = dlg.selectedCategories(); |
778 | 776 | ||
779 | QStringList uids = mViewManager->selectedUids(); | 777 | QStringList uids = mViewManager->selectedUids(); |
780 | QStringList::Iterator it; | 778 | QStringList::Iterator it; |
781 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 779 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
782 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 780 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
783 | if ( !addr.isEmpty() ) { | 781 | if ( !addr.isEmpty() ) { |
784 | if ( !merge ) | 782 | if ( !merge ) |
785 | addr.setCategories( categories ); | 783 | addr.setCategories( categories ); |
786 | else { | 784 | else { |
787 | QStringList addrCategories = addr.categories(); | 785 | QStringList addrCategories = addr.categories(); |
788 | QStringList::Iterator catIt; | 786 | QStringList::Iterator catIt; |
789 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 787 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
790 | if ( !addrCategories.contains( *catIt ) ) | 788 | if ( !addrCategories.contains( *catIt ) ) |
791 | addrCategories.append( *catIt ); | 789 | addrCategories.append( *catIt ); |
792 | } | 790 | } |
793 | addr.setCategories( addrCategories ); | 791 | addr.setCategories( addrCategories ); |
794 | } | 792 | } |
795 | 793 | ||
796 | mAddressBook->insertAddressee( addr ); | 794 | mAddressBook->insertAddressee( addr ); |
797 | } | 795 | } |
798 | } | 796 | } |
799 | 797 | ||
800 | if ( uids.count() > 0 ) | 798 | if ( uids.count() > 0 ) |
801 | setModified( true ); | 799 | setModified( true ); |
802 | } | 800 | } |
803 | 801 | ||
804 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 802 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
805 | { | 803 | { |
806 | mIncSearchWidget->setFields( fields ); | 804 | mIncSearchWidget->setFields( fields ); |
807 | } | 805 | } |
808 | 806 | ||
809 | void KABCore::incrementalSearch( const QString& text ) | 807 | void KABCore::incrementalSearch( const QString& text ) |
810 | { | 808 | { |
811 | mViewManager->setSelected( QString::null, false ); | 809 | mViewManager->setSelected( QString::null, false ); |
812 | 810 | ||
813 | if ( !text.isEmpty() ) { | 811 | if ( !text.isEmpty() ) { |
814 | KABC::Field *field = mIncSearchWidget->currentField(); | 812 | KABC::Field *field = mIncSearchWidget->currentField(); |
815 | 813 | ||
816 | QString pattern = text.lower(); | 814 | QString pattern = text.lower(); |
817 | 815 | ||
818 | #if 1 //KDE_VERSION >= 319 | 816 | #if 1 //KDE_VERSION >= 319 |
819 | KABC::AddresseeList list( mAddressBook->allAddressees() ); | 817 | KABC::AddresseeList list( mAddressBook->allAddressees() ); |
820 | if ( field ) { | 818 | if ( field ) { |
821 | list.sortByField( field ); | 819 | list.sortByField( field ); |
822 | KABC::AddresseeList::Iterator it; | 820 | KABC::AddresseeList::Iterator it; |
823 | for ( it = list.begin(); it != list.end(); ++it ) { | 821 | for ( it = list.begin(); it != list.end(); ++it ) { |
824 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 822 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
825 | mViewManager->setSelected( (*it).uid(), true ); | 823 | mViewManager->setSelected( (*it).uid(), true ); |
826 | return; | 824 | return; |
827 | } | 825 | } |
828 | } | 826 | } |
829 | } else { | 827 | } else { |
830 | KABC::AddresseeList::Iterator it; | 828 | KABC::AddresseeList::Iterator it; |
831 | for ( it = list.begin(); it != list.end(); ++it ) { | 829 | for ( it = list.begin(); it != list.end(); ++it ) { |
832 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 830 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
833 | KABC::Field::List::ConstIterator fieldIt; | 831 | KABC::Field::List::ConstIterator fieldIt; |
834 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 832 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
835 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | 833 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { |
836 | mViewManager->setSelected( (*it).uid(), true ); | 834 | mViewManager->setSelected( (*it).uid(), true ); |
837 | return; | 835 | return; |
838 | } | 836 | } |
839 | } | 837 | } |
840 | } | 838 | } |
841 | } | 839 | } |
842 | #else | 840 | #else |
843 | KABC::AddressBook::Iterator it; | 841 | KABC::AddressBook::Iterator it; |
844 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 842 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
845 | if ( field ) { | 843 | if ( field ) { |
846 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 844 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
847 | mViewManager->setSelected( (*it).uid(), true ); | 845 | mViewManager->setSelected( (*it).uid(), true ); |
848 | return; | 846 | return; |
849 | } | 847 | } |
850 | } else { | 848 | } else { |
851 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 849 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
852 | KABC::Field::List::ConstIterator fieldIt; | 850 | KABC::Field::List::ConstIterator fieldIt; |
853 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 851 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |