author | zautrix <zautrix> | 2004-07-06 15:55:15 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-06 15:55:15 (UTC) |
commit | 45e2744074e876a74919b340efc320bdadadcb25 (patch) (unidiff) | |
tree | 5fac15064970f378dc59284b451491d924c7e5b2 | |
parent | 60ec860b41d2af2444955e5cc3d04d132c76dbbb (diff) | |
download | kdepimpi-45e2744074e876a74919b340efc320bdadadcb25.zip kdepimpi-45e2744074e876a74919b340efc320bdadadcb25.tar.gz kdepimpi-45e2744074e876a74919b340efc320bdadadcb25.tar.bz2 |
Fixed a crash
-rw-r--r-- | kaddressbook/kabcore.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 7cba9aa..3ae23e8 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -741,95 +741,94 @@ void KABCore::setModified( bool modified ) | |||
741 | mDetails->refreshView(); | 741 | mDetails->refreshView(); |
742 | 742 | ||
743 | } | 743 | } |
744 | 744 | ||
745 | bool KABCore::modified() const | 745 | bool KABCore::modified() const |
746 | { | 746 | { |
747 | return mModified; | 747 | return mModified; |
748 | } | 748 | } |
749 | 749 | ||
750 | void KABCore::contactModified( const KABC::Addressee &addr ) | 750 | void KABCore::contactModified( const KABC::Addressee &addr ) |
751 | { | 751 | { |
752 | 752 | ||
753 | Command *command = 0; | 753 | Command *command = 0; |
754 | QString uid; | 754 | QString uid; |
755 | 755 | ||
756 | // check if it exists already | 756 | // check if it exists already |
757 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 757 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
758 | if ( origAddr.isEmpty() ) | 758 | if ( origAddr.isEmpty() ) |
759 | command = new PwNewCommand( mAddressBook, addr ); | 759 | command = new PwNewCommand( mAddressBook, addr ); |
760 | else { | 760 | else { |
761 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 761 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
762 | uid = addr.uid(); | 762 | uid = addr.uid(); |
763 | } | 763 | } |
764 | 764 | ||
765 | UndoStack::instance()->push( command ); | 765 | UndoStack::instance()->push( command ); |
766 | RedoStack::instance()->clear(); | 766 | RedoStack::instance()->clear(); |
767 | 767 | ||
768 | setModified( true ); | 768 | setModified( true ); |
769 | } | 769 | } |
770 | 770 | ||
771 | void KABCore::newContact() | 771 | void KABCore::newContact() |
772 | { | 772 | { |
773 | AddresseeEditorDialog *dialog = 0; | 773 | |
774 | 774 | ||
775 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 775 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
776 | 776 | ||
777 | QPtrList<KRES::Resource> kresResources; | 777 | QPtrList<KRES::Resource> kresResources; |
778 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 778 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
779 | KABC::Resource *resource; | 779 | KABC::Resource *resource; |
780 | while ( ( resource = it.current() ) != 0 ) { | 780 | while ( ( resource = it.current() ) != 0 ) { |
781 | ++it; | 781 | ++it; |
782 | if ( !resource->readOnly() ) { | 782 | if ( !resource->readOnly() ) { |
783 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 783 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
784 | if ( res ) | 784 | if ( res ) |
785 | kresResources.append( res ); | 785 | kresResources.append( res ); |
786 | } | 786 | } |
787 | } | 787 | } |
788 | 788 | ||
789 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 789 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
790 | resource = static_cast<KABC::Resource*>( res ); | 790 | resource = static_cast<KABC::Resource*>( res ); |
791 | 791 | ||
792 | if ( resource ) { | 792 | if ( resource ) { |
793 | KABC::Addressee addr; | 793 | KABC::Addressee addr; |
794 | addr.setResource( resource ); | 794 | addr.setResource( resource ); |
795 | mEditorDialog->setAddressee( addr ); | 795 | mEditorDialog->setAddressee( addr ); |
796 | KApplication::execDialog ( mEditorDialog ); | 796 | KApplication::execDialog ( mEditorDialog ); |
797 | 797 | ||
798 | } else | 798 | } else |
799 | return; | 799 | return; |
800 | 800 | ||
801 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 801 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
802 | 802 | ||
803 | dialog->show(); | ||
804 | 803 | ||
805 | } | 804 | } |
806 | 805 | ||
807 | void KABCore::addEmail( QString aStr ) | 806 | void KABCore::addEmail( QString aStr ) |
808 | { | 807 | { |
809 | #ifndef KAB_EMBEDDED | 808 | #ifndef KAB_EMBEDDED |
810 | QString fullName, email; | 809 | QString fullName, email; |
811 | 810 | ||
812 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 811 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
813 | 812 | ||
814 | // Try to lookup the addressee matching the email address | 813 | // Try to lookup the addressee matching the email address |
815 | bool found = false; | 814 | bool found = false; |
816 | QStringList emailList; | 815 | QStringList emailList; |
817 | KABC::AddressBook::Iterator it; | 816 | KABC::AddressBook::Iterator it; |
818 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 817 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
819 | emailList = (*it).emails(); | 818 | emailList = (*it).emails(); |
820 | if ( emailList.contains( email ) > 0 ) { | 819 | if ( emailList.contains( email ) > 0 ) { |
821 | found = true; | 820 | found = true; |
822 | (*it).setNameFromString( fullName ); | 821 | (*it).setNameFromString( fullName ); |
823 | editContact( (*it).uid() ); | 822 | editContact( (*it).uid() ); |
824 | } | 823 | } |
825 | } | 824 | } |
826 | 825 | ||
827 | if ( !found ) { | 826 | if ( !found ) { |
828 | KABC::Addressee addr; | 827 | KABC::Addressee addr; |
829 | addr.setNameFromString( fullName ); | 828 | addr.setNameFromString( fullName ); |
830 | addr.insertEmail( email, true ); | 829 | addr.insertEmail( email, true ); |
831 | 830 | ||
832 | mAddressBook->insertAddressee( addr ); | 831 | mAddressBook->insertAddressee( addr ); |
833 | mViewManager->refreshView( addr.uid() ); | 832 | mViewManager->refreshView( addr.uid() ); |
834 | editContact( addr.uid() ); | 833 | editContact( addr.uid() ); |
835 | } | 834 | } |