-rw-r--r-- | kaddressbook/details/detailsviewcontainer.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/details/detailsviewcontainer.h | 1 | ||||
-rw-r--r-- | kaddressbook/details/look_basic.h | 2 | ||||
-rw-r--r-- | kaddressbook/details/look_html.cpp | 10 | ||||
-rw-r--r-- | kaddressbook/details/look_html.h | 8 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 21 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 1 | ||||
-rw-r--r-- | kaddressbook/kaddressbookview.h | 9 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/mainembedded.cpp | 3 | ||||
-rw-r--r-- | kaddressbook/viewmanager.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 27 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 29 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/xxportmanager.cpp | 2 |
17 files changed, 107 insertions, 18 deletions
diff --git a/kaddressbook/details/detailsviewcontainer.cpp b/kaddressbook/details/detailsviewcontainer.cpp index 229cce0..cee5886 100644 --- a/kaddressbook/details/detailsviewcontainer.cpp +++ b/kaddressbook/details/detailsviewcontainer.cpp | |||
@@ -1,160 +1,164 @@ | |||
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 | ||
45 | ViewContainer::ViewContainer( QWidget *parent, const char* name ) | 45 | ViewContainer::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 | ||
81 | void ViewContainer::printView() | ||
82 | { | ||
83 | mCurrentLook->printView(); | ||
84 | } | ||
81 | KABBasicLook *ViewContainer::currentLook() | 85 | KABBasicLook *ViewContainer::currentLook() |
82 | { | 86 | { |
83 | return mCurrentLook; | 87 | return mCurrentLook; |
84 | } | 88 | } |
85 | 89 | ||
86 | void ViewContainer::registerLooks() | 90 | void ViewContainer::registerLooks() |
87 | { | 91 | { |
88 | mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) ); | 92 | mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) ); |
89 | // mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) ); | 93 | // mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) ); |
90 | mStyleCombo->clear(); | 94 | mStyleCombo->clear(); |
91 | 95 | ||
92 | for ( uint i = 0; i < mLookFactories.count(); ++i ) | 96 | for ( uint i = 0; i < mLookFactories.count(); ++i ) |
93 | mStyleCombo->insertItem( mLookFactories.at( i )->description() ); | 97 | mStyleCombo->insertItem( mLookFactories.at( i )->description() ); |
94 | 98 | ||
95 | if ( !mLookFactories.isEmpty() ) | 99 | if ( !mLookFactories.isEmpty() ) |
96 | slotStyleSelected( 0 ); | 100 | slotStyleSelected( 0 ); |
97 | } | 101 | } |
98 | 102 | ||
99 | void ViewContainer::slotStyleSelected( int index ) | 103 | void ViewContainer::slotStyleSelected( int index ) |
100 | { | 104 | { |
101 | #ifndef KAB_EMBEDDED | 105 | #ifndef KAB_EMBEDDED |
102 | KConfig *config = kapp->config(); | 106 | KConfig *config = kapp->config(); |
103 | #else //KAB_EMBEDDED | 107 | #else //KAB_EMBEDDED |
104 | //US I hope I got the same config object as above expected. | 108 | //US I hope I got the same config object as above expected. |
105 | KConfig *config = KABPrefs::instance()->getConfig(); | 109 | KConfig *config = KABPrefs::instance()->getConfig(); |
106 | #endif //KAB_EMBEDDED | 110 | #endif //KAB_EMBEDDED |
107 | KABC::Addressee addr; | 111 | KABC::Addressee addr; |
108 | 112 | ||
109 | if ( index >= 0 && index < mStyleCombo->count() ) { | 113 | if ( index >= 0 && index < mStyleCombo->count() ) { |
110 | if ( mCurrentLook != 0 ) { | 114 | if ( mCurrentLook != 0 ) { |
111 | mCurrentLook->saveSettings( config ); | 115 | mCurrentLook->saveSettings( config ); |
112 | addr = mCurrentLook->addressee(); | 116 | addr = mCurrentLook->addressee(); |
113 | 117 | ||
114 | delete mCurrentLook; | 118 | delete mCurrentLook; |
115 | mCurrentLook = 0; | 119 | mCurrentLook = 0; |
116 | } | 120 | } |
117 | 121 | ||
118 | KABLookFactory *factory = mLookFactories.at( index ); | 122 | KABLookFactory *factory = mLookFactories.at( index ); |
119 | 123 | ||
120 | mCurrentLook = factory->create(); | 124 | mCurrentLook = factory->create(); |
121 | mDetailsStack->raiseWidget( mCurrentLook ); | 125 | mDetailsStack->raiseWidget( mCurrentLook ); |
122 | 126 | ||
123 | connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this, | 127 | connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this, |
124 | SIGNAL( sendEmail( const QString& ) ) ); | 128 | SIGNAL( sendEmail( const QString& ) ) ); |
125 | connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this, | 129 | connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this, |
126 | SIGNAL( browse( const QString& ) ) ); | 130 | SIGNAL( browse( const QString& ) ) ); |
127 | } | 131 | } |
128 | 132 | ||
129 | mCurrentLook->restoreSettings( config ); | 133 | mCurrentLook->restoreSettings( config ); |
130 | mCurrentLook->setAddressee( addr ); | 134 | mCurrentLook->setAddressee( addr ); |
131 | } | 135 | } |
132 | 136 | ||
133 | void ViewContainer::setAddressee( const KABC::Addressee& addressee ) | 137 | void ViewContainer::setAddressee( const KABC::Addressee& addressee ) |
134 | { | 138 | { |
135 | if ( mCurrentLook != 0 ) { | 139 | if ( mCurrentLook != 0 ) { |
136 | mCurrentAddressee = addressee; | 140 | mCurrentAddressee = addressee; |
137 | mCurrentLook->setAddressee( mCurrentAddressee ); | 141 | mCurrentLook->setAddressee( mCurrentAddressee ); |
138 | 142 | ||
139 | } | 143 | } |
140 | } | 144 | } |
141 | 145 | ||
142 | KABC::Addressee ViewContainer::addressee() | 146 | KABC::Addressee ViewContainer::addressee() |
143 | { | 147 | { |
144 | static KABC::Addressee empty; // do not use! | 148 | static KABC::Addressee empty; // do not use! |
145 | 149 | ||
146 | if ( !mCurrentLook ) | 150 | if ( !mCurrentLook ) |
147 | return empty; | 151 | return empty; |
148 | else | 152 | else |
149 | return mCurrentLook->addressee(); | 153 | return mCurrentLook->addressee(); |
150 | } | 154 | } |
151 | 155 | ||
152 | void ViewContainer::setReadOnly( bool state ) | 156 | void ViewContainer::setReadOnly( bool state ) |
153 | { | 157 | { |
154 | if ( mCurrentLook ) | 158 | if ( mCurrentLook ) |
155 | mCurrentLook->setReadOnly( state ); | 159 | mCurrentLook->setReadOnly( state ); |
156 | } | 160 | } |
157 | 161 | ||
158 | #ifndef KAB_EMBEDDED | 162 | #ifndef KAB_EMBEDDED |
159 | #include "detailsviewcontainer.moc" | 163 | #include "detailsviewcontainer.moc" |
160 | #endif //KAB_EMBEDDED | 164 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/details/detailsviewcontainer.h b/kaddressbook/details/detailsviewcontainer.h index 667f0cb..9684736 100644 --- a/kaddressbook/details/detailsviewcontainer.h +++ b/kaddressbook/details/detailsviewcontainer.h | |||
@@ -1,102 +1,103 @@ | |||
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 | ||
31 | class QComboBox; | 31 | class QComboBox; |
32 | class QWidgetStack; | 32 | class QWidgetStack; |
33 | 33 | ||
34 | class ViewContainer : public QWidget | 34 | class 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 | /** | 48 | /** |
49 | Return the contact currently displayed. | 49 | Return the contact currently displayed. |
50 | */ | 50 | */ |
51 | KABC::Addressee addressee(); | 51 | KABC::Addressee addressee(); |
52 | 52 | ||
53 | public slots: | 53 | public slots: |
54 | void printView(); | ||
54 | /** | 55 | /** |
55 | Set the contact currently displayed. | 56 | Set the contact currently displayed. |
56 | */ | 57 | */ |
57 | void setAddressee( const KABC::Addressee& addressee ); | 58 | void setAddressee( const KABC::Addressee& addressee ); |
58 | 59 | ||
59 | /** | 60 | /** |
60 | Set read-write state. | 61 | Set read-write state. |
61 | */ | 62 | */ |
62 | void setReadOnly( bool state ); | 63 | void setReadOnly( bool state ); |
63 | 64 | ||
64 | signals: | 65 | signals: |
65 | /** | 66 | /** |
66 | The contact has been changed. | 67 | The contact has been changed. |
67 | */ | 68 | */ |
68 | void addresseeChanged(); | 69 | void addresseeChanged(); |
69 | 70 | ||
70 | /** | 71 | /** |
71 | The user acticated the email address displayed. This may happen | 72 | The user acticated the email address displayed. This may happen |
72 | by, for example, clicking on the displayed mailto-URL. | 73 | by, for example, clicking on the displayed mailto-URL. |
73 | */ | 74 | */ |
74 | void sendEmail( const QString& ); | 75 | void sendEmail( const QString& ); |
75 | 76 | ||
76 | /** | 77 | /** |
77 | The user activated one of the displayed HTTP URLs. For example | 78 | The user activated one of the displayed HTTP URLs. For example |
78 | by clicking on the displayed homepage address. | 79 | by clicking on the displayed homepage address. |
79 | */ | 80 | */ |
80 | void browse( const QString& ); | 81 | void browse( const QString& ); |
81 | 82 | ||
82 | protected: | 83 | protected: |
83 | /** | 84 | /** |
84 | A style has been selected. Overloaded from base class. | 85 | A style has been selected. Overloaded from base class. |
85 | */ | 86 | */ |
86 | void slotStyleSelected( int ); | 87 | void slotStyleSelected( int ); |
87 | 88 | ||
88 | /** | 89 | /** |
89 | Register the available looks. | 90 | Register the available looks. |
90 | */ | 91 | */ |
91 | void registerLooks(); | 92 | void registerLooks(); |
92 | 93 | ||
93 | private: | 94 | private: |
94 | KABC::Addressee mCurrentAddressee; | 95 | KABC::Addressee mCurrentAddressee; |
95 | KABBasicLook *mCurrentLook; | 96 | KABBasicLook *mCurrentLook; |
96 | QPtrList<KABLookFactory> mLookFactories; | 97 | QPtrList<KABLookFactory> mLookFactories; |
97 | 98 | ||
98 | QComboBox *mStyleCombo; | 99 | QComboBox *mStyleCombo; |
99 | QWidgetStack *mDetailsStack; | 100 | QWidgetStack *mDetailsStack; |
100 | }; | 101 | }; |
101 | 102 | ||
102 | #endif | 103 | #endif |
diff --git a/kaddressbook/details/look_basic.h b/kaddressbook/details/look_basic.h index 7e8baff..a65c99c 100644 --- a/kaddressbook/details/look_basic.h +++ b/kaddressbook/details/look_basic.h | |||
@@ -1,134 +1,136 @@ | |||
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 LOOK_KABBASIC_H | 24 | #ifndef LOOK_KABBASIC_H |
25 | #define LOOK_KABBASIC_H | 25 | #define LOOK_KABBASIC_H |
26 | 26 | ||
27 | #include <kabc/addressbook.h> | 27 | #include <kabc/addressbook.h> |
28 | #include <qvbox.h> | 28 | #include <qvbox.h> |
29 | 29 | ||
30 | class KConfig; | 30 | class KConfig; |
31 | 31 | ||
32 | /** | 32 | /** |
33 | This is a pure virtual base class that defines the | 33 | This is a pure virtual base class that defines the |
34 | interface for how to display and change entries of | 34 | interface for how to display and change entries of |
35 | the KDE addressbook. | 35 | the KDE addressbook. |
36 | 36 | ||
37 | This basic widget does not show anything in its client space. | 37 | This basic widget does not show anything in its client space. |
38 | Derive it and implement its look and how the user may edit the | 38 | Derive it and implement its look and how the user may edit the |
39 | entry. | 39 | entry. |
40 | 40 | ||
41 | The paintEvent() has to paint the whole widget, since repaint() | 41 | The paintEvent() has to paint the whole widget, since repaint() |
42 | calls will not delete the widgets background. | 42 | calls will not delete the widgets background. |
43 | */ | 43 | */ |
44 | class KABBasicLook : public QVBox | 44 | class KABBasicLook : public QVBox |
45 | { | 45 | { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | 47 | ||
48 | public: | 48 | public: |
49 | /** | 49 | /** |
50 | The constructor. | 50 | The constructor. |
51 | */ | 51 | */ |
52 | KABBasicLook( QWidget *parent = 0, const char *name = 0 ); | 52 | KABBasicLook( QWidget *parent = 0, const char *name = 0 ); |
53 | 53 | ||
54 | /** | 54 | /** |
55 | Set the entry. It will be displayed automatically. | 55 | Set the entry. It will be displayed automatically. |
56 | */ | 56 | */ |
57 | virtual void setAddressee( const KABC::Addressee& addressee ); | 57 | virtual void setAddressee( const KABC::Addressee& addressee ); |
58 | 58 | ||
59 | /** | 59 | /** |
60 | Get the current entry. | 60 | Get the current entry. |
61 | */ | 61 | */ |
62 | virtual KABC::Addressee addressee(); | 62 | virtual KABC::Addressee addressee(); |
63 | 63 | ||
64 | /** | 64 | /** |
65 | Configure the view from the configuration file. | 65 | Configure the view from the configuration file. |
66 | */ | 66 | */ |
67 | virtual void restoreSettings( KConfig* ); | 67 | virtual void restoreSettings( KConfig* ); |
68 | 68 | ||
69 | /** | 69 | /** |
70 | Save the view settings to the configuration file. | 70 | Save the view settings to the configuration file. |
71 | */ | 71 | */ |
72 | virtual void saveSettings( KConfig* ); | 72 | virtual void saveSettings( KConfig* ); |
73 | 73 | ||
74 | /** | 74 | /** |
75 | Retrieve read-write state. | 75 | Retrieve read-write state. |
76 | */ | 76 | */ |
77 | bool isReadOnly() const; | 77 | bool isReadOnly() const; |
78 | void printView(){ emit printMyView();} | ||
78 | 79 | ||
79 | signals: | 80 | signals: |
81 | void printMyView(); | ||
80 | /** | 82 | /** |
81 | This signal is emitted when the user changed the entry. | 83 | This signal is emitted when the user changed the entry. |
82 | */ | 84 | */ |
83 | void entryChanged(); | 85 | void entryChanged(); |
84 | 86 | ||
85 | /** | 87 | /** |
86 | This signal indicates that the entry needs to be changed | 88 | This signal indicates that the entry needs to be changed |
87 | immidiately in the database. This might be due to changes in | 89 | immidiately in the database. This might be due to changes in |
88 | values that are available in menus. | 90 | values that are available in menus. |
89 | */ | 91 | */ |
90 | void saveMe(); | 92 | void saveMe(); |
91 | 93 | ||
92 | /** | 94 | /** |
93 | The user acticated the email address displayed. This may happen | 95 | The user acticated the email address displayed. This may happen |
94 | by, for example, clicking on the displayed mailto-URL. | 96 | by, for example, clicking on the displayed mailto-URL. |
95 | */ | 97 | */ |
96 | void sendEmail( const QString &email ); | 98 | void sendEmail( const QString &email ); |
97 | 99 | ||
98 | /** | 100 | /** |
99 | The user activated one of the displayed HTTP URLs. For example | 101 | The user activated one of the displayed HTTP URLs. For example |
100 | by clicking on the displayed homepage address. | 102 | by clicking on the displayed homepage address. |
101 | */ | 103 | */ |
102 | void browse( const QString &url ); | 104 | void browse( const QString &url ); |
103 | 105 | ||
104 | public slots: | 106 | public slots: |
105 | /** | 107 | /** |
106 | Set read-write state. | 108 | Set read-write state. |
107 | */ | 109 | */ |
108 | virtual void setReadOnly( bool state ); | 110 | virtual void setReadOnly( bool state ); |
109 | 111 | ||
110 | private: | 112 | private: |
111 | KABC::Addressee mAddressee; | 113 | KABC::Addressee mAddressee; |
112 | bool mReadOnly; | 114 | bool mReadOnly; |
113 | }; | 115 | }; |
114 | 116 | ||
115 | class KABLookFactory | 117 | class KABLookFactory |
116 | { | 118 | { |
117 | public: | 119 | public: |
118 | KABLookFactory( QWidget *parent = 0, const char *name = 0 ); | 120 | KABLookFactory( QWidget *parent = 0, const char *name = 0 ); |
119 | virtual ~KABLookFactory(); | 121 | virtual ~KABLookFactory(); |
120 | 122 | ||
121 | virtual KABBasicLook *create() = 0; | 123 | virtual KABBasicLook *create() = 0; |
122 | 124 | ||
123 | /** | 125 | /** |
124 | Overload this method to provide a one-liner description | 126 | Overload this method to provide a one-liner description |
125 | for your look. | 127 | for your look. |
126 | */ | 128 | */ |
127 | virtual QString description() = 0; | 129 | virtual QString description() = 0; |
128 | 130 | ||
129 | protected: | 131 | protected: |
130 | QWidget *mParent; | 132 | QWidget *mParent; |
131 | const char* mName; | 133 | const char* mName; |
132 | }; | 134 | }; |
133 | 135 | ||
134 | #endif | 136 | #endif |
diff --git a/kaddressbook/details/look_html.cpp b/kaddressbook/details/look_html.cpp index 64987b8..bb30650 100644 --- a/kaddressbook/details/look_html.cpp +++ b/kaddressbook/details/look_html.cpp | |||
@@ -1,48 +1,56 @@ | |||
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 <addresseeview.h> | 24 | #include <addresseeview.h> |
25 | 25 | ||
26 | #include "look_html.h" | 26 | #include "look_html.h" |
27 | #include <qscrollview.h> | 27 | #include <qscrollview.h> |
28 | #include "kabprefs.h" | 28 | #include "kabprefs.h" |
29 | #include <kabc/addresseeview.h> | ||
29 | KABHtmlView::KABHtmlView( QWidget *parent, const char *name ) | 30 | KABHtmlView::KABHtmlView( QWidget *parent, const char *name ) |
30 | : KABBasicLook( parent, name ) | 31 | : KABBasicLook( parent, name ) |
31 | { | 32 | { |
32 | mView = new KPIM::AddresseeView( this ); | 33 | mView = new KABC::AddresseeView( this ); |
33 | mView->setFont( KABPrefs::instance()->mDetailsFont ); | 34 | mView->setFont( KABPrefs::instance()->mDetailsFont ); |
35 | connect(this, SIGNAL(printMyView()), | ||
36 | this , SLOT(printMe())); | ||
34 | } | 37 | } |
35 | 38 | ||
36 | KABHtmlView::~KABHtmlView() | 39 | KABHtmlView::~KABHtmlView() |
37 | { | 40 | { |
38 | } | 41 | } |
42 | void KABHtmlView::printMe() | ||
43 | { | ||
44 | mView->printMe(); | ||
45 | |||
46 | } | ||
39 | 47 | ||
40 | void KABHtmlView::setAddressee( const KABC::Addressee &addr ) | 48 | void KABHtmlView::setAddressee( const KABC::Addressee &addr ) |
41 | { | 49 | { |
42 | mView->setFont( KABPrefs::instance()->mDetailsFont ); | 50 | mView->setFont( KABPrefs::instance()->mDetailsFont ); |
43 | mView->setAddressee( addr ); | 51 | mView->setAddressee( addr ); |
44 | } | 52 | } |
45 | 53 | ||
46 | #ifndef KAB_EMBEDDED | 54 | #ifndef KAB_EMBEDDED |
47 | #include "look_html.moc" | 55 | #include "look_html.moc" |
48 | #endif //KAB_EMBEDDED | 56 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/details/look_html.h b/kaddressbook/details/look_html.h index 68a02d9..57eb56f 100644 --- a/kaddressbook/details/look_html.h +++ b/kaddressbook/details/look_html.h | |||
@@ -1,75 +1,77 @@ | |||
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 LOOK_HTML_H | 24 | #ifndef LOOK_HTML_H |
25 | #define LOOK_HTML_H | 25 | #define LOOK_HTML_H |
26 | 26 | ||
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | #include "look_basic.h" | 29 | #include "look_basic.h" |
30 | 30 | ||
31 | namespace KABC { class Addressee; } | 31 | namespace KABC { class Addressee; } |
32 | namespace KPIM { class AddresseeView; } | 32 | namespace KABC { class AddresseeView; } |
33 | 33 | ||
34 | class KABHtmlView : public KABBasicLook | 34 | class KABHtmlView : public KABBasicLook |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | 37 | ||
38 | public: | 38 | public: |
39 | /** | 39 | /** |
40 | The constructor. | 40 | The constructor. |
41 | */ | 41 | */ |
42 | KABHtmlView( QWidget *parent = 0, const char* name = 0 ); | 42 | KABHtmlView( QWidget *parent = 0, const char* name = 0 ); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | The virtual destructor. | 45 | The virtual destructor. |
46 | */ | 46 | */ |
47 | virtual ~KABHtmlView(); | 47 | virtual ~KABHtmlView(); |
48 | 48 | ||
49 | /** | 49 | /** |
50 | Set the addressee. | 50 | Set the addressee. |
51 | */ | 51 | */ |
52 | void setAddressee( const KABC::Addressee& ); | 52 | void setAddressee( const KABC::Addressee& ); |
53 | public slots: | ||
54 | void printMe(); | ||
53 | 55 | ||
54 | private: | 56 | private: |
55 | KPIM::AddresseeView *mView; | 57 | KABC::AddresseeView *mView; |
56 | }; | 58 | }; |
57 | 59 | ||
58 | class KABHtmlViewFactory : public KABLookFactory | 60 | class KABHtmlViewFactory : public KABLookFactory |
59 | { | 61 | { |
60 | public: | 62 | public: |
61 | KABHtmlViewFactory( QWidget *parent = 0, const char *name = 0 ) | 63 | KABHtmlViewFactory( QWidget *parent = 0, const char *name = 0 ) |
62 | : KABLookFactory( parent, name ) {} | 64 | : KABLookFactory( parent, name ) {} |
63 | 65 | ||
64 | KABBasicLook *create() | 66 | KABBasicLook *create() |
65 | { | 67 | { |
66 | return new KABHtmlView( mParent, mName ); | 68 | return new KABHtmlView( mParent, mName ); |
67 | } | 69 | } |
68 | 70 | ||
69 | QString description() | 71 | QString description() |
70 | { | 72 | { |
71 | return i18n( "HTML table style." ); | 73 | return i18n( "HTML table style." ); |
72 | } | 74 | } |
73 | }; | 75 | }; |
74 | 76 | ||
75 | #endif | 77 | #endif |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 4098dda..e61f65f 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,3266 +1,3265 @@ | |||
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 |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #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 "nameeditdialog.h" | 154 | #include "nameeditdialog.h" |
155 | #include <kcmultidialog.h> | 155 | #include <kcmultidialog.h> |
156 | 156 | ||
157 | #ifdef _WIN32_ | 157 | #ifdef _WIN32_ |
158 | 158 | ||
159 | #include "kaimportoldialog.h" | 159 | #include "kaimportoldialog.h" |
160 | #else | 160 | #else |
161 | #include <unistd.h> | 161 | #include <unistd.h> |
162 | #endif | 162 | #endif |
163 | // sync includes | 163 | // sync includes |
164 | #include <libkdepim/ksyncprofile.h> | 164 | #include <libkdepim/ksyncprofile.h> |
165 | #include <libkdepim/ksyncprefsdialog.h> | 165 | #include <libkdepim/ksyncprefsdialog.h> |
166 | 166 | ||
167 | 167 | ||
168 | class KABCatPrefs : public QDialog | 168 | class KABCatPrefs : public QDialog |
169 | { | 169 | { |
170 | public: | 170 | public: |
171 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : | 171 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : |
172 | QDialog( parent, name, true ) | 172 | QDialog( parent, name, true ) |
173 | { | 173 | { |
174 | setCaption( i18n("Manage new Categories") ); | 174 | setCaption( i18n("Manage new Categories") ); |
175 | QVBoxLayout* lay = new QVBoxLayout( this ); | 175 | QVBoxLayout* lay = new QVBoxLayout( this ); |
176 | lay->setSpacing( 3 ); | 176 | lay->setSpacing( 3 ); |
177 | lay->setMargin( 3 ); | 177 | lay->setMargin( 3 ); |
178 | 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 | 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 ); |
179 | lay->addWidget( lab ); | 179 | lay->addWidget( lab ); |
180 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 180 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
181 | lay->addWidget( format ); | 181 | lay->addWidget( format ); |
182 | format->setExclusive ( true ) ; | 182 | format->setExclusive ( true ) ; |
183 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 183 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
184 | new QRadioButton(i18n("Remove from addressees"), format ); | 184 | new QRadioButton(i18n("Remove from addressees"), format ); |
185 | addCatBut->setChecked( true ); | 185 | addCatBut->setChecked( true ); |
186 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 186 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
187 | lay->addWidget( ok ); | 187 | lay->addWidget( ok ); |
188 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 188 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
189 | lay->addWidget( cancel ); | 189 | lay->addWidget( cancel ); |
190 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 190 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
191 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 191 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
192 | resize( 200, 200 ); | 192 | resize( 200, 200 ); |
193 | } | 193 | } |
194 | 194 | ||
195 | bool addCat() { return addCatBut->isChecked(); } | 195 | bool addCat() { return addCatBut->isChecked(); } |
196 | private: | 196 | private: |
197 | QRadioButton* addCatBut; | 197 | QRadioButton* addCatBut; |
198 | }; | 198 | }; |
199 | 199 | ||
200 | class KABFormatPrefs : public QDialog | 200 | class KABFormatPrefs : public QDialog |
201 | { | 201 | { |
202 | public: | 202 | public: |
203 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : | 203 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : |
204 | QDialog( parent, name, true ) | 204 | QDialog( parent, name, true ) |
205 | { | 205 | { |
206 | setCaption( i18n("Set formatted name") ); | 206 | setCaption( i18n("Set formatted name") ); |
207 | QVBoxLayout* lay = new QVBoxLayout( this ); | 207 | QVBoxLayout* lay = new QVBoxLayout( this ); |
208 | lay->setSpacing( 3 ); | 208 | lay->setSpacing( 3 ); |
209 | lay->setMargin( 3 ); | 209 | lay->setMargin( 3 ); |
210 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); | 210 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); |
211 | lay->addWidget( lab ); | 211 | lay->addWidget( lab ); |
212 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); | 212 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); |
213 | lay->addWidget( format ); | 213 | lay->addWidget( format ); |
214 | format->setExclusive ( true ) ; | 214 | format->setExclusive ( true ) ; |
215 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); | 215 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); |
216 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); | 216 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); |
217 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); | 217 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); |
218 | company = new QRadioButton(i18n("Organization: MI6"), format ); | 218 | company = new QRadioButton(i18n("Organization: MI6"), format ); |
219 | simple->setChecked( true ); | 219 | simple->setChecked( true ); |
220 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); | 220 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); |
221 | lay->addWidget( setCompany ); | 221 | lay->addWidget( setCompany ); |
222 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); | 222 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); |
223 | lay->addWidget( ok ); | 223 | lay->addWidget( ok ); |
224 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 224 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
225 | lay->addWidget( cancel ); | 225 | lay->addWidget( cancel ); |
226 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 226 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
227 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 227 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
228 | resize( 200, 200 ); | 228 | resize( 200, 200 ); |
229 | } | 229 | } |
230 | public: | 230 | public: |
231 | QRadioButton* simple, *full, *reverse, *company; | 231 | QRadioButton* simple, *full, *reverse, *company; |
232 | QCheckBox* setCompany; | 232 | QCheckBox* setCompany; |
233 | }; | 233 | }; |
234 | 234 | ||
235 | 235 | ||
236 | 236 | ||
237 | class KAex2phonePrefs : public QDialog | 237 | class KAex2phonePrefs : public QDialog |
238 | { | 238 | { |
239 | public: | 239 | public: |
240 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 240 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
241 | QDialog( parent, name, true ) | 241 | QDialog( parent, name, true ) |
242 | { | 242 | { |
243 | setCaption( i18n("Export to phone options") ); | 243 | setCaption( i18n("Export to phone options") ); |
244 | QVBoxLayout* lay = new QVBoxLayout( this ); | 244 | QVBoxLayout* lay = new QVBoxLayout( this ); |
245 | lay->setSpacing( 3 ); | 245 | lay->setSpacing( 3 ); |
246 | lay->setMargin( 3 ); | 246 | lay->setMargin( 3 ); |
247 | QLabel *lab; | 247 | QLabel *lab; |
248 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 248 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
249 | lab->setAlignment (AlignHCenter ); | 249 | lab->setAlignment (AlignHCenter ); |
250 | QHBox* temphb; | 250 | QHBox* temphb; |
251 | temphb = new QHBox( this ); | 251 | temphb = new QHBox( this ); |
252 | new QLabel( i18n("I/O device: "), temphb ); | 252 | new QLabel( i18n("I/O device: "), temphb ); |
253 | mPhoneDevice = new QLineEdit( temphb); | 253 | mPhoneDevice = new QLineEdit( temphb); |
254 | lay->addWidget( temphb ); | 254 | lay->addWidget( temphb ); |
255 | temphb = new QHBox( this ); | 255 | temphb = new QHBox( this ); |
256 | new QLabel( i18n("Connection: "), temphb ); | 256 | new QLabel( i18n("Connection: "), temphb ); |
257 | mPhoneConnection = new QLineEdit( temphb); | 257 | mPhoneConnection = new QLineEdit( temphb); |
258 | lay->addWidget( temphb ); | 258 | lay->addWidget( temphb ); |
259 | temphb = new QHBox( this ); | 259 | temphb = new QHBox( this ); |
260 | new QLabel( i18n("Model(opt.): "), temphb ); | 260 | new QLabel( i18n("Model(opt.): "), temphb ); |
261 | mPhoneModel = new QLineEdit( temphb); | 261 | mPhoneModel = new QLineEdit( temphb); |
262 | lay->addWidget( temphb ); | 262 | lay->addWidget( temphb ); |
263 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 263 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
264 | // lay->addWidget( mWriteToSim ); | 264 | // lay->addWidget( mWriteToSim ); |
265 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 265 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
266 | lab->setAlignment (AlignHCenter ); | 266 | lab->setAlignment (AlignHCenter ); |
267 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 267 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
268 | lay->addWidget( ok ); | 268 | lay->addWidget( ok ); |
269 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 269 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
270 | lay->addWidget( cancel ); | 270 | lay->addWidget( cancel ); |
271 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 271 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
272 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 272 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
273 | resize( 220, 240 ); | 273 | resize( 220, 240 ); |
274 | 274 | ||
275 | } | 275 | } |
276 | 276 | ||
277 | public: | 277 | public: |
278 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 278 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
279 | QCheckBox* mWriteToSim; | 279 | QCheckBox* mWriteToSim; |
280 | }; | 280 | }; |
281 | 281 | ||
282 | 282 | ||
283 | bool pasteWithNewUid = true; | 283 | bool pasteWithNewUid = true; |
284 | 284 | ||
285 | #ifdef KAB_EMBEDDED | 285 | #ifdef KAB_EMBEDDED |
286 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 286 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
287 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 287 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
288 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 288 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
289 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 289 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
290 | #else //KAB_EMBEDDED | 290 | #else //KAB_EMBEDDED |
291 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 291 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
292 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 292 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
293 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 293 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
294 | mReadWrite( readWrite ), mModified( false ) | 294 | mReadWrite( readWrite ), mModified( false ) |
295 | #endif //KAB_EMBEDDED | 295 | #endif //KAB_EMBEDDED |
296 | { | 296 | { |
297 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 297 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
298 | // syncManager->setBlockSave(false); | 298 | // syncManager->setBlockSave(false); |
299 | mMiniSplitter = 0; | 299 | mMiniSplitter = 0; |
300 | mExtensionBarSplitter = 0; | 300 | mExtensionBarSplitter = 0; |
301 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 301 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
302 | mAddressBook = KABC::StdAddressBook::self(); | 302 | mAddressBook = KABC::StdAddressBook::self(); |
303 | KABC::StdAddressBook::setAutomaticSave( false ); | 303 | KABC::StdAddressBook::setAutomaticSave( false ); |
304 | 304 | ||
305 | #ifndef KAB_EMBEDDED | 305 | #ifndef KAB_EMBEDDED |
306 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 306 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
307 | #endif //KAB_EMBEDDED | 307 | #endif //KAB_EMBEDDED |
308 | 308 | ||
309 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 309 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
310 | SLOT( addressBookChanged() ) ); | 310 | SLOT( addressBookChanged() ) ); |
311 | 311 | ||
312 | #if 0 | 312 | #if 0 |
313 | // LP moved to addressbook init method | 313 | // LP moved to addressbook init method |
314 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 314 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
315 | "X-Department", "KADDRESSBOOK" ); | 315 | "X-Department", "KADDRESSBOOK" ); |
316 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 316 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
317 | "X-Profession", "KADDRESSBOOK" ); | 317 | "X-Profession", "KADDRESSBOOK" ); |
318 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 318 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
319 | "X-AssistantsName", "KADDRESSBOOK" ); | 319 | "X-AssistantsName", "KADDRESSBOOK" ); |
320 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 320 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
321 | "X-ManagersName", "KADDRESSBOOK" ); | 321 | "X-ManagersName", "KADDRESSBOOK" ); |
322 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 322 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
323 | "X-SpousesName", "KADDRESSBOOK" ); | 323 | "X-SpousesName", "KADDRESSBOOK" ); |
324 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 324 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
325 | "X-Office", "KADDRESSBOOK" ); | 325 | "X-Office", "KADDRESSBOOK" ); |
326 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 326 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
327 | "X-IMAddress", "KADDRESSBOOK" ); | 327 | "X-IMAddress", "KADDRESSBOOK" ); |
328 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 328 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
329 | "X-Anniversary", "KADDRESSBOOK" ); | 329 | "X-Anniversary", "KADDRESSBOOK" ); |
330 | 330 | ||
331 | //US added this field to become compatible with Opie/qtopia addressbook | 331 | //US added this field to become compatible with Opie/qtopia addressbook |
332 | // values can be "female" or "male" or "". An empty field represents undefined. | 332 | // values can be "female" or "male" or "". An empty field represents undefined. |
333 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 333 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
334 | "X-Gender", "KADDRESSBOOK" ); | 334 | "X-Gender", "KADDRESSBOOK" ); |
335 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 335 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
336 | "X-Children", "KADDRESSBOOK" ); | 336 | "X-Children", "KADDRESSBOOK" ); |
337 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 337 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
338 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 338 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
339 | #endif | 339 | #endif |
340 | initGUI(); | 340 | initGUI(); |
341 | 341 | ||
342 | mIncSearchWidget->setFocus(); | 342 | mIncSearchWidget->setFocus(); |
343 | 343 | ||
344 | 344 | ||
345 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 345 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
346 | SLOT( setContactSelected( const QString& ) ) ); | 346 | SLOT( setContactSelected( const QString& ) ) ); |
347 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 347 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
348 | SLOT( executeContact( const QString& ) ) ); | 348 | SLOT( executeContact( const QString& ) ) ); |
349 | 349 | ||
350 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 350 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
351 | SLOT( deleteContacts( ) ) ); | 351 | SLOT( deleteContacts( ) ) ); |
352 | connect( mViewManager, SIGNAL( modified() ), | 352 | connect( mViewManager, SIGNAL( modified() ), |
353 | SLOT( setModified() ) ); | 353 | SLOT( setModified() ) ); |
354 | 354 | ||
355 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 355 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
356 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 356 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
357 | 357 | ||
358 | connect( mXXPortManager, SIGNAL( modified() ), | 358 | connect( mXXPortManager, SIGNAL( modified() ), |
359 | SLOT( setModified() ) ); | 359 | SLOT( setModified() ) ); |
360 | 360 | ||
361 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 361 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
362 | SLOT( incrementalSearch( const QString& ) ) ); | 362 | SLOT( incrementalSearch( const QString& ) ) ); |
363 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 363 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
364 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 364 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
365 | 365 | ||
366 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 366 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
367 | SLOT( sendMail( const QString& ) ) ); | 367 | SLOT( sendMail( const QString& ) ) ); |
368 | 368 | ||
369 | 369 | ||
370 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 370 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
371 | 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&))); | 371 | 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&))); |
372 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 372 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
373 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); | 373 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); |
374 | 374 | ||
375 | 375 | ||
376 | #ifndef KAB_EMBEDDED | 376 | #ifndef KAB_EMBEDDED |
377 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 377 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
378 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 378 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
379 | 379 | ||
380 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 380 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
381 | SLOT( browse( const QString& ) ) ); | 381 | SLOT( browse( const QString& ) ) ); |
382 | 382 | ||
383 | 383 | ||
384 | mAddressBookService = new KAddressBookService( this ); | 384 | mAddressBookService = new KAddressBookService( this ); |
385 | 385 | ||
386 | #endif //KAB_EMBEDDED | 386 | #endif //KAB_EMBEDDED |
387 | 387 | ||
388 | mMessageTimer = new QTimer( this ); | 388 | mMessageTimer = new QTimer( this ); |
389 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 389 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
390 | mEditorDialog = 0; | 390 | mEditorDialog = 0; |
391 | createAddresseeEditorDialog( this ); | 391 | createAddresseeEditorDialog( this ); |
392 | setModified( false ); | 392 | setModified( false ); |
393 | mBRdisabled = false; | 393 | mBRdisabled = false; |
394 | #ifndef DESKTOP_VERSION | 394 | #ifndef DESKTOP_VERSION |
395 | infrared = 0; | 395 | infrared = 0; |
396 | #endif | 396 | #endif |
397 | //toggleBeamReceive( ); | 397 | //toggleBeamReceive( ); |
398 | //mMainWindow->toolBar()->show(); | 398 | //mMainWindow->toolBar()->show(); |
399 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi | 399 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi |
400 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 400 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
401 | } | 401 | } |
402 | 402 | ||
403 | void KABCore::updateToolBar() | 403 | void KABCore::updateToolBar() |
404 | { | 404 | { |
405 | static int iii = 0; | 405 | static int iii = 0; |
406 | ++iii; | 406 | ++iii; |
407 | mMainWindow->toolBar()->repaintMe(); | 407 | mMainWindow->toolBar()->repaintMe(); |
408 | if ( iii < 5 ) | 408 | if ( iii < 5 ) |
409 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 409 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
410 | } | 410 | } |
411 | KABCore::~KABCore() | 411 | KABCore::~KABCore() |
412 | { | 412 | { |
413 | // save(); | 413 | // save(); |
414 | //saveSettings(); | 414 | //saveSettings(); |
415 | //KABPrefs::instance()->writeConfig(); | 415 | //KABPrefs::instance()->writeConfig(); |
416 | delete AddresseeConfig::instance(); | 416 | delete AddresseeConfig::instance(); |
417 | mAddressBook = 0; | 417 | mAddressBook = 0; |
418 | KABC::StdAddressBook::close(); | 418 | KABC::StdAddressBook::close(); |
419 | 419 | ||
420 | delete syncManager; | 420 | delete syncManager; |
421 | #ifndef DESKTOP_VERSION | 421 | #ifndef DESKTOP_VERSION |
422 | if ( infrared ) | 422 | if ( infrared ) |
423 | delete infrared; | 423 | delete infrared; |
424 | #endif | 424 | #endif |
425 | } | 425 | } |
426 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 426 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
427 | { | 427 | { |
428 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 428 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
429 | if ( cmsg == "setDocument(QString)" ) { | 429 | if ( cmsg == "setDocument(QString)" ) { |
430 | QDataStream stream( data, IO_ReadOnly ); | 430 | QDataStream stream( data, IO_ReadOnly ); |
431 | QString fileName; | 431 | QString fileName; |
432 | stream >> fileName; | 432 | stream >> fileName; |
433 | recieve( fileName ); | 433 | recieve( fileName ); |
434 | return; | 434 | return; |
435 | } | 435 | } |
436 | } | 436 | } |
437 | void KABCore::toggleBeamReceive( ) | 437 | void KABCore::toggleBeamReceive( ) |
438 | { | 438 | { |
439 | if ( mBRdisabled ) | 439 | if ( mBRdisabled ) |
440 | return; | 440 | return; |
441 | #ifndef DESKTOP_VERSION | 441 | #ifndef DESKTOP_VERSION |
442 | if ( infrared ) { | 442 | if ( infrared ) { |
443 | qDebug("AB disable BeamReceive "); | 443 | qDebug("AB disable BeamReceive "); |
444 | delete infrared; | 444 | delete infrared; |
445 | infrared = 0; | 445 | infrared = 0; |
446 | mActionBR->setChecked(false); | 446 | mActionBR->setChecked(false); |
447 | return; | 447 | return; |
448 | } | 448 | } |
449 | qDebug("AB enable BeamReceive "); | 449 | qDebug("AB enable BeamReceive "); |
450 | mActionBR->setChecked(true); | 450 | mActionBR->setChecked(true); |
451 | 451 | ||
452 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 452 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
453 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 453 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
454 | #endif | 454 | #endif |
455 | } | 455 | } |
456 | 456 | ||
457 | 457 | ||
458 | void KABCore::disableBR(bool b) | 458 | void KABCore::disableBR(bool b) |
459 | { | 459 | { |
460 | #ifndef DESKTOP_VERSION | 460 | #ifndef DESKTOP_VERSION |
461 | if ( b ) { | 461 | if ( b ) { |
462 | if ( infrared ) { | 462 | if ( infrared ) { |
463 | toggleBeamReceive( ); | 463 | toggleBeamReceive( ); |
464 | } | 464 | } |
465 | mBRdisabled = true; | 465 | mBRdisabled = true; |
466 | } else { | 466 | } else { |
467 | if ( mBRdisabled ) { | 467 | if ( mBRdisabled ) { |
468 | mBRdisabled = false; | 468 | mBRdisabled = false; |
469 | //toggleBeamReceive( ); | 469 | //toggleBeamReceive( ); |
470 | } | 470 | } |
471 | } | 471 | } |
472 | #endif | 472 | #endif |
473 | 473 | ||
474 | } | 474 | } |
475 | void KABCore::recieve( QString fn ) | 475 | void KABCore::recieve( QString fn ) |
476 | { | 476 | { |
477 | //qDebug("KABCore::recieve "); | 477 | //qDebug("KABCore::recieve "); |
478 | int count = mAddressBook->importFromFile( fn, true ); | 478 | int count = mAddressBook->importFromFile( fn, true ); |
479 | if ( count ) | 479 | if ( count ) |
480 | setModified( true ); | 480 | setModified( true ); |
481 | mViewManager->refreshView(); | 481 | mViewManager->refreshView(); |
482 | message(i18n("%1 contact(s) received!").arg( count )); | 482 | message(i18n("%1 contact(s) received!").arg( count )); |
483 | topLevelWidget()->showMaximized(); | 483 | topLevelWidget()->showMaximized(); |
484 | topLevelWidget()->raise(); | 484 | topLevelWidget()->raise(); |
485 | } | 485 | } |
486 | void KABCore::restoreSettings() | 486 | void KABCore::restoreSettings() |
487 | { | 487 | { |
488 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 488 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
489 | 489 | ||
490 | bool state; | 490 | bool state; |
491 | 491 | ||
492 | if (mMultipleViewsAtOnce) | 492 | if (mMultipleViewsAtOnce) |
493 | state = KABPrefs::instance()->mDetailsPageVisible; | 493 | state = KABPrefs::instance()->mDetailsPageVisible; |
494 | else | 494 | else |
495 | state = false; | 495 | state = false; |
496 | 496 | ||
497 | mActionDetails->setChecked( state ); | 497 | mActionDetails->setChecked( state ); |
498 | setDetailsVisible( state ); | 498 | setDetailsVisible( state ); |
499 | 499 | ||
500 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 500 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
501 | 501 | ||
502 | mActionJumpBar->setChecked( state ); | 502 | mActionJumpBar->setChecked( state ); |
503 | setJumpButtonBarVisible( state ); | 503 | setJumpButtonBarVisible( state ); |
504 | /*US | 504 | /*US |
505 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 505 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
506 | if ( splitterSize.count() == 0 ) { | 506 | if ( splitterSize.count() == 0 ) { |
507 | splitterSize.append( width() / 2 ); | 507 | splitterSize.append( width() / 2 ); |
508 | splitterSize.append( width() / 2 ); | 508 | splitterSize.append( width() / 2 ); |
509 | } | 509 | } |
510 | mMiniSplitter->setSizes( splitterSize ); | 510 | mMiniSplitter->setSizes( splitterSize ); |
511 | if ( mExtensionBarSplitter ) { | 511 | if ( mExtensionBarSplitter ) { |
512 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 512 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
513 | if ( splitterSize.count() == 0 ) { | 513 | if ( splitterSize.count() == 0 ) { |
514 | splitterSize.append( width() / 2 ); | 514 | splitterSize.append( width() / 2 ); |
515 | splitterSize.append( width() / 2 ); | 515 | splitterSize.append( width() / 2 ); |
516 | } | 516 | } |
517 | mExtensionBarSplitter->setSizes( splitterSize ); | 517 | mExtensionBarSplitter->setSizes( splitterSize ); |
518 | 518 | ||
519 | } | 519 | } |
520 | */ | 520 | */ |
521 | mViewManager->restoreSettings(); | 521 | mViewManager->restoreSettings(); |
522 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 522 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
523 | mExtensionManager->restoreSettings(); | 523 | mExtensionManager->restoreSettings(); |
524 | #ifdef DESKTOP_VERSION | 524 | #ifdef DESKTOP_VERSION |
525 | int wid = width(); | 525 | int wid = width(); |
526 | if ( wid < 10 ) | 526 | if ( wid < 10 ) |
527 | wid = 400; | 527 | wid = 400; |
528 | #else | 528 | #else |
529 | int wid = QApplication::desktop()->width(); | 529 | int wid = QApplication::desktop()->width(); |
530 | if ( wid < 640 ) | 530 | if ( wid < 640 ) |
531 | wid = QApplication::desktop()->height(); | 531 | wid = QApplication::desktop()->height(); |
532 | #endif | 532 | #endif |
533 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 533 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
534 | if ( true /*splitterSize.count() == 0*/ ) { | 534 | if ( true /*splitterSize.count() == 0*/ ) { |
535 | splitterSize.append( wid / 2 ); | 535 | splitterSize.append( wid / 2 ); |
536 | splitterSize.append( wid / 2 ); | 536 | splitterSize.append( wid / 2 ); |
537 | } | 537 | } |
538 | mMiniSplitter->setSizes( splitterSize ); | 538 | mMiniSplitter->setSizes( splitterSize ); |
539 | if ( mExtensionBarSplitter ) { | 539 | if ( mExtensionBarSplitter ) { |
540 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 540 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
541 | if ( true /*splitterSize.count() == 0*/ ) { | 541 | if ( true /*splitterSize.count() == 0*/ ) { |
542 | splitterSize.append( wid / 2 ); | 542 | splitterSize.append( wid / 2 ); |
543 | splitterSize.append( wid / 2 ); | 543 | splitterSize.append( wid / 2 ); |
544 | } | 544 | } |
545 | mExtensionBarSplitter->setSizes( splitterSize ); | 545 | mExtensionBarSplitter->setSizes( splitterSize ); |
546 | 546 | ||
547 | } | 547 | } |
548 | 548 | ||
549 | 549 | ||
550 | } | 550 | } |
551 | 551 | ||
552 | void KABCore::saveSettings() | 552 | void KABCore::saveSettings() |
553 | { | 553 | { |
554 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 554 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
555 | if ( mExtensionBarSplitter ) | 555 | if ( mExtensionBarSplitter ) |
556 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 556 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
557 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 557 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
558 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 558 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
559 | #ifndef KAB_EMBEDDED | 559 | #ifndef KAB_EMBEDDED |
560 | 560 | ||
561 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 561 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
562 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 562 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
563 | #endif //KAB_EMBEDDED | 563 | #endif //KAB_EMBEDDED |
564 | mExtensionManager->saveSettings(); | 564 | mExtensionManager->saveSettings(); |
565 | mViewManager->saveSettings(); | 565 | mViewManager->saveSettings(); |
566 | 566 | ||
567 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 567 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
568 | } | 568 | } |
569 | 569 | ||
570 | KABC::AddressBook *KABCore::addressBook() const | 570 | KABC::AddressBook *KABCore::addressBook() const |
571 | { | 571 | { |
572 | return mAddressBook; | 572 | return mAddressBook; |
573 | } | 573 | } |
574 | 574 | ||
575 | KConfig *KABCore::config() | 575 | KConfig *KABCore::config() |
576 | { | 576 | { |
577 | #ifndef KAB_EMBEDDED | 577 | #ifndef KAB_EMBEDDED |
578 | return KABPrefs::instance()->config(); | 578 | return KABPrefs::instance()->config(); |
579 | #else //KAB_EMBEDDED | 579 | #else //KAB_EMBEDDED |
580 | return KABPrefs::instance()->getConfig(); | 580 | return KABPrefs::instance()->getConfig(); |
581 | #endif //KAB_EMBEDDED | 581 | #endif //KAB_EMBEDDED |
582 | } | 582 | } |
583 | 583 | ||
584 | KActionCollection *KABCore::actionCollection() const | 584 | KActionCollection *KABCore::actionCollection() const |
585 | { | 585 | { |
586 | return mGUIClient->actionCollection(); | 586 | return mGUIClient->actionCollection(); |
587 | } | 587 | } |
588 | 588 | ||
589 | KABC::Field *KABCore::currentSearchField() const | 589 | KABC::Field *KABCore::currentSearchField() const |
590 | { | 590 | { |
591 | if (mIncSearchWidget) | 591 | if (mIncSearchWidget) |
592 | return mIncSearchWidget->currentField(); | 592 | return mIncSearchWidget->currentField(); |
593 | else | 593 | else |
594 | return 0; | 594 | return 0; |
595 | } | 595 | } |
596 | 596 | ||
597 | QStringList KABCore::selectedUIDs() const | 597 | QStringList KABCore::selectedUIDs() const |
598 | { | 598 | { |
599 | return mViewManager->selectedUids(); | 599 | return mViewManager->selectedUids(); |
600 | } | 600 | } |
601 | 601 | ||
602 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 602 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
603 | { | 603 | { |
604 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 604 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
605 | 605 | ||
606 | QPtrList<KRES::Resource> kresResources; | 606 | QPtrList<KRES::Resource> kresResources; |
607 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 607 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
608 | KABC::Resource *resource; | 608 | KABC::Resource *resource; |
609 | while ( ( resource = resIt.current() ) != 0 ) { | 609 | while ( ( resource = resIt.current() ) != 0 ) { |
610 | ++resIt; | 610 | ++resIt; |
611 | if ( !resource->readOnly() ) { | 611 | if ( !resource->readOnly() ) { |
612 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 612 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
613 | if ( res ) | 613 | if ( res ) |
614 | kresResources.append( res ); | 614 | kresResources.append( res ); |
615 | } | 615 | } |
616 | } | 616 | } |
617 | 617 | ||
618 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 618 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
619 | return static_cast<KABC::Resource*>( res ); | 619 | return static_cast<KABC::Resource*>( res ); |
620 | } | 620 | } |
621 | 621 | ||
622 | #ifndef KAB_EMBEDDED | 622 | #ifndef KAB_EMBEDDED |
623 | KAboutData *KABCore::createAboutData() | 623 | KAboutData *KABCore::createAboutData() |
624 | #else //KAB_EMBEDDED | 624 | #else //KAB_EMBEDDED |
625 | void KABCore::createAboutData() | 625 | void KABCore::createAboutData() |
626 | #endif //KAB_EMBEDDED | 626 | #endif //KAB_EMBEDDED |
627 | { | 627 | { |
628 | #ifndef KAB_EMBEDDED | 628 | #ifndef KAB_EMBEDDED |
629 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 629 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
630 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 630 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
631 | KAboutData::License_GPL_V2, | 631 | KAboutData::License_GPL_V2, |
632 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 632 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
633 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 633 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
634 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 634 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
635 | about->addAuthor( "Cornelius Schumacher", | 635 | about->addAuthor( "Cornelius Schumacher", |
636 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 636 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
637 | "schumacher@kde.org" ); | 637 | "schumacher@kde.org" ); |
638 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 638 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
639 | "mpilone@slac.com" ); | 639 | "mpilone@slac.com" ); |
640 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 640 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
641 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 641 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
642 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 642 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
643 | "michel@klaralvdalens-datakonsult.se" ); | 643 | "michel@klaralvdalens-datakonsult.se" ); |
644 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 644 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
645 | "hansen@kde.org" ); | 645 | "hansen@kde.org" ); |
646 | 646 | ||
647 | return about; | 647 | return about; |
648 | #endif //KAB_EMBEDDED | 648 | #endif //KAB_EMBEDDED |
649 | 649 | ||
650 | QString version; | 650 | QString version; |
651 | #include <../version> | 651 | #include <../version> |
652 | QMessageBox::about( this, "About KAddressbook/Pi", | 652 | QMessageBox::about( this, "About KAddressbook/Pi", |
653 | "KAddressbook/Platform-independent\n" | 653 | "KAddressbook/Platform-independent\n" |
654 | "(KA/Pi) " +version + " - " + | 654 | "(KA/Pi) " +version + " - " + |
655 | #ifdef DESKTOP_VERSION | 655 | #ifdef DESKTOP_VERSION |
656 | "Desktop Edition\n" | 656 | "Desktop Edition\n" |
657 | #else | 657 | #else |
658 | "PDA-Edition\n" | 658 | "PDA-Edition\n" |
659 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 659 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
660 | #endif | 660 | #endif |
661 | 661 | ||
662 | "(c) 2004 Ulf Schenk\n" | 662 | "(c) 2004 Ulf Schenk\n" |
663 | "(c) 2004 Lutz Rogowski\n" | 663 | "(c) 2004 Lutz Rogowski\n" |
664 | "(c) 1997-2003, The KDE PIM Team\n" | 664 | "(c) 1997-2003, The KDE PIM Team\n" |
665 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 665 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
666 | "Don Sanders Original author\n" | 666 | "Don Sanders Original author\n" |
667 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 667 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
668 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 668 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
669 | "Greg Stern DCOP interface\n" | 669 | "Greg Stern DCOP interface\n" |
670 | "Mark Westcot Contact pinning\n" | 670 | "Mark Westcot Contact pinning\n" |
671 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 671 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
672 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 672 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
673 | #ifdef _WIN32_ | 673 | #ifdef _WIN32_ |
674 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 674 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
675 | #endif | 675 | #endif |
676 | ); | 676 | ); |
677 | } | 677 | } |
678 | 678 | ||
679 | void KABCore::setContactSelected( const QString &uid ) | 679 | void KABCore::setContactSelected( const QString &uid ) |
680 | { | 680 | { |
681 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 681 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
682 | if ( !mDetails->isHidden() ) | 682 | if ( !mDetails->isHidden() ) |
683 | mDetails->setAddressee( addr ); | 683 | mDetails->setAddressee( addr ); |
684 | 684 | ||
685 | if ( !addr.isEmpty() ) { | 685 | if ( !addr.isEmpty() ) { |
686 | emit contactSelected( addr.formattedName() ); | 686 | emit contactSelected( addr.formattedName() ); |
687 | KABC::Picture pic = addr.photo(); | 687 | KABC::Picture pic = addr.photo(); |
688 | if ( pic.isIntern() ) { | 688 | if ( pic.isIntern() ) { |
689 | //US emit contactSelected( pic.data() ); | 689 | //US emit contactSelected( pic.data() ); |
690 | //US instead use: | 690 | //US instead use: |
691 | QPixmap px; | 691 | QPixmap px; |
692 | if (pic.data().isNull() != true) | 692 | if (pic.data().isNull() != true) |
693 | { | 693 | { |
694 | px.convertFromImage(pic.data()); | 694 | px.convertFromImage(pic.data()); |
695 | } | 695 | } |
696 | 696 | ||
697 | emit contactSelected( px ); | 697 | emit contactSelected( px ); |
698 | } | 698 | } |
699 | } | 699 | } |
700 | 700 | ||
701 | 701 | ||
702 | mExtensionManager->setSelectionChanged(); | 702 | mExtensionManager->setSelectionChanged(); |
703 | 703 | ||
704 | // update the actions | 704 | // update the actions |
705 | bool selected = !uid.isEmpty(); | 705 | bool selected = !uid.isEmpty(); |
706 | 706 | ||
707 | if ( mReadWrite ) { | 707 | if ( mReadWrite ) { |
708 | mActionCut->setEnabled( selected ); | 708 | mActionCut->setEnabled( selected ); |
709 | mActionPaste->setEnabled( selected ); | 709 | mActionPaste->setEnabled( selected ); |
710 | } | 710 | } |
711 | 711 | ||
712 | mActionCopy->setEnabled( selected ); | 712 | mActionCopy->setEnabled( selected ); |
713 | mActionDelete->setEnabled( selected ); | 713 | mActionDelete->setEnabled( selected ); |
714 | mActionEditAddressee->setEnabled( selected ); | 714 | mActionEditAddressee->setEnabled( selected ); |
715 | mActionMail->setEnabled( selected ); | 715 | mActionMail->setEnabled( selected ); |
716 | mActionMailVCard->setEnabled( selected ); | 716 | mActionMailVCard->setEnabled( selected ); |
717 | //if (mActionBeam) | 717 | //if (mActionBeam) |
718 | //mActionBeam->setEnabled( selected ); | 718 | //mActionBeam->setEnabled( selected ); |
719 | mActionWhoAmI->setEnabled( selected ); | 719 | mActionWhoAmI->setEnabled( selected ); |
720 | } | 720 | } |
721 | 721 | ||
722 | void KABCore::sendMail() | 722 | void KABCore::sendMail() |
723 | { | 723 | { |
724 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 724 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
725 | } | 725 | } |
726 | 726 | ||
727 | void KABCore::sendMail( const QString& emaillist ) | 727 | void KABCore::sendMail( const QString& emaillist ) |
728 | { | 728 | { |
729 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 729 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
730 | if (emaillist.contains(",") > 0) | 730 | if (emaillist.contains(",") > 0) |
731 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 731 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
732 | else | 732 | else |
733 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 733 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
734 | } | 734 | } |
735 | 735 | ||
736 | 736 | ||
737 | 737 | ||
738 | void KABCore::mailVCard() | 738 | void KABCore::mailVCard() |
739 | { | 739 | { |
740 | QStringList uids = mViewManager->selectedUids(); | 740 | QStringList uids = mViewManager->selectedUids(); |
741 | if ( !uids.isEmpty() ) | 741 | if ( !uids.isEmpty() ) |
742 | mailVCard( uids ); | 742 | mailVCard( uids ); |
743 | } | 743 | } |
744 | 744 | ||
745 | void KABCore::mailVCard( const QStringList& uids ) | 745 | void KABCore::mailVCard( const QStringList& uids ) |
746 | { | 746 | { |
747 | QStringList urls; | 747 | QStringList urls; |
748 | 748 | ||
749 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 749 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
750 | 750 | ||
751 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 751 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
752 | 752 | ||
753 | 753 | ||
754 | 754 | ||
755 | QDir().mkdir( dirName, true ); | 755 | QDir().mkdir( dirName, true ); |
756 | 756 | ||
757 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 757 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
758 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 758 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
759 | 759 | ||
760 | if ( a.isEmpty() ) | 760 | if ( a.isEmpty() ) |
761 | continue; | 761 | continue; |
762 | 762 | ||
763 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 763 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
764 | 764 | ||
765 | QString fileName = dirName + "/" + name; | 765 | QString fileName = dirName + "/" + name; |
766 | 766 | ||
767 | QFile outFile(fileName); | 767 | QFile outFile(fileName); |
768 | 768 | ||
769 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 769 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
770 | KABC::VCardConverter converter; | 770 | KABC::VCardConverter converter; |
771 | QString vcard; | 771 | QString vcard; |
772 | 772 | ||
773 | converter.addresseeToVCard( a, vcard ); | 773 | converter.addresseeToVCard( a, vcard ); |
774 | 774 | ||
775 | QTextStream t( &outFile ); // use a text stream | 775 | QTextStream t( &outFile ); // use a text stream |
776 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 776 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
777 | t << vcard; | 777 | t << vcard; |
778 | 778 | ||
779 | outFile.close(); | 779 | outFile.close(); |
780 | 780 | ||
781 | urls.append( fileName ); | 781 | urls.append( fileName ); |
782 | } | 782 | } |
783 | } | 783 | } |
784 | 784 | ||
785 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 785 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
786 | 786 | ||
787 | 787 | ||
788 | /*US | 788 | /*US |
789 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 789 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
790 | QString::null, // subject | 790 | QString::null, // subject |
791 | QString::null, // body | 791 | QString::null, // body |
792 | QString::null, | 792 | QString::null, |
793 | urls ); // attachments | 793 | urls ); // attachments |
794 | */ | 794 | */ |
795 | 795 | ||
796 | } | 796 | } |
797 | 797 | ||
798 | /** | 798 | /** |
799 | Beams the "WhoAmI contact. | 799 | Beams the "WhoAmI contact. |
800 | */ | 800 | */ |
801 | void KABCore::beamMySelf() | 801 | void KABCore::beamMySelf() |
802 | { | 802 | { |
803 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 803 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
804 | if (!a.isEmpty()) | 804 | if (!a.isEmpty()) |
805 | { | 805 | { |
806 | QStringList uids; | 806 | QStringList uids; |
807 | uids << a.uid(); | 807 | uids << a.uid(); |
808 | 808 | ||
809 | beamVCard(uids); | 809 | beamVCard(uids); |
810 | } else { | 810 | } else { |
811 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 811 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
812 | 812 | ||
813 | 813 | ||
814 | } | 814 | } |
815 | } | 815 | } |
816 | void KABCore::updateMainWindow() | 816 | void KABCore::updateMainWindow() |
817 | { | 817 | { |
818 | 818 | ||
819 | mMainWindow->showMaximized(); | 819 | mMainWindow->showMaximized(); |
820 | mMainWindow->update(); | 820 | mMainWindow->update(); |
821 | } | 821 | } |
822 | void KABCore::resizeEvent(QResizeEvent* e ) | 822 | void KABCore::resizeEvent(QResizeEvent* e ) |
823 | { | 823 | { |
824 | if ( !mMiniSplitter ) | 824 | if ( !mMiniSplitter ) |
825 | return; | 825 | return; |
826 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); | 826 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); |
827 | if ( QApplication::desktop()->width() >= 480 ) { | 827 | if ( QApplication::desktop()->width() >= 480 ) { |
828 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 828 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
829 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 829 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
830 | mMiniSplitter->setOrientation( Qt::Horizontal); | 830 | mMiniSplitter->setOrientation( Qt::Horizontal); |
831 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 831 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
832 | if ( QApplication::desktop()->width() <= 640 ) { | 832 | if ( QApplication::desktop()->width() <= 640 ) { |
833 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 833 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
834 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 834 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
835 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 835 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
836 | } | 836 | } |
837 | } | 837 | } |
838 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 838 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
839 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 839 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
840 | mMiniSplitter->setOrientation( Qt::Vertical ); | 840 | mMiniSplitter->setOrientation( Qt::Vertical ); |
841 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 841 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
842 | if ( QApplication::desktop()->width() <= 640 ) { | 842 | if ( QApplication::desktop()->width() <= 640 ) { |
843 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 843 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
844 | mMainWindow->showMinimized(); | 844 | mMainWindow->showMinimized(); |
845 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 845 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
846 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 846 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
847 | } | 847 | } |
848 | } | 848 | } |
849 | } | 849 | } |
850 | } | 850 | } |
851 | 851 | ||
852 | } | 852 | } |
853 | void KABCore::export2phone() | 853 | void KABCore::export2phone() |
854 | { | 854 | { |
855 | 855 | ||
856 | QStringList uids; | 856 | QStringList uids; |
857 | XXPortSelectDialog dlg( this, false, this ); | 857 | XXPortSelectDialog dlg( this, false, this ); |
858 | if ( dlg.exec() ) | 858 | if ( dlg.exec() ) |
859 | uids = dlg.uids(); | 859 | uids = dlg.uids(); |
860 | else | 860 | else |
861 | return; | 861 | return; |
862 | if ( uids.isEmpty() ) | 862 | if ( uids.isEmpty() ) |
863 | return; | 863 | return; |
864 | // qDebug("count %d ", uids.count()); | 864 | // qDebug("count %d ", uids.count()); |
865 | 865 | ||
866 | KAex2phonePrefs ex2phone; | 866 | KAex2phonePrefs ex2phone; |
867 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 867 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
868 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 868 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
869 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 869 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
870 | 870 | ||
871 | if ( !ex2phone.exec() ) { | 871 | if ( !ex2phone.exec() ) { |
872 | return; | 872 | return; |
873 | } | 873 | } |
874 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 874 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
875 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 875 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
876 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 876 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
877 | 877 | ||
878 | 878 | ||
879 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 879 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
880 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 880 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
881 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 881 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
882 | 882 | ||
883 | QString fileName = getPhoneFile(); | 883 | QString fileName = getPhoneFile(); |
884 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 884 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
885 | return; | 885 | return; |
886 | 886 | ||
887 | message(i18n("Exporting to phone...")); | 887 | message(i18n("Exporting to phone...")); |
888 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 888 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
889 | 889 | ||
890 | } | 890 | } |
891 | QString KABCore::getPhoneFile() | 891 | QString KABCore::getPhoneFile() |
892 | { | 892 | { |
893 | #ifdef DESKTOP_VERSION | 893 | #ifdef DESKTOP_VERSION |
894 | return locateLocal("tmp", "phonefile.vcf"); | 894 | return locateLocal("tmp", "phonefile.vcf"); |
895 | #else | 895 | #else |
896 | return "/tmp/phonefile.vcf"; | 896 | return "/tmp/phonefile.vcf"; |
897 | #endif | 897 | #endif |
898 | 898 | ||
899 | } | 899 | } |
900 | void KABCore::writeToPhone( ) | 900 | void KABCore::writeToPhone( ) |
901 | { | 901 | { |
902 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 902 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
903 | message(i18n("Export to phone finished!")); | 903 | message(i18n("Export to phone finished!")); |
904 | else | 904 | else |
905 | qDebug(i18n("Error exporting to phone")); | 905 | qDebug(i18n("Error exporting to phone")); |
906 | } | 906 | } |
907 | void KABCore::beamVCard() | 907 | void KABCore::beamVCard() |
908 | { | 908 | { |
909 | QStringList uids; | 909 | QStringList uids; |
910 | XXPortSelectDialog dlg( this, false, this ); | 910 | XXPortSelectDialog dlg( this, false, this ); |
911 | if ( dlg.exec() ) | 911 | if ( dlg.exec() ) |
912 | uids = dlg.uids(); | 912 | uids = dlg.uids(); |
913 | else | 913 | else |
914 | return; | 914 | return; |
915 | if ( uids.isEmpty() ) | 915 | if ( uids.isEmpty() ) |
916 | return; | 916 | return; |
917 | beamVCard( uids ); | 917 | beamVCard( uids ); |
918 | } | 918 | } |
919 | 919 | ||
920 | 920 | ||
921 | void KABCore::beamVCard(const QStringList& uids) | 921 | void KABCore::beamVCard(const QStringList& uids) |
922 | { | 922 | { |
923 | 923 | ||
924 | // LR: we should use the /tmp dir on the Zaurus, | 924 | // LR: we should use the /tmp dir on the Zaurus, |
925 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 925 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
926 | 926 | ||
927 | #ifdef DESKTOP_VERSION | 927 | #ifdef DESKTOP_VERSION |
928 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 928 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
929 | #else | 929 | #else |
930 | QString fileName = "/tmp/kapibeamfile.vcf"; | 930 | QString fileName = "/tmp/kapibeamfile.vcf"; |
931 | #endif | 931 | #endif |
932 | 932 | ||
933 | KABC::VCardConverter converter; | 933 | KABC::VCardConverter converter; |
934 | QString description; | 934 | QString description; |
935 | QString datastream; | 935 | QString datastream; |
936 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 936 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
937 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 937 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
938 | 938 | ||
939 | if ( a.isEmpty() ) | 939 | if ( a.isEmpty() ) |
940 | continue; | 940 | continue; |
941 | 941 | ||
942 | if (description.isEmpty()) | 942 | if (description.isEmpty()) |
943 | description = a.formattedName(); | 943 | description = a.formattedName(); |
944 | 944 | ||
945 | QString vcard; | 945 | QString vcard; |
946 | converter.addresseeToVCard( a, vcard ); | 946 | converter.addresseeToVCard( a, vcard ); |
947 | int start = 0; | 947 | int start = 0; |
948 | int next; | 948 | int next; |
949 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 949 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
950 | int semi = vcard.find(";", next); | 950 | int semi = vcard.find(";", next); |
951 | int dopp = vcard.find(":", next); | 951 | int dopp = vcard.find(":", next); |
952 | int sep; | 952 | int sep; |
953 | if ( semi < dopp && semi >= 0 ) | 953 | if ( semi < dopp && semi >= 0 ) |
954 | sep = semi ; | 954 | sep = semi ; |
955 | else | 955 | else |
956 | sep = dopp; | 956 | sep = dopp; |
957 | datastream +=vcard.mid( start, next - start); | 957 | datastream +=vcard.mid( start, next - start); |
958 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 958 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
959 | start = sep; | 959 | start = sep; |
960 | } | 960 | } |
961 | datastream += vcard.mid( start,vcard.length() ); | 961 | datastream += vcard.mid( start,vcard.length() ); |
962 | } | 962 | } |
963 | #ifndef DESKTOP_VERSION | 963 | #ifndef DESKTOP_VERSION |
964 | QFile outFile(fileName); | 964 | QFile outFile(fileName); |
965 | if ( outFile.open(IO_WriteOnly) ) { | 965 | if ( outFile.open(IO_WriteOnly) ) { |
966 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 966 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
967 | QTextStream t( &outFile ); // use a text stream | 967 | QTextStream t( &outFile ); // use a text stream |
968 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 968 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
969 | t.setEncoding( QTextStream::Latin1 ); | 969 | t.setEncoding( QTextStream::Latin1 ); |
970 | t <<datastream.latin1(); | 970 | t <<datastream.latin1(); |
971 | outFile.close(); | 971 | outFile.close(); |
972 | Ir *ir = new Ir( this ); | 972 | Ir *ir = new Ir( this ); |
973 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 973 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
974 | ir->send( fileName, description, "text/x-vCard" ); | 974 | ir->send( fileName, description, "text/x-vCard" ); |
975 | } else { | 975 | } else { |
976 | qDebug("Error open temp beam file "); | 976 | qDebug("Error open temp beam file "); |
977 | return; | 977 | return; |
978 | } | 978 | } |
979 | #endif | 979 | #endif |
980 | 980 | ||
981 | } | 981 | } |
982 | 982 | ||
983 | void KABCore::beamDone( Ir *ir ) | 983 | void KABCore::beamDone( Ir *ir ) |
984 | { | 984 | { |
985 | #ifndef DESKTOP_VERSION | 985 | #ifndef DESKTOP_VERSION |
986 | delete ir; | 986 | delete ir; |
987 | #endif | 987 | #endif |
988 | topLevelWidget()->raise(); | 988 | topLevelWidget()->raise(); |
989 | message( i18n("Beaming finished!") ); | 989 | message( i18n("Beaming finished!") ); |
990 | } | 990 | } |
991 | 991 | ||
992 | 992 | ||
993 | void KABCore::browse( const QString& url ) | 993 | void KABCore::browse( const QString& url ) |
994 | { | 994 | { |
995 | #ifndef KAB_EMBEDDED | 995 | #ifndef KAB_EMBEDDED |
996 | kapp->invokeBrowser( url ); | 996 | kapp->invokeBrowser( url ); |
997 | #else //KAB_EMBEDDED | 997 | #else //KAB_EMBEDDED |
998 | qDebug("KABCore::browse must be fixed"); | 998 | qDebug("KABCore::browse must be fixed"); |
999 | #endif //KAB_EMBEDDED | 999 | #endif //KAB_EMBEDDED |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | void KABCore::selectAllContacts() | 1002 | void KABCore::selectAllContacts() |
1003 | { | 1003 | { |
1004 | mViewManager->setSelected( QString::null, true ); | 1004 | mViewManager->setSelected( QString::null, true ); |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | void KABCore::deleteContacts() | 1007 | void KABCore::deleteContacts() |
1008 | { | 1008 | { |
1009 | QStringList uidList = mViewManager->selectedUids(); | 1009 | QStringList uidList = mViewManager->selectedUids(); |
1010 | deleteContacts( uidList ); | 1010 | deleteContacts( uidList ); |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | void KABCore::deleteContacts( const QStringList &uids ) | 1013 | void KABCore::deleteContacts( const QStringList &uids ) |
1014 | { | 1014 | { |
1015 | if ( uids.count() > 0 ) { | 1015 | if ( uids.count() > 0 ) { |
1016 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 1016 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
1017 | UndoStack::instance()->push( command ); | 1017 | UndoStack::instance()->push( command ); |
1018 | RedoStack::instance()->clear(); | 1018 | RedoStack::instance()->clear(); |
1019 | 1019 | ||
1020 | // now if we deleted anything, refresh | 1020 | // now if we deleted anything, refresh |
1021 | setContactSelected( QString::null ); | 1021 | setContactSelected( QString::null ); |
1022 | setModified( true ); | 1022 | setModified( true ); |
1023 | } | 1023 | } |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | void KABCore::copyContacts() | 1026 | void KABCore::copyContacts() |
1027 | { | 1027 | { |
1028 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1028 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1029 | 1029 | ||
1030 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 1030 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
1031 | 1031 | ||
1032 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 1032 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
1033 | 1033 | ||
1034 | QClipboard *cb = QApplication::clipboard(); | 1034 | QClipboard *cb = QApplication::clipboard(); |
1035 | cb->setText( clipText ); | 1035 | cb->setText( clipText ); |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | void KABCore::cutContacts() | 1038 | void KABCore::cutContacts() |
1039 | { | 1039 | { |
1040 | QStringList uidList = mViewManager->selectedUids(); | 1040 | QStringList uidList = mViewManager->selectedUids(); |
1041 | 1041 | ||
1042 | //US if ( uidList.size() > 0 ) { | 1042 | //US if ( uidList.size() > 0 ) { |
1043 | if ( uidList.count() > 0 ) { | 1043 | if ( uidList.count() > 0 ) { |
1044 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 1044 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
1045 | UndoStack::instance()->push( command ); | 1045 | UndoStack::instance()->push( command ); |
1046 | RedoStack::instance()->clear(); | 1046 | RedoStack::instance()->clear(); |
1047 | 1047 | ||
1048 | setModified( true ); | 1048 | setModified( true ); |
1049 | } | 1049 | } |
1050 | } | 1050 | } |
1051 | 1051 | ||
1052 | void KABCore::pasteContacts() | 1052 | void KABCore::pasteContacts() |
1053 | { | 1053 | { |
1054 | QClipboard *cb = QApplication::clipboard(); | 1054 | QClipboard *cb = QApplication::clipboard(); |
1055 | 1055 | ||
1056 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 1056 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
1057 | 1057 | ||
1058 | pasteContacts( list ); | 1058 | pasteContacts( list ); |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 1061 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
1062 | { | 1062 | { |
1063 | KABC::Resource *resource = requestResource( this ); | 1063 | KABC::Resource *resource = requestResource( this ); |
1064 | KABC::Addressee::List::Iterator it; | 1064 | KABC::Addressee::List::Iterator it; |
1065 | for ( it = list.begin(); it != list.end(); ++it ) | 1065 | for ( it = list.begin(); it != list.end(); ++it ) |
1066 | (*it).setResource( resource ); | 1066 | (*it).setResource( resource ); |
1067 | 1067 | ||
1068 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 1068 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
1069 | UndoStack::instance()->push( command ); | 1069 | UndoStack::instance()->push( command ); |
1070 | RedoStack::instance()->clear(); | 1070 | RedoStack::instance()->clear(); |
1071 | 1071 | ||
1072 | setModified( true ); | 1072 | setModified( true ); |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | void KABCore::setWhoAmI() | 1075 | void KABCore::setWhoAmI() |
1076 | { | 1076 | { |
1077 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1077 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1078 | 1078 | ||
1079 | if ( addrList.count() > 1 ) { | 1079 | if ( addrList.count() > 1 ) { |
1080 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 1080 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
1081 | return; | 1081 | return; |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 1084 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
1085 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 1085 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
1086 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 1086 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
1087 | } | 1087 | } |
1088 | void KABCore::editCategories() | 1088 | void KABCore::editCategories() |
1089 | { | 1089 | { |
1090 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); | 1090 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); |
1091 | dlg.exec(); | 1091 | dlg.exec(); |
1092 | } | 1092 | } |
1093 | void KABCore::setCategories() | 1093 | void KABCore::setCategories() |
1094 | { | 1094 | { |
1095 | 1095 | ||
1096 | QStringList uids; | 1096 | QStringList uids; |
1097 | XXPortSelectDialog dlgx( this, false, this ); | 1097 | XXPortSelectDialog dlgx( this, false, this ); |
1098 | if ( dlgx.exec() ) | 1098 | if ( dlgx.exec() ) |
1099 | uids = dlgx.uids(); | 1099 | uids = dlgx.uids(); |
1100 | else | 1100 | else |
1101 | return; | 1101 | return; |
1102 | if ( uids.isEmpty() ) | 1102 | if ( uids.isEmpty() ) |
1103 | return; | 1103 | return; |
1104 | // qDebug("count %d ", uids.count()); | 1104 | // qDebug("count %d ", uids.count()); |
1105 | 1105 | ||
1106 | 1106 | ||
1107 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 1107 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
1108 | if ( !dlg.exec() ) { | 1108 | if ( !dlg.exec() ) { |
1109 | message( i18n("Setting categories cancelled") ); | 1109 | message( i18n("Setting categories cancelled") ); |
1110 | return; | 1110 | return; |
1111 | } | 1111 | } |
1112 | bool merge = false; | 1112 | bool merge = false; |
1113 | QString msg = i18n( "Merge with existing categories?" ); | 1113 | QString msg = i18n( "Merge with existing categories?" ); |
1114 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 1114 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
1115 | merge = true; | 1115 | merge = true; |
1116 | 1116 | ||
1117 | message( i18n("Setting categories ... please wait!") ); | 1117 | message( i18n("Setting categories ... please wait!") ); |
1118 | QStringList categories = dlg.selectedCategories(); | 1118 | QStringList categories = dlg.selectedCategories(); |
1119 | 1119 | ||
1120 | //QStringList uids = mViewManager->selectedUids(); | 1120 | //QStringList uids = mViewManager->selectedUids(); |
1121 | QStringList::Iterator it; | 1121 | QStringList::Iterator it; |
1122 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1122 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1123 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1123 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1124 | if ( !addr.isEmpty() ) { | 1124 | if ( !addr.isEmpty() ) { |
1125 | if ( !merge ) | 1125 | if ( !merge ) |
1126 | addr.setCategories( categories ); | 1126 | addr.setCategories( categories ); |
1127 | else { | 1127 | else { |
1128 | QStringList addrCategories = addr.categories(); | 1128 | QStringList addrCategories = addr.categories(); |
1129 | QStringList::Iterator catIt; | 1129 | QStringList::Iterator catIt; |
1130 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1130 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1131 | if ( !addrCategories.contains( *catIt ) ) | 1131 | if ( !addrCategories.contains( *catIt ) ) |
1132 | addrCategories.append( *catIt ); | 1132 | addrCategories.append( *catIt ); |
1133 | } | 1133 | } |
1134 | addr.setCategories( addrCategories ); | 1134 | addr.setCategories( addrCategories ); |
1135 | } | 1135 | } |
1136 | mAddressBook->insertAddressee( addr ); | 1136 | mAddressBook->insertAddressee( addr ); |
1137 | } | 1137 | } |
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | if ( uids.count() > 0 ) | 1140 | if ( uids.count() > 0 ) |
1141 | setModified( true ); | 1141 | setModified( true ); |
1142 | message( i18n("Setting categories completed!") ); | 1142 | message( i18n("Setting categories completed!") ); |
1143 | } | 1143 | } |
1144 | 1144 | ||
1145 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1145 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1146 | { | 1146 | { |
1147 | mIncSearchWidget->setFields( fields ); | 1147 | mIncSearchWidget->setFields( fields ); |
1148 | } | 1148 | } |
1149 | 1149 | ||
1150 | void KABCore::incrementalSearch( const QString& text ) | 1150 | void KABCore::incrementalSearch( const QString& text ) |
1151 | { | 1151 | { |
1152 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1152 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | void KABCore::setModified() | 1155 | void KABCore::setModified() |
1156 | { | 1156 | { |
1157 | setModified( true ); | 1157 | setModified( true ); |
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | void KABCore::setModifiedWOrefresh() | 1160 | void KABCore::setModifiedWOrefresh() |
1161 | { | 1161 | { |
1162 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1162 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1163 | mModified = true; | 1163 | mModified = true; |
1164 | mActionSave->setEnabled( mModified ); | 1164 | mActionSave->setEnabled( mModified ); |
1165 | 1165 | ||
1166 | 1166 | ||
1167 | } | 1167 | } |
1168 | void KABCore::setModified( bool modified ) | 1168 | void KABCore::setModified( bool modified ) |
1169 | { | 1169 | { |
1170 | mModified = modified; | 1170 | mModified = modified; |
1171 | mActionSave->setEnabled( mModified ); | 1171 | mActionSave->setEnabled( mModified ); |
1172 | 1172 | ||
1173 | if ( modified ) | 1173 | if ( modified ) |
1174 | mJumpButtonBar->recreateButtons(); | 1174 | mJumpButtonBar->recreateButtons(); |
1175 | 1175 | ||
1176 | mViewManager->refreshView(); | 1176 | mViewManager->refreshView(); |
1177 | 1177 | ||
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | bool KABCore::modified() const | 1180 | bool KABCore::modified() const |
1181 | { | 1181 | { |
1182 | return mModified; | 1182 | return mModified; |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1185 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1186 | { | 1186 | { |
1187 | addrModified( addr ); | 1187 | addrModified( addr ); |
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | 1190 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) |
1191 | { | 1191 | { |
1192 | 1192 | ||
1193 | Command *command = 0; | 1193 | Command *command = 0; |
1194 | QString uid; | 1194 | QString uid; |
1195 | 1195 | ||
1196 | // check if it exists already | 1196 | // check if it exists already |
1197 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1197 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1198 | if ( origAddr.isEmpty() ) | 1198 | if ( origAddr.isEmpty() ) |
1199 | command = new PwNewCommand( mAddressBook, addr ); | 1199 | command = new PwNewCommand( mAddressBook, addr ); |
1200 | else { | 1200 | else { |
1201 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1201 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1202 | uid = addr.uid(); | 1202 | uid = addr.uid(); |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | UndoStack::instance()->push( command ); | 1205 | UndoStack::instance()->push( command ); |
1206 | RedoStack::instance()->clear(); | 1206 | RedoStack::instance()->clear(); |
1207 | if ( updateDetails ) | 1207 | if ( updateDetails ) |
1208 | mDetails->setAddressee( addr ); | 1208 | mDetails->setAddressee( addr ); |
1209 | setModified( true ); | 1209 | setModified( true ); |
1210 | } | 1210 | } |
1211 | 1211 | ||
1212 | void KABCore::newContact() | 1212 | void KABCore::newContact() |
1213 | { | 1213 | { |
1214 | 1214 | ||
1215 | 1215 | ||
1216 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1216 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1217 | 1217 | ||
1218 | QPtrList<KRES::Resource> kresResources; | 1218 | QPtrList<KRES::Resource> kresResources; |
1219 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1219 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1220 | KABC::Resource *resource; | 1220 | KABC::Resource *resource; |
1221 | while ( ( resource = it.current() ) != 0 ) { | 1221 | while ( ( resource = it.current() ) != 0 ) { |
1222 | ++it; | 1222 | ++it; |
1223 | if ( !resource->readOnly() ) { | 1223 | if ( !resource->readOnly() ) { |
1224 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1224 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1225 | if ( res ) | 1225 | if ( res ) |
1226 | kresResources.append( res ); | 1226 | kresResources.append( res ); |
1227 | } | 1227 | } |
1228 | } | 1228 | } |
1229 | 1229 | ||
1230 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1230 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1231 | resource = static_cast<KABC::Resource*>( res ); | 1231 | resource = static_cast<KABC::Resource*>( res ); |
1232 | 1232 | ||
1233 | if ( resource ) { | 1233 | if ( resource ) { |
1234 | KABC::Addressee addr; | 1234 | KABC::Addressee addr; |
1235 | addr.setResource( resource ); | 1235 | addr.setResource( resource ); |
1236 | mEditorDialog->setAddressee( addr ); | 1236 | mEditorDialog->setAddressee( addr ); |
1237 | KApplication::execDialog ( mEditorDialog ); | 1237 | KApplication::execDialog ( mEditorDialog ); |
1238 | 1238 | ||
1239 | } else | 1239 | } else |
1240 | return; | 1240 | return; |
1241 | 1241 | ||
1242 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1242 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1243 | 1243 | ||
1244 | 1244 | ||
1245 | } | 1245 | } |
1246 | 1246 | ||
1247 | void KABCore::addEmail( QString aStr ) | 1247 | void KABCore::addEmail( QString aStr ) |
1248 | { | 1248 | { |
1249 | #ifndef KAB_EMBEDDED | 1249 | #ifndef KAB_EMBEDDED |
1250 | QString fullName, email; | 1250 | QString fullName, email; |
1251 | 1251 | ||
1252 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1252 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1253 | 1253 | ||
1254 | // Try to lookup the addressee matching the email address | 1254 | // Try to lookup the addressee matching the email address |
1255 | bool found = false; | 1255 | bool found = false; |
1256 | QStringList emailList; | 1256 | QStringList emailList; |
1257 | KABC::AddressBook::Iterator it; | 1257 | KABC::AddressBook::Iterator it; |
1258 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1258 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1259 | emailList = (*it).emails(); | 1259 | emailList = (*it).emails(); |
1260 | if ( emailList.contains( email ) > 0 ) { | 1260 | if ( emailList.contains( email ) > 0 ) { |
1261 | found = true; | 1261 | found = true; |
1262 | (*it).setNameFromString( fullName ); | 1262 | (*it).setNameFromString( fullName ); |
1263 | editContact( (*it).uid() ); | 1263 | editContact( (*it).uid() ); |
1264 | } | 1264 | } |
1265 | } | 1265 | } |
1266 | 1266 | ||
1267 | if ( !found ) { | 1267 | if ( !found ) { |
1268 | KABC::Addressee addr; | 1268 | KABC::Addressee addr; |
1269 | addr.setNameFromString( fullName ); | 1269 | addr.setNameFromString( fullName ); |
1270 | addr.insertEmail( email, true ); | 1270 | addr.insertEmail( email, true ); |
1271 | 1271 | ||
1272 | mAddressBook->insertAddressee( addr ); | 1272 | mAddressBook->insertAddressee( addr ); |
1273 | mViewManager->refreshView( addr.uid() ); | 1273 | mViewManager->refreshView( addr.uid() ); |
1274 | editContact( addr.uid() ); | 1274 | editContact( addr.uid() ); |
1275 | } | 1275 | } |
1276 | #else //KAB_EMBEDDED | 1276 | #else //KAB_EMBEDDED |
1277 | qDebug("KABCore::addEmail finsih method"); | 1277 | qDebug("KABCore::addEmail finsih method"); |
1278 | #endif //KAB_EMBEDDED | 1278 | #endif //KAB_EMBEDDED |
1279 | } | 1279 | } |
1280 | 1280 | ||
1281 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1281 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1282 | { | 1282 | { |
1283 | mXXPortManager->importVCard( url, showPreview ); | 1283 | mXXPortManager->importVCard( url, showPreview ); |
1284 | } | 1284 | } |
1285 | void KABCore::importFromOL() | 1285 | void KABCore::importFromOL() |
1286 | { | 1286 | { |
1287 | #ifdef _WIN32_ | 1287 | #ifdef _WIN32_ |
1288 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1288 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1289 | idgl->exec(); | 1289 | idgl->exec(); |
1290 | KABC::Addressee::List list = idgl->getAddressList(); | 1290 | KABC::Addressee::List list = idgl->getAddressList(); |
1291 | if ( list.count() > 0 ) { | 1291 | if ( list.count() > 0 ) { |
1292 | KABC::Addressee::List listNew; | 1292 | KABC::Addressee::List listNew; |
1293 | KABC::Addressee::List listExisting; | 1293 | KABC::Addressee::List listExisting; |
1294 | KABC::Addressee::List::Iterator it; | 1294 | KABC::Addressee::List::Iterator it; |
1295 | KABC::AddressBook::Iterator iter; | 1295 | KABC::AddressBook::Iterator iter; |
1296 | for ( it = list.begin(); it != list.end(); ++it ) { | 1296 | for ( it = list.begin(); it != list.end(); ++it ) { |
1297 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1297 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1298 | listNew.append( (*it) ); | 1298 | listNew.append( (*it) ); |
1299 | else | 1299 | else |
1300 | listExisting.append( (*it) ); | 1300 | listExisting.append( (*it) ); |
1301 | } | 1301 | } |
1302 | if ( listExisting.count() > 0 ) | 1302 | if ( listExisting.count() > 0 ) |
1303 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1303 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1304 | if ( listNew.count() > 0 ) { | 1304 | if ( listNew.count() > 0 ) { |
1305 | pasteWithNewUid = false; | 1305 | pasteWithNewUid = false; |
1306 | pasteContacts( listNew ); | 1306 | pasteContacts( listNew ); |
1307 | pasteWithNewUid = true; | 1307 | pasteWithNewUid = true; |
1308 | } | 1308 | } |
1309 | } | 1309 | } |
1310 | delete idgl; | 1310 | delete idgl; |
1311 | #endif | 1311 | #endif |
1312 | } | 1312 | } |
1313 | 1313 | ||
1314 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1314 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1315 | { | 1315 | { |
1316 | mXXPortManager->importVCard( vCard, showPreview ); | 1316 | mXXPortManager->importVCard( vCard, showPreview ); |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | //US added a second method without defaultparameter | 1319 | //US added a second method without defaultparameter |
1320 | void KABCore::editContact2() { | 1320 | void KABCore::editContact2() { |
1321 | editContact( QString::null ); | 1321 | editContact( QString::null ); |
1322 | } | 1322 | } |
1323 | 1323 | ||
1324 | void KABCore::editContact( const QString &uid ) | 1324 | void KABCore::editContact( const QString &uid ) |
1325 | { | 1325 | { |
1326 | 1326 | ||
1327 | if ( mExtensionManager->isQuickEditVisible() ) | 1327 | if ( mExtensionManager->isQuickEditVisible() ) |
1328 | return; | 1328 | return; |
1329 | 1329 | ||
1330 | // First, locate the contact entry | 1330 | // First, locate the contact entry |
1331 | QString localUID = uid; | 1331 | QString localUID = uid; |
1332 | if ( localUID.isNull() ) { | 1332 | if ( localUID.isNull() ) { |
1333 | QStringList uidList = mViewManager->selectedUids(); | 1333 | QStringList uidList = mViewManager->selectedUids(); |
1334 | if ( uidList.count() > 0 ) | 1334 | if ( uidList.count() > 0 ) |
1335 | localUID = *( uidList.at( 0 ) ); | 1335 | localUID = *( uidList.at( 0 ) ); |
1336 | } | 1336 | } |
1337 | 1337 | ||
1338 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1338 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1339 | if ( !addr.isEmpty() ) { | 1339 | if ( !addr.isEmpty() ) { |
1340 | mEditorDialog->setAddressee( addr ); | 1340 | mEditorDialog->setAddressee( addr ); |
1341 | KApplication::execDialog ( mEditorDialog ); | 1341 | KApplication::execDialog ( mEditorDialog ); |
1342 | } | 1342 | } |
1343 | } | 1343 | } |
1344 | 1344 | ||
1345 | /** | 1345 | /** |
1346 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1346 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1347 | the method will try to find a selected addressee in the view. | 1347 | the method will try to find a selected addressee in the view. |
1348 | */ | 1348 | */ |
1349 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1349 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1350 | { | 1350 | { |
1351 | if ( mMultipleViewsAtOnce ) | 1351 | if ( mMultipleViewsAtOnce ) |
1352 | { | 1352 | { |
1353 | editContact( uid ); | 1353 | editContact( uid ); |
1354 | } | 1354 | } |
1355 | else | 1355 | else |
1356 | { | 1356 | { |
1357 | setDetailsVisible( true ); | 1357 | setDetailsVisible( true ); |
1358 | mActionDetails->setChecked(true); | 1358 | mActionDetails->setChecked(true); |
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | void KABCore::save() | 1363 | void KABCore::save() |
1364 | { | 1364 | { |
1365 | if (syncManager->blockSave()) | 1365 | if (syncManager->blockSave()) |
1366 | return; | 1366 | return; |
1367 | if ( !mModified ) | 1367 | if ( !mModified ) |
1368 | return; | 1368 | return; |
1369 | 1369 | ||
1370 | syncManager->setBlockSave(true); | 1370 | syncManager->setBlockSave(true); |
1371 | QString text = i18n( "There was an error while attempting to save\n the " | 1371 | QString text = i18n( "There was an error while attempting to save\n the " |
1372 | "address book. Please check that some \nother application is " | 1372 | "address book. Please check that some \nother application is " |
1373 | "not using it. " ); | 1373 | "not using it. " ); |
1374 | message(i18n("Saving addressbook ... ")); | 1374 | message(i18n("Saving addressbook ... ")); |
1375 | #ifndef KAB_EMBEDDED | 1375 | #ifndef KAB_EMBEDDED |
1376 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1376 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1377 | if ( !b || !b->save() ) { | 1377 | if ( !b || !b->save() ) { |
1378 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1378 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1379 | } | 1379 | } |
1380 | #else //KAB_EMBEDDED | 1380 | #else //KAB_EMBEDDED |
1381 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1381 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1382 | if ( !b || !b->save() ) { | 1382 | if ( !b || !b->save() ) { |
1383 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1383 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1384 | } | 1384 | } |
1385 | #endif //KAB_EMBEDDED | 1385 | #endif //KAB_EMBEDDED |
1386 | 1386 | ||
1387 | message(i18n("Addressbook saved!")); | 1387 | message(i18n("Addressbook saved!")); |
1388 | setModified( false ); | 1388 | setModified( false ); |
1389 | syncManager->setBlockSave(false); | 1389 | syncManager->setBlockSave(false); |
1390 | } | 1390 | } |
1391 | 1391 | ||
1392 | 1392 | ||
1393 | void KABCore::undo() | 1393 | void KABCore::undo() |
1394 | { | 1394 | { |
1395 | UndoStack::instance()->undo(); | 1395 | UndoStack::instance()->undo(); |
1396 | 1396 | ||
1397 | // Refresh the view | 1397 | // Refresh the view |
1398 | mViewManager->refreshView(); | 1398 | mViewManager->refreshView(); |
1399 | } | 1399 | } |
1400 | 1400 | ||
1401 | void KABCore::redo() | 1401 | void KABCore::redo() |
1402 | { | 1402 | { |
1403 | RedoStack::instance()->redo(); | 1403 | RedoStack::instance()->redo(); |
1404 | 1404 | ||
1405 | // Refresh the view | 1405 | // Refresh the view |
1406 | mViewManager->refreshView(); | 1406 | mViewManager->refreshView(); |
1407 | } | 1407 | } |
1408 | 1408 | ||
1409 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1409 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1410 | { | 1410 | { |
1411 | if (mMultipleViewsAtOnce) | 1411 | if (mMultipleViewsAtOnce) |
1412 | { | 1412 | { |
1413 | if ( visible ) | 1413 | if ( visible ) |
1414 | mJumpButtonBar->show(); | 1414 | mJumpButtonBar->show(); |
1415 | else | 1415 | else |
1416 | mJumpButtonBar->hide(); | 1416 | mJumpButtonBar->hide(); |
1417 | } | 1417 | } |
1418 | else | 1418 | else |
1419 | { | 1419 | { |
1420 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1420 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1421 | if (mViewManager->isVisible()) | 1421 | if (mViewManager->isVisible()) |
1422 | { | 1422 | { |
1423 | if ( visible ) | 1423 | if ( visible ) |
1424 | mJumpButtonBar->show(); | 1424 | mJumpButtonBar->show(); |
1425 | else | 1425 | else |
1426 | mJumpButtonBar->hide(); | 1426 | mJumpButtonBar->hide(); |
1427 | } | 1427 | } |
1428 | else | 1428 | else |
1429 | { | 1429 | { |
1430 | mJumpButtonBar->hide(); | 1430 | mJumpButtonBar->hide(); |
1431 | } | 1431 | } |
1432 | } | 1432 | } |
1433 | } | 1433 | } |
1434 | 1434 | ||
1435 | 1435 | ||
1436 | void KABCore::setDetailsToState() | 1436 | void KABCore::setDetailsToState() |
1437 | { | 1437 | { |
1438 | setDetailsVisible( mActionDetails->isChecked() ); | 1438 | setDetailsVisible( mActionDetails->isChecked() ); |
1439 | } | 1439 | } |
1440 | void KABCore::setDetailsToggle() | 1440 | void KABCore::setDetailsToggle() |
1441 | { | 1441 | { |
1442 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1442 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1443 | setDetailsToState(); | 1443 | setDetailsToState(); |
1444 | } | 1444 | } |
1445 | 1445 | ||
1446 | 1446 | ||
1447 | 1447 | ||
1448 | void KABCore::setDetailsVisible( bool visible ) | 1448 | void KABCore::setDetailsVisible( bool visible ) |
1449 | { | 1449 | { |
1450 | if (visible && mDetails->isHidden()) | 1450 | if (visible && mDetails->isHidden()) |
1451 | { | 1451 | { |
1452 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1452 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1453 | if ( addrList.count() > 0 ) | 1453 | if ( addrList.count() > 0 ) |
1454 | mDetails->setAddressee( addrList[ 0 ] ); | 1454 | mDetails->setAddressee( addrList[ 0 ] ); |
1455 | } | 1455 | } |
1456 | 1456 | ||
1457 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1457 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1458 | // the listview and the detailview. We do that by changing the splitbar size. | 1458 | // the listview and the detailview. We do that by changing the splitbar size. |
1459 | if (mMultipleViewsAtOnce) | 1459 | if (mMultipleViewsAtOnce) |
1460 | { | 1460 | { |
1461 | if ( visible ) | 1461 | if ( visible ) |
1462 | mDetails->show(); | 1462 | mDetails->show(); |
1463 | else | 1463 | else |
1464 | mDetails->hide(); | 1464 | mDetails->hide(); |
1465 | } | 1465 | } |
1466 | else | 1466 | else |
1467 | { | 1467 | { |
1468 | if ( visible ) { | 1468 | if ( visible ) { |
1469 | mViewManager->hide(); | 1469 | mViewManager->hide(); |
1470 | mDetails->show(); | 1470 | mDetails->show(); |
1471 | mIncSearchWidget->setFocus(); | 1471 | mIncSearchWidget->setFocus(); |
1472 | } | 1472 | } |
1473 | else { | 1473 | else { |
1474 | mViewManager->show(); | 1474 | mViewManager->show(); |
1475 | mDetails->hide(); | 1475 | mDetails->hide(); |
1476 | mViewManager->setFocusAV(); | 1476 | mViewManager->setFocusAV(); |
1477 | } | 1477 | } |
1478 | setJumpButtonBarVisible( !visible ); | 1478 | setJumpButtonBarVisible( !visible ); |
1479 | } | 1479 | } |
1480 | 1480 | ||
1481 | } | 1481 | } |
1482 | 1482 | ||
1483 | void KABCore::extensionChanged( int id ) | 1483 | void KABCore::extensionChanged( int id ) |
1484 | { | 1484 | { |
1485 | //change the details view only for non desktop systems | 1485 | //change the details view only for non desktop systems |
1486 | #ifndef DESKTOP_VERSION | 1486 | #ifndef DESKTOP_VERSION |
1487 | 1487 | ||
1488 | if (id == 0) | 1488 | if (id == 0) |
1489 | { | 1489 | { |
1490 | //the user disabled the extension. | 1490 | //the user disabled the extension. |
1491 | 1491 | ||
1492 | if (mMultipleViewsAtOnce) | 1492 | if (mMultipleViewsAtOnce) |
1493 | { // enable detailsview again | 1493 | { // enable detailsview again |
1494 | setDetailsVisible( true ); | 1494 | setDetailsVisible( true ); |
1495 | mActionDetails->setChecked( true ); | 1495 | mActionDetails->setChecked( true ); |
1496 | } | 1496 | } |
1497 | else | 1497 | else |
1498 | { //go back to the listview | 1498 | { //go back to the listview |
1499 | setDetailsVisible( false ); | 1499 | setDetailsVisible( false ); |
1500 | mActionDetails->setChecked( false ); | 1500 | mActionDetails->setChecked( false ); |
1501 | mActionDetails->setEnabled(true); | 1501 | mActionDetails->setEnabled(true); |
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | } | 1504 | } |
1505 | else | 1505 | else |
1506 | { | 1506 | { |
1507 | //the user enabled the extension. | 1507 | //the user enabled the extension. |
1508 | setDetailsVisible( false ); | 1508 | setDetailsVisible( false ); |
1509 | mActionDetails->setChecked( false ); | 1509 | mActionDetails->setChecked( false ); |
1510 | 1510 | ||
1511 | if (!mMultipleViewsAtOnce) | 1511 | if (!mMultipleViewsAtOnce) |
1512 | { | 1512 | { |
1513 | mActionDetails->setEnabled(false); | 1513 | mActionDetails->setEnabled(false); |
1514 | } | 1514 | } |
1515 | 1515 | ||
1516 | mExtensionManager->setSelectionChanged(); | 1516 | mExtensionManager->setSelectionChanged(); |
1517 | 1517 | ||
1518 | } | 1518 | } |
1519 | 1519 | ||
1520 | #endif// DESKTOP_VERSION | 1520 | #endif// DESKTOP_VERSION |
1521 | 1521 | ||
1522 | } | 1522 | } |
1523 | 1523 | ||
1524 | 1524 | ||
1525 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1525 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1526 | { | 1526 | { |
1527 | 1527 | ||
1528 | if ( list.count() != 0 ) { | 1528 | if ( list.count() != 0 ) { |
1529 | KABC::Addressee::List::ConstIterator it; | 1529 | KABC::Addressee::List::ConstIterator it; |
1530 | for ( it = list.begin(); it != list.end(); ++it ) | 1530 | for ( it = list.begin(); it != list.end(); ++it ) |
1531 | mAddressBook->insertAddressee( *it ); | 1531 | mAddressBook->insertAddressee( *it ); |
1532 | if ( list.count() > 1 ) | 1532 | if ( list.count() > 1 ) |
1533 | setModified(); | 1533 | setModified(); |
1534 | else | 1534 | else |
1535 | setModifiedWOrefresh(); | 1535 | setModifiedWOrefresh(); |
1536 | } | 1536 | } |
1537 | if ( list.count() == 0 ) | 1537 | if ( list.count() == 0 ) |
1538 | mViewManager->refreshView(); | 1538 | mViewManager->refreshView(); |
1539 | else | 1539 | else |
1540 | mViewManager->refreshView( list[ 0 ].uid() ); | 1540 | mViewManager->refreshView( list[ 0 ].uid() ); |
1541 | 1541 | ||
1542 | 1542 | ||
1543 | 1543 | ||
1544 | } | 1544 | } |
1545 | 1545 | ||
1546 | QString KABCore::getNameByPhone( const QString &phone ) | 1546 | QString KABCore::getNameByPhone( const QString &phone ) |
1547 | { | 1547 | { |
1548 | #ifndef KAB_EMBEDDED | 1548 | #ifndef KAB_EMBEDDED |
1549 | QRegExp r( "[/*/-/ ]" ); | 1549 | QRegExp r( "[/*/-/ ]" ); |
1550 | QString localPhone( phone ); | 1550 | QString localPhone( phone ); |
1551 | 1551 | ||
1552 | bool found = false; | 1552 | bool found = false; |
1553 | QString ownerName = ""; | 1553 | QString ownerName = ""; |
1554 | KABC::AddressBook::Iterator iter; | 1554 | KABC::AddressBook::Iterator iter; |
1555 | KABC::PhoneNumber::List::Iterator phoneIter; | 1555 | KABC::PhoneNumber::List::Iterator phoneIter; |
1556 | KABC::PhoneNumber::List phoneList; | 1556 | KABC::PhoneNumber::List phoneList; |
1557 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1557 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1558 | phoneList = (*iter).phoneNumbers(); | 1558 | phoneList = (*iter).phoneNumbers(); |
1559 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1559 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1560 | ++phoneIter) { | 1560 | ++phoneIter) { |
1561 | // Get rid of separator chars so just the numbers are compared. | 1561 | // Get rid of separator chars so just the numbers are compared. |
1562 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1562 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1563 | ownerName = (*iter).formattedName(); | 1563 | ownerName = (*iter).formattedName(); |
1564 | found = true; | 1564 | found = true; |
1565 | } | 1565 | } |
1566 | } | 1566 | } |
1567 | } | 1567 | } |
1568 | 1568 | ||
1569 | return ownerName; | 1569 | return ownerName; |
1570 | #else //KAB_EMBEDDED | 1570 | #else //KAB_EMBEDDED |
1571 | qDebug("KABCore::getNameByPhone finsih method"); | 1571 | qDebug("KABCore::getNameByPhone finsih method"); |
1572 | return ""; | 1572 | return ""; |
1573 | #endif //KAB_EMBEDDED | 1573 | #endif //KAB_EMBEDDED |
1574 | 1574 | ||
1575 | } | 1575 | } |
1576 | 1576 | ||
1577 | void KABCore::openConfigDialog() | 1577 | void KABCore::openConfigDialog() |
1578 | { | 1578 | { |
1579 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1579 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1580 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1580 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1581 | ConfigureDialog->addModule(kabcfg ); | 1581 | ConfigureDialog->addModule(kabcfg ); |
1582 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1582 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1583 | ConfigureDialog->addModule(kdelibcfg ); | 1583 | ConfigureDialog->addModule(kdelibcfg ); |
1584 | 1584 | ||
1585 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1585 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1586 | this, SLOT( configurationChanged() ) ); | 1586 | this, SLOT( configurationChanged() ) ); |
1587 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1587 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1588 | this, SLOT( configurationChanged() ) ); | 1588 | this, SLOT( configurationChanged() ) ); |
1589 | saveSettings(); | 1589 | saveSettings(); |
1590 | #ifndef DESKTOP_VERSION | 1590 | #ifndef DESKTOP_VERSION |
1591 | ConfigureDialog->showMaximized(); | 1591 | ConfigureDialog->showMaximized(); |
1592 | #endif | 1592 | #endif |
1593 | if ( ConfigureDialog->exec() ) | 1593 | if ( ConfigureDialog->exec() ) |
1594 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1594 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1595 | delete ConfigureDialog; | 1595 | delete ConfigureDialog; |
1596 | } | 1596 | } |
1597 | 1597 | ||
1598 | void KABCore::openLDAPDialog() | 1598 | void KABCore::openLDAPDialog() |
1599 | { | 1599 | { |
1600 | #ifndef KAB_EMBEDDED | 1600 | #ifndef KAB_EMBEDDED |
1601 | if ( !mLdapSearchDialog ) { | 1601 | if ( !mLdapSearchDialog ) { |
1602 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1602 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1603 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1603 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1604 | SLOT( refreshView() ) ); | 1604 | SLOT( refreshView() ) ); |
1605 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1605 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1606 | SLOT( setModified() ) ); | 1606 | SLOT( setModified() ) ); |
1607 | } else | 1607 | } else |
1608 | mLdapSearchDialog->restoreSettings(); | 1608 | mLdapSearchDialog->restoreSettings(); |
1609 | 1609 | ||
1610 | if ( mLdapSearchDialog->isOK() ) | 1610 | if ( mLdapSearchDialog->isOK() ) |
1611 | mLdapSearchDialog->exec(); | 1611 | mLdapSearchDialog->exec(); |
1612 | #else //KAB_EMBEDDED | 1612 | #else //KAB_EMBEDDED |
1613 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1613 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1614 | #endif //KAB_EMBEDDED | 1614 | #endif //KAB_EMBEDDED |
1615 | } | 1615 | } |
1616 | 1616 | ||
1617 | void KABCore::print() | 1617 | void KABCore::print() |
1618 | { | 1618 | { |
1619 | #ifndef KAB_EMBEDDED | 1619 | #ifndef KAB_EMBEDDED |
1620 | KPrinter printer; | 1620 | KPrinter printer; |
1621 | if ( !printer.setup( this ) ) | 1621 | if ( !printer.setup( this ) ) |
1622 | return; | 1622 | return; |
1623 | 1623 | ||
1624 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1624 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1625 | mViewManager->selectedUids(), this ); | 1625 | mViewManager->selectedUids(), this ); |
1626 | 1626 | ||
1627 | wizard.exec(); | 1627 | wizard.exec(); |
1628 | #else //KAB_EMBEDDED | 1628 | #else //KAB_EMBEDDED |
1629 | qDebug("KABCore::print() finsih method"); | 1629 | qDebug("KABCore::print() finsih method"); |
1630 | #endif //KAB_EMBEDDED | 1630 | #endif //KAB_EMBEDDED |
1631 | 1631 | ||
1632 | } | 1632 | } |
1633 | 1633 | ||
1634 | 1634 | ||
1635 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1635 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1636 | { | 1636 | { |
1637 | if ( mGUIClient ) | 1637 | if ( mGUIClient ) |
1638 | mGUIClient->insertChildClient( client ); | 1638 | mGUIClient->insertChildClient( client ); |
1639 | else | 1639 | else |
1640 | KMessageBox::error( this, "no KXMLGUICLient"); | 1640 | KMessageBox::error( this, "no KXMLGUICLient"); |
1641 | } | 1641 | } |
1642 | 1642 | ||
1643 | 1643 | ||
1644 | void KABCore::configurationChanged() | 1644 | void KABCore::configurationChanged() |
1645 | { | 1645 | { |
1646 | mExtensionManager->reconfigure(); | 1646 | mExtensionManager->reconfigure(); |
1647 | } | 1647 | } |
1648 | 1648 | ||
1649 | void KABCore::addressBookChanged() | 1649 | void KABCore::addressBookChanged() |
1650 | { | 1650 | { |
1651 | /*US | 1651 | /*US |
1652 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1652 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1653 | while ( it.current() ) { | 1653 | while ( it.current() ) { |
1654 | if ( it.current()->dirty() ) { | 1654 | if ( it.current()->dirty() ) { |
1655 | QString text = i18n( "Data has been changed externally. Unsaved " | 1655 | QString text = i18n( "Data has been changed externally. Unsaved " |
1656 | "changes will be lost." ); | 1656 | "changes will be lost." ); |
1657 | KMessageBox::information( this, text ); | 1657 | KMessageBox::information( this, text ); |
1658 | } | 1658 | } |
1659 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1659 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1660 | ++it; | 1660 | ++it; |
1661 | } | 1661 | } |
1662 | */ | 1662 | */ |
1663 | if (mEditorDialog) | 1663 | if (mEditorDialog) |
1664 | { | 1664 | { |
1665 | if (mEditorDialog->dirty()) | 1665 | if (mEditorDialog->dirty()) |
1666 | { | 1666 | { |
1667 | QString text = i18n( "Data has been changed externally. Unsaved " | 1667 | QString text = i18n( "Data has been changed externally. Unsaved " |
1668 | "changes will be lost." ); | 1668 | "changes will be lost." ); |
1669 | KMessageBox::information( this, text ); | 1669 | KMessageBox::information( this, text ); |
1670 | } | 1670 | } |
1671 | QString currentuid = mEditorDialog->addressee().uid(); | 1671 | QString currentuid = mEditorDialog->addressee().uid(); |
1672 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1672 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1673 | } | 1673 | } |
1674 | mViewManager->refreshView(); | 1674 | mViewManager->refreshView(); |
1675 | 1675 | ||
1676 | 1676 | ||
1677 | } | 1677 | } |
1678 | 1678 | ||
1679 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1679 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1680 | const char *name ) | 1680 | const char *name ) |
1681 | { | 1681 | { |
1682 | 1682 | ||
1683 | if ( mEditorDialog == 0 ) { | 1683 | if ( mEditorDialog == 0 ) { |
1684 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1684 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1685 | name ? name : "editorDialog" ); | 1685 | name ? name : "editorDialog" ); |
1686 | 1686 | ||
1687 | 1687 | ||
1688 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1688 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1689 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1689 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1690 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1690 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1691 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1691 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1692 | } | 1692 | } |
1693 | 1693 | ||
1694 | return mEditorDialog; | 1694 | return mEditorDialog; |
1695 | } | 1695 | } |
1696 | 1696 | ||
1697 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1697 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1698 | { | 1698 | { |
1699 | //mEditorDict.remove( uid ); | 1699 | //mEditorDict.remove( uid ); |
1700 | } | 1700 | } |
1701 | 1701 | ||
1702 | void KABCore::initGUI() | 1702 | void KABCore::initGUI() |
1703 | { | 1703 | { |
1704 | #ifndef KAB_EMBEDDED | 1704 | #ifndef KAB_EMBEDDED |
1705 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1705 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1706 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1706 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1707 | 1707 | ||
1708 | mExtensionBarSplitter = new QSplitter( this ); | 1708 | mExtensionBarSplitter = new QSplitter( this ); |
1709 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1709 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1710 | 1710 | ||
1711 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1711 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1712 | 1712 | ||
1713 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1713 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1714 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1714 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1715 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1715 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1716 | SLOT( incrementalSearch( const QString& ) ) ); | 1716 | SLOT( incrementalSearch( const QString& ) ) ); |
1717 | 1717 | ||
1718 | mViewManager = new ViewManager( this, viewSpace ); | 1718 | mViewManager = new ViewManager( this, viewSpace ); |
1719 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1719 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1720 | 1720 | ||
1721 | mDetails = new ViewContainer( mDetailsSplitter ); | 1721 | mDetails = new ViewContainer( mDetailsSplitter ); |
1722 | 1722 | ||
1723 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1723 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1724 | 1724 | ||
1725 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1725 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1726 | 1726 | ||
1727 | topLayout->addWidget( mExtensionBarSplitter ); | 1727 | topLayout->addWidget( mExtensionBarSplitter ); |
1728 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1728 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1729 | topLayout->addWidget( mJumpButtonBar ); | 1729 | topLayout->addWidget( mJumpButtonBar ); |
1730 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1730 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1731 | 1731 | ||
1732 | mXXPortManager = new XXPortManager( this, this ); | 1732 | mXXPortManager = new XXPortManager( this, this ); |
1733 | 1733 | ||
1734 | #else //KAB_EMBEDDED | 1734 | #else //KAB_EMBEDDED |
1735 | //US initialize viewMenu before settingup viewmanager. | 1735 | //US initialize viewMenu before settingup viewmanager. |
1736 | // Viewmanager needs this menu to plugin submenues. | 1736 | // Viewmanager needs this menu to plugin submenues. |
1737 | viewMenu = new QPopupMenu( this ); | 1737 | viewMenu = new QPopupMenu( this ); |
1738 | settingsMenu = new QPopupMenu( this ); | 1738 | settingsMenu = new QPopupMenu( this ); |
1739 | //filterMenu = new QPopupMenu( this ); | 1739 | //filterMenu = new QPopupMenu( this ); |
1740 | ImportMenu = new QPopupMenu( this ); | 1740 | ImportMenu = new QPopupMenu( this ); |
1741 | ExportMenu = new QPopupMenu( this ); | 1741 | ExportMenu = new QPopupMenu( this ); |
1742 | syncMenu = new QPopupMenu( this ); | 1742 | syncMenu = new QPopupMenu( this ); |
1743 | changeMenu= new QPopupMenu( this ); | 1743 | changeMenu= new QPopupMenu( this ); |
1744 | beamMenu= new QPopupMenu( this ); | 1744 | beamMenu= new QPopupMenu( this ); |
1745 | 1745 | ||
1746 | //US since we have no splitter for the embedded system, setup | 1746 | //US since we have no splitter for the embedded system, setup |
1747 | // a layout with two frames. One left and one right. | 1747 | // a layout with two frames. One left and one right. |
1748 | 1748 | ||
1749 | QBoxLayout *topLayout; | 1749 | QBoxLayout *topLayout; |
1750 | 1750 | ||
1751 | // = new QHBoxLayout( this ); | 1751 | // = new QHBoxLayout( this ); |
1752 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1752 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1753 | 1753 | ||
1754 | // QWidget *mainBox = new QWidget( this ); | 1754 | // QWidget *mainBox = new QWidget( this ); |
1755 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1755 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1756 | 1756 | ||
1757 | #ifdef DESKTOP_VERSION | 1757 | #ifdef DESKTOP_VERSION |
1758 | topLayout = new QHBoxLayout( this ); | 1758 | topLayout = new QHBoxLayout( this ); |
1759 | 1759 | ||
1760 | 1760 | ||
1761 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1761 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1762 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1762 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1763 | 1763 | ||
1764 | topLayout->addWidget(mMiniSplitter ); | 1764 | topLayout->addWidget(mMiniSplitter ); |
1765 | 1765 | ||
1766 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1766 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1767 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1767 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1768 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1768 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1769 | mDetails = new ViewContainer( mMiniSplitter ); | 1769 | mDetails = new ViewContainer( mMiniSplitter ); |
1770 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1770 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1771 | #else | 1771 | #else |
1772 | if ( QApplication::desktop()->width() > 480 ) { | 1772 | if ( QApplication::desktop()->width() > 480 ) { |
1773 | topLayout = new QHBoxLayout( this ); | 1773 | topLayout = new QHBoxLayout( this ); |
1774 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1774 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1775 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1775 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1776 | } else { | 1776 | } else { |
1777 | 1777 | ||
1778 | topLayout = new QHBoxLayout( this ); | 1778 | topLayout = new QHBoxLayout( this ); |
1779 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1779 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1780 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1780 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1781 | } | 1781 | } |
1782 | 1782 | ||
1783 | topLayout->addWidget(mMiniSplitter ); | 1783 | topLayout->addWidget(mMiniSplitter ); |
1784 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1784 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1785 | mDetails = new ViewContainer( mMiniSplitter ); | 1785 | mDetails = new ViewContainer( mMiniSplitter ); |
1786 | 1786 | ||
1787 | 1787 | ||
1788 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1788 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1789 | #endif | 1789 | #endif |
1790 | //eh->hide(); | 1790 | //eh->hide(); |
1791 | // topLayout->addWidget(mExtensionManager ); | 1791 | // topLayout->addWidget(mExtensionManager ); |
1792 | 1792 | ||
1793 | 1793 | ||
1794 | /*US | 1794 | /*US |
1795 | #ifndef KAB_NOSPLITTER | 1795 | #ifndef KAB_NOSPLITTER |
1796 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1796 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1797 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1797 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1798 | topLayout->setSpacing( 10 ); | 1798 | topLayout->setSpacing( 10 ); |
1799 | 1799 | ||
1800 | mDetailsSplitter = new QSplitter( this ); | 1800 | mDetailsSplitter = new QSplitter( this ); |
1801 | 1801 | ||
1802 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1802 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1803 | 1803 | ||
1804 | mViewManager = new ViewManager( this, viewSpace ); | 1804 | mViewManager = new ViewManager( this, viewSpace ); |
1805 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1805 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1806 | 1806 | ||
1807 | mDetails = new ViewContainer( mDetailsSplitter ); | 1807 | mDetails = new ViewContainer( mDetailsSplitter ); |
1808 | 1808 | ||
1809 | topLayout->addWidget( mDetailsSplitter ); | 1809 | topLayout->addWidget( mDetailsSplitter ); |
1810 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1810 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1811 | #else //KAB_NOSPLITTER | 1811 | #else //KAB_NOSPLITTER |
1812 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1812 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1813 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1813 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1814 | topLayout->setSpacing( 10 ); | 1814 | topLayout->setSpacing( 10 ); |
1815 | 1815 | ||
1816 | // mDetailsSplitter = new QSplitter( this ); | 1816 | // mDetailsSplitter = new QSplitter( this ); |
1817 | 1817 | ||
1818 | QVBox *viewSpace = new QVBox( this ); | 1818 | QVBox *viewSpace = new QVBox( this ); |
1819 | 1819 | ||
1820 | mViewManager = new ViewManager( this, viewSpace ); | 1820 | mViewManager = new ViewManager( this, viewSpace ); |
1821 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1821 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1822 | 1822 | ||
1823 | mDetails = new ViewContainer( this ); | 1823 | mDetails = new ViewContainer( this ); |
1824 | 1824 | ||
1825 | topLayout->addWidget( viewSpace ); | 1825 | topLayout->addWidget( viewSpace ); |
1826 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1826 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1827 | topLayout->addWidget( mDetails ); | 1827 | topLayout->addWidget( mDetails ); |
1828 | #endif //KAB_NOSPLITTER | 1828 | #endif //KAB_NOSPLITTER |
1829 | */ | 1829 | */ |
1830 | 1830 | ||
1831 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1831 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1832 | syncManager->setBlockSave(false); | 1832 | syncManager->setBlockSave(false); |
1833 | 1833 | ||
1834 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1834 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1835 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1835 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1836 | QString sync_file = sentSyncFile(); | 1836 | QString sync_file = sentSyncFile(); |
1837 | qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); | 1837 | qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); |
1838 | syncManager->setDefaultFileName( sync_file ); | 1838 | syncManager->setDefaultFileName( sync_file ); |
1839 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1839 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1840 | 1840 | ||
1841 | #endif //KAB_EMBEDDED | 1841 | #endif //KAB_EMBEDDED |
1842 | initActions(); | 1842 | initActions(); |
1843 | 1843 | ||
1844 | #ifdef KAB_EMBEDDED | 1844 | #ifdef KAB_EMBEDDED |
1845 | addActionsManually(); | 1845 | addActionsManually(); |
1846 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1846 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1847 | mXXPortManager = new XXPortManager( this, this ); | 1847 | mXXPortManager = new XXPortManager( this, this ); |
1848 | 1848 | ||
1849 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1849 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1850 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1850 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1851 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1851 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1852 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1852 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1853 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1853 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1854 | // mIncSearchWidget->hide(); | 1854 | // mIncSearchWidget->hide(); |
1855 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1855 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1856 | SLOT( incrementalSearch( const QString& ) ) ); | 1856 | SLOT( incrementalSearch( const QString& ) ) ); |
1857 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1857 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1858 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1858 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1859 | 1859 | ||
1860 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1860 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1861 | 1861 | ||
1862 | topLayout->addWidget( mJumpButtonBar ); | 1862 | topLayout->addWidget( mJumpButtonBar ); |
1863 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1863 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1864 | 1864 | ||
1865 | // mMainWindow->getIconToolBar()->raise(); | 1865 | // mMainWindow->getIconToolBar()->raise(); |
1866 | 1866 | ||
1867 | #endif //KAB_EMBEDDED | 1867 | #endif //KAB_EMBEDDED |
1868 | 1868 | ||
1869 | } | 1869 | } |
1870 | void KABCore::initActions() | 1870 | void KABCore::initActions() |
1871 | { | 1871 | { |
1872 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1872 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1873 | 1873 | ||
1874 | #ifndef KAB_EMBEDDED | 1874 | #ifndef KAB_EMBEDDED |
1875 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1875 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1876 | SLOT( clipboardDataChanged() ) ); | 1876 | SLOT( clipboardDataChanged() ) ); |
1877 | #endif //KAB_EMBEDDED | 1877 | #endif //KAB_EMBEDDED |
1878 | 1878 | ||
1879 | // file menu | 1879 | // file menu |
1880 | if ( mIsPart ) { | 1880 | |
1881 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | ||
1882 | SLOT( sendMail() ), actionCollection(), | ||
1883 | "kaddressbook_mail" ); | ||
1884 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | ||
1885 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | ||
1886 | |||
1887 | } else { | ||
1888 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1881 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1889 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1882 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1890 | } | 1883 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, |
1884 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); | ||
1885 | |||
1891 | 1886 | ||
1887 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, | ||
1888 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); | ||
1892 | 1889 | ||
1893 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1890 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1894 | SLOT( save() ), actionCollection(), "file_sync" ); | 1891 | SLOT( save() ), actionCollection(), "file_sync" ); |
1895 | 1892 | ||
1896 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1893 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1897 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1894 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1898 | 1895 | ||
1899 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1896 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1900 | this, SLOT( mailVCard() ), | 1897 | this, SLOT( mailVCard() ), |
1901 | actionCollection(), "file_mail_vcard"); | 1898 | actionCollection(), "file_mail_vcard"); |
1902 | 1899 | ||
1903 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, | 1900 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, |
1904 | SLOT( export2phone() ), actionCollection(), | 1901 | SLOT( export2phone() ), actionCollection(), |
1905 | "kaddressbook_ex2phone" ); | 1902 | "kaddressbook_ex2phone" ); |
1906 | 1903 | ||
1907 | mActionBeamVCard = 0; | 1904 | mActionBeamVCard = 0; |
1908 | mActionBeam = 0; | 1905 | mActionBeam = 0; |
1909 | 1906 | ||
1910 | #ifndef DESKTOP_VERSION | 1907 | #ifndef DESKTOP_VERSION |
1911 | if ( Ir::supported() ) { | 1908 | if ( Ir::supported() ) { |
1912 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, | 1909 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, |
1913 | SLOT( beamVCard() ), actionCollection(), | 1910 | SLOT( beamVCard() ), actionCollection(), |
1914 | "kaddressbook_beam_vcard" ); | 1911 | "kaddressbook_beam_vcard" ); |
1915 | 1912 | ||
1916 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1913 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1917 | SLOT( beamMySelf() ), actionCollection(), | 1914 | SLOT( beamMySelf() ), actionCollection(), |
1918 | "kaddressbook_beam_myself" ); | 1915 | "kaddressbook_beam_myself" ); |
1919 | } | 1916 | } |
1920 | #endif | 1917 | #endif |
1921 | 1918 | ||
1922 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1919 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1923 | this, SLOT( editContact2() ), | 1920 | this, SLOT( editContact2() ), |
1924 | actionCollection(), "file_properties" ); | 1921 | actionCollection(), "file_properties" ); |
1925 | 1922 | ||
1926 | #ifdef KAB_EMBEDDED | 1923 | #ifdef KAB_EMBEDDED |
1927 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1924 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1928 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1925 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1929 | mMainWindow, SLOT( exit() ), | 1926 | mMainWindow, SLOT( exit() ), |
1930 | actionCollection(), "quit" ); | 1927 | actionCollection(), "quit" ); |
1931 | #endif //KAB_EMBEDDED | 1928 | #endif //KAB_EMBEDDED |
1932 | 1929 | ||
1933 | // edit menu | 1930 | // edit menu |
1934 | if ( mIsPart ) { | 1931 | if ( mIsPart ) { |
1935 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1932 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1936 | SLOT( copyContacts() ), actionCollection(), | 1933 | SLOT( copyContacts() ), actionCollection(), |
1937 | "kaddressbook_copy" ); | 1934 | "kaddressbook_copy" ); |
1938 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1935 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1939 | SLOT( cutContacts() ), actionCollection(), | 1936 | SLOT( cutContacts() ), actionCollection(), |
1940 | "kaddressbook_cut" ); | 1937 | "kaddressbook_cut" ); |
1941 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1938 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1942 | SLOT( pasteContacts() ), actionCollection(), | 1939 | SLOT( pasteContacts() ), actionCollection(), |
1943 | "kaddressbook_paste" ); | 1940 | "kaddressbook_paste" ); |
1944 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1941 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1945 | SLOT( selectAllContacts() ), actionCollection(), | 1942 | SLOT( selectAllContacts() ), actionCollection(), |
1946 | "kaddressbook_select_all" ); | 1943 | "kaddressbook_select_all" ); |
1947 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1944 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1948 | SLOT( undo() ), actionCollection(), | 1945 | SLOT( undo() ), actionCollection(), |
1949 | "kaddressbook_undo" ); | 1946 | "kaddressbook_undo" ); |
1950 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1947 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1951 | this, SLOT( redo() ), actionCollection(), | 1948 | this, SLOT( redo() ), actionCollection(), |
1952 | "kaddressbook_redo" ); | 1949 | "kaddressbook_redo" ); |
1953 | } else { | 1950 | } else { |
1954 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1951 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1955 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1952 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1956 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1953 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1957 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1954 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1958 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1955 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1959 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1956 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1960 | } | 1957 | } |
1961 | 1958 | ||
1962 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1959 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1963 | Key_Delete, this, SLOT( deleteContacts() ), | 1960 | Key_Delete, this, SLOT( deleteContacts() ), |
1964 | actionCollection(), "edit_delete" ); | 1961 | actionCollection(), "edit_delete" ); |
1965 | 1962 | ||
1966 | mActionUndo->setEnabled( false ); | 1963 | mActionUndo->setEnabled( false ); |
1967 | mActionRedo->setEnabled( false ); | 1964 | mActionRedo->setEnabled( false ); |
1968 | 1965 | ||
1969 | // settings menu | 1966 | // settings menu |
1970 | #ifdef KAB_EMBEDDED | 1967 | #ifdef KAB_EMBEDDED |
1971 | //US special menuentry to configure the addressbook resources. On KDE | 1968 | //US special menuentry to configure the addressbook resources. On KDE |
1972 | // you do that through the control center !!! | 1969 | // you do that through the control center !!! |
1973 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1970 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1974 | SLOT( configureResources() ), actionCollection(), | 1971 | SLOT( configureResources() ), actionCollection(), |
1975 | "kaddressbook_configure_resources" ); | 1972 | "kaddressbook_configure_resources" ); |
1976 | #endif //KAB_EMBEDDED | 1973 | #endif //KAB_EMBEDDED |
1977 | 1974 | ||
1978 | if ( mIsPart ) { | 1975 | if ( mIsPart ) { |
1979 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1976 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1980 | SLOT( openConfigDialog() ), actionCollection(), | 1977 | SLOT( openConfigDialog() ), actionCollection(), |
1981 | "kaddressbook_configure" ); | 1978 | "kaddressbook_configure" ); |
1982 | 1979 | ||
1983 | //US not implemented yet | 1980 | //US not implemented yet |
1984 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1981 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1985 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1982 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1986 | // "kaddressbook_configure_shortcuts" ); | 1983 | // "kaddressbook_configure_shortcuts" ); |
1987 | #ifdef KAB_EMBEDDED | 1984 | #ifdef KAB_EMBEDDED |
1988 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1985 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1989 | mActionConfigureToolbars->setEnabled( false ); | 1986 | mActionConfigureToolbars->setEnabled( false ); |
1990 | #endif //KAB_EMBEDDED | 1987 | #endif //KAB_EMBEDDED |
1991 | 1988 | ||
1992 | } else { | 1989 | } else { |
1993 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1990 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1994 | 1991 | ||
1995 | //US not implemented yet | 1992 | //US not implemented yet |
1996 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1993 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1997 | } | 1994 | } |
1998 | 1995 | ||
1999 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1996 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
2000 | actionCollection(), "options_show_jump_bar" ); | 1997 | actionCollection(), "options_show_jump_bar" ); |
2001 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1998 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
2002 | 1999 | ||
2003 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 2000 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
2004 | actionCollection(), "options_show_details" ); | 2001 | actionCollection(), "options_show_details" ); |
2005 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 2002 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
2006 | 2003 | ||
2007 | 2004 | ||
2008 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 2005 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
2009 | SLOT( toggleBeamReceive() ), actionCollection(), | 2006 | SLOT( toggleBeamReceive() ), actionCollection(), |
2010 | "kaddressbook_beam_rec" ); | 2007 | "kaddressbook_beam_rec" ); |
2011 | 2008 | ||
2012 | 2009 | ||
2013 | // misc | 2010 | // misc |
2014 | // only enable LDAP lookup if we can handle the protocol | 2011 | // only enable LDAP lookup if we can handle the protocol |
2015 | #ifndef KAB_EMBEDDED | 2012 | #ifndef KAB_EMBEDDED |
2016 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 2013 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
2017 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 2014 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
2018 | this, SLOT( openLDAPDialog() ), actionCollection(), | 2015 | this, SLOT( openLDAPDialog() ), actionCollection(), |
2019 | "ldap_lookup" ); | 2016 | "ldap_lookup" ); |
2020 | } | 2017 | } |
2021 | #else //KAB_EMBEDDED | 2018 | #else //KAB_EMBEDDED |
2022 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 2019 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
2023 | #endif //KAB_EMBEDDED | 2020 | #endif //KAB_EMBEDDED |
2024 | 2021 | ||
2025 | 2022 | ||
2026 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 2023 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
2027 | SLOT( setWhoAmI() ), actionCollection(), | 2024 | SLOT( setWhoAmI() ), actionCollection(), |
2028 | "set_personal" ); | 2025 | "set_personal" ); |
2029 | 2026 | ||
2030 | 2027 | ||
2031 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 2028 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
2032 | SLOT( setCategories() ), actionCollection(), | 2029 | SLOT( setCategories() ), actionCollection(), |
2033 | "edit_set_categories" ); | 2030 | "edit_set_categories" ); |
2034 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, | 2031 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, |
2035 | SLOT( editCategories() ), actionCollection(), | 2032 | SLOT( editCategories() ), actionCollection(), |
2036 | "edit__categories" ); | 2033 | "edit__categories" ); |
2037 | 2034 | ||
2038 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 2035 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
2039 | SLOT( removeVoice() ), actionCollection(), | 2036 | SLOT( removeVoice() ), actionCollection(), |
2040 | "remove_voice" ); | 2037 | "remove_voice" ); |
2041 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, | 2038 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, |
2042 | SLOT( setFormattedName() ), actionCollection(), | 2039 | SLOT( setFormattedName() ), actionCollection(), |
2043 | "set_formatted" ); | 2040 | "set_formatted" ); |
2044 | 2041 | ||
2045 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 2042 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
2046 | SLOT( manageCategories() ), actionCollection(), | 2043 | SLOT( manageCategories() ), actionCollection(), |
2047 | "remove_voice" ); | 2044 | "remove_voice" ); |
2048 | 2045 | ||
2049 | 2046 | ||
2050 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 2047 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
2051 | SLOT( importFromOL() ), actionCollection(), | 2048 | SLOT( importFromOL() ), actionCollection(), |
2052 | "import_OL" ); | 2049 | "import_OL" ); |
2053 | #ifdef KAB_EMBEDDED | 2050 | #ifdef KAB_EMBEDDED |
2054 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 2051 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
2055 | this, SLOT( showLicence() ), actionCollection(), | 2052 | this, SLOT( showLicence() ), actionCollection(), |
2056 | "licence_about_data" ); | 2053 | "licence_about_data" ); |
2057 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 2054 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
2058 | this, SLOT( faq() ), actionCollection(), | 2055 | this, SLOT( faq() ), actionCollection(), |
2059 | "faq_about_data" ); | 2056 | "faq_about_data" ); |
2060 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 2057 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
2061 | this, SLOT( whatsnew() ), actionCollection(), | 2058 | this, SLOT( whatsnew() ), actionCollection(), |
2062 | "wn" ); | 2059 | "wn" ); |
2063 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2060 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2064 | this, SLOT( synchowto() ), actionCollection(), | 2061 | this, SLOT( synchowto() ), actionCollection(), |
2065 | "sync" ); | 2062 | "sync" ); |
2066 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2063 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2067 | this, SLOT( kdesynchowto() ), actionCollection(), | 2064 | this, SLOT( kdesynchowto() ), actionCollection(), |
2068 | "kdesync" ); | 2065 | "kdesync" ); |
2069 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2066 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2070 | this, SLOT( multisynchowto() ), actionCollection(), | 2067 | this, SLOT( multisynchowto() ), actionCollection(), |
2071 | "multisync" ); | 2068 | "multisync" ); |
2072 | 2069 | ||
2073 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2070 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2074 | this, SLOT( createAboutData() ), actionCollection(), | 2071 | this, SLOT( createAboutData() ), actionCollection(), |
2075 | "kaddressbook_about_data" ); | 2072 | "kaddressbook_about_data" ); |
2076 | #endif //KAB_EMBEDDED | 2073 | #endif //KAB_EMBEDDED |
2077 | 2074 | ||
2078 | clipboardDataChanged(); | 2075 | clipboardDataChanged(); |
2079 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2076 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2080 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2077 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2081 | } | 2078 | } |
2082 | 2079 | ||
2083 | //US we need this function, to plug all actions into the correct menues. | 2080 | //US we need this function, to plug all actions into the correct menues. |
2084 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2081 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2085 | void KABCore::addActionsManually() | 2082 | void KABCore::addActionsManually() |
2086 | { | 2083 | { |
2087 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2084 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
2088 | 2085 | ||
2089 | #ifdef KAB_EMBEDDED | 2086 | #ifdef KAB_EMBEDDED |
2090 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 2087 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
2091 | QPopupMenu *editMenu = new QPopupMenu( this ); | 2088 | QPopupMenu *editMenu = new QPopupMenu( this ); |
2092 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 2089 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
2093 | 2090 | ||
2094 | KToolBar* tb = mMainWindow->toolBar(); | 2091 | KToolBar* tb = mMainWindow->toolBar(); |
2095 | 2092 | ||
2096 | #ifndef DESKTOP_VERSION | 2093 | #ifndef DESKTOP_VERSION |
2097 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 2094 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
2098 | #endif | 2095 | #endif |
2099 | QMenuBar* mb = mMainWindow->menuBar(); | 2096 | QMenuBar* mb = mMainWindow->menuBar(); |
2100 | 2097 | ||
2101 | //US setup menubar. | 2098 | //US setup menubar. |
2102 | //Disable the following block if you do not want to have a menubar. | 2099 | //Disable the following block if you do not want to have a menubar. |
2103 | mb->insertItem( i18n("&File"), fileMenu ); | 2100 | mb->insertItem( i18n("&File"), fileMenu ); |
2104 | mb->insertItem( i18n("&Edit"), editMenu ); | 2101 | mb->insertItem( i18n("&Edit"), editMenu ); |
2105 | mb->insertItem( i18n("&View"), viewMenu ); | 2102 | mb->insertItem( i18n("&View"), viewMenu ); |
2106 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2103 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2107 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2104 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2108 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2105 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2109 | mb->insertItem( i18n("&Help"), helpMenu ); | 2106 | mb->insertItem( i18n("&Help"), helpMenu ); |
2110 | mIncSearchWidget = new IncSearchWidget( tb ); | 2107 | mIncSearchWidget = new IncSearchWidget( tb ); |
2111 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2108 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2112 | #ifndef DESKTOP_VERSION | 2109 | #ifndef DESKTOP_VERSION |
2113 | } else { | 2110 | } else { |
2114 | //US setup toolbar | 2111 | //US setup toolbar |
2115 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2112 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2116 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2113 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2117 | menuBarTB->insertItem( "ME", popupBarTB); | 2114 | menuBarTB->insertItem( "ME", popupBarTB); |
2118 | tb->insertWidget(-1, 0, menuBarTB); | 2115 | tb->insertWidget(-1, 0, menuBarTB); |
2119 | mIncSearchWidget = new IncSearchWidget( tb ); | 2116 | mIncSearchWidget = new IncSearchWidget( tb ); |
2120 | 2117 | ||
2121 | tb->enableMoving(false); | 2118 | tb->enableMoving(false); |
2122 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2119 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2123 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2120 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2124 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2121 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2125 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2122 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2126 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2123 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2127 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2124 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2128 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2125 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2129 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2126 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2130 | if (QApplication::desktop()->width() > 320 ) { | 2127 | if (QApplication::desktop()->width() > 320 ) { |
2131 | // mViewManager->getFilterAction()->plug ( tb); | 2128 | // mViewManager->getFilterAction()->plug ( tb); |
2132 | } | 2129 | } |
2133 | } | 2130 | } |
2134 | #endif | 2131 | #endif |
2135 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2132 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2136 | 2133 | ||
2137 | 2134 | ||
2138 | 2135 | ||
2139 | //US Now connect the actions with the menue entries. | 2136 | //US Now connect the actions with the menue entries. |
2140 | #ifdef DESKTOP_VERSION | 2137 | #ifdef DESKTOP_VERSION |
2141 | mActionPrint->plug( fileMenu ); | 2138 | mActionPrint->plug( fileMenu ); |
2139 | mActionPrintDetails->plug( fileMenu ); | ||
2140 | fileMenu->insertSeparator(); | ||
2142 | #endif | 2141 | #endif |
2143 | mActionMail->plug( fileMenu ); | 2142 | mActionMail->plug( fileMenu ); |
2144 | fileMenu->insertSeparator(); | 2143 | fileMenu->insertSeparator(); |
2145 | 2144 | ||
2146 | mActionNewContact->plug( fileMenu ); | 2145 | mActionNewContact->plug( fileMenu ); |
2147 | mActionNewContact->plug( tb ); | 2146 | mActionNewContact->plug( tb ); |
2148 | 2147 | ||
2149 | mActionEditAddressee->plug( fileMenu ); | 2148 | mActionEditAddressee->plug( fileMenu ); |
2150 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2149 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2151 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2150 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2152 | mActionEditAddressee->plug( tb ); | 2151 | mActionEditAddressee->plug( tb ); |
2153 | 2152 | ||
2154 | fileMenu->insertSeparator(); | 2153 | fileMenu->insertSeparator(); |
2155 | mActionSave->plug( fileMenu ); | 2154 | mActionSave->plug( fileMenu ); |
2156 | fileMenu->insertItem( "&Import", ImportMenu ); | 2155 | fileMenu->insertItem( "&Import", ImportMenu ); |
2157 | fileMenu->insertItem( "&Export", ExportMenu ); | 2156 | fileMenu->insertItem( "&Export", ExportMenu ); |
2158 | fileMenu->insertItem( i18n("&Change"), changeMenu ); | 2157 | fileMenu->insertItem( i18n("&Change"), changeMenu ); |
2159 | #ifndef DESKTOP_VERSION | 2158 | #ifndef DESKTOP_VERSION |
2160 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2159 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2161 | #endif | 2160 | #endif |
2162 | #if 0 | 2161 | #if 0 |
2163 | // PENDING fix MailVCard | 2162 | // PENDING fix MailVCard |
2164 | fileMenu->insertSeparator(); | 2163 | fileMenu->insertSeparator(); |
2165 | mActionMailVCard->plug( fileMenu ); | 2164 | mActionMailVCard->plug( fileMenu ); |
2166 | #endif | 2165 | #endif |
2167 | #ifndef DESKTOP_VERSION | 2166 | #ifndef DESKTOP_VERSION |
2168 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2167 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2169 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2168 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2170 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2169 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2171 | #endif | 2170 | #endif |
2172 | fileMenu->insertSeparator(); | 2171 | fileMenu->insertSeparator(); |
2173 | mActionQuit->plug( fileMenu ); | 2172 | mActionQuit->plug( fileMenu ); |
2174 | #ifdef _WIN32_ | 2173 | #ifdef _WIN32_ |
2175 | mActionImportOL->plug( ImportMenu ); | 2174 | mActionImportOL->plug( ImportMenu ); |
2176 | #endif | 2175 | #endif |
2177 | // edit menu | 2176 | // edit menu |
2178 | mActionUndo->plug( editMenu ); | 2177 | mActionUndo->plug( editMenu ); |
2179 | mActionRedo->plug( editMenu ); | 2178 | mActionRedo->plug( editMenu ); |
2180 | editMenu->insertSeparator(); | 2179 | editMenu->insertSeparator(); |
2181 | mActionCut->plug( editMenu ); | 2180 | mActionCut->plug( editMenu ); |
2182 | mActionCopy->plug( editMenu ); | 2181 | mActionCopy->plug( editMenu ); |
2183 | mActionPaste->plug( editMenu ); | 2182 | mActionPaste->plug( editMenu ); |
2184 | mActionDelete->plug( editMenu ); | 2183 | mActionDelete->plug( editMenu ); |
2185 | editMenu->insertSeparator(); | 2184 | editMenu->insertSeparator(); |
2186 | mActionSelectAll->plug( editMenu ); | 2185 | mActionSelectAll->plug( editMenu ); |
2187 | 2186 | ||
2188 | mActionSetFormattedName->plug( changeMenu ); | 2187 | mActionSetFormattedName->plug( changeMenu ); |
2189 | mActionRemoveVoice->plug( changeMenu ); | 2188 | mActionRemoveVoice->plug( changeMenu ); |
2190 | // settings menu | 2189 | // settings menu |
2191 | //US special menuentry to configure the addressbook resources. On KDE | 2190 | //US special menuentry to configure the addressbook resources. On KDE |
2192 | // you do that through the control center !!! | 2191 | // you do that through the control center !!! |
2193 | mActionConfigResources->plug( settingsMenu ); | 2192 | mActionConfigResources->plug( settingsMenu ); |
2194 | settingsMenu->insertSeparator(); | 2193 | settingsMenu->insertSeparator(); |
2195 | 2194 | ||
2196 | mActionConfigKAddressbook->plug( settingsMenu ); | 2195 | mActionConfigKAddressbook->plug( settingsMenu ); |
2197 | 2196 | ||
2198 | if ( mIsPart ) { | 2197 | if ( mIsPart ) { |
2199 | //US not implemented yet | 2198 | //US not implemented yet |
2200 | //mActionConfigShortcuts->plug( settingsMenu ); | 2199 | //mActionConfigShortcuts->plug( settingsMenu ); |
2201 | //mActionConfigureToolbars->plug( settingsMenu ); | 2200 | //mActionConfigureToolbars->plug( settingsMenu ); |
2202 | 2201 | ||
2203 | } else { | 2202 | } else { |
2204 | //US not implemented yet | 2203 | //US not implemented yet |
2205 | //mActionKeyBindings->plug( settingsMenu ); | 2204 | //mActionKeyBindings->plug( settingsMenu ); |
2206 | } | 2205 | } |
2207 | 2206 | ||
2208 | settingsMenu->insertSeparator(); | 2207 | settingsMenu->insertSeparator(); |
2209 | 2208 | ||
2210 | mActionJumpBar->plug( settingsMenu ); | 2209 | mActionJumpBar->plug( settingsMenu ); |
2211 | mActionDetails->plug( settingsMenu ); | 2210 | mActionDetails->plug( settingsMenu ); |
2212 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2211 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2213 | mActionDetails->plug( tb ); | 2212 | mActionDetails->plug( tb ); |
2214 | settingsMenu->insertSeparator(); | 2213 | settingsMenu->insertSeparator(); |
2215 | #ifndef DESKTOP_VERSION | 2214 | #ifndef DESKTOP_VERSION |
2216 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2215 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2217 | #endif | 2216 | #endif |
2218 | settingsMenu->insertSeparator(); | 2217 | settingsMenu->insertSeparator(); |
2219 | 2218 | ||
2220 | mActionWhoAmI->plug( settingsMenu ); | 2219 | mActionWhoAmI->plug( settingsMenu ); |
2221 | mActionEditCategories->plug( settingsMenu ); | 2220 | mActionEditCategories->plug( settingsMenu ); |
2222 | mActionEditCategories->plug( changeMenu ); | 2221 | mActionEditCategories->plug( changeMenu ); |
2223 | mActionCategories->plug( changeMenu ); | 2222 | mActionCategories->plug( changeMenu ); |
2224 | mActionManageCategories->plug( changeMenu ); | 2223 | mActionManageCategories->plug( changeMenu ); |
2225 | 2224 | ||
2226 | mActionCategories->plug( settingsMenu ); | 2225 | mActionCategories->plug( settingsMenu ); |
2227 | mActionManageCategories->plug( settingsMenu ); | 2226 | mActionManageCategories->plug( settingsMenu ); |
2228 | 2227 | ||
2229 | 2228 | ||
2230 | mActionWN->plug( helpMenu ); | 2229 | mActionWN->plug( helpMenu ); |
2231 | mActionSyncHowto->plug( helpMenu ); | 2230 | mActionSyncHowto->plug( helpMenu ); |
2232 | mActionKdeSyncHowto->plug( helpMenu ); | 2231 | mActionKdeSyncHowto->plug( helpMenu ); |
2233 | mActionMultiSyncHowto->plug( helpMenu ); | 2232 | mActionMultiSyncHowto->plug( helpMenu ); |
2234 | mActionFaq->plug( helpMenu ); | 2233 | mActionFaq->plug( helpMenu ); |
2235 | mActionLicence->plug( helpMenu ); | 2234 | mActionLicence->plug( helpMenu ); |
2236 | mActionAboutKAddressbook->plug( helpMenu ); | 2235 | mActionAboutKAddressbook->plug( helpMenu ); |
2237 | 2236 | ||
2238 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2237 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2239 | 2238 | ||
2240 | mActionSave->plug( tb ); | 2239 | mActionSave->plug( tb ); |
2241 | mViewManager->getFilterAction()->plug ( tb); | 2240 | mViewManager->getFilterAction()->plug ( tb); |
2242 | //LR hide filteraction on started in 480x640 | 2241 | //LR hide filteraction on started in 480x640 |
2243 | if (QApplication::desktop()->width() == 480 ) { | 2242 | if (QApplication::desktop()->width() == 480 ) { |
2244 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 2243 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2245 | } | 2244 | } |
2246 | mActionUndo->plug( tb ); | 2245 | mActionUndo->plug( tb ); |
2247 | mActionDelete->plug( tb ); | 2246 | mActionDelete->plug( tb ); |
2248 | mActionRedo->plug( tb ); | 2247 | mActionRedo->plug( tb ); |
2249 | } else { | 2248 | } else { |
2250 | mActionSave->plug( tb ); | 2249 | mActionSave->plug( tb ); |
2251 | tb->enableMoving(false); | 2250 | tb->enableMoving(false); |
2252 | } | 2251 | } |
2253 | //mActionQuit->plug ( tb ); | 2252 | //mActionQuit->plug ( tb ); |
2254 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2253 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2255 | 2254 | ||
2256 | //US link the searchwidget first to this. | 2255 | //US link the searchwidget first to this. |
2257 | // The real linkage to the toolbar happens later. | 2256 | // The real linkage to the toolbar happens later. |
2258 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2257 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2259 | //US tb->insertItem( mIncSearchWidget ); | 2258 | //US tb->insertItem( mIncSearchWidget ); |
2260 | /*US | 2259 | /*US |
2261 | mIncSearchWidget = new IncSearchWidget( tb ); | 2260 | mIncSearchWidget = new IncSearchWidget( tb ); |
2262 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2261 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2263 | SLOT( incrementalSearch( const QString& ) ) ); | 2262 | SLOT( incrementalSearch( const QString& ) ) ); |
2264 | 2263 | ||
2265 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2264 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2266 | 2265 | ||
2267 | //US topLayout->addWidget( mJumpButtonBar ); | 2266 | //US topLayout->addWidget( mJumpButtonBar ); |
2268 | this->layout()->add( mJumpButtonBar ); | 2267 | this->layout()->add( mJumpButtonBar ); |
2269 | */ | 2268 | */ |
2270 | 2269 | ||
2271 | #endif //KAB_EMBEDDED | 2270 | #endif //KAB_EMBEDDED |
2272 | 2271 | ||
2273 | mActionExport2phone->plug( ExportMenu ); | 2272 | mActionExport2phone->plug( ExportMenu ); |
2274 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2273 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2275 | syncManager->fillSyncMenu(); | 2274 | syncManager->fillSyncMenu(); |
2276 | 2275 | ||
2277 | } | 2276 | } |
2278 | void KABCore::showLicence() | 2277 | void KABCore::showLicence() |
2279 | { | 2278 | { |
2280 | KApplication::showLicence(); | 2279 | KApplication::showLicence(); |
2281 | } | 2280 | } |
2282 | 2281 | ||
2283 | void KABCore::manageCategories( ) | 2282 | void KABCore::manageCategories( ) |
2284 | { | 2283 | { |
2285 | KABCatPrefs* cp = new KABCatPrefs(); | 2284 | KABCatPrefs* cp = new KABCatPrefs(); |
2286 | cp->show(); | 2285 | cp->show(); |
2287 | int w =cp->sizeHint().width() ; | 2286 | int w =cp->sizeHint().width() ; |
2288 | int h = cp->sizeHint().height() ; | 2287 | int h = cp->sizeHint().height() ; |
2289 | int dw = QApplication::desktop()->width(); | 2288 | int dw = QApplication::desktop()->width(); |
2290 | int dh = QApplication::desktop()->height(); | 2289 | int dh = QApplication::desktop()->height(); |
2291 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2290 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2292 | if ( !cp->exec() ) { | 2291 | if ( !cp->exec() ) { |
2293 | delete cp; | 2292 | delete cp; |
2294 | return; | 2293 | return; |
2295 | } | 2294 | } |
2296 | int count = 0; | 2295 | int count = 0; |
2297 | message( i18n("Please wait, processing categories...")); | 2296 | message( i18n("Please wait, processing categories...")); |
2298 | if ( cp->addCat() ) { | 2297 | if ( cp->addCat() ) { |
2299 | KABC::AddressBook::Iterator it; | 2298 | KABC::AddressBook::Iterator it; |
2300 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2299 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2301 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2300 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2302 | QStringList catIncList = (*it).categories(); | 2301 | QStringList catIncList = (*it).categories(); |
2303 | int i; | 2302 | int i; |
2304 | for( i = 0; i< catIncList.count(); ++i ) { | 2303 | for( i = 0; i< catIncList.count(); ++i ) { |
2305 | if ( !catList.contains (catIncList[i])) { | 2304 | if ( !catList.contains (catIncList[i])) { |
2306 | catList.append( catIncList[i] ); | 2305 | catList.append( catIncList[i] ); |
2307 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2306 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2308 | ++count; | 2307 | ++count; |
2309 | } | 2308 | } |
2310 | } | 2309 | } |
2311 | } | 2310 | } |
2312 | catList.sort(); | 2311 | catList.sort(); |
2313 | KABPrefs::instance()->mCustomCategories = catList; | 2312 | KABPrefs::instance()->mCustomCategories = catList; |
2314 | KABPrefs::instance()->writeConfig(); | 2313 | KABPrefs::instance()->writeConfig(); |
2315 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2314 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2316 | } else { | 2315 | } else { |
2317 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2316 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2318 | QStringList catIncList; | 2317 | QStringList catIncList; |
2319 | QStringList newCatList; | 2318 | QStringList newCatList; |
2320 | KABC::AddressBook::Iterator it; | 2319 | KABC::AddressBook::Iterator it; |
2321 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2320 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2322 | QStringList catIncList = (*it).categories(); | 2321 | QStringList catIncList = (*it).categories(); |
2323 | int i; | 2322 | int i; |
2324 | if ( catIncList.count() ) { | 2323 | if ( catIncList.count() ) { |
2325 | newCatList.clear(); | 2324 | newCatList.clear(); |
2326 | for( i = 0; i< catIncList.count(); ++i ) { | 2325 | for( i = 0; i< catIncList.count(); ++i ) { |
2327 | if ( catList.contains (catIncList[i])) { | 2326 | if ( catList.contains (catIncList[i])) { |
2328 | newCatList.append( catIncList[i] ); | 2327 | newCatList.append( catIncList[i] ); |
2329 | } | 2328 | } |
2330 | } | 2329 | } |
2331 | newCatList.sort(); | 2330 | newCatList.sort(); |
2332 | (*it).setCategories( newCatList ); | 2331 | (*it).setCategories( newCatList ); |
2333 | mAddressBook->insertAddressee( (*it) ); | 2332 | mAddressBook->insertAddressee( (*it) ); |
2334 | } | 2333 | } |
2335 | } | 2334 | } |
2336 | setModified( true ); | 2335 | setModified( true ); |
2337 | mViewManager->refreshView(); | 2336 | mViewManager->refreshView(); |
2338 | message( i18n("Removing categories done!")); | 2337 | message( i18n("Removing categories done!")); |
2339 | } | 2338 | } |
2340 | delete cp; | 2339 | delete cp; |
2341 | } | 2340 | } |
2342 | void KABCore::removeVoice() | 2341 | void KABCore::removeVoice() |
2343 | { | 2342 | { |
2344 | 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 ) | 2343 | 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 ) |
2345 | return; | 2344 | return; |
2346 | KABC::Addressee::List list; | 2345 | KABC::Addressee::List list; |
2347 | XXPortSelectDialog dlg( this, false, this ); | 2346 | XXPortSelectDialog dlg( this, false, this ); |
2348 | if ( dlg.exec() ) | 2347 | if ( dlg.exec() ) |
2349 | list = dlg.contacts(); | 2348 | list = dlg.contacts(); |
2350 | else | 2349 | else |
2351 | return; | 2350 | return; |
2352 | KABC::Addressee::List::Iterator it; | 2351 | KABC::Addressee::List::Iterator it; |
2353 | for ( it = list.begin(); it != list.end(); ++it ) { | 2352 | for ( it = list.begin(); it != list.end(); ++it ) { |
2354 | if ( (*it).removeVoice() ) | 2353 | if ( (*it).removeVoice() ) |
2355 | addrModified((*it), false ); | 2354 | addrModified((*it), false ); |
2356 | } | 2355 | } |
2357 | } | 2356 | } |
2358 | 2357 | ||
2359 | void KABCore::setFormattedName() | 2358 | void KABCore::setFormattedName() |
2360 | { | 2359 | { |
2361 | KABFormatPrefs setpref; | 2360 | KABFormatPrefs setpref; |
2362 | if ( !setpref.exec() ) { | 2361 | if ( !setpref.exec() ) { |
2363 | return; | 2362 | return; |
2364 | } | 2363 | } |
2365 | KABC::Addressee::List list; | 2364 | KABC::Addressee::List list; |
2366 | XXPortSelectDialog dlg( this, false, this ); | 2365 | XXPortSelectDialog dlg( this, false, this ); |
2367 | if ( dlg.exec() ) | 2366 | if ( dlg.exec() ) |
2368 | list = dlg.contacts(); | 2367 | list = dlg.contacts(); |
2369 | else | 2368 | else |
2370 | return; | 2369 | return; |
2371 | KABC::Addressee::List::Iterator it; | 2370 | KABC::Addressee::List::Iterator it; |
2372 | for ( it = list.begin(); it != list.end(); ++it ) { | 2371 | for ( it = list.begin(); it != list.end(); ++it ) { |
2373 | QString fName; | 2372 | QString fName; |
2374 | if ( setpref.simple->isChecked() ) | 2373 | if ( setpref.simple->isChecked() ) |
2375 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2374 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2376 | else if ( setpref.full->isChecked() ) | 2375 | else if ( setpref.full->isChecked() ) |
2377 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2376 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2378 | else if ( setpref.reverse->isChecked() ) | 2377 | else if ( setpref.reverse->isChecked() ) |
2379 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2378 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2380 | else | 2379 | else |
2381 | fName = (*it).organization(); | 2380 | fName = (*it).organization(); |
2382 | if ( setpref.setCompany->isChecked() ) | 2381 | if ( setpref.setCompany->isChecked() ) |
2383 | if ( fName.isEmpty() || fName =="," ) | 2382 | if ( fName.isEmpty() || fName =="," ) |
2384 | fName = (*it).organization(); | 2383 | fName = (*it).organization(); |
2385 | (*it).setFormattedName( fName ); | 2384 | (*it).setFormattedName( fName ); |
2386 | addrModified((*it),false ); | 2385 | addrModified((*it),false ); |
2387 | } | 2386 | } |
2388 | Addressee add; | 2387 | Addressee add; |
2389 | mDetails->setAddressee( add ); | 2388 | mDetails->setAddressee( add ); |
2390 | } | 2389 | } |
2391 | 2390 | ||
2392 | void KABCore::clipboardDataChanged() | 2391 | void KABCore::clipboardDataChanged() |
2393 | { | 2392 | { |
2394 | 2393 | ||
2395 | if ( mReadWrite ) | 2394 | if ( mReadWrite ) |
2396 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2395 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2397 | 2396 | ||
2398 | } | 2397 | } |
2399 | 2398 | ||
2400 | void KABCore::updateActionMenu() | 2399 | void KABCore::updateActionMenu() |
2401 | { | 2400 | { |
2402 | UndoStack *undo = UndoStack::instance(); | 2401 | UndoStack *undo = UndoStack::instance(); |
2403 | RedoStack *redo = RedoStack::instance(); | 2402 | RedoStack *redo = RedoStack::instance(); |
2404 | 2403 | ||
2405 | if ( undo->isEmpty() ) | 2404 | if ( undo->isEmpty() ) |
2406 | mActionUndo->setText( i18n( "Undo" ) ); | 2405 | mActionUndo->setText( i18n( "Undo" ) ); |
2407 | else | 2406 | else |
2408 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2407 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2409 | 2408 | ||
2410 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2409 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2411 | 2410 | ||
2412 | if ( !redo->top() ) | 2411 | if ( !redo->top() ) |
2413 | mActionRedo->setText( i18n( "Redo" ) ); | 2412 | mActionRedo->setText( i18n( "Redo" ) ); |
2414 | else | 2413 | else |
2415 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2414 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2416 | 2415 | ||
2417 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2416 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2418 | } | 2417 | } |
2419 | 2418 | ||
2420 | void KABCore::configureKeyBindings() | 2419 | void KABCore::configureKeyBindings() |
2421 | { | 2420 | { |
2422 | #ifndef KAB_EMBEDDED | 2421 | #ifndef KAB_EMBEDDED |
2423 | KKeyDialog::configure( actionCollection(), true ); | 2422 | KKeyDialog::configure( actionCollection(), true ); |
2424 | #else //KAB_EMBEDDED | 2423 | #else //KAB_EMBEDDED |
2425 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2424 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2426 | #endif //KAB_EMBEDDED | 2425 | #endif //KAB_EMBEDDED |
2427 | } | 2426 | } |
2428 | 2427 | ||
2429 | #ifdef KAB_EMBEDDED | 2428 | #ifdef KAB_EMBEDDED |
2430 | void KABCore::configureResources() | 2429 | void KABCore::configureResources() |
2431 | { | 2430 | { |
2432 | KRES::KCMKResources dlg( this, "" , 0 ); | 2431 | KRES::KCMKResources dlg( this, "" , 0 ); |
2433 | 2432 | ||
2434 | if ( !dlg.exec() ) | 2433 | if ( !dlg.exec() ) |
2435 | return; | 2434 | return; |
2436 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2435 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2437 | } | 2436 | } |
2438 | #endif //KAB_EMBEDDED | 2437 | #endif //KAB_EMBEDDED |
2439 | 2438 | ||
2440 | 2439 | ||
2441 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2440 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2442 | * for the attendees list of an event. | 2441 | * for the attendees list of an event. |
2443 | */ | 2442 | */ |
2444 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2443 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2445 | { | 2444 | { |
2446 | QStringList nameList; | 2445 | QStringList nameList; |
2447 | QStringList emailList; | 2446 | QStringList emailList; |
2448 | QStringList uidList; | 2447 | QStringList uidList; |
2449 | 2448 | ||
2450 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2449 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2451 | uint i=0; | 2450 | uint i=0; |
2452 | for (i=0; i < list.count(); i++) | 2451 | for (i=0; i < list.count(); i++) |
2453 | { | 2452 | { |
2454 | nameList.append(list[i].realName()); | 2453 | nameList.append(list[i].realName()); |
2455 | emailList.append(list[i].preferredEmail()); | 2454 | emailList.append(list[i].preferredEmail()); |
2456 | uidList.append(list[i].uid()); | 2455 | uidList.append(list[i].uid()); |
2457 | } | 2456 | } |
2458 | 2457 | ||
2459 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2458 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2460 | 2459 | ||
2461 | } | 2460 | } |
2462 | 2461 | ||
2463 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2462 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2464 | * to put them into the calendar. | 2463 | * to put them into the calendar. |
2465 | */ | 2464 | */ |
2466 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2465 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2467 | { | 2466 | { |
2468 | // qDebug("KABCore::requestForBirthdayList"); | 2467 | // qDebug("KABCore::requestForBirthdayList"); |
2469 | QStringList birthdayList; | 2468 | QStringList birthdayList; |
2470 | QStringList anniversaryList; | 2469 | QStringList anniversaryList; |
2471 | QStringList realNameList; | 2470 | QStringList realNameList; |
2472 | QStringList preferredEmailList; | 2471 | QStringList preferredEmailList; |
2473 | QStringList assembledNameList; | 2472 | QStringList assembledNameList; |
2474 | QStringList uidList; | 2473 | QStringList uidList; |
2475 | 2474 | ||
2476 | KABC::AddressBook::Iterator it; | 2475 | KABC::AddressBook::Iterator it; |
2477 | 2476 | ||
2478 | int count = 0; | 2477 | int count = 0; |
2479 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2478 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2480 | ++count; | 2479 | ++count; |
2481 | } | 2480 | } |
2482 | QProgressBar bar(count,0 ); | 2481 | QProgressBar bar(count,0 ); |
2483 | int w = 300; | 2482 | int w = 300; |
2484 | if ( QApplication::desktop()->width() < 320 ) | 2483 | if ( QApplication::desktop()->width() < 320 ) |
2485 | w = 220; | 2484 | w = 220; |
2486 | int h = bar.sizeHint().height() ; | 2485 | int h = bar.sizeHint().height() ; |
2487 | int dw = QApplication::desktop()->width(); | 2486 | int dw = QApplication::desktop()->width(); |
2488 | int dh = QApplication::desktop()->height(); | 2487 | int dh = QApplication::desktop()->height(); |
2489 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2488 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2490 | bar.show(); | 2489 | bar.show(); |
2491 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2490 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2492 | qApp->processEvents(); | 2491 | qApp->processEvents(); |
2493 | 2492 | ||
2494 | QDate bday; | 2493 | QDate bday; |
2495 | QString anni; | 2494 | QString anni; |
2496 | QString formattedbday; | 2495 | QString formattedbday; |
2497 | 2496 | ||
2498 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2497 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2499 | { | 2498 | { |
2500 | if ( ! bar.isVisible() ) | 2499 | if ( ! bar.isVisible() ) |
2501 | return; | 2500 | return; |
2502 | bar.setProgress( count++ ); | 2501 | bar.setProgress( count++ ); |
2503 | qApp->processEvents(); | 2502 | qApp->processEvents(); |
2504 | bday = (*it).birthday().date(); | 2503 | bday = (*it).birthday().date(); |
2505 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2504 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2506 | 2505 | ||
2507 | if ( bday.isValid() || !anni.isEmpty()) | 2506 | if ( bday.isValid() || !anni.isEmpty()) |
2508 | { | 2507 | { |
2509 | if (bday.isValid()) | 2508 | if (bday.isValid()) |
2510 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2509 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2511 | else | 2510 | else |
2512 | formattedbday = "NOTVALID"; | 2511 | formattedbday = "NOTVALID"; |
2513 | if (anni.isEmpty()) | 2512 | if (anni.isEmpty()) |
2514 | anni = "INVALID"; | 2513 | anni = "INVALID"; |
2515 | 2514 | ||
2516 | birthdayList.append(formattedbday); | 2515 | birthdayList.append(formattedbday); |
2517 | anniversaryList.append(anni); //should be ISODate | 2516 | anniversaryList.append(anni); //should be ISODate |
2518 | realNameList.append((*it).realName()); | 2517 | realNameList.append((*it).realName()); |
2519 | preferredEmailList.append((*it).preferredEmail()); | 2518 | preferredEmailList.append((*it).preferredEmail()); |
2520 | assembledNameList.append((*it).assembledName()); | 2519 | assembledNameList.append((*it).assembledName()); |
2521 | uidList.append((*it).uid()); | 2520 | uidList.append((*it).uid()); |
2522 | 2521 | ||
2523 | //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() ); | 2522 | //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() ); |
2524 | } | 2523 | } |
2525 | } | 2524 | } |
2526 | 2525 | ||
2527 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2526 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2528 | 2527 | ||
2529 | } | 2528 | } |
2530 | 2529 | ||
2531 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2530 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2532 | */ | 2531 | */ |
2533 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2532 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2534 | { | 2533 | { |
2535 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2534 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2536 | 2535 | ||
2537 | QString foundUid = QString::null; | 2536 | QString foundUid = QString::null; |
2538 | if ( ! uid.isEmpty() ) { | 2537 | if ( ! uid.isEmpty() ) { |
2539 | Addressee adrr = mAddressBook->findByUid( uid ); | 2538 | Addressee adrr = mAddressBook->findByUid( uid ); |
2540 | if ( !adrr.isEmpty() ) { | 2539 | if ( !adrr.isEmpty() ) { |
2541 | foundUid = uid; | 2540 | foundUid = uid; |
2542 | } | 2541 | } |
2543 | if ( email == "sendbacklist" ) { | 2542 | if ( email == "sendbacklist" ) { |
2544 | //qDebug("ssssssssssssssssssssssend "); | 2543 | //qDebug("ssssssssssssssssssssssend "); |
2545 | QStringList nameList; | 2544 | QStringList nameList; |
2546 | QStringList emailList; | 2545 | QStringList emailList; |
2547 | QStringList uidList; | 2546 | QStringList uidList; |
2548 | nameList.append(adrr.realName()); | 2547 | nameList.append(adrr.realName()); |
2549 | emailList = adrr.emails(); | 2548 | emailList = adrr.emails(); |
2550 | uidList.append( adrr.preferredEmail()); | 2549 | uidList.append( adrr.preferredEmail()); |
2551 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2550 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2552 | return; | 2551 | return; |
2553 | } | 2552 | } |
2554 | 2553 | ||
2555 | } | 2554 | } |
2556 | 2555 | ||
2557 | if ( email == "sendbacklist" ) | 2556 | if ( email == "sendbacklist" ) |
2558 | return; | 2557 | return; |
2559 | if (foundUid.isEmpty()) | 2558 | if (foundUid.isEmpty()) |
2560 | { | 2559 | { |
2561 | //find the uid of the person first | 2560 | //find the uid of the person first |
2562 | Addressee::List namelist; | 2561 | Addressee::List namelist; |
2563 | Addressee::List emaillist; | 2562 | Addressee::List emaillist; |
2564 | 2563 | ||
2565 | if (!name.isEmpty()) | 2564 | if (!name.isEmpty()) |
2566 | namelist = mAddressBook->findByName( name ); | 2565 | namelist = mAddressBook->findByName( name ); |
2567 | 2566 | ||
2568 | if (!email.isEmpty()) | 2567 | if (!email.isEmpty()) |
2569 | emaillist = mAddressBook->findByEmail( email ); | 2568 | emaillist = mAddressBook->findByEmail( email ); |
2570 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2569 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2571 | //check if we have a match in Namelist and Emaillist | 2570 | //check if we have a match in Namelist and Emaillist |
2572 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2571 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2573 | foundUid = emaillist[0].uid(); | 2572 | foundUid = emaillist[0].uid(); |
2574 | } | 2573 | } |
2575 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2574 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2576 | foundUid = namelist[0].uid(); | 2575 | foundUid = namelist[0].uid(); |
2577 | else | 2576 | else |
2578 | { | 2577 | { |
2579 | for (int i = 0; i < namelist.count(); i++) | 2578 | for (int i = 0; i < namelist.count(); i++) |
2580 | { | 2579 | { |
2581 | for (int j = 0; j < emaillist.count(); j++) | 2580 | for (int j = 0; j < emaillist.count(); j++) |
2582 | { | 2581 | { |
2583 | if (namelist[i] == emaillist[j]) | 2582 | if (namelist[i] == emaillist[j]) |
2584 | { | 2583 | { |
2585 | foundUid = namelist[i].uid(); | 2584 | foundUid = namelist[i].uid(); |
2586 | } | 2585 | } |
2587 | } | 2586 | } |
2588 | } | 2587 | } |
2589 | } | 2588 | } |
2590 | } | 2589 | } |
2591 | else | 2590 | else |
2592 | { | 2591 | { |
2593 | foundUid = uid; | 2592 | foundUid = uid; |
2594 | } | 2593 | } |
2595 | 2594 | ||
2596 | if (!foundUid.isEmpty()) | 2595 | if (!foundUid.isEmpty()) |
2597 | { | 2596 | { |
2598 | 2597 | ||
2599 | // raise Ka/Pi if it is in the background | 2598 | // raise Ka/Pi if it is in the background |
2600 | #ifndef DESKTOP_VERSION | 2599 | #ifndef DESKTOP_VERSION |
2601 | #ifndef KORG_NODCOP | 2600 | #ifndef KORG_NODCOP |
2602 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2601 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2603 | #endif | 2602 | #endif |
2604 | #endif | 2603 | #endif |
2605 | 2604 | ||
2606 | mMainWindow->showMaximized(); | 2605 | mMainWindow->showMaximized(); |
2607 | mMainWindow-> raise(); | 2606 | mMainWindow-> raise(); |
2608 | 2607 | ||
2609 | mViewManager->setSelected( "", false); | 2608 | mViewManager->setSelected( "", false); |
2610 | mViewManager->refreshView( "" ); | 2609 | mViewManager->refreshView( "" ); |
2611 | mViewManager->setSelected( foundUid, true ); | 2610 | mViewManager->setSelected( foundUid, true ); |
2612 | mViewManager->refreshView( foundUid ); | 2611 | mViewManager->refreshView( foundUid ); |
2613 | 2612 | ||
2614 | if ( !mMultipleViewsAtOnce ) | 2613 | if ( !mMultipleViewsAtOnce ) |
2615 | { | 2614 | { |
2616 | setDetailsVisible( true ); | 2615 | setDetailsVisible( true ); |
2617 | mActionDetails->setChecked(true); | 2616 | mActionDetails->setChecked(true); |
2618 | } | 2617 | } |
2619 | } | 2618 | } |
2620 | } | 2619 | } |
2621 | 2620 | ||
2622 | void KABCore::whatsnew() | 2621 | void KABCore::whatsnew() |
2623 | { | 2622 | { |
2624 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2623 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2625 | } | 2624 | } |
2626 | void KABCore::synchowto() | 2625 | void KABCore::synchowto() |
2627 | { | 2626 | { |
2628 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2627 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2629 | } | 2628 | } |
2630 | void KABCore::kdesynchowto() | 2629 | void KABCore::kdesynchowto() |
2631 | { | 2630 | { |
2632 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2631 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2633 | } | 2632 | } |
2634 | void KABCore::multisynchowto() | 2633 | void KABCore::multisynchowto() |
2635 | { | 2634 | { |
2636 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2635 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2637 | } | 2636 | } |
2638 | void KABCore::faq() | 2637 | void KABCore::faq() |
2639 | { | 2638 | { |
2640 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2639 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2641 | } | 2640 | } |
2642 | 2641 | ||
2643 | #include <libkcal/syncdefines.h> | 2642 | #include <libkcal/syncdefines.h> |
2644 | 2643 | ||
2645 | KABC::Addressee KABCore::getLastSyncAddressee() | 2644 | KABC::Addressee KABCore::getLastSyncAddressee() |
2646 | { | 2645 | { |
2647 | Addressee lse; | 2646 | Addressee lse; |
2648 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2647 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2649 | 2648 | ||
2650 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2649 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2651 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2650 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2652 | if (lse.isEmpty()) { | 2651 | if (lse.isEmpty()) { |
2653 | qDebug("Creating new last-syncAddressee "); | 2652 | qDebug("Creating new last-syncAddressee "); |
2654 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2653 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2655 | QString sum = ""; | 2654 | QString sum = ""; |
2656 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2655 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2657 | sum = "E: "; | 2656 | sum = "E: "; |
2658 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2657 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2659 | lse.setRevision( mLastAddressbookSync ); | 2658 | lse.setRevision( mLastAddressbookSync ); |
2660 | lse.setCategories( i18n("SyncEvent") ); | 2659 | lse.setCategories( i18n("SyncEvent") ); |
2661 | mAddressBook->insertAddressee( lse ); | 2660 | mAddressBook->insertAddressee( lse ); |
2662 | } | 2661 | } |
2663 | return lse; | 2662 | return lse; |
2664 | } | 2663 | } |
2665 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2664 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2666 | { | 2665 | { |
2667 | 2666 | ||
2668 | //void setZaurusId(int id); | 2667 | //void setZaurusId(int id); |
2669 | // int zaurusId() const; | 2668 | // int zaurusId() const; |
2670 | // void setZaurusUid(int id); | 2669 | // void setZaurusUid(int id); |
2671 | // int zaurusUid() const; | 2670 | // int zaurusUid() const; |
2672 | // void setZaurusStat(int id); | 2671 | // void setZaurusStat(int id); |
2673 | // int zaurusStat() const; | 2672 | // int zaurusStat() const; |
2674 | // 0 equal | 2673 | // 0 equal |
2675 | // 1 take local | 2674 | // 1 take local |
2676 | // 2 take remote | 2675 | // 2 take remote |
2677 | // 3 cancel | 2676 | // 3 cancel |
2678 | QDateTime lastSync = mLastAddressbookSync; | 2677 | QDateTime lastSync = mLastAddressbookSync; |
2679 | QDateTime localMod = local->revision(); | 2678 | QDateTime localMod = local->revision(); |
2680 | QDateTime remoteMod = remote->revision(); | 2679 | QDateTime remoteMod = remote->revision(); |
2681 | 2680 | ||
2682 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2681 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2683 | 2682 | ||
2684 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2683 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2685 | bool remCh, locCh; | 2684 | bool remCh, locCh; |
2686 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2685 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2687 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2686 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2688 | locCh = ( localMod > mLastAddressbookSync ); | 2687 | locCh = ( localMod > mLastAddressbookSync ); |
2689 | if ( !remCh && ! locCh ) { | 2688 | if ( !remCh && ! locCh ) { |
2690 | //qDebug("both not changed "); | 2689 | //qDebug("both not changed "); |
2691 | lastSync = localMod.addDays(1); | 2690 | lastSync = localMod.addDays(1); |
2692 | if ( mode <= SYNC_PREF_ASK ) | 2691 | if ( mode <= SYNC_PREF_ASK ) |
2693 | return 0; | 2692 | return 0; |
2694 | } else { | 2693 | } else { |
2695 | if ( locCh ) { | 2694 | if ( locCh ) { |
2696 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2695 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2697 | lastSync = localMod.addDays( -1 ); | 2696 | lastSync = localMod.addDays( -1 ); |
2698 | if ( !remCh ) | 2697 | if ( !remCh ) |
2699 | remoteMod =( lastSync.addDays( -1 ) ); | 2698 | remoteMod =( lastSync.addDays( -1 ) ); |
2700 | } else { | 2699 | } else { |
2701 | //qDebug(" not loc changed "); | 2700 | //qDebug(" not loc changed "); |
2702 | lastSync = localMod.addDays( 1 ); | 2701 | lastSync = localMod.addDays( 1 ); |
2703 | if ( remCh ) { | 2702 | if ( remCh ) { |
2704 | //qDebug("rem changed "); | 2703 | //qDebug("rem changed "); |
2705 | remoteMod =( lastSync.addDays( 1 ) ); | 2704 | remoteMod =( lastSync.addDays( 1 ) ); |
2706 | } | 2705 | } |
2707 | 2706 | ||
2708 | } | 2707 | } |
2709 | } | 2708 | } |
2710 | full = true; | 2709 | full = true; |
2711 | if ( mode < SYNC_PREF_ASK ) | 2710 | if ( mode < SYNC_PREF_ASK ) |
2712 | mode = SYNC_PREF_ASK; | 2711 | mode = SYNC_PREF_ASK; |
2713 | } else { | 2712 | } else { |
2714 | if ( localMod == remoteMod ) | 2713 | if ( localMod == remoteMod ) |
2715 | return 0; | 2714 | return 0; |
2716 | 2715 | ||
2717 | } | 2716 | } |
2718 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2717 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2719 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2718 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2720 | //full = true; //debug only | 2719 | //full = true; //debug only |
2721 | if ( full ) { | 2720 | if ( full ) { |
2722 | bool equ = ( (*local) == (*remote) ); | 2721 | bool equ = ( (*local) == (*remote) ); |
2723 | if ( equ ) { | 2722 | if ( equ ) { |
2724 | //qDebug("equal "); | 2723 | //qDebug("equal "); |
2725 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2726 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2725 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2727 | } | 2726 | } |
2728 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2727 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2729 | return 0; | 2728 | return 0; |
2730 | 2729 | ||
2731 | }//else //debug only | 2730 | }//else //debug only |
2732 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2731 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2733 | } | 2732 | } |
2734 | int result; | 2733 | int result; |
2735 | bool localIsNew; | 2734 | bool localIsNew; |
2736 | //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() ); | 2735 | //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() ); |
2737 | 2736 | ||
2738 | if ( full && mode < SYNC_PREF_NEWEST ) | 2737 | if ( full && mode < SYNC_PREF_NEWEST ) |
2739 | mode = SYNC_PREF_ASK; | 2738 | mode = SYNC_PREF_ASK; |
2740 | 2739 | ||
2741 | switch( mode ) { | 2740 | switch( mode ) { |
2742 | case SYNC_PREF_LOCAL: | 2741 | case SYNC_PREF_LOCAL: |
2743 | if ( lastSync > remoteMod ) | 2742 | if ( lastSync > remoteMod ) |
2744 | return 1; | 2743 | return 1; |
2745 | if ( lastSync > localMod ) | 2744 | if ( lastSync > localMod ) |
2746 | return 2; | 2745 | return 2; |
2747 | return 1; | 2746 | return 1; |
2748 | break; | 2747 | break; |
2749 | case SYNC_PREF_REMOTE: | 2748 | case SYNC_PREF_REMOTE: |
2750 | if ( lastSync > remoteMod ) | 2749 | if ( lastSync > remoteMod ) |
2751 | return 1; | 2750 | return 1; |
2752 | if ( lastSync > localMod ) | 2751 | if ( lastSync > localMod ) |
2753 | return 2; | 2752 | return 2; |
2754 | return 2; | 2753 | return 2; |
2755 | break; | 2754 | break; |
2756 | case SYNC_PREF_NEWEST: | 2755 | case SYNC_PREF_NEWEST: |
2757 | if ( localMod > remoteMod ) | 2756 | if ( localMod > remoteMod ) |
2758 | return 1; | 2757 | return 1; |
2759 | else | 2758 | else |
2760 | return 2; | 2759 | return 2; |
2761 | break; | 2760 | break; |
2762 | case SYNC_PREF_ASK: | 2761 | case SYNC_PREF_ASK: |
2763 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2762 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2764 | if ( lastSync > remoteMod ) | 2763 | if ( lastSync > remoteMod ) |
2765 | return 1; | 2764 | return 1; |
2766 | if ( lastSync > localMod ) | 2765 | if ( lastSync > localMod ) |
2767 | return 2; | 2766 | return 2; |
2768 | localIsNew = localMod >= remoteMod; | 2767 | localIsNew = localMod >= remoteMod; |
2769 | //qDebug("conflict! ************************************** "); | 2768 | //qDebug("conflict! ************************************** "); |
2770 | { | 2769 | { |
2771 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2770 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2772 | result = acd.executeD(localIsNew); | 2771 | result = acd.executeD(localIsNew); |
2773 | return result; | 2772 | return result; |
2774 | } | 2773 | } |
2775 | break; | 2774 | break; |
2776 | case SYNC_PREF_FORCE_LOCAL: | 2775 | case SYNC_PREF_FORCE_LOCAL: |
2777 | return 1; | 2776 | return 1; |
2778 | break; | 2777 | break; |
2779 | case SYNC_PREF_FORCE_REMOTE: | 2778 | case SYNC_PREF_FORCE_REMOTE: |
2780 | return 2; | 2779 | return 2; |
2781 | break; | 2780 | break; |
2782 | 2781 | ||
2783 | default: | 2782 | default: |
2784 | // SYNC_PREF_TAKE_BOTH not implemented | 2783 | // SYNC_PREF_TAKE_BOTH not implemented |
2785 | break; | 2784 | break; |
2786 | } | 2785 | } |
2787 | return 0; | 2786 | return 0; |
2788 | } | 2787 | } |
2789 | 2788 | ||
2790 | 2789 | ||
2791 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2790 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2792 | { | 2791 | { |
2793 | bool syncOK = true; | 2792 | bool syncOK = true; |
2794 | int addedAddressee = 0; | 2793 | int addedAddressee = 0; |
2795 | int addedAddresseeR = 0; | 2794 | int addedAddresseeR = 0; |
2796 | int deletedAddresseeR = 0; | 2795 | int deletedAddresseeR = 0; |
2797 | int deletedAddresseeL = 0; | 2796 | int deletedAddresseeL = 0; |
2798 | int changedLocal = 0; | 2797 | int changedLocal = 0; |
2799 | int changedRemote = 0; | 2798 | int changedRemote = 0; |
2800 | 2799 | ||
2801 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2800 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2802 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2801 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2803 | 2802 | ||
2804 | //QPtrList<Addressee> el = local->rawAddressees(); | 2803 | //QPtrList<Addressee> el = local->rawAddressees(); |
2805 | Addressee addresseeR; | 2804 | Addressee addresseeR; |
2806 | QString uid; | 2805 | QString uid; |
2807 | int take; | 2806 | int take; |
2808 | Addressee addresseeL; | 2807 | Addressee addresseeL; |
2809 | Addressee addresseeRSync; | 2808 | Addressee addresseeRSync; |
2810 | Addressee addresseeLSync; | 2809 | Addressee addresseeLSync; |
2811 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2810 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2812 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2811 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2813 | bool fullDateRange = false; | 2812 | bool fullDateRange = false; |
2814 | local->resetTempSyncStat(); | 2813 | local->resetTempSyncStat(); |
2815 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2814 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2816 | if ( syncManager->syncWithDesktop() ) { | 2815 | if ( syncManager->syncWithDesktop() ) { |
2817 | // remote->removeSyncInfo( QString());//remove all info | 2816 | // remote->removeSyncInfo( QString());//remove all info |
2818 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2817 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2819 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2818 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2820 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2819 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2821 | } else { | 2820 | } else { |
2822 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2821 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2823 | } | 2822 | } |
2824 | } | 2823 | } |
2825 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2824 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2826 | addresseeLSync = getLastSyncAddressee(); | 2825 | addresseeLSync = getLastSyncAddressee(); |
2827 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2826 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2828 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2827 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2829 | if ( !addresseeR.isEmpty() ) { | 2828 | if ( !addresseeR.isEmpty() ) { |
2830 | addresseeRSync = addresseeR; | 2829 | addresseeRSync = addresseeR; |
2831 | remote->removeAddressee(addresseeR ); | 2830 | remote->removeAddressee(addresseeR ); |
2832 | 2831 | ||
2833 | } else { | 2832 | } else { |
2834 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2833 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2835 | addresseeRSync = addresseeLSync ; | 2834 | addresseeRSync = addresseeLSync ; |
2836 | } else { | 2835 | } else { |
2837 | //qDebug("FULLDATE 1"); | 2836 | //qDebug("FULLDATE 1"); |
2838 | fullDateRange = true; | 2837 | fullDateRange = true; |
2839 | Addressee newAdd; | 2838 | Addressee newAdd; |
2840 | addresseeRSync = newAdd; | 2839 | addresseeRSync = newAdd; |
2841 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2840 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2842 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2841 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2843 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2842 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2844 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2843 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2845 | } | 2844 | } |
2846 | } | 2845 | } |
2847 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2846 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2848 | // qDebug("FULLDATE 2"); | 2847 | // qDebug("FULLDATE 2"); |
2849 | fullDateRange = true; | 2848 | fullDateRange = true; |
2850 | } | 2849 | } |
2851 | if ( ! fullDateRange ) { | 2850 | if ( ! fullDateRange ) { |
2852 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2851 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2853 | 2852 | ||
2854 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2853 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2855 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2854 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2856 | fullDateRange = true; | 2855 | fullDateRange = true; |
2857 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2856 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2858 | } | 2857 | } |
2859 | } | 2858 | } |
2860 | // fullDateRange = true; // debug only! | 2859 | // fullDateRange = true; // debug only! |
2861 | if ( fullDateRange ) | 2860 | if ( fullDateRange ) |
2862 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2861 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2863 | else | 2862 | else |
2864 | mLastAddressbookSync = addresseeLSync.revision(); | 2863 | mLastAddressbookSync = addresseeLSync.revision(); |
2865 | // for resyncing if own file has changed | 2864 | // for resyncing if own file has changed |
2866 | // PENDING fixme later when implemented | 2865 | // PENDING fixme later when implemented |
2867 | #if 0 | 2866 | #if 0 |
2868 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2867 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2869 | mLastAddressbookSync = loadedFileVersion; | 2868 | mLastAddressbookSync = loadedFileVersion; |
2870 | qDebug("setting mLastAddressbookSync "); | 2869 | qDebug("setting mLastAddressbookSync "); |
2871 | } | 2870 | } |
2872 | #endif | 2871 | #endif |
2873 | 2872 | ||
2874 | 2873 | ||
2875 | // ********** setting filters **************** | 2874 | // ********** setting filters **************** |
2876 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); | 2875 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); |
2877 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); | 2876 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); |
2878 | 2877 | ||
2879 | //qDebug("*************************** "); | 2878 | //qDebug("*************************** "); |
2880 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2879 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2881 | QStringList er = remote->uidList(); | 2880 | QStringList er = remote->uidList(); |
2882 | Addressee inR ;//= er.first(); | 2881 | Addressee inR ;//= er.first(); |
2883 | Addressee inL; | 2882 | Addressee inL; |
2884 | 2883 | ||
2885 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2884 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2886 | 2885 | ||
2887 | int modulo = (er.count()/10)+1; | 2886 | int modulo = (er.count()/10)+1; |
2888 | int incCounter = 0; | 2887 | int incCounter = 0; |
2889 | while ( incCounter < er.count()) { | 2888 | while ( incCounter < er.count()) { |
2890 | if (syncManager->isProgressBarCanceled()) | 2889 | if (syncManager->isProgressBarCanceled()) |
2891 | return false; | 2890 | return false; |
2892 | if ( incCounter % modulo == 0 ) | 2891 | if ( incCounter % modulo == 0 ) |
2893 | syncManager->showProgressBar(incCounter); | 2892 | syncManager->showProgressBar(incCounter); |
2894 | 2893 | ||
2895 | uid = er[ incCounter ]; | 2894 | uid = er[ incCounter ]; |
2896 | bool skipIncidence = false; | 2895 | bool skipIncidence = false; |
2897 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2896 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2898 | skipIncidence = true; | 2897 | skipIncidence = true; |
2899 | QString idS,OidS; | 2898 | QString idS,OidS; |
2900 | qApp->processEvents(); | 2899 | qApp->processEvents(); |
2901 | if ( !skipIncidence ) { | 2900 | if ( !skipIncidence ) { |
2902 | inL = local->findByUid( uid ); | 2901 | inL = local->findByUid( uid ); |
2903 | inR = remote->findByUid( uid ); | 2902 | inR = remote->findByUid( uid ); |
2904 | //inL.setResource( 0 ); | 2903 | //inL.setResource( 0 ); |
2905 | //inR.setResource( 0 ); | 2904 | //inR.setResource( 0 ); |
2906 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2905 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2907 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2906 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2908 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { | 2907 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
2909 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2908 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2910 | if ( take == 3 ) | 2909 | if ( take == 3 ) |
2911 | return false; | 2910 | return false; |
2912 | if ( take == 1 ) {// take local ********************** | 2911 | if ( take == 1 ) {// take local ********************** |
2913 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2912 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2914 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2913 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2915 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2914 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2916 | local->insertAddressee( inL, false ); | 2915 | local->insertAddressee( inL, false ); |
2917 | idS = inR.externalUID(); | 2916 | idS = inR.externalUID(); |
2918 | OidS = inR.originalExternalUID(); | 2917 | OidS = inR.originalExternalUID(); |
2919 | } | 2918 | } |
2920 | else | 2919 | else |
2921 | idS = inR.IDStr(); | 2920 | idS = inR.IDStr(); |
2922 | remote->removeAddressee( inR ); | 2921 | remote->removeAddressee( inR ); |
2923 | inR = inL; | 2922 | inR = inL; |
2924 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2923 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2925 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2924 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2926 | inR.setOriginalExternalUID( OidS ); | 2925 | inR.setOriginalExternalUID( OidS ); |
2927 | inR.setExternalUID( idS ); | 2926 | inR.setExternalUID( idS ); |
2928 | if ( syncManager->syncWithDesktop() ) { | 2927 | if ( syncManager->syncWithDesktop() ) { |
2929 | inR.setIDStr("changed" ); | 2928 | inR.setIDStr("changed" ); |
2930 | } | 2929 | } |
2931 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 2930 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2932 | } else { | 2931 | } else { |
2933 | inR.setIDStr( idS ); | 2932 | inR.setIDStr( idS ); |
2934 | } | 2933 | } |
2935 | inR.setResource( 0 ); | 2934 | inR.setResource( 0 ); |
2936 | remote->insertAddressee( inR , false); | 2935 | remote->insertAddressee( inR , false); |
2937 | ++changedRemote; | 2936 | ++changedRemote; |
2938 | } else { // take == 2 take remote ********************** | 2937 | } else { // take == 2 take remote ********************** |
2939 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2938 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2940 | if ( inR.revision().date().year() < 2004 ) | 2939 | if ( inR.revision().date().year() < 2004 ) |
2941 | inR.setRevision( modifiedCalendar ); | 2940 | inR.setRevision( modifiedCalendar ); |
2942 | } | 2941 | } |
2943 | idS = inL.IDStr(); | 2942 | idS = inL.IDStr(); |
2944 | local->removeAddressee( inL ); | 2943 | local->removeAddressee( inL ); |
2945 | inL = inR; | 2944 | inL = inR; |
2946 | inL.setIDStr( idS ); | 2945 | inL.setIDStr( idS ); |
2947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2946 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2948 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2947 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2949 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2948 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2950 | } | 2949 | } |
2951 | inL.setResource( 0 ); | 2950 | inL.setResource( 0 ); |
2952 | local->insertAddressee( inL , false ); | 2951 | local->insertAddressee( inL , false ); |
2953 | ++changedLocal; | 2952 | ++changedLocal; |
2954 | } | 2953 | } |
2955 | } | 2954 | } |
2956 | } | 2955 | } |
2957 | } else { // no conflict ********** add or delete remote | 2956 | } else { // no conflict ********** add or delete remote |
2958 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { | 2957 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { |
2959 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2958 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2960 | QString des = addresseeLSync.note(); | 2959 | QString des = addresseeLSync.note(); |
2961 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2960 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2962 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2961 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2963 | remote->insertAddressee( inR, false ); | 2962 | remote->insertAddressee( inR, false ); |
2964 | ++deletedAddresseeR; | 2963 | ++deletedAddresseeR; |
2965 | } else { | 2964 | } else { |
2966 | inR.setRevision( modifiedCalendar ); | 2965 | inR.setRevision( modifiedCalendar ); |
2967 | remote->insertAddressee( inR, false ); | 2966 | remote->insertAddressee( inR, false ); |
2968 | inL = inR; | 2967 | inL = inR; |
2969 | inL.setIDStr( ":" ); | 2968 | inL.setIDStr( ":" ); |
2970 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2969 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2971 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2970 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2972 | inL.setResource( 0 ); | 2971 | inL.setResource( 0 ); |
2973 | local->insertAddressee( inL , false); | 2972 | local->insertAddressee( inL , false); |
2974 | ++addedAddressee; | 2973 | ++addedAddressee; |
2975 | } | 2974 | } |
2976 | } else { | 2975 | } else { |
2977 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2976 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2978 | inR.setRevision( modifiedCalendar ); | 2977 | inR.setRevision( modifiedCalendar ); |
2979 | remote->insertAddressee( inR, false ); | 2978 | remote->insertAddressee( inR, false ); |
2980 | inR.setResource( 0 ); | 2979 | inR.setResource( 0 ); |
2981 | local->insertAddressee( inR, false ); | 2980 | local->insertAddressee( inR, false ); |
2982 | ++addedAddressee; | 2981 | ++addedAddressee; |
2983 | } else { | 2982 | } else { |
2984 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2983 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2985 | remote->removeAddressee( inR ); | 2984 | remote->removeAddressee( inR ); |
2986 | ++deletedAddresseeR; | 2985 | ++deletedAddresseeR; |
2987 | } | 2986 | } |
2988 | } | 2987 | } |
2989 | } | 2988 | } |
2990 | } | 2989 | } |
2991 | } | 2990 | } |
2992 | ++incCounter; | 2991 | ++incCounter; |
2993 | } | 2992 | } |
2994 | er.clear(); | 2993 | er.clear(); |
2995 | QStringList el = local->uidList(); | 2994 | QStringList el = local->uidList(); |
2996 | modulo = (el.count()/10)+1; | 2995 | modulo = (el.count()/10)+1; |
2997 | 2996 | ||
2998 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2997 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2999 | incCounter = 0; | 2998 | incCounter = 0; |
3000 | while ( incCounter < el.count()) { | 2999 | while ( incCounter < el.count()) { |
3001 | qApp->processEvents(); | 3000 | qApp->processEvents(); |
3002 | if (syncManager->isProgressBarCanceled()) | 3001 | if (syncManager->isProgressBarCanceled()) |
3003 | return false; | 3002 | return false; |
3004 | if ( incCounter % modulo == 0 ) | 3003 | if ( incCounter % modulo == 0 ) |
3005 | syncManager->showProgressBar(incCounter); | 3004 | syncManager->showProgressBar(incCounter); |
3006 | uid = el[ incCounter ]; | 3005 | uid = el[ incCounter ]; |
3007 | bool skipIncidence = false; | 3006 | bool skipIncidence = false; |
3008 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3007 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3009 | skipIncidence = true; | 3008 | skipIncidence = true; |
3010 | if ( !filterOUT.name().isEmpty() && ! filterOUT.filterAddressee( inL ) ) | 3009 | if ( !filterOUT.name().isEmpty() && ! filterOUT.filterAddressee( inL ) ) |
3011 | skipIncidence = true; | 3010 | skipIncidence = true; |
3012 | if ( !skipIncidence ) { | 3011 | if ( !skipIncidence ) { |
3013 | inL = local->findByUid( uid ); | 3012 | inL = local->findByUid( uid ); |
3014 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3013 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3015 | inR = remote->findByUid( uid ); | 3014 | inR = remote->findByUid( uid ); |
3016 | if ( inR.isEmpty() ) { // no conflict ********** add or delete local | 3015 | if ( inR.isEmpty() ) { // no conflict ********** add or delete local |
3017 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3016 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3018 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3017 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3019 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3018 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3020 | local->removeAddressee( inL ); | 3019 | local->removeAddressee( inL ); |
3021 | ++deletedAddresseeL; | 3020 | ++deletedAddresseeL; |
3022 | } else { | 3021 | } else { |
3023 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3022 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3024 | inL.removeID(mCurrentSyncDevice ); | 3023 | inL.removeID(mCurrentSyncDevice ); |
3025 | ++addedAddresseeR; | 3024 | ++addedAddresseeR; |
3026 | inL.setRevision( modifiedCalendar ); | 3025 | inL.setRevision( modifiedCalendar ); |
3027 | local->insertAddressee( inL, false ); | 3026 | local->insertAddressee( inL, false ); |
3028 | inR = inL; | 3027 | inR = inL; |
3029 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3028 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3030 | inR.setResource( 0 ); | 3029 | inR.setResource( 0 ); |
3031 | remote->insertAddressee( inR, false ); | 3030 | remote->insertAddressee( inR, false ); |
3032 | } | 3031 | } |
3033 | } | 3032 | } |
3034 | } else { | 3033 | } else { |
3035 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3034 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3036 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3035 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3037 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3036 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3038 | local->removeAddressee( inL ); | 3037 | local->removeAddressee( inL ); |
3039 | ++deletedAddresseeL; | 3038 | ++deletedAddresseeL; |
3040 | } else { | 3039 | } else { |
3041 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3040 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3042 | ++addedAddresseeR; | 3041 | ++addedAddresseeR; |
3043 | inL.setRevision( modifiedCalendar ); | 3042 | inL.setRevision( modifiedCalendar ); |
3044 | local->insertAddressee( inL, false ); | 3043 | local->insertAddressee( inL, false ); |
3045 | inR = inL; | 3044 | inR = inL; |
3046 | inR.setIDStr( ":" ); | 3045 | inR.setIDStr( ":" ); |
3047 | inR.setResource( 0 ); | 3046 | inR.setResource( 0 ); |
3048 | remote->insertAddressee( inR, false ); | 3047 | remote->insertAddressee( inR, false ); |
3049 | } | 3048 | } |
3050 | } | 3049 | } |
3051 | } | 3050 | } |
3052 | } | 3051 | } |
3053 | } | 3052 | } |
3054 | } | 3053 | } |
3055 | ++incCounter; | 3054 | ++incCounter; |
3056 | } | 3055 | } |
3057 | el.clear(); | 3056 | el.clear(); |
3058 | syncManager->hideProgressBar(); | 3057 | syncManager->hideProgressBar(); |
3059 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3058 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3060 | // get rid of micro seconds | 3059 | // get rid of micro seconds |
3061 | QTime t = mLastAddressbookSync.time(); | 3060 | QTime t = mLastAddressbookSync.time(); |
3062 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3061 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3063 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3062 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3064 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3063 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3065 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3064 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3066 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3065 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3067 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3066 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3068 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3067 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3069 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3068 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3070 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3069 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3071 | addresseeRSync.setNote( "" ) ; | 3070 | addresseeRSync.setNote( "" ) ; |
3072 | addresseeLSync.setNote( "" ); | 3071 | addresseeLSync.setNote( "" ); |
3073 | 3072 | ||
3074 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3073 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3075 | remote->insertAddressee( addresseeRSync, false ); | 3074 | remote->insertAddressee( addresseeRSync, false ); |
3076 | local->insertAddressee( addresseeLSync, false ); | 3075 | local->insertAddressee( addresseeLSync, false ); |
3077 | QString mes; | 3076 | QString mes; |
3078 | 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 ); | 3077 | 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 ); |
3079 | qDebug( mes ); | 3078 | qDebug( mes ); |
3080 | mes = i18n("Local addressbook changed!\n") +mes; | 3079 | mes = i18n("Local addressbook changed!\n") +mes; |
3081 | if ( syncManager->mShowSyncSummary ) { | 3080 | if ( syncManager->mShowSyncSummary ) { |
3082 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3081 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3083 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3082 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3084 | qDebug("cancelled "); | 3083 | qDebug("cancelled "); |
3085 | return false; | 3084 | return false; |
3086 | } | 3085 | } |
3087 | } | 3086 | } |
3088 | return syncOK; | 3087 | return syncOK; |
3089 | } | 3088 | } |
3090 | 3089 | ||
3091 | 3090 | ||
3092 | //this is a overwritten callbackmethods from the syncinterface | 3091 | //this is a overwritten callbackmethods from the syncinterface |
3093 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3092 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
3094 | { | 3093 | { |
3095 | 3094 | ||
3096 | //pending prepare addresseeview for output | 3095 | //pending prepare addresseeview for output |
3097 | //pending detect, if remote file has REV field. if not switch to external sync | 3096 | //pending detect, if remote file has REV field. if not switch to external sync |
3098 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3097 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3099 | if ( manager != syncManager ) | 3098 | if ( manager != syncManager ) |
3100 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3099 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3101 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3100 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3102 | 3101 | ||
3103 | AddressBook abLocal(filename,"syncContact"); | 3102 | AddressBook abLocal(filename,"syncContact"); |
3104 | bool syncOK = false; | 3103 | bool syncOK = false; |
3105 | if ( abLocal.load() ) { | 3104 | if ( abLocal.load() ) { |
3106 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3105 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3107 | bool external = false; | 3106 | bool external = false; |
3108 | bool isXML = false; | 3107 | bool isXML = false; |
3109 | if ( filename.right(4) == ".xml") { | 3108 | if ( filename.right(4) == ".xml") { |
3110 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3109 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3111 | isXML = true; | 3110 | isXML = true; |
3112 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3111 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3113 | } else { | 3112 | } else { |
3114 | external = !manager->mIsKapiFile; | 3113 | external = !manager->mIsKapiFile; |
3115 | if ( external ) { | 3114 | if ( external ) { |
3116 | qDebug("Setting vcf mode to external "); | 3115 | qDebug("Setting vcf mode to external "); |
3117 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3116 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3118 | AddressBook::Iterator it; | 3117 | AddressBook::Iterator it; |
3119 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3118 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3120 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3119 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3121 | (*it).computeCsum( mCurrentSyncDevice ); | 3120 | (*it).computeCsum( mCurrentSyncDevice ); |
3122 | } | 3121 | } |
3123 | } | 3122 | } |
3124 | } | 3123 | } |
3125 | //AddressBook::Iterator it; | 3124 | //AddressBook::Iterator it; |
3126 | //QStringList vcards; | 3125 | //QStringList vcards; |
3127 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3126 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3128 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3127 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3129 | //} | 3128 | //} |
3130 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3129 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3131 | if ( syncOK ) { | 3130 | if ( syncOK ) { |
3132 | if ( syncManager->mWriteBackFile ) | 3131 | if ( syncManager->mWriteBackFile ) |
3133 | { | 3132 | { |
3134 | if ( external ) | 3133 | if ( external ) |
3135 | abLocal.removeSyncAddressees( !isXML); | 3134 | abLocal.removeSyncAddressees( !isXML); |
3136 | qDebug("Saving remote AB "); | 3135 | qDebug("Saving remote AB "); |
3137 | if ( ! abLocal.saveAB()) | 3136 | if ( ! abLocal.saveAB()) |
3138 | qDebug("Error writing back AB to file "); | 3137 | qDebug("Error writing back AB to file "); |
3139 | if ( external ) { | 3138 | if ( external ) { |
3140 | // afterwrite processing | 3139 | // afterwrite processing |
3141 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3140 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3142 | } | 3141 | } |
3143 | } | 3142 | } |
3144 | } | 3143 | } |
3145 | setModified(); | 3144 | setModified(); |
3146 | 3145 | ||
3147 | } | 3146 | } |
3148 | abLocal.removeResources(); | 3147 | abLocal.removeResources(); |
3149 | if ( syncOK ) | 3148 | if ( syncOK ) |
3150 | mViewManager->refreshView(); | 3149 | mViewManager->refreshView(); |
3151 | return syncOK; | 3150 | return syncOK; |
3152 | 3151 | ||
3153 | } | 3152 | } |
3154 | void KABCore::removeSyncInfo( QString syncProfile) | 3153 | void KABCore::removeSyncInfo( QString syncProfile) |
3155 | { | 3154 | { |
3156 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3155 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3157 | mAddressBook->removeSyncInfo( syncProfile ); | 3156 | mAddressBook->removeSyncInfo( syncProfile ); |
3158 | setModified(); | 3157 | setModified(); |
3159 | } | 3158 | } |
3160 | 3159 | ||
3161 | 3160 | ||
3162 | //this is a overwritten callbackmethods from the syncinterface | 3161 | //this is a overwritten callbackmethods from the syncinterface |
3163 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3162 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3164 | { | 3163 | { |
3165 | if ( resource == "phone" ) | 3164 | if ( resource == "phone" ) |
3166 | return syncPhone(); | 3165 | return syncPhone(); |
3167 | disableBR( true ); | 3166 | disableBR( true ); |
3168 | if ( manager != syncManager ) | 3167 | if ( manager != syncManager ) |
3169 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3168 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3170 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3169 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3171 | 3170 | ||
3172 | AddressBook abLocal( resource,"syncContact"); | 3171 | AddressBook abLocal( resource,"syncContact"); |
3173 | bool syncOK = false; | 3172 | bool syncOK = false; |
3174 | if ( abLocal.load() ) { | 3173 | if ( abLocal.load() ) { |
3175 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3174 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3176 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3175 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3177 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3176 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3178 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3177 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3179 | if ( syncOK ) { | 3178 | if ( syncOK ) { |
3180 | if ( syncManager->mWriteBackFile ) { | 3179 | if ( syncManager->mWriteBackFile ) { |
3181 | abLocal.removeSyncAddressees( false ); | 3180 | abLocal.removeSyncAddressees( false ); |
3182 | abLocal.saveAB(); | 3181 | abLocal.saveAB(); |
3183 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3182 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3184 | } | 3183 | } |
3185 | } else | 3184 | } else |
3186 | message( i18n("Sync cancelled or failed.") ); | 3185 | message( i18n("Sync cancelled or failed.") ); |
3187 | setModified(); | 3186 | setModified(); |
3188 | } | 3187 | } |
3189 | abLocal.removeResources(); | 3188 | abLocal.removeResources(); |
3190 | if ( syncOK ) | 3189 | if ( syncOK ) |
3191 | mViewManager->refreshView(); | 3190 | mViewManager->refreshView(); |
3192 | disableBR( false ); | 3191 | disableBR( false ); |
3193 | return syncOK; | 3192 | return syncOK; |
3194 | 3193 | ||
3195 | } | 3194 | } |
3196 | void KABCore::message( QString m ) | 3195 | void KABCore::message( QString m ) |
3197 | { | 3196 | { |
3198 | topLevelWidget()->setCaption( m ); | 3197 | topLevelWidget()->setCaption( m ); |
3199 | mMessageTimer->start( 15000, true ); | 3198 | mMessageTimer->start( 15000, true ); |
3200 | } | 3199 | } |
3201 | bool KABCore::syncPhone() | 3200 | bool KABCore::syncPhone() |
3202 | { | 3201 | { |
3203 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3202 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3204 | QString fileName = getPhoneFile(); | 3203 | QString fileName = getPhoneFile(); |
3205 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3204 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3206 | message(i18n("Phone access failed!")); | 3205 | message(i18n("Phone access failed!")); |
3207 | return false; | 3206 | return false; |
3208 | } | 3207 | } |
3209 | AddressBook abLocal( fileName,"syncContact"); | 3208 | AddressBook abLocal( fileName,"syncContact"); |
3210 | bool syncOK = false; | 3209 | bool syncOK = false; |
3211 | { | 3210 | { |
3212 | abLocal.importFromFile( fileName ); | 3211 | abLocal.importFromFile( fileName ); |
3213 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3212 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3214 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3213 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3215 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3214 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3216 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3215 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3217 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3216 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3218 | if ( syncOK ) { | 3217 | if ( syncOK ) { |
3219 | if ( syncManager->mWriteBackFile ) { | 3218 | if ( syncManager->mWriteBackFile ) { |
3220 | abLocal.removeSyncAddressees( true ); | 3219 | abLocal.removeSyncAddressees( true ); |
3221 | abLocal.saveABphone( fileName ); | 3220 | abLocal.saveABphone( fileName ); |
3222 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3221 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3223 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3222 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3224 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3223 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3225 | } | 3224 | } |
3226 | } | 3225 | } |
3227 | setModified(); | 3226 | setModified(); |
3228 | } | 3227 | } |
3229 | abLocal.removeResources(); | 3228 | abLocal.removeResources(); |
3230 | if ( syncOK ) | 3229 | if ( syncOK ) |
3231 | mViewManager->refreshView(); | 3230 | mViewManager->refreshView(); |
3232 | return syncOK; | 3231 | return syncOK; |
3233 | } | 3232 | } |
3234 | void KABCore::getFile( bool success ) | 3233 | void KABCore::getFile( bool success ) |
3235 | { | 3234 | { |
3236 | if ( ! success ) { | 3235 | if ( ! success ) { |
3237 | message( i18n("Error receiving file. Nothing changed!") ); | 3236 | message( i18n("Error receiving file. Nothing changed!") ); |
3238 | return; | 3237 | return; |
3239 | } | 3238 | } |
3240 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3239 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
3241 | if ( count ) | 3240 | if ( count ) |
3242 | setModified( true ); | 3241 | setModified( true ); |
3243 | message( i18n("Pi-Sync successful!") ); | 3242 | message( i18n("Pi-Sync successful!") ); |
3244 | mViewManager->refreshView(); | 3243 | mViewManager->refreshView(); |
3245 | } | 3244 | } |
3246 | void KABCore::syncFileRequest() | 3245 | void KABCore::syncFileRequest() |
3247 | { | 3246 | { |
3248 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3247 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3249 | syncManager->slotSyncMenu( 999 ); | 3248 | syncManager->slotSyncMenu( 999 ); |
3250 | } | 3249 | } |
3251 | mAddressBook->export2File( sentSyncFile() ); | 3250 | mAddressBook->export2File( sentSyncFile() ); |
3252 | } | 3251 | } |
3253 | QString KABCore::sentSyncFile() | 3252 | QString KABCore::sentSyncFile() |
3254 | { | 3253 | { |
3255 | #ifdef DESKTOP_VERSION | 3254 | #ifdef DESKTOP_VERSION |
3256 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3255 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3257 | #else | 3256 | #else |
3258 | return QString( "/tmp/copysyncab.vcf" ); | 3257 | return QString( "/tmp/copysyncab.vcf" ); |
3259 | #endif | 3258 | #endif |
3260 | } | 3259 | } |
3261 | 3260 | ||
3262 | void KABCore::setCaptionBack() | 3261 | void KABCore::setCaptionBack() |
3263 | { | 3262 | { |
3264 | mMessageTimer->stop(); | 3263 | mMessageTimer->stop(); |
3265 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 3264 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
3266 | } | 3265 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 0d5891e..ecfe6e9 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,518 +1,519 @@ | |||
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 | ||
41 | namespace KABC { | 41 | namespace KABC { |
42 | class AddressBook; | 42 | class AddressBook; |
43 | } | 43 | } |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | class KAboutData; | 46 | class KAboutData; |
47 | class KConfig; | 47 | class KConfig; |
48 | 48 | ||
49 | class KAddressBookService; | 49 | class KAddressBookService; |
50 | class LDAPSearchDialog; | 50 | class LDAPSearchDialog; |
51 | #else //KAB_EMBEDDED | 51 | #else //KAB_EMBEDDED |
52 | class KAddressBookMain; | 52 | class KAddressBookMain; |
53 | //US class QAction; | 53 | //US class QAction; |
54 | #endif //KAB_EMBEDDED | 54 | #endif //KAB_EMBEDDED |
55 | class KCMultiDialog; | 55 | class KCMultiDialog; |
56 | class KXMLGUIClient; | 56 | class KXMLGUIClient; |
57 | class ExtensionManager; | 57 | class ExtensionManager; |
58 | class XXPortManager; | 58 | class XXPortManager; |
59 | class JumpButtonBar; | 59 | class JumpButtonBar; |
60 | class IncSearchWidget; | 60 | class IncSearchWidget; |
61 | class KDGanttMinimizeSplitter; | 61 | class KDGanttMinimizeSplitter; |
62 | class KAction; | 62 | class KAction; |
63 | class KActionCollection; | 63 | class KActionCollection; |
64 | class KToggleAction; | 64 | class KToggleAction; |
65 | class KSyncProfile; | 65 | class KSyncProfile; |
66 | 66 | ||
67 | class QAction; | 67 | class QAction; |
68 | class QMenuBar; | 68 | class QMenuBar; |
69 | class QSplitter; | 69 | class QSplitter; |
70 | class ViewContainer; | 70 | class ViewContainer; |
71 | class ViewManager; | 71 | class ViewManager; |
72 | class AddresseeEditorDialog; | 72 | class AddresseeEditorDialog; |
73 | class Ir; | 73 | class Ir; |
74 | 74 | ||
75 | class KABCore : public QWidget, public KSyncInterface | 75 | class 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 | 99 | ||
100 | /** | 100 | /** |
101 | Returns a pointer to the StdAddressBook of the application. | 101 | Returns a pointer to the StdAddressBook of the application. |
102 | */ | 102 | */ |
103 | KABC::AddressBook *addressBook() const; | 103 | KABC::AddressBook *addressBook() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Returns a pointer to the KConfig object of the application. | 106 | Returns a pointer to the KConfig object of the application. |
107 | */ | 107 | */ |
108 | static KConfig *config(); | 108 | static KConfig *config(); |
109 | 109 | ||
110 | /** | 110 | /** |
111 | Returns a pointer to the global KActionCollection object. So | 111 | Returns a pointer to the global KActionCollection object. So |
112 | other classes can register their actions easily. | 112 | other classes can register their actions easily. |
113 | */ | 113 | */ |
114 | KActionCollection *actionCollection() const; | 114 | KActionCollection *actionCollection() const; |
115 | 115 | ||
116 | /** | 116 | /** |
117 | Returns the current search field of the Incremental Search Widget. | 117 | Returns the current search field of the Incremental Search Widget. |
118 | */ | 118 | */ |
119 | KABC::Field *currentSearchField() const; | 119 | KABC::Field *currentSearchField() const; |
120 | 120 | ||
121 | /** | 121 | /** |
122 | Returns the uid list of the currently selected contacts. | 122 | Returns the uid list of the currently selected contacts. |
123 | */ | 123 | */ |
124 | QStringList selectedUIDs() const; | 124 | QStringList selectedUIDs() const; |
125 | 125 | ||
126 | /** | 126 | /** |
127 | Displays the ResourceSelectDialog and returns the selected | 127 | Displays the ResourceSelectDialog and returns the selected |
128 | resource or a null pointer if no resource was selected by | 128 | resource or a null pointer if no resource was selected by |
129 | the user. | 129 | the user. |
130 | */ | 130 | */ |
131 | KABC::Resource *requestResource( QWidget *parent ); | 131 | KABC::Resource *requestResource( QWidget *parent ); |
132 | 132 | ||
133 | #ifndef KAB_EMBEDDED | 133 | #ifndef KAB_EMBEDDED |
134 | static KAboutData *createAboutData(); | 134 | static KAboutData *createAboutData(); |
135 | #endif //KAB_EMBEDDED | 135 | #endif //KAB_EMBEDDED |
136 | 136 | ||
137 | #ifdef KAB_EMBEDDED | 137 | #ifdef KAB_EMBEDDED |
138 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 138 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
139 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 139 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
140 | #endif //KAB_EMBEDDED | 140 | #endif //KAB_EMBEDDED |
141 | 141 | ||
142 | public slots: | 142 | public slots: |
143 | #ifdef KAB_EMBEDDED | 143 | #ifdef KAB_EMBEDDED |
144 | void createAboutData(); | 144 | void createAboutData(); |
145 | #endif //KAB_EMBEDDED | 145 | #endif //KAB_EMBEDDED |
146 | void setDetailsToggle(); | 146 | void setDetailsToggle(); |
147 | 147 | ||
148 | void showLicence(); | 148 | void showLicence(); |
149 | void faq(); | 149 | void faq(); |
150 | void whatsnew() ; | 150 | void whatsnew() ; |
151 | void synchowto() ; | 151 | void synchowto() ; |
152 | void multisynchowto() ; | 152 | void multisynchowto() ; |
153 | void kdesynchowto() ; | 153 | void kdesynchowto() ; |
154 | void writeToPhone(); | 154 | void writeToPhone(); |
155 | 155 | ||
156 | /** | 156 | /** |
157 | Is called whenever a contact is selected in the view. | 157 | Is called whenever a contact is selected in the view. |
158 | */ | 158 | */ |
159 | void setContactSelected( const QString &uid ); | 159 | void setContactSelected( const QString &uid ); |
160 | 160 | ||
161 | /** | 161 | /** |
162 | Opens the preferred mail composer with all selected contacts as | 162 | Opens the preferred mail composer with all selected contacts as |
163 | arguments. | 163 | arguments. |
164 | */ | 164 | */ |
165 | void sendMail(); | 165 | void sendMail(); |
166 | 166 | ||
167 | /** | 167 | /** |
168 | Opens the preferred mail composer with the given contacts as | 168 | Opens the preferred mail composer with the given contacts as |
169 | arguments. | 169 | arguments. |
170 | */ | 170 | */ |
171 | void sendMail( const QString& email ); | 171 | void sendMail( const QString& email ); |
172 | 172 | ||
173 | 173 | ||
174 | void mailVCard(); | 174 | void mailVCard(); |
175 | void mailVCard(const QStringList& uids); | 175 | void mailVCard(const QStringList& uids); |
176 | 176 | ||
177 | /** | 177 | /** |
178 | Beams the "WhoAmI contact. | 178 | Beams the "WhoAmI contact. |
179 | */ | 179 | */ |
180 | void beamMySelf(); | 180 | void beamMySelf(); |
181 | 181 | ||
182 | void beamVCard(); | 182 | void beamVCard(); |
183 | void export2phone(); | 183 | void export2phone(); |
184 | void beamVCard(const QStringList& uids); | 184 | void beamVCard(const QStringList& uids); |
185 | void beamDone( Ir *ir ); | 185 | void beamDone( Ir *ir ); |
186 | 186 | ||
187 | 187 | ||
188 | /** | 188 | /** |
189 | Starts the preferred web browser with the given URL as argument. | 189 | Starts the preferred web browser with the given URL as argument. |
190 | */ | 190 | */ |
191 | void browse( const QString& url ); | 191 | void browse( const QString& url ); |
192 | 192 | ||
193 | /** | 193 | /** |
194 | Select all contacts in the view. | 194 | Select all contacts in the view. |
195 | */ | 195 | */ |
196 | void selectAllContacts(); | 196 | void selectAllContacts(); |
197 | 197 | ||
198 | /** | 198 | /** |
199 | Deletes all selected contacts from the address book. | 199 | Deletes all selected contacts from the address book. |
200 | */ | 200 | */ |
201 | void deleteContacts(); | 201 | void deleteContacts(); |
202 | 202 | ||
203 | /** | 203 | /** |
204 | Deletes given contacts from the address book. | 204 | Deletes given contacts from the address book. |
205 | 205 | ||
206 | @param uids The uids of the contacts, which shall be deleted. | 206 | @param uids The uids of the contacts, which shall be deleted. |
207 | */ | 207 | */ |
208 | void deleteContacts( const QStringList &uids ); | 208 | void deleteContacts( const QStringList &uids ); |
209 | 209 | ||
210 | /** | 210 | /** |
211 | Copys the selected contacts into clipboard for later pasting. | 211 | Copys the selected contacts into clipboard for later pasting. |
212 | */ | 212 | */ |
213 | void copyContacts(); | 213 | void copyContacts(); |
214 | 214 | ||
215 | /** | 215 | /** |
216 | Cuts the selected contacts and stores them for later pasting. | 216 | Cuts the selected contacts and stores them for later pasting. |
217 | */ | 217 | */ |
218 | void cutContacts(); | 218 | void cutContacts(); |
219 | 219 | ||
220 | /** | 220 | /** |
221 | Paste contacts from clipboard into the address book. | 221 | Paste contacts from clipboard into the address book. |
222 | */ | 222 | */ |
223 | void pasteContacts(); | 223 | void pasteContacts(); |
224 | 224 | ||
225 | /** | 225 | /** |
226 | Paste given contacts into the address book. | 226 | Paste given contacts into the address book. |
227 | 227 | ||
228 | @param list The list of addressee, which shall be pasted. | 228 | @param list The list of addressee, which shall be pasted. |
229 | */ | 229 | */ |
230 | void pasteContacts( KABC::Addressee::List &list ); | 230 | void pasteContacts( KABC::Addressee::List &list ); |
231 | 231 | ||
232 | /** | 232 | /** |
233 | 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 |
234 | get personal information about the current user. | 234 | get personal information about the current user. |
235 | */ | 235 | */ |
236 | void setWhoAmI(); | 236 | void setWhoAmI(); |
237 | 237 | ||
238 | /** | 238 | /** |
239 | Displays the category dialog and applies the result to all | 239 | Displays the category dialog and applies the result to all |
240 | selected contacts. | 240 | selected contacts. |
241 | */ | 241 | */ |
242 | void setCategories(); | 242 | void setCategories(); |
243 | void manageCategories(); | 243 | void manageCategories(); |
244 | void editCategories(); | 244 | void editCategories(); |
245 | 245 | ||
246 | /** | 246 | /** |
247 | Sets the field list of the Incremental Search Widget. | 247 | Sets the field list of the Incremental Search Widget. |
248 | */ | 248 | */ |
249 | void setSearchFields( const KABC::Field::List &fields ); | 249 | void setSearchFields( const KABC::Field::List &fields ); |
250 | 250 | ||
251 | /** | 251 | /** |
252 | Search with the current search field for a contact, that matches | 252 | Search with the current search field for a contact, that matches |
253 | the given text, and selects it in the view. | 253 | the given text, and selects it in the view. |
254 | */ | 254 | */ |
255 | void incrementalSearch( const QString& text ); | 255 | void incrementalSearch( const QString& text ); |
256 | 256 | ||
257 | /** | 257 | /** |
258 | Marks the address book as modified. | 258 | Marks the address book as modified. |
259 | */ | 259 | */ |
260 | void setModified(); | 260 | void setModified(); |
261 | /** | 261 | /** |
262 | Marks the address book as modified without refreshing the view. | 262 | Marks the address book as modified without refreshing the view. |
263 | */ | 263 | */ |
264 | void setModifiedWOrefresh(); | 264 | void setModifiedWOrefresh(); |
265 | 265 | ||
266 | /** | 266 | /** |
267 | Marks the address book as modified concerning the argument. | 267 | Marks the address book as modified concerning the argument. |
268 | */ | 268 | */ |
269 | void setModified( bool modified ); | 269 | void setModified( bool modified ); |
270 | 270 | ||
271 | /** | 271 | /** |
272 | Returns whether the address book is modified. | 272 | Returns whether the address book is modified. |
273 | */ | 273 | */ |
274 | bool modified() const; | 274 | bool modified() const; |
275 | 275 | ||
276 | /** | 276 | /** |
277 | Called whenever an contact is modified in the contact editor | 277 | Called whenever an contact is modified in the contact editor |
278 | dialog or the quick edit. | 278 | dialog or the quick edit. |
279 | */ | 279 | */ |
280 | void contactModified( const KABC::Addressee &addr ); | 280 | void contactModified( const KABC::Addressee &addr ); |
281 | void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); | 281 | void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); |
282 | 282 | ||
283 | /** | 283 | /** |
284 | DCOP METHODS. | 284 | DCOP METHODS. |
285 | */ | 285 | */ |
286 | void addEmail( QString addr ); | 286 | void addEmail( QString addr ); |
287 | void importVCard( const KURL& url, bool showPreview ); | 287 | void importVCard( const KURL& url, bool showPreview ); |
288 | void importVCard( const QString& vCard, bool showPreview ); | 288 | void importVCard( const QString& vCard, bool showPreview ); |
289 | void newContact(); | 289 | void newContact(); |
290 | QString getNameByPhone( const QString& phone ); | 290 | QString getNameByPhone( const QString& phone ); |
291 | /** | 291 | /** |
292 | END DCOP METHODS | 292 | END DCOP METHODS |
293 | */ | 293 | */ |
294 | 294 | ||
295 | /** | 295 | /** |
296 | Saves the contents of the AddressBook back to disk. | 296 | Saves the contents of the AddressBook back to disk. |
297 | */ | 297 | */ |
298 | void save(); | 298 | void save(); |
299 | 299 | ||
300 | /** | 300 | /** |
301 | Undos the last command using the undo stack. | 301 | Undos the last command using the undo stack. |
302 | */ | 302 | */ |
303 | void undo(); | 303 | void undo(); |
304 | 304 | ||
305 | /** | 305 | /** |
306 | Redos the last command that was undone, using the redo stack. | 306 | Redos the last command that was undone, using the redo stack. |
307 | */ | 307 | */ |
308 | void redo(); | 308 | void redo(); |
309 | 309 | ||
310 | /** | 310 | /** |
311 | Shows the edit dialog for the given uid. If the uid is QString::null, | 311 | Shows the edit dialog for the given uid. If the uid is QString::null, |
312 | the method will try to find a selected addressee in the view. | 312 | the method will try to find a selected addressee in the view. |
313 | */ | 313 | */ |
314 | void editContact( const QString &uid /*US = QString::null*/ ); | 314 | void editContact( const QString &uid /*US = QString::null*/ ); |
315 | //US added a second method without defaultparameter | 315 | //US added a second method without defaultparameter |
316 | void editContact2(); | 316 | void editContact2(); |
317 | 317 | ||
318 | /** | 318 | /** |
319 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 319 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
320 | the method will try to find a selected addressee in the view. | 320 | the method will try to find a selected addressee in the view. |
321 | */ | 321 | */ |
322 | void executeContact( const QString &uid /*US = QString::null*/ ); | 322 | void executeContact( const QString &uid /*US = QString::null*/ ); |
323 | 323 | ||
324 | /** | 324 | /** |
325 | Launches the configuration dialog. | 325 | Launches the configuration dialog. |
326 | */ | 326 | */ |
327 | void openConfigDialog(); | 327 | void openConfigDialog(); |
328 | 328 | ||
329 | /** | 329 | /** |
330 | Launches the ldap search dialog. | 330 | Launches the ldap search dialog. |
331 | */ | 331 | */ |
332 | void openLDAPDialog(); | 332 | void openLDAPDialog(); |
333 | 333 | ||
334 | /** | 334 | /** |
335 | Creates a KAddressBookPrinter, which will display the print | 335 | Creates a KAddressBookPrinter, which will display the print |
336 | dialog and do the printing. | 336 | dialog and do the printing. |
337 | */ | 337 | */ |
338 | void print(); | 338 | void print(); |
339 | 339 | ||
340 | /** | 340 | /** |
341 | Registers a new GUI client, so plugins can register its actions. | 341 | Registers a new GUI client, so plugins can register its actions. |
342 | */ | 342 | */ |
343 | void addGUIClient( KXMLGUIClient *client ); | 343 | void addGUIClient( KXMLGUIClient *client ); |
344 | 344 | ||
345 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 345 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
346 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 346 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
347 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); | 347 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |
348 | 348 | ||
349 | 349 | ||
350 | signals: | 350 | signals: |
351 | void contactSelected( const QString &name ); | 351 | void contactSelected( const QString &name ); |
352 | void contactSelected( const QPixmap &pixmap ); | 352 | void contactSelected( const QPixmap &pixmap ); |
353 | public slots: | 353 | public slots: |
354 | void recieve(QString cmsg ); | 354 | void recieve(QString cmsg ); |
355 | void getFile( bool success ); | 355 | void getFile( bool success ); |
356 | void syncFileRequest(); | 356 | void syncFileRequest(); |
357 | void setDetailsVisible( bool visible ); | 357 | void setDetailsVisible( bool visible ); |
358 | void setDetailsToState(); | 358 | void setDetailsToState(); |
359 | 359 | ||
360 | void saveSettings(); | 360 | void saveSettings(); |
361 | 361 | ||
362 | private slots: | 362 | private slots: |
363 | void updateToolBar(); | 363 | void updateToolBar(); |
364 | void updateMainWindow(); | 364 | void updateMainWindow(); |
365 | void receive( const QCString& cmsg, const QByteArray& data ); | 365 | void receive( const QCString& cmsg, const QByteArray& data ); |
366 | void toggleBeamReceive( ); | 366 | void toggleBeamReceive( ); |
367 | void disableBR(bool); | 367 | void disableBR(bool); |
368 | void setJumpButtonBarVisible( bool visible ); | 368 | void setJumpButtonBarVisible( bool visible ); |
369 | void setCaptionBack(); | 369 | void setCaptionBack(); |
370 | void importFromOL(); | 370 | void importFromOL(); |
371 | void extensionModified( const KABC::Addressee::List &list ); | 371 | void extensionModified( const KABC::Addressee::List &list ); |
372 | void extensionChanged( int id ); | 372 | void extensionChanged( int id ); |
373 | void clipboardDataChanged(); | 373 | void clipboardDataChanged(); |
374 | void updateActionMenu(); | 374 | void updateActionMenu(); |
375 | void configureKeyBindings(); | 375 | void configureKeyBindings(); |
376 | void removeVoice(); | 376 | void removeVoice(); |
377 | void setFormattedName(); | 377 | void setFormattedName(); |
378 | #ifdef KAB_EMBEDDED | 378 | #ifdef KAB_EMBEDDED |
379 | void configureResources(); | 379 | void configureResources(); |
380 | #endif //KAB_EMBEDDED | 380 | #endif //KAB_EMBEDDED |
381 | 381 | ||
382 | void slotEditorDestroyed( const QString &uid ); | 382 | void slotEditorDestroyed( const QString &uid ); |
383 | void configurationChanged(); | 383 | void configurationChanged(); |
384 | void addressBookChanged(); | 384 | void addressBookChanged(); |
385 | 385 | ||
386 | private: | 386 | private: |
387 | void resizeEvent(QResizeEvent* e ); | 387 | void resizeEvent(QResizeEvent* e ); |
388 | bool mBRdisabled; | 388 | bool mBRdisabled; |
389 | #ifndef DESKTOP_VERSION | 389 | #ifndef DESKTOP_VERSION |
390 | QCopChannel* infrared; | 390 | QCopChannel* infrared; |
391 | #endif | 391 | #endif |
392 | QTimer *mMessageTimer; | 392 | QTimer *mMessageTimer; |
393 | void initGUI(); | 393 | void initGUI(); |
394 | void initActions(); | 394 | void initActions(); |
395 | QString getPhoneFile(); | 395 | QString getPhoneFile(); |
396 | 396 | ||
397 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 397 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
398 | const char *name = 0 ); | 398 | const char *name = 0 ); |
399 | 399 | ||
400 | KXMLGUIClient *mGUIClient; | 400 | KXMLGUIClient *mGUIClient; |
401 | 401 | ||
402 | KABC::AddressBook *mAddressBook; | 402 | KABC::AddressBook *mAddressBook; |
403 | 403 | ||
404 | ViewManager *mViewManager; | 404 | ViewManager *mViewManager; |
405 | // QSplitter *mDetailsSplitter; | 405 | // QSplitter *mDetailsSplitter; |
406 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 406 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
407 | ViewContainer *mDetails; | 407 | ViewContainer *mDetails; |
408 | KDGanttMinimizeSplitter* mMiniSplitter; | 408 | KDGanttMinimizeSplitter* mMiniSplitter; |
409 | XXPortManager *mXXPortManager; | 409 | XXPortManager *mXXPortManager; |
410 | JumpButtonBar *mJumpButtonBar; | 410 | JumpButtonBar *mJumpButtonBar; |
411 | IncSearchWidget *mIncSearchWidget; | 411 | IncSearchWidget *mIncSearchWidget; |
412 | ExtensionManager *mExtensionManager; | 412 | ExtensionManager *mExtensionManager; |
413 | 413 | ||
414 | KCMultiDialog *mConfigureDialog; | 414 | KCMultiDialog *mConfigureDialog; |
415 | 415 | ||
416 | #ifndef KAB_EMBEDDED | 416 | #ifndef KAB_EMBEDDED |
417 | LDAPSearchDialog *mLdapSearchDialog; | 417 | LDAPSearchDialog *mLdapSearchDialog; |
418 | #endif //KAB_EMBEDDED | 418 | #endif //KAB_EMBEDDED |
419 | // QDict<AddresseeEditorDialog> mEditorDict; | 419 | // QDict<AddresseeEditorDialog> mEditorDict; |
420 | AddresseeEditorDialog *mEditorDialog; | 420 | AddresseeEditorDialog *mEditorDialog; |
421 | bool mReadWrite; | 421 | bool mReadWrite; |
422 | bool mModified; | 422 | bool mModified; |
423 | bool mIsPart; | 423 | bool mIsPart; |
424 | bool mMultipleViewsAtOnce; | 424 | bool mMultipleViewsAtOnce; |
425 | 425 | ||
426 | 426 | ||
427 | //US file menu | 427 | //US file menu |
428 | KAction *mActionMail; | 428 | KAction *mActionMail; |
429 | KAction *mActionBeam; | 429 | KAction *mActionBeam; |
430 | KToggleAction *mActionBR; | 430 | KToggleAction *mActionBR; |
431 | KAction *mActionExport2phone; | 431 | KAction *mActionExport2phone; |
432 | KAction* mActionPrint; | 432 | KAction* mActionPrint; |
433 | KAction* mActionPrintDetails; | ||
433 | KAction* mActionNewContact; | 434 | KAction* mActionNewContact; |
434 | KAction *mActionSave; | 435 | KAction *mActionSave; |
435 | KAction *mActionEditAddressee; | 436 | KAction *mActionEditAddressee; |
436 | KAction *mActionMailVCard; | 437 | KAction *mActionMailVCard; |
437 | KAction *mActionBeamVCard; | 438 | KAction *mActionBeamVCard; |
438 | 439 | ||
439 | KAction *mActionQuit; | 440 | KAction *mActionQuit; |
440 | 441 | ||
441 | //US edit menu | 442 | //US edit menu |
442 | KAction *mActionCopy; | 443 | KAction *mActionCopy; |
443 | KAction *mActionCut; | 444 | KAction *mActionCut; |
444 | KAction *mActionPaste; | 445 | KAction *mActionPaste; |
445 | KAction *mActionSelectAll; | 446 | KAction *mActionSelectAll; |
446 | KAction *mActionUndo; | 447 | KAction *mActionUndo; |
447 | KAction *mActionRedo; | 448 | KAction *mActionRedo; |
448 | KAction *mActionDelete; | 449 | KAction *mActionDelete; |
449 | 450 | ||
450 | //US settings menu | 451 | //US settings menu |
451 | KAction *mActionConfigResources; | 452 | KAction *mActionConfigResources; |
452 | KAction *mActionConfigKAddressbook; | 453 | KAction *mActionConfigKAddressbook; |
453 | KAction *mActionConfigShortcuts; | 454 | KAction *mActionConfigShortcuts; |
454 | KAction *mActionConfigureToolbars; | 455 | KAction *mActionConfigureToolbars; |
455 | KAction *mActionKeyBindings; | 456 | KAction *mActionKeyBindings; |
456 | KToggleAction *mActionJumpBar; | 457 | KToggleAction *mActionJumpBar; |
457 | KToggleAction *mActionDetails; | 458 | KToggleAction *mActionDetails; |
458 | KAction *mActionWhoAmI; | 459 | KAction *mActionWhoAmI; |
459 | KAction *mActionCategories; | 460 | KAction *mActionCategories; |
460 | KAction *mActionEditCategories; | 461 | KAction *mActionEditCategories; |
461 | KAction *mActionManageCategories; | 462 | KAction *mActionManageCategories; |
462 | KAction *mActionAboutKAddressbook; | 463 | KAction *mActionAboutKAddressbook; |
463 | KAction *mActionLicence; | 464 | KAction *mActionLicence; |
464 | KAction *mActionFaq; | 465 | KAction *mActionFaq; |
465 | KAction *mActionWN; | 466 | KAction *mActionWN; |
466 | KAction *mActionSyncHowto; | 467 | KAction *mActionSyncHowto; |
467 | KAction *mActionKdeSyncHowto; | 468 | KAction *mActionKdeSyncHowto; |
468 | KAction *mActionMultiSyncHowto; | 469 | KAction *mActionMultiSyncHowto; |
469 | 470 | ||
470 | KAction *mActionDeleteView; | 471 | KAction *mActionDeleteView; |
471 | 472 | ||
472 | QPopupMenu *viewMenu; | 473 | QPopupMenu *viewMenu; |
473 | QPopupMenu *filterMenu; | 474 | QPopupMenu *filterMenu; |
474 | QPopupMenu *settingsMenu; | 475 | QPopupMenu *settingsMenu; |
475 | QPopupMenu *changeMenu; | 476 | QPopupMenu *changeMenu; |
476 | QPopupMenu *beamMenu; | 477 | QPopupMenu *beamMenu; |
477 | //US QAction *mActionSave; | 478 | //US QAction *mActionSave; |
478 | QPopupMenu *ImportMenu; | 479 | QPopupMenu *ImportMenu; |
479 | QPopupMenu *ExportMenu; | 480 | QPopupMenu *ExportMenu; |
480 | //LR additional methods | 481 | //LR additional methods |
481 | KAction *mActionRemoveVoice; | 482 | KAction *mActionRemoveVoice; |
482 | KAction *mActionSetFormattedName; | 483 | KAction *mActionSetFormattedName; |
483 | KAction * mActionImportOL; | 484 | KAction * mActionImportOL; |
484 | 485 | ||
485 | #ifndef KAB_EMBEDDED | 486 | #ifndef KAB_EMBEDDED |
486 | KAddressBookService *mAddressBookService; | 487 | KAddressBookService *mAddressBookService; |
487 | #endif //KAB_EMBEDDED | 488 | #endif //KAB_EMBEDDED |
488 | 489 | ||
489 | class KABCorePrivate; | 490 | class KABCorePrivate; |
490 | KABCorePrivate *d; | 491 | KABCorePrivate *d; |
491 | //US bool mBlockSaveFlag; | 492 | //US bool mBlockSaveFlag; |
492 | 493 | ||
493 | #ifdef KAB_EMBEDDED | 494 | #ifdef KAB_EMBEDDED |
494 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 495 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
495 | #endif //KAB_EMBEDDED | 496 | #endif //KAB_EMBEDDED |
496 | 497 | ||
497 | //this are the overwritten callbackmethods from the syncinterface | 498 | //this are the overwritten callbackmethods from the syncinterface |
498 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 499 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
499 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 500 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
500 | virtual void removeSyncInfo( QString syncProfile); | 501 | virtual void removeSyncInfo( QString syncProfile); |
501 | bool syncPhone(); | 502 | bool syncPhone(); |
502 | void message( QString m ); | 503 | void message( QString m ); |
503 | 504 | ||
504 | // LR ******************************* | 505 | // LR ******************************* |
505 | // sync stuff! | 506 | // sync stuff! |
506 | QString sentSyncFile(); | 507 | QString sentSyncFile(); |
507 | QPopupMenu *syncMenu; | 508 | QPopupMenu *syncMenu; |
508 | KSyncManager* syncManager; | 509 | KSyncManager* syncManager; |
509 | int mGlobalSyncMode; | 510 | int mGlobalSyncMode; |
510 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 511 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
511 | KABC::Addressee getLastSyncAddressee(); | 512 | KABC::Addressee getLastSyncAddressee(); |
512 | QDateTime mLastAddressbookSync; | 513 | QDateTime mLastAddressbookSync; |
513 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 514 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
514 | // ********************* | 515 | // ********************* |
515 | 516 | ||
516 | }; | 517 | }; |
517 | 518 | ||
518 | #endif | 519 | #endif |
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h index 8646136..8f31910 100644 --- a/kaddressbook/kaddressbookview.h +++ b/kaddressbook/kaddressbookview.h | |||
@@ -1,301 +1,310 @@ | |||
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 | #ifndef KADDRESSBOOKVIEW_H | 24 | #ifndef KADDRESSBOOKVIEW_H |
25 | #define KADDRESSBOOKVIEW_H | 25 | #define KADDRESSBOOKVIEW_H |
26 | 26 | ||
27 | #ifndef KAB_EMBEDDED | 27 | #ifndef KAB_EMBEDDED |
28 | #include <klibloader.h> | 28 | #include <klibloader.h> |
29 | #endif //KAB_EMBEDDED | 29 | #endif //KAB_EMBEDDED |
30 | 30 | ||
31 | class KConfig; | 31 | class KConfig; |
32 | class QDropEvent; | 32 | class QDropEvent; |
33 | 33 | ||
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <kabc/field.h> | 35 | #include <kabc/field.h> |
36 | #include <qwidget.h> | 36 | #include <qwidget.h> |
37 | 37 | ||
38 | #include "viewconfigurewidget.h" | 38 | #include "viewconfigurewidget.h" |
39 | #include "filter.h" | 39 | #include "filter.h" |
40 | 40 | ||
41 | #ifdef DESKTOP_VERSION | ||
42 | #include <qpaintdevicemetrics.h> | ||
43 | #include <qprinter.h> | ||
44 | #include <qpainter.h> | ||
45 | #endif | ||
46 | |||
41 | namespace KABC { class AddressBook; } | 47 | namespace KABC { class AddressBook; } |
42 | 48 | ||
43 | /** | 49 | /** |
44 | Base class for all views in kaddressbook. This class implements | 50 | Base class for all views in kaddressbook. This class implements |
45 | all the common methods needed to provide a view to the user. | 51 | all the common methods needed to provide a view to the user. |
46 | 52 | ||
47 | To implement a specific view (table, card, etc), just inherit from | 53 | To implement a specific view (table, card, etc), just inherit from |
48 | this class and implement all the pure virtuals. | 54 | this class and implement all the pure virtuals. |
49 | 55 | ||
50 | @author Mike Pilone <mpilone@slac.com> | 56 | @author Mike Pilone <mpilone@slac.com> |
51 | */ | 57 | */ |
52 | class KAddressBookView : public QWidget | 58 | class KAddressBookView : public QWidget |
53 | { | 59 | { |
54 | Q_OBJECT | 60 | Q_OBJECT |
55 | 61 | ||
56 | public: | 62 | public: |
57 | enum DefaultFilterType { None = 0, Active = 1, Specific = 2 }; | 63 | enum DefaultFilterType { None = 0, Active = 1, Specific = 2 }; |
58 | 64 | ||
59 | KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ); | 65 | KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ); |
60 | virtual ~KAddressBookView(); | 66 | virtual ~KAddressBookView(); |
61 | 67 | ||
62 | /** | 68 | /** |
63 | Must be overloaded in subclasses. Should return a list of | 69 | Must be overloaded in subclasses. Should return a list of |
64 | all the uids of selected contacts. | 70 | all the uids of selected contacts. |
65 | */ | 71 | */ |
66 | virtual QStringList selectedUids() = 0; | 72 | virtual QStringList selectedUids() = 0; |
67 | virtual void doSearch( const QString& s ,KABC::Field *field ) = 0; | 73 | virtual void doSearch( const QString& s ,KABC::Field *field ) = 0; |
68 | virtual void scrollUP() = 0; | 74 | virtual void scrollUP() = 0; |
69 | virtual void scrollDOWN() = 0; | 75 | virtual void scrollDOWN() = 0; |
70 | virtual void setFocusAV() = 0; | 76 | virtual void setFocusAV() = 0; |
71 | 77 | ||
72 | /** | 78 | /** |
73 | Called whenever this view should read the config. This can be used | 79 | Called whenever this view should read the config. This can be used |
74 | as a sign that the config has changed, therefore the view should | 80 | as a sign that the config has changed, therefore the view should |
75 | assume the worst and rebuild itself if necessary. For example, | 81 | assume the worst and rebuild itself if necessary. For example, |
76 | in a table view this method may be called when the user adds or | 82 | in a table view this method may be called when the user adds or |
77 | removes columns from the view. | 83 | removes columns from the view. |
78 | 84 | ||
79 | If overloaded in the subclass, do not forget to call super class's | 85 | If overloaded in the subclass, do not forget to call super class's |
80 | method. | 86 | method. |
81 | 87 | ||
82 | @param config The KConfig object to read from. The group will already | 88 | @param config The KConfig object to read from. The group will already |
83 | be set, so do not change the group. | 89 | be set, so do not change the group. |
84 | */ | 90 | */ |
85 | virtual void readConfig( KConfig *config ); | 91 | virtual void readConfig( KConfig *config ); |
86 | 92 | ||
87 | /** | 93 | /** |
88 | Called whenever this view should write the config. The view should not | 94 | Called whenever this view should write the config. The view should not |
89 | write out information handled by the application, such as which fields | 95 | write out information handled by the application, such as which fields |
90 | are visible. The view should only write out information specific | 96 | are visible. The view should only write out information specific |
91 | to itself (i.e.: All information in the ViewConfigWidget) | 97 | to itself (i.e.: All information in the ViewConfigWidget) |
92 | 98 | ||
93 | If overloaded in the subclass, do not forget to call the super class's | 99 | If overloaded in the subclass, do not forget to call the super class's |
94 | method. | 100 | method. |
95 | 101 | ||
96 | @param config The KConfig object to read from. The group will already | 102 | @param config The KConfig object to read from. The group will already |
97 | be set, so do not change the group. | 103 | be set, so do not change the group. |
98 | */ | 104 | */ |
99 | virtual void writeConfig( KConfig *config ); | 105 | virtual void writeConfig( KConfig *config ); |
100 | 106 | ||
101 | /** | 107 | /** |
102 | Returns a QString with all the selected email addresses concatenated | 108 | Returns a QString with all the selected email addresses concatenated |
103 | together with a ',' seperator. | 109 | together with a ',' seperator. |
104 | */ | 110 | */ |
105 | virtual QString selectedEmails(); | 111 | virtual QString selectedEmails(); |
106 | 112 | ||
107 | /** | 113 | /** |
108 | Return the type of the view: Icon, Table, etc. Please make sure that | 114 | Return the type of the view: Icon, Table, etc. Please make sure that |
109 | this is the same value that ViewWrapper::type() will return for your | 115 | this is the same value that ViewWrapper::type() will return for your |
110 | view. | 116 | view. |
111 | */ | 117 | */ |
112 | virtual QString type() const = 0; | 118 | virtual QString type() const = 0; |
113 | 119 | ||
114 | /** | 120 | /** |
115 | Returns a list of the fields that should be displayed. The list | 121 | Returns a list of the fields that should be displayed. The list |
116 | is composed of the fields proper names (ie: Home Address), so | 122 | is composed of the fields proper names (ie: Home Address), so |
117 | the view may need to translate them in order to get the | 123 | the view may need to translate them in order to get the |
118 | value from the addressee. | 124 | value from the addressee. |
119 | 125 | ||
120 | This list is generated from the config file, so it is advisable to call | 126 | This list is generated from the config file, so it is advisable to call |
121 | this method whenever a readConfig() is called in order to get the newest | 127 | this method whenever a readConfig() is called in order to get the newest |
122 | list of fields. | 128 | list of fields. |
123 | */ | 129 | */ |
124 | KABC::Field::List fields() const; | 130 | KABC::Field::List fields() const; |
125 | 131 | ||
126 | KABC::Field::List allFields() const; | 132 | KABC::Field::List allFields() const; |
127 | 133 | ||
128 | /** | 134 | /** |
129 | Sets the active filter. This filter will be used for filtering | 135 | Sets the active filter. This filter will be used for filtering |
130 | the list of addressees to display. The view will <b>not</b> | 136 | the list of addressees to display. The view will <b>not</b> |
131 | automatically refresh itself, so in most cases you will want to call | 137 | automatically refresh itself, so in most cases you will want to call |
132 | KAddressBookView::refresh() after this method. | 138 | KAddressBookView::refresh() after this method. |
133 | */ | 139 | */ |
134 | void setFilter( const Filter& ); | 140 | void setFilter( const Filter& ); |
135 | 141 | ||
136 | /** | 142 | /** |
137 | @return The default filter type selection. If the selection | 143 | @return The default filter type selection. If the selection |
138 | is SpecificFilter, the name of the filter can be retrieved with | 144 | is SpecificFilter, the name of the filter can be retrieved with |
139 | defaultFilterName() | 145 | defaultFilterName() |
140 | */ | 146 | */ |
141 | DefaultFilterType defaultFilterType() const; | 147 | DefaultFilterType defaultFilterType() const; |
142 | 148 | ||
143 | /** | 149 | /** |
144 | @return The name of the default filter. This string is | 150 | @return The name of the default filter. This string is |
145 | only valid if defaultFilterType() is returning SpecificFilter. | 151 | only valid if defaultFilterType() is returning SpecificFilter. |
146 | */ | 152 | */ |
147 | const QString &defaultFilterName() const; | 153 | const QString &defaultFilterName() const; |
148 | 154 | ||
149 | /** | 155 | /** |
150 | @return The address book. | 156 | @return The address book. |
151 | */ | 157 | */ |
152 | KABC::AddressBook *addressBook() const; | 158 | KABC::AddressBook *addressBook() const; |
159 | void printMyView() { emit printView() ;} | ||
153 | 160 | ||
154 | public slots: | 161 | public slots: |
155 | /** | 162 | /** |
156 | Must be overloaded in subclasses to refresh the view. | 163 | Must be overloaded in subclasses to refresh the view. |
157 | Refreshing includes updating the view to ensure that only items | 164 | Refreshing includes updating the view to ensure that only items |
158 | in the document are visible. If <i>uid</i> is valid, only the | 165 | in the document are visible. If <i>uid</i> is valid, only the |
159 | addressee with uid needs to be refreshed. This is an optimization | 166 | addressee with uid needs to be refreshed. This is an optimization |
160 | only. | 167 | only. |
161 | */ | 168 | */ |
162 | virtual void refresh( QString uid = QString::null ) = 0; | 169 | virtual void refresh( QString uid = QString::null ) = 0; |
163 | 170 | ||
164 | /** | 171 | /** |
165 | This method must be overloaded in subclasses. Select (highlight) | 172 | This method must be overloaded in subclasses. Select (highlight) |
166 | the addressee matching <i>uid</i>. If uid | 173 | the addressee matching <i>uid</i>. If uid |
167 | is equal to QString::null, then all addressees should be selected. | 174 | is equal to QString::null, then all addressees should be selected. |
168 | */ | 175 | */ |
169 | #ifndef KAB_EMBEDDED | 176 | #ifndef KAB_EMBEDDED |
170 | //MOC_SKIP_BEGIN | 177 | //MOC_SKIP_BEGIN |
171 | virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; | 178 | virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; |
172 | //MOC_SKIP_END | 179 | //MOC_SKIP_END |
173 | #else //KAB_EMBEDDED | 180 | #else //KAB_EMBEDDED |
174 | //US my moc can not handle the default parameters. Is this a problem ??? | 181 | //US my moc can not handle the default parameters. Is this a problem ??? |
175 | virtual void setSelected( QString uid, bool selected) = 0; | 182 | virtual void setSelected( QString uid, bool selected) = 0; |
176 | #endif //KAB_EMBEDDED | 183 | #endif //KAB_EMBEDDED |
177 | 184 | ||
178 | signals: | 185 | signals: |
186 | |||
187 | void printView(); | ||
179 | /** | 188 | /** |
180 | This signal should be emitted by a subclass whenever an addressee | 189 | This signal should be emitted by a subclass whenever an addressee |
181 | is modified. | 190 | is modified. |
182 | */ | 191 | */ |
183 | void modified(); | 192 | void modified(); |
184 | 193 | ||
185 | /** | 194 | /** |
186 | This signal should be emitted by a subclass whenever an addressee | 195 | This signal should be emitted by a subclass whenever an addressee |
187 | is selected. Selected means that the addressee was given the focus. | 196 | is selected. Selected means that the addressee was given the focus. |
188 | Some widgets may call this 'highlighted'. The view is responsible for | 197 | Some widgets may call this 'highlighted'. The view is responsible for |
189 | emitting this signal multiple times if multiple items are selected, | 198 | emitting this signal multiple times if multiple items are selected, |
190 | with the last item selected being the last emit. | 199 | with the last item selected being the last emit. |
191 | 200 | ||
192 | @param uid The uid of the selected addressee. | 201 | @param uid The uid of the selected addressee. |
193 | 202 | ||
194 | @see KListView | 203 | @see KListView |
195 | */ | 204 | */ |
196 | void selected( const QString &uid ); | 205 | void selected( const QString &uid ); |
197 | void deleteRequest(); | 206 | void deleteRequest(); |
198 | /** | 207 | /** |
199 | This signal should be emitted by a subclass whenever an addressee | 208 | This signal should be emitted by a subclass whenever an addressee |
200 | is executed. This is defined by the KDE system wide config, but it | 209 | is executed. This is defined by the KDE system wide config, but it |
201 | either means single or doubleclicked. | 210 | either means single or doubleclicked. |
202 | 211 | ||
203 | @param ui The uid of the selected addressee | 212 | @param ui The uid of the selected addressee |
204 | 213 | ||
205 | @see KListView | 214 | @see KListView |
206 | */ | 215 | */ |
207 | void executed( const QString &uid ); | 216 | void executed( const QString &uid ); |
208 | 217 | ||
209 | /** | 218 | /** |
210 | This signal is emitted whenever a user attempts to start a drag | 219 | This signal is emitted whenever a user attempts to start a drag |
211 | in the view. The slot connected to this signal would usually want | 220 | in the view. The slot connected to this signal would usually want |
212 | to create a QDragObject. | 221 | to create a QDragObject. |
213 | */ | 222 | */ |
214 | void startDrag(); | 223 | void startDrag(); |
215 | 224 | ||
216 | /** | 225 | /** |
217 | This signal is emitted whenever the user drops something on the | 226 | This signal is emitted whenever the user drops something on the |
218 | view. The individual view should handle checking if the item is | 227 | view. The individual view should handle checking if the item is |
219 | droppable (ie: if it is a vcard). | 228 | droppable (ie: if it is a vcard). |
220 | */ | 229 | */ |
221 | void dropped( QDropEvent* ); | 230 | void dropped( QDropEvent* ); |
222 | 231 | ||
223 | protected: | 232 | protected: |
224 | /** | 233 | /** |
225 | Returns a list of the addressees that should be displayed. This method | 234 | Returns a list of the addressees that should be displayed. This method |
226 | should always be used by the subclass to get a list of addressees. This | 235 | should always be used by the subclass to get a list of addressees. This |
227 | method internally takes many factors into account, including the current | 236 | method internally takes many factors into account, including the current |
228 | filter. | 237 | filter. |
229 | */ | 238 | */ |
230 | KABC::Addressee::List addressees(); | 239 | KABC::Addressee::List addressees(); |
231 | 240 | ||
232 | /** | 241 | /** |
233 | This method returns the widget that should be used as the parent for | 242 | This method returns the widget that should be used as the parent for |
234 | all view components. By using this widget as the parent and not | 243 | all view components. By using this widget as the parent and not |
235 | 'this', the view subclass has the option of placing other widgets | 244 | 'this', the view subclass has the option of placing other widgets |
236 | around the view (ie: search fields, etc). Do not delete this widget! | 245 | around the view (ie: search fields, etc). Do not delete this widget! |
237 | */ | 246 | */ |
238 | QWidget *viewWidget(); | 247 | QWidget *viewWidget(); |
239 | 248 | ||
240 | private: | 249 | private: |
241 | void initGUI(); | 250 | void initGUI(); |
242 | 251 | ||
243 | DefaultFilterType mDefaultFilterType; | 252 | DefaultFilterType mDefaultFilterType; |
244 | Filter mFilter; | 253 | Filter mFilter; |
245 | QString mDefaultFilterName; | 254 | QString mDefaultFilterName; |
246 | KABC::AddressBook *mAddressBook; | 255 | KABC::AddressBook *mAddressBook; |
247 | KABC::Field::List mFieldList; | 256 | KABC::Field::List mFieldList; |
248 | 257 | ||
249 | QWidget *mViewWidget; | 258 | QWidget *mViewWidget; |
250 | }; | 259 | }; |
251 | 260 | ||
252 | #ifndef KAB_EMBEDDED | 261 | #ifndef KAB_EMBEDDED |
253 | //MOC_SKIP_BEGIN | 262 | //MOC_SKIP_BEGIN |
254 | class ViewFactory : public KLibFactory | 263 | class ViewFactory : public KLibFactory |
255 | //MOC_SKIP_END | 264 | //MOC_SKIP_END |
256 | #else //KAB_EMBEDDED | 265 | #else //KAB_EMBEDDED |
257 | class ViewFactory | 266 | class ViewFactory |
258 | #endif //KAB_EMBEDDED | 267 | #endif //KAB_EMBEDDED |
259 | { | 268 | { |
260 | 269 | ||
261 | public: | 270 | public: |
262 | virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, | 271 | virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, |
263 | const char *name = 0 ) = 0; | 272 | const char *name = 0 ) = 0; |
264 | 273 | ||
265 | /** | 274 | /** |
266 | @return The type of the view. This is normally a small one word | 275 | @return The type of the view. This is normally a small one word |
267 | string (ie: Table, Icon, Tree, etc). | 276 | string (ie: Table, Icon, Tree, etc). |
268 | */ | 277 | */ |
269 | virtual QString type() const = 0; | 278 | virtual QString type() const = 0; |
270 | 279 | ||
271 | /** | 280 | /** |
272 | @return The description of the view. This should be a 3 to | 281 | @return The description of the view. This should be a 3 to |
273 | 4 line string (don't actually use return characters in the string) | 282 | 4 line string (don't actually use return characters in the string) |
274 | describing the features offered by the view. | 283 | describing the features offered by the view. |
275 | */ | 284 | */ |
276 | virtual QString description() const = 0; | 285 | virtual QString description() const = 0; |
277 | 286 | ||
278 | /** | 287 | /** |
279 | Creates a config dialog for the view type. The default | 288 | Creates a config dialog for the view type. The default |
280 | implementation will return a ViewConfigDialog. This default | 289 | implementation will return a ViewConfigDialog. This default |
281 | dialog will allow the user to set the visible fields only. If | 290 | dialog will allow the user to set the visible fields only. If |
282 | you need more config options (as most views will), this method | 291 | you need more config options (as most views will), this method |
283 | can be overloaded to return your sublcass of ViewConfigDialog. | 292 | can be overloaded to return your sublcass of ViewConfigDialog. |
284 | If this method is over loaded the base classes method should | 293 | If this method is over loaded the base classes method should |
285 | <B>not</B> be called. | 294 | <B>not</B> be called. |
286 | */ | 295 | */ |
287 | virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, | 296 | virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, |
288 | QWidget *parent, | 297 | QWidget *parent, |
289 | const char *name = 0 ); | 298 | const char *name = 0 ); |
290 | 299 | ||
291 | protected: | 300 | protected: |
292 | virtual QObject* createObject( QObject*, const char*, const char*, | 301 | virtual QObject* createObject( QObject*, const char*, const char*, |
293 | const QStringList & ) | 302 | const QStringList & ) |
294 | { | 303 | { |
295 | return 0; | 304 | return 0; |
296 | } | 305 | } |
297 | 306 | ||
298 | }; | 307 | }; |
299 | 308 | ||
300 | 309 | ||
301 | #endif | 310 | #endif |
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp index 8bf9bb0..3ad2f74 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp +++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp | |||
@@ -1,401 +1,401 @@ | |||
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 <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qframe.h> | 25 | #include <qframe.h> |
26 | #include <qgroupbox.h> | 26 | #include <qgroupbox.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qtabwidget.h> | 29 | #include <qtabwidget.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qvbox.h> | 34 | #include <qvbox.h> |
35 | 35 | ||
36 | #include <kconfig.h> | 36 | #include <kconfig.h> |
37 | #include <kdebug.h> | 37 | #include <kdebug.h> |
38 | #include <kdialog.h> | 38 | #include <kdialog.h> |
39 | #include <klistview.h> | 39 | #include <klistview.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kglobal.h> | 41 | #include <kglobal.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <ktrader.h> | 46 | #include <ktrader.h> |
47 | #else // KAB_EMBEDDED | 47 | #else // KAB_EMBEDDED |
48 | #include <mergewidget.h> | 48 | #include <mergewidget.h> |
49 | #include <distributionlistwidget.h> | 49 | #include <distributionlistwidget.h> |
50 | #endif // KAB_EMBEDDED | 50 | #endif // KAB_EMBEDDED |
51 | 51 | ||
52 | #include "addresseewidget.h" | 52 | #include "addresseewidget.h" |
53 | #include "extensionconfigdialog.h" | 53 | #include "extensionconfigdialog.h" |
54 | #include "extensionwidget.h" | 54 | #include "extensionwidget.h" |
55 | #include "kabprefs.h" | 55 | #include "kabprefs.h" |
56 | 56 | ||
57 | #include "kabconfigwidget.h" | 57 | #include "kabconfigwidget.h" |
58 | 58 | ||
59 | class ExtensionItem : public QCheckListItem | 59 | class ExtensionItem : public QCheckListItem |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | 62 | ||
63 | #ifndef KAB_EMBEDDED | 63 | #ifndef KAB_EMBEDDED |
64 | ExtensionItem( QListView *parent, const QString &text ); | 64 | ExtensionItem( QListView *parent, const QString &text ); |
65 | void setService( const KService::Ptr &ptr ); | 65 | void setService( const KService::Ptr &ptr ); |
66 | #else //KAB_EMBEDDED | 66 | #else //KAB_EMBEDDED |
67 | ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); | 67 | ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); |
68 | void setFactory( ExtensionFactory* fac ); | 68 | void setFactory( ExtensionFactory* fac ); |
69 | #endif //KAB_EMBEDDED | 69 | #endif //KAB_EMBEDDED |
70 | 70 | ||
71 | bool configWidgetAvailable() const; | 71 | bool configWidgetAvailable() const; |
72 | ExtensionFactory *factory() const; | 72 | ExtensionFactory *factory() const; |
73 | 73 | ||
74 | virtual QString text( int column ) const; | 74 | virtual QString text( int column ) const; |
75 | 75 | ||
76 | private: | 76 | private: |
77 | #ifndef KAB_EMBEDDED | 77 | #ifndef KAB_EMBEDDED |
78 | KService::Ptr mPtr; | 78 | KService::Ptr mPtr; |
79 | #else //KAB_EMBEDDED | 79 | #else //KAB_EMBEDDED |
80 | ExtensionFactory* mFactory; | 80 | ExtensionFactory* mFactory; |
81 | QString mName; | 81 | QString mName; |
82 | QString mComment; | 82 | QString mComment; |
83 | 83 | ||
84 | #endif //KAB_EMBEDDED | 84 | #endif //KAB_EMBEDDED |
85 | 85 | ||
86 | }; | 86 | }; |
87 | 87 | ||
88 | KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name ) | 88 | KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name ) |
89 | : KPrefsWidget( prefs, parent, name ) | 89 | : KPrefsWidget( prefs, parent, name ) |
90 | { | 90 | { |
91 | QVBoxLayout *topLayout = new QVBoxLayout( this, 0, | 91 | QVBoxLayout *topLayout = new QVBoxLayout( this, 0, |
92 | KDialog::spacingHint() ); | 92 | KDialog::spacingHint() ); |
93 | 93 | ||
94 | QTabWidget *tabWidget = new QTabWidget( this ); | 94 | QTabWidget *tabWidget = new QTabWidget( this ); |
95 | topLayout->addWidget( tabWidget ); | 95 | topLayout->addWidget( tabWidget ); |
96 | 96 | ||
97 | // General page | 97 | // General page |
98 | QWidget *generalPage = new QWidget( this ); | 98 | QWidget *generalPage = new QWidget( this ); |
99 | QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), | 99 | QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), |
100 | KDialog::spacingHintSmall() ); | 100 | KDialog::spacingHintSmall() ); |
101 | 101 | ||
102 | 102 | ||
103 | QWidget *hBox = new QWidget( generalPage, "qhbox" ); | 103 | QWidget *hBox = new QWidget( generalPage, "qhbox" ); |
104 | QHBoxLayout *hboxLayout = new QHBoxLayout( hBox); | 104 | QHBoxLayout *hboxLayout = new QHBoxLayout( hBox); |
105 | KPrefsWidFont *detailsFont = | 105 | KPrefsWidFont *detailsFont = |
106 | addWidFont(i18n("phone:123"),i18n("Details view font"), | 106 | addWidFont(i18n("phone:123"),i18n("Details view font"), |
107 | &(KABPrefs::instance()->mDetailsFont),hBox); | 107 | &(KABPrefs::instance()->mDetailsFont),hBox); |
108 | hboxLayout->addWidget(detailsFont->label()); | 108 | hboxLayout->addWidget(detailsFont->label()); |
109 | hboxLayout->addWidget(detailsFont->preview()); | 109 | hboxLayout->addWidget(detailsFont->preview()); |
110 | hboxLayout->addWidget(detailsFont->button()); | 110 | hboxLayout->addWidget(detailsFont->button()); |
111 | hboxLayout->setMargin(KDialog::marginHintSmall() ); | 111 | hboxLayout->setMargin(KDialog::marginHintSmall() ); |
112 | hboxLayout->setSpacing(KDialog::spacingHintSmall()); | 112 | hboxLayout->setSpacing(KDialog::spacingHintSmall()); |
113 | //hBox->setBackgroundColor( black); | 113 | //hBox->setBackgroundColor( black); |
114 | layout->addWidget( hBox ); | 114 | layout->addWidget( hBox ); |
115 | 115 | ||
116 | //general groupbox | 116 | //general groupbox |
117 | QWidget *vBox = new QWidget( generalPage, "qvbox" ); | 117 | QWidget *vBox = new QWidget( generalPage, "qvbox" ); |
118 | QVBoxLayout *boxLayout = new QVBoxLayout( vBox ); | 118 | QVBoxLayout *boxLayout = new QVBoxLayout( vBox ); |
119 | boxLayout->setAlignment( Qt::AlignTop ); | 119 | boxLayout->setAlignment( Qt::AlignTop ); |
120 | boxLayout->setMargin(KDialog::marginHintSmall() ); | 120 | boxLayout->setMargin(KDialog::marginHintSmall() ); |
121 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); | 121 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); |
122 | mMenuBarBox = new QCheckBox( i18n( "Full Menu bar (restart)" ), vBox, "mremenuturn" ); | 122 | mMenuBarBox = new QCheckBox( i18n( "Full Menu bar (restart)" ), vBox, "mremenuturn" ); |
123 | boxLayout->addWidget( mMenuBarBox ); | 123 | boxLayout->addWidget( mMenuBarBox ); |
124 | mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); | 124 | mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); |
125 | boxLayout->addWidget( mSearchReturnBox ); | 125 | boxLayout->addWidget( mSearchReturnBox ); |
126 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); | 126 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); |
127 | boxLayout->addWidget( mViewsSingleClickBox ); | 127 | boxLayout->addWidget( mViewsSingleClickBox ); |
128 | 128 | ||
129 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); | 129 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); |
130 | boxLayout->addWidget( mNameParsing ); | 130 | boxLayout->addWidget( mNameParsing ); |
131 | 131 | ||
132 | mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); | 132 | mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); |
133 | boxLayout->addWidget( mMultipleViewsAtOnce ); | 133 | boxLayout->addWidget( mMultipleViewsAtOnce ); |
134 | 134 | ||
135 | mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); | 135 | mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); |
136 | boxLayout->addWidget( mAskForQuit ); | 136 | boxLayout->addWidget( mAskForQuit ); |
137 | 137 | ||
138 | layout->addWidget( vBox ); | 138 | layout->addWidget( vBox ); |
139 | 139 | ||
140 | tabWidget->addTab( generalPage, i18n( "General" ) ); | 140 | tabWidget->addTab( generalPage, i18n( "General" ) ); |
141 | 141 | ||
142 | // Extension page | 142 | // Extension page |
143 | QWidget *extensionPage = new QWidget( this ); | 143 | QWidget *extensionPage = new QWidget( this ); |
144 | QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), | 144 | QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), |
145 | KDialog::spacingHintSmall() ); | 145 | KDialog::spacingHintSmall() ); |
146 | 146 | ||
147 | //extensions groupbox | 147 | //extensions groupbox |
148 | 148 | ||
149 | QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); | 149 | QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); |
150 | boxLayout = new QVBoxLayout( groupBox->layout() ); | 150 | boxLayout = new QVBoxLayout( groupBox->layout() ); |
151 | boxLayout->setAlignment( Qt::AlignTop ); | 151 | boxLayout->setAlignment( Qt::AlignTop ); |
152 | boxLayout->setMargin(KDialog::marginHintSmall()); | 152 | boxLayout->setMargin(KDialog::marginHintSmall()); |
153 | boxLayout->setSpacing(KDialog::spacingHintSmall()); | 153 | boxLayout->setSpacing(KDialog::spacingHintSmall()); |
154 | groupBox->layout()->setMargin(1) ; | 154 | groupBox->layout()->setMargin(1) ; |
155 | groupBox->layout()->setSpacing(0); | 155 | groupBox->layout()->setSpacing(0); |
156 | mExtensionView = new KListView( groupBox ); | 156 | mExtensionView = new KListView( groupBox ); |
157 | mExtensionView->setAllColumnsShowFocus( true ); | 157 | mExtensionView->setAllColumnsShowFocus( true ); |
158 | mExtensionView->addColumn( i18n( "Name" ) ); | 158 | mExtensionView->addColumn( i18n( "Name" ) ); |
159 | mExtensionView->addColumn( i18n( "Description" ) ); | 159 | mExtensionView->addColumn( i18n( "Description" ) ); |
160 | mExtensionView->setMaximumHeight(80); | 160 | //mExtensionView->setMaximumHeight(80); |
161 | 161 | ||
162 | boxLayout->addWidget( mExtensionView ); | 162 | boxLayout->addWidget( mExtensionView ); |
163 | 163 | ||
164 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); | 164 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); |
165 | mConfigureButton->setEnabled( false ); | 165 | mConfigureButton->setEnabled( false ); |
166 | boxLayout->addWidget( mConfigureButton ); | 166 | boxLayout->addWidget( mConfigureButton ); |
167 | 167 | ||
168 | extensionLayout->addWidget( groupBox ); | 168 | extensionLayout->addWidget( groupBox ); |
169 | 169 | ||
170 | connect( mMenuBarBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 170 | connect( mMenuBarBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
171 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 171 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
172 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 172 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
173 | connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 173 | connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
174 | connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 174 | connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
175 | connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 175 | connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
176 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), | 176 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), |
177 | SLOT( selectionChanged( QListViewItem* ) ) ); | 177 | SLOT( selectionChanged( QListViewItem* ) ) ); |
178 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), | 178 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), |
179 | SLOT( itemClicked( QListViewItem* ) ) ); | 179 | SLOT( itemClicked( QListViewItem* ) ) ); |
180 | connect( mConfigureButton, SIGNAL( clicked() ), | 180 | connect( mConfigureButton, SIGNAL( clicked() ), |
181 | SLOT( configureExtension() ) ); | 181 | SLOT( configureExtension() ) ); |
182 | 182 | ||
183 | tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); | 183 | tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); |
184 | 184 | ||
185 | // Addressee page | 185 | // Addressee page |
186 | mAddresseeWidget = new AddresseeWidget( this ); | 186 | mAddresseeWidget = new AddresseeWidget( this ); |
187 | tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); | 187 | tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); |
188 | connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); | 188 | connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); |
189 | 189 | ||
190 | } | 190 | } |
191 | 191 | ||
192 | void KABConfigWidget::usrReadConfig() | 192 | void KABConfigWidget::usrReadConfig() |
193 | { | 193 | { |
194 | KABPrefs* prefs = KABPrefs::instance(); | 194 | KABPrefs* prefs = KABPrefs::instance(); |
195 | 195 | ||
196 | bool blocked = signalsBlocked(); | 196 | bool blocked = signalsBlocked(); |
197 | blockSignals( true ); | 197 | blockSignals( true ); |
198 | mMenuBarBox->setChecked( prefs->mFullMenuBarVisible); | 198 | mMenuBarBox->setChecked( prefs->mFullMenuBarVisible); |
199 | mNameParsing->setChecked( prefs->mAutomaticNameParsing ); | 199 | mNameParsing->setChecked( prefs->mAutomaticNameParsing ); |
200 | mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); | 200 | mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); |
201 | mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); | 201 | mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); |
202 | mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); | 202 | mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); |
203 | mAskForQuit->setChecked( prefs->mAskForQuit ); | 203 | mAskForQuit->setChecked( prefs->mAskForQuit ); |
204 | 204 | ||
205 | mAddresseeWidget->restoreSettings(); | 205 | mAddresseeWidget->restoreSettings(); |
206 | 206 | ||
207 | restoreExtensionSettings(); | 207 | restoreExtensionSettings(); |
208 | 208 | ||
209 | blockSignals( blocked ); | 209 | blockSignals( blocked ); |
210 | 210 | ||
211 | } | 211 | } |
212 | 212 | ||
213 | void KABConfigWidget::usrWriteConfig() | 213 | void KABConfigWidget::usrWriteConfig() |
214 | { | 214 | { |
215 | KABPrefs* prefs = KABPrefs::instance(); | 215 | KABPrefs* prefs = KABPrefs::instance(); |
216 | prefs->mFullMenuBarVisible = mMenuBarBox->isChecked(); | 216 | prefs->mFullMenuBarVisible = mMenuBarBox->isChecked(); |
217 | prefs->mAutomaticNameParsing = mNameParsing->isChecked(); | 217 | prefs->mAutomaticNameParsing = mNameParsing->isChecked(); |
218 | prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); | 218 | prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); |
219 | prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); | 219 | prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); |
220 | prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); | 220 | prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); |
221 | prefs->mAskForQuit = mAskForQuit->isChecked(); | 221 | prefs->mAskForQuit = mAskForQuit->isChecked(); |
222 | 222 | ||
223 | mAddresseeWidget->saveSettings(); | 223 | mAddresseeWidget->saveSettings(); |
224 | 224 | ||
225 | saveExtensionSettings(); | 225 | saveExtensionSettings(); |
226 | 226 | ||
227 | } | 227 | } |
228 | 228 | ||
229 | void KABConfigWidget::restoreExtensionSettings() | 229 | void KABConfigWidget::restoreExtensionSettings() |
230 | { | 230 | { |
231 | QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; | 231 | QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; |
232 | 232 | ||
233 | mExtensionView->clear(); | 233 | mExtensionView->clear(); |
234 | 234 | ||
235 | #ifndef KAB_EMBEDDED | 235 | #ifndef KAB_EMBEDDED |
236 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); | 236 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); |
237 | KTrader::OfferList::ConstIterator it; | 237 | KTrader::OfferList::ConstIterator it; |
238 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 238 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
239 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) | 239 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) |
240 | continue; | 240 | continue; |
241 | 241 | ||
242 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); | 242 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); |
243 | item->setService( *it ); | 243 | item->setService( *it ); |
244 | if ( activeExtensions.contains( item->factory()->identifier() ) ) | 244 | if ( activeExtensions.contains( item->factory()->identifier() ) ) |
245 | item->setOn( true ); | 245 | item->setOn( true ); |
246 | } | 246 | } |
247 | #else //KAB_EMBEDDED | 247 | #else //KAB_EMBEDDED |
248 | ExtensionFactory *extensionFactory = new MergeFactory(); | 248 | ExtensionFactory *extensionFactory = new MergeFactory(); |
249 | 249 | ||
250 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); | 250 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); |
251 | 251 | ||
252 | item->setFactory( extensionFactory ); | 252 | item->setFactory( extensionFactory ); |
253 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 253 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
254 | item->setOn( true ); | 254 | item->setOn( true ); |
255 | 255 | ||
256 | 256 | ||
257 | 257 | ||
258 | extensionFactory = new DistributionListFactory(); | 258 | extensionFactory = new DistributionListFactory(); |
259 | 259 | ||
260 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); | 260 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); |
261 | 261 | ||
262 | item->setFactory( extensionFactory ); | 262 | item->setFactory( extensionFactory ); |
263 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 263 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
264 | item->setOn( true ); | 264 | item->setOn( true ); |
265 | 265 | ||
266 | 266 | ||
267 | #endif //KAB_EMBEDDED | 267 | #endif //KAB_EMBEDDED |
268 | 268 | ||
269 | } | 269 | } |
270 | 270 | ||
271 | void KABConfigWidget::saveExtensionSettings() | 271 | void KABConfigWidget::saveExtensionSettings() |
272 | { | 272 | { |
273 | QStringList activeExtensions; | 273 | QStringList activeExtensions; |
274 | 274 | ||
275 | QPtrList<QListViewItem> list; | 275 | QPtrList<QListViewItem> list; |
276 | QListViewItemIterator it( mExtensionView ); | 276 | QListViewItemIterator it( mExtensionView ); |
277 | while ( it.current() ) { | 277 | while ( it.current() ) { |
278 | ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); | 278 | ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); |
279 | if ( item ) { | 279 | if ( item ) { |
280 | if ( item->isOn() ) | 280 | if ( item->isOn() ) |
281 | activeExtensions.append( item->factory()->identifier() ); | 281 | activeExtensions.append( item->factory()->identifier() ); |
282 | } | 282 | } |
283 | ++it; | 283 | ++it; |
284 | } | 284 | } |
285 | 285 | ||
286 | KABPrefs::instance()->mActiveExtensions = activeExtensions; | 286 | KABPrefs::instance()->mActiveExtensions = activeExtensions; |
287 | } | 287 | } |
288 | 288 | ||
289 | void KABConfigWidget::configureExtension() | 289 | void KABConfigWidget::configureExtension() |
290 | { | 290 | { |
291 | ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); | 291 | ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); |
292 | if ( !item ) | 292 | if ( !item ) |
293 | return; | 293 | return; |
294 | 294 | ||
295 | #ifndef KAB_EMBEDDED | 295 | #ifndef KAB_EMBEDDED |
296 | KConfig config( "kaddressbookrc" ); | 296 | KConfig config( "kaddressbookrc" ); |
297 | #else //KAB_EMBEDDED | 297 | #else //KAB_EMBEDDED |
298 | KConfig config( locateLocal("config", "kaddressbookrc") ); | 298 | KConfig config( locateLocal("config", "kaddressbookrc") ); |
299 | #endif //KAB_EMBEDDED | 299 | #endif //KAB_EMBEDDED |
300 | config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); | 300 | config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); |
301 | 301 | ||
302 | ExtensionConfigDialog dlg( item->factory(), &config, this ); | 302 | ExtensionConfigDialog dlg( item->factory(), &config, this ); |
303 | dlg.exec(); | 303 | dlg.exec(); |
304 | 304 | ||
305 | config.sync(); | 305 | config.sync(); |
306 | } | 306 | } |
307 | 307 | ||
308 | void KABConfigWidget::selectionChanged( QListViewItem *i ) | 308 | void KABConfigWidget::selectionChanged( QListViewItem *i ) |
309 | { | 309 | { |
310 | ExtensionItem *item = static_cast<ExtensionItem*>( i ); | 310 | ExtensionItem *item = static_cast<ExtensionItem*>( i ); |
311 | if ( !item ) | 311 | if ( !item ) |
312 | return; | 312 | return; |
313 | 313 | ||
314 | mConfigureButton->setEnabled( item->configWidgetAvailable() ); | 314 | mConfigureButton->setEnabled( item->configWidgetAvailable() ); |
315 | } | 315 | } |
316 | 316 | ||
317 | void KABConfigWidget::itemClicked( QListViewItem *item ) | 317 | void KABConfigWidget::itemClicked( QListViewItem *item ) |
318 | { | 318 | { |
319 | if ( item != 0 ) | 319 | if ( item != 0 ) |
320 | modified(); | 320 | modified(); |
321 | } | 321 | } |
322 | 322 | ||
323 | #ifndef KAB_EMBEDDED | 323 | #ifndef KAB_EMBEDDED |
324 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) | 324 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) |
325 | : QCheckListItem( parent, text, CheckBox ) | 325 | : QCheckListItem( parent, text, CheckBox ) |
326 | { | 326 | { |
327 | } | 327 | } |
328 | 328 | ||
329 | void ExtensionItem::setService( const KService::Ptr &ptr ) | 329 | void ExtensionItem::setService( const KService::Ptr &ptr ) |
330 | { | 330 | { |
331 | mPtr = ptr; | 331 | mPtr = ptr; |
332 | } | 332 | } |
333 | #else //KAB_EMBEDDED | 333 | #else //KAB_EMBEDDED |
334 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) | 334 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) |
335 | : QCheckListItem( parent, text, CheckBox ) | 335 | : QCheckListItem( parent, text, CheckBox ) |
336 | { | 336 | { |
337 | mName = name; | 337 | mName = name; |
338 | mComment = comment; | 338 | mComment = comment; |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | void ExtensionItem::setFactory( ExtensionFactory* fac ) | 342 | void ExtensionItem::setFactory( ExtensionFactory* fac ) |
343 | { | 343 | { |
344 | mFactory = fac; | 344 | mFactory = fac; |
345 | } | 345 | } |
346 | #endif //KAB_EMBEDDED | 346 | #endif //KAB_EMBEDDED |
347 | 347 | ||
348 | bool ExtensionItem::configWidgetAvailable() const | 348 | bool ExtensionItem::configWidgetAvailable() const |
349 | { | 349 | { |
350 | #ifndef KAB_EMBEDDED | 350 | #ifndef KAB_EMBEDDED |
351 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); | 351 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); |
352 | if ( !factory ) | 352 | if ( !factory ) |
353 | return false; | 353 | return false; |
354 | 354 | ||
355 | ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); | 355 | ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); |
356 | if ( !extensionFactory ) | 356 | if ( !extensionFactory ) |
357 | return false; | 357 | return false; |
358 | 358 | ||
359 | return extensionFactory->configureWidgetAvailable(); | 359 | return extensionFactory->configureWidgetAvailable(); |
360 | #else //KAB_EMBEDDED | 360 | #else //KAB_EMBEDDED |
361 | return mFactory->configureWidgetAvailable(); | 361 | return mFactory->configureWidgetAvailable(); |
362 | #endif //KAB_EMBEDDED | 362 | #endif //KAB_EMBEDDED |
363 | 363 | ||
364 | } | 364 | } |
365 | 365 | ||
366 | ExtensionFactory *ExtensionItem::factory() const | 366 | ExtensionFactory *ExtensionItem::factory() const |
367 | { | 367 | { |
368 | #ifndef KAB_EMBEDDED | 368 | #ifndef KAB_EMBEDDED |
369 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); | 369 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); |
370 | if ( !factory ) | 370 | if ( !factory ) |
371 | return 0; | 371 | return 0; |
372 | 372 | ||
373 | return static_cast<ExtensionFactory*>( factory ); | 373 | return static_cast<ExtensionFactory*>( factory ); |
374 | #else //KAB_EMBEDDED | 374 | #else //KAB_EMBEDDED |
375 | return mFactory; | 375 | return mFactory; |
376 | #endif //KAB_EMBEDDED | 376 | #endif //KAB_EMBEDDED |
377 | } | 377 | } |
378 | 378 | ||
379 | QString ExtensionItem::text( int column ) const | 379 | QString ExtensionItem::text( int column ) const |
380 | { | 380 | { |
381 | #ifndef KAB_EMBEDDED | 381 | #ifndef KAB_EMBEDDED |
382 | if ( column == 0 ) | 382 | if ( column == 0 ) |
383 | return mPtr->name(); | 383 | return mPtr->name(); |
384 | else if ( column == 1 ) | 384 | else if ( column == 1 ) |
385 | return mPtr->comment(); | 385 | return mPtr->comment(); |
386 | else | 386 | else |
387 | return QString::null; | 387 | return QString::null; |
388 | #else //KAB_EMBEDDED | 388 | #else //KAB_EMBEDDED |
389 | if ( column == 0 ) | 389 | if ( column == 0 ) |
390 | return mName; | 390 | return mName; |
391 | else if ( column == 1 ) | 391 | else if ( column == 1 ) |
392 | return mComment; | 392 | return mComment; |
393 | else | 393 | else |
394 | return QString::null; | 394 | return QString::null; |
395 | #endif //KAB_EMBEDDED | 395 | #endif //KAB_EMBEDDED |
396 | } | 396 | } |
397 | 397 | ||
398 | #ifndef KAB_EMBEDDED | 398 | #ifndef KAB_EMBEDDED |
399 | #include "kabconfigwidget.moc" | 399 | #include "kabconfigwidget.moc" |
400 | #endif //KAB_EMBEDDED | 400 | #endif //KAB_EMBEDDED |
401 | 401 | ||
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index 771bec9..1e03dba 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp | |||
@@ -1,99 +1,100 @@ | |||
1 | #ifndef DESKTOP_VERSION | 1 | #ifndef DESKTOP_VERSION |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <qcopchannel_qws.h> | 3 | #include <qcopchannel_qws.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #else | 5 | #else |
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | #include <qwindowsstyle.h> | 7 | #include <qwindowsstyle.h> |
8 | #include <qplatinumstyle.h> | 8 | #include <qplatinumstyle.h> |
9 | #include <qmainwindow.h> | 9 | #include <qmainwindow.h> |
10 | #endif | 10 | #endif |
11 | 11 | ||
12 | #include <qtextcodec.h> | 12 | #include <qtextcodec.h> |
13 | #include <kstandarddirs.h> | 13 | #include <kstandarddirs.h> |
14 | #include <qregexp.h> | 14 | #include <qregexp.h> |
15 | #include <kglobal.h> | 15 | #include <kglobal.h> |
16 | #include <stdio.h> | 16 | #include <stdio.h> |
17 | #include <qdir.h> | 17 | #include <qdir.h> |
18 | #include "kabprefs.h" | 18 | #include "kabprefs.h" |
19 | #include "kaddressbookmain.h" | 19 | #include "kaddressbookmain.h" |
20 | #include "externalapphandler.h" | 20 | #include "externalapphandler.h" |
21 | #include <libkdepim/kpimglobalprefs.h> | 21 | #include <libkdepim/kpimglobalprefs.h> |
22 | void dumpMissing(); | 22 | void dumpMissing(); |
23 | int main( int argc, char **argv ) | 23 | int main( int argc, char **argv ) |
24 | { | 24 | { |
25 | #ifndef DESKTOP_VERSION | 25 | #ifndef DESKTOP_VERSION |
26 | QPEApplication a( argc, argv ); | 26 | QPEApplication a( argc, argv ); |
27 | a.setKeepRunning (); | 27 | a.setKeepRunning (); |
28 | #else | 28 | #else |
29 | QApplication a( argc, argv ); | 29 | QApplication a( argc, argv ); |
30 | QApplication::setStyle( new QPlatinumStyle ()); | 30 | QApplication::setStyle( new QPlatinumStyle ()); |
31 | QString hdir = QDir::homeDirPath(); | 31 | QString hdir = QDir::homeDirPath(); |
32 | // there is a bug when creating dirs for WIN 98 | 32 | // there is a bug when creating dirs for WIN 98 |
33 | // it is difficult to fix, because we have no WIN 98 runnung | 33 | // it is difficult to fix, because we have no WIN 98 runnung |
34 | // such that we try it to create the dirs at startup here | 34 | // such that we try it to create the dirs at startup here |
35 | if ( hdir == "C:\\" ) { // win 98 or ME | 35 | if ( hdir == "C:\\" ) { // win 98 or ME |
36 | QDir app_dir; | 36 | QDir app_dir; |
37 | if ( !app_dir.exists("C:\\kdepim") ) | 37 | if ( !app_dir.exists("C:\\kdepim") ) |
38 | app_dir.mkdir ("C:\\kdepim"); | 38 | app_dir.mkdir ("C:\\kdepim"); |
39 | if ( !app_dir.exists("C:\\kdepim\\apps") ) | 39 | if ( !app_dir.exists("C:\\kdepim\\apps") ) |
40 | app_dir.mkdir ("C:\\kdepim\\apps"); | 40 | app_dir.mkdir ("C:\\kdepim\\apps"); |
41 | if ( !app_dir.exists("C:\\kdepim\\config") ) | 41 | if ( !app_dir.exists("C:\\kdepim\\config") ) |
42 | app_dir.mkdir ("C:\\kdepim\\config"); | 42 | app_dir.mkdir ("C:\\kdepim\\config"); |
43 | if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) | 43 | if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) |
44 | app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); | 44 | app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); |
45 | } | 45 | } |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | bool exitHelp = false; | 48 | bool exitHelp = false; |
49 | if ( argc > 1 ) { | 49 | if ( argc > 1 ) { |
50 | QString command = argv[1]; | 50 | QString command = argv[1]; |
51 | if ( command == "-help" ){ | 51 | if ( command == "-help" ){ |
52 | printf("KA/E command line commands:\n"); | 52 | printf("KA/E command line commands:\n"); |
53 | printf(" no command: Start KA/E in usual way\n"); | 53 | printf(" no command: Start KA/E in usual way\n"); |
54 | printf(" -help: This output\n"); | 54 | printf(" -help: This output\n"); |
55 | printf(" KA/E is exiting now. Bye!\n"); | 55 | printf(" KA/E is exiting now. Bye!\n"); |
56 | exitHelp = true; | 56 | exitHelp = true; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | if ( ! exitHelp ) { | 59 | if ( ! exitHelp ) { |
60 | 60 | ||
61 | KGlobal::setAppName( "kaddressbook" ); | 61 | KGlobal::setAppName( "kaddressbook" ); |
62 | #ifndef DESKTOP_VERSION | 62 | #ifndef DESKTOP_VERSION |
63 | if ( QApplication::desktop()->width() > 320 ) | 63 | if ( QApplication::desktop()->width() > 320 ) |
64 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); | 64 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); |
65 | else | 65 | else |
66 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); | 66 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); |
67 | #else | 67 | #else |
68 | QString fileName ; | 68 | QString fileName ; |
69 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; | 69 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; |
70 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 70 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
71 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); | 71 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); |
72 | 72 | ||
73 | #endif | 73 | #endif |
74 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); | 74 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); |
75 | // init language | 75 | // init language |
76 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 76 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
77 | KAddressBookMain m ; | 77 | KAddressBookMain m ; |
78 | //US MainWindow m; | 78 | //US MainWindow m; |
79 | #ifndef DESKTOP_VERSION | ||
79 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 80 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
80 | 81 | #endif | |
81 | 82 | ||
82 | 83 | ||
83 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
84 | a.showMainWidget( &m ); | 85 | a.showMainWidget( &m ); |
85 | 86 | ||
86 | #else | 87 | #else |
87 | a.setMainWidget( &m ); | 88 | a.setMainWidget( &m ); |
88 | m.resize (640, 480 ); | 89 | m.resize (640, 480 ); |
89 | m.show(); | 90 | m.show(); |
90 | #endif | 91 | #endif |
91 | a.exec(); | 92 | a.exec(); |
92 | 93 | ||
93 | dumpMissing(); | 94 | dumpMissing(); |
94 | 95 | ||
95 | KPimGlobalPrefs::instance()->writeConfig(); | 96 | KPimGlobalPrefs::instance()->writeConfig(); |
96 | } | 97 | } |
97 | qDebug("KA: Bye! "); | 98 | qDebug("KA: Bye! "); |
98 | } | 99 | } |
99 | 100 | ||
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h index 272e1b0..dff9998 100644 --- a/kaddressbook/viewmanager.h +++ b/kaddressbook/viewmanager.h | |||
@@ -1,159 +1,160 @@ | |||
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 | #ifndef VIEWMANAGER_H | 24 | #ifndef VIEWMANAGER_H |
25 | #define VIEWMANAGER_H | 25 | #define VIEWMANAGER_H |
26 | 26 | ||
27 | #include <qwidget.h> | 27 | #include <qwidget.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <kaddressbookview.h> | 29 | #include <kaddressbookview.h> |
30 | #include <qdict.h> | 30 | #include <qdict.h> |
31 | #include "filter.h" | 31 | #include "filter.h" |
32 | 32 | ||
33 | class KAction; | 33 | class KAction; |
34 | class KSelectAction; | 34 | class KSelectAction; |
35 | 35 | ||
36 | class KABCore; | 36 | class KABCore; |
37 | class QWidgetStack; | 37 | class QWidgetStack; |
38 | class QDropEvent; | 38 | class QDropEvent; |
39 | 39 | ||
40 | namespace KABC { class AddressBook; } | 40 | namespace KABC { class AddressBook; } |
41 | 41 | ||
42 | /** | 42 | /** |
43 | The view manager manages the views and everything related to them. The | 43 | The view manager manages the views and everything related to them. The |
44 | manager will load the views at startup and display a view when told to | 44 | manager will load the views at startup and display a view when told to |
45 | make one active. | 45 | make one active. |
46 | 46 | ||
47 | The view manager will also create and manage all dialogs directly related to | 47 | The view manager will also create and manage all dialogs directly related to |
48 | views (ie: AddView, ConfigureView, DeleteView, etc). | 48 | views (ie: AddView, ConfigureView, DeleteView, etc). |
49 | */ | 49 | */ |
50 | class ViewManager : public QWidget | 50 | class ViewManager : public QWidget |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | public: | 53 | public: |
54 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); | 54 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); |
55 | ~ViewManager(); | 55 | ~ViewManager(); |
56 | 56 | ||
57 | void restoreSettings(); | 57 | void restoreSettings(); |
58 | void saveSettings(); | 58 | void saveSettings(); |
59 | void doSearch( const QString& s ,KABC::Field *field ); | 59 | void doSearch( const QString& s ,KABC::Field *field ); |
60 | 60 | ||
61 | void unloadViews(); | 61 | void unloadViews(); |
62 | KSelectAction * getFilterAction() { return mActionSelectFilter; } | 62 | KSelectAction * getFilterAction() { return mActionSelectFilter; } |
63 | Filter getFilterByName( const QString &name ) const; | 63 | Filter getFilterByName( const QString &name ) const; |
64 | 64 | ||
65 | QStringList selectedUids() const; | 65 | QStringList selectedUids() const; |
66 | QStringList selectedEmails() const; | 66 | QStringList selectedEmails() const; |
67 | KABC::Addressee::List selectedAddressees() const; | 67 | KABC::Addressee::List selectedAddressees() const; |
68 | void setListSelected(QStringList); | 68 | void setListSelected(QStringList); |
69 | void setFocusAV(); | 69 | void setFocusAV(); |
70 | 70 | ||
71 | public slots: | 71 | public slots: |
72 | void printView() { if (mActiveView) mActiveView->printMyView() ;} | ||
72 | void scrollUP(); | 73 | void scrollUP(); |
73 | void scrollDOWN(); | 74 | void scrollDOWN(); |
74 | 75 | ||
75 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); | 76 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); |
76 | void setSelected( const QString &uid, bool); | 77 | void setSelected( const QString &uid, bool); |
77 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 78 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
78 | void setSelected(); | 79 | void setSelected(); |
79 | 80 | ||
80 | 81 | ||
81 | 82 | ||
82 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 83 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
83 | void refreshView(); | 84 | void refreshView(); |
84 | void refreshView( const QString &uid); | 85 | void refreshView( const QString &uid); |
85 | 86 | ||
86 | void editView(); | 87 | void editView(); |
87 | void deleteView(); | 88 | void deleteView(); |
88 | void addView(); | 89 | void addView(); |
89 | 90 | ||
90 | protected slots: | 91 | protected slots: |
91 | /** | 92 | /** |
92 | Called whenever the user drops something in the active view. | 93 | Called whenever the user drops something in the active view. |
93 | This method will try to decode what was dropped, and if it was | 94 | This method will try to decode what was dropped, and if it was |
94 | a valid addressee, add it to the addressbook. | 95 | a valid addressee, add it to the addressbook. |
95 | */ | 96 | */ |
96 | void dropped( QDropEvent* ); | 97 | void dropped( QDropEvent* ); |
97 | 98 | ||
98 | /** | 99 | /** |
99 | Called whenever the user attempts to start a drag in the view. | 100 | Called whenever the user attempts to start a drag in the view. |
100 | This method will convert all the selected addressees into text (vcard) | 101 | This method will convert all the selected addressees into text (vcard) |
101 | and create a drag object. | 102 | and create a drag object. |
102 | */ | 103 | */ |
103 | void startDrag(); | 104 | void startDrag(); |
104 | 105 | ||
105 | signals: | 106 | signals: |
106 | /** | 107 | /** |
107 | Emitted whenever the user selects an entry in the view. | 108 | Emitted whenever the user selects an entry in the view. |
108 | */ | 109 | */ |
109 | void selected( const QString &uid ); | 110 | void selected( const QString &uid ); |
110 | void deleteRequest( ); | 111 | void deleteRequest( ); |
111 | 112 | ||
112 | /** | 113 | /** |
113 | Emitted whenever the user activates an entry in the view. | 114 | Emitted whenever the user activates an entry in the view. |
114 | */ | 115 | */ |
115 | void executed( const QString &uid ); | 116 | void executed( const QString &uid ); |
116 | 117 | ||
117 | /** | 118 | /** |
118 | Emitted whenever the address book is modified in some way. | 119 | Emitted whenever the address book is modified in some way. |
119 | */ | 120 | */ |
120 | void modified(); | 121 | void modified(); |
121 | 122 | ||
122 | /** | 123 | /** |
123 | Emitted whenever a url is dragged on a view. | 124 | Emitted whenever a url is dragged on a view. |
124 | */ | 125 | */ |
125 | void urlDropped( const KURL& ); | 126 | void urlDropped( const KURL& ); |
126 | 127 | ||
127 | private slots: | 128 | private slots: |
128 | void setActiveView( const QString &name ); | 129 | void setActiveView( const QString &name ); |
129 | void setActiveFilter( int index ); | 130 | void setActiveFilter( int index ); |
130 | void configureFilters(); | 131 | void configureFilters(); |
131 | 132 | ||
132 | private: | 133 | private: |
133 | void createViewFactories(); | 134 | void createViewFactories(); |
134 | QStringList filterNames() const; | 135 | QStringList filterNames() const; |
135 | int filterPosition( const QString &name ) const; | 136 | int filterPosition( const QString &name ) const; |
136 | QStringList viewNames() const; | 137 | QStringList viewNames() const; |
137 | int viewPosition( const QString &name ) const; | 138 | int viewPosition( const QString &name ) const; |
138 | void initActions(); | 139 | void initActions(); |
139 | void initGUI(); | 140 | void initGUI(); |
140 | 141 | ||
141 | KABCore *mCore; | 142 | KABCore *mCore; |
142 | 143 | ||
143 | Filter mCurrentFilter; | 144 | Filter mCurrentFilter; |
144 | Filter::List mFilterList; | 145 | Filter::List mFilterList; |
145 | 146 | ||
146 | QDict<KAddressBookView> mViewDict; | 147 | QDict<KAddressBookView> mViewDict; |
147 | QDict<ViewFactory> mViewFactoryDict; | 148 | QDict<ViewFactory> mViewFactoryDict; |
148 | QStringList mViewNameList; | 149 | QStringList mViewNameList; |
149 | 150 | ||
150 | QWidgetStack *mViewWidgetStack; | 151 | QWidgetStack *mViewWidgetStack; |
151 | KAddressBookView *mActiveView; | 152 | KAddressBookView *mActiveView; |
152 | 153 | ||
153 | KAction *mActionDeleteView; | 154 | KAction *mActionDeleteView; |
154 | KSelectAction *mActionSelectFilter; | 155 | KSelectAction *mActionSelectFilter; |
155 | KSelectAction *mActionSelectView; | 156 | KSelectAction *mActionSelectView; |
156 | 157 | ||
157 | }; | 158 | }; |
158 | 159 | ||
159 | #endif | 160 | #endif |
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp index 23b091c..e75810e 100644 --- a/kaddressbook/views/contactlistview.cpp +++ b/kaddressbook/views/contactlistview.cpp | |||
@@ -1,373 +1,400 @@ | |||
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 | #include <qheader.h> | 24 | #include <qheader.h> |
25 | #include <qiconset.h> | 25 | #include <qiconset.h> |
26 | #include <qimage.h> | 26 | #include <qimage.h> |
27 | #include <qdragobject.h> | 27 | #include <qdragobject.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qbrush.h> | 30 | #include <qbrush.h> |
31 | #include <qevent.h> | 31 | #include <qevent.h> |
32 | 32 | ||
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobalsettings.h> | 34 | #include <kglobalsettings.h> |
35 | #include <kiconloader.h> | 35 | #include <kiconloader.h> |
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <kconfig.h> | 37 | #include <kconfig.h> |
38 | #include <kapplication.h> | 38 | #include <kapplication.h> |
39 | #include <kurl.h> | 39 | #include <kurl.h> |
40 | 40 | ||
41 | #include "kaddressbooktableview.h" | 41 | #include "kaddressbooktableview.h" |
42 | 42 | ||
43 | #include "contactlistview.h" | 43 | #include "contactlistview.h" |
44 | 44 | ||
45 | ///////////////////////////////// | 45 | ///////////////////////////////// |
46 | // DynamicTip Methods | 46 | // DynamicTip Methods |
47 | 47 | ||
48 | DynamicTip::DynamicTip( ContactListView *parent) | 48 | DynamicTip::DynamicTip( ContactListView *parent) |
49 | : QToolTip( parent ) | 49 | : QToolTip( parent ) |
50 | { | 50 | { |
51 | } | 51 | } |
52 | 52 | ||
53 | void DynamicTip::maybeTip( const QPoint &pos ) | 53 | void DynamicTip::maybeTip( const QPoint &pos ) |
54 | { | 54 | { |
55 | static bool ishidden = true; | 55 | static bool ishidden = true; |
56 | if (!parentWidget()->inherits( "ContactListView" )) | 56 | if (!parentWidget()->inherits( "ContactListView" )) |
57 | return; | 57 | return; |
58 | 58 | ||
59 | ContactListView *plv = (ContactListView*)parentWidget(); | 59 | ContactListView *plv = (ContactListView*)parentWidget(); |
60 | if (!plv->tooltips()) | 60 | if (!plv->tooltips()) |
61 | return; | 61 | return; |
62 | 62 | ||
63 | QPoint posVp = plv->viewport()->pos(); | 63 | QPoint posVp = plv->viewport()->pos(); |
64 | 64 | ||
65 | QListViewItem *lvi = plv->itemAt( pos - posVp ); | 65 | QListViewItem *lvi = plv->itemAt( pos - posVp ); |
66 | if (!lvi) | 66 | if (!lvi) |
67 | return; | 67 | return; |
68 | 68 | ||
69 | #ifndef KAB_EMBEDDED | 69 | #ifndef KAB_EMBEDDED |
70 | ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi); | 70 | ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi); |
71 | #else //KAB_EMBEDDED | 71 | #else //KAB_EMBEDDED |
72 | ContactListViewItem *plvi = (ContactListViewItem*)(lvi); | 72 | ContactListViewItem *plvi = (ContactListViewItem*)(lvi); |
73 | #endif //KAB_EMBEDDED | 73 | #endif //KAB_EMBEDDED |
74 | 74 | ||
75 | if (!plvi) | 75 | if (!plvi) |
76 | return; | 76 | return; |
77 | 77 | ||
78 | if (ishidden) { | 78 | if (ishidden) { |
79 | QString s; | 79 | QString s; |
80 | QRect r = plv->itemRect( lvi ); | 80 | QRect r = plv->itemRect( lvi ); |
81 | r.moveBy( posVp.x(), posVp.y() ); | 81 | r.moveBy( posVp.x(), posVp.y() ); |
82 | 82 | ||
83 | //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width() | 83 | //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width() |
84 | // << "," << r.height() << endl; | 84 | // << "," << r.height() << endl; |
85 | 85 | ||
86 | KABC::Addressee a = plvi->addressee(); | 86 | KABC::Addressee a = plvi->addressee(); |
87 | if (a.isEmpty()) | 87 | if (a.isEmpty()) |
88 | return; | 88 | return; |
89 | 89 | ||
90 | s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel()) | 90 | s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel()) |
91 | .arg(a.formattedName()); | 91 | .arg(a.formattedName()); |
92 | 92 | ||
93 | s += '\n'; | 93 | s += '\n'; |
94 | s += i18n("label: value", "%1: %2").arg(a.organizationLabel()) | 94 | s += i18n("label: value", "%1: %2").arg(a.organizationLabel()) |
95 | .arg(a.organization()); | 95 | .arg(a.organization()); |
96 | 96 | ||
97 | QString notes = a.note().stripWhiteSpace(); | 97 | QString notes = a.note().stripWhiteSpace(); |
98 | if ( !notes.isEmpty() ) { | 98 | if ( !notes.isEmpty() ) { |
99 | notes += '\n'; | 99 | notes += '\n'; |
100 | s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); | 100 | s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); |
101 | QFontMetrics fm( font() ); | 101 | QFontMetrics fm( font() ); |
102 | 102 | ||
103 | // Begin word wrap code based on QMultiLineEdit code | 103 | // Begin word wrap code based on QMultiLineEdit code |
104 | int i = 0; | 104 | int i = 0; |
105 | bool doBreak = false; | 105 | bool doBreak = false; |
106 | int linew = 0; | 106 | int linew = 0; |
107 | int lastSpace = -1; | 107 | int lastSpace = -1; |
108 | int a = 0; | 108 | int a = 0; |
109 | int lastw = 0; | 109 | int lastw = 0; |
110 | 110 | ||
111 | while ( i < int(notes.length()) ) { | 111 | while ( i < int(notes.length()) ) { |
112 | doBreak = FALSE; | 112 | doBreak = FALSE; |
113 | if ( notes[i] != '\n' ) | 113 | if ( notes[i] != '\n' ) |
114 | linew += fm.width( notes[i] ); | 114 | linew += fm.width( notes[i] ); |
115 | 115 | ||
116 | if ( lastSpace >= a && notes[i] != '\n' ) | 116 | if ( lastSpace >= a && notes[i] != '\n' ) |
117 | if (linew >= parentWidget()->width()) { | 117 | if (linew >= parentWidget()->width()) { |
118 | doBreak = TRUE; | 118 | doBreak = TRUE; |
119 | if ( lastSpace > a ) { | 119 | if ( lastSpace > a ) { |
120 | i = lastSpace; | 120 | i = lastSpace; |
121 | linew = lastw; | 121 | linew = lastw; |
122 | } | 122 | } |
123 | else | 123 | else |
124 | i = QMAX( a, i-1 ); | 124 | i = QMAX( a, i-1 ); |
125 | } | 125 | } |
126 | 126 | ||
127 | if ( notes[i] == '\n' || doBreak ) { | 127 | if ( notes[i] == '\n' || doBreak ) { |
128 | s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n"; | 128 | s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n"; |
129 | 129 | ||
130 | a = i + 1; | 130 | a = i + 1; |
131 | lastSpace = a; | 131 | lastSpace = a; |
132 | linew = 0; | 132 | linew = 0; |
133 | } | 133 | } |
134 | 134 | ||
135 | if ( notes[i].isSpace() ) { | 135 | if ( notes[i].isSpace() ) { |
136 | lastSpace = i; | 136 | lastSpace = i; |
137 | lastw = linew; | 137 | lastw = linew; |
138 | } | 138 | } |
139 | 139 | ||
140 | if ( lastSpace <= a ) { | 140 | if ( lastSpace <= a ) { |
141 | lastw = linew; | 141 | lastw = linew; |
142 | } | 142 | } |
143 | 143 | ||
144 | ++i; | 144 | ++i; |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | tip( r, s ); | 148 | tip( r, s ); |
149 | } | 149 | } |
150 | else | 150 | else |
151 | hide(); | 151 | hide(); |
152 | ishidden = !ishidden; | 152 | ishidden = !ishidden; |
153 | 153 | ||
154 | } | 154 | } |
155 | 155 | ||
156 | /////////////////////////// | 156 | /////////////////////////// |
157 | // ContactListViewItem Methods | 157 | // ContactListViewItem Methods |
158 | 158 | ||
159 | ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, | 159 | ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, |
160 | ContactListView *parent, | 160 | ContactListView *parent, |
161 | KABC::AddressBook *doc, | 161 | KABC::AddressBook *doc, |
162 | const KABC::Field::List &fields ) | 162 | const KABC::Field::List &fields ) |
163 | : KListViewItem(parent), mAddressee(a), mFields( fields ), | 163 | : KListViewItem(parent), mAddressee(a), mFields( fields ), |
164 | parentListView( parent ), mDocument(doc) | 164 | parentListView( parent ), mDocument(doc) |
165 | { | 165 | { |
166 | refresh(); | 166 | refresh(); |
167 | } | 167 | } |
168 | 168 | ||
169 | QString ContactListViewItem::key(int column, bool ascending) const | 169 | QString ContactListViewItem::key(int column, bool ascending) const |
170 | { | 170 | { |
171 | #ifndef DESKTOP_VERSION | 171 | #ifndef DESKTOP_VERSION |
172 | int lan = KGlobal::locale()->language(); | 172 | int lan = KGlobal::locale()->language(); |
173 | //qDebug("language %d ", lan); | 173 | //qDebug("language %d ", lan); |
174 | if ( lan == 1 ) { //GERMAN | 174 | if ( lan == 1 ) { //GERMAN |
175 | QString ret = QListViewItem::key(column, ascending).lower().utf8(); | 175 | QString ret = QListViewItem::key(column, ascending).lower().utf8(); |
176 | int start = -1; | 176 | int start = -1; |
177 | while ( (start = ret.find( 'ä', start+1)) > 0 ) { | 177 | while ( (start = ret.find( 'ä', start+1)) > 0 ) { |
178 | ret.at(start-1) = 'a'; | 178 | ret.at(start-1) = 'a'; |
179 | } | 179 | } |
180 | start = -1; | 180 | start = -1; |
181 | while ( (start = ret.find( 'ö', start+1)) > 0 ) { | 181 | while ( (start = ret.find( 'ö', start+1)) > 0 ) { |
182 | ret.at(start-1) = 'o'; | 182 | ret.at(start-1) = 'o'; |
183 | } | 183 | } |
184 | start = -1; | 184 | start = -1; |
185 | while ( (start = ret.find( 'ü', start+1)) > 0 ) { | 185 | while ( (start = ret.find( 'ü', start+1)) > 0 ) { |
186 | ret.at(start-1) = 'o'; | 186 | ret.at(start-1) = 'o'; |
187 | } | 187 | } |
188 | start = -1; | 188 | start = -1; |
189 | while ( (start = ret.find( 'ß', start+1)) > 0 ) { | 189 | while ( (start = ret.find( 'ß', start+1)) > 0 ) { |
190 | ret.at(start-1) = 's'; | 190 | ret.at(start-1) = 's'; |
191 | } | 191 | } |
192 | //qDebug("conv string %s ", ret.latin1()); | 192 | //qDebug("conv string %s ", ret.latin1()); |
193 | 193 | ||
194 | return ret; | 194 | return ret; |
195 | 195 | ||
196 | } | 196 | } |
197 | else | 197 | else |
198 | #endif | 198 | #endif |
199 | return QListViewItem::key(column, ascending).lower(); | 199 | return QListViewItem::key(column, ascending).lower(); |
200 | } | 200 | } |
201 | 201 | ||
202 | void ContactListViewItem::paintCell(QPainter * p, | 202 | void ContactListViewItem::paintCell(QPainter * p, |
203 | const QColorGroup & cg, | 203 | const QColorGroup & cg, |
204 | int column, | 204 | int column, |
205 | int width, | 205 | int width, |
206 | int align) | 206 | int align) |
207 | { | 207 | { |
208 | KListViewItem::paintCell(p, cg, column, width, align); | 208 | KListViewItem::paintCell(p, cg, column, width, align); |
209 | 209 | ||
210 | if ( !p ) | 210 | if ( !p ) |
211 | return; | 211 | return; |
212 | 212 | ||
213 | if (parentListView->singleLine()) { | 213 | if (parentListView->singleLine()) { |
214 | p->setPen( parentListView->alternateColor() ); | 214 | p->setPen( parentListView->alternateColor() ); |
215 | p->drawLine( 0, height() - 1, width, height() - 1 ); | 215 | p->drawLine( 0, height() - 1, width, height() - 1 ); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | 219 | ||
220 | ContactListView *ContactListViewItem::parent() | 220 | ContactListView *ContactListViewItem::parent() |
221 | { | 221 | { |
222 | return parentListView; | 222 | return parentListView; |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | void ContactListViewItem::refresh() | 226 | void ContactListViewItem::refresh() |
227 | { | 227 | { |
228 | // Update our addressee, since it may have changed else were | 228 | // Update our addressee, since it may have changed else were |
229 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 229 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
230 | if (mAddressee.isEmpty()) | 230 | if (mAddressee.isEmpty()) |
231 | return; | 231 | return; |
232 | 232 | ||
233 | int i = 0; | 233 | int i = 0; |
234 | KABC::Field::List::ConstIterator it; | 234 | KABC::Field::List::ConstIterator it; |
235 | for( it = mFields.begin(); it != mFields.end(); ++it ) { | 235 | for( it = mFields.begin(); it != mFields.end(); ++it ) { |
236 | setText( i++, (*it)->value( mAddressee ) ); | 236 | setText( i++, (*it)->value( mAddressee ) ); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | /////////////////////////////// | 240 | /////////////////////////////// |
241 | // ContactListView | 241 | // ContactListView |
242 | 242 | ||
243 | ContactListView::ContactListView(KAddressBookTableView *view, | 243 | ContactListView::ContactListView(KAddressBookTableView *view, |
244 | KABC::AddressBook* /* doc */, | 244 | KABC::AddressBook* /* doc */, |
245 | QWidget *parent, | 245 | QWidget *parent, |
246 | const char *name ) | 246 | const char *name ) |
247 | : KListView( parent, name ), | 247 | : KListView( parent, name ), |
248 | pabWidget( view ), | 248 | pabWidget( view ), |
249 | oldColumn( 0 ) | 249 | oldColumn( 0 ) |
250 | { | 250 | { |
251 | mABackground = true; | 251 | mABackground = true; |
252 | mSingleLine = false; | 252 | mSingleLine = false; |
253 | mToolTips = true; | 253 | mToolTips = true; |
254 | #ifndef KAB_EMBEDDED | 254 | #ifndef KAB_EMBEDDED |
255 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); | 255 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); |
256 | #else //KAB_EMBEDDED | 256 | #else //KAB_EMBEDDED |
257 | mAlternateColor = QColor(240, 240, 240); | 257 | mAlternateColor = QColor(240, 240, 240); |
258 | #endif //KAB_EMBEDDED | 258 | #endif //KAB_EMBEDDED |
259 | 259 | ||
260 | setAlternateBackgroundEnabled(mABackground); | 260 | setAlternateBackgroundEnabled(mABackground); |
261 | setAcceptDrops( true ); | 261 | setAcceptDrops( true ); |
262 | viewport()->setAcceptDrops( true ); | 262 | viewport()->setAcceptDrops( true ); |
263 | setAllColumnsShowFocus( true ); | 263 | setAllColumnsShowFocus( true ); |
264 | setShowSortIndicator(true); | 264 | setShowSortIndicator(true); |
265 | 265 | ||
266 | setSelectionModeExt( KListView::Extended ); | 266 | setSelectionModeExt( KListView::Extended ); |
267 | setDropVisualizer(false); | 267 | setDropVisualizer(false); |
268 | // setFrameStyle(QFrame::NoFrame); | 268 | // setFrameStyle(QFrame::NoFrame); |
269 | //setLineWidth ( 0 ); | 269 | //setLineWidth ( 0 ); |
270 | //setMidLineWidth ( 0 ); | 270 | //setMidLineWidth ( 0 ); |
271 | //setMargin ( 0 ); | 271 | //setMargin ( 0 ); |
272 | #ifndef KAB_EMBEDDED | 272 | #ifndef KAB_EMBEDDED |
273 | connect(this, SIGNAL(dropped(QDropEvent*)), | 273 | connect(this, SIGNAL(dropped(QDropEvent*)), |
274 | this, SLOT(itemDropped(QDropEvent*))); | 274 | this, SLOT(itemDropped(QDropEvent*))); |
275 | #endif //KAB_EMBEDDED | 275 | #endif //KAB_EMBEDDED |
276 | 276 | ||
277 | 277 | ||
278 | new DynamicTip( this ); | 278 | new DynamicTip( this ); |
279 | } | 279 | } |
280 | void ContactListView::printMe() | ||
281 | { | ||
282 | #ifdef DESKTOP_VERSION | ||
283 | QPrinter printer; | ||
284 | if (!printer.setup() ) | ||
285 | return; | ||
286 | QPainter p; | ||
287 | p.begin ( &printer ); | ||
288 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | ||
289 | float dx, dy; | ||
290 | int wid = (m.width() * 9)/10; | ||
291 | dx = (float) wid/(float)contentsWidth (); | ||
292 | dy = (float)(m.height()) / (float)contentsHeight (); | ||
293 | float scale; | ||
294 | // scale to fit the width or height of the paper | ||
295 | if ( dx < dy ) | ||
296 | scale = dx; | ||
297 | else | ||
298 | scale = dy; | ||
299 | p.translate( m.width()/10,0 ); | ||
300 | p.scale( scale, scale ); | ||
301 | qDebug("scale %f ", scale); | ||
302 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | ||
303 | p.end(); | ||
304 | qDebug("Why does it not print??? "); | ||
305 | #endif | ||
306 | } | ||
280 | 307 | ||
281 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) | 308 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) |
282 | { | 309 | { |
283 | mAlternateColor = m_AlternateColor; | 310 | mAlternateColor = m_AlternateColor; |
284 | } | 311 | } |
285 | 312 | ||
286 | void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) | 313 | void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) |
287 | { | 314 | { |
288 | QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); | 315 | QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); |
289 | 316 | ||
290 | // Get the brush, which will have the background pixmap if there is one. | 317 | // Get the brush, which will have the background pixmap if there is one. |
291 | if (b.pixmap()) | 318 | if (b.pixmap()) |
292 | { | 319 | { |
293 | p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), | 320 | p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), |
294 | *(b.pixmap()), | 321 | *(b.pixmap()), |
295 | rect.left() + contentsX(), | 322 | rect.left() + contentsX(), |
296 | rect.top() + contentsY() ); | 323 | rect.top() + contentsY() ); |
297 | } | 324 | } |
298 | 325 | ||
299 | else | 326 | else |
300 | { | 327 | { |
301 | // Do a normal paint | 328 | // Do a normal paint |
302 | KListView::paintEmptyArea(p, rect); | 329 | KListView::paintEmptyArea(p, rect); |
303 | } | 330 | } |
304 | } | 331 | } |
305 | 332 | ||
306 | void ContactListView::contentsMousePressEvent(QMouseEvent* e) | 333 | void ContactListView::contentsMousePressEvent(QMouseEvent* e) |
307 | { | 334 | { |
308 | presspos = e->pos(); | 335 | presspos = e->pos(); |
309 | KListView::contentsMousePressEvent(e); | 336 | KListView::contentsMousePressEvent(e); |
310 | } | 337 | } |
311 | 338 | ||
312 | 339 | ||
313 | // To initiate a drag operation | 340 | // To initiate a drag operation |
314 | void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) | 341 | void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) |
315 | { | 342 | { |
316 | if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { | 343 | if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { |
317 | emit startAddresseeDrag(); | 344 | emit startAddresseeDrag(); |
318 | } | 345 | } |
319 | else | 346 | else |
320 | KListView::contentsMouseMoveEvent( e ); | 347 | KListView::contentsMouseMoveEvent( e ); |
321 | } | 348 | } |
322 | 349 | ||
323 | bool ContactListView::acceptDrag(QDropEvent *e) const | 350 | bool ContactListView::acceptDrag(QDropEvent *e) const |
324 | { | 351 | { |
325 | #ifndef KAB_EMBEDDED | 352 | #ifndef KAB_EMBEDDED |
326 | return QTextDrag::canDecode(e); | 353 | return QTextDrag::canDecode(e); |
327 | #else //KAB_EMBEDDED | 354 | #else //KAB_EMBEDDED |
328 | qDebug("ContactListView::acceptDrag has to be fixed"); | 355 | qDebug("ContactListView::acceptDrag has to be fixed"); |
329 | return false; | 356 | return false; |
330 | #endif //KAB_EMBEDDED | 357 | #endif //KAB_EMBEDDED |
331 | } | 358 | } |
332 | 359 | ||
333 | void ContactListView::itemDropped(QDropEvent *e) | 360 | void ContactListView::itemDropped(QDropEvent *e) |
334 | { | 361 | { |
335 | contentsDropEvent(e); | 362 | contentsDropEvent(e); |
336 | } | 363 | } |
337 | 364 | ||
338 | void ContactListView::contentsDropEvent( QDropEvent *e ) | 365 | void ContactListView::contentsDropEvent( QDropEvent *e ) |
339 | { | 366 | { |
340 | emit addresseeDropped(e); | 367 | emit addresseeDropped(e); |
341 | } | 368 | } |
342 | 369 | ||
343 | void ContactListView::setAlternateBackgroundEnabled(bool enabled) | 370 | void ContactListView::setAlternateBackgroundEnabled(bool enabled) |
344 | { | 371 | { |
345 | mABackground = enabled; | 372 | mABackground = enabled; |
346 | 373 | ||
347 | if (mABackground) | 374 | if (mABackground) |
348 | { | 375 | { |
349 | setAlternateBackground(mAlternateColor); | 376 | setAlternateBackground(mAlternateColor); |
350 | } | 377 | } |
351 | else | 378 | else |
352 | { | 379 | { |
353 | setAlternateBackground(QColor()); | 380 | setAlternateBackground(QColor()); |
354 | } | 381 | } |
355 | } | 382 | } |
356 | 383 | ||
357 | void ContactListView::setBackgroundPixmap(const QString &filename) | 384 | void ContactListView::setBackgroundPixmap(const QString &filename) |
358 | { | 385 | { |
359 | if (filename.isEmpty()) | 386 | if (filename.isEmpty()) |
360 | { | 387 | { |
361 | unsetPalette(); | 388 | unsetPalette(); |
362 | } | 389 | } |
363 | else | 390 | else |
364 | { | 391 | { |
365 | qDebug("ContactListView::setBackgroundPixmap has to be verified"); | 392 | qDebug("ContactListView::setBackgroundPixmap has to be verified"); |
366 | //US setPaletteBackgroundPixmap(QPixmap(filename)); | 393 | //US setPaletteBackgroundPixmap(QPixmap(filename)); |
367 | KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); | 394 | KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); |
368 | } | 395 | } |
369 | 396 | ||
370 | } | 397 | } |
371 | #ifndef KAB_EMBEDDED | 398 | #ifndef KAB_EMBEDDED |
372 | #include "contactlistview.moc" | 399 | #include "contactlistview.moc" |
373 | #endif //KAB_EMBEDDED | 400 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h index fad7f38..9d1a672 100644 --- a/kaddressbook/views/contactlistview.h +++ b/kaddressbook/views/contactlistview.h | |||
@@ -1,129 +1,130 @@ | |||
1 | #ifndef CONTACTLISTVIEW_H | 1 | #ifndef CONTACTLISTVIEW_H |
2 | #define CONTACTLISTVIEW_H | 2 | #define CONTACTLISTVIEW_H |
3 | 3 | ||
4 | #include <qcolor.h> | 4 | #include <qcolor.h> |
5 | #include <qpixmap.h> | 5 | #include <qpixmap.h> |
6 | #include <qtooltip.h> | 6 | #include <qtooltip.h> |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | 8 | ||
9 | #include <klistview.h> | 9 | #include <klistview.h> |
10 | 10 | ||
11 | #include <kabc/field.h> | 11 | #include <kabc/field.h> |
12 | #include <kabc/addressee.h> | 12 | #include <kabc/addressee.h> |
13 | #include <kabc/addressbook.h> | 13 | #include <kabc/addressbook.h> |
14 | 14 | ||
15 | 15 | ||
16 | class QDropEvent; | 16 | class QDropEvent; |
17 | class KAddressBookTableView; | 17 | class KAddressBookTableView; |
18 | class ContactListView; | 18 | class ContactListView; |
19 | 19 | ||
20 | /** The whole tooltip design needs a lot of work. Currently it is | 20 | /** The whole tooltip design needs a lot of work. Currently it is |
21 | * hacked together to function. | 21 | * hacked together to function. |
22 | */ | 22 | */ |
23 | class DynamicTip : public QToolTip | 23 | class DynamicTip : public QToolTip |
24 | { | 24 | { |
25 | public: | 25 | public: |
26 | DynamicTip( ContactListView * parent ); | 26 | DynamicTip( ContactListView * parent ); |
27 | 27 | ||
28 | protected: | 28 | protected: |
29 | void maybeTip( const QPoint & ); | 29 | void maybeTip( const QPoint & ); |
30 | 30 | ||
31 | private: | 31 | private: |
32 | }; | 32 | }; |
33 | 33 | ||
34 | class ContactListViewItem : public KListViewItem | 34 | class ContactListViewItem : public KListViewItem |
35 | { | 35 | { |
36 | 36 | ||
37 | public: | 37 | public: |
38 | ContactListViewItem(const KABC::Addressee &a, ContactListView* parent, | 38 | ContactListViewItem(const KABC::Addressee &a, ContactListView* parent, |
39 | KABC::AddressBook *doc, const KABC::Field::List &fields ); | 39 | KABC::AddressBook *doc, const KABC::Field::List &fields ); |
40 | const KABC::Addressee &addressee() const { return mAddressee; } | 40 | const KABC::Addressee &addressee() const { return mAddressee; } |
41 | virtual void refresh(); | 41 | virtual void refresh(); |
42 | virtual ContactListView* parent(); | 42 | virtual ContactListView* parent(); |
43 | virtual QString key ( int, bool ) const; | 43 | virtual QString key ( int, bool ) const; |
44 | 44 | ||
45 | /** Adds the border around the cell if the user wants it. | 45 | /** Adds the border around the cell if the user wants it. |
46 | * This is how the single line config option is implemented. | 46 | * This is how the single line config option is implemented. |
47 | */ | 47 | */ |
48 | virtual void paintCell(QPainter * p, const QColorGroup & cg, | 48 | virtual void paintCell(QPainter * p, const QColorGroup & cg, |
49 | int column, int width, int align ); | 49 | int column, int width, int align ); |
50 | 50 | ||
51 | private: | 51 | private: |
52 | KABC::Addressee mAddressee; | 52 | KABC::Addressee mAddressee; |
53 | KABC::Field::List mFields; | 53 | KABC::Field::List mFields; |
54 | ContactListView *parentListView; | 54 | ContactListView *parentListView; |
55 | KABC::AddressBook *mDocument; | 55 | KABC::AddressBook *mDocument; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | 58 | ||
59 | ///////////////////////////////////////////// | 59 | ///////////////////////////////////////////// |
60 | // ContactListView | 60 | // ContactListView |
61 | 61 | ||
62 | class ContactListView : public KListView | 62 | class ContactListView : public KListView |
63 | { | 63 | { |
64 | Q_OBJECT | 64 | Q_OBJECT |
65 | 65 | ||
66 | public: | 66 | public: |
67 | ContactListView(KAddressBookTableView *view, | 67 | ContactListView(KAddressBookTableView *view, |
68 | KABC::AddressBook *doc, | 68 | KABC::AddressBook *doc, |
69 | QWidget *parent, | 69 | QWidget *parent, |
70 | const char *name = 0L ); | 70 | const char *name = 0L ); |
71 | virtual ~ContactListView() {} | 71 | virtual ~ContactListView() {} |
72 | //void resort(); | 72 | //void resort(); |
73 | 73 | ||
74 | /** Returns true if tooltips should be displayed, false otherwise | 74 | /** Returns true if tooltips should be displayed, false otherwise |
75 | */ | 75 | */ |
76 | bool tooltips() const { return mToolTips; } | 76 | bool tooltips() const { return mToolTips; } |
77 | void setToolTipsEnabled(bool enabled) { mToolTips = enabled; } | 77 | void setToolTipsEnabled(bool enabled) { mToolTips = enabled; } |
78 | 78 | ||
79 | bool alternateBackground() const { return mABackground; } | 79 | bool alternateBackground() const { return mABackground; } |
80 | void setAlternateBackgroundEnabled(bool enabled); | 80 | void setAlternateBackgroundEnabled(bool enabled); |
81 | 81 | ||
82 | bool singleLine() const { return mSingleLine; } | 82 | bool singleLine() const { return mSingleLine; } |
83 | void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; } | 83 | void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; } |
84 | 84 | ||
85 | const QColor &alternateColor() const { return mAlternateColor; } | 85 | const QColor &alternateColor() const { return mAlternateColor; } |
86 | void setAlternateColor(const QColor &mAlternateColor); | 86 | void setAlternateColor(const QColor &mAlternateColor); |
87 | 87 | ||
88 | /** Sets the background pixmap to <i>filename</i>. If the | 88 | /** Sets the background pixmap to <i>filename</i>. If the |
89 | * QString is empty (QString::isEmpty()), then the background | 89 | * QString is empty (QString::isEmpty()), then the background |
90 | * pixmap will be disabled. | 90 | * pixmap will be disabled. |
91 | */ | 91 | */ |
92 | void setBackgroundPixmap(const QString &filename); | 92 | void setBackgroundPixmap(const QString &filename); |
93 | 93 | ||
94 | protected: | 94 | protected: |
95 | /** Paints the background pixmap in the empty area. This method is needed | 95 | /** Paints the background pixmap in the empty area. This method is needed |
96 | * since Qt::FixedPixmap will not scroll with the list view. | 96 | * since Qt::FixedPixmap will not scroll with the list view. |
97 | */ | 97 | */ |
98 | virtual void paintEmptyArea( QPainter * p, const QRect & rect ); | 98 | virtual void paintEmptyArea( QPainter * p, const QRect & rect ); |
99 | virtual void contentsMousePressEvent(QMouseEvent*); | 99 | virtual void contentsMousePressEvent(QMouseEvent*); |
100 | void contentsMouseMoveEvent( QMouseEvent *e ); | 100 | void contentsMouseMoveEvent( QMouseEvent *e ); |
101 | void contentsDropEvent( QDropEvent *e ); | 101 | void contentsDropEvent( QDropEvent *e ); |
102 | virtual bool acceptDrag(QDropEvent *e) const; | 102 | virtual bool acceptDrag(QDropEvent *e) const; |
103 | 103 | ||
104 | protected slots: | 104 | protected slots: |
105 | void itemDropped(QDropEvent *e); | 105 | void itemDropped(QDropEvent *e); |
106 | 106 | ||
107 | public slots: | 107 | public slots: |
108 | void printMe(); | ||
108 | 109 | ||
109 | signals: | 110 | signals: |
110 | void startAddresseeDrag(); | 111 | void startAddresseeDrag(); |
111 | void addresseeDropped(QDropEvent *); | 112 | void addresseeDropped(QDropEvent *); |
112 | 113 | ||
113 | private: | 114 | private: |
114 | KAddressBookTableView *pabWidget; | 115 | KAddressBookTableView *pabWidget; |
115 | int oldColumn; | 116 | int oldColumn; |
116 | int column; | 117 | int column; |
117 | bool ascending; | 118 | bool ascending; |
118 | 119 | ||
119 | bool mABackground; | 120 | bool mABackground; |
120 | bool mSingleLine; | 121 | bool mSingleLine; |
121 | bool mToolTips; | 122 | bool mToolTips; |
122 | 123 | ||
123 | QColor mAlternateColor; | 124 | QColor mAlternateColor; |
124 | 125 | ||
125 | QPoint presspos; | 126 | QPoint presspos; |
126 | }; | 127 | }; |
127 | 128 | ||
128 | 129 | ||
129 | #endif | 130 | #endif |
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 2d7ed08..107be59 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp | |||
@@ -1,478 +1,507 @@ | |||
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 | #include <qdragobject.h> | 24 | #include <qdragobject.h> |
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qiconview.h> | 26 | #include <qiconview.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kabc/addressbook.h> | 32 | #include <kabc/addressbook.h> |
33 | #include <kabc/addressee.h> | 33 | #include <kabc/addressee.h> |
34 | #include <kconfig.h> | 34 | #include <kconfig.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | 37 | ||
38 | #include "kabprefs.h" | 38 | #include "kabprefs.h" |
39 | #include "viewmanager.h" | 39 | #include "viewmanager.h" |
40 | 40 | ||
41 | |||
41 | #include "kaddressbookcardview.h" | 42 | #include "kaddressbookcardview.h" |
42 | 43 | ||
43 | #ifndef KAB_EMBEDDED | 44 | #ifndef KAB_EMBEDDED |
44 | extern "C" { | 45 | extern "C" { |
45 | void *init_libkaddrbk_cardview() | 46 | void *init_libkaddrbk_cardview() |
46 | { | 47 | { |
47 | return ( new CardViewFactory ); | 48 | return ( new CardViewFactory ); |
48 | } | 49 | } |
49 | } | 50 | } |
50 | #endif //KAB_EMBEDDED | 51 | #endif //KAB_EMBEDDED |
51 | 52 | ||
52 | //////////////////////////////// | 53 | //////////////////////////////// |
53 | // AddresseeCardViewItem (internal class) | 54 | // AddresseeCardViewItem (internal class) |
54 | class AddresseeCardViewItem : public CardViewItem | 55 | class AddresseeCardViewItem : public CardViewItem |
55 | { | 56 | { |
56 | public: | 57 | public: |
57 | AddresseeCardViewItem(const KABC::Field::List &fields, | 58 | AddresseeCardViewItem(const KABC::Field::List &fields, |
58 | bool showEmptyFields, | 59 | bool showEmptyFields, |
59 | KABC::AddressBook *doc, const KABC::Addressee &a, | 60 | KABC::AddressBook *doc, const KABC::Addressee &a, |
60 | CardView *parent) | 61 | CardView *parent) |
61 | : CardViewItem(parent, a.formattedName()), | 62 | : CardViewItem(parent, a.formattedName()), |
62 | mFields( fields ), mShowEmptyFields(showEmptyFields), | 63 | mFields( fields ), mShowEmptyFields(showEmptyFields), |
63 | mDocument(doc), mAddressee(a) | 64 | mDocument(doc), mAddressee(a) |
64 | { | 65 | { |
65 | if ( mFields.isEmpty() ) { | 66 | if ( mFields.isEmpty() ) { |
66 | mFields = KABC::Field::defaultFields(); | 67 | mFields = KABC::Field::defaultFields(); |
67 | } | 68 | } |
68 | refresh(); | 69 | refresh(); |
69 | } | 70 | } |
70 | 71 | ||
71 | const KABC::Addressee &addressee() const { return mAddressee; } | 72 | const KABC::Addressee &addressee() const { return mAddressee; } |
72 | 73 | ||
73 | void refresh() | 74 | void refresh() |
74 | { | 75 | { |
75 | // Update our addressee, since it may have changed elsewhere | 76 | // Update our addressee, since it may have changed elsewhere |
76 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 77 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
77 | 78 | ||
78 | if (!mAddressee.isEmpty()) | 79 | if (!mAddressee.isEmpty()) |
79 | { | 80 | { |
80 | clearFields(); | 81 | clearFields(); |
81 | 82 | ||
82 | // Try all the selected fields until we find one with text. | 83 | // Try all the selected fields until we find one with text. |
83 | // This will limit the number of unlabeled icons in the view | 84 | // This will limit the number of unlabeled icons in the view |
84 | KABC::Field::List::Iterator iter; | 85 | KABC::Field::List::Iterator iter; |
85 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) | 86 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) |
86 | { | 87 | { |
87 | // insert empty fields or not? not doing so saves a bit of memory and CPU | 88 | // insert empty fields or not? not doing so saves a bit of memory and CPU |
88 | // (during geometry calculations), but prevents having equally | 89 | // (during geometry calculations), but prevents having equally |
89 | // wide label columns in all cards, unless CardViewItem/CardView search | 90 | // wide label columns in all cards, unless CardViewItem/CardView search |
90 | // globally for the widest label. (anders) | 91 | // globally for the widest label. (anders) |
91 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) | 92 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) |
92 | insertField((*iter)->label(), (*iter)->value( mAddressee )); | 93 | insertField((*iter)->label(), (*iter)->value( mAddressee )); |
93 | } | 94 | } |
94 | 95 | ||
95 | // We might want to make this the first field. hmm... -mpilone | 96 | // We might want to make this the first field. hmm... -mpilone |
96 | setCaption( mAddressee.realName() ); | 97 | setCaption( mAddressee.realName() ); |
97 | } | 98 | } |
98 | } | 99 | } |
99 | 100 | ||
100 | private: | 101 | private: |
101 | KABC::Field::List mFields; | 102 | KABC::Field::List mFields; |
102 | bool mShowEmptyFields; | 103 | bool mShowEmptyFields; |
103 | KABC::AddressBook *mDocument; | 104 | KABC::AddressBook *mDocument; |
104 | KABC::Addressee mAddressee; | 105 | KABC::Addressee mAddressee; |
105 | }; | 106 | }; |
106 | 107 | ||
107 | /////////////////////////////// | 108 | /////////////////////////////// |
108 | // AddresseeCardView | 109 | // AddresseeCardView |
109 | 110 | ||
110 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) | 111 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) |
111 | : CardView(parent, name) | 112 | : CardView(parent, name) |
112 | { | 113 | { |
113 | setAcceptDrops(true); | 114 | setAcceptDrops(true); |
114 | } | 115 | } |
115 | 116 | ||
116 | AddresseeCardView::~AddresseeCardView() | 117 | AddresseeCardView::~AddresseeCardView() |
117 | { | 118 | { |
118 | } | 119 | } |
120 | void AddresseeCardView::printMe() | ||
121 | { | ||
122 | #ifdef DESKTOP_VERSION | ||
123 | QPrinter printer; | ||
124 | if (!printer.setup() ) | ||
125 | return; | ||
126 | QPainter p; | ||
127 | p.begin ( &printer ); | ||
128 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | ||
129 | float dx, dy; | ||
130 | int wid = (m.width() * 9)/10; | ||
131 | dx = (float) wid/(float)contentsWidth (); | ||
132 | dy = (float)(m.height()) / (float)contentsHeight (); | ||
133 | float scale; | ||
134 | // scale to fit the width or height of the paper | ||
135 | if ( dx < dy ) | ||
136 | scale = dx; | ||
137 | else | ||
138 | scale = dy; | ||
139 | p.translate( m.width()/10,0 ); | ||
140 | p.scale( scale, scale ); | ||
141 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | ||
142 | p.end(); | ||
143 | repaint(); | ||
144 | #endif | ||
145 | } | ||
119 | 146 | ||
120 | 147 | ||
121 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) | 148 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) |
122 | { | 149 | { |
123 | #ifndef KAB_EMBEDDED | 150 | #ifndef KAB_EMBEDDED |
124 | if (QTextDrag::canDecode(e)) | 151 | if (QTextDrag::canDecode(e)) |
125 | e->accept(); | 152 | e->accept(); |
126 | #else //KAB_EMBEDDED | 153 | #else //KAB_EMBEDDED |
127 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); | 154 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); |
128 | #endif //KAB_EMBEDDED | 155 | #endif //KAB_EMBEDDED |
129 | } | 156 | } |
130 | 157 | ||
131 | void AddresseeCardView::dropEvent(QDropEvent *e) | 158 | void AddresseeCardView::dropEvent(QDropEvent *e) |
132 | { | 159 | { |
133 | emit addresseeDropped(e); | 160 | emit addresseeDropped(e); |
134 | } | 161 | } |
135 | 162 | ||
136 | void AddresseeCardView::startDrag() | 163 | void AddresseeCardView::startDrag() |
137 | { | 164 | { |
138 | emit startAddresseeDrag(); | 165 | emit startAddresseeDrag(); |
139 | } | 166 | } |
140 | 167 | ||
141 | 168 | ||
142 | /////////////////////////////// | 169 | /////////////////////////////// |
143 | // KAddressBookCardView | 170 | // KAddressBookCardView |
144 | 171 | ||
145 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, | 172 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, |
146 | QWidget *parent, const char *name ) | 173 | QWidget *parent, const char *name ) |
147 | : KAddressBookView( ab, parent, name ) | 174 | : KAddressBookView( ab, parent, name ) |
148 | { | 175 | { |
149 | mShowEmptyFields = false; | 176 | mShowEmptyFields = false; |
150 | 177 | ||
151 | // Init the GUI | 178 | // Init the GUI |
152 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 179 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
153 | 180 | ||
154 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); | 181 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); |
155 | mCardView->setSelectionMode(CardView::Extended); | 182 | mCardView->setSelectionMode(CardView::Extended); |
156 | layout->addWidget(mCardView); | 183 | layout->addWidget(mCardView); |
157 | 184 | ||
158 | // Connect up the signals | 185 | // Connect up the signals |
159 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 186 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
160 | this, SLOT(addresseeExecuted(CardViewItem *))); | 187 | this, SLOT(addresseeExecuted(CardViewItem *))); |
161 | connect(mCardView, SIGNAL(selectionChanged()), | 188 | connect(mCardView, SIGNAL(selectionChanged()), |
162 | this, SLOT(addresseeSelected())); | 189 | this, SLOT(addresseeSelected())); |
163 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), | 190 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), |
164 | this, SIGNAL(dropped(QDropEvent*))); | 191 | this, SIGNAL(dropped(QDropEvent*))); |
165 | connect(mCardView, SIGNAL(startAddresseeDrag()), | 192 | connect(mCardView, SIGNAL(startAddresseeDrag()), |
166 | this, SIGNAL(startDrag())); | 193 | this, SIGNAL(startDrag())); |
194 | connect(this, SIGNAL(printView()), | ||
195 | mCardView , SLOT(printMe())); | ||
167 | } | 196 | } |
168 | 197 | ||
169 | KAddressBookCardView::~KAddressBookCardView() | 198 | KAddressBookCardView::~KAddressBookCardView() |
170 | { | 199 | { |
171 | } | 200 | } |
172 | void KAddressBookCardView::setFocusAV() | 201 | void KAddressBookCardView::setFocusAV() |
173 | { | 202 | { |
174 | if ( mCardView ) | 203 | if ( mCardView ) |
175 | mCardView->setFocus(); | 204 | mCardView->setFocus(); |
176 | 205 | ||
177 | } | 206 | } |
178 | void KAddressBookCardView::scrollUP() | 207 | void KAddressBookCardView::scrollUP() |
179 | { | 208 | { |
180 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | 209 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); |
181 | QApplication::postEvent( mCardView, ev ); | 210 | QApplication::postEvent( mCardView, ev ); |
182 | 211 | ||
183 | } | 212 | } |
184 | void KAddressBookCardView::scrollDOWN() | 213 | void KAddressBookCardView::scrollDOWN() |
185 | { | 214 | { |
186 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | 215 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); |
187 | QApplication::postEvent( mCardView, ev ); | 216 | QApplication::postEvent( mCardView, ev ); |
188 | } | 217 | } |
189 | void KAddressBookCardView::readConfig(KConfig *config) | 218 | void KAddressBookCardView::readConfig(KConfig *config) |
190 | { | 219 | { |
191 | KAddressBookView::readConfig(config); | 220 | KAddressBookView::readConfig(config); |
192 | 221 | ||
193 | // costum colors? | 222 | // costum colors? |
194 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 223 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
195 | { | 224 | { |
196 | QPalette p( mCardView->palette() ); | 225 | QPalette p( mCardView->palette() ); |
197 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 226 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
198 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 227 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
199 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 228 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
200 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 229 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
201 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 230 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
202 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 231 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
203 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 232 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
204 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 233 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
205 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 234 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
206 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 235 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
207 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 236 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
208 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 237 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
209 | mCardView->viewport()->setPalette( p ); | 238 | mCardView->viewport()->setPalette( p ); |
210 | } | 239 | } |
211 | else | 240 | else |
212 | { | 241 | { |
213 | // needed if turned off during a session. | 242 | // needed if turned off during a session. |
214 | mCardView->viewport()->setPalette( mCardView->palette() ); | 243 | mCardView->viewport()->setPalette( mCardView->palette() ); |
215 | } | 244 | } |
216 | 245 | ||
217 | //custom fonts? | 246 | //custom fonts? |
218 | QFont f( font() ); | 247 | QFont f( font() ); |
219 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 248 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
220 | { | 249 | { |
221 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); | 250 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); |
222 | f.setBold( true ); | 251 | f.setBold( true ); |
223 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 252 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
224 | } | 253 | } |
225 | else | 254 | else |
226 | { | 255 | { |
227 | mCardView->setFont( f ); | 256 | mCardView->setFont( f ); |
228 | f.setBold( true ); | 257 | f.setBold( true ); |
229 | mCardView->setHeaderFont( f ); | 258 | mCardView->setHeaderFont( f ); |
230 | } | 259 | } |
231 | 260 | ||
232 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); | 261 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); |
233 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", | 262 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", |
234 | true)); | 263 | true)); |
235 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); | 264 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); |
236 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); | 265 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); |
237 | 266 | ||
238 | mCardView->setShowEmptyFields( mShowEmptyFields ); | 267 | mCardView->setShowEmptyFields( mShowEmptyFields ); |
239 | 268 | ||
240 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); | 269 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); |
241 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); | 270 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); |
242 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); | 271 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); |
243 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); | 272 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); |
244 | 273 | ||
245 | #if 0 | 274 | #if 0 |
246 | // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven | 275 | // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven |
247 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), | 276 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), |
248 | this, SLOT(addresseeExecuted(CardViewItem *))); | 277 | this, SLOT(addresseeExecuted(CardViewItem *))); |
249 | 278 | ||
250 | if (KABPrefs::instance()->mHonorSingleClick) | 279 | if (KABPrefs::instance()->mHonorSingleClick) |
251 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 280 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
252 | this, SLOT(addresseeExecuted(CardViewItem *))); | 281 | this, SLOT(addresseeExecuted(CardViewItem *))); |
253 | else | 282 | else |
254 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 283 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
255 | this, SLOT(addresseeExecuted(CardViewItem *))); | 284 | this, SLOT(addresseeExecuted(CardViewItem *))); |
256 | #endif | 285 | #endif |
257 | 286 | ||
258 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 287 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
259 | this, SLOT(addresseeExecuted(CardViewItem *))); | 288 | this, SLOT(addresseeExecuted(CardViewItem *))); |
260 | } | 289 | } |
261 | 290 | ||
262 | void KAddressBookCardView::writeConfig( KConfig *config ) | 291 | void KAddressBookCardView::writeConfig( KConfig *config ) |
263 | { | 292 | { |
264 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); | 293 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); |
265 | KAddressBookView::writeConfig( config ); | 294 | KAddressBookView::writeConfig( config ); |
266 | } | 295 | } |
267 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | 296 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) |
268 | { | 297 | { |
269 | mCardView->clear(); | 298 | mCardView->clear(); |
270 | if ( s.isEmpty() || s == "*" ) { | 299 | if ( s.isEmpty() || s == "*" ) { |
271 | refresh(); | 300 | refresh(); |
272 | return; | 301 | return; |
273 | } | 302 | } |
274 | QString pattern = s.lower()+"*"; | 303 | QString pattern = s.lower()+"*"; |
275 | QRegExp re; | 304 | QRegExp re; |
276 | re.setWildcard(true); // most people understand these better. | 305 | re.setWildcard(true); // most people understand these better. |
277 | re.setCaseSensitive(false); | 306 | re.setCaseSensitive(false); |
278 | re.setPattern( pattern ); | 307 | re.setPattern( pattern ); |
279 | if (!re.isValid()) | 308 | if (!re.isValid()) |
280 | return; | 309 | return; |
281 | mCardView->viewport()->setUpdatesEnabled( false ); | 310 | mCardView->viewport()->setUpdatesEnabled( false ); |
282 | KABC::Addressee::List addresseeList = addressees(); | 311 | KABC::Addressee::List addresseeList = addressees(); |
283 | KABC::Addressee::List::Iterator it; | 312 | KABC::Addressee::List::Iterator it; |
284 | if ( field ) { | 313 | if ( field ) { |
285 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 314 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
286 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 315 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
287 | continue; | 316 | continue; |
288 | #if QT_VERSION >= 300 | 317 | #if QT_VERSION >= 300 |
289 | if (re.search(field->value( *it ).lower()) != -1) | 318 | if (re.search(field->value( *it ).lower()) != -1) |
290 | #else | 319 | #else |
291 | if (re.match(field->value( *it ).lower()) != -1) | 320 | if (re.match(field->value( *it ).lower()) != -1) |
292 | #endif | 321 | #endif |
293 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 322 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
294 | addressBook(), *it, mCardView); | 323 | addressBook(), *it, mCardView); |
295 | 324 | ||
296 | } | 325 | } |
297 | } else { | 326 | } else { |
298 | KABC::Field::List fieldList = allFields(); | 327 | KABC::Field::List fieldList = allFields(); |
299 | KABC::Field::List::ConstIterator fieldIt; | 328 | KABC::Field::List::ConstIterator fieldIt; |
300 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 329 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
301 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 330 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
302 | continue; | 331 | continue; |
303 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 332 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
304 | #if QT_VERSION >= 300 | 333 | #if QT_VERSION >= 300 |
305 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 334 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
306 | #else | 335 | #else |
307 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 336 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
308 | #endif | 337 | #endif |
309 | { | 338 | { |
310 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 339 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
311 | addressBook(), *it, mCardView); | 340 | addressBook(), *it, mCardView); |
312 | continue; | 341 | continue; |
313 | } | 342 | } |
314 | } | 343 | } |
315 | } | 344 | } |
316 | } | 345 | } |
317 | mCardView->viewport()->setUpdatesEnabled( true ); | 346 | mCardView->viewport()->setUpdatesEnabled( true ); |
318 | mCardView->viewport()->update(); | 347 | mCardView->viewport()->update(); |
319 | if ( mCardView->firstItem() ) { | 348 | if ( mCardView->firstItem() ) { |
320 | mCardView->setCurrentItem ( mCardView->firstItem() ); | 349 | mCardView->setCurrentItem ( mCardView->firstItem() ); |
321 | mCardView->setSelected ( mCardView->firstItem() , true ); | 350 | mCardView->setSelected ( mCardView->firstItem() , true ); |
322 | } | 351 | } |
323 | else | 352 | else |
324 | emit selected(QString::null); | 353 | emit selected(QString::null); |
325 | } | 354 | } |
326 | QStringList KAddressBookCardView::selectedUids() | 355 | QStringList KAddressBookCardView::selectedUids() |
327 | { | 356 | { |
328 | QStringList uidList; | 357 | QStringList uidList; |
329 | CardViewItem *item; | 358 | CardViewItem *item; |
330 | AddresseeCardViewItem *aItem; | 359 | AddresseeCardViewItem *aItem; |
331 | 360 | ||
332 | for (item = mCardView->firstItem(); item; item = item->nextItem()) | 361 | for (item = mCardView->firstItem(); item; item = item->nextItem()) |
333 | { | 362 | { |
334 | if (item->isSelected()) | 363 | if (item->isSelected()) |
335 | { | 364 | { |
336 | #ifndef KAB_EMBEDDED | 365 | #ifndef KAB_EMBEDDED |
337 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 366 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
338 | #else //KAB_EMBEDDED | 367 | #else //KAB_EMBEDDED |
339 | aItem = (AddresseeCardViewItem*)(item); | 368 | aItem = (AddresseeCardViewItem*)(item); |
340 | #endif //KAB_EMBEDDED | 369 | #endif //KAB_EMBEDDED |
341 | if (aItem) | 370 | if (aItem) |
342 | uidList << aItem->addressee().uid(); | 371 | uidList << aItem->addressee().uid(); |
343 | } | 372 | } |
344 | } | 373 | } |
345 | 374 | ||
346 | return uidList; | 375 | return uidList; |
347 | } | 376 | } |
348 | 377 | ||
349 | void KAddressBookCardView::refresh(QString uid) | 378 | void KAddressBookCardView::refresh(QString uid) |
350 | { | 379 | { |
351 | CardViewItem *item; | 380 | CardViewItem *item; |
352 | AddresseeCardViewItem *aItem; | 381 | AddresseeCardViewItem *aItem; |
353 | 382 | ||
354 | if (uid.isNull()) | 383 | if (uid.isNull()) |
355 | { | 384 | { |
356 | // Rebuild the view | 385 | // Rebuild the view |
357 | mCardView->viewport()->setUpdatesEnabled( false ); | 386 | mCardView->viewport()->setUpdatesEnabled( false ); |
358 | mCardView->clear(); | 387 | mCardView->clear(); |
359 | 388 | ||
360 | KABC::Addressee::List addresseeList = addressees(); | 389 | KABC::Addressee::List addresseeList = addressees(); |
361 | KABC::Addressee::List::Iterator iter; | 390 | KABC::Addressee::List::Iterator iter; |
362 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) | 391 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) |
363 | { | 392 | { |
364 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) | 393 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) |
365 | continue; | 394 | continue; |
366 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, | 395 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, |
367 | addressBook(), *iter, mCardView); | 396 | addressBook(), *iter, mCardView); |
368 | } | 397 | } |
369 | mCardView->viewport()->setUpdatesEnabled( true ); | 398 | mCardView->viewport()->setUpdatesEnabled( true ); |
370 | mCardView->viewport()->update(); | 399 | mCardView->viewport()->update(); |
371 | 400 | ||
372 | // by default nothing is selected | 401 | // by default nothing is selected |
373 | emit selected(QString::null); | 402 | emit selected(QString::null); |
374 | } | 403 | } |
375 | else | 404 | else |
376 | { | 405 | { |
377 | // Try to find the one to refresh | 406 | // Try to find the one to refresh |
378 | bool found = false; | 407 | bool found = false; |
379 | for (item = mCardView->firstItem(); item && !found; | 408 | for (item = mCardView->firstItem(); item && !found; |
380 | item = item->nextItem()) | 409 | item = item->nextItem()) |
381 | { | 410 | { |
382 | #ifndef KAB_EMBEDDED | 411 | #ifndef KAB_EMBEDDED |
383 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 412 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
384 | #else //KAB_EMBEDDED | 413 | #else //KAB_EMBEDDED |
385 | aItem = (AddresseeCardViewItem*)(item); | 414 | aItem = (AddresseeCardViewItem*)(item); |
386 | #endif //KAB_EMBEDDED | 415 | #endif //KAB_EMBEDDED |
387 | 416 | ||
388 | if ((aItem) && (aItem->addressee().uid() == uid)) | 417 | if ((aItem) && (aItem->addressee().uid() == uid)) |
389 | { | 418 | { |
390 | aItem->refresh(); | 419 | aItem->refresh(); |
391 | found = true; | 420 | found = true; |
392 | } | 421 | } |
393 | } | 422 | } |
394 | } | 423 | } |
395 | } | 424 | } |
396 | 425 | ||
397 | void KAddressBookCardView::setSelected(QString uid, bool selected) | 426 | void KAddressBookCardView::setSelected(QString uid, bool selected) |
398 | { | 427 | { |
399 | CardViewItem *item; | 428 | CardViewItem *item; |
400 | AddresseeCardViewItem *aItem; | 429 | AddresseeCardViewItem *aItem; |
401 | 430 | ||
402 | if (uid.isNull()) | 431 | if (uid.isNull()) |
403 | { | 432 | { |
404 | mCardView->selectAll(selected); | 433 | mCardView->selectAll(selected); |
405 | } | 434 | } |
406 | else | 435 | else |
407 | { | 436 | { |
408 | bool found = false; | 437 | bool found = false; |
409 | for (item = mCardView->firstItem(); item && !found; | 438 | for (item = mCardView->firstItem(); item && !found; |
410 | item = item->nextItem()) | 439 | item = item->nextItem()) |
411 | { | 440 | { |
412 | #ifndef KAB_EMBEDDED | 441 | #ifndef KAB_EMBEDDED |
413 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 442 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
414 | #else //KAB_EMBEDDED | 443 | #else //KAB_EMBEDDED |
415 | aItem = (AddresseeCardViewItem*)(item); | 444 | aItem = (AddresseeCardViewItem*)(item); |
416 | #endif //KAB_EMBEDDED | 445 | #endif //KAB_EMBEDDED |
417 | 446 | ||
418 | if ((aItem) && (aItem->addressee().uid() == uid)) | 447 | if ((aItem) && (aItem->addressee().uid() == uid)) |
419 | { | 448 | { |
420 | mCardView->setSelected(aItem, selected); | 449 | mCardView->setSelected(aItem, selected); |
421 | mCardView->ensureItemVisible(item); | 450 | mCardView->ensureItemVisible(item); |
422 | found = true; | 451 | found = true; |
423 | } | 452 | } |
424 | } | 453 | } |
425 | } | 454 | } |
426 | } | 455 | } |
427 | 456 | ||
428 | //US added an additional method without parameter | 457 | //US added an additional method without parameter |
429 | void KAddressBookCardView::setSelected() | 458 | void KAddressBookCardView::setSelected() |
430 | { | 459 | { |
431 | setSelected(QString::null, true); | 460 | setSelected(QString::null, true); |
432 | } | 461 | } |
433 | 462 | ||
434 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) | 463 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) |
435 | { | 464 | { |
436 | #ifndef KAB_EMBEDDED | 465 | #ifndef KAB_EMBEDDED |
437 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 466 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
438 | #else //KAB_EMBEDDED | 467 | #else //KAB_EMBEDDED |
439 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); | 468 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); |
440 | #endif //KAB_EMBEDDED | 469 | #endif //KAB_EMBEDDED |
441 | if (aItem) | 470 | if (aItem) |
442 | { | 471 | { |
443 | //kdDebug()<<"... even has a valid item:)"<<endl; | 472 | //kdDebug()<<"... even has a valid item:)"<<endl; |
444 | emit executed(aItem->addressee().uid()); | 473 | emit executed(aItem->addressee().uid()); |
445 | } | 474 | } |
446 | } | 475 | } |
447 | 476 | ||
448 | void KAddressBookCardView::addresseeSelected() | 477 | void KAddressBookCardView::addresseeSelected() |
449 | { | 478 | { |
450 | CardViewItem *item; | 479 | CardViewItem *item; |
451 | AddresseeCardViewItem *aItem; | 480 | AddresseeCardViewItem *aItem; |
452 | 481 | ||
453 | bool found = false; | 482 | bool found = false; |
454 | for (item = mCardView->firstItem(); item && !found; | 483 | for (item = mCardView->firstItem(); item && !found; |
455 | item = item->nextItem()) | 484 | item = item->nextItem()) |
456 | { | 485 | { |
457 | if (item->isSelected()) | 486 | if (item->isSelected()) |
458 | { | 487 | { |
459 | #ifndef KAB_EMBEDDED | 488 | #ifndef KAB_EMBEDDED |
460 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 489 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
461 | #else //KAB_EMBEDDED | 490 | #else //KAB_EMBEDDED |
462 | aItem = (AddresseeCardViewItem*)(item); | 491 | aItem = (AddresseeCardViewItem*)(item); |
463 | #endif //KAB_EMBEDDED | 492 | #endif //KAB_EMBEDDED |
464 | if ( aItem ) | 493 | if ( aItem ) |
465 | { | 494 | { |
466 | emit selected(aItem->addressee().uid()); | 495 | emit selected(aItem->addressee().uid()); |
467 | found = true; | 496 | found = true; |
468 | } | 497 | } |
469 | } | 498 | } |
470 | } | 499 | } |
471 | 500 | ||
472 | if (!found) | 501 | if (!found) |
473 | emit selected(QString::null); | 502 | emit selected(QString::null); |
474 | 503 | ||
475 | } | 504 | } |
476 | #ifndef KAB_EMBEDDED | 505 | #ifndef KAB_EMBEDDED |
477 | #include "kaddressbookcardview.moc" | 506 | #include "kaddressbookcardview.moc" |
478 | #endif //KAB_EMBEDDED | 507 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h index 8f22d54..2a71f7e 100644 --- a/kaddressbook/views/kaddressbookcardview.h +++ b/kaddressbook/views/kaddressbookcardview.h | |||
@@ -1,120 +1,122 @@ | |||
1 | #ifndef KADDRESSBOOKCARDVIEW_H | 1 | #ifndef KADDRESSBOOKCARDVIEW_H |
2 | #define KADDRESSBOOKCARDVIEW_H | 2 | #define KADDRESSBOOKCARDVIEW_H |
3 | 3 | ||
4 | /* | 4 | /* |
5 | This file is part of KAddressBook. | 5 | This file is part of KAddressBook. |
6 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 6 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #ifndef KAB_EMBEDDED | 28 | #ifndef KAB_EMBEDDED |
29 | #include <kiconview.h> | 29 | #include <kiconview.h> |
30 | #else //KAB_EMBEDDED | 30 | #else //KAB_EMBEDDED |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #endif //KAB_EMBEDDED | 32 | #endif //KAB_EMBEDDED |
33 | 33 | ||
34 | #include "cardview.h" | 34 | #include "cardview.h" |
35 | #include "kaddressbookview.h" | 35 | #include "kaddressbookview.h" |
36 | #include "configurecardviewdialog.h" | 36 | #include "configurecardviewdialog.h" |
37 | 37 | ||
38 | class QDragEnterEvent; | 38 | class QDragEnterEvent; |
39 | class QDragEntryEvent; | 39 | class QDragEntryEvent; |
40 | class QDropEvent; | 40 | class QDropEvent; |
41 | class KConfig; | 41 | class KConfig; |
42 | class AddresseeCardView; | 42 | class AddresseeCardView; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | This view uses the CardView class to create a card view. At some | 45 | This view uses the CardView class to create a card view. At some |
46 | point in the future I think this will be the default view of | 46 | point in the future I think this will be the default view of |
47 | KAddressBook. | 47 | KAddressBook. |
48 | */ | 48 | */ |
49 | class KAddressBookCardView : public KAddressBookView | 49 | class KAddressBookCardView : public KAddressBookView |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | 52 | ||
53 | public: | 53 | public: |
54 | KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, | 54 | KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, |
55 | const char *name = 0 ); | 55 | const char *name = 0 ); |
56 | virtual ~KAddressBookCardView(); | 56 | virtual ~KAddressBookCardView(); |
57 | void doSearch( const QString& s,KABC::Field *field ); | 57 | void doSearch( const QString& s,KABC::Field *field ); |
58 | virtual QStringList selectedUids(); | 58 | virtual QStringList selectedUids(); |
59 | virtual QString type() const { return "Card"; } | 59 | virtual QString type() const { return "Card"; } |
60 | 60 | ||
61 | virtual void readConfig(KConfig *config); | 61 | virtual void readConfig(KConfig *config); |
62 | virtual void writeConfig(KConfig *); | 62 | virtual void writeConfig(KConfig *); |
63 | virtual void scrollUP(); | 63 | virtual void scrollUP(); |
64 | virtual void scrollDOWN(); | 64 | virtual void scrollDOWN(); |
65 | virtual void setFocusAV(); | 65 | virtual void setFocusAV(); |
66 | 66 | ||
67 | public slots: | 67 | public slots: |
68 | void refresh(QString uid = QString::null); | 68 | void refresh(QString uid = QString::null); |
69 | void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); | 69 | void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); |
70 | //US added an additional method without parameter | 70 | //US added an additional method without parameter |
71 | void setSelected(); | 71 | void setSelected(); |
72 | 72 | ||
73 | protected slots: | 73 | protected slots: |
74 | void addresseeExecuted(CardViewItem *item); | 74 | void addresseeExecuted(CardViewItem *item); |
75 | void addresseeSelected(); | 75 | void addresseeSelected(); |
76 | 76 | ||
77 | private: | 77 | private: |
78 | AddresseeCardView *mCardView; | 78 | AddresseeCardView *mCardView; |
79 | bool mShowEmptyFields; | 79 | bool mShowEmptyFields; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | class AddresseeCardView : public CardView | 82 | class AddresseeCardView : public CardView |
83 | { | 83 | { |
84 | Q_OBJECT | 84 | Q_OBJECT |
85 | public: | 85 | public: |
86 | AddresseeCardView(QWidget *parent, const char *name = 0); | 86 | AddresseeCardView(QWidget *parent, const char *name = 0); |
87 | ~AddresseeCardView(); | 87 | ~AddresseeCardView(); |
88 | public slots: | ||
89 | void printMe(); | ||
88 | 90 | ||
89 | signals: | 91 | signals: |
90 | void startAddresseeDrag(); | 92 | void startAddresseeDrag(); |
91 | void addresseeDropped(QDropEvent *); | 93 | void addresseeDropped(QDropEvent *); |
92 | 94 | ||
93 | protected: | 95 | protected: |
94 | virtual void dragEnterEvent(QDragEnterEvent *); | 96 | virtual void dragEnterEvent(QDragEnterEvent *); |
95 | virtual void dropEvent(QDropEvent *); | 97 | virtual void dropEvent(QDropEvent *); |
96 | virtual void startDrag(); | 98 | virtual void startDrag(); |
97 | }; | 99 | }; |
98 | 100 | ||
99 | 101 | ||
100 | class CardViewFactory : public ViewFactory | 102 | class CardViewFactory : public ViewFactory |
101 | { | 103 | { |
102 | public: | 104 | public: |
103 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 105 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
104 | { | 106 | { |
105 | return new KAddressBookCardView( ab, parent, name ); | 107 | return new KAddressBookCardView( ab, parent, name ); |
106 | } | 108 | } |
107 | 109 | ||
108 | QString type() const { return "Card"; } | 110 | QString type() const { return "Card"; } |
109 | 111 | ||
110 | QString description() const { return i18n( "Rolodex style cards represent contacts." ); } | 112 | QString description() const { return i18n( "Rolodex style cards represent contacts." ); } |
111 | 113 | ||
112 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, | 114 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, |
113 | const char *name = 0 ) | 115 | const char *name = 0 ) |
114 | { | 116 | { |
115 | return new ConfigureCardViewWidget( ab, parent, name ); | 117 | return new ConfigureCardViewWidget( ab, parent, name ); |
116 | } | 118 | } |
117 | }; | 119 | }; |
118 | 120 | ||
119 | 121 | ||
120 | #endif | 122 | #endif |
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 61703ee..ecd6f05 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -1,471 +1,473 @@ | |||
1 | // $Id$ | 1 | // $Id$ |
2 | 2 | ||
3 | #include <qvbox.h> | 3 | #include <qvbox.h> |
4 | #include <qlistbox.h> | 4 | #include <qlistbox.h> |
5 | #include <qwidget.h> | 5 | #include <qwidget.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | #include <qimage.h> | 7 | #include <qimage.h> |
8 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
9 | #include <qapplication.h> | 9 | #include <qapplication.h> |
10 | #include <qdragobject.h> | 10 | #include <qdragobject.h> |
11 | #include <qevent.h> | 11 | #include <qevent.h> |
12 | #include <qurl.h> | 12 | #include <qurl.h> |
13 | #include <qpixmap.h> | 13 | #include <qpixmap.h> |
14 | 14 | ||
15 | #include <kabc/addressbook.h> | 15 | #include <kabc/addressbook.h> |
16 | #include <kapplication.h> | 16 | #include <kapplication.h> |
17 | #include <kconfig.h> | 17 | #include <kconfig.h> |
18 | #include <kcolorbutton.h> | 18 | #include <kcolorbutton.h> |
19 | #include <kdebug.h> | 19 | #include <kdebug.h> |
20 | #include <kglobal.h> | 20 | #include <kglobal.h> |
21 | #include <kiconloader.h> | 21 | #include <kiconloader.h> |
22 | #include <klineedit.h> | 22 | #include <klineedit.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kmessagebox.h> | 24 | #include <kmessagebox.h> |
25 | #include <kurl.h> | 25 | #include <kurl.h> |
26 | #include <kurlrequester.h> | 26 | #include <kurlrequester.h> |
27 | 27 | ||
28 | //US#include "configuretableviewdialog.h" | 28 | //US#include "configuretableviewdialog.h" |
29 | #include "contactlistview.h" | 29 | #include "contactlistview.h" |
30 | #include "kabprefs.h" | 30 | #include "kabprefs.h" |
31 | #include "undocmds.h" | 31 | #include "undocmds.h" |
32 | #include "viewmanager.h" | 32 | #include "viewmanager.h" |
33 | 33 | ||
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qheader.h> | 35 | #include <qheader.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | 37 | ||
38 | #include "kaddressbooktableview.h" | 38 | #include "kaddressbooktableview.h" |
39 | 39 | ||
40 | 40 | ||
41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, | 41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, |
42 | QWidget *parent, const char *name ) | 42 | QWidget *parent, const char *name ) |
43 | : KAddressBookView( ab, parent, name ) | 43 | : KAddressBookView( ab, parent, name ) |
44 | { | 44 | { |
45 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); | 45 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); |
46 | 46 | ||
47 | // The list view will be created when the config is read. | 47 | // The list view will be created when the config is read. |
48 | mListView = 0; | 48 | mListView = 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | KAddressBookTableView::~KAddressBookTableView() | 51 | KAddressBookTableView::~KAddressBookTableView() |
52 | { | 52 | { |
53 | } | 53 | } |
54 | void KAddressBookTableView::setFocusAV() | 54 | void KAddressBookTableView::setFocusAV() |
55 | { | 55 | { |
56 | if ( mListView ) | 56 | if ( mListView ) |
57 | mListView->setFocus(); | 57 | mListView->setFocus(); |
58 | 58 | ||
59 | } | 59 | } |
60 | void KAddressBookTableView::scrollUP() | 60 | void KAddressBookTableView::scrollUP() |
61 | { | 61 | { |
62 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | 62 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); |
63 | QApplication::postEvent( mListView, ev ); | 63 | QApplication::postEvent( mListView, ev ); |
64 | } | 64 | } |
65 | void KAddressBookTableView::scrollDOWN() | 65 | void KAddressBookTableView::scrollDOWN() |
66 | { | 66 | { |
67 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | 67 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); |
68 | QApplication::postEvent( mListView, ev ); | 68 | QApplication::postEvent( mListView, ev ); |
69 | } | 69 | } |
70 | void KAddressBookTableView::reconstructListView() | 70 | void KAddressBookTableView::reconstructListView() |
71 | { | 71 | { |
72 | if (mListView) | 72 | if (mListView) |
73 | { | 73 | { |
74 | disconnect(mListView, SIGNAL(selectionChanged()), | 74 | disconnect(mListView, SIGNAL(selectionChanged()), |
75 | this, SLOT(addresseeSelected())); | 75 | this, SLOT(addresseeSelected())); |
76 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), | 76 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), |
77 | this, SLOT(addresseeExecuted(QListViewItem*))); | 77 | this, SLOT(addresseeExecuted(QListViewItem*))); |
78 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 78 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
79 | this, SLOT(addresseeExecuted(QListViewItem*))); | 79 | this, SLOT(addresseeExecuted(QListViewItem*))); |
80 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, | 80 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, |
81 | SIGNAL(startDrag())); | 81 | SIGNAL(startDrag())); |
82 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 82 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
83 | this, SLOT(addresseeExecuted(QListViewItem*))); | 83 | this, SLOT(addresseeExecuted(QListViewItem*))); |
84 | 84 | ||
85 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 85 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
86 | SIGNAL(dropped(QDropEvent*))); | 86 | SIGNAL(dropped(QDropEvent*))); |
87 | delete mListView; | 87 | delete mListView; |
88 | } | 88 | } |
89 | 89 | ||
90 | mListView = new ContactListView( this, addressBook(), viewWidget() ); | 90 | mListView = new ContactListView( this, addressBook(), viewWidget() ); |
91 | 91 | ||
92 | connect(this, SIGNAL(printView()), | ||
93 | mListView , SLOT(printMe())); | ||
92 | //US set singleClick manually, because it is no global configparameter in embedded space | 94 | //US set singleClick manually, because it is no global configparameter in embedded space |
93 | mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); | 95 | mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); |
94 | 96 | ||
95 | // Add the columns | 97 | // Add the columns |
96 | KABC::Field::List fieldList = fields(); | 98 | KABC::Field::List fieldList = fields(); |
97 | KABC::Field::List::ConstIterator it; | 99 | KABC::Field::List::ConstIterator it; |
98 | 100 | ||
99 | int c = 0; | 101 | int c = 0; |
100 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { | 102 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { |
101 | mListView->addColumn( (*it)->label() ); | 103 | mListView->addColumn( (*it)->label() ); |
102 | mListView->setColumnWidthMode(c++, QListView::Manual); | 104 | mListView->setColumnWidthMode(c++, QListView::Manual); |
103 | //US | 105 | //US |
104 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); | 106 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); |
105 | } | 107 | } |
106 | 108 | ||
107 | connect(mListView, SIGNAL(selectionChanged()), | 109 | connect(mListView, SIGNAL(selectionChanged()), |
108 | this, SLOT(addresseeSelected())); | 110 | this, SLOT(addresseeSelected())); |
109 | connect(mListView, SIGNAL(startAddresseeDrag()), this, | 111 | connect(mListView, SIGNAL(startAddresseeDrag()), this, |
110 | SIGNAL(startDrag())); | 112 | SIGNAL(startDrag())); |
111 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 113 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
112 | SIGNAL(dropped(QDropEvent*))); | 114 | SIGNAL(dropped(QDropEvent*))); |
113 | 115 | ||
114 | if (KABPrefs::instance()->mHonorSingleClick) { | 116 | if (KABPrefs::instance()->mHonorSingleClick) { |
115 | // qDebug("KAddressBookTableView::reconstructListView single"); | 117 | // qDebug("KAddressBookTableView::reconstructListView single"); |
116 | connect(mListView, SIGNAL(executed(QListViewItem*)), | 118 | connect(mListView, SIGNAL(executed(QListViewItem*)), |
117 | this, SLOT(addresseeExecuted(QListViewItem*))); | 119 | this, SLOT(addresseeExecuted(QListViewItem*))); |
118 | } else { | 120 | } else { |
119 | // qDebug("KAddressBookTableView::reconstructListView double"); | 121 | // qDebug("KAddressBookTableView::reconstructListView double"); |
120 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 122 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
121 | this, SLOT(addresseeExecuted(QListViewItem*))); | 123 | this, SLOT(addresseeExecuted(QListViewItem*))); |
122 | } | 124 | } |
123 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 125 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
124 | this, SLOT(addresseeExecuted(QListViewItem*))); | 126 | this, SLOT(addresseeExecuted(QListViewItem*))); |
125 | connect(mListView, SIGNAL(signalDelete()), | 127 | connect(mListView, SIGNAL(signalDelete()), |
126 | this, SLOT(addresseeDeleted())); | 128 | this, SLOT(addresseeDeleted())); |
127 | 129 | ||
128 | //US performceimprovement. Refresh is done from the outside | 130 | //US performceimprovement. Refresh is done from the outside |
129 | //US refresh(); | 131 | //US refresh(); |
130 | 132 | ||
131 | mListView->setSorting( 0, true ); | 133 | mListView->setSorting( 0, true ); |
132 | mainLayout->addWidget( mListView ); | 134 | mainLayout->addWidget( mListView ); |
133 | mainLayout->activate(); | 135 | mainLayout->activate(); |
134 | mListView->show(); | 136 | mListView->show(); |
135 | } | 137 | } |
136 | 138 | ||
137 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 139 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) |
138 | { | 140 | { |
139 | mListView->clear(); | 141 | mListView->clear(); |
140 | if ( s.isEmpty() || s == "*" ) { | 142 | if ( s.isEmpty() || s == "*" ) { |
141 | refresh(); | 143 | refresh(); |
142 | return; | 144 | return; |
143 | } | 145 | } |
144 | QString pattern = s.lower()+"*"; | 146 | QString pattern = s.lower()+"*"; |
145 | QRegExp re; | 147 | QRegExp re; |
146 | re.setWildcard(true); // most people understand these better. | 148 | re.setWildcard(true); // most people understand these better. |
147 | re.setCaseSensitive(false); | 149 | re.setCaseSensitive(false); |
148 | re.setPattern( pattern ); | 150 | re.setPattern( pattern ); |
149 | if (!re.isValid()) | 151 | if (!re.isValid()) |
150 | return; | 152 | return; |
151 | KABC::Addressee::List addresseeList = addressees(); | 153 | KABC::Addressee::List addresseeList = addressees(); |
152 | KABC::Addressee::List::Iterator it; | 154 | KABC::Addressee::List::Iterator it; |
153 | if ( field ) { | 155 | if ( field ) { |
154 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 156 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
155 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 157 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
156 | continue; | 158 | continue; |
157 | #if QT_VERSION >= 300 | 159 | #if QT_VERSION >= 300 |
158 | if (re.search(field->value( *it ).lower()) != -1) | 160 | if (re.search(field->value( *it ).lower()) != -1) |
159 | #else | 161 | #else |
160 | if (re.match(field->value( *it ).lower()) != -1) | 162 | if (re.match(field->value( *it ).lower()) != -1) |
161 | #endif | 163 | #endif |
162 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 164 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
163 | 165 | ||
164 | } | 166 | } |
165 | } else { | 167 | } else { |
166 | KABC::Field::List fieldList = allFields(); | 168 | KABC::Field::List fieldList = allFields(); |
167 | KABC::Field::List::ConstIterator fieldIt; | 169 | KABC::Field::List::ConstIterator fieldIt; |
168 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 170 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
169 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 171 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
170 | continue; | 172 | continue; |
171 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 173 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
172 | #if QT_VERSION >= 300 | 174 | #if QT_VERSION >= 300 |
173 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 175 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
174 | #else | 176 | #else |
175 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 177 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
176 | #endif | 178 | #endif |
177 | { | 179 | { |
178 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 180 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
179 | break; | 181 | break; |
180 | } | 182 | } |
181 | } | 183 | } |
182 | } | 184 | } |
183 | } | 185 | } |
184 | // Sometimes the background pixmap gets messed up when we add lots | 186 | // Sometimes the background pixmap gets messed up when we add lots |
185 | // of items. | 187 | // of items. |
186 | mListView->repaint(); | 188 | mListView->repaint(); |
187 | if ( mListView->firstChild() ) { | 189 | if ( mListView->firstChild() ) { |
188 | mListView->setCurrentItem ( mListView->firstChild() ); | 190 | mListView->setCurrentItem ( mListView->firstChild() ); |
189 | mListView->setSelected ( mListView->firstChild(), true ); | 191 | mListView->setSelected ( mListView->firstChild(), true ); |
190 | } | 192 | } |
191 | else | 193 | else |
192 | emit selected(QString::null); | 194 | emit selected(QString::null); |
193 | 195 | ||
194 | } | 196 | } |
195 | void KAddressBookTableView::writeConfig(KConfig *config) | 197 | void KAddressBookTableView::writeConfig(KConfig *config) |
196 | { | 198 | { |
197 | KAddressBookView::writeConfig(config); | 199 | KAddressBookView::writeConfig(config); |
198 | 200 | ||
199 | mListView->saveLayout(config, config->group()); | 201 | mListView->saveLayout(config, config->group()); |
200 | } | 202 | } |
201 | 203 | ||
202 | void KAddressBookTableView::readConfig(KConfig *config) | 204 | void KAddressBookTableView::readConfig(KConfig *config) |
203 | { | 205 | { |
204 | KAddressBookView::readConfig( config ); | 206 | KAddressBookView::readConfig( config ); |
205 | // The config could have changed the fields, so we need to reconstruct | 207 | // The config could have changed the fields, so we need to reconstruct |
206 | // the listview. | 208 | // the listview. |
207 | reconstructListView(); | 209 | reconstructListView(); |
208 | 210 | ||
209 | // costum colors? | 211 | // costum colors? |
210 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 212 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
211 | { | 213 | { |
212 | QPalette p( mListView->palette() ); | 214 | QPalette p( mListView->palette() ); |
213 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 215 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
214 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 216 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
215 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 217 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
216 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 218 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
217 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 219 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
218 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 220 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
219 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 221 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
220 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 222 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
221 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 223 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
222 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 224 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
223 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 225 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
224 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 226 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
225 | #ifndef KAB_EMBEDDED | 227 | #ifndef KAB_EMBEDDED |
226 | c = KGlobalSettings::alternateBackgroundColor(); | 228 | c = KGlobalSettings::alternateBackgroundColor(); |
227 | #else //KAB_EMBEDDED | 229 | #else //KAB_EMBEDDED |
228 | c = QColor(240, 240, 240); | 230 | c = QColor(240, 240, 240); |
229 | #endif //KAB_EMBEDDED | 231 | #endif //KAB_EMBEDDED |
230 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); | 232 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); |
231 | mListView->setAlternateColor(c); | 233 | mListView->setAlternateColor(c); |
232 | 234 | ||
233 | 235 | ||
234 | //US mListView->viewport()->setPalette( p ); | 236 | //US mListView->viewport()->setPalette( p ); |
235 | mListView->setPalette( p ); | 237 | mListView->setPalette( p ); |
236 | } | 238 | } |
237 | else | 239 | else |
238 | { | 240 | { |
239 | // needed if turned off during a session. | 241 | // needed if turned off during a session. |
240 | //US mListView->viewport()->setPalette( mListView->palette() ); | 242 | //US mListView->viewport()->setPalette( mListView->palette() ); |
241 | mListView->setPalette( mListView->palette() ); | 243 | mListView->setPalette( mListView->palette() ); |
242 | } | 244 | } |
243 | 245 | ||
244 | //custom fonts? | 246 | //custom fonts? |
245 | QFont f( font() ); | 247 | QFont f( font() ); |
246 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 248 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
247 | { | 249 | { |
248 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); | 250 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); |
249 | f.setBold( true ); | 251 | f.setBold( true ); |
250 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 252 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
251 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); | 253 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); |
252 | } | 254 | } |
253 | else | 255 | else |
254 | { | 256 | { |
255 | mListView->setFont( f ); | 257 | mListView->setFont( f ); |
256 | f.setBold( true ); | 258 | f.setBold( true ); |
257 | //US mListView->setHeaderFont( f ); | 259 | //US mListView->setHeaderFont( f ); |
258 | mListView->header()->setFont( f ); | 260 | mListView->header()->setFont( f ); |
259 | } | 261 | } |
260 | 262 | ||
261 | // Set the list view options | 263 | // Set the list view options |
262 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", | 264 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", |
263 | true)); | 265 | true)); |
264 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); | 266 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); |
265 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); | 267 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); |
266 | 268 | ||
267 | if (config->readBoolEntry("Background", false)) | 269 | if (config->readBoolEntry("Background", false)) |
268 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); | 270 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); |
269 | 271 | ||
270 | // Restore the layout of the listview | 272 | // Restore the layout of the listview |
271 | mListView->restoreLayout(config, config->group()); | 273 | mListView->restoreLayout(config, config->group()); |
272 | } | 274 | } |
273 | 275 | ||
274 | void KAddressBookTableView::refresh(QString uid) | 276 | void KAddressBookTableView::refresh(QString uid) |
275 | { | 277 | { |
276 | // For now just repopulate. In reality this method should | 278 | // For now just repopulate. In reality this method should |
277 | // check the value of uid, and if valid iterate through | 279 | // check the value of uid, and if valid iterate through |
278 | // the listview to find the entry, then tell it to refresh. | 280 | // the listview to find the entry, then tell it to refresh. |
279 | 281 | ||
280 | if (uid.isNull()) { | 282 | if (uid.isNull()) { |
281 | // Clear the list view | 283 | // Clear the list view |
282 | QString currentUID, nextUID; | 284 | QString currentUID, nextUID; |
283 | #ifndef KAB_EMBEDDED | 285 | #ifndef KAB_EMBEDDED |
284 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); | 286 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); |
285 | #else //KAB_EMBEDDED | 287 | #else //KAB_EMBEDDED |
286 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); | 288 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |
287 | #endif //KAB_EMBEDDED | 289 | #endif //KAB_EMBEDDED |
288 | 290 | ||
289 | if ( currentItem ) { | 291 | if ( currentItem ) { |
290 | #ifndef KAB_EMBEDDED | 292 | #ifndef KAB_EMBEDDED |
291 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); | 293 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); |
292 | #else //KAB_EMBEDDED | 294 | #else //KAB_EMBEDDED |
293 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); | 295 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); |
294 | #endif //KAB_EMBEDDED | 296 | #endif //KAB_EMBEDDED |
295 | if ( nextItem ) | 297 | if ( nextItem ) |
296 | nextUID = nextItem->addressee().uid(); | 298 | nextUID = nextItem->addressee().uid(); |
297 | currentUID = currentItem->addressee().uid(); | 299 | currentUID = currentItem->addressee().uid(); |
298 | } | 300 | } |
299 | 301 | ||
300 | mListView->clear(); | 302 | mListView->clear(); |
301 | 303 | ||
302 | currentItem = 0; | 304 | currentItem = 0; |
303 | KABC::Addressee::List addresseeList = addressees(); | 305 | KABC::Addressee::List addresseeList = addressees(); |
304 | KABC::Addressee::List::Iterator it; | 306 | KABC::Addressee::List::Iterator it; |
305 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 307 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
306 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 308 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
307 | continue; | 309 | continue; |
308 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 310 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
309 | if ( (*it).uid() == currentUID ) | 311 | if ( (*it).uid() == currentUID ) |
310 | currentItem = item; | 312 | currentItem = item; |
311 | else if ( (*it).uid() == nextUID && !currentItem ) | 313 | else if ( (*it).uid() == nextUID && !currentItem ) |
312 | currentItem = item; | 314 | currentItem = item; |
313 | } | 315 | } |
314 | 316 | ||
315 | // Sometimes the background pixmap gets messed up when we add lots | 317 | // Sometimes the background pixmap gets messed up when we add lots |
316 | // of items. | 318 | // of items. |
317 | mListView->repaint(); | 319 | mListView->repaint(); |
318 | 320 | ||
319 | if ( currentItem ) { | 321 | if ( currentItem ) { |
320 | mListView->setCurrentItem( currentItem ); | 322 | mListView->setCurrentItem( currentItem ); |
321 | mListView->ensureItemVisible( currentItem ); | 323 | mListView->ensureItemVisible( currentItem ); |
322 | } | 324 | } |
323 | } else { | 325 | } else { |
324 | // Only need to update on entry. Iterate through and try to find it | 326 | // Only need to update on entry. Iterate through and try to find it |
325 | ContactListViewItem *ceItem; | 327 | ContactListViewItem *ceItem; |
326 | QListViewItemIterator it( mListView ); | 328 | QListViewItemIterator it( mListView ); |
327 | while ( it.current() ) { | 329 | while ( it.current() ) { |
328 | #ifndef KAB_EMBEDDED | 330 | #ifndef KAB_EMBEDDED |
329 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); | 331 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); |
330 | #else //KAB_EMBEDDED | 332 | #else //KAB_EMBEDDED |
331 | ceItem = (ContactListViewItem*)( it.current() ); | 333 | ceItem = (ContactListViewItem*)( it.current() ); |
332 | #endif //KAB_EMBEDDED | 334 | #endif //KAB_EMBEDDED |
333 | 335 | ||
334 | if ( ceItem && ceItem->addressee().uid() == uid ) { | 336 | if ( ceItem && ceItem->addressee().uid() == uid ) { |
335 | ceItem->refresh(); | 337 | ceItem->refresh(); |
336 | return; | 338 | return; |
337 | } | 339 | } |
338 | ++it; | 340 | ++it; |
339 | } | 341 | } |
340 | 342 | ||
341 | refresh( QString::null ); | 343 | refresh( QString::null ); |
342 | } | 344 | } |
343 | } | 345 | } |
344 | 346 | ||
345 | QStringList KAddressBookTableView::selectedUids() | 347 | QStringList KAddressBookTableView::selectedUids() |
346 | { | 348 | { |
347 | QStringList uidList; | 349 | QStringList uidList; |
348 | QListViewItem *item; | 350 | QListViewItem *item; |
349 | ContactListViewItem *ceItem; | 351 | ContactListViewItem *ceItem; |
350 | 352 | ||
351 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 353 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
352 | { | 354 | { |
353 | if (mListView->isSelected( item )) | 355 | if (mListView->isSelected( item )) |
354 | { | 356 | { |
355 | #ifndef KAB_EMBEDDED | 357 | #ifndef KAB_EMBEDDED |
356 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 358 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
357 | #else //KAB_EMBEDDED | 359 | #else //KAB_EMBEDDED |
358 | ceItem = (ContactListViewItem*)(item); | 360 | ceItem = (ContactListViewItem*)(item); |
359 | #endif //KAB_EMBEDDED | 361 | #endif //KAB_EMBEDDED |
360 | 362 | ||
361 | if (ceItem != 0L) | 363 | if (ceItem != 0L) |
362 | uidList << ceItem->addressee().uid(); | 364 | uidList << ceItem->addressee().uid(); |
363 | } | 365 | } |
364 | } | 366 | } |
365 | if ( uidList.count() == 0 ) | 367 | if ( uidList.count() == 0 ) |
366 | if ( mListView->currentItem() ) { | 368 | if ( mListView->currentItem() ) { |
367 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; | 369 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; |
368 | uidList << ceItem->addressee().uid(); | 370 | uidList << ceItem->addressee().uid(); |
369 | } | 371 | } |
370 | 372 | ||
371 | return uidList; | 373 | return uidList; |
372 | } | 374 | } |
373 | 375 | ||
374 | void KAddressBookTableView::setSelected(QString uid, bool selected) | 376 | void KAddressBookTableView::setSelected(QString uid, bool selected) |
375 | { | 377 | { |
376 | QListViewItem *item; | 378 | QListViewItem *item; |
377 | ContactListViewItem *ceItem; | 379 | ContactListViewItem *ceItem; |
378 | 380 | ||
379 | if (uid.isNull()) | 381 | if (uid.isNull()) |
380 | { | 382 | { |
381 | mListView->selectAll(selected); | 383 | mListView->selectAll(selected); |
382 | } | 384 | } |
383 | else | 385 | else |
384 | { | 386 | { |
385 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 387 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
386 | { | 388 | { |
387 | #ifndef KAB_EMBEDDED | 389 | #ifndef KAB_EMBEDDED |
388 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 390 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
389 | #else //KAB_EMBEDDED | 391 | #else //KAB_EMBEDDED |
390 | ceItem = (ContactListViewItem*)(item); | 392 | ceItem = (ContactListViewItem*)(item); |
391 | #endif //KAB_EMBEDDED | 393 | #endif //KAB_EMBEDDED |
392 | 394 | ||
393 | 395 | ||
394 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) | 396 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) |
395 | { | 397 | { |
396 | mListView->setSelected(item, selected); | 398 | mListView->setSelected(item, selected); |
397 | 399 | ||
398 | if (selected) | 400 | if (selected) |
399 | mListView->ensureItemVisible(item); | 401 | mListView->ensureItemVisible(item); |
400 | } | 402 | } |
401 | } | 403 | } |
402 | } | 404 | } |
403 | } | 405 | } |
404 | 406 | ||
405 | void KAddressBookTableView::addresseeSelected() | 407 | void KAddressBookTableView::addresseeSelected() |
406 | { | 408 | { |
407 | // We need to try to find the first selected item. This might not be the | 409 | // We need to try to find the first selected item. This might not be the |
408 | // last selected item, but when QListView is in multiselection mode, | 410 | // last selected item, but when QListView is in multiselection mode, |
409 | // there is no way to figure out which one was | 411 | // there is no way to figure out which one was |
410 | // selected last. | 412 | // selected last. |
411 | QListViewItem *item; | 413 | QListViewItem *item; |
412 | bool found =false; | 414 | bool found =false; |
413 | for (item = mListView->firstChild(); item && !found; | 415 | for (item = mListView->firstChild(); item && !found; |
414 | item = item->nextSibling()) | 416 | item = item->nextSibling()) |
415 | { | 417 | { |
416 | if (item->isSelected()) | 418 | if (item->isSelected()) |
417 | { | 419 | { |
418 | found = true; | 420 | found = true; |
419 | #ifndef KAB_EMBEDDED | 421 | #ifndef KAB_EMBEDDED |
420 | ContactListViewItem *ceItem | 422 | ContactListViewItem *ceItem |
421 | = dynamic_cast<ContactListViewItem*>(item); | 423 | = dynamic_cast<ContactListViewItem*>(item); |
422 | #else //KAB_EMBEDDED | 424 | #else //KAB_EMBEDDED |
423 | ContactListViewItem *ceItem | 425 | ContactListViewItem *ceItem |
424 | = (ContactListViewItem*)(item); | 426 | = (ContactListViewItem*)(item); |
425 | #endif //KAB_EMBEDDED | 427 | #endif //KAB_EMBEDDED |
426 | 428 | ||
427 | if ( ceItem ) emit selected(ceItem->addressee().uid()); | 429 | if ( ceItem ) emit selected(ceItem->addressee().uid()); |
428 | } | 430 | } |
429 | } | 431 | } |
430 | 432 | ||
431 | if (!found) | 433 | if (!found) |
432 | emit selected(QString::null); | 434 | emit selected(QString::null); |
433 | } | 435 | } |
434 | 436 | ||
435 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) | 437 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) |
436 | { | 438 | { |
437 | if (item) | 439 | if (item) |
438 | { | 440 | { |
439 | #ifndef KAB_EMBEDDED | 441 | #ifndef KAB_EMBEDDED |
440 | ContactListViewItem *ceItem | 442 | ContactListViewItem *ceItem |
441 | = dynamic_cast<ContactListViewItem*>(item); | 443 | = dynamic_cast<ContactListViewItem*>(item); |
442 | #else //KAB_EMBEDDED | 444 | #else //KAB_EMBEDDED |
443 | ContactListViewItem *ceItem | 445 | ContactListViewItem *ceItem |
444 | = (ContactListViewItem*)(item); | 446 | = (ContactListViewItem*)(item); |
445 | #endif //KAB_EMBEDDED | 447 | #endif //KAB_EMBEDDED |
446 | 448 | ||
447 | if (ceItem) | 449 | if (ceItem) |
448 | { | 450 | { |
449 | emit executed(ceItem->addressee().uid()); | 451 | emit executed(ceItem->addressee().uid()); |
450 | } | 452 | } |
451 | } | 453 | } |
452 | else | 454 | else |
453 | { | 455 | { |
454 | emit executed(QString::null); | 456 | emit executed(QString::null); |
455 | } | 457 | } |
456 | } | 458 | } |
457 | 459 | ||
458 | void KAddressBookTableView::addresseeDeleted() | 460 | void KAddressBookTableView::addresseeDeleted() |
459 | { | 461 | { |
460 | 462 | ||
461 | emit deleteRequest(); | 463 | emit deleteRequest(); |
462 | 464 | ||
463 | } | 465 | } |
464 | 466 | ||
465 | 467 | ||
466 | 468 | ||
467 | 469 | ||
468 | 470 | ||
469 | #ifndef KAB_EMBEDDED | 471 | #ifndef KAB_EMBEDDED |
470 | #include "kaddressbooktableview.moc" | 472 | #include "kaddressbooktableview.moc" |
471 | #endif //KAB_EMBEDDED | 473 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp index 8d40ffe..89a2626 100644 --- a/kaddressbook/xxportmanager.cpp +++ b/kaddressbook/xxportmanager.cpp | |||
@@ -1,242 +1,242 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qlist.h> | 32 | #include <qlist.h> |
33 | 33 | ||
34 | #include <kabc/addressbook.h> | 34 | #include <kabc/addressbook.h> |
35 | #include <kabc/resource.h> | 35 | #include <kabc/resource.h> |
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <kdialogbase.h> | 37 | #include <kdialogbase.h> |
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | 40 | ||
41 | #ifndef KAB_EMBEDDED | 41 | #ifndef KAB_EMBEDDED |
42 | #include <ktrader.h> | 42 | #include <ktrader.h> |
43 | #else //KAB_EMBEDDED | 43 | #else //KAB_EMBEDDED |
44 | extern "C" | 44 | extern "C" |
45 | { | 45 | { |
46 | void* init_microkaddrbk_csv_xxport(); | 46 | void* init_microkaddrbk_csv_xxport(); |
47 | void* init_microkaddrbk_kde2_xxport(); | 47 | void* init_microkaddrbk_kde2_xxport(); |
48 | void* init_microkaddrbk_vcard_xxport(); | 48 | void* init_microkaddrbk_vcard_xxport(); |
49 | // void* init_microkaddrbk_opie_xxport(); | 49 | // void* init_microkaddrbk_opie_xxport(); |
50 | void* init_microkaddrbk_qtopia_xxport(); | 50 | void* init_microkaddrbk_qtopia_xxport(); |
51 | void* init_microkaddrbk_sharpdtm_xxport(); | 51 | void* init_microkaddrbk_sharpdtm_xxport(); |
52 | } | 52 | } |
53 | #endif //KAB_EMBEDDED | 53 | #endif //KAB_EMBEDDED |
54 | 54 | ||
55 | #include <addresseeview.h> | 55 | #include <addresseeview.h> |
56 | 56 | ||
57 | #include "kabcore.h" | 57 | #include "kabcore.h" |
58 | #include "undocmds.h" | 58 | #include "undocmds.h" |
59 | #include "xxportselectdialog.h" | 59 | #include "xxportselectdialog.h" |
60 | 60 | ||
61 | #include "xxportmanager.h" | 61 | #include "xxportmanager.h" |
62 | 62 | ||
63 | KURL XXPortManager::importURL = KURL(); | 63 | KURL XXPortManager::importURL = KURL(); |
64 | QString XXPortManager::importData = QString::null; | 64 | QString XXPortManager::importData = QString::null; |
65 | 65 | ||
66 | class PreviewDialog : public KDialogBase | 66 | class PreviewDialog : public KDialogBase |
67 | { | 67 | { |
68 | public: | 68 | public: |
69 | PreviewDialog( const KABC::Addressee &addr, | 69 | PreviewDialog( const KABC::Addressee &addr, |
70 | QWidget *parent, const char *name = 0 ); | 70 | QWidget *parent, const char *name = 0 ); |
71 | }; | 71 | }; |
72 | 72 | ||
73 | XXPortManager::XXPortManager( KABCore *core, QObject *parent, const char *name ) | 73 | XXPortManager::XXPortManager( KABCore *core, QObject *parent, const char *name ) |
74 | : QObject( parent, name ), mCore( core ), mShowPreview( false ) | 74 | : QObject( parent, name ), mCore( core ), mShowPreview( false ) |
75 | { | 75 | { |
76 | loadPlugins(); | 76 | loadPlugins(); |
77 | } | 77 | } |
78 | 78 | ||
79 | XXPortManager::~XXPortManager() | 79 | XXPortManager::~XXPortManager() |
80 | { | 80 | { |
81 | } | 81 | } |
82 | 82 | ||
83 | void XXPortManager::restoreSettings() | 83 | void XXPortManager::restoreSettings() |
84 | { | 84 | { |
85 | } | 85 | } |
86 | 86 | ||
87 | void XXPortManager::saveSettings() | 87 | void XXPortManager::saveSettings() |
88 | { | 88 | { |
89 | } | 89 | } |
90 | 90 | ||
91 | void XXPortManager::importVCard( const KURL &url ) | 91 | void XXPortManager::importVCard( const KURL &url ) |
92 | { | 92 | { |
93 | importVCard( url, false ); | 93 | importVCard( url, false ); |
94 | } | 94 | } |
95 | 95 | ||
96 | void XXPortManager::importVCard( const KURL &url, bool showPreview ) | 96 | void XXPortManager::importVCard( const KURL &url, bool showPreview ) |
97 | { | 97 | { |
98 | importURL = url; | 98 | importURL = url; |
99 | mShowPreview = showPreview; | 99 | mShowPreview = showPreview; |
100 | slotImport( "vcard", "<empty>" ); | 100 | slotImport( "vcard", "<empty>" ); |
101 | mShowPreview = false; | 101 | mShowPreview = false; |
102 | importURL = KURL(); | 102 | importURL = KURL(); |
103 | } | 103 | } |
104 | 104 | ||
105 | void XXPortManager::importVCard( const QString &vCard, bool showPreview ) | 105 | void XXPortManager::importVCard( const QString &vCard, bool showPreview ) |
106 | { | 106 | { |
107 | importData = vCard; | 107 | importData = vCard; |
108 | mShowPreview = showPreview; | 108 | mShowPreview = showPreview; |
109 | slotImport( "vcard", "<empty>" ); | 109 | slotImport( "vcard", "<empty>" ); |
110 | mShowPreview = false; | 110 | mShowPreview = false; |
111 | importData = ""; | 111 | importData = ""; |
112 | } | 112 | } |
113 | 113 | ||
114 | void XXPortManager::slotImport( const QString &identifier, const QString &data ) | 114 | void XXPortManager::slotImport( const QString &identifier, const QString &data ) |
115 | { | 115 | { |
116 | XXPortObject *obj = mXXPortObjects[ identifier ]; | 116 | XXPortObject *obj = mXXPortObjects[ identifier ]; |
117 | if ( !obj ) { | 117 | if ( !obj ) { |
118 | KMessageBox::error( mCore, i18n( "<qt>No import plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); | 118 | KMessageBox::error( mCore, i18n( "<qt>No import plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); |
119 | return; | 119 | return; |
120 | } | 120 | } |
121 | 121 | ||
122 | KABC::Resource *resource = mCore->requestResource( mCore ); | 122 | KABC::Resource *resource = mCore->requestResource( mCore ); |
123 | if ( !resource ) | 123 | if ( !resource ) |
124 | return; | 124 | return; |
125 | 125 | ||
126 | KABC::AddresseeList list = obj->importContacts( data ); | 126 | KABC::AddresseeList list = obj->importContacts( data ); |
127 | KABC::AddresseeList::Iterator it; | 127 | KABC::AddresseeList::Iterator it; |
128 | bool imported = false; | 128 | bool imported = false; |
129 | for ( it = list.begin(); it != list.end(); ++it ) { | 129 | for ( it = list.begin(); it != list.end(); ++it ) { |
130 | if ( mShowPreview ) { | 130 | if ( mShowPreview ) { |
131 | PreviewDialog dlg( *it, mCore ); | 131 | PreviewDialog dlg( *it, mCore ); |
132 | if ( !dlg.exec() ) | 132 | if ( !dlg.exec() ) |
133 | continue; | 133 | continue; |
134 | } | 134 | } |
135 | 135 | ||
136 | (*it).setResource( resource ); | 136 | (*it).setResource( resource ); |
137 | // We use a PwNewCommand so the user can undo it. | 137 | // We use a PwNewCommand so the user can undo it. |
138 | PwNewCommand *command = new PwNewCommand( mCore->addressBook(), *it ); | 138 | PwNewCommand *command = new PwNewCommand( mCore->addressBook(), *it ); |
139 | UndoStack::instance()->push( command ); | 139 | UndoStack::instance()->push( command ); |
140 | RedoStack::instance()->clear(); | 140 | RedoStack::instance()->clear(); |
141 | imported = true; | 141 | imported = true; |
142 | } | 142 | } |
143 | 143 | ||
144 | if ( imported ) { | 144 | if ( imported ) { |
145 | KMessageBox::information( mCore, i18n( "contacts successfully imported." ) ); | 145 | KMessageBox::information( mCore, i18n( "contacts successfully imported." ) ); |
146 | 146 | ||
147 | emit modified(); | 147 | emit modified(); |
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | void XXPortManager::slotExport( const QString &identifier, const QString &data ) | 151 | void XXPortManager::slotExport( const QString &identifier, const QString &data ) |
152 | { | 152 | { |
153 | XXPortObject *obj = mXXPortObjects[ identifier ]; | 153 | XXPortObject *obj = mXXPortObjects[ identifier ]; |
154 | if ( !obj ) { | 154 | if ( !obj ) { |
155 | KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); | 155 | KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); |
156 | return; | 156 | return; |
157 | } | 157 | } |
158 | 158 | ||
159 | KABC::AddresseeList addrList; | 159 | KABC::AddresseeList addrList; |
160 | XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore ); | 160 | XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore ); |
161 | if ( dlg.exec() ) | 161 | if ( dlg.exec() ) |
162 | addrList = dlg.contacts(); | 162 | addrList = dlg.contacts(); |
163 | else | 163 | else |
164 | return; | 164 | return; |
165 | if ( !obj->exportContacts( addrList, data ) ) | 165 | if ( !obj->exportContacts( addrList, data ) ) |
166 | KMessageBox::error( mCore, i18n( "Unable to export contacts." ) ); | 166 | KMessageBox::error( mCore, i18n( "Unable to export contacts." ) ); |
167 | else | 167 | else |
168 | KMessageBox::information( mCore, i18n( "contacts successfully exported." ) ); | 168 | KMessageBox::information( mCore, i18n( "contacts successfully exported." ) ); |
169 | } | 169 | } |
170 | 170 | ||
171 | void XXPortManager::loadPlugins() | 171 | void XXPortManager::loadPlugins() |
172 | { | 172 | { |
173 | mXXPortObjects.clear(); | 173 | mXXPortObjects.clear(); |
174 | 174 | ||
175 | #ifndef KAB_EMBEDDED | 175 | #ifndef KAB_EMBEDDED |
176 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" ); | 176 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" ); |
177 | KTrader::OfferList::ConstIterator it; | 177 | KTrader::OfferList::ConstIterator it; |
178 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 178 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
179 | if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) ) | 179 | if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) ) |
180 | continue; | 180 | continue; |
181 | 181 | ||
182 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); | 182 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); |
183 | if ( !factory ) { | 183 | if ( !factory ) { |
184 | kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl; | 184 | kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl; |
185 | continue; | 185 | continue; |
186 | } | 186 | } |
187 | 187 | ||
188 | XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); | 188 | XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); |
189 | 189 | ||
190 | if ( !xxportFactory ) { | 190 | if ( !xxportFactory ) { |
191 | kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; | 191 | kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; |
192 | continue; | 192 | continue; |
193 | } | 193 | } |
194 | 194 | ||
195 | #else //KAB_EMBEDDED | 195 | #else //KAB_EMBEDDED |
196 | QList<XXPortFactory> factorylist; | 196 | QList<XXPortFactory> factorylist; |
197 | factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_csv_xxport())); | 197 | factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_csv_xxport())); |
198 | factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_kde2_xxport())); | 198 | factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_kde2_xxport())); |
199 | factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_vcard_xxport())); | 199 | factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_vcard_xxport())); |
200 | //US factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_opie_xxport())); | 200 | //US factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_opie_xxport())); |
201 | factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_qtopia_xxport())); | 201 | factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_qtopia_xxport())); |
202 | factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_sharpdtm_xxport())); | 202 | factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_sharpdtm_xxport())); |
203 | 203 | ||
204 | QListIterator<XXPortFactory> it(factorylist); | 204 | QListIterator<XXPortFactory> it(factorylist); |
205 | for ( ; it.current(); ++it ) | 205 | for ( ; it.current(); ++it ) |
206 | { | 206 | { |
207 | XXPortFactory *xxportFactory = it.current(); | 207 | XXPortFactory *xxportFactory = it.current(); |
208 | #endif //KAB_EMBEDDED | 208 | #endif //KAB_EMBEDDED |
209 | 209 | ||
210 | XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); | 210 | XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); |
211 | if ( obj ) { | 211 | if ( obj ) { |
212 | mCore->addGUIClient( obj ); | 212 | mCore->addGUIClient( obj ); |
213 | mXXPortObjects.insert( obj->identifier(), obj ); | 213 | mXXPortObjects.insert( obj->identifier(), obj ); |
214 | connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), | 214 | connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), |
215 | this, SLOT( slotExport( const QString&, const QString& ) ) ); | 215 | this, SLOT( slotExport( const QString&, const QString& ) ) ); |
216 | connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), | 216 | connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), |
217 | this, SLOT( slotImport( const QString&, const QString& ) ) ); | 217 | this, SLOT( slotImport( const QString&, const QString& ) ) ); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent, | 223 | PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent, |
224 | const char *name ) | 224 | const char *name ) |
225 | : KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent, | 225 | : KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent, |
226 | name, true, true ) | 226 | name, true, true ) |
227 | { | 227 | { |
228 | QWidget *page = plainPage(); | 228 | QWidget *page = plainPage(); |
229 | QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() ); | 229 | QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() ); |
230 | 230 | ||
231 | KPIM::AddresseeView *view = new KPIM::AddresseeView( page ); | 231 | KABC::AddresseeView *view = new KABC::AddresseeView( page ); |
232 | view->setAddressee( addr ); | 232 | view->setAddressee( addr ); |
233 | 233 | ||
234 | layout->addWidget( view ); | 234 | layout->addWidget( view ); |
235 | 235 | ||
236 | resize( 400, 300 ); | 236 | resize( 400, 300 ); |
237 | } | 237 | } |
238 | 238 | ||
239 | #ifndef KAB_EMBEDDED | 239 | #ifndef KAB_EMBEDDED |
240 | #include "xxportmanager.moc" | 240 | #include "xxportmanager.moc" |
241 | #endif //KAB_EMBEDDED | 241 | #endif //KAB_EMBEDDED |
242 | 242 | ||