author | zautrix <zautrix> | 2005-07-01 06:40:20 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-01 06:40:20 (UTC) |
commit | 409f5296344084e22833b35c03923b89d7be653b (patch) (unidiff) | |
tree | 5332c1a045c6fece04a38313cac18485380259c6 | |
parent | a7924287e231b461585c4121f6ee2ce32f955089 (diff) | |
download | kdepimpi-409f5296344084e22833b35c03923b89d7be653b.zip kdepimpi-409f5296344084e22833b35c03923b89d7be653b.tar.gz kdepimpi-409f5296344084e22833b35c03923b89d7be653b.tar.bz2 |
fixxx
-rw-r--r-- | kaddressbook/incsearchwidget.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp index b1ffe04..5f8b83d 100644 --- a/kaddressbook/incsearchwidget.cpp +++ b/kaddressbook/incsearchwidget.cpp | |||
@@ -1,178 +1,181 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qtooltip.h> | 26 | #include <qtooltip.h> |
27 | #include <qapplication.h> | 27 | #include <qapplication.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | 29 | ||
30 | #include <kdialog.h> | 30 | #include <kdialog.h> |
31 | #include <klineedit.h> | 31 | #include <klineedit.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | #include <kglobal.h> | 33 | #include <kglobal.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | #include "kabprefs.h" | 35 | #include "kabprefs.h" |
36 | 36 | ||
37 | #include "incsearchwidget.h" | 37 | #include "incsearchwidget.h" |
38 | 38 | ||
39 | IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) | 39 | IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) |
40 | : QWidget( parent, name ) | 40 | : QWidget( parent, name ) |
41 | { | 41 | { |
42 | #ifndef KAB_EMBEDDED | 42 | #ifndef KAB_EMBEDDED |
43 | //US setCaption( i18n( "Incremental Search" ) ); | 43 | //US setCaption( i18n( "Incremental Search" ) ); |
44 | #endif //KAB_EMBEDDED | 44 | #endif //KAB_EMBEDDED |
45 | 45 | ||
46 | QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); | 46 | QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); |
47 | 47 | ||
48 | #ifdef DESKTOP_VERSION | 48 | #ifdef DESKTOP_VERSION |
49 | QLabel *label = new QLabel( i18n( "Search:" ), this ); | 49 | QLabel *label = new QLabel( i18n( "Search:" ), this ); |
50 | label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); | 50 | label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); |
51 | layout->addWidget( label ); | 51 | layout->addWidget( label ); |
52 | #endif //KAB_EMBEDDED | 52 | #endif //KAB_EMBEDDED |
53 | 53 | ||
54 | mSearchText = new KLineEdit( this ); | 54 | mSearchText = new KLineEdit( this ); |
55 | layout->addWidget( mSearchText ); | 55 | layout->addWidget( mSearchText ); |
56 | // #ifdef KAB_EMBEDDED | 56 | // #ifdef KAB_EMBEDDED |
57 | // if (KGlobal::getOrientation() == KGlobal::Portrait) | 57 | // if (KGlobal::getOrientation() == KGlobal::Portrait) |
58 | // mSearchText->setMaximumWidth(30); | 58 | // mSearchText->setMaximumWidth(30); |
59 | // #endif //KAB_EMBEDDED | 59 | // #endif //KAB_EMBEDDED |
60 | //mSearchText->setMaximumWidth(60); | 60 | //mSearchText->setMaximumWidth(60); |
61 | 61 | ||
62 | 62 | ||
63 | mFieldCombo = new QComboBox( false, this ); | 63 | mFieldCombo = new QComboBox( false, this ); |
64 | layout->addWidget( mFieldCombo ); | 64 | layout->addWidget( mFieldCombo ); |
65 | mFieldCombo->setMaximumHeight( 34 ); | 65 | mFieldCombo->setMaximumHeight( 34 ); |
66 | QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); | 66 | QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); |
67 | 67 | ||
68 | // #ifndef KAB_EMBEDDED | 68 | // #ifndef KAB_EMBEDDED |
69 | // resize( QSize(420, 50).expandedTo( sizeHint() ) ); | 69 | // resize( QSize(420, 50).expandedTo( sizeHint() ) ); |
70 | // #else //KAB_EMBEDDED | 70 | // #else //KAB_EMBEDDED |
71 | // resize( QSize(30, 10).expandedTo( sizeHint() ) ); | 71 | // resize( QSize(30, 10).expandedTo( sizeHint() ) ); |
72 | // #endif //KAB_EMBEDDED | 72 | // #endif //KAB_EMBEDDED |
73 | 73 | ||
74 | 74 | ||
75 | // for performance reasons, we do a search on the pda only after return is pressed | 75 | // for performance reasons, we do a search on the pda only after return is pressed |
76 | connect( mSearchText, SIGNAL( textChanged( const QString& ) ), | 76 | connect( mSearchText, SIGNAL( textChanged( const QString& ) ), |
77 | SLOT( announceDoSearch2() ) ); | 77 | SLOT( announceDoSearch2() ) ); |
78 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), | 78 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), |
79 | SLOT( announceDoSearch2() ) ); | 79 | SLOT( announceDoSearch2() ) ); |
80 | 80 | ||
81 | connect( mSearchText, SIGNAL( returnPressed() ), | 81 | connect( mSearchText, SIGNAL( returnPressed() ), |
82 | SLOT( announceDoSearch() ) ); | 82 | SLOT( announceDoSearch() ) ); |
83 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), | 83 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), |
84 | SLOT( announceFieldChanged() ) ); | 84 | SLOT( announceFieldChanged() ) ); |
85 | 85 | ||
86 | 86 | ||
87 | 87 | ||
88 | connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() )); | 88 | connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() )); |
89 | connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() )); | 89 | connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() )); |
90 | 90 | ||
91 | 91 | ||
92 | setFocusProxy( mSearchText ); | 92 | setFocusProxy( mSearchText ); |
93 | } | 93 | } |
94 | 94 | ||
95 | IncSearchWidget::~IncSearchWidget() | 95 | IncSearchWidget::~IncSearchWidget() |
96 | { | 96 | { |
97 | 97 | ||
98 | } | 98 | } |
99 | void IncSearchWidget::announceDoSearch2() | 99 | void IncSearchWidget::announceDoSearch2() |
100 | { | 100 | { |
101 | if ( KABPrefs::instance()->mSearchWithReturn ) | 101 | if ( KABPrefs::instance()->mSearchWithReturn ) |
102 | return; | 102 | return; |
103 | emit doSearch( mSearchText->text() ); | 103 | emit doSearch( mSearchText->text() ); |
104 | //qDebug("emit dosreach "); | 104 | //qDebug("emit dosreach "); |
105 | } | 105 | } |
106 | 106 | ||
107 | void IncSearchWidget::announceDoSearch() | 107 | void IncSearchWidget::announceDoSearch() |
108 | { | 108 | { |
109 | 109 | ||
110 | emit doSearch( mSearchText->text() ); | 110 | emit doSearch( mSearchText->text() ); |
111 | // qDebug("emit dosreach "); | 111 | // qDebug("emit dosreach "); |
112 | } | 112 | } |
113 | 113 | ||
114 | void IncSearchWidget::announceFieldChanged() | 114 | void IncSearchWidget::announceFieldChanged() |
115 | { | 115 | { |
116 | emit fieldChanged(); | 116 | emit fieldChanged(); |
117 | } | 117 | } |
118 | void IncSearchWidget::setSize() | 118 | void IncSearchWidget::setSize() |
119 | { | 119 | { |
120 | if ( KABPrefs::instance()->mHideSearchOnSwitch && QApplication::desktop()->width() == 480) { | 120 | if ( KABPrefs::instance()->mHideSearchOnSwitch && QApplication::desktop()->width() == 480) { |
121 | mFieldCombo->setMaximumWidth( 40 ); | 121 | setCurrentItem( 0 ); |
122 | mSearchText->setMaximumWidth( 30 ); | 122 | //mFieldCombo->setMaximumWidth( 0 ); |
123 | mFieldCombo->hide(); | ||
124 | mSearchText->setMaximumWidth( 200 ); | ||
123 | } else { | 125 | } else { |
126 | mFieldCombo->show(); | ||
124 | QFontMetrics fm ( mFieldCombo->font() ); | 127 | QFontMetrics fm ( mFieldCombo->font() ); |
125 | int wid = fm.width(i18n( "All Fields" ) ); | 128 | int wid = fm.width(i18n( "All Fields" ) ); |
126 | #ifdef DESKTOP_VERSION | 129 | #ifdef DESKTOP_VERSION |
127 | mFieldCombo->setMinimumWidth( wid+60 ); | 130 | mFieldCombo->setMinimumWidth( wid+60 ); |
128 | wid = wid * 2; | 131 | wid = wid * 2; |
129 | #endif | 132 | #endif |
130 | mFieldCombo->setMaximumWidth( wid+60 ); | 133 | mFieldCombo->setMaximumWidth( wid+60 ); |
131 | mSearchText->setMaximumWidth( 1024 ); | 134 | mSearchText->setMaximumWidth( 1024 ); |
132 | } | 135 | } |
133 | } | 136 | } |
134 | void IncSearchWidget::setFields( const KABC::Field::List &list ) | 137 | void IncSearchWidget::setFields( const KABC::Field::List &list ) |
135 | { | 138 | { |
136 | 139 | ||
137 | mFieldCombo->clear(); | 140 | mFieldCombo->clear(); |
138 | mFieldCombo->insertItem( i18n( "All Fields" ) ); | 141 | mFieldCombo->insertItem( i18n( "All Fields" ) ); |
139 | 142 | ||
140 | KABC::Field::List::ConstIterator it; | 143 | KABC::Field::List::ConstIterator it; |
141 | for ( it = list.begin(); it != list.end(); ++it ) { | 144 | for ( it = list.begin(); it != list.end(); ++it ) { |
142 | mFieldCombo->insertItem( (*it)->label() ); | 145 | mFieldCombo->insertItem( (*it)->label() ); |
143 | } | 146 | } |
144 | 147 | ||
145 | mFieldList = list; | 148 | mFieldList = list; |
146 | 149 | ||
147 | announceDoSearch(); | 150 | announceDoSearch(); |
148 | announceFieldChanged(); | 151 | announceFieldChanged(); |
149 | setSize(); | 152 | setSize(); |
150 | } | 153 | } |
151 | 154 | ||
152 | KABC::Field::List IncSearchWidget::fields() const | 155 | KABC::Field::List IncSearchWidget::fields() const |
153 | { | 156 | { |
154 | return mFieldList; | 157 | return mFieldList; |
155 | } | 158 | } |
156 | 159 | ||
157 | KABC::Field *IncSearchWidget::currentField()const | 160 | KABC::Field *IncSearchWidget::currentField()const |
158 | { | 161 | { |
159 | if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) | 162 | if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) |
160 | return 0; // for error or 'use all fields' | 163 | return 0; // for error or 'use all fields' |
161 | else | 164 | else |
162 | return mFieldList[ mFieldCombo->currentItem() - 1 ]; | 165 | return mFieldList[ mFieldCombo->currentItem() - 1 ]; |
163 | } | 166 | } |
164 | 167 | ||
165 | void IncSearchWidget::setCurrentItem( int pos ) | 168 | void IncSearchWidget::setCurrentItem( int pos ) |
166 | { | 169 | { |
167 | mFieldCombo->setCurrentItem( pos ); | 170 | mFieldCombo->setCurrentItem( pos ); |
168 | announceFieldChanged(); | 171 | announceFieldChanged(); |
169 | } | 172 | } |
170 | 173 | ||
171 | int IncSearchWidget::currentItem() const | 174 | int IncSearchWidget::currentItem() const |
172 | { | 175 | { |
173 | 176 | ||
174 | return mFieldCombo->currentItem(); | 177 | return mFieldCombo->currentItem(); |
175 | } | 178 | } |
176 | #ifndef KAB_EMBEDDED | 179 | #ifndef KAB_EMBEDDED |
177 | #include "incsearchwidget.moc" | 180 | #include "incsearchwidget.moc" |
178 | #endif //KAB_EMBEDDED | 181 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 046cb63..b4e0b07 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -639,384 +639,385 @@ KABC::Resource *KABCore::requestResource( QWidget *parent ) | |||
639 | kresResources.append( res ); | 639 | kresResources.append( res ); |
640 | } | 640 | } |
641 | } | 641 | } |
642 | 642 | ||
643 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 643 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
644 | return static_cast<KABC::Resource*>( res ); | 644 | return static_cast<KABC::Resource*>( res ); |
645 | } | 645 | } |
646 | 646 | ||
647 | #ifndef KAB_EMBEDDED | 647 | #ifndef KAB_EMBEDDED |
648 | KAboutData *KABCore::createAboutData() | 648 | KAboutData *KABCore::createAboutData() |
649 | #else //KAB_EMBEDDED | 649 | #else //KAB_EMBEDDED |
650 | void KABCore::createAboutData() | 650 | void KABCore::createAboutData() |
651 | #endif //KAB_EMBEDDED | 651 | #endif //KAB_EMBEDDED |
652 | { | 652 | { |
653 | 653 | ||
654 | 654 | ||
655 | QString version; | 655 | QString version; |
656 | #include <../version> | 656 | #include <../version> |
657 | QMessageBox::about( this, "About KAddressbook/Pi", | 657 | QMessageBox::about( this, "About KAddressbook/Pi", |
658 | "KAddressbook/Platform-independent\n" | 658 | "KAddressbook/Platform-independent\n" |
659 | "(KA/Pi) " +version + " - " + | 659 | "(KA/Pi) " +version + " - " + |
660 | #ifdef DESKTOP_VERSION | 660 | #ifdef DESKTOP_VERSION |
661 | "Desktop Edition\n" | 661 | "Desktop Edition\n" |
662 | #else | 662 | #else |
663 | "PDA-Edition\n" | 663 | "PDA-Edition\n" |
664 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 664 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
665 | #endif | 665 | #endif |
666 | 666 | ||
667 | "(c) 2004 Ulf Schenk\n" | 667 | "(c) 2004 Ulf Schenk\n" |
668 | "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" | 668 | "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" |
669 | "(c) 1997-2003, The KDE PIM Team\n" | 669 | "(c) 1997-2003, The KDE PIM Team\n" |
670 | "Tobias Koenig Maintainer\n" | 670 | "Tobias Koenig Maintainer\n" |
671 | "Don Sanders Original author\n" | 671 | "Don Sanders Original author\n" |
672 | "Cornelius Schumacher Co-maintainer\n" | 672 | "Cornelius Schumacher Co-maintainer\n" |
673 | "Mike Pilone GUI and framework redesign\n" | 673 | "Mike Pilone GUI and framework redesign\n" |
674 | "Greg Stern DCOP interface\n" | 674 | "Greg Stern DCOP interface\n" |
675 | "Mark Westcot Contact pinning\n" | 675 | "Mark Westcot Contact pinning\n" |
676 | "Michel Boyer de la Giroday LDAP Lookup\n" | 676 | "Michel Boyer de la Giroday LDAP Lookup\n" |
677 | "Steffen Hansen LDAP Lookup" | 677 | "Steffen Hansen LDAP Lookup" |
678 | #ifdef _WIN32_ | 678 | #ifdef _WIN32_ |
679 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 679 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
680 | #endif | 680 | #endif |
681 | ); | 681 | ); |
682 | } | 682 | } |
683 | 683 | ||
684 | void KABCore::setContactSelected( const QString &uid ) | 684 | void KABCore::setContactSelected( const QString &uid ) |
685 | { | 685 | { |
686 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 686 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
687 | if ( !mDetails->isHidden() ) | 687 | if ( !mDetails->isHidden() ) |
688 | mDetails->setAddressee( addr ); | 688 | mDetails->setAddressee( addr ); |
689 | 689 | ||
690 | if ( !addr.isEmpty() ) { | 690 | if ( !addr.isEmpty() ) { |
691 | emit contactSelected( addr.formattedName() ); | 691 | emit contactSelected( addr.formattedName() ); |
692 | KABC::Picture pic = addr.photo(); | 692 | KABC::Picture pic = addr.photo(); |
693 | if ( pic.isIntern() ) { | 693 | if ( pic.isIntern() ) { |
694 | //US emit contactSelected( pic.data() ); | 694 | //US emit contactSelected( pic.data() ); |
695 | //US instead use: | 695 | //US instead use: |
696 | QPixmap px; | 696 | QPixmap px; |
697 | if (pic.data().isNull() != true) | 697 | if (pic.data().isNull() != true) |
698 | { | 698 | { |
699 | px.convertFromImage(pic.data()); | 699 | px.convertFromImage(pic.data()); |
700 | } | 700 | } |
701 | 701 | ||
702 | emit contactSelected( px ); | 702 | emit contactSelected( px ); |
703 | } | 703 | } |
704 | } | 704 | } |
705 | 705 | ||
706 | 706 | ||
707 | mExtensionManager->setSelectionChanged(); | 707 | mExtensionManager->setSelectionChanged(); |
708 | 708 | ||
709 | // update the actions | 709 | // update the actions |
710 | bool selected = !uid.isEmpty(); | 710 | bool selected = !uid.isEmpty(); |
711 | 711 | ||
712 | if ( mReadWrite ) { | 712 | if ( mReadWrite ) { |
713 | mActionCut->setEnabled( selected ); | 713 | mActionCut->setEnabled( selected ); |
714 | mActionPaste->setEnabled( selected ); | 714 | mActionPaste->setEnabled( selected ); |
715 | } | 715 | } |
716 | 716 | ||
717 | mActionCopy->setEnabled( selected ); | 717 | mActionCopy->setEnabled( selected ); |
718 | mActionDelete->setEnabled( selected ); | 718 | mActionDelete->setEnabled( selected ); |
719 | mActionEditAddressee->setEnabled( selected ); | 719 | mActionEditAddressee->setEnabled( selected ); |
720 | mActionMail->setEnabled( selected ); | 720 | mActionMail->setEnabled( selected ); |
721 | mActionMailVCard->setEnabled( selected ); | 721 | mActionMailVCard->setEnabled( selected ); |
722 | //if (mActionBeam) | 722 | //if (mActionBeam) |
723 | //mActionBeam->setEnabled( selected ); | 723 | //mActionBeam->setEnabled( selected ); |
724 | mActionWhoAmI->setEnabled( selected ); | 724 | mActionWhoAmI->setEnabled( selected ); |
725 | } | 725 | } |
726 | 726 | ||
727 | void KABCore::sendMail() | 727 | void KABCore::sendMail() |
728 | { | 728 | { |
729 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 729 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
730 | } | 730 | } |
731 | 731 | ||
732 | void KABCore::sendMail( const QString& emaillist ) | 732 | void KABCore::sendMail( const QString& emaillist ) |
733 | { | 733 | { |
734 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 734 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
735 | if (emaillist.contains(",") > 0) | 735 | if (emaillist.contains(",") > 0) |
736 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 736 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
737 | else | 737 | else |
738 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 738 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
739 | } | 739 | } |
740 | 740 | ||
741 | 741 | ||
742 | 742 | ||
743 | void KABCore::mailVCard() | 743 | void KABCore::mailVCard() |
744 | { | 744 | { |
745 | QStringList uids = mViewManager->selectedUids(); | 745 | QStringList uids = mViewManager->selectedUids(); |
746 | if ( !uids.isEmpty() ) | 746 | if ( !uids.isEmpty() ) |
747 | mailVCard( uids ); | 747 | mailVCard( uids ); |
748 | } | 748 | } |
749 | 749 | ||
750 | void KABCore::mailVCard( const QStringList& uids ) | 750 | void KABCore::mailVCard( const QStringList& uids ) |
751 | { | 751 | { |
752 | QStringList urls; | 752 | QStringList urls; |
753 | 753 | ||
754 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 754 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
755 | 755 | ||
756 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 756 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
757 | 757 | ||
758 | 758 | ||
759 | 759 | ||
760 | QDir().mkdir( dirName, true ); | 760 | QDir().mkdir( dirName, true ); |
761 | 761 | ||
762 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 762 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
763 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 763 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
764 | 764 | ||
765 | if ( a.isEmpty() ) | 765 | if ( a.isEmpty() ) |
766 | continue; | 766 | continue; |
767 | 767 | ||
768 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 768 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
769 | 769 | ||
770 | QString fileName = dirName + "/" + name; | 770 | QString fileName = dirName + "/" + name; |
771 | 771 | ||
772 | QFile outFile(fileName); | 772 | QFile outFile(fileName); |
773 | 773 | ||
774 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 774 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
775 | KABC::VCardConverter converter; | 775 | KABC::VCardConverter converter; |
776 | QString vcard; | 776 | QString vcard; |
777 | 777 | ||
778 | converter.addresseeToVCard( a, vcard ); | 778 | converter.addresseeToVCard( a, vcard ); |
779 | 779 | ||
780 | QTextStream t( &outFile ); // use a text stream | 780 | QTextStream t( &outFile ); // use a text stream |
781 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 781 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
782 | t << vcard; | 782 | t << vcard; |
783 | 783 | ||
784 | outFile.close(); | 784 | outFile.close(); |
785 | 785 | ||
786 | urls.append( fileName ); | 786 | urls.append( fileName ); |
787 | } | 787 | } |
788 | } | 788 | } |
789 | 789 | ||
790 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 790 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
791 | 791 | ||
792 | 792 | ||
793 | /*US | 793 | /*US |
794 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 794 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
795 | QString::null, // subject | 795 | QString::null, // subject |
796 | QString::null, // body | 796 | QString::null, // body |
797 | QString::null, | 797 | QString::null, |
798 | urls ); // attachments | 798 | urls ); // attachments |
799 | */ | 799 | */ |
800 | 800 | ||
801 | } | 801 | } |
802 | 802 | ||
803 | /** | 803 | /** |
804 | Beams the "WhoAmI contact. | 804 | Beams the "WhoAmI contact. |
805 | */ | 805 | */ |
806 | void KABCore::beamMySelf() | 806 | void KABCore::beamMySelf() |
807 | { | 807 | { |
808 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 808 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
809 | if (!a.isEmpty()) | 809 | if (!a.isEmpty()) |
810 | { | 810 | { |
811 | QStringList uids; | 811 | QStringList uids; |
812 | uids << a.uid(); | 812 | uids << a.uid(); |
813 | 813 | ||
814 | beamVCard(uids); | 814 | beamVCard(uids); |
815 | } else { | 815 | } else { |
816 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 816 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
817 | 817 | ||
818 | 818 | ||
819 | } | 819 | } |
820 | } | 820 | } |
821 | void KABCore::updateMainWindow() | 821 | void KABCore::updateMainWindow() |
822 | { | 822 | { |
823 | mMainWindow->showMaximized(); | 823 | mMainWindow->showMaximized(); |
824 | mMainWindow->update(); | 824 | mMainWindow->update(); |
825 | } | 825 | } |
826 | void KABCore::resizeEvent(QResizeEvent* e ) | 826 | void KABCore::resizeEvent(QResizeEvent* e ) |
827 | { | 827 | { |
828 | if ( !mMiniSplitter ) | 828 | if ( !mMiniSplitter ) |
829 | return; | 829 | return; |
830 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); | 830 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); |
831 | if ( e->oldSize().width() != e->size().width() ) | ||
831 | if ( QApplication::desktop()->width() >= 480 ) { | 832 | if ( QApplication::desktop()->width() >= 480 ) { |
832 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 833 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
833 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 834 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
834 | mMiniSplitter->setOrientation( Qt::Horizontal); | 835 | mMiniSplitter->setOrientation( Qt::Horizontal); |
835 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 836 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
836 | } | 837 | } |
837 | if ( QApplication::desktop()->width() <= 640 ) { | 838 | if ( QApplication::desktop()->width() <= 640 ) { |
838 | mMainWindow->showMinimized(); | 839 | mMainWindow->showMinimized(); |
839 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 840 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
840 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 841 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
841 | if ( mIncSearchWidget ) | 842 | if ( mIncSearchWidget ) |
842 | mIncSearchWidget->setSize(); | 843 | mIncSearchWidget->setSize(); |
843 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 844 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
844 | } | 845 | } |
845 | 846 | ||
846 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 847 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
847 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 848 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
848 | mMiniSplitter->setOrientation( Qt::Vertical ); | 849 | mMiniSplitter->setOrientation( Qt::Vertical ); |
849 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 850 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
850 | } | 851 | } |
851 | if ( QApplication::desktop()->width() <= 640 ) { | 852 | if ( QApplication::desktop()->width() <= 640 ) { |
852 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 853 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
853 | mMainWindow->showMinimized(); | 854 | mMainWindow->showMinimized(); |
854 | if ( KABPrefs::instance()->mHideSearchOnSwitch ) { | 855 | if ( KABPrefs::instance()->mHideSearchOnSwitch ) { |
855 | if ( mIncSearchWidget ) { | 856 | if ( mIncSearchWidget ) { |
856 | mIncSearchWidget->setSize(); | 857 | mIncSearchWidget->setSize(); |
857 | } | 858 | } |
858 | } else { | 859 | } else { |
859 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 860 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
860 | } | 861 | } |
861 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 862 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
862 | } | 863 | } |
863 | } | 864 | } |
864 | } | 865 | } |
865 | QWidget::resizeEvent( e ); | 866 | QWidget::resizeEvent( e ); |
866 | 867 | ||
867 | } | 868 | } |
868 | void KABCore::export2phone() | 869 | void KABCore::export2phone() |
869 | { | 870 | { |
870 | 871 | ||
871 | QStringList uids; | 872 | QStringList uids; |
872 | XXPortSelectDialog dlg( this, false, this ); | 873 | XXPortSelectDialog dlg( this, false, this ); |
873 | if ( dlg.exec() ) | 874 | if ( dlg.exec() ) |
874 | uids = dlg.uids(); | 875 | uids = dlg.uids(); |
875 | else | 876 | else |
876 | return; | 877 | return; |
877 | if ( uids.isEmpty() ) | 878 | if ( uids.isEmpty() ) |
878 | return; | 879 | return; |
879 | // qDebug("count %d ", uids.count()); | 880 | // qDebug("count %d ", uids.count()); |
880 | 881 | ||
881 | KAex2phonePrefs ex2phone; | 882 | KAex2phonePrefs ex2phone; |
882 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 883 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
883 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 884 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
884 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 885 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
885 | 886 | ||
886 | if ( !ex2phone.exec() ) { | 887 | if ( !ex2phone.exec() ) { |
887 | return; | 888 | return; |
888 | } | 889 | } |
889 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 890 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
890 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 891 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
891 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 892 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
892 | 893 | ||
893 | 894 | ||
894 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 895 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
895 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 896 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
896 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 897 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
897 | 898 | ||
898 | QString fileName = getPhoneFile(); | 899 | QString fileName = getPhoneFile(); |
899 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 900 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
900 | return; | 901 | return; |
901 | 902 | ||
902 | message(i18n("Exporting to phone...")); | 903 | message(i18n("Exporting to phone...")); |
903 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 904 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
904 | 905 | ||
905 | } | 906 | } |
906 | QString KABCore::getPhoneFile() | 907 | QString KABCore::getPhoneFile() |
907 | { | 908 | { |
908 | #ifdef DESKTOP_VERSION | 909 | #ifdef DESKTOP_VERSION |
909 | return locateLocal("tmp", "phonefile.vcf"); | 910 | return locateLocal("tmp", "phonefile.vcf"); |
910 | #else | 911 | #else |
911 | return "/tmp/phonefile.vcf"; | 912 | return "/tmp/phonefile.vcf"; |
912 | #endif | 913 | #endif |
913 | 914 | ||
914 | } | 915 | } |
915 | void KABCore::writeToPhone( ) | 916 | void KABCore::writeToPhone( ) |
916 | { | 917 | { |
917 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 918 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
918 | message(i18n("Export to phone finished!")); | 919 | message(i18n("Export to phone finished!")); |
919 | else | 920 | else |
920 | qDebug(i18n("KA: Error exporting to phone")); | 921 | qDebug(i18n("KA: Error exporting to phone")); |
921 | } | 922 | } |
922 | void KABCore::beamVCard() | 923 | void KABCore::beamVCard() |
923 | { | 924 | { |
924 | QStringList uids; | 925 | QStringList uids; |
925 | XXPortSelectDialog dlg( this, false, this ); | 926 | XXPortSelectDialog dlg( this, false, this ); |
926 | if ( dlg.exec() ) | 927 | if ( dlg.exec() ) |
927 | uids = dlg.uids(); | 928 | uids = dlg.uids(); |
928 | else | 929 | else |
929 | return; | 930 | return; |
930 | if ( uids.isEmpty() ) | 931 | if ( uids.isEmpty() ) |
931 | return; | 932 | return; |
932 | beamVCard( uids ); | 933 | beamVCard( uids ); |
933 | } | 934 | } |
934 | 935 | ||
935 | 936 | ||
936 | void KABCore::beamVCard(const QStringList& uids) | 937 | void KABCore::beamVCard(const QStringList& uids) |
937 | { | 938 | { |
938 | 939 | ||
939 | // LR: we should use the /tmp dir on the Zaurus, | 940 | // LR: we should use the /tmp dir on the Zaurus, |
940 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 941 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
941 | 942 | ||
942 | #ifdef DESKTOP_VERSION | 943 | #ifdef DESKTOP_VERSION |
943 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 944 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
944 | #else | 945 | #else |
945 | QString fileName = "/tmp/kapibeamfile.vcf"; | 946 | QString fileName = "/tmp/kapibeamfile.vcf"; |
946 | #endif | 947 | #endif |
947 | 948 | ||
948 | KABC::VCardConverter converter; | 949 | KABC::VCardConverter converter; |
949 | QString description; | 950 | QString description; |
950 | QString datastream; | 951 | QString datastream; |
951 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 952 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
952 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 953 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
953 | 954 | ||
954 | if ( a.isEmpty() ) | 955 | if ( a.isEmpty() ) |
955 | continue; | 956 | continue; |
956 | 957 | ||
957 | if (description.isEmpty()) | 958 | if (description.isEmpty()) |
958 | description = a.formattedName(); | 959 | description = a.formattedName(); |
959 | 960 | ||
960 | QString vcard; | 961 | QString vcard; |
961 | converter.addresseeToVCard( a, vcard ); | 962 | converter.addresseeToVCard( a, vcard ); |
962 | int start = 0; | 963 | int start = 0; |
963 | int next; | 964 | int next; |
964 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 965 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
965 | int semi = vcard.find(";", next); | 966 | int semi = vcard.find(";", next); |
966 | int dopp = vcard.find(":", next); | 967 | int dopp = vcard.find(":", next); |
967 | int sep; | 968 | int sep; |
968 | if ( semi < dopp && semi >= 0 ) | 969 | if ( semi < dopp && semi >= 0 ) |
969 | sep = semi ; | 970 | sep = semi ; |
970 | else | 971 | else |
971 | sep = dopp; | 972 | sep = dopp; |
972 | datastream +=vcard.mid( start, next - start); | 973 | datastream +=vcard.mid( start, next - start); |
973 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 974 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
974 | start = sep; | 975 | start = sep; |
975 | } | 976 | } |
976 | datastream += vcard.mid( start,vcard.length() ); | 977 | datastream += vcard.mid( start,vcard.length() ); |
977 | } | 978 | } |
978 | #ifndef DESKTOP_VERSION | 979 | #ifndef DESKTOP_VERSION |
979 | QFile outFile(fileName); | 980 | QFile outFile(fileName); |
980 | if ( outFile.open(IO_WriteOnly) ) { | 981 | if ( outFile.open(IO_WriteOnly) ) { |
981 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 982 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
982 | QTextStream t( &outFile ); // use a text stream | 983 | QTextStream t( &outFile ); // use a text stream |
983 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 984 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
984 | t.setEncoding( QTextStream::Latin1 ); | 985 | t.setEncoding( QTextStream::Latin1 ); |
985 | t <<datastream.latin1(); | 986 | t <<datastream.latin1(); |
986 | outFile.close(); | 987 | outFile.close(); |
987 | Ir *ir = new Ir( this ); | 988 | Ir *ir = new Ir( this ); |
988 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 989 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
989 | ir->send( fileName, description, "text/x-vCard" ); | 990 | ir->send( fileName, description, "text/x-vCard" ); |
990 | } else { | 991 | } else { |
991 | qDebug("KA: Error open temp beam file "); | 992 | qDebug("KA: Error open temp beam file "); |
992 | return; | 993 | return; |
993 | } | 994 | } |
994 | #endif | 995 | #endif |
995 | 996 | ||
996 | } | 997 | } |
997 | 998 | ||
998 | void KABCore::beamDone( Ir *ir ) | 999 | void KABCore::beamDone( Ir *ir ) |
999 | { | 1000 | { |
1000 | #ifndef DESKTOP_VERSION | 1001 | #ifndef DESKTOP_VERSION |
1001 | delete ir; | 1002 | delete ir; |
1002 | #endif | 1003 | #endif |
1003 | topLevelWidget()->raise(); | 1004 | topLevelWidget()->raise(); |
1004 | message( i18n("Beaming finished!") ); | 1005 | message( i18n("Beaming finished!") ); |
1005 | } | 1006 | } |
1006 | 1007 | ||
1007 | 1008 | ||
1008 | void KABCore::browse( const QString& url ) | 1009 | void KABCore::browse( const QString& url ) |
1009 | { | 1010 | { |
1010 | #ifndef KAB_EMBEDDED | 1011 | #ifndef KAB_EMBEDDED |
1011 | kapp->invokeBrowser( url ); | 1012 | kapp->invokeBrowser( url ); |
1012 | #else //KAB_EMBEDDED | 1013 | #else //KAB_EMBEDDED |
1013 | qDebug("KABCore::browse must be fixed"); | 1014 | qDebug("KABCore::browse must be fixed"); |
1014 | #endif //KAB_EMBEDDED | 1015 | #endif //KAB_EMBEDDED |
1015 | } | 1016 | } |
1016 | 1017 | ||
1017 | void KABCore::selectAllContacts() | 1018 | void KABCore::selectAllContacts() |
1018 | { | 1019 | { |
1019 | mViewManager->setSelected( QString::null, true ); | 1020 | mViewManager->setSelected( QString::null, true ); |
1020 | } | 1021 | } |
1021 | 1022 | ||
1022 | void KABCore::deleteContacts() | 1023 | void KABCore::deleteContacts() |