-rw-r--r-- | bin/kdepim/kaddressbook/icons22/listview.png | bin | 365 -> 657 bytes | |||
-rw-r--r-- | kaddressbook/kabcore.cpp | 4 |
2 files changed, 3 insertions, 1 deletions
diff --git a/bin/kdepim/kaddressbook/icons22/listview.png b/bin/kdepim/kaddressbook/icons22/listview.png index b19d9f8..7de6ba0 100644 --- a/bin/kdepim/kaddressbook/icons22/listview.png +++ b/bin/kdepim/kaddressbook/icons22/listview.png | |||
Binary files differ | |||
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index cb9b992..f0f08f4 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2094 +1,2096 @@ | |||
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 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | 35 | ||
36 | #ifndef KAB_EMBEDDED | 36 | #ifndef KAB_EMBEDDED |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qdir.h> | 38 | #include <qdir.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qapplicaton.h> | 40 | #include <qapplicaton.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qregexp.h> | 42 | #include <qregexp.h> |
43 | #include <qvbox.h> | 43 | #include <qvbox.h> |
44 | #include <kabc/addresseelist.h> | 44 | #include <kabc/addresseelist.h> |
45 | #include <kabc/errorhandler.h> | 45 | #include <kabc/errorhandler.h> |
46 | #include <kabc/resource.h> | 46 | #include <kabc/resource.h> |
47 | #include <kabc/vcardconverter.h> | 47 | #include <kabc/vcardconverter.h> |
48 | #include <kapplication.h> | 48 | #include <kapplication.h> |
49 | #include <kactionclasses.h> | 49 | #include <kactionclasses.h> |
50 | #include <kcmultidialog.h> | 50 | #include <kcmultidialog.h> |
51 | #include <kdebug.h> | 51 | #include <kdebug.h> |
52 | #include <kdeversion.h> | 52 | #include <kdeversion.h> |
53 | #include <kkeydialog.h> | 53 | #include <kkeydialog.h> |
54 | #include <kmessagebox.h> | 54 | #include <kmessagebox.h> |
55 | #include <kprinter.h> | 55 | #include <kprinter.h> |
56 | #include <kprotocolinfo.h> | 56 | #include <kprotocolinfo.h> |
57 | #include <kresources/selectdialog.h> | 57 | #include <kresources/selectdialog.h> |
58 | #include <kstandarddirs.h> | 58 | #include <kstandarddirs.h> |
59 | #include <ktempfile.h> | 59 | #include <ktempfile.h> |
60 | #include <kxmlguiclient.h> | 60 | #include <kxmlguiclient.h> |
61 | #include <kaboutdata.h> | 61 | #include <kaboutdata.h> |
62 | #include <libkdepim/categoryselectdialog.h> | 62 | #include <libkdepim/categoryselectdialog.h> |
63 | 63 | ||
64 | #include "addresseeutil.h" | 64 | #include "addresseeutil.h" |
65 | #include "addresseeeditordialog.h" | 65 | #include "addresseeeditordialog.h" |
66 | #include "extensionmanager.h" | 66 | #include "extensionmanager.h" |
67 | #include "kstdaction.h" | 67 | #include "kstdaction.h" |
68 | #include "kaddressbookservice.h" | 68 | #include "kaddressbookservice.h" |
69 | #include "ldapsearchdialog.h" | 69 | #include "ldapsearchdialog.h" |
70 | #include "printing/printingwizard.h" | 70 | #include "printing/printingwizard.h" |
71 | #else // KAB_EMBEDDED | 71 | #else // KAB_EMBEDDED |
72 | 72 | ||
73 | #include <kapplication.h> | 73 | #include <kapplication.h> |
74 | #include "KDGanttMinimizeSplitter.h" | 74 | #include "KDGanttMinimizeSplitter.h" |
75 | #include "kaddressbookmain.h" | 75 | #include "kaddressbookmain.h" |
76 | #include "kactioncollection.h" | 76 | #include "kactioncollection.h" |
77 | #include "addresseedialog.h" | 77 | #include "addresseedialog.h" |
78 | //US | 78 | //US |
79 | #include <libkdepim/addresseeview.h> | 79 | #include <libkdepim/addresseeview.h> |
80 | 80 | ||
81 | #include <qapp.h> | 81 | #include <qapp.h> |
82 | #include <qmenubar.h> | 82 | #include <qmenubar.h> |
83 | //#include <qtoolbar.h> | 83 | //#include <qtoolbar.h> |
84 | #include <qmessagebox.h> | 84 | #include <qmessagebox.h> |
85 | #include <kdebug.h> | 85 | #include <kdebug.h> |
86 | #include <kiconloader.h> // needed for SmallIcon | 86 | #include <kiconloader.h> // needed for SmallIcon |
87 | #include <kresources/kcmkresources.h> | 87 | #include <kresources/kcmkresources.h> |
88 | #include <ktoolbar.h> | 88 | #include <ktoolbar.h> |
89 | 89 | ||
90 | 90 | ||
91 | //#include <qlabel.h> | 91 | //#include <qlabel.h> |
92 | 92 | ||
93 | 93 | ||
94 | #ifndef DESKTOP_VERSION | 94 | #ifndef DESKTOP_VERSION |
95 | #include <qpe/ir.h> | 95 | #include <qpe/ir.h> |
96 | #include <qtopia/qcopenvelope_qws.h> | 96 | #include <qtopia/qcopenvelope_qws.h> |
97 | #else | 97 | #else |
98 | 98 | ||
99 | #endif | 99 | #endif |
100 | 100 | ||
101 | #endif // KAB_EMBEDDED | 101 | #endif // KAB_EMBEDDED |
102 | #include "kcmconfigs/kcmkabconfig.h" | 102 | #include "kcmconfigs/kcmkabconfig.h" |
103 | #include "kcmconfigs/kcmkdepimconfig.h" | 103 | #include "kcmconfigs/kcmkdepimconfig.h" |
104 | #include "kpimglobalprefs.h" | 104 | #include "kpimglobalprefs.h" |
105 | #include "externalapphandler.h" | 105 | #include "externalapphandler.h" |
106 | 106 | ||
107 | 107 | ||
108 | #include <kresources/selectdialog.h> | 108 | #include <kresources/selectdialog.h> |
109 | #include <kmessagebox.h> | 109 | #include <kmessagebox.h> |
110 | 110 | ||
111 | #include <picture.h> | 111 | #include <picture.h> |
112 | #include <resource.h> | 112 | #include <resource.h> |
113 | 113 | ||
114 | //US#include <qsplitter.h> | 114 | //US#include <qsplitter.h> |
115 | #include <qmap.h> | 115 | #include <qmap.h> |
116 | #include <qdir.h> | 116 | #include <qdir.h> |
117 | #include <qfile.h> | 117 | #include <qfile.h> |
118 | #include <qvbox.h> | 118 | #include <qvbox.h> |
119 | #include <qlayout.h> | 119 | #include <qlayout.h> |
120 | #include <qclipboard.h> | 120 | #include <qclipboard.h> |
121 | #include <qtextstream.h> | 121 | #include <qtextstream.h> |
122 | 122 | ||
123 | #include <libkdepim/categoryselectdialog.h> | 123 | #include <libkdepim/categoryselectdialog.h> |
124 | #include <kabc/vcardconverter.h> | 124 | #include <kabc/vcardconverter.h> |
125 | 125 | ||
126 | 126 | ||
127 | #include "addresseeutil.h" | 127 | #include "addresseeutil.h" |
128 | #include "undocmds.h" | 128 | #include "undocmds.h" |
129 | #include "addresseeeditordialog.h" | 129 | #include "addresseeeditordialog.h" |
130 | #include "viewmanager.h" | 130 | #include "viewmanager.h" |
131 | #include "details/detailsviewcontainer.h" | 131 | #include "details/detailsviewcontainer.h" |
132 | #include "kabprefs.h" | 132 | #include "kabprefs.h" |
133 | #include "xxportmanager.h" | 133 | #include "xxportmanager.h" |
134 | #include "incsearchwidget.h" | 134 | #include "incsearchwidget.h" |
135 | #include "jumpbuttonbar.h" | 135 | #include "jumpbuttonbar.h" |
136 | #include "extensionmanager.h" | 136 | #include "extensionmanager.h" |
137 | #include "addresseeconfig.h" | 137 | #include "addresseeconfig.h" |
138 | #include <kcmultidialog.h> | 138 | #include <kcmultidialog.h> |
139 | 139 | ||
140 | #ifdef _WIN32_ | 140 | #ifdef _WIN32_ |
141 | 141 | ||
142 | #include "kaimportoldialog.h" | 142 | #include "kaimportoldialog.h" |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | bool pasteWithNewUid = true; | 145 | bool pasteWithNewUid = true; |
146 | 146 | ||
147 | #ifdef KAB_EMBEDDED | 147 | #ifdef KAB_EMBEDDED |
148 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 148 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
149 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 149 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
150 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 150 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
151 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 151 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
152 | #else //KAB_EMBEDDED | 152 | #else //KAB_EMBEDDED |
153 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 153 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
154 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 154 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
155 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 155 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
156 | mReadWrite( readWrite ), mModified( false ) | 156 | mReadWrite( readWrite ), mModified( false ) |
157 | #endif //KAB_EMBEDDED | 157 | #endif //KAB_EMBEDDED |
158 | { | 158 | { |
159 | 159 | ||
160 | mExtensionBarSplitter = 0; | 160 | mExtensionBarSplitter = 0; |
161 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 161 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
162 | 162 | ||
163 | mAddressBook = KABC::StdAddressBook::self(); | 163 | mAddressBook = KABC::StdAddressBook::self(); |
164 | KABC::StdAddressBook::setAutomaticSave( false ); | 164 | KABC::StdAddressBook::setAutomaticSave( false ); |
165 | 165 | ||
166 | #ifndef KAB_EMBEDDED | 166 | #ifndef KAB_EMBEDDED |
167 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 167 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
168 | #endif //KAB_EMBEDDED | 168 | #endif //KAB_EMBEDDED |
169 | 169 | ||
170 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 170 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
171 | SLOT( addressBookChanged() ) ); | 171 | SLOT( addressBookChanged() ) ); |
172 | 172 | ||
173 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 173 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
174 | "X-Department", "KADDRESSBOOK" ); | 174 | "X-Department", "KADDRESSBOOK" ); |
175 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 175 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
176 | "X-Profession", "KADDRESSBOOK" ); | 176 | "X-Profession", "KADDRESSBOOK" ); |
177 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 177 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
178 | "X-AssistantsName", "KADDRESSBOOK" ); | 178 | "X-AssistantsName", "KADDRESSBOOK" ); |
179 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 179 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
180 | "X-ManagersName", "KADDRESSBOOK" ); | 180 | "X-ManagersName", "KADDRESSBOOK" ); |
181 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 181 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
182 | "X-SpousesName", "KADDRESSBOOK" ); | 182 | "X-SpousesName", "KADDRESSBOOK" ); |
183 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 183 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
184 | "X-Office", "KADDRESSBOOK" ); | 184 | "X-Office", "KADDRESSBOOK" ); |
185 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 185 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
186 | "X-IMAddress", "KADDRESSBOOK" ); | 186 | "X-IMAddress", "KADDRESSBOOK" ); |
187 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 187 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
188 | "X-Anniversary", "KADDRESSBOOK" ); | 188 | "X-Anniversary", "KADDRESSBOOK" ); |
189 | 189 | ||
190 | //US added this field to become compatible with Opie/qtopia addressbook | 190 | //US added this field to become compatible with Opie/qtopia addressbook |
191 | // values can be "female" or "male" or "". An empty field represents undefined. | 191 | // values can be "female" or "male" or "". An empty field represents undefined. |
192 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 192 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
193 | "X-Gender", "KADDRESSBOOK" ); | 193 | "X-Gender", "KADDRESSBOOK" ); |
194 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 194 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
195 | "X-Children", "KADDRESSBOOK" ); | 195 | "X-Children", "KADDRESSBOOK" ); |
196 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 196 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
197 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 197 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
198 | 198 | ||
199 | initGUI(); | 199 | initGUI(); |
200 | 200 | ||
201 | mIncSearchWidget->setFocus(); | 201 | mIncSearchWidget->setFocus(); |
202 | 202 | ||
203 | 203 | ||
204 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 204 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
205 | SLOT( setContactSelected( const QString& ) ) ); | 205 | SLOT( setContactSelected( const QString& ) ) ); |
206 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 206 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
207 | SLOT( executeContact( const QString& ) ) ); | 207 | SLOT( executeContact( const QString& ) ) ); |
208 | 208 | ||
209 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 209 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
210 | SLOT( deleteContacts( ) ) ); | 210 | SLOT( deleteContacts( ) ) ); |
211 | connect( mViewManager, SIGNAL( modified() ), | 211 | connect( mViewManager, SIGNAL( modified() ), |
212 | SLOT( setModified() ) ); | 212 | SLOT( setModified() ) ); |
213 | 213 | ||
214 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 214 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
215 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 215 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
216 | 216 | ||
217 | connect( mXXPortManager, SIGNAL( modified() ), | 217 | connect( mXXPortManager, SIGNAL( modified() ), |
218 | SLOT( setModified() ) ); | 218 | SLOT( setModified() ) ); |
219 | 219 | ||
220 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 220 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
221 | SLOT( incrementalSearch( const QString& ) ) ); | 221 | SLOT( incrementalSearch( const QString& ) ) ); |
222 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 222 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
223 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 223 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
224 | 224 | ||
225 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 225 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
226 | SLOT( sendMail( const QString& ) ) ); | 226 | SLOT( sendMail( const QString& ) ) ); |
227 | 227 | ||
228 | 228 | ||
229 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 229 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
230 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 230 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
231 | 231 | ||
232 | 232 | ||
233 | #ifndef KAB_EMBEDDED | 233 | #ifndef KAB_EMBEDDED |
234 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 234 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
235 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 235 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
236 | 236 | ||
237 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 237 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
238 | SLOT( browse( const QString& ) ) ); | 238 | SLOT( browse( const QString& ) ) ); |
239 | 239 | ||
240 | 240 | ||
241 | mAddressBookService = new KAddressBookService( this ); | 241 | mAddressBookService = new KAddressBookService( this ); |
242 | 242 | ||
243 | #endif //KAB_EMBEDDED | 243 | #endif //KAB_EMBEDDED |
244 | mEditorDialog = 0; | 244 | mEditorDialog = 0; |
245 | createAddresseeEditorDialog( this ); | 245 | createAddresseeEditorDialog( this ); |
246 | setModified( false ); | 246 | setModified( false ); |
247 | } | 247 | } |
248 | 248 | ||
249 | KABCore::~KABCore() | 249 | KABCore::~KABCore() |
250 | { | 250 | { |
251 | // save(); | 251 | // save(); |
252 | //saveSettings(); | 252 | //saveSettings(); |
253 | //KABPrefs::instance()->writeConfig(); | 253 | //KABPrefs::instance()->writeConfig(); |
254 | delete AddresseeConfig::instance(); | 254 | delete AddresseeConfig::instance(); |
255 | mAddressBook = 0; | 255 | mAddressBook = 0; |
256 | KABC::StdAddressBook::close(); | 256 | KABC::StdAddressBook::close(); |
257 | } | 257 | } |
258 | 258 | ||
259 | void KABCore::restoreSettings() | 259 | void KABCore::restoreSettings() |
260 | { | 260 | { |
261 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 261 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
262 | 262 | ||
263 | bool state; | 263 | bool state; |
264 | 264 | ||
265 | if (mMultipleViewsAtOnce) | 265 | if (mMultipleViewsAtOnce) |
266 | state = KABPrefs::instance()->mDetailsPageVisible; | 266 | state = KABPrefs::instance()->mDetailsPageVisible; |
267 | else | 267 | else |
268 | state = false; | 268 | state = false; |
269 | 269 | ||
270 | mActionDetails->setChecked( state ); | 270 | mActionDetails->setChecked( state ); |
271 | setDetailsVisible( state ); | 271 | setDetailsVisible( state ); |
272 | 272 | ||
273 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 273 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
274 | 274 | ||
275 | mActionJumpBar->setChecked( state ); | 275 | mActionJumpBar->setChecked( state ); |
276 | setJumpButtonBarVisible( state ); | 276 | setJumpButtonBarVisible( state ); |
277 | /*US | 277 | /*US |
278 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 278 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
279 | if ( splitterSize.count() == 0 ) { | 279 | if ( splitterSize.count() == 0 ) { |
280 | splitterSize.append( width() / 2 ); | 280 | splitterSize.append( width() / 2 ); |
281 | splitterSize.append( width() / 2 ); | 281 | splitterSize.append( width() / 2 ); |
282 | } | 282 | } |
283 | mMiniSplitter->setSizes( splitterSize ); | 283 | mMiniSplitter->setSizes( splitterSize ); |
284 | if ( mExtensionBarSplitter ) { | 284 | if ( mExtensionBarSplitter ) { |
285 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 285 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
286 | if ( splitterSize.count() == 0 ) { | 286 | if ( splitterSize.count() == 0 ) { |
287 | splitterSize.append( width() / 2 ); | 287 | splitterSize.append( width() / 2 ); |
288 | splitterSize.append( width() / 2 ); | 288 | splitterSize.append( width() / 2 ); |
289 | } | 289 | } |
290 | mExtensionBarSplitter->setSizes( splitterSize ); | 290 | mExtensionBarSplitter->setSizes( splitterSize ); |
291 | 291 | ||
292 | } | 292 | } |
293 | */ | 293 | */ |
294 | mViewManager->restoreSettings(); | 294 | mViewManager->restoreSettings(); |
295 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 295 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
296 | mExtensionManager->restoreSettings(); | 296 | mExtensionManager->restoreSettings(); |
297 | 297 | ||
298 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 298 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
299 | if ( splitterSize.count() == 0 ) { | 299 | if ( splitterSize.count() == 0 ) { |
300 | splitterSize.append( width() / 2 ); | 300 | splitterSize.append( width() / 2 ); |
301 | splitterSize.append( width() / 2 ); | 301 | splitterSize.append( width() / 2 ); |
302 | } | 302 | } |
303 | mMiniSplitter->setSizes( splitterSize ); | 303 | mMiniSplitter->setSizes( splitterSize ); |
304 | if ( mExtensionBarSplitter ) { | 304 | if ( mExtensionBarSplitter ) { |
305 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 305 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
306 | if ( splitterSize.count() == 0 ) { | 306 | if ( splitterSize.count() == 0 ) { |
307 | splitterSize.append( width() / 2 ); | 307 | splitterSize.append( width() / 2 ); |
308 | splitterSize.append( width() / 2 ); | 308 | splitterSize.append( width() / 2 ); |
309 | } | 309 | } |
310 | mExtensionBarSplitter->setSizes( splitterSize ); | 310 | mExtensionBarSplitter->setSizes( splitterSize ); |
311 | 311 | ||
312 | } | 312 | } |
313 | 313 | ||
314 | 314 | ||
315 | } | 315 | } |
316 | 316 | ||
317 | void KABCore::saveSettings() | 317 | void KABCore::saveSettings() |
318 | { | 318 | { |
319 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 319 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
320 | if ( mExtensionBarSplitter ) | 320 | if ( mExtensionBarSplitter ) |
321 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 321 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
322 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 322 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
323 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 323 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
324 | #ifndef KAB_EMBEDDED | 324 | #ifndef KAB_EMBEDDED |
325 | 325 | ||
326 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 326 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
327 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 327 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
328 | #endif //KAB_EMBEDDED | 328 | #endif //KAB_EMBEDDED |
329 | mExtensionManager->saveSettings(); | 329 | mExtensionManager->saveSettings(); |
330 | mViewManager->saveSettings(); | 330 | mViewManager->saveSettings(); |
331 | 331 | ||
332 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 332 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
333 | } | 333 | } |
334 | 334 | ||
335 | KABC::AddressBook *KABCore::addressBook() const | 335 | KABC::AddressBook *KABCore::addressBook() const |
336 | { | 336 | { |
337 | return mAddressBook; | 337 | return mAddressBook; |
338 | } | 338 | } |
339 | 339 | ||
340 | KConfig *KABCore::config() | 340 | KConfig *KABCore::config() |
341 | { | 341 | { |
342 | #ifndef KAB_EMBEDDED | 342 | #ifndef KAB_EMBEDDED |
343 | return KABPrefs::instance()->config(); | 343 | return KABPrefs::instance()->config(); |
344 | #else //KAB_EMBEDDED | 344 | #else //KAB_EMBEDDED |
345 | return KABPrefs::instance()->getConfig(); | 345 | return KABPrefs::instance()->getConfig(); |
346 | #endif //KAB_EMBEDDED | 346 | #endif //KAB_EMBEDDED |
347 | } | 347 | } |
348 | 348 | ||
349 | KActionCollection *KABCore::actionCollection() const | 349 | KActionCollection *KABCore::actionCollection() const |
350 | { | 350 | { |
351 | return mGUIClient->actionCollection(); | 351 | return mGUIClient->actionCollection(); |
352 | } | 352 | } |
353 | 353 | ||
354 | KABC::Field *KABCore::currentSearchField() const | 354 | KABC::Field *KABCore::currentSearchField() const |
355 | { | 355 | { |
356 | if (mIncSearchWidget) | 356 | if (mIncSearchWidget) |
357 | return mIncSearchWidget->currentField(); | 357 | return mIncSearchWidget->currentField(); |
358 | else | 358 | else |
359 | return 0; | 359 | return 0; |
360 | } | 360 | } |
361 | 361 | ||
362 | QStringList KABCore::selectedUIDs() const | 362 | QStringList KABCore::selectedUIDs() const |
363 | { | 363 | { |
364 | return mViewManager->selectedUids(); | 364 | return mViewManager->selectedUids(); |
365 | } | 365 | } |
366 | 366 | ||
367 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 367 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
368 | { | 368 | { |
369 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 369 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
370 | 370 | ||
371 | QPtrList<KRES::Resource> kresResources; | 371 | QPtrList<KRES::Resource> kresResources; |
372 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 372 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
373 | KABC::Resource *resource; | 373 | KABC::Resource *resource; |
374 | while ( ( resource = resIt.current() ) != 0 ) { | 374 | while ( ( resource = resIt.current() ) != 0 ) { |
375 | ++resIt; | 375 | ++resIt; |
376 | if ( !resource->readOnly() ) { | 376 | if ( !resource->readOnly() ) { |
377 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 377 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
378 | if ( res ) | 378 | if ( res ) |
379 | kresResources.append( res ); | 379 | kresResources.append( res ); |
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 383 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
384 | return static_cast<KABC::Resource*>( res ); | 384 | return static_cast<KABC::Resource*>( res ); |
385 | } | 385 | } |
386 | 386 | ||
387 | #ifndef KAB_EMBEDDED | 387 | #ifndef KAB_EMBEDDED |
388 | KAboutData *KABCore::createAboutData() | 388 | KAboutData *KABCore::createAboutData() |
389 | #else //KAB_EMBEDDED | 389 | #else //KAB_EMBEDDED |
390 | void KABCore::createAboutData() | 390 | void KABCore::createAboutData() |
391 | #endif //KAB_EMBEDDED | 391 | #endif //KAB_EMBEDDED |
392 | { | 392 | { |
393 | #ifndef KAB_EMBEDDED | 393 | #ifndef KAB_EMBEDDED |
394 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 394 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
395 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 395 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
396 | KAboutData::License_GPL_V2, | 396 | KAboutData::License_GPL_V2, |
397 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 397 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
398 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 398 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
399 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 399 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
400 | about->addAuthor( "Cornelius Schumacher", | 400 | about->addAuthor( "Cornelius Schumacher", |
401 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 401 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
402 | "schumacher@kde.org" ); | 402 | "schumacher@kde.org" ); |
403 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 403 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
404 | "mpilone@slac.com" ); | 404 | "mpilone@slac.com" ); |
405 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 405 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
406 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 406 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
407 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 407 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
408 | "michel@klaralvdalens-datakonsult.se" ); | 408 | "michel@klaralvdalens-datakonsult.se" ); |
409 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 409 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
410 | "hansen@kde.org" ); | 410 | "hansen@kde.org" ); |
411 | 411 | ||
412 | return about; | 412 | return about; |
413 | #endif //KAB_EMBEDDED | 413 | #endif //KAB_EMBEDDED |
414 | 414 | ||
415 | QString version; | 415 | QString version; |
416 | #include <../version> | 416 | #include <../version> |
417 | QMessageBox::about( this, "About KAddressbook/Pi", | 417 | QMessageBox::about( this, "About KAddressbook/Pi", |
418 | "KAddressbook/Platform-independent\n" | 418 | "KAddressbook/Platform-independent\n" |
419 | "(KA/Pi) " +version + " - " + | 419 | "(KA/Pi) " +version + " - " + |
420 | #ifdef DESKTOP_VERSION | 420 | #ifdef DESKTOP_VERSION |
421 | "Desktop Edition\n" | 421 | "Desktop Edition\n" |
422 | #else | 422 | #else |
423 | "PDA-Edition\n" | 423 | "PDA-Edition\n" |
424 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 424 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
425 | #endif | 425 | #endif |
426 | 426 | ||
427 | "(c) 2004 Ulf Schenk\n" | 427 | "(c) 2004 Ulf Schenk\n" |
428 | "(c) 2004 Lutz Rogowski\n" | 428 | "(c) 2004 Lutz Rogowski\n" |
429 | "(c) 1997-2003, The KDE PIM Team\n" | 429 | "(c) 1997-2003, The KDE PIM Team\n" |
430 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 430 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
431 | "Don Sanders Original author\n" | 431 | "Don Sanders Original author\n" |
432 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 432 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
433 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 433 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
434 | "Greg Stern DCOP interface\n" | 434 | "Greg Stern DCOP interface\n" |
435 | "Mark Westcot Contact pinning\n" | 435 | "Mark Westcot Contact pinning\n" |
436 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 436 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
437 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 437 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
438 | #ifdef _WIN32_ | 438 | #ifdef _WIN32_ |
439 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 439 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
440 | #endif | 440 | #endif |
441 | ); | 441 | ); |
442 | } | 442 | } |
443 | 443 | ||
444 | void KABCore::setContactSelected( const QString &uid ) | 444 | void KABCore::setContactSelected( const QString &uid ) |
445 | { | 445 | { |
446 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 446 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
447 | if ( !mDetails->isHidden() ) | 447 | if ( !mDetails->isHidden() ) |
448 | mDetails->setAddressee( addr ); | 448 | mDetails->setAddressee( addr ); |
449 | 449 | ||
450 | if ( !addr.isEmpty() ) { | 450 | if ( !addr.isEmpty() ) { |
451 | emit contactSelected( addr.formattedName() ); | 451 | emit contactSelected( addr.formattedName() ); |
452 | KABC::Picture pic = addr.photo(); | 452 | KABC::Picture pic = addr.photo(); |
453 | if ( pic.isIntern() ) { | 453 | if ( pic.isIntern() ) { |
454 | //US emit contactSelected( pic.data() ); | 454 | //US emit contactSelected( pic.data() ); |
455 | //US instead use: | 455 | //US instead use: |
456 | QPixmap px; | 456 | QPixmap px; |
457 | if (pic.data().isNull() != true) | 457 | if (pic.data().isNull() != true) |
458 | { | 458 | { |
459 | px.convertFromImage(pic.data()); | 459 | px.convertFromImage(pic.data()); |
460 | } | 460 | } |
461 | 461 | ||
462 | emit contactSelected( px ); | 462 | emit contactSelected( px ); |
463 | } | 463 | } |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | mExtensionManager->setSelectionChanged(); | 467 | mExtensionManager->setSelectionChanged(); |
468 | 468 | ||
469 | // update the actions | 469 | // update the actions |
470 | bool selected = !uid.isEmpty(); | 470 | bool selected = !uid.isEmpty(); |
471 | 471 | ||
472 | if ( mReadWrite ) { | 472 | if ( mReadWrite ) { |
473 | mActionCut->setEnabled( selected ); | 473 | mActionCut->setEnabled( selected ); |
474 | mActionPaste->setEnabled( selected ); | 474 | mActionPaste->setEnabled( selected ); |
475 | } | 475 | } |
476 | 476 | ||
477 | mActionCopy->setEnabled( selected ); | 477 | mActionCopy->setEnabled( selected ); |
478 | mActionDelete->setEnabled( selected ); | 478 | mActionDelete->setEnabled( selected ); |
479 | mActionEditAddressee->setEnabled( selected ); | 479 | mActionEditAddressee->setEnabled( selected ); |
480 | mActionMail->setEnabled( selected ); | 480 | mActionMail->setEnabled( selected ); |
481 | mActionMailVCard->setEnabled( selected ); | 481 | mActionMailVCard->setEnabled( selected ); |
482 | //if (mActionBeam) | 482 | //if (mActionBeam) |
483 | //mActionBeam->setEnabled( selected ); | 483 | //mActionBeam->setEnabled( selected ); |
484 | 484 | ||
485 | if (mActionBeamVCard) | 485 | if (mActionBeamVCard) |
486 | mActionBeamVCard->setEnabled( selected ); | 486 | mActionBeamVCard->setEnabled( selected ); |
487 | 487 | ||
488 | mActionWhoAmI->setEnabled( selected ); | 488 | mActionWhoAmI->setEnabled( selected ); |
489 | mActionCategories->setEnabled( selected ); | 489 | mActionCategories->setEnabled( selected ); |
490 | } | 490 | } |
491 | 491 | ||
492 | void KABCore::sendMail() | 492 | void KABCore::sendMail() |
493 | { | 493 | { |
494 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 494 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
495 | } | 495 | } |
496 | 496 | ||
497 | void KABCore::sendMail( const QString& emaillist ) | 497 | void KABCore::sendMail( const QString& emaillist ) |
498 | { | 498 | { |
499 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 499 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
500 | if (emaillist.contains(",") > 0) | 500 | if (emaillist.contains(",") > 0) |
501 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 501 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
502 | else | 502 | else |
503 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 503 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | 507 | ||
508 | void KABCore::mailVCard() | 508 | void KABCore::mailVCard() |
509 | { | 509 | { |
510 | QStringList uids = mViewManager->selectedUids(); | 510 | QStringList uids = mViewManager->selectedUids(); |
511 | if ( !uids.isEmpty() ) | 511 | if ( !uids.isEmpty() ) |
512 | mailVCard( uids ); | 512 | mailVCard( uids ); |
513 | } | 513 | } |
514 | 514 | ||
515 | void KABCore::mailVCard( const QStringList& uids ) | 515 | void KABCore::mailVCard( const QStringList& uids ) |
516 | { | 516 | { |
517 | QStringList urls; | 517 | QStringList urls; |
518 | 518 | ||
519 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 519 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
520 | 520 | ||
521 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 521 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
522 | 522 | ||
523 | 523 | ||
524 | 524 | ||
525 | QDir().mkdir( dirName, true ); | 525 | QDir().mkdir( dirName, true ); |
526 | 526 | ||
527 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 527 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
528 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 528 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
529 | 529 | ||
530 | if ( a.isEmpty() ) | 530 | if ( a.isEmpty() ) |
531 | continue; | 531 | continue; |
532 | 532 | ||
533 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 533 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
534 | 534 | ||
535 | QString fileName = dirName + "/" + name; | 535 | QString fileName = dirName + "/" + name; |
536 | 536 | ||
537 | QFile outFile(fileName); | 537 | QFile outFile(fileName); |
538 | 538 | ||
539 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 539 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
540 | KABC::VCardConverter converter; | 540 | KABC::VCardConverter converter; |
541 | QString vcard; | 541 | QString vcard; |
542 | 542 | ||
543 | converter.addresseeToVCard( a, vcard ); | 543 | converter.addresseeToVCard( a, vcard ); |
544 | 544 | ||
545 | QTextStream t( &outFile ); // use a text stream | 545 | QTextStream t( &outFile ); // use a text stream |
546 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 546 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
547 | t << vcard; | 547 | t << vcard; |
548 | 548 | ||
549 | outFile.close(); | 549 | outFile.close(); |
550 | 550 | ||
551 | urls.append( fileName ); | 551 | urls.append( fileName ); |
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 555 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
556 | 556 | ||
557 | 557 | ||
558 | /*US | 558 | /*US |
559 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 559 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
560 | QString::null, // subject | 560 | QString::null, // subject |
561 | QString::null, // body | 561 | QString::null, // body |
562 | QString::null, | 562 | QString::null, |
563 | urls ); // attachments | 563 | urls ); // attachments |
564 | */ | 564 | */ |
565 | 565 | ||
566 | } | 566 | } |
567 | 567 | ||
568 | /** | 568 | /** |
569 | Beams the "WhoAmI contact. | 569 | Beams the "WhoAmI contact. |
570 | */ | 570 | */ |
571 | void KABCore::beamMySelf() | 571 | void KABCore::beamMySelf() |
572 | { | 572 | { |
573 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 573 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
574 | if (!a.isEmpty()) | 574 | if (!a.isEmpty()) |
575 | { | 575 | { |
576 | QStringList uids; | 576 | QStringList uids; |
577 | uids << a.uid(); | 577 | uids << a.uid(); |
578 | 578 | ||
579 | beamVCard(uids); | 579 | beamVCard(uids); |
580 | } else { | 580 | } else { |
581 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 581 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
582 | 582 | ||
583 | 583 | ||
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | void KABCore::beamVCard() | 587 | void KABCore::beamVCard() |
588 | { | 588 | { |
589 | QStringList uids = mViewManager->selectedUids(); | 589 | QStringList uids = mViewManager->selectedUids(); |
590 | if ( !uids.isEmpty() ) | 590 | if ( !uids.isEmpty() ) |
591 | beamVCard( uids ); | 591 | beamVCard( uids ); |
592 | } | 592 | } |
593 | 593 | ||
594 | 594 | ||
595 | void KABCore::beamVCard(const QStringList& uids) | 595 | void KABCore::beamVCard(const QStringList& uids) |
596 | { | 596 | { |
597 | /*US | 597 | /*US |
598 | QString beamFilename; | 598 | QString beamFilename; |
599 | Opie::OPimContact c; | 599 | Opie::OPimContact c; |
600 | if ( actionPersonal->isOn() ) { | 600 | if ( actionPersonal->isOn() ) { |
601 | beamFilename = addressbookPersonalVCardName(); | 601 | beamFilename = addressbookPersonalVCardName(); |
602 | if ( !QFile::exists( beamFilename ) ) | 602 | if ( !QFile::exists( beamFilename ) ) |
603 | return; // can't beam a non-existent file | 603 | return; // can't beam a non-existent file |
604 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 604 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
605 | beamFilename ); | 605 | beamFilename ); |
606 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 606 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
607 | Opie::OPimContactAccess::List allList = access->allRecords(); | 607 | Opie::OPimContactAccess::List allList = access->allRecords(); |
608 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 608 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
609 | c = *it; | 609 | c = *it; |
610 | 610 | ||
611 | delete access; | 611 | delete access; |
612 | } else { | 612 | } else { |
613 | unlink( beamfile ); // delete if exists | 613 | unlink( beamfile ); // delete if exists |
614 | mkdir("/tmp/obex/", 0755); | 614 | mkdir("/tmp/obex/", 0755); |
615 | c = m_abView -> currentEntry(); | 615 | c = m_abView -> currentEntry(); |
616 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 616 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
617 | beamfile ); | 617 | beamfile ); |
618 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 618 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
619 | access->add( c ); | 619 | access->add( c ); |
620 | access->save(); | 620 | access->save(); |
621 | delete access; | 621 | delete access; |
622 | 622 | ||
623 | beamFilename = beamfile; | 623 | beamFilename = beamfile; |
624 | } | 624 | } |
625 | 625 | ||
626 | owarn << "Beaming: " << beamFilename << oendl; | 626 | owarn << "Beaming: " << beamFilename << oendl; |
627 | */ | 627 | */ |
628 | 628 | ||
629 | #if 0 | 629 | #if 0 |
630 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 630 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
631 | 631 | ||
632 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 632 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
633 | 633 | ||
634 | QString name = "contact.vcf"; | 634 | QString name = "contact.vcf"; |
635 | 635 | ||
636 | QString fileName = dirName + "/" + name; | 636 | QString fileName = dirName + "/" + name; |
637 | #endif | 637 | #endif |
638 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 638 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
639 | // | 639 | // |
640 | QString fileName = "/tmp/kdepimbeamfile"; | 640 | QString fileName = "/tmp/kdepimbeamfile"; |
641 | 641 | ||
642 | 642 | ||
643 | //QDir().mkdir( dirName, true ); | 643 | //QDir().mkdir( dirName, true ); |
644 | 644 | ||
645 | QFile outFile(fileName); | 645 | QFile outFile(fileName); |
646 | KABC::VCardConverter converter; | 646 | KABC::VCardConverter converter; |
647 | QString description; | 647 | QString description; |
648 | 648 | ||
649 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 649 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
650 | 650 | ||
651 | QTextStream t( &outFile ); // use a text stream | 651 | QTextStream t( &outFile ); // use a text stream |
652 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 652 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
653 | 653 | ||
654 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 654 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
655 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 655 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
656 | 656 | ||
657 | if ( a.isEmpty() ) | 657 | if ( a.isEmpty() ) |
658 | continue; | 658 | continue; |
659 | 659 | ||
660 | if (description.isEmpty()) | 660 | if (description.isEmpty()) |
661 | description = a.formattedName(); | 661 | description = a.formattedName(); |
662 | 662 | ||
663 | QString vcard; | 663 | QString vcard; |
664 | converter.addresseeToVCard( a, vcard ); | 664 | converter.addresseeToVCard( a, vcard ); |
665 | t << vcard; | 665 | t << vcard; |
666 | 666 | ||
667 | } | 667 | } |
668 | } else { | 668 | } else { |
669 | qDebug("Error open temp beam file "); | 669 | qDebug("Error open temp beam file "); |
670 | return; | 670 | return; |
671 | } | 671 | } |
672 | 672 | ||
673 | outFile.close(); | 673 | outFile.close(); |
674 | 674 | ||
675 | #ifndef DESKTOP_VERSION | 675 | #ifndef DESKTOP_VERSION |
676 | Ir *ir = new Ir( this ); | 676 | Ir *ir = new Ir( this ); |
677 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 677 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
678 | ir->send( fileName, description, "text/x-vCard" ); | 678 | ir->send( fileName, description, "text/x-vCard" ); |
679 | #endif | 679 | #endif |
680 | 680 | ||
681 | } | 681 | } |
682 | 682 | ||
683 | void KABCore::beamDone( Ir *ir ) | 683 | void KABCore::beamDone( Ir *ir ) |
684 | { | 684 | { |
685 | #ifndef DESKTOP_VERSION | 685 | #ifndef DESKTOP_VERSION |
686 | delete ir; | 686 | delete ir; |
687 | #endif | 687 | #endif |
688 | } | 688 | } |
689 | 689 | ||
690 | 690 | ||
691 | void KABCore::browse( const QString& url ) | 691 | void KABCore::browse( const QString& url ) |
692 | { | 692 | { |
693 | #ifndef KAB_EMBEDDED | 693 | #ifndef KAB_EMBEDDED |
694 | kapp->invokeBrowser( url ); | 694 | kapp->invokeBrowser( url ); |
695 | #else //KAB_EMBEDDED | 695 | #else //KAB_EMBEDDED |
696 | qDebug("KABCore::browse must be fixed"); | 696 | qDebug("KABCore::browse must be fixed"); |
697 | #endif //KAB_EMBEDDED | 697 | #endif //KAB_EMBEDDED |
698 | } | 698 | } |
699 | 699 | ||
700 | void KABCore::selectAllContacts() | 700 | void KABCore::selectAllContacts() |
701 | { | 701 | { |
702 | mViewManager->setSelected( QString::null, true ); | 702 | mViewManager->setSelected( QString::null, true ); |
703 | } | 703 | } |
704 | 704 | ||
705 | void KABCore::deleteContacts() | 705 | void KABCore::deleteContacts() |
706 | { | 706 | { |
707 | QStringList uidList = mViewManager->selectedUids(); | 707 | QStringList uidList = mViewManager->selectedUids(); |
708 | deleteContacts( uidList ); | 708 | deleteContacts( uidList ); |
709 | } | 709 | } |
710 | 710 | ||
711 | void KABCore::deleteContacts( const QStringList &uids ) | 711 | void KABCore::deleteContacts( const QStringList &uids ) |
712 | { | 712 | { |
713 | if ( uids.count() > 0 ) { | 713 | if ( uids.count() > 0 ) { |
714 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 714 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
715 | UndoStack::instance()->push( command ); | 715 | UndoStack::instance()->push( command ); |
716 | RedoStack::instance()->clear(); | 716 | RedoStack::instance()->clear(); |
717 | 717 | ||
718 | // now if we deleted anything, refresh | 718 | // now if we deleted anything, refresh |
719 | setContactSelected( QString::null ); | 719 | setContactSelected( QString::null ); |
720 | setModified( true ); | 720 | setModified( true ); |
721 | } | 721 | } |
722 | } | 722 | } |
723 | 723 | ||
724 | void KABCore::copyContacts() | 724 | void KABCore::copyContacts() |
725 | { | 725 | { |
726 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 726 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
727 | 727 | ||
728 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 728 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
729 | 729 | ||
730 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 730 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
731 | 731 | ||
732 | QClipboard *cb = QApplication::clipboard(); | 732 | QClipboard *cb = QApplication::clipboard(); |
733 | cb->setText( clipText ); | 733 | cb->setText( clipText ); |
734 | } | 734 | } |
735 | 735 | ||
736 | void KABCore::cutContacts() | 736 | void KABCore::cutContacts() |
737 | { | 737 | { |
738 | QStringList uidList = mViewManager->selectedUids(); | 738 | QStringList uidList = mViewManager->selectedUids(); |
739 | 739 | ||
740 | //US if ( uidList.size() > 0 ) { | 740 | //US if ( uidList.size() > 0 ) { |
741 | if ( uidList.count() > 0 ) { | 741 | if ( uidList.count() > 0 ) { |
742 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 742 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
743 | UndoStack::instance()->push( command ); | 743 | UndoStack::instance()->push( command ); |
744 | RedoStack::instance()->clear(); | 744 | RedoStack::instance()->clear(); |
745 | 745 | ||
746 | setModified( true ); | 746 | setModified( true ); |
747 | } | 747 | } |
748 | } | 748 | } |
749 | 749 | ||
750 | void KABCore::pasteContacts() | 750 | void KABCore::pasteContacts() |
751 | { | 751 | { |
752 | QClipboard *cb = QApplication::clipboard(); | 752 | QClipboard *cb = QApplication::clipboard(); |
753 | 753 | ||
754 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 754 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
755 | 755 | ||
756 | pasteContacts( list ); | 756 | pasteContacts( list ); |
757 | } | 757 | } |
758 | 758 | ||
759 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 759 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
760 | { | 760 | { |
761 | KABC::Resource *resource = requestResource( this ); | 761 | KABC::Resource *resource = requestResource( this ); |
762 | KABC::Addressee::List::Iterator it; | 762 | KABC::Addressee::List::Iterator it; |
763 | for ( it = list.begin(); it != list.end(); ++it ) | 763 | for ( it = list.begin(); it != list.end(); ++it ) |
764 | (*it).setResource( resource ); | 764 | (*it).setResource( resource ); |
765 | 765 | ||
766 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 766 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
767 | UndoStack::instance()->push( command ); | 767 | UndoStack::instance()->push( command ); |
768 | RedoStack::instance()->clear(); | 768 | RedoStack::instance()->clear(); |
769 | 769 | ||
770 | setModified( true ); | 770 | setModified( true ); |
771 | } | 771 | } |
772 | 772 | ||
773 | void KABCore::setWhoAmI() | 773 | void KABCore::setWhoAmI() |
774 | { | 774 | { |
775 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 775 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
776 | 776 | ||
777 | if ( addrList.count() > 1 ) { | 777 | if ( addrList.count() > 1 ) { |
778 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 778 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
779 | return; | 779 | return; |
780 | } | 780 | } |
781 | 781 | ||
782 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 782 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
783 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 783 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
784 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 784 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
785 | } | 785 | } |
786 | 786 | ||
787 | void KABCore::setCategories() | 787 | void KABCore::setCategories() |
788 | { | 788 | { |
789 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 789 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
790 | if ( !dlg.exec() ) | 790 | if ( !dlg.exec() ) |
791 | return; | 791 | return; |
792 | 792 | ||
793 | bool merge = false; | 793 | bool merge = false; |
794 | QString msg = i18n( "Merge with existing categories?" ); | 794 | QString msg = i18n( "Merge with existing categories?" ); |
795 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 795 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
796 | merge = true; | 796 | merge = true; |
797 | 797 | ||
798 | QStringList categories = dlg.selectedCategories(); | 798 | QStringList categories = dlg.selectedCategories(); |
799 | 799 | ||
800 | QStringList uids = mViewManager->selectedUids(); | 800 | QStringList uids = mViewManager->selectedUids(); |
801 | QStringList::Iterator it; | 801 | QStringList::Iterator it; |
802 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 802 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
803 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 803 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
804 | if ( !addr.isEmpty() ) { | 804 | if ( !addr.isEmpty() ) { |
805 | if ( !merge ) | 805 | if ( !merge ) |
806 | addr.setCategories( categories ); | 806 | addr.setCategories( categories ); |
807 | else { | 807 | else { |
808 | QStringList addrCategories = addr.categories(); | 808 | QStringList addrCategories = addr.categories(); |
809 | QStringList::Iterator catIt; | 809 | QStringList::Iterator catIt; |
810 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 810 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
811 | if ( !addrCategories.contains( *catIt ) ) | 811 | if ( !addrCategories.contains( *catIt ) ) |
812 | addrCategories.append( *catIt ); | 812 | addrCategories.append( *catIt ); |
813 | } | 813 | } |
814 | addr.setCategories( addrCategories ); | 814 | addr.setCategories( addrCategories ); |
815 | } | 815 | } |
816 | 816 | ||
817 | mAddressBook->insertAddressee( addr ); | 817 | mAddressBook->insertAddressee( addr ); |
818 | } | 818 | } |
819 | } | 819 | } |
820 | 820 | ||
821 | if ( uids.count() > 0 ) | 821 | if ( uids.count() > 0 ) |
822 | setModified( true ); | 822 | setModified( true ); |
823 | } | 823 | } |
824 | 824 | ||
825 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 825 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
826 | { | 826 | { |
827 | mIncSearchWidget->setFields( fields ); | 827 | mIncSearchWidget->setFields( fields ); |
828 | } | 828 | } |
829 | 829 | ||
830 | void KABCore::incrementalSearch( const QString& text ) | 830 | void KABCore::incrementalSearch( const QString& text ) |
831 | { | 831 | { |
832 | mViewManager->setSelected( QString::null, false ); | 832 | mViewManager->setSelected( QString::null, false ); |
833 | 833 | ||
834 | if ( !text.isEmpty() ) { | 834 | if ( !text.isEmpty() ) { |
835 | KABC::Field *field = mIncSearchWidget->currentField(); | 835 | KABC::Field *field = mIncSearchWidget->currentField(); |
836 | 836 | ||
837 | QString pattern = text.lower(); | 837 | QString pattern = text.lower(); |
838 | 838 | ||
839 | #if 1 //KDE_VERSION >= 319 | 839 | #if 1 //KDE_VERSION >= 319 |
840 | KABC::AddresseeList list( mAddressBook->allAddressees() ); | 840 | KABC::AddresseeList list( mAddressBook->allAddressees() ); |
841 | if ( field ) { | 841 | if ( field ) { |
842 | list.sortByField( field ); | 842 | list.sortByField( field ); |
843 | KABC::AddresseeList::Iterator it; | 843 | KABC::AddresseeList::Iterator it; |
844 | for ( it = list.begin(); it != list.end(); ++it ) { | 844 | for ( it = list.begin(); it != list.end(); ++it ) { |
845 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 845 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
846 | mViewManager->setSelected( (*it).uid(), true ); | 846 | mViewManager->setSelected( (*it).uid(), true ); |
847 | return; | 847 | return; |
848 | } | 848 | } |
849 | } | 849 | } |
850 | } else { | 850 | } else { |
851 | KABC::AddresseeList::Iterator it; | 851 | KABC::AddresseeList::Iterator it; |
852 | for ( it = list.begin(); it != list.end(); ++it ) { | 852 | for ( it = list.begin(); it != list.end(); ++it ) { |
853 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 853 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
854 | KABC::Field::List::ConstIterator fieldIt; | 854 | KABC::Field::List::ConstIterator fieldIt; |
855 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 855 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
856 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | 856 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { |
857 | mViewManager->setSelected( (*it).uid(), true ); | 857 | mViewManager->setSelected( (*it).uid(), true ); |
858 | return; | 858 | return; |
859 | } | 859 | } |
860 | } | 860 | } |
861 | } | 861 | } |
862 | } | 862 | } |
863 | #else | 863 | #else |
864 | KABC::AddressBook::Iterator it; | 864 | KABC::AddressBook::Iterator it; |
865 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 865 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
866 | if ( field ) { | 866 | if ( field ) { |
867 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 867 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
868 | mViewManager->setSelected( (*it).uid(), true ); | 868 | mViewManager->setSelected( (*it).uid(), true ); |
869 | return; | 869 | return; |
870 | } | 870 | } |
871 | } else { | 871 | } else { |
872 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 872 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
873 | KABC::Field::List::ConstIterator fieldIt; | 873 | KABC::Field::List::ConstIterator fieldIt; |
874 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 874 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
875 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | 875 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { |
876 | mViewManager->setSelected( (*it).uid(), true ); | 876 | mViewManager->setSelected( (*it).uid(), true ); |
877 | return; | 877 | return; |
878 | } | 878 | } |
879 | } | 879 | } |
880 | } | 880 | } |
881 | } | 881 | } |
882 | #endif | 882 | #endif |
883 | } | 883 | } |
884 | } | 884 | } |
885 | 885 | ||
886 | void KABCore::setModified() | 886 | void KABCore::setModified() |
887 | { | 887 | { |
888 | setModified( true ); | 888 | setModified( true ); |
889 | } | 889 | } |
890 | 890 | ||
891 | void KABCore::setModifiedWOrefresh() | 891 | void KABCore::setModifiedWOrefresh() |
892 | { | 892 | { |
893 | // qDebug("KABCore::setModifiedWOrefresh() "); | 893 | // qDebug("KABCore::setModifiedWOrefresh() "); |
894 | mModified = true; | 894 | mModified = true; |
895 | mActionSave->setEnabled( mModified ); | 895 | mActionSave->setEnabled( mModified ); |
896 | #ifdef DESKTOP_VERSION | 896 | #ifdef DESKTOP_VERSION |
897 | mDetails->refreshView(); | 897 | mDetails->refreshView(); |
898 | #endif | 898 | #endif |
899 | 899 | ||
900 | } | 900 | } |
901 | void KABCore::setModified( bool modified ) | 901 | void KABCore::setModified( bool modified ) |
902 | { | 902 | { |
903 | mModified = modified; | 903 | mModified = modified; |
904 | mActionSave->setEnabled( mModified ); | 904 | mActionSave->setEnabled( mModified ); |
905 | 905 | ||
906 | if ( modified ) | 906 | if ( modified ) |
907 | mJumpButtonBar->recreateButtons(); | 907 | mJumpButtonBar->recreateButtons(); |
908 | 908 | ||
909 | mViewManager->refreshView(); | 909 | mViewManager->refreshView(); |
910 | mDetails->refreshView(); | 910 | mDetails->refreshView(); |
911 | 911 | ||
912 | } | 912 | } |
913 | 913 | ||
914 | bool KABCore::modified() const | 914 | bool KABCore::modified() const |
915 | { | 915 | { |
916 | return mModified; | 916 | return mModified; |
917 | } | 917 | } |
918 | 918 | ||
919 | void KABCore::contactModified( const KABC::Addressee &addr ) | 919 | void KABCore::contactModified( const KABC::Addressee &addr ) |
920 | { | 920 | { |
921 | 921 | ||
922 | Command *command = 0; | 922 | Command *command = 0; |
923 | QString uid; | 923 | QString uid; |
924 | 924 | ||
925 | // check if it exists already | 925 | // check if it exists already |
926 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 926 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
927 | if ( origAddr.isEmpty() ) | 927 | if ( origAddr.isEmpty() ) |
928 | command = new PwNewCommand( mAddressBook, addr ); | 928 | command = new PwNewCommand( mAddressBook, addr ); |
929 | else { | 929 | else { |
930 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 930 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
931 | uid = addr.uid(); | 931 | uid = addr.uid(); |
932 | } | 932 | } |
933 | 933 | ||
934 | UndoStack::instance()->push( command ); | 934 | UndoStack::instance()->push( command ); |
935 | RedoStack::instance()->clear(); | 935 | RedoStack::instance()->clear(); |
936 | 936 | ||
937 | setModified( true ); | 937 | setModified( true ); |
938 | } | 938 | } |
939 | 939 | ||
940 | void KABCore::newContact() | 940 | void KABCore::newContact() |
941 | { | 941 | { |
942 | 942 | ||
943 | 943 | ||
944 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 944 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
945 | 945 | ||
946 | QPtrList<KRES::Resource> kresResources; | 946 | QPtrList<KRES::Resource> kresResources; |
947 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 947 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
948 | KABC::Resource *resource; | 948 | KABC::Resource *resource; |
949 | while ( ( resource = it.current() ) != 0 ) { | 949 | while ( ( resource = it.current() ) != 0 ) { |
950 | ++it; | 950 | ++it; |
951 | if ( !resource->readOnly() ) { | 951 | if ( !resource->readOnly() ) { |
952 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 952 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
953 | if ( res ) | 953 | if ( res ) |
954 | kresResources.append( res ); | 954 | kresResources.append( res ); |
955 | } | 955 | } |
956 | } | 956 | } |
957 | 957 | ||
958 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 958 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
959 | resource = static_cast<KABC::Resource*>( res ); | 959 | resource = static_cast<KABC::Resource*>( res ); |
960 | 960 | ||
961 | if ( resource ) { | 961 | if ( resource ) { |
962 | KABC::Addressee addr; | 962 | KABC::Addressee addr; |
963 | addr.setResource( resource ); | 963 | addr.setResource( resource ); |
964 | mEditorDialog->setAddressee( addr ); | 964 | mEditorDialog->setAddressee( addr ); |
965 | KApplication::execDialog ( mEditorDialog ); | 965 | KApplication::execDialog ( mEditorDialog ); |
966 | 966 | ||
967 | } else | 967 | } else |
968 | return; | 968 | return; |
969 | 969 | ||
970 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 970 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
971 | 971 | ||
972 | 972 | ||
973 | } | 973 | } |
974 | 974 | ||
975 | void KABCore::addEmail( QString aStr ) | 975 | void KABCore::addEmail( QString aStr ) |
976 | { | 976 | { |
977 | #ifndef KAB_EMBEDDED | 977 | #ifndef KAB_EMBEDDED |
978 | QString fullName, email; | 978 | QString fullName, email; |
979 | 979 | ||
980 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 980 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
981 | 981 | ||
982 | // Try to lookup the addressee matching the email address | 982 | // Try to lookup the addressee matching the email address |
983 | bool found = false; | 983 | bool found = false; |
984 | QStringList emailList; | 984 | QStringList emailList; |
985 | KABC::AddressBook::Iterator it; | 985 | KABC::AddressBook::Iterator it; |
986 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 986 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
987 | emailList = (*it).emails(); | 987 | emailList = (*it).emails(); |
988 | if ( emailList.contains( email ) > 0 ) { | 988 | if ( emailList.contains( email ) > 0 ) { |
989 | found = true; | 989 | found = true; |
990 | (*it).setNameFromString( fullName ); | 990 | (*it).setNameFromString( fullName ); |
991 | editContact( (*it).uid() ); | 991 | editContact( (*it).uid() ); |
992 | } | 992 | } |
993 | } | 993 | } |
994 | 994 | ||
995 | if ( !found ) { | 995 | if ( !found ) { |
996 | KABC::Addressee addr; | 996 | KABC::Addressee addr; |
997 | addr.setNameFromString( fullName ); | 997 | addr.setNameFromString( fullName ); |
998 | addr.insertEmail( email, true ); | 998 | addr.insertEmail( email, true ); |
999 | 999 | ||
1000 | mAddressBook->insertAddressee( addr ); | 1000 | mAddressBook->insertAddressee( addr ); |
1001 | mViewManager->refreshView( addr.uid() ); | 1001 | mViewManager->refreshView( addr.uid() ); |
1002 | editContact( addr.uid() ); | 1002 | editContact( addr.uid() ); |
1003 | } | 1003 | } |
1004 | #else //KAB_EMBEDDED | 1004 | #else //KAB_EMBEDDED |
1005 | qDebug("KABCore::addEmail finsih method"); | 1005 | qDebug("KABCore::addEmail finsih method"); |
1006 | #endif //KAB_EMBEDDED | 1006 | #endif //KAB_EMBEDDED |
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1009 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1010 | { | 1010 | { |
1011 | mXXPortManager->importVCard( url, showPreview ); | 1011 | mXXPortManager->importVCard( url, showPreview ); |
1012 | } | 1012 | } |
1013 | void KABCore::importFromOL() | 1013 | void KABCore::importFromOL() |
1014 | { | 1014 | { |
1015 | #ifdef _WIN32_ | 1015 | #ifdef _WIN32_ |
1016 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1016 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1017 | idgl->exec(); | 1017 | idgl->exec(); |
1018 | KABC::Addressee::List list = idgl->getAddressList(); | 1018 | KABC::Addressee::List list = idgl->getAddressList(); |
1019 | if ( list.count() > 0 ) { | 1019 | if ( list.count() > 0 ) { |
1020 | KABC::Addressee::List listNew; | 1020 | KABC::Addressee::List listNew; |
1021 | KABC::Addressee::List listExisting; | 1021 | KABC::Addressee::List listExisting; |
1022 | KABC::Addressee::List::Iterator it; | 1022 | KABC::Addressee::List::Iterator it; |
1023 | KABC::AddressBook::Iterator iter; | 1023 | KABC::AddressBook::Iterator iter; |
1024 | for ( it = list.begin(); it != list.end(); ++it ) { | 1024 | for ( it = list.begin(); it != list.end(); ++it ) { |
1025 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1025 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1026 | listNew.append( (*it) ); | 1026 | listNew.append( (*it) ); |
1027 | else | 1027 | else |
1028 | listExisting.append( (*it) ); | 1028 | listExisting.append( (*it) ); |
1029 | } | 1029 | } |
1030 | if ( listExisting.count() > 0 ) | 1030 | if ( listExisting.count() > 0 ) |
1031 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1031 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1032 | if ( listNew.count() > 0 ) { | 1032 | if ( listNew.count() > 0 ) { |
1033 | pasteWithNewUid = false; | 1033 | pasteWithNewUid = false; |
1034 | pasteContacts( listNew ); | 1034 | pasteContacts( listNew ); |
1035 | pasteWithNewUid = true; | 1035 | pasteWithNewUid = true; |
1036 | } | 1036 | } |
1037 | } | 1037 | } |
1038 | delete idgl; | 1038 | delete idgl; |
1039 | #endif | 1039 | #endif |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1042 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1043 | { | 1043 | { |
1044 | mXXPortManager->importVCard( vCard, showPreview ); | 1044 | mXXPortManager->importVCard( vCard, showPreview ); |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | //US added a second method without defaultparameter | 1047 | //US added a second method without defaultparameter |
1048 | void KABCore::editContact2() { | 1048 | void KABCore::editContact2() { |
1049 | editContact( QString::null ); | 1049 | editContact( QString::null ); |
1050 | } | 1050 | } |
1051 | 1051 | ||
1052 | void KABCore::editContact( const QString &uid ) | 1052 | void KABCore::editContact( const QString &uid ) |
1053 | { | 1053 | { |
1054 | 1054 | ||
1055 | if ( mExtensionManager->isQuickEditVisible() ) | 1055 | if ( mExtensionManager->isQuickEditVisible() ) |
1056 | return; | 1056 | return; |
1057 | 1057 | ||
1058 | // First, locate the contact entry | 1058 | // First, locate the contact entry |
1059 | QString localUID = uid; | 1059 | QString localUID = uid; |
1060 | if ( localUID.isNull() ) { | 1060 | if ( localUID.isNull() ) { |
1061 | QStringList uidList = mViewManager->selectedUids(); | 1061 | QStringList uidList = mViewManager->selectedUids(); |
1062 | if ( uidList.count() > 0 ) | 1062 | if ( uidList.count() > 0 ) |
1063 | localUID = *( uidList.at( 0 ) ); | 1063 | localUID = *( uidList.at( 0 ) ); |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1066 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1067 | if ( !addr.isEmpty() ) { | 1067 | if ( !addr.isEmpty() ) { |
1068 | mEditorDialog->setAddressee( addr ); | 1068 | mEditorDialog->setAddressee( addr ); |
1069 | KApplication::execDialog ( mEditorDialog ); | 1069 | KApplication::execDialog ( mEditorDialog ); |
1070 | } | 1070 | } |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | /** | 1073 | /** |
1074 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1074 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1075 | the method will try to find a selected addressee in the view. | 1075 | the method will try to find a selected addressee in the view. |
1076 | */ | 1076 | */ |
1077 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1077 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1078 | { | 1078 | { |
1079 | if ( mMultipleViewsAtOnce ) | 1079 | if ( mMultipleViewsAtOnce ) |
1080 | { | 1080 | { |
1081 | editContact( uid ); | 1081 | editContact( uid ); |
1082 | } | 1082 | } |
1083 | else | 1083 | else |
1084 | { | 1084 | { |
1085 | setDetailsVisible( true ); | 1085 | setDetailsVisible( true ); |
1086 | mActionDetails->setChecked(true); | 1086 | mActionDetails->setChecked(true); |
1087 | } | 1087 | } |
1088 | 1088 | ||
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | void KABCore::save() | 1091 | void KABCore::save() |
1092 | { | 1092 | { |
1093 | if ( !mModified ) | 1093 | if ( !mModified ) |
1094 | return; | 1094 | return; |
1095 | QString text = i18n( "There was an error while attempting to save\n the " | 1095 | QString text = i18n( "There was an error while attempting to save\n the " |
1096 | "address book. Please check that some \nother application is " | 1096 | "address book. Please check that some \nother application is " |
1097 | "not using it. " ); | 1097 | "not using it. " ); |
1098 | statusMessage(i18n("Saving addressbook ... ")); | 1098 | statusMessage(i18n("Saving addressbook ... ")); |
1099 | #ifndef KAB_EMBEDDED | 1099 | #ifndef KAB_EMBEDDED |
1100 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1100 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1101 | if ( !b || !b->save() ) { | 1101 | if ( !b || !b->save() ) { |
1102 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1102 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1103 | } | 1103 | } |
1104 | #else //KAB_EMBEDDED | 1104 | #else //KAB_EMBEDDED |
1105 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1105 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1106 | if ( !b || !b->save() ) { | 1106 | if ( !b || !b->save() ) { |
1107 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1107 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1108 | } | 1108 | } |
1109 | #endif //KAB_EMBEDDED | 1109 | #endif //KAB_EMBEDDED |
1110 | 1110 | ||
1111 | statusMessage(i18n("Addressbook saved!")); | 1111 | statusMessage(i18n("Addressbook saved!")); |
1112 | setModified( false ); | 1112 | setModified( false ); |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | void KABCore::statusMessage(QString mess , int time ) | 1115 | void KABCore::statusMessage(QString mess , int time ) |
1116 | { | 1116 | { |
1117 | //topLevelWidget()->setCaption( mess ); | 1117 | //topLevelWidget()->setCaption( mess ); |
1118 | // pending setting timer to revome message | 1118 | // pending setting timer to revome message |
1119 | } | 1119 | } |
1120 | void KABCore::undo() | 1120 | void KABCore::undo() |
1121 | { | 1121 | { |
1122 | UndoStack::instance()->undo(); | 1122 | UndoStack::instance()->undo(); |
1123 | 1123 | ||
1124 | // Refresh the view | 1124 | // Refresh the view |
1125 | mViewManager->refreshView(); | 1125 | mViewManager->refreshView(); |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | void KABCore::redo() | 1128 | void KABCore::redo() |
1129 | { | 1129 | { |
1130 | RedoStack::instance()->redo(); | 1130 | RedoStack::instance()->redo(); |
1131 | 1131 | ||
1132 | // Refresh the view | 1132 | // Refresh the view |
1133 | mViewManager->refreshView(); | 1133 | mViewManager->refreshView(); |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1136 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1137 | { | 1137 | { |
1138 | if (mMultipleViewsAtOnce) | 1138 | if (mMultipleViewsAtOnce) |
1139 | { | 1139 | { |
1140 | if ( visible ) | 1140 | if ( visible ) |
1141 | mJumpButtonBar->show(); | 1141 | mJumpButtonBar->show(); |
1142 | else | 1142 | else |
1143 | mJumpButtonBar->hide(); | 1143 | mJumpButtonBar->hide(); |
1144 | } | 1144 | } |
1145 | else | 1145 | else |
1146 | { | 1146 | { |
1147 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1147 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1148 | if (mViewManager->isVisible()) | 1148 | if (mViewManager->isVisible()) |
1149 | { | 1149 | { |
1150 | if ( visible ) | 1150 | if ( visible ) |
1151 | mJumpButtonBar->show(); | 1151 | mJumpButtonBar->show(); |
1152 | else | 1152 | else |
1153 | mJumpButtonBar->hide(); | 1153 | mJumpButtonBar->hide(); |
1154 | } | 1154 | } |
1155 | else | 1155 | else |
1156 | { | 1156 | { |
1157 | mJumpButtonBar->hide(); | 1157 | mJumpButtonBar->hide(); |
1158 | } | 1158 | } |
1159 | } | 1159 | } |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | 1162 | ||
1163 | void KABCore::setDetailsToState() | 1163 | void KABCore::setDetailsToState() |
1164 | { | 1164 | { |
1165 | setDetailsVisible( mActionDetails->isChecked() ); | 1165 | setDetailsVisible( mActionDetails->isChecked() ); |
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | 1168 | ||
1169 | 1169 | ||
1170 | void KABCore::setDetailsVisible( bool visible ) | 1170 | void KABCore::setDetailsVisible( bool visible ) |
1171 | { | 1171 | { |
1172 | if (visible && mDetails->isHidden()) | 1172 | if (visible && mDetails->isHidden()) |
1173 | { | 1173 | { |
1174 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1174 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1175 | if ( addrList.count() > 0 ) | 1175 | if ( addrList.count() > 0 ) |
1176 | mDetails->setAddressee( addrList[ 0 ] ); | 1176 | mDetails->setAddressee( addrList[ 0 ] ); |
1177 | } | 1177 | } |
1178 | 1178 | ||
1179 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1179 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1180 | // the listview and the detailview. We do that by changing the splitbar size. | 1180 | // the listview and the detailview. We do that by changing the splitbar size. |
1181 | if (mMultipleViewsAtOnce) | 1181 | if (mMultipleViewsAtOnce) |
1182 | { | 1182 | { |
1183 | if ( visible ) | 1183 | if ( visible ) |
1184 | mDetails->show(); | 1184 | mDetails->show(); |
1185 | else | 1185 | else |
1186 | mDetails->hide(); | 1186 | mDetails->hide(); |
1187 | } | 1187 | } |
1188 | else | 1188 | else |
1189 | { | 1189 | { |
1190 | if ( visible ) { | 1190 | if ( visible ) { |
1191 | mViewManager->hide(); | 1191 | mViewManager->hide(); |
1192 | mDetails->show(); | 1192 | mDetails->show(); |
1193 | } | 1193 | } |
1194 | else { | 1194 | else { |
1195 | mViewManager->show(); | 1195 | mViewManager->show(); |
1196 | mDetails->hide(); | 1196 | mDetails->hide(); |
1197 | } | 1197 | } |
1198 | setJumpButtonBarVisible( !visible ); | 1198 | setJumpButtonBarVisible( !visible ); |
1199 | } | 1199 | } |
1200 | 1200 | ||
1201 | } | 1201 | } |
1202 | 1202 | ||
1203 | void KABCore::extensionChanged( int id ) | 1203 | void KABCore::extensionChanged( int id ) |
1204 | { | 1204 | { |
1205 | //change the details view only for non desktop systems | 1205 | //change the details view only for non desktop systems |
1206 | #ifndef DESKTOP_VERSION | 1206 | #ifndef DESKTOP_VERSION |
1207 | 1207 | ||
1208 | if (id == 0) | 1208 | if (id == 0) |
1209 | { | 1209 | { |
1210 | //the user disabled the extension. | 1210 | //the user disabled the extension. |
1211 | 1211 | ||
1212 | if (mMultipleViewsAtOnce) | 1212 | if (mMultipleViewsAtOnce) |
1213 | { // enable detailsview again | 1213 | { // enable detailsview again |
1214 | setDetailsVisible( true ); | 1214 | setDetailsVisible( true ); |
1215 | mActionDetails->setChecked( true ); | 1215 | mActionDetails->setChecked( true ); |
1216 | } | 1216 | } |
1217 | else | 1217 | else |
1218 | { //go back to the listview | 1218 | { //go back to the listview |
1219 | setDetailsVisible( false ); | 1219 | setDetailsVisible( false ); |
1220 | mActionDetails->setChecked( false ); | 1220 | mActionDetails->setChecked( false ); |
1221 | mActionDetails->setEnabled(true); | 1221 | mActionDetails->setEnabled(true); |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | } | 1224 | } |
1225 | else | 1225 | else |
1226 | { | 1226 | { |
1227 | //the user enabled the extension. | 1227 | //the user enabled the extension. |
1228 | setDetailsVisible( false ); | 1228 | setDetailsVisible( false ); |
1229 | mActionDetails->setChecked( false ); | 1229 | mActionDetails->setChecked( false ); |
1230 | 1230 | ||
1231 | if (!mMultipleViewsAtOnce) | 1231 | if (!mMultipleViewsAtOnce) |
1232 | { | 1232 | { |
1233 | mActionDetails->setEnabled(false); | 1233 | mActionDetails->setEnabled(false); |
1234 | } | 1234 | } |
1235 | 1235 | ||
1236 | mExtensionManager->setSelectionChanged(); | 1236 | mExtensionManager->setSelectionChanged(); |
1237 | 1237 | ||
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | #endif// DESKTOP_VERSION | 1240 | #endif// DESKTOP_VERSION |
1241 | 1241 | ||
1242 | } | 1242 | } |
1243 | 1243 | ||
1244 | 1244 | ||
1245 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1245 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1246 | { | 1246 | { |
1247 | 1247 | ||
1248 | if ( list.count() != 0 ) { | 1248 | if ( list.count() != 0 ) { |
1249 | KABC::Addressee::List::ConstIterator it; | 1249 | KABC::Addressee::List::ConstIterator it; |
1250 | for ( it = list.begin(); it != list.end(); ++it ) | 1250 | for ( it = list.begin(); it != list.end(); ++it ) |
1251 | mAddressBook->insertAddressee( *it ); | 1251 | mAddressBook->insertAddressee( *it ); |
1252 | if ( list.count() > 1 ) | 1252 | if ( list.count() > 1 ) |
1253 | setModified(); | 1253 | setModified(); |
1254 | else | 1254 | else |
1255 | setModifiedWOrefresh(); | 1255 | setModifiedWOrefresh(); |
1256 | } | 1256 | } |
1257 | if ( list.count() == 0 ) | 1257 | if ( list.count() == 0 ) |
1258 | mViewManager->refreshView(); | 1258 | mViewManager->refreshView(); |
1259 | else | 1259 | else |
1260 | mViewManager->refreshView( list[ 0 ].uid() ); | 1260 | mViewManager->refreshView( list[ 0 ].uid() ); |
1261 | 1261 | ||
1262 | 1262 | ||
1263 | 1263 | ||
1264 | } | 1264 | } |
1265 | 1265 | ||
1266 | QString KABCore::getNameByPhone( const QString &phone ) | 1266 | QString KABCore::getNameByPhone( const QString &phone ) |
1267 | { | 1267 | { |
1268 | #ifndef KAB_EMBEDDED | 1268 | #ifndef KAB_EMBEDDED |
1269 | QRegExp r( "[/*/-/ ]" ); | 1269 | QRegExp r( "[/*/-/ ]" ); |
1270 | QString localPhone( phone ); | 1270 | QString localPhone( phone ); |
1271 | 1271 | ||
1272 | bool found = false; | 1272 | bool found = false; |
1273 | QString ownerName = ""; | 1273 | QString ownerName = ""; |
1274 | KABC::AddressBook::Iterator iter; | 1274 | KABC::AddressBook::Iterator iter; |
1275 | KABC::PhoneNumber::List::Iterator phoneIter; | 1275 | KABC::PhoneNumber::List::Iterator phoneIter; |
1276 | KABC::PhoneNumber::List phoneList; | 1276 | KABC::PhoneNumber::List phoneList; |
1277 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1277 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1278 | phoneList = (*iter).phoneNumbers(); | 1278 | phoneList = (*iter).phoneNumbers(); |
1279 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1279 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1280 | ++phoneIter) { | 1280 | ++phoneIter) { |
1281 | // Get rid of separator chars so just the numbers are compared. | 1281 | // Get rid of separator chars so just the numbers are compared. |
1282 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1282 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1283 | ownerName = (*iter).formattedName(); | 1283 | ownerName = (*iter).formattedName(); |
1284 | found = true; | 1284 | found = true; |
1285 | } | 1285 | } |
1286 | } | 1286 | } |
1287 | } | 1287 | } |
1288 | 1288 | ||
1289 | return ownerName; | 1289 | return ownerName; |
1290 | #else //KAB_EMBEDDED | 1290 | #else //KAB_EMBEDDED |
1291 | qDebug("KABCore::getNameByPhone finsih method"); | 1291 | qDebug("KABCore::getNameByPhone finsih method"); |
1292 | return ""; | 1292 | return ""; |
1293 | #endif //KAB_EMBEDDED | 1293 | #endif //KAB_EMBEDDED |
1294 | 1294 | ||
1295 | } | 1295 | } |
1296 | 1296 | ||
1297 | void KABCore::openConfigDialog() | 1297 | void KABCore::openConfigDialog() |
1298 | { | 1298 | { |
1299 | KABPrefs* kab_prefs = KABPrefs::instance(); | 1299 | KABPrefs* kab_prefs = KABPrefs::instance(); |
1300 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); | 1300 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); |
1301 | 1301 | ||
1302 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1302 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1303 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1303 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1304 | ConfigureDialog->addModule(kabcfg ); | 1304 | ConfigureDialog->addModule(kabcfg ); |
1305 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1305 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1306 | ConfigureDialog->addModule(kdelibcfg ); | 1306 | ConfigureDialog->addModule(kdelibcfg ); |
1307 | 1307 | ||
1308 | 1308 | ||
1309 | 1309 | ||
1310 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1310 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1311 | this, SLOT( configurationChanged() ) ); | 1311 | this, SLOT( configurationChanged() ) ); |
1312 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1312 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1313 | this, SLOT( configurationChanged() ) ); | 1313 | this, SLOT( configurationChanged() ) ); |
1314 | saveSettings(); | 1314 | saveSettings(); |
1315 | #ifndef DESKTOP_VERSION | ||
1315 | ConfigureDialog->showMaximized(); | 1316 | ConfigureDialog->showMaximized(); |
1317 | #endif | ||
1316 | if ( ConfigureDialog->exec() ) | 1318 | if ( ConfigureDialog->exec() ) |
1317 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1319 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1318 | delete ConfigureDialog; | 1320 | delete ConfigureDialog; |
1319 | } | 1321 | } |
1320 | 1322 | ||
1321 | void KABCore::openLDAPDialog() | 1323 | void KABCore::openLDAPDialog() |
1322 | { | 1324 | { |
1323 | #ifndef KAB_EMBEDDED | 1325 | #ifndef KAB_EMBEDDED |
1324 | if ( !mLdapSearchDialog ) { | 1326 | if ( !mLdapSearchDialog ) { |
1325 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1327 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1326 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1328 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1327 | SLOT( refreshView() ) ); | 1329 | SLOT( refreshView() ) ); |
1328 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1330 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1329 | SLOT( setModified() ) ); | 1331 | SLOT( setModified() ) ); |
1330 | } else | 1332 | } else |
1331 | mLdapSearchDialog->restoreSettings(); | 1333 | mLdapSearchDialog->restoreSettings(); |
1332 | 1334 | ||
1333 | if ( mLdapSearchDialog->isOK() ) | 1335 | if ( mLdapSearchDialog->isOK() ) |
1334 | mLdapSearchDialog->exec(); | 1336 | mLdapSearchDialog->exec(); |
1335 | #else //KAB_EMBEDDED | 1337 | #else //KAB_EMBEDDED |
1336 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1338 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1337 | #endif //KAB_EMBEDDED | 1339 | #endif //KAB_EMBEDDED |
1338 | } | 1340 | } |
1339 | 1341 | ||
1340 | void KABCore::print() | 1342 | void KABCore::print() |
1341 | { | 1343 | { |
1342 | #ifndef KAB_EMBEDDED | 1344 | #ifndef KAB_EMBEDDED |
1343 | KPrinter printer; | 1345 | KPrinter printer; |
1344 | if ( !printer.setup( this ) ) | 1346 | if ( !printer.setup( this ) ) |
1345 | return; | 1347 | return; |
1346 | 1348 | ||
1347 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1349 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1348 | mViewManager->selectedUids(), this ); | 1350 | mViewManager->selectedUids(), this ); |
1349 | 1351 | ||
1350 | wizard.exec(); | 1352 | wizard.exec(); |
1351 | #else //KAB_EMBEDDED | 1353 | #else //KAB_EMBEDDED |
1352 | qDebug("KABCore::print() finsih method"); | 1354 | qDebug("KABCore::print() finsih method"); |
1353 | #endif //KAB_EMBEDDED | 1355 | #endif //KAB_EMBEDDED |
1354 | 1356 | ||
1355 | } | 1357 | } |
1356 | 1358 | ||
1357 | 1359 | ||
1358 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1360 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1359 | { | 1361 | { |
1360 | if ( mGUIClient ) | 1362 | if ( mGUIClient ) |
1361 | mGUIClient->insertChildClient( client ); | 1363 | mGUIClient->insertChildClient( client ); |
1362 | else | 1364 | else |
1363 | KMessageBox::error( this, "no KXMLGUICLient"); | 1365 | KMessageBox::error( this, "no KXMLGUICLient"); |
1364 | } | 1366 | } |
1365 | 1367 | ||
1366 | 1368 | ||
1367 | void KABCore::configurationChanged() | 1369 | void KABCore::configurationChanged() |
1368 | { | 1370 | { |
1369 | mExtensionManager->reconfigure(); | 1371 | mExtensionManager->reconfigure(); |
1370 | } | 1372 | } |
1371 | 1373 | ||
1372 | void KABCore::addressBookChanged() | 1374 | void KABCore::addressBookChanged() |
1373 | { | 1375 | { |
1374 | /*US | 1376 | /*US |
1375 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1377 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1376 | while ( it.current() ) { | 1378 | while ( it.current() ) { |
1377 | if ( it.current()->dirty() ) { | 1379 | if ( it.current()->dirty() ) { |
1378 | QString text = i18n( "Data has been changed externally. Unsaved " | 1380 | QString text = i18n( "Data has been changed externally. Unsaved " |
1379 | "changes will be lost." ); | 1381 | "changes will be lost." ); |
1380 | KMessageBox::information( this, text ); | 1382 | KMessageBox::information( this, text ); |
1381 | } | 1383 | } |
1382 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1384 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1383 | ++it; | 1385 | ++it; |
1384 | } | 1386 | } |
1385 | */ | 1387 | */ |
1386 | if (mEditorDialog) | 1388 | if (mEditorDialog) |
1387 | { | 1389 | { |
1388 | if (mEditorDialog->dirty()) | 1390 | if (mEditorDialog->dirty()) |
1389 | { | 1391 | { |
1390 | QString text = i18n( "Data has been changed externally. Unsaved " | 1392 | QString text = i18n( "Data has been changed externally. Unsaved " |
1391 | "changes will be lost." ); | 1393 | "changes will be lost." ); |
1392 | KMessageBox::information( this, text ); | 1394 | KMessageBox::information( this, text ); |
1393 | } | 1395 | } |
1394 | QString currentuid = mEditorDialog->addressee().uid(); | 1396 | QString currentuid = mEditorDialog->addressee().uid(); |
1395 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1397 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1396 | } | 1398 | } |
1397 | mViewManager->refreshView(); | 1399 | mViewManager->refreshView(); |
1398 | // mDetails->refreshView(); | 1400 | // mDetails->refreshView(); |
1399 | 1401 | ||
1400 | 1402 | ||
1401 | } | 1403 | } |
1402 | 1404 | ||
1403 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1405 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1404 | const char *name ) | 1406 | const char *name ) |
1405 | { | 1407 | { |
1406 | 1408 | ||
1407 | if ( mEditorDialog == 0 ) { | 1409 | if ( mEditorDialog == 0 ) { |
1408 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1410 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1409 | name ? name : "editorDialog" ); | 1411 | name ? name : "editorDialog" ); |
1410 | 1412 | ||
1411 | 1413 | ||
1412 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1414 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1413 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1415 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1414 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1416 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1415 | // SLOT( slotEditorDestroyed( const QString& ) ) ); | 1417 | // SLOT( slotEditorDestroyed( const QString& ) ) ); |
1416 | } | 1418 | } |
1417 | 1419 | ||
1418 | return mEditorDialog; | 1420 | return mEditorDialog; |
1419 | } | 1421 | } |
1420 | 1422 | ||
1421 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1423 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1422 | { | 1424 | { |
1423 | //mEditorDict.remove( uid ); | 1425 | //mEditorDict.remove( uid ); |
1424 | } | 1426 | } |
1425 | 1427 | ||
1426 | void KABCore::initGUI() | 1428 | void KABCore::initGUI() |
1427 | { | 1429 | { |
1428 | #ifndef KAB_EMBEDDED | 1430 | #ifndef KAB_EMBEDDED |
1429 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1431 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1430 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1432 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1431 | 1433 | ||
1432 | mExtensionBarSplitter = new QSplitter( this ); | 1434 | mExtensionBarSplitter = new QSplitter( this ); |
1433 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1435 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1434 | 1436 | ||
1435 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1437 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1436 | 1438 | ||
1437 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1439 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1438 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1440 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1439 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1441 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1440 | SLOT( incrementalSearch( const QString& ) ) ); | 1442 | SLOT( incrementalSearch( const QString& ) ) ); |
1441 | 1443 | ||
1442 | mViewManager = new ViewManager( this, viewSpace ); | 1444 | mViewManager = new ViewManager( this, viewSpace ); |
1443 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1445 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1444 | 1446 | ||
1445 | mDetails = new ViewContainer( mDetailsSplitter ); | 1447 | mDetails = new ViewContainer( mDetailsSplitter ); |
1446 | 1448 | ||
1447 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1449 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1448 | 1450 | ||
1449 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1451 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1450 | 1452 | ||
1451 | topLayout->addWidget( mExtensionBarSplitter ); | 1453 | topLayout->addWidget( mExtensionBarSplitter ); |
1452 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1454 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1453 | topLayout->addWidget( mJumpButtonBar ); | 1455 | topLayout->addWidget( mJumpButtonBar ); |
1454 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1456 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1455 | 1457 | ||
1456 | mXXPortManager = new XXPortManager( this, this ); | 1458 | mXXPortManager = new XXPortManager( this, this ); |
1457 | 1459 | ||
1458 | #else //KAB_EMBEDDED | 1460 | #else //KAB_EMBEDDED |
1459 | //US initialize viewMenu before settingup viewmanager. | 1461 | //US initialize viewMenu before settingup viewmanager. |
1460 | // Viewmanager needs this menu to plugin submenues. | 1462 | // Viewmanager needs this menu to plugin submenues. |
1461 | viewMenu = new QPopupMenu( this ); | 1463 | viewMenu = new QPopupMenu( this ); |
1462 | settingsMenu = new QPopupMenu( this ); | 1464 | settingsMenu = new QPopupMenu( this ); |
1463 | //filterMenu = new QPopupMenu( this ); | 1465 | //filterMenu = new QPopupMenu( this ); |
1464 | ImportMenu = new QPopupMenu( this ); | 1466 | ImportMenu = new QPopupMenu( this ); |
1465 | ExportMenu = new QPopupMenu( this ); | 1467 | ExportMenu = new QPopupMenu( this ); |
1466 | 1468 | ||
1467 | changeMenu= new QPopupMenu( this ); | 1469 | changeMenu= new QPopupMenu( this ); |
1468 | 1470 | ||
1469 | //US since we have no splitter for the embedded system, setup | 1471 | //US since we have no splitter for the embedded system, setup |
1470 | // a layout with two frames. One left and one right. | 1472 | // a layout with two frames. One left and one right. |
1471 | 1473 | ||
1472 | QBoxLayout *topLayout; | 1474 | QBoxLayout *topLayout; |
1473 | 1475 | ||
1474 | // = new QHBoxLayout( this ); | 1476 | // = new QHBoxLayout( this ); |
1475 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1477 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1476 | 1478 | ||
1477 | // QWidget *mainBox = new QWidget( this ); | 1479 | // QWidget *mainBox = new QWidget( this ); |
1478 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1480 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1479 | 1481 | ||
1480 | #ifdef DESKTOP_VERSION | 1482 | #ifdef DESKTOP_VERSION |
1481 | topLayout = new QHBoxLayout( this ); | 1483 | topLayout = new QHBoxLayout( this ); |
1482 | 1484 | ||
1483 | 1485 | ||
1484 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1486 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1485 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1487 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1486 | 1488 | ||
1487 | topLayout->addWidget(mMiniSplitter ); | 1489 | topLayout->addWidget(mMiniSplitter ); |
1488 | 1490 | ||
1489 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1491 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1490 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1492 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1491 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1493 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1492 | mDetails = new ViewContainer( mMiniSplitter ); | 1494 | mDetails = new ViewContainer( mMiniSplitter ); |
1493 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1495 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1494 | #else | 1496 | #else |
1495 | if ( QApplication::desktop()->width() > 480 ) { | 1497 | if ( QApplication::desktop()->width() > 480 ) { |
1496 | topLayout = new QHBoxLayout( this ); | 1498 | topLayout = new QHBoxLayout( this ); |
1497 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1499 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1498 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1500 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1499 | } else { | 1501 | } else { |
1500 | 1502 | ||
1501 | topLayout = new QHBoxLayout( this ); | 1503 | topLayout = new QHBoxLayout( this ); |
1502 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1504 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1503 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1505 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1504 | } | 1506 | } |
1505 | 1507 | ||
1506 | topLayout->addWidget(mMiniSplitter ); | 1508 | topLayout->addWidget(mMiniSplitter ); |
1507 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1509 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1508 | mDetails = new ViewContainer( mMiniSplitter ); | 1510 | mDetails = new ViewContainer( mMiniSplitter ); |
1509 | 1511 | ||
1510 | 1512 | ||
1511 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1513 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1512 | #endif | 1514 | #endif |
1513 | //eh->hide(); | 1515 | //eh->hide(); |
1514 | // topLayout->addWidget(mExtensionManager ); | 1516 | // topLayout->addWidget(mExtensionManager ); |
1515 | 1517 | ||
1516 | 1518 | ||
1517 | /*US | 1519 | /*US |
1518 | #ifndef KAB_NOSPLITTER | 1520 | #ifndef KAB_NOSPLITTER |
1519 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1521 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1520 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1522 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1521 | topLayout->setSpacing( 10 ); | 1523 | topLayout->setSpacing( 10 ); |
1522 | 1524 | ||
1523 | mDetailsSplitter = new QSplitter( this ); | 1525 | mDetailsSplitter = new QSplitter( this ); |
1524 | 1526 | ||
1525 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1527 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1526 | 1528 | ||
1527 | mViewManager = new ViewManager( this, viewSpace ); | 1529 | mViewManager = new ViewManager( this, viewSpace ); |
1528 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1530 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1529 | 1531 | ||
1530 | mDetails = new ViewContainer( mDetailsSplitter ); | 1532 | mDetails = new ViewContainer( mDetailsSplitter ); |
1531 | 1533 | ||
1532 | topLayout->addWidget( mDetailsSplitter ); | 1534 | topLayout->addWidget( mDetailsSplitter ); |
1533 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1535 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1534 | #else //KAB_NOSPLITTER | 1536 | #else //KAB_NOSPLITTER |
1535 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1537 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1536 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1538 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1537 | topLayout->setSpacing( 10 ); | 1539 | topLayout->setSpacing( 10 ); |
1538 | 1540 | ||
1539 | // mDetailsSplitter = new QSplitter( this ); | 1541 | // mDetailsSplitter = new QSplitter( this ); |
1540 | 1542 | ||
1541 | QVBox *viewSpace = new QVBox( this ); | 1543 | QVBox *viewSpace = new QVBox( this ); |
1542 | 1544 | ||
1543 | mViewManager = new ViewManager( this, viewSpace ); | 1545 | mViewManager = new ViewManager( this, viewSpace ); |
1544 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1546 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1545 | 1547 | ||
1546 | mDetails = new ViewContainer( this ); | 1548 | mDetails = new ViewContainer( this ); |
1547 | 1549 | ||
1548 | topLayout->addWidget( viewSpace ); | 1550 | topLayout->addWidget( viewSpace ); |
1549 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1551 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1550 | topLayout->addWidget( mDetails ); | 1552 | topLayout->addWidget( mDetails ); |
1551 | #endif //KAB_NOSPLITTER | 1553 | #endif //KAB_NOSPLITTER |
1552 | */ | 1554 | */ |
1553 | 1555 | ||
1554 | 1556 | ||
1555 | #endif //KAB_EMBEDDED | 1557 | #endif //KAB_EMBEDDED |
1556 | initActions(); | 1558 | initActions(); |
1557 | 1559 | ||
1558 | #ifdef KAB_EMBEDDED | 1560 | #ifdef KAB_EMBEDDED |
1559 | addActionsManually(); | 1561 | addActionsManually(); |
1560 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1562 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1561 | mXXPortManager = new XXPortManager( this, this ); | 1563 | mXXPortManager = new XXPortManager( this, this ); |
1562 | 1564 | ||
1563 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1565 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1564 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1566 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1565 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1567 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1566 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1568 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1567 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1569 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1568 | // mIncSearchWidget->hide(); | 1570 | // mIncSearchWidget->hide(); |
1569 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1571 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1570 | SLOT( incrementalSearch( const QString& ) ) ); | 1572 | SLOT( incrementalSearch( const QString& ) ) ); |
1571 | 1573 | ||
1572 | 1574 | ||
1573 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1575 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1574 | 1576 | ||
1575 | topLayout->addWidget( mJumpButtonBar ); | 1577 | topLayout->addWidget( mJumpButtonBar ); |
1576 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1578 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1577 | 1579 | ||
1578 | // mMainWindow->getIconToolBar()->raise(); | 1580 | // mMainWindow->getIconToolBar()->raise(); |
1579 | 1581 | ||
1580 | #endif //KAB_EMBEDDED | 1582 | #endif //KAB_EMBEDDED |
1581 | 1583 | ||
1582 | } | 1584 | } |
1583 | void KABCore::initActions() | 1585 | void KABCore::initActions() |
1584 | { | 1586 | { |
1585 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1587 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1586 | 1588 | ||
1587 | #ifndef KAB_EMBEDDED | 1589 | #ifndef KAB_EMBEDDED |
1588 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1590 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1589 | SLOT( clipboardDataChanged() ) ); | 1591 | SLOT( clipboardDataChanged() ) ); |
1590 | #endif //KAB_EMBEDDED | 1592 | #endif //KAB_EMBEDDED |
1591 | 1593 | ||
1592 | // file menu | 1594 | // file menu |
1593 | if ( mIsPart ) { | 1595 | if ( mIsPart ) { |
1594 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1596 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1595 | SLOT( sendMail() ), actionCollection(), | 1597 | SLOT( sendMail() ), actionCollection(), |
1596 | "kaddressbook_mail" ); | 1598 | "kaddressbook_mail" ); |
1597 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1599 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1598 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1600 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1599 | 1601 | ||
1600 | } else { | 1602 | } else { |
1601 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1603 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1602 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1604 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1603 | } | 1605 | } |
1604 | 1606 | ||
1605 | 1607 | ||
1606 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1608 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1607 | SLOT( save() ), actionCollection(), "file_sync" ); | 1609 | SLOT( save() ), actionCollection(), "file_sync" ); |
1608 | 1610 | ||
1609 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1611 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1610 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1612 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1611 | 1613 | ||
1612 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1614 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1613 | this, SLOT( mailVCard() ), | 1615 | this, SLOT( mailVCard() ), |
1614 | actionCollection(), "file_mail_vcard"); | 1616 | actionCollection(), "file_mail_vcard"); |
1615 | 1617 | ||
1616 | mActionBeamVCard = 0; | 1618 | mActionBeamVCard = 0; |
1617 | mActionBeam = 0; | 1619 | mActionBeam = 0; |
1618 | 1620 | ||
1619 | #ifndef DESKTOP_VERSION | 1621 | #ifndef DESKTOP_VERSION |
1620 | if ( Ir::supported() ) { | 1622 | if ( Ir::supported() ) { |
1621 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1623 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1622 | SLOT( beamVCard() ), actionCollection(), | 1624 | SLOT( beamVCard() ), actionCollection(), |
1623 | "kaddressbook_beam_vcard" ); | 1625 | "kaddressbook_beam_vcard" ); |
1624 | 1626 | ||
1625 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1627 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1626 | SLOT( beamMySelf() ), actionCollection(), | 1628 | SLOT( beamMySelf() ), actionCollection(), |
1627 | "kaddressbook_beam_myself" ); | 1629 | "kaddressbook_beam_myself" ); |
1628 | } | 1630 | } |
1629 | #endif | 1631 | #endif |
1630 | 1632 | ||
1631 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1633 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1632 | this, SLOT( editContact2() ), | 1634 | this, SLOT( editContact2() ), |
1633 | actionCollection(), "file_properties" ); | 1635 | actionCollection(), "file_properties" ); |
1634 | 1636 | ||
1635 | #ifdef KAB_EMBEDDED | 1637 | #ifdef KAB_EMBEDDED |
1636 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1638 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1637 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1639 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1638 | mMainWindow, SLOT( exit() ), | 1640 | mMainWindow, SLOT( exit() ), |
1639 | actionCollection(), "quit" ); | 1641 | actionCollection(), "quit" ); |
1640 | #endif //KAB_EMBEDDED | 1642 | #endif //KAB_EMBEDDED |
1641 | 1643 | ||
1642 | // edit menu | 1644 | // edit menu |
1643 | if ( mIsPart ) { | 1645 | if ( mIsPart ) { |
1644 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1646 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1645 | SLOT( copyContacts() ), actionCollection(), | 1647 | SLOT( copyContacts() ), actionCollection(), |
1646 | "kaddressbook_copy" ); | 1648 | "kaddressbook_copy" ); |
1647 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1649 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1648 | SLOT( cutContacts() ), actionCollection(), | 1650 | SLOT( cutContacts() ), actionCollection(), |
1649 | "kaddressbook_cut" ); | 1651 | "kaddressbook_cut" ); |
1650 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1652 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1651 | SLOT( pasteContacts() ), actionCollection(), | 1653 | SLOT( pasteContacts() ), actionCollection(), |
1652 | "kaddressbook_paste" ); | 1654 | "kaddressbook_paste" ); |
1653 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1655 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1654 | SLOT( selectAllContacts() ), actionCollection(), | 1656 | SLOT( selectAllContacts() ), actionCollection(), |
1655 | "kaddressbook_select_all" ); | 1657 | "kaddressbook_select_all" ); |
1656 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1658 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1657 | SLOT( undo() ), actionCollection(), | 1659 | SLOT( undo() ), actionCollection(), |
1658 | "kaddressbook_undo" ); | 1660 | "kaddressbook_undo" ); |
1659 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1661 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1660 | this, SLOT( redo() ), actionCollection(), | 1662 | this, SLOT( redo() ), actionCollection(), |
1661 | "kaddressbook_redo" ); | 1663 | "kaddressbook_redo" ); |
1662 | } else { | 1664 | } else { |
1663 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1665 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1664 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1666 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1665 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1667 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1666 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1668 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1667 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1669 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1668 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1670 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1669 | } | 1671 | } |
1670 | 1672 | ||
1671 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1673 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1672 | Key_Delete, this, SLOT( deleteContacts() ), | 1674 | Key_Delete, this, SLOT( deleteContacts() ), |
1673 | actionCollection(), "edit_delete" ); | 1675 | actionCollection(), "edit_delete" ); |
1674 | 1676 | ||
1675 | mActionUndo->setEnabled( false ); | 1677 | mActionUndo->setEnabled( false ); |
1676 | mActionRedo->setEnabled( false ); | 1678 | mActionRedo->setEnabled( false ); |
1677 | 1679 | ||
1678 | // settings menu | 1680 | // settings menu |
1679 | #ifdef KAB_EMBEDDED | 1681 | #ifdef KAB_EMBEDDED |
1680 | //US special menuentry to configure the addressbook resources. On KDE | 1682 | //US special menuentry to configure the addressbook resources. On KDE |
1681 | // you do that through the control center !!! | 1683 | // you do that through the control center !!! |
1682 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1684 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1683 | SLOT( configureResources() ), actionCollection(), | 1685 | SLOT( configureResources() ), actionCollection(), |
1684 | "kaddressbook_configure_resources" ); | 1686 | "kaddressbook_configure_resources" ); |
1685 | #endif //KAB_EMBEDDED | 1687 | #endif //KAB_EMBEDDED |
1686 | 1688 | ||
1687 | if ( mIsPart ) { | 1689 | if ( mIsPart ) { |
1688 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1690 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1689 | SLOT( openConfigDialog() ), actionCollection(), | 1691 | SLOT( openConfigDialog() ), actionCollection(), |
1690 | "kaddressbook_configure" ); | 1692 | "kaddressbook_configure" ); |
1691 | 1693 | ||
1692 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1694 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1693 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1695 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1694 | "kaddressbook_configure_shortcuts" ); | 1696 | "kaddressbook_configure_shortcuts" ); |
1695 | #ifdef KAB_EMBEDDED | 1697 | #ifdef KAB_EMBEDDED |
1696 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1698 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1697 | mActionConfigureToolbars->setEnabled( false ); | 1699 | mActionConfigureToolbars->setEnabled( false ); |
1698 | #endif //KAB_EMBEDDED | 1700 | #endif //KAB_EMBEDDED |
1699 | 1701 | ||
1700 | } else { | 1702 | } else { |
1701 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1703 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1702 | 1704 | ||
1703 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1705 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1704 | } | 1706 | } |
1705 | 1707 | ||
1706 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1708 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1707 | actionCollection(), "options_show_jump_bar" ); | 1709 | actionCollection(), "options_show_jump_bar" ); |
1708 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1710 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1709 | 1711 | ||
1710 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1712 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1711 | actionCollection(), "options_show_details" ); | 1713 | actionCollection(), "options_show_details" ); |
1712 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1714 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1713 | 1715 | ||
1714 | // misc | 1716 | // misc |
1715 | // only enable LDAP lookup if we can handle the protocol | 1717 | // only enable LDAP lookup if we can handle the protocol |
1716 | #ifndef KAB_EMBEDDED | 1718 | #ifndef KAB_EMBEDDED |
1717 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1719 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1718 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1720 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1719 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1721 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1720 | "ldap_lookup" ); | 1722 | "ldap_lookup" ); |
1721 | } | 1723 | } |
1722 | #else //KAB_EMBEDDED | 1724 | #else //KAB_EMBEDDED |
1723 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1725 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1724 | #endif //KAB_EMBEDDED | 1726 | #endif //KAB_EMBEDDED |
1725 | 1727 | ||
1726 | 1728 | ||
1727 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1729 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1728 | SLOT( setWhoAmI() ), actionCollection(), | 1730 | SLOT( setWhoAmI() ), actionCollection(), |
1729 | "set_personal" ); | 1731 | "set_personal" ); |
1730 | 1732 | ||
1731 | 1733 | ||
1732 | 1734 | ||
1733 | 1735 | ||
1734 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1736 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1735 | SLOT( setCategories() ), actionCollection(), | 1737 | SLOT( setCategories() ), actionCollection(), |
1736 | "edit_set_categories" ); | 1738 | "edit_set_categories" ); |
1737 | 1739 | ||
1738 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1740 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1739 | SLOT( removeVoice() ), actionCollection(), | 1741 | SLOT( removeVoice() ), actionCollection(), |
1740 | "remove_voice" ); | 1742 | "remove_voice" ); |
1741 | mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, | 1743 | mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, |
1742 | SLOT( importFromOL() ), actionCollection(), | 1744 | SLOT( importFromOL() ), actionCollection(), |
1743 | "import_OL" ); | 1745 | "import_OL" ); |
1744 | #ifdef KAB_EMBEDDED | 1746 | #ifdef KAB_EMBEDDED |
1745 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1747 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1746 | this, SLOT( showLicence() ), actionCollection(), | 1748 | this, SLOT( showLicence() ), actionCollection(), |
1747 | "licence_about_data" ); | 1749 | "licence_about_data" ); |
1748 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1750 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1749 | this, SLOT( faq() ), actionCollection(), | 1751 | this, SLOT( faq() ), actionCollection(), |
1750 | "faq_about_data" ); | 1752 | "faq_about_data" ); |
1751 | 1753 | ||
1752 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1754 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1753 | this, SLOT( createAboutData() ), actionCollection(), | 1755 | this, SLOT( createAboutData() ), actionCollection(), |
1754 | "kaddressbook_about_data" ); | 1756 | "kaddressbook_about_data" ); |
1755 | #endif //KAB_EMBEDDED | 1757 | #endif //KAB_EMBEDDED |
1756 | 1758 | ||
1757 | clipboardDataChanged(); | 1759 | clipboardDataChanged(); |
1758 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1760 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1759 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1761 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1760 | } | 1762 | } |
1761 | 1763 | ||
1762 | //US we need this function, to plug all actions into the correct menues. | 1764 | //US we need this function, to plug all actions into the correct menues. |
1763 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1765 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1764 | void KABCore::addActionsManually() | 1766 | void KABCore::addActionsManually() |
1765 | { | 1767 | { |
1766 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1768 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1767 | 1769 | ||
1768 | #ifdef KAB_EMBEDDED | 1770 | #ifdef KAB_EMBEDDED |
1769 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1771 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1770 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1772 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1771 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1773 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1772 | 1774 | ||
1773 | KToolBar* tb = mMainWindow->toolBar(); | 1775 | KToolBar* tb = mMainWindow->toolBar(); |
1774 | 1776 | ||
1775 | #ifdef DESKTOP_VERSION | 1777 | #ifdef DESKTOP_VERSION |
1776 | QMenuBar* mb = mMainWindow->menuBar(); | 1778 | QMenuBar* mb = mMainWindow->menuBar(); |
1777 | 1779 | ||
1778 | //US setup menubar. | 1780 | //US setup menubar. |
1779 | //Disable the following block if you do not want to have a menubar. | 1781 | //Disable the following block if you do not want to have a menubar. |
1780 | mb->insertItem( "&File", fileMenu ); | 1782 | mb->insertItem( "&File", fileMenu ); |
1781 | mb->insertItem( "&Edit", editMenu ); | 1783 | mb->insertItem( "&Edit", editMenu ); |
1782 | mb->insertItem( "&View", viewMenu ); | 1784 | mb->insertItem( "&View", viewMenu ); |
1783 | mb->insertItem( "&Settings", settingsMenu ); | 1785 | mb->insertItem( "&Settings", settingsMenu ); |
1784 | mb->insertItem( "&Change selected", changeMenu ); | 1786 | mb->insertItem( "&Change selected", changeMenu ); |
1785 | mb->insertItem( "&Help", helpMenu ); | 1787 | mb->insertItem( "&Help", helpMenu ); |
1786 | mIncSearchWidget = new IncSearchWidget( tb ); | 1788 | mIncSearchWidget = new IncSearchWidget( tb ); |
1787 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1789 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1788 | 1790 | ||
1789 | #else | 1791 | #else |
1790 | //US setup toolbar | 1792 | //US setup toolbar |
1791 | QMenuBar *menuBarTB = new QMenuBar( tb ); | 1793 | QMenuBar *menuBarTB = new QMenuBar( tb ); |
1792 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1794 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1793 | menuBarTB->insertItem( "ME", popupBarTB); | 1795 | menuBarTB->insertItem( "ME", popupBarTB); |
1794 | tb->insertWidget(-1, 0, menuBarTB); | 1796 | tb->insertWidget(-1, 0, menuBarTB); |
1795 | mIncSearchWidget = new IncSearchWidget( tb ); | 1797 | mIncSearchWidget = new IncSearchWidget( tb ); |
1796 | 1798 | ||
1797 | tb->enableMoving(false); | 1799 | tb->enableMoving(false); |
1798 | popupBarTB->insertItem( "&File", fileMenu ); | 1800 | popupBarTB->insertItem( "&File", fileMenu ); |
1799 | popupBarTB->insertItem( "&Edit", editMenu ); | 1801 | popupBarTB->insertItem( "&Edit", editMenu ); |
1800 | popupBarTB->insertItem( "&View", viewMenu ); | 1802 | popupBarTB->insertItem( "&View", viewMenu ); |
1801 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1803 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1802 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1804 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1803 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1805 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1804 | popupBarTB->insertItem( "&Help", helpMenu ); | 1806 | popupBarTB->insertItem( "&Help", helpMenu ); |
1805 | if (QApplication::desktop()->width() > 320 ) { | 1807 | if (QApplication::desktop()->width() > 320 ) { |
1806 | // mViewManager->getFilterAction()->plug ( tb); | 1808 | // mViewManager->getFilterAction()->plug ( tb); |
1807 | } | 1809 | } |
1808 | #endif | 1810 | #endif |
1809 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1811 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1810 | 1812 | ||
1811 | 1813 | ||
1812 | 1814 | ||
1813 | //US Now connect the actions with the menue entries. | 1815 | //US Now connect the actions with the menue entries. |
1814 | mActionPrint->plug( fileMenu ); | 1816 | mActionPrint->plug( fileMenu ); |
1815 | mActionMail->plug( fileMenu ); | 1817 | mActionMail->plug( fileMenu ); |
1816 | fileMenu->insertSeparator(); | 1818 | fileMenu->insertSeparator(); |
1817 | 1819 | ||
1818 | mActionNewContact->plug( fileMenu ); | 1820 | mActionNewContact->plug( fileMenu ); |
1819 | mActionNewContact->plug( tb ); | 1821 | mActionNewContact->plug( tb ); |
1820 | 1822 | ||
1821 | mActionEditAddressee->plug( fileMenu ); | 1823 | mActionEditAddressee->plug( fileMenu ); |
1822 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1824 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1823 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1825 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1824 | mActionEditAddressee->plug( tb ); | 1826 | mActionEditAddressee->plug( tb ); |
1825 | 1827 | ||
1826 | fileMenu->insertSeparator(); | 1828 | fileMenu->insertSeparator(); |
1827 | mActionSave->plug( fileMenu ); | 1829 | mActionSave->plug( fileMenu ); |
1828 | fileMenu->insertItem( "&Import", ImportMenu ); | 1830 | fileMenu->insertItem( "&Import", ImportMenu ); |
1829 | fileMenu->insertItem( "&Emport", ExportMenu ); | 1831 | fileMenu->insertItem( "&Emport", ExportMenu ); |
1830 | fileMenu->insertSeparator(); | 1832 | fileMenu->insertSeparator(); |
1831 | mActionMailVCard->plug( fileMenu ); | 1833 | mActionMailVCard->plug( fileMenu ); |
1832 | #ifndef DESKTOP_VERSION | 1834 | #ifndef DESKTOP_VERSION |
1833 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1835 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1834 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1836 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1835 | #endif | 1837 | #endif |
1836 | fileMenu->insertSeparator(); | 1838 | fileMenu->insertSeparator(); |
1837 | mActionQuit->plug( fileMenu ); | 1839 | mActionQuit->plug( fileMenu ); |
1838 | #ifdef _WIN32_ | 1840 | #ifdef _WIN32_ |
1839 | mActionImportOL->plug( ImportMenu ); | 1841 | mActionImportOL->plug( ImportMenu ); |
1840 | #endif | 1842 | #endif |
1841 | // edit menu | 1843 | // edit menu |
1842 | mActionUndo->plug( editMenu ); | 1844 | mActionUndo->plug( editMenu ); |
1843 | mActionRedo->plug( editMenu ); | 1845 | mActionRedo->plug( editMenu ); |
1844 | editMenu->insertSeparator(); | 1846 | editMenu->insertSeparator(); |
1845 | mActionCut->plug( editMenu ); | 1847 | mActionCut->plug( editMenu ); |
1846 | mActionCopy->plug( editMenu ); | 1848 | mActionCopy->plug( editMenu ); |
1847 | mActionPaste->plug( editMenu ); | 1849 | mActionPaste->plug( editMenu ); |
1848 | mActionDelete->plug( editMenu ); | 1850 | mActionDelete->plug( editMenu ); |
1849 | editMenu->insertSeparator(); | 1851 | editMenu->insertSeparator(); |
1850 | mActionSelectAll->plug( editMenu ); | 1852 | mActionSelectAll->plug( editMenu ); |
1851 | 1853 | ||
1852 | mActionRemoveVoice->plug( changeMenu ); | 1854 | mActionRemoveVoice->plug( changeMenu ); |
1853 | // settings menu | 1855 | // settings menu |
1854 | //US special menuentry to configure the addressbook resources. On KDE | 1856 | //US special menuentry to configure the addressbook resources. On KDE |
1855 | // you do that through the control center !!! | 1857 | // you do that through the control center !!! |
1856 | mActionConfigResources->plug( settingsMenu ); | 1858 | mActionConfigResources->plug( settingsMenu ); |
1857 | settingsMenu->insertSeparator(); | 1859 | settingsMenu->insertSeparator(); |
1858 | 1860 | ||
1859 | mActionConfigKAddressbook->plug( settingsMenu ); | 1861 | mActionConfigKAddressbook->plug( settingsMenu ); |
1860 | 1862 | ||
1861 | if ( mIsPart ) { | 1863 | if ( mIsPart ) { |
1862 | mActionConfigShortcuts->plug( settingsMenu ); | 1864 | mActionConfigShortcuts->plug( settingsMenu ); |
1863 | mActionConfigureToolbars->plug( settingsMenu ); | 1865 | mActionConfigureToolbars->plug( settingsMenu ); |
1864 | 1866 | ||
1865 | } else { | 1867 | } else { |
1866 | mActionKeyBindings->plug( settingsMenu ); | 1868 | mActionKeyBindings->plug( settingsMenu ); |
1867 | } | 1869 | } |
1868 | 1870 | ||
1869 | settingsMenu->insertSeparator(); | 1871 | settingsMenu->insertSeparator(); |
1870 | 1872 | ||
1871 | mActionJumpBar->plug( settingsMenu ); | 1873 | mActionJumpBar->plug( settingsMenu ); |
1872 | mActionDetails->plug( settingsMenu ); | 1874 | mActionDetails->plug( settingsMenu ); |
1873 | if (!KABPrefs::instance()->mMultipleViewsAtOnce ) | 1875 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
1874 | mActionDetails->plug( tb ); | 1876 | mActionDetails->plug( tb ); |
1875 | settingsMenu->insertSeparator(); | 1877 | settingsMenu->insertSeparator(); |
1876 | 1878 | ||
1877 | mActionWhoAmI->plug( settingsMenu ); | 1879 | mActionWhoAmI->plug( settingsMenu ); |
1878 | mActionCategories->plug( settingsMenu ); | 1880 | mActionCategories->plug( settingsMenu ); |
1879 | 1881 | ||
1880 | mActionLicence->plug( helpMenu ); | 1882 | mActionLicence->plug( helpMenu ); |
1881 | mActionFaq->plug( helpMenu ); | 1883 | mActionFaq->plug( helpMenu ); |
1882 | mActionAboutKAddressbook->plug( helpMenu ); | 1884 | mActionAboutKAddressbook->plug( helpMenu ); |
1883 | 1885 | ||
1884 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1886 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1885 | 1887 | ||
1886 | mActionSave->plug( tb ); | 1888 | mActionSave->plug( tb ); |
1887 | mViewManager->getFilterAction()->plug ( tb); | 1889 | mViewManager->getFilterAction()->plug ( tb); |
1888 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 1890 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
1889 | mActionUndo->plug( tb ); | 1891 | mActionUndo->plug( tb ); |
1890 | mActionDelete->plug( tb ); | 1892 | mActionDelete->plug( tb ); |
1891 | mActionRedo->plug( tb ); | 1893 | mActionRedo->plug( tb ); |
1892 | } | 1894 | } |
1893 | } | 1895 | } |
1894 | //mActionQuit->plug ( tb ); | 1896 | //mActionQuit->plug ( tb ); |
1895 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1897 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1896 | 1898 | ||
1897 | //US link the searchwidget first to this. | 1899 | //US link the searchwidget first to this. |
1898 | // The real linkage to the toolbar happens later. | 1900 | // The real linkage to the toolbar happens later. |
1899 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1901 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1900 | //US tb->insertItem( mIncSearchWidget ); | 1902 | //US tb->insertItem( mIncSearchWidget ); |
1901 | /*US | 1903 | /*US |
1902 | mIncSearchWidget = new IncSearchWidget( tb ); | 1904 | mIncSearchWidget = new IncSearchWidget( tb ); |
1903 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1905 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1904 | SLOT( incrementalSearch( const QString& ) ) ); | 1906 | SLOT( incrementalSearch( const QString& ) ) ); |
1905 | 1907 | ||
1906 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1908 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1907 | 1909 | ||
1908 | //US topLayout->addWidget( mJumpButtonBar ); | 1910 | //US topLayout->addWidget( mJumpButtonBar ); |
1909 | this->layout()->add( mJumpButtonBar ); | 1911 | this->layout()->add( mJumpButtonBar ); |
1910 | */ | 1912 | */ |
1911 | 1913 | ||
1912 | #endif //KAB_EMBEDDED | 1914 | #endif //KAB_EMBEDDED |
1913 | } | 1915 | } |
1914 | void KABCore::showLicence() | 1916 | void KABCore::showLicence() |
1915 | { | 1917 | { |
1916 | KApplication::showLicence(); | 1918 | KApplication::showLicence(); |
1917 | } | 1919 | } |
1918 | void KABCore::removeVoice() | 1920 | void KABCore::removeVoice() |
1919 | { | 1921 | { |
1920 | 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 ) | 1922 | 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 ) |
1921 | return; | 1923 | return; |
1922 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 1924 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
1923 | KABC::Addressee::List::Iterator it; | 1925 | KABC::Addressee::List::Iterator it; |
1924 | for ( it = list.begin(); it != list.end(); ++it ) { | 1926 | for ( it = list.begin(); it != list.end(); ++it ) { |
1925 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 1927 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
1926 | PhoneNumber::List::Iterator phoneIt; | 1928 | PhoneNumber::List::Iterator phoneIt; |
1927 | bool found = false; | 1929 | bool found = false; |
1928 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 1930 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
1929 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 1931 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
1930 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 1932 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
1931 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 1933 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
1932 | (*it).insertPhoneNumber( (*phoneIt) ); | 1934 | (*it).insertPhoneNumber( (*phoneIt) ); |
1933 | found = true; | 1935 | found = true; |
1934 | } | 1936 | } |
1935 | } | 1937 | } |
1936 | 1938 | ||
1937 | } | 1939 | } |
1938 | if ( found ) | 1940 | if ( found ) |
1939 | contactModified((*it) ); | 1941 | contactModified((*it) ); |
1940 | } | 1942 | } |
1941 | } | 1943 | } |
1942 | 1944 | ||
1943 | 1945 | ||
1944 | 1946 | ||
1945 | void KABCore::clipboardDataChanged() | 1947 | void KABCore::clipboardDataChanged() |
1946 | { | 1948 | { |
1947 | 1949 | ||
1948 | if ( mReadWrite ) | 1950 | if ( mReadWrite ) |
1949 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 1951 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
1950 | 1952 | ||
1951 | } | 1953 | } |
1952 | 1954 | ||
1953 | void KABCore::updateActionMenu() | 1955 | void KABCore::updateActionMenu() |
1954 | { | 1956 | { |
1955 | UndoStack *undo = UndoStack::instance(); | 1957 | UndoStack *undo = UndoStack::instance(); |
1956 | RedoStack *redo = RedoStack::instance(); | 1958 | RedoStack *redo = RedoStack::instance(); |
1957 | 1959 | ||
1958 | if ( undo->isEmpty() ) | 1960 | if ( undo->isEmpty() ) |
1959 | mActionUndo->setText( i18n( "Undo" ) ); | 1961 | mActionUndo->setText( i18n( "Undo" ) ); |
1960 | else | 1962 | else |
1961 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 1963 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
1962 | 1964 | ||
1963 | mActionUndo->setEnabled( !undo->isEmpty() ); | 1965 | mActionUndo->setEnabled( !undo->isEmpty() ); |
1964 | 1966 | ||
1965 | if ( !redo->top() ) | 1967 | if ( !redo->top() ) |
1966 | mActionRedo->setText( i18n( "Redo" ) ); | 1968 | mActionRedo->setText( i18n( "Redo" ) ); |
1967 | else | 1969 | else |
1968 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 1970 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
1969 | 1971 | ||
1970 | mActionRedo->setEnabled( !redo->isEmpty() ); | 1972 | mActionRedo->setEnabled( !redo->isEmpty() ); |
1971 | } | 1973 | } |
1972 | 1974 | ||
1973 | void KABCore::configureKeyBindings() | 1975 | void KABCore::configureKeyBindings() |
1974 | { | 1976 | { |
1975 | #ifndef KAB_EMBEDDED | 1977 | #ifndef KAB_EMBEDDED |
1976 | KKeyDialog::configure( actionCollection(), true ); | 1978 | KKeyDialog::configure( actionCollection(), true ); |
1977 | #else //KAB_EMBEDDED | 1979 | #else //KAB_EMBEDDED |
1978 | qDebug("KABCore::configureKeyBindings() not implemented"); | 1980 | qDebug("KABCore::configureKeyBindings() not implemented"); |
1979 | #endif //KAB_EMBEDDED | 1981 | #endif //KAB_EMBEDDED |
1980 | } | 1982 | } |
1981 | 1983 | ||
1982 | #ifdef KAB_EMBEDDED | 1984 | #ifdef KAB_EMBEDDED |
1983 | void KABCore::configureResources() | 1985 | void KABCore::configureResources() |
1984 | { | 1986 | { |
1985 | KRES::KCMKResources dlg( this, "" , 0 ); | 1987 | KRES::KCMKResources dlg( this, "" , 0 ); |
1986 | 1988 | ||
1987 | if ( !dlg.exec() ) | 1989 | if ( !dlg.exec() ) |
1988 | return; | 1990 | return; |
1989 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 1991 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
1990 | } | 1992 | } |
1991 | #endif //KAB_EMBEDDED | 1993 | #endif //KAB_EMBEDDED |
1992 | 1994 | ||
1993 | 1995 | ||
1994 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 1996 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
1995 | * for the attendees list of an event. | 1997 | * for the attendees list of an event. |
1996 | */ | 1998 | */ |
1997 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 1999 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
1998 | { | 2000 | { |
1999 | QStringList nameList; | 2001 | QStringList nameList; |
2000 | QStringList emailList; | 2002 | QStringList emailList; |
2001 | QStringList uidList; | 2003 | QStringList uidList; |
2002 | 2004 | ||
2003 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2005 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2004 | uint i=0; | 2006 | uint i=0; |
2005 | for (i=0; i < list.count(); i++) | 2007 | for (i=0; i < list.count(); i++) |
2006 | { | 2008 | { |
2007 | nameList.append(list[i].realName()); | 2009 | nameList.append(list[i].realName()); |
2008 | emailList.append(list[i].preferredEmail()); | 2010 | emailList.append(list[i].preferredEmail()); |
2009 | uidList.append(list[i].uid()); | 2011 | uidList.append(list[i].uid()); |
2010 | } | 2012 | } |
2011 | 2013 | ||
2012 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2014 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2013 | 2015 | ||
2014 | } | 2016 | } |
2015 | 2017 | ||
2016 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2018 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2017 | */ | 2019 | */ |
2018 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2020 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2019 | { | 2021 | { |
2020 | // qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2022 | // qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2021 | 2023 | ||
2022 | QString foundUid = QString::null; | 2024 | QString foundUid = QString::null; |
2023 | if (uid.isEmpty()) | 2025 | if (uid.isEmpty()) |
2024 | { | 2026 | { |
2025 | //find the uid of the person first | 2027 | //find the uid of the person first |
2026 | Addressee::List namelist; | 2028 | Addressee::List namelist; |
2027 | Addressee::List emaillist; | 2029 | Addressee::List emaillist; |
2028 | 2030 | ||
2029 | if (!name.isEmpty()) | 2031 | if (!name.isEmpty()) |
2030 | namelist = mAddressBook->findByName( name ); | 2032 | namelist = mAddressBook->findByName( name ); |
2031 | 2033 | ||
2032 | if (!email.isEmpty()) | 2034 | if (!email.isEmpty()) |
2033 | emaillist = mAddressBook->findByEmail( email ); | 2035 | emaillist = mAddressBook->findByEmail( email ); |
2034 | 2036 | ||
2035 | //check if we have a match in Namelist and Emaillist | 2037 | //check if we have a match in Namelist and Emaillist |
2036 | if ((namelist.count() == 0) && (emaillist.count() > 0)) | 2038 | if ((namelist.count() == 0) && (emaillist.count() > 0)) |
2037 | foundUid == emaillist[0].uid(); | 2039 | foundUid == emaillist[0].uid(); |
2038 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2040 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2039 | foundUid == namelist[0].uid(); | 2041 | foundUid == namelist[0].uid(); |
2040 | else | 2042 | else |
2041 | { | 2043 | { |
2042 | for (int i = 0; i < namelist.count(); i++) | 2044 | for (int i = 0; i < namelist.count(); i++) |
2043 | { | 2045 | { |
2044 | for (int j = 0; j < emaillist.count(); j++) | 2046 | for (int j = 0; j < emaillist.count(); j++) |
2045 | { | 2047 | { |
2046 | if (namelist[i] == emaillist[j]) | 2048 | if (namelist[i] == emaillist[j]) |
2047 | { | 2049 | { |
2048 | foundUid == namelist[i].uid(); | 2050 | foundUid == namelist[i].uid(); |
2049 | } | 2051 | } |
2050 | } | 2052 | } |
2051 | } | 2053 | } |
2052 | } | 2054 | } |
2053 | } | 2055 | } |
2054 | else | 2056 | else |
2055 | { | 2057 | { |
2056 | foundUid = uid; | 2058 | foundUid = uid; |
2057 | } | 2059 | } |
2058 | 2060 | ||
2059 | if (!foundUid.isEmpty()) | 2061 | if (!foundUid.isEmpty()) |
2060 | { | 2062 | { |
2061 | // raise Ka/Pi if it is in the background | 2063 | // raise Ka/Pi if it is in the background |
2062 | #ifndef DESKTOP_VERSION | 2064 | #ifndef DESKTOP_VERSION |
2063 | #ifndef KORG_NODCOP | 2065 | #ifndef KORG_NODCOP |
2064 | QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2066 | QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2065 | #endif | 2067 | #endif |
2066 | #endif | 2068 | #endif |
2067 | 2069 | ||
2068 | mMainWindow->showMaximized(); | 2070 | mMainWindow->showMaximized(); |
2069 | 2071 | ||
2070 | mViewManager->setSelected( "", false); | 2072 | mViewManager->setSelected( "", false); |
2071 | mViewManager->refreshView( "" ); | 2073 | mViewManager->refreshView( "" ); |
2072 | mViewManager->setSelected( foundUid, true ); | 2074 | mViewManager->setSelected( foundUid, true ); |
2073 | mViewManager->refreshView( foundUid ); | 2075 | mViewManager->refreshView( foundUid ); |
2074 | 2076 | ||
2075 | if ( !mMultipleViewsAtOnce ) | 2077 | if ( !mMultipleViewsAtOnce ) |
2076 | { | 2078 | { |
2077 | setDetailsVisible( true ); | 2079 | setDetailsVisible( true ); |
2078 | mActionDetails->setChecked(true); | 2080 | mActionDetails->setChecked(true); |
2079 | } | 2081 | } |
2080 | } | 2082 | } |
2081 | } | 2083 | } |
2082 | 2084 | ||
2083 | 2085 | ||
2084 | void KABCore::faq() | 2086 | void KABCore::faq() |
2085 | { | 2087 | { |
2086 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2088 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2087 | } | 2089 | } |
2088 | 2090 | ||
2089 | 2091 | ||
2090 | 2092 | ||
2091 | 2093 | ||
2092 | #ifndef KAB_EMBEDDED | 2094 | #ifndef KAB_EMBEDDED |
2093 | #include "kabcore.moc" | 2095 | #include "kabcore.moc" |
2094 | #endif //KAB_EMBEDDED | 2096 | #endif //KAB_EMBEDDED |