summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-28 11:37:28 (UTC)
committer zautrix <zautrix>2004-10-28 11:37:28 (UTC)
commitaf21c3d45173ece8492850b8c2c5019e7c25d59c (patch) (unidiff)
tree52e60b226372bbe37987df07495b02de321410fe
parent01cd4ef94b8604532181c390e9abd560aebaf372 (diff)
downloadkdepimpi-af21c3d45173ece8492850b8c2c5019e7c25d59c.zip
kdepimpi-af21c3d45173ece8492850b8c2c5019e7c25d59c.tar.gz
kdepimpi-af21c3d45173ece8492850b8c2c5019e7c25d59c.tar.bz2
dtm sync fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp14
-rw-r--r--korganizer/calendarview.cpp10
2 files changed, 15 insertions, 9 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index bdc5bd8..c75b4bc 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -591,2385 +591,2389 @@ void KABCore::createAboutData()
591 "Greg Stern DCOP interface\n" 591 "Greg Stern DCOP interface\n"
592 "Mark Westcot Contact pinning\n" 592 "Mark Westcot Contact pinning\n"
593 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 593 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
594 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 594 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
595#ifdef _WIN32_ 595#ifdef _WIN32_
596 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 596 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
597#endif 597#endif
598 ); 598 );
599} 599}
600 600
601void KABCore::setContactSelected( const QString &uid ) 601void KABCore::setContactSelected( const QString &uid )
602{ 602{
603 KABC::Addressee addr = mAddressBook->findByUid( uid ); 603 KABC::Addressee addr = mAddressBook->findByUid( uid );
604 if ( !mDetails->isHidden() ) 604 if ( !mDetails->isHidden() )
605 mDetails->setAddressee( addr ); 605 mDetails->setAddressee( addr );
606 606
607 if ( !addr.isEmpty() ) { 607 if ( !addr.isEmpty() ) {
608 emit contactSelected( addr.formattedName() ); 608 emit contactSelected( addr.formattedName() );
609 KABC::Picture pic = addr.photo(); 609 KABC::Picture pic = addr.photo();
610 if ( pic.isIntern() ) { 610 if ( pic.isIntern() ) {
611//US emit contactSelected( pic.data() ); 611//US emit contactSelected( pic.data() );
612//US instead use: 612//US instead use:
613 QPixmap px; 613 QPixmap px;
614 if (pic.data().isNull() != true) 614 if (pic.data().isNull() != true)
615 { 615 {
616 px.convertFromImage(pic.data()); 616 px.convertFromImage(pic.data());
617 } 617 }
618 618
619 emit contactSelected( px ); 619 emit contactSelected( px );
620 } 620 }
621 } 621 }
622 622
623 623
624 mExtensionManager->setSelectionChanged(); 624 mExtensionManager->setSelectionChanged();
625 625
626 // update the actions 626 // update the actions
627 bool selected = !uid.isEmpty(); 627 bool selected = !uid.isEmpty();
628 628
629 if ( mReadWrite ) { 629 if ( mReadWrite ) {
630 mActionCut->setEnabled( selected ); 630 mActionCut->setEnabled( selected );
631 mActionPaste->setEnabled( selected ); 631 mActionPaste->setEnabled( selected );
632 } 632 }
633 633
634 mActionCopy->setEnabled( selected ); 634 mActionCopy->setEnabled( selected );
635 mActionDelete->setEnabled( selected ); 635 mActionDelete->setEnabled( selected );
636 mActionEditAddressee->setEnabled( selected ); 636 mActionEditAddressee->setEnabled( selected );
637 mActionMail->setEnabled( selected ); 637 mActionMail->setEnabled( selected );
638 mActionMailVCard->setEnabled( selected ); 638 mActionMailVCard->setEnabled( selected );
639 //if (mActionBeam) 639 //if (mActionBeam)
640 //mActionBeam->setEnabled( selected ); 640 //mActionBeam->setEnabled( selected );
641 641
642 if (mActionBeamVCard) 642 if (mActionBeamVCard)
643 mActionBeamVCard->setEnabled( selected ); 643 mActionBeamVCard->setEnabled( selected );
644 644
645 mActionExport2phone->setEnabled( selected ); 645 mActionExport2phone->setEnabled( selected );
646 mActionWhoAmI->setEnabled( selected ); 646 mActionWhoAmI->setEnabled( selected );
647 mActionCategories->setEnabled( selected ); 647 mActionCategories->setEnabled( selected );
648} 648}
649 649
650void KABCore::sendMail() 650void KABCore::sendMail()
651{ 651{
652 sendMail( mViewManager->selectedEmails().join( ", " ) ); 652 sendMail( mViewManager->selectedEmails().join( ", " ) );
653} 653}
654 654
655void KABCore::sendMail( const QString& emaillist ) 655void KABCore::sendMail( const QString& emaillist )
656{ 656{
657 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 657 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
658 if (emaillist.contains(",") > 0) 658 if (emaillist.contains(",") > 0)
659 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 659 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
660 else 660 else
661 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 661 ExternalAppHandler::instance()->mailToOneContact( emaillist );
662} 662}
663 663
664 664
665 665
666void KABCore::mailVCard() 666void KABCore::mailVCard()
667{ 667{
668 QStringList uids = mViewManager->selectedUids(); 668 QStringList uids = mViewManager->selectedUids();
669 if ( !uids.isEmpty() ) 669 if ( !uids.isEmpty() )
670 mailVCard( uids ); 670 mailVCard( uids );
671} 671}
672 672
673void KABCore::mailVCard( const QStringList& uids ) 673void KABCore::mailVCard( const QStringList& uids )
674{ 674{
675 QStringList urls; 675 QStringList urls;
676 676
677// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 677// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
678 678
679 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 679 QString dirName = "/tmp/" + KApplication::randomString( 8 );
680 680
681 681
682 682
683 QDir().mkdir( dirName, true ); 683 QDir().mkdir( dirName, true );
684 684
685 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 685 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
686 KABC::Addressee a = mAddressBook->findByUid( *it ); 686 KABC::Addressee a = mAddressBook->findByUid( *it );
687 687
688 if ( a.isEmpty() ) 688 if ( a.isEmpty() )
689 continue; 689 continue;
690 690
691 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 691 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
692 692
693 QString fileName = dirName + "/" + name; 693 QString fileName = dirName + "/" + name;
694 694
695 QFile outFile(fileName); 695 QFile outFile(fileName);
696 696
697 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 697 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
698 KABC::VCardConverter converter; 698 KABC::VCardConverter converter;
699 QString vcard; 699 QString vcard;
700 700
701 converter.addresseeToVCard( a, vcard ); 701 converter.addresseeToVCard( a, vcard );
702 702
703 QTextStream t( &outFile ); // use a text stream 703 QTextStream t( &outFile ); // use a text stream
704 t.setEncoding( QTextStream::UnicodeUTF8 ); 704 t.setEncoding( QTextStream::UnicodeUTF8 );
705 t << vcard; 705 t << vcard;
706 706
707 outFile.close(); 707 outFile.close();
708 708
709 urls.append( fileName ); 709 urls.append( fileName );
710 } 710 }
711 } 711 }
712 712
713 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 713 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
714 714
715 715
716/*US 716/*US
717 kapp->invokeMailer( QString::null, QString::null, QString::null, 717 kapp->invokeMailer( QString::null, QString::null, QString::null,
718 QString::null, // subject 718 QString::null, // subject
719 QString::null, // body 719 QString::null, // body
720 QString::null, 720 QString::null,
721 urls ); // attachments 721 urls ); // attachments
722*/ 722*/
723 723
724} 724}
725 725
726/** 726/**
727 Beams the "WhoAmI contact. 727 Beams the "WhoAmI contact.
728*/ 728*/
729void KABCore::beamMySelf() 729void KABCore::beamMySelf()
730{ 730{
731 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 731 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
732 if (!a.isEmpty()) 732 if (!a.isEmpty())
733 { 733 {
734 QStringList uids; 734 QStringList uids;
735 uids << a.uid(); 735 uids << a.uid();
736 736
737 beamVCard(uids); 737 beamVCard(uids);
738 } else { 738 } else {
739 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 739 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
740 740
741 741
742 } 742 }
743} 743}
744 744
745void KABCore::export2phone() 745void KABCore::export2phone()
746{ 746{
747 747
748 KAex2phonePrefs ex2phone; 748 KAex2phonePrefs ex2phone;
749 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 749 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
750 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 750 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
751 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 751 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
752 752
753 if ( !ex2phone.exec() ) { 753 if ( !ex2phone.exec() ) {
754 return; 754 return;
755 } 755 }
756 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 756 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
757 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 757 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
758 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 758 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
759 759
760 760
761 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 761 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
762 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 762 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
763 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 763 KPimGlobalPrefs::instance()->mEx2PhoneModel );
764 764
765 QStringList uids = mViewManager->selectedUids(); 765 QStringList uids = mViewManager->selectedUids();
766 if ( uids.isEmpty() ) 766 if ( uids.isEmpty() )
767 return; 767 return;
768 768
769 QString fileName = getPhoneFile(); 769 QString fileName = getPhoneFile();
770 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 770 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
771 return; 771 return;
772 772
773 message(i18n("Exporting to phone...")); 773 message(i18n("Exporting to phone..."));
774 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 774 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
775 775
776} 776}
777QString KABCore::getPhoneFile() 777QString KABCore::getPhoneFile()
778{ 778{
779#ifdef DESKTOP_VERSION 779#ifdef DESKTOP_VERSION
780 return locateLocal("tmp", "phonefile.vcf"); 780 return locateLocal("tmp", "phonefile.vcf");
781#else 781#else
782 return "/tmp/phonefile.vcf"; 782 return "/tmp/phonefile.vcf";
783#endif 783#endif
784 784
785} 785}
786void KABCore::writeToPhone( ) 786void KABCore::writeToPhone( )
787{ 787{
788 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 788 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
789 message(i18n("Export to phone finished!")); 789 message(i18n("Export to phone finished!"));
790 else 790 else
791 qDebug(i18n("Error exporting to phone")); 791 qDebug(i18n("Error exporting to phone"));
792} 792}
793void KABCore::beamVCard() 793void KABCore::beamVCard()
794{ 794{
795 QStringList uids = mViewManager->selectedUids(); 795 QStringList uids = mViewManager->selectedUids();
796 if ( !uids.isEmpty() ) 796 if ( !uids.isEmpty() )
797 beamVCard( uids ); 797 beamVCard( uids );
798} 798}
799 799
800 800
801void KABCore::beamVCard(const QStringList& uids) 801void KABCore::beamVCard(const QStringList& uids)
802{ 802{
803 803
804 // LR: we should use the /tmp dir on the Zaurus, 804 // LR: we should use the /tmp dir on the Zaurus,
805 // because: /tmp = RAM, (HOME)/kdepim = flash memory 805 // because: /tmp = RAM, (HOME)/kdepim = flash memory
806 806
807#ifdef DESKTOP_VERSION 807#ifdef DESKTOP_VERSION
808 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 808 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
809#else 809#else
810 QString fileName = "/tmp/kapibeamfile.vcf"; 810 QString fileName = "/tmp/kapibeamfile.vcf";
811#endif 811#endif
812 812
813 KABC::VCardConverter converter; 813 KABC::VCardConverter converter;
814 QString description; 814 QString description;
815 QString datastream; 815 QString datastream;
816 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 816 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
817 KABC::Addressee a = mAddressBook->findByUid( *it ); 817 KABC::Addressee a = mAddressBook->findByUid( *it );
818 818
819 if ( a.isEmpty() ) 819 if ( a.isEmpty() )
820 continue; 820 continue;
821 821
822 if (description.isEmpty()) 822 if (description.isEmpty())
823 description = a.formattedName(); 823 description = a.formattedName();
824 824
825 QString vcard; 825 QString vcard;
826 converter.addresseeToVCard( a, vcard ); 826 converter.addresseeToVCard( a, vcard );
827 int start = 0; 827 int start = 0;
828 int next; 828 int next;
829 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 829 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
830 int semi = vcard.find(";", next); 830 int semi = vcard.find(";", next);
831 int dopp = vcard.find(":", next); 831 int dopp = vcard.find(":", next);
832 int sep; 832 int sep;
833 if ( semi < dopp && semi >= 0 ) 833 if ( semi < dopp && semi >= 0 )
834 sep = semi ; 834 sep = semi ;
835 else 835 else
836 sep = dopp; 836 sep = dopp;
837 datastream +=vcard.mid( start, next - start); 837 datastream +=vcard.mid( start, next - start);
838 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 838 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
839 start = sep; 839 start = sep;
840 } 840 }
841 datastream += vcard.mid( start,vcard.length() ); 841 datastream += vcard.mid( start,vcard.length() );
842 } 842 }
843#ifndef DESKTOP_VERSION 843#ifndef DESKTOP_VERSION
844 QFile outFile(fileName); 844 QFile outFile(fileName);
845 if ( outFile.open(IO_WriteOnly) ) { 845 if ( outFile.open(IO_WriteOnly) ) {
846 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 846 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
847 QTextStream t( &outFile ); // use a text stream 847 QTextStream t( &outFile ); // use a text stream
848 //t.setEncoding( QTextStream::UnicodeUTF8 ); 848 //t.setEncoding( QTextStream::UnicodeUTF8 );
849 t.setEncoding( QTextStream::Latin1 ); 849 t.setEncoding( QTextStream::Latin1 );
850 t <<datastream.latin1(); 850 t <<datastream.latin1();
851 outFile.close(); 851 outFile.close();
852 Ir *ir = new Ir( this ); 852 Ir *ir = new Ir( this );
853 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 853 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
854 ir->send( fileName, description, "text/x-vCard" ); 854 ir->send( fileName, description, "text/x-vCard" );
855 } else { 855 } else {
856 qDebug("Error open temp beam file "); 856 qDebug("Error open temp beam file ");
857 return; 857 return;
858 } 858 }
859#endif 859#endif
860 860
861} 861}
862 862
863void KABCore::beamDone( Ir *ir ) 863void KABCore::beamDone( Ir *ir )
864{ 864{
865#ifndef DESKTOP_VERSION 865#ifndef DESKTOP_VERSION
866 delete ir; 866 delete ir;
867#endif 867#endif
868 topLevelWidget()->raise(); 868 topLevelWidget()->raise();
869 message( i18n("Beaming finished!") ); 869 message( i18n("Beaming finished!") );
870} 870}
871 871
872 872
873void KABCore::browse( const QString& url ) 873void KABCore::browse( const QString& url )
874{ 874{
875#ifndef KAB_EMBEDDED 875#ifndef KAB_EMBEDDED
876 kapp->invokeBrowser( url ); 876 kapp->invokeBrowser( url );
877#else //KAB_EMBEDDED 877#else //KAB_EMBEDDED
878 qDebug("KABCore::browse must be fixed"); 878 qDebug("KABCore::browse must be fixed");
879#endif //KAB_EMBEDDED 879#endif //KAB_EMBEDDED
880} 880}
881 881
882void KABCore::selectAllContacts() 882void KABCore::selectAllContacts()
883{ 883{
884 mViewManager->setSelected( QString::null, true ); 884 mViewManager->setSelected( QString::null, true );
885} 885}
886 886
887void KABCore::deleteContacts() 887void KABCore::deleteContacts()
888{ 888{
889 QStringList uidList = mViewManager->selectedUids(); 889 QStringList uidList = mViewManager->selectedUids();
890 deleteContacts( uidList ); 890 deleteContacts( uidList );
891} 891}
892 892
893void KABCore::deleteContacts( const QStringList &uids ) 893void KABCore::deleteContacts( const QStringList &uids )
894{ 894{
895 if ( uids.count() > 0 ) { 895 if ( uids.count() > 0 ) {
896 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 896 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
897 UndoStack::instance()->push( command ); 897 UndoStack::instance()->push( command );
898 RedoStack::instance()->clear(); 898 RedoStack::instance()->clear();
899 899
900 // now if we deleted anything, refresh 900 // now if we deleted anything, refresh
901 setContactSelected( QString::null ); 901 setContactSelected( QString::null );
902 setModified( true ); 902 setModified( true );
903 } 903 }
904} 904}
905 905
906void KABCore::copyContacts() 906void KABCore::copyContacts()
907{ 907{
908 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 908 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
909 909
910 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 910 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
911 911
912 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 912 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
913 913
914 QClipboard *cb = QApplication::clipboard(); 914 QClipboard *cb = QApplication::clipboard();
915 cb->setText( clipText ); 915 cb->setText( clipText );
916} 916}
917 917
918void KABCore::cutContacts() 918void KABCore::cutContacts()
919{ 919{
920 QStringList uidList = mViewManager->selectedUids(); 920 QStringList uidList = mViewManager->selectedUids();
921 921
922//US if ( uidList.size() > 0 ) { 922//US if ( uidList.size() > 0 ) {
923 if ( uidList.count() > 0 ) { 923 if ( uidList.count() > 0 ) {
924 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 924 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
925 UndoStack::instance()->push( command ); 925 UndoStack::instance()->push( command );
926 RedoStack::instance()->clear(); 926 RedoStack::instance()->clear();
927 927
928 setModified( true ); 928 setModified( true );
929 } 929 }
930} 930}
931 931
932void KABCore::pasteContacts() 932void KABCore::pasteContacts()
933{ 933{
934 QClipboard *cb = QApplication::clipboard(); 934 QClipboard *cb = QApplication::clipboard();
935 935
936 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 936 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
937 937
938 pasteContacts( list ); 938 pasteContacts( list );
939} 939}
940 940
941void KABCore::pasteContacts( KABC::Addressee::List &list ) 941void KABCore::pasteContacts( KABC::Addressee::List &list )
942{ 942{
943 KABC::Resource *resource = requestResource( this ); 943 KABC::Resource *resource = requestResource( this );
944 KABC::Addressee::List::Iterator it; 944 KABC::Addressee::List::Iterator it;
945 for ( it = list.begin(); it != list.end(); ++it ) 945 for ( it = list.begin(); it != list.end(); ++it )
946 (*it).setResource( resource ); 946 (*it).setResource( resource );
947 947
948 PwPasteCommand *command = new PwPasteCommand( this, list ); 948 PwPasteCommand *command = new PwPasteCommand( this, list );
949 UndoStack::instance()->push( command ); 949 UndoStack::instance()->push( command );
950 RedoStack::instance()->clear(); 950 RedoStack::instance()->clear();
951 951
952 setModified( true ); 952 setModified( true );
953} 953}
954 954
955void KABCore::setWhoAmI() 955void KABCore::setWhoAmI()
956{ 956{
957 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 957 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
958 958
959 if ( addrList.count() > 1 ) { 959 if ( addrList.count() > 1 ) {
960 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 960 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
961 return; 961 return;
962 } 962 }
963 963
964 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 964 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
965 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 965 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
966 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 966 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
967} 967}
968 968
969void KABCore::setCategories() 969void KABCore::setCategories()
970{ 970{
971 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 971 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
972 if ( !dlg.exec() ) 972 if ( !dlg.exec() )
973 return; 973 return;
974 974
975 bool merge = false; 975 bool merge = false;
976 QString msg = i18n( "Merge with existing categories?" ); 976 QString msg = i18n( "Merge with existing categories?" );
977 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 977 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
978 merge = true; 978 merge = true;
979 979
980 QStringList categories = dlg.selectedCategories(); 980 QStringList categories = dlg.selectedCategories();
981 981
982 QStringList uids = mViewManager->selectedUids(); 982 QStringList uids = mViewManager->selectedUids();
983 QStringList::Iterator it; 983 QStringList::Iterator it;
984 for ( it = uids.begin(); it != uids.end(); ++it ) { 984 for ( it = uids.begin(); it != uids.end(); ++it ) {
985 KABC::Addressee addr = mAddressBook->findByUid( *it ); 985 KABC::Addressee addr = mAddressBook->findByUid( *it );
986 if ( !addr.isEmpty() ) { 986 if ( !addr.isEmpty() ) {
987 if ( !merge ) 987 if ( !merge )
988 addr.setCategories( categories ); 988 addr.setCategories( categories );
989 else { 989 else {
990 QStringList addrCategories = addr.categories(); 990 QStringList addrCategories = addr.categories();
991 QStringList::Iterator catIt; 991 QStringList::Iterator catIt;
992 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 992 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
993 if ( !addrCategories.contains( *catIt ) ) 993 if ( !addrCategories.contains( *catIt ) )
994 addrCategories.append( *catIt ); 994 addrCategories.append( *catIt );
995 } 995 }
996 addr.setCategories( addrCategories ); 996 addr.setCategories( addrCategories );
997 } 997 }
998 998
999 mAddressBook->insertAddressee( addr ); 999 mAddressBook->insertAddressee( addr );
1000 } 1000 }
1001 } 1001 }
1002 1002
1003 if ( uids.count() > 0 ) 1003 if ( uids.count() > 0 )
1004 setModified( true ); 1004 setModified( true );
1005} 1005}
1006 1006
1007void KABCore::setSearchFields( const KABC::Field::List &fields ) 1007void KABCore::setSearchFields( const KABC::Field::List &fields )
1008{ 1008{
1009 mIncSearchWidget->setFields( fields ); 1009 mIncSearchWidget->setFields( fields );
1010} 1010}
1011 1011
1012void KABCore::incrementalSearch( const QString& text ) 1012void KABCore::incrementalSearch( const QString& text )
1013{ 1013{
1014 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1014 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1015} 1015}
1016 1016
1017void KABCore::setModified() 1017void KABCore::setModified()
1018{ 1018{
1019 setModified( true ); 1019 setModified( true );
1020} 1020}
1021 1021
1022void KABCore::setModifiedWOrefresh() 1022void KABCore::setModifiedWOrefresh()
1023{ 1023{
1024 // qDebug("KABCore::setModifiedWOrefresh() "); 1024 // qDebug("KABCore::setModifiedWOrefresh() ");
1025 mModified = true; 1025 mModified = true;
1026 mActionSave->setEnabled( mModified ); 1026 mActionSave->setEnabled( mModified );
1027#ifdef DESKTOP_VERSION 1027#ifdef DESKTOP_VERSION
1028 mDetails->refreshView(); 1028 mDetails->refreshView();
1029#endif 1029#endif
1030 1030
1031} 1031}
1032void KABCore::setModified( bool modified ) 1032void KABCore::setModified( bool modified )
1033{ 1033{
1034 mModified = modified; 1034 mModified = modified;
1035 mActionSave->setEnabled( mModified ); 1035 mActionSave->setEnabled( mModified );
1036 1036
1037 if ( modified ) 1037 if ( modified )
1038 mJumpButtonBar->recreateButtons(); 1038 mJumpButtonBar->recreateButtons();
1039 1039
1040 mViewManager->refreshView(); 1040 mViewManager->refreshView();
1041 mDetails->refreshView(); 1041 mDetails->refreshView();
1042 1042
1043} 1043}
1044 1044
1045bool KABCore::modified() const 1045bool KABCore::modified() const
1046{ 1046{
1047 return mModified; 1047 return mModified;
1048} 1048}
1049 1049
1050void KABCore::contactModified( const KABC::Addressee &addr ) 1050void KABCore::contactModified( const KABC::Addressee &addr )
1051{ 1051{
1052 1052
1053 Command *command = 0; 1053 Command *command = 0;
1054 QString uid; 1054 QString uid;
1055 1055
1056 // check if it exists already 1056 // check if it exists already
1057 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1057 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1058 if ( origAddr.isEmpty() ) 1058 if ( origAddr.isEmpty() )
1059 command = new PwNewCommand( mAddressBook, addr ); 1059 command = new PwNewCommand( mAddressBook, addr );
1060 else { 1060 else {
1061 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1061 command = new PwEditCommand( mAddressBook, origAddr, addr );
1062 uid = addr.uid(); 1062 uid = addr.uid();
1063 } 1063 }
1064 1064
1065 UndoStack::instance()->push( command ); 1065 UndoStack::instance()->push( command );
1066 RedoStack::instance()->clear(); 1066 RedoStack::instance()->clear();
1067 1067
1068 setModified( true ); 1068 setModified( true );
1069} 1069}
1070 1070
1071void KABCore::newContact() 1071void KABCore::newContact()
1072{ 1072{
1073 1073
1074 1074
1075 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1075 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1076 1076
1077 QPtrList<KRES::Resource> kresResources; 1077 QPtrList<KRES::Resource> kresResources;
1078 QPtrListIterator<KABC::Resource> it( kabcResources ); 1078 QPtrListIterator<KABC::Resource> it( kabcResources );
1079 KABC::Resource *resource; 1079 KABC::Resource *resource;
1080 while ( ( resource = it.current() ) != 0 ) { 1080 while ( ( resource = it.current() ) != 0 ) {
1081 ++it; 1081 ++it;
1082 if ( !resource->readOnly() ) { 1082 if ( !resource->readOnly() ) {
1083 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1083 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1084 if ( res ) 1084 if ( res )
1085 kresResources.append( res ); 1085 kresResources.append( res );
1086 } 1086 }
1087 } 1087 }
1088 1088
1089 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1089 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1090 resource = static_cast<KABC::Resource*>( res ); 1090 resource = static_cast<KABC::Resource*>( res );
1091 1091
1092 if ( resource ) { 1092 if ( resource ) {
1093 KABC::Addressee addr; 1093 KABC::Addressee addr;
1094 addr.setResource( resource ); 1094 addr.setResource( resource );
1095 mEditorDialog->setAddressee( addr ); 1095 mEditorDialog->setAddressee( addr );
1096 KApplication::execDialog ( mEditorDialog ); 1096 KApplication::execDialog ( mEditorDialog );
1097 1097
1098 } else 1098 } else
1099 return; 1099 return;
1100 1100
1101 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1101 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1102 1102
1103 1103
1104} 1104}
1105 1105
1106void KABCore::addEmail( QString aStr ) 1106void KABCore::addEmail( QString aStr )
1107{ 1107{
1108#ifndef KAB_EMBEDDED 1108#ifndef KAB_EMBEDDED
1109 QString fullName, email; 1109 QString fullName, email;
1110 1110
1111 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1111 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1112 1112
1113 // Try to lookup the addressee matching the email address 1113 // Try to lookup the addressee matching the email address
1114 bool found = false; 1114 bool found = false;
1115 QStringList emailList; 1115 QStringList emailList;
1116 KABC::AddressBook::Iterator it; 1116 KABC::AddressBook::Iterator it;
1117 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1117 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1118 emailList = (*it).emails(); 1118 emailList = (*it).emails();
1119 if ( emailList.contains( email ) > 0 ) { 1119 if ( emailList.contains( email ) > 0 ) {
1120 found = true; 1120 found = true;
1121 (*it).setNameFromString( fullName ); 1121 (*it).setNameFromString( fullName );
1122 editContact( (*it).uid() ); 1122 editContact( (*it).uid() );
1123 } 1123 }
1124 } 1124 }
1125 1125
1126 if ( !found ) { 1126 if ( !found ) {
1127 KABC::Addressee addr; 1127 KABC::Addressee addr;
1128 addr.setNameFromString( fullName ); 1128 addr.setNameFromString( fullName );
1129 addr.insertEmail( email, true ); 1129 addr.insertEmail( email, true );
1130 1130
1131 mAddressBook->insertAddressee( addr ); 1131 mAddressBook->insertAddressee( addr );
1132 mViewManager->refreshView( addr.uid() ); 1132 mViewManager->refreshView( addr.uid() );
1133 editContact( addr.uid() ); 1133 editContact( addr.uid() );
1134 } 1134 }
1135#else //KAB_EMBEDDED 1135#else //KAB_EMBEDDED
1136 qDebug("KABCore::addEmail finsih method"); 1136 qDebug("KABCore::addEmail finsih method");
1137#endif //KAB_EMBEDDED 1137#endif //KAB_EMBEDDED
1138} 1138}
1139 1139
1140void KABCore::importVCard( const KURL &url, bool showPreview ) 1140void KABCore::importVCard( const KURL &url, bool showPreview )
1141{ 1141{
1142 mXXPortManager->importVCard( url, showPreview ); 1142 mXXPortManager->importVCard( url, showPreview );
1143} 1143}
1144void KABCore::importFromOL() 1144void KABCore::importFromOL()
1145{ 1145{
1146#ifdef _WIN32_ 1146#ifdef _WIN32_
1147 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1147 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1148 idgl->exec(); 1148 idgl->exec();
1149 KABC::Addressee::List list = idgl->getAddressList(); 1149 KABC::Addressee::List list = idgl->getAddressList();
1150 if ( list.count() > 0 ) { 1150 if ( list.count() > 0 ) {
1151 KABC::Addressee::List listNew; 1151 KABC::Addressee::List listNew;
1152 KABC::Addressee::List listExisting; 1152 KABC::Addressee::List listExisting;
1153 KABC::Addressee::List::Iterator it; 1153 KABC::Addressee::List::Iterator it;
1154 KABC::AddressBook::Iterator iter; 1154 KABC::AddressBook::Iterator iter;
1155 for ( it = list.begin(); it != list.end(); ++it ) { 1155 for ( it = list.begin(); it != list.end(); ++it ) {
1156 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1156 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1157 listNew.append( (*it) ); 1157 listNew.append( (*it) );
1158 else 1158 else
1159 listExisting.append( (*it) ); 1159 listExisting.append( (*it) );
1160 } 1160 }
1161 if ( listExisting.count() > 0 ) 1161 if ( listExisting.count() > 0 )
1162 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1162 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1163 if ( listNew.count() > 0 ) { 1163 if ( listNew.count() > 0 ) {
1164 pasteWithNewUid = false; 1164 pasteWithNewUid = false;
1165 pasteContacts( listNew ); 1165 pasteContacts( listNew );
1166 pasteWithNewUid = true; 1166 pasteWithNewUid = true;
1167 } 1167 }
1168 } 1168 }
1169 delete idgl; 1169 delete idgl;
1170#endif 1170#endif
1171} 1171}
1172 1172
1173void KABCore::importVCard( const QString &vCard, bool showPreview ) 1173void KABCore::importVCard( const QString &vCard, bool showPreview )
1174{ 1174{
1175 mXXPortManager->importVCard( vCard, showPreview ); 1175 mXXPortManager->importVCard( vCard, showPreview );
1176} 1176}
1177 1177
1178//US added a second method without defaultparameter 1178//US added a second method without defaultparameter
1179void KABCore::editContact2() { 1179void KABCore::editContact2() {
1180 editContact( QString::null ); 1180 editContact( QString::null );
1181} 1181}
1182 1182
1183void KABCore::editContact( const QString &uid ) 1183void KABCore::editContact( const QString &uid )
1184{ 1184{
1185 1185
1186 if ( mExtensionManager->isQuickEditVisible() ) 1186 if ( mExtensionManager->isQuickEditVisible() )
1187 return; 1187 return;
1188 1188
1189 // First, locate the contact entry 1189 // First, locate the contact entry
1190 QString localUID = uid; 1190 QString localUID = uid;
1191 if ( localUID.isNull() ) { 1191 if ( localUID.isNull() ) {
1192 QStringList uidList = mViewManager->selectedUids(); 1192 QStringList uidList = mViewManager->selectedUids();
1193 if ( uidList.count() > 0 ) 1193 if ( uidList.count() > 0 )
1194 localUID = *( uidList.at( 0 ) ); 1194 localUID = *( uidList.at( 0 ) );
1195 } 1195 }
1196 1196
1197 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1197 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1198 if ( !addr.isEmpty() ) { 1198 if ( !addr.isEmpty() ) {
1199 mEditorDialog->setAddressee( addr ); 1199 mEditorDialog->setAddressee( addr );
1200 KApplication::execDialog ( mEditorDialog ); 1200 KApplication::execDialog ( mEditorDialog );
1201 } 1201 }
1202} 1202}
1203 1203
1204/** 1204/**
1205 Shows or edits the detail view for the given uid. If the uid is QString::null, 1205 Shows or edits the detail view for the given uid. If the uid is QString::null,
1206 the method will try to find a selected addressee in the view. 1206 the method will try to find a selected addressee in the view.
1207 */ 1207 */
1208void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1208void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1209{ 1209{
1210 if ( mMultipleViewsAtOnce ) 1210 if ( mMultipleViewsAtOnce )
1211 { 1211 {
1212 editContact( uid ); 1212 editContact( uid );
1213 } 1213 }
1214 else 1214 else
1215 { 1215 {
1216 setDetailsVisible( true ); 1216 setDetailsVisible( true );
1217 mActionDetails->setChecked(true); 1217 mActionDetails->setChecked(true);
1218 } 1218 }
1219 1219
1220} 1220}
1221 1221
1222void KABCore::save() 1222void KABCore::save()
1223{ 1223{
1224 if (syncManager->blockSave()) 1224 if (syncManager->blockSave())
1225 return; 1225 return;
1226 if ( !mModified ) 1226 if ( !mModified )
1227 return; 1227 return;
1228 1228
1229 syncManager->setBlockSave(true); 1229 syncManager->setBlockSave(true);
1230 QString text = i18n( "There was an error while attempting to save\n the " 1230 QString text = i18n( "There was an error while attempting to save\n the "
1231 "address book. Please check that some \nother application is " 1231 "address book. Please check that some \nother application is "
1232 "not using it. " ); 1232 "not using it. " );
1233 message(i18n("Saving addressbook ... ")); 1233 message(i18n("Saving addressbook ... "));
1234#ifndef KAB_EMBEDDED 1234#ifndef KAB_EMBEDDED
1235 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1235 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1236 if ( !b || !b->save() ) { 1236 if ( !b || !b->save() ) {
1237 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1237 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1238 } 1238 }
1239#else //KAB_EMBEDDED 1239#else //KAB_EMBEDDED
1240 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1240 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1241 if ( !b || !b->save() ) { 1241 if ( !b || !b->save() ) {
1242 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1242 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1243 } 1243 }
1244#endif //KAB_EMBEDDED 1244#endif //KAB_EMBEDDED
1245 1245
1246 message(i18n("Addressbook saved!")); 1246 message(i18n("Addressbook saved!"));
1247 setModified( false ); 1247 setModified( false );
1248 syncManager->setBlockSave(false); 1248 syncManager->setBlockSave(false);
1249} 1249}
1250 1250
1251 1251
1252void KABCore::undo() 1252void KABCore::undo()
1253{ 1253{
1254 UndoStack::instance()->undo(); 1254 UndoStack::instance()->undo();
1255 1255
1256 // Refresh the view 1256 // Refresh the view
1257 mViewManager->refreshView(); 1257 mViewManager->refreshView();
1258} 1258}
1259 1259
1260void KABCore::redo() 1260void KABCore::redo()
1261{ 1261{
1262 RedoStack::instance()->redo(); 1262 RedoStack::instance()->redo();
1263 1263
1264 // Refresh the view 1264 // Refresh the view
1265 mViewManager->refreshView(); 1265 mViewManager->refreshView();
1266} 1266}
1267 1267
1268void KABCore::setJumpButtonBarVisible( bool visible ) 1268void KABCore::setJumpButtonBarVisible( bool visible )
1269{ 1269{
1270 if (mMultipleViewsAtOnce) 1270 if (mMultipleViewsAtOnce)
1271 { 1271 {
1272 if ( visible ) 1272 if ( visible )
1273 mJumpButtonBar->show(); 1273 mJumpButtonBar->show();
1274 else 1274 else
1275 mJumpButtonBar->hide(); 1275 mJumpButtonBar->hide();
1276 } 1276 }
1277 else 1277 else
1278 { 1278 {
1279 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1279 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1280 if (mViewManager->isVisible()) 1280 if (mViewManager->isVisible())
1281 { 1281 {
1282 if ( visible ) 1282 if ( visible )
1283 mJumpButtonBar->show(); 1283 mJumpButtonBar->show();
1284 else 1284 else
1285 mJumpButtonBar->hide(); 1285 mJumpButtonBar->hide();
1286 } 1286 }
1287 else 1287 else
1288 { 1288 {
1289 mJumpButtonBar->hide(); 1289 mJumpButtonBar->hide();
1290 } 1290 }
1291 } 1291 }
1292} 1292}
1293 1293
1294 1294
1295void KABCore::setDetailsToState() 1295void KABCore::setDetailsToState()
1296{ 1296{
1297 setDetailsVisible( mActionDetails->isChecked() ); 1297 setDetailsVisible( mActionDetails->isChecked() );
1298} 1298}
1299void KABCore::setDetailsToggle() 1299void KABCore::setDetailsToggle()
1300{ 1300{
1301 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1301 mActionDetails->setChecked( !mActionDetails->isChecked() );
1302 setDetailsToState(); 1302 setDetailsToState();
1303} 1303}
1304 1304
1305 1305
1306 1306
1307void KABCore::setDetailsVisible( bool visible ) 1307void KABCore::setDetailsVisible( bool visible )
1308{ 1308{
1309 if (visible && mDetails->isHidden()) 1309 if (visible && mDetails->isHidden())
1310 { 1310 {
1311 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1311 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1312 if ( addrList.count() > 0 ) 1312 if ( addrList.count() > 0 )
1313 mDetails->setAddressee( addrList[ 0 ] ); 1313 mDetails->setAddressee( addrList[ 0 ] );
1314 } 1314 }
1315 1315
1316 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1316 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1317 // the listview and the detailview. We do that by changing the splitbar size. 1317 // the listview and the detailview. We do that by changing the splitbar size.
1318 if (mMultipleViewsAtOnce) 1318 if (mMultipleViewsAtOnce)
1319 { 1319 {
1320 if ( visible ) 1320 if ( visible )
1321 mDetails->show(); 1321 mDetails->show();
1322 else 1322 else
1323 mDetails->hide(); 1323 mDetails->hide();
1324 } 1324 }
1325 else 1325 else
1326 { 1326 {
1327 if ( visible ) { 1327 if ( visible ) {
1328 mViewManager->hide(); 1328 mViewManager->hide();
1329 mDetails->show(); 1329 mDetails->show();
1330 mIncSearchWidget->setFocus(); 1330 mIncSearchWidget->setFocus();
1331 } 1331 }
1332 else { 1332 else {
1333 mViewManager->show(); 1333 mViewManager->show();
1334 mDetails->hide(); 1334 mDetails->hide();
1335 mViewManager->setFocusAV(); 1335 mViewManager->setFocusAV();
1336 } 1336 }
1337 setJumpButtonBarVisible( !visible ); 1337 setJumpButtonBarVisible( !visible );
1338 } 1338 }
1339 1339
1340} 1340}
1341 1341
1342void KABCore::extensionChanged( int id ) 1342void KABCore::extensionChanged( int id )
1343{ 1343{
1344 //change the details view only for non desktop systems 1344 //change the details view only for non desktop systems
1345#ifndef DESKTOP_VERSION 1345#ifndef DESKTOP_VERSION
1346 1346
1347 if (id == 0) 1347 if (id == 0)
1348 { 1348 {
1349 //the user disabled the extension. 1349 //the user disabled the extension.
1350 1350
1351 if (mMultipleViewsAtOnce) 1351 if (mMultipleViewsAtOnce)
1352 { // enable detailsview again 1352 { // enable detailsview again
1353 setDetailsVisible( true ); 1353 setDetailsVisible( true );
1354 mActionDetails->setChecked( true ); 1354 mActionDetails->setChecked( true );
1355 } 1355 }
1356 else 1356 else
1357 { //go back to the listview 1357 { //go back to the listview
1358 setDetailsVisible( false ); 1358 setDetailsVisible( false );
1359 mActionDetails->setChecked( false ); 1359 mActionDetails->setChecked( false );
1360 mActionDetails->setEnabled(true); 1360 mActionDetails->setEnabled(true);
1361 } 1361 }
1362 1362
1363 } 1363 }
1364 else 1364 else
1365 { 1365 {
1366 //the user enabled the extension. 1366 //the user enabled the extension.
1367 setDetailsVisible( false ); 1367 setDetailsVisible( false );
1368 mActionDetails->setChecked( false ); 1368 mActionDetails->setChecked( false );
1369 1369
1370 if (!mMultipleViewsAtOnce) 1370 if (!mMultipleViewsAtOnce)
1371 { 1371 {
1372 mActionDetails->setEnabled(false); 1372 mActionDetails->setEnabled(false);
1373 } 1373 }
1374 1374
1375 mExtensionManager->setSelectionChanged(); 1375 mExtensionManager->setSelectionChanged();
1376 1376
1377 } 1377 }
1378 1378
1379#endif// DESKTOP_VERSION 1379#endif// DESKTOP_VERSION
1380 1380
1381} 1381}
1382 1382
1383 1383
1384void KABCore::extensionModified( const KABC::Addressee::List &list ) 1384void KABCore::extensionModified( const KABC::Addressee::List &list )
1385{ 1385{
1386 1386
1387 if ( list.count() != 0 ) { 1387 if ( list.count() != 0 ) {
1388 KABC::Addressee::List::ConstIterator it; 1388 KABC::Addressee::List::ConstIterator it;
1389 for ( it = list.begin(); it != list.end(); ++it ) 1389 for ( it = list.begin(); it != list.end(); ++it )
1390 mAddressBook->insertAddressee( *it ); 1390 mAddressBook->insertAddressee( *it );
1391 if ( list.count() > 1 ) 1391 if ( list.count() > 1 )
1392 setModified(); 1392 setModified();
1393 else 1393 else
1394 setModifiedWOrefresh(); 1394 setModifiedWOrefresh();
1395 } 1395 }
1396 if ( list.count() == 0 ) 1396 if ( list.count() == 0 )
1397 mViewManager->refreshView(); 1397 mViewManager->refreshView();
1398 else 1398 else
1399 mViewManager->refreshView( list[ 0 ].uid() ); 1399 mViewManager->refreshView( list[ 0 ].uid() );
1400 1400
1401 1401
1402 1402
1403} 1403}
1404 1404
1405QString KABCore::getNameByPhone( const QString &phone ) 1405QString KABCore::getNameByPhone( const QString &phone )
1406{ 1406{
1407#ifndef KAB_EMBEDDED 1407#ifndef KAB_EMBEDDED
1408 QRegExp r( "[/*/-/ ]" ); 1408 QRegExp r( "[/*/-/ ]" );
1409 QString localPhone( phone ); 1409 QString localPhone( phone );
1410 1410
1411 bool found = false; 1411 bool found = false;
1412 QString ownerName = ""; 1412 QString ownerName = "";
1413 KABC::AddressBook::Iterator iter; 1413 KABC::AddressBook::Iterator iter;
1414 KABC::PhoneNumber::List::Iterator phoneIter; 1414 KABC::PhoneNumber::List::Iterator phoneIter;
1415 KABC::PhoneNumber::List phoneList; 1415 KABC::PhoneNumber::List phoneList;
1416 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1416 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1417 phoneList = (*iter).phoneNumbers(); 1417 phoneList = (*iter).phoneNumbers();
1418 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1418 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1419 ++phoneIter) { 1419 ++phoneIter) {
1420 // Get rid of separator chars so just the numbers are compared. 1420 // Get rid of separator chars so just the numbers are compared.
1421 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1421 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1422 ownerName = (*iter).formattedName(); 1422 ownerName = (*iter).formattedName();
1423 found = true; 1423 found = true;
1424 } 1424 }
1425 } 1425 }
1426 } 1426 }
1427 1427
1428 return ownerName; 1428 return ownerName;
1429#else //KAB_EMBEDDED 1429#else //KAB_EMBEDDED
1430 qDebug("KABCore::getNameByPhone finsih method"); 1430 qDebug("KABCore::getNameByPhone finsih method");
1431 return ""; 1431 return "";
1432#endif //KAB_EMBEDDED 1432#endif //KAB_EMBEDDED
1433 1433
1434} 1434}
1435 1435
1436void KABCore::openConfigDialog() 1436void KABCore::openConfigDialog()
1437{ 1437{
1438 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1438 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1439 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1439 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1440 ConfigureDialog->addModule(kabcfg ); 1440 ConfigureDialog->addModule(kabcfg );
1441 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1441 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1442 ConfigureDialog->addModule(kdelibcfg ); 1442 ConfigureDialog->addModule(kdelibcfg );
1443 1443
1444 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1444 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1445 this, SLOT( configurationChanged() ) ); 1445 this, SLOT( configurationChanged() ) );
1446 connect( ConfigureDialog, SIGNAL( okClicked() ), 1446 connect( ConfigureDialog, SIGNAL( okClicked() ),
1447 this, SLOT( configurationChanged() ) ); 1447 this, SLOT( configurationChanged() ) );
1448 saveSettings(); 1448 saveSettings();
1449#ifndef DESKTOP_VERSION 1449#ifndef DESKTOP_VERSION
1450 ConfigureDialog->showMaximized(); 1450 ConfigureDialog->showMaximized();
1451#endif 1451#endif
1452 if ( ConfigureDialog->exec() ) 1452 if ( ConfigureDialog->exec() )
1453 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1453 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1454 delete ConfigureDialog; 1454 delete ConfigureDialog;
1455} 1455}
1456 1456
1457void KABCore::openLDAPDialog() 1457void KABCore::openLDAPDialog()
1458{ 1458{
1459#ifndef KAB_EMBEDDED 1459#ifndef KAB_EMBEDDED
1460 if ( !mLdapSearchDialog ) { 1460 if ( !mLdapSearchDialog ) {
1461 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1461 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1462 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1462 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1463 SLOT( refreshView() ) ); 1463 SLOT( refreshView() ) );
1464 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1464 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1465 SLOT( setModified() ) ); 1465 SLOT( setModified() ) );
1466 } else 1466 } else
1467 mLdapSearchDialog->restoreSettings(); 1467 mLdapSearchDialog->restoreSettings();
1468 1468
1469 if ( mLdapSearchDialog->isOK() ) 1469 if ( mLdapSearchDialog->isOK() )
1470 mLdapSearchDialog->exec(); 1470 mLdapSearchDialog->exec();
1471#else //KAB_EMBEDDED 1471#else //KAB_EMBEDDED
1472 qDebug("KABCore::openLDAPDialog() finsih method"); 1472 qDebug("KABCore::openLDAPDialog() finsih method");
1473#endif //KAB_EMBEDDED 1473#endif //KAB_EMBEDDED
1474} 1474}
1475 1475
1476void KABCore::print() 1476void KABCore::print()
1477{ 1477{
1478#ifndef KAB_EMBEDDED 1478#ifndef KAB_EMBEDDED
1479 KPrinter printer; 1479 KPrinter printer;
1480 if ( !printer.setup( this ) ) 1480 if ( !printer.setup( this ) )
1481 return; 1481 return;
1482 1482
1483 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1483 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1484 mViewManager->selectedUids(), this ); 1484 mViewManager->selectedUids(), this );
1485 1485
1486 wizard.exec(); 1486 wizard.exec();
1487#else //KAB_EMBEDDED 1487#else //KAB_EMBEDDED
1488 qDebug("KABCore::print() finsih method"); 1488 qDebug("KABCore::print() finsih method");
1489#endif //KAB_EMBEDDED 1489#endif //KAB_EMBEDDED
1490 1490
1491} 1491}
1492 1492
1493 1493
1494void KABCore::addGUIClient( KXMLGUIClient *client ) 1494void KABCore::addGUIClient( KXMLGUIClient *client )
1495{ 1495{
1496 if ( mGUIClient ) 1496 if ( mGUIClient )
1497 mGUIClient->insertChildClient( client ); 1497 mGUIClient->insertChildClient( client );
1498 else 1498 else
1499 KMessageBox::error( this, "no KXMLGUICLient"); 1499 KMessageBox::error( this, "no KXMLGUICLient");
1500} 1500}
1501 1501
1502 1502
1503void KABCore::configurationChanged() 1503void KABCore::configurationChanged()
1504{ 1504{
1505 mExtensionManager->reconfigure(); 1505 mExtensionManager->reconfigure();
1506} 1506}
1507 1507
1508void KABCore::addressBookChanged() 1508void KABCore::addressBookChanged()
1509{ 1509{
1510/*US 1510/*US
1511 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1511 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1512 while ( it.current() ) { 1512 while ( it.current() ) {
1513 if ( it.current()->dirty() ) { 1513 if ( it.current()->dirty() ) {
1514 QString text = i18n( "Data has been changed externally. Unsaved " 1514 QString text = i18n( "Data has been changed externally. Unsaved "
1515 "changes will be lost." ); 1515 "changes will be lost." );
1516 KMessageBox::information( this, text ); 1516 KMessageBox::information( this, text );
1517 } 1517 }
1518 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1518 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1519 ++it; 1519 ++it;
1520 } 1520 }
1521*/ 1521*/
1522 if (mEditorDialog) 1522 if (mEditorDialog)
1523 { 1523 {
1524 if (mEditorDialog->dirty()) 1524 if (mEditorDialog->dirty())
1525 { 1525 {
1526 QString text = i18n( "Data has been changed externally. Unsaved " 1526 QString text = i18n( "Data has been changed externally. Unsaved "
1527 "changes will be lost." ); 1527 "changes will be lost." );
1528 KMessageBox::information( this, text ); 1528 KMessageBox::information( this, text );
1529 } 1529 }
1530 QString currentuid = mEditorDialog->addressee().uid(); 1530 QString currentuid = mEditorDialog->addressee().uid();
1531 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1531 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1532 } 1532 }
1533 mViewManager->refreshView(); 1533 mViewManager->refreshView();
1534// mDetails->refreshView(); 1534// mDetails->refreshView();
1535 1535
1536 1536
1537} 1537}
1538 1538
1539AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1539AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1540 const char *name ) 1540 const char *name )
1541{ 1541{
1542 1542
1543 if ( mEditorDialog == 0 ) { 1543 if ( mEditorDialog == 0 ) {
1544 mEditorDialog = new AddresseeEditorDialog( this, parent, 1544 mEditorDialog = new AddresseeEditorDialog( this, parent,
1545 name ? name : "editorDialog" ); 1545 name ? name : "editorDialog" );
1546 1546
1547 1547
1548 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1548 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1549 SLOT( contactModified( const KABC::Addressee& ) ) ); 1549 SLOT( contactModified( const KABC::Addressee& ) ) );
1550 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1550 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1551 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1551 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1552 } 1552 }
1553 1553
1554 return mEditorDialog; 1554 return mEditorDialog;
1555} 1555}
1556 1556
1557void KABCore::slotEditorDestroyed( const QString &uid ) 1557void KABCore::slotEditorDestroyed( const QString &uid )
1558{ 1558{
1559 //mEditorDict.remove( uid ); 1559 //mEditorDict.remove( uid );
1560} 1560}
1561 1561
1562void KABCore::initGUI() 1562void KABCore::initGUI()
1563{ 1563{
1564#ifndef KAB_EMBEDDED 1564#ifndef KAB_EMBEDDED
1565 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1565 QHBoxLayout *topLayout = new QHBoxLayout( this );
1566 topLayout->setSpacing( KDialogBase::spacingHint() ); 1566 topLayout->setSpacing( KDialogBase::spacingHint() );
1567 1567
1568 mExtensionBarSplitter = new QSplitter( this ); 1568 mExtensionBarSplitter = new QSplitter( this );
1569 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1569 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1570 1570
1571 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1571 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1572 1572
1573 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1573 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1574 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1574 mIncSearchWidget = new IncSearchWidget( viewSpace );
1575 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1575 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1576 SLOT( incrementalSearch( const QString& ) ) ); 1576 SLOT( incrementalSearch( const QString& ) ) );
1577 1577
1578 mViewManager = new ViewManager( this, viewSpace ); 1578 mViewManager = new ViewManager( this, viewSpace );
1579 viewSpace->setStretchFactor( mViewManager, 1 ); 1579 viewSpace->setStretchFactor( mViewManager, 1 );
1580 1580
1581 mDetails = new ViewContainer( mDetailsSplitter ); 1581 mDetails = new ViewContainer( mDetailsSplitter );
1582 1582
1583 mJumpButtonBar = new JumpButtonBar( this, this ); 1583 mJumpButtonBar = new JumpButtonBar( this, this );
1584 1584
1585 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1585 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1586 1586
1587 topLayout->addWidget( mExtensionBarSplitter ); 1587 topLayout->addWidget( mExtensionBarSplitter );
1588 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1588 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1589 topLayout->addWidget( mJumpButtonBar ); 1589 topLayout->addWidget( mJumpButtonBar );
1590 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1590 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1591 1591
1592 mXXPortManager = new XXPortManager( this, this ); 1592 mXXPortManager = new XXPortManager( this, this );
1593 1593
1594#else //KAB_EMBEDDED 1594#else //KAB_EMBEDDED
1595 //US initialize viewMenu before settingup viewmanager. 1595 //US initialize viewMenu before settingup viewmanager.
1596 // Viewmanager needs this menu to plugin submenues. 1596 // Viewmanager needs this menu to plugin submenues.
1597 viewMenu = new QPopupMenu( this ); 1597 viewMenu = new QPopupMenu( this );
1598 settingsMenu = new QPopupMenu( this ); 1598 settingsMenu = new QPopupMenu( this );
1599 //filterMenu = new QPopupMenu( this ); 1599 //filterMenu = new QPopupMenu( this );
1600 ImportMenu = new QPopupMenu( this ); 1600 ImportMenu = new QPopupMenu( this );
1601 ExportMenu = new QPopupMenu( this ); 1601 ExportMenu = new QPopupMenu( this );
1602 syncMenu = new QPopupMenu( this ); 1602 syncMenu = new QPopupMenu( this );
1603 changeMenu= new QPopupMenu( this ); 1603 changeMenu= new QPopupMenu( this );
1604 1604
1605//US since we have no splitter for the embedded system, setup 1605//US since we have no splitter for the embedded system, setup
1606// a layout with two frames. One left and one right. 1606// a layout with two frames. One left and one right.
1607 1607
1608 QBoxLayout *topLayout; 1608 QBoxLayout *topLayout;
1609 1609
1610 // = new QHBoxLayout( this ); 1610 // = new QHBoxLayout( this );
1611// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1611// QBoxLayout *topLayout = (QBoxLayout*)layout();
1612 1612
1613// QWidget *mainBox = new QWidget( this ); 1613// QWidget *mainBox = new QWidget( this );
1614// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1614// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1615 1615
1616#ifdef DESKTOP_VERSION 1616#ifdef DESKTOP_VERSION
1617 topLayout = new QHBoxLayout( this ); 1617 topLayout = new QHBoxLayout( this );
1618 1618
1619 1619
1620 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1620 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1621 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1621 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1622 1622
1623 topLayout->addWidget(mMiniSplitter ); 1623 topLayout->addWidget(mMiniSplitter );
1624 1624
1625 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1625 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1626 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1626 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1627 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1627 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1628 mDetails = new ViewContainer( mMiniSplitter ); 1628 mDetails = new ViewContainer( mMiniSplitter );
1629 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1629 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1630#else 1630#else
1631 if ( QApplication::desktop()->width() > 480 ) { 1631 if ( QApplication::desktop()->width() > 480 ) {
1632 topLayout = new QHBoxLayout( this ); 1632 topLayout = new QHBoxLayout( this );
1633 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1633 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1634 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1634 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1635 } else { 1635 } else {
1636 1636
1637 topLayout = new QHBoxLayout( this ); 1637 topLayout = new QHBoxLayout( this );
1638 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1638 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1639 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1639 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1640 } 1640 }
1641 1641
1642 topLayout->addWidget(mMiniSplitter ); 1642 topLayout->addWidget(mMiniSplitter );
1643 mViewManager = new ViewManager( this, mMiniSplitter ); 1643 mViewManager = new ViewManager( this, mMiniSplitter );
1644 mDetails = new ViewContainer( mMiniSplitter ); 1644 mDetails = new ViewContainer( mMiniSplitter );
1645 1645
1646 1646
1647 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1647 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1648#endif 1648#endif
1649 //eh->hide(); 1649 //eh->hide();
1650 // topLayout->addWidget(mExtensionManager ); 1650 // topLayout->addWidget(mExtensionManager );
1651 1651
1652 1652
1653/*US 1653/*US
1654#ifndef KAB_NOSPLITTER 1654#ifndef KAB_NOSPLITTER
1655 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1655 QHBoxLayout *topLayout = new QHBoxLayout( this );
1656//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1656//US topLayout->setSpacing( KDialogBase::spacingHint() );
1657 topLayout->setSpacing( 10 ); 1657 topLayout->setSpacing( 10 );
1658 1658
1659 mDetailsSplitter = new QSplitter( this ); 1659 mDetailsSplitter = new QSplitter( this );
1660 1660
1661 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1661 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1662 1662
1663 mViewManager = new ViewManager( this, viewSpace ); 1663 mViewManager = new ViewManager( this, viewSpace );
1664 viewSpace->setStretchFactor( mViewManager, 1 ); 1664 viewSpace->setStretchFactor( mViewManager, 1 );
1665 1665
1666 mDetails = new ViewContainer( mDetailsSplitter ); 1666 mDetails = new ViewContainer( mDetailsSplitter );
1667 1667
1668 topLayout->addWidget( mDetailsSplitter ); 1668 topLayout->addWidget( mDetailsSplitter );
1669 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1669 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1670#else //KAB_NOSPLITTER 1670#else //KAB_NOSPLITTER
1671 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1671 QHBoxLayout *topLayout = new QHBoxLayout( this );
1672//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1672//US topLayout->setSpacing( KDialogBase::spacingHint() );
1673 topLayout->setSpacing( 10 ); 1673 topLayout->setSpacing( 10 );
1674 1674
1675// mDetailsSplitter = new QSplitter( this ); 1675// mDetailsSplitter = new QSplitter( this );
1676 1676
1677 QVBox *viewSpace = new QVBox( this ); 1677 QVBox *viewSpace = new QVBox( this );
1678 1678
1679 mViewManager = new ViewManager( this, viewSpace ); 1679 mViewManager = new ViewManager( this, viewSpace );
1680 viewSpace->setStretchFactor( mViewManager, 1 ); 1680 viewSpace->setStretchFactor( mViewManager, 1 );
1681 1681
1682 mDetails = new ViewContainer( this ); 1682 mDetails = new ViewContainer( this );
1683 1683
1684 topLayout->addWidget( viewSpace ); 1684 topLayout->addWidget( viewSpace );
1685// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1685// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1686 topLayout->addWidget( mDetails ); 1686 topLayout->addWidget( mDetails );
1687#endif //KAB_NOSPLITTER 1687#endif //KAB_NOSPLITTER
1688*/ 1688*/
1689 1689
1690 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1690 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1691 syncManager->setBlockSave(false); 1691 syncManager->setBlockSave(false);
1692 1692
1693 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1693 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1694 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1694 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1695 syncManager->setDefaultFileName( sentSyncFile()); 1695 syncManager->setDefaultFileName( sentSyncFile());
1696 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1696 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1697 1697
1698#endif //KAB_EMBEDDED 1698#endif //KAB_EMBEDDED
1699 initActions(); 1699 initActions();
1700 1700
1701#ifdef KAB_EMBEDDED 1701#ifdef KAB_EMBEDDED
1702 addActionsManually(); 1702 addActionsManually();
1703 //US make sure the export and import menues are initialized before creating the xxPortManager. 1703 //US make sure the export and import menues are initialized before creating the xxPortManager.
1704 mXXPortManager = new XXPortManager( this, this ); 1704 mXXPortManager = new XXPortManager( this, this );
1705 1705
1706 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1706 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1707 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1707 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1708 // mActionQuit->plug ( mMainWindow->toolBar()); 1708 // mActionQuit->plug ( mMainWindow->toolBar());
1709 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1709 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1710 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1710 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1711 // mIncSearchWidget->hide(); 1711 // mIncSearchWidget->hide();
1712 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1712 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1713 SLOT( incrementalSearch( const QString& ) ) ); 1713 SLOT( incrementalSearch( const QString& ) ) );
1714 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1714 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1715 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1715 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1716 1716
1717 mJumpButtonBar = new JumpButtonBar( this, this ); 1717 mJumpButtonBar = new JumpButtonBar( this, this );
1718 1718
1719 topLayout->addWidget( mJumpButtonBar ); 1719 topLayout->addWidget( mJumpButtonBar );
1720//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1720//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1721 1721
1722// mMainWindow->getIconToolBar()->raise(); 1722// mMainWindow->getIconToolBar()->raise();
1723 1723
1724#endif //KAB_EMBEDDED 1724#endif //KAB_EMBEDDED
1725 1725
1726} 1726}
1727void KABCore::initActions() 1727void KABCore::initActions()
1728{ 1728{
1729//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1729//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1730 1730
1731#ifndef KAB_EMBEDDED 1731#ifndef KAB_EMBEDDED
1732 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1732 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1733 SLOT( clipboardDataChanged() ) ); 1733 SLOT( clipboardDataChanged() ) );
1734#endif //KAB_EMBEDDED 1734#endif //KAB_EMBEDDED
1735 1735
1736 // file menu 1736 // file menu
1737 if ( mIsPart ) { 1737 if ( mIsPart ) {
1738 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1738 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1739 SLOT( sendMail() ), actionCollection(), 1739 SLOT( sendMail() ), actionCollection(),
1740 "kaddressbook_mail" ); 1740 "kaddressbook_mail" );
1741 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1741 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1742 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1742 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1743 1743
1744 } else { 1744 } else {
1745 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1745 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1746 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1746 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1747 } 1747 }
1748 1748
1749 1749
1750 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1750 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1751 SLOT( save() ), actionCollection(), "file_sync" ); 1751 SLOT( save() ), actionCollection(), "file_sync" );
1752 1752
1753 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1753 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1754 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1754 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1755 1755
1756 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1756 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1757 this, SLOT( mailVCard() ), 1757 this, SLOT( mailVCard() ),
1758 actionCollection(), "file_mail_vcard"); 1758 actionCollection(), "file_mail_vcard");
1759 1759
1760 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1760 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1761 SLOT( export2phone() ), actionCollection(), 1761 SLOT( export2phone() ), actionCollection(),
1762 "kaddressbook_ex2phone" ); 1762 "kaddressbook_ex2phone" );
1763 1763
1764 mActionBeamVCard = 0; 1764 mActionBeamVCard = 0;
1765 mActionBeam = 0; 1765 mActionBeam = 0;
1766 1766
1767#ifndef DESKTOP_VERSION 1767#ifndef DESKTOP_VERSION
1768 if ( Ir::supported() ) { 1768 if ( Ir::supported() ) {
1769 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1769 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1770 SLOT( beamVCard() ), actionCollection(), 1770 SLOT( beamVCard() ), actionCollection(),
1771 "kaddressbook_beam_vcard" ); 1771 "kaddressbook_beam_vcard" );
1772 1772
1773 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1773 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1774 SLOT( beamMySelf() ), actionCollection(), 1774 SLOT( beamMySelf() ), actionCollection(),
1775 "kaddressbook_beam_myself" ); 1775 "kaddressbook_beam_myself" );
1776 } 1776 }
1777#endif 1777#endif
1778 1778
1779 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1779 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1780 this, SLOT( editContact2() ), 1780 this, SLOT( editContact2() ),
1781 actionCollection(), "file_properties" ); 1781 actionCollection(), "file_properties" );
1782 1782
1783#ifdef KAB_EMBEDDED 1783#ifdef KAB_EMBEDDED
1784 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1784 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1785 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1785 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1786 mMainWindow, SLOT( exit() ), 1786 mMainWindow, SLOT( exit() ),
1787 actionCollection(), "quit" ); 1787 actionCollection(), "quit" );
1788#endif //KAB_EMBEDDED 1788#endif //KAB_EMBEDDED
1789 1789
1790 // edit menu 1790 // edit menu
1791 if ( mIsPart ) { 1791 if ( mIsPart ) {
1792 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1792 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1793 SLOT( copyContacts() ), actionCollection(), 1793 SLOT( copyContacts() ), actionCollection(),
1794 "kaddressbook_copy" ); 1794 "kaddressbook_copy" );
1795 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1795 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1796 SLOT( cutContacts() ), actionCollection(), 1796 SLOT( cutContacts() ), actionCollection(),
1797 "kaddressbook_cut" ); 1797 "kaddressbook_cut" );
1798 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1798 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1799 SLOT( pasteContacts() ), actionCollection(), 1799 SLOT( pasteContacts() ), actionCollection(),
1800 "kaddressbook_paste" ); 1800 "kaddressbook_paste" );
1801 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1801 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1802 SLOT( selectAllContacts() ), actionCollection(), 1802 SLOT( selectAllContacts() ), actionCollection(),
1803 "kaddressbook_select_all" ); 1803 "kaddressbook_select_all" );
1804 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1804 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1805 SLOT( undo() ), actionCollection(), 1805 SLOT( undo() ), actionCollection(),
1806 "kaddressbook_undo" ); 1806 "kaddressbook_undo" );
1807 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1807 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1808 this, SLOT( redo() ), actionCollection(), 1808 this, SLOT( redo() ), actionCollection(),
1809 "kaddressbook_redo" ); 1809 "kaddressbook_redo" );
1810 } else { 1810 } else {
1811 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1811 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1812 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1812 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1813 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1813 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1814 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1814 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1815 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1815 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1816 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1816 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1817 } 1817 }
1818 1818
1819 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1819 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1820 Key_Delete, this, SLOT( deleteContacts() ), 1820 Key_Delete, this, SLOT( deleteContacts() ),
1821 actionCollection(), "edit_delete" ); 1821 actionCollection(), "edit_delete" );
1822 1822
1823 mActionUndo->setEnabled( false ); 1823 mActionUndo->setEnabled( false );
1824 mActionRedo->setEnabled( false ); 1824 mActionRedo->setEnabled( false );
1825 1825
1826 // settings menu 1826 // settings menu
1827#ifdef KAB_EMBEDDED 1827#ifdef KAB_EMBEDDED
1828//US special menuentry to configure the addressbook resources. On KDE 1828//US special menuentry to configure the addressbook resources. On KDE
1829// you do that through the control center !!! 1829// you do that through the control center !!!
1830 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1830 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1831 SLOT( configureResources() ), actionCollection(), 1831 SLOT( configureResources() ), actionCollection(),
1832 "kaddressbook_configure_resources" ); 1832 "kaddressbook_configure_resources" );
1833#endif //KAB_EMBEDDED 1833#endif //KAB_EMBEDDED
1834 1834
1835 if ( mIsPart ) { 1835 if ( mIsPart ) {
1836 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1836 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1837 SLOT( openConfigDialog() ), actionCollection(), 1837 SLOT( openConfigDialog() ), actionCollection(),
1838 "kaddressbook_configure" ); 1838 "kaddressbook_configure" );
1839 1839
1840 //US not implemented yet 1840 //US not implemented yet
1841 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1841 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1842 // this, SLOT( configureKeyBindings() ), actionCollection(), 1842 // this, SLOT( configureKeyBindings() ), actionCollection(),
1843 // "kaddressbook_configure_shortcuts" ); 1843 // "kaddressbook_configure_shortcuts" );
1844#ifdef KAB_EMBEDDED 1844#ifdef KAB_EMBEDDED
1845 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1845 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1846 mActionConfigureToolbars->setEnabled( false ); 1846 mActionConfigureToolbars->setEnabled( false );
1847#endif //KAB_EMBEDDED 1847#endif //KAB_EMBEDDED
1848 1848
1849 } else { 1849 } else {
1850 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1850 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1851 1851
1852 //US not implemented yet 1852 //US not implemented yet
1853 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1853 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1854 } 1854 }
1855 1855
1856 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1856 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1857 actionCollection(), "options_show_jump_bar" ); 1857 actionCollection(), "options_show_jump_bar" );
1858 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1858 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1859 1859
1860 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1860 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1861 actionCollection(), "options_show_details" ); 1861 actionCollection(), "options_show_details" );
1862 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1862 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1863 1863
1864 1864
1865 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 1865 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
1866 SLOT( toggleBeamReceive() ), actionCollection(), 1866 SLOT( toggleBeamReceive() ), actionCollection(),
1867 "kaddressbook_beam_rec" ); 1867 "kaddressbook_beam_rec" );
1868 1868
1869 1869
1870 // misc 1870 // misc
1871 // only enable LDAP lookup if we can handle the protocol 1871 // only enable LDAP lookup if we can handle the protocol
1872#ifndef KAB_EMBEDDED 1872#ifndef KAB_EMBEDDED
1873 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1873 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1874 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1874 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1875 this, SLOT( openLDAPDialog() ), actionCollection(), 1875 this, SLOT( openLDAPDialog() ), actionCollection(),
1876 "ldap_lookup" ); 1876 "ldap_lookup" );
1877 } 1877 }
1878#else //KAB_EMBEDDED 1878#else //KAB_EMBEDDED
1879 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1879 //qDebug("KABCore::initActions() LDAP has to be implemented");
1880#endif //KAB_EMBEDDED 1880#endif //KAB_EMBEDDED
1881 1881
1882 1882
1883 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1883 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1884 SLOT( setWhoAmI() ), actionCollection(), 1884 SLOT( setWhoAmI() ), actionCollection(),
1885 "set_personal" ); 1885 "set_personal" );
1886 1886
1887 1887
1888 1888
1889 1889
1890 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1890 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1891 SLOT( setCategories() ), actionCollection(), 1891 SLOT( setCategories() ), actionCollection(),
1892 "edit_set_categories" ); 1892 "edit_set_categories" );
1893 1893
1894 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1894 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1895 SLOT( removeVoice() ), actionCollection(), 1895 SLOT( removeVoice() ), actionCollection(),
1896 "remove_voice" ); 1896 "remove_voice" );
1897 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1897 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1898 SLOT( importFromOL() ), actionCollection(), 1898 SLOT( importFromOL() ), actionCollection(),
1899 "import_OL" ); 1899 "import_OL" );
1900#ifdef KAB_EMBEDDED 1900#ifdef KAB_EMBEDDED
1901 mActionLicence = new KAction( i18n( "Licence" ), 0, 1901 mActionLicence = new KAction( i18n( "Licence" ), 0,
1902 this, SLOT( showLicence() ), actionCollection(), 1902 this, SLOT( showLicence() ), actionCollection(),
1903 "licence_about_data" ); 1903 "licence_about_data" );
1904 mActionFaq = new KAction( i18n( "Faq" ), 0, 1904 mActionFaq = new KAction( i18n( "Faq" ), 0,
1905 this, SLOT( faq() ), actionCollection(), 1905 this, SLOT( faq() ), actionCollection(),
1906 "faq_about_data" ); 1906 "faq_about_data" );
1907 mActionWN = new KAction( i18n( "What's New?" ), 0, 1907 mActionWN = new KAction( i18n( "What's New?" ), 0,
1908 this, SLOT( whatsnew() ), actionCollection(), 1908 this, SLOT( whatsnew() ), actionCollection(),
1909 "wn" ); 1909 "wn" );
1910 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 1910 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
1911 this, SLOT( synchowto() ), actionCollection(), 1911 this, SLOT( synchowto() ), actionCollection(),
1912 "sync" ); 1912 "sync" );
1913 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 1913 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
1914 this, SLOT( kdesynchowto() ), actionCollection(), 1914 this, SLOT( kdesynchowto() ), actionCollection(),
1915 "kdesync" ); 1915 "kdesync" );
1916 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 1916 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
1917 this, SLOT( multisynchowto() ), actionCollection(), 1917 this, SLOT( multisynchowto() ), actionCollection(),
1918 "multisync" ); 1918 "multisync" );
1919 1919
1920 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1920 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1921 this, SLOT( createAboutData() ), actionCollection(), 1921 this, SLOT( createAboutData() ), actionCollection(),
1922 "kaddressbook_about_data" ); 1922 "kaddressbook_about_data" );
1923#endif //KAB_EMBEDDED 1923#endif //KAB_EMBEDDED
1924 1924
1925 clipboardDataChanged(); 1925 clipboardDataChanged();
1926 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1926 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1927 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1927 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1928} 1928}
1929 1929
1930//US we need this function, to plug all actions into the correct menues. 1930//US we need this function, to plug all actions into the correct menues.
1931// KDE uses a XML format to plug the actions, but we work her without this overhead. 1931// KDE uses a XML format to plug the actions, but we work her without this overhead.
1932void KABCore::addActionsManually() 1932void KABCore::addActionsManually()
1933{ 1933{
1934//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1934//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1935 1935
1936#ifdef KAB_EMBEDDED 1936#ifdef KAB_EMBEDDED
1937 QPopupMenu *fileMenu = new QPopupMenu( this ); 1937 QPopupMenu *fileMenu = new QPopupMenu( this );
1938 QPopupMenu *editMenu = new QPopupMenu( this ); 1938 QPopupMenu *editMenu = new QPopupMenu( this );
1939 QPopupMenu *helpMenu = new QPopupMenu( this ); 1939 QPopupMenu *helpMenu = new QPopupMenu( this );
1940 1940
1941 KToolBar* tb = mMainWindow->toolBar(); 1941 KToolBar* tb = mMainWindow->toolBar();
1942 1942
1943#ifndef DESKTOP_VERSION 1943#ifndef DESKTOP_VERSION
1944 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 1944 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
1945#endif 1945#endif
1946 QMenuBar* mb = mMainWindow->menuBar(); 1946 QMenuBar* mb = mMainWindow->menuBar();
1947 1947
1948 //US setup menubar. 1948 //US setup menubar.
1949 //Disable the following block if you do not want to have a menubar. 1949 //Disable the following block if you do not want to have a menubar.
1950 mb->insertItem( "&File", fileMenu ); 1950 mb->insertItem( "&File", fileMenu );
1951 mb->insertItem( "&Edit", editMenu ); 1951 mb->insertItem( "&Edit", editMenu );
1952 mb->insertItem( "&View", viewMenu ); 1952 mb->insertItem( "&View", viewMenu );
1953 mb->insertItem( "&Settings", settingsMenu ); 1953 mb->insertItem( "&Settings", settingsMenu );
1954 mb->insertItem( i18n("Synchronize"), syncMenu ); 1954 mb->insertItem( i18n("Synchronize"), syncMenu );
1955 mb->insertItem( "&Change selected", changeMenu ); 1955 mb->insertItem( "&Change selected", changeMenu );
1956 mb->insertItem( "&Help", helpMenu ); 1956 mb->insertItem( "&Help", helpMenu );
1957 mIncSearchWidget = new IncSearchWidget( tb ); 1957 mIncSearchWidget = new IncSearchWidget( tb );
1958 // tb->insertWidget(-1, 0, mIncSearchWidget); 1958 // tb->insertWidget(-1, 0, mIncSearchWidget);
1959#ifndef DESKTOP_VERSION 1959#ifndef DESKTOP_VERSION
1960 } else { 1960 } else {
1961 //US setup toolbar 1961 //US setup toolbar
1962 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1962 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1963 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1963 QPopupMenu *popupBarTB = new QPopupMenu( this );
1964 menuBarTB->insertItem( "ME", popupBarTB); 1964 menuBarTB->insertItem( "ME", popupBarTB);
1965 tb->insertWidget(-1, 0, menuBarTB); 1965 tb->insertWidget(-1, 0, menuBarTB);
1966 mIncSearchWidget = new IncSearchWidget( tb ); 1966 mIncSearchWidget = new IncSearchWidget( tb );
1967 1967
1968 tb->enableMoving(false); 1968 tb->enableMoving(false);
1969 popupBarTB->insertItem( "&File", fileMenu ); 1969 popupBarTB->insertItem( "&File", fileMenu );
1970 popupBarTB->insertItem( "&Edit", editMenu ); 1970 popupBarTB->insertItem( "&Edit", editMenu );
1971 popupBarTB->insertItem( "&View", viewMenu ); 1971 popupBarTB->insertItem( "&View", viewMenu );
1972 popupBarTB->insertItem( "&Settings", settingsMenu ); 1972 popupBarTB->insertItem( "&Settings", settingsMenu );
1973 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1973 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1974 mViewManager->getFilterAction()->plug ( popupBarTB); 1974 mViewManager->getFilterAction()->plug ( popupBarTB);
1975 popupBarTB->insertItem( "&Change selected", changeMenu ); 1975 popupBarTB->insertItem( "&Change selected", changeMenu );
1976 popupBarTB->insertItem( "&Help", helpMenu ); 1976 popupBarTB->insertItem( "&Help", helpMenu );
1977 if (QApplication::desktop()->width() > 320 ) { 1977 if (QApplication::desktop()->width() > 320 ) {
1978 // mViewManager->getFilterAction()->plug ( tb); 1978 // mViewManager->getFilterAction()->plug ( tb);
1979 } 1979 }
1980 } 1980 }
1981#endif 1981#endif
1982 // mActionQuit->plug ( mMainWindow->toolBar()); 1982 // mActionQuit->plug ( mMainWindow->toolBar());
1983 1983
1984 1984
1985 1985
1986 //US Now connect the actions with the menue entries. 1986 //US Now connect the actions with the menue entries.
1987 mActionPrint->plug( fileMenu ); 1987 mActionPrint->plug( fileMenu );
1988 mActionMail->plug( fileMenu ); 1988 mActionMail->plug( fileMenu );
1989 fileMenu->insertSeparator(); 1989 fileMenu->insertSeparator();
1990 1990
1991 mActionNewContact->plug( fileMenu ); 1991 mActionNewContact->plug( fileMenu );
1992 mActionNewContact->plug( tb ); 1992 mActionNewContact->plug( tb );
1993 1993
1994 mActionEditAddressee->plug( fileMenu ); 1994 mActionEditAddressee->plug( fileMenu );
1995 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1995 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1996 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1996 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1997 mActionEditAddressee->plug( tb ); 1997 mActionEditAddressee->plug( tb );
1998 1998
1999 fileMenu->insertSeparator(); 1999 fileMenu->insertSeparator();
2000 mActionSave->plug( fileMenu ); 2000 mActionSave->plug( fileMenu );
2001 fileMenu->insertItem( "&Import", ImportMenu ); 2001 fileMenu->insertItem( "&Import", ImportMenu );
2002 fileMenu->insertItem( "&Export", ExportMenu ); 2002 fileMenu->insertItem( "&Export", ExportMenu );
2003 fileMenu->insertSeparator(); 2003 fileMenu->insertSeparator();
2004 mActionMailVCard->plug( fileMenu ); 2004 mActionMailVCard->plug( fileMenu );
2005#ifndef DESKTOP_VERSION 2005#ifndef DESKTOP_VERSION
2006 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 2006 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
2007 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 2007 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
2008#endif 2008#endif
2009 fileMenu->insertSeparator(); 2009 fileMenu->insertSeparator();
2010 mActionQuit->plug( fileMenu ); 2010 mActionQuit->plug( fileMenu );
2011#ifdef _WIN32_ 2011#ifdef _WIN32_
2012 mActionImportOL->plug( ImportMenu ); 2012 mActionImportOL->plug( ImportMenu );
2013#endif 2013#endif
2014 // edit menu 2014 // edit menu
2015 mActionUndo->plug( editMenu ); 2015 mActionUndo->plug( editMenu );
2016 mActionRedo->plug( editMenu ); 2016 mActionRedo->plug( editMenu );
2017 editMenu->insertSeparator(); 2017 editMenu->insertSeparator();
2018 mActionCut->plug( editMenu ); 2018 mActionCut->plug( editMenu );
2019 mActionCopy->plug( editMenu ); 2019 mActionCopy->plug( editMenu );
2020 mActionPaste->plug( editMenu ); 2020 mActionPaste->plug( editMenu );
2021 mActionDelete->plug( editMenu ); 2021 mActionDelete->plug( editMenu );
2022 editMenu->insertSeparator(); 2022 editMenu->insertSeparator();
2023 mActionSelectAll->plug( editMenu ); 2023 mActionSelectAll->plug( editMenu );
2024 2024
2025 mActionRemoveVoice->plug( changeMenu ); 2025 mActionRemoveVoice->plug( changeMenu );
2026 // settings menu 2026 // settings menu
2027//US special menuentry to configure the addressbook resources. On KDE 2027//US special menuentry to configure the addressbook resources. On KDE
2028// you do that through the control center !!! 2028// you do that through the control center !!!
2029 mActionConfigResources->plug( settingsMenu ); 2029 mActionConfigResources->plug( settingsMenu );
2030 settingsMenu->insertSeparator(); 2030 settingsMenu->insertSeparator();
2031 2031
2032 mActionConfigKAddressbook->plug( settingsMenu ); 2032 mActionConfigKAddressbook->plug( settingsMenu );
2033 2033
2034 if ( mIsPart ) { 2034 if ( mIsPart ) {
2035 //US not implemented yet 2035 //US not implemented yet
2036 //mActionConfigShortcuts->plug( settingsMenu ); 2036 //mActionConfigShortcuts->plug( settingsMenu );
2037 //mActionConfigureToolbars->plug( settingsMenu ); 2037 //mActionConfigureToolbars->plug( settingsMenu );
2038 2038
2039 } else { 2039 } else {
2040 //US not implemented yet 2040 //US not implemented yet
2041 //mActionKeyBindings->plug( settingsMenu ); 2041 //mActionKeyBindings->plug( settingsMenu );
2042 } 2042 }
2043 2043
2044 settingsMenu->insertSeparator(); 2044 settingsMenu->insertSeparator();
2045 2045
2046 mActionJumpBar->plug( settingsMenu ); 2046 mActionJumpBar->plug( settingsMenu );
2047 mActionDetails->plug( settingsMenu ); 2047 mActionDetails->plug( settingsMenu );
2048 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2048 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2049 mActionDetails->plug( tb ); 2049 mActionDetails->plug( tb );
2050 settingsMenu->insertSeparator(); 2050 settingsMenu->insertSeparator();
2051 mActionBR->plug(settingsMenu ); 2051 mActionBR->plug(settingsMenu );
2052 settingsMenu->insertSeparator(); 2052 settingsMenu->insertSeparator();
2053 2053
2054 mActionWhoAmI->plug( settingsMenu ); 2054 mActionWhoAmI->plug( settingsMenu );
2055 mActionCategories->plug( settingsMenu ); 2055 mActionCategories->plug( settingsMenu );
2056 2056
2057 2057
2058 mActionWN->plug( helpMenu ); 2058 mActionWN->plug( helpMenu );
2059 mActionSyncHowto->plug( helpMenu ); 2059 mActionSyncHowto->plug( helpMenu );
2060 mActionKdeSyncHowto->plug( helpMenu ); 2060 mActionKdeSyncHowto->plug( helpMenu );
2061 mActionMultiSyncHowto->plug( helpMenu ); 2061 mActionMultiSyncHowto->plug( helpMenu );
2062 mActionFaq->plug( helpMenu ); 2062 mActionFaq->plug( helpMenu );
2063 mActionLicence->plug( helpMenu ); 2063 mActionLicence->plug( helpMenu );
2064 mActionAboutKAddressbook->plug( helpMenu ); 2064 mActionAboutKAddressbook->plug( helpMenu );
2065 2065
2066 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2066 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2067 2067
2068 mActionSave->plug( tb ); 2068 mActionSave->plug( tb );
2069 mViewManager->getFilterAction()->plug ( tb); 2069 mViewManager->getFilterAction()->plug ( tb);
2070 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2070 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2071 mActionUndo->plug( tb ); 2071 mActionUndo->plug( tb );
2072 mActionDelete->plug( tb ); 2072 mActionDelete->plug( tb );
2073 mActionRedo->plug( tb ); 2073 mActionRedo->plug( tb );
2074 } 2074 }
2075 } else { 2075 } else {
2076 mActionSave->plug( tb ); 2076 mActionSave->plug( tb );
2077 tb->enableMoving(false); 2077 tb->enableMoving(false);
2078 } 2078 }
2079 //mActionQuit->plug ( tb ); 2079 //mActionQuit->plug ( tb );
2080 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2080 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2081 2081
2082 //US link the searchwidget first to this. 2082 //US link the searchwidget first to this.
2083 // The real linkage to the toolbar happens later. 2083 // The real linkage to the toolbar happens later.
2084//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2084//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2085//US tb->insertItem( mIncSearchWidget ); 2085//US tb->insertItem( mIncSearchWidget );
2086/*US 2086/*US
2087 mIncSearchWidget = new IncSearchWidget( tb ); 2087 mIncSearchWidget = new IncSearchWidget( tb );
2088 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2088 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2089 SLOT( incrementalSearch( const QString& ) ) ); 2089 SLOT( incrementalSearch( const QString& ) ) );
2090 2090
2091 mJumpButtonBar = new JumpButtonBar( this, this ); 2091 mJumpButtonBar = new JumpButtonBar( this, this );
2092 2092
2093//US topLayout->addWidget( mJumpButtonBar ); 2093//US topLayout->addWidget( mJumpButtonBar );
2094 this->layout()->add( mJumpButtonBar ); 2094 this->layout()->add( mJumpButtonBar );
2095*/ 2095*/
2096 2096
2097#endif //KAB_EMBEDDED 2097#endif //KAB_EMBEDDED
2098 2098
2099 mActionExport2phone->plug( ExportMenu ); 2099 mActionExport2phone->plug( ExportMenu );
2100 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2100 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2101 syncManager->fillSyncMenu(); 2101 syncManager->fillSyncMenu();
2102 2102
2103} 2103}
2104void KABCore::showLicence() 2104void KABCore::showLicence()
2105{ 2105{
2106 KApplication::showLicence(); 2106 KApplication::showLicence();
2107} 2107}
2108void KABCore::removeVoice() 2108void KABCore::removeVoice()
2109{ 2109{
2110 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2110 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2111 return; 2111 return;
2112 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2112 KABC::Addressee::List list = mViewManager->selectedAddressees();
2113 KABC::Addressee::List::Iterator it; 2113 KABC::Addressee::List::Iterator it;
2114 for ( it = list.begin(); it != list.end(); ++it ) { 2114 for ( it = list.begin(); it != list.end(); ++it ) {
2115 2115
2116 if ( (*it).removeVoice() ) 2116 if ( (*it).removeVoice() )
2117 contactModified((*it) ); 2117 contactModified((*it) );
2118 } 2118 }
2119} 2119}
2120 2120
2121 2121
2122 2122
2123void KABCore::clipboardDataChanged() 2123void KABCore::clipboardDataChanged()
2124{ 2124{
2125 2125
2126 if ( mReadWrite ) 2126 if ( mReadWrite )
2127 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2127 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2128 2128
2129} 2129}
2130 2130
2131void KABCore::updateActionMenu() 2131void KABCore::updateActionMenu()
2132{ 2132{
2133 UndoStack *undo = UndoStack::instance(); 2133 UndoStack *undo = UndoStack::instance();
2134 RedoStack *redo = RedoStack::instance(); 2134 RedoStack *redo = RedoStack::instance();
2135 2135
2136 if ( undo->isEmpty() ) 2136 if ( undo->isEmpty() )
2137 mActionUndo->setText( i18n( "Undo" ) ); 2137 mActionUndo->setText( i18n( "Undo" ) );
2138 else 2138 else
2139 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2139 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2140 2140
2141 mActionUndo->setEnabled( !undo->isEmpty() ); 2141 mActionUndo->setEnabled( !undo->isEmpty() );
2142 2142
2143 if ( !redo->top() ) 2143 if ( !redo->top() )
2144 mActionRedo->setText( i18n( "Redo" ) ); 2144 mActionRedo->setText( i18n( "Redo" ) );
2145 else 2145 else
2146 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2146 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2147 2147
2148 mActionRedo->setEnabled( !redo->isEmpty() ); 2148 mActionRedo->setEnabled( !redo->isEmpty() );
2149} 2149}
2150 2150
2151void KABCore::configureKeyBindings() 2151void KABCore::configureKeyBindings()
2152{ 2152{
2153#ifndef KAB_EMBEDDED 2153#ifndef KAB_EMBEDDED
2154 KKeyDialog::configure( actionCollection(), true ); 2154 KKeyDialog::configure( actionCollection(), true );
2155#else //KAB_EMBEDDED 2155#else //KAB_EMBEDDED
2156 qDebug("KABCore::configureKeyBindings() not implemented"); 2156 qDebug("KABCore::configureKeyBindings() not implemented");
2157#endif //KAB_EMBEDDED 2157#endif //KAB_EMBEDDED
2158} 2158}
2159 2159
2160#ifdef KAB_EMBEDDED 2160#ifdef KAB_EMBEDDED
2161void KABCore::configureResources() 2161void KABCore::configureResources()
2162{ 2162{
2163 KRES::KCMKResources dlg( this, "" , 0 ); 2163 KRES::KCMKResources dlg( this, "" , 0 );
2164 2164
2165 if ( !dlg.exec() ) 2165 if ( !dlg.exec() )
2166 return; 2166 return;
2167 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2167 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2168} 2168}
2169#endif //KAB_EMBEDDED 2169#endif //KAB_EMBEDDED
2170 2170
2171 2171
2172/* this method will be called through the QCop interface from Ko/Pi to select addresses 2172/* this method will be called through the QCop interface from Ko/Pi to select addresses
2173 * for the attendees list of an event. 2173 * for the attendees list of an event.
2174 */ 2174 */
2175void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2175void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2176{ 2176{
2177 QStringList nameList; 2177 QStringList nameList;
2178 QStringList emailList; 2178 QStringList emailList;
2179 QStringList uidList; 2179 QStringList uidList;
2180 2180
2181 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2181 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2182 uint i=0; 2182 uint i=0;
2183 for (i=0; i < list.count(); i++) 2183 for (i=0; i < list.count(); i++)
2184 { 2184 {
2185 nameList.append(list[i].realName()); 2185 nameList.append(list[i].realName());
2186 emailList.append(list[i].preferredEmail()); 2186 emailList.append(list[i].preferredEmail());
2187 uidList.append(list[i].uid()); 2187 uidList.append(list[i].uid());
2188 } 2188 }
2189 2189
2190 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2190 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2191 2191
2192} 2192}
2193 2193
2194/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2194/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2195 * to put them into the calendar. 2195 * to put them into the calendar.
2196 */ 2196 */
2197void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2197void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2198{ 2198{
2199 // qDebug("KABCore::requestForBirthdayList"); 2199 // qDebug("KABCore::requestForBirthdayList");
2200 QStringList birthdayList; 2200 QStringList birthdayList;
2201 QStringList anniversaryList; 2201 QStringList anniversaryList;
2202 QStringList realNameList; 2202 QStringList realNameList;
2203 QStringList preferredEmailList; 2203 QStringList preferredEmailList;
2204 QStringList assembledNameList; 2204 QStringList assembledNameList;
2205 QStringList uidList; 2205 QStringList uidList;
2206 2206
2207 KABC::AddressBook::Iterator it; 2207 KABC::AddressBook::Iterator it;
2208 2208
2209 int count = 0; 2209 int count = 0;
2210 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2210 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2211 ++count; 2211 ++count;
2212 } 2212 }
2213 QProgressBar bar(count,0 ); 2213 QProgressBar bar(count,0 );
2214 int w = 300; 2214 int w = 300;
2215 if ( QApplication::desktop()->width() < 320 ) 2215 if ( QApplication::desktop()->width() < 320 )
2216 w = 220; 2216 w = 220;
2217 int h = bar.sizeHint().height() ; 2217 int h = bar.sizeHint().height() ;
2218 int dw = QApplication::desktop()->width(); 2218 int dw = QApplication::desktop()->width();
2219 int dh = QApplication::desktop()->height(); 2219 int dh = QApplication::desktop()->height();
2220 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2220 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2221 bar.show(); 2221 bar.show();
2222 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2222 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2223 qApp->processEvents(); 2223 qApp->processEvents();
2224 2224
2225 QDate bday; 2225 QDate bday;
2226 QString anni; 2226 QString anni;
2227 QString formattedbday; 2227 QString formattedbday;
2228 2228
2229 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2229 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2230 { 2230 {
2231 if ( ! bar.isVisible() ) 2231 if ( ! bar.isVisible() )
2232 return; 2232 return;
2233 bar.setProgress( count++ ); 2233 bar.setProgress( count++ );
2234 qApp->processEvents(); 2234 qApp->processEvents();
2235 bday = (*it).birthday().date(); 2235 bday = (*it).birthday().date();
2236 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2236 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2237 2237
2238 if ( bday.isValid() || !anni.isEmpty()) 2238 if ( bday.isValid() || !anni.isEmpty())
2239 { 2239 {
2240 if (bday.isValid()) 2240 if (bday.isValid())
2241 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2241 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2242 else 2242 else
2243 formattedbday = "NOTVALID"; 2243 formattedbday = "NOTVALID";
2244 if (anni.isEmpty()) 2244 if (anni.isEmpty())
2245 anni = "INVALID"; 2245 anni = "INVALID";
2246 2246
2247 birthdayList.append(formattedbday); 2247 birthdayList.append(formattedbday);
2248 anniversaryList.append(anni); //should be ISODate 2248 anniversaryList.append(anni); //should be ISODate
2249 realNameList.append((*it).realName()); 2249 realNameList.append((*it).realName());
2250 preferredEmailList.append((*it).preferredEmail()); 2250 preferredEmailList.append((*it).preferredEmail());
2251 assembledNameList.append((*it).assembledName()); 2251 assembledNameList.append((*it).assembledName());
2252 uidList.append((*it).uid()); 2252 uidList.append((*it).uid());
2253 2253
2254 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2254 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2255 } 2255 }
2256 } 2256 }
2257 2257
2258 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2258 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2259 2259
2260} 2260}
2261 2261
2262/* this method will be called through the QCop interface from other apps to show details of a contact. 2262/* this method will be called through the QCop interface from other apps to show details of a contact.
2263 */ 2263 */
2264void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2264void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2265{ 2265{
2266 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2266 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2267 2267
2268 QString foundUid = QString::null; 2268 QString foundUid = QString::null;
2269 if ( ! uid.isEmpty() ) { 2269 if ( ! uid.isEmpty() ) {
2270 Addressee adrr = mAddressBook->findByUid( uid ); 2270 Addressee adrr = mAddressBook->findByUid( uid );
2271 if ( !adrr.isEmpty() ) { 2271 if ( !adrr.isEmpty() ) {
2272 foundUid = uid; 2272 foundUid = uid;
2273 } 2273 }
2274 if ( email == "sendbacklist" ) { 2274 if ( email == "sendbacklist" ) {
2275 //qDebug("ssssssssssssssssssssssend "); 2275 //qDebug("ssssssssssssssssssssssend ");
2276 QStringList nameList; 2276 QStringList nameList;
2277 QStringList emailList; 2277 QStringList emailList;
2278 QStringList uidList; 2278 QStringList uidList;
2279 nameList.append(adrr.realName()); 2279 nameList.append(adrr.realName());
2280 emailList = adrr.emails(); 2280 emailList = adrr.emails();
2281 uidList.append( adrr.preferredEmail()); 2281 uidList.append( adrr.preferredEmail());
2282 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2282 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2283 return; 2283 return;
2284 } 2284 }
2285 2285
2286 } 2286 }
2287 2287
2288 if ( email == "sendbacklist" ) 2288 if ( email == "sendbacklist" )
2289 return; 2289 return;
2290 if (foundUid.isEmpty()) 2290 if (foundUid.isEmpty())
2291 { 2291 {
2292 //find the uid of the person first 2292 //find the uid of the person first
2293 Addressee::List namelist; 2293 Addressee::List namelist;
2294 Addressee::List emaillist; 2294 Addressee::List emaillist;
2295 2295
2296 if (!name.isEmpty()) 2296 if (!name.isEmpty())
2297 namelist = mAddressBook->findByName( name ); 2297 namelist = mAddressBook->findByName( name );
2298 2298
2299 if (!email.isEmpty()) 2299 if (!email.isEmpty())
2300 emaillist = mAddressBook->findByEmail( email ); 2300 emaillist = mAddressBook->findByEmail( email );
2301 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2301 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2302 //check if we have a match in Namelist and Emaillist 2302 //check if we have a match in Namelist and Emaillist
2303 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2303 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2304 foundUid = emaillist[0].uid(); 2304 foundUid = emaillist[0].uid();
2305 } 2305 }
2306 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2306 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2307 foundUid = namelist[0].uid(); 2307 foundUid = namelist[0].uid();
2308 else 2308 else
2309 { 2309 {
2310 for (int i = 0; i < namelist.count(); i++) 2310 for (int i = 0; i < namelist.count(); i++)
2311 { 2311 {
2312 for (int j = 0; j < emaillist.count(); j++) 2312 for (int j = 0; j < emaillist.count(); j++)
2313 { 2313 {
2314 if (namelist[i] == emaillist[j]) 2314 if (namelist[i] == emaillist[j])
2315 { 2315 {
2316 foundUid = namelist[i].uid(); 2316 foundUid = namelist[i].uid();
2317 } 2317 }
2318 } 2318 }
2319 } 2319 }
2320 } 2320 }
2321 } 2321 }
2322 else 2322 else
2323 { 2323 {
2324 foundUid = uid; 2324 foundUid = uid;
2325 } 2325 }
2326 2326
2327 if (!foundUid.isEmpty()) 2327 if (!foundUid.isEmpty())
2328 { 2328 {
2329 2329
2330 // raise Ka/Pi if it is in the background 2330 // raise Ka/Pi if it is in the background
2331#ifndef DESKTOP_VERSION 2331#ifndef DESKTOP_VERSION
2332#ifndef KORG_NODCOP 2332#ifndef KORG_NODCOP
2333 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2333 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2334#endif 2334#endif
2335#endif 2335#endif
2336 2336
2337 mMainWindow->showMaximized(); 2337 mMainWindow->showMaximized();
2338 mMainWindow-> raise(); 2338 mMainWindow-> raise();
2339 2339
2340 mViewManager->setSelected( "", false); 2340 mViewManager->setSelected( "", false);
2341 mViewManager->refreshView( "" ); 2341 mViewManager->refreshView( "" );
2342 mViewManager->setSelected( foundUid, true ); 2342 mViewManager->setSelected( foundUid, true );
2343 mViewManager->refreshView( foundUid ); 2343 mViewManager->refreshView( foundUid );
2344 2344
2345 if ( !mMultipleViewsAtOnce ) 2345 if ( !mMultipleViewsAtOnce )
2346 { 2346 {
2347 setDetailsVisible( true ); 2347 setDetailsVisible( true );
2348 mActionDetails->setChecked(true); 2348 mActionDetails->setChecked(true);
2349 } 2349 }
2350 } 2350 }
2351} 2351}
2352 2352
2353void KABCore::whatsnew() 2353void KABCore::whatsnew()
2354{ 2354{
2355 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2355 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2356} 2356}
2357void KABCore::synchowto() 2357void KABCore::synchowto()
2358{ 2358{
2359 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2359 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2360} 2360}
2361void KABCore::kdesynchowto() 2361void KABCore::kdesynchowto()
2362{ 2362{
2363 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2363 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2364} 2364}
2365void KABCore::multisynchowto() 2365void KABCore::multisynchowto()
2366{ 2366{
2367 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2367 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2368} 2368}
2369void KABCore::faq() 2369void KABCore::faq()
2370{ 2370{
2371 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2371 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2372} 2372}
2373 2373
2374#include <libkcal/syncdefines.h> 2374#include <libkcal/syncdefines.h>
2375 2375
2376KABC::Addressee KABCore::getLastSyncAddressee() 2376KABC::Addressee KABCore::getLastSyncAddressee()
2377{ 2377{
2378 Addressee lse; 2378 Addressee lse;
2379 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2379 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2380 2380
2381 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2381 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2382 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2382 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2383 if (lse.isEmpty()) { 2383 if (lse.isEmpty()) {
2384 qDebug("Creating new last-syncAddressee "); 2384 qDebug("Creating new last-syncAddressee ");
2385 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2385 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2386 QString sum = ""; 2386 QString sum = "";
2387 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2387 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2388 sum = "E: "; 2388 sum = "E: ";
2389 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2389 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2390 lse.setRevision( mLastAddressbookSync ); 2390 lse.setRevision( mLastAddressbookSync );
2391 lse.setCategories( i18n("SyncEvent") ); 2391 lse.setCategories( i18n("SyncEvent") );
2392 mAddressBook->insertAddressee( lse ); 2392 mAddressBook->insertAddressee( lse );
2393 } 2393 }
2394 return lse; 2394 return lse;
2395} 2395}
2396int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2396int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2397{ 2397{
2398 2398
2399 //void setZaurusId(int id); 2399 //void setZaurusId(int id);
2400 // int zaurusId() const; 2400 // int zaurusId() const;
2401 // void setZaurusUid(int id); 2401 // void setZaurusUid(int id);
2402 // int zaurusUid() const; 2402 // int zaurusUid() const;
2403 // void setZaurusStat(int id); 2403 // void setZaurusStat(int id);
2404 // int zaurusStat() const; 2404 // int zaurusStat() const;
2405 // 0 equal 2405 // 0 equal
2406 // 1 take local 2406 // 1 take local
2407 // 2 take remote 2407 // 2 take remote
2408 // 3 cancel 2408 // 3 cancel
2409 QDateTime lastSync = mLastAddressbookSync; 2409 QDateTime lastSync = mLastAddressbookSync;
2410 QDateTime localMod = local->revision(); 2410 QDateTime localMod = local->revision();
2411 QDateTime remoteMod = remote->revision(); 2411 QDateTime remoteMod = remote->revision();
2412 2412
2413 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2413 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2414 2414
2415 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2415 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2416 bool remCh, locCh; 2416 bool remCh, locCh;
2417 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2417 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2418 2418
2419 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2419 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2420 locCh = ( localMod > mLastAddressbookSync ); 2420 locCh = ( localMod > mLastAddressbookSync );
2421 if ( !remCh && ! locCh ) { 2421 if ( !remCh && ! locCh ) {
2422 //qDebug("both not changed "); 2422 //qDebug("both not changed ");
2423 lastSync = localMod.addDays(1); 2423 lastSync = localMod.addDays(1);
2424 if ( mode <= SYNC_PREF_ASK ) 2424 if ( mode <= SYNC_PREF_ASK )
2425 return 0; 2425 return 0;
2426 } else { 2426 } else {
2427 if ( locCh ) { 2427 if ( locCh ) {
2428 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2428 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2429 lastSync = localMod.addDays( -1 ); 2429 lastSync = localMod.addDays( -1 );
2430 if ( !remCh ) 2430 if ( !remCh )
2431 remoteMod =( lastSync.addDays( -1 ) ); 2431 remoteMod =( lastSync.addDays( -1 ) );
2432 } else { 2432 } else {
2433 //qDebug(" not loc changed "); 2433 //qDebug(" not loc changed ");
2434 lastSync = localMod.addDays( 1 ); 2434 lastSync = localMod.addDays( 1 );
2435 if ( remCh ) 2435 if ( remCh )
2436 remoteMod =( lastSync.addDays( 1 ) ); 2436 remoteMod =( lastSync.addDays( 1 ) );
2437 2437
2438 } 2438 }
2439 } 2439 }
2440 full = true; 2440 full = true;
2441 if ( mode < SYNC_PREF_ASK ) 2441 if ( mode < SYNC_PREF_ASK )
2442 mode = SYNC_PREF_ASK; 2442 mode = SYNC_PREF_ASK;
2443 } else { 2443 } else {
2444 if ( localMod == remoteMod ) 2444 if ( localMod == remoteMod )
2445 return 0; 2445 return 0;
2446 2446
2447 } 2447 }
2448 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2448 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2449 2449
2450 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2450 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2451 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2451 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2452 //full = true; //debug only 2452 //full = true; //debug only
2453 if ( full ) { 2453 if ( full ) {
2454 bool equ = ( (*local) == (*remote) ); 2454 bool equ = ( (*local) == (*remote) );
2455 if ( equ ) { 2455 if ( equ ) {
2456 //qDebug("equal "); 2456 //qDebug("equal ");
2457 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2457 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2458 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2458 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2459 } 2459 }
2460 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2460 if ( mode < SYNC_PREF_FORCE_LOCAL )
2461 return 0; 2461 return 0;
2462 2462
2463 }//else //debug only 2463 }//else //debug only
2464 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2464 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2465 } 2465 }
2466 int result; 2466 int result;
2467 bool localIsNew; 2467 bool localIsNew;
2468 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2468 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2469 2469
2470 if ( full && mode < SYNC_PREF_NEWEST ) 2470 if ( full && mode < SYNC_PREF_NEWEST )
2471 mode = SYNC_PREF_ASK; 2471 mode = SYNC_PREF_ASK;
2472 2472
2473 switch( mode ) { 2473 switch( mode ) {
2474 case SYNC_PREF_LOCAL: 2474 case SYNC_PREF_LOCAL:
2475 if ( lastSync > remoteMod ) 2475 if ( lastSync > remoteMod )
2476 return 1; 2476 return 1;
2477 if ( lastSync > localMod ) 2477 if ( lastSync > localMod )
2478 return 2; 2478 return 2;
2479 return 1; 2479 return 1;
2480 break; 2480 break;
2481 case SYNC_PREF_REMOTE: 2481 case SYNC_PREF_REMOTE:
2482 if ( lastSync > remoteMod ) 2482 if ( lastSync > remoteMod )
2483 return 1; 2483 return 1;
2484 if ( lastSync > localMod ) 2484 if ( lastSync > localMod )
2485 return 2; 2485 return 2;
2486 return 2; 2486 return 2;
2487 break; 2487 break;
2488 case SYNC_PREF_NEWEST: 2488 case SYNC_PREF_NEWEST:
2489 if ( localMod > remoteMod ) 2489 if ( localMod > remoteMod )
2490 return 1; 2490 return 1;
2491 else 2491 else
2492 return 2; 2492 return 2;
2493 break; 2493 break;
2494 case SYNC_PREF_ASK: 2494 case SYNC_PREF_ASK:
2495 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2495 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2496 if ( lastSync > remoteMod ) 2496 if ( lastSync > remoteMod )
2497 return 1; 2497 return 1;
2498 if ( lastSync > localMod ) 2498 if ( lastSync > localMod )
2499 return 2; 2499 return 2;
2500 localIsNew = localMod >= remoteMod; 2500 localIsNew = localMod >= remoteMod;
2501 //qDebug("conflict! ************************************** "); 2501 //qDebug("conflict! ************************************** ");
2502 { 2502 {
2503 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2503 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2504 result = acd.executeD(localIsNew); 2504 result = acd.executeD(localIsNew);
2505 return result; 2505 return result;
2506 } 2506 }
2507 break; 2507 break;
2508 case SYNC_PREF_FORCE_LOCAL: 2508 case SYNC_PREF_FORCE_LOCAL:
2509 return 1; 2509 return 1;
2510 break; 2510 break;
2511 case SYNC_PREF_FORCE_REMOTE: 2511 case SYNC_PREF_FORCE_REMOTE:
2512 return 2; 2512 return 2;
2513 break; 2513 break;
2514 2514
2515 default: 2515 default:
2516 // SYNC_PREF_TAKE_BOTH not implemented 2516 // SYNC_PREF_TAKE_BOTH not implemented
2517 break; 2517 break;
2518 } 2518 }
2519 return 0; 2519 return 0;
2520} 2520}
2521 2521
2522 2522
2523bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2523bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2524{ 2524{
2525 bool syncOK = true; 2525 bool syncOK = true;
2526 int addedAddressee = 0; 2526 int addedAddressee = 0;
2527 int addedAddresseeR = 0; 2527 int addedAddresseeR = 0;
2528 int deletedAddresseeR = 0; 2528 int deletedAddresseeR = 0;
2529 int deletedAddresseeL = 0; 2529 int deletedAddresseeL = 0;
2530 int changedLocal = 0; 2530 int changedLocal = 0;
2531 int changedRemote = 0; 2531 int changedRemote = 0;
2532 2532
2533 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2533 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2534 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2534 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2535 2535
2536 //QPtrList<Addressee> el = local->rawAddressees(); 2536 //QPtrList<Addressee> el = local->rawAddressees();
2537 Addressee addresseeR; 2537 Addressee addresseeR;
2538 QString uid; 2538 QString uid;
2539 int take; 2539 int take;
2540 Addressee addresseeL; 2540 Addressee addresseeL;
2541 Addressee addresseeRSync; 2541 Addressee addresseeRSync;
2542 Addressee addresseeLSync; 2542 Addressee addresseeLSync;
2543 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2543 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2544 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2544 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2545 bool fullDateRange = false; 2545 bool fullDateRange = false;
2546 local->resetTempSyncStat(); 2546 local->resetTempSyncStat();
2547 mLastAddressbookSync = QDateTime::currentDateTime(); 2547 mLastAddressbookSync = QDateTime::currentDateTime();
2548 if ( syncManager->syncWithDesktop() ) { 2548 if ( syncManager->syncWithDesktop() ) {
2549 // remote->removeSyncInfo( QString());//remove all info 2549 // remote->removeSyncInfo( QString());//remove all info
2550 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2550 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2551 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2551 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2552 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2552 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2553 } else { 2553 } else {
2554 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2554 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2555 } 2555 }
2556 } 2556 }
2557 QDateTime modifiedCalendar = mLastAddressbookSync; 2557 QDateTime modifiedCalendar = mLastAddressbookSync;
2558 addresseeLSync = getLastSyncAddressee(); 2558 addresseeLSync = getLastSyncAddressee();
2559 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2559 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2560 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2560 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2561 if ( !addresseeR.isEmpty() ) { 2561 if ( !addresseeR.isEmpty() ) {
2562 addresseeRSync = addresseeR; 2562 addresseeRSync = addresseeR;
2563 remote->removeAddressee(addresseeR ); 2563 remote->removeAddressee(addresseeR );
2564 2564
2565 } else { 2565 } else {
2566 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2566 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2567 addresseeRSync = addresseeLSync ; 2567 addresseeRSync = addresseeLSync ;
2568 } else { 2568 } else {
2569 qDebug("FULLDATE 1"); 2569 qDebug("FULLDATE 1");
2570 fullDateRange = true; 2570 fullDateRange = true;
2571 Addressee newAdd; 2571 Addressee newAdd;
2572 addresseeRSync = newAdd; 2572 addresseeRSync = newAdd;
2573 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2573 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2574 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2574 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2575 addresseeRSync.setRevision( mLastAddressbookSync ); 2575 addresseeRSync.setRevision( mLastAddressbookSync );
2576 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2576 addresseeRSync.setCategories( i18n("SyncAddressee") );
2577 } 2577 }
2578 } 2578 }
2579 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2579 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2580 qDebug("FULLDATE 2"); 2580 qDebug("FULLDATE 2");
2581 fullDateRange = true; 2581 fullDateRange = true;
2582 } 2582 }
2583 if ( ! fullDateRange ) { 2583 if ( ! fullDateRange ) {
2584 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2584 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2585 2585
2586 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2586 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2587 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2587 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2588 fullDateRange = true; 2588 fullDateRange = true;
2589 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2589 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2590 } 2590 }
2591 } 2591 }
2592 // fullDateRange = true; // debug only! 2592 // fullDateRange = true; // debug only!
2593 if ( fullDateRange ) 2593 if ( fullDateRange )
2594 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2594 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2595 else 2595 else
2596 mLastAddressbookSync = addresseeLSync.revision(); 2596 mLastAddressbookSync = addresseeLSync.revision();
2597 // for resyncing if own file has changed 2597 // for resyncing if own file has changed
2598 // PENDING fixme later when implemented 2598 // PENDING fixme later when implemented
2599#if 0 2599#if 0
2600 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2600 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2601 mLastAddressbookSync = loadedFileVersion; 2601 mLastAddressbookSync = loadedFileVersion;
2602 qDebug("setting mLastAddressbookSync "); 2602 qDebug("setting mLastAddressbookSync ");
2603 } 2603 }
2604#endif 2604#endif
2605 2605
2606 //qDebug("*************************** "); 2606 //qDebug("*************************** ");
2607 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2607 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2608 QStringList er = remote->uidList(); 2608 QStringList er = remote->uidList();
2609 Addressee inR ;//= er.first(); 2609 Addressee inR ;//= er.first();
2610 Addressee inL; 2610 Addressee inL;
2611 2611
2612 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2612 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2613 2613
2614 int modulo = (er.count()/10)+1; 2614 int modulo = (er.count()/10)+1;
2615 int incCounter = 0; 2615 int incCounter = 0;
2616 while ( incCounter < er.count()) { 2616 while ( incCounter < er.count()) {
2617 if (syncManager->isProgressBarCanceled()) 2617 if (syncManager->isProgressBarCanceled())
2618 return false; 2618 return false;
2619 if ( incCounter % modulo == 0 ) 2619 if ( incCounter % modulo == 0 )
2620 syncManager->showProgressBar(incCounter); 2620 syncManager->showProgressBar(incCounter);
2621 2621
2622 uid = er[ incCounter ]; 2622 uid = er[ incCounter ];
2623 bool skipIncidence = false; 2623 bool skipIncidence = false;
2624 if ( uid.left(19) == QString("last-syncAddressee-") ) 2624 if ( uid.left(19) == QString("last-syncAddressee-") )
2625 skipIncidence = true; 2625 skipIncidence = true;
2626 QString idS,OidS; 2626 QString idS,OidS;
2627 qApp->processEvents(); 2627 qApp->processEvents();
2628 if ( !skipIncidence ) { 2628 if ( !skipIncidence ) {
2629 inL = local->findByUid( uid ); 2629 inL = local->findByUid( uid );
2630 inR = remote->findByUid( uid ); 2630 inR = remote->findByUid( uid );
2631 //inL.setResource( 0 ); 2631 //inL.setResource( 0 );
2632 //inR.setResource( 0 ); 2632 //inR.setResource( 0 );
2633 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2633 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2634 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2634 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2635 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2635 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2636 //qDebug("take %d %s ", take, inL.summary().latin1()); 2636 //qDebug("take %d %s ", take, inL.summary().latin1());
2637 if ( take == 3 ) 2637 if ( take == 3 )
2638 return false; 2638 return false;
2639 if ( take == 1 ) {// take local 2639 if ( take == 1 ) {// take local **********************
2640 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2640 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2641 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2641 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2642 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2642 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2643 local->insertAddressee( inL, false ); 2643 local->insertAddressee( inL, false );
2644 idS = inR.externalUID(); 2644 idS = inR.externalUID();
2645 OidS = inR.originalExternalUID(); 2645 OidS = inR.originalExternalUID();
2646 } 2646 }
2647 else 2647 else
2648 idS = inR.IDStr(); 2648 idS = inR.IDStr();
2649 remote->removeAddressee( inR ); 2649 remote->removeAddressee( inR );
2650 inR = inL; 2650 inR = inL;
2651 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2651 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2652 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2652 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2653 inR.setOriginalExternalUID( OidS ); 2653 inR.setOriginalExternalUID( OidS );
2654 inR.setExternalUID( idS ); 2654 inR.setExternalUID( idS );
2655 if ( syncManager->syncWithDesktop() ) 2655 if ( syncManager->syncWithDesktop() )
2656 inR.setIDStr("changed" ); 2656 inR.setIDStr("changed" );
2657 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2657 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2658 } else { 2658 } else {
2659 inR.setIDStr( idS ); 2659 inR.setIDStr( idS );
2660 } 2660 }
2661 inR.setResource( 0 ); 2661 inR.setResource( 0 );
2662 remote->insertAddressee( inR , false); 2662 remote->insertAddressee( inR , false);
2663 ++changedRemote; 2663 ++changedRemote;
2664 } else { // take == 2 take remote 2664 } else { // take == 2 take remote **********************
2665 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2665 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2666 if ( inR.revision().date().year() < 2004 ) 2666 if ( inR.revision().date().year() < 2004 )
2667 inR.setRevision( modifiedCalendar ); 2667 inR.setRevision( modifiedCalendar );
2668 } 2668 }
2669 idS = inL.IDStr(); 2669 idS = inL.IDStr();
2670 local->removeAddressee( inL ); 2670 local->removeAddressee( inL );
2671 inL = inR; 2671 inL = inR;
2672 inL.setIDStr( idS ); 2672 inL.setIDStr( idS );
2673 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2673 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2674 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2674 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2675 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2675 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2676 } 2676 }
2677 inL.setResource( 0 ); 2677 inL.setResource( 0 );
2678 local->insertAddressee( inL , false ); 2678 local->insertAddressee( inL , false );
2679 ++changedLocal; 2679 ++changedLocal;
2680 } 2680 }
2681 } 2681 }
2682 } 2682 }
2683 } else { // no conflict 2683 } else { // no conflict ********** add or delete remote
2684 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2684 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2685 QString des = addresseeLSync.note(); 2685 QString des = addresseeLSync.note();
2686 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2686 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2687 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2687 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2688 remote->insertAddressee( inR, false ); 2688 remote->insertAddressee( inR, false );
2689 ++deletedAddresseeR; 2689 ++deletedAddresseeR;
2690 } else { 2690 } else {
2691 inR.setRevision( modifiedCalendar ); 2691 inR.setRevision( modifiedCalendar );
2692 remote->insertAddressee( inR, false ); 2692 remote->insertAddressee( inR, false );
2693 inL = inR; 2693 inL = inR;
2694 inL.setIDStr( ":" );
2695 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2696 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2694 inL.setResource( 0 ); 2697 inL.setResource( 0 );
2695 local->insertAddressee( inL , false); 2698 local->insertAddressee( inL , false);
2696 ++addedAddressee; 2699 ++addedAddressee;
2697 } 2700 }
2698 } else { 2701 } else {
2699 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2702 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2700 inR.setRevision( modifiedCalendar ); 2703 inR.setRevision( modifiedCalendar );
2701 remote->insertAddressee( inR, false ); 2704 remote->insertAddressee( inR, false );
2702 inR.setResource( 0 ); 2705 inR.setResource( 0 );
2703 local->insertAddressee( inR, false ); 2706 local->insertAddressee( inR, false );
2704 ++addedAddressee; 2707 ++addedAddressee;
2705 } else { 2708 } else {
2706 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2709 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2707 remote->removeAddressee( inR ); 2710 remote->removeAddressee( inR );
2708 ++deletedAddresseeR; 2711 ++deletedAddresseeR;
2709 } 2712 }
2710 } 2713 }
2711 } 2714 }
2712 } 2715 }
2713 ++incCounter; 2716 ++incCounter;
2714 } 2717 }
2715 er.clear(); 2718 er.clear();
2716 QStringList el = local->uidList(); 2719 QStringList el = local->uidList();
2717 modulo = (el.count()/10)+1; 2720 modulo = (el.count()/10)+1;
2718 2721
2719 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2722 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2720 incCounter = 0; 2723 incCounter = 0;
2721 while ( incCounter < el.count()) { 2724 while ( incCounter < el.count()) {
2722 qApp->processEvents(); 2725 qApp->processEvents();
2723 if (syncManager->isProgressBarCanceled()) 2726 if (syncManager->isProgressBarCanceled())
2724 return false; 2727 return false;
2725 if ( incCounter % modulo == 0 ) 2728 if ( incCounter % modulo == 0 )
2726 syncManager->showProgressBar(incCounter); 2729 syncManager->showProgressBar(incCounter);
2727 uid = el[ incCounter ]; 2730 uid = el[ incCounter ];
2728 bool skipIncidence = false; 2731 bool skipIncidence = false;
2729 if ( uid.left(19) == QString("last-syncAddressee-") ) 2732 if ( uid.left(19) == QString("last-syncAddressee-") )
2730 skipIncidence = true; 2733 skipIncidence = true;
2731 if ( !skipIncidence ) { 2734 if ( !skipIncidence ) {
2732 inL = local->findByUid( uid ); 2735 inL = local->findByUid( uid );
2733 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2736 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2734 inR = remote->findByUid( uid ); 2737 inR = remote->findByUid( uid );
2735 if ( inR.isEmpty() ) { 2738 if ( inR.isEmpty() ) { / no conflict ********** add or delete local
2736 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2739 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2737 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2740 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2738 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2741 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2739 local->removeAddressee( inL ); 2742 local->removeAddressee( inL );
2740 ++deletedAddresseeL; 2743 ++deletedAddresseeL;
2741 } else { 2744 } else {
2742 if ( ! syncManager->mWriteBackExistingOnly ) { 2745 if ( ! syncManager->mWriteBackExistingOnly ) {
2743 inL.removeID(mCurrentSyncDevice ); 2746 inL.removeID(mCurrentSyncDevice );
2744 ++addedAddresseeR; 2747 ++addedAddresseeR;
2745 inL.setRevision( modifiedCalendar ); 2748 inL.setRevision( modifiedCalendar );
2746 local->insertAddressee( inL, false ); 2749 local->insertAddressee( inL, false );
2747 inR = inL; 2750 inR = inL;
2748 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2751 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2749 inR.setResource( 0 ); 2752 inR.setResource( 0 );
2750 remote->insertAddressee( inR, false ); 2753 remote->insertAddressee( inR, false );
2751 } 2754 }
2752 } 2755 }
2753 } else { 2756 } else {
2754 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2757 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2755 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2758 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2756 local->removeAddressee( inL ); 2759 local->removeAddressee( inL );
2757 ++deletedAddresseeL; 2760 ++deletedAddresseeL;
2758 } else { 2761 } else {
2759 if ( ! syncManager->mWriteBackExistingOnly ) { 2762 if ( ! syncManager->mWriteBackExistingOnly ) {
2760 ++addedAddresseeR; 2763 ++addedAddresseeR;
2761 inL.setRevision( modifiedCalendar ); 2764 inL.setRevision( modifiedCalendar );
2762 local->insertAddressee( inL, false ); 2765 local->insertAddressee( inL, false );
2763 inR = inL; 2766 inR = inL;
2767 inR.setIDStr( ":" );
2764 inR.setResource( 0 ); 2768 inR.setResource( 0 );
2765 remote->insertAddressee( inR, false ); 2769 remote->insertAddressee( inR, false );
2766 } 2770 }
2767 } 2771 }
2768 } 2772 }
2769 } 2773 }
2770 } 2774 }
2771 } 2775 }
2772 ++incCounter; 2776 ++incCounter;
2773 } 2777 }
2774 el.clear(); 2778 el.clear();
2775 syncManager->hideProgressBar(); 2779 syncManager->hideProgressBar();
2776 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2780 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2777 // get rid of micro seconds 2781 // get rid of micro seconds
2778 QTime t = mLastAddressbookSync.time(); 2782 QTime t = mLastAddressbookSync.time();
2779 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2783 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2780 addresseeLSync.setRevision( mLastAddressbookSync ); 2784 addresseeLSync.setRevision( mLastAddressbookSync );
2781 addresseeRSync.setRevision( mLastAddressbookSync ); 2785 addresseeRSync.setRevision( mLastAddressbookSync );
2782 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2786 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2783 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2787 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2784 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2788 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2785 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2789 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2786 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2790 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2787 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2791 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2788 addresseeRSync.setNote( "" ) ; 2792 addresseeRSync.setNote( "" ) ;
2789 addresseeLSync.setNote( "" ); 2793 addresseeLSync.setNote( "" );
2790 2794
2791 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2795 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2792 remote->insertAddressee( addresseeRSync, false ); 2796 remote->insertAddressee( addresseeRSync, false );
2793 local->insertAddressee( addresseeLSync, false ); 2797 local->insertAddressee( addresseeLSync, false );
2794 QString mes; 2798 QString mes;
2795 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2799 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2796 qDebug( mes ); 2800 qDebug( mes );
2797 if ( syncManager->mShowSyncSummary ) { 2801 if ( syncManager->mShowSyncSummary ) {
2798 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 2802 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
2799 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 2803 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
2800 qDebug("cancelled "); 2804 qDebug("cancelled ");
2801 return false; 2805 return false;
2802 } 2806 }
2803 } 2807 }
2804 return syncOK; 2808 return syncOK;
2805} 2809}
2806 2810
2807 2811
2808//this is a overwritten callbackmethods from the syncinterface 2812//this is a overwritten callbackmethods from the syncinterface
2809bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2813bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2810{ 2814{
2811 2815
2812 //pending prepare addresseeview for output 2816 //pending prepare addresseeview for output
2813 //pending detect, if remote file has REV field. if not switch to external sync 2817 //pending detect, if remote file has REV field. if not switch to external sync
2814 mGlobalSyncMode = SYNC_MODE_NORMAL; 2818 mGlobalSyncMode = SYNC_MODE_NORMAL;
2815 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2819 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2816 2820
2817 AddressBook abLocal(filename,"syncContact"); 2821 AddressBook abLocal(filename,"syncContact");
2818 bool syncOK = false; 2822 bool syncOK = false;
2819 if ( abLocal.load() ) { 2823 if ( abLocal.load() ) {
2820 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2824 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2821 bool external = false; 2825 bool external = false;
2822 bool isXML = false; 2826 bool isXML = false;
2823 if ( filename.right(4) == ".xml") { 2827 if ( filename.right(4) == ".xml") {
2824 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2828 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2825 isXML = true; 2829 isXML = true;
2826 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2830 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2827 } else { 2831 } else {
2828 external = !manager->mIsKapiFile; 2832 external = !manager->mIsKapiFile;
2829 if ( external ) { 2833 if ( external ) {
2830 qDebug("Setting vcf mode to external "); 2834 qDebug("Setting vcf mode to external ");
2831 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2835 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2832 AddressBook::Iterator it; 2836 AddressBook::Iterator it;
2833 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2837 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2834 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2838 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2835 (*it).computeCsum( mCurrentSyncDevice ); 2839 (*it).computeCsum( mCurrentSyncDevice );
2836 } 2840 }
2837 } 2841 }
2838 } 2842 }
2839 //AddressBook::Iterator it; 2843 //AddressBook::Iterator it;
2840 //QStringList vcards; 2844 //QStringList vcards;
2841 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2845 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2842 // qDebug("Name %s ", (*it).familyName().latin1()); 2846 // qDebug("Name %s ", (*it).familyName().latin1());
2843 //} 2847 //}
2844 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2848 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2845 if ( syncOK ) { 2849 if ( syncOK ) {
2846 if ( syncManager->mWriteBackFile ) 2850 if ( syncManager->mWriteBackFile )
2847 { 2851 {
2848 if ( external ) 2852 if ( external )
2849 abLocal.removeSyncAddressees( !isXML); 2853 abLocal.removeSyncAddressees( !isXML);
2850 qDebug("Saving remote AB "); 2854 qDebug("Saving remote AB ");
2851 if ( ! abLocal.saveAB()) 2855 if ( ! abLocal.saveAB())
2852 qDebug("Error writing back AB to file "); 2856 qDebug("Error writing back AB to file ");
2853 if ( external ) { 2857 if ( external ) {
2854 // afterwrite processing 2858 // afterwrite processing
2855 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 2859 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
2856 } 2860 }
2857 } 2861 }
2858 } 2862 }
2859 setModified(); 2863 setModified();
2860 2864
2861 } 2865 }
2862 if ( syncOK ) 2866 if ( syncOK )
2863 mViewManager->refreshView(); 2867 mViewManager->refreshView();
2864 return syncOK; 2868 return syncOK;
2865 2869
2866} 2870}
2867void KABCore::removeSyncInfo( QString syncProfile) 2871void KABCore::removeSyncInfo( QString syncProfile)
2868{ 2872{
2869 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 2873 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
2870 mAddressBook->removeSyncInfo( syncProfile ); 2874 mAddressBook->removeSyncInfo( syncProfile );
2871 setModified(); 2875 setModified();
2872} 2876}
2873 2877
2874 2878
2875//this is a overwritten callbackmethods from the syncinterface 2879//this is a overwritten callbackmethods from the syncinterface
2876bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2880bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2877{ 2881{
2878 if ( resource == "phone" ) 2882 if ( resource == "phone" )
2879 return syncPhone(); 2883 return syncPhone();
2880 disableBR( true ); 2884 disableBR( true );
2881 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2885 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2882 2886
2883 AddressBook abLocal( resource,"syncContact"); 2887 AddressBook abLocal( resource,"syncContact");
2884 bool syncOK = false; 2888 bool syncOK = false;
2885 if ( abLocal.load() ) { 2889 if ( abLocal.load() ) {
2886 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2890 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2887 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2891 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2888 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 2892 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
2889 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2893 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2890 if ( syncOK ) { 2894 if ( syncOK ) {
2891 if ( syncManager->mWriteBackFile ) { 2895 if ( syncManager->mWriteBackFile ) {
2892 abLocal.removeSyncAddressees( false ); 2896 abLocal.removeSyncAddressees( false );
2893 abLocal.saveAB(); 2897 abLocal.saveAB();
2894 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 2898 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
2895 } 2899 }
2896 } else 2900 } else
2897 message( i18n("Sync cancelled or failed.") ); 2901 message( i18n("Sync cancelled or failed.") );
2898 setModified(); 2902 setModified();
2899 } 2903 }
2900 if ( syncOK ) 2904 if ( syncOK )
2901 mViewManager->refreshView(); 2905 mViewManager->refreshView();
2902 disableBR( false ); 2906 disableBR( false );
2903 return syncOK; 2907 return syncOK;
2904 2908
2905} 2909}
2906void KABCore::message( QString m ) 2910void KABCore::message( QString m )
2907{ 2911{
2908 topLevelWidget()->setCaption( m ); 2912 topLevelWidget()->setCaption( m );
2909 mMessageTimer->start( 15000, true ); 2913 mMessageTimer->start( 15000, true );
2910} 2914}
2911bool KABCore::syncPhone() 2915bool KABCore::syncPhone()
2912{ 2916{
2913 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2917 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2914 QString fileName = getPhoneFile(); 2918 QString fileName = getPhoneFile();
2915 if ( !PhoneAccess::readFromPhone( fileName) ) { 2919 if ( !PhoneAccess::readFromPhone( fileName) ) {
2916 message(i18n("Phone access failed!")); 2920 message(i18n("Phone access failed!"));
2917 return false; 2921 return false;
2918 } 2922 }
2919 AddressBook abLocal( fileName,"syncContact"); 2923 AddressBook abLocal( fileName,"syncContact");
2920 bool syncOK = false; 2924 bool syncOK = false;
2921 { 2925 {
2922 abLocal.importFromFile( fileName ); 2926 abLocal.importFromFile( fileName );
2923 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2927 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2924 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2928 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2925 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2929 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2926 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2930 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2927 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2931 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2928 if ( syncOK ) { 2932 if ( syncOK ) {
2929 if ( syncManager->mWriteBackFile ) { 2933 if ( syncManager->mWriteBackFile ) {
2930 abLocal.removeSyncAddressees( true ); 2934 abLocal.removeSyncAddressees( true );
2931 abLocal.saveABphone( fileName ); 2935 abLocal.saveABphone( fileName );
2932 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 2936 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2933 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2937 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2934 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 2938 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
2935 } 2939 }
2936 } 2940 }
2937 setModified(); 2941 setModified();
2938 } 2942 }
2939 if ( syncOK ) 2943 if ( syncOK )
2940 mViewManager->refreshView(); 2944 mViewManager->refreshView();
2941 return syncOK; 2945 return syncOK;
2942} 2946}
2943void KABCore::getFile( bool success ) 2947void KABCore::getFile( bool success )
2944{ 2948{
2945 if ( ! success ) { 2949 if ( ! success ) {
2946 message( i18n("Error receiving file. Nothing changed!") ); 2950 message( i18n("Error receiving file. Nothing changed!") );
2947 return; 2951 return;
2948 } 2952 }
2949 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 2953 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
2950 if ( count ) 2954 if ( count )
2951 setModified( true ); 2955 setModified( true );
2952 message( i18n("Pi-Sync successful!") ); 2956 message( i18n("Pi-Sync successful!") );
2953 mViewManager->refreshView(); 2957 mViewManager->refreshView();
2954} 2958}
2955void KABCore::syncFileRequest() 2959void KABCore::syncFileRequest()
2956{ 2960{
2957 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 2961 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
2958 syncManager->slotSyncMenu( 999 ); 2962 syncManager->slotSyncMenu( 999 );
2959 } 2963 }
2960 mAddressBook->export2File( sentSyncFile() ); 2964 mAddressBook->export2File( sentSyncFile() );
2961} 2965}
2962QString KABCore::sentSyncFile() 2966QString KABCore::sentSyncFile()
2963{ 2967{
2964#ifdef DESKTOP_VERSION 2968#ifdef DESKTOP_VERSION
2965 return locateLocal( "tmp", "copysyncab.vcf" ); 2969 return locateLocal( "tmp", "copysyncab.vcf" );
2966#else 2970#else
2967 return QString( "/tmp/copysyncab.vcf" ); 2971 return QString( "/tmp/copysyncab.vcf" );
2968#endif 2972#endif
2969} 2973}
2970 2974
2971void KABCore::setCaptionBack() 2975void KABCore::setCaptionBack()
2972{ 2976{
2973 mMessageTimer->stop(); 2977 mMessageTimer->stop();
2974 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2978 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2975} 2979}
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 4667918..4e29d6f 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3155 +1,3157 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "statusdialog.h" 110#include "statusdialog.h"
111#include "kdatenavigator.h" 111#include "kdatenavigator.h"
112#include "kotodoview.h" 112#include "kotodoview.h"
113#include "datenavigator.h" 113#include "datenavigator.h"
114#include "resourceview.h" 114#include "resourceview.h"
115#include "navigatorbar.h" 115#include "navigatorbar.h"
116#include "searchdialog.h" 116#include "searchdialog.h"
117#include "mainwindow.h" 117#include "mainwindow.h"
118 118
119#include "calendarview.h" 119#include "calendarview.h"
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121#include <qtopia/alarmserver.h> 121#include <qtopia/alarmserver.h>
122#endif 122#endif
123#ifndef _WIN32_ 123#ifndef _WIN32_
124#include <stdlib.h> 124#include <stdlib.h>
125#include <stdio.h> 125#include <stdio.h>
126#include <unistd.h> 126#include <unistd.h>
127#else 127#else
128#include <qprocess.h> 128#include <qprocess.h>
129#endif 129#endif
130 130
131#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
132#include <kabc/stdaddressbook.h> 132#include <kabc/stdaddressbook.h>
133#endif 133#endif
134using namespace KOrg; 134using namespace KOrg;
135using namespace KCal; 135using namespace KCal;
136extern int globalFlagBlockAgenda; 136extern int globalFlagBlockAgenda;
137extern int globalFlagBlockStartup; 137extern int globalFlagBlockStartup;
138 138
139 139
140 140
141class KOBeamPrefs : public QDialog 141class KOBeamPrefs : public QDialog
142{ 142{
143 public: 143 public:
144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
145 QDialog( parent, name, true ) 145 QDialog( parent, name, true )
146 { 146 {
147 setCaption( i18n("Beam Options") ); 147 setCaption( i18n("Beam Options") );
148 QVBoxLayout* lay = new QVBoxLayout( this ); 148 QVBoxLayout* lay = new QVBoxLayout( this );
149 lay->setSpacing( 3 ); 149 lay->setSpacing( 3 );
150 lay->setMargin( 3 ); 150 lay->setMargin( 3 );
151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
152 lay->addWidget( format ); 152 lay->addWidget( format );
153 format->setExclusive ( true ) ; 153 format->setExclusive ( true ) ;
154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
155 lay->addWidget( time ); time->setExclusive ( true ) ; 155 lay->addWidget( time ); time->setExclusive ( true ) ;
156 vcal = new QRadioButton(" vCalendar ", format ); 156 vcal = new QRadioButton(" vCalendar ", format );
157 ical = new QRadioButton(" iCalendar ", format ); 157 ical = new QRadioButton(" iCalendar ", format );
158 vcal->setChecked( true ); 158 vcal->setChecked( true );
159 tz = new QRadioButton(i18n(" With timezone "), time ); 159 tz = new QRadioButton(i18n(" With timezone "), time );
160 local = new QRadioButton(i18n(" Local time "), time ); 160 local = new QRadioButton(i18n(" Local time "), time );
161 tz->setChecked( true ); 161 tz->setChecked( true );
162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
163 lay->addWidget( ok ); 163 lay->addWidget( ok );
164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
165 lay->addWidget( cancel ); 165 lay->addWidget( cancel );
166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
168 resize( 200, 200 ); 168 resize( 200, 200 );
169 } 169 }
170 170
171 bool beamVcal() { return vcal->isChecked(); } 171 bool beamVcal() { return vcal->isChecked(); }
172 bool beamLocal() { return local->isChecked(); } 172 bool beamLocal() { return local->isChecked(); }
173private: 173private:
174 QRadioButton* vcal, *ical, *local, *tz; 174 QRadioButton* vcal, *ical, *local, *tz;
175}; 175};
176class KOCatPrefs : public QDialog 176class KOCatPrefs : public QDialog
177{ 177{
178 public: 178 public:
179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
180 QDialog( parent, name, true ) 180 QDialog( parent, name, true )
181 { 181 {
182 setCaption( i18n("Manage new Categories") ); 182 setCaption( i18n("Manage new Categories") );
183 QVBoxLayout* lay = new QVBoxLayout( this ); 183 QVBoxLayout* lay = new QVBoxLayout( this );
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
187 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::CalendarView( Calendar *calendar,
224 QWidget *parent, const char *name ) 224 QWidget *parent, const char *name )
225 : CalendarViewBase( parent, name ), 225 : CalendarViewBase( parent, name ),
226 mCalendar( calendar ), 226 mCalendar( calendar ),
227 mResourceManager( 0 ) 227 mResourceManager( 0 )
228{ 228{
229 229
230 mEventEditor = 0; 230 mEventEditor = 0;
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 beamDialog = new KOBeamPrefs(); 236 beamDialog = new KOBeamPrefs();
237 mDatePickerMode = 0; 237 mDatePickerMode = 0;
238 mCurrentSyncDevice = ""; 238 mCurrentSyncDevice = "";
239 writeLocale(); 239 writeLocale();
240 mViewManager = new KOViewManager( this ); 240 mViewManager = new KOViewManager( this );
241 mDialogManager = new KODialogManager( this ); 241 mDialogManager = new KODialogManager( this );
242 mEventViewerDialog = 0; 242 mEventViewerDialog = 0;
243 mModified = false; 243 mModified = false;
244 mReadOnly = false; 244 mReadOnly = false;
245 mSelectedIncidence = 0; 245 mSelectedIncidence = 0;
246 mCalPrinter = 0; 246 mCalPrinter = 0;
247 mFilters.setAutoDelete(true); 247 mFilters.setAutoDelete(true);
248 248
249 mCalendar->registerObserver( this ); 249 mCalendar->registerObserver( this );
250 // TODO: Make sure that view is updated, when calendar is changed. 250 // TODO: Make sure that view is updated, when calendar is changed.
251 251
252 mStorage = new FileStorage( mCalendar ); 252 mStorage = new FileStorage( mCalendar );
253 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 253 mNavigator = new DateNavigator( this, "datevav", mViewManager );
254 254
255 QBoxLayout *topLayout = (QBoxLayout*)layout(); 255 QBoxLayout *topLayout = (QBoxLayout*)layout();
256#ifndef KORG_NOSPLITTER 256#ifndef KORG_NOSPLITTER
257 // create the main layout frames. 257 // create the main layout frames.
258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
259 topLayout->addWidget(mPanner); 259 topLayout->addWidget(mPanner);
260 260
261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
262 "CalendarView::LeftFrame"); 262 "CalendarView::LeftFrame");
263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
264 264
265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
266 "CalendarView::DateNavigator", QDate::currentDate() ); 266 "CalendarView::DateNavigator", QDate::currentDate() );
267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
269 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 269 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
270 270
271#ifdef KORG_NORESOURCEVIEW 271#ifdef KORG_NORESOURCEVIEW
272 mResourceView = 0; 272 mResourceView = 0;
273#else 273#else
274 if ( mResourceManager ) { 274 if ( mResourceManager ) {
275 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 275 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
276 mResourceView->updateView(); 276 mResourceView->updateView();
277 connect( mResourceView, SIGNAL( resourcesChanged() ), 277 connect( mResourceView, SIGNAL( resourcesChanged() ),
278 SLOT( updateView() ) ); 278 SLOT( updateView() ) );
279 } else { 279 } else {
280 mResourceView = 0; 280 mResourceView = 0;
281 } 281 }
282#endif 282#endif
283 QWidget *rightBox = new QWidget( mPanner ); 283 QWidget *rightBox = new QWidget( mPanner );
284 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 284 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
285 285
286 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 286 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
287 rightLayout->addWidget( mNavigatorBar ); 287 rightLayout->addWidget( mNavigatorBar );
288 288
289 mRightFrame = new QWidgetStack( rightBox ); 289 mRightFrame = new QWidgetStack( rightBox );
290 rightLayout->addWidget( mRightFrame, 1 ); 290 rightLayout->addWidget( mRightFrame, 1 );
291 291
292 mLeftFrame = mLeftSplitter; 292 mLeftFrame = mLeftSplitter;
293#else 293#else
294 QWidget *mainBox = new QWidget( this ); 294 QWidget *mainBox = new QWidget( this );
295 QWidget *leftFrame = new QWidget( mainBox ); 295 QWidget *leftFrame = new QWidget( mainBox );
296 296
297 QBoxLayout * mainBoxLayout; 297 QBoxLayout * mainBoxLayout;
298 QBoxLayout * leftFrameLayout; 298 QBoxLayout * leftFrameLayout;
299 if ( KOPrefs::instance()->mVerticalScreen ) { 299 if ( KOPrefs::instance()->mVerticalScreen ) {
300 mainBoxLayout = new QVBoxLayout(mainBox); 300 mainBoxLayout = new QVBoxLayout(mainBox);
301 leftFrameLayout = new QHBoxLayout(leftFrame ); 301 leftFrameLayout = new QHBoxLayout(leftFrame );
302 } else { 302 } else {
303 mainBoxLayout = new QHBoxLayout(mainBox); 303 mainBoxLayout = new QHBoxLayout(mainBox);
304 leftFrameLayout = new QVBoxLayout(leftFrame ); 304 leftFrameLayout = new QVBoxLayout(leftFrame );
305 } 305 }
306 topLayout->addWidget( mainBox ); 306 topLayout->addWidget( mainBox );
307 mainBoxLayout->addWidget (leftFrame); 307 mainBoxLayout->addWidget (leftFrame);
308 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 308 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
309 "CalendarView::DateNavigator", QDate::currentDate()); 309 "CalendarView::DateNavigator", QDate::currentDate());
310 // mDateNavigator->blockSignals( true ); 310 // mDateNavigator->blockSignals( true );
311 leftFrameLayout->addWidget( mDateNavigator ); 311 leftFrameLayout->addWidget( mDateNavigator );
312 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 312 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
313 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 313 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
314 314
315 if ( QApplication::desktop()->width() < 480 ) { 315 if ( QApplication::desktop()->width() < 480 ) {
316 leftFrameLayout->addWidget(mFilterView); 316 leftFrameLayout->addWidget(mFilterView);
317 leftFrameLayout->addWidget(mTodoList, 2 ); 317 leftFrameLayout->addWidget(mTodoList, 2 );
318 318
319 } else { 319 } else {
320 leftFrameLayout->addWidget(mTodoList,2 ); 320 leftFrameLayout->addWidget(mTodoList,2 );
321 leftFrameLayout->addWidget(mFilterView ); 321 leftFrameLayout->addWidget(mFilterView );
322 } 322 }
323 mFilterView->hide(); 323 mFilterView->hide();
324 QWidget *rightBox = new QWidget( mainBox ); 324 QWidget *rightBox = new QWidget( mainBox );
325 mainBoxLayout->addWidget ( rightBox, 10 ); 325 mainBoxLayout->addWidget ( rightBox, 10 );
326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
327 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 327 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
328 mRightFrame = new QWidgetStack( rightBox ); 328 mRightFrame = new QWidgetStack( rightBox );
329 rightLayout->addWidget( mNavigatorBar ); 329 rightLayout->addWidget( mNavigatorBar );
330 rightLayout->addWidget( mRightFrame, 10 ); 330 rightLayout->addWidget( mRightFrame, 10 );
331 331
332 mLeftFrame = leftFrame; 332 mLeftFrame = leftFrame;
333 if ( KOPrefs::instance()->mVerticalScreen ) { 333 if ( KOPrefs::instance()->mVerticalScreen ) {
334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
336 } else { 336 } else {
337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
339 } 339 }
340 340
341 //qDebug("Calendarview Size %d %d ", width(), height()); 341 //qDebug("Calendarview Size %d %d ", width(), height());
342#endif 342#endif
343 343
344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
345 SLOT( showDates( const KCal::DateList & ) ) ); 345 SLOT( showDates( const KCal::DateList & ) ) );
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
348 348
349 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 349 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
350 mNavigator, SLOT( selectPreviousYear() ) ); 350 mNavigator, SLOT( selectPreviousYear() ) );
351 connect( mNavigatorBar, SIGNAL( goNextYear() ), 351 connect( mNavigatorBar, SIGNAL( goNextYear() ),
352 mNavigator, SLOT( selectNextYear() ) ); 352 mNavigator, SLOT( selectNextYear() ) );
353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
354 mNavigator, SLOT( selectPreviousMonth() ) ); 354 mNavigator, SLOT( selectPreviousMonth() ) );
355 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 355 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
356 mNavigator, SLOT( selectNextMonth() ) ); 356 mNavigator, SLOT( selectNextMonth() ) );
357 357
358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
360 360
361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
362 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 362 mNavigator, SLOT( selectWeek( const QDate & ) ) );
363 363
364 connect( mDateNavigator, SIGNAL( goPrevYear() ), 364 connect( mDateNavigator, SIGNAL( goPrevYear() ),
365 mNavigator, SLOT( selectPreviousYear() ) ); 365 mNavigator, SLOT( selectPreviousYear() ) );
366 connect( mDateNavigator, SIGNAL( goNextYear() ), 366 connect( mDateNavigator, SIGNAL( goNextYear() ),
367 mNavigator, SLOT( selectNextYear() ) ); 367 mNavigator, SLOT( selectNextYear() ) );
368 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 368 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
369 mNavigator, SLOT( selectPreviousMonth() ) ); 369 mNavigator, SLOT( selectPreviousMonth() ) );
370 connect( mDateNavigator, SIGNAL( goNextMonth() ), 370 connect( mDateNavigator, SIGNAL( goNextMonth() ),
371 mNavigator, SLOT( selectNextMonth() ) ); 371 mNavigator, SLOT( selectNextMonth() ) );
372 372
373 connect( mDateNavigator, SIGNAL( goPrevious() ), 373 connect( mDateNavigator, SIGNAL( goPrevious() ),
374 mNavigator, SLOT( selectPrevious() ) ); 374 mNavigator, SLOT( selectPrevious() ) );
375 connect( mDateNavigator, SIGNAL( goNext() ), 375 connect( mDateNavigator, SIGNAL( goNext() ),
376 mNavigator, SLOT( selectNext() ) ); 376 mNavigator, SLOT( selectNext() ) );
377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
378 mNavigator, SLOT( slotMonthSelect( int ) ) ); 378 mNavigator, SLOT( slotMonthSelect( int ) ) );
379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
380 mNavigator, SLOT( slotMonthSelect( int ) ) ); 380 mNavigator, SLOT( slotMonthSelect( int ) ) );
381 381
382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
384 384
385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
386 SLOT( eventAdded( Event *) ) ); 386 SLOT( eventAdded( Event *) ) );
387 387
388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
389 389
390 connect( this, SIGNAL( configChanged() ), 390 connect( this, SIGNAL( configChanged() ),
391 mDateNavigator, SLOT( updateConfig() ) ); 391 mDateNavigator, SLOT( updateConfig() ) );
392 392
393 connect( mTodoList, SIGNAL( newTodoSignal() ), 393 connect( mTodoList, SIGNAL( newTodoSignal() ),
394 SLOT( newTodo() ) ); 394 SLOT( newTodo() ) );
395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
396 SLOT( newSubTodo( Todo * ) ) ); 396 SLOT( newSubTodo( Todo * ) ) );
397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
398 SLOT( editTodo( Todo * ) ) ); 398 SLOT( editTodo( Todo * ) ) );
399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
400 SLOT( showTodo( Todo *) ) ); 400 SLOT( showTodo( Todo *) ) );
401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
402 SLOT( deleteTodo( Todo *) ) ); 402 SLOT( deleteTodo( Todo *) ) );
403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
405 SLOT( purgeCompleted() ) ); 405 SLOT( purgeCompleted() ) );
406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
407 SIGNAL( todoModified( Todo *, int ) ) ); 407 SIGNAL( todoModified( Todo *, int ) ) );
408 408
409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
410 this, SLOT ( cloneIncidence( Incidence * ) ) ); 410 this, SLOT ( cloneIncidence( Incidence * ) ) );
411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
412 this, SLOT (cancelIncidence( Incidence * ) ) ); 412 this, SLOT (cancelIncidence( Incidence * ) ) );
413 413
414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
415 this, SLOT ( moveIncidence( Incidence * ) ) ); 415 this, SLOT ( moveIncidence( Incidence * ) ) );
416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
417 this, SLOT ( beamIncidence( Incidence * ) ) ); 417 this, SLOT ( beamIncidence( Incidence * ) ) );
418 418
419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
420 this, SLOT ( todo_unsub( Todo * ) ) ); 420 this, SLOT ( todo_unsub( Todo * ) ) );
421 421
422 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 422 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
423 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 423 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
424 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 424 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
425 SLOT( updateTodo( Todo *, int ) ) ); 425 SLOT( updateTodo( Todo *, int ) ) );
426 connect( this, SIGNAL( todoModified( Todo *, int )), this, 426 connect( this, SIGNAL( todoModified( Todo *, int )), this,
427 SLOT( changeTodoDisplay( Todo *, int ) ) ); 427 SLOT( changeTodoDisplay( Todo *, int ) ) );
428 428
429 429
430 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 430 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
431 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 431 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
432 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 432 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
433 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 433 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
434 434
435 435
436 436
437 437
438 438
439 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 439 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
440 SLOT(checkClipboard())); 440 SLOT(checkClipboard()));
441 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 441 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
442 SLOT( processTodoListSelection( Incidence * ) ) ); 442 SLOT( processTodoListSelection( Incidence * ) ) );
443 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 443 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
444 444
445 // kdDebug() << "CalendarView::CalendarView() done" << endl; 445 // kdDebug() << "CalendarView::CalendarView() done" << endl;
446 446
447 mDateFrame = new QVBox(0,0,WType_Popup); 447 mDateFrame = new QVBox(0,0,WType_Popup);
448 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 448 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
449 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 449 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
450 mDateFrame->setLineWidth(3); 450 mDateFrame->setLineWidth(3);
451 mDateFrame->hide(); 451 mDateFrame->hide();
452 mDateFrame->setCaption( i18n( "Pick a date to display")); 452 mDateFrame->setCaption( i18n( "Pick a date to display"));
453 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 453 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
454 454
455 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 455 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
456 456
457 mEventEditor = mDialogManager->getEventEditor(); 457 mEventEditor = mDialogManager->getEventEditor();
458 mTodoEditor = mDialogManager->getTodoEditor(); 458 mTodoEditor = mDialogManager->getTodoEditor();
459 459
460 mFlagEditDescription = false; 460 mFlagEditDescription = false;
461 461
462 mSuspendTimer = new QTimer( this ); 462 mSuspendTimer = new QTimer( this );
463 mAlarmTimer = new QTimer( this ); 463 mAlarmTimer = new QTimer( this );
464 mRecheckAlarmTimer = new QTimer( this ); 464 mRecheckAlarmTimer = new QTimer( this );
465 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 465 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
466 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 466 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
467 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 467 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
468 mAlarmDialog = new AlarmDialog( this ); 468 mAlarmDialog = new AlarmDialog( this );
469 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 469 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
470 mAlarmDialog->setServerNotification( false ); 470 mAlarmDialog->setServerNotification( false );
471 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 471 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
472 472
473 473
474#ifndef DESKTOP_VERSION 474#ifndef DESKTOP_VERSION
475//US listen for arriving address resultsets 475//US listen for arriving address resultsets
476 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 476 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
477 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 477 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
478#endif 478#endif
479 479
480} 480}
481 481
482 482
483CalendarView::~CalendarView() 483CalendarView::~CalendarView()
484{ 484{
485 // kdDebug() << "~CalendarView()" << endl; 485 // kdDebug() << "~CalendarView()" << endl;
486 //qDebug("CalendarView::~CalendarView() "); 486 //qDebug("CalendarView::~CalendarView() ");
487 delete mDialogManager; 487 delete mDialogManager;
488 delete mViewManager; 488 delete mViewManager;
489 delete mStorage; 489 delete mStorage;
490 delete mDateFrame ; 490 delete mDateFrame ;
491 delete beamDialog; 491 delete beamDialog;
492 //kdDebug() << "~CalendarView() done" << endl; 492 //kdDebug() << "~CalendarView() done" << endl;
493} 493}
494void CalendarView::timerAlarm() 494void CalendarView::timerAlarm()
495{ 495{
496 //qDebug("CalendarView::timerAlarm() "); 496 //qDebug("CalendarView::timerAlarm() ");
497 computeAlarm(mAlarmNotification ); 497 computeAlarm(mAlarmNotification );
498} 498}
499 499
500void CalendarView::suspendAlarm() 500void CalendarView::suspendAlarm()
501{ 501{
502 //qDebug(" CalendarView::suspendAlarm() "); 502 //qDebug(" CalendarView::suspendAlarm() ");
503 computeAlarm(mSuspendAlarmNotification ); 503 computeAlarm(mSuspendAlarmNotification );
504 504
505} 505}
506 506
507void CalendarView::startAlarm( QString mess , QString filename) 507void CalendarView::startAlarm( QString mess , QString filename)
508{ 508{
509 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 509 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
510 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 510 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
511 511
512} 512}
513 513
514void CalendarView::checkNextTimerAlarm() 514void CalendarView::checkNextTimerAlarm()
515{ 515{
516 mCalendar->checkAlarmForIncidence( 0, true ); 516 mCalendar->checkAlarmForIncidence( 0, true );
517} 517}
518 518
519void CalendarView::computeAlarm( QString msg ) 519void CalendarView::computeAlarm( QString msg )
520{ 520{
521 521
522 QString mess = msg; 522 QString mess = msg;
523 QString mAlarmMessage = mess.mid( 9 ); 523 QString mAlarmMessage = mess.mid( 9 );
524 QString filename = MainWindow::resourcePath(); 524 QString filename = MainWindow::resourcePath();
525 filename += "koalarm.wav"; 525 filename += "koalarm.wav";
526 QString tempfilename; 526 QString tempfilename;
527 if ( mess.left( 13 ) == "suspend_alarm") { 527 if ( mess.left( 13 ) == "suspend_alarm") {
528 bool error = false; 528 bool error = false;
529 int len = mess.mid( 13 ).find("+++"); 529 int len = mess.mid( 13 ).find("+++");
530 if ( len < 2 ) 530 if ( len < 2 )
531 error = true; 531 error = true;
532 else { 532 else {
533 tempfilename = mess.mid( 13, len ); 533 tempfilename = mess.mid( 13, len );
534 if ( !QFile::exists( tempfilename ) ) 534 if ( !QFile::exists( tempfilename ) )
535 error = true; 535 error = true;
536 } 536 }
537 if ( ! error ) { 537 if ( ! error ) {
538 filename = tempfilename; 538 filename = tempfilename;
539 } 539 }
540 mAlarmMessage = mess.mid( 13+len+3 ); 540 mAlarmMessage = mess.mid( 13+len+3 );
541 //qDebug("suspend file %s ",tempfilename.latin1() ); 541 //qDebug("suspend file %s ",tempfilename.latin1() );
542 startAlarm( mAlarmMessage, filename); 542 startAlarm( mAlarmMessage, filename);
543 return; 543 return;
544 } 544 }
545 if ( mess.left( 11 ) == "timer_alarm") { 545 if ( mess.left( 11 ) == "timer_alarm") {
546 //mTimerTime = 0; 546 //mTimerTime = 0;
547 startAlarm( mess.mid( 11 ), filename ); 547 startAlarm( mess.mid( 11 ), filename );
548 return; 548 return;
549 } 549 }
550 if ( mess.left( 10 ) == "proc_alarm") { 550 if ( mess.left( 10 ) == "proc_alarm") {
551 bool error = false; 551 bool error = false;
552 int len = mess.mid( 10 ).find("+++"); 552 int len = mess.mid( 10 ).find("+++");
553 if ( len < 2 ) 553 if ( len < 2 )
554 error = true; 554 error = true;
555 else { 555 else {
556 tempfilename = mess.mid( 10, len ); 556 tempfilename = mess.mid( 10, len );
557 if ( !QFile::exists( tempfilename ) ) 557 if ( !QFile::exists( tempfilename ) )
558 error = true; 558 error = true;
559 } 559 }
560 if ( error ) { 560 if ( error ) {
561 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 561 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
562 mAlarmMessage += mess.mid( 10+len+3+9 ); 562 mAlarmMessage += mess.mid( 10+len+3+9 );
563 } else { 563 } else {
564 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 564 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
565 //qDebug("-----system command %s ",tempfilename.latin1() ); 565 //qDebug("-----system command %s ",tempfilename.latin1() );
566#ifndef _WIN32_ 566#ifndef _WIN32_
567 if ( vfork () == 0 ) { 567 if ( vfork () == 0 ) {
568 execl ( tempfilename.latin1(), 0 ); 568 execl ( tempfilename.latin1(), 0 );
569 return; 569 return;
570 } 570 }
571#else 571#else
572 QProcess* p = new QProcess(); 572 QProcess* p = new QProcess();
573 p->addArgument( tempfilename.latin1() ); 573 p->addArgument( tempfilename.latin1() );
574 p->start(); 574 p->start();
575 return; 575 return;
576#endif 576#endif
577 577
578 return; 578 return;
579 } 579 }
580 580
581 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 581 //qDebug("+++++++system command %s ",tempfilename.latin1() );
582 } 582 }
583 if ( mess.left( 11 ) == "audio_alarm") { 583 if ( mess.left( 11 ) == "audio_alarm") {
584 bool error = false; 584 bool error = false;
585 int len = mess.mid( 11 ).find("+++"); 585 int len = mess.mid( 11 ).find("+++");
586 if ( len < 2 ) 586 if ( len < 2 )
587 error = true; 587 error = true;
588 else { 588 else {
589 tempfilename = mess.mid( 11, len ); 589 tempfilename = mess.mid( 11, len );
590 if ( !QFile::exists( tempfilename ) ) 590 if ( !QFile::exists( tempfilename ) )
591 error = true; 591 error = true;
592 } 592 }
593 if ( ! error ) { 593 if ( ! error ) {
594 filename = tempfilename; 594 filename = tempfilename;
595 } 595 }
596 mAlarmMessage = mess.mid( 11+len+3+9 ); 596 mAlarmMessage = mess.mid( 11+len+3+9 );
597 //qDebug("audio file command %s ",tempfilename.latin1() ); 597 //qDebug("audio file command %s ",tempfilename.latin1() );
598 } 598 }
599 if ( mess.left( 9 ) == "cal_alarm") { 599 if ( mess.left( 9 ) == "cal_alarm") {
600 mAlarmMessage = mess.mid( 9 ) ; 600 mAlarmMessage = mess.mid( 9 ) ;
601 } 601 }
602 602
603 startAlarm( mAlarmMessage, filename ); 603 startAlarm( mAlarmMessage, filename );
604 604
605 605
606} 606}
607 607
608void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 608void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
609{ 609{
610 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 610 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
611 611
612 mSuspendAlarmNotification = noti; 612 mSuspendAlarmNotification = noti;
613 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 613 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
614 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 614 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
615 mSuspendTimer->start( ms , true ); 615 mSuspendTimer->start( ms , true );
616 616
617} 617}
618 618
619void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 619void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
620{ 620{
621 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 621 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
622 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 622 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
623#ifndef DESKTOP_VERSION 623#ifndef DESKTOP_VERSION
624 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 624 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
625#endif 625#endif
626 return; 626 return;
627 } 627 }
628 int maxSec; 628 int maxSec;
629 //maxSec = 5; //testing only 629 //maxSec = 5; //testing only
630 maxSec = 86400+3600; // one day+1hour 630 maxSec = 86400+3600; // one day+1hour
631 mAlarmNotification = noti; 631 mAlarmNotification = noti;
632 int sec = QDateTime::currentDateTime().secsTo( qdt ); 632 int sec = QDateTime::currentDateTime().secsTo( qdt );
633 if ( sec > maxSec ) { 633 if ( sec > maxSec ) {
634 mRecheckAlarmTimer->start( maxSec * 1000 ); 634 mRecheckAlarmTimer->start( maxSec * 1000 );
635 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 635 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
636 return; 636 return;
637 } else { 637 } else {
638 mRecheckAlarmTimer->stop(); 638 mRecheckAlarmTimer->stop();
639 } 639 }
640 //qDebug("Alarm timer started with secs: %d ", sec); 640 //qDebug("Alarm timer started with secs: %d ", sec);
641 mAlarmTimer->start( sec *1000 , true ); 641 mAlarmTimer->start( sec *1000 , true );
642 642
643} 643}
644// called by mRecheckAlarmTimer to get next alarm 644// called by mRecheckAlarmTimer to get next alarm
645// we need this, because a QTimer has only a max range of 25 days 645// we need this, because a QTimer has only a max range of 25 days
646void CalendarView::recheckTimerAlarm() 646void CalendarView::recheckTimerAlarm()
647{ 647{
648 mAlarmTimer->stop(); 648 mAlarmTimer->stop();
649 mRecheckAlarmTimer->stop(); 649 mRecheckAlarmTimer->stop();
650 mCalendar->checkAlarmForIncidence( 0, true ); 650 mCalendar->checkAlarmForIncidence( 0, true );
651} 651}
652void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 652void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
653{ 653{
654 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 654 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
655 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 655 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
656#ifndef DESKTOP_VERSION 656#ifndef DESKTOP_VERSION
657 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 657 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
658#endif 658#endif
659 return; 659 return;
660 } 660 }
661 mAlarmTimer->stop(); 661 mAlarmTimer->stop();
662} 662}
663void CalendarView::selectWeekNum ( int num ) 663void CalendarView::selectWeekNum ( int num )
664{ 664{
665 dateNavigator()->selectWeek( num ); 665 dateNavigator()->selectWeek( num );
666 mViewManager->showWeekView(); 666 mViewManager->showWeekView();
667} 667}
668KOViewManager *CalendarView::viewManager() 668KOViewManager *CalendarView::viewManager()
669{ 669{
670 return mViewManager; 670 return mViewManager;
671} 671}
672 672
673KODialogManager *CalendarView::dialogManager() 673KODialogManager *CalendarView::dialogManager()
674{ 674{
675 return mDialogManager; 675 return mDialogManager;
676} 676}
677 677
678QDate CalendarView::startDate() 678QDate CalendarView::startDate()
679{ 679{
680 DateList dates = mNavigator->selectedDates(); 680 DateList dates = mNavigator->selectedDates();
681 681
682 return dates.first(); 682 return dates.first();
683} 683}
684 684
685QDate CalendarView::endDate() 685QDate CalendarView::endDate()
686{ 686{
687 DateList dates = mNavigator->selectedDates(); 687 DateList dates = mNavigator->selectedDates();
688 688
689 return dates.last(); 689 return dates.last();
690} 690}
691 691
692 692
693void CalendarView::createPrinter() 693void CalendarView::createPrinter()
694{ 694{
695#ifndef KORG_NOPRINTER 695#ifndef KORG_NOPRINTER
696 if (!mCalPrinter) { 696 if (!mCalPrinter) {
697 mCalPrinter = new CalPrinter(this, mCalendar); 697 mCalPrinter = new CalPrinter(this, mCalendar);
698 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 698 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
699 } 699 }
700#endif 700#endif
701} 701}
702 702
703 703
704//KOPrefs::instance()->mWriteBackFile 704//KOPrefs::instance()->mWriteBackFile
705//KOPrefs::instance()->mWriteBackExistingOnly 705//KOPrefs::instance()->mWriteBackExistingOnly
706 706
707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
713 713
714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
715{ 715{
716 716
717 // 0 equal 717 // 0 equal
718 // 1 take local 718 // 1 take local
719 // 2 take remote 719 // 2 take remote
720 // 3 cancel 720 // 3 cancel
721 QDateTime lastSync = mLastCalendarSync; 721 QDateTime lastSync = mLastCalendarSync;
722 QDateTime localMod = local->lastModified(); 722 QDateTime localMod = local->lastModified();
723 QDateTime remoteMod = remote->lastModified(); 723 QDateTime remoteMod = remote->lastModified();
724 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 724 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
725 bool remCh, locCh; 725 bool remCh, locCh;
726 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 726 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
727 //if ( remCh ) 727 //if ( remCh )
728 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 728 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
729 locCh = ( localMod > mLastCalendarSync ); 729 locCh = ( localMod > mLastCalendarSync );
730 if ( !remCh && ! locCh ) { 730 if ( !remCh && ! locCh ) {
731 //qDebug("both not changed "); 731 //qDebug("both not changed ");
732 lastSync = localMod.addDays(1); 732 lastSync = localMod.addDays(1);
733 if ( mode <= SYNC_PREF_ASK ) 733 if ( mode <= SYNC_PREF_ASK )
734 return 0; 734 return 0;
735 } else { 735 } else {
736 if ( locCh ) { 736 if ( locCh ) {
737 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 737 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
738 lastSync = localMod.addDays( -1 ); 738 lastSync = localMod.addDays( -1 );
739 if ( !remCh ) 739 if ( !remCh )
740 remoteMod = ( lastSync.addDays( -1 ) ); 740 remoteMod = ( lastSync.addDays( -1 ) );
741 } else { 741 } else {
742 //qDebug(" not loc changed "); 742 //qDebug(" not loc changed ");
743 lastSync = localMod.addDays( 1 ); 743 lastSync = localMod.addDays( 1 );
744 if ( remCh ) 744 if ( remCh )
745 remoteMod =( lastSync.addDays( 1 ) ); 745 remoteMod =( lastSync.addDays( 1 ) );
746 746
747 } 747 }
748 } 748 }
749 full = true; 749 full = true;
750 if ( mode < SYNC_PREF_ASK ) 750 if ( mode < SYNC_PREF_ASK )
751 mode = SYNC_PREF_ASK; 751 mode = SYNC_PREF_ASK;
752 } else { 752 } else {
753 if ( localMod == remoteMod ) 753 if ( localMod == remoteMod )
754 // if ( local->revision() == remote->revision() ) 754 // if ( local->revision() == remote->revision() )
755 return 0; 755 return 0;
756 756
757 } 757 }
758 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 758 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
759 759
760 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 760 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
761 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 761 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
762 //full = true; //debug only 762 //full = true; //debug only
763 if ( full ) { 763 if ( full ) {
764 bool equ = false; 764 bool equ = false;
765 if ( local->type() == "Event" ) { 765 if ( local->type() == "Event" ) {
766 equ = (*((Event*) local) == *((Event*) remote)); 766 equ = (*((Event*) local) == *((Event*) remote));
767 } 767 }
768 else if ( local->type() =="Todo" ) 768 else if ( local->type() =="Todo" )
769 equ = (*((Todo*) local) == (*(Todo*) remote)); 769 equ = (*((Todo*) local) == (*(Todo*) remote));
770 else if ( local->type() =="Journal" ) 770 else if ( local->type() =="Journal" )
771 equ = (*((Journal*) local) == *((Journal*) remote)); 771 equ = (*((Journal*) local) == *((Journal*) remote));
772 if ( equ ) { 772 if ( equ ) {
773 //qDebug("equal "); 773 //qDebug("equal ");
774 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 774 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
775 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 775 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
776 } 776 }
777 if ( mode < SYNC_PREF_FORCE_LOCAL ) 777 if ( mode < SYNC_PREF_FORCE_LOCAL )
778 return 0; 778 return 0;
779 779
780 }//else //debug only 780 }//else //debug only
781 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 781 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
782 } 782 }
783 int result; 783 int result;
784 bool localIsNew; 784 bool localIsNew;
785 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 785 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
786 786
787 if ( full && mode < SYNC_PREF_NEWEST ) 787 if ( full && mode < SYNC_PREF_NEWEST )
788 mode = SYNC_PREF_ASK; 788 mode = SYNC_PREF_ASK;
789 789
790 switch( mode ) { 790 switch( mode ) {
791 case SYNC_PREF_LOCAL: 791 case SYNC_PREF_LOCAL:
792 if ( lastSync > remoteMod ) 792 if ( lastSync > remoteMod )
793 return 1; 793 return 1;
794 if ( lastSync > localMod ) 794 if ( lastSync > localMod )
795 return 2; 795 return 2;
796 return 1; 796 return 1;
797 break; 797 break;
798 case SYNC_PREF_REMOTE: 798 case SYNC_PREF_REMOTE:
799 if ( lastSync > remoteMod ) 799 if ( lastSync > remoteMod )
800 return 1; 800 return 1;
801 if ( lastSync > localMod ) 801 if ( lastSync > localMod )
802 return 2; 802 return 2;
803 return 2; 803 return 2;
804 break; 804 break;
805 case SYNC_PREF_NEWEST: 805 case SYNC_PREF_NEWEST:
806 if ( localMod > remoteMod ) 806 if ( localMod > remoteMod )
807 return 1; 807 return 1;
808 else 808 else
809 return 2; 809 return 2;
810 break; 810 break;
811 case SYNC_PREF_ASK: 811 case SYNC_PREF_ASK:
812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
813 if ( lastSync > remoteMod ) 813 if ( lastSync > remoteMod )
814 return 1; 814 return 1;
815 if ( lastSync > localMod ) 815 if ( lastSync > localMod )
816 return 2; 816 return 2;
817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
818 localIsNew = localMod >= remoteMod; 818 localIsNew = localMod >= remoteMod;
819 if ( localIsNew ) 819 if ( localIsNew )
820 getEventViewerDialog()->setColorMode( 1 ); 820 getEventViewerDialog()->setColorMode( 1 );
821 else 821 else
822 getEventViewerDialog()->setColorMode( 2 ); 822 getEventViewerDialog()->setColorMode( 2 );
823 getEventViewerDialog()->setIncidence(local); 823 getEventViewerDialog()->setIncidence(local);
824 if ( localIsNew ) 824 if ( localIsNew )
825 getEventViewerDialog()->setColorMode( 2 ); 825 getEventViewerDialog()->setColorMode( 2 );
826 else 826 else
827 getEventViewerDialog()->setColorMode( 1 ); 827 getEventViewerDialog()->setColorMode( 1 );
828 getEventViewerDialog()->addIncidence(remote); 828 getEventViewerDialog()->addIncidence(remote);
829 getEventViewerDialog()->setColorMode( 0 ); 829 getEventViewerDialog()->setColorMode( 0 );
830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
832 getEventViewerDialog()->showMe(); 832 getEventViewerDialog()->showMe();
833 result = getEventViewerDialog()->executeS( localIsNew ); 833 result = getEventViewerDialog()->executeS( localIsNew );
834 return result; 834 return result;
835 835
836 break; 836 break;
837 case SYNC_PREF_FORCE_LOCAL: 837 case SYNC_PREF_FORCE_LOCAL:
838 return 1; 838 return 1;
839 break; 839 break;
840 case SYNC_PREF_FORCE_REMOTE: 840 case SYNC_PREF_FORCE_REMOTE:
841 return 2; 841 return 2;
842 break; 842 break;
843 843
844 default: 844 default:
845 // SYNC_PREF_TAKE_BOTH not implemented 845 // SYNC_PREF_TAKE_BOTH not implemented
846 break; 846 break;
847 } 847 }
848 return 0; 848 return 0;
849} 849}
850Event* CalendarView::getLastSyncEvent() 850Event* CalendarView::getLastSyncEvent()
851{ 851{
852 Event* lse; 852 Event* lse;
853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
855 if (!lse) { 855 if (!lse) {
856 lse = new Event(); 856 lse = new Event();
857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
858 QString sum = ""; 858 QString sum = "";
859 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 859 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
860 sum = "E: "; 860 sum = "E: ";
861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
862 lse->setDtStart( mLastCalendarSync ); 862 lse->setDtStart( mLastCalendarSync );
863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
864 lse->setCategories( i18n("SyncEvent") ); 864 lse->setCategories( i18n("SyncEvent") );
865 lse->setReadOnly( true ); 865 lse->setReadOnly( true );
866 mCalendar->addEvent( lse ); 866 mCalendar->addEvent( lse );
867 } 867 }
868 868
869 return lse; 869 return lse;
870 870
871} 871}
872 872
873// we check, if the to delete event has a id for a profile 873// we check, if the to delete event has a id for a profile
874// if yes, we set this id in the profile to delete 874// if yes, we set this id in the profile to delete
875void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 875void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
876{ 876{
877 if ( lastSync.count() == 0 ) { 877 if ( lastSync.count() == 0 ) {
878 //qDebug(" lastSync.count() == 0"); 878 //qDebug(" lastSync.count() == 0");
879 return; 879 return;
880 } 880 }
881 if ( toDelete->type() == "Journal" ) 881 if ( toDelete->type() == "Journal" )
882 return; 882 return;
883 883
884 Event* eve = lastSync.first(); 884 Event* eve = lastSync.first();
885 885
886 while ( eve ) { 886 while ( eve ) {
887 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 887 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
888 if ( !id.isEmpty() ) { 888 if ( !id.isEmpty() ) {
889 QString des = eve->description(); 889 QString des = eve->description();
890 QString pref = "e"; 890 QString pref = "e";
891 if ( toDelete->type() == "Todo" ) 891 if ( toDelete->type() == "Todo" )
892 pref = "t"; 892 pref = "t";
893 des += pref+ id + ","; 893 des += pref+ id + ",";
894 eve->setReadOnly( false ); 894 eve->setReadOnly( false );
895 eve->setDescription( des ); 895 eve->setDescription( des );
896 //qDebug("setdes %s ", des.latin1()); 896 //qDebug("setdes %s ", des.latin1());
897 eve->setReadOnly( true ); 897 eve->setReadOnly( true );
898 } 898 }
899 eve = lastSync.next(); 899 eve = lastSync.next();
900 } 900 }
901 901
902} 902}
903void CalendarView::checkExternalId( Incidence * inc ) 903void CalendarView::checkExternalId( Incidence * inc )
904{ 904{
905 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 905 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
906 checkExternSyncEvent( lastSync, inc ); 906 checkExternSyncEvent( lastSync, inc );
907 907
908} 908}
909bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 909bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
910{ 910{
911 bool syncOK = true; 911 bool syncOK = true;
912 int addedEvent = 0; 912 int addedEvent = 0;
913 int addedEventR = 0; 913 int addedEventR = 0;
914 int deletedEventR = 0; 914 int deletedEventR = 0;
915 int deletedEventL = 0; 915 int deletedEventL = 0;
916 int changedLocal = 0; 916 int changedLocal = 0;
917 int changedRemote = 0; 917 int changedRemote = 0;
918 //QPtrList<Event> el = local->rawEvents(); 918 //QPtrList<Event> el = local->rawEvents();
919 Event* eventR; 919 Event* eventR;
920 QString uid; 920 QString uid;
921 int take; 921 int take;
922 Event* eventL; 922 Event* eventL;
923 Event* eventRSync; 923 Event* eventRSync;
924 Event* eventLSync; 924 Event* eventLSync;
925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
927 bool fullDateRange = false; 927 bool fullDateRange = false;
928 local->resetTempSyncStat(); 928 local->resetTempSyncStat();
929 mLastCalendarSync = QDateTime::currentDateTime(); 929 mLastCalendarSync = QDateTime::currentDateTime();
930 if ( mSyncManager->syncWithDesktop() ) { 930 if ( mSyncManager->syncWithDesktop() ) {
931 remote->resetPilotStat(1); 931 remote->resetPilotStat(1);
932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
934 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 934 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
935 } else { 935 } else {
936 qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); 936 qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime ");
937 } 937 }
938 } 938 }
939 QDateTime modifiedCalendar = mLastCalendarSync;; 939 QDateTime modifiedCalendar = mLastCalendarSync;;
940 eventLSync = getLastSyncEvent(); 940 eventLSync = getLastSyncEvent();
941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
942 if ( eventR ) { 942 if ( eventR ) {
943 eventRSync = (Event*) eventR->clone(); 943 eventRSync = (Event*) eventR->clone();
944 remote->deleteEvent(eventR ); 944 remote->deleteEvent(eventR );
945 945
946 } else { 946 } else {
947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
948 eventRSync = (Event*)eventLSync->clone(); 948 eventRSync = (Event*)eventLSync->clone();
949 } else { 949 } else {
950 fullDateRange = true; 950 fullDateRange = true;
951 eventRSync = new Event(); 951 eventRSync = new Event();
952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
954 eventRSync->setDtStart( mLastCalendarSync ); 954 eventRSync->setDtStart( mLastCalendarSync );
955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
956 eventRSync->setCategories( i18n("SyncEvent") ); 956 eventRSync->setCategories( i18n("SyncEvent") );
957 } 957 }
958 } 958 }
959 if ( eventLSync->dtStart() == mLastCalendarSync ) 959 if ( eventLSync->dtStart() == mLastCalendarSync )
960 fullDateRange = true; 960 fullDateRange = true;
961 961
962 if ( ! fullDateRange ) { 962 if ( ! fullDateRange ) {
963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
964 964
965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
967 fullDateRange = true; 967 fullDateRange = true;
968 } 968 }
969 } 969 }
970 if ( mSyncManager->syncWithDesktop() ) { 970 if ( mSyncManager->syncWithDesktop() ) {
971 fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); 971 fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync );
972 } 972 }
973 if ( fullDateRange ) 973 if ( fullDateRange )
974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
975 else 975 else
976 mLastCalendarSync = eventLSync->dtStart(); 976 mLastCalendarSync = eventLSync->dtStart();
977 // for resyncing if own file has changed 977 // for resyncing if own file has changed
978 if ( mCurrentSyncDevice == "deleteaftersync" ) { 978 if ( mCurrentSyncDevice == "deleteaftersync" ) {
979 mLastCalendarSync = loadedFileVersion; 979 mLastCalendarSync = loadedFileVersion;
980 //qDebug("setting mLastCalendarSync "); 980 //qDebug("setting mLastCalendarSync ");
981 } 981 }
982 //qDebug("*************************** "); 982 //qDebug("*************************** ");
983 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 983 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
984 QPtrList<Incidence> er = remote->rawIncidences(); 984 QPtrList<Incidence> er = remote->rawIncidences();
985 Incidence* inR = er.first(); 985 Incidence* inR = er.first();
986 Incidence* inL; 986 Incidence* inL;
987 QProgressBar bar( er.count(),0 ); 987 QProgressBar bar( er.count(),0 );
988 bar.setCaption (i18n("Syncing - close to abort!") ); 988 bar.setCaption (i18n("Syncing - close to abort!") );
989 989
990 int w = 300; 990 int w = 300;
991 if ( QApplication::desktop()->width() < 320 ) 991 if ( QApplication::desktop()->width() < 320 )
992 w = 220; 992 w = 220;
993 int h = bar.sizeHint().height() ; 993 int h = bar.sizeHint().height() ;
994 int dw = QApplication::desktop()->width(); 994 int dw = QApplication::desktop()->width();
995 int dh = QApplication::desktop()->height(); 995 int dh = QApplication::desktop()->height();
996 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 996 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
997 bar.show(); 997 bar.show();
998 int modulo = (er.count()/10)+1; 998 int modulo = (er.count()/10)+1;
999 int incCounter = 0; 999 int incCounter = 0;
1000 while ( inR ) { 1000 while ( inR ) {
1001 if ( ! bar.isVisible() ) 1001 if ( ! bar.isVisible() )
1002 return false; 1002 return false;
1003 if ( incCounter % modulo == 0 ) 1003 if ( incCounter % modulo == 0 )
1004 bar.setProgress( incCounter ); 1004 bar.setProgress( incCounter );
1005 ++incCounter; 1005 ++incCounter;
1006 uid = inR->uid(); 1006 uid = inR->uid();
1007 bool skipIncidence = false; 1007 bool skipIncidence = false;
1008 if ( uid.left(15) == QString("last-syncEvent-") ) 1008 if ( uid.left(15) == QString("last-syncEvent-") )
1009 skipIncidence = true; 1009 skipIncidence = true;
1010 QString idS; 1010 QString idS;
1011 qApp->processEvents(); 1011 qApp->processEvents();
1012 if ( !skipIncidence ) { 1012 if ( !skipIncidence ) {
1013 inL = local->incidence( uid ); 1013 inL = local->incidence( uid );
1014 if ( inL ) { // maybe conflict - same uid in both calendars 1014 if ( inL ) { // maybe conflict - same uid in both calendars
1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1016 //qDebug("take %d %s ", take, inL->summary().latin1()); 1016 //qDebug("take %d %s ", take, inL->summary().latin1());
1017 if ( take == 3 ) 1017 if ( take == 3 )
1018 return false; 1018 return false;
1019 if ( take == 1 ) {// take local 1019 if ( take == 1 ) {// take local **********************
1020 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1020 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1021 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1021 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1022 else 1022 else
1023 idS = inR->IDStr(); 1023 idS = inR->IDStr();
1024 remote->deleteIncidence( inR ); 1024 remote->deleteIncidence( inR );
1025 inR = inL->clone(); 1025 inR = inL->clone();
1026 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1026 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1027 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1027 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1028 inR->setIDStr( idS ); 1028 inR->setIDStr( idS );
1029 remote->addIncidence( inR ); 1029 remote->addIncidence( inR );
1030 if ( mSyncManager->syncWithDesktop() ) 1030 if ( mSyncManager->syncWithDesktop() )
1031 inR->setPilotId( 2 ); 1031 inR->setPilotId( 2 );
1032 ++changedRemote; 1032 ++changedRemote;
1033 } else { 1033 } else {// take remote **********************
1034 idS = inL->IDStr(); 1034 idS = inL->IDStr();
1035 int pid = inL->pilotId(); 1035 int pid = inL->pilotId();
1036 local->deleteIncidence( inL ); 1036 local->deleteIncidence( inL );
1037 inL = inR->clone(); 1037 inL = inR->clone();
1038 if ( mSyncManager->syncWithDesktop() ) 1038 if ( mSyncManager->syncWithDesktop() )
1039 inL->setPilotId( pid ); 1039 inL->setPilotId( pid );
1040 inL->setIDStr( idS ); 1040 inL->setIDStr( idS );
1041 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1041 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1042 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1042 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1043 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1043 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1044 } 1044 }
1045 local->addIncidence( inL ); 1045 local->addIncidence( inL );
1046 ++changedLocal; 1046 ++changedLocal;
1047 } 1047 }
1048 } 1048 }
1049 } else { // no conflict 1049 } else { // no conflict ********** add or delete remote
1050 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1050 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1051 QString des = eventLSync->description(); 1051 QString des = eventLSync->description();
1052 QString pref = "e"; 1052 QString pref = "e";
1053 if ( inR->type() == "Todo" ) 1053 if ( inR->type() == "Todo" )
1054 pref = "t"; 1054 pref = "t";
1055 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1055 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1056 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1056 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1057 //remote->deleteIncidence( inR ); 1057 //remote->deleteIncidence( inR );
1058 ++deletedEventR; 1058 ++deletedEventR;
1059 } else { 1059 } else {
1060 inR->setLastModified( modifiedCalendar ); 1060 inR->setLastModified( modifiedCalendar );
1061 inL = inR->clone(); 1061 inL = inR->clone();
1062 inL->setIDStr( ":" ); 1062 inL->setIDStr( ":" );
1063 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1064 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1063 local->addIncidence( inL ); 1065 local->addIncidence( inL );
1064 ++addedEvent; 1066 ++addedEvent;
1065 } 1067 }
1066 } else { 1068 } else {
1067 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1069 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1068 inR->setLastModified( modifiedCalendar ); 1070 inR->setLastModified( modifiedCalendar );
1069 inL = inR->clone(); 1071 inL = inR->clone();
1070 inL->setIDStr( ":" ); 1072 inL->setIDStr( ":" );
1071 local->addIncidence( inL ); 1073 local->addIncidence( inL );
1072 ++addedEvent; 1074 ++addedEvent;
1073 } else { 1075 } else {
1074 checkExternSyncEvent(eventRSyncSharp, inR); 1076 checkExternSyncEvent(eventRSyncSharp, inR);
1075 remote->deleteIncidence( inR ); 1077 remote->deleteIncidence( inR );
1076 ++deletedEventR; 1078 ++deletedEventR;
1077 } 1079 }
1078 } 1080 }
1079 } 1081 }
1080 } 1082 }
1081 inR = er.next(); 1083 inR = er.next();
1082 } 1084 }
1083 QPtrList<Incidence> el = local->rawIncidences(); 1085 QPtrList<Incidence> el = local->rawIncidences();
1084 inL = el.first(); 1086 inL = el.first();
1085 modulo = (el.count()/10)+1; 1087 modulo = (el.count()/10)+1;
1086 bar.setCaption (i18n("Add / remove events") ); 1088 bar.setCaption (i18n("Add / remove events") );
1087 bar.setTotalSteps ( el.count() ) ; 1089 bar.setTotalSteps ( el.count() ) ;
1088 bar.show(); 1090 bar.show();
1089 incCounter = 0; 1091 incCounter = 0;
1090 1092
1091 while ( inL ) { 1093 while ( inL ) {
1092 1094
1093 qApp->processEvents(); 1095 qApp->processEvents();
1094 if ( ! bar.isVisible() ) 1096 if ( ! bar.isVisible() )
1095 return false; 1097 return false;
1096 if ( incCounter % modulo == 0 ) 1098 if ( incCounter % modulo == 0 )
1097 bar.setProgress( incCounter ); 1099 bar.setProgress( incCounter );
1098 ++incCounter; 1100 ++incCounter;
1099 uid = inL->uid(); 1101 uid = inL->uid();
1100 bool skipIncidence = false; 1102 bool skipIncidence = false;
1101 if ( uid.left(15) == QString("last-syncEvent-") ) 1103 if ( uid.left(15) == QString("last-syncEvent-") )
1102 skipIncidence = true; 1104 skipIncidence = true;
1103 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1105 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1104 skipIncidence = true; 1106 skipIncidence = true;
1105 if ( !skipIncidence ) { 1107 if ( !skipIncidence ) {
1106 inR = remote->incidence( uid ); 1108 inR = remote->incidence( uid );
1107 if ( ! inR ) { 1109 if ( ! inR ) { // no conflict ********** add or delete local
1108 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1110 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1109 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1111 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1110 checkExternSyncEvent(eventLSyncSharp, inL); 1112 checkExternSyncEvent(eventLSyncSharp, inL);
1111 local->deleteIncidence( inL ); 1113 local->deleteIncidence( inL );
1112 ++deletedEventL; 1114 ++deletedEventL;
1113 } else { 1115 } else {
1114 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1116 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1115 inL->removeID(mCurrentSyncDevice ); 1117 inL->removeID(mCurrentSyncDevice );
1116 ++addedEventR; 1118 ++addedEventR;
1117 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1119 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1118 inL->setLastModified( modifiedCalendar ); 1120 inL->setLastModified( modifiedCalendar );
1119 inR = inL->clone(); 1121 inR = inL->clone();
1120 inR->setIDStr( ":" ); 1122 inR->setIDStr( ":" );
1121 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1123 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1122 remote->addIncidence( inR ); 1124 remote->addIncidence( inR );
1123 } 1125 }
1124 } 1126 }
1125 } else { 1127 } else {
1126 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1128 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1127 checkExternSyncEvent(eventLSyncSharp, inL); 1129 checkExternSyncEvent(eventLSyncSharp, inL);
1128 local->deleteIncidence( inL ); 1130 local->deleteIncidence( inL );
1129 ++deletedEventL; 1131 ++deletedEventL;
1130 } else { 1132 } else {
1131 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1133 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1132 ++addedEventR; 1134 ++addedEventR;
1133 inL->setLastModified( modifiedCalendar ); 1135 inL->setLastModified( modifiedCalendar );
1134 inR = inL->clone(); 1136 inR = inL->clone();
1135 inR->setIDStr( ":" ); 1137 inR->setIDStr( ":" );
1136 remote->addIncidence( inR ); 1138 remote->addIncidence( inR );
1137 } 1139 }
1138 } 1140 }
1139 } 1141 }
1140 } 1142 }
1141 } 1143 }
1142 inL = el.next(); 1144 inL = el.next();
1143 } 1145 }
1144 int delFut = 0; 1146 int delFut = 0;
1145 int remRem = 0; 1147 int remRem = 0;
1146 if ( mSyncManager->mWriteBackInFuture ) { 1148 if ( mSyncManager->mWriteBackInFuture ) {
1147 er = remote->rawIncidences(); 1149 er = remote->rawIncidences();
1148 remRem = er.count(); 1150 remRem = er.count();
1149 inR = er.first(); 1151 inR = er.first();
1150 QDateTime dt; 1152 QDateTime dt;
1151 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1153 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1152 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); 1154 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
1153 while ( inR ) { 1155 while ( inR ) {
1154 if ( inR->type() == "Todo" ) { 1156 if ( inR->type() == "Todo" ) {
1155 Todo * t = (Todo*)inR; 1157 Todo * t = (Todo*)inR;
1156 if ( t->hasDueDate() ) 1158 if ( t->hasDueDate() )
1157 dt = t->dtDue(); 1159 dt = t->dtDue();
1158 else 1160 else
1159 dt = cur.addSecs( 62 ); 1161 dt = cur.addSecs( 62 );
1160 } 1162 }
1161 else if (inR->type() == "Event" ) { 1163 else if (inR->type() == "Event" ) {
1162 bool ok; 1164 bool ok;
1163 dt = inR->getNextOccurence( cur, &ok ); 1165 dt = inR->getNextOccurence( cur, &ok );
1164 if ( !ok ) 1166 if ( !ok )
1165 dt = cur.addSecs( -62 ); 1167 dt = cur.addSecs( -62 );
1166 } 1168 }
1167 else 1169 else
1168 dt = inR->dtStart(); 1170 dt = inR->dtStart();
1169 if ( dt < cur || dt > end ) { 1171 if ( dt < cur || dt > end ) {
1170 remote->deleteIncidence( inR ); 1172 remote->deleteIncidence( inR );
1171 ++delFut; 1173 ++delFut;
1172 } 1174 }
1173 inR = er.next(); 1175 inR = er.next();
1174 } 1176 }
1175 } 1177 }
1176 bar.hide(); 1178 bar.hide();
1177 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1179 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1178 eventLSync->setReadOnly( false ); 1180 eventLSync->setReadOnly( false );
1179 eventLSync->setDtStart( mLastCalendarSync ); 1181 eventLSync->setDtStart( mLastCalendarSync );
1180 eventRSync->setDtStart( mLastCalendarSync ); 1182 eventRSync->setDtStart( mLastCalendarSync );
1181 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1183 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1182 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1184 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1183 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1185 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1184 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1186 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1185 eventLSync->setReadOnly( true ); 1187 eventLSync->setReadOnly( true );
1186 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1188 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1187 remote->addEvent( eventRSync ); 1189 remote->addEvent( eventRSync );
1188 else 1190 else
1189 delete eventRSync; 1191 delete eventRSync;
1190 QString mes; 1192 QString mes;
1191 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1193 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1192 QString delmess; 1194 QString delmess;
1193 if ( delFut ) { 1195 if ( delFut ) {
1194 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); 1196 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut);
1195 mes += delmess; 1197 mes += delmess;
1196 } 1198 }
1197 mCalendar->checkAlarmForIncidence( 0, true ); 1199 mCalendar->checkAlarmForIncidence( 0, true );
1198 qDebug( mes ); 1200 qDebug( mes );
1199 if ( mSyncManager->mShowSyncSummary ) { 1201 if ( mSyncManager->mShowSyncSummary ) {
1200 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1202 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1201 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1203 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1202 qDebug("cancelled "); 1204 qDebug("cancelled ");
1203 return false; 1205 return false;
1204 } 1206 }
1205 } 1207 }
1206 return syncOK; 1208 return syncOK;
1207} 1209}
1208 1210
1209void CalendarView::setSyncDevice( QString s ) 1211void CalendarView::setSyncDevice( QString s )
1210{ 1212{
1211 mCurrentSyncDevice= s; 1213 mCurrentSyncDevice= s;
1212} 1214}
1213void CalendarView::setSyncName( QString s ) 1215void CalendarView::setSyncName( QString s )
1214{ 1216{
1215 mCurrentSyncName= s; 1217 mCurrentSyncName= s;
1216} 1218}
1217bool CalendarView::syncCalendar(QString filename, int mode) 1219bool CalendarView::syncCalendar(QString filename, int mode)
1218{ 1220{
1219 //qDebug("syncCalendar %s ", filename.latin1()); 1221 //qDebug("syncCalendar %s ", filename.latin1());
1220 mGlobalSyncMode = SYNC_MODE_NORMAL; 1222 mGlobalSyncMode = SYNC_MODE_NORMAL;
1221 CalendarLocal* calendar = new CalendarLocal(); 1223 CalendarLocal* calendar = new CalendarLocal();
1222 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1224 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1223 FileStorage* storage = new FileStorage( calendar ); 1225 FileStorage* storage = new FileStorage( calendar );
1224 bool syncOK = false; 1226 bool syncOK = false;
1225 storage->setFileName( filename ); 1227 storage->setFileName( filename );
1226 // qDebug("loading ... "); 1228 // qDebug("loading ... ");
1227 if ( storage->load() ) { 1229 if ( storage->load() ) {
1228 getEventViewerDialog()->setSyncMode( true ); 1230 getEventViewerDialog()->setSyncMode( true );
1229 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1231 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1230 getEventViewerDialog()->setSyncMode( false ); 1232 getEventViewerDialog()->setSyncMode( false );
1231 if ( syncOK ) { 1233 if ( syncOK ) {
1232 if ( mSyncManager->mWriteBackFile ) 1234 if ( mSyncManager->mWriteBackFile )
1233 { 1235 {
1234 storage->setSaveFormat( new ICalFormat() ); 1236 storage->setSaveFormat( new ICalFormat() );
1235 storage->save(); 1237 storage->save();
1236 } 1238 }
1237 } 1239 }
1238 setModified( true ); 1240 setModified( true );
1239 } 1241 }
1240 delete storage; 1242 delete storage;
1241 delete calendar; 1243 delete calendar;
1242 if ( syncOK ) 1244 if ( syncOK )
1243 updateView(); 1245 updateView();
1244 return syncOK; 1246 return syncOK;
1245} 1247}
1246 1248
1247void CalendarView::syncExternal( int mode ) 1249void CalendarView::syncExternal( int mode )
1248{ 1250{
1249 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1251 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1250 1252
1251 qApp->processEvents(); 1253 qApp->processEvents();
1252 CalendarLocal* calendar = new CalendarLocal(); 1254 CalendarLocal* calendar = new CalendarLocal();
1253 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1255 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1254 bool syncOK = false; 1256 bool syncOK = false;
1255 bool loadSuccess = false; 1257 bool loadSuccess = false;
1256 PhoneFormat* phoneFormat = 0; 1258 PhoneFormat* phoneFormat = 0;
1257 emit tempDisableBR(true); 1259 emit tempDisableBR(true);
1258#ifndef DESKTOP_VERSION 1260#ifndef DESKTOP_VERSION
1259 SharpFormat* sharpFormat = 0; 1261 SharpFormat* sharpFormat = 0;
1260 if ( mode == 0 ) { // sharp 1262 if ( mode == 0 ) { // sharp
1261 sharpFormat = new SharpFormat () ; 1263 sharpFormat = new SharpFormat () ;
1262 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1264 loadSuccess = sharpFormat->load( calendar, mCalendar );
1263 1265
1264 } else 1266 } else
1265#endif 1267#endif
1266 if ( mode == 1 ) { // phone 1268 if ( mode == 1 ) { // phone
1267 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1269 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1268 mSyncManager->mPhoneDevice, 1270 mSyncManager->mPhoneDevice,
1269 mSyncManager->mPhoneConnection, 1271 mSyncManager->mPhoneConnection,
1270 mSyncManager->mPhoneModel); 1272 mSyncManager->mPhoneModel);
1271 loadSuccess = phoneFormat->load( calendar,mCalendar); 1273 loadSuccess = phoneFormat->load( calendar,mCalendar);
1272 1274
1273 } else { 1275 } else {
1274 emit tempDisableBR(false); 1276 emit tempDisableBR(false);
1275 return; 1277 return;
1276 } 1278 }
1277 if ( loadSuccess ) { 1279 if ( loadSuccess ) {
1278 getEventViewerDialog()->setSyncMode( true ); 1280 getEventViewerDialog()->setSyncMode( true );
1279 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1281 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1280 getEventViewerDialog()->setSyncMode( false ); 1282 getEventViewerDialog()->setSyncMode( false );
1281 qApp->processEvents(); 1283 qApp->processEvents();
1282 if ( syncOK ) { 1284 if ( syncOK ) {
1283 if ( mSyncManager->mWriteBackFile ) 1285 if ( mSyncManager->mWriteBackFile )
1284 { 1286 {
1285 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1287 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1286 Incidence* inc = iL.first(); 1288 Incidence* inc = iL.first();
1287 if ( phoneFormat ) { 1289 if ( phoneFormat ) {
1288 while ( inc ) { 1290 while ( inc ) {
1289 inc->removeID(mCurrentSyncDevice); 1291 inc->removeID(mCurrentSyncDevice);
1290 inc = iL.next(); 1292 inc = iL.next();
1291 } 1293 }
1292 } 1294 }
1293#ifndef DESKTOP_VERSION 1295#ifndef DESKTOP_VERSION
1294 if ( sharpFormat ) 1296 if ( sharpFormat )
1295 sharpFormat->save(calendar); 1297 sharpFormat->save(calendar);
1296#endif 1298#endif
1297 if ( phoneFormat ) 1299 if ( phoneFormat )
1298 phoneFormat->save(calendar); 1300 phoneFormat->save(calendar);
1299 iL = calendar->rawIncidences(); 1301 iL = calendar->rawIncidences();
1300 inc = iL.first(); 1302 inc = iL.first();
1301 Incidence* loc; 1303 Incidence* loc;
1302 while ( inc ) { 1304 while ( inc ) {
1303 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1305 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1304 loc = mCalendar->incidence(inc->uid() ); 1306 loc = mCalendar->incidence(inc->uid() );
1305 if ( loc ) { 1307 if ( loc ) {
1306 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1308 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1307 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1309 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1308 } 1310 }
1309 } 1311 }
1310 inc = iL.next(); 1312 inc = iL.next();
1311 } 1313 }
1312 Incidence* lse = getLastSyncEvent(); 1314 Incidence* lse = getLastSyncEvent();
1313 if ( lse ) { 1315 if ( lse ) {
1314 lse->setReadOnly( false ); 1316 lse->setReadOnly( false );
1315 lse->setDescription( "" ); 1317 lse->setDescription( "" );
1316 lse->setReadOnly( true ); 1318 lse->setReadOnly( true );
1317 } 1319 }
1318 } 1320 }
1319 } else { 1321 } else {
1320 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1322 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1321 } 1323 }
1322 setModified( true ); 1324 setModified( true );
1323 } else { 1325 } else {
1324 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1326 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1325 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1327 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1326 question, i18n("Ok")) ; 1328 question, i18n("Ok")) ;
1327 1329
1328 } 1330 }
1329 delete calendar; 1331 delete calendar;
1330 updateView(); 1332 updateView();
1331 emit tempDisableBR(false); 1333 emit tempDisableBR(false);
1332 return ;//syncOK; 1334 return ;//syncOK;
1333 1335
1334} 1336}
1335 1337
1336bool CalendarView::importBday() 1338bool CalendarView::importBday()
1337{ 1339{
1338#ifndef KORG_NOKABC 1340#ifndef KORG_NOKABC
1339 1341
1340#ifdef DESKTOP_VERSION 1342#ifdef DESKTOP_VERSION
1341 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1343 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1342 KABC::AddressBook::Iterator it; 1344 KABC::AddressBook::Iterator it;
1343 int count = 0; 1345 int count = 0;
1344 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1346 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1345 ++count; 1347 ++count;
1346 } 1348 }
1347 QProgressBar bar(count,0 ); 1349 QProgressBar bar(count,0 );
1348 int w = 300; 1350 int w = 300;
1349 if ( QApplication::desktop()->width() < 320 ) 1351 if ( QApplication::desktop()->width() < 320 )
1350 w = 220; 1352 w = 220;
1351 int h = bar.sizeHint().height() ; 1353 int h = bar.sizeHint().height() ;
1352 int dw = QApplication::desktop()->width(); 1354 int dw = QApplication::desktop()->width();
1353 int dh = QApplication::desktop()->height(); 1355 int dh = QApplication::desktop()->height();
1354 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1356 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1355 bar.show(); 1357 bar.show();
1356 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1358 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1357 qApp->processEvents(); 1359 qApp->processEvents();
1358 count = 0; 1360 count = 0;
1359 int addCount = 0; 1361 int addCount = 0;
1360 KCal::Attendee* a = 0; 1362 KCal::Attendee* a = 0;
1361 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1363 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1362 if ( ! bar.isVisible() ) 1364 if ( ! bar.isVisible() )
1363 return false; 1365 return false;
1364 bar.setProgress( count++ ); 1366 bar.setProgress( count++ );
1365 qApp->processEvents(); 1367 qApp->processEvents();
1366 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1368 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1367 if ( (*it).birthday().date().isValid() ){ 1369 if ( (*it).birthday().date().isValid() ){
1368 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1370 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1369 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1371 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1370 ++addCount; 1372 ++addCount;
1371 } 1373 }
1372 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1374 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1373 if ( anni.isValid() ){ 1375 if ( anni.isValid() ){
1374 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1376 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1375 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1377 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1376 ++addCount; 1378 ++addCount;
1377 } 1379 }
1378 } 1380 }
1379 updateView(); 1381 updateView();
1380 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1382 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1381#else //DESKTOP_VERSION 1383#else //DESKTOP_VERSION
1382 1384
1383 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1385 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1384 // the result should now arrive through method insertBirthdays 1386 // the result should now arrive through method insertBirthdays
1385 1387
1386#endif //DESKTOP_VERSION 1388#endif //DESKTOP_VERSION
1387 1389
1388#endif //KORG_NOKABC 1390#endif //KORG_NOKABC
1389 1391
1390 1392
1391 return true; 1393 return true;
1392} 1394}
1393 1395
1394// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1396// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1395void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1397void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1396 const QStringList& anniversaryList, const QStringList& realNameList, 1398 const QStringList& anniversaryList, const QStringList& realNameList,
1397 const QStringList& emailList, const QStringList& assembledNameList, 1399 const QStringList& emailList, const QStringList& assembledNameList,
1398 const QStringList& uidList) 1400 const QStringList& uidList)
1399{ 1401{
1400 qDebug("CalendarView::insertBirthdays"); 1402 qDebug("CalendarView::insertBirthdays");
1401 if (uid == this->name()) 1403 if (uid == this->name())
1402 { 1404 {
1403 int count = birthdayList.count(); 1405 int count = birthdayList.count();
1404 int addCount = 0; 1406 int addCount = 0;
1405 KCal::Attendee* a = 0; 1407 KCal::Attendee* a = 0;
1406 1408
1407 qDebug("CalView 1 %i", count); 1409 qDebug("CalView 1 %i", count);
1408 1410
1409 QProgressBar bar(count,0 ); 1411 QProgressBar bar(count,0 );
1410 int w = 300; 1412 int w = 300;
1411 if ( QApplication::desktop()->width() < 320 ) 1413 if ( QApplication::desktop()->width() < 320 )
1412 w = 220; 1414 w = 220;
1413 int h = bar.sizeHint().height() ; 1415 int h = bar.sizeHint().height() ;
1414 int dw = QApplication::desktop()->width(); 1416 int dw = QApplication::desktop()->width();
1415 int dh = QApplication::desktop()->height(); 1417 int dh = QApplication::desktop()->height();
1416 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1418 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1417 bar.show(); 1419 bar.show();
1418 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1420 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1419 qApp->processEvents(); 1421 qApp->processEvents();
1420 1422
1421 QDate birthday; 1423 QDate birthday;
1422 QDate anniversary; 1424 QDate anniversary;
1423 QString realName; 1425 QString realName;
1424 QString email; 1426 QString email;
1425 QString assembledName; 1427 QString assembledName;
1426 QString uid; 1428 QString uid;
1427 bool ok = true; 1429 bool ok = true;
1428 for ( int i = 0; i < count; i++) 1430 for ( int i = 0; i < count; i++)
1429 { 1431 {
1430 if ( ! bar.isVisible() ) 1432 if ( ! bar.isVisible() )
1431 return; 1433 return;
1432 bar.setProgress( i ); 1434 bar.setProgress( i );
1433 qApp->processEvents(); 1435 qApp->processEvents();
1434 1436
1435 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1437 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1436 if (!ok) { 1438 if (!ok) {
1437 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1439 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1438 } 1440 }
1439 1441
1440 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1442 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1441 if (!ok) { 1443 if (!ok) {
1442 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1444 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1443 } 1445 }
1444 realName = realNameList[i]; 1446 realName = realNameList[i];
1445 email = emailList[i]; 1447 email = emailList[i];
1446 assembledName = assembledNameList[i]; 1448 assembledName = assembledNameList[i];
1447 uid = uidList[i]; 1449 uid = uidList[i];
1448 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1450 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1449 1451
1450 if ( birthday.isValid() ){ 1452 if ( birthday.isValid() ){
1451 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1453 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1452 KCal::Attendee::ReqParticipant,uid) ; 1454 KCal::Attendee::ReqParticipant,uid) ;
1453 if ( addAnniversary( birthday, assembledName, a, true ) ) 1455 if ( addAnniversary( birthday, assembledName, a, true ) )
1454 ++addCount; 1456 ++addCount;
1455 } 1457 }
1456 1458
1457 if ( anniversary.isValid() ){ 1459 if ( anniversary.isValid() ){
1458 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1460 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1459 KCal::Attendee::ReqParticipant,uid) ; 1461 KCal::Attendee::ReqParticipant,uid) ;
1460 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1462 if ( addAnniversary( anniversary, assembledName, a, false ) )
1461 ++addCount; 1463 ++addCount;
1462 } 1464 }
1463 } 1465 }
1464 1466
1465 updateView(); 1467 updateView();
1466 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1468 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1467 1469
1468 } 1470 }
1469 1471
1470} 1472}
1471 1473
1472 1474
1473 1475
1474bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1476bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1475{ 1477{
1476 //qDebug("addAnni "); 1478 //qDebug("addAnni ");
1477 Event * ev = new Event(); 1479 Event * ev = new Event();
1478 if ( a ) { 1480 if ( a ) {
1479 ev->addAttendee( a ); 1481 ev->addAttendee( a );
1480 } 1482 }
1481 QString kind; 1483 QString kind;
1482 if ( birthday ) 1484 if ( birthday )
1483 kind = i18n( "Birthday" ); 1485 kind = i18n( "Birthday" );
1484 else 1486 else
1485 kind = i18n( "Anniversary" ); 1487 kind = i18n( "Anniversary" );
1486 ev->setSummary( name + " - " + kind ); 1488 ev->setSummary( name + " - " + kind );
1487 ev->setOrganizer(a->email()); 1489 ev->setOrganizer(a->email());
1488 ev->setCategories( kind ); 1490 ev->setCategories( kind );
1489 ev->setDtStart( QDateTime(date) ); 1491 ev->setDtStart( QDateTime(date) );
1490 ev->setDtEnd( QDateTime(date) ); 1492 ev->setDtEnd( QDateTime(date) );
1491 ev->setFloats( true ); 1493 ev->setFloats( true );
1492 Recurrence * rec = ev->recurrence(); 1494 Recurrence * rec = ev->recurrence();
1493 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1495 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1494 rec->addYearlyNum( date.month() ); 1496 rec->addYearlyNum( date.month() );
1495 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1497 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1496 delete ev; 1498 delete ev;
1497 return false; 1499 return false;
1498 } 1500 }
1499 return true; 1501 return true;
1500 1502
1501} 1503}
1502bool CalendarView::importQtopia( const QString &categories, 1504bool CalendarView::importQtopia( const QString &categories,
1503 const QString &datebook, 1505 const QString &datebook,
1504 const QString &todolist ) 1506 const QString &todolist )
1505{ 1507{
1506 1508
1507 QtopiaFormat qtopiaFormat; 1509 QtopiaFormat qtopiaFormat;
1508 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1510 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1509 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1511 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1510 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1512 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1511 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1513 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1512 1514
1513 updateView(); 1515 updateView();
1514 return true; 1516 return true;
1515 1517
1516#if 0 1518#if 0
1517 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1519 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1518 mCurrentSyncDevice = "qtopia-XML"; 1520 mCurrentSyncDevice = "qtopia-XML";
1519 if ( mSyncManager->mAskForPreferences ) 1521 if ( mSyncManager->mAskForPreferences )
1520 edit_sync_options(); 1522 edit_sync_options();
1521 qApp->processEvents(); 1523 qApp->processEvents();
1522 CalendarLocal* calendar = new CalendarLocal(); 1524 CalendarLocal* calendar = new CalendarLocal();
1523 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1525 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1524 bool syncOK = false; 1526 bool syncOK = false;
1525 QtopiaFormat qtopiaFormat; 1527 QtopiaFormat qtopiaFormat;
1526 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1528 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1527 bool loadOk = true; 1529 bool loadOk = true;
1528 if ( !categories.isEmpty() ) 1530 if ( !categories.isEmpty() )
1529 loadOk = qtopiaFormat.load( calendar, categories ); 1531 loadOk = qtopiaFormat.load( calendar, categories );
1530 if ( loadOk && !datebook.isEmpty() ) 1532 if ( loadOk && !datebook.isEmpty() )
1531 loadOk = qtopiaFormat.load( calendar, datebook ); 1533 loadOk = qtopiaFormat.load( calendar, datebook );
1532 if ( loadOk && !todolist.isEmpty() ) 1534 if ( loadOk && !todolist.isEmpty() )
1533 loadOk = qtopiaFormat.load( calendar, todolist ); 1535 loadOk = qtopiaFormat.load( calendar, todolist );
1534 1536
1535 if ( loadOk ) { 1537 if ( loadOk ) {
1536 getEventViewerDialog()->setSyncMode( true ); 1538 getEventViewerDialog()->setSyncMode( true );
1537 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1539 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1538 getEventViewerDialog()->setSyncMode( false ); 1540 getEventViewerDialog()->setSyncMode( false );
1539 qApp->processEvents(); 1541 qApp->processEvents();
1540 if ( syncOK ) { 1542 if ( syncOK ) {
1541 if ( mSyncManager->mWriteBackFile ) 1543 if ( mSyncManager->mWriteBackFile )
1542 { 1544 {
1543 // write back XML file 1545 // write back XML file
1544 1546
1545 } 1547 }
1546 setModified( true ); 1548 setModified( true );
1547 } 1549 }
1548 } else { 1550 } else {
1549 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1551 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1550 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1552 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1551 question, i18n("Ok")) ; 1553 question, i18n("Ok")) ;
1552 } 1554 }
1553 delete calendar; 1555 delete calendar;
1554 updateView(); 1556 updateView();
1555 return syncOK; 1557 return syncOK;
1556 1558
1557 1559
1558#endif 1560#endif
1559 1561
1560} 1562}
1561 1563
1562void CalendarView::setSyncEventsReadOnly() 1564void CalendarView::setSyncEventsReadOnly()
1563{ 1565{
1564 Event * ev; 1566 Event * ev;
1565 QPtrList<Event> eL = mCalendar->rawEvents(); 1567 QPtrList<Event> eL = mCalendar->rawEvents();
1566 ev = eL.first(); 1568 ev = eL.first();
1567 while ( ev ) { 1569 while ( ev ) {
1568 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1570 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1569 ev->setReadOnly( true ); 1571 ev->setReadOnly( true );
1570 ev = eL.next(); 1572 ev = eL.next();
1571 } 1573 }
1572} 1574}
1573bool CalendarView::openCalendar(QString filename, bool merge) 1575bool CalendarView::openCalendar(QString filename, bool merge)
1574{ 1576{
1575 1577
1576 if (filename.isEmpty()) { 1578 if (filename.isEmpty()) {
1577 return false; 1579 return false;
1578 } 1580 }
1579 1581
1580 if (!QFile::exists(filename)) { 1582 if (!QFile::exists(filename)) {
1581 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1583 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1582 return false; 1584 return false;
1583 } 1585 }
1584 1586
1585 globalFlagBlockAgenda = 1; 1587 globalFlagBlockAgenda = 1;
1586 if (!merge) mCalendar->close(); 1588 if (!merge) mCalendar->close();
1587 1589
1588 mStorage->setFileName( filename ); 1590 mStorage->setFileName( filename );
1589 1591
1590 if ( mStorage->load() ) { 1592 if ( mStorage->load() ) {
1591 if ( merge ) ;//setModified( true ); 1593 if ( merge ) ;//setModified( true );
1592 else { 1594 else {
1593 //setModified( true ); 1595 //setModified( true );
1594 mViewManager->setDocumentId( filename ); 1596 mViewManager->setDocumentId( filename );
1595 mDialogManager->setDocumentId( filename ); 1597 mDialogManager->setDocumentId( filename );
1596 mTodoList->setDocumentId( filename ); 1598 mTodoList->setDocumentId( filename );
1597 } 1599 }
1598 globalFlagBlockAgenda = 2; 1600 globalFlagBlockAgenda = 2;
1599 // if ( getLastSyncEvent() ) 1601 // if ( getLastSyncEvent() )
1600 // getLastSyncEvent()->setReadOnly( true ); 1602 // getLastSyncEvent()->setReadOnly( true );
1601 mCalendar->reInitAlarmSettings(); 1603 mCalendar->reInitAlarmSettings();
1602 setSyncEventsReadOnly(); 1604 setSyncEventsReadOnly();
1603 updateUnmanagedViews(); 1605 updateUnmanagedViews();
1604 updateView(); 1606 updateView();
1605 if ( filename != MainWindow::defaultFileName() ) { 1607 if ( filename != MainWindow::defaultFileName() ) {
1606 saveCalendar( MainWindow::defaultFileName() ); 1608 saveCalendar( MainWindow::defaultFileName() );
1607 } else { 1609 } else {
1608 QFileInfo finf ( MainWindow::defaultFileName()); 1610 QFileInfo finf ( MainWindow::defaultFileName());
1609 if ( finf.exists() ) { 1611 if ( finf.exists() ) {
1610 setLoadedFileVersion( finf.lastModified () ); 1612 setLoadedFileVersion( finf.lastModified () );
1611 } 1613 }
1612 } 1614 }
1613 return true; 1615 return true;
1614 } else { 1616 } else {
1615 // while failing to load, the calendar object could 1617 // while failing to load, the calendar object could
1616 // have become partially populated. Clear it out. 1618 // have become partially populated. Clear it out.
1617 if ( !merge ) { 1619 if ( !merge ) {
1618 mCalendar->close(); 1620 mCalendar->close();
1619 mViewManager->setDocumentId( filename ); 1621 mViewManager->setDocumentId( filename );
1620 mDialogManager->setDocumentId( filename ); 1622 mDialogManager->setDocumentId( filename );
1621 mTodoList->setDocumentId( filename ); 1623 mTodoList->setDocumentId( filename );
1622 } 1624 }
1623 1625
1624 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1626 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1625 1627
1626 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1628 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1627 globalFlagBlockAgenda = 2; 1629 globalFlagBlockAgenda = 2;
1628 mCalendar->reInitAlarmSettings(); 1630 mCalendar->reInitAlarmSettings();
1629 setSyncEventsReadOnly(); 1631 setSyncEventsReadOnly();
1630 updateUnmanagedViews(); 1632 updateUnmanagedViews();
1631 updateView(); 1633 updateView();
1632 } 1634 }
1633 return false; 1635 return false;
1634} 1636}
1635void CalendarView::showOpenError() 1637void CalendarView::showOpenError()
1636{ 1638{
1637 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1639 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1638} 1640}
1639void CalendarView::setLoadedFileVersion(QDateTime dt) 1641void CalendarView::setLoadedFileVersion(QDateTime dt)
1640{ 1642{
1641 loadedFileVersion = dt; 1643 loadedFileVersion = dt;
1642} 1644}
1643bool CalendarView::checkFileChanged(QString fn) 1645bool CalendarView::checkFileChanged(QString fn)
1644{ 1646{
1645 QFileInfo finf ( fn ); 1647 QFileInfo finf ( fn );
1646 if ( !finf.exists() ) 1648 if ( !finf.exists() )
1647 return true; 1649 return true;
1648 QDateTime dt = finf.lastModified (); 1650 QDateTime dt = finf.lastModified ();
1649 if ( dt <= loadedFileVersion ) 1651 if ( dt <= loadedFileVersion )
1650 return false; 1652 return false;
1651 return true; 1653 return true;
1652 1654
1653} 1655}
1654void CalendarView::watchSavedFile() 1656void CalendarView::watchSavedFile()
1655{ 1657{
1656 QFileInfo finf ( MainWindow::defaultFileName()); 1658 QFileInfo finf ( MainWindow::defaultFileName());
1657 if ( !finf.exists() ) 1659 if ( !finf.exists() )
1658 return; 1660 return;
1659 QDateTime dt = finf.lastModified (); 1661 QDateTime dt = finf.lastModified ();
1660 if ( dt < loadedFileVersion ) { 1662 if ( dt < loadedFileVersion ) {
1661 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1663 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1662 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1664 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1663 return; 1665 return;
1664 } 1666 }
1665 loadedFileVersion = dt; 1667 loadedFileVersion = dt;
1666} 1668}
1667 1669
1668bool CalendarView::checkFileVersion(QString fn) 1670bool CalendarView::checkFileVersion(QString fn)
1669{ 1671{
1670 QFileInfo finf ( fn ); 1672 QFileInfo finf ( fn );
1671 if ( !finf.exists() ) 1673 if ( !finf.exists() )
1672 return true; 1674 return true;
1673 QDateTime dt = finf.lastModified (); 1675 QDateTime dt = finf.lastModified ();
1674 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1676 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1675 //qDebug("file on disk version %s",dt.toString().latin1()); 1677 //qDebug("file on disk version %s",dt.toString().latin1());
1676 if ( dt <= loadedFileVersion ) 1678 if ( dt <= loadedFileVersion )
1677 return true; 1679 return true;
1678 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1680 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1679 i18n("KO/Pi Warning"),i18n("Overwrite"), 1681 i18n("KO/Pi Warning"),i18n("Overwrite"),
1680 i18n("Sync+save")); 1682 i18n("Sync+save"));
1681 1683
1682 if ( km == KMessageBox::Cancel ) 1684 if ( km == KMessageBox::Cancel )
1683 return false; 1685 return false;
1684 if ( km == KMessageBox::Yes ) 1686 if ( km == KMessageBox::Yes )
1685 return true; 1687 return true;
1686 1688
1687 setSyncDevice("deleteaftersync" ); 1689 setSyncDevice("deleteaftersync" );
1688 mSyncManager->mAskForPreferences = true; 1690 mSyncManager->mAskForPreferences = true;
1689 mSyncManager->mSyncAlgoPrefs = 3; 1691 mSyncManager->mSyncAlgoPrefs = 3;
1690 mSyncManager->mWriteBackFile = false; 1692 mSyncManager->mWriteBackFile = false;
1691 mSyncManager->mWriteBackExistingOnly = false; 1693 mSyncManager->mWriteBackExistingOnly = false;
1692 mSyncManager->mShowSyncSummary = false; 1694 mSyncManager->mShowSyncSummary = false;
1693 syncCalendar( fn, 3 ); 1695 syncCalendar( fn, 3 );
1694 Event * e = getLastSyncEvent(); 1696 Event * e = getLastSyncEvent();
1695 mCalendar->deleteEvent ( e ); 1697 mCalendar->deleteEvent ( e );
1696 updateView(); 1698 updateView();
1697 return true; 1699 return true;
1698} 1700}
1699 1701
1700bool CalendarView::saveCalendar( QString filename ) 1702bool CalendarView::saveCalendar( QString filename )
1701{ 1703{
1702 1704
1703 // Store back all unsaved data into calendar object 1705 // Store back all unsaved data into calendar object
1704 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1706 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1705 if ( mViewManager->currentView() ) 1707 if ( mViewManager->currentView() )
1706 mViewManager->currentView()->flushView(); 1708 mViewManager->currentView()->flushView();
1707 1709
1708 1710
1709 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1711 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1710 mStorage->setSaveFormat( new ICalFormat() ); 1712 mStorage->setSaveFormat( new ICalFormat() );
1711 mStorage->setFileName( filename ); 1713 mStorage->setFileName( filename );
1712 bool success; 1714 bool success;
1713 success = mStorage->save(); 1715 success = mStorage->save();
1714 if ( !success ) { 1716 if ( !success ) {
1715 return false; 1717 return false;
1716 } 1718 }
1717 if ( filename == MainWindow::defaultFileName() ) { 1719 if ( filename == MainWindow::defaultFileName() ) {
1718 setLoadedFileVersion( lfv ); 1720 setLoadedFileVersion( lfv );
1719 watchSavedFile(); 1721 watchSavedFile();
1720 } 1722 }
1721 return true; 1723 return true;
1722} 1724}
1723 1725
1724void CalendarView::closeCalendar() 1726void CalendarView::closeCalendar()
1725{ 1727{
1726 1728
1727 // child windows no longer valid 1729 // child windows no longer valid
1728 emit closingDown(); 1730 emit closingDown();
1729 1731
1730 mCalendar->close(); 1732 mCalendar->close();
1731 setModified(false); 1733 setModified(false);
1732 updateView(); 1734 updateView();
1733} 1735}
1734 1736
1735void CalendarView::archiveCalendar() 1737void CalendarView::archiveCalendar()
1736{ 1738{
1737 mDialogManager->showArchiveDialog(); 1739 mDialogManager->showArchiveDialog();
1738} 1740}
1739 1741
1740 1742
1741void CalendarView::readSettings() 1743void CalendarView::readSettings()
1742{ 1744{
1743 1745
1744 1746
1745 // mViewManager->showAgendaView(); 1747 // mViewManager->showAgendaView();
1746 QString str; 1748 QString str;
1747 //qDebug("CalendarView::readSettings() "); 1749 //qDebug("CalendarView::readSettings() ");
1748 // read settings from the KConfig, supplying reasonable 1750 // read settings from the KConfig, supplying reasonable
1749 // defaults where none are to be found 1751 // defaults where none are to be found
1750 KConfig *config = KOGlobals::config(); 1752 KConfig *config = KOGlobals::config();
1751#ifndef KORG_NOSPLITTER 1753#ifndef KORG_NOSPLITTER
1752 config->setGroup("KOrganizer Geometry"); 1754 config->setGroup("KOrganizer Geometry");
1753 1755
1754 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1756 QValueList<int> sizes = config->readIntListEntry("Separator1");
1755 if (sizes.count() != 2) { 1757 if (sizes.count() != 2) {
1756 sizes << mDateNavigator->minimumSizeHint().width(); 1758 sizes << mDateNavigator->minimumSizeHint().width();
1757 sizes << 300; 1759 sizes << 300;
1758 } 1760 }
1759 mPanner->setSizes(sizes); 1761 mPanner->setSizes(sizes);
1760 1762
1761 sizes = config->readIntListEntry("Separator2"); 1763 sizes = config->readIntListEntry("Separator2");
1762 if ( ( mResourceView && sizes.count() == 4 ) || 1764 if ( ( mResourceView && sizes.count() == 4 ) ||
1763 ( !mResourceView && sizes.count() == 3 ) ) { 1765 ( !mResourceView && sizes.count() == 3 ) ) {
1764 mLeftSplitter->setSizes(sizes); 1766 mLeftSplitter->setSizes(sizes);
1765 } 1767 }
1766#endif 1768#endif
1767 globalFlagBlockAgenda = 1; 1769 globalFlagBlockAgenda = 1;
1768 mViewManager->showAgendaView(); 1770 mViewManager->showAgendaView();
1769 //mViewManager->readSettings( config ); 1771 //mViewManager->readSettings( config );
1770 mTodoList->restoreLayout(config,QString("Todo Layout")); 1772 mTodoList->restoreLayout(config,QString("Todo Layout"));
1771 readFilterSettings(config); 1773 readFilterSettings(config);
1772 config->setGroup( "Views" ); 1774 config->setGroup( "Views" );
1773 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1775 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1774 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1776 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1775 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1777 else if ( dateCount == 7 ) mNavigator->selectWeek();
1776 else mNavigator->selectDates( dateCount ); 1778 else mNavigator->selectDates( dateCount );
1777 // mViewManager->readSettings( config ); 1779 // mViewManager->readSettings( config );
1778 updateConfig(); 1780 updateConfig();
1779 globalFlagBlockAgenda = 2; 1781 globalFlagBlockAgenda = 2;
1780 mViewManager->readSettings( config ); 1782 mViewManager->readSettings( config );
1781#ifdef DESKTOP_VERSION 1783#ifdef DESKTOP_VERSION
1782 config->setGroup("WidgetLayout"); 1784 config->setGroup("WidgetLayout");
1783 QStringList list; 1785 QStringList list;
1784 list = config->readListEntry("MainLayout"); 1786 list = config->readListEntry("MainLayout");
1785 int x,y,w,h; 1787 int x,y,w,h;
1786 if ( ! list.isEmpty() ) { 1788 if ( ! list.isEmpty() ) {
1787 x = list[0].toInt(); 1789 x = list[0].toInt();
1788 y = list[1].toInt(); 1790 y = list[1].toInt();
1789 w = list[2].toInt(); 1791 w = list[2].toInt();
1790 h = list[3].toInt(); 1792 h = list[3].toInt();
1791 topLevelWidget()->setGeometry(x,y,w,h); 1793 topLevelWidget()->setGeometry(x,y,w,h);
1792 1794
1793 } else { 1795 } else {
1794 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1796 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1795 } 1797 }
1796 list = config->readListEntry("EditEventLayout"); 1798 list = config->readListEntry("EditEventLayout");
1797 if ( ! list.isEmpty() ) { 1799 if ( ! list.isEmpty() ) {
1798 x = list[0].toInt(); 1800 x = list[0].toInt();
1799 y = list[1].toInt(); 1801 y = list[1].toInt();
1800 w = list[2].toInt(); 1802 w = list[2].toInt();
1801 h = list[3].toInt(); 1803 h = list[3].toInt();
1802 mEventEditor->setGeometry(x,y,w,h); 1804 mEventEditor->setGeometry(x,y,w,h);
1803 1805
1804 } 1806 }
1805 list = config->readListEntry("EditTodoLayout"); 1807 list = config->readListEntry("EditTodoLayout");
1806 if ( ! list.isEmpty() ) { 1808 if ( ! list.isEmpty() ) {
1807 x = list[0].toInt(); 1809 x = list[0].toInt();
1808 y = list[1].toInt(); 1810 y = list[1].toInt();
1809 w = list[2].toInt(); 1811 w = list[2].toInt();
1810 h = list[3].toInt(); 1812 h = list[3].toInt();
1811 mTodoEditor->setGeometry(x,y,w,h); 1813 mTodoEditor->setGeometry(x,y,w,h);
1812 1814
1813 } 1815 }
1814 list = config->readListEntry("ViewerLayout"); 1816 list = config->readListEntry("ViewerLayout");
1815 if ( ! list.isEmpty() ) { 1817 if ( ! list.isEmpty() ) {
1816 x = list[0].toInt(); 1818 x = list[0].toInt();
1817 y = list[1].toInt(); 1819 y = list[1].toInt();
1818 w = list[2].toInt(); 1820 w = list[2].toInt();
1819 h = list[3].toInt(); 1821 h = list[3].toInt();
1820 getEventViewerDialog()->setGeometry(x,y,w,h); 1822 getEventViewerDialog()->setGeometry(x,y,w,h);
1821 } 1823 }
1822#endif 1824#endif
1823 1825
1824} 1826}
1825 1827
1826 1828
1827void CalendarView::writeSettings() 1829void CalendarView::writeSettings()
1828{ 1830{
1829 // kdDebug() << "CalendarView::writeSettings" << endl; 1831 // kdDebug() << "CalendarView::writeSettings" << endl;
1830 1832
1831 KConfig *config = KOGlobals::config(); 1833 KConfig *config = KOGlobals::config();
1832 1834
1833#ifndef KORG_NOSPLITTER 1835#ifndef KORG_NOSPLITTER
1834 config->setGroup("KOrganizer Geometry"); 1836 config->setGroup("KOrganizer Geometry");
1835 1837
1836 QValueList<int> list = mPanner->sizes(); 1838 QValueList<int> list = mPanner->sizes();
1837 config->writeEntry("Separator1",list); 1839 config->writeEntry("Separator1",list);
1838 1840
1839 list = mLeftSplitter->sizes(); 1841 list = mLeftSplitter->sizes();
1840 config->writeEntry("Separator2",list); 1842 config->writeEntry("Separator2",list);
1841#endif 1843#endif
1842 1844
1843 mViewManager->writeSettings( config ); 1845 mViewManager->writeSettings( config );
1844 mTodoList->saveLayout(config,QString("Todo Layout")); 1846 mTodoList->saveLayout(config,QString("Todo Layout"));
1845 mDialogManager->writeSettings( config ); 1847 mDialogManager->writeSettings( config );
1846 //KOPrefs::instance()->usrWriteConfig(); 1848 //KOPrefs::instance()->usrWriteConfig();
1847 KOPrefs::instance()->writeConfig(); 1849 KOPrefs::instance()->writeConfig();
1848 1850
1849 writeFilterSettings(config); 1851 writeFilterSettings(config);
1850 1852
1851 config->setGroup( "Views" ); 1853 config->setGroup( "Views" );
1852 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1854 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1853 1855
1854#ifdef DESKTOP_VERSION 1856#ifdef DESKTOP_VERSION
1855 config->setGroup("WidgetLayout"); 1857 config->setGroup("WidgetLayout");
1856 QStringList list ;//= config->readListEntry("MainLayout"); 1858 QStringList list ;//= config->readListEntry("MainLayout");
1857 int x,y,w,h; 1859 int x,y,w,h;
1858 QWidget* wid; 1860 QWidget* wid;
1859 wid = topLevelWidget(); 1861 wid = topLevelWidget();
1860 x = wid->geometry().x(); 1862 x = wid->geometry().x();
1861 y = wid->geometry().y(); 1863 y = wid->geometry().y();
1862 w = wid->width(); 1864 w = wid->width();
1863 h = wid->height(); 1865 h = wid->height();
1864 list.clear(); 1866 list.clear();
1865 list << QString::number( x ); 1867 list << QString::number( x );
1866 list << QString::number( y ); 1868 list << QString::number( y );
1867 list << QString::number( w ); 1869 list << QString::number( w );
1868 list << QString::number( h ); 1870 list << QString::number( h );
1869 config->writeEntry("MainLayout",list ); 1871 config->writeEntry("MainLayout",list );
1870 1872
1871 wid = mEventEditor; 1873 wid = mEventEditor;
1872 x = wid->geometry().x(); 1874 x = wid->geometry().x();
1873 y = wid->geometry().y(); 1875 y = wid->geometry().y();
1874 w = wid->width(); 1876 w = wid->width();
1875 h = wid->height(); 1877 h = wid->height();
1876 list.clear(); 1878 list.clear();
1877 list << QString::number( x ); 1879 list << QString::number( x );
1878 list << QString::number( y ); 1880 list << QString::number( y );
1879 list << QString::number( w ); 1881 list << QString::number( w );
1880 list << QString::number( h ); 1882 list << QString::number( h );
1881 config->writeEntry("EditEventLayout",list ); 1883 config->writeEntry("EditEventLayout",list );
1882 1884
1883 wid = mTodoEditor; 1885 wid = mTodoEditor;
1884 x = wid->geometry().x(); 1886 x = wid->geometry().x();
1885 y = wid->geometry().y(); 1887 y = wid->geometry().y();
1886 w = wid->width(); 1888 w = wid->width();
1887 h = wid->height(); 1889 h = wid->height();
1888 list.clear(); 1890 list.clear();
1889 list << QString::number( x ); 1891 list << QString::number( x );
1890 list << QString::number( y ); 1892 list << QString::number( y );
1891 list << QString::number( w ); 1893 list << QString::number( w );
1892 list << QString::number( h ); 1894 list << QString::number( h );
1893 config->writeEntry("EditTodoLayout",list ); 1895 config->writeEntry("EditTodoLayout",list );
1894 wid = getEventViewerDialog(); 1896 wid = getEventViewerDialog();
1895 x = wid->geometry().x(); 1897 x = wid->geometry().x();
1896 y = wid->geometry().y(); 1898 y = wid->geometry().y();
1897 w = wid->width(); 1899 w = wid->width();
1898 h = wid->height(); 1900 h = wid->height();
1899 list.clear(); 1901 list.clear();
1900 list << QString::number( x ); 1902 list << QString::number( x );
1901 list << QString::number( y ); 1903 list << QString::number( y );
1902 list << QString::number( w ); 1904 list << QString::number( w );
1903 list << QString::number( h ); 1905 list << QString::number( h );
1904 config->writeEntry("ViewerLayout",list ); 1906 config->writeEntry("ViewerLayout",list );
1905 wid = mDialogManager->getSearchDialog(); 1907 wid = mDialogManager->getSearchDialog();
1906 if ( wid ) { 1908 if ( wid ) {
1907 x = wid->geometry().x(); 1909 x = wid->geometry().x();
1908 y = wid->geometry().y(); 1910 y = wid->geometry().y();
1909 w = wid->width(); 1911 w = wid->width();
1910 h = wid->height(); 1912 h = wid->height();
1911 list.clear(); 1913 list.clear();
1912 list << QString::number( x ); 1914 list << QString::number( x );
1913 list << QString::number( y ); 1915 list << QString::number( y );
1914 list << QString::number( w ); 1916 list << QString::number( w );
1915 list << QString::number( h ); 1917 list << QString::number( h );
1916 config->writeEntry("SearchLayout",list ); 1918 config->writeEntry("SearchLayout",list );
1917 } 1919 }
1918#endif 1920#endif
1919 1921
1920 1922
1921 config->sync(); 1923 config->sync();
1922} 1924}
1923 1925
1924void CalendarView::readFilterSettings(KConfig *config) 1926void CalendarView::readFilterSettings(KConfig *config)
1925{ 1927{
1926 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1928 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1927 1929
1928 mFilters.clear(); 1930 mFilters.clear();
1929 1931
1930 config->setGroup("General"); 1932 config->setGroup("General");
1931 QStringList filterList = config->readListEntry("CalendarFilters"); 1933 QStringList filterList = config->readListEntry("CalendarFilters");
1932 1934
1933 QStringList::ConstIterator it = filterList.begin(); 1935 QStringList::ConstIterator it = filterList.begin();
1934 QStringList::ConstIterator end = filterList.end(); 1936 QStringList::ConstIterator end = filterList.end();
1935 while(it != end) { 1937 while(it != end) {
1936 // kdDebug() << " filter: " << (*it) << endl; 1938 // kdDebug() << " filter: " << (*it) << endl;
1937 1939
1938 CalFilter *filter; 1940 CalFilter *filter;
1939 filter = new CalFilter(*it); 1941 filter = new CalFilter(*it);
1940 config->setGroup("Filter_" + (*it)); 1942 config->setGroup("Filter_" + (*it));
1941 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1943 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1942 filter->setCriteria(config->readNumEntry("Criteria",0)); 1944 filter->setCriteria(config->readNumEntry("Criteria",0));
1943 filter->setCategoryList(config->readListEntry("CategoryList")); 1945 filter->setCategoryList(config->readListEntry("CategoryList"));
1944 mFilters.append(filter); 1946 mFilters.append(filter);
1945 1947
1946 ++it; 1948 ++it;
1947 } 1949 }
1948 1950
1949 if (mFilters.count() == 0) { 1951 if (mFilters.count() == 0) {
1950 CalFilter *filter = new CalFilter(i18n("Default")); 1952 CalFilter *filter = new CalFilter(i18n("Default"));
1951 mFilters.append(filter); 1953 mFilters.append(filter);
1952 } 1954 }
1953 mFilterView->updateFilters(); 1955 mFilterView->updateFilters();
1954 config->setGroup("FilterView"); 1956 config->setGroup("FilterView");
1955 1957
1956 mFilterView->blockSignals(true); 1958 mFilterView->blockSignals(true);
1957 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1959 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1958 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1960 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1959 mFilterView->blockSignals(false); 1961 mFilterView->blockSignals(false);
1960 // We do it manually to avoid it being done twice by the above calls 1962 // We do it manually to avoid it being done twice by the above calls
1961 updateFilter(); 1963 updateFilter();
1962} 1964}
1963 1965
1964void CalendarView::writeFilterSettings(KConfig *config) 1966void CalendarView::writeFilterSettings(KConfig *config)
1965{ 1967{
1966 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1968 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1967 1969
1968 QStringList filterList; 1970 QStringList filterList;
1969 1971
1970 CalFilter *filter = mFilters.first(); 1972 CalFilter *filter = mFilters.first();
1971 while(filter) { 1973 while(filter) {
1972 // kdDebug() << " fn: " << filter->name() << endl; 1974 // kdDebug() << " fn: " << filter->name() << endl;
1973 filterList << filter->name(); 1975 filterList << filter->name();
1974 config->setGroup("Filter_" + filter->name()); 1976 config->setGroup("Filter_" + filter->name());
1975 config->writeEntry("Criteria",filter->criteria()); 1977 config->writeEntry("Criteria",filter->criteria());
1976 config->writeEntry("CategoryList",filter->categoryList()); 1978 config->writeEntry("CategoryList",filter->categoryList());
1977 filter = mFilters.next(); 1979 filter = mFilters.next();
1978 } 1980 }
1979 config->setGroup("General"); 1981 config->setGroup("General");
1980 config->writeEntry("CalendarFilters",filterList); 1982 config->writeEntry("CalendarFilters",filterList);
1981 1983
1982 config->setGroup("FilterView"); 1984 config->setGroup("FilterView");
1983 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1985 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1984 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1986 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1985} 1987}
1986 1988
1987 1989
1988void CalendarView::goToday() 1990void CalendarView::goToday()
1989{ 1991{
1990 mNavigator->selectToday(); 1992 mNavigator->selectToday();
1991} 1993}
1992 1994
1993void CalendarView::goNext() 1995void CalendarView::goNext()
1994{ 1996{
1995 mNavigator->selectNext(); 1997 mNavigator->selectNext();
1996} 1998}
1997 1999
1998void CalendarView::goPrevious() 2000void CalendarView::goPrevious()
1999{ 2001{
2000 mNavigator->selectPrevious(); 2002 mNavigator->selectPrevious();
2001} 2003}
2002void CalendarView::goNextMonth() 2004void CalendarView::goNextMonth()
2003{ 2005{
2004 mNavigator->selectNextMonth(); 2006 mNavigator->selectNextMonth();
2005} 2007}
2006 2008
2007void CalendarView::goPreviousMonth() 2009void CalendarView::goPreviousMonth()
2008{ 2010{
2009 mNavigator->selectPreviousMonth(); 2011 mNavigator->selectPreviousMonth();
2010} 2012}
2011void CalendarView::writeLocale() 2013void CalendarView::writeLocale()
2012{ 2014{
2013 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2015 //KPimGlobalPrefs::instance()->setGlobalConfig();
2014#if 0 2016#if 0
2015 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2017 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2016 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2018 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2017 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2019 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2018 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2020 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2019 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2021 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2020 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2022 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2021 dummy = KOPrefs::instance()->mUserDateFormatShort; 2023 dummy = KOPrefs::instance()->mUserDateFormatShort;
2022 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2024 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2023 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2025 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2024 KOPrefs::instance()->mDaylightsavingStart, 2026 KOPrefs::instance()->mDaylightsavingStart,
2025 KOPrefs::instance()->mDaylightsavingEnd ); 2027 KOPrefs::instance()->mDaylightsavingEnd );
2026 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2028 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2027#endif 2029#endif
2028} 2030}
2029void CalendarView::updateConfig() 2031void CalendarView::updateConfig()
2030{ 2032{
2031 writeLocale(); 2033 writeLocale();
2032 if ( KOPrefs::instance()->mUseAppColors ) 2034 if ( KOPrefs::instance()->mUseAppColors )
2033 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2035 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2034 emit configChanged(); 2036 emit configChanged();
2035 mTodoList->updateConfig(); 2037 mTodoList->updateConfig();
2036 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2038 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2037 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2039 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2038 // To make the "fill window" configurations work 2040 // To make the "fill window" configurations work
2039 //mViewManager->raiseCurrentView(); 2041 //mViewManager->raiseCurrentView();
2040} 2042}
2041 2043
2042 2044
2043void CalendarView::eventChanged(Event *event) 2045void CalendarView::eventChanged(Event *event)
2044{ 2046{
2045 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2047 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2046 //updateUnmanagedViews(); 2048 //updateUnmanagedViews();
2047} 2049}
2048 2050
2049void CalendarView::eventAdded(Event *event) 2051void CalendarView::eventAdded(Event *event)
2050{ 2052{
2051 changeEventDisplay(event,KOGlobals::EVENTADDED); 2053 changeEventDisplay(event,KOGlobals::EVENTADDED);
2052} 2054}
2053 2055
2054void CalendarView::eventToBeDeleted(Event *) 2056void CalendarView::eventToBeDeleted(Event *)
2055{ 2057{
2056 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2058 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2057} 2059}
2058 2060
2059void CalendarView::eventDeleted() 2061void CalendarView::eventDeleted()
2060{ 2062{
2061 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2063 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2062} 2064}
2063void CalendarView::changeTodoDisplay(Todo *which, int action) 2065void CalendarView::changeTodoDisplay(Todo *which, int action)
2064{ 2066{
2065 changeIncidenceDisplay((Incidence *)which, action); 2067 changeIncidenceDisplay((Incidence *)which, action);
2066 mDateNavigator->updateView(); //LR 2068 mDateNavigator->updateView(); //LR
2067 //mDialogManager->updateSearchDialog(); 2069 //mDialogManager->updateSearchDialog();
2068 2070
2069 if (which) { 2071 if (which) {
2070 mViewManager->updateWNview(); 2072 mViewManager->updateWNview();
2071 //mTodoList->updateView(); 2073 //mTodoList->updateView();
2072 } 2074 }
2073 2075
2074} 2076}
2075 2077
2076void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2078void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2077{ 2079{
2078 updateUnmanagedViews(); 2080 updateUnmanagedViews();
2079 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2081 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2080 if ( action == KOGlobals::EVENTDELETED ) { //delete 2082 if ( action == KOGlobals::EVENTDELETED ) { //delete
2081 mCalendar->checkAlarmForIncidence( 0, true ); 2083 mCalendar->checkAlarmForIncidence( 0, true );
2082 if ( mEventViewerDialog ) 2084 if ( mEventViewerDialog )
2083 mEventViewerDialog->hide(); 2085 mEventViewerDialog->hide();
2084 } 2086 }
2085 else 2087 else
2086 mCalendar->checkAlarmForIncidence( which , false ); 2088 mCalendar->checkAlarmForIncidence( which , false );
2087} 2089}
2088 2090
2089// most of the changeEventDisplays() right now just call the view's 2091// most of the changeEventDisplays() right now just call the view's
2090// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2092// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2091void CalendarView::changeEventDisplay(Event *which, int action) 2093void CalendarView::changeEventDisplay(Event *which, int action)
2092{ 2094{
2093 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2095 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2094 changeIncidenceDisplay((Incidence *)which, action); 2096 changeIncidenceDisplay((Incidence *)which, action);
2095 mDateNavigator->updateView(); 2097 mDateNavigator->updateView();
2096 //mDialogManager->updateSearchDialog(); 2098 //mDialogManager->updateSearchDialog();
2097 2099
2098 if (which) { 2100 if (which) {
2099 // If there is an event view visible update the display 2101 // If there is an event view visible update the display
2100 mViewManager->currentView()->changeEventDisplay(which,action); 2102 mViewManager->currentView()->changeEventDisplay(which,action);
2101 // TODO: check, if update needed 2103 // TODO: check, if update needed
2102 // if (which->getTodoStatus()) { 2104 // if (which->getTodoStatus()) {
2103 mTodoList->updateView(); 2105 mTodoList->updateView();
2104 // } 2106 // }
2105 } else { 2107 } else {
2106 mViewManager->currentView()->updateView(); 2108 mViewManager->currentView()->updateView();
2107 } 2109 }
2108} 2110}
2109 2111
2110 2112
2111void CalendarView::updateTodoViews() 2113void CalendarView::updateTodoViews()
2112{ 2114{
2113 2115
2114 mTodoList->updateView(); 2116 mTodoList->updateView();
2115 mViewManager->currentView()->updateView(); 2117 mViewManager->currentView()->updateView();
2116 2118
2117} 2119}
2118 2120
2119 2121
2120void CalendarView::updateView(const QDate &start, const QDate &end) 2122void CalendarView::updateView(const QDate &start, const QDate &end)
2121{ 2123{
2122 mTodoList->updateView(); 2124 mTodoList->updateView();
2123 mViewManager->updateView(start, end); 2125 mViewManager->updateView(start, end);
2124 //mDateNavigator->updateView(); 2126 //mDateNavigator->updateView();
2125} 2127}
2126 2128
2127void CalendarView::updateView() 2129void CalendarView::updateView()
2128{ 2130{
2129 DateList tmpList = mNavigator->selectedDates(); 2131 DateList tmpList = mNavigator->selectedDates();
2130 2132
2131 // We assume that the navigator only selects consecutive days. 2133 // We assume that the navigator only selects consecutive days.
2132 updateView( tmpList.first(), tmpList.last() ); 2134 updateView( tmpList.first(), tmpList.last() );
2133} 2135}
2134 2136
2135void CalendarView::updateUnmanagedViews() 2137void CalendarView::updateUnmanagedViews()
2136{ 2138{
2137 mDateNavigator->updateDayMatrix(); 2139 mDateNavigator->updateDayMatrix();
2138} 2140}
2139 2141
2140int CalendarView::msgItemDelete() 2142int CalendarView::msgItemDelete()
2141{ 2143{
2142 return KMessageBox::warningContinueCancel(this, 2144 return KMessageBox::warningContinueCancel(this,
2143 i18n("This item will be\npermanently deleted."), 2145 i18n("This item will be\npermanently deleted."),
2144 i18n("KO/Pi Confirmation"),i18n("Delete")); 2146 i18n("KO/Pi Confirmation"),i18n("Delete"));
2145} 2147}
2146 2148
2147 2149
2148void CalendarView::edit_cut() 2150void CalendarView::edit_cut()
2149{ 2151{
2150 Event *anEvent=0; 2152 Event *anEvent=0;
2151 2153
2152 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2154 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2153 2155
2154 if (mViewManager->currentView()->isEventView()) { 2156 if (mViewManager->currentView()->isEventView()) {
2155 if ( incidence && incidence->type() == "Event" ) { 2157 if ( incidence && incidence->type() == "Event" ) {
2156 anEvent = static_cast<Event *>(incidence); 2158 anEvent = static_cast<Event *>(incidence);
2157 } 2159 }
2158 } 2160 }
2159 2161
2160 if (!anEvent) { 2162 if (!anEvent) {
2161 KNotifyClient::beep(); 2163 KNotifyClient::beep();
2162 return; 2164 return;
2163 } 2165 }
2164 DndFactory factory( mCalendar ); 2166 DndFactory factory( mCalendar );
2165 factory.cutEvent(anEvent); 2167 factory.cutEvent(anEvent);
2166 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2168 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2167} 2169}
2168 2170
2169void CalendarView::edit_copy() 2171void CalendarView::edit_copy()
2170{ 2172{
2171 Event *anEvent=0; 2173 Event *anEvent=0;
2172 2174
2173 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2175 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2174 2176
2175 if (mViewManager->currentView()->isEventView()) { 2177 if (mViewManager->currentView()->isEventView()) {
2176 if ( incidence && incidence->type() == "Event" ) { 2178 if ( incidence && incidence->type() == "Event" ) {
2177 anEvent = static_cast<Event *>(incidence); 2179 anEvent = static_cast<Event *>(incidence);
2178 } 2180 }
2179 } 2181 }
2180 2182
2181 if (!anEvent) { 2183 if (!anEvent) {
2182 KNotifyClient::beep(); 2184 KNotifyClient::beep();
2183 return; 2185 return;
2184 } 2186 }
2185 DndFactory factory( mCalendar ); 2187 DndFactory factory( mCalendar );
2186 factory.copyEvent(anEvent); 2188 factory.copyEvent(anEvent);
2187} 2189}
2188 2190
2189void CalendarView::edit_paste() 2191void CalendarView::edit_paste()
2190{ 2192{
2191 QDate date = mNavigator->selectedDates().first(); 2193 QDate date = mNavigator->selectedDates().first();
2192 2194
2193 DndFactory factory( mCalendar ); 2195 DndFactory factory( mCalendar );
2194 Event *pastedEvent = factory.pasteEvent( date ); 2196 Event *pastedEvent = factory.pasteEvent( date );
2195 2197
2196 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2198 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2197} 2199}
2198 2200
2199void CalendarView::edit_options() 2201void CalendarView::edit_options()
2200{ 2202{
2201 mDialogManager->showOptionsDialog(); 2203 mDialogManager->showOptionsDialog();
2202 //writeSettings(); 2204 //writeSettings();
2203} 2205}
2204 2206
2205void CalendarView::slotSelectPickerDate( QDate d) 2207void CalendarView::slotSelectPickerDate( QDate d)
2206{ 2208{
2207 mDateFrame->hide(); 2209 mDateFrame->hide();
2208 if ( mDatePickerMode == 1 ) { 2210 if ( mDatePickerMode == 1 ) {
2209 mNavigator->slotDaySelect( d ); 2211 mNavigator->slotDaySelect( d );
2210 } else if ( mDatePickerMode == 2 ) { 2212 } else if ( mDatePickerMode == 2 ) {
2211 if ( mMoveIncidence->type() == "Todo" ) { 2213 if ( mMoveIncidence->type() == "Todo" ) {
2212 Todo * to = (Todo *) mMoveIncidence; 2214 Todo * to = (Todo *) mMoveIncidence;
2213 QTime tim; 2215 QTime tim;
2214 if ( to->hasDueDate() ) 2216 if ( to->hasDueDate() )
2215 tim = to->dtDue().time(); 2217 tim = to->dtDue().time();
2216 else { 2218 else {
2217 tim = QTime ( 0,0,0 ); 2219 tim = QTime ( 0,0,0 );
2218 to->setFloats( true ); 2220 to->setFloats( true );
2219 to->setHasDueDate( true ); 2221 to->setHasDueDate( true );
2220 } 2222 }
2221 QDateTime dt ( d,tim ); 2223 QDateTime dt ( d,tim );
2222 to->setDtDue( dt ); 2224 to->setDtDue( dt );
2223 todoChanged( to ); 2225 todoChanged( to );
2224 } else { 2226 } else {
2225 QTime tim = mMoveIncidence->dtStart().time(); 2227 QTime tim = mMoveIncidence->dtStart().time();
2226 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2228 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2227 QDateTime dt ( d,tim ); 2229 QDateTime dt ( d,tim );
2228 mMoveIncidence->setDtStart( dt ); 2230 mMoveIncidence->setDtStart( dt );
2229 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2231 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2230 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2232 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2231 } 2233 }
2232 2234
2233 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2235 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2234 } 2236 }
2235} 2237}
2236 2238
2237void CalendarView::removeCategories() 2239void CalendarView::removeCategories()
2238{ 2240{
2239 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2241 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2240 QStringList catList = KOPrefs::instance()->mCustomCategories; 2242 QStringList catList = KOPrefs::instance()->mCustomCategories;
2241 QStringList catIncList; 2243 QStringList catIncList;
2242 QStringList newCatList; 2244 QStringList newCatList;
2243 Incidence* inc = incList.first(); 2245 Incidence* inc = incList.first();
2244 int i; 2246 int i;
2245 int count = 0; 2247 int count = 0;
2246 while ( inc ) { 2248 while ( inc ) {
2247 newCatList.clear(); 2249 newCatList.clear();
2248 catIncList = inc->categories() ; 2250 catIncList = inc->categories() ;
2249 for( i = 0; i< catIncList.count(); ++i ) { 2251 for( i = 0; i< catIncList.count(); ++i ) {
2250 if ( catList.contains (catIncList[i])) 2252 if ( catList.contains (catIncList[i]))
2251 newCatList.append( catIncList[i] ); 2253 newCatList.append( catIncList[i] );
2252 } 2254 }
2253 newCatList.sort(); 2255 newCatList.sort();
2254 inc->setCategories( newCatList.join(",") ); 2256 inc->setCategories( newCatList.join(",") );
2255 inc = incList.next(); 2257 inc = incList.next();
2256 } 2258 }
2257} 2259}
2258 2260
2259int CalendarView::addCategories() 2261int CalendarView::addCategories()
2260{ 2262{
2261 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2263 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2262 QStringList catList = KOPrefs::instance()->mCustomCategories; 2264 QStringList catList = KOPrefs::instance()->mCustomCategories;
2263 QStringList catIncList; 2265 QStringList catIncList;
2264 Incidence* inc = incList.first(); 2266 Incidence* inc = incList.first();
2265 int i; 2267 int i;
2266 int count = 0; 2268 int count = 0;
2267 while ( inc ) { 2269 while ( inc ) {
2268 catIncList = inc->categories() ; 2270 catIncList = inc->categories() ;
2269 for( i = 0; i< catIncList.count(); ++i ) { 2271 for( i = 0; i< catIncList.count(); ++i ) {
2270 if ( !catList.contains (catIncList[i])) { 2272 if ( !catList.contains (catIncList[i])) {
2271 catList.append( catIncList[i] ); 2273 catList.append( catIncList[i] );
2272 //qDebug("add cat %s ", catIncList[i].latin1()); 2274 //qDebug("add cat %s ", catIncList[i].latin1());
2273 ++count; 2275 ++count;
2274 } 2276 }
2275 } 2277 }
2276 inc = incList.next(); 2278 inc = incList.next();
2277 } 2279 }
2278 catList.sort(); 2280 catList.sort();
2279 KOPrefs::instance()->mCustomCategories = catList; 2281 KOPrefs::instance()->mCustomCategories = catList;
2280 return count; 2282 return count;
2281} 2283}
2282 2284
2283void CalendarView::manageCategories() 2285void CalendarView::manageCategories()
2284{ 2286{
2285 KOCatPrefs* cp = new KOCatPrefs(); 2287 KOCatPrefs* cp = new KOCatPrefs();
2286 cp->show(); 2288 cp->show();
2287 int w =cp->sizeHint().width() ; 2289 int w =cp->sizeHint().width() ;
2288 int h = cp->sizeHint().height() ; 2290 int h = cp->sizeHint().height() ;
2289 int dw = QApplication::desktop()->width(); 2291 int dw = QApplication::desktop()->width();
2290 int dh = QApplication::desktop()->height(); 2292 int dh = QApplication::desktop()->height();
2291 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2293 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2292 if ( !cp->exec() ) { 2294 if ( !cp->exec() ) {
2293 delete cp; 2295 delete cp;
2294 return; 2296 return;
2295 } 2297 }
2296 int count = 0; 2298 int count = 0;
2297 if ( cp->addCat() ) { 2299 if ( cp->addCat() ) {
2298 count = addCategories(); 2300 count = addCategories();
2299 if ( count ) { 2301 if ( count ) {
2300 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2302 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2301 writeSettings(); 2303 writeSettings();
2302 } 2304 }
2303 } else { 2305 } else {
2304 removeCategories(); 2306 removeCategories();
2305 updateView(); 2307 updateView();
2306 } 2308 }
2307 delete cp; 2309 delete cp;
2308} 2310}
2309 2311
2310void CalendarView::beamIncidence(Incidence * Inc) 2312void CalendarView::beamIncidence(Incidence * Inc)
2311{ 2313{
2312 QPtrList<Incidence> delSel ; 2314 QPtrList<Incidence> delSel ;
2313 delSel.append(Inc); 2315 delSel.append(Inc);
2314 beamIncidenceList( delSel ); 2316 beamIncidenceList( delSel );
2315} 2317}
2316void CalendarView::beamCalendar() 2318void CalendarView::beamCalendar()
2317{ 2319{
2318 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2320 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2319 //qDebug("beamCalendar() "); 2321 //qDebug("beamCalendar() ");
2320 beamIncidenceList( delSel ); 2322 beamIncidenceList( delSel );
2321} 2323}
2322void CalendarView::beamFilteredCalendar() 2324void CalendarView::beamFilteredCalendar()
2323{ 2325{
2324 QPtrList<Incidence> delSel = mCalendar->incidences(); 2326 QPtrList<Incidence> delSel = mCalendar->incidences();
2325 //qDebug("beamFilteredCalendar() "); 2327 //qDebug("beamFilteredCalendar() ");
2326 beamIncidenceList( delSel ); 2328 beamIncidenceList( delSel );
2327} 2329}
2328void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2330void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2329{ 2331{
2330 if ( beamDialog->exec () == QDialog::Rejected ) 2332 if ( beamDialog->exec () == QDialog::Rejected )
2331 return; 2333 return;
2332#ifdef DESKTOP_VERSION 2334#ifdef DESKTOP_VERSION
2333 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2335 QString fn = locateLocal( "tmp", "kopibeamfile" );
2334#else 2336#else
2335 QString fn = "/tmp/kopibeamfile"; 2337 QString fn = "/tmp/kopibeamfile";
2336#endif 2338#endif
2337 QString mes; 2339 QString mes;
2338 bool createbup = true; 2340 bool createbup = true;
2339 if ( createbup ) { 2341 if ( createbup ) {
2340 QString description = "\n"; 2342 QString description = "\n";
2341 CalendarLocal* cal = new CalendarLocal(); 2343 CalendarLocal* cal = new CalendarLocal();
2342 if ( beamDialog->beamLocal() ) 2344 if ( beamDialog->beamLocal() )
2343 cal->setLocalTime(); 2345 cal->setLocalTime();
2344 else 2346 else
2345 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2347 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2346 Incidence *incidence = delSel.first(); 2348 Incidence *incidence = delSel.first();
2347 bool addText = false; 2349 bool addText = false;
2348 if ( delSel.count() < 10 ) 2350 if ( delSel.count() < 10 )
2349 addText = true; 2351 addText = true;
2350 else { 2352 else {
2351 description.sprintf(i18n(" %d items?"),delSel.count() ); 2353 description.sprintf(i18n(" %d items?"),delSel.count() );
2352 } 2354 }
2353 while ( incidence ) { 2355 while ( incidence ) {
2354 Incidence *in = incidence->clone(); 2356 Incidence *in = incidence->clone();
2355 if ( ! in->summary().isEmpty() ) { 2357 if ( ! in->summary().isEmpty() ) {
2356 in->setDescription(""); 2358 in->setDescription("");
2357 } else { 2359 } else {
2358 in->setSummary( in->description().left(20)); 2360 in->setSummary( in->description().left(20));
2359 in->setDescription(""); 2361 in->setDescription("");
2360 } 2362 }
2361 if ( addText ) 2363 if ( addText )
2362 description += in->summary() + "\n"; 2364 description += in->summary() + "\n";
2363 cal->addIncidence( in ); 2365 cal->addIncidence( in );
2364 incidence = delSel.next(); 2366 incidence = delSel.next();
2365 } 2367 }
2366 if ( beamDialog->beamVcal() ) { 2368 if ( beamDialog->beamVcal() ) {
2367 fn += ".vcs"; 2369 fn += ".vcs";
2368 FileStorage storage( cal, fn, new VCalFormat ); 2370 FileStorage storage( cal, fn, new VCalFormat );
2369 storage.save(); 2371 storage.save();
2370 } else { 2372 } else {
2371 fn += ".ics"; 2373 fn += ".ics";
2372 FileStorage storage( cal, fn, new ICalFormat( ) ); 2374 FileStorage storage( cal, fn, new ICalFormat( ) );
2373 storage.save(); 2375 storage.save();
2374 } 2376 }
2375 delete cal; 2377 delete cal;
2376 mes = i18n("KO/Pi: Ready for beaming"); 2378 mes = i18n("KO/Pi: Ready for beaming");
2377 topLevelWidget()->setCaption(mes); 2379 topLevelWidget()->setCaption(mes);
2378 KApplication::convert2latin1( fn ); 2380 KApplication::convert2latin1( fn );
2379#ifndef DESKTOP_VERSION 2381#ifndef DESKTOP_VERSION
2380 Ir *ir = new Ir( this ); 2382 Ir *ir = new Ir( this );
2381 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2383 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2382 ir->send( fn, description, "text/x-vCalendar" ); 2384 ir->send( fn, description, "text/x-vCalendar" );
2383#endif 2385#endif
2384 } 2386 }
2385} 2387}
2386void CalendarView::beamDone( Ir *ir ) 2388void CalendarView::beamDone( Ir *ir )
2387{ 2389{
2388#ifndef DESKTOP_VERSION 2390#ifndef DESKTOP_VERSION
2389 delete ir; 2391 delete ir;
2390#endif 2392#endif
2391 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2393 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2392 topLevelWidget()->raise(); 2394 topLevelWidget()->raise();
2393} 2395}
2394 2396
2395void CalendarView::moveIncidence(Incidence * inc ) 2397void CalendarView::moveIncidence(Incidence * inc )
2396{ 2398{
2397 if ( !inc ) return; 2399 if ( !inc ) return;
2398 // qDebug("showDatePickerForIncidence( ) "); 2400 // qDebug("showDatePickerForIncidence( ) ");
2399 if ( mDateFrame->isVisible() ) 2401 if ( mDateFrame->isVisible() )
2400 mDateFrame->hide(); 2402 mDateFrame->hide();
2401 else { 2403 else {
2402 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2404 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2403 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2405 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2404 int dw = QApplication::desktop()->width(); 2406 int dw = QApplication::desktop()->width();
2405 int dh = QApplication::desktop()->height(); 2407 int dh = QApplication::desktop()->height();
2406 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2408 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2407 mDateFrame->show(); 2409 mDateFrame->show();
2408 } 2410 }
2409 mDatePickerMode = 2; 2411 mDatePickerMode = 2;
2410 mMoveIncidence = inc ; 2412 mMoveIncidence = inc ;
2411 QDate da; 2413 QDate da;
2412 if ( mMoveIncidence->type() == "Todo" ) { 2414 if ( mMoveIncidence->type() == "Todo" ) {
2413 Todo * to = (Todo *) mMoveIncidence; 2415 Todo * to = (Todo *) mMoveIncidence;
2414 if ( to->hasDueDate() ) 2416 if ( to->hasDueDate() )
2415 da = to->dtDue().date(); 2417 da = to->dtDue().date();
2416 else 2418 else
2417 da = QDate::currentDate(); 2419 da = QDate::currentDate();
2418 } else { 2420 } else {
2419 da = mMoveIncidence->dtStart().date(); 2421 da = mMoveIncidence->dtStart().date();
2420 } 2422 }
2421 mDatePicker->setDate( da ); 2423 mDatePicker->setDate( da );
2422} 2424}
2423void CalendarView::showDatePicker( ) 2425void CalendarView::showDatePicker( )
2424{ 2426{
2425 //qDebug("CalendarView::showDatePicker( ) "); 2427 //qDebug("CalendarView::showDatePicker( ) ");
2426 if ( mDateFrame->isVisible() ) 2428 if ( mDateFrame->isVisible() )
2427 mDateFrame->hide(); 2429 mDateFrame->hide();
2428 else { 2430 else {
2429 int w =mDatePicker->sizeHint().width() ; 2431 int w =mDatePicker->sizeHint().width() ;
2430 int h = mDatePicker->sizeHint().height() ; 2432 int h = mDatePicker->sizeHint().height() ;
2431 int dw = QApplication::desktop()->width(); 2433 int dw = QApplication::desktop()->width();
2432 int dh = QApplication::desktop()->height(); 2434 int dh = QApplication::desktop()->height();
2433 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2435 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2434 mDateFrame->show(); 2436 mDateFrame->show();
2435 } 2437 }
2436 mDatePickerMode = 1; 2438 mDatePickerMode = 1;
2437 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2439 mDatePicker->setDate( mNavigator->selectedDates().first() );
2438} 2440}
2439 2441
2440void CalendarView::showEventEditor() 2442void CalendarView::showEventEditor()
2441{ 2443{
2442#ifdef DESKTOP_VERSION 2444#ifdef DESKTOP_VERSION
2443 mEventEditor->show(); 2445 mEventEditor->show();
2444#else 2446#else
2445 mEventEditor->showMaximized(); 2447 mEventEditor->showMaximized();
2446#endif 2448#endif
2447} 2449}
2448void CalendarView::showTodoEditor() 2450void CalendarView::showTodoEditor()
2449{ 2451{
2450#ifdef DESKTOP_VERSION 2452#ifdef DESKTOP_VERSION
2451 mTodoEditor->show(); 2453 mTodoEditor->show();
2452#else 2454#else
2453 mTodoEditor->showMaximized(); 2455 mTodoEditor->showMaximized();
2454#endif 2456#endif
2455} 2457}
2456 2458
2457void CalendarView::cloneIncidence() 2459void CalendarView::cloneIncidence()
2458{ 2460{
2459 Incidence *incidence = currentSelection(); 2461 Incidence *incidence = currentSelection();
2460 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2462 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2461 if ( incidence ) { 2463 if ( incidence ) {
2462 cloneIncidence(incidence); 2464 cloneIncidence(incidence);
2463 } 2465 }
2464} 2466}
2465void CalendarView::moveIncidence() 2467void CalendarView::moveIncidence()
2466{ 2468{
2467 Incidence *incidence = currentSelection(); 2469 Incidence *incidence = currentSelection();
2468 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2470 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2469 if ( incidence ) { 2471 if ( incidence ) {
2470 moveIncidence(incidence); 2472 moveIncidence(incidence);
2471 } 2473 }
2472} 2474}
2473void CalendarView::beamIncidence() 2475void CalendarView::beamIncidence()
2474{ 2476{
2475 Incidence *incidence = currentSelection(); 2477 Incidence *incidence = currentSelection();
2476 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2478 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2477 if ( incidence ) { 2479 if ( incidence ) {
2478 beamIncidence(incidence); 2480 beamIncidence(incidence);
2479 } 2481 }
2480} 2482}
2481void CalendarView::toggleCancelIncidence() 2483void CalendarView::toggleCancelIncidence()
2482{ 2484{
2483 Incidence *incidence = currentSelection(); 2485 Incidence *incidence = currentSelection();
2484 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2486 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2485 if ( incidence ) { 2487 if ( incidence ) {
2486 cancelIncidence(incidence); 2488 cancelIncidence(incidence);
2487 } 2489 }
2488} 2490}
2489 2491
2490 2492
2491void CalendarView::cancelIncidence(Incidence * inc ) 2493void CalendarView::cancelIncidence(Incidence * inc )
2492{ 2494{
2493 inc->setCancelled( ! inc->cancelled() ); 2495 inc->setCancelled( ! inc->cancelled() );
2494 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2496 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2495 updateView(); 2497 updateView();
2496} 2498}
2497void CalendarView::cloneIncidence(Incidence * orgInc ) 2499void CalendarView::cloneIncidence(Incidence * orgInc )
2498{ 2500{
2499 Incidence * newInc = orgInc->clone(); 2501 Incidence * newInc = orgInc->clone();
2500 newInc->recreate(); 2502 newInc->recreate();
2501 2503
2502 if ( newInc->type() == "Todo" ) { 2504 if ( newInc->type() == "Todo" ) {
2503 Todo* t = (Todo*) newInc; 2505 Todo* t = (Todo*) newInc;
2504 mTodoEditor->editTodo( t ); 2506 mTodoEditor->editTodo( t );
2505 showTodoEditor(); 2507 showTodoEditor();
2506 if ( mTodoEditor->exec() ) { 2508 if ( mTodoEditor->exec() ) {
2507 mCalendar->addTodo( t ); 2509 mCalendar->addTodo( t );
2508 updateView(); 2510 updateView();
2509 } else { 2511 } else {
2510 delete t; 2512 delete t;
2511 } 2513 }
2512 } 2514 }
2513 else { 2515 else {
2514 Event* e = (Event*) newInc; 2516 Event* e = (Event*) newInc;
2515 mEventEditor->editEvent( e ); 2517 mEventEditor->editEvent( e );
2516 showEventEditor(); 2518 showEventEditor();
2517 if ( mEventEditor->exec() ) { 2519 if ( mEventEditor->exec() ) {
2518 mCalendar->addEvent( e ); 2520 mCalendar->addEvent( e );
2519 updateView(); 2521 updateView();
2520 } else { 2522 } else {
2521 delete e; 2523 delete e;
2522 } 2524 }
2523 } 2525 }
2524} 2526}
2525 2527
2526void CalendarView::newEvent() 2528void CalendarView::newEvent()
2527{ 2529{
2528 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2530 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2529 KOAgendaView *aView = mViewManager->agendaView(); 2531 KOAgendaView *aView = mViewManager->agendaView();
2530 if (aView) { 2532 if (aView) {
2531 if (aView->selectionStart().isValid()) { 2533 if (aView->selectionStart().isValid()) {
2532 if (aView->selectedIsAllDay()) { 2534 if (aView->selectedIsAllDay()) {
2533 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2535 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2534 } else { 2536 } else {
2535 newEvent(aView->selectionStart(),aView->selectionEnd()); 2537 newEvent(aView->selectionStart(),aView->selectionEnd());
2536 } 2538 }
2537 return; 2539 return;
2538 } 2540 }
2539 } 2541 }
2540 2542
2541 QDate date = mNavigator->selectedDates().first(); 2543 QDate date = mNavigator->selectedDates().first();
2542 QDateTime current = QDateTime::currentDateTime(); 2544 QDateTime current = QDateTime::currentDateTime();
2543 if ( date <= current.date() ) { 2545 if ( date <= current.date() ) {
2544 int hour = current.time().hour() +1; 2546 int hour = current.time().hour() +1;
2545 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2547 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2546 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2548 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2547 } else 2549 } else
2548 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2550 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2549 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2551 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2550 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2552 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2551} 2553}
2552 2554
2553void CalendarView::newEvent(QDateTime fh) 2555void CalendarView::newEvent(QDateTime fh)
2554{ 2556{
2555 newEvent(fh, 2557 newEvent(fh,
2556 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2558 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2557} 2559}
2558 2560
2559void CalendarView::newEvent(QDate dt) 2561void CalendarView::newEvent(QDate dt)
2560{ 2562{
2561 newEvent(QDateTime(dt, QTime(0,0,0)), 2563 newEvent(QDateTime(dt, QTime(0,0,0)),
2562 QDateTime(dt, QTime(0,0,0)), true); 2564 QDateTime(dt, QTime(0,0,0)), true);
2563} 2565}
2564 2566
2565void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2567void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2566{ 2568{
2567 2569
2568 mEventEditor->newEvent(fromHint,toHint,allDay); 2570 mEventEditor->newEvent(fromHint,toHint,allDay);
2569 if ( mFilterView->filtersEnabled() ) { 2571 if ( mFilterView->filtersEnabled() ) {
2570 CalFilter *filter = mFilterView->selectedFilter(); 2572 CalFilter *filter = mFilterView->selectedFilter();
2571 if (filter && filter->showCategories()) { 2573 if (filter && filter->showCategories()) {
2572 mEventEditor->setCategories(filter->categoryList().join(",") ); 2574 mEventEditor->setCategories(filter->categoryList().join(",") );
2573 } 2575 }
2574 if ( filter ) 2576 if ( filter )
2575 mEventEditor->setSecrecy( filter->getSecrecy() ); 2577 mEventEditor->setSecrecy( filter->getSecrecy() );
2576 } 2578 }
2577 showEventEditor(); 2579 showEventEditor();
2578} 2580}
2579void CalendarView::todoAdded(Todo * t) 2581void CalendarView::todoAdded(Todo * t)
2580{ 2582{
2581 2583
2582 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2584 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2583 updateTodoViews(); 2585 updateTodoViews();
2584} 2586}
2585void CalendarView::todoChanged(Todo * t) 2587void CalendarView::todoChanged(Todo * t)
2586{ 2588{
2587 emit todoModified( t, 4 ); 2589 emit todoModified( t, 4 );
2588 // updateTodoViews(); 2590 // updateTodoViews();
2589} 2591}
2590void CalendarView::todoToBeDeleted(Todo *) 2592void CalendarView::todoToBeDeleted(Todo *)
2591{ 2593{
2592 //qDebug("todoToBeDeleted(Todo *) "); 2594 //qDebug("todoToBeDeleted(Todo *) ");
2593 updateTodoViews(); 2595 updateTodoViews();
2594} 2596}
2595void CalendarView::todoDeleted() 2597void CalendarView::todoDeleted()
2596{ 2598{
2597 //qDebug(" todoDeleted()"); 2599 //qDebug(" todoDeleted()");
2598 updateTodoViews(); 2600 updateTodoViews();
2599} 2601}
2600 2602
2601 2603
2602 2604
2603void CalendarView::newTodo() 2605void CalendarView::newTodo()
2604{ 2606{
2605 2607
2606 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2608 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2607 if ( mFilterView->filtersEnabled() ) { 2609 if ( mFilterView->filtersEnabled() ) {
2608 CalFilter *filter = mFilterView->selectedFilter(); 2610 CalFilter *filter = mFilterView->selectedFilter();
2609 if (filter && filter->showCategories()) { 2611 if (filter && filter->showCategories()) {
2610 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2612 mTodoEditor->setCategories(filter->categoryList().join(",") );
2611 } 2613 }
2612 if ( filter ) 2614 if ( filter )
2613 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2615 mTodoEditor->setSecrecy( filter->getSecrecy() );
2614 } 2616 }
2615 showTodoEditor(); 2617 showTodoEditor();
2616} 2618}
2617 2619
2618void CalendarView::newSubTodo() 2620void CalendarView::newSubTodo()
2619{ 2621{
2620 Todo *todo = selectedTodo(); 2622 Todo *todo = selectedTodo();
2621 if ( todo ) newSubTodo( todo ); 2623 if ( todo ) newSubTodo( todo );
2622} 2624}
2623 2625
2624void CalendarView::newSubTodo(Todo *parentEvent) 2626void CalendarView::newSubTodo(Todo *parentEvent)
2625{ 2627{
2626 2628
2627 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2629 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2628 showTodoEditor(); 2630 showTodoEditor();
2629} 2631}
2630 2632
2631void CalendarView::newFloatingEvent() 2633void CalendarView::newFloatingEvent()
2632{ 2634{
2633 DateList tmpList = mNavigator->selectedDates(); 2635 DateList tmpList = mNavigator->selectedDates();
2634 QDate date = tmpList.first(); 2636 QDate date = tmpList.first();
2635 2637
2636 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2638 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2637 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2639 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2638} 2640}
2639 2641
2640 2642
2641void CalendarView::editEvent( Event *event ) 2643void CalendarView::editEvent( Event *event )
2642{ 2644{
2643 2645
2644 if ( !event ) return; 2646 if ( !event ) return;
2645 if ( event->isReadOnly() ) { 2647 if ( event->isReadOnly() ) {
2646 showEvent( event ); 2648 showEvent( event );
2647 return; 2649 return;
2648 } 2650 }
2649 mEventEditor->editEvent( event , mFlagEditDescription); 2651 mEventEditor->editEvent( event , mFlagEditDescription);
2650 showEventEditor(); 2652 showEventEditor();
2651} 2653}
2652void CalendarView::editJournal( Journal *jour ) 2654void CalendarView::editJournal( Journal *jour )
2653{ 2655{
2654 if ( !jour ) return; 2656 if ( !jour ) return;
2655 mDialogManager->hideSearchDialog(); 2657 mDialogManager->hideSearchDialog();
2656 mViewManager->showJournalView(); 2658 mViewManager->showJournalView();
2657 mNavigator->slotDaySelect( jour->dtStart().date() ); 2659 mNavigator->slotDaySelect( jour->dtStart().date() );
2658} 2660}
2659void CalendarView::editTodo( Todo *todo ) 2661void CalendarView::editTodo( Todo *todo )
2660{ 2662{
2661 if ( !todo ) return; 2663 if ( !todo ) return;
2662 2664
2663 if ( todo->isReadOnly() ) { 2665 if ( todo->isReadOnly() ) {
2664 showTodo( todo ); 2666 showTodo( todo );
2665 return; 2667 return;
2666 } 2668 }
2667 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2669 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2668 showTodoEditor(); 2670 showTodoEditor();
2669 2671
2670} 2672}
2671 2673
2672KOEventViewerDialog* CalendarView::getEventViewerDialog() 2674KOEventViewerDialog* CalendarView::getEventViewerDialog()
2673{ 2675{
2674 if ( !mEventViewerDialog ) { 2676 if ( !mEventViewerDialog ) {
2675 mEventViewerDialog = new KOEventViewerDialog(this); 2677 mEventViewerDialog = new KOEventViewerDialog(this);
2676 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2678 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2677 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2679 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2678 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2680 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2679 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2681 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2680 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2682 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2681 viewManager(), SLOT( showAgendaView( bool ) ) ); 2683 viewManager(), SLOT( showAgendaView( bool ) ) );
2682 mEventViewerDialog->resize( 640, 480 ); 2684 mEventViewerDialog->resize( 640, 480 );
2683 2685
2684 } 2686 }
2685 return mEventViewerDialog; 2687 return mEventViewerDialog;
2686} 2688}
2687void CalendarView::showEvent(Event *event) 2689void CalendarView::showEvent(Event *event)
2688{ 2690{
2689 getEventViewerDialog()->setEvent(event); 2691 getEventViewerDialog()->setEvent(event);
2690 getEventViewerDialog()->showMe(); 2692 getEventViewerDialog()->showMe();
2691} 2693}
2692 2694
2693void CalendarView::showTodo(Todo *event) 2695void CalendarView::showTodo(Todo *event)
2694{ 2696{
2695 getEventViewerDialog()->setTodo(event); 2697 getEventViewerDialog()->setTodo(event);
2696 getEventViewerDialog()->showMe(); 2698 getEventViewerDialog()->showMe();
2697} 2699}
2698void CalendarView::showJournal( Journal *jour ) 2700void CalendarView::showJournal( Journal *jour )
2699{ 2701{
2700 getEventViewerDialog()->setJournal(jour); 2702 getEventViewerDialog()->setJournal(jour);
2701 getEventViewerDialog()->showMe(); 2703 getEventViewerDialog()->showMe();
2702 2704
2703} 2705}
2704// void CalendarView::todoModified (Todo *event, int changed) 2706// void CalendarView::todoModified (Todo *event, int changed)
2705// { 2707// {
2706// // if (mDialogList.find (event) != mDialogList.end ()) { 2708// // if (mDialogList.find (event) != mDialogList.end ()) {
2707// // kdDebug() << "Todo modified and open" << endl; 2709// // kdDebug() << "Todo modified and open" << endl;
2708// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2710// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2709// // temp->modified (changed); 2711// // temp->modified (changed);
2710 2712
2711// // } 2713// // }
2712 2714
2713// mViewManager->updateView(); 2715// mViewManager->updateView();
2714// } 2716// }
2715 2717
2716void CalendarView::appointment_show() 2718void CalendarView::appointment_show()
2717{ 2719{
2718 Event *anEvent = 0; 2720 Event *anEvent = 0;
2719 2721
2720 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2722 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2721 2723
2722 if (mViewManager->currentView()->isEventView()) { 2724 if (mViewManager->currentView()->isEventView()) {
2723 if ( incidence && incidence->type() == "Event" ) { 2725 if ( incidence && incidence->type() == "Event" ) {
2724 anEvent = static_cast<Event *>(incidence); 2726 anEvent = static_cast<Event *>(incidence);
2725 } 2727 }
2726 } 2728 }
2727 2729
2728 if (!anEvent) { 2730 if (!anEvent) {
2729 KNotifyClient::beep(); 2731 KNotifyClient::beep();
2730 return; 2732 return;
2731 } 2733 }
2732 2734
2733 showEvent(anEvent); 2735 showEvent(anEvent);
2734} 2736}
2735 2737
2736void CalendarView::appointment_edit() 2738void CalendarView::appointment_edit()
2737{ 2739{
2738 Event *anEvent = 0; 2740 Event *anEvent = 0;
2739 2741
2740 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2742 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2741 2743
2742 if (mViewManager->currentView()->isEventView()) { 2744 if (mViewManager->currentView()->isEventView()) {
2743 if ( incidence && incidence->type() == "Event" ) { 2745 if ( incidence && incidence->type() == "Event" ) {
2744 anEvent = static_cast<Event *>(incidence); 2746 anEvent = static_cast<Event *>(incidence);
2745 } 2747 }
2746 } 2748 }
2747 2749
2748 if (!anEvent) { 2750 if (!anEvent) {
2749 KNotifyClient::beep(); 2751 KNotifyClient::beep();
2750 return; 2752 return;
2751 } 2753 }
2752 2754
2753 editEvent(anEvent); 2755 editEvent(anEvent);
2754} 2756}
2755 2757
2756void CalendarView::appointment_delete() 2758void CalendarView::appointment_delete()
2757{ 2759{
2758 Event *anEvent = 0; 2760 Event *anEvent = 0;
2759 2761
2760 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2762 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2761 2763
2762 if (mViewManager->currentView()->isEventView()) { 2764 if (mViewManager->currentView()->isEventView()) {
2763 if ( incidence && incidence->type() == "Event" ) { 2765 if ( incidence && incidence->type() == "Event" ) {
2764 anEvent = static_cast<Event *>(incidence); 2766 anEvent = static_cast<Event *>(incidence);
2765 } 2767 }
2766 } 2768 }
2767 2769
2768 if (!anEvent) { 2770 if (!anEvent) {
2769 KNotifyClient::beep(); 2771 KNotifyClient::beep();
2770 return; 2772 return;
2771 } 2773 }
2772 2774
2773 deleteEvent(anEvent); 2775 deleteEvent(anEvent);
2774} 2776}
2775 2777
2776void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2778void CalendarView::todo_resub( Todo * parent, Todo * sub )
2777{ 2779{
2778 if (!sub) return; 2780 if (!sub) return;
2779 if (!parent) return; 2781 if (!parent) return;
2780 if ( sub->relatedTo() ) 2782 if ( sub->relatedTo() )
2781 sub->relatedTo()->removeRelation(sub); 2783 sub->relatedTo()->removeRelation(sub);
2782 sub->setRelatedTo(parent); 2784 sub->setRelatedTo(parent);
2783 sub->setRelatedToUid(parent->uid()); 2785 sub->setRelatedToUid(parent->uid());
2784 parent->addRelation(sub); 2786 parent->addRelation(sub);
2785 sub->updated(); 2787 sub->updated();
2786 parent->updated(); 2788 parent->updated();
2787 setModified(true); 2789 setModified(true);
2788 updateView(); 2790 updateView();
2789} 2791}
2790void CalendarView::todo_unsub(Todo *anTodo ) 2792void CalendarView::todo_unsub(Todo *anTodo )
2791{ 2793{
2792 // Todo *anTodo = selectedTodo(); 2794 // Todo *anTodo = selectedTodo();
2793 if (!anTodo) return; 2795 if (!anTodo) return;
2794 if (!anTodo->relatedTo()) return; 2796 if (!anTodo->relatedTo()) return;
2795 anTodo->relatedTo()->removeRelation(anTodo); 2797 anTodo->relatedTo()->removeRelation(anTodo);
2796 anTodo->setRelatedTo(0); 2798 anTodo->setRelatedTo(0);
2797 anTodo->updated(); 2799 anTodo->updated();
2798 anTodo->setRelatedToUid(""); 2800 anTodo->setRelatedToUid("");
2799 setModified(true); 2801 setModified(true);
2800 updateView(); 2802 updateView();
2801} 2803}
2802 2804
2803void CalendarView::deleteTodo(Todo *todo) 2805void CalendarView::deleteTodo(Todo *todo)
2804{ 2806{
2805 if (!todo) { 2807 if (!todo) {
2806 KNotifyClient::beep(); 2808 KNotifyClient::beep();
2807 return; 2809 return;
2808 } 2810 }
2809 if (KOPrefs::instance()->mConfirm) { 2811 if (KOPrefs::instance()->mConfirm) {
2810 switch (msgItemDelete()) { 2812 switch (msgItemDelete()) {
2811 case KMessageBox::Continue: // OK 2813 case KMessageBox::Continue: // OK
2812 if (!todo->relations().isEmpty()) { 2814 if (!todo->relations().isEmpty()) {
2813 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2815 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2814 i18n("Delete To-Do")); 2816 i18n("Delete To-Do"));
2815 } else { 2817 } else {
2816 checkExternalId( todo ); 2818 checkExternalId( todo );
2817 calendar()->deleteTodo(todo); 2819 calendar()->deleteTodo(todo);
2818 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2820 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2819 updateView(); 2821 updateView();
2820 } 2822 }
2821 break; 2823 break;
2822 } // switch 2824 } // switch
2823 } else { 2825 } else {
2824 if (!todo->relations().isEmpty()) { 2826 if (!todo->relations().isEmpty()) {
2825 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2827 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2826 i18n("Delete To-Do")); 2828 i18n("Delete To-Do"));
2827 } else { 2829 } else {
2828 checkExternalId( todo ); 2830 checkExternalId( todo );
2829 mCalendar->deleteTodo(todo); 2831 mCalendar->deleteTodo(todo);
2830 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2832 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2831 updateView(); 2833 updateView();
2832 } 2834 }
2833 } 2835 }
2834 emit updateSearchDialog(); 2836 emit updateSearchDialog();
2835} 2837}
2836void CalendarView::deleteJournal(Journal *jour) 2838void CalendarView::deleteJournal(Journal *jour)
2837{ 2839{
2838 if (!jour) { 2840 if (!jour) {
2839 KNotifyClient::beep(); 2841 KNotifyClient::beep();
2840 return; 2842 return;
2841 } 2843 }
2842 if (KOPrefs::instance()->mConfirm) { 2844 if (KOPrefs::instance()->mConfirm) {
2843 switch (msgItemDelete()) { 2845 switch (msgItemDelete()) {
2844 case KMessageBox::Continue: // OK 2846 case KMessageBox::Continue: // OK
2845 calendar()->deleteJournal(jour); 2847 calendar()->deleteJournal(jour);
2846 updateView(); 2848 updateView();
2847 break; 2849 break;
2848 } // switch 2850 } // switch
2849 } else { 2851 } else {
2850 calendar()->deleteJournal(jour);; 2852 calendar()->deleteJournal(jour);;
2851 updateView(); 2853 updateView();
2852 } 2854 }
2853 emit updateSearchDialog(); 2855 emit updateSearchDialog();
2854} 2856}
2855 2857
2856void CalendarView::deleteEvent(Event *anEvent) 2858void CalendarView::deleteEvent(Event *anEvent)
2857{ 2859{
2858 if (!anEvent) { 2860 if (!anEvent) {
2859 KNotifyClient::beep(); 2861 KNotifyClient::beep();
2860 return; 2862 return;
2861 } 2863 }
2862 2864
2863 if (anEvent->recurrence()->doesRecur()) { 2865 if (anEvent->recurrence()->doesRecur()) {
2864 QDate itemDate = mViewManager->currentSelectionDate(); 2866 QDate itemDate = mViewManager->currentSelectionDate();
2865 int km; 2867 int km;
2866 if (!itemDate.isValid()) { 2868 if (!itemDate.isValid()) {
2867 //kdDebug() << "Date Not Valid" << endl; 2869 //kdDebug() << "Date Not Valid" << endl;
2868 if (KOPrefs::instance()->mConfirm) { 2870 if (KOPrefs::instance()->mConfirm) {
2869 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2871 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2870 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2872 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2871 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2873 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2872 if ( km == KMessageBox::Continue ) 2874 if ( km == KMessageBox::Continue )
2873 km = KMessageBox::No; // No = all below 2875 km = KMessageBox::No; // No = all below
2874 } else 2876 } else
2875 km = KMessageBox::No; 2877 km = KMessageBox::No;
2876 } else { 2878 } else {
2877 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2879 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2878 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2880 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2879 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2881 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2880 i18n("KO/Pi Confirmation"),i18n("Current"), 2882 i18n("KO/Pi Confirmation"),i18n("Current"),
2881 i18n("All")); 2883 i18n("All"));
2882 } 2884 }
2883 switch(km) { 2885 switch(km) {
2884 2886
2885 case KMessageBox::No: // Continue // all 2887 case KMessageBox::No: // Continue // all
2886 //qDebug("KMessageBox::No "); 2888 //qDebug("KMessageBox::No ");
2887 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2889 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2888 schedule(Scheduler::Cancel,anEvent); 2890 schedule(Scheduler::Cancel,anEvent);
2889 2891
2890 checkExternalId( anEvent); 2892 checkExternalId( anEvent);
2891 mCalendar->deleteEvent(anEvent); 2893 mCalendar->deleteEvent(anEvent);
2892 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2894 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2893 break; 2895 break;
2894 2896
2895 // Disabled because it does not work 2897 // Disabled because it does not work
2896 //#if 0 2898 //#if 0
2897 case KMessageBox::Yes: // just this one 2899 case KMessageBox::Yes: // just this one
2898 //QDate qd = mNavigator->selectedDates().first(); 2900 //QDate qd = mNavigator->selectedDates().first();
2899 //if (!qd.isValid()) { 2901 //if (!qd.isValid()) {
2900 // kdDebug() << "no date selected, or invalid date" << endl; 2902 // kdDebug() << "no date selected, or invalid date" << endl;
2901 // KNotifyClient::beep(); 2903 // KNotifyClient::beep();
2902 // return; 2904 // return;
2903 //} 2905 //}
2904 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2906 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2905 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2907 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2906 anEvent->addExDate(itemDate); 2908 anEvent->addExDate(itemDate);
2907 int duration = anEvent->recurrence()->duration(); 2909 int duration = anEvent->recurrence()->duration();
2908 if ( duration > 0 ) { 2910 if ( duration > 0 ) {
2909 anEvent->recurrence()->setDuration( duration - 1 ); 2911 anEvent->recurrence()->setDuration( duration - 1 );
2910 } 2912 }
2911 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2913 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2912 } 2914 }
2913 break; 2915 break;
2914 //#endif 2916 //#endif
2915 } // switch 2917 } // switch
2916 } else { 2918 } else {
2917 if (KOPrefs::instance()->mConfirm) { 2919 if (KOPrefs::instance()->mConfirm) {
2918 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2920 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2919 i18n("\nAre you sure you want\nto delete this event?"), 2921 i18n("\nAre you sure you want\nto delete this event?"),
2920 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2922 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2921 case KMessageBox::Continue: // OK 2923 case KMessageBox::Continue: // OK
2922 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2924 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2923 schedule(Scheduler::Cancel,anEvent); 2925 schedule(Scheduler::Cancel,anEvent);
2924 checkExternalId( anEvent); 2926 checkExternalId( anEvent);
2925 mCalendar->deleteEvent(anEvent); 2927 mCalendar->deleteEvent(anEvent);
2926 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2928 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2927 break; 2929 break;
2928 } // switch 2930 } // switch
2929 } else { 2931 } else {
2930 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2932 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2931 schedule(Scheduler::Cancel,anEvent); 2933 schedule(Scheduler::Cancel,anEvent);
2932 checkExternalId( anEvent); 2934 checkExternalId( anEvent);
2933 mCalendar->deleteEvent(anEvent); 2935 mCalendar->deleteEvent(anEvent);
2934 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2936 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2935 } 2937 }
2936 } // if-else 2938 } // if-else
2937 emit updateSearchDialog(); 2939 emit updateSearchDialog();
2938} 2940}
2939 2941
2940bool CalendarView::deleteEvent(const QString &uid) 2942bool CalendarView::deleteEvent(const QString &uid)
2941{ 2943{
2942 Event *ev = mCalendar->event(uid); 2944 Event *ev = mCalendar->event(uid);
2943 if (ev) { 2945 if (ev) {
2944 deleteEvent(ev); 2946 deleteEvent(ev);
2945 return true; 2947 return true;
2946 } else { 2948 } else {
2947 return false; 2949 return false;
2948 } 2950 }
2949} 2951}
2950 2952
2951/*****************************************************************************/ 2953/*****************************************************************************/
2952 2954
2953void CalendarView::action_mail() 2955void CalendarView::action_mail()
2954{ 2956{
2955#ifndef KORG_NOMAIL 2957#ifndef KORG_NOMAIL
2956 KOMailClient mailClient; 2958 KOMailClient mailClient;
2957 2959
2958 Incidence *incidence = currentSelection(); 2960 Incidence *incidence = currentSelection();
2959 2961
2960 if (!incidence) { 2962 if (!incidence) {
2961 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2963 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2962 return; 2964 return;
2963 } 2965 }
2964 if(incidence->attendeeCount() == 0 ) { 2966 if(incidence->attendeeCount() == 0 ) {
2965 KMessageBox::sorry(this, 2967 KMessageBox::sorry(this,
2966 i18n("Can't generate mail:\nNo attendees defined.\n")); 2968 i18n("Can't generate mail:\nNo attendees defined.\n"));
2967 return; 2969 return;
2968 } 2970 }
2969 2971
2970 CalendarLocal cal_tmp; 2972 CalendarLocal cal_tmp;
2971 Event *event = 0; 2973 Event *event = 0;
2972 Event *ev = 0; 2974 Event *ev = 0;
2973 if ( incidence && incidence->type() == "Event" ) { 2975 if ( incidence && incidence->type() == "Event" ) {
2974 event = static_cast<Event *>(incidence); 2976 event = static_cast<Event *>(incidence);
2975 ev = new Event(*event); 2977 ev = new Event(*event);
2976 cal_tmp.addEvent(ev); 2978 cal_tmp.addEvent(ev);
2977 } 2979 }
2978 ICalFormat mForm(); 2980 ICalFormat mForm();
2979 QString attachment = mForm.toString( &cal_tmp ); 2981 QString attachment = mForm.toString( &cal_tmp );
2980 if (ev) delete(ev); 2982 if (ev) delete(ev);
2981 2983
2982 mailClient.mailAttendees(currentSelection(), attachment); 2984 mailClient.mailAttendees(currentSelection(), attachment);
2983 2985
2984#endif 2986#endif
2985 2987
2986#if 0 2988#if 0
2987 Event *anEvent = 0; 2989 Event *anEvent = 0;
2988 if (mViewManager->currentView()->isEventView()) { 2990 if (mViewManager->currentView()->isEventView()) {
2989 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2991 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2990 } 2992 }
2991 2993
2992 if (!anEvent) { 2994 if (!anEvent) {
2993 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2995 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2994 return; 2996 return;
2995 } 2997 }
2996 if(anEvent->attendeeCount() == 0 ) { 2998 if(anEvent->attendeeCount() == 0 ) {
2997 KMessageBox::sorry(this, 2999 KMessageBox::sorry(this,
2998 i18n("Can't generate mail:\nNo attendees defined.\n")); 3000 i18n("Can't generate mail:\nNo attendees defined.\n"));
2999 return; 3001 return;
3000 } 3002 }
3001 3003
3002 mailobject.emailEvent(anEvent); 3004 mailobject.emailEvent(anEvent);
3003#endif 3005#endif
3004} 3006}
3005 3007
3006 3008
3007void CalendarView::schedule_publish(Incidence *incidence) 3009void CalendarView::schedule_publish(Incidence *incidence)
3008{ 3010{
3009 Event *event = 0; 3011 Event *event = 0;
3010 Todo *todo = 0; 3012 Todo *todo = 0;
3011 3013
3012 if (incidence == 0) { 3014 if (incidence == 0) {
3013 incidence = mViewManager->currentView()->selectedIncidences().first(); 3015 incidence = mViewManager->currentView()->selectedIncidences().first();
3014 if (incidence == 0) { 3016 if (incidence == 0) {
3015 incidence = mTodoList->selectedIncidences().first(); 3017 incidence = mTodoList->selectedIncidences().first();
3016 } 3018 }
3017 } 3019 }
3018 if ( incidence && incidence->type() == "Event" ) { 3020 if ( incidence && incidence->type() == "Event" ) {
3019 event = static_cast<Event *>(incidence); 3021 event = static_cast<Event *>(incidence);
3020 } else { 3022 } else {
3021 if ( incidence && incidence->type() == "Todo" ) { 3023 if ( incidence && incidence->type() == "Todo" ) {
3022 todo = static_cast<Todo *>(incidence); 3024 todo = static_cast<Todo *>(incidence);
3023 } 3025 }
3024 } 3026 }
3025 3027
3026 if (!event && !todo) { 3028 if (!event && !todo) {
3027 KMessageBox::sorry(this,i18n("No event selected.")); 3029 KMessageBox::sorry(this,i18n("No event selected."));
3028 return; 3030 return;
3029 } 3031 }
3030 3032
3031 PublishDialog *publishdlg = new PublishDialog(); 3033 PublishDialog *publishdlg = new PublishDialog();
3032 if (incidence->attendeeCount()>0) { 3034 if (incidence->attendeeCount()>0) {
3033 QPtrList<Attendee> attendees = incidence->attendees(); 3035 QPtrList<Attendee> attendees = incidence->attendees();
3034 attendees.first(); 3036 attendees.first();
3035 while ( attendees.current()!=0 ) { 3037 while ( attendees.current()!=0 ) {
3036 publishdlg->addAttendee(attendees.current()); 3038 publishdlg->addAttendee(attendees.current());
3037 attendees.next(); 3039 attendees.next();
3038 } 3040 }
3039 } 3041 }
3040 bool send = true; 3042 bool send = true;
3041 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3043 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3042 if ( publishdlg->exec() != QDialog::Accepted ) 3044 if ( publishdlg->exec() != QDialog::Accepted )
3043 send = false; 3045 send = false;
3044 } 3046 }
3045 if ( send ) { 3047 if ( send ) {
3046 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3048 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3047 if ( event ) { 3049 if ( event ) {
3048 Event *ev = new Event(*event); 3050 Event *ev = new Event(*event);
3049 ev->registerObserver(0); 3051 ev->registerObserver(0);
3050 ev->clearAttendees(); 3052 ev->clearAttendees();
3051 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3053 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3052 delete(ev); 3054 delete(ev);
3053 } 3055 }
3054 } else { 3056 } else {
3055 if ( todo ) { 3057 if ( todo ) {
3056 Todo *ev = new Todo(*todo); 3058 Todo *ev = new Todo(*todo);
3057 ev->registerObserver(0); 3059 ev->registerObserver(0);
3058 ev->clearAttendees(); 3060 ev->clearAttendees();
3059 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3061 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3060 delete(ev); 3062 delete(ev);
3061 } 3063 }
3062 } 3064 }
3063 } 3065 }
3064 } 3066 }
3065 delete publishdlg; 3067 delete publishdlg;
3066} 3068}
3067 3069
3068void CalendarView::schedule_request(Incidence *incidence) 3070void CalendarView::schedule_request(Incidence *incidence)
3069{ 3071{
3070 schedule(Scheduler::Request,incidence); 3072 schedule(Scheduler::Request,incidence);
3071} 3073}
3072 3074
3073void CalendarView::schedule_refresh(Incidence *incidence) 3075void CalendarView::schedule_refresh(Incidence *incidence)
3074{ 3076{
3075 schedule(Scheduler::Refresh,incidence); 3077 schedule(Scheduler::Refresh,incidence);
3076} 3078}
3077 3079
3078void CalendarView::schedule_cancel(Incidence *incidence) 3080void CalendarView::schedule_cancel(Incidence *incidence)
3079{ 3081{
3080 schedule(Scheduler::Cancel,incidence); 3082 schedule(Scheduler::Cancel,incidence);
3081} 3083}
3082 3084
3083void CalendarView::schedule_add(Incidence *incidence) 3085void CalendarView::schedule_add(Incidence *incidence)
3084{ 3086{
3085 schedule(Scheduler::Add,incidence); 3087 schedule(Scheduler::Add,incidence);
3086} 3088}
3087 3089
3088void CalendarView::schedule_reply(Incidence *incidence) 3090void CalendarView::schedule_reply(Incidence *incidence)
3089{ 3091{
3090 schedule(Scheduler::Reply,incidence); 3092 schedule(Scheduler::Reply,incidence);
3091} 3093}
3092 3094
3093void CalendarView::schedule_counter(Incidence *incidence) 3095void CalendarView::schedule_counter(Incidence *incidence)
3094{ 3096{
3095 schedule(Scheduler::Counter,incidence); 3097 schedule(Scheduler::Counter,incidence);
3096} 3098}
3097 3099
3098void CalendarView::schedule_declinecounter(Incidence *incidence) 3100void CalendarView::schedule_declinecounter(Incidence *incidence)
3099{ 3101{
3100 schedule(Scheduler::Declinecounter,incidence); 3102 schedule(Scheduler::Declinecounter,incidence);
3101} 3103}
3102 3104
3103void CalendarView::schedule_publish_freebusy(int daysToPublish) 3105void CalendarView::schedule_publish_freebusy(int daysToPublish)
3104{ 3106{
3105 QDateTime start = QDateTime::currentDateTime(); 3107 QDateTime start = QDateTime::currentDateTime();
3106 QDateTime end = start.addDays(daysToPublish); 3108 QDateTime end = start.addDays(daysToPublish);
3107 3109
3108 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3110 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3109 freebusy->setOrganizer(KOPrefs::instance()->email()); 3111 freebusy->setOrganizer(KOPrefs::instance()->email());
3110 3112
3111 3113
3112 PublishDialog *publishdlg = new PublishDialog(); 3114 PublishDialog *publishdlg = new PublishDialog();
3113 if ( publishdlg->exec() == QDialog::Accepted ) { 3115 if ( publishdlg->exec() == QDialog::Accepted ) {
3114 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3116 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3115 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3117 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3116 delete(freebusy); 3118 delete(freebusy);
3117 } 3119 }
3118 } 3120 }
3119 delete publishdlg; 3121 delete publishdlg;
3120} 3122}
3121 3123
3122void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3124void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3123{ 3125{
3124 Event *event = 0; 3126 Event *event = 0;
3125 Todo *todo = 0; 3127 Todo *todo = 0;
3126 3128
3127 if (incidence == 0) { 3129 if (incidence == 0) {
3128 incidence = mViewManager->currentView()->selectedIncidences().first(); 3130 incidence = mViewManager->currentView()->selectedIncidences().first();
3129 if (incidence == 0) { 3131 if (incidence == 0) {
3130 incidence = mTodoList->selectedIncidences().first(); 3132 incidence = mTodoList->selectedIncidences().first();
3131 } 3133 }
3132 } 3134 }
3133 if ( incidence && incidence->type() == "Event" ) { 3135 if ( incidence && incidence->type() == "Event" ) {
3134 event = static_cast<Event *>(incidence); 3136 event = static_cast<Event *>(incidence);
3135 } 3137 }
3136 if ( incidence && incidence->type() == "Todo" ) { 3138 if ( incidence && incidence->type() == "Todo" ) {
3137 todo = static_cast<Todo *>(incidence); 3139 todo = static_cast<Todo *>(incidence);
3138 } 3140 }
3139 3141
3140 if (!event && !todo) { 3142 if (!event && !todo) {
3141 KMessageBox::sorry(this,i18n("No event selected.")); 3143 KMessageBox::sorry(this,i18n("No event selected."));
3142 return; 3144 return;
3143 } 3145 }
3144 3146
3145 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3147 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3146 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3148 KMessageBox::sorry(this,i18n("The event has no attendees."));
3147 return; 3149 return;
3148 } 3150 }
3149 3151
3150 Event *ev = 0; 3152 Event *ev = 0;
3151 if (event) ev = new Event(*event); 3153 if (event) ev = new Event(*event);
3152 Todo *to = 0; 3154 Todo *to = 0;
3153 if (todo) to = new Todo(*todo); 3155 if (todo) to = new Todo(*todo);
3154 3156
3155 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3157 if (method == Scheduler::Reply || method == Scheduler::Refresh) {