author | zautrix <zautrix> | 2005-10-22 14:12:43 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-22 14:12:43 (UTC) |
commit | a72d70beb381b9cd6f2af301b52ca82cdcafb299 (patch) (unidiff) | |
tree | f5b068e80395821abb5717fb07757a17d805f770 /kaddressbook | |
parent | a72f3f3acfac791715a1c512fc4cc4c3facdbb62 (diff) | |
download | kdepimpi-a72d70beb381b9cd6f2af301b52ca82cdcafb299.zip kdepimpi-a72d70beb381b9cd6f2af301b52ca82cdcafb299.tar.gz kdepimpi-a72d70beb381b9cd6f2af301b52ca82cdcafb299.tar.bz2 |
fix
-rw-r--r-- | kaddressbook/kabcore.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 4e2523e..033e537 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -83,1584 +83,1588 @@ $Id$ | |||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | #include <kprefsdialog.h> | 99 | #include <kprefsdialog.h> |
100 | 100 | ||
101 | 101 | ||
102 | //#include <qlabel.h> | 102 | //#include <qlabel.h> |
103 | 103 | ||
104 | 104 | ||
105 | #ifndef DESKTOP_VERSION | 105 | #ifndef DESKTOP_VERSION |
106 | #include <qpe/ir.h> | 106 | #include <qpe/ir.h> |
107 | #include <qpe/qpemenubar.h> | 107 | #include <qpe/qpemenubar.h> |
108 | #include <qtopia/qcopenvelope_qws.h> | 108 | #include <qtopia/qcopenvelope_qws.h> |
109 | #else | 109 | #else |
110 | 110 | ||
111 | #include <qmenubar.h> | 111 | #include <qmenubar.h> |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | #endif // KAB_EMBEDDED | 114 | #endif // KAB_EMBEDDED |
115 | #include "kcmconfigs/kcmkabconfig.h" | 115 | #include "kcmconfigs/kcmkabconfig.h" |
116 | #include "kcmconfigs/kcmkdepimconfig.h" | 116 | #include "kcmconfigs/kcmkdepimconfig.h" |
117 | #include "kpimglobalprefs.h" | 117 | #include "kpimglobalprefs.h" |
118 | #include "externalapphandler.h" | 118 | #include "externalapphandler.h" |
119 | #include "xxportselectdialog.h" | 119 | #include "xxportselectdialog.h" |
120 | 120 | ||
121 | 121 | ||
122 | #include <kresources/selectdialog.h> | 122 | #include <kresources/selectdialog.h> |
123 | #include <kmessagebox.h> | 123 | #include <kmessagebox.h> |
124 | 124 | ||
125 | #include <picture.h> | 125 | #include <picture.h> |
126 | #include <resource.h> | 126 | #include <resource.h> |
127 | 127 | ||
128 | //US#include <qsplitter.h> | 128 | //US#include <qsplitter.h> |
129 | #include <qmap.h> | 129 | #include <qmap.h> |
130 | #include <qdir.h> | 130 | #include <qdir.h> |
131 | #include <qfile.h> | 131 | #include <qfile.h> |
132 | #include <qvbox.h> | 132 | #include <qvbox.h> |
133 | #include <qlayout.h> | 133 | #include <qlayout.h> |
134 | #include <qclipboard.h> | 134 | #include <qclipboard.h> |
135 | #include <qtextstream.h> | 135 | #include <qtextstream.h> |
136 | #include <qradiobutton.h> | 136 | #include <qradiobutton.h> |
137 | #include <qbuttongroup.h> | 137 | #include <qbuttongroup.h> |
138 | 138 | ||
139 | #include <libkdepim/categoryselectdialog.h> | 139 | #include <libkdepim/categoryselectdialog.h> |
140 | #include <libkdepim/categoryeditdialog.h> | 140 | #include <libkdepim/categoryeditdialog.h> |
141 | #include <kabc/vcardconverter.h> | 141 | #include <kabc/vcardconverter.h> |
142 | 142 | ||
143 | 143 | ||
144 | #include "addresseeutil.h" | 144 | #include "addresseeutil.h" |
145 | #include "undocmds.h" | 145 | #include "undocmds.h" |
146 | #include "addresseeeditordialog.h" | 146 | #include "addresseeeditordialog.h" |
147 | #include "viewmanager.h" | 147 | #include "viewmanager.h" |
148 | #include "details/detailsviewcontainer.h" | 148 | #include "details/detailsviewcontainer.h" |
149 | #include "kabprefs.h" | 149 | #include "kabprefs.h" |
150 | #include "xxportmanager.h" | 150 | #include "xxportmanager.h" |
151 | #include "incsearchwidget.h" | 151 | #include "incsearchwidget.h" |
152 | #include "jumpbuttonbar.h" | 152 | #include "jumpbuttonbar.h" |
153 | #include "extensionmanager.h" | 153 | #include "extensionmanager.h" |
154 | #include "addresseeconfig.h" | 154 | #include "addresseeconfig.h" |
155 | #include "nameeditdialog.h" | 155 | #include "nameeditdialog.h" |
156 | #include <kcmultidialog.h> | 156 | #include <kcmultidialog.h> |
157 | 157 | ||
158 | #ifdef _WIN32_ | 158 | #ifdef _WIN32_ |
159 | #ifdef _OL_IMPORT_ | 159 | #ifdef _OL_IMPORT_ |
160 | #include "kaimportoldialog.h" | 160 | #include "kaimportoldialog.h" |
161 | #endif | 161 | #endif |
162 | #else | 162 | #else |
163 | #include <unistd.h> | 163 | #include <unistd.h> |
164 | #endif | 164 | #endif |
165 | // sync includes | 165 | // sync includes |
166 | #include <libkdepim/ksyncprofile.h> | 166 | #include <libkdepim/ksyncprofile.h> |
167 | #include <libkdepim/ksyncprefsdialog.h> | 167 | #include <libkdepim/ksyncprefsdialog.h> |
168 | 168 | ||
169 | 169 | ||
170 | class KABCatPrefs : public QDialog | 170 | class KABCatPrefs : public QDialog |
171 | { | 171 | { |
172 | public: | 172 | public: |
173 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : | 173 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : |
174 | QDialog( parent, name, true ) | 174 | QDialog( parent, name, true ) |
175 | { | 175 | { |
176 | setCaption( i18n("Manage new Categories") ); | 176 | setCaption( i18n("Manage new Categories") ); |
177 | QVBoxLayout* lay = new QVBoxLayout( this ); | 177 | QVBoxLayout* lay = new QVBoxLayout( this ); |
178 | lay->setSpacing( 3 ); | 178 | lay->setSpacing( 3 ); |
179 | lay->setMargin( 3 ); | 179 | lay->setMargin( 3 ); |
180 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 180 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
181 | lay->addWidget( lab ); | 181 | lay->addWidget( lab ); |
182 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 182 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
183 | lay->addWidget( format ); | 183 | lay->addWidget( format ); |
184 | format->setExclusive ( true ) ; | 184 | format->setExclusive ( true ) ; |
185 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 185 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
186 | new QRadioButton(i18n("Remove from addressees"), format ); | 186 | new QRadioButton(i18n("Remove from addressees"), format ); |
187 | addCatBut->setChecked( true ); | 187 | addCatBut->setChecked( true ); |
188 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 188 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
189 | lay->addWidget( ok ); | 189 | lay->addWidget( ok ); |
190 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 190 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
191 | lay->addWidget( cancel ); | 191 | lay->addWidget( cancel ); |
192 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 192 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
193 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 193 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
194 | resize( 200, 200 ); | 194 | resize( 200, 200 ); |
195 | } | 195 | } |
196 | 196 | ||
197 | bool addCat() { return addCatBut->isChecked(); } | 197 | bool addCat() { return addCatBut->isChecked(); } |
198 | private: | 198 | private: |
199 | QRadioButton* addCatBut; | 199 | QRadioButton* addCatBut; |
200 | }; | 200 | }; |
201 | 201 | ||
202 | class KABFormatPrefs : public QDialog | 202 | class KABFormatPrefs : public QDialog |
203 | { | 203 | { |
204 | public: | 204 | public: |
205 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : | 205 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : |
206 | QDialog( parent, name, true ) | 206 | QDialog( parent, name, true ) |
207 | { | 207 | { |
208 | setCaption( i18n("Set formatted name") ); | 208 | setCaption( i18n("Set formatted name") ); |
209 | QVBoxLayout* lay = new QVBoxLayout( this ); | 209 | QVBoxLayout* lay = new QVBoxLayout( this ); |
210 | lay->setSpacing( 3 ); | 210 | lay->setSpacing( 3 ); |
211 | lay->setMargin( 3 ); | 211 | lay->setMargin( 3 ); |
212 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); | 212 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); |
213 | lay->addWidget( lab ); | 213 | lay->addWidget( lab ); |
214 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); | 214 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); |
215 | lay->addWidget( format ); | 215 | lay->addWidget( format ); |
216 | format->setExclusive ( true ) ; | 216 | format->setExclusive ( true ) ; |
217 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); | 217 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); |
218 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); | 218 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); |
219 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); | 219 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); |
220 | company = new QRadioButton(i18n("Organization: MI6"), format ); | 220 | company = new QRadioButton(i18n("Organization: MI6"), format ); |
221 | simple->setChecked( true ); | 221 | simple->setChecked( true ); |
222 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); | 222 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); |
223 | lay->addWidget( setCompany ); | 223 | lay->addWidget( setCompany ); |
224 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); | 224 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); |
225 | lay->addWidget( ok ); | 225 | lay->addWidget( ok ); |
226 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 226 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
227 | lay->addWidget( cancel ); | 227 | lay->addWidget( cancel ); |
228 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 228 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
229 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 229 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
230 | //resize( 200, 200 ); | 230 | //resize( 200, 200 ); |
231 | 231 | ||
232 | } | 232 | } |
233 | public: | 233 | public: |
234 | QRadioButton* simple, *full, *reverse, *company; | 234 | QRadioButton* simple, *full, *reverse, *company; |
235 | QCheckBox* setCompany; | 235 | QCheckBox* setCompany; |
236 | }; | 236 | }; |
237 | 237 | ||
238 | 238 | ||
239 | 239 | ||
240 | class KAex2phonePrefs : public QDialog | 240 | class KAex2phonePrefs : public QDialog |
241 | { | 241 | { |
242 | public: | 242 | public: |
243 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 243 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
244 | QDialog( parent, name, true ) | 244 | QDialog( parent, name, true ) |
245 | { | 245 | { |
246 | setCaption( i18n("Export to phone options") ); | 246 | setCaption( i18n("Export to phone options") ); |
247 | QVBoxLayout* lay = new QVBoxLayout( this ); | 247 | QVBoxLayout* lay = new QVBoxLayout( this ); |
248 | lay->setSpacing( 3 ); | 248 | lay->setSpacing( 3 ); |
249 | lay->setMargin( 3 ); | 249 | lay->setMargin( 3 ); |
250 | QLabel *lab; | 250 | QLabel *lab; |
251 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 251 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
252 | lab->setAlignment (AlignHCenter ); | 252 | lab->setAlignment (AlignHCenter ); |
253 | QHBox* temphb; | 253 | QHBox* temphb; |
254 | temphb = new QHBox( this ); | 254 | temphb = new QHBox( this ); |
255 | new QLabel( i18n("I/O device: "), temphb ); | 255 | new QLabel( i18n("I/O device: "), temphb ); |
256 | mPhoneDevice = new QLineEdit( temphb); | 256 | mPhoneDevice = new QLineEdit( temphb); |
257 | lay->addWidget( temphb ); | 257 | lay->addWidget( temphb ); |
258 | temphb = new QHBox( this ); | 258 | temphb = new QHBox( this ); |
259 | new QLabel( i18n("Connection: "), temphb ); | 259 | new QLabel( i18n("Connection: "), temphb ); |
260 | mPhoneConnection = new QLineEdit( temphb); | 260 | mPhoneConnection = new QLineEdit( temphb); |
261 | lay->addWidget( temphb ); | 261 | lay->addWidget( temphb ); |
262 | temphb = new QHBox( this ); | 262 | temphb = new QHBox( this ); |
263 | new QLabel( i18n("Model(opt.): "), temphb ); | 263 | new QLabel( i18n("Model(opt.): "), temphb ); |
264 | mPhoneModel = new QLineEdit( temphb); | 264 | mPhoneModel = new QLineEdit( temphb); |
265 | lay->addWidget( temphb ); | 265 | lay->addWidget( temphb ); |
266 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 266 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
267 | // lay->addWidget( mWriteToSim ); | 267 | // lay->addWidget( mWriteToSim ); |
268 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 268 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
269 | lab->setAlignment (AlignHCenter); | 269 | lab->setAlignment (AlignHCenter); |
270 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 270 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
271 | lay->addWidget( ok ); | 271 | lay->addWidget( ok ); |
272 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 272 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
273 | lay->addWidget( cancel ); | 273 | lay->addWidget( cancel ); |
274 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 274 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
275 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 275 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
276 | resize( 220, 240 ); | 276 | resize( 220, 240 ); |
277 | 277 | ||
278 | } | 278 | } |
279 | 279 | ||
280 | public: | 280 | public: |
281 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 281 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
282 | QCheckBox* mWriteToSim; | 282 | QCheckBox* mWriteToSim; |
283 | }; | 283 | }; |
284 | 284 | ||
285 | 285 | ||
286 | bool pasteWithNewUid = true; | 286 | bool pasteWithNewUid = true; |
287 | 287 | ||
288 | #ifdef KAB_EMBEDDED | 288 | #ifdef KAB_EMBEDDED |
289 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 289 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
290 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 290 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
291 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 291 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
292 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 292 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
293 | #else //KAB_EMBEDDED | 293 | #else //KAB_EMBEDDED |
294 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 294 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
295 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 295 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
296 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 296 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
297 | mReadWrite( readWrite ), mModified( false ) | 297 | mReadWrite( readWrite ), mModified( false ) |
298 | #endif //KAB_EMBEDDED | 298 | #endif //KAB_EMBEDDED |
299 | { | 299 | { |
300 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 300 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
301 | // syncManager->setBlockSave(false); | 301 | // syncManager->setBlockSave(false); |
302 | mIncSearchWidget = 0; | 302 | mIncSearchWidget = 0; |
303 | mMiniSplitter = 0; | 303 | mMiniSplitter = 0; |
304 | mExtensionBarSplitter = 0; | 304 | mExtensionBarSplitter = 0; |
305 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 305 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
306 | mAddressBook = KABC::StdAddressBook::selfNoLoad(); | 306 | mAddressBook = KABC::StdAddressBook::selfNoLoad(); |
307 | KABC::StdAddressBook::setAutomaticSave( false ); | 307 | KABC::StdAddressBook::setAutomaticSave( false ); |
308 | 308 | ||
309 | #ifndef KAB_EMBEDDED | 309 | #ifndef KAB_EMBEDDED |
310 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 310 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
311 | #endif //KAB_EMBEDDED | 311 | #endif //KAB_EMBEDDED |
312 | 312 | ||
313 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 313 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
314 | SLOT( addressBookChanged() ) ); | 314 | SLOT( addressBookChanged() ) ); |
315 | 315 | ||
316 | #if 0 | 316 | #if 0 |
317 | // LR moved to addressbook init method | 317 | // LR moved to addressbook init method |
318 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 318 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
319 | "X-Department", "KADDRESSBOOK" ); | 319 | "X-Department", "KADDRESSBOOK" ); |
320 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 320 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
321 | "X-Profession", "KADDRESSBOOK" ); | 321 | "X-Profession", "KADDRESSBOOK" ); |
322 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 322 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
323 | "X-AssistantsName", "KADDRESSBOOK" ); | 323 | "X-AssistantsName", "KADDRESSBOOK" ); |
324 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 324 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
325 | "X-ManagersName", "KADDRESSBOOK" ); | 325 | "X-ManagersName", "KADDRESSBOOK" ); |
326 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 326 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
327 | "X-SpousesName", "KADDRESSBOOK" ); | 327 | "X-SpousesName", "KADDRESSBOOK" ); |
328 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 328 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
329 | "X-Office", "KADDRESSBOOK" ); | 329 | "X-Office", "KADDRESSBOOK" ); |
330 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 330 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
331 | "X-IMAddress", "KADDRESSBOOK" ); | 331 | "X-IMAddress", "KADDRESSBOOK" ); |
332 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 332 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
333 | "X-Anniversary", "KADDRESSBOOK" ); | 333 | "X-Anniversary", "KADDRESSBOOK" ); |
334 | 334 | ||
335 | //US added this field to become compatible with Opie/qtopia addressbook | 335 | //US added this field to become compatible with Opie/qtopia addressbook |
336 | // values can be "female" or "male" or "". An empty field represents undefined. | 336 | // values can be "female" or "male" or "". An empty field represents undefined. |
337 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 337 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
338 | "X-Gender", "KADDRESSBOOK" ); | 338 | "X-Gender", "KADDRESSBOOK" ); |
339 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 339 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
340 | "X-Children", "KADDRESSBOOK" ); | 340 | "X-Children", "KADDRESSBOOK" ); |
341 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 341 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
342 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 342 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
343 | #endif | 343 | #endif |
344 | initGUI(); | 344 | initGUI(); |
345 | 345 | ||
346 | mIncSearchWidget->setFocus(); | 346 | mIncSearchWidget->setFocus(); |
347 | 347 | ||
348 | 348 | ||
349 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 349 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
350 | SLOT( setContactSelected( const QString& ) ) ); | 350 | SLOT( setContactSelected( const QString& ) ) ); |
351 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 351 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
352 | SLOT( executeContact( const QString& ) ) ); | 352 | SLOT( executeContact( const QString& ) ) ); |
353 | 353 | ||
354 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 354 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
355 | SLOT( deleteContacts( ) ) ); | 355 | SLOT( deleteContacts( ) ) ); |
356 | connect( mViewManager, SIGNAL( modified() ), | 356 | connect( mViewManager, SIGNAL( modified() ), |
357 | SLOT( setModified() ) ); | 357 | SLOT( setModified() ) ); |
358 | 358 | ||
359 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 359 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
360 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 360 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
361 | 361 | ||
362 | connect( mXXPortManager, SIGNAL( modified() ), | 362 | connect( mXXPortManager, SIGNAL( modified() ), |
363 | SLOT( setModified() ) ); | 363 | SLOT( setModified() ) ); |
364 | 364 | ||
365 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 365 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
366 | SLOT( incrementalSearchJump( const QString& ) ) ); | 366 | SLOT( incrementalSearchJump( const QString& ) ) ); |
367 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 367 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
368 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 368 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
369 | 369 | ||
370 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 370 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
371 | SLOT( sendMail( const QString& ) ) ); | 371 | SLOT( sendMail( const QString& ) ) ); |
372 | 372 | ||
373 | 373 | ||
374 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 374 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
375 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 375 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
376 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 376 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
377 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); | 377 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); |
378 | connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync())); | 378 | connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync())); |
379 | connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); | 379 | connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); |
380 | 380 | ||
381 | 381 | ||
382 | #ifndef KAB_EMBEDDED | 382 | #ifndef KAB_EMBEDDED |
383 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 383 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
384 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 384 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
385 | 385 | ||
386 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 386 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
387 | SLOT( browse( const QString& ) ) ); | 387 | SLOT( browse( const QString& ) ) ); |
388 | 388 | ||
389 | 389 | ||
390 | mAddressBookService = new KAddressBookService( this ); | 390 | mAddressBookService = new KAddressBookService( this ); |
391 | 391 | ||
392 | #endif //KAB_EMBEDDED | 392 | #endif //KAB_EMBEDDED |
393 | 393 | ||
394 | mMessageTimer = new QTimer( this ); | 394 | mMessageTimer = new QTimer( this ); |
395 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 395 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
396 | mEditorDialog = 0; | 396 | mEditorDialog = 0; |
397 | createAddresseeEditorDialog( this ); | 397 | createAddresseeEditorDialog( this ); |
398 | setModified( false ); | 398 | setModified( false ); |
399 | mBRdisabled = false; | 399 | mBRdisabled = false; |
400 | #ifndef DESKTOP_VERSION | 400 | #ifndef DESKTOP_VERSION |
401 | infrared = 0; | 401 | infrared = 0; |
402 | #endif | 402 | #endif |
403 | //toggleBeamReceive( ); | 403 | //toggleBeamReceive( ); |
404 | mMainWindow->toolBar()->show(); | 404 | mMainWindow->toolBar()->show(); |
405 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi | 405 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi |
406 | //QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 406 | //QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
407 | QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() )); | 407 | QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() )); |
408 | } | 408 | } |
409 | void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data ) | 409 | void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data ) |
410 | { | 410 | { |
411 | //qDebug("KO: QCOP start message received: %s ", cmsg.data() ); | 411 | //qDebug("KO: QCOP start message received: %s ", cmsg.data() ); |
412 | mCStringMess = cmsg; | 412 | mCStringMess = cmsg; |
413 | mByteData = data; | 413 | mByteData = data; |
414 | } | 414 | } |
415 | 415 | ||
416 | void KABCore::loadDataAfterStart() | 416 | void KABCore::loadDataAfterStart() |
417 | { | 417 | { |
418 | //qDebug("KABCore::loadDataAfterStart() "); | 418 | //qDebug("KABCore::loadDataAfterStart() "); |
419 | ((StdAddressBook*)mAddressBook)->init( true ); | 419 | ((StdAddressBook*)mAddressBook)->init( true ); |
420 | mViewManager->refreshView(); | 420 | mViewManager->refreshView(); |
421 | 421 | ||
422 | #ifndef DESKTOP_VERSION | 422 | #ifndef DESKTOP_VERSION |
423 | disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); | 423 | disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); |
424 | 424 | ||
425 | QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 425 | QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
426 | if ( !mCStringMess.isEmpty() ) | 426 | if ( !mCStringMess.isEmpty() ) |
427 | ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); | 427 | ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); |
428 | #endif | 428 | #endif |
429 | // QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 429 | // QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
430 | setCaptionBack(); | 430 | setCaptionBack(); |
431 | } | 431 | } |
432 | void KABCore::updateToolBar() | 432 | void KABCore::updateToolBar() |
433 | { | 433 | { |
434 | static int iii = 0; | 434 | static int iii = 0; |
435 | ++iii; | 435 | ++iii; |
436 | mMainWindow->toolBar()->repaintMe(); | 436 | mMainWindow->toolBar()->repaintMe(); |
437 | if ( iii < 4 ) | 437 | if ( iii < 4 ) |
438 | QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); | 438 | QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); |
439 | } | 439 | } |
440 | KABCore::~KABCore() | 440 | KABCore::~KABCore() |
441 | { | 441 | { |
442 | // save(); | 442 | // save(); |
443 | //saveSettings(); | 443 | //saveSettings(); |
444 | //KABPrefs::instance()->writeConfig(); | 444 | //KABPrefs::instance()->writeConfig(); |
445 | delete AddresseeConfig::instance(); | 445 | delete AddresseeConfig::instance(); |
446 | mAddressBook = 0; | 446 | mAddressBook = 0; |
447 | KABC::StdAddressBook::close(); | 447 | KABC::StdAddressBook::close(); |
448 | 448 | ||
449 | delete syncManager; | 449 | delete syncManager; |
450 | #ifndef DESKTOP_VERSION | 450 | #ifndef DESKTOP_VERSION |
451 | if ( infrared ) | 451 | if ( infrared ) |
452 | delete infrared; | 452 | delete infrared; |
453 | #endif | 453 | #endif |
454 | } | 454 | } |
455 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 455 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
456 | { | 456 | { |
457 | //qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 457 | //qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
458 | if ( cmsg == "setDocument(QString)" ) { | 458 | if ( cmsg == "setDocument(QString)" ) { |
459 | QDataStream stream( data, IO_ReadOnly ); | 459 | QDataStream stream( data, IO_ReadOnly ); |
460 | QString fileName; | 460 | QString fileName; |
461 | stream >> fileName; | 461 | stream >> fileName; |
462 | recieve( fileName ); | 462 | recieve( fileName ); |
463 | return; | 463 | return; |
464 | } | 464 | } |
465 | } | 465 | } |
466 | void KABCore::toggleBeamReceive( ) | 466 | void KABCore::toggleBeamReceive( ) |
467 | { | 467 | { |
468 | if ( mBRdisabled ) | 468 | if ( mBRdisabled ) |
469 | return; | 469 | return; |
470 | #ifndef DESKTOP_VERSION | 470 | #ifndef DESKTOP_VERSION |
471 | if ( infrared ) { | 471 | if ( infrared ) { |
472 | qDebug("KA: AB disable BeamReceive "); | 472 | qDebug("KA: AB disable BeamReceive "); |
473 | delete infrared; | 473 | delete infrared; |
474 | infrared = 0; | 474 | infrared = 0; |
475 | mActionBR->setChecked(false); | 475 | mActionBR->setChecked(false); |
476 | return; | 476 | return; |
477 | } | 477 | } |
478 | qDebug("KA: AB enable BeamReceive "); | 478 | qDebug("KA: AB enable BeamReceive "); |
479 | mActionBR->setChecked(true); | 479 | mActionBR->setChecked(true); |
480 | 480 | ||
481 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 481 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
482 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 482 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
483 | #endif | 483 | #endif |
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | void KABCore::disableBR(bool b) | 487 | void KABCore::disableBR(bool b) |
488 | { | 488 | { |
489 | #ifndef DESKTOP_VERSION | 489 | #ifndef DESKTOP_VERSION |
490 | if ( b ) { | 490 | if ( b ) { |
491 | if ( infrared ) { | 491 | if ( infrared ) { |
492 | toggleBeamReceive( ); | 492 | toggleBeamReceive( ); |
493 | } | 493 | } |
494 | mBRdisabled = true; | 494 | mBRdisabled = true; |
495 | } else { | 495 | } else { |
496 | if ( mBRdisabled ) { | 496 | if ( mBRdisabled ) { |
497 | mBRdisabled = false; | 497 | mBRdisabled = false; |
498 | //toggleBeamReceive( ); | 498 | //toggleBeamReceive( ); |
499 | } | 499 | } |
500 | } | 500 | } |
501 | #endif | 501 | #endif |
502 | 502 | ||
503 | } | 503 | } |
504 | void KABCore::recieve( QString fn ) | 504 | void KABCore::recieve( QString fn ) |
505 | { | 505 | { |
506 | //qDebug("KABCore::recieve "); | 506 | //qDebug("KABCore::recieve "); |
507 | int count = mAddressBook->importFromFile( fn, true ); | 507 | int count = mAddressBook->importFromFile( fn, true ); |
508 | if ( count ) | 508 | if ( count ) |
509 | setModified( true ); | 509 | setModified( true ); |
510 | mViewManager->refreshView(); | 510 | mViewManager->refreshView(); |
511 | message(i18n("%1 contact(s) received!").arg( count )); | 511 | message(i18n("%1 contact(s) received!").arg( count )); |
512 | topLevelWidget()->showMaximized(); | 512 | topLevelWidget()->showMaximized(); |
513 | topLevelWidget()->raise(); | 513 | topLevelWidget()->raise(); |
514 | } | 514 | } |
515 | void KABCore::restoreSettings() | 515 | void KABCore::restoreSettings() |
516 | { | 516 | { |
517 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 517 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
518 | 518 | ||
519 | bool state; | 519 | bool state; |
520 | 520 | ||
521 | if (mMultipleViewsAtOnce) | 521 | if (mMultipleViewsAtOnce) |
522 | state = KABPrefs::instance()->mDetailsPageVisible; | 522 | state = KABPrefs::instance()->mDetailsPageVisible; |
523 | else | 523 | else |
524 | state = false; | 524 | state = false; |
525 | 525 | ||
526 | mActionDetails->setChecked( state ); | 526 | mActionDetails->setChecked( state ); |
527 | setDetailsVisible( state ); | 527 | setDetailsVisible( state ); |
528 | 528 | ||
529 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 529 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
530 | 530 | ||
531 | mActionJumpBar->setChecked( state ); | 531 | mActionJumpBar->setChecked( state ); |
532 | setJumpButtonBarVisible( state ); | 532 | setJumpButtonBarVisible( state ); |
533 | /*US | 533 | /*US |
534 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 534 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
535 | if ( splitterSize.count() == 0 ) { | 535 | if ( splitterSize.count() == 0 ) { |
536 | splitterSize.append( width() / 2 ); | 536 | splitterSize.append( width() / 2 ); |
537 | splitterSize.append( width() / 2 ); | 537 | splitterSize.append( width() / 2 ); |
538 | } | 538 | } |
539 | mMiniSplitter->setSizes( splitterSize ); | 539 | mMiniSplitter->setSizes( splitterSize ); |
540 | if ( mExtensionBarSplitter ) { | 540 | if ( mExtensionBarSplitter ) { |
541 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 541 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
542 | if ( splitterSize.count() == 0 ) { | 542 | if ( splitterSize.count() == 0 ) { |
543 | splitterSize.append( width() / 2 ); | 543 | splitterSize.append( width() / 2 ); |
544 | splitterSize.append( width() / 2 ); | 544 | splitterSize.append( width() / 2 ); |
545 | } | 545 | } |
546 | mExtensionBarSplitter->setSizes( splitterSize ); | 546 | mExtensionBarSplitter->setSizes( splitterSize ); |
547 | 547 | ||
548 | } | 548 | } |
549 | */ | 549 | */ |
550 | mViewManager->restoreSettings(); | 550 | mViewManager->restoreSettings(); |
551 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 551 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
552 | mExtensionManager->restoreSettings(); | 552 | mExtensionManager->restoreSettings(); |
553 | #ifdef DESKTOP_VERSION | 553 | #ifdef DESKTOP_VERSION |
554 | int wid = width(); | 554 | int wid = width(); |
555 | if ( wid < 10 ) | 555 | if ( wid < 10 ) |
556 | wid = 400; | 556 | wid = 400; |
557 | #else | 557 | #else |
558 | int wid = QApplication::desktop()->width(); | 558 | int wid = QApplication::desktop()->width(); |
559 | if ( wid < 640 ) | 559 | if ( wid < 640 ) |
560 | wid = QApplication::desktop()->height(); | 560 | wid = QApplication::desktop()->height(); |
561 | #endif | 561 | #endif |
562 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 562 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
563 | if ( true /*splitterSize.count() == 0*/ ) { | 563 | if ( true /*splitterSize.count() == 0*/ ) { |
564 | splitterSize.append( wid / 2 ); | 564 | splitterSize.append( wid / 2 ); |
565 | splitterSize.append( wid / 2 ); | 565 | splitterSize.append( wid / 2 ); |
566 | } | 566 | } |
567 | mMiniSplitter->setSizes( splitterSize ); | 567 | mMiniSplitter->setSizes( splitterSize ); |
568 | if ( mExtensionBarSplitter ) { | 568 | if ( mExtensionBarSplitter ) { |
569 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 569 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
570 | if ( true /*splitterSize.count() == 0*/ ) { | 570 | if ( true /*splitterSize.count() == 0*/ ) { |
571 | splitterSize.append( wid / 2 ); | 571 | splitterSize.append( wid / 2 ); |
572 | splitterSize.append( wid / 2 ); | 572 | splitterSize.append( wid / 2 ); |
573 | } | 573 | } |
574 | mExtensionBarSplitter->setSizes( splitterSize ); | 574 | mExtensionBarSplitter->setSizes( splitterSize ); |
575 | 575 | ||
576 | } | 576 | } |
577 | #ifdef DESKTOP_VERSION | 577 | #ifdef DESKTOP_VERSION |
578 | KConfig *config = KABPrefs::instance()->getConfig(); | 578 | KConfig *config = KABPrefs::instance()->getConfig(); |
579 | config->setGroup("WidgetLayout"); | 579 | config->setGroup("WidgetLayout"); |
580 | QStringList list; | 580 | QStringList list; |
581 | list = config->readListEntry("MainLayout"); | 581 | list = config->readListEntry("MainLayout"); |
582 | int x,y,w,h; | 582 | int x,y,w,h; |
583 | if ( ! list.isEmpty() ) { | 583 | if ( ! list.isEmpty() ) { |
584 | x = list[0].toInt(); | 584 | x = list[0].toInt(); |
585 | y = list[1].toInt(); | 585 | y = list[1].toInt(); |
586 | w = list[2].toInt(); | 586 | w = list[2].toInt(); |
587 | h = list[3].toInt(); | 587 | h = list[3].toInt(); |
588 | KApplication::testCoords( &x,&y,&w,&h ); | 588 | KApplication::testCoords( &x,&y,&w,&h ); |
589 | topLevelWidget()->setGeometry(x,y,w,h); | 589 | topLevelWidget()->setGeometry(x,y,w,h); |
590 | 590 | ||
591 | } else { | 591 | } else { |
592 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 592 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
593 | } | 593 | } |
594 | #endif | 594 | #endif |
595 | } | 595 | } |
596 | 596 | ||
597 | void KABCore::saveSettings() | 597 | void KABCore::saveSettings() |
598 | { | 598 | { |
599 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 599 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
600 | if ( mExtensionBarSplitter ) | 600 | if ( mExtensionBarSplitter ) |
601 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 601 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
602 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 602 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
603 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 603 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
604 | #ifndef KAB_EMBEDDED | 604 | #ifndef KAB_EMBEDDED |
605 | 605 | ||
606 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 606 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
607 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 607 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
608 | #endif //KAB_EMBEDDED | 608 | #endif //KAB_EMBEDDED |
609 | mExtensionManager->saveSettings(); | 609 | mExtensionManager->saveSettings(); |
610 | mViewManager->saveSettings(); | 610 | mViewManager->saveSettings(); |
611 | 611 | ||
612 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 612 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
613 | 613 | ||
614 | KABPrefs::instance()->writeConfig(); | 614 | KABPrefs::instance()->writeConfig(); |
615 | //qDebug("KA: KABCore::saveSettings() "); | 615 | //qDebug("KA: KABCore::saveSettings() "); |
616 | } | 616 | } |
617 | 617 | ||
618 | KABC::AddressBook *KABCore::addressBook() const | 618 | KABC::AddressBook *KABCore::addressBook() const |
619 | { | 619 | { |
620 | return mAddressBook; | 620 | return mAddressBook; |
621 | } | 621 | } |
622 | 622 | ||
623 | KConfig *KABCore::config() | 623 | KConfig *KABCore::config() |
624 | { | 624 | { |
625 | #ifndef KAB_EMBEDDED | 625 | #ifndef KAB_EMBEDDED |
626 | return KABPrefs::instance()->config(); | 626 | return KABPrefs::instance()->config(); |
627 | #else //KAB_EMBEDDED | 627 | #else //KAB_EMBEDDED |
628 | return KABPrefs::instance()->getConfig(); | 628 | return KABPrefs::instance()->getConfig(); |
629 | #endif //KAB_EMBEDDED | 629 | #endif //KAB_EMBEDDED |
630 | } | 630 | } |
631 | 631 | ||
632 | KActionCollection *KABCore::actionCollection() const | 632 | KActionCollection *KABCore::actionCollection() const |
633 | { | 633 | { |
634 | return mGUIClient->actionCollection(); | 634 | return mGUIClient->actionCollection(); |
635 | } | 635 | } |
636 | 636 | ||
637 | KABC::Field *KABCore::currentSearchField() const | 637 | KABC::Field *KABCore::currentSearchField() const |
638 | { | 638 | { |
639 | if (mIncSearchWidget) | 639 | if (mIncSearchWidget) |
640 | return mIncSearchWidget->currentField(); | 640 | return mIncSearchWidget->currentField(); |
641 | else | 641 | else |
642 | return 0; | 642 | return 0; |
643 | } | 643 | } |
644 | 644 | ||
645 | QStringList KABCore::selectedUIDs() const | 645 | QStringList KABCore::selectedUIDs() const |
646 | { | 646 | { |
647 | return mViewManager->selectedUids(); | 647 | return mViewManager->selectedUids(); |
648 | } | 648 | } |
649 | 649 | ||
650 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 650 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
651 | { | 651 | { |
652 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 652 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
653 | 653 | ||
654 | QPtrList<KRES::Resource> kresResources; | 654 | QPtrList<KRES::Resource> kresResources; |
655 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 655 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
656 | KABC::Resource *resource; | 656 | KABC::Resource *resource; |
657 | while ( ( resource = resIt.current() ) != 0 ) { | 657 | while ( ( resource = resIt.current() ) != 0 ) { |
658 | ++resIt; | 658 | ++resIt; |
659 | if ( !resource->readOnly() ) { | 659 | if ( !resource->readOnly() ) { |
660 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 660 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
661 | if ( res ) | 661 | if ( res ) |
662 | kresResources.append( res ); | 662 | kresResources.append( res ); |
663 | } | 663 | } |
664 | } | 664 | } |
665 | 665 | ||
666 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 666 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
667 | return static_cast<KABC::Resource*>( res ); | 667 | return static_cast<KABC::Resource*>( res ); |
668 | } | 668 | } |
669 | 669 | ||
670 | #ifndef KAB_EMBEDDED | 670 | #ifndef KAB_EMBEDDED |
671 | KAboutData *KABCore::createAboutData() | 671 | KAboutData *KABCore::createAboutData() |
672 | #else //KAB_EMBEDDED | 672 | #else //KAB_EMBEDDED |
673 | void KABCore::createAboutData() | 673 | void KABCore::createAboutData() |
674 | #endif //KAB_EMBEDDED | 674 | #endif //KAB_EMBEDDED |
675 | { | 675 | { |
676 | 676 | ||
677 | 677 | ||
678 | QString version; | 678 | QString version; |
679 | #include <../version> | 679 | #include <../version> |
680 | QMessageBox::about( this, "About KAddressbook/Pi", | 680 | QMessageBox::about( this, "About KAddressbook/Pi", |
681 | "KAddressbook/Platform-independent\n" | 681 | "KAddressbook/Platform-independent\n" |
682 | "(KA/Pi) " +version + " - " + | 682 | "(KA/Pi) " +version + " - " + |
683 | #ifdef DESKTOP_VERSION | 683 | #ifdef DESKTOP_VERSION |
684 | "Desktop Edition\n" | 684 | "Desktop Edition\n" |
685 | #else | 685 | #else |
686 | "PDA-Edition\n" | 686 | "PDA-Edition\n" |
687 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 687 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
688 | #endif | 688 | #endif |
689 | 689 | ||
690 | "(c) 2004 Ulf Schenk\n" | 690 | "(c) 2004 Ulf Schenk\n" |
691 | "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" | 691 | "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" |
692 | "(c) 1997-2003, The KDE PIM Team\n" | 692 | "(c) 1997-2003, The KDE PIM Team\n" |
693 | "Tobias Koenig Maintainer\n" | 693 | "Tobias Koenig Maintainer\n" |
694 | "Don Sanders Original author\n" | 694 | "Don Sanders Original author\n" |
695 | "Cornelius Schumacher Co-maintainer\n" | 695 | "Cornelius Schumacher Co-maintainer\n" |
696 | "Mike Pilone GUI and framework redesign\n" | 696 | "Mike Pilone GUI and framework redesign\n" |
697 | "Greg Stern DCOP interface\n" | 697 | "Greg Stern DCOP interface\n" |
698 | "Mark Westcot Contact pinning\n" | 698 | "Mark Westcot Contact pinning\n" |
699 | "Michel Boyer de la Giroday LDAP Lookup\n" | 699 | "Michel Boyer de la Giroday LDAP Lookup\n" |
700 | "Steffen Hansen LDAP Lookup" | 700 | "Steffen Hansen LDAP Lookup" |
701 | #ifdef _WIN32_ | 701 | #ifdef _WIN32_ |
702 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 702 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
703 | #endif | 703 | #endif |
704 | ); | 704 | ); |
705 | } | 705 | } |
706 | 706 | ||
707 | void KABCore::setContactSelected( const QString &uid ) | 707 | void KABCore::setContactSelected( const QString &uid ) |
708 | { | 708 | { |
709 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 709 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
710 | if ( !mDetails->isHidden() ) | 710 | if ( !mDetails->isHidden() ) |
711 | mDetails->setAddressee( addr ); | 711 | mDetails->setAddressee( addr ); |
712 | 712 | ||
713 | if ( !addr.isEmpty() ) { | 713 | if ( !addr.isEmpty() ) { |
714 | emit contactSelected( addr.formattedName() ); | 714 | emit contactSelected( addr.formattedName() ); |
715 | KABC::Picture pic = addr.photo(); | 715 | KABC::Picture pic = addr.photo(); |
716 | if ( pic.isIntern() ) { | 716 | if ( pic.isIntern() ) { |
717 | //US emit contactSelected( pic.data() ); | 717 | //US emit contactSelected( pic.data() ); |
718 | //US instead use: | 718 | //US instead use: |
719 | QPixmap px; | 719 | QPixmap px; |
720 | if (pic.data().isNull() != true) | 720 | if (pic.data().isNull() != true) |
721 | { | 721 | { |
722 | px.convertFromImage(pic.data()); | 722 | px.convertFromImage(pic.data()); |
723 | } | 723 | } |
724 | 724 | ||
725 | emit contactSelected( px ); | 725 | emit contactSelected( px ); |
726 | } | 726 | } |
727 | } | 727 | } |
728 | 728 | ||
729 | 729 | ||
730 | mExtensionManager->setSelectionChanged(); | 730 | mExtensionManager->setSelectionChanged(); |
731 | 731 | ||
732 | // update the actions | 732 | // update the actions |
733 | bool selected = !uid.isEmpty(); | 733 | bool selected = !uid.isEmpty(); |
734 | 734 | ||
735 | if ( mReadWrite ) { | 735 | if ( mReadWrite ) { |
736 | mActionCut->setEnabled( selected ); | 736 | mActionCut->setEnabled( selected ); |
737 | mActionPaste->setEnabled( selected ); | 737 | mActionPaste->setEnabled( selected ); |
738 | } | 738 | } |
739 | 739 | ||
740 | mActionCopy->setEnabled( selected ); | 740 | mActionCopy->setEnabled( selected ); |
741 | mActionDelete->setEnabled( selected ); | 741 | mActionDelete->setEnabled( selected ); |
742 | mActionEditAddressee->setEnabled( selected ); | 742 | mActionEditAddressee->setEnabled( selected ); |
743 | mActionMail->setEnabled( selected ); | 743 | mActionMail->setEnabled( selected ); |
744 | mActionMailVCard->setEnabled( selected ); | 744 | mActionMailVCard->setEnabled( selected ); |
745 | //if (mActionBeam) | 745 | //if (mActionBeam) |
746 | //mActionBeam->setEnabled( selected ); | 746 | //mActionBeam->setEnabled( selected ); |
747 | mActionWhoAmI->setEnabled( selected ); | 747 | mActionWhoAmI->setEnabled( selected ); |
748 | } | 748 | } |
749 | 749 | ||
750 | void KABCore::sendMail() | 750 | void KABCore::sendMail() |
751 | { | 751 | { |
752 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 752 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
753 | } | 753 | } |
754 | 754 | ||
755 | void KABCore::sendMail( const QString& emaillist ) | 755 | void KABCore::sendMail( const QString& emaillist ) |
756 | { | 756 | { |
757 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 757 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
758 | if (emaillist.contains(",") > 0) | 758 | if (emaillist.contains(",") > 0) |
759 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 759 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
760 | else | 760 | else |
761 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 761 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
762 | } | 762 | } |
763 | 763 | ||
764 | 764 | ||
765 | 765 | ||
766 | void KABCore::mailVCard() | 766 | void KABCore::mailVCard() |
767 | { | 767 | { |
768 | QStringList uids = mViewManager->selectedUids(); | 768 | QStringList uids = mViewManager->selectedUids(); |
769 | if ( !uids.isEmpty() ) | 769 | if ( !uids.isEmpty() ) |
770 | mailVCard( uids ); | 770 | mailVCard( uids ); |
771 | } | 771 | } |
772 | 772 | ||
773 | void KABCore::mailVCard( const QStringList& uids ) | 773 | void KABCore::mailVCard( const QStringList& uids ) |
774 | { | 774 | { |
775 | QStringList urls; | 775 | QStringList urls; |
776 | 776 | ||
777 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 777 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
778 | 778 | ||
779 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 779 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
780 | 780 | ||
781 | 781 | ||
782 | 782 | ||
783 | QDir().mkdir( dirName, true ); | 783 | QDir().mkdir( dirName, true ); |
784 | 784 | ||
785 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 785 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
786 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 786 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
787 | 787 | ||
788 | if ( a.isEmpty() ) | 788 | if ( a.isEmpty() ) |
789 | continue; | 789 | continue; |
790 | 790 | ||
791 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 791 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
792 | 792 | ||
793 | QString fileName = dirName + "/" + name; | 793 | QString fileName = dirName + "/" + name; |
794 | 794 | ||
795 | QFile outFile(fileName); | 795 | QFile outFile(fileName); |
796 | 796 | ||
797 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 797 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
798 | KABC::VCardConverter converter; | 798 | KABC::VCardConverter converter; |
799 | QString vcard; | 799 | QString vcard; |
800 | 800 | ||
801 | converter.addresseeToVCard( a, vcard ); | 801 | converter.addresseeToVCard( a, vcard ); |
802 | 802 | ||
803 | QTextStream t( &outFile ); // use a text stream | 803 | QTextStream t( &outFile ); // use a text stream |
804 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 804 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
805 | t << vcard; | 805 | t << vcard; |
806 | 806 | ||
807 | outFile.close(); | 807 | outFile.close(); |
808 | 808 | ||
809 | urls.append( fileName ); | 809 | urls.append( fileName ); |
810 | } | 810 | } |
811 | } | 811 | } |
812 | 812 | ||
813 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 813 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
814 | 814 | ||
815 | 815 | ||
816 | /*US | 816 | /*US |
817 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 817 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
818 | QString::null, // subject | 818 | QString::null, // subject |
819 | QString::null, // body | 819 | QString::null, // body |
820 | QString::null, | 820 | QString::null, |
821 | urls ); // attachments | 821 | urls ); // attachments |
822 | */ | 822 | */ |
823 | 823 | ||
824 | } | 824 | } |
825 | 825 | ||
826 | /** | 826 | /** |
827 | Beams the "WhoAmI contact. | 827 | Beams the "WhoAmI contact. |
828 | */ | 828 | */ |
829 | void KABCore::beamMySelf() | 829 | void KABCore::beamMySelf() |
830 | { | 830 | { |
831 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 831 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
832 | if (!a.isEmpty()) | 832 | if (!a.isEmpty()) |
833 | { | 833 | { |
834 | QStringList uids; | 834 | QStringList uids; |
835 | uids << a.uid(); | 835 | uids << a.uid(); |
836 | 836 | ||
837 | beamVCard(uids); | 837 | beamVCard(uids); |
838 | } else { | 838 | } else { |
839 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 839 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
840 | 840 | ||
841 | 841 | ||
842 | } | 842 | } |
843 | } | 843 | } |
844 | void KABCore::updateMainWindow() | 844 | void KABCore::updateMainWindow() |
845 | { | 845 | { |
846 | mMainWindow->showMaximized(); | 846 | mMainWindow->showMaximized(); |
847 | //mMainWindow->repaint(); | 847 | //mMainWindow->repaint(); |
848 | } | 848 | } |
849 | void KABCore::resizeEvent(QResizeEvent* e ) | 849 | void KABCore::resizeEvent(QResizeEvent* e ) |
850 | { | 850 | { |
851 | if ( !mMiniSplitter ) | 851 | if ( !mMiniSplitter ) { |
852 | QWidget::resizeEvent( e ); | ||
852 | return; | 853 | return; |
854 | } | ||
855 | #ifndef DESKTOP_VERSION | ||
853 | static int desktop_width = 0; | 856 | static int desktop_width = 0; |
854 | //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() ); | 857 | //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() ); |
855 | if ( desktop_width != QApplication::desktop()->width() ) | 858 | if ( desktop_width != QApplication::desktop()->width() ) |
856 | if ( QApplication::desktop()->width() >= 480 ) { | 859 | if ( QApplication::desktop()->width() >= 480 ) { |
857 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 860 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
858 | //qDebug("640 "); | 861 | //qDebug("640 "); |
859 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 862 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
860 | //qDebug("switch V->H "); | 863 | //qDebug("switch V->H "); |
861 | mMiniSplitter->setOrientation( Qt::Horizontal); | 864 | mMiniSplitter->setOrientation( Qt::Horizontal); |
862 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 865 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
863 | } | 866 | } |
864 | if ( QApplication::desktop()->width() <= 640 ) { | 867 | if ( QApplication::desktop()->width() <= 640 ) { |
865 | bool shot = mMainWindow->isVisible(); | 868 | bool shot = mMainWindow->isVisible(); |
866 | mMainWindow->showMinimized(); | 869 | mMainWindow->showMinimized(); |
867 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 870 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
868 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 871 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
869 | if ( mIncSearchWidget ) | 872 | if ( mIncSearchWidget ) |
870 | mIncSearchWidget->setSize(); | 873 | mIncSearchWidget->setSize(); |
871 | if ( shot ) | 874 | if ( shot ) |
872 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 875 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
873 | } | 876 | } |
874 | 877 | ||
875 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 878 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
876 | //qDebug("480 "); | 879 | //qDebug("480 "); |
877 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 880 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
878 | //qDebug("switch H->V "); | 881 | //qDebug("switch H->V "); |
879 | mMiniSplitter->setOrientation( Qt::Vertical ); | 882 | mMiniSplitter->setOrientation( Qt::Vertical ); |
880 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 883 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
881 | } | 884 | } |
882 | if ( QApplication::desktop()->width() <= 640 ) { | 885 | if ( QApplication::desktop()->width() <= 640 ) { |
883 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 886 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
884 | bool shot = mMainWindow->isVisible(); | 887 | bool shot = mMainWindow->isVisible(); |
885 | mMainWindow->showMinimized(); | 888 | mMainWindow->showMinimized(); |
886 | if ( KABPrefs::instance()->mHideSearchOnSwitch ) { | 889 | if ( KABPrefs::instance()->mHideSearchOnSwitch ) { |
887 | if ( mIncSearchWidget ) { | 890 | if ( mIncSearchWidget ) { |
888 | mIncSearchWidget->setSize(); | 891 | mIncSearchWidget->setSize(); |
889 | } | 892 | } |
890 | } else { | 893 | } else { |
891 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 894 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
892 | } | 895 | } |
893 | if ( shot ) | 896 | if ( shot ) |
894 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 897 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
895 | } | 898 | } |
896 | } | 899 | } |
897 | } | 900 | } |
898 | desktop_width = QApplication::desktop()->width(); | 901 | desktop_width = QApplication::desktop()->width(); |
902 | #endif | ||
899 | QWidget::resizeEvent( e ); | 903 | QWidget::resizeEvent( e ); |
900 | 904 | ||
901 | } | 905 | } |
902 | void KABCore::export2phone() | 906 | void KABCore::export2phone() |
903 | { | 907 | { |
904 | 908 | ||
905 | QStringList uids; | 909 | QStringList uids; |
906 | XXPortSelectDialog dlg( this, false, this ); | 910 | XXPortSelectDialog dlg( this, false, this ); |
907 | if ( dlg.exec() ) | 911 | if ( dlg.exec() ) |
908 | uids = dlg.uids(); | 912 | uids = dlg.uids(); |
909 | else | 913 | else |
910 | return; | 914 | return; |
911 | if ( uids.isEmpty() ) | 915 | if ( uids.isEmpty() ) |
912 | return; | 916 | return; |
913 | // qDebug("count %d ", uids.count()); | 917 | // qDebug("count %d ", uids.count()); |
914 | 918 | ||
915 | KAex2phonePrefs ex2phone; | 919 | KAex2phonePrefs ex2phone; |
916 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 920 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
917 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 921 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
918 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 922 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
919 | 923 | ||
920 | if ( !ex2phone.exec() ) { | 924 | if ( !ex2phone.exec() ) { |
921 | return; | 925 | return; |
922 | } | 926 | } |
923 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 927 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
924 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 928 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
925 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 929 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
926 | 930 | ||
927 | 931 | ||
928 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 932 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
929 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 933 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
930 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 934 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
931 | 935 | ||
932 | QString fileName = getPhoneFile(); | 936 | QString fileName = getPhoneFile(); |
933 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 937 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
934 | return; | 938 | return; |
935 | 939 | ||
936 | message(i18n("Exporting to phone...")); | 940 | message(i18n("Exporting to phone...")); |
937 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 941 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
938 | 942 | ||
939 | } | 943 | } |
940 | QString KABCore::getPhoneFile() | 944 | QString KABCore::getPhoneFile() |
941 | { | 945 | { |
942 | #ifdef DESKTOP_VERSION | 946 | #ifdef DESKTOP_VERSION |
943 | return locateLocal("tmp", "phonefile.vcf"); | 947 | return locateLocal("tmp", "phonefile.vcf"); |
944 | #else | 948 | #else |
945 | return "/tmp/phonefile.vcf"; | 949 | return "/tmp/phonefile.vcf"; |
946 | #endif | 950 | #endif |
947 | 951 | ||
948 | } | 952 | } |
949 | void KABCore::writeToPhone( ) | 953 | void KABCore::writeToPhone( ) |
950 | { | 954 | { |
951 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 955 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
952 | message(i18n("Export to phone finished!")); | 956 | message(i18n("Export to phone finished!")); |
953 | else | 957 | else |
954 | qDebug(i18n("KA: Error exporting to phone")); | 958 | qDebug(i18n("KA: Error exporting to phone")); |
955 | } | 959 | } |
956 | void KABCore::beamVCard() | 960 | void KABCore::beamVCard() |
957 | { | 961 | { |
958 | QStringList uids; | 962 | QStringList uids; |
959 | XXPortSelectDialog dlg( this, false, this ); | 963 | XXPortSelectDialog dlg( this, false, this ); |
960 | if ( dlg.exec() ) | 964 | if ( dlg.exec() ) |
961 | uids = dlg.uids(); | 965 | uids = dlg.uids(); |
962 | else | 966 | else |
963 | return; | 967 | return; |
964 | if ( uids.isEmpty() ) | 968 | if ( uids.isEmpty() ) |
965 | return; | 969 | return; |
966 | beamVCard( uids ); | 970 | beamVCard( uids ); |
967 | } | 971 | } |
968 | 972 | ||
969 | 973 | ||
970 | void KABCore::beamVCard(const QStringList& uids) | 974 | void KABCore::beamVCard(const QStringList& uids) |
971 | { | 975 | { |
972 | 976 | ||
973 | // LR: we should use the /tmp dir on the Zaurus, | 977 | // LR: we should use the /tmp dir on the Zaurus, |
974 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 978 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
975 | 979 | ||
976 | #ifdef DESKTOP_VERSION | 980 | #ifdef DESKTOP_VERSION |
977 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 981 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
978 | #else | 982 | #else |
979 | QString fileName = "/tmp/kapibeamfile.vcf"; | 983 | QString fileName = "/tmp/kapibeamfile.vcf"; |
980 | #endif | 984 | #endif |
981 | 985 | ||
982 | KABC::VCardConverter converter; | 986 | KABC::VCardConverter converter; |
983 | QString description; | 987 | QString description; |
984 | QString datastream; | 988 | QString datastream; |
985 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 989 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
986 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 990 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
987 | 991 | ||
988 | if ( a.isEmpty() ) | 992 | if ( a.isEmpty() ) |
989 | continue; | 993 | continue; |
990 | 994 | ||
991 | if (description.isEmpty()) | 995 | if (description.isEmpty()) |
992 | description = a.formattedName(); | 996 | description = a.formattedName(); |
993 | 997 | ||
994 | QString vcard; | 998 | QString vcard; |
995 | converter.addresseeToVCard( a, vcard ); | 999 | converter.addresseeToVCard( a, vcard ); |
996 | int start = 0; | 1000 | int start = 0; |
997 | int next; | 1001 | int next; |
998 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 1002 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
999 | int semi = vcard.find(";", next); | 1003 | int semi = vcard.find(";", next); |
1000 | int dopp = vcard.find(":", next); | 1004 | int dopp = vcard.find(":", next); |
1001 | int sep; | 1005 | int sep; |
1002 | if ( semi < dopp && semi >= 0 ) | 1006 | if ( semi < dopp && semi >= 0 ) |
1003 | sep = semi ; | 1007 | sep = semi ; |
1004 | else | 1008 | else |
1005 | sep = dopp; | 1009 | sep = dopp; |
1006 | datastream +=vcard.mid( start, next - start); | 1010 | datastream +=vcard.mid( start, next - start); |
1007 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 1011 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
1008 | start = sep; | 1012 | start = sep; |
1009 | } | 1013 | } |
1010 | datastream += vcard.mid( start,vcard.length() ); | 1014 | datastream += vcard.mid( start,vcard.length() ); |
1011 | } | 1015 | } |
1012 | #ifndef DESKTOP_VERSION | 1016 | #ifndef DESKTOP_VERSION |
1013 | QFile outFile(fileName); | 1017 | QFile outFile(fileName); |
1014 | if ( outFile.open(IO_WriteOnly) ) { | 1018 | if ( outFile.open(IO_WriteOnly) ) { |
1015 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 1019 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
1016 | QTextStream t( &outFile ); // use a text stream | 1020 | QTextStream t( &outFile ); // use a text stream |
1017 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 1021 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
1018 | t.setEncoding( QTextStream::Latin1 ); | 1022 | t.setEncoding( QTextStream::Latin1 ); |
1019 | t <<datastream.latin1(); | 1023 | t <<datastream.latin1(); |
1020 | outFile.close(); | 1024 | outFile.close(); |
1021 | Ir *ir = new Ir( this ); | 1025 | Ir *ir = new Ir( this ); |
1022 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 1026 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
1023 | ir->send( fileName, description, "text/x-vCard" ); | 1027 | ir->send( fileName, description, "text/x-vCard" ); |
1024 | } else { | 1028 | } else { |
1025 | qDebug("KA: Error open temp beam file "); | 1029 | qDebug("KA: Error open temp beam file "); |
1026 | return; | 1030 | return; |
1027 | } | 1031 | } |
1028 | #endif | 1032 | #endif |
1029 | 1033 | ||
1030 | } | 1034 | } |
1031 | 1035 | ||
1032 | void KABCore::beamDone( Ir *ir ) | 1036 | void KABCore::beamDone( Ir *ir ) |
1033 | { | 1037 | { |
1034 | #ifndef DESKTOP_VERSION | 1038 | #ifndef DESKTOP_VERSION |
1035 | delete ir; | 1039 | delete ir; |
1036 | #endif | 1040 | #endif |
1037 | topLevelWidget()->raise(); | 1041 | topLevelWidget()->raise(); |
1038 | message( i18n("Beaming finished!") ); | 1042 | message( i18n("Beaming finished!") ); |
1039 | } | 1043 | } |
1040 | 1044 | ||
1041 | 1045 | ||
1042 | void KABCore::browse( const QString& url ) | 1046 | void KABCore::browse( const QString& url ) |
1043 | { | 1047 | { |
1044 | #ifndef KAB_EMBEDDED | 1048 | #ifndef KAB_EMBEDDED |
1045 | kapp->invokeBrowser( url ); | 1049 | kapp->invokeBrowser( url ); |
1046 | #else //KAB_EMBEDDED | 1050 | #else //KAB_EMBEDDED |
1047 | qDebug("KABCore::browse must be fixed"); | 1051 | qDebug("KABCore::browse must be fixed"); |
1048 | #endif //KAB_EMBEDDED | 1052 | #endif //KAB_EMBEDDED |
1049 | } | 1053 | } |
1050 | 1054 | ||
1051 | void KABCore::selectAllContacts() | 1055 | void KABCore::selectAllContacts() |
1052 | { | 1056 | { |
1053 | mViewManager->setSelected( QString::null, true ); | 1057 | mViewManager->setSelected( QString::null, true ); |
1054 | } | 1058 | } |
1055 | 1059 | ||
1056 | void KABCore::deleteContacts() | 1060 | void KABCore::deleteContacts() |
1057 | { | 1061 | { |
1058 | QStringList uidList = mViewManager->selectedUids(); | 1062 | QStringList uidList = mViewManager->selectedUids(); |
1059 | deleteContacts( uidList ); | 1063 | deleteContacts( uidList ); |
1060 | } | 1064 | } |
1061 | 1065 | ||
1062 | void KABCore::deleteContacts( const QStringList &uids ) | 1066 | void KABCore::deleteContacts( const QStringList &uids ) |
1063 | { | 1067 | { |
1064 | 1068 | ||
1065 | if ( uids.count() > 0 ) { | 1069 | if ( uids.count() > 0 ) { |
1066 | 1070 | ||
1067 | if ( KABPrefs::instance()->mAskForDelete ) { | 1071 | if ( KABPrefs::instance()->mAskForDelete ) { |
1068 | int count = uids.count(); | 1072 | int count = uids.count(); |
1069 | if ( count > 5 ) count = 5; | 1073 | if ( count > 5 ) count = 5; |
1070 | QString cNames; | 1074 | QString cNames; |
1071 | int i; | 1075 | int i; |
1072 | for ( i = 0; i < count ; ++i ) { | 1076 | for ( i = 0; i < count ; ++i ) { |
1073 | cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; | 1077 | cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; |
1074 | } | 1078 | } |
1075 | if ( uids.count() > 5 ) | 1079 | if ( uids.count() > 5 ) |
1076 | cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); | 1080 | cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); |
1077 | QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; | 1081 | QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; |
1078 | if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) | 1082 | if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) |
1079 | return; | 1083 | return; |
1080 | } | 1084 | } |
1081 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 1085 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
1082 | UndoStack::instance()->push( command ); | 1086 | UndoStack::instance()->push( command ); |
1083 | RedoStack::instance()->clear(); | 1087 | RedoStack::instance()->clear(); |
1084 | 1088 | ||
1085 | // now if we deleted anything, refresh | 1089 | // now if we deleted anything, refresh |
1086 | setContactSelected( QString::null ); | 1090 | setContactSelected( QString::null ); |
1087 | setModified( true ); | 1091 | setModified( true ); |
1088 | } | 1092 | } |
1089 | } | 1093 | } |
1090 | 1094 | ||
1091 | void KABCore::copyContacts() | 1095 | void KABCore::copyContacts() |
1092 | { | 1096 | { |
1093 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1097 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1094 | 1098 | ||
1095 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 1099 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
1096 | 1100 | ||
1097 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 1101 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
1098 | 1102 | ||
1099 | QClipboard *cb = QApplication::clipboard(); | 1103 | QClipboard *cb = QApplication::clipboard(); |
1100 | cb->setText( clipText ); | 1104 | cb->setText( clipText ); |
1101 | } | 1105 | } |
1102 | 1106 | ||
1103 | void KABCore::cutContacts() | 1107 | void KABCore::cutContacts() |
1104 | { | 1108 | { |
1105 | QStringList uidList = mViewManager->selectedUids(); | 1109 | QStringList uidList = mViewManager->selectedUids(); |
1106 | 1110 | ||
1107 | //US if ( uidList.size() > 0 ) { | 1111 | //US if ( uidList.size() > 0 ) { |
1108 | if ( uidList.count() > 0 ) { | 1112 | if ( uidList.count() > 0 ) { |
1109 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 1113 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
1110 | UndoStack::instance()->push( command ); | 1114 | UndoStack::instance()->push( command ); |
1111 | RedoStack::instance()->clear(); | 1115 | RedoStack::instance()->clear(); |
1112 | 1116 | ||
1113 | setModified( true ); | 1117 | setModified( true ); |
1114 | } | 1118 | } |
1115 | } | 1119 | } |
1116 | 1120 | ||
1117 | void KABCore::pasteContacts() | 1121 | void KABCore::pasteContacts() |
1118 | { | 1122 | { |
1119 | QClipboard *cb = QApplication::clipboard(); | 1123 | QClipboard *cb = QApplication::clipboard(); |
1120 | 1124 | ||
1121 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 1125 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
1122 | 1126 | ||
1123 | pasteContacts( list ); | 1127 | pasteContacts( list ); |
1124 | } | 1128 | } |
1125 | 1129 | ||
1126 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 1130 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
1127 | { | 1131 | { |
1128 | KABC::Resource *resource = requestResource( this ); | 1132 | KABC::Resource *resource = requestResource( this ); |
1129 | KABC::Addressee::List::Iterator it; | 1133 | KABC::Addressee::List::Iterator it; |
1130 | for ( it = list.begin(); it != list.end(); ++it ) | 1134 | for ( it = list.begin(); it != list.end(); ++it ) |
1131 | (*it).setResource( resource ); | 1135 | (*it).setResource( resource ); |
1132 | 1136 | ||
1133 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 1137 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
1134 | UndoStack::instance()->push( command ); | 1138 | UndoStack::instance()->push( command ); |
1135 | RedoStack::instance()->clear(); | 1139 | RedoStack::instance()->clear(); |
1136 | 1140 | ||
1137 | setModified( true ); | 1141 | setModified( true ); |
1138 | } | 1142 | } |
1139 | 1143 | ||
1140 | void KABCore::setWhoAmI() | 1144 | void KABCore::setWhoAmI() |
1141 | { | 1145 | { |
1142 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1146 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1143 | 1147 | ||
1144 | if ( addrList.count() > 1 ) { | 1148 | if ( addrList.count() > 1 ) { |
1145 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 1149 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
1146 | return; | 1150 | return; |
1147 | } | 1151 | } |
1148 | 1152 | ||
1149 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 1153 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
1150 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) | 1154 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) |
1151 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 1155 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
1152 | } | 1156 | } |
1153 | void KABCore::editCategories() | 1157 | void KABCore::editCategories() |
1154 | { | 1158 | { |
1155 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); | 1159 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); |
1156 | dlg.exec(); | 1160 | dlg.exec(); |
1157 | } | 1161 | } |
1158 | void KABCore::setCategories() | 1162 | void KABCore::setCategories() |
1159 | { | 1163 | { |
1160 | 1164 | ||
1161 | QStringList uids; | 1165 | QStringList uids; |
1162 | XXPortSelectDialog dlgx( this, false, this ); | 1166 | XXPortSelectDialog dlgx( this, false, this ); |
1163 | if ( dlgx.exec() ) | 1167 | if ( dlgx.exec() ) |
1164 | uids = dlgx.uids(); | 1168 | uids = dlgx.uids(); |
1165 | else | 1169 | else |
1166 | return; | 1170 | return; |
1167 | if ( uids.isEmpty() ) | 1171 | if ( uids.isEmpty() ) |
1168 | return; | 1172 | return; |
1169 | // qDebug("count %d ", uids.count()); | 1173 | // qDebug("count %d ", uids.count()); |
1170 | 1174 | ||
1171 | 1175 | ||
1172 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 1176 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
1173 | if ( !dlg.exec() ) { | 1177 | if ( !dlg.exec() ) { |
1174 | message( i18n("Setting categories cancelled") ); | 1178 | message( i18n("Setting categories cancelled") ); |
1175 | return; | 1179 | return; |
1176 | } | 1180 | } |
1177 | bool merge = false; | 1181 | bool merge = false; |
1178 | QString msg = i18n( "Merge with existing categories?" ); | 1182 | QString msg = i18n( "Merge with existing categories?" ); |
1179 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 1183 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
1180 | merge = true; | 1184 | merge = true; |
1181 | 1185 | ||
1182 | message( i18n("Setting categories ... please wait!") ); | 1186 | message( i18n("Setting categories ... please wait!") ); |
1183 | QStringList categories = dlg.selectedCategories(); | 1187 | QStringList categories = dlg.selectedCategories(); |
1184 | 1188 | ||
1185 | //QStringList uids = mViewManager->selectedUids(); | 1189 | //QStringList uids = mViewManager->selectedUids(); |
1186 | QStringList::Iterator it; | 1190 | QStringList::Iterator it; |
1187 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1191 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1188 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1192 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1189 | if ( !addr.isEmpty() ) { | 1193 | if ( !addr.isEmpty() ) { |
1190 | if ( !merge ) | 1194 | if ( !merge ) |
1191 | addr.setCategories( categories ); | 1195 | addr.setCategories( categories ); |
1192 | else { | 1196 | else { |
1193 | QStringList addrCategories = addr.categories(); | 1197 | QStringList addrCategories = addr.categories(); |
1194 | QStringList::Iterator catIt; | 1198 | QStringList::Iterator catIt; |
1195 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1199 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1196 | if ( !addrCategories.contains( *catIt ) ) | 1200 | if ( !addrCategories.contains( *catIt ) ) |
1197 | addrCategories.append( *catIt ); | 1201 | addrCategories.append( *catIt ); |
1198 | } | 1202 | } |
1199 | addr.setCategories( addrCategories ); | 1203 | addr.setCategories( addrCategories ); |
1200 | } | 1204 | } |
1201 | mAddressBook->insertAddressee( addr ); | 1205 | mAddressBook->insertAddressee( addr ); |
1202 | } | 1206 | } |
1203 | } | 1207 | } |
1204 | 1208 | ||
1205 | if ( uids.count() > 0 ) | 1209 | if ( uids.count() > 0 ) |
1206 | setModified( true ); | 1210 | setModified( true ); |
1207 | message( i18n("Setting categories completed!") ); | 1211 | message( i18n("Setting categories completed!") ); |
1208 | } | 1212 | } |
1209 | 1213 | ||
1210 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1214 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1211 | { | 1215 | { |
1212 | mIncSearchWidget->setFields( fields ); | 1216 | mIncSearchWidget->setFields( fields ); |
1213 | } | 1217 | } |
1214 | 1218 | ||
1215 | void KABCore::incrementalSearch( const QString& text ) | 1219 | void KABCore::incrementalSearch( const QString& text ) |
1216 | { | 1220 | { |
1217 | QString stext; | 1221 | QString stext; |
1218 | if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { | 1222 | if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { |
1219 | stext = "*" + text; | 1223 | stext = "*" + text; |
1220 | } else { | 1224 | } else { |
1221 | stext = text; | 1225 | stext = text; |
1222 | } | 1226 | } |
1223 | mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); | 1227 | mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); |
1224 | } | 1228 | } |
1225 | void KABCore::incrementalSearchJump( const QString& text ) | 1229 | void KABCore::incrementalSearchJump( const QString& text ) |
1226 | { | 1230 | { |
1227 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1231 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1228 | } | 1232 | } |
1229 | 1233 | ||
1230 | void KABCore::setModified() | 1234 | void KABCore::setModified() |
1231 | { | 1235 | { |
1232 | setModified( true ); | 1236 | setModified( true ); |
1233 | } | 1237 | } |
1234 | 1238 | ||
1235 | void KABCore::setModifiedWOrefresh() | 1239 | void KABCore::setModifiedWOrefresh() |
1236 | { | 1240 | { |
1237 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1241 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1238 | mModified = true; | 1242 | mModified = true; |
1239 | mActionSave->setEnabled( mModified ); | 1243 | mActionSave->setEnabled( mModified ); |
1240 | 1244 | ||
1241 | 1245 | ||
1242 | } | 1246 | } |
1243 | void KABCore::setModified( bool modified ) | 1247 | void KABCore::setModified( bool modified ) |
1244 | { | 1248 | { |
1245 | mModified = modified; | 1249 | mModified = modified; |
1246 | mActionSave->setEnabled( mModified ); | 1250 | mActionSave->setEnabled( mModified ); |
1247 | 1251 | ||
1248 | if ( modified ) | 1252 | if ( modified ) |
1249 | mJumpButtonBar->recreateButtons(); | 1253 | mJumpButtonBar->recreateButtons(); |
1250 | 1254 | ||
1251 | mViewManager->refreshView(); | 1255 | mViewManager->refreshView(); |
1252 | 1256 | ||
1253 | } | 1257 | } |
1254 | 1258 | ||
1255 | bool KABCore::modified() const | 1259 | bool KABCore::modified() const |
1256 | { | 1260 | { |
1257 | return mModified; | 1261 | return mModified; |
1258 | } | 1262 | } |
1259 | 1263 | ||
1260 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1264 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1261 | { | 1265 | { |
1262 | addrModified( addr ); | 1266 | addrModified( addr ); |
1263 | #if 0 // debug only | 1267 | #if 0 // debug only |
1264 | KABC::Addressee ad = addr; | 1268 | KABC::Addressee ad = addr; |
1265 | ad.computeCsum( "123"); | 1269 | ad.computeCsum( "123"); |
1266 | #endif | 1270 | #endif |
1267 | } | 1271 | } |
1268 | 1272 | ||
1269 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | 1273 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) |
1270 | { | 1274 | { |
1271 | 1275 | ||
1272 | Command *command = 0; | 1276 | Command *command = 0; |
1273 | QString uid; | 1277 | QString uid; |
1274 | 1278 | ||
1275 | // check if it exists already | 1279 | // check if it exists already |
1276 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1280 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1277 | if ( origAddr.isEmpty() ) | 1281 | if ( origAddr.isEmpty() ) |
1278 | command = new PwNewCommand( mAddressBook, addr ); | 1282 | command = new PwNewCommand( mAddressBook, addr ); |
1279 | else { | 1283 | else { |
1280 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1284 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1281 | uid = addr.uid(); | 1285 | uid = addr.uid(); |
1282 | } | 1286 | } |
1283 | 1287 | ||
1284 | UndoStack::instance()->push( command ); | 1288 | UndoStack::instance()->push( command ); |
1285 | RedoStack::instance()->clear(); | 1289 | RedoStack::instance()->clear(); |
1286 | if ( updateDetails ) | 1290 | if ( updateDetails ) |
1287 | mDetails->setAddressee( addr ); | 1291 | mDetails->setAddressee( addr ); |
1288 | setModified( true ); | 1292 | setModified( true ); |
1289 | } | 1293 | } |
1290 | 1294 | ||
1291 | void KABCore::newContact() | 1295 | void KABCore::newContact() |
1292 | { | 1296 | { |
1293 | 1297 | ||
1294 | 1298 | ||
1295 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1299 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1296 | 1300 | ||
1297 | QPtrList<KRES::Resource> kresResources; | 1301 | QPtrList<KRES::Resource> kresResources; |
1298 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1302 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1299 | KABC::Resource *resource; | 1303 | KABC::Resource *resource; |
1300 | while ( ( resource = it.current() ) != 0 ) { | 1304 | while ( ( resource = it.current() ) != 0 ) { |
1301 | ++it; | 1305 | ++it; |
1302 | if ( !resource->readOnly() ) { | 1306 | if ( !resource->readOnly() ) { |
1303 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1307 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1304 | if ( res ) | 1308 | if ( res ) |
1305 | kresResources.append( res ); | 1309 | kresResources.append( res ); |
1306 | } | 1310 | } |
1307 | } | 1311 | } |
1308 | 1312 | ||
1309 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1313 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1310 | resource = static_cast<KABC::Resource*>( res ); | 1314 | resource = static_cast<KABC::Resource*>( res ); |
1311 | 1315 | ||
1312 | if ( resource ) { | 1316 | if ( resource ) { |
1313 | KABC::Addressee addr; | 1317 | KABC::Addressee addr; |
1314 | addr.setResource( resource ); | 1318 | addr.setResource( resource ); |
1315 | mEditorDialog->setAddressee( addr ); | 1319 | mEditorDialog->setAddressee( addr ); |
1316 | mEditorDialog->setCaption( i18n("Edit new contact")); | 1320 | mEditorDialog->setCaption( i18n("Edit new contact")); |
1317 | KApplication::execDialog ( mEditorDialog ); | 1321 | KApplication::execDialog ( mEditorDialog ); |
1318 | 1322 | ||
1319 | } else | 1323 | } else |
1320 | return; | 1324 | return; |
1321 | 1325 | ||
1322 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1326 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1323 | 1327 | ||
1324 | 1328 | ||
1325 | } | 1329 | } |
1326 | 1330 | ||
1327 | void KABCore::addEmail( QString aStr ) | 1331 | void KABCore::addEmail( QString aStr ) |
1328 | { | 1332 | { |
1329 | #ifndef KAB_EMBEDDED | 1333 | #ifndef KAB_EMBEDDED |
1330 | QString fullName, email; | 1334 | QString fullName, email; |
1331 | 1335 | ||
1332 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1336 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1333 | 1337 | ||
1334 | // Try to lookup the addressee matching the email address | 1338 | // Try to lookup the addressee matching the email address |
1335 | bool found = false; | 1339 | bool found = false; |
1336 | QStringList emailList; | 1340 | QStringList emailList; |
1337 | KABC::AddressBook::Iterator it; | 1341 | KABC::AddressBook::Iterator it; |
1338 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1342 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1339 | emailList = (*it).emails(); | 1343 | emailList = (*it).emails(); |
1340 | if ( emailList.contains( email ) > 0 ) { | 1344 | if ( emailList.contains( email ) > 0 ) { |
1341 | found = true; | 1345 | found = true; |
1342 | (*it).setNameFromString( fullName ); | 1346 | (*it).setNameFromString( fullName ); |
1343 | editContact( (*it).uid() ); | 1347 | editContact( (*it).uid() ); |
1344 | } | 1348 | } |
1345 | } | 1349 | } |
1346 | 1350 | ||
1347 | if ( !found ) { | 1351 | if ( !found ) { |
1348 | KABC::Addressee addr; | 1352 | KABC::Addressee addr; |
1349 | addr.setNameFromString( fullName ); | 1353 | addr.setNameFromString( fullName ); |
1350 | addr.insertEmail( email, true ); | 1354 | addr.insertEmail( email, true ); |
1351 | 1355 | ||
1352 | mAddressBook->insertAddressee( addr ); | 1356 | mAddressBook->insertAddressee( addr ); |
1353 | mViewManager->refreshView( addr.uid() ); | 1357 | mViewManager->refreshView( addr.uid() ); |
1354 | editContact( addr.uid() ); | 1358 | editContact( addr.uid() ); |
1355 | } | 1359 | } |
1356 | #else //KAB_EMBEDDED | 1360 | #else //KAB_EMBEDDED |
1357 | qDebug("KABCore::addEmail finsih method"); | 1361 | qDebug("KABCore::addEmail finsih method"); |
1358 | #endif //KAB_EMBEDDED | 1362 | #endif //KAB_EMBEDDED |
1359 | } | 1363 | } |
1360 | 1364 | ||
1361 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1365 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1362 | { | 1366 | { |
1363 | mXXPortManager->importVCard( url, showPreview ); | 1367 | mXXPortManager->importVCard( url, showPreview ); |
1364 | } | 1368 | } |
1365 | void KABCore::importFromOL() | 1369 | void KABCore::importFromOL() |
1366 | { | 1370 | { |
1367 | #ifdef _OL_IMPORT_ | 1371 | #ifdef _OL_IMPORT_ |
1368 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1372 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1369 | idgl->exec(); | 1373 | idgl->exec(); |
1370 | KABC::Addressee::List list = idgl->getAddressList(); | 1374 | KABC::Addressee::List list = idgl->getAddressList(); |
1371 | if ( list.count() > 0 ) { | 1375 | if ( list.count() > 0 ) { |
1372 | KABC::Addressee::List listNew; | 1376 | KABC::Addressee::List listNew; |
1373 | KABC::Addressee::List listExisting; | 1377 | KABC::Addressee::List listExisting; |
1374 | KABC::Addressee::List::Iterator it; | 1378 | KABC::Addressee::List::Iterator it; |
1375 | KABC::AddressBook::Iterator iter; | 1379 | KABC::AddressBook::Iterator iter; |
1376 | for ( it = list.begin(); it != list.end(); ++it ) { | 1380 | for ( it = list.begin(); it != list.end(); ++it ) { |
1377 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1381 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1378 | listNew.append( (*it) ); | 1382 | listNew.append( (*it) ); |
1379 | else | 1383 | else |
1380 | listExisting.append( (*it) ); | 1384 | listExisting.append( (*it) ); |
1381 | } | 1385 | } |
1382 | if ( listExisting.count() > 0 ) | 1386 | if ( listExisting.count() > 0 ) |
1383 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1387 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1384 | if ( listNew.count() > 0 ) { | 1388 | if ( listNew.count() > 0 ) { |
1385 | pasteWithNewUid = false; | 1389 | pasteWithNewUid = false; |
1386 | pasteContacts( listNew ); | 1390 | pasteContacts( listNew ); |
1387 | pasteWithNewUid = true; | 1391 | pasteWithNewUid = true; |
1388 | } | 1392 | } |
1389 | } | 1393 | } |
1390 | delete idgl; | 1394 | delete idgl; |
1391 | #endif | 1395 | #endif |
1392 | } | 1396 | } |
1393 | 1397 | ||
1394 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1398 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1395 | { | 1399 | { |
1396 | mXXPortManager->importVCard( vCard, showPreview ); | 1400 | mXXPortManager->importVCard( vCard, showPreview ); |
1397 | } | 1401 | } |
1398 | 1402 | ||
1399 | //US added a second method without defaultparameter | 1403 | //US added a second method without defaultparameter |
1400 | void KABCore::editContact2() { | 1404 | void KABCore::editContact2() { |
1401 | editContact( QString::null ); | 1405 | editContact( QString::null ); |
1402 | } | 1406 | } |
1403 | 1407 | ||
1404 | void KABCore::editContact( const QString &uid ) | 1408 | void KABCore::editContact( const QString &uid ) |
1405 | { | 1409 | { |
1406 | 1410 | ||
1407 | if ( mExtensionManager->isQuickEditVisible() ) | 1411 | if ( mExtensionManager->isQuickEditVisible() ) |
1408 | return; | 1412 | return; |
1409 | 1413 | ||
1410 | // First, locate the contact entry | 1414 | // First, locate the contact entry |
1411 | QString localUID = uid; | 1415 | QString localUID = uid; |
1412 | if ( localUID.isNull() ) { | 1416 | if ( localUID.isNull() ) { |
1413 | QStringList uidList = mViewManager->selectedUids(); | 1417 | QStringList uidList = mViewManager->selectedUids(); |
1414 | if ( uidList.count() > 0 ) | 1418 | if ( uidList.count() > 0 ) |
1415 | localUID = *( uidList.at( 0 ) ); | 1419 | localUID = *( uidList.at( 0 ) ); |
1416 | } | 1420 | } |
1417 | 1421 | ||
1418 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1422 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1419 | if ( !addr.isEmpty() ) { | 1423 | if ( !addr.isEmpty() ) { |
1420 | mEditorDialog->setAddressee( addr ); | 1424 | mEditorDialog->setAddressee( addr ); |
1421 | KApplication::execDialog ( mEditorDialog ); | 1425 | KApplication::execDialog ( mEditorDialog ); |
1422 | } | 1426 | } |
1423 | } | 1427 | } |
1424 | 1428 | ||
1425 | /** | 1429 | /** |
1426 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1430 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1427 | the method will try to find a selected addressee in the view. | 1431 | the method will try to find a selected addressee in the view. |
1428 | */ | 1432 | */ |
1429 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1433 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1430 | { | 1434 | { |
1431 | if ( mMultipleViewsAtOnce ) | 1435 | if ( mMultipleViewsAtOnce ) |
1432 | { | 1436 | { |
1433 | editContact( uid ); | 1437 | editContact( uid ); |
1434 | } | 1438 | } |
1435 | else | 1439 | else |
1436 | { | 1440 | { |
1437 | setDetailsVisible( true ); | 1441 | setDetailsVisible( true ); |
1438 | mActionDetails->setChecked(true); | 1442 | mActionDetails->setChecked(true); |
1439 | } | 1443 | } |
1440 | 1444 | ||
1441 | } | 1445 | } |
1442 | 1446 | ||
1443 | void KABCore::save() | 1447 | void KABCore::save() |
1444 | { | 1448 | { |
1445 | if (syncManager->blockSave()) | 1449 | if (syncManager->blockSave()) |
1446 | return; | 1450 | return; |
1447 | if ( !mModified ) | 1451 | if ( !mModified ) |
1448 | return; | 1452 | return; |
1449 | 1453 | ||
1450 | syncManager->setBlockSave(true); | 1454 | syncManager->setBlockSave(true); |
1451 | QString text = i18n( "There was an error while attempting to save\n the " | 1455 | QString text = i18n( "There was an error while attempting to save\n the " |
1452 | "address book. Please check that some \nother application is " | 1456 | "address book. Please check that some \nother application is " |
1453 | "not using it. " ); | 1457 | "not using it. " ); |
1454 | message(i18n("Saving ... please wait! "), false); | 1458 | message(i18n("Saving ... please wait! "), false); |
1455 | //qApp->processEvents(); | 1459 | //qApp->processEvents(); |
1456 | #ifndef KAB_EMBEDDED | 1460 | #ifndef KAB_EMBEDDED |
1457 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1461 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1458 | if ( !b || !b->save() ) { | 1462 | if ( !b || !b->save() ) { |
1459 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1463 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1460 | } | 1464 | } |
1461 | #else //KAB_EMBEDDED | 1465 | #else //KAB_EMBEDDED |
1462 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1466 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1463 | if ( !b || !b->save() ) { | 1467 | if ( !b || !b->save() ) { |
1464 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1468 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1465 | } | 1469 | } |
1466 | #endif //KAB_EMBEDDED | 1470 | #endif //KAB_EMBEDDED |
1467 | 1471 | ||
1468 | message(i18n("Addressbook saved!")); | 1472 | message(i18n("Addressbook saved!")); |
1469 | setModified( false ); | 1473 | setModified( false ); |
1470 | syncManager->setBlockSave(false); | 1474 | syncManager->setBlockSave(false); |
1471 | } | 1475 | } |
1472 | 1476 | ||
1473 | 1477 | ||
1474 | void KABCore::undo() | 1478 | void KABCore::undo() |
1475 | { | 1479 | { |
1476 | UndoStack::instance()->undo(); | 1480 | UndoStack::instance()->undo(); |
1477 | 1481 | ||
1478 | // Refresh the view | 1482 | // Refresh the view |
1479 | mViewManager->refreshView(); | 1483 | mViewManager->refreshView(); |
1480 | } | 1484 | } |
1481 | 1485 | ||
1482 | void KABCore::redo() | 1486 | void KABCore::redo() |
1483 | { | 1487 | { |
1484 | RedoStack::instance()->redo(); | 1488 | RedoStack::instance()->redo(); |
1485 | 1489 | ||
1486 | // Refresh the view | 1490 | // Refresh the view |
1487 | mViewManager->refreshView(); | 1491 | mViewManager->refreshView(); |
1488 | } | 1492 | } |
1489 | void KABCore::setJumpButtonBar( bool visible ) | 1493 | void KABCore::setJumpButtonBar( bool visible ) |
1490 | { | 1494 | { |
1491 | setJumpButtonBarVisible(visible ); | 1495 | setJumpButtonBarVisible(visible ); |
1492 | saveSettings(); | 1496 | saveSettings(); |
1493 | } | 1497 | } |
1494 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1498 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1495 | { | 1499 | { |
1496 | if (mMultipleViewsAtOnce) | 1500 | if (mMultipleViewsAtOnce) |
1497 | { | 1501 | { |
1498 | if ( visible ) | 1502 | if ( visible ) |
1499 | mJumpButtonBar->show(); | 1503 | mJumpButtonBar->show(); |
1500 | else | 1504 | else |
1501 | mJumpButtonBar->hide(); | 1505 | mJumpButtonBar->hide(); |
1502 | } | 1506 | } |
1503 | else | 1507 | else |
1504 | { | 1508 | { |
1505 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1509 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1506 | if (mViewManager->isVisible()) | 1510 | if (mViewManager->isVisible()) |
1507 | { | 1511 | { |
1508 | if ( visible ) | 1512 | if ( visible ) |
1509 | mJumpButtonBar->show(); | 1513 | mJumpButtonBar->show(); |
1510 | else | 1514 | else |
1511 | mJumpButtonBar->hide(); | 1515 | mJumpButtonBar->hide(); |
1512 | } | 1516 | } |
1513 | else | 1517 | else |
1514 | { | 1518 | { |
1515 | mJumpButtonBar->hide(); | 1519 | mJumpButtonBar->hide(); |
1516 | } | 1520 | } |
1517 | } | 1521 | } |
1518 | if ( visible ) { | 1522 | if ( visible ) { |
1519 | if ( mIncSearchWidget->currentItem() == 0 ) { | 1523 | if ( mIncSearchWidget->currentItem() == 0 ) { |
1520 | message( i18n("Change search field enable jump bar") ); | 1524 | message( i18n("Change search field enable jump bar") ); |
1521 | } | 1525 | } |
1522 | } | 1526 | } |
1523 | } | 1527 | } |
1524 | 1528 | ||
1525 | 1529 | ||
1526 | void KABCore::setDetailsToState() | 1530 | void KABCore::setDetailsToState() |
1527 | { | 1531 | { |
1528 | setDetailsVisible( mActionDetails->isChecked() ); | 1532 | setDetailsVisible( mActionDetails->isChecked() ); |
1529 | } | 1533 | } |
1530 | void KABCore::setDetailsToggle() | 1534 | void KABCore::setDetailsToggle() |
1531 | { | 1535 | { |
1532 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1536 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1533 | setDetailsToState(); | 1537 | setDetailsToState(); |
1534 | } | 1538 | } |
1535 | 1539 | ||
1536 | 1540 | ||
1537 | 1541 | ||
1538 | void KABCore::setDetailsVisible( bool visible ) | 1542 | void KABCore::setDetailsVisible( bool visible ) |
1539 | { | 1543 | { |
1540 | if (visible && mDetails->isHidden()) | 1544 | if (visible && mDetails->isHidden()) |
1541 | { | 1545 | { |
1542 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1546 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1543 | if ( addrList.count() > 0 ) | 1547 | if ( addrList.count() > 0 ) |
1544 | mDetails->setAddressee( addrList[ 0 ] ); | 1548 | mDetails->setAddressee( addrList[ 0 ] ); |
1545 | } | 1549 | } |
1546 | 1550 | ||
1547 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1551 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1548 | // the listview and the detailview. We do that by changing the splitbar size. | 1552 | // the listview and the detailview. We do that by changing the splitbar size. |
1549 | if (mMultipleViewsAtOnce) | 1553 | if (mMultipleViewsAtOnce) |
1550 | { | 1554 | { |
1551 | if ( visible ) | 1555 | if ( visible ) |
1552 | mDetails->show(); | 1556 | mDetails->show(); |
1553 | else | 1557 | else |
1554 | mDetails->hide(); | 1558 | mDetails->hide(); |
1555 | } | 1559 | } |
1556 | else | 1560 | else |
1557 | { | 1561 | { |
1558 | if ( visible ) { | 1562 | if ( visible ) { |
1559 | mViewManager->hide(); | 1563 | mViewManager->hide(); |
1560 | mDetails->show(); | 1564 | mDetails->show(); |
1561 | mIncSearchWidget->setFocus(); | 1565 | mIncSearchWidget->setFocus(); |
1562 | } | 1566 | } |
1563 | else { | 1567 | else { |
1564 | mViewManager->show(); | 1568 | mViewManager->show(); |
1565 | mDetails->hide(); | 1569 | mDetails->hide(); |
1566 | mViewManager->setFocusAV(); | 1570 | mViewManager->setFocusAV(); |
1567 | } | 1571 | } |
1568 | setJumpButtonBarVisible( !visible ); | 1572 | setJumpButtonBarVisible( !visible ); |
1569 | } | 1573 | } |
1570 | 1574 | ||
1571 | } | 1575 | } |
1572 | 1576 | ||
1573 | void KABCore::extensionChanged( int id ) | 1577 | void KABCore::extensionChanged( int id ) |
1574 | { | 1578 | { |
1575 | //change the details view only for non desktop systems | 1579 | //change the details view only for non desktop systems |
1576 | #ifndef DESKTOP_VERSION | 1580 | #ifndef DESKTOP_VERSION |
1577 | 1581 | ||
1578 | if (id == 0) | 1582 | if (id == 0) |
1579 | { | 1583 | { |
1580 | //the user disabled the extension. | 1584 | //the user disabled the extension. |
1581 | 1585 | ||
1582 | if (mMultipleViewsAtOnce) | 1586 | if (mMultipleViewsAtOnce) |
1583 | { // enable detailsview again | 1587 | { // enable detailsview again |
1584 | setDetailsVisible( true ); | 1588 | setDetailsVisible( true ); |
1585 | mActionDetails->setChecked( true ); | 1589 | mActionDetails->setChecked( true ); |
1586 | } | 1590 | } |
1587 | else | 1591 | else |
1588 | { //go back to the listview | 1592 | { //go back to the listview |
1589 | setDetailsVisible( false ); | 1593 | setDetailsVisible( false ); |
1590 | mActionDetails->setChecked( false ); | 1594 | mActionDetails->setChecked( false ); |
1591 | mActionDetails->setEnabled(true); | 1595 | mActionDetails->setEnabled(true); |
1592 | } | 1596 | } |
1593 | 1597 | ||
1594 | } | 1598 | } |
1595 | else | 1599 | else |
1596 | { | 1600 | { |
1597 | //the user enabled the extension. | 1601 | //the user enabled the extension. |
1598 | setDetailsVisible( false ); | 1602 | setDetailsVisible( false ); |
1599 | mActionDetails->setChecked( false ); | 1603 | mActionDetails->setChecked( false ); |
1600 | 1604 | ||
1601 | if (!mMultipleViewsAtOnce) | 1605 | if (!mMultipleViewsAtOnce) |
1602 | { | 1606 | { |
1603 | mActionDetails->setEnabled(false); | 1607 | mActionDetails->setEnabled(false); |
1604 | } | 1608 | } |
1605 | 1609 | ||
1606 | mExtensionManager->setSelectionChanged(); | 1610 | mExtensionManager->setSelectionChanged(); |
1607 | 1611 | ||
1608 | } | 1612 | } |
1609 | 1613 | ||
1610 | #endif// DESKTOP_VERSION | 1614 | #endif// DESKTOP_VERSION |
1611 | 1615 | ||
1612 | } | 1616 | } |
1613 | 1617 | ||
1614 | 1618 | ||
1615 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1619 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1616 | { | 1620 | { |
1617 | 1621 | ||
1618 | if ( list.count() != 0 ) { | 1622 | if ( list.count() != 0 ) { |
1619 | KABC::Addressee::List::ConstIterator it; | 1623 | KABC::Addressee::List::ConstIterator it; |
1620 | for ( it = list.begin(); it != list.end(); ++it ) | 1624 | for ( it = list.begin(); it != list.end(); ++it ) |
1621 | mAddressBook->insertAddressee( *it ); | 1625 | mAddressBook->insertAddressee( *it ); |
1622 | if ( list.count() > 1 ) | 1626 | if ( list.count() > 1 ) |
1623 | setModified(); | 1627 | setModified(); |
1624 | else | 1628 | else |
1625 | setModifiedWOrefresh(); | 1629 | setModifiedWOrefresh(); |
1626 | } | 1630 | } |
1627 | if ( list.count() == 0 ) | 1631 | if ( list.count() == 0 ) |
1628 | mViewManager->refreshView(); | 1632 | mViewManager->refreshView(); |
1629 | else | 1633 | else |
1630 | mViewManager->refreshView( list[ 0 ].uid() ); | 1634 | mViewManager->refreshView( list[ 0 ].uid() ); |
1631 | 1635 | ||
1632 | 1636 | ||
1633 | 1637 | ||
1634 | } | 1638 | } |
1635 | 1639 | ||
1636 | QString KABCore::getNameByPhone( const QString &phone ) | 1640 | QString KABCore::getNameByPhone( const QString &phone ) |
1637 | { | 1641 | { |
1638 | #ifndef KAB_EMBEDDED | 1642 | #ifndef KAB_EMBEDDED |
1639 | QRegExp r( "[/*/-/ ]" ); | 1643 | QRegExp r( "[/*/-/ ]" ); |
1640 | QString localPhone( phone ); | 1644 | QString localPhone( phone ); |
1641 | 1645 | ||
1642 | bool found = false; | 1646 | bool found = false; |
1643 | QString ownerName = ""; | 1647 | QString ownerName = ""; |
1644 | KABC::AddressBook::Iterator iter; | 1648 | KABC::AddressBook::Iterator iter; |
1645 | KABC::PhoneNumber::List::Iterator phoneIter; | 1649 | KABC::PhoneNumber::List::Iterator phoneIter; |
1646 | KABC::PhoneNumber::List phoneList; | 1650 | KABC::PhoneNumber::List phoneList; |
1647 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1651 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1648 | phoneList = (*iter).phoneNumbers(); | 1652 | phoneList = (*iter).phoneNumbers(); |
1649 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1653 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1650 | ++phoneIter) { | 1654 | ++phoneIter) { |
1651 | // Get rid of separator chars so just the numbers are compared. | 1655 | // Get rid of separator chars so just the numbers are compared. |
1652 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1656 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1653 | ownerName = (*iter).formattedName(); | 1657 | ownerName = (*iter).formattedName(); |
1654 | found = true; | 1658 | found = true; |
1655 | } | 1659 | } |
1656 | } | 1660 | } |
1657 | } | 1661 | } |
1658 | 1662 | ||
1659 | return ownerName; | 1663 | return ownerName; |
1660 | #else //KAB_EMBEDDED | 1664 | #else //KAB_EMBEDDED |
1661 | qDebug("KABCore::getNameByPhone finsih method"); | 1665 | qDebug("KABCore::getNameByPhone finsih method"); |
1662 | return ""; | 1666 | return ""; |
1663 | #endif //KAB_EMBEDDED | 1667 | #endif //KAB_EMBEDDED |
1664 | 1668 | ||
1665 | } | 1669 | } |
1666 | void KABCore::openConfigGlobalDialog() | 1670 | void KABCore::openConfigGlobalDialog() |