summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2004-11-08 21:51:06 (UTC)
committer zautrix <zautrix>2004-11-08 21:51:06 (UTC)
commit4e06ab7da7f56f579010e93b1b9009ed9fd6a33e (patch) (unidiff)
treec5a9bc71126dfd136d7d6394675d8d1b3d70d1d1 /kaddressbook
parent91edd790af2bb6c19954638da1e22158382203a0 (diff)
downloadkdepimpi-4e06ab7da7f56f579010e93b1b9009ed9fd6a33e.zip
kdepimpi-4e06ab7da7f56f579010e93b1b9009ed9fd6a33e.tar.gz
kdepimpi-4e06ab7da7f56f579010e93b1b9009ed9fd6a33e.tar.bz2
word fixes
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp19
-rw-r--r--kaddressbook/xxportselectdialog.cpp16
2 files changed, 25 insertions, 10 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d99a9cd..7be5db8 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -635,97 +635,96 @@ void KABCore::createAboutData()
635 ); 635 );
636} 636}
637 637
638void KABCore::setContactSelected( const QString &uid ) 638void KABCore::setContactSelected( const QString &uid )
639{ 639{
640 KABC::Addressee addr = mAddressBook->findByUid( uid ); 640 KABC::Addressee addr = mAddressBook->findByUid( uid );
641 if ( !mDetails->isHidden() ) 641 if ( !mDetails->isHidden() )
642 mDetails->setAddressee( addr ); 642 mDetails->setAddressee( addr );
643 643
644 if ( !addr.isEmpty() ) { 644 if ( !addr.isEmpty() ) {
645 emit contactSelected( addr.formattedName() ); 645 emit contactSelected( addr.formattedName() );
646 KABC::Picture pic = addr.photo(); 646 KABC::Picture pic = addr.photo();
647 if ( pic.isIntern() ) { 647 if ( pic.isIntern() ) {
648//US emit contactSelected( pic.data() ); 648//US emit contactSelected( pic.data() );
649//US instead use: 649//US instead use:
650 QPixmap px; 650 QPixmap px;
651 if (pic.data().isNull() != true) 651 if (pic.data().isNull() != true)
652 { 652 {
653 px.convertFromImage(pic.data()); 653 px.convertFromImage(pic.data());
654 } 654 }
655 655
656 emit contactSelected( px ); 656 emit contactSelected( px );
657 } 657 }
658 } 658 }
659 659
660 660
661 mExtensionManager->setSelectionChanged(); 661 mExtensionManager->setSelectionChanged();
662 662
663 // update the actions 663 // update the actions
664 bool selected = !uid.isEmpty(); 664 bool selected = !uid.isEmpty();
665 665
666 if ( mReadWrite ) { 666 if ( mReadWrite ) {
667 mActionCut->setEnabled( selected ); 667 mActionCut->setEnabled( selected );
668 mActionPaste->setEnabled( selected ); 668 mActionPaste->setEnabled( selected );
669 } 669 }
670 670
671 mActionCopy->setEnabled( selected ); 671 mActionCopy->setEnabled( selected );
672 mActionDelete->setEnabled( selected ); 672 mActionDelete->setEnabled( selected );
673 mActionEditAddressee->setEnabled( selected ); 673 mActionEditAddressee->setEnabled( selected );
674 mActionMail->setEnabled( selected ); 674 mActionMail->setEnabled( selected );
675 mActionMailVCard->setEnabled( selected ); 675 mActionMailVCard->setEnabled( selected );
676 //if (mActionBeam) 676 //if (mActionBeam)
677 //mActionBeam->setEnabled( selected ); 677 //mActionBeam->setEnabled( selected );
678 678
679 if (mActionBeamVCard) 679 if (mActionBeamVCard)
680 mActionBeamVCard->setEnabled( selected ); 680 mActionBeamVCard->setEnabled( selected );
681 681
682 mActionWhoAmI->setEnabled( selected ); 682 mActionWhoAmI->setEnabled( selected );
683 mActionCategories->setEnabled( selected );
684} 683}
685 684
686void KABCore::sendMail() 685void KABCore::sendMail()
687{ 686{
688 sendMail( mViewManager->selectedEmails().join( ", " ) ); 687 sendMail( mViewManager->selectedEmails().join( ", " ) );
689} 688}
690 689
691void KABCore::sendMail( const QString& emaillist ) 690void KABCore::sendMail( const QString& emaillist )
692{ 691{
693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 692 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
694 if (emaillist.contains(",") > 0) 693 if (emaillist.contains(",") > 0)
695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 694 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
696 else 695 else
697 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 696 ExternalAppHandler::instance()->mailToOneContact( emaillist );
698} 697}
699 698
700 699
701 700
702void KABCore::mailVCard() 701void KABCore::mailVCard()
703{ 702{
704 QStringList uids = mViewManager->selectedUids(); 703 QStringList uids = mViewManager->selectedUids();
705 if ( !uids.isEmpty() ) 704 if ( !uids.isEmpty() )
706 mailVCard( uids ); 705 mailVCard( uids );
707} 706}
708 707
709void KABCore::mailVCard( const QStringList& uids ) 708void KABCore::mailVCard( const QStringList& uids )
710{ 709{
711 QStringList urls; 710 QStringList urls;
712 711
713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 712// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
714 713
715 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 714 QString dirName = "/tmp/" + KApplication::randomString( 8 );
716 715
717 716
718 717
719 QDir().mkdir( dirName, true ); 718 QDir().mkdir( dirName, true );
720 719
721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 720 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
722 KABC::Addressee a = mAddressBook->findByUid( *it ); 721 KABC::Addressee a = mAddressBook->findByUid( *it );
723 722
724 if ( a.isEmpty() ) 723 if ( a.isEmpty() )
725 continue; 724 continue;
726 725
727 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 726 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
728 727
729 QString fileName = dirName + "/" + name; 728 QString fileName = dirName + "/" + name;
730 729
731 QFile outFile(fileName); 730 QFile outFile(fileName);
@@ -968,110 +967,122 @@ void KABCore::cutContacts()
968 967
969 setModified( true ); 968 setModified( true );
970 } 969 }
971} 970}
972 971
973void KABCore::pasteContacts() 972void KABCore::pasteContacts()
974{ 973{
975 QClipboard *cb = QApplication::clipboard(); 974 QClipboard *cb = QApplication::clipboard();
976 975
977 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 976 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
978 977
979 pasteContacts( list ); 978 pasteContacts( list );
980} 979}
981 980
982void KABCore::pasteContacts( KABC::Addressee::List &list ) 981void KABCore::pasteContacts( KABC::Addressee::List &list )
983{ 982{
984 KABC::Resource *resource = requestResource( this ); 983 KABC::Resource *resource = requestResource( this );
985 KABC::Addressee::List::Iterator it; 984 KABC::Addressee::List::Iterator it;
986 for ( it = list.begin(); it != list.end(); ++it ) 985 for ( it = list.begin(); it != list.end(); ++it )
987 (*it).setResource( resource ); 986 (*it).setResource( resource );
988 987
989 PwPasteCommand *command = new PwPasteCommand( this, list ); 988 PwPasteCommand *command = new PwPasteCommand( this, list );
990 UndoStack::instance()->push( command ); 989 UndoStack::instance()->push( command );
991 RedoStack::instance()->clear(); 990 RedoStack::instance()->clear();
992 991
993 setModified( true ); 992 setModified( true );
994} 993}
995 994
996void KABCore::setWhoAmI() 995void KABCore::setWhoAmI()
997{ 996{
998 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 997 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
999 998
1000 if ( addrList.count() > 1 ) { 999 if ( addrList.count() > 1 ) {
1001 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1000 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1002 return; 1001 return;
1003 } 1002 }
1004 1003
1005 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1004 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1006 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1005 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1007 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1006 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1008} 1007}
1009void KABCore::editCategories() 1008void KABCore::editCategories()
1010{ 1009{
1011 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1010 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1012 dlg.exec(); 1011 dlg.exec();
1013} 1012}
1014void KABCore::setCategories() 1013void KABCore::setCategories()
1015{ 1014{
1015
1016 QStringList uids;
1017 XXPortSelectDialog dlgx( this, false, this );
1018 if ( dlgx.exec() )
1019 uids = dlgx.uids();
1020 else
1021 return;
1022 if ( uids.isEmpty() )
1023 return;
1024 // qDebug("count %d ", uids.count());
1025
1026
1016 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1027 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1017 if ( !dlg.exec() ) { 1028 if ( !dlg.exec() ) {
1018 message( i18n("Setting categories cancelled") ); 1029 message( i18n("Setting categories cancelled") );
1019 return; 1030 return;
1020 } 1031 }
1021 bool merge = false; 1032 bool merge = false;
1022 QString msg = i18n( "Merge with existing categories?" ); 1033 QString msg = i18n( "Merge with existing categories?" );
1023 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1034 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1024 merge = true; 1035 merge = true;
1025 1036
1026 message( i18n("Setting categories ... please wait!") ); 1037 message( i18n("Setting categories ... please wait!") );
1027 QStringList categories = dlg.selectedCategories(); 1038 QStringList categories = dlg.selectedCategories();
1028 1039
1029 QStringList uids = mViewManager->selectedUids(); 1040 //QStringList uids = mViewManager->selectedUids();
1030 QStringList::Iterator it; 1041 QStringList::Iterator it;
1031 for ( it = uids.begin(); it != uids.end(); ++it ) { 1042 for ( it = uids.begin(); it != uids.end(); ++it ) {
1032 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1043 KABC::Addressee addr = mAddressBook->findByUid( *it );
1033 if ( !addr.isEmpty() ) { 1044 if ( !addr.isEmpty() ) {
1034 if ( !merge ) 1045 if ( !merge )
1035 addr.setCategories( categories ); 1046 addr.setCategories( categories );
1036 else { 1047 else {
1037 QStringList addrCategories = addr.categories(); 1048 QStringList addrCategories = addr.categories();
1038 QStringList::Iterator catIt; 1049 QStringList::Iterator catIt;
1039 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1050 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1040 if ( !addrCategories.contains( *catIt ) ) 1051 if ( !addrCategories.contains( *catIt ) )
1041 addrCategories.append( *catIt ); 1052 addrCategories.append( *catIt );
1042 } 1053 }
1043 addr.setCategories( addrCategories ); 1054 addr.setCategories( addrCategories );
1044 } 1055 }
1045 mAddressBook->insertAddressee( addr ); 1056 mAddressBook->insertAddressee( addr );
1046 } 1057 }
1047 } 1058 }
1048 1059
1049 if ( uids.count() > 0 ) 1060 if ( uids.count() > 0 )
1050 setModified( true ); 1061 setModified( true );
1051 message( i18n("Setting categories completed!") ); 1062 message( i18n("Setting categories completed!") );
1052} 1063}
1053 1064
1054void KABCore::setSearchFields( const KABC::Field::List &fields ) 1065void KABCore::setSearchFields( const KABC::Field::List &fields )
1055{ 1066{
1056 mIncSearchWidget->setFields( fields ); 1067 mIncSearchWidget->setFields( fields );
1057} 1068}
1058 1069
1059void KABCore::incrementalSearch( const QString& text ) 1070void KABCore::incrementalSearch( const QString& text )
1060{ 1071{
1061 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1072 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1062} 1073}
1063 1074
1064void KABCore::setModified() 1075void KABCore::setModified()
1065{ 1076{
1066 setModified( true ); 1077 setModified( true );
1067} 1078}
1068 1079
1069void KABCore::setModifiedWOrefresh() 1080void KABCore::setModifiedWOrefresh()
1070{ 1081{
1071 // qDebug("KABCore::setModifiedWOrefresh() "); 1082 // qDebug("KABCore::setModifiedWOrefresh() ");
1072 mModified = true; 1083 mModified = true;
1073 mActionSave->setEnabled( mModified ); 1084 mActionSave->setEnabled( mModified );
1074#ifdef DESKTOP_VERSION 1085#ifdef DESKTOP_VERSION
1075 mDetails->refreshView(); 1086 mDetails->refreshView();
1076#endif 1087#endif
1077 1088
@@ -2063,96 +2074,100 @@ void KABCore::addActionsManually()
2063#endif 2074#endif
2064 fileMenu->insertSeparator(); 2075 fileMenu->insertSeparator();
2065 mActionQuit->plug( fileMenu ); 2076 mActionQuit->plug( fileMenu );
2066#ifdef _WIN32_ 2077#ifdef _WIN32_
2067 mActionImportOL->plug( ImportMenu ); 2078 mActionImportOL->plug( ImportMenu );
2068#endif 2079#endif
2069 // edit menu 2080 // edit menu
2070 mActionUndo->plug( editMenu ); 2081 mActionUndo->plug( editMenu );
2071 mActionRedo->plug( editMenu ); 2082 mActionRedo->plug( editMenu );
2072 editMenu->insertSeparator(); 2083 editMenu->insertSeparator();
2073 mActionCut->plug( editMenu ); 2084 mActionCut->plug( editMenu );
2074 mActionCopy->plug( editMenu ); 2085 mActionCopy->plug( editMenu );
2075 mActionPaste->plug( editMenu ); 2086 mActionPaste->plug( editMenu );
2076 mActionDelete->plug( editMenu ); 2087 mActionDelete->plug( editMenu );
2077 editMenu->insertSeparator(); 2088 editMenu->insertSeparator();
2078 mActionSelectAll->plug( editMenu ); 2089 mActionSelectAll->plug( editMenu );
2079 2090
2080 mActionRemoveVoice->plug( changeMenu ); 2091 mActionRemoveVoice->plug( changeMenu );
2081 // settings menu 2092 // settings menu
2082//US special menuentry to configure the addressbook resources. On KDE 2093//US special menuentry to configure the addressbook resources. On KDE
2083// you do that through the control center !!! 2094// you do that through the control center !!!
2084 mActionConfigResources->plug( settingsMenu ); 2095 mActionConfigResources->plug( settingsMenu );
2085 settingsMenu->insertSeparator(); 2096 settingsMenu->insertSeparator();
2086 2097
2087 mActionConfigKAddressbook->plug( settingsMenu ); 2098 mActionConfigKAddressbook->plug( settingsMenu );
2088 2099
2089 if ( mIsPart ) { 2100 if ( mIsPart ) {
2090 //US not implemented yet 2101 //US not implemented yet
2091 //mActionConfigShortcuts->plug( settingsMenu ); 2102 //mActionConfigShortcuts->plug( settingsMenu );
2092 //mActionConfigureToolbars->plug( settingsMenu ); 2103 //mActionConfigureToolbars->plug( settingsMenu );
2093 2104
2094 } else { 2105 } else {
2095 //US not implemented yet 2106 //US not implemented yet
2096 //mActionKeyBindings->plug( settingsMenu ); 2107 //mActionKeyBindings->plug( settingsMenu );
2097 } 2108 }
2098 2109
2099 settingsMenu->insertSeparator(); 2110 settingsMenu->insertSeparator();
2100 2111
2101 mActionJumpBar->plug( settingsMenu ); 2112 mActionJumpBar->plug( settingsMenu );
2102 mActionDetails->plug( settingsMenu ); 2113 mActionDetails->plug( settingsMenu );
2103 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2114 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2104 mActionDetails->plug( tb ); 2115 mActionDetails->plug( tb );
2105 settingsMenu->insertSeparator(); 2116 settingsMenu->insertSeparator();
2106 mActionBR->plug(settingsMenu ); 2117 mActionBR->plug(settingsMenu );
2107 settingsMenu->insertSeparator(); 2118 settingsMenu->insertSeparator();
2108 2119
2109 mActionWhoAmI->plug( settingsMenu ); 2120 mActionWhoAmI->plug( settingsMenu );
2110 mActionEditCategories->plug( settingsMenu ); 2121 mActionEditCategories->plug( settingsMenu );
2122 mActionEditCategories->plug( changeMenu );
2123 mActionCategories->plug( changeMenu );
2124 mActionManageCategories->plug( changeMenu );
2125
2111 mActionCategories->plug( settingsMenu ); 2126 mActionCategories->plug( settingsMenu );
2112 mActionManageCategories->plug( settingsMenu ); 2127 mActionManageCategories->plug( settingsMenu );
2113 2128
2114 2129
2115 mActionWN->plug( helpMenu ); 2130 mActionWN->plug( helpMenu );
2116 mActionSyncHowto->plug( helpMenu ); 2131 mActionSyncHowto->plug( helpMenu );
2117 mActionKdeSyncHowto->plug( helpMenu ); 2132 mActionKdeSyncHowto->plug( helpMenu );
2118 mActionMultiSyncHowto->plug( helpMenu ); 2133 mActionMultiSyncHowto->plug( helpMenu );
2119 mActionFaq->plug( helpMenu ); 2134 mActionFaq->plug( helpMenu );
2120 mActionLicence->plug( helpMenu ); 2135 mActionLicence->plug( helpMenu );
2121 mActionAboutKAddressbook->plug( helpMenu ); 2136 mActionAboutKAddressbook->plug( helpMenu );
2122 2137
2123 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2138 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2124 2139
2125 mActionSave->plug( tb ); 2140 mActionSave->plug( tb );
2126 mViewManager->getFilterAction()->plug ( tb); 2141 mViewManager->getFilterAction()->plug ( tb);
2127 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2142 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2128 mActionUndo->plug( tb ); 2143 mActionUndo->plug( tb );
2129 mActionDelete->plug( tb ); 2144 mActionDelete->plug( tb );
2130 mActionRedo->plug( tb ); 2145 mActionRedo->plug( tb );
2131 } 2146 }
2132 } else { 2147 } else {
2133 mActionSave->plug( tb ); 2148 mActionSave->plug( tb );
2134 tb->enableMoving(false); 2149 tb->enableMoving(false);
2135 } 2150 }
2136 //mActionQuit->plug ( tb ); 2151 //mActionQuit->plug ( tb );
2137 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2152 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2138 2153
2139 //US link the searchwidget first to this. 2154 //US link the searchwidget first to this.
2140 // The real linkage to the toolbar happens later. 2155 // The real linkage to the toolbar happens later.
2141//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2156//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2142//US tb->insertItem( mIncSearchWidget ); 2157//US tb->insertItem( mIncSearchWidget );
2143/*US 2158/*US
2144 mIncSearchWidget = new IncSearchWidget( tb ); 2159 mIncSearchWidget = new IncSearchWidget( tb );
2145 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2160 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2146 SLOT( incrementalSearch( const QString& ) ) ); 2161 SLOT( incrementalSearch( const QString& ) ) );
2147 2162
2148 mJumpButtonBar = new JumpButtonBar( this, this ); 2163 mJumpButtonBar = new JumpButtonBar( this, this );
2149 2164
2150//US topLayout->addWidget( mJumpButtonBar ); 2165//US topLayout->addWidget( mJumpButtonBar );
2151 this->layout()->add( mJumpButtonBar ); 2166 this->layout()->add( mJumpButtonBar );
2152*/ 2167*/
2153 2168
2154#endif //KAB_EMBEDDED 2169#endif //KAB_EMBEDDED
2155 2170
2156 mActionExport2phone->plug( ExportMenu ); 2171 mActionExport2phone->plug( ExportMenu );
2157 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2172 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2158 syncManager->fillSyncMenu(); 2173 syncManager->fillSyncMenu();
diff --git a/kaddressbook/xxportselectdialog.cpp b/kaddressbook/xxportselectdialog.cpp
index be254c0..ab95d5f 100644
--- a/kaddressbook/xxportselectdialog.cpp
+++ b/kaddressbook/xxportselectdialog.cpp
@@ -8,97 +8,97 @@
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25/* 25/*
26Enhanced Version of the file for platform independent KDE tools. 26Enhanced Version of the file for platform independent KDE tools.
27Copyright (c) 2004 Ulf Schenk 27Copyright (c) 2004 Ulf Schenk
28 28
29$Id$ 29$Id$
30*/ 30*/
31 31
32#include <kabc/addressbook.h> 32#include <kabc/addressbook.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <kcombobox.h> 34#include <kcombobox.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kglobal.h> 36#include <kglobal.h>
37 37
38#include <qbuttongroup.h> 38#include <qbuttongroup.h>
39#include <qcombobox.h> 39#include <qcombobox.h>
40#include <qheader.h> 40#include <qheader.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlayout.h> 42#include <qlayout.h>
43#include <qlistview.h> 43#include <qlistview.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qradiobutton.h> 45#include <qradiobutton.h>
46#include <qstringlist.h> 46#include <qstringlist.h>
47#include <qwhatsthis.h> 47#include <qwhatsthis.h>
48 48
49#include "kabcore.h" 49#include "kabcore.h"
50#include "kabprefs.h" 50#include "kabprefs.h"
51 51
52#include "xxportselectdialog.h" 52#include "xxportselectdialog.h"
53 53
54XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort, 54XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort,
55 QWidget* parent, const char* name ) 55 QWidget* parent, const char* name )
56 : KDialogBase( Plain, i18n( "Choose which contacts to export" ), Help | Ok | Cancel, 56 : KDialogBase( Plain, i18n( "Choose which contacts to select" ), Help | Ok | Cancel,
57 Ok, parent, name, true, true ), mCore( core ), 57 Ok, parent, name, true, true ), mCore( core ),
58 mUseSorting( sort ) 58 mUseSorting( sort )
59{ 59{
60 initGUI(); 60 initGUI();
61 61
62 connect( mFiltersCombo, SIGNAL( activated( int ) ), 62 connect( mFiltersCombo, SIGNAL( activated( int ) ),
63 SLOT( filterChanged( int ) ) ); 63 SLOT( filterChanged( int ) ) );
64 connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ), 64 connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ),
65 SLOT( categoryClicked( QListViewItem* ) ) ); 65 SLOT( categoryClicked( QListViewItem* ) ) );
66 66
67 // setup filters 67 // setup filters
68#ifndef KAB_EMBEDDED 68#ifndef KAB_EMBEDDED
69 mFilters = Filter::restore( kapp->config(), "Filter" ); 69 mFilters = Filter::restore( kapp->config(), "Filter" );
70 Filter::List::iterator filterIt; 70 Filter::List::iterator filterIt;
71#else //KAB_EMBEDDED 71#else //KAB_EMBEDDED
72 mFilters = Filter::restore( KGlobal::config(), "Filter" ); 72 mFilters = Filter::restore( KGlobal::config(), "Filter" );
73 Filter::List::Iterator filterIt; 73 Filter::List::Iterator filterIt;
74#endif //KAB_EMBEDDED 74#endif //KAB_EMBEDDED
75 QStringList filters; 75 QStringList filters;
76 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) 76 for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt )
77 filters.append( (*filterIt).name() ); 77 filters.append( (*filterIt).name() );
78 78
79 mFiltersCombo->insertStringList( filters ); 79 mFiltersCombo->insertStringList( filters );
80 mUseFilters->setEnabled( filters.count() > 0 ); 80 mUseFilters->setEnabled( filters.count() > 0 );
81 81
82 // setup categories 82 // setup categories
83 QStringList categories = KABPrefs::instance()->mCustomCategories; 83 QStringList categories = KABPrefs::instance()->mCustomCategories;
84 QStringList::Iterator it; 84 QStringList::Iterator it;
85 for ( it = categories.begin(); it != categories.end(); ++it ) 85 for ( it = categories.begin(); it != categories.end(); ++it )
86 new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox ); 86 new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox );
87 mUseCategories->setEnabled( categories.count() > 0 ); 87 mUseCategories->setEnabled( categories.count() > 0 );
88 88
89 int count = mCore->selectedUIDs().count(); 89 int count = mCore->selectedUIDs().count();
90 mUseSelection->setEnabled( count != 0 ); 90 mUseSelection->setEnabled( count != 0 );
91 mUseSelection->setChecked( count > 1 ); 91 mUseSelection->setChecked( count > 1 );
92 92
93 mSortTypeCombo->insertItem( i18n( "Ascending" ) ); 93 mSortTypeCombo->insertItem( i18n( "Ascending" ) );
94 mSortTypeCombo->insertItem( i18n( "Descending" ) ); 94 mSortTypeCombo->insertItem( i18n( "Descending" ) );
95 95
96 mFields = mCore->addressBook()->fields( KABC::Field::All ); 96 mFields = mCore->addressBook()->fields( KABC::Field::All );
97 KABC::Field::List::Iterator fieldIt; 97 KABC::Field::List::Iterator fieldIt;
98 for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt ) 98 for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt )
99 mFieldCombo->insertItem( (*fieldIt)->label() ); 99 mFieldCombo->insertItem( (*fieldIt)->label() );
100} 100}
101 101
102QStringList XXPortSelectDialog::uids() 102QStringList XXPortSelectDialog::uids()
103{ 103{
104 QStringList uidlist; 104 QStringList uidlist;
@@ -159,130 +159,130 @@ KABC::AddresseeList XXPortSelectDialog::contacts()
159 } 159 }
160 160
161 return list; 161 return list;
162} 162}
163 163
164QStringList XXPortSelectDialog::categories() const 164QStringList XXPortSelectDialog::categories() const
165{ 165{
166 QStringList list; 166 QStringList list;
167 167
168 QListViewItemIterator it( mCategoriesView ); 168 QListViewItemIterator it( mCategoriesView );
169 for ( ; it.current(); ++it ) { 169 for ( ; it.current(); ++it ) {
170 QCheckListItem* qcli = static_cast<QCheckListItem*>(it.current()); 170 QCheckListItem* qcli = static_cast<QCheckListItem*>(it.current());
171 if ( qcli->isOn() ) 171 if ( qcli->isOn() )
172 list.append( it.current()->text( 0 ) ); 172 list.append( it.current()->text( 0 ) );
173 } 173 }
174 174
175 return list; 175 return list;
176} 176}
177 177
178void XXPortSelectDialog::filterChanged( int ) 178void XXPortSelectDialog::filterChanged( int )
179{ 179{
180 mUseFilters->setChecked( true ); 180 mUseFilters->setChecked( true );
181} 181}
182 182
183void XXPortSelectDialog::categoryClicked( QListViewItem *i ) 183void XXPortSelectDialog::categoryClicked( QListViewItem *i )
184{ 184{
185 QCheckListItem *qcli = static_cast<QCheckListItem*>( i ); 185 QCheckListItem *qcli = static_cast<QCheckListItem*>( i );
186 if ( qcli->isOn() ) 186 if ( qcli->isOn() )
187 mUseCategories->setChecked( true ); 187 mUseCategories->setChecked( true );
188} 188}
189 189
190void XXPortSelectDialog::slotHelp() 190void XXPortSelectDialog::slotHelp()
191{ 191{
192#ifndef KAB_EMBEDDED 192#ifndef KAB_EMBEDDED
193 kapp->invokeHelp( "import-and-export" ); 193 kapp->invokeHelp( "import-and-export" );
194#else //KAB_EMBEDDED 194#else //KAB_EMBEDDED
195 qDebug("XXPortSelectDialog::slotHelp is not implemented yet"); 195 qDebug("XXPortSelectDialog::slotHelp is not implemented yet");
196#endif //KAB_EMBEDDED 196#endif //KAB_EMBEDDED
197 197
198} 198}
199 199
200void XXPortSelectDialog::initGUI() 200void XXPortSelectDialog::initGUI()
201{ 201{
202 QFrame *page = plainPage(); 202 QFrame *page = plainPage();
203 203
204 QVBoxLayout *topLayout = new QVBoxLayout( page, KDialog::marginHint(), 204 QVBoxLayout *topLayout = new QVBoxLayout( page, KDialog::marginHint(),
205 KDialog::spacingHint() ); 205 KDialog::spacingHint() );
206 206
207 QLabel *label = new QLabel( i18n( "Which contacts do you want to export?" ), page ); 207 QLabel *label = new QLabel( i18n( "Which contacts do you want to select?" ), page );
208 topLayout->addWidget( label ); 208 topLayout->addWidget( label );
209 209
210 mButtonGroup = new QButtonGroup( i18n( "Contact Selection" ), page ); 210 mButtonGroup = new QButtonGroup( i18n( "Contact Selection" ), page );
211 mButtonGroup->setColumnLayout( 0, Qt::Vertical ); 211 mButtonGroup->setColumnLayout( 0, Qt::Vertical );
212 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() ); 212 mButtonGroup->layout()->setSpacing( KDialog::spacingHint() );
213 mButtonGroup->layout()->setMargin( KDialog::marginHint() ); 213 mButtonGroup->layout()->setMargin( KDialog::marginHint() );
214 214
215 QGridLayout *groupLayout = new QGridLayout( mButtonGroup->layout() ); 215 QGridLayout *groupLayout = new QGridLayout( mButtonGroup->layout() );
216 groupLayout->setAlignment( Qt::AlignTop ); 216 groupLayout->setAlignment( Qt::AlignTop );
217 217
218 mUseWholeBook = new QRadioButton( i18n( "&All" ), mButtonGroup ); 218 mUseWholeBook = new QRadioButton( i18n( "&All" ), mButtonGroup );
219 mUseWholeBook->setChecked( true ); 219 mUseWholeBook->setChecked( true );
220 QWhatsThis::add( mUseWholeBook, i18n( "Export the entire address book" ) ); 220 QWhatsThis::add( mUseWholeBook, i18n( "Select the entire address book" ) );
221 groupLayout->addWidget( mUseWholeBook, 0, 0 ); 221 groupLayout->addWidget( mUseWholeBook, 0, 0 );
222 222
223 mUseSelection = new QRadioButton( i18n( "&Selected" ), mButtonGroup ); 223 mUseSelection = new QRadioButton( i18n( "&Selected" ), mButtonGroup );
224 QWhatsThis::add( mUseSelection, i18n( "Only export contacts selected in KAddressBook.\n" 224 QWhatsThis::add( mUseSelection, i18n( "Only contacts selected in KAddressBook.\n"
225 "This option is disabled if no contacts are selected." ) ); 225 "This option is disabled if no contacts are selected." ) );
226 groupLayout->addWidget( mUseSelection, 1, 0 ); 226 groupLayout->addWidget( mUseSelection, 1, 0 );
227 227
228 mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup ); 228 mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup );
229 QWhatsThis::add( mUseFilters, i18n( "Only export contacts matching the selected filter.\n" 229 QWhatsThis::add( mUseFilters, i18n( "Only contacts matching the selected filter.\n"
230 "This option is disabled if you haven't defined any filters" ) ); 230 "This option is disabled if you haven't defined any filters" ) );
231 groupLayout->addWidget( mUseFilters, 2, 0 ); 231 groupLayout->addWidget( mUseFilters, 2, 0 );
232 232
233 mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup ); 233 mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup );
234 QWhatsThis::add( mUseCategories, i18n( "Only export contacts who are members of a category that is checked on the list to the left.\n" 234 QWhatsThis::add( mUseCategories, i18n( "Only contacts who are members of a category that is checked on the list to the left.\n"
235 "This option is disabled if you have no categories." ) ); 235 "This option is disabled if you have no categories." ) );
236 groupLayout->addWidget( mUseCategories, 3, 0 ); 236 groupLayout->addWidget( mUseCategories, 3, 0 );
237 237
238 mFiltersCombo = new QComboBox( false, mButtonGroup ); 238 mFiltersCombo = new QComboBox( false, mButtonGroup );
239 QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to export." ) ); 239 QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to select." ) );
240 groupLayout->addWidget( mFiltersCombo, 2, 1 ); 240 groupLayout->addWidget( mFiltersCombo, 2, 1 );
241 241
242 mCategoriesView = new QListView( mButtonGroup ); 242 mCategoriesView = new QListView( mButtonGroup );
243 mCategoriesView->addColumn( "" ); 243 mCategoriesView->addColumn( "" );
244 mCategoriesView->header()->hide(); 244 mCategoriesView->header()->hide();
245 QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to export." ) ); 245 QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to select." ) );
246 groupLayout->addWidget( mCategoriesView, 3, 1 ); 246 groupLayout->addWidget( mCategoriesView, 3, 1 );
247 247
248 topLayout->addWidget( mButtonGroup ); 248 topLayout->addWidget( mButtonGroup );
249 249
250 QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page ); 250 QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page );
251 sortingGroup->setColumnLayout( 0, Qt::Vertical ); 251 sortingGroup->setColumnLayout( 0, Qt::Vertical );
252 QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2, 252 QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2,
253 KDialog::spacingHint() ); 253 KDialog::spacingHint() );
254 sortLayout->setAlignment( Qt::AlignTop ); 254 sortLayout->setAlignment( Qt::AlignTop );
255 255
256 label = new QLabel( i18n( "Criterion:" ), sortingGroup ); 256 label = new QLabel( i18n( "Criterion:" ), sortingGroup );
257 sortLayout->addWidget( label, 0, 0 ); 257 sortLayout->addWidget( label, 0, 0 );
258 258
259#ifndef KAB_EMBEDDED 259#ifndef KAB_EMBEDDED
260 mFieldCombo = new KComboBox( false, sortingGroup ); 260 mFieldCombo = new KComboBox( false, sortingGroup );
261#else //KAB_EMBEDDED 261#else //KAB_EMBEDDED
262 //US Combobox is not editable anyway 262 //US Combobox is not editable anyway
263 mFieldCombo = new KComboBox( sortingGroup ); 263 mFieldCombo = new KComboBox( sortingGroup );
264#endif //KAB_EMBEDDED 264#endif //KAB_EMBEDDED
265 sortLayout->addWidget( mFieldCombo, 0, 1 ); 265 sortLayout->addWidget( mFieldCombo, 0, 1 );
266 266
267 label = new QLabel( i18n( "Order:" ), sortingGroup ); 267 label = new QLabel( i18n( "Order:" ), sortingGroup );
268 sortLayout->addWidget( label, 1, 0 ); 268 sortLayout->addWidget( label, 1, 0 );
269 269
270#ifndef KAB_EMBEDDED 270#ifndef KAB_EMBEDDED
271 mSortTypeCombo = new KComboBox( false, sortingGroup ); 271 mSortTypeCombo = new KComboBox( false, sortingGroup );
272#else //KAB_EMBEDDED 272#else //KAB_EMBEDDED
273 //US Combobox is not editable anyway 273 //US Combobox is not editable anyway
274 mSortTypeCombo = new KComboBox( sortingGroup ); 274 mSortTypeCombo = new KComboBox( sortingGroup );
275#endif //KAB_EMBEDDED 275#endif //KAB_EMBEDDED
276 sortLayout->addWidget( mSortTypeCombo, 1, 1 ); 276 sortLayout->addWidget( mSortTypeCombo, 1, 1 );
277 277
278 topLayout->addWidget( sortingGroup ); 278 topLayout->addWidget( sortingGroup );
279 279
280 if ( !mUseSorting ) 280 if ( !mUseSorting )
281 sortingGroup->hide(); 281 sortingGroup->hide();
282} 282}
283 283
284#ifndef KAB_EMBEDDED 284#ifndef KAB_EMBEDDED
285#include "xxportselectdialog.moc" 285#include "xxportselectdialog.moc"
286#endif //KAB_EMBEDDED 286#endif //KAB_EMBEDDED
287 287
288 288