author | zautrix <zautrix> | 2004-11-08 08:05:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-11-08 08:05:08 (UTC) |
commit | 4481ce9842b3820087b24a8bfce2c194974aae73 (patch) (unidiff) | |
tree | 70da30be2b8cd4b6934c1a51c08a9d83aa93d8b6 /korganizer | |
parent | 90e33436f6d1c502a5620760ac6592b9881ee4ab (diff) | |
download | kdepimpi-4481ce9842b3820087b24a8bfce2c194974aae73.zip kdepimpi-4481ce9842b3820087b24a8bfce2c194974aae73.tar.gz kdepimpi-4481ce9842b3820087b24a8bfce2c194974aae73.tar.bz2 |
some small fixes
-rw-r--r-- | korganizer/koeditordetails.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp index 2e1ae6e..66f6977 100644 --- a/korganizer/koeditordetails.cpp +++ b/korganizer/koeditordetails.cpp | |||
@@ -174,259 +174,265 @@ KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name) | |||
174 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); | 174 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); |
175 | topLayout->addWidget(statusLabel,5,3); | 175 | topLayout->addWidget(statusLabel,5,3); |
176 | topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); | 176 | topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); |
177 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); | 177 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); |
178 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); | 178 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); |
179 | topLayout->addMultiCellWidget(buttonBox,3,4,5,5); | 179 | topLayout->addMultiCellWidget(buttonBox,3,4,5,5); |
180 | topLayout->setRowStretch(1,5); | 180 | topLayout->setRowStretch(1,5); |
181 | topLayout->setColStretch(0,0); | 181 | topLayout->setColStretch(0,0); |
182 | } | 182 | } |
183 | // #if 0 | 183 | // #if 0 |
184 | // topLayout->setColStretch(2,1); | 184 | // topLayout->setColStretch(2,1); |
185 | // topLayout->addWidget(statusLabel,3,3); | 185 | // topLayout->addWidget(statusLabel,3,3); |
186 | // topLayout->addWidget(mStatusCombo,3,4); | 186 | // topLayout->addWidget(mStatusCombo,3,4); |
187 | // #else | 187 | // #else |
188 | // topLayout->addWidget(statusLabel,4,3); | 188 | // topLayout->addWidget(statusLabel,4,3); |
189 | // // topLayout->addWidget(mStatusCombo,4,3); | 189 | // // topLayout->addWidget(mStatusCombo,4,3); |
190 | // topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); | 190 | // topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); |
191 | 191 | ||
192 | // #endif | 192 | // #endif |
193 | // // topLayout->setRowStretch(5,1); | 193 | // // topLayout->setRowStretch(5,1); |
194 | // topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); | 194 | // topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); |
195 | // topLayout->addMultiCellWidget(buttonBox,2,3,5,5); | 195 | // topLayout->addMultiCellWidget(buttonBox,2,3,5,5); |
196 | // topLayout->setRowStretch(1,5); | 196 | // topLayout->setRowStretch(1,5); |
197 | // topLayout->setColStretch(0,0); | 197 | // topLayout->setColStretch(0,0); |
198 | 198 | ||
199 | #ifdef KORG_NOKABC | 199 | #ifdef KORG_NOKABC |
200 | mAddressBookButton->hide(); | 200 | mAddressBookButton->hide(); |
201 | #endif | 201 | #endif |
202 | 202 | ||
203 | updateAttendeeInput(); | 203 | updateAttendeeInput(); |
204 | #ifndef DESKTOP_VERSION | 204 | #ifndef DESKTOP_VERSION |
205 | //US listen for arriving address resultsets | 205 | //US listen for arriving address resultsets |
206 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 206 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
207 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 207 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
208 | #endif | 208 | #endif |
209 | 209 | ||
210 | } | 210 | } |
211 | 211 | ||
212 | KOEditorDetails::~KOEditorDetails() | 212 | KOEditorDetails::~KOEditorDetails() |
213 | { | 213 | { |
214 | } | 214 | } |
215 | 215 | ||
216 | void KOEditorDetails::removeAttendee() | 216 | void KOEditorDetails::removeAttendee() |
217 | { | 217 | { |
218 | AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); | 218 | AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); |
219 | if (!aItem) return; | 219 | if (!aItem) return; |
220 | 220 | ||
221 | Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), | 221 | Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), |
222 | aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), | 222 | aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), |
223 | aItem->data()->uid()); | 223 | aItem->data()->uid()); |
224 | mdelAttendees.append(delA); | 224 | mdelAttendees.append(delA); |
225 | 225 | ||
226 | delete aItem; | 226 | delete aItem; |
227 | 227 | ||
228 | updateAttendeeInput(); | 228 | updateAttendeeInput(); |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | void KOEditorDetails::openAddressBook() | 232 | void KOEditorDetails::openAddressBook() |
233 | { | 233 | { |
234 | #ifndef KORG_NOKABC | 234 | #ifndef KORG_NOKABC |
235 | 235 | ||
236 | #ifdef DESKTOP_VERSION | 236 | #ifdef DESKTOP_VERSION |
237 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 237 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
238 | uint i=0; | 238 | uint i=0; |
239 | for (i=0; i < list.count(); i++) { | 239 | for (i=0; i < list.count(); i++) { |
240 | insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) ); | 240 | insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) ); |
241 | } | 241 | } |
242 | #else | 242 | #else |
243 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 243 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
244 | // the result should now arrive through method insertAttendees | 244 | // the result should now arrive through method insertAttendees |
245 | #endif | 245 | #endif |
246 | 246 | ||
247 | 247 | ||
248 | #if 0 | 248 | #if 0 |
249 | KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); | 249 | KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); |
250 | if (!a.isEmpty()) { | 250 | if (!a.isEmpty()) { |
251 | insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); | 251 | insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); |
252 | } | 252 | } |
253 | #endif | 253 | #endif |
254 | #endif | 254 | #endif |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | void KOEditorDetails::addNewAttendee() | 258 | void KOEditorDetails::addNewAttendee() |
259 | { | 259 | { |
260 | #if 0 | 260 | #if 0 |
261 | // this is cool. If they didn't enter an email address, | 261 | // this is cool. If they didn't enter an email address, |
262 | // try to look it up in the address book and fill it in for them. | 262 | // try to look it up in the address book and fill it in for them. |
263 | if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { | 263 | if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { |
264 | KabAPI addrBook; | 264 | KabAPI addrBook; |
265 | QString name; | 265 | QString name; |
266 | std::list<AddressBook::Entry> entries; | 266 | std::list<AddressBook::Entry> entries; |
267 | name = mNameEdit->text(); | 267 | name = mNameEdit->text(); |
268 | if (addrBook.init() == AddressBook::NoError) { | 268 | if (addrBook.init() == AddressBook::NoError) { |
269 | if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { | 269 | if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { |
270 | kdDebug() << "positive match" << endl; | 270 | kdDebug() << "positive match" << endl; |
271 | // take first email address | 271 | // take first email address |
272 | if (!entries.front().emails.isEmpty() && | 272 | if (!entries.front().emails.isEmpty() && |
273 | entries.front().emails.first().length()>0) | 273 | entries.front().emails.first().length()>0) |
274 | mEmailEdit->setText(entries.front().emails.first()); | 274 | mEmailEdit->setText(entries.front().emails.first()); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | } | 277 | } |
278 | #endif | 278 | #endif |
279 | 279 | ||
280 | Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); | 280 | Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); |
281 | insertAttendee(a); | 281 | insertAttendee(a); |
282 | } | 282 | } |
283 | 283 | ||
284 | //the map includes name/email pairs, that comes from Ka/Pi | 284 | //the map includes name/email pairs, that comes from Ka/Pi |
285 | void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 285 | void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
286 | { | 286 | { |
287 | if (uid == this->name()) | 287 | if (uid == this->name()) |
288 | { | 288 | { |
289 | for ( int i = 0; i < nameList.count(); i++) | 289 | for ( int i = 0; i < nameList.count(); i++) |
290 | { | 290 | { |
291 | QString _name = nameList[i]; | 291 | QString _name = nameList[i]; |
292 | QString _email = emailList[i]; | 292 | QString _email = emailList[i]; |
293 | QString _uid = uidList[i]; | 293 | QString _uid = uidList[i]; |
294 | 294 | ||
295 | Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); | 295 | Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); |
296 | insertAttendee(a); | 296 | insertAttendee(a); |
297 | } | 297 | } |
298 | } | 298 | } |
299 | 299 | ||
300 | } | 300 | } |
301 | 301 | ||
302 | |||
303 | void KOEditorDetails::insertAttendee(Attendee *a) | 302 | void KOEditorDetails::insertAttendee(Attendee *a) |
304 | { | 303 | { |
304 | AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild(); | ||
305 | while (first) { | ||
306 | if ( first->data()->name() == a->name() && first->data()->email() == a->email() ) | ||
307 | return; | ||
308 | first = (AttendeeListItem*) first->nextSibling(); | ||
309 | } | ||
310 | |||
305 | AttendeeListItem *item = new AttendeeListItem(a,mListView); | 311 | AttendeeListItem *item = new AttendeeListItem(a,mListView); |
306 | mListView->setSelected( item, true ); | 312 | mListView->setSelected( item, true ); |
307 | } | 313 | } |
308 | 314 | ||
309 | void KOEditorDetails::setDefaults() | 315 | void KOEditorDetails::setDefaults() |
310 | { | 316 | { |
311 | mRsvpButton->setChecked(true); | 317 | mRsvpButton->setChecked(true); |
312 | mListView->clear(); | 318 | mListView->clear(); |
313 | mdelAttendees.clear(); | 319 | mdelAttendees.clear(); |
314 | clearAttendeeInput(); | 320 | clearAttendeeInput(); |
315 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); | 321 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); |
316 | 322 | ||
317 | mNameEdit->setText(""); | 323 | mNameEdit->setText(""); |
318 | mUidEdit->setText(""); | 324 | mUidEdit->setText(""); |
319 | mEmailEdit->setText(""); | 325 | mEmailEdit->setText(""); |
320 | mRoleCombo->setCurrentItem( 0 ); | 326 | mRoleCombo->setCurrentItem( 0 ); |
321 | mStatusCombo->setCurrentItem( 0 ); | 327 | mStatusCombo->setCurrentItem( 0 ); |
322 | 328 | ||
323 | } | 329 | } |
324 | 330 | ||
325 | void KOEditorDetails::readEvent(Incidence *event) | 331 | void KOEditorDetails::readEvent(Incidence *event) |
326 | { | 332 | { |
327 | setDefaults(); | 333 | setDefaults(); |
328 | //mListView->clear(); | 334 | //mListView->clear(); |
329 | //mdelAttendees.clear(); | 335 | //mdelAttendees.clear(); |
330 | QPtrList<Attendee> tmpAList = event->attendees(); | 336 | QPtrList<Attendee> tmpAList = event->attendees(); |
331 | Attendee *a; | 337 | Attendee *a; |
332 | for (a = tmpAList.first(); a; a = tmpAList.next()) | 338 | for (a = tmpAList.first(); a; a = tmpAList.next()) |
333 | insertAttendee(new Attendee(*a)); | 339 | insertAttendee(new Attendee(*a)); |
334 | 340 | ||
335 | mListView->setSelected( mListView->firstChild(), true ); | 341 | mListView->setSelected( mListView->firstChild(), true ); |
336 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); | 342 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); |
337 | } | 343 | } |
338 | 344 | ||
339 | void KOEditorDetails::writeEvent(Incidence *event) | 345 | void KOEditorDetails::writeEvent(Incidence *event) |
340 | { | 346 | { |
341 | event->clearAttendees(); | 347 | event->clearAttendees(); |
342 | QListViewItem *item; | 348 | QListViewItem *item; |
343 | AttendeeListItem *a; | 349 | AttendeeListItem *a; |
344 | for (item = mListView->firstChild(); item; | 350 | for (item = mListView->firstChild(); item; |
345 | item = item->nextSibling()) { | 351 | item = item->nextSibling()) { |
346 | a = (AttendeeListItem *)item; | 352 | a = (AttendeeListItem *)item; |
347 | event->addAttendee(new Attendee(*(a->data()))); | 353 | event->addAttendee(new Attendee(*(a->data()))); |
348 | } | 354 | } |
349 | event->setOrganizer(KOPrefs::instance()->email()); | 355 | event->setOrganizer(KOPrefs::instance()->email()); |
350 | } | 356 | } |
351 | 357 | ||
352 | void KOEditorDetails::cancelAttendeeEvent(Incidence *event) | 358 | void KOEditorDetails::cancelAttendeeEvent(Incidence *event) |
353 | { | 359 | { |
354 | event->clearAttendees(); | 360 | event->clearAttendees(); |
355 | Attendee * att; | 361 | Attendee * att; |
356 | for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { | 362 | for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { |
357 | event->addAttendee(new Attendee(*att)); | 363 | event->addAttendee(new Attendee(*att)); |
358 | } | 364 | } |
359 | mdelAttendees.clear(); | 365 | mdelAttendees.clear(); |
360 | } | 366 | } |
361 | 367 | ||
362 | bool KOEditorDetails::validateInput() | 368 | bool KOEditorDetails::validateInput() |
363 | { | 369 | { |
364 | return true; | 370 | return true; |
365 | } | 371 | } |
366 | 372 | ||
367 | void KOEditorDetails::updateAttendeeInput() | 373 | void KOEditorDetails::updateAttendeeInput() |
368 | { | 374 | { |
369 | QListViewItem *item = mListView->selectedItem(); | 375 | QListViewItem *item = mListView->selectedItem(); |
370 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); | 376 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); |
371 | if (aItem) { | 377 | if (aItem) { |
372 | fillAttendeeInput( aItem ); | 378 | fillAttendeeInput( aItem ); |
373 | } else { | 379 | } else { |
374 | clearAttendeeInput(); | 380 | clearAttendeeInput(); |
375 | } | 381 | } |
376 | } | 382 | } |
377 | 383 | ||
378 | void KOEditorDetails::clearAttendeeInput() | 384 | void KOEditorDetails::clearAttendeeInput() |
379 | { | 385 | { |
380 | mNameEdit->setText(""); | 386 | mNameEdit->setText(""); |
381 | mUidEdit->setText(""); | 387 | mUidEdit->setText(""); |
382 | mEmailEdit->setText(""); | 388 | mEmailEdit->setText(""); |
383 | mRoleCombo->setCurrentItem(0); | 389 | mRoleCombo->setCurrentItem(0); |
384 | mStatusCombo->setCurrentItem(0); | 390 | mStatusCombo->setCurrentItem(0); |
385 | mRsvpButton->setChecked(true); | 391 | mRsvpButton->setChecked(true); |
386 | setEnabledAttendeeInput( false ); | 392 | setEnabledAttendeeInput( false ); |
387 | } | 393 | } |
388 | 394 | ||
389 | void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) | 395 | void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) |
390 | { | 396 | { |
391 | Attendee *a = aItem->data(); | 397 | Attendee *a = aItem->data(); |
392 | mDisableItemUpdate = true; | 398 | mDisableItemUpdate = true; |
393 | mNameEdit->setText(a->name()); | 399 | mNameEdit->setText(a->name()); |
394 | mUidEdit->setText(a->uid()); | 400 | mUidEdit->setText(a->uid()); |
395 | mEmailEdit->setText(a->email()); | 401 | mEmailEdit->setText(a->email()); |
396 | mRoleCombo->setCurrentItem(a->role()); | 402 | mRoleCombo->setCurrentItem(a->role()); |
397 | mStatusCombo->setCurrentItem(a->status()); | 403 | mStatusCombo->setCurrentItem(a->status()); |
398 | mRsvpButton->setChecked(a->RSVP()); | 404 | mRsvpButton->setChecked(a->RSVP()); |
399 | 405 | ||
400 | mDisableItemUpdate = false; | 406 | mDisableItemUpdate = false; |
401 | 407 | ||
402 | setEnabledAttendeeInput( true ); | 408 | setEnabledAttendeeInput( true ); |
403 | } | 409 | } |
404 | 410 | ||
405 | void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) | 411 | void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) |
406 | { | 412 | { |
407 | mNameEdit->setEnabled( enabled ); | 413 | mNameEdit->setEnabled( enabled ); |
408 | mEmailEdit->setEnabled( enabled ); | 414 | mEmailEdit->setEnabled( enabled ); |
409 | mRoleCombo->setEnabled( enabled ); | 415 | mRoleCombo->setEnabled( enabled ); |
410 | mStatusCombo->setEnabled( enabled ); | 416 | mStatusCombo->setEnabled( enabled ); |
411 | mRsvpButton->setEnabled( enabled ); | 417 | mRsvpButton->setEnabled( enabled ); |
412 | 418 | ||
413 | mRemoveButton->setEnabled( enabled ); | 419 | mRemoveButton->setEnabled( enabled ); |
414 | } | 420 | } |
415 | 421 | ||
416 | void KOEditorDetails::updateAttendeeItem() | 422 | void KOEditorDetails::updateAttendeeItem() |
417 | { | 423 | { |
418 | if (mDisableItemUpdate) return; | 424 | if (mDisableItemUpdate) return; |
419 | 425 | ||
420 | QListViewItem *item = mListView->selectedItem(); | 426 | QListViewItem *item = mListView->selectedItem(); |
421 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); | 427 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); |
422 | if ( !aItem ) return; | 428 | if ( !aItem ) return; |
423 | 429 | ||
424 | Attendee *a = aItem->data(); | 430 | Attendee *a = aItem->data(); |
425 | 431 | ||
426 | a->setName( mNameEdit->text() ); | 432 | a->setName( mNameEdit->text() ); |
427 | a->setUid( mUidEdit->text() ); | 433 | a->setUid( mUidEdit->text() ); |
428 | a->setEmail( mEmailEdit->text() ); | 434 | a->setEmail( mEmailEdit->text() ); |
429 | a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); | 435 | a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); |
430 | a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); | 436 | a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); |
431 | a->setRSVP( mRsvpButton->isChecked() ); | 437 | a->setRSVP( mRsvpButton->isChecked() ); |
432 | aItem->updateItem(); | 438 | aItem->updateItem(); |