author | zautrix <zautrix> | 2005-01-17 12:18:59 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-17 12:18:59 (UTC) |
commit | 6b166ece0a576e9be9c71a61fab5424d75a9301f (patch) (unidiff) | |
tree | b88bf3e82cafc0ac279eb46b8ebc61f112083032 /kaddressbook | |
parent | 376ffdba71ab4d7d7988229f38678394a54e5576 (diff) | |
download | kdepimpi-6b166ece0a576e9be9c71a61fab5424d75a9301f.zip kdepimpi-6b166ece0a576e9be9c71a61fab5424d75a9301f.tar.gz kdepimpi-6b166ece0a576e9be9c71a61fab5424d75a9301f.tar.bz2 |
many AB fixes
-rw-r--r-- | kaddressbook/filter.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/filter.h | 2 | ||||
-rw-r--r-- | kaddressbook/filtereditdialog.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 16 | ||||
-rw-r--r-- | kaddressbook/kaddressbookmain.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 3 |
6 files changed, 15 insertions, 11 deletions
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp index 9cb4c2d..7a869fa 100644 --- a/kaddressbook/filter.cpp +++ b/kaddressbook/filter.cpp | |||
@@ -1,228 +1,228 @@ | |||
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 <kconfig.h> | 24 | #include <kconfig.h> |
25 | #include <kconfigbase.h> | 25 | #include <kconfigbase.h> |
26 | #include <kdebug.h> | 26 | #include <kdebug.h> |
27 | 27 | ||
28 | #include "kabprefs.h" | 28 | #include "kabprefs.h" |
29 | 29 | ||
30 | #include "filter.h" | 30 | #include "filter.h" |
31 | #include <secrecy.h> | 31 | #include <secrecy.h> |
32 | 32 | ||
33 | Filter::Filter() | 33 | Filter::Filter() |
34 | : mName( QString::null ), mMatchRule( Matching ), mEnabled( true ), | 34 | : mName( QString::null ), mMatchRule( Matching ), mEnabled( true ), |
35 | mInternal( false ) | 35 | mInternal( false ) |
36 | { | 36 | { |
37 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; | 37 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; |
38 | } | 38 | } |
39 | 39 | ||
40 | Filter::Filter( const QString &name ) | 40 | Filter::Filter( const QString &name ) |
41 | : mName( name ), mMatchRule( Matching ), mEnabled( true ), | 41 | : mName( name ), mMatchRule( Matching ), mEnabled( true ), |
42 | mInternal( false ) | 42 | mInternal( false ) |
43 | { | 43 | { |
44 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; | 44 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; |
45 | } | 45 | } |
46 | 46 | ||
47 | Filter::~Filter() | 47 | Filter::~Filter() |
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
51 | void Filter::setName( const QString &name ) | 51 | void Filter::setName( const QString &name ) |
52 | { | 52 | { |
53 | mName = name; | 53 | mName = name; |
54 | } | 54 | } |
55 | 55 | ||
56 | const QString &Filter::name() const | 56 | const QString &Filter::name() const |
57 | { | 57 | { |
58 | return mName; | 58 | return mName; |
59 | } | 59 | } |
60 | 60 | ||
61 | bool Filter::isInternal() const | 61 | bool Filter::isInternal() const |
62 | { | 62 | { |
63 | return mInternal; | 63 | return mInternal; |
64 | } | 64 | } |
65 | 65 | ||
66 | void Filter::apply( KABC::Addressee::List &addresseeList ) | 66 | void Filter::apply( KABC::Addressee::List &addresseeList ) |
67 | { | 67 | { |
68 | KABC::Addressee::List::Iterator iter; | 68 | KABC::Addressee::List::Iterator iter; |
69 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) { | 69 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) { |
70 | if ( filterAddressee( *iter ) ) | 70 | if ( filterAddressee( *iter ) ) |
71 | ++iter; | 71 | ++iter; |
72 | else | 72 | else |
73 | { | 73 | { |
74 | #ifndef KAB_EMBEDDED | 74 | #ifndef KAB_EMBEDDED |
75 | iter = addresseeList.erase( iter ); | 75 | iter = addresseeList.erase( iter ); |
76 | #else //KAB_EMBEDDED | 76 | #else //KAB_EMBEDDED |
77 | iter = addresseeList.remove( iter ); | 77 | iter = addresseeList.remove( iter ); |
78 | #endif //KAB_EMBEDDED | 78 | #endif //KAB_EMBEDDED |
79 | } | 79 | } |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | bool Filter::filterAddressee( const KABC::Addressee &a ) | 83 | bool Filter::filterAddressee( const KABC::Addressee &a ) |
84 | { | 84 | { |
85 | switch ( a.secrecy().type()) { | 85 | switch ( a.secrecy().type()) { |
86 | case KABC::Secrecy::Public: | 86 | case KABC::Secrecy::Public: |
87 | if (! (mCriteria & ShowPublic )) | 87 | if (! (mCriteria & ShowPublic )) |
88 | return false; | 88 | return false; |
89 | break; | 89 | break; |
90 | case KABC::Secrecy::Private: | 90 | case KABC::Secrecy::Private: |
91 | if (! (mCriteria & ShowPrivate )) | 91 | if (! (mCriteria & ShowPrivate )) |
92 | return false; | 92 | return false; |
93 | break; | 93 | break; |
94 | case KABC::Secrecy::Confidential: | 94 | case KABC::Secrecy::Confidential: |
95 | if (! (mCriteria & ShowConfidential )) | 95 | if (! (mCriteria & ShowConfidential )) |
96 | return false; | 96 | return false; |
97 | break; | 97 | break; |
98 | default: | 98 | default: |
99 | return false; | 99 | return false; |
100 | break; | 100 | break; |
101 | } | 101 | } |
102 | QStringList::Iterator iter; | 102 | QStringList::Iterator iter; |
103 | iter = mCategoryList.begin(); | 103 | iter = mCategoryList.begin(); |
104 | // empty filter always matches | 104 | // empty filter always matches |
105 | 105 | ||
106 | if ( iter == mCategoryList.end() ) | 106 | if ( iter == mCategoryList.end() ) |
107 | return true; | 107 | return true; |
108 | 108 | ||
109 | for ( ; iter != mCategoryList.end(); ++iter ) { | 109 | for ( ; iter != mCategoryList.end(); ++iter ) { |
110 | if ( a.hasCategory( *iter ) ) | 110 | if ( a.hasCategory( *iter ) ) |
111 | return ( mMatchRule == Matching ); | 111 | return ( mMatchRule == Matching ); |
112 | } | 112 | } |
113 | 113 | ||
114 | return !( mMatchRule == Matching ); | 114 | return !( mMatchRule == Matching ); |
115 | } | 115 | } |
116 | 116 | ||
117 | void Filter::setEnabled( bool on ) | 117 | void Filter::setEnabled( bool on ) |
118 | { | 118 | { |
119 | mEnabled = on; | 119 | mEnabled = on; |
120 | } | 120 | } |
121 | 121 | ||
122 | bool Filter::isEnabled() const | 122 | bool Filter::isEnabled() const |
123 | { | 123 | { |
124 | return mEnabled; | 124 | return mEnabled; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Filter::setCategories( const QStringList &list ) | 127 | void Filter::setCategories( const QStringList &list ) |
128 | { | 128 | { |
129 | mCategoryList = list; | 129 | mCategoryList = list; |
130 | } | 130 | } |
131 | 131 | ||
132 | const QStringList &Filter::categories() const | 132 | const QStringList &Filter::categories() const |
133 | { | 133 | { |
134 | return mCategoryList; | 134 | return mCategoryList; |
135 | } | 135 | } |
136 | 136 | ||
137 | void Filter::save( KConfig *config ) | 137 | void Filter::save( KConfig *config ) |
138 | { | 138 | { |
139 | config->writeEntry( "Name", mName ); | 139 | config->writeEntry( "Name", mName ); |
140 | config->writeEntry( "Enabled", mEnabled ); | 140 | config->writeEntry( "Enabled", mEnabled ); |
141 | config->writeEntry( "Categories", mCategoryList ); | 141 | config->writeEntry( "Categories", mCategoryList ); |
142 | config->writeEntry( "MatchRule", (int)mMatchRule ); | 142 | config->writeEntry( "MatchRule", (int)mMatchRule ); |
143 | config->writeEntry( "Criteria", (int)mCriteria ); | 143 | config->writeEntry( "Criteria", (int)mCriteria ); |
144 | } | 144 | } |
145 | 145 | ||
146 | void Filter::restore( KConfig *config ) | 146 | void Filter::restore( KConfig *config ) |
147 | { | 147 | { |
148 | mName = config->readEntry( "Name", "<internal error>" ); | 148 | mName = config->readEntry( "Name", "<internal error>" ); |
149 | mEnabled = config->readBoolEntry( "Enabled", true ); | 149 | mEnabled = config->readBoolEntry( "Enabled", true ); |
150 | mCategoryList = config->readListEntry( "Categories" ); | 150 | mCategoryList = config->readListEntry( "Categories" ); |
151 | mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); | 151 | mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); |
152 | mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential) ); | 152 | mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential ) ); |
153 | } | 153 | } |
154 | 154 | ||
155 | void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) | 155 | void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) |
156 | { | 156 | { |
157 | { | 157 | { |
158 | KConfigGroupSaver s( config, baseGroup ); | 158 | KConfigGroupSaver s( config, baseGroup ); |
159 | 159 | ||
160 | // remove the old filters | 160 | // remove the old filters |
161 | uint count = config->readNumEntry( "Count" ); | 161 | uint count = config->readNumEntry( "Count" ); |
162 | /* // memory access violation here | 162 | /* // memory access violation here |
163 | for ( uint i = 0; i < count; ++i ) | 163 | for ( uint i = 0; i < count; ++i ) |
164 | config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); | 164 | config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); |
165 | */ | 165 | */ |
166 | } | 166 | } |
167 | 167 | ||
168 | int index = 0; | 168 | int index = 0; |
169 | Filter::List::Iterator iter; | 169 | Filter::List::Iterator iter; |
170 | for ( iter = list.begin(); iter != list.end(); ++iter ) { | 170 | for ( iter = list.begin(); iter != list.end(); ++iter ) { |
171 | if ( !(*iter).mInternal ) { | 171 | if ( !(*iter).mInternal ) { |
172 | KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) ); | 172 | KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) ); |
173 | 173 | ||
174 | (*iter).save( config ); | 174 | (*iter).save( config ); |
175 | index++; | 175 | index++; |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
179 | KConfigGroupSaver s( config, baseGroup ); | 179 | KConfigGroupSaver s( config, baseGroup ); |
180 | 180 | ||
181 | config->writeEntry( "Count", index ); | 181 | config->writeEntry( "Count", index ); |
182 | 182 | ||
183 | } | 183 | } |
184 | 184 | ||
185 | Filter::List Filter::restore( KConfig *config, QString baseGroup ) | 185 | Filter::List Filter::restore( KConfig *config, QString baseGroup ) |
186 | { | 186 | { |
187 | Filter::List list; | 187 | Filter::List list; |
188 | int count = 0; | 188 | int count = 0; |
189 | Filter f; | 189 | Filter f; |
190 | 190 | ||
191 | { | 191 | { |
192 | KConfigGroupSaver s( config, baseGroup ); | 192 | KConfigGroupSaver s( config, baseGroup ); |
193 | count = config->readNumEntry( "Count", 0 ); | 193 | count = config->readNumEntry( "Count", 0 ); |
194 | } | 194 | } |
195 | 195 | ||
196 | for ( int i = 0; i < count; i++ ) { | 196 | for ( int i = 0; i < count; i++ ) { |
197 | { | 197 | { |
198 | KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); | 198 | KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); |
199 | f.restore( config ); | 199 | f.restore( config ); |
200 | } | 200 | } |
201 | 201 | ||
202 | list.append( f ); | 202 | list.append( f ); |
203 | } | 203 | } |
204 | 204 | ||
205 | if ( list.isEmpty()) { | 205 | if ( list.isEmpty()) { |
206 | QStringList cats = KABPrefs::instance()->mCustomCategories; | 206 | QStringList cats = KABPrefs::instance()->mCustomCategories; |
207 | for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { | 207 | for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { |
208 | Filter filter; | 208 | Filter filter; |
209 | filter.mName = *it; | 209 | filter.mName = *it; |
210 | filter.mEnabled = true; | 210 | filter.mEnabled = true; |
211 | filter.mCategoryList = *it; | 211 | filter.mCategoryList = *it; |
212 | filter.mMatchRule = Matching; | 212 | filter.mMatchRule = Matching; |
213 | filter.mInternal = true; | 213 | filter.mInternal = true; |
214 | list.append( filter ); | 214 | list.append( filter ); |
215 | } | 215 | } |
216 | } | 216 | } |
217 | return list; | 217 | return list; |
218 | } | 218 | } |
219 | 219 | ||
220 | void Filter::setMatchRule( MatchRule rule ) | 220 | void Filter::setMatchRule( MatchRule rule ) |
221 | { | 221 | { |
222 | mMatchRule = rule; | 222 | mMatchRule = rule; |
223 | } | 223 | } |
224 | 224 | ||
225 | Filter::MatchRule Filter::matchRule() const | 225 | Filter::MatchRule Filter::matchRule() const |
226 | { | 226 | { |
227 | return mMatchRule; | 227 | return mMatchRule; |
228 | } | 228 | } |
diff --git a/kaddressbook/filter.h b/kaddressbook/filter.h index 26870d7..93f1352 100644 --- a/kaddressbook/filter.h +++ b/kaddressbook/filter.h | |||
@@ -1,157 +1,157 @@ | |||
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 FILTER_H | 24 | #ifndef FILTER_H |
25 | #define FILTER_H | 25 | #define FILTER_H |
26 | 26 | ||
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qvaluelist.h> | 29 | #include <qvaluelist.h> |
30 | 30 | ||
31 | #include <kabc/addressee.h> | 31 | #include <kabc/addressee.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | 33 | ||
34 | /** | 34 | /** |
35 | Filter for AddressBook related objects (Addressees) | 35 | Filter for AddressBook related objects (Addressees) |
36 | 36 | ||
37 | @todo This class should be switched to use shared data. | 37 | @todo This class should be switched to use shared data. |
38 | */ | 38 | */ |
39 | class Filter | 39 | class Filter |
40 | { | 40 | { |
41 | public: | 41 | public: |
42 | enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4}; | 42 | enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4 }; |
43 | void setCriteria(int c) { mCriteria = c ;} | 43 | void setCriteria(int c) { mCriteria = c ;} |
44 | int criteria() const { return mCriteria;} | 44 | int criteria() const { return mCriteria;} |
45 | typedef QValueList<Filter> List; | 45 | typedef QValueList<Filter> List; |
46 | 46 | ||
47 | enum MatchRule { Matching = 0, NotMatching = 1 }; | 47 | enum MatchRule { Matching = 0, NotMatching = 1 }; |
48 | 48 | ||
49 | Filter(); | 49 | Filter(); |
50 | Filter( const QString& name ); | 50 | Filter( const QString& name ); |
51 | ~Filter(); | 51 | ~Filter(); |
52 | 52 | ||
53 | /** | 53 | /** |
54 | Set the name of the filter. | 54 | Set the name of the filter. |
55 | */ | 55 | */ |
56 | void setName( const QString &name ); | 56 | void setName( const QString &name ); |
57 | 57 | ||
58 | /** | 58 | /** |
59 | @return The name of the filter. | 59 | @return The name of the filter. |
60 | */ | 60 | */ |
61 | const QString &name() const; | 61 | const QString &name() const; |
62 | 62 | ||
63 | /** | 63 | /** |
64 | @return Whether the filter is an internal one. | 64 | @return Whether the filter is an internal one. |
65 | */ | 65 | */ |
66 | bool isInternal() const; | 66 | bool isInternal() const; |
67 | 67 | ||
68 | /** | 68 | /** |
69 | Apply the filter to the addressee list. All addressees not passing | 69 | Apply the filter to the addressee list. All addressees not passing |
70 | the filter criterias will be removed from the list. | 70 | the filter criterias will be removed from the list. |
71 | 71 | ||
72 | If the MatchRule is NotMatch, then all the addressees matching the | 72 | If the MatchRule is NotMatch, then all the addressees matching the |
73 | filter will be removed from the list. | 73 | filter will be removed from the list. |
74 | */ | 74 | */ |
75 | void apply( KABC::Addressee::List &addresseeList ); | 75 | void apply( KABC::Addressee::List &addresseeList ); |
76 | 76 | ||
77 | /** | 77 | /** |
78 | Apply the filter to the addressee. | 78 | Apply the filter to the addressee. |
79 | 79 | ||
80 | @return True if the addressee passes the criteria, false otherwise. | 80 | @return True if the addressee passes the criteria, false otherwise. |
81 | The return values are opposite if the MatchRule is NotMatch. | 81 | The return values are opposite if the MatchRule is NotMatch. |
82 | */ | 82 | */ |
83 | bool filterAddressee( const KABC::Addressee &a ); | 83 | bool filterAddressee( const KABC::Addressee &a ); |
84 | 84 | ||
85 | /** | 85 | /** |
86 | Enable or disable the filter | 86 | Enable or disable the filter |
87 | */ | 87 | */ |
88 | void setEnabled( bool on ); | 88 | void setEnabled( bool on ); |
89 | 89 | ||
90 | /** | 90 | /** |
91 | @return True if this filter is enabled, false otherwise. | 91 | @return True if this filter is enabled, false otherwise. |
92 | */ | 92 | */ |
93 | bool isEnabled() const; | 93 | bool isEnabled() const; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | Set the list of categories. This list is used to filter addressees. | 96 | Set the list of categories. This list is used to filter addressees. |
97 | */ | 97 | */ |
98 | void setCategories( const QStringList &list ); | 98 | void setCategories( const QStringList &list ); |
99 | 99 | ||
100 | /** | 100 | /** |
101 | @return The list of categories. | 101 | @return The list of categories. |
102 | */ | 102 | */ |
103 | const QStringList &categories() const; | 103 | const QStringList &categories() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Saves the filter to the config file. The group should already be set. | 106 | Saves the filter to the config file. The group should already be set. |
107 | */ | 107 | */ |
108 | void save( KConfig *config ); | 108 | void save( KConfig *config ); |
109 | 109 | ||
110 | /** | 110 | /** |
111 | Loads the filter from the config file. The group should already be set. | 111 | Loads the filter from the config file. The group should already be set. |
112 | */ | 112 | */ |
113 | void restore( KConfig *config ); | 113 | void restore( KConfig *config ); |
114 | 114 | ||
115 | /** | 115 | /** |
116 | Saves a list of filters to the config file. | 116 | Saves a list of filters to the config file. |
117 | 117 | ||
118 | @param config The config file to use | 118 | @param config The config file to use |
119 | @param baseGroup The base groupname to use. The number of filters | 119 | @param baseGroup The base groupname to use. The number of filters |
120 | will be written to this group, then a _1, _2, etc | 120 | will be written to this group, then a _1, _2, etc |
121 | will be append for each filter saved. | 121 | will be append for each filter saved. |
122 | @param list The list of filters to be saved. | 122 | @param list The list of filters to be saved. |
123 | */ | 123 | */ |
124 | static void save( KConfig *config, QString baseGroup, Filter::List &list ); | 124 | static void save( KConfig *config, QString baseGroup, Filter::List &list ); |
125 | 125 | ||
126 | /** | 126 | /** |
127 | Restores a list of filters from a config file. | 127 | Restores a list of filters from a config file. |
128 | 128 | ||
129 | @param config The config file to read from. | 129 | @param config The config file to read from. |
130 | @param baseGroup The base group name to be used to find the filters | 130 | @param baseGroup The base group name to be used to find the filters |
131 | 131 | ||
132 | @return The list of filters. | 132 | @return The list of filters. |
133 | */ | 133 | */ |
134 | static Filter::List restore( KConfig *config, QString baseGroup ); | 134 | static Filter::List restore( KConfig *config, QString baseGroup ); |
135 | 135 | ||
136 | /** | 136 | /** |
137 | Sets the filter rule. If the rule is Filter::Matching (default), | 137 | Sets the filter rule. If the rule is Filter::Matching (default), |
138 | then the filter will return true on items that match the filter. | 138 | then the filter will return true on items that match the filter. |
139 | If the rule is Filter::NotMatching, then the filter will return | 139 | If the rule is Filter::NotMatching, then the filter will return |
140 | true on items that do not match the filter. | 140 | true on items that do not match the filter. |
141 | */ | 141 | */ |
142 | void setMatchRule( MatchRule rule ); | 142 | void setMatchRule( MatchRule rule ); |
143 | 143 | ||
144 | /** @return The current match rule. | 144 | /** @return The current match rule. |
145 | */ | 145 | */ |
146 | MatchRule matchRule() const; | 146 | MatchRule matchRule() const; |
147 | 147 | ||
148 | private: | 148 | private: |
149 | int mCriteria; | 149 | int mCriteria; |
150 | QString mName; | 150 | QString mName; |
151 | QStringList mCategoryList; | 151 | QStringList mCategoryList; |
152 | MatchRule mMatchRule; | 152 | MatchRule mMatchRule; |
153 | bool mEnabled; | 153 | bool mEnabled; |
154 | bool mInternal; | 154 | bool mInternal; |
155 | }; | 155 | }; |
156 | 156 | ||
157 | #endif | 157 | #endif |
diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp index 987f234..1194406 100644 --- a/kaddressbook/filtereditdialog.cpp +++ b/kaddressbook/filtereditdialog.cpp | |||
@@ -1,316 +1,315 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
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 <qbuttongroup.h> | 31 | #include <qbuttongroup.h> |
32 | #include <qhbox.h> | 32 | #include <qhbox.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qradiobutton.h> | 36 | #include <qradiobutton.h> |
37 | #include <qcheckbox.h> | 37 | #include <qcheckbox.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qstring.h> | 39 | #include <qstring.h> |
40 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
41 | #include <qtooltip.h> | 41 | #include <qtooltip.h> |
42 | #include <qwidget.h> | 42 | #include <qwidget.h> |
43 | 43 | ||
44 | #include <kapplication.h> | 44 | #include <kapplication.h> |
45 | #include <kbuttonbox.h> | 45 | #include <kbuttonbox.h> |
46 | #include <kdebug.h> | 46 | #include <kdebug.h> |
47 | #include <kiconloader.h> | 47 | #include <kiconloader.h> |
48 | #include <klineedit.h> | 48 | #include <klineedit.h> |
49 | #include <klistbox.h> | 49 | #include <klistbox.h> |
50 | #include <klistview.h> | 50 | #include <klistview.h> |
51 | #include <klocale.h> | 51 | #include <klocale.h> |
52 | #include <kglobal.h> | 52 | #include <kglobal.h> |
53 | 53 | ||
54 | #include "kabprefs.h" | 54 | #include "kabprefs.h" |
55 | #include "filtereditdialog.h" | 55 | #include "filtereditdialog.h" |
56 | 56 | ||
57 | FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name ) | 57 | FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name ) |
58 | : KDialogBase( Plain, i18n( "Edit Address Book Filter" ), | 58 | : KDialogBase( Plain, i18n( "Edit Address Book Filter" ), |
59 | Help | Ok | Cancel, Ok, parent, name, /*US false*/ true, true ) | 59 | Help | Ok | Cancel, Ok, parent, name, /*US false*/ true, true ) |
60 | { | 60 | { |
61 | initGUI(); | 61 | initGUI(); |
62 | 62 | ||
63 | QStringList cats = KABPrefs::instance()->mCustomCategories; | 63 | QStringList cats = KABPrefs::instance()->mCustomCategories; |
64 | 64 | ||
65 | QStringList::Iterator iter; | 65 | QStringList::Iterator iter; |
66 | for ( iter = cats.begin(); iter != cats.end(); ++iter ) | 66 | for ( iter = cats.begin(); iter != cats.end(); ++iter ) |
67 | mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) ); | 67 | mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) ); |
68 | filterNameTextChanged( mNameEdit->text() ); | 68 | filterNameTextChanged( mNameEdit->text() ); |
69 | } | 69 | } |
70 | 70 | ||
71 | FilterEditDialog::~FilterEditDialog() | 71 | FilterEditDialog::~FilterEditDialog() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | void FilterEditDialog::setFilter( const Filter &filter ) | 75 | void FilterEditDialog::setFilter( const Filter &filter ) |
76 | { | 76 | { |
77 | mNameEdit->setText( filter.name() ); | 77 | mNameEdit->setText( filter.name() ); |
78 | 78 | ||
79 | QStringList categories = filter.categories(); | 79 | QStringList categories = filter.categories(); |
80 | QListViewItem *item = mCategoriesView->firstChild(); | 80 | QListViewItem *item = mCategoriesView->firstChild(); |
81 | while ( item != 0 ) { | 81 | while ( item != 0 ) { |
82 | if ( categories.contains( item->text( 0 ) ) ) { | 82 | if ( categories.contains( item->text( 0 ) ) ) { |
83 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); | 83 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); |
84 | checkItem->setOn( true ); | 84 | checkItem->setOn( true ); |
85 | } | 85 | } |
86 | 86 | ||
87 | item = item->nextSibling(); | 87 | item = item->nextSibling(); |
88 | } | 88 | } |
89 | 89 | ||
90 | if ( filter.matchRule() == Filter::Matching ) | 90 | if ( filter.matchRule() == Filter::Matching ) |
91 | mMatchRuleGroup->setButton( 0 ); | 91 | mMatchRuleGroup->setButton( 0 ); |
92 | else | 92 | else |
93 | mMatchRuleGroup->setButton( 1 ); | 93 | mMatchRuleGroup->setButton( 1 ); |
94 | 94 | ||
95 | int c = filter.criteria() ; | 95 | int c = filter.criteria() ; |
96 | mPublic->setChecked(c &Filter::ShowPublic); | 96 | mPublic->setChecked(c &Filter::ShowPublic); |
97 | mPrivate->setChecked(c & Filter::ShowPrivate); | 97 | mPrivate->setChecked(c & Filter::ShowPrivate); |
98 | mConfidential->setChecked(c & Filter::ShowConfidential); | 98 | mConfidential->setChecked(c & Filter::ShowConfidential); |
99 | |||
100 | } | 99 | } |
101 | 100 | ||
102 | Filter FilterEditDialog::filter() | 101 | Filter FilterEditDialog::filter() |
103 | { | 102 | { |
104 | Filter filter; | 103 | Filter filter; |
105 | 104 | ||
106 | filter.setName( mNameEdit->text() ); | 105 | filter.setName( mNameEdit->text() ); |
107 | 106 | ||
108 | QStringList categories; | 107 | QStringList categories; |
109 | QListViewItem *item = mCategoriesView->firstChild(); | 108 | QListViewItem *item = mCategoriesView->firstChild(); |
110 | while ( item != 0 ) { | 109 | while ( item != 0 ) { |
111 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); | 110 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); |
112 | if ( checkItem->isOn() ) | 111 | if ( checkItem->isOn() ) |
113 | categories.append( item->text( 0 ) ); | 112 | categories.append( item->text( 0 ) ); |
114 | 113 | ||
115 | item = item->nextSibling(); | 114 | item = item->nextSibling(); |
116 | } | 115 | } |
117 | filter.setCategories( categories ); | 116 | filter.setCategories( categories ); |
118 | 117 | ||
119 | if ( mMatchRuleGroup->find( 0 )->isOn() ) | 118 | if ( mMatchRuleGroup->find( 0 )->isOn() ) |
120 | filter.setMatchRule( Filter::Matching ); | 119 | filter.setMatchRule( Filter::Matching ); |
121 | else | 120 | else |
122 | filter.setMatchRule( Filter::NotMatching ); | 121 | filter.setMatchRule( Filter::NotMatching ); |
123 | 122 | ||
124 | int c = 0; | 123 | int c = 0; |
125 | if (mPublic->isChecked()) c |= Filter::ShowPublic; | 124 | if (mPublic->isChecked()) c |= Filter::ShowPublic; |
126 | if (mPrivate->isChecked()) c |= Filter::ShowPrivate; | 125 | if (mPrivate->isChecked()) c |= Filter::ShowPrivate; |
127 | if (mConfidential->isChecked()) c |= Filter::ShowConfidential; | 126 | if (mConfidential->isChecked()) c |= Filter::ShowConfidential; |
128 | filter.setCriteria( c ) ; | 127 | filter.setCriteria( c ) ; |
129 | 128 | ||
130 | return filter; | 129 | return filter; |
131 | } | 130 | } |
132 | 131 | ||
133 | void FilterEditDialog::initGUI() | 132 | void FilterEditDialog::initGUI() |
134 | { | 133 | { |
135 | #ifndef KAB_EMBEDDED | 134 | #ifndef KAB_EMBEDDED |
136 | resize( 490, 300 ); | 135 | resize( 490, 300 ); |
137 | #else //KAB_EMBEDDED | 136 | #else //KAB_EMBEDDED |
138 | resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); | 137 | resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); |
139 | #endif //KAB_EMBEDDED | 138 | #endif //KAB_EMBEDDED |
140 | 139 | ||
141 | 140 | ||
142 | QWidget *page = plainPage(); | 141 | QWidget *page = plainPage(); |
143 | QLabel *label; | 142 | QLabel *label; |
144 | 143 | ||
145 | QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() ); | 144 | QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() ); |
146 | 145 | ||
147 | label = new QLabel( i18n( "Name" ), page ); | 146 | label = new QLabel( i18n( "Name" ), page ); |
148 | mNameEdit = new KLineEdit( page ); | 147 | mNameEdit = new KLineEdit( page ); |
149 | mNameEdit->setFocus(); | 148 | mNameEdit->setFocus(); |
150 | topLayout->addWidget( label, 0, 0 ); | 149 | topLayout->addWidget( label, 0, 0 ); |
151 | topLayout->addWidget( mNameEdit, 0, 1 ); | 150 | topLayout->addWidget( mNameEdit, 0, 1 ); |
152 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), | 151 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), |
153 | SLOT( filterNameTextChanged( const QString&) ) ); | 152 | SLOT( filterNameTextChanged( const QString&) ) ); |
154 | 153 | ||
155 | mCategoriesView = new KListView( page ); | 154 | mCategoriesView = new KListView( page ); |
156 | mCategoriesView->addColumn( i18n( "Categories" ) ); | 155 | mCategoriesView->addColumn( i18n( "Categories" ) ); |
157 | topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); | 156 | topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); |
158 | 157 | ||
159 | mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page ); | 158 | mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page ); |
160 | mMatchRuleGroup->setExclusive( true ); | 159 | mMatchRuleGroup->setExclusive( true ); |
161 | QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup ); | 160 | QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup ); |
162 | radio->setChecked( true ); | 161 | radio->setChecked( true ); |
163 | //mMatchRuleGroup->insert( radio ); | 162 | //mMatchRuleGroup->insert( radio ); |
164 | radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup ); | 163 | radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup ); |
165 | //mMatchRuleGroup->insert( radio ); | 164 | //mMatchRuleGroup->insert( radio ); |
166 | topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 ); | 165 | topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 ); |
167 | 166 | ||
168 | QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page ); | 167 | QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page ); |
169 | mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup ); | 168 | mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup ); |
170 | mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup ); | 169 | mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup ); |
171 | mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup ); | 170 | mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup ); |
172 | mPublic->setChecked( true ); | 171 | mPublic->setChecked( true ); |
173 | mPrivate->setChecked( true ); | 172 | mPrivate->setChecked( true ); |
174 | mConfidential->setChecked( true ); | 173 | mConfidential->setChecked( true ); |
175 | topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 ); | 174 | topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 ); |
176 | 175 | ||
177 | } | 176 | } |
178 | 177 | ||
179 | void FilterEditDialog::filterNameTextChanged( const QString &text ) | 178 | void FilterEditDialog::filterNameTextChanged( const QString &text ) |
180 | { | 179 | { |
181 | enableButtonOK( !text.isEmpty() ); | 180 | enableButtonOK( !text.isEmpty() ); |
182 | } | 181 | } |
183 | 182 | ||
184 | void FilterEditDialog::slotHelp() | 183 | void FilterEditDialog::slotHelp() |
185 | { | 184 | { |
186 | #ifndef KAB_EMBEDDED | 185 | #ifndef KAB_EMBEDDED |
187 | kapp->invokeHelp( "using-filters" ); | 186 | kapp->invokeHelp( "using-filters" ); |
188 | #endif //KAB_EMBEDDED | 187 | #endif //KAB_EMBEDDED |
189 | } | 188 | } |
190 | 189 | ||
191 | FilterDialog::FilterDialog( QWidget *parent, const char *name ) | 190 | FilterDialog::FilterDialog( QWidget *parent, const char *name ) |
192 | : KDialogBase( Plain, i18n( "Edit Address Book Filters" ), | 191 | : KDialogBase( Plain, i18n( "Edit Address Book Filters" ), |
193 | Ok | Cancel, Ok, parent, name, /*US false*/true, true ) | 192 | Ok | Cancel, Ok, parent, name, /*US false*/true, true ) |
194 | { | 193 | { |
195 | initGUI(); | 194 | initGUI(); |
196 | } | 195 | } |
197 | 196 | ||
198 | FilterDialog::~FilterDialog() | 197 | FilterDialog::~FilterDialog() |
199 | { | 198 | { |
200 | } | 199 | } |
201 | 200 | ||
202 | void FilterDialog::setFilters( const Filter::List &list ) | 201 | void FilterDialog::setFilters( const Filter::List &list ) |
203 | { | 202 | { |
204 | mFilterList.clear(); | 203 | mFilterList.clear(); |
205 | mInternalFilterList.clear(); | 204 | mInternalFilterList.clear(); |
206 | 205 | ||
207 | Filter::List::ConstIterator it; | 206 | Filter::List::ConstIterator it; |
208 | for ( it = list.begin(); it != list.end(); ++it ) { | 207 | for ( it = list.begin(); it != list.end(); ++it ) { |
209 | if ( (*it).isInternal() ) | 208 | if ( (*it).isInternal() ) |
210 | mInternalFilterList.append( *it ); | 209 | mInternalFilterList.append( *it ); |
211 | else | 210 | else |
212 | mFilterList.append( *it ); | 211 | mFilterList.append( *it ); |
213 | } | 212 | } |
214 | 213 | ||
215 | refresh(); | 214 | refresh(); |
216 | } | 215 | } |
217 | 216 | ||
218 | Filter::List FilterDialog::filters() const | 217 | Filter::List FilterDialog::filters() const |
219 | { | 218 | { |
220 | Filter::List list = mFilterList + mInternalFilterList; | 219 | Filter::List list = mFilterList + mInternalFilterList; |
221 | return list; | 220 | return list; |
222 | } | 221 | } |
223 | 222 | ||
224 | void FilterDialog::add() | 223 | void FilterDialog::add() |
225 | { | 224 | { |
226 | #ifndef KAB_EMBEDDED | 225 | #ifndef KAB_EMBEDDED |
227 | FilterEditDialog dlg( this ); | 226 | FilterEditDialog dlg( this ); |
228 | #else //KAB_EMBEDDED | 227 | #else //KAB_EMBEDDED |
229 | FilterEditDialog dlg( this->parentWidget() ); | 228 | FilterEditDialog dlg( this->parentWidget() ); |
230 | #endif //KAB_EMBEDDED | 229 | #endif //KAB_EMBEDDED |
231 | 230 | ||
232 | if ( dlg.exec() ) | 231 | if ( dlg.exec() ) |
233 | mFilterList.append( dlg.filter() ); | 232 | mFilterList.append( dlg.filter() ); |
234 | 233 | ||
235 | refresh(); | 234 | refresh(); |
236 | 235 | ||
237 | mFilterListBox->setCurrentItem( mFilterListBox->count() - 1 ); | 236 | mFilterListBox->setCurrentItem( mFilterListBox->count() - 1 ); |
238 | } | 237 | } |
239 | 238 | ||
240 | void FilterDialog::edit() | 239 | void FilterDialog::edit() |
241 | { | 240 | { |
242 | FilterEditDialog dlg( this ); | 241 | FilterEditDialog dlg( this ); |
243 | 242 | ||
244 | uint pos = mFilterListBox->currentItem(); | 243 | uint pos = mFilterListBox->currentItem(); |
245 | 244 | ||
246 | dlg.setFilter( mFilterList[ pos ] ); | 245 | dlg.setFilter( mFilterList[ pos ] ); |
247 | 246 | ||
248 | if ( dlg.exec() ) { | 247 | if ( dlg.exec() ) { |
249 | mFilterList.remove( mFilterList.at( pos ) ); | 248 | mFilterList.remove( mFilterList.at( pos ) ); |
250 | mFilterList.insert( mFilterList.at( pos ), dlg.filter() ); | 249 | mFilterList.insert( mFilterList.at( pos ), dlg.filter() ); |
251 | } | 250 | } |
252 | 251 | ||
253 | refresh(); | 252 | refresh(); |
254 | 253 | ||
255 | mFilterListBox->setCurrentItem( pos ); | 254 | mFilterListBox->setCurrentItem( pos ); |
256 | } | 255 | } |
257 | 256 | ||
258 | void FilterDialog::remove() | 257 | void FilterDialog::remove() |
259 | { | 258 | { |
260 | mFilterList.remove( mFilterList.at( mFilterListBox->currentItem() ) ); | 259 | mFilterList.remove( mFilterList.at( mFilterListBox->currentItem() ) ); |
261 | 260 | ||
262 | selectionChanged( 0 ); | 261 | selectionChanged( 0 ); |
263 | 262 | ||
264 | refresh(); | 263 | refresh(); |
265 | } | 264 | } |
266 | 265 | ||
267 | void FilterDialog::refresh() | 266 | void FilterDialog::refresh() |
268 | { | 267 | { |
269 | mFilterListBox->clear(); | 268 | mFilterListBox->clear(); |
270 | 269 | ||
271 | Filter::List::Iterator iter; | 270 | Filter::List::Iterator iter; |
272 | for ( iter = mFilterList.begin(); iter != mFilterList.end(); ++iter ) | 271 | for ( iter = mFilterList.begin(); iter != mFilterList.end(); ++iter ) |
273 | mFilterListBox->insertItem( (*iter).name() ); | 272 | mFilterListBox->insertItem( (*iter).name() ); |
274 | } | 273 | } |
275 | 274 | ||
276 | void FilterDialog::selectionChanged( QListBoxItem *item ) | 275 | void FilterDialog::selectionChanged( QListBoxItem *item ) |
277 | { | 276 | { |
278 | bool state = ( item != 0 ); | 277 | bool state = ( item != 0 ); |
279 | 278 | ||
280 | mEditButton->setEnabled( state ); | 279 | mEditButton->setEnabled( state ); |
281 | mRemoveButton->setEnabled( state ); | 280 | mRemoveButton->setEnabled( state ); |
282 | } | 281 | } |
283 | 282 | ||
284 | void FilterDialog::initGUI() | 283 | void FilterDialog::initGUI() |
285 | { | 284 | { |
286 | #ifndef KAB_EMBEDDED | 285 | #ifndef KAB_EMBEDDED |
287 | resize( 330, 200 ); | 286 | resize( 330, 200 ); |
288 | #else //KAB_EMBEDDED | 287 | #else //KAB_EMBEDDED |
289 | resize( KMIN(KGlobal::getDesktopWidth()-10, 330), KMIN(KGlobal::getDesktopHeight()-50, 200)); | 288 | resize( KMIN(KGlobal::getDesktopWidth()-10, 330), KMIN(KGlobal::getDesktopHeight()-50, 200)); |
290 | #endif //KAB_EMBEDDED | 289 | #endif //KAB_EMBEDDED |
291 | 290 | ||
292 | QWidget *page = plainPage(); | 291 | QWidget *page = plainPage(); |
293 | 292 | ||
294 | QGridLayout *topLayout = new QGridLayout( page, 1, 2, 0, spacingHint() ); | 293 | QGridLayout *topLayout = new QGridLayout( page, 1, 2, 0, spacingHint() ); |
295 | 294 | ||
296 | mFilterListBox = new KListBox( page ); | 295 | mFilterListBox = new KListBox( page ); |
297 | topLayout->addWidget( mFilterListBox, 0, 0 ); | 296 | topLayout->addWidget( mFilterListBox, 0, 0 ); |
298 | connect( mFilterListBox, SIGNAL( selectionChanged( QListBoxItem * ) ), | 297 | connect( mFilterListBox, SIGNAL( selectionChanged( QListBoxItem * ) ), |
299 | SLOT( selectionChanged( QListBoxItem * ) ) ); | 298 | SLOT( selectionChanged( QListBoxItem * ) ) ); |
300 | connect( mFilterListBox, SIGNAL( doubleClicked ( QListBoxItem * ) ), | 299 | connect( mFilterListBox, SIGNAL( doubleClicked ( QListBoxItem * ) ), |
301 | SLOT( edit() ) ); | 300 | SLOT( edit() ) ); |
302 | 301 | ||
303 | KButtonBox *buttonBox = new KButtonBox( page, Vertical ); | 302 | KButtonBox *buttonBox = new KButtonBox( page, Vertical ); |
304 | buttonBox->addButton( i18n( "&Add..." ), this, SLOT( add() ) ); | 303 | buttonBox->addButton( i18n( "&Add..." ), this, SLOT( add() ) ); |
305 | mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( edit() ) ); | 304 | mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( edit() ) ); |
306 | mEditButton->setEnabled( false ); | 305 | mEditButton->setEnabled( false ); |
307 | mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( remove() ) ); | 306 | mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( remove() ) ); |
308 | mRemoveButton->setEnabled( false ); | 307 | mRemoveButton->setEnabled( false ); |
309 | 308 | ||
310 | buttonBox->layout(); | 309 | buttonBox->layout(); |
311 | topLayout->addWidget( buttonBox, 0, 1 ); | 310 | topLayout->addWidget( buttonBox, 0, 1 ); |
312 | } | 311 | } |
313 | 312 | ||
314 | #ifndef KAB_EMBEDDED | 313 | #ifndef KAB_EMBEDDED |
315 | #include "filtereditdialog.moc" | 314 | #include "filtereditdialog.moc" |
316 | #endif //KAB_EMBEDDED | 315 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index e61f65f..aa04631 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -10,814 +10,816 @@ | |||
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 | KABPrefs::instance()->writeConfig(); | ||
569 | qDebug("KABPrefs::instance()->writeConfig() "); | ||
568 | } | 570 | } |
569 | 571 | ||
570 | KABC::AddressBook *KABCore::addressBook() const | 572 | KABC::AddressBook *KABCore::addressBook() const |
571 | { | 573 | { |
572 | return mAddressBook; | 574 | return mAddressBook; |
573 | } | 575 | } |
574 | 576 | ||
575 | KConfig *KABCore::config() | 577 | KConfig *KABCore::config() |
576 | { | 578 | { |
577 | #ifndef KAB_EMBEDDED | 579 | #ifndef KAB_EMBEDDED |
578 | return KABPrefs::instance()->config(); | 580 | return KABPrefs::instance()->config(); |
579 | #else //KAB_EMBEDDED | 581 | #else //KAB_EMBEDDED |
580 | return KABPrefs::instance()->getConfig(); | 582 | return KABPrefs::instance()->getConfig(); |
581 | #endif //KAB_EMBEDDED | 583 | #endif //KAB_EMBEDDED |
582 | } | 584 | } |
583 | 585 | ||
584 | KActionCollection *KABCore::actionCollection() const | 586 | KActionCollection *KABCore::actionCollection() const |
585 | { | 587 | { |
586 | return mGUIClient->actionCollection(); | 588 | return mGUIClient->actionCollection(); |
587 | } | 589 | } |
588 | 590 | ||
589 | KABC::Field *KABCore::currentSearchField() const | 591 | KABC::Field *KABCore::currentSearchField() const |
590 | { | 592 | { |
591 | if (mIncSearchWidget) | 593 | if (mIncSearchWidget) |
592 | return mIncSearchWidget->currentField(); | 594 | return mIncSearchWidget->currentField(); |
593 | else | 595 | else |
594 | return 0; | 596 | return 0; |
595 | } | 597 | } |
596 | 598 | ||
597 | QStringList KABCore::selectedUIDs() const | 599 | QStringList KABCore::selectedUIDs() const |
598 | { | 600 | { |
599 | return mViewManager->selectedUids(); | 601 | return mViewManager->selectedUids(); |
600 | } | 602 | } |
601 | 603 | ||
602 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 604 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
603 | { | 605 | { |
604 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 606 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
605 | 607 | ||
606 | QPtrList<KRES::Resource> kresResources; | 608 | QPtrList<KRES::Resource> kresResources; |
607 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 609 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
608 | KABC::Resource *resource; | 610 | KABC::Resource *resource; |
609 | while ( ( resource = resIt.current() ) != 0 ) { | 611 | while ( ( resource = resIt.current() ) != 0 ) { |
610 | ++resIt; | 612 | ++resIt; |
611 | if ( !resource->readOnly() ) { | 613 | if ( !resource->readOnly() ) { |
612 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 614 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
613 | if ( res ) | 615 | if ( res ) |
614 | kresResources.append( res ); | 616 | kresResources.append( res ); |
615 | } | 617 | } |
616 | } | 618 | } |
617 | 619 | ||
618 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 620 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
619 | return static_cast<KABC::Resource*>( res ); | 621 | return static_cast<KABC::Resource*>( res ); |
620 | } | 622 | } |
621 | 623 | ||
622 | #ifndef KAB_EMBEDDED | 624 | #ifndef KAB_EMBEDDED |
623 | KAboutData *KABCore::createAboutData() | 625 | KAboutData *KABCore::createAboutData() |
624 | #else //KAB_EMBEDDED | 626 | #else //KAB_EMBEDDED |
625 | void KABCore::createAboutData() | 627 | void KABCore::createAboutData() |
626 | #endif //KAB_EMBEDDED | 628 | #endif //KAB_EMBEDDED |
627 | { | 629 | { |
628 | #ifndef KAB_EMBEDDED | 630 | #ifndef KAB_EMBEDDED |
629 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 631 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
630 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 632 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
631 | KAboutData::License_GPL_V2, | 633 | KAboutData::License_GPL_V2, |
632 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 634 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
633 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 635 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
634 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 636 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
635 | about->addAuthor( "Cornelius Schumacher", | 637 | about->addAuthor( "Cornelius Schumacher", |
636 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 638 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
637 | "schumacher@kde.org" ); | 639 | "schumacher@kde.org" ); |
638 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 640 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
639 | "mpilone@slac.com" ); | 641 | "mpilone@slac.com" ); |
640 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 642 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
641 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 643 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
642 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 644 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
643 | "michel@klaralvdalens-datakonsult.se" ); | 645 | "michel@klaralvdalens-datakonsult.se" ); |
644 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 646 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
645 | "hansen@kde.org" ); | 647 | "hansen@kde.org" ); |
646 | 648 | ||
647 | return about; | 649 | return about; |
648 | #endif //KAB_EMBEDDED | 650 | #endif //KAB_EMBEDDED |
649 | 651 | ||
650 | QString version; | 652 | QString version; |
651 | #include <../version> | 653 | #include <../version> |
652 | QMessageBox::about( this, "About KAddressbook/Pi", | 654 | QMessageBox::about( this, "About KAddressbook/Pi", |
653 | "KAddressbook/Platform-independent\n" | 655 | "KAddressbook/Platform-independent\n" |
654 | "(KA/Pi) " +version + " - " + | 656 | "(KA/Pi) " +version + " - " + |
655 | #ifdef DESKTOP_VERSION | 657 | #ifdef DESKTOP_VERSION |
656 | "Desktop Edition\n" | 658 | "Desktop Edition\n" |
657 | #else | 659 | #else |
658 | "PDA-Edition\n" | 660 | "PDA-Edition\n" |
659 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 661 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
660 | #endif | 662 | #endif |
661 | 663 | ||
662 | "(c) 2004 Ulf Schenk\n" | 664 | "(c) 2004 Ulf Schenk\n" |
663 | "(c) 2004 Lutz Rogowski\n" | 665 | "(c) 2004 Lutz Rogowski\n" |
664 | "(c) 1997-2003, The KDE PIM Team\n" | 666 | "(c) 1997-2003, The KDE PIM Team\n" |
665 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 667 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
666 | "Don Sanders Original author\n" | 668 | "Don Sanders Original author\n" |
667 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 669 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
668 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 670 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
669 | "Greg Stern DCOP interface\n" | 671 | "Greg Stern DCOP interface\n" |
670 | "Mark Westcot Contact pinning\n" | 672 | "Mark Westcot Contact pinning\n" |
671 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 673 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
672 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 674 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
673 | #ifdef _WIN32_ | 675 | #ifdef _WIN32_ |
674 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 676 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
675 | #endif | 677 | #endif |
676 | ); | 678 | ); |
677 | } | 679 | } |
678 | 680 | ||
679 | void KABCore::setContactSelected( const QString &uid ) | 681 | void KABCore::setContactSelected( const QString &uid ) |
680 | { | 682 | { |
681 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 683 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
682 | if ( !mDetails->isHidden() ) | 684 | if ( !mDetails->isHidden() ) |
683 | mDetails->setAddressee( addr ); | 685 | mDetails->setAddressee( addr ); |
684 | 686 | ||
685 | if ( !addr.isEmpty() ) { | 687 | if ( !addr.isEmpty() ) { |
686 | emit contactSelected( addr.formattedName() ); | 688 | emit contactSelected( addr.formattedName() ); |
687 | KABC::Picture pic = addr.photo(); | 689 | KABC::Picture pic = addr.photo(); |
688 | if ( pic.isIntern() ) { | 690 | if ( pic.isIntern() ) { |
689 | //US emit contactSelected( pic.data() ); | 691 | //US emit contactSelected( pic.data() ); |
690 | //US instead use: | 692 | //US instead use: |
691 | QPixmap px; | 693 | QPixmap px; |
692 | if (pic.data().isNull() != true) | 694 | if (pic.data().isNull() != true) |
693 | { | 695 | { |
694 | px.convertFromImage(pic.data()); | 696 | px.convertFromImage(pic.data()); |
695 | } | 697 | } |
696 | 698 | ||
697 | emit contactSelected( px ); | 699 | emit contactSelected( px ); |
698 | } | 700 | } |
699 | } | 701 | } |
700 | 702 | ||
701 | 703 | ||
702 | mExtensionManager->setSelectionChanged(); | 704 | mExtensionManager->setSelectionChanged(); |
703 | 705 | ||
704 | // update the actions | 706 | // update the actions |
705 | bool selected = !uid.isEmpty(); | 707 | bool selected = !uid.isEmpty(); |
706 | 708 | ||
707 | if ( mReadWrite ) { | 709 | if ( mReadWrite ) { |
708 | mActionCut->setEnabled( selected ); | 710 | mActionCut->setEnabled( selected ); |
709 | mActionPaste->setEnabled( selected ); | 711 | mActionPaste->setEnabled( selected ); |
710 | } | 712 | } |
711 | 713 | ||
712 | mActionCopy->setEnabled( selected ); | 714 | mActionCopy->setEnabled( selected ); |
713 | mActionDelete->setEnabled( selected ); | 715 | mActionDelete->setEnabled( selected ); |
714 | mActionEditAddressee->setEnabled( selected ); | 716 | mActionEditAddressee->setEnabled( selected ); |
715 | mActionMail->setEnabled( selected ); | 717 | mActionMail->setEnabled( selected ); |
716 | mActionMailVCard->setEnabled( selected ); | 718 | mActionMailVCard->setEnabled( selected ); |
717 | //if (mActionBeam) | 719 | //if (mActionBeam) |
718 | //mActionBeam->setEnabled( selected ); | 720 | //mActionBeam->setEnabled( selected ); |
719 | mActionWhoAmI->setEnabled( selected ); | 721 | mActionWhoAmI->setEnabled( selected ); |
720 | } | 722 | } |
721 | 723 | ||
722 | void KABCore::sendMail() | 724 | void KABCore::sendMail() |
723 | { | 725 | { |
724 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 726 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
725 | } | 727 | } |
726 | 728 | ||
727 | void KABCore::sendMail( const QString& emaillist ) | 729 | void KABCore::sendMail( const QString& emaillist ) |
728 | { | 730 | { |
729 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 731 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
730 | if (emaillist.contains(",") > 0) | 732 | if (emaillist.contains(",") > 0) |
731 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 733 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
732 | else | 734 | else |
733 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 735 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
734 | } | 736 | } |
735 | 737 | ||
736 | 738 | ||
737 | 739 | ||
738 | void KABCore::mailVCard() | 740 | void KABCore::mailVCard() |
739 | { | 741 | { |
740 | QStringList uids = mViewManager->selectedUids(); | 742 | QStringList uids = mViewManager->selectedUids(); |
741 | if ( !uids.isEmpty() ) | 743 | if ( !uids.isEmpty() ) |
742 | mailVCard( uids ); | 744 | mailVCard( uids ); |
743 | } | 745 | } |
744 | 746 | ||
745 | void KABCore::mailVCard( const QStringList& uids ) | 747 | void KABCore::mailVCard( const QStringList& uids ) |
746 | { | 748 | { |
747 | QStringList urls; | 749 | QStringList urls; |
748 | 750 | ||
749 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 751 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
750 | 752 | ||
751 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 753 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
752 | 754 | ||
753 | 755 | ||
754 | 756 | ||
755 | QDir().mkdir( dirName, true ); | 757 | QDir().mkdir( dirName, true ); |
756 | 758 | ||
757 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 759 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
758 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 760 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
759 | 761 | ||
760 | if ( a.isEmpty() ) | 762 | if ( a.isEmpty() ) |
761 | continue; | 763 | continue; |
762 | 764 | ||
763 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 765 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
764 | 766 | ||
765 | QString fileName = dirName + "/" + name; | 767 | QString fileName = dirName + "/" + name; |
766 | 768 | ||
767 | QFile outFile(fileName); | 769 | QFile outFile(fileName); |
768 | 770 | ||
769 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 771 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
770 | KABC::VCardConverter converter; | 772 | KABC::VCardConverter converter; |
771 | QString vcard; | 773 | QString vcard; |
772 | 774 | ||
773 | converter.addresseeToVCard( a, vcard ); | 775 | converter.addresseeToVCard( a, vcard ); |
774 | 776 | ||
775 | QTextStream t( &outFile ); // use a text stream | 777 | QTextStream t( &outFile ); // use a text stream |
776 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 778 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
777 | t << vcard; | 779 | t << vcard; |
778 | 780 | ||
779 | outFile.close(); | 781 | outFile.close(); |
780 | 782 | ||
781 | urls.append( fileName ); | 783 | urls.append( fileName ); |
782 | } | 784 | } |
783 | } | 785 | } |
784 | 786 | ||
785 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 787 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
786 | 788 | ||
787 | 789 | ||
788 | /*US | 790 | /*US |
789 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 791 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
790 | QString::null, // subject | 792 | QString::null, // subject |
791 | QString::null, // body | 793 | QString::null, // body |
792 | QString::null, | 794 | QString::null, |
793 | urls ); // attachments | 795 | urls ); // attachments |
794 | */ | 796 | */ |
795 | 797 | ||
796 | } | 798 | } |
797 | 799 | ||
798 | /** | 800 | /** |
799 | Beams the "WhoAmI contact. | 801 | Beams the "WhoAmI contact. |
800 | */ | 802 | */ |
801 | void KABCore::beamMySelf() | 803 | void KABCore::beamMySelf() |
802 | { | 804 | { |
803 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 805 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
804 | if (!a.isEmpty()) | 806 | if (!a.isEmpty()) |
805 | { | 807 | { |
806 | QStringList uids; | 808 | QStringList uids; |
807 | uids << a.uid(); | 809 | uids << a.uid(); |
808 | 810 | ||
809 | beamVCard(uids); | 811 | beamVCard(uids); |
810 | } else { | 812 | } 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" ) ); | 813 | 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 | 814 | ||
813 | 815 | ||
814 | } | 816 | } |
815 | } | 817 | } |
816 | void KABCore::updateMainWindow() | 818 | void KABCore::updateMainWindow() |
817 | { | 819 | { |
818 | 820 | ||
819 | mMainWindow->showMaximized(); | 821 | mMainWindow->showMaximized(); |
820 | mMainWindow->update(); | 822 | mMainWindow->update(); |
821 | } | 823 | } |
822 | void KABCore::resizeEvent(QResizeEvent* e ) | 824 | void KABCore::resizeEvent(QResizeEvent* e ) |
823 | { | 825 | { |
@@ -2432,834 +2434,838 @@ void KABCore::configureResources() | |||
2432 | 2434 | ||
2433 | if ( !dlg.exec() ) | 2435 | if ( !dlg.exec() ) |
2434 | return; | 2436 | return; |
2435 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2437 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2436 | } | 2438 | } |
2437 | #endif //KAB_EMBEDDED | 2439 | #endif //KAB_EMBEDDED |
2438 | 2440 | ||
2439 | 2441 | ||
2440 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2442 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2441 | * for the attendees list of an event. | 2443 | * for the attendees list of an event. |
2442 | */ | 2444 | */ |
2443 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2445 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2444 | { | 2446 | { |
2445 | QStringList nameList; | 2447 | QStringList nameList; |
2446 | QStringList emailList; | 2448 | QStringList emailList; |
2447 | QStringList uidList; | 2449 | QStringList uidList; |
2448 | 2450 | ||
2449 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2451 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2450 | uint i=0; | 2452 | uint i=0; |
2451 | for (i=0; i < list.count(); i++) | 2453 | for (i=0; i < list.count(); i++) |
2452 | { | 2454 | { |
2453 | nameList.append(list[i].realName()); | 2455 | nameList.append(list[i].realName()); |
2454 | emailList.append(list[i].preferredEmail()); | 2456 | emailList.append(list[i].preferredEmail()); |
2455 | uidList.append(list[i].uid()); | 2457 | uidList.append(list[i].uid()); |
2456 | } | 2458 | } |
2457 | 2459 | ||
2458 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2460 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2459 | 2461 | ||
2460 | } | 2462 | } |
2461 | 2463 | ||
2462 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2464 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2463 | * to put them into the calendar. | 2465 | * to put them into the calendar. |
2464 | */ | 2466 | */ |
2465 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2467 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2466 | { | 2468 | { |
2467 | // qDebug("KABCore::requestForBirthdayList"); | 2469 | // qDebug("KABCore::requestForBirthdayList"); |
2468 | QStringList birthdayList; | 2470 | QStringList birthdayList; |
2469 | QStringList anniversaryList; | 2471 | QStringList anniversaryList; |
2470 | QStringList realNameList; | 2472 | QStringList realNameList; |
2471 | QStringList preferredEmailList; | 2473 | QStringList preferredEmailList; |
2472 | QStringList assembledNameList; | 2474 | QStringList assembledNameList; |
2473 | QStringList uidList; | 2475 | QStringList uidList; |
2474 | 2476 | ||
2475 | KABC::AddressBook::Iterator it; | 2477 | KABC::AddressBook::Iterator it; |
2476 | 2478 | ||
2477 | int count = 0; | 2479 | int count = 0; |
2478 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2480 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2479 | ++count; | 2481 | ++count; |
2480 | } | 2482 | } |
2481 | QProgressBar bar(count,0 ); | 2483 | QProgressBar bar(count,0 ); |
2482 | int w = 300; | 2484 | int w = 300; |
2483 | if ( QApplication::desktop()->width() < 320 ) | 2485 | if ( QApplication::desktop()->width() < 320 ) |
2484 | w = 220; | 2486 | w = 220; |
2485 | int h = bar.sizeHint().height() ; | 2487 | int h = bar.sizeHint().height() ; |
2486 | int dw = QApplication::desktop()->width(); | 2488 | int dw = QApplication::desktop()->width(); |
2487 | int dh = QApplication::desktop()->height(); | 2489 | int dh = QApplication::desktop()->height(); |
2488 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2490 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2489 | bar.show(); | 2491 | bar.show(); |
2490 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2492 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2491 | qApp->processEvents(); | 2493 | qApp->processEvents(); |
2492 | 2494 | ||
2493 | QDate bday; | 2495 | QDate bday; |
2494 | QString anni; | 2496 | QString anni; |
2495 | QString formattedbday; | 2497 | QString formattedbday; |
2496 | 2498 | ||
2497 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2499 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2498 | { | 2500 | { |
2499 | if ( ! bar.isVisible() ) | 2501 | if ( ! bar.isVisible() ) |
2500 | return; | 2502 | return; |
2501 | bar.setProgress( count++ ); | 2503 | bar.setProgress( count++ ); |
2502 | qApp->processEvents(); | 2504 | qApp->processEvents(); |
2503 | bday = (*it).birthday().date(); | 2505 | bday = (*it).birthday().date(); |
2504 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2506 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2505 | 2507 | ||
2506 | if ( bday.isValid() || !anni.isEmpty()) | 2508 | if ( bday.isValid() || !anni.isEmpty()) |
2507 | { | 2509 | { |
2508 | if (bday.isValid()) | 2510 | if (bday.isValid()) |
2509 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2511 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2510 | else | 2512 | else |
2511 | formattedbday = "NOTVALID"; | 2513 | formattedbday = "NOTVALID"; |
2512 | if (anni.isEmpty()) | 2514 | if (anni.isEmpty()) |
2513 | anni = "INVALID"; | 2515 | anni = "INVALID"; |
2514 | 2516 | ||
2515 | birthdayList.append(formattedbday); | 2517 | birthdayList.append(formattedbday); |
2516 | anniversaryList.append(anni); //should be ISODate | 2518 | anniversaryList.append(anni); //should be ISODate |
2517 | realNameList.append((*it).realName()); | 2519 | realNameList.append((*it).realName()); |
2518 | preferredEmailList.append((*it).preferredEmail()); | 2520 | preferredEmailList.append((*it).preferredEmail()); |
2519 | assembledNameList.append((*it).assembledName()); | 2521 | assembledNameList.append((*it).assembledName()); |
2520 | uidList.append((*it).uid()); | 2522 | uidList.append((*it).uid()); |
2521 | 2523 | ||
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 | //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() ); |
2523 | } | 2525 | } |
2524 | } | 2526 | } |
2525 | 2527 | ||
2526 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2528 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2527 | 2529 | ||
2528 | } | 2530 | } |
2529 | 2531 | ||
2530 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2532 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2531 | */ | 2533 | */ |
2532 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2534 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2533 | { | 2535 | { |
2534 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2536 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2535 | 2537 | ||
2536 | QString foundUid = QString::null; | 2538 | QString foundUid = QString::null; |
2537 | if ( ! uid.isEmpty() ) { | 2539 | if ( ! uid.isEmpty() ) { |
2538 | Addressee adrr = mAddressBook->findByUid( uid ); | 2540 | Addressee adrr = mAddressBook->findByUid( uid ); |
2539 | if ( !adrr.isEmpty() ) { | 2541 | if ( !adrr.isEmpty() ) { |
2540 | foundUid = uid; | 2542 | foundUid = uid; |
2541 | } | 2543 | } |
2542 | if ( email == "sendbacklist" ) { | 2544 | if ( email == "sendbacklist" ) { |
2543 | //qDebug("ssssssssssssssssssssssend "); | 2545 | //qDebug("ssssssssssssssssssssssend "); |
2544 | QStringList nameList; | 2546 | QStringList nameList; |
2545 | QStringList emailList; | 2547 | QStringList emailList; |
2546 | QStringList uidList; | 2548 | QStringList uidList; |
2547 | nameList.append(adrr.realName()); | 2549 | nameList.append(adrr.realName()); |
2548 | emailList = adrr.emails(); | 2550 | emailList = adrr.emails(); |
2549 | uidList.append( adrr.preferredEmail()); | 2551 | uidList.append( adrr.preferredEmail()); |
2550 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2552 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2551 | return; | 2553 | return; |
2552 | } | 2554 | } |
2553 | 2555 | ||
2554 | } | 2556 | } |
2555 | 2557 | ||
2556 | if ( email == "sendbacklist" ) | 2558 | if ( email == "sendbacklist" ) |
2557 | return; | 2559 | return; |
2558 | if (foundUid.isEmpty()) | 2560 | if (foundUid.isEmpty()) |
2559 | { | 2561 | { |
2560 | //find the uid of the person first | 2562 | //find the uid of the person first |
2561 | Addressee::List namelist; | 2563 | Addressee::List namelist; |
2562 | Addressee::List emaillist; | 2564 | Addressee::List emaillist; |
2563 | 2565 | ||
2564 | if (!name.isEmpty()) | 2566 | if (!name.isEmpty()) |
2565 | namelist = mAddressBook->findByName( name ); | 2567 | namelist = mAddressBook->findByName( name ); |
2566 | 2568 | ||
2567 | if (!email.isEmpty()) | 2569 | if (!email.isEmpty()) |
2568 | emaillist = mAddressBook->findByEmail( email ); | 2570 | emaillist = mAddressBook->findByEmail( email ); |
2569 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2571 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2570 | //check if we have a match in Namelist and Emaillist | 2572 | //check if we have a match in Namelist and Emaillist |
2571 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2573 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2572 | foundUid = emaillist[0].uid(); | 2574 | foundUid = emaillist[0].uid(); |
2573 | } | 2575 | } |
2574 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2576 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2575 | foundUid = namelist[0].uid(); | 2577 | foundUid = namelist[0].uid(); |
2576 | else | 2578 | else |
2577 | { | 2579 | { |
2578 | for (int i = 0; i < namelist.count(); i++) | 2580 | for (int i = 0; i < namelist.count(); i++) |
2579 | { | 2581 | { |
2580 | for (int j = 0; j < emaillist.count(); j++) | 2582 | for (int j = 0; j < emaillist.count(); j++) |
2581 | { | 2583 | { |
2582 | if (namelist[i] == emaillist[j]) | 2584 | if (namelist[i] == emaillist[j]) |
2583 | { | 2585 | { |
2584 | foundUid = namelist[i].uid(); | 2586 | foundUid = namelist[i].uid(); |
2585 | } | 2587 | } |
2586 | } | 2588 | } |
2587 | } | 2589 | } |
2588 | } | 2590 | } |
2589 | } | 2591 | } |
2590 | else | 2592 | else |
2591 | { | 2593 | { |
2592 | foundUid = uid; | 2594 | foundUid = uid; |
2593 | } | 2595 | } |
2594 | 2596 | ||
2595 | if (!foundUid.isEmpty()) | 2597 | if (!foundUid.isEmpty()) |
2596 | { | 2598 | { |
2597 | 2599 | ||
2598 | // raise Ka/Pi if it is in the background | 2600 | // raise Ka/Pi if it is in the background |
2599 | #ifndef DESKTOP_VERSION | 2601 | #ifndef DESKTOP_VERSION |
2600 | #ifndef KORG_NODCOP | 2602 | #ifndef KORG_NODCOP |
2601 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2603 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2602 | #endif | 2604 | #endif |
2603 | #endif | 2605 | #endif |
2604 | 2606 | ||
2605 | mMainWindow->showMaximized(); | 2607 | mMainWindow->showMaximized(); |
2606 | mMainWindow-> raise(); | 2608 | mMainWindow-> raise(); |
2607 | 2609 | ||
2608 | mViewManager->setSelected( "", false); | 2610 | mViewManager->setSelected( "", false); |
2609 | mViewManager->refreshView( "" ); | 2611 | mViewManager->refreshView( "" ); |
2610 | mViewManager->setSelected( foundUid, true ); | 2612 | mViewManager->setSelected( foundUid, true ); |
2611 | mViewManager->refreshView( foundUid ); | 2613 | mViewManager->refreshView( foundUid ); |
2612 | 2614 | ||
2613 | if ( !mMultipleViewsAtOnce ) | 2615 | if ( !mMultipleViewsAtOnce ) |
2614 | { | 2616 | { |
2615 | setDetailsVisible( true ); | 2617 | setDetailsVisible( true ); |
2616 | mActionDetails->setChecked(true); | 2618 | mActionDetails->setChecked(true); |
2617 | } | 2619 | } |
2618 | } | 2620 | } |
2619 | } | 2621 | } |
2620 | 2622 | ||
2621 | void KABCore::whatsnew() | 2623 | void KABCore::whatsnew() |
2622 | { | 2624 | { |
2623 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2625 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2624 | } | 2626 | } |
2625 | void KABCore::synchowto() | 2627 | void KABCore::synchowto() |
2626 | { | 2628 | { |
2627 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2629 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2628 | } | 2630 | } |
2629 | void KABCore::kdesynchowto() | 2631 | void KABCore::kdesynchowto() |
2630 | { | 2632 | { |
2631 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2633 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2632 | } | 2634 | } |
2633 | void KABCore::multisynchowto() | 2635 | void KABCore::multisynchowto() |
2634 | { | 2636 | { |
2635 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2637 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2636 | } | 2638 | } |
2637 | void KABCore::faq() | 2639 | void KABCore::faq() |
2638 | { | 2640 | { |
2639 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2641 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2640 | } | 2642 | } |
2641 | 2643 | ||
2642 | #include <libkcal/syncdefines.h> | 2644 | #include <libkcal/syncdefines.h> |
2643 | 2645 | ||
2644 | KABC::Addressee KABCore::getLastSyncAddressee() | 2646 | KABC::Addressee KABCore::getLastSyncAddressee() |
2645 | { | 2647 | { |
2646 | Addressee lse; | 2648 | Addressee lse; |
2647 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2649 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2648 | 2650 | ||
2649 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2651 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2650 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2652 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2651 | if (lse.isEmpty()) { | 2653 | if (lse.isEmpty()) { |
2652 | qDebug("Creating new last-syncAddressee "); | 2654 | qDebug("Creating new last-syncAddressee "); |
2653 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2655 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2654 | QString sum = ""; | 2656 | QString sum = ""; |
2655 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2657 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2656 | sum = "E: "; | 2658 | sum = "E: "; |
2657 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2659 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2658 | lse.setRevision( mLastAddressbookSync ); | 2660 | lse.setRevision( mLastAddressbookSync ); |
2659 | lse.setCategories( i18n("SyncEvent") ); | 2661 | lse.setCategories( i18n("SyncEvent") ); |
2660 | mAddressBook->insertAddressee( lse ); | 2662 | mAddressBook->insertAddressee( lse ); |
2661 | } | 2663 | } |
2662 | return lse; | 2664 | return lse; |
2663 | } | 2665 | } |
2664 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2666 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2665 | { | 2667 | { |
2666 | 2668 | ||
2667 | //void setZaurusId(int id); | 2669 | //void setZaurusId(int id); |
2668 | // int zaurusId() const; | 2670 | // int zaurusId() const; |
2669 | // void setZaurusUid(int id); | 2671 | // void setZaurusUid(int id); |
2670 | // int zaurusUid() const; | 2672 | // int zaurusUid() const; |
2671 | // void setZaurusStat(int id); | 2673 | // void setZaurusStat(int id); |
2672 | // int zaurusStat() const; | 2674 | // int zaurusStat() const; |
2673 | // 0 equal | 2675 | // 0 equal |
2674 | // 1 take local | 2676 | // 1 take local |
2675 | // 2 take remote | 2677 | // 2 take remote |
2676 | // 3 cancel | 2678 | // 3 cancel |
2677 | QDateTime lastSync = mLastAddressbookSync; | 2679 | QDateTime lastSync = mLastAddressbookSync; |
2678 | QDateTime localMod = local->revision(); | 2680 | QDateTime localMod = local->revision(); |
2679 | QDateTime remoteMod = remote->revision(); | 2681 | QDateTime remoteMod = remote->revision(); |
2680 | 2682 | ||
2681 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2683 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2682 | 2684 | ||
2683 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2685 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2684 | bool remCh, locCh; | 2686 | bool remCh, locCh; |
2685 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2687 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2686 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2688 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2687 | locCh = ( localMod > mLastAddressbookSync ); | 2689 | locCh = ( localMod > mLastAddressbookSync ); |
2690 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); | ||
2688 | if ( !remCh && ! locCh ) { | 2691 | if ( !remCh && ! locCh ) { |
2689 | //qDebug("both not changed "); | 2692 | //qDebug("both not changed "); |
2690 | lastSync = localMod.addDays(1); | 2693 | lastSync = localMod.addDays(1); |
2691 | if ( mode <= SYNC_PREF_ASK ) | 2694 | if ( mode <= SYNC_PREF_ASK ) |
2692 | return 0; | 2695 | return 0; |
2693 | } else { | 2696 | } else { |
2694 | if ( locCh ) { | 2697 | if ( locCh ) { |
2695 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2698 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2696 | lastSync = localMod.addDays( -1 ); | 2699 | lastSync = localMod.addDays( -1 ); |
2697 | if ( !remCh ) | 2700 | if ( !remCh ) |
2698 | remoteMod =( lastSync.addDays( -1 ) ); | 2701 | remoteMod =( lastSync.addDays( -1 ) ); |
2699 | } else { | 2702 | } else { |
2700 | //qDebug(" not loc changed "); | 2703 | //qDebug(" not loc changed "); |
2701 | lastSync = localMod.addDays( 1 ); | 2704 | lastSync = localMod.addDays( 1 ); |
2702 | if ( remCh ) { | 2705 | if ( remCh ) { |
2703 | //qDebug("rem changed "); | 2706 | //qDebug("rem changed "); |
2704 | remoteMod =( lastSync.addDays( 1 ) ); | 2707 | remoteMod =( lastSync.addDays( 1 ) ); |
2705 | } | 2708 | } |
2706 | 2709 | ||
2707 | } | 2710 | } |
2708 | } | 2711 | } |
2709 | full = true; | 2712 | full = true; |
2710 | if ( mode < SYNC_PREF_ASK ) | 2713 | if ( mode < SYNC_PREF_ASK ) |
2711 | mode = SYNC_PREF_ASK; | 2714 | mode = SYNC_PREF_ASK; |
2712 | } else { | 2715 | } else { |
2713 | if ( localMod == remoteMod ) | 2716 | if ( localMod == remoteMod ) |
2714 | return 0; | 2717 | return 0; |
2715 | 2718 | ||
2716 | } | 2719 | } |
2717 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2720 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2718 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2721 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2719 | //full = true; //debug only | 2722 | //full = true; //debug only |
2720 | if ( full ) { | 2723 | if ( full ) { |
2721 | bool equ = ( (*local) == (*remote) ); | 2724 | bool equ = ( (*local) == (*remote) ); |
2722 | if ( equ ) { | 2725 | if ( equ ) { |
2723 | //qDebug("equal "); | 2726 | //qDebug("equal "); |
2724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2727 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2725 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2728 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2726 | } | 2729 | } |
2727 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2730 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2728 | return 0; | 2731 | return 0; |
2729 | 2732 | ||
2730 | }//else //debug only | 2733 | }//else //debug only |
2731 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2734 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2732 | } | 2735 | } |
2733 | int result; | 2736 | int result; |
2734 | bool localIsNew; | 2737 | bool localIsNew; |
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() ); | 2738 | //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() ); |
2736 | 2739 | ||
2737 | if ( full && mode < SYNC_PREF_NEWEST ) | 2740 | if ( full && mode < SYNC_PREF_NEWEST ) |
2738 | mode = SYNC_PREF_ASK; | 2741 | mode = SYNC_PREF_ASK; |
2739 | 2742 | ||
2740 | switch( mode ) { | 2743 | switch( mode ) { |
2741 | case SYNC_PREF_LOCAL: | 2744 | case SYNC_PREF_LOCAL: |
2742 | if ( lastSync > remoteMod ) | 2745 | if ( lastSync > remoteMod ) |
2743 | return 1; | 2746 | return 1; |
2744 | if ( lastSync > localMod ) | 2747 | if ( lastSync > localMod ) |
2745 | return 2; | 2748 | return 2; |
2746 | return 1; | 2749 | return 1; |
2747 | break; | 2750 | break; |
2748 | case SYNC_PREF_REMOTE: | 2751 | case SYNC_PREF_REMOTE: |
2749 | if ( lastSync > remoteMod ) | 2752 | if ( lastSync > remoteMod ) |
2750 | return 1; | 2753 | return 1; |
2751 | if ( lastSync > localMod ) | 2754 | if ( lastSync > localMod ) |
2752 | return 2; | 2755 | return 2; |
2753 | return 2; | 2756 | return 2; |
2754 | break; | 2757 | break; |
2755 | case SYNC_PREF_NEWEST: | 2758 | case SYNC_PREF_NEWEST: |
2756 | if ( localMod > remoteMod ) | 2759 | if ( localMod > remoteMod ) |
2757 | return 1; | 2760 | return 1; |
2758 | else | 2761 | else |
2759 | return 2; | 2762 | return 2; |
2760 | break; | 2763 | break; |
2761 | case SYNC_PREF_ASK: | 2764 | case SYNC_PREF_ASK: |
2762 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2765 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2763 | if ( lastSync > remoteMod ) | 2766 | if ( lastSync > remoteMod ) |
2764 | return 1; | 2767 | return 1; |
2765 | if ( lastSync > localMod ) | 2768 | if ( lastSync > localMod ) { |
2766 | return 2; | 2769 | return 2; |
2770 | } | ||
2767 | localIsNew = localMod >= remoteMod; | 2771 | localIsNew = localMod >= remoteMod; |
2768 | //qDebug("conflict! ************************************** "); | 2772 | //qDebug("conflict! ************************************** "); |
2769 | { | 2773 | { |
2770 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2774 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2771 | result = acd.executeD(localIsNew); | 2775 | result = acd.executeD(localIsNew); |
2772 | return result; | 2776 | return result; |
2773 | } | 2777 | } |
2774 | break; | 2778 | break; |
2775 | case SYNC_PREF_FORCE_LOCAL: | 2779 | case SYNC_PREF_FORCE_LOCAL: |
2776 | return 1; | 2780 | return 1; |
2777 | break; | 2781 | break; |
2778 | case SYNC_PREF_FORCE_REMOTE: | 2782 | case SYNC_PREF_FORCE_REMOTE: |
2779 | return 2; | 2783 | return 2; |
2780 | break; | 2784 | break; |
2781 | 2785 | ||
2782 | default: | 2786 | default: |
2783 | // SYNC_PREF_TAKE_BOTH not implemented | 2787 | // SYNC_PREF_TAKE_BOTH not implemented |
2784 | break; | 2788 | break; |
2785 | } | 2789 | } |
2786 | return 0; | 2790 | return 0; |
2787 | } | 2791 | } |
2788 | 2792 | ||
2789 | 2793 | ||
2790 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2794 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2791 | { | 2795 | { |
2792 | bool syncOK = true; | 2796 | bool syncOK = true; |
2793 | int addedAddressee = 0; | 2797 | int addedAddressee = 0; |
2794 | int addedAddresseeR = 0; | 2798 | int addedAddresseeR = 0; |
2795 | int deletedAddresseeR = 0; | 2799 | int deletedAddresseeR = 0; |
2796 | int deletedAddresseeL = 0; | 2800 | int deletedAddresseeL = 0; |
2797 | int changedLocal = 0; | 2801 | int changedLocal = 0; |
2798 | int changedRemote = 0; | 2802 | int changedRemote = 0; |
2799 | 2803 | ||
2800 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2804 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2801 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2805 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2802 | 2806 | ||
2803 | //QPtrList<Addressee> el = local->rawAddressees(); | 2807 | //QPtrList<Addressee> el = local->rawAddressees(); |
2804 | Addressee addresseeR; | 2808 | Addressee addresseeR; |
2805 | QString uid; | 2809 | QString uid; |
2806 | int take; | 2810 | int take; |
2807 | Addressee addresseeL; | 2811 | Addressee addresseeL; |
2808 | Addressee addresseeRSync; | 2812 | Addressee addresseeRSync; |
2809 | Addressee addresseeLSync; | 2813 | Addressee addresseeLSync; |
2810 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2814 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2811 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2815 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2812 | bool fullDateRange = false; | 2816 | bool fullDateRange = false; |
2813 | local->resetTempSyncStat(); | 2817 | local->resetTempSyncStat(); |
2814 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2818 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2815 | if ( syncManager->syncWithDesktop() ) { | 2819 | if ( syncManager->syncWithDesktop() ) { |
2816 | // remote->removeSyncInfo( QString());//remove all info | 2820 | // remote->removeSyncInfo( QString());//remove all info |
2817 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2821 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2818 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2822 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2819 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2823 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2820 | } else { | 2824 | } else { |
2821 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2825 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2822 | } | 2826 | } |
2823 | } | 2827 | } |
2824 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2828 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2825 | addresseeLSync = getLastSyncAddressee(); | 2829 | addresseeLSync = getLastSyncAddressee(); |
2826 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2830 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2827 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2831 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2828 | if ( !addresseeR.isEmpty() ) { | 2832 | if ( !addresseeR.isEmpty() ) { |
2829 | addresseeRSync = addresseeR; | 2833 | addresseeRSync = addresseeR; |
2830 | remote->removeAddressee(addresseeR ); | 2834 | remote->removeAddressee(addresseeR ); |
2831 | 2835 | ||
2832 | } else { | 2836 | } else { |
2833 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2837 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2834 | addresseeRSync = addresseeLSync ; | 2838 | addresseeRSync = addresseeLSync ; |
2835 | } else { | 2839 | } else { |
2836 | //qDebug("FULLDATE 1"); | 2840 | //qDebug("FULLDATE 1"); |
2837 | fullDateRange = true; | 2841 | fullDateRange = true; |
2838 | Addressee newAdd; | 2842 | Addressee newAdd; |
2839 | addresseeRSync = newAdd; | 2843 | addresseeRSync = newAdd; |
2840 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2844 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2841 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2845 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2842 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2846 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2843 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2847 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2844 | } | 2848 | } |
2845 | } | 2849 | } |
2846 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2850 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2847 | // qDebug("FULLDATE 2"); | 2851 | // qDebug("FULLDATE 2"); |
2848 | fullDateRange = true; | 2852 | fullDateRange = true; |
2849 | } | 2853 | } |
2850 | if ( ! fullDateRange ) { | 2854 | if ( ! fullDateRange ) { |
2851 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2855 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2852 | 2856 | ||
2853 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2857 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2854 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2858 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2855 | fullDateRange = true; | 2859 | fullDateRange = true; |
2856 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2860 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2857 | } | 2861 | } |
2858 | } | 2862 | } |
2859 | // fullDateRange = true; // debug only! | 2863 | // fullDateRange = true; // debug only! |
2860 | if ( fullDateRange ) | 2864 | if ( fullDateRange ) |
2861 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2865 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2862 | else | 2866 | else |
2863 | mLastAddressbookSync = addresseeLSync.revision(); | 2867 | mLastAddressbookSync = addresseeLSync.revision(); |
2864 | // for resyncing if own file has changed | 2868 | // for resyncing if own file has changed |
2865 | // PENDING fixme later when implemented | 2869 | // PENDING fixme later when implemented |
2866 | #if 0 | 2870 | #if 0 |
2867 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2871 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2868 | mLastAddressbookSync = loadedFileVersion; | 2872 | mLastAddressbookSync = loadedFileVersion; |
2869 | qDebug("setting mLastAddressbookSync "); | 2873 | qDebug("setting mLastAddressbookSync "); |
2870 | } | 2874 | } |
2871 | #endif | 2875 | #endif |
2872 | 2876 | ||
2873 | 2877 | ||
2874 | // ********** setting filters **************** | 2878 | // ********** setting filters **************** |
2875 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); | 2879 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); |
2876 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); | 2880 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); |
2877 | 2881 | ||
2878 | //qDebug("*************************** "); | 2882 | //qDebug("*************************** "); |
2879 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2883 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2880 | QStringList er = remote->uidList(); | 2884 | QStringList er = remote->uidList(); |
2881 | Addressee inR ;//= er.first(); | 2885 | Addressee inR ;//= er.first(); |
2882 | Addressee inL; | 2886 | Addressee inL; |
2883 | 2887 | ||
2884 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2888 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2885 | 2889 | ||
2886 | int modulo = (er.count()/10)+1; | 2890 | int modulo = (er.count()/10)+1; |
2887 | int incCounter = 0; | 2891 | int incCounter = 0; |
2888 | while ( incCounter < er.count()) { | 2892 | while ( incCounter < er.count()) { |
2889 | if (syncManager->isProgressBarCanceled()) | 2893 | if (syncManager->isProgressBarCanceled()) |
2890 | return false; | 2894 | return false; |
2891 | if ( incCounter % modulo == 0 ) | 2895 | if ( incCounter % modulo == 0 ) |
2892 | syncManager->showProgressBar(incCounter); | 2896 | syncManager->showProgressBar(incCounter); |
2893 | 2897 | ||
2894 | uid = er[ incCounter ]; | 2898 | uid = er[ incCounter ]; |
2895 | bool skipIncidence = false; | 2899 | bool skipIncidence = false; |
2896 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2900 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2897 | skipIncidence = true; | 2901 | skipIncidence = true; |
2898 | QString idS,OidS; | 2902 | QString idS,OidS; |
2899 | qApp->processEvents(); | 2903 | qApp->processEvents(); |
2900 | if ( !skipIncidence ) { | 2904 | if ( !skipIncidence ) { |
2901 | inL = local->findByUid( uid ); | 2905 | inL = local->findByUid( uid ); |
2902 | inR = remote->findByUid( uid ); | 2906 | inR = remote->findByUid( uid ); |
2903 | //inL.setResource( 0 ); | 2907 | //inL.setResource( 0 ); |
2904 | //inR.setResource( 0 ); | 2908 | //inR.setResource( 0 ); |
2905 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2909 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2906 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2910 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2907 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { | 2911 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
2908 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2912 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2909 | if ( take == 3 ) | 2913 | if ( take == 3 ) |
2910 | return false; | 2914 | return false; |
2911 | if ( take == 1 ) {// take local ********************** | 2915 | if ( take == 1 ) {// take local ********************** |
2912 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2916 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2913 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2917 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2914 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2918 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2915 | local->insertAddressee( inL, false ); | 2919 | local->insertAddressee( inL, false ); |
2916 | idS = inR.externalUID(); | 2920 | idS = inR.externalUID(); |
2917 | OidS = inR.originalExternalUID(); | 2921 | OidS = inR.originalExternalUID(); |
2918 | } | 2922 | } |
2919 | else | 2923 | else |
2920 | idS = inR.IDStr(); | 2924 | idS = inR.IDStr(); |
2921 | remote->removeAddressee( inR ); | 2925 | remote->removeAddressee( inR ); |
2922 | inR = inL; | 2926 | inR = inL; |
2923 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2927 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2924 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2928 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2925 | inR.setOriginalExternalUID( OidS ); | 2929 | inR.setOriginalExternalUID( OidS ); |
2926 | inR.setExternalUID( idS ); | 2930 | inR.setExternalUID( idS ); |
2927 | if ( syncManager->syncWithDesktop() ) { | 2931 | if ( syncManager->syncWithDesktop() ) { |
2928 | inR.setIDStr("changed" ); | 2932 | inR.setIDStr("changed" ); |
2929 | } | 2933 | } |
2930 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 2934 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2931 | } else { | 2935 | } else { |
2932 | inR.setIDStr( idS ); | 2936 | inR.setIDStr( idS ); |
2933 | } | 2937 | } |
2934 | inR.setResource( 0 ); | 2938 | inR.setResource( 0 ); |
2935 | remote->insertAddressee( inR , false); | 2939 | remote->insertAddressee( inR , false); |
2936 | ++changedRemote; | 2940 | ++changedRemote; |
2937 | } else { // take == 2 take remote ********************** | 2941 | } else { // take == 2 take remote ********************** |
2938 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2942 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2939 | if ( inR.revision().date().year() < 2004 ) | 2943 | if ( inR.revision().date().year() < 2004 ) |
2940 | inR.setRevision( modifiedCalendar ); | 2944 | inR.setRevision( modifiedCalendar ); |
2941 | } | 2945 | } |
2942 | idS = inL.IDStr(); | 2946 | idS = inL.IDStr(); |
2943 | local->removeAddressee( inL ); | 2947 | local->removeAddressee( inL ); |
2944 | inL = inR; | 2948 | inL = inR; |
2945 | inL.setIDStr( idS ); | 2949 | inL.setIDStr( idS ); |
2946 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2950 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2947 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2951 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2948 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2952 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2949 | } | 2953 | } |
2950 | inL.setResource( 0 ); | 2954 | inL.setResource( 0 ); |
2951 | local->insertAddressee( inL , false ); | 2955 | local->insertAddressee( inL , false ); |
2952 | ++changedLocal; | 2956 | ++changedLocal; |
2953 | } | 2957 | } |
2954 | } | 2958 | } |
2955 | } | 2959 | } |
2956 | } else { // no conflict ********** add or delete remote | 2960 | } else { // no conflict ********** add or delete remote |
2957 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { | 2961 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { |
2958 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2962 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2959 | QString des = addresseeLSync.note(); | 2963 | QString des = addresseeLSync.note(); |
2960 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2964 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2961 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2965 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2962 | remote->insertAddressee( inR, false ); | 2966 | remote->insertAddressee( inR, false ); |
2963 | ++deletedAddresseeR; | 2967 | ++deletedAddresseeR; |
2964 | } else { | 2968 | } else { |
2965 | inR.setRevision( modifiedCalendar ); | 2969 | inR.setRevision( modifiedCalendar ); |
2966 | remote->insertAddressee( inR, false ); | 2970 | remote->insertAddressee( inR, false ); |
2967 | inL = inR; | 2971 | inL = inR; |
2968 | inL.setIDStr( ":" ); | 2972 | inL.setIDStr( ":" ); |
2969 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2973 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2970 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2974 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2971 | inL.setResource( 0 ); | 2975 | inL.setResource( 0 ); |
2972 | local->insertAddressee( inL , false); | 2976 | local->insertAddressee( inL , false); |
2973 | ++addedAddressee; | 2977 | ++addedAddressee; |
2974 | } | 2978 | } |
2975 | } else { | 2979 | } else { |
2976 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2980 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2977 | inR.setRevision( modifiedCalendar ); | 2981 | inR.setRevision( modifiedCalendar ); |
2978 | remote->insertAddressee( inR, false ); | 2982 | remote->insertAddressee( inR, false ); |
2979 | inR.setResource( 0 ); | 2983 | inR.setResource( 0 ); |
2980 | local->insertAddressee( inR, false ); | 2984 | local->insertAddressee( inR, false ); |
2981 | ++addedAddressee; | 2985 | ++addedAddressee; |
2982 | } else { | 2986 | } else { |
2983 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2987 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2984 | remote->removeAddressee( inR ); | 2988 | remote->removeAddressee( inR ); |
2985 | ++deletedAddresseeR; | 2989 | ++deletedAddresseeR; |
2986 | } | 2990 | } |
2987 | } | 2991 | } |
2988 | } | 2992 | } |
2989 | } | 2993 | } |
2990 | } | 2994 | } |
2991 | ++incCounter; | 2995 | ++incCounter; |
2992 | } | 2996 | } |
2993 | er.clear(); | 2997 | er.clear(); |
2994 | QStringList el = local->uidList(); | 2998 | QStringList el = local->uidList(); |
2995 | modulo = (el.count()/10)+1; | 2999 | modulo = (el.count()/10)+1; |
2996 | 3000 | ||
2997 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3001 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2998 | incCounter = 0; | 3002 | incCounter = 0; |
2999 | while ( incCounter < el.count()) { | 3003 | while ( incCounter < el.count()) { |
3000 | qApp->processEvents(); | 3004 | qApp->processEvents(); |
3001 | if (syncManager->isProgressBarCanceled()) | 3005 | if (syncManager->isProgressBarCanceled()) |
3002 | return false; | 3006 | return false; |
3003 | if ( incCounter % modulo == 0 ) | 3007 | if ( incCounter % modulo == 0 ) |
3004 | syncManager->showProgressBar(incCounter); | 3008 | syncManager->showProgressBar(incCounter); |
3005 | uid = el[ incCounter ]; | 3009 | uid = el[ incCounter ]; |
3006 | bool skipIncidence = false; | 3010 | bool skipIncidence = false; |
3007 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3011 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3008 | skipIncidence = true; | 3012 | skipIncidence = true; |
3009 | if ( !filterOUT.name().isEmpty() && ! filterOUT.filterAddressee( inL ) ) | 3013 | if ( ! skipIncidence ) { |
3010 | skipIncidence = true; | ||
3011 | if ( !skipIncidence ) { | ||
3012 | inL = local->findByUid( uid ); | 3014 | inL = local->findByUid( uid ); |
3015 | if ( (!filterOUT.name().isEmpty()) && (! filterOUT.filterAddressee( inL ) ) ) | ||
3016 | skipIncidence = true; | ||
3017 | } | ||
3018 | if ( !skipIncidence ) { | ||
3013 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3019 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3014 | inR = remote->findByUid( uid ); | 3020 | inR = remote->findByUid( uid ); |
3015 | if ( inR.isEmpty() ) { // no conflict ********** add or delete local | 3021 | if ( inR.isEmpty() ) { // no conflict ********** add or delete local |
3016 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3022 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3017 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3023 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3018 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3024 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3019 | local->removeAddressee( inL ); | 3025 | local->removeAddressee( inL ); |
3020 | ++deletedAddresseeL; | 3026 | ++deletedAddresseeL; |
3021 | } else { | 3027 | } else { |
3022 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3028 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3023 | inL.removeID(mCurrentSyncDevice ); | 3029 | inL.removeID(mCurrentSyncDevice ); |
3024 | ++addedAddresseeR; | 3030 | ++addedAddresseeR; |
3025 | inL.setRevision( modifiedCalendar ); | 3031 | inL.setRevision( modifiedCalendar ); |
3026 | local->insertAddressee( inL, false ); | 3032 | local->insertAddressee( inL, false ); |
3027 | inR = inL; | 3033 | inR = inL; |
3028 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3034 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3029 | inR.setResource( 0 ); | 3035 | inR.setResource( 0 ); |
3030 | remote->insertAddressee( inR, false ); | 3036 | remote->insertAddressee( inR, false ); |
3031 | } | 3037 | } |
3032 | } | 3038 | } |
3033 | } else { | 3039 | } else { |
3034 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3040 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3035 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3041 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3036 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3042 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3037 | local->removeAddressee( inL ); | 3043 | local->removeAddressee( inL ); |
3038 | ++deletedAddresseeL; | 3044 | ++deletedAddresseeL; |
3039 | } else { | 3045 | } else { |
3040 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3046 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3041 | ++addedAddresseeR; | 3047 | ++addedAddresseeR; |
3042 | inL.setRevision( modifiedCalendar ); | 3048 | inL.setRevision( modifiedCalendar ); |
3043 | local->insertAddressee( inL, false ); | 3049 | local->insertAddressee( inL, false ); |
3044 | inR = inL; | 3050 | inR = inL; |
3045 | inR.setIDStr( ":" ); | 3051 | inR.setIDStr( ":" ); |
3046 | inR.setResource( 0 ); | 3052 | inR.setResource( 0 ); |
3047 | remote->insertAddressee( inR, false ); | 3053 | remote->insertAddressee( inR, false ); |
3048 | } | 3054 | } |
3049 | } | 3055 | } |
3050 | } | 3056 | } |
3051 | } | 3057 | } |
3052 | } | 3058 | } |
3053 | } | 3059 | } |
3054 | ++incCounter; | 3060 | ++incCounter; |
3055 | } | 3061 | } |
3056 | el.clear(); | 3062 | el.clear(); |
3057 | syncManager->hideProgressBar(); | 3063 | syncManager->hideProgressBar(); |
3058 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3064 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3059 | // get rid of micro seconds | 3065 | // get rid of micro seconds |
3060 | QTime t = mLastAddressbookSync.time(); | 3066 | QTime t = mLastAddressbookSync.time(); |
3061 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3067 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3062 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3068 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3063 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3069 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3064 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3070 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3065 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3071 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3066 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3072 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3067 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3073 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3068 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3074 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3069 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3075 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3070 | addresseeRSync.setNote( "" ) ; | 3076 | addresseeRSync.setNote( "" ) ; |
3071 | addresseeLSync.setNote( "" ); | 3077 | addresseeLSync.setNote( "" ); |
3072 | 3078 | ||
3073 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3079 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3074 | remote->insertAddressee( addresseeRSync, false ); | 3080 | remote->insertAddressee( addresseeRSync, false ); |
3075 | local->insertAddressee( addresseeLSync, false ); | 3081 | local->insertAddressee( addresseeLSync, false ); |
3076 | QString mes; | 3082 | QString mes; |
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 ); | 3083 | 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 ); |
3078 | qDebug( mes ); | 3084 | qDebug( mes ); |
3079 | mes = i18n("Local addressbook changed!\n") +mes; | 3085 | mes = i18n("Local addressbook changed!\n") +mes; |
3080 | if ( syncManager->mShowSyncSummary ) { | 3086 | if ( syncManager->mShowSyncSummary ) { |
3081 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3087 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3082 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3088 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3083 | qDebug("cancelled "); | 3089 | qDebug("cancelled "); |
3084 | return false; | 3090 | return false; |
3085 | } | 3091 | } |
3086 | } | 3092 | } |
3087 | return syncOK; | 3093 | return syncOK; |
3088 | } | 3094 | } |
3089 | 3095 | ||
3090 | 3096 | ||
3091 | //this is a overwritten callbackmethods from the syncinterface | 3097 | //this is a overwritten callbackmethods from the syncinterface |
3092 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3098 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
3093 | { | 3099 | { |
3094 | 3100 | ||
3095 | //pending prepare addresseeview for output | 3101 | //pending prepare addresseeview for output |
3096 | //pending detect, if remote file has REV field. if not switch to external sync | 3102 | //pending detect, if remote file has REV field. if not switch to external sync |
3097 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3103 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3098 | if ( manager != syncManager ) | 3104 | if ( manager != syncManager ) |
3099 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3105 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3100 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3106 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3101 | 3107 | ||
3102 | AddressBook abLocal(filename,"syncContact"); | 3108 | AddressBook abLocal(filename,"syncContact"); |
3103 | bool syncOK = false; | 3109 | bool syncOK = false; |
3104 | if ( abLocal.load() ) { | 3110 | if ( abLocal.load() ) { |
3105 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3111 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3106 | bool external = false; | 3112 | bool external = false; |
3107 | bool isXML = false; | 3113 | bool isXML = false; |
3108 | if ( filename.right(4) == ".xml") { | 3114 | if ( filename.right(4) == ".xml") { |
3109 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3115 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3110 | isXML = true; | 3116 | isXML = true; |
3111 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3117 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3112 | } else { | 3118 | } else { |
3113 | external = !manager->mIsKapiFile; | 3119 | external = !manager->mIsKapiFile; |
3114 | if ( external ) { | 3120 | if ( external ) { |
3115 | qDebug("Setting vcf mode to external "); | 3121 | qDebug("Setting vcf mode to external "); |
3116 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3122 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3117 | AddressBook::Iterator it; | 3123 | AddressBook::Iterator it; |
3118 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3124 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3119 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3125 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3120 | (*it).computeCsum( mCurrentSyncDevice ); | 3126 | (*it).computeCsum( mCurrentSyncDevice ); |
3121 | } | 3127 | } |
3122 | } | 3128 | } |
3123 | } | 3129 | } |
3124 | //AddressBook::Iterator it; | 3130 | //AddressBook::Iterator it; |
3125 | //QStringList vcards; | 3131 | //QStringList vcards; |
3126 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3132 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3127 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3133 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3128 | //} | 3134 | //} |
3129 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3135 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3130 | if ( syncOK ) { | 3136 | if ( syncOK ) { |
3131 | if ( syncManager->mWriteBackFile ) | 3137 | if ( syncManager->mWriteBackFile ) |
3132 | { | 3138 | { |
3133 | if ( external ) | 3139 | if ( external ) |
3134 | abLocal.removeSyncAddressees( !isXML); | 3140 | abLocal.removeSyncAddressees( !isXML); |
3135 | qDebug("Saving remote AB "); | 3141 | qDebug("Saving remote AB "); |
3136 | if ( ! abLocal.saveAB()) | 3142 | if ( ! abLocal.saveAB()) |
3137 | qDebug("Error writing back AB to file "); | 3143 | qDebug("Error writing back AB to file "); |
3138 | if ( external ) { | 3144 | if ( external ) { |
3139 | // afterwrite processing | 3145 | // afterwrite processing |
3140 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3146 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3141 | } | 3147 | } |
3142 | } | 3148 | } |
3143 | } | 3149 | } |
3144 | setModified(); | 3150 | setModified(); |
3145 | 3151 | ||
3146 | } | 3152 | } |
3147 | abLocal.removeResources(); | 3153 | abLocal.removeResources(); |
3148 | if ( syncOK ) | 3154 | if ( syncOK ) |
3149 | mViewManager->refreshView(); | 3155 | mViewManager->refreshView(); |
3150 | return syncOK; | 3156 | return syncOK; |
3151 | 3157 | ||
3152 | } | 3158 | } |
3153 | void KABCore::removeSyncInfo( QString syncProfile) | 3159 | void KABCore::removeSyncInfo( QString syncProfile) |
3154 | { | 3160 | { |
3155 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3161 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3156 | mAddressBook->removeSyncInfo( syncProfile ); | 3162 | mAddressBook->removeSyncInfo( syncProfile ); |
3157 | setModified(); | 3163 | setModified(); |
3158 | } | 3164 | } |
3159 | 3165 | ||
3160 | 3166 | ||
3161 | //this is a overwritten callbackmethods from the syncinterface | 3167 | //this is a overwritten callbackmethods from the syncinterface |
3162 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3168 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3163 | { | 3169 | { |
3164 | if ( resource == "phone" ) | 3170 | if ( resource == "phone" ) |
3165 | return syncPhone(); | 3171 | return syncPhone(); |
3166 | disableBR( true ); | 3172 | disableBR( true ); |
3167 | if ( manager != syncManager ) | 3173 | if ( manager != syncManager ) |
3168 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3174 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3169 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3175 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3170 | 3176 | ||
3171 | AddressBook abLocal( resource,"syncContact"); | 3177 | AddressBook abLocal( resource,"syncContact"); |
3172 | bool syncOK = false; | 3178 | bool syncOK = false; |
3173 | if ( abLocal.load() ) { | 3179 | if ( abLocal.load() ) { |
3174 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3180 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3175 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3181 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3176 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3182 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3177 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3183 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3178 | if ( syncOK ) { | 3184 | if ( syncOK ) { |
3179 | if ( syncManager->mWriteBackFile ) { | 3185 | if ( syncManager->mWriteBackFile ) { |
3180 | abLocal.removeSyncAddressees( false ); | 3186 | abLocal.removeSyncAddressees( false ); |
3181 | abLocal.saveAB(); | 3187 | abLocal.saveAB(); |
3182 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3188 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3183 | } | 3189 | } |
3184 | } else | 3190 | } else |
3185 | message( i18n("Sync cancelled or failed.") ); | 3191 | message( i18n("Sync cancelled or failed.") ); |
3186 | setModified(); | 3192 | setModified(); |
3187 | } | 3193 | } |
3188 | abLocal.removeResources(); | 3194 | abLocal.removeResources(); |
3189 | if ( syncOK ) | 3195 | if ( syncOK ) |
3190 | mViewManager->refreshView(); | 3196 | mViewManager->refreshView(); |
3191 | disableBR( false ); | 3197 | disableBR( false ); |
3192 | return syncOK; | 3198 | return syncOK; |
3193 | 3199 | ||
3194 | } | 3200 | } |
3195 | void KABCore::message( QString m ) | 3201 | void KABCore::message( QString m ) |
3196 | { | 3202 | { |
3197 | topLevelWidget()->setCaption( m ); | 3203 | topLevelWidget()->setCaption( m ); |
3198 | mMessageTimer->start( 15000, true ); | 3204 | mMessageTimer->start( 15000, true ); |
3199 | } | 3205 | } |
3200 | bool KABCore::syncPhone() | 3206 | bool KABCore::syncPhone() |
3201 | { | 3207 | { |
3202 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3208 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3203 | QString fileName = getPhoneFile(); | 3209 | QString fileName = getPhoneFile(); |
3204 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3210 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3205 | message(i18n("Phone access failed!")); | 3211 | message(i18n("Phone access failed!")); |
3206 | return false; | 3212 | return false; |
3207 | } | 3213 | } |
3208 | AddressBook abLocal( fileName,"syncContact"); | 3214 | AddressBook abLocal( fileName,"syncContact"); |
3209 | bool syncOK = false; | 3215 | bool syncOK = false; |
3210 | { | 3216 | { |
3211 | abLocal.importFromFile( fileName ); | 3217 | abLocal.importFromFile( fileName ); |
3212 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3218 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3213 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3219 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3214 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3220 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3215 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3221 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3216 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3222 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3217 | if ( syncOK ) { | 3223 | if ( syncOK ) { |
3218 | if ( syncManager->mWriteBackFile ) { | 3224 | if ( syncManager->mWriteBackFile ) { |
3219 | abLocal.removeSyncAddressees( true ); | 3225 | abLocal.removeSyncAddressees( true ); |
3220 | abLocal.saveABphone( fileName ); | 3226 | abLocal.saveABphone( fileName ); |
3221 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3227 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3222 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3228 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3223 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3229 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3224 | } | 3230 | } |
3225 | } | 3231 | } |
3226 | setModified(); | 3232 | setModified(); |
3227 | } | 3233 | } |
3228 | abLocal.removeResources(); | 3234 | abLocal.removeResources(); |
3229 | if ( syncOK ) | 3235 | if ( syncOK ) |
3230 | mViewManager->refreshView(); | 3236 | mViewManager->refreshView(); |
3231 | return syncOK; | 3237 | return syncOK; |
3232 | } | 3238 | } |
3233 | void KABCore::getFile( bool success ) | 3239 | void KABCore::getFile( bool success ) |
3234 | { | 3240 | { |
3235 | if ( ! success ) { | 3241 | if ( ! success ) { |
3236 | message( i18n("Error receiving file. Nothing changed!") ); | 3242 | message( i18n("Error receiving file. Nothing changed!") ); |
3237 | return; | 3243 | return; |
3238 | } | 3244 | } |
3239 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3245 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
3240 | if ( count ) | 3246 | if ( count ) |
3241 | setModified( true ); | 3247 | setModified( true ); |
3242 | message( i18n("Pi-Sync successful!") ); | 3248 | message( i18n("Pi-Sync successful!") ); |
3243 | mViewManager->refreshView(); | 3249 | mViewManager->refreshView(); |
3244 | } | 3250 | } |
3245 | void KABCore::syncFileRequest() | 3251 | void KABCore::syncFileRequest() |
3246 | { | 3252 | { |
3247 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3253 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3248 | syncManager->slotSyncMenu( 999 ); | 3254 | syncManager->slotSyncMenu( 999 ); |
3249 | } | 3255 | } |
3250 | mAddressBook->export2File( sentSyncFile() ); | 3256 | mAddressBook->export2File( sentSyncFile() ); |
3251 | } | 3257 | } |
3252 | QString KABCore::sentSyncFile() | 3258 | QString KABCore::sentSyncFile() |
3253 | { | 3259 | { |
3254 | #ifdef DESKTOP_VERSION | 3260 | #ifdef DESKTOP_VERSION |
3255 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3261 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3256 | #else | 3262 | #else |
3257 | return QString( "/tmp/copysyncab.vcf" ); | 3263 | return QString( "/tmp/copysyncab.vcf" ); |
3258 | #endif | 3264 | #endif |
3259 | } | 3265 | } |
3260 | 3266 | ||
3261 | void KABCore::setCaptionBack() | 3267 | void KABCore::setCaptionBack() |
3262 | { | 3268 | { |
3263 | mMessageTimer->stop(); | 3269 | mMessageTimer->stop(); |
3264 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 3270 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
3265 | } | 3271 | } |
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index 2832257..519dc92 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp | |||
@@ -1,239 +1,239 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 1999 Don Sanders <dsanders@kde.org> | 3 | Copyright (c) 1999 Don Sanders <dsanders@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 | #ifdef KAB_EMBEDDED | 24 | #ifdef KAB_EMBEDDED |
25 | #include "kabprefs.h" | 25 | #include "kabprefs.h" |
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtoolbar.h> | 28 | #include <qtoolbar.h> |
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | #else //KAB_EMBEDDED | 30 | #else //KAB_EMBEDDED |
31 | #include <kedittoolbar.h> | 31 | #include <kedittoolbar.h> |
32 | #include <kkeydialog.h> | 32 | #include <kkeydialog.h> |
33 | #include <kmessagebox.h> | 33 | #include <kmessagebox.h> |
34 | #include <kstatusbar.h> | 34 | #include <kstatusbar.h> |
35 | #endif //KAB_EMBEDDED | 35 | #endif //KAB_EMBEDDED |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | 37 | ||
38 | #include "kabcore.h" | 38 | #include "kabcore.h" |
39 | #include "kaddressbookmain.h" | 39 | #include "kaddressbookmain.h" |
40 | #include "kactioncollection.h" | 40 | #include "kactioncollection.h" |
41 | 41 | ||
42 | #ifdef KAB_EMBEDDED | 42 | #ifdef KAB_EMBEDDED |
43 | KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) | 43 | KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) |
44 | #else //KAB_EMBEDDED | 44 | #else //KAB_EMBEDDED |
45 | //MOC_SKIP_BEGIN | 45 | //MOC_SKIP_BEGIN |
46 | KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) | 46 | KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) |
47 | //MOC_SKIP_END | 47 | //MOC_SKIP_END |
48 | #endif //KAB_EMBEDDED | 48 | #endif //KAB_EMBEDDED |
49 | { | 49 | { |
50 | setIcon(SmallIcon( "ka24" ) ); | 50 | setIcon(SmallIcon( "ka24" ) ); |
51 | #if 0 | 51 | #if 0 |
52 | //US for embedded systems, create the toolbar before we initiate KABCore. | 52 | //US for embedded systems, create the toolbar before we initiate KABCore. |
53 | // KABCore will fill the toolbar with menues and icons | 53 | // KABCore will fill the toolbar with menues and icons |
54 | QMainWindow::ToolBarDock tbd; | 54 | QMainWindow::ToolBarDock tbd; |
55 | tbd = Top; | 55 | tbd = Top; |
56 | iconToolBar = new QToolBar( this ); | 56 | iconToolBar = new QToolBar( this ); |
57 | addToolBar (iconToolBar , tbd ); | 57 | addToolBar (iconToolBar , tbd ); |
58 | iconToolBar->setHorizontalStretchable(true); | 58 | iconToolBar->setHorizontalStretchable(true); |
59 | //US iconToolBar->setWidth(300); | 59 | //US iconToolBar->setWidth(300); |
60 | #endif // 0 | 60 | #endif // 0 |
61 | 61 | ||
62 | mCore = new KABCore( this, true, this ); | 62 | mCore = new KABCore( this, true, this ); |
63 | 63 | ||
64 | #ifdef KAB_EMBEDDED | 64 | #ifdef KAB_EMBEDDED |
65 | setCaption( i18n( "KAddressbook/Pi" ) ); | 65 | setCaption( i18n( "KAddressbook/Pi" ) ); |
66 | #else //KAB_EMBEDDED | 66 | #else //KAB_EMBEDDED |
67 | setCaption( i18n( "Address Book Browser" ) ); | 67 | setCaption( i18n( "Address Book Browser" ) ); |
68 | #endif //KAB_EMBEDDED | 68 | #endif //KAB_EMBEDDED |
69 | 69 | ||
70 | //mCore->restoreSettings(); | 70 | //mCore->restoreSettings(); |
71 | 71 | ||
72 | initActions(); | 72 | initActions(); |
73 | 73 | ||
74 | setCentralWidget( mCore ); | 74 | setCentralWidget( mCore ); |
75 | 75 | ||
76 | //US statusBar()->show(); | 76 | //US statusBar()->show(); |
77 | 77 | ||
78 | #ifndef KAB_EMBEDDED | 78 | #ifndef KAB_EMBEDDED |
79 | setStandardToolBarMenuEnabled(true); | 79 | setStandardToolBarMenuEnabled(true); |
80 | 80 | ||
81 | createGUI( "kaddressbookui.rc", false ); | 81 | createGUI( "kaddressbookui.rc", false ); |
82 | 82 | ||
83 | 83 | ||
84 | #endif //KAB_EMBEDDED | 84 | #endif //KAB_EMBEDDED |
85 | setAutoSaveSettings(); | 85 | setAutoSaveSettings(); |
86 | qApp->processEvents(); | 86 | qApp->processEvents(); |
87 | mCore->restoreSettings(); | 87 | mCore->restoreSettings(); |
88 | } | 88 | } |
89 | 89 | ||
90 | KAddressBookMain::~KAddressBookMain() | 90 | KAddressBookMain::~KAddressBookMain() |
91 | { | 91 | { |
92 | // mCore->saveSettings(); | 92 | // mCore->saveSettings(); |
93 | } | 93 | } |
94 | 94 | ||
95 | void KAddressBookMain::showMinimized () | 95 | void KAddressBookMain::showMinimized () |
96 | { | 96 | { |
97 | QWidget::showMinimized () ; | 97 | QWidget::showMinimized () ; |
98 | } | 98 | } |
99 | void KAddressBookMain::addEmail( QString addr ) | 99 | void KAddressBookMain::addEmail( QString addr ) |
100 | { | 100 | { |
101 | mCore->addEmail( addr ); | 101 | mCore->addEmail( addr ); |
102 | } | 102 | } |
103 | 103 | ||
104 | #ifndef KAB_EMBEDDED | 104 | #ifndef KAB_EMBEDDED |
105 | ASYNC KAddressBookMain::showContactEditor( QString uid ) | 105 | ASYNC KAddressBookMain::showContactEditor( QString uid ) |
106 | { | 106 | { |
107 | mCore->editContact( uid ); | 107 | mCore->editContact( uid ); |
108 | } | 108 | } |
109 | #endif //KAB_EMBEDDED | 109 | #endif //KAB_EMBEDDED |
110 | void KAddressBookMain::newContact() | 110 | void KAddressBookMain::newContact() |
111 | { | 111 | { |
112 | mCore->newContact(); | 112 | mCore->newContact(); |
113 | } | 113 | } |
114 | 114 | ||
115 | QString KAddressBookMain::getNameByPhone( QString phone ) | 115 | QString KAddressBookMain::getNameByPhone( QString phone ) |
116 | { | 116 | { |
117 | return mCore->getNameByPhone( phone ); | 117 | return mCore->getNameByPhone( phone ); |
118 | } | 118 | } |
119 | 119 | ||
120 | void KAddressBookMain::save() | 120 | void KAddressBookMain::save() |
121 | { | 121 | { |
122 | mCore->save(); | 122 | mCore->save(); |
123 | } | 123 | } |
124 | 124 | ||
125 | void KAddressBookMain::exit() | 125 | void KAddressBookMain::exit() |
126 | { | 126 | { |
127 | close( ); | 127 | close( ); |
128 | } | 128 | } |
129 | 129 | ||
130 | void KAddressBookMain::saveProperties( KConfig* ) | 130 | void KAddressBookMain::saveProperties( KConfig* ) |
131 | { | 131 | { |
132 | } | 132 | } |
133 | 133 | ||
134 | void KAddressBookMain::readProperties( KConfig* ) | 134 | void KAddressBookMain::readProperties( KConfig* ) |
135 | { | 135 | { |
136 | } | 136 | } |
137 | 137 | ||
138 | void KAddressBookMain::initActions() | 138 | void KAddressBookMain::initActions() |
139 | { | 139 | { |
140 | #ifndef KAB_EMBEDDED | 140 | #ifndef KAB_EMBEDDED |
141 | KStdAction::quit( this, SLOT( close() ), actionCollection() ); | 141 | KStdAction::quit( this, SLOT( close() ), actionCollection() ); |
142 | KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); | 142 | KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); |
143 | #else //KAB_EMBEDDED | 143 | #else //KAB_EMBEDDED |
144 | //US: transfered the setup of the actions into KABCore | 144 | //US: transfered the setup of the actions into KABCore |
145 | #endif //KAB_EMBEDDED | 145 | #endif //KAB_EMBEDDED |
146 | 146 | ||
147 | 147 | ||
148 | } | 148 | } |
149 | 149 | ||
150 | //US new method to setup menues and toolbars on embedded systems | 150 | //US new method to setup menues and toolbars on embedded systems |
151 | #ifdef KAB_EMBEDDED | 151 | #ifdef KAB_EMBEDDED |
152 | /* | 152 | /* |
153 | QToolBar * KAddressBookMain::getIconToolBar() | 153 | QToolBar * KAddressBookMain::getIconToolBar() |
154 | { | 154 | { |
155 | return iconToolBar; | 155 | return iconToolBar; |
156 | } | 156 | } |
157 | */ | 157 | */ |
158 | 158 | ||
159 | void KAddressBookMain::createGUI() | 159 | void KAddressBookMain::createGUI() |
160 | { | 160 | { |
161 | 161 | ||
162 | 162 | ||
163 | 163 | ||
164 | } | 164 | } |
165 | #endif //KAB_EMBEDDED | 165 | #endif //KAB_EMBEDDED |
166 | 166 | ||
167 | void KAddressBookMain::configureToolbars() | 167 | void KAddressBookMain::configureToolbars() |
168 | { | 168 | { |
169 | #ifndef KAB_EMBEDDED | 169 | #ifndef KAB_EMBEDDED |
170 | saveMainWindowSettings( KGlobal::config(), "MainWindow" ); | 170 | saveMainWindowSettings( KGlobal::config(), "MainWindow" ); |
171 | 171 | ||
172 | KEditToolbar dlg( factory() ); | 172 | KEditToolbar dlg( factory() ); |
173 | connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); | 173 | connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); |
174 | 174 | ||
175 | dlg.exec(); | 175 | dlg.exec(); |
176 | #else //KAB_EMBEDDED | 176 | #else //KAB_EMBEDDED |
177 | qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); | 177 | qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); |
178 | #endif //KAB_EMBEDDED | 178 | #endif //KAB_EMBEDDED |
179 | } | 179 | } |
180 | 180 | ||
181 | void KAddressBookMain::slotNewToolbarConfig() | 181 | void KAddressBookMain::slotNewToolbarConfig() |
182 | { | 182 | { |
183 | #ifndef KAB_EMBEDDED | 183 | #ifndef KAB_EMBEDDED |
184 | applyMainWindowSettings( KGlobal::config(), "MainWindow" ); | 184 | applyMainWindowSettings( KGlobal::config(), "MainWindow" ); |
185 | #else //KAB_EMBEDDED | 185 | #else //KAB_EMBEDDED |
186 | qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); | 186 | qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); |
187 | #endif //KAB_EMBEDDED | 187 | #endif //KAB_EMBEDDED |
188 | } | 188 | } |
189 | 189 | ||
190 | void KAddressBookMain::configureKeys() | 190 | void KAddressBookMain::configureKeys() |
191 | { | 191 | { |
192 | #ifndef KAB_EMBEDDED | 192 | #ifndef KAB_EMBEDDED |
193 | KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); | 193 | KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); |
194 | #else //KAB_EMBEDDED | 194 | #else //KAB_EMBEDDED |
195 | qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); | 195 | qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); |
196 | #endif //KAB_EMBEDDED | 196 | #endif //KAB_EMBEDDED |
197 | } | 197 | } |
198 | 198 | ||
199 | void KAddressBookMain::closeEvent( QCloseEvent* ce ) | 199 | void KAddressBookMain::closeEvent( QCloseEvent* ce ) |
200 | { | 200 | { |
201 | bool mModified = mCore->modified(); | 201 | bool mModified = mCore->modified(); |
202 | bool mAskForQuit = KABPrefs::instance()->mAskForQuit; | 202 | bool mAskForQuit = KABPrefs::instance()->mAskForQuit; |
203 | 203 | ||
204 | QString mess = i18n( "Close KA/Pi?"); | 204 | QString mess = i18n( "Close KA/Pi?"); |
205 | if ( mModified == true ) | 205 | if ( mModified == true ) |
206 | mess += i18n( "\nChanges will be saved!"); | 206 | mess += i18n( "\nChanges will be saved!"); |
207 | else | 207 | else |
208 | mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); | 208 | mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); |
209 | 209 | ||
210 | bool mQuit = true; | 210 | bool mQuit = true; |
211 | 211 | ||
212 | 212 | ||
213 | if (mAskForQuit) | 213 | if (mAskForQuit) |
214 | { | 214 | { |
215 | 215 | ||
216 | int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); | 216 | int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); |
217 | if (res == 0) | 217 | if (res == 0) |
218 | mQuit = true; | 218 | mQuit = true; |
219 | else | 219 | else |
220 | mQuit = false; | 220 | mQuit = false; |
221 | } | 221 | } |
222 | 222 | ||
223 | if (mQuit == false) | 223 | if (mQuit == false) |
224 | return; | 224 | return; |
225 | 225 | ||
226 | if (mModified == true) | 226 | if (mModified == true) |
227 | { | 227 | { |
228 | save(); | 228 | save(); |
229 | mCore->saveSettings(); | 229 | mCore->saveSettings(); |
230 | KABPrefs::instance()->writeConfig(); | 230 | //KABPrefs::instance()->writeConfig(); |
231 | } | 231 | } |
232 | 232 | ||
233 | ce->accept(); | 233 | ce->accept(); |
234 | } | 234 | } |
235 | 235 | ||
236 | #ifndef KAB_EMBEDDED | 236 | #ifndef KAB_EMBEDDED |
237 | #include "kaddressbookmain.moc" | 237 | #include "kaddressbookmain.moc" |
238 | #endif //KAB_EMBEDDED | 238 | #endif //KAB_EMBEDDED |
239 | 239 | ||
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 9c3a641..4be860e 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -30,518 +30,517 @@ $Id$ | |||
30 | 30 | ||
31 | 31 | ||
32 | #ifndef KAB_EMBEDDED | 32 | #ifndef KAB_EMBEDDED |
33 | #include <libkdepim/kvcarddrag.h> | 33 | #include <libkdepim/kvcarddrag.h> |
34 | #include <kabc/vcardconverter.h> | 34 | #include <kabc/vcardconverter.h> |
35 | #include <kconfig.h> | 35 | #include <kconfig.h> |
36 | #include <kdeversion.h> | 36 | #include <kdeversion.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | #include <kmultipledrag.h> | 40 | #include <kmultipledrag.h> |
41 | #include <ktrader.h> | 41 | #include <ktrader.h> |
42 | #include <kurldrag.h> | 42 | #include <kurldrag.h> |
43 | 43 | ||
44 | #include "addresseeutil.h" | 44 | #include "addresseeutil.h" |
45 | #else //KAB_EMBEDDED | 45 | #else //KAB_EMBEDDED |
46 | #include "views/kaddressbookiconview.h" | 46 | #include "views/kaddressbookiconview.h" |
47 | #include "views/kaddressbooktableview.h" | 47 | #include "views/kaddressbooktableview.h" |
48 | #include "views/kaddressbookcardview.h" | 48 | #include "views/kaddressbookcardview.h" |
49 | #include "kaddressbookview.h" | 49 | #include "kaddressbookview.h" |
50 | 50 | ||
51 | #include <qaction.h> | 51 | #include <qaction.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
54 | #include <kconfigbase.h> | 54 | #include <kconfigbase.h> |
55 | 55 | ||
56 | #endif //KAB_EMBEDDED | 56 | #endif //KAB_EMBEDDED |
57 | 57 | ||
58 | 58 | ||
59 | #include <kdebug.h> | 59 | #include <kdebug.h> |
60 | #include <kactionclasses.h> | 60 | #include <kactionclasses.h> |
61 | 61 | ||
62 | #include <qlayout.h> | 62 | #include <qlayout.h> |
63 | #include <qapplication.h> | 63 | #include <qapplication.h> |
64 | #include <qwidgetstack.h> | 64 | #include <qwidgetstack.h> |
65 | 65 | ||
66 | #include <kabc/addressbook.h> | 66 | #include <kabc/addressbook.h> |
67 | #include "filtereditdialog.h" | 67 | #include "filtereditdialog.h" |
68 | #include "addviewdialog.h" | 68 | #include "addviewdialog.h" |
69 | #include "kabcore.h" | 69 | #include "kabcore.h" |
70 | #include "kabprefs.h" | 70 | #include "kabprefs.h" |
71 | #include "viewmanager.h" | 71 | #include "viewmanager.h" |
72 | 72 | ||
73 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) | 73 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) |
74 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) | 74 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) |
75 | { | 75 | { |
76 | initGUI(); | 76 | initGUI(); |
77 | initActions(); | 77 | initActions(); |
78 | 78 | ||
79 | mViewDict.setAutoDelete( true ); | 79 | mViewDict.setAutoDelete( true ); |
80 | 80 | ||
81 | createViewFactories(); | 81 | createViewFactories(); |
82 | } | 82 | } |
83 | 83 | ||
84 | ViewManager::~ViewManager() | 84 | ViewManager::~ViewManager() |
85 | { | 85 | { |
86 | unloadViews(); | 86 | unloadViews(); |
87 | mViewFactoryDict.clear(); | 87 | mViewFactoryDict.clear(); |
88 | } | 88 | } |
89 | void ViewManager::scrollUP() | 89 | void ViewManager::scrollUP() |
90 | { | 90 | { |
91 | if ( mActiveView ) | 91 | if ( mActiveView ) |
92 | mActiveView->scrollUP(); | 92 | mActiveView->scrollUP(); |
93 | } | 93 | } |
94 | void ViewManager::scrollDOWN() | 94 | void ViewManager::scrollDOWN() |
95 | { | 95 | { |
96 | if ( mActiveView ) | 96 | if ( mActiveView ) |
97 | mActiveView->scrollDOWN(); | 97 | mActiveView->scrollDOWN(); |
98 | } | 98 | } |
99 | void ViewManager::restoreSettings() | 99 | void ViewManager::restoreSettings() |
100 | { | 100 | { |
101 | mViewNameList = KABPrefs::instance()->mViewNames; | 101 | mViewNameList = KABPrefs::instance()->mViewNames; |
102 | QString activeViewName = KABPrefs::instance()->mCurrentView; | 102 | QString activeViewName = KABPrefs::instance()->mCurrentView; |
103 | 103 | ||
104 | mActionSelectView->setItems( mViewNameList ); | 104 | mActionSelectView->setItems( mViewNameList ); |
105 | 105 | ||
106 | // Filter | 106 | // Filter |
107 | mFilterList = Filter::restore( mCore->config(), "Filter" ); | 107 | mFilterList = Filter::restore( mCore->config(), "Filter" ); |
108 | mActionSelectFilter->setItems( filterNames() ); | 108 | mActionSelectFilter->setItems( filterNames() ); |
109 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); | 109 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); |
110 | int cw = 150; | 110 | int cw = 150; |
111 | if (QApplication::desktop()->width() == 480 ) | 111 | if (QApplication::desktop()->width() == 480 ) |
112 | cw = 0; | 112 | cw = 0; |
113 | mActionSelectFilter->setComboWidth( cw ); | 113 | mActionSelectFilter->setComboWidth( cw ); |
114 | // Tell the views to reread their config, since they may have | 114 | // Tell the views to reread their config, since they may have |
115 | // been modified by global settings | 115 | // been modified by global settings |
116 | QString _oldgroup = mCore->config()->group(); | 116 | QString _oldgroup = mCore->config()->group(); |
117 | 117 | ||
118 | QDictIterator<KAddressBookView> it( mViewDict ); | 118 | QDictIterator<KAddressBookView> it( mViewDict ); |
119 | for ( it.toFirst(); it.current(); ++it ) { | 119 | for ( it.toFirst(); it.current(); ++it ) { |
120 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 120 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
121 | it.current()->readConfig( mCore->config() ); | 121 | it.current()->readConfig( mCore->config() ); |
122 | } | 122 | } |
123 | setActiveView( activeViewName ); | 123 | setActiveView( activeViewName ); |
124 | 124 | ||
125 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 125 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
126 | } | 126 | } |
127 | 127 | ||
128 | void ViewManager::saveSettings() | 128 | void ViewManager::saveSettings() |
129 | { | 129 | { |
130 | QString _oldgroup = mCore->config()->group(); | 130 | QString _oldgroup = mCore->config()->group(); |
131 | 131 | ||
132 | QDictIterator<KAddressBookView> it( mViewDict ); | 132 | QDictIterator<KAddressBookView> it( mViewDict ); |
133 | for ( it.toFirst(); it.current(); ++it ) { | 133 | for ( it.toFirst(); it.current(); ++it ) { |
134 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 134 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
135 | #ifdef DESKTOP_VERSION | 135 | #ifdef DESKTOP_VERSION |
136 | (*it)->writeConfig( mCore->config() ); | 136 | (*it)->writeConfig( mCore->config() ); |
137 | #else | 137 | #else |
138 | (*it).writeConfig( mCore->config() ); | 138 | (*it).writeConfig( mCore->config() ); |
139 | #endif | 139 | #endif |
140 | } | 140 | } |
141 | 141 | ||
142 | Filter::save( mCore->config(), "Filter", mFilterList ); | 142 | Filter::save( mCore->config(), "Filter", mFilterList ); |
143 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); | 143 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); |
144 | 144 | ||
145 | // write the view name list | 145 | // write the view name list |
146 | KABPrefs::instance()->mViewNames = mViewNameList; | 146 | KABPrefs::instance()->mViewNames = mViewNameList; |
147 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); | 147 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); |
148 | 148 | ||
149 | } | 149 | } |
150 | 150 | ||
151 | QStringList ViewManager::selectedUids() const | 151 | QStringList ViewManager::selectedUids() const |
152 | { | 152 | { |
153 | if ( mActiveView ) | 153 | if ( mActiveView ) |
154 | return mActiveView->selectedUids(); | 154 | return mActiveView->selectedUids(); |
155 | else | 155 | else |
156 | return QStringList(); | 156 | return QStringList(); |
157 | } | 157 | } |
158 | 158 | ||
159 | QStringList ViewManager::selectedEmails() const | 159 | QStringList ViewManager::selectedEmails() const |
160 | { | 160 | { |
161 | if ( mActiveView ) | 161 | if ( mActiveView ) |
162 | return mActiveView->selectedEmails(); | 162 | return mActiveView->selectedEmails(); |
163 | else | 163 | else |
164 | return QStringList(); | 164 | return QStringList(); |
165 | } | 165 | } |
166 | 166 | ||
167 | KABC::Addressee::List ViewManager::selectedAddressees() const | 167 | KABC::Addressee::List ViewManager::selectedAddressees() const |
168 | { | 168 | { |
169 | KABC::Addressee::List list; | 169 | KABC::Addressee::List list; |
170 | if ( mActiveView ) { | 170 | if ( mActiveView ) { |
171 | QStringList uids = mActiveView->selectedUids(); | 171 | QStringList uids = mActiveView->selectedUids(); |
172 | QStringList::Iterator it; | 172 | QStringList::Iterator it; |
173 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 173 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
174 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); | 174 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); |
175 | if ( !addr.isEmpty() ) | 175 | if ( !addr.isEmpty() ) |
176 | list.append( addr ); | 176 | list.append( addr ); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | return list; | 180 | return list; |
181 | } | 181 | } |
182 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 182 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
183 | void ViewManager::setSelected() | 183 | void ViewManager::setSelected() |
184 | { | 184 | { |
185 | setSelected( QString::null, true ); | 185 | setSelected( QString::null, true ); |
186 | } | 186 | } |
187 | 187 | ||
188 | void ViewManager::setSelected( const QString &uid, bool selected ) | 188 | void ViewManager::setSelected( const QString &uid, bool selected ) |
189 | { | 189 | { |
190 | if ( mActiveView ) | 190 | if ( mActiveView ) |
191 | mActiveView->setSelected( uid, selected ); | 191 | mActiveView->setSelected( uid, selected ); |
192 | } | 192 | } |
193 | 193 | ||
194 | void ViewManager::setListSelected(QStringList list) | 194 | void ViewManager::setListSelected(QStringList list) |
195 | { | 195 | { |
196 | int i, count = list.count(); | 196 | int i, count = list.count(); |
197 | for ( i = 0; i < count;++i ) | 197 | for ( i = 0; i < count;++i ) |
198 | setSelected( list[i], true ); | 198 | setSelected( list[i], true ); |
199 | 199 | ||
200 | } | 200 | } |
201 | void ViewManager::unloadViews() | 201 | void ViewManager::unloadViews() |
202 | { | 202 | { |
203 | mViewDict.clear(); | 203 | mViewDict.clear(); |
204 | mActiveView = 0; | 204 | mActiveView = 0; |
205 | } | 205 | } |
206 | 206 | ||
207 | void ViewManager::setActiveView( const QString &name ) | 207 | void ViewManager::setActiveView( const QString &name ) |
208 | { | 208 | { |
209 | KAddressBookView *view = 0; | 209 | KAddressBookView *view = 0; |
210 | 210 | ||
211 | // Check that this isn't the same as the current active view | 211 | // Check that this isn't the same as the current active view |
212 | if ( mActiveView && ( mActiveView->caption() == name ) ) | 212 | if ( mActiveView && ( mActiveView->caption() == name ) ) |
213 | return; | 213 | return; |
214 | 214 | ||
215 | // At this point we know the view that should be active is not | 215 | // At this point we know the view that should be active is not |
216 | // currently active. We will try to find the new on in the list. If | 216 | // currently active. We will try to find the new on in the list. If |
217 | // we can't find it, it means it hasn't been instantiated, so we will | 217 | // we can't find it, it means it hasn't been instantiated, so we will |
218 | // create it on demand. | 218 | // create it on demand. |
219 | 219 | ||
220 | view = mViewDict.find( name ); | 220 | view = mViewDict.find( name ); |
221 | 221 | ||
222 | // Check if we found the view. If we didn't, then we need to create it | 222 | // Check if we found the view. If we didn't, then we need to create it |
223 | if ( view == 0 ) { | 223 | if ( view == 0 ) { |
224 | KConfig *config = mCore->config(); | 224 | KConfig *config = mCore->config(); |
225 | 225 | ||
226 | KConfigGroupSaver saver( config, name ); | 226 | KConfigGroupSaver saver( config, name ); |
227 | 227 | ||
228 | QString type = config->readEntry( "Type", "Table" ); | 228 | QString type = config->readEntry( "Type", "Table" ); |
229 | 229 | ||
230 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; | 230 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; |
231 | 231 | ||
232 | ViewFactory *factory = mViewFactoryDict.find( type ); | 232 | ViewFactory *factory = mViewFactoryDict.find( type ); |
233 | if ( factory ) | 233 | if ( factory ) |
234 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); | 234 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); |
235 | 235 | ||
236 | if ( view ) { | 236 | if ( view ) { |
237 | view->setCaption( name ); | 237 | view->setCaption( name ); |
238 | mViewDict.insert( name, view ); | 238 | mViewDict.insert( name, view ); |
239 | //US my version needs an int as second parameter to addWidget | 239 | //US my version needs an int as second parameter to addWidget |
240 | mViewWidgetStack->addWidget( view, -1 ); | 240 | mViewWidgetStack->addWidget( view, -1 ); |
241 | view->readConfig( config ); | 241 | view->readConfig( config ); |
242 | 242 | ||
243 | // The manager just relays the signals | 243 | // The manager just relays the signals |
244 | connect( view, SIGNAL( selected( const QString& ) ), | 244 | connect( view, SIGNAL( selected( const QString& ) ), |
245 | SIGNAL( selected( const QString & ) ) ); | 245 | SIGNAL( selected( const QString & ) ) ); |
246 | connect( view, SIGNAL( executed( const QString& ) ), | 246 | connect( view, SIGNAL( executed( const QString& ) ), |
247 | SIGNAL( executed( const QString& ) ) ); | 247 | SIGNAL( executed( const QString& ) ) ); |
248 | 248 | ||
249 | connect( view, SIGNAL( deleteRequest( ) ), | 249 | connect( view, SIGNAL( deleteRequest( ) ), |
250 | SIGNAL( deleteRequest( ) ) ); | 250 | SIGNAL( deleteRequest( ) ) ); |
251 | 251 | ||
252 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); | 252 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); |
253 | connect( view, SIGNAL( dropped( QDropEvent* ) ), | 253 | connect( view, SIGNAL( dropped( QDropEvent* ) ), |
254 | SLOT( dropped( QDropEvent* ) ) ); | 254 | SLOT( dropped( QDropEvent* ) ) ); |
255 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); | 255 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); |
256 | } | 256 | } |
257 | } | 257 | } |
258 | 258 | ||
259 | // If we found or created the view, raise it and refresh it | 259 | // If we found or created the view, raise it and refresh it |
260 | if ( view ) { | 260 | if ( view ) { |
261 | mActiveView = view; | 261 | mActiveView = view; |
262 | mViewWidgetStack->raiseWidget( view ); | 262 | mViewWidgetStack->raiseWidget( view ); |
263 | // Set the proper filter in the view. By setting the combo | 263 | // Set the proper filter in the view. By setting the combo |
264 | // box, the activated slot will be called, which will push | 264 | // box, the activated slot will be called, which will push |
265 | // the filter to the view and refresh it. | 265 | // the filter to the view and refresh it. |
266 | 266 | ||
267 | if ( view->defaultFilterType() == KAddressBookView::None ) { | 267 | if ( view->defaultFilterType() == KAddressBookView::None ) { |
268 | 268 | ||
269 | mActionSelectFilter->setCurrentItem( 0 ); | 269 | mActionSelectFilter->setCurrentItem( 0 ); |
270 | setActiveFilter( 0 ); | 270 | setActiveFilter( 0 ); |
271 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { | 271 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { |
272 | setActiveFilter( mActionSelectFilter->currentItem() ); | 272 | setActiveFilter( mActionSelectFilter->currentItem() ); |
273 | } else { | 273 | } else { |
274 | uint pos = filterPosition( view->defaultFilterName() ); | 274 | uint pos = filterPosition( view->defaultFilterName() ); |
275 | mActionSelectFilter->setCurrentItem( pos ); | 275 | mActionSelectFilter->setCurrentItem( pos ); |
276 | setActiveFilter( pos ); | 276 | setActiveFilter( pos ); |
277 | } | 277 | } |
278 | //US qDebug("ViewManager::setActiveView 6" ); | 278 | //US qDebug("ViewManager::setActiveView 6" ); |
279 | 279 | ||
280 | // Update the inc search widget to show the fields in the new active | 280 | // Update the inc search widget to show the fields in the new active |
281 | // view. | 281 | // view. |
282 | mCore->setSearchFields( mActiveView->fields() ); | 282 | mCore->setSearchFields( mActiveView->fields() ); |
283 | 283 | ||
284 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 284 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
285 | //US mActiveView->refresh(); | 285 | //US mActiveView->refresh(); |
286 | 286 | mCore->saveSettings(); | |
287 | } | 287 | } |
288 | else | 288 | else |
289 | { | 289 | { |
290 | qDebug("ViewManager::setActiveView: unable to find view" ); | 290 | qDebug("ViewManager::setActiveView: unable to find view" ); |
291 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; | ||
292 | } | 291 | } |
293 | } | 292 | } |
294 | 293 | ||
295 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 294 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
296 | void ViewManager::refreshView() | 295 | void ViewManager::refreshView() |
297 | { | 296 | { |
298 | refreshView( QString::null ); | 297 | refreshView( QString::null ); |
299 | } | 298 | } |
300 | 299 | ||
301 | void ViewManager::refreshView( const QString &uid ) | 300 | void ViewManager::refreshView( const QString &uid ) |
302 | { | 301 | { |
303 | if ( mActiveView ) | 302 | if ( mActiveView ) |
304 | mActiveView->refresh( uid ); | 303 | mActiveView->refresh( uid ); |
305 | } | 304 | } |
306 | 305 | ||
307 | void ViewManager::setFocusAV() | 306 | void ViewManager::setFocusAV() |
308 | { | 307 | { |
309 | if ( mActiveView ) | 308 | if ( mActiveView ) |
310 | mActiveView->setFocusAV(); | 309 | mActiveView->setFocusAV(); |
311 | } | 310 | } |
312 | void ViewManager::editView() | 311 | void ViewManager::editView() |
313 | { | 312 | { |
314 | if ( !mActiveView ) | 313 | if ( !mActiveView ) |
315 | return; | 314 | return; |
316 | 315 | ||
317 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); | 316 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); |
318 | ViewConfigureWidget *wdg = 0; | 317 | ViewConfigureWidget *wdg = 0; |
319 | ViewConfigureDialog* dlg = 0; | 318 | ViewConfigureDialog* dlg = 0; |
320 | if ( factory ) { | 319 | if ( factory ) { |
321 | // Save the filters so the dialog has the latest set | 320 | // Save the filters so the dialog has the latest set |
322 | Filter::save( mCore->config(), "Filter", mFilterList ); | 321 | Filter::save( mCore->config(), "Filter", mFilterList ); |
323 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); | 322 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); |
324 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); | 323 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); |
325 | } else { | 324 | } else { |
326 | qDebug("ViewManager::editView()::cannot find viewfactory "); | 325 | qDebug("ViewManager::editView()::cannot find viewfactory "); |
327 | return; | 326 | return; |
328 | } | 327 | } |
329 | if ( wdg ) { | 328 | if ( wdg ) { |
330 | dlg->setWidget( wdg ); | 329 | dlg->setWidget( wdg ); |
331 | 330 | ||
332 | #ifndef DESKTOP_VERSION | 331 | #ifndef DESKTOP_VERSION |
333 | //dlg.setMaximumSize( 640, 480 ); | 332 | //dlg.setMaximumSize( 640, 480 ); |
334 | //dlg->setGeometry( 40,40, 400, 300); | 333 | //dlg->setGeometry( 40,40, 400, 300); |
335 | dlg->showMaximized(); | 334 | dlg->showMaximized(); |
336 | #endif | 335 | #endif |
337 | 336 | ||
338 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); | 337 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); |
339 | 338 | ||
340 | dlg->restoreSettings( mCore->config() ); | 339 | dlg->restoreSettings( mCore->config() ); |
341 | 340 | ||
342 | if ( dlg->exec() ) { | 341 | if ( dlg->exec() ) { |
343 | dlg->saveSettings( mCore->config() ); | 342 | dlg->saveSettings( mCore->config() ); |
344 | mActiveView->readConfig( mCore->config() ); | 343 | mActiveView->readConfig( mCore->config() ); |
345 | 344 | ||
346 | // Set the proper filter in the view. By setting the combo | 345 | // Set the proper filter in the view. By setting the combo |
347 | // box, the activated slot will be called, which will push | 346 | // box, the activated slot will be called, which will push |
348 | // the filter to the view and refresh it. | 347 | // the filter to the view and refresh it. |
349 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { | 348 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { |
350 | mActionSelectFilter->setCurrentItem( 0 ); | 349 | mActionSelectFilter->setCurrentItem( 0 ); |
351 | setActiveFilter( 0 ); | 350 | setActiveFilter( 0 ); |
352 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { | 351 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { |
353 | setActiveFilter( mActionSelectFilter->currentItem() ); | 352 | setActiveFilter( mActionSelectFilter->currentItem() ); |
354 | } else { | 353 | } else { |
355 | uint pos = filterPosition( mActiveView->defaultFilterName() ); | 354 | uint pos = filterPosition( mActiveView->defaultFilterName() ); |
356 | mActionSelectFilter->setCurrentItem( pos ); | 355 | mActionSelectFilter->setCurrentItem( pos ); |
357 | setActiveFilter( pos ); | 356 | setActiveFilter( pos ); |
358 | } | 357 | } |
359 | mCore->setSearchFields( mActiveView->fields() ); | 358 | mCore->setSearchFields( mActiveView->fields() ); |
360 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 359 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
361 | //US mActiveView->refresh(); | 360 | //US mActiveView->refresh(); |
362 | 361 | ||
363 | 362 | ||
364 | //US this is a bugfix, that we get notified if we change a views configuration | 363 | //US this is a bugfix, that we get notified if we change a views configuration |
365 | emit modified(); | 364 | emit modified(); |
366 | 365 | ||
367 | } | 366 | } |
368 | 367 | ||
369 | } | 368 | } |
370 | delete dlg; | 369 | delete dlg; |
371 | } | 370 | } |
372 | 371 | ||
373 | void ViewManager::deleteView() | 372 | void ViewManager::deleteView() |
374 | { | 373 | { |
375 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) | 374 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) |
376 | .arg( mActiveView->caption() ); | 375 | .arg( mActiveView->caption() ); |
377 | QString caption = i18n( "Confirm Delete" ); | 376 | QString caption = i18n( "Confirm Delete" ); |
378 | 377 | ||
379 | 378 | ||
380 | if (QMessageBox::information( this, caption, | 379 | if (QMessageBox::information( this, caption, |
381 | text, | 380 | text, |
382 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) | 381 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) |
383 | { | 382 | { |
384 | mViewNameList.remove( mActiveView->caption() ); | 383 | mViewNameList.remove( mActiveView->caption() ); |
385 | 384 | ||
386 | // remove the view from the config file | 385 | // remove the view from the config file |
387 | KConfig *config = mCore->config(); | 386 | KConfig *config = mCore->config(); |
388 | config->deleteGroup( mActiveView->caption() ); | 387 | config->deleteGroup( mActiveView->caption() ); |
389 | 388 | ||
390 | mViewDict.remove( mActiveView->caption() ); | 389 | mViewDict.remove( mActiveView->caption() ); |
391 | mActiveView = 0; | 390 | mActiveView = 0; |
392 | 391 | ||
393 | // we are in an invalid state now, but that should be fixed after | 392 | // we are in an invalid state now, but that should be fixed after |
394 | // we emit the signal | 393 | // we emit the signal |
395 | mActionSelectView->setItems( mViewNameList ); | 394 | mActionSelectView->setItems( mViewNameList ); |
396 | if ( mViewNameList.count() > 0 ) { | 395 | if ( mViewNameList.count() > 0 ) { |
397 | mActionSelectView->setCurrentItem( 0 ); | 396 | mActionSelectView->setCurrentItem( 0 ); |
398 | setActiveView( mViewNameList[ 0 ] ); | 397 | setActiveView( mViewNameList[ 0 ] ); |
399 | } | 398 | } |
400 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 399 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
401 | } | 400 | } |
402 | } | 401 | } |
403 | 402 | ||
404 | void ViewManager::addView() | 403 | void ViewManager::addView() |
405 | { | 404 | { |
406 | AddViewDialog dialog( &mViewFactoryDict, this ); | 405 | AddViewDialog dialog( &mViewFactoryDict, this ); |
407 | 406 | ||
408 | if ( dialog.exec() ) { | 407 | if ( dialog.exec() ) { |
409 | QString newName = dialog.viewName(); | 408 | QString newName = dialog.viewName(); |
410 | QString type = dialog.viewType(); | 409 | QString type = dialog.viewType(); |
411 | 410 | ||
412 | // Check for name conflicts | 411 | // Check for name conflicts |
413 | bool firstConflict = true; | 412 | bool firstConflict = true; |
414 | int numTries = 1; | 413 | int numTries = 1; |
415 | while ( mViewNameList.contains( newName ) > 0 ) { | 414 | while ( mViewNameList.contains( newName ) > 0 ) { |
416 | if ( !firstConflict ) { | 415 | if ( !firstConflict ) { |
417 | newName = newName.left( newName.length() - 4 ); | 416 | newName = newName.left( newName.length() - 4 ); |
418 | firstConflict = false; | 417 | firstConflict = false; |
419 | } | 418 | } |
420 | 419 | ||
421 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); | 420 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); |
422 | numTries++; | 421 | numTries++; |
423 | } | 422 | } |
424 | 423 | ||
425 | // Add the new one to the list | 424 | // Add the new one to the list |
426 | mViewNameList.append( newName ); | 425 | mViewNameList.append( newName ); |
427 | 426 | ||
428 | // write the view to the config file, | 427 | // write the view to the config file, |
429 | KConfig *config = mCore->config(); | 428 | KConfig *config = mCore->config(); |
430 | 429 | ||
431 | config->deleteGroup( newName ); | 430 | config->deleteGroup( newName ); |
432 | 431 | ||
433 | KConfigGroupSaver saver( config, newName ); | 432 | KConfigGroupSaver saver( config, newName ); |
434 | 433 | ||
435 | config->writeEntry( "Type", type ); | 434 | config->writeEntry( "Type", type ); |
436 | 435 | ||
437 | // try to set the active view | 436 | // try to set the active view |
438 | mActionSelectView->setItems( mViewNameList ); | 437 | mActionSelectView->setItems( mViewNameList ); |
439 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); | 438 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); |
440 | setActiveView( newName ); | 439 | setActiveView( newName ); |
441 | 440 | ||
442 | editView(); | 441 | editView(); |
443 | 442 | ||
444 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 443 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
445 | } | 444 | } |
446 | } | 445 | } |
447 | 446 | ||
448 | void ViewManager::createViewFactories() | 447 | void ViewManager::createViewFactories() |
449 | { | 448 | { |
450 | #ifndef KAB_EMBEDDED | 449 | #ifndef KAB_EMBEDDED |
451 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); | 450 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); |
452 | KTrader::OfferList::ConstIterator it; | 451 | KTrader::OfferList::ConstIterator it; |
453 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 452 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
454 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) | 453 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) |
455 | continue; | 454 | continue; |
456 | 455 | ||
457 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); | 456 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); |
458 | 457 | ||
459 | if ( !factory ) { | 458 | if ( !factory ) { |
460 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; | 459 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; |
461 | continue; | 460 | continue; |
462 | } | 461 | } |
463 | 462 | ||
464 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); | 463 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); |
465 | 464 | ||
466 | if ( !viewFactory ) { | 465 | if ( !viewFactory ) { |
467 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; | 466 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; |
468 | continue; | 467 | continue; |
469 | } | 468 | } |
470 | 469 | ||
471 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 470 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
472 | } | 471 | } |
473 | 472 | ||
474 | #else //KAB_EMBEDDED | 473 | #else //KAB_EMBEDDED |
475 | ViewFactory* viewFactory = new IconViewFactory(); | 474 | ViewFactory* viewFactory = new IconViewFactory(); |
476 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 475 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
477 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 476 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
478 | 477 | ||
479 | viewFactory = new TableViewFactory(); | 478 | viewFactory = new TableViewFactory(); |
480 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 479 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
481 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 480 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
482 | 481 | ||
483 | viewFactory = new CardViewFactory(); | 482 | viewFactory = new CardViewFactory(); |
484 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 483 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
485 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 484 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
486 | 485 | ||
487 | #endif //KAB_EMBEDDED | 486 | #endif //KAB_EMBEDDED |
488 | 487 | ||
489 | } | 488 | } |
490 | 489 | ||
491 | void ViewManager::dropped( QDropEvent *e ) | 490 | void ViewManager::dropped( QDropEvent *e ) |
492 | { | 491 | { |
493 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; | 492 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; |
494 | 493 | ||
495 | #ifndef KAB_EMBEDDED | 494 | #ifndef KAB_EMBEDDED |
496 | 495 | ||
497 | QString clipText, vcards; | 496 | QString clipText, vcards; |
498 | KURL::List urls; | 497 | KURL::List urls; |
499 | 498 | ||
500 | if ( KURLDrag::decode( e, urls) ) { | 499 | if ( KURLDrag::decode( e, urls) ) { |
501 | KURL::List::Iterator it = urls.begin(); | 500 | KURL::List::Iterator it = urls.begin(); |
502 | int c = urls.count(); | 501 | int c = urls.count(); |
503 | if ( c > 1 ) { | 502 | if ( c > 1 ) { |
504 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); | 503 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); |
505 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { | 504 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { |
506 | for ( ; it != urls.end(); ++it ) | 505 | for ( ; it != urls.end(); ++it ) |
507 | emit urlDropped( *it ); | 506 | emit urlDropped( *it ); |
508 | } | 507 | } |
509 | } else if ( c == 1 ) | 508 | } else if ( c == 1 ) |
510 | emit urlDropped( *it ); | 509 | emit urlDropped( *it ); |
511 | } else if ( KVCardDrag::decode( e, vcards ) ) { | 510 | } else if ( KVCardDrag::decode( e, vcards ) ) { |
512 | KABC::Addressee addr; | 511 | KABC::Addressee addr; |
513 | KABC::VCardConverter converter; | 512 | KABC::VCardConverter converter; |
514 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); | 513 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); |
515 | QStringList::Iterator it; | 514 | QStringList::Iterator it; |
516 | for ( it = list.begin(); it != list.end(); ++it ) { | 515 | for ( it = list.begin(); it != list.end(); ++it ) { |
517 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { | 516 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { |
518 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); | 517 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); |
519 | if ( a.isEmpty() ) { | 518 | if ( a.isEmpty() ) { |
520 | mCore->addressBook()->insertAddressee( addr ); | 519 | mCore->addressBook()->insertAddressee( addr ); |
521 | emit modified(); | 520 | emit modified(); |
522 | } | 521 | } |
523 | } | 522 | } |
524 | } | 523 | } |
525 | 524 | ||
526 | mActiveView->refresh(); | 525 | mActiveView->refresh(); |
527 | } | 526 | } |
528 | #else //KAB_EMBEDDED | 527 | #else //KAB_EMBEDDED |
529 | qDebug("ViewManager::dropped() has to be changed!!" ); | 528 | qDebug("ViewManager::dropped() has to be changed!!" ); |
530 | #endif //KAB_EMBEDDED | 529 | #endif //KAB_EMBEDDED |
531 | 530 | ||
532 | } | 531 | } |
533 | 532 | ||
534 | void ViewManager::startDrag() | 533 | void ViewManager::startDrag() |
535 | { | 534 | { |
536 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; | 535 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; |
537 | 536 | ||
538 | #ifndef KAB_EMBEDDED | 537 | #ifndef KAB_EMBEDDED |
539 | 538 | ||
540 | // Get the list of all the selected addressees | 539 | // Get the list of all the selected addressees |
541 | KABC::Addressee::List addrList; | 540 | KABC::Addressee::List addrList; |
542 | QStringList uidList = selectedUids(); | 541 | QStringList uidList = selectedUids(); |
543 | QStringList::Iterator iter; | 542 | QStringList::Iterator iter; |
544 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) | 543 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) |
545 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); | 544 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); |
546 | 545 | ||
547 | KMultipleDrag *drag = new KMultipleDrag( this ); | 546 | KMultipleDrag *drag = new KMultipleDrag( this ); |