summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/details/detailsviewcontainer.cpp11
-rw-r--r--kaddressbook/details/detailsviewcontainer.h1
-rw-r--r--kaddressbook/imagewidget.cpp7
-rw-r--r--kaddressbook/kabcore.cpp9
-rw-r--r--kaddressbook/kabcore.h9
-rw-r--r--kaddressbook/viewmanager.cpp1
6 files changed, 9 insertions, 29 deletions
diff --git a/kaddressbook/details/detailsviewcontainer.cpp b/kaddressbook/details/detailsviewcontainer.cpp
index ceffc77..229cce0 100644
--- a/kaddressbook/details/detailsviewcontainer.cpp
+++ b/kaddressbook/details/detailsviewcontainer.cpp
@@ -1,169 +1,160 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org> 3 Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qframe.h> 25#include <qframe.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29 29
30#include <kapplication.h> 30#include <kapplication.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kdialog.h> 32#include <kdialog.h>
33 33
34#include "look_basic.h" 34#include "look_basic.h"
35//#include "look_details.h" 35//#include "look_details.h"
36#include "look_html.h" 36#include "look_html.h"
37 37
38#ifdef KAB_EMBEDDED 38#ifdef KAB_EMBEDDED
39#include "kabprefs.h" 39#include "kabprefs.h"
40#endif //KAB_EMBEDDED 40#endif //KAB_EMBEDDED
41 41
42 42
43#include "detailsviewcontainer.h" 43#include "detailsviewcontainer.h"
44 44
45ViewContainer::ViewContainer( QWidget *parent, const char* name ) 45ViewContainer::ViewContainer( QWidget *parent, const char* name )
46 : QWidget( parent, name ), mCurrentLook( 0 ) 46 : QWidget( parent, name ), mCurrentLook( 0 )
47{ 47{
48 QBoxLayout *topLayout = new QVBoxLayout( this ); 48 QBoxLayout *topLayout = new QVBoxLayout( this );
49 //topLayout->setMargin( KDialog::marginHint() ); 49 //topLayout->setMargin( KDialog::marginHint() );
50 //topLayout->setSpacing( KDialog::spacingHint() ); 50 //topLayout->setSpacing( KDialog::spacingHint() );
51 topLayout->setMargin( 0 ); 51 topLayout->setMargin( 0 );
52 topLayout->setSpacing( 0 ); 52 topLayout->setSpacing( 0 );
53 53
54 QBoxLayout *styleLayout = new QHBoxLayout( topLayout ); 54 QBoxLayout *styleLayout = new QHBoxLayout( topLayout );
55 55
56 QLabel *label = new QLabel( i18n("Style:"), this ); 56 QLabel *label = new QLabel( i18n("Style:"), this );
57 styleLayout->addWidget( label ); 57 styleLayout->addWidget( label );
58 58
59 mStyleCombo = new QComboBox( this ); 59 mStyleCombo = new QComboBox( this );
60 styleLayout->addWidget( mStyleCombo ); 60 styleLayout->addWidget( mStyleCombo );
61 61
62 QFrame *frameRuler = new QFrame( this ); 62 QFrame *frameRuler = new QFrame( this );
63//US frameRuler->setFrameShape( QFrame::HLine ); 63//US frameRuler->setFrameShape( QFrame::HLine );
64//US frameRuler->setFrameShadow( QFrame::Sunken ); 64//US frameRuler->setFrameShadow( QFrame::Sunken );
65//US topLayout->addWidget( frameRuler ); 65//US topLayout->addWidget( frameRuler );
66 66
67 mDetailsStack = new QWidgetStack( this ); 67 mDetailsStack = new QWidgetStack( this );
68 topLayout->addWidget( mDetailsStack, 1 ); 68 topLayout->addWidget( mDetailsStack, 1 );
69 69
70 registerLooks(); 70 registerLooks();
71 71
72#if 1 72#if 1
73 // Hide detailed view selection combo box, because we currently have 73 // Hide detailed view selection combo box, because we currently have
74 // only one. Reenable it when there are more detailed views. 74 // only one. Reenable it when there are more detailed views.
75 label->hide(); 75 label->hide();
76 mStyleCombo->hide(); 76 mStyleCombo->hide();
77 frameRuler->hide(); 77 frameRuler->hide();
78#endif 78#endif
79} 79}
80 80
81KABBasicLook *ViewContainer::currentLook() 81KABBasicLook *ViewContainer::currentLook()
82{ 82{
83 return mCurrentLook; 83 return mCurrentLook;
84} 84}
85 85
86void ViewContainer::registerLooks() 86void ViewContainer::registerLooks()
87{ 87{
88 mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) ); 88 mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) );
89// mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) ); 89// mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) );
90 mStyleCombo->clear(); 90 mStyleCombo->clear();
91 91
92 for ( uint i = 0; i < mLookFactories.count(); ++i ) 92 for ( uint i = 0; i < mLookFactories.count(); ++i )
93 mStyleCombo->insertItem( mLookFactories.at( i )->description() ); 93 mStyleCombo->insertItem( mLookFactories.at( i )->description() );
94 94
95 if ( !mLookFactories.isEmpty() ) 95 if ( !mLookFactories.isEmpty() )
96 slotStyleSelected( 0 ); 96 slotStyleSelected( 0 );
97} 97}
98 98
99void ViewContainer::slotStyleSelected( int index ) 99void ViewContainer::slotStyleSelected( int index )
100{ 100{
101#ifndef KAB_EMBEDDED 101#ifndef KAB_EMBEDDED
102 KConfig *config = kapp->config(); 102 KConfig *config = kapp->config();
103#else //KAB_EMBEDDED 103#else //KAB_EMBEDDED
104 //US I hope I got the same config object as above expected. 104 //US I hope I got the same config object as above expected.
105 KConfig *config = KABPrefs::instance()->getConfig(); 105 KConfig *config = KABPrefs::instance()->getConfig();
106#endif //KAB_EMBEDDED 106#endif //KAB_EMBEDDED
107 KABC::Addressee addr; 107 KABC::Addressee addr;
108 108
109 if ( index >= 0 && index < mStyleCombo->count() ) { 109 if ( index >= 0 && index < mStyleCombo->count() ) {
110 if ( mCurrentLook != 0 ) { 110 if ( mCurrentLook != 0 ) {
111 mCurrentLook->saveSettings( config ); 111 mCurrentLook->saveSettings( config );
112 addr = mCurrentLook->addressee(); 112 addr = mCurrentLook->addressee();
113 113
114 delete mCurrentLook; 114 delete mCurrentLook;
115 mCurrentLook = 0; 115 mCurrentLook = 0;
116 } 116 }
117 117
118 KABLookFactory *factory = mLookFactories.at( index ); 118 KABLookFactory *factory = mLookFactories.at( index );
119 119
120 mCurrentLook = factory->create(); 120 mCurrentLook = factory->create();
121 mDetailsStack->raiseWidget( mCurrentLook ); 121 mDetailsStack->raiseWidget( mCurrentLook );
122 122
123 connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this, 123 connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this,
124 SIGNAL( sendEmail( const QString& ) ) ); 124 SIGNAL( sendEmail( const QString& ) ) );
125 connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this, 125 connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this,
126 SIGNAL( browse( const QString& ) ) ); 126 SIGNAL( browse( const QString& ) ) );
127 } 127 }
128 128
129 mCurrentLook->restoreSettings( config ); 129 mCurrentLook->restoreSettings( config );
130 mCurrentLook->setAddressee( addr ); 130 mCurrentLook->setAddressee( addr );
131} 131}
132void ViewContainer::refreshView()
133{
134 if ( mCurrentLook ) {
135 mCurrentLook->setAddressee( mCurrentAddressee );
136 }
137}
138 132
139void ViewContainer::setAddressee( const KABC::Addressee& addressee ) 133void ViewContainer::setAddressee( const KABC::Addressee& addressee )
140{ 134{
141 if ( mCurrentLook != 0 ) { 135 if ( mCurrentLook != 0 ) {
142 if ( addressee == mCurrentAddressee )
143 return;
144 else {
145 mCurrentAddressee = addressee; 136 mCurrentAddressee = addressee;
146 mCurrentLook->setAddressee( mCurrentAddressee ); 137 mCurrentLook->setAddressee( mCurrentAddressee );
147 } 138
148 } 139 }
149} 140}
150 141
151KABC::Addressee ViewContainer::addressee() 142KABC::Addressee ViewContainer::addressee()
152{ 143{
153 static KABC::Addressee empty; // do not use! 144 static KABC::Addressee empty; // do not use!
154 145
155 if ( !mCurrentLook ) 146 if ( !mCurrentLook )
156 return empty; 147 return empty;
157 else 148 else
158 return mCurrentLook->addressee(); 149 return mCurrentLook->addressee();
159} 150}
160 151
161void ViewContainer::setReadOnly( bool state ) 152void ViewContainer::setReadOnly( bool state )
162{ 153{
163 if ( mCurrentLook ) 154 if ( mCurrentLook )
164 mCurrentLook->setReadOnly( state ); 155 mCurrentLook->setReadOnly( state );
165} 156}
166 157
167#ifndef KAB_EMBEDDED 158#ifndef KAB_EMBEDDED
168#include "detailsviewcontainer.moc" 159#include "detailsviewcontainer.moc"
169#endif //KAB_EMBEDDED 160#endif //KAB_EMBEDDED
diff --git a/kaddressbook/details/detailsviewcontainer.h b/kaddressbook/details/detailsviewcontainer.h
index b561d12..667f0cb 100644
--- a/kaddressbook/details/detailsviewcontainer.h
+++ b/kaddressbook/details/detailsviewcontainer.h
@@ -1,103 +1,102 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org> 3 Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef DETAILSVIEWCONTAINER_H 24#ifndef DETAILSVIEWCONTAINER_H
25#define DETAILSVIEWCONTAINER_H 25#define DETAILSVIEWCONTAINER_H
26 26
27#include <qptrlist.h> 27#include <qptrlist.h>
28 28
29#include "look_basic.h" 29#include "look_basic.h"
30 30
31class QComboBox; 31class QComboBox;
32class QWidgetStack; 32class QWidgetStack;
33 33
34class ViewContainer : public QWidget 34class ViewContainer : public QWidget
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 37
38 public: 38 public:
39 ViewContainer( QWidget *parent = 0, const char* name = 0 ); 39 ViewContainer( QWidget *parent = 0, const char* name = 0 );
40 40
41 /** 41 /**
42 Return the look currently selected. If there is none, it 42 Return the look currently selected. If there is none, it
43 returns zero. Do not use this pointer to store a reference 43 returns zero. Do not use this pointer to store a reference
44 to a look, the user might select another one (e.g., create 44 to a look, the user might select another one (e.g., create
45 a new object) at any time. 45 a new object) at any time.
46 */ 46 */
47 KABBasicLook *currentLook(); 47 KABBasicLook *currentLook();
48 void refreshView();
49 /** 48 /**
50 Return the contact currently displayed. 49 Return the contact currently displayed.
51 */ 50 */
52 KABC::Addressee addressee(); 51 KABC::Addressee addressee();
53 52
54 public slots: 53 public slots:
55 /** 54 /**
56 Set the contact currently displayed. 55 Set the contact currently displayed.
57 */ 56 */
58 void setAddressee( const KABC::Addressee& addressee ); 57 void setAddressee( const KABC::Addressee& addressee );
59 58
60 /** 59 /**
61 Set read-write state. 60 Set read-write state.
62 */ 61 */
63 void setReadOnly( bool state ); 62 void setReadOnly( bool state );
64 63
65 signals: 64 signals:
66 /** 65 /**
67 The contact has been changed. 66 The contact has been changed.
68 */ 67 */
69 void addresseeChanged(); 68 void addresseeChanged();
70 69
71 /** 70 /**
72 The user acticated the email address displayed. This may happen 71 The user acticated the email address displayed. This may happen
73 by, for example, clicking on the displayed mailto-URL. 72 by, for example, clicking on the displayed mailto-URL.
74 */ 73 */
75 void sendEmail( const QString& ); 74 void sendEmail( const QString& );
76 75
77 /** 76 /**
78 The user activated one of the displayed HTTP URLs. For example 77 The user activated one of the displayed HTTP URLs. For example
79 by clicking on the displayed homepage address. 78 by clicking on the displayed homepage address.
80 */ 79 */
81 void browse( const QString& ); 80 void browse( const QString& );
82 81
83 protected: 82 protected:
84 /** 83 /**
85 A style has been selected. Overloaded from base class. 84 A style has been selected. Overloaded from base class.
86 */ 85 */
87 void slotStyleSelected( int ); 86 void slotStyleSelected( int );
88 87
89 /** 88 /**
90 Register the available looks. 89 Register the available looks.
91 */ 90 */
92 void registerLooks(); 91 void registerLooks();
93 92
94 private: 93 private:
95 KABC::Addressee mCurrentAddressee; 94 KABC::Addressee mCurrentAddressee;
96 KABBasicLook *mCurrentLook; 95 KABBasicLook *mCurrentLook;
97 QPtrList<KABLookFactory> mLookFactories; 96 QPtrList<KABLookFactory> mLookFactories;
98 97
99 QComboBox *mStyleCombo; 98 QComboBox *mStyleCombo;
100 QWidgetStack *mDetailsStack; 99 QWidgetStack *mDetailsStack;
101}; 100};
102 101
103#endif 102#endif
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp
index 49d456b..48370e3 100644
--- a/kaddressbook/imagewidget.cpp
+++ b/kaddressbook/imagewidget.cpp
@@ -1,299 +1,294 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <kabc/picture.h> 24#include <kabc/picture.h>
25 25
26#ifndef KAB_EMBEDDED 26#ifndef KAB_EMBEDDED
27#include <kaccelmanager.h> 27#include <kaccelmanager.h>
28#include <kio/netaccess.h> 28#include <kio/netaccess.h>
29#include <kimageio.h> 29#include <kimageio.h>
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kdialog.h> 33#include <kdialog.h>
34#include <kiconloader.h> 34#include <kiconloader.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kurlrequester.h> 36#include <kurlrequester.h>
37#include <kurl.h> 37#include <kurl.h>
38 38
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qgroupbox.h> 40#include <qgroupbox.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlayout.h> 42#include <qlayout.h>
43#include <qpixmap.h> 43#include <qpixmap.h>
44#include <qapplication.h> 44#include <qapplication.h>
45 45
46#include "imagewidget.h" 46#include "imagewidget.h"
47 47
48ImageWidget::ImageWidget( QWidget *parent, const char *name ) 48ImageWidget::ImageWidget( QWidget *parent, const char *name )
49 : QWidget( parent, name ) 49 : QWidget( parent, name )
50{ 50{
51 QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(), 51 QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(),
52 KDialog::spacingHint() ); 52 KDialog::spacingHint() );
53 53
54 QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this ); 54 QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this );
55 QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2, 55 QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2,
56 KDialog::spacingHint() ); 56 KDialog::spacingHint() );
57 boxLayout->setRowStretch( 2, 1 ); 57 boxLayout->setRowStretch( 2, 1 );
58 58
59 mPhotoLabel = new QLabel( photoBox ); 59 mPhotoLabel = new QLabel( photoBox );
60 int fac = 9; 60 int fac = 9;
61 if ( QApplication::desktop()->width() > 320 ) 61 if ( QApplication::desktop()->width() > 320 )
62 fac = 6; 62 fac = 6;
63 mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac ); 63 mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac );
64 mPhotoLabel->setScaledContents( true ); 64 mPhotoLabel->setScaledContents( true );
65 mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 65 mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
66 boxLayout->addMultiCellWidget( mPhotoLabel, 0, 2, 0, 0 ); 66 boxLayout->addMultiCellWidget( mPhotoLabel, 0, 2, 0, 0 );
67 67
68 mPhotoUrl = new KURLRequester( photoBox ); 68 mPhotoUrl = new KURLRequester( photoBox );
69#ifndef KAB_EMBEDDED 69#ifndef KAB_EMBEDDED
70 mPhotoUrl->setFilter( KImageIO::pattern() ); 70 mPhotoUrl->setFilter( KImageIO::pattern() );
71#else //KAB_EMBEDDED 71#else //KAB_EMBEDDED
72//US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???"); 72//US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???");
73#endif //KAB_EMBEDDED 73#endif //KAB_EMBEDDED
74 74
75 75
76 boxLayout->addWidget( mPhotoUrl, 0, 1 ); 76 boxLayout->addWidget( mPhotoUrl, 0, 1 );
77 77
78 mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), photoBox ); 78 mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), photoBox );
79 mUsePhotoUrl->setEnabled( false ); 79 mUsePhotoUrl->setEnabled( false );
80 boxLayout->addWidget( mUsePhotoUrl, 1, 1 ); 80 boxLayout->addWidget( mUsePhotoUrl, 1, 1 );
81 81
82 topLayout->addWidget( photoBox, 0, 0 ); 82 topLayout->addWidget( photoBox, 0, 0 );
83 83
84 QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this ); 84 QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this );
85 boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() ); 85 boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() );
86 boxLayout->setRowStretch( 2, 1 ); 86 boxLayout->setRowStretch( 2, 1 );
87 87
88 mLogoLabel = new QLabel( logoBox ); 88 mLogoLabel = new QLabel( logoBox );
89 mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac ); 89 mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac );
90 mLogoLabel->setScaledContents( true ); 90 mLogoLabel->setScaledContents( true );
91 mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 91 mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
92 boxLayout->addMultiCellWidget( mLogoLabel, 0, 2, 0, 0 ); 92 boxLayout->addMultiCellWidget( mLogoLabel, 0, 2, 0, 0 );
93 93
94 mLogoUrl = new KURLRequester( logoBox ); 94 mLogoUrl = new KURLRequester( logoBox );
95#ifndef KAB_EMBEDDED 95#ifndef KAB_EMBEDDED
96 mLogoUrl->setFilter( KImageIO::pattern() ); 96 mLogoUrl->setFilter( KImageIO::pattern() );
97#else //KAB_EMBEDDED 97#else //KAB_EMBEDDED
98//US qDebug("ImageWidget::ImageWidget KImageIO not defined 2"); 98//US qDebug("ImageWidget::ImageWidget KImageIO not defined 2");
99#endif //KAB_EMBEDDED 99#endif //KAB_EMBEDDED
100 boxLayout->addWidget( mLogoUrl, 0, 1 ); 100 boxLayout->addWidget( mLogoUrl, 0, 1 );
101 101
102 mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), logoBox ); 102 mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), logoBox );
103 mUseLogoUrl->setEnabled( false ); 103 mUseLogoUrl->setEnabled( false );
104 boxLayout->addWidget( mUseLogoUrl, 1, 1 ); 104 boxLayout->addWidget( mUseLogoUrl, 1, 1 );
105 105
106 topLayout->addWidget( logoBox, 1, 0 ); 106 topLayout->addWidget( logoBox, 1, 0 );
107 107
108 connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), 108 connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ),
109 SIGNAL( changed() ) ); 109 SIGNAL( changed() ) );
110 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), 110 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
111 SLOT( loadPhoto() ) ); 111 SLOT( loadPhoto() ) );
112 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), 112 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
113 SIGNAL( changed() ) ); 113 SIGNAL( changed() ) );
114 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), 114 connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
115 SLOT( updateGUI() ) ); 115 SLOT( updateGUI() ) );
116 connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), 116 connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ),
117 SIGNAL( changed() ) ); 117 SIGNAL( changed() ) );
118 118
119 connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), 119 connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ),
120 SIGNAL( changed() ) ); 120 SIGNAL( changed() ) );
121 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), 121 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
122 SLOT( loadLogo() ) ); 122 SLOT( loadLogo() ) );
123 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), 123 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
124 SIGNAL( changed() ) ); 124 SIGNAL( changed() ) );
125 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), 125 connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
126 SLOT( updateGUI() ) ); 126 SLOT( updateGUI() ) );
127 connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), 127 connect( mUseLogoUrl, SIGNAL( toggled( bool ) ),
128 SIGNAL( changed() ) ); 128 SIGNAL( changed() ) );
129 129
130#ifndef KAB_EMBEDDED 130#ifndef KAB_EMBEDDED
131 KAcceleratorManager::manage( this ); 131 KAcceleratorManager::manage( this );
132#endif //KAB_EMBEDDED 132#endif //KAB_EMBEDDED
133 133
134#ifndef DESKTOP_VERSION
135 mUsePhotoUrl->setChecked( true );
136 mUseLogoUrl->setChecked( true );
137#endif
138} 134}
139 135
140ImageWidget::~ImageWidget() 136ImageWidget::~ImageWidget()
141{ 137{
142} 138}
143 139
144void ImageWidget::setPhoto( const KABC::Picture &photo ) 140void ImageWidget::setPhoto( const KABC::Picture &photo )
145{ 141{
146 bool blocked = signalsBlocked(); 142 bool blocked = signalsBlocked();
147 blockSignals( true ); 143 blockSignals( true );
148 144
149 if ( photo.isIntern() ) { 145 if ( photo.isIntern() ) {
150//US 146//US
151//US mPhotoLabel->setPixmap( photo.data() ); 147//US mPhotoLabel->setPixmap( photo.data() );
152 if (photo.data().isNull() != true) 148 if (photo.data().isNull() != true)
153 { 149 {
154 QPixmap pm; 150 QPixmap pm;
155 pm.convertFromImage(photo.data()); 151 pm.convertFromImage(photo.data());
156 152
157 mPhotoLabel->setPixmap( pm ); 153 mPhotoLabel->setPixmap( pm );
158 } 154 }
159 155
160 mUsePhotoUrl->setChecked( false ); 156 mUsePhotoUrl->setChecked( false );
161 } else { 157 } else {
162 mPhotoUrl->setURL( photo.url() ); 158 mPhotoUrl->setURL( photo.url() );
163 if ( !photo.url().isEmpty() ) 159 if ( !photo.url().isEmpty() )
164 mUsePhotoUrl->setChecked( true ); 160 mUsePhotoUrl->setChecked( true );
165 loadPhoto(); 161 loadPhoto();
166 } 162 }
167 163
168 blockSignals( blocked ); 164 blockSignals( blocked );
169} 165}
170 166
171KABC::Picture ImageWidget::photo() const 167KABC::Picture ImageWidget::photo() const
172{ 168{
173 KABC::Picture photo; 169 KABC::Picture photo;
174 170
175 if ( mUsePhotoUrl->isChecked() ) 171 if ( mUsePhotoUrl->isChecked() )
176 photo.setUrl( mPhotoUrl->url() ); 172 photo.setUrl( mPhotoUrl->url() );
177 else { 173 else {
178 QPixmap *px = mPhotoLabel->pixmap(); 174 QPixmap *px = mPhotoLabel->pixmap();
179 if ( px ) { 175 if ( px ) {
180#ifndef KAB_EMBEDDED 176#ifndef KAB_EMBEDDED
181 if ( px->height() > px->width() ) 177 if ( px->height() > px->width() )
182 photo.setData( px->convertToImage().scaleHeight( 140 ) ); 178 photo.setData( px->convertToImage().scaleHeight( 140 ) );
183 else 179 else
184 photo.setData( px->convertToImage().scaleWidth( 100 ) ); 180 photo.setData( px->convertToImage().scaleWidth( 100 ) );
185#else //KAB_EMBEDDED 181#else //KAB_EMBEDDED
186//US add teh nullcheck 182//US add teh nullcheck
187 if (px->isNull() != true ) 183 if (px->isNull() != true )
188 photo.setData( px->convertToImage() ); 184 photo.setData( px->convertToImage() );
189#endif //KAB_EMBEDDED 185#endif //KAB_EMBEDDED
190 186
191 photo.setType( "PNG" ); 187 photo.setType( "PNG" );
192 } 188 }
193 } 189 }
194 190
195 return photo; 191 return photo;
196} 192}
197 193
198void ImageWidget::setLogo( const KABC::Picture &logo ) 194void ImageWidget::setLogo( const KABC::Picture &logo )
199{ 195{
200 bool blocked = signalsBlocked(); 196 bool blocked = signalsBlocked();
201 blockSignals( true ); 197 blockSignals( true );
202 198
203 if ( logo.isIntern() ) { 199 if ( logo.isIntern() ) {
204//US 200//US
205//US mLogoLabel->setPixmap( logo.data() ); 201//US mLogoLabel->setPixmap( logo.data() );
206 if (logo.data().isNull() != true) 202 if (logo.data().isNull() != true)
207 { 203 {
208 QPixmap pm; 204 QPixmap pm;
209 pm.convertFromImage(logo.data()); 205 pm.convertFromImage(logo.data());
210 mLogoLabel->setPixmap( pm ); 206 mLogoLabel->setPixmap( pm );
211 } 207 }
212 mUseLogoUrl->setChecked( false ); 208 mUseLogoUrl->setChecked( false );
213 } else { 209 } else {
214 mLogoUrl->setURL( logo.url() ); 210 mLogoUrl->setURL( logo.url() );
215 if ( !logo.url().isEmpty() ) 211 if ( !logo.url().isEmpty() )
216 mUseLogoUrl->setChecked( true ); 212 mUseLogoUrl->setChecked( true );
217 loadLogo(); 213 loadLogo();
218 } 214 }
219 215
220 blockSignals( blocked ); 216 blockSignals( blocked );
221} 217}
222 218
223KABC::Picture ImageWidget::logo() const 219KABC::Picture ImageWidget::logo() const
224{ 220{
225 KABC::Picture logo; 221 KABC::Picture logo;
226 222
227 if ( mUseLogoUrl->isChecked() ) 223 if ( mUseLogoUrl->isChecked() )
228 logo.setUrl( mLogoUrl->url() ); 224 logo.setUrl( mLogoUrl->url() );
229 else { 225 else {
230 QPixmap *px = mLogoLabel->pixmap(); 226 QPixmap *px = mLogoLabel->pixmap();
231 if ( px ) { 227 if ( px ) {
232#ifndef KAB_EMBEDDED 228#ifndef KAB_EMBEDDED
233 if ( px->height() > px->width() ) 229 if ( px->height() > px->width() )
234 logo.setData( px->convertToImage().scaleHeight( 140 ) ); 230 logo.setData( px->convertToImage().scaleHeight( 140 ) );
235 else 231 else
236 logo.setData( px->convertToImage().scaleWidth( 100 ) ); 232 logo.setData( px->convertToImage().scaleWidth( 100 ) );
237#else //KAB_EMBEDDED 233#else //KAB_EMBEDDED
238 logo.setData( px->convertToImage() ); 234 logo.setData( px->convertToImage() );
239#endif //KAB_EMBEDDED 235#endif //KAB_EMBEDDED
240 236
241 logo.setType( "PNG" ); 237 logo.setType( "PNG" );
242 238
243 } 239 }
244 } 240 }
245 241
246 return logo; 242 return logo;
247} 243}
248 244
249void ImageWidget::loadPhoto() 245void ImageWidget::loadPhoto()
250{ 246{
251 mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); 247 mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) );
252} 248}
253 249
254void ImageWidget::loadLogo() 250void ImageWidget::loadLogo()
255{ 251{
256 mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); 252 mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) );
257} 253}
258 254
259void ImageWidget::updateGUI() 255void ImageWidget::updateGUI()
260{ 256{
261 KURLRequester *ptr = (KURLRequester*)sender(); 257 KURLRequester *ptr = (KURLRequester*)sender();
262 258
263#ifdef DESKTOP_VERSION 259
264 if ( ptr == mPhotoUrl ) 260 if ( ptr == mPhotoUrl )
265 mUsePhotoUrl->setEnabled( true ); 261 mUsePhotoUrl->setEnabled( true );
266 else if ( ptr == mLogoUrl ) 262 else if ( ptr == mLogoUrl )
267 mUseLogoUrl->setEnabled( true ); 263 mUseLogoUrl->setEnabled( true );
268#endif
269} 264}
270 265
271QPixmap ImageWidget::loadPixmap( const KURL &url ) 266QPixmap ImageWidget::loadPixmap( const KURL &url )
272{ 267{
273 QString tempFile; 268 QString tempFile;
274 QPixmap pixmap; 269 QPixmap pixmap;
275 270
276 if ( url.isEmpty() ) 271 if ( url.isEmpty() )
277 return pixmap; 272 return pixmap;
278 273
279 if ( url.isLocalFile() ) 274 if ( url.isLocalFile() )
280 pixmap = QPixmap( url.path() ); 275 pixmap = QPixmap( url.path() );
281 else 276 else
282 { 277 {
283#ifndef KAB_EMBEDDED 278#ifndef KAB_EMBEDDED
284 if ( KIO::NetAccess::download( url, tempFile ) ) { 279 if ( KIO::NetAccess::download( url, tempFile ) ) {
285 pixmap = QPixmap( tempFile ); 280 pixmap = QPixmap( tempFile );
286 KIO::NetAccess::removeTempFile( tempFile ); 281 KIO::NetAccess::removeTempFile( tempFile );
287 } 282 }
288#else //KAB_EMBEDDED 283#else //KAB_EMBEDDED
289 qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); 284 qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed");
290#endif //KAB_EMBEDDED 285#endif //KAB_EMBEDDED
291 286
292 } 287 }
293 288
294 return pixmap; 289 return pixmap;
295} 290}
296 291
297#ifndef KAB_EMBEDDED 292#ifndef KAB_EMBEDDED
298#include "imagewidget.moc" 293#include "imagewidget.moc"
299#endif //KAB_EMBEDDED 294#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index f6bdda4..e14e579 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3181 +1,3176 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
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 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118#include "xxportselectdialog.h" 118#include "xxportselectdialog.h"
119 119
120 120
121#include <kresources/selectdialog.h> 121#include <kresources/selectdialog.h>
122#include <kmessagebox.h> 122#include <kmessagebox.h>
123 123
124#include <picture.h> 124#include <picture.h>
125#include <resource.h> 125#include <resource.h>
126 126
127//US#include <qsplitter.h> 127//US#include <qsplitter.h>
128#include <qmap.h> 128#include <qmap.h>
129#include <qdir.h> 129#include <qdir.h>
130#include <qfile.h> 130#include <qfile.h>
131#include <qvbox.h> 131#include <qvbox.h>
132#include <qlayout.h> 132#include <qlayout.h>
133#include <qclipboard.h> 133#include <qclipboard.h>
134#include <qtextstream.h> 134#include <qtextstream.h>
135#include <qradiobutton.h> 135#include <qradiobutton.h>
136#include <qbuttongroup.h> 136#include <qbuttongroup.h>
137 137
138#include <libkdepim/categoryselectdialog.h> 138#include <libkdepim/categoryselectdialog.h>
139#include <libkdepim/categoryeditdialog.h> 139#include <libkdepim/categoryeditdialog.h>
140#include <kabc/vcardconverter.h> 140#include <kabc/vcardconverter.h>
141 141
142 142
143#include "addresseeutil.h" 143#include "addresseeutil.h"
144#include "undocmds.h" 144#include "undocmds.h"
145#include "addresseeeditordialog.h" 145#include "addresseeeditordialog.h"
146#include "viewmanager.h" 146#include "viewmanager.h"
147#include "details/detailsviewcontainer.h" 147#include "details/detailsviewcontainer.h"
148#include "kabprefs.h" 148#include "kabprefs.h"
149#include "xxportmanager.h" 149#include "xxportmanager.h"
150#include "incsearchwidget.h" 150#include "incsearchwidget.h"
151#include "jumpbuttonbar.h" 151#include "jumpbuttonbar.h"
152#include "extensionmanager.h" 152#include "extensionmanager.h"
153#include "addresseeconfig.h" 153#include "addresseeconfig.h"
154#include <kcmultidialog.h> 154#include <kcmultidialog.h>
155 155
156#ifdef _WIN32_ 156#ifdef _WIN32_
157 157
158#include "kaimportoldialog.h" 158#include "kaimportoldialog.h"
159#else 159#else
160#include <unistd.h> 160#include <unistd.h>
161#endif 161#endif
162// sync includes 162// sync includes
163#include <libkdepim/ksyncprofile.h> 163#include <libkdepim/ksyncprofile.h>
164#include <libkdepim/ksyncprefsdialog.h> 164#include <libkdepim/ksyncprefsdialog.h>
165 165
166 166
167class KABCatPrefs : public QDialog 167class KABCatPrefs : public QDialog
168{ 168{
169 public: 169 public:
170 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 170 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
171 QDialog( parent, name, true ) 171 QDialog( parent, name, true )
172 { 172 {
173 setCaption( i18n("Manage new Categories") ); 173 setCaption( i18n("Manage new Categories") );
174 QVBoxLayout* lay = new QVBoxLayout( this ); 174 QVBoxLayout* lay = new QVBoxLayout( this );
175 lay->setSpacing( 3 ); 175 lay->setSpacing( 3 );
176 lay->setMargin( 3 ); 176 lay->setMargin( 3 );
177 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 ); 177 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 );
178 lay->addWidget( lab ); 178 lay->addWidget( lab );
179 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 179 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
180 lay->addWidget( format ); 180 lay->addWidget( format );
181 format->setExclusive ( true ) ; 181 format->setExclusive ( true ) ;
182 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 182 addCatBut = new QRadioButton(i18n("Add to category list"), format );
183 new QRadioButton(i18n("Remove from addressees"), format ); 183 new QRadioButton(i18n("Remove from addressees"), format );
184 addCatBut->setChecked( true ); 184 addCatBut->setChecked( true );
185 QPushButton * ok = new QPushButton( i18n("OK"), this ); 185 QPushButton * ok = new QPushButton( i18n("OK"), this );
186 lay->addWidget( ok ); 186 lay->addWidget( ok );
187 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 187 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
188 lay->addWidget( cancel ); 188 lay->addWidget( cancel );
189 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 189 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
190 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 190 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
191 resize( 200, 200 ); 191 resize( 200, 200 );
192 } 192 }
193 193
194 bool addCat() { return addCatBut->isChecked(); } 194 bool addCat() { return addCatBut->isChecked(); }
195private: 195private:
196 QRadioButton* addCatBut; 196 QRadioButton* addCatBut;
197}; 197};
198 198
199 199
200 200
201class KAex2phonePrefs : public QDialog 201class KAex2phonePrefs : public QDialog
202{ 202{
203 public: 203 public:
204 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 204 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
205 QDialog( parent, name, true ) 205 QDialog( parent, name, true )
206 { 206 {
207 setCaption( i18n("Export to phone options") ); 207 setCaption( i18n("Export to phone options") );
208 QVBoxLayout* lay = new QVBoxLayout( this ); 208 QVBoxLayout* lay = new QVBoxLayout( this );
209 lay->setSpacing( 3 ); 209 lay->setSpacing( 3 );
210 lay->setMargin( 3 ); 210 lay->setMargin( 3 );
211 QLabel *lab; 211 QLabel *lab;
212 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 212 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
213 lab->setAlignment (AlignHCenter ); 213 lab->setAlignment (AlignHCenter );
214 QHBox* temphb; 214 QHBox* temphb;
215 temphb = new QHBox( this ); 215 temphb = new QHBox( this );
216 new QLabel( i18n("I/O device: "), temphb ); 216 new QLabel( i18n("I/O device: "), temphb );
217 mPhoneDevice = new QLineEdit( temphb); 217 mPhoneDevice = new QLineEdit( temphb);
218 lay->addWidget( temphb ); 218 lay->addWidget( temphb );
219 temphb = new QHBox( this ); 219 temphb = new QHBox( this );
220 new QLabel( i18n("Connection: "), temphb ); 220 new QLabel( i18n("Connection: "), temphb );
221 mPhoneConnection = new QLineEdit( temphb); 221 mPhoneConnection = new QLineEdit( temphb);
222 lay->addWidget( temphb ); 222 lay->addWidget( temphb );
223 temphb = new QHBox( this ); 223 temphb = new QHBox( this );
224 new QLabel( i18n("Model(opt.): "), temphb ); 224 new QLabel( i18n("Model(opt.): "), temphb );
225 mPhoneModel = new QLineEdit( temphb); 225 mPhoneModel = new QLineEdit( temphb);
226 lay->addWidget( temphb ); 226 lay->addWidget( temphb );
227 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 227 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
228 // lay->addWidget( mWriteToSim ); 228 // lay->addWidget( mWriteToSim );
229 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 229 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
230 lab->setAlignment (AlignHCenter ); 230 lab->setAlignment (AlignHCenter );
231 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 231 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
232 lay->addWidget( ok ); 232 lay->addWidget( ok );
233 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 233 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
234 lay->addWidget( cancel ); 234 lay->addWidget( cancel );
235 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 235 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
236 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 236 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
237 resize( 220, 240 ); 237 resize( 220, 240 );
238 238
239 } 239 }
240 240
241public: 241public:
242 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 242 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
243 QCheckBox* mWriteToSim; 243 QCheckBox* mWriteToSim;
244}; 244};
245 245
246 246
247bool pasteWithNewUid = true; 247bool pasteWithNewUid = true;
248 248
249#ifdef KAB_EMBEDDED 249#ifdef KAB_EMBEDDED
250KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 250KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
251 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 251 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
252 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 252 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
253 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 253 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
254#else //KAB_EMBEDDED 254#else //KAB_EMBEDDED
255KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 255KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
256 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 256 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
257 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 257 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
258 mReadWrite( readWrite ), mModified( false ) 258 mReadWrite( readWrite ), mModified( false )
259#endif //KAB_EMBEDDED 259#endif //KAB_EMBEDDED
260{ 260{
261 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 261 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
262 // syncManager->setBlockSave(false); 262 // syncManager->setBlockSave(false);
263 mMiniSplitter = 0; 263 mMiniSplitter = 0;
264 mExtensionBarSplitter = 0; 264 mExtensionBarSplitter = 0;
265 mIsPart = !parent->inherits( "KAddressBookMain" ); 265 mIsPart = !parent->inherits( "KAddressBookMain" );
266 mAddressBook = KABC::StdAddressBook::self(); 266 mAddressBook = KABC::StdAddressBook::self();
267 KABC::StdAddressBook::setAutomaticSave( false ); 267 KABC::StdAddressBook::setAutomaticSave( false );
268 268
269#ifndef KAB_EMBEDDED 269#ifndef KAB_EMBEDDED
270 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 270 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
271#endif //KAB_EMBEDDED 271#endif //KAB_EMBEDDED
272 272
273 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 273 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
274 SLOT( addressBookChanged() ) ); 274 SLOT( addressBookChanged() ) );
275 275
276#if 0 276#if 0
277 // LP moved to addressbook init method 277 // LP moved to addressbook init method
278 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 278 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
279 "X-Department", "KADDRESSBOOK" ); 279 "X-Department", "KADDRESSBOOK" );
280 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 280 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
281 "X-Profession", "KADDRESSBOOK" ); 281 "X-Profession", "KADDRESSBOOK" );
282 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 282 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
283 "X-AssistantsName", "KADDRESSBOOK" ); 283 "X-AssistantsName", "KADDRESSBOOK" );
284 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 284 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
285 "X-ManagersName", "KADDRESSBOOK" ); 285 "X-ManagersName", "KADDRESSBOOK" );
286 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 286 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
287 "X-SpousesName", "KADDRESSBOOK" ); 287 "X-SpousesName", "KADDRESSBOOK" );
288 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 288 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
289 "X-Office", "KADDRESSBOOK" ); 289 "X-Office", "KADDRESSBOOK" );
290 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 290 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
291 "X-IMAddress", "KADDRESSBOOK" ); 291 "X-IMAddress", "KADDRESSBOOK" );
292 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 292 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
293 "X-Anniversary", "KADDRESSBOOK" ); 293 "X-Anniversary", "KADDRESSBOOK" );
294 294
295 //US added this field to become compatible with Opie/qtopia addressbook 295 //US added this field to become compatible with Opie/qtopia addressbook
296 // values can be "female" or "male" or "". An empty field represents undefined. 296 // values can be "female" or "male" or "". An empty field represents undefined.
297 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 297 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
298 "X-Gender", "KADDRESSBOOK" ); 298 "X-Gender", "KADDRESSBOOK" );
299 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 299 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
300 "X-Children", "KADDRESSBOOK" ); 300 "X-Children", "KADDRESSBOOK" );
301 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 301 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
302 "X-FreeBusyUrl", "KADDRESSBOOK" ); 302 "X-FreeBusyUrl", "KADDRESSBOOK" );
303#endif 303#endif
304 initGUI(); 304 initGUI();
305 305
306 mIncSearchWidget->setFocus(); 306 mIncSearchWidget->setFocus();
307 307
308 308
309 connect( mViewManager, SIGNAL( selected( const QString& ) ), 309 connect( mViewManager, SIGNAL( selected( const QString& ) ),
310 SLOT( setContactSelected( const QString& ) ) ); 310 SLOT( setContactSelected( const QString& ) ) );
311 connect( mViewManager, SIGNAL( executed( const QString& ) ), 311 connect( mViewManager, SIGNAL( executed( const QString& ) ),
312 SLOT( executeContact( const QString& ) ) ); 312 SLOT( executeContact( const QString& ) ) );
313 313
314 connect( mViewManager, SIGNAL( deleteRequest( ) ), 314 connect( mViewManager, SIGNAL( deleteRequest( ) ),
315 SLOT( deleteContacts( ) ) ); 315 SLOT( deleteContacts( ) ) );
316 connect( mViewManager, SIGNAL( modified() ), 316 connect( mViewManager, SIGNAL( modified() ),
317 SLOT( setModified() ) ); 317 SLOT( setModified() ) );
318 318
319 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 319 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
320 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 320 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
321 321
322 connect( mXXPortManager, SIGNAL( modified() ), 322 connect( mXXPortManager, SIGNAL( modified() ),
323 SLOT( setModified() ) ); 323 SLOT( setModified() ) );
324 324
325 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 325 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
326 SLOT( incrementalSearch( const QString& ) ) ); 326 SLOT( incrementalSearch( const QString& ) ) );
327 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 327 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
328 mJumpButtonBar, SLOT( recreateButtons() ) ); 328 mJumpButtonBar, SLOT( recreateButtons() ) );
329 329
330 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 330 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
331 SLOT( sendMail( const QString& ) ) ); 331 SLOT( sendMail( const QString& ) ) );
332 332
333 333
334 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 334 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
335 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&))); 335 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&)));
336 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 336 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
337 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 337 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
338 338
339 339
340#ifndef KAB_EMBEDDED 340#ifndef KAB_EMBEDDED
341 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 341 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
342 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 342 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
343 343
344 connect( mDetails, SIGNAL( browse( const QString& ) ), 344 connect( mDetails, SIGNAL( browse( const QString& ) ),
345 SLOT( browse( const QString& ) ) ); 345 SLOT( browse( const QString& ) ) );
346 346
347 347
348 mAddressBookService = new KAddressBookService( this ); 348 mAddressBookService = new KAddressBookService( this );
349 349
350#endif //KAB_EMBEDDED 350#endif //KAB_EMBEDDED
351 351
352 mMessageTimer = new QTimer( this ); 352 mMessageTimer = new QTimer( this );
353 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 353 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
354 mEditorDialog = 0; 354 mEditorDialog = 0;
355 createAddresseeEditorDialog( this ); 355 createAddresseeEditorDialog( this );
356 setModified( false ); 356 setModified( false );
357 mBRdisabled = false; 357 mBRdisabled = false;
358#ifndef DESKTOP_VERSION 358#ifndef DESKTOP_VERSION
359 infrared = 0; 359 infrared = 0;
360#endif 360#endif
361 //toggleBeamReceive( ); 361 //toggleBeamReceive( );
362 //mMainWindow->toolBar()->show(); 362 //mMainWindow->toolBar()->show();
363 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 363 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
364 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 364 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
365} 365}
366 366
367void KABCore::updateToolBar() 367void KABCore::updateToolBar()
368{ 368{
369 static int iii = 0; 369 static int iii = 0;
370 ++iii; 370 ++iii;
371 mMainWindow->toolBar()->repaintMe(); 371 mMainWindow->toolBar()->repaintMe();
372 if ( iii < 5 ) 372 if ( iii < 5 )
373 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 373 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
374} 374}
375KABCore::~KABCore() 375KABCore::~KABCore()
376{ 376{
377 // save(); 377 // save();
378 //saveSettings(); 378 //saveSettings();
379 //KABPrefs::instance()->writeConfig(); 379 //KABPrefs::instance()->writeConfig();
380 delete AddresseeConfig::instance(); 380 delete AddresseeConfig::instance();
381 mAddressBook = 0; 381 mAddressBook = 0;
382 KABC::StdAddressBook::close(); 382 KABC::StdAddressBook::close();
383 383
384 delete syncManager; 384 delete syncManager;
385#ifndef DESKTOP_VERSION 385#ifndef DESKTOP_VERSION
386 if ( infrared ) 386 if ( infrared )
387 delete infrared; 387 delete infrared;
388#endif 388#endif
389} 389}
390void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 390void KABCore::receive( const QCString& cmsg, const QByteArray& data )
391{ 391{
392 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 392 qDebug("KA: QCOP message received: %s ", cmsg.data() );
393 if ( cmsg == "setDocument(QString)" ) { 393 if ( cmsg == "setDocument(QString)" ) {
394 QDataStream stream( data, IO_ReadOnly ); 394 QDataStream stream( data, IO_ReadOnly );
395 QString fileName; 395 QString fileName;
396 stream >> fileName; 396 stream >> fileName;
397 recieve( fileName ); 397 recieve( fileName );
398 return; 398 return;
399 } 399 }
400} 400}
401void KABCore::toggleBeamReceive( ) 401void KABCore::toggleBeamReceive( )
402{ 402{
403 if ( mBRdisabled ) 403 if ( mBRdisabled )
404 return; 404 return;
405#ifndef DESKTOP_VERSION 405#ifndef DESKTOP_VERSION
406 if ( infrared ) { 406 if ( infrared ) {
407 qDebug("AB disable BeamReceive "); 407 qDebug("AB disable BeamReceive ");
408 delete infrared; 408 delete infrared;
409 infrared = 0; 409 infrared = 0;
410 mActionBR->setChecked(false); 410 mActionBR->setChecked(false);
411 return; 411 return;
412 } 412 }
413 qDebug("AB enable BeamReceive "); 413 qDebug("AB enable BeamReceive ");
414 mActionBR->setChecked(true); 414 mActionBR->setChecked(true);
415 415
416 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 416 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
417 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 417 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
418#endif 418#endif
419} 419}
420 420
421 421
422void KABCore::disableBR(bool b) 422void KABCore::disableBR(bool b)
423{ 423{
424#ifndef DESKTOP_VERSION 424#ifndef DESKTOP_VERSION
425 if ( b ) { 425 if ( b ) {
426 if ( infrared ) { 426 if ( infrared ) {
427 toggleBeamReceive( ); 427 toggleBeamReceive( );
428 } 428 }
429 mBRdisabled = true; 429 mBRdisabled = true;
430 } else { 430 } else {
431 if ( mBRdisabled ) { 431 if ( mBRdisabled ) {
432 mBRdisabled = false; 432 mBRdisabled = false;
433 //toggleBeamReceive( ); 433 //toggleBeamReceive( );
434 } 434 }
435 } 435 }
436#endif 436#endif
437 437
438} 438}
439void KABCore::recieve( QString fn ) 439void KABCore::recieve( QString fn )
440{ 440{
441 //qDebug("KABCore::recieve "); 441 //qDebug("KABCore::recieve ");
442 int count = mAddressBook->importFromFile( fn, true ); 442 int count = mAddressBook->importFromFile( fn, true );
443 if ( count ) 443 if ( count )
444 setModified( true ); 444 setModified( true );
445 mViewManager->refreshView(); 445 mViewManager->refreshView();
446 message(i18n("%1 contact(s) received!").arg( count )); 446 message(i18n("%1 contact(s) received!").arg( count ));
447 topLevelWidget()->showMaximized(); 447 topLevelWidget()->showMaximized();
448 topLevelWidget()->raise(); 448 topLevelWidget()->raise();
449} 449}
450void KABCore::restoreSettings() 450void KABCore::restoreSettings()
451{ 451{
452 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 452 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
453 453
454 bool state; 454 bool state;
455 455
456 if (mMultipleViewsAtOnce) 456 if (mMultipleViewsAtOnce)
457 state = KABPrefs::instance()->mDetailsPageVisible; 457 state = KABPrefs::instance()->mDetailsPageVisible;
458 else 458 else
459 state = false; 459 state = false;
460 460
461 mActionDetails->setChecked( state ); 461 mActionDetails->setChecked( state );
462 setDetailsVisible( state ); 462 setDetailsVisible( state );
463 463
464 state = KABPrefs::instance()->mJumpButtonBarVisible; 464 state = KABPrefs::instance()->mJumpButtonBarVisible;
465 465
466 mActionJumpBar->setChecked( state ); 466 mActionJumpBar->setChecked( state );
467 setJumpButtonBarVisible( state ); 467 setJumpButtonBarVisible( state );
468/*US 468/*US
469 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 469 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
470 if ( splitterSize.count() == 0 ) { 470 if ( splitterSize.count() == 0 ) {
471 splitterSize.append( width() / 2 ); 471 splitterSize.append( width() / 2 );
472 splitterSize.append( width() / 2 ); 472 splitterSize.append( width() / 2 );
473 } 473 }
474 mMiniSplitter->setSizes( splitterSize ); 474 mMiniSplitter->setSizes( splitterSize );
475 if ( mExtensionBarSplitter ) { 475 if ( mExtensionBarSplitter ) {
476 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 476 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
477 if ( splitterSize.count() == 0 ) { 477 if ( splitterSize.count() == 0 ) {
478 splitterSize.append( width() / 2 ); 478 splitterSize.append( width() / 2 );
479 splitterSize.append( width() / 2 ); 479 splitterSize.append( width() / 2 );
480 } 480 }
481 mExtensionBarSplitter->setSizes( splitterSize ); 481 mExtensionBarSplitter->setSizes( splitterSize );
482 482
483 } 483 }
484*/ 484*/
485 mViewManager->restoreSettings(); 485 mViewManager->restoreSettings();
486 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 486 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
487 mExtensionManager->restoreSettings(); 487 mExtensionManager->restoreSettings();
488#ifdef DESKTOP_VERSION 488#ifdef DESKTOP_VERSION
489 int wid = width(); 489 int wid = width();
490 if ( wid < 10 ) 490 if ( wid < 10 )
491 wid = 400; 491 wid = 400;
492#else 492#else
493 int wid = QApplication::desktop()->width(); 493 int wid = QApplication::desktop()->width();
494 if ( wid < 640 ) 494 if ( wid < 640 )
495 wid = QApplication::desktop()->height(); 495 wid = QApplication::desktop()->height();
496#endif 496#endif
497 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 497 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
498 if ( true /*splitterSize.count() == 0*/ ) { 498 if ( true /*splitterSize.count() == 0*/ ) {
499 splitterSize.append( wid / 2 ); 499 splitterSize.append( wid / 2 );
500 splitterSize.append( wid / 2 ); 500 splitterSize.append( wid / 2 );
501 } 501 }
502 mMiniSplitter->setSizes( splitterSize ); 502 mMiniSplitter->setSizes( splitterSize );
503 if ( mExtensionBarSplitter ) { 503 if ( mExtensionBarSplitter ) {
504 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 504 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
505 if ( true /*splitterSize.count() == 0*/ ) { 505 if ( true /*splitterSize.count() == 0*/ ) {
506 splitterSize.append( wid / 2 ); 506 splitterSize.append( wid / 2 );
507 splitterSize.append( wid / 2 ); 507 splitterSize.append( wid / 2 );
508 } 508 }
509 mExtensionBarSplitter->setSizes( splitterSize ); 509 mExtensionBarSplitter->setSizes( splitterSize );
510 510
511 } 511 }
512 512
513 513
514} 514}
515 515
516void KABCore::saveSettings() 516void KABCore::saveSettings()
517{ 517{
518 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 518 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
519 if ( mExtensionBarSplitter ) 519 if ( mExtensionBarSplitter )
520 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 520 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
521 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 521 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
522 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 522 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
523#ifndef KAB_EMBEDDED 523#ifndef KAB_EMBEDDED
524 524
525 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 525 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
526 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 526 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
527#endif //KAB_EMBEDDED 527#endif //KAB_EMBEDDED
528 mExtensionManager->saveSettings(); 528 mExtensionManager->saveSettings();
529 mViewManager->saveSettings(); 529 mViewManager->saveSettings();
530 530
531 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 531 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
532} 532}
533 533
534KABC::AddressBook *KABCore::addressBook() const 534KABC::AddressBook *KABCore::addressBook() const
535{ 535{
536 return mAddressBook; 536 return mAddressBook;
537} 537}
538 538
539KConfig *KABCore::config() 539KConfig *KABCore::config()
540{ 540{
541#ifndef KAB_EMBEDDED 541#ifndef KAB_EMBEDDED
542 return KABPrefs::instance()->config(); 542 return KABPrefs::instance()->config();
543#else //KAB_EMBEDDED 543#else //KAB_EMBEDDED
544 return KABPrefs::instance()->getConfig(); 544 return KABPrefs::instance()->getConfig();
545#endif //KAB_EMBEDDED 545#endif //KAB_EMBEDDED
546} 546}
547 547
548KActionCollection *KABCore::actionCollection() const 548KActionCollection *KABCore::actionCollection() const
549{ 549{
550 return mGUIClient->actionCollection(); 550 return mGUIClient->actionCollection();
551} 551}
552 552
553KABC::Field *KABCore::currentSearchField() const 553KABC::Field *KABCore::currentSearchField() const
554{ 554{
555 if (mIncSearchWidget) 555 if (mIncSearchWidget)
556 return mIncSearchWidget->currentField(); 556 return mIncSearchWidget->currentField();
557 else 557 else
558 return 0; 558 return 0;
559} 559}
560 560
561QStringList KABCore::selectedUIDs() const 561QStringList KABCore::selectedUIDs() const
562{ 562{
563 return mViewManager->selectedUids(); 563 return mViewManager->selectedUids();
564} 564}
565 565
566KABC::Resource *KABCore::requestResource( QWidget *parent ) 566KABC::Resource *KABCore::requestResource( QWidget *parent )
567{ 567{
568 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 568 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
569 569
570 QPtrList<KRES::Resource> kresResources; 570 QPtrList<KRES::Resource> kresResources;
571 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 571 QPtrListIterator<KABC::Resource> resIt( kabcResources );
572 KABC::Resource *resource; 572 KABC::Resource *resource;
573 while ( ( resource = resIt.current() ) != 0 ) { 573 while ( ( resource = resIt.current() ) != 0 ) {
574 ++resIt; 574 ++resIt;
575 if ( !resource->readOnly() ) { 575 if ( !resource->readOnly() ) {
576 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 576 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
577 if ( res ) 577 if ( res )
578 kresResources.append( res ); 578 kresResources.append( res );
579 } 579 }
580 } 580 }
581 581
582 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 582 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
583 return static_cast<KABC::Resource*>( res ); 583 return static_cast<KABC::Resource*>( res );
584} 584}
585 585
586#ifndef KAB_EMBEDDED 586#ifndef KAB_EMBEDDED
587KAboutData *KABCore::createAboutData() 587KAboutData *KABCore::createAboutData()
588#else //KAB_EMBEDDED 588#else //KAB_EMBEDDED
589void KABCore::createAboutData() 589void KABCore::createAboutData()
590#endif //KAB_EMBEDDED 590#endif //KAB_EMBEDDED
591{ 591{
592#ifndef KAB_EMBEDDED 592#ifndef KAB_EMBEDDED
593 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 593 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
594 "3.1", I18N_NOOP( "The KDE Address Book" ), 594 "3.1", I18N_NOOP( "The KDE Address Book" ),
595 KAboutData::License_GPL_V2, 595 KAboutData::License_GPL_V2,
596 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 596 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
597 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 597 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
598 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 598 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
599 about->addAuthor( "Cornelius Schumacher", 599 about->addAuthor( "Cornelius Schumacher",
600 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 600 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
601 "schumacher@kde.org" ); 601 "schumacher@kde.org" );
602 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 602 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
603 "mpilone@slac.com" ); 603 "mpilone@slac.com" );
604 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 604 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
605 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 605 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
606 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 606 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
607 "michel@klaralvdalens-datakonsult.se" ); 607 "michel@klaralvdalens-datakonsult.se" );
608 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 608 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
609 "hansen@kde.org" ); 609 "hansen@kde.org" );
610 610
611 return about; 611 return about;
612#endif //KAB_EMBEDDED 612#endif //KAB_EMBEDDED
613 613
614 QString version; 614 QString version;
615#include <../version> 615#include <../version>
616 QMessageBox::about( this, "About KAddressbook/Pi", 616 QMessageBox::about( this, "About KAddressbook/Pi",
617 "KAddressbook/Platform-independent\n" 617 "KAddressbook/Platform-independent\n"
618 "(KA/Pi) " +version + " - " + 618 "(KA/Pi) " +version + " - " +
619#ifdef DESKTOP_VERSION 619#ifdef DESKTOP_VERSION
620 "Desktop Edition\n" 620 "Desktop Edition\n"
621#else 621#else
622 "PDA-Edition\n" 622 "PDA-Edition\n"
623 "for: Zaurus 5500 / 7x0 / 8x0\n" 623 "for: Zaurus 5500 / 7x0 / 8x0\n"
624#endif 624#endif
625 625
626 "(c) 2004 Ulf Schenk\n" 626 "(c) 2004 Ulf Schenk\n"
627 "(c) 2004 Lutz Rogowski\n" 627 "(c) 2004 Lutz Rogowski\n"
628 "(c) 1997-2003, The KDE PIM Team\n" 628 "(c) 1997-2003, The KDE PIM Team\n"
629 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 629 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
630 "Don Sanders Original author\n" 630 "Don Sanders Original author\n"
631 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 631 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
632 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 632 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
633 "Greg Stern DCOP interface\n" 633 "Greg Stern DCOP interface\n"
634 "Mark Westcot Contact pinning\n" 634 "Mark Westcot Contact pinning\n"
635 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 635 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
636 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 636 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
637#ifdef _WIN32_ 637#ifdef _WIN32_
638 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 638 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
639#endif 639#endif
640 ); 640 );
641} 641}
642 642
643void KABCore::setContactSelected( const QString &uid ) 643void KABCore::setContactSelected( const QString &uid )
644{ 644{
645 KABC::Addressee addr = mAddressBook->findByUid( uid ); 645 KABC::Addressee addr = mAddressBook->findByUid( uid );
646 if ( !mDetails->isHidden() ) 646 if ( !mDetails->isHidden() )
647 mDetails->setAddressee( addr ); 647 mDetails->setAddressee( addr );
648 648
649 if ( !addr.isEmpty() ) { 649 if ( !addr.isEmpty() ) {
650 emit contactSelected( addr.formattedName() ); 650 emit contactSelected( addr.formattedName() );
651 KABC::Picture pic = addr.photo(); 651 KABC::Picture pic = addr.photo();
652 if ( pic.isIntern() ) { 652 if ( pic.isIntern() ) {
653//US emit contactSelected( pic.data() ); 653//US emit contactSelected( pic.data() );
654//US instead use: 654//US instead use:
655 QPixmap px; 655 QPixmap px;
656 if (pic.data().isNull() != true) 656 if (pic.data().isNull() != true)
657 { 657 {
658 px.convertFromImage(pic.data()); 658 px.convertFromImage(pic.data());
659 } 659 }
660 660
661 emit contactSelected( px ); 661 emit contactSelected( px );
662 } 662 }
663 } 663 }
664 664
665 665
666 mExtensionManager->setSelectionChanged(); 666 mExtensionManager->setSelectionChanged();
667 667
668 // update the actions 668 // update the actions
669 bool selected = !uid.isEmpty(); 669 bool selected = !uid.isEmpty();
670 670
671 if ( mReadWrite ) { 671 if ( mReadWrite ) {
672 mActionCut->setEnabled( selected ); 672 mActionCut->setEnabled( selected );
673 mActionPaste->setEnabled( selected ); 673 mActionPaste->setEnabled( selected );
674 } 674 }
675 675
676 mActionCopy->setEnabled( selected ); 676 mActionCopy->setEnabled( selected );
677 mActionDelete->setEnabled( selected ); 677 mActionDelete->setEnabled( selected );
678 mActionEditAddressee->setEnabled( selected ); 678 mActionEditAddressee->setEnabled( selected );
679 mActionMail->setEnabled( selected ); 679 mActionMail->setEnabled( selected );
680 mActionMailVCard->setEnabled( selected ); 680 mActionMailVCard->setEnabled( selected );
681 //if (mActionBeam) 681 //if (mActionBeam)
682 //mActionBeam->setEnabled( selected ); 682 //mActionBeam->setEnabled( selected );
683 mActionWhoAmI->setEnabled( selected ); 683 mActionWhoAmI->setEnabled( selected );
684} 684}
685 685
686void KABCore::sendMail() 686void KABCore::sendMail()
687{ 687{
688 sendMail( mViewManager->selectedEmails().join( ", " ) ); 688 sendMail( mViewManager->selectedEmails().join( ", " ) );
689} 689}
690 690
691void KABCore::sendMail( const QString& emaillist ) 691void KABCore::sendMail( const QString& emaillist )
692{ 692{
693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
694 if (emaillist.contains(",") > 0) 694 if (emaillist.contains(",") > 0)
695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
696 else 696 else
697 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 697 ExternalAppHandler::instance()->mailToOneContact( emaillist );
698} 698}
699 699
700 700
701 701
702void KABCore::mailVCard() 702void KABCore::mailVCard()
703{ 703{
704 QStringList uids = mViewManager->selectedUids(); 704 QStringList uids = mViewManager->selectedUids();
705 if ( !uids.isEmpty() ) 705 if ( !uids.isEmpty() )
706 mailVCard( uids ); 706 mailVCard( uids );
707} 707}
708 708
709void KABCore::mailVCard( const QStringList& uids ) 709void KABCore::mailVCard( const QStringList& uids )
710{ 710{
711 QStringList urls; 711 QStringList urls;
712 712
713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
714 714
715 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 715 QString dirName = "/tmp/" + KApplication::randomString( 8 );
716 716
717 717
718 718
719 QDir().mkdir( dirName, true ); 719 QDir().mkdir( dirName, true );
720 720
721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
722 KABC::Addressee a = mAddressBook->findByUid( *it ); 722 KABC::Addressee a = mAddressBook->findByUid( *it );
723 723
724 if ( a.isEmpty() ) 724 if ( a.isEmpty() )
725 continue; 725 continue;
726 726
727 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 727 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
728 728
729 QString fileName = dirName + "/" + name; 729 QString fileName = dirName + "/" + name;
730 730
731 QFile outFile(fileName); 731 QFile outFile(fileName);
732 732
733 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 733 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
734 KABC::VCardConverter converter; 734 KABC::VCardConverter converter;
735 QString vcard; 735 QString vcard;
736 736
737 converter.addresseeToVCard( a, vcard ); 737 converter.addresseeToVCard( a, vcard );
738 738
739 QTextStream t( &outFile ); // use a text stream 739 QTextStream t( &outFile ); // use a text stream
740 t.setEncoding( QTextStream::UnicodeUTF8 ); 740 t.setEncoding( QTextStream::UnicodeUTF8 );
741 t << vcard; 741 t << vcard;
742 742
743 outFile.close(); 743 outFile.close();
744 744
745 urls.append( fileName ); 745 urls.append( fileName );
746 } 746 }
747 } 747 }
748 748
749 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 749 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
750 750
751 751
752/*US 752/*US
753 kapp->invokeMailer( QString::null, QString::null, QString::null, 753 kapp->invokeMailer( QString::null, QString::null, QString::null,
754 QString::null, // subject 754 QString::null, // subject
755 QString::null, // body 755 QString::null, // body
756 QString::null, 756 QString::null,
757 urls ); // attachments 757 urls ); // attachments
758*/ 758*/
759 759
760} 760}
761 761
762/** 762/**
763 Beams the "WhoAmI contact. 763 Beams the "WhoAmI contact.
764*/ 764*/
765void KABCore::beamMySelf() 765void KABCore::beamMySelf()
766{ 766{
767 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 767 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
768 if (!a.isEmpty()) 768 if (!a.isEmpty())
769 { 769 {
770 QStringList uids; 770 QStringList uids;
771 uids << a.uid(); 771 uids << a.uid();
772 772
773 beamVCard(uids); 773 beamVCard(uids);
774 } else { 774 } else {
775 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 775 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
776 776
777 777
778 } 778 }
779} 779}
780void KABCore::updateMainWindow() 780void KABCore::updateMainWindow()
781{ 781{
782 782
783 mMainWindow->showMaximized(); 783 mMainWindow->showMaximized();
784 mMainWindow->update(); 784 mMainWindow->update();
785} 785}
786void KABCore::resizeEvent(QResizeEvent* e ) 786void KABCore::resizeEvent(QResizeEvent* e )
787{ 787{
788 if ( !mMiniSplitter ) 788 if ( !mMiniSplitter )
789 return; 789 return;
790 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 790 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
791 if ( QApplication::desktop()->width() >= 480 ) { 791 if ( QApplication::desktop()->width() >= 480 ) {
792 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 792 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
793 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 793 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
794 mMiniSplitter->setOrientation( Qt::Horizontal); 794 mMiniSplitter->setOrientation( Qt::Horizontal);
795 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 795 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
796 if ( QApplication::desktop()->width() <= 640 ) { 796 if ( QApplication::desktop()->width() <= 640 ) {
797 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 797 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
798 mViewManager->getFilterAction()->setComboWidth( 150 ); 798 mViewManager->getFilterAction()->setComboWidth( 150 );
799 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 799 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
800 } 800 }
801 } 801 }
802 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 802 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
803 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 803 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
804 mMiniSplitter->setOrientation( Qt::Vertical ); 804 mMiniSplitter->setOrientation( Qt::Vertical );
805 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 805 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
806 if ( QApplication::desktop()->width() <= 640 ) { 806 if ( QApplication::desktop()->width() <= 640 ) {
807 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 807 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
808 mMainWindow->showMinimized(); 808 mMainWindow->showMinimized();
809 mViewManager->getFilterAction()->setComboWidth( 0 ); 809 mViewManager->getFilterAction()->setComboWidth( 0 );
810 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 810 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
811 } 811 }
812 } 812 }
813 } 813 }
814 } 814 }
815 815
816} 816}
817void KABCore::export2phone() 817void KABCore::export2phone()
818{ 818{
819 819
820 QStringList uids; 820 QStringList uids;
821 XXPortSelectDialog dlg( this, false, this ); 821 XXPortSelectDialog dlg( this, false, this );
822 if ( dlg.exec() ) 822 if ( dlg.exec() )
823 uids = dlg.uids(); 823 uids = dlg.uids();
824 else 824 else
825 return; 825 return;
826 if ( uids.isEmpty() ) 826 if ( uids.isEmpty() )
827 return; 827 return;
828 // qDebug("count %d ", uids.count()); 828 // qDebug("count %d ", uids.count());
829 829
830 KAex2phonePrefs ex2phone; 830 KAex2phonePrefs ex2phone;
831 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 831 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
832 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 832 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
833 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 833 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
834 834
835 if ( !ex2phone.exec() ) { 835 if ( !ex2phone.exec() ) {
836 return; 836 return;
837 } 837 }
838 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 838 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
839 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 839 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
840 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 840 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
841 841
842 842
843 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 843 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
844 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 844 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
845 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 845 KPimGlobalPrefs::instance()->mEx2PhoneModel );
846 846
847 QString fileName = getPhoneFile(); 847 QString fileName = getPhoneFile();
848 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 848 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
849 return; 849 return;
850 850
851 message(i18n("Exporting to phone...")); 851 message(i18n("Exporting to phone..."));
852 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 852 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
853 853
854} 854}
855QString KABCore::getPhoneFile() 855QString KABCore::getPhoneFile()
856{ 856{
857#ifdef DESKTOP_VERSION 857#ifdef DESKTOP_VERSION
858 return locateLocal("tmp", "phonefile.vcf"); 858 return locateLocal("tmp", "phonefile.vcf");
859#else 859#else
860 return "/tmp/phonefile.vcf"; 860 return "/tmp/phonefile.vcf";
861#endif 861#endif
862 862
863} 863}
864void KABCore::writeToPhone( ) 864void KABCore::writeToPhone( )
865{ 865{
866 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 866 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
867 message(i18n("Export to phone finished!")); 867 message(i18n("Export to phone finished!"));
868 else 868 else
869 qDebug(i18n("Error exporting to phone")); 869 qDebug(i18n("Error exporting to phone"));
870} 870}
871void KABCore::beamVCard() 871void KABCore::beamVCard()
872{ 872{
873 QStringList uids; 873 QStringList uids;
874 XXPortSelectDialog dlg( this, false, this ); 874 XXPortSelectDialog dlg( this, false, this );
875 if ( dlg.exec() ) 875 if ( dlg.exec() )
876 uids = dlg.uids(); 876 uids = dlg.uids();
877 else 877 else
878 return; 878 return;
879 if ( uids.isEmpty() ) 879 if ( uids.isEmpty() )
880 return; 880 return;
881 beamVCard( uids ); 881 beamVCard( uids );
882} 882}
883 883
884 884
885void KABCore::beamVCard(const QStringList& uids) 885void KABCore::beamVCard(const QStringList& uids)
886{ 886{
887 887
888 // LR: we should use the /tmp dir on the Zaurus, 888 // LR: we should use the /tmp dir on the Zaurus,
889 // because: /tmp = RAM, (HOME)/kdepim = flash memory 889 // because: /tmp = RAM, (HOME)/kdepim = flash memory
890 890
891#ifdef DESKTOP_VERSION 891#ifdef DESKTOP_VERSION
892 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 892 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
893#else 893#else
894 QString fileName = "/tmp/kapibeamfile.vcf"; 894 QString fileName = "/tmp/kapibeamfile.vcf";
895#endif 895#endif
896 896
897 KABC::VCardConverter converter; 897 KABC::VCardConverter converter;
898 QString description; 898 QString description;
899 QString datastream; 899 QString datastream;
900 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 900 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
901 KABC::Addressee a = mAddressBook->findByUid( *it ); 901 KABC::Addressee a = mAddressBook->findByUid( *it );
902 902
903 if ( a.isEmpty() ) 903 if ( a.isEmpty() )
904 continue; 904 continue;
905 905
906 if (description.isEmpty()) 906 if (description.isEmpty())
907 description = a.formattedName(); 907 description = a.formattedName();
908 908
909 QString vcard; 909 QString vcard;
910 converter.addresseeToVCard( a, vcard ); 910 converter.addresseeToVCard( a, vcard );
911 int start = 0; 911 int start = 0;
912 int next; 912 int next;
913 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 913 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
914 int semi = vcard.find(";", next); 914 int semi = vcard.find(";", next);
915 int dopp = vcard.find(":", next); 915 int dopp = vcard.find(":", next);
916 int sep; 916 int sep;
917 if ( semi < dopp && semi >= 0 ) 917 if ( semi < dopp && semi >= 0 )
918 sep = semi ; 918 sep = semi ;
919 else 919 else
920 sep = dopp; 920 sep = dopp;
921 datastream +=vcard.mid( start, next - start); 921 datastream +=vcard.mid( start, next - start);
922 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 922 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
923 start = sep; 923 start = sep;
924 } 924 }
925 datastream += vcard.mid( start,vcard.length() ); 925 datastream += vcard.mid( start,vcard.length() );
926 } 926 }
927#ifndef DESKTOP_VERSION 927#ifndef DESKTOP_VERSION
928 QFile outFile(fileName); 928 QFile outFile(fileName);
929 if ( outFile.open(IO_WriteOnly) ) { 929 if ( outFile.open(IO_WriteOnly) ) {
930 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 930 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
931 QTextStream t( &outFile ); // use a text stream 931 QTextStream t( &outFile ); // use a text stream
932 //t.setEncoding( QTextStream::UnicodeUTF8 ); 932 //t.setEncoding( QTextStream::UnicodeUTF8 );
933 t.setEncoding( QTextStream::Latin1 ); 933 t.setEncoding( QTextStream::Latin1 );
934 t <<datastream.latin1(); 934 t <<datastream.latin1();
935 outFile.close(); 935 outFile.close();
936 Ir *ir = new Ir( this ); 936 Ir *ir = new Ir( this );
937 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 937 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
938 ir->send( fileName, description, "text/x-vCard" ); 938 ir->send( fileName, description, "text/x-vCard" );
939 } else { 939 } else {
940 qDebug("Error open temp beam file "); 940 qDebug("Error open temp beam file ");
941 return; 941 return;
942 } 942 }
943#endif 943#endif
944 944
945} 945}
946 946
947void KABCore::beamDone( Ir *ir ) 947void KABCore::beamDone( Ir *ir )
948{ 948{
949#ifndef DESKTOP_VERSION 949#ifndef DESKTOP_VERSION
950 delete ir; 950 delete ir;
951#endif 951#endif
952 topLevelWidget()->raise(); 952 topLevelWidget()->raise();
953 message( i18n("Beaming finished!") ); 953 message( i18n("Beaming finished!") );
954} 954}
955 955
956 956
957void KABCore::browse( const QString& url ) 957void KABCore::browse( const QString& url )
958{ 958{
959#ifndef KAB_EMBEDDED 959#ifndef KAB_EMBEDDED
960 kapp->invokeBrowser( url ); 960 kapp->invokeBrowser( url );
961#else //KAB_EMBEDDED 961#else //KAB_EMBEDDED
962 qDebug("KABCore::browse must be fixed"); 962 qDebug("KABCore::browse must be fixed");
963#endif //KAB_EMBEDDED 963#endif //KAB_EMBEDDED
964} 964}
965 965
966void KABCore::selectAllContacts() 966void KABCore::selectAllContacts()
967{ 967{
968 mViewManager->setSelected( QString::null, true ); 968 mViewManager->setSelected( QString::null, true );
969} 969}
970 970
971void KABCore::deleteContacts() 971void KABCore::deleteContacts()
972{ 972{
973 QStringList uidList = mViewManager->selectedUids(); 973 QStringList uidList = mViewManager->selectedUids();
974 deleteContacts( uidList ); 974 deleteContacts( uidList );
975} 975}
976 976
977void KABCore::deleteContacts( const QStringList &uids ) 977void KABCore::deleteContacts( const QStringList &uids )
978{ 978{
979 if ( uids.count() > 0 ) { 979 if ( uids.count() > 0 ) {
980 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 980 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
981 UndoStack::instance()->push( command ); 981 UndoStack::instance()->push( command );
982 RedoStack::instance()->clear(); 982 RedoStack::instance()->clear();
983 983
984 // now if we deleted anything, refresh 984 // now if we deleted anything, refresh
985 setContactSelected( QString::null ); 985 setContactSelected( QString::null );
986 setModified( true ); 986 setModified( true );
987 } 987 }
988} 988}
989 989
990void KABCore::copyContacts() 990void KABCore::copyContacts()
991{ 991{
992 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 992 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
993 993
994 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 994 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
995 995
996 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 996 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
997 997
998 QClipboard *cb = QApplication::clipboard(); 998 QClipboard *cb = QApplication::clipboard();
999 cb->setText( clipText ); 999 cb->setText( clipText );
1000} 1000}
1001 1001
1002void KABCore::cutContacts() 1002void KABCore::cutContacts()
1003{ 1003{
1004 QStringList uidList = mViewManager->selectedUids(); 1004 QStringList uidList = mViewManager->selectedUids();
1005 1005
1006//US if ( uidList.size() > 0 ) { 1006//US if ( uidList.size() > 0 ) {
1007 if ( uidList.count() > 0 ) { 1007 if ( uidList.count() > 0 ) {
1008 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1008 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1009 UndoStack::instance()->push( command ); 1009 UndoStack::instance()->push( command );
1010 RedoStack::instance()->clear(); 1010 RedoStack::instance()->clear();
1011 1011
1012 setModified( true ); 1012 setModified( true );
1013 } 1013 }
1014} 1014}
1015 1015
1016void KABCore::pasteContacts() 1016void KABCore::pasteContacts()
1017{ 1017{
1018 QClipboard *cb = QApplication::clipboard(); 1018 QClipboard *cb = QApplication::clipboard();
1019 1019
1020 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1020 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1021 1021
1022 pasteContacts( list ); 1022 pasteContacts( list );
1023} 1023}
1024 1024
1025void KABCore::pasteContacts( KABC::Addressee::List &list ) 1025void KABCore::pasteContacts( KABC::Addressee::List &list )
1026{ 1026{
1027 KABC::Resource *resource = requestResource( this ); 1027 KABC::Resource *resource = requestResource( this );
1028 KABC::Addressee::List::Iterator it; 1028 KABC::Addressee::List::Iterator it;
1029 for ( it = list.begin(); it != list.end(); ++it ) 1029 for ( it = list.begin(); it != list.end(); ++it )
1030 (*it).setResource( resource ); 1030 (*it).setResource( resource );
1031 1031
1032 PwPasteCommand *command = new PwPasteCommand( this, list ); 1032 PwPasteCommand *command = new PwPasteCommand( this, list );
1033 UndoStack::instance()->push( command ); 1033 UndoStack::instance()->push( command );
1034 RedoStack::instance()->clear(); 1034 RedoStack::instance()->clear();
1035 1035
1036 setModified( true ); 1036 setModified( true );
1037} 1037}
1038 1038
1039void KABCore::setWhoAmI() 1039void KABCore::setWhoAmI()
1040{ 1040{
1041 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1041 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1042 1042
1043 if ( addrList.count() > 1 ) { 1043 if ( addrList.count() > 1 ) {
1044 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1044 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1045 return; 1045 return;
1046 } 1046 }
1047 1047
1048 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1048 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1049 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1049 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1050 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1050 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1051} 1051}
1052void KABCore::editCategories() 1052void KABCore::editCategories()
1053{ 1053{
1054 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1054 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1055 dlg.exec(); 1055 dlg.exec();
1056} 1056}
1057void KABCore::setCategories() 1057void KABCore::setCategories()
1058{ 1058{
1059 1059
1060 QStringList uids; 1060 QStringList uids;
1061 XXPortSelectDialog dlgx( this, false, this ); 1061 XXPortSelectDialog dlgx( this, false, this );
1062 if ( dlgx.exec() ) 1062 if ( dlgx.exec() )
1063 uids = dlgx.uids(); 1063 uids = dlgx.uids();
1064 else 1064 else
1065 return; 1065 return;
1066 if ( uids.isEmpty() ) 1066 if ( uids.isEmpty() )
1067 return; 1067 return;
1068 // qDebug("count %d ", uids.count()); 1068 // qDebug("count %d ", uids.count());
1069 1069
1070 1070
1071 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1071 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1072 if ( !dlg.exec() ) { 1072 if ( !dlg.exec() ) {
1073 message( i18n("Setting categories cancelled") ); 1073 message( i18n("Setting categories cancelled") );
1074 return; 1074 return;
1075 } 1075 }
1076 bool merge = false; 1076 bool merge = false;
1077 QString msg = i18n( "Merge with existing categories?" ); 1077 QString msg = i18n( "Merge with existing categories?" );
1078 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1078 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1079 merge = true; 1079 merge = true;
1080 1080
1081 message( i18n("Setting categories ... please wait!") ); 1081 message( i18n("Setting categories ... please wait!") );
1082 QStringList categories = dlg.selectedCategories(); 1082 QStringList categories = dlg.selectedCategories();
1083 1083
1084 //QStringList uids = mViewManager->selectedUids(); 1084 //QStringList uids = mViewManager->selectedUids();
1085 QStringList::Iterator it; 1085 QStringList::Iterator it;
1086 for ( it = uids.begin(); it != uids.end(); ++it ) { 1086 for ( it = uids.begin(); it != uids.end(); ++it ) {
1087 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1087 KABC::Addressee addr = mAddressBook->findByUid( *it );
1088 if ( !addr.isEmpty() ) { 1088 if ( !addr.isEmpty() ) {
1089 if ( !merge ) 1089 if ( !merge )
1090 addr.setCategories( categories ); 1090 addr.setCategories( categories );
1091 else { 1091 else {
1092 QStringList addrCategories = addr.categories(); 1092 QStringList addrCategories = addr.categories();
1093 QStringList::Iterator catIt; 1093 QStringList::Iterator catIt;
1094 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1094 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1095 if ( !addrCategories.contains( *catIt ) ) 1095 if ( !addrCategories.contains( *catIt ) )
1096 addrCategories.append( *catIt ); 1096 addrCategories.append( *catIt );
1097 } 1097 }
1098 addr.setCategories( addrCategories ); 1098 addr.setCategories( addrCategories );
1099 } 1099 }
1100 mAddressBook->insertAddressee( addr ); 1100 mAddressBook->insertAddressee( addr );
1101 } 1101 }
1102 } 1102 }
1103 1103
1104 if ( uids.count() > 0 ) 1104 if ( uids.count() > 0 )
1105 setModified( true ); 1105 setModified( true );
1106 message( i18n("Setting categories completed!") ); 1106 message( i18n("Setting categories completed!") );
1107} 1107}
1108 1108
1109void KABCore::setSearchFields( const KABC::Field::List &fields ) 1109void KABCore::setSearchFields( const KABC::Field::List &fields )
1110{ 1110{
1111 mIncSearchWidget->setFields( fields ); 1111 mIncSearchWidget->setFields( fields );
1112} 1112}
1113 1113
1114void KABCore::incrementalSearch( const QString& text ) 1114void KABCore::incrementalSearch( const QString& text )
1115{ 1115{
1116 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1116 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1117} 1117}
1118 1118
1119void KABCore::setModified() 1119void KABCore::setModified()
1120{ 1120{
1121 setModified( true ); 1121 setModified( true );
1122} 1122}
1123 1123
1124void KABCore::setModifiedWOrefresh() 1124void KABCore::setModifiedWOrefresh()
1125{ 1125{
1126 // qDebug("KABCore::setModifiedWOrefresh() "); 1126 // qDebug("KABCore::setModifiedWOrefresh() ");
1127 mModified = true; 1127 mModified = true;
1128 mActionSave->setEnabled( mModified ); 1128 mActionSave->setEnabled( mModified );
1129#ifdef DESKTOP_VERSION 1129
1130 mDetails->refreshView();
1131#endif
1132 1130
1133} 1131}
1134void KABCore::setModified( bool modified ) 1132void KABCore::setModified( bool modified )
1135{ 1133{
1136 mModified = modified; 1134 mModified = modified;
1137 mActionSave->setEnabled( mModified ); 1135 mActionSave->setEnabled( mModified );
1138 1136
1139 if ( modified ) 1137 if ( modified )
1140 mJumpButtonBar->recreateButtons(); 1138 mJumpButtonBar->recreateButtons();
1141 1139
1142 mViewManager->refreshView(); 1140 mViewManager->refreshView();
1143 mDetails->refreshView();
1144 1141
1145} 1142}
1146 1143
1147bool KABCore::modified() const 1144bool KABCore::modified() const
1148{ 1145{
1149 return mModified; 1146 return mModified;
1150} 1147}
1151 1148
1152void KABCore::contactModified( const KABC::Addressee &addr ) 1149void KABCore::contactModified( const KABC::Addressee &addr )
1153{ 1150{
1154 1151
1155 Command *command = 0; 1152 Command *command = 0;
1156 QString uid; 1153 QString uid;
1157 1154
1158 // check if it exists already 1155 // check if it exists already
1159 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1156 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1160 if ( origAddr.isEmpty() ) 1157 if ( origAddr.isEmpty() )
1161 command = new PwNewCommand( mAddressBook, addr ); 1158 command = new PwNewCommand( mAddressBook, addr );
1162 else { 1159 else {
1163 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1160 command = new PwEditCommand( mAddressBook, origAddr, addr );
1164 uid = addr.uid(); 1161 uid = addr.uid();
1165 } 1162 }
1166 1163
1167 UndoStack::instance()->push( command ); 1164 UndoStack::instance()->push( command );
1168 RedoStack::instance()->clear(); 1165 RedoStack::instance()->clear();
1169 1166 mDetails->setAddressee( addr );
1170 setModified( true ); 1167 setModified( true );
1171} 1168}
1172 1169
1173void KABCore::newContact() 1170void KABCore::newContact()
1174{ 1171{
1175 1172
1176 1173
1177 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1174 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1178 1175
1179 QPtrList<KRES::Resource> kresResources; 1176 QPtrList<KRES::Resource> kresResources;
1180 QPtrListIterator<KABC::Resource> it( kabcResources ); 1177 QPtrListIterator<KABC::Resource> it( kabcResources );
1181 KABC::Resource *resource; 1178 KABC::Resource *resource;
1182 while ( ( resource = it.current() ) != 0 ) { 1179 while ( ( resource = it.current() ) != 0 ) {
1183 ++it; 1180 ++it;
1184 if ( !resource->readOnly() ) { 1181 if ( !resource->readOnly() ) {
1185 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1182 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1186 if ( res ) 1183 if ( res )
1187 kresResources.append( res ); 1184 kresResources.append( res );
1188 } 1185 }
1189 } 1186 }
1190 1187
1191 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1188 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1192 resource = static_cast<KABC::Resource*>( res ); 1189 resource = static_cast<KABC::Resource*>( res );
1193 1190
1194 if ( resource ) { 1191 if ( resource ) {
1195 KABC::Addressee addr; 1192 KABC::Addressee addr;
1196 addr.setResource( resource ); 1193 addr.setResource( resource );
1197 mEditorDialog->setAddressee( addr ); 1194 mEditorDialog->setAddressee( addr );
1198 KApplication::execDialog ( mEditorDialog ); 1195 KApplication::execDialog ( mEditorDialog );
1199 1196
1200 } else 1197 } else
1201 return; 1198 return;
1202 1199
1203 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1200 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1204 1201
1205 1202
1206} 1203}
1207 1204
1208void KABCore::addEmail( QString aStr ) 1205void KABCore::addEmail( QString aStr )
1209{ 1206{
1210#ifndef KAB_EMBEDDED 1207#ifndef KAB_EMBEDDED
1211 QString fullName, email; 1208 QString fullName, email;
1212 1209
1213 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1210 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1214 1211
1215 // Try to lookup the addressee matching the email address 1212 // Try to lookup the addressee matching the email address
1216 bool found = false; 1213 bool found = false;
1217 QStringList emailList; 1214 QStringList emailList;
1218 KABC::AddressBook::Iterator it; 1215 KABC::AddressBook::Iterator it;
1219 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1216 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1220 emailList = (*it).emails(); 1217 emailList = (*it).emails();
1221 if ( emailList.contains( email ) > 0 ) { 1218 if ( emailList.contains( email ) > 0 ) {
1222 found = true; 1219 found = true;
1223 (*it).setNameFromString( fullName ); 1220 (*it).setNameFromString( fullName );
1224 editContact( (*it).uid() ); 1221 editContact( (*it).uid() );
1225 } 1222 }
1226 } 1223 }
1227 1224
1228 if ( !found ) { 1225 if ( !found ) {
1229 KABC::Addressee addr; 1226 KABC::Addressee addr;
1230 addr.setNameFromString( fullName ); 1227 addr.setNameFromString( fullName );
1231 addr.insertEmail( email, true ); 1228 addr.insertEmail( email, true );
1232 1229
1233 mAddressBook->insertAddressee( addr ); 1230 mAddressBook->insertAddressee( addr );
1234 mViewManager->refreshView( addr.uid() ); 1231 mViewManager->refreshView( addr.uid() );
1235 editContact( addr.uid() ); 1232 editContact( addr.uid() );
1236 } 1233 }
1237#else //KAB_EMBEDDED 1234#else //KAB_EMBEDDED
1238 qDebug("KABCore::addEmail finsih method"); 1235 qDebug("KABCore::addEmail finsih method");
1239#endif //KAB_EMBEDDED 1236#endif //KAB_EMBEDDED
1240} 1237}
1241 1238
1242void KABCore::importVCard( const KURL &url, bool showPreview ) 1239void KABCore::importVCard( const KURL &url, bool showPreview )
1243{ 1240{
1244 mXXPortManager->importVCard( url, showPreview ); 1241 mXXPortManager->importVCard( url, showPreview );
1245} 1242}
1246void KABCore::importFromOL() 1243void KABCore::importFromOL()
1247{ 1244{
1248#ifdef _WIN32_ 1245#ifdef _WIN32_
1249 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1246 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1250 idgl->exec(); 1247 idgl->exec();
1251 KABC::Addressee::List list = idgl->getAddressList(); 1248 KABC::Addressee::List list = idgl->getAddressList();
1252 if ( list.count() > 0 ) { 1249 if ( list.count() > 0 ) {
1253 KABC::Addressee::List listNew; 1250 KABC::Addressee::List listNew;
1254 KABC::Addressee::List listExisting; 1251 KABC::Addressee::List listExisting;
1255 KABC::Addressee::List::Iterator it; 1252 KABC::Addressee::List::Iterator it;
1256 KABC::AddressBook::Iterator iter; 1253 KABC::AddressBook::Iterator iter;
1257 for ( it = list.begin(); it != list.end(); ++it ) { 1254 for ( it = list.begin(); it != list.end(); ++it ) {
1258 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1255 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1259 listNew.append( (*it) ); 1256 listNew.append( (*it) );
1260 else 1257 else
1261 listExisting.append( (*it) ); 1258 listExisting.append( (*it) );
1262 } 1259 }
1263 if ( listExisting.count() > 0 ) 1260 if ( listExisting.count() > 0 )
1264 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1261 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1265 if ( listNew.count() > 0 ) { 1262 if ( listNew.count() > 0 ) {
1266 pasteWithNewUid = false; 1263 pasteWithNewUid = false;
1267 pasteContacts( listNew ); 1264 pasteContacts( listNew );
1268 pasteWithNewUid = true; 1265 pasteWithNewUid = true;
1269 } 1266 }
1270 } 1267 }
1271 delete idgl; 1268 delete idgl;
1272#endif 1269#endif
1273} 1270}
1274 1271
1275void KABCore::importVCard( const QString &vCard, bool showPreview ) 1272void KABCore::importVCard( const QString &vCard, bool showPreview )
1276{ 1273{
1277 mXXPortManager->importVCard( vCard, showPreview ); 1274 mXXPortManager->importVCard( vCard, showPreview );
1278} 1275}
1279 1276
1280//US added a second method without defaultparameter 1277//US added a second method without defaultparameter
1281void KABCore::editContact2() { 1278void KABCore::editContact2() {
1282 editContact( QString::null ); 1279 editContact( QString::null );
1283} 1280}
1284 1281
1285void KABCore::editContact( const QString &uid ) 1282void KABCore::editContact( const QString &uid )
1286{ 1283{
1287 1284
1288 if ( mExtensionManager->isQuickEditVisible() ) 1285 if ( mExtensionManager->isQuickEditVisible() )
1289 return; 1286 return;
1290 1287
1291 // First, locate the contact entry 1288 // First, locate the contact entry
1292 QString localUID = uid; 1289 QString localUID = uid;
1293 if ( localUID.isNull() ) { 1290 if ( localUID.isNull() ) {
1294 QStringList uidList = mViewManager->selectedUids(); 1291 QStringList uidList = mViewManager->selectedUids();
1295 if ( uidList.count() > 0 ) 1292 if ( uidList.count() > 0 )
1296 localUID = *( uidList.at( 0 ) ); 1293 localUID = *( uidList.at( 0 ) );
1297 } 1294 }
1298 1295
1299 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1296 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1300 if ( !addr.isEmpty() ) { 1297 if ( !addr.isEmpty() ) {
1301 mEditorDialog->setAddressee( addr ); 1298 mEditorDialog->setAddressee( addr );
1302 KApplication::execDialog ( mEditorDialog ); 1299 KApplication::execDialog ( mEditorDialog );
1303 } 1300 }
1304} 1301}
1305 1302
1306/** 1303/**
1307 Shows or edits the detail view for the given uid. If the uid is QString::null, 1304 Shows or edits the detail view for the given uid. If the uid is QString::null,
1308 the method will try to find a selected addressee in the view. 1305 the method will try to find a selected addressee in the view.
1309 */ 1306 */
1310void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1307void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1311{ 1308{
1312 if ( mMultipleViewsAtOnce ) 1309 if ( mMultipleViewsAtOnce )
1313 { 1310 {
1314 editContact( uid ); 1311 editContact( uid );
1315 } 1312 }
1316 else 1313 else
1317 { 1314 {
1318 setDetailsVisible( true ); 1315 setDetailsVisible( true );
1319 mActionDetails->setChecked(true); 1316 mActionDetails->setChecked(true);
1320 } 1317 }
1321 1318
1322} 1319}
1323 1320
1324void KABCore::save() 1321void KABCore::save()
1325{ 1322{
1326 if (syncManager->blockSave()) 1323 if (syncManager->blockSave())
1327 return; 1324 return;
1328 if ( !mModified ) 1325 if ( !mModified )
1329 return; 1326 return;
1330 1327
1331 syncManager->setBlockSave(true); 1328 syncManager->setBlockSave(true);
1332 QString text = i18n( "There was an error while attempting to save\n the " 1329 QString text = i18n( "There was an error while attempting to save\n the "
1333 "address book. Please check that some \nother application is " 1330 "address book. Please check that some \nother application is "
1334 "not using it. " ); 1331 "not using it. " );
1335 message(i18n("Saving addressbook ... ")); 1332 message(i18n("Saving addressbook ... "));
1336#ifndef KAB_EMBEDDED 1333#ifndef KAB_EMBEDDED
1337 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1334 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1338 if ( !b || !b->save() ) { 1335 if ( !b || !b->save() ) {
1339 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1336 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1340 } 1337 }
1341#else //KAB_EMBEDDED 1338#else //KAB_EMBEDDED
1342 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1339 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1343 if ( !b || !b->save() ) { 1340 if ( !b || !b->save() ) {
1344 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1341 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1345 } 1342 }
1346#endif //KAB_EMBEDDED 1343#endif //KAB_EMBEDDED
1347 1344
1348 message(i18n("Addressbook saved!")); 1345 message(i18n("Addressbook saved!"));
1349 setModified( false ); 1346 setModified( false );
1350 syncManager->setBlockSave(false); 1347 syncManager->setBlockSave(false);
1351} 1348}
1352 1349
1353 1350
1354void KABCore::undo() 1351void KABCore::undo()
1355{ 1352{
1356 UndoStack::instance()->undo(); 1353 UndoStack::instance()->undo();
1357 1354
1358 // Refresh the view 1355 // Refresh the view
1359 mViewManager->refreshView(); 1356 mViewManager->refreshView();
1360} 1357}
1361 1358
1362void KABCore::redo() 1359void KABCore::redo()
1363{ 1360{
1364 RedoStack::instance()->redo(); 1361 RedoStack::instance()->redo();
1365 1362
1366 // Refresh the view 1363 // Refresh the view
1367 mViewManager->refreshView(); 1364 mViewManager->refreshView();
1368} 1365}
1369 1366
1370void KABCore::setJumpButtonBarVisible( bool visible ) 1367void KABCore::setJumpButtonBarVisible( bool visible )
1371{ 1368{
1372 if (mMultipleViewsAtOnce) 1369 if (mMultipleViewsAtOnce)
1373 { 1370 {
1374 if ( visible ) 1371 if ( visible )
1375 mJumpButtonBar->show(); 1372 mJumpButtonBar->show();
1376 else 1373 else
1377 mJumpButtonBar->hide(); 1374 mJumpButtonBar->hide();
1378 } 1375 }
1379 else 1376 else
1380 { 1377 {
1381 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1378 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1382 if (mViewManager->isVisible()) 1379 if (mViewManager->isVisible())
1383 { 1380 {
1384 if ( visible ) 1381 if ( visible )
1385 mJumpButtonBar->show(); 1382 mJumpButtonBar->show();
1386 else 1383 else
1387 mJumpButtonBar->hide(); 1384 mJumpButtonBar->hide();
1388 } 1385 }
1389 else 1386 else
1390 { 1387 {
1391 mJumpButtonBar->hide(); 1388 mJumpButtonBar->hide();
1392 } 1389 }
1393 } 1390 }
1394} 1391}
1395 1392
1396 1393
1397void KABCore::setDetailsToState() 1394void KABCore::setDetailsToState()
1398{ 1395{
1399 setDetailsVisible( mActionDetails->isChecked() ); 1396 setDetailsVisible( mActionDetails->isChecked() );
1400} 1397}
1401void KABCore::setDetailsToggle() 1398void KABCore::setDetailsToggle()
1402{ 1399{
1403 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1400 mActionDetails->setChecked( !mActionDetails->isChecked() );
1404 setDetailsToState(); 1401 setDetailsToState();
1405} 1402}
1406 1403
1407 1404
1408 1405
1409void KABCore::setDetailsVisible( bool visible ) 1406void KABCore::setDetailsVisible( bool visible )
1410{ 1407{
1411 if (visible && mDetails->isHidden()) 1408 if (visible && mDetails->isHidden())
1412 { 1409 {
1413 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1410 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1414 if ( addrList.count() > 0 ) 1411 if ( addrList.count() > 0 )
1415 mDetails->setAddressee( addrList[ 0 ] ); 1412 mDetails->setAddressee( addrList[ 0 ] );
1416 } 1413 }
1417 1414
1418 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1415 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1419 // the listview and the detailview. We do that by changing the splitbar size. 1416 // the listview and the detailview. We do that by changing the splitbar size.
1420 if (mMultipleViewsAtOnce) 1417 if (mMultipleViewsAtOnce)
1421 { 1418 {
1422 if ( visible ) 1419 if ( visible )
1423 mDetails->show(); 1420 mDetails->show();
1424 else 1421 else
1425 mDetails->hide(); 1422 mDetails->hide();
1426 } 1423 }
1427 else 1424 else
1428 { 1425 {
1429 if ( visible ) { 1426 if ( visible ) {
1430 mViewManager->hide(); 1427 mViewManager->hide();
1431 mDetails->show(); 1428 mDetails->show();
1432 mIncSearchWidget->setFocus(); 1429 mIncSearchWidget->setFocus();
1433 } 1430 }
1434 else { 1431 else {
1435 mViewManager->show(); 1432 mViewManager->show();
1436 mDetails->hide(); 1433 mDetails->hide();
1437 mViewManager->setFocusAV(); 1434 mViewManager->setFocusAV();
1438 } 1435 }
1439 setJumpButtonBarVisible( !visible ); 1436 setJumpButtonBarVisible( !visible );
1440 } 1437 }
1441 1438
1442} 1439}
1443 1440
1444void KABCore::extensionChanged( int id ) 1441void KABCore::extensionChanged( int id )
1445{ 1442{
1446 //change the details view only for non desktop systems 1443 //change the details view only for non desktop systems
1447#ifndef DESKTOP_VERSION 1444#ifndef DESKTOP_VERSION
1448 1445
1449 if (id == 0) 1446 if (id == 0)
1450 { 1447 {
1451 //the user disabled the extension. 1448 //the user disabled the extension.
1452 1449
1453 if (mMultipleViewsAtOnce) 1450 if (mMultipleViewsAtOnce)
1454 { // enable detailsview again 1451 { // enable detailsview again
1455 setDetailsVisible( true ); 1452 setDetailsVisible( true );
1456 mActionDetails->setChecked( true ); 1453 mActionDetails->setChecked( true );
1457 } 1454 }
1458 else 1455 else
1459 { //go back to the listview 1456 { //go back to the listview
1460 setDetailsVisible( false ); 1457 setDetailsVisible( false );
1461 mActionDetails->setChecked( false ); 1458 mActionDetails->setChecked( false );
1462 mActionDetails->setEnabled(true); 1459 mActionDetails->setEnabled(true);
1463 } 1460 }
1464 1461
1465 } 1462 }
1466 else 1463 else
1467 { 1464 {
1468 //the user enabled the extension. 1465 //the user enabled the extension.
1469 setDetailsVisible( false ); 1466 setDetailsVisible( false );
1470 mActionDetails->setChecked( false ); 1467 mActionDetails->setChecked( false );
1471 1468
1472 if (!mMultipleViewsAtOnce) 1469 if (!mMultipleViewsAtOnce)
1473 { 1470 {
1474 mActionDetails->setEnabled(false); 1471 mActionDetails->setEnabled(false);
1475 } 1472 }
1476 1473
1477 mExtensionManager->setSelectionChanged(); 1474 mExtensionManager->setSelectionChanged();
1478 1475
1479 } 1476 }
1480 1477
1481#endif// DESKTOP_VERSION 1478#endif// DESKTOP_VERSION
1482 1479
1483} 1480}
1484 1481
1485 1482
1486void KABCore::extensionModified( const KABC::Addressee::List &list ) 1483void KABCore::extensionModified( const KABC::Addressee::List &list )
1487{ 1484{
1488 1485
1489 if ( list.count() != 0 ) { 1486 if ( list.count() != 0 ) {
1490 KABC::Addressee::List::ConstIterator it; 1487 KABC::Addressee::List::ConstIterator it;
1491 for ( it = list.begin(); it != list.end(); ++it ) 1488 for ( it = list.begin(); it != list.end(); ++it )
1492 mAddressBook->insertAddressee( *it ); 1489 mAddressBook->insertAddressee( *it );
1493 if ( list.count() > 1 ) 1490 if ( list.count() > 1 )
1494 setModified(); 1491 setModified();
1495 else 1492 else
1496 setModifiedWOrefresh(); 1493 setModifiedWOrefresh();
1497 } 1494 }
1498 if ( list.count() == 0 ) 1495 if ( list.count() == 0 )
1499 mViewManager->refreshView(); 1496 mViewManager->refreshView();
1500 else 1497 else
1501 mViewManager->refreshView( list[ 0 ].uid() ); 1498 mViewManager->refreshView( list[ 0 ].uid() );
1502 1499
1503 1500
1504 1501
1505} 1502}
1506 1503
1507QString KABCore::getNameByPhone( const QString &phone ) 1504QString KABCore::getNameByPhone( const QString &phone )
1508{ 1505{
1509#ifndef KAB_EMBEDDED 1506#ifndef KAB_EMBEDDED
1510 QRegExp r( "[/*/-/ ]" ); 1507 QRegExp r( "[/*/-/ ]" );
1511 QString localPhone( phone ); 1508 QString localPhone( phone );
1512 1509
1513 bool found = false; 1510 bool found = false;
1514 QString ownerName = ""; 1511 QString ownerName = "";
1515 KABC::AddressBook::Iterator iter; 1512 KABC::AddressBook::Iterator iter;
1516 KABC::PhoneNumber::List::Iterator phoneIter; 1513 KABC::PhoneNumber::List::Iterator phoneIter;
1517 KABC::PhoneNumber::List phoneList; 1514 KABC::PhoneNumber::List phoneList;
1518 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1515 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1519 phoneList = (*iter).phoneNumbers(); 1516 phoneList = (*iter).phoneNumbers();
1520 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1517 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1521 ++phoneIter) { 1518 ++phoneIter) {
1522 // Get rid of separator chars so just the numbers are compared. 1519 // Get rid of separator chars so just the numbers are compared.
1523 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1520 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1524 ownerName = (*iter).formattedName(); 1521 ownerName = (*iter).formattedName();
1525 found = true; 1522 found = true;
1526 } 1523 }
1527 } 1524 }
1528 } 1525 }
1529 1526
1530 return ownerName; 1527 return ownerName;
1531#else //KAB_EMBEDDED 1528#else //KAB_EMBEDDED
1532 qDebug("KABCore::getNameByPhone finsih method"); 1529 qDebug("KABCore::getNameByPhone finsih method");
1533 return ""; 1530 return "";
1534#endif //KAB_EMBEDDED 1531#endif //KAB_EMBEDDED
1535 1532
1536} 1533}
1537 1534
1538void KABCore::openConfigDialog() 1535void KABCore::openConfigDialog()
1539{ 1536{
1540 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1537 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1541 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1538 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1542 ConfigureDialog->addModule(kabcfg ); 1539 ConfigureDialog->addModule(kabcfg );
1543 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1540 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1544 ConfigureDialog->addModule(kdelibcfg ); 1541 ConfigureDialog->addModule(kdelibcfg );
1545 1542
1546 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1543 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1547 this, SLOT( configurationChanged() ) ); 1544 this, SLOT( configurationChanged() ) );
1548 connect( ConfigureDialog, SIGNAL( okClicked() ), 1545 connect( ConfigureDialog, SIGNAL( okClicked() ),
1549 this, SLOT( configurationChanged() ) ); 1546 this, SLOT( configurationChanged() ) );
1550 saveSettings(); 1547 saveSettings();
1551#ifndef DESKTOP_VERSION 1548#ifndef DESKTOP_VERSION
1552 ConfigureDialog->showMaximized(); 1549 ConfigureDialog->showMaximized();
1553#endif 1550#endif
1554 if ( ConfigureDialog->exec() ) 1551 if ( ConfigureDialog->exec() )
1555 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1552 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1556 delete ConfigureDialog; 1553 delete ConfigureDialog;
1557} 1554}
1558 1555
1559void KABCore::openLDAPDialog() 1556void KABCore::openLDAPDialog()
1560{ 1557{
1561#ifndef KAB_EMBEDDED 1558#ifndef KAB_EMBEDDED
1562 if ( !mLdapSearchDialog ) { 1559 if ( !mLdapSearchDialog ) {
1563 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1560 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1564 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1561 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1565 SLOT( refreshView() ) ); 1562 SLOT( refreshView() ) );
1566 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1563 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1567 SLOT( setModified() ) ); 1564 SLOT( setModified() ) );
1568 } else 1565 } else
1569 mLdapSearchDialog->restoreSettings(); 1566 mLdapSearchDialog->restoreSettings();
1570 1567
1571 if ( mLdapSearchDialog->isOK() ) 1568 if ( mLdapSearchDialog->isOK() )
1572 mLdapSearchDialog->exec(); 1569 mLdapSearchDialog->exec();
1573#else //KAB_EMBEDDED 1570#else //KAB_EMBEDDED
1574 qDebug("KABCore::openLDAPDialog() finsih method"); 1571 qDebug("KABCore::openLDAPDialog() finsih method");
1575#endif //KAB_EMBEDDED 1572#endif //KAB_EMBEDDED
1576} 1573}
1577 1574
1578void KABCore::print() 1575void KABCore::print()
1579{ 1576{
1580#ifndef KAB_EMBEDDED 1577#ifndef KAB_EMBEDDED
1581 KPrinter printer; 1578 KPrinter printer;
1582 if ( !printer.setup( this ) ) 1579 if ( !printer.setup( this ) )
1583 return; 1580 return;
1584 1581
1585 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1582 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1586 mViewManager->selectedUids(), this ); 1583 mViewManager->selectedUids(), this );
1587 1584
1588 wizard.exec(); 1585 wizard.exec();
1589#else //KAB_EMBEDDED 1586#else //KAB_EMBEDDED
1590 qDebug("KABCore::print() finsih method"); 1587 qDebug("KABCore::print() finsih method");
1591#endif //KAB_EMBEDDED 1588#endif //KAB_EMBEDDED
1592 1589
1593} 1590}
1594 1591
1595 1592
1596void KABCore::addGUIClient( KXMLGUIClient *client ) 1593void KABCore::addGUIClient( KXMLGUIClient *client )
1597{ 1594{
1598 if ( mGUIClient ) 1595 if ( mGUIClient )
1599 mGUIClient->insertChildClient( client ); 1596 mGUIClient->insertChildClient( client );
1600 else 1597 else
1601 KMessageBox::error( this, "no KXMLGUICLient"); 1598 KMessageBox::error( this, "no KXMLGUICLient");
1602} 1599}
1603 1600
1604 1601
1605void KABCore::configurationChanged() 1602void KABCore::configurationChanged()
1606{ 1603{
1607 mExtensionManager->reconfigure(); 1604 mExtensionManager->reconfigure();
1608} 1605}
1609 1606
1610void KABCore::addressBookChanged() 1607void KABCore::addressBookChanged()
1611{ 1608{
1612/*US 1609/*US
1613 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1610 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1614 while ( it.current() ) { 1611 while ( it.current() ) {
1615 if ( it.current()->dirty() ) { 1612 if ( it.current()->dirty() ) {
1616 QString text = i18n( "Data has been changed externally. Unsaved " 1613 QString text = i18n( "Data has been changed externally. Unsaved "
1617 "changes will be lost." ); 1614 "changes will be lost." );
1618 KMessageBox::information( this, text ); 1615 KMessageBox::information( this, text );
1619 } 1616 }
1620 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1617 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1621 ++it; 1618 ++it;
1622 } 1619 }
1623*/ 1620*/
1624 if (mEditorDialog) 1621 if (mEditorDialog)
1625 { 1622 {
1626 if (mEditorDialog->dirty()) 1623 if (mEditorDialog->dirty())
1627 { 1624 {
1628 QString text = i18n( "Data has been changed externally. Unsaved " 1625 QString text = i18n( "Data has been changed externally. Unsaved "
1629 "changes will be lost." ); 1626 "changes will be lost." );
1630 KMessageBox::information( this, text ); 1627 KMessageBox::information( this, text );
1631 } 1628 }
1632 QString currentuid = mEditorDialog->addressee().uid(); 1629 QString currentuid = mEditorDialog->addressee().uid();
1633 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1630 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1634 } 1631 }
1635 mViewManager->refreshView(); 1632 mViewManager->refreshView();
1636// mDetails->refreshView();
1637 1633
1638 1634
1639} 1635}
1640 1636
1641AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1637AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1642 const char *name ) 1638 const char *name )
1643{ 1639{
1644 1640
1645 if ( mEditorDialog == 0 ) { 1641 if ( mEditorDialog == 0 ) {
1646 mEditorDialog = new AddresseeEditorDialog( this, parent, 1642 mEditorDialog = new AddresseeEditorDialog( this, parent,
1647 name ? name : "editorDialog" ); 1643 name ? name : "editorDialog" );
1648 1644
1649 1645
1650 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1646 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1651 SLOT( contactModified( const KABC::Addressee& ) ) ); 1647 SLOT( contactModified( const KABC::Addressee& ) ) );
1652 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1648 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1653 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1649 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1654 } 1650 }
1655 1651
1656 return mEditorDialog; 1652 return mEditorDialog;
1657} 1653}
1658 1654
1659void KABCore::slotEditorDestroyed( const QString &uid ) 1655void KABCore::slotEditorDestroyed( const QString &uid )
1660{ 1656{
1661 //mEditorDict.remove( uid ); 1657 //mEditorDict.remove( uid );
1662} 1658}
1663 1659
1664void KABCore::initGUI() 1660void KABCore::initGUI()
1665{ 1661{
1666#ifndef KAB_EMBEDDED 1662#ifndef KAB_EMBEDDED
1667 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1663 QHBoxLayout *topLayout = new QHBoxLayout( this );
1668 topLayout->setSpacing( KDialogBase::spacingHint() ); 1664 topLayout->setSpacing( KDialogBase::spacingHint() );
1669 1665
1670 mExtensionBarSplitter = new QSplitter( this ); 1666 mExtensionBarSplitter = new QSplitter( this );
1671 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1667 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1672 1668
1673 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1669 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1674 1670
1675 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1671 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1676 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1672 mIncSearchWidget = new IncSearchWidget( viewSpace );
1677 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1673 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1678 SLOT( incrementalSearch( const QString& ) ) ); 1674 SLOT( incrementalSearch( const QString& ) ) );
1679 1675
1680 mViewManager = new ViewManager( this, viewSpace ); 1676 mViewManager = new ViewManager( this, viewSpace );
1681 viewSpace->setStretchFactor( mViewManager, 1 ); 1677 viewSpace->setStretchFactor( mViewManager, 1 );
1682 1678
1683 mDetails = new ViewContainer( mDetailsSplitter ); 1679 mDetails = new ViewContainer( mDetailsSplitter );
1684 1680
1685 mJumpButtonBar = new JumpButtonBar( this, this ); 1681 mJumpButtonBar = new JumpButtonBar( this, this );
1686 1682
1687 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1683 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1688 1684
1689 topLayout->addWidget( mExtensionBarSplitter ); 1685 topLayout->addWidget( mExtensionBarSplitter );
1690 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1686 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1691 topLayout->addWidget( mJumpButtonBar ); 1687 topLayout->addWidget( mJumpButtonBar );
1692 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1688 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1693 1689
1694 mXXPortManager = new XXPortManager( this, this ); 1690 mXXPortManager = new XXPortManager( this, this );
1695 1691
1696#else //KAB_EMBEDDED 1692#else //KAB_EMBEDDED
1697 //US initialize viewMenu before settingup viewmanager. 1693 //US initialize viewMenu before settingup viewmanager.
1698 // Viewmanager needs this menu to plugin submenues. 1694 // Viewmanager needs this menu to plugin submenues.
1699 viewMenu = new QPopupMenu( this ); 1695 viewMenu = new QPopupMenu( this );
1700 settingsMenu = new QPopupMenu( this ); 1696 settingsMenu = new QPopupMenu( this );
1701 //filterMenu = new QPopupMenu( this ); 1697 //filterMenu = new QPopupMenu( this );
1702 ImportMenu = new QPopupMenu( this ); 1698 ImportMenu = new QPopupMenu( this );
1703 ExportMenu = new QPopupMenu( this ); 1699 ExportMenu = new QPopupMenu( this );
1704 syncMenu = new QPopupMenu( this ); 1700 syncMenu = new QPopupMenu( this );
1705 changeMenu= new QPopupMenu( this ); 1701 changeMenu= new QPopupMenu( this );
1706 beamMenu= new QPopupMenu( this ); 1702 beamMenu= new QPopupMenu( this );
1707 1703
1708//US since we have no splitter for the embedded system, setup 1704//US since we have no splitter for the embedded system, setup
1709// a layout with two frames. One left and one right. 1705// a layout with two frames. One left and one right.
1710 1706
1711 QBoxLayout *topLayout; 1707 QBoxLayout *topLayout;
1712 1708
1713 // = new QHBoxLayout( this ); 1709 // = new QHBoxLayout( this );
1714// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1710// QBoxLayout *topLayout = (QBoxLayout*)layout();
1715 1711
1716// QWidget *mainBox = new QWidget( this ); 1712// QWidget *mainBox = new QWidget( this );
1717// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1713// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1718 1714
1719#ifdef DESKTOP_VERSION 1715#ifdef DESKTOP_VERSION
1720 topLayout = new QHBoxLayout( this ); 1716 topLayout = new QHBoxLayout( this );
1721 1717
1722 1718
1723 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1719 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1724 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1720 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1725 1721
1726 topLayout->addWidget(mMiniSplitter ); 1722 topLayout->addWidget(mMiniSplitter );
1727 1723
1728 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1724 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1729 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1725 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1730 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1726 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1731 mDetails = new ViewContainer( mMiniSplitter ); 1727 mDetails = new ViewContainer( mMiniSplitter );
1732 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1728 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1733#else 1729#else
1734 if ( QApplication::desktop()->width() > 480 ) { 1730 if ( QApplication::desktop()->width() > 480 ) {
1735 topLayout = new QHBoxLayout( this ); 1731 topLayout = new QHBoxLayout( this );
1736 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1732 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1737 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1733 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1738 } else { 1734 } else {
1739 1735
1740 topLayout = new QHBoxLayout( this ); 1736 topLayout = new QHBoxLayout( this );
1741 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1737 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1742 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1738 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1743 } 1739 }
1744 1740
1745 topLayout->addWidget(mMiniSplitter ); 1741 topLayout->addWidget(mMiniSplitter );
1746 mViewManager = new ViewManager( this, mMiniSplitter ); 1742 mViewManager = new ViewManager( this, mMiniSplitter );
1747 mDetails = new ViewContainer( mMiniSplitter ); 1743 mDetails = new ViewContainer( mMiniSplitter );
1748 1744
1749 1745
1750 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1746 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1751#endif 1747#endif
1752 //eh->hide(); 1748 //eh->hide();
1753 // topLayout->addWidget(mExtensionManager ); 1749 // topLayout->addWidget(mExtensionManager );
1754 1750
1755 1751
1756/*US 1752/*US
1757#ifndef KAB_NOSPLITTER 1753#ifndef KAB_NOSPLITTER
1758 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1754 QHBoxLayout *topLayout = new QHBoxLayout( this );
1759//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1755//US topLayout->setSpacing( KDialogBase::spacingHint() );
1760 topLayout->setSpacing( 10 ); 1756 topLayout->setSpacing( 10 );
1761 1757
1762 mDetailsSplitter = new QSplitter( this ); 1758 mDetailsSplitter = new QSplitter( this );
1763 1759
1764 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1760 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1765 1761
1766 mViewManager = new ViewManager( this, viewSpace ); 1762 mViewManager = new ViewManager( this, viewSpace );
1767 viewSpace->setStretchFactor( mViewManager, 1 ); 1763 viewSpace->setStretchFactor( mViewManager, 1 );
1768 1764
1769 mDetails = new ViewContainer( mDetailsSplitter ); 1765 mDetails = new ViewContainer( mDetailsSplitter );
1770 1766
1771 topLayout->addWidget( mDetailsSplitter ); 1767 topLayout->addWidget( mDetailsSplitter );
1772 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1768 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1773#else //KAB_NOSPLITTER 1769#else //KAB_NOSPLITTER
1774 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1770 QHBoxLayout *topLayout = new QHBoxLayout( this );
1775//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1771//US topLayout->setSpacing( KDialogBase::spacingHint() );
1776 topLayout->setSpacing( 10 ); 1772 topLayout->setSpacing( 10 );
1777 1773
1778// mDetailsSplitter = new QSplitter( this ); 1774// mDetailsSplitter = new QSplitter( this );
1779 1775
1780 QVBox *viewSpace = new QVBox( this ); 1776 QVBox *viewSpace = new QVBox( this );
1781 1777
1782 mViewManager = new ViewManager( this, viewSpace ); 1778 mViewManager = new ViewManager( this, viewSpace );
1783 viewSpace->setStretchFactor( mViewManager, 1 ); 1779 viewSpace->setStretchFactor( mViewManager, 1 );
1784 1780
1785 mDetails = new ViewContainer( this ); 1781 mDetails = new ViewContainer( this );
1786 1782
1787 topLayout->addWidget( viewSpace ); 1783 topLayout->addWidget( viewSpace );
1788// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1784// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1789 topLayout->addWidget( mDetails ); 1785 topLayout->addWidget( mDetails );
1790#endif //KAB_NOSPLITTER 1786#endif //KAB_NOSPLITTER
1791*/ 1787*/
1792 1788
1793 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1789 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1794 syncManager->setBlockSave(false); 1790 syncManager->setBlockSave(false);
1795 1791
1796 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1792 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1797 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1793 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1798 QString sync_file = sentSyncFile(); 1794 QString sync_file = sentSyncFile();
1799 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1795 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1800 syncManager->setDefaultFileName( sync_file ); 1796 syncManager->setDefaultFileName( sync_file );
1801 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1797 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1802 1798
1803#endif //KAB_EMBEDDED 1799#endif //KAB_EMBEDDED
1804 initActions(); 1800 initActions();
1805 1801
1806#ifdef KAB_EMBEDDED 1802#ifdef KAB_EMBEDDED
1807 addActionsManually(); 1803 addActionsManually();
1808 //US make sure the export and import menues are initialized before creating the xxPortManager. 1804 //US make sure the export and import menues are initialized before creating the xxPortManager.
1809 mXXPortManager = new XXPortManager( this, this ); 1805 mXXPortManager = new XXPortManager( this, this );
1810 1806
1811 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1807 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1812 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1808 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1813 // mActionQuit->plug ( mMainWindow->toolBar()); 1809 // mActionQuit->plug ( mMainWindow->toolBar());
1814 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1810 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1815 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1811 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1816 // mIncSearchWidget->hide(); 1812 // mIncSearchWidget->hide();
1817 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1813 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1818 SLOT( incrementalSearch( const QString& ) ) ); 1814 SLOT( incrementalSearch( const QString& ) ) );
1819 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1815 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1820 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1816 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1821 1817
1822 mJumpButtonBar = new JumpButtonBar( this, this ); 1818 mJumpButtonBar = new JumpButtonBar( this, this );
1823 1819
1824 topLayout->addWidget( mJumpButtonBar ); 1820 topLayout->addWidget( mJumpButtonBar );
1825//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1821//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1826 1822
1827// mMainWindow->getIconToolBar()->raise(); 1823// mMainWindow->getIconToolBar()->raise();
1828 1824
1829#endif //KAB_EMBEDDED 1825#endif //KAB_EMBEDDED
1830 1826
1831} 1827}
1832void KABCore::initActions() 1828void KABCore::initActions()
1833{ 1829{
1834//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1830//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1835 1831
1836#ifndef KAB_EMBEDDED 1832#ifndef KAB_EMBEDDED
1837 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1833 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1838 SLOT( clipboardDataChanged() ) ); 1834 SLOT( clipboardDataChanged() ) );
1839#endif //KAB_EMBEDDED 1835#endif //KAB_EMBEDDED
1840 1836
1841 // file menu 1837 // file menu
1842 if ( mIsPart ) { 1838 if ( mIsPart ) {
1843 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1839 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1844 SLOT( sendMail() ), actionCollection(), 1840 SLOT( sendMail() ), actionCollection(),
1845 "kaddressbook_mail" ); 1841 "kaddressbook_mail" );
1846 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1842 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1847 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1843 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1848 1844
1849 } else { 1845 } else {
1850 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1846 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1851 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1847 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1852 } 1848 }
1853 1849
1854 1850
1855 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1851 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1856 SLOT( save() ), actionCollection(), "file_sync" ); 1852 SLOT( save() ), actionCollection(), "file_sync" );
1857 1853
1858 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1854 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1859 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1855 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1860 1856
1861 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1857 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1862 this, SLOT( mailVCard() ), 1858 this, SLOT( mailVCard() ),
1863 actionCollection(), "file_mail_vcard"); 1859 actionCollection(), "file_mail_vcard");
1864 1860
1865 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1861 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1866 SLOT( export2phone() ), actionCollection(), 1862 SLOT( export2phone() ), actionCollection(),
1867 "kaddressbook_ex2phone" ); 1863 "kaddressbook_ex2phone" );
1868 1864
1869 mActionBeamVCard = 0; 1865 mActionBeamVCard = 0;
1870 mActionBeam = 0; 1866 mActionBeam = 0;
1871 1867
1872#ifndef DESKTOP_VERSION 1868#ifndef DESKTOP_VERSION
1873 if ( Ir::supported() ) { 1869 if ( Ir::supported() ) {
1874 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1870 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1875 SLOT( beamVCard() ), actionCollection(), 1871 SLOT( beamVCard() ), actionCollection(),
1876 "kaddressbook_beam_vcard" ); 1872 "kaddressbook_beam_vcard" );
1877 1873
1878 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1874 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1879 SLOT( beamMySelf() ), actionCollection(), 1875 SLOT( beamMySelf() ), actionCollection(),
1880 "kaddressbook_beam_myself" ); 1876 "kaddressbook_beam_myself" );
1881 } 1877 }
1882#endif 1878#endif
1883 1879
1884 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1880 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1885 this, SLOT( editContact2() ), 1881 this, SLOT( editContact2() ),
1886 actionCollection(), "file_properties" ); 1882 actionCollection(), "file_properties" );
1887 1883
1888#ifdef KAB_EMBEDDED 1884#ifdef KAB_EMBEDDED
1889 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1885 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1890 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1886 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1891 mMainWindow, SLOT( exit() ), 1887 mMainWindow, SLOT( exit() ),
1892 actionCollection(), "quit" ); 1888 actionCollection(), "quit" );
1893#endif //KAB_EMBEDDED 1889#endif //KAB_EMBEDDED
1894 1890
1895 // edit menu 1891 // edit menu
1896 if ( mIsPart ) { 1892 if ( mIsPart ) {
1897 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1893 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1898 SLOT( copyContacts() ), actionCollection(), 1894 SLOT( copyContacts() ), actionCollection(),
1899 "kaddressbook_copy" ); 1895 "kaddressbook_copy" );
1900 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1896 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1901 SLOT( cutContacts() ), actionCollection(), 1897 SLOT( cutContacts() ), actionCollection(),
1902 "kaddressbook_cut" ); 1898 "kaddressbook_cut" );
1903 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1899 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1904 SLOT( pasteContacts() ), actionCollection(), 1900 SLOT( pasteContacts() ), actionCollection(),
1905 "kaddressbook_paste" ); 1901 "kaddressbook_paste" );
1906 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1902 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1907 SLOT( selectAllContacts() ), actionCollection(), 1903 SLOT( selectAllContacts() ), actionCollection(),
1908 "kaddressbook_select_all" ); 1904 "kaddressbook_select_all" );
1909 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1905 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1910 SLOT( undo() ), actionCollection(), 1906 SLOT( undo() ), actionCollection(),
1911 "kaddressbook_undo" ); 1907 "kaddressbook_undo" );
1912 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1908 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1913 this, SLOT( redo() ), actionCollection(), 1909 this, SLOT( redo() ), actionCollection(),
1914 "kaddressbook_redo" ); 1910 "kaddressbook_redo" );
1915 } else { 1911 } else {
1916 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1912 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1917 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1913 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1918 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1914 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1919 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1915 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1920 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1916 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1921 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1917 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1922 } 1918 }
1923 1919
1924 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1920 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1925 Key_Delete, this, SLOT( deleteContacts() ), 1921 Key_Delete, this, SLOT( deleteContacts() ),
1926 actionCollection(), "edit_delete" ); 1922 actionCollection(), "edit_delete" );
1927 1923
1928 mActionUndo->setEnabled( false ); 1924 mActionUndo->setEnabled( false );
1929 mActionRedo->setEnabled( false ); 1925 mActionRedo->setEnabled( false );
1930 1926
1931 // settings menu 1927 // settings menu
1932#ifdef KAB_EMBEDDED 1928#ifdef KAB_EMBEDDED
1933//US special menuentry to configure the addressbook resources. On KDE 1929//US special menuentry to configure the addressbook resources. On KDE
1934// you do that through the control center !!! 1930// you do that through the control center !!!
1935 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1931 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1936 SLOT( configureResources() ), actionCollection(), 1932 SLOT( configureResources() ), actionCollection(),
1937 "kaddressbook_configure_resources" ); 1933 "kaddressbook_configure_resources" );
1938#endif //KAB_EMBEDDED 1934#endif //KAB_EMBEDDED
1939 1935
1940 if ( mIsPart ) { 1936 if ( mIsPart ) {
1941 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1937 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1942 SLOT( openConfigDialog() ), actionCollection(), 1938 SLOT( openConfigDialog() ), actionCollection(),
1943 "kaddressbook_configure" ); 1939 "kaddressbook_configure" );
1944 1940
1945 //US not implemented yet 1941 //US not implemented yet
1946 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1942 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1947 // this, SLOT( configureKeyBindings() ), actionCollection(), 1943 // this, SLOT( configureKeyBindings() ), actionCollection(),
1948 // "kaddressbook_configure_shortcuts" ); 1944 // "kaddressbook_configure_shortcuts" );
1949#ifdef KAB_EMBEDDED 1945#ifdef KAB_EMBEDDED
1950 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1946 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1951 mActionConfigureToolbars->setEnabled( false ); 1947 mActionConfigureToolbars->setEnabled( false );
1952#endif //KAB_EMBEDDED 1948#endif //KAB_EMBEDDED
1953 1949
1954 } else { 1950 } else {
1955 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1951 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1956 1952
1957 //US not implemented yet 1953 //US not implemented yet
1958 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1954 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1959 } 1955 }
1960 1956
1961 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1957 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1962 actionCollection(), "options_show_jump_bar" ); 1958 actionCollection(), "options_show_jump_bar" );
1963 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1959 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1964 1960
1965 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1961 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1966 actionCollection(), "options_show_details" ); 1962 actionCollection(), "options_show_details" );
1967 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1963 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1968 1964
1969 1965
1970 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 1966 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
1971 SLOT( toggleBeamReceive() ), actionCollection(), 1967 SLOT( toggleBeamReceive() ), actionCollection(),
1972 "kaddressbook_beam_rec" ); 1968 "kaddressbook_beam_rec" );
1973 1969
1974 1970
1975 // misc 1971 // misc
1976 // only enable LDAP lookup if we can handle the protocol 1972 // only enable LDAP lookup if we can handle the protocol
1977#ifndef KAB_EMBEDDED 1973#ifndef KAB_EMBEDDED
1978 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1974 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1979 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1975 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1980 this, SLOT( openLDAPDialog() ), actionCollection(), 1976 this, SLOT( openLDAPDialog() ), actionCollection(),
1981 "ldap_lookup" ); 1977 "ldap_lookup" );
1982 } 1978 }
1983#else //KAB_EMBEDDED 1979#else //KAB_EMBEDDED
1984 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1980 //qDebug("KABCore::initActions() LDAP has to be implemented");
1985#endif //KAB_EMBEDDED 1981#endif //KAB_EMBEDDED
1986 1982
1987 1983
1988 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1984 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1989 SLOT( setWhoAmI() ), actionCollection(), 1985 SLOT( setWhoAmI() ), actionCollection(),
1990 "set_personal" ); 1986 "set_personal" );
1991 1987
1992 1988
1993 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1989 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1994 SLOT( setCategories() ), actionCollection(), 1990 SLOT( setCategories() ), actionCollection(),
1995 "edit_set_categories" ); 1991 "edit_set_categories" );
1996 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, 1992 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
1997 SLOT( editCategories() ), actionCollection(), 1993 SLOT( editCategories() ), actionCollection(),
1998 "edit__categories" ); 1994 "edit__categories" );
1999 1995
2000 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1996 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2001 SLOT( removeVoice() ), actionCollection(), 1997 SLOT( removeVoice() ), actionCollection(),
2002 "remove_voice" ); 1998 "remove_voice" );
2003 1999
2004 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2000 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2005 SLOT( manageCategories() ), actionCollection(), 2001 SLOT( manageCategories() ), actionCollection(),
2006 "remove_voice" ); 2002 "remove_voice" );
2007 2003
2008 2004
2009 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2005 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2010 SLOT( importFromOL() ), actionCollection(), 2006 SLOT( importFromOL() ), actionCollection(),
2011 "import_OL" ); 2007 "import_OL" );
2012#ifdef KAB_EMBEDDED 2008#ifdef KAB_EMBEDDED
2013 mActionLicence = new KAction( i18n( "Licence" ), 0, 2009 mActionLicence = new KAction( i18n( "Licence" ), 0,
2014 this, SLOT( showLicence() ), actionCollection(), 2010 this, SLOT( showLicence() ), actionCollection(),
2015 "licence_about_data" ); 2011 "licence_about_data" );
2016 mActionFaq = new KAction( i18n( "Faq" ), 0, 2012 mActionFaq = new KAction( i18n( "Faq" ), 0,
2017 this, SLOT( faq() ), actionCollection(), 2013 this, SLOT( faq() ), actionCollection(),
2018 "faq_about_data" ); 2014 "faq_about_data" );
2019 mActionWN = new KAction( i18n( "What's New?" ), 0, 2015 mActionWN = new KAction( i18n( "What's New?" ), 0,
2020 this, SLOT( whatsnew() ), actionCollection(), 2016 this, SLOT( whatsnew() ), actionCollection(),
2021 "wn" ); 2017 "wn" );
2022 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2018 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2023 this, SLOT( synchowto() ), actionCollection(), 2019 this, SLOT( synchowto() ), actionCollection(),
2024 "sync" ); 2020 "sync" );
2025 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2021 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2026 this, SLOT( kdesynchowto() ), actionCollection(), 2022 this, SLOT( kdesynchowto() ), actionCollection(),
2027 "kdesync" ); 2023 "kdesync" );
2028 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2024 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2029 this, SLOT( multisynchowto() ), actionCollection(), 2025 this, SLOT( multisynchowto() ), actionCollection(),
2030 "multisync" ); 2026 "multisync" );
2031 2027
2032 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2028 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2033 this, SLOT( createAboutData() ), actionCollection(), 2029 this, SLOT( createAboutData() ), actionCollection(),
2034 "kaddressbook_about_data" ); 2030 "kaddressbook_about_data" );
2035#endif //KAB_EMBEDDED 2031#endif //KAB_EMBEDDED
2036 2032
2037 clipboardDataChanged(); 2033 clipboardDataChanged();
2038 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2034 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2039 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2035 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2040} 2036}
2041 2037
2042//US we need this function, to plug all actions into the correct menues. 2038//US we need this function, to plug all actions into the correct menues.
2043// KDE uses a XML format to plug the actions, but we work her without this overhead. 2039// KDE uses a XML format to plug the actions, but we work her without this overhead.
2044void KABCore::addActionsManually() 2040void KABCore::addActionsManually()
2045{ 2041{
2046//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2042//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2047 2043
2048#ifdef KAB_EMBEDDED 2044#ifdef KAB_EMBEDDED
2049 QPopupMenu *fileMenu = new QPopupMenu( this ); 2045 QPopupMenu *fileMenu = new QPopupMenu( this );
2050 QPopupMenu *editMenu = new QPopupMenu( this ); 2046 QPopupMenu *editMenu = new QPopupMenu( this );
2051 QPopupMenu *helpMenu = new QPopupMenu( this ); 2047 QPopupMenu *helpMenu = new QPopupMenu( this );
2052 2048
2053 KToolBar* tb = mMainWindow->toolBar(); 2049 KToolBar* tb = mMainWindow->toolBar();
2054 2050
2055#ifndef DESKTOP_VERSION 2051#ifndef DESKTOP_VERSION
2056 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2052 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2057#endif 2053#endif
2058 QMenuBar* mb = mMainWindow->menuBar(); 2054 QMenuBar* mb = mMainWindow->menuBar();
2059 2055
2060 //US setup menubar. 2056 //US setup menubar.
2061 //Disable the following block if you do not want to have a menubar. 2057 //Disable the following block if you do not want to have a menubar.
2062 mb->insertItem( i18n("&File"), fileMenu ); 2058 mb->insertItem( i18n("&File"), fileMenu );
2063 mb->insertItem( i18n("&Edit"), editMenu ); 2059 mb->insertItem( i18n("&Edit"), editMenu );
2064 mb->insertItem( i18n("&View"), viewMenu ); 2060 mb->insertItem( i18n("&View"), viewMenu );
2065 mb->insertItem( i18n("&Settings"), settingsMenu ); 2061 mb->insertItem( i18n("&Settings"), settingsMenu );
2066 mb->insertItem( i18n("Synchronize"), syncMenu ); 2062 mb->insertItem( i18n("Synchronize"), syncMenu );
2067 //mb->insertItem( i18n("&Change"), changeMenu ); 2063 //mb->insertItem( i18n("&Change"), changeMenu );
2068 mb->insertItem( i18n("&Help"), helpMenu ); 2064 mb->insertItem( i18n("&Help"), helpMenu );
2069 mIncSearchWidget = new IncSearchWidget( tb ); 2065 mIncSearchWidget = new IncSearchWidget( tb );
2070 // tb->insertWidget(-1, 0, mIncSearchWidget); 2066 // tb->insertWidget(-1, 0, mIncSearchWidget);
2071#ifndef DESKTOP_VERSION 2067#ifndef DESKTOP_VERSION
2072 } else { 2068 } else {
2073 //US setup toolbar 2069 //US setup toolbar
2074 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2070 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2075 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2071 QPopupMenu *popupBarTB = new QPopupMenu( this );
2076 menuBarTB->insertItem( "ME", popupBarTB); 2072 menuBarTB->insertItem( "ME", popupBarTB);
2077 tb->insertWidget(-1, 0, menuBarTB); 2073 tb->insertWidget(-1, 0, menuBarTB);
2078 mIncSearchWidget = new IncSearchWidget( tb ); 2074 mIncSearchWidget = new IncSearchWidget( tb );
2079 2075
2080 tb->enableMoving(false); 2076 tb->enableMoving(false);
2081 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2077 popupBarTB->insertItem( i18n("&File"), fileMenu );
2082 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2078 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2083 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2079 popupBarTB->insertItem( i18n("&View"), viewMenu );
2084 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2080 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2085 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2081 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2086 mViewManager->getFilterAction()->plug ( popupBarTB); 2082 mViewManager->getFilterAction()->plug ( popupBarTB);
2087 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2083 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2088 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2084 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2089 if (QApplication::desktop()->width() > 320 ) { 2085 if (QApplication::desktop()->width() > 320 ) {
2090 // mViewManager->getFilterAction()->plug ( tb); 2086 // mViewManager->getFilterAction()->plug ( tb);
2091 } 2087 }
2092 } 2088 }
2093#endif 2089#endif
2094 // mActionQuit->plug ( mMainWindow->toolBar()); 2090 // mActionQuit->plug ( mMainWindow->toolBar());
2095 2091
2096 2092
2097 2093
2098 //US Now connect the actions with the menue entries. 2094 //US Now connect the actions with the menue entries.
2099 mActionPrint->plug( fileMenu ); 2095 mActionPrint->plug( fileMenu );
2100 mActionMail->plug( fileMenu ); 2096 mActionMail->plug( fileMenu );
2101 fileMenu->insertSeparator(); 2097 fileMenu->insertSeparator();
2102 2098
2103 mActionNewContact->plug( fileMenu ); 2099 mActionNewContact->plug( fileMenu );
2104 mActionNewContact->plug( tb ); 2100 mActionNewContact->plug( tb );
2105 2101
2106 mActionEditAddressee->plug( fileMenu ); 2102 mActionEditAddressee->plug( fileMenu );
2107 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2103 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2108 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2104 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2109 mActionEditAddressee->plug( tb ); 2105 mActionEditAddressee->plug( tb );
2110 2106
2111 fileMenu->insertSeparator(); 2107 fileMenu->insertSeparator();
2112 mActionSave->plug( fileMenu ); 2108 mActionSave->plug( fileMenu );
2113 fileMenu->insertItem( "&Import", ImportMenu ); 2109 fileMenu->insertItem( "&Import", ImportMenu );
2114 fileMenu->insertItem( "&Export", ExportMenu ); 2110 fileMenu->insertItem( "&Export", ExportMenu );
2115 fileMenu->insertItem( i18n("&Change"), changeMenu ); 2111 fileMenu->insertItem( i18n("&Change"), changeMenu );
2116#ifndef DESKTOP_VERSION 2112#ifndef DESKTOP_VERSION
2117 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2113 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2118#endif 2114#endif
2119 2115
2120 fileMenu->insertSeparator(); 2116 fileMenu->insertSeparator();
2121 mActionMailVCard->plug( fileMenu ); 2117 mActionMailVCard->plug( fileMenu );
2122#ifndef DESKTOP_VERSION 2118#ifndef DESKTOP_VERSION
2123 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2119 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2124 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2120 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2125 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2121 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2126#endif 2122#endif
2127 fileMenu->insertSeparator(); 2123 fileMenu->insertSeparator();
2128 mActionQuit->plug( fileMenu ); 2124 mActionQuit->plug( fileMenu );
2129#ifdef _WIN32_ 2125#ifdef _WIN32_
2130 mActionImportOL->plug( ImportMenu ); 2126 mActionImportOL->plug( ImportMenu );
2131#endif 2127#endif
2132 // edit menu 2128 // edit menu
2133 mActionUndo->plug( editMenu ); 2129 mActionUndo->plug( editMenu );
2134 mActionRedo->plug( editMenu ); 2130 mActionRedo->plug( editMenu );
2135 editMenu->insertSeparator(); 2131 editMenu->insertSeparator();
2136 mActionCut->plug( editMenu ); 2132 mActionCut->plug( editMenu );
2137 mActionCopy->plug( editMenu ); 2133 mActionCopy->plug( editMenu );
2138 mActionPaste->plug( editMenu ); 2134 mActionPaste->plug( editMenu );
2139 mActionDelete->plug( editMenu ); 2135 mActionDelete->plug( editMenu );
2140 editMenu->insertSeparator(); 2136 editMenu->insertSeparator();
2141 mActionSelectAll->plug( editMenu ); 2137 mActionSelectAll->plug( editMenu );
2142 2138
2143 mActionRemoveVoice->plug( changeMenu ); 2139 mActionRemoveVoice->plug( changeMenu );
2144 // settings menu 2140 // settings menu
2145//US special menuentry to configure the addressbook resources. On KDE 2141//US special menuentry to configure the addressbook resources. On KDE
2146// you do that through the control center !!! 2142// you do that through the control center !!!
2147 mActionConfigResources->plug( settingsMenu ); 2143 mActionConfigResources->plug( settingsMenu );
2148 settingsMenu->insertSeparator(); 2144 settingsMenu->insertSeparator();
2149 2145
2150 mActionConfigKAddressbook->plug( settingsMenu ); 2146 mActionConfigKAddressbook->plug( settingsMenu );
2151 2147
2152 if ( mIsPart ) { 2148 if ( mIsPart ) {
2153 //US not implemented yet 2149 //US not implemented yet
2154 //mActionConfigShortcuts->plug( settingsMenu ); 2150 //mActionConfigShortcuts->plug( settingsMenu );
2155 //mActionConfigureToolbars->plug( settingsMenu ); 2151 //mActionConfigureToolbars->plug( settingsMenu );
2156 2152
2157 } else { 2153 } else {
2158 //US not implemented yet 2154 //US not implemented yet
2159 //mActionKeyBindings->plug( settingsMenu ); 2155 //mActionKeyBindings->plug( settingsMenu );
2160 } 2156 }
2161 2157
2162 settingsMenu->insertSeparator(); 2158 settingsMenu->insertSeparator();
2163 2159
2164 mActionJumpBar->plug( settingsMenu ); 2160 mActionJumpBar->plug( settingsMenu );
2165 mActionDetails->plug( settingsMenu ); 2161 mActionDetails->plug( settingsMenu );
2166 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2162 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2167 mActionDetails->plug( tb ); 2163 mActionDetails->plug( tb );
2168 settingsMenu->insertSeparator(); 2164 settingsMenu->insertSeparator();
2169#ifndef DESKTOP_VERSION 2165#ifndef DESKTOP_VERSION
2170 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2166 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2171#endif 2167#endif
2172 settingsMenu->insertSeparator(); 2168 settingsMenu->insertSeparator();
2173 2169
2174 mActionWhoAmI->plug( settingsMenu ); 2170 mActionWhoAmI->plug( settingsMenu );
2175 mActionEditCategories->plug( settingsMenu ); 2171 mActionEditCategories->plug( settingsMenu );
2176 mActionEditCategories->plug( changeMenu ); 2172 mActionEditCategories->plug( changeMenu );
2177 mActionCategories->plug( changeMenu ); 2173 mActionCategories->plug( changeMenu );
2178 mActionManageCategories->plug( changeMenu ); 2174 mActionManageCategories->plug( changeMenu );
2179 2175
2180 mActionCategories->plug( settingsMenu ); 2176 mActionCategories->plug( settingsMenu );
2181 mActionManageCategories->plug( settingsMenu ); 2177 mActionManageCategories->plug( settingsMenu );
2182 2178
2183 2179
2184 mActionWN->plug( helpMenu ); 2180 mActionWN->plug( helpMenu );
2185 mActionSyncHowto->plug( helpMenu ); 2181 mActionSyncHowto->plug( helpMenu );
2186 mActionKdeSyncHowto->plug( helpMenu ); 2182 mActionKdeSyncHowto->plug( helpMenu );
2187 mActionMultiSyncHowto->plug( helpMenu ); 2183 mActionMultiSyncHowto->plug( helpMenu );
2188 mActionFaq->plug( helpMenu ); 2184 mActionFaq->plug( helpMenu );
2189 mActionLicence->plug( helpMenu ); 2185 mActionLicence->plug( helpMenu );
2190 mActionAboutKAddressbook->plug( helpMenu ); 2186 mActionAboutKAddressbook->plug( helpMenu );
2191 2187
2192 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2188 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2193 2189
2194 mActionSave->plug( tb ); 2190 mActionSave->plug( tb );
2195 mViewManager->getFilterAction()->plug ( tb); 2191 mViewManager->getFilterAction()->plug ( tb);
2196 //LR hide filteraction on started in 480x640 2192 //LR hide filteraction on started in 480x640
2197 if (QApplication::desktop()->width() == 480 ) { 2193 if (QApplication::desktop()->width() == 480 ) {
2198 mViewManager->getFilterAction()->setComboWidth( 0 ); 2194 mViewManager->getFilterAction()->setComboWidth( 0 );
2199 } 2195 }
2200 mActionUndo->plug( tb ); 2196 mActionUndo->plug( tb );
2201 mActionDelete->plug( tb ); 2197 mActionDelete->plug( tb );
2202 mActionRedo->plug( tb ); 2198 mActionRedo->plug( tb );
2203 } else { 2199 } else {
2204 mActionSave->plug( tb ); 2200 mActionSave->plug( tb );
2205 tb->enableMoving(false); 2201 tb->enableMoving(false);
2206 } 2202 }
2207 //mActionQuit->plug ( tb ); 2203 //mActionQuit->plug ( tb );
2208 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2204 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2209 2205
2210 //US link the searchwidget first to this. 2206 //US link the searchwidget first to this.
2211 // The real linkage to the toolbar happens later. 2207 // The real linkage to the toolbar happens later.
2212//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2208//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2213//US tb->insertItem( mIncSearchWidget ); 2209//US tb->insertItem( mIncSearchWidget );
2214/*US 2210/*US
2215 mIncSearchWidget = new IncSearchWidget( tb ); 2211 mIncSearchWidget = new IncSearchWidget( tb );
2216 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2212 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2217 SLOT( incrementalSearch( const QString& ) ) ); 2213 SLOT( incrementalSearch( const QString& ) ) );
2218 2214
2219 mJumpButtonBar = new JumpButtonBar( this, this ); 2215 mJumpButtonBar = new JumpButtonBar( this, this );
2220 2216
2221//US topLayout->addWidget( mJumpButtonBar ); 2217//US topLayout->addWidget( mJumpButtonBar );
2222 this->layout()->add( mJumpButtonBar ); 2218 this->layout()->add( mJumpButtonBar );
2223*/ 2219*/
2224 2220
2225#endif //KAB_EMBEDDED 2221#endif //KAB_EMBEDDED
2226 2222
2227 mActionExport2phone->plug( ExportMenu ); 2223 mActionExport2phone->plug( ExportMenu );
2228 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2224 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2229 syncManager->fillSyncMenu(); 2225 syncManager->fillSyncMenu();
2230 2226
2231} 2227}
2232void KABCore::showLicence() 2228void KABCore::showLicence()
2233{ 2229{
2234 KApplication::showLicence(); 2230 KApplication::showLicence();
2235} 2231}
2236 2232
2237void KABCore::manageCategories( ) 2233void KABCore::manageCategories( )
2238{ 2234{
2239 KABCatPrefs* cp = new KABCatPrefs(); 2235 KABCatPrefs* cp = new KABCatPrefs();
2240 cp->show(); 2236 cp->show();
2241 int w =cp->sizeHint().width() ; 2237 int w =cp->sizeHint().width() ;
2242 int h = cp->sizeHint().height() ; 2238 int h = cp->sizeHint().height() ;
2243 int dw = QApplication::desktop()->width(); 2239 int dw = QApplication::desktop()->width();
2244 int dh = QApplication::desktop()->height(); 2240 int dh = QApplication::desktop()->height();
2245 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2241 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2246 if ( !cp->exec() ) { 2242 if ( !cp->exec() ) {
2247 delete cp; 2243 delete cp;
2248 return; 2244 return;
2249 } 2245 }
2250 int count = 0; 2246 int count = 0;
2251 message( i18n("Please wait, processing categories...")); 2247 message( i18n("Please wait, processing categories..."));
2252 if ( cp->addCat() ) { 2248 if ( cp->addCat() ) {
2253 KABC::AddressBook::Iterator it; 2249 KABC::AddressBook::Iterator it;
2254 QStringList catList = KABPrefs::instance()->mCustomCategories; 2250 QStringList catList = KABPrefs::instance()->mCustomCategories;
2255 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2251 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2256 QStringList catIncList = (*it).categories(); 2252 QStringList catIncList = (*it).categories();
2257 int i; 2253 int i;
2258 for( i = 0; i< catIncList.count(); ++i ) { 2254 for( i = 0; i< catIncList.count(); ++i ) {
2259 if ( !catList.contains (catIncList[i])) { 2255 if ( !catList.contains (catIncList[i])) {
2260 catList.append( catIncList[i] ); 2256 catList.append( catIncList[i] );
2261 //qDebug("add cat %s ", catIncList[i].latin1()); 2257 //qDebug("add cat %s ", catIncList[i].latin1());
2262 ++count; 2258 ++count;
2263 } 2259 }
2264 } 2260 }
2265 } 2261 }
2266 catList.sort(); 2262 catList.sort();
2267 KABPrefs::instance()->mCustomCategories = catList; 2263 KABPrefs::instance()->mCustomCategories = catList;
2268 KABPrefs::instance()->writeConfig(); 2264 KABPrefs::instance()->writeConfig();
2269 message(QString::number( count )+ i18n(" categories added to list! ")); 2265 message(QString::number( count )+ i18n(" categories added to list! "));
2270 } else { 2266 } else {
2271 QStringList catList = KABPrefs::instance()->mCustomCategories; 2267 QStringList catList = KABPrefs::instance()->mCustomCategories;
2272 QStringList catIncList; 2268 QStringList catIncList;
2273 QStringList newCatList; 2269 QStringList newCatList;
2274 KABC::AddressBook::Iterator it; 2270 KABC::AddressBook::Iterator it;
2275 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2271 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2276 QStringList catIncList = (*it).categories(); 2272 QStringList catIncList = (*it).categories();
2277 int i; 2273 int i;
2278 if ( catIncList.count() ) { 2274 if ( catIncList.count() ) {
2279 newCatList.clear(); 2275 newCatList.clear();
2280 for( i = 0; i< catIncList.count(); ++i ) { 2276 for( i = 0; i< catIncList.count(); ++i ) {
2281 if ( catList.contains (catIncList[i])) { 2277 if ( catList.contains (catIncList[i])) {
2282 newCatList.append( catIncList[i] ); 2278 newCatList.append( catIncList[i] );
2283 } 2279 }
2284 } 2280 }
2285 newCatList.sort(); 2281 newCatList.sort();
2286 (*it).setCategories( newCatList ); 2282 (*it).setCategories( newCatList );
2287 mAddressBook->insertAddressee( (*it) ); 2283 mAddressBook->insertAddressee( (*it) );
2288 } 2284 }
2289 } 2285 }
2290 setModified( true ); 2286 setModified( true );
2291 mViewManager->refreshView(); 2287 mViewManager->refreshView();
2292 mDetails->refreshView();
2293 message( i18n("Removing categories done!")); 2288 message( i18n("Removing categories done!"));
2294 } 2289 }
2295 delete cp; 2290 delete cp;
2296} 2291}
2297void KABCore::removeVoice() 2292void KABCore::removeVoice()
2298{ 2293{
2299 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2294 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2300 return; 2295 return;
2301 KABC::Addressee::List list; 2296 KABC::Addressee::List list;
2302 XXPortSelectDialog dlg( this, false, this ); 2297 XXPortSelectDialog dlg( this, false, this );
2303 if ( dlg.exec() ) 2298 if ( dlg.exec() )
2304 list = dlg.contacts(); 2299 list = dlg.contacts();
2305 else 2300 else
2306 return; 2301 return;
2307 KABC::Addressee::List::Iterator it; 2302 KABC::Addressee::List::Iterator it;
2308 for ( it = list.begin(); it != list.end(); ++it ) { 2303 for ( it = list.begin(); it != list.end(); ++it ) {
2309 if ( (*it).removeVoice() ) 2304 if ( (*it).removeVoice() )
2310 contactModified((*it) ); 2305 contactModified((*it) );
2311 } 2306 }
2312} 2307}
2313 2308
2314 2309
2315 2310
2316void KABCore::clipboardDataChanged() 2311void KABCore::clipboardDataChanged()
2317{ 2312{
2318 2313
2319 if ( mReadWrite ) 2314 if ( mReadWrite )
2320 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2315 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2321 2316
2322} 2317}
2323 2318
2324void KABCore::updateActionMenu() 2319void KABCore::updateActionMenu()
2325{ 2320{
2326 UndoStack *undo = UndoStack::instance(); 2321 UndoStack *undo = UndoStack::instance();
2327 RedoStack *redo = RedoStack::instance(); 2322 RedoStack *redo = RedoStack::instance();
2328 2323
2329 if ( undo->isEmpty() ) 2324 if ( undo->isEmpty() )
2330 mActionUndo->setText( i18n( "Undo" ) ); 2325 mActionUndo->setText( i18n( "Undo" ) );
2331 else 2326 else
2332 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2327 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2333 2328
2334 mActionUndo->setEnabled( !undo->isEmpty() ); 2329 mActionUndo->setEnabled( !undo->isEmpty() );
2335 2330
2336 if ( !redo->top() ) 2331 if ( !redo->top() )
2337 mActionRedo->setText( i18n( "Redo" ) ); 2332 mActionRedo->setText( i18n( "Redo" ) );
2338 else 2333 else
2339 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2334 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2340 2335
2341 mActionRedo->setEnabled( !redo->isEmpty() ); 2336 mActionRedo->setEnabled( !redo->isEmpty() );
2342} 2337}
2343 2338
2344void KABCore::configureKeyBindings() 2339void KABCore::configureKeyBindings()
2345{ 2340{
2346#ifndef KAB_EMBEDDED 2341#ifndef KAB_EMBEDDED
2347 KKeyDialog::configure( actionCollection(), true ); 2342 KKeyDialog::configure( actionCollection(), true );
2348#else //KAB_EMBEDDED 2343#else //KAB_EMBEDDED
2349 qDebug("KABCore::configureKeyBindings() not implemented"); 2344 qDebug("KABCore::configureKeyBindings() not implemented");
2350#endif //KAB_EMBEDDED 2345#endif //KAB_EMBEDDED
2351} 2346}
2352 2347
2353#ifdef KAB_EMBEDDED 2348#ifdef KAB_EMBEDDED
2354void KABCore::configureResources() 2349void KABCore::configureResources()
2355{ 2350{
2356 KRES::KCMKResources dlg( this, "" , 0 ); 2351 KRES::KCMKResources dlg( this, "" , 0 );
2357 2352
2358 if ( !dlg.exec() ) 2353 if ( !dlg.exec() )
2359 return; 2354 return;
2360 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2355 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2361} 2356}
2362#endif //KAB_EMBEDDED 2357#endif //KAB_EMBEDDED
2363 2358
2364 2359
2365/* this method will be called through the QCop interface from Ko/Pi to select addresses 2360/* this method will be called through the QCop interface from Ko/Pi to select addresses
2366 * for the attendees list of an event. 2361 * for the attendees list of an event.
2367 */ 2362 */
2368void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2363void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2369{ 2364{
2370 QStringList nameList; 2365 QStringList nameList;
2371 QStringList emailList; 2366 QStringList emailList;
2372 QStringList uidList; 2367 QStringList uidList;
2373 2368
2374 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2369 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2375 uint i=0; 2370 uint i=0;
2376 for (i=0; i < list.count(); i++) 2371 for (i=0; i < list.count(); i++)
2377 { 2372 {
2378 nameList.append(list[i].realName()); 2373 nameList.append(list[i].realName());
2379 emailList.append(list[i].preferredEmail()); 2374 emailList.append(list[i].preferredEmail());
2380 uidList.append(list[i].uid()); 2375 uidList.append(list[i].uid());
2381 } 2376 }
2382 2377
2383 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2378 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2384 2379
2385} 2380}
2386 2381
2387/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2382/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2388 * to put them into the calendar. 2383 * to put them into the calendar.
2389 */ 2384 */
2390void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2385void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2391{ 2386{
2392 // qDebug("KABCore::requestForBirthdayList"); 2387 // qDebug("KABCore::requestForBirthdayList");
2393 QStringList birthdayList; 2388 QStringList birthdayList;
2394 QStringList anniversaryList; 2389 QStringList anniversaryList;
2395 QStringList realNameList; 2390 QStringList realNameList;
2396 QStringList preferredEmailList; 2391 QStringList preferredEmailList;
2397 QStringList assembledNameList; 2392 QStringList assembledNameList;
2398 QStringList uidList; 2393 QStringList uidList;
2399 2394
2400 KABC::AddressBook::Iterator it; 2395 KABC::AddressBook::Iterator it;
2401 2396
2402 int count = 0; 2397 int count = 0;
2403 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2398 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2404 ++count; 2399 ++count;
2405 } 2400 }
2406 QProgressBar bar(count,0 ); 2401 QProgressBar bar(count,0 );
2407 int w = 300; 2402 int w = 300;
2408 if ( QApplication::desktop()->width() < 320 ) 2403 if ( QApplication::desktop()->width() < 320 )
2409 w = 220; 2404 w = 220;
2410 int h = bar.sizeHint().height() ; 2405 int h = bar.sizeHint().height() ;
2411 int dw = QApplication::desktop()->width(); 2406 int dw = QApplication::desktop()->width();
2412 int dh = QApplication::desktop()->height(); 2407 int dh = QApplication::desktop()->height();
2413 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2408 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2414 bar.show(); 2409 bar.show();
2415 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2410 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2416 qApp->processEvents(); 2411 qApp->processEvents();
2417 2412
2418 QDate bday; 2413 QDate bday;
2419 QString anni; 2414 QString anni;
2420 QString formattedbday; 2415 QString formattedbday;
2421 2416
2422 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2417 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2423 { 2418 {
2424 if ( ! bar.isVisible() ) 2419 if ( ! bar.isVisible() )
2425 return; 2420 return;
2426 bar.setProgress( count++ ); 2421 bar.setProgress( count++ );
2427 qApp->processEvents(); 2422 qApp->processEvents();
2428 bday = (*it).birthday().date(); 2423 bday = (*it).birthday().date();
2429 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2424 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2430 2425
2431 if ( bday.isValid() || !anni.isEmpty()) 2426 if ( bday.isValid() || !anni.isEmpty())
2432 { 2427 {
2433 if (bday.isValid()) 2428 if (bday.isValid())
2434 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2429 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2435 else 2430 else
2436 formattedbday = "NOTVALID"; 2431 formattedbday = "NOTVALID";
2437 if (anni.isEmpty()) 2432 if (anni.isEmpty())
2438 anni = "INVALID"; 2433 anni = "INVALID";
2439 2434
2440 birthdayList.append(formattedbday); 2435 birthdayList.append(formattedbday);
2441 anniversaryList.append(anni); //should be ISODate 2436 anniversaryList.append(anni); //should be ISODate
2442 realNameList.append((*it).realName()); 2437 realNameList.append((*it).realName());
2443 preferredEmailList.append((*it).preferredEmail()); 2438 preferredEmailList.append((*it).preferredEmail());
2444 assembledNameList.append((*it).assembledName()); 2439 assembledNameList.append((*it).assembledName());
2445 uidList.append((*it).uid()); 2440 uidList.append((*it).uid());
2446 2441
2447 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2442 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2448 } 2443 }
2449 } 2444 }
2450 2445
2451 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2446 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2452 2447
2453} 2448}
2454 2449
2455/* this method will be called through the QCop interface from other apps to show details of a contact. 2450/* this method will be called through the QCop interface from other apps to show details of a contact.
2456 */ 2451 */
2457void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2452void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2458{ 2453{
2459 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2454 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2460 2455
2461 QString foundUid = QString::null; 2456 QString foundUid = QString::null;
2462 if ( ! uid.isEmpty() ) { 2457 if ( ! uid.isEmpty() ) {
2463 Addressee adrr = mAddressBook->findByUid( uid ); 2458 Addressee adrr = mAddressBook->findByUid( uid );
2464 if ( !adrr.isEmpty() ) { 2459 if ( !adrr.isEmpty() ) {
2465 foundUid = uid; 2460 foundUid = uid;
2466 } 2461 }
2467 if ( email == "sendbacklist" ) { 2462 if ( email == "sendbacklist" ) {
2468 //qDebug("ssssssssssssssssssssssend "); 2463 //qDebug("ssssssssssssssssssssssend ");
2469 QStringList nameList; 2464 QStringList nameList;
2470 QStringList emailList; 2465 QStringList emailList;
2471 QStringList uidList; 2466 QStringList uidList;
2472 nameList.append(adrr.realName()); 2467 nameList.append(adrr.realName());
2473 emailList = adrr.emails(); 2468 emailList = adrr.emails();
2474 uidList.append( adrr.preferredEmail()); 2469 uidList.append( adrr.preferredEmail());
2475 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2470 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2476 return; 2471 return;
2477 } 2472 }
2478 2473
2479 } 2474 }
2480 2475
2481 if ( email == "sendbacklist" ) 2476 if ( email == "sendbacklist" )
2482 return; 2477 return;
2483 if (foundUid.isEmpty()) 2478 if (foundUid.isEmpty())
2484 { 2479 {
2485 //find the uid of the person first 2480 //find the uid of the person first
2486 Addressee::List namelist; 2481 Addressee::List namelist;
2487 Addressee::List emaillist; 2482 Addressee::List emaillist;
2488 2483
2489 if (!name.isEmpty()) 2484 if (!name.isEmpty())
2490 namelist = mAddressBook->findByName( name ); 2485 namelist = mAddressBook->findByName( name );
2491 2486
2492 if (!email.isEmpty()) 2487 if (!email.isEmpty())
2493 emaillist = mAddressBook->findByEmail( email ); 2488 emaillist = mAddressBook->findByEmail( email );
2494 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2489 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2495 //check if we have a match in Namelist and Emaillist 2490 //check if we have a match in Namelist and Emaillist
2496 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2491 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2497 foundUid = emaillist[0].uid(); 2492 foundUid = emaillist[0].uid();
2498 } 2493 }
2499 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2494 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2500 foundUid = namelist[0].uid(); 2495 foundUid = namelist[0].uid();
2501 else 2496 else
2502 { 2497 {
2503 for (int i = 0; i < namelist.count(); i++) 2498 for (int i = 0; i < namelist.count(); i++)
2504 { 2499 {
2505 for (int j = 0; j < emaillist.count(); j++) 2500 for (int j = 0; j < emaillist.count(); j++)
2506 { 2501 {
2507 if (namelist[i] == emaillist[j]) 2502 if (namelist[i] == emaillist[j])
2508 { 2503 {
2509 foundUid = namelist[i].uid(); 2504 foundUid = namelist[i].uid();
2510 } 2505 }
2511 } 2506 }
2512 } 2507 }
2513 } 2508 }
2514 } 2509 }
2515 else 2510 else
2516 { 2511 {
2517 foundUid = uid; 2512 foundUid = uid;
2518 } 2513 }
2519 2514
2520 if (!foundUid.isEmpty()) 2515 if (!foundUid.isEmpty())
2521 { 2516 {
2522 2517
2523 // raise Ka/Pi if it is in the background 2518 // raise Ka/Pi if it is in the background
2524#ifndef DESKTOP_VERSION 2519#ifndef DESKTOP_VERSION
2525#ifndef KORG_NODCOP 2520#ifndef KORG_NODCOP
2526 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2521 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2527#endif 2522#endif
2528#endif 2523#endif
2529 2524
2530 mMainWindow->showMaximized(); 2525 mMainWindow->showMaximized();
2531 mMainWindow-> raise(); 2526 mMainWindow-> raise();
2532 2527
2533 mViewManager->setSelected( "", false); 2528 mViewManager->setSelected( "", false);
2534 mViewManager->refreshView( "" ); 2529 mViewManager->refreshView( "" );
2535 mViewManager->setSelected( foundUid, true ); 2530 mViewManager->setSelected( foundUid, true );
2536 mViewManager->refreshView( foundUid ); 2531 mViewManager->refreshView( foundUid );
2537 2532
2538 if ( !mMultipleViewsAtOnce ) 2533 if ( !mMultipleViewsAtOnce )
2539 { 2534 {
2540 setDetailsVisible( true ); 2535 setDetailsVisible( true );
2541 mActionDetails->setChecked(true); 2536 mActionDetails->setChecked(true);
2542 } 2537 }
2543 } 2538 }
2544} 2539}
2545 2540
2546void KABCore::whatsnew() 2541void KABCore::whatsnew()
2547{ 2542{
2548 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2543 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2549} 2544}
2550void KABCore::synchowto() 2545void KABCore::synchowto()
2551{ 2546{
2552 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2547 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2553} 2548}
2554void KABCore::kdesynchowto() 2549void KABCore::kdesynchowto()
2555{ 2550{
2556 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2551 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2557} 2552}
2558void KABCore::multisynchowto() 2553void KABCore::multisynchowto()
2559{ 2554{
2560 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2555 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2561} 2556}
2562void KABCore::faq() 2557void KABCore::faq()
2563{ 2558{
2564 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2559 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2565} 2560}
2566 2561
2567#include <libkcal/syncdefines.h> 2562#include <libkcal/syncdefines.h>
2568 2563
2569KABC::Addressee KABCore::getLastSyncAddressee() 2564KABC::Addressee KABCore::getLastSyncAddressee()
2570{ 2565{
2571 Addressee lse; 2566 Addressee lse;
2572 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2567 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2573 2568
2574 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2569 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2575 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2570 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2576 if (lse.isEmpty()) { 2571 if (lse.isEmpty()) {
2577 qDebug("Creating new last-syncAddressee "); 2572 qDebug("Creating new last-syncAddressee ");
2578 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2573 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2579 QString sum = ""; 2574 QString sum = "";
2580 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2575 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2581 sum = "E: "; 2576 sum = "E: ";
2582 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2577 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2583 lse.setRevision( mLastAddressbookSync ); 2578 lse.setRevision( mLastAddressbookSync );
2584 lse.setCategories( i18n("SyncEvent") ); 2579 lse.setCategories( i18n("SyncEvent") );
2585 mAddressBook->insertAddressee( lse ); 2580 mAddressBook->insertAddressee( lse );
2586 } 2581 }
2587 return lse; 2582 return lse;
2588} 2583}
2589int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2584int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2590{ 2585{
2591 2586
2592 //void setZaurusId(int id); 2587 //void setZaurusId(int id);
2593 // int zaurusId() const; 2588 // int zaurusId() const;
2594 // void setZaurusUid(int id); 2589 // void setZaurusUid(int id);
2595 // int zaurusUid() const; 2590 // int zaurusUid() const;
2596 // void setZaurusStat(int id); 2591 // void setZaurusStat(int id);
2597 // int zaurusStat() const; 2592 // int zaurusStat() const;
2598 // 0 equal 2593 // 0 equal
2599 // 1 take local 2594 // 1 take local
2600 // 2 take remote 2595 // 2 take remote
2601 // 3 cancel 2596 // 3 cancel
2602 QDateTime lastSync = mLastAddressbookSync; 2597 QDateTime lastSync = mLastAddressbookSync;
2603 QDateTime localMod = local->revision(); 2598 QDateTime localMod = local->revision();
2604 QDateTime remoteMod = remote->revision(); 2599 QDateTime remoteMod = remote->revision();
2605 2600
2606 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2601 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2607 2602
2608 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2603 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2609 bool remCh, locCh; 2604 bool remCh, locCh;
2610 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2605 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2611 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2606 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2612 locCh = ( localMod > mLastAddressbookSync ); 2607 locCh = ( localMod > mLastAddressbookSync );
2613 if ( !remCh && ! locCh ) { 2608 if ( !remCh && ! locCh ) {
2614 //qDebug("both not changed "); 2609 //qDebug("both not changed ");
2615 lastSync = localMod.addDays(1); 2610 lastSync = localMod.addDays(1);
2616 if ( mode <= SYNC_PREF_ASK ) 2611 if ( mode <= SYNC_PREF_ASK )
2617 return 0; 2612 return 0;
2618 } else { 2613 } else {
2619 if ( locCh ) { 2614 if ( locCh ) {
2620 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2615 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2621 lastSync = localMod.addDays( -1 ); 2616 lastSync = localMod.addDays( -1 );
2622 if ( !remCh ) 2617 if ( !remCh )
2623 remoteMod =( lastSync.addDays( -1 ) ); 2618 remoteMod =( lastSync.addDays( -1 ) );
2624 } else { 2619 } else {
2625 //qDebug(" not loc changed "); 2620 //qDebug(" not loc changed ");
2626 lastSync = localMod.addDays( 1 ); 2621 lastSync = localMod.addDays( 1 );
2627 if ( remCh ) { 2622 if ( remCh ) {
2628 //qDebug("rem changed "); 2623 //qDebug("rem changed ");
2629 remoteMod =( lastSync.addDays( 1 ) ); 2624 remoteMod =( lastSync.addDays( 1 ) );
2630 } 2625 }
2631 2626
2632 } 2627 }
2633 } 2628 }
2634 full = true; 2629 full = true;
2635 if ( mode < SYNC_PREF_ASK ) 2630 if ( mode < SYNC_PREF_ASK )
2636 mode = SYNC_PREF_ASK; 2631 mode = SYNC_PREF_ASK;
2637 } else { 2632 } else {
2638 if ( localMod == remoteMod ) 2633 if ( localMod == remoteMod )
2639 return 0; 2634 return 0;
2640 2635
2641 } 2636 }
2642 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2637 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2643 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2638 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2644 //full = true; //debug only 2639 //full = true; //debug only
2645 if ( full ) { 2640 if ( full ) {
2646 bool equ = ( (*local) == (*remote) ); 2641 bool equ = ( (*local) == (*remote) );
2647 if ( equ ) { 2642 if ( equ ) {
2648 //qDebug("equal "); 2643 //qDebug("equal ");
2649 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2644 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2650 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2645 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2651 } 2646 }
2652 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2647 if ( mode < SYNC_PREF_FORCE_LOCAL )
2653 return 0; 2648 return 0;
2654 2649
2655 }//else //debug only 2650 }//else //debug only
2656 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2651 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2657 } 2652 }
2658 int result; 2653 int result;
2659 bool localIsNew; 2654 bool localIsNew;
2660 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2655 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2661 2656
2662 if ( full && mode < SYNC_PREF_NEWEST ) 2657 if ( full && mode < SYNC_PREF_NEWEST )
2663 mode = SYNC_PREF_ASK; 2658 mode = SYNC_PREF_ASK;
2664 2659
2665 switch( mode ) { 2660 switch( mode ) {
2666 case SYNC_PREF_LOCAL: 2661 case SYNC_PREF_LOCAL:
2667 if ( lastSync > remoteMod ) 2662 if ( lastSync > remoteMod )
2668 return 1; 2663 return 1;
2669 if ( lastSync > localMod ) 2664 if ( lastSync > localMod )
2670 return 2; 2665 return 2;
2671 return 1; 2666 return 1;
2672 break; 2667 break;
2673 case SYNC_PREF_REMOTE: 2668 case SYNC_PREF_REMOTE:
2674 if ( lastSync > remoteMod ) 2669 if ( lastSync > remoteMod )
2675 return 1; 2670 return 1;
2676 if ( lastSync > localMod ) 2671 if ( lastSync > localMod )
2677 return 2; 2672 return 2;
2678 return 2; 2673 return 2;
2679 break; 2674 break;
2680 case SYNC_PREF_NEWEST: 2675 case SYNC_PREF_NEWEST:
2681 if ( localMod > remoteMod ) 2676 if ( localMod > remoteMod )
2682 return 1; 2677 return 1;
2683 else 2678 else
2684 return 2; 2679 return 2;
2685 break; 2680 break;
2686 case SYNC_PREF_ASK: 2681 case SYNC_PREF_ASK:
2687 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2682 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2688 if ( lastSync > remoteMod ) 2683 if ( lastSync > remoteMod )
2689 return 1; 2684 return 1;
2690 if ( lastSync > localMod ) 2685 if ( lastSync > localMod )
2691 return 2; 2686 return 2;
2692 localIsNew = localMod >= remoteMod; 2687 localIsNew = localMod >= remoteMod;
2693 //qDebug("conflict! ************************************** "); 2688 //qDebug("conflict! ************************************** ");
2694 { 2689 {
2695 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2690 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2696 result = acd.executeD(localIsNew); 2691 result = acd.executeD(localIsNew);
2697 return result; 2692 return result;
2698 } 2693 }
2699 break; 2694 break;
2700 case SYNC_PREF_FORCE_LOCAL: 2695 case SYNC_PREF_FORCE_LOCAL:
2701 return 1; 2696 return 1;
2702 break; 2697 break;
2703 case SYNC_PREF_FORCE_REMOTE: 2698 case SYNC_PREF_FORCE_REMOTE:
2704 return 2; 2699 return 2;
2705 break; 2700 break;
2706 2701
2707 default: 2702 default:
2708 // SYNC_PREF_TAKE_BOTH not implemented 2703 // SYNC_PREF_TAKE_BOTH not implemented
2709 break; 2704 break;
2710 } 2705 }
2711 return 0; 2706 return 0;
2712} 2707}
2713 2708
2714 2709
2715bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2710bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2716{ 2711{
2717 bool syncOK = true; 2712 bool syncOK = true;
2718 int addedAddressee = 0; 2713 int addedAddressee = 0;
2719 int addedAddresseeR = 0; 2714 int addedAddresseeR = 0;
2720 int deletedAddresseeR = 0; 2715 int deletedAddresseeR = 0;
2721 int deletedAddresseeL = 0; 2716 int deletedAddresseeL = 0;
2722 int changedLocal = 0; 2717 int changedLocal = 0;
2723 int changedRemote = 0; 2718 int changedRemote = 0;
2724 2719
2725 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2720 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2726 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2721 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2727 2722
2728 //QPtrList<Addressee> el = local->rawAddressees(); 2723 //QPtrList<Addressee> el = local->rawAddressees();
2729 Addressee addresseeR; 2724 Addressee addresseeR;
2730 QString uid; 2725 QString uid;
2731 int take; 2726 int take;
2732 Addressee addresseeL; 2727 Addressee addresseeL;
2733 Addressee addresseeRSync; 2728 Addressee addresseeRSync;
2734 Addressee addresseeLSync; 2729 Addressee addresseeLSync;
2735 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2730 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2736 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2731 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2737 bool fullDateRange = false; 2732 bool fullDateRange = false;
2738 local->resetTempSyncStat(); 2733 local->resetTempSyncStat();
2739 mLastAddressbookSync = QDateTime::currentDateTime(); 2734 mLastAddressbookSync = QDateTime::currentDateTime();
2740 if ( syncManager->syncWithDesktop() ) { 2735 if ( syncManager->syncWithDesktop() ) {
2741 // remote->removeSyncInfo( QString());//remove all info 2736 // remote->removeSyncInfo( QString());//remove all info
2742 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2737 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2743 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2738 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2744 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2739 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2745 } else { 2740 } else {
2746 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2741 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2747 } 2742 }
2748 } 2743 }
2749 QDateTime modifiedCalendar = mLastAddressbookSync; 2744 QDateTime modifiedCalendar = mLastAddressbookSync;
2750 addresseeLSync = getLastSyncAddressee(); 2745 addresseeLSync = getLastSyncAddressee();
2751 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2746 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2752 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2747 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2753 if ( !addresseeR.isEmpty() ) { 2748 if ( !addresseeR.isEmpty() ) {
2754 addresseeRSync = addresseeR; 2749 addresseeRSync = addresseeR;
2755 remote->removeAddressee(addresseeR ); 2750 remote->removeAddressee(addresseeR );
2756 2751
2757 } else { 2752 } else {
2758 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2753 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2759 addresseeRSync = addresseeLSync ; 2754 addresseeRSync = addresseeLSync ;
2760 } else { 2755 } else {
2761 //qDebug("FULLDATE 1"); 2756 //qDebug("FULLDATE 1");
2762 fullDateRange = true; 2757 fullDateRange = true;
2763 Addressee newAdd; 2758 Addressee newAdd;
2764 addresseeRSync = newAdd; 2759 addresseeRSync = newAdd;
2765 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2760 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2766 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2761 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2767 addresseeRSync.setRevision( mLastAddressbookSync ); 2762 addresseeRSync.setRevision( mLastAddressbookSync );
2768 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2763 addresseeRSync.setCategories( i18n("SyncAddressee") );
2769 } 2764 }
2770 } 2765 }
2771 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2766 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2772 // qDebug("FULLDATE 2"); 2767 // qDebug("FULLDATE 2");
2773 fullDateRange = true; 2768 fullDateRange = true;
2774 } 2769 }
2775 if ( ! fullDateRange ) { 2770 if ( ! fullDateRange ) {
2776 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2771 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2777 2772
2778 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2773 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2779 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2774 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2780 fullDateRange = true; 2775 fullDateRange = true;
2781 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2776 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2782 } 2777 }
2783 } 2778 }
2784 // fullDateRange = true; // debug only! 2779 // fullDateRange = true; // debug only!
2785 if ( fullDateRange ) 2780 if ( fullDateRange )
2786 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2781 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2787 else 2782 else
2788 mLastAddressbookSync = addresseeLSync.revision(); 2783 mLastAddressbookSync = addresseeLSync.revision();
2789 // for resyncing if own file has changed 2784 // for resyncing if own file has changed
2790 // PENDING fixme later when implemented 2785 // PENDING fixme later when implemented
2791#if 0 2786#if 0
2792 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2787 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2793 mLastAddressbookSync = loadedFileVersion; 2788 mLastAddressbookSync = loadedFileVersion;
2794 qDebug("setting mLastAddressbookSync "); 2789 qDebug("setting mLastAddressbookSync ");
2795 } 2790 }
2796#endif 2791#endif
2797 2792
2798 //qDebug("*************************** "); 2793 //qDebug("*************************** ");
2799 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2794 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2800 QStringList er = remote->uidList(); 2795 QStringList er = remote->uidList();
2801 Addressee inR ;//= er.first(); 2796 Addressee inR ;//= er.first();
2802 Addressee inL; 2797 Addressee inL;
2803 2798
2804 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2799 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2805 2800
2806 int modulo = (er.count()/10)+1; 2801 int modulo = (er.count()/10)+1;
2807 int incCounter = 0; 2802 int incCounter = 0;
2808 while ( incCounter < er.count()) { 2803 while ( incCounter < er.count()) {
2809 if (syncManager->isProgressBarCanceled()) 2804 if (syncManager->isProgressBarCanceled())
2810 return false; 2805 return false;
2811 if ( incCounter % modulo == 0 ) 2806 if ( incCounter % modulo == 0 )
2812 syncManager->showProgressBar(incCounter); 2807 syncManager->showProgressBar(incCounter);
2813 2808
2814 uid = er[ incCounter ]; 2809 uid = er[ incCounter ];
2815 bool skipIncidence = false; 2810 bool skipIncidence = false;
2816 if ( uid.left(19) == QString("last-syncAddressee-") ) 2811 if ( uid.left(19) == QString("last-syncAddressee-") )
2817 skipIncidence = true; 2812 skipIncidence = true;
2818 QString idS,OidS; 2813 QString idS,OidS;
2819 qApp->processEvents(); 2814 qApp->processEvents();
2820 if ( !skipIncidence ) { 2815 if ( !skipIncidence ) {
2821 inL = local->findByUid( uid ); 2816 inL = local->findByUid( uid );
2822 inR = remote->findByUid( uid ); 2817 inR = remote->findByUid( uid );
2823 //inL.setResource( 0 ); 2818 //inL.setResource( 0 );
2824 //inR.setResource( 0 ); 2819 //inR.setResource( 0 );
2825 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2820 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2826 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2821 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2827 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2822 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2828 //qDebug("take %d %s ", take, inL.summary().latin1()); 2823 //qDebug("take %d %s ", take, inL.summary().latin1());
2829 if ( take == 3 ) 2824 if ( take == 3 )
2830 return false; 2825 return false;
2831 if ( take == 1 ) {// take local ********************** 2826 if ( take == 1 ) {// take local **********************
2832 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2827 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2833 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2828 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2834 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2829 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2835 local->insertAddressee( inL, false ); 2830 local->insertAddressee( inL, false );
2836 idS = inR.externalUID(); 2831 idS = inR.externalUID();
2837 OidS = inR.originalExternalUID(); 2832 OidS = inR.originalExternalUID();
2838 } 2833 }
2839 else 2834 else
2840 idS = inR.IDStr(); 2835 idS = inR.IDStr();
2841 remote->removeAddressee( inR ); 2836 remote->removeAddressee( inR );
2842 inR = inL; 2837 inR = inL;
2843 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2838 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2844 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2839 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2845 inR.setOriginalExternalUID( OidS ); 2840 inR.setOriginalExternalUID( OidS );
2846 inR.setExternalUID( idS ); 2841 inR.setExternalUID( idS );
2847 if ( syncManager->syncWithDesktop() ) { 2842 if ( syncManager->syncWithDesktop() ) {
2848 inR.setIDStr("changed" ); 2843 inR.setIDStr("changed" );
2849 } 2844 }
2850 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2845 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2851 } else { 2846 } else {
2852 inR.setIDStr( idS ); 2847 inR.setIDStr( idS );
2853 } 2848 }
2854 inR.setResource( 0 ); 2849 inR.setResource( 0 );
2855 remote->insertAddressee( inR , false); 2850 remote->insertAddressee( inR , false);
2856 ++changedRemote; 2851 ++changedRemote;
2857 } else { // take == 2 take remote ********************** 2852 } else { // take == 2 take remote **********************
2858 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2853 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2859 if ( inR.revision().date().year() < 2004 ) 2854 if ( inR.revision().date().year() < 2004 )
2860 inR.setRevision( modifiedCalendar ); 2855 inR.setRevision( modifiedCalendar );
2861 } 2856 }
2862 idS = inL.IDStr(); 2857 idS = inL.IDStr();
2863 local->removeAddressee( inL ); 2858 local->removeAddressee( inL );
2864 inL = inR; 2859 inL = inR;
2865 inL.setIDStr( idS ); 2860 inL.setIDStr( idS );
2866 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2861 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2867 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2862 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2868 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2863 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2869 } 2864 }
2870 inL.setResource( 0 ); 2865 inL.setResource( 0 );
2871 local->insertAddressee( inL , false ); 2866 local->insertAddressee( inL , false );
2872 ++changedLocal; 2867 ++changedLocal;
2873 } 2868 }
2874 } 2869 }
2875 } 2870 }
2876 } else { // no conflict ********** add or delete remote 2871 } else { // no conflict ********** add or delete remote
2877 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2872 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2878 QString des = addresseeLSync.note(); 2873 QString des = addresseeLSync.note();
2879 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2874 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2880 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2875 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2881 remote->insertAddressee( inR, false ); 2876 remote->insertAddressee( inR, false );
2882 ++deletedAddresseeR; 2877 ++deletedAddresseeR;
2883 } else { 2878 } else {
2884 inR.setRevision( modifiedCalendar ); 2879 inR.setRevision( modifiedCalendar );
2885 remote->insertAddressee( inR, false ); 2880 remote->insertAddressee( inR, false );
2886 inL = inR; 2881 inL = inR;
2887 inL.setIDStr( ":" ); 2882 inL.setIDStr( ":" );
2888 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2883 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2889 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2884 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2890 inL.setResource( 0 ); 2885 inL.setResource( 0 );
2891 local->insertAddressee( inL , false); 2886 local->insertAddressee( inL , false);
2892 ++addedAddressee; 2887 ++addedAddressee;
2893 } 2888 }
2894 } else { 2889 } else {
2895 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2890 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2896 inR.setRevision( modifiedCalendar ); 2891 inR.setRevision( modifiedCalendar );
2897 remote->insertAddressee( inR, false ); 2892 remote->insertAddressee( inR, false );
2898 inR.setResource( 0 ); 2893 inR.setResource( 0 );
2899 local->insertAddressee( inR, false ); 2894 local->insertAddressee( inR, false );
2900 ++addedAddressee; 2895 ++addedAddressee;
2901 } else { 2896 } else {
2902 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2897 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2903 remote->removeAddressee( inR ); 2898 remote->removeAddressee( inR );
2904 ++deletedAddresseeR; 2899 ++deletedAddresseeR;
2905 } 2900 }
2906 } 2901 }
2907 } 2902 }
2908 } 2903 }
2909 ++incCounter; 2904 ++incCounter;
2910 } 2905 }
2911 er.clear(); 2906 er.clear();
2912 QStringList el = local->uidList(); 2907 QStringList el = local->uidList();
2913 modulo = (el.count()/10)+1; 2908 modulo = (el.count()/10)+1;
2914 2909
2915 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2910 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2916 incCounter = 0; 2911 incCounter = 0;
2917 while ( incCounter < el.count()) { 2912 while ( incCounter < el.count()) {
2918 qApp->processEvents(); 2913 qApp->processEvents();
2919 if (syncManager->isProgressBarCanceled()) 2914 if (syncManager->isProgressBarCanceled())
2920 return false; 2915 return false;
2921 if ( incCounter % modulo == 0 ) 2916 if ( incCounter % modulo == 0 )
2922 syncManager->showProgressBar(incCounter); 2917 syncManager->showProgressBar(incCounter);
2923 uid = el[ incCounter ]; 2918 uid = el[ incCounter ];
2924 bool skipIncidence = false; 2919 bool skipIncidence = false;
2925 if ( uid.left(19) == QString("last-syncAddressee-") ) 2920 if ( uid.left(19) == QString("last-syncAddressee-") )
2926 skipIncidence = true; 2921 skipIncidence = true;
2927 if ( !skipIncidence ) { 2922 if ( !skipIncidence ) {
2928 inL = local->findByUid( uid ); 2923 inL = local->findByUid( uid );
2929 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2924 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2930 inR = remote->findByUid( uid ); 2925 inR = remote->findByUid( uid );
2931 if ( inR.isEmpty() ) { // no conflict ********** add or delete local 2926 if ( inR.isEmpty() ) { // no conflict ********** add or delete local
2932 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2927 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2933 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2928 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2934 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2929 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2935 local->removeAddressee( inL ); 2930 local->removeAddressee( inL );
2936 ++deletedAddresseeL; 2931 ++deletedAddresseeL;
2937 } else { 2932 } else {
2938 if ( ! syncManager->mWriteBackExistingOnly ) { 2933 if ( ! syncManager->mWriteBackExistingOnly ) {
2939 inL.removeID(mCurrentSyncDevice ); 2934 inL.removeID(mCurrentSyncDevice );
2940 ++addedAddresseeR; 2935 ++addedAddresseeR;
2941 inL.setRevision( modifiedCalendar ); 2936 inL.setRevision( modifiedCalendar );
2942 local->insertAddressee( inL, false ); 2937 local->insertAddressee( inL, false );
2943 inR = inL; 2938 inR = inL;
2944 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2939 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2945 inR.setResource( 0 ); 2940 inR.setResource( 0 );
2946 remote->insertAddressee( inR, false ); 2941 remote->insertAddressee( inR, false );
2947 } 2942 }
2948 } 2943 }
2949 } else { 2944 } else {
2950 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2945 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2951 //qDebug("data %s ", inL.revision().toString().latin1()); 2946 //qDebug("data %s ", inL.revision().toString().latin1());
2952 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2947 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2953 local->removeAddressee( inL ); 2948 local->removeAddressee( inL );
2954 ++deletedAddresseeL; 2949 ++deletedAddresseeL;
2955 } else { 2950 } else {
2956 if ( ! syncManager->mWriteBackExistingOnly ) { 2951 if ( ! syncManager->mWriteBackExistingOnly ) {
2957 ++addedAddresseeR; 2952 ++addedAddresseeR;
2958 inL.setRevision( modifiedCalendar ); 2953 inL.setRevision( modifiedCalendar );
2959 local->insertAddressee( inL, false ); 2954 local->insertAddressee( inL, false );
2960 inR = inL; 2955 inR = inL;
2961 inR.setIDStr( ":" ); 2956 inR.setIDStr( ":" );
2962 inR.setResource( 0 ); 2957 inR.setResource( 0 );
2963 remote->insertAddressee( inR, false ); 2958 remote->insertAddressee( inR, false );
2964 } 2959 }
2965 } 2960 }
2966 } 2961 }
2967 } 2962 }
2968 } 2963 }
2969 } 2964 }
2970 ++incCounter; 2965 ++incCounter;
2971 } 2966 }
2972 el.clear(); 2967 el.clear();
2973 syncManager->hideProgressBar(); 2968 syncManager->hideProgressBar();
2974 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2969 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2975 // get rid of micro seconds 2970 // get rid of micro seconds
2976 QTime t = mLastAddressbookSync.time(); 2971 QTime t = mLastAddressbookSync.time();
2977 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2972 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2978 addresseeLSync.setRevision( mLastAddressbookSync ); 2973 addresseeLSync.setRevision( mLastAddressbookSync );
2979 addresseeRSync.setRevision( mLastAddressbookSync ); 2974 addresseeRSync.setRevision( mLastAddressbookSync );
2980 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2975 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2981 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2976 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2982 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2977 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2983 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2978 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2984 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2979 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2985 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2980 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2986 addresseeRSync.setNote( "" ) ; 2981 addresseeRSync.setNote( "" ) ;
2987 addresseeLSync.setNote( "" ); 2982 addresseeLSync.setNote( "" );
2988 2983
2989 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2984 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2990 remote->insertAddressee( addresseeRSync, false ); 2985 remote->insertAddressee( addresseeRSync, false );
2991 local->insertAddressee( addresseeLSync, false ); 2986 local->insertAddressee( addresseeLSync, false );
2992 QString mes; 2987 QString mes;
2993 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2988 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2994 qDebug( mes ); 2989 qDebug( mes );
2995 mes = i18n("Local addressbook changed!\n") +mes; 2990 mes = i18n("Local addressbook changed!\n") +mes;
2996 if ( syncManager->mShowSyncSummary ) { 2991 if ( syncManager->mShowSyncSummary ) {
2997 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 2992 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
2998 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 2993 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
2999 qDebug("cancelled "); 2994 qDebug("cancelled ");
3000 return false; 2995 return false;
3001 } 2996 }
3002 } 2997 }
3003 return syncOK; 2998 return syncOK;
3004} 2999}
3005 3000
3006 3001
3007//this is a overwritten callbackmethods from the syncinterface 3002//this is a overwritten callbackmethods from the syncinterface
3008bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3003bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3009{ 3004{
3010 3005
3011 //pending prepare addresseeview for output 3006 //pending prepare addresseeview for output
3012 //pending detect, if remote file has REV field. if not switch to external sync 3007 //pending detect, if remote file has REV field. if not switch to external sync
3013 mGlobalSyncMode = SYNC_MODE_NORMAL; 3008 mGlobalSyncMode = SYNC_MODE_NORMAL;
3014 if ( manager != syncManager ) 3009 if ( manager != syncManager )
3015 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3010 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3016 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3011 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3017 3012
3018 AddressBook abLocal(filename,"syncContact"); 3013 AddressBook abLocal(filename,"syncContact");
3019 bool syncOK = false; 3014 bool syncOK = false;
3020 if ( abLocal.load() ) { 3015 if ( abLocal.load() ) {
3021 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 3016 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
3022 bool external = false; 3017 bool external = false;
3023 bool isXML = false; 3018 bool isXML = false;
3024 if ( filename.right(4) == ".xml") { 3019 if ( filename.right(4) == ".xml") {
3025 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3020 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3026 isXML = true; 3021 isXML = true;
3027 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3022 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3028 } else { 3023 } else {
3029 external = !manager->mIsKapiFile; 3024 external = !manager->mIsKapiFile;
3030 if ( external ) { 3025 if ( external ) {
3031 qDebug("Setting vcf mode to external "); 3026 qDebug("Setting vcf mode to external ");
3032 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3027 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3033 AddressBook::Iterator it; 3028 AddressBook::Iterator it;
3034 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3029 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3035 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3030 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3036 (*it).computeCsum( mCurrentSyncDevice ); 3031 (*it).computeCsum( mCurrentSyncDevice );
3037 } 3032 }
3038 } 3033 }
3039 } 3034 }
3040 //AddressBook::Iterator it; 3035 //AddressBook::Iterator it;
3041 //QStringList vcards; 3036 //QStringList vcards;
3042 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3037 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3043 // qDebug("Name %s ", (*it).familyName().latin1()); 3038 // qDebug("Name %s ", (*it).familyName().latin1());
3044 //} 3039 //}
3045 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3040 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3046 if ( syncOK ) { 3041 if ( syncOK ) {
3047 if ( syncManager->mWriteBackFile ) 3042 if ( syncManager->mWriteBackFile )
3048 { 3043 {
3049 if ( external ) 3044 if ( external )
3050 abLocal.removeSyncAddressees( !isXML); 3045 abLocal.removeSyncAddressees( !isXML);
3051 qDebug("Saving remote AB "); 3046 qDebug("Saving remote AB ");
3052 if ( ! abLocal.saveAB()) 3047 if ( ! abLocal.saveAB())
3053 qDebug("Error writing back AB to file "); 3048 qDebug("Error writing back AB to file ");
3054 if ( external ) { 3049 if ( external ) {
3055 // afterwrite processing 3050 // afterwrite processing
3056 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3051 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3057 } 3052 }
3058 } 3053 }
3059 } 3054 }
3060 setModified(); 3055 setModified();
3061 3056
3062 } 3057 }
3063 abLocal.removeResources(); 3058 abLocal.removeResources();
3064 if ( syncOK ) 3059 if ( syncOK )
3065 mViewManager->refreshView(); 3060 mViewManager->refreshView();
3066 return syncOK; 3061 return syncOK;
3067 3062
3068} 3063}
3069void KABCore::removeSyncInfo( QString syncProfile) 3064void KABCore::removeSyncInfo( QString syncProfile)
3070{ 3065{
3071 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3066 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3072 mAddressBook->removeSyncInfo( syncProfile ); 3067 mAddressBook->removeSyncInfo( syncProfile );
3073 setModified(); 3068 setModified();
3074} 3069}
3075 3070
3076 3071
3077//this is a overwritten callbackmethods from the syncinterface 3072//this is a overwritten callbackmethods from the syncinterface
3078bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3073bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3079{ 3074{
3080 if ( resource == "phone" ) 3075 if ( resource == "phone" )
3081 return syncPhone(); 3076 return syncPhone();
3082 disableBR( true ); 3077 disableBR( true );
3083 if ( manager != syncManager ) 3078 if ( manager != syncManager )
3084 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3079 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3085 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3080 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3086 3081
3087 AddressBook abLocal( resource,"syncContact"); 3082 AddressBook abLocal( resource,"syncContact");
3088 bool syncOK = false; 3083 bool syncOK = false;
3089 if ( abLocal.load() ) { 3084 if ( abLocal.load() ) {
3090 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3085 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3091 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3086 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3092 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3087 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3093 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3088 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3094 if ( syncOK ) { 3089 if ( syncOK ) {
3095 if ( syncManager->mWriteBackFile ) { 3090 if ( syncManager->mWriteBackFile ) {
3096 abLocal.removeSyncAddressees( false ); 3091 abLocal.removeSyncAddressees( false );
3097 abLocal.saveAB(); 3092 abLocal.saveAB();
3098 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3093 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3099 } 3094 }
3100 } else 3095 } else
3101 message( i18n("Sync cancelled or failed.") ); 3096 message( i18n("Sync cancelled or failed.") );
3102 setModified(); 3097 setModified();
3103 } 3098 }
3104 abLocal.removeResources(); 3099 abLocal.removeResources();
3105 if ( syncOK ) 3100 if ( syncOK )
3106 mViewManager->refreshView(); 3101 mViewManager->refreshView();
3107 disableBR( false ); 3102 disableBR( false );
3108 return syncOK; 3103 return syncOK;
3109 3104
3110} 3105}
3111void KABCore::message( QString m ) 3106void KABCore::message( QString m )
3112{ 3107{
3113 topLevelWidget()->setCaption( m ); 3108 topLevelWidget()->setCaption( m );
3114 mMessageTimer->start( 15000, true ); 3109 mMessageTimer->start( 15000, true );
3115} 3110}
3116bool KABCore::syncPhone() 3111bool KABCore::syncPhone()
3117{ 3112{
3118 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3113 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3119 QString fileName = getPhoneFile(); 3114 QString fileName = getPhoneFile();
3120 if ( !PhoneAccess::readFromPhone( fileName) ) { 3115 if ( !PhoneAccess::readFromPhone( fileName) ) {
3121 message(i18n("Phone access failed!")); 3116 message(i18n("Phone access failed!"));
3122 return false; 3117 return false;
3123 } 3118 }
3124 AddressBook abLocal( fileName,"syncContact"); 3119 AddressBook abLocal( fileName,"syncContact");
3125 bool syncOK = false; 3120 bool syncOK = false;
3126 { 3121 {
3127 abLocal.importFromFile( fileName ); 3122 abLocal.importFromFile( fileName );
3128 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3123 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3129 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3124 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3130 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3125 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3131 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3126 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3132 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3127 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3133 if ( syncOK ) { 3128 if ( syncOK ) {
3134 if ( syncManager->mWriteBackFile ) { 3129 if ( syncManager->mWriteBackFile ) {
3135 abLocal.removeSyncAddressees( true ); 3130 abLocal.removeSyncAddressees( true );
3136 abLocal.saveABphone( fileName ); 3131 abLocal.saveABphone( fileName );
3137 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3132 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3138 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3133 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3139 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3134 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3140 } 3135 }
3141 } 3136 }
3142 setModified(); 3137 setModified();
3143 } 3138 }
3144 abLocal.removeResources(); 3139 abLocal.removeResources();
3145 if ( syncOK ) 3140 if ( syncOK )
3146 mViewManager->refreshView(); 3141 mViewManager->refreshView();
3147 return syncOK; 3142 return syncOK;
3148} 3143}
3149void KABCore::getFile( bool success ) 3144void KABCore::getFile( bool success )
3150{ 3145{
3151 if ( ! success ) { 3146 if ( ! success ) {
3152 message( i18n("Error receiving file. Nothing changed!") ); 3147 message( i18n("Error receiving file. Nothing changed!") );
3153 return; 3148 return;
3154 } 3149 }
3155 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3150 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3156 if ( count ) 3151 if ( count )
3157 setModified( true ); 3152 setModified( true );
3158 message( i18n("Pi-Sync successful!") ); 3153 message( i18n("Pi-Sync successful!") );
3159 mViewManager->refreshView(); 3154 mViewManager->refreshView();
3160} 3155}
3161void KABCore::syncFileRequest() 3156void KABCore::syncFileRequest()
3162{ 3157{
3163 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3158 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3164 syncManager->slotSyncMenu( 999 ); 3159 syncManager->slotSyncMenu( 999 );
3165 } 3160 }
3166 mAddressBook->export2File( sentSyncFile() ); 3161 mAddressBook->export2File( sentSyncFile() );
3167} 3162}
3168QString KABCore::sentSyncFile() 3163QString KABCore::sentSyncFile()
3169{ 3164{
3170#ifdef DESKTOP_VERSION 3165#ifdef DESKTOP_VERSION
3171 return locateLocal( "tmp", "copysyncab.vcf" ); 3166 return locateLocal( "tmp", "copysyncab.vcf" );
3172#else 3167#else
3173 return QString( "/tmp/copysyncab.vcf" ); 3168 return QString( "/tmp/copysyncab.vcf" );
3174#endif 3169#endif
3175} 3170}
3176 3171
3177void KABCore::setCaptionBack() 3172void KABCore::setCaptionBack()
3178{ 3173{
3179 mMessageTimer->stop(); 3174 mMessageTimer->stop();
3180 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3175 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3181} 3176}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index c7c12ff..85ffbdb 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,516 +1,515 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <qdict.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <qwidget.h> 34#include <qwidget.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <ksyncmanager.h> 36#include <ksyncmanager.h>
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38#include <qcopchannel_qws.h> 38#include <qcopchannel_qws.h>
39#endif 39#endif
40 40
41namespace KABC { 41namespace KABC {
42class AddressBook; 42class AddressBook;
43} 43}
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46class KAboutData; 46class KAboutData;
47class KConfig; 47class KConfig;
48 48
49class KAddressBookService; 49class KAddressBookService;
50class LDAPSearchDialog; 50class LDAPSearchDialog;
51#else //KAB_EMBEDDED 51#else //KAB_EMBEDDED
52class KAddressBookMain; 52class KAddressBookMain;
53//US class QAction; 53//US class QAction;
54#endif //KAB_EMBEDDED 54#endif //KAB_EMBEDDED
55class KCMultiDialog; 55class KCMultiDialog;
56class KXMLGUIClient; 56class KXMLGUIClient;
57class ExtensionManager; 57class ExtensionManager;
58class XXPortManager; 58class XXPortManager;
59class JumpButtonBar; 59class JumpButtonBar;
60class IncSearchWidget; 60class IncSearchWidget;
61class KDGanttMinimizeSplitter; 61class KDGanttMinimizeSplitter;
62class KAction; 62class KAction;
63class KActionCollection; 63class KActionCollection;
64class KToggleAction; 64class KToggleAction;
65class KSyncProfile; 65class KSyncProfile;
66 66
67class QAction; 67class QAction;
68class QMenuBar; 68class QMenuBar;
69class QSplitter; 69class QSplitter;
70class ViewContainer; 70class ViewContainer;
71class ViewManager; 71class ViewManager;
72class AddresseeEditorDialog; 72class AddresseeEditorDialog;
73class Ir; 73class Ir;
74 74
75class KABCore : public QWidget, public KSyncInterface 75class KABCore : public QWidget, public KSyncInterface
76{ 76{
77 Q_OBJECT 77 Q_OBJECT
78 78
79 public: 79 public:
80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
81 81
82 82
83 ~KABCore(); 83 ~KABCore();
84 84
85 85
86#ifdef KAB_EMBEDDED 86#ifdef KAB_EMBEDDED
87 //US added functionality 87 //US added functionality
88 QPopupMenu* getViewMenu() {return viewMenu;} 88 QPopupMenu* getViewMenu() {return viewMenu;}
89 QPopupMenu* getFilterMenu() {return filterMenu;} 89 QPopupMenu* getFilterMenu() {return filterMenu;}
90 QPopupMenu* getSettingsMenu() {return settingsMenu;} 90 QPopupMenu* getSettingsMenu() {return settingsMenu;}
91 void addActionsManually(); 91 void addActionsManually();
92#endif //KAB_EMBEDDED 92#endif //KAB_EMBEDDED
93 /** 93 /**
94 Restores the global settings. 94 Restores the global settings.
95 */ 95 */
96 void restoreSettings(); 96 void restoreSettings();
97 97
98 /** 98
99 Saves the global settings.
100 */
101 void saveSettings();
102 99
103 /** 100 /**
104 Returns a pointer to the StdAddressBook of the application. 101 Returns a pointer to the StdAddressBook of the application.
105 */ 102 */
106 KABC::AddressBook *addressBook() const; 103 KABC::AddressBook *addressBook() const;
107 104
108 /** 105 /**
109 Returns a pointer to the KConfig object of the application. 106 Returns a pointer to the KConfig object of the application.
110 */ 107 */
111 static KConfig *config(); 108 static KConfig *config();
112 109
113 /** 110 /**
114 Returns a pointer to the global KActionCollection object. So 111 Returns a pointer to the global KActionCollection object. So
115 other classes can register their actions easily. 112 other classes can register their actions easily.
116 */ 113 */
117 KActionCollection *actionCollection() const; 114 KActionCollection *actionCollection() const;
118 115
119 /** 116 /**
120 Returns the current search field of the Incremental Search Widget. 117 Returns the current search field of the Incremental Search Widget.
121 */ 118 */
122 KABC::Field *currentSearchField() const; 119 KABC::Field *currentSearchField() const;
123 120
124 /** 121 /**
125 Returns the uid list of the currently selected contacts. 122 Returns the uid list of the currently selected contacts.
126 */ 123 */
127 QStringList selectedUIDs() const; 124 QStringList selectedUIDs() const;
128 125
129 /** 126 /**
130 Displays the ResourceSelectDialog and returns the selected 127 Displays the ResourceSelectDialog and returns the selected
131 resource or a null pointer if no resource was selected by 128 resource or a null pointer if no resource was selected by
132 the user. 129 the user.
133 */ 130 */
134 KABC::Resource *requestResource( QWidget *parent ); 131 KABC::Resource *requestResource( QWidget *parent );
135 132
136#ifndef KAB_EMBEDDED 133#ifndef KAB_EMBEDDED
137 static KAboutData *createAboutData(); 134 static KAboutData *createAboutData();
138#endif //KAB_EMBEDDED 135#endif //KAB_EMBEDDED
139 136
140#ifdef KAB_EMBEDDED 137#ifdef KAB_EMBEDDED
141 inline QPopupMenu* getImportMenu() { return ImportMenu;} 138 inline QPopupMenu* getImportMenu() { return ImportMenu;}
142 inline QPopupMenu* getExportMenu() { return ExportMenu;} 139 inline QPopupMenu* getExportMenu() { return ExportMenu;}
143#endif //KAB_EMBEDDED 140#endif //KAB_EMBEDDED
144 141
145 public slots: 142 public slots:
146#ifdef KAB_EMBEDDED 143#ifdef KAB_EMBEDDED
147 void createAboutData(); 144 void createAboutData();
148#endif //KAB_EMBEDDED 145#endif //KAB_EMBEDDED
149 void setDetailsToggle(); 146 void setDetailsToggle();
150 147
151 void showLicence(); 148 void showLicence();
152 void faq(); 149 void faq();
153 void whatsnew() ; 150 void whatsnew() ;
154 void synchowto() ; 151 void synchowto() ;
155 void multisynchowto() ; 152 void multisynchowto() ;
156 void kdesynchowto() ; 153 void kdesynchowto() ;
157 void writeToPhone(); 154 void writeToPhone();
158 155
159 /** 156 /**
160 Is called whenever a contact is selected in the view. 157 Is called whenever a contact is selected in the view.
161 */ 158 */
162 void setContactSelected( const QString &uid ); 159 void setContactSelected( const QString &uid );
163 160
164 /** 161 /**
165 Opens the preferred mail composer with all selected contacts as 162 Opens the preferred mail composer with all selected contacts as
166 arguments. 163 arguments.
167 */ 164 */
168 void sendMail(); 165 void sendMail();
169 166
170 /** 167 /**
171 Opens the preferred mail composer with the given contacts as 168 Opens the preferred mail composer with the given contacts as
172 arguments. 169 arguments.
173 */ 170 */
174 void sendMail( const QString& email ); 171 void sendMail( const QString& email );
175 172
176 173
177 void mailVCard(); 174 void mailVCard();
178 void mailVCard(const QStringList& uids); 175 void mailVCard(const QStringList& uids);
179 176
180 /** 177 /**
181 Beams the "WhoAmI contact. 178 Beams the "WhoAmI contact.
182 */ 179 */
183 void beamMySelf(); 180 void beamMySelf();
184 181
185 void beamVCard(); 182 void beamVCard();
186 void export2phone(); 183 void export2phone();
187 void beamVCard(const QStringList& uids); 184 void beamVCard(const QStringList& uids);
188 void beamDone( Ir *ir ); 185 void beamDone( Ir *ir );
189 186
190 187
191 /** 188 /**
192 Starts the preferred web browser with the given URL as argument. 189 Starts the preferred web browser with the given URL as argument.
193 */ 190 */
194 void browse( const QString& url ); 191 void browse( const QString& url );
195 192
196 /** 193 /**
197 Select all contacts in the view. 194 Select all contacts in the view.
198 */ 195 */
199 void selectAllContacts(); 196 void selectAllContacts();
200 197
201 /** 198 /**
202 Deletes all selected contacts from the address book. 199 Deletes all selected contacts from the address book.
203 */ 200 */
204 void deleteContacts(); 201 void deleteContacts();
205 202
206 /** 203 /**
207 Deletes given contacts from the address book. 204 Deletes given contacts from the address book.
208 205
209 @param uids The uids of the contacts, which shall be deleted. 206 @param uids The uids of the contacts, which shall be deleted.
210 */ 207 */
211 void deleteContacts( const QStringList &uids ); 208 void deleteContacts( const QStringList &uids );
212 209
213 /** 210 /**
214 Copys the selected contacts into clipboard for later pasting. 211 Copys the selected contacts into clipboard for later pasting.
215 */ 212 */
216 void copyContacts(); 213 void copyContacts();
217 214
218 /** 215 /**
219 Cuts the selected contacts and stores them for later pasting. 216 Cuts the selected contacts and stores them for later pasting.
220 */ 217 */
221 void cutContacts(); 218 void cutContacts();
222 219
223 /** 220 /**
224 Paste contacts from clipboard into the address book. 221 Paste contacts from clipboard into the address book.
225 */ 222 */
226 void pasteContacts(); 223 void pasteContacts();
227 224
228 /** 225 /**
229 Paste given contacts into the address book. 226 Paste given contacts into the address book.
230 227
231 @param list The list of addressee, which shall be pasted. 228 @param list The list of addressee, which shall be pasted.
232 */ 229 */
233 void pasteContacts( KABC::Addressee::List &list ); 230 void pasteContacts( KABC::Addressee::List &list );
234 231
235 /** 232 /**
236 Sets the whoAmI contact, that is used by many other programs to 233 Sets the whoAmI contact, that is used by many other programs to
237 get personal information about the current user. 234 get personal information about the current user.
238 */ 235 */
239 void setWhoAmI(); 236 void setWhoAmI();
240 237
241 /** 238 /**
242 Displays the category dialog and applies the result to all 239 Displays the category dialog and applies the result to all
243 selected contacts. 240 selected contacts.
244 */ 241 */
245 void setCategories(); 242 void setCategories();
246 void manageCategories(); 243 void manageCategories();
247 void editCategories(); 244 void editCategories();
248 245
249 /** 246 /**
250 Sets the field list of the Incremental Search Widget. 247 Sets the field list of the Incremental Search Widget.
251 */ 248 */
252 void setSearchFields( const KABC::Field::List &fields ); 249 void setSearchFields( const KABC::Field::List &fields );
253 250
254 /** 251 /**
255 Search with the current search field for a contact, that matches 252 Search with the current search field for a contact, that matches
256 the given text, and selects it in the view. 253 the given text, and selects it in the view.
257 */ 254 */
258 void incrementalSearch( const QString& text ); 255 void incrementalSearch( const QString& text );
259 256
260 /** 257 /**
261 Marks the address book as modified. 258 Marks the address book as modified.
262 */ 259 */
263 void setModified(); 260 void setModified();
264 /** 261 /**
265 Marks the address book as modified without refreshing the view. 262 Marks the address book as modified without refreshing the view.
266 */ 263 */
267 void setModifiedWOrefresh(); 264 void setModifiedWOrefresh();
268 265
269 /** 266 /**
270 Marks the address book as modified concerning the argument. 267 Marks the address book as modified concerning the argument.
271 */ 268 */
272 void setModified( bool modified ); 269 void setModified( bool modified );
273 270
274 /** 271 /**
275 Returns whether the address book is modified. 272 Returns whether the address book is modified.
276 */ 273 */
277 bool modified() const; 274 bool modified() const;
278 275
279 /** 276 /**
280 Called whenever an contact is modified in the contact editor 277 Called whenever an contact is modified in the contact editor
281 dialog or the quick edit. 278 dialog or the quick edit.
282 */ 279 */
283 void contactModified( const KABC::Addressee &addr ); 280 void contactModified( const KABC::Addressee &addr );
284 281
285 /** 282 /**
286 DCOP METHODS. 283 DCOP METHODS.
287 */ 284 */
288 void addEmail( QString addr ); 285 void addEmail( QString addr );
289 void importVCard( const KURL& url, bool showPreview ); 286 void importVCard( const KURL& url, bool showPreview );
290 void importVCard( const QString& vCard, bool showPreview ); 287 void importVCard( const QString& vCard, bool showPreview );
291 void newContact(); 288 void newContact();
292 QString getNameByPhone( const QString& phone ); 289 QString getNameByPhone( const QString& phone );
293 /** 290 /**
294 END DCOP METHODS 291 END DCOP METHODS
295 */ 292 */
296 293
297 /** 294 /**
298 Saves the contents of the AddressBook back to disk. 295 Saves the contents of the AddressBook back to disk.
299 */ 296 */
300 void save(); 297 void save();
301 298
302 /** 299 /**
303 Undos the last command using the undo stack. 300 Undos the last command using the undo stack.
304 */ 301 */
305 void undo(); 302 void undo();
306 303
307 /** 304 /**
308 Redos the last command that was undone, using the redo stack. 305 Redos the last command that was undone, using the redo stack.
309 */ 306 */
310 void redo(); 307 void redo();
311 308
312 /** 309 /**
313 Shows the edit dialog for the given uid. If the uid is QString::null, 310 Shows the edit dialog for the given uid. If the uid is QString::null,
314 the method will try to find a selected addressee in the view. 311 the method will try to find a selected addressee in the view.
315 */ 312 */
316 void editContact( const QString &uid /*US = QString::null*/ ); 313 void editContact( const QString &uid /*US = QString::null*/ );
317//US added a second method without defaultparameter 314//US added a second method without defaultparameter
318 void editContact2(); 315 void editContact2();
319 316
320 /** 317 /**
321 Shows or edits the detail view for the given uid. If the uid is QString::null, 318 Shows or edits the detail view for the given uid. If the uid is QString::null,
322 the method will try to find a selected addressee in the view. 319 the method will try to find a selected addressee in the view.
323 */ 320 */
324 void executeContact( const QString &uid /*US = QString::null*/ ); 321 void executeContact( const QString &uid /*US = QString::null*/ );
325 322
326 /** 323 /**
327 Launches the configuration dialog. 324 Launches the configuration dialog.
328 */ 325 */
329 void openConfigDialog(); 326 void openConfigDialog();
330 327
331 /** 328 /**
332 Launches the ldap search dialog. 329 Launches the ldap search dialog.
333 */ 330 */
334 void openLDAPDialog(); 331 void openLDAPDialog();
335 332
336 /** 333 /**
337 Creates a KAddressBookPrinter, which will display the print 334 Creates a KAddressBookPrinter, which will display the print
338 dialog and do the printing. 335 dialog and do the printing.
339 */ 336 */
340 void print(); 337 void print();
341 338
342 /** 339 /**
343 Registers a new GUI client, so plugins can register its actions. 340 Registers a new GUI client, so plugins can register its actions.
344 */ 341 */
345 void addGUIClient( KXMLGUIClient *client ); 342 void addGUIClient( KXMLGUIClient *client );
346 343
347 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 344 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
348 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 345 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
349 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 346 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
350 347
351 348
352 signals: 349 signals:
353 void contactSelected( const QString &name ); 350 void contactSelected( const QString &name );
354 void contactSelected( const QPixmap &pixmap ); 351 void contactSelected( const QPixmap &pixmap );
355 public slots: 352 public slots:
356 void recieve(QString cmsg ); 353 void recieve(QString cmsg );
357 void getFile( bool success ); 354 void getFile( bool success );
358 void syncFileRequest(); 355 void syncFileRequest();
359 void setDetailsVisible( bool visible ); 356 void setDetailsVisible( bool visible );
360 void setDetailsToState(); 357 void setDetailsToState();
361 // void slotSyncMenu( int ); 358
359 void saveSettings();
360
362 private slots: 361 private slots:
363 void updateToolBar(); 362 void updateToolBar();
364 void updateMainWindow(); 363 void updateMainWindow();
365 void receive( const QCString& cmsg, const QByteArray& data ); 364 void receive( const QCString& cmsg, const QByteArray& data );
366 void toggleBeamReceive( ); 365 void toggleBeamReceive( );
367 void disableBR(bool); 366 void disableBR(bool);
368 void setJumpButtonBarVisible( bool visible ); 367 void setJumpButtonBarVisible( bool visible );
369 void setCaptionBack(); 368 void setCaptionBack();
370 void importFromOL(); 369 void importFromOL();
371 void extensionModified( const KABC::Addressee::List &list ); 370 void extensionModified( const KABC::Addressee::List &list );
372 void extensionChanged( int id ); 371 void extensionChanged( int id );
373 void clipboardDataChanged(); 372 void clipboardDataChanged();
374 void updateActionMenu(); 373 void updateActionMenu();
375 void configureKeyBindings(); 374 void configureKeyBindings();
376 void removeVoice(); 375 void removeVoice();
377#ifdef KAB_EMBEDDED 376#ifdef KAB_EMBEDDED
378 void configureResources(); 377 void configureResources();
379#endif //KAB_EMBEDDED 378#endif //KAB_EMBEDDED
380 379
381 void slotEditorDestroyed( const QString &uid ); 380 void slotEditorDestroyed( const QString &uid );
382 void configurationChanged(); 381 void configurationChanged();
383 void addressBookChanged(); 382 void addressBookChanged();
384 383
385 private: 384 private:
386 void resizeEvent(QResizeEvent* e ); 385 void resizeEvent(QResizeEvent* e );
387 bool mBRdisabled; 386 bool mBRdisabled;
388#ifndef DESKTOP_VERSION 387#ifndef DESKTOP_VERSION
389 QCopChannel* infrared; 388 QCopChannel* infrared;
390#endif 389#endif
391 QTimer *mMessageTimer; 390 QTimer *mMessageTimer;
392 void initGUI(); 391 void initGUI();
393 void initActions(); 392 void initActions();
394 QString getPhoneFile(); 393 QString getPhoneFile();
395 394
396 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 395 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
397 const char *name = 0 ); 396 const char *name = 0 );
398 397
399 KXMLGUIClient *mGUIClient; 398 KXMLGUIClient *mGUIClient;
400 399
401 KABC::AddressBook *mAddressBook; 400 KABC::AddressBook *mAddressBook;
402 401
403 ViewManager *mViewManager; 402 ViewManager *mViewManager;
404 // QSplitter *mDetailsSplitter; 403 // QSplitter *mDetailsSplitter;
405 KDGanttMinimizeSplitter *mExtensionBarSplitter; 404 KDGanttMinimizeSplitter *mExtensionBarSplitter;
406 ViewContainer *mDetails; 405 ViewContainer *mDetails;
407 KDGanttMinimizeSplitter* mMiniSplitter; 406 KDGanttMinimizeSplitter* mMiniSplitter;
408 XXPortManager *mXXPortManager; 407 XXPortManager *mXXPortManager;
409 JumpButtonBar *mJumpButtonBar; 408 JumpButtonBar *mJumpButtonBar;
410 IncSearchWidget *mIncSearchWidget; 409 IncSearchWidget *mIncSearchWidget;
411 ExtensionManager *mExtensionManager; 410 ExtensionManager *mExtensionManager;
412 411
413 KCMultiDialog *mConfigureDialog; 412 KCMultiDialog *mConfigureDialog;
414 413
415#ifndef KAB_EMBEDDED 414#ifndef KAB_EMBEDDED
416 LDAPSearchDialog *mLdapSearchDialog; 415 LDAPSearchDialog *mLdapSearchDialog;
417#endif //KAB_EMBEDDED 416#endif //KAB_EMBEDDED
418 // QDict<AddresseeEditorDialog> mEditorDict; 417 // QDict<AddresseeEditorDialog> mEditorDict;
419 AddresseeEditorDialog *mEditorDialog; 418 AddresseeEditorDialog *mEditorDialog;
420 bool mReadWrite; 419 bool mReadWrite;
421 bool mModified; 420 bool mModified;
422 bool mIsPart; 421 bool mIsPart;
423 bool mMultipleViewsAtOnce; 422 bool mMultipleViewsAtOnce;
424 423
425 424
426 //US file menu 425 //US file menu
427 KAction *mActionMail; 426 KAction *mActionMail;
428 KAction *mActionBeam; 427 KAction *mActionBeam;
429 KToggleAction *mActionBR; 428 KToggleAction *mActionBR;
430 KAction *mActionExport2phone; 429 KAction *mActionExport2phone;
431 KAction* mActionPrint; 430 KAction* mActionPrint;
432 KAction* mActionNewContact; 431 KAction* mActionNewContact;
433 KAction *mActionSave; 432 KAction *mActionSave;
434 KAction *mActionEditAddressee; 433 KAction *mActionEditAddressee;
435 KAction *mActionMailVCard; 434 KAction *mActionMailVCard;
436 KAction *mActionBeamVCard; 435 KAction *mActionBeamVCard;
437 436
438 KAction *mActionQuit; 437 KAction *mActionQuit;
439 438
440 //US edit menu 439 //US edit menu
441 KAction *mActionCopy; 440 KAction *mActionCopy;
442 KAction *mActionCut; 441 KAction *mActionCut;
443 KAction *mActionPaste; 442 KAction *mActionPaste;
444 KAction *mActionSelectAll; 443 KAction *mActionSelectAll;
445 KAction *mActionUndo; 444 KAction *mActionUndo;
446 KAction *mActionRedo; 445 KAction *mActionRedo;
447 KAction *mActionDelete; 446 KAction *mActionDelete;
448 447
449 //US settings menu 448 //US settings menu
450 KAction *mActionConfigResources; 449 KAction *mActionConfigResources;
451 KAction *mActionConfigKAddressbook; 450 KAction *mActionConfigKAddressbook;
452 KAction *mActionConfigShortcuts; 451 KAction *mActionConfigShortcuts;
453 KAction *mActionConfigureToolbars; 452 KAction *mActionConfigureToolbars;
454 KAction *mActionKeyBindings; 453 KAction *mActionKeyBindings;
455 KToggleAction *mActionJumpBar; 454 KToggleAction *mActionJumpBar;
456 KToggleAction *mActionDetails; 455 KToggleAction *mActionDetails;
457 KAction *mActionWhoAmI; 456 KAction *mActionWhoAmI;
458 KAction *mActionCategories; 457 KAction *mActionCategories;
459 KAction *mActionEditCategories; 458 KAction *mActionEditCategories;
460 KAction *mActionManageCategories; 459 KAction *mActionManageCategories;
461 KAction *mActionAboutKAddressbook; 460 KAction *mActionAboutKAddressbook;
462 KAction *mActionLicence; 461 KAction *mActionLicence;
463 KAction *mActionFaq; 462 KAction *mActionFaq;
464 KAction *mActionWN; 463 KAction *mActionWN;
465 KAction *mActionSyncHowto; 464 KAction *mActionSyncHowto;
466 KAction *mActionKdeSyncHowto; 465 KAction *mActionKdeSyncHowto;
467 KAction *mActionMultiSyncHowto; 466 KAction *mActionMultiSyncHowto;
468 467
469 KAction *mActionDeleteView; 468 KAction *mActionDeleteView;
470 469
471 QPopupMenu *viewMenu; 470 QPopupMenu *viewMenu;
472 QPopupMenu *filterMenu; 471 QPopupMenu *filterMenu;
473 QPopupMenu *settingsMenu; 472 QPopupMenu *settingsMenu;
474 QPopupMenu *changeMenu; 473 QPopupMenu *changeMenu;
475 QPopupMenu *beamMenu; 474 QPopupMenu *beamMenu;
476//US QAction *mActionSave; 475//US QAction *mActionSave;
477 QPopupMenu *ImportMenu; 476 QPopupMenu *ImportMenu;
478 QPopupMenu *ExportMenu; 477 QPopupMenu *ExportMenu;
479 //LR additional methods 478 //LR additional methods
480 KAction *mActionRemoveVoice; 479 KAction *mActionRemoveVoice;
481 KAction * mActionImportOL; 480 KAction * mActionImportOL;
482 481
483#ifndef KAB_EMBEDDED 482#ifndef KAB_EMBEDDED
484 KAddressBookService *mAddressBookService; 483 KAddressBookService *mAddressBookService;
485#endif //KAB_EMBEDDED 484#endif //KAB_EMBEDDED
486 485
487 class KABCorePrivate; 486 class KABCorePrivate;
488 KABCorePrivate *d; 487 KABCorePrivate *d;
489 //US bool mBlockSaveFlag; 488 //US bool mBlockSaveFlag;
490 489
491#ifdef KAB_EMBEDDED 490#ifdef KAB_EMBEDDED
492 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 491 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
493#endif //KAB_EMBEDDED 492#endif //KAB_EMBEDDED
494 493
495 //this are the overwritten callbackmethods from the syncinterface 494 //this are the overwritten callbackmethods from the syncinterface
496 virtual bool sync(KSyncManager* manager, QString filename, int mode); 495 virtual bool sync(KSyncManager* manager, QString filename, int mode);
497 virtual bool syncExternal(KSyncManager* manager, QString resource); 496 virtual bool syncExternal(KSyncManager* manager, QString resource);
498 virtual void removeSyncInfo( QString syncProfile); 497 virtual void removeSyncInfo( QString syncProfile);
499 bool syncPhone(); 498 bool syncPhone();
500 void message( QString m ); 499 void message( QString m );
501 500
502 // LR ******************************* 501 // LR *******************************
503 // sync stuff! 502 // sync stuff!
504 QString sentSyncFile(); 503 QString sentSyncFile();
505 QPopupMenu *syncMenu; 504 QPopupMenu *syncMenu;
506 KSyncManager* syncManager; 505 KSyncManager* syncManager;
507 int mGlobalSyncMode; 506 int mGlobalSyncMode;
508 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 507 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
509 KABC::Addressee getLastSyncAddressee(); 508 KABC::Addressee getLastSyncAddressee();
510 QDateTime mLastAddressbookSync; 509 QDateTime mLastAddressbookSync;
511 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 510 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
512 // ********************* 511 // *********************
513 512
514}; 513};
515 514
516#endif 515#endif
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 33bef5a..59bddd9 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -1,725 +1,726 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31 31
32#ifndef KAB_EMBEDDED 32#ifndef KAB_EMBEDDED
33#include <libkdepim/kvcarddrag.h> 33#include <libkdepim/kvcarddrag.h>
34#include <kabc/vcardconverter.h> 34#include <kabc/vcardconverter.h>
35#include <kconfig.h> 35#include <kconfig.h>
36#include <kdeversion.h> 36#include <kdeversion.h>
37#include <kiconloader.h> 37#include <kiconloader.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40#include <kmultipledrag.h> 40#include <kmultipledrag.h>
41#include <ktrader.h> 41#include <ktrader.h>
42#include <kurldrag.h> 42#include <kurldrag.h>
43 43
44#include "addresseeutil.h" 44#include "addresseeutil.h"
45#else //KAB_EMBEDDED 45#else //KAB_EMBEDDED
46#include "views/kaddressbookiconview.h" 46#include "views/kaddressbookiconview.h"
47#include "views/kaddressbooktableview.h" 47#include "views/kaddressbooktableview.h"
48#include "views/kaddressbookcardview.h" 48#include "views/kaddressbookcardview.h"
49#include "kaddressbookview.h" 49#include "kaddressbookview.h"
50 50
51#include <qaction.h> 51#include <qaction.h>
52#include <qmessagebox.h> 52#include <qmessagebox.h>
53#include <qpopupmenu.h> 53#include <qpopupmenu.h>
54#include <kconfigbase.h> 54#include <kconfigbase.h>
55 55
56#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
57 57
58 58
59#include <kdebug.h> 59#include <kdebug.h>
60#include <kactionclasses.h> 60#include <kactionclasses.h>
61 61
62#include <qlayout.h> 62#include <qlayout.h>
63#include <qapplication.h> 63#include <qapplication.h>
64#include <qwidgetstack.h> 64#include <qwidgetstack.h>
65 65
66#include <kabc/addressbook.h> 66#include <kabc/addressbook.h>
67#include "filtereditdialog.h" 67#include "filtereditdialog.h"
68#include "addviewdialog.h" 68#include "addviewdialog.h"
69#include "kabcore.h" 69#include "kabcore.h"
70#include "kabprefs.h" 70#include "kabprefs.h"
71#include "viewmanager.h" 71#include "viewmanager.h"
72 72
73ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) 73ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name )
74 : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) 74 : QWidget( parent, name ), mCore( core ), mActiveView( 0 )
75{ 75{
76 initGUI(); 76 initGUI();
77 initActions(); 77 initActions();
78 78
79 mViewDict.setAutoDelete( true ); 79 mViewDict.setAutoDelete( true );
80 80
81 createViewFactories(); 81 createViewFactories();
82} 82}
83 83
84ViewManager::~ViewManager() 84ViewManager::~ViewManager()
85{ 85{
86 unloadViews(); 86 unloadViews();
87 mViewFactoryDict.clear(); 87 mViewFactoryDict.clear();
88} 88}
89void ViewManager::scrollUP() 89void ViewManager::scrollUP()
90{ 90{
91 if ( mActiveView ) 91 if ( mActiveView )
92 mActiveView->scrollUP(); 92 mActiveView->scrollUP();
93} 93}
94void ViewManager::scrollDOWN() 94void ViewManager::scrollDOWN()
95{ 95{
96 if ( mActiveView ) 96 if ( mActiveView )
97 mActiveView->scrollDOWN(); 97 mActiveView->scrollDOWN();
98} 98}
99void ViewManager::restoreSettings() 99void ViewManager::restoreSettings()
100{ 100{
101 mViewNameList = KABPrefs::instance()->mViewNames; 101 mViewNameList = KABPrefs::instance()->mViewNames;
102 QString activeViewName = KABPrefs::instance()->mCurrentView; 102 QString activeViewName = KABPrefs::instance()->mCurrentView;
103 103
104 mActionSelectView->setItems( mViewNameList ); 104 mActionSelectView->setItems( mViewNameList );
105 105
106 // Filter 106 // Filter
107 mFilterList = Filter::restore( mCore->config(), "Filter" ); 107 mFilterList = Filter::restore( mCore->config(), "Filter" );
108 mActionSelectFilter->setItems( filterNames() ); 108 mActionSelectFilter->setItems( filterNames() );
109 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); 109 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter );
110 int cw = 150; 110 int cw = 150;
111 if (QApplication::desktop()->width() == 480 ) 111 if (QApplication::desktop()->width() == 480 )
112 cw = 0; 112 cw = 0;
113 mActionSelectFilter->setComboWidth( cw ); 113 mActionSelectFilter->setComboWidth( cw );
114 // Tell the views to reread their config, since they may have 114 // Tell the views to reread their config, since they may have
115 // been modified by global settings 115 // been modified by global settings
116 QString _oldgroup = mCore->config()->group(); 116 QString _oldgroup = mCore->config()->group();
117 117
118 QDictIterator<KAddressBookView> it( mViewDict ); 118 QDictIterator<KAddressBookView> it( mViewDict );
119 for ( it.toFirst(); it.current(); ++it ) { 119 for ( it.toFirst(); it.current(); ++it ) {
120 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 120 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
121 it.current()->readConfig( mCore->config() ); 121 it.current()->readConfig( mCore->config() );
122 } 122 }
123 setActiveView( activeViewName ); 123 setActiveView( activeViewName );
124 124
125 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 125 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
126} 126}
127 127
128void ViewManager::saveSettings() 128void ViewManager::saveSettings()
129{ 129{
130 QString _oldgroup = mCore->config()->group(); 130 QString _oldgroup = mCore->config()->group();
131 131
132 QDictIterator<KAddressBookView> it( mViewDict ); 132 QDictIterator<KAddressBookView> it( mViewDict );
133 for ( it.toFirst(); it.current(); ++it ) { 133 for ( it.toFirst(); it.current(); ++it ) {
134 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 134 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
135#ifdef DESKTOP_VERSION 135#ifdef DESKTOP_VERSION
136 (*it)->writeConfig( mCore->config() ); 136 (*it)->writeConfig( mCore->config() );
137#else 137#else
138 (*it).writeConfig( mCore->config() ); 138 (*it).writeConfig( mCore->config() );
139#endif 139#endif
140 } 140 }
141 141
142 Filter::save( mCore->config(), "Filter", mFilterList ); 142 Filter::save( mCore->config(), "Filter", mFilterList );
143 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); 143 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
144 144
145 // write the view name list 145 // write the view name list
146 KABPrefs::instance()->mViewNames = mViewNameList; 146 KABPrefs::instance()->mViewNames = mViewNameList;
147 KABPrefs::instance()->mCurrentView = mActiveView->caption(); 147 KABPrefs::instance()->mCurrentView = mActiveView->caption();
148 148
149} 149}
150 150
151QStringList ViewManager::selectedUids() const 151QStringList ViewManager::selectedUids() const
152{ 152{
153 if ( mActiveView ) 153 if ( mActiveView )
154 return mActiveView->selectedUids(); 154 return mActiveView->selectedUids();
155 else 155 else
156 return QStringList(); 156 return QStringList();
157} 157}
158 158
159QStringList ViewManager::selectedEmails() const 159QStringList ViewManager::selectedEmails() const
160{ 160{
161 if ( mActiveView ) 161 if ( mActiveView )
162 return mActiveView->selectedEmails(); 162 return mActiveView->selectedEmails();
163 else 163 else
164 return QStringList(); 164 return QStringList();
165} 165}
166 166
167KABC::Addressee::List ViewManager::selectedAddressees() const 167KABC::Addressee::List ViewManager::selectedAddressees() const
168{ 168{
169 KABC::Addressee::List list; 169 KABC::Addressee::List list;
170 if ( mActiveView ) { 170 if ( mActiveView ) {
171 QStringList uids = mActiveView->selectedUids(); 171 QStringList uids = mActiveView->selectedUids();
172 QStringList::Iterator it; 172 QStringList::Iterator it;
173 for ( it = uids.begin(); it != uids.end(); ++it ) { 173 for ( it = uids.begin(); it != uids.end(); ++it ) {
174 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 174 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
175 if ( !addr.isEmpty() ) 175 if ( !addr.isEmpty() )
176 list.append( addr ); 176 list.append( addr );
177 } 177 }
178 } 178 }
179 179
180 return list; 180 return list;
181} 181}
182//US added another method with no parameter, since my moc compiler does not support default parameters. 182//US added another method with no parameter, since my moc compiler does not support default parameters.
183void ViewManager::setSelected() 183void ViewManager::setSelected()
184{ 184{
185 setSelected( QString::null, true ); 185 setSelected( QString::null, true );
186} 186}
187 187
188void ViewManager::setSelected( const QString &uid, bool selected ) 188void ViewManager::setSelected( const QString &uid, bool selected )
189{ 189{
190 if ( mActiveView ) 190 if ( mActiveView )
191 mActiveView->setSelected( uid, selected ); 191 mActiveView->setSelected( uid, selected );
192} 192}
193 193
194void ViewManager::setListSelected(QStringList list) 194void ViewManager::setListSelected(QStringList list)
195{ 195{
196 int i, count = list.count(); 196 int i, count = list.count();
197 for ( i = 0; i < count;++i ) 197 for ( i = 0; i < count;++i )
198 setSelected( list[i], true ); 198 setSelected( list[i], true );
199 199
200} 200}
201void ViewManager::unloadViews() 201void ViewManager::unloadViews()
202{ 202{
203 mViewDict.clear(); 203 mViewDict.clear();
204 mActiveView = 0; 204 mActiveView = 0;
205} 205}
206 206
207void ViewManager::setActiveView( const QString &name ) 207void ViewManager::setActiveView( const QString &name )
208{ 208{
209 KAddressBookView *view = 0; 209 KAddressBookView *view = 0;
210 210
211 // Check that this isn't the same as the current active view 211 // Check that this isn't the same as the current active view
212 if ( mActiveView && ( mActiveView->caption() == name ) ) 212 if ( mActiveView && ( mActiveView->caption() == name ) )
213 return; 213 return;
214 214
215 // At this point we know the view that should be active is not 215 // At this point we know the view that should be active is not
216 // currently active. We will try to find the new on in the list. If 216 // currently active. We will try to find the new on in the list. If
217 // we can't find it, it means it hasn't been instantiated, so we will 217 // we can't find it, it means it hasn't been instantiated, so we will
218 // create it on demand. 218 // create it on demand.
219 219
220 view = mViewDict.find( name ); 220 view = mViewDict.find( name );
221 221
222 // Check if we found the view. If we didn't, then we need to create it 222 // Check if we found the view. If we didn't, then we need to create it
223 if ( view == 0 ) { 223 if ( view == 0 ) {
224 KConfig *config = mCore->config(); 224 KConfig *config = mCore->config();
225 225
226 KConfigGroupSaver saver( config, name ); 226 KConfigGroupSaver saver( config, name );
227 227
228 QString type = config->readEntry( "Type", "Table" ); 228 QString type = config->readEntry( "Type", "Table" );
229 229
230 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; 230 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl;
231 231
232 ViewFactory *factory = mViewFactoryDict.find( type ); 232 ViewFactory *factory = mViewFactoryDict.find( type );
233 if ( factory ) 233 if ( factory )
234 view = factory->view( mCore->addressBook(), mViewWidgetStack ); 234 view = factory->view( mCore->addressBook(), mViewWidgetStack );
235 235
236 if ( view ) { 236 if ( view ) {
237 view->setCaption( name ); 237 view->setCaption( name );
238 mViewDict.insert( name, view ); 238 mViewDict.insert( name, view );
239//US my version needs an int as second parameter to addWidget 239//US my version needs an int as second parameter to addWidget
240 mViewWidgetStack->addWidget( view, -1 ); 240 mViewWidgetStack->addWidget( view, -1 );
241 view->readConfig( config ); 241 view->readConfig( config );
242 242
243 // The manager just relays the signals 243 // The manager just relays the signals
244 connect( view, SIGNAL( selected( const QString& ) ), 244 connect( view, SIGNAL( selected( const QString& ) ),
245 SIGNAL( selected( const QString & ) ) ); 245 SIGNAL( selected( const QString & ) ) );
246 connect( view, SIGNAL( executed( const QString& ) ), 246 connect( view, SIGNAL( executed( const QString& ) ),
247 SIGNAL( executed( const QString& ) ) ); 247 SIGNAL( executed( const QString& ) ) );
248 248
249 connect( view, SIGNAL( deleteRequest( ) ), 249 connect( view, SIGNAL( deleteRequest( ) ),
250 SIGNAL( deleteRequest( ) ) ); 250 SIGNAL( deleteRequest( ) ) );
251 251
252 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); 252 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) );
253 connect( view, SIGNAL( dropped( QDropEvent* ) ), 253 connect( view, SIGNAL( dropped( QDropEvent* ) ),
254 SLOT( dropped( QDropEvent* ) ) ); 254 SLOT( dropped( QDropEvent* ) ) );
255 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); 255 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) );
256 } 256 }
257 } 257 }
258 258
259 // If we found or created the view, raise it and refresh it 259 // If we found or created the view, raise it and refresh it
260 if ( view ) { 260 if ( view ) {
261 mActiveView = view; 261 mActiveView = view;
262 mViewWidgetStack->raiseWidget( view ); 262 mViewWidgetStack->raiseWidget( view );
263 // Set the proper filter in the view. By setting the combo 263 // Set the proper filter in the view. By setting the combo
264 // box, the activated slot will be called, which will push 264 // box, the activated slot will be called, which will push
265 // the filter to the view and refresh it. 265 // the filter to the view and refresh it.
266 266
267 if ( view->defaultFilterType() == KAddressBookView::None ) { 267 if ( view->defaultFilterType() == KAddressBookView::None ) {
268 268
269 mActionSelectFilter->setCurrentItem( 0 ); 269 mActionSelectFilter->setCurrentItem( 0 );
270 setActiveFilter( 0 ); 270 setActiveFilter( 0 );
271 } else if ( view->defaultFilterType() == KAddressBookView::Active ) { 271 } else if ( view->defaultFilterType() == KAddressBookView::Active ) {
272 setActiveFilter( mActionSelectFilter->currentItem() ); 272 setActiveFilter( mActionSelectFilter->currentItem() );
273 } else { 273 } else {
274 uint pos = filterPosition( view->defaultFilterName() ); 274 uint pos = filterPosition( view->defaultFilterName() );
275 mActionSelectFilter->setCurrentItem( pos ); 275 mActionSelectFilter->setCurrentItem( pos );
276 setActiveFilter( pos ); 276 setActiveFilter( pos );
277 } 277 }
278//US qDebug("ViewManager::setActiveView 6" ); 278//US qDebug("ViewManager::setActiveView 6" );
279 279
280 // Update the inc search widget to show the fields in the new active 280 // Update the inc search widget to show the fields in the new active
281 // view. 281 // view.
282 mCore->setSearchFields( mActiveView->fields() ); 282 mCore->setSearchFields( mActiveView->fields() );
283 283
284//US performance optimization. setActiveFilter calls also mActiveView->refresh() 284//US performance optimization. setActiveFilter calls also mActiveView->refresh()
285//US mActiveView->refresh(); 285//US mActiveView->refresh();
286 286
287 } 287 }
288 else 288 else
289 { 289 {
290 qDebug("ViewManager::setActiveView: unable to find view" ); 290 qDebug("ViewManager::setActiveView: unable to find view" );
291 kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; 291 kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n";
292 } 292 }
293} 293}
294 294
295//US added another method with no parameter, since my moc compiler does not support default parameters. 295//US added another method with no parameter, since my moc compiler does not support default parameters.
296void ViewManager::refreshView() 296void ViewManager::refreshView()
297{ 297{
298 refreshView( QString::null ); 298 refreshView( QString::null );
299} 299}
300 300
301void ViewManager::refreshView( const QString &uid ) 301void ViewManager::refreshView( const QString &uid )
302{ 302{
303 if ( mActiveView ) 303 if ( mActiveView )
304 mActiveView->refresh( uid ); 304 mActiveView->refresh( uid );
305} 305}
306 306
307void ViewManager::setFocusAV() 307void ViewManager::setFocusAV()
308{ 308{
309 if ( mActiveView ) 309 if ( mActiveView )
310 mActiveView->setFocusAV(); 310 mActiveView->setFocusAV();
311} 311}
312void ViewManager::editView() 312void ViewManager::editView()
313{ 313{
314 if ( !mActiveView ) 314 if ( !mActiveView )
315 return; 315 return;
316 316
317 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); 317 ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() );
318 ViewConfigureWidget *wdg = 0; 318 ViewConfigureWidget *wdg = 0;
319 ViewConfigureDialog* dlg = 0; 319 ViewConfigureDialog* dlg = 0;
320 if ( factory ) { 320 if ( factory ) {
321 // Save the filters so the dialog has the latest set 321 // Save the filters so the dialog has the latest set
322 Filter::save( mCore->config(), "Filter", mFilterList ); 322 Filter::save( mCore->config(), "Filter", mFilterList );
323 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); 323 dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" );
324 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); 324 wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" );
325 } else { 325 } else {
326 qDebug("ViewManager::editView()::cannot find viewfactory "); 326 qDebug("ViewManager::editView()::cannot find viewfactory ");
327 return; 327 return;
328 } 328 }
329 if ( wdg ) { 329 if ( wdg ) {
330 dlg->setWidget( wdg ); 330 dlg->setWidget( wdg );
331 331
332#ifndef DESKTOP_VERSION 332#ifndef DESKTOP_VERSION
333 //dlg.setMaximumSize( 640, 480 ); 333 //dlg.setMaximumSize( 640, 480 );
334 //dlg->setGeometry( 40,40, 400, 300); 334 //dlg->setGeometry( 40,40, 400, 300);
335 dlg->showMaximized(); 335 dlg->showMaximized();
336#endif 336#endif
337 337
338 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); 338 KConfigGroupSaver saver( mCore->config(), mActiveView->caption() );
339 339
340 dlg->restoreSettings( mCore->config() ); 340 dlg->restoreSettings( mCore->config() );
341 341
342 if ( dlg->exec() ) { 342 if ( dlg->exec() ) {
343 dlg->saveSettings( mCore->config() ); 343 dlg->saveSettings( mCore->config() );
344 mActiveView->readConfig( mCore->config() ); 344 mActiveView->readConfig( mCore->config() );
345 345
346 // Set the proper filter in the view. By setting the combo 346 // Set the proper filter in the view. By setting the combo
347 // box, the activated slot will be called, which will push 347 // box, the activated slot will be called, which will push
348 // the filter to the view and refresh it. 348 // the filter to the view and refresh it.
349 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { 349 if ( mActiveView->defaultFilterType() == KAddressBookView::None ) {
350 mActionSelectFilter->setCurrentItem( 0 ); 350 mActionSelectFilter->setCurrentItem( 0 );
351 setActiveFilter( 0 ); 351 setActiveFilter( 0 );
352 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { 352 } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) {
353 setActiveFilter( mActionSelectFilter->currentItem() ); 353 setActiveFilter( mActionSelectFilter->currentItem() );
354 } else { 354 } else {
355 uint pos = filterPosition( mActiveView->defaultFilterName() ); 355 uint pos = filterPosition( mActiveView->defaultFilterName() );
356 mActionSelectFilter->setCurrentItem( pos ); 356 mActionSelectFilter->setCurrentItem( pos );
357 setActiveFilter( pos ); 357 setActiveFilter( pos );
358 } 358 }
359 mCore->setSearchFields( mActiveView->fields() ); 359 mCore->setSearchFields( mActiveView->fields() );
360//US performance optimization. setActiveFilter calls also mActiveView->refresh() 360//US performance optimization. setActiveFilter calls also mActiveView->refresh()
361//US mActiveView->refresh(); 361//US mActiveView->refresh();
362 362
363 363
364 //US this is a bugfix, that we get notified if we change a views configuration 364 //US this is a bugfix, that we get notified if we change a views configuration
365 emit modified(); 365 emit modified();
366 366
367 } 367 }
368 368
369 } 369 }
370 delete dlg; 370 delete dlg;
371} 371}
372 372
373void ViewManager::deleteView() 373void ViewManager::deleteView()
374{ 374{
375 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) 375 QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" )
376 .arg( mActiveView->caption() ); 376 .arg( mActiveView->caption() );
377 QString caption = i18n( "Confirm Delete" ); 377 QString caption = i18n( "Confirm Delete" );
378 378
379 379
380 if (QMessageBox::information( this, caption, 380 if (QMessageBox::information( this, caption,
381 text, 381 text,
382 i18n("Yes!"), i18n("No"), 0, 0 ) == 0) 382 i18n("Yes!"), i18n("No"), 0, 0 ) == 0)
383 { 383 {
384 mViewNameList.remove( mActiveView->caption() ); 384 mViewNameList.remove( mActiveView->caption() );
385 385
386 // remove the view from the config file 386 // remove the view from the config file
387 KConfig *config = mCore->config(); 387 KConfig *config = mCore->config();
388 config->deleteGroup( mActiveView->caption() ); 388 config->deleteGroup( mActiveView->caption() );
389 389
390 mViewDict.remove( mActiveView->caption() ); 390 mViewDict.remove( mActiveView->caption() );
391 mActiveView = 0; 391 mActiveView = 0;
392 392
393 // we are in an invalid state now, but that should be fixed after 393 // we are in an invalid state now, but that should be fixed after
394 // we emit the signal 394 // we emit the signal
395 mActionSelectView->setItems( mViewNameList ); 395 mActionSelectView->setItems( mViewNameList );
396 if ( mViewNameList.count() > 0 ) { 396 if ( mViewNameList.count() > 0 ) {
397 mActionSelectView->setCurrentItem( 0 ); 397 mActionSelectView->setCurrentItem( 0 );
398 setActiveView( mViewNameList[ 0 ] ); 398 setActiveView( mViewNameList[ 0 ] );
399 } 399 }
400 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 400 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
401 } 401 }
402} 402}
403 403
404void ViewManager::addView() 404void ViewManager::addView()
405{ 405{
406 AddViewDialog dialog( &mViewFactoryDict, this ); 406 AddViewDialog dialog( &mViewFactoryDict, this );
407 407
408 if ( dialog.exec() ) { 408 if ( dialog.exec() ) {
409 QString newName = dialog.viewName(); 409 QString newName = dialog.viewName();
410 QString type = dialog.viewType(); 410 QString type = dialog.viewType();
411 411
412 // Check for name conflicts 412 // Check for name conflicts
413 bool firstConflict = true; 413 bool firstConflict = true;
414 int numTries = 1; 414 int numTries = 1;
415 while ( mViewNameList.contains( newName ) > 0 ) { 415 while ( mViewNameList.contains( newName ) > 0 ) {
416 if ( !firstConflict ) { 416 if ( !firstConflict ) {
417 newName = newName.left( newName.length() - 4 ); 417 newName = newName.left( newName.length() - 4 );
418 firstConflict = false; 418 firstConflict = false;
419 } 419 }
420 420
421 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); 421 newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries );
422 numTries++; 422 numTries++;
423 } 423 }
424 424
425 // Add the new one to the list 425 // Add the new one to the list
426 mViewNameList.append( newName ); 426 mViewNameList.append( newName );
427 427
428 // write the view to the config file, 428 // write the view to the config file,
429 KConfig *config = mCore->config(); 429 KConfig *config = mCore->config();
430 430
431 config->deleteGroup( newName ); 431 config->deleteGroup( newName );
432 432
433 KConfigGroupSaver saver( config, newName ); 433 KConfigGroupSaver saver( config, newName );
434 434
435 config->writeEntry( "Type", type ); 435 config->writeEntry( "Type", type );
436 436
437 // try to set the active view 437 // try to set the active view
438 mActionSelectView->setItems( mViewNameList ); 438 mActionSelectView->setItems( mViewNameList );
439 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); 439 mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) );
440 setActiveView( newName ); 440 setActiveView( newName );
441 441
442 editView(); 442 editView();
443 443
444 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 444 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
445 } 445 }
446} 446}
447 447
448void ViewManager::createViewFactories() 448void ViewManager::createViewFactories()
449{ 449{
450#ifndef KAB_EMBEDDED 450#ifndef KAB_EMBEDDED
451 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); 451 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" );
452 KTrader::OfferList::ConstIterator it; 452 KTrader::OfferList::ConstIterator it;
453 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 453 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
454 if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) 454 if ( !(*it)->hasServiceType( "KAddressBook/View" ) )
455 continue; 455 continue;
456 456
457 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 457 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
458 458
459 if ( !factory ) { 459 if ( !factory ) {
460 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; 460 kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl;
461 continue; 461 continue;
462 } 462 }
463 463
464 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); 464 ViewFactory *viewFactory = static_cast<ViewFactory*>( factory );
465 465
466 if ( !viewFactory ) { 466 if ( !viewFactory ) {
467 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; 467 kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl;
468 continue; 468 continue;
469 } 469 }
470 470
471 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 471 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
472 } 472 }
473 473
474#else //KAB_EMBEDDED 474#else //KAB_EMBEDDED
475 ViewFactory* viewFactory = new IconViewFactory(); 475 ViewFactory* viewFactory = new IconViewFactory();
476 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 476 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
477// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 477// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
478 478
479 viewFactory = new TableViewFactory(); 479 viewFactory = new TableViewFactory();
480 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 480 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
481// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 481// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
482 482
483 viewFactory = new CardViewFactory(); 483 viewFactory = new CardViewFactory();
484 mViewFactoryDict.insert( viewFactory->type(), viewFactory ); 484 mViewFactoryDict.insert( viewFactory->type(), viewFactory );
485// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); 485// qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1());
486 486
487#endif //KAB_EMBEDDED 487#endif //KAB_EMBEDDED
488 488
489} 489}
490 490
491void ViewManager::dropped( QDropEvent *e ) 491void ViewManager::dropped( QDropEvent *e )
492{ 492{
493 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; 493 kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl;
494 494
495#ifndef KAB_EMBEDDED 495#ifndef KAB_EMBEDDED
496 496
497 QString clipText, vcards; 497 QString clipText, vcards;
498 KURL::List urls; 498 KURL::List urls;
499 499
500 if ( KURLDrag::decode( e, urls) ) { 500 if ( KURLDrag::decode( e, urls) ) {
501 KURL::List::Iterator it = urls.begin(); 501 KURL::List::Iterator it = urls.begin();
502 int c = urls.count(); 502 int c = urls.count();
503 if ( c > 1 ) { 503 if ( c > 1 ) {
504 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); 504 QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c );
505 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { 505 if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) {
506 for ( ; it != urls.end(); ++it ) 506 for ( ; it != urls.end(); ++it )
507 emit urlDropped( *it ); 507 emit urlDropped( *it );
508 } 508 }
509 } else if ( c == 1 ) 509 } else if ( c == 1 )
510 emit urlDropped( *it ); 510 emit urlDropped( *it );
511 } else if ( KVCardDrag::decode( e, vcards ) ) { 511 } else if ( KVCardDrag::decode( e, vcards ) ) {
512 KABC::Addressee addr; 512 KABC::Addressee addr;
513 KABC::VCardConverter converter; 513 KABC::VCardConverter converter;
514 QStringList list = QStringList::split( "\r\n\r\n", vcards ); 514 QStringList list = QStringList::split( "\r\n\r\n", vcards );
515 QStringList::Iterator it; 515 QStringList::Iterator it;
516 for ( it = list.begin(); it != list.end(); ++it ) { 516 for ( it = list.begin(); it != list.end(); ++it ) {
517 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { 517 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) {
518 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); 518 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() );
519 if ( a.isEmpty() ) { 519 if ( a.isEmpty() ) {
520 mCore->addressBook()->insertAddressee( addr ); 520 mCore->addressBook()->insertAddressee( addr );
521 emit modified(); 521 emit modified();
522 } 522 }
523 } 523 }
524 } 524 }
525 525
526 mActiveView->refresh(); 526 mActiveView->refresh();
527 } 527 }
528#else //KAB_EMBEDDED 528#else //KAB_EMBEDDED
529qDebug("ViewManager::dropped() has to be changed!!" ); 529qDebug("ViewManager::dropped() has to be changed!!" );
530#endif //KAB_EMBEDDED 530#endif //KAB_EMBEDDED
531 531
532} 532}
533 533
534void ViewManager::startDrag() 534void ViewManager::startDrag()
535{ 535{
536 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; 536 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;
537 537
538#ifndef KAB_EMBEDDED 538#ifndef KAB_EMBEDDED
539 539
540 // Get the list of all the selected addressees 540 // Get the list of all the selected addressees
541 KABC::Addressee::List addrList; 541 KABC::Addressee::List addrList;
542 QStringList uidList = selectedUids(); 542 QStringList uidList = selectedUids();
543 QStringList::Iterator iter; 543 QStringList::Iterator iter;
544 for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) 544 for ( iter = uidList.begin(); iter != uidList.end(); ++iter )
545 addrList.append( mCore->addressBook()->findByUid( *iter ) ); 545 addrList.append( mCore->addressBook()->findByUid( *iter ) );
546 546
547 KMultipleDrag *drag = new KMultipleDrag( this ); 547 KMultipleDrag *drag = new KMultipleDrag( this );
548 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); 548 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) );
549 KABC::Addressee::List::Iterator it; 549 KABC::Addressee::List::Iterator it;
550 QStringList vcards; 550 QStringList vcards;
551 for ( it = addrList.begin(); it != addrList.end(); ++it ) { 551 for ( it = addrList.begin(); it != addrList.end(); ++it ) {
552 QString vcard = QString::null; 552 QString vcard = QString::null;
553 KABC::VCardConverter converter; 553 KABC::VCardConverter converter;
554 if ( converter.addresseeToVCard( *it, vcard ) ) 554 if ( converter.addresseeToVCard( *it, vcard ) )
555 vcards.append( vcard ); 555 vcards.append( vcard );
556 } 556 }
557 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); 557 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) );
558 558
559 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); 559 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) );
560 drag->dragCopy(); 560 drag->dragCopy();
561 561
562#else //KAB_EMBEDDED 562#else //KAB_EMBEDDED
563qDebug("ViewManager::startDrag() has to be changed!!" ); 563qDebug("ViewManager::startDrag() has to be changed!!" );
564#endif //KAB_EMBEDDED 564#endif //KAB_EMBEDDED
565 565
566} 566}
567void ViewManager::doSearch( const QString& s,KABC::Field *field ) 567void ViewManager::doSearch( const QString& s,KABC::Field *field )
568{ 568{
569 if ( mActiveView ) 569 if ( mActiveView )
570 mActiveView->doSearch( s, field ); 570 mActiveView->doSearch( s, field );
571 571
572} 572}
573void ViewManager::setActiveFilter( int index ) 573void ViewManager::setActiveFilter( int index )
574{ 574{
575 Filter currentFilter; 575 Filter currentFilter;
576 576
577 if ( ( index - 1 ) < 0 ) 577 if ( ( index - 1 ) < 0 )
578 currentFilter = Filter(); 578 currentFilter = Filter();
579 else 579 else
580 currentFilter = mFilterList[ index - 1 ]; 580 currentFilter = mFilterList[ index - 1 ];
581 581
582 // Check if we have a view. Since the filter combo is created before 582 // Check if we have a view. Since the filter combo is created before
583 // the view, this slot could be called before there is a valid view. 583 // the view, this slot could be called before there is a valid view.
584 if ( mActiveView ) { 584 if ( mActiveView ) {
585 mActiveView->setFilter( currentFilter ); 585 mActiveView->setFilter( currentFilter );
586 mActiveView->refresh(); 586 mActiveView->refresh();
587 emit selected( QString::null ); 587 emit selected( QString::null );
588 } 588 }
589} 589}
590 590
591void ViewManager::configureFilters() 591void ViewManager::configureFilters()
592{ 592{
593 FilterDialog dlg( this ); 593 FilterDialog dlg( this );
594 594
595 dlg.setFilters( mFilterList ); 595 dlg.setFilters( mFilterList );
596 596
597 if ( dlg.exec() ) 597 if ( dlg.exec() )
598 mFilterList = dlg.filters(); 598 mFilterList = dlg.filters();
599 599
600 uint pos = mActionSelectFilter->currentItem(); 600 uint pos = mActionSelectFilter->currentItem();
601 mActionSelectFilter->setItems( filterNames() ); 601 mActionSelectFilter->setItems( filterNames() );
602 mActionSelectFilter->setCurrentItem( pos ); 602 mActionSelectFilter->setCurrentItem( pos );
603 setActiveFilter( pos ); 603 setActiveFilter( pos );
604 int cw = 150; 604 int cw = 150;
605 if (QApplication::desktop()->width() == 480 ) 605 if (QApplication::desktop()->width() == 480 )
606 cw = 0; 606 cw = 0;
607 mActionSelectFilter->setComboWidth( cw ); 607 mActionSelectFilter->setComboWidth( cw );
608 saveSettings();
608} 609}
609 610
610QStringList ViewManager::filterNames() const 611QStringList ViewManager::filterNames() const
611{ 612{
612 QStringList names( i18n( "No Filter" ) ); 613 QStringList names( i18n( "No Filter" ) );
613 614
614 Filter::List::ConstIterator it; 615 Filter::List::ConstIterator it;
615 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 616 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
616 names.append( (*it).name() ); 617 names.append( (*it).name() );
617 618
618 return names; 619 return names;
619} 620}
620 621
621int ViewManager::filterPosition( const QString &name ) const 622int ViewManager::filterPosition( const QString &name ) const
622{ 623{
623 int pos = 0; 624 int pos = 0;
624 625
625 Filter::List::ConstIterator it; 626 Filter::List::ConstIterator it;
626 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 627 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
627 if ( name == (*it).name() ) 628 if ( name == (*it).name() )
628 return pos + 1; 629 return pos + 1;
629 630
630 return 0; 631 return 0;
631} 632}
632 633
633void ViewManager::initActions() 634void ViewManager::initActions()
634{ 635{
635//US <ActionList name="view_loadedviews"/> 636//US <ActionList name="view_loadedviews"/>
636//US <Separator/> 637//US <Separator/>
637 638
638#ifdef KAB_EMBEDDED 639#ifdef KAB_EMBEDDED
639 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 640 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
640 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 641 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
641 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 642 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
642#endif //KAB_EMBEDDED 643#endif //KAB_EMBEDDED
643 644
644 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 645 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
645#if KDE_VERSION >= 309 646#if KDE_VERSION >= 309
646 mActionSelectView->setMenuAccelsEnabled( false ); 647 mActionSelectView->setMenuAccelsEnabled( false );
647#endif 648#endif
648 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 649 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
649 SLOT( setActiveView( const QString& ) ) ); 650 SLOT( setActiveView( const QString& ) ) );
650 651
651 652
652#ifdef KAB_EMBEDDED 653#ifdef KAB_EMBEDDED
653 mActionSelectView->plug(viewmenu); 654 mActionSelectView->plug(viewmenu);
654 viewmenu->insertSeparator(); 655 viewmenu->insertSeparator();
655#endif //KAB_EMBEDDED 656#endif //KAB_EMBEDDED
656 657
657 KAction *action; 658 KAction *action;
658 659
659 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 660 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
660 SLOT( editView() ), mCore->actionCollection(), "view_modify" ); 661 SLOT( editView() ), mCore->actionCollection(), "view_modify" );
661#ifndef KAB_EMBEDDED 662#ifndef KAB_EMBEDDED
662 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); 663 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) );
663#else //KAB_EMBEDDED 664#else //KAB_EMBEDDED
664 action->plug(viewmenu); 665 action->plug(viewmenu);
665#endif //KAB_EMBEDDED 666#endif //KAB_EMBEDDED
666 667
667 action = new KAction( i18n( "Add View..." ), "window_new", 0, this, 668 action = new KAction( i18n( "Add View..." ), "window_new", 0, this,
668 SLOT( addView() ), mCore->actionCollection(), "view_add" ); 669 SLOT( addView() ), mCore->actionCollection(), "view_add" );
669#ifndef KAB_EMBEDDED 670#ifndef KAB_EMBEDDED
670 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); 671 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) );
671#else //KAB_EMBEDDED 672#else //KAB_EMBEDDED
672 action->plug(viewmenu); 673 action->plug(viewmenu);
673#endif //KAB_EMBEDDED 674#endif //KAB_EMBEDDED
674 675
675 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, 676 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0,
676 this, SLOT( deleteView() ), 677 this, SLOT( deleteView() ),
677 mCore->actionCollection(), "view_delete" ); 678 mCore->actionCollection(), "view_delete" );
678#ifndef KAB_EMBEDDED 679#ifndef KAB_EMBEDDED
679 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); 680 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) );
680#else //KAB_EMBEDDED 681#else //KAB_EMBEDDED
681 mActionDeleteView->plug(viewmenu); 682 mActionDeleteView->plug(viewmenu);
682 viewmenu->insertSeparator(); 683 viewmenu->insertSeparator();
683#endif //KAB_EMBEDDED 684#endif //KAB_EMBEDDED
684 685
685#ifndef KAB_EMBEDDED 686#ifndef KAB_EMBEDDED
686 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 687 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
687 SLOT( refreshView(const QString &) ), mCore->actionCollection(), 688 SLOT( refreshView(const QString &) ), mCore->actionCollection(),
688 "view_refresh" ); 689 "view_refresh" );
689 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); 690 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) );
690#else //KAB_EMBEDDED 691#else //KAB_EMBEDDED
691 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 692 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
692 SLOT( refreshView()), mCore->actionCollection(), 693 SLOT( refreshView()), mCore->actionCollection(),
693 "view_refresh" ); 694 "view_refresh" );
694 action->plug(viewmenu); 695 action->plug(viewmenu);
695 viewmenu->insertSeparator(); 696 viewmenu->insertSeparator();
696#endif //KAB_EMBEDDED 697#endif //KAB_EMBEDDED
697 698
698 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, 699 action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this,
699 SLOT( configureFilters() ), mCore->actionCollection(), 700 SLOT( configureFilters() ), mCore->actionCollection(),
700 "options_edit_filters" ); 701 "options_edit_filters" );
701 702
702 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); 703 mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" );
703#if KDE_VERSION >= 309 704#if KDE_VERSION >= 309
704 mActionSelectFilter->setMenuAccelsEnabled( false ); 705 mActionSelectFilter->setMenuAccelsEnabled( false );
705#endif 706#endif
706 connect( mActionSelectFilter, SIGNAL( activated( int ) ), 707 connect( mActionSelectFilter, SIGNAL( activated( int ) ),
707 SLOT( setActiveFilter( int ) ) ); 708 SLOT( setActiveFilter( int ) ) );
708 709
709#ifdef KAB_EMBEDDED 710#ifdef KAB_EMBEDDED
710 action->plug(settingsmenu); 711 action->plug(settingsmenu);
711 mActionSelectFilter->plug(viewmenu); 712 mActionSelectFilter->plug(viewmenu);
712#endif //KAB_EMBEDDED 713#endif //KAB_EMBEDDED
713 714
714} 715}
715 716
716void ViewManager::initGUI() 717void ViewManager::initGUI()
717{ 718{
718 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); 719 QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 );
719 mViewWidgetStack = new QWidgetStack( this ); 720 mViewWidgetStack = new QWidgetStack( this );
720 layout->addWidget( mViewWidgetStack ); 721 layout->addWidget( mViewWidgetStack );
721} 722}
722 723
723#ifndef KAB_EMBEDDED 724#ifndef KAB_EMBEDDED
724#include "viewmanager.moc" 725#include "viewmanager.moc"
725#endif //KAB_EMBEDDED 726#endif //KAB_EMBEDDED