-rw-r--r-- | kaddressbook/incsearchwidget.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 42 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/viewmanager.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 6 |
5 files changed, 48 insertions, 15 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp index 94c37e7..2ffa357 100644 --- a/kaddressbook/incsearchwidget.cpp +++ b/kaddressbook/incsearchwidget.cpp | |||
@@ -1,147 +1,150 @@ | |||
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 <qcombobox.h> | 27 | #include <qcombobox.h> |
28 | 28 | ||
29 | #include <kdialog.h> | 29 | #include <kdialog.h> |
30 | #include <klineedit.h> | 30 | #include <klineedit.h> |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | 33 | ||
34 | #include "incsearchwidget.h" | 34 | #include "incsearchwidget.h" |
35 | 35 | ||
36 | IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) | 36 | IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) |
37 | : QWidget( parent, name ) | 37 | : QWidget( parent, name ) |
38 | { | 38 | { |
39 | #ifndef KAB_EMBEDDED | 39 | #ifndef KAB_EMBEDDED |
40 | //US setCaption( i18n( "Incremental Search" ) ); | 40 | //US setCaption( i18n( "Incremental Search" ) ); |
41 | #endif //KAB_EMBEDDED | 41 | #endif //KAB_EMBEDDED |
42 | 42 | ||
43 | QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); | 43 | QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); |
44 | 44 | ||
45 | #ifdef DESKTOP_VERSION | 45 | #ifdef DESKTOP_VERSION |
46 | QLabel *label = new QLabel( i18n( "Search:" ), this ); | 46 | QLabel *label = new QLabel( i18n( "Search:" ), this ); |
47 | label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); | 47 | label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); |
48 | layout->addWidget( label ); | 48 | layout->addWidget( label ); |
49 | #endif //KAB_EMBEDDED | 49 | #endif //KAB_EMBEDDED |
50 | 50 | ||
51 | mSearchText = new KLineEdit( this ); | 51 | mSearchText = new KLineEdit( this ); |
52 | layout->addWidget( mSearchText ); | 52 | layout->addWidget( mSearchText ); |
53 | // #ifdef KAB_EMBEDDED | 53 | // #ifdef KAB_EMBEDDED |
54 | // if (KGlobal::getOrientation() == KGlobal::Portrait) | 54 | // if (KGlobal::getOrientation() == KGlobal::Portrait) |
55 | // mSearchText->setMaximumWidth(30); | 55 | // mSearchText->setMaximumWidth(30); |
56 | // #endif //KAB_EMBEDDED | 56 | // #endif //KAB_EMBEDDED |
57 | 57 | ||
58 | 58 | ||
59 | mFieldCombo = new QComboBox( false, this ); | 59 | mFieldCombo = new QComboBox( false, this ); |
60 | layout->addWidget( mFieldCombo ); | 60 | layout->addWidget( mFieldCombo ); |
61 | mFieldCombo->setMaximumHeight( 34 ); | 61 | mFieldCombo->setMaximumHeight( 34 ); |
62 | QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); | 62 | QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); |
63 | 63 | ||
64 | // #ifndef KAB_EMBEDDED | 64 | // #ifndef KAB_EMBEDDED |
65 | // resize( QSize(420, 50).expandedTo( sizeHint() ) ); | 65 | // resize( QSize(420, 50).expandedTo( sizeHint() ) ); |
66 | // #else //KAB_EMBEDDED | 66 | // #else //KAB_EMBEDDED |
67 | // resize( QSize(30, 10).expandedTo( sizeHint() ) ); | 67 | // resize( QSize(30, 10).expandedTo( sizeHint() ) ); |
68 | // #endif //KAB_EMBEDDED | 68 | // #endif //KAB_EMBEDDED |
69 | 69 | ||
70 | #ifdef DESKTOP_VERSION | ||
71 | // for performance reasons, we do a search on the pda only after return is pressed | ||
70 | connect( mSearchText, SIGNAL( textChanged( const QString& ) ), | 72 | connect( mSearchText, SIGNAL( textChanged( const QString& ) ), |
71 | SLOT( announceDoSearch() ) ); | 73 | SLOT( announceDoSearch() ) ); |
72 | connect( mSearchText, SIGNAL( returnPressed() ), | ||
73 | SLOT( announceDoSearch() ) ); | ||
74 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), | 74 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), |
75 | SLOT( announceDoSearch() ) ); | 75 | SLOT( announceDoSearch() ) ); |
76 | #endif | ||
77 | connect( mSearchText, SIGNAL( returnPressed() ), | ||
78 | SLOT( announceDoSearch() ) ); | ||
76 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), | 79 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), |
77 | SLOT( announceFieldChanged() ) ); | 80 | SLOT( announceFieldChanged() ) ); |
78 | 81 | ||
79 | setFocusProxy( mSearchText ); | 82 | setFocusProxy( mSearchText ); |
80 | } | 83 | } |
81 | 84 | ||
82 | IncSearchWidget::~IncSearchWidget() | 85 | IncSearchWidget::~IncSearchWidget() |
83 | { | 86 | { |
84 | 87 | ||
85 | } | 88 | } |
86 | 89 | ||
87 | void IncSearchWidget::announceDoSearch() | 90 | void IncSearchWidget::announceDoSearch() |
88 | { | 91 | { |
89 | emit doSearch( mSearchText->text() ); | 92 | emit doSearch( mSearchText->text() ); |
90 | } | 93 | } |
91 | 94 | ||
92 | void IncSearchWidget::announceFieldChanged() | 95 | void IncSearchWidget::announceFieldChanged() |
93 | { | 96 | { |
94 | emit fieldChanged(); | 97 | emit fieldChanged(); |
95 | } | 98 | } |
96 | 99 | ||
97 | void IncSearchWidget::setFields( const KABC::Field::List &list ) | 100 | void IncSearchWidget::setFields( const KABC::Field::List &list ) |
98 | { | 101 | { |
99 | 102 | ||
100 | mFieldCombo->clear(); | 103 | mFieldCombo->clear(); |
101 | mFieldCombo->insertItem( i18n( "All Fields" ) ); | 104 | mFieldCombo->insertItem( i18n( "All Fields" ) ); |
102 | QFontMetrics fm ( mFieldCombo->font() ); | 105 | QFontMetrics fm ( mFieldCombo->font() ); |
103 | int wid = fm.width(i18n( "All Fields" ) ); | 106 | int wid = fm.width(i18n( "All Fields" ) ); |
104 | int max = wid; | 107 | int max = wid; |
105 | 108 | ||
106 | KABC::Field::List::ConstIterator it; | 109 | KABC::Field::List::ConstIterator it; |
107 | for ( it = list.begin(); it != list.end(); ++it ) { | 110 | for ( it = list.begin(); it != list.end(); ++it ) { |
108 | mFieldCombo->insertItem( (*it)->label() ); | 111 | mFieldCombo->insertItem( (*it)->label() ); |
109 | // wid = fm.width((*it)->label() ); | 112 | // wid = fm.width((*it)->label() ); |
110 | //if ( wid > max ) | 113 | //if ( wid > max ) |
111 | // max = wid; | 114 | // max = wid; |
112 | } | 115 | } |
113 | 116 | ||
114 | mFieldList = list; | 117 | mFieldList = list; |
115 | 118 | ||
116 | announceDoSearch(); | 119 | announceDoSearch(); |
117 | announceFieldChanged(); | 120 | announceFieldChanged(); |
118 | mFieldCombo->setMaximumWidth( wid+60 ); | 121 | mFieldCombo->setMaximumWidth( wid+60 ); |
119 | } | 122 | } |
120 | 123 | ||
121 | KABC::Field::List IncSearchWidget::fields() const | 124 | KABC::Field::List IncSearchWidget::fields() const |
122 | { | 125 | { |
123 | return mFieldList; | 126 | return mFieldList; |
124 | } | 127 | } |
125 | 128 | ||
126 | KABC::Field *IncSearchWidget::currentField()const | 129 | KABC::Field *IncSearchWidget::currentField()const |
127 | { | 130 | { |
128 | if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) | 131 | if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) |
129 | return 0; // for error or 'use all fields' | 132 | return 0; // for error or 'use all fields' |
130 | else | 133 | else |
131 | return mFieldList[ mFieldCombo->currentItem() - 1 ]; | 134 | return mFieldList[ mFieldCombo->currentItem() - 1 ]; |
132 | } | 135 | } |
133 | 136 | ||
134 | void IncSearchWidget::setCurrentItem( int pos ) | 137 | void IncSearchWidget::setCurrentItem( int pos ) |
135 | { | 138 | { |
136 | mFieldCombo->setCurrentItem( pos ); | 139 | mFieldCombo->setCurrentItem( pos ); |
137 | announceFieldChanged(); | 140 | announceFieldChanged(); |
138 | } | 141 | } |
139 | 142 | ||
140 | int IncSearchWidget::currentItem() const | 143 | int IncSearchWidget::currentItem() const |
141 | { | 144 | { |
142 | 145 | ||
143 | return mFieldCombo->currentItem(); | 146 | return mFieldCombo->currentItem(); |
144 | } | 147 | } |
145 | #ifndef KAB_EMBEDDED | 148 | #ifndef KAB_EMBEDDED |
146 | #include "incsearchwidget.moc" | 149 | #include "incsearchwidget.moc" |
147 | #endif //KAB_EMBEDDED | 150 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index f0f08f4..4299ebd 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -68,1563 +68,1585 @@ $Id$ | |||
68 | #include "kaddressbookservice.h" | 68 | #include "kaddressbookservice.h" |
69 | #include "ldapsearchdialog.h" | 69 | #include "ldapsearchdialog.h" |
70 | #include "printing/printingwizard.h" | 70 | #include "printing/printingwizard.h" |
71 | #else // KAB_EMBEDDED | 71 | #else // KAB_EMBEDDED |
72 | 72 | ||
73 | #include <kapplication.h> | 73 | #include <kapplication.h> |
74 | #include "KDGanttMinimizeSplitter.h" | 74 | #include "KDGanttMinimizeSplitter.h" |
75 | #include "kaddressbookmain.h" | 75 | #include "kaddressbookmain.h" |
76 | #include "kactioncollection.h" | 76 | #include "kactioncollection.h" |
77 | #include "addresseedialog.h" | 77 | #include "addresseedialog.h" |
78 | //US | 78 | //US |
79 | #include <libkdepim/addresseeview.h> | 79 | #include <libkdepim/addresseeview.h> |
80 | 80 | ||
81 | #include <qapp.h> | 81 | #include <qapp.h> |
82 | #include <qmenubar.h> | 82 | #include <qmenubar.h> |
83 | //#include <qtoolbar.h> | 83 | //#include <qtoolbar.h> |
84 | #include <qmessagebox.h> | 84 | #include <qmessagebox.h> |
85 | #include <kdebug.h> | 85 | #include <kdebug.h> |
86 | #include <kiconloader.h> // needed for SmallIcon | 86 | #include <kiconloader.h> // needed for SmallIcon |
87 | #include <kresources/kcmkresources.h> | 87 | #include <kresources/kcmkresources.h> |
88 | #include <ktoolbar.h> | 88 | #include <ktoolbar.h> |
89 | 89 | ||
90 | 90 | ||
91 | //#include <qlabel.h> | 91 | //#include <qlabel.h> |
92 | 92 | ||
93 | 93 | ||
94 | #ifndef DESKTOP_VERSION | 94 | #ifndef DESKTOP_VERSION |
95 | #include <qpe/ir.h> | 95 | #include <qpe/ir.h> |
96 | #include <qtopia/qcopenvelope_qws.h> | 96 | #include <qtopia/qcopenvelope_qws.h> |
97 | #else | 97 | #else |
98 | 98 | ||
99 | #endif | 99 | #endif |
100 | 100 | ||
101 | #endif // KAB_EMBEDDED | 101 | #endif // KAB_EMBEDDED |
102 | #include "kcmconfigs/kcmkabconfig.h" | 102 | #include "kcmconfigs/kcmkabconfig.h" |
103 | #include "kcmconfigs/kcmkdepimconfig.h" | 103 | #include "kcmconfigs/kcmkdepimconfig.h" |
104 | #include "kpimglobalprefs.h" | 104 | #include "kpimglobalprefs.h" |
105 | #include "externalapphandler.h" | 105 | #include "externalapphandler.h" |
106 | 106 | ||
107 | 107 | ||
108 | #include <kresources/selectdialog.h> | 108 | #include <kresources/selectdialog.h> |
109 | #include <kmessagebox.h> | 109 | #include <kmessagebox.h> |
110 | 110 | ||
111 | #include <picture.h> | 111 | #include <picture.h> |
112 | #include <resource.h> | 112 | #include <resource.h> |
113 | 113 | ||
114 | //US#include <qsplitter.h> | 114 | //US#include <qsplitter.h> |
115 | #include <qmap.h> | 115 | #include <qmap.h> |
116 | #include <qdir.h> | 116 | #include <qdir.h> |
117 | #include <qfile.h> | 117 | #include <qfile.h> |
118 | #include <qvbox.h> | 118 | #include <qvbox.h> |
119 | #include <qlayout.h> | 119 | #include <qlayout.h> |
120 | #include <qclipboard.h> | 120 | #include <qclipboard.h> |
121 | #include <qtextstream.h> | 121 | #include <qtextstream.h> |
122 | 122 | ||
123 | #include <libkdepim/categoryselectdialog.h> | 123 | #include <libkdepim/categoryselectdialog.h> |
124 | #include <kabc/vcardconverter.h> | 124 | #include <kabc/vcardconverter.h> |
125 | 125 | ||
126 | 126 | ||
127 | #include "addresseeutil.h" | 127 | #include "addresseeutil.h" |
128 | #include "undocmds.h" | 128 | #include "undocmds.h" |
129 | #include "addresseeeditordialog.h" | 129 | #include "addresseeeditordialog.h" |
130 | #include "viewmanager.h" | 130 | #include "viewmanager.h" |
131 | #include "details/detailsviewcontainer.h" | 131 | #include "details/detailsviewcontainer.h" |
132 | #include "kabprefs.h" | 132 | #include "kabprefs.h" |
133 | #include "xxportmanager.h" | 133 | #include "xxportmanager.h" |
134 | #include "incsearchwidget.h" | 134 | #include "incsearchwidget.h" |
135 | #include "jumpbuttonbar.h" | 135 | #include "jumpbuttonbar.h" |
136 | #include "extensionmanager.h" | 136 | #include "extensionmanager.h" |
137 | #include "addresseeconfig.h" | 137 | #include "addresseeconfig.h" |
138 | #include <kcmultidialog.h> | 138 | #include <kcmultidialog.h> |
139 | 139 | ||
140 | #ifdef _WIN32_ | 140 | #ifdef _WIN32_ |
141 | 141 | ||
142 | #include "kaimportoldialog.h" | 142 | #include "kaimportoldialog.h" |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | bool pasteWithNewUid = true; | 145 | bool pasteWithNewUid = true; |
146 | 146 | ||
147 | #ifdef KAB_EMBEDDED | 147 | #ifdef KAB_EMBEDDED |
148 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 148 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
149 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 149 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
150 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 150 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
151 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 151 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
152 | #else //KAB_EMBEDDED | 152 | #else //KAB_EMBEDDED |
153 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 153 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
154 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 154 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
155 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 155 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
156 | mReadWrite( readWrite ), mModified( false ) | 156 | mReadWrite( readWrite ), mModified( false ) |
157 | #endif //KAB_EMBEDDED | 157 | #endif //KAB_EMBEDDED |
158 | { | 158 | { |
159 | 159 | ||
160 | mExtensionBarSplitter = 0; | 160 | mExtensionBarSplitter = 0; |
161 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 161 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
162 | 162 | ||
163 | mAddressBook = KABC::StdAddressBook::self(); | 163 | mAddressBook = KABC::StdAddressBook::self(); |
164 | KABC::StdAddressBook::setAutomaticSave( false ); | 164 | KABC::StdAddressBook::setAutomaticSave( false ); |
165 | 165 | ||
166 | #ifndef KAB_EMBEDDED | 166 | #ifndef KAB_EMBEDDED |
167 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 167 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
168 | #endif //KAB_EMBEDDED | 168 | #endif //KAB_EMBEDDED |
169 | 169 | ||
170 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 170 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
171 | SLOT( addressBookChanged() ) ); | 171 | SLOT( addressBookChanged() ) ); |
172 | 172 | ||
173 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 173 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
174 | "X-Department", "KADDRESSBOOK" ); | 174 | "X-Department", "KADDRESSBOOK" ); |
175 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 175 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
176 | "X-Profession", "KADDRESSBOOK" ); | 176 | "X-Profession", "KADDRESSBOOK" ); |
177 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 177 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
178 | "X-AssistantsName", "KADDRESSBOOK" ); | 178 | "X-AssistantsName", "KADDRESSBOOK" ); |
179 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 179 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
180 | "X-ManagersName", "KADDRESSBOOK" ); | 180 | "X-ManagersName", "KADDRESSBOOK" ); |
181 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 181 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
182 | "X-SpousesName", "KADDRESSBOOK" ); | 182 | "X-SpousesName", "KADDRESSBOOK" ); |
183 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 183 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
184 | "X-Office", "KADDRESSBOOK" ); | 184 | "X-Office", "KADDRESSBOOK" ); |
185 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 185 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
186 | "X-IMAddress", "KADDRESSBOOK" ); | 186 | "X-IMAddress", "KADDRESSBOOK" ); |
187 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 187 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
188 | "X-Anniversary", "KADDRESSBOOK" ); | 188 | "X-Anniversary", "KADDRESSBOOK" ); |
189 | 189 | ||
190 | //US added this field to become compatible with Opie/qtopia addressbook | 190 | //US added this field to become compatible with Opie/qtopia addressbook |
191 | // values can be "female" or "male" or "". An empty field represents undefined. | 191 | // values can be "female" or "male" or "". An empty field represents undefined. |
192 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 192 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
193 | "X-Gender", "KADDRESSBOOK" ); | 193 | "X-Gender", "KADDRESSBOOK" ); |
194 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 194 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
195 | "X-Children", "KADDRESSBOOK" ); | 195 | "X-Children", "KADDRESSBOOK" ); |
196 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 196 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
197 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 197 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
198 | 198 | ||
199 | initGUI(); | 199 | initGUI(); |
200 | 200 | ||
201 | mIncSearchWidget->setFocus(); | 201 | mIncSearchWidget->setFocus(); |
202 | 202 | ||
203 | 203 | ||
204 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 204 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
205 | SLOT( setContactSelected( const QString& ) ) ); | 205 | SLOT( setContactSelected( const QString& ) ) ); |
206 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 206 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
207 | SLOT( executeContact( const QString& ) ) ); | 207 | SLOT( executeContact( const QString& ) ) ); |
208 | 208 | ||
209 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 209 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
210 | SLOT( deleteContacts( ) ) ); | 210 | SLOT( deleteContacts( ) ) ); |
211 | connect( mViewManager, SIGNAL( modified() ), | 211 | connect( mViewManager, SIGNAL( modified() ), |
212 | SLOT( setModified() ) ); | 212 | SLOT( setModified() ) ); |
213 | 213 | ||
214 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 214 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
215 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 215 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
216 | 216 | ||
217 | connect( mXXPortManager, SIGNAL( modified() ), | 217 | connect( mXXPortManager, SIGNAL( modified() ), |
218 | SLOT( setModified() ) ); | 218 | SLOT( setModified() ) ); |
219 | 219 | ||
220 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 220 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
221 | SLOT( incrementalSearch( const QString& ) ) ); | 221 | SLOT( incrementalSearch( const QString& ) ) ); |
222 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 222 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
223 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 223 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
224 | 224 | ||
225 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 225 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
226 | SLOT( sendMail( const QString& ) ) ); | 226 | SLOT( sendMail( const QString& ) ) ); |
227 | 227 | ||
228 | 228 | ||
229 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 229 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
230 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 230 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
231 | 231 | ||
232 | 232 | ||
233 | #ifndef KAB_EMBEDDED | 233 | #ifndef KAB_EMBEDDED |
234 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 234 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
235 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 235 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
236 | 236 | ||
237 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 237 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
238 | SLOT( browse( const QString& ) ) ); | 238 | SLOT( browse( const QString& ) ) ); |
239 | 239 | ||
240 | 240 | ||
241 | mAddressBookService = new KAddressBookService( this ); | 241 | mAddressBookService = new KAddressBookService( this ); |
242 | 242 | ||
243 | #endif //KAB_EMBEDDED | 243 | #endif //KAB_EMBEDDED |
244 | mEditorDialog = 0; | 244 | mEditorDialog = 0; |
245 | createAddresseeEditorDialog( this ); | 245 | createAddresseeEditorDialog( this ); |
246 | setModified( false ); | 246 | setModified( false ); |
247 | } | 247 | } |
248 | 248 | ||
249 | KABCore::~KABCore() | 249 | KABCore::~KABCore() |
250 | { | 250 | { |
251 | // save(); | 251 | // save(); |
252 | //saveSettings(); | 252 | //saveSettings(); |
253 | //KABPrefs::instance()->writeConfig(); | 253 | //KABPrefs::instance()->writeConfig(); |
254 | delete AddresseeConfig::instance(); | 254 | delete AddresseeConfig::instance(); |
255 | mAddressBook = 0; | 255 | mAddressBook = 0; |
256 | KABC::StdAddressBook::close(); | 256 | KABC::StdAddressBook::close(); |
257 | } | 257 | } |
258 | 258 | ||
259 | void KABCore::restoreSettings() | 259 | void KABCore::restoreSettings() |
260 | { | 260 | { |
261 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 261 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
262 | 262 | ||
263 | bool state; | 263 | bool state; |
264 | 264 | ||
265 | if (mMultipleViewsAtOnce) | 265 | if (mMultipleViewsAtOnce) |
266 | state = KABPrefs::instance()->mDetailsPageVisible; | 266 | state = KABPrefs::instance()->mDetailsPageVisible; |
267 | else | 267 | else |
268 | state = false; | 268 | state = false; |
269 | 269 | ||
270 | mActionDetails->setChecked( state ); | 270 | mActionDetails->setChecked( state ); |
271 | setDetailsVisible( state ); | 271 | setDetailsVisible( state ); |
272 | 272 | ||
273 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 273 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
274 | 274 | ||
275 | mActionJumpBar->setChecked( state ); | 275 | mActionJumpBar->setChecked( state ); |
276 | setJumpButtonBarVisible( state ); | 276 | setJumpButtonBarVisible( state ); |
277 | /*US | 277 | /*US |
278 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 278 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
279 | if ( splitterSize.count() == 0 ) { | 279 | if ( splitterSize.count() == 0 ) { |
280 | splitterSize.append( width() / 2 ); | 280 | splitterSize.append( width() / 2 ); |
281 | splitterSize.append( width() / 2 ); | 281 | splitterSize.append( width() / 2 ); |
282 | } | 282 | } |
283 | mMiniSplitter->setSizes( splitterSize ); | 283 | mMiniSplitter->setSizes( splitterSize ); |
284 | if ( mExtensionBarSplitter ) { | 284 | if ( mExtensionBarSplitter ) { |
285 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 285 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
286 | if ( splitterSize.count() == 0 ) { | 286 | if ( splitterSize.count() == 0 ) { |
287 | splitterSize.append( width() / 2 ); | 287 | splitterSize.append( width() / 2 ); |
288 | splitterSize.append( width() / 2 ); | 288 | splitterSize.append( width() / 2 ); |
289 | } | 289 | } |
290 | mExtensionBarSplitter->setSizes( splitterSize ); | 290 | mExtensionBarSplitter->setSizes( splitterSize ); |
291 | 291 | ||
292 | } | 292 | } |
293 | */ | 293 | */ |
294 | mViewManager->restoreSettings(); | 294 | mViewManager->restoreSettings(); |
295 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 295 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
296 | mExtensionManager->restoreSettings(); | 296 | mExtensionManager->restoreSettings(); |
297 | 297 | ||
298 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 298 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
299 | if ( splitterSize.count() == 0 ) { | 299 | if ( splitterSize.count() == 0 ) { |
300 | splitterSize.append( width() / 2 ); | 300 | splitterSize.append( width() / 2 ); |
301 | splitterSize.append( width() / 2 ); | 301 | splitterSize.append( width() / 2 ); |
302 | } | 302 | } |
303 | mMiniSplitter->setSizes( splitterSize ); | 303 | mMiniSplitter->setSizes( splitterSize ); |
304 | if ( mExtensionBarSplitter ) { | 304 | if ( mExtensionBarSplitter ) { |
305 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 305 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
306 | if ( splitterSize.count() == 0 ) { | 306 | if ( splitterSize.count() == 0 ) { |
307 | splitterSize.append( width() / 2 ); | 307 | splitterSize.append( width() / 2 ); |
308 | splitterSize.append( width() / 2 ); | 308 | splitterSize.append( width() / 2 ); |
309 | } | 309 | } |
310 | mExtensionBarSplitter->setSizes( splitterSize ); | 310 | mExtensionBarSplitter->setSizes( splitterSize ); |
311 | 311 | ||
312 | } | 312 | } |
313 | 313 | ||
314 | 314 | ||
315 | } | 315 | } |
316 | 316 | ||
317 | void KABCore::saveSettings() | 317 | void KABCore::saveSettings() |
318 | { | 318 | { |
319 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 319 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
320 | if ( mExtensionBarSplitter ) | 320 | if ( mExtensionBarSplitter ) |
321 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 321 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
322 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 322 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
323 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 323 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
324 | #ifndef KAB_EMBEDDED | 324 | #ifndef KAB_EMBEDDED |
325 | 325 | ||
326 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 326 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
327 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 327 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
328 | #endif //KAB_EMBEDDED | 328 | #endif //KAB_EMBEDDED |
329 | mExtensionManager->saveSettings(); | 329 | mExtensionManager->saveSettings(); |
330 | mViewManager->saveSettings(); | 330 | mViewManager->saveSettings(); |
331 | 331 | ||
332 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 332 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
333 | } | 333 | } |
334 | 334 | ||
335 | KABC::AddressBook *KABCore::addressBook() const | 335 | KABC::AddressBook *KABCore::addressBook() const |
336 | { | 336 | { |
337 | return mAddressBook; | 337 | return mAddressBook; |
338 | } | 338 | } |
339 | 339 | ||
340 | KConfig *KABCore::config() | 340 | KConfig *KABCore::config() |
341 | { | 341 | { |
342 | #ifndef KAB_EMBEDDED | 342 | #ifndef KAB_EMBEDDED |
343 | return KABPrefs::instance()->config(); | 343 | return KABPrefs::instance()->config(); |
344 | #else //KAB_EMBEDDED | 344 | #else //KAB_EMBEDDED |
345 | return KABPrefs::instance()->getConfig(); | 345 | return KABPrefs::instance()->getConfig(); |
346 | #endif //KAB_EMBEDDED | 346 | #endif //KAB_EMBEDDED |
347 | } | 347 | } |
348 | 348 | ||
349 | KActionCollection *KABCore::actionCollection() const | 349 | KActionCollection *KABCore::actionCollection() const |
350 | { | 350 | { |
351 | return mGUIClient->actionCollection(); | 351 | return mGUIClient->actionCollection(); |
352 | } | 352 | } |
353 | 353 | ||
354 | KABC::Field *KABCore::currentSearchField() const | 354 | KABC::Field *KABCore::currentSearchField() const |
355 | { | 355 | { |
356 | if (mIncSearchWidget) | 356 | if (mIncSearchWidget) |
357 | return mIncSearchWidget->currentField(); | 357 | return mIncSearchWidget->currentField(); |
358 | else | 358 | else |
359 | return 0; | 359 | return 0; |
360 | } | 360 | } |
361 | 361 | ||
362 | QStringList KABCore::selectedUIDs() const | 362 | QStringList KABCore::selectedUIDs() const |
363 | { | 363 | { |
364 | return mViewManager->selectedUids(); | 364 | return mViewManager->selectedUids(); |
365 | } | 365 | } |
366 | 366 | ||
367 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 367 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
368 | { | 368 | { |
369 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 369 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
370 | 370 | ||
371 | QPtrList<KRES::Resource> kresResources; | 371 | QPtrList<KRES::Resource> kresResources; |
372 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 372 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
373 | KABC::Resource *resource; | 373 | KABC::Resource *resource; |
374 | while ( ( resource = resIt.current() ) != 0 ) { | 374 | while ( ( resource = resIt.current() ) != 0 ) { |
375 | ++resIt; | 375 | ++resIt; |
376 | if ( !resource->readOnly() ) { | 376 | if ( !resource->readOnly() ) { |
377 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 377 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
378 | if ( res ) | 378 | if ( res ) |
379 | kresResources.append( res ); | 379 | kresResources.append( res ); |
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 383 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
384 | return static_cast<KABC::Resource*>( res ); | 384 | return static_cast<KABC::Resource*>( res ); |
385 | } | 385 | } |
386 | 386 | ||
387 | #ifndef KAB_EMBEDDED | 387 | #ifndef KAB_EMBEDDED |
388 | KAboutData *KABCore::createAboutData() | 388 | KAboutData *KABCore::createAboutData() |
389 | #else //KAB_EMBEDDED | 389 | #else //KAB_EMBEDDED |
390 | void KABCore::createAboutData() | 390 | void KABCore::createAboutData() |
391 | #endif //KAB_EMBEDDED | 391 | #endif //KAB_EMBEDDED |
392 | { | 392 | { |
393 | #ifndef KAB_EMBEDDED | 393 | #ifndef KAB_EMBEDDED |
394 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 394 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
395 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 395 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
396 | KAboutData::License_GPL_V2, | 396 | KAboutData::License_GPL_V2, |
397 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 397 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
398 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 398 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
399 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 399 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
400 | about->addAuthor( "Cornelius Schumacher", | 400 | about->addAuthor( "Cornelius Schumacher", |
401 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 401 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
402 | "schumacher@kde.org" ); | 402 | "schumacher@kde.org" ); |
403 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 403 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
404 | "mpilone@slac.com" ); | 404 | "mpilone@slac.com" ); |
405 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 405 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
406 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 406 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
407 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 407 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
408 | "michel@klaralvdalens-datakonsult.se" ); | 408 | "michel@klaralvdalens-datakonsult.se" ); |
409 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 409 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
410 | "hansen@kde.org" ); | 410 | "hansen@kde.org" ); |
411 | 411 | ||
412 | return about; | 412 | return about; |
413 | #endif //KAB_EMBEDDED | 413 | #endif //KAB_EMBEDDED |
414 | 414 | ||
415 | QString version; | 415 | QString version; |
416 | #include <../version> | 416 | #include <../version> |
417 | QMessageBox::about( this, "About KAddressbook/Pi", | 417 | QMessageBox::about( this, "About KAddressbook/Pi", |
418 | "KAddressbook/Platform-independent\n" | 418 | "KAddressbook/Platform-independent\n" |
419 | "(KA/Pi) " +version + " - " + | 419 | "(KA/Pi) " +version + " - " + |
420 | #ifdef DESKTOP_VERSION | 420 | #ifdef DESKTOP_VERSION |
421 | "Desktop Edition\n" | 421 | "Desktop Edition\n" |
422 | #else | 422 | #else |
423 | "PDA-Edition\n" | 423 | "PDA-Edition\n" |
424 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 424 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
425 | #endif | 425 | #endif |
426 | 426 | ||
427 | "(c) 2004 Ulf Schenk\n" | 427 | "(c) 2004 Ulf Schenk\n" |
428 | "(c) 2004 Lutz Rogowski\n" | 428 | "(c) 2004 Lutz Rogowski\n" |
429 | "(c) 1997-2003, The KDE PIM Team\n" | 429 | "(c) 1997-2003, The KDE PIM Team\n" |
430 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 430 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
431 | "Don Sanders Original author\n" | 431 | "Don Sanders Original author\n" |
432 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 432 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
433 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 433 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
434 | "Greg Stern DCOP interface\n" | 434 | "Greg Stern DCOP interface\n" |
435 | "Mark Westcot Contact pinning\n" | 435 | "Mark Westcot Contact pinning\n" |
436 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 436 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
437 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 437 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
438 | #ifdef _WIN32_ | 438 | #ifdef _WIN32_ |
439 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 439 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
440 | #endif | 440 | #endif |
441 | ); | 441 | ); |
442 | } | 442 | } |
443 | 443 | ||
444 | void KABCore::setContactSelected( const QString &uid ) | 444 | void KABCore::setContactSelected( const QString &uid ) |
445 | { | 445 | { |
446 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 446 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
447 | if ( !mDetails->isHidden() ) | 447 | if ( !mDetails->isHidden() ) |
448 | mDetails->setAddressee( addr ); | 448 | mDetails->setAddressee( addr ); |
449 | 449 | ||
450 | if ( !addr.isEmpty() ) { | 450 | if ( !addr.isEmpty() ) { |
451 | emit contactSelected( addr.formattedName() ); | 451 | emit contactSelected( addr.formattedName() ); |
452 | KABC::Picture pic = addr.photo(); | 452 | KABC::Picture pic = addr.photo(); |
453 | if ( pic.isIntern() ) { | 453 | if ( pic.isIntern() ) { |
454 | //US emit contactSelected( pic.data() ); | 454 | //US emit contactSelected( pic.data() ); |
455 | //US instead use: | 455 | //US instead use: |
456 | QPixmap px; | 456 | QPixmap px; |
457 | if (pic.data().isNull() != true) | 457 | if (pic.data().isNull() != true) |
458 | { | 458 | { |
459 | px.convertFromImage(pic.data()); | 459 | px.convertFromImage(pic.data()); |
460 | } | 460 | } |
461 | 461 | ||
462 | emit contactSelected( px ); | 462 | emit contactSelected( px ); |
463 | } | 463 | } |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | mExtensionManager->setSelectionChanged(); | 467 | mExtensionManager->setSelectionChanged(); |
468 | 468 | ||
469 | // update the actions | 469 | // update the actions |
470 | bool selected = !uid.isEmpty(); | 470 | bool selected = !uid.isEmpty(); |
471 | 471 | ||
472 | if ( mReadWrite ) { | 472 | if ( mReadWrite ) { |
473 | mActionCut->setEnabled( selected ); | 473 | mActionCut->setEnabled( selected ); |
474 | mActionPaste->setEnabled( selected ); | 474 | mActionPaste->setEnabled( selected ); |
475 | } | 475 | } |
476 | 476 | ||
477 | mActionCopy->setEnabled( selected ); | 477 | mActionCopy->setEnabled( selected ); |
478 | mActionDelete->setEnabled( selected ); | 478 | mActionDelete->setEnabled( selected ); |
479 | mActionEditAddressee->setEnabled( selected ); | 479 | mActionEditAddressee->setEnabled( selected ); |
480 | mActionMail->setEnabled( selected ); | 480 | mActionMail->setEnabled( selected ); |
481 | mActionMailVCard->setEnabled( selected ); | 481 | mActionMailVCard->setEnabled( selected ); |
482 | //if (mActionBeam) | 482 | //if (mActionBeam) |
483 | //mActionBeam->setEnabled( selected ); | 483 | //mActionBeam->setEnabled( selected ); |
484 | 484 | ||
485 | if (mActionBeamVCard) | 485 | if (mActionBeamVCard) |
486 | mActionBeamVCard->setEnabled( selected ); | 486 | mActionBeamVCard->setEnabled( selected ); |
487 | 487 | ||
488 | mActionWhoAmI->setEnabled( selected ); | 488 | mActionWhoAmI->setEnabled( selected ); |
489 | mActionCategories->setEnabled( selected ); | 489 | mActionCategories->setEnabled( selected ); |
490 | } | 490 | } |
491 | 491 | ||
492 | void KABCore::sendMail() | 492 | void KABCore::sendMail() |
493 | { | 493 | { |
494 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 494 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
495 | } | 495 | } |
496 | 496 | ||
497 | void KABCore::sendMail( const QString& emaillist ) | 497 | void KABCore::sendMail( const QString& emaillist ) |
498 | { | 498 | { |
499 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 499 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
500 | if (emaillist.contains(",") > 0) | 500 | if (emaillist.contains(",") > 0) |
501 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 501 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
502 | else | 502 | else |
503 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 503 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | 507 | ||
508 | void KABCore::mailVCard() | 508 | void KABCore::mailVCard() |
509 | { | 509 | { |
510 | QStringList uids = mViewManager->selectedUids(); | 510 | QStringList uids = mViewManager->selectedUids(); |
511 | if ( !uids.isEmpty() ) | 511 | if ( !uids.isEmpty() ) |
512 | mailVCard( uids ); | 512 | mailVCard( uids ); |
513 | } | 513 | } |
514 | 514 | ||
515 | void KABCore::mailVCard( const QStringList& uids ) | 515 | void KABCore::mailVCard( const QStringList& uids ) |
516 | { | 516 | { |
517 | QStringList urls; | 517 | QStringList urls; |
518 | 518 | ||
519 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 519 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
520 | 520 | ||
521 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 521 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
522 | 522 | ||
523 | 523 | ||
524 | 524 | ||
525 | QDir().mkdir( dirName, true ); | 525 | QDir().mkdir( dirName, true ); |
526 | 526 | ||
527 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 527 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
528 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 528 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
529 | 529 | ||
530 | if ( a.isEmpty() ) | 530 | if ( a.isEmpty() ) |
531 | continue; | 531 | continue; |
532 | 532 | ||
533 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 533 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
534 | 534 | ||
535 | QString fileName = dirName + "/" + name; | 535 | QString fileName = dirName + "/" + name; |
536 | 536 | ||
537 | QFile outFile(fileName); | 537 | QFile outFile(fileName); |
538 | 538 | ||
539 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 539 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
540 | KABC::VCardConverter converter; | 540 | KABC::VCardConverter converter; |
541 | QString vcard; | 541 | QString vcard; |
542 | 542 | ||
543 | converter.addresseeToVCard( a, vcard ); | 543 | converter.addresseeToVCard( a, vcard ); |
544 | 544 | ||
545 | QTextStream t( &outFile ); // use a text stream | 545 | QTextStream t( &outFile ); // use a text stream |
546 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 546 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
547 | t << vcard; | 547 | t << vcard; |
548 | 548 | ||
549 | outFile.close(); | 549 | outFile.close(); |
550 | 550 | ||
551 | urls.append( fileName ); | 551 | urls.append( fileName ); |
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 555 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
556 | 556 | ||
557 | 557 | ||
558 | /*US | 558 | /*US |
559 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 559 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
560 | QString::null, // subject | 560 | QString::null, // subject |
561 | QString::null, // body | 561 | QString::null, // body |
562 | QString::null, | 562 | QString::null, |
563 | urls ); // attachments | 563 | urls ); // attachments |
564 | */ | 564 | */ |
565 | 565 | ||
566 | } | 566 | } |
567 | 567 | ||
568 | /** | 568 | /** |
569 | Beams the "WhoAmI contact. | 569 | Beams the "WhoAmI contact. |
570 | */ | 570 | */ |
571 | void KABCore::beamMySelf() | 571 | void KABCore::beamMySelf() |
572 | { | 572 | { |
573 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 573 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
574 | if (!a.isEmpty()) | 574 | if (!a.isEmpty()) |
575 | { | 575 | { |
576 | QStringList uids; | 576 | QStringList uids; |
577 | uids << a.uid(); | 577 | uids << a.uid(); |
578 | 578 | ||
579 | beamVCard(uids); | 579 | beamVCard(uids); |
580 | } else { | 580 | } else { |
581 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 581 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
582 | 582 | ||
583 | 583 | ||
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | void KABCore::beamVCard() | 587 | void KABCore::beamVCard() |
588 | { | 588 | { |
589 | QStringList uids = mViewManager->selectedUids(); | 589 | QStringList uids = mViewManager->selectedUids(); |
590 | if ( !uids.isEmpty() ) | 590 | if ( !uids.isEmpty() ) |
591 | beamVCard( uids ); | 591 | beamVCard( uids ); |
592 | } | 592 | } |
593 | 593 | ||
594 | 594 | ||
595 | void KABCore::beamVCard(const QStringList& uids) | 595 | void KABCore::beamVCard(const QStringList& uids) |
596 | { | 596 | { |
597 | /*US | 597 | /*US |
598 | QString beamFilename; | 598 | QString beamFilename; |
599 | Opie::OPimContact c; | 599 | Opie::OPimContact c; |
600 | if ( actionPersonal->isOn() ) { | 600 | if ( actionPersonal->isOn() ) { |
601 | beamFilename = addressbookPersonalVCardName(); | 601 | beamFilename = addressbookPersonalVCardName(); |
602 | if ( !QFile::exists( beamFilename ) ) | 602 | if ( !QFile::exists( beamFilename ) ) |
603 | return; // can't beam a non-existent file | 603 | return; // can't beam a non-existent file |
604 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 604 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
605 | beamFilename ); | 605 | beamFilename ); |
606 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 606 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
607 | Opie::OPimContactAccess::List allList = access->allRecords(); | 607 | Opie::OPimContactAccess::List allList = access->allRecords(); |
608 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 608 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
609 | c = *it; | 609 | c = *it; |
610 | 610 | ||
611 | delete access; | 611 | delete access; |
612 | } else { | 612 | } else { |
613 | unlink( beamfile ); // delete if exists | 613 | unlink( beamfile ); // delete if exists |
614 | mkdir("/tmp/obex/", 0755); | 614 | mkdir("/tmp/obex/", 0755); |
615 | c = m_abView -> currentEntry(); | 615 | c = m_abView -> currentEntry(); |
616 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 616 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
617 | beamfile ); | 617 | beamfile ); |
618 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 618 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
619 | access->add( c ); | 619 | access->add( c ); |
620 | access->save(); | 620 | access->save(); |
621 | delete access; | 621 | delete access; |
622 | 622 | ||
623 | beamFilename = beamfile; | 623 | beamFilename = beamfile; |
624 | } | 624 | } |
625 | 625 | ||
626 | owarn << "Beaming: " << beamFilename << oendl; | 626 | owarn << "Beaming: " << beamFilename << oendl; |
627 | */ | 627 | */ |
628 | 628 | ||
629 | #if 0 | 629 | #if 0 |
630 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 630 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
631 | 631 | ||
632 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 632 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
633 | 633 | ||
634 | QString name = "contact.vcf"; | 634 | QString name = "contact.vcf"; |
635 | 635 | ||
636 | QString fileName = dirName + "/" + name; | 636 | QString fileName = dirName + "/" + name; |
637 | #endif | 637 | #endif |
638 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 638 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
639 | // | 639 | // |
640 | QString fileName = "/tmp/kdepimbeamfile"; | 640 | QString fileName = "/tmp/kdepimbeamfile"; |
641 | 641 | ||
642 | 642 | ||
643 | //QDir().mkdir( dirName, true ); | 643 | //QDir().mkdir( dirName, true ); |
644 | 644 | ||
645 | QFile outFile(fileName); | 645 | QFile outFile(fileName); |
646 | KABC::VCardConverter converter; | 646 | KABC::VCardConverter converter; |
647 | QString description; | 647 | QString description; |
648 | 648 | ||
649 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 649 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
650 | 650 | ||
651 | QTextStream t( &outFile ); // use a text stream | 651 | QTextStream t( &outFile ); // use a text stream |
652 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 652 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
653 | 653 | ||
654 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 654 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
655 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 655 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
656 | 656 | ||
657 | if ( a.isEmpty() ) | 657 | if ( a.isEmpty() ) |
658 | continue; | 658 | continue; |
659 | 659 | ||
660 | if (description.isEmpty()) | 660 | if (description.isEmpty()) |
661 | description = a.formattedName(); | 661 | description = a.formattedName(); |
662 | 662 | ||
663 | QString vcard; | 663 | QString vcard; |
664 | converter.addresseeToVCard( a, vcard ); | 664 | converter.addresseeToVCard( a, vcard ); |
665 | t << vcard; | 665 | t << vcard; |
666 | 666 | ||
667 | } | 667 | } |
668 | } else { | 668 | } else { |
669 | qDebug("Error open temp beam file "); | 669 | qDebug("Error open temp beam file "); |
670 | return; | 670 | return; |
671 | } | 671 | } |
672 | 672 | ||
673 | outFile.close(); | 673 | outFile.close(); |
674 | 674 | ||
675 | #ifndef DESKTOP_VERSION | 675 | #ifndef DESKTOP_VERSION |
676 | Ir *ir = new Ir( this ); | 676 | Ir *ir = new Ir( this ); |
677 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 677 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
678 | ir->send( fileName, description, "text/x-vCard" ); | 678 | ir->send( fileName, description, "text/x-vCard" ); |
679 | #endif | 679 | #endif |
680 | 680 | ||
681 | } | 681 | } |
682 | 682 | ||
683 | void KABCore::beamDone( Ir *ir ) | 683 | void KABCore::beamDone( Ir *ir ) |
684 | { | 684 | { |
685 | #ifndef DESKTOP_VERSION | 685 | #ifndef DESKTOP_VERSION |
686 | delete ir; | 686 | delete ir; |
687 | #endif | 687 | #endif |
688 | } | 688 | } |
689 | 689 | ||
690 | 690 | ||
691 | void KABCore::browse( const QString& url ) | 691 | void KABCore::browse( const QString& url ) |
692 | { | 692 | { |
693 | #ifndef KAB_EMBEDDED | 693 | #ifndef KAB_EMBEDDED |
694 | kapp->invokeBrowser( url ); | 694 | kapp->invokeBrowser( url ); |
695 | #else //KAB_EMBEDDED | 695 | #else //KAB_EMBEDDED |
696 | qDebug("KABCore::browse must be fixed"); | 696 | qDebug("KABCore::browse must be fixed"); |
697 | #endif //KAB_EMBEDDED | 697 | #endif //KAB_EMBEDDED |
698 | } | 698 | } |
699 | 699 | ||
700 | void KABCore::selectAllContacts() | 700 | void KABCore::selectAllContacts() |
701 | { | 701 | { |
702 | mViewManager->setSelected( QString::null, true ); | 702 | mViewManager->setSelected( QString::null, true ); |
703 | } | 703 | } |
704 | 704 | ||
705 | void KABCore::deleteContacts() | 705 | void KABCore::deleteContacts() |
706 | { | 706 | { |
707 | QStringList uidList = mViewManager->selectedUids(); | 707 | QStringList uidList = mViewManager->selectedUids(); |
708 | deleteContacts( uidList ); | 708 | deleteContacts( uidList ); |
709 | } | 709 | } |
710 | 710 | ||
711 | void KABCore::deleteContacts( const QStringList &uids ) | 711 | void KABCore::deleteContacts( const QStringList &uids ) |
712 | { | 712 | { |
713 | if ( uids.count() > 0 ) { | 713 | if ( uids.count() > 0 ) { |
714 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 714 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
715 | UndoStack::instance()->push( command ); | 715 | UndoStack::instance()->push( command ); |
716 | RedoStack::instance()->clear(); | 716 | RedoStack::instance()->clear(); |
717 | 717 | ||
718 | // now if we deleted anything, refresh | 718 | // now if we deleted anything, refresh |
719 | setContactSelected( QString::null ); | 719 | setContactSelected( QString::null ); |
720 | setModified( true ); | 720 | setModified( true ); |
721 | } | 721 | } |
722 | } | 722 | } |
723 | 723 | ||
724 | void KABCore::copyContacts() | 724 | void KABCore::copyContacts() |
725 | { | 725 | { |
726 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 726 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
727 | 727 | ||
728 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 728 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
729 | 729 | ||
730 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 730 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
731 | 731 | ||
732 | QClipboard *cb = QApplication::clipboard(); | 732 | QClipboard *cb = QApplication::clipboard(); |
733 | cb->setText( clipText ); | 733 | cb->setText( clipText ); |
734 | } | 734 | } |
735 | 735 | ||
736 | void KABCore::cutContacts() | 736 | void KABCore::cutContacts() |
737 | { | 737 | { |
738 | QStringList uidList = mViewManager->selectedUids(); | 738 | QStringList uidList = mViewManager->selectedUids(); |
739 | 739 | ||
740 | //US if ( uidList.size() > 0 ) { | 740 | //US if ( uidList.size() > 0 ) { |
741 | if ( uidList.count() > 0 ) { | 741 | if ( uidList.count() > 0 ) { |
742 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 742 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
743 | UndoStack::instance()->push( command ); | 743 | UndoStack::instance()->push( command ); |
744 | RedoStack::instance()->clear(); | 744 | RedoStack::instance()->clear(); |
745 | 745 | ||
746 | setModified( true ); | 746 | setModified( true ); |
747 | } | 747 | } |
748 | } | 748 | } |
749 | 749 | ||
750 | void KABCore::pasteContacts() | 750 | void KABCore::pasteContacts() |
751 | { | 751 | { |
752 | QClipboard *cb = QApplication::clipboard(); | 752 | QClipboard *cb = QApplication::clipboard(); |
753 | 753 | ||
754 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 754 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
755 | 755 | ||
756 | pasteContacts( list ); | 756 | pasteContacts( list ); |
757 | } | 757 | } |
758 | 758 | ||
759 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 759 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
760 | { | 760 | { |
761 | KABC::Resource *resource = requestResource( this ); | 761 | KABC::Resource *resource = requestResource( this ); |
762 | KABC::Addressee::List::Iterator it; | 762 | KABC::Addressee::List::Iterator it; |
763 | for ( it = list.begin(); it != list.end(); ++it ) | 763 | for ( it = list.begin(); it != list.end(); ++it ) |
764 | (*it).setResource( resource ); | 764 | (*it).setResource( resource ); |
765 | 765 | ||
766 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 766 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
767 | UndoStack::instance()->push( command ); | 767 | UndoStack::instance()->push( command ); |
768 | RedoStack::instance()->clear(); | 768 | RedoStack::instance()->clear(); |
769 | 769 | ||
770 | setModified( true ); | 770 | setModified( true ); |
771 | } | 771 | } |
772 | 772 | ||
773 | void KABCore::setWhoAmI() | 773 | void KABCore::setWhoAmI() |
774 | { | 774 | { |
775 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 775 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
776 | 776 | ||
777 | if ( addrList.count() > 1 ) { | 777 | if ( addrList.count() > 1 ) { |
778 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 778 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
779 | return; | 779 | return; |
780 | } | 780 | } |
781 | 781 | ||
782 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 782 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
783 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 783 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
784 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 784 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
785 | } | 785 | } |
786 | 786 | ||
787 | void KABCore::setCategories() | 787 | void KABCore::setCategories() |
788 | { | 788 | { |
789 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 789 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
790 | if ( !dlg.exec() ) | 790 | if ( !dlg.exec() ) |
791 | return; | 791 | return; |
792 | 792 | ||
793 | bool merge = false; | 793 | bool merge = false; |
794 | QString msg = i18n( "Merge with existing categories?" ); | 794 | QString msg = i18n( "Merge with existing categories?" ); |
795 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 795 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
796 | merge = true; | 796 | merge = true; |
797 | 797 | ||
798 | QStringList categories = dlg.selectedCategories(); | 798 | QStringList categories = dlg.selectedCategories(); |
799 | 799 | ||
800 | QStringList uids = mViewManager->selectedUids(); | 800 | QStringList uids = mViewManager->selectedUids(); |
801 | QStringList::Iterator it; | 801 | QStringList::Iterator it; |
802 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 802 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
803 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 803 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
804 | if ( !addr.isEmpty() ) { | 804 | if ( !addr.isEmpty() ) { |
805 | if ( !merge ) | 805 | if ( !merge ) |
806 | addr.setCategories( categories ); | 806 | addr.setCategories( categories ); |
807 | else { | 807 | else { |
808 | QStringList addrCategories = addr.categories(); | 808 | QStringList addrCategories = addr.categories(); |
809 | QStringList::Iterator catIt; | 809 | QStringList::Iterator catIt; |
810 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 810 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
811 | if ( !addrCategories.contains( *catIt ) ) | 811 | if ( !addrCategories.contains( *catIt ) ) |
812 | addrCategories.append( *catIt ); | 812 | addrCategories.append( *catIt ); |
813 | } | 813 | } |
814 | addr.setCategories( addrCategories ); | 814 | addr.setCategories( addrCategories ); |
815 | } | 815 | } |
816 | 816 | ||
817 | mAddressBook->insertAddressee( addr ); | 817 | mAddressBook->insertAddressee( addr ); |
818 | } | 818 | } |
819 | } | 819 | } |
820 | 820 | ||
821 | if ( uids.count() > 0 ) | 821 | if ( uids.count() > 0 ) |
822 | setModified( true ); | 822 | setModified( true ); |
823 | } | 823 | } |
824 | 824 | ||
825 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 825 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
826 | { | 826 | { |
827 | mIncSearchWidget->setFields( fields ); | 827 | mIncSearchWidget->setFields( fields ); |
828 | } | 828 | } |
829 | 829 | ||
830 | void KABCore::incrementalSearch( const QString& text ) | 830 | void KABCore::incrementalSearch( const QString& text ) |
831 | { | 831 | { |
832 | mViewManager->setSelected( QString::null, false ); | 832 | mViewManager->setSelected( QString::null, false ); |
833 | 833 | ||
834 | if ( !text.isEmpty() ) { | 834 | if ( !text.isEmpty() ) { |
835 | KABC::Field *field = mIncSearchWidget->currentField(); | 835 | KABC::Field *field = mIncSearchWidget->currentField(); |
836 | 836 | QString pattern = text.lower()+"*"; | |
837 | QString pattern = text.lower(); | 837 | QRegExp re; |
838 | 838 | re.setWildcard(true); // most people understand these better. | |
839 | re.setCaseSensitive(false); | ||
840 | re.setPattern( pattern ); | ||
841 | QStringList foundUids; | ||
842 | if (!re.isValid()) | ||
843 | return; | ||
839 | #if 1 //KDE_VERSION >= 319 | 844 | #if 1 //KDE_VERSION >= 319 |
840 | KABC::AddresseeList list( mAddressBook->allAddressees() ); | 845 | KABC::AddresseeList list( mAddressBook->allAddressees() ); |
841 | if ( field ) { | 846 | if ( field ) { |
842 | list.sortByField( field ); | 847 | list.sortByField( field ); |
843 | KABC::AddresseeList::Iterator it; | 848 | KABC::AddresseeList::Iterator it; |
844 | for ( it = list.begin(); it != list.end(); ++it ) { | 849 | for ( it = list.begin(); it != list.end(); ++it ) { |
845 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 850 | |
846 | mViewManager->setSelected( (*it).uid(), true ); | 851 | #if QT_VERSION >= 300 |
847 | return; | 852 | if (re.search(field->value( *it ).lower()) != -1) |
848 | } | 853 | #else |
854 | if (re.match(field->value( *it ).lower()) != -1) | ||
855 | #endif | ||
856 | { | ||
857 | // if ( field->value( *it ).lower().startsWith( pattern ) ) { | ||
858 | //mViewManager->setSelected( (*it).uid(), true ); | ||
859 | foundUids.append( (*it).uid() ); | ||
860 | //return; | ||
861 | } | ||
849 | } | 862 | } |
850 | } else { | 863 | } else { |
851 | KABC::AddresseeList::Iterator it; | 864 | KABC::AddresseeList::Iterator it; |
852 | for ( it = list.begin(); it != list.end(); ++it ) { | 865 | for ( it = list.begin(); it != list.end(); ++it ) { |
853 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 866 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
854 | KABC::Field::List::ConstIterator fieldIt; | 867 | KABC::Field::List::ConstIterator fieldIt; |
855 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 868 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
856 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | 869 | #if QT_VERSION >= 300 |
857 | mViewManager->setSelected( (*it).uid(), true ); | 870 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
858 | return; | 871 | #else |
872 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | ||
873 | #endif | ||
874 | { | ||
875 | // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | ||
876 | //mViewManager->setSelected( (*it).uid(), true ); | ||
877 | foundUids.append( (*it).uid() ); | ||
878 | //return; | ||
859 | } | 879 | } |
860 | } | 880 | } |
861 | } | 881 | } |
862 | } | 882 | } |
883 | if ( foundUids.count() > 0 ) | ||
884 | mViewManager->setListSelected( foundUids ); | ||
863 | #else | 885 | #else |
864 | KABC::AddressBook::Iterator it; | 886 | KABC::AddressBook::Iterator it; |
865 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 887 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
866 | if ( field ) { | 888 | if ( field ) { |
867 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 889 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
868 | mViewManager->setSelected( (*it).uid(), true ); | 890 | mViewManager->setSelected( (*it).uid(), true ); |
869 | return; | 891 | return; |
870 | } | 892 | } |
871 | } else { | 893 | } else { |
872 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 894 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
873 | KABC::Field::List::ConstIterator fieldIt; | 895 | KABC::Field::List::ConstIterator fieldIt; |
874 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 896 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
875 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | 897 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { |
876 | mViewManager->setSelected( (*it).uid(), true ); | 898 | mViewManager->setSelected( (*it).uid(), true ); |
877 | return; | 899 | return; |
878 | } | 900 | } |
879 | } | 901 | } |
880 | } | 902 | } |
881 | } | 903 | } |
882 | #endif | 904 | #endif |
883 | } | 905 | } |
884 | } | 906 | } |
885 | 907 | ||
886 | void KABCore::setModified() | 908 | void KABCore::setModified() |
887 | { | 909 | { |
888 | setModified( true ); | 910 | setModified( true ); |
889 | } | 911 | } |
890 | 912 | ||
891 | void KABCore::setModifiedWOrefresh() | 913 | void KABCore::setModifiedWOrefresh() |
892 | { | 914 | { |
893 | // qDebug("KABCore::setModifiedWOrefresh() "); | 915 | // qDebug("KABCore::setModifiedWOrefresh() "); |
894 | mModified = true; | 916 | mModified = true; |
895 | mActionSave->setEnabled( mModified ); | 917 | mActionSave->setEnabled( mModified ); |
896 | #ifdef DESKTOP_VERSION | 918 | #ifdef DESKTOP_VERSION |
897 | mDetails->refreshView(); | 919 | mDetails->refreshView(); |
898 | #endif | 920 | #endif |
899 | 921 | ||
900 | } | 922 | } |
901 | void KABCore::setModified( bool modified ) | 923 | void KABCore::setModified( bool modified ) |
902 | { | 924 | { |
903 | mModified = modified; | 925 | mModified = modified; |
904 | mActionSave->setEnabled( mModified ); | 926 | mActionSave->setEnabled( mModified ); |
905 | 927 | ||
906 | if ( modified ) | 928 | if ( modified ) |
907 | mJumpButtonBar->recreateButtons(); | 929 | mJumpButtonBar->recreateButtons(); |
908 | 930 | ||
909 | mViewManager->refreshView(); | 931 | mViewManager->refreshView(); |
910 | mDetails->refreshView(); | 932 | mDetails->refreshView(); |
911 | 933 | ||
912 | } | 934 | } |
913 | 935 | ||
914 | bool KABCore::modified() const | 936 | bool KABCore::modified() const |
915 | { | 937 | { |
916 | return mModified; | 938 | return mModified; |
917 | } | 939 | } |
918 | 940 | ||
919 | void KABCore::contactModified( const KABC::Addressee &addr ) | 941 | void KABCore::contactModified( const KABC::Addressee &addr ) |
920 | { | 942 | { |
921 | 943 | ||
922 | Command *command = 0; | 944 | Command *command = 0; |
923 | QString uid; | 945 | QString uid; |
924 | 946 | ||
925 | // check if it exists already | 947 | // check if it exists already |
926 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 948 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
927 | if ( origAddr.isEmpty() ) | 949 | if ( origAddr.isEmpty() ) |
928 | command = new PwNewCommand( mAddressBook, addr ); | 950 | command = new PwNewCommand( mAddressBook, addr ); |
929 | else { | 951 | else { |
930 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 952 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
931 | uid = addr.uid(); | 953 | uid = addr.uid(); |
932 | } | 954 | } |
933 | 955 | ||
934 | UndoStack::instance()->push( command ); | 956 | UndoStack::instance()->push( command ); |
935 | RedoStack::instance()->clear(); | 957 | RedoStack::instance()->clear(); |
936 | 958 | ||
937 | setModified( true ); | 959 | setModified( true ); |
938 | } | 960 | } |
939 | 961 | ||
940 | void KABCore::newContact() | 962 | void KABCore::newContact() |
941 | { | 963 | { |
942 | 964 | ||
943 | 965 | ||
944 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 966 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
945 | 967 | ||
946 | QPtrList<KRES::Resource> kresResources; | 968 | QPtrList<KRES::Resource> kresResources; |
947 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 969 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
948 | KABC::Resource *resource; | 970 | KABC::Resource *resource; |
949 | while ( ( resource = it.current() ) != 0 ) { | 971 | while ( ( resource = it.current() ) != 0 ) { |
950 | ++it; | 972 | ++it; |
951 | if ( !resource->readOnly() ) { | 973 | if ( !resource->readOnly() ) { |
952 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 974 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
953 | if ( res ) | 975 | if ( res ) |
954 | kresResources.append( res ); | 976 | kresResources.append( res ); |
955 | } | 977 | } |
956 | } | 978 | } |
957 | 979 | ||
958 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 980 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
959 | resource = static_cast<KABC::Resource*>( res ); | 981 | resource = static_cast<KABC::Resource*>( res ); |
960 | 982 | ||
961 | if ( resource ) { | 983 | if ( resource ) { |
962 | KABC::Addressee addr; | 984 | KABC::Addressee addr; |
963 | addr.setResource( resource ); | 985 | addr.setResource( resource ); |
964 | mEditorDialog->setAddressee( addr ); | 986 | mEditorDialog->setAddressee( addr ); |
965 | KApplication::execDialog ( mEditorDialog ); | 987 | KApplication::execDialog ( mEditorDialog ); |
966 | 988 | ||
967 | } else | 989 | } else |
968 | return; | 990 | return; |
969 | 991 | ||
970 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 992 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
971 | 993 | ||
972 | 994 | ||
973 | } | 995 | } |
974 | 996 | ||
975 | void KABCore::addEmail( QString aStr ) | 997 | void KABCore::addEmail( QString aStr ) |
976 | { | 998 | { |
977 | #ifndef KAB_EMBEDDED | 999 | #ifndef KAB_EMBEDDED |
978 | QString fullName, email; | 1000 | QString fullName, email; |
979 | 1001 | ||
980 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1002 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
981 | 1003 | ||
982 | // Try to lookup the addressee matching the email address | 1004 | // Try to lookup the addressee matching the email address |
983 | bool found = false; | 1005 | bool found = false; |
984 | QStringList emailList; | 1006 | QStringList emailList; |
985 | KABC::AddressBook::Iterator it; | 1007 | KABC::AddressBook::Iterator it; |
986 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1008 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
987 | emailList = (*it).emails(); | 1009 | emailList = (*it).emails(); |
988 | if ( emailList.contains( email ) > 0 ) { | 1010 | if ( emailList.contains( email ) > 0 ) { |
989 | found = true; | 1011 | found = true; |
990 | (*it).setNameFromString( fullName ); | 1012 | (*it).setNameFromString( fullName ); |
991 | editContact( (*it).uid() ); | 1013 | editContact( (*it).uid() ); |
992 | } | 1014 | } |
993 | } | 1015 | } |
994 | 1016 | ||
995 | if ( !found ) { | 1017 | if ( !found ) { |
996 | KABC::Addressee addr; | 1018 | KABC::Addressee addr; |
997 | addr.setNameFromString( fullName ); | 1019 | addr.setNameFromString( fullName ); |
998 | addr.insertEmail( email, true ); | 1020 | addr.insertEmail( email, true ); |
999 | 1021 | ||
1000 | mAddressBook->insertAddressee( addr ); | 1022 | mAddressBook->insertAddressee( addr ); |
1001 | mViewManager->refreshView( addr.uid() ); | 1023 | mViewManager->refreshView( addr.uid() ); |
1002 | editContact( addr.uid() ); | 1024 | editContact( addr.uid() ); |
1003 | } | 1025 | } |
1004 | #else //KAB_EMBEDDED | 1026 | #else //KAB_EMBEDDED |
1005 | qDebug("KABCore::addEmail finsih method"); | 1027 | qDebug("KABCore::addEmail finsih method"); |
1006 | #endif //KAB_EMBEDDED | 1028 | #endif //KAB_EMBEDDED |
1007 | } | 1029 | } |
1008 | 1030 | ||
1009 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1031 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1010 | { | 1032 | { |
1011 | mXXPortManager->importVCard( url, showPreview ); | 1033 | mXXPortManager->importVCard( url, showPreview ); |
1012 | } | 1034 | } |
1013 | void KABCore::importFromOL() | 1035 | void KABCore::importFromOL() |
1014 | { | 1036 | { |
1015 | #ifdef _WIN32_ | 1037 | #ifdef _WIN32_ |
1016 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1038 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1017 | idgl->exec(); | 1039 | idgl->exec(); |
1018 | KABC::Addressee::List list = idgl->getAddressList(); | 1040 | KABC::Addressee::List list = idgl->getAddressList(); |
1019 | if ( list.count() > 0 ) { | 1041 | if ( list.count() > 0 ) { |
1020 | KABC::Addressee::List listNew; | 1042 | KABC::Addressee::List listNew; |
1021 | KABC::Addressee::List listExisting; | 1043 | KABC::Addressee::List listExisting; |
1022 | KABC::Addressee::List::Iterator it; | 1044 | KABC::Addressee::List::Iterator it; |
1023 | KABC::AddressBook::Iterator iter; | 1045 | KABC::AddressBook::Iterator iter; |
1024 | for ( it = list.begin(); it != list.end(); ++it ) { | 1046 | for ( it = list.begin(); it != list.end(); ++it ) { |
1025 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1047 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1026 | listNew.append( (*it) ); | 1048 | listNew.append( (*it) ); |
1027 | else | 1049 | else |
1028 | listExisting.append( (*it) ); | 1050 | listExisting.append( (*it) ); |
1029 | } | 1051 | } |
1030 | if ( listExisting.count() > 0 ) | 1052 | if ( listExisting.count() > 0 ) |
1031 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1053 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1032 | if ( listNew.count() > 0 ) { | 1054 | if ( listNew.count() > 0 ) { |
1033 | pasteWithNewUid = false; | 1055 | pasteWithNewUid = false; |
1034 | pasteContacts( listNew ); | 1056 | pasteContacts( listNew ); |
1035 | pasteWithNewUid = true; | 1057 | pasteWithNewUid = true; |
1036 | } | 1058 | } |
1037 | } | 1059 | } |
1038 | delete idgl; | 1060 | delete idgl; |
1039 | #endif | 1061 | #endif |
1040 | } | 1062 | } |
1041 | 1063 | ||
1042 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1064 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1043 | { | 1065 | { |
1044 | mXXPortManager->importVCard( vCard, showPreview ); | 1066 | mXXPortManager->importVCard( vCard, showPreview ); |
1045 | } | 1067 | } |
1046 | 1068 | ||
1047 | //US added a second method without defaultparameter | 1069 | //US added a second method without defaultparameter |
1048 | void KABCore::editContact2() { | 1070 | void KABCore::editContact2() { |
1049 | editContact( QString::null ); | 1071 | editContact( QString::null ); |
1050 | } | 1072 | } |
1051 | 1073 | ||
1052 | void KABCore::editContact( const QString &uid ) | 1074 | void KABCore::editContact( const QString &uid ) |
1053 | { | 1075 | { |
1054 | 1076 | ||
1055 | if ( mExtensionManager->isQuickEditVisible() ) | 1077 | if ( mExtensionManager->isQuickEditVisible() ) |
1056 | return; | 1078 | return; |
1057 | 1079 | ||
1058 | // First, locate the contact entry | 1080 | // First, locate the contact entry |
1059 | QString localUID = uid; | 1081 | QString localUID = uid; |
1060 | if ( localUID.isNull() ) { | 1082 | if ( localUID.isNull() ) { |
1061 | QStringList uidList = mViewManager->selectedUids(); | 1083 | QStringList uidList = mViewManager->selectedUids(); |
1062 | if ( uidList.count() > 0 ) | 1084 | if ( uidList.count() > 0 ) |
1063 | localUID = *( uidList.at( 0 ) ); | 1085 | localUID = *( uidList.at( 0 ) ); |
1064 | } | 1086 | } |
1065 | 1087 | ||
1066 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1088 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1067 | if ( !addr.isEmpty() ) { | 1089 | if ( !addr.isEmpty() ) { |
1068 | mEditorDialog->setAddressee( addr ); | 1090 | mEditorDialog->setAddressee( addr ); |
1069 | KApplication::execDialog ( mEditorDialog ); | 1091 | KApplication::execDialog ( mEditorDialog ); |
1070 | } | 1092 | } |
1071 | } | 1093 | } |
1072 | 1094 | ||
1073 | /** | 1095 | /** |
1074 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1096 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1075 | the method will try to find a selected addressee in the view. | 1097 | the method will try to find a selected addressee in the view. |
1076 | */ | 1098 | */ |
1077 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1099 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1078 | { | 1100 | { |
1079 | if ( mMultipleViewsAtOnce ) | 1101 | if ( mMultipleViewsAtOnce ) |
1080 | { | 1102 | { |
1081 | editContact( uid ); | 1103 | editContact( uid ); |
1082 | } | 1104 | } |
1083 | else | 1105 | else |
1084 | { | 1106 | { |
1085 | setDetailsVisible( true ); | 1107 | setDetailsVisible( true ); |
1086 | mActionDetails->setChecked(true); | 1108 | mActionDetails->setChecked(true); |
1087 | } | 1109 | } |
1088 | 1110 | ||
1089 | } | 1111 | } |
1090 | 1112 | ||
1091 | void KABCore::save() | 1113 | void KABCore::save() |
1092 | { | 1114 | { |
1093 | if ( !mModified ) | 1115 | if ( !mModified ) |
1094 | return; | 1116 | return; |
1095 | QString text = i18n( "There was an error while attempting to save\n the " | 1117 | QString text = i18n( "There was an error while attempting to save\n the " |
1096 | "address book. Please check that some \nother application is " | 1118 | "address book. Please check that some \nother application is " |
1097 | "not using it. " ); | 1119 | "not using it. " ); |
1098 | statusMessage(i18n("Saving addressbook ... ")); | 1120 | statusMessage(i18n("Saving addressbook ... ")); |
1099 | #ifndef KAB_EMBEDDED | 1121 | #ifndef KAB_EMBEDDED |
1100 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1122 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1101 | if ( !b || !b->save() ) { | 1123 | if ( !b || !b->save() ) { |
1102 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1124 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1103 | } | 1125 | } |
1104 | #else //KAB_EMBEDDED | 1126 | #else //KAB_EMBEDDED |
1105 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1127 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1106 | if ( !b || !b->save() ) { | 1128 | if ( !b || !b->save() ) { |
1107 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1129 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1108 | } | 1130 | } |
1109 | #endif //KAB_EMBEDDED | 1131 | #endif //KAB_EMBEDDED |
1110 | 1132 | ||
1111 | statusMessage(i18n("Addressbook saved!")); | 1133 | statusMessage(i18n("Addressbook saved!")); |
1112 | setModified( false ); | 1134 | setModified( false ); |
1113 | } | 1135 | } |
1114 | 1136 | ||
1115 | void KABCore::statusMessage(QString mess , int time ) | 1137 | void KABCore::statusMessage(QString mess , int time ) |
1116 | { | 1138 | { |
1117 | //topLevelWidget()->setCaption( mess ); | 1139 | //topLevelWidget()->setCaption( mess ); |
1118 | // pending setting timer to revome message | 1140 | // pending setting timer to revome message |
1119 | } | 1141 | } |
1120 | void KABCore::undo() | 1142 | void KABCore::undo() |
1121 | { | 1143 | { |
1122 | UndoStack::instance()->undo(); | 1144 | UndoStack::instance()->undo(); |
1123 | 1145 | ||
1124 | // Refresh the view | 1146 | // Refresh the view |
1125 | mViewManager->refreshView(); | 1147 | mViewManager->refreshView(); |
1126 | } | 1148 | } |
1127 | 1149 | ||
1128 | void KABCore::redo() | 1150 | void KABCore::redo() |
1129 | { | 1151 | { |
1130 | RedoStack::instance()->redo(); | 1152 | RedoStack::instance()->redo(); |
1131 | 1153 | ||
1132 | // Refresh the view | 1154 | // Refresh the view |
1133 | mViewManager->refreshView(); | 1155 | mViewManager->refreshView(); |
1134 | } | 1156 | } |
1135 | 1157 | ||
1136 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1158 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1137 | { | 1159 | { |
1138 | if (mMultipleViewsAtOnce) | 1160 | if (mMultipleViewsAtOnce) |
1139 | { | 1161 | { |
1140 | if ( visible ) | 1162 | if ( visible ) |
1141 | mJumpButtonBar->show(); | 1163 | mJumpButtonBar->show(); |
1142 | else | 1164 | else |
1143 | mJumpButtonBar->hide(); | 1165 | mJumpButtonBar->hide(); |
1144 | } | 1166 | } |
1145 | else | 1167 | else |
1146 | { | 1168 | { |
1147 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1169 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1148 | if (mViewManager->isVisible()) | 1170 | if (mViewManager->isVisible()) |
1149 | { | 1171 | { |
1150 | if ( visible ) | 1172 | if ( visible ) |
1151 | mJumpButtonBar->show(); | 1173 | mJumpButtonBar->show(); |
1152 | else | 1174 | else |
1153 | mJumpButtonBar->hide(); | 1175 | mJumpButtonBar->hide(); |
1154 | } | 1176 | } |
1155 | else | 1177 | else |
1156 | { | 1178 | { |
1157 | mJumpButtonBar->hide(); | 1179 | mJumpButtonBar->hide(); |
1158 | } | 1180 | } |
1159 | } | 1181 | } |
1160 | } | 1182 | } |
1161 | 1183 | ||
1162 | 1184 | ||
1163 | void KABCore::setDetailsToState() | 1185 | void KABCore::setDetailsToState() |
1164 | { | 1186 | { |
1165 | setDetailsVisible( mActionDetails->isChecked() ); | 1187 | setDetailsVisible( mActionDetails->isChecked() ); |
1166 | } | 1188 | } |
1167 | 1189 | ||
1168 | 1190 | ||
1169 | 1191 | ||
1170 | void KABCore::setDetailsVisible( bool visible ) | 1192 | void KABCore::setDetailsVisible( bool visible ) |
1171 | { | 1193 | { |
1172 | if (visible && mDetails->isHidden()) | 1194 | if (visible && mDetails->isHidden()) |
1173 | { | 1195 | { |
1174 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1196 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1175 | if ( addrList.count() > 0 ) | 1197 | if ( addrList.count() > 0 ) |
1176 | mDetails->setAddressee( addrList[ 0 ] ); | 1198 | mDetails->setAddressee( addrList[ 0 ] ); |
1177 | } | 1199 | } |
1178 | 1200 | ||
1179 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1201 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1180 | // the listview and the detailview. We do that by changing the splitbar size. | 1202 | // the listview and the detailview. We do that by changing the splitbar size. |
1181 | if (mMultipleViewsAtOnce) | 1203 | if (mMultipleViewsAtOnce) |
1182 | { | 1204 | { |
1183 | if ( visible ) | 1205 | if ( visible ) |
1184 | mDetails->show(); | 1206 | mDetails->show(); |
1185 | else | 1207 | else |
1186 | mDetails->hide(); | 1208 | mDetails->hide(); |
1187 | } | 1209 | } |
1188 | else | 1210 | else |
1189 | { | 1211 | { |
1190 | if ( visible ) { | 1212 | if ( visible ) { |
1191 | mViewManager->hide(); | 1213 | mViewManager->hide(); |
1192 | mDetails->show(); | 1214 | mDetails->show(); |
1193 | } | 1215 | } |
1194 | else { | 1216 | else { |
1195 | mViewManager->show(); | 1217 | mViewManager->show(); |
1196 | mDetails->hide(); | 1218 | mDetails->hide(); |
1197 | } | 1219 | } |
1198 | setJumpButtonBarVisible( !visible ); | 1220 | setJumpButtonBarVisible( !visible ); |
1199 | } | 1221 | } |
1200 | 1222 | ||
1201 | } | 1223 | } |
1202 | 1224 | ||
1203 | void KABCore::extensionChanged( int id ) | 1225 | void KABCore::extensionChanged( int id ) |
1204 | { | 1226 | { |
1205 | //change the details view only for non desktop systems | 1227 | //change the details view only for non desktop systems |
1206 | #ifndef DESKTOP_VERSION | 1228 | #ifndef DESKTOP_VERSION |
1207 | 1229 | ||
1208 | if (id == 0) | 1230 | if (id == 0) |
1209 | { | 1231 | { |
1210 | //the user disabled the extension. | 1232 | //the user disabled the extension. |
1211 | 1233 | ||
1212 | if (mMultipleViewsAtOnce) | 1234 | if (mMultipleViewsAtOnce) |
1213 | { // enable detailsview again | 1235 | { // enable detailsview again |
1214 | setDetailsVisible( true ); | 1236 | setDetailsVisible( true ); |
1215 | mActionDetails->setChecked( true ); | 1237 | mActionDetails->setChecked( true ); |
1216 | } | 1238 | } |
1217 | else | 1239 | else |
1218 | { //go back to the listview | 1240 | { //go back to the listview |
1219 | setDetailsVisible( false ); | 1241 | setDetailsVisible( false ); |
1220 | mActionDetails->setChecked( false ); | 1242 | mActionDetails->setChecked( false ); |
1221 | mActionDetails->setEnabled(true); | 1243 | mActionDetails->setEnabled(true); |
1222 | } | 1244 | } |
1223 | 1245 | ||
1224 | } | 1246 | } |
1225 | else | 1247 | else |
1226 | { | 1248 | { |
1227 | //the user enabled the extension. | 1249 | //the user enabled the extension. |
1228 | setDetailsVisible( false ); | 1250 | setDetailsVisible( false ); |
1229 | mActionDetails->setChecked( false ); | 1251 | mActionDetails->setChecked( false ); |
1230 | 1252 | ||
1231 | if (!mMultipleViewsAtOnce) | 1253 | if (!mMultipleViewsAtOnce) |
1232 | { | 1254 | { |
1233 | mActionDetails->setEnabled(false); | 1255 | mActionDetails->setEnabled(false); |
1234 | } | 1256 | } |
1235 | 1257 | ||
1236 | mExtensionManager->setSelectionChanged(); | 1258 | mExtensionManager->setSelectionChanged(); |
1237 | 1259 | ||
1238 | } | 1260 | } |
1239 | 1261 | ||
1240 | #endif// DESKTOP_VERSION | 1262 | #endif// DESKTOP_VERSION |
1241 | 1263 | ||
1242 | } | 1264 | } |
1243 | 1265 | ||
1244 | 1266 | ||
1245 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1267 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1246 | { | 1268 | { |
1247 | 1269 | ||
1248 | if ( list.count() != 0 ) { | 1270 | if ( list.count() != 0 ) { |
1249 | KABC::Addressee::List::ConstIterator it; | 1271 | KABC::Addressee::List::ConstIterator it; |
1250 | for ( it = list.begin(); it != list.end(); ++it ) | 1272 | for ( it = list.begin(); it != list.end(); ++it ) |
1251 | mAddressBook->insertAddressee( *it ); | 1273 | mAddressBook->insertAddressee( *it ); |
1252 | if ( list.count() > 1 ) | 1274 | if ( list.count() > 1 ) |
1253 | setModified(); | 1275 | setModified(); |
1254 | else | 1276 | else |
1255 | setModifiedWOrefresh(); | 1277 | setModifiedWOrefresh(); |
1256 | } | 1278 | } |
1257 | if ( list.count() == 0 ) | 1279 | if ( list.count() == 0 ) |
1258 | mViewManager->refreshView(); | 1280 | mViewManager->refreshView(); |
1259 | else | 1281 | else |
1260 | mViewManager->refreshView( list[ 0 ].uid() ); | 1282 | mViewManager->refreshView( list[ 0 ].uid() ); |
1261 | 1283 | ||
1262 | 1284 | ||
1263 | 1285 | ||
1264 | } | 1286 | } |
1265 | 1287 | ||
1266 | QString KABCore::getNameByPhone( const QString &phone ) | 1288 | QString KABCore::getNameByPhone( const QString &phone ) |
1267 | { | 1289 | { |
1268 | #ifndef KAB_EMBEDDED | 1290 | #ifndef KAB_EMBEDDED |
1269 | QRegExp r( "[/*/-/ ]" ); | 1291 | QRegExp r( "[/*/-/ ]" ); |
1270 | QString localPhone( phone ); | 1292 | QString localPhone( phone ); |
1271 | 1293 | ||
1272 | bool found = false; | 1294 | bool found = false; |
1273 | QString ownerName = ""; | 1295 | QString ownerName = ""; |
1274 | KABC::AddressBook::Iterator iter; | 1296 | KABC::AddressBook::Iterator iter; |
1275 | KABC::PhoneNumber::List::Iterator phoneIter; | 1297 | KABC::PhoneNumber::List::Iterator phoneIter; |
1276 | KABC::PhoneNumber::List phoneList; | 1298 | KABC::PhoneNumber::List phoneList; |
1277 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1299 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1278 | phoneList = (*iter).phoneNumbers(); | 1300 | phoneList = (*iter).phoneNumbers(); |
1279 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1301 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1280 | ++phoneIter) { | 1302 | ++phoneIter) { |
1281 | // Get rid of separator chars so just the numbers are compared. | 1303 | // Get rid of separator chars so just the numbers are compared. |
1282 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1304 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1283 | ownerName = (*iter).formattedName(); | 1305 | ownerName = (*iter).formattedName(); |
1284 | found = true; | 1306 | found = true; |
1285 | } | 1307 | } |
1286 | } | 1308 | } |
1287 | } | 1309 | } |
1288 | 1310 | ||
1289 | return ownerName; | 1311 | return ownerName; |
1290 | #else //KAB_EMBEDDED | 1312 | #else //KAB_EMBEDDED |
1291 | qDebug("KABCore::getNameByPhone finsih method"); | 1313 | qDebug("KABCore::getNameByPhone finsih method"); |
1292 | return ""; | 1314 | return ""; |
1293 | #endif //KAB_EMBEDDED | 1315 | #endif //KAB_EMBEDDED |
1294 | 1316 | ||
1295 | } | 1317 | } |
1296 | 1318 | ||
1297 | void KABCore::openConfigDialog() | 1319 | void KABCore::openConfigDialog() |
1298 | { | 1320 | { |
1299 | KABPrefs* kab_prefs = KABPrefs::instance(); | 1321 | KABPrefs* kab_prefs = KABPrefs::instance(); |
1300 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); | 1322 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); |
1301 | 1323 | ||
1302 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1324 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1303 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1325 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1304 | ConfigureDialog->addModule(kabcfg ); | 1326 | ConfigureDialog->addModule(kabcfg ); |
1305 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1327 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1306 | ConfigureDialog->addModule(kdelibcfg ); | 1328 | ConfigureDialog->addModule(kdelibcfg ); |
1307 | 1329 | ||
1308 | 1330 | ||
1309 | 1331 | ||
1310 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1332 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1311 | this, SLOT( configurationChanged() ) ); | 1333 | this, SLOT( configurationChanged() ) ); |
1312 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1334 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1313 | this, SLOT( configurationChanged() ) ); | 1335 | this, SLOT( configurationChanged() ) ); |
1314 | saveSettings(); | 1336 | saveSettings(); |
1315 | #ifndef DESKTOP_VERSION | 1337 | #ifndef DESKTOP_VERSION |
1316 | ConfigureDialog->showMaximized(); | 1338 | ConfigureDialog->showMaximized(); |
1317 | #endif | 1339 | #endif |
1318 | if ( ConfigureDialog->exec() ) | 1340 | if ( ConfigureDialog->exec() ) |
1319 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1341 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1320 | delete ConfigureDialog; | 1342 | delete ConfigureDialog; |
1321 | } | 1343 | } |
1322 | 1344 | ||
1323 | void KABCore::openLDAPDialog() | 1345 | void KABCore::openLDAPDialog() |
1324 | { | 1346 | { |
1325 | #ifndef KAB_EMBEDDED | 1347 | #ifndef KAB_EMBEDDED |
1326 | if ( !mLdapSearchDialog ) { | 1348 | if ( !mLdapSearchDialog ) { |
1327 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1349 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1328 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1350 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1329 | SLOT( refreshView() ) ); | 1351 | SLOT( refreshView() ) ); |
1330 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1352 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1331 | SLOT( setModified() ) ); | 1353 | SLOT( setModified() ) ); |
1332 | } else | 1354 | } else |
1333 | mLdapSearchDialog->restoreSettings(); | 1355 | mLdapSearchDialog->restoreSettings(); |
1334 | 1356 | ||
1335 | if ( mLdapSearchDialog->isOK() ) | 1357 | if ( mLdapSearchDialog->isOK() ) |
1336 | mLdapSearchDialog->exec(); | 1358 | mLdapSearchDialog->exec(); |
1337 | #else //KAB_EMBEDDED | 1359 | #else //KAB_EMBEDDED |
1338 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1360 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1339 | #endif //KAB_EMBEDDED | 1361 | #endif //KAB_EMBEDDED |
1340 | } | 1362 | } |
1341 | 1363 | ||
1342 | void KABCore::print() | 1364 | void KABCore::print() |
1343 | { | 1365 | { |
1344 | #ifndef KAB_EMBEDDED | 1366 | #ifndef KAB_EMBEDDED |
1345 | KPrinter printer; | 1367 | KPrinter printer; |
1346 | if ( !printer.setup( this ) ) | 1368 | if ( !printer.setup( this ) ) |
1347 | return; | 1369 | return; |
1348 | 1370 | ||
1349 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1371 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1350 | mViewManager->selectedUids(), this ); | 1372 | mViewManager->selectedUids(), this ); |
1351 | 1373 | ||
1352 | wizard.exec(); | 1374 | wizard.exec(); |
1353 | #else //KAB_EMBEDDED | 1375 | #else //KAB_EMBEDDED |
1354 | qDebug("KABCore::print() finsih method"); | 1376 | qDebug("KABCore::print() finsih method"); |
1355 | #endif //KAB_EMBEDDED | 1377 | #endif //KAB_EMBEDDED |
1356 | 1378 | ||
1357 | } | 1379 | } |
1358 | 1380 | ||
1359 | 1381 | ||
1360 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1382 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1361 | { | 1383 | { |
1362 | if ( mGUIClient ) | 1384 | if ( mGUIClient ) |
1363 | mGUIClient->insertChildClient( client ); | 1385 | mGUIClient->insertChildClient( client ); |
1364 | else | 1386 | else |
1365 | KMessageBox::error( this, "no KXMLGUICLient"); | 1387 | KMessageBox::error( this, "no KXMLGUICLient"); |
1366 | } | 1388 | } |
1367 | 1389 | ||
1368 | 1390 | ||
1369 | void KABCore::configurationChanged() | 1391 | void KABCore::configurationChanged() |
1370 | { | 1392 | { |
1371 | mExtensionManager->reconfigure(); | 1393 | mExtensionManager->reconfigure(); |
1372 | } | 1394 | } |
1373 | 1395 | ||
1374 | void KABCore::addressBookChanged() | 1396 | void KABCore::addressBookChanged() |
1375 | { | 1397 | { |
1376 | /*US | 1398 | /*US |
1377 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1399 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1378 | while ( it.current() ) { | 1400 | while ( it.current() ) { |
1379 | if ( it.current()->dirty() ) { | 1401 | if ( it.current()->dirty() ) { |
1380 | QString text = i18n( "Data has been changed externally. Unsaved " | 1402 | QString text = i18n( "Data has been changed externally. Unsaved " |
1381 | "changes will be lost." ); | 1403 | "changes will be lost." ); |
1382 | KMessageBox::information( this, text ); | 1404 | KMessageBox::information( this, text ); |
1383 | } | 1405 | } |
1384 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1406 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1385 | ++it; | 1407 | ++it; |
1386 | } | 1408 | } |
1387 | */ | 1409 | */ |
1388 | if (mEditorDialog) | 1410 | if (mEditorDialog) |
1389 | { | 1411 | { |
1390 | if (mEditorDialog->dirty()) | 1412 | if (mEditorDialog->dirty()) |
1391 | { | 1413 | { |
1392 | QString text = i18n( "Data has been changed externally. Unsaved " | 1414 | QString text = i18n( "Data has been changed externally. Unsaved " |
1393 | "changes will be lost." ); | 1415 | "changes will be lost." ); |
1394 | KMessageBox::information( this, text ); | 1416 | KMessageBox::information( this, text ); |
1395 | } | 1417 | } |
1396 | QString currentuid = mEditorDialog->addressee().uid(); | 1418 | QString currentuid = mEditorDialog->addressee().uid(); |
1397 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1419 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1398 | } | 1420 | } |
1399 | mViewManager->refreshView(); | 1421 | mViewManager->refreshView(); |
1400 | // mDetails->refreshView(); | 1422 | // mDetails->refreshView(); |
1401 | 1423 | ||
1402 | 1424 | ||
1403 | } | 1425 | } |
1404 | 1426 | ||
1405 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1427 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1406 | const char *name ) | 1428 | const char *name ) |
1407 | { | 1429 | { |
1408 | 1430 | ||
1409 | if ( mEditorDialog == 0 ) { | 1431 | if ( mEditorDialog == 0 ) { |
1410 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1432 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1411 | name ? name : "editorDialog" ); | 1433 | name ? name : "editorDialog" ); |
1412 | 1434 | ||
1413 | 1435 | ||
1414 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1436 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1415 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1437 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1416 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1438 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1417 | // SLOT( slotEditorDestroyed( const QString& ) ) ); | 1439 | // SLOT( slotEditorDestroyed( const QString& ) ) ); |
1418 | } | 1440 | } |
1419 | 1441 | ||
1420 | return mEditorDialog; | 1442 | return mEditorDialog; |
1421 | } | 1443 | } |
1422 | 1444 | ||
1423 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1445 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1424 | { | 1446 | { |
1425 | //mEditorDict.remove( uid ); | 1447 | //mEditorDict.remove( uid ); |
1426 | } | 1448 | } |
1427 | 1449 | ||
1428 | void KABCore::initGUI() | 1450 | void KABCore::initGUI() |
1429 | { | 1451 | { |
1430 | #ifndef KAB_EMBEDDED | 1452 | #ifndef KAB_EMBEDDED |
1431 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1453 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1432 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1454 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1433 | 1455 | ||
1434 | mExtensionBarSplitter = new QSplitter( this ); | 1456 | mExtensionBarSplitter = new QSplitter( this ); |
1435 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1457 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1436 | 1458 | ||
1437 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1459 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1438 | 1460 | ||
1439 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1461 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1440 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1462 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1441 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1463 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1442 | SLOT( incrementalSearch( const QString& ) ) ); | 1464 | SLOT( incrementalSearch( const QString& ) ) ); |
1443 | 1465 | ||
1444 | mViewManager = new ViewManager( this, viewSpace ); | 1466 | mViewManager = new ViewManager( this, viewSpace ); |
1445 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1467 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1446 | 1468 | ||
1447 | mDetails = new ViewContainer( mDetailsSplitter ); | 1469 | mDetails = new ViewContainer( mDetailsSplitter ); |
1448 | 1470 | ||
1449 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1471 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1450 | 1472 | ||
1451 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1473 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1452 | 1474 | ||
1453 | topLayout->addWidget( mExtensionBarSplitter ); | 1475 | topLayout->addWidget( mExtensionBarSplitter ); |
1454 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1476 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1455 | topLayout->addWidget( mJumpButtonBar ); | 1477 | topLayout->addWidget( mJumpButtonBar ); |
1456 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1478 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1457 | 1479 | ||
1458 | mXXPortManager = new XXPortManager( this, this ); | 1480 | mXXPortManager = new XXPortManager( this, this ); |
1459 | 1481 | ||
1460 | #else //KAB_EMBEDDED | 1482 | #else //KAB_EMBEDDED |
1461 | //US initialize viewMenu before settingup viewmanager. | 1483 | //US initialize viewMenu before settingup viewmanager. |
1462 | // Viewmanager needs this menu to plugin submenues. | 1484 | // Viewmanager needs this menu to plugin submenues. |
1463 | viewMenu = new QPopupMenu( this ); | 1485 | viewMenu = new QPopupMenu( this ); |
1464 | settingsMenu = new QPopupMenu( this ); | 1486 | settingsMenu = new QPopupMenu( this ); |
1465 | //filterMenu = new QPopupMenu( this ); | 1487 | //filterMenu = new QPopupMenu( this ); |
1466 | ImportMenu = new QPopupMenu( this ); | 1488 | ImportMenu = new QPopupMenu( this ); |
1467 | ExportMenu = new QPopupMenu( this ); | 1489 | ExportMenu = new QPopupMenu( this ); |
1468 | 1490 | ||
1469 | changeMenu= new QPopupMenu( this ); | 1491 | changeMenu= new QPopupMenu( this ); |
1470 | 1492 | ||
1471 | //US since we have no splitter for the embedded system, setup | 1493 | //US since we have no splitter for the embedded system, setup |
1472 | // a layout with two frames. One left and one right. | 1494 | // a layout with two frames. One left and one right. |
1473 | 1495 | ||
1474 | QBoxLayout *topLayout; | 1496 | QBoxLayout *topLayout; |
1475 | 1497 | ||
1476 | // = new QHBoxLayout( this ); | 1498 | // = new QHBoxLayout( this ); |
1477 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1499 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1478 | 1500 | ||
1479 | // QWidget *mainBox = new QWidget( this ); | 1501 | // QWidget *mainBox = new QWidget( this ); |
1480 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1502 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1481 | 1503 | ||
1482 | #ifdef DESKTOP_VERSION | 1504 | #ifdef DESKTOP_VERSION |
1483 | topLayout = new QHBoxLayout( this ); | 1505 | topLayout = new QHBoxLayout( this ); |
1484 | 1506 | ||
1485 | 1507 | ||
1486 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1508 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1487 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1509 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1488 | 1510 | ||
1489 | topLayout->addWidget(mMiniSplitter ); | 1511 | topLayout->addWidget(mMiniSplitter ); |
1490 | 1512 | ||
1491 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1513 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1492 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1514 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1493 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1515 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1494 | mDetails = new ViewContainer( mMiniSplitter ); | 1516 | mDetails = new ViewContainer( mMiniSplitter ); |
1495 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1517 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1496 | #else | 1518 | #else |
1497 | if ( QApplication::desktop()->width() > 480 ) { | 1519 | if ( QApplication::desktop()->width() > 480 ) { |
1498 | topLayout = new QHBoxLayout( this ); | 1520 | topLayout = new QHBoxLayout( this ); |
1499 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1521 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1500 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1522 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1501 | } else { | 1523 | } else { |
1502 | 1524 | ||
1503 | topLayout = new QHBoxLayout( this ); | 1525 | topLayout = new QHBoxLayout( this ); |
1504 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1526 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1505 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1527 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1506 | } | 1528 | } |
1507 | 1529 | ||
1508 | topLayout->addWidget(mMiniSplitter ); | 1530 | topLayout->addWidget(mMiniSplitter ); |
1509 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1531 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1510 | mDetails = new ViewContainer( mMiniSplitter ); | 1532 | mDetails = new ViewContainer( mMiniSplitter ); |
1511 | 1533 | ||
1512 | 1534 | ||
1513 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1535 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1514 | #endif | 1536 | #endif |
1515 | //eh->hide(); | 1537 | //eh->hide(); |
1516 | // topLayout->addWidget(mExtensionManager ); | 1538 | // topLayout->addWidget(mExtensionManager ); |
1517 | 1539 | ||
1518 | 1540 | ||
1519 | /*US | 1541 | /*US |
1520 | #ifndef KAB_NOSPLITTER | 1542 | #ifndef KAB_NOSPLITTER |
1521 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1543 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1522 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1544 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1523 | topLayout->setSpacing( 10 ); | 1545 | topLayout->setSpacing( 10 ); |
1524 | 1546 | ||
1525 | mDetailsSplitter = new QSplitter( this ); | 1547 | mDetailsSplitter = new QSplitter( this ); |
1526 | 1548 | ||
1527 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1549 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1528 | 1550 | ||
1529 | mViewManager = new ViewManager( this, viewSpace ); | 1551 | mViewManager = new ViewManager( this, viewSpace ); |
1530 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1552 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1531 | 1553 | ||
1532 | mDetails = new ViewContainer( mDetailsSplitter ); | 1554 | mDetails = new ViewContainer( mDetailsSplitter ); |
1533 | 1555 | ||
1534 | topLayout->addWidget( mDetailsSplitter ); | 1556 | topLayout->addWidget( mDetailsSplitter ); |
1535 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1557 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1536 | #else //KAB_NOSPLITTER | 1558 | #else //KAB_NOSPLITTER |
1537 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1559 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1538 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1560 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1539 | topLayout->setSpacing( 10 ); | 1561 | topLayout->setSpacing( 10 ); |
1540 | 1562 | ||
1541 | // mDetailsSplitter = new QSplitter( this ); | 1563 | // mDetailsSplitter = new QSplitter( this ); |
1542 | 1564 | ||
1543 | QVBox *viewSpace = new QVBox( this ); | 1565 | QVBox *viewSpace = new QVBox( this ); |
1544 | 1566 | ||
1545 | mViewManager = new ViewManager( this, viewSpace ); | 1567 | mViewManager = new ViewManager( this, viewSpace ); |
1546 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1568 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1547 | 1569 | ||
1548 | mDetails = new ViewContainer( this ); | 1570 | mDetails = new ViewContainer( this ); |
1549 | 1571 | ||
1550 | topLayout->addWidget( viewSpace ); | 1572 | topLayout->addWidget( viewSpace ); |
1551 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1573 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1552 | topLayout->addWidget( mDetails ); | 1574 | topLayout->addWidget( mDetails ); |
1553 | #endif //KAB_NOSPLITTER | 1575 | #endif //KAB_NOSPLITTER |
1554 | */ | 1576 | */ |
1555 | 1577 | ||
1556 | 1578 | ||
1557 | #endif //KAB_EMBEDDED | 1579 | #endif //KAB_EMBEDDED |
1558 | initActions(); | 1580 | initActions(); |
1559 | 1581 | ||
1560 | #ifdef KAB_EMBEDDED | 1582 | #ifdef KAB_EMBEDDED |
1561 | addActionsManually(); | 1583 | addActionsManually(); |
1562 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1584 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1563 | mXXPortManager = new XXPortManager( this, this ); | 1585 | mXXPortManager = new XXPortManager( this, this ); |
1564 | 1586 | ||
1565 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1587 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1566 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1588 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1567 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1589 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1568 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1590 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1569 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1591 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1570 | // mIncSearchWidget->hide(); | 1592 | // mIncSearchWidget->hide(); |
1571 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1593 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1572 | SLOT( incrementalSearch( const QString& ) ) ); | 1594 | SLOT( incrementalSearch( const QString& ) ) ); |
1573 | 1595 | ||
1574 | 1596 | ||
1575 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1597 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1576 | 1598 | ||
1577 | topLayout->addWidget( mJumpButtonBar ); | 1599 | topLayout->addWidget( mJumpButtonBar ); |
1578 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1600 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1579 | 1601 | ||
1580 | // mMainWindow->getIconToolBar()->raise(); | 1602 | // mMainWindow->getIconToolBar()->raise(); |
1581 | 1603 | ||
1582 | #endif //KAB_EMBEDDED | 1604 | #endif //KAB_EMBEDDED |
1583 | 1605 | ||
1584 | } | 1606 | } |
1585 | void KABCore::initActions() | 1607 | void KABCore::initActions() |
1586 | { | 1608 | { |
1587 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1609 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1588 | 1610 | ||
1589 | #ifndef KAB_EMBEDDED | 1611 | #ifndef KAB_EMBEDDED |
1590 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1612 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1591 | SLOT( clipboardDataChanged() ) ); | 1613 | SLOT( clipboardDataChanged() ) ); |
1592 | #endif //KAB_EMBEDDED | 1614 | #endif //KAB_EMBEDDED |
1593 | 1615 | ||
1594 | // file menu | 1616 | // file menu |
1595 | if ( mIsPart ) { | 1617 | if ( mIsPart ) { |
1596 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1618 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1597 | SLOT( sendMail() ), actionCollection(), | 1619 | SLOT( sendMail() ), actionCollection(), |
1598 | "kaddressbook_mail" ); | 1620 | "kaddressbook_mail" ); |
1599 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1621 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1600 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1622 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1601 | 1623 | ||
1602 | } else { | 1624 | } else { |
1603 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1625 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1604 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1626 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1605 | } | 1627 | } |
1606 | 1628 | ||
1607 | 1629 | ||
1608 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1630 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1609 | SLOT( save() ), actionCollection(), "file_sync" ); | 1631 | SLOT( save() ), actionCollection(), "file_sync" ); |
1610 | 1632 | ||
1611 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1633 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1612 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1634 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1613 | 1635 | ||
1614 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1636 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1615 | this, SLOT( mailVCard() ), | 1637 | this, SLOT( mailVCard() ), |
1616 | actionCollection(), "file_mail_vcard"); | 1638 | actionCollection(), "file_mail_vcard"); |
1617 | 1639 | ||
1618 | mActionBeamVCard = 0; | 1640 | mActionBeamVCard = 0; |
1619 | mActionBeam = 0; | 1641 | mActionBeam = 0; |
1620 | 1642 | ||
1621 | #ifndef DESKTOP_VERSION | 1643 | #ifndef DESKTOP_VERSION |
1622 | if ( Ir::supported() ) { | 1644 | if ( Ir::supported() ) { |
1623 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1645 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1624 | SLOT( beamVCard() ), actionCollection(), | 1646 | SLOT( beamVCard() ), actionCollection(), |
1625 | "kaddressbook_beam_vcard" ); | 1647 | "kaddressbook_beam_vcard" ); |
1626 | 1648 | ||
1627 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1649 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1628 | SLOT( beamMySelf() ), actionCollection(), | 1650 | SLOT( beamMySelf() ), actionCollection(), |
1629 | "kaddressbook_beam_myself" ); | 1651 | "kaddressbook_beam_myself" ); |
1630 | } | 1652 | } |
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 45c7b55..c93d51a 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -1,692 +1,699 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
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 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | 31 | ||
32 | #ifndef KAB_EMBEDDED | 32 | #ifndef KAB_EMBEDDED |
33 | #include <libkdepim/kvcarddrag.h> | 33 | #include <libkdepim/kvcarddrag.h> |
34 | #include <kabc/vcardconverter.h> | 34 | #include <kabc/vcardconverter.h> |
35 | #include <kconfig.h> | 35 | #include <kconfig.h> |
36 | #include <kdeversion.h> | 36 | #include <kdeversion.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | #include <kmultipledrag.h> | 40 | #include <kmultipledrag.h> |
41 | #include <ktrader.h> | 41 | #include <ktrader.h> |
42 | #include <kurldrag.h> | 42 | #include <kurldrag.h> |
43 | 43 | ||
44 | #include "addresseeutil.h" | 44 | #include "addresseeutil.h" |
45 | #else //KAB_EMBEDDED | 45 | #else //KAB_EMBEDDED |
46 | #include "views/kaddressbookiconview.h" | 46 | #include "views/kaddressbookiconview.h" |
47 | #include "views/kaddressbooktableview.h" | 47 | #include "views/kaddressbooktableview.h" |
48 | #include "views/kaddressbookcardview.h" | 48 | #include "views/kaddressbookcardview.h" |
49 | #include "kaddressbookview.h" | 49 | #include "kaddressbookview.h" |
50 | 50 | ||
51 | #include <qaction.h> | 51 | #include <qaction.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
54 | #include <kconfigbase.h> | 54 | #include <kconfigbase.h> |
55 | 55 | ||
56 | #endif //KAB_EMBEDDED | 56 | #endif //KAB_EMBEDDED |
57 | 57 | ||
58 | 58 | ||
59 | #include <kdebug.h> | 59 | #include <kdebug.h> |
60 | #include <kactionclasses.h> | 60 | #include <kactionclasses.h> |
61 | 61 | ||
62 | #include <qlayout.h> | 62 | #include <qlayout.h> |
63 | #include <qwidgetstack.h> | 63 | #include <qwidgetstack.h> |
64 | 64 | ||
65 | #include <kabc/addressbook.h> | 65 | #include <kabc/addressbook.h> |
66 | #include "filtereditdialog.h" | 66 | #include "filtereditdialog.h" |
67 | #include "addviewdialog.h" | 67 | #include "addviewdialog.h" |
68 | #include "kabcore.h" | 68 | #include "kabcore.h" |
69 | #include "kabprefs.h" | 69 | #include "kabprefs.h" |
70 | #include "viewmanager.h" | 70 | #include "viewmanager.h" |
71 | 71 | ||
72 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) | 72 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) |
73 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) | 73 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) |
74 | { | 74 | { |
75 | initGUI(); | 75 | initGUI(); |
76 | initActions(); | 76 | initActions(); |
77 | 77 | ||
78 | mViewDict.setAutoDelete( true ); | 78 | mViewDict.setAutoDelete( true ); |
79 | 79 | ||
80 | createViewFactories(); | 80 | createViewFactories(); |
81 | } | 81 | } |
82 | 82 | ||
83 | ViewManager::~ViewManager() | 83 | ViewManager::~ViewManager() |
84 | { | 84 | { |
85 | unloadViews(); | 85 | unloadViews(); |
86 | mViewFactoryDict.clear(); | 86 | mViewFactoryDict.clear(); |
87 | } | 87 | } |
88 | 88 | ||
89 | void ViewManager::restoreSettings() | 89 | void ViewManager::restoreSettings() |
90 | { | 90 | { |
91 | mViewNameList = KABPrefs::instance()->mViewNames; | 91 | mViewNameList = KABPrefs::instance()->mViewNames; |
92 | QString activeViewName = KABPrefs::instance()->mCurrentView; | 92 | QString activeViewName = KABPrefs::instance()->mCurrentView; |
93 | 93 | ||
94 | mActionSelectView->setItems( mViewNameList ); | 94 | mActionSelectView->setItems( mViewNameList ); |
95 | 95 | ||
96 | // Filter | 96 | // Filter |
97 | mFilterList = Filter::restore( mCore->config(), "Filter" ); | 97 | mFilterList = Filter::restore( mCore->config(), "Filter" ); |
98 | mActionSelectFilter->setItems( filterNames() ); | 98 | mActionSelectFilter->setItems( filterNames() ); |
99 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); | 99 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); |
100 | 100 | ||
101 | // Tell the views to reread their config, since they may have | 101 | // Tell the views to reread their config, since they may have |
102 | // been modified by global settings | 102 | // been modified by global settings |
103 | QString _oldgroup = mCore->config()->group(); | 103 | QString _oldgroup = mCore->config()->group(); |
104 | 104 | ||
105 | QDictIterator<KAddressBookView> it( mViewDict ); | 105 | QDictIterator<KAddressBookView> it( mViewDict ); |
106 | for ( it.toFirst(); it.current(); ++it ) { | 106 | for ( it.toFirst(); it.current(); ++it ) { |
107 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 107 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
108 | it.current()->readConfig( mCore->config() ); | 108 | it.current()->readConfig( mCore->config() ); |
109 | } | 109 | } |
110 | setActiveView( activeViewName ); | 110 | setActiveView( activeViewName ); |
111 | 111 | ||
112 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 112 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
113 | } | 113 | } |
114 | 114 | ||
115 | void ViewManager::saveSettings() | 115 | void ViewManager::saveSettings() |
116 | { | 116 | { |
117 | QString _oldgroup = mCore->config()->group(); | 117 | QString _oldgroup = mCore->config()->group(); |
118 | 118 | ||
119 | QDictIterator<KAddressBookView> it( mViewDict ); | 119 | QDictIterator<KAddressBookView> it( mViewDict ); |
120 | for ( it.toFirst(); it.current(); ++it ) { | 120 | for ( it.toFirst(); it.current(); ++it ) { |
121 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 121 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
122 | #ifdef DESKTOP_VERSION | 122 | #ifdef DESKTOP_VERSION |
123 | (*it)->writeConfig( mCore->config() ); | 123 | (*it)->writeConfig( mCore->config() ); |
124 | #else | 124 | #else |
125 | (*it).writeConfig( mCore->config() ); | 125 | (*it).writeConfig( mCore->config() ); |
126 | #endif | 126 | #endif |
127 | } | 127 | } |
128 | 128 | ||
129 | Filter::save( mCore->config(), "Filter", mFilterList ); | 129 | Filter::save( mCore->config(), "Filter", mFilterList ); |
130 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); | 130 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); |
131 | 131 | ||
132 | // write the view name list | 132 | // write the view name list |
133 | KABPrefs::instance()->mViewNames = mViewNameList; | 133 | KABPrefs::instance()->mViewNames = mViewNameList; |
134 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); | 134 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); |
135 | 135 | ||
136 | } | 136 | } |
137 | 137 | ||
138 | QStringList ViewManager::selectedUids() const | 138 | QStringList ViewManager::selectedUids() const |
139 | { | 139 | { |
140 | if ( mActiveView ) | 140 | if ( mActiveView ) |
141 | return mActiveView->selectedUids(); | 141 | return mActiveView->selectedUids(); |
142 | else | 142 | else |
143 | return QStringList(); | 143 | return QStringList(); |
144 | } | 144 | } |
145 | 145 | ||
146 | QStringList ViewManager::selectedEmails() const | 146 | QStringList ViewManager::selectedEmails() const |
147 | { | 147 | { |
148 | if ( mActiveView ) | 148 | if ( mActiveView ) |
149 | return mActiveView->selectedEmails(); | 149 | return mActiveView->selectedEmails(); |
150 | else | 150 | else |
151 | return QStringList(); | 151 | return QStringList(); |
152 | } | 152 | } |
153 | 153 | ||
154 | KABC::Addressee::List ViewManager::selectedAddressees() const | 154 | KABC::Addressee::List ViewManager::selectedAddressees() const |
155 | { | 155 | { |
156 | KABC::Addressee::List list; | 156 | KABC::Addressee::List list; |
157 | if ( mActiveView ) { | 157 | if ( mActiveView ) { |
158 | QStringList uids = mActiveView->selectedUids(); | 158 | QStringList uids = mActiveView->selectedUids(); |
159 | QStringList::Iterator it; | 159 | QStringList::Iterator it; |
160 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 160 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
161 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); | 161 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); |
162 | if ( !addr.isEmpty() ) | 162 | if ( !addr.isEmpty() ) |
163 | list.append( addr ); | 163 | list.append( addr ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | return list; | 167 | return list; |
168 | } | 168 | } |
169 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 169 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
170 | void ViewManager::setSelected() | 170 | void ViewManager::setSelected() |
171 | { | 171 | { |
172 | setSelected( QString::null, true ); | 172 | setSelected( QString::null, true ); |
173 | } | 173 | } |
174 | 174 | ||
175 | void ViewManager::setSelected( const QString &uid, bool selected ) | 175 | void ViewManager::setSelected( const QString &uid, bool selected ) |
176 | { | 176 | { |
177 | if ( mActiveView ) | 177 | if ( mActiveView ) |
178 | mActiveView->setSelected( uid, selected ); | 178 | mActiveView->setSelected( uid, selected ); |
179 | } | 179 | } |
180 | 180 | ||
181 | void ViewManager::setListSelected(QStringList list) | ||
182 | { | ||
183 | int i, count = list.count(); | ||
184 | for ( i = 0; i < count;++i ) | ||
185 | setSelected( list[i], true ); | ||
186 | |||
187 | } | ||
181 | void ViewManager::unloadViews() | 188 | void ViewManager::unloadViews() |
182 | { | 189 | { |
183 | mViewDict.clear(); | 190 | mViewDict.clear(); |
184 | mActiveView = 0; | 191 | mActiveView = 0; |
185 | } | 192 | } |
186 | 193 | ||
187 | void ViewManager::setActiveView( const QString &name ) | 194 | void ViewManager::setActiveView( const QString &name ) |
188 | { | 195 | { |
189 | KAddressBookView *view = 0; | 196 | KAddressBookView *view = 0; |
190 | 197 | ||
191 | // Check that this isn't the same as the current active view | 198 | // Check that this isn't the same as the current active view |
192 | if ( mActiveView && ( mActiveView->caption() == name ) ) | 199 | if ( mActiveView && ( mActiveView->caption() == name ) ) |
193 | return; | 200 | return; |
194 | 201 | ||
195 | // At this point we know the view that should be active is not | 202 | // At this point we know the view that should be active is not |
196 | // currently active. We will try to find the new on in the list. If | 203 | // currently active. We will try to find the new on in the list. If |
197 | // we can't find it, it means it hasn't been instantiated, so we will | 204 | // we can't find it, it means it hasn't been instantiated, so we will |
198 | // create it on demand. | 205 | // create it on demand. |
199 | 206 | ||
200 | view = mViewDict.find( name ); | 207 | view = mViewDict.find( name ); |
201 | 208 | ||
202 | // Check if we found the view. If we didn't, then we need to create it | 209 | // Check if we found the view. If we didn't, then we need to create it |
203 | if ( view == 0 ) { | 210 | if ( view == 0 ) { |
204 | KConfig *config = mCore->config(); | 211 | KConfig *config = mCore->config(); |
205 | 212 | ||
206 | KConfigGroupSaver saver( config, name ); | 213 | KConfigGroupSaver saver( config, name ); |
207 | 214 | ||
208 | QString type = config->readEntry( "Type", "Table" ); | 215 | QString type = config->readEntry( "Type", "Table" ); |
209 | 216 | ||
210 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; | 217 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; |
211 | 218 | ||
212 | ViewFactory *factory = mViewFactoryDict.find( type ); | 219 | ViewFactory *factory = mViewFactoryDict.find( type ); |
213 | if ( factory ) | 220 | if ( factory ) |
214 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); | 221 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); |
215 | 222 | ||
216 | if ( view ) { | 223 | if ( view ) { |
217 | view->setCaption( name ); | 224 | view->setCaption( name ); |
218 | mViewDict.insert( name, view ); | 225 | mViewDict.insert( name, view ); |
219 | //US my version needs an int as second parameter to addWidget | 226 | //US my version needs an int as second parameter to addWidget |
220 | mViewWidgetStack->addWidget( view, -1 ); | 227 | mViewWidgetStack->addWidget( view, -1 ); |
221 | view->readConfig( config ); | 228 | view->readConfig( config ); |
222 | 229 | ||
223 | // The manager just relays the signals | 230 | // The manager just relays the signals |
224 | connect( view, SIGNAL( selected( const QString& ) ), | 231 | connect( view, SIGNAL( selected( const QString& ) ), |
225 | SIGNAL( selected( const QString & ) ) ); | 232 | SIGNAL( selected( const QString & ) ) ); |
226 | connect( view, SIGNAL( executed( const QString& ) ), | 233 | connect( view, SIGNAL( executed( const QString& ) ), |
227 | SIGNAL( executed( const QString& ) ) ); | 234 | SIGNAL( executed( const QString& ) ) ); |
228 | 235 | ||
229 | connect( view, SIGNAL( deleteRequest( ) ), | 236 | connect( view, SIGNAL( deleteRequest( ) ), |
230 | SIGNAL( deleteRequest( ) ) ); | 237 | SIGNAL( deleteRequest( ) ) ); |
231 | 238 | ||
232 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); | 239 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); |
233 | connect( view, SIGNAL( dropped( QDropEvent* ) ), | 240 | connect( view, SIGNAL( dropped( QDropEvent* ) ), |
234 | SLOT( dropped( QDropEvent* ) ) ); | 241 | SLOT( dropped( QDropEvent* ) ) ); |
235 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); | 242 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); |
236 | } | 243 | } |
237 | } | 244 | } |
238 | 245 | ||
239 | // If we found or created the view, raise it and refresh it | 246 | // If we found or created the view, raise it and refresh it |
240 | if ( view ) { | 247 | if ( view ) { |
241 | mActiveView = view; | 248 | mActiveView = view; |
242 | mViewWidgetStack->raiseWidget( view ); | 249 | mViewWidgetStack->raiseWidget( view ); |
243 | // Set the proper filter in the view. By setting the combo | 250 | // Set the proper filter in the view. By setting the combo |
244 | // box, the activated slot will be called, which will push | 251 | // box, the activated slot will be called, which will push |
245 | // the filter to the view and refresh it. | 252 | // the filter to the view and refresh it. |
246 | 253 | ||
247 | if ( view->defaultFilterType() == KAddressBookView::None ) { | 254 | if ( view->defaultFilterType() == KAddressBookView::None ) { |
248 | 255 | ||
249 | mActionSelectFilter->setCurrentItem( 0 ); | 256 | mActionSelectFilter->setCurrentItem( 0 ); |
250 | setActiveFilter( 0 ); | 257 | setActiveFilter( 0 ); |
251 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { | 258 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { |
252 | setActiveFilter( mActionSelectFilter->currentItem() ); | 259 | setActiveFilter( mActionSelectFilter->currentItem() ); |
253 | } else { | 260 | } else { |
254 | uint pos = filterPosition( view->defaultFilterName() ); | 261 | uint pos = filterPosition( view->defaultFilterName() ); |
255 | mActionSelectFilter->setCurrentItem( pos ); | 262 | mActionSelectFilter->setCurrentItem( pos ); |
256 | setActiveFilter( pos ); | 263 | setActiveFilter( pos ); |
257 | } | 264 | } |
258 | //US qDebug("ViewManager::setActiveView 6" ); | 265 | //US qDebug("ViewManager::setActiveView 6" ); |
259 | 266 | ||
260 | // Update the inc search widget to show the fields in the new active | 267 | // Update the inc search widget to show the fields in the new active |
261 | // view. | 268 | // view. |
262 | mCore->setSearchFields( mActiveView->fields() ); | 269 | mCore->setSearchFields( mActiveView->fields() ); |
263 | 270 | ||
264 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 271 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
265 | //US mActiveView->refresh(); | 272 | //US mActiveView->refresh(); |
266 | 273 | ||
267 | } | 274 | } |
268 | else | 275 | else |
269 | { | 276 | { |
270 | qDebug("ViewManager::setActiveView: unable to find view" ); | 277 | qDebug("ViewManager::setActiveView: unable to find view" ); |
271 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; | 278 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; |
272 | } | 279 | } |
273 | } | 280 | } |
274 | 281 | ||
275 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 282 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
276 | void ViewManager::refreshView() | 283 | void ViewManager::refreshView() |
277 | { | 284 | { |
278 | refreshView( QString::null ); | 285 | refreshView( QString::null ); |
279 | } | 286 | } |
280 | 287 | ||
281 | void ViewManager::refreshView( const QString &uid ) | 288 | void ViewManager::refreshView( const QString &uid ) |
282 | { | 289 | { |
283 | if ( mActiveView ) | 290 | if ( mActiveView ) |
284 | mActiveView->refresh( uid ); | 291 | mActiveView->refresh( uid ); |
285 | } | 292 | } |
286 | 293 | ||
287 | void ViewManager::editView() | 294 | void ViewManager::editView() |
288 | { | 295 | { |
289 | if ( !mActiveView ) | 296 | if ( !mActiveView ) |
290 | return; | 297 | return; |
291 | 298 | ||
292 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); | 299 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); |
293 | ViewConfigureWidget *wdg = 0; | 300 | ViewConfigureWidget *wdg = 0; |
294 | ViewConfigureDialog* dlg = 0; | 301 | ViewConfigureDialog* dlg = 0; |
295 | if ( factory ) { | 302 | if ( factory ) { |
296 | // Save the filters so the dialog has the latest set | 303 | // Save the filters so the dialog has the latest set |
297 | Filter::save( mCore->config(), "Filter", mFilterList ); | 304 | Filter::save( mCore->config(), "Filter", mFilterList ); |
298 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); | 305 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); |
299 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); | 306 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); |
300 | } else { | 307 | } else { |
301 | qDebug("ViewManager::editView()::cannot find viewfactory "); | 308 | qDebug("ViewManager::editView()::cannot find viewfactory "); |
302 | return; | 309 | return; |
303 | } | 310 | } |
304 | if ( wdg ) { | 311 | if ( wdg ) { |
305 | dlg->setWidget( wdg ); | 312 | dlg->setWidget( wdg ); |
306 | 313 | ||
307 | #ifndef DESKTOP_VERSION | 314 | #ifndef DESKTOP_VERSION |
308 | //dlg.setMaximumSize( 640, 480 ); | 315 | //dlg.setMaximumSize( 640, 480 ); |
309 | //dlg->setGeometry( 40,40, 400, 300); | 316 | //dlg->setGeometry( 40,40, 400, 300); |
310 | dlg->showMaximized(); | 317 | dlg->showMaximized(); |
311 | #endif | 318 | #endif |
312 | 319 | ||
313 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); | 320 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); |
314 | 321 | ||
315 | dlg->restoreSettings( mCore->config() ); | 322 | dlg->restoreSettings( mCore->config() ); |
316 | 323 | ||
317 | if ( dlg->exec() ) { | 324 | if ( dlg->exec() ) { |
318 | dlg->saveSettings( mCore->config() ); | 325 | dlg->saveSettings( mCore->config() ); |
319 | mActiveView->readConfig( mCore->config() ); | 326 | mActiveView->readConfig( mCore->config() ); |
320 | 327 | ||
321 | // Set the proper filter in the view. By setting the combo | 328 | // Set the proper filter in the view. By setting the combo |
322 | // box, the activated slot will be called, which will push | 329 | // box, the activated slot will be called, which will push |
323 | // the filter to the view and refresh it. | 330 | // the filter to the view and refresh it. |
324 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { | 331 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { |
325 | mActionSelectFilter->setCurrentItem( 0 ); | 332 | mActionSelectFilter->setCurrentItem( 0 ); |
326 | setActiveFilter( 0 ); | 333 | setActiveFilter( 0 ); |
327 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { | 334 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { |
328 | setActiveFilter( mActionSelectFilter->currentItem() ); | 335 | setActiveFilter( mActionSelectFilter->currentItem() ); |
329 | } else { | 336 | } else { |
330 | uint pos = filterPosition( mActiveView->defaultFilterName() ); | 337 | uint pos = filterPosition( mActiveView->defaultFilterName() ); |
331 | mActionSelectFilter->setCurrentItem( pos ); | 338 | mActionSelectFilter->setCurrentItem( pos ); |
332 | setActiveFilter( pos ); | 339 | setActiveFilter( pos ); |
333 | } | 340 | } |
334 | mCore->setSearchFields( mActiveView->fields() ); | 341 | mCore->setSearchFields( mActiveView->fields() ); |
335 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 342 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
336 | //US mActiveView->refresh(); | 343 | //US mActiveView->refresh(); |
337 | 344 | ||
338 | 345 | ||
339 | //US this is a bugfix, that we get notified if we change a views configuration | 346 | //US this is a bugfix, that we get notified if we change a views configuration |
340 | emit modified(); | 347 | emit modified(); |
341 | 348 | ||
342 | } | 349 | } |
343 | 350 | ||
344 | } | 351 | } |
345 | delete dlg; | 352 | delete dlg; |
346 | } | 353 | } |
347 | 354 | ||
348 | void ViewManager::deleteView() | 355 | void ViewManager::deleteView() |
349 | { | 356 | { |
350 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) | 357 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) |
351 | .arg( mActiveView->caption() ); | 358 | .arg( mActiveView->caption() ); |
352 | QString caption = i18n( "Confirm Delete" ); | 359 | QString caption = i18n( "Confirm Delete" ); |
353 | 360 | ||
354 | 361 | ||
355 | if (QMessageBox::information( this, caption, | 362 | if (QMessageBox::information( this, caption, |
356 | text, | 363 | text, |
357 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) | 364 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) |
358 | { | 365 | { |
359 | mViewNameList.remove( mActiveView->caption() ); | 366 | mViewNameList.remove( mActiveView->caption() ); |
360 | 367 | ||
361 | // remove the view from the config file | 368 | // remove the view from the config file |
362 | KConfig *config = mCore->config(); | 369 | KConfig *config = mCore->config(); |
363 | config->deleteGroup( mActiveView->caption() ); | 370 | config->deleteGroup( mActiveView->caption() ); |
364 | 371 | ||
365 | mViewDict.remove( mActiveView->caption() ); | 372 | mViewDict.remove( mActiveView->caption() ); |
366 | mActiveView = 0; | 373 | mActiveView = 0; |
367 | 374 | ||
368 | // we are in an invalid state now, but that should be fixed after | 375 | // we are in an invalid state now, but that should be fixed after |
369 | // we emit the signal | 376 | // we emit the signal |
370 | mActionSelectView->setItems( mViewNameList ); | 377 | mActionSelectView->setItems( mViewNameList ); |
371 | if ( mViewNameList.count() > 0 ) { | 378 | if ( mViewNameList.count() > 0 ) { |
372 | mActionSelectView->setCurrentItem( 0 ); | 379 | mActionSelectView->setCurrentItem( 0 ); |
373 | setActiveView( mViewNameList[ 0 ] ); | 380 | setActiveView( mViewNameList[ 0 ] ); |
374 | } | 381 | } |
375 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 382 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
376 | } | 383 | } |
377 | } | 384 | } |
378 | 385 | ||
379 | void ViewManager::addView() | 386 | void ViewManager::addView() |
380 | { | 387 | { |
381 | AddViewDialog dialog( &mViewFactoryDict, this ); | 388 | AddViewDialog dialog( &mViewFactoryDict, this ); |
382 | 389 | ||
383 | if ( dialog.exec() ) { | 390 | if ( dialog.exec() ) { |
384 | QString newName = dialog.viewName(); | 391 | QString newName = dialog.viewName(); |
385 | QString type = dialog.viewType(); | 392 | QString type = dialog.viewType(); |
386 | 393 | ||
387 | // Check for name conflicts | 394 | // Check for name conflicts |
388 | bool firstConflict = true; | 395 | bool firstConflict = true; |
389 | int numTries = 1; | 396 | int numTries = 1; |
390 | while ( mViewNameList.contains( newName ) > 0 ) { | 397 | while ( mViewNameList.contains( newName ) > 0 ) { |
391 | if ( !firstConflict ) { | 398 | if ( !firstConflict ) { |
392 | newName = newName.left( newName.length() - 4 ); | 399 | newName = newName.left( newName.length() - 4 ); |
393 | firstConflict = false; | 400 | firstConflict = false; |
394 | } | 401 | } |
395 | 402 | ||
396 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); | 403 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); |
397 | numTries++; | 404 | numTries++; |
398 | } | 405 | } |
399 | 406 | ||
400 | // Add the new one to the list | 407 | // Add the new one to the list |
401 | mViewNameList.append( newName ); | 408 | mViewNameList.append( newName ); |
402 | 409 | ||
403 | // write the view to the config file, | 410 | // write the view to the config file, |
404 | KConfig *config = mCore->config(); | 411 | KConfig *config = mCore->config(); |
405 | 412 | ||
406 | config->deleteGroup( newName ); | 413 | config->deleteGroup( newName ); |
407 | 414 | ||
408 | KConfigGroupSaver saver( config, newName ); | 415 | KConfigGroupSaver saver( config, newName ); |
409 | 416 | ||
410 | config->writeEntry( "Type", type ); | 417 | config->writeEntry( "Type", type ); |
411 | 418 | ||
412 | // try to set the active view | 419 | // try to set the active view |
413 | mActionSelectView->setItems( mViewNameList ); | 420 | mActionSelectView->setItems( mViewNameList ); |
414 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); | 421 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); |
415 | setActiveView( newName ); | 422 | setActiveView( newName ); |
416 | 423 | ||
417 | editView(); | 424 | editView(); |
418 | 425 | ||
419 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 426 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
420 | } | 427 | } |
421 | } | 428 | } |
422 | 429 | ||
423 | void ViewManager::createViewFactories() | 430 | void ViewManager::createViewFactories() |
424 | { | 431 | { |
425 | #ifndef KAB_EMBEDDED | 432 | #ifndef KAB_EMBEDDED |
426 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); | 433 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); |
427 | KTrader::OfferList::ConstIterator it; | 434 | KTrader::OfferList::ConstIterator it; |
428 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 435 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
429 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) | 436 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) |
430 | continue; | 437 | continue; |
431 | 438 | ||
432 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); | 439 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); |
433 | 440 | ||
434 | if ( !factory ) { | 441 | if ( !factory ) { |
435 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; | 442 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; |
436 | continue; | 443 | continue; |
437 | } | 444 | } |
438 | 445 | ||
439 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); | 446 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); |
440 | 447 | ||
441 | if ( !viewFactory ) { | 448 | if ( !viewFactory ) { |
442 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; | 449 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; |
443 | continue; | 450 | continue; |
444 | } | 451 | } |
445 | 452 | ||
446 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 453 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
447 | } | 454 | } |
448 | 455 | ||
449 | #else //KAB_EMBEDDED | 456 | #else //KAB_EMBEDDED |
450 | ViewFactory* viewFactory = new IconViewFactory(); | 457 | ViewFactory* viewFactory = new IconViewFactory(); |
451 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 458 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
452 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 459 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
453 | 460 | ||
454 | viewFactory = new TableViewFactory(); | 461 | viewFactory = new TableViewFactory(); |
455 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 462 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
456 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 463 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
457 | 464 | ||
458 | viewFactory = new CardViewFactory(); | 465 | viewFactory = new CardViewFactory(); |
459 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 466 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
460 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 467 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
461 | 468 | ||
462 | #endif //KAB_EMBEDDED | 469 | #endif //KAB_EMBEDDED |
463 | 470 | ||
464 | } | 471 | } |
465 | 472 | ||
466 | void ViewManager::dropped( QDropEvent *e ) | 473 | void ViewManager::dropped( QDropEvent *e ) |
467 | { | 474 | { |
468 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; | 475 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; |
469 | 476 | ||
470 | #ifndef KAB_EMBEDDED | 477 | #ifndef KAB_EMBEDDED |
471 | 478 | ||
472 | QString clipText, vcards; | 479 | QString clipText, vcards; |
473 | KURL::List urls; | 480 | KURL::List urls; |
474 | 481 | ||
475 | if ( KURLDrag::decode( e, urls) ) { | 482 | if ( KURLDrag::decode( e, urls) ) { |
476 | KURL::List::Iterator it = urls.begin(); | 483 | KURL::List::Iterator it = urls.begin(); |
477 | int c = urls.count(); | 484 | int c = urls.count(); |
478 | if ( c > 1 ) { | 485 | if ( c > 1 ) { |
479 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); | 486 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); |
480 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { | 487 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { |
481 | for ( ; it != urls.end(); ++it ) | 488 | for ( ; it != urls.end(); ++it ) |
482 | emit urlDropped( *it ); | 489 | emit urlDropped( *it ); |
483 | } | 490 | } |
484 | } else if ( c == 1 ) | 491 | } else if ( c == 1 ) |
485 | emit urlDropped( *it ); | 492 | emit urlDropped( *it ); |
486 | } else if ( KVCardDrag::decode( e, vcards ) ) { | 493 | } else if ( KVCardDrag::decode( e, vcards ) ) { |
487 | KABC::Addressee addr; | 494 | KABC::Addressee addr; |
488 | KABC::VCardConverter converter; | 495 | KABC::VCardConverter converter; |
489 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); | 496 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); |
490 | QStringList::Iterator it; | 497 | QStringList::Iterator it; |
491 | for ( it = list.begin(); it != list.end(); ++it ) { | 498 | for ( it = list.begin(); it != list.end(); ++it ) { |
492 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { | 499 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { |
493 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); | 500 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); |
494 | if ( a.isEmpty() ) { | 501 | if ( a.isEmpty() ) { |
495 | mCore->addressBook()->insertAddressee( addr ); | 502 | mCore->addressBook()->insertAddressee( addr ); |
496 | emit modified(); | 503 | emit modified(); |
497 | } | 504 | } |
498 | } | 505 | } |
499 | } | 506 | } |
500 | 507 | ||
501 | mActiveView->refresh(); | 508 | mActiveView->refresh(); |
502 | } | 509 | } |
503 | #else //KAB_EMBEDDED | 510 | #else //KAB_EMBEDDED |
504 | qDebug("ViewManager::dropped() has to be changed!!" ); | 511 | qDebug("ViewManager::dropped() has to be changed!!" ); |
505 | #endif //KAB_EMBEDDED | 512 | #endif //KAB_EMBEDDED |
506 | 513 | ||
507 | } | 514 | } |
508 | 515 | ||
509 | void ViewManager::startDrag() | 516 | void ViewManager::startDrag() |
510 | { | 517 | { |
511 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; | 518 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; |
512 | 519 | ||
513 | #ifndef KAB_EMBEDDED | 520 | #ifndef KAB_EMBEDDED |
514 | 521 | ||
515 | // Get the list of all the selected addressees | 522 | // Get the list of all the selected addressees |
516 | KABC::Addressee::List addrList; | 523 | KABC::Addressee::List addrList; |
517 | QStringList uidList = selectedUids(); | 524 | QStringList uidList = selectedUids(); |
518 | QStringList::Iterator iter; | 525 | QStringList::Iterator iter; |
519 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) | 526 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) |
520 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); | 527 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); |
521 | 528 | ||
522 | KMultipleDrag *drag = new KMultipleDrag( this ); | 529 | KMultipleDrag *drag = new KMultipleDrag( this ); |
523 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); | 530 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); |
524 | KABC::Addressee::List::Iterator it; | 531 | KABC::Addressee::List::Iterator it; |
525 | QStringList vcards; | 532 | QStringList vcards; |
526 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { | 533 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { |
527 | QString vcard = QString::null; | 534 | QString vcard = QString::null; |
528 | KABC::VCardConverter converter; | 535 | KABC::VCardConverter converter; |
529 | if ( converter.addresseeToVCard( *it, vcard ) ) | 536 | if ( converter.addresseeToVCard( *it, vcard ) ) |
530 | vcards.append( vcard ); | 537 | vcards.append( vcard ); |
531 | } | 538 | } |
532 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); | 539 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); |
533 | 540 | ||
534 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); | 541 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); |
535 | drag->dragCopy(); | 542 | drag->dragCopy(); |
536 | 543 | ||
537 | #else //KAB_EMBEDDED | 544 | #else //KAB_EMBEDDED |
538 | qDebug("ViewManager::startDrag() has to be changed!!" ); | 545 | qDebug("ViewManager::startDrag() has to be changed!!" ); |
539 | #endif //KAB_EMBEDDED | 546 | #endif //KAB_EMBEDDED |
540 | 547 | ||
541 | } | 548 | } |
542 | 549 | ||
543 | void ViewManager::setActiveFilter( int index ) | 550 | void ViewManager::setActiveFilter( int index ) |
544 | { | 551 | { |
545 | Filter currentFilter; | 552 | Filter currentFilter; |
546 | 553 | ||
547 | if ( ( index - 1 ) < 0 ) | 554 | if ( ( index - 1 ) < 0 ) |
548 | currentFilter = Filter(); | 555 | currentFilter = Filter(); |
549 | else | 556 | else |
550 | currentFilter = mFilterList[ index - 1 ]; | 557 | currentFilter = mFilterList[ index - 1 ]; |
551 | 558 | ||
552 | // Check if we have a view. Since the filter combo is created before | 559 | // Check if we have a view. Since the filter combo is created before |
553 | // the view, this slot could be called before there is a valid view. | 560 | // the view, this slot could be called before there is a valid view. |
554 | if ( mActiveView ) { | 561 | if ( mActiveView ) { |
555 | mActiveView->setFilter( currentFilter ); | 562 | mActiveView->setFilter( currentFilter ); |
556 | mActiveView->refresh(); | 563 | mActiveView->refresh(); |
557 | emit selected( QString::null ); | 564 | emit selected( QString::null ); |
558 | } | 565 | } |
559 | } | 566 | } |
560 | 567 | ||
561 | void ViewManager::configureFilters() | 568 | void ViewManager::configureFilters() |
562 | { | 569 | { |
563 | FilterDialog dlg( this ); | 570 | FilterDialog dlg( this ); |
564 | 571 | ||
565 | dlg.setFilters( mFilterList ); | 572 | dlg.setFilters( mFilterList ); |
566 | 573 | ||
567 | if ( dlg.exec() ) | 574 | if ( dlg.exec() ) |
568 | mFilterList = dlg.filters(); | 575 | mFilterList = dlg.filters(); |
569 | 576 | ||
570 | uint pos = mActionSelectFilter->currentItem(); | 577 | uint pos = mActionSelectFilter->currentItem(); |
571 | mActionSelectFilter->setItems( filterNames() ); | 578 | mActionSelectFilter->setItems( filterNames() ); |
572 | mActionSelectFilter->setCurrentItem( pos ); | 579 | mActionSelectFilter->setCurrentItem( pos ); |
573 | setActiveFilter( pos ); | 580 | setActiveFilter( pos ); |
574 | } | 581 | } |
575 | 582 | ||
576 | QStringList ViewManager::filterNames() const | 583 | QStringList ViewManager::filterNames() const |
577 | { | 584 | { |
578 | QStringList names( i18n( "No Filter" ) ); | 585 | QStringList names( i18n( "No Filter" ) ); |
579 | 586 | ||
580 | Filter::List::ConstIterator it; | 587 | Filter::List::ConstIterator it; |
581 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) | 588 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) |
582 | names.append( (*it).name() ); | 589 | names.append( (*it).name() ); |
583 | 590 | ||
584 | return names; | 591 | return names; |
585 | } | 592 | } |
586 | 593 | ||
587 | int ViewManager::filterPosition( const QString &name ) const | 594 | int ViewManager::filterPosition( const QString &name ) const |
588 | { | 595 | { |
589 | int pos = 0; | 596 | int pos = 0; |
590 | 597 | ||
591 | Filter::List::ConstIterator it; | 598 | Filter::List::ConstIterator it; |
592 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) | 599 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) |
593 | if ( name == (*it).name() ) | 600 | if ( name == (*it).name() ) |
594 | return pos + 1; | 601 | return pos + 1; |
595 | 602 | ||
596 | return 0; | 603 | return 0; |
597 | } | 604 | } |
598 | 605 | ||
599 | void ViewManager::initActions() | 606 | void ViewManager::initActions() |
600 | { | 607 | { |
601 | //US <ActionList name="view_loadedviews"/> | 608 | //US <ActionList name="view_loadedviews"/> |
602 | //US <Separator/> | 609 | //US <Separator/> |
603 | 610 | ||
604 | #ifdef KAB_EMBEDDED | 611 | #ifdef KAB_EMBEDDED |
605 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); | 612 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); |
606 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); | 613 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); |
607 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); | 614 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); |
608 | #endif //KAB_EMBEDDED | 615 | #endif //KAB_EMBEDDED |
609 | 616 | ||
610 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); | 617 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); |
611 | #if KDE_VERSION >= 309 | 618 | #if KDE_VERSION >= 309 |
612 | mActionSelectView->setMenuAccelsEnabled( false ); | 619 | mActionSelectView->setMenuAccelsEnabled( false ); |
613 | #endif | 620 | #endif |
614 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), | 621 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), |
615 | SLOT( setActiveView( const QString& ) ) ); | 622 | SLOT( setActiveView( const QString& ) ) ); |
616 | 623 | ||
617 | 624 | ||
618 | #ifdef KAB_EMBEDDED | 625 | #ifdef KAB_EMBEDDED |
619 | mActionSelectView->plug(viewmenu); | 626 | mActionSelectView->plug(viewmenu); |
620 | viewmenu->insertSeparator(); | 627 | viewmenu->insertSeparator(); |
621 | #endif //KAB_EMBEDDED | 628 | #endif //KAB_EMBEDDED |
622 | 629 | ||
623 | KAction *action; | 630 | KAction *action; |
624 | 631 | ||
625 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, | 632 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, |
626 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); | 633 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); |
627 | #ifndef KAB_EMBEDDED | 634 | #ifndef KAB_EMBEDDED |
628 | action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); | 635 | action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); |
629 | #else //KAB_EMBEDDED | 636 | #else //KAB_EMBEDDED |
630 | action->plug(viewmenu); | 637 | action->plug(viewmenu); |
631 | #endif //KAB_EMBEDDED | 638 | #endif //KAB_EMBEDDED |
632 | 639 | ||
633 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, | 640 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, |
634 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); | 641 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); |
635 | #ifndef KAB_EMBEDDED | 642 | #ifndef KAB_EMBEDDED |
636 | action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); | 643 | action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); |
637 | #else //KAB_EMBEDDED | 644 | #else //KAB_EMBEDDED |
638 | action->plug(viewmenu); | 645 | action->plug(viewmenu); |
639 | #endif //KAB_EMBEDDED | 646 | #endif //KAB_EMBEDDED |
640 | 647 | ||
641 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, | 648 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, |
642 | this, SLOT( deleteView() ), | 649 | this, SLOT( deleteView() ), |
643 | mCore->actionCollection(), "view_delete" ); | 650 | mCore->actionCollection(), "view_delete" ); |
644 | #ifndef KAB_EMBEDDED | 651 | #ifndef KAB_EMBEDDED |
645 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); | 652 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); |
646 | #else //KAB_EMBEDDED | 653 | #else //KAB_EMBEDDED |
647 | mActionDeleteView->plug(viewmenu); | 654 | mActionDeleteView->plug(viewmenu); |
648 | viewmenu->insertSeparator(); | 655 | viewmenu->insertSeparator(); |
649 | #endif //KAB_EMBEDDED | 656 | #endif //KAB_EMBEDDED |
650 | 657 | ||
651 | #ifndef KAB_EMBEDDED | 658 | #ifndef KAB_EMBEDDED |
652 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 659 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
653 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), | 660 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), |
654 | "view_refresh" ); | 661 | "view_refresh" ); |
655 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); | 662 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); |
656 | #else //KAB_EMBEDDED | 663 | #else //KAB_EMBEDDED |
657 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 664 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
658 | SLOT( refreshView()), mCore->actionCollection(), | 665 | SLOT( refreshView()), mCore->actionCollection(), |
659 | "view_refresh" ); | 666 | "view_refresh" ); |
660 | action->plug(viewmenu); | 667 | action->plug(viewmenu); |
661 | viewmenu->insertSeparator(); | 668 | viewmenu->insertSeparator(); |
662 | #endif //KAB_EMBEDDED | 669 | #endif //KAB_EMBEDDED |
663 | 670 | ||
664 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, | 671 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, |
665 | SLOT( configureFilters() ), mCore->actionCollection(), | 672 | SLOT( configureFilters() ), mCore->actionCollection(), |
666 | "options_edit_filters" ); | 673 | "options_edit_filters" ); |
667 | 674 | ||
668 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); | 675 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); |
669 | 676 | ||
670 | #if KDE_VERSION >= 309 | 677 | #if KDE_VERSION >= 309 |
671 | mActionSelectFilter->setMenuAccelsEnabled( false ); | 678 | mActionSelectFilter->setMenuAccelsEnabled( false ); |
672 | #endif | 679 | #endif |
673 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), | 680 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), |
674 | SLOT( setActiveFilter( int ) ) ); | 681 | SLOT( setActiveFilter( int ) ) ); |
675 | 682 | ||
676 | #ifdef KAB_EMBEDDED | 683 | #ifdef KAB_EMBEDDED |
677 | action->plug(settingsmenu); | 684 | action->plug(settingsmenu); |
678 | mActionSelectFilter->plug(viewmenu); | 685 | mActionSelectFilter->plug(viewmenu); |
679 | #endif //KAB_EMBEDDED | 686 | #endif //KAB_EMBEDDED |
680 | 687 | ||
681 | } | 688 | } |
682 | 689 | ||
683 | void ViewManager::initGUI() | 690 | void ViewManager::initGUI() |
684 | { | 691 | { |
685 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); | 692 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); |
686 | mViewWidgetStack = new QWidgetStack( this ); | 693 | mViewWidgetStack = new QWidgetStack( this ); |
687 | layout->addWidget( mViewWidgetStack ); | 694 | layout->addWidget( mViewWidgetStack ); |
688 | } | 695 | } |
689 | 696 | ||
690 | #ifndef KAB_EMBEDDED | 697 | #ifndef KAB_EMBEDDED |
691 | #include "viewmanager.moc" | 698 | #include "viewmanager.moc" |
692 | #endif //KAB_EMBEDDED | 699 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h index a18e87d..97c2275 100644 --- a/kaddressbook/viewmanager.h +++ b/kaddressbook/viewmanager.h | |||
@@ -1,152 +1,153 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
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 | #ifndef VIEWMANAGER_H | 24 | #ifndef VIEWMANAGER_H |
25 | #define VIEWMANAGER_H | 25 | #define VIEWMANAGER_H |
26 | 26 | ||
27 | #include <qwidget.h> | 27 | #include <qwidget.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <kaddressbookview.h> | 29 | #include <kaddressbookview.h> |
30 | #include <qdict.h> | 30 | #include <qdict.h> |
31 | 31 | ||
32 | class KAction; | 32 | class KAction; |
33 | class KSelectAction; | 33 | class KSelectAction; |
34 | 34 | ||
35 | class KABCore; | 35 | class KABCore; |
36 | class QWidgetStack; | 36 | class QWidgetStack; |
37 | class QDropEvent; | 37 | class QDropEvent; |
38 | 38 | ||
39 | namespace KABC { class AddressBook; } | 39 | namespace KABC { class AddressBook; } |
40 | 40 | ||
41 | /** | 41 | /** |
42 | The view manager manages the views and everything related to them. The | 42 | The view manager manages the views and everything related to them. The |
43 | manager will load the views at startup and display a view when told to | 43 | manager will load the views at startup and display a view when told to |
44 | make one active. | 44 | make one active. |
45 | 45 | ||
46 | The view manager will also create and manage all dialogs directly related to | 46 | The view manager will also create and manage all dialogs directly related to |
47 | views (ie: AddView, ConfigureView, DeleteView, etc). | 47 | views (ie: AddView, ConfigureView, DeleteView, etc). |
48 | */ | 48 | */ |
49 | class ViewManager : public QWidget | 49 | class ViewManager : public QWidget |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); | 53 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); |
54 | ~ViewManager(); | 54 | ~ViewManager(); |
55 | 55 | ||
56 | void restoreSettings(); | 56 | void restoreSettings(); |
57 | void saveSettings(); | 57 | void saveSettings(); |
58 | 58 | ||
59 | void unloadViews(); | 59 | void unloadViews(); |
60 | KSelectAction * getFilterAction() { return mActionSelectFilter; } | 60 | KSelectAction * getFilterAction() { return mActionSelectFilter; } |
61 | 61 | ||
62 | QStringList selectedUids() const; | 62 | QStringList selectedUids() const; |
63 | QStringList selectedEmails() const; | 63 | QStringList selectedEmails() const; |
64 | KABC::Addressee::List selectedAddressees() const; | 64 | KABC::Addressee::List selectedAddressees() const; |
65 | void setListSelected(QStringList); | ||
65 | 66 | ||
66 | public slots: | 67 | public slots: |
67 | 68 | ||
68 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); | 69 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); |
69 | void setSelected( const QString &uid, bool); | 70 | void setSelected( const QString &uid, bool); |
70 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 71 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
71 | void setSelected(); | 72 | void setSelected(); |
72 | 73 | ||
73 | 74 | ||
74 | 75 | ||
75 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 76 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
76 | void refreshView(); | 77 | void refreshView(); |
77 | void refreshView( const QString &uid); | 78 | void refreshView( const QString &uid); |
78 | 79 | ||
79 | void editView(); | 80 | void editView(); |
80 | void deleteView(); | 81 | void deleteView(); |
81 | void addView(); | 82 | void addView(); |
82 | 83 | ||
83 | protected slots: | 84 | protected slots: |
84 | /** | 85 | /** |
85 | Called whenever the user drops something in the active view. | 86 | Called whenever the user drops something in the active view. |
86 | This method will try to decode what was dropped, and if it was | 87 | This method will try to decode what was dropped, and if it was |
87 | a valid addressee, add it to the addressbook. | 88 | a valid addressee, add it to the addressbook. |
88 | */ | 89 | */ |
89 | void dropped( QDropEvent* ); | 90 | void dropped( QDropEvent* ); |
90 | 91 | ||
91 | /** | 92 | /** |
92 | Called whenever the user attempts to start a drag in the view. | 93 | Called whenever the user attempts to start a drag in the view. |
93 | This method will convert all the selected addressees into text (vcard) | 94 | This method will convert all the selected addressees into text (vcard) |
94 | and create a drag object. | 95 | and create a drag object. |
95 | */ | 96 | */ |
96 | void startDrag(); | 97 | void startDrag(); |
97 | 98 | ||
98 | signals: | 99 | signals: |
99 | /** | 100 | /** |
100 | Emitted whenever the user selects an entry in the view. | 101 | Emitted whenever the user selects an entry in the view. |
101 | */ | 102 | */ |
102 | void selected( const QString &uid ); | 103 | void selected( const QString &uid ); |
103 | void deleteRequest( ); | 104 | void deleteRequest( ); |
104 | 105 | ||
105 | /** | 106 | /** |
106 | Emitted whenever the user activates an entry in the view. | 107 | Emitted whenever the user activates an entry in the view. |
107 | */ | 108 | */ |
108 | void executed( const QString &uid ); | 109 | void executed( const QString &uid ); |
109 | 110 | ||
110 | /** | 111 | /** |
111 | Emitted whenever the address book is modified in some way. | 112 | Emitted whenever the address book is modified in some way. |
112 | */ | 113 | */ |
113 | void modified(); | 114 | void modified(); |
114 | 115 | ||
115 | /** | 116 | /** |
116 | Emitted whenever a url is dragged on a view. | 117 | Emitted whenever a url is dragged on a view. |
117 | */ | 118 | */ |
118 | void urlDropped( const KURL& ); | 119 | void urlDropped( const KURL& ); |
119 | 120 | ||
120 | private slots: | 121 | private slots: |
121 | void setActiveView( const QString &name ); | 122 | void setActiveView( const QString &name ); |
122 | void setActiveFilter( int index ); | 123 | void setActiveFilter( int index ); |
123 | void configureFilters(); | 124 | void configureFilters(); |
124 | 125 | ||
125 | private: | 126 | private: |
126 | void createViewFactories(); | 127 | void createViewFactories(); |
127 | QStringList filterNames() const; | 128 | QStringList filterNames() const; |
128 | int filterPosition( const QString &name ) const; | 129 | int filterPosition( const QString &name ) const; |
129 | QStringList viewNames() const; | 130 | QStringList viewNames() const; |
130 | int viewPosition( const QString &name ) const; | 131 | int viewPosition( const QString &name ) const; |
131 | void initActions(); | 132 | void initActions(); |
132 | void initGUI(); | 133 | void initGUI(); |
133 | 134 | ||
134 | KABCore *mCore; | 135 | KABCore *mCore; |
135 | 136 | ||
136 | Filter mCurrentFilter; | 137 | Filter mCurrentFilter; |
137 | Filter::List mFilterList; | 138 | Filter::List mFilterList; |
138 | 139 | ||
139 | QDict<KAddressBookView> mViewDict; | 140 | QDict<KAddressBookView> mViewDict; |
140 | QDict<ViewFactory> mViewFactoryDict; | 141 | QDict<ViewFactory> mViewFactoryDict; |
141 | QStringList mViewNameList; | 142 | QStringList mViewNameList; |
142 | 143 | ||
143 | QWidgetStack *mViewWidgetStack; | 144 | QWidgetStack *mViewWidgetStack; |
144 | KAddressBookView *mActiveView; | 145 | KAddressBookView *mActiveView; |
145 | 146 | ||
146 | KAction *mActionDeleteView; | 147 | KAction *mActionDeleteView; |
147 | KSelectAction *mActionSelectFilter; | 148 | KSelectAction *mActionSelectFilter; |
148 | KSelectAction *mActionSelectView; | 149 | KSelectAction *mActionSelectView; |
149 | 150 | ||
150 | }; | 151 | }; |
151 | 152 | ||
152 | #endif | 153 | #endif |
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 66a3f0b..0847b64 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -1,382 +1,382 @@ | |||
1 | // $Id$ | 1 | // $Id$ |
2 | 2 | ||
3 | #include <qvbox.h> | 3 | #include <qvbox.h> |
4 | #include <qlistbox.h> | 4 | #include <qlistbox.h> |
5 | #include <qwidget.h> | 5 | #include <qwidget.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | #include <qimage.h> | 7 | #include <qimage.h> |
8 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
9 | #include <qapplication.h> | 9 | #include <qapplication.h> |
10 | #include <qdragobject.h> | 10 | #include <qdragobject.h> |
11 | #include <qevent.h> | 11 | #include <qevent.h> |
12 | #include <qurl.h> | 12 | #include <qurl.h> |
13 | #include <qpixmap.h> | 13 | #include <qpixmap.h> |
14 | 14 | ||
15 | #include <kabc/addressbook.h> | 15 | #include <kabc/addressbook.h> |
16 | #include <kapplication.h> | 16 | #include <kapplication.h> |
17 | #include <kconfig.h> | 17 | #include <kconfig.h> |
18 | #include <kcolorbutton.h> | 18 | #include <kcolorbutton.h> |
19 | #include <kdebug.h> | 19 | #include <kdebug.h> |
20 | #include <kglobal.h> | 20 | #include <kglobal.h> |
21 | #include <kiconloader.h> | 21 | #include <kiconloader.h> |
22 | #include <klineedit.h> | 22 | #include <klineedit.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kmessagebox.h> | 24 | #include <kmessagebox.h> |
25 | #include <kurl.h> | 25 | #include <kurl.h> |
26 | #include <kurlrequester.h> | 26 | #include <kurlrequester.h> |
27 | 27 | ||
28 | //US#include "configuretableviewdialog.h" | 28 | //US#include "configuretableviewdialog.h" |
29 | #include "contactlistview.h" | 29 | #include "contactlistview.h" |
30 | #include "kabprefs.h" | 30 | #include "kabprefs.h" |
31 | #include "undocmds.h" | 31 | #include "undocmds.h" |
32 | #include "viewmanager.h" | 32 | #include "viewmanager.h" |
33 | 33 | ||
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | 35 | ||
36 | 36 | ||
37 | #include "kaddressbooktableview.h" | 37 | #include "kaddressbooktableview.h" |
38 | 38 | ||
39 | 39 | ||
40 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, | 40 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, |
41 | QWidget *parent, const char *name ) | 41 | QWidget *parent, const char *name ) |
42 | : KAddressBookView( ab, parent, name ) | 42 | : KAddressBookView( ab, parent, name ) |
43 | { | 43 | { |
44 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); | 44 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); |
45 | 45 | ||
46 | // The list view will be created when the config is read. | 46 | // The list view will be created when the config is read. |
47 | mListView = 0; | 47 | mListView = 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | KAddressBookTableView::~KAddressBookTableView() | 50 | KAddressBookTableView::~KAddressBookTableView() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | void KAddressBookTableView::reconstructListView() | 54 | void KAddressBookTableView::reconstructListView() |
55 | { | 55 | { |
56 | if (mListView) | 56 | if (mListView) |
57 | { | 57 | { |
58 | disconnect(mListView, SIGNAL(selectionChanged()), | 58 | disconnect(mListView, SIGNAL(selectionChanged()), |
59 | this, SLOT(addresseeSelected())); | 59 | this, SLOT(addresseeSelected())); |
60 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), | 60 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), |
61 | this, SLOT(addresseeExecuted(QListViewItem*))); | 61 | this, SLOT(addresseeExecuted(QListViewItem*))); |
62 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 62 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
63 | this, SLOT(addresseeExecuted(QListViewItem*))); | 63 | this, SLOT(addresseeExecuted(QListViewItem*))); |
64 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, | 64 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, |
65 | SIGNAL(startDrag())); | 65 | SIGNAL(startDrag())); |
66 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 66 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
67 | this, SLOT(addresseeExecuted(QListViewItem*))); | 67 | this, SLOT(addresseeExecuted(QListViewItem*))); |
68 | 68 | ||
69 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 69 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
70 | SIGNAL(dropped(QDropEvent*))); | 70 | SIGNAL(dropped(QDropEvent*))); |
71 | delete mListView; | 71 | delete mListView; |
72 | } | 72 | } |
73 | 73 | ||
74 | mListView = new ContactListView( this, addressBook(), viewWidget() ); | 74 | mListView = new ContactListView( this, addressBook(), viewWidget() ); |
75 | 75 | ||
76 | // Add the columns | 76 | // Add the columns |
77 | KABC::Field::List fieldList = fields(); | 77 | KABC::Field::List fieldList = fields(); |
78 | KABC::Field::List::ConstIterator it; | 78 | KABC::Field::List::ConstIterator it; |
79 | 79 | ||
80 | int c = 0; | 80 | int c = 0; |
81 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { | 81 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { |
82 | mListView->addColumn( (*it)->label() ); | 82 | mListView->addColumn( (*it)->label() ); |
83 | mListView->setColumnWidthMode(c++, QListView::Manual); | 83 | mListView->setColumnWidthMode(c++, QListView::Manual); |
84 | //US | 84 | //US |
85 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); | 85 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); |
86 | } | 86 | } |
87 | 87 | ||
88 | connect(mListView, SIGNAL(selectionChanged()), | 88 | connect(mListView, SIGNAL(selectionChanged()), |
89 | this, SLOT(addresseeSelected())); | 89 | this, SLOT(addresseeSelected())); |
90 | connect(mListView, SIGNAL(startAddresseeDrag()), this, | 90 | connect(mListView, SIGNAL(startAddresseeDrag()), this, |
91 | SIGNAL(startDrag())); | 91 | SIGNAL(startDrag())); |
92 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 92 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
93 | SIGNAL(dropped(QDropEvent*))); | 93 | SIGNAL(dropped(QDropEvent*))); |
94 | 94 | ||
95 | if (KABPrefs::instance()->mHonorSingleClick) | 95 | if (KABPrefs::instance()->mHonorSingleClick) |
96 | connect(mListView, SIGNAL(executed(QListViewItem*)), | 96 | connect(mListView, SIGNAL(executed(QListViewItem*)), |
97 | this, SLOT(addresseeExecuted(QListViewItem*))); | 97 | this, SLOT(addresseeExecuted(QListViewItem*))); |
98 | else | 98 | else |
99 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 99 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
100 | this, SLOT(addresseeExecuted(QListViewItem*))); | 100 | this, SLOT(addresseeExecuted(QListViewItem*))); |
101 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 101 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
102 | this, SLOT(addresseeExecuted(QListViewItem*))); | 102 | this, SLOT(addresseeExecuted(QListViewItem*))); |
103 | connect(mListView, SIGNAL(signalDelete()), | 103 | connect(mListView, SIGNAL(signalDelete()), |
104 | this, SLOT(addresseeDeleted())); | 104 | this, SLOT(addresseeDeleted())); |
105 | 105 | ||
106 | //US performceimprovement. Refresh is done from the outside | 106 | //US performceimprovement. Refresh is done from the outside |
107 | //US refresh(); | 107 | //US refresh(); |
108 | 108 | ||
109 | mListView->setSorting( 0, true ); | 109 | mListView->setSorting( 0, true ); |
110 | mainLayout->addWidget( mListView ); | 110 | mainLayout->addWidget( mListView ); |
111 | mainLayout->activate(); | 111 | mainLayout->activate(); |
112 | mListView->show(); | 112 | mListView->show(); |
113 | } | 113 | } |
114 | 114 | ||
115 | void KAddressBookTableView::writeConfig(KConfig *config) | 115 | void KAddressBookTableView::writeConfig(KConfig *config) |
116 | { | 116 | { |
117 | KAddressBookView::writeConfig(config); | 117 | KAddressBookView::writeConfig(config); |
118 | 118 | ||
119 | mListView->saveLayout(config, config->group()); | 119 | mListView->saveLayout(config, config->group()); |
120 | } | 120 | } |
121 | 121 | ||
122 | void KAddressBookTableView::readConfig(KConfig *config) | 122 | void KAddressBookTableView::readConfig(KConfig *config) |
123 | { | 123 | { |
124 | KAddressBookView::readConfig( config ); | 124 | KAddressBookView::readConfig( config ); |
125 | // The config could have changed the fields, so we need to reconstruct | ||
126 | // the listview. | ||
127 | reconstructListView(); | ||
125 | 128 | ||
126 | // costum colors? | 129 | // costum colors? |
127 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 130 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
128 | { | 131 | { |
129 | QPalette p( mListView->palette() ); | 132 | QPalette p( mListView->palette() ); |
130 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 133 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
131 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 134 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
132 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 135 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
133 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 136 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
134 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 137 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
135 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 138 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
136 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 139 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
137 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 140 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
138 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 141 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
139 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 142 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
140 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 143 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
141 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 144 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
142 | c = p.color(QPalette::Normal, QColorGroup::Base ); | 145 | c = p.color(QPalette::Normal, QColorGroup::Base ); |
143 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "AlternatingBackgroundColor", &c ) ); | 146 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "AlternatingBackgroundColor", &c ) ); |
144 | mListView->viewport()->setPalette( p ); | 147 | mListView->viewport()->setPalette( p ); |
145 | } | 148 | } |
146 | else | 149 | else |
147 | { | 150 | { |
148 | // needed if turned off during a session. | 151 | // needed if turned off during a session. |
149 | mListView->viewport()->setPalette( mListView->palette() ); | 152 | mListView->viewport()->setPalette( mListView->palette() ); |
150 | } | 153 | } |
151 | 154 | ||
152 | //custom fonts? | 155 | //custom fonts? |
153 | QFont f( font() ); | 156 | QFont f( font() ); |
154 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 157 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
155 | { | 158 | { |
156 | // mListView->setFont( config->readFontEntry( "TextFont", &f) ); | 159 | // mListView->setFont( config->readFontEntry( "TextFont", &f) ); |
157 | f.setBold( true ); | 160 | f.setBold( true ); |
158 | // mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 161 | // mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
159 | } | 162 | } |
160 | else | 163 | else |
161 | { | 164 | { |
162 | // mListView->setFont( f ); | 165 | // mListView->setFont( f ); |
163 | f.setBold( true ); | 166 | f.setBold( true ); |
164 | // mListView->setHeaderFont( f ); | 167 | // mListView->setHeaderFont( f ); |
165 | } | 168 | } |
166 | 169 | ||
167 | 170 | ||
168 | 171 | ||
169 | 172 | ||
170 | // The config could have changed the fields, so we need to reconstruct | ||
171 | // the listview. | ||
172 | reconstructListView(); | ||
173 | 173 | ||
174 | // Set the list view options | 174 | // Set the list view options |
175 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", | 175 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", |
176 | true)); | 176 | true)); |
177 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); | 177 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); |
178 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); | 178 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); |
179 | 179 | ||
180 | if (config->readBoolEntry("Background", false)) | 180 | if (config->readBoolEntry("Background", false)) |
181 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); | 181 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); |
182 | 182 | ||
183 | // Restore the layout of the listview | 183 | // Restore the layout of the listview |
184 | mListView->restoreLayout(config, config->group()); | 184 | mListView->restoreLayout(config, config->group()); |
185 | } | 185 | } |
186 | 186 | ||
187 | void KAddressBookTableView::refresh(QString uid) | 187 | void KAddressBookTableView::refresh(QString uid) |
188 | { | 188 | { |
189 | // For now just repopulate. In reality this method should | 189 | // For now just repopulate. In reality this method should |
190 | // check the value of uid, and if valid iterate through | 190 | // check the value of uid, and if valid iterate through |
191 | // the listview to find the entry, then tell it to refresh. | 191 | // the listview to find the entry, then tell it to refresh. |
192 | 192 | ||
193 | if (uid.isNull()) { | 193 | if (uid.isNull()) { |
194 | // Clear the list view | 194 | // Clear the list view |
195 | QString currentUID, nextUID; | 195 | QString currentUID, nextUID; |
196 | #ifndef KAB_EMBEDDED | 196 | #ifndef KAB_EMBEDDED |
197 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); | 197 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); |
198 | #else //KAB_EMBEDDED | 198 | #else //KAB_EMBEDDED |
199 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); | 199 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |
200 | #endif //KAB_EMBEDDED | 200 | #endif //KAB_EMBEDDED |
201 | 201 | ||
202 | if ( currentItem ) { | 202 | if ( currentItem ) { |
203 | #ifndef KAB_EMBEDDED | 203 | #ifndef KAB_EMBEDDED |
204 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); | 204 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); |
205 | #else //KAB_EMBEDDED | 205 | #else //KAB_EMBEDDED |
206 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); | 206 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); |
207 | #endif //KAB_EMBEDDED | 207 | #endif //KAB_EMBEDDED |
208 | if ( nextItem ) | 208 | if ( nextItem ) |
209 | nextUID = nextItem->addressee().uid(); | 209 | nextUID = nextItem->addressee().uid(); |
210 | currentUID = currentItem->addressee().uid(); | 210 | currentUID = currentItem->addressee().uid(); |
211 | } | 211 | } |
212 | 212 | ||
213 | mListView->clear(); | 213 | mListView->clear(); |
214 | 214 | ||
215 | currentItem = 0; | 215 | currentItem = 0; |
216 | KABC::Addressee::List addresseeList = addressees(); | 216 | KABC::Addressee::List addresseeList = addressees(); |
217 | KABC::Addressee::List::Iterator it; | 217 | KABC::Addressee::List::Iterator it; |
218 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 218 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
219 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 219 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
220 | if ( (*it).uid() == currentUID ) | 220 | if ( (*it).uid() == currentUID ) |
221 | currentItem = item; | 221 | currentItem = item; |
222 | else if ( (*it).uid() == nextUID && !currentItem ) | 222 | else if ( (*it).uid() == nextUID && !currentItem ) |
223 | currentItem = item; | 223 | currentItem = item; |
224 | } | 224 | } |
225 | 225 | ||
226 | // Sometimes the background pixmap gets messed up when we add lots | 226 | // Sometimes the background pixmap gets messed up when we add lots |
227 | // of items. | 227 | // of items. |
228 | mListView->repaint(); | 228 | mListView->repaint(); |
229 | 229 | ||
230 | if ( currentItem ) { | 230 | if ( currentItem ) { |
231 | mListView->setCurrentItem( currentItem ); | 231 | mListView->setCurrentItem( currentItem ); |
232 | mListView->ensureItemVisible( currentItem ); | 232 | mListView->ensureItemVisible( currentItem ); |
233 | } | 233 | } |
234 | } else { | 234 | } else { |
235 | // Only need to update on entry. Iterate through and try to find it | 235 | // Only need to update on entry. Iterate through and try to find it |
236 | ContactListViewItem *ceItem; | 236 | ContactListViewItem *ceItem; |
237 | QListViewItemIterator it( mListView ); | 237 | QListViewItemIterator it( mListView ); |
238 | while ( it.current() ) { | 238 | while ( it.current() ) { |
239 | #ifndef KAB_EMBEDDED | 239 | #ifndef KAB_EMBEDDED |
240 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); | 240 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); |
241 | #else //KAB_EMBEDDED | 241 | #else //KAB_EMBEDDED |
242 | ceItem = (ContactListViewItem*)( it.current() ); | 242 | ceItem = (ContactListViewItem*)( it.current() ); |
243 | #endif //KAB_EMBEDDED | 243 | #endif //KAB_EMBEDDED |
244 | 244 | ||
245 | if ( ceItem && ceItem->addressee().uid() == uid ) { | 245 | if ( ceItem && ceItem->addressee().uid() == uid ) { |
246 | ceItem->refresh(); | 246 | ceItem->refresh(); |
247 | return; | 247 | return; |
248 | } | 248 | } |
249 | ++it; | 249 | ++it; |
250 | } | 250 | } |
251 | 251 | ||
252 | refresh( QString::null ); | 252 | refresh( QString::null ); |
253 | } | 253 | } |
254 | } | 254 | } |
255 | 255 | ||
256 | QStringList KAddressBookTableView::selectedUids() | 256 | QStringList KAddressBookTableView::selectedUids() |
257 | { | 257 | { |
258 | QStringList uidList; | 258 | QStringList uidList; |
259 | QListViewItem *item; | 259 | QListViewItem *item; |
260 | ContactListViewItem *ceItem; | 260 | ContactListViewItem *ceItem; |
261 | 261 | ||
262 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 262 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
263 | { | 263 | { |
264 | if (mListView->isSelected( item )) | 264 | if (mListView->isSelected( item )) |
265 | { | 265 | { |
266 | #ifndef KAB_EMBEDDED | 266 | #ifndef KAB_EMBEDDED |
267 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 267 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
268 | #else //KAB_EMBEDDED | 268 | #else //KAB_EMBEDDED |
269 | ceItem = (ContactListViewItem*)(item); | 269 | ceItem = (ContactListViewItem*)(item); |
270 | #endif //KAB_EMBEDDED | 270 | #endif //KAB_EMBEDDED |
271 | 271 | ||
272 | if (ceItem != 0L) | 272 | if (ceItem != 0L) |
273 | uidList << ceItem->addressee().uid(); | 273 | uidList << ceItem->addressee().uid(); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | if ( uidList.count() == 0 ) | 276 | if ( uidList.count() == 0 ) |
277 | if ( mListView->currentItem() ) { | 277 | if ( mListView->currentItem() ) { |
278 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; | 278 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; |
279 | uidList << ceItem->addressee().uid(); | 279 | uidList << ceItem->addressee().uid(); |
280 | } | 280 | } |
281 | 281 | ||
282 | return uidList; | 282 | return uidList; |
283 | } | 283 | } |
284 | 284 | ||
285 | void KAddressBookTableView::setSelected(QString uid, bool selected) | 285 | void KAddressBookTableView::setSelected(QString uid, bool selected) |
286 | { | 286 | { |
287 | QListViewItem *item; | 287 | QListViewItem *item; |
288 | ContactListViewItem *ceItem; | 288 | ContactListViewItem *ceItem; |
289 | 289 | ||
290 | if (uid.isNull()) | 290 | if (uid.isNull()) |
291 | { | 291 | { |
292 | mListView->selectAll(selected); | 292 | mListView->selectAll(selected); |
293 | } | 293 | } |
294 | else | 294 | else |
295 | { | 295 | { |
296 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 296 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
297 | { | 297 | { |
298 | #ifndef KAB_EMBEDDED | 298 | #ifndef KAB_EMBEDDED |
299 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 299 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
300 | #else //KAB_EMBEDDED | 300 | #else //KAB_EMBEDDED |
301 | ceItem = (ContactListViewItem*)(item); | 301 | ceItem = (ContactListViewItem*)(item); |
302 | #endif //KAB_EMBEDDED | 302 | #endif //KAB_EMBEDDED |
303 | 303 | ||
304 | 304 | ||
305 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) | 305 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) |
306 | { | 306 | { |
307 | mListView->setSelected(item, selected); | 307 | mListView->setSelected(item, selected); |
308 | 308 | ||
309 | if (selected) | 309 | if (selected) |
310 | mListView->ensureItemVisible(item); | 310 | mListView->ensureItemVisible(item); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | void KAddressBookTableView::addresseeSelected() | 316 | void KAddressBookTableView::addresseeSelected() |
317 | { | 317 | { |
318 | // We need to try to find the first selected item. This might not be the | 318 | // We need to try to find the first selected item. This might not be the |
319 | // last selected item, but when QListView is in multiselection mode, | 319 | // last selected item, but when QListView is in multiselection mode, |
320 | // there is no way to figure out which one was | 320 | // there is no way to figure out which one was |
321 | // selected last. | 321 | // selected last. |
322 | QListViewItem *item; | 322 | QListViewItem *item; |
323 | bool found =false; | 323 | bool found =false; |
324 | for (item = mListView->firstChild(); item && !found; | 324 | for (item = mListView->firstChild(); item && !found; |
325 | item = item->nextSibling()) | 325 | item = item->nextSibling()) |
326 | { | 326 | { |
327 | if (item->isSelected()) | 327 | if (item->isSelected()) |
328 | { | 328 | { |
329 | found = true; | 329 | found = true; |
330 | #ifndef KAB_EMBEDDED | 330 | #ifndef KAB_EMBEDDED |
331 | ContactListViewItem *ceItem | 331 | ContactListViewItem *ceItem |
332 | = dynamic_cast<ContactListViewItem*>(item); | 332 | = dynamic_cast<ContactListViewItem*>(item); |
333 | #else //KAB_EMBEDDED | 333 | #else //KAB_EMBEDDED |
334 | ContactListViewItem *ceItem | 334 | ContactListViewItem *ceItem |
335 | = (ContactListViewItem*)(item); | 335 | = (ContactListViewItem*)(item); |
336 | #endif //KAB_EMBEDDED | 336 | #endif //KAB_EMBEDDED |
337 | 337 | ||
338 | if ( ceItem ) emit selected(ceItem->addressee().uid()); | 338 | if ( ceItem ) emit selected(ceItem->addressee().uid()); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | if (!found) | 342 | if (!found) |
343 | emit selected(QString::null); | 343 | emit selected(QString::null); |
344 | } | 344 | } |
345 | 345 | ||
346 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) | 346 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) |
347 | { | 347 | { |
348 | if (item) | 348 | if (item) |
349 | { | 349 | { |
350 | #ifndef KAB_EMBEDDED | 350 | #ifndef KAB_EMBEDDED |
351 | ContactListViewItem *ceItem | 351 | ContactListViewItem *ceItem |
352 | = dynamic_cast<ContactListViewItem*>(item); | 352 | = dynamic_cast<ContactListViewItem*>(item); |
353 | #else //KAB_EMBEDDED | 353 | #else //KAB_EMBEDDED |
354 | ContactListViewItem *ceItem | 354 | ContactListViewItem *ceItem |
355 | = (ContactListViewItem*)(item); | 355 | = (ContactListViewItem*)(item); |
356 | #endif //KAB_EMBEDDED | 356 | #endif //KAB_EMBEDDED |
357 | 357 | ||
358 | if (ceItem) | 358 | if (ceItem) |
359 | { | 359 | { |
360 | emit executed(ceItem->addressee().uid()); | 360 | emit executed(ceItem->addressee().uid()); |
361 | } | 361 | } |
362 | } | 362 | } |
363 | else | 363 | else |
364 | { | 364 | { |
365 | emit executed(QString::null); | 365 | emit executed(QString::null); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | void KAddressBookTableView::addresseeDeleted() | 369 | void KAddressBookTableView::addresseeDeleted() |
370 | { | 370 | { |
371 | 371 | ||
372 | emit deleteRequest(); | 372 | emit deleteRequest(); |
373 | 373 | ||
374 | } | 374 | } |
375 | 375 | ||
376 | 376 | ||
377 | 377 | ||
378 | 378 | ||
379 | 379 | ||
380 | #ifndef KAB_EMBEDDED | 380 | #ifndef KAB_EMBEDDED |
381 | #include "kaddressbooktableview.moc" | 381 | #include "kaddressbooktableview.moc" |
382 | #endif //KAB_EMBEDDED | 382 | #endif //KAB_EMBEDDED |