-rw-r--r-- | kabc/addresseeview.cpp | 66 | ||||
-rw-r--r-- | kabc/addresseeview.h | 18 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 7 |
3 files changed, 89 insertions, 2 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index b4717d7..487e8a5 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp | |||
@@ -1,401 +1,467 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | 3 | ||
4 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 4 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <kabc/address.h> | 22 | #include <kabc/address.h> |
23 | #include <kabc/addressee.h> | 23 | #include <kabc/addressee.h> |
24 | #include <kabc/phonenumber.h> | 24 | #include <kabc/phonenumber.h> |
25 | #include <kglobal.h> | 25 | #include <kglobal.h> |
26 | //US#include <kglobalsettings.h> | 26 | //US#include <kglobalsettings.h> |
27 | #include <kiconloader.h> | 27 | #include <kiconloader.h> |
28 | #include <klocale.h> | 28 | #include <klocale.h> |
29 | //US #include <kstringhandler.h> | 29 | //US #include <kstringhandler.h> |
30 | #include <qscrollview.h> | 30 | #include <qscrollview.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qvbox.h> | ||
34 | #include <qlabel.h> | ||
35 | #include <qwidget.h> | ||
36 | #include <qlayout.h> | ||
33 | #include <qapplication.h> | 37 | #include <qapplication.h> |
38 | #include <qpushbutton.h> | ||
34 | 39 | ||
35 | 40 | ||
36 | #include "externalapphandler.h" | 41 | #include "externalapphandler.h" |
37 | #include "addresseeview.h" | 42 | #include "addresseeview.h" |
38 | 43 | ||
39 | 44 | ||
40 | //US #ifndef DESKTOP_VERSION | 45 | //US #ifndef DESKTOP_VERSION |
41 | //US #include <qtopia/qcopenvelope_qws.h> | 46 | //US #include <qtopia/qcopenvelope_qws.h> |
42 | //US #include <qpe/qpeapplication.h> | 47 | //US #include <qpe/qpeapplication.h> |
43 | //US #endif | 48 | //US #endif |
44 | 49 | ||
45 | //US static int kphoneInstalled = 0; | 50 | //US static int kphoneInstalled = 0; |
46 | 51 | ||
47 | using namespace KPIM; | 52 | using namespace KPIM; |
48 | 53 | ||
49 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) | 54 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) |
50 | //US : KTextBrowser( parent, name ) | 55 | //US : KTextBrowser( parent, name ) |
51 | : QTextBrowser( parent, name ) | 56 | : QTextBrowser( parent, name ) |
52 | 57 | ||
53 | 58 | ||
54 | { | 59 | { |
55 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); | 60 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); |
56 | setLinkUnderline( false ); | 61 | setLinkUnderline( false ); |
57 | // setVScrollBarMode( QScrollView::AlwaysOff ); | 62 | // setVScrollBarMode( QScrollView::AlwaysOff ); |
58 | //setHScrollBarMode( QScrollView::AlwaysOff ); | 63 | //setHScrollBarMode( QScrollView::AlwaysOff ); |
59 | 64 | ||
60 | //US QStyleSheet *sheet = styleSheet(); | 65 | //US QStyleSheet *sheet = styleSheet(); |
61 | //US QStyleSheetItem *link = sheet->item( "a" ); | 66 | //US QStyleSheetItem *link = sheet->item( "a" ); |
62 | //US link->setColor( KGlobalSettings::linkColor() ); | 67 | //US link->setColor( KGlobalSettings::linkColor() ); |
63 | 68 | ||
64 | } | 69 | } |
65 | 70 | ||
66 | void AddresseeView::setSource(const QString& n) | 71 | void AddresseeView::setSource(const QString& n) |
67 | { | 72 | { |
68 | //qDebug("********AddresseeView::setSource %s", n.latin1()); | 73 | //qDebug("********AddresseeView::setSource %s", n.latin1()); |
69 | 74 | ||
70 | if ( n.left( 6 ) == "mailto" ) | 75 | if ( n.left( 6 ) == "mailto" ) |
71 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); | 76 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); |
72 | else if ( n.left( 7 ) == "phoneto" ) | 77 | else if ( n.left( 7 ) == "phoneto" ) |
73 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); | 78 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); |
74 | else if ( n.left( 5 ) == "faxto" ) | 79 | else if ( n.left( 5 ) == "faxto" ) |
75 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); | 80 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); |
76 | else if ( n.left( 5 ) == "smsto" ) | 81 | else if ( n.left( 5 ) == "smsto" ) |
77 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); | 82 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); |
78 | else if ( n.left( 7 ) == "pagerto" ) | 83 | else if ( n.left( 7 ) == "pagerto" ) |
79 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); | 84 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); |
80 | else if ( n.left( 5 ) == "sipto" ) | 85 | else if ( n.left( 5 ) == "sipto" ) |
81 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); | 86 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); |
82 | 87 | ||
83 | } | 88 | } |
84 | void AddresseeView::setAddressee( const KABC::Addressee& addr ) | 89 | void AddresseeView::setAddressee( const KABC::Addressee& addr ) |
85 | { | 90 | { |
86 | ExternalAppHandler* eah = ExternalAppHandler::instance(); | 91 | ExternalAppHandler* eah = ExternalAppHandler::instance(); |
87 | bool kemailAvail = eah->isEmailAppAvailable(); | 92 | bool kemailAvail = eah->isEmailAppAvailable(); |
88 | bool kphoneAvail = eah->isPhoneAppAvailable(); | 93 | bool kphoneAvail = eah->isPhoneAppAvailable(); |
89 | bool kfaxAvail = eah->isFaxAppAvailable(); | 94 | bool kfaxAvail = eah->isFaxAppAvailable(); |
90 | bool ksmsAvail = eah->isSMSAppAvailable(); | 95 | bool ksmsAvail = eah->isSMSAppAvailable(); |
91 | bool kpagerAvail = eah->isPagerAppAvailable(); | 96 | bool kpagerAvail = eah->isPagerAppAvailable(); |
92 | bool ksipAvail = eah->isSIPAppAvailable(); | 97 | bool ksipAvail = eah->isSIPAppAvailable(); |
93 | 98 | ||
94 | 99 | ||
95 | mAddressee = addr; | 100 | mAddressee = addr; |
96 | // clear view | 101 | // clear view |
97 | setText( QString::null ); | 102 | setText( QString::null ); |
98 | 103 | ||
99 | if ( mAddressee.isEmpty() ) | 104 | if ( mAddressee.isEmpty() ) |
100 | return; | 105 | return; |
101 | 106 | ||
102 | QString name = ( mAddressee.assembledName().isEmpty() ? | 107 | QString name = ( mAddressee.assembledName().isEmpty() ? |
103 | mAddressee.formattedName() : mAddressee.assembledName() ); | 108 | mAddressee.formattedName() : mAddressee.assembledName() ); |
104 | 109 | ||
105 | QString dynamicPart; | 110 | QString dynamicPart; |
106 | 111 | ||
107 | QStringList emails = mAddressee.emails(); | 112 | QStringList emails = mAddressee.emails(); |
108 | QStringList::ConstIterator emailIt; | 113 | QStringList::ConstIterator emailIt; |
109 | QString type = i18n( "Email" ); | 114 | QString type = i18n( "Email" ); |
110 | emailIt = emails.begin(); | 115 | emailIt = emails.begin(); |
111 | if ( emailIt != emails.end() ) { | 116 | if ( emailIt != emails.end() ) { |
112 | if ( kemailAvail ) { | 117 | if ( kemailAvail ) { |
113 | dynamicPart += QString( | 118 | dynamicPart += QString( |
114 | "<tr><td align=\"right\"><b>%1</b></td>" | 119 | "<tr><td align=\"right\"><b>%1</b></td>" |
115 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 120 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
116 | .arg( type ) | 121 | .arg( type ) |
117 | .arg( name ) | 122 | .arg( name ) |
118 | .arg( *emailIt ) | 123 | .arg( *emailIt ) |
119 | .arg( *emailIt ); | 124 | .arg( *emailIt ); |
120 | ++emailIt; | 125 | ++emailIt; |
121 | } else { | 126 | } else { |
122 | dynamicPart += QString( | 127 | dynamicPart += QString( |
123 | "<tr><td align=\"right\"><b>%1</b></td>" | 128 | "<tr><td align=\"right\"><b>%1</b></td>" |
124 | "<td align=\"left\">%2</td></tr>" ) | 129 | "<td align=\"left\">%2</td></tr>" ) |
125 | .arg( type ) | 130 | .arg( type ) |
126 | .arg( *emailIt ); | 131 | .arg( *emailIt ); |
127 | ++emailIt; | 132 | ++emailIt; |
128 | } | 133 | } |
129 | } | 134 | } |
130 | if ( mAddressee.birthday().date().isValid() ) { | 135 | if ( mAddressee.birthday().date().isValid() ) { |
131 | dynamicPart += QString( | 136 | dynamicPart += QString( |
132 | "<tr><td align=\"right\"><b>%1</b></td>" | 137 | "<tr><td align=\"right\"><b>%1</b></td>" |
133 | "<td align=\"left\">%2</td></tr>" ) | 138 | "<td align=\"left\">%2</td></tr>" ) |
134 | .arg( i18n ("Birthday") ) | 139 | .arg( i18n ("Birthday") ) |
135 | .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); | 140 | .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); |
136 | } | 141 | } |
137 | KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); | 142 | KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); |
138 | KABC::PhoneNumber::List::ConstIterator phoneIt; | 143 | KABC::PhoneNumber::List::ConstIterator phoneIt; |
139 | QString extension; | 144 | QString extension; |
140 | int phonetype; | 145 | int phonetype; |
141 | QString sms; | 146 | QString sms; |
142 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { | 147 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { |
143 | phonetype = (*phoneIt).type(); | 148 | phonetype = (*phoneIt).type(); |
144 | if (ksmsAvail && | 149 | if (ksmsAvail && |
145 | ( | 150 | ( |
146 | ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || | 151 | ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || |
147 | ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) | 152 | ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) |
148 | ) | 153 | ) |
149 | ) | 154 | ) |
150 | { | 155 | { |
151 | sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) | 156 | sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) |
152 | .arg( (*phoneIt).number() ); | 157 | .arg( (*phoneIt).number() ); |
153 | 158 | ||
154 | } | 159 | } |
155 | else | 160 | else |
156 | sms = ""; | 161 | sms = ""; |
157 | 162 | ||
158 | extension = QString::null; | 163 | extension = QString::null; |
159 | if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { | 164 | if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { |
160 | if (kfaxAvail) extension = "faxto:"; | 165 | if (kfaxAvail) extension = "faxto:"; |
161 | } | 166 | } |
162 | else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { | 167 | else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { |
163 | if (kpagerAvail) extension = "pagerto:"; | 168 | if (kpagerAvail) extension = "pagerto:"; |
164 | } | 169 | } |
165 | else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { | 170 | else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { |
166 | if (ksipAvail) extension = "sipto:"; | 171 | if (ksipAvail) extension = "sipto:"; |
167 | } | 172 | } |
168 | else if (kphoneAvail) { | 173 | else if (kphoneAvail) { |
169 | extension = "phoneto:"; | 174 | extension = "phoneto:"; |
170 | } | 175 | } |
171 | else | 176 | else |
172 | extension = QString::null; | 177 | extension = QString::null; |
173 | 178 | ||
174 | if ( !extension.isEmpty() ) { | 179 | if ( !extension.isEmpty() ) { |
175 | dynamicPart += QString( | 180 | dynamicPart += QString( |
176 | "<tr><td align=\"right\"><b>%1</b></td>" | 181 | "<tr><td align=\"right\"><b>%1</b></td>" |
177 | "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) | 182 | "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) |
178 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) | 183 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) |
179 | .arg( extension ) | 184 | .arg( extension ) |
180 | .arg( (*phoneIt).number() ) | 185 | .arg( (*phoneIt).number() ) |
181 | .arg( (*phoneIt).number() ) | 186 | .arg( (*phoneIt).number() ) |
182 | .arg( sms ); | 187 | .arg( sms ); |
183 | 188 | ||
184 | } else { | 189 | } else { |
185 | dynamicPart += QString( | 190 | dynamicPart += QString( |
186 | "<tr><td align=\"right\"><b>%1</b></td>" | 191 | "<tr><td align=\"right\"><b>%1</b></td>" |
187 | "<td align=\"left\">%2 %3</td></tr>" ) | 192 | "<td align=\"left\">%2 %3</td></tr>" ) |
188 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) | 193 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) |
189 | .arg( (*phoneIt).number() ) | 194 | .arg( (*phoneIt).number() ) |
190 | .arg( sms ); | 195 | .arg( sms ); |
191 | } | 196 | } |
192 | } | 197 | } |
193 | 198 | ||
194 | 199 | ||
195 | for ( ; emailIt != emails.end(); ++emailIt ) { | 200 | for ( ; emailIt != emails.end(); ++emailIt ) { |
196 | if ( kemailAvail ) { | 201 | if ( kemailAvail ) { |
197 | dynamicPart += QString( | 202 | dynamicPart += QString( |
198 | "<tr><td align=\"right\"><b>%1</b></td>" | 203 | "<tr><td align=\"right\"><b>%1</b></td>" |
199 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 204 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
200 | .arg( type ) | 205 | .arg( type ) |
201 | .arg( name ) | 206 | .arg( name ) |
202 | .arg( *emailIt ) | 207 | .arg( *emailIt ) |
203 | .arg( *emailIt ); | 208 | .arg( *emailIt ); |
204 | } else { | 209 | } else { |
205 | dynamicPart += QString( | 210 | dynamicPart += QString( |
206 | "<tr><td align=\"right\"><b>%1</b></td>" | 211 | "<tr><td align=\"right\"><b>%1</b></td>" |
207 | "<td align=\"left\">%2</td></tr>" ) | 212 | "<td align=\"left\">%2</td></tr>" ) |
208 | .arg( type ) | 213 | .arg( type ) |
209 | .arg( *emailIt ); | 214 | .arg( *emailIt ); |
210 | } | 215 | } |
211 | } | 216 | } |
212 | 217 | ||
213 | if ( !mAddressee.url().url().isEmpty() ) { | 218 | if ( !mAddressee.url().url().isEmpty() ) { |
214 | dynamicPart += QString( | 219 | dynamicPart += QString( |
215 | "<tr><td align=\"right\"><b>%1</b></td>" | 220 | "<tr><td align=\"right\"><b>%1</b></td>" |
216 | "<td align=\"left\">%2</td></tr>" ) | 221 | "<td align=\"left\">%2</td></tr>" ) |
217 | .arg( i18n( "Homepage" ) ) | 222 | .arg( i18n( "Homepage" ) ) |
218 | //US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); | 223 | //US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); |
219 | .arg( mAddressee.url().url() ); | 224 | .arg( mAddressee.url().url() ); |
220 | //qDebug("AddresseeView::setAddressee has to be verified."); | 225 | //qDebug("AddresseeView::setAddressee has to be verified."); |
221 | } | 226 | } |
222 | 227 | ||
223 | KABC::Address::List addresses = mAddressee.addresses(); | 228 | KABC::Address::List addresses = mAddressee.addresses(); |
224 | KABC::Address::List::ConstIterator addrIt; | 229 | KABC::Address::List::ConstIterator addrIt; |
225 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { | 230 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { |
226 | if ( true /*(*addrIt).label().isEmpty()*/ ) { | 231 | if ( true /*(*addrIt).label().isEmpty()*/ ) { |
227 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); | 232 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); |
228 | //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); | 233 | //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); |
229 | //qDebug("adresss %s ",formattedAddress.latin1() ); | 234 | //qDebug("adresss %s ",formattedAddress.latin1() ); |
230 | formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); | 235 | formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); |
231 | //qDebug("AddresseeView::setAddressee has to be verified."); | 236 | //qDebug("AddresseeView::setAddressee has to be verified."); |
232 | 237 | ||
233 | dynamicPart += QString( | 238 | dynamicPart += QString( |
234 | "<tr><td align=\"right\"><b>%1</b></td>" | 239 | "<tr><td align=\"right\"><b>%1</b></td>" |
235 | "<td align=\"left\">%2</td></tr>" ) | 240 | "<td align=\"left\">%2</td></tr>" ) |
236 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) | 241 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) |
237 | .arg( formattedAddress ); | 242 | .arg( formattedAddress ); |
238 | } else { | 243 | } else { |
239 | 244 | ||
240 | dynamicPart += QString( | 245 | dynamicPart += QString( |
241 | "<tr><td align=\"right\"><b>%1</b></td>" | 246 | "<tr><td align=\"right\"><b>%1</b></td>" |
242 | "<td align=\"left\">%2</td></tr>" ) | 247 | "<td align=\"left\">%2</td></tr>" ) |
243 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) | 248 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) |
244 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); | 249 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); |
245 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); | 250 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); |
246 | 251 | ||
247 | } | 252 | } |
248 | } | 253 | } |
249 | 254 | ||
250 | QString notes; | 255 | QString notes; |
251 | if ( !mAddressee.note().isEmpty() ) { | 256 | if ( !mAddressee.note().isEmpty() ) { |
252 | notes = QString( | 257 | notes = QString( |
253 | "<tr>" | 258 | "<tr>" |
254 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label | 259 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label |
255 | "<td align=\"left\">%2</td>" // note | 260 | "<td align=\"left\">%2</td>" // note |
256 | "</tr>" ).arg( i18n( "Notes" ) ) | 261 | "</tr>" ).arg( i18n( "Notes" ) ) |
257 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); | 262 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); |
258 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); | 263 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); |
259 | //qDebug("AddresseeView::setAddressee has to be verified."); | 264 | //qDebug("AddresseeView::setAddressee has to be verified."); |
260 | } | 265 | } |
261 | 266 | ||
262 | QString aRole = ""; | 267 | QString aRole = ""; |
263 | QString aOrga = ""; | 268 | QString aOrga = ""; |
264 | if ( true /*!mAddressee.role().isEmpty()*/ ) { | 269 | if ( true /*!mAddressee.role().isEmpty()*/ ) { |
265 | aRole = "<tr>" | 270 | aRole = "<tr>" |
266 | "<td align=\"left\">" + mAddressee.role() + "</td>" | 271 | "<td align=\"left\">" + mAddressee.role() + "</td>" |
267 | "</tr>"; | 272 | "</tr>"; |
268 | } | 273 | } |
269 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { | 274 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { |
270 | aOrga = "<tr>" | 275 | aOrga = "<tr>" |
271 | "<td align=\"left\">" + mAddressee.organization() + "</td>" ; | 276 | "<td align=\"left\">" + mAddressee.organization() + "</td>" ; |
272 | "</tr>"; | 277 | "</tr>"; |
273 | } | 278 | } |
274 | mText = ""; | 279 | mText = ""; |
275 | QString picString = ""; | 280 | QString picString = ""; |
276 | KABC::Picture picture = mAddressee.photo(); | 281 | KABC::Picture picture = mAddressee.photo(); |
277 | bool picAvailintern = false; | 282 | bool picAvailintern = false; |
278 | bool picAvailUrl = false; | 283 | bool picAvailUrl = false; |
279 | if (! picture.undefined() ) { | 284 | if (! picture.undefined() ) { |
280 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); | 285 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); |
281 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); | 286 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); |
282 | } | 287 | } |
283 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { | 288 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { |
284 | if ( picAvailintern ) { | 289 | if ( picAvailintern ) { |
285 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); | 290 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); |
286 | } else { | 291 | } else { |
287 | if ( picAvailUrl ) { | 292 | if ( picAvailUrl ) { |
288 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); | 293 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); |
289 | } else { | 294 | } else { |
290 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); | 295 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); |
291 | } | 296 | } |
292 | } | 297 | } |
293 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; | 298 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; |
294 | mText = QString::fromLatin1( | 299 | mText = QString::fromLatin1( |
295 | "<html>" | 300 | "<html>" |
296 | "<body text=\"%1\" bgcolor=\"%2\">" // text and background color | 301 | "<body text=\"%1\" bgcolor=\"%2\">" // text and background color |
297 | "<table>" | 302 | "<table>" |
298 | "<tr>" | 303 | "<tr>" |
299 | "<td rowspan=\"3\" align=\"right\" valign=\"top\">" | 304 | "<td rowspan=\"3\" align=\"right\" valign=\"top\">" |
300 | "%3" | 305 | "%3" |
301 | "</td>" | 306 | "</td>" |
302 | "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name | 307 | "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name |
303 | "</tr>" | 308 | "</tr>" |
304 | "%5" // role | 309 | "%5" // role |
305 | "%6" // organization | 310 | "%6" // organization |
306 | "<td colspan=\"2\"> </td>" | 311 | "<td colspan=\"2\"> </td>" |
307 | "%7" // dynamic part | 312 | "%7" // dynamic part |
308 | "%8" // notes | 313 | "%8" // notes |
309 | "</table>" | 314 | "</table>" |
310 | "</body>" | 315 | "</body>" |
311 | "</html>") | 316 | "</html>") |
312 | //US | 317 | //US |
313 | .arg( /*KGlobalSettings::textColor().name()*/ "black" ) | 318 | .arg( /*KGlobalSettings::textColor().name()*/ "black" ) |
314 | //US | 319 | //US |
315 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) | 320 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) |
316 | .arg( picString ) | 321 | .arg( picString ) |
317 | .arg( name ) | 322 | .arg( name ) |
318 | .arg( aRole ) | 323 | .arg( aRole ) |
319 | .arg( aOrga ) | 324 | .arg( aOrga ) |
320 | .arg( dynamicPart ) | 325 | .arg( dynamicPart ) |
321 | .arg( notes ); | 326 | .arg( notes ); |
322 | 327 | ||
323 | } else { // no picture! | 328 | } else { // no picture! |
324 | 329 | ||
325 | mText = "<table width=\"100%\">\n"; | 330 | mText = "<table width=\"100%\">\n"; |
326 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 331 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
327 | #ifdef DESKTOP_VERSION | 332 | #ifdef DESKTOP_VERSION |
328 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; | 333 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; |
329 | #else | 334 | #else |
330 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>"; | 335 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>"; |
331 | #endif | 336 | #endif |
332 | 337 | ||
333 | #ifdef DESKTOP_VERSION | 338 | #ifdef DESKTOP_VERSION |
334 | mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>"; | 339 | mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>"; |
335 | #else | 340 | #else |
336 | mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>"; | 341 | mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>"; |
337 | #endif | 342 | #endif |
338 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 343 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
339 | 344 | ||
340 | mText += "<table><td colspan=\"2\"> </td>"; | 345 | mText += "<table><td colspan=\"2\"> </td>"; |
341 | /* | 346 | /* |
342 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" | 347 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" |
343 | "<td align=\"left\"><b>%2</b></td></tr>" ) | 348 | "<td align=\"left\"><b>%2</b></td></tr>" ) |
344 | .arg( i18n(" ") ) | 349 | .arg( i18n(" ") ) |
345 | .arg( name ); | 350 | .arg( name ); |
346 | */ | 351 | */ |
347 | if ( ! mAddressee.role().isEmpty() ) | 352 | if ( ! mAddressee.role().isEmpty() ) |
348 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 353 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
349 | "<td align=\"left\">%2</td></tr>" ) | 354 | "<td align=\"left\">%2</td></tr>" ) |
350 | .arg( i18n(" ") ) | 355 | .arg( i18n(" ") ) |
351 | .arg( mAddressee.role()); | 356 | .arg( mAddressee.role()); |
352 | if ( ! mAddressee.organization().isEmpty() ) | 357 | if ( ! mAddressee.organization().isEmpty() ) |
353 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 358 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
354 | "<td align=\"left\">%2</td></tr>" ) | 359 | "<td align=\"left\">%2</td></tr>" ) |
355 | .arg( i18n(" ") ) | 360 | .arg( i18n(" ") ) |
356 | .arg( mAddressee.organization()); | 361 | .arg( mAddressee.organization()); |
357 | mText += dynamicPart; | 362 | mText += dynamicPart; |
358 | mText += notes; | 363 | mText += notes; |
359 | mText += "</table>"; | 364 | mText += "</table>"; |
360 | 365 | ||
361 | } | 366 | } |
362 | 367 | ||
363 | // at last display it... | 368 | // at last display it... |
364 | setText( mText ); | 369 | setText( mText ); |
365 | 370 | ||
366 | } | 371 | } |
367 | 372 | ||
368 | KABC::Addressee AddresseeView::addressee() const | 373 | KABC::Addressee AddresseeView::addressee() const |
369 | { | 374 | { |
370 | return mAddressee; | 375 | return mAddressee; |
371 | } | 376 | } |
372 | void AddresseeView::addTag(const QString & tag,const QString & text) | 377 | void AddresseeView::addTag(const QString & tag,const QString & text) |
373 | { | 378 | { |
374 | if ( text.isEmpty() ) | 379 | if ( text.isEmpty() ) |
375 | return; | 380 | return; |
376 | int number=text.contains("\n"); | 381 | int number=text.contains("\n"); |
377 | QString str = "<" + tag + ">"; | 382 | QString str = "<" + tag + ">"; |
378 | QString tmpText=text; | 383 | QString tmpText=text; |
379 | QString tmpStr=str; | 384 | QString tmpStr=str; |
380 | if(number !=-1) | 385 | if(number !=-1) |
381 | { | 386 | { |
382 | if (number > 0) { | 387 | if (number > 0) { |
383 | int pos=0; | 388 | int pos=0; |
384 | QString tmp; | 389 | QString tmp; |
385 | for(int i=0;i<=number;i++) { | 390 | for(int i=0;i<=number;i++) { |
386 | pos=tmpText.find("\n"); | 391 | pos=tmpText.find("\n"); |
387 | tmp=tmpText.left(pos); | 392 | tmp=tmpText.left(pos); |
388 | tmpText=tmpText.right(tmpText.length()-pos-1); | 393 | tmpText=tmpText.right(tmpText.length()-pos-1); |
389 | tmpStr+=tmp+"<br>"; | 394 | tmpStr+=tmp+"<br>"; |
390 | } | 395 | } |
391 | } | 396 | } |
392 | else tmpStr += tmpText; | 397 | else tmpStr += tmpText; |
393 | tmpStr+="</" + tag + ">"; | 398 | tmpStr+="</" + tag + ">"; |
394 | mText.append(tmpStr); | 399 | mText.append(tmpStr); |
395 | } | 400 | } |
396 | else | 401 | else |
397 | { | 402 | { |
398 | str += text + "</" + tag + ">"; | 403 | str += text + "</" + tag + ">"; |
399 | mText.append(str); | 404 | mText.append(str); |
400 | } | 405 | } |
401 | } | 406 | } |
407 | |||
408 | AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, | ||
409 | true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) | ||
410 | { | ||
411 | findButton( Close )->setText( i18n("Cancel Sync")); | ||
412 | findButton( Ok )->setText( i18n("Remote")); | ||
413 | findButton( User1 )->setText( i18n("Local")); | ||
414 | QWidget* topframe = new QWidget( this ); | ||
415 | //QVBox* topframe = new QVBox( this ); | ||
416 | setMainWidget( topframe ); | ||
417 | QBoxLayout* bl; | ||
418 | if ( QApplication::desktop()->width() < 640 ) { | ||
419 | bl = new QVBoxLayout( topframe ); | ||
420 | |||
421 | } else { | ||
422 | bl = new QHBoxLayout( topframe ); | ||
423 | |||
424 | } | ||
425 | QVBox* subframe = new QVBox( topframe ); | ||
426 | bl->addWidget(subframe ); | ||
427 | QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); | ||
428 | AddresseeView * av = new AddresseeView( subframe ); | ||
429 | av->setAddressee( loc ); | ||
430 | subframe = new QVBox( topframe ); | ||
431 | bl->addWidget(subframe ); | ||
432 | lab = new QLabel( i18n("Remote Addressee"), subframe ); | ||
433 | av = new AddresseeView( subframe ); | ||
434 | av->setAddressee( rem ); | ||
435 | |||
436 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), | ||
437 | SLOT(slot_remote())); | ||
438 | QObject::connect(this,SIGNAL(user1Clicked()), | ||
439 | SLOT(slot_local())); | ||
440 | #ifndef DESKTOP_VERSION | ||
441 | showMaximized(); | ||
442 | #else | ||
443 | resize ( 640, 400 ); | ||
444 | #endif | ||
445 | } | ||
446 | |||
447 | int AddresseeChooser::executeD( bool local ) | ||
448 | { | ||
449 | mSyncResult = 3; | ||
450 | if ( local ) | ||
451 | findButton( User1 )->setFocus(); | ||
452 | else | ||
453 | findButton( Ok )->setFocus(); | ||
454 | exec(); | ||
455 | qDebug("returning %d ",mSyncResult ); | ||
456 | return mSyncResult; | ||
457 | } | ||
458 | void AddresseeChooser::slot_remote() | ||
459 | { | ||
460 | mSyncResult = 2; | ||
461 | accept(); | ||
462 | } | ||
463 | void AddresseeChooser::slot_local() | ||
464 | { | ||
465 | mSyncResult = 1; | ||
466 | accept(); | ||
467 | } | ||
diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h index 1865fc4..689d997 100644 --- a/kabc/addresseeview.h +++ b/kabc/addresseeview.h | |||
@@ -1,60 +1,78 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | 3 | ||
4 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 4 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef KPIM_ADDRESSEEVIEW_H | 22 | #ifndef KPIM_ADDRESSEEVIEW_H |
23 | #define KPIM_ADDRESSEEVIEW_H | 23 | #define KPIM_ADDRESSEEVIEW_H |
24 | 24 | ||
25 | #include <kabc/addressee.h> | 25 | #include <kabc/addressee.h> |
26 | #include <kdialogbase.h> | ||
26 | 27 | ||
27 | //US #include <ktextbrowser.h> | 28 | //US #include <ktextbrowser.h> |
28 | #include <qtextbrowser.h> | 29 | #include <qtextbrowser.h> |
29 | 30 | ||
30 | namespace KPIM { | 31 | namespace KPIM { |
31 | 32 | ||
32 | //US class AddresseeView : public KTextBrowser | 33 | //US class AddresseeView : public KTextBrowser |
33 | class AddresseeView : public QTextBrowser | 34 | class AddresseeView : public QTextBrowser |
34 | { | 35 | { |
35 | public: | 36 | public: |
36 | AddresseeView( QWidget *parent = 0, const char *name = 0 ); | 37 | AddresseeView( QWidget *parent = 0, const char *name = 0 ); |
37 | 38 | ||
38 | /** | 39 | /** |
39 | Sets the addressee object. The addressee is displayed immediately. | 40 | Sets the addressee object. The addressee is displayed immediately. |
40 | 41 | ||
41 | @param addr The addressee object. | 42 | @param addr The addressee object. |
42 | */ | 43 | */ |
43 | void setAddressee( const KABC::Addressee& addr ); | 44 | void setAddressee( const KABC::Addressee& addr ); |
44 | void setSource(const QString& n); | 45 | void setSource(const QString& n); |
45 | /** | 46 | /** |
46 | Returns the current addressee object. | 47 | Returns the current addressee object. |
47 | */ | 48 | */ |
48 | KABC::Addressee addressee() const; | 49 | KABC::Addressee addressee() const; |
49 | 50 | ||
50 | private: | 51 | private: |
51 | KABC::Addressee mAddressee; | 52 | KABC::Addressee mAddressee; |
52 | QString mText; | 53 | QString mText; |
53 | void addTag(const QString & tag,const QString & text); | 54 | void addTag(const QString & tag,const QString & text); |
54 | class AddresseeViewPrivate; | 55 | class AddresseeViewPrivate; |
55 | AddresseeViewPrivate *d; | 56 | AddresseeViewPrivate *d; |
56 | }; | 57 | }; |
58 | class AddresseeChooser : public KDialogBase | ||
59 | { | ||
60 | Q_OBJECT | ||
61 | |||
62 | public: | ||
63 | AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 ); | ||
64 | |||
65 | int executeD( bool local ); | ||
66 | |||
67 | private: | ||
68 | int mSyncResult; | ||
69 | |||
70 | private slots: | ||
71 | void slot_remote(); | ||
72 | void slot_local(); | ||
73 | |||
74 | }; | ||
57 | 75 | ||
58 | } | 76 | } |
59 | 77 | ||
60 | #endif | 78 | #endif |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 74c10d2..b1a951c 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1631,1379 +1631,1382 @@ void KABCore::initActions() | |||
1631 | // edit menu | 1631 | // edit menu |
1632 | if ( mIsPart ) { | 1632 | if ( mIsPart ) { |
1633 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1633 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1634 | SLOT( copyContacts() ), actionCollection(), | 1634 | SLOT( copyContacts() ), actionCollection(), |
1635 | "kaddressbook_copy" ); | 1635 | "kaddressbook_copy" ); |
1636 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1636 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1637 | SLOT( cutContacts() ), actionCollection(), | 1637 | SLOT( cutContacts() ), actionCollection(), |
1638 | "kaddressbook_cut" ); | 1638 | "kaddressbook_cut" ); |
1639 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1639 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1640 | SLOT( pasteContacts() ), actionCollection(), | 1640 | SLOT( pasteContacts() ), actionCollection(), |
1641 | "kaddressbook_paste" ); | 1641 | "kaddressbook_paste" ); |
1642 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1642 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1643 | SLOT( selectAllContacts() ), actionCollection(), | 1643 | SLOT( selectAllContacts() ), actionCollection(), |
1644 | "kaddressbook_select_all" ); | 1644 | "kaddressbook_select_all" ); |
1645 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1645 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1646 | SLOT( undo() ), actionCollection(), | 1646 | SLOT( undo() ), actionCollection(), |
1647 | "kaddressbook_undo" ); | 1647 | "kaddressbook_undo" ); |
1648 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1648 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1649 | this, SLOT( redo() ), actionCollection(), | 1649 | this, SLOT( redo() ), actionCollection(), |
1650 | "kaddressbook_redo" ); | 1650 | "kaddressbook_redo" ); |
1651 | } else { | 1651 | } else { |
1652 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1652 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1653 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1653 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1654 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1654 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1655 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1655 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1656 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1656 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1657 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1657 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1658 | } | 1658 | } |
1659 | 1659 | ||
1660 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1660 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1661 | Key_Delete, this, SLOT( deleteContacts() ), | 1661 | Key_Delete, this, SLOT( deleteContacts() ), |
1662 | actionCollection(), "edit_delete" ); | 1662 | actionCollection(), "edit_delete" ); |
1663 | 1663 | ||
1664 | mActionUndo->setEnabled( false ); | 1664 | mActionUndo->setEnabled( false ); |
1665 | mActionRedo->setEnabled( false ); | 1665 | mActionRedo->setEnabled( false ); |
1666 | 1666 | ||
1667 | // settings menu | 1667 | // settings menu |
1668 | #ifdef KAB_EMBEDDED | 1668 | #ifdef KAB_EMBEDDED |
1669 | //US special menuentry to configure the addressbook resources. On KDE | 1669 | //US special menuentry to configure the addressbook resources. On KDE |
1670 | // you do that through the control center !!! | 1670 | // you do that through the control center !!! |
1671 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1671 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1672 | SLOT( configureResources() ), actionCollection(), | 1672 | SLOT( configureResources() ), actionCollection(), |
1673 | "kaddressbook_configure_resources" ); | 1673 | "kaddressbook_configure_resources" ); |
1674 | #endif //KAB_EMBEDDED | 1674 | #endif //KAB_EMBEDDED |
1675 | 1675 | ||
1676 | if ( mIsPart ) { | 1676 | if ( mIsPart ) { |
1677 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1677 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1678 | SLOT( openConfigDialog() ), actionCollection(), | 1678 | SLOT( openConfigDialog() ), actionCollection(), |
1679 | "kaddressbook_configure" ); | 1679 | "kaddressbook_configure" ); |
1680 | 1680 | ||
1681 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1681 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1682 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1682 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1683 | "kaddressbook_configure_shortcuts" ); | 1683 | "kaddressbook_configure_shortcuts" ); |
1684 | #ifdef KAB_EMBEDDED | 1684 | #ifdef KAB_EMBEDDED |
1685 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1685 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1686 | mActionConfigureToolbars->setEnabled( false ); | 1686 | mActionConfigureToolbars->setEnabled( false ); |
1687 | #endif //KAB_EMBEDDED | 1687 | #endif //KAB_EMBEDDED |
1688 | 1688 | ||
1689 | } else { | 1689 | } else { |
1690 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1690 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1691 | 1691 | ||
1692 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1692 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1693 | } | 1693 | } |
1694 | 1694 | ||
1695 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1695 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1696 | actionCollection(), "options_show_jump_bar" ); | 1696 | actionCollection(), "options_show_jump_bar" ); |
1697 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1697 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1698 | 1698 | ||
1699 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1699 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1700 | actionCollection(), "options_show_details" ); | 1700 | actionCollection(), "options_show_details" ); |
1701 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1701 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1702 | 1702 | ||
1703 | // misc | 1703 | // misc |
1704 | // only enable LDAP lookup if we can handle the protocol | 1704 | // only enable LDAP lookup if we can handle the protocol |
1705 | #ifndef KAB_EMBEDDED | 1705 | #ifndef KAB_EMBEDDED |
1706 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1706 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1707 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1707 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1708 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1708 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1709 | "ldap_lookup" ); | 1709 | "ldap_lookup" ); |
1710 | } | 1710 | } |
1711 | #else //KAB_EMBEDDED | 1711 | #else //KAB_EMBEDDED |
1712 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1712 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1713 | #endif //KAB_EMBEDDED | 1713 | #endif //KAB_EMBEDDED |
1714 | 1714 | ||
1715 | 1715 | ||
1716 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1716 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1717 | SLOT( setWhoAmI() ), actionCollection(), | 1717 | SLOT( setWhoAmI() ), actionCollection(), |
1718 | "set_personal" ); | 1718 | "set_personal" ); |
1719 | 1719 | ||
1720 | 1720 | ||
1721 | 1721 | ||
1722 | 1722 | ||
1723 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1723 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1724 | SLOT( setCategories() ), actionCollection(), | 1724 | SLOT( setCategories() ), actionCollection(), |
1725 | "edit_set_categories" ); | 1725 | "edit_set_categories" ); |
1726 | 1726 | ||
1727 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1727 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1728 | SLOT( removeVoice() ), actionCollection(), | 1728 | SLOT( removeVoice() ), actionCollection(), |
1729 | "remove_voice" ); | 1729 | "remove_voice" ); |
1730 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1730 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1731 | SLOT( importFromOL() ), actionCollection(), | 1731 | SLOT( importFromOL() ), actionCollection(), |
1732 | "import_OL" ); | 1732 | "import_OL" ); |
1733 | #ifdef KAB_EMBEDDED | 1733 | #ifdef KAB_EMBEDDED |
1734 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1734 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1735 | this, SLOT( showLicence() ), actionCollection(), | 1735 | this, SLOT( showLicence() ), actionCollection(), |
1736 | "licence_about_data" ); | 1736 | "licence_about_data" ); |
1737 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1737 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1738 | this, SLOT( faq() ), actionCollection(), | 1738 | this, SLOT( faq() ), actionCollection(), |
1739 | "faq_about_data" ); | 1739 | "faq_about_data" ); |
1740 | 1740 | ||
1741 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1741 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1742 | this, SLOT( createAboutData() ), actionCollection(), | 1742 | this, SLOT( createAboutData() ), actionCollection(), |
1743 | "kaddressbook_about_data" ); | 1743 | "kaddressbook_about_data" ); |
1744 | #endif //KAB_EMBEDDED | 1744 | #endif //KAB_EMBEDDED |
1745 | 1745 | ||
1746 | clipboardDataChanged(); | 1746 | clipboardDataChanged(); |
1747 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1747 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1748 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1748 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1749 | } | 1749 | } |
1750 | 1750 | ||
1751 | //US we need this function, to plug all actions into the correct menues. | 1751 | //US we need this function, to plug all actions into the correct menues. |
1752 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1752 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1753 | void KABCore::addActionsManually() | 1753 | void KABCore::addActionsManually() |
1754 | { | 1754 | { |
1755 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1755 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1756 | 1756 | ||
1757 | #ifdef KAB_EMBEDDED | 1757 | #ifdef KAB_EMBEDDED |
1758 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1758 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1759 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1759 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1760 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1760 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1761 | 1761 | ||
1762 | KToolBar* tb = mMainWindow->toolBar(); | 1762 | KToolBar* tb = mMainWindow->toolBar(); |
1763 | 1763 | ||
1764 | #ifdef DESKTOP_VERSION | 1764 | #ifdef DESKTOP_VERSION |
1765 | QMenuBar* mb = mMainWindow->menuBar(); | 1765 | QMenuBar* mb = mMainWindow->menuBar(); |
1766 | 1766 | ||
1767 | //US setup menubar. | 1767 | //US setup menubar. |
1768 | //Disable the following block if you do not want to have a menubar. | 1768 | //Disable the following block if you do not want to have a menubar. |
1769 | mb->insertItem( "&File", fileMenu ); | 1769 | mb->insertItem( "&File", fileMenu ); |
1770 | mb->insertItem( "&Edit", editMenu ); | 1770 | mb->insertItem( "&Edit", editMenu ); |
1771 | mb->insertItem( "&View", viewMenu ); | 1771 | mb->insertItem( "&View", viewMenu ); |
1772 | mb->insertItem( "&Settings", settingsMenu ); | 1772 | mb->insertItem( "&Settings", settingsMenu ); |
1773 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1773 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1774 | mb->insertItem( "&Change selected", changeMenu ); | 1774 | mb->insertItem( "&Change selected", changeMenu ); |
1775 | mb->insertItem( "&Help", helpMenu ); | 1775 | mb->insertItem( "&Help", helpMenu ); |
1776 | mIncSearchWidget = new IncSearchWidget( tb ); | 1776 | mIncSearchWidget = new IncSearchWidget( tb ); |
1777 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1777 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1778 | 1778 | ||
1779 | #else | 1779 | #else |
1780 | //US setup toolbar | 1780 | //US setup toolbar |
1781 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1781 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1782 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1782 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1783 | menuBarTB->insertItem( "ME", popupBarTB); | 1783 | menuBarTB->insertItem( "ME", popupBarTB); |
1784 | tb->insertWidget(-1, 0, menuBarTB); | 1784 | tb->insertWidget(-1, 0, menuBarTB); |
1785 | mIncSearchWidget = new IncSearchWidget( tb ); | 1785 | mIncSearchWidget = new IncSearchWidget( tb ); |
1786 | 1786 | ||
1787 | tb->enableMoving(false); | 1787 | tb->enableMoving(false); |
1788 | popupBarTB->insertItem( "&File", fileMenu ); | 1788 | popupBarTB->insertItem( "&File", fileMenu ); |
1789 | popupBarTB->insertItem( "&Edit", editMenu ); | 1789 | popupBarTB->insertItem( "&Edit", editMenu ); |
1790 | popupBarTB->insertItem( "&View", viewMenu ); | 1790 | popupBarTB->insertItem( "&View", viewMenu ); |
1791 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1791 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1792 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1792 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1793 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1793 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1794 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1794 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1795 | popupBarTB->insertItem( "&Help", helpMenu ); | 1795 | popupBarTB->insertItem( "&Help", helpMenu ); |
1796 | if (QApplication::desktop()->width() > 320 ) { | 1796 | if (QApplication::desktop()->width() > 320 ) { |
1797 | // mViewManager->getFilterAction()->plug ( tb); | 1797 | // mViewManager->getFilterAction()->plug ( tb); |
1798 | } | 1798 | } |
1799 | #endif | 1799 | #endif |
1800 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1800 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1801 | 1801 | ||
1802 | 1802 | ||
1803 | 1803 | ||
1804 | //US Now connect the actions with the menue entries. | 1804 | //US Now connect the actions with the menue entries. |
1805 | mActionPrint->plug( fileMenu ); | 1805 | mActionPrint->plug( fileMenu ); |
1806 | mActionMail->plug( fileMenu ); | 1806 | mActionMail->plug( fileMenu ); |
1807 | fileMenu->insertSeparator(); | 1807 | fileMenu->insertSeparator(); |
1808 | 1808 | ||
1809 | mActionNewContact->plug( fileMenu ); | 1809 | mActionNewContact->plug( fileMenu ); |
1810 | mActionNewContact->plug( tb ); | 1810 | mActionNewContact->plug( tb ); |
1811 | 1811 | ||
1812 | mActionEditAddressee->plug( fileMenu ); | 1812 | mActionEditAddressee->plug( fileMenu ); |
1813 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1813 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1814 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1814 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1815 | mActionEditAddressee->plug( tb ); | 1815 | mActionEditAddressee->plug( tb ); |
1816 | 1816 | ||
1817 | fileMenu->insertSeparator(); | 1817 | fileMenu->insertSeparator(); |
1818 | mActionSave->plug( fileMenu ); | 1818 | mActionSave->plug( fileMenu ); |
1819 | fileMenu->insertItem( "&Import", ImportMenu ); | 1819 | fileMenu->insertItem( "&Import", ImportMenu ); |
1820 | fileMenu->insertItem( "&Export", ExportMenu ); | 1820 | fileMenu->insertItem( "&Export", ExportMenu ); |
1821 | fileMenu->insertSeparator(); | 1821 | fileMenu->insertSeparator(); |
1822 | mActionMailVCard->plug( fileMenu ); | 1822 | mActionMailVCard->plug( fileMenu ); |
1823 | #ifndef DESKTOP_VERSION | 1823 | #ifndef DESKTOP_VERSION |
1824 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1824 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1825 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1825 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1826 | #endif | 1826 | #endif |
1827 | fileMenu->insertSeparator(); | 1827 | fileMenu->insertSeparator(); |
1828 | mActionQuit->plug( fileMenu ); | 1828 | mActionQuit->plug( fileMenu ); |
1829 | #ifdef _WIN32_ | 1829 | #ifdef _WIN32_ |
1830 | mActionImportOL->plug( ImportMenu ); | 1830 | mActionImportOL->plug( ImportMenu ); |
1831 | #endif | 1831 | #endif |
1832 | // edit menu | 1832 | // edit menu |
1833 | mActionUndo->plug( editMenu ); | 1833 | mActionUndo->plug( editMenu ); |
1834 | mActionRedo->plug( editMenu ); | 1834 | mActionRedo->plug( editMenu ); |
1835 | editMenu->insertSeparator(); | 1835 | editMenu->insertSeparator(); |
1836 | mActionCut->plug( editMenu ); | 1836 | mActionCut->plug( editMenu ); |
1837 | mActionCopy->plug( editMenu ); | 1837 | mActionCopy->plug( editMenu ); |
1838 | mActionPaste->plug( editMenu ); | 1838 | mActionPaste->plug( editMenu ); |
1839 | mActionDelete->plug( editMenu ); | 1839 | mActionDelete->plug( editMenu ); |
1840 | editMenu->insertSeparator(); | 1840 | editMenu->insertSeparator(); |
1841 | mActionSelectAll->plug( editMenu ); | 1841 | mActionSelectAll->plug( editMenu ); |
1842 | 1842 | ||
1843 | mActionRemoveVoice->plug( changeMenu ); | 1843 | mActionRemoveVoice->plug( changeMenu ); |
1844 | // settings menu | 1844 | // settings menu |
1845 | //US special menuentry to configure the addressbook resources. On KDE | 1845 | //US special menuentry to configure the addressbook resources. On KDE |
1846 | // you do that through the control center !!! | 1846 | // you do that through the control center !!! |
1847 | mActionConfigResources->plug( settingsMenu ); | 1847 | mActionConfigResources->plug( settingsMenu ); |
1848 | settingsMenu->insertSeparator(); | 1848 | settingsMenu->insertSeparator(); |
1849 | 1849 | ||
1850 | mActionConfigKAddressbook->plug( settingsMenu ); | 1850 | mActionConfigKAddressbook->plug( settingsMenu ); |
1851 | 1851 | ||
1852 | if ( mIsPart ) { | 1852 | if ( mIsPart ) { |
1853 | mActionConfigShortcuts->plug( settingsMenu ); | 1853 | mActionConfigShortcuts->plug( settingsMenu ); |
1854 | mActionConfigureToolbars->plug( settingsMenu ); | 1854 | mActionConfigureToolbars->plug( settingsMenu ); |
1855 | 1855 | ||
1856 | } else { | 1856 | } else { |
1857 | mActionKeyBindings->plug( settingsMenu ); | 1857 | mActionKeyBindings->plug( settingsMenu ); |
1858 | } | 1858 | } |
1859 | 1859 | ||
1860 | settingsMenu->insertSeparator(); | 1860 | settingsMenu->insertSeparator(); |
1861 | 1861 | ||
1862 | mActionJumpBar->plug( settingsMenu ); | 1862 | mActionJumpBar->plug( settingsMenu ); |
1863 | mActionDetails->plug( settingsMenu ); | 1863 | mActionDetails->plug( settingsMenu ); |
1864 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 1864 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
1865 | mActionDetails->plug( tb ); | 1865 | mActionDetails->plug( tb ); |
1866 | settingsMenu->insertSeparator(); | 1866 | settingsMenu->insertSeparator(); |
1867 | 1867 | ||
1868 | mActionWhoAmI->plug( settingsMenu ); | 1868 | mActionWhoAmI->plug( settingsMenu ); |
1869 | mActionCategories->plug( settingsMenu ); | 1869 | mActionCategories->plug( settingsMenu ); |
1870 | 1870 | ||
1871 | mActionLicence->plug( helpMenu ); | 1871 | mActionLicence->plug( helpMenu ); |
1872 | mActionFaq->plug( helpMenu ); | 1872 | mActionFaq->plug( helpMenu ); |
1873 | mActionAboutKAddressbook->plug( helpMenu ); | 1873 | mActionAboutKAddressbook->plug( helpMenu ); |
1874 | 1874 | ||
1875 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1875 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1876 | 1876 | ||
1877 | mActionSave->plug( tb ); | 1877 | mActionSave->plug( tb ); |
1878 | mViewManager->getFilterAction()->plug ( tb); | 1878 | mViewManager->getFilterAction()->plug ( tb); |
1879 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 1879 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
1880 | mActionUndo->plug( tb ); | 1880 | mActionUndo->plug( tb ); |
1881 | mActionDelete->plug( tb ); | 1881 | mActionDelete->plug( tb ); |
1882 | mActionRedo->plug( tb ); | 1882 | mActionRedo->plug( tb ); |
1883 | } | 1883 | } |
1884 | } | 1884 | } |
1885 | //mActionQuit->plug ( tb ); | 1885 | //mActionQuit->plug ( tb ); |
1886 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1886 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1887 | 1887 | ||
1888 | //US link the searchwidget first to this. | 1888 | //US link the searchwidget first to this. |
1889 | // The real linkage to the toolbar happens later. | 1889 | // The real linkage to the toolbar happens later. |
1890 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1890 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1891 | //US tb->insertItem( mIncSearchWidget ); | 1891 | //US tb->insertItem( mIncSearchWidget ); |
1892 | /*US | 1892 | /*US |
1893 | mIncSearchWidget = new IncSearchWidget( tb ); | 1893 | mIncSearchWidget = new IncSearchWidget( tb ); |
1894 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1894 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1895 | SLOT( incrementalSearch( const QString& ) ) ); | 1895 | SLOT( incrementalSearch( const QString& ) ) ); |
1896 | 1896 | ||
1897 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1897 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1898 | 1898 | ||
1899 | //US topLayout->addWidget( mJumpButtonBar ); | 1899 | //US topLayout->addWidget( mJumpButtonBar ); |
1900 | this->layout()->add( mJumpButtonBar ); | 1900 | this->layout()->add( mJumpButtonBar ); |
1901 | */ | 1901 | */ |
1902 | 1902 | ||
1903 | #endif //KAB_EMBEDDED | 1903 | #endif //KAB_EMBEDDED |
1904 | 1904 | ||
1905 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 1905 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); |
1906 | fillSyncMenu(); | 1906 | fillSyncMenu(); |
1907 | 1907 | ||
1908 | } | 1908 | } |
1909 | void KABCore::showLicence() | 1909 | void KABCore::showLicence() |
1910 | { | 1910 | { |
1911 | KApplication::showLicence(); | 1911 | KApplication::showLicence(); |
1912 | } | 1912 | } |
1913 | void KABCore::removeVoice() | 1913 | void KABCore::removeVoice() |
1914 | { | 1914 | { |
1915 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 1915 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
1916 | return; | 1916 | return; |
1917 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 1917 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
1918 | KABC::Addressee::List::Iterator it; | 1918 | KABC::Addressee::List::Iterator it; |
1919 | for ( it = list.begin(); it != list.end(); ++it ) { | 1919 | for ( it = list.begin(); it != list.end(); ++it ) { |
1920 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 1920 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
1921 | PhoneNumber::List::Iterator phoneIt; | 1921 | PhoneNumber::List::Iterator phoneIt; |
1922 | bool found = false; | 1922 | bool found = false; |
1923 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 1923 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
1924 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 1924 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
1925 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 1925 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
1926 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 1926 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
1927 | (*it).insertPhoneNumber( (*phoneIt) ); | 1927 | (*it).insertPhoneNumber( (*phoneIt) ); |
1928 | found = true; | 1928 | found = true; |
1929 | } | 1929 | } |
1930 | } | 1930 | } |
1931 | 1931 | ||
1932 | } | 1932 | } |
1933 | if ( found ) | 1933 | if ( found ) |
1934 | contactModified((*it) ); | 1934 | contactModified((*it) ); |
1935 | } | 1935 | } |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | 1938 | ||
1939 | 1939 | ||
1940 | void KABCore::clipboardDataChanged() | 1940 | void KABCore::clipboardDataChanged() |
1941 | { | 1941 | { |
1942 | 1942 | ||
1943 | if ( mReadWrite ) | 1943 | if ( mReadWrite ) |
1944 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 1944 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
1945 | 1945 | ||
1946 | } | 1946 | } |
1947 | 1947 | ||
1948 | void KABCore::updateActionMenu() | 1948 | void KABCore::updateActionMenu() |
1949 | { | 1949 | { |
1950 | UndoStack *undo = UndoStack::instance(); | 1950 | UndoStack *undo = UndoStack::instance(); |
1951 | RedoStack *redo = RedoStack::instance(); | 1951 | RedoStack *redo = RedoStack::instance(); |
1952 | 1952 | ||
1953 | if ( undo->isEmpty() ) | 1953 | if ( undo->isEmpty() ) |
1954 | mActionUndo->setText( i18n( "Undo" ) ); | 1954 | mActionUndo->setText( i18n( "Undo" ) ); |
1955 | else | 1955 | else |
1956 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 1956 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
1957 | 1957 | ||
1958 | mActionUndo->setEnabled( !undo->isEmpty() ); | 1958 | mActionUndo->setEnabled( !undo->isEmpty() ); |
1959 | 1959 | ||
1960 | if ( !redo->top() ) | 1960 | if ( !redo->top() ) |
1961 | mActionRedo->setText( i18n( "Redo" ) ); | 1961 | mActionRedo->setText( i18n( "Redo" ) ); |
1962 | else | 1962 | else |
1963 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 1963 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
1964 | 1964 | ||
1965 | mActionRedo->setEnabled( !redo->isEmpty() ); | 1965 | mActionRedo->setEnabled( !redo->isEmpty() ); |
1966 | } | 1966 | } |
1967 | 1967 | ||
1968 | void KABCore::configureKeyBindings() | 1968 | void KABCore::configureKeyBindings() |
1969 | { | 1969 | { |
1970 | #ifndef KAB_EMBEDDED | 1970 | #ifndef KAB_EMBEDDED |
1971 | KKeyDialog::configure( actionCollection(), true ); | 1971 | KKeyDialog::configure( actionCollection(), true ); |
1972 | #else //KAB_EMBEDDED | 1972 | #else //KAB_EMBEDDED |
1973 | qDebug("KABCore::configureKeyBindings() not implemented"); | 1973 | qDebug("KABCore::configureKeyBindings() not implemented"); |
1974 | #endif //KAB_EMBEDDED | 1974 | #endif //KAB_EMBEDDED |
1975 | } | 1975 | } |
1976 | 1976 | ||
1977 | #ifdef KAB_EMBEDDED | 1977 | #ifdef KAB_EMBEDDED |
1978 | void KABCore::configureResources() | 1978 | void KABCore::configureResources() |
1979 | { | 1979 | { |
1980 | KRES::KCMKResources dlg( this, "" , 0 ); | 1980 | KRES::KCMKResources dlg( this, "" , 0 ); |
1981 | 1981 | ||
1982 | if ( !dlg.exec() ) | 1982 | if ( !dlg.exec() ) |
1983 | return; | 1983 | return; |
1984 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 1984 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
1985 | } | 1985 | } |
1986 | #endif //KAB_EMBEDDED | 1986 | #endif //KAB_EMBEDDED |
1987 | 1987 | ||
1988 | 1988 | ||
1989 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 1989 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
1990 | * for the attendees list of an event. | 1990 | * for the attendees list of an event. |
1991 | */ | 1991 | */ |
1992 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 1992 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
1993 | { | 1993 | { |
1994 | QStringList nameList; | 1994 | QStringList nameList; |
1995 | QStringList emailList; | 1995 | QStringList emailList; |
1996 | QStringList uidList; | 1996 | QStringList uidList; |
1997 | 1997 | ||
1998 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 1998 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
1999 | uint i=0; | 1999 | uint i=0; |
2000 | for (i=0; i < list.count(); i++) | 2000 | for (i=0; i < list.count(); i++) |
2001 | { | 2001 | { |
2002 | nameList.append(list[i].realName()); | 2002 | nameList.append(list[i].realName()); |
2003 | emailList.append(list[i].preferredEmail()); | 2003 | emailList.append(list[i].preferredEmail()); |
2004 | uidList.append(list[i].uid()); | 2004 | uidList.append(list[i].uid()); |
2005 | } | 2005 | } |
2006 | 2006 | ||
2007 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2007 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2008 | 2008 | ||
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2011 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2012 | */ | 2012 | */ |
2013 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2013 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2014 | { | 2014 | { |
2015 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2015 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2016 | 2016 | ||
2017 | QString foundUid = QString::null; | 2017 | QString foundUid = QString::null; |
2018 | if ( ! uid.isEmpty() ) { | 2018 | if ( ! uid.isEmpty() ) { |
2019 | Addressee adrr = mAddressBook->findByUid( uid ); | 2019 | Addressee adrr = mAddressBook->findByUid( uid ); |
2020 | if ( !adrr.isEmpty() ) { | 2020 | if ( !adrr.isEmpty() ) { |
2021 | foundUid = uid; | 2021 | foundUid = uid; |
2022 | } | 2022 | } |
2023 | if ( email == "sendbacklist" ) { | 2023 | if ( email == "sendbacklist" ) { |
2024 | //qDebug("ssssssssssssssssssssssend "); | 2024 | //qDebug("ssssssssssssssssssssssend "); |
2025 | QStringList nameList; | 2025 | QStringList nameList; |
2026 | QStringList emailList; | 2026 | QStringList emailList; |
2027 | QStringList uidList; | 2027 | QStringList uidList; |
2028 | nameList.append(adrr.realName()); | 2028 | nameList.append(adrr.realName()); |
2029 | emailList = adrr.emails(); | 2029 | emailList = adrr.emails(); |
2030 | uidList.append( adrr.preferredEmail()); | 2030 | uidList.append( adrr.preferredEmail()); |
2031 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2031 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2032 | return; | 2032 | return; |
2033 | } | 2033 | } |
2034 | 2034 | ||
2035 | } | 2035 | } |
2036 | 2036 | ||
2037 | if ( email == "sendbacklist" ) | 2037 | if ( email == "sendbacklist" ) |
2038 | return; | 2038 | return; |
2039 | if (foundUid.isEmpty()) | 2039 | if (foundUid.isEmpty()) |
2040 | { | 2040 | { |
2041 | //find the uid of the person first | 2041 | //find the uid of the person first |
2042 | Addressee::List namelist; | 2042 | Addressee::List namelist; |
2043 | Addressee::List emaillist; | 2043 | Addressee::List emaillist; |
2044 | 2044 | ||
2045 | if (!name.isEmpty()) | 2045 | if (!name.isEmpty()) |
2046 | namelist = mAddressBook->findByName( name ); | 2046 | namelist = mAddressBook->findByName( name ); |
2047 | 2047 | ||
2048 | if (!email.isEmpty()) | 2048 | if (!email.isEmpty()) |
2049 | emaillist = mAddressBook->findByEmail( email ); | 2049 | emaillist = mAddressBook->findByEmail( email ); |
2050 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2050 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2051 | //check if we have a match in Namelist and Emaillist | 2051 | //check if we have a match in Namelist and Emaillist |
2052 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2052 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2053 | foundUid = emaillist[0].uid(); | 2053 | foundUid = emaillist[0].uid(); |
2054 | } | 2054 | } |
2055 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2055 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2056 | foundUid = namelist[0].uid(); | 2056 | foundUid = namelist[0].uid(); |
2057 | else | 2057 | else |
2058 | { | 2058 | { |
2059 | for (int i = 0; i < namelist.count(); i++) | 2059 | for (int i = 0; i < namelist.count(); i++) |
2060 | { | 2060 | { |
2061 | for (int j = 0; j < emaillist.count(); j++) | 2061 | for (int j = 0; j < emaillist.count(); j++) |
2062 | { | 2062 | { |
2063 | if (namelist[i] == emaillist[j]) | 2063 | if (namelist[i] == emaillist[j]) |
2064 | { | 2064 | { |
2065 | foundUid = namelist[i].uid(); | 2065 | foundUid = namelist[i].uid(); |
2066 | } | 2066 | } |
2067 | } | 2067 | } |
2068 | } | 2068 | } |
2069 | } | 2069 | } |
2070 | } | 2070 | } |
2071 | else | 2071 | else |
2072 | { | 2072 | { |
2073 | foundUid = uid; | 2073 | foundUid = uid; |
2074 | } | 2074 | } |
2075 | 2075 | ||
2076 | if (!foundUid.isEmpty()) | 2076 | if (!foundUid.isEmpty()) |
2077 | { | 2077 | { |
2078 | 2078 | ||
2079 | // raise Ka/Pi if it is in the background | 2079 | // raise Ka/Pi if it is in the background |
2080 | #ifndef DESKTOP_VERSION | 2080 | #ifndef DESKTOP_VERSION |
2081 | #ifndef KORG_NODCOP | 2081 | #ifndef KORG_NODCOP |
2082 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2082 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2083 | #endif | 2083 | #endif |
2084 | #endif | 2084 | #endif |
2085 | 2085 | ||
2086 | mMainWindow->showMaximized(); | 2086 | mMainWindow->showMaximized(); |
2087 | mMainWindow-> raise(); | 2087 | mMainWindow-> raise(); |
2088 | 2088 | ||
2089 | mViewManager->setSelected( "", false); | 2089 | mViewManager->setSelected( "", false); |
2090 | mViewManager->refreshView( "" ); | 2090 | mViewManager->refreshView( "" ); |
2091 | mViewManager->setSelected( foundUid, true ); | 2091 | mViewManager->setSelected( foundUid, true ); |
2092 | mViewManager->refreshView( foundUid ); | 2092 | mViewManager->refreshView( foundUid ); |
2093 | 2093 | ||
2094 | if ( !mMultipleViewsAtOnce ) | 2094 | if ( !mMultipleViewsAtOnce ) |
2095 | { | 2095 | { |
2096 | setDetailsVisible( true ); | 2096 | setDetailsVisible( true ); |
2097 | mActionDetails->setChecked(true); | 2097 | mActionDetails->setChecked(true); |
2098 | } | 2098 | } |
2099 | } | 2099 | } |
2100 | } | 2100 | } |
2101 | 2101 | ||
2102 | 2102 | ||
2103 | void KABCore::faq() | 2103 | void KABCore::faq() |
2104 | { | 2104 | { |
2105 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2105 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2106 | } | 2106 | } |
2107 | 2107 | ||
2108 | 2108 | ||
2109 | void KABCore::fillSyncMenu() | 2109 | void KABCore::fillSyncMenu() |
2110 | { | 2110 | { |
2111 | if ( syncMenu->count() ) | 2111 | if ( syncMenu->count() ) |
2112 | syncMenu->clear(); | 2112 | syncMenu->clear(); |
2113 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 2113 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
2114 | syncMenu->insertSeparator(); | 2114 | syncMenu->insertSeparator(); |
2115 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 2115 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
2116 | syncMenu->insertSeparator(); | 2116 | syncMenu->insertSeparator(); |
2117 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2117 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2118 | config.setGroup("General"); | 2118 | config.setGroup("General"); |
2119 | QStringList prof = config.readListEntry("SyncProfileNames"); | 2119 | QStringList prof = config.readListEntry("SyncProfileNames"); |
2120 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 2120 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
2121 | if ( prof.count() < 3 ) { | 2121 | if ( prof.count() < 3 ) { |
2122 | prof.clear(); | 2122 | prof.clear(); |
2123 | prof << i18n("Sharp_DTM"); | 2123 | prof << i18n("Sharp_DTM"); |
2124 | prof << i18n("Local_file"); | 2124 | prof << i18n("Local_file"); |
2125 | prof << i18n("Last_file"); | 2125 | prof << i18n("Last_file"); |
2126 | KSyncProfile* temp = new KSyncProfile (); | 2126 | KSyncProfile* temp = new KSyncProfile (); |
2127 | temp->setName( prof[0] ); | 2127 | temp->setName( prof[0] ); |
2128 | temp->writeConfig(&config); | 2128 | temp->writeConfig(&config); |
2129 | temp->setName( prof[1] ); | 2129 | temp->setName( prof[1] ); |
2130 | temp->writeConfig(&config); | 2130 | temp->writeConfig(&config); |
2131 | temp->setName( prof[2] ); | 2131 | temp->setName( prof[2] ); |
2132 | temp->writeConfig(&config); | 2132 | temp->writeConfig(&config); |
2133 | config.setGroup("General"); | 2133 | config.setGroup("General"); |
2134 | config.writeEntry("SyncProfileNames",prof); | 2134 | config.writeEntry("SyncProfileNames",prof); |
2135 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 2135 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
2136 | config.sync(); | 2136 | config.sync(); |
2137 | delete temp; | 2137 | delete temp; |
2138 | } | 2138 | } |
2139 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 2139 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
2140 | KABPrefs::instance()->mSyncProfileNames = prof; | 2140 | KABPrefs::instance()->mSyncProfileNames = prof; |
2141 | int i; | 2141 | int i; |
2142 | for ( i = 0; i < prof.count(); ++i ) { | 2142 | for ( i = 0; i < prof.count(); ++i ) { |
2143 | 2143 | ||
2144 | syncMenu->insertItem( prof[i], 1000+i ); | 2144 | syncMenu->insertItem( prof[i], 1000+i ); |
2145 | if ( i == 2 ) | 2145 | if ( i == 2 ) |
2146 | syncMenu->insertSeparator(); | 2146 | syncMenu->insertSeparator(); |
2147 | } | 2147 | } |
2148 | QDir app_dir; | 2148 | QDir app_dir; |
2149 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 2149 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
2150 | syncMenu->setItemEnabled( false , 1000 ); | 2150 | syncMenu->setItemEnabled( false , 1000 ); |
2151 | } | 2151 | } |
2152 | //probaly useless | 2152 | //probaly useless |
2153 | //mView->setupExternSyncProfiles(); | 2153 | //mView->setupExternSyncProfiles(); |
2154 | } | 2154 | } |
2155 | void KABCore::slotSyncMenu( int action ) | 2155 | void KABCore::slotSyncMenu( int action ) |
2156 | { | 2156 | { |
2157 | //qDebug("syncaction %d ", action); | 2157 | //qDebug("syncaction %d ", action); |
2158 | if ( action == 0 ) { | 2158 | if ( action == 0 ) { |
2159 | 2159 | ||
2160 | // seems to be a Qt2 event handling bug | 2160 | // seems to be a Qt2 event handling bug |
2161 | // syncmenu.clear causes a segfault at first time | 2161 | // syncmenu.clear causes a segfault at first time |
2162 | // when we call it after the main event loop, it is ok | 2162 | // when we call it after the main event loop, it is ok |
2163 | // same behaviour when calling OM/Pi via QCOP for the first time | 2163 | // same behaviour when calling OM/Pi via QCOP for the first time |
2164 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 2164 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
2165 | //confSync(); | 2165 | //confSync(); |
2166 | 2166 | ||
2167 | return; | 2167 | return; |
2168 | } | 2168 | } |
2169 | if ( action == 1 ) { | 2169 | if ( action == 1 ) { |
2170 | multiSync( true ); | 2170 | multiSync( true ); |
2171 | return; | 2171 | return; |
2172 | } | 2172 | } |
2173 | 2173 | ||
2174 | if (mBlockSaveFlag) | 2174 | if (mBlockSaveFlag) |
2175 | return; | 2175 | return; |
2176 | mBlockSaveFlag = true; | 2176 | mBlockSaveFlag = true; |
2177 | mCurrentSyncProfile = action - 1000 ; | 2177 | mCurrentSyncProfile = action - 1000 ; |
2178 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; | 2178 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; |
2179 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; | 2179 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; |
2180 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2180 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2181 | KSyncProfile* temp = new KSyncProfile (); | 2181 | KSyncProfile* temp = new KSyncProfile (); |
2182 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2182 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2183 | temp->readConfig(&config); | 2183 | temp->readConfig(&config); |
2184 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2184 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2185 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2185 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2186 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2186 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2187 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2187 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2188 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2188 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2189 | if ( temp->getWriteBackFuture() ) | 2189 | if ( temp->getWriteBackFuture() ) |
2190 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2190 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2191 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2191 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2192 | if ( action == 1000 ) { | 2192 | if ( action == 1000 ) { |
2193 | syncSharp(); | 2193 | syncSharp(); |
2194 | 2194 | ||
2195 | } else if ( action == 1001 ) { | 2195 | } else if ( action == 1001 ) { |
2196 | syncLocalFile(); | 2196 | syncLocalFile(); |
2197 | 2197 | ||
2198 | } else if ( action == 1002 ) { | 2198 | } else if ( action == 1002 ) { |
2199 | quickSyncLocalFile(); | 2199 | quickSyncLocalFile(); |
2200 | 2200 | ||
2201 | } else if ( action >= 1003 ) { | 2201 | } else if ( action >= 1003 ) { |
2202 | if ( temp->getIsLocalFileSync() ) { | 2202 | if ( temp->getIsLocalFileSync() ) { |
2203 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 2203 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
2204 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 2204 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2205 | } else { | 2205 | } else { |
2206 | if ( temp->getIsPhoneSync() ) { | 2206 | if ( temp->getIsPhoneSync() ) { |
2207 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2207 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2208 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2208 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2209 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2209 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2210 | syncPhone(); | 2210 | syncPhone(); |
2211 | } else | 2211 | } else |
2212 | syncRemote( temp ); | 2212 | syncRemote( temp ); |
2213 | 2213 | ||
2214 | } | 2214 | } |
2215 | } | 2215 | } |
2216 | delete temp; | 2216 | delete temp; |
2217 | mBlockSaveFlag = false; | 2217 | mBlockSaveFlag = false; |
2218 | } | 2218 | } |
2219 | 2219 | ||
2220 | void KABCore::syncLocalFile() | 2220 | void KABCore::syncLocalFile() |
2221 | { | 2221 | { |
2222 | 2222 | ||
2223 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; | 2223 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; |
2224 | 2224 | ||
2225 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2225 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2226 | if ( fn == "" ) | 2226 | if ( fn == "" ) |
2227 | return; | 2227 | return; |
2228 | if ( syncWithFile( fn, false ) ) { | 2228 | if ( syncWithFile( fn, false ) ) { |
2229 | qDebug("syncLocalFile() successful "); | 2229 | qDebug("syncLocalFile() successful "); |
2230 | } | 2230 | } |
2231 | 2231 | ||
2232 | } | 2232 | } |
2233 | bool KABCore::syncWithFile( QString fn , bool quick ) | 2233 | bool KABCore::syncWithFile( QString fn , bool quick ) |
2234 | { | 2234 | { |
2235 | bool ret = false; | 2235 | bool ret = false; |
2236 | QFileInfo info; | 2236 | QFileInfo info; |
2237 | info.setFile( fn ); | 2237 | info.setFile( fn ); |
2238 | QString mess; | 2238 | QString mess; |
2239 | bool loadbup = true; | 2239 | bool loadbup = true; |
2240 | if ( !info. exists() ) { | 2240 | if ( !info. exists() ) { |
2241 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2241 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2242 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2242 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2243 | mess ); | 2243 | mess ); |
2244 | return ret; | 2244 | return ret; |
2245 | } | 2245 | } |
2246 | int result = 0; | 2246 | int result = 0; |
2247 | if ( !quick ) { | 2247 | if ( !quick ) { |
2248 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2248 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2249 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2249 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2250 | mess, | 2250 | mess, |
2251 | i18n("Sync"), i18n("Cancel"), 0, | 2251 | i18n("Sync"), i18n("Cancel"), 0, |
2252 | 0, 1 ); | 2252 | 0, 1 ); |
2253 | if ( result ) | 2253 | if ( result ) |
2254 | return false; | 2254 | return false; |
2255 | } | 2255 | } |
2256 | if ( KABPrefs::instance()->mAskForPreferences ) | 2256 | if ( KABPrefs::instance()->mAskForPreferences ) |
2257 | edit_sync_options(); | 2257 | edit_sync_options(); |
2258 | if ( result == 0 ) { | 2258 | if ( result == 0 ) { |
2259 | //qDebug("Now sycing ... "); | 2259 | //qDebug("Now sycing ... "); |
2260 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) | 2260 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) |
2261 | setCaption( i18n("Synchronization successful") ); | 2261 | setCaption( i18n("Synchronization successful") ); |
2262 | else | 2262 | else |
2263 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 2263 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
2264 | if ( ! quick ) | 2264 | if ( ! quick ) |
2265 | KABPrefs::instance()->mLastSyncedLocalFile = fn; | 2265 | KABPrefs::instance()->mLastSyncedLocalFile = fn; |
2266 | setModified(); | 2266 | setModified(); |
2267 | } | 2267 | } |
2268 | return ret; | 2268 | return ret; |
2269 | } | 2269 | } |
2270 | void KABCore::quickSyncLocalFile() | 2270 | void KABCore::quickSyncLocalFile() |
2271 | { | 2271 | { |
2272 | 2272 | ||
2273 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 2273 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
2274 | qDebug("quick syncLocalFile() successful "); | 2274 | qDebug("quick syncLocalFile() successful "); |
2275 | 2275 | ||
2276 | } | 2276 | } |
2277 | } | 2277 | } |
2278 | void KABCore::multiSync( bool askforPrefs ) | 2278 | void KABCore::multiSync( bool askforPrefs ) |
2279 | { | 2279 | { |
2280 | if (mBlockSaveFlag) | 2280 | if (mBlockSaveFlag) |
2281 | return; | 2281 | return; |
2282 | mBlockSaveFlag = true; | 2282 | mBlockSaveFlag = true; |
2283 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 2283 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
2284 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2284 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2285 | question, | 2285 | question, |
2286 | i18n("Yes"), i18n("No"), | 2286 | i18n("Yes"), i18n("No"), |
2287 | 0, 0 ) != 0 ) { | 2287 | 0, 0 ) != 0 ) { |
2288 | mBlockSaveFlag = false; | 2288 | mBlockSaveFlag = false; |
2289 | setCaption(i18n("Aborted! Nothing synced!")); | 2289 | setCaption(i18n("Aborted! Nothing synced!")); |
2290 | return; | 2290 | return; |
2291 | } | 2291 | } |
2292 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 2292 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
2293 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; | 2293 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; |
2294 | if ( askforPrefs ) { | 2294 | if ( askforPrefs ) { |
2295 | edit_sync_options(); | 2295 | edit_sync_options(); |
2296 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; | 2296 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; |
2297 | } | 2297 | } |
2298 | setCaption(i18n("Multiple sync started.") ); | 2298 | setCaption(i18n("Multiple sync started.") ); |
2299 | qApp->processEvents(); | 2299 | qApp->processEvents(); |
2300 | int num = ringSync() ; | 2300 | int num = ringSync() ; |
2301 | if ( num > 1 ) | 2301 | if ( num > 1 ) |
2302 | ringSync(); | 2302 | ringSync(); |
2303 | mBlockSaveFlag = false; | 2303 | mBlockSaveFlag = false; |
2304 | if ( num ) | 2304 | if ( num ) |
2305 | save(); | 2305 | save(); |
2306 | if ( num ) | 2306 | if ( num ) |
2307 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 2307 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
2308 | else | 2308 | else |
2309 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 2309 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
2310 | return; | 2310 | return; |
2311 | } | 2311 | } |
2312 | int KABCore::ringSync() | 2312 | int KABCore::ringSync() |
2313 | { | 2313 | { |
2314 | int syncedProfiles = 0; | 2314 | int syncedProfiles = 0; |
2315 | int i; | 2315 | int i; |
2316 | QTime timer; | 2316 | QTime timer; |
2317 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2317 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2318 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; | 2318 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; |
2319 | KSyncProfile* temp = new KSyncProfile (); | 2319 | KSyncProfile* temp = new KSyncProfile (); |
2320 | KABPrefs::instance()->mAskForPreferences = false; | 2320 | KABPrefs::instance()->mAskForPreferences = false; |
2321 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 2321 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
2322 | mCurrentSyncProfile = i; | 2322 | mCurrentSyncProfile = i; |
2323 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 2323 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
2324 | temp->readConfig(&config); | 2324 | temp->readConfig(&config); |
2325 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { | 2325 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { |
2326 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 2326 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
2327 | ++syncedProfiles; | 2327 | ++syncedProfiles; |
2328 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2328 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2329 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2329 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2330 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2330 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2331 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2331 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2332 | if ( temp->getWriteBackFuture() ) | 2332 | if ( temp->getWriteBackFuture() ) |
2333 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2333 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2334 | KABPrefs::instance()->mShowSyncSummary = false; | 2334 | KABPrefs::instance()->mShowSyncSummary = false; |
2335 | mCurrentSyncDevice = syncProfileNames[i] ; | 2335 | mCurrentSyncDevice = syncProfileNames[i] ; |
2336 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; | 2336 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; |
2337 | if ( i == 0 ) { | 2337 | if ( i == 0 ) { |
2338 | syncSharp(); | 2338 | syncSharp(); |
2339 | } else { | 2339 | } else { |
2340 | if ( temp->getIsLocalFileSync() ) { | 2340 | if ( temp->getIsLocalFileSync() ) { |
2341 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) | 2341 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) |
2342 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 2342 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2343 | } else { | 2343 | } else { |
2344 | if ( temp->getIsPhoneSync() ) { | 2344 | if ( temp->getIsPhoneSync() ) { |
2345 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2345 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2346 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2346 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2347 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2347 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2348 | syncPhone(); | 2348 | syncPhone(); |
2349 | } else | 2349 | } else |
2350 | syncRemote( temp, false ); | 2350 | syncRemote( temp, false ); |
2351 | 2351 | ||
2352 | } | 2352 | } |
2353 | } | 2353 | } |
2354 | timer.start(); | 2354 | timer.start(); |
2355 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 2355 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
2356 | while ( timer.elapsed () < 2000 ) { | 2356 | while ( timer.elapsed () < 2000 ) { |
2357 | qApp->processEvents(); | 2357 | qApp->processEvents(); |
2358 | #ifndef _WIN32_ | 2358 | #ifndef _WIN32_ |
2359 | sleep (1); | 2359 | sleep (1); |
2360 | #endif | 2360 | #endif |
2361 | } | 2361 | } |
2362 | 2362 | ||
2363 | } | 2363 | } |
2364 | 2364 | ||
2365 | } | 2365 | } |
2366 | delete temp; | 2366 | delete temp; |
2367 | return syncedProfiles; | 2367 | return syncedProfiles; |
2368 | } | 2368 | } |
2369 | 2369 | ||
2370 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) | 2370 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) |
2371 | { | 2371 | { |
2372 | QString question; | 2372 | QString question; |
2373 | if ( ask ) { | 2373 | if ( ask ) { |
2374 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 2374 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
2375 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2375 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2376 | question, | 2376 | question, |
2377 | i18n("Yes"), i18n("No"), | 2377 | i18n("Yes"), i18n("No"), |
2378 | 0, 0 ) != 0 ) | 2378 | 0, 0 ) != 0 ) |
2379 | return; | 2379 | return; |
2380 | } | 2380 | } |
2381 | QString command = prof->getPreSyncCommandAB(); | 2381 | QString command = prof->getPreSyncCommandAB(); |
2382 | int fi; | 2382 | int fi; |
2383 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2383 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2384 | QString pwd = getPassword(); | 2384 | QString pwd = getPassword(); |
2385 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2385 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2386 | 2386 | ||
2387 | } | 2387 | } |
2388 | int maxlen = 30; | 2388 | int maxlen = 30; |
2389 | if ( QApplication::desktop()->width() > 320 ) | 2389 | if ( QApplication::desktop()->width() > 320 ) |
2390 | maxlen += 25; | 2390 | maxlen += 25; |
2391 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2391 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2392 | int fileSize = 0; | 2392 | int fileSize = 0; |
2393 | int result = system ( command ); | 2393 | int result = system ( command ); |
2394 | // 0 : okay | 2394 | // 0 : okay |
2395 | // 256: no such file or dir | 2395 | // 256: no such file or dir |
2396 | // | 2396 | // |
2397 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2397 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2398 | if ( result != 0 ) { | 2398 | if ( result != 0 ) { |
2399 | int len = maxlen; | 2399 | int len = maxlen; |
2400 | while ( len < command.length() ) { | 2400 | while ( len < command.length() ) { |
2401 | command.insert( len , "\n" ); | 2401 | command.insert( len , "\n" ); |
2402 | len += maxlen +2; | 2402 | len += maxlen +2; |
2403 | } | 2403 | } |
2404 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2404 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2405 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2405 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2406 | question, | 2406 | question, |
2407 | i18n("Okay!")) ; | 2407 | i18n("Okay!")) ; |
2408 | setCaption ("KO/Pi"); | 2408 | setCaption ("KO/Pi"); |
2409 | return; | 2409 | return; |
2410 | } | 2410 | } |
2411 | setCaption ( i18n( "Copying succeed." ) ); | 2411 | setCaption ( i18n( "Copying succeed." ) ); |
2412 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2412 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2413 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { | 2413 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { |
2414 | // Event* e = mView->getLastSyncEvent(); | 2414 | // Event* e = mView->getLastSyncEvent(); |
2415 | // e->setReadOnly( false ); | 2415 | // e->setReadOnly( false ); |
2416 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2416 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2417 | // e->setReadOnly( true ); | 2417 | // e->setReadOnly( true ); |
2418 | if ( KABPrefs::instance()->mWriteBackFile ) { | 2418 | if ( KABPrefs::instance()->mWriteBackFile ) { |
2419 | command = prof->getPostSyncCommandAB(); | 2419 | command = prof->getPostSyncCommandAB(); |
2420 | int fi; | 2420 | int fi; |
2421 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2421 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2422 | QString pwd = getPassword(); | 2422 | QString pwd = getPassword(); |
2423 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2423 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2424 | 2424 | ||
2425 | } | 2425 | } |
2426 | setCaption ( i18n( "Writing back file ..." ) ); | 2426 | setCaption ( i18n( "Writing back file ..." ) ); |
2427 | result = system ( command ); | 2427 | result = system ( command ); |
2428 | qDebug("KO: Writing back file result: %d ", result); | 2428 | qDebug("KO: Writing back file result: %d ", result); |
2429 | if ( result != 0 ) { | 2429 | if ( result != 0 ) { |
2430 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2430 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2431 | return; | 2431 | return; |
2432 | } else { | 2432 | } else { |
2433 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2433 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2434 | } | 2434 | } |
2435 | } | 2435 | } |
2436 | } | 2436 | } |
2437 | return; | 2437 | return; |
2438 | } | 2438 | } |
2439 | #include <qpushbutton.h> | 2439 | #include <qpushbutton.h> |
2440 | #include <qradiobutton.h> | 2440 | #include <qradiobutton.h> |
2441 | #include <qbuttongroup.h> | 2441 | #include <qbuttongroup.h> |
2442 | void KABCore::edit_sync_options() | 2442 | void KABCore::edit_sync_options() |
2443 | { | 2443 | { |
2444 | //mDialogManager->showSyncOptions(); | 2444 | //mDialogManager->showSyncOptions(); |
2445 | //KABPrefs::instance()->mSyncAlgoPrefs | 2445 | //KABPrefs::instance()->mSyncAlgoPrefs |
2446 | QDialog dia( this, "dia", true ); | 2446 | QDialog dia( this, "dia", true ); |
2447 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2447 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2448 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2448 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2449 | QVBoxLayout lay ( &dia ); | 2449 | QVBoxLayout lay ( &dia ); |
2450 | lay.setSpacing( 2 ); | 2450 | lay.setSpacing( 2 ); |
2451 | lay.setMargin( 3 ); | 2451 | lay.setMargin( 3 ); |
2452 | lay.addWidget(&gr); | 2452 | lay.addWidget(&gr); |
2453 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2453 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2454 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2454 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2455 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2455 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2456 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2456 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2457 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2457 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2458 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2458 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2459 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2459 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2460 | QPushButton pb ( "OK", &dia); | 2460 | QPushButton pb ( "OK", &dia); |
2461 | lay.addWidget( &pb ); | 2461 | lay.addWidget( &pb ); |
2462 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2462 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2463 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { | 2463 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { |
2464 | case 0: | 2464 | case 0: |
2465 | loc.setChecked( true); | 2465 | loc.setChecked( true); |
2466 | break; | 2466 | break; |
2467 | case 1: | 2467 | case 1: |
2468 | rem.setChecked( true ); | 2468 | rem.setChecked( true ); |
2469 | break; | 2469 | break; |
2470 | case 2: | 2470 | case 2: |
2471 | newest.setChecked( true); | 2471 | newest.setChecked( true); |
2472 | break; | 2472 | break; |
2473 | case 3: | 2473 | case 3: |
2474 | ask.setChecked( true); | 2474 | ask.setChecked( true); |
2475 | break; | 2475 | break; |
2476 | case 4: | 2476 | case 4: |
2477 | f_loc.setChecked( true); | 2477 | f_loc.setChecked( true); |
2478 | break; | 2478 | break; |
2479 | case 5: | 2479 | case 5: |
2480 | f_rem.setChecked( true); | 2480 | f_rem.setChecked( true); |
2481 | break; | 2481 | break; |
2482 | case 6: | 2482 | case 6: |
2483 | // both.setChecked( true); | 2483 | // both.setChecked( true); |
2484 | break; | 2484 | break; |
2485 | default: | 2485 | default: |
2486 | break; | 2486 | break; |
2487 | } | 2487 | } |
2488 | if ( dia.exec() ) { | 2488 | if ( dia.exec() ) { |
2489 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2489 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2490 | } | 2490 | } |
2491 | 2491 | ||
2492 | 2492 | ||
2493 | } | 2493 | } |
2494 | QString KABCore::getPassword( ) | 2494 | QString KABCore::getPassword( ) |
2495 | { | 2495 | { |
2496 | QString retfile = ""; | 2496 | QString retfile = ""; |
2497 | QDialog dia ( this, "input-dialog", true ); | 2497 | QDialog dia ( this, "input-dialog", true ); |
2498 | QLineEdit lab ( &dia ); | 2498 | QLineEdit lab ( &dia ); |
2499 | lab.setEchoMode( QLineEdit::Password ); | 2499 | lab.setEchoMode( QLineEdit::Password ); |
2500 | QVBoxLayout lay( &dia ); | 2500 | QVBoxLayout lay( &dia ); |
2501 | lay.setMargin(7); | 2501 | lay.setMargin(7); |
2502 | lay.setSpacing(7); | 2502 | lay.setSpacing(7); |
2503 | lay.addWidget( &lab); | 2503 | lay.addWidget( &lab); |
2504 | dia.setFixedSize( 230,50 ); | 2504 | dia.setFixedSize( 230,50 ); |
2505 | dia.setCaption( i18n("Enter password") ); | 2505 | dia.setCaption( i18n("Enter password") ); |
2506 | QPushButton pb ( "OK", &dia); | 2506 | QPushButton pb ( "OK", &dia); |
2507 | lay.addWidget( &pb ); | 2507 | lay.addWidget( &pb ); |
2508 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2508 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2509 | dia.show(); | 2509 | dia.show(); |
2510 | int res = dia.exec(); | 2510 | int res = dia.exec(); |
2511 | if ( res ) | 2511 | if ( res ) |
2512 | retfile = lab.text(); | 2512 | retfile = lab.text(); |
2513 | dia.hide(); | 2513 | dia.hide(); |
2514 | qApp->processEvents(); | 2514 | qApp->processEvents(); |
2515 | return retfile; | 2515 | return retfile; |
2516 | 2516 | ||
2517 | } | 2517 | } |
2518 | #include <libkcal/syncdefines.h> | 2518 | #include <libkcal/syncdefines.h> |
2519 | 2519 | ||
2520 | KABC::Addressee KABCore::getLastSyncAddressee() | 2520 | KABC::Addressee KABCore::getLastSyncAddressee() |
2521 | { | 2521 | { |
2522 | Addressee lse; | 2522 | Addressee lse; |
2523 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2523 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2524 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2524 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2525 | if (lse.isEmpty()) { | 2525 | if (lse.isEmpty()) { |
2526 | qDebug("Creating new last-syncAddressee "); | 2526 | qDebug("Creating new last-syncAddressee "); |
2527 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2527 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2528 | QString sum = ""; | 2528 | QString sum = ""; |
2529 | if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 2529 | if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
2530 | sum = "E: "; | 2530 | sum = "E: "; |
2531 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2531 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2532 | lse.setRevision( mLastAddressbookSync ); | 2532 | lse.setRevision( mLastAddressbookSync ); |
2533 | lse.setCategories( i18n("SyncEvent") ); | 2533 | lse.setCategories( i18n("SyncEvent") ); |
2534 | mAddressBook->insertAddressee( lse ); | 2534 | mAddressBook->insertAddressee( lse ); |
2535 | } | 2535 | } |
2536 | return lse; | 2536 | return lse; |
2537 | } | 2537 | } |
2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2539 | { | 2539 | { |
2540 | 2540 | ||
2541 | //void setZaurusId(int id); | 2541 | //void setZaurusId(int id); |
2542 | // int zaurusId() const; | 2542 | // int zaurusId() const; |
2543 | // void setZaurusUid(int id); | 2543 | // void setZaurusUid(int id); |
2544 | // int zaurusUid() const; | 2544 | // int zaurusUid() const; |
2545 | // void setZaurusStat(int id); | 2545 | // void setZaurusStat(int id); |
2546 | // int zaurusStat() const; | 2546 | // int zaurusStat() const; |
2547 | // 0 equal | 2547 | // 0 equal |
2548 | // 1 take local | 2548 | // 1 take local |
2549 | // 2 take remote | 2549 | // 2 take remote |
2550 | // 3 cancel | 2550 | // 3 cancel |
2551 | QDateTime lastSync = mLastAddressbookSync; | 2551 | QDateTime lastSync = mLastAddressbookSync; |
2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2553 | bool remCh, locCh; | 2553 | bool remCh, locCh; |
2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2555 | //if ( remCh ) | 2555 | //if ( remCh ) |
2556 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2556 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2557 | locCh = ( local->revision() > mLastAddressbookSync ); | 2557 | locCh = ( local->revision() > mLastAddressbookSync ); |
2558 | if ( !remCh && ! locCh ) { | 2558 | if ( !remCh && ! locCh ) { |
2559 | //qDebug("both not changed "); | 2559 | //qDebug("both not changed "); |
2560 | lastSync = local->revision().addDays(1); | 2560 | lastSync = local->revision().addDays(1); |
2561 | } else { | 2561 | } else { |
2562 | if ( locCh ) { | 2562 | if ( locCh ) { |
2563 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); | 2563 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); |
2564 | lastSync = local->revision().addDays( -1 ); | 2564 | lastSync = local->revision().addDays( -1 ); |
2565 | if ( !remCh ) | 2565 | if ( !remCh ) |
2566 | remote->setRevision( lastSync.addDays( -1 ) ); | 2566 | remote->setRevision( lastSync.addDays( -1 ) ); |
2567 | } else { | 2567 | } else { |
2568 | //qDebug(" not loc changed "); | 2568 | //qDebug(" not loc changed "); |
2569 | lastSync = local->revision().addDays( 1 ); | 2569 | lastSync = local->revision().addDays( 1 ); |
2570 | if ( remCh ) | 2570 | if ( remCh ) |
2571 | remote->setRevision( lastSync.addDays( 1 ) ); | 2571 | remote->setRevision( lastSync.addDays( 1 ) ); |
2572 | 2572 | ||
2573 | } | 2573 | } |
2574 | } | 2574 | } |
2575 | full = true; | 2575 | full = true; |
2576 | if ( mode < SYNC_PREF_ASK ) | 2576 | if ( mode < SYNC_PREF_ASK ) |
2577 | mode = SYNC_PREF_ASK; | 2577 | mode = SYNC_PREF_ASK; |
2578 | } else { | 2578 | } else { |
2579 | if ( local->revision() == remote->revision() ) | 2579 | if ( local->revision() == remote->revision() ) |
2580 | return 0; | 2580 | return 0; |
2581 | 2581 | ||
2582 | } | 2582 | } |
2583 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2583 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2584 | 2584 | ||
2585 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 2585 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
2586 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2586 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2587 | //full = true; //debug only | 2587 | //full = true; //debug only |
2588 | if ( full ) { | 2588 | if ( full ) { |
2589 | bool equ = ( (*local) == (*remote) ); | 2589 | bool equ = ( (*local) == (*remote) ); |
2590 | if ( equ ) { | 2590 | if ( equ ) { |
2591 | //qDebug("equal "); | 2591 | //qDebug("equal "); |
2592 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2592 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2593 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2593 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2594 | } | 2594 | } |
2595 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2595 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2596 | return 0; | 2596 | return 0; |
2597 | 2597 | ||
2598 | }//else //debug only | 2598 | }//else //debug only |
2599 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2599 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2600 | } | 2600 | } |
2601 | int result; | 2601 | int result; |
2602 | bool localIsNew; | 2602 | bool localIsNew; |
2603 | //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() ); | 2603 | //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() ); |
2604 | 2604 | ||
2605 | if ( full && mode < SYNC_PREF_NEWEST ) | 2605 | if ( full && mode < SYNC_PREF_NEWEST ) |
2606 | mode = SYNC_PREF_ASK; | 2606 | mode = SYNC_PREF_ASK; |
2607 | 2607 | ||
2608 | switch( mode ) { | 2608 | switch( mode ) { |
2609 | case SYNC_PREF_LOCAL: | 2609 | case SYNC_PREF_LOCAL: |
2610 | if ( lastSync > remote->revision() ) | 2610 | if ( lastSync > remote->revision() ) |
2611 | return 1; | 2611 | return 1; |
2612 | if ( lastSync > local->revision() ) | 2612 | if ( lastSync > local->revision() ) |
2613 | return 2; | 2613 | return 2; |
2614 | return 1; | 2614 | return 1; |
2615 | break; | 2615 | break; |
2616 | case SYNC_PREF_REMOTE: | 2616 | case SYNC_PREF_REMOTE: |
2617 | if ( lastSync > remote->revision() ) | 2617 | if ( lastSync > remote->revision() ) |
2618 | return 1; | 2618 | return 1; |
2619 | if ( lastSync > local->revision() ) | 2619 | if ( lastSync > local->revision() ) |
2620 | return 2; | 2620 | return 2; |
2621 | return 2; | 2621 | return 2; |
2622 | break; | 2622 | break; |
2623 | case SYNC_PREF_NEWEST: | 2623 | case SYNC_PREF_NEWEST: |
2624 | if ( local->revision() > remote->revision() ) | 2624 | if ( local->revision() > remote->revision() ) |
2625 | return 1; | 2625 | return 1; |
2626 | else | 2626 | else |
2627 | return 2; | 2627 | return 2; |
2628 | break; | 2628 | break; |
2629 | case SYNC_PREF_ASK: | 2629 | case SYNC_PREF_ASK: |
2630 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); | 2630 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); |
2631 | if ( lastSync > remote->revision() ) | 2631 | if ( lastSync > remote->revision() ) |
2632 | return 1; | 2632 | return 1; |
2633 | if ( lastSync > local->revision() ) | 2633 | if ( lastSync > local->revision() ) |
2634 | return 2; | 2634 | return 2; |
2635 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); | 2635 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); |
2636 | localIsNew = local->revision() >= remote->revision(); | 2636 | localIsNew = local->revision() >= remote->revision(); |
2637 | #if 0 | 2637 | #if 0 |
2638 | if ( localIsNew ) | 2638 | if ( localIsNew ) |
2639 | getEventViewerDialog()->setColorMode( 1 ); | 2639 | getEventViewerDialog()->setColorMode( 1 ); |
2640 | else | 2640 | else |
2641 | getEventViewerDialog()->setColorMode( 2 ); | 2641 | getEventViewerDialog()->setColorMode( 2 ); |
2642 | getEventViewerDialog()->setIncidence(local); | 2642 | getEventViewerDialog()->setIncidence(local); |
2643 | if ( localIsNew ) | 2643 | if ( localIsNew ) |
2644 | getEventViewerDialog()->setColorMode( 2 ); | 2644 | getEventViewerDialog()->setColorMode( 2 ); |
2645 | else | 2645 | else |
2646 | getEventViewerDialog()->setColorMode( 1 ); | 2646 | getEventViewerDialog()->setColorMode( 1 ); |
2647 | getEventViewerDialog()->addIncidence(remote); | 2647 | getEventViewerDialog()->addIncidence(remote); |
2648 | getEventViewerDialog()->setColorMode( 0 ); | 2648 | getEventViewerDialog()->setColorMode( 0 ); |
2649 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 2649 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
2650 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 2650 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
2651 | getEventViewerDialog()->showMe(); | 2651 | getEventViewerDialog()->showMe(); |
2652 | result = getEventViewerDialog()->executeS( localIsNew ); | 2652 | result = getEventViewerDialog()->executeS( localIsNew ); |
2653 | #endif | 2653 | #endif |
2654 | qDebug("conflict! ************************************** "); | 2654 | qDebug("conflict! ************************************** "); |
2655 | result = 1; | 2655 | { |
2656 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | ||
2657 | result = acd.executeD(localIsNew); | ||
2656 | return result; | 2658 | return result; |
2657 | 2659 | } | |
2658 | break; | 2660 | break; |
2659 | case SYNC_PREF_FORCE_LOCAL: | 2661 | case SYNC_PREF_FORCE_LOCAL: |
2660 | return 1; | 2662 | return 1; |
2661 | break; | 2663 | break; |
2662 | case SYNC_PREF_FORCE_REMOTE: | 2664 | case SYNC_PREF_FORCE_REMOTE: |
2663 | return 2; | 2665 | return 2; |
2664 | break; | 2666 | break; |
2665 | 2667 | ||
2666 | default: | 2668 | default: |
2667 | // SYNC_PREF_TAKE_BOTH not implemented | 2669 | // SYNC_PREF_TAKE_BOTH not implemented |
2668 | break; | 2670 | break; |
2669 | } | 2671 | } |
2670 | return 0; | 2672 | return 0; |
2671 | } | 2673 | } |
2672 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2674 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2673 | { | 2675 | { |
2674 | bool syncOK = true; | 2676 | bool syncOK = true; |
2675 | int addedAddressee = 0; | 2677 | int addedAddressee = 0; |
2676 | int addedAddresseeR = 0; | 2678 | int addedAddresseeR = 0; |
2677 | int deletedAddresseeR = 0; | 2679 | int deletedAddresseeR = 0; |
2678 | int deletedAddresseeL = 0; | 2680 | int deletedAddresseeL = 0; |
2679 | int changedLocal = 0; | 2681 | int changedLocal = 0; |
2680 | int changedRemote = 0; | 2682 | int changedRemote = 0; |
2681 | //QPtrList<Addressee> el = local->rawAddressees(); | 2683 | //QPtrList<Addressee> el = local->rawAddressees(); |
2682 | Addressee addresseeR; | 2684 | Addressee addresseeR; |
2683 | QString uid; | 2685 | QString uid; |
2684 | int take; | 2686 | int take; |
2685 | Addressee addresseeL; | 2687 | Addressee addresseeL; |
2686 | Addressee addresseeRSync; | 2688 | Addressee addresseeRSync; |
2687 | Addressee addresseeLSync; | 2689 | Addressee addresseeLSync; |
2688 | KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2690 | KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2689 | KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2691 | KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2690 | bool fullDateRange = false; | 2692 | bool fullDateRange = false; |
2691 | local->resetTempSyncStat(); | 2693 | local->resetTempSyncStat(); |
2692 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2694 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2693 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2695 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2694 | addresseeLSync = getLastSyncAddressee(); | 2696 | addresseeLSync = getLastSyncAddressee(); |
2695 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2697 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2696 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2698 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2697 | if ( !addresseeR.isEmpty() ) { | 2699 | if ( !addresseeR.isEmpty() ) { |
2698 | addresseeRSync = addresseeR; | 2700 | addresseeRSync = addresseeR; |
2699 | remote->removeAddressee(addresseeR ); | 2701 | remote->removeAddressee(addresseeR ); |
2700 | 2702 | ||
2701 | } else { | 2703 | } else { |
2702 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2704 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2703 | addresseeRSync = addresseeLSync ; | 2705 | addresseeRSync = addresseeLSync ; |
2704 | } else { | 2706 | } else { |
2705 | qDebug("FULLDATE 1"); | 2707 | qDebug("FULLDATE 1"); |
2706 | fullDateRange = true; | 2708 | fullDateRange = true; |
2707 | Addressee newAdd; | 2709 | Addressee newAdd; |
2708 | addresseeRSync = newAdd; | 2710 | addresseeRSync = newAdd; |
2709 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2711 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2710 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2712 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2711 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2713 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2712 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2714 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2713 | } | 2715 | } |
2714 | } | 2716 | } |
2715 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2717 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2716 | qDebug("FULLDATE 2"); | 2718 | qDebug("FULLDATE 2"); |
2717 | fullDateRange = true; | 2719 | fullDateRange = true; |
2718 | } | 2720 | } |
2719 | if ( ! fullDateRange ) { | 2721 | if ( ! fullDateRange ) { |
2720 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2722 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2721 | 2723 | ||
2722 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2724 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2723 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2725 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2724 | fullDateRange = true; | 2726 | fullDateRange = true; |
2725 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2727 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2726 | } | 2728 | } |
2727 | } | 2729 | } |
2730 | fullDateRange = true; // debug only! | ||
2728 | if ( fullDateRange ) | 2731 | if ( fullDateRange ) |
2729 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2732 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2730 | else | 2733 | else |
2731 | mLastAddressbookSync = addresseeLSync.revision(); | 2734 | mLastAddressbookSync = addresseeLSync.revision(); |
2732 | // for resyncing if own file has changed | 2735 | // for resyncing if own file has changed |
2733 | // PENDING fixme later when implemented | 2736 | // PENDING fixme later when implemented |
2734 | #if 0 | 2737 | #if 0 |
2735 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2738 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2736 | mLastAddressbookSync = loadedFileVersion; | 2739 | mLastAddressbookSync = loadedFileVersion; |
2737 | qDebug("setting mLastAddressbookSync "); | 2740 | qDebug("setting mLastAddressbookSync "); |
2738 | } | 2741 | } |
2739 | #endif | 2742 | #endif |
2740 | 2743 | ||
2741 | //qDebug("*************************** "); | 2744 | //qDebug("*************************** "); |
2742 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2745 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2743 | QStringList er = remote->uidList(); | 2746 | QStringList er = remote->uidList(); |
2744 | Addressee inR ;//= er.first(); | 2747 | Addressee inR ;//= er.first(); |
2745 | Addressee inL; | 2748 | Addressee inL; |
2746 | QProgressBar bar( er.count(),0 ); | 2749 | QProgressBar bar( er.count(),0 ); |
2747 | bar.setCaption (i18n("Syncing - close to abort!") ); | 2750 | bar.setCaption (i18n("Syncing - close to abort!") ); |
2748 | 2751 | ||
2749 | int w = 300; | 2752 | int w = 300; |
2750 | if ( QApplication::desktop()->width() < 320 ) | 2753 | if ( QApplication::desktop()->width() < 320 ) |
2751 | w = 220; | 2754 | w = 220; |
2752 | int h = bar.sizeHint().height() ; | 2755 | int h = bar.sizeHint().height() ; |
2753 | int dw = QApplication::desktop()->width(); | 2756 | int dw = QApplication::desktop()->width(); |
2754 | int dh = QApplication::desktop()->height(); | 2757 | int dh = QApplication::desktop()->height(); |
2755 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2758 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2756 | bar.show(); | 2759 | bar.show(); |
2757 | int modulo = (er.count()/10)+1; | 2760 | int modulo = (er.count()/10)+1; |
2758 | int incCounter = 0; | 2761 | int incCounter = 0; |
2759 | while ( incCounter < er.count()) { | 2762 | while ( incCounter < er.count()) { |
2760 | if ( ! bar.isVisible() ) | 2763 | if ( ! bar.isVisible() ) |
2761 | return false; | 2764 | return false; |
2762 | if ( incCounter % modulo == 0 ) | 2765 | if ( incCounter % modulo == 0 ) |
2763 | bar.setProgress( incCounter ); | 2766 | bar.setProgress( incCounter ); |
2764 | uid = er[ incCounter ]; | 2767 | uid = er[ incCounter ]; |
2765 | bool skipIncidence = false; | 2768 | bool skipIncidence = false; |
2766 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2769 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2767 | skipIncidence = true; | 2770 | skipIncidence = true; |
2768 | QString idS; | 2771 | QString idS; |
2769 | qApp->processEvents(); | 2772 | qApp->processEvents(); |
2770 | if ( !skipIncidence ) { | 2773 | if ( !skipIncidence ) { |
2771 | inL = local->findByUid( uid ); | 2774 | inL = local->findByUid( uid ); |
2772 | inR = remote->findByUid( uid ); | 2775 | inR = remote->findByUid( uid ); |
2773 | //inL.setResource( 0 ); | 2776 | //inL.setResource( 0 ); |
2774 | //inR.setResource( 0 ); | 2777 | //inR.setResource( 0 ); |
2775 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2778 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2776 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2779 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2777 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2780 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2778 | if ( take == 3 ) | 2781 | if ( take == 3 ) |
2779 | return false; | 2782 | return false; |
2780 | if ( take == 1 ) {// take local | 2783 | if ( take == 1 ) {// take local |
2781 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2784 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2782 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2785 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2783 | local->insertAddressee( inL, false ); | 2786 | local->insertAddressee( inL, false ); |
2784 | } | 2787 | } |
2785 | else | 2788 | else |
2786 | idS = inR.IDStr(); | 2789 | idS = inR.IDStr(); |
2787 | remote->removeAddressee( inR ); | 2790 | remote->removeAddressee( inR ); |
2788 | inR = inL; | 2791 | inR = inL; |
2789 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2792 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2790 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 2793 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
2791 | inR.setIDStr( idS ); | 2794 | inR.setIDStr( idS ); |
2792 | inR.setResource( 0 ); | 2795 | inR.setResource( 0 ); |
2793 | remote->insertAddressee( inR , false); | 2796 | remote->insertAddressee( inR , false); |
2794 | ++changedRemote; | 2797 | ++changedRemote; |
2795 | } else { | 2798 | } else { |
2796 | idS = inL.IDStr(); | 2799 | idS = inL.IDStr(); |
2797 | local->removeAddressee( inL ); | 2800 | local->removeAddressee( inL ); |
2798 | inL = inR; | 2801 | inL = inR; |
2799 | inL.setIDStr( idS ); | 2802 | inL.setIDStr( idS ); |
2800 | inL.setResource( 0 ); | 2803 | inL.setResource( 0 ); |
2801 | local->insertAddressee( inL , false ); | 2804 | local->insertAddressee( inL , false ); |
2802 | ++changedLocal; | 2805 | ++changedLocal; |
2803 | } | 2806 | } |
2804 | } | 2807 | } |
2805 | } else { // no conflict | 2808 | } else { // no conflict |
2806 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2809 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2807 | QString des = addresseeLSync.note(); | 2810 | QString des = addresseeLSync.note(); |
2808 | QString pref = "a"; | 2811 | QString pref = "a"; |
2809 | if ( des.find(pref+ inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2812 | if ( des.find(pref+ inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2810 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2813 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2811 | ++deletedAddresseeR; | 2814 | ++deletedAddresseeR; |
2812 | } else { | 2815 | } else { |
2813 | inR.setRevision( modifiedCalendar ); | 2816 | inR.setRevision( modifiedCalendar ); |
2814 | remote->insertAddressee( inR, false ); | 2817 | remote->insertAddressee( inR, false ); |
2815 | inL = inR; | 2818 | inL = inR; |
2816 | inL.setResource( 0 ); | 2819 | inL.setResource( 0 ); |
2817 | local->insertAddressee( inL , false); | 2820 | local->insertAddressee( inL , false); |
2818 | ++addedAddressee; | 2821 | ++addedAddressee; |
2819 | } | 2822 | } |
2820 | } else { | 2823 | } else { |
2821 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2824 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2822 | inR.setRevision( modifiedCalendar ); | 2825 | inR.setRevision( modifiedCalendar ); |
2823 | remote->insertAddressee( inR, false ); | 2826 | remote->insertAddressee( inR, false ); |
2824 | inR.setResource( 0 ); | 2827 | inR.setResource( 0 ); |
2825 | local->insertAddressee( inR, false ); | 2828 | local->insertAddressee( inR, false ); |
2826 | ++addedAddressee; | 2829 | ++addedAddressee; |
2827 | } else { | 2830 | } else { |
2828 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2831 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2829 | remote->removeAddressee( inR ); | 2832 | remote->removeAddressee( inR ); |
2830 | ++deletedAddresseeR; | 2833 | ++deletedAddresseeR; |
2831 | } | 2834 | } |
2832 | } | 2835 | } |
2833 | } | 2836 | } |
2834 | } | 2837 | } |
2835 | ++incCounter; | 2838 | ++incCounter; |
2836 | } | 2839 | } |
2837 | er.clear(); | 2840 | er.clear(); |
2838 | QStringList el = remote->uidList(); | 2841 | QStringList el = remote->uidList(); |
2839 | modulo = (el.count()/10)+1; | 2842 | modulo = (el.count()/10)+1; |
2840 | bar.setCaption (i18n("Add / remove addressees") ); | 2843 | bar.setCaption (i18n("Add / remove addressees") ); |
2841 | bar.setTotalSteps ( el.count() ) ; | 2844 | bar.setTotalSteps ( el.count() ) ; |
2842 | bar.show(); | 2845 | bar.show(); |
2843 | incCounter = 0; | 2846 | incCounter = 0; |
2844 | while ( incCounter < el.count()) { | 2847 | while ( incCounter < el.count()) { |
2845 | 2848 | ||
2846 | qApp->processEvents(); | 2849 | qApp->processEvents(); |
2847 | if ( ! bar.isVisible() ) | 2850 | if ( ! bar.isVisible() ) |
2848 | return false; | 2851 | return false; |
2849 | if ( incCounter % modulo == 0 ) | 2852 | if ( incCounter % modulo == 0 ) |
2850 | bar.setProgress( incCounter ); | 2853 | bar.setProgress( incCounter ); |
2851 | uid = el[ incCounter ]; | 2854 | uid = el[ incCounter ]; |
2852 | bool skipIncidence = false; | 2855 | bool skipIncidence = false; |
2853 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2856 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2854 | skipIncidence = true; | 2857 | skipIncidence = true; |
2855 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2858 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2856 | skipIncidence = true; | 2859 | skipIncidence = true; |
2857 | if ( !skipIncidence ) { | 2860 | if ( !skipIncidence ) { |
2858 | inL = local->findByUid( uid ); | 2861 | inL = local->findByUid( uid ); |
2859 | inR = remote->findByUid( uid ); | 2862 | inR = remote->findByUid( uid ); |
2860 | if ( inR.isEmpty() ) { | 2863 | if ( inR.isEmpty() ) { |
2861 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2864 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2862 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2865 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2863 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2866 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2864 | local->removeAddressee( inL ); | 2867 | local->removeAddressee( inL ); |
2865 | ++deletedAddresseeL; | 2868 | ++deletedAddresseeL; |
2866 | } else { | 2869 | } else { |
2867 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2870 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2868 | inL.removeID(mCurrentSyncDevice ); | 2871 | inL.removeID(mCurrentSyncDevice ); |
2869 | ++addedAddresseeR; | 2872 | ++addedAddresseeR; |
2870 | //qDebug("remote added Incidence %s ", inL.summary().latin1()); | 2873 | //qDebug("remote added Incidence %s ", inL.summary().latin1()); |
2871 | inL.setRevision( modifiedCalendar ); | 2874 | inL.setRevision( modifiedCalendar ); |
2872 | local->insertAddressee( inL, false ); | 2875 | local->insertAddressee( inL, false ); |
2873 | inR = inL; | 2876 | inR = inL; |
2874 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2877 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2875 | inR.setResource( 0 ); | 2878 | inR.setResource( 0 ); |
2876 | remote->insertAddressee( inR, false ); | 2879 | remote->insertAddressee( inR, false ); |
2877 | } | 2880 | } |
2878 | } | 2881 | } |
2879 | } else { | 2882 | } else { |
2880 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2883 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2881 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2884 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2882 | local->removeAddressee( inL ); | 2885 | local->removeAddressee( inL ); |
2883 | ++deletedAddresseeL; | 2886 | ++deletedAddresseeL; |
2884 | } else { | 2887 | } else { |
2885 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2888 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2886 | ++addedAddresseeR; | 2889 | ++addedAddresseeR; |
2887 | inL.setRevision( modifiedCalendar ); | 2890 | inL.setRevision( modifiedCalendar ); |
2888 | local->insertAddressee( inL, false ); | 2891 | local->insertAddressee( inL, false ); |
2889 | inR = inL; | 2892 | inR = inL; |
2890 | inR.setResource( 0 ); | 2893 | inR.setResource( 0 ); |
2891 | remote->insertAddressee( inR, false ); | 2894 | remote->insertAddressee( inR, false ); |
2892 | } | 2895 | } |
2893 | } | 2896 | } |
2894 | } | 2897 | } |
2895 | } | 2898 | } |
2896 | } | 2899 | } |
2897 | ++incCounter; | 2900 | ++incCounter; |
2898 | } | 2901 | } |
2899 | el.clear(); | 2902 | el.clear(); |
2900 | bar.hide(); | 2903 | bar.hide(); |
2901 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2904 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2902 | // get rid of micro seconds | 2905 | // get rid of micro seconds |
2903 | QTime t = mLastAddressbookSync.time(); | 2906 | QTime t = mLastAddressbookSync.time(); |
2904 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2907 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2905 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2908 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2906 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2909 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2907 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2910 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2908 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2911 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2909 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2912 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2910 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2913 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2911 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2914 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2912 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2915 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2913 | 2916 | ||
2914 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2917 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2915 | remote->insertAddressee( addresseeRSync, false ); | 2918 | remote->insertAddressee( addresseeRSync, false ); |
2916 | local->insertAddressee( addresseeLSync, false ); | 2919 | local->insertAddressee( addresseeLSync, false ); |
2917 | QString mes; | 2920 | QString mes; |
2918 | 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 ); | 2921 | 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 ); |
2919 | if ( KABPrefs::instance()->mShowSyncSummary ) { | 2922 | if ( KABPrefs::instance()->mShowSyncSummary ) { |
2920 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2923 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2921 | } | 2924 | } |
2922 | qDebug( mes ); | 2925 | qDebug( mes ); |
2923 | return syncOK; | 2926 | return syncOK; |
2924 | } | 2927 | } |
2925 | 2928 | ||
2926 | bool KABCore::syncAB(QString filename, int mode) | 2929 | bool KABCore::syncAB(QString filename, int mode) |
2927 | { | 2930 | { |
2928 | 2931 | ||
2929 | //pending prepare addresseeview for output | 2932 | //pending prepare addresseeview for output |
2930 | //pending detect, if remote file has REV field. if not switch to external sync | 2933 | //pending detect, if remote file has REV field. if not switch to external sync |
2931 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2934 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2932 | AddressBook abLocal(filename,"syncContact"); | 2935 | AddressBook abLocal(filename,"syncContact"); |
2933 | bool syncOK = false; | 2936 | bool syncOK = false; |
2934 | if ( abLocal.load() ) { | 2937 | if ( abLocal.load() ) { |
2935 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); | 2938 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); |
2936 | AddressBook::Iterator it; | 2939 | AddressBook::Iterator it; |
2937 | //QStringList vcards; | 2940 | //QStringList vcards; |
2938 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2941 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2939 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2942 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2940 | //} | 2943 | //} |
2941 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2944 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2942 | if ( syncOK ) { | 2945 | if ( syncOK ) { |
2943 | if ( KABPrefs::instance()->mWriteBackFile ) | 2946 | if ( KABPrefs::instance()->mWriteBackFile ) |
2944 | { | 2947 | { |
2945 | qDebug("saving remote AB "); | 2948 | qDebug("saving remote AB "); |
2946 | abLocal.saveAB(); | 2949 | abLocal.saveAB(); |
2947 | } | 2950 | } |
2948 | } | 2951 | } |
2949 | setModified(); | 2952 | setModified(); |
2950 | 2953 | ||
2951 | } | 2954 | } |
2952 | if ( syncOK ) | 2955 | if ( syncOK ) |
2953 | mViewManager->refreshView(); | 2956 | mViewManager->refreshView(); |
2954 | return syncOK; | 2957 | return syncOK; |
2955 | #if 0 | 2958 | #if 0 |
2956 | 2959 | ||
2957 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2960 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2958 | getEventViewerDialog()->setSyncMode( true ); | 2961 | getEventViewerDialog()->setSyncMode( true ); |
2959 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2962 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2960 | getEventViewerDialog()->setSyncMode( false ); | 2963 | getEventViewerDialog()->setSyncMode( false ); |
2961 | if ( syncOK ) { | 2964 | if ( syncOK ) { |
2962 | if ( KOPrefs::instance()->mWriteBackFile ) | 2965 | if ( KOPrefs::instance()->mWriteBackFile ) |
2963 | { | 2966 | { |
2964 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2967 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2965 | storage->save(); | 2968 | storage->save(); |
2966 | } | 2969 | } |
2967 | } | 2970 | } |
2968 | setModified(); | 2971 | setModified(); |
2969 | } | 2972 | } |
2970 | 2973 | ||
2971 | #endif | 2974 | #endif |
2972 | } | 2975 | } |
2973 | 2976 | ||
2974 | 2977 | ||
2975 | void KABCore::confSync() | 2978 | void KABCore::confSync() |
2976 | { | 2979 | { |
2977 | static KSyncPrefsDialog* sp = 0; | 2980 | static KSyncPrefsDialog* sp = 0; |
2978 | if ( ! sp ) { | 2981 | if ( ! sp ) { |
2979 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 2982 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
2980 | } | 2983 | } |
2981 | sp->usrReadConfig(); | 2984 | sp->usrReadConfig(); |
2982 | #ifndef DESKTOP_VERSION | 2985 | #ifndef DESKTOP_VERSION |
2983 | sp->showMaximized(); | 2986 | sp->showMaximized(); |
2984 | #else | 2987 | #else |
2985 | sp->show(); | 2988 | sp->show(); |
2986 | #endif | 2989 | #endif |
2987 | sp->exec(); | 2990 | sp->exec(); |
2988 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 2991 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
2989 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 2992 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
2990 | fillSyncMenu(); | 2993 | fillSyncMenu(); |
2991 | } | 2994 | } |
2992 | void KABCore::syncSharp() | 2995 | void KABCore::syncSharp() |
2993 | { | 2996 | { |
2994 | if ( mModified ) | 2997 | if ( mModified ) |
2995 | save(); | 2998 | save(); |
2996 | qDebug("pending syncSharp() "); | 2999 | qDebug("pending syncSharp() "); |
2997 | //mView->syncSharp(); | 3000 | //mView->syncSharp(); |
2998 | setModified(); | 3001 | setModified(); |
2999 | 3002 | ||
3000 | } | 3003 | } |
3001 | void KABCore::syncPhone() | 3004 | void KABCore::syncPhone() |
3002 | { | 3005 | { |
3003 | if ( mModified ) | 3006 | if ( mModified ) |
3004 | save(); | 3007 | save(); |
3005 | qDebug("pending syncPhone(); "); | 3008 | qDebug("pending syncPhone(); "); |
3006 | //mView->syncPhone(); | 3009 | //mView->syncPhone(); |
3007 | setModified(); | 3010 | setModified(); |
3008 | 3011 | ||
3009 | } | 3012 | } |