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