author | zautrix <zautrix> | 2004-10-07 22:37:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-07 22:37:40 (UTC) |
commit | 21ec296f7f2832920dac336bb9f9476c80d746f5 (patch) (unidiff) | |
tree | 69b2897665d70ad45da249b1cf374a01d3be6dc4 | |
parent | 4a01915314201cbe2461ce68cdf9c556c687d727 (diff) | |
download | kdepimpi-21ec296f7f2832920dac336bb9f9476c80d746f5.zip kdepimpi-21ec296f7f2832920dac336bb9f9476c80d746f5.tar.gz kdepimpi-21ec296f7f2832920dac336bb9f9476c80d746f5.tar.bz2 |
ab view fixes
-rw-r--r-- | kabc/addressbook.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 2 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 3 |
5 files changed, 12 insertions, 3 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index ed5e9c2..dc3cda1 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1,995 +1,996 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | /*US | 28 | /*US |
29 | 29 | ||
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <kapplication.h> | 34 | #include <kapplication.h> |
35 | #include <kinstance.h> | 35 | #include <kinstance.h> |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | 37 | ||
38 | #include "errorhandler.h" | 38 | #include "errorhandler.h" |
39 | */ | 39 | */ |
40 | #include <qptrlist.h> | 40 | #include <qptrlist.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | 43 | ||
44 | #include <kglobal.h> | 44 | #include <kglobal.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kmessagebox.h> | 46 | #include <kmessagebox.h> |
47 | #include <kdebug.h> | 47 | #include <kdebug.h> |
48 | #include <libkcal/syncdefines.h> | 48 | #include <libkcal/syncdefines.h> |
49 | #include "addressbook.h" | 49 | #include "addressbook.h" |
50 | #include "resource.h" | 50 | #include "resource.h" |
51 | #include "vcardconverter.h" | 51 | #include "vcardconverter.h" |
52 | #include "vcardparser/vcardtool.h" | 52 | #include "vcardparser/vcardtool.h" |
53 | 53 | ||
54 | //US #include "addressbook.moc" | 54 | //US #include "addressbook.moc" |
55 | 55 | ||
56 | using namespace KABC; | 56 | using namespace KABC; |
57 | 57 | ||
58 | struct AddressBook::AddressBookData | 58 | struct AddressBook::AddressBookData |
59 | { | 59 | { |
60 | Addressee::List mAddressees; | 60 | Addressee::List mAddressees; |
61 | Addressee::List mRemovedAddressees; | 61 | Addressee::List mRemovedAddressees; |
62 | Field::List mAllFields; | 62 | Field::List mAllFields; |
63 | KConfig *mConfig; | 63 | KConfig *mConfig; |
64 | KRES::Manager<Resource> *mManager; | 64 | KRES::Manager<Resource> *mManager; |
65 | //US ErrorHandler *mErrorHandler; | 65 | //US ErrorHandler *mErrorHandler; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | struct AddressBook::Iterator::IteratorData | 68 | struct AddressBook::Iterator::IteratorData |
69 | { | 69 | { |
70 | Addressee::List::Iterator mIt; | 70 | Addressee::List::Iterator mIt; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | struct AddressBook::ConstIterator::ConstIteratorData | 73 | struct AddressBook::ConstIterator::ConstIteratorData |
74 | { | 74 | { |
75 | Addressee::List::ConstIterator mIt; | 75 | Addressee::List::ConstIterator mIt; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | AddressBook::Iterator::Iterator() | 78 | AddressBook::Iterator::Iterator() |
79 | { | 79 | { |
80 | d = new IteratorData; | 80 | d = new IteratorData; |
81 | } | 81 | } |
82 | 82 | ||
83 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 83 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
84 | { | 84 | { |
85 | d = new IteratorData; | 85 | d = new IteratorData; |
86 | d->mIt = i.d->mIt; | 86 | d->mIt = i.d->mIt; |
87 | } | 87 | } |
88 | 88 | ||
89 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 89 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
90 | { | 90 | { |
91 | if( this == &i ) return *this; // guard against self assignment | 91 | if( this == &i ) return *this; // guard against self assignment |
92 | delete d; // delete the old data the Iterator was completely constructed before | 92 | delete d; // delete the old data the Iterator was completely constructed before |
93 | d = new IteratorData; | 93 | d = new IteratorData; |
94 | d->mIt = i.d->mIt; | 94 | d->mIt = i.d->mIt; |
95 | return *this; | 95 | return *this; |
96 | } | 96 | } |
97 | 97 | ||
98 | AddressBook::Iterator::~Iterator() | 98 | AddressBook::Iterator::~Iterator() |
99 | { | 99 | { |
100 | delete d; | 100 | delete d; |
101 | } | 101 | } |
102 | 102 | ||
103 | const Addressee &AddressBook::Iterator::operator*() const | 103 | const Addressee &AddressBook::Iterator::operator*() const |
104 | { | 104 | { |
105 | return *(d->mIt); | 105 | return *(d->mIt); |
106 | } | 106 | } |
107 | 107 | ||
108 | Addressee &AddressBook::Iterator::operator*() | 108 | Addressee &AddressBook::Iterator::operator*() |
109 | { | 109 | { |
110 | return *(d->mIt); | 110 | return *(d->mIt); |
111 | } | 111 | } |
112 | 112 | ||
113 | Addressee *AddressBook::Iterator::operator->() | 113 | Addressee *AddressBook::Iterator::operator->() |
114 | { | 114 | { |
115 | return &(*(d->mIt)); | 115 | return &(*(d->mIt)); |
116 | } | 116 | } |
117 | 117 | ||
118 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 118 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
119 | { | 119 | { |
120 | (d->mIt)++; | 120 | (d->mIt)++; |
121 | return *this; | 121 | return *this; |
122 | } | 122 | } |
123 | 123 | ||
124 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 124 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
125 | { | 125 | { |
126 | (d->mIt)++; | 126 | (d->mIt)++; |
127 | return *this; | 127 | return *this; |
128 | } | 128 | } |
129 | 129 | ||
130 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 130 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
131 | { | 131 | { |
132 | (d->mIt)--; | 132 | (d->mIt)--; |
133 | return *this; | 133 | return *this; |
134 | } | 134 | } |
135 | 135 | ||
136 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 136 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
137 | { | 137 | { |
138 | (d->mIt)--; | 138 | (d->mIt)--; |
139 | return *this; | 139 | return *this; |
140 | } | 140 | } |
141 | 141 | ||
142 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 142 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
143 | { | 143 | { |
144 | return ( d->mIt == it.d->mIt ); | 144 | return ( d->mIt == it.d->mIt ); |
145 | } | 145 | } |
146 | 146 | ||
147 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 147 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
148 | { | 148 | { |
149 | return ( d->mIt != it.d->mIt ); | 149 | return ( d->mIt != it.d->mIt ); |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | AddressBook::ConstIterator::ConstIterator() | 153 | AddressBook::ConstIterator::ConstIterator() |
154 | { | 154 | { |
155 | d = new ConstIteratorData; | 155 | d = new ConstIteratorData; |
156 | } | 156 | } |
157 | 157 | ||
158 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 158 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
159 | { | 159 | { |
160 | d = new ConstIteratorData; | 160 | d = new ConstIteratorData; |
161 | d->mIt = i.d->mIt; | 161 | d->mIt = i.d->mIt; |
162 | } | 162 | } |
163 | 163 | ||
164 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 164 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
165 | { | 165 | { |
166 | if( this == &i ) return *this; // guard for self assignment | 166 | if( this == &i ) return *this; // guard for self assignment |
167 | delete d; // delete the old data because the Iterator was really constructed before | 167 | delete d; // delete the old data because the Iterator was really constructed before |
168 | d = new ConstIteratorData; | 168 | d = new ConstIteratorData; |
169 | d->mIt = i.d->mIt; | 169 | d->mIt = i.d->mIt; |
170 | return *this; | 170 | return *this; |
171 | } | 171 | } |
172 | 172 | ||
173 | AddressBook::ConstIterator::~ConstIterator() | 173 | AddressBook::ConstIterator::~ConstIterator() |
174 | { | 174 | { |
175 | delete d; | 175 | delete d; |
176 | } | 176 | } |
177 | 177 | ||
178 | const Addressee &AddressBook::ConstIterator::operator*() const | 178 | const Addressee &AddressBook::ConstIterator::operator*() const |
179 | { | 179 | { |
180 | return *(d->mIt); | 180 | return *(d->mIt); |
181 | } | 181 | } |
182 | 182 | ||
183 | const Addressee* AddressBook::ConstIterator::operator->() const | 183 | const Addressee* AddressBook::ConstIterator::operator->() const |
184 | { | 184 | { |
185 | return &(*(d->mIt)); | 185 | return &(*(d->mIt)); |
186 | } | 186 | } |
187 | 187 | ||
188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
189 | { | 189 | { |
190 | (d->mIt)++; | 190 | (d->mIt)++; |
191 | return *this; | 191 | return *this; |
192 | } | 192 | } |
193 | 193 | ||
194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
195 | { | 195 | { |
196 | (d->mIt)++; | 196 | (d->mIt)++; |
197 | return *this; | 197 | return *this; |
198 | } | 198 | } |
199 | 199 | ||
200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
201 | { | 201 | { |
202 | (d->mIt)--; | 202 | (d->mIt)--; |
203 | return *this; | 203 | return *this; |
204 | } | 204 | } |
205 | 205 | ||
206 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 206 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
207 | { | 207 | { |
208 | (d->mIt)--; | 208 | (d->mIt)--; |
209 | return *this; | 209 | return *this; |
210 | } | 210 | } |
211 | 211 | ||
212 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 212 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
213 | { | 213 | { |
214 | return ( d->mIt == it.d->mIt ); | 214 | return ( d->mIt == it.d->mIt ); |
215 | } | 215 | } |
216 | 216 | ||
217 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 217 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
218 | { | 218 | { |
219 | return ( d->mIt != it.d->mIt ); | 219 | return ( d->mIt != it.d->mIt ); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | AddressBook::AddressBook() | 223 | AddressBook::AddressBook() |
224 | { | 224 | { |
225 | init(0, "contact"); | 225 | init(0, "contact"); |
226 | } | 226 | } |
227 | 227 | ||
228 | AddressBook::AddressBook( const QString &config ) | 228 | AddressBook::AddressBook( const QString &config ) |
229 | { | 229 | { |
230 | init(config, "contact"); | 230 | init(config, "contact"); |
231 | } | 231 | } |
232 | 232 | ||
233 | AddressBook::AddressBook( const QString &config, const QString &family ) | 233 | AddressBook::AddressBook( const QString &config, const QString &family ) |
234 | { | 234 | { |
235 | init(config, family); | 235 | init(config, family); |
236 | 236 | ||
237 | } | 237 | } |
238 | 238 | ||
239 | // the default family is "contact" | 239 | // the default family is "contact" |
240 | void AddressBook::init(const QString &config, const QString &family ) | 240 | void AddressBook::init(const QString &config, const QString &family ) |
241 | { | 241 | { |
242 | blockLSEchange = false; | 242 | blockLSEchange = false; |
243 | d = new AddressBookData; | 243 | d = new AddressBookData; |
244 | QString fami = family; | 244 | QString fami = family; |
245 | if (config != 0) { | 245 | if (config != 0) { |
246 | if ( family == "syncContact" ) { | 246 | if ( family == "syncContact" ) { |
247 | qDebug("creating sync config "); | 247 | qDebug("creating sync config "); |
248 | fami = "contact"; | 248 | fami = "contact"; |
249 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 249 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
250 | con->setGroup( "General" ); | 250 | con->setGroup( "General" ); |
251 | con->writeEntry( "ResourceKeys", QString("sync") ); | 251 | con->writeEntry( "ResourceKeys", QString("sync") ); |
252 | con->writeEntry( "Standard", QString("sync") ); | 252 | con->writeEntry( "Standard", QString("sync") ); |
253 | con->setGroup( "Resource_sync" ); | 253 | con->setGroup( "Resource_sync" ); |
254 | con->writeEntry( "FileName", config ); | 254 | con->writeEntry( "FileName", config ); |
255 | con->writeEntry( "FileFormat", QString("vcard") ); | 255 | con->writeEntry( "FileFormat", QString("vcard") ); |
256 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 256 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
257 | con->writeEntry( "ResourceName", QString("sync_res") ); | 257 | con->writeEntry( "ResourceName", QString("sync_res") ); |
258 | if ( config.right(4) == ".xml" ) | 258 | if ( config.right(4) == ".xml" ) |
259 | con->writeEntry( "ResourceType", QString("qtopia") ); | 259 | con->writeEntry( "ResourceType", QString("qtopia") ); |
260 | else if ( config == "sharp" ) { | 260 | else if ( config == "sharp" ) { |
261 | con->writeEntry( "ResourceType", QString("sharp") ); | 261 | con->writeEntry( "ResourceType", QString("sharp") ); |
262 | } else { | 262 | } else { |
263 | con->writeEntry( "ResourceType", QString("file") ); | 263 | con->writeEntry( "ResourceType", QString("file") ); |
264 | } | 264 | } |
265 | //con->sync(); | 265 | //con->sync(); |
266 | d->mConfig = con; | 266 | d->mConfig = con; |
267 | } | 267 | } |
268 | else | 268 | else |
269 | d->mConfig = new KConfig( locateLocal("config", config) ); | 269 | d->mConfig = new KConfig( locateLocal("config", config) ); |
270 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 270 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
271 | } | 271 | } |
272 | else { | 272 | else { |
273 | d->mConfig = 0; | 273 | d->mConfig = 0; |
274 | // qDebug("AddressBook::init 1 config=0"); | 274 | // qDebug("AddressBook::init 1 config=0"); |
275 | } | 275 | } |
276 | 276 | ||
277 | //US d->mErrorHandler = 0; | 277 | //US d->mErrorHandler = 0; |
278 | d->mManager = new KRES::Manager<Resource>( fami, false ); | 278 | d->mManager = new KRES::Manager<Resource>( fami, false ); |
279 | d->mManager->readConfig( d->mConfig ); | 279 | d->mManager->readConfig( d->mConfig ); |
280 | if ( family == "syncContact" ) { | 280 | if ( family == "syncContact" ) { |
281 | KRES::Manager<Resource> *manager = d->mManager; | 281 | KRES::Manager<Resource> *manager = d->mManager; |
282 | KRES::Manager<Resource>::ActiveIterator it; | 282 | KRES::Manager<Resource>::ActiveIterator it; |
283 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 283 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
284 | (*it)->setAddressBook( this ); | 284 | (*it)->setAddressBook( this ); |
285 | if ( !(*it)->open() ) | 285 | if ( !(*it)->open() ) |
286 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 286 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
287 | } | 287 | } |
288 | Resource *res = standardResource(); | 288 | Resource *res = standardResource(); |
289 | if ( !res ) { | 289 | if ( !res ) { |
290 | qDebug("ERROR: no standard resource"); | 290 | qDebug("ERROR: no standard resource"); |
291 | res = manager->createResource( "file" ); | 291 | res = manager->createResource( "file" ); |
292 | if ( res ) | 292 | if ( res ) |
293 | { | 293 | { |
294 | addResource( res ); | 294 | addResource( res ); |
295 | } | 295 | } |
296 | else | 296 | else |
297 | qDebug(" No resource available!!!"); | 297 | qDebug(" No resource available!!!"); |
298 | } | 298 | } |
299 | setStandardResource( res ); | 299 | setStandardResource( res ); |
300 | manager->writeConfig(); | 300 | manager->writeConfig(); |
301 | } | 301 | } |
302 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 302 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
303 | "X-Department", "KADDRESSBOOK" ); | 303 | "X-Department", "KADDRESSBOOK" ); |
304 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 304 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
305 | "X-Profession", "KADDRESSBOOK" ); | 305 | "X-Profession", "KADDRESSBOOK" ); |
306 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 306 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
307 | "X-AssistantsName", "KADDRESSBOOK" ); | 307 | "X-AssistantsName", "KADDRESSBOOK" ); |
308 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 308 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
309 | "X-ManagersName", "KADDRESSBOOK" ); | 309 | "X-ManagersName", "KADDRESSBOOK" ); |
310 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 310 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
311 | "X-SpousesName", "KADDRESSBOOK" ); | 311 | "X-SpousesName", "KADDRESSBOOK" ); |
312 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
313 | "X-Office", "KADDRESSBOOK" ); | 313 | "X-Office", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
315 | "X-IMAddress", "KADDRESSBOOK" ); | 315 | "X-IMAddress", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
317 | "X-Anniversary", "KADDRESSBOOK" ); | 317 | "X-Anniversary", "KADDRESSBOOK" ); |
318 | 318 | ||
319 | //US added this field to become compatible with Opie/qtopia addressbook | 319 | //US added this field to become compatible with Opie/qtopia addressbook |
320 | // values can be "female" or "male" or "". An empty field represents undefined. | 320 | // values can be "female" or "male" or "". An empty field represents undefined. |
321 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 321 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
322 | "X-Gender", "KADDRESSBOOK" ); | 322 | "X-Gender", "KADDRESSBOOK" ); |
323 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 323 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
324 | "X-Children", "KADDRESSBOOK" ); | 324 | "X-Children", "KADDRESSBOOK" ); |
325 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 325 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
326 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 326 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
327 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 327 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
328 | "X-ExternalID", "KADDRESSBOOK" ); | 328 | "X-ExternalID", "KADDRESSBOOK" ); |
329 | } | 329 | } |
330 | 330 | ||
331 | AddressBook::~AddressBook() | 331 | AddressBook::~AddressBook() |
332 | { | 332 | { |
333 | delete d->mConfig; d->mConfig = 0; | 333 | delete d->mConfig; d->mConfig = 0; |
334 | delete d->mManager; d->mManager = 0; | 334 | delete d->mManager; d->mManager = 0; |
335 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 335 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
336 | delete d; d = 0; | 336 | delete d; d = 0; |
337 | } | 337 | } |
338 | 338 | ||
339 | bool AddressBook::load() | 339 | bool AddressBook::load() |
340 | { | 340 | { |
341 | 341 | ||
342 | 342 | ||
343 | clear(); | 343 | clear(); |
344 | 344 | ||
345 | KRES::Manager<Resource>::ActiveIterator it; | 345 | KRES::Manager<Resource>::ActiveIterator it; |
346 | bool ok = true; | 346 | bool ok = true; |
347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
348 | if ( !(*it)->load() ) { | 348 | if ( !(*it)->load() ) { |
349 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 349 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
350 | ok = false; | 350 | ok = false; |
351 | } | 351 | } |
352 | 352 | ||
353 | // mark all addressees as unchanged | 353 | // mark all addressees as unchanged |
354 | Addressee::List::Iterator addrIt; | 354 | Addressee::List::Iterator addrIt; |
355 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 355 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
356 | (*addrIt).setChanged( false ); | 356 | (*addrIt).setChanged( false ); |
357 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 357 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
358 | if ( !id.isEmpty() ) { | 358 | if ( !id.isEmpty() ) { |
359 | //qDebug("setId aa %s ", id.latin1()); | 359 | //qDebug("setId aa %s ", id.latin1()); |
360 | (*addrIt).setIDStr(id ); | 360 | (*addrIt).setIDStr(id ); |
361 | } | 361 | } |
362 | } | 362 | } |
363 | blockLSEchange = true; | 363 | blockLSEchange = true; |
364 | return ok; | 364 | return ok; |
365 | } | 365 | } |
366 | 366 | ||
367 | bool AddressBook::save( Ticket *ticket ) | 367 | bool AddressBook::save( Ticket *ticket ) |
368 | { | 368 | { |
369 | kdDebug(5700) << "AddressBook::save()"<< endl; | 369 | kdDebug(5700) << "AddressBook::save()"<< endl; |
370 | 370 | ||
371 | if ( ticket->resource() ) { | 371 | if ( ticket->resource() ) { |
372 | deleteRemovedAddressees(); | 372 | deleteRemovedAddressees(); |
373 | return ticket->resource()->save( ticket ); | 373 | return ticket->resource()->save( ticket ); |
374 | } | 374 | } |
375 | 375 | ||
376 | return false; | 376 | return false; |
377 | } | 377 | } |
378 | void AddressBook::export2File( QString fileName ) | 378 | void AddressBook::export2File( QString fileName ) |
379 | { | 379 | { |
380 | 380 | ||
381 | QFile outFile( fileName ); | 381 | QFile outFile( fileName ); |
382 | if ( !outFile.open( IO_WriteOnly ) ) { | 382 | if ( !outFile.open( IO_WriteOnly ) ) { |
383 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 383 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
384 | KMessageBox::error( 0, text.arg( fileName ) ); | 384 | KMessageBox::error( 0, text.arg( fileName ) ); |
385 | return ; | 385 | return ; |
386 | } | 386 | } |
387 | QTextStream t( &outFile ); | 387 | QTextStream t( &outFile ); |
388 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 388 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
389 | Iterator it; | 389 | Iterator it; |
390 | KABC::VCardConverter::Version version; | 390 | KABC::VCardConverter::Version version; |
391 | version = KABC::VCardConverter::v3_0; | 391 | version = KABC::VCardConverter::v3_0; |
392 | for ( it = begin(); it != end(); ++it ) { | 392 | for ( it = begin(); it != end(); ++it ) { |
393 | if ( !(*it).IDStr().isEmpty() ) { | 393 | if ( !(*it).IDStr().isEmpty() ) { |
394 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 394 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
395 | } | 395 | } |
396 | KABC::VCardConverter converter; | 396 | KABC::VCardConverter converter; |
397 | QString vcard; | 397 | QString vcard; |
398 | //Resource *resource() const; | 398 | //Resource *resource() const; |
399 | converter.addresseeToVCard( *it, vcard, version ); | 399 | converter.addresseeToVCard( *it, vcard, version ); |
400 | t << vcard << "\r\n"; | 400 | t << vcard << "\r\n"; |
401 | } | 401 | } |
402 | t << "\r\n\r\n"; | ||
402 | outFile.close(); | 403 | outFile.close(); |
403 | } | 404 | } |
404 | void AddressBook::importFromFile( QString fileName ) | 405 | void AddressBook::importFromFile( QString fileName ) |
405 | { | 406 | { |
406 | 407 | ||
407 | KABC::Addressee::List list; | 408 | KABC::Addressee::List list; |
408 | QFile file( fileName ); | 409 | QFile file( fileName ); |
409 | 410 | ||
410 | file.open( IO_ReadOnly ); | 411 | file.open( IO_ReadOnly ); |
411 | QByteArray rawData = file.readAll(); | 412 | QByteArray rawData = file.readAll(); |
412 | file.close(); | 413 | file.close(); |
413 | 414 | ||
414 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 415 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
415 | KABC::VCardTool tool; | 416 | KABC::VCardTool tool; |
416 | list = tool.parseVCards( data ); | 417 | list = tool.parseVCards( data ); |
417 | KABC::Addressee::List::Iterator it; | 418 | KABC::Addressee::List::Iterator it; |
418 | for ( it = list.begin(); it != list.end(); ++it ) { | 419 | for ( it = list.begin(); it != list.end(); ++it ) { |
419 | (*it).setResource( 0 ); | 420 | (*it).setResource( 0 ); |
420 | insertAddressee( (*it), false, true ); | 421 | insertAddressee( (*it), false, true ); |
421 | } | 422 | } |
422 | 423 | ||
423 | } | 424 | } |
424 | 425 | ||
425 | bool AddressBook::saveAB() | 426 | bool AddressBook::saveAB() |
426 | { | 427 | { |
427 | bool ok = true; | 428 | bool ok = true; |
428 | 429 | ||
429 | deleteRemovedAddressees(); | 430 | deleteRemovedAddressees(); |
430 | Iterator ait; | 431 | Iterator ait; |
431 | for ( ait = begin(); ait != end(); ++ait ) { | 432 | for ( ait = begin(); ait != end(); ++ait ) { |
432 | if ( !(*ait).IDStr().isEmpty() ) { | 433 | if ( !(*ait).IDStr().isEmpty() ) { |
433 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 434 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
434 | } | 435 | } |
435 | } | 436 | } |
436 | KRES::Manager<Resource>::ActiveIterator it; | 437 | KRES::Manager<Resource>::ActiveIterator it; |
437 | KRES::Manager<Resource> *manager = d->mManager; | 438 | KRES::Manager<Resource> *manager = d->mManager; |
438 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 439 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
439 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 440 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
440 | Ticket *ticket = requestSaveTicket( *it ); | 441 | Ticket *ticket = requestSaveTicket( *it ); |
441 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 442 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
442 | if ( !ticket ) { | 443 | if ( !ticket ) { |
443 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 444 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
444 | .arg( (*it)->resourceName() ) ); | 445 | .arg( (*it)->resourceName() ) ); |
445 | return false; | 446 | return false; |
446 | } | 447 | } |
447 | 448 | ||
448 | //if ( !save( ticket ) ) | 449 | //if ( !save( ticket ) ) |
449 | if ( ticket->resource() ) { | 450 | if ( ticket->resource() ) { |
450 | if ( ! ticket->resource()->save( ticket ) ) | 451 | if ( ! ticket->resource()->save( ticket ) ) |
451 | ok = false; | 452 | ok = false; |
452 | } else | 453 | } else |
453 | ok = false; | 454 | ok = false; |
454 | 455 | ||
455 | } | 456 | } |
456 | } | 457 | } |
457 | return ok; | 458 | return ok; |
458 | } | 459 | } |
459 | 460 | ||
460 | AddressBook::Iterator AddressBook::begin() | 461 | AddressBook::Iterator AddressBook::begin() |
461 | { | 462 | { |
462 | Iterator it = Iterator(); | 463 | Iterator it = Iterator(); |
463 | it.d->mIt = d->mAddressees.begin(); | 464 | it.d->mIt = d->mAddressees.begin(); |
464 | return it; | 465 | return it; |
465 | } | 466 | } |
466 | 467 | ||
467 | AddressBook::ConstIterator AddressBook::begin() const | 468 | AddressBook::ConstIterator AddressBook::begin() const |
468 | { | 469 | { |
469 | ConstIterator it = ConstIterator(); | 470 | ConstIterator it = ConstIterator(); |
470 | it.d->mIt = d->mAddressees.begin(); | 471 | it.d->mIt = d->mAddressees.begin(); |
471 | return it; | 472 | return it; |
472 | } | 473 | } |
473 | 474 | ||
474 | AddressBook::Iterator AddressBook::end() | 475 | AddressBook::Iterator AddressBook::end() |
475 | { | 476 | { |
476 | Iterator it = Iterator(); | 477 | Iterator it = Iterator(); |
477 | it.d->mIt = d->mAddressees.end(); | 478 | it.d->mIt = d->mAddressees.end(); |
478 | return it; | 479 | return it; |
479 | } | 480 | } |
480 | 481 | ||
481 | AddressBook::ConstIterator AddressBook::end() const | 482 | AddressBook::ConstIterator AddressBook::end() const |
482 | { | 483 | { |
483 | ConstIterator it = ConstIterator(); | 484 | ConstIterator it = ConstIterator(); |
484 | it.d->mIt = d->mAddressees.end(); | 485 | it.d->mIt = d->mAddressees.end(); |
485 | return it; | 486 | return it; |
486 | } | 487 | } |
487 | 488 | ||
488 | void AddressBook::clear() | 489 | void AddressBook::clear() |
489 | { | 490 | { |
490 | d->mAddressees.clear(); | 491 | d->mAddressees.clear(); |
491 | } | 492 | } |
492 | 493 | ||
493 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 494 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
494 | { | 495 | { |
495 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 496 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
496 | 497 | ||
497 | if ( !resource ) | 498 | if ( !resource ) |
498 | { | 499 | { |
499 | qDebug("AddressBook::requestSaveTicket no resource" ); | 500 | qDebug("AddressBook::requestSaveTicket no resource" ); |
500 | resource = standardResource(); | 501 | resource = standardResource(); |
501 | } | 502 | } |
502 | 503 | ||
503 | KRES::Manager<Resource>::ActiveIterator it; | 504 | KRES::Manager<Resource>::ActiveIterator it; |
504 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 505 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
505 | if ( (*it) == resource ) { | 506 | if ( (*it) == resource ) { |
506 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 507 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
507 | return 0; | 508 | return 0; |
508 | else | 509 | else |
509 | return (*it)->requestSaveTicket(); | 510 | return (*it)->requestSaveTicket(); |
510 | } | 511 | } |
511 | } | 512 | } |
512 | 513 | ||
513 | return 0; | 514 | return 0; |
514 | } | 515 | } |
515 | 516 | ||
516 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 517 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) |
517 | { | 518 | { |
518 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 519 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
519 | //qDebug("block insert "); | 520 | //qDebug("block insert "); |
520 | return; | 521 | return; |
521 | } | 522 | } |
522 | //qDebug("inserting.... %s ",a.uid().latin1() ); | 523 | //qDebug("inserting.... %s ",a.uid().latin1() ); |
523 | bool found = false; | 524 | bool found = false; |
524 | Addressee::List::Iterator it; | 525 | Addressee::List::Iterator it; |
525 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 526 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
526 | if ( a.uid() == (*it).uid() ) { | 527 | if ( a.uid() == (*it).uid() ) { |
527 | 528 | ||
528 | bool changed = false; | 529 | bool changed = false; |
529 | Addressee addr = a; | 530 | Addressee addr = a; |
530 | if ( addr != (*it) ) | 531 | if ( addr != (*it) ) |
531 | changed = true; | 532 | changed = true; |
532 | 533 | ||
533 | if ( takeResource ) { | 534 | if ( takeResource ) { |
534 | Resource * res = (*it).resource(); | 535 | Resource * res = (*it).resource(); |
535 | (*it) = a; | 536 | (*it) = a; |
536 | (*it).setResource( res ); | 537 | (*it).setResource( res ); |
537 | } else { | 538 | } else { |
538 | (*it) = a; | 539 | (*it) = a; |
539 | if ( (*it).resource() == 0 ) | 540 | if ( (*it).resource() == 0 ) |
540 | (*it).setResource( standardResource() ); | 541 | (*it).setResource( standardResource() ); |
541 | } | 542 | } |
542 | if ( changed ) { | 543 | if ( changed ) { |
543 | if ( setRev ) { | 544 | if ( setRev ) { |
544 | 545 | ||
545 | // get rid of micro seconds | 546 | // get rid of micro seconds |
546 | QDateTime dt = QDateTime::currentDateTime(); | 547 | QDateTime dt = QDateTime::currentDateTime(); |
547 | QTime t = dt.time(); | 548 | QTime t = dt.time(); |
548 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 549 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
549 | (*it).setRevision( dt ); | 550 | (*it).setRevision( dt ); |
550 | } | 551 | } |
551 | (*it).setChanged( true ); | 552 | (*it).setChanged( true ); |
552 | } | 553 | } |
553 | 554 | ||
554 | found = true; | 555 | found = true; |
555 | } else { | 556 | } else { |
556 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 557 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
557 | QString name = (*it).uid().mid( 19 ); | 558 | QString name = (*it).uid().mid( 19 ); |
558 | Addressee b = a; | 559 | Addressee b = a; |
559 | QString id = b.getID( name ); | 560 | QString id = b.getID( name ); |
560 | if ( ! id.isEmpty() ) { | 561 | if ( ! id.isEmpty() ) { |
561 | QString des = (*it).note(); | 562 | QString des = (*it).note(); |
562 | int startN; | 563 | int startN; |
563 | if( (startN = des.find( id ) ) >= 0 ) { | 564 | if( (startN = des.find( id ) ) >= 0 ) { |
564 | int endN = des.find( ",", startN+1 ); | 565 | int endN = des.find( ",", startN+1 ); |
565 | des = des.left( startN ) + des.mid( endN+1 ); | 566 | des = des.left( startN ) + des.mid( endN+1 ); |
566 | (*it).setNote( des ); | 567 | (*it).setNote( des ); |
567 | } | 568 | } |
568 | } | 569 | } |
569 | } | 570 | } |
570 | } | 571 | } |
571 | } | 572 | } |
572 | if ( found ) | 573 | if ( found ) |
573 | return; | 574 | return; |
574 | d->mAddressees.append( a ); | 575 | d->mAddressees.append( a ); |
575 | Addressee& addr = d->mAddressees.last(); | 576 | Addressee& addr = d->mAddressees.last(); |
576 | if ( addr.resource() == 0 ) | 577 | if ( addr.resource() == 0 ) |
577 | addr.setResource( standardResource() ); | 578 | addr.setResource( standardResource() ); |
578 | 579 | ||
579 | addr.setChanged( true ); | 580 | addr.setChanged( true ); |
580 | } | 581 | } |
581 | 582 | ||
582 | void AddressBook::removeAddressee( const Addressee &a ) | 583 | void AddressBook::removeAddressee( const Addressee &a ) |
583 | { | 584 | { |
584 | Iterator it; | 585 | Iterator it; |
585 | Iterator it2; | 586 | Iterator it2; |
586 | bool found = false; | 587 | bool found = false; |
587 | for ( it = begin(); it != end(); ++it ) { | 588 | for ( it = begin(); it != end(); ++it ) { |
588 | if ( a.uid() == (*it).uid() ) { | 589 | if ( a.uid() == (*it).uid() ) { |
589 | found = true; | 590 | found = true; |
590 | it2 = it; | 591 | it2 = it; |
591 | } else { | 592 | } else { |
592 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 593 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
593 | QString name = (*it).uid().mid( 19 ); | 594 | QString name = (*it).uid().mid( 19 ); |
594 | Addressee b = a; | 595 | Addressee b = a; |
595 | QString id = b.getID( name ); | 596 | QString id = b.getID( name ); |
596 | if ( ! id.isEmpty() ) { | 597 | if ( ! id.isEmpty() ) { |
597 | QString des = (*it).note(); | 598 | QString des = (*it).note(); |
598 | if( des.find( id ) < 0 ) { | 599 | if( des.find( id ) < 0 ) { |
599 | des += id + ","; | 600 | des += id + ","; |
600 | (*it).setNote( des ); | 601 | (*it).setNote( des ); |
601 | } | 602 | } |
602 | } | 603 | } |
603 | } | 604 | } |
604 | 605 | ||
605 | } | 606 | } |
606 | } | 607 | } |
607 | 608 | ||
608 | if ( found ) | 609 | if ( found ) |
609 | removeAddressee( it2 ); | 610 | removeAddressee( it2 ); |
610 | 611 | ||
611 | } | 612 | } |
612 | 613 | ||
613 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 614 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
614 | { | 615 | { |
615 | Iterator it = begin(); | 616 | Iterator it = begin(); |
616 | Iterator it2 ; | 617 | Iterator it2 ; |
617 | QDateTime dt ( QDate( 2004,1,1) ); | 618 | QDateTime dt ( QDate( 2004,1,1) ); |
618 | while ( it != end() ) { | 619 | while ( it != end() ) { |
619 | (*it).setRevision( dt ); | 620 | (*it).setRevision( dt ); |
620 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 621 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
621 | (*it).setIDStr(""); | 622 | (*it).setIDStr(""); |
622 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 623 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
623 | it2 = it; | 624 | it2 = it; |
624 | //qDebug("removing %s ",(*it).uid().latin1() ); | 625 | //qDebug("removing %s ",(*it).uid().latin1() ); |
625 | ++it; | 626 | ++it; |
626 | removeAddressee( it2 ); | 627 | removeAddressee( it2 ); |
627 | } else { | 628 | } else { |
628 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 629 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
629 | ++it; | 630 | ++it; |
630 | } | 631 | } |
631 | } | 632 | } |
632 | deleteRemovedAddressees(); | 633 | deleteRemovedAddressees(); |
633 | } | 634 | } |
634 | 635 | ||
635 | void AddressBook::removeAddressee( const Iterator &it ) | 636 | void AddressBook::removeAddressee( const Iterator &it ) |
636 | { | 637 | { |
637 | d->mRemovedAddressees.append( (*it) ); | 638 | d->mRemovedAddressees.append( (*it) ); |
638 | d->mAddressees.remove( it.d->mIt ); | 639 | d->mAddressees.remove( it.d->mIt ); |
639 | } | 640 | } |
640 | 641 | ||
641 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 642 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
642 | { | 643 | { |
643 | Iterator it; | 644 | Iterator it; |
644 | for ( it = begin(); it != end(); ++it ) { | 645 | for ( it = begin(); it != end(); ++it ) { |
645 | if ( a.uid() == (*it).uid() ) { | 646 | if ( a.uid() == (*it).uid() ) { |
646 | return it; | 647 | return it; |
647 | } | 648 | } |
648 | } | 649 | } |
649 | return end(); | 650 | return end(); |
650 | } | 651 | } |
651 | 652 | ||
652 | Addressee AddressBook::findByUid( const QString &uid ) | 653 | Addressee AddressBook::findByUid( const QString &uid ) |
653 | { | 654 | { |
654 | Iterator it; | 655 | Iterator it; |
655 | for ( it = begin(); it != end(); ++it ) { | 656 | for ( it = begin(); it != end(); ++it ) { |
656 | if ( uid == (*it).uid() ) { | 657 | if ( uid == (*it).uid() ) { |
657 | return *it; | 658 | return *it; |
658 | } | 659 | } |
659 | } | 660 | } |
660 | return Addressee(); | 661 | return Addressee(); |
661 | } | 662 | } |
662 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) | 663 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) |
663 | { | 664 | { |
664 | //qDebug("AddressBook::preExternSync "); | 665 | //qDebug("AddressBook::preExternSync "); |
665 | AddressBook::Iterator it; | 666 | AddressBook::Iterator it; |
666 | for ( it = begin(); it != end(); ++it ) { | 667 | for ( it = begin(); it != end(); ++it ) { |
667 | (*it).setID( csd, (*it).externalUID() ); | 668 | (*it).setID( csd, (*it).externalUID() ); |
668 | (*it).computeCsum( csd ); | 669 | (*it).computeCsum( csd ); |
669 | } | 670 | } |
670 | mergeAB( aBook ,csd ); | 671 | mergeAB( aBook ,csd ); |
671 | } | 672 | } |
672 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | 673 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) |
673 | { | 674 | { |
674 | //qDebug("AddressBook::postExternSync "); | 675 | //qDebug("AddressBook::postExternSync "); |
675 | AddressBook::Iterator it; | 676 | AddressBook::Iterator it; |
676 | for ( it = begin(); it != end(); ++it ) { | 677 | for ( it = begin(); it != end(); ++it ) { |
677 | // qDebug("check uid %s ", (*it).uid().latin1() ); | 678 | // qDebug("check uid %s ", (*it).uid().latin1() ); |
678 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 679 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
679 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | 680 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { |
680 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 681 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
681 | if ( ad.isEmpty() ) { | 682 | if ( ad.isEmpty() ) { |
682 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); | 683 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); |
683 | } else { | 684 | } else { |
684 | (*it).computeCsum( csd ); | 685 | (*it).computeCsum( csd ); |
685 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 686 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
686 | ad.setID( csd, (*it).externalUID() ); | 687 | ad.setID( csd, (*it).externalUID() ); |
687 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 688 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
688 | aBook->insertAddressee( ad ); | 689 | aBook->insertAddressee( ad ); |
689 | } | 690 | } |
690 | } | 691 | } |
691 | } | 692 | } |
692 | } | 693 | } |
693 | 694 | ||
694 | bool AddressBook::containsExternalUid( const QString& uid ) | 695 | bool AddressBook::containsExternalUid( const QString& uid ) |
695 | { | 696 | { |
696 | Iterator it; | 697 | Iterator it; |
697 | for ( it = begin(); it != end(); ++it ) { | 698 | for ( it = begin(); it != end(); ++it ) { |
698 | if ( uid == (*it).externalUID( ) ) | 699 | if ( uid == (*it).externalUID( ) ) |
699 | return true; | 700 | return true; |
700 | } | 701 | } |
701 | return false; | 702 | return false; |
702 | } | 703 | } |
703 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 704 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) |
704 | { | 705 | { |
705 | Iterator it; | 706 | Iterator it; |
706 | for ( it = begin(); it != end(); ++it ) { | 707 | for ( it = begin(); it != end(); ++it ) { |
707 | if ( uid == (*it).getID( profile ) ) | 708 | if ( uid == (*it).getID( profile ) ) |
708 | return (*it); | 709 | return (*it); |
709 | } | 710 | } |
710 | return Addressee(); | 711 | return Addressee(); |
711 | } | 712 | } |
712 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) | 713 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) |
713 | { | 714 | { |
714 | Iterator it; | 715 | Iterator it; |
715 | Addressee ad; | 716 | Addressee ad; |
716 | for ( it = begin(); it != end(); ++it ) { | 717 | for ( it = begin(); it != end(); ++it ) { |
717 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 718 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
718 | if ( !ad.isEmpty() ) { | 719 | if ( !ad.isEmpty() ) { |
719 | (*it).mergeContact( ad ); | 720 | (*it).mergeContact( ad ); |
720 | } | 721 | } |
721 | } | 722 | } |
722 | #if 0 | 723 | #if 0 |
723 | // test only | 724 | // test only |
724 | for ( it = begin(); it != end(); ++it ) { | 725 | for ( it = begin(); it != end(); ++it ) { |
725 | 726 | ||
726 | qDebug("uid %s ", (*it).uid().latin1()); | 727 | qDebug("uid %s ", (*it).uid().latin1()); |
727 | } | 728 | } |
728 | #endif | 729 | #endif |
729 | } | 730 | } |
730 | 731 | ||
731 | #if 0 | 732 | #if 0 |
732 | Addressee::List AddressBook::getExternLastSyncAddressees() | 733 | Addressee::List AddressBook::getExternLastSyncAddressees() |
733 | { | 734 | { |
734 | Addressee::List results; | 735 | Addressee::List results; |
735 | 736 | ||
736 | Iterator it; | 737 | Iterator it; |
737 | for ( it = begin(); it != end(); ++it ) { | 738 | for ( it = begin(); it != end(); ++it ) { |
738 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 739 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
739 | if ( (*it).familyName().left(4) == "!E: " ) | 740 | if ( (*it).familyName().left(4) == "!E: " ) |
740 | results.append( *it ); | 741 | results.append( *it ); |
741 | } | 742 | } |
742 | } | 743 | } |
743 | 744 | ||
744 | return results; | 745 | return results; |
745 | } | 746 | } |
746 | #endif | 747 | #endif |
747 | void AddressBook::resetTempSyncStat() | 748 | void AddressBook::resetTempSyncStat() |
748 | { | 749 | { |
749 | Iterator it; | 750 | Iterator it; |
750 | for ( it = begin(); it != end(); ++it ) { | 751 | for ( it = begin(); it != end(); ++it ) { |
751 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 752 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
752 | } | 753 | } |
753 | 754 | ||
754 | } | 755 | } |
755 | 756 | ||
756 | QStringList AddressBook:: uidList() | 757 | QStringList AddressBook:: uidList() |
757 | { | 758 | { |
758 | QStringList results; | 759 | QStringList results; |
759 | Iterator it; | 760 | Iterator it; |
760 | for ( it = begin(); it != end(); ++it ) { | 761 | for ( it = begin(); it != end(); ++it ) { |
761 | results.append( (*it).uid() ); | 762 | results.append( (*it).uid() ); |
762 | } | 763 | } |
763 | return results; | 764 | return results; |
764 | } | 765 | } |
765 | 766 | ||
766 | 767 | ||
767 | Addressee::List AddressBook::allAddressees() | 768 | Addressee::List AddressBook::allAddressees() |
768 | { | 769 | { |
769 | return d->mAddressees; | 770 | return d->mAddressees; |
770 | 771 | ||
771 | } | 772 | } |
772 | 773 | ||
773 | Addressee::List AddressBook::findByName( const QString &name ) | 774 | Addressee::List AddressBook::findByName( const QString &name ) |
774 | { | 775 | { |
775 | Addressee::List results; | 776 | Addressee::List results; |
776 | 777 | ||
777 | Iterator it; | 778 | Iterator it; |
778 | for ( it = begin(); it != end(); ++it ) { | 779 | for ( it = begin(); it != end(); ++it ) { |
779 | if ( name == (*it).realName() ) { | 780 | if ( name == (*it).realName() ) { |
780 | results.append( *it ); | 781 | results.append( *it ); |
781 | } | 782 | } |
782 | } | 783 | } |
783 | 784 | ||
784 | return results; | 785 | return results; |
785 | } | 786 | } |
786 | 787 | ||
787 | Addressee::List AddressBook::findByEmail( const QString &email ) | 788 | Addressee::List AddressBook::findByEmail( const QString &email ) |
788 | { | 789 | { |
789 | Addressee::List results; | 790 | Addressee::List results; |
790 | QStringList mailList; | 791 | QStringList mailList; |
791 | 792 | ||
792 | Iterator it; | 793 | Iterator it; |
793 | for ( it = begin(); it != end(); ++it ) { | 794 | for ( it = begin(); it != end(); ++it ) { |
794 | mailList = (*it).emails(); | 795 | mailList = (*it).emails(); |
795 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 796 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
796 | if ( email == (*ite) ) { | 797 | if ( email == (*ite) ) { |
797 | results.append( *it ); | 798 | results.append( *it ); |
798 | } | 799 | } |
799 | } | 800 | } |
800 | } | 801 | } |
801 | 802 | ||
802 | return results; | 803 | return results; |
803 | } | 804 | } |
804 | 805 | ||
805 | Addressee::List AddressBook::findByCategory( const QString &category ) | 806 | Addressee::List AddressBook::findByCategory( const QString &category ) |
806 | { | 807 | { |
807 | Addressee::List results; | 808 | Addressee::List results; |
808 | 809 | ||
809 | Iterator it; | 810 | Iterator it; |
810 | for ( it = begin(); it != end(); ++it ) { | 811 | for ( it = begin(); it != end(); ++it ) { |
811 | if ( (*it).hasCategory( category) ) { | 812 | if ( (*it).hasCategory( category) ) { |
812 | results.append( *it ); | 813 | results.append( *it ); |
813 | } | 814 | } |
814 | } | 815 | } |
815 | 816 | ||
816 | return results; | 817 | return results; |
817 | } | 818 | } |
818 | 819 | ||
819 | void AddressBook::dump() const | 820 | void AddressBook::dump() const |
820 | { | 821 | { |
821 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 822 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
822 | 823 | ||
823 | ConstIterator it; | 824 | ConstIterator it; |
824 | for( it = begin(); it != end(); ++it ) { | 825 | for( it = begin(); it != end(); ++it ) { |
825 | (*it).dump(); | 826 | (*it).dump(); |
826 | } | 827 | } |
827 | 828 | ||
828 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 829 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
829 | } | 830 | } |
830 | 831 | ||
831 | QString AddressBook::identifier() | 832 | QString AddressBook::identifier() |
832 | { | 833 | { |
833 | QStringList identifier; | 834 | QStringList identifier; |
834 | 835 | ||
835 | 836 | ||
836 | KRES::Manager<Resource>::ActiveIterator it; | 837 | KRES::Manager<Resource>::ActiveIterator it; |
837 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 838 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
838 | if ( !(*it)->identifier().isEmpty() ) | 839 | if ( !(*it)->identifier().isEmpty() ) |
839 | identifier.append( (*it)->identifier() ); | 840 | identifier.append( (*it)->identifier() ); |
840 | } | 841 | } |
841 | 842 | ||
842 | return identifier.join( ":" ); | 843 | return identifier.join( ":" ); |
843 | } | 844 | } |
844 | 845 | ||
845 | Field::List AddressBook::fields( int category ) | 846 | Field::List AddressBook::fields( int category ) |
846 | { | 847 | { |
847 | if ( d->mAllFields.isEmpty() ) { | 848 | if ( d->mAllFields.isEmpty() ) { |
848 | d->mAllFields = Field::allFields(); | 849 | d->mAllFields = Field::allFields(); |
849 | } | 850 | } |
850 | 851 | ||
851 | if ( category == Field::All ) return d->mAllFields; | 852 | if ( category == Field::All ) return d->mAllFields; |
852 | 853 | ||
853 | Field::List result; | 854 | Field::List result; |
854 | Field::List::ConstIterator it; | 855 | Field::List::ConstIterator it; |
855 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 856 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
856 | if ( (*it)->category() & category ) result.append( *it ); | 857 | if ( (*it)->category() & category ) result.append( *it ); |
857 | } | 858 | } |
858 | 859 | ||
859 | return result; | 860 | return result; |
860 | } | 861 | } |
861 | 862 | ||
862 | bool AddressBook::addCustomField( const QString &label, int category, | 863 | bool AddressBook::addCustomField( const QString &label, int category, |
863 | const QString &key, const QString &app ) | 864 | const QString &key, const QString &app ) |
864 | { | 865 | { |
865 | if ( d->mAllFields.isEmpty() ) { | 866 | if ( d->mAllFields.isEmpty() ) { |
866 | d->mAllFields = Field::allFields(); | 867 | d->mAllFields = Field::allFields(); |
867 | } | 868 | } |
868 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 869 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
869 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 870 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
870 | 871 | ||
871 | QString k = key.isNull() ? label : key; | 872 | QString k = key.isNull() ? label : key; |
872 | 873 | ||
873 | Field *field = Field::createCustomField( label, category, k, a ); | 874 | Field *field = Field::createCustomField( label, category, k, a ); |
874 | 875 | ||
875 | if ( !field ) return false; | 876 | if ( !field ) return false; |
876 | 877 | ||
877 | d->mAllFields.append( field ); | 878 | d->mAllFields.append( field ); |
878 | 879 | ||
879 | return true; | 880 | return true; |
880 | } | 881 | } |
881 | 882 | ||
882 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 883 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
883 | { | 884 | { |
884 | if (!ab.d) return s; | 885 | if (!ab.d) return s; |
885 | 886 | ||
886 | return s << ab.d->mAddressees; | 887 | return s << ab.d->mAddressees; |
887 | } | 888 | } |
888 | 889 | ||
889 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 890 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
890 | { | 891 | { |
891 | if (!ab.d) return s; | 892 | if (!ab.d) return s; |
892 | 893 | ||
893 | s >> ab.d->mAddressees; | 894 | s >> ab.d->mAddressees; |
894 | 895 | ||
895 | return s; | 896 | return s; |
896 | } | 897 | } |
897 | 898 | ||
898 | bool AddressBook::addResource( Resource *resource ) | 899 | bool AddressBook::addResource( Resource *resource ) |
899 | { | 900 | { |
900 | if ( !resource->open() ) { | 901 | if ( !resource->open() ) { |
901 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 902 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
902 | return false; | 903 | return false; |
903 | } | 904 | } |
904 | 905 | ||
905 | resource->setAddressBook( this ); | 906 | resource->setAddressBook( this ); |
906 | 907 | ||
907 | d->mManager->add( resource ); | 908 | d->mManager->add( resource ); |
908 | return true; | 909 | return true; |
909 | } | 910 | } |
910 | 911 | ||
911 | bool AddressBook::removeResource( Resource *resource ) | 912 | bool AddressBook::removeResource( Resource *resource ) |
912 | { | 913 | { |
913 | resource->close(); | 914 | resource->close(); |
914 | 915 | ||
915 | if ( resource == standardResource() ) | 916 | if ( resource == standardResource() ) |
916 | d->mManager->setStandardResource( 0 ); | 917 | d->mManager->setStandardResource( 0 ); |
917 | 918 | ||
918 | resource->setAddressBook( 0 ); | 919 | resource->setAddressBook( 0 ); |
919 | 920 | ||
920 | d->mManager->remove( resource ); | 921 | d->mManager->remove( resource ); |
921 | return true; | 922 | return true; |
922 | } | 923 | } |
923 | 924 | ||
924 | QPtrList<Resource> AddressBook::resources() | 925 | QPtrList<Resource> AddressBook::resources() |
925 | { | 926 | { |
926 | QPtrList<Resource> list; | 927 | QPtrList<Resource> list; |
927 | 928 | ||
928 | // qDebug("AddressBook::resources() 1"); | 929 | // qDebug("AddressBook::resources() 1"); |
929 | 930 | ||
930 | KRES::Manager<Resource>::ActiveIterator it; | 931 | KRES::Manager<Resource>::ActiveIterator it; |
931 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 932 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
932 | list.append( *it ); | 933 | list.append( *it ); |
933 | 934 | ||
934 | return list; | 935 | return list; |
935 | } | 936 | } |
936 | 937 | ||
937 | /*US | 938 | /*US |
938 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 939 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
939 | { | 940 | { |
940 | delete d->mErrorHandler; | 941 | delete d->mErrorHandler; |
941 | d->mErrorHandler = handler; | 942 | d->mErrorHandler = handler; |
942 | } | 943 | } |
943 | */ | 944 | */ |
944 | 945 | ||
945 | void AddressBook::error( const QString& msg ) | 946 | void AddressBook::error( const QString& msg ) |
946 | { | 947 | { |
947 | /*US | 948 | /*US |
948 | if ( !d->mErrorHandler ) // create default error handler | 949 | if ( !d->mErrorHandler ) // create default error handler |
949 | d->mErrorHandler = new ConsoleErrorHandler; | 950 | d->mErrorHandler = new ConsoleErrorHandler; |
950 | 951 | ||
951 | if ( d->mErrorHandler ) | 952 | if ( d->mErrorHandler ) |
952 | d->mErrorHandler->error( msg ); | 953 | d->mErrorHandler->error( msg ); |
953 | else | 954 | else |
954 | kdError(5700) << "no error handler defined" << endl; | 955 | kdError(5700) << "no error handler defined" << endl; |
955 | */ | 956 | */ |
956 | kdDebug(5700) << "msg" << endl; | 957 | kdDebug(5700) << "msg" << endl; |
957 | qDebug(msg); | 958 | qDebug(msg); |
958 | } | 959 | } |
959 | 960 | ||
960 | void AddressBook::deleteRemovedAddressees() | 961 | void AddressBook::deleteRemovedAddressees() |
961 | { | 962 | { |
962 | Addressee::List::Iterator it; | 963 | Addressee::List::Iterator it; |
963 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 964 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
964 | Resource *resource = (*it).resource(); | 965 | Resource *resource = (*it).resource(); |
965 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 966 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
966 | resource->removeAddressee( *it ); | 967 | resource->removeAddressee( *it ); |
967 | } | 968 | } |
968 | 969 | ||
969 | d->mRemovedAddressees.clear(); | 970 | d->mRemovedAddressees.clear(); |
970 | } | 971 | } |
971 | 972 | ||
972 | void AddressBook::setStandardResource( Resource *resource ) | 973 | void AddressBook::setStandardResource( Resource *resource ) |
973 | { | 974 | { |
974 | // qDebug("AddressBook::setStandardResource 1"); | 975 | // qDebug("AddressBook::setStandardResource 1"); |
975 | d->mManager->setStandardResource( resource ); | 976 | d->mManager->setStandardResource( resource ); |
976 | } | 977 | } |
977 | 978 | ||
978 | Resource *AddressBook::standardResource() | 979 | Resource *AddressBook::standardResource() |
979 | { | 980 | { |
980 | return d->mManager->standardResource(); | 981 | return d->mManager->standardResource(); |
981 | } | 982 | } |
982 | 983 | ||
983 | KRES::Manager<Resource> *AddressBook::resourceManager() | 984 | KRES::Manager<Resource> *AddressBook::resourceManager() |
984 | { | 985 | { |
985 | return d->mManager; | 986 | return d->mManager; |
986 | } | 987 | } |
987 | 988 | ||
988 | void AddressBook::cleanUp() | 989 | void AddressBook::cleanUp() |
989 | { | 990 | { |
990 | KRES::Manager<Resource>::ActiveIterator it; | 991 | KRES::Manager<Resource>::ActiveIterator it; |
991 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 992 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
992 | if ( !(*it)->readOnly() && (*it)->isOpen() ) | 993 | if ( !(*it)->readOnly() && (*it)->isOpen() ) |
993 | (*it)->cleanUp(); | 994 | (*it)->cleanUp(); |
994 | } | 995 | } |
995 | } | 996 | } |
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 8d0fca1..4babf67 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp | |||
@@ -1,446 +1,448 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qdragobject.h> | 24 | #include <qdragobject.h> |
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qiconview.h> | 26 | #include <qiconview.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | 30 | ||
31 | #include <kabc/addressbook.h> | 31 | #include <kabc/addressbook.h> |
32 | #include <kabc/addressee.h> | 32 | #include <kabc/addressee.h> |
33 | #include <kconfig.h> | 33 | #include <kconfig.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | 36 | ||
37 | #include "kabprefs.h" | 37 | #include "kabprefs.h" |
38 | #include "viewmanager.h" | 38 | #include "viewmanager.h" |
39 | 39 | ||
40 | #include "kaddressbookcardview.h" | 40 | #include "kaddressbookcardview.h" |
41 | 41 | ||
42 | #ifndef KAB_EMBEDDED | 42 | #ifndef KAB_EMBEDDED |
43 | extern "C" { | 43 | extern "C" { |
44 | void *init_libkaddrbk_cardview() | 44 | void *init_libkaddrbk_cardview() |
45 | { | 45 | { |
46 | return ( new CardViewFactory ); | 46 | return ( new CardViewFactory ); |
47 | } | 47 | } |
48 | } | 48 | } |
49 | #endif //KAB_EMBEDDED | 49 | #endif //KAB_EMBEDDED |
50 | 50 | ||
51 | //////////////////////////////// | 51 | //////////////////////////////// |
52 | // AddresseeCardViewItem (internal class) | 52 | // AddresseeCardViewItem (internal class) |
53 | class AddresseeCardViewItem : public CardViewItem | 53 | class AddresseeCardViewItem : public CardViewItem |
54 | { | 54 | { |
55 | public: | 55 | public: |
56 | AddresseeCardViewItem(const KABC::Field::List &fields, | 56 | AddresseeCardViewItem(const KABC::Field::List &fields, |
57 | bool showEmptyFields, | 57 | bool showEmptyFields, |
58 | KABC::AddressBook *doc, const KABC::Addressee &a, | 58 | KABC::AddressBook *doc, const KABC::Addressee &a, |
59 | CardView *parent) | 59 | CardView *parent) |
60 | : CardViewItem(parent, a.formattedName()), | 60 | : CardViewItem(parent, a.formattedName()), |
61 | mFields( fields ), mShowEmptyFields(showEmptyFields), | 61 | mFields( fields ), mShowEmptyFields(showEmptyFields), |
62 | mDocument(doc), mAddressee(a) | 62 | mDocument(doc), mAddressee(a) |
63 | { | 63 | { |
64 | if ( mFields.isEmpty() ) { | 64 | if ( mFields.isEmpty() ) { |
65 | mFields = KABC::Field::defaultFields(); | 65 | mFields = KABC::Field::defaultFields(); |
66 | } | 66 | } |
67 | refresh(); | 67 | refresh(); |
68 | } | 68 | } |
69 | 69 | ||
70 | const KABC::Addressee &addressee() const { return mAddressee; } | 70 | const KABC::Addressee &addressee() const { return mAddressee; } |
71 | 71 | ||
72 | void refresh() | 72 | void refresh() |
73 | { | 73 | { |
74 | // Update our addressee, since it may have changed elsewhere | 74 | // Update our addressee, since it may have changed elsewhere |
75 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 75 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
76 | 76 | ||
77 | if (!mAddressee.isEmpty()) | 77 | if (!mAddressee.isEmpty()) |
78 | { | 78 | { |
79 | clearFields(); | 79 | clearFields(); |
80 | 80 | ||
81 | // Try all the selected fields until we find one with text. | 81 | // Try all the selected fields until we find one with text. |
82 | // This will limit the number of unlabeled icons in the view | 82 | // This will limit the number of unlabeled icons in the view |
83 | KABC::Field::List::Iterator iter; | 83 | KABC::Field::List::Iterator iter; |
84 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) | 84 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) |
85 | { | 85 | { |
86 | // insert empty fields or not? not doing so saves a bit of memory and CPU | 86 | // insert empty fields or not? not doing so saves a bit of memory and CPU |
87 | // (during geometry calculations), but prevents having equally | 87 | // (during geometry calculations), but prevents having equally |
88 | // wide label columns in all cards, unless CardViewItem/CardView search | 88 | // wide label columns in all cards, unless CardViewItem/CardView search |
89 | // globally for the widest label. (anders) | 89 | // globally for the widest label. (anders) |
90 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) | 90 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) |
91 | insertField((*iter)->label(), (*iter)->value( mAddressee )); | 91 | insertField((*iter)->label(), (*iter)->value( mAddressee )); |
92 | } | 92 | } |
93 | 93 | ||
94 | // We might want to make this the first field. hmm... -mpilone | 94 | // We might want to make this the first field. hmm... -mpilone |
95 | setCaption( mAddressee.realName() ); | 95 | setCaption( mAddressee.realName() ); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | private: | 99 | private: |
100 | KABC::Field::List mFields; | 100 | KABC::Field::List mFields; |
101 | bool mShowEmptyFields; | 101 | bool mShowEmptyFields; |
102 | KABC::AddressBook *mDocument; | 102 | KABC::AddressBook *mDocument; |
103 | KABC::Addressee mAddressee; | 103 | KABC::Addressee mAddressee; |
104 | }; | 104 | }; |
105 | 105 | ||
106 | /////////////////////////////// | 106 | /////////////////////////////// |
107 | // AddresseeCardView | 107 | // AddresseeCardView |
108 | 108 | ||
109 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) | 109 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) |
110 | : CardView(parent, name) | 110 | : CardView(parent, name) |
111 | { | 111 | { |
112 | setAcceptDrops(true); | 112 | setAcceptDrops(true); |
113 | } | 113 | } |
114 | 114 | ||
115 | AddresseeCardView::~AddresseeCardView() | 115 | AddresseeCardView::~AddresseeCardView() |
116 | { | 116 | { |
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
120 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) | 120 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) |
121 | { | 121 | { |
122 | #ifndef KAB_EMBEDDED | 122 | #ifndef KAB_EMBEDDED |
123 | if (QTextDrag::canDecode(e)) | 123 | if (QTextDrag::canDecode(e)) |
124 | e->accept(); | 124 | e->accept(); |
125 | #else //KAB_EMBEDDED | 125 | #else //KAB_EMBEDDED |
126 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); | 126 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); |
127 | #endif //KAB_EMBEDDED | 127 | #endif //KAB_EMBEDDED |
128 | } | 128 | } |
129 | 129 | ||
130 | void AddresseeCardView::dropEvent(QDropEvent *e) | 130 | void AddresseeCardView::dropEvent(QDropEvent *e) |
131 | { | 131 | { |
132 | emit addresseeDropped(e); | 132 | emit addresseeDropped(e); |
133 | } | 133 | } |
134 | 134 | ||
135 | void AddresseeCardView::startDrag() | 135 | void AddresseeCardView::startDrag() |
136 | { | 136 | { |
137 | emit startAddresseeDrag(); | 137 | emit startAddresseeDrag(); |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | /////////////////////////////// | 141 | /////////////////////////////// |
142 | // KAddressBookCardView | 142 | // KAddressBookCardView |
143 | 143 | ||
144 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, | 144 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, |
145 | QWidget *parent, const char *name ) | 145 | QWidget *parent, const char *name ) |
146 | : KAddressBookView( ab, parent, name ) | 146 | : KAddressBookView( ab, parent, name ) |
147 | { | 147 | { |
148 | mShowEmptyFields = false; | 148 | mShowEmptyFields = false; |
149 | 149 | ||
150 | // Init the GUI | 150 | // Init the GUI |
151 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 151 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
152 | 152 | ||
153 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); | 153 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); |
154 | mCardView->setSelectionMode(CardView::Extended); | 154 | mCardView->setSelectionMode(CardView::Extended); |
155 | layout->addWidget(mCardView); | 155 | layout->addWidget(mCardView); |
156 | 156 | ||
157 | // Connect up the signals | 157 | // Connect up the signals |
158 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 158 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
159 | this, SLOT(addresseeExecuted(CardViewItem *))); | 159 | this, SLOT(addresseeExecuted(CardViewItem *))); |
160 | connect(mCardView, SIGNAL(selectionChanged()), | 160 | connect(mCardView, SIGNAL(selectionChanged()), |
161 | this, SLOT(addresseeSelected())); | 161 | this, SLOT(addresseeSelected())); |
162 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), | 162 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), |
163 | this, SIGNAL(dropped(QDropEvent*))); | 163 | this, SIGNAL(dropped(QDropEvent*))); |
164 | connect(mCardView, SIGNAL(startAddresseeDrag()), | 164 | connect(mCardView, SIGNAL(startAddresseeDrag()), |
165 | this, SIGNAL(startDrag())); | 165 | this, SIGNAL(startDrag())); |
166 | } | 166 | } |
167 | 167 | ||
168 | KAddressBookCardView::~KAddressBookCardView() | 168 | KAddressBookCardView::~KAddressBookCardView() |
169 | { | 169 | { |
170 | } | 170 | } |
171 | 171 | ||
172 | void KAddressBookCardView::readConfig(KConfig *config) | 172 | void KAddressBookCardView::readConfig(KConfig *config) |
173 | { | 173 | { |
174 | KAddressBookView::readConfig(config); | 174 | KAddressBookView::readConfig(config); |
175 | 175 | ||
176 | // costum colors? | 176 | // costum colors? |
177 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 177 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
178 | { | 178 | { |
179 | QPalette p( mCardView->palette() ); | 179 | QPalette p( mCardView->palette() ); |
180 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 180 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
181 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 181 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
182 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 182 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
183 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 183 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
184 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 184 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
185 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 185 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
186 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 186 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
187 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 187 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
188 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 188 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
189 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 189 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
190 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 190 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
191 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 191 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
192 | mCardView->viewport()->setPalette( p ); | 192 | mCardView->viewport()->setPalette( p ); |
193 | } | 193 | } |
194 | else | 194 | else |
195 | { | 195 | { |
196 | // needed if turned off during a session. | 196 | // needed if turned off during a session. |
197 | mCardView->viewport()->setPalette( mCardView->palette() ); | 197 | mCardView->viewport()->setPalette( mCardView->palette() ); |
198 | } | 198 | } |
199 | 199 | ||
200 | //custom fonts? | 200 | //custom fonts? |
201 | QFont f( font() ); | 201 | QFont f( font() ); |
202 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 202 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
203 | { | 203 | { |
204 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); | 204 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); |
205 | f.setBold( true ); | 205 | f.setBold( true ); |
206 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 206 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
207 | } | 207 | } |
208 | else | 208 | else |
209 | { | 209 | { |
210 | mCardView->setFont( f ); | 210 | mCardView->setFont( f ); |
211 | f.setBold( true ); | 211 | f.setBold( true ); |
212 | mCardView->setHeaderFont( f ); | 212 | mCardView->setHeaderFont( f ); |
213 | } | 213 | } |
214 | 214 | ||
215 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); | 215 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); |
216 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", | 216 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", |
217 | true)); | 217 | true)); |
218 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); | 218 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); |
219 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); | 219 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); |
220 | 220 | ||
221 | mCardView->setShowEmptyFields( mShowEmptyFields ); | 221 | mCardView->setShowEmptyFields( mShowEmptyFields ); |
222 | 222 | ||
223 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); | 223 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); |
224 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); | 224 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); |
225 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); | 225 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); |
226 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); | 226 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); |
227 | 227 | ||
228 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), | 228 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), |
229 | this, SLOT(addresseeExecuted(CardViewItem *))); | 229 | this, SLOT(addresseeExecuted(CardViewItem *))); |
230 | 230 | ||
231 | if (KABPrefs::instance()->mHonorSingleClick) | 231 | if (KABPrefs::instance()->mHonorSingleClick) |
232 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 232 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
233 | this, SLOT(addresseeExecuted(CardViewItem *))); | 233 | this, SLOT(addresseeExecuted(CardViewItem *))); |
234 | else | 234 | else |
235 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 235 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
236 | this, SLOT(addresseeExecuted(CardViewItem *))); | 236 | this, SLOT(addresseeExecuted(CardViewItem *))); |
237 | 237 | ||
238 | } | 238 | } |
239 | 239 | ||
240 | void KAddressBookCardView::writeConfig( KConfig *config ) | 240 | void KAddressBookCardView::writeConfig( KConfig *config ) |
241 | { | 241 | { |
242 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); | 242 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); |
243 | KAddressBookView::writeConfig( config ); | 243 | KAddressBookView::writeConfig( config ); |
244 | } | 244 | } |
245 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | 245 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) |
246 | { | 246 | { |
247 | mCardView->clear(); | 247 | mCardView->clear(); |
248 | if ( s.isEmpty() || s == "*" ) { | 248 | if ( s.isEmpty() || s == "*" ) { |
249 | refresh(); | 249 | refresh(); |
250 | return; | 250 | return; |
251 | } | 251 | } |
252 | QString pattern = s.lower()+"*"; | 252 | QString pattern = s.lower()+"*"; |
253 | QRegExp re; | 253 | QRegExp re; |
254 | re.setWildcard(true); // most people understand these better. | 254 | re.setWildcard(true); // most people understand these better. |
255 | re.setCaseSensitive(false); | 255 | re.setCaseSensitive(false); |
256 | re.setPattern( pattern ); | 256 | re.setPattern( pattern ); |
257 | if (!re.isValid()) | 257 | if (!re.isValid()) |
258 | return; | 258 | return; |
259 | mCardView->viewport()->setUpdatesEnabled( false ); | 259 | mCardView->viewport()->setUpdatesEnabled( false ); |
260 | KABC::Addressee::List addresseeList = addressees(); | 260 | KABC::Addressee::List addresseeList = addressees(); |
261 | KABC::Addressee::List::Iterator it; | 261 | KABC::Addressee::List::Iterator it; |
262 | if ( field ) { | 262 | if ( field ) { |
263 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 263 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
264 | #if QT_VERSION >= 300 | 264 | #if QT_VERSION >= 300 |
265 | if (re.search(field->value( *it ).lower()) != -1) | 265 | if (re.search(field->value( *it ).lower()) != -1) |
266 | #else | 266 | #else |
267 | if (re.match(field->value( *it ).lower()) != -1) | 267 | if (re.match(field->value( *it ).lower()) != -1) |
268 | #endif | 268 | #endif |
269 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 269 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
270 | addressBook(), *it, mCardView); | 270 | addressBook(), *it, mCardView); |
271 | 271 | ||
272 | } | 272 | } |
273 | } else { | 273 | } else { |
274 | KABC::Field::List fieldList = fields(); | 274 | KABC::Field::List fieldList = fields(); |
275 | KABC::Field::List::ConstIterator fieldIt; | 275 | KABC::Field::List::ConstIterator fieldIt; |
276 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 276 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
277 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 277 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
278 | #if QT_VERSION >= 300 | 278 | #if QT_VERSION >= 300 |
279 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 279 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
280 | #else | 280 | #else |
281 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 281 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
282 | #endif | 282 | #endif |
283 | { | 283 | { |
284 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 284 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
285 | addressBook(), *it, mCardView); | 285 | addressBook(), *it, mCardView); |
286 | continue; | 286 | continue; |
287 | } | 287 | } |
288 | } | 288 | } |
289 | } | 289 | } |
290 | } | 290 | } |
291 | mCardView->viewport()->setUpdatesEnabled( true ); | 291 | mCardView->viewport()->setUpdatesEnabled( true ); |
292 | mCardView->viewport()->update(); | 292 | mCardView->viewport()->update(); |
293 | // by default nothing is selected | 293 | // by default nothing is selected |
294 | emit selected(QString::null); | 294 | emit selected(QString::null); |
295 | } | 295 | } |
296 | QStringList KAddressBookCardView::selectedUids() | 296 | QStringList KAddressBookCardView::selectedUids() |
297 | { | 297 | { |
298 | QStringList uidList; | 298 | QStringList uidList; |
299 | CardViewItem *item; | 299 | CardViewItem *item; |
300 | AddresseeCardViewItem *aItem; | 300 | AddresseeCardViewItem *aItem; |
301 | 301 | ||
302 | for (item = mCardView->firstItem(); item; item = item->nextItem()) | 302 | for (item = mCardView->firstItem(); item; item = item->nextItem()) |
303 | { | 303 | { |
304 | if (item->isSelected()) | 304 | if (item->isSelected()) |
305 | { | 305 | { |
306 | #ifndef KAB_EMBEDDED | 306 | #ifndef KAB_EMBEDDED |
307 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 307 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
308 | #else //KAB_EMBEDDED | 308 | #else //KAB_EMBEDDED |
309 | aItem = (AddresseeCardViewItem*)(item); | 309 | aItem = (AddresseeCardViewItem*)(item); |
310 | #endif //KAB_EMBEDDED | 310 | #endif //KAB_EMBEDDED |
311 | if (aItem) | 311 | if (aItem) |
312 | uidList << aItem->addressee().uid(); | 312 | uidList << aItem->addressee().uid(); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | return uidList; | 316 | return uidList; |
317 | } | 317 | } |
318 | 318 | ||
319 | void KAddressBookCardView::refresh(QString uid) | 319 | void KAddressBookCardView::refresh(QString uid) |
320 | { | 320 | { |
321 | CardViewItem *item; | 321 | CardViewItem *item; |
322 | AddresseeCardViewItem *aItem; | 322 | AddresseeCardViewItem *aItem; |
323 | 323 | ||
324 | if (uid.isNull()) | 324 | if (uid.isNull()) |
325 | { | 325 | { |
326 | // Rebuild the view | 326 | // Rebuild the view |
327 | mCardView->viewport()->setUpdatesEnabled( false ); | 327 | mCardView->viewport()->setUpdatesEnabled( false ); |
328 | mCardView->clear(); | 328 | mCardView->clear(); |
329 | 329 | ||
330 | KABC::Addressee::List addresseeList = addressees(); | 330 | KABC::Addressee::List addresseeList = addressees(); |
331 | KABC::Addressee::List::Iterator iter; | 331 | KABC::Addressee::List::Iterator iter; |
332 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) | 332 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) |
333 | { | 333 | { |
334 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) | ||
335 | continue; | ||
334 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, | 336 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, |
335 | addressBook(), *iter, mCardView); | 337 | addressBook(), *iter, mCardView); |
336 | } | 338 | } |
337 | mCardView->viewport()->setUpdatesEnabled( true ); | 339 | mCardView->viewport()->setUpdatesEnabled( true ); |
338 | mCardView->viewport()->update(); | 340 | mCardView->viewport()->update(); |
339 | 341 | ||
340 | // by default nothing is selected | 342 | // by default nothing is selected |
341 | emit selected(QString::null); | 343 | emit selected(QString::null); |
342 | } | 344 | } |
343 | else | 345 | else |
344 | { | 346 | { |
345 | // Try to find the one to refresh | 347 | // Try to find the one to refresh |
346 | bool found = false; | 348 | bool found = false; |
347 | for (item = mCardView->firstItem(); item && !found; | 349 | for (item = mCardView->firstItem(); item && !found; |
348 | item = item->nextItem()) | 350 | item = item->nextItem()) |
349 | { | 351 | { |
350 | #ifndef KAB_EMBEDDED | 352 | #ifndef KAB_EMBEDDED |
351 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 353 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
352 | #else //KAB_EMBEDDED | 354 | #else //KAB_EMBEDDED |
353 | aItem = (AddresseeCardViewItem*)(item); | 355 | aItem = (AddresseeCardViewItem*)(item); |
354 | #endif //KAB_EMBEDDED | 356 | #endif //KAB_EMBEDDED |
355 | 357 | ||
356 | if ((aItem) && (aItem->addressee().uid() == uid)) | 358 | if ((aItem) && (aItem->addressee().uid() == uid)) |
357 | { | 359 | { |
358 | aItem->refresh(); | 360 | aItem->refresh(); |
359 | found = true; | 361 | found = true; |
360 | } | 362 | } |
361 | } | 363 | } |
362 | } | 364 | } |
363 | } | 365 | } |
364 | 366 | ||
365 | void KAddressBookCardView::setSelected(QString uid, bool selected) | 367 | void KAddressBookCardView::setSelected(QString uid, bool selected) |
366 | { | 368 | { |
367 | CardViewItem *item; | 369 | CardViewItem *item; |
368 | AddresseeCardViewItem *aItem; | 370 | AddresseeCardViewItem *aItem; |
369 | 371 | ||
370 | if (uid.isNull()) | 372 | if (uid.isNull()) |
371 | { | 373 | { |
372 | mCardView->selectAll(selected); | 374 | mCardView->selectAll(selected); |
373 | } | 375 | } |
374 | else | 376 | else |
375 | { | 377 | { |
376 | bool found = false; | 378 | bool found = false; |
377 | for (item = mCardView->firstItem(); item && !found; | 379 | for (item = mCardView->firstItem(); item && !found; |
378 | item = item->nextItem()) | 380 | item = item->nextItem()) |
379 | { | 381 | { |
380 | #ifndef KAB_EMBEDDED | 382 | #ifndef KAB_EMBEDDED |
381 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 383 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
382 | #else //KAB_EMBEDDED | 384 | #else //KAB_EMBEDDED |
383 | aItem = (AddresseeCardViewItem*)(item); | 385 | aItem = (AddresseeCardViewItem*)(item); |
384 | #endif //KAB_EMBEDDED | 386 | #endif //KAB_EMBEDDED |
385 | 387 | ||
386 | if ((aItem) && (aItem->addressee().uid() == uid)) | 388 | if ((aItem) && (aItem->addressee().uid() == uid)) |
387 | { | 389 | { |
388 | mCardView->setSelected(aItem, selected); | 390 | mCardView->setSelected(aItem, selected); |
389 | mCardView->ensureItemVisible(item); | 391 | mCardView->ensureItemVisible(item); |
390 | found = true; | 392 | found = true; |
391 | } | 393 | } |
392 | } | 394 | } |
393 | } | 395 | } |
394 | } | 396 | } |
395 | 397 | ||
396 | //US added an additional method without parameter | 398 | //US added an additional method without parameter |
397 | void KAddressBookCardView::setSelected() | 399 | void KAddressBookCardView::setSelected() |
398 | { | 400 | { |
399 | setSelected(QString::null, true); | 401 | setSelected(QString::null, true); |
400 | } | 402 | } |
401 | 403 | ||
402 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) | 404 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) |
403 | { | 405 | { |
404 | #ifndef KAB_EMBEDDED | 406 | #ifndef KAB_EMBEDDED |
405 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 407 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
406 | #else //KAB_EMBEDDED | 408 | #else //KAB_EMBEDDED |
407 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); | 409 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); |
408 | #endif //KAB_EMBEDDED | 410 | #endif //KAB_EMBEDDED |
409 | if (aItem) | 411 | if (aItem) |
410 | { | 412 | { |
411 | //kdDebug()<<"... even has a valid item:)"<<endl; | 413 | //kdDebug()<<"... even has a valid item:)"<<endl; |
412 | emit executed(aItem->addressee().uid()); | 414 | emit executed(aItem->addressee().uid()); |
413 | } | 415 | } |
414 | } | 416 | } |
415 | 417 | ||
416 | void KAddressBookCardView::addresseeSelected() | 418 | void KAddressBookCardView::addresseeSelected() |
417 | { | 419 | { |
418 | CardViewItem *item; | 420 | CardViewItem *item; |
419 | AddresseeCardViewItem *aItem; | 421 | AddresseeCardViewItem *aItem; |
420 | 422 | ||
421 | bool found = false; | 423 | bool found = false; |
422 | for (item = mCardView->firstItem(); item && !found; | 424 | for (item = mCardView->firstItem(); item && !found; |
423 | item = item->nextItem()) | 425 | item = item->nextItem()) |
424 | { | 426 | { |
425 | if (item->isSelected()) | 427 | if (item->isSelected()) |
426 | { | 428 | { |
427 | #ifndef KAB_EMBEDDED | 429 | #ifndef KAB_EMBEDDED |
428 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 430 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
429 | #else //KAB_EMBEDDED | 431 | #else //KAB_EMBEDDED |
430 | aItem = (AddresseeCardViewItem*)(item); | 432 | aItem = (AddresseeCardViewItem*)(item); |
431 | #endif //KAB_EMBEDDED | 433 | #endif //KAB_EMBEDDED |
432 | if ( aItem ) | 434 | if ( aItem ) |
433 | { | 435 | { |
434 | emit selected(aItem->addressee().uid()); | 436 | emit selected(aItem->addressee().uid()); |
435 | found = true; | 437 | found = true; |
436 | } | 438 | } |
437 | } | 439 | } |
438 | } | 440 | } |
439 | 441 | ||
440 | if (!found) | 442 | if (!found) |
441 | emit selected(QString::null); | 443 | emit selected(QString::null); |
442 | 444 | ||
443 | } | 445 | } |
444 | #ifndef KAB_EMBEDDED | 446 | #ifndef KAB_EMBEDDED |
445 | #include "kaddressbookcardview.moc" | 447 | #include "kaddressbookcardview.moc" |
446 | #endif //KAB_EMBEDDED | 448 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index 0ffc674..fdc0db9 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp | |||
@@ -1,426 +1,429 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KAB_EMBEDDED | 24 | #ifndef KAB_EMBEDDED |
25 | #include <qiconview.h> | 25 | #include <qiconview.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | 27 | ||
28 | #include <kabc/addressee.h> | 28 | #include <kabc/addressee.h> |
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | #include <kdebug.h> | 30 | #include <kdebug.h> |
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #else //KAB_EMBEDDED | 35 | #else //KAB_EMBEDDED |
36 | #endif //KAB_EMBEDDED | 36 | #endif //KAB_EMBEDDED |
37 | 37 | ||
38 | #include <kabc/addressbook.h> | 38 | #include <kabc/addressbook.h> |
39 | #include "kabprefs.h" | 39 | #include "kabprefs.h" |
40 | #include "viewmanager.h" | 40 | #include "viewmanager.h" |
41 | #include "kaddressbookiconview.h" | 41 | #include "kaddressbookiconview.h" |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <kglobal.h> | 44 | #include <kglobal.h> |
45 | /*US transfered to the headerfile | 45 | /*US transfered to the headerfile |
46 | class IconViewFactory : public ViewFactory | 46 | class IconViewFactory : public ViewFactory |
47 | { | 47 | { |
48 | public: | 48 | public: |
49 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 49 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
50 | { | 50 | { |
51 | return new KAddressBookIconView( ab, parent, name ); | 51 | return new KAddressBookIconView( ab, parent, name ); |
52 | } | 52 | } |
53 | 53 | ||
54 | QString type() const { return "Icon"; } | 54 | QString type() const { return "Icon"; } |
55 | 55 | ||
56 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } | 56 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } |
57 | }; | 57 | }; |
58 | 58 | ||
59 | */ | 59 | */ |
60 | 60 | ||
61 | extern "C" { | 61 | extern "C" { |
62 | void *init_libkaddrbk_iconview() | 62 | void *init_libkaddrbk_iconview() |
63 | { | 63 | { |
64 | return ( new IconViewFactory ); | 64 | return ( new IconViewFactory ); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | //////////////////////////////// | 68 | //////////////////////////////// |
69 | // AddresseeIconView (internal class) | 69 | // AddresseeIconView (internal class) |
70 | #ifndef KAB_EMBEDDED | 70 | #ifndef KAB_EMBEDDED |
71 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 71 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
72 | : KIconView(parent, name) | 72 | : KIconView(parent, name) |
73 | #else //KAB_EMBEDDED | 73 | #else //KAB_EMBEDDED |
74 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 74 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
75 | : QIconView(parent, name) | 75 | : QIconView(parent, name) |
76 | #endif //KAB_EMBEDDED | 76 | #endif //KAB_EMBEDDED |
77 | 77 | ||
78 | { | 78 | { |
79 | setSelectionMode( QIconView::Extended ); | 79 | setSelectionMode( QIconView::Extended ); |
80 | setResizeMode( QIconView::Adjust ); | 80 | setResizeMode( QIconView::Adjust ); |
81 | setWordWrapIconText( true ); | 81 | setWordWrapIconText( true ); |
82 | setGridX( 100 ); | 82 | setGridX( 100 ); |
83 | setItemsMovable(false); | 83 | setItemsMovable(false); |
84 | setSorting(true, true); | 84 | setSorting(true, true); |
85 | 85 | ||
86 | 86 | ||
87 | //US ??? setMode( KIconView::Select ); | 87 | //US ??? setMode( KIconView::Select ); |
88 | 88 | ||
89 | #ifndef KAB_EMBEDDED | 89 | #ifndef KAB_EMBEDDED |
90 | 90 | ||
91 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), | 91 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), |
92 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); | 92 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); |
93 | #endif //KAB_EMBEDDED | 93 | #endif //KAB_EMBEDDED |
94 | } | 94 | } |
95 | 95 | ||
96 | AddresseeIconView::~AddresseeIconView() | 96 | AddresseeIconView::~AddresseeIconView() |
97 | { | 97 | { |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | void AddresseeIconView::itemDropped(QDropEvent *e, | 101 | void AddresseeIconView::itemDropped(QDropEvent *e, |
102 | const QValueList<QIconDragItem> &) | 102 | const QValueList<QIconDragItem> &) |
103 | { | 103 | { |
104 | emit addresseeDropped(e); | 104 | emit addresseeDropped(e); |
105 | } | 105 | } |
106 | 106 | ||
107 | QDragObject *AddresseeIconView::dragObject() | 107 | QDragObject *AddresseeIconView::dragObject() |
108 | { | 108 | { |
109 | emit startAddresseeDrag(); | 109 | emit startAddresseeDrag(); |
110 | 110 | ||
111 | // We never want IconView to start the drag | 111 | // We never want IconView to start the drag |
112 | return 0; | 112 | return 0; |
113 | } | 113 | } |
114 | //////////////////////////////// | 114 | //////////////////////////////// |
115 | // AddresseeIconViewItem (internal class) | 115 | // AddresseeIconViewItem (internal class) |
116 | #ifndef KAB_EMBEDDED | 116 | #ifndef KAB_EMBEDDED |
117 | class AddresseeIconViewItem : public KIconViewItem | 117 | class AddresseeIconViewItem : public KIconViewItem |
118 | #else //KAB_EMBEDDED | 118 | #else //KAB_EMBEDDED |
119 | class AddresseeIconViewItem : public QIconViewItem | 119 | class AddresseeIconViewItem : public QIconViewItem |
120 | #endif //KAB_EMBEDDED | 120 | #endif //KAB_EMBEDDED |
121 | { | 121 | { |
122 | public: | 122 | public: |
123 | #ifndef KAB_EMBEDDED | 123 | #ifndef KAB_EMBEDDED |
124 | AddresseeIconViewItem(const KABC::Field::List &fields, | 124 | AddresseeIconViewItem(const KABC::Field::List &fields, |
125 | KABC::AddressBook *doc, const KABC::Addressee &a, | 125 | KABC::AddressBook *doc, const KABC::Addressee &a, |
126 | QIconView *parent) | 126 | QIconView *parent) |
127 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 127 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
128 | #else //KAB_EMBEDDED | 128 | #else //KAB_EMBEDDED |
129 | AddresseeIconViewItem(const KABC::Field::List &fields, | 129 | AddresseeIconViewItem(const KABC::Field::List &fields, |
130 | KABC::AddressBook *doc, const KABC::Addressee &a, | 130 | KABC::AddressBook *doc, const KABC::Addressee &a, |
131 | QIconView *parent) | 131 | QIconView *parent) |
132 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 132 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
133 | #endif //KAB_EMBEDDED | 133 | #endif //KAB_EMBEDDED |
134 | { | 134 | { |
135 | if ( mFields.isEmpty() ) { | 135 | if ( mFields.isEmpty() ) { |
136 | mFields = KABC::Field::defaultFields(); | 136 | mFields = KABC::Field::defaultFields(); |
137 | } | 137 | } |
138 | refresh(); | 138 | refresh(); |
139 | } | 139 | } |
140 | 140 | ||
141 | const KABC::Addressee &addressee() const { return mAddressee; } | 141 | const KABC::Addressee &addressee() const { return mAddressee; } |
142 | 142 | ||
143 | void refresh() | 143 | void refresh() |
144 | { | 144 | { |
145 | // Update our addressee, since it may have changed elsewhere | 145 | // Update our addressee, since it may have changed elsewhere |
146 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 146 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
147 | 147 | ||
148 | if (!mAddressee.isEmpty()) | 148 | if (!mAddressee.isEmpty()) |
149 | setText( mAddressee.givenName() + " " + mAddressee.familyName() ); | 149 | setText( mAddressee.givenName() + " " + mAddressee.familyName() ); |
150 | 150 | ||
151 | QPixmap icon; | 151 | QPixmap icon; |
152 | QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); | 152 | QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); |
153 | KABC::Picture pic = mAddressee.photo(); | 153 | KABC::Picture pic = mAddressee.photo(); |
154 | if ( pic.data().isNull() ) | 154 | if ( pic.data().isNull() ) |
155 | pic = mAddressee.logo(); | 155 | pic = mAddressee.logo(); |
156 | 156 | ||
157 | if ( pic.isIntern() && !pic.data().isNull() ) { | 157 | if ( pic.isIntern() && !pic.data().isNull() ) { |
158 | QImage img = pic.data(); | 158 | QImage img = pic.data(); |
159 | #ifndef KAB_EMBEDDED | 159 | #ifndef KAB_EMBEDDED |
160 | if ( img.width() > img.height() ) | 160 | if ( img.width() > img.height() ) |
161 | icon = img.scaleWidth( 32 ); | 161 | icon = img.scaleWidth( 32 ); |
162 | else | 162 | else |
163 | icon = img.scaleHeight( 32 ); | 163 | icon = img.scaleHeight( 32 ); |
164 | #else //KAB_EMBEDDED | 164 | #else //KAB_EMBEDDED |
165 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); | 165 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); |
166 | icon.convertFromImage(img.smoothScale(32, 32)); | 166 | icon.convertFromImage(img.smoothScale(32, 32)); |
167 | #endif //KAB_EMBEDDED | 167 | #endif //KAB_EMBEDDED |
168 | 168 | ||
169 | } else | 169 | } else |
170 | icon = defaultIcon; | 170 | icon = defaultIcon; |
171 | 171 | ||
172 | setPixmap( icon ); | 172 | setPixmap( icon ); |
173 | } | 173 | } |
174 | 174 | ||
175 | private: | 175 | private: |
176 | KABC::Field::List mFields; | 176 | KABC::Field::List mFields; |
177 | KABC::AddressBook *mDocument; | 177 | KABC::AddressBook *mDocument; |
178 | KABC::Addressee mAddressee; | 178 | KABC::Addressee mAddressee; |
179 | }; | 179 | }; |
180 | 180 | ||
181 | /////////////////////////////// | 181 | /////////////////////////////// |
182 | // KAddressBookView | 182 | // KAddressBookView |
183 | 183 | ||
184 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, | 184 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, |
185 | QWidget *parent, const char *name) | 185 | QWidget *parent, const char *name) |
186 | : KAddressBookView( ab, parent, name ) | 186 | : KAddressBookView( ab, parent, name ) |
187 | { | 187 | { |
188 | // Init the GUI | 188 | // Init the GUI |
189 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 189 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
190 | 190 | ||
191 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); | 191 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); |
192 | layout->addWidget(mIconView); | 192 | layout->addWidget(mIconView); |
193 | 193 | ||
194 | // Connect up the signals | 194 | // Connect up the signals |
195 | 195 | ||
196 | //US method executed is part of KIconView | 196 | //US method executed is part of KIconView |
197 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 197 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
198 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 198 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
199 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 199 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
200 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 200 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
201 | 201 | ||
202 | connect(mIconView, SIGNAL(selectionChanged()), | 202 | connect(mIconView, SIGNAL(selectionChanged()), |
203 | this, SLOT(addresseeSelected())); | 203 | this, SLOT(addresseeSelected())); |
204 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), | 204 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), |
205 | this, SIGNAL(dropped(QDropEvent*))); | 205 | this, SIGNAL(dropped(QDropEvent*))); |
206 | connect(mIconView, SIGNAL(startAddresseeDrag()), | 206 | connect(mIconView, SIGNAL(startAddresseeDrag()), |
207 | this, SIGNAL(startDrag())); | 207 | this, SIGNAL(startDrag())); |
208 | } | 208 | } |
209 | 209 | ||
210 | KAddressBookIconView::~KAddressBookIconView() | 210 | KAddressBookIconView::~KAddressBookIconView() |
211 | { | 211 | { |
212 | } | 212 | } |
213 | 213 | ||
214 | void KAddressBookIconView::readConfig(KConfig *config) | 214 | void KAddressBookIconView::readConfig(KConfig *config) |
215 | { | 215 | { |
216 | KAddressBookView::readConfig(config); | 216 | KAddressBookView::readConfig(config); |
217 | 217 | ||
218 | //US method executed is part of KIconView | 218 | //US method executed is part of KIconView |
219 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), | 219 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), |
220 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 220 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
221 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 221 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
222 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 222 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
223 | 223 | ||
224 | //US method executed is part of KIconView. Use selectionChanged instead | 224 | //US method executed is part of KIconView. Use selectionChanged instead |
225 | /*US | 225 | /*US |
226 | if (KABPrefs::instance()->mHonorSingleClick) | 226 | if (KABPrefs::instance()->mHonorSingleClick) |
227 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 227 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
228 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 228 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
229 | else | 229 | else |
230 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), | 230 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), |
231 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 231 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
232 | */ | 232 | */ |
233 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 233 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
234 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 234 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
235 | 235 | ||
236 | } | 236 | } |
237 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | 237 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) |
238 | { | 238 | { |
239 | mIconView->clear(); | 239 | mIconView->clear(); |
240 | mIconList.clear(); | 240 | mIconList.clear(); |
241 | if ( s.isEmpty() || s == "*" ) { | 241 | if ( s.isEmpty() || s == "*" ) { |
242 | refresh(); | 242 | refresh(); |
243 | return; | 243 | return; |
244 | } | 244 | } |
245 | QString pattern = s.lower()+"*"; | 245 | QString pattern = s.lower()+"*"; |
246 | QRegExp re; | 246 | QRegExp re; |
247 | re.setWildcard(true); // most people understand these better. | 247 | re.setWildcard(true); // most people understand these better. |
248 | re.setCaseSensitive(false); | 248 | re.setCaseSensitive(false); |
249 | re.setPattern( pattern ); | 249 | re.setPattern( pattern ); |
250 | if (!re.isValid()) | 250 | if (!re.isValid()) |
251 | return; | 251 | return; |
252 | KABC::Addressee::List addresseeList = addressees(); | 252 | KABC::Addressee::List addresseeList = addressees(); |
253 | KABC::Addressee::List::Iterator it; | 253 | KABC::Addressee::List::Iterator it; |
254 | if ( field ) { | 254 | if ( field ) { |
255 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 255 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
256 | #if QT_VERSION >= 300 | 256 | #if QT_VERSION >= 300 |
257 | if (re.search(field->value( *it ).lower()) != -1) | 257 | if (re.search(field->value( *it ).lower()) != -1) |
258 | #else | 258 | #else |
259 | if (re.match(field->value( *it ).lower()) != -1) | 259 | if (re.match(field->value( *it ).lower()) != -1) |
260 | #endif | 260 | #endif |
261 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | 261 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); |
262 | 262 | ||
263 | 263 | ||
264 | } | 264 | } |
265 | } else { | 265 | } else { |
266 | KABC::Field::List fieldList = fields(); | 266 | KABC::Field::List fieldList = fields(); |
267 | KABC::Field::List::ConstIterator fieldIt; | 267 | KABC::Field::List::ConstIterator fieldIt; |
268 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 268 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
269 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 269 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
270 | #if QT_VERSION >= 300 | 270 | #if QT_VERSION >= 300 |
271 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 271 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
272 | #else | 272 | #else |
273 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 273 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
274 | #endif | 274 | #endif |
275 | { | 275 | { |
276 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | 276 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); |
277 | continue; | 277 | continue; |
278 | } | 278 | } |
279 | } | 279 | } |
280 | } | 280 | } |
281 | } | 281 | } |
282 | mIconView->arrangeItemsInGrid( true ); | 282 | mIconView->arrangeItemsInGrid( true ); |
283 | } | 283 | } |
284 | QStringList KAddressBookIconView::selectedUids() | 284 | QStringList KAddressBookIconView::selectedUids() |
285 | { | 285 | { |
286 | QStringList uidList; | 286 | QStringList uidList; |
287 | QIconViewItem *item; | 287 | QIconViewItem *item; |
288 | AddresseeIconViewItem *aItem; | 288 | AddresseeIconViewItem *aItem; |
289 | 289 | ||
290 | for (item = mIconView->firstItem(); item; item = item->nextItem()) | 290 | for (item = mIconView->firstItem(); item; item = item->nextItem()) |
291 | { | 291 | { |
292 | if (item->isSelected()) | 292 | if (item->isSelected()) |
293 | { | 293 | { |
294 | #ifndef KAB_EMBEDDED | 294 | #ifndef KAB_EMBEDDED |
295 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 295 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
296 | #else //KAB_EMBEDDED | 296 | #else //KAB_EMBEDDED |
297 | aItem = (AddresseeIconViewItem*)(item); | 297 | aItem = (AddresseeIconViewItem*)(item); |
298 | #endif //KAB_EMBEDDED | 298 | #endif //KAB_EMBEDDED |
299 | if (aItem) | 299 | if (aItem) |
300 | uidList << aItem->addressee().uid(); | 300 | uidList << aItem->addressee().uid(); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | return uidList; | 304 | return uidList; |
305 | } | 305 | } |
306 | 306 | ||
307 | void KAddressBookIconView::refresh(QString uid) | 307 | void KAddressBookIconView::refresh(QString uid) |
308 | { | 308 | { |
309 | QIconViewItem *item; | 309 | QIconViewItem *item; |
310 | AddresseeIconViewItem *aItem; | 310 | AddresseeIconViewItem *aItem; |
311 | 311 | ||
312 | if ( uid.isNull() ) { | 312 | if ( uid.isNull() ) { |
313 | // Rebuild the view | 313 | // Rebuild the view |
314 | mIconView->clear(); | 314 | mIconView->clear(); |
315 | mIconList.clear(); | 315 | mIconList.clear(); |
316 | 316 | ||
317 | KABC::Addressee::List addresseeList = addressees(); | 317 | KABC::Addressee::List addresseeList = addressees(); |
318 | KABC::Addressee::List::Iterator iter; | 318 | KABC::Addressee::List::Iterator iter; |
319 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) | 319 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { |
320 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); | 320 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) |
321 | continue; | ||
322 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); | ||
323 | } | ||
321 | 324 | ||
322 | mIconView->arrangeItemsInGrid( true ); | 325 | mIconView->arrangeItemsInGrid( true ); |
323 | 326 | ||
324 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) | 327 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) |
325 | { | 328 | { |
326 | #ifndef KAB_EMBEDDED | 329 | #ifndef KAB_EMBEDDED |
327 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); | 330 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); |
328 | #else //KAB_EMBEDDED | 331 | #else //KAB_EMBEDDED |
329 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); | 332 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); |
330 | #endif //KAB_EMBEDDED | 333 | #endif //KAB_EMBEDDED |
331 | mIconList.append( aivi ); | 334 | mIconList.append( aivi ); |
332 | } | 335 | } |
333 | 336 | ||
334 | } else { | 337 | } else { |
335 | // Try to find the one to refresh | 338 | // Try to find the one to refresh |
336 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { | 339 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { |
337 | #ifndef KAB_EMBEDDED | 340 | #ifndef KAB_EMBEDDED |
338 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 341 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
339 | #else //KAB_EMBEDDED | 342 | #else //KAB_EMBEDDED |
340 | aItem = (AddresseeIconViewItem*)(item); | 343 | aItem = (AddresseeIconViewItem*)(item); |
341 | #endif //KAB_EMBEDDED | 344 | #endif //KAB_EMBEDDED |
342 | if ((aItem) && (aItem->addressee().uid() == uid)) { | 345 | if ((aItem) && (aItem->addressee().uid() == uid)) { |
343 | aItem->refresh(); | 346 | aItem->refresh(); |
344 | mIconView->arrangeItemsInGrid( true ); | 347 | mIconView->arrangeItemsInGrid( true ); |
345 | return; | 348 | return; |
346 | } | 349 | } |
347 | } | 350 | } |
348 | refresh( QString::null ); | 351 | refresh( QString::null ); |
349 | } | 352 | } |
350 | } | 353 | } |
351 | 354 | ||
352 | void KAddressBookIconView::setSelected(QString uid, bool selected) | 355 | void KAddressBookIconView::setSelected(QString uid, bool selected) |
353 | { | 356 | { |
354 | QIconViewItem *item; | 357 | QIconViewItem *item; |
355 | AddresseeIconViewItem *aItem; | 358 | AddresseeIconViewItem *aItem; |
356 | 359 | ||
357 | if (uid.isNull()) | 360 | if (uid.isNull()) |
358 | { | 361 | { |
359 | mIconView->selectAll(selected); | 362 | mIconView->selectAll(selected); |
360 | } | 363 | } |
361 | else | 364 | else |
362 | { | 365 | { |
363 | bool found = false; | 366 | bool found = false; |
364 | for (item = mIconView->firstItem(); item && !found; | 367 | for (item = mIconView->firstItem(); item && !found; |
365 | item = item->nextItem()) | 368 | item = item->nextItem()) |
366 | { | 369 | { |
367 | #ifndef KAB_EMBEDDED | 370 | #ifndef KAB_EMBEDDED |
368 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 371 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
369 | #else //KAB_EMBEDDED | 372 | #else //KAB_EMBEDDED |
370 | aItem = (AddresseeIconViewItem*)(item); | 373 | aItem = (AddresseeIconViewItem*)(item); |
371 | #endif //KAB_EMBEDDED | 374 | #endif //KAB_EMBEDDED |
372 | 375 | ||
373 | if ((aItem) && (aItem->addressee().uid() == uid)) | 376 | if ((aItem) && (aItem->addressee().uid() == uid)) |
374 | { | 377 | { |
375 | mIconView->setSelected(aItem, selected); | 378 | mIconView->setSelected(aItem, selected); |
376 | mIconView->ensureItemVisible( aItem ); | 379 | mIconView->ensureItemVisible( aItem ); |
377 | found = true; | 380 | found = true; |
378 | } | 381 | } |
379 | } | 382 | } |
380 | } | 383 | } |
381 | } | 384 | } |
382 | 385 | ||
383 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) | 386 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) |
384 | { | 387 | { |
385 | #ifndef KAB_EMBEDDED | 388 | #ifndef KAB_EMBEDDED |
386 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 389 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
387 | #else //KAB_EMBEDDED | 390 | #else //KAB_EMBEDDED |
388 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); | 391 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); |
389 | #endif //KAB_EMBEDDED | 392 | #endif //KAB_EMBEDDED |
390 | 393 | ||
391 | if (aItem) { | 394 | if (aItem) { |
392 | emit executed(aItem->addressee().uid()); | 395 | emit executed(aItem->addressee().uid()); |
393 | } | 396 | } |
394 | } | 397 | } |
395 | 398 | ||
396 | void KAddressBookIconView::addresseeSelected() | 399 | void KAddressBookIconView::addresseeSelected() |
397 | { | 400 | { |
398 | QIconViewItem *item; | 401 | QIconViewItem *item; |
399 | AddresseeIconViewItem *aItem; | 402 | AddresseeIconViewItem *aItem; |
400 | 403 | ||
401 | bool found = false; | 404 | bool found = false; |
402 | for (item = mIconView->firstItem(); item && !found; | 405 | for (item = mIconView->firstItem(); item && !found; |
403 | item = item->nextItem()) | 406 | item = item->nextItem()) |
404 | { | 407 | { |
405 | if (item->isSelected()) | 408 | if (item->isSelected()) |
406 | { | 409 | { |
407 | #ifndef KAB_EMBEDDED | 410 | #ifndef KAB_EMBEDDED |
408 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 411 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
409 | #else //KAB_EMBEDDED | 412 | #else //KAB_EMBEDDED |
410 | aItem = (AddresseeIconViewItem*)(item); | 413 | aItem = (AddresseeIconViewItem*)(item); |
411 | #endif //KAB_EMBEDDED | 414 | #endif //KAB_EMBEDDED |
412 | if (aItem) | 415 | if (aItem) |
413 | { | 416 | { |
414 | emit selected(aItem->addressee().uid()); | 417 | emit selected(aItem->addressee().uid()); |
415 | found = true; | 418 | found = true; |
416 | } | 419 | } |
417 | } | 420 | } |
418 | } | 421 | } |
419 | 422 | ||
420 | if (!found) | 423 | if (!found) |
421 | emit selected(QString::null); | 424 | emit selected(QString::null); |
422 | } | 425 | } |
423 | 426 | ||
424 | #ifndef KAB_EMBEDDED | 427 | #ifndef KAB_EMBEDDED |
425 | #include "kaddressbookiconview.moc" | 428 | #include "kaddressbookiconview.moc" |
426 | #endif //KAB_EMBEDDED | 429 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 1dc9198..fbfddba 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -1,443 +1,445 @@ | |||
1 | // $Id$ | 1 | // $Id$ |
2 | 2 | ||
3 | #include <qvbox.h> | 3 | #include <qvbox.h> |
4 | #include <qlistbox.h> | 4 | #include <qlistbox.h> |
5 | #include <qwidget.h> | 5 | #include <qwidget.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | #include <qimage.h> | 7 | #include <qimage.h> |
8 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
9 | #include <qapplication.h> | 9 | #include <qapplication.h> |
10 | #include <qdragobject.h> | 10 | #include <qdragobject.h> |
11 | #include <qevent.h> | 11 | #include <qevent.h> |
12 | #include <qurl.h> | 12 | #include <qurl.h> |
13 | #include <qpixmap.h> | 13 | #include <qpixmap.h> |
14 | 14 | ||
15 | #include <kabc/addressbook.h> | 15 | #include <kabc/addressbook.h> |
16 | #include <kapplication.h> | 16 | #include <kapplication.h> |
17 | #include <kconfig.h> | 17 | #include <kconfig.h> |
18 | #include <kcolorbutton.h> | 18 | #include <kcolorbutton.h> |
19 | #include <kdebug.h> | 19 | #include <kdebug.h> |
20 | #include <kglobal.h> | 20 | #include <kglobal.h> |
21 | #include <kiconloader.h> | 21 | #include <kiconloader.h> |
22 | #include <klineedit.h> | 22 | #include <klineedit.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kmessagebox.h> | 24 | #include <kmessagebox.h> |
25 | #include <kurl.h> | 25 | #include <kurl.h> |
26 | #include <kurlrequester.h> | 26 | #include <kurlrequester.h> |
27 | 27 | ||
28 | //US#include "configuretableviewdialog.h" | 28 | //US#include "configuretableviewdialog.h" |
29 | #include "contactlistview.h" | 29 | #include "contactlistview.h" |
30 | #include "kabprefs.h" | 30 | #include "kabprefs.h" |
31 | #include "undocmds.h" | 31 | #include "undocmds.h" |
32 | #include "viewmanager.h" | 32 | #include "viewmanager.h" |
33 | 33 | ||
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qheader.h> | 35 | #include <qheader.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | 37 | ||
38 | #include "kaddressbooktableview.h" | 38 | #include "kaddressbooktableview.h" |
39 | 39 | ||
40 | 40 | ||
41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, | 41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, |
42 | QWidget *parent, const char *name ) | 42 | QWidget *parent, const char *name ) |
43 | : KAddressBookView( ab, parent, name ) | 43 | : KAddressBookView( ab, parent, name ) |
44 | { | 44 | { |
45 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); | 45 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); |
46 | 46 | ||
47 | // The list view will be created when the config is read. | 47 | // The list view will be created when the config is read. |
48 | mListView = 0; | 48 | mListView = 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | KAddressBookTableView::~KAddressBookTableView() | 51 | KAddressBookTableView::~KAddressBookTableView() |
52 | { | 52 | { |
53 | } | 53 | } |
54 | 54 | ||
55 | void KAddressBookTableView::reconstructListView() | 55 | void KAddressBookTableView::reconstructListView() |
56 | { | 56 | { |
57 | if (mListView) | 57 | if (mListView) |
58 | { | 58 | { |
59 | disconnect(mListView, SIGNAL(selectionChanged()), | 59 | disconnect(mListView, SIGNAL(selectionChanged()), |
60 | this, SLOT(addresseeSelected())); | 60 | this, SLOT(addresseeSelected())); |
61 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), | 61 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), |
62 | this, SLOT(addresseeExecuted(QListViewItem*))); | 62 | this, SLOT(addresseeExecuted(QListViewItem*))); |
63 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 63 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
64 | this, SLOT(addresseeExecuted(QListViewItem*))); | 64 | this, SLOT(addresseeExecuted(QListViewItem*))); |
65 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, | 65 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, |
66 | SIGNAL(startDrag())); | 66 | SIGNAL(startDrag())); |
67 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 67 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
68 | this, SLOT(addresseeExecuted(QListViewItem*))); | 68 | this, SLOT(addresseeExecuted(QListViewItem*))); |
69 | 69 | ||
70 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 70 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
71 | SIGNAL(dropped(QDropEvent*))); | 71 | SIGNAL(dropped(QDropEvent*))); |
72 | delete mListView; | 72 | delete mListView; |
73 | } | 73 | } |
74 | 74 | ||
75 | mListView = new ContactListView( this, addressBook(), viewWidget() ); | 75 | mListView = new ContactListView( this, addressBook(), viewWidget() ); |
76 | 76 | ||
77 | // Add the columns | 77 | // Add the columns |
78 | KABC::Field::List fieldList = fields(); | 78 | KABC::Field::List fieldList = fields(); |
79 | KABC::Field::List::ConstIterator it; | 79 | KABC::Field::List::ConstIterator it; |
80 | 80 | ||
81 | int c = 0; | 81 | int c = 0; |
82 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { | 82 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { |
83 | mListView->addColumn( (*it)->label() ); | 83 | mListView->addColumn( (*it)->label() ); |
84 | mListView->setColumnWidthMode(c++, QListView::Manual); | 84 | mListView->setColumnWidthMode(c++, QListView::Manual); |
85 | //US | 85 | //US |
86 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); | 86 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); |
87 | } | 87 | } |
88 | 88 | ||
89 | connect(mListView, SIGNAL(selectionChanged()), | 89 | connect(mListView, SIGNAL(selectionChanged()), |
90 | this, SLOT(addresseeSelected())); | 90 | this, SLOT(addresseeSelected())); |
91 | connect(mListView, SIGNAL(startAddresseeDrag()), this, | 91 | connect(mListView, SIGNAL(startAddresseeDrag()), this, |
92 | SIGNAL(startDrag())); | 92 | SIGNAL(startDrag())); |
93 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 93 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
94 | SIGNAL(dropped(QDropEvent*))); | 94 | SIGNAL(dropped(QDropEvent*))); |
95 | 95 | ||
96 | if (KABPrefs::instance()->mHonorSingleClick) | 96 | if (KABPrefs::instance()->mHonorSingleClick) |
97 | connect(mListView, SIGNAL(executed(QListViewItem*)), | 97 | connect(mListView, SIGNAL(executed(QListViewItem*)), |
98 | this, SLOT(addresseeExecuted(QListViewItem*))); | 98 | this, SLOT(addresseeExecuted(QListViewItem*))); |
99 | else | 99 | else |
100 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 100 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
101 | this, SLOT(addresseeExecuted(QListViewItem*))); | 101 | this, SLOT(addresseeExecuted(QListViewItem*))); |
102 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 102 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
103 | this, SLOT(addresseeExecuted(QListViewItem*))); | 103 | this, SLOT(addresseeExecuted(QListViewItem*))); |
104 | connect(mListView, SIGNAL(signalDelete()), | 104 | connect(mListView, SIGNAL(signalDelete()), |
105 | this, SLOT(addresseeDeleted())); | 105 | this, SLOT(addresseeDeleted())); |
106 | 106 | ||
107 | //US performceimprovement. Refresh is done from the outside | 107 | //US performceimprovement. Refresh is done from the outside |
108 | //US refresh(); | 108 | //US refresh(); |
109 | 109 | ||
110 | mListView->setSorting( 0, true ); | 110 | mListView->setSorting( 0, true ); |
111 | mainLayout->addWidget( mListView ); | 111 | mainLayout->addWidget( mListView ); |
112 | mainLayout->activate(); | 112 | mainLayout->activate(); |
113 | mListView->show(); | 113 | mListView->show(); |
114 | } | 114 | } |
115 | 115 | ||
116 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 116 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) |
117 | { | 117 | { |
118 | mListView->clear(); | 118 | mListView->clear(); |
119 | if ( s.isEmpty() || s == "*" ) { | 119 | if ( s.isEmpty() || s == "*" ) { |
120 | refresh(); | 120 | refresh(); |
121 | return; | 121 | return; |
122 | } | 122 | } |
123 | QString pattern = s.lower()+"*"; | 123 | QString pattern = s.lower()+"*"; |
124 | QRegExp re; | 124 | QRegExp re; |
125 | re.setWildcard(true); // most people understand these better. | 125 | re.setWildcard(true); // most people understand these better. |
126 | re.setCaseSensitive(false); | 126 | re.setCaseSensitive(false); |
127 | re.setPattern( pattern ); | 127 | re.setPattern( pattern ); |
128 | if (!re.isValid()) | 128 | if (!re.isValid()) |
129 | return; | 129 | return; |
130 | KABC::Addressee::List addresseeList = addressees(); | 130 | KABC::Addressee::List addresseeList = addressees(); |
131 | KABC::Addressee::List::Iterator it; | 131 | KABC::Addressee::List::Iterator it; |
132 | if ( field ) { | 132 | if ( field ) { |
133 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 133 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
134 | #if QT_VERSION >= 300 | 134 | #if QT_VERSION >= 300 |
135 | if (re.search(field->value( *it ).lower()) != -1) | 135 | if (re.search(field->value( *it ).lower()) != -1) |
136 | #else | 136 | #else |
137 | if (re.match(field->value( *it ).lower()) != -1) | 137 | if (re.match(field->value( *it ).lower()) != -1) |
138 | #endif | 138 | #endif |
139 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 139 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
140 | 140 | ||
141 | } | 141 | } |
142 | } else { | 142 | } else { |
143 | KABC::Field::List fieldList = fields(); | 143 | KABC::Field::List fieldList = fields(); |
144 | KABC::Field::List::ConstIterator fieldIt; | 144 | KABC::Field::List::ConstIterator fieldIt; |
145 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 145 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
146 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 146 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
147 | #if QT_VERSION >= 300 | 147 | #if QT_VERSION >= 300 |
148 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 148 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
149 | #else | 149 | #else |
150 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 150 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
151 | #endif | 151 | #endif |
152 | { | 152 | { |
153 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 153 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
154 | break; | 154 | break; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | } | 157 | } |
158 | } | 158 | } |
159 | // Sometimes the background pixmap gets messed up when we add lots | 159 | // Sometimes the background pixmap gets messed up when we add lots |
160 | // of items. | 160 | // of items. |
161 | mListView->repaint(); | 161 | mListView->repaint(); |
162 | emit selected(QString::null); | 162 | emit selected(QString::null); |
163 | 163 | ||
164 | } | 164 | } |
165 | void KAddressBookTableView::writeConfig(KConfig *config) | 165 | void KAddressBookTableView::writeConfig(KConfig *config) |
166 | { | 166 | { |
167 | KAddressBookView::writeConfig(config); | 167 | KAddressBookView::writeConfig(config); |
168 | 168 | ||
169 | mListView->saveLayout(config, config->group()); | 169 | mListView->saveLayout(config, config->group()); |
170 | } | 170 | } |
171 | 171 | ||
172 | void KAddressBookTableView::readConfig(KConfig *config) | 172 | void KAddressBookTableView::readConfig(KConfig *config) |
173 | { | 173 | { |
174 | KAddressBookView::readConfig( config ); | 174 | KAddressBookView::readConfig( config ); |
175 | // The config could have changed the fields, so we need to reconstruct | 175 | // The config could have changed the fields, so we need to reconstruct |
176 | // the listview. | 176 | // the listview. |
177 | reconstructListView(); | 177 | reconstructListView(); |
178 | 178 | ||
179 | // costum colors? | 179 | // costum colors? |
180 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 180 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
181 | { | 181 | { |
182 | QPalette p( mListView->palette() ); | 182 | QPalette p( mListView->palette() ); |
183 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 183 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
184 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 184 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
185 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 185 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
186 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 186 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
187 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 187 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
188 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 188 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
189 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 189 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
190 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 190 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
191 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 191 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
192 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 192 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
193 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 193 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
194 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 194 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
195 | #ifndef KAB_EMBEDDED | 195 | #ifndef KAB_EMBEDDED |
196 | c = KGlobalSettings::alternateBackgroundColor(); | 196 | c = KGlobalSettings::alternateBackgroundColor(); |
197 | #else //KAB_EMBEDDED | 197 | #else //KAB_EMBEDDED |
198 | c = QColor(240, 240, 240); | 198 | c = QColor(240, 240, 240); |
199 | #endif //KAB_EMBEDDED | 199 | #endif //KAB_EMBEDDED |
200 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); | 200 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); |
201 | mListView->setAlternateColor(c); | 201 | mListView->setAlternateColor(c); |
202 | 202 | ||
203 | 203 | ||
204 | //US mListView->viewport()->setPalette( p ); | 204 | //US mListView->viewport()->setPalette( p ); |
205 | mListView->setPalette( p ); | 205 | mListView->setPalette( p ); |
206 | } | 206 | } |
207 | else | 207 | else |
208 | { | 208 | { |
209 | // needed if turned off during a session. | 209 | // needed if turned off during a session. |
210 | //US mListView->viewport()->setPalette( mListView->palette() ); | 210 | //US mListView->viewport()->setPalette( mListView->palette() ); |
211 | mListView->setPalette( mListView->palette() ); | 211 | mListView->setPalette( mListView->palette() ); |
212 | } | 212 | } |
213 | 213 | ||
214 | //custom fonts? | 214 | //custom fonts? |
215 | QFont f( font() ); | 215 | QFont f( font() ); |
216 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 216 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
217 | { | 217 | { |
218 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); | 218 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); |
219 | f.setBold( true ); | 219 | f.setBold( true ); |
220 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 220 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
221 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); | 221 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); |
222 | } | 222 | } |
223 | else | 223 | else |
224 | { | 224 | { |
225 | mListView->setFont( f ); | 225 | mListView->setFont( f ); |
226 | f.setBold( true ); | 226 | f.setBold( true ); |
227 | //US mListView->setHeaderFont( f ); | 227 | //US mListView->setHeaderFont( f ); |
228 | mListView->header()->setFont( f ); | 228 | mListView->header()->setFont( f ); |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | 232 | ||
233 | 233 | ||
234 | 234 | ||
235 | // Set the list view options | 235 | // Set the list view options |
236 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", | 236 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", |
237 | true)); | 237 | true)); |
238 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); | 238 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); |
239 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); | 239 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); |
240 | 240 | ||
241 | if (config->readBoolEntry("Background", false)) | 241 | if (config->readBoolEntry("Background", false)) |
242 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); | 242 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); |
243 | 243 | ||
244 | // Restore the layout of the listview | 244 | // Restore the layout of the listview |
245 | mListView->restoreLayout(config, config->group()); | 245 | mListView->restoreLayout(config, config->group()); |
246 | } | 246 | } |
247 | 247 | ||
248 | void KAddressBookTableView::refresh(QString uid) | 248 | void KAddressBookTableView::refresh(QString uid) |
249 | { | 249 | { |
250 | // For now just repopulate. In reality this method should | 250 | // For now just repopulate. In reality this method should |
251 | // check the value of uid, and if valid iterate through | 251 | // check the value of uid, and if valid iterate through |
252 | // the listview to find the entry, then tell it to refresh. | 252 | // the listview to find the entry, then tell it to refresh. |
253 | 253 | ||
254 | if (uid.isNull()) { | 254 | if (uid.isNull()) { |
255 | // Clear the list view | 255 | // Clear the list view |
256 | QString currentUID, nextUID; | 256 | QString currentUID, nextUID; |
257 | #ifndef KAB_EMBEDDED | 257 | #ifndef KAB_EMBEDDED |
258 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); | 258 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); |
259 | #else //KAB_EMBEDDED | 259 | #else //KAB_EMBEDDED |
260 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); | 260 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |
261 | #endif //KAB_EMBEDDED | 261 | #endif //KAB_EMBEDDED |
262 | 262 | ||
263 | if ( currentItem ) { | 263 | if ( currentItem ) { |
264 | #ifndef KAB_EMBEDDED | 264 | #ifndef KAB_EMBEDDED |
265 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); | 265 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); |
266 | #else //KAB_EMBEDDED | 266 | #else //KAB_EMBEDDED |
267 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); | 267 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); |
268 | #endif //KAB_EMBEDDED | 268 | #endif //KAB_EMBEDDED |
269 | if ( nextItem ) | 269 | if ( nextItem ) |
270 | nextUID = nextItem->addressee().uid(); | 270 | nextUID = nextItem->addressee().uid(); |
271 | currentUID = currentItem->addressee().uid(); | 271 | currentUID = currentItem->addressee().uid(); |
272 | } | 272 | } |
273 | 273 | ||
274 | mListView->clear(); | 274 | mListView->clear(); |
275 | 275 | ||
276 | currentItem = 0; | 276 | currentItem = 0; |
277 | KABC::Addressee::List addresseeList = addressees(); | 277 | KABC::Addressee::List addresseeList = addressees(); |
278 | KABC::Addressee::List::Iterator it; | 278 | KABC::Addressee::List::Iterator it; |
279 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 279 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
280 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | ||
281 | continue; | ||
280 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 282 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
281 | if ( (*it).uid() == currentUID ) | 283 | if ( (*it).uid() == currentUID ) |
282 | currentItem = item; | 284 | currentItem = item; |
283 | else if ( (*it).uid() == nextUID && !currentItem ) | 285 | else if ( (*it).uid() == nextUID && !currentItem ) |
284 | currentItem = item; | 286 | currentItem = item; |
285 | } | 287 | } |
286 | 288 | ||
287 | // Sometimes the background pixmap gets messed up when we add lots | 289 | // Sometimes the background pixmap gets messed up when we add lots |
288 | // of items. | 290 | // of items. |
289 | mListView->repaint(); | 291 | mListView->repaint(); |
290 | 292 | ||
291 | if ( currentItem ) { | 293 | if ( currentItem ) { |
292 | mListView->setCurrentItem( currentItem ); | 294 | mListView->setCurrentItem( currentItem ); |
293 | mListView->ensureItemVisible( currentItem ); | 295 | mListView->ensureItemVisible( currentItem ); |
294 | } | 296 | } |
295 | } else { | 297 | } else { |
296 | // Only need to update on entry. Iterate through and try to find it | 298 | // Only need to update on entry. Iterate through and try to find it |
297 | ContactListViewItem *ceItem; | 299 | ContactListViewItem *ceItem; |
298 | QListViewItemIterator it( mListView ); | 300 | QListViewItemIterator it( mListView ); |
299 | while ( it.current() ) { | 301 | while ( it.current() ) { |
300 | #ifndef KAB_EMBEDDED | 302 | #ifndef KAB_EMBEDDED |
301 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); | 303 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); |
302 | #else //KAB_EMBEDDED | 304 | #else //KAB_EMBEDDED |
303 | ceItem = (ContactListViewItem*)( it.current() ); | 305 | ceItem = (ContactListViewItem*)( it.current() ); |
304 | #endif //KAB_EMBEDDED | 306 | #endif //KAB_EMBEDDED |
305 | 307 | ||
306 | if ( ceItem && ceItem->addressee().uid() == uid ) { | 308 | if ( ceItem && ceItem->addressee().uid() == uid ) { |
307 | ceItem->refresh(); | 309 | ceItem->refresh(); |
308 | return; | 310 | return; |
309 | } | 311 | } |
310 | ++it; | 312 | ++it; |
311 | } | 313 | } |
312 | 314 | ||
313 | refresh( QString::null ); | 315 | refresh( QString::null ); |
314 | } | 316 | } |
315 | } | 317 | } |
316 | 318 | ||
317 | QStringList KAddressBookTableView::selectedUids() | 319 | QStringList KAddressBookTableView::selectedUids() |
318 | { | 320 | { |
319 | QStringList uidList; | 321 | QStringList uidList; |
320 | QListViewItem *item; | 322 | QListViewItem *item; |
321 | ContactListViewItem *ceItem; | 323 | ContactListViewItem *ceItem; |
322 | 324 | ||
323 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 325 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
324 | { | 326 | { |
325 | if (mListView->isSelected( item )) | 327 | if (mListView->isSelected( item )) |
326 | { | 328 | { |
327 | #ifndef KAB_EMBEDDED | 329 | #ifndef KAB_EMBEDDED |
328 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 330 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
329 | #else //KAB_EMBEDDED | 331 | #else //KAB_EMBEDDED |
330 | ceItem = (ContactListViewItem*)(item); | 332 | ceItem = (ContactListViewItem*)(item); |
331 | #endif //KAB_EMBEDDED | 333 | #endif //KAB_EMBEDDED |
332 | 334 | ||
333 | if (ceItem != 0L) | 335 | if (ceItem != 0L) |
334 | uidList << ceItem->addressee().uid(); | 336 | uidList << ceItem->addressee().uid(); |
335 | } | 337 | } |
336 | } | 338 | } |
337 | if ( uidList.count() == 0 ) | 339 | if ( uidList.count() == 0 ) |
338 | if ( mListView->currentItem() ) { | 340 | if ( mListView->currentItem() ) { |
339 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; | 341 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; |
340 | uidList << ceItem->addressee().uid(); | 342 | uidList << ceItem->addressee().uid(); |
341 | } | 343 | } |
342 | 344 | ||
343 | return uidList; | 345 | return uidList; |
344 | } | 346 | } |
345 | 347 | ||
346 | void KAddressBookTableView::setSelected(QString uid, bool selected) | 348 | void KAddressBookTableView::setSelected(QString uid, bool selected) |
347 | { | 349 | { |
348 | QListViewItem *item; | 350 | QListViewItem *item; |
349 | ContactListViewItem *ceItem; | 351 | ContactListViewItem *ceItem; |
350 | 352 | ||
351 | if (uid.isNull()) | 353 | if (uid.isNull()) |
352 | { | 354 | { |
353 | mListView->selectAll(selected); | 355 | mListView->selectAll(selected); |
354 | } | 356 | } |
355 | else | 357 | else |
356 | { | 358 | { |
357 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 359 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
358 | { | 360 | { |
359 | #ifndef KAB_EMBEDDED | 361 | #ifndef KAB_EMBEDDED |
360 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 362 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
361 | #else //KAB_EMBEDDED | 363 | #else //KAB_EMBEDDED |
362 | ceItem = (ContactListViewItem*)(item); | 364 | ceItem = (ContactListViewItem*)(item); |
363 | #endif //KAB_EMBEDDED | 365 | #endif //KAB_EMBEDDED |
364 | 366 | ||
365 | 367 | ||
366 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) | 368 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) |
367 | { | 369 | { |
368 | mListView->setSelected(item, selected); | 370 | mListView->setSelected(item, selected); |
369 | 371 | ||
370 | if (selected) | 372 | if (selected) |
371 | mListView->ensureItemVisible(item); | 373 | mListView->ensureItemVisible(item); |
372 | } | 374 | } |
373 | } | 375 | } |
374 | } | 376 | } |
375 | } | 377 | } |
376 | 378 | ||
377 | void KAddressBookTableView::addresseeSelected() | 379 | void KAddressBookTableView::addresseeSelected() |
378 | { | 380 | { |
379 | // We need to try to find the first selected item. This might not be the | 381 | // We need to try to find the first selected item. This might not be the |
380 | // last selected item, but when QListView is in multiselection mode, | 382 | // last selected item, but when QListView is in multiselection mode, |
381 | // there is no way to figure out which one was | 383 | // there is no way to figure out which one was |
382 | // selected last. | 384 | // selected last. |
383 | QListViewItem *item; | 385 | QListViewItem *item; |
384 | bool found =false; | 386 | bool found =false; |
385 | for (item = mListView->firstChild(); item && !found; | 387 | for (item = mListView->firstChild(); item && !found; |
386 | item = item->nextSibling()) | 388 | item = item->nextSibling()) |
387 | { | 389 | { |
388 | if (item->isSelected()) | 390 | if (item->isSelected()) |
389 | { | 391 | { |
390 | found = true; | 392 | found = true; |
391 | #ifndef KAB_EMBEDDED | 393 | #ifndef KAB_EMBEDDED |
392 | ContactListViewItem *ceItem | 394 | ContactListViewItem *ceItem |
393 | = dynamic_cast<ContactListViewItem*>(item); | 395 | = dynamic_cast<ContactListViewItem*>(item); |
394 | #else //KAB_EMBEDDED | 396 | #else //KAB_EMBEDDED |
395 | ContactListViewItem *ceItem | 397 | ContactListViewItem *ceItem |
396 | = (ContactListViewItem*)(item); | 398 | = (ContactListViewItem*)(item); |
397 | #endif //KAB_EMBEDDED | 399 | #endif //KAB_EMBEDDED |
398 | 400 | ||
399 | if ( ceItem ) emit selected(ceItem->addressee().uid()); | 401 | if ( ceItem ) emit selected(ceItem->addressee().uid()); |
400 | } | 402 | } |
401 | } | 403 | } |
402 | 404 | ||
403 | if (!found) | 405 | if (!found) |
404 | emit selected(QString::null); | 406 | emit selected(QString::null); |
405 | } | 407 | } |
406 | 408 | ||
407 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) | 409 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) |
408 | { | 410 | { |
409 | if (item) | 411 | if (item) |
410 | { | 412 | { |
411 | #ifndef KAB_EMBEDDED | 413 | #ifndef KAB_EMBEDDED |
412 | ContactListViewItem *ceItem | 414 | ContactListViewItem *ceItem |
413 | = dynamic_cast<ContactListViewItem*>(item); | 415 | = dynamic_cast<ContactListViewItem*>(item); |
414 | #else //KAB_EMBEDDED | 416 | #else //KAB_EMBEDDED |
415 | ContactListViewItem *ceItem | 417 | ContactListViewItem *ceItem |
416 | = (ContactListViewItem*)(item); | 418 | = (ContactListViewItem*)(item); |
417 | #endif //KAB_EMBEDDED | 419 | #endif //KAB_EMBEDDED |
418 | 420 | ||
419 | if (ceItem) | 421 | if (ceItem) |
420 | { | 422 | { |
421 | emit executed(ceItem->addressee().uid()); | 423 | emit executed(ceItem->addressee().uid()); |
422 | } | 424 | } |
423 | } | 425 | } |
424 | else | 426 | else |
425 | { | 427 | { |
426 | emit executed(QString::null); | 428 | emit executed(QString::null); |
427 | } | 429 | } |
428 | } | 430 | } |
429 | 431 | ||
430 | void KAddressBookTableView::addresseeDeleted() | 432 | void KAddressBookTableView::addresseeDeleted() |
431 | { | 433 | { |
432 | 434 | ||
433 | emit deleteRequest(); | 435 | emit deleteRequest(); |
434 | 436 | ||
435 | } | 437 | } |
436 | 438 | ||
437 | 439 | ||
438 | 440 | ||
439 | 441 | ||
440 | 442 | ||
441 | #ifndef KAB_EMBEDDED | 443 | #ifndef KAB_EMBEDDED |
442 | #include "kaddressbooktableview.moc" | 444 | #include "kaddressbooktableview.moc" |
443 | #endif //KAB_EMBEDDED | 445 | #endif //KAB_EMBEDDED |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index f7766f8..c7ce8cb 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,1795 +1,1796 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qtopia/alarmserver.h> | 28 | #include <qtopia/alarmserver.h> |
29 | #include <qtopia/qcopenvelope_qws.h> | 29 | #include <qtopia/qcopenvelope_qws.h> |
30 | #include <unistd.h> // for sleep | 30 | #include <unistd.h> // for sleep |
31 | #else | 31 | #else |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | //#include <resource.h> | 35 | //#include <resource.h> |
36 | 36 | ||
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendarlocal.h> | 38 | #include <libkcal/calendarlocal.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | #include <libkcal/phoneformat.h> | 40 | #include <libkcal/phoneformat.h> |
41 | #include <libkdepim/ksyncprofile.h> | 41 | #include <libkdepim/ksyncprofile.h> |
42 | #include <libkdepim/phoneaccess.h> | 42 | #include <libkdepim/phoneaccess.h> |
43 | #include <libkcal/kincidenceformatter.h> | 43 | #include <libkcal/kincidenceformatter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "calendarview.h" | 46 | #include "calendarview.h" |
47 | #include "koviewmanager.h" | 47 | #include "koviewmanager.h" |
48 | #include "datenavigator.h" | 48 | #include "datenavigator.h" |
49 | #include "koagendaview.h" | 49 | #include "koagendaview.h" |
50 | #include "koagenda.h" | 50 | #include "koagenda.h" |
51 | #include "kodialogmanager.h" | 51 | #include "kodialogmanager.h" |
52 | #include "kdialogbase.h" | 52 | #include "kdialogbase.h" |
53 | #include "kapplication.h" | 53 | #include "kapplication.h" |
54 | #include "kofilterview.h" | 54 | #include "kofilterview.h" |
55 | #include "kstandarddirs.h" | 55 | #include "kstandarddirs.h" |
56 | #include "koprefs.h" | 56 | #include "koprefs.h" |
57 | #include "kfiledialog.h" | 57 | #include "kfiledialog.h" |
58 | #include "koglobals.h" | 58 | #include "koglobals.h" |
59 | #include "kglobal.h" | 59 | #include "kglobal.h" |
60 | #include "klocale.h" | 60 | #include "klocale.h" |
61 | #include "kconfig.h" | 61 | #include "kconfig.h" |
62 | #include "simplealarmclient.h" | 62 | #include "simplealarmclient.h" |
63 | #include "externalapphandler.h" | 63 | #include "externalapphandler.h" |
64 | 64 | ||
65 | using namespace KCal; | 65 | using namespace KCal; |
66 | #ifndef _WIN32_ | 66 | #ifndef _WIN32_ |
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #else | 68 | #else |
69 | #include "koimportoldialog.h" | 69 | #include "koimportoldialog.h" |
70 | #endif | 70 | #endif |
71 | #include "mainwindow.h" | 71 | #include "mainwindow.h" |
72 | 72 | ||
73 | class KOex2phonePrefs : public QDialog | 73 | class KOex2phonePrefs : public QDialog |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 76 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
77 | QDialog( parent, name, true ) | 77 | QDialog( parent, name, true ) |
78 | { | 78 | { |
79 | setCaption( i18n("Export to phone options") ); | 79 | setCaption( i18n("Export to phone options") ); |
80 | QVBoxLayout* lay = new QVBoxLayout( this ); | 80 | QVBoxLayout* lay = new QVBoxLayout( this ); |
81 | lay->setSpacing( 3 ); | 81 | lay->setSpacing( 3 ); |
82 | lay->setMargin( 3 ); | 82 | lay->setMargin( 3 ); |
83 | QLabel *lab; | 83 | QLabel *lab; |
84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
85 | lab->setAlignment (AlignHCenter ); | 85 | lab->setAlignment (AlignHCenter ); |
86 | QHBox* temphb; | 86 | QHBox* temphb; |
87 | temphb = new QHBox( this ); | 87 | temphb = new QHBox( this ); |
88 | new QLabel( i18n("I/O device: "), temphb ); | 88 | new QLabel( i18n("I/O device: "), temphb ); |
89 | mPhoneDevice = new QLineEdit( temphb); | 89 | mPhoneDevice = new QLineEdit( temphb); |
90 | lay->addWidget( temphb ); | 90 | lay->addWidget( temphb ); |
91 | temphb = new QHBox( this ); | 91 | temphb = new QHBox( this ); |
92 | new QLabel( i18n("Connection: "), temphb ); | 92 | new QLabel( i18n("Connection: "), temphb ); |
93 | mPhoneConnection = new QLineEdit( temphb); | 93 | mPhoneConnection = new QLineEdit( temphb); |
94 | lay->addWidget( temphb ); | 94 | lay->addWidget( temphb ); |
95 | temphb = new QHBox( this ); | 95 | temphb = new QHBox( this ); |
96 | new QLabel( i18n("Model(opt.): "), temphb ); | 96 | new QLabel( i18n("Model(opt.): "), temphb ); |
97 | mPhoneModel = new QLineEdit( temphb); | 97 | mPhoneModel = new QLineEdit( temphb); |
98 | lay->addWidget( temphb ); | 98 | lay->addWidget( temphb ); |
99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
100 | mWriteBackFuture->setChecked( true ); | 100 | mWriteBackFuture->setChecked( true ); |
101 | lay->addWidget( mWriteBackFuture ); | 101 | lay->addWidget( mWriteBackFuture ); |
102 | temphb = new QHBox( this ); | 102 | temphb = new QHBox( this ); |
103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
105 | mWriteBackFutureWeeks->setValue( 8 ); | 105 | mWriteBackFutureWeeks->setValue( 8 ); |
106 | lay->addWidget( temphb ); | 106 | lay->addWidget( temphb ); |
107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
108 | lab->setAlignment (AlignHCenter ); | 108 | lab->setAlignment (AlignHCenter ); |
109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
110 | lay->addWidget( ok ); | 110 | lay->addWidget( ok ); |
111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
112 | lay->addWidget( cancel ); | 112 | lay->addWidget( cancel ); |
113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
115 | resize( 220, 240 ); | 115 | resize( 220, 240 ); |
116 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | public: | 119 | public: |
120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
121 | QCheckBox* mWriteBackFuture; | 121 | QCheckBox* mWriteBackFuture; |
122 | QSpinBox* mWriteBackFutureWeeks; | 122 | QSpinBox* mWriteBackFutureWeeks; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | int globalFlagBlockStartup; | 125 | int globalFlagBlockStartup; |
126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
127 | QMainWindow( parent, name ) | 127 | QMainWindow( parent, name ) |
128 | { | 128 | { |
129 | 129 | ||
130 | #ifdef DESKTOP_VERSION | 130 | #ifdef DESKTOP_VERSION |
131 | setFont( QFont("Arial"), 14 ); | 131 | setFont( QFont("Arial"), 14 ); |
132 | #endif | 132 | #endif |
133 | mServerSocket = 0; | 133 | mServerSocket = 0; |
134 | mClosed = false; | 134 | mClosed = false; |
135 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 135 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
136 | QString confFile = locateLocal("config","korganizerrc"); | 136 | QString confFile = locateLocal("config","korganizerrc"); |
137 | QFileInfo finf ( confFile ); | 137 | QFileInfo finf ( confFile ); |
138 | bool showWarning = !finf.exists(); | 138 | bool showWarning = !finf.exists(); |
139 | setIcon(SmallIcon( "ko24" ) ); | 139 | setIcon(SmallIcon( "ko24" ) ); |
140 | mBlockAtStartup = true; | 140 | mBlockAtStartup = true; |
141 | mFlagKeyPressed = false; | 141 | mFlagKeyPressed = false; |
142 | setCaption("KOrganizer/Pi"); | 142 | setCaption("KOrganizer/Pi"); |
143 | KOPrefs *p = KOPrefs::instance(); | 143 | KOPrefs *p = KOPrefs::instance(); |
144 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 144 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
145 | if ( p->mHourSize > 18 ) | 145 | if ( p->mHourSize > 18 ) |
146 | p->mHourSize = 18; | 146 | p->mHourSize = 18; |
147 | QMainWindow::ToolBarDock tbd; | 147 | QMainWindow::ToolBarDock tbd; |
148 | if ( p->mToolBarHor ) { | 148 | if ( p->mToolBarHor ) { |
149 | if ( p->mToolBarUp ) | 149 | if ( p->mToolBarUp ) |
150 | tbd = Bottom; | 150 | tbd = Bottom; |
151 | else | 151 | else |
152 | tbd = Top; | 152 | tbd = Top; |
153 | } | 153 | } |
154 | else { | 154 | else { |
155 | if ( p->mToolBarUp ) | 155 | if ( p->mToolBarUp ) |
156 | tbd = Right; | 156 | tbd = Right; |
157 | else | 157 | else |
158 | tbd = Left; | 158 | tbd = Left; |
159 | } | 159 | } |
160 | if ( KOPrefs::instance()->mUseAppColors ) | 160 | if ( KOPrefs::instance()->mUseAppColors ) |
161 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 161 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
162 | globalFlagBlockStartup = 1; | 162 | globalFlagBlockStartup = 1; |
163 | iconToolBar = new QPEToolBar( this ); | 163 | iconToolBar = new QPEToolBar( this ); |
164 | addToolBar (iconToolBar , tbd ); | 164 | addToolBar (iconToolBar , tbd ); |
165 | mCalendarModifiedFlag = false; | 165 | mCalendarModifiedFlag = false; |
166 | 166 | ||
167 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 167 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
168 | splash->setAlignment ( AlignCenter ); | 168 | splash->setAlignment ( AlignCenter ); |
169 | setCentralWidget( splash ); | 169 | setCentralWidget( splash ); |
170 | #ifndef DESKTOP_VERSION | 170 | #ifndef DESKTOP_VERSION |
171 | showMaximized(); | 171 | showMaximized(); |
172 | #endif | 172 | #endif |
173 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 173 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
174 | setDefaultPreferences(); | 174 | setDefaultPreferences(); |
175 | mCalendar = new CalendarLocal(); | 175 | mCalendar = new CalendarLocal(); |
176 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 176 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
177 | mView->hide(); | 177 | mView->hide(); |
178 | //mView->resize(splash->size() ); | 178 | //mView->resize(splash->size() ); |
179 | initActions(); | 179 | initActions(); |
180 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 180 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
181 | mSyncManager->setBlockSave(false); | 181 | mSyncManager->setBlockSave(false); |
182 | mView->setSyncManager(mSyncManager); | 182 | mView->setSyncManager(mSyncManager); |
183 | #ifndef DESKTOP_VERSION | 183 | #ifndef DESKTOP_VERSION |
184 | iconToolBar->show(); | 184 | iconToolBar->show(); |
185 | qApp->processEvents(); | 185 | qApp->processEvents(); |
186 | #endif | 186 | #endif |
187 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 187 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
188 | int vh = height() ; | 188 | int vh = height() ; |
189 | int vw = width(); | 189 | int vw = width(); |
190 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 190 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
191 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 191 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
192 | vh -= iconToolBar->height(); | 192 | vh -= iconToolBar->height(); |
193 | } else { | 193 | } else { |
194 | vw -= iconToolBar->height(); | 194 | vw -= iconToolBar->height(); |
195 | } | 195 | } |
196 | //mView->setMaximumSize( splash->size() ); | 196 | //mView->setMaximumSize( splash->size() ); |
197 | //mView->resize( splash->size() ); | 197 | //mView->resize( splash->size() ); |
198 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 198 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
199 | mView->readSettings(); | 199 | mView->readSettings(); |
200 | bool newFile = false; | 200 | bool newFile = false; |
201 | if( !QFile::exists( defaultFileName() ) ) { | 201 | if( !QFile::exists( defaultFileName() ) ) { |
202 | QFileInfo finfo ( defaultFileName() ); | 202 | QFileInfo finfo ( defaultFileName() ); |
203 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 203 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
204 | qDebug("oldfile %s ", oldFile.latin1()); | 204 | qDebug("oldfile %s ", oldFile.latin1()); |
205 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 205 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
206 | finfo.setFile( oldFile ); | 206 | finfo.setFile( oldFile ); |
207 | if (finfo.exists() ) { | 207 | if (finfo.exists() ) { |
208 | KMessageBox::information( this, message); | 208 | KMessageBox::information( this, message); |
209 | mView->openCalendar( oldFile ); | 209 | mView->openCalendar( oldFile ); |
210 | qApp->processEvents(); | 210 | qApp->processEvents(); |
211 | } else { | 211 | } else { |
212 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 212 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
213 | finfo.setFile( oldFile ); | 213 | finfo.setFile( oldFile ); |
214 | if (finfo.exists() ) { | 214 | if (finfo.exists() ) { |
215 | KMessageBox::information( this, message); | 215 | KMessageBox::information( this, message); |
216 | mView->openCalendar( oldFile ); | 216 | mView->openCalendar( oldFile ); |
217 | qApp->processEvents(); | 217 | qApp->processEvents(); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | mView->saveCalendar( defaultFileName() ); | 220 | mView->saveCalendar( defaultFileName() ); |
221 | newFile = true; | 221 | newFile = true; |
222 | } | 222 | } |
223 | 223 | ||
224 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 224 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
225 | mView->openCalendar( defaultFileName() ); | 225 | mView->openCalendar( defaultFileName() ); |
226 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 226 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
227 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 227 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
228 | 228 | ||
229 | if ( KOPrefs::instance()->mLanguageChanged ) { | 229 | if ( KOPrefs::instance()->mLanguageChanged ) { |
230 | KOPrefs::instance()->setCategoryDefaults(); | 230 | KOPrefs::instance()->setCategoryDefaults(); |
231 | int count = mView->addCategories(); | 231 | int count = mView->addCategories(); |
232 | KOPrefs::instance()->mLanguageChanged = false; | 232 | KOPrefs::instance()->mLanguageChanged = false; |
233 | } | 233 | } |
234 | processIncidenceSelection( 0 ); | 234 | processIncidenceSelection( 0 ); |
235 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 235 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
236 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 236 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
237 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 237 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
238 | SLOT( slotModifiedChanged( bool ) ) ); | 238 | SLOT( slotModifiedChanged( bool ) ) ); |
239 | 239 | ||
240 | 240 | ||
241 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 241 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
242 | mView->setModified( false ); | 242 | mView->setModified( false ); |
243 | mBlockAtStartup = false; | 243 | mBlockAtStartup = false; |
244 | mView->setModified( false ); | 244 | mView->setModified( false ); |
245 | setCentralWidget( mView ); | 245 | setCentralWidget( mView ); |
246 | globalFlagBlockStartup = 0; | 246 | globalFlagBlockStartup = 0; |
247 | mView->show(); | 247 | mView->show(); |
248 | delete splash; | 248 | delete splash; |
249 | if ( newFile ) | 249 | if ( newFile ) |
250 | mView->updateConfig(); | 250 | mView->updateConfig(); |
251 | // qApp->processEvents(); | 251 | // qApp->processEvents(); |
252 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 252 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
253 | //fillSyncMenu(); | 253 | //fillSyncMenu(); |
254 | 254 | ||
255 | 255 | ||
256 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 256 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
257 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 257 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
258 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 258 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
259 | mSyncManager->setDefaultFileName( defaultFileName()); | 259 | mSyncManager->setDefaultFileName( defaultFileName()); |
260 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | ||
260 | mSyncManager->fillSyncMenu(); | 261 | mSyncManager->fillSyncMenu(); |
261 | 262 | ||
262 | 263 | ||
263 | 264 | ||
264 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 265 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
265 | if ( showWarning ) { | 266 | if ( showWarning ) { |
266 | KMessageBox::information( this, | 267 | KMessageBox::information( this, |
267 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 268 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
268 | qApp->processEvents(); | 269 | qApp->processEvents(); |
269 | mView->dialogManager()->showSyncOptions(); | 270 | mView->dialogManager()->showSyncOptions(); |
270 | } | 271 | } |
271 | 272 | ||
272 | //US listen for result adressed from Ka/Pi | 273 | //US listen for result adressed from Ka/Pi |
273 | #ifndef DESKTOP_VERSION | 274 | #ifndef DESKTOP_VERSION |
274 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 275 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
275 | #endif | 276 | #endif |
276 | } | 277 | } |
277 | MainWindow::~MainWindow() | 278 | MainWindow::~MainWindow() |
278 | { | 279 | { |
279 | //qDebug("MainWindow::~MainWindow() "); | 280 | //qDebug("MainWindow::~MainWindow() "); |
280 | //save toolbar location | 281 | //save toolbar location |
281 | delete mServerSocket; | 282 | delete mServerSocket; |
282 | delete mCalendar; | 283 | delete mCalendar; |
283 | delete KOPrefs::instance(); | 284 | delete KOPrefs::instance(); |
284 | delete KIncidenceFormatter::instance(); | 285 | delete KIncidenceFormatter::instance(); |
285 | 286 | ||
286 | 287 | ||
287 | } | 288 | } |
288 | void MainWindow::showMaximized () | 289 | void MainWindow::showMaximized () |
289 | { | 290 | { |
290 | #ifndef DESKTOP_VERSION | 291 | #ifndef DESKTOP_VERSION |
291 | if ( ! globalFlagBlockStartup ) | 292 | if ( ! globalFlagBlockStartup ) |
292 | if ( mClosed ) | 293 | if ( mClosed ) |
293 | mView->goToday(); | 294 | mView->goToday(); |
294 | #endif | 295 | #endif |
295 | QWidget::showMaximized () ; | 296 | QWidget::showMaximized () ; |
296 | mClosed = false; | 297 | mClosed = false; |
297 | } | 298 | } |
298 | void MainWindow::closeEvent( QCloseEvent* ce ) | 299 | void MainWindow::closeEvent( QCloseEvent* ce ) |
299 | { | 300 | { |
300 | 301 | ||
301 | 302 | ||
302 | 303 | ||
303 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 304 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
304 | saveOnClose(); | 305 | saveOnClose(); |
305 | mClosed = true; | 306 | mClosed = true; |
306 | ce->accept(); | 307 | ce->accept(); |
307 | return; | 308 | return; |
308 | 309 | ||
309 | } | 310 | } |
310 | 311 | ||
311 | switch( QMessageBox::information( this, "KO/Pi", | 312 | switch( QMessageBox::information( this, "KO/Pi", |
312 | i18n("Do you really want\nto close KO/Pi?"), | 313 | i18n("Do you really want\nto close KO/Pi?"), |
313 | i18n("Close"), i18n("No"), | 314 | i18n("Close"), i18n("No"), |
314 | 0, 0 ) ) { | 315 | 0, 0 ) ) { |
315 | case 0: | 316 | case 0: |
316 | saveOnClose(); | 317 | saveOnClose(); |
317 | mClosed = true; | 318 | mClosed = true; |
318 | ce->accept(); | 319 | ce->accept(); |
319 | break; | 320 | break; |
320 | case 1: | 321 | case 1: |
321 | ce->ignore(); | 322 | ce->ignore(); |
322 | break; | 323 | break; |
323 | case 2: | 324 | case 2: |
324 | 325 | ||
325 | default: | 326 | default: |
326 | break; | 327 | break; |
327 | } | 328 | } |
328 | 329 | ||
329 | 330 | ||
330 | } | 331 | } |
331 | 332 | ||
332 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 333 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
333 | { | 334 | { |
334 | QDataStream stream( data, IO_ReadOnly ); | 335 | QDataStream stream( data, IO_ReadOnly ); |
335 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 336 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
336 | //QString datamess; | 337 | //QString datamess; |
337 | //qDebug("message "); | 338 | //qDebug("message "); |
338 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 339 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
339 | 340 | ||
340 | if ( cmsg == "-writeFile" ) { | 341 | if ( cmsg == "-writeFile" ) { |
341 | // I made from the "-writeFile" an "-writeAlarm" | 342 | // I made from the "-writeFile" an "-writeAlarm" |
342 | mView->viewManager()->showWhatsNextView(); | 343 | mView->viewManager()->showWhatsNextView(); |
343 | mCalendar->checkAlarmForIncidence( 0, true); | 344 | mCalendar->checkAlarmForIncidence( 0, true); |
344 | showMaximized(); | 345 | showMaximized(); |
345 | raise(); | 346 | raise(); |
346 | return; | 347 | return; |
347 | } | 348 | } |
348 | 349 | ||
349 | if ( cmsg == "-writeFile" ) { | 350 | if ( cmsg == "-writeFile" ) { |
350 | // I made from the "-writeFile" an "-writeAlarm" | 351 | // I made from the "-writeFile" an "-writeAlarm" |
351 | mView->viewManager()->showWhatsNextView(); | 352 | mView->viewManager()->showWhatsNextView(); |
352 | mCalendar->checkAlarmForIncidence( 0, true); | 353 | mCalendar->checkAlarmForIncidence( 0, true); |
353 | showMaximized(); | 354 | showMaximized(); |
354 | raise(); | 355 | raise(); |
355 | return; | 356 | return; |
356 | 357 | ||
357 | } | 358 | } |
358 | if ( cmsg == "-writeFileSilent" ) { | 359 | if ( cmsg == "-writeFileSilent" ) { |
359 | // I made from the "-writeFile" an "-writeAlarm" | 360 | // I made from the "-writeFile" an "-writeAlarm" |
360 | // mView->viewManager()->showWhatsNextView(); | 361 | // mView->viewManager()->showWhatsNextView(); |
361 | mCalendar->checkAlarmForIncidence( 0, true); | 362 | mCalendar->checkAlarmForIncidence( 0, true); |
362 | //showMaximized(); | 363 | //showMaximized(); |
363 | //raise(); | 364 | //raise(); |
364 | hide(); | 365 | hide(); |
365 | return; | 366 | return; |
366 | } | 367 | } |
367 | if ( cmsg == "-newCountdown" ) { | 368 | if ( cmsg == "-newCountdown" ) { |
368 | qDebug("newCountdown "); | 369 | qDebug("newCountdown "); |
369 | 370 | ||
370 | } | 371 | } |
371 | QString msg ; | 372 | QString msg ; |
372 | QString allmsg = cmsg; | 373 | QString allmsg = cmsg; |
373 | while ( allmsg.length() > 0 ) { | 374 | while ( allmsg.length() > 0 ) { |
374 | int nextC = allmsg.find( "-", 1 ); | 375 | int nextC = allmsg.find( "-", 1 ); |
375 | if ( nextC == -1 ) { | 376 | if ( nextC == -1 ) { |
376 | msg = allmsg; | 377 | msg = allmsg; |
377 | allmsg = ""; | 378 | allmsg = ""; |
378 | } else{ | 379 | } else{ |
379 | msg = allmsg.left( nextC ); | 380 | msg = allmsg.left( nextC ); |
380 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 381 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
381 | } | 382 | } |
382 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 383 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
383 | if ( msg == "-newEvent" ) { | 384 | if ( msg == "-newEvent" ) { |
384 | mView->newEvent(); | 385 | mView->newEvent(); |
385 | } | 386 | } |
386 | if ( msg == "-newTodo" ) { | 387 | if ( msg == "-newTodo" ) { |
387 | mView->newTodo(); | 388 | mView->newTodo(); |
388 | 389 | ||
389 | } | 390 | } |
390 | if ( msg == "-showWN" ) { | 391 | if ( msg == "-showWN" ) { |
391 | mView->viewManager()->showWhatsNextView(); | 392 | mView->viewManager()->showWhatsNextView(); |
392 | } | 393 | } |
393 | if ( msg == "-showTodo" ) { | 394 | if ( msg == "-showTodo" ) { |
394 | mView->viewManager()->showTodoView(); | 395 | mView->viewManager()->showTodoView(); |
395 | } | 396 | } |
396 | if ( msg == "-showList" ) { | 397 | if ( msg == "-showList" ) { |
397 | mView->viewManager()->showListView(); | 398 | mView->viewManager()->showListView(); |
398 | } | 399 | } |
399 | else if ( msg == "-showDay" ) { | 400 | else if ( msg == "-showDay" ) { |
400 | mView->viewManager()->showDayView(); | 401 | mView->viewManager()->showDayView(); |
401 | } | 402 | } |
402 | else if ( msg == "-showWWeek" ) { | 403 | else if ( msg == "-showWWeek" ) { |
403 | mView->viewManager()->showWorkWeekView(); | 404 | mView->viewManager()->showWorkWeekView(); |
404 | } | 405 | } |
405 | else if ( msg == "-ringSync" ) { | 406 | else if ( msg == "-ringSync" ) { |
406 | mSyncManager->multiSync( false ); | 407 | mSyncManager->multiSync( false ); |
407 | } | 408 | } |
408 | else if ( msg == "-showWeek" ) { | 409 | else if ( msg == "-showWeek" ) { |
409 | mView->viewManager()->showWeekView(); | 410 | mView->viewManager()->showWeekView(); |
410 | } | 411 | } |
411 | else if ( msg == "-showTodo" ) { | 412 | else if ( msg == "-showTodo" ) { |
412 | mView->viewManager()->showTodoView(); | 413 | mView->viewManager()->showTodoView(); |
413 | } | 414 | } |
414 | else if ( msg == "-showJournal" ) { | 415 | else if ( msg == "-showJournal" ) { |
415 | mView->dateNavigator()->selectDates( 1 ); | 416 | mView->dateNavigator()->selectDates( 1 ); |
416 | mView->dateNavigator()->selectToday(); | 417 | mView->dateNavigator()->selectToday(); |
417 | mView->viewManager()->showJournalView(); | 418 | mView->viewManager()->showJournalView(); |
418 | } | 419 | } |
419 | else if ( msg == "-showKO" ) { | 420 | else if ( msg == "-showKO" ) { |
420 | mView->viewManager()->showNextXView(); | 421 | mView->viewManager()->showNextXView(); |
421 | } | 422 | } |
422 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 423 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
423 | mView->viewManager()->showWhatsNextView(); | 424 | mView->viewManager()->showWhatsNextView(); |
424 | } | 425 | } |
425 | else if ( msg == "-showNextXView" ) { | 426 | else if ( msg == "-showNextXView" ) { |
426 | mView->viewManager()->showNextXView(); | 427 | mView->viewManager()->showNextXView(); |
427 | } | 428 | } |
428 | 429 | ||
429 | 430 | ||
430 | } | 431 | } |
431 | 432 | ||
432 | showMaximized(); | 433 | showMaximized(); |
433 | raise(); | 434 | raise(); |
434 | } | 435 | } |
435 | 436 | ||
436 | QPixmap MainWindow::loadPixmap( QString name ) | 437 | QPixmap MainWindow::loadPixmap( QString name ) |
437 | { | 438 | { |
438 | return SmallIcon( name ); | 439 | return SmallIcon( name ); |
439 | 440 | ||
440 | } | 441 | } |
441 | void MainWindow::initActions() | 442 | void MainWindow::initActions() |
442 | { | 443 | { |
443 | //KOPrefs::instance()->mShowFullMenu | 444 | //KOPrefs::instance()->mShowFullMenu |
444 | iconToolBar->clear(); | 445 | iconToolBar->clear(); |
445 | KOPrefs *p = KOPrefs::instance(); | 446 | KOPrefs *p = KOPrefs::instance(); |
446 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 447 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
447 | 448 | ||
448 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 449 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
449 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 450 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
450 | QPopupMenu *importMenu = new QPopupMenu( this ); | 451 | QPopupMenu *importMenu = new QPopupMenu( this ); |
451 | selectFilterMenu = new QPopupMenu( this ); | 452 | selectFilterMenu = new QPopupMenu( this ); |
452 | selectFilterMenu->setCheckable( true ); | 453 | selectFilterMenu->setCheckable( true ); |
453 | syncMenu = new QPopupMenu( this ); | 454 | syncMenu = new QPopupMenu( this ); |
454 | configureAgendaMenu = new QPopupMenu( this ); | 455 | configureAgendaMenu = new QPopupMenu( this ); |
455 | configureToolBarMenu = new QPopupMenu( this ); | 456 | configureToolBarMenu = new QPopupMenu( this ); |
456 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 457 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
457 | if ( KOPrefs::instance()->mShowFullMenu ) { | 458 | if ( KOPrefs::instance()->mShowFullMenu ) { |
458 | QMenuBar *menuBar1; | 459 | QMenuBar *menuBar1; |
459 | menuBar1 = menuBar(); | 460 | menuBar1 = menuBar(); |
460 | menuBar1->insertItem( i18n("File"), importMenu ); | 461 | menuBar1->insertItem( i18n("File"), importMenu ); |
461 | menuBar1->insertItem( i18n("View"), viewMenu ); | 462 | menuBar1->insertItem( i18n("View"), viewMenu ); |
462 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 463 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
463 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 464 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
464 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 465 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
465 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 466 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
466 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 467 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
467 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 468 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
468 | } else { | 469 | } else { |
469 | QPEMenuBar *menuBar1; | 470 | QPEMenuBar *menuBar1; |
470 | menuBar1 = new QPEMenuBar( iconToolBar ); | 471 | menuBar1 = new QPEMenuBar( iconToolBar ); |
471 | QPopupMenu *menuBar = new QPopupMenu( this ); | 472 | QPopupMenu *menuBar = new QPopupMenu( this ); |
472 | menuBar1->insertItem( i18n("ME"), menuBar); | 473 | menuBar1->insertItem( i18n("ME"), menuBar); |
473 | menuBar->insertItem( i18n("File"), importMenu ); | 474 | menuBar->insertItem( i18n("File"), importMenu ); |
474 | menuBar->insertItem( i18n("View"), viewMenu ); | 475 | menuBar->insertItem( i18n("View"), viewMenu ); |
475 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 476 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
476 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 477 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
477 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 478 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
478 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 479 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
479 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 480 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
480 | menuBar->insertItem( i18n("Help"), helpMenu ); | 481 | menuBar->insertItem( i18n("Help"), helpMenu ); |
481 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 482 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
482 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 483 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
483 | } | 484 | } |
484 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 485 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); |
485 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 486 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
486 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); | 487 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); |
487 | 488 | ||
488 | // ****************** | 489 | // ****************** |
489 | QAction *action; | 490 | QAction *action; |
490 | QIconSet icon; | 491 | QIconSet icon; |
491 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 492 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
492 | configureToolBarMenu->setCheckable( true ); | 493 | configureToolBarMenu->setCheckable( true ); |
493 | 494 | ||
494 | QString pathString = ""; | 495 | QString pathString = ""; |
495 | if ( !p->mToolBarMiniIcons ) { | 496 | if ( !p->mToolBarMiniIcons ) { |
496 | if ( QApplication::desktop()->width() < 480 ) | 497 | if ( QApplication::desktop()->width() < 480 ) |
497 | pathString += "icons16/"; | 498 | pathString += "icons16/"; |
498 | } else | 499 | } else |
499 | pathString += "iconsmini/"; | 500 | pathString += "iconsmini/"; |
500 | configureAgendaMenu->setCheckable( true ); | 501 | configureAgendaMenu->setCheckable( true ); |
501 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); | 502 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); |
502 | configureAgendaMenu->insertSeparator(); | 503 | configureAgendaMenu->insertSeparator(); |
503 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); | 504 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); |
504 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); | 505 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); |
505 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); | 506 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); |
506 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); | 507 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); |
507 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); | 508 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); |
508 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); | 509 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); |
509 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); | 510 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); |
510 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); | 511 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); |
511 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 512 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
512 | 513 | ||
513 | icon = loadPixmap( pathString + "configure" ); | 514 | icon = loadPixmap( pathString + "configure" ); |
514 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 515 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
515 | action->addTo( actionMenu ); | 516 | action->addTo( actionMenu ); |
516 | connect( action, SIGNAL( activated() ), | 517 | connect( action, SIGNAL( activated() ), |
517 | mView, SLOT( edit_options() ) ); | 518 | mView, SLOT( edit_options() ) ); |
518 | actionMenu->insertSeparator(); | 519 | actionMenu->insertSeparator(); |
519 | icon = loadPixmap( pathString + "newevent" ); | 520 | icon = loadPixmap( pathString + "newevent" ); |
520 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 521 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
521 | configureToolBarMenu->insertSeparator(); | 522 | configureToolBarMenu->insertSeparator(); |
522 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 523 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
523 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 524 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
524 | ne_action->addTo( actionMenu ); | 525 | ne_action->addTo( actionMenu ); |
525 | connect( ne_action, SIGNAL( activated() ), | 526 | connect( ne_action, SIGNAL( activated() ), |
526 | mView, SLOT( newEvent() ) ); | 527 | mView, SLOT( newEvent() ) ); |
527 | icon = loadPixmap( pathString + "newtodo" ); | 528 | icon = loadPixmap( pathString + "newtodo" ); |
528 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 529 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
529 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 530 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
530 | nt_action->addTo( actionMenu ); | 531 | nt_action->addTo( actionMenu ); |
531 | connect( nt_action, SIGNAL( activated() ), | 532 | connect( nt_action, SIGNAL( activated() ), |
532 | mView, SLOT( newTodo() ) ); | 533 | mView, SLOT( newTodo() ) ); |
533 | icon = loadPixmap( pathString + "navi" ); | 534 | icon = loadPixmap( pathString + "navi" ); |
534 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 535 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
535 | action->addTo( viewMenu ); | 536 | action->addTo( viewMenu ); |
536 | connect( action, SIGNAL( activated() ), | 537 | connect( action, SIGNAL( activated() ), |
537 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 538 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
538 | icon = loadPixmap( pathString + "filter" ); | 539 | icon = loadPixmap( pathString + "filter" ); |
539 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 540 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
540 | action->addTo( viewMenu ); | 541 | action->addTo( viewMenu ); |
541 | connect( action, SIGNAL( activated() ), | 542 | connect( action, SIGNAL( activated() ), |
542 | mView, SLOT( toggleFilter() ) ); | 543 | mView, SLOT( toggleFilter() ) ); |
543 | 544 | ||
544 | 545 | ||
545 | viewMenu->insertSeparator(); | 546 | viewMenu->insertSeparator(); |
546 | icon = loadPixmap( pathString + "picker" ); | 547 | icon = loadPixmap( pathString + "picker" ); |
547 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 548 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
548 | action->addTo( viewMenu ); | 549 | action->addTo( viewMenu ); |
549 | connect( action, SIGNAL( activated() ), | 550 | connect( action, SIGNAL( activated() ), |
550 | mView, SLOT( showDatePicker() ) ); | 551 | mView, SLOT( showDatePicker() ) ); |
551 | action->addTo( iconToolBar ); | 552 | action->addTo( iconToolBar ); |
552 | viewMenu->insertSeparator(); | 553 | viewMenu->insertSeparator(); |
553 | icon = loadPixmap( pathString + "list" ); | 554 | icon = loadPixmap( pathString + "list" ); |
554 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 555 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
555 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 556 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
556 | showlist_action->addTo( viewMenu ); | 557 | showlist_action->addTo( viewMenu ); |
557 | connect( showlist_action, SIGNAL( activated() ), | 558 | connect( showlist_action, SIGNAL( activated() ), |
558 | mView->viewManager(), SLOT( showListView() ) ); | 559 | mView->viewManager(), SLOT( showListView() ) ); |
559 | 560 | ||
560 | 561 | ||
561 | icon = loadPixmap( pathString + "day" ); | 562 | icon = loadPixmap( pathString + "day" ); |
562 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 563 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
563 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 564 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
564 | day1_action->addTo( viewMenu ); | 565 | day1_action->addTo( viewMenu ); |
565 | // action->addTo( toolBar ); | 566 | // action->addTo( toolBar ); |
566 | connect( day1_action, SIGNAL( activated() ), | 567 | connect( day1_action, SIGNAL( activated() ), |
567 | mView->viewManager(), SLOT( showDayView() ) ); | 568 | mView->viewManager(), SLOT( showDayView() ) ); |
568 | 569 | ||
569 | icon = loadPixmap( pathString + "workweek" ); | 570 | icon = loadPixmap( pathString + "workweek" ); |
570 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 571 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
571 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 572 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
572 | day5_action->addTo( viewMenu ); | 573 | day5_action->addTo( viewMenu ); |
573 | connect( day5_action, SIGNAL( activated() ), | 574 | connect( day5_action, SIGNAL( activated() ), |
574 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 575 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
575 | 576 | ||
576 | icon = loadPixmap( pathString + "week" ); | 577 | icon = loadPixmap( pathString + "week" ); |
577 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 578 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
578 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 579 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
579 | day7_action->addTo( viewMenu ); | 580 | day7_action->addTo( viewMenu ); |
580 | connect( day7_action, SIGNAL( activated() ), | 581 | connect( day7_action, SIGNAL( activated() ), |
581 | mView->viewManager(), SLOT( showWeekView() ) ); | 582 | mView->viewManager(), SLOT( showWeekView() ) ); |
582 | 583 | ||
583 | icon = loadPixmap( pathString + "month" ); | 584 | icon = loadPixmap( pathString + "month" ); |
584 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 585 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
585 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 586 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
586 | month_action->addTo( viewMenu ); | 587 | month_action->addTo( viewMenu ); |
587 | connect( month_action, SIGNAL( activated() ), | 588 | connect( month_action, SIGNAL( activated() ), |
588 | mView->viewManager(), SLOT( showMonthView() ) ); | 589 | mView->viewManager(), SLOT( showMonthView() ) ); |
589 | 590 | ||
590 | icon = loadPixmap( pathString + "todo" ); | 591 | icon = loadPixmap( pathString + "todo" ); |
591 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 592 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
592 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 593 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
593 | todoview_action->addTo( viewMenu ); | 594 | todoview_action->addTo( viewMenu ); |
594 | connect( todoview_action, SIGNAL( activated() ), | 595 | connect( todoview_action, SIGNAL( activated() ), |
595 | mView->viewManager(), SLOT( showTodoView() ) ); | 596 | mView->viewManager(), SLOT( showTodoView() ) ); |
596 | 597 | ||
597 | icon = loadPixmap( pathString + "journal" ); | 598 | icon = loadPixmap( pathString + "journal" ); |
598 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 599 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
599 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 600 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
600 | viewjournal_action->addTo( viewMenu ); | 601 | viewjournal_action->addTo( viewMenu ); |
601 | connect( viewjournal_action, SIGNAL( activated() ), | 602 | connect( viewjournal_action, SIGNAL( activated() ), |
602 | mView->viewManager(), SLOT( showJournalView() ) ); | 603 | mView->viewManager(), SLOT( showJournalView() ) ); |
603 | 604 | ||
604 | icon = loadPixmap( pathString + "xdays" ); | 605 | icon = loadPixmap( pathString + "xdays" ); |
605 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | 606 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); |
606 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 607 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
607 | xdays_action->addTo( viewMenu ); | 608 | xdays_action->addTo( viewMenu ); |
608 | connect( xdays_action, SIGNAL( activated() ), | 609 | connect( xdays_action, SIGNAL( activated() ), |
609 | mView->viewManager(), SLOT( showNextXView() ) ); | 610 | mView->viewManager(), SLOT( showNextXView() ) ); |
610 | 611 | ||
611 | icon = loadPixmap( pathString + "whatsnext" ); | 612 | icon = loadPixmap( pathString + "whatsnext" ); |
612 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | 613 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); |
613 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 614 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
614 | whatsnext_action->addTo( viewMenu ); | 615 | whatsnext_action->addTo( viewMenu ); |
615 | connect( whatsnext_action, SIGNAL( activated() ), | 616 | connect( whatsnext_action, SIGNAL( activated() ), |
616 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 617 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
617 | 618 | ||
618 | #if 0 | 619 | #if 0 |
619 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 620 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
620 | action->addTo( viewMenu ); | 621 | action->addTo( viewMenu ); |
621 | connect( action, SIGNAL( activated() ), | 622 | connect( action, SIGNAL( activated() ), |
622 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 623 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
623 | #endif | 624 | #endif |
624 | 625 | ||
625 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 626 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
626 | this ); | 627 | this ); |
627 | mNewSubTodoAction->addTo( actionMenu ); | 628 | mNewSubTodoAction->addTo( actionMenu ); |
628 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 629 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
629 | mView, SLOT( newSubTodo() ) ); | 630 | mView, SLOT( newSubTodo() ) ); |
630 | 631 | ||
631 | actionMenu->insertSeparator(); | 632 | actionMenu->insertSeparator(); |
632 | 633 | ||
633 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 634 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
634 | mShowAction->addTo( actionMenu ); | 635 | mShowAction->addTo( actionMenu ); |
635 | connect( mShowAction, SIGNAL( activated() ), | 636 | connect( mShowAction, SIGNAL( activated() ), |
636 | mView, SLOT( showIncidence() ) ); | 637 | mView, SLOT( showIncidence() ) ); |
637 | 638 | ||
638 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 639 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
639 | mEditAction->addTo( actionMenu ); | 640 | mEditAction->addTo( actionMenu ); |
640 | connect( mEditAction, SIGNAL( activated() ), | 641 | connect( mEditAction, SIGNAL( activated() ), |
641 | mView, SLOT( editIncidence() ) ); | 642 | mView, SLOT( editIncidence() ) ); |
642 | 643 | ||
643 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 644 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
644 | mDeleteAction->addTo( actionMenu ); | 645 | mDeleteAction->addTo( actionMenu ); |
645 | connect( mDeleteAction, SIGNAL( activated() ), | 646 | connect( mDeleteAction, SIGNAL( activated() ), |
646 | mView, SLOT( deleteIncidence() ) ); | 647 | mView, SLOT( deleteIncidence() ) ); |
647 | 648 | ||
648 | 649 | ||
649 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 650 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
650 | mCloneAction->addTo( actionMenu ); | 651 | mCloneAction->addTo( actionMenu ); |
651 | connect( mCloneAction, SIGNAL( activated() ), | 652 | connect( mCloneAction, SIGNAL( activated() ), |
652 | mView, SLOT( cloneIncidence() ) ); | 653 | mView, SLOT( cloneIncidence() ) ); |
653 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 654 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
654 | mMoveAction->addTo( actionMenu ); | 655 | mMoveAction->addTo( actionMenu ); |
655 | connect( mMoveAction, SIGNAL( activated() ), | 656 | connect( mMoveAction, SIGNAL( activated() ), |
656 | mView, SLOT( moveIncidence() ) ); | 657 | mView, SLOT( moveIncidence() ) ); |
657 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 658 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
658 | mBeamAction->addTo( actionMenu ); | 659 | mBeamAction->addTo( actionMenu ); |
659 | connect( mBeamAction, SIGNAL( activated() ), | 660 | connect( mBeamAction, SIGNAL( activated() ), |
660 | mView, SLOT( beamIncidence() ) ); | 661 | mView, SLOT( beamIncidence() ) ); |
661 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 662 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
662 | mCancelAction->addTo( actionMenu ); | 663 | mCancelAction->addTo( actionMenu ); |
663 | connect( mCancelAction, SIGNAL( activated() ), | 664 | connect( mCancelAction, SIGNAL( activated() ), |
664 | mView, SLOT( toggleCancelIncidence() ) ); | 665 | mView, SLOT( toggleCancelIncidence() ) ); |
665 | 666 | ||
666 | actionMenu->insertSeparator(); | 667 | actionMenu->insertSeparator(); |
667 | 668 | ||
668 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 669 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
669 | this ); | 670 | this ); |
670 | action->addTo( actionMenu ); | 671 | action->addTo( actionMenu ); |
671 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 672 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
672 | 673 | ||
673 | icon = loadPixmap( pathString + "search" ); | 674 | icon = loadPixmap( pathString + "search" ); |
674 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 675 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
675 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | 676 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); |
676 | search_action->addTo( actionMenu ); | 677 | search_action->addTo( actionMenu ); |
677 | connect( search_action, SIGNAL( activated() ), | 678 | connect( search_action, SIGNAL( activated() ), |
678 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 679 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
679 | 680 | ||
680 | icon = loadPixmap( pathString + "today" ); | 681 | icon = loadPixmap( pathString + "today" ); |
681 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 682 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
682 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 683 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
683 | today_action->addTo( actionMenu ); | 684 | today_action->addTo( actionMenu ); |
684 | connect( today_action, SIGNAL( activated() ), | 685 | connect( today_action, SIGNAL( activated() ), |
685 | mView, SLOT( goToday() ) ); | 686 | mView, SLOT( goToday() ) ); |
686 | 687 | ||
687 | if ( KOPrefs::instance()->mShowFullMenu ) { | 688 | if ( KOPrefs::instance()->mShowFullMenu ) { |
688 | actionMenu->insertSeparator(); | 689 | actionMenu->insertSeparator(); |
689 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 690 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
690 | 691 | ||
691 | } | 692 | } |
692 | // actionMenu->insertSeparator(); | 693 | // actionMenu->insertSeparator(); |
693 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 694 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
694 | this ); | 695 | this ); |
695 | action->addTo( importMenu ); | 696 | action->addTo( importMenu ); |
696 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 697 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
697 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 698 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
698 | this ); | 699 | this ); |
699 | action->addTo( importMenu ); | 700 | action->addTo( importMenu ); |
700 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 701 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
701 | importMenu->insertSeparator(); | 702 | importMenu->insertSeparator(); |
702 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 703 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
703 | this ); | 704 | this ); |
704 | action->addTo( importMenu ); | 705 | action->addTo( importMenu ); |
705 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 706 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
706 | #ifndef DESKTOP_VERSION | 707 | #ifndef DESKTOP_VERSION |
707 | importMenu->insertSeparator(); | 708 | importMenu->insertSeparator(); |
708 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 709 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
709 | this ); | 710 | this ); |
710 | action->addTo( importMenu ); | 711 | action->addTo( importMenu ); |
711 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 712 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
712 | #else | 713 | #else |
713 | #ifdef _WIN32_ | 714 | #ifdef _WIN32_ |
714 | importMenu->insertSeparator(); | 715 | importMenu->insertSeparator(); |
715 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 716 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
716 | this ); | 717 | this ); |
717 | action->addTo( importMenu ); | 718 | action->addTo( importMenu ); |
718 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 719 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
719 | #endif | 720 | #endif |
720 | #endif | 721 | #endif |
721 | 722 | ||
722 | importMenu->insertSeparator(); | 723 | importMenu->insertSeparator(); |
723 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 724 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
724 | this ); | 725 | this ); |
725 | action->addTo( importMenu ); | 726 | action->addTo( importMenu ); |
726 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 727 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
727 | 728 | ||
728 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 729 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
729 | this ); | 730 | this ); |
730 | action->addTo( importMenu ); | 731 | action->addTo( importMenu ); |
731 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 732 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
732 | 733 | ||
733 | importMenu->insertSeparator(); | 734 | importMenu->insertSeparator(); |
734 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 735 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
735 | this ); | 736 | this ); |
736 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 737 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
737 | 738 | ||
738 | 739 | ||
739 | //LR | 740 | //LR |
740 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 741 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
741 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 742 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
742 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 743 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
743 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 744 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
744 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); | 745 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); |
745 | 746 | ||
746 | importMenu->insertSeparator(); | 747 | importMenu->insertSeparator(); |
747 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 748 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
748 | this ); | 749 | this ); |
749 | action->addTo( importMenu ); | 750 | action->addTo( importMenu ); |
750 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 751 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
751 | #ifndef DESKTOP_VERSION | 752 | #ifndef DESKTOP_VERSION |
752 | importMenu->insertSeparator(); | 753 | importMenu->insertSeparator(); |
753 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 754 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
754 | this ); | 755 | this ); |
755 | action->addTo( importMenu ); | 756 | action->addTo( importMenu ); |
756 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 757 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
757 | 758 | ||
758 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 759 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
759 | this ); | 760 | this ); |
760 | action->addTo( importMenu ); | 761 | action->addTo( importMenu ); |
761 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 762 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
762 | #else | 763 | #else |
763 | importMenu->insertSeparator(); | 764 | importMenu->insertSeparator(); |
764 | icon = loadPixmap( pathString + "print" ); | 765 | icon = loadPixmap( pathString + "print" ); |
765 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 766 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
766 | action->addTo( importMenu ); | 767 | action->addTo( importMenu ); |
767 | connect( action, SIGNAL( activated() ), | 768 | connect( action, SIGNAL( activated() ), |
768 | this, SLOT( printCal() ) ); | 769 | this, SLOT( printCal() ) ); |
769 | 770 | ||
770 | icon = loadPixmap( pathString + "print" ); | 771 | icon = loadPixmap( pathString + "print" ); |
771 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 772 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
772 | action->addTo( importMenu ); | 773 | action->addTo( importMenu ); |
773 | connect( action, SIGNAL( activated() ), | 774 | connect( action, SIGNAL( activated() ), |
774 | this, SLOT( printSel() ) ); | 775 | this, SLOT( printSel() ) ); |
775 | #endif | 776 | #endif |
776 | importMenu->insertSeparator(); | 777 | importMenu->insertSeparator(); |
777 | action = new QAction( "beam all", i18n("Save"), 0, | 778 | action = new QAction( "beam all", i18n("Save"), 0, |
778 | this ); | 779 | this ); |
779 | action->addTo( importMenu ); | 780 | action->addTo( importMenu ); |
780 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 781 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
781 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 782 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
782 | this ); | 783 | this ); |
783 | action->addTo( importMenu ); | 784 | action->addTo( importMenu ); |
784 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 785 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
785 | 786 | ||
786 | //menuBar->insertItem( "Configure",configureMenu ); | 787 | //menuBar->insertItem( "Configure",configureMenu ); |
787 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 788 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
788 | icon = loadPixmap( "korganizer/korganizer" ); | 789 | icon = loadPixmap( "korganizer/korganizer" ); |
789 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 790 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
790 | action->addTo( helpMenu ); | 791 | action->addTo( helpMenu ); |
791 | connect( action, SIGNAL( activated() ), | 792 | connect( action, SIGNAL( activated() ), |
792 | SLOT( keyBindings() ) ); | 793 | SLOT( keyBindings() ) ); |
793 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 794 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
794 | action->addTo( helpMenu ); | 795 | action->addTo( helpMenu ); |
795 | connect( action, SIGNAL( activated() ), | 796 | connect( action, SIGNAL( activated() ), |
796 | SLOT( features() ) ); | 797 | SLOT( features() ) ); |
797 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 798 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
798 | action->addTo( helpMenu ); | 799 | action->addTo( helpMenu ); |
799 | connect( action, SIGNAL( activated() ), | 800 | connect( action, SIGNAL( activated() ), |
800 | SLOT( aboutAutoSaving() ) ); | 801 | SLOT( aboutAutoSaving() ) ); |
801 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 802 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
802 | action->addTo( helpMenu ); | 803 | action->addTo( helpMenu ); |
803 | connect( action, SIGNAL( activated() ), | 804 | connect( action, SIGNAL( activated() ), |
804 | SLOT( aboutKnownBugs() ) ); | 805 | SLOT( aboutKnownBugs() ) ); |
805 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 806 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
806 | action->addTo( helpMenu ); | 807 | action->addTo( helpMenu ); |
807 | connect( action, SIGNAL( activated() ), | 808 | connect( action, SIGNAL( activated() ), |
808 | SLOT( usertrans() ) ); | 809 | SLOT( usertrans() ) ); |
809 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 810 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
810 | action->addTo( helpMenu ); | 811 | action->addTo( helpMenu ); |
811 | connect( action, SIGNAL( activated() ), | 812 | connect( action, SIGNAL( activated() ), |
812 | SLOT( synchowto() ) ); | 813 | SLOT( synchowto() ) ); |
813 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 814 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
814 | action->addTo( helpMenu ); | 815 | action->addTo( helpMenu ); |
815 | connect( action, SIGNAL( activated() ), | 816 | connect( action, SIGNAL( activated() ), |
816 | SLOT( whatsNew() ) ); | 817 | SLOT( whatsNew() ) ); |
817 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 818 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
818 | action->addTo( helpMenu ); | 819 | action->addTo( helpMenu ); |
819 | connect( action, SIGNAL( activated() ), | 820 | connect( action, SIGNAL( activated() ), |
820 | SLOT( faq() ) ); | 821 | SLOT( faq() ) ); |
821 | 822 | ||
822 | 823 | ||
823 | action = new QAction( "about", i18n("About..."), 0, this ); | 824 | action = new QAction( "about", i18n("About..."), 0, this ); |
824 | action->addTo( helpMenu ); | 825 | action->addTo( helpMenu ); |
825 | connect( action, SIGNAL( activated() ), | 826 | connect( action, SIGNAL( activated() ), |
826 | SLOT( about() ) ); | 827 | SLOT( about() ) ); |
827 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 828 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
828 | action->addTo( helpMenu ); | 829 | action->addTo( helpMenu ); |
829 | connect( action, SIGNAL( activated() ), | 830 | connect( action, SIGNAL( activated() ), |
830 | SLOT( licence() ) ); | 831 | SLOT( licence() ) ); |
831 | //menuBar->insertSeparator(); | 832 | //menuBar->insertSeparator(); |
832 | 833 | ||
833 | // ****************************************************** | 834 | // ****************************************************** |
834 | // menubar icons | 835 | // menubar icons |
835 | 836 | ||
836 | 837 | ||
837 | iconToolBar->setHorizontalStretchable (true ); | 838 | iconToolBar->setHorizontalStretchable (true ); |
838 | //menuBar->insertItem( iconToolBar ); | 839 | //menuBar->insertItem( iconToolBar ); |
839 | //xdays_action | 840 | //xdays_action |
840 | if (p-> mShowIconNewEvent) | 841 | if (p-> mShowIconNewEvent) |
841 | ne_action->addTo( iconToolBar ); | 842 | ne_action->addTo( iconToolBar ); |
842 | if (p->mShowIconNewTodo ) | 843 | if (p->mShowIconNewTodo ) |
843 | nt_action->addTo( iconToolBar ); | 844 | nt_action->addTo( iconToolBar ); |
844 | if (p-> mShowIconSearch) | 845 | if (p-> mShowIconSearch) |
845 | search_action->addTo( iconToolBar ); | 846 | search_action->addTo( iconToolBar ); |
846 | if (p-> mShowIconNext) | 847 | if (p-> mShowIconNext) |
847 | whatsnext_action->addTo( iconToolBar ); | 848 | whatsnext_action->addTo( iconToolBar ); |
848 | if (p-> mShowIconNextDays) | 849 | if (p-> mShowIconNextDays) |
849 | xdays_action->addTo( iconToolBar ); | 850 | xdays_action->addTo( iconToolBar ); |
850 | if (p-> mShowIconList) | 851 | if (p-> mShowIconList) |
851 | showlist_action->addTo( iconToolBar ); | 852 | showlist_action->addTo( iconToolBar ); |
852 | if (p-> mShowIconDay1) | 853 | if (p-> mShowIconDay1) |
853 | day1_action->addTo( iconToolBar ); | 854 | day1_action->addTo( iconToolBar ); |
854 | if (p-> mShowIconDay5) | 855 | if (p-> mShowIconDay5) |
855 | day5_action->addTo( iconToolBar ); | 856 | day5_action->addTo( iconToolBar ); |
856 | if (p-> mShowIconDay7) | 857 | if (p-> mShowIconDay7) |
857 | day7_action->addTo( iconToolBar ); | 858 | day7_action->addTo( iconToolBar ); |
858 | if (p-> mShowIconMonth) | 859 | if (p-> mShowIconMonth) |
859 | month_action->addTo( iconToolBar ); | 860 | month_action->addTo( iconToolBar ); |
860 | if (p-> mShowIconTodoview) | 861 | if (p-> mShowIconTodoview) |
861 | todoview_action->addTo( iconToolBar ); | 862 | todoview_action->addTo( iconToolBar ); |
862 | if (p-> mShowIconJournal) | 863 | if (p-> mShowIconJournal) |
863 | viewjournal_action->addTo( iconToolBar ); | 864 | viewjournal_action->addTo( iconToolBar ); |
864 | icon = loadPixmap( pathString + "2leftarrowB" ); | 865 | icon = loadPixmap( pathString + "2leftarrowB" ); |
865 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 866 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
866 | if (p-> mShowIconBackFast) { | 867 | if (p-> mShowIconBackFast) { |
867 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 868 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
868 | connect( action, SIGNAL( activated() ), | 869 | connect( action, SIGNAL( activated() ), |
869 | mView, SLOT( goPreviousMonth() ) ); | 870 | mView, SLOT( goPreviousMonth() ) ); |
870 | action->addTo( iconToolBar ); | 871 | action->addTo( iconToolBar ); |
871 | } | 872 | } |
872 | icon = loadPixmap( pathString + "1leftarrowB" ); | 873 | icon = loadPixmap( pathString + "1leftarrowB" ); |
873 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 874 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
874 | if (p-> mShowIconBack) { | 875 | if (p-> mShowIconBack) { |
875 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 876 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
876 | connect( action, SIGNAL( activated() ), | 877 | connect( action, SIGNAL( activated() ), |
877 | mView, SLOT( goPrevious() ) ); | 878 | mView, SLOT( goPrevious() ) ); |
878 | action->addTo( iconToolBar ); | 879 | action->addTo( iconToolBar ); |
879 | } | 880 | } |
880 | if (p-> mShowIconToday) | 881 | if (p-> mShowIconToday) |
881 | today_action->addTo( iconToolBar ); | 882 | today_action->addTo( iconToolBar ); |
882 | icon = loadPixmap( pathString + "1rightarrowB" ); | 883 | icon = loadPixmap( pathString + "1rightarrowB" ); |
883 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 884 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
884 | if (p-> mShowIconForward) { | 885 | if (p-> mShowIconForward) { |
885 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 886 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
886 | connect( action, SIGNAL( activated() ), | 887 | connect( action, SIGNAL( activated() ), |
887 | mView, SLOT( goNext() ) ); | 888 | mView, SLOT( goNext() ) ); |
888 | action->addTo( iconToolBar ); | 889 | action->addTo( iconToolBar ); |
889 | } | 890 | } |
890 | icon = loadPixmap( pathString + "2rightarrowB" ); | 891 | icon = loadPixmap( pathString + "2rightarrowB" ); |
891 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 892 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
892 | if (p-> mShowIconForwardFast) { | 893 | if (p-> mShowIconForwardFast) { |
893 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 894 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
894 | connect( action, SIGNAL( activated() ), | 895 | connect( action, SIGNAL( activated() ), |
895 | mView, SLOT( goNextMonth() ) ); | 896 | mView, SLOT( goNextMonth() ) ); |
896 | action->addTo( iconToolBar ); | 897 | action->addTo( iconToolBar ); |
897 | } | 898 | } |
898 | 899 | ||
899 | 900 | ||
900 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 901 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
901 | 902 | ||
902 | if (p-> mShowIconNewEvent) | 903 | if (p-> mShowIconNewEvent) |
903 | configureToolBarMenu->setItemChecked( 10, true ); | 904 | configureToolBarMenu->setItemChecked( 10, true ); |
904 | if (p->mShowIconNewTodo ) | 905 | if (p->mShowIconNewTodo ) |
905 | configureToolBarMenu->setItemChecked( 20, true ); | 906 | configureToolBarMenu->setItemChecked( 20, true ); |
906 | if (p-> mShowIconSearch) | 907 | if (p-> mShowIconSearch) |
907 | configureToolBarMenu->setItemChecked( 120, true ); | 908 | configureToolBarMenu->setItemChecked( 120, true ); |
908 | if (p-> mShowIconList) | 909 | if (p-> mShowIconList) |
909 | configureToolBarMenu->setItemChecked( 30, true ); | 910 | configureToolBarMenu->setItemChecked( 30, true ); |
910 | if (p-> mShowIconDay1) | 911 | if (p-> mShowIconDay1) |
911 | configureToolBarMenu->setItemChecked( 40, true ); | 912 | configureToolBarMenu->setItemChecked( 40, true ); |
912 | if (p-> mShowIconDay5) | 913 | if (p-> mShowIconDay5) |
913 | configureToolBarMenu->setItemChecked( 50, true ); | 914 | configureToolBarMenu->setItemChecked( 50, true ); |
914 | if (p-> mShowIconDay7) | 915 | if (p-> mShowIconDay7) |
915 | configureToolBarMenu->setItemChecked( 60, true ); | 916 | configureToolBarMenu->setItemChecked( 60, true ); |
916 | if (p-> mShowIconMonth) | 917 | if (p-> mShowIconMonth) |
917 | configureToolBarMenu->setItemChecked( 70, true ); | 918 | configureToolBarMenu->setItemChecked( 70, true ); |
918 | if (p-> mShowIconTodoview) | 919 | if (p-> mShowIconTodoview) |
919 | configureToolBarMenu->setItemChecked( 80, true ); | 920 | configureToolBarMenu->setItemChecked( 80, true ); |
920 | if (p-> mShowIconBackFast) | 921 | if (p-> mShowIconBackFast) |
921 | configureToolBarMenu->setItemChecked( 200, true ); | 922 | configureToolBarMenu->setItemChecked( 200, true ); |
922 | if (p-> mShowIconBack) | 923 | if (p-> mShowIconBack) |
923 | configureToolBarMenu->setItemChecked( 210, true ); | 924 | configureToolBarMenu->setItemChecked( 210, true ); |
924 | if (p-> mShowIconToday) | 925 | if (p-> mShowIconToday) |
925 | configureToolBarMenu->setItemChecked( 130, true ); | 926 | configureToolBarMenu->setItemChecked( 130, true ); |
926 | if (p-> mShowIconForward) | 927 | if (p-> mShowIconForward) |
927 | configureToolBarMenu->setItemChecked( 220, true ); | 928 | configureToolBarMenu->setItemChecked( 220, true ); |
928 | if (p-> mShowIconForwardFast) | 929 | if (p-> mShowIconForwardFast) |
929 | configureToolBarMenu->setItemChecked( 230, true ); | 930 | configureToolBarMenu->setItemChecked( 230, true ); |
930 | if (p-> mShowIconNextDays) | 931 | if (p-> mShowIconNextDays) |
931 | configureToolBarMenu->setItemChecked( 100, true ); | 932 | configureToolBarMenu->setItemChecked( 100, true ); |
932 | if (p-> mShowIconNext) | 933 | if (p-> mShowIconNext) |
933 | configureToolBarMenu->setItemChecked( 110, true ); | 934 | configureToolBarMenu->setItemChecked( 110, true ); |
934 | if (p-> mShowIconJournal) | 935 | if (p-> mShowIconJournal) |
935 | configureToolBarMenu->setItemChecked( 90, true ); | 936 | configureToolBarMenu->setItemChecked( 90, true ); |
936 | if (p-> mShowIconWhatsThis) | 937 | if (p-> mShowIconWhatsThis) |
937 | configureToolBarMenu->setItemChecked( 300, true ); | 938 | configureToolBarMenu->setItemChecked( 300, true ); |
938 | 939 | ||
939 | QLabel* dummy = new QLabel( iconToolBar ); | 940 | QLabel* dummy = new QLabel( iconToolBar ); |
940 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 941 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
941 | if (!p-> mShowIconStretch) | 942 | if (!p-> mShowIconStretch) |
942 | iconToolBar->setStretchableWidget ( dummy ) ; | 943 | iconToolBar->setStretchableWidget ( dummy ) ; |
943 | else | 944 | else |
944 | configureToolBarMenu->setItemChecked( 5, true ); | 945 | configureToolBarMenu->setItemChecked( 5, true ); |
945 | if (p-> mShowIconWhatsThis) | 946 | if (p-> mShowIconWhatsThis) |
946 | QWhatsThis::whatsThisButton ( iconToolBar ); | 947 | QWhatsThis::whatsThisButton ( iconToolBar ); |
947 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 948 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
948 | configureAgenda( p->mHourSize ); | 949 | configureAgenda( p->mHourSize ); |
949 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 950 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
950 | } | 951 | } |
951 | 952 | ||
952 | void MainWindow::exportToPhone( int mode ) | 953 | void MainWindow::exportToPhone( int mode ) |
953 | { | 954 | { |
954 | 955 | ||
955 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 956 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
956 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 957 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
957 | KOex2phonePrefs ex2phone; | 958 | KOex2phonePrefs ex2phone; |
958 | 959 | ||
959 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 960 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
960 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 961 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
961 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 962 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
962 | if ( mode == 1 ) | 963 | if ( mode == 1 ) |
963 | ex2phone.setCaption(i18n("Export complete calendar")); | 964 | ex2phone.setCaption(i18n("Export complete calendar")); |
964 | if ( mode == 2 ) | 965 | if ( mode == 2 ) |
965 | ex2phone.setCaption(i18n("Export filtered calendar")); | 966 | ex2phone.setCaption(i18n("Export filtered calendar")); |
966 | 967 | ||
967 | if ( !ex2phone.exec() ) { | 968 | if ( !ex2phone.exec() ) { |
968 | return; | 969 | return; |
969 | } | 970 | } |
970 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 971 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
971 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 972 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
972 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 973 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
973 | 974 | ||
974 | int inFuture = 0; | 975 | int inFuture = 0; |
975 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 976 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
976 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 977 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
977 | QPtrList<Incidence> delSel; | 978 | QPtrList<Incidence> delSel; |
978 | if ( mode == 1 ) | 979 | if ( mode == 1 ) |
979 | delSel = mCalendar->rawIncidences(); | 980 | delSel = mCalendar->rawIncidences(); |
980 | if ( mode == 2 ) | 981 | if ( mode == 2 ) |
981 | delSel = mCalendar->incidences(); | 982 | delSel = mCalendar->incidences(); |
982 | CalendarLocal* cal = new CalendarLocal(); | 983 | CalendarLocal* cal = new CalendarLocal(); |
983 | cal->setLocalTime(); | 984 | cal->setLocalTime(); |
984 | Incidence *incidence = delSel.first(); | 985 | Incidence *incidence = delSel.first(); |
985 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 986 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
986 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 987 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
987 | while ( incidence ) { | 988 | while ( incidence ) { |
988 | if ( incidence->type() != "Journal" ) { | 989 | if ( incidence->type() != "Journal" ) { |
989 | bool add = true; | 990 | bool add = true; |
990 | if ( inFuture ) { | 991 | if ( inFuture ) { |
991 | QDateTime dt; | 992 | QDateTime dt; |
992 | if ( incidence->type() == "Todo" ) { | 993 | if ( incidence->type() == "Todo" ) { |
993 | Todo * t = (Todo*)incidence; | 994 | Todo * t = (Todo*)incidence; |
994 | if ( t->hasDueDate() ) | 995 | if ( t->hasDueDate() ) |
995 | dt = t->dtDue(); | 996 | dt = t->dtDue(); |
996 | else | 997 | else |
997 | dt = cur.addSecs( 62 ); | 998 | dt = cur.addSecs( 62 ); |
998 | } | 999 | } |
999 | else { | 1000 | else { |
1000 | bool ok; | 1001 | bool ok; |
1001 | dt = incidence->getNextOccurence( cur, &ok ); | 1002 | dt = incidence->getNextOccurence( cur, &ok ); |
1002 | if ( !ok ) | 1003 | if ( !ok ) |
1003 | dt = cur.addSecs( -62 ); | 1004 | dt = cur.addSecs( -62 ); |
1004 | } | 1005 | } |
1005 | if ( dt < cur || dt > end ) { | 1006 | if ( dt < cur || dt > end ) { |
1006 | add = false; | 1007 | add = false; |
1007 | } | 1008 | } |
1008 | } | 1009 | } |
1009 | if ( add ) { | 1010 | if ( add ) { |
1010 | Incidence *in = incidence->clone(); | 1011 | Incidence *in = incidence->clone(); |
1011 | cal->addIncidence( in ); | 1012 | cal->addIncidence( in ); |
1012 | } | 1013 | } |
1013 | } | 1014 | } |
1014 | incidence = delSel.next(); | 1015 | incidence = delSel.next(); |
1015 | } | 1016 | } |
1016 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1017 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1017 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1018 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1018 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1019 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1019 | 1020 | ||
1020 | setCaption( i18n("Writing to phone...")); | 1021 | setCaption( i18n("Writing to phone...")); |
1021 | if ( PhoneFormat::writeToPhone( cal ) ) | 1022 | if ( PhoneFormat::writeToPhone( cal ) ) |
1022 | setCaption( i18n("Export to phone successful!")); | 1023 | setCaption( i18n("Export to phone successful!")); |
1023 | else | 1024 | else |
1024 | setCaption( i18n("Error exporting to phone!")); | 1025 | setCaption( i18n("Error exporting to phone!")); |
1025 | delete cal; | 1026 | delete cal; |
1026 | } | 1027 | } |
1027 | 1028 | ||
1028 | 1029 | ||
1029 | void MainWindow::setDefaultPreferences() | 1030 | void MainWindow::setDefaultPreferences() |
1030 | { | 1031 | { |
1031 | KOPrefs *p = KOPrefs::instance(); | 1032 | KOPrefs *p = KOPrefs::instance(); |
1032 | 1033 | ||
1033 | p->mCompactDialogs = true; | 1034 | p->mCompactDialogs = true; |
1034 | p->mConfirm = true; | 1035 | p->mConfirm = true; |
1035 | // p->mEnableQuickTodo = false; | 1036 | // p->mEnableQuickTodo = false; |
1036 | 1037 | ||
1037 | } | 1038 | } |
1038 | 1039 | ||
1039 | QString MainWindow::resourcePath() | 1040 | QString MainWindow::resourcePath() |
1040 | { | 1041 | { |
1041 | return KGlobal::iconLoader()->iconPath(); | 1042 | return KGlobal::iconLoader()->iconPath(); |
1042 | } | 1043 | } |
1043 | 1044 | ||
1044 | void MainWindow::displayText( QString text ,QString cap ) | 1045 | void MainWindow::displayText( QString text ,QString cap ) |
1045 | { | 1046 | { |
1046 | QDialog dia( this, "name", true ); ; | 1047 | QDialog dia( this, "name", true ); ; |
1047 | dia.setCaption( cap ); | 1048 | dia.setCaption( cap ); |
1048 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1049 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1049 | lay->setSpacing( 3 ); | 1050 | lay->setSpacing( 3 ); |
1050 | lay->setMargin( 3 ); | 1051 | lay->setMargin( 3 ); |
1051 | QTextBrowser tb ( &dia ); | 1052 | QTextBrowser tb ( &dia ); |
1052 | lay->addWidget( &tb ); | 1053 | lay->addWidget( &tb ); |
1053 | tb.setText( text ); | 1054 | tb.setText( text ); |
1054 | #ifdef DESKTOP_VERSION | 1055 | #ifdef DESKTOP_VERSION |
1055 | dia.resize( 640, 480); | 1056 | dia.resize( 640, 480); |
1056 | #else | 1057 | #else |
1057 | dia.showMaximized(); | 1058 | dia.showMaximized(); |
1058 | #endif | 1059 | #endif |
1059 | dia.exec(); | 1060 | dia.exec(); |
1060 | } | 1061 | } |
1061 | void MainWindow::displayFile( QString fn, QString cap ) | 1062 | void MainWindow::displayFile( QString fn, QString cap ) |
1062 | { | 1063 | { |
1063 | QString fileName = resourcePath() + fn; | 1064 | QString fileName = resourcePath() + fn; |
1064 | QString text; | 1065 | QString text; |
1065 | QFile file( fileName ); | 1066 | QFile file( fileName ); |
1066 | if (!file.open( IO_ReadOnly ) ) { | 1067 | if (!file.open( IO_ReadOnly ) ) { |
1067 | return ; | 1068 | return ; |
1068 | 1069 | ||
1069 | } | 1070 | } |
1070 | QTextStream ts( &file ); | 1071 | QTextStream ts( &file ); |
1071 | text = ts.read(); | 1072 | text = ts.read(); |
1072 | file.close(); | 1073 | file.close(); |
1073 | displayText( text, cap); | 1074 | displayText( text, cap); |
1074 | } | 1075 | } |
1075 | void MainWindow::features() | 1076 | void MainWindow::features() |
1076 | { | 1077 | { |
1077 | 1078 | ||
1078 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1079 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1079 | } | 1080 | } |
1080 | 1081 | ||
1081 | void MainWindow::usertrans() | 1082 | void MainWindow::usertrans() |
1082 | { | 1083 | { |
1083 | 1084 | ||
1084 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1085 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1085 | } | 1086 | } |
1086 | 1087 | ||
1087 | void MainWindow::synchowto() | 1088 | void MainWindow::synchowto() |
1088 | { | 1089 | { |
1089 | #if 0 | 1090 | #if 0 |
1090 | QPtrList<Incidence> er = mCalendar->rawIncidences(); | 1091 | QPtrList<Incidence> er = mCalendar->rawIncidences(); |
1091 | Incidence* inR = er.first(); | 1092 | Incidence* inR = er.first(); |
1092 | VCalFormat vf; | 1093 | VCalFormat vf; |
1093 | QString strout; | 1094 | QString strout; |
1094 | while ( inR ) { | 1095 | while ( inR ) { |
1095 | if ( inR->type() == "Todo" ) | 1096 | if ( inR->type() == "Todo" ) |
1096 | strout = vf.todoToString( (Todo *) inR ); | 1097 | strout = vf.todoToString( (Todo *) inR ); |
1097 | if ( inR->type() == "Event" ) | 1098 | if ( inR->type() == "Event" ) |
1098 | strout = vf.eventToString( (Event *) inR ); | 1099 | strout = vf.eventToString( (Event *) inR ); |
1099 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); | 1100 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); |
1100 | inR = er.next(); | 1101 | inR = er.next(); |
1101 | } | 1102 | } |
1102 | #endif | 1103 | #endif |
1103 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); | 1104 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); |
1104 | } | 1105 | } |
1105 | void MainWindow::faq() | 1106 | void MainWindow::faq() |
1106 | { | 1107 | { |
1107 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1108 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1108 | 1109 | ||
1109 | } | 1110 | } |
1110 | void MainWindow::whatsNew() | 1111 | void MainWindow::whatsNew() |
1111 | { | 1112 | { |
1112 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); | 1113 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); |
1113 | 1114 | ||
1114 | } | 1115 | } |
1115 | void MainWindow::licence() | 1116 | void MainWindow::licence() |
1116 | { | 1117 | { |
1117 | KApplication::showLicence(); | 1118 | KApplication::showLicence(); |
1118 | 1119 | ||
1119 | } | 1120 | } |
1120 | void MainWindow::about() | 1121 | void MainWindow::about() |
1121 | { | 1122 | { |
1122 | QString version; | 1123 | QString version; |
1123 | #include <../version> | 1124 | #include <../version> |
1124 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1125 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1125 | i18n("KOrganizer/Platform-independent\n") + | 1126 | i18n("KOrganizer/Platform-independent\n") + |
1126 | "(KO/Pi) " + version + " - " + | 1127 | "(KO/Pi) " + version + " - " + |
1127 | 1128 | ||
1128 | #ifdef DESKTOP_VERSION | 1129 | #ifdef DESKTOP_VERSION |
1129 | i18n("Desktop Edition\n") + | 1130 | i18n("Desktop Edition\n") + |
1130 | #else | 1131 | #else |
1131 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1132 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1132 | #endif | 1133 | #endif |
1133 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); | 1134 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); |
1134 | } | 1135 | } |
1135 | void MainWindow::keyBindings() | 1136 | void MainWindow::keyBindings() |
1136 | { | 1137 | { |
1137 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1138 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1138 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1139 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1139 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1140 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1140 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1141 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1141 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1142 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1142 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1143 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1143 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1144 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1144 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1145 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1145 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1146 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1146 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1147 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1147 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1148 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1148 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1149 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1149 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1150 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1150 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1151 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1151 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1152 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1152 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1153 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1153 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1154 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1154 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1155 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1155 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1156 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1156 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1157 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1157 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1158 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1158 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1159 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1159 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1160 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1160 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1161 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1161 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1162 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1162 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1163 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1163 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1164 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1164 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1165 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1165 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1166 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1166 | i18n("<p><h3>In list view:</h3></p>\n") + | 1167 | i18n("<p><h3>In list view:</h3></p>\n") + |
1167 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1168 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1168 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1169 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1169 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1170 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1170 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1171 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1171 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1172 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1172 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1173 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1173 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1174 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1174 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1175 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1175 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1176 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1176 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1177 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1177 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1178 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1178 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1179 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1179 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1180 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1180 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1181 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1181 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1182 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1182 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1183 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1183 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1184 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1184 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1185 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1185 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1186 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1186 | displayText( text, cap); | 1187 | displayText( text, cap); |
1187 | 1188 | ||
1188 | } | 1189 | } |
1189 | void MainWindow::aboutAutoSaving() | 1190 | void MainWindow::aboutAutoSaving() |
1190 | { | 1191 | { |
1191 | QMessageBox* msg; | 1192 | QMessageBox* msg; |
1192 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1193 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1193 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, | 1194 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, |
1194 | QMessageBox::Ok, | 1195 | QMessageBox::Ok, |
1195 | QMessageBox::NoButton, | 1196 | QMessageBox::NoButton, |
1196 | QMessageBox::NoButton); | 1197 | QMessageBox::NoButton); |
1197 | msg->exec(); | 1198 | msg->exec(); |
1198 | delete msg; | 1199 | delete msg; |
1199 | 1200 | ||
1200 | 1201 | ||
1201 | } | 1202 | } |
1202 | void MainWindow::aboutKnownBugs() | 1203 | void MainWindow::aboutKnownBugs() |
1203 | { | 1204 | { |
1204 | QMessageBox* msg; | 1205 | QMessageBox* msg; |
1205 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1206 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1206 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1207 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1207 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1208 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1208 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1209 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1209 | i18n("\nor report them in the bugtracker on\n") + | 1210 | i18n("\nor report them in the bugtracker on\n") + |
1210 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1211 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1211 | QMessageBox::NoIcon, | 1212 | QMessageBox::NoIcon, |
1212 | QMessageBox::Ok, | 1213 | QMessageBox::Ok, |
1213 | QMessageBox::NoButton, | 1214 | QMessageBox::NoButton, |
1214 | QMessageBox::NoButton); | 1215 | QMessageBox::NoButton); |
1215 | msg->exec(); | 1216 | msg->exec(); |
1216 | delete msg; | 1217 | delete msg; |
1217 | 1218 | ||
1218 | } | 1219 | } |
1219 | 1220 | ||
1220 | QString MainWindow::defaultFileName() | 1221 | QString MainWindow::defaultFileName() |
1221 | { | 1222 | { |
1222 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1223 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1223 | } | 1224 | } |
1224 | QString MainWindow::syncFileName() | 1225 | QString MainWindow::syncFileName() |
1225 | { | 1226 | { |
1226 | #ifdef _WIN32_ | 1227 | #ifdef _WIN32_ |
1227 | return locateLocal( "tmp", "synccalendar.ics" ); | 1228 | return locateLocal( "tmp", "synccalendar.ics" ); |
1228 | #else | 1229 | #else |
1229 | return QString( "/tmp/kopitempfile.ics" ); | 1230 | return QString( "/tmp/kopitempfile.ics" ); |
1230 | #endif | 1231 | #endif |
1231 | } | 1232 | } |
1232 | 1233 | ||
1233 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1234 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1234 | { | 1235 | { |
1235 | if ( !incidence ) { | 1236 | if ( !incidence ) { |
1236 | enableIncidenceActions( false ); | 1237 | enableIncidenceActions( false ); |
1237 | 1238 | ||
1238 | mNewSubTodoAction->setEnabled( false ); | 1239 | mNewSubTodoAction->setEnabled( false ); |
1239 | setCaptionToDates(); | 1240 | setCaptionToDates(); |
1240 | return; | 1241 | return; |
1241 | 1242 | ||
1242 | } | 1243 | } |
1243 | 1244 | ||
1244 | //KGlobal::locale()->formatDateTime(nextA, true); | 1245 | //KGlobal::locale()->formatDateTime(nextA, true); |
1245 | QString startString = ""; | 1246 | QString startString = ""; |
1246 | if ( incidence->type() != "Todo" ) { | 1247 | if ( incidence->type() != "Todo" ) { |
1247 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1248 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1248 | if ( incidence->doesFloat() ) { | 1249 | if ( incidence->doesFloat() ) { |
1249 | startString += ": "+incidence->dtStartDateStr( true ); | 1250 | startString += ": "+incidence->dtStartDateStr( true ); |
1250 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1251 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1251 | 1252 | ||
1252 | } else { | 1253 | } else { |
1253 | startString = ": "+incidence->dtStartStr(true); | 1254 | startString = ": "+incidence->dtStartStr(true); |
1254 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1255 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1255 | 1256 | ||
1256 | } | 1257 | } |
1257 | 1258 | ||
1258 | } else { | 1259 | } else { |
1259 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1260 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1260 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1261 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1261 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1262 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1262 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1263 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1263 | } | 1264 | } |
1264 | 1265 | ||
1265 | } | 1266 | } |
1266 | else | 1267 | else |
1267 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1268 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1268 | if ( !incidence->location().isEmpty() ) | 1269 | if ( !incidence->location().isEmpty() ) |
1269 | startString += " (" +incidence->location()+")"; | 1270 | startString += " (" +incidence->location()+")"; |
1270 | setCaption( incidence->summary()+startString); | 1271 | setCaption( incidence->summary()+startString); |
1271 | 1272 | ||
1272 | enableIncidenceActions( true ); | 1273 | enableIncidenceActions( true ); |
1273 | 1274 | ||
1274 | if ( incidence->type() == "Event" ) { | 1275 | if ( incidence->type() == "Event" ) { |
1275 | mShowAction->setText( i18n("Show Event...") ); | 1276 | mShowAction->setText( i18n("Show Event...") ); |
1276 | mEditAction->setText( i18n("Edit Event...") ); | 1277 | mEditAction->setText( i18n("Edit Event...") ); |
1277 | mDeleteAction->setText( i18n("Delete Event...") ); | 1278 | mDeleteAction->setText( i18n("Delete Event...") ); |
1278 | 1279 | ||
1279 | mNewSubTodoAction->setEnabled( false ); | 1280 | mNewSubTodoAction->setEnabled( false ); |
1280 | } else if ( incidence->type() == "Todo" ) { | 1281 | } else if ( incidence->type() == "Todo" ) { |
1281 | mShowAction->setText( i18n("Show Todo...") ); | 1282 | mShowAction->setText( i18n("Show Todo...") ); |
1282 | mEditAction->setText( i18n("Edit Todo...") ); | 1283 | mEditAction->setText( i18n("Edit Todo...") ); |
1283 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1284 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1284 | 1285 | ||
1285 | mNewSubTodoAction->setEnabled( true ); | 1286 | mNewSubTodoAction->setEnabled( true ); |
1286 | } else { | 1287 | } else { |
1287 | mShowAction->setText( i18n("Show...") ); | 1288 | mShowAction->setText( i18n("Show...") ); |
1288 | mShowAction->setText( i18n("Edit...") ); | 1289 | mShowAction->setText( i18n("Edit...") ); |
1289 | mShowAction->setText( i18n("Delete...") ); | 1290 | mShowAction->setText( i18n("Delete...") ); |
1290 | 1291 | ||
1291 | mNewSubTodoAction->setEnabled( false ); | 1292 | mNewSubTodoAction->setEnabled( false ); |
1292 | } | 1293 | } |
1293 | } | 1294 | } |
1294 | 1295 | ||
1295 | void MainWindow::enableIncidenceActions( bool enabled ) | 1296 | void MainWindow::enableIncidenceActions( bool enabled ) |
1296 | { | 1297 | { |
1297 | mShowAction->setEnabled( enabled ); | 1298 | mShowAction->setEnabled( enabled ); |
1298 | mEditAction->setEnabled( enabled ); | 1299 | mEditAction->setEnabled( enabled ); |
1299 | mDeleteAction->setEnabled( enabled ); | 1300 | mDeleteAction->setEnabled( enabled ); |
1300 | 1301 | ||
1301 | mCloneAction->setEnabled( enabled ); | 1302 | mCloneAction->setEnabled( enabled ); |
1302 | mMoveAction->setEnabled( enabled ); | 1303 | mMoveAction->setEnabled( enabled ); |
1303 | mBeamAction->setEnabled( enabled ); | 1304 | mBeamAction->setEnabled( enabled ); |
1304 | mCancelAction->setEnabled( enabled ); | 1305 | mCancelAction->setEnabled( enabled ); |
1305 | } | 1306 | } |
1306 | 1307 | ||
1307 | void MainWindow::importOL() | 1308 | void MainWindow::importOL() |
1308 | { | 1309 | { |
1309 | #ifdef _WIN32_ | 1310 | #ifdef _WIN32_ |
1310 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1311 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1311 | id->exec(); | 1312 | id->exec(); |
1312 | delete id; | 1313 | delete id; |
1313 | mView->updateView(); | 1314 | mView->updateView(); |
1314 | #endif | 1315 | #endif |
1315 | } | 1316 | } |
1316 | void MainWindow::importBday() | 1317 | void MainWindow::importBday() |
1317 | { | 1318 | { |
1318 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1319 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1319 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1320 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1320 | i18n("Import!"), i18n("Cancel"), 0, | 1321 | i18n("Import!"), i18n("Cancel"), 0, |
1321 | 0, 1 ); | 1322 | 0, 1 ); |
1322 | if ( result == 0 ) { | 1323 | if ( result == 0 ) { |
1323 | mView->importBday(); | 1324 | mView->importBday(); |
1324 | 1325 | ||
1325 | } | 1326 | } |
1326 | 1327 | ||
1327 | 1328 | ||
1328 | } | 1329 | } |
1329 | void MainWindow::importQtopia() | 1330 | void MainWindow::importQtopia() |
1330 | { | 1331 | { |
1331 | #ifndef DESKTOP_VERSION | 1332 | #ifndef DESKTOP_VERSION |
1332 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1333 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1333 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1334 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1334 | i18n("Import!"), i18n("Cancel"), 0, | 1335 | i18n("Import!"), i18n("Cancel"), 0, |
1335 | 0, 1 ); | 1336 | 0, 1 ); |
1336 | if ( result == 0 ) { | 1337 | if ( result == 0 ) { |
1337 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1338 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1338 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1339 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1339 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1340 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1340 | mView->importQtopia( categories, datebook, todolist ); | 1341 | mView->importQtopia( categories, datebook, todolist ); |
1341 | } | 1342 | } |
1342 | #else | 1343 | #else |
1343 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1344 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1344 | i18n("Not supported \non desktop!\n"), | 1345 | i18n("Not supported \non desktop!\n"), |
1345 | i18n("Ok"), i18n("Cancel"), 0, | 1346 | i18n("Ok"), i18n("Cancel"), 0, |
1346 | 0, 1 ); | 1347 | 0, 1 ); |
1347 | 1348 | ||
1348 | #endif | 1349 | #endif |
1349 | } | 1350 | } |
1350 | 1351 | ||
1351 | void MainWindow::saveOnClose() | 1352 | void MainWindow::saveOnClose() |
1352 | { | 1353 | { |
1353 | KOPrefs *p = KOPrefs::instance(); | 1354 | KOPrefs *p = KOPrefs::instance(); |
1354 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1355 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1355 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1356 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1356 | iconToolBar->y() > height()/2; | 1357 | iconToolBar->y() > height()/2; |
1357 | mView->writeSettings(); | 1358 | mView->writeSettings(); |
1358 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1359 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1359 | save(); | 1360 | save(); |
1360 | } | 1361 | } |
1361 | void MainWindow::slotModifiedChanged( bool changed ) | 1362 | void MainWindow::slotModifiedChanged( bool changed ) |
1362 | { | 1363 | { |
1363 | if ( mBlockAtStartup ) | 1364 | if ( mBlockAtStartup ) |
1364 | return; | 1365 | return; |
1365 | int msec; | 1366 | int msec; |
1366 | // we store the changes after 1 minute, | 1367 | // we store the changes after 1 minute, |
1367 | // and for safety reasons after 10 minutes again | 1368 | // and for safety reasons after 10 minutes again |
1368 | if ( !mSyncManager->blockSave() ) | 1369 | if ( !mSyncManager->blockSave() ) |
1369 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1370 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1370 | else | 1371 | else |
1371 | msec = 1000 * 600; | 1372 | msec = 1000 * 600; |
1372 | mSaveTimer.start( msec, true ); // 1 minute | 1373 | mSaveTimer.start( msec, true ); // 1 minute |
1373 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1374 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1374 | mCalendarModifiedFlag = true; | 1375 | mCalendarModifiedFlag = true; |
1375 | } | 1376 | } |
1376 | void MainWindow::save() | 1377 | void MainWindow::save() |
1377 | { | 1378 | { |
1378 | if ( mSyncManager->blockSave() ) | 1379 | if ( mSyncManager->blockSave() ) |
1379 | return; | 1380 | return; |
1380 | mSyncManager->setBlockSave(true); | 1381 | mSyncManager->setBlockSave(true); |
1381 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1382 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1382 | 1383 | ||
1383 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1384 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1384 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1385 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1385 | qDebug("KO: Start saving data to file!"); | 1386 | qDebug("KO: Start saving data to file!"); |
1386 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1387 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1387 | mView->saveCalendar( defaultFileName() ); | 1388 | mView->saveCalendar( defaultFileName() ); |
1388 | 1389 | ||
1389 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1390 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1390 | mView->watchSavedFile(); | 1391 | mView->watchSavedFile(); |
1391 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1392 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1392 | QString savemes; | 1393 | QString savemes; |
1393 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1394 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1394 | setCaption(savemes); | 1395 | setCaption(savemes); |
1395 | } else | 1396 | } else |
1396 | setCaption(i18n("Saving cancelled!")); | 1397 | setCaption(i18n("Saving cancelled!")); |
1397 | mCalendarModifiedFlag = false; | 1398 | mCalendarModifiedFlag = false; |
1398 | mSyncManager->setBlockSave( false ); | 1399 | mSyncManager->setBlockSave( false ); |
1399 | } | 1400 | } |
1400 | 1401 | ||
1401 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1402 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1402 | { | 1403 | { |
1403 | if ( !e->isAutoRepeat() ) { | 1404 | if ( !e->isAutoRepeat() ) { |
1404 | mFlagKeyPressed = false; | 1405 | mFlagKeyPressed = false; |
1405 | } | 1406 | } |
1406 | } | 1407 | } |
1407 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1408 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1408 | { | 1409 | { |
1409 | qApp->processEvents(); | 1410 | qApp->processEvents(); |
1410 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1411 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1411 | e->ignore(); | 1412 | e->ignore(); |
1412 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1413 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1413 | return; | 1414 | return; |
1414 | } | 1415 | } |
1415 | if (! e->isAutoRepeat() ) | 1416 | if (! e->isAutoRepeat() ) |
1416 | mFlagKeyPressed = true; | 1417 | mFlagKeyPressed = true; |
1417 | KOPrefs *p = KOPrefs::instance(); | 1418 | KOPrefs *p = KOPrefs::instance(); |
1418 | bool showSelectedDates = false; | 1419 | bool showSelectedDates = false; |
1419 | int size; | 1420 | int size; |
1420 | int pro = 0; | 1421 | int pro = 0; |
1421 | //qDebug("MainWindow::keyPressEvent "); | 1422 | //qDebug("MainWindow::keyPressEvent "); |
1422 | switch ( e->key() ) { | 1423 | switch ( e->key() ) { |
1423 | case Qt::Key_Right: | 1424 | case Qt::Key_Right: |
1424 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1425 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1425 | mView->goNextMonth(); | 1426 | mView->goNextMonth(); |
1426 | else | 1427 | else |
1427 | mView->goNext(); | 1428 | mView->goNext(); |
1428 | showSelectedDates = true; | 1429 | showSelectedDates = true; |
1429 | break; | 1430 | break; |
1430 | case Qt::Key_Left: | 1431 | case Qt::Key_Left: |
1431 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1432 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1432 | mView->goPreviousMonth(); | 1433 | mView->goPreviousMonth(); |
1433 | else | 1434 | else |
1434 | mView->goPrevious(); | 1435 | mView->goPrevious(); |
1435 | showSelectedDates = true; | 1436 | showSelectedDates = true; |
1436 | break; | 1437 | break; |
1437 | case Qt::Key_Down: | 1438 | case Qt::Key_Down: |
1438 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1439 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1439 | break; | 1440 | break; |
1440 | case Qt::Key_Up: | 1441 | case Qt::Key_Up: |
1441 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1442 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1442 | break; | 1443 | break; |
1443 | case Qt::Key_I: | 1444 | case Qt::Key_I: |
1444 | mView->showIncidence(); | 1445 | mView->showIncidence(); |
1445 | break; | 1446 | break; |
1446 | case Qt::Key_Delete: | 1447 | case Qt::Key_Delete: |
1447 | case Qt::Key_Backspace: | 1448 | case Qt::Key_Backspace: |
1448 | mView->deleteIncidence(); | 1449 | mView->deleteIncidence(); |
1449 | break; | 1450 | break; |
1450 | case Qt::Key_D: | 1451 | case Qt::Key_D: |
1451 | mView->viewManager()->showDayView(); | 1452 | mView->viewManager()->showDayView(); |
1452 | showSelectedDates = true; | 1453 | showSelectedDates = true; |
1453 | break; | 1454 | break; |
1454 | case Qt::Key_O: | 1455 | case Qt::Key_O: |
1455 | mView->toggleFilerEnabled( ); | 1456 | mView->toggleFilerEnabled( ); |
1456 | break; | 1457 | break; |
1457 | case Qt::Key_0: | 1458 | case Qt::Key_0: |
1458 | case Qt::Key_1: | 1459 | case Qt::Key_1: |
1459 | case Qt::Key_2: | 1460 | case Qt::Key_2: |
1460 | case Qt::Key_3: | 1461 | case Qt::Key_3: |
1461 | case Qt::Key_4: | 1462 | case Qt::Key_4: |
1462 | case Qt::Key_5: | 1463 | case Qt::Key_5: |
1463 | case Qt::Key_6: | 1464 | case Qt::Key_6: |
1464 | case Qt::Key_7: | 1465 | case Qt::Key_7: |
1465 | case Qt::Key_8: | 1466 | case Qt::Key_8: |
1466 | case Qt::Key_9: | 1467 | case Qt::Key_9: |
1467 | pro = e->key()-48; | 1468 | pro = e->key()-48; |
1468 | if ( pro == 0 ) | 1469 | if ( pro == 0 ) |
1469 | pro = 10; | 1470 | pro = 10; |
1470 | if ( e->state() == Qt::ControlButton) | 1471 | if ( e->state() == Qt::ControlButton) |
1471 | pro += 10; | 1472 | pro += 10; |
1472 | break; | 1473 | break; |
1473 | case Qt::Key_M: | 1474 | case Qt::Key_M: |
1474 | mView->viewManager()->showMonthView(); | 1475 | mView->viewManager()->showMonthView(); |
1475 | showSelectedDates = true; | 1476 | showSelectedDates = true; |
1476 | break; | 1477 | break; |
1477 | case Qt::Key_Insert: | 1478 | case Qt::Key_Insert: |
1478 | mView->newEvent(); | 1479 | mView->newEvent(); |
1479 | break; | 1480 | break; |
1480 | case Qt::Key_S : | 1481 | case Qt::Key_S : |
1481 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1482 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1482 | mView->newSubTodo(); | 1483 | mView->newSubTodo(); |
1483 | else | 1484 | else |
1484 | mView->dialogManager()->showSearchDialog(); | 1485 | mView->dialogManager()->showSearchDialog(); |
1485 | break; | 1486 | break; |
1486 | case Qt::Key_Y : | 1487 | case Qt::Key_Y : |
1487 | case Qt::Key_Z : | 1488 | case Qt::Key_Z : |
1488 | mView->viewManager()->showWorkWeekView(); | 1489 | mView->viewManager()->showWorkWeekView(); |
1489 | showSelectedDates = true; | 1490 | showSelectedDates = true; |
1490 | break; | 1491 | break; |
1491 | case Qt::Key_U : | 1492 | case Qt::Key_U : |
1492 | mView->viewManager()->showWeekView(); | 1493 | mView->viewManager()->showWeekView(); |
1493 | showSelectedDates = true; | 1494 | showSelectedDates = true; |
1494 | break; | 1495 | break; |
1495 | case Qt::Key_H : | 1496 | case Qt::Key_H : |
1496 | keyBindings(); | 1497 | keyBindings(); |
1497 | break; | 1498 | break; |
1498 | case Qt::Key_W: | 1499 | case Qt::Key_W: |
1499 | mView->viewManager()->showWhatsNextView(); | 1500 | mView->viewManager()->showWhatsNextView(); |
1500 | break; | 1501 | break; |
1501 | case Qt::Key_L: | 1502 | case Qt::Key_L: |
1502 | mView->viewManager()->showListView(); | 1503 | mView->viewManager()->showListView(); |
1503 | break; | 1504 | break; |
1504 | case Qt::Key_N: | 1505 | case Qt::Key_N: |
1505 | mView->viewManager()->showNextXView(); | 1506 | mView->viewManager()->showNextXView(); |
1506 | showSelectedDates = true; | 1507 | showSelectedDates = true; |
1507 | break; | 1508 | break; |
1508 | case Qt::Key_V: | 1509 | case Qt::Key_V: |
1509 | mView->viewManager()->showTodoView(); | 1510 | mView->viewManager()->showTodoView(); |
1510 | break; | 1511 | break; |
1511 | case Qt::Key_C: | 1512 | case Qt::Key_C: |
1512 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1513 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1513 | break; | 1514 | break; |
1514 | case Qt::Key_P: | 1515 | case Qt::Key_P: |
1515 | mView->showDatePicker( ); | 1516 | mView->showDatePicker( ); |
1516 | break; | 1517 | break; |
1517 | case Qt::Key_F: | 1518 | case Qt::Key_F: |
1518 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1519 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1519 | mView->editFilters(); | 1520 | mView->editFilters(); |
1520 | else | 1521 | else |
1521 | mView->toggleFilter(); | 1522 | mView->toggleFilter(); |
1522 | break; | 1523 | break; |
1523 | case Qt::Key_X: | 1524 | case Qt::Key_X: |
1524 | mView->toggleDateNavigatorWidget(); | 1525 | mView->toggleDateNavigatorWidget(); |
1525 | break; | 1526 | break; |
1526 | case Qt::Key_Space: | 1527 | case Qt::Key_Space: |
1527 | mView->toggleExpand(); | 1528 | mView->toggleExpand(); |
1528 | break; | 1529 | break; |
1529 | case Qt::Key_A: | 1530 | case Qt::Key_A: |
1530 | mView->toggleAllDaySize(); | 1531 | mView->toggleAllDaySize(); |
1531 | break; | 1532 | break; |
1532 | case Qt::Key_T: | 1533 | case Qt::Key_T: |
1533 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1534 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1534 | mView->newTodo(); | 1535 | mView->newTodo(); |
1535 | else { | 1536 | else { |
1536 | mView->goToday(); | 1537 | mView->goToday(); |
1537 | showSelectedDates = true; | 1538 | showSelectedDates = true; |
1538 | } | 1539 | } |
1539 | break; | 1540 | break; |
1540 | case Qt::Key_J: | 1541 | case Qt::Key_J: |
1541 | mView->viewManager()->showJournalView(); | 1542 | mView->viewManager()->showJournalView(); |
1542 | break; | 1543 | break; |
1543 | case Qt::Key_B: | 1544 | case Qt::Key_B: |
1544 | mView->editIncidenceDescription();; | 1545 | mView->editIncidenceDescription();; |
1545 | break; | 1546 | break; |
1546 | // case Qt::Key_Return: | 1547 | // case Qt::Key_Return: |
1547 | case Qt::Key_E: | 1548 | case Qt::Key_E: |
1548 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1549 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1549 | mView->newEvent(); | 1550 | mView->newEvent(); |
1550 | else | 1551 | else |
1551 | mView->editIncidence(); | 1552 | mView->editIncidence(); |
1552 | break; | 1553 | break; |
1553 | case Qt::Key_Plus: | 1554 | case Qt::Key_Plus: |
1554 | size = p->mHourSize +2; | 1555 | size = p->mHourSize +2; |
1555 | if ( size <= 18 ) | 1556 | if ( size <= 18 ) |
1556 | configureAgenda( size ); | 1557 | configureAgenda( size ); |
1557 | break; | 1558 | break; |
1558 | case Qt::Key_Minus: | 1559 | case Qt::Key_Minus: |
1559 | size = p->mHourSize - 2; | 1560 | size = p->mHourSize - 2; |
1560 | if ( size >= 4 ) | 1561 | if ( size >= 4 ) |
1561 | configureAgenda( size ); | 1562 | configureAgenda( size ); |
1562 | break; | 1563 | break; |
1563 | 1564 | ||
1564 | 1565 | ||
1565 | default: | 1566 | default: |
1566 | e->ignore(); | 1567 | e->ignore(); |
1567 | } | 1568 | } |
1568 | if ( pro > 0 ) { | 1569 | if ( pro > 0 ) { |
1569 | mView->selectFilter( pro-1 ); | 1570 | mView->selectFilter( pro-1 ); |
1570 | } | 1571 | } |
1571 | if ( showSelectedDates ) { | 1572 | if ( showSelectedDates ) { |
1572 | ;// setCaptionToDates(); | 1573 | ;// setCaptionToDates(); |
1573 | } | 1574 | } |
1574 | 1575 | ||
1575 | } | 1576 | } |
1576 | 1577 | ||
1577 | void MainWindow::fillFilterMenu() | 1578 | void MainWindow::fillFilterMenu() |
1578 | { | 1579 | { |
1579 | selectFilterMenu->clear(); | 1580 | selectFilterMenu->clear(); |
1580 | bool disable = false; | 1581 | bool disable = false; |
1581 | if ( mView->filterView()->filtersEnabled() ) { | 1582 | if ( mView->filterView()->filtersEnabled() ) { |
1582 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1583 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1583 | } | 1584 | } |
1584 | else { | 1585 | else { |
1585 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1586 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1586 | disable = true; | 1587 | disable = true; |
1587 | } | 1588 | } |
1588 | selectFilterMenu->insertSeparator(); | 1589 | selectFilterMenu->insertSeparator(); |
1589 | QPtrList<CalFilter> fili = mView->filters(); | 1590 | QPtrList<CalFilter> fili = mView->filters(); |
1590 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1591 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1591 | CalFilter *filter = fili.first(); | 1592 | CalFilter *filter = fili.first(); |
1592 | int iii = 1; | 1593 | int iii = 1; |
1593 | while(filter) { | 1594 | while(filter) { |
1594 | selectFilterMenu->insertItem( filter->name(), iii ); | 1595 | selectFilterMenu->insertItem( filter->name(), iii ); |
1595 | if ( filter == curfilter) | 1596 | if ( filter == curfilter) |
1596 | selectFilterMenu->setItemChecked( iii, true ); | 1597 | selectFilterMenu->setItemChecked( iii, true ); |
1597 | if ( disable ) | 1598 | if ( disable ) |
1598 | selectFilterMenu->setItemEnabled( iii, false ); | 1599 | selectFilterMenu->setItemEnabled( iii, false ); |
1599 | filter = fili.next(); | 1600 | filter = fili.next(); |
1600 | ++iii; | 1601 | ++iii; |
1601 | } | 1602 | } |
1602 | } | 1603 | } |
1603 | void MainWindow::selectFilter( int fil ) | 1604 | void MainWindow::selectFilter( int fil ) |
1604 | { | 1605 | { |
1605 | if ( fil == 0 ) { | 1606 | if ( fil == 0 ) { |
1606 | mView->toggleFilerEnabled( ); | 1607 | mView->toggleFilerEnabled( ); |
1607 | } else { | 1608 | } else { |
1608 | mView->selectFilter( fil-1 ); | 1609 | mView->selectFilter( fil-1 ); |
1609 | } | 1610 | } |
1610 | } | 1611 | } |
1611 | void MainWindow::configureToolBar( int item ) | 1612 | void MainWindow::configureToolBar( int item ) |
1612 | { | 1613 | { |
1613 | 1614 | ||
1614 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1615 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1615 | KOPrefs *p = KOPrefs::instance(); | 1616 | KOPrefs *p = KOPrefs::instance(); |
1616 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1617 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1617 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1618 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1618 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1619 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1619 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1620 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1620 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1621 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1621 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1622 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1622 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1623 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1623 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1624 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1624 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1625 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1625 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1626 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1626 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1627 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1627 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1628 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1628 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1629 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1629 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1630 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1630 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1631 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1631 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1632 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1632 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1633 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1633 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1634 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1634 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1635 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1635 | // initActions(); | 1636 | // initActions(); |
1636 | } | 1637 | } |
1637 | 1638 | ||
1638 | void MainWindow::setCaptionToDates() | 1639 | void MainWindow::setCaptionToDates() |
1639 | { | 1640 | { |
1640 | QString selDates; | 1641 | QString selDates; |
1641 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1642 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1642 | if (mView->startDate() < mView->endDate() ) | 1643 | if (mView->startDate() < mView->endDate() ) |
1643 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1644 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1644 | setCaption( i18n("Dates: ") + selDates ); | 1645 | setCaption( i18n("Dates: ") + selDates ); |
1645 | 1646 | ||
1646 | } | 1647 | } |
1647 | // parameter item == 0: reinit | 1648 | // parameter item == 0: reinit |
1648 | void MainWindow::configureAgenda( int item ) | 1649 | void MainWindow::configureAgenda( int item ) |
1649 | { | 1650 | { |
1650 | 1651 | ||
1651 | KOPrefs *p = KOPrefs::instance(); | 1652 | KOPrefs *p = KOPrefs::instance(); |
1652 | 1653 | ||
1653 | int i; | 1654 | int i; |
1654 | if ( item == 1 ) { | 1655 | if ( item == 1 ) { |
1655 | mView->toggleAllDaySize(); | 1656 | mView->toggleAllDaySize(); |
1656 | return; | 1657 | return; |
1657 | } | 1658 | } |
1658 | // do not allow 4 for widgets higher than 480 | 1659 | // do not allow 4 for widgets higher than 480 |
1659 | // if ( QApplication::desktop()->height() > 480 ) { | 1660 | // if ( QApplication::desktop()->height() > 480 ) { |
1660 | // if ( item == 4 ) | 1661 | // if ( item == 4 ) |
1661 | // item = 6; | 1662 | // item = 6; |
1662 | // } | 1663 | // } |
1663 | for ( i = 4; i <= 18; i= i+2 ) | 1664 | for ( i = 4; i <= 18; i= i+2 ) |
1664 | configureAgendaMenu->setItemChecked( i, false ); | 1665 | configureAgendaMenu->setItemChecked( i, false ); |
1665 | configureAgendaMenu->setItemChecked( item, true ); | 1666 | configureAgendaMenu->setItemChecked( item, true ); |
1666 | if ( p->mHourSize == item ) | 1667 | if ( p->mHourSize == item ) |
1667 | return; | 1668 | return; |
1668 | p->mHourSize=item; | 1669 | p->mHourSize=item; |
1669 | mView->viewManager()->agendaView()->updateConfig(); | 1670 | mView->viewManager()->agendaView()->updateConfig(); |
1670 | } | 1671 | } |
1671 | 1672 | ||
1672 | void MainWindow::saveCalendar() | 1673 | void MainWindow::saveCalendar() |
1673 | { | 1674 | { |
1674 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1675 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1675 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1676 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1676 | 1677 | ||
1677 | if ( fn == "" ) | 1678 | if ( fn == "" ) |
1678 | return; | 1679 | return; |
1679 | QFileInfo info; | 1680 | QFileInfo info; |
1680 | info.setFile( fn ); | 1681 | info.setFile( fn ); |
1681 | QString mes; | 1682 | QString mes; |
1682 | bool createbup = true; | 1683 | bool createbup = true; |
1683 | if ( info. exists() ) { | 1684 | if ( info. exists() ) { |
1684 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1685 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1685 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1686 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1686 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1687 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1687 | 0, 1 ); | 1688 | 0, 1 ); |
1688 | if ( result != 0 ) { | 1689 | if ( result != 0 ) { |
1689 | createbup = false; | 1690 | createbup = false; |
1690 | } | 1691 | } |
1691 | } | 1692 | } |
1692 | if ( createbup ) { | 1693 | if ( createbup ) { |
1693 | mView->saveCalendar( fn ); | 1694 | mView->saveCalendar( fn ); |
1694 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1695 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1695 | KOPrefs::instance()->mLastSaveFile = fn; | 1696 | KOPrefs::instance()->mLastSaveFile = fn; |
1696 | setCaption(mes); | 1697 | setCaption(mes); |
1697 | } | 1698 | } |
1698 | } | 1699 | } |
1699 | void MainWindow::loadCalendar() | 1700 | void MainWindow::loadCalendar() |
1700 | { | 1701 | { |
1701 | 1702 | ||
1702 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1703 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1703 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1704 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1704 | 1705 | ||
1705 | if ( fn == "" ) | 1706 | if ( fn == "" ) |
1706 | return; | 1707 | return; |
1707 | QFileInfo info; | 1708 | QFileInfo info; |
1708 | info.setFile( fn ); | 1709 | info.setFile( fn ); |
1709 | QString mess; | 1710 | QString mess; |
1710 | bool loadbup = true; | 1711 | bool loadbup = true; |
1711 | if ( info. exists() ) { | 1712 | if ( info. exists() ) { |
1712 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1713 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1713 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1714 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1714 | mess, | 1715 | mess, |
1715 | i18n("Load!"), i18n("Cancel"), 0, | 1716 | i18n("Load!"), i18n("Cancel"), 0, |
1716 | 0, 1 ); | 1717 | 0, 1 ); |
1717 | if ( result != 0 ) { | 1718 | if ( result != 0 ) { |
1718 | loadbup = false; | 1719 | loadbup = false; |
1719 | } | 1720 | } |
1720 | } else { | 1721 | } else { |
1721 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1722 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1722 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1723 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1723 | 0, 1 ); | 1724 | 0, 1 ); |
1724 | 1725 | ||
1725 | return; | 1726 | return; |
1726 | } | 1727 | } |
1727 | if ( loadbup ) { | 1728 | if ( loadbup ) { |
1728 | mView->openCalendar( fn ); | 1729 | mView->openCalendar( fn ); |
1729 | KOPrefs::instance()->mLastLoadFile = fn; | 1730 | KOPrefs::instance()->mLastLoadFile = fn; |
1730 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1731 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1731 | setCaption(mess); | 1732 | setCaption(mess); |
1732 | } | 1733 | } |
1733 | 1734 | ||
1734 | } | 1735 | } |
1735 | void MainWindow::quickImportIcal() | 1736 | void MainWindow::quickImportIcal() |
1736 | { | 1737 | { |
1737 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1738 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1738 | } | 1739 | } |
1739 | void MainWindow::importFile( QString fn, bool quick ) | 1740 | void MainWindow::importFile( QString fn, bool quick ) |
1740 | { | 1741 | { |
1741 | QFileInfo info; | 1742 | QFileInfo info; |
1742 | info.setFile( fn ); | 1743 | info.setFile( fn ); |
1743 | QString mess; | 1744 | QString mess; |
1744 | bool loadbup = true; | 1745 | bool loadbup = true; |
1745 | if ( !info. exists() ) { | 1746 | if ( !info. exists() ) { |
1746 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1747 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1747 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1748 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1748 | mess ); | 1749 | mess ); |
1749 | return; | 1750 | return; |
1750 | } | 1751 | } |
1751 | int result = 0; | 1752 | int result = 0; |
1752 | if ( !quick ) { | 1753 | if ( !quick ) { |
1753 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1754 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1754 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1755 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1755 | mess, | 1756 | mess, |
1756 | "Import", "Cancel", 0, | 1757 | "Import", "Cancel", 0, |
1757 | 0, 1 ); | 1758 | 0, 1 ); |
1758 | } | 1759 | } |
1759 | if ( result == 0 ) { | 1760 | if ( result == 0 ) { |
1760 | if ( mView->openCalendar( fn, true )) { | 1761 | if ( mView->openCalendar( fn, true )) { |
1761 | KOPrefs::instance()->mLastImportFile = fn; | 1762 | KOPrefs::instance()->mLastImportFile = fn; |
1762 | setCaption(i18n("Imported file successfully")); | 1763 | setCaption(i18n("Imported file successfully")); |
1763 | } else { | 1764 | } else { |
1764 | setCaption(i18n("Error importing file")); | 1765 | setCaption(i18n("Error importing file")); |
1765 | } | 1766 | } |
1766 | } | 1767 | } |
1767 | } | 1768 | } |
1768 | 1769 | ||
1769 | void MainWindow::importIcal() | 1770 | void MainWindow::importIcal() |
1770 | { | 1771 | { |
1771 | 1772 | ||
1772 | QString fn =KOPrefs::instance()->mLastImportFile; | 1773 | QString fn =KOPrefs::instance()->mLastImportFile; |
1773 | 1774 | ||
1774 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1775 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1775 | if ( fn == "" ) | 1776 | if ( fn == "" ) |
1776 | return; | 1777 | return; |
1777 | importFile( fn, true ); | 1778 | importFile( fn, true ); |
1778 | 1779 | ||
1779 | } | 1780 | } |
1780 | 1781 | ||
1781 | void MainWindow::exportVCalendar() | 1782 | void MainWindow::exportVCalendar() |
1782 | { | 1783 | { |
1783 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1784 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1784 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1785 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1785 | if ( fn == "" ) | 1786 | if ( fn == "" ) |
1786 | return; | 1787 | return; |
1787 | QFileInfo info; | 1788 | QFileInfo info; |
1788 | info.setFile( fn ); | 1789 | info.setFile( fn ); |
1789 | QString mes; | 1790 | QString mes; |
1790 | bool createbup = true; | 1791 | bool createbup = true; |
1791 | if ( info. exists() ) { | 1792 | if ( info. exists() ) { |
1792 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1793 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1793 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1794 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1794 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1795 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1795 | 0, 1 ); | 1796 | 0, 1 ); |